[PATCH 4/8] sysfs: implement symlink auto-removal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When a sysfs_node is removed, automatically remove all symlinks
pointing to it together.

Note that as links created with kobject based sysfs_create_link()
aren't chained on its target, they aren't removed automatically.  This
is for backward compatibility.

Signed-off-by: Tejun Heo <[email protected]>
---
 fs/sysfs/dir.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index bb9e87e..4a04cb4 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -956,6 +956,12 @@ void __sysfs_remove(struct sysfs_dirent *sd, int recurse)
 		    (sysfs_type(cur) == SYSFS_DIR || cur->s_parent != sd))
 			continue;
 
+		/* kill all symlinks pointing to @cur */
+		if (sysfs_type(cur) == SYSFS_DIR)
+			while (cur->s_dir.links)
+				sysfs_remove_one(&acxt, cur->s_dir.links);
+
+		/* kill @cur */
 		sysfs_remove_one(&acxt, cur);
 	} while ((cur = next));
 
-- 
1.5.0.3


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux