Make use of the new FDOPT_NORETRY facility. It does not make sense to
authorJoerg Wunsch <joerg@FreeBSD.org>
Sun, 22 May 1994 17:43:34 +0000 (17:43 +0000)
committerJoerg Wunsch <joerg@FreeBSD.org>
Sun, 22 May 1994 17:43:34 +0000 (17:43 +0000)
verify formatted tracks with fully retryng. The head should not be moved
in either case.
Also some minor copyright cleanup.

usr.sbin/fdformat/Makefile
usr.sbin/fdformat/fdformat.1
usr.sbin/fdformat/fdformat.c

index 209af72..3ee3b4d 100644 (file)
@@ -1,32 +1,9 @@
-# Copyright (C) 1993 by Joerg Wunsch, Dresden
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-#    notice, this list of conditions and the following disclaimer in the
-#    documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
 #
 PROG    = fdformat
 
 # the -I's seem to be confusing, but necessery this way
 # (so the right <unistd.h> will be found in /usr/include, and the
 # "../i386/isa/ic/nec765.h" included from fdreg.h is accessible, too)
 #
 PROG    = fdformat
 
 # the -I's seem to be confusing, but necessery this way
 # (so the right <unistd.h> will be found in /usr/include, and the
 # "../i386/isa/ic/nec765.h" included from fdreg.h is accessible, too)
-CFLAGS+=-Wall -I/usr/include -I/sys/sys
+CFLAGS+= -Wall -I/usr/include -I/sys/sys
 
 .include <bsd.prog.mk>
 
 .include <bsd.prog.mk>
index 78a6b13..2b27f7f 100644 (file)
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
 .\"
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
 .\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
+.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+.\" DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
+.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .Dd September 16, 1993
 .\"
 .Dd September 16, 1993
-.Os FreeBSD
+.Os
 .Dt FDFORMAT 1
 .Sh NAME
 .Nm fdformat
 .Dt FDFORMAT 1
 .Sh NAME
 .Nm fdformat
@@ -57,7 +57,7 @@ or default name in an abbreviated form
 .Pq e.\ g. Em fd0 .
 In the latter case, the name is constructed by prepending
 .Pa /dev/r
 .Pq e.\ g. Em fd0 .
 In the latter case, the name is constructed by prepending
 .Pa /dev/r
-and appending an
+and appending a
 .Em .capacity
 to the
 .Ar device_name .
 .Em .capacity
 to the
 .Ar device_name .
index b88a8ea..6ab7d94 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 1992-1993 by Joerg Wunsch, Dresden
+ * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
 
 /*
  */
 
 /*
@@ -90,7 +90,16 @@ verify_track(int fd, int track, int tracksize)
 {
        static char *buf = 0;
        static int bufsz = 0;
 {
        static char *buf = 0;
        static int bufsz = 0;
-
+       int fdopts = -1, ofdopts, rv = 0;
+
+       if (ioctl(fd, FD_GOPTS, &fdopts) < 0)
+               perror("warning: ioctl(FD_GOPTS)");
+       else {
+               ofdopts = fdopts;
+               fdopts |= FDOPT_NORETRY;
+               (void)ioctl(fd, FD_SOPTS, &fdopts);
+       }
+       
        if (bufsz < tracksize) {
                if (buf)
                        free (buf);
        if (bufsz < tracksize) {
                if (buf)
                        free (buf);
@@ -104,10 +113,14 @@ verify_track(int fd, int track, int tracksize)
                exit (2);
        }
        if (lseek (fd, (long) track*tracksize, 0) < 0)
                exit (2);
        }
        if (lseek (fd, (long) track*tracksize, 0) < 0)
-               return (-1);
-       if (read (fd, buf, tracksize) != tracksize)
-               return (-1);
-       return (0);
+               rv = -1;
+       /* try twice reading it, without using the normal retrier */
+       else if (read (fd, buf, tracksize) != tracksize
+                && read (fd, buf, tracksize) != tracksize)
+               rv = -1;
+       if(fdopts != -1)
+               (void)ioctl(fd, FD_SOPTS, &ofdopts);
+       return (rv);
 }
 
 static const char *
 }
 
 static const char *
@@ -127,7 +140,7 @@ makename(const char *arg, const char *suffix)
 }
 
 static void
 }
 
 static void
-usage ()
+usage (void)
 {
        printf("Usage:\n\tfdformat [-q] [-n | -v] [-f #] [-c #] [-s #] [-h #]\n");
        printf("\t\t [-r #] [-g #] [-i #] [-S #] [-F #] [-t #] devname\n");
 {
        printf("Usage:\n\tfdformat [-q] [-n | -v] [-f #] [-c #] [-s #] [-h #]\n");
        printf("\t\t [-r #] [-g #] [-i #] [-S #] [-F #] [-t #] devname\n");
@@ -152,7 +165,7 @@ usage ()
 }
 
 static int
 }
 
 static int
-yes ()
+yes (void)
 {
        char reply [256], *p;
 
 {
        char reply [256], *p;
 
@@ -353,3 +366,18 @@ main(int argc, char **argv)
 
        return errs;
 }
 
        return errs;
 }
+/*
+ * Local Variables:
+ *  c-indent-level:               8
+ *  c-continued-statement-offset: 8
+ *  c-continued-brace-offset:     0
+ *  c-brace-offset:              -8
+ *  c-brace-imaginary-offset:     0
+ *  c-argdecl-indent:             8
+ *  c-label-offset:              -8
+ *  c++-hanging-braces:           1
+ *  c++-access-specifier-offset: -8
+ *  c++-empty-arglist-indent:     8
+ *  c++-friend-offset:            0
+ * End:
+ */