diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-12-01 15:02:38 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-12-01 15:02:38 +0200 |
commit | 3945f9db44c935608caa5f084fd7f67ae59ee9e1 (patch) | |
tree | 40dc48c8b3a8872bb8aaafdc9af1133a11d4e460 | |
parent | 4900a5e7be9ad90fda7c4743fd31613ceb0eda05 (diff) | |
download | cpio-3945f9db44c935608caa5f084fd7f67ae59ee9e1.tar.gz cpio-3945f9db44c935608caa5f084fd7f67ae59ee9e1.tar.bz2 |
New options to create device and inode-independent archives.
* src/util.c (inode_val): New member trans_inode
(find_inode_val): New function.
(find_inode_file): Rewrite using the above.
(add_inode): Initialize the trans_inode member
depending on the value of renumber_inodes_option.
(get_inode_and_dev): New function.
(stat_to_cpio): Use get_inode_and_dev.
(arf_stores_inode_p): New function.
* src/extern.h (renumber_inodes_option)
(ignore_devno_option): New externs.
* src/global.c (renumber_inodes_option)
(ignore_devno_option): New variables.
* src/main.c: Add new options.
* NEWS: Document changes.
* doc/cpio.1: Document new options.
* doc/cpio.texi: Likewise.
-rw-r--r-- | NEWS | 13 | ||||
-rw-r--r-- | doc/cpio.1 | 15 | ||||
-rw-r--r-- | doc/cpio.texi | 9 | ||||
-rw-r--r-- | src/extern.h | 8 | ||||
-rw-r--r-- | src/global.c | 4 | ||||
-rw-r--r-- | src/main.c | 34 | ||||
-rw-r--r-- | src/util.c | 84 |
7 files changed, 150 insertions, 17 deletions
@@ -1,4 +1,4 @@ | |||
1 | GNU cpio NEWS -- history of user-visible changes. 2014-01-30 | 1 | GNU cpio NEWS -- history of user-visible changes. 2014-12-01 |
2 | Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, | 2 | Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, |
3 | 2010, 2014 Free Software Foundation, Inc. | 3 | 2010, 2014 Free Software Foundation, Inc. |
4 | See the end of file for copying conditions. | 4 | See the end of file for copying conditions. |
@@ -9,7 +9,18 @@ Version 2.11.90 - Git | |||
9 | 9 | ||
10 | * Improved documentation. | 10 | * Improved documentation. |
11 | * Manpages are installed by make install. | 11 | * Manpages are installed by make install. |
12 | * New options for copy-out mode: | ||
12 | 13 | ||
14 | ** --ignore-devno | ||
15 | Store 0 in the device number fields, instead of the actual device | ||
16 | number. | ||
17 | |||
18 | ** --renumber-inodes | ||
19 | Renumber inodes when storing them in the archive. | ||
20 | |||
21 | ** --device-independent or --reproducible | ||
22 | Create reproducible archives. This is equivalent to | ||
23 | --ignore-devno --renumber-inodes. | ||
13 | 24 | ||
14 | Version 2.11 - Sergey Poznyakoff, 2010-03-10 | 25 | Version 2.11 - Sergey Poznyakoff, 2010-03-10 |
15 | 26 | ||
@@ -13,7 +13,7 @@ | |||
13 | .\" | 13 | .\" |
14 | .\" You should have received a copy of the GNU General Public License | 14 | .\" You should have received a copy of the GNU General Public License |
15 | .\" along with GNU cpio. If not, see <http://www.gnu.org/licenses/>. | 15 | .\" along with GNU cpio. If not, see <http://www.gnu.org/licenses/>. |
16 | .TH CPIO 1 "January 30, 2014" "CPIO" "GNU CPIO" | 16 | .TH CPIO 1 "December 1, 2014" "CPIO" "GNU CPIO" |
17 | .SH NAME | 17 | .SH NAME |
18 | cpio \- copy files to and from archives | 18 | cpio \- copy files to and from archives |
19 | .SH SYNOPSIS | 19 | .SH SYNOPSIS |
@@ -29,7 +29,7 @@ cpio \- copy files to and from archives | |||
29 | [\fB\-\-block\-size=\fIblocks\fR] [\fB\-\-dereference\fR] | 29 | [\fB\-\-block\-size=\fIblocks\fR] [\fB\-\-dereference\fR] |
30 | [\fB\-\-io\-size=\fIBYTES\fR] [\fB\-\-quiet\fR] | 30 | [\fB\-\-io\-size=\fIBYTES\fR] [\fB\-\-quiet\fR] |
31 | [\fB\-\-force\-local\fR] [\fB\-\-rsh\-command=\fICOMMAND\fR] | 31 | [\fB\-\-force\-local\fR] [\fB\-\-rsh\-command=\fICOMMAND\fR] |
32 | < \fIname-list\fR [\fB>\fR \fIarchive\fR] | 32 | \fB<\fR \fIname-list\fR [\fB>\fR \fIarchive\fR] |
33 | 33 | ||
34 | .B cpio | 34 | .B cpio |
35 | {\fB\-i\fR|\fB\-\-extract\fR} [\fB\-bcdfmnrtsuvBSV\fR] [\fB\-C\fR \fIBYTES\fR] | 35 | {\fB\-i\fR|\fB\-\-extract\fR} [\fB\-bcdfmnrtsuvBSV\fR] [\fB\-C\fR \fIBYTES\fR] |
@@ -262,6 +262,14 @@ in the archive, without actually extracting the files. | |||
262 | .BR \-A ", " \-\-append | 262 | .BR \-A ", " \-\-append |
263 | Append to an existing archive. | 263 | Append to an existing archive. |
264 | .TP | 264 | .TP |
265 | .BR \-\-device\-independent ", " \-\-reproducible | ||
266 | Create reproducible archives. This is equivalent to | ||
267 | .BR "\-\-ignore\-devno \-\-renumber\-inodes" . | ||
268 | .TP | ||
269 | .B \-\-ignore\-devno | ||
270 | Store 0 in the device number field of each archive member, instead of | ||
271 | the actual device number. | ||
272 | .TP | ||
265 | \fB\-O\fR [[\fIUSER\fB@\fR]\fIHOST\fB:\fR]\fIARCHIVE-NAME\fR | 273 | \fB\-O\fR [[\fIUSER\fB@\fR]\fIHOST\fB:\fR]\fIARCHIVE-NAME\fR |
266 | Use \fIARCHIVE-NAME\fR instead of standard output. Optional \fIUSER\fR and | 274 | Use \fIARCHIVE-NAME\fR instead of standard output. Optional \fIUSER\fR and |
267 | \fIHOST\fR specify the user and host names in case of a remote | 275 | \fIHOST\fR specify the user and host names in case of a remote |
@@ -269,6 +277,9 @@ archive. | |||
269 | 277 | ||
270 | The output archive name can be specified wither using this option, or | 278 | The output archive name can be specified wither using this option, or |
271 | using \fB\-F\fR (\fB\-\-file\fR), but not both. | 279 | using \fB\-F\fR (\fB\-\-file\fR), but not both. |
280 | .TP | ||
281 | .B \-\-renumber\-inodes | ||
282 | Renumber inodes when storing them in the archive. | ||
272 | .SS Operation modifiers valid only in copy-pass mode | 283 | .SS Operation modifiers valid only in copy-pass mode |
273 | .TP | 284 | .TP |
274 | .BR \-l ", " \-\-link | 285 | .BR \-l ", " \-\-link |
diff --git a/doc/cpio.texi b/doc/cpio.texi index c1cf11b..dee3c13 100644 --- a/doc/cpio.texi +++ b/doc/cpio.texi | |||
@@ -461,6 +461,10 @@ Set the I/O block size to the given @var{number} of bytes. | |||
461 | @item -d | 461 | @item -d |
462 | @itemx --make-directories | 462 | @itemx --make-directories |
463 | Create leading directories where needed. | 463 | Create leading directories where needed. |
464 | @item --device-independent | ||
465 | @itemx --reproducible | ||
466 | Create reproducible archives. This is equivalent to | ||
467 | @option{--ignore-devno --renumber-inodes}. | ||
464 | @item -D @var{dir} | 468 | @item -D @var{dir} |
465 | @itemx --directory=@var{dir} | 469 | @itemx --directory=@var{dir} |
466 | Change to directory @var{dir} | 470 | Change to directory @var{dir} |
@@ -483,6 +487,9 @@ Treat the archive file as local, even if its name contains colons. | |||
483 | @itemx --format=@var{format} | 487 | @itemx --format=@var{format} |
484 | Use given archive format. @xref{format}, for a list of available | 488 | Use given archive format. @xref{format}, for a list of available |
485 | formats. | 489 | formats. |
490 | @item --ignore-devno | ||
491 | Store 0 in the device number field of each archive member, instead of | ||
492 | the actual device number. | ||
486 | @item -l | 493 | @item -l |
487 | @itemx --link | 494 | @itemx --link |
488 | Link files instead of copying them, when possible. | 495 | Link files instead of copying them, when possible. |
@@ -512,6 +519,8 @@ Use @var{command} instead of @command{rsh} to access remote archives. | |||
512 | @item -r | 519 | @item -r |
513 | @itemx --rename | 520 | @itemx --rename |
514 | Interactively rename files | 521 | Interactively rename files |
522 | @item --renumber-inodes | ||
523 | Renumber inodes when storing them in the archive. | ||
515 | @item -R | 524 | @item -R |
516 | @itemx --owner=[@var{user}][:.][@var{group}] | 525 | @itemx --owner=[@var{user}][:.][@var{group}] |
517 | Set the ownership of all files created to the specified @var{user} | 526 | Set the ownership of all files created to the specified @var{user} |
diff --git a/src/extern.h b/src/extern.h index 92117cd..da16794 100644 --- a/src/extern.h +++ b/src/extern.h | |||
@@ -56,6 +56,8 @@ extern int only_verify_crc_flag; | |||
56 | extern int no_abs_paths_flag; | 56 | extern int no_abs_paths_flag; |
57 | extern unsigned int warn_option; | 57 | extern unsigned int warn_option; |
58 | extern mode_t newdir_umask; | 58 | extern mode_t newdir_umask; |
59 | extern int renumber_inodes_option; | ||
60 | extern int ignore_devno_option; | ||
59 | 61 | ||
60 | /* Values for warn_option */ | 62 | /* Values for warn_option */ |
61 | #define CPIO_WARN_NONE 0 | 63 | #define CPIO_WARN_NONE 0 |
@@ -171,8 +173,8 @@ void create_all_directories (char *name); | |||
171 | void prepare_append (int out_file_des); | 173 | void prepare_append (int out_file_des); |
172 | char *find_inode_file (ino_t node_num, | 174 | char *find_inode_file (ino_t node_num, |
173 | unsigned long major_num, unsigned long minor_num); | 175 | unsigned long major_num, unsigned long minor_num); |
174 | void add_inode (ino_t node_num, char *file_name, | 176 | struct inode_val *add_inode (ino_t node_num, char *file_name, |
175 | unsigned long major_num, unsigned long minor_num); | 177 | unsigned long major_num, unsigned long minor_num); |
176 | int open_archive (char *file); | 178 | int open_archive (char *file); |
177 | void tape_offline (int tape_des); | 179 | void tape_offline (int tape_des); |
178 | void get_next_reel (int tape_des); | 180 | void get_next_reel (int tape_des); |
@@ -218,3 +220,5 @@ void delay_set_stat (char const *file_name, struct stat *st, | |||
218 | int repair_delayed_set_stat (struct cpio_file_stat *file_hdr); | 220 | int repair_delayed_set_stat (struct cpio_file_stat *file_hdr); |
219 | void apply_delayed_set_stat (void); | 221 | void apply_delayed_set_stat (void); |
220 | 222 | ||
223 | int arf_stores_inode_p (enum archive_format arf); | ||
224 | |||
diff --git a/src/global.c b/src/global.c index c699f6e..0449193 100644 --- a/src/global.c +++ b/src/global.c | |||
@@ -195,3 +195,7 @@ int (*xstat) (); | |||
195 | void (*copy_function) () = 0; | 195 | void (*copy_function) () = 0; |
196 | 196 | ||
197 | char *change_directory_option; | 197 | char *change_directory_option; |
198 | |||
199 | int renumber_inodes_option; | ||
200 | int ignore_devno_option; | ||
201 | |||
@@ -58,7 +58,10 @@ enum cpio_options { | |||
58 | FORCE_LOCAL_OPTION, | 58 | FORCE_LOCAL_OPTION, |
59 | DEBUG_OPTION, | 59 | DEBUG_OPTION, |
60 | BLOCK_SIZE_OPTION, | 60 | BLOCK_SIZE_OPTION, |
61 | TO_STDOUT_OPTION | 61 | TO_STDOUT_OPTION, |
62 | RENUMBER_INODES_OPTION, | ||
63 | IGNORE_DEVNO_OPTION, | ||
64 | DEVICE_INDEPENDENT_OPTION | ||
62 | }; | 65 | }; |
63 | 66 | ||
64 | const char *program_authors[] = | 67 | const char *program_authors[] = |
@@ -190,6 +193,13 @@ static struct argp_option options[] = { | |||
190 | N_("Append to an existing archive."), GRID+1 }, | 193 | N_("Append to an existing archive."), GRID+1 }, |
191 | {NULL, 'O', N_("[[USER@]HOST:]FILE-NAME"), 0, | 194 | {NULL, 'O', N_("[[USER@]HOST:]FILE-NAME"), 0, |
192 | N_("Archive filename to use instead of standard output. Optional USER and HOST specify the user and host names in case of a remote archive"), GRID+1 }, | 195 | N_("Archive filename to use instead of standard output. Optional USER and HOST specify the user and host names in case of a remote archive"), GRID+1 }, |
196 | {"renumber-inodes", RENUMBER_INODES_OPTION, NULL, 0, | ||
197 | N_("Renumber inodes") }, | ||
198 | {"ignore-devno", IGNORE_DEVNO_OPTION, NULL, 0, | ||
199 | N_("Don't store device numbers") }, | ||
200 | {"device-independent", DEVICE_INDEPENDENT_OPTION, NULL, 0, | ||
201 | N_("Create device-independent (reproducible) archives") }, | ||
202 | {"reproducible", 0, NULL, OPTION_ALIAS }, | ||
193 | #undef GRID | 203 | #undef GRID |
194 | 204 | ||
195 | /* ********** */ | 205 | /* ********** */ |
@@ -441,7 +451,19 @@ crc newc odc bin ustar tar (all-caps also recognized)"), arg)); | |||
441 | USAGE_ERROR ((0, 0, _("Mode already defined"))); | 451 | USAGE_ERROR ((0, 0, _("Mode already defined"))); |
442 | copy_function = process_copy_pass; | 452 | copy_function = process_copy_pass; |
443 | break; | 453 | break; |
444 | 454 | ||
455 | case IGNORE_DEVNO_OPTION: | ||
456 | ignore_devno_option = 1; | ||
457 | break; | ||
458 | |||
459 | case RENUMBER_INODES_OPTION: | ||
460 | renumber_inodes_option = 1; | ||
461 | break; | ||
462 | |||
463 | case DEVICE_INDEPENDENT_OPTION: | ||
464 | ignore_devno_option = renumber_inodes_option = 1; | ||
465 | break; | ||
466 | |||
445 | case RSH_COMMAND_OPTION: | 467 | case RSH_COMMAND_OPTION: |
446 | rsh_command_option = arg; | 468 | rsh_command_option = arg; |
447 | break; | 469 | break; |
@@ -592,6 +614,8 @@ process_args (int argc, char *argv[]) | |||
592 | CHECK_USAGE (xstat != lstat, "--dereference", "--extract"); | 614 | CHECK_USAGE (xstat != lstat, "--dereference", "--extract"); |
593 | CHECK_USAGE (append_flag, "--append", "--extract"); | 615 | CHECK_USAGE (append_flag, "--append", "--extract"); |
594 | CHECK_USAGE (output_archive_name, "-O", "--extract"); | 616 | CHECK_USAGE (output_archive_name, "-O", "--extract"); |
617 | CHECK_USAGE (renumber_inodes_option, "--renumber-inodes", "--extract"); | ||
618 | CHECK_USAGE (ignore_devno_option, "--ignore-devno", "--extract"); | ||
595 | if (to_stdout_option) | 619 | if (to_stdout_option) |