Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf481442 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* '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
parents 788d908f 7815f4be
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -123,6 +123,9 @@ available from the same CVS repository.
There are user and developer mailing lists available through the v9fs project
There are user and developer mailing lists available through the v9fs project
on sourceforge (http://sourceforge.net/projects/v9fs).
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).
News and other information is maintained on SWiK (http://swik.net/v9fs).


Bug reports may be issued through the kernel.org bugzilla 
Bug reports may be issued through the kernel.org bugzilla 
+5 −16
Original line number Original line Diff line number Diff line
@@ -76,7 +76,7 @@ static const match_table_t tokens = {
 * Return 0 upon success, -ERRNO upon failure.
 * 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;
	char *options;
	substring_t args[MAX_OPT_ARGS];
	substring_t args[MAX_OPT_ARGS];
@@ -90,10 +90,10 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses)
	v9ses->debug = 0;
	v9ses->debug = 0;
	v9ses->cache = 0;
	v9ses->cache = 0;


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


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


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

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


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


/**
/**
+0 −1
Original line number Original line Diff line number Diff line
@@ -85,7 +85,6 @@ struct v9fs_session_info {
	unsigned int afid;
	unsigned int afid;
	unsigned int cache;
	unsigned int cache;


	char *options;		/* copy of mount options */
	char *uname;		/* user name to mount as */
	char *uname;		/* user name to mount as */
	char *aname;		/* name of remote hierarchy being mounted */
	char *aname;		/* name of remote hierarchy being mounted */
	unsigned int maxdata;	/* max data for client interface */
	unsigned int maxdata;	/* max data for client interface */
+65 −61
Original line number Original line Diff line number Diff line
@@ -171,7 +171,6 @@ int v9fs_uflags2omode(int uflags, int extended)


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


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


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


	inode = new_inode(sb);
	inode = new_inode(sb);
	if (inode) {
	if (!inode) {
		P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
		return ERR_PTR(-ENOMEM);
	}

	inode->i_mode = mode;
	inode->i_mode = mode;
	inode->i_uid = current_fsuid();
	inode->i_uid = current_fsuid();
	inode->i_gid = current_fsgid();
	inode->i_gid = current_fsgid();
@@ -230,10 +234,10 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
		if (!v9fs_extended(v9ses)) {
		if (!v9fs_extended(v9ses)) {
			P9_DPRINTK(P9_DEBUG_ERROR,
			P9_DPRINTK(P9_DEBUG_ERROR,
				   "special files without extended mode\n");
				   "special files without extended mode\n");
				return ERR_PTR(-EINVAL);
			err = -EINVAL;
			goto error;
		}
		}
			init_special_inode(inode, inode->i_mode,
		init_special_inode(inode, inode->i_mode, inode->i_rdev);
					   inode->i_rdev);
		break;
		break;
	case S_IFREG:
	case S_IFREG:
		inode->i_op = &v9fs_file_inode_operations;
		inode->i_op = &v9fs_file_inode_operations;
@@ -243,7 +247,8 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
		if (!v9fs_extended(v9ses)) {
		if (!v9fs_extended(v9ses)) {
			P9_DPRINTK(P9_DEBUG_ERROR,
			P9_DPRINTK(P9_DEBUG_ERROR,
				   "extended modes used w/o 9P2000.u\n");
				   "extended modes used w/o 9P2000.u\n");
				return ERR_PTR(-EINVAL);
			err = -EINVAL;
			goto error;
		}
		}
		inode->i_op = &v9fs_symlink_inode_operations;
		inode->i_op = &v9fs_symlink_inode_operations;
		break;
		break;
@@ -256,16 +261,17 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
		inode->i_fop = &v9fs_dir_operations;
		inode->i_fop = &v9fs_dir_operations;
		break;
		break;
	default:
	default:
			P9_DPRINTK(P9_DEBUG_ERROR,
		P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n",
				"BAD mode 0x%x S_IFMT 0x%x\n",
			   mode, mode & S_IFMT);
			   mode, mode & S_IFMT);
			return ERR_PTR(-EINVAL);
		err = -EINVAL;
		}
		goto error;
	} else {
		P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
		return ERR_PTR(-ENOMEM);
	}
	}

	return inode;
	return inode;

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


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


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


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


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


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

	return ERR_PTR(err);
	return ERR_PTR(err);
}
}


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


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

	return ofid;
	return ofid;


error:
error:
+12 −27
Original line number Original line Diff line number Diff line
@@ -81,7 +81,7 @@ static int v9fs_set_super(struct super_block *s, void *data)


static void
static void
v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
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_maxbytes = MAX_LFS_FILESIZE;
	sb->s_blocksize_bits = fls(v9ses->maxdata - 1);
	sb->s_blocksize_bits = fls(v9ses->maxdata - 1);
@@ -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 |
	sb->s_flags = flags | MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC |
	    MS_NOATIME;
	    MS_NOATIME;

	save_mount_options(sb, data);
}
}


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


	P9_DPRINTK(P9_DEBUG_VFS, " \n");
	P9_DPRINTK(P9_DEBUG_VFS, " \n");


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


	inode = v9fs_get_inode(sb, S_IFDIR | mode);
	inode = v9fs_get_inode(sb, S_IFDIR | mode);
	if (IS_ERR(inode)) {
	if (IS_ERR(inode)) {
@@ -150,9 +149,6 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
		goto release_sb;
		goto release_sb;
	}
	}


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

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


release_sb:
	deactivate_locked_super(sb);

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


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


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


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


	v9fs_session_close(v9ses);
	v9fs_session_close(v9ses);
	kfree(v9ses);
	kfree(v9ses);
	s->s_fs_info = NULL;
	P9_DPRINTK(P9_DEBUG_VFS, "exiting kill_super\n");
	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
static void
v9fs_umount_begin(struct super_block *sb)
v9fs_umount_begin(struct super_block *sb)
{
{
@@ -237,7 +222,7 @@ v9fs_umount_begin(struct super_block *sb)
static const struct super_operations v9fs_super_ops = {
static const struct super_operations v9fs_super_ops = {
	.statfs = simple_statfs,
	.statfs = simple_statfs,
	.clear_inode = v9fs_clear_inode,
	.clear_inode = v9fs_clear_inode,
	.show_options = v9fs_show_options,
	.show_options = generic_show_options,
	.umount_begin = v9fs_umount_begin,
	.umount_begin = v9fs_umount_begin,
};
};


Loading