1 /* global.c - global variables and initial values for cpio.
2 Copyright (C) 1990, 1991, 1992, 2001 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 License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #include <sys/types.h>
25 /* If true, reset access times after reading files (-a). */
26 int reset_time_flag = false;
28 /* Block size value, initially 512. -B sets to 5120. */
29 int io_block_size = 512;
31 /* The header format to recognize and produce. */
32 enum archive_format archive_format = arf_unknown;
34 /* If true, create directories as needed. (-d with -i or -p) */
35 int create_dir_flag = false;
37 /* If true, interactively rename files. (-r) */
38 int rename_flag = false;
40 /* If non-NULL, the name of a file that will be read to
41 rename all of the files in the archive. --rename-batch-file. */
42 char *rename_batch_file = NULL;
44 /* If true, print a table of contents of input. (-t) */
45 int table_flag = false;
47 /* If true, copy unconditionally (older replaces newer). (-u) */
48 int unconditional_flag = false;
50 /* If true, list the files processed, or ls -l style output with -t. (-v) */
51 int verbose_flag = false;
53 /* If true, print a . for each file processed. (-V) */
56 /* If true, link files whenever possible. Used with -p option. (-l) */
57 int link_flag = false;
59 /* If true, retain previous file modification time. (-m) */
60 int retain_time_flag = false;
62 /* Set true if crc_flag is true and we are doing a cpio -i. Used
63 by copy_files so it knows whether to compute the crc. */
64 int crc_i_flag = false;
66 /* If true, append to end of archive. (-A) */
67 int append_flag = false;
69 /* If true, swap bytes of each file during cpio -i. */
70 int swap_bytes_flag = false;
72 /* If true, swap halfwords of each file during cpio -i. */
73 int swap_halfwords_flag = false;
75 /* If true, we are swapping halfwords on the current file. */
76 int swapping_halfwords = false;
78 /* If true, we are swapping bytes on the current file. */
79 int swapping_bytes = false;
81 /* If true, set ownership of all files to UID `set_owner'. */
82 int set_owner_flag = false;
85 /* If true, set group ownership of all files to GID `set_group'. */
86 int set_group_flag = false;
89 /* If true, do not chown the files. */
90 int no_chown_flag = false;
92 /* If true, try to write sparse ("holey") files. */
93 int sparse_flag = false;
95 /* If true, don't report number of blocks copied. */
96 int quiet_flag = false;
98 /* If true, only read the archive and verify the files' CRC's, don't
99 actually extract the files. */
100 int only_verify_crc_flag = false;
102 /* If true, don't use any absolute paths, prefix them by `./'. */
103 int abs_paths_flag = false;
106 /* If true, print debugging information. */
107 int debug_flag = false;
110 /* File position of last header read. Only used during -A to determine
111 where the old TRAILER!!! record started. */
112 int last_header_start = 0;
114 /* With -i; if true, copy only files that match any of the given patterns;
115 if false, copy only files that do not match any of the patterns. (-f) */
116 int copy_matching_files = true;
118 /* With -itv; if true, list numeric uid and gid instead of translating them
120 int numeric_uid = false;
122 /* Name of file containing additional patterns (-E). */
123 char *pattern_file_name = NULL;
125 /* Message to print when end of medium is reached (-M). */
126 char *new_media_message = NULL;
128 /* With -M with %d, message to print when end of medium is reached. */
129 char *new_media_message_with_number = NULL;
130 char *new_media_message_after_number = NULL;
132 /* File descriptor containing the archive. */
135 /* Name of file containing the archive, if known; NULL if stdin/out. */
136 char *archive_name = NULL;
138 /* Name of the remote shell command, if known; NULL otherwise. */
139 char *rsh_command_option = NULL;
144 /* Input and output buffers. */
145 char *input_buffer, *output_buffer;
147 /* The size of the input buffer. */
148 long input_buffer_size;
150 /* Current locations in `input_buffer' and `output_buffer'. */
151 char *in_buff, *out_buff;
153 /* Current number of bytes stored at `input_buff' and `output_buff'. */
154 long input_size, output_size;
156 /* Total number of bytes read and written for all files.
157 Now that many tape drives hold more than 4Gb we need more than 32
158 bits to hold input_bytes and output_bytes. But it's not worth
159 the trouble of adding special multi-precision arithmetic if the
160 compiler doesn't support 64 bit ints since input_bytes and
161 output_bytes are only used to print the number of blocks copied. */
163 long long input_bytes, output_bytes;
165 long input_bytes, output_bytes;
168 /* 512 bytes of 0; used for various padding operations. */
171 /* Saving of argument values for later reference. */
172 char *directory_name = NULL;
173 char **save_patterns;
176 /* Character that terminates file names read from stdin. */
177 char name_end = '\n';
179 /* true if input (cpio -i) or output (cpio -o) is a device node. */
180 char input_is_special = false;
181 char output_is_special = false;
183 /* true if lseek works on the input. */
184 char input_is_seekable = false;
186 /* true if lseek works on the output. */
187 char output_is_seekable = false;
189 /* Print extra warning messages */
190 unsigned int warn_option = 0;
192 /* Extract to standard output? */
193 bool to_stdout_option = false;
195 /* The name this program was run with. */
198 /* A pointer to either lstat or stat, depending on whether
199 dereferencing of symlinks is done for input files. */
202 /* Which copy operation to perform. (-i, -o, -p) */
203 void (*copy_function) () = 0;