From: Karel Zak Date: Thu, 2 May 2013 09:23:25 +0000 (+0200) Subject: libfdisk: add fdisk_context_enable_details() X-Git-Tag: v2.24-rc1~263 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a5c1b0fa2079b3584c8b71548f95391879b685b0;p=thirdparty%2Futil-linux.git libfdisk: add fdisk_context_enable_details() Signed-off-by: Karel Zak --- diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index 3da40b6a98..570d61defb 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -810,6 +810,8 @@ expert_command_prompt(struct fdisk_context *cxt) assert(cxt); + fdisk_context_enable_details(cxt, 1); + while(1) { assert(cxt->label); @@ -875,6 +877,7 @@ expert_command_prompt(struct fdisk_context *cxt) case 'q': handle_quit(cxt); case 'r': + fdisk_context_enable_details(cxt, 0); return; case 's': user_sectors = read_int(cxt, 1, cxt->geom.sectors, 63, 0, diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index 7569e5b525..e77274bae1 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -237,6 +237,27 @@ int fdisk_context_set_ask(struct fdisk_context *cxt, return 0; } +/** + * fdisk_context_enable_details: + * cxt: context + * enable: true/flase + * + * Enables or disables "details" display mode. + * + * Returns: 0 on success, < 0 on error. + */ +int fdisk_context_enable_details(struct fdisk_context *cxt, int enable) +{ + assert(cxt); + cxt->display_details = enable ? 1 : 0; + return 0; +} + +int fdisk_context_display_details(struct fdisk_context *cxt) +{ + assert(cxt); + return cxt->display_details == 1; +} /* * @str: "cylinder" or "sector". diff --git a/libfdisk/src/fdiskP.h b/libfdisk/src/fdiskP.h index c4d61b6c56..ff4c31bd2f 100644 --- a/libfdisk/src/fdiskP.h +++ b/libfdisk/src/fdiskP.h @@ -259,7 +259,8 @@ struct fdisk_context { unsigned long sector_size; /* logical size */ unsigned long alignment_offset; - int display_in_cyl_units; /* for obscure labels */ + unsigned int display_in_cyl_units : 1, /* for obscure labels */ + display_details : 1; /* expert display mode */ /* alignment */ unsigned long grain; /* alignment unit */ @@ -285,6 +286,10 @@ struct fdisk_context { extern int __fdisk_context_switch_label(struct fdisk_context *cxt, struct fdisk_label *lb); +extern int fdisk_context_use_cylinders(struct fdisk_context *cxt); +extern int fdisk_context_display_details(struct fdisk_context *cxt); + + /* alignment.c */ extern sector_t fdisk_topology_get_first_lba(struct fdisk_context *cxt); extern unsigned long fdisk_topology_get_grain(struct fdisk_context *cxt); diff --git a/libfdisk/src/libfdisk.h b/libfdisk/src/libfdisk.h index 343eece81f..b7c2735d13 100644 --- a/libfdisk/src/libfdisk.h +++ b/libfdisk/src/libfdisk.h @@ -89,9 +89,10 @@ extern int fdisk_context_switch_label(struct fdisk_context *cxt, extern int fdisk_context_set_unit(struct fdisk_context *cxt, const char *str); extern const char *fdisk_context_get_unit(struct fdisk_context *cxt, int n); -extern int fdisk_context_use_cylinders(struct fdisk_context *cxt); extern unsigned int fdisk_context_get_units_per_sector(struct fdisk_context *cxt); +extern int fdisk_context_enable_details(struct fdisk_context *cxt, int enable); + /* parttype.c */ extern struct fdisk_parttype *fdisk_get_parttype_from_code(struct fdisk_context *cxt, unsigned int code);