From fd56d21c7477f026bb1c9d353c461d08e22ba024 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 14 Apr 2009 22:23:28 +0200 Subject: when dealing with unknown block device type don't confuse with sunplus device --- atasmart.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/atasmart.c b/atasmart.c index 456e4d3..da6138b 100644 --- a/atasmart.c +++ b/atasmart.c @@ -512,7 +512,9 @@ static int disk_command(SkDisk *d, SkAtaCommand command, SkDirection direction, [SK_DISK_TYPE_ATA] = disk_ata_command, [SK_DISK_TYPE_ATA_PASSTHROUGH_12] = disk_passthrough_12_command, [SK_DISK_TYPE_ATA_PASSTHROUGH_16] = disk_passthrough_16_command, - [SK_DISK_TYPE_SUNPLUS] = disk_sunplus_command + [SK_DISK_TYPE_SUNPLUS] = disk_sunplus_command, + [SK_DISK_TYPE_BLOB] = NULL, + [SK_DISK_TYPE_UNKNOWN] = NULL }; assert(d); @@ -522,6 +524,11 @@ static int disk_command(SkDisk *d, SkAtaCommand command, SkDirection direction, assert(direction == SK_DIRECTION_NONE || (data && len && *len > 0)); assert(direction != SK_DIRECTION_NONE || (!data && !len)); + if (!disk_command_table[d->type]) { + errno = -ENOTSUP; + return -1; + } + return disk_command_table[d->type](d, command, direction, cmd_data, data, len); } @@ -2177,6 +2184,8 @@ int sk_disk_open(const char *name, SkDisk **_d) { for (d->type = 0; d->type < _SK_DISK_TYPE_TEST_MAX; d->type++) if (disk_identify_device(d) >= 0) break; + if (d->type >= _SK_DISK_TYPE_TEST_MAX) + d->type = SK_DISK_TYPE_UNKNOWN; } else disk_identify_device(d); -- cgit