[Yaffs] write operation returns incorrect value in case device is out of space

Mikhail Ryleev mryleev at gmail.com
Fri Dec 23 02:10:26 GMT 2005


There are at least two separate cases here:

1. device is out of space while writing an existing file.
 This problem here is actually became worse with revision 1.32 of yaffs_fs.c
that changed  *  *
yaffs_commit_write routine to returns -1 (which is translated into EACESS
errno) and at least is misleading. The attached patch fixes this problem
while keeping desired effect of change 1.32.
It also fixes a problem with partially written data that actually should
return the amount of data written.

2. device is out of space while creating new object. In this case current
code returns ENOMEM error code which is also misleading. Unfortunatly, I do
not see a simple fix here,  the structure of code is such that it is hard to
diffirenciate out-of-memory vs. out-of-space situation here but I think
ENOSPC would be better here because it is more likely to happen.

M.



--- yaffs_fs.c 2005-12-16 18:23:10.000000000 -0800
+++ ./new/yaffs_fs.c 2005-12-21 16:53:31.000000000 -0800
@@ -624,10 +624,9 @@

  T(YAFFS_TRACE_OS,
    (KERN_DEBUG "yaffs_commit_write returning %d\n",
-    nWritten == nBytes ? 0 : -1));
-
- return nWritten == nBytes ? 0 : -1;
+    nWritten == nBytes ? 0 : nWritten));

+ return nWritten == nBytes ? 0 : nWritten;
 }

 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *
obj)
@@ -785,7 +784,7 @@
  }
  yaffs_GrossUnlock(dev);

- return nWritten != n ? -ENOSPC : nWritten;
+    return  ( nWritten == n || nWritten > 0 ) ? nWritten : -ENOSPC;
 }

 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.aleph1.co.uk/pipermail/yaffs/attachments/20051222/3b2ac4e8/attachment.htm


More information about the yaffs mailing list