Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/ericvh/v9fs

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs:
  9p: update documentation pointers
  9p: remove unnecessary v9fses->options which duplicates the mount string
  net/9p: insulate the client against an invalid error code sent by a 9p server
  9p: Add missing cast for the error return value in v9fs_get_inode
  9p: Remove redundant inode uid/gid assignment
  9p: Fix possible regressions when ->get_sb fails.
  9p: Fix v9fs show_options
  9p: Fix possible memleak in v9fs_inode_from fid.
  9p: minor comment fixes
  9p: Fix possible inode leak in v9fs_get_inode.
  9p: Check for error in return value of v9fs_fid_add
  • Loading branch information
torvalds committed Aug 27, 2009
2 parents 788d908 + 7815f4b commit cf48144
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 134 deletions.
3 changes: 3 additions & 0 deletions Documentation/filesystems/9p.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ available from the same CVS repository.
There are user and developer mailing lists available through the v9fs project
on sourceforge (http://sourceforge.net/projects/v9fs).

A stand-alone version of the module (which should build for any 2.6 kernel)
is available via (http://github.com/ericvh/9p-sac/tree/master)

News and other information is maintained on SWiK (http://swik.net/v9fs).

Bug reports may be issued through the kernel.org bugzilla
Expand Down
21 changes: 5 additions & 16 deletions fs/9p/v9fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static const match_table_t tokens = {
* Return 0 upon success, -ERRNO upon failure.
*/

static int v9fs_parse_options(struct v9fs_session_info *v9ses)
static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
{
char *options;
substring_t args[MAX_OPT_ARGS];
Expand All @@ -90,10 +90,10 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses)
v9ses->debug = 0;
v9ses->cache = 0;

if (!v9ses->options)
if (!opts)
return 0;

options = kstrdup(v9ses->options, GFP_KERNEL);
options = kstrdup(opts, GFP_KERNEL);
if (!options) {
P9_DPRINTK(P9_DEBUG_ERROR,
"failed to allocate copy of option string\n");
Expand Down Expand Up @@ -206,24 +206,14 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
v9ses->uid = ~0;
v9ses->dfltuid = V9FS_DEFUID;
v9ses->dfltgid = V9FS_DEFGID;
if (data) {
v9ses->options = kstrdup(data, GFP_KERNEL);
if (!v9ses->options) {
P9_DPRINTK(P9_DEBUG_ERROR,
"failed to allocate copy of option string\n");
retval = -ENOMEM;
goto error;
}
}

rc = v9fs_parse_options(v9ses);
rc = v9fs_parse_options(v9ses, data);
if (rc < 0) {
retval = rc;
goto error;
}

v9ses->clnt = p9_client_create(dev_name, v9ses->options);

v9ses->clnt = p9_client_create(dev_name, data);
if (IS_ERR(v9ses->clnt)) {
retval = PTR_ERR(v9ses->clnt);
v9ses->clnt = NULL;
Expand Down Expand Up @@ -280,7 +270,6 @@ void v9fs_session_close(struct v9fs_session_info *v9ses)

__putname(v9ses->uname);
__putname(v9ses->aname);
kfree(v9ses->options);
}

/**
Expand Down
1 change: 0 additions & 1 deletion fs/9p/v9fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ struct v9fs_session_info {
unsigned int afid;
unsigned int cache;

char *options; /* copy of mount options */
char *uname; /* user name to mount as */
char *aname; /* name of remote hierarchy being mounted */
unsigned int maxdata; /* max data for client interface */
Expand Down
126 changes: 65 additions & 61 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ int v9fs_uflags2omode(int uflags, int extended)

/**
* v9fs_blank_wstat - helper function to setup a 9P stat structure
* @v9ses: 9P session info (for determining extended mode)
* @wstat: structure to initialize
*
*/
Expand Down Expand Up @@ -207,65 +206,72 @@ v9fs_blank_wstat(struct p9_wstat *wstat)

struct inode *v9fs_get_inode(struct super_block *sb, int mode)
{
int err;
struct inode *inode;
struct v9fs_session_info *v9ses = sb->s_fs_info;

P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode);

inode = new_inode(sb);
if (inode) {
inode->i_mode = mode;
inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid();
inode->i_blocks = 0;
inode->i_rdev = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_mapping->a_ops = &v9fs_addr_operations;

switch (mode & S_IFMT) {
case S_IFIFO:
case S_IFBLK:
case S_IFCHR:
case S_IFSOCK:
if (!v9fs_extended(v9ses)) {
P9_DPRINTK(P9_DEBUG_ERROR,
"special files without extended mode\n");
return ERR_PTR(-EINVAL);
}
init_special_inode(inode, inode->i_mode,
inode->i_rdev);
break;
case S_IFREG:
inode->i_op = &v9fs_file_inode_operations;
inode->i_fop = &v9fs_file_operations;
break;
case S_IFLNK:
if (!v9fs_extended(v9ses)) {
P9_DPRINTK(P9_DEBUG_ERROR,
"extended modes used w/o 9P2000.u\n");
return ERR_PTR(-EINVAL);
}
inode->i_op = &v9fs_symlink_inode_operations;
break;
case S_IFDIR:
inc_nlink(inode);
if (v9fs_extended(v9ses))
inode->i_op = &v9fs_dir_inode_operations_ext;
else
inode->i_op = &v9fs_dir_inode_operations;
inode->i_fop = &v9fs_dir_operations;
break;
default:
P9_DPRINTK(P9_DEBUG_ERROR,
"BAD mode 0x%x S_IFMT 0x%x\n",
mode, mode & S_IFMT);
return ERR_PTR(-EINVAL);
}
} else {
if (!inode) {
P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
return ERR_PTR(-ENOMEM);
}

inode->i_mode = mode;
inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid();
inode->i_blocks = 0;
inode->i_rdev = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_mapping->a_ops = &v9fs_addr_operations;

switch (mode & S_IFMT) {
case S_IFIFO:
case S_IFBLK:
case S_IFCHR:
case S_IFSOCK:
if (!v9fs_extended(v9ses)) {
P9_DPRINTK(P9_DEBUG_ERROR,
"special files without extended mode\n");
err = -EINVAL;
goto error;
}
init_special_inode(inode, inode->i_mode, inode->i_rdev);
break;
case S_IFREG:
inode->i_op = &v9fs_file_inode_operations;
inode->i_fop = &v9fs_file_operations;
break;
case S_IFLNK:
if (!v9fs_extended(v9ses)) {
P9_DPRINTK(P9_DEBUG_ERROR,
"extended modes used w/o 9P2000.u\n");
err = -EINVAL;
goto error;
}
inode->i_op = &v9fs_symlink_inode_operations;
break;
case S_IFDIR:
inc_nlink(inode);
if (v9fs_extended(v9ses))
inode->i_op = &v9fs_dir_inode_operations_ext;
else
inode->i_op = &v9fs_dir_inode_operations;
inode->i_fop = &v9fs_dir_operations;
break;
default:
P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n",
mode, mode & S_IFMT);
err = -EINVAL;
goto error;
}

return inode;

error:
iput(inode);
return ERR_PTR(err);
}

/*
Expand Down Expand Up @@ -338,30 +344,25 @@ v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,

ret = NULL;
st = p9_client_stat(fid);
if (IS_ERR(st)) {
err = PTR_ERR(st);
st = NULL;
goto error;
}
if (IS_ERR(st))
return ERR_CAST(st);

umode = p9mode2unixmode(v9ses, st->mode);
ret = v9fs_get_inode(sb, umode);
if (IS_ERR(ret)) {
err = PTR_ERR(ret);
ret = NULL;
goto error;
}

v9fs_stat2inode(st, ret, sb);
ret->i_ino = v9fs_qid2ino(&st->qid);
p9stat_free(st);
kfree(st);
return ret;

error:
p9stat_free(st);
kfree(st);
if (ret)
iput(ret);

return ERR_PTR(err);
}

Expand Down Expand Up @@ -403,9 +404,9 @@ v9fs_open_created(struct inode *inode, struct file *file)
* @v9ses: session information
* @dir: directory that dentry is being created in
* @dentry: dentry that is being created
* @extension: 9p2000.u extension string to support devices, etc.
* @perm: create permissions
* @mode: open mode
* @extension: 9p2000.u extension string to support devices, etc.
*
*/
static struct p9_fid *
Expand Down Expand Up @@ -470,7 +471,10 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
dentry->d_op = &v9fs_dentry_operations;

d_instantiate(dentry, inode);
v9fs_fid_add(dentry, fid);
err = v9fs_fid_add(dentry, fid);
if (err < 0)
goto error;

return ofid;

error:
Expand Down
39 changes: 12 additions & 27 deletions fs/9p/vfs_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static int v9fs_set_super(struct super_block *s, void *data)

static void
v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
int flags)
int flags, void *data)
{
sb->s_maxbytes = MAX_LFS_FILESIZE;
sb->s_blocksize_bits = fls(v9ses->maxdata - 1);
Expand All @@ -91,6 +91,8 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,

sb->s_flags = flags | MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC |
MS_NOATIME;

save_mount_options(sb, data);
}

/**
Expand All @@ -113,14 +115,11 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
struct v9fs_session_info *v9ses = NULL;
struct p9_wstat *st = NULL;
int mode = S_IRWXUGO | S_ISVTX;
uid_t uid = current_fsuid();
gid_t gid = current_fsgid();
struct p9_fid *fid;
int retval = 0;

P9_DPRINTK(P9_DEBUG_VFS, " \n");

st = NULL;
v9ses = kzalloc(sizeof(struct v9fs_session_info), GFP_KERNEL);
if (!v9ses)
return -ENOMEM;
Expand All @@ -142,17 +141,14 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
retval = PTR_ERR(sb);
goto free_stat;
}
v9fs_fill_super(sb, v9ses, flags);
v9fs_fill_super(sb, v9ses, flags, data);

inode = v9fs_get_inode(sb, S_IFDIR | mode);
if (IS_ERR(inode)) {
retval = PTR_ERR(inode);
goto release_sb;
}

inode->i_uid = uid;
inode->i_gid = gid;

root = d_alloc_root(inode);
if (!root) {
iput(inode);
Expand All @@ -173,10 +169,8 @@ P9_DPRINTK(P9_DEBUG_VFS, " simple set mount, return 0\n");
simple_set_mnt(mnt, sb);
return 0;

release_sb:
deactivate_locked_super(sb);

free_stat:
p9stat_free(st);
kfree(st);

clunk_fid:
Expand All @@ -185,7 +179,12 @@ P9_DPRINTK(P9_DEBUG_VFS, " simple set mount, return 0\n");
close_session:
v9fs_session_close(v9ses);
kfree(v9ses);
return retval;

release_sb:
p9stat_free(st);
kfree(st);
deactivate_locked_super(sb);
return retval;
}

Expand All @@ -207,24 +206,10 @@ static void v9fs_kill_super(struct super_block *s)

v9fs_session_close(v9ses);
kfree(v9ses);
s->s_fs_info = NULL;
P9_DPRINTK(P9_DEBUG_VFS, "exiting kill_super\n");
}

/**
* v9fs_show_options - Show mount options in /proc/mounts
* @m: seq_file to write to
* @mnt: mount descriptor
*
*/

static int v9fs_show_options(struct seq_file *m, struct vfsmount *mnt)
{
struct v9fs_session_info *v9ses = mnt->mnt_sb->s_fs_info;

seq_printf(m, "%s", v9ses->options);
return 0;
}

static void
v9fs_umount_begin(struct super_block *sb)
{
Expand All @@ -237,7 +222,7 @@ v9fs_umount_begin(struct super_block *sb)
static const struct super_operations v9fs_super_ops = {
.statfs = simple_statfs,
.clear_inode = v9fs_clear_inode,
.show_options = v9fs_show_options,
.show_options = generic_show_options,
.umount_begin = v9fs_umount_begin,
};

Expand Down
Loading

0 comments on commit cf48144

Please sign in to comment.