diff options
-rw-r--r-- | util-linux/fdisk.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index a048dd93b..32a66d03d 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
@@ -473,6 +473,42 @@ close_dev_fd(void) | |||
473 | xmove_fd(xopen(bb_dev_null, O_RDONLY), dev_fd); | 473 | xmove_fd(xopen(bb_dev_null, O_RDONLY), dev_fd); |
474 | } | 474 | } |
475 | 475 | ||
476 | /* Return partition name */ | ||
477 | static const char * | ||
478 | partname(const char *dev, int pno, int lth) | ||
479 | { | ||
480 | const char *p; | ||
481 | int w, wp; | ||
482 | int bufsiz; | ||
483 | char *bufp; | ||
484 | |||
485 | bufp = auto_string(xzalloc(80)); | ||
486 | bufsiz = 80; | ||
487 | |||
488 | w = strlen(dev); | ||
489 | p = ""; | ||
490 | |||
491 | if (isdigit(dev[w-1])) | ||
492 | p = "p"; | ||
493 | |||
494 | /* devfs kludge - note: fdisk partition names are not supposed | ||
495 | to equal kernel names, so there is no reason to do this */ | ||
496 | if (strcmp(dev + w - 4, "disc") == 0) { | ||
497 | w -= 4; | ||
498 | p = "part"; | ||
499 | } | ||
500 | |||
501 | wp = strlen(p); | ||
502 | |||
503 | if (lth) { | ||
504 | snprintf(bufp, bufsiz, "%*.*s%s%-2u", | ||
505 | lth-wp-2, w, dev, p, pno); | ||
506 | } else { | ||
507 | snprintf(bufp, bufsiz, "%.*s%s%-2u", w, dev, p, pno); | ||
508 | } | ||
509 | return bufp; | ||
510 | } | ||
511 | |||
476 | static ALWAYS_INLINE struct partition * | 512 | static ALWAYS_INLINE struct partition * |
477 | get_part_table(int i) | 513 | get_part_table(int i) |
478 | { | 514 | { |
@@ -2057,42 +2093,6 @@ fix_partition_table_order(void) | |||
2057 | } | 2093 | } |
2058 | #endif | 2094 | #endif |
2059 | 2095 | ||
2060 | /* Return partition name */ | ||
2061 | static const char * | ||
2062 | partname(const char *dev, int pno, int lth) | ||
2063 | { | ||
2064 | const char *p; | ||
2065 | int w, wp; | ||
2066 | int bufsiz; | ||
2067 | char *bufp; | ||
2068 | |||
2069 | bufp = auto_string(xzalloc(80)); | ||
2070 | bufsiz = 80; | ||
2071 | |||
2072 | w = strlen(dev); | ||
2073 | p = ""; | ||
2074 | |||
2075 | if (isdigit(dev[w-1])) | ||
2076 | p = "p"; | ||
2077 | |||
2078 | /* devfs kludge - note: fdisk partition names are not supposed | ||
2079 | to equal kernel names, so there is no reason to do this */ | ||
2080 | if (strcmp(dev + w - 4, "disc") == 0) { | ||
2081 | w -= 4; | ||
2082 | p = "part"; | ||
2083 | } | ||
2084 | |||
2085 | wp = strlen(p); | ||
2086 | |||
2087 | if (lth) { | ||
2088 | snprintf(bufp, bufsiz, "%*.*s%s%-2u", | ||
2089 | lth-wp-2, w, dev, p, pno); | ||
2090 | } else { | ||
2091 | snprintf(bufp, bufsiz, "%.*s%s%-2u", w, dev, p, pno); | ||
2092 | } | ||
2093 | return bufp; | ||
2094 | } | ||
2095 | |||
2096 | static const char * | 2096 | static const char * |
2097 | chs_string11(unsigned cyl, unsigned head, unsigned sect) | 2097 | chs_string11(unsigned cyl, unsigned head, unsigned sect) |
2098 | { | 2098 | { |