sysfs: make __sysfs_remove_dir() recursive
authorTejun Heo <tj@kernel.org>
Wed, 18 Sep 2013 21:15:37 +0000 (17:15 -0400)
committerMaciej Wereski <m.wereski@partner.samsung.com>
Tue, 9 Jun 2015 09:31:11 +0000 (11:31 +0200)
commit2f09f3a9b164159151db3a55248307a2c964bbc5
tree0817dc58eeee9db2248615c6b0d4165fb6eb2f6c
parent7770977c35f7500a19a29f03152092edde0e2c6b
sysfs: make __sysfs_remove_dir() recursive

Currently, sysfs directory removal is inconsistent in that it would
remove any files directly under it but wouldn't recurse into
directories.  Thanks to group subdirectories, this doesn't even match
with kobject boundaries.  sysfs is in the process of being separated
out so that it can be used by multiple subsystems and we want to have
a consistent behavior - either removal of a sysfs_dirent should remove
every descendant entries or none instead of something inbetween.

This patch implements proper recursive removal in
__sysfs_remove_dir().  The function now walks its subtree in a
post-order walk to remove all descendants.

This is a behavior change but kobject / driver layer, which currently
is the only consumer, has already been updated to handle duplicate
removal attempts, so nothing should be broken after this change.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/sysfs/dir.c