1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
From 808d176a4da607ed3187d58605d089b373694ba2 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Mon, 28 Jun 2021 07:09:25 -0600
Subject: [PATCH 1/2] cpio: add support for --ignore-devno like GNU cpio
The --ignore-devno option is used to set device numbers to (0, 0).
This can be useful in verifying whether a CPIO archive is reproducible.
function old new delta
cpio_o 922 961 +39
.rodata 78407 78422 +15
bbconfig_config_bz2 6161 6167 +6
packed_usage 25770 25764 -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 60/-6) Total: 54 bytes
Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
---
archival/cpio.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/archival/cpio.c b/archival/cpio.c
index d84f6937d..4d386d38d 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -38,6 +38,13 @@
//config: depends on FEATURE_CPIO_O
//config: help
//config: Passthrough mode. Rarely used.
+//config:
+//config:config FEATURE_CPIO_IGNORE_DEVNO
+//config: bool "Support --ignore-devno like GNU cpio"
+//config: default y
+//config: depends on FEATURE_CPIO_O && LONG_OPTS
+//config: help
+//config: Optionally ignore device numbers when creating archives.
//applet:IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP))
@@ -75,6 +82,9 @@
//usage: "\n -R USER[:GRP] Set owner of created files"
//usage: "\n -L Dereference symlinks"
//usage: "\n -0 Input is separated by NULs"
+//usage: IF_FEATURE_CPIO_IGNORE_DEVNO(
+//usage: "\n --ignore-devno"
+//usage: )
/* GNU cpio 2.9 --help (abridged):
@@ -162,11 +172,13 @@ enum {
IF_FEATURE_CPIO_P(OPTBIT_PASSTHROUGH,)
IF_LONG_OPTS( OPTBIT_QUIET ,)
IF_LONG_OPTS( OPTBIT_2STDOUT ,)
+ IF_FEATURE_CPIO_IGNORE_DEVNO(OPTBIT_IGNORE_DEVNO,)
OPT_CREATE = IF_FEATURE_CPIO_O((1 << OPTBIT_CREATE )) + 0,
OPT_FORMAT = IF_FEATURE_CPIO_O((1 << OPTBIT_FORMAT )) + 0,
OPT_PASSTHROUGH = IF_FEATURE_CPIO_P((1 << OPTBIT_PASSTHROUGH)) + 0,
OPT_QUIET = IF_LONG_OPTS( (1 << OPTBIT_QUIET )) + 0,
OPT_2STDOUT = IF_LONG_OPTS( (1 << OPTBIT_2STDOUT )) + 0,
+ OPT_IGNORE_DEVNO = IF_FEATURE_CPIO_IGNORE_DEVNO((1 << OPTBIT_IGNORE_DEVNO)) + 0,
};
#define OPTION_STR "it0uvdmLF:R:"
@@ -304,6 +316,11 @@ static NOINLINE int cpio_o(void)
}
}
+#if ENABLE_FEATURE_CPIO_IGNORE_DEVNO
+ if (option_mask32 & OPT_IGNORE_DEVNO)
+ st.st_dev = st.st_rdev = 0;
+#endif
+
bytes += printf("070701"
"%08X%08X%08X%08X%08X%08X%08X"
"%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */
@@ -379,6 +396,9 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
"null\0" No_argument "0"
"quiet\0" No_argument "\xff"
"to-stdout\0" No_argument "\xfe"
+#if ENABLE_FEATURE_CPIO_IGNORE_DEVNO
+ "ignore-devno\0" No_argument "\xfd"
+#endif
;
#endif
--
2.32.0
|