diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-04-14 22:23:28 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-04-14 22:23:28 +0200 |
commit | fd56d21c7477f026bb1c9d353c461d08e22ba024 (patch) | |
tree | 5bb896f574292e6c60ea7e2d1f51de33135a7c58 | |
parent | 9da1b3dd07682dcd77320b658a2addc95b6973e8 (diff) |
when dealing with unknown block device type don't confuse with sunplus device
-rw-r--r-- | atasmart.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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); |