]> err.no Git - util-linux/commitdiff
fdisk: use canonicalized names for -l (and sfdisk -d)
authorKarel Zak <kzak@redhat.com>
Fri, 17 Dec 2010 00:28:59 +0000 (01:28 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 17 Dec 2010 00:28:59 +0000 (01:28 +0100)
.. no more /dev/dm-X in "fdisk -l" and "sfdisk -d" output, always use
/dev/mapper/<name>.

Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk/Makefile.am
fdisk/fdisk.c
fdisk/fdisk.h
fdisk/sfdisk.c

index 36871f3cf8e804cbb442dda499b7fe53aa6c9e4c..51d0eb39064d16aa58cccbb235b1cd43f3fa48a7 100644 (file)
@@ -17,7 +17,8 @@ dist_man_MANS = fdisk.8
 fdisk_SOURCES = fdisk.c fdiskbsdlabel.c fdisksgilabel.c \
        fdisksunlabel.c fdiskaixlabel.c fdiskmaclabel.c partname.c \
        fdisk.h fdisksunlabel.h fdisksgilabel.h fdiskaixlabel.h \
-       fdiskbsdlabel.h fdiskmaclabel.h $(fdisk_common)
+       fdiskbsdlabel.h fdiskmaclabel.h $(fdisk_common) \
+       $(top_srcdir)/lib/canonicalize.c
 
 cflags_blkid = $(AM_CFLAGS)
 ldadd_blkid =
@@ -43,7 +44,8 @@ if !ARCH_SPARC
 
 sbin_PROGRAMS += sfdisk
 dist_man_MANS += sfdisk.8
-sfdisk_SOURCES = sfdisk.c partname.c $(fdisk_common)
+sfdisk_SOURCES = sfdisk.c partname.c $(fdisk_common) \
+       $(top_srcdir)/lib/canonicalize.c
 
 if HAVE_STATIC_SFDISK
 sbin_PROGRAMS += sfdisk.static
index 1f841d17d13a2edf50a01b9ac7d89d5b44a27662..5a69437393e5a549b37e01ee111a4c865b4a77f1 100644 (file)
@@ -28,6 +28,8 @@
 #include "mbsalign.h"
 #include "fdisk.h"
 #include "wholedisk.h"
+#include "pathnames.h"
+#include "canonicalize.h"
 
 #include "fdisksunlabel.h"
 #include "fdisksgilabel.h"
@@ -2896,9 +2898,9 @@ tryprocpt(void) {
        int ma, mi;
        unsigned long long sz;
 
-       procpt = fopen(PROC_PARTITIONS, "r");
+       procpt = fopen(_PATH_PROC_PARTITIONS, "r");
        if (procpt == NULL) {
-               fprintf(stderr, _("cannot open %s\n"), PROC_PARTITIONS);
+               fprintf(stderr, _("cannot open %s\n"), _PATH_PROC_PARTITIONS);
                return;
        }
 
@@ -2907,8 +2909,13 @@ tryprocpt(void) {
                            &ma, &mi, &sz, ptname) != 4)
                        continue;
                snprintf(devname, sizeof(devname), "/dev/%s", ptname);
-               if (is_whole_disk(devname))
-                       try(devname, 0);
+               if (is_whole_disk(devname)) {
+                       char *cn = canonicalize_path(devname);
+                       if (cn) {
+                               try(cn, 0);
+                               free(cn);
+                       }
+               }
        }
        fclose(procpt);
 }
index 1a89beb9a8903428c839f4bf738c5c10fb5bd53e..56230d685d30534b9063a927e8e571381f95b081 100644 (file)
@@ -109,4 +109,3 @@ extern void xbsd_print_disklabel(int);
 /* prototypes for fdisksgilabel.c */
 extern int valid_part_table_flag(unsigned char *b);
 
-#define PROC_PARTITIONS "/proc/partitions"
index 958faaebfafb434a76295306e87012f8f05e4c85..d99bf3c3cf38a3fb5c8e8d54105490a2dbebe068 100644 (file)
@@ -54,6 +54,8 @@
 #include "common.h"
 #include "wholedisk.h"
 #include "gpt.h"
+#include "pathnames.h"
+#include "canonicalize.h"
 
 /*
  * Table of contents:
@@ -2423,8 +2425,6 @@ is_ide_cdrom_or_tape(char *device) {
        return is_ide;
 }
 
-#define PROC_PARTITIONS        "/proc/partitions"
-
 static char *
 nextproc(FILE *procf) {
        static char devname[256];
@@ -2441,7 +2441,7 @@ nextproc(FILE *procf) {
                snprintf(devname, sizeof(devname), "/dev/%s", ptname);
                if (!is_whole_disk(devname))
                        continue;
-               return devname;
+               return canonicalize_path(devname);
        }
 
        return NULL;
@@ -2608,22 +2608,23 @@ main(int argc, char **argv) {
        /* try all known devices */
        total_size = 0;
 
-       procf = fopen(PROC_PARTITIONS, "r");
+       procf = fopen(_PATH_PROC_PARTITIONS, "r");
        if (!procf)
-           fprintf(stderr, _("cannot open %s\n"), PROC_PARTITIONS);
+           fprintf(stderr, _("cannot open %s\n"), _PATH_PROC_PARTITIONS);
        else {
            while ((dev = nextproc(procf)) != NULL) {
-               if (is_ide_cdrom_or_tape(dev))
-                  continue;
-               gpt_warning(dev, 1);
-               if (opt_out_geom)
-                  do_geom(dev, 1);
-               if (opt_out_pt_geom)
-                  do_pt_geom(dev, 1);
-               if (opt_size)
-                  do_size(dev, 1);
-               if (opt_list || verify)
-                  do_list(dev, 1);
+               if (!is_ide_cdrom_or_tape(dev)) {
+                   gpt_warning(dev, 1);
+                   if (opt_out_geom)
+                       do_geom(dev, 1);
+                   if (opt_out_pt_geom)
+                       do_pt_geom(dev, 1);
+                   if (opt_size)
+                       do_size(dev, 1);
+                   if (opt_list || verify)
+                       do_list(dev, 1);
+               }
+               free(dev);
            }
            fclose(procf);
        }