diff options
author | Sripathi Kodi <sripathik@in.ibm.com> | 2010-03-05 13:48:00 -0500 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2010-03-05 16:04:41 -0500 |
commit | dd6102fbd917889384d89bc427e98e85e8fda000 (patch) | |
tree | 06028b4b6a964c6a1578702c69c0731e3f03538c | |
parent | c1a7c2262035e83a8f70ebe1328b3451702cf51b (diff) |
9P2010.L handshake: Add VFS flags
Add 9P2000.u and 9P2010.L protocol flags to V9FS VFS
This patch adds 9P2000.u and 9P2010.L protocol flags into V9FS VFS side code
and removes the single flag used for 'extended'.
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
-rw-r--r-- | fs/9p/fid.c | 2 | ||||
-rw-r--r-- | fs/9p/v9fs.c | 6 | ||||
-rw-r--r-- | fs/9p/v9fs.h | 23 | ||||
-rw-r--r-- | fs/9p/vfs_file.c | 4 | ||||
-rw-r--r-- | fs/9p/vfs_inode.c | 29 |
5 files changed, 36 insertions, 28 deletions
diff --git a/fs/9p/fid.c b/fs/9p/fid.c index 14d944204571..08b2eb157048 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c | |||
@@ -151,7 +151,7 @@ struct p9_fid *v9fs_fid_lookup(struct dentry *dentry) | |||
151 | if (access == V9FS_ACCESS_SINGLE) | 151 | if (access == V9FS_ACCESS_SINGLE) |
152 | return ERR_PTR(-EPERM); | 152 | return ERR_PTR(-EPERM); |
153 | 153 | ||
154 | if (v9fs_extended(v9ses)) | 154 | if (v9fs_proto_dotu(v9ses)) |
155 | uname = NULL; | 155 | uname = NULL; |
156 | else | 156 | else |
157 | uname = v9ses->uname; | 157 | uname = v9ses->uname; |
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 7d6c2139891d..247f10a934ed 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c | |||
@@ -241,7 +241,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, | |||
241 | list_add(&v9ses->slist, &v9fs_sessionlist); | 241 | list_add(&v9ses->slist, &v9fs_sessionlist); |
242 | spin_unlock(&v9fs_sessionlist_lock); | 242 | spin_unlock(&v9fs_sessionlist_lock); |
243 | 243 | ||
244 | v9ses->flags = V9FS_EXTENDED | V9FS_ACCESS_USER; | 244 | v9ses->flags = V9FS_PROTO_2000U | V9FS_ACCESS_USER; |
245 | strcpy(v9ses->uname, V9FS_DEFUSER); | 245 | strcpy(v9ses->uname, V9FS_DEFUSER); |
246 | strcpy(v9ses->aname, V9FS_DEFANAME); | 246 | strcpy(v9ses->aname, V9FS_DEFANAME); |
247 | v9ses->uid = ~0; | 247 | v9ses->uid = ~0; |
@@ -263,12 +263,12 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, | |||
263 | } | 263 | } |
264 | 264 | ||
265 | if (!v9ses->clnt->dotu) | 265 | if (!v9ses->clnt->dotu) |
266 | v9ses->flags &= ~V9FS_EXTENDED; | 266 | v9ses->flags &= ~V9FS_PROTO_2000U; |
267 | 267 | ||
268 | v9ses->maxdata = v9ses->clnt->msize - P9_IOHDRSZ; | 268 | v9ses->maxdata = v9ses->clnt->msize - P9_IOHDRSZ; |
269 | 269 | ||
270 | /* for legacy mode, fall back to V9FS_ACCESS_ANY */ | 270 | /* for legacy mode, fall back to V9FS_ACCESS_ANY */ |
271 | if (!v9fs_extended(v9ses) && | 271 | if (!v9fs_proto_dotu(v9ses) && |
272 | ((v9ses->flags&V9FS_ACCESS_MASK) == V9FS_ACCESS_USER)) { | 272 | ((v9ses->flags&V9FS_ACCESS_MASK) == V9FS_ACCESS_USER)) { |
273 | 273 | ||
274 | v9ses->flags &= ~V9FS_ACCESS_MASK; | 274 | v9ses->flags &= ~V9FS_ACCESS_MASK; |
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index 019f4ccb70c1..79000bf62491 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h | |||
@@ -23,7 +23,8 @@ | |||
23 | 23 | ||
24 | /** | 24 | /** |
25 | * enum p9_session_flags - option flags for each 9P session | 25 | * enum p9_session_flags - option flags for each 9P session |
26 | * @V9FS_EXTENDED: whether or not to use 9P2000.u extensions | 26 | * @V9FS_PROTO_2000U: whether or not to use 9P2000.u extensions |
27 | * @V9FS_PROTO_2010L: whether or not to use 9P2010.l extensions | ||
27 | * @V9FS_ACCESS_SINGLE: only the mounting user can access the hierarchy | 28 | * @V9FS_ACCESS_SINGLE: only the mounting user can access the hierarchy |
28 | * @V9FS_ACCESS_USER: a new attach will be issued for every user (default) | 29 | * @V9FS_ACCESS_USER: a new attach will be issued for every user (default) |
29 | * @V9FS_ACCESS_ANY: use a single attach for all users | 30 | * @V9FS_ACCESS_ANY: use a single attach for all users |
@@ -32,11 +33,12 @@ | |||
32 | * Session flags reflect options selected by users at mount time | 33 | * Session flags reflect options selected by users at mount time |
33 | */ | 34 | */ |
34 | enum p9_session_flags { | 35 | enum p9_session_flags { |
35 | V9FS_EXTENDED = 0x01, | 36 | V9FS_PROTO_2000U = 0x01, |
36 | V9FS_ACCESS_SINGLE = 0x02, | 37 | V9FS_PROTO_2010L = 0x02, |
37 | V9FS_ACCESS_USER = 0x04, | 38 | V9FS_ACCESS_SINGLE = 0x04, |
38 | V9FS_ACCESS_ANY = 0x06, | 39 | V9FS_ACCESS_USER = 0x08, |
39 | V9FS_ACCESS_MASK = 0x06, | 40 | V9FS_ACCESS_ANY = 0x0C, |
41 | V9FS_ACCESS_MASK = 0x0C, | ||
40 | }; | 42 | }; |
41 | 43 | ||
42 | /* possible values of ->cache */ | 44 | /* possible values of ->cache */ |
@@ -121,7 +123,12 @@ static inline struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode) | |||
121 | return (inode->i_sb->s_fs_info); | 123 | return (inode->i_sb->s_fs_info); |
122 | } | 124 | } |
123 | 125 | ||
124 | static inline int v9fs_extended(struct v9fs_session_info *v9ses) | 126 | static inline int v9fs_proto_dotu(struct v9fs_session_info *v9ses) |
125 | { | 127 | { |
126 | return v9ses->flags & V9FS_EXTENDED; | 128 | return v9ses->flags & V9FS_PROTO_2000U; |
129 | } | ||
130 | |||
131 | static inline int v9fs_proto_dotl(struct v9fs_session_info *v9ses) | ||
132 | { | ||
133 | return v9ses->flags & V9FS_PROTO_2010L; | ||
127 | } | 134 | } |
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 74a0461a9ac0..36122683fae8 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -61,7 +61,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) | |||
61 | 61 | ||
62 | P9_DPRINTK(P9_DEBUG_VFS, "inode: %p file: %p \n", inode, file); | 62 | P9_DPRINTK(P9_DEBUG_VFS, "inode: %p file: %p \n", inode, file); |
63 | v9ses = v9fs_inode2v9ses(inode); | 63 | v9ses = v9fs_inode2v9ses(inode); |
64 | omode = v9fs_uflags2omode(file->f_flags, v9fs_extended(v9ses)); | 64 | omode = v9fs_uflags2omode(file->f_flags, v9fs_proto_dotu(v9ses)); |
65 | fid = file->private_data; | 65 | fid = file->private_data; |
66 | if (!fid) { | 66 | if (!fid) { |
67 | fid = v9fs_fid_clone(file->f_path.dentry); | 67 | fid = v9fs_fid_clone(file->f_path.dentry); |
@@ -77,7 +77,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) | |||
77 | i_size_write(inode, 0); | 77 | i_size_write(inode, 0); |
78 | inode->i_blocks = 0; | 78 | inode->i_blocks = 0; |
79 | } | 79 | } |
80 | if ((file->f_flags & O_APPEND) && (!v9fs_extended(v9ses))) | 80 | if ((file->f_flags & O_APPEND) && (!v9fs_proto_dotu(v9ses))) |
81 | generic_file_llseek(file, 0, SEEK_END); | 81 | generic_file_llseek(file, 0, SEEK_END); |
82 | } | 82 | } |
83 | 83 | ||
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index a407fa3388c0..d3d3c3c20001 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -60,7 +60,7 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) | |||
60 | res = mode & 0777; | 60 | res = mode & 0777; |
61 | if (S_ISDIR(mode)) | 61 | if (S_ISDIR(mode)) |
62 | res |= P9_DMDIR; | 62 | res |= P9_DMDIR; |
63 | if (v9fs_extended(v9ses)) { | 63 | if (v9fs_proto_dotu(v9ses)) { |
64 | if (S_ISLNK(mode)) | 64 | if (S_ISLNK(mode)) |
65 | res |= P9_DMSYMLINK; | 65 | res |= P9_DMSYMLINK; |
66 | if (v9ses->nodev == 0) { | 66 | if (v9ses->nodev == 0) { |
@@ -102,21 +102,21 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) | |||
102 | 102 | ||
103 | if ((mode & P9_DMDIR) == P9_DMDIR) | 103 | if ((mode & P9_DMDIR) == P9_DMDIR) |
104 | res |= S_IFDIR; | 104 | res |= S_IFDIR; |
105 | else if ((mode & P9_DMSYMLINK) && (v9fs_extended(v9ses))) | 105 | else if ((mode & P9_DMSYMLINK) && (v9fs_proto_dotu(v9ses))) |
106 | res |= S_IFLNK; | 106 | res |= S_IFLNK; |
107 | else if ((mode & P9_DMSOCKET) && (v9fs_extended(v9ses)) | 107 | else if ((mode & P9_DMSOCKET) && (v9fs_proto_dotu(v9ses)) |
108 | && (v9ses->nodev == 0)) | 108 | && (v9ses->nodev == 0)) |
109 | res |= S_IFSOCK; | 109 | res |= S_IFSOCK; |
110 | else if ((mode & P9_DMNAMEDPIPE) && (v9fs_extended(v9ses)) | 110 | else if ((mode & P9_DMNAMEDPIPE) && (v9fs_proto_dotu(v9ses)) |
111 | && (v9ses->nodev == 0)) | 111 | && (v9ses->nodev == 0)) |
112 | res |= S_IFIFO; | 112 | res |= S_IFIFO; |
113 | else if ((mode & P9_DMDEVICE) && (v9fs_extended(v9ses)) | 113 | else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses)) |
114 | && (v9ses->nodev == 0)) | 114 | && (v9ses->nodev == 0)) |
115 | res |= S_IFBLK; | 115 | res |= S_IFBLK; |
116 | else | 116 | else |
117 | res |= S_IFREG; | 117 | res |= S_IFREG; |
118 | 118 | ||
119 | if (v9fs_extended(v9ses)) { | 119 | if (v9fs_proto_dotu(v9ses)) { |
120 | if ((mode & P9_DMSETUID) == P9_DMSETUID) | 120 | if ((mode & P9_DMSETUID) == P9_DMSETUID) |
121 | res |= S_ISUID; | 121 | res |= S_ISUID; |
122 | 122 | ||
@@ -265,7 +265,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
265 | case S_IFBLK: | 265 | case S_IFBLK: |
266 | case S_IFCHR: | 266 | case S_IFCHR: |
267 | case S_IFSOCK: | 267 | case S_IFSOCK: |
268 | if (!v9fs_extended(v9ses)) { | 268 | if (!v9fs_proto_dotu(v9ses)) { |
269 | P9_DPRINTK(P9_DEBUG_ERROR, | 269 | P9_DPRINTK(P9_DEBUG_ERROR, |
270 | "special files without extended mode\n"); | 270 | "special files without extended mode\n"); |
271 | err = -EINVAL; | 271 | err = -EINVAL; |
@@ -278,7 +278,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
278 | inode->i_fop = &v9fs_file_operations; | 278 | inode->i_fop = &v9fs_file_operations; |
279 | break; | 279 | break; |
280 | case S_IFLNK: | 280 | case S_IFLNK: |
281 | if (!v9fs_extended(v9ses)) { | 281 | if (!v9fs_proto_dotu(v9ses)) { |
282 | P9_DPRINTK(P9_DEBUG_ERROR, | 282 | P9_DPRINTK(P9_DEBUG_ERROR, |
283 | "extended modes used w/o 9P2000.u\n"); | 283 | "extended modes used w/o 9P2000.u\n"); |
284 | err = -EINVAL; | 284 | err = -EINVAL; |
@@ -288,7 +288,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
288 | break; | 288 | break; |
289 | case S_IFDIR: | 289 | case S_IFDIR: |
290 | inc_nlink(inode); | 290 | inc_nlink(inode); |
291 | if (v9fs_extended(v9ses)) | 291 | if (v9fs_proto_dotu(v9ses)) |
292 | inode->i_op = &v9fs_dir_inode_operations_ext; | 292 | inode->i_op = &v9fs_dir_inode_operations_ext; |
293 | else | 293 | else |
294 | inode->i_op = &v9fs_dir_inode_operations; | 294 | inode->i_op = &v9fs_dir_inode_operations; |
@@ -575,7 +575,8 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
575 | flags = O_RDWR; | 575 | flags = O_RDWR; |
576 | 576 | ||
577 | fid = v9fs_create(v9ses, dir, dentry, NULL, perm, | 577 | fid = v9fs_create(v9ses, dir, dentry, NULL, perm, |
578 | v9fs_uflags2omode(flags, v9fs_extended(v9ses))); | 578 | v9fs_uflags2omode(flags, |
579 | v9fs_proto_dotu(v9ses))); | ||
579 | if (IS_ERR(fid)) { | 580 | if (IS_ERR(fid)) { |
580 | err = PTR_ERR(fid); | 581 | err = PTR_ERR(fid); |
581 | fid = NULL; | 582 | fid = NULL; |
@@ -858,7 +859,7 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) | |||
858 | if (iattr->ia_valid & ATTR_SIZE) | 859 | if (iattr->ia_valid & ATTR_SIZE) |
859 | wstat.length = iattr->ia_size; | 860 | wstat.length = iattr->ia_size; |
860 | 861 | ||
861 | if (v9fs_extended(v9ses)) { | 862 | if (v9fs_proto_dotu(v9ses)) { |
862 | if (iattr->ia_valid & ATTR_UID) | 863 | if (iattr->ia_valid & ATTR_UID) |
863 | wstat.n_uid = iattr->ia_uid; | 864 | wstat.n_uid = iattr->ia_uid; |
864 | 865 | ||
@@ -897,7 +898,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, | |||
897 | inode->i_uid = v9ses->dfltuid; | 898 | inode->i_uid = v9ses->dfltuid; |
898 | inode->i_gid = v9ses->dfltgid; | 899 | inode->i_gid = v9ses->dfltgid; |
899 | 900 | ||
900 | if (v9fs_extended(v9ses)) { | 901 | if (v9fs_proto_dotu(v9ses)) { |
901 | inode->i_uid = stat->n_uid; | 902 | inode->i_uid = stat->n_uid; |
902 | inode->i_gid = stat->n_gid; | 903 | inode->i_gid = stat->n_gid; |
903 | } | 904 | } |
@@ -976,7 +977,7 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen) | |||
976 | if (IS_ERR(fid)) | 977 | if (IS_ERR(fid)) |
977 | return PTR_ERR(fid); | 978 | return PTR_ERR(fid); |
978 | 979 | ||
979 | if (!v9fs_extended(v9ses)) | 980 | if (!v9fs_proto_dotu(v9ses)) |
980 | return -EBADF; | 981 | return -EBADF; |
981 | 982 | ||
982 | st = p9_client_stat(fid); | 983 | st = p9_client_stat(fid); |
@@ -1066,7 +1067,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, | |||
1066 | struct p9_fid *fid; | 1067 | struct p9_fid *fid; |
1067 | 1068 | ||
1068 | v9ses = v9fs_inode2v9ses(dir); | 1069 | v9ses = v9fs_inode2v9ses(dir); |
1069 | if (!v9fs_extended(v9ses)) { | 1070 | if (!v9fs_proto_dotu(v9ses)) { |
1070 | P9_DPRINTK(P9_DEBUG_ERROR, "not extended\n"); | 1071 | P9_DPRINTK(P9_DEBUG_ERROR, "not extended\n"); |
1071 | return -EPERM; | 1072 | return -EPERM; |
1072 | } | 1073 | } |