From: Christoph Hellwig <hch@lst.de>
To: viro@zeniv.linux.org.uk, zippel@linux-m68k.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 5/14] hfsplus: merge mknod/mkdir/creat
Date: Fri, 1 Oct 2010 09:26:10 +0200 [thread overview]
Message-ID: <20101001072610.GE27055@lst.de> (raw)
In-Reply-To: <20101001072500.GA26972@lst.de>
Make hfsplus_mkdir and hfsplus_create call hfsplus_mknod instead of
duplicating the code.
Signed-off-by: Christoph Hellwig <hch@tuxera.com>
Index: linux-2.6/fs/hfsplus/dir.c
===================================================================
--- linux-2.6.orig/fs/hfsplus/dir.c 2010-09-30 16:56:02.074782662 +0900
+++ linux-2.6/fs/hfsplus/dir.c 2010-09-30 17:03:56.970782669 +0900
@@ -237,28 +237,6 @@ static int hfsplus_dir_release(struct in
return 0;
}
-static int hfsplus_create(struct inode *dir, struct dentry *dentry, int mode,
- struct nameidata *nd)
-{
- struct inode *inode;
- int res;
-
- inode = hfsplus_new_inode(dir->i_sb, mode);
- if (!inode)
- return -ENOSPC;
-
- res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode);
- if (res) {
- inode->i_nlink = 0;
- hfsplus_delete_inode(inode);
- iput(inode);
- return res;
- }
- hfsplus_instantiate(dentry, inode, inode->i_ino);
- mark_inode_dirty(inode);
- return 0;
-}
-
static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
struct dentry *dst_dentry)
{
@@ -365,27 +343,6 @@ static int hfsplus_unlink(struct inode *
return res;
}
-static int hfsplus_mkdir(struct inode *dir, struct dentry *dentry, int mode)
-{
- struct inode *inode;
- int res;
-
- inode = hfsplus_new_inode(dir->i_sb, S_IFDIR | mode);
- if (!inode)
- return -ENOSPC;
-
- res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode);
- if (res) {
- inode->i_nlink = 0;
- hfsplus_delete_inode(inode);
- iput(inode);
- return res;
- }
- hfsplus_instantiate(dentry, inode, inode->i_ino);
- mark_inode_dirty(inode);
- return 0;
-}
-
static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
{
struct inode *inode;
@@ -438,12 +395,10 @@ static int hfsplus_symlink(struct inode
static int hfsplus_mknod(struct inode *dir, struct dentry *dentry,
int mode, dev_t rdev)
{
- struct super_block *sb;
struct inode *inode;
int res;
- sb = dir->i_sb;
- inode = hfsplus_new_inode(sb, mode);
+ inode = hfsplus_new_inode(dir->i_sb, mode);
if (!inode)
return -ENOSPC;
@@ -454,13 +409,26 @@ static int hfsplus_mknod(struct inode *d
iput(inode);
return res;
}
- init_special_inode(inode, mode, rdev);
+
+ if (S_ISBLK(mode) || S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode))
+ init_special_inode(inode, mode, rdev);
+
hfsplus_instantiate(dentry, inode, inode->i_ino);
mark_inode_dirty(inode);
-
return 0;
}
+static int hfsplus_create(struct inode *dir, struct dentry *dentry, int mode,
+ struct nameidata *nd)
+{
+ return hfsplus_mknod(dir, dentry, mode, 0);
+}
+
+static int hfsplus_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+{
+ return hfsplus_mknod(dir, dentry, mode | S_IFDIR, 0);
+}
+
static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry)
{
next prev parent reply other threads:[~2010-10-01 7:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-01 7:25 [PATCH 0/14] more hfsplus updates Christoph Hellwig
2010-10-01 7:25 ` [PATCH 1/14] hfsplus: fix HFSPLUS_SB calling convention Christoph Hellwig
2010-10-01 7:25 ` [PATCH 2/14] hfsplus: fix HFSPLUS_I " Christoph Hellwig
2010-10-01 7:25 ` [PATCH 3/14] hfsplus: clean up hfsplus_iget Christoph Hellwig
2010-10-01 7:26 ` [PATCH 4/14] hfsplus: clean up hfsplus_write_inode Christoph Hellwig
2010-10-01 7:26 ` Christoph Hellwig [this message]
2010-10-01 7:26 ` [PATCH 6/14] hfsplus: fix error handling in hfsplus_symlink Christoph Hellwig
2010-10-01 7:26 ` [PATCH 7/14] hfsplus: do not cache and write next_alloc Christoph Hellwig
2010-10-01 7:26 ` [PATCH 8/14] hfsplus: remove the rsrc_inodes list Christoph Hellwig
2010-10-01 7:26 ` [PATCH 9/14] hfsplus: add per-superblock lock for volume header updates Christoph Hellwig
2010-10-01 7:27 ` [PATCH 10/14] hfsplus: use atomic bitops for the superblock flags Christoph Hellwig
2010-10-01 7:27 ` [PATCH 11/14] hfsplus: protect readdir against removals from open_dir_list Christoph Hellwig
2010-10-01 7:27 ` [PATCH 12/14] hfsplus: add missing extent locking in hfsplus_write_inode Christoph Hellwig
2010-10-01 7:27 ` [PATCH 13/14] hfsplus: convert tree_lock to mutex Christoph Hellwig
2010-10-01 7:28 ` [PATCH 14/14] hfsplus: fix rename over directories Christoph Hellwig
2010-10-01 14:06 ` [PATCH 0/14] more hfsplus updates Christoph Hellwig
2010-10-01 14:16 ` Christoph Hellwig
2010-10-02 4:09 ` Stephen Rothwell
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=20101001072610.GE27055@lst.de \
--to=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zippel@linux-m68k.org \
/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.