aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-03-03 22:06:55 -0600
committerRob Landley <rob@landley.net>2015-03-03 22:06:55 -0600
commit40f7fb02aaceecee2625191afecaeea8ca95e259 (patch)
tree8b9812508315bf2c07a9bd7cbc5c7168c0181b4b
parent38e5485c6a8ece99aa8aac2f318f14764857ee24 (diff)
downloadtoybox-40f7fb02aaceecee2625191afecaeea8ca95e259.tar.gz
Quick cleanup pass on tar.
-rw-r--r--toys/pending/tar.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/toys/pending/tar.c b/toys/pending/tar.c
index 8b5f443e..f44465cc 100644
--- a/toys/pending/tar.c
+++ b/toys/pending/tar.c
@@ -32,6 +32,7 @@ config TAR
X File with names to exclude
T File with names to include
*/
+
#define FOR_tar
#include "toys.h"
@@ -433,7 +434,8 @@ COPY:
if (pw) u = pw->pw_uid;
if (gr) g = gr->gr_gid;
}
- chown(file_hdr->name, u, g);
+ if (chown(file_hdr->name, u, g))
+ perror_msg("chown %d:%d '%s'", u, g, file_hdr->name);;
}
if (toys.optflags & FLAG_p) // || !(toys.optflags & FLAG_no_same_permissions))
@@ -745,15 +747,10 @@ SKIP:
void tar_main(void)
{
struct archive_handler *tar_hdl;
- int fd = 0, flags = O_RDONLY;
+ int fd = 0;
struct arg_list *tmp;
char **args = toys.optargs;
- if (!toys.argv[1]) {
- toys.exithelp++;
- error_exit(NULL);
- }
-
if (!geteuid()) toys.optflags |= FLAG_p;
for (tmp = TT.exc; tmp; tmp = tmp->next)
@@ -765,16 +762,16 @@ void tar_main(void)
if (toys.optflags & FLAG_c) {
if (!TT.inc) error_exit("empty archive");
- fd = 1, flags = O_WRONLY|O_CREAT|O_TRUNC;
+ fd = 1;
}
if ((toys.optflags & FLAG_f) && strcmp(TT.fname, "-"))
- fd = xcreate(TT.fname, flags, 0666);
+ fd = xcreate(TT.fname, fd*(O_WRONLY|O_CREAT|O_TRUNC), 0666);
if (toys.optflags & FLAG_C) xchdir(TT.dir);
tar_hdl = init_handler();
tar_hdl->src_fd = fd;
- if (toys.optflags & FLAG_x || toys.optflags & FLAG_t) {
+ if ((toys.optflags & FLAG_x) || (toys.optflags & FLAG_t)) {
if (toys.optflags & FLAG_O) tar_hdl->extract_handler = extract_to_stdout;
if (toys.optflags & FLAG_to_command) {
signal(SIGPIPE, SIG_IGN); //will be using pipe between child & parent