From 2e6828953e9c505e76a17eec441fc714c6579922 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Fri, 7 Jan 2000 19:23:53 +0000 Subject: [PATCH] Handle EINTR in atomical reads/writes in dump. Handle more than 16 characters for the device names in dumpdates. Fixed a bug in dump which prevented the creation of the dumpdates file when doing a 0-level dump. Changed the way dump 'S' flag reports the size estimate from number of blocks into bytes. --- CHANGES | 21 ++++++++++++++++- THANKS | 6 ++++- TODO | 14 ++++++----- compat/include/protocols/dumprestore.h | 6 +---- dump/dump.8.in | 4 ++-- dump/itime.c | 32 ++++++++++++++++++++------ dump/main.c | 4 ++-- dump/tape.c | 14 +++++++---- 8 files changed, 72 insertions(+), 29 deletions(-) diff --git a/CHANGES b/CHANGES index e077b26..2e3f13d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.27 1999/12/17 10:21:30 tiniou Exp $ +$Id: CHANGES,v 1.28 2000/01/07 19:23:53 tiniou Exp $ Changes between versions 0.4b11 and 0.4b12 (released ????????????????) ====================================================================== @@ -10,6 +10,25 @@ Changes between versions 0.4b11 and 0.4b12 (released ????????????????) dump. Thanks to Matti Taskinen for submitting the patch. +3. Handle EINTR in atomical reads/writes in dump, which was causing + dump to fail on some systems. Thanks to Eric Jergensen + for reporting the bug and submitting the patch. + +4. Handle more than 16 characters for the device names in dumpdates. + (up to 255 now). Thanks to Rainer Clasen for + tracking down the problem and proposing the solution. + +5. Fixed a bug in dump which prevented the creation of the + dumpdates file when doing a 0-level dump without already + having a dumpdates file. Thanks to Patrik Schindler + for reporting the bug. + +6. Changed the way dump 'S' flag reports the size estimate + from number of blocks into bytes (making it compatible + with the Solaris version, and simplifying things for + amanda users). Thanks to Jason L Tibbitts III + for reporting the bug. + Changes between versions 0.4b10 and 0.4b11 (released December 5, 1999) ====================================================================== diff --git a/THANKS b/THANKS index ff5f962..ca81cb3 100644 --- a/THANKS +++ b/THANKS @@ -1,4 +1,4 @@ -$Id: THANKS,v 1.14 1999/12/17 10:14:27 tiniou Exp $ +$Id: THANKS,v 1.15 2000/01/07 19:23:53 tiniou Exp $ Dump and restore were written by the people of the CSRG at the University of California, Berkeley. @@ -24,10 +24,12 @@ Here is a partial list of them (if I have forgotten someone, please complain): Stephen Carr sgcarr@civeng.adelaide.edu.au Rob Cermak cermak@ahab.rutgers.edu +Rainer Clasen bj@ncc.cicely.de Abhijit Dasgupta abhijit@ans.net Jason Fearon jasonf@netrider.org.au Jeremy Fitzhardinge jeremy@goop.org Eirik Fuller eirik@netcom.com +Eric Jergensen eric@dvns.com Henry Katz hkatz@hkatz.dialup.access.net Klaus Kudielka kkudielk@cacofonix.nt.tuwien.ac.at Thorsten Kukuk kukuk@suse.de @@ -41,9 +43,11 @@ Lukas Nellen L.Nellen@ThPhys.Uni-Heidelberg.DE Nuno Oliveira nuno@eq.uc.pt Brent Olson night@halcyon.com Bernhard Sadlowski sadlowsk@Mathematik.Uni-Bielefeld.DE +Patrik Schindler poc@pocnet.net Chris Siebenmann cks@utcc.utoronto.ca Bob Snyder rsnyder@janet.advsys.com Matti Taskinen mkt@rni.helsinki.fi +Jason L Tibbitts III tibbs@math.uh.edu Theodore Y. Ts'o tytso@mit.edu Stephen Tweedie sct@dcs.ed.ac.uk Daniel Veillard Daniel.Veillard@imag.fr diff --git a/TODO b/TODO index bdb4783..ae08d2c 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -$Id: TODO,v 1.8 1999/11/21 02:24:45 tiniou Exp $ +$Id: TODO,v 1.9 2000/01/07 19:23:53 tiniou Exp $ Need to verify: --------------- @@ -34,9 +34,11 @@ All others: 6. Add a compression mode using zlib on each file (see http://www.cdrom.com/pub/infozip/zlib). -7. Add some support in dump and restore for numbering in sequence - the output files (when dumping to a file). Something like -N - which creates (or reads) -1, -2 etc... - -8. Make a bootable dump tape? I don't know if it is possible... +7. Make a bootable dump tape? I don't know if it is possible... +8. From Kjetil Torgrim Homme : + a archive_file + Archive file. Archive a dump table-of-contents in + the specified archive_file to be used by + ufsrestore(1M) to determine whether a file is in + the dump file that is being restored. diff --git a/compat/include/protocols/dumprestore.h b/compat/include/protocols/dumprestore.h index 4985f80..0d6e0c8 100644 --- a/compat/include/protocols/dumprestore.h +++ b/compat/include/protocols/dumprestore.h @@ -43,7 +43,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: dumprestore.h,v 1.3 1999/10/11 13:31:09 stelian Exp $ + * $Id: dumprestore.h,v 1.4 2000/01/07 19:24:04 tiniou Exp $ */ #ifndef _PROTOCOLS_DUMPRESTORE_H_ @@ -117,8 +117,4 @@ union u_spcl { #define DR_NEWHEADER 0x0001 /* new format tape header */ #define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */ -#define DUMPOUTFMT "%-16s %c %s" /* for printf */ - /* name, level, ctime(date) */ -#define DUMPINFMT "%16s %c %[^\n]\n" /* inverse for scanf */ - #endif /* !_DUMPRESTORE_H_ */ diff --git a/dump/dump.8.in b/dump/dump.8.in index a6f0e52..064d980 100644 --- a/dump/dump.8.in +++ b/dump/dump.8.in @@ -30,7 +30,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: dump.8.in,v 1.7 1999/12/06 21:37:50 tiniou Exp $ +.\" $Id: dump.8.in,v 1.8 2000/01/07 19:24:04 tiniou Exp $ .\" .Dd __DATE__ .Dt DUMP 8 @@ -230,7 +230,7 @@ The default tape length is 2300 feet. Size estimate. Determine the amount of space that is needed to perform the dump without actually doing it, and display the estimated -number of blocks it will take. This is useful +number of bytes it will take. This is useful with incremental dumps to determine how many volumes of media will be needed. .It Fl T Ar date diff --git a/dump/itime.c b/dump/itime.c index 6279225..e9a9802 100644 --- a/dump/itime.c +++ b/dump/itime.c @@ -40,7 +40,7 @@ #ifndef lint static const char rcsid[] = - "$Id: itime.c,v 1.7 1999/10/31 19:48:28 tiniou Exp $"; + "$Id: itime.c,v 1.8 2000/01/07 19:24:04 tiniou Exp $"; #endif /* not lint */ #include @@ -168,10 +168,11 @@ getdumptime(int createdumpdates) spcl.c_ddate = 0; lastlevel = '0'; - /* If this is a level 0 dump, there's no point in trying to read + /* If this is a level 0 dump, and we're not updating + dumpdates, there's no point in trying to read dumpdates. It may not exist yet, or may not be mounted. For incrementals, we *must* read dumpdates (fail if it's not there!) */ - if (level == lastlevel) + if ( (level == lastlevel) && !createdumpdates) return; initdumptimes(createdumpdates); if (ddatev == NULL) @@ -261,7 +262,7 @@ static void dumprecout(FILE *file, struct dumpdates *what) { - if (fprintf(file, DUMPOUTFMT, + if (fprintf(file, "%s %c %s", what->dd_name, what->dd_level, ctime(&what->dd_ddate)) < 0) @@ -293,10 +294,27 @@ getrecord(FILE *df, struct dumpdates *ddatep) static int makedumpdate(struct dumpdates *ddp, char *tbuf) { - char un_buf[BUFSIZ]; + char *tok; + + /* device name */ + if ( NULL == (tok = strsep( &tbuf, " ")) ) + return(-1); + if ( strlen(tok) > NAME_MAX ) + return(-1); + strcpy(ddp->dd_name, tok); + + /* eat whitespace */ + for( ; *tbuf == ' ' ; tbuf++); + + /* dump level */ + ddp->dd_level = *tbuf; + ++tbuf; + + /* eat whitespace */ + for( ; *tbuf == ' ' ; tbuf++); - (void) sscanf(tbuf, DUMPINFMT, ddp->dd_name, &ddp->dd_level, un_buf); - ddp->dd_ddate = unctime(un_buf); + /* dump date */ + ddp->dd_ddate = unctime(tbuf); if (ddp->dd_ddate < 0) return(-1); return(0); diff --git a/dump/main.c b/dump/main.c index 3c56b84..3a371b1 100644 --- a/dump/main.c +++ b/dump/main.c @@ -40,7 +40,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.10 1999/12/17 10:14:59 tiniou Exp $"; + "$Id: main.c,v 1.11 2000/01/07 19:24:04 tiniou Exp $"; #endif /* not lint */ #include @@ -514,7 +514,7 @@ main(int argc, char *argv[]) } if (sizest) { - printf("%ld\n", tapesize + 10); + printf("%.0f\n", ((double)tapesize + 10) * TP_BSIZE); exit(X_FINOK); } /* stop here for size estimate */ diff --git a/dump/tape.c b/dump/tape.c index 7790cc4..c080198 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -40,7 +40,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.9 1999/11/21 16:01:47 tiniou Exp $"; + "$Id: tape.c,v 1.10 2000/01/07 19:24:04 tiniou Exp $"; #endif /* not lint */ #ifdef __linux__ @@ -1029,8 +1029,10 @@ atomic_read(int fd, void *buf, size_t count) { int got, need = count; - while ((got = read(fd, buf, need)) > 0 && (need -= got) > 0) - (char *)buf += got; + do { + while ((got = read(fd, buf, need)) > 0 && (need -= got) > 0) + (char *)buf += got; + } while (got == -1 && errno == EINTR); return (got < 0 ? got : count - need); } @@ -1044,7 +1046,9 @@ atomic_write(int fd, const void *buf, size_t count) { int got, need = count; - while ((got = write(fd, buf, need)) > 0 && (need -= got) > 0) - (char *)buf += got; + do { + while ((got = write(fd, buf, need)) > 0 && (need -= got) > 0) + (char *)buf += got; + } while (got == -1 && errno == EINTR); return (got < 0 ? got : count - need); } -- 2.39.2