Преглед на файлове

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>
Michael Stapelberg преди 13 години
родител
ревизия
d57980204e
променени са 1 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 4 2
      src/mkdosfs.c

+ 4 - 2
src/mkdosfs.c

@@ -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;