diff options
author | Karel Zak | 2014-03-21 14:04:59 +0100 |
---|---|---|
committer | Karel Zak | 2014-03-21 14:04:59 +0100 |
commit | e146ae4edb52b0559cbb42717338665c6395b56f (patch) | |
tree | 95f86c65e0c0f4d1eed1940b92a955be838dc670 /disk-utils/fdisk-menu.c | |
parent | libfdisk: clean up debug output (diff) | |
download | kernel-qcow2-util-linux-e146ae4edb52b0559cbb42717338665c6395b56f.tar.gz kernel-qcow2-util-linux-e146ae4edb52b0559cbb42717338665c6395b56f.tar.xz kernel-qcow2-util-linux-e146ae4edb52b0559cbb42717338665c6395b56f.zip |
libfdisk: properly implement read-only mode
Don't use fallback to read-only mode in fdisk_context_assign_device(),
it's application responsibility open the device in the right mode.
The commands fdisk and cfdisk check (and report) read-only mode now.
Reported-by: Maciej MaĆecki <me@mmalecki.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/fdisk-menu.c')
-rw-r--r-- | disk-utils/fdisk-menu.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c index 822761568..bdaa73475 100644 --- a/disk-utils/fdisk-menu.c +++ b/disk-utils/fdisk-menu.c @@ -447,6 +447,10 @@ static int generic_menu_cb(struct fdisk_context **cxt0, list_disklabel(cxt); break; case 'w': + if (fdisk_context_is_readonly(cxt)) { + fdisk_warnx(cxt, _("Device open in read-only mode.")); + break; + } rc = fdisk_write_disklabel(cxt); if (rc) err(EXIT_FAILURE, _("failed to write disklabel")); |