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 2/6] sysfs-mount.patch
Date: Mon, 6 Oct 2003 14:30:30 +0530 [thread overview]
Message-ID: <20031006090030.GG4220@in.ibm.com> (raw)
In-Reply-To: <20031006090003.GF4220@in.ibm.com>
o This patch provides mount related changes for sysfs backing store. Now,
sysfs_init() just registers the sysfs filesystem and do not mount it.
o The global sysfs_mount indicates whether sysfs is mounted or not. For this
we initialize it in fs/super.c:do_kern_mount(). It looks like more of a hack.
o We also have new dir_operations and dir_inode_operations structs for sysfs
directories including the root directory.
o sysfs inode links are obtained from sysfs_get_link_count().
fs/super.c | 5 +++++
fs/sysfs/mount.c | 26 ++++++--------------------
init/do_mounts.c | 1 +
3 files changed, 12 insertions(+), 20 deletions(-)
diff -puN init/do_mounts.c~sysfs-mount init/do_mounts.c
--- linux-2.6.0-test6/init/do_mounts.c~sysfs-mount 2003-10-06 11:54:59.000000000 +0530
+++ linux-2.6.0-test6-maneesh/init/do_mounts.c 2003-10-06 11:55:14.000000000 +0530
@@ -189,6 +189,7 @@ done:
sys_umount("/sys", 0);
out:
sys_rmdir("/sys");
+ sysfs_mount = NULL;
return res;
fail:
res = 0;
diff -puN fs/super.c~sysfs-mount fs/super.c
--- linux-2.6.0-test6/fs/super.c~sysfs-mount 2003-10-06 11:55:03.000000000 +0530
+++ linux-2.6.0-test6-maneesh/fs/super.c 2003-10-06 11:55:14.000000000 +0530
@@ -32,6 +32,7 @@
#include <linux/security.h>
#include <linux/vfs.h>
#include <linux/writeback.h> /* for the emergency remount stuff */
+#include <linux/sysfs.h>
#include <asm/uaccess.h>
@@ -692,6 +693,10 @@ do_kern_mount(const char *fstype, int fl
mnt->mnt_mountpoint = sb->s_root;
mnt->mnt_parent = mnt;
up_write(&sb->s_umount);
+
+ if (!strcmp(fstype, "sysfs"))
+ sysfs_mount = mnt;
+
put_filesystem(type);
return mnt;
out_sb:
diff -puN fs/sysfs/mount.c~sysfs-mount fs/sysfs/mount.c
--- linux-2.6.0-test6/fs/sysfs/mount.c~sysfs-mount 2003-10-06 11:55:07.000000000 +0530
+++ linux-2.6.0-test6-maneesh/fs/sysfs/mount.c 2003-10-06 11:55:14.000000000 +0530
@@ -2,8 +2,6 @@
* mount.c - operations for initializing and mounting sysfs.
*/
-#define DEBUG
-
#include <linux/fs.h>
#include <linux/mount.h>
#include <linux/pagemap.h>
@@ -14,7 +12,7 @@
/* Random magic number */
#define SYSFS_MAGIC 0x62656572
-struct vfsmount *sysfs_mount;
+struct vfsmount *sysfs_mount = NULL;
struct super_block * sysfs_sb = NULL;
static struct super_operations sysfs_ops = {
@@ -35,10 +33,9 @@ static int sysfs_fill_super(struct super
inode = sysfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO);
if (inode) {
- inode->i_op = &simple_dir_inode_operations;
- inode->i_fop = &simple_dir_operations;
- /* directory inodes start off with i_nlink == 2 (for "." entry) */
- inode->i_nlink++;
+ inode->i_op = &sysfs_dir_inode_operations;
+ inode->i_fop = &sysfs_dir_operations;
+ inode->i_nlink += sysfs_get_link_count(NULL);
} else {
pr_debug("sysfs: could not get root inode\n");
return -ENOMEM;
@@ -63,21 +60,10 @@ static struct super_block *sysfs_get_sb(
static struct file_system_type sysfs_fs_type = {
.name = "sysfs",
.get_sb = sysfs_get_sb,
- .kill_sb = kill_litter_super,
+ .kill_sb = kill_anon_super,
};
int __init sysfs_init(void)
{
- int err;
-
- err = register_filesystem(&sysfs_fs_type);
- if (!err) {
- sysfs_mount = kern_mount(&sysfs_fs_type);
- if (IS_ERR(sysfs_mount)) {
- printk(KERN_ERR "sysfs: could not mount!\n");
- err = PTR_ERR(sysfs_mount);
- sysfs_mount = NULL;
- }
- }
- return err;
+ return register_filesystem(&sysfs_fs_type);
}
_
--
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:00 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 ` Maneesh Soni [this message]
2003-10-06 9:01 ` [RFC 3/6] sysfs-file.patch Maneesh Soni
2003-10-06 9:01 ` [RFC 4/6] sysfs-symlink.patch Maneesh Soni
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=20031006090030.GG4220@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 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.