Skip to content
  • Tejun Heo's avatar
    cgroup: make cgroup_path() and friends behave in the style of strlcpy() · 4c737b41
    Tejun Heo authored
    
    
    cgroup_path() and friends used to format the path from the end and
    thus the resulting path usually didn't start at the start of the
    passed in buffer.  Also, when the buffer was too small, the partial
    result was truncated from the head rather than tail and there was no
    way to tell how long the full path would be.  These make the functions
    less robust and more awkward to use.
    
    With recent updates to kernfs_path(), cgroup_path() and friends can be
    made to behave in strlcpy() style.
    
    * cgroup_path(), cgroup_path_ns[_locked]() and task_cgroup_path() now
      always return the length of the full path.  If buffer is too small,
      it contains nul terminated truncated output.
    
    * All users updated accordingly.
    
    v2: cgroup_path() usage in kernel/sched/debug.c converted.
    
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Serge Hallyn <serge.hallyn@ubuntu.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    4c737b41