*** empty log message ***
authorcharles <charles>
Wed, 29 Oct 2003 20:38:56 +0000 (20:38 +0000)
committercharles <charles>
Wed, 29 Oct 2003 20:38:56 +0000 (20:38 +0000)
utils/mmaptest.c [new file with mode: 0644]
yaffs_fs.c

diff --git a/utils/mmaptest.c b/utils/mmaptest.c
new file mode 100644 (file)
index 0000000..582946c
--- /dev/null
@@ -0,0 +1,65 @@
+
+// mmaptest.c
+// Used to test mmap writing (ie yaffs_writepage)
+//
+// Written by James McKenzie
+//
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <string.h>
+#include <errno.h>
+
+int
+main (int argc, char *argv[])
+{
+  int fd;
+  off_t size = 0;
+  void *map;
+
+  size = 6291456;
+
+  (void) unlink ("testfile");
+
+  fd = open ("testfile", O_RDWR | O_CREAT | O_TRUNC, 0666);
+
+  if (fd < 0)
+    {
+      perror ("open");
+      return -1;
+    }
+
+  if (lseek (fd, size, SEEK_SET) != size)
+    {
+      perror ("lseek");
+      return -1;
+    }
+
+  if (write (fd, "", 1) != 1)
+    {
+      perror ("write");
+      return -1;
+    }
+
+  size++;
+
+  map = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  if (map == MAP_FAILED)
+    {
+      perror ("mmap");
+      return -1;
+    }
+
+  memset (map, 1 + (*(unsigned char *) map), size);
+
+  errno = 0;
+
+  printf ("msync(map,8536,MS_SYNC) returns %d (errno=%d [%s])\n",
+          msync (map, 8536, MS_SYNC), errno, strerror (errno));
+
+  (void) munmap (map, size);
+
+  return 0;
+}
index 69039af0601f11f146d79178c650e5f12f5bde4a..c0b101ae6688becef805553f9c2eb4bae03b03a0 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 
-const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.31 2003-10-27 08:27:01 charles Exp $";
+const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.32 2003-10-29 20:42:34 charles Exp $";
 extern const char *yaffs_guts_c_version;
 
 
@@ -522,7 +522,7 @@ static int yaffs_writepage(struct page *page)
        UnlockPage(page);
        put_page(page);
 
-       return nWritten>0 ? nWritten : -ENOSPC;
+       return (nWritten == nBytes) ? 0  : -ENOSPC;
 }