diff options
author | Aaro Koskinen <aaro.koskinen@iki.fi> | 2015-10-16 17:24:46 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-16 17:24:46 +0200 |
commit | 2735bc00e35c5fd8eec6d656f4d8a17ee2630c2a (patch) | |
tree | a04c7e75f1363e431431c24dc36549a5ff7e9595 /archival/libarchive | |
parent | 93dd9fd90ae284e7878767fe14bcb17e3edd9cf8 (diff) | |
download | busybox-w32-2735bc00e35c5fd8eec6d656f4d8a17ee2630c2a.tar.gz busybox-w32-2735bc00e35c5fd8eec6d656f4d8a17ee2630c2a.tar.bz2 busybox-w32-2735bc00e35c5fd8eec6d656f4d8a17ee2630c2a.zip |
cpio: implement -R/--owner
Implement -R/--owner to force ownership of files.
function old new delta
cpio_main 532 586 +54
get_header_cpio 909 939 +30
print 36 65 +29
cpio_o 804 832 +28
cpio_TRAILER - 11 +11
packed_usage 30667 30662 -5
static.trailer 11 - -11
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 4/1 up/down: 152/-16) Total: 136 bytes
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/libarchive')
-rw-r--r-- | archival/libarchive/Kbuild.src | 2 | ||||
-rw-r--r-- | archival/libarchive/common.c | 9 | ||||
-rw-r--r-- | archival/libarchive/get_header_cpio.c | 7 |
3 files changed, 16 insertions, 2 deletions
diff --git a/archival/libarchive/Kbuild.src b/archival/libarchive/Kbuild.src index b7faaf77f..b159a786a 100644 --- a/archival/libarchive/Kbuild.src +++ b/archival/libarchive/Kbuild.src | |||
@@ -4,7 +4,7 @@ | |||
4 | # | 4 | # |
5 | # Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | # Licensed under GPLv2 or later, see file LICENSE in this source tree. |
6 | 6 | ||
7 | lib-y:= | 7 | lib-y:= common.o |
8 | 8 | ||
9 | COMMON_FILES:= \ | 9 | COMMON_FILES:= \ |
10 | \ | 10 | \ |
diff --git a/archival/libarchive/common.c b/archival/libarchive/common.c new file mode 100644 index 000000000..dd69d2222 --- /dev/null +++ b/archival/libarchive/common.c | |||
@@ -0,0 +1,9 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | ||
4 | */ | ||
5 | |||
6 | #include "libbb.h" | ||
7 | #include "bb_archive.h" | ||
8 | |||
9 | const char cpio_TRAILER[] = "TRAILER!!!"; | ||
diff --git a/archival/libarchive/get_header_cpio.c b/archival/libarchive/get_header_cpio.c index 7861d1f6f..badd4a841 100644 --- a/archival/libarchive/get_header_cpio.c +++ b/archival/libarchive/get_header_cpio.c | |||
@@ -52,6 +52,11 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle) | |||
52 | &major, &minor, &namesize) != 10) | 52 | &major, &minor, &namesize) != 10) |
53 | bb_error_msg_and_die("damaged cpio file"); | 53 | bb_error_msg_and_die("damaged cpio file"); |
54 | file_header->mode = mode; | 54 | file_header->mode = mode; |
55 | /* "cpio -R USER:GRP" support: */ | ||
56 | if (archive_handle->cpio__owner.uid != (uid_t)-1L) | ||
57 | uid = archive_handle->cpio__owner.uid; | ||
58 | if (archive_handle->cpio__owner.gid != (gid_t)-1L) | ||
59 | gid = archive_handle->cpio__owner.gid; | ||
55 | file_header->uid = uid; | 60 | file_header->uid = uid; |
56 | file_header->gid = gid; | 61 | file_header->gid = gid; |
57 | file_header->mtime = mtime; | 62 | file_header->mtime = mtime; |
@@ -75,7 +80,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle) | |||
75 | /* Update offset amount and skip padding before file contents */ | 80 | /* Update offset amount and skip padding before file contents */ |
76 | data_align(archive_handle, 4); | 81 | data_align(archive_handle, 4); |
77 | 82 | ||
78 | if (strcmp(file_header->name, "TRAILER!!!") == 0) { | 83 | if (strcmp(file_header->name, cpio_TRAILER) == 0) { |
79 | /* Always round up. ">> 9" divides by 512 */ | 84 | /* Always round up. ">> 9" divides by 512 */ |
80 | archive_handle->cpio__blocks = (uoff_t)(archive_handle->offset + 511) >> 9; | 85 | archive_handle->cpio__blocks = (uoff_t)(archive_handle->offset + 511) >> 9; |
81 | goto create_hardlinks; | 86 | goto create_hardlinks; |