summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDmitry Monakhov <dmonakhov@openvz.org>2010-03-04 17:29:14 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2010-05-21 18:31:22 -0400
commita1bd120d13e586ea1c424048fd2c8420a442852a (patch)
treefdac342d7ab0fbaaeb1dd7d61a86b457a6938672 /fs
parent52957fe1c709d5ca3732456d73f4e4d95492c72c (diff)
downloadlinux-a1bd120d13e586ea1c424048fd2c8420a442852a.tar.gz
linux-a1bd120d13e586ea1c424048fd2c8420a442852a.tar.bz2
linux-a1bd120d13e586ea1c424048fd2c8420a442852a.zip
vfs: Add inode uid,gid,mode init helper
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/inode.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/inode.c b/fs/inode.c
index 498b10f04c3c..2bee20ae3d65 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1606,3 +1606,23 @@ void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev)
inode->i_ino);
}
EXPORT_SYMBOL(init_special_inode);
+
+/**
+ * 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,
+ mode_t 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);