change definition of Chan.create to return a chan like open

This commit is contained in:
cinap_lenrek 2011-08-17 23:27:31 +02:00
parent 72304eb350
commit c44b78f739
20 changed files with 62 additions and 19 deletions

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -8,6 +8,7 @@ dev
proc
mnt
srv
shr
dup
rtc
arch

View file

@ -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

View file

@ -7,6 +7,7 @@ dev
proc
mnt
srv
shr
dup
arch
ssl

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -383,10 +383,11 @@ Return:
return c;
}
void
Chan*
devcreate(Chan*, char*, int, ulong)
{
error(Eperm);
return 0;
}
Block*

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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;

View file

@ -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