summaryrefslogtreecommitdiffstats
path: root/linux.c
diff options
context:
space:
mode:
authorGravatar Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>2013-10-25 23:56:27 +0000
committerGravatar Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>2013-10-25 23:56:27 +0000
commit6259b0301bbdf10c8337be35d440f6f1521ee2b0 (patch)
tree2a190f0b7314d31e891573d3e55ebc2712621e12 /linux.c
parent695f64a23a2b9b5caeceddf802fb1c0c29401c84 (diff)
downloadsubsurface-6259b0301bbdf10c8337be35d440f6f1521ee2b0.tar.gz
fix device probing for UEMIS computer on linux
When the device probing was ported from the Gtk version we skipped the UEMIS code. It's still based on the contents of /proc/mounts, although without the use of glib's helpers. Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
Diffstat (limited to 'linux.c')
-rw-r--r--linux.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/linux.c b/linux.c
index 93481953f..5006ca011 100644
--- a/linux.c
+++ b/linux.c
@@ -37,6 +37,10 @@ int enumerate_devices (device_callback_t callback, void *userdata)
"rfcomm*",
NULL
};
+ FILE *file;
+ char *line = NULL;
+ char *fname;
+ size_t len;
dp = opendir (dirname);
if (dp == NULL) {
@@ -59,8 +63,37 @@ int enumerate_devices (device_callback_t callback, void *userdata)
}
}
}
- // TODO: list UEMIS mount point from /proc/mounts
-
closedir (dp);
+
+ file = fopen("/proc/mounts", "r");
+ if (file == NULL)
+ return index;
+
+ while ((getline(&line, &len, file)) != -1) {
+ char *ptr = strstr(line, "UEMISSDA");
+ if (ptr) {
+ char *end = ptr, *start = ptr;
+ while (start > line && *start != ' ')
+ start--;
+ if (*start == ' ')
+ start++;
+ while (*end != ' ' && *end != '\0')
+ end++;
+
+ *end = '\0';
+ fname = strdup(start);
+
+ callback(fname, userdata);
+
+ if (is_default_dive_computer_device(fname))
+ index = i;
+ i++;
+ free((void *)fname);
+ }
+ }
+
+ free(line);
+ fclose(file);
+
return index;
}