Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin Try the DIOCGWEDGEINFO ioctl first. If that succeeds (...



details:   https://anonhg.NetBSD.org/src/rev/7ed7da97b485
branches:  trunk
changeset: 570113:7ed7da97b485
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Sep 25 03:32:52 2004 +0000

description:
Try the DIOCGWEDGEINFO ioctl first.  If that succeeds (i.e. the block
device is a wedge), use the partition type string from the dkwedge_info
structure to get the file system type.

diffstat:

 sbin/fsck/fsck.c   |  14 +++++++++++---
 sbin/mount/mount.c |  13 +++++++++++--
 2 files changed, 22 insertions(+), 5 deletions(-)

diffs (100 lines):

diff -r e0ca7b47b6fc -r 7ed7da97b485 sbin/fsck/fsck.c
--- a/sbin/fsck/fsck.c  Sat Sep 25 03:31:35 2004 +0000
+++ b/sbin/fsck/fsck.c  Sat Sep 25 03:32:52 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fsck.c,v 1.35 2004/08/19 22:28:38 christos Exp $       */
+/*     $NetBSD: fsck.c,v 1.36 2004/09/25 03:32:52 thorpej Exp $        */
 
 /*
  * Copyright (c) 1996 Christos Zoulas. All rights reserved.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fsck.c,v 1.35 2004/08/19 22:28:38 christos Exp $");
+__RCSID("$NetBSD: fsck.c,v 1.36 2004/09/25 03:32:52 thorpej Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -45,6 +45,7 @@
 #include <sys/wait.h>
 #define FSTYPENAMES
 #define FSCKNAMES
+#include <sys/disk.h>
 #include <sys/disklabel.h>
 #include <sys/ioctl.h>
 
@@ -490,10 +491,10 @@
        *maxargcp = maxargc;
 }
 
-
 const static char *
 getfslab(const char *str)
 {
+       static struct dkwedge_info dkw;
        struct disklabel dl;
        int fd;
        char p;
@@ -504,6 +505,13 @@
        if ((fd = open(str, O_RDONLY)) == -1)
                err(1, "cannot open `%s'", str);
 
+       /* First check to see if it's a wedge. */
+       if (ioctl(fd, DIOCGWEDGEINFO, &dkw) == 0) {
+               /* Yup, this is easy. */
+               (void) close(fd);
+               return (dkw.dkw_ptype);
+       }
+
        if (ioctl(fd, DIOCGDINFO, &dl) == -1)
                err(1, "cannot get disklabel for `%s'", str);
 
diff -r e0ca7b47b6fc -r 7ed7da97b485 sbin/mount/mount.c
--- a/sbin/mount/mount.c        Sat Sep 25 03:31:35 2004 +0000
+++ b/sbin/mount/mount.c        Sat Sep 25 03:32:52 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount.c,v 1.72 2004/08/19 23:02:09 christos Exp $      */
+/*     $NetBSD: mount.c,v 1.73 2004/09/25 03:32:52 thorpej Exp $       */
 
 /*
  * Copyright (c) 1980, 1989, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)mount.c    8.25 (Berkeley) 5/8/95";
 #else
-__RCSID("$NetBSD: mount.c,v 1.72 2004/08/19 23:02:09 christos Exp $");
+__RCSID("$NetBSD: mount.c,v 1.73 2004/09/25 03:32:52 thorpej Exp $");
 #endif
 #endif /* not lint */
 
@@ -59,6 +59,7 @@
 
 #define MOUNTNAMES
 #include <fcntl.h>
+#include <sys/disk.h>
 #include <sys/disklabel.h>
 #include <sys/ioctl.h>
 
@@ -660,6 +661,7 @@
 getfslab(str)
        const char *str;
 {
+       static struct dkwedge_info dkw;
        struct disklabel dl;
        int fd;
        int part;
@@ -689,6 +691,13 @@
                        return (NULL);
        }
 
+       /* Check to see if this is a wedge. */
+       if (ioctl(fd, DIOCGWEDGEINFO, &dkw) == 0) {
+               /* Yup, this is easy. */
+               (void) close(fd);
+               return (dkw.dkw_ptype);
+       }
+
        if (ioctl(fd, DIOCGDINFO, &dl) == -1) {
                (void) close(fd);
                return (NULL);



Home | Main Index | Thread Index | Old Index