On Friday 25 June 2010 00:41:35 Amir Comforti wrote:
> Dear Charles,
>
> I think I've found a bug in yaffsfs.c in function yaffsfs_do_write(int fd,
> const void *vbuf, unsigned int nbyte, int isPwrite, int offset) In this
> function there is the following section -
>
> if(!h || !obj){
> // bad handle
> yaffsfs_SetError(-EBADF);
> totalWritten = -1;
> } else if( h && obj && (h->readOnly || obj->myDev->readOnly)){
> yaffsfs_SetError(-EINVAL);
> totalWritten=-1;
> } else if( h && obj){
> if(isPwrite)
> startPos = offset;
> else if(h->append)
> startPos =
> yaffs_GetObjectFileLength(obj); else
> startPos = h->position;
Thank you for pointing this error out. I fixed it, but slightly differently.
--- a/direct/yaffsfs.c
+++ b/direct/yaffsfs.c
@@ -826,10 +826,10 @@ int yaffsfs_do_write(int fd, const void *vbuf, unsigned
in
yaffsfs_SetError(-EINVAL);
totalWritten=-1;
} else if( h && obj){
- if(isPwrite)
- startPos = offset;
if(h->append)
startPos = yaffs_GetObjectFileLength(obj);
+ else if(isPwrite)
+ startPos = offset;
else
startPos = h->position;
The reason for fixing it this way is that if the handle has been opened with
O_APPEND then pwrite() should ignore the offset and append the write.
NB that bold does not make it through ASCII emails. It is better to use diff
format.
Thanks
Charles