aboutsummaryrefslogtreecommitdiff
path: root/archival/libarchive/get_header_cpio.c
diff options
context:
space:
mode:
authorAaro Koskinen <aaro.koskinen@iki.fi>2015-10-16 17:24:46 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-16 17:24:46 +0200
commit2735bc00e35c5fd8eec6d656f4d8a17ee2630c2a (patch)
treea04c7e75f1363e431431c24dc36549a5ff7e9595 /archival/libarchive/get_header_cpio.c
parent93dd9fd90ae284e7878767fe14bcb17e3edd9cf8 (diff)
downloadbusybox-2735bc00e35c5fd8eec6d656f4d8a17ee2630c2a.tar.gz
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/get_header_cpio.c')
-rw-r--r--archival/libarchive/get_header_cpio.c7
1 files changed, 6 insertions, 1 deletions
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)
&major, &minor, &namesize) != 10)
bb_error_msg_and_die("damaged cpio file");
file_header->mode = mode;
+ /* "cpio -R USER:GRP" support: */
+ if (archive_handle->cpio__owner.uid != (uid_t)-1L)
+ uid = archive_handle->cpio__owner.uid;
+ if (archive_handle->cpio__owner.gid != (gid_t)-1L)
+ gid = archive_handle->cpio__owner.gid;
file_header->uid = uid;
file_header->gid = gid;
file_header->mtime = mtime;
@@ -75,7 +80,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
/* Update offset amount and skip padding before file contents */
data_align(archive_handle, 4);
- if (strcmp(file_header->name, "TRAILER!!!") == 0) {
+ if (strcmp(file_header->name, cpio_TRAILER) == 0) {
/* Always round up. ">> 9" divides by 512 */
archive_handle->cpio__blocks = (uoff_t)(archive_handle->offset + 511) >> 9;
goto create_hardlinks;