All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: ebiederm@xmission.com, cornelia.huck@de.ibm.com, greg@kroah.com,
	stern@rowland.harvard.edu, kay.sievers@vrfy.org,
	linux-kernel@vger.kernel.org, htejun@gmail.com
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 4/8] sysfs: implement symlink auto-removal
Date: Thu, 20 Sep 2007 17:31:38 +0900	[thread overview]
Message-ID: <11902770982552-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11902770971822-git-send-email-htejun@gmail.com>

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 <htejun@gmail.com>
---
 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



  parent reply	other threads:[~2007-09-20  8:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-20  8:31 [PATCHSET 4/4] sysfs: implement new features Tejun Heo
2007-09-20  8:31 ` [PATCH 1/8] sysfs: notify file on deactivation Tejun Heo
2007-09-20  8:31 ` [PATCH 2/8] sysfs: add name formatting support for symlinks Tejun Heo
2007-09-20  8:31 ` [PATCH 6/8] sysfs: implement plugged creation of sysfs nodes Tejun Heo
2007-09-20  8:31 ` Tejun Heo [this message]
2007-09-20  8:31 ` [PATCH 5/8] sysfs: implement symlink auto-rename Tejun Heo
2007-09-20  8:31 ` [PATCH 7/8] sysfs: implement batch error handling Tejun Heo
2007-09-20  8:31 ` [PATCH 3/8] sysfs: chain symlinks to their targets Tejun Heo
2007-09-20  8:31 ` [PATCH 8/8] sysfs: add copyrights Tejun Heo
2007-09-25 22:50 ` [PATCHSET 4/4] sysfs: implement new features Greg KH
2007-09-27 12:24   ` Tejun Heo
2007-09-27 22:38   ` Kyle Moffett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11902770982552-git-send-email-htejun@gmail.com \
    --to=htejun@gmail.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=ebiederm@xmission.com \
    --cc=greg@kroah.com \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.