1 /* global.c - global variables and initial values for cpio. 2 Copyright (C) 1990-1992, 2001, 2006-2007, 2009-2010, 2014-2015, 2017 3 Free Software Foundation, Inc. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3, or (at your option) 8 any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public 16 License along with this program; if not, write to the Free 17 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301 USA. */ 19 20 #include <system.h> 21 22 #include <sys/types.h> 23 #include "cpiohdr.h" 24 #include "dstring.h" 25 #include "extern.h" 26 27 /* If true, reset access times after reading files (-a). */ 28 int reset_time_flag = false; 29 30 /* Block size value, initially 512. -B sets to 5120. */ 31 int io_block_size = 512; 32 33 /* The header format to recognize and produce. */ 34 enum archive_format archive_format = arf_unknown; 35 36 /* If true, create directories as needed. (-d with -i or -p) */ 37 int create_dir_flag = false; 38 39 /* If true, interactively rename files. (-r) */ 40 int rename_flag = false; 41 42 /* If non-NULL, the name of a file that will be read to 43 rename all of the files in the archive. --rename-batch-file. */ 44 char *rename_batch_file = NULL; 45 46 /* If true, print a table of contents of input. (-t) */ 47 int table_flag = false; 48 49 /* If true, copy unconditionally (older replaces newer). (-u) */ 50 int unconditional_flag = false; 51 52 /* If true, list the files processed, or ls -l style output with -t. (-v) */ 53 int verbose_flag = false; 54 55 /* If true, print a . for each file processed. (-V) */ 56 int dot_flag = false; 57 58 /* If true, link files whenever possible. Used with -p option. (-l) */ 59 int link_flag = false; 60 61 /* If true, retain previous file modification time. (-m) */ 62 int retain_time_flag = false; 63 64 /* Set true if crc_flag is true and we are doing a cpio -i. Used 65 by copy_files so it knows whether to compute the crc. */ 66 int crc_i_flag = false; 67 68 /* If true, append to end of archive. (-A) */ 69 int append_flag = false; 70 71 /* If true, swap bytes of each file during cpio -i. */ 72 int swap_bytes_flag = false; 73 74 /* If true, swap halfwords of each file during cpio -i. */ 75 int swap_halfwords_flag = false; 76 77 /* If true, we are swapping halfwords on the current file. */ 78 int swapping_halfwords = false; 79 80 /* If true, we are swapping bytes on the current file. */ 81 int swapping_bytes = false; 82 83 /* Umask for creating new directories */ 84 mode_t newdir_umask; 85 86 /* If true, set ownership of all files to UID `set_owner'. */ 87 int set_owner_flag = false; 88 uid_t set_owner; 89 90 /* If true, set group ownership of all files to GID `set_group'. */ 91 int set_group_flag = false; 92 gid_t set_group; 93 94 /* If true, do not chown the files. */ 95 int no_chown_flag = false; 96 97 /* If true, try to write sparse ("holey") files. */ 98 int sparse_flag = false; 99 100 /* If true, don't report number of blocks copied. */ 101 int quiet_flag = false; 102 103 /* If true, only read the archive and verify the files' CRC's, don't 104 actually extract the files. */ 105 int only_verify_crc_flag = false; 106 107 /* If true, don't use any absolute paths, prefix them by `./'. */ 108 int no_abs_paths_flag = false; 109 110 #ifdef DEBUG_CPIO 111 /* If true, print debugging information. */ 112 int debug_flag = false; 113 #endif 114 115 /* File position of last header read. Only used during -A to determine 116 where the old TRAILER!!! record started. */ 117 int last_header_start = 0; 118 119 /* With -i; if true, copy only files that match any of the given patterns; 120 if false, copy only files that do not match any of the patterns. (-f) */ 121 int copy_matching_files = true; 122 123 /* With -itv; if true, list numeric uid and gid instead of translating them 124 into names. */ 125 int numeric_uid = false; 126 127 /* Name of file containing additional patterns (-E). */ 128 char *pattern_file_name = NULL; 129 130 /* Message to print when end of medium is reached (-M). */ 131 char *new_media_message = NULL; 132 133 /* With -M with %d, message to print when end of medium is reached. */ 134 char *new_media_message_with_number = NULL; 135 char *new_media_message_after_number = NULL; 136 137 /* File descriptor containing the archive. */ 138 int archive_des; 139 140 /* Name of file containing the archive, if known; NULL if stdin/out. */ 141 char *archive_name = NULL; 142 143 /* Name of the remote shell command, if known; NULL otherwise. */ 144 char *rsh_command_option = NULL; 145 146 /* CRC checksum. */ 147 uint32_t crc; 148 149 /* Input and output buffers. */ 150 char *input_buffer, *output_buffer; 151 152 /* The size of the input buffer. */ 153 size_t input_buffer_size; 154 155 /* Current locations in `input_buffer' and `output_buffer'. */ 156 char *in_buff, *out_buff; 157 158 /* Current number of bytes stored at `input_buff' and `output_buff'. */ 159 size_t input_size, output_size; 160 161 off_t input_bytes, output_bytes; 162 163 /* Saving of argument values for later reference. */ 164 char *directory_name = NULL; 165 char **save_patterns; 166 int num_patterns; 167 168 /* Character that terminates file names read from stdin. */ 169 char name_end = '\n'; 170 171 /* true if input (cpio -i) or output (cpio -o) is a device node. */ 172 char input_is_special = false; 173 char output_is_special = false; 174 175 /* true if lseek works on the input. */ 176 char input_is_seekable = false; 177 178 /* true if lseek works on the output. */ 179 char output_is_seekable = false; 180 181 /* Print extra warning messages */ 182 unsigned int warn_option = 0; 183 184 /* Extract to standard output? */ 185 bool to_stdout_option = false; 186 187 /* A pointer to either lstat or stat, depending on whether 188 dereferencing of symlinks is done for input files. */ 189 int (*xstat) (); 190 191 /* Which copy operation to perform. (-i, -o, -p) */ 192 void (*copy_function) () = 0; 193 194 char *change_directory_option; 195 196 int renumber_inodes_option; 197 int ignore_devno_option; 198 199