aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-11 21:42:12 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-11 21:42:12 +0000
commit2b407b12be6bc25b81961557dd96bf81f2cf88e8 (patch)
treee567beefd99c879c331d2463dc95e1dff55f2b38
parentabe49fa54fbd4d13f8424532abced8c3bc9afd0c (diff)
downloadbusybox-w32-2b407b12be6bc25b81961557dd96bf81f2cf88e8.tar.gz
busybox-w32-2b407b12be6bc25b81961557dd96bf81f2cf88e8.tar.bz2
busybox-w32-2b407b12be6bc25b81961557dd96bf81f2cf88e8.zip
cpio: support some long options; document GNU options
-rw-r--r--archival/cpio.c103
-rw-r--r--archival/libunarchive/get_header_cpio.c5
2 files changed, 92 insertions, 16 deletions
diff --git a/archival/cpio.c b/archival/cpio.c
index 4c9fb1f65..530af802a 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -14,18 +14,6 @@
14#include "libbb.h" 14#include "libbb.h"
15#include "unarchive.h" 15#include "unarchive.h"
16 16
17enum {
18 CPIO_OPT_EXTRACT = (1 << 0),
19 CPIO_OPT_TEST = (1 << 1),
20 CPIO_OPT_UNCONDITIONAL = (1 << 2),
21 CPIO_OPT_VERBOSE = (1 << 3),
22 CPIO_OPT_FILE = (1 << 4),
23 CPIO_OPT_CREATE_LEADING_DIR = (1 << 5),
24 CPIO_OPT_PRESERVE_MTIME = (1 << 6),
25 CPIO_OPT_CREATE = (1 << 7),
26 CPIO_OPT_FORMAT = (1 << 8),
27};
28
29#if ENABLE_FEATURE_CPIO_O 17#if ENABLE_FEATURE_CPIO_O
30static off_t cpio_pad4(off_t size) 18static off_t cpio_pad4(off_t size)
31{ 19{
@@ -190,15 +178,102 @@ static int cpio_o(void)
190} 178}
191#endif 179#endif
192 180
181/* GNU cpio (GNU cpio) 2.9 help (abridged):
182
183 Main operation mode:
184 -i, --extract Extract files from an archive
185 -o, --create Create the archive
186 -p, --pass-through Copy-pass mode (was ist das?!)
187 -t, --list List the archive
188
189 Operation modifiers valid in any mode:
190 --block-size=SIZE I/O block size = SIZE * 512 bytes
191 -B I/O block size = 5120 bytes
192 -c Use the old portable (ASCII) archive format
193 -C, --io-size=NUMBER I/O block size to the given NUMBER bytes
194 -f, --nonmatching Only copy files that do not match given pattern
195 -F, --file=FILE Use FILE instead of standard input or output
196 -H, --format=FORMAT Use given archive FORMAT
197 -M, --message=STRING Print STRING when the end of a volume of the
198 backup media is reached
199 -n, --numeric-uid-gid If -v, show numeric UID and GID
200 --quiet Do not print the number of blocks copied
201 --rsh-command=COMMAND Use remote COMMAND instead of rsh
202 -v, --verbose Verbosely list the files processed
203 -V, --dot Print a "." for each file processed
204 -W, --warning=FLAG Control warning display: 'none','truncate','all';
205 multiple options accumulate
206
207 Operation modifiers valid only in --extract mode:
208 -b, --swap Swap both halfwords of words and bytes of
209 halfwords in the data (equivalent to -sS)
210 -r, --rename Interactively rename files
211 -s, --swap-bytes Swap the bytes of each halfword in the files
212 -S, --swap-halfwords Swap the halfwords of each word (4 bytes)
213 --to-stdout Extract files to standard output
214 -E, --pattern-file=FILE Read additional patterns specifying filenames to
215 extract or list from FILE
216 --only-verify-crc Verify CRC's, don't actually extract the files
217
218 Operation modifiers valid only in --create mode:
219 -A, --append Append to an existing archive
220 -O FILE File to use instead of standard output
221
222 Operation modifiers valid only in --pass-through mode:
223 -l, --link Link files instead of copying them, when possible
224
225 Operation modifiers valid in --extract and --create modes:
226 --absolute-filenames Do not strip file system prefix components from
227 the file names
228 --no-absolute-filenames Create all files relative to the current dir
229
230 Operation modifiers valid in --create and --pass-through modes:
231 -0, --null A list of filenames is terminated by a NUL
232 -a, --reset-access-time Reset the access times of files after reading them
233 -I FILE File to use instead of standard input
234 -L, --dereference Dereference symbolic links (copy the files
235 that they point to instead of copying the links)
236 -R, --owner=[USER][:.][GROUP] Set owner of created files
237
238 Operation modifiers valid in --extract and --pass-through modes:
239 -d, --make-directories Create leading directories where needed
240 -m, --preserve-modification-time
241 Retain previous file modification times when
242 creating files
243 --no-preserve-owner Do not change the ownership of the files
244 --sparse Write files with blocks of zeros as sparse files
245 -u, --unconditional Replace all files unconditionally
246 */
247
193int cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 248int cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
194int cpio_main(int argc UNUSED_PARAM, char **argv) 249int cpio_main(int argc UNUSED_PARAM, char **argv)
195{ 250{
196 archive_handle_t *archive_handle; 251 archive_handle_t *archive_handle;
197 char *cpio_filename; 252 char *cpio_filename;
253 USE_FEATURE_CPIO_O(const char *cpio_fmt = "";)
254 unsigned opt;
255 enum {
256 CPIO_OPT_EXTRACT = (1 << 0),
257 CPIO_OPT_TEST = (1 << 1),
258 CPIO_OPT_UNCONDITIONAL = (1 << 2),
259 CPIO_OPT_VERBOSE = (1 << 3),
260 CPIO_OPT_FILE = (1 << 4),
261 CPIO_OPT_CREATE_LEADING_DIR = (1 << 5),
262 CPIO_OPT_PRESERVE_MTIME = (1 << 6),
263 CPIO_OPT_CREATE = (1 << 7),
264 CPIO_OPT_FORMAT = (1 << 8),
265 };
266
267#if ENABLE_GETOPT_LONG && ENABLE_DESKTOP
268 applet_long_options =
269 "extract\0" No_argument "i"
270 "list\0" No_argument "t"
198#if ENABLE_FEATURE_CPIO_O 271#if ENABLE_FEATURE_CPIO_O
199 const char *cpio_fmt = ""; 272 "create\0" No_argument "o"
273 "format\0" Required_argument "H"
274#endif
275 ;
200#endif 276#endif
201 unsigned opt;
202 277
203 /* Initialize */ 278 /* Initialize */
204 archive_handle = init_handle(); 279 archive_handle = init_handle();
diff --git a/archival/libunarchive/get_header_cpio.c b/archival/libunarchive/get_header_cpio.c
index 96be4b5ac..95d36cca8 100644
--- a/archival/libunarchive/get_header_cpio.c
+++ b/archival/libunarchive/get_header_cpio.c
@@ -7,8 +7,8 @@
7#include "libbb.h" 7#include "libbb.h"
8#include "unarchive.h" 8#include "unarchive.h"
9 9
10typedef struct hardlinks_s { 10typedef struct hardlinks_t {
11 struct hardlinks_s *next; 11 struct hardlinks_t *next;
12 int inode; /* TODO: must match maj/min too! */ 12 int inode; /* TODO: must match maj/min too! */
13 int mode ; 13 int mode ;
14 int mtime; /* These three are useful only in corner case */ 14 int mtime; /* These three are useful only in corner case */
@@ -149,6 +149,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
149 free(make_me); 149 free(make_me);
150 goto next_link; 150 goto next_link;
151 } 151 }
152 cur = cur->next;
152 } 153 }
153 /* Oops... no file with such inode was created... do it now 154 /* Oops... no file with such inode was created... do it now
154 * (happens when hardlinked files are empty (zero length)) */ 155 * (happens when hardlinked files are empty (zero length)) */