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 10/11] split out libfs/inode.c from libfs.c
Date: Tue, 19 Feb 2008 05:04:45 +0100 [thread overview]
Message-ID: <20080219040829.836560927@arndb.de> (raw)
In-Reply-To: 20080219040435.825494460@arndb.de
[-- Attachment #1: libfs-inode.diff --]
[-- Type: text/plain, Size: 4508 bytes --]
Consolidate all inode 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,78 +12,6 @@
#include <asm/uaccess.h>
-int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
-{
- struct inode *inode = old_dentry->d_inode;
-
- inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
- inc_nlink(inode);
- atomic_inc(&inode->i_count);
- dget(dentry);
- d_instantiate(dentry, inode);
- return 0;
-}
-
-int simple_empty(struct dentry *dentry)
-{
- struct dentry *child;
- int ret = 0;
-
- spin_lock(&dcache_lock);
- list_for_each_entry(child, &dentry->d_subdirs, d_u.d_child)
- if (simple_positive(child))
- goto out;
- ret = 1;
-out:
- spin_unlock(&dcache_lock);
- return ret;
-}
-
-int simple_unlink(struct inode *dir, struct dentry *dentry)
-{
- struct inode *inode = dentry->d_inode;
-
- inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
- drop_nlink(inode);
- dput(dentry);
- return 0;
-}
-
-int simple_rmdir(struct inode *dir, struct dentry *dentry)
-{
- if (!simple_empty(dentry))
- return -ENOTEMPTY;
-
- drop_nlink(dentry->d_inode);
- simple_unlink(dir, dentry);
- drop_nlink(dir);
- return 0;
-}
-
-int simple_rename(struct inode *old_dir, struct dentry *old_dentry,
- struct inode *new_dir, struct dentry *new_dentry)
-{
- struct inode *inode = old_dentry->d_inode;
- int they_are_dirs = S_ISDIR(old_dentry->d_inode->i_mode);
-
- if (!simple_empty(new_dentry))
- return -ENOTEMPTY;
-
- if (new_dentry->d_inode) {
- simple_unlink(new_dir, new_dentry);
- if (they_are_dirs)
- drop_nlink(old_dir);
- } else if (they_are_dirs) {
- drop_nlink(old_dir);
- inc_nlink(new_dir);
- }
-
- old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime =
- new_dir->i_mtime = inode->i_ctime = CURRENT_TIME;
-
- return 0;
-}
-
int simple_readpage(struct file *file, struct page *page)
{
clear_highpage(page);
@@ -183,11 +111,6 @@ ssize_t simple_read_from_buffer(void __u
EXPORT_SYMBOL(simple_write_begin);
EXPORT_SYMBOL(simple_write_end);
-EXPORT_SYMBOL(simple_empty);
-EXPORT_SYMBOL(simple_link);
EXPORT_SYMBOL(simple_prepare_write);
EXPORT_SYMBOL(simple_readpage);
-EXPORT_SYMBOL(simple_rename);
-EXPORT_SYMBOL(simple_rmdir);
-EXPORT_SYMBOL(simple_unlink);
EXPORT_SYMBOL(simple_read_from_buffer);
Index: linux-2.6/fs/libfs/inode.c
===================================================================
--- linux-2.6.orig/fs/libfs/inode.c
+++ linux-2.6/fs/libfs/inode.c
@@ -417,4 +417,79 @@ exit:
}
EXPORT_SYMBOL_GPL(simple_rename_named);
+int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
+{
+ struct inode *inode = old_dentry->d_inode;
+ inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+ inc_nlink(inode);
+ atomic_inc(&inode->i_count);
+ dget(dentry);
+ d_instantiate(dentry, inode);
+ return 0;
+}
+EXPORT_SYMBOL(simple_link);
+
+int simple_empty(struct dentry *dentry)
+{
+ struct dentry *child;
+ int ret = 0;
+
+ spin_lock(&dcache_lock);
+ list_for_each_entry(child, &dentry->d_subdirs, d_u.d_child)
+ if (simple_positive(child))
+ goto out;
+ ret = 1;
+out:
+ spin_unlock(&dcache_lock);
+ return ret;
+}
+EXPORT_SYMBOL(simple_empty);
+
+int simple_unlink(struct inode *dir, struct dentry *dentry)
+{
+ struct inode *inode = dentry->d_inode;
+
+ inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+ drop_nlink(inode);
+ dput(dentry);
+ return 0;
+}
+EXPORT_SYMBOL(simple_unlink);
+
+int simple_rmdir(struct inode *dir, struct dentry *dentry)
+{
+ if (!simple_empty(dentry))
+ return -ENOTEMPTY;
+
+ drop_nlink(dentry->d_inode);
+ simple_unlink(dir, dentry);
+ drop_nlink(dir);
+ return 0;
+}
+EXPORT_SYMBOL(simple_rmdir);
+
+int simple_rename(struct inode *old_dir, struct dentry *old_dentry,
+ struct inode *new_dir, struct dentry *new_dentry)
+{
+ struct inode *inode = old_dentry->d_inode;
+ int they_are_dirs = S_ISDIR(old_dentry->d_inode->i_mode);
+
+ if (!simple_empty(new_dentry))
+ return -ENOTEMPTY;
+
+ if (new_dentry->d_inode) {
+ simple_unlink(new_dir, new_dentry);
+ if (they_are_dirs)
+ drop_nlink(old_dir);
+ } else if (they_are_dirs) {
+ drop_nlink(old_dir);
+ inc_nlink(new_dir);
+ }
+
+ old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime =
+ new_dir->i_mtime = inode->i_ctime = CURRENT_TIME;
+
+ return 0;
+}
+EXPORT_SYMBOL(simple_rename);
--
next prev parent reply other threads:[~2008-02-19 4:12 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 ` [RFC 09/11] split out libfs/super.c " Arnd Bergmann
2008-02-19 4:04 ` Arnd Bergmann [this message]
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.836560927@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).