1 /* global.c - global variables and initial values for cpio.
2 Copyright (C) 1990, 1991, 1992 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
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
18 #include <sys/types.h>
24 /* If TRUE, reset access times after reading files (-a). */
25 int reset_time_flag
= FALSE
;
27 /* Block size value, initially 512. -B sets to 5120. */
28 int io_block_size
= 512;
30 /* The header format to recognize and produce. */
31 enum archive_format archive_format
= arf_unknown
;
33 /* If TRUE, create directories as needed. (-d with -i or -p) */
34 int create_dir_flag
= FALSE
;
36 /* If TRUE, interactively rename files. (-r) */
37 int rename_flag
= FALSE
;
39 /* If non-NULL, the name of a file that will be read to
40 rename all of the files in the archive. --rename-batch-file. */
41 char *rename_batch_file
= NULL
;
43 /* If TRUE, print a table of contents of input. (-t) */
44 int table_flag
= FALSE
;
46 /* If TRUE, copy unconditionally (older replaces newer). (-u) */
47 int unconditional_flag
= FALSE
;
49 /* If TRUE, list the files processed, or ls -l style output with -t. (-v) */
50 int verbose_flag
= FALSE
;
52 /* If TRUE, print a . for each file processed. (-V) */
55 /* If TRUE, link files whenever possible. Used with -p option. (-l) */
56 int link_flag
= FALSE
;
58 /* If TRUE, retain previous file modification time. (-m) */
59 int retain_time_flag
= FALSE
;
61 /* Set TRUE if crc_flag is TRUE and we are doing a cpio -i. Used
62 by copy_files so it knows whether to compute the crc. */
63 int crc_i_flag
= FALSE
;
65 /* If TRUE, append to end of archive. (-A) */
66 int append_flag
= FALSE
;
68 /* If TRUE, swap bytes of each file during cpio -i. */
69 int swap_bytes_flag
= FALSE
;
71 /* If TRUE, swap halfwords of each file during cpio -i. */
72 int swap_halfwords_flag
= FALSE
;
74 /* If TRUE, we are swapping halfwords on the current file. */
75 int swapping_halfwords
= FALSE
;
77 /* If TRUE, we are swapping bytes on the current file. */
78 int swapping_bytes
= FALSE
;
80 /* If TRUE, set ownership of all files to UID `set_owner'. */
81 int set_owner_flag
= FALSE
;
84 /* If TRUE, set group ownership of all files to GID `set_group'. */
85 int set_group_flag
= FALSE
;
88 /* If TRUE, do not chown the files. */
89 int no_chown_flag
= FALSE
;
91 /* If TRUE, try to write sparse ("holey") files. */
92 int sparse_flag
= FALSE
;
94 /* If TRUE, don't report number of blocks copied. */
95 int quiet_flag
= FALSE
;
97 /* If TRUE, only read the archive and verify the files' CRC's, don't
98 actually extract the files. */
99 int only_verify_crc_flag
= FALSE
;
101 /* If TRUE, don't use any absolute paths, prefix them by `./'. */
102 int no_abs_paths_flag
= FALSE
;
105 /* If TRUE, print debugging information. */
106 int debug_flag
= FALSE
;
109 /* File position of last header read. Only used during -A to determine
110 where the old TRAILER!!! record started. */
111 int last_header_start
= 0;
113 /* With -i; if TRUE, copy only files that match any of the given patterns;
114 if FALSE, copy only files that do not match any of the patterns. (-f) */
115 int copy_matching_files
= TRUE
;
117 /* With -itv; if TRUE, list numeric uid and gid instead of translating them
119 int numeric_uid
= FALSE
;
121 /* Name of file containing additional patterns (-E). */
122 char *pattern_file_name
= NULL
;
124 /* Message to print when end of medium is reached (-M). */
125 char *new_media_message
= NULL
;
127 /* With -M with %d, message to print when end of medium is reached. */
128 char *new_media_message_with_number
= NULL
;
129 char *new_media_message_after_number
= NULL
;
131 /* File descriptor containing the archive. */
134 /* Name of file containing the archive, if known; NULL if stdin/out. */
135 char *archive_name
= NULL
;
140 /* Input and output buffers. */
141 char *input_buffer
, *output_buffer
;
143 /* The size of the input buffer. */
144 long input_buffer_size
;
146 /* Current locations in `input_buffer' and `output_buffer'. */
147 char *in_buff
, *out_buff
;
149 /* Current number of bytes stored at `input_buff' and `output_buff'. */
150 long input_size
, output_size
;
152 /* Total number of bytes read and written for all files.
153 Now that many tape drives hold more than 4Gb we need more than 32
154 bits to hold input_bytes and output_bytes. But it's not worth
155 the trouble of adding special multi-precision arithmetic if the
156 compiler doesn't support 64 bit ints since input_bytes and
157 output_bytes are only used to print the number of blocks copied. */
159 long long input_bytes
, output_bytes
;
161 long input_bytes
, output_bytes
;
164 /* 512 bytes of 0; used for various padding operations. */
167 /* Saving of argument values for later reference. */
168 char *directory_name
= NULL
;
169 char **save_patterns
;
172 /* Character that terminates file names read from stdin. */
173 char name_end
= '\n';
175 /* TRUE if input (cpio -i) or output (cpio -o) is a device node. */
176 char input_is_special
= FALSE
;
177 char output_is_special
= FALSE
;
179 /* TRUE if lseek works on the input. */
180 char input_is_seekable
= FALSE
;
182 /* TRUE if lseek works on the output. */
183 char output_is_seekable
= FALSE
;
185 /* If nonzero, don't consider file names that contain a `:' to be
186 on remote hosts; all files are local. */
187 int f_force_local
= 0;
189 /* The name this program was run with. */
192 /* A pointer to either lstat or stat, depending on whether
193 dereferencing of symlinks is done for input files. */
196 /* Which copy operation to perform. (-i, -o, -p) */
197 void (*copy_function
) () = 0;