X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=fs%2Finode.c;fp=fs%2Finode.c;h=2bee20ae3d65ba74f970129ec8d147ab7cd4fe50;hb=a1bd120d13e586ea1c424048fd2c8420a442852a;hp=498b10f04c3c7a4a7e5bc527deb9eaccd6385ab2;hpb=52957fe1c709d5ca3732456d73f4e4d95492c72c;p=safe%2Fjmp%2Flinux-2.6 diff --git a/fs/inode.c b/fs/inode.c index 498b10f..2bee20a 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);