From: Maneesh Soni <maneesh@in.ibm.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Greg KH <greg@kroah.com>,
Al Viro <viro@parcelfarce.linux.theplanet.co.uk>,
Patrick Mochel <mochel@digitalimplant.org>,
Dipankar Sarma <dipankar@in.ibm.com>
Subject: [RFC 5/5] sysfs backing store (leaves only) - sysfs-leaves-misc.patch
Date: Mon, 29 Dec 2003 15:06:30 +0530 [thread overview]
Message-ID: <20031229093630.GF1649@in.ibm.com> (raw)
In-Reply-To: <20031229093545.GE1649@in.ibm.com>
o This patch has the changes require for attribute groups and symlinks, and
misc. routines.
fs/sysfs/group.c | 2 -
fs/sysfs/symlink.c | 2 +
fs/sysfs/sysfs.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 72 insertions(+), 2 deletions(-)
diff -puN fs/sysfs/symlink.c~sysfs-leaves-misc fs/sysfs/symlink.c
--- linux-2.6.0/fs/sysfs/symlink.c~sysfs-leaves-misc 2003-12-29 14:39:03.000000000 +0530
+++ linux-2.6.0-maneesh/fs/sysfs/symlink.c 2003-12-29 14:39:36.000000000 +0530
@@ -25,6 +25,8 @@ static int sysfs_symlink(struct inode *
error = page_symlink(dentry->d_inode, symname, l);
if (error)
iput(dentry->d_inode);
+ else
+ d_rehash(dentry);
}
return error;
}
diff -puN fs/sysfs/group.c~sysfs-leaves-misc fs/sysfs/group.c
--- linux-2.6.0/fs/sysfs/group.c~sysfs-leaves-misc 2003-12-29 14:39:03.000000000 +0530
+++ linux-2.6.0-maneesh/fs/sysfs/group.c 2003-12-29 14:39:03.000000000 +0530
@@ -31,7 +31,7 @@ static int create_files(struct dentry *
int error = 0;
for (attr = grp->attrs; *attr && !error; attr++) {
- error = sysfs_add_file(dir,*attr);
+ error = sysfs_add_file(dir, SYSFS_KOBJ_ATTR, * attr);
}
if (error)
remove_files(dir,grp);
diff -puN fs/sysfs/sysfs.h~sysfs-leaves-misc fs/sysfs/sysfs.h
--- linux-2.6.0/fs/sysfs/sysfs.h~sysfs-leaves-misc 2003-12-29 14:39:03.000000000 +0530
+++ linux-2.6.0-maneesh/fs/sysfs/sysfs.h 2003-12-29 14:39:03.000000000 +0530
@@ -1,4 +1,5 @@
+#include <linux/fs.h>
extern struct vfsmount * sysfs_mount;
extern struct inode * sysfs_new_inode(mode_t mode);
@@ -6,8 +7,75 @@ extern int sysfs_create(struct dentry *,
extern struct dentry * sysfs_get_dentry(struct dentry *, const char *);
-extern int sysfs_add_file(struct dentry * dir, const struct attribute * attr);
+extern int sysfs_add_file(struct dentry *, int, const struct attribute *);
extern void sysfs_hash_and_remove(struct dentry * dir, const char * name);
extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **);
extern void sysfs_remove_subdir(struct dentry *);
+
+extern loff_t sysfs_dir_lseek(struct file *, loff_t, int);
+extern int sysfs_readdir(struct file *, void *, filldir_t);
+extern void sysfs_umount_begin(struct super_block *);
+extern char * sysfs_get_name(struct sysfs_dirent *);
+extern struct dentry * sysfs_lookup(struct inode *, struct dentry *, struct nameidata *);
+
+extern struct file_operations sysfs_file_operations;
+extern struct file_operations bin_fops;
+extern struct inode_operations sysfs_dir_inode_operations;
+extern struct file_operations sysfs_dir_operations;
+
+
+static inline
+struct sysfs_dirent * sysfs_new_dirent(struct sysfs_dirent * p, void * e, int t)
+{
+ struct sysfs_dirent * sd;
+
+ sd = kmalloc(sizeof(*sd), GFP_KERNEL);
+ if (!sd)
+ return NULL;
+ memset(sd, 0, sizeof(*sd));
+ atomic_set(&sd->s_count, 1);
+ sd->s_element = e;
+ sd->s_type = t;
+ sd->s_dentry = NULL;
+ INIT_LIST_HEAD(&sd->s_children);
+ list_add(&sd->s_sibling, &p->s_children);
+
+ return sd;
+}
+
+static inline struct sysfs_dirent * sysfs_get(struct sysfs_dirent * sd)
+{
+ if (sd) {
+ WARN_ON(!atomic_read(&sd->s_count));
+ atomic_inc(&sd->s_count);
+ }
+ return sd;
+}
+
+static inline void sysfs_put(struct sysfs_dirent * sd)
+{
+ if (atomic_dec_and_test(&sd->s_count))
+ kfree(sd);
+}
+
+static inline
+void sysfs_remove_attr_dirent(struct sysfs_dirent * sd, const char * name)
+{
+ struct list_head * tmp;
+
+ tmp = sd->s_children.next;
+ while (tmp != & sd->s_children) {
+ struct sysfs_dirent * tmp_sd;
+ tmp_sd = list_entry(tmp, struct sysfs_dirent, s_sibling);
+ tmp = tmp->next;
+ if ((tmp_sd->s_type == SYSFS_KOBJ_ATTR) ||
+ (tmp_sd->s_type == SYSFS_KOBJ_BIN_ATTR)) {
+ if (!strcmp(sysfs_get_name(tmp_sd), name)) {
+ list_del_init(&tmp_sd->s_sibling);
+ sysfs_put(tmp_sd);
+ }
+ }
+ }
+}
+
_
--
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-12-29 9:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-29 9:32 [RFC 0/5] sysfs backing store (leaves only) Maneesh Soni
2003-12-29 9:33 ` [RFC 1/5] sysfs backing store (leaves only) - sysfs-leaves-mount.patch Maneesh Soni
2003-12-29 9:34 ` [RFC 1/5] sysfs backing store (leaves only) - sysfs-leaves-dir.patch Maneesh Soni
2003-12-29 9:35 ` [RFC 3/5] sysfs backing store (leaves only) - sysfs-leaves-file.patch Maneesh Soni
2003-12-29 9:35 ` [RFC 4/5] sysfs backing store (leaves only) - sysfs-leaves-bin.patch Maneesh Soni
2003-12-29 9:36 ` Maneesh Soni [this message]
2004-01-02 6:45 ` [RFC 2/5] sysfs backing store (leaves only) - sysfs-leaves-dir.patch 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=20031229093630.GF1649@in.ibm.com \
--to=maneesh@in.ibm.com \
--cc=dipankar@in.ibm.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@digitalimplant.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