Make device enumeration use the device transport data

This removes some special-case code for Uemis, replacing it with simply
passing in the device transport information.

This makes device enumeration work for the Garmin Descent (if it is
listed by libdivecomputer as a USB storage device, that is).

I don't actually do any of the libdivecomputer parsing yet, and only
have a stub for the Garmin Descent, but now the directory selection
works with that stub. The actual download obviously does not.

[Dirk Hohndel: removed obsolete FIXME from code]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2018-08-27 10:32:14 -07:00 committed by Dirk Hohndel
parent bb067b6ee4
commit 270e9eccad
13 changed files with 40 additions and 33 deletions

View file

@ -100,7 +100,7 @@ const char *system_default_filename(void)
return path;
}
int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)
int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)
{
int index = -1, entries = 0;
DIR *dp = NULL;
@ -110,7 +110,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)
char *line = NULL;
char *fname;
size_t len;
if (dc_type != DC_TYPE_UEMIS) {
if (transport & DC_TRANSPORT_SERIAL) {
const char *dirname = "/dev";
#ifdef __OpenBSD__
const char *patterns[] = {
@ -153,7 +153,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)
closedir(dp);
}
#ifdef __linux__
if (dc_type != DC_TYPE_SERIAL) {
if (transport & DC_TRANSPORT_USBSTORAGE) {
int num_uemis = 0;
file = fopen("/proc/mounts", "r");
if (file == NULL)