ar_subs.c (90110) | ar_subs.c (90113) |
---|---|
1/*- 2 * Copyright (c) 1992 Keith Muller. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Keith Muller of the University of California, San Diego. 8 * --- 26 unchanged lines hidden (view full) --- 35 * SUCH DAMAGE. 36 */ 37 38#ifndef lint 39#if 0 40static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94"; 41#endif 42static const char rcsid[] = | 1/*- 2 * Copyright (c) 1992 Keith Muller. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Keith Muller of the University of California, San Diego. 8 * --- 26 unchanged lines hidden (view full) --- 35 * SUCH DAMAGE. 36 */ 37 38#ifndef lint 39#if 0 40static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94"; 41#endif 42static const char rcsid[] = |
43 "$FreeBSD: head/bin/pax/ar_subs.c 90110 2002-02-02 06:48:10Z imp $"; | 43 "$FreeBSD: head/bin/pax/ar_subs.c 90113 2002-02-02 07:07:59Z imp $"; |
44#endif /* not lint */ 45 46#include <sys/types.h> 47#include <sys/time.h> 48#include <sys/stat.h> 49#include <signal.h> 50#include <string.h> 51#include <stdio.h> 52#include <fcntl.h> 53#include <errno.h> 54#include <unistd.h> 55#include <stdlib.h> 56#include "pax.h" 57#include "extern.h" 58 | 44#endif /* not lint */ 45 46#include <sys/types.h> 47#include <sys/time.h> 48#include <sys/stat.h> 49#include <signal.h> 50#include <string.h> 51#include <stdio.h> 52#include <fcntl.h> 53#include <errno.h> 54#include <unistd.h> 55#include <stdlib.h> 56#include "pax.h" 57#include "extern.h" 58 |
59static void wr_archive(register ARCHD *, int is_app); | 59static void wr_archive(ARCHD *, int is_app); |
60static int get_arc(void); | 60static int get_arc(void); |
61static int next_head(register ARCHD *); | 61static int next_head(ARCHD *); |
62extern sigset_t s_mask; 63 64/* 65 * Routines which control the overall operation modes of pax as specified by 66 * the user: list, append, read ... 67 */ 68 69static char hdbuf[BLKMULT]; /* space for archive header on read */ 70u_long flcnt; /* number of files processed */ 71 72/* 73 * list() 74 * list the contents of an archive which match user supplied pattern(s) 75 * (no pattern matches all). 76 */ 77 78void 79list(void) 80{ | 62extern sigset_t s_mask; 63 64/* 65 * Routines which control the overall operation modes of pax as specified by 66 * the user: list, append, read ... 67 */ 68 69static char hdbuf[BLKMULT]; /* space for archive header on read */ 70u_long flcnt; /* number of files processed */ 71 72/* 73 * list() 74 * list the contents of an archive which match user supplied pattern(s) 75 * (no pattern matches all). 76 */ 77 78void 79list(void) 80{ |
81 register ARCHD *arcn; 82 register int res; | 81 ARCHD *arcn; 82 int res; |
83 ARCHD archd; 84 time_t now; 85 86 arcn = &archd; 87 /* 88 * figure out archive type; pass any format specific options to the 89 * archive option processing routine; call the format init routine. We 90 * also save current time for ls_list() so we do not make a system --- 59 unchanged lines hidden (view full) --- 150 * extract() 151 * extract the member(s) of an archive as specified by user supplied 152 * pattern(s) (no patterns extracts all members) 153 */ 154 155void 156extract(void) 157{ | 83 ARCHD archd; 84 time_t now; 85 86 arcn = &archd; 87 /* 88 * figure out archive type; pass any format specific options to the 89 * archive option processing routine; call the format init routine. We 90 * also save current time for ls_list() so we do not make a system --- 59 unchanged lines hidden (view full) --- 150 * extract() 151 * extract the member(s) of an archive as specified by user supplied 152 * pattern(s) (no patterns extracts all members) 153 */ 154 155void 156extract(void) 157{ |
158 register ARCHD *arcn; 159 register int res; | 158 ARCHD *arcn; 159 int res; |
160 off_t cnt; 161 ARCHD archd; 162 struct stat sb; 163 int fd; 164 time_t now; 165 166 arcn = &archd; 167 /* --- 186 unchanged lines hidden (view full) --- 354 355/* 356 * wr_archive() 357 * Write an archive. used in both creating a new archive and appends on 358 * previously written archive. 359 */ 360 361static void | 160 off_t cnt; 161 ARCHD archd; 162 struct stat sb; 163 int fd; 164 time_t now; 165 166 arcn = &archd; 167 /* --- 186 unchanged lines hidden (view full) --- 354 355/* 356 * wr_archive() 357 * Write an archive. used in both creating a new archive and appends on 358 * previously written archive. 359 */ 360 361static void |
362wr_archive(register ARCHD *arcn, int is_app) | 362wr_archive(ARCHD *arcn, int is_app) |
363{ | 363{ |
364 register int res; 365 register int hlk; 366 register int wr_one; | 364 int res; 365 int hlk; 366 int wr_one; |
367 off_t cnt; 368 int (*wrf)(); 369 int fd = -1; 370 time_t now; 371 372 /* 373 * if this format supports hard link storage, start up the database 374 * that detects them. --- 184 unchanged lines hidden (view full) --- 559 * header that invalidates a previous archive record. The POSIX spec left 560 * the method used to implement -u unspecified. This pax is able to 561 * over write existing files that it creates. 562 */ 563 564void 565append(void) 566{ | 367 off_t cnt; 368 int (*wrf)(); 369 int fd = -1; 370 time_t now; 371 372 /* 373 * if this format supports hard link storage, start up the database 374 * that detects them. --- 184 unchanged lines hidden (view full) --- 559 * header that invalidates a previous archive record. The POSIX spec left 560 * the method used to implement -u unspecified. This pax is able to 561 * over write existing files that it creates. 562 */ 563 564void 565append(void) 566{ |
567 register ARCHD *arcn; 568 register int res; | 567 ARCHD *arcn; 568 int res; |
569 ARCHD archd; 570 FSUB *orgfrmt; 571 int udev; 572 off_t tlen; 573 574 arcn = &archd; 575 orgfrmt = frmt; 576 --- 144 unchanged lines hidden (view full) --- 721 * use any archive storage. The EFFECT OF THE COPY IS THE SAME as if an 722 * archive was written and then extracted in the destination directory 723 * (except the files are forced to be under the destination directory). 724 */ 725 726void 727copy(void) 728{ | 569 ARCHD archd; 570 FSUB *orgfrmt; 571 int udev; 572 off_t tlen; 573 574 arcn = &archd; 575 orgfrmt = frmt; 576 --- 144 unchanged lines hidden (view full) --- 721 * use any archive storage. The EFFECT OF THE COPY IS THE SAME as if an 722 * archive was written and then extracted in the destination directory 723 * (except the files are forced to be under the destination directory). 724 */ 725 726void 727copy(void) 728{ |
729 register ARCHD *arcn; 730 register int res; 731 register int fddest; 732 register char *dest_pt; 733 register int dlen; 734 register int drem; | 729 ARCHD *arcn; 730 int res; 731 int fddest; 732 char *dest_pt; 733 int dlen; 734 int drem; |
735 int fdsrc = -1; 736 struct stat sb; 737 ARCHD archd; 738 char dirbuf[PAXPATHLEN+1]; 739 740 arcn = &archd; 741 /* 742 * set up the destination dir path and make sure it is a directory. We --- 223 unchanged lines hidden (view full) --- 966 * ASSUMED: headers fit within a BLKMULT header. 967 * Return: 968 * 0 if we got a header, -1 if we are unable to ever find another one 969 * (we reached the end of input, or we reached the limit on retries. see 970 * the specs for rd_wrbuf() for more details) 971 */ 972 973static int | 735 int fdsrc = -1; 736 struct stat sb; 737 ARCHD archd; 738 char dirbuf[PAXPATHLEN+1]; 739 740 arcn = &archd; 741 /* 742 * set up the destination dir path and make sure it is a directory. We --- 223 unchanged lines hidden (view full) --- 966 * ASSUMED: headers fit within a BLKMULT header. 967 * Return: 968 * 0 if we got a header, -1 if we are unable to ever find another one 969 * (we reached the end of input, or we reached the limit on retries. see 970 * the specs for rd_wrbuf() for more details) 971 */ 972 973static int |
974next_head(register ARCHD *arcn) | 974next_head(ARCHD *arcn) |
975{ | 975{ |
976 register int ret; 977 register char *hdend; 978 register int res; 979 register int shftsz; 980 register int hsz; 981 register int in_resync = 0; /* set when we are in resync mode */ | 976 int ret; 977 char *hdend; 978 int res; 979 int shftsz; 980 int hsz; 981 int in_resync = 0; /* set when we are in resync mode */ |
982 int cnt = 0; /* counter for trailer function */ 983 int first = 1; /* on 1st read, EOF isn't premature. */ 984 985 /* 986 * set up initial conditions, we want a whole frmt->hsz block as we 987 * have no data yet. 988 */ 989 res = hsz = frmt->hsz; --- 130 unchanged lines hidden (view full) --- 1120 * ASSUMED: headers fit within a BLKMULT header. 1121 * Return: 1122 * 0 if archive found -1 otherwise 1123 */ 1124 1125static int 1126get_arc(void) 1127{ | 982 int cnt = 0; /* counter for trailer function */ 983 int first = 1; /* on 1st read, EOF isn't premature. */ 984 985 /* 986 * set up initial conditions, we want a whole frmt->hsz block as we 987 * have no data yet. 988 */ 989 res = hsz = frmt->hsz; --- 130 unchanged lines hidden (view full) --- 1120 * ASSUMED: headers fit within a BLKMULT header. 1121 * Return: 1122 * 0 if archive found -1 otherwise 1123 */ 1124 1125static int 1126get_arc(void) 1127{ |
1128 register int i; 1129 register int hdsz = 0; 1130 register int res; 1131 register int minhd = BLKMULT; | 1128 int i; 1129 int hdsz = 0; 1130 int res; 1131 int minhd = BLKMULT; |
1132 char *hdend; 1133 int notice = 0; 1134 1135 /* 1136 * find the smallest header size in all archive formats and then set up 1137 * to read the archive. 1138 */ 1139 for (i = 0; ford[i] >= 0; ++i) { --- 100 unchanged lines hidden --- | 1132 char *hdend; 1133 int notice = 0; 1134 1135 /* 1136 * find the smallest header size in all archive formats and then set up 1137 * to read the archive. 1138 */ 1139 for (i = 0; ford[i] >= 0; ++i) { --- 100 unchanged lines hidden --- |