diff options
author | Karel Zak | 2013-11-19 13:02:39 +0100 |
---|---|---|
committer | Karel Zak | 2013-11-19 13:02:39 +0100 |
commit | e41e151427b0d7b9d655822b31adbc485220d1e4 (patch) | |
tree | d6ddc9cea75e2a63453a52866f6b4fb7f5589593 /libfdisk/src/sgi.c | |
parent | unshare: add more hints about mount namespaces to the man page (diff) | |
download | kernel-qcow2-util-linux-e41e151427b0d7b9d655822b31adbc485220d1e4.tar.gz kernel-qcow2-util-linux-e41e151427b0d7b9d655822b31adbc485220d1e4.tar.xz kernel-qcow2-util-linux-e41e151427b0d7b9d655822b31adbc485220d1e4.zip |
libfdisk: (sgi) generate partname according to partition position
The SGI drive currently counts only usable partitions, that's wrong as
Linux kernel counts all partition to generate partition number. For
example:
Kernel:
sdb 8:16 0 600M 0 disk
├─sdb9 8:25 0 2M 0 part
└─sdb11 8:27 0 596.2M 0 part
Fdisk:
Pt# Device Info Start End Sectors Id System
9: /dev/sdb1 0 4095 4096 0 SGI volhdr
11: /dev/sdb2 0 1220939 1220940 6 SGI volume
Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/sgi.c')
-rw-r--r-- | libfdisk/src/sgi.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c index 1e725de8f..871d673ae 100644 --- a/libfdisk/src/sgi.c +++ b/libfdisk/src/sgi.c @@ -253,7 +253,7 @@ static int sgi_list_table(struct fdisk_context *cxt) struct sgi_device_parameter *sgiparam = &sgilabel->devparam; size_t i, used; char *p; - int rc; + int rc = 0; if (fdisk_context_display_details(cxt)) fdisk_colon(cxt, _( @@ -280,7 +280,7 @@ static int sgi_list_table(struct fdisk_context *cxt) tt_define_column(tb, _("Id"), 2, TT_FL_RIGHT); tt_define_column(tb, _("System"), 0.2, TT_FL_TRUNC); - for (i = 0, used = 1; i < cxt->label->nparts_max; i++) { + for (i = 0, used = 0; i < cxt->label->nparts_max; i++) { uint32_t start, len; struct fdisk_parttype *t; struct tt_line *ln; @@ -297,7 +297,7 @@ static int sgi_list_table(struct fdisk_context *cxt) if (asprintf(&p, "%zu:", i + 1) > 0) tt_line_set_data(ln, 0, p); /* # */ - p = fdisk_partname(cxt->dev_path, used++); + p = fdisk_partname(cxt->dev_path, i + 1); if (p) tt_line_set_data(ln, 1, p); /* Device */ @@ -317,9 +317,11 @@ static int sgi_list_table(struct fdisk_context *cxt) if (t->name) tt_line_set_data(ln, 7, strdup(t->name)); /* type Name */ fdisk_free_parttype(t); + used++; } - rc = fdisk_print_table(cxt, tb); + if (used) + rc = fdisk_print_table(cxt, tb); tt_free_table(tb); if (rc) return rc; |