don't write empty directories back if initial read fails!
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Thu, 4 Sep 1986 08:04:35 +0000 (00:04 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Thu, 4 Sep 1986 08:04:35 +0000 (00:04 -0800)
SCCS-vsn: old/arff/arff.c 5.3

usr/src/old/arff/arff.c

index 38fc24d..1bf9678 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)arff.c     5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)arff.c     5.3 (Berkeley) %G%";
 #endif not lint
 
 #include <sys/types.h>
 #endif not lint
 
 #include <sys/types.h>
@@ -340,7 +340,7 @@ rtx(name)
                count = dope->count;
                startad = dope->startad;
                for( ; count > 0 ; count -= 512) {
                count = dope->count;
                startad = dope->startad;
                for( ; count > 0 ; count -= 512) {
-                       lread(startad, 512, buff);
+                       (void) lread(startad, 512, buff);
                        (void) write(file, buff, 512);
                        startad += 512;
                }
                        (void) write(file, buff, 512);
                        startad += 512;
                }
@@ -389,7 +389,8 @@ ignore:
        } else
                floppydes = fileno(temp_floppydes);
        if (!flag(c)) {
        } else
                floppydes = fileno(temp_floppydes);
        if (!flag(c)) {
-               lread(6*RT_BLOCK, 2*RT_BLOCK, (char *)&rt_dir[0]);
+               if (lread(6*RT_BLOCK, 2*RT_BLOCK, (char *)&rt_dir[0]))
+                       exit(2);
                dirnum = rt_dir[0].rd_numseg;
                /* check for blank/uninitialized diskette */
                if (dirnum <= 0) {
                dirnum = rt_dir[0].rd_numseg;
                /* check for blank/uninitialized diskette */
                if (dirnum <= 0) {
@@ -401,7 +402,8 @@ ignore:
                        exit(1);
                }
                for (i = 1; i < dirnum; i++)
                        exit(1);
                }
                for (i = 1; i < dirnum; i++)
-                       lread((6+2*i)*RT_BLOCK, 2*RT_BLOCK, (char *)&rt_dir[i]);
+                   if (lread((6+2*i)*RT_BLOCK, 2*RT_BLOCK, (char *)&rt_dir[i]))
+                       exit(1);
        } else {
                dirnum = 1;
                if (flag(b)) {
        } else {
                dirnum = 1;
                if (flag(b)) {
@@ -634,17 +636,24 @@ lread(startad, count, obuff)
        long trans();
        extern floppydes;
        register int size = flag(m) ? 512 : 128;
        long trans();
        extern floppydes;
        register int size = flag(m) ? 512 : 128;
+       int error = 0;
+       extern int errno;
 
        rt_init();
        while ((count -= size) >= 0) {
                (void) lseek(floppydes, flag(m) ?
                        (long)startad : trans(startad), 0);
 
        rt_init();
        while ((count -= size) >= 0) {
                (void) lseek(floppydes, flag(m) ?
                        (long)startad : trans(startad), 0);
-               if (read(floppydes, obuff, size) != size)
-                       fprintf(stderr, "arff: read error block %d\n",
+               if (read(floppydes, obuff, size) != size) {
+                       error = errno;
+                       fprintf(stderr, "arff: read error block %d: ",
                                startad/size);
                                startad/size);
+                       errno = error;
+                       perror("");
+               }
                obuff += size;
                startad += size;
        }
                obuff += size;
                startad += size;
        }
+       return (error);
 }
 
 lwrite(startad, count, obuff)
 }
 
 lwrite(startad, count, obuff)