summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-06-14 17:25:34 -0700
committerKeith Packard <keithp@keithp.com>2009-06-14 17:25:34 -0700
commit1c3cc12c08ddefbd6456a55c54ef87dd94d4ae9a (patch)
tree7087170b9b3ba1d860c88a1c2d086d4360609703
parent0f2cbd41332b1b63865c5f1a4e749419b469853a (diff)
Some kernels reference USB ttys as tty/tty* instead of tty:tty*
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--aoview/aoview_dev.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/aoview/aoview_dev.c b/aoview/aoview_dev.c
index 2fabfe26..9b8cc19e 100644
--- a/aoview/aoview_dev.c
+++ b/aoview/aoview_dev.c
@@ -60,11 +60,17 @@ load_hex(char *dir, char *file)
}
static int
-dir_filter_tty(const struct dirent *d)
+dir_filter_tty_colon(const struct dirent *d)
{
return strncmp(d->d_name, "tty:", 4) == 0;
}
+static int
+dir_filter_tty(const struct dirent *d)
+{
+ return strncmp(d->d_name, "tty", 3) == 0;
+}
+
static char *
usb_tty(char *sys)
{
@@ -76,6 +82,7 @@ usb_tty(char *sys)
int num_interfaces;
char endpoint_base[20];
char *endpoint_full;
+ char *tty_dir;
int ntty;
char *tty;
@@ -87,15 +94,32 @@ usb_tty(char *sys)
sprintf(endpoint_base, "%s:%d.%d",
base, config, interface);
endpoint_full = aoview_fullname(sys, endpoint_base);
+
+ /* Check for tty:ttyACMx style names
+ */
ntty = scandir(endpoint_full, &namelist,
- dir_filter_tty,
+ dir_filter_tty_colon,
alphasort);
- free(endpoint_full);
if (ntty > 0) {
+ free(endpoint_full);
tty = aoview_fullname("/dev", namelist[0]->d_name + 4);
free(namelist);
return tty;
}
+
+ /* Check for tty/ttyACMx style names
+ */
+ tty_dir = aoview_fullname(endpoint_full, "tty");
+ free(endpoint_full);
+ ntty = scandir(tty_dir, &namelist,
+ dir_filter_tty,
+ alphasort);
+ free (tty_dir);
+ if (ntty > 0) {
+ tty = aoview_fullname("/dev", namelist[0]->d_name);
+ free(namelist);
+ return tty;
+ }
}
}
return NULL;