diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2012-06-20 18:38:02 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2012-06-20 18:38:02 +0000 |
commit | 2478b6d1f46b698779b910f092221f5f249938cc (patch) | |
tree | 6f002895ef4320c9607bee9c1e0c0694ae027240 | |
parent | 2cbe7d6f1cb221b2b1b97130bd005b76948ba14e (diff) | |
download | util-linux-old-2478b6d1f46b698779b910f092221f5f249938cc.tar.gz |
Fixed segfault is disk_device is read-only
-rw-r--r-- | fdisk/cfdisk.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c index 848a1013..4fb5a40f 100644 --- a/fdisk/cfdisk.c +++ b/fdisk/cfdisk.c @@ -113,8 +113,8 @@ #define DEFAULT_DEVICE "/dev/ad0" #define ALTERNATE_DEVICE "/dev/da0" #elif defined(__sun__) -#define DEFAULT_DEVICE "/dev/rdsk/c0d0" -#define ALTERNATE_DEVICE "/dev/rdsk/c0t0d0" +#define DEFAULT_DEVICE "/dev/rdsk/c0d0p0" +#define ALTERNATE_DEVICE "/dev/rdsk/c0t0d0p0" #else #define DEFAULT_DEVICE "/dev/hda" #define ALTERNATE_DEVICE "/dev/sda" @@ -2461,11 +2461,13 @@ draw_partition(int i) { int l = strlen(dbn); #ifdef __sun__ - /* XXX: Whole disk is c0t0d0p0, but patitions are c0t0d0p1, c0t0d0p2, etc */ - dbn[l-1] = '\0'; /* Cutoff '0' */ - mvprintw(y, NAME_START, - "%s%d", dbn, p_info[i].num+1); - dbn[l-1] = '0'; /* Restore '0' */ + /* + * XXX: Whole disk is c0t0d0p0, but patitions are c0t0d0p1, c0t0d0p2, etc. + * disk_device (and dbn) could be read-only, so we just overwrite the last 0 + * on the screen + */ + mvprintw(y, NAME_START, "%s", dbn); + mvprintw(y, NAME_START+l-1, "%d", p_info[i].num+1); #else int digit_last = isdigit(dbn[l-1]); mvprintw(y, NAME_START, |