All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maneesh Soni <maneesh@in.ibm.com>
To: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>,
	Greg KH <greg@kroah.com>, Patrick Mochel <mochel@osdl.org>,
	Christian Borntraeger <CBORNTRA@de.ibm.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Dipankar Sarma <dipankar@in.ibm.com>
Subject: Re: [RFC 5/5] sysfs-symlink.patch
Date: Wed, 12 Nov 2003 17:56:47 +0530	[thread overview]
Message-ID: <20031112122647.GI14580@in.ibm.com> (raw)
In-Reply-To: <20031112122615.GH14580@in.ibm.com>



o This patch creates symlink kobject. We don't create the symlink in sysfs
  when sysfs_create_symlink() is called but just allocates one sysfs_dirent 
  of type SYSFS_KOBJ_LINK. The s_element for symlinks is an array of two
  strings, one prepresenting the name of the link and another patch of 
  the target of the link.


 fs/sysfs/symlink.c |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diff -puN fs/sysfs/symlink.c~sysfs-symlink fs/sysfs/symlink.c
--- linux-2.6.0-test9/fs/sysfs/symlink.c~sysfs-symlink	2003-11-12 15:26:34.000000000 +0530
+++ linux-2.6.0-test9-maneesh/fs/sysfs/symlink.c	2003-11-12 15:26:53.000000000 +0530
@@ -15,7 +15,7 @@ static int init_symlink(struct inode * i
 	return 0;
 }
 
-static int sysfs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
+int sysfs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
 {
 	int error;
 
@@ -71,13 +71,12 @@ static void fill_object_path(struct kobj
  */
 int sysfs_create_link(struct kobject * kobj, struct kobject * target, char * name)
 {
-	struct dentry * dentry = kobj->dentry;
-	struct dentry * d;
-	int error = 0;
 	int size;
 	int depth;
 	char * path;
 	char * s;
+        char ** link_names;
+        struct sysfs_dirent * link;
 
 	depth = object_depth(kobj);
 	size = object_path_length(target) + depth * 3 - 1;
@@ -96,18 +95,23 @@ int sysfs_create_link(struct kobject * k
 	fill_object_path(target,path,size);
 	pr_debug("%s: path = '%s'\n",__FUNCTION__,path);
 
-	down(&dentry->d_inode->i_sem);
-	d = sysfs_get_dentry(dentry,name);
-	if (!IS_ERR(d))
-		error = sysfs_symlink(dentry->d_inode,d,path);
-	else
-		error = PTR_ERR(d);
-	dput(d);
-	up(&dentry->d_inode->i_sem);
-	kfree(path);
-	return error;
-}
+        link_names = kmalloc(2 * (sizeof(char *)), GFP_KERNEL);
+        if (!link_names) {
+                kfree(path);
+                return -ENOMEM;
+        }
+        link_names[0] = name;
+        link_names[1] = path;
+                                                                                
+	link = sysfs_alloc_dirent(kobj->s_dirent, link_names, SYSFS_KOBJ_LINK);
+	if (IS_ERR(link)) {
+                kfree(path);
+                kfree(link_names);
+		return PTR_ERR(link);
+	}
 
+	return 0;
+}
 
 /**
  *	sysfs_remove_link - remove symlink in object's directory.
@@ -117,7 +121,7 @@ int sysfs_create_link(struct kobject * k
 
 void sysfs_remove_link(struct kobject * kobj, char * name)
 {
-	sysfs_hash_and_remove(kobj->dentry,name);
+	sysfs_hash_and_remove(kobj->s_dirent, name);
 }
 
 

_
-- 
Maneesh Soni
Linux Technology Center, 
IBM Software Lab, Bangalore, India
email: maneesh@in.ibm.com
Phone: 91-80-5044999 Fax: 91-80-5268553
T/L : 9243696

  reply	other threads:[~2003-11-12 12:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-12 12:23 [RFC 0/5] Backing Store for sysfs (Overhauled) Maneesh Soni
2003-11-12 12:25 ` [RFC 1/5] sysfs-backing-store.patch Maneesh Soni
2003-11-12 12:25   ` [RFC 2/5] sysfs-dir.patch Maneesh Soni
2003-11-12 12:25     ` [RFC 3/5] sysfs-file.patch Maneesh Soni
2003-11-12 12:26       ` [RFC 4/5] sysfs-attr_group.patch Maneesh Soni
2003-11-12 12:26         ` Maneesh Soni [this message]
2003-11-12 14:39     ` [RFC 2/5] sysfs-dir.patch viro
2003-11-12 16:00 ` [RFC 0/5] Backing Store for sysfs (Overhauled) Greg KH
2003-11-12 16:27   ` Dipankar Sarma
2003-11-12 16:39     ` Greg KH
2003-11-13 19:34 ` Patrick Mochel
2003-11-13 19:55   ` Dipankar Sarma

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=20031112122647.GI14580@in.ibm.com \
    --to=maneesh@in.ibm.com \
    --cc=CBORNTRA@de.ibm.com \
    --cc=dipankar@in.ibm.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.org \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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.