diff options
author | Karel Zak | 2015-04-13 13:40:25 +0200 |
---|---|---|
committer | Karel Zak | 2015-04-13 13:40:25 +0200 |
commit | 3457d90e3014b0ec25341c39629583b5655aa97f (patch) | |
tree | 52aa9989467d29645b8aa095cc07de29ab2f65f6 /libfdisk/src/context.c | |
parent | sfdisk: improve -N warnings (diff) | |
download | kernel-qcow2-util-linux-3457d90e3014b0ec25341c39629583b5655aa97f.tar.gz kernel-qcow2-util-linux-3457d90e3014b0ec25341c39629583b5655aa97f.tar.xz kernel-qcow2-util-linux-3457d90e3014b0ec25341c39629583b5655aa97f.zip |
libfdisk: support bootbits protection from (p)MBR
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/context.c')
-rw-r--r-- | libfdisk/src/context.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index 84867b0ab..efc961cf7 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -94,12 +94,13 @@ static int init_nested_from_parent(struct fdisk_context *cxt, int isnew) cxt->user_log_sector = parent->user_log_sector; cxt->user_pyh_sector = parent->user_pyh_sector; - /* parent <--> nested independent setting, initialize for new nested + /* parent <--> nested independent setting, initialize for new nested * contexts only */ if (isnew) { cxt->listonly = parent->listonly; cxt->display_details = parent->display_details; cxt->display_in_cyl_units = parent->display_in_cyl_units; + cxt->protect_bootbits = parent->protect_bootbits; } free(cxt->dev_path); @@ -304,6 +305,36 @@ int fdisk_has_label(struct fdisk_context *cxt) } /** + * fdisk_has_protected_bootbits: + * @cxt: fdisk context + * + * Returns: return 1 if boot bits protection enabled. + */ +int fdisk_has_protected_bootbits(struct fdisk_context *cxt) +{ + return cxt && cxt->protect_bootbits; +} + +/** + * fdisk_enable_bootbits_protection: + * @cxt: fdisk context + * @enable: 1 or 0 + * + * The library zeroizes all the first sector when create a new disk label by + * default. This function allows to control this behavior. For now it's + * supported for MBR and GPT. + * + * Returns: 0 on success, < 0 on error. + */ +int fdisk_enable_bootbits_protection(struct fdisk_context *cxt, int enable) +{ + if (!cxt) + return -EINVAL; + cxt->protect_bootbits = enable ? 1 : 0; + return 0; +} + +/** * fdisk_get_npartitions: * @cxt: context * |