summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-08-17 23:27:31 +0200
committercinap_lenrek <cinap_lenrek@centraldogma>2011-08-17 23:27:31 +0200
commitc44b78f739a15469ea0d9a1cb3895abeb62e21fc (patch)
tree0289c607eede11a18aa3b08a0f770385a051272c
parent72304eb350228a3267ef339905bef2f11659c4bf (diff)
downloadplan9front-c44b78f739a15469ea0d9a1cb3895abeb62e21fc.tar.xz
change definition of Chan.create to return a chan like open
-rw-r--r--sys/src/9/bitsy/devpenmouse.c3
-rw-r--r--sys/src/9/boot/boot.c1
-rw-r--r--sys/src/9/ip/devip.c3
-rw-r--r--sys/src/9/kw/devether.c4
-rw-r--r--sys/src/9/kw/mkfile2
-rw-r--r--sys/src/9/kw/plug1
-rw-r--r--sys/src/9/mtx/devether.c4
-rw-r--r--sys/src/9/omap/beagle1
-rw-r--r--sys/src/9/omap/devether.c4
-rw-r--r--sys/src/9/pc/devether.c4
-rw-r--r--sys/src/9/port/chan.c2
-rw-r--r--sys/src/9/port/dev.c3
-rw-r--r--sys/src/9/port/devenv.c3
-rw-r--r--sys/src/9/port/devmnt.c4
-rw-r--r--sys/src/9/port/devmouse.c3
-rw-r--r--sys/src/9/port/devshr.c28
-rw-r--r--sys/src/9/port/devsrv.c3
-rw-r--r--sys/src/9/port/portdat.h2
-rw-r--r--sys/src/9/port/portfns.h2
-rw-r--r--sys/src/9/ppc/devether.c4
20 files changed, 62 insertions, 19 deletions
diff --git a/sys/src/9/bitsy/devpenmouse.c b/sys/src/9/bitsy/devpenmouse.c
index 4174c21f7..b26c27711 100644
--- a/sys/src/9/bitsy/devpenmouse.c
+++ b/sys/src/9/bitsy/devpenmouse.c
@@ -214,12 +214,13 @@ penmouseopen(Chan *c, int omode)
return c;
}
-static void
+static Chan*
penmousecreate(Chan*, char*, int, ulong)
{
if(!conf.monitor)
error(Egreg);
error(Eperm);
+ return 0;
}
static void
diff --git a/sys/src/9/boot/boot.c b/sys/src/9/boot/boot.c
index 3f947047d..5ec3118fb 100644
--- a/sys/src/9/boot/boot.c
+++ b/sys/src/9/boot/boot.c
@@ -33,6 +33,7 @@ boot(int argc, char *argv[])
print("%lux %s ", (ulong)argv[i], argv[i]);
print("\n");
}
+ USED(argc);
readfile("#e/cputype", cputype, sizeof(cputype));
setenv("bootdisk", bootdisk, 0);
diff --git a/sys/src/9/ip/devip.c b/sys/src/9/ip/devip.c
index 828345796..93a8514b4 100644
--- a/sys/src/9/ip/devip.c
+++ b/sys/src/9/ip/devip.c
@@ -506,10 +506,11 @@ ipopen(Chan* c, int omode)
return c;
}
-static void
+static Chan*
ipcreate(Chan*, char*, int, ulong)
{
error(Eperm);
+ return 0;
}
static void
diff --git a/sys/src/9/kw/devether.c b/sys/src/9/kw/devether.c
index 4d0a51e4c..63d06f62c 100644
--- a/sys/src/9/kw/devether.c
+++ b/sys/src/9/kw/devether.c
@@ -61,9 +61,11 @@ etheropen(Chan* chan, int omode)
return netifopen(etherxx[chan->dev], chan, omode);
}
-static void
+static Chan*
ethercreate(Chan*, char*, int, ulong)
{
+ error(Eperm);
+ return 0;
}
static void
diff --git a/sys/src/9/kw/mkfile b/sys/src/9/kw/mkfile
index 945c13801..ccd74bcc3 100644
--- a/sys/src/9/kw/mkfile
+++ b/sys/src/9/kw/mkfile
@@ -68,6 +68,8 @@ LIB=\
/$objtype/lib/libip.a\
/$objtype/lib/libsec.a\
/$objtype/lib/libc.a\
+ /$objtype/lib/libmp.a\
+ /$objtype/lib/libfis.a\
9:V: $p$CONF s$p$CONF
diff --git a/sys/src/9/kw/plug b/sys/src/9/kw/plug
index aa13a138f..b91a84580 100644
--- a/sys/src/9/kw/plug
+++ b/sys/src/9/kw/plug
@@ -8,6 +8,7 @@ dev
proc
mnt
srv
+ shr
dup
rtc
arch
diff --git a/sys/src/9/mtx/devether.c b/sys/src/9/mtx/devether.c
index 73c8bac4e..8a5457954 100644
--- a/sys/src/9/mtx/devether.c
+++ b/sys/src/9/mtx/devether.c
@@ -53,9 +53,11 @@ etheropen(Chan* chan, int omode)
return netifopen(etherxx[chan->dev], chan, omode);
}
-static void
+static Chan*
ethercreate(Chan*, char*, int, ulong)
{
+ error(Eperm);
+ return 0;
}
static void
diff --git a/sys/src/9/omap/beagle b/sys/src/9/omap/beagle
index 67fcf9ef0..8852bd7d4 100644
--- a/sys/src/9/omap/beagle
+++ b/sys/src/9/omap/beagle
@@ -7,6 +7,7 @@ dev
proc
mnt
srv
+ shr
dup
arch
ssl
diff --git a/sys/src/9/omap/devether.c b/sys/src/9/omap/devether.c
index f6c32b9f0..2f2e47e0f 100644
--- a/sys/src/9/omap/devether.c
+++ b/sys/src/9/omap/devether.c
@@ -61,9 +61,11 @@ etheropen(Chan* chan, int omode)
return netifopen(etherxx[chan->dev], chan, omode);
}
-static void
+static Chan*
ethercreate(Chan*, char*, int, ulong)
{
+ error(Eperm);
+ return 0;
}
static void
diff --git a/sys/src/9/pc/devether.c b/sys/src/9/pc/devether.c
index d81c9ec48..c9cdd0843 100644
--- a/sys/src/9/pc/devether.c
+++ b/sys/src/9/pc/devether.c
@@ -59,9 +59,11 @@ etheropen(Chan* chan, int omode)
return netifopen(etherxx[chan->dev], chan, omode);
}
-static void
+static Chan*
ethercreate(Chan*, char*, int, ulong)
{
+ error(Eperm);
+ return 0;
}
static void
diff --git a/sys/src/9/port/chan.c b/sys/src/9/port/chan.c
index 12af9baa3..d21e9ac3a 100644
--- a/sys/src/9/port/chan.c
+++ b/sys/src/9/port/chan.c
@@ -1592,7 +1592,7 @@ if(c->umh != nil){
cnew->path = c->path;
incref(cnew->path);
- devtab[cnew->type]->create(cnew, e.elems[e.nelems-1], omode&~(OEXCL|OCEXEC), perm);
+ cnew = devtab[cnew->type]->create(cnew, e.elems[e.nelems-1], omode&~(OEXCL|OCEXEC), perm);
poperror();
if(omode & OCEXEC)
cnew->flag |= CCEXEC;
diff --git a/sys/src/9/port/dev.c b/sys/src/9/port/dev.c
index bbe1fcc12..aa86dad5d 100644
--- a/sys/src/9/port/dev.c
+++ b/sys/src/9/port/dev.c
@@ -383,10 +383,11 @@ Return:
return c;
}
-void
+Chan*
devcreate(Chan*, char*, int, ulong)
{
error(Eperm);
+ return 0;
}
Block*
diff --git a/sys/src/9/port/devenv.c b/sys/src/9/port/devenv.c
index 3031cc50e..b744b12fe 100644
--- a/sys/src/9/port/devenv.c
+++ b/sys/src/9/port/devenv.c
@@ -137,7 +137,7 @@ envopen(Chan *c, int omode)
return c;
}
-static void
+static Chan*
envcreate(Chan *c, char *name, int omode, ulong)
{
Egrp *eg;
@@ -183,6 +183,7 @@ envcreate(Chan *c, char *name, int omode, ulong)
c->offset = 0;
c->mode = omode;
c->flag |= COPEN;
+ return c;
}
static void
diff --git a/sys/src/9/port/devmnt.c b/sys/src/9/port/devmnt.c
index 6f06e0d55..841f3ce71 100644
--- a/sys/src/9/port/devmnt.c
+++ b/sys/src/9/port/devmnt.c
@@ -534,10 +534,10 @@ mntopen(Chan *c, int omode)
return mntopencreate(Topen, c, nil, omode, 0);
}
-static void
+static Chan*
mntcreate(Chan *c, char *name, int omode, ulong perm)
{
- mntopencreate(Tcreate, c, name, omode, perm);
+ return mntopencreate(Tcreate, c, name, omode, perm);
}
static void
diff --git a/sys/src/9/port/devmouse.c b/sys/src/9/port/devmouse.c
index 028d8e2b2..b080e518b 100644
--- a/sys/src/9/port/devmouse.c
+++ b/sys/src/9/port/devmouse.c
@@ -208,12 +208,13 @@ mouseopen(Chan *c, int omode)
return c;
}
-static void
+static Chan*
mousecreate(Chan*, char*, int, ulong)
{
if(!conf.monitor)
error(Egreg);
error(Eperm);
+ return 0;
}
static void
diff --git a/sys/src/9/port/devshr.c b/sys/src/9/port/devshr.c
index 3aa604ea0..ddab43d0b 100644
--- a/sys/src/9/port/devshr.c
+++ b/sys/src/9/port/devshr.c
@@ -418,7 +418,10 @@ shropen(Chan *c, int omode)
return c;
}
-static void
+/* chan.c */
+Chan* createdir(Chan *c, Mhead *m);
+
+static Chan*
shrcreate(Chan *c, char *name, int omode, ulong perm)
{
Sch *sch;
@@ -426,17 +429,34 @@ shrcreate(Chan *c, char *name, int omode, ulong perm)
Mpt *mpt;
Mhead *h;
Mount *m;
+ Chan *nc;
sch = tosch(c);
switch(sch->level){
- default:
- error(Enocreate);
case Qcroot:
case Qcshr:
if(strcmp(up->user, "none") == 0)
error(Eperm);
}
switch(sch->level){
+ default:
+ error(Eperm);
+ case Qshr:
+ incref(c);
+ if(waserror()){
+ cclose(c);
+ nexterror();
+ }
+ nc = createdir(c, &sch->shr->umh);
+ poperror();
+ if(waserror()){
+ cclose(nc);
+ nexterror();
+ }
+ nc = devtab[nc->type]->create(nc, name, omode, perm);
+ poperror();
+ cclose(c);
+ return nc;
case Qcroot:
if((perm & DMDIR) == 0 || openmode(omode) != OREAD)
error(Eperm);
@@ -498,6 +518,7 @@ shrcreate(Chan *c, char *name, int omode, ulong perm)
mpt->perm = perm;
incref(mpt);
+ mpt->m.mflag = (h->mount == nil) ? MCREATE : 0;
mpt->m.head = h;
mpt->m.next = h->mount;
h->mount = &mpt->m;
@@ -511,6 +532,7 @@ shrcreate(Chan *c, char *name, int omode, ulong perm)
}
c->flag |= COPEN;
c->mode = openmode(omode);
+ return c;
}
static void
diff --git a/sys/src/9/port/devsrv.c b/sys/src/9/port/devsrv.c
index 867d077d7..4426d1e00 100644
--- a/sys/src/9/port/devsrv.c
+++ b/sys/src/9/port/devsrv.c
@@ -136,7 +136,7 @@ srvopen(Chan *c, int omode)
return sp->chan;
}
-static void
+static Chan*
srvcreate(Chan *c, char *name, int omode, ulong perm)
{
char *sname;
@@ -175,6 +175,7 @@ srvcreate(Chan *c, char *name, int omode, ulong perm)
c->flag |= COPEN;
c->mode = OWRITE;
+ return c;
}
static void
diff --git a/sys/src/9/port/portdat.h b/sys/src/9/port/portdat.h
index bdc88153a..2fcb37b0b 100644
--- a/sys/src/9/port/portdat.h
+++ b/sys/src/9/port/portdat.h
@@ -209,7 +209,7 @@ struct Dev
Walkqid*(*walk)(Chan*, Chan*, char**, int);
int (*stat)(Chan*, uchar*, int);
Chan* (*open)(Chan*, int);
- void (*create)(Chan*, char*, int, ulong);
+ Chan* (*create)(Chan*, char*, int, ulong);
void (*close)(Chan*);
long (*read)(Chan*, void*, long, vlong);
Block* (*bread)(Chan*, long, ulong);
diff --git a/sys/src/9/port/portfns.h b/sys/src/9/port/portfns.h
index a62e24040..f8f6b809f 100644
--- a/sys/src/9/port/portfns.h
+++ b/sys/src/9/port/portfns.h
@@ -61,7 +61,7 @@ Block* devbread(Chan*, long, ulong);
long devbwrite(Chan*, Block*, ulong);
Chan* devclone(Chan*);
int devconfig(int, char *, DevConf *);
-void devcreate(Chan*, char*, int, ulong);
+Chan* devcreate(Chan*, char*, int, ulong);
void devdir(Chan*, Qid, char*, vlong, char*, long, Dir*);
long devdirread(Chan*, char*, long, Dirtab*, int, Devgen*);
Devgen devgen;
diff --git a/sys/src/9/ppc/devether.c b/sys/src/9/ppc/devether.c
index 6d58e70dd..2f8553932 100644
--- a/sys/src/9/ppc/devether.c
+++ b/sys/src/9/ppc/devether.c
@@ -54,9 +54,11 @@ etheropen(Chan* chan, int omode)
return netifopen(etherxx[chan->dev], chan, omode);
}
-static void
+static Chan*
ethercreate(Chan*, char*, int, ulong)
{
+ error(Eperm);
+ return 0;
}
static void