14b88c807SRodney W. Grimes /*- 2*8a16b7a1SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 3*8a16b7a1SPedro F. Giffuni * 44b88c807SRodney W. Grimes * Copyright (c) 1992 Keith Muller. 54b88c807SRodney W. Grimes * Copyright (c) 1992, 1993 64b88c807SRodney W. Grimes * The Regents of the University of California. All rights reserved. 74b88c807SRodney W. Grimes * 84b88c807SRodney W. Grimes * This code is derived from software contributed to Berkeley by 94b88c807SRodney W. Grimes * Keith Muller of the University of California, San Diego. 104b88c807SRodney W. Grimes * 114b88c807SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 124b88c807SRodney W. Grimes * modification, are permitted provided that the following conditions 134b88c807SRodney W. Grimes * are met: 144b88c807SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 154b88c807SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 164b88c807SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 174b88c807SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 184b88c807SRodney W. Grimes * documentation and/or other materials provided with the distribution. 19fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 204b88c807SRodney W. Grimes * may be used to endorse or promote products derived from this software 214b88c807SRodney W. Grimes * without specific prior written permission. 224b88c807SRodney W. Grimes * 234b88c807SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 244b88c807SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 254b88c807SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 264b88c807SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 274b88c807SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 284b88c807SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 294b88c807SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 304b88c807SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 314b88c807SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 324b88c807SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 334b88c807SRodney W. Grimes * SUCH DAMAGE. 344b88c807SRodney W. Grimes * 354b88c807SRodney W. Grimes * @(#)extern.h 8.2 (Berkeley) 4/18/94 362a456239SPeter Wemm * $FreeBSD$ 374b88c807SRodney W. Grimes */ 384b88c807SRodney W. Grimes 394b88c807SRodney W. Grimes /* 404b88c807SRodney W. Grimes * External references from each source file 414b88c807SRodney W. Grimes */ 424b88c807SRodney W. Grimes 434b88c807SRodney W. Grimes #include <sys/cdefs.h> 444b88c807SRodney W. Grimes 454b88c807SRodney W. Grimes /* 464b88c807SRodney W. Grimes * ar_io.c 474b88c807SRodney W. Grimes */ 4840feca3aSMark Murray extern const char *arcname; 491192d531SKris Kennaway extern const char *gzip_program; 5040feca3aSMark Murray int ar_open(const char *); 5146251ddeSWarner Losh void ar_close(void); 5246251ddeSWarner Losh void ar_drain(void); 5346251ddeSWarner Losh int ar_set_wr(void); 5446251ddeSWarner Losh int ar_app_ok(void); 5546251ddeSWarner Losh int ar_read(char *, int); 5646251ddeSWarner Losh int ar_write(char *, int); 5746251ddeSWarner Losh int ar_rdsync(void); 5846251ddeSWarner Losh int ar_fow(off_t, off_t *); 5946251ddeSWarner Losh int ar_rev(off_t ); 6046251ddeSWarner Losh int ar_next(void); 614b88c807SRodney W. Grimes 624b88c807SRodney W. Grimes /* 634b88c807SRodney W. Grimes * ar_subs.c 644b88c807SRodney W. Grimes */ 654b88c807SRodney W. Grimes extern u_long flcnt; 6646251ddeSWarner Losh void list(void); 6746251ddeSWarner Losh void extract(void); 6846251ddeSWarner Losh void append(void); 6946251ddeSWarner Losh void archive(void); 7046251ddeSWarner Losh void copy(void); 714b88c807SRodney W. Grimes 724b88c807SRodney W. Grimes /* 734b88c807SRodney W. Grimes * buf_subs.c 744b88c807SRodney W. Grimes */ 754b88c807SRodney W. Grimes extern int blksz; 764b88c807SRodney W. Grimes extern int wrblksz; 774b88c807SRodney W. Grimes extern int maxflt; 784b88c807SRodney W. Grimes extern int rdblksz; 794b88c807SRodney W. Grimes extern off_t wrlimit; 804b88c807SRodney W. Grimes extern off_t rdcnt; 814b88c807SRodney W. Grimes extern off_t wrcnt; 8246251ddeSWarner Losh int wr_start(void); 8346251ddeSWarner Losh int rd_start(void); 8446251ddeSWarner Losh void cp_start(void); 8546251ddeSWarner Losh int appnd_start(off_t); 8646251ddeSWarner Losh int rd_sync(void); 8746251ddeSWarner Losh void pback(char *, int); 8846251ddeSWarner Losh int rd_skip(off_t); 8946251ddeSWarner Losh void wr_fin(void); 9046251ddeSWarner Losh int wr_rdbuf(char *, int); 9146251ddeSWarner Losh int rd_wrbuf(char *, int); 9246251ddeSWarner Losh int wr_skip(off_t); 9346251ddeSWarner Losh int wr_rdfile(ARCHD *, int, off_t *); 9446251ddeSWarner Losh int rd_wrfile(ARCHD *, int, off_t *); 9546251ddeSWarner Losh void cp_file(ARCHD *, int, int); 9646251ddeSWarner Losh int buf_fill(void); 9746251ddeSWarner Losh int buf_flush(int); 984b88c807SRodney W. Grimes 994b88c807SRodney W. Grimes /* 1004b88c807SRodney W. Grimes * cache.c 1014b88c807SRodney W. Grimes */ 10246251ddeSWarner Losh int uidtb_start(void); 10346251ddeSWarner Losh int gidtb_start(void); 10446251ddeSWarner Losh int usrtb_start(void); 10546251ddeSWarner Losh int grptb_start(void); 10640feca3aSMark Murray const char * name_uid(uid_t, int); 10740feca3aSMark Murray const char * name_gid(gid_t, int); 10846251ddeSWarner Losh int uid_name(char *, uid_t *); 10946251ddeSWarner Losh int gid_name(char *, gid_t *); 1104b88c807SRodney W. Grimes 1114b88c807SRodney W. Grimes /* 1124b88c807SRodney W. Grimes * cpio.c 1134b88c807SRodney W. Grimes */ 11446251ddeSWarner Losh int cpio_strd(void); 11546251ddeSWarner Losh int cpio_trail(ARCHD *); 11646251ddeSWarner Losh int cpio_endwr(void); 11746251ddeSWarner Losh int cpio_id(char *, int); 11846251ddeSWarner Losh int cpio_rd(ARCHD *, char *); 11946251ddeSWarner Losh off_t cpio_endrd(void); 12046251ddeSWarner Losh int cpio_stwr(void); 12146251ddeSWarner Losh int cpio_wr(ARCHD *); 12246251ddeSWarner Losh int vcpio_id(char *, int); 12346251ddeSWarner Losh int crc_id(char *, int); 12446251ddeSWarner Losh int crc_strd(void); 12546251ddeSWarner Losh int vcpio_rd(ARCHD *, char *); 12646251ddeSWarner Losh off_t vcpio_endrd(void); 12746251ddeSWarner Losh int crc_stwr(void); 12846251ddeSWarner Losh int vcpio_wr(ARCHD *); 12946251ddeSWarner Losh int bcpio_id(char *, int); 13046251ddeSWarner Losh int bcpio_rd(ARCHD *, char *); 13146251ddeSWarner Losh off_t bcpio_endrd(void); 13246251ddeSWarner Losh int bcpio_wr(ARCHD *); 1334b88c807SRodney W. Grimes 1344b88c807SRodney W. Grimes /* 1354b88c807SRodney W. Grimes * file_subs.c 1364b88c807SRodney W. Grimes */ 13746251ddeSWarner Losh int file_creat(ARCHD *); 13846251ddeSWarner Losh void file_close(ARCHD *, int); 13946251ddeSWarner Losh int lnk_creat(ARCHD *); 14046251ddeSWarner Losh int cross_lnk(ARCHD *); 14146251ddeSWarner Losh int chk_same(ARCHD *); 14246251ddeSWarner Losh int node_creat(ARCHD *); 14346251ddeSWarner Losh int unlnk_exist(char *, int); 14446251ddeSWarner Losh int chk_path(char *, uid_t, gid_t); 14546251ddeSWarner Losh void set_ftime(char *fnm, time_t mtime, time_t atime, int frc); 14646251ddeSWarner Losh int set_ids(char *, uid_t, gid_t); 14746251ddeSWarner Losh int set_lids(char *, uid_t, gid_t); 14846251ddeSWarner Losh void set_pmode(char *, mode_t); 14946251ddeSWarner Losh int file_write(int, char *, int, int *, int *, int, char *); 15046251ddeSWarner Losh void file_flush(int, char *, int); 15146251ddeSWarner Losh void rdfile_close(ARCHD *, int *); 15246251ddeSWarner Losh int set_crc(ARCHD *, int); 1534b88c807SRodney W. Grimes 1544b88c807SRodney W. Grimes /* 1554b88c807SRodney W. Grimes * ftree.c 1564b88c807SRodney W. Grimes */ 15746251ddeSWarner Losh int ftree_start(void); 15846251ddeSWarner Losh int ftree_add(char *, int); 15946251ddeSWarner Losh void ftree_sel(ARCHD *); 1600e32d64eSBrian Somers void ftree_notsel(void); 16146251ddeSWarner Losh void ftree_chk(void); 16246251ddeSWarner Losh int next_file(ARCHD *); 1634b88c807SRodney W. Grimes 1644b88c807SRodney W. Grimes /* 1654b88c807SRodney W. Grimes * gen_subs.c 1664b88c807SRodney W. Grimes */ 16746251ddeSWarner Losh void ls_list(ARCHD *, time_t, FILE *); 16846251ddeSWarner Losh void ls_tty(ARCHD *); 16940feca3aSMark Murray int l_strncpy(char *, const char *, int); 17046251ddeSWarner Losh u_long asc_ul(char *, int, int); 17146251ddeSWarner Losh int ul_asc(u_long, char *, int, int); 1724b88c807SRodney W. Grimes #ifndef NET2_STAT 17346251ddeSWarner Losh u_quad_t asc_uqd(char *, int, int); 17446251ddeSWarner Losh int uqd_asc(u_quad_t, char *, int, int); 1754b88c807SRodney W. Grimes #endif 1764b88c807SRodney W. Grimes 1774b88c807SRodney W. Grimes /* 178b1787decSKris Kennaway * getoldopt.c 179b1787decSKris Kennaway */ 18040feca3aSMark Murray int getoldopt(int, char **, const char *); 181b1787decSKris Kennaway 182b1787decSKris Kennaway /* 1834b88c807SRodney W. Grimes * options.c 1844b88c807SRodney W. Grimes */ 1854b88c807SRodney W. Grimes extern FSUB fsub[]; 1864b88c807SRodney W. Grimes extern int ford[]; 18746251ddeSWarner Losh void options(int, char **); 18846251ddeSWarner Losh OPLIST * opt_next(void); 18940feca3aSMark Murray int opt_add(const char *); 19046251ddeSWarner Losh int bad_opt(void); 191ae824d80SEd Schouten extern char *chdname; 1924b88c807SRodney W. Grimes 1934b88c807SRodney W. Grimes /* 1944b88c807SRodney W. Grimes * pat_rep.c 1954b88c807SRodney W. Grimes */ 19646251ddeSWarner Losh int rep_add(char *); 19746251ddeSWarner Losh int pat_add(char *, char *); 19846251ddeSWarner Losh void pat_chk(void); 19946251ddeSWarner Losh int pat_sel(ARCHD *); 20046251ddeSWarner Losh int pat_match(ARCHD *); 20146251ddeSWarner Losh int mod_name(ARCHD *); 20246251ddeSWarner Losh int set_dest(ARCHD *, char *, int); 2034b88c807SRodney W. Grimes 2044b88c807SRodney W. Grimes /* 2054b88c807SRodney W. Grimes * pax.c 2064b88c807SRodney W. Grimes */ 2074b88c807SRodney W. Grimes extern int act; 2084b88c807SRodney W. Grimes extern FSUB *frmt; 2094b88c807SRodney W. Grimes extern int cflag; 210b1787decSKris Kennaway extern int cwdfd; 2114b88c807SRodney W. Grimes extern int dflag; 2124b88c807SRodney W. Grimes extern int iflag; 2134b88c807SRodney W. Grimes extern int kflag; 2144b88c807SRodney W. Grimes extern int lflag; 2154b88c807SRodney W. Grimes extern int nflag; 2164b88c807SRodney W. Grimes extern int tflag; 2174b88c807SRodney W. Grimes extern int uflag; 2184b88c807SRodney W. Grimes extern int vflag; 2194b88c807SRodney W. Grimes extern int Dflag; 2204b88c807SRodney W. Grimes extern int Hflag; 2214b88c807SRodney W. Grimes extern int Lflag; 222d6e1f8d7SEitan Adler extern int Oflag; 2234b88c807SRodney W. Grimes extern int Xflag; 2244b88c807SRodney W. Grimes extern int Yflag; 2254b88c807SRodney W. Grimes extern int Zflag; 2264b88c807SRodney W. Grimes extern int vfpart; 2274b88c807SRodney W. Grimes extern int patime; 2284b88c807SRodney W. Grimes extern int pmtime; 229b1787decSKris Kennaway extern int nodirs; 2304b88c807SRodney W. Grimes extern int pmode; 2314b88c807SRodney W. Grimes extern int pids; 232b1787decSKris Kennaway extern int rmleadslash; 2334b88c807SRodney W. Grimes extern int exit_val; 2344b88c807SRodney W. Grimes extern int docrc; 2354b88c807SRodney W. Grimes extern char *dirptr; 23640feca3aSMark Murray extern const char *argv0; 237ae824d80SEd Schouten extern sigset_t s_mask; 238b1787decSKris Kennaway extern FILE *listf; 239ffbef1cdSKris Kennaway extern char *tempfile; 240ffbef1cdSKris Kennaway extern char *tempbase; 241ffbef1cdSKris Kennaway 24246251ddeSWarner Losh void sig_cleanup(int); 2434b88c807SRodney W. Grimes 2444b88c807SRodney W. Grimes /* 2454b88c807SRodney W. Grimes * sel_subs.c 2464b88c807SRodney W. Grimes */ 24746251ddeSWarner Losh int sel_chk(ARCHD *); 24846251ddeSWarner Losh int grp_add(char *); 24946251ddeSWarner Losh int usr_add(char *); 25046251ddeSWarner Losh int trng_add(char *); 2514b88c807SRodney W. Grimes 2524b88c807SRodney W. Grimes /* 2534b88c807SRodney W. Grimes * tables.c 2544b88c807SRodney W. Grimes */ 25546251ddeSWarner Losh int lnk_start(void); 25646251ddeSWarner Losh int chk_lnk(ARCHD *); 25746251ddeSWarner Losh void purg_lnk(ARCHD *); 25846251ddeSWarner Losh void lnk_end(void); 25946251ddeSWarner Losh int ftime_start(void); 26046251ddeSWarner Losh int chk_ftime(ARCHD *); 26146251ddeSWarner Losh int name_start(void); 26246251ddeSWarner Losh int add_name(char *, int, char *); 26346251ddeSWarner Losh void sub_name(char *, int *, size_t); 26446251ddeSWarner Losh int dev_start(void); 26546251ddeSWarner Losh int add_dev(ARCHD *); 26646251ddeSWarner Losh int map_dev(ARCHD *, u_long, u_long); 26746251ddeSWarner Losh int atdir_start(void); 26846251ddeSWarner Losh void atdir_end(void); 26946251ddeSWarner Losh void add_atdir(char *, dev_t, ino_t, time_t, time_t); 27046251ddeSWarner Losh int get_atdir(dev_t, ino_t, time_t *, time_t *); 27146251ddeSWarner Losh int dir_start(void); 27246251ddeSWarner Losh void add_dir(char *, int, struct stat *, int); 27346251ddeSWarner Losh void proc_dir(void); 27446251ddeSWarner Losh u_int st_hash(char *, int, int); 2754b88c807SRodney W. Grimes 2764b88c807SRodney W. Grimes /* 2774b88c807SRodney W. Grimes * tar.c 2784b88c807SRodney W. Grimes */ 27946251ddeSWarner Losh int tar_endwr(void); 28046251ddeSWarner Losh off_t tar_endrd(void); 28146251ddeSWarner Losh int tar_trail(char *, int, int *); 28246251ddeSWarner Losh int tar_id(char *, int); 28346251ddeSWarner Losh int tar_opt(void); 28446251ddeSWarner Losh int tar_rd(ARCHD *, char *); 28546251ddeSWarner Losh int tar_wr(ARCHD *); 28646251ddeSWarner Losh int ustar_strd(void); 28746251ddeSWarner Losh int ustar_stwr(void); 28846251ddeSWarner Losh int ustar_id(char *, int); 28946251ddeSWarner Losh int ustar_rd(ARCHD *, char *); 29046251ddeSWarner Losh int ustar_wr(ARCHD *); 2914b88c807SRodney W. Grimes 2924b88c807SRodney W. Grimes /* 2934b88c807SRodney W. Grimes * tty_subs.c 2944b88c807SRodney W. Grimes */ 29546251ddeSWarner Losh int tty_init(void); 29646251ddeSWarner Losh void tty_prnt(const char *, ...) __printflike(1, 2); 29746251ddeSWarner Losh int tty_read(char *, int); 29846251ddeSWarner Losh void paxwarn(int, const char *, ...) __printflike(2, 3); 29946251ddeSWarner Losh void syswarn(int, int, const char *, ...) __printflike(3, 4); 300