summaryrefslogtreecommitdiffstats
path: root/atasmart.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-04-14 22:23:28 +0200
committerLennart Poettering <lennart@poettering.net>2009-04-14 22:23:28 +0200
commitfd56d21c7477f026bb1c9d353c461d08e22ba024 (patch)
tree5bb896f574292e6c60ea7e2d1f51de33135a7c58 /atasmart.c
parent9da1b3dd07682dcd77320b658a2addc95b6973e8 (diff)
when dealing with unknown block device type don't confuse with sunplus device
Diffstat (limited to 'atasmart.c')
-rw-r--r--atasmart.c11
1 files changed, 10 insertions, 1 deletions
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);