[PATCH 1/2] fs: implement inode uid/gid setting function

Rui Xiang
2013-08-23T02:48:37Z

Supply a interface inode_set_user to set uid/gid of inode
structs.

Signed-off-by: Rui Xiang <rui.xiang@huawei.com>
---
fs/inode.c | 7 +++++++
include/linux/fs.h | 1 +
2 files changed, 8 insertions(+)

diff --git a/fs/inode.c b/fs/inode.c
index e315c0a..3f90499 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -343,6 +343,13 @@ void inc_nlink(struct inode *inode)
}
EXPORT_SYMBOL(inc_nlink);

+void inode_set_user(struct inode *inode, kuid_t uid, kgid_t gid)
+{
+ inode->i_uid = uid;
+ inode->i_gid = gid;
+}
+EXPORT_SYMBOL(inode_set_user);
+
void address_space_init_once(struct address_space *mapping)
{
memset(mapping, 0, sizeof(*mapping));
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 729e81b..36ac51b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2619,6 +2619,7 @@ void __inode_sub_bytes(struct inode *inode, loff_t bytes);
void inode_sub_bytes(struct inode *inode, loff_t bytes);
loff_t inode_get_bytes(struct inode *inode);
void inode_set_bytes(struct inode *inode, loff_t bytes);
+void inode_set_user(struct inode *inode, kuid_t uid, kgid_t gid);

extern int vfs_readdir(struct file *, filldir_t, void *);
extern int iterate_dir(struct file *, struct dir_context *);
--
1.8.2.2