cpio.c (0b9a51588b7231474f7b4009cb9cad83e4db7b74) | cpio.c (6d3b960aa395b3d268922a1938aed248a213725b) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 14 unchanged lines hidden (view full) --- 23 * Copyright 2012 Milan Jurik. All rights reserved. 24 * Copyright (c) 2012 Gary Mills 25 */ 26 27/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28/* All Rights Reserved */ 29 30/* | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 14 unchanged lines hidden (view full) --- 23 * Copyright 2012 Milan Jurik. All rights reserved. 24 * Copyright (c) 2012 Gary Mills 25 */ 26 27/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28/* All Rights Reserved */ 29 30/* |
31 * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. 32 */ 33 34/* |
|
31 * Portions of this source code were derived from Berkeley 4.3 BSD 32 * under license from the Regents of the University of California. 33 */ 34 35#include <stdio.h> 36#include <sys/types.h> 37#include <errno.h> 38#include <unistd.h> --- 32 unchanged lines hidden (view full) --- 71#endif /* _PC_SATTR_ENABLED */ 72#ifdef SOLARIS_PRIVS 73#include <priv.h> 74#endif /* SOLARIS_PRIVS */ 75 76/* 77 * Special kludge for off_t being a signed quantity. 78 */ | 35 * Portions of this source code were derived from Berkeley 4.3 BSD 36 * under license from the Regents of the University of California. 37 */ 38 39#include <stdio.h> 40#include <sys/types.h> 41#include <errno.h> 42#include <unistd.h> --- 32 unchanged lines hidden (view full) --- 75#endif /* _PC_SATTR_ENABLED */ 76#ifdef SOLARIS_PRIVS 77#include <priv.h> 78#endif /* SOLARIS_PRIVS */ 79 80/* 81 * Special kludge for off_t being a signed quantity. 82 */ |
79#if _FILE_OFFSET_BITS == 64 80typedef u_longlong_t u_off_t; 81#else | |
82typedef ulong_t u_off_t; | 83typedef ulong_t u_off_t; |
83#endif | |
84 85#define SECMODE 0xe080 86 87#define DEVNULL "/dev/null" 88#define XATTRHDR ".hdr" 89 90#define NAMELEN 32 91#define TYPELEN 16 --- 20 unchanged lines hidden (view full) --- 112#define LSTAT(dir, path, statbuf) fstatat(dir, \ 113 get_component((Gen.g_attrnam_p == NULL) ? \ 114 path : Gen.g_attrnam_p), statbuf, AT_SYMLINK_NOFOLLOW) 115#define STAT(dir, path, statbuf) fstatat(dir, \ 116 get_component((Gen.g_attrnam_p == NULL) ? \ 117 path : Gen.g_attrnam_p), statbuf, 0) 118 119/* | 84 85#define SECMODE 0xe080 86 87#define DEVNULL "/dev/null" 88#define XATTRHDR ".hdr" 89 90#define NAMELEN 32 91#define TYPELEN 16 --- 20 unchanged lines hidden (view full) --- 112#define LSTAT(dir, path, statbuf) fstatat(dir, \ 113 get_component((Gen.g_attrnam_p == NULL) ? \ 114 path : Gen.g_attrnam_p), statbuf, AT_SYMLINK_NOFOLLOW) 115#define STAT(dir, path, statbuf) fstatat(dir, \ 116 get_component((Gen.g_attrnam_p == NULL) ? \ 117 path : Gen.g_attrnam_p), statbuf, 0) 118 119/* |
120 * Convert from and to old dev_t formats. 121 */ 122#define SVR3_MAJOR(x) ((major_t)((dev_t)(x) >> ONBITSMINOR) & OMAXMAJ) 123#define SVR3_MINOR(x) ((minor_t)((dev_t)(x) & OMAXMIN)) 124#define TO_SVR3(maj, min) \ 125 ((((ushort_t)(maj) & OMAXMAJ) << ONBITSMINOR) | \ 126 ((ushort_t)(min) & OMAXMIN)) 127 128/* |
|
120 * These limits reflect the maximum size regular file that 121 * can be archived, depending on the archive type. For archives 122 * with character-format headers (odc, tar, ustar) we use 123 * CHAR_OFFSET_MAX. For archives with SVR4 ASCII headers (-c, -H crc) 124 * we store filesize in an 8-char hexadecimal string and use 125 * ASC_OFFSET_MAX. Otherwise, we are limited to the size that will | 129 * These limits reflect the maximum size regular file that 130 * can be archived, depending on the archive type. For archives 131 * with character-format headers (odc, tar, ustar) we use 132 * CHAR_OFFSET_MAX. For archives with SVR4 ASCII headers (-c, -H crc) 133 * we store filesize in an 8-char hexadecimal string and use 134 * ASC_OFFSET_MAX. Otherwise, we are limited to the size that will |
126 * fit in a signed long value. | 135 * fit in a signed int value. |
127 */ 128#define CHAR_OFFSET_MAX 077777777777ULL /* 11 octal digits */ 129#define ASC_OFFSET_MAX 0XFFFFFFFF /* 8 hexadecimal digits */ | 136 */ 137#define CHAR_OFFSET_MAX 077777777777ULL /* 11 octal digits */ 138#define ASC_OFFSET_MAX 0XFFFFFFFF /* 8 hexadecimal digits */ |
130#define BIN_OFFSET_MAX LONG_MAX /* signed long max value */ | 139#define BIN_OFFSET_MAX INT_MAX /* signed int max value */ |
131 132#define POSIXMODES 07777 133 134static char aclchar = ' '; 135 136static struct Lnk *add_lnk(struct Lnk **); 137static int bfill(void); 138static void bflush(void); 139static int chgreel(int dir); 140static int ckname(int); 141static void ckopts(long mask); | 140 141#define POSIXMODES 07777 142 143static char aclchar = ' '; 144 145static struct Lnk *add_lnk(struct Lnk **); 146static int bfill(void); 147static void bflush(void); 148static int chgreel(int dir); 149static int ckname(int); 150static void ckopts(long mask); |
142static long cksum(char hdr, int byt_cnt, int *err); | 151static uint_t cksum(char hdr, int byt_cnt, int *err); |
143static int creat_hdr(void); 144static int creat_lnk(int dirfd, char *name1_p, char *name2_p); 145static int creat_spec(int dirfd); 146static int creat_tmp(char *nam_p); 147static void data_in(int proc_mode); 148static void data_out(void); 149static void data_pass(void); 150static void file_in(void); --- 72 unchanged lines hidden (view full) --- 223/* Data structure for buffered I/O. */ 224 225static 226struct buf_info { 227 char *b_base_p, /* Pointer to base of buffer */ 228 *b_out_p, /* Position to take bytes from buffer at */ 229 *b_in_p, /* Position to put bytes into buffer at */ 230 *b_end_p; /* Pointer to end of buffer */ | 152static int creat_hdr(void); 153static int creat_lnk(int dirfd, char *name1_p, char *name2_p); 154static int creat_spec(int dirfd); 155static int creat_tmp(char *nam_p); 156static void data_in(int proc_mode); 157static void data_out(void); 158static void data_pass(void); 159static void file_in(void); --- 72 unchanged lines hidden (view full) --- 232/* Data structure for buffered I/O. */ 233 234static 235struct buf_info { 236 char *b_base_p, /* Pointer to base of buffer */ 237 *b_out_p, /* Position to take bytes from buffer at */ 238 *b_in_p, /* Position to put bytes into buffer at */ 239 *b_end_p; /* Pointer to end of buffer */ |
231 long b_cnt, /* Count of unprocessed bytes */ | 240 int b_cnt, /* Count of unprocessed bytes */ |
232 b_size; /* Size of buffer in bytes */ 233} Buffr; 234 235/* Generic header format */ 236 237static 238struct gen_hdr { | 241 b_size; /* Size of buffer in bytes */ 242} Buffr; 243 244/* Generic header format */ 245 246static 247struct gen_hdr { |
239 ulong_t g_magic, /* Magic number field */ | 248 uint_t g_magic, /* Magic number field */ |
240 g_ino, /* Inode number of file */ 241 g_mode, /* Mode of file */ 242 g_uid, /* Uid of file */ 243 g_gid, /* Gid of file */ 244 g_nlink, /* Number of links */ 245 g_mtime; /* Modification time */ 246 off_t g_filesz; /* Length of file */ | 249 g_ino, /* Inode number of file */ 250 g_mode, /* Mode of file */ 251 g_uid, /* Uid of file */ 252 g_gid, /* Gid of file */ 253 g_nlink, /* Number of links */ 254 g_mtime; /* Modification time */ 255 off_t g_filesz; /* Length of file */ |
247 ulong_t g_dev, /* File system of file */ 248 g_rdev, /* Major/minor numbers of special files */ 249 g_namesz, /* Length of filename */ | 256 dev_t g_dev, /* File system of file */ 257 g_rdev; /* Major/minor numbers of special files */ 258 uint_t g_namesz, /* Length of filename */ |
250 g_cksum; /* Checksum of file */ 251 char g_gname[32], 252 g_uname[32], 253 g_version[2], 254 g_tmagic[6], 255 g_typeflag; 256 char *g_tname, 257 *g_prefix, --- 48 unchanged lines hidden (view full) --- 306static 307FILE *In_p = stdin; /* Where the input comes from */ 308 309typedef struct sl_info 310{ 311 struct sl_info *llink; /* Left subtree ptr (tree depth in *sl_head) */ 312 struct sl_info *rlink; /* Right subtree ptr */ 313 int bal; /* Subtree balance factor */ | 259 g_cksum; /* Checksum of file */ 260 char g_gname[32], 261 g_uname[32], 262 g_version[2], 263 g_tmagic[6], 264 g_typeflag; 265 char *g_tname, 266 *g_prefix, --- 48 unchanged lines hidden (view full) --- 315static 316FILE *In_p = stdin; /* Where the input comes from */ 317 318typedef struct sl_info 319{ 320 struct sl_info *llink; /* Left subtree ptr (tree depth in *sl_head) */ 321 struct sl_info *rlink; /* Right subtree ptr */ 322 int bal; /* Subtree balance factor */ |
314 ulong_t sl_count; /* Number of symlinks */ | 323 uint_t sl_count; /* Number of symlinks */ |
315 int sl_ftype; /* file type of inode */ 316 ino_t sl_ino; /* Inode of file */ 317 ino_t sl_ino2; /* alternate inode for -Hodc */ 318} sl_info_t; 319 320typedef struct data_in 321{ 322 int data_in_errno; --- 31 unchanged lines hidden (view full) --- 354 int inode_count; /* # inodes seen on dev */ 355 struct sl_remap *next; /* next in the chain */ 356} sl_remap_t; 357 358/* forward declarations */ 359 360static sl_info_t *sl_info_alloc(void); 361static sl_info_t *sl_insert(dev_t, ino_t, int); | 324 int sl_ftype; /* file type of inode */ 325 ino_t sl_ino; /* Inode of file */ 326 ino_t sl_ino2; /* alternate inode for -Hodc */ 327} sl_info_t; 328 329typedef struct data_in 330{ 331 int data_in_errno; --- 31 unchanged lines hidden (view full) --- 363 int inode_count; /* # inodes seen on dev */ 364 struct sl_remap *next; /* next in the chain */ 365} sl_remap_t; 366 367/* forward declarations */ 368 369static sl_info_t *sl_info_alloc(void); 370static sl_info_t *sl_insert(dev_t, ino_t, int); |
362static ulong_t sl_numlinks(dev_t, ino_t, int); | 371static uint_t sl_numlinks(dev_t, ino_t, int); |
363static void sl_preview_synonyms(void); 364static void sl_remember_tgt(const struct stat *, int, int); 365static sl_info_t *sl_search(dev_t, ino_t, int); 366static sl_info_t *sl_devhash_lookup(dev_t); 367static void sl_devhash_insert(dev_t, sl_info_t *); 368 369extern int sl_compare(ino_t, int, ino_t, int); 370#define sl_compare(lino, lftype, rino, rftype) (lino < rino ? -1 : \ --- 37 unchanged lines hidden (view full) --- 408 * halfwords within a word, or to reverse the order of the 409 * bytes within a word. Also used in mklong() and mkshort(). 410 */ 411 412static 413union swpbuf { 414 unsigned char s_byte[4]; 415 ushort_t s_half[2]; | 372static void sl_preview_synonyms(void); 373static void sl_remember_tgt(const struct stat *, int, int); 374static sl_info_t *sl_search(dev_t, ino_t, int); 375static sl_info_t *sl_devhash_lookup(dev_t); 376static void sl_devhash_insert(dev_t, sl_info_t *); 377 378extern int sl_compare(ino_t, int, ino_t, int); 379#define sl_compare(lino, lftype, rino, rftype) (lino < rino ? -1 : \ --- 37 unchanged lines hidden (view full) --- 417 * halfwords within a word, or to reverse the order of the 418 * bytes within a word. Also used in mklong() and mkshort(). 419 */ 420 421static 422union swpbuf { 423 unsigned char s_byte[4]; 424 ushort_t s_half[2]; |
416 ulong_t s_word; | 425 uint_t s_word; |
417} *Swp_p; 418 419static 420char *myname, /* program name */ 421 Adir, /* Flags object as a directory */ 422 Hiddendir, /* Processing hidden attribute directory */ 423 Aspec, /* Flags object as a special file */ 424 Do_rename, /* Indicates rename() is to be used */ --- 60 unchanged lines hidden (view full) --- 485static 486long Args, /* Mask of selected options */ 487 Max_namesz = CPATH; /* Maximum size of pathnames/filenames */ 488 489static 490int Bufsize = BUFSZ; /* Default block size */ 491 492 | 426} *Swp_p; 427 428static 429char *myname, /* program name */ 430 Adir, /* Flags object as a directory */ 431 Hiddendir, /* Processing hidden attribute directory */ 432 Aspec, /* Flags object as a special file */ 433 Do_rename, /* Indicates rename() is to be used */ --- 60 unchanged lines hidden (view full) --- 494static 495long Args, /* Mask of selected options */ 496 Max_namesz = CPATH; /* Maximum size of pathnames/filenames */ 497 498static 499int Bufsize = BUFSZ; /* Default block size */ 500 501 |
493static u_longlong_t Blocks; /* full blocks transferred */ 494static u_longlong_t SBlocks; /* cumulative char count from short reads */ | 502static ulong_t Blocks; /* full blocks transferred */ 503static ulong_t SBlocks; /* cumulative char count from short reads */ |
495 496 497static off_t Max_offset = BIN_OFFSET_MAX; /* largest file size */ 498static off_t Max_filesz; /* from getrlimit */ 499 | 504 505 506static off_t Max_offset = BIN_OFFSET_MAX; /* largest file size */ 507static off_t Max_filesz; /* from getrlimit */ 508 |
500static ulong_t Savedev; | 509static uint_t Savedev; |
501 502static 503FILE *Ef_p, /* File pointer of pattern input file */ 504 *Err_p = stderr, /* File pointer for error reporting */ 505 *Out_p = stdout, /* File pointer for non-archive output */ 506 *Rtty_p, /* Input file pointer for interactive rename */ 507 *Wtty_p; /* Output file ptr for interactive rename */ 508 --- 233 unchanged lines hidden (view full) --- 742 aclp = NULL; 743 } 744 acl_is_set = 0; 745 } 746 (void) memset(&Gen, 0, sizeof (Gen)); 747 } 748 /* Do not count "extra" "read-ahead" buffered data */ 749 if (Buffr.b_cnt > Bufsize) | 510 511static 512FILE *Ef_p, /* File pointer of pattern input file */ 513 *Err_p = stderr, /* File pointer for error reporting */ 514 *Out_p = stdout, /* File pointer for non-archive output */ 515 *Rtty_p, /* Input file pointer for interactive rename */ 516 *Wtty_p; /* Output file ptr for interactive rename */ 517 --- 233 unchanged lines hidden (view full) --- 751 aclp = NULL; 752 } 753 acl_is_set = 0; 754 } 755 (void) memset(&Gen, 0, sizeof (Gen)); 756 } 757 /* Do not count "extra" "read-ahead" buffered data */ 758 if (Buffr.b_cnt > Bufsize) |
750 Blocks -= (u_longlong_t)(Buffr.b_cnt / Bufsize); | 759 Blocks -= (Buffr.b_cnt / Bufsize); |
751 break; 752 case OCo: /* COPY OUT */ 753 if (Args & OCA) { 754 scan4trail(); 755 } 756 757 Gen.g_dirfd = -1; 758 Gen.g_dirpath = NULL; --- 63 unchanged lines hidden (view full) --- 822 if (close(Ofile) != 0) 823 msg(EXTN, "close error"); 824 } 825 if (Archive > 0) { 826 if (close(Archive) != 0) 827 msg(EXTN, "close error"); 828 } 829 if ((Args & OCq) == 0) { | 760 break; 761 case OCo: /* COPY OUT */ 762 if (Args & OCA) { 763 scan4trail(); 764 } 765 766 Gen.g_dirfd = -1; 767 Gen.g_dirpath = NULL; --- 63 unchanged lines hidden (view full) --- 831 if (close(Ofile) != 0) 832 msg(EXTN, "close error"); 833 } 834 if (Archive > 0) { 835 if (close(Archive) != 0) 836 msg(EXTN, "close error"); 837 } 838 if ((Args & OCq) == 0) { |
830 Blocks = (u_longlong_t)(Blocks * Bufsize + SBlocks + | 839 Blocks = (ulong_t)(Blocks * Bufsize + SBlocks + |
831 0x1FF) >> 9; | 840 0x1FF) >> 9; |
832 msg(EPOST, "%lld blocks", Blocks); | 841 msg(EPOST, "%ld blocks", Blocks); |
833 } 834 if (Error_cnt) 835 msg(EPOST, "%d error(s)", Error_cnt); 836 return (EXIT_CODE); 837} 838 839/* 840 * add_lnk: Add a linked file's header to the linked file data structure, by --- 95 unchanged lines hidden (view full) --- 936 Buf_error++; 937 rv = 0; 938 continue; 939 } else 940 ioerror(INPUT); 941 } /* (rv = g_read(Device, Archive ... */ 942 if (Hdr_type != BAR || rv == Bufsize) { 943 Buffr.b_in_p += rv; | 842 } 843 if (Error_cnt) 844 msg(EPOST, "%d error(s)", Error_cnt); 845 return (EXIT_CODE); 846} 847 848/* 849 * add_lnk: Add a linked file's header to the linked file data structure, by --- 95 unchanged lines hidden (view full) --- 945 Buf_error++; 946 rv = 0; 947 continue; 948 } else 949 ioerror(INPUT); 950 } /* (rv = g_read(Device, Archive ... */ 951 if (Hdr_type != BAR || rv == Bufsize) { 952 Buffr.b_in_p += rv; |
944 Buffr.b_cnt += (long)rv; | 953 Buffr.b_cnt += rv; |
945 } 946 if (rv == Bufsize) { 947 eof = 0; 948 Blocks++; 949 } else if (rv == 0) { 950 if (!eof) { 951 eof = 1; 952 break; --- 8 unchanged lines hidden (view full) --- 961 */ 962 if (Hdr_type == BAR) { 963 skip_bar_volhdr(); 964 } 965 966 continue; 967 } else { 968 eof = 0; | 954 } 955 if (rv == Bufsize) { 956 eof = 0; 957 Blocks++; 958 } else if (rv == 0) { 959 if (!eof) { 960 eof = 1; 961 break; --- 8 unchanged lines hidden (view full) --- 970 */ 971 if (Hdr_type == BAR) { 972 skip_bar_volhdr(); 973 } 974 975 continue; 976 } else { 977 eof = 0; |
969 SBlocks += (u_longlong_t)rv; | 978 SBlocks += (ulong_t)rv; |
970 } 971 } /* (Buffr.b_end_p - Buffr.b_in_p) <= Bufsize */ 972 973 } else { /* Dflag */ 974 errno = 0; 975 if ((rv = g_read(Device, Archive, Buffr.b_in_p, Bufsize)) < 0) { 976 return (-1); 977 } /* (rv = g_read(Device, Archive ... */ 978 Buffr.b_in_p += rv; | 979 } 980 } /* (Buffr.b_end_p - Buffr.b_in_p) <= Bufsize */ 981 982 } else { /* Dflag */ 983 errno = 0; 984 if ((rv = g_read(Device, Archive, Buffr.b_in_p, Bufsize)) < 0) { 985 return (-1); 986 } /* (rv = g_read(Device, Archive ... */ 987 Buffr.b_in_p += rv; |
979 Buffr.b_cnt += (long)rv; | 988 Buffr.b_cnt += rv; |
980 if (rv == Bufsize) { 981 eof = 0; 982 Blocks++; 983 } else if (!rv) { 984 if (!eof) { 985 eof = 1; 986 return (rv); 987 } 988 return (-1); 989 } else { 990 eof = 0; | 989 if (rv == Bufsize) { 990 eof = 0; 991 Blocks++; 992 } else if (!rv) { 993 if (!eof) { 994 eof = 1; 995 return (rv); 996 } 997 return (-1); 998 } else { 999 eof = 0; |
991 SBlocks += (u_longlong_t)rv; | 1000 SBlocks += (ulong_t)rv; |
992 } 993 } 994 return (rv); 995} 996 997/* 998 * bflush: Move wr_cnt bytes from data_p into the I/O buffer. When the 999 * I/O buffer is full, Flushbuf is set and the buffer is written out. --- 9 unchanged lines hidden (view full) --- 1009 if ((rv = g_write(Device, Archive, Buffr.b_out_p, 1010 Bufsize)) < 0) { 1011 if (errno == ENOSPC && !Dflag) 1012 rv = chgreel(OUTPUT); 1013 else 1014 ioerror(OUTPUT); 1015 } 1016 Buffr.b_out_p += rv; | 1001 } 1002 } 1003 return (rv); 1004} 1005 1006/* 1007 * bflush: Move wr_cnt bytes from data_p into the I/O buffer. When the 1008 * I/O buffer is full, Flushbuf is set and the buffer is written out. --- 9 unchanged lines hidden (view full) --- 1018 if ((rv = g_write(Device, Archive, Buffr.b_out_p, 1019 Bufsize)) < 0) { 1020 if (errno == ENOSPC && !Dflag) 1021 rv = chgreel(OUTPUT); 1022 else 1023 ioerror(OUTPUT); 1024 } 1025 Buffr.b_out_p += rv; |
1017 Buffr.b_cnt -= (long)rv; | 1026 Buffr.b_cnt -= rv; |
1018 if (rv == Bufsize) 1019 Blocks++; 1020 else if (rv > 0) | 1027 if (rv == Bufsize) 1028 Blocks++; 1029 else if (rv > 0) |
1021 SBlocks += (u_longlong_t)rv; | 1030 SBlocks += (ulong_t)rv; |
1022 } 1023 rstbuf(); 1024} 1025 1026/* 1027 * chgreel: Determine if end-of-medium has been reached. If it has, 1028 * close the current medium and prompt the user for the next medium. 1029 */ --- 410 unchanged lines hidden (view full) --- 1440 * (TARTYP (TAR and USTAR)). For -o and the CRC header, the file is opened and 1441 * the checksum is calculated. For -i and the CRC header, the checksum 1442 * is calculated as each block is transferred from the archive I/O buffer 1443 * to the file system I/O buffer. The TARTYP (TAR and USTAR) headers calculate 1444 * the simple checksum of the header (with the checksum field of the 1445 * header initialized to all spaces (\040). 1446 */ 1447 | 1031 } 1032 rstbuf(); 1033} 1034 1035/* 1036 * chgreel: Determine if end-of-medium has been reached. If it has, 1037 * close the current medium and prompt the user for the next medium. 1038 */ --- 410 unchanged lines hidden (view full) --- 1449 * (TARTYP (TAR and USTAR)). For -o and the CRC header, the file is opened and 1450 * the checksum is calculated. For -i and the CRC header, the checksum 1451 * is calculated as each block is transferred from the archive I/O buffer 1452 * to the file system I/O buffer. The TARTYP (TAR and USTAR) headers calculate 1453 * the simple checksum of the header (with the checksum field of the 1454 * header initialized to all spaces (\040). 1455 */ 1456 |
1448static long | 1457static uint_t |
1449cksum(char hdr, int byt_cnt, int *err) 1450{ 1451 char *crc_p, *end_p; 1452 int cnt; | 1458cksum(char hdr, int byt_cnt, int *err) 1459{ 1460 char *crc_p, *end_p; 1461 int cnt; |
1453 long checksum = 0L, have; | 1462 uint_t checksum = 0, have; |
1454 off_t lcnt; 1455 1456 if (err != NULL) 1457 *err = 0; 1458 switch (hdr) { 1459 case CRC: 1460 if (Args & OCi) { /* do running checksum */ 1461 end_p = Buffr.b_out_p + byt_cnt; 1462 for (crc_p = Buffr.b_out_p; crc_p < end_p; crc_p++) | 1463 off_t lcnt; 1464 1465 if (err != NULL) 1466 *err = 0; 1467 switch (hdr) { 1468 case CRC: 1469 if (Args & OCi) { /* do running checksum */ 1470 end_p = Buffr.b_out_p + byt_cnt; 1471 for (crc_p = Buffr.b_out_p; crc_p < end_p; crc_p++) |
1463 checksum += (long)*crc_p; | 1472 checksum += (uint_t)*crc_p; |
1464 break; 1465 } 1466 /* OCo - do checksum of file */ 1467 lcnt = G_p->g_filesz; 1468 1469 while (lcnt > 0) { 1470 have = (lcnt < Bufsize) ? lcnt : Bufsize; 1471 errno = 0; --- 129 unchanged lines hidden (view full) --- 1601 (void) strcpy(Gen.g_tname, namebuff); 1602 1603 Gen.g_prefix = e_zalloc(E_EXIT, presize + 1); 1604 (void) strcpy(Gen.g_prefix, prebuff); 1605 } else { 1606 Gen.g_tname = Gen.g_nam_p; 1607 } 1608 (void) strcpy(Gen.g_tmagic, "ustar"); | 1473 break; 1474 } 1475 /* OCo - do checksum of file */ 1476 lcnt = G_p->g_filesz; 1477 1478 while (lcnt > 0) { 1479 have = (lcnt < Bufsize) ? lcnt : Bufsize; 1480 errno = 0; --- 129 unchanged lines hidden (view full) --- 1610 (void) strcpy(Gen.g_tname, namebuff); 1611 1612 Gen.g_prefix = e_zalloc(E_EXIT, presize + 1); 1613 (void) strcpy(Gen.g_prefix, prebuff); 1614 } else { 1615 Gen.g_tname = Gen.g_nam_p; 1616 } 1617 (void) strcpy(Gen.g_tmagic, "ustar"); |
1609 (void) strcpy(Gen.g_version, "00"); | 1618 (void) memcpy(Gen.g_version, "00", 2); |
1610 1611 dpasswd = getpwuid(SrcSt.st_uid); 1612 if (dpasswd == NULL) { 1613 msg(EPOST, 1614 "cpio: could not get passwd information " 1615 "for %s%s%s", 1616 (Gen.g_attrnam_p == NULL) ? 1617 Gen.g_nam_p : Gen.g_attrfnam_p, --- 63 unchanged lines hidden (view full) --- 1681 Gen.g_dev = SrcSt.st_dev; 1682 1683 if (Use_old_stat) { 1684 /* -Hodc */ 1685 1686 sl_info_t *p = sl_search(dev, ino, ftype); 1687 Gen.g_ino = p ? p->sl_ino2 : -1; 1688 | 1619 1620 dpasswd = getpwuid(SrcSt.st_uid); 1621 if (dpasswd == NULL) { 1622 msg(EPOST, 1623 "cpio: could not get passwd information " 1624 "for %s%s%s", 1625 (Gen.g_attrnam_p == NULL) ? 1626 Gen.g_nam_p : Gen.g_attrfnam_p, --- 63 unchanged lines hidden (view full) --- 1690 Gen.g_dev = SrcSt.st_dev; 1691 1692 if (Use_old_stat) { 1693 /* -Hodc */ 1694 1695 sl_info_t *p = sl_search(dev, ino, ftype); 1696 Gen.g_ino = p ? p->sl_ino2 : -1; 1697 |
1689 if (Gen.g_ino == (ulong_t)-1) { | 1698 if (Gen.g_ino == UINT_MAX) { |
1690 msg(ERR, "%s%s%s: cannot be archived - inode too big " 1691 "for -Hodc format", 1692 (Gen.g_attrnam_p == NULL) ? 1693 Gen.g_nam_p : Gen.g_attrfnam_p, 1694 (Gen.g_attrnam_p == NULL) ? "" : Gen.g_rw_sysattr ? 1695 gettext(" System Attribute ") : 1696 gettext(" Attribute "), 1697 (Gen.g_attrnam_p == NULL) ? "" : Gen.g_attrnam_p); --- 275 unchanged lines hidden (view full) --- 1973 result = mkdir(nam_p, G_p->g_mode); 1974 } else if (ustar_spec() || Aspec) { 1975 /* 1976 * The archive file is block special, 1977 * char special, socket, or a fifo. 1978 * Note that, for a socket, the third 1979 * parameter to mknod() is ignored. 1980 */ | 1699 msg(ERR, "%s%s%s: cannot be archived - inode too big " 1700 "for -Hodc format", 1701 (Gen.g_attrnam_p == NULL) ? 1702 Gen.g_nam_p : Gen.g_attrfnam_p, 1703 (Gen.g_attrnam_p == NULL) ? "" : Gen.g_rw_sysattr ? 1704 gettext(" System Attribute ") : 1705 gettext(" Attribute "), 1706 (Gen.g_attrnam_p == NULL) ? "" : Gen.g_attrnam_p); --- 275 unchanged lines hidden (view full) --- 1982 result = mkdir(nam_p, G_p->g_mode); 1983 } else if (ustar_spec() || Aspec) { 1984 /* 1985 * The archive file is block special, 1986 * char special, socket, or a fifo. 1987 * Note that, for a socket, the third 1988 * parameter to mknod() is ignored. 1989 */ |
1981 | |
1982 result = mknod(nam_p, (int)G_p->g_mode, 1983 (int)G_p->g_rdev); 1984 } 1985 1986 if (result >= 0) { 1987 /* 1988 * The file creation succeeded. Take care of the ACLs. 1989 */ --- 120 unchanged lines hidden (view full) --- 2110 * in order to accommodate potential executables. 2111 * 2112 * Note: g_typeflag is only defined (set) for USTAR archive types. It 2113 * defaults to 0 in the cpio-format-regular file case, so this test 2114 * succeeds. 2115 */ 2116 2117 if (G_p->g_typeflag == 0 && | 1990 result = mknod(nam_p, (int)G_p->g_mode, 1991 (int)G_p->g_rdev); 1992 } 1993 1994 if (result >= 0) { 1995 /* 1996 * The file creation succeeded. Take care of the ACLs. 1997 */ --- 120 unchanged lines hidden (view full) --- 2118 * in order to accommodate potential executables. 2119 * 2120 * Note: g_typeflag is only defined (set) for USTAR archive types. It 2121 * defaults to 0 in the cpio-format-regular file case, so this test 2122 * succeeds. 2123 */ 2124 2125 if (G_p->g_typeflag == 0 && |
2118 (DesSt.st_mode & (ulong_t)Ftype) == S_IFREG && 2119 (G_p->g_mode & (ulong_t)Ftype) == S_IFREG) { | 2126 (DesSt.st_mode & (uint_t)Ftype) == S_IFREG && 2127 (G_p->g_mode & (uint_t)Ftype) == S_IFREG) { |
2120 /* 2121 * The archive file and the filesystem file are both regular 2122 * files. We write to the temporary file in this case. 2123 */ 2124 2125 if (Args & OCp) { 2126 if (G_p->g_attrnam_p == NULL) { 2127 Fullnam_p = Over_p; --- 201 unchanged lines hidden (view full) --- 2329 * failure, or if we just couldn't write all of the data 2330 * requested so that we know that the rest of the file's 2331 * data can be read but not written. 2332 */ 2333 if (cnt != -1) 2334 data_in_info->data_in_wr_part = 1; 2335 return (1); 2336 } else if (Args & OCp) { | 2128 /* 2129 * The archive file and the filesystem file are both regular 2130 * files. We write to the temporary file in this case. 2131 */ 2132 2133 if (Args & OCp) { 2134 if (G_p->g_attrnam_p == NULL) { 2135 Fullnam_p = Over_p; --- 201 unchanged lines hidden (view full) --- 2337 * failure, or if we just couldn't write all of the data 2338 * requested so that we know that the rest of the file's 2339 * data can be read but not written. 2340 */ 2341 if (cnt != -1) 2342 data_in_info->data_in_wr_part = 1; 2343 return (1); 2344 } else if (Args & OCp) { |
2337 Blocks += (u_longlong_t)((cnt + (Bufsize - 1)) / Bufsize); | 2345 Blocks += (ulong_t)((cnt + (Bufsize - 1)) / Bufsize); |
2338 } 2339 return (0); 2340} 2341 2342/* 2343 * Perform I/O for given byte size with using limited i/o block size 2344 * and supplied buffer. 2345 * --- 336 unchanged lines hidden (view full) --- 2682 nam_p = G_p->g_nam_p; 2683 } 2684 2685 if (((G_p->g_mode & Ftype) == S_IFLNK && proc_mode != P_SKIP) || 2686 (Hdr_type == BAR && bar_linkflag == '2' && proc_mode != P_SKIP)) { 2687 proc_mode = P_SKIP; 2688 VERBOSE((Args & (OCv | OCV)), nam_p); 2689 } | 2346 } 2347 return (0); 2348} 2349 2350/* 2351 * Perform I/O for given byte size with using limited i/o block size 2352 * and supplied buffer. 2353 * --- 336 unchanged lines hidden (view full) --- 2690 nam_p = G_p->g_nam_p; 2691 } 2692 2693 if (((G_p->g_mode & Ftype) == S_IFLNK && proc_mode != P_SKIP) || 2694 (Hdr_type == BAR && bar_linkflag == '2' && proc_mode != P_SKIP)) { 2695 proc_mode = P_SKIP; 2696 VERBOSE((Args & (OCv | OCV)), nam_p); 2697 } |
2690 if (Args & (OCb | OCs | OCS)) { /* verfify that swapping is possible */ | 2698 if (Args & (OCb | OCs | OCS)) { /* verify that swapping is possible */ |
2691 swapfile = 1; 2692 if (Args & (OCs | OCb) && G_p->g_filesz % 2) { 2693 msg(ERR, 2694 "Cannot swap bytes of \"%s\", odd number of bytes", 2695 nam_p); 2696 swapfile = 0; 2697 } 2698 if (Args & (OCS | OCb) && G_p->g_filesz % 4) { --- 161 unchanged lines hidden (view full) --- 2860 (amount_read - amt_to_read); 2861 amount_read = amt_to_read; 2862 } else if (amount_read == amt_to_read) { 2863 /* the file is the same size */ 2864 *real_filesz = file_size; 2865 } 2866 2867 Buffr.b_in_p += amount_read; | 2699 swapfile = 1; 2700 if (Args & (OCs | OCb) && G_p->g_filesz % 2) { 2701 msg(ERR, 2702 "Cannot swap bytes of \"%s\", odd number of bytes", 2703 nam_p); 2704 swapfile = 0; 2705 } 2706 if (Args & (OCS | OCb) && G_p->g_filesz % 4) { --- 161 unchanged lines hidden (view full) --- 2868 (amount_read - amt_to_read); 2869 amount_read = amt_to_read; 2870 } else if (amount_read == amt_to_read) { 2871 /* the file is the same size */ 2872 *real_filesz = file_size; 2873 } 2874 2875 Buffr.b_in_p += amount_read; |
2868 Buffr.b_cnt += (long)amount_read; | 2876 Buffr.b_cnt += amount_read; |
2869 2870 amt_to_read -= (off_t)amount_read; 2871 if (!read_exact && 2872 amt_to_read == 0 && amount_read == CPIOBSZ) { 2873 /* 2874 * If the file size is multiple of CPIOBSZ, we may 2875 * be able to read more from the file even though 2876 * amt_to_read already gets 0. --- 236 unchanged lines hidden (view full) --- 3113 * Dump extended attribute header. 3114 */ 3115 3116 if (Gen.g_attrnam_p != NULL) { 3117 write_xattr_hdr(); 3118 } 3119 3120 if (Hdr_type == CRC) { | 2877 2878 amt_to_read -= (off_t)amount_read; 2879 if (!read_exact && 2880 amt_to_read == 0 && amount_read == CPIOBSZ) { 2881 /* 2882 * If the file size is multiple of CPIOBSZ, we may 2883 * be able to read more from the file even though 2884 * amt_to_read already gets 0. --- 236 unchanged lines hidden (view full) --- 3121 * Dump extended attribute header. 3122 */ 3123 3124 if (Gen.g_attrnam_p != NULL) { 3125 write_xattr_hdr(); 3126 } 3127 3128 if (Hdr_type == CRC) { |
3121 long csum = cksum(CRC, 0, &errret); | 3129 uint_t csum = cksum(CRC, 0, &errret); |
3122 if (errret != 0) { | 3130 if (errret != 0) { |
3123 G_p->g_cksum = (ulong_t)-1; | 3131 G_p->g_cksum = UINT_MAX; |
3124 msg(POST, "\"%s%s%s\" skipped", 3125 (Gen.g_attrnam_p == NULL) ? 3126 nam_p : Gen.g_attrfnam_p, 3127 (Gen.g_attrnam_p == NULL) ? "" : Gen.g_rw_sysattr ? 3128 gettext(" System Attribute ") : 3129 gettext(" Attribute "), 3130 (Gen.g_attrnam_p == NULL) ? "" : nam_p); 3131 if (holes != NULL) --- 697 unchanged lines hidden (view full) --- 3829 _PC_SATTR_EXISTS : _PC_SATTR_ENABLED) != 1) { 3830 return (ATTR_SATTR_ERR); 3831 } 3832#endif /* _PC_SATTR_ENABLED */ 3833 } else { 3834 return (ATTR_SKIP); 3835 } 3836 | 3132 msg(POST, "\"%s%s%s\" skipped", 3133 (Gen.g_attrnam_p == NULL) ? 3134 nam_p : Gen.g_attrfnam_p, 3135 (Gen.g_attrnam_p == NULL) ? "" : Gen.g_rw_sysattr ? 3136 gettext(" System Attribute ") : 3137 gettext(" Attribute "), 3138 (Gen.g_attrnam_p == NULL) ? "" : nam_p); 3139 if (holes != NULL) --- 697 unchanged lines hidden (view full) --- 3837 _PC_SATTR_EXISTS : _PC_SATTR_ENABLED) != 1) { 3838 return (ATTR_SATTR_ERR); 3839 } 3840#endif /* _PC_SATTR_ENABLED */ 3841 } else { 3842 return (ATTR_SKIP); 3843 } 3844 |
3837return (ATTR_OK); | 3845 return (ATTR_OK); |
3838} 3839#endif 3840 3841#if defined(O_XATTR) 3842/* 3843 * Verify the attribute, attrname, is an attribute we want to restore. 3844 * Never restore read-only system attribute files. Only restore read-write 3845 * system attributes files when -/ was specified, and only traverse into --- 742 unchanged lines hidden (view full) --- 4588 cksum(TARTYP, 0, NULL)) { 4589 goodhdr = 0; 4590 msg(ERR, 4591 "Bad header - checksum " 4592 "error."); 4593 } 4594 } 4595 } else if (hit != BAR) { /* binary, -c, ASC and CRC */ | 3846} 3847#endif 3848 3849#if defined(O_XATTR) 3850/* 3851 * Verify the attribute, attrname, is an attribute we want to restore. 3852 * Never restore read-only system attribute files. Only restore read-write 3853 * system attributes files when -/ was specified, and only traverse into --- 742 unchanged lines hidden (view full) --- 4596 cksum(TARTYP, 0, NULL)) { 4597 goodhdr = 0; 4598 msg(ERR, 4599 "Bad header - checksum " 4600 "error."); 4601 } 4602 } 4603 } else if (hit != BAR) { /* binary, -c, ASC and CRC */ |
4596 if (Gen.g_nlink <= (ulong_t)0) | 4604 if (Gen.g_nlink <= 0) |
4597 goodhdr = 0; 4598 if (*(Buffr.b_out_p + hsize - 1) != '\0') 4599 goodhdr = 0; 4600 } 4601 if (!goodhdr) { 4602 hit = NONE; 4603 if (!(Args & OCk)) 4604 break; --- 302 unchanged lines hidden (view full) --- 4907 4908 /* got all attributes in secp */ 4909 tp = secp; 4910 do { 4911 attr = (struct sec_attr *)tp; 4912 switch (attr->attr_type) { 4913 case UFSD_ACL: 4914 case ACE_ACL: | 4605 goodhdr = 0; 4606 if (*(Buffr.b_out_p + hsize - 1) != '\0') 4607 goodhdr = 0; 4608 } 4609 if (!goodhdr) { 4610 hit = NONE; 4611 if (!(Args & OCk)) 4612 break; --- 302 unchanged lines hidden (view full) --- 4915 4916 /* got all attributes in secp */ 4917 tp = secp; 4918 do { 4919 attr = (struct sec_attr *)tp; 4920 switch (attr->attr_type) { 4921 case UFSD_ACL: 4922 case ACE_ACL: |
4915 (void) sscanf(attr->attr_len, "%7lo", 4916 (ulong_t *)&aclcnt); | 4923 (void) sscanf(attr->attr_len, "%7o", 4924 (uint_t *)&aclcnt); |
4917 /* header is 8 */ 4918 attrsize = 8 + 4919 strlen(&attr->attr_info[0]) 4920 + 1; 4921 4922 error = 4923 acl_fromtext(&attr->attr_info[0], 4924 &aclp); --- 14 unchanged lines hidden (view full) --- 4939 bytes -= attrsize; 4940 break; 4941 4942 /* SunFed case goes here */ 4943 4944 default: 4945 msg(EXT, "unrecognized attr type"); 4946 break; | 4925 /* header is 8 */ 4926 attrsize = 8 + 4927 strlen(&attr->attr_info[0]) 4928 + 1; 4929 4930 error = 4931 acl_fromtext(&attr->attr_info[0], 4932 &aclp); --- 14 unchanged lines hidden (view full) --- 4947 bytes -= attrsize; 4948 break; 4949 4950 /* SunFed case goes here */ 4951 4952 default: 4953 msg(EXT, "unrecognized attr type"); 4954 break; |
4947 } 4948 /* next attributes */ 4949 tp += attrsize; | 4955 } 4956 /* next attributes */ 4957 tp += attrsize; |
4950 } while (bytes > 0); 4951 free(secp); 4952 } else { 4953 /* skip security info */ 4954 G_p = &Gen; 4955 data_in(P_SKIP); 4956 } 4957 /* --- 455 unchanged lines hidden (view full) --- 5413 * mkshort: Convert a long into 2 shorts, for VAX, Interdata ... 5414 */ 5415 5416static void 5417mkshort(short sval[], long v) 5418{ 5419 union swpbuf *swp_p, swp_b; 5420 | 4958 } while (bytes > 0); 4959 free(secp); 4960 } else { 4961 /* skip security info */ 4962 G_p = &Gen; 4963 data_in(P_SKIP); 4964 } 4965 /* --- 455 unchanged lines hidden (view full) --- 5421 * mkshort: Convert a long into 2 shorts, for VAX, Interdata ... 5422 */ 5423 5424static void 5425mkshort(short sval[], long v) 5426{ 5427 union swpbuf *swp_p, swp_b; 5428 |
5421 /* LINTED alignment */ | |
5422 swp_p = (union swpbuf *)sval; 5423 swp_b.s_word = 1; 5424 if (swp_b.s_byte[0]) { 5425 swp_b.s_word = v; 5426 swp_p->s_half[0] = swp_b.s_half[1]; 5427 swp_p->s_half[1] = swp_b.s_half[0]; 5428 } else { 5429 swp_b.s_word = v; --- 410 unchanged lines hidden (view full) --- 5840 Gen.g_mode = Hdr.h_mode; 5841 Gen.g_uid = Hdr.h_uid; 5842 Gen.g_gid = Hdr.h_gid; 5843 Gen.g_nlink = Hdr.h_nlink; 5844 Gen.g_mtime = mklong(Hdr.h_mtime); 5845 Gen.g_ino = Hdr.h_ino; 5846 Gen.g_dev = Hdr.h_dev; 5847 Gen.g_rdev = Hdr.h_rdev; | 5429 swp_p = (union swpbuf *)sval; 5430 swp_b.s_word = 1; 5431 if (swp_b.s_byte[0]) { 5432 swp_b.s_word = v; 5433 swp_p->s_half[0] = swp_b.s_half[1]; 5434 swp_p->s_half[1] = swp_b.s_half[0]; 5435 } else { 5436 swp_b.s_word = v; --- 410 unchanged lines hidden (view full) --- 5847 Gen.g_mode = Hdr.h_mode; 5848 Gen.g_uid = Hdr.h_uid; 5849 Gen.g_gid = Hdr.h_gid; 5850 Gen.g_nlink = Hdr.h_nlink; 5851 Gen.g_mtime = mklong(Hdr.h_mtime); 5852 Gen.g_ino = Hdr.h_ino; 5853 Gen.g_dev = Hdr.h_dev; 5854 Gen.g_rdev = Hdr.h_rdev; |
5855 maj = SVR3_MAJOR(Gen.g_dev); 5856 rmaj = SVR3_MAJOR(Gen.g_rdev); 5857 min = SVR3_MINOR(Gen.g_dev); 5858 rmin = SVR3_MINOR(Gen.g_rdev); 5859 Gen.g_dev = makedev(maj, min); 5860 Gen.g_rdev = makedev(rmaj, rmin); |
|
5848 Gen.g_cksum = 0L; 5849 Gen.g_filesz = (off_t)mklong(Hdr.h_filesize); 5850 Gen.g_namesz = Hdr.h_namesize; 5851 rv = BIN; 5852 break; 5853 case CHR: 5854 if (sscanf(Buffr.b_out_p, | 5861 Gen.g_cksum = 0L; 5862 Gen.g_filesz = (off_t)mklong(Hdr.h_filesize); 5863 Gen.g_namesz = Hdr.h_namesize; 5864 rv = BIN; 5865 break; 5866 case CHR: 5867 if (sscanf(Buffr.b_out_p, |
5855 "%6lo%6lo%6lo%6lo%6lo%6lo%6lo%6lo%11lo%6o%11llo", | 5868 "%6o%6o%6o%6o" 5869 "%6" _SCNoID "%6" _SCNoID 5870 "%6o%6o%11o%6o%11lo", |
5856 &Gen.g_magic, &Gen.g_dev, &Gen.g_ino, &Gen.g_mode, | 5871 &Gen.g_magic, &Gen.g_dev, &Gen.g_ino, &Gen.g_mode, |
5857 &Gen.g_uid, &Gen.g_gid, &Gen.g_nlink, &Gen.g_rdev, 5858 (ulong_t *)&Gen.g_mtime, (uint_t *)&Gen.g_namesz, | 5872 &Gen.g_uid, &Gen.g_gid, 5873 &Gen.g_nlink, &Gen.g_rdev, 5874 (uint_t *)&Gen.g_mtime, (uint_t *)&Gen.g_namesz, |
5859 (u_off_t *)&Gen.g_filesz) == CHR_CNT) { 5860 rv = CHR; | 5875 (u_off_t *)&Gen.g_filesz) == CHR_CNT) { 5876 rv = CHR; |
5861#define cpioMAJOR(x) (int)(((unsigned)x >> 8) & 0x7F) 5862#define cpioMINOR(x) (int)(x & 0xFF) 5863 maj = cpioMAJOR(Gen.g_dev); 5864 rmaj = cpioMAJOR(Gen.g_rdev); 5865 min = cpioMINOR(Gen.g_dev); 5866 rmin = cpioMINOR(Gen.g_rdev); 5867 if (Use_old_stat) { 5868 /* needs error checking */ 5869 Gen.g_dev = (maj << 8) | min; 5870 Gen.g_rdev = (rmaj << 8) | rmin; 5871 } else { 5872 Gen.g_dev = makedev(maj, min); 5873 Gen.g_rdev = makedev(rmaj, rmin); 5874 } | 5877 maj = SVR3_MAJOR(Gen.g_dev); 5878 rmaj = SVR3_MAJOR(Gen.g_rdev); 5879 min = SVR3_MINOR(Gen.g_dev); 5880 rmin = SVR3_MINOR(Gen.g_rdev); 5881 Gen.g_dev = makedev(maj, min); 5882 Gen.g_rdev = makedev(rmaj, rmin); |
5875 } 5876 break; 5877 case ASC: 5878 case CRC: 5879 if (sscanf(Buffr.b_out_p, | 5883 } 5884 break; 5885 case ASC: 5886 case CRC: 5887 if (sscanf(Buffr.b_out_p, |
5880 "%6lx%8lx%8lx%8lx%8lx%8lx%8lx%8llx%8x%8x%8x%8x%8x%8lx", 5881 &Gen.g_magic, &Gen.g_ino, &Gen.g_mode, &Gen.g_uid, 5882 &Gen.g_gid, &Gen.g_nlink, &Gen.g_mtime, | 5888 "%6x%8x%8x" 5889 "%8" _SCNxID "%8" _SCNxID 5890 "%8x%8x%8lx%8x%8x%8x%8x%8x%8x", 5891 &Gen.g_magic, &Gen.g_ino, &Gen.g_mode, 5892 &Gen.g_uid, &Gen.g_gid, 5893 &Gen.g_nlink, &Gen.g_mtime, |
5883 (u_off_t *)&Gen.g_filesz, (uint_t *)&maj, (uint_t *)&min, 5884 (uint_t *)&rmaj, (uint_t *)&rmin, (uint_t *)&Gen.g_namesz, 5885 &Gen.g_cksum) == ASC_CNT) { 5886 Gen.g_dev = makedev(maj, min); 5887 Gen.g_rdev = makedev(rmaj, rmin); 5888 rv = hdr; 5889 } 5890 break; 5891 case USTAR: /* TAR and USTAR */ 5892 if (*Buffr.b_out_p == '\0') { 5893 *Gen.g_nam_p = '\0'; 5894 nambuf[0] = '\0'; 5895 } else { 5896 Thdr_p = (union tblock *)Buffr.b_out_p; 5897 Gen.g_nam_p[0] = '\0'; 5898 (void) strncpy((char *)&nambuf, 5899 Thdr_p->tbuf.t_name, NAMSIZ); | 5894 (u_off_t *)&Gen.g_filesz, (uint_t *)&maj, (uint_t *)&min, 5895 (uint_t *)&rmaj, (uint_t *)&rmin, (uint_t *)&Gen.g_namesz, 5896 &Gen.g_cksum) == ASC_CNT) { 5897 Gen.g_dev = makedev(maj, min); 5898 Gen.g_rdev = makedev(rmaj, rmin); 5899 rv = hdr; 5900 } 5901 break; 5902 case USTAR: /* TAR and USTAR */ 5903 if (*Buffr.b_out_p == '\0') { 5904 *Gen.g_nam_p = '\0'; 5905 nambuf[0] = '\0'; 5906 } else { 5907 Thdr_p = (union tblock *)Buffr.b_out_p; 5908 Gen.g_nam_p[0] = '\0'; 5909 (void) strncpy((char *)&nambuf, 5910 Thdr_p->tbuf.t_name, NAMSIZ); |
5900 (void) sscanf(Thdr_p->tbuf.t_mode, "%8lo", | 5911 (void) sscanf(Thdr_p->tbuf.t_mode, "%8o", |
5901 &Gen.g_mode); | 5912 &Gen.g_mode); |
5902 (void) sscanf(Thdr_p->tbuf.t_uid, "%8lo", &Gen.g_uid); 5903 (void) sscanf(Thdr_p->tbuf.t_gid, "%8lo", &Gen.g_gid); 5904 (void) sscanf(Thdr_p->tbuf.t_size, "%11llo", | 5913 (void) sscanf(Thdr_p->tbuf.t_uid, "%8" _SCNoID, 5914 &Gen.g_uid); 5915 (void) sscanf(Thdr_p->tbuf.t_gid, "%8" _SCNoID, 5916 &Gen.g_gid); 5917 (void) sscanf(Thdr_p->tbuf.t_size, "%12lo", |
5905 (u_off_t *)&Gen.g_filesz); | 5918 (u_off_t *)&Gen.g_filesz); |
5906 (void) sscanf(Thdr_p->tbuf.t_mtime, "%12lo", 5907 (ulong_t *)&Gen.g_mtime); 5908 (void) sscanf(Thdr_p->tbuf.t_cksum, "%8lo", 5909 (ulong_t *)&Gen.g_cksum); | 5919 (void) sscanf(Thdr_p->tbuf.t_mtime, "%12o", 5920 (uint_t *)&Gen.g_mtime); 5921 (void) sscanf(Thdr_p->tbuf.t_cksum, "%8o", 5922 (uint_t *)&Gen.g_cksum); |
5910 if (Thdr_p->tbuf.t_linkname[0] != '\0') 5911 Gen.g_nlink = 1; 5912 else 5913 Gen.g_nlink = 0; 5914 5915 switch (Thdr_p->tbuf.t_typeflag) { 5916 case SYMTYPE: 5917 /* Symbolic Link */ --- 8 unchanged lines hidden (view full) --- 5926 case DIRTYPE: 5927 Gen.g_mode |= (S_IFMT & S_IFDIR); 5928 break; 5929 case FIFOTYPE: 5930 Gen.g_mode |= (S_IFMT & S_IFIFO); 5931 break; 5932 } 5933 | 5923 if (Thdr_p->tbuf.t_linkname[0] != '\0') 5924 Gen.g_nlink = 1; 5925 else 5926 Gen.g_nlink = 0; 5927 5928 switch (Thdr_p->tbuf.t_typeflag) { 5929 case SYMTYPE: 5930 /* Symbolic Link */ --- 8 unchanged lines hidden (view full) --- 5939 case DIRTYPE: 5940 Gen.g_mode |= (S_IFMT & S_IFDIR); 5941 break; 5942 case FIFOTYPE: 5943 Gen.g_mode |= (S_IFMT & S_IFIFO); 5944 break; 5945 } 5946 |
5934 (void) sscanf(Thdr_p->tbuf.t_magic, "%8lo", 5935 /* LINTED alignment */ 5936 (ulong_t *)&Gen.g_tmagic); 5937 (void) sscanf(Thdr_p->tbuf.t_version, "%8lo", 5938 /* LINTED alignment */ 5939 (ulong_t *)&Gen.g_version); | 5947 (void) sscanf(Thdr_p->tbuf.t_magic, "%6o", 5948 (uint_t *)&Gen.g_tmagic); 5949 (void) sscanf(Thdr_p->tbuf.t_version, "%2o", 5950 (uint_t *)&Gen.g_version); |
5940 (void) sscanf(Thdr_p->tbuf.t_uname, "%32s", 5941 (char *)&Gen.g_uname); 5942 (void) sscanf(Thdr_p->tbuf.t_gname, "%32s", 5943 (char *)&Gen.g_gname); | 5951 (void) sscanf(Thdr_p->tbuf.t_uname, "%32s", 5952 (char *)&Gen.g_uname); 5953 (void) sscanf(Thdr_p->tbuf.t_gname, "%32s", 5954 (char *)&Gen.g_gname); |
5944 (void) sscanf(Thdr_p->tbuf.t_devmajor, "%8lo", 5945 &Gen.g_dev); 5946 (void) sscanf(Thdr_p->tbuf.t_devminor, "%8lo", 5947 &Gen.g_rdev); | 5955 (void) sscanf(Thdr_p->tbuf.t_devmajor, "%8o", &maj); 5956 (void) sscanf(Thdr_p->tbuf.t_devminor, "%8o", &min); |
5948 (void) strncpy((char *)&prebuf, 5949 Thdr_p->tbuf.t_prefix, PRESIZ); 5950 Gen.g_namesz = strlen(Gen.g_nam_p) + 1; | 5957 (void) strncpy((char *)&prebuf, 5958 Thdr_p->tbuf.t_prefix, PRESIZ); 5959 Gen.g_namesz = strlen(Gen.g_nam_p) + 1; |
5951 Gen.g_dev = makedev(maj, min); | 5960 Gen.g_rdev = makedev(maj, min); |
5952 } 5953 rv = USTAR; 5954 break; 5955 case TAR: 5956 if (*Buffr.b_out_p == '\0') { 5957 *Gen.g_nam_p = '\0'; 5958 nambuf[0] = '\0'; 5959 } else { 5960 Thdr_p = (union tblock *)Buffr.b_out_p; 5961 Gen.g_nam_p[0] = '\0'; | 5961 } 5962 rv = USTAR; 5963 break; 5964 case TAR: 5965 if (*Buffr.b_out_p == '\0') { 5966 *Gen.g_nam_p = '\0'; 5967 nambuf[0] = '\0'; 5968 } else { 5969 Thdr_p = (union tblock *)Buffr.b_out_p; 5970 Gen.g_nam_p[0] = '\0'; |
5962 (void) sscanf(Thdr_p->tbuf.t_mode, "%lo", &Gen.g_mode); 5963 (void) sscanf(Thdr_p->tbuf.t_uid, "%lo", &Gen.g_uid); 5964 (void) sscanf(Thdr_p->tbuf.t_gid, "%lo", &Gen.g_gid); 5965 (void) sscanf(Thdr_p->tbuf.t_size, "%llo", | 5971 (void) sscanf(Thdr_p->tbuf.t_mode, "%8o", &Gen.g_mode); 5972 (void) sscanf(Thdr_p->tbuf.t_uid, "%8" _SCNoID, 5973 &Gen.g_uid); 5974 (void) sscanf(Thdr_p->tbuf.t_gid, "%8" _SCNoID, 5975 &Gen.g_gid); 5976 (void) sscanf(Thdr_p->tbuf.t_size, "%12" SCNo64, |
5966 (u_off_t *)&Gen.g_filesz); | 5977 (u_off_t *)&Gen.g_filesz); |
5967 (void) sscanf(Thdr_p->tbuf.t_mtime, "%lo", | 5978 (void) sscanf(Thdr_p->tbuf.t_mtime, "%12o", |
5968 &Gen.g_mtime); | 5979 &Gen.g_mtime); |
5969 (void) sscanf(Thdr_p->tbuf.t_cksum, "%lo", | 5980 (void) sscanf(Thdr_p->tbuf.t_cksum, "%8o", |
5970 &Gen.g_cksum); 5971 if (Thdr_p->tbuf.t_typeflag == '1') /* hardlink */ 5972 Gen.g_nlink = 1; 5973 else 5974 Gen.g_nlink = 0; 5975 (void) strncpy(Gen.g_nam_p, 5976 Thdr_p->tbuf.t_name, NAMSIZ); 5977 Gen.g_namesz = strlen(Gen.g_nam_p) + 1; 5978 (void) strcpy(nambuf, Gen.g_nam_p); 5979 } 5980 rv = TAR; 5981 break; 5982 case BAR: 5983 if (Bar_vol_num == 0 && bar_read_cnt == 0) { 5984 read_bar_vol_hdr(); 5985 bar_read_cnt++; | 5981 &Gen.g_cksum); 5982 if (Thdr_p->tbuf.t_typeflag == '1') /* hardlink */ 5983 Gen.g_nlink = 1; 5984 else 5985 Gen.g_nlink = 0; 5986 (void) strncpy(Gen.g_nam_p, 5987 Thdr_p->tbuf.t_name, NAMSIZ); 5988 Gen.g_namesz = strlen(Gen.g_nam_p) + 1; 5989 (void) strcpy(nambuf, Gen.g_nam_p); 5990 } 5991 rv = TAR; 5992 break; 5993 case BAR: 5994 if (Bar_vol_num == 0 && bar_read_cnt == 0) { 5995 read_bar_vol_hdr(); 5996 bar_read_cnt++; |
5986 } 5987 else | 5997 } else { |
5988 read_bar_file_hdr(); | 5998 read_bar_file_hdr(); |
5999 } |
|
5989 rv = BAR; 5990 break; 5991 default: 5992 msg(EXT, "Impossible header type."); 5993 } 5994 5995 if (hdr != BAR) { 5996 if (Buffr.b_end_p != (Buffr.b_out_p + Hdrsz)) --- 102 unchanged lines hidden (view full) --- 6099 6100 if (Args & OCp) { 6101 if (G_p->g_attrnam_p == NULL) { 6102 nam_p = Fullnam_p; 6103 } else { 6104 nam_p = G_p->g_attrnam_p; 6105 } 6106 } else { | 6000 rv = BAR; 6001 break; 6002 default: 6003 msg(EXT, "Impossible header type."); 6004 } 6005 6006 if (hdr != BAR) { 6007 if (Buffr.b_end_p != (Buffr.b_out_p + Hdrsz)) --- 102 unchanged lines hidden (view full) --- 6110 6111 if (Args & OCp) { 6112 if (G_p->g_attrnam_p == NULL) { 6113 nam_p = Fullnam_p; 6114 } else { 6115 nam_p = G_p->g_attrnam_p; 6116 } 6117 } else { |
6107 if (Gen.g_nlink > (ulong_t)0) { | 6118 if (Gen.g_nlink > 0) { |
6108 nam_p = G_p->g_nam_p; 6109 } else { 6110 nam_p = Gen.g_nam_p; 6111 } 6112 } 6113 if (Gen.g_attrnam_p != NULL) { 6114 nam_p = Gen.g_attrnam_p; 6115 } --- 207 unchanged lines hidden (view full) --- 6323 } 6324 6325 if (!(Args & OCi) && (Args & OCa)) { 6326 /* 6327 * Use dirfd since we are updating original file 6328 * and not just created file 6329 */ 6330 set_tym(G_p->g_dirfd, get_component(inam_p), | 6119 nam_p = G_p->g_nam_p; 6120 } else { 6121 nam_p = Gen.g_nam_p; 6122 } 6123 } 6124 if (Gen.g_attrnam_p != NULL) { 6125 nam_p = Gen.g_attrnam_p; 6126 } --- 207 unchanged lines hidden (view full) --- 6334 } 6335 6336 if (!(Args & OCi) && (Args & OCa)) { 6337 /* 6338 * Use dirfd since we are updating original file 6339 * and not just created file 6340 */ 6341 set_tym(G_p->g_dirfd, get_component(inam_p), |
6331 (ulong_t)SrcSt.st_atime, (ulong_t)SrcSt.st_mtime); | 6342 (uint_t)SrcSt.st_atime, (uint_t)SrcSt.st_mtime); |
6332 } 6333} 6334 6335/* 6336 * scan4trail: Scan the archive looking for the trailer. 6337 * When found, back the archive up over the trailer and overwrite 6338 * the trailer with the files to be added to the archive. 6339 */ --- 486 unchanged lines hidden (view full) --- 6826 int tcnt; 6827 int rcnt; 6828 ushort_t thalf; 6829 6830 rcnt = cnt % 4; 6831 cnt /= 4; 6832 if (Args & (OCb | OCs | BSM)) { 6833 tcnt = cnt; | 6343 } 6344} 6345 6346/* 6347 * scan4trail: Scan the archive looking for the trailer. 6348 * When found, back the archive up over the trailer and overwrite 6349 * the trailer with the files to be added to the archive. 6350 */ --- 486 unchanged lines hidden (view full) --- 6837 int tcnt; 6838 int rcnt; 6839 ushort_t thalf; 6840 6841 rcnt = cnt % 4; 6842 cnt /= 4; 6843 if (Args & (OCb | OCs | BSM)) { 6844 tcnt = cnt; |
6834 /* LINTED alignment */ | |
6835 Swp_p = (union swpbuf *)buf_p; 6836 while (tcnt-- > 0) { 6837 tbyte = Swp_p->s_byte[0]; 6838 Swp_p->s_byte[0] = Swp_p->s_byte[1]; 6839 Swp_p->s_byte[1] = tbyte; 6840 tbyte = Swp_p->s_byte[2]; 6841 Swp_p->s_byte[2] = Swp_p->s_byte[3]; 6842 Swp_p->s_byte[3] = tbyte; 6843 Swp_p++; 6844 } 6845 if (rcnt >= 2) { 6846 tbyte = Swp_p->s_byte[0]; 6847 Swp_p->s_byte[0] = Swp_p->s_byte[1]; 6848 Swp_p->s_byte[1] = tbyte; 6849 tbyte = Swp_p->s_byte[2]; 6850 } 6851 } 6852 if (Args & (OCb | OCS)) { 6853 tcnt = cnt; | 6845 Swp_p = (union swpbuf *)buf_p; 6846 while (tcnt-- > 0) { 6847 tbyte = Swp_p->s_byte[0]; 6848 Swp_p->s_byte[0] = Swp_p->s_byte[1]; 6849 Swp_p->s_byte[1] = tbyte; 6850 tbyte = Swp_p->s_byte[2]; 6851 Swp_p->s_byte[2] = Swp_p->s_byte[3]; 6852 Swp_p->s_byte[3] = tbyte; 6853 Swp_p++; 6854 } 6855 if (rcnt >= 2) { 6856 tbyte = Swp_p->s_byte[0]; 6857 Swp_p->s_byte[0] = Swp_p->s_byte[1]; 6858 Swp_p->s_byte[1] = tbyte; 6859 tbyte = Swp_p->s_byte[2]; 6860 } 6861 } 6862 if (Args & (OCb | OCS)) { 6863 tcnt = cnt; |
6854 /* LINTED alignment */ | |
6855 Swp_p = (union swpbuf *)buf_p; 6856 while (tcnt-- > 0) { 6857 thalf = Swp_p->s_half[0]; 6858 Swp_p->s_half[0] = Swp_p->s_half[1]; 6859 Swp_p->s_half[1] = thalf; 6860 Swp_p++; 6861 } 6862 } --- 161 unchanged lines hidden (view full) --- 7024 else 7025 (void) printf("%s%4d ", modestr, (int)Gen.g_nlink); 7026 if (Lastuid == (uid_t)Gen.g_uid) { 7027 if (Lastuid == (uid_t)-1) 7028 (void) printf("-1 "); 7029 else 7030 (void) printf("%-9s", Curpw_p->pw_name); 7031 } else { | 6864 Swp_p = (union swpbuf *)buf_p; 6865 while (tcnt-- > 0) { 6866 thalf = Swp_p->s_half[0]; 6867 Swp_p->s_half[0] = Swp_p->s_half[1]; 6868 Swp_p->s_half[1] = thalf; 6869 Swp_p++; 6870 } 6871 } --- 161 unchanged lines hidden (view full) --- 7033 else 7034 (void) printf("%s%4d ", modestr, (int)Gen.g_nlink); 7035 if (Lastuid == (uid_t)Gen.g_uid) { 7036 if (Lastuid == (uid_t)-1) 7037 (void) printf("-1 "); 7038 else 7039 (void) printf("%-9s", Curpw_p->pw_name); 7040 } else { |
7032 if (Curpw_p = getpwuid((int)Gen.g_uid)) { | 7041 if ((Curpw_p = getpwuid((int)Gen.g_uid)) != NULL) { |
7033 (void) printf("%-9s", Curpw_p->pw_name); 7034 Lastuid = (uid_t)Gen.g_uid; 7035 } else { 7036 (void) printf("%-9d", (int)Gen.g_uid); 7037 Lastuid = (uid_t)-1; 7038 } 7039 } 7040 if (Lastgid == (gid_t)Gen.g_gid) { 7041 if (Lastgid == (gid_t)-1) 7042 (void) printf("-1 "); 7043 else 7044 (void) printf("%-9s", Curgr_p->gr_name); 7045 } else { | 7042 (void) printf("%-9s", Curpw_p->pw_name); 7043 Lastuid = (uid_t)Gen.g_uid; 7044 } else { 7045 (void) printf("%-9d", (int)Gen.g_uid); 7046 Lastuid = (uid_t)-1; 7047 } 7048 } 7049 if (Lastgid == (gid_t)Gen.g_gid) { 7050 if (Lastgid == (gid_t)-1) 7051 (void) printf("-1 "); 7052 else 7053 (void) printf("%-9s", Curgr_p->gr_name); 7054 } else { |
7046 if (Curgr_p = getgrgid((int)Gen.g_gid)) { | 7055 if ((Curgr_p = getgrgid((int)Gen.g_gid)) != NULL) { |
7047 (void) printf("%-9s", Curgr_p->gr_name); 7048 Lastgid = (gid_t)Gen.g_gid; 7049 } else { 7050 (void) printf("%-9d", (int)Gen.g_gid); 7051 Lastgid = (gid_t)-1; 7052 } 7053 } 7054 7055 /* print file size */ 7056 if (!Aspec || ((Gen.g_mode & Ftype) == S_IFIFO) || 7057 ((Gen.g_mode & Ftype) == S_IFSOCK) || 7058 (Hdr_type == BAR && bar_linkflag == SYMTYPE)) { 7059 off_t filesz = Gen.g_filesz; 7060 7061 if (S_ISSPARSE(Gen.g_mode) && Gen.g_holes != NULL) 7062 filesz = Gen.g_holes->orig_size; 7063 | 7056 (void) printf("%-9s", Curgr_p->gr_name); 7057 Lastgid = (gid_t)Gen.g_gid; 7058 } else { 7059 (void) printf("%-9d", (int)Gen.g_gid); 7060 Lastgid = (gid_t)-1; 7061 } 7062 } 7063 7064 /* print file size */ 7065 if (!Aspec || ((Gen.g_mode & Ftype) == S_IFIFO) || 7066 ((Gen.g_mode & Ftype) == S_IFSOCK) || 7067 (Hdr_type == BAR && bar_linkflag == SYMTYPE)) { 7068 off_t filesz = Gen.g_filesz; 7069 7070 if (S_ISSPARSE(Gen.g_mode) && Gen.g_holes != NULL) 7071 filesz = Gen.g_holes->orig_size; 7072 |
7064 if (filesz < (1LL << 31)) 7065 (void) printf("%7lld ", (offset_t)filesz); 7066 else 7067 (void) printf("%11lld ", (offset_t)filesz); 7068 } else 7069 (void) printf("%3d,%3d ", (int)major(Gen.g_rdev), 7070 (int)minor(Gen.g_rdev)); | 7073 (void) printf("%*" PRId64 " ", 7074 filesz < (1L << 31) ? 7 : 11, filesz); 7075 } else { 7076 (void) printf("%3" PRId32 ",%3" PRId32 " ", 7077 major(Gen.g_rdev), minor(Gen.g_rdev)); 7078 } |
7071 ttime = Gen.g_mtime; 7072 (void) strftime(Time, sizeof (Time), 7073 dcgettext(NULL, FORMAT, LC_TIME), localtime(&ttime)); 7074 (void) printf("%s, ", Time); 7075 str_fprintf(stdout, name_fmt, name, attribute); 7076 if ((Gen.g_mode & Ftype) == S_IFLNK) { | 7079 ttime = Gen.g_mtime; 7080 (void) strftime(Time, sizeof (Time), 7081 dcgettext(NULL, FORMAT, LC_TIME), localtime(&ttime)); 7082 (void) printf("%s, ", Time); 7083 str_fprintf(stdout, name_fmt, name, attribute); 7084 if ((Gen.g_mode & Ftype) == S_IFLNK) { |
7077 if (Hdr_type == USTAR || Hdr_type == TAR) | 7085 if (Hdr_type == USTAR || Hdr_type == TAR) { |
7078 (void) strcpy(Symlnk_p, 7079 Thdr_p->tbuf.t_linkname); | 7086 (void) strcpy(Symlnk_p, 7087 Thdr_p->tbuf.t_linkname); |
7080 else { | 7088 } else { |
7081 FILL(Gen.g_filesz); 7082 (void) strncpy(Symlnk_p, Buffr.b_out_p, 7083 Gen.g_filesz); 7084 *(Symlnk_p + Gen.g_filesz) = '\0'; 7085 } 7086 (void) printf(" -> %s", Symlnk_p); 7087 } 7088 if (Hdr_type == BAR) { --- 23 unchanged lines hidden (view full) --- 7112 if (Verbcnt++ >= 49) { /* start a new line of dots */ 7113 Verbcnt = 0; 7114 (void) fputc('\n', Out_p); 7115 } 7116 } 7117 (void) fflush(Out_p); 7118} 7119 | 7089 FILL(Gen.g_filesz); 7090 (void) strncpy(Symlnk_p, Buffr.b_out_p, 7091 Gen.g_filesz); 7092 *(Symlnk_p + Gen.g_filesz) = '\0'; 7093 } 7094 (void) printf(" -> %s", Symlnk_p); 7095 } 7096 if (Hdr_type == BAR) { --- 23 unchanged lines hidden (view full) --- 7120 if (Verbcnt++ >= 49) { /* start a new line of dots */ 7121 Verbcnt = 0; 7122 (void) fputc('\n', Out_p); 7123 } 7124 } 7125 (void) fflush(Out_p); 7126} 7127 |
7120#define MK_USHORT(a) (a & 00000177777) 7121 | |
7122/* 7123 * write_hdr: Transfer header information for the generic structure 7124 * into the format for the selected header and bwrite() the header. 7125 */ 7126 7127static void 7128write_hdr(int arcflag, off_t len) 7129{ 7130 int cnt = 0, pad; 7131 mode_t mode = 0; | 7128/* 7129 * write_hdr: Transfer header information for the generic structure 7130 * into the format for the selected header and bwrite() the header. 7131 */ 7132 7133static void 7134write_hdr(int arcflag, off_t len) 7135{ 7136 int cnt = 0, pad; 7137 mode_t mode = 0; |
7138 major_t maj; 7139 minor_t min; |
|
7132 uid_t uid; 7133 gid_t gid; 7134 const char warnfmt[] = "%s%s%s : %s"; 7135 7136 switch (arcflag) { 7137 case ARCHIVE_ACL: 7138 mode = SECMODE; 7139 break; --- 30 unchanged lines hidden (view full) --- 7170 uid = G_p->g_uid; 7171 gid = G_p->g_gid; 7172 /* 7173 * Handle EFT uids and gids. If they get too big 7174 * to be represented in a particular format, force 'em to 'nobody'. 7175 */ 7176 switch (Hdr_type) { 7177 case BIN: /* 16-bits of u_short */ | 7140 uid_t uid; 7141 gid_t gid; 7142 const char warnfmt[] = "%s%s%s : %s"; 7143 7144 switch (arcflag) { 7145 case ARCHIVE_ACL: 7146 mode = SECMODE; 7147 break; --- 30 unchanged lines hidden (view full) --- 7178 uid = G_p->g_uid; 7179 gid = G_p->g_gid; 7180 /* 7181 * Handle EFT uids and gids. If they get too big 7182 * to be represented in a particular format, force 'em to 'nobody'. 7183 */ 7184 switch (Hdr_type) { 7185 case BIN: /* 16-bits of u_short */ |
7178 if ((ulong_t)uid > (ulong_t)USHRT_MAX) | 7186 if ((uint_t)uid > (uint_t)USHRT_MAX) |
7179 uid = UID_NOBODY; | 7187 uid = UID_NOBODY; |
7180 if ((ulong_t)gid > (ulong_t)USHRT_MAX) | 7188 if ((uint_t)gid > (uint_t)USHRT_MAX) |
7181 gid = GID_NOBODY; 7182 break; | 7189 gid = GID_NOBODY; 7190 break; |
7183 case CHR: /* %.6lo => 262143 base 10 */ 7184 if ((ulong_t)uid > (ulong_t)0777777) | 7191 case CHR: /* %.6o => 262143 base 10 */ 7192 if ((uint_t)uid > (uint_t)0777777) |
7185 uid = UID_NOBODY; | 7193 uid = UID_NOBODY; |
7186 if ((ulong_t)gid > (ulong_t)0777777) | 7194 if ((uint_t)gid > (uint_t)0777777) |
7187 gid = GID_NOBODY; 7188 break; | 7195 gid = GID_NOBODY; 7196 break; |
7189 case ASC: /* %.8lx => full 32 bits */ | 7197 case ASC: /* %.8x => full 32 bits */ |
7190 case CRC: 7191 break; 7192 case USTAR: | 7198 case CRC: 7199 break; 7200 case USTAR: |
7193 case TAR: /* %.7lo => 2097151 base 10 */ 7194 if ((ulong_t)uid > (ulong_t)07777777) | 7201 case TAR: /* %.7o => 2097151 base 10 */ 7202 if ((uint_t)uid > (uint_t)07777777) |
7195 uid = UID_NOBODY; | 7203 uid = UID_NOBODY; |
7196 if ((ulong_t)gid > (ulong_t)07777777) | 7204 if ((uint_t)gid > (uint_t)07777777) |
7197 gid = GID_NOBODY; 7198 break; 7199 default: 7200 msg(EXT, "Impossible header type."); 7201 } 7202 7203 /* 7204 * Since cpio formats -don't- encode the symbolic names, print --- 47 unchanged lines hidden (view full) --- 7252 case BIN: 7253 Hdr.h_magic = (short)G_p->g_magic; 7254 Hdr.h_dev = G_p->g_dev; 7255 Hdr.h_ino = G_p->g_ino; 7256 Hdr.h_uid = uid; 7257 Hdr.h_gid = gid; 7258 Hdr.h_mode = mode; 7259 Hdr.h_nlink = G_p->g_nlink; | 7205 gid = GID_NOBODY; 7206 break; 7207 default: 7208 msg(EXT, "Impossible header type."); 7209 } 7210 7211 /* 7212 * Since cpio formats -don't- encode the symbolic names, print --- 47 unchanged lines hidden (view full) --- 7260 case BIN: 7261 Hdr.h_magic = (short)G_p->g_magic; 7262 Hdr.h_dev = G_p->g_dev; 7263 Hdr.h_ino = G_p->g_ino; 7264 Hdr.h_uid = uid; 7265 Hdr.h_gid = gid; 7266 Hdr.h_mode = mode; 7267 Hdr.h_nlink = G_p->g_nlink; |
7260 Hdr.h_rdev = G_p->g_rdev; | 7268 maj = major(G_p->g_rdev); 7269 min = minor(G_p->g_rdev); 7270 if (maj > (uint_t)OMAXMAJ) 7271 maj = 0; 7272 if (min > (uint_t)OMAXMIN) 7273 min = 0; 7274 Hdr.h_rdev = TO_SVR3(maj, min); |
7261 mkshort(Hdr.h_mtime, (long)G_p->g_mtime); 7262 Hdr.h_namesize = (short)G_p->g_namesz; 7263 mkshort(Hdr.h_filesize, (long)len); 7264 (void) strcpy(Hdr.h_name, G_p->g_nam_p); 7265 (void) memcpy(Buffr.b_in_p, &Hdr, cnt); 7266 break; 7267 case CHR: | 7275 mkshort(Hdr.h_mtime, (long)G_p->g_mtime); 7276 Hdr.h_namesize = (short)G_p->g_namesz; 7277 mkshort(Hdr.h_filesize, (long)len); 7278 (void) strcpy(Hdr.h_name, G_p->g_nam_p); 7279 (void) memcpy(Buffr.b_in_p, &Hdr, cnt); 7280 break; 7281 case CHR: |
7268 /*LINTED*/ | |
7269 (void) sprintf(Buffr.b_in_p, | 7282 (void) sprintf(Buffr.b_in_p, |
7270 "%.6lo%.6lo%.6lo%.6lo%.6lo%.6lo%.6lo%.6lo%.11lo%.6lo%." 7271 "11llo%s", G_p->g_magic, G_p->g_dev, G_p->g_ino, mode, 7272 (long)uid, (long)gid, G_p->g_nlink, MK_USHORT(G_p->g_rdev), 7273 G_p->g_mtime, (long)G_p->g_namesz, (offset_t)len, | 7283 "%.6o%.6o%.6o%.6o" 7284 "%.6" _PRIoID "%.6" _PRIoID "%.6o" 7285 "%.6" PRIo16 7286 "%.11o%.6o%.11" PRIo64 7287 "%s", 7288 G_p->g_magic, G_p->g_dev, G_p->g_ino, mode, 7289 uid, gid, G_p->g_nlink, 7290 (unsigned short)(G_p->g_rdev & 0xffff), 7291 G_p->g_mtime, G_p->g_namesz, len, |
7274 G_p->g_nam_p); 7275 break; 7276 case ASC: 7277 case CRC: | 7292 G_p->g_nam_p); 7293 break; 7294 case ASC: 7295 case CRC: |
7278 /*LINTED*/ | |
7279 (void) sprintf(Buffr.b_in_p, | 7296 (void) sprintf(Buffr.b_in_p, |
7280 "%.6lx%.8lx%.8lx%.8lx%.8lx%.8lx%.8lx%.8lx%.8lx%.8lx%." 7281 "8lx%.8lx%.8lx%.8lx%s", 7282 G_p->g_magic, G_p->g_ino, mode, G_p->g_uid, 7283 G_p->g_gid, G_p->g_nlink, G_p->g_mtime, (ulong_t)len, | 7297 "%.6x%.8x%.8x" 7298 "%.8" _PRIxID "%.8" _PRIxID 7299 "%.8x%.8x%.8x" 7300 "%.8" PRIx32 "%.8" PRIx32 "%.8" PRIx32 "%.8" PRIx32 7301 "%.8x%.8x%s", 7302 G_p->g_magic, G_p->g_ino, mode, 7303 G_p->g_uid, G_p->g_gid, 7304 G_p->g_nlink, G_p->g_mtime, (uint_t)len, |
7284 major(G_p->g_dev), minor(G_p->g_dev), 7285 major(G_p->g_rdev), minor(G_p->g_rdev), 7286 G_p->g_namesz, G_p->g_cksum, G_p->g_nam_p); 7287 break; 7288 case USTAR: 7289 Thdr_p = (union tblock *)Buffr.b_in_p; 7290 (void) memset(Thdr_p, 0, TARSZ); 7291 (void) strncpy(Thdr_p->tbuf.t_name, G_p->g_tname, | 7305 major(G_p->g_dev), minor(G_p->g_dev), 7306 major(G_p->g_rdev), minor(G_p->g_rdev), 7307 G_p->g_namesz, G_p->g_cksum, G_p->g_nam_p); 7308 break; 7309 case USTAR: 7310 Thdr_p = (union tblock *)Buffr.b_in_p; 7311 (void) memset(Thdr_p, 0, TARSZ); 7312 (void) strncpy(Thdr_p->tbuf.t_name, G_p->g_tname, |
7292 (int)strlen(G_p->g_tname)); 7293 (void) sprintf(Thdr_p->tbuf.t_mode, "%07o", (int)mode); 7294 (void) sprintf(Thdr_p->tbuf.t_uid, "%07o", (int)uid); 7295 (void) sprintf(Thdr_p->tbuf.t_gid, "%07o", (int)gid); 7296 (void) sprintf(Thdr_p->tbuf.t_size, "%011llo", 7297 (offset_t)len); 7298 (void) sprintf(Thdr_p->tbuf.t_mtime, "%011lo", G_p->g_mtime); | 7313 strlen(G_p->g_tname)); 7314 (void) sprintf(Thdr_p->tbuf.t_mode, "%07o", mode); 7315 (void) sprintf(Thdr_p->tbuf.t_uid, "%07" _PRIoID, uid); 7316 (void) sprintf(Thdr_p->tbuf.t_gid, "%07" _PRIoID, gid); 7317 (void) sprintf(Thdr_p->tbuf.t_size, "%011" PRIo64, len); 7318 (void) sprintf(Thdr_p->tbuf.t_mtime, "%011o", G_p->g_mtime); |
7299 if (arcflag == ARCHIVE_ACL) { 7300 Thdr_p->tbuf.t_typeflag = 'A'; /* ACL file type */ 7301 } else if (arcflag == ARCHIVE_XATTR || 7302 (G_p->g_attrnam_p != NULL)) { 7303 Thdr_p->tbuf.t_typeflag = _XATTR_HDRTYPE; 7304 } else { 7305 Thdr_p->tbuf.t_typeflag = G_p->g_typeflag; 7306 } --- 6 unchanged lines hidden (view full) --- 7313 Thdr_p->tbuf.t_typeflag = LNKTYPE; 7314 (void) sprintf(Thdr_p->tbuf.t_size, 7315 "%011lo", 0L); 7316 } 7317 (void) strncpy(Thdr_p->tbuf.t_linkname, T_lname, 7318 strlen(T_lname)); 7319 } 7320 (void) strcpy(Thdr_p->tbuf.t_magic, TMAGIC); | 7319 if (arcflag == ARCHIVE_ACL) { 7320 Thdr_p->tbuf.t_typeflag = 'A'; /* ACL file type */ 7321 } else if (arcflag == ARCHIVE_XATTR || 7322 (G_p->g_attrnam_p != NULL)) { 7323 Thdr_p->tbuf.t_typeflag = _XATTR_HDRTYPE; 7324 } else { 7325 Thdr_p->tbuf.t_typeflag = G_p->g_typeflag; 7326 } --- 6 unchanged lines hidden (view full) --- 7333 Thdr_p->tbuf.t_typeflag = LNKTYPE; 7334 (void) sprintf(Thdr_p->tbuf.t_size, 7335 "%011lo", 0L); 7336 } 7337 (void) strncpy(Thdr_p->tbuf.t_linkname, T_lname, 7338 strlen(T_lname)); 7339 } 7340 (void) strcpy(Thdr_p->tbuf.t_magic, TMAGIC); |
7321 (void) strcpy(Thdr_p->tbuf.t_version, TVERSION); | 7341 (void) memcpy(Thdr_p->tbuf.t_version, TVERSION, 2); |
7322 (void) strcpy(Thdr_p->tbuf.t_uname, G_p->g_uname); 7323 (void) strcpy(Thdr_p->tbuf.t_gname, G_p->g_gname); | 7342 (void) strcpy(Thdr_p->tbuf.t_uname, G_p->g_uname); 7343 (void) strcpy(Thdr_p->tbuf.t_gname, G_p->g_gname); |
7324 (void) sprintf(Thdr_p->tbuf.t_devmajor, "%07o", 7325 (int)major(G_p->g_rdev)); 7326 (void) sprintf(Thdr_p->tbuf.t_devminor, "%07o", 7327 (int)minor(G_p->g_rdev)); | 7344 (void) sprintf(Thdr_p->tbuf.t_devmajor, "%07" PRIo32, 7345 major(G_p->g_rdev)); 7346 (void) sprintf(Thdr_p->tbuf.t_devminor, "%07" PRIo32, 7347 minor(G_p->g_rdev)); |
7328 if (Gen.g_prefix) { 7329 (void) strcpy(Thdr_p->tbuf.t_prefix, Gen.g_prefix); 7330 free(Gen.g_prefix); 7331 Gen.g_prefix = NULL; 7332 } else { 7333 Thdr_p->tbuf.t_prefix[0] = '\0'; 7334 } 7335 (void) sprintf(Thdr_p->tbuf.t_cksum, "%07o", | 7348 if (Gen.g_prefix) { 7349 (void) strcpy(Thdr_p->tbuf.t_prefix, Gen.g_prefix); 7350 free(Gen.g_prefix); 7351 Gen.g_prefix = NULL; 7352 } else { 7353 Thdr_p->tbuf.t_prefix[0] = '\0'; 7354 } 7355 (void) sprintf(Thdr_p->tbuf.t_cksum, "%07o", |
7336 (int)cksum(TARTYP, 0, NULL)); | 7356 cksum(TARTYP, 0, NULL)); |
7337 break; 7338 case TAR: 7339 Thdr_p = (union tblock *)Buffr.b_in_p; 7340 (void) memset(Thdr_p, 0, TARSZ); 7341 (void) strncpy(Thdr_p->tbuf.t_name, G_p->g_nam_p, 7342 G_p->g_namesz); | 7357 break; 7358 case TAR: 7359 Thdr_p = (union tblock *)Buffr.b_in_p; 7360 (void) memset(Thdr_p, 0, TARSZ); 7361 (void) strncpy(Thdr_p->tbuf.t_name, G_p->g_nam_p, 7362 G_p->g_namesz); |
7343 (void) sprintf(Thdr_p->tbuf.t_mode, "%07o ", (int)mode); 7344 (void) sprintf(Thdr_p->tbuf.t_uid, "%07o ", (int)uid); 7345 (void) sprintf(Thdr_p->tbuf.t_gid, "%07o ", (int)gid); 7346 (void) sprintf(Thdr_p->tbuf.t_size, "%011llo ", 7347 (offset_t)len); 7348 (void) sprintf(Thdr_p->tbuf.t_mtime, "%011o ", 7349 (int)G_p->g_mtime); | 7363 (void) sprintf(Thdr_p->tbuf.t_mode, "%07o ", mode); 7364 (void) sprintf(Thdr_p->tbuf.t_uid, "%07" _PRIoID " ", uid); 7365 (void) sprintf(Thdr_p->tbuf.t_gid, "%07" _PRIoID " ", gid); 7366 (void) sprintf(Thdr_p->tbuf.t_size, "%011" PRIo64 " ", len); 7367 (void) sprintf(Thdr_p->tbuf.t_mtime, "%011o ", G_p->g_mtime); |
7350 if (T_lname[0] != '\0') { 7351 Thdr_p->tbuf.t_typeflag = '1'; 7352 } else { 7353 Thdr_p->tbuf.t_typeflag = '\0'; 7354 } 7355 (void) strncpy(Thdr_p->tbuf.t_linkname, T_lname, 7356 strlen(T_lname)); 7357 break; --- 184 unchanged lines hidden (view full) --- 7542 7543 ToSt.st_uid = TmpSt.st_uid; 7544 7545 /* -actual- not truncated gid */ 7546 7547 ToSt.st_gid = TmpSt.st_gid; 7548 ToSt.st_ino = (ino_t)TmpSt.st_ino; 7549 ToSt.st_mode = (mode_t)TmpSt.st_mode; | 7368 if (T_lname[0] != '\0') { 7369 Thdr_p->tbuf.t_typeflag = '1'; 7370 } else { 7371 Thdr_p->tbuf.t_typeflag = '\0'; 7372 } 7373 (void) strncpy(Thdr_p->tbuf.t_linkname, T_lname, 7374 strlen(T_lname)); 7375 break; --- 184 unchanged lines hidden (view full) --- 7560 7561 ToSt.st_uid = TmpSt.st_uid; 7562 7563 /* -actual- not truncated gid */ 7564 7565 ToSt.st_gid = TmpSt.st_gid; 7566 ToSt.st_ino = (ino_t)TmpSt.st_ino; 7567 ToSt.st_mode = (mode_t)TmpSt.st_mode; |
7550 ToSt.st_mtime = (ulong_t)TmpSt.st_modtime; | 7568 ToSt.st_mtime = (uint_t)TmpSt.st_modtime; |
7551 ToSt.st_nlink = (nlink_t)TmpSt.st_nlink; 7552 ToSt.st_size = (off_t)TmpSt.st_size; 7553 ToSt.st_rdev = (dev_t)TmpSt.st_rdev; 7554 7555 return (&ToSt); 7556} 7557 7558/* --- 38 unchanged lines hidden (view full) --- 7597 } 7598 (void) memcpy(&(bar_Vhdr->dbuf), &(tmp_hdr->dbuf), TBLOCK); 7599 } else { 7600 (void) fprintf(stderr, gettext( 7601 "bar error: cannot read volume header\n")); 7602 exit(1); 7603 } 7604 | 7569 ToSt.st_nlink = (nlink_t)TmpSt.st_nlink; 7570 ToSt.st_size = (off_t)TmpSt.st_size; 7571 ToSt.st_rdev = (dev_t)TmpSt.st_rdev; 7572 7573 return (&ToSt); 7574} 7575 7576/* --- 38 unchanged lines hidden (view full) --- 7615 } 7616 (void) memcpy(&(bar_Vhdr->dbuf), &(tmp_hdr->dbuf), TBLOCK); 7617 } else { 7618 (void) fprintf(stderr, gettext( 7619 "bar error: cannot read volume header\n")); 7620 exit(1); 7621 } 7622 |
7605 (void) sscanf(bar_Vhdr->dbuf.mode, "%8lo", &Gen_bar_vol.g_mode); 7606 (void) sscanf(bar_Vhdr->dbuf.uid, "%8d", (int *)&Gen_bar_vol.g_uid); 7607 (void) sscanf(bar_Vhdr->dbuf.gid, "%8d", (int *)&Gen_bar_vol.g_gid); 7608 (void) sscanf(bar_Vhdr->dbuf.size, "%12llo", | 7623 (void) sscanf(bar_Vhdr->dbuf.mode, "%8l", &Gen_bar_vol.g_mode); 7624 (void) sscanf(bar_Vhdr->dbuf.uid, "%8" _SCNdID, &Gen_bar_vol.g_uid); 7625 (void) sscanf(bar_Vhdr->dbuf.gid, "%8" _SCNdID, &Gen_bar_vol.g_gid); 7626 (void) sscanf(bar_Vhdr->dbuf.size, "%12" SCNo64, |
7609 (u_off_t *)&Gen_bar_vol.g_filesz); | 7627 (u_off_t *)&Gen_bar_vol.g_filesz); |
7610 (void) sscanf(bar_Vhdr->dbuf.mtime, "%12lo", &Gen_bar_vol.g_mtime); 7611 (void) sscanf(bar_Vhdr->dbuf.chksum, "%8lo", &Gen_bar_vol.g_cksum); | 7628 (void) sscanf(bar_Vhdr->dbuf.mtime, "%12o", &Gen_bar_vol.g_mtime); 7629 (void) sscanf(bar_Vhdr->dbuf.chksum, "%8o", &Gen_bar_vol.g_cksum); |
7612 7613 /* set the compress flag */ 7614 if (bar_Vhdr->dbuf.compressed == '1') 7615 Compressed = 1; 7616 else 7617 Compressed = 0; 7618 7619 Buffr.b_out_p += 512; --- 18 unchanged lines hidden (view full) --- 7638 * read in the header that describes the current file to be extracted 7639 */ 7640static void 7641read_bar_file_hdr(void) 7642{ 7643 union b_block *tmp_hdr; 7644 char *start_of_name, *name_p; 7645 char *tmp; | 7630 7631 /* set the compress flag */ 7632 if (bar_Vhdr->dbuf.compressed == '1') 7633 Compressed = 1; 7634 else 7635 Compressed = 0; 7636 7637 Buffr.b_out_p += 512; --- 18 unchanged lines hidden (view full) --- 7656 * read in the header that describes the current file to be extracted 7657 */ 7658static void 7659read_bar_file_hdr(void) 7660{ 7661 union b_block *tmp_hdr; 7662 char *start_of_name, *name_p; 7663 char *tmp; |
7664 major_t maj; 7665 minor_t min; |
|
7646 7647 if (*Buffr.b_out_p == '\0') { 7648 *Gen.g_nam_p = '\0'; 7649 exit(0); 7650 } 7651 7652 tmp_hdr = (union b_block *)Buffr.b_out_p; 7653 7654 tmp = &tmp_hdr->dbuf.mode[1]; | 7666 7667 if (*Buffr.b_out_p == '\0') { 7668 *Gen.g_nam_p = '\0'; 7669 exit(0); 7670 } 7671 7672 tmp_hdr = (union b_block *)Buffr.b_out_p; 7673 7674 tmp = &tmp_hdr->dbuf.mode[1]; |
7655 (void) sscanf(tmp, "%8lo", &Gen.g_mode); 7656 (void) sscanf(tmp_hdr->dbuf.uid, "%8lo", &Gen.g_uid); 7657 (void) sscanf(tmp_hdr->dbuf.gid, "%8lo", &Gen.g_gid); 7658 (void) sscanf(tmp_hdr->dbuf.size, "%12llo", | 7675 (void) sscanf(tmp, "%8o", &Gen.g_mode); 7676 (void) sscanf(tmp_hdr->dbuf.uid, "%8" _SCNoID, &Gen.g_uid); 7677 (void) sscanf(tmp_hdr->dbuf.gid, "%8" _SCNoID, &Gen.g_gid); 7678 (void) sscanf(tmp_hdr->dbuf.size, "%12" SCNo64, |
7659 (u_off_t *)&Gen.g_filesz); | 7679 (u_off_t *)&Gen.g_filesz); |
7660 (void) sscanf(tmp_hdr->dbuf.mtime, "%12lo", &Gen.g_mtime); 7661 (void) sscanf(tmp_hdr->dbuf.chksum, "%8lo", &Gen.g_cksum); 7662 (void) sscanf(tmp_hdr->dbuf.rdev, "%8lo", &Gen.g_rdev); | 7680 (void) sscanf(tmp_hdr->dbuf.mtime, "%12o", &Gen.g_mtime); 7681 (void) sscanf(tmp_hdr->dbuf.chksum, "%8o", &Gen.g_cksum); 7682 (void) sscanf(tmp_hdr->dbuf.rdev, "%8o", &Gen.g_rdev); |
7663 | 7683 |
7664#define to_new_major(x) (int)((unsigned)((x) & OMAXMAJ) << NBITSMINOR) 7665#define to_new_minor(x) (int)((x) & OMAXMIN) 7666 Gen.g_rdev = to_new_major(Gen.g_rdev) | to_new_minor(Gen.g_rdev); | 7684 maj = SVR3_MAJOR(Gen.g_rdev); 7685 min = SVR3_MINOR(Gen.g_rdev); 7686 Gen.g_rdev = makedev(maj, min); |
7667 bar_linkflag = tmp_hdr->dbuf.linkflag; 7668 start_of_name = &tmp_hdr->dbuf.start_of_name; 7669 7670 7671 name_p = Gen.g_nam_p; | 7687 bar_linkflag = tmp_hdr->dbuf.linkflag; 7688 start_of_name = &tmp_hdr->dbuf.start_of_name; 7689 7690 7691 name_p = Gen.g_nam_p; |
7672 while (*name_p++ = *start_of_name++) | 7692 while ((*name_p++ = *start_of_name++) != '\0') |
7673 ; 7674 *name_p = '\0'; 7675 if (bar_linkflag == LNKTYPE || bar_linkflag == SYMTYPE) 7676 (void) strcpy(bar_linkname, start_of_name); 7677 7678 Gen.g_namesz = strlen(Gen.g_nam_p) + 1; 7679 (void) strcpy(nambuf, Gen.g_nam_p); 7680} --- 9 unchanged lines hidden (view full) --- 7690 size_t cmdlen; 7691 7692 cmd_buf = e_zalloc(E_EXIT, MAXPATHLEN * 2); 7693 7694 if (access(Gen.g_nam_p, W_OK) != 0) { 7695 cmdlen = snprintf(cmd_buf, MAXPATHLEN * 2, 7696 "chmod +w '%s'; uncompress -c > '%s'; " 7697 "chmod 0%o '%s'", | 7693 ; 7694 *name_p = '\0'; 7695 if (bar_linkflag == LNKTYPE || bar_linkflag == SYMTYPE) 7696 (void) strcpy(bar_linkname, start_of_name); 7697 7698 Gen.g_namesz = strlen(Gen.g_nam_p) + 1; 7699 (void) strcpy(nambuf, Gen.g_nam_p); 7700} --- 9 unchanged lines hidden (view full) --- 7710 size_t cmdlen; 7711 7712 cmd_buf = e_zalloc(E_EXIT, MAXPATHLEN * 2); 7713 7714 if (access(Gen.g_nam_p, W_OK) != 0) { 7715 cmdlen = snprintf(cmd_buf, MAXPATHLEN * 2, 7716 "chmod +w '%s'; uncompress -c > '%s'; " 7717 "chmod 0%o '%s'", |
7698 Gen.g_nam_p, Gen.g_nam_p, (int)G_p->g_mode, Gen.g_nam_p); | 7718 Gen.g_nam_p, Gen.g_nam_p, G_p->g_mode, Gen.g_nam_p); |
7699 } else { 7700 cmdlen = snprintf(cmd_buf, MAXPATHLEN * 2, 7701 "uncompress -c > '%s'", Gen.g_nam_p); 7702 } 7703 7704 if (cmdlen >= MAXPATHLEN * 2 || 7705 (*pipef = popen(cmd_buf, "w")) == NULL) { 7706 (void) fprintf(stderr, gettext("error\n")); --- 34 unchanged lines hidden (view full) --- 7741 &(tmp_hdr->dbuf), TBLOCK); 7742 } else { 7743 (void) fprintf(stderr, 7744 gettext("cpio error: cannot read bar volume " 7745 "header\n")); 7746 exit(1); 7747 } 7748 | 7719 } else { 7720 cmdlen = snprintf(cmd_buf, MAXPATHLEN * 2, 7721 "uncompress -c > '%s'", Gen.g_nam_p); 7722 } 7723 7724 if (cmdlen >= MAXPATHLEN * 2 || 7725 (*pipef = popen(cmd_buf, "w")) == NULL) { 7726 (void) fprintf(stderr, gettext("error\n")); --- 34 unchanged lines hidden (view full) --- 7761 &(tmp_hdr->dbuf), TBLOCK); 7762 } else { 7763 (void) fprintf(stderr, 7764 gettext("cpio error: cannot read bar volume " 7765 "header\n")); 7766 exit(1); 7767 } 7768 |
7749 (void) sscanf(bar_Vhdr->dbuf.mode, "%8lo", | 7769 (void) sscanf(bar_Vhdr->dbuf.mode, "%8o", |
7750 &Gen_bar_vol.g_mode); | 7770 &Gen_bar_vol.g_mode); |
7751 (void) sscanf(bar_Vhdr->dbuf.uid, "%8lo", | 7771 (void) sscanf(bar_Vhdr->dbuf.uid, "%8" _SCNoID, |
7752 &Gen_bar_vol.g_uid); | 7772 &Gen_bar_vol.g_uid); |
7753 (void) sscanf(bar_Vhdr->dbuf.gid, "%8lo", | 7773 (void) sscanf(bar_Vhdr->dbuf.gid, "%8" _SCNoID, |
7754 &Gen_bar_vol.g_gid); | 7774 &Gen_bar_vol.g_gid); |
7755 (void) sscanf(bar_Vhdr->dbuf.size, "%12llo", | 7775 (void) sscanf(bar_Vhdr->dbuf.size, "%12" SCNo64, |
7756 (u_off_t *)&Gen_bar_vol.g_filesz); | 7776 (u_off_t *)&Gen_bar_vol.g_filesz); |
7757 (void) sscanf(bar_Vhdr->dbuf.mtime, "%12lo", | 7777 (void) sscanf(bar_Vhdr->dbuf.mtime, "%12o", |
7758 &Gen_bar_vol.g_mtime); | 7778 &Gen_bar_vol.g_mtime); |
7759 (void) sscanf(bar_Vhdr->dbuf.chksum, "%8lo", | 7779 (void) sscanf(bar_Vhdr->dbuf.chksum, "%8o", |
7760 &Gen_bar_vol.g_cksum); 7761 if (bar_Vhdr->dbuf.compressed == '1') 7762 Compressed = 1; 7763 else 7764 Compressed = 0; 7765 } 7766 7767 /* --- 1020 unchanged lines hidden (view full) --- 8788 return (1); 8789 } 8790 (void) sscanf(xattrhead->h_component_len, "%10d", &comp_len); 8791 (void) sscanf(xattrhead->h_link_component_len, "%10d", &link_len); 8792 xattrp = (struct xattr_buf *)(((char *)xattrhead) + 8793 sizeof (struct xattr_hdr)); 8794 (void) sscanf(xattrp->h_namesz, "%7d", &namelen); 8795 if (link_len > 0) { | 7780 &Gen_bar_vol.g_cksum); 7781 if (bar_Vhdr->dbuf.compressed == '1') 7782 Compressed = 1; 7783 else 7784 Compressed = 0; 7785 } 7786 7787 /* --- 1020 unchanged lines hidden (view full) --- 8808 return (1); 8809 } 8810 (void) sscanf(xattrhead->h_component_len, "%10d", &comp_len); 8811 (void) sscanf(xattrhead->h_link_component_len, "%10d", &link_len); 8812 xattrp = (struct xattr_buf *)(((char *)xattrhead) + 8813 sizeof (struct xattr_hdr)); 8814 (void) sscanf(xattrp->h_namesz, "%7d", &namelen); 8815 if (link_len > 0) { |
8796 xattr_linkp = (struct xattr_buf *)((int)xattrp + (int)comp_len); | 8816 xattr_linkp = (struct xattr_buf *)((intptr_t)xattrp + 8817 (int)comp_len); |
8797 } else { 8798 xattr_linkp = NULL; 8799 } 8800 8801 /* 8802 * Gather the attribute path from the filename and attrnames section. 8803 * The filename and attrnames section can be composed of two or more 8804 * path segments separated by a null character. The first segment --- 209 unchanged lines hidden (view full) --- 9014 } 9015 prepare_xattr_hdr(&attrbuf, Gen.g_attrfnam_p, 9016 Gen.g_attrpath_p, 9017 (linkinfo == NULL) ? 9018 tartype(Gen.g_mode & Ftype) : LNKTYPE, 9019 linkinfo, &attrlen); 9020 Gen.g_filesz = attrlen; 9021 write_hdr(ARCHIVE_XATTR, (off_t)attrlen); | 8818 } else { 8819 xattr_linkp = NULL; 8820 } 8821 8822 /* 8823 * Gather the attribute path from the filename and attrnames section. 8824 * The filename and attrnames section can be composed of two or more 8825 * path segments separated by a null character. The first segment --- 209 unchanged lines hidden (view full) --- 9035 } 9036 prepare_xattr_hdr(&attrbuf, Gen.g_attrfnam_p, 9037 Gen.g_attrpath_p, 9038 (linkinfo == NULL) ? 9039 tartype(Gen.g_mode & Ftype) : LNKTYPE, 9040 linkinfo, &attrlen); 9041 Gen.g_filesz = attrlen; 9042 write_hdr(ARCHIVE_XATTR, (off_t)attrlen); |
9022 /*LINTED*/ | |
9023 (void) sprintf(namep, "%s/%s", DEVNULL, Gen.g_attrnam_p); 9024 write_ancillary(attrbuf, attrlen, B_TRUE); 9025 } 9026 9027 (void) creat_hdr(); 9028#endif 9029} 9030 --- 157 unchanged lines hidden (view full) --- 9188 if (cmpflg < 0) { 9189 a = -1; 9190 } else { 9191 a = 1; 9192 } 9193 9194 if (s->bal == 0) { 9195 s->bal = a; | 9043 (void) sprintf(namep, "%s/%s", DEVNULL, Gen.g_attrnam_p); 9044 write_ancillary(attrbuf, attrlen, B_TRUE); 9045 } 9046 9047 (void) creat_hdr(); 9048#endif 9049} 9050 --- 157 unchanged lines hidden (view full) --- 9208 if (cmpflg < 0) { 9209 a = -1; 9210 } else { 9211 a = 1; 9212 } 9213 9214 if (s->bal == 0) { 9215 s->bal = a; |
9196 head->llink = (sl_info_t *)((int)head->llink + 1); | 9216 head->llink = (sl_info_t *)((intptr_t)head->llink + 1); |
9197 return (q); 9198 } else if (s->bal == -a) { 9199 s->bal = 0; 9200 return (q); 9201 } 9202 9203 /* 9204 * (s->bal == a) --- 55 unchanged lines hidden (view full) --- 9260 9261 return (q); 9262} 9263 9264/* 9265 * sl_numlinks: return the number of links that we saw during our preview. 9266 */ 9267 | 9217 return (q); 9218 } else if (s->bal == -a) { 9219 s->bal = 0; 9220 return (q); 9221 } 9222 9223 /* 9224 * (s->bal == a) --- 55 unchanged lines hidden (view full) --- 9280 9281 return (q); 9282} 9283 9284/* 9285 * sl_numlinks: return the number of links that we saw during our preview. 9286 */ 9287 |
9268static ulong_t | 9288static uint_t |
9269sl_numlinks(dev_t device, ino_t inode, int ftype) 9270{ 9271 sl_info_t *p = sl_search(device, inode, ftype); 9272 9273 if (p) { 9274 return (p->sl_count); 9275 } else { 9276 return (1); --- 75 unchanged lines hidden (view full) --- 9352 } 9353 dirp = fdopendir(tmpfd); 9354 if (dirp == NULL) { 9355 (void) close(dirfd); 9356 (void) close(tmpfd); 9357 return (1); 9358 } 9359 | 9289sl_numlinks(dev_t device, ino_t inode, int ftype) 9290{ 9291 sl_info_t *p = sl_search(device, inode, ftype); 9292 9293 if (p) { 9294 return (p->sl_count); 9295 } else { 9296 return (1); --- 75 unchanged lines hidden (view full) --- 9372 } 9373 dirp = fdopendir(tmpfd); 9374 if (dirp == NULL) { 9375 (void) close(dirfd); 9376 (void) close(tmpfd); 9377 return (1); 9378 } 9379 |
9360 while (dp = readdir(dirp)) { | 9380 while ((dp = readdir(dirp)) != NULL) { |
9361 if (dp->d_name[0] == '.') { 9362 if (dp->d_name[1] == '\0') { 9363 Hiddendir = 1; 9364 } else if ((dp->d_name[1] == '.') && 9365 (dp->d_name[2] == '\0')) { 9366 continue; 9367 } else { 9368 Hiddendir = 0; --- 372 unchanged lines hidden --- | 9381 if (dp->d_name[0] == '.') { 9382 if (dp->d_name[1] == '\0') { 9383 Hiddendir = 1; 9384 } else if ((dp->d_name[1] == '.') && 9385 (dp->d_name[2] == '\0')) { 9386 continue; 9387 } else { 9388 Hiddendir = 0; --- 372 unchanged lines hidden --- |