Print this page
1154 cpio needs a quiet option
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/cpio/cpio.h
+++ new/usr/src/cmd/cpio/cpio.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 + * Copyright (c) 2012 Gary Mills
23 + *
22 24 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 25 * Use is subject to license terms.
24 26 */
25 27
26 28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 29 /* All Rights Reserved */
28 30
29 31 #ifndef _CPIO_H
30 32 #define _CPIO_H
31 33
32 34 #ifdef __cplusplus
33 35 extern "C" {
34 36 #endif
35 37
36 38 #include <stdio.h>
37 39 #include <archives.h>
38 40
39 41 /* Option Character keys (OC#), where '#' is the option character specified. */
40 42
41 43 #define OCa 0x1
42 44 #define OCb 0x2
43 45 #define OCc 0x4
44 46 #define OCd 0x8
45 47 #define OCf 0x10
46 48 #define OCi 0x20
47 49 #define OCk 0x40
48 50 #define OCl 0x80
49 51 #define OCm 0x100
50 52 #define OCo 0x200
51 53 #define OCp 0x400
52 54 #define OCr 0x800
53 55 #define OCs 0x1000
54 56 #define OCt 0x2000
55 57 #define OCu 0x4000
56 58 #define OCv 0x8000
57 59 #define OCA 0x10000
58 60 #define OCB 0x20000
59 61 #define OCC 0x40000
60 62 #define OCE 0x80000
61 63 #define OCH 0x100000
↓ open down ↓ |
30 lines elided |
↑ open up ↑ |
62 64 #define OCI 0x200000
63 65 #define OCL 0x400000
64 66 #define OCM 0x800000
65 67 #define OCO 0x1000000
66 68 #define OCR 0x2000000
67 69 #define OCS 0x4000000
68 70 #define OCV 0x8000000
69 71 #define OC6 0x10000000
70 72 #define BSM 0x20000000
71 73 #define OCP 0x40000000
74 +#define OCq 0x80000000
72 75
73 76 /* Sparse file support */
74 77 #define C_ISSPARSE 0200000
75 78 #define S_IFSPARSE 0x10000
76 79 #define HIGH_ORD_MASK 0x30000
77 80 #define S_ISSPARSE(mode) \
78 81 (S_ISREG(mode) && (mode & HIGH_ORD_MASK) == S_IFSPARSE)
79 82
80 83 /* Invalid option masks for each action option (-i, -o or -p). */
81 84
82 85 #define INV_MSK4i (OCo | OCp | OCA | OCL | OCO)
83 86
84 87 #define INV_MSK4o (OCi | OCp | OCE | OCI | OCR)
85 88
86 89 #define INV_MSK4p (OCf | OCi | OCo | OCr | OCt | OCA \
87 90 | OCE | OCH | OCI | OCO)
88 91
89 92 /* Header types */
90 93
91 94 #define NONE 0 /* No header value verified */
92 95 #define BIN 1 /* Binary */
93 96 #define CHR 2 /* ASCII character (-c) */
94 97 #define ASC 3 /* ASCII with expanded maj/min numbers */
95 98 #define CRC 4 /* CRC with expanded maj/min numbers */
96 99 #define TARTYP 5 /* Tar or USTAR */
97 100 #define SECURE 6 /* Secure system */
98 101
99 102 /* Differentiate between TAR and USTAR */
100 103
101 104 #define TAR 7 /* Regular tar */
102 105 #define USTAR 8 /* IEEE data interchange standard */
103 106
104 107 #define ULL_MAX_SIZE 20
105 108 #define UL_MAX_SIZE 10
106 109
107 110 /* constants for bar, used for extracting bar archives */
108 111 #define BAR 9
109 112 #define BAR_VOLUME_MAGIC 'V'
110 113 #define BARTYP 7
111 114 #define BARSZ 512
112 115 #define BAR_TAPE_SIZE (126*BARSZ)
113 116 #define BAR_FLOPPY_SIZE (18*BARSZ)
114 117
115 118 /* the pathname lengths for the USTAR header */
116 119
117 120 #define MAXNAM 256 /* The maximum pathname length */
118 121 #define NAMSIZ 100 /* The maximum length of the name field */
119 122 #define PRESIZ 155 /* The maximum length of the prefix */
120 123
121 124 /* HDRSZ: header size minus filename field length */
122 125
123 126 #define HDRSZ (Hdr.h_name - (char *)&Hdr)
124 127
125 128 /*
126 129 * IDENT: Determine if two stat() structures represent identical files.
127 130 * Assumes that if the device and inode are the same the files are
128 131 * identical (prevents the archive file from appearing in the archive).
129 132 */
130 133
131 134 #define IDENT(a, b) ((a.st_ino == b.st_ino && a.st_dev == b.st_dev) ? 1 : 0)
132 135
133 136 /*
134 137 * FLUSH: Determine if enough space remains in the buffer to hold
135 138 * cnt bytes, if not, call bflush() to flush the buffer to the archive.
136 139 */
137 140
138 141 #define FLUSH(cnt) if ((Buffr.b_end_p - Buffr.b_in_p) < cnt) bflush()
139 142
140 143 /*
141 144 * FILL: Determine if enough bytes remain in the buffer to meet current needs,
142 145 * if not, call rstbuf() to reset and refill the buffer from the archive.
143 146 */
144 147
145 148 #define FILL(cnt) while (Buffr.b_cnt < cnt) rstbuf()
146 149
147 150 /*
148 151 * VERBOSE: If x is non-zero, call verbose().
149 152 */
150 153
151 154 #define VERBOSE(x, name) if (x) verbose(name)
152 155
153 156 /*
154 157 * FORMAT: Date time formats
155 158 * b - abbreviated month name
156 159 * e - day of month (1 - 31)
157 160 * H - hour (00 - 23)
158 161 * M - minute (00 - 59)
159 162 * Y - year as ccyy
160 163 */
161 164
162 165 #define FORMAT "%b %e %H:%M %Y"
163 166
164 167 /* Extended system attributes */
165 168 #ifndef VIEW_READONLY
166 169 #define VIEW_READONLY "SUNWattr_ro"
167 170 #endif
168 171
169 172 #ifndef VIEW_READWRITE
170 173 #define VIEW_READWRITE "SUNWattr_rw"
171 174 #endif
172 175
173 176 #define min(a, b) ((a) < (b) ? (a) : (b))
174 177
175 178 /* Values used in typeflag field */
176 179 #define REGTYPE '0' /* Regular File */
177 180 #define LNKTYPE '1' /* Link */
178 181 #define SYMTYPE '2' /* Reserved */
179 182 #define CHRTYPE '3' /* Character Special File */
180 183 #define BLKTYPE '4' /* Block Special File */
181 184 #define DIRTYPE '5' /* Directory */
182 185 #define FIFOTYPE '6' /* FIFO */
183 186 #define CONTTYPE '7' /* Reserved */
184 187 #define XHDRTYPE 'X' /* Extended header */
185 188
186 189 #define INPUT 0 /* -i mode (used for chgreel() */
187 190 #define OUTPUT 1 /* -o mode (used for chgreel() */
188 191 #define APATH 1024 /* maximum ASC or CRC header path length */
189 192 #define CPATH 256 /* maximum -c and binary path length */
190 193 #define BUFSZ 512 /* default buffer size for archive I/O */
191 194 #define CPIOBSZ 8192 /* buffer size for file system I/O */
192 195 #define LNK_INC 500 /* link allocation increment */
193 196 #define MX_BUFS 10 /* max. number of buffers to allocate */
194 197
195 198 #define F_SKIP 0 /* an object did not match the patterns */
196 199 #define F_LINK 1 /* linked file */
197 200 #define F_EXTR 2 /* extract non-linked object that matched patterns */
198 201
199 202 #define MX_SEEKS 10 /* max. number of lseek attempts after error */
200 203 #define SEEK_ABS 0 /* lseek absolute */
201 204 #define SEEK_REL 1 /* lseek relative */
202 205
203 206 /*
204 207 * xxx_CNT represents the number of sscanf items that will be matched
205 208 * if the sscanf to read a header is successful. If sscanf returns a number
206 209 * that is not equal to this, an error occured (which indicates that this
207 210 * is not a valid header of the type assumed.
208 211 */
209 212
210 213 #define ASC_CNT 14 /* ASC and CRC headers */
211 214 #define CHR_CNT 11 /* CHR header */
212 215
213 216 /* These defines determine the severity of the message sent to the user. */
214 217
215 218 #define ERR 1 /* Error message (warning) - not fatal */
216 219 #define EXT 2 /* Error message - fatal, causes exit */
217 220 #define ERRN 3 /* Error message with errno (warning) - not fatal */
218 221 #define EXTN 4 /* Error message with errno - fatal, causes exit */
219 222 #define POST 5 /* Information message, not an error */
220 223 #define EPOST 6 /* Information message to stderr */
221 224
222 225 #define SIXTH 060000 /* UNIX 6th edition files */
223 226
224 227 #define P_SKIP 0 /* File should be skipped */
225 228 #define P_PROC 1 /* File should be processed */
226 229
227 230 #define U_KEEP 0 /* Keep the existing version of a file (-u) */
228 231 #define U_OVER 1 /* Overwrite the existing version of a file (-u) */
229 232
230 233 /*
231 234 * _20K: Allocate the maximum of (20K or (MX_BUFS * Bufsize)) bytes
232 235 * for the main I/O buffer. Therefore if a user specifies a small buffer
233 236 * size, they still get decent performance due to the buffering strategy.
234 237 */
235 238
236 239 #define _20K 20480
237 240
238 241 #define HALFWD 1 /* Pad headers/data to halfword boundaries */
239 242 #define FULLWD 3 /* Pad headers/data to word boundaries */
240 243 #define FULLBK 511 /* Pad headers/data to 512 byte boundaries */
241 244
242 245 /* bar structure */
243 246 union b_block {
244 247 char dummy[TBLOCK];
245 248 struct bar_header {
246 249 char mode[8];
247 250 char uid[8];
248 251 char gid[8];
249 252 char size[12];
250 253 char mtime[12];
251 254 char chksum[8];
252 255 char rdev[8];
253 256 char linkflag;
254 257
255 258 /*
256 259 * The following fields are specific to the volume
257 260 * header. They are set to zero in all file headers
258 261 * in the archive.
259 262 */
260 263 char bar_magic[2]; /* magic number */
261 264 char volume_num[4]; /* volume number */
262 265 char compressed; /* files compressed = 1 */
263 266 char date[12]; /* date of archive mmddhhmm */
264 267 char start_of_name; /* start of the filename */
265 268 } dbuf;
266 269 };
267 270
268 271 /* svr32 stat structure -- for -Hodc headers */
269 272
270 273 typedef struct cpioinfo {
271 274 o_dev_t st_dev;
272 275 o_ino_t st_ino;
273 276 o_mode_t st_mode;
274 277 o_nlink_t st_nlink;
275 278 uid_t st_uid; /* actual uid */
276 279 gid_t st_gid; /* actual gid */
277 280 o_dev_t st_rdev;
278 281 off_t st_size;
279 282 time_t st_modtime;
280 283 } cpioinfo_t;
281 284
282 285 extern void msg(int severity, const char *fmt, ...);
283 286 extern void stat_to_svr32_stat(cpioinfo_t *TmpSt, struct stat *FromStat);
284 287
285 288 /*
286 289 * Allocation wrappers and their flags
287 290 */
288 291 #define E_NORMAL 0x0 /* Return NULL if allocation fails */
289 292 #define E_EXIT 0x1 /* Exit if allocation fails */
290 293
291 294 extern void *e_realloc(int flag, void *old, size_t newsize);
292 295 extern char *e_strdup(int flag, const char *arg);
293 296 extern void *e_valloc(int flag, size_t size);
294 297 extern void *e_zalloc(int flag, size_t size);
295 298
296 299 /*
297 300 * If compiling on a system that doesn't
298 301 * support extended attributes, then
299 302 * define a couple of things so we can compile.
300 303 */
301 304 #if !defined(O_XATTR)
302 305 #define AT_SYMLINK_NOFOLLOW 0x1000
303 306 #define AT_REMOVEDIR 0x0001
304 307 #define _XATTR_CPIO_MODE 0xB000
305 308 #define _XATTR_HDRTYPE 'E'
306 309 #endif /* O_XATTR */
307 310
308 311 /*
309 312 * Sparse file support
310 313 */
311 314 #define MIN_HOLES_HDRSIZE (UL_MAX_SIZE + 1 + ULL_MAX_SIZE + 1)
312 315
313 316 typedef struct holes_list {
314 317 off_t hl_data;
315 318 off_t hl_hole;
316 319 struct holes_list *hl_next;
317 320 } holes_list_t;
318 321
319 322 typedef struct holes_info {
320 323 holes_list_t *holes_list; /* linked list of holes_list */
321 324 off_t orig_size; /* original file size */
322 325 off_t data_size; /* compressed file size */
323 326 char *holesdata; /* holesdata string */
324 327 size_t holesdata_sz; /* string size */
325 328 } holes_info_t;
326 329
327 330 extern holes_info_t *get_holes_info(int, off_t, boolean_t);
328 331 extern holes_info_t *read_holes_header(const char *, off_t);
329 332 extern int parse_holesdata(holes_info_t *, const char *);
330 333 extern void free_holes_info(holes_info_t *);
331 334
332 335 extern void str_fprintf(FILE *, const char *, ...);
333 336
334 337 #ifdef __cplusplus
335 338 }
336 339 #endif
337 340
338 341 #endif /* _CPIO_H */
↓ open down ↓ |
257 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX