]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] uClinux bits for /dev/zero
authorChristoph Hellwig <hch@lst.de>
Thu, 21 Nov 2002 04:24:43 +0000 (20:24 -0800)
committerChristoph Hellwig <hch@lst.de>
Thu, 21 Nov 2002 04:24:43 +0000 (20:24 -0800)
uClinux ports can't use mmu tricks for reading /dev/zero due to the
lack of one.  similarly it can't mmap /dev/zero.

drivers/char/mem.c

index 129bce3a0d73820b235499c85f19fa22008dbad6..c1ca48f798e0d092df2f98936a7c2d534b411c5c 100644 (file)
@@ -377,6 +377,7 @@ static ssize_t write_null(struct file * file, const char * buf,
        return count;
 }
 
+#ifdef CONFIG_MMU
 /*
  * For fun, we are using the MMU for this.
  */
@@ -476,6 +477,29 @@ static int mmap_zero(struct file * file, struct vm_area_struct * vma)
                return -EAGAIN;
        return 0;
 }
+#else /* CONFIG_MMU */
+static ssize_t read_zero(struct file * file, char * buf, 
+                        size_t count, loff_t *ppos)
+{
+       unsigned long left;
+
+       if (!count)
+               return 0;
+
+       for (left = count; left > 0; left--, buf++) {
+               if (put_user(0, buf))
+                       return -EFAULT;
+               cond_resched();
+       }
+
+       return count;
+}
+
+static int mmap_zero(struct file * file, struct vm_area_struct * vma)
+{
+       return -ENOSYS;
+}
+#endif /* CONFIG_MMU */
 
 static ssize_t write_full(struct file * file, const char * buf,
                          size_t count, loff_t *ppos)