diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2001-01-09 15:56:40 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2001-01-09 15:56:40 +0000 |
commit | 0b3be608ea5b573446f0ff8b82b8c300a65bbbd0 (patch) | |
tree | d083240ccb9134fc9190710cab15ba319315aba5 /libstore | |
parent | 9427ecdc49da3ab43a4cfbf7c667c1ea4a89bb5e (diff) |
2001-01-09 Marcus Brinkmann <marcus@gnu.org>
* device.c (store_device_create): Protect code of last change with
#ifdef DEV_GET_RECORDS, and set sizes_len again before second try.
(enforce): Likewise. Move definition of variable err up to top
level.
Diffstat (limited to 'libstore')
-rw-r--r-- | libstore/ChangeLog | 7 | ||||
-rw-r--r-- | libstore/device.c | 12 |
2 files changed, 16 insertions, 3 deletions
diff --git a/libstore/ChangeLog b/libstore/ChangeLog index 5346f9ff..83cea5fb 100644 --- a/libstore/ChangeLog +++ b/libstore/ChangeLog @@ -1,5 +1,12 @@ 2001-01-09 Marcus Brinkmann <marcus@gnu.org> + * device.c (store_device_create): Protect code of last change with + #ifdef DEV_GET_RECORDS, and set sizes_len again before second try. + (enforce): Likewise. Move definition of variable err up to top + level. + +2001-01-09 Marcus Brinkmann <marcus@gnu.org> + * device.c (enforce): First try DEV_GET_RECORDS, and only fall back to DEV_GET_STORE if this fails with D_INVALID_OPERATION. (store_device_create): Likewise, but fall back for any failure. diff --git a/libstore/device.c b/libstore/device.c index e9b5704e..97fe8036 100644 --- a/libstore/device.c +++ b/libstore/device.c @@ -116,6 +116,7 @@ dclose (struct store *store) static error_t enforced (struct store *store) { + error_t err; size_t sizes[DEV_STATUS_MAX]; size_t sizes_len = DEV_STATUS_MAX; @@ -125,7 +126,8 @@ enforced (struct store *store) else /* See if the the current (one) range is that the kernel is enforcing. */ { - error_t err = +#ifdef DEV_GET_RECORDS + err = device_get_status (store->port, DEV_GET_RECORDS, sizes, &sizes_len); if (err && err != D_INVALID_OPERATION) @@ -143,9 +145,10 @@ enforced (struct store *store) return 0; } else +#endif { - sizes_len = DEV_GET_SIZE_COUNT; - error_t err = + sizes_len = DEV_STATUS_MAX; + err = device_get_status (store->port, DEV_GET_SIZE, sizes, &sizes_len); if (err) @@ -238,6 +241,7 @@ store_device_create (device_t device, int flags, struct store **store) size_t sizes_len = DEV_STATUS_MAX; error_t err; +#ifdef DEV_GET_RECORDS err = device_get_status (device, DEV_GET_RECORDS, sizes, &sizes_len); if (! err && sizes_len == DEV_GET_RECORDS_COUNT) { @@ -250,12 +254,14 @@ store_device_create (device_t device, int flags, struct store **store) } } else +#endif { /* Some Mach devices do not implement device_get_status, but do not return an error. To detect these devices we set the size of the input buffer to something larger than DEV_GET_SIZE_COUNT. If the size of the returned device status is not equal to DEV_GET_SIZE_COUNT, we know that something is wrong. */ + sizes_len = DEV_STATUS_MAX; err = device_get_status (device, DEV_GET_SIZE, sizes, &sizes_len); if (! err && sizes_len == DEV_GET_SIZE_COUNT) { |