[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: jffs_file_write always appends to file.
Hi David,
This patch uses the ideas in your patch but takes care of
one more bug as you can see. I also would like to remove
the call to jffs_delete_data() that you added because that
is supposed to be done from jffs_insert_node() later on.
With this patch I got the correct result when I ran your
test program.
Thanks a lot!
/Finn
Index: inode-v22.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs/inode-v22.c,v
retrieving revision 1.14
diff -u -r1.14 inode-v22.c
--- inode-v22.c 2000/08/02 13:34:46 1.14
+++ inode-v22.c 2000/08/02 19:50:40
@@ -1440,7 +1440,7 @@
goto out;
}
DJM(no_jffs_node++);
- node->data_offset = f->size;
+ node->data_offset = pos;
node->removed_size = 0;
/* Initialize the raw inode. */
@@ -1459,7 +1459,7 @@
raw_inode.atime = CURRENT_TIME;
raw_inode.mtime = raw_inode.atime;
raw_inode.ctime = f->ctime;
- raw_inode.offset = f->size;
+ raw_inode.offset = pos;
raw_inode.dsize = count;
raw_inode.rsize = 0;
raw_inode.nsize = 0;
@@ -1467,6 +1467,11 @@
raw_inode.spare = 0;
raw_inode.rename = 0;
raw_inode.deleted = 0;
+
+ if (pos < f->size) {
+ raw_inode.rsize = jffs_min(count, f->size - pos);
+ node->removed_size = raw_inode.rsize;
+ }
/* TODO: BAAAAAAAAD! buf is a userspace-pointer, and should be
treated as such, with copy_from_user etc... */
On Wed, 2 Aug 2000, David Woodhouse wrote:
> This patch makes it use the 'ppos' argument, but even with the addition of
> the jffs_delete_data() call, the filesystem needs to be remounted before
> the 'new' data appear in the right position.
>
> (... more stuff that might be fixed if we were using the page cache,
> methinks...)
>
> I'm off home. Bob, if you want to take a look at this, feel free. This
> patch is all there is that I haven't committed to CVS. I posted my test
> program earlier, IIRC.
>
> Index: inode-v22.c
> ===================================================================
> RCS file: /home/cvs/mtd/fs/jffs/inode-v22.c,v
> retrieving revision 1.14
> diff -u -w -r1.14 inode-v22.c
> --- inode-v22.c 2000/08/02 13:34:46 1.14
> +++ inode-v22.c 2000/08/02 16:32:46
> @@ -1459,7 +1459,7 @@
> raw_inode.atime = CURRENT_TIME;
> raw_inode.mtime = raw_inode.atime;
> raw_inode.ctime = f->ctime;
> - raw_inode.offset = f->size;
> + raw_inode.offset = pos;
> raw_inode.dsize = count;
> raw_inode.rsize = 0;
> raw_inode.nsize = 0;
> @@ -1467,6 +1467,11 @@
> raw_inode.spare = 0;
> raw_inode.rename = 0;
> raw_inode.deleted = 0;
> +
> + if (pos < f->size) {
> + node->removed_size = raw_inode.rsize = jffs_min(count, f->size - pos);
> + jffs_delete_data(f, node);
> + }
>
> /* TODO: BAAAAAAAAD! buf is a userspace-pointer, and should be
> treated as such, with copy_from_user etc... */
>
>
> --
> dwmw2
>
>
>