From: Christoph Hellwig Date: Thu, 21 Nov 2002 04:24:43 +0000 (-0800) Subject: [PATCH] uClinux bits for /dev/zero X-Git-Tag: v2.5.49~6^2~3 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=d04e13f07b945e4f2ff99f1e721964b266df602d;p=history.git [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. --- 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)