From: mortimer Date: Thu, 21 Jan 2021 00:16:36 +0000 (+0000) Subject: Rearrange variables in dump / restore to handle -fno-common. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9be7043ffd0d162f30fbb5ad6b7f73fc5d6b2819;p=openbsd Rearrange variables in dump / restore to handle -fno-common. Largely following the commit by mckusick in FreeBSD. ok naddy@ --- diff --git a/include/protocols/dumprestore.h b/include/protocols/dumprestore.h index 9a94a0c9e1e..05b99a7b068 100644 --- a/include/protocols/dumprestore.h +++ b/include/protocols/dumprestore.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dumprestore.h,v 1.10 2014/07/11 16:01:40 halex Exp $ */ +/* $OpenBSD: dumprestore.h,v 1.11 2021/01/21 00:16:36 mortimer Exp $ */ /* $NetBSD: dumprestore.h,v 1.14 2005/12/26 19:01:47 perry Exp $ */ /* @@ -66,7 +66,7 @@ #endif #define CHECKSUM (int)84446 -union u_spcl { +extern union u_spcl { char dummy[TP_BSIZE]; struct s_spcl { int32_t c_type; /* record type (see below) */ diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h index 83023c68773..f2f8cb4528f 100644 --- a/sbin/dump/dump.h +++ b/sbin/dump/dump.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dump.h,v 1.24 2015/05/23 05:17:20 guenther Exp $ */ +/* $OpenBSD: dump.h,v 1.25 2021/01/21 00:16:36 mortimer Exp $ */ /* $NetBSD: dump.h,v 1.11 1997/06/05 11:13:20 lukem Exp $ */ /*- @@ -35,10 +35,10 @@ /* * Dump maps used to describe what is to be dumped. */ -int mapsize; /* size of the state maps */ -char *usedinomap; /* map of allocated inodes */ -char *dumpdirmap; /* map of directories to be dumped */ -char *dumpinomap; /* map of files to be dumped */ +extern int mapsize; /* size of the state maps */ +extern char *usedinomap; /* map of allocated inodes */ +extern char *dumpdirmap; /* map of directories to be dumped */ +extern char *dumpinomap; /* map of files to be dumped */ /* * Map manipulation macros. */ @@ -52,35 +52,35 @@ char *dumpinomap; /* map of files to be dumped */ /* * All calculations done in 0.1" units! */ -char *disk; /* name of the disk file */ -char *tape; /* name of the tape file */ -char *dumpdates; /* name of the file containing dump date information*/ -char *temp; /* name of the file for doing rewrite of dumpdates */ -char *duid; /* duid of the disk being dumped */ -char lastlevel; /* dump level of previous dump */ -char level; /* dump level of this dump */ -int uflag; /* update flag */ -int diskfd; /* disk file descriptor */ -int tapefd; /* tape file descriptor */ -int pipeout; /* true => output to standard output */ -ino_t curino; /* current inumber; used globally */ -int newtape; /* new tape flag */ -int density; /* density in 0.1" units */ -int64_t tapesize; /* estimated tape size, blocks */ -int64_t tsize; /* tape size in 0.1" units */ -int unlimited; /* if set, write to end of medium */ -int64_t asize; /* number of 0.1" units written on current tape */ -int etapes; /* estimated number of tapes */ -int nonodump; /* if set, do not honor UF_NODUMP user flags */ - -int notify; /* notify operator flag */ -int64_t blockswritten; /* number of blocks written on current tape */ -int tapeno; /* current tape number */ -time_t tstart_writing; /* when started writing the first tape block */ -long xferrate; /* averaged transfer rate of all volumes */ -struct fs *sblock; /* the file system super block */ -char sblock_buf[MAXBSIZE]; -int tp_bshift; /* log2(TP_BSIZE) */ +extern char *disk; /* name of the disk file */ +extern char *tape; /* name of the tape file */ +extern char *dumpdates; /* name of the file containing dump date information*/ +extern char *duid; /* duid of the disk being dumped */ +extern char lastlevel; /* dump level of previous dump */ +extern char level; /* dump level of this dump */ +extern int uflag; /* update flag */ +extern int diskfd; /* disk file descriptor */ +extern int pipeout; /* true => output to standard output */ +extern ino_t curino; /* current inumber; used globally */ +extern int newtape; /* new tape flag */ +extern int density; /* density in 0.1" units */ +extern int64_t tapesize; /* estimated tape size, blocks */ +extern int64_t tsize; /* tape size in 0.1" units */ +extern int unlimited; /* if set, write to end of medium */ +extern int etapes; /* estimated number of tapes */ +extern int nonodump; /* if set, do not honor UF_NODUMP user flags */ +extern int notify; /* notify operator flag */ +extern int64_t blockswritten; /* number of blocks written on current tape */ +extern int tapeno; /* current tape number */ +extern int ntrec; /* blocking factor on tape */ +extern int64_t blocksperfile; /* number of blocks per output file */ +extern int cartridge; /* assume non-cartridge tape */ +extern char *host; /* remote host (if any) */ +extern time_t tstart_writing; /* when started writing the first tape block */ +extern long xferrate; /* averaged transfer rate of all volumes */ +extern struct fs *sblock; /* the file system super block */ +extern char sblock_buf[MAXBSIZE]; +extern int tp_bshift; /* log2(TP_BSIZE) */ /* operator interface functions */ void broadcast(char *message); @@ -163,10 +163,10 @@ struct dumptime { struct dumpdates dt_value; struct dumptime *dt_next; }; -struct dumptime *dthead; /* head of the list version */ -int nddates; /* number of records (might be zero) */ -int ddates_in; /* we have read the increment file */ -struct dumpdates **ddatev; /* the arrayfied version */ +extern struct dumptime *dthead; /* head of the list version */ +extern int ddates_in; /* we have read the increment file */ +extern int nddates; /* number of records (might be zero) */ +extern struct dumpdates **ddatev; /* the arrayfied version */ void initdumptimes(void); void getdumptime(void); void putdumptime(void); diff --git a/sbin/dump/dumprmt.c b/sbin/dump/dumprmt.c index 9cf7b6e09a0..ad8fa99520b 100644 --- a/sbin/dump/dumprmt.c +++ b/sbin/dump/dumprmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dumprmt.c,v 1.30 2019/06/28 13:32:43 deraadt Exp $ */ +/* $OpenBSD: dumprmt.c,v 1.31 2021/01/21 00:16:36 mortimer Exp $ */ /* $NetBSD: dumprmt.c,v 1.17 1997/06/05 16:10:47 mrg Exp $ */ /*- @@ -80,7 +80,6 @@ int rmtseek(int offset, int pos); int rmtioctl(int cmd, int count); void rmtclose(void); -extern int ntrec; /* blocking factor on tape */ int rmthost(char *host) diff --git a/sbin/dump/itime.c b/sbin/dump/itime.c index 4ab4bfe3406..0cd11f18150 100644 --- a/sbin/dump/itime.c +++ b/sbin/dump/itime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: itime.c,v 1.24 2019/06/28 13:32:43 deraadt Exp $ */ +/* $OpenBSD: itime.c,v 1.25 2021/01/21 00:16:36 mortimer Exp $ */ /* $NetBSD: itime.c,v 1.4 1997/04/15 01:09:50 lukem Exp $ */ /*- @@ -47,8 +47,10 @@ #include "dump.h" -struct dumpdates **ddatev = NULL; int nddates = 0; +struct dumpdates **ddatev = NULL; +char *dumpdates = NULL; +char lastlevel = 0; int ddates_in = 0; struct dumptime *dthead = NULL; diff --git a/sbin/dump/main.c b/sbin/dump/main.c index 93d74728782..0370be54883 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.61 2019/06/28 13:32:43 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.62 2021/01/21 00:16:36 mortimer Exp $ */ /* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */ /*- @@ -60,15 +60,36 @@ #include "dump.h" #include "pathnames.h" -int notify = 0; /* notify operator flag */ -int64_t blockswritten = 0; /* number of blocks written on current tape */ -int tapeno = 0; /* current tape number */ -int density = 0; /* density in bytes/0.1" */ -int ntrec = NTREC; /* # tape blocks in each tape record */ -int cartridge = 0; /* Assume non-cartridge tape */ -int64_t blocksperfile; /* output blocks per file */ -char *host = NULL; /* remote host (if any) */ -int maxbsize = 64*1024; /* XXX MAXBSIZE from sys/param.h */ +int mapsize; /* size of the state maps */ +char *usedinomap; /* map of allocated inodes */ +char *dumpdirmap; /* map of directories to be dumped */ +char *dumpinomap; /* map of files to be dumped */ +char *disk; /* name of the disk file */ +char *tape; /* name of the tape file */ +char level; /* dump level of this dump */ +int uflag; /* update flag */ +int diskfd; /* disk file descriptor */ +int pipeout; /* true => output to standard output */ +int density = 0; /* density in bytes/0.1" */ +int64_t tapesize; /* estimated tape size, blocks */ +int64_t tsize; /* tape size in 0.1" units */ +int etapes; /* estimated number of tapes */ +int nonodump; /* if set, do not honor UF_NODUMP user flags */ +int unlimited; /* if set, write to end of medium */ +int notify = 0; /* notify operator flag */ +int64_t blockswritten = 0; /* number of blocks written on current tape */ +int tapeno = 0; /* current tape number */ +int ntrec = NTREC; /* # tape blocks in each tape record */ +int64_t blocksperfile; /* output blocks per file */ +int cartridge = 0; /* Assume non-cartridge tape */ +char *host = NULL; /* remote host (if any) */ +time_t tstart_writing; /* when started writing the first tape block */ +long xferrate; /* averaged transfer rate of all volumes */ +struct fs *sblock; /* the file system super block */ +char sblock_buf[MAXBSIZE]; +int tp_bshift; /* log2(TP_BSIZE) */ +char *duid; /* duid of the disk being dumped */ +int maxbsize = 64*1024; /* XXX MAXBSIZE from sys/param.h */ struct disklabel lab; @@ -106,7 +127,6 @@ main(int argc, char *argv[]) if ((tape = getenv("TAPE")) == NULL) tape = _PATH_DEFTAPE; dumpdates = _PATH_DUMPDATES; - temp = _PATH_DTMP; if (TP_BSIZE / DEV_BSIZE == 0 || TP_BSIZE % DEV_BSIZE != 0) quit("TP_BSIZE must be a multiple of DEV_BSIZE\n"); level = '0'; diff --git a/sbin/dump/pathnames.h b/sbin/dump/pathnames.h index 0686fede7ef..bbd0b938d20 100644 --- a/sbin/dump/pathnames.h +++ b/sbin/dump/pathnames.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pathnames.h,v 1.6 2003/06/02 20:06:14 millert Exp $ */ +/* $OpenBSD: pathnames.h,v 1.7 2021/01/21 00:16:36 mortimer Exp $ */ /* $NetBSD: pathnames.h,v 1.9 1997/04/15 07:00:47 lukem Exp $ */ /* @@ -34,7 +34,6 @@ #include -#define _PATH_DTMP "/etc/dtmp" #define _PATH_DUMPDATES "/etc/dumpdates" #define _PATH_LOCK "/tmp/dumplockXXXXXX" #define _PATH_RMT "/etc/rmt" diff --git a/sbin/dump/tape.c b/sbin/dump/tape.c index 68c1fe22435..3bedb451f81 100644 --- a/sbin/dump/tape.c +++ b/sbin/dump/tape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tape.c,v 1.46 2020/10/01 07:58:54 otto Exp $ */ +/* $OpenBSD: tape.c,v 1.47 2021/01/21 00:16:36 mortimer Exp $ */ /* $NetBSD: tape.c,v 1.11 1997/06/05 11:13:26 lukem Exp $ */ /*- @@ -55,15 +55,17 @@ #define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) -int writesize; /* size of malloc()ed buffer for tape */ -int64_t lastspclrec = -1; /* tape block number of last written header */ -int trecno = 0; /* next record to write in current block */ -extern int64_t blocksperfile; /* number of blocks per output file */ -int64_t blocksthisvol; /* number of blocks on current output file */ -extern int ntrec; /* blocking factor on tape */ -extern int cartridge; -extern char *host; -char *nexttape; +ino_t curino; /* current inumber; used globally */ +int newtape; /* new tape flag */ +union u_spcl u_spcl; /* mapping of variables in a control block */ + +static int tapefd; /* tape file descriptor */ +static int64_t asize; /* number of 0.1" units written on cur tape */ +static int writesize; /* size of malloc()ed buffer for tape */ +static int64_t lastspclrec = -1; /* tape block number of last written header */ +static int trecno = 0; /* next record to write in current block */ +static int64_t blocksthisvol; /* number of blocks on current output file */ +static char *nexttape; static ssize_t atomic(ssize_t (*)(int, void *, size_t), int, char *, int); static void doslave(int, int); @@ -88,10 +90,10 @@ struct req { daddr_t dblk; int count; }; -int reqsiz; +static int reqsiz; #define SLAVES 3 /* 1 slave writing, 1 reading, 1 for slack */ -struct slave { +static struct slave { int64_t tapea; /* header number at start of this chunk */ int64_t firstrec; /* record number of this block */ int count; /* count to next header (used for TS_TAPE */ @@ -103,15 +105,15 @@ struct slave { char (*tblock)[TP_BSIZE]; /* buffer for data blocks */ struct req *req; /* buffer for requests */ } slaves[SLAVES+1]; -struct slave *slp; +static struct slave *slp; -char (*nextblock)[TP_BSIZE]; +static char (*nextblock)[TP_BSIZE]; static time_t tstart_volume; /* time of volume start */ static int64_t tapea_volume; /* value of spcl.c_tapea at volume start */ -pid_t master; /* pid of master, for sending error signals */ -int tenths; /* length of tape used per block written */ +static pid_t master; /* pid of master, for sending error signals */ +static int tenths; /* length of tape used per block written */ static volatile sig_atomic_t caught; /* have we caught the signal to proceed? */ int diff --git a/sbin/restore/restore.h b/sbin/restore/restore.h index 714830e9a3c..2420d9e18ae 100644 --- a/sbin/restore/restore.h +++ b/sbin/restore/restore.h @@ -1,4 +1,4 @@ -/* $OpenBSD: restore.h,v 1.9 2017/01/21 08:31:44 krw Exp $ */ +/* $OpenBSD: restore.h,v 1.10 2021/01/21 00:16:36 mortimer Exp $ */ /* $NetBSD: restore.h,v 1.8 1997/07/01 05:37:54 lukem Exp $ */ /* @@ -104,7 +104,7 @@ struct entry { /* * The entry describes the next file available on the tape */ -struct context { +extern struct context { short action; /* action being taken on this file */ mode_t mode; /* mode of file */ ino_t ino; /* inumber of file */ diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c index 324ec6378d8..0e2c693cd2a 100644 --- a/sbin/restore/tape.c +++ b/sbin/restore/tape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tape.c,v 1.51 2019/06/28 13:32:46 deraadt Exp $ */ +/* $OpenBSD: tape.c,v 1.52 2021/01/21 00:16:36 mortimer Exp $ */ /* $NetBSD: tape.c,v 1.26 1997/04/15 07:12:25 lukem Exp $ */ /* @@ -78,6 +78,8 @@ static char *map; static char lnkbuf[PATH_MAX + 1]; static size_t pathlen; +struct context curfile; /* describes next file available on the tape */ +union u_spcl u_spcl; /* mapping of variables in a control block */ int oldinofmt; /* old inode format conversion required */ int Bcvt; /* Swap Bytes (for CCI or sun) */