Print the size in 512-byte sectors of each given block device. This option is DEPRECATED in favour of *blockdev*(8).
*-t*, *--type* _type_::
-Enable support only for disklabels of the specified _type_, and disable support for all other types.
+Enable support only for disklabels of the specified _type_, and disable support for all other types. This also determines the disklabel type used when *fdisk* automatically creates a new disklabel on an empty device.
*-u*, *--units*[**=**_unit_]::
When listing partition tables, show sizes in 'sectors' or in 'cylinders'. The default is to show sizes in sectors. For backward compatibility, it is possible to use the option without the _unit_ argument -- then the default is used. Note that the optional _unit_ argument cannot be separated from the *-u* option by a space; the correct form is *-u=cylinders*, for example.
struct fdisk_context *cxt;
char *outarg = NULL;
const char *devname, *lockmode = NULL;
+ const char *wanted_label = NULL;
enum {
OPT_BYTES = CHAR_MAX + 1,
OPT_LOCK
if (!lb)
errx(EXIT_FAILURE, _("unsupported disklabel: %s"), optarg);
fdisk_label_set_disabled(lb, 0);
+ wanted_label = fdisk_label_get_name(lb);
break;
}
case 'u':
if (!fdisk_has_label(cxt)) {
fdisk_info(cxt, _("Device does not contain a recognized partition table."));
- if (!noauto_pt)
- fdisk_create_disklabel(cxt, NULL);
+ if (!noauto_pt) {
+ rc = fdisk_create_disklabel(cxt, wanted_label);
+ if (rc)
+ fdisk_warn(cxt, _("Failed to create a disklabel."));
+ }
} else if (fdisk_is_label(cxt, GPT) && fdisk_gpt_is_hybrid(cxt))
fdisk_warnx(cxt, _(