xclose (parent_pipe[PWRITE]);
/* Check if we need a grandchild tar. This happens only if either:
- a) we are writing stdout: to force reblocking;
- b) the file is to be accessed by rmt: compressor doesn't know how;
- c) the file is not a plain file. */
+ a) the file is to be accessed by rmt: compressor doesn't know how;
+ b) the file is not a plain file. */
- if (strcmp (archive_name_array[0], "-") != 0
- && !_remdev (archive_name_array[0])
+ if (!_remdev (archive_name_array[0])
&& is_regular_file (archive_name_array[0]))
{
if (backup_option)
/* We don't need a grandchild tar. Open the archive and launch the
compressor. */
-
- archive = creat (archive_name_array[0], MODE_RW);
- if (archive < 0)
+ if (strcmp (archive_name_array[0], "-"))
{
- int saved_errno = errno;
-
- if (backup_option)
- undo_last_backup ();
- errno = saved_errno;
- open_fatal (archive_name_array[0]);
+ archive = creat (archive_name_array[0], MODE_RW);
+ if (archive < 0)
+ {
+ int saved_errno = errno;
+
+ if (backup_option)
+ undo_last_backup ();
+ errno = saved_errno;
+ open_fatal (archive_name_array[0]);
+ }
+ xdup2 (archive, STDOUT_FILENO);
}
- xdup2 (archive, STDOUT_FILENO);
- execlp (use_compress_program_option, use_compress_program_option,
- (char *) 0);
+ execlp (use_compress_program_option, use_compress_program_option, NULL);
exec_fatal (use_compress_program_option);
}
char *numstr;
numstr = STRINGIFY_BIGINT (num, buf);
- setenv (envar, numstr, 1);
+ if (setenv (envar, numstr, 1) != 0)
+ xalloc_die ();
+}
+
+static void
+time_to_env (char *envar, struct timespec t)
+{
+ char buf[TIMESPEC_STRSIZE_BOUND];
+ if (setenv (envar, code_timespec (t, buf), 1) != 0)
+ xalloc_die ();
}
static void
char buf[1+1+(sizeof(unsigned long)*CHAR_BIT+2)/3];
snprintf (buf, sizeof buf, "0%lo", num);
- setenv (envar, buf, 1);
+ if (setenv (envar, buf, 1) != 0)
+ xalloc_die ();
}
static void
str_to_env (char *envar, char const *str)
{
if (str)
- setenv (envar, str, 1);
+ {
+ if (setenv (envar, str, 1) != 0)
+ xalloc_die ();
+ }
else
unsetenv (envar);
}
char buf[2];
buf[0] = c;
buf[1] = 0;
- setenv (envar, buf, 1);
+ if (setenv (envar, buf, 1) != 0)
+ xalloc_die ();
}
static void
str_to_env ("TAR_REALNAME", st->file_name);
str_to_env ("TAR_UNAME", st->uname);
str_to_env ("TAR_GNAME", st->gname);
- dec_to_env ("TAR_MTIME", st->stat.st_mtime);
- dec_to_env ("TAR_ATIME", st->stat.st_atime);
- dec_to_env ("TAR_CTIME", st->stat.st_ctime);
+ time_to_env ("TAR_ATIME", st->atime);
+ time_to_env ("TAR_MTIME", st->mtime);
+ time_to_env ("TAR_CTIME", st->ctime);
dec_to_env ("TAR_SIZE", st->stat.st_size);
dec_to_env ("TAR_UID", st->stat.st_uid);
dec_to_env ("TAR_GID", st->stat.st_gid);