[PATCH 01/19] vfs: Add inode uid,gid,mode init helper v2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



James Morris <jmorris@xxxxxxxxx> writes:

> On Wed, 17 Feb 2010, Dmitry Monakhov wrote:
>
>> + */
>> +inline void inode_init_owner(struct inode *inode, const struct inode *dir,
>> +			int mode)
>> +{
>
> You should only try and inline functions which are smaller than about 100 
> bytes or which have fewer than four lines of code.  Also, the compiler can 
> generally figure out which functions to inline. 
Indeed.
>From 38b401c4bf5e29f9fa8afa90b17ab0adc3f362d8 Mon Sep 17 00:00:00 2001
From: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
Date: Thu, 18 Feb 2010 09:46:36 +0300
Subject: [PATCH 01/19] vfs: Add inode uid,gid,mode init helper v2


Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
---
 fs/namei.c         |   19 +++++++++++++++++++
 include/linux/fs.h |    3 ++-
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index d62fdc8..d3ba44b 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1435,6 +1435,25 @@ void unlock_rename(struct dentry *p1, struct dentry *p2)
 		mutex_unlock(&p1->d_inode->i_sb->s_vfs_rename_mutex);
 	}
 }
+/**
+ * Init uid,gid,mode for new inode according to posix standards
+ * @inode: New inode
+ * @dir: Directory inode
+ * @mode: mode of the new inode
+ */
+void inode_init_owner(struct inode *inode, const struct inode *dir,
+			int mode)
+{
+	inode->i_uid = current_fsuid();
+	if (dir && dir->i_mode & S_ISGID) {
+		inode->i_gid = dir->i_gid;
+		if (S_ISDIR(mode))
+			mode |= S_ISGID;
+	} else
+		inode->i_gid = current_fsgid();
+	inode->i_mode = mode;
+}
+EXPORT_SYMBOL(inode_init_owner);
 
 int vfs_create(struct inode *dir, struct dentry *dentry, int mode,
 		struct nameidata *nd)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b1bcb27..b2d7cb3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1426,7 +1426,8 @@ extern void dentry_unhash(struct dentry *dentry);
  * VFS file helper functions.
  */
 extern int file_permission(struct file *, int);
-
+extern void inode_init_owner(struct inode *inode, const struct inode *dir,
+			int mode);
 /*
  * VFS FS_IOC_FIEMAP helper definitions.
  */
-- 
1.6.6


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux