]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Add support "--format-options" option to bsdtar to use
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 26 Jan 2009 14:36:09 +0000 (09:36 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 26 Jan 2009 14:36:09 +0000 (09:36 -0500)
format option frame work.

SVN-Revision: 492

tar/bsdtar.c
tar/bsdtar.h
tar/cmdline.c
tar/read.c
tar/write.c

index 33a044baa796c71a6b69f138e4237d79570cb996..65975dff964ae44e68b80e26e270393d8d8b13ad 100644 (file)
@@ -194,6 +194,9 @@ main(int argc, char **argv)
                case OPTION_FORMAT: /* GNU tar, others */
                        bsdtar->create_format = bsdtar->optarg;
                        break;
+               case OPTION_FORMAT_OPTIONS:
+                       bsdtar->option_format_options = bsdtar->optarg;
+                       break;
                case 'f': /* SUSv2 */
                        bsdtar->filename = bsdtar->optarg;
                        if (strcmp(bsdtar->filename, "-") == 0)
index 9222b60b44e414c1e7bbf4ffb0739acf7837c535..a427b9a396cfe25cc78ab5ae26054e2a20ce2935 100644 (file)
@@ -60,6 +60,7 @@ struct bsdtar {
        char              option_chroot; /* --chroot */
        char              option_dont_traverse_mounts; /* --one-file-system */
        char              option_fast_read; /* --fast-read */
+       const char       *option_format_options; /* --format-options */
        char              option_honor_nodump; /* --nodump */
        char              option_interactive; /* -w */
        char              option_no_owner; /* -o */
@@ -110,6 +111,7 @@ enum {
        OPTION_CHROOT,
        OPTION_EXCLUDE,
        OPTION_FORMAT,
+       OPTION_FORMAT_OPTIONS,
        OPTION_HELP,
        OPTION_INCLUDE,
        OPTION_KEEP_NEWER_FILES,
index 09818a31af1e1df89dac06f992ec1e27edf64d1e..ad8b487a66b5e708fb896d7cbc43871958473ecf 100644 (file)
@@ -83,6 +83,7 @@ static struct option {
        { "file",                 1, 'f' },
        { "files-from",           1, 'T' },
        { "format",               1, OPTION_FORMAT },
+       { "format-options",       1, OPTION_FORMAT_OPTIONS },
        { "gunzip",               0, 'z' },
        { "gzip",                 0, 'z' },
        { "help",                 0, OPTION_HELP },
index a8cb14ab3c088121268a95a893834f00748aff4a..c4b6e938b19ff4d523f9ccd1860c4e1674c1c093 100644 (file)
@@ -132,6 +132,12 @@ read_archive(struct bsdtar *bsdtar, char mode)
            DEFAULT_BYTES_PER_BLOCK))
                bsdtar_errc(bsdtar, 1, 0, "Error opening archive: %s",
                    archive_error_string(a));
+       if (bsdtar->option_format_options != NULL) {
+               r = archive_read_set_options(a, bsdtar->option_format_options);
+               if (r != ARCHIVE_OK)
+                       bsdtar_errc(bsdtar, 1, 0, "Error archive options: %s",
+                           archive_error_string(a));
+       }
 
        do_chdir(bsdtar);
 
index bd16a8b0a8819bd1cd23ea040160ef4ef799a32b..6bb317cd2cd3d968862c835ff418795a71d14695 100644 (file)
@@ -201,6 +201,12 @@ tar_mode_c(struct bsdtar *bsdtar)
        if (r != ARCHIVE_OK)
                bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
 
+       if (bsdtar->option_format_options != NULL) {
+               r = archive_write_set_options(a, bsdtar->option_format_options);
+               if (r != ARCHIVE_OK)
+                       bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
+       }
+
        write_archive(a, bsdtar);
 }
 
@@ -287,6 +293,11 @@ tar_mode_r(struct bsdtar *bsdtar)
        }
        lseek(bsdtar->fd, end_offset, SEEK_SET); /* XXX check return val XXX */
        archive_write_open_fd(a, bsdtar->fd); /* XXX check return val XXX */
+       if (bsdtar->option_format_options != NULL) {
+               r = archive_write_set_options(a, bsdtar->option_format_options);
+               if (r != ARCHIVE_OK)
+                       bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
+       }
 
        write_archive(a, bsdtar); /* XXX check return val XXX */
 
@@ -303,6 +314,7 @@ tar_mode_u(struct bsdtar *bsdtar)
        int                      format;
        struct archive_dir_entry        *p;
        struct archive_dir       archive_dir;
+       int                      r;
 
        bsdtar->archive_dir = &archive_dir;
        memset(&archive_dir, 0, sizeof(archive_dir));
@@ -367,6 +379,11 @@ tar_mode_u(struct bsdtar *bsdtar)
        lseek(bsdtar->fd, end_offset, SEEK_SET);
        ftruncate(bsdtar->fd, end_offset);
        archive_write_open_fd(a, bsdtar->fd);
+       if (bsdtar->option_format_options != NULL) {
+               r = archive_write_set_options(a, bsdtar->option_format_options);
+               if (r != ARCHIVE_OK)
+                       bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
+       }
 
        write_archive(a, bsdtar);