]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: clean up cylinder column
authorKarel Zak <kzak@redhat.com>
Thu, 19 Dec 2013 12:25:51 +0000 (13:25 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 11 Mar 2014 10:35:13 +0000 (11:35 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/bsd.c
libfdisk/src/dos.c
libfdisk/src/gpt.c
libfdisk/src/label.c
libfdisk/src/sgi.c
libfdisk/src/sun.c
libfdisk/src/table.c

index 8495363286591a19e2d323cd437284c3b006c166..d24c10434829618371806add261640f5f61e5c91 100644 (file)
@@ -877,9 +877,11 @@ static const struct fdisk_label_operations bsd_operations =
 static const struct fdisk_column bsd_columns[] =
 {
        { FDISK_COL_DEVICE,     N_("Slice"),      1,    0 },
-       { FDISK_COL_START,      N_("Start"),      9,    TT_FL_RIGHT },
-       { FDISK_COL_END,        N_("End"),        9,    TT_FL_RIGHT },
-       { FDISK_COL_SIZE,       N_("Size"),       9,    TT_FL_RIGHT },
+       { FDISK_COL_START,      N_("Start"),      5,    TT_FL_RIGHT },
+       { FDISK_COL_END,        N_("End"),        5,    TT_FL_RIGHT },
+       { FDISK_COL_SIZE,       N_("Size"),       5,    TT_FL_RIGHT },
+       { FDISK_COL_SECTORS,    N_("Sectors"),    5,    TT_FL_RIGHT },
+       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    TT_FL_RIGHT },
        { FDISK_COL_TYPE,       N_("Type"),       8,    0 },
        { FDISK_COL_FSIZE,      N_("Fsize"),      5,    TT_FL_RIGHT },
        { FDISK_COL_BSIZE,      N_("Bsize"),      5,    TT_FL_RIGHT },
index 63072fc3f11e7e71d610cb9a6ee83d0d9e0cf1a0..1beeb6573df1851d2f858990da64bf7e88b2b103 100644 (file)
@@ -1836,6 +1836,7 @@ static const struct fdisk_column dos_columns[] =
        { FDISK_COL_START,      N_("Start"),      5,    TT_FL_RIGHT },
        { FDISK_COL_END,        N_("End"),        5,    TT_FL_RIGHT },
        { FDISK_COL_SECTORS,    N_("Sectors"),    5,    TT_FL_RIGHT },
+       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    TT_FL_RIGHT },
        { FDISK_COL_SIZE,       N_("Size"),       5,    TT_FL_RIGHT, FDISK_COLFL_EYECANDY },
        { FDISK_COL_TYPEID,     N_("Id"),         2,    TT_FL_RIGHT },
        { FDISK_COL_TYPE,       N_("Type"),     0.1,    TT_FL_TRUNC },
index c9917cf56d52da1b716bf13187d68b5f0e22bdf9..8c1c868356aabcfc2a208a2be80ca8e6f95181f2 100644 (file)
@@ -2269,6 +2269,7 @@ static const struct fdisk_column gpt_columns[] =
        { FDISK_COL_START,      N_("Start"),      5,    TT_FL_RIGHT },
        { FDISK_COL_END,        N_("End"),        5,    TT_FL_RIGHT },
        { FDISK_COL_SECTORS,    N_("Sectors"),    5,    TT_FL_RIGHT },
+       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    TT_FL_RIGHT },
        { FDISK_COL_SIZE,       N_("Size"),       5,    TT_FL_RIGHT, FDISK_COLFL_EYECANDY },
        { FDISK_COL_TYPE,       N_("Type"),     0.1,    TT_FL_TRUNC, FDISK_COLFL_EYECANDY },
        /* expert */
index 00b25ee2935d32d3c0c2f563e958b6d64ef629ff..d04363a1da79305dbd7ede79a10a3447cf809f0e 100644 (file)
@@ -137,13 +137,20 @@ int fdisk_get_columns(struct fdisk_context *cxt, int all, int **cols, size_t *nc
        if (!c)
                return -ENOMEM;
        for (n = 0, i = 0; i < cxt->label->ncolumns; i++) {
+               int id = cxt->label->columns[i].id;
+
                if (!all &&
                    ((fdisk_context_display_details(cxt) &&
                                (cxt->label->columns[i].flags & FDISK_COLFL_EYECANDY))
                     || (!fdisk_context_display_details(cxt) &&
-                               (cxt->label->columns[i].flags & FDISK_COLFL_DETAIL))))
+                               (cxt->label->columns[i].flags & FDISK_COLFL_DETAIL))
+                    || (id == FDISK_COL_SECTORS &&
+                                fdisk_context_use_cylinders(cxt))
+                    || (id == FDISK_COL_CYLINDERS &&
+                                !fdisk_context_use_cylinders(cxt))))
                        continue;
-               c[n++] = cxt->label->columns[i].id;
+
+               c[n++] = id;
        }
        if (cols)
                *cols = c;
index 33a13c8b7654876480f1f09919e640f3e551aebc..19daf3ad460dcf0db67a4aa00a8e7d95ce9caca7 100644 (file)
@@ -1121,6 +1121,7 @@ static const struct fdisk_column sgi_columns[] =
        { FDISK_COL_START,      N_("Start"),      5,    TT_FL_RIGHT },
        { FDISK_COL_END,        N_("End"),        5,    TT_FL_RIGHT },
        { FDISK_COL_SECTORS,    N_("Sectors"),    5,    TT_FL_RIGHT },
+       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    TT_FL_RIGHT },
        { FDISK_COL_SIZE,       N_("Size"),       5,    TT_FL_RIGHT, FDISK_COLFL_EYECANDY },
        { FDISK_COL_TYPEID,     N_("Id"),         2,    TT_FL_RIGHT },
        { FDISK_COL_TYPE,       N_("Type"),     0.1,    TT_FL_TRUNC, FDISK_COLFL_EYECANDY },
index 9c064f28efaede916adb22179bdc88428b4843d3..2b31358b9e6899518996955cff2771f7cd7d77ac 100644 (file)
@@ -988,6 +988,7 @@ static const struct fdisk_column sun_columns[] =
        { FDISK_COL_START,      N_("Start"),      5,    TT_FL_RIGHT },
        { FDISK_COL_END,        N_("End"),        5,    TT_FL_RIGHT },
        { FDISK_COL_SECTORS,    N_("Sectors"),    5,    TT_FL_RIGHT },
+       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    TT_FL_RIGHT },
        { FDISK_COL_SIZE,       N_("Size"),       5,    TT_FL_RIGHT },
        { FDISK_COL_TYPEID,     N_("Id"),         2,    TT_FL_RIGHT },
        { FDISK_COL_TYPE,       N_("Type"),     0.1,    TT_FL_TRUNC },
index 1d034d42806372e01c12e56e04d4996fd9cf8da0..c934910a1f6aa0217cb277c16a6c22009dec263c 100644 (file)
@@ -322,13 +322,8 @@ int fdisk_table_to_string(struct fdisk_table *tb,
        /* define columns */
        for (j = 0; j < ncols; j++) {
                col = fdisk_label_get_column(cxt->label, cols[j]);
-               if (!col)
-                       continue;
-               tt_define_column(tt,
-                       col->id == FDISK_COL_SECTORS &&
-                       fdisk_context_use_cylinders(cxt) ?
-                               _("Cylinders") : col->name,
-                       col->width, col->tt_flags);
+               if (col)
+                       tt_define_column(tt, col->name, col->width, col->tt_flags);
        }
 
        fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);