summaryrefslogtreecommitdiff
path: root/emu/port/devindir.c
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2009-03-25 15:55:14 +0000
committerCharles.Forsyth <devnull@localhost>2009-03-25 15:55:14 +0000
commitdfd1934d5e1ddbeb326f77fc0e52307c801a1a3e (patch)
treef1e8b23278caae95e01d88b00421d6c3642357ef /emu/port/devindir.c
parent78dfdcbd59dc8f36975e7695933e3f753957474c (diff)
x20090325-1554
Diffstat (limited to 'emu/port/devindir.c')
-rw-r--r--emu/port/devindir.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/emu/port/devindir.c b/emu/port/devindir.c
new file mode 100644
index 00000000..9c214927
--- /dev/null
+++ b/emu/port/devindir.c
@@ -0,0 +1,35 @@
+#include "dat.h"
+#include "fns.h"
+#include "error.h"
+
+static Chan *
+indirattach(char *spec)
+{
+ char *p;
+ Dev *d;
+
+ if(*spec == 0)
+ error(Ebadspec);
+ p = strrchr(spec, '!');
+ if(p == nil)
+ p = "";
+ else
+ *p++ = 0;
+ d = devbyname(spec);
+ if(d == nil || d->dc == '*'){
+ snprint(up->env->errstr, ERRMAX, "unknown device: %s", spec);
+ error(up->env->errstr);
+ }
+ if(up->env->pgrp->nodevs &&
+ (utfrune("|esDa", d->dc) == nil || d->dc == 's' && *p!='\0'))
+ error(Enoattach);
+ return d->attach(p);
+}
+
+Dev indirdevtab = {
+ '*',
+ "indir",
+
+ devinit,
+ indirattach,
+};