Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dmitry Monakhov and committed by
Al Viro
a1bd120d 52957fe1

+22 -1
+20
fs/inode.c
··· 1606 1606 inode->i_ino); 1607 1607 } 1608 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);
+2 -1
include/linux/fs.h
··· 1428 1428 * VFS file helper functions. 1429 1429 */ 1430 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 1434 * VFS FS_IOC_FIEMAP helper definitions. 1434 1435 */