disk: Do not fail when empty block device is exported

This commit is contained in:
Pali Rohár committed 2016-12-07 11:38:07 +01:00
1 parent 19e2b22193
commit f2a51b5041
1 file changed
+3 -1
+3 -1
View File
@@ -35,6 +35,7 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h>
#endif #endif
#include "disk.h" #include "disk.h"
@@ -147,6 +148,7 @@ int disk_open_dev(int maj, int min, int partition, int readonly) {
fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL); fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL);
if ( fd < 0 ) { if ( fd < 0 ) {
if ( errno != ENOMEDIUM )
ERROR_INFO("Cannot open block device %s", blkdev); ERROR_INFO("Cannot open block device %s", blkdev);
return -1; return -1;
} }
@@ -371,7 +373,7 @@ int disk_init(struct usb_device_info * dev) {
else else
fd = disk_open_dev(maj1, min1, 1, 1); fd = disk_open_dev(maj1, min1, 1, 1);
if ( fd < 0 ) if ( fd < 0 && errno != ENOMEDIUM )
return -1; return -1;
dev->data = fd; dev->data = fd;