1 /* global.c - global variables and initial values for cpio.
2 Copyright (C) 1990, 1991, 1992, 2001, 2006 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public
15 License along with this program; if not, write to the Free
16 Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301 USA. */
21 #include <sys/types.h>
26 /* If true, reset access times after reading files (-a). */
27 int reset_time_flag = false;
29 /* Block size value, initially 512. -B sets to 5120. */
30 int io_block_size = 512;
32 /* The header format to recognize and produce. */
33 enum archive_format archive_format = arf_unknown;
35 /* If true, create directories as needed. (-d with -i or -p) */
36 int create_dir_flag = false;
38 /* If true, interactively rename files. (-r) */
39 int rename_flag = false;
41 /* If non-NULL, the name of a file that will be read to
42 rename all of the files in the archive. --rename-batch-file. */
43 char *rename_batch_file = NULL;
45 /* If true, print a table of contents of input. (-t) */
46 int table_flag = false;
48 /* If true, copy unconditionally (older replaces newer). (-u) */
49 int unconditional_flag = false;
51 /* If true, list the files processed, or ls -l style output with -t. (-v) */
52 int verbose_flag = false;
54 /* If true, print a . for each file processed. (-V) */
57 /* If true, link files whenever possible. Used with -p option. (-l) */
58 int link_flag = false;
60 /* If true, retain previous file modification time. (-m) */
61 int retain_time_flag = false;
63 /* Set true if crc_flag is true and we are doing a cpio -i. Used
64 by copy_files so it knows whether to compute the crc. */
65 int crc_i_flag = false;
67 /* If true, append to end of archive. (-A) */
68 int append_flag = false;
70 /* If true, swap bytes of each file during cpio -i. */
71 int swap_bytes_flag = false;
73 /* If true, swap halfwords of each file during cpio -i. */
74 int swap_halfwords_flag = false;
76 /* If true, we are swapping halfwords on the current file. */
77 int swapping_halfwords = false;
79 /* If true, we are swapping bytes on the current file. */
80 int swapping_bytes = false;
82 /* If true, set ownership of all files to UID `set_owner'. */
83 int set_owner_flag = false;
86 /* If true, set group ownership of all files to GID `set_group'. */
87 int set_group_flag = false;
90 /* If true, do not chown the files. */
91 int no_chown_flag = false;
93 /* If true, try to write sparse ("holey") files. */
94 int sparse_flag = false;
96 /* If true, don't report number of blocks copied. */
97 int quiet_flag = false;
99 /* If true, only read the archive and verify the files' CRC's, don't
100 actually extract the files. */
101 int only_verify_crc_flag = false;
103 /* If true, don't use any absolute paths, prefix them by `./'. */
104 int abs_paths_flag = false;
107 /* If true, print debugging information. */
108 int debug_flag = false;
111 /* File position of last header read. Only used during -A to determine
112 where the old TRAILER!!! record started. */
113 int last_header_start = 0;
115 /* With -i; if true, copy only files that match any of the given patterns;
116 if false, copy only files that do not match any of the patterns. (-f) */
117 int copy_matching_files = true;
119 /* With -itv; if true, list numeric uid and gid instead of translating them
121 int numeric_uid = false;
123 /* Name of file containing additional patterns (-E). */
124 char *pattern_file_name = NULL;
126 /* Message to print when end of medium is reached (-M). */
127 char *new_media_message = NULL;
129 /* With -M with %d, message to print when end of medium is reached. */
130 char *new_media_message_with_number = NULL;
131 char *new_media_message_after_number = NULL;
133 /* File descriptor containing the archive. */
136 /* Name of file containing the archive, if known; NULL if stdin/out. */
137 char *archive_name = NULL;
139 /* Name of the remote shell command, if known; NULL otherwise. */
140 char *rsh_command_option = NULL;
145 /* Input and output buffers. */
146 char *input_buffer, *output_buffer;
148 /* The size of the input buffer. */
149 long input_buffer_size;
151 /* Current locations in `input_buffer' and `output_buffer'. */
152 char *in_buff, *out_buff;
154 /* Current number of bytes stored at `input_buff' and `output_buff'. */
155 long input_size, output_size;
157 /* Total number of bytes read and written for all files.
158 Now that many tape drives hold more than 4Gb we need more than 32
159 bits to hold input_bytes and output_bytes. But it's not worth
160 the trouble of adding special multi-precision arithmetic if the
161 compiler doesn't support 64 bit ints since input_bytes and
162 output_bytes are only used to print the number of blocks copied. */
164 long long input_bytes, output_bytes;
166 long input_bytes, output_bytes;
169 /* Saving of argument values for later reference. */
170 char *directory_name = NULL;
171 char **save_patterns;
174 /* Character that terminates file names read from stdin. */
175 char name_end = '\n';
177 /* true if input (cpio -i) or output (cpio -o) is a device node. */
178 char input_is_special = false;
179 char output_is_special = false;
181 /* true if lseek works on the input. */
182 char input_is_seekable = false;
184 /* true if lseek works on the output. */
185 char output_is_seekable = false;
187 /* Print extra warning messages */
188 unsigned int warn_option = 0;
190 /* Extract to standard output? */
191 bool to_stdout_option = false;
193 /* The name this program was run with. */
196 /* A pointer to either lstat or stat, depending on whether
197 dereferencing of symlinks is done for input files. */
200 /* Which copy operation to perform. (-i, -o, -p) */
201 void (*copy_function) () = 0;