1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1992 Keith Muller. 5 * Copyright (c) 1992, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * Keith Muller of the University of California, San Diego. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 36/* 37 * External references from each source file 38 */ 39 40#include <sys/cdefs.h> 41 42/* 43 * ar_io.c 44 */ 45extern const char *arcname; 46extern const char *gzip_program; 47int ar_open(const char *); 48void ar_close(void); 49void ar_drain(void); 50int ar_set_wr(void); 51int ar_app_ok(void); 52int ar_read(char *, int); 53int ar_write(char *, int); 54int ar_rdsync(void); 55int ar_fow(off_t, off_t *); 56int ar_rev(off_t ); 57int ar_next(void); 58 59/* 60 * ar_subs.c 61 */ 62extern u_long flcnt; 63void list(void); 64void extract(void); 65void append(void); 66void archive(void); 67void copy(void); 68 69/* 70 * buf_subs.c 71 */ 72extern int blksz; 73extern int wrblksz; 74extern int maxflt; 75extern int rdblksz; 76extern off_t wrlimit; 77extern off_t rdcnt; 78extern off_t wrcnt; 79int wr_start(void); 80int rd_start(void); 81void cp_start(void); 82int appnd_start(off_t); 83int rd_sync(void); 84void pback(char *, int); 85int rd_skip(off_t); 86void wr_fin(void); 87int wr_rdbuf(char *, int); 88int rd_wrbuf(char *, int); 89int wr_skip(off_t); 90int wr_rdfile(ARCHD *, int, off_t *); 91int rd_wrfile(ARCHD *, int, off_t *); 92void cp_file(ARCHD *, int, int); 93int buf_fill(void); 94int buf_flush(int); 95 96/* 97 * cache.c 98 */ 99int uidtb_start(void); 100int gidtb_start(void); 101int usrtb_start(void); 102int grptb_start(void); 103const char * name_uid(uid_t, int); 104const char * name_gid(gid_t, int); 105int uid_name(char *, uid_t *); 106int gid_name(char *, gid_t *); 107 108/* 109 * cpio.c 110 */ 111int cpio_strd(void); 112int cpio_trail(ARCHD *); 113int cpio_endwr(void); 114int cpio_id(char *, int); 115int cpio_rd(ARCHD *, char *); 116off_t cpio_endrd(void); 117int cpio_stwr(void); 118int cpio_wr(ARCHD *); 119int vcpio_id(char *, int); 120int crc_id(char *, int); 121int crc_strd(void); 122int vcpio_rd(ARCHD *, char *); 123off_t vcpio_endrd(void); 124int crc_stwr(void); 125int vcpio_wr(ARCHD *); 126int bcpio_id(char *, int); 127int bcpio_rd(ARCHD *, char *); 128off_t bcpio_endrd(void); 129int bcpio_wr(ARCHD *); 130 131/* 132 * file_subs.c 133 */ 134int file_creat(ARCHD *); 135void file_close(ARCHD *, int); 136int lnk_creat(ARCHD *); 137int cross_lnk(ARCHD *); 138int chk_same(ARCHD *); 139int node_creat(ARCHD *); 140int unlnk_exist(char *, int); 141int chk_path(char *, uid_t, gid_t); 142void set_ftime(char *fnm, time_t mtime, time_t atime, int frc); 143int set_ids(char *, uid_t, gid_t); 144int set_lids(char *, uid_t, gid_t); 145void set_pmode(char *, mode_t); 146int file_write(int, char *, int, int *, int *, int, char *); 147void file_flush(int, char *, int); 148void rdfile_close(ARCHD *, int *); 149int set_crc(ARCHD *, int); 150 151/* 152 * ftree.c 153 */ 154int ftree_start(void); 155int ftree_add(char *, int); 156void ftree_sel(ARCHD *); 157void ftree_notsel(void); 158void ftree_chk(void); 159int next_file(ARCHD *); 160 161/* 162 * gen_subs.c 163 */ 164void ls_list(ARCHD *, time_t, FILE *); 165void ls_tty(ARCHD *); 166int l_strncpy(char *, const char *, int); 167u_long asc_ul(char *, int, int); 168int ul_asc(u_long, char *, int, int); 169u_quad_t asc_uqd(char *, int, int); 170int uqd_asc(u_quad_t, char *, int, int); 171 172/* 173 * getoldopt.c 174 */ 175int getoldopt(int, char **, const char *); 176 177/* 178 * options.c 179 */ 180extern FSUB fsub[]; 181extern int ford[]; 182void options(int, char **); 183OPLIST * opt_next(void); 184int opt_add(const char *); 185int bad_opt(void); 186extern char *chdname; 187 188/* 189 * pat_rep.c 190 */ 191int rep_add(char *); 192int pat_add(char *, char *); 193void pat_chk(void); 194int pat_sel(ARCHD *); 195int pat_match(ARCHD *); 196int mod_name(ARCHD *); 197int set_dest(ARCHD *, char *, int); 198 199/* 200 * pax.c 201 */ 202extern int act; 203extern FSUB *frmt; 204extern int cflag; 205extern int cwdfd; 206extern int dflag; 207extern int iflag; 208extern int kflag; 209extern int lflag; 210extern int nflag; 211extern int tflag; 212extern int uflag; 213extern int vflag; 214extern int Dflag; 215extern int Hflag; 216extern int Lflag; 217extern int Oflag; 218extern int Xflag; 219extern int Yflag; 220extern int Zflag; 221extern int vfpart; 222extern int patime; 223extern int pmtime; 224extern int nodirs; 225extern int pmode; 226extern int pids; 227extern int rmleadslash; 228extern int exit_val; 229extern int docrc; 230extern char *dirptr; 231extern const char *argv0; 232extern sigset_t s_mask; 233extern FILE *listf; 234extern char *tempfile; 235extern char *tempbase; 236 237void sig_cleanup(int); 238 239/* 240 * sel_subs.c 241 */ 242int sel_chk(ARCHD *); 243int grp_add(char *); 244int usr_add(char *); 245int trng_add(char *); 246 247/* 248 * tables.c 249 */ 250int lnk_start(void); 251int chk_lnk(ARCHD *); 252void purg_lnk(ARCHD *); 253void lnk_end(void); 254int ftime_start(void); 255int chk_ftime(ARCHD *); 256int name_start(void); 257int add_name(char *, int, char *); 258void sub_name(char *, int *, size_t); 259int dev_start(void); 260int add_dev(ARCHD *); 261int map_dev(ARCHD *, u_long, u_long); 262int atdir_start(void); 263void atdir_end(void); 264void add_atdir(char *, dev_t, ino_t, time_t, time_t); 265int get_atdir(dev_t, ino_t, time_t *, time_t *); 266int dir_start(void); 267void add_dir(char *, int, struct stat *, int); 268void proc_dir(void); 269u_int st_hash(char *, int, int); 270 271/* 272 * tar.c 273 */ 274int tar_endwr(void); 275off_t tar_endrd(void); 276int tar_trail(char *, int, int *); 277int tar_id(char *, int); 278int tar_opt(void); 279int tar_rd(ARCHD *, char *); 280int tar_wr(ARCHD *); 281int ustar_strd(void); 282int ustar_stwr(void); 283int ustar_id(char *, int); 284int ustar_rd(ARCHD *, char *); 285int ustar_wr(ARCHD *); 286 287/* 288 * tty_subs.c 289 */ 290int tty_init(void); 291void tty_prnt(const char *, ...) __printflike(1, 2); 292int tty_read(char *, int); 293void paxwarn(int, const char *, ...) __printflike(2, 3); 294void syswarn(int, int, const char *, ...) __printflike(3, 4); 295