diff options
author | Karel Zak | 2016-02-18 12:50:11 +0100 |
---|---|---|
committer | Karel Zak | 2016-02-18 12:58:12 +0100 |
commit | cb9a4b0033eca429689a403be2a192fe2842f2e9 (patch) | |
tree | d2bb843aaa8462e6714fa609aa1c9cc03b6aab27 /disk-utils/fdisk-list.h | |
parent | libfdisk: add API to control signatures wiping (diff) | |
download | kernel-qcow2-util-linux-cb9a4b0033eca429689a403be2a192fe2842f2e9.tar.gz kernel-qcow2-util-linux-cb9a4b0033eca429689a403be2a192fe2842f2e9.tar.xz kernel-qcow2-util-linux-cb9a4b0033eca429689a403be2a192fe2842f2e9.zip |
fdisk: add --wipe
This patch changes fdisk behavior and it wipes foreign signatures
from the device to avoid collisions. The wipe functionality is
automatically enabled in the interactive mode only (user is always
warned about it), otherwise it's possible to control all by --wipe
<auto|never|always>.
The program does not change behavior when executed in scripts (echo
<something> | fdisk), the option "--wipe=always" is required to enable
in this case.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/fdisk-list.h')
-rw-r--r-- | disk-utils/fdisk-list.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/disk-utils/fdisk-list.h b/disk-utils/fdisk-list.h index c24c4ddcc..eddab92ec 100644 --- a/disk-utils/fdisk-list.h +++ b/disk-utils/fdisk-list.h @@ -15,4 +15,32 @@ extern void print_all_devices_freespace(struct fdisk_context *cxt); extern void list_available_columns(FILE *out); extern int *init_fields(struct fdisk_context *cxt, const char *str, size_t *n); + +/* used by fdisk and sfdisk */ +enum { + WIPEMODE_AUTO = 0, + WIPEMODE_NEVER = 1, + WIPEMODE_ALWAYS = 2 +}; + +static inline int wipemode_from_string(const char *str) +{ + size_t i; + static const char *modes[] = { + [WIPEMODE_AUTO] = "auto", + [WIPEMODE_NEVER] = "never", + [WIPEMODE_ALWAYS] = "always" + }; + + if (!str || !*str) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(modes); i++) { + if (strcasecmp(str, modes[i]) == 0) + return i; + } + + return -EINVAL; +} + #endif /* UTIL_LINUX_FDISK_LIST_H */ |