aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/fid.c4
-rw-r--r--fs/9p/v9fs.c51
-rw-r--r--fs/9p/v9fs.h5
-rw-r--r--fs/9p/vfs_file.c4
-rw-r--r--fs/9p/vfs_inode.c7
5 files changed, 23 insertions, 48 deletions
diff --git a/fs/9p/fid.c b/fs/9p/fid.c
index b364da70ff28..dfebdbe7440e 100644
--- a/fs/9p/fid.c
+++ b/fs/9p/fid.c
@@ -175,7 +175,7 @@ struct p9_fid *v9fs_fid_lookup(struct dentry *dentry)
175 if (!wnames) 175 if (!wnames)
176 return ERR_PTR(-ENOMEM); 176 return ERR_PTR(-ENOMEM);
177 177
178 for (d = dentry, i = n; i >= 0; i--, d = d->d_parent) 178 for (d = dentry, i = (n-1); i >= 0; i--, d = d->d_parent)
179 wnames[i] = (char *) d->d_name.name; 179 wnames[i] = (char *) d->d_name.name;
180 180
181 clone = 1; 181 clone = 1;
@@ -183,7 +183,7 @@ struct p9_fid *v9fs_fid_lookup(struct dentry *dentry)
183 while (i < n) { 183 while (i < n) {
184 l = min(n - i, P9_MAXWELEM); 184 l = min(n - i, P9_MAXWELEM);
185 fid = p9_client_walk(fid, l, &wnames[i], clone); 185 fid = p9_client_walk(fid, l, &wnames[i], clone);
186 if (!fid) { 186 if (IS_ERR(fid)) {
187 kfree(wnames); 187 kfree(wnames);
188 return fid; 188 return fid;
189 } 189 }
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index fbb12dadba83..9b0f0222e8bb 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * This file contains functions assisting in mapping VFS to 9P2000 4 * This file contains functions assisting in mapping VFS to 9P2000
5 * 5 *
6 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 6 * Copyright (C) 2004-2008 by Eric Van Hensbergen <ericvh@gmail.com>
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
@@ -31,7 +31,6 @@
31#include <linux/idr.h> 31#include <linux/idr.h>
32#include <net/9p/9p.h> 32#include <net/9p/9p.h>
33#include <net/9p/transport.h> 33#include <net/9p/transport.h>
34#include <net/9p/conn.h>
35#include <net/9p/client.h> 34#include <net/9p/client.h>
36#include "v9fs.h" 35#include "v9fs.h"
37#include "v9fs_vfs.h" 36#include "v9fs_vfs.h"
@@ -43,11 +42,11 @@
43 42
44enum { 43enum {
45 /* Options that take integer arguments */ 44 /* Options that take integer arguments */
46 Opt_debug, Opt_msize, Opt_dfltuid, Opt_dfltgid, Opt_afid, 45 Opt_debug, Opt_dfltuid, Opt_dfltgid, Opt_afid,
47 /* String options */ 46 /* String options */
48 Opt_uname, Opt_remotename, Opt_trans, 47 Opt_uname, Opt_remotename, Opt_trans,
49 /* Options that take no arguments */ 48 /* Options that take no arguments */
50 Opt_legacy, Opt_nodevmap, 49 Opt_nodevmap,
51 /* Cache options */ 50 /* Cache options */
52 Opt_cache_loose, 51 Opt_cache_loose,
53 /* Access options */ 52 /* Access options */
@@ -58,14 +57,11 @@ enum {
58 57
59static match_table_t tokens = { 58static match_table_t tokens = {
60 {Opt_debug, "debug=%x"}, 59 {Opt_debug, "debug=%x"},
61 {Opt_msize, "msize=%u"},
62 {Opt_dfltuid, "dfltuid=%u"}, 60 {Opt_dfltuid, "dfltuid=%u"},
63 {Opt_dfltgid, "dfltgid=%u"}, 61 {Opt_dfltgid, "dfltgid=%u"},
64 {Opt_afid, "afid=%u"}, 62 {Opt_afid, "afid=%u"},
65 {Opt_uname, "uname=%s"}, 63 {Opt_uname, "uname=%s"},
66 {Opt_remotename, "aname=%s"}, 64 {Opt_remotename, "aname=%s"},
67 {Opt_trans, "trans=%s"},
68 {Opt_legacy, "noextend"},
69 {Opt_nodevmap, "nodevmap"}, 65 {Opt_nodevmap, "nodevmap"},
70 {Opt_cache_loose, "cache=loose"}, 66 {Opt_cache_loose, "cache=loose"},
71 {Opt_cache_loose, "loose"}, 67 {Opt_cache_loose, "loose"},
@@ -85,16 +81,14 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
85 char *options; 81 char *options;
86 substring_t args[MAX_OPT_ARGS]; 82 substring_t args[MAX_OPT_ARGS];
87 char *p; 83 char *p;
88 int option; 84 int option = 0;
89 int ret;
90 char *s, *e; 85 char *s, *e;
86 int ret;
91 87
92 /* setup defaults */ 88 /* setup defaults */
93 v9ses->maxdata = 8192;
94 v9ses->afid = ~0; 89 v9ses->afid = ~0;
95 v9ses->debug = 0; 90 v9ses->debug = 0;
96 v9ses->cache = 0; 91 v9ses->cache = 0;
97 v9ses->trans = v9fs_default_trans();
98 92
99 if (!v9ses->options) 93 if (!v9ses->options)
100 return; 94 return;
@@ -106,7 +100,8 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
106 continue; 100 continue;
107 token = match_token(p, tokens, args); 101 token = match_token(p, tokens, args);
108 if (token < Opt_uname) { 102 if (token < Opt_uname) {
109 if ((ret = match_int(&args[0], &option)) < 0) { 103 ret = match_int(&args[0], &option);
104 if (ret < 0) {
110 P9_DPRINTK(P9_DEBUG_ERROR, 105 P9_DPRINTK(P9_DEBUG_ERROR,
111 "integer field, but no integer?\n"); 106 "integer field, but no integer?\n");
112 continue; 107 continue;
@@ -119,9 +114,7 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
119 p9_debug_level = option; 114 p9_debug_level = option;
120#endif 115#endif
121 break; 116 break;
122 case Opt_msize: 117
123 v9ses->maxdata = option;
124 break;
125 case Opt_dfltuid: 118 case Opt_dfltuid:
126 v9ses->dfltuid = option; 119 v9ses->dfltuid = option;
127 break; 120 break;
@@ -131,18 +124,12 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
131 case Opt_afid: 124 case Opt_afid:
132 v9ses->afid = option; 125 v9ses->afid = option;
133 break; 126 break;
134 case Opt_trans:
135 v9ses->trans = v9fs_match_trans(&args[0]);
136 break;
137 case Opt_uname: 127 case Opt_uname:
138 match_strcpy(v9ses->uname, &args[0]); 128 match_strcpy(v9ses->uname, &args[0]);
139 break; 129 break;
140 case Opt_remotename: 130 case Opt_remotename:
141 match_strcpy(v9ses->aname, &args[0]); 131 match_strcpy(v9ses->aname, &args[0]);
142 break; 132 break;
143 case Opt_legacy:
144 v9ses->flags &= ~V9FS_EXTENDED;
145 break;
146 case Opt_nodevmap: 133 case Opt_nodevmap:
147 v9ses->nodev = 1; 134 v9ses->nodev = 1;
148 break; 135 break;
@@ -185,7 +172,6 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
185 const char *dev_name, char *data) 172 const char *dev_name, char *data)
186{ 173{
187 int retval = -EINVAL; 174 int retval = -EINVAL;
188 struct p9_trans *trans = NULL;
189 struct p9_fid *fid; 175 struct p9_fid *fid;
190 176
191 v9ses->uname = __getname(); 177 v9ses->uname = __getname();
@@ -207,24 +193,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
207 v9ses->options = kstrdup(data, GFP_KERNEL); 193 v9ses->options = kstrdup(data, GFP_KERNEL);
208 v9fs_parse_options(v9ses); 194 v9fs_parse_options(v9ses);
209 195
210 if (v9ses->trans == NULL) { 196 v9ses->clnt = p9_client_create(dev_name, v9ses->options);
211 retval = -EPROTONOSUPPORT;
212 P9_DPRINTK(P9_DEBUG_ERROR,
213 "No transport defined or default transport\n");
214 goto error;
215 }
216
217 trans = v9ses->trans->create(dev_name, v9ses->options);
218 if (IS_ERR(trans)) {
219 retval = PTR_ERR(trans);
220 trans = NULL;
221 goto error;
222 }
223 if ((v9ses->maxdata+P9_IOHDRSZ) > v9ses->trans->maxsize)
224 v9ses->maxdata = v9ses->trans->maxsize-P9_IOHDRSZ;
225
226 v9ses->clnt = p9_client_create(trans, v9ses->maxdata+P9_IOHDRSZ,
227 v9fs_extended(v9ses));
228 197
229 if (IS_ERR(v9ses->clnt)) { 198 if (IS_ERR(v9ses->clnt)) {
230 retval = PTR_ERR(v9ses->clnt); 199 retval = PTR_ERR(v9ses->clnt);
@@ -236,6 +205,8 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
236 if (!v9ses->clnt->dotu) 205 if (!v9ses->clnt->dotu)
237 v9ses->flags &= ~V9FS_EXTENDED; 206 v9ses->flags &= ~V9FS_EXTENDED;
238 207
208 v9ses->maxdata = v9ses->clnt->msize;
209
239 /* for legacy mode, fall back to V9FS_ACCESS_ANY */ 210 /* for legacy mode, fall back to V9FS_ACCESS_ANY */
240 if (!v9fs_extended(v9ses) && 211 if (!v9fs_extended(v9ses) &&
241 ((v9ses->flags&V9FS_ACCESS_MASK) == V9FS_ACCESS_USER)) { 212 ((v9ses->flags&V9FS_ACCESS_MASK) == V9FS_ACCESS_USER)) {
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index db4b4193f2e2..7d3a1018db52 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * V9FS definitions. 2 * V9FS definitions.
3 * 3 *
4 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 4 * Copyright (C) 2004-2008 by Eric Van Hensbergen <ericvh@gmail.com>
5 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 5 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,6 @@
28 28
29struct v9fs_session_info { 29struct v9fs_session_info {
30 /* options */ 30 /* options */
31 unsigned int maxdata;
32 unsigned char flags; /* session flags */ 31 unsigned char flags; /* session flags */
33 unsigned char nodev; /* set to 1 if no disable device mapping */ 32 unsigned char nodev; /* set to 1 if no disable device mapping */
34 unsigned short debug; /* debug level */ 33 unsigned short debug; /* debug level */
@@ -38,10 +37,10 @@ struct v9fs_session_info {
38 char *options; /* copy of mount options */ 37 char *options; /* copy of mount options */
39 char *uname; /* user name to mount as */ 38 char *uname; /* user name to mount as */
40 char *aname; /* name of remote hierarchy being mounted */ 39 char *aname; /* name of remote hierarchy being mounted */
40 unsigned int maxdata; /* max data for client interface */
41 unsigned int dfltuid; /* default uid/muid for legacy support */ 41 unsigned int dfltuid; /* default uid/muid for legacy support */
42 unsigned int dfltgid; /* default gid for legacy support */ 42 unsigned int dfltgid; /* default gid for legacy support */
43 u32 uid; /* if ACCESS_SINGLE, the uid that has access */ 43 u32 uid; /* if ACCESS_SINGLE, the uid that has access */
44 struct p9_trans_module *trans; /* 9p transport */
45 struct p9_client *clnt; /* 9p client */ 44 struct p9_client *clnt; /* 9p client */
46 struct dentry *debugfs_dir; 45 struct dentry *debugfs_dir;
47}; 46};
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index ba4b1caa9c43..a616fff8906d 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -184,7 +184,7 @@ static const struct file_operations v9fs_cached_file_operations = {
184 .open = v9fs_file_open, 184 .open = v9fs_file_open,
185 .release = v9fs_dir_release, 185 .release = v9fs_dir_release,
186 .lock = v9fs_file_lock, 186 .lock = v9fs_file_lock,
187 .mmap = generic_file_mmap, 187 .mmap = generic_file_readonly_mmap,
188}; 188};
189 189
190const struct file_operations v9fs_file_operations = { 190const struct file_operations v9fs_file_operations = {
@@ -194,5 +194,5 @@ const struct file_operations v9fs_file_operations = {
194 .open = v9fs_file_open, 194 .open = v9fs_file_open,
195 .release = v9fs_dir_release, 195 .release = v9fs_dir_release,
196 .lock = v9fs_file_lock, 196 .lock = v9fs_file_lock,
197 .mmap = generic_file_mmap, 197 .mmap = generic_file_readonly_mmap,
198}; 198};
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 23581bcb599b..6a28842052ea 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -77,6 +77,8 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
77 res |= P9_DMSETUID; 77 res |= P9_DMSETUID;
78 if ((mode & S_ISGID) == S_ISGID) 78 if ((mode & S_ISGID) == S_ISGID)
79 res |= P9_DMSETGID; 79 res |= P9_DMSETGID;
80 if ((mode & S_ISVTX) == S_ISVTX)
81 res |= P9_DMSETVTX;
80 if ((mode & P9_DMLINK)) 82 if ((mode & P9_DMLINK))
81 res |= P9_DMLINK; 83 res |= P9_DMLINK;
82 } 84 }
@@ -119,6 +121,9 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
119 121
120 if ((mode & P9_DMSETGID) == P9_DMSETGID) 122 if ((mode & P9_DMSETGID) == P9_DMSETGID)
121 res |= S_ISGID; 123 res |= S_ISGID;
124
125 if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
126 res |= S_ISVTX;
122 } 127 }
123 128
124 return res; 129 return res;
@@ -568,7 +573,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
568 v9ses = v9fs_inode2v9ses(dir); 573 v9ses = v9fs_inode2v9ses(dir);
569 dfid = v9fs_fid_lookup(dentry->d_parent); 574 dfid = v9fs_fid_lookup(dentry->d_parent);
570 if (IS_ERR(dfid)) 575 if (IS_ERR(dfid))
571 return ERR_PTR(PTR_ERR(dfid)); 576 return ERR_CAST(dfid);
572 577
573 name = (char *) dentry->d_name.name; 578 name = (char *) dentry->d_name.name;
574 fid = p9_client_walk(dfid, 1, &name, 1); 579 fid = p9_client_walk(dfid, 1, &name, 1);