diff options
author | Eric Van Hensbergen <ericvh@gmail.com> | 2008-06-24 18:39:39 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@opteron.9grid.us> | 2008-07-03 10:59:03 -0400 |
commit | 2e4bef41a0f7df31be140ef354b9c12f2299016a (patch) | |
tree | 6ddea6aa929a5f49a4e815a3bfe21f04177dc69e | |
parent | c461a973118346d5c103aaaddd62e53939fd7c67 (diff) |
9p: fix O_APPEND in legacy mode
The legacy protocol's open operation doesn't handle an append operation
(it is expected that the client take care of it). We were incorrectly
passing the extended protocol's flag through even in legacy mode. This
was reported in bugzilla report #10689. This patch fixes the problem
by disallowing extended protocol open modes from being passed in legacy
mode and implemented append functionality on the client side by adding
a seek after the open.
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
-rw-r--r-- | fs/9p/v9fs_vfs.h | 2 | ||||
-rw-r--r-- | fs/9p/vfs_file.c | 4 | ||||
-rw-r--r-- | fs/9p/vfs_inode.c | 18 |
3 files changed, 14 insertions, 10 deletions
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index fd01d90cada5..57997fa14e69 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h | |||
@@ -51,4 +51,4 @@ int v9fs_dir_release(struct inode *inode, struct file *filp); | |||
51 | int v9fs_file_open(struct inode *inode, struct file *file); | 51 | int v9fs_file_open(struct inode *inode, struct file *file); |
52 | void v9fs_inode2stat(struct inode *inode, struct p9_stat *stat); | 52 | void v9fs_inode2stat(struct inode *inode, struct p9_stat *stat); |
53 | void v9fs_dentry_release(struct dentry *); | 53 | void v9fs_dentry_release(struct dentry *); |
54 | int v9fs_uflags2omode(int uflags); | 54 | int v9fs_uflags2omode(int uflags, int extended); |
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 0d55affe37d4..52944d2249a4 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -59,7 +59,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) | |||
59 | 59 | ||
60 | P9_DPRINTK(P9_DEBUG_VFS, "inode: %p file: %p \n", inode, file); | 60 | P9_DPRINTK(P9_DEBUG_VFS, "inode: %p file: %p \n", inode, file); |
61 | v9ses = v9fs_inode2v9ses(inode); | 61 | v9ses = v9fs_inode2v9ses(inode); |
62 | omode = v9fs_uflags2omode(file->f_flags); | 62 | omode = v9fs_uflags2omode(file->f_flags, v9fs_extended(v9ses)); |
63 | fid = file->private_data; | 63 | fid = file->private_data; |
64 | if (!fid) { | 64 | if (!fid) { |
65 | fid = v9fs_fid_clone(file->f_path.dentry); | 65 | fid = v9fs_fid_clone(file->f_path.dentry); |
@@ -75,6 +75,8 @@ int v9fs_file_open(struct inode *inode, struct file *file) | |||
75 | inode->i_size = 0; | 75 | inode->i_size = 0; |
76 | inode->i_blocks = 0; | 76 | inode->i_blocks = 0; |
77 | } | 77 | } |
78 | if ((file->f_flags & O_APPEND) && (!v9fs_extended(v9ses))) | ||
79 | generic_file_llseek(file, 0, SEEK_END); | ||
78 | } | 80 | } |
79 | 81 | ||
80 | file->private_data = fid; | 82 | file->private_data = fid; |
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 40fa807bd929..c95295c65045 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -132,10 +132,10 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) | |||
132 | /** | 132 | /** |
133 | * v9fs_uflags2omode- convert posix open flags to plan 9 mode bits | 133 | * v9fs_uflags2omode- convert posix open flags to plan 9 mode bits |
134 | * @uflags: flags to convert | 134 | * @uflags: flags to convert |
135 | * | 135 | * @extended: if .u extensions are active |
136 | */ | 136 | */ |
137 | 137 | ||
138 | int v9fs_uflags2omode(int uflags) | 138 | int v9fs_uflags2omode(int uflags, int extended) |
139 | { | 139 | { |
140 | int ret; | 140 | int ret; |
141 | 141 | ||
@@ -155,14 +155,16 @@ int v9fs_uflags2omode(int uflags) | |||
155 | break; | 155 | break; |
156 | } | 156 | } |
157 | 157 | ||
158 | if (uflags & O_EXCL) | ||
159 | ret |= P9_OEXCL; | ||
160 | |||
161 | if (uflags & O_TRUNC) | 158 | if (uflags & O_TRUNC) |
162 | ret |= P9_OTRUNC; | 159 | ret |= P9_OTRUNC; |
163 | 160 | ||
164 | if (uflags & O_APPEND) | 161 | if (extended) { |
165 | ret |= P9_OAPPEND; | 162 | if (uflags & O_EXCL) |
163 | ret |= P9_OEXCL; | ||
164 | |||
165 | if (uflags & O_APPEND) | ||
166 | ret |= P9_OAPPEND; | ||
167 | } | ||
166 | 168 | ||
167 | return ret; | 169 | return ret; |
168 | } | 170 | } |
@@ -506,7 +508,7 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
506 | flags = O_RDWR; | 508 | flags = O_RDWR; |
507 | 509 | ||
508 | fid = v9fs_create(v9ses, dir, dentry, NULL, perm, | 510 | fid = v9fs_create(v9ses, dir, dentry, NULL, perm, |
509 | v9fs_uflags2omode(flags)); | 511 | v9fs_uflags2omode(flags, v9fs_extended(v9ses))); |
510 | if (IS_ERR(fid)) { | 512 | if (IS_ERR(fid)) { |
511 | err = PTR_ERR(fid); | 513 | err = PTR_ERR(fid); |
512 | fid = NULL; | 514 | fid = NULL; |