summaryrefslogtreecommitdiff
path: root/inotail.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2007-09-19 10:13:44 +0200
committerTobias Klauser <tklauser@xenon.tklauser.home>2007-09-19 10:13:44 +0200
commit6ec61a62e5a1a586766d46108d5ae7e1aaf3dd8c (patch)
treeec7dcec92fcee2bce373ce5bcc5c4be3704c3b4a /inotail.c
parentf4c22bb16fc842f66060d4f7a79338c900f8dfb9 (diff)
inotail.c: Check for n_units == 0 only if tailing from end
inotail -n+0/-c+0 should be allowed
Diffstat (limited to 'inotail.c')
-rw-r--r--inotail.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/inotail.c b/inotail.c
index 7ed5b31..483306e 100644
--- a/inotail.c
+++ b/inotail.c
@@ -244,7 +244,8 @@ static int tail_pipe_from_begin(struct file_struct *f, unsigned long n_units, co
int bytes_read = 0;
char buf[BUFSIZ];
- n_units--;
+ if (n_units)
+ n_units--;
while (n_units > 0) {
if ((bytes_read = read(f->fd, buf, BUFSIZ)) <= 0) {
@@ -296,6 +297,9 @@ static int tail_pipe_lines(struct file_struct *f, unsigned long n_lines)
if (from_begin)
return tail_pipe_from_begin(f, n_lines, M_LINES);
+ if (n_lines == 0)
+ return 0;
+
first = last = emalloc(sizeof(struct line_buf));
first->n_bytes = first->n_lines = 0;
first->next = NULL;
@@ -401,6 +405,10 @@ static int tail_pipe_bytes(struct file_struct *f, unsigned long n_bytes)
if (from_begin)
return tail_pipe_from_begin(f, n_bytes, M_BYTES);
+ /* XXX: Needed? */
+ if (n_bytes == 0)
+ return 0;
+
first = last = emalloc(sizeof(struct char_buf));
first->n_bytes = 0;
first->next = NULL;
@@ -507,9 +515,6 @@ static int tail_file(struct file_struct *f, unsigned long n_units, char mode, ch
if (verbose)
write_header(f->name);
- if (n_units == 0)
- return 0;
-
if (mode == M_LINES)
return tail_pipe_lines(f, n_units);
else
it/commit/fs/jbd2/recovery.c?id=3caa487f53f65fd1e3950a6b6ae1709e6c43b334'>jbd2: checksum descriptor blocksDarrick J. Wong1-1/+36 2012-05-27jbd2: checksum revocation blocksDarrick J. Wong1-0/+22 2012-05-22jbd2: change disk layout for metadata checksummingDarrick J. Wong1-3/+3 2012-03-13jbd2: issue cache flush after checkpointing even with internal journalJan Kara1-1/+4 2011-11-01jbd2: Unify log messages in jbd2 codeEryu Guan1-14/+14 2010-12-18jbd2: move debug message into debug #ifdefTheodore Ts'o1-1/+1 2010-06-14ext4: remove initialized but not read variablesAndi Kleen1-8/+2