The following diff switches fsck_msdos to opendev() so that it works with
disklabel UIDs (DUIDs). The output is also changed to follow fsck_ffs(8)
(i.e. print the realname then the DUID in brackets).

ok?

Index: Makefile
===================================================================
RCS file: /cvs/src/sbin/fsck_msdos/Makefile,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile
--- Makefile    21 Sep 1997 11:36:40 -0000      1.4
+++ Makefile    13 Nov 2010 16:30:36 -0000
@@ -3,7 +3,9 @@
 PROG=  fsck_msdos
 MAN=   fsck_msdos.8
 SRCS=  main.c check.c boot.c fat.c dir.c fsutil.c
-CFLAGS+= -I${.CURDIR}/../fsck
 .PATH: ${.CURDIR}/../fsck
+CFLAGS+= -I${.CURDIR}/../fsck
+DPADD+=        ${LIBUTIL}
+LDADD+=        -lutil
 
 .include <bsd.prog.mk>
Index: check.c
===================================================================
RCS file: /cvs/src/sbin/fsck_msdos/check.c,v
retrieving revision 1.12
diff -u -p -r1.12 check.c
--- check.c     27 Oct 2009 23:59:33 -0000      1.12
+++ check.c     13 Nov 2010 16:30:36 -0000
@@ -33,6 +33,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <sys/param.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
@@ -48,29 +49,31 @@ checkfilesys(const char *fname)
        int dosfs;
        struct bootblock boot;
        struct fatEntry *fat = NULL;
+       char *realdev;
        int i;
        int mod = 0;
 
        rdonly = alwaysno;
-       if (!preen)
-               printf("** %s", fname);
 
-       dosfs = open(fname, rdonly ? O_RDONLY : O_RDWR, 0);
+       dosfs = opendev(fname, rdonly ? O_RDONLY : O_RDWR, 0, &realdev);
        if (dosfs < 0 && !rdonly) {
-               dosfs = open(fname, O_RDONLY, 0);
-               if (dosfs >= 0)
-                       pwarn(" (NO WRITE)\n");
-               else if (!preen)
-                       printf("\n");
+               dosfs = opendev(fname, O_RDONLY, 0, &realdev);
                rdonly = 1;
-       } else if (!preen)
-               printf("\n");
-
+       }
        if (dosfs < 0) {
                xperror("Can't open");
                return (8);
        }
 
+       if (!preen) {
+               printf("** %s", realdev);
+               if (strncmp(fname, realdev, PATH_MAX) != 0)
+                       printf(" (%s)", fname);
+               if (rdonly)
+                       printf(" (NO WRITE)");
+               printf("\n");
+       }
+
        if (readboot(dosfs, &boot) != FSOK) {
                (void)close(dosfs);
                return (8);

-- 

   "Stop assuming that systems are secure unless demonstrated insecure;
    start assuming that systems are insecure unless designed securely."
          - Bruce Schneier

Reply via email to