From ba2dacab305c598cd4c34a604f8e276bf5bab5ff Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Fri, 12 May 2000 21:05:59 +0000 Subject: Merge with Linux 2.3.99-pre7 and various other bits. --- drivers/char/misc.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'drivers/char/misc.c') diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 2826a9d9e..86ee11a5e 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c @@ -86,12 +86,24 @@ static int misc_read_proc(char *buf, char **start, off_t offset, int len, int *eof, void *private) { struct miscdevice *p; + int written; - len=0; - for (p = misc_list.next; p != &misc_list && len < 4000; p = p->next) - len += sprintf(buf+len, "%3i %s\n",p->minor, p->name ?: ""); + written=0; + for (p = misc_list.next; p != &misc_list && written < len; p = p->next) { + written += sprintf(buf+written, "%3i %s\n",p->minor, p->name ?: ""); + if (written < offset) { + offset -= written; + written = 0; + } + } *start = buf + offset; - return len > offset ? len - offset : 0; + written -= offset; + if(written > len) { + *eof = 0; + return len; + } + *eof = 1; + return (written<0) ? 0 : written; } -- cgit v1.2.3