From: Arnd Bergmann <arnd@arndb.de>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christoph Hellwig <hch@lst.de>, Greg KH <gregkh@suse.de>,
David Howells <dhowells@redhat.com>
Subject: [RFC 09/11] split out libfs/super.c from libfs.c
Date: Tue, 19 Feb 2008 05:04:44 +0100 [thread overview]
Message-ID: <20080219040829.668040560@arndb.de> (raw)
In-Reply-To: 20080219040435.825494460@arndb.de
[-- Attachment #1: libfs-super.o --]
[-- Type: text/plain, Size: 4096 bytes --]
Consolidate all super block manipulation code in libfs in a single
source file.
Signed-off-by: Arnd Bergman <arnd@arndb.de>
Index: linux-2.6/fs/libfs.c
===================================================================
--- linux-2.6.orig/fs/libfs.c
+++ linux-2.6/fs/libfs.c
@@ -12,63 +12,6 @@
#include <asm/uaccess.h>
-static const struct super_operations simple_super_operations = {
- .statfs = simple_statfs,
-};
-
-/*
- * Common helper for pseudo-filesystems (sockfs, pipefs, bdev - stuff that
- * will never be mountable)
- */
-int get_sb_pseudo(struct file_system_type *fs_type, char *name,
- const struct super_operations *ops, unsigned long magic,
- struct vfsmount *mnt)
-{
- struct super_block *s = sget(fs_type, NULL, set_anon_super, NULL);
- struct dentry *dentry;
- struct inode *root;
- struct qstr d_name = {.name = name, .len = strlen(name)};
-
- if (IS_ERR(s))
- return PTR_ERR(s);
-
- s->s_flags = MS_NOUSER;
- s->s_maxbytes = ~0ULL;
- s->s_blocksize = 1024;
- s->s_blocksize_bits = 10;
- s->s_magic = magic;
- s->s_op = ops ? ops : &simple_super_operations;
- s->s_time_gran = 1;
- root = new_inode(s);
- if (!root)
- goto Enomem;
- /*
- * since this is the first inode, make it number 1. New inodes created
- * after this must take care not to collide with it (by passing
- * max_reserved of 1 to iunique).
- */
- root->i_ino = 1;
- root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
- root->i_uid = root->i_gid = 0;
- root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME;
- dentry = d_alloc(NULL, &d_name);
- if (!dentry) {
- iput(root);
- goto Enomem;
- }
- dentry->d_sb = s;
- dentry->d_parent = dentry;
- d_instantiate(dentry, root);
- s->s_root = dentry;
- s->s_flags |= MS_ACTIVE;
- return simple_set_mnt(mnt, s);
-
-Enomem:
- up_write(&s->s_umount);
- deactivate_super(s);
- return -ENOMEM;
-}
-
int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
{
struct inode *inode = old_dentry->d_inode;
@@ -238,7 +181,6 @@ ssize_t simple_read_from_buffer(void __u
return count;
}
-EXPORT_SYMBOL(get_sb_pseudo);
EXPORT_SYMBOL(simple_write_begin);
EXPORT_SYMBOL(simple_write_end);
EXPORT_SYMBOL(simple_empty);
Index: linux-2.6/fs/libfs/super.c
===================================================================
--- linux-2.6.orig/fs/libfs/super.c
+++ linux-2.6/fs/libfs/super.c
@@ -54,6 +54,60 @@ static const struct super_operations sim
};
/*
+ * Common helper for pseudo-filesystems (sockfs, pipefs, bdev - stuff that
+ * will never be mountable)
+ */
+int get_sb_pseudo(struct file_system_type *fs_type, char *name,
+ const struct super_operations *ops, unsigned long magic,
+ struct vfsmount *mnt)
+{
+ struct super_block *s = sget(fs_type, NULL, set_anon_super, NULL);
+ struct dentry *dentry;
+ struct inode *root;
+ struct qstr d_name = {.name = name, .len = strlen(name)};
+
+ if (IS_ERR(s))
+ return PTR_ERR(s);
+
+ s->s_flags = MS_NOUSER;
+ s->s_maxbytes = ~0ULL;
+ s->s_blocksize = 1024;
+ s->s_blocksize_bits = 10;
+ s->s_magic = magic;
+ s->s_op = ops ? ops : &simple_super_operations;
+ s->s_time_gran = 1;
+ root = new_inode(s);
+ if (!root)
+ goto Enomem;
+ /*
+ * since this is the first inode, make it number 1. New inodes created
+ * after this must take care not to collide with it (by passing
+ * max_reserved of 1 to iunique).
+ */
+ root->i_ino = 1;
+ root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
+ root->i_uid = root->i_gid = 0;
+ root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME;
+ dentry = d_alloc(NULL, &d_name);
+ if (!dentry) {
+ iput(root);
+ goto Enomem;
+ }
+ dentry->d_sb = s;
+ dentry->d_parent = dentry;
+ d_instantiate(dentry, root);
+ s->s_root = dentry;
+ s->s_flags |= MS_ACTIVE;
+ return simple_set_mnt(mnt, s);
+
+Enomem:
+ up_write(&s->s_umount);
+ deactivate_super(s);
+ return -ENOMEM;
+}
+EXPORT_SYMBOL(get_sb_pseudo);
+
+/*
* the inodes created here are not hashed. If you use iunique to generate
* unique inode values later for this filesystem, then you must take care
* to pass it an appropriate max_reserved value to avoid collisions.
--
next prev parent reply other threads:[~2008-02-19 4:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-19 4:04 [RFC 00/11] possible debugfs/libfs consolidation Arnd Bergmann
2008-02-19 4:04 ` [RFC 01/11] add generic versions of debugfs file operations Arnd Bergmann
2008-02-23 12:24 ` Al Viro
2008-02-24 10:46 ` Arnd Bergmann
2008-02-24 18:00 ` Greg KH
2008-02-23 12:33 ` Al Viro
2008-02-19 4:04 ` [RFC 02/11] introduce simple_fs_type Arnd Bergmann
2008-02-23 12:28 ` Al Viro
2008-02-24 10:55 ` Arnd Bergmann
2008-02-19 4:04 ` [RFC 03/11] slim down debugfs Arnd Bergmann
2008-02-23 12:37 ` Al Viro
2008-02-23 19:55 ` Hugh Dickins
2008-02-24 10:59 ` Arnd Bergmann
2008-02-19 4:04 ` [RFC 04/11] slim down securityfs Arnd Bergmann
2008-02-19 4:04 ` [RFC 05/11] slim down usbfs Arnd Bergmann
2008-02-19 4:04 ` [RFC 06/11] split out linux/libfs.h from linux/fs.h Arnd Bergmann
2008-02-19 4:04 ` [RFC 07/11] split out libfs/file.c from libfs.c Arnd Bergmann
2008-02-19 4:04 ` [RFC 08/11] split out libfs/dentry.c " Arnd Bergmann
2008-02-19 4:04 ` Arnd Bergmann [this message]
2008-02-19 4:04 ` [RFC 10/11] split out libfs/inode.c " Arnd Bergmann
2008-02-19 4:04 ` [RFC 11/11] split out libfs/aops.c " Arnd Bergmann
2008-02-19 16:38 ` [RFC 00/11] possible debugfs/libfs consolidation Greg KH
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=20080219040829.668040560@arndb.de \
--to=arnd@arndb.de \
--cc=dhowells@redhat.com \
--cc=gregkh@suse.de \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.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;
as well as URLs for NNTP newsgroup(s).