summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2016-12-07 11:38:07 +0100
committerPali Rohár <pali.rohar@gmail.com>2016-12-07 11:38:07 +0100
commitf2a51b5041f01858a0154fb06fc9d7054f94ccbb (patch)
tree14055a9c8eac98c0d989142e0746d84f09182e39
parent19e2b22193776e8edc3b45679e3fcc7b0bf8bb5f (diff)
download0xFFFF-f2a51b5041f01858a0154fb06fc9d7054f94ccbb.tar.bz2
disk: Do not fail when empty block device is exported
-rw-r--r--src/disk.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/disk.c b/src/disk.c
index 11df4af..50dac45 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -35,6 +35,7 @@
#include <sys/ioctl.h>
#include <linux/fs.h>
#include <dirent.h>
+#include <errno.h>
#endif
#include "disk.h"
@@ -147,7 +148,8 @@ int disk_open_dev(int maj, int min, int partition, int readonly) {
fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL);
if ( fd < 0 ) {
- ERROR_INFO("Cannot open block device %s", blkdev);
+ if ( errno != ENOMEDIUM )
+ ERROR_INFO("Cannot open block device %s", blkdev);
return -1;
}
@@ -371,7 +373,7 @@ int disk_init(struct usb_device_info * dev) {
else
fd = disk_open_dev(maj1, min1, 1, 1);
- if ( fd < 0 )
+ if ( fd < 0 && errno != ENOMEDIUM )
return -1;
dev->data = fd;