aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-12-01 15:02:38 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2014-12-01 15:02:38 +0200
commit3945f9db44c935608caa5f084fd7f67ae59ee9e1 (patch)
tree40dc48c8b3a8872bb8aaafdc9af1133a11d4e460
parent4900a5e7be9ad90fda7c4743fd31613ceb0eda05 (diff)
downloadcpio-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--NEWS13
-rw-r--r--doc/cpio.115
-rw-r--r--doc/cpio.texi9
-rw-r--r--src/extern.h8
-rw-r--r--src/global.c4
-rw-r--r--src/main.c34
-rw-r--r--src/util.c84
7 files changed, 150 insertions, 17 deletions
diff --git a/NEWS b/NEWS
index a7d2a57..dbd6ce6 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
1GNU cpio NEWS -- history of user-visible changes. 2014-01-30 1GNU cpio NEWS -- history of user-visible changes. 2014-12-01
2Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009,
32010, 2014 Free Software Foundation, Inc. 32010, 2014 Free Software Foundation, Inc.
4See the end of file for copying conditions. 4See 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
15Store 0 in the device number fields, instead of the actual device
16number.
17
18** --renumber-inodes
19Renumber inodes when storing them in the archive.
20
21** --device-independent or --reproducible
22Create reproducible archives. This is equivalent to
23--ignore-devno --renumber-inodes.
13 24
14Version 2.11 - Sergey Poznyakoff, 2010-03-10 25Version 2.11 - Sergey Poznyakoff, 2010-03-10
15 26
diff --git a/doc/cpio.1 b/doc/cpio.1
index d48d2df..c71ba6c 100644
--- a/doc/cpio.1
+++ b/doc/cpio.1
@@ -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
18cpio \- copy files to and from archives 18cpio \- 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
263Append to an existing archive. 263Append to an existing archive.
264.TP 264.TP
265.BR \-\-device\-independent ", " \-\-reproducible
266Create reproducible archives. This is equivalent to
267.BR "\-\-ignore\-devno \-\-renumber\-inodes" .
268.TP
269.B \-\-ignore\-devno
270Store 0 in the device number field of each archive member, instead of
271the 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
266Use \fIARCHIVE-NAME\fR instead of standard output. Optional \fIUSER\fR and 274Use \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
270The output archive name can be specified wither using this option, or 278The output archive name can be specified wither using this option, or
271using \fB\-F\fR (\fB\-\-file\fR), but not both. 279using \fB\-F\fR (\fB\-\-file\fR), but not both.
280.TP
281.B \-\-renumber\-inodes
282Renumber 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
463Create leading directories where needed. 463Create leading directories where needed.
464@item --device-independent
465@itemx --reproducible
466Create 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}
466Change to directory @var{dir} 470Change 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}
484Use given archive format. @xref{format}, for a list of available 488Use given archive format. @xref{format}, for a list of available
485formats. 489formats.
490@item --ignore-devno
491Store 0 in the device number field of each archive member, instead of
492the actual device number.
486@item -l 493@item -l
487@itemx --link 494@itemx --link
488Link files instead of copying them, when possible. 495Link 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
514Interactively rename files 521Interactively rename files
522@item --renumber-inodes
523Renumber 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}]
517Set the ownership of all files created to the specified @var{user} 526Set 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;
56extern int no_abs_paths_flag; 56extern int no_abs_paths_flag;
57extern unsigned int warn_option; 57extern unsigned int warn_option;
58extern mode_t newdir_umask; 58extern mode_t newdir_umask;
59extern int renumber_inodes_option;
60extern 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);
171void prepare_append (int out_file_des); 173void prepare_append (int out_file_des);
172char *find_inode_file (ino_t node_num, 174char *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);
174void add_inode (ino_t node_num, char *file_name, 176struct 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);
176int open_archive (char *file); 178int open_archive (char *file);
177void tape_offline (int tape_des); 179void tape_offline (int tape_des);
178void get_next_reel (int tape_des); 180void get_next_reel (int tape_des);
@@ -218,3 +220,5 @@ void delay_set_stat (char const *file_name, struct stat *st,
218int repair_delayed_set_stat (struct cpio_file_stat *file_hdr); 220int repair_delayed_set_stat (struct cpio_file_stat *file_hdr);
219void apply_delayed_set_stat (void); 221void apply_delayed_set_stat (void);
220 222
223int 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) ();
195void (*copy_function) () = 0; 195void (*copy_function) () = 0;
196 196
197char *change_directory_option; 197char *change_directory_option;
198
199int renumber_inodes_option;
200int ignore_devno_option;
201
diff --git a/src/main.c b/src/main.c
index e1f2c5c..ee9f64e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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
64const char *program_authors[] = 67const 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)