diff options
-rw-r--r-- | fdisk/fdisk.c | 4 | ||||
-rw-r--r-- | fdisk/fdisk.h | 1 | ||||
-rw-r--r-- | fdisk/utils.c | 14 |
3 files changed, 16 insertions, 3 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index 190b21061..578b72d9a 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -2154,6 +2154,10 @@ int main(int argc, char **argv) print_welcome(); + if (!fdisk_dev_sectsz_is_default(cxt)) + printf(_("Note: sector size is %ld (not %d)\n"), + cxt->sector_size, DEFAULT_SECTOR_SIZE); + gpt_warning(cxt->dev_path); get_boot(cxt, 0); diff --git a/fdisk/fdisk.h b/fdisk/fdisk.h index 61853d14c..f73d13afc 100644 --- a/fdisk/fdisk.h +++ b/fdisk/fdisk.h @@ -119,6 +119,7 @@ struct fdisk_context { extern struct fdisk_context *fdisk_new_context_from_filename(const char *fname, int readonly); extern int fdisk_dev_has_topology(struct fdisk_context *cxt); +extern int fdisk_dev_sectsz_is_default(struct fdisk_context *cxt); extern void fdisk_free_context(struct fdisk_context *cxt); /* prototypes for fdisk.c */ diff --git a/fdisk/utils.c b/fdisk/utils.c index 3162c7054..94b8bd84e 100644 --- a/fdisk/utils.c +++ b/fdisk/utils.c @@ -80,14 +80,22 @@ static int __discover_topology(struct fdisk_context *cxt) cxt->sector_size = __get_sector_size(cxt->dev_fd); if (!cxt->phy_sector_size) /* could not discover physical size */ cxt->phy_sector_size = cxt->sector_size; - if (cxt->sector_size != DEFAULT_SECTOR_SIZE) - printf(_("Note: sector size is %ld (not %d)\n"), - cxt->sector_size, DEFAULT_SECTOR_SIZE); return 0; } /** + * fdisk_dev_sectsz_is_default: + * @cxt: fdisk context + * + * Returns 1 if the device's sector size is the default value, otherwise 0. + */ +int fdisk_dev_sectsz_is_default(struct fdisk_context *cxt) +{ + return cxt->sector_size == DEFAULT_SECTOR_SIZE; +} + +/** * fdisk_dev_has_topology: * @cxt: fdisk context * |