]> git.ipfire.org Git - thirdparty/libatasmart.git/commitdiff
when dealing with unknown block device type don't confuse with sunplus device
authorLennart Poettering <lennart@poettering.net>
Tue, 14 Apr 2009 20:23:28 +0000 (22:23 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 14 Apr 2009 20:23:28 +0000 (22:23 +0200)
atasmart.c

index 456e4d3d6f2cfa0f762f462d02d4b158ccebb936..da6138b1889d15518034e9199794fe7d88dd5e28 100644 (file)
@@ -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);