From 42bcc624fe21059d5e550e90befb3553c17e2858 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Tue, 5 Dec 2000 15:43:48 +0000 Subject: [PATCH] Check for 'file system full' when creating temporary files. --- CHANGES | 9 ++++++++- THANKS | 3 ++- restore/dirs.c | 20 +++++++++++++------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 3a4df88..f71417f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.94 2000/12/04 16:05:35 stelian Exp $ +$Id: CHANGES,v 1.95 2000/12/05 15:43:48 stelian Exp $ Changes between versions 0.4b20 and 0.4b21 (released ?????????????????) ======================================================================= @@ -15,6 +15,13 @@ Changes between versions 0.4b20 and 0.4b21 (released ?????????????????) _PATH_MNTTAB being undefined. Thanks to John Adams for reporting the bug. +4. Improved the error detection in restore when creating + the temporary files in TMPDIR. Now restore will corectly + report a 'no space left on device' error instead of + strange errors which could imply an archive corruption. + Thanks to Gabriel Somlo and + bgjenero for reporting the bug. + Changes between versions 0.4b19 and 0.4b20 (released November 10, 2000) ======================================================================= diff --git a/THANKS b/THANKS index 8142560..4992ea1 100644 --- a/THANKS +++ b/THANKS @@ -1,4 +1,4 @@ -$Id: THANKS,v 1.40 2000/12/04 16:05:35 stelian Exp $ +$Id: THANKS,v 1.41 2000/12/05 15:43:48 stelian Exp $ Dump and restore were written by the people of the CSRG at the University of California, Berkeley. @@ -63,6 +63,7 @@ Patrik Schindler poc@pocnet.net Gunther Schlegel schlegel@riege.de Chris Siebenmann cks@utcc.utoronto.ca Bob Snyder rsnyder@janet.advsys.com +Gabriel Somlo somlo@cs.colostate.edu Matti Taskinen mkt@rni.helsinki.fi Jason L Tibbitts III tibbs@math.uh.edu Mike Tibor tibor@lib.uaa.alaska.edu diff --git a/restore/dirs.c b/restore/dirs.c index 5241284..3d91c3c 100644 --- a/restore/dirs.c +++ b/restore/dirs.c @@ -46,7 +46,7 @@ #ifndef lint static const char rcsid[] = - "$Id: dirs.c,v 1.11 2000/12/04 15:43:17 stelian Exp $"; + "$Id: dirs.c,v 1.12 2000/12/05 15:43:49 stelian Exp $"; #endif /* not lint */ #include @@ -208,12 +208,13 @@ extractdirs(int genmode) curfile.action = USING; ip = curfile.dip; if (ip == NULL || (ip->di_mode & IFMT) != IFDIR) { - (void) fclose(df); + if ( fclose(df) == EOF ) + err(1, "cannot write to file %s", dirfile); dirp = opendirfile(dirfile); if (dirp == NULL) warn("opendirfile"); - if (mf != NULL) - (void) fclose(mf); + if (mf != NULL && fclose(mf) == EOF ) + err(1, "cannot write to file %s", dirfile); i = dirlookup(dot); if (i == 0) panic("Root directory is not on tape\n"); @@ -439,7 +440,8 @@ putent(struct direct *dp) if (dirloc + dp->d_reclen > DIRBLKSIZ) { ((struct direct *)(dirbuf + prev))->d_reclen = DIRBLKSIZ - prev; - (void) fwrite(dirbuf, 1, DIRBLKSIZ, df); + if ( fwrite(dirbuf, 1, DIRBLKSIZ, df) != DIRBLKSIZ ) + err(1,"cannot write to file %s", dirfile); dirloc = 0; } memmove(dirbuf + dirloc, dp, (size_t)dp->d_reclen); @@ -454,8 +456,11 @@ static void flushent(void) { ((struct direct *)(dirbuf + prev))->d_reclen = DIRBLKSIZ - prev; - (void) fwrite(dirbuf, (int)dirloc, 1, df); + if ( fwrite(dirbuf, (int)dirloc, 1, df) != 1 ) + err(1, "cannot write to file %s", dirfile); seekpt = ftell(df); + if (seekpt == -1) + err(1, "cannot write to file %s", dirfile); dirloc = 0; } @@ -748,7 +753,8 @@ allocinotab(ino_t ino, struct dinode *dip, long seekpt) node.flags = dip->di_flags; node.uid = dip->di_uid; node.gid = dip->di_gid; - (void) fwrite((char *)&node, 1, sizeof(struct modeinfo), mf); + if ( fwrite((char *)&node, 1, sizeof(struct modeinfo), mf) != sizeof(struct modeinfo) ) + err(1,"cannot write to file %s", modefile); return (itp); } -- 2.39.2