Skip to content

Commit

Permalink
9p: fix O_APPEND in legacy mode
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ericvh authored and Eric Van Hensbergen committed Jul 3, 2008
1 parent c461a97 commit 2e4bef4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fs/9p/v9fs_vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ int v9fs_dir_release(struct inode *inode, struct file *filp);
int v9fs_file_open(struct inode *inode, struct file *file);
void v9fs_inode2stat(struct inode *inode, struct p9_stat *stat);
void v9fs_dentry_release(struct dentry *);
int v9fs_uflags2omode(int uflags);
int v9fs_uflags2omode(int uflags, int extended);
4 changes: 3 additions & 1 deletion fs/9p/vfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)

P9_DPRINTK(P9_DEBUG_VFS, "inode: %p file: %p \n", inode, file);
v9ses = v9fs_inode2v9ses(inode);
omode = v9fs_uflags2omode(file->f_flags);
omode = v9fs_uflags2omode(file->f_flags, v9fs_extended(v9ses));
fid = file->private_data;
if (!fid) {
fid = v9fs_fid_clone(file->f_path.dentry);
Expand All @@ -75,6 +75,8 @@ int v9fs_file_open(struct inode *inode, struct file *file)
inode->i_size = 0;
inode->i_blocks = 0;
}
if ((file->f_flags & O_APPEND) && (!v9fs_extended(v9ses)))
generic_file_llseek(file, 0, SEEK_END);
}

file->private_data = fid;
Expand Down
18 changes: 10 additions & 8 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
/**
* v9fs_uflags2omode- convert posix open flags to plan 9 mode bits
* @uflags: flags to convert
*
* @extended: if .u extensions are active
*/

int v9fs_uflags2omode(int uflags)
int v9fs_uflags2omode(int uflags, int extended)
{
int ret;

Expand All @@ -155,14 +155,16 @@ int v9fs_uflags2omode(int uflags)
break;
}

if (uflags & O_EXCL)
ret |= P9_OEXCL;

if (uflags & O_TRUNC)
ret |= P9_OTRUNC;

if (uflags & O_APPEND)
ret |= P9_OAPPEND;
if (extended) {
if (uflags & O_EXCL)
ret |= P9_OEXCL;

if (uflags & O_APPEND)
ret |= P9_OAPPEND;
}

return ret;
}
Expand Down Expand Up @@ -506,7 +508,7 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
flags = O_RDWR;

fid = v9fs_create(v9ses, dir, dentry, NULL, perm,
v9fs_uflags2omode(flags));
v9fs_uflags2omode(flags, v9fs_extended(v9ses)));
if (IS_ERR(fid)) {
err = PTR_ERR(fid);
fid = NULL;
Expand Down

0 comments on commit 2e4bef4

Please sign in to comment.