change definition of Chan.create to return a chan like open
This commit is contained in:
parent
72304eb350
commit
c44b78f739
20 changed files with 62 additions and 19 deletions
|
@ -214,12 +214,13 @@ penmouseopen(Chan *c, int omode)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Chan*
|
||||||
penmousecreate(Chan*, char*, int, ulong)
|
penmousecreate(Chan*, char*, int, ulong)
|
||||||
{
|
{
|
||||||
if(!conf.monitor)
|
if(!conf.monitor)
|
||||||
error(Egreg);
|
error(Egreg);
|
||||||
error(Eperm);
|
error(Eperm);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -33,6 +33,7 @@ boot(int argc, char *argv[])
|
||||||
print("%lux %s ", (ulong)argv[i], argv[i]);
|
print("%lux %s ", (ulong)argv[i], argv[i]);
|
||||||
print("\n");
|
print("\n");
|
||||||
}
|
}
|
||||||
|
USED(argc);
|
||||||
|
|
||||||
readfile("#e/cputype", cputype, sizeof(cputype));
|
readfile("#e/cputype", cputype, sizeof(cputype));
|
||||||
setenv("bootdisk", bootdisk, 0);
|
setenv("bootdisk", bootdisk, 0);
|
||||||
|
|
|
@ -506,10 +506,11 @@ ipopen(Chan* c, int omode)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Chan*
|
||||||
ipcreate(Chan*, char*, int, ulong)
|
ipcreate(Chan*, char*, int, ulong)
|
||||||
{
|
{
|
||||||
error(Eperm);
|
error(Eperm);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -61,9 +61,11 @@ etheropen(Chan* chan, int omode)
|
||||||
return netifopen(etherxx[chan->dev], chan, omode);
|
return netifopen(etherxx[chan->dev], chan, omode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Chan*
|
||||||
ethercreate(Chan*, char*, int, ulong)
|
ethercreate(Chan*, char*, int, ulong)
|
||||||
{
|
{
|
||||||
|
error(Eperm);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -68,6 +68,8 @@ LIB=\
|
||||||
/$objtype/lib/libip.a\
|
/$objtype/lib/libip.a\
|
||||||
/$objtype/lib/libsec.a\
|
/$objtype/lib/libsec.a\
|
||||||
/$objtype/lib/libc.a\
|
/$objtype/lib/libc.a\
|
||||||
|
/$objtype/lib/libmp.a\
|
||||||
|
/$objtype/lib/libfis.a\
|
||||||
|
|
||||||
9:V: $p$CONF s$p$CONF
|
9:V: $p$CONF s$p$CONF
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ dev
|
||||||
proc
|
proc
|
||||||
mnt
|
mnt
|
||||||
srv
|
srv
|
||||||
|
shr
|
||||||
dup
|
dup
|
||||||
rtc
|
rtc
|
||||||
arch
|
arch
|
||||||
|
|
|
@ -53,9 +53,11 @@ etheropen(Chan* chan, int omode)
|
||||||
return netifopen(etherxx[chan->dev], chan, omode);
|
return netifopen(etherxx[chan->dev], chan, omode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Chan*
|
||||||
ethercreate(Chan*, char*, int, ulong)
|
ethercreate(Chan*, char*, int, ulong)
|
||||||
{
|
{
|
||||||
|
error(Eperm);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -7,6 +7,7 @@ dev
|
||||||
proc
|
proc
|
||||||
mnt
|
mnt
|
||||||
srv
|
srv
|
||||||
|
shr
|
||||||
dup
|
dup
|
||||||
arch
|
arch
|
||||||
ssl
|
ssl
|
||||||
|
|
|
@ -61,9 +61,11 @@ etheropen(Chan* chan, int omode)
|
||||||
return netifopen(etherxx[chan->dev], chan, omode);
|
return netifopen(etherxx[chan->dev], chan, omode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Chan*
|
||||||
ethercreate(Chan*, char*, int, ulong)
|
ethercreate(Chan*, char*, int, ulong)
|
||||||
{
|
{
|
||||||
|
error(Eperm);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -59,9 +59,11 @@ etheropen(Chan* chan, int omode)
|
||||||
return netifopen(etherxx[chan->dev], chan, omode);
|
return netifopen(etherxx[chan->dev], chan, omode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Chan*
|
||||||
ethercreate(Chan*, char*, int, ulong)
|
ethercreate(Chan*, char*, int, ulong)
|
||||||
{
|
{
|
||||||
|
error(Eperm);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -1592,7 +1592,7 @@ if(c->umh != nil){
|
||||||
cnew->path = c->path;
|
cnew->path = c->path;
|
||||||
incref(cnew->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();
|
poperror();
|
||||||
if(omode & OCEXEC)
|
if(omode & OCEXEC)
|
||||||
cnew->flag |= CCEXEC;
|
cnew->flag |= CCEXEC;
|
||||||
|
|
|
@ -383,10 +383,11 @@ Return:
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
Chan*
|
||||||
devcreate(Chan*, char*, int, ulong)
|
devcreate(Chan*, char*, int, ulong)
|
||||||
{
|
{
|
||||||
error(Eperm);
|
error(Eperm);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block*
|
Block*
|
||||||
|
|
|
@ -137,7 +137,7 @@ envopen(Chan *c, int omode)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Chan*
|
||||||
envcreate(Chan *c, char *name, int omode, ulong)
|
envcreate(Chan *c, char *name, int omode, ulong)
|
||||||
{
|
{
|
||||||
Egrp *eg;
|
Egrp *eg;
|
||||||
|
@ -183,6 +183,7 @@ envcreate(Chan *c, char *name, int omode, ulong)
|
||||||
c->offset = 0;
|
c->offset = 0;
|
||||||
c->mode = omode;
|
c->mode = omode;
|
||||||
c->flag |= COPEN;
|
c->flag |= COPEN;
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -534,10 +534,10 @@ mntopen(Chan *c, int omode)
|
||||||
return mntopencreate(Topen, c, nil, omode, 0);
|
return mntopencreate(Topen, c, nil, omode, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Chan*
|
||||||
mntcreate(Chan *c, char *name, int omode, ulong perm)
|
mntcreate(Chan *c, char *name, int omode, ulong perm)
|
||||||
{
|
{
|
||||||
mntopencreate(Tcreate, c, name, omode, perm);
|
return mntopencreate(Tcreate, c, name, omode, perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -208,12 +208,13 @@ mouseopen(Chan *c, int omode)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Chan*
|
||||||
mousecreate(Chan*, char*, int, ulong)
|
mousecreate(Chan*, char*, int, ulong)
|
||||||
{
|
{
|
||||||
if(!conf.monitor)
|
if(!conf.monitor)
|
||||||
error(Egreg);
|
error(Egreg);
|
||||||
error(Eperm);
|
error(Eperm);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -418,7 +418,10 @@ shropen(Chan *c, int omode)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/* chan.c */
|
||||||
|
Chan* createdir(Chan *c, Mhead *m);
|
||||||
|
|
||||||
|
static Chan*
|
||||||
shrcreate(Chan *c, char *name, int omode, ulong perm)
|
shrcreate(Chan *c, char *name, int omode, ulong perm)
|
||||||
{
|
{
|
||||||
Sch *sch;
|
Sch *sch;
|
||||||
|
@ -426,17 +429,34 @@ shrcreate(Chan *c, char *name, int omode, ulong perm)
|
||||||
Mpt *mpt;
|
Mpt *mpt;
|
||||||
Mhead *h;
|
Mhead *h;
|
||||||
Mount *m;
|
Mount *m;
|
||||||
|
Chan *nc;
|
||||||
|
|
||||||
sch = tosch(c);
|
sch = tosch(c);
|
||||||
switch(sch->level){
|
switch(sch->level){
|
||||||
default:
|
|
||||||
error(Enocreate);
|
|
||||||
case Qcroot:
|
case Qcroot:
|
||||||
case Qcshr:
|
case Qcshr:
|
||||||
if(strcmp(up->user, "none") == 0)
|
if(strcmp(up->user, "none") == 0)
|
||||||
error(Eperm);
|
error(Eperm);
|
||||||
}
|
}
|
||||||
switch(sch->level){
|
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:
|
case Qcroot:
|
||||||
if((perm & DMDIR) == 0 || openmode(omode) != OREAD)
|
if((perm & DMDIR) == 0 || openmode(omode) != OREAD)
|
||||||
error(Eperm);
|
error(Eperm);
|
||||||
|
@ -498,6 +518,7 @@ shrcreate(Chan *c, char *name, int omode, ulong perm)
|
||||||
mpt->perm = perm;
|
mpt->perm = perm;
|
||||||
|
|
||||||
incref(mpt);
|
incref(mpt);
|
||||||
|
mpt->m.mflag = (h->mount == nil) ? MCREATE : 0;
|
||||||
mpt->m.head = h;
|
mpt->m.head = h;
|
||||||
mpt->m.next = h->mount;
|
mpt->m.next = h->mount;
|
||||||
h->mount = &mpt->m;
|
h->mount = &mpt->m;
|
||||||
|
@ -511,6 +532,7 @@ shrcreate(Chan *c, char *name, int omode, ulong perm)
|
||||||
}
|
}
|
||||||
c->flag |= COPEN;
|
c->flag |= COPEN;
|
||||||
c->mode = openmode(omode);
|
c->mode = openmode(omode);
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -136,7 +136,7 @@ srvopen(Chan *c, int omode)
|
||||||
return sp->chan;
|
return sp->chan;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Chan*
|
||||||
srvcreate(Chan *c, char *name, int omode, ulong perm)
|
srvcreate(Chan *c, char *name, int omode, ulong perm)
|
||||||
{
|
{
|
||||||
char *sname;
|
char *sname;
|
||||||
|
@ -175,6 +175,7 @@ srvcreate(Chan *c, char *name, int omode, ulong perm)
|
||||||
|
|
||||||
c->flag |= COPEN;
|
c->flag |= COPEN;
|
||||||
c->mode = OWRITE;
|
c->mode = OWRITE;
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -209,7 +209,7 @@ struct Dev
|
||||||
Walkqid*(*walk)(Chan*, Chan*, char**, int);
|
Walkqid*(*walk)(Chan*, Chan*, char**, int);
|
||||||
int (*stat)(Chan*, uchar*, int);
|
int (*stat)(Chan*, uchar*, int);
|
||||||
Chan* (*open)(Chan*, int);
|
Chan* (*open)(Chan*, int);
|
||||||
void (*create)(Chan*, char*, int, ulong);
|
Chan* (*create)(Chan*, char*, int, ulong);
|
||||||
void (*close)(Chan*);
|
void (*close)(Chan*);
|
||||||
long (*read)(Chan*, void*, long, vlong);
|
long (*read)(Chan*, void*, long, vlong);
|
||||||
Block* (*bread)(Chan*, long, ulong);
|
Block* (*bread)(Chan*, long, ulong);
|
||||||
|
|
|
@ -61,7 +61,7 @@ Block* devbread(Chan*, long, ulong);
|
||||||
long devbwrite(Chan*, Block*, ulong);
|
long devbwrite(Chan*, Block*, ulong);
|
||||||
Chan* devclone(Chan*);
|
Chan* devclone(Chan*);
|
||||||
int devconfig(int, char *, DevConf *);
|
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*);
|
void devdir(Chan*, Qid, char*, vlong, char*, long, Dir*);
|
||||||
long devdirread(Chan*, char*, long, Dirtab*, int, Devgen*);
|
long devdirread(Chan*, char*, long, Dirtab*, int, Devgen*);
|
||||||
Devgen devgen;
|
Devgen devgen;
|
||||||
|
|
|
@ -54,9 +54,11 @@ etheropen(Chan* chan, int omode)
|
||||||
return netifopen(etherxx[chan->dev], chan, omode);
|
return netifopen(etherxx[chan->dev], chan, omode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Chan*
|
||||||
ethercreate(Chan*, char*, int, ulong)
|
ethercreate(Chan*, char*, int, ulong)
|
||||||
{
|
{
|
||||||
|
error(Eperm);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue