Notes on portability, and on when #include <linux/blah> is appropriate.
[oweals/busybox.git] / archival / tar.c
index 9d0a7c5e4e1b0875c1fe25e333b31f358d055717..e4008b0c9c5a141216bd8fb759edf9b0141d896d 100644 (file)
@@ -19,9 +19,8 @@
  *
  * Based in part on the tar implementation from busybox-0.28
  *  Copyright (C) 1995 Bruce Perens
- *  This is free software under the GNU General Public License.
  *
- * Licensed under GPL v2 (or later), see file LICENSE in this tarball.
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
 #include <fcntl.h>
@@ -597,7 +596,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
 #define TAR_OPT_AFTER_START               8
 
 #define CTX_CREATE                        (1 << (TAR_OPT_AFTER_START))
-#define TAR_OPT_DEREFERNCE                (1 << (TAR_OPT_AFTER_START + 1))
+#define TAR_OPT_DEREFERENCE               (1 << (TAR_OPT_AFTER_START + 1))
 #ifdef CONFIG_FEATURE_TAR_CREATE
 # define TAR_OPT_STR_CREATE               "ch"
 # define TAR_OPT_AFTER_CREATE             TAR_OPT_AFTER_START + 2
@@ -834,8 +833,8 @@ int tar_main(int argc, char **argv)
                }
        }
 
-       if ((base_dir) && (chdir(base_dir)))
-               bb_perror_msg_and_die("Couldnt chdir to %s", base_dir);
+       if (base_dir)
+               bb_xchdir(base_dir);
 
        /* create an archive */
        if (ENABLE_FEATURE_TAR_CREATE && (opt & CTX_CREATE)) {
@@ -852,7 +851,8 @@ int tar_main(int argc, char **argv)
                {
                        verboseFlag = TRUE;
                }
-               writeTarFile(tar_handle->src_fd, verboseFlag, opt & TAR_OPT_DEREFERNCE, tar_handle->accept,
+               writeTarFile(tar_handle->src_fd, verboseFlag, opt & TAR_OPT_DEREFERENCE,
+                               tar_handle->accept,
                        tar_handle->reject, zipMode);
        } else {
                while (get_header_ptr(tar_handle) == EXIT_SUCCESS);