]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - disk-utils/partx.c
misc: consolidate smartcols error messages
[thirdparty/util-linux.git] / disk-utils / partx.c
index a0e337b78b45739a456d1d10fba90672c9c21aa7..941fc46aaf333b0507ce3ec1f84eec9ed621cfb2 100644 (file)
@@ -578,7 +578,7 @@ static int add_scols_line(struct libscols_table *table, blkid_partition par)
 
        line = scols_table_new_line(table, NULL);
        if (!line) {
-               warn(_("failed to add line to output"));
+               warn(_("failed to allocate output line"));
                return -ENOMEM;
        }
 
@@ -641,7 +641,7 @@ static int add_scols_line(struct libscols_table *table, blkid_partition par)
                else if (str)
                        rc = scols_line_refer_data(line, i, str);
                if (rc) {
-                       warn(_("failed to add data to output table"));
+                       warn(_("failed to add output data"));
                        break;
                }
        }
@@ -664,7 +664,7 @@ static int show_parts(blkid_partlist ls, int scols_flags, int lower, int upper)
        scols_init_debug(0);
        table = scols_new_table();
        if (!table) {
-               warn(_("failed to initialize output table"));
+               warn(_("failed to allocate output table"));
                return -1;
        }
        scols_table_enable_raw(table, !!(scols_flags & PARTX_RAW));
@@ -675,7 +675,7 @@ static int show_parts(blkid_partlist ls, int scols_flags, int lower, int upper)
                struct colinfo *col = get_column_info(i);
 
                if (!scols_table_new_column(table, col->name, col->whint, col->flags)) {
-                       warnx(_("failed to initialize output column"));
+                       warnx(_("failed to allocate output column"));
                        goto done;
                }
        }
@@ -767,7 +767,8 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
        fputs(_(" -P, --pairs          use key=\"value\" output format\n"), out);
        fputs(_(" -r, --raw            use raw output format\n"), out);
        fputs(_(" -S, --sector-size <num>  overwrite sector size\n"), out);
-       fputs(_(" -t, --type <type>    specify the partition type (dos, bsd, solaris, etc.)\n"), out);
+       fputs(_(" -t, --type <type>    specify the partition type\n"), out);
+       fputs(_("     --list-types     list supported partition types and exit\n"), out);
        fputs(_(" -v, --verbose        verbose mode\n"), out);
 
        fputs(USAGE_SEPARATOR, out);
@@ -795,6 +796,9 @@ int main(int argc, char **argv)
        dev_t disk_devno = 0, part_devno = 0;
        unsigned int sector_size = 0;
 
+       enum {
+               OPT_LIST_TYPES = CHAR_MAX + 1
+       };
        static const struct option long_opts[] = {
                { "bytes",      no_argument,       NULL, 'b' },
                { "noheadings", no_argument,       NULL, 'g' },
@@ -805,6 +809,7 @@ int main(int argc, char **argv)
                { "delete",     no_argument,       NULL, 'd' },
                { "update",     no_argument,       NULL, 'u' },
                { "type",       required_argument, NULL, 't' },
+               { "list-types", no_argument,       NULL, OPT_LIST_TYPES },
                { "nr",         required_argument, NULL, 'n' },
                { "output",     required_argument, NULL, 'o' },
                { "pairs",      no_argument,       NULL, 'P' },
@@ -877,6 +882,15 @@ int main(int argc, char **argv)
                case 'v':
                        verbose = 1;
                        break;
+               case OPT_LIST_TYPES:
+               {
+                       size_t idx = 0;
+                       const char *name = NULL;
+
+                       while (blkid_partitions_get_name(idx++, &name) == 0)
+                               puts(name);
+                       return EXIT_SUCCESS;
+               }
                case 'h':
                        usage(stdout);
                case 'V':