lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 20 Sep 2007 17:31:38 +0900
From:	Tejun Heo <htejun@...il.com>
To:	ebiederm@...ssion.com, cornelia.huck@...ibm.com, greg@...ah.com,
	stern@...land.harvard.edu, kay.sievers@...y.org,
	linux-kernel@...r.kernel.org, htejun@...il.com
Cc:	Tejun Heo <htejun@...il.com>
Subject: [PATCH 5/8] sysfs: implement symlink auto-rename

When a sysfs_node or one of its ancestors is renamed, automatically
rename symlinks pointing to it according to the name format together.

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

Signed-off-by: Tejun Heo <htejun@...il.com>
---
 fs/sysfs/dir.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 4a04cb4..eac8fef 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -1196,6 +1196,7 @@ static int sysfs_prep_rename(struct sysfs_rename_context *rcxt,
 {
 	struct sysfs_rcxt_rename_ent *rent;
 	struct sysfs_rcxt_mutex_ent *ment;
+	struct sysfs_dirent *cur;
 	int rc;
 
 	INIT_LIST_HEAD(&rcxt->mutexes);
@@ -1220,6 +1221,50 @@ static int sysfs_prep_rename(struct sysfs_rename_context *rcxt,
 		goto err;
 
 	/*
+	 * prep links pointing to @sd and its children
+	 */
+	cur = NULL;
+	while ((cur = sysfs_tree_walk_next(sd, cur))) {
+		struct sysfs_dirent *link;
+
+		if (sysfs_type(cur) != SYSFS_DIR)
+			continue;
+
+		for (link = cur->s_dir.links; link; link = link->s_link.next) {
+			const char *link_new_name;
+			int copied;
+
+			rc = sysfs_link_name(link->s_link.name_fmt,
+					     link->s_link.target,
+					     &link_new_name,
+					     sd, new_parent, new_name);
+			if (rc < 0)
+				goto err;
+			copied = rc;
+
+			if (!strcmp(link->s_name, link_new_name)) {
+				if (copied)
+					kfree(link_new_name);
+				continue;
+			}
+
+			rc = -ENOMEM;
+			rent = sysfs_rcxt_add(rcxt, link, link->s_parent);
+			if (!rent) {
+				mutex_unlock(&sysfs_mutex);
+				goto err;
+			}
+
+			rent->new_name = link_new_name;
+			rent->new_name_copied = copied;
+
+			rc = sysfs_rcxt_get_dentries(rcxt, rent);
+			if (rc)
+				goto err;
+		}
+	}
+
+	/*
 	 * lock all i_mutexes
 	 */
  try_lock:
-- 
1.5.0.3


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ