summaryrefslogtreecommitdiff
path: root/inotail.c
diff options
context:
space:
mode:
Diffstat (limited to 'inotail.c')
-rw-r--r--inotail.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/inotail.c b/inotail.c
index fdb2919..02cf462 100644
--- a/inotail.c
+++ b/inotail.c
@@ -94,7 +94,7 @@ static inline void setup_file(struct file_struct *f)
{
f->fd = f->i_watch = -1;
f->size = 0;
- f->blksize = BUFFER_SIZE;
+ f->blksize = BUFSIZ;
f->ignore = 0;
}
@@ -256,7 +256,7 @@ static ssize_t tail_pipe_lines(struct file_struct *f, unsigned long n_lines)
tmp = emalloc(sizeof(struct line_buf));
while (1) {
- if ((rc = read(f->fd, tmp->buf, BUFFER_SIZE)) <= 0) {
+ if ((rc = read(f->fd, tmp->buf, BUFSIZ)) <= 0) {
if (rc < 0 && (errno == EINTR || errno == EAGAIN))
continue;
else
@@ -269,15 +269,15 @@ static ssize_t tail_pipe_lines(struct file_struct *f, unsigned long n_lines)
/* Count the lines in the current buffer */
while ((p = memchr(p, '\n', tmp->buf + rc - p))) {
- ++p;
- ++tmp->n_lines;
+ p++;
+ tmp->n_lines++;
}
total_lines += tmp->n_lines;
/* Try to append to the previous buffer if there's enough free
* space
*/
- if (tmp->n_bytes + last->n_bytes < BUFFER_SIZE) {
+ if (tmp->n_bytes + last->n_bytes < BUFSIZ) {
memcpy(&last->buf[last->n_bytes], tmp->buf, tmp->n_bytes);
last->n_bytes += tmp->n_bytes;
last->n_lines += tmp->n_lines;
@@ -304,8 +304,8 @@ static ssize_t tail_pipe_lines(struct file_struct *f, unsigned long n_lines)
/* Count incomplete lines */
if (last->buf[last->n_bytes - 1] != '\n') {
- ++last->n_lines;
- ++total_lines;
+ last->n_lines++;
+ total_lines++;
}
/* Skip unneeded buffers */
@@ -315,10 +315,10 @@ static ssize_t tail_pipe_lines(struct file_struct *f, unsigned long n_lines)
p = tmp->buf;
if (total_lines > n_lines) {
- size_t j;
+ unsigned long j;
for (j = total_lines - n_lines; j; --j) {
p = memchr(p, '\n', tmp->buf + tmp->n_bytes - p);
- ++p;
+ p++;
}
}
@@ -330,13 +330,11 @@ static ssize_t tail_pipe_lines(struct file_struct *f, unsigned long n_lines)
for (tmp = tmp->next; tmp; tmp = tmp->next)
if ((rc = write(STDOUT_FILENO, tmp->buf, tmp->n_bytes)) <= 0) {
- /* e.g. when writing to a pipe which gets closed */
fprintf(stderr, "Error: Could not write to stdout (%s)\n", strerror(errno));
goto out;
}
rc = 0;
-
out:
while (first) {
tmp = first->next;
@@ -351,7 +349,7 @@ out:
static ssize_t tail_pipe_bytes(struct file_struct *f, unsigned long n_bytes)
{
ssize_t rc;
- char buf[BUFFER_SIZE];
+ char buf[BUFSIZ];
/* We will just tail everything here */
while ((rc = read(f->fd, buf, f->blksize)) > 0) {
3-06-29 12:46:47 +0400'>2013-06-29[readdir] introduce ->iterate(), ctx->pos, dir_emit()Al Viro1-4/+15 2013-02-22new helper: file_inode(file)Al Viro1-1/+1 2012-07-14don't pass nameidata to ->create()Al Viro1-2/+2 2012-07-14stop passing nameidata to ->lookup()Al Viro1-2/+2 2012-07-14stop passing nameidata * to ->d_revalidate()Al Viro1-3/+3 2012-01-10coda: switch coda_cnode_make() to sane API as well, clean coda_lookup()Al Viro1-16/+13 2012-01-10coda: deal correctly with allocation failure from coda_cnode_makectl()Al Viro1-2/+2 2012-01-03switch ->create() to umode_tAl Viro1-2/+2 2012-01-03switch vfs_mkdir() and ->mkdir() to umode_tAl Viro1-2/+2 2011-11-02filesystems: add missing nlink wrappersMiklos Szeredi1-1/+1 2011-07-20don't open-code parent_ino() in assorted ->readdir()Al Viro1-1/+1 2011-07-20coda_venus_readdir(): use offsetof()Al Viro1-2/+1 2011-07-20->permission() sanitizing: don't pass flags to ->permission()Al Viro1-2/+2 2011-05-28coda: remove unnecessary dentry_unhash on rmdir, dir renameSage Weil1-5/+0 2011-05-26vfs: push dentry_unhash on rename_dir into file systemsSage Weil1-0/+3 2011-05-26vfs: push dentry_unhash on rmdir into file systemsSage Weil1-0/+2 2011-01-12take coda-private headers out of include/linuxAl Viro1-3/+2 2011-01-12switch codaAl Viro1-3/+1 2011-01-07fs: provide rcu-walk aware permission i_opsNick Piggin1-1/+4 2011-01-07fs: rcu-walk aware d_revalidate methodNick Piggin1-1/+6 2011-01-07fs: dcache reduce branches in lookup pathNick Piggin1-1/+1 2011-01-07fs: dcache scale dentry refcountNick Piggin1-1/+1 2011-01-07fs: change d_delete semanticsNick Piggin1-2/+2 2010-10-25new helper: ihold()Al Viro1-1/+1 2010-10-25Coda: push BKL regions into coda_upcall()Yoshihisa Abe1-107/+42 2010-10-25Coda: add spin lock to protect accesses to struct coda_inode_info.Yoshihisa Abe1-0/+6