2011-03-16 05:09:28

by M. Mohan Kumar

[permalink] [raw]
Subject: [PATCH] fs/9p: Use updated offset for writing

Use the updated offset given by generic_write_checks. Without this fix,
even if a file is opened in O_APPEND mode, data will be written at current
file position instead of end of file.

Signed-off-by: M. Mohan Kumar <[email protected]>
---
fs/9p/vfs_file.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 6997eb6..51049cd 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -510,7 +510,7 @@ v9fs_file_write(struct file *filp, const char __user * data,

return v9fs_file_write_internal(filp->f_path.dentry->d_inode,
filp->private_data,
- data, count, offset, 1);
+ data, count, &origin, 1);
out:
return retval;
}
--
1.7.3.4


2011-03-16 08:05:55

by Aneesh Kumar K.V

[permalink] [raw]
Subject: Re: [PATCH] fs/9p: Use updated offset for writing

On Wed, 16 Mar 2011 10:39:16 +0530, "M. Mohan Kumar" <[email protected]> wrote:
> Use the updated offset given by generic_write_checks. Without this fix,
> even if a file is opened in O_APPEND mode, data will be written at current
> file position instead of end of file.
>
> Signed-off-by: M. Mohan Kumar <[email protected]>
> ---
> fs/9p/vfs_file.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
> index 6997eb6..51049cd 100644
> --- a/fs/9p/vfs_file.c
> +++ b/fs/9p/vfs_file.c
> @@ -510,7 +510,7 @@ v9fs_file_write(struct file *filp, const char __user * data,
>
> return v9fs_file_write_internal(filp->f_path.dentry->d_inode,
> filp->private_data,
> - data, count, offset, 1);
> + data, count, &origin, 1);
> out:
> return retval;
> }

You should also update offset on success.

-aneesh

2011-03-16 11:19:09

by M. Mohan Kumar

[permalink] [raw]
Subject: Re: [PATCH] fs/9p: Use updated offset for writing

On Wednesday 16 March 2011 1:35:46 pm Aneesh Kumar K. V wrote:
> On Wed, 16 Mar 2011 10:39:16 +0530, "M. Mohan Kumar" <[email protected]>
wrote:
> > Use the updated offset given by generic_write_checks. Without this fix,
> > even if a file is opened in O_APPEND mode, data will be written at
> > current file position instead of end of file.

>
> You should also update offset on success.

Thanks Aneesh, I will send a updated patch.

----
M. Mohan Kumar