Skip to content

Commit

Permalink
autofs4: pass mode to autofs4_get_inode() explicitly
Browse files Browse the repository at this point in the history
In all cases we'd set inf->mode to know value just before
passing it to autofs4_get_inode().  That kills the need
to store it in autofs_info and pass it to autofs_init_ino()

Acked-by: Ian Kent <raven@themaw.net>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jan 18, 2011
1 parent 14a2f00 commit 09f12c0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
5 changes: 2 additions & 3 deletions fs/autofs4/autofs_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ struct autofs_info {
uid_t uid;
gid_t gid;

mode_t mode;
size_t size;
};

Expand Down Expand Up @@ -170,7 +169,7 @@ static inline int autofs4_ispending(struct dentry *dentry)
return 0;
}

struct inode *autofs4_get_inode(struct super_block *, struct autofs_info *);
struct inode *autofs4_get_inode(struct super_block *, struct autofs_info *, mode_t);
void autofs4_free_ino(struct autofs_info *);

/* Expiration */
Expand Down Expand Up @@ -280,7 +279,7 @@ static inline void managed_dentry_clear_managed(struct dentry *dentry)
/* Initializing function */

int autofs4_fill_super(struct super_block *, void *, int);
struct autofs_info *autofs4_init_ino(struct autofs_info *, struct autofs_sb_info *sbi, mode_t mode);
struct autofs_info *autofs4_init_ino(struct autofs_info *, struct autofs_sb_info *sbi);

/* Queue management functions */

Expand Down
16 changes: 8 additions & 8 deletions fs/autofs4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <linux/module.h>

struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
struct autofs_sb_info *sbi, mode_t mode)
struct autofs_sb_info *sbi)
{
int reinit = 1;

Expand All @@ -47,7 +47,6 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino,

ino->uid = 0;
ino->gid = 0;
ino->mode = mode;
ino->last_used = jiffies;

ino->sbi = sbi;
Expand Down Expand Up @@ -258,10 +257,10 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
/*
* Get the root inode and dentry, but defer checking for errors.
*/
ino = autofs4_init_ino(NULL, sbi, S_IFDIR | 0755);
ino = autofs4_init_ino(NULL, sbi);
if (!ino)
goto fail_free;
root_inode = autofs4_get_inode(s, ino);
root_inode = autofs4_get_inode(s, ino, S_IFDIR | 0755);
if (!root_inode)
goto fail_ino;

Expand Down Expand Up @@ -345,26 +344,27 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
}

struct inode *autofs4_get_inode(struct super_block *sb,
struct autofs_info *inf)
struct autofs_info *inf,
mode_t mode)
{
struct inode *inode = new_inode(sb);

if (inode == NULL)
return NULL;

inode->i_mode = inf->mode;
inode->i_mode = mode;
if (sb->s_root) {
inode->i_uid = sb->s_root->d_inode->i_uid;
inode->i_gid = sb->s_root->d_inode->i_gid;
}
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_ino = get_next_ino();

if (S_ISDIR(inf->mode)) {
if (S_ISDIR(mode)) {
inode->i_nlink = 2;
inode->i_op = &autofs4_dir_inode_operations;
inode->i_fop = &autofs4_dir_operations;
} else if (S_ISLNK(inf->mode)) {
} else if (S_ISLNK(mode)) {
inode->i_size = inf->size;
inode->i_op = &autofs4_symlink_inode_operations;
}
Expand Down
10 changes: 5 additions & 5 deletions fs/autofs4/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
if (autofs_type_indirect(sbi->type) && IS_ROOT(dentry->d_parent))
__managed_dentry_set_managed(dentry);

ino = autofs4_init_ino(NULL, sbi, 0555);
ino = autofs4_init_ino(NULL, sbi);
if (!ino)
return ERR_PTR(-ENOMEM);

Expand Down Expand Up @@ -538,7 +538,7 @@ static int autofs4_dir_symlink(struct inode *dir,
if (!autofs4_oz_mode(sbi))
return -EACCES;

ino = autofs4_init_ino(ino, sbi, S_IFLNK | 0555);
ino = autofs4_init_ino(ino, sbi);
if (!ino)
return -ENOMEM;

Expand All @@ -554,7 +554,7 @@ static int autofs4_dir_symlink(struct inode *dir,

strcpy(cp, symname);

inode = autofs4_get_inode(dir->i_sb, ino);
inode = autofs4_get_inode(dir->i_sb, ino, S_IFLNK | 0555);
if (!inode) {
kfree(cp);
if (!dentry->d_fsdata)
Expand Down Expand Up @@ -733,13 +733,13 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
DPRINTK("dentry %p, creating %.*s",
dentry, dentry->d_name.len, dentry->d_name.name);

ino = autofs4_init_ino(ino, sbi, S_IFDIR | 0555);
ino = autofs4_init_ino(ino, sbi);
if (!ino)
return -ENOMEM;

autofs4_del_active(dentry);

inode = autofs4_get_inode(dir->i_sb, ino);
inode = autofs4_get_inode(dir->i_sb, ino, S_IFDIR | 0555);
if (!inode) {
if (!dentry->d_fsdata)
kfree(ino);
Expand Down

0 comments on commit 09f12c0

Please sign in to comment.