diff options
author | Dmitry Monakhov <dmonakhov@openvz.org> | 2010-03-04 09:29:14 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-05-21 18:31:22 -0400 |
commit | a1bd120d13e586ea1c424048fd2c8420a442852a (patch) | |
tree | fdac342d7ab0fbaaeb1dd7d61a86b457a6938672 | |
parent | 52957fe1c709d5ca3732456d73f4e4d95492c72c (diff) |
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>
-rw-r--r-- | fs/inode.c | 20 | ||||
-rw-r--r-- | include/linux/fs.h | 3 |
2 files changed, 22 insertions, 1 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) | |||
1606 | inode->i_ino); | 1606 | inode->i_ino); |
1607 | } | 1607 | } |
1608 | EXPORT_SYMBOL(init_special_inode); | 1608 | EXPORT_SYMBOL(init_special_inode); |
1609 | |||
1610 | /** | ||
1611 | * Init uid,gid,mode for new inode according to posix standards | ||
1612 | * @inode: New inode | ||
1613 | * @dir: Directory inode | ||
1614 | * @mode: mode of the new inode | ||
1615 | */ | ||
1616 | void inode_init_owner(struct inode *inode, const struct inode *dir, | ||
1617 | mode_t mode) | ||
1618 | { | ||
1619 | inode->i_uid = current_fsuid(); | ||
1620 | if (dir && dir->i_mode & S_ISGID) { | ||
1621 | inode->i_gid = dir->i_gid; | ||
1622 | if (S_ISDIR(mode)) | ||
1623 | mode |= S_ISGID; | ||
1624 | } else | ||
1625 | inode->i_gid = current_fsgid(); | ||
1626 | inode->i_mode = mode; | ||
1627 | } | ||
1628 | EXPORT_SYMBOL(inode_init_owner); | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index 9626c5fbb0e1..8a733862a411 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1428,7 +1428,8 @@ extern void dentry_unhash(struct dentry *dentry); | |||
1428 | * VFS file helper functions. | 1428 | * VFS file helper functions. |
1429 | */ | 1429 | */ |
1430 | extern int file_permission(struct file *, int); | 1430 | extern int file_permission(struct file *, int); |
1431 | 1431 | extern void inode_init_owner(struct inode *inode, const struct inode *dir, | |
1432 | mode_t mode); | ||
1432 | /* | 1433 | /* |
1433 | * VFS FS_IOC_FIEMAP helper definitions. | 1434 | * VFS FS_IOC_FIEMAP helper definitions. |
1434 | */ | 1435 | */ |