linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-fsdevel@vger.kernel.org
Cc: Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 14/19] ramfs: replace inode uid,gid,mode initialization with helper function
Date: Thu,  4 Mar 2010 17:32:18 +0300	[thread overview]
Message-ID: <1267713143-9258-5-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1267712897-9088-1-git-send-email-dmonakhov@openvz.org>

- seems what ramfs_get_inode is only locally, make it static.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/ramfs/inode.c      |   20 ++++++--------------
 include/linux/ramfs.h |    1 -
 2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index a6090aa..ac55307 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -51,14 +51,13 @@ static struct backing_dev_info ramfs_backing_dev_info = {
 			  BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP,
 };
 
-struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev)
+static struct inode *ramfs_get_inode(struct super_block *sb,
+				const struct inode *dir, int mode, dev_t dev)
 {
 	struct inode * inode = new_inode(sb);
 
 	if (inode) {
-		inode->i_mode = mode;
-		inode->i_uid = current_fsuid();
-		inode->i_gid = current_fsgid();
+		inode_init_owner(inode, dir, mode);
 		inode->i_mapping->a_ops = &ramfs_aops;
 		inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info;
 		mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER);
@@ -94,15 +93,10 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev)
 static int
 ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
 {
-	struct inode * inode = ramfs_get_inode(dir->i_sb, mode, dev);
+	struct inode * inode = ramfs_get_inode(dir->i_sb, dir, mode, dev);
 	int error = -ENOSPC;
 
 	if (inode) {
-		if (dir->i_mode & S_ISGID) {
-			inode->i_gid = dir->i_gid;
-			if (S_ISDIR(mode))
-				inode->i_mode |= S_ISGID;
-		}
 		d_instantiate(dentry, inode);
 		dget(dentry);	/* Extra count - pin the dentry in core */
 		error = 0;
@@ -129,13 +123,11 @@ static int ramfs_symlink(struct inode * dir, struct dentry *dentry, const char *
 	struct inode *inode;
 	int error = -ENOSPC;
 
-	inode = ramfs_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0);
+	inode = ramfs_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0);
 	if (inode) {
 		int l = strlen(symname)+1;
 		error = page_symlink(inode, symname, l);
 		if (!error) {
-			if (dir->i_mode & S_ISGID)
-				inode->i_gid = dir->i_gid;
 			d_instantiate(dentry, inode);
 			dget(dentry);
 			dir->i_mtime = dir->i_ctime = CURRENT_TIME;
@@ -240,7 +232,7 @@ static int ramfs_fill_super(struct super_block * sb, void * data, int silent)
 	sb->s_op		= &ramfs_ops;
 	sb->s_time_gran		= 1;
 
-	inode = ramfs_get_inode(sb, S_IFDIR | fsi->mount_opts.mode, 0);
+	inode = ramfs_get_inode(sb, NULL, S_IFDIR | fsi->mount_opts.mode, 0);
 	if (!inode) {
 		err = -ENOMEM;
 		goto fail;
diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h
index 4e768dd..6ee2bb9 100644
--- a/include/linux/ramfs.h
+++ b/include/linux/ramfs.h
@@ -1,7 +1,6 @@
 #ifndef _LINUX_RAMFS_H
 #define _LINUX_RAMFS_H
 
-struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev);
 extern int ramfs_get_sb(struct file_system_type *fs_type,
 	 int flags, const char *dev_name, void *data, struct vfsmount *mnt);
 
-- 
1.6.6


  parent reply	other threads:[~2010-03-04 14:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-04 14:28 [PATCH 00/19] fs cleanup: remove duplicated code on inode init v2 Dmitry Monakhov
2010-03-04 14:29 ` [PATCH 01/19] vfs: Add inode uid,gid,mode init helper v2 Dmitry Monakhov
2010-03-04 14:30 ` [PATCH 02/19] 9p: replace inode uid,gid,mode initialization with helper function Dmitry Monakhov
2010-03-04 14:30 ` [PATCH 09/19] jfs: replace inode uid,gid,mode init with helper v2 Dmitry Monakhov
2010-03-04 14:31 ` [PATCH 03/19] bfs: replace inode uid,gid,mode initialization with helper function Dmitry Monakhov
2010-03-04 14:31 ` [PATCH 04/19] btrfs: " Dmitry Monakhov
2010-03-04 14:31 ` [PATCH 05/19] exofs: " Dmitry Monakhov
2010-03-04 14:31 ` [PATCH 06/19] ext2: replace inode uid,gid,mode init with helper v2 Dmitry Monakhov
2010-03-04 14:31 ` [PATCH 07/19] ext3: " Dmitry Monakhov
2010-03-04 14:31 ` [PATCH 08/19] ext4: " Dmitry Monakhov
2010-03-04 14:32 ` [PATCH 10/19] minix: replace inode uid,gid,mode init with helper Dmitry Monakhov
2010-03-04 14:32 ` [PATCH 11/19] nilfs2: replace inode uid,gid,mode initialization with helper function Dmitry Monakhov
2010-03-04 14:32 ` [PATCH 12/19] ocfs2: " Dmitry Monakhov
2010-03-04 14:32 ` [PATCH 13/19] omfs: " Dmitry Monakhov
2010-03-04 14:32 ` Dmitry Monakhov [this message]
2010-03-04 14:32 ` [PATCH 15/19] reiserfs: " Dmitry Monakhov
2010-03-04 14:32 ` [PATCH 16/19] sysv: " Dmitry Monakhov
2010-03-04 14:32 ` [PATCH 17/19] ubifs: " Dmitry Monakhov
2010-03-04 14:32 ` [PATCH 18/19] udf: replace inode uid,gid,mode init with helper v3 Dmitry Monakhov
2010-03-04 14:32 ` [PATCH 19/19] ufs: replace inode uid,gid,mode initialization with helper function Dmitry Monakhov
  -- strict thread matches above, loose matches on Subject: below --
2010-02-17 18:29 [PATCH 00/19] fs cleanup: remove duplicated code on inode init Dmitry Monakhov
2010-02-17 18:44 ` [PATCH 14/19] ramfs: replace inode uid,gid,mode initialization with helper function Dmitry Monakhov

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=1267713143-9258-5-git-send-email-dmonakhov@openvz.org \
    --to=dmonakhov@openvz.org \
    --cc=linux-fsdevel@vger.kernel.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 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).