Fix -ENOSPC to work properly with zero length writes
[yaffs2.git] / yaffs_fs.c
index f2f709b1aaa0efdf33cb769fde65391b519bedb6..ed247f9e9307a5afbf58e68853519987b4cdd434 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
  *
- * Copyright (C) 2002-2007 Aleph One Ltd.
+ * Copyright (C) 2002-2009 Aleph One Ltd.
  *   for Toby Churchill Ltd and Brightstar Engineering
  *
  * Created by Charles Manning <charles@aleph1.co.uk>
@@ -32,7 +32,7 @@
  */
 
 const char *yaffs_fs_c_version =
-    "$Id: yaffs_fs.c,v 1.77 2009-03-09 07:25:09 charles Exp $";
+    "$Id: yaffs_fs.c,v 1.80 2009-05-12 02:23:51 charles Exp $";
 extern const char *yaffs_guts_c_version;
 
 #include <linux/version.h>
@@ -489,8 +489,6 @@ static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry)
        d_add(dentry, inode);
 
        return NULL;
-       /*      return (ERR_PTR(-EIO)); */
-
 }
 
 
@@ -623,8 +621,7 @@ static int yaffs_readpage_nolock(struct file *f, struct page *pg)
 
        yaffs_GrossLock(dev);
 
-       ret =
-               yaffs_ReadDataFromFile(obj, pg_buf,
+       ret = yaffs_ReadDataFromFile(obj, pg_buf,
                                pg->index << PAGE_CACHE_SHIFT,
                                PAGE_CACHE_SIZE);
 
@@ -1078,7 +1075,7 @@ static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
 
        }
        yaffs_GrossUnlock(dev);
-       return nWritten == 0 ? -ENOSPC : nWritten;
+       return (nWritten == 0) && (n > 0) ? -ENOSPC : nWritten;
 }
 
 /* Space holding and freeing is done to ensure we have space available for write_begin/end */