From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Monakhov Subject: [PATCH 14/19] ramfs: replace inode uid,gid,mode initialization with helper function Date: Wed, 17 Feb 2010 21:44:53 +0300 Message-ID: <1266432293-9710-1-git-send-email-dmonakhov@openvz.org> References: <1266431353-8549-1-git-send-email-dmonakhov@openvz.org> Cc: Dmitry Monakhov To: linux-fsdevel@vger.kernel.org Return-path: Received: from fg-out-1718.google.com ([72.14.220.154]:64442 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753640Ab0BQSo7 (ORCPT ); Wed, 17 Feb 2010 13:44:59 -0500 Received: by fg-out-1718.google.com with SMTP id 19so350305fgg.1 for ; Wed, 17 Feb 2010 10:44:58 -0800 (PST) In-Reply-To: <1266431353-8549-1-git-send-email-dmonakhov@openvz.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: - seems what ramfs_get_inode is only locally, make it static. Signed-off-by: Dmitry Monakhov --- 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