Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Oct 2004 16:34:11 -0500 (EST)
From:      Sam <sah@softcardsystems.com>
To:        freebsd-current@freebsd.org
Subject:   fdisk buglet
Message-ID:  <Pine.LNX.4.60.0410151632100.21014@athena>

next in thread | raw e-mail | index | archive | help
fivethree% fdisk /dev/ad1
fdisk: cannot open disk /dev//dev/ad1: No such file or directory

One possible fix:

fivethree% diff -upr src/sbin/fdisk src2/sbin/fdisk
diff -upr src/sbin/fdisk/fdisk.c src2/sbin/fdisk/fdisk.c
--- src/sbin/fdisk/fdisk.c      Mon Jun 14 03:21:19 2004
+++ src2/sbin/fdisk/fdisk.c     Fri Oct 15 16:35:28 2004
@@ -299,14 +299,16 @@ main(int argc, char *argv[])
         if (argc == 0) {
                 disk = get_rootdisk();
         } else {
-               if (stat(argv[0], &sb) == 0) {
+               disk = argv[0];
+               if (stat(disk, &sb) == 0) {
                         /* OK, full pathname given */
-                       disk = argv[0];
                 } else if (errno == ENOENT) {
                         /* Try prepending "/dev" */
-                       asprintf(&disk, "%s%s", _PATH_DEV, argv[0]);
-                       if (disk == NULL)
-                               errx(1, "out of memory");
+                       if (strncmp(disk, _PATH_DEV, strlen(_PATH_DEV))) {
+                               asprintf(&disk, "%s%s", _PATH_DEV, argv[0]);
+                               if (disk == NULL)
+                                       errx(1, "out of memory");
+                       }
                 } else {
                         /* other stat error, let it fail below */
                         disk = argv[0];


Cheers,

Sam



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.60.0410151632100.21014>