From: "Maciej Małecki" <me@mmalecki.com>
To: util-linux@vger.kernel.org
Cc: "Maciej Małecki" <me@mmalecki.com>
Subject: [PATCH v2 3/3] fdisk: retry opening device in read-only mode
Date: Mon, 3 Mar 2014 22:14:07 +0100 [thread overview]
Message-ID: <1393881247-17092-3-git-send-email-me@mmalecki.com> (raw)
In-Reply-To: <1393881247-17092-1-git-send-email-me@mmalecki.com>
Print a warning if opening in write mode fails.
---
fdisks/fdisk.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c
index 7afd642..1c7b1f7 100644
--- a/fdisks/fdisk.c
+++ b/fdisks/fdisk.c
@@ -538,8 +538,16 @@ int main(int argc, char **argv)
fdisk_info(cxt, _("Changes will remain in memory only, until you decide to write them.\n"
"Be careful before using the write command.\n"));
- if (fdisk_context_assign_device(cxt, argv[optind], 0) != 0)
- err(EXIT_FAILURE, _("cannot open %s"), argv[optind]);
+ if (fdisk_context_assign_device(cxt, argv[optind], 0) != 0) {
+ if (fdisk_context_assign_device(cxt, argv[optind], 1) != 0)
+ err(EXIT_FAILURE, _("cannot open %s"), argv[optind]);
+
+ fdisk_warnx(cxt, _(
+ "Opening device in write mode failed, device "
+ "is open in read-only mode.\nfdisk won't be "
+ "able to write changes."));
+ assert(cxt->readonly);
+ }
fflush(stdout);
--
1.9.0
prev parent reply other threads:[~2014-03-03 21:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-27 3:26 [PATCH 1/2] fdisk: warn if opening a device in write mode failed Maciej Małecki
2014-02-27 3:26 ` [PATCH 2/2] fdisk: do not allow writing to a read-only device Maciej Małecki
2014-02-28 2:32 ` [PATCH 1/2] fdisk: warn if opening a device in write mode failed Davidlohr Bueso
2014-02-28 11:00 ` Maciej Małecki
2014-02-28 16:23 ` Phillip Susi
2014-02-28 18:18 ` Maciej Małecki
2014-02-28 18:27 ` Davidlohr Bueso
2014-02-28 19:18 ` Phillip Susi
2014-03-03 9:04 ` Karel Zak
2014-03-03 21:19 ` Maciej Małecki
2014-03-03 21:47 ` Phillip Susi
2014-03-21 13:10 ` Karel Zak
2014-03-03 21:14 ` [PATCH v2 1/3] fdisk: do not allow writing to a read-only device Maciej Małecki
2014-03-03 21:14 ` [PATCH v2 2/3] libfdisk: remove `O_RDONLY` fallback mode when opening device Maciej Małecki
2014-03-03 21:14 ` Maciej Małecki [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1393881247-17092-3-git-send-email-me@mmalecki.com \
--to=me@mmalecki.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox