From: Maneesh Soni <maneesh@in.ibm.com>
To: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>,
Patrick Mochel <mochel@osdl.org>, Greg KH <gregkh@us.ibm.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Dipankar Sarma <dipankar@in.ibm.com>
Subject: [RFC 4/6] sysfs-symlink.patch
Date: Mon, 6 Oct 2003 14:31:39 +0530 [thread overview]
Message-ID: <20031006090139.GI4220@in.ibm.com> (raw)
In-Reply-To: <20031006090107.GH4220@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 kobject to act
as symlink. Again this code should be part of kobject code. But to keep the
interfaces same it is in sysfs code.
fs/sysfs/symlink.c | 41 +++++++++++++++++++++++++++++------------
1 files changed, 29 insertions(+), 12 deletions(-)
diff -puN fs/sysfs/symlink.c~sysfs-symlink fs/sysfs/symlink.c
--- linux-2.6.0-test6/fs/sysfs/symlink.c~sysfs-symlink 2003-10-06 12:08:04.000000000 +0530
+++ linux-2.6.0-test6-maneesh/fs/sysfs/symlink.c 2003-10-06 12:14:43.000000000 +0530
@@ -15,7 +15,8 @@ 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 +72,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;
+ struct kobject * link;
depth = object_depth(kobj);
size = object_path_length(target) + depth * 3 - 1;
@@ -96,15 +96,19 @@ 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);
+ link = kmalloc(sizeof(struct kobject), GFP_KERNEL);
+ if (!link) {
+ kfree(path);
+ return -ENOMEM;
+ }
+ memset(link, 0, sizeof(struct kobject));
+ kobject_init(link);
+ kobject_set_name(link, name);
+ link->k_symlink = path;
+ down_write(&kobj->k_rwsem);
+ list_add(&link->k_sibling, &kobj->k_children);
+ up_write(&kobj->k_rwsem);
+ link->dentry = NULL;
return error;
}
@@ -117,6 +121,19 @@ int sysfs_create_link(struct kobject * k
void sysfs_remove_link(struct kobject * kobj, char * name)
{
+ struct list_head * tmp;
+
+ down_write(&kobj->k_rwsem);
+ tmp = kobj->k_sibling.next;
+ while (tmp != &kobj->k_sibling) {
+ struct kobject * k = list_entry(tmp, struct kobject, k_sibling);
+ tmp = tmp->next;
+ if (!strcmp(kobject_name(k), name) && (k->k_symlink)) {
+ kfree(k->k_symlink);
+ kobject_cleanup(k);
+ }
+ }
+ up_write(&kobj->k_rwsem);
sysfs_hash_and_remove(kobj->dentry,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
next prev parent reply other threads:[~2003-10-06 9:02 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-06 8:59 [RFC 0/6] Backing Store for sysfs Maneesh Soni
2003-10-06 9:00 ` [RFC 1/6] sysfs-kobject.patch Maneesh Soni
2003-10-06 9:00 ` [RFC 2/6] sysfs-mount.patch Maneesh Soni
2003-10-06 9:01 ` [RFC 3/6] sysfs-file.patch Maneesh Soni
2003-10-06 9:01 ` Maneesh Soni [this message]
2003-10-06 9:02 ` [RFC 5/6] sysfs-attr_group.patch Maneesh Soni
2003-10-06 9:03 ` [RFC 6/6] sysfs-dir.patch Maneesh Soni
2003-10-06 13:43 ` [RFC 2/6] sysfs-mount.patch viro
2003-10-07 7:17 ` Maneesh Soni
2003-10-06 13:41 ` [RFC 1/6] sysfs-kobject.patch viro
2003-10-06 16:16 ` Greg KH
2003-10-06 17:41 ` Dipankar Sarma
2003-10-06 17:44 ` Greg KH
2003-10-06 16:08 ` [RFC 0/6] Backing Store for sysfs Greg KH
2003-10-06 17:31 ` Dipankar Sarma
2003-10-06 17:38 ` Greg KH
2003-10-06 18:01 ` Dipankar Sarma
2003-10-06 18:09 ` Greg KH
2003-10-06 18:31 ` Dipankar Sarma
2003-10-06 18:34 ` Greg KH
2003-10-07 9:08 ` Andreas Jellinghaus
2003-10-06 18:44 ` Patrick Mochel
2003-10-06 19:27 ` Dipankar Sarma
2003-10-06 19:30 ` viro
2003-10-06 20:01 ` Dipankar Sarma
2003-10-06 20:34 ` viro
2003-10-07 4:47 ` Maneesh Soni
2003-10-06 19:33 ` Patrick Mochel
2003-10-06 20:26 ` Dipankar Sarma
2003-10-06 20:29 ` Patrick Mochel
2003-10-07 4:31 ` Maneesh Soni
2003-10-07 5:25 ` Nick Piggin
2003-10-07 7:17 ` Maneesh Soni
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=20031006090139.GI4220@in.ibm.com \
--to=maneesh@in.ibm.com \
--cc=dipankar@in.ibm.com \
--cc=gregkh@us.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox