summaryrefslogtreecommitdiffstats
path: root/src/disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/disk.c')
-rw-r--r--src/disk.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/disk.c b/src/disk.c
index 8a16ca3..63f7a52 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -131,8 +131,18 @@ int disk_open_dev(int maj, int min, int partition, int readonly) {
if ( stat(blkdev, &st) != 0 || ! S_ISBLK(st.st_mode) ) {
memcpy(blkdev+len, "1", 2);
if ( stat(blkdev, &st) != 0 || ! S_ISBLK(st.st_mode) ) {
- ERROR("Block device has partitions");
- return -1;
+ blkdev[len] = 0;
+ fd = open(blkdev, O_RDONLY);
+ if ( fd < 0 ) {
+ if ( errno != ENOMEDIUM ) {
+ ERROR_INFO("Cannot open block device %s", blkdev);
+ return -1;
+ }
+ } else {
+ close(fd);
+ ERROR("Block device does not have partitions");
+ return -1;
+ }
}
}