causing name look-up errors. Also look-ups are first done outside the chroot,
in case the look-up within the chroot fails due to library conflicts etc.
+ split avoids unnecessary input buffering, immediately writing input to output
+ which is significant with --filter or when writing to fifos or stdout etc.
+
stat and tail work better with HFS+ and HFSX. stat -f --format=%T now reports
the file system type, and tail -f now uses inotify for files, rather than the
default of issuing a warning and reverting to polling.
#include "error.h"
#include "fd-reopen.h"
#include "fcntl--.h"
-#include "full-read.h"
#include "full-write.h"
#include "ioblksize.h"
#include "quote.h"
do
{
- n_read = full_read (STDIN_FILENO, buf, bufsize);
- if (n_read < bufsize && errno)
+ n_read = safe_read (STDIN_FILENO, buf, bufsize);
+ if (n_read == SAFE_READ_ERROR)
error (EXIT_FAILURE, errno, "%s", infile);
bp_out = buf;
to_read = n_read;
}
}
}
- while (n_read == bufsize);
+ while (n_read);
/* Ensure NUMBER files are created, which truncates
any existing files or notifies any consumers on fifos.
do
{
- n_read = full_read (STDIN_FILENO, buf, bufsize);
- if (n_read < bufsize && errno)
+ n_read = safe_read (STDIN_FILENO, buf, bufsize);
+ if (n_read == SAFE_READ_ERROR)
error (EXIT_FAILURE, errno, "%s", infile);
bp = bp_out = buf;
eob = bp + n_read;
}
}
}
- while (n_read == bufsize);
+ while (n_read);
}
/* Split into pieces that are as large as possible while still not more
do
{
- n_read = full_read (STDIN_FILENO, buf, bufsize);
- if (n_read < bufsize && errno)
+ n_read = safe_read (STDIN_FILENO, buf, bufsize);
+ if (n_read == SAFE_READ_ERROR)
error (EXIT_FAILURE, errno, "%s", infile);
size_t n_left = n_read;
char *sob = buf;
}
}
}
- while (n_read == bufsize);
+ while (n_read);
/* Handle no eol at end of file. */
if (n_hold)
while (n_written < file_size)
{
char *bp = buf, *eob;
- size_t n_read = full_read (STDIN_FILENO, buf, bufsize);
- if (n_read < bufsize && errno)
+ size_t n_read = safe_read (STDIN_FILENO, buf, bufsize);
+ if (n_read == SAFE_READ_ERROR)
error (EXIT_FAILURE, errno, "%s", infile);
else if (n_read == 0)
break; /* eof. */
while (start < end)
{
- size_t n_read = full_read (STDIN_FILENO, buf, bufsize);
- if (n_read < bufsize && errno)
+ size_t n_read = safe_read (STDIN_FILENO, buf, bufsize);
+ if (n_read == SAFE_READ_ERROR)
error (EXIT_FAILURE, errno, "%s", infile);
else if (n_read == 0)
break; /* eof. */
while (true)
{
char *bp = buf, *eob;
- /* Use safe_read() rather than full_read() here
- so that we process available data immediately. */
size_t n_read = safe_read (STDIN_FILENO, buf, bufsize);
if (n_read == SAFE_READ_ERROR)
error (EXIT_FAILURE, errno, "%s", infile);