78ed81a3 |
1 | /* global.c - global variables and initial values for cpio. |
2 | Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc. |
3 | |
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) |
7 | any later version. |
8 | |
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. |
13 | |
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. */ |
17 | |
18 | #include <sys/types.h> |
19 | #include "cpiohdr.h" |
20 | #include "dstring.h" |
21 | #include "system.h" |
22 | #include "extern.h" |
23 | |
24 | /* If TRUE, reset access times after reading files (-a). */ |
25 | int reset_time_flag = FALSE; |
26 | |
27 | /* Block size value, initially 512. -B sets to 5120. */ |
28 | int io_block_size = 512; |
29 | |
30 | /* The header format to recognize and produce. */ |
31 | enum archive_format archive_format = arf_unknown; |
32 | |
33 | /* If TRUE, create directories as needed. (-d with -i or -p) */ |
34 | int create_dir_flag = FALSE; |
35 | |
36 | /* If TRUE, interactively rename files. (-r) */ |
37 | int rename_flag = FALSE; |
38 | |
39 | /* If TRUE, print a table of contents of input. (-t) */ |
40 | int table_flag = FALSE; |
41 | |
42 | /* If TRUE, copy unconditionally (older replaces newer). (-u) */ |
43 | int unconditional_flag = FALSE; |
44 | |
45 | /* If TRUE, list the files processed, or ls -l style output with -t. (-v) */ |
46 | int verbose_flag = FALSE; |
47 | |
48 | /* If TRUE, print a . for each file processed. (-V) */ |
49 | int dot_flag = FALSE; |
50 | |
51 | /* If TRUE, link files whenever possible. Used with -p option. (-l) */ |
52 | int link_flag = FALSE; |
53 | |
54 | /* If TRUE, retain previous file modification time. (-m) */ |
55 | int retain_time_flag = FALSE; |
56 | |
57 | /* Set TRUE if crc_flag is TRUE and we are doing a cpio -i. Used |
58 | by copy_files so it knows whether to compute the crc. */ |
59 | int crc_i_flag = FALSE; |
60 | |
61 | /* If TRUE, append to end of archive. (-A) */ |
62 | int append_flag = FALSE; |
63 | |
64 | /* If TRUE, swap bytes of each file during cpio -i. */ |
65 | int swap_bytes_flag = FALSE; |
66 | |
67 | /* If TRUE, swap halfwords of each file during cpio -i. */ |
68 | int swap_halfwords_flag = FALSE; |
69 | |
70 | /* If TRUE, we are swapping halfwords on the current file. */ |
71 | int swapping_halfwords = FALSE; |
72 | |
73 | /* If TRUE, we are swapping bytes on the current file. */ |
74 | int swapping_bytes = FALSE; |
75 | |
76 | /* If TRUE, set ownership of all files to UID `set_owner'. */ |
77 | int set_owner_flag = FALSE; |
78 | uid_t set_owner; |
79 | |
80 | /* If TRUE, set group ownership of all files to GID `set_group'. */ |
81 | int set_group_flag = FALSE; |
82 | gid_t set_group; |
83 | |
84 | /* If TRUE, do not chown the files. */ |
85 | int no_chown_flag = FALSE; |
86 | |
87 | #ifdef DEBUG_CPIO |
88 | /* If TRUE, print debugging information. */ |
89 | int debug_flag = FALSE; |
90 | #endif |
91 | |
92 | /* File position of last header read. Only used during -A to determine |
93 | where the old TRAILER!!! record started. */ |
94 | int last_header_start = 0; |
95 | |
96 | /* With -i; if TRUE, copy only files that match any of the given patterns; |
97 | if FALSE, copy only files that do not match any of the patterns. (-f) */ |
98 | int copy_matching_files = TRUE; |
99 | |
100 | /* With -itv; if TRUE, list numeric uid and gid instead of translating them |
101 | into names. */ |
102 | int numeric_uid = FALSE; |
103 | |
104 | /* Name of file containing additional patterns (-E). */ |
105 | char *pattern_file_name = NULL; |
106 | |
107 | /* Message to print when end of medium is reached (-M). */ |
108 | char *new_media_message = NULL; |
109 | |
110 | /* With -M with %d, message to print when end of medium is reached. */ |
111 | char *new_media_message_with_number = NULL; |
112 | char *new_media_message_after_number = NULL; |
113 | |
114 | /* File descriptor containing the archive. */ |
115 | int archive_des; |
116 | |
117 | /* Name of file containing the archive, if known; NULL if stdin/out. */ |
118 | char *archive_name = NULL; |
119 | |
120 | /* CRC checksum. */ |
121 | unsigned long crc; |
122 | |
123 | /* Input and output buffers. */ |
124 | char *input_buffer, *output_buffer; |
125 | |
126 | /* Current locations in `input_buffer' and `output_buffer'. */ |
127 | char *in_buff, *out_buff; |
128 | |
129 | /* Current number of bytes stored at `input_buff' and `output_buff'. */ |
130 | long input_size, output_size; |
131 | |
132 | /* Total number of bytes read and written for all files. */ |
133 | long input_bytes, output_bytes; |
134 | |
135 | /* 512 bytes of 0; used for various padding operations. */ |
136 | char zeros_512[512]; |
137 | |
138 | /* Saving of argument values for later reference. */ |
139 | char *directory_name = NULL; |
140 | char **save_patterns; |
141 | int num_patterns; |
142 | |
143 | /* Character that terminates file names read from stdin. */ |
144 | char name_end = '\n'; |
145 | |
146 | /* TRUE if input (cpio -i) or output (cpio -o) is a device node. */ |
147 | char input_is_special = FALSE; |
148 | char output_is_special = FALSE; |
149 | |
150 | /* TRUE if lseek works on the input. */ |
151 | char input_is_seekable = FALSE; |
152 | |
153 | /* TRUE if lseek works on the output. */ |
154 | char output_is_seekable = FALSE; |
155 | |
156 | /* If nonzero, don't consider file names that contain a `:' to be |
157 | on remote hosts; all files are local. */ |
158 | int f_force_local = 0; |
159 | |
160 | /* The name this program was run with. */ |
161 | char *program_name; |
162 | |
163 | /* A pointer to either lstat or stat, depending on whether |
164 | dereferencing of symlinks is done for input files. */ |
165 | int (*xstat) (); |
166 | |
167 | /* Which copy operation to perform. (-i, -o, -p) */ |
168 | void (*copy_function) () = 0; |