[PATCH 05/52] CRED: Prepare TMPFS for cred passing

From: David Howells
Date: Fri Oct 12 2007 - 12:07:39 EST


Prepare TMPFS for cred passing.

Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
---

mm/shmem.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index e1fa1c3..49a4b40 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1375,7 +1375,7 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
}

static struct inode *
-shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
+shmem_get_inode(struct super_block *sb, int mode, dev_t dev, struct cred *cred)
{
struct inode *inode;
struct shmem_inode_info *info;
@@ -1394,8 +1394,8 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
inode = new_inode(sb);
if (inode) {
inode->i_mode = mode;
- inode->i_uid = current->cred->uid;
- inode->i_gid = current->cred->gid;
+ inode->i_uid = cred->uid;
+ inode->i_gid = cred->gid;
inode->i_blocks = 0;
inode->i_mapping->a_ops = &shmem_aops;
inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
@@ -1708,7 +1708,8 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
static int
shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
{
- struct inode *inode = shmem_get_inode(dir->i_sb, mode, dev);
+ struct cred *cred = current->cred;
+ struct inode *inode = shmem_get_inode(dir->i_sb, mode, dev, cred);
int error = -ENOSPC;

if (inode) {
@@ -1849,6 +1850,7 @@ static int shmem_rename(struct inode *old_dir, struct dentry *old_dentry, struct

static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
{
+ struct cred *cred = current->cred;
int error;
int len;
struct inode *inode;
@@ -1860,7 +1862,7 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
if (len > PAGE_CACHE_SIZE)
return -ENAMETOOLONG;

- inode = shmem_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0);
+ inode = shmem_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0, cred);
if (!inode)
return -ENOSPC;

@@ -2209,11 +2211,12 @@ static void shmem_put_super(struct super_block *sb)
static int shmem_fill_super(struct super_block *sb,
void *data, int silent)
{
+ struct cred *cred = current->cred;
struct inode *inode;
struct dentry *root;
int mode = S_IRWXUGO | S_ISVTX;
- uid_t uid = current->cred->uid;
- gid_t gid = current->cred->gid;
+ uid_t uid = cred->uid;
+ gid_t gid = cred->gid;
int err = -ENOMEM;
struct shmem_sb_info *sbinfo;
unsigned long blocks = 0;
@@ -2267,7 +2270,7 @@ static int shmem_fill_super(struct super_block *sb,
sb->s_flags |= MS_POSIXACL;
#endif

- inode = shmem_get_inode(sb, S_IFDIR | mode, 0);
+ inode = shmem_get_inode(sb, S_IFDIR | mode, 0, cred);
if (!inode)
goto failed;
inode->i_uid = uid;
@@ -2480,6 +2483,7 @@ module_init(init_tmpfs)
*/
struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
{
+ struct cred *cred = current->cred;
int error;
struct file *file;
struct inode *inode;
@@ -2510,7 +2514,7 @@ struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
goto put_dentry;

error = -ENOSPC;
- inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0);
+ inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0, cred);
if (!inode)
goto close_file;


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/