Add better error message when the device cannot be opened.
This is helpful for SD cards or other removable media which have an enabled write lock -- without the "Permission denied" message, the user has to strace mkdosfs to find out what's going on. Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
This commit is contained in:
parent
bb6000fc30
commit
d57980204e
@ -1728,8 +1728,10 @@ main (int argc, char **argv)
|
||||
if (!create) {
|
||||
check_mount (device_name); /* Is the device already mounted? */
|
||||
dev = open (device_name, O_EXCL|O_RDWR); /* Is it a suitable device to build the FS on? */
|
||||
if (dev < 0)
|
||||
die ("unable to open %s");
|
||||
if (dev < 0) {
|
||||
fprintf (stderr, "%s: unable to open %s: %s\n", program_name, device_name, strerror(errno));
|
||||
exit (1); /* The error exit code is 1! */
|
||||
}
|
||||
}
|
||||
else {
|
||||
loff_t offset = blocks*BLOCK_SIZE - 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user