summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-12-17 01:28:59 +0100
committerKarel Zak <kzak@redhat.com>2010-12-17 01:28:59 +0100
commit6bec87105cb4f2e5baf9cde14174bee8376e3b32 (patch)
treef40751962fab339e540c13bbce243171af1d7434
parent57a60bf0effd1539aa78fd19aa13024ce6a9edf6 (diff)
downloadutil-linux-old-6bec87105cb4f2e5baf9cde14174bee8376e3b32.tar.gz
fdisk: use canonicalized names for -l (and sfdisk -d)
.. 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>
-rw-r--r--fdisk/Makefile.am6
-rw-r--r--fdisk/fdisk.c15
-rw-r--r--fdisk/fdisk.h1
-rw-r--r--fdisk/sfdisk.c33
4 files changed, 32 insertions, 23 deletions
diff --git a/fdisk/Makefile.am b/fdisk/Makefile.am
index 36871f3c..51d0eb39 100644
--- a/fdisk/Makefile.am
+++ b/fdisk/Makefile.am
@@ -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
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 1f841d17..5a694373 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -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);
}
diff --git a/fdisk/fdisk.h b/fdisk/fdisk.h
index 1a89beb9..56230d68 100644
--- a/fdisk/fdisk.h
+++ b/fdisk/fdisk.h
@@ -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"
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index 958faaeb..d99bf3c3 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -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);
}