}
/* Perform a write to flush the buffer. */
-static ssize_t
+static idx_t
_flush_write (void)
{
- ssize_t status;
+ idx_t status;
checkpoint_run (true);
if (tape_length_option && tape_length_option <= bytes_written)
static void
simple_flush_write (MAYBE_UNUSED idx_t level)
{
- ssize_t status;
-
- status = _flush_write ();
+ idx_t status = _flush_write ();
if (status != record_size)
archive_write_error (status);
else
static void
_gnu_flush_write (idx_t buffer_level)
{
- ssize_t status;
union block *header;
char *copy_ptr;
idx_t copy_size;
idx_t bufsize;
struct bufmap *map;
- status = _flush_write ();
- if (status != record_size && !multi_volume_option)
- archive_write_error (status);
- else
- {
- if (status)
- records_written++;
- bytes_written += status;
- }
+ idx_t status = _flush_write ();
+ records_written += !!status;
+ bytes_written += status;
if (status == record_size)
{
if (status % BLOCKSIZE)
{
+ int e = errno;
paxerror (0, _("write did not end on a block boundary"));
+ errno = e;
archive_write_error (status);
}
- /* In multi-volume mode. */
/* ENXIO is for the UNIX PC. */
- if (status < 0 && errno != ENOSPC && errno != EIO && errno != ENXIO)
+ if (! (multi_volume_option
+ && (errno == ENOSPC || errno == EIO || errno == ENXIO)))
archive_write_error (status);
+ /* In multi-volume mode. */
+
if (!new_volume (ACCESS_WRITE))
return;
int sys_truncate (int fd);
pid_t sys_child_open_for_compress (void);
pid_t sys_child_open_for_uncompress (void);
-size_t sys_write_archive_buffer (void);
+idx_t sys_write_archive_buffer (void);
bool sys_get_archive_stat (void);
int sys_exec_command (char *file_name, int typechar, struct tar_stat_info *st);
void sys_wait_command (void);
return write (fd, "", 0);
}
-size_t
+idx_t
sys_write_archive_buffer (void)
{
return full_write (archive, record_start->buffer, record_size);
return errno == ENOENT;
}
-size_t
+idx_t
sys_write_archive_buffer (void)
{
return rmtwrite (archive, record_start->buffer, record_size);
length < record_size;
length += status, cursor += status)
{
- size_t size = record_size - length;
+ idx_t size = record_size - length;
status = safe_read (STDIN_FILENO, cursor, size);
if (status < 0)
struct pollfd pfd;
char *buffer = NULL;
- size_t buflen = 0;
- size_t bufsize = 0;
+ idx_t buflen = 0;
+ idx_t bufsize = 0;
char *cp;
int rc = 0;
open_error (dev_null);
priv_set_restore_linkdir ();
+ /* FIXME: This mishandles shell metacharacters in the file name.
+ Come to think of it, isn't every use of xexec suspect? */
xexec (command);
}
close (p[1]);
if (pfd.revents & POLLIN)
{
if (buflen == bufsize)
- {
- if (bufsize == 0)
- bufsize = BUFSIZ;
- buffer = x2nrealloc (buffer, &bufsize, 1);
- }
+ buffer = xpalloc (buffer, &bufsize, 1, -1, 1);
ssize_t nread = read (pfd.fd, buffer + buflen, bufsize - buflen);
if (nread < 0)
{
else
{
if (buflen == bufsize)
- buffer = x2nrealloc (buffer, &bufsize, 1);
+ buffer = xirealloc (buffer, ++bufsize);
buffer[buflen] = 0;
}