summaryrefslogtreecommitdiff
path: root/libdde_linux26/lib/src/mach_glue
diff options
context:
space:
mode:
authorZheng Da <zhengda1936@gmail.com>2010-06-17 11:14:58 +0200
committerZheng Da <zhengda1936@gmail.com>2010-06-17 11:14:58 +0200
commitd8d10fa335320a3e8e0783b8a74346364b08614a (patch)
treed08a9cd3f4d23bc0ce2b9136846e91ec4b5538be /libdde_linux26/lib/src/mach_glue
parente9762c27cfc0b614ca09b4812351c83167501447 (diff)
check disk existence in open_block_dev.
Diffstat (limited to 'libdde_linux26/lib/src/mach_glue')
-rw-r--r--libdde_linux26/lib/src/mach_glue/block.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libdde_linux26/lib/src/mach_glue/block.c b/libdde_linux26/lib/src/mach_glue/block.c
index 7eac7e46..a856cc9b 100644
--- a/libdde_linux26/lib/src/mach_glue/block.c
+++ b/libdde_linux26/lib/src/mach_glue/block.c
@@ -9,8 +9,12 @@ void dde_page_cache_add (struct page *);
struct block_device *open_block_dev (char *name, int part, fmode_t mode)
{
struct gendisk *disk = find_disk_by_name (name);
- dev_t devid = MKDEV (disk->major, disk->first_minor + part);
- return open_by_devnum (devid, mode);
+ if (disk)
+ {
+ dev_t devid = MKDEV (disk->major, disk->first_minor + part);
+ return open_by_devnum (devid, mode);
+ }
+ return ERR_PTR(-ENXIO);
}
/* write a piece of data to a block device.