summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2002-11-20 20:24:43 -0800
committerChristoph Hellwig <hch@lst.de>2002-11-20 20:24:43 -0800
commitd04e13f07b945e4f2ff99f1e721964b266df602d (patch)
tree7d7fa254cde89f2b817c56d4ee207b41db62419b
parente5c6d30e24be5115692e7fa8281c38cb8318b49b (diff)
[PATCH] uClinux bits for /dev/zero
uClinux ports can't use mmu tricks for reading /dev/zero due to the lack of one. similarly it can't mmap /dev/zero.
-rw-r--r--drivers/char/mem.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 129bce3a0d73..c1ca48f798e0 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -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)