try to create a `dumpdates' file if it does not exist
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 24 Jul 1991 06:05:23 +0000 (22:05 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 24 Jul 1991 06:05:23 +0000 (22:05 -0800)
SCCS-vsn: sbin/dump/itime.c 5.8

usr/src/sbin/dump/itime.c

index ad9d3bf..c590260 100644 (file)
@@ -6,11 +6,10 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)itime.c    5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)itime.c    5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
-#include <ufs/dir.h>
 #include <ufs/dinode.h>
 #include <fcntl.h>
 #include <protocols/dumprestore.h>
 #include <ufs/dinode.h>
 #include <fcntl.h>
 #include <protocols/dumprestore.h>
@@ -41,12 +40,26 @@ initdumptimes()
        FILE *df;
 
        if ((df = fopen(dumpdates, "r")) == NULL) {
        FILE *df;
 
        if ((df = fopen(dumpdates, "r")) == NULL) {
-               if (errno == ENOENT) {
-                       msg("WARNING: no file `%s'\n", dumpdates);
-                       return;
+               if (errno != ENOENT) {
+                       quit("cannot read %s: %s\n", dumpdates,
+                           strerror(errno));
+                       /* NOTREACHED */
+               }
+               /*
+                * Dumpdates does not exist, make an empty one.
+                */
+               msg("WARNING: no file `%s', making an empty one\n", dumpdates);
+               if ((df = fopen(dumpdates, "w")) == NULL) {
+                       quit("cannot create %s: %s\n", dumpdates,
+                           strerror(errno));
+                       /* NOTREACHED */
+               }
+               (void) fclose(df);
+               if ((df = fopen(dumpdates, "r")) == NULL) {
+                       quit("cannot read %s even after creating it: %s\n",
+                           dumpdates, strerror(errno));
+                       /* NOTREACHED */
                }
                }
-               quit("cannot read %s: %s\n", dumpdates, strerror(errno));
-               /* NOTREACHED */
        }
        (void) flock(fileno(df), LOCK_SH);
        readdumptimes(df);
        }
        (void) flock(fileno(df), LOCK_SH);
        readdumptimes(df);