cwfs: various cleanups
- consistently refer to Dentry.name length with NAMELEN - make sure whoname is null terminated - remove useless nil check for whoname
This commit is contained in:
parent
76e0968e35
commit
ffe4844da8
3 changed files with 6 additions and 8 deletions
|
@ -348,7 +348,7 @@ attach(Chan* chan, Fcall* f, Fcall* r)
|
||||||
|
|
||||||
r->qid = file->qid;
|
r->qid = file->qid;
|
||||||
|
|
||||||
strncpy(chan->whoname, f->uname, sizeof(chan->whoname));
|
snprint(chan->whoname, sizeof(chan->whoname), "%s", f->uname);
|
||||||
chan->whotime = time(nil);
|
chan->whotime = time(nil);
|
||||||
out:
|
out:
|
||||||
if(p != nil)
|
if(p != nil)
|
||||||
|
@ -913,7 +913,7 @@ fs_create(Chan* chan, Fcall* f, Fcall* r)
|
||||||
goto phase;
|
goto phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(d1->name, f->name, sizeof(d1->name));
|
strncpy(d1->name, f->name, NAMELEN);
|
||||||
if(chan == cons.chan){
|
if(chan == cons.chan){
|
||||||
d1->uid = cons.uid;
|
d1->uid = cons.uid;
|
||||||
d1->gid = cons.gid;
|
d1->gid = cons.gid;
|
||||||
|
@ -1014,7 +1014,6 @@ fs_read(Chan* chan, Fcall* f, Fcall* r, uchar* data)
|
||||||
}
|
}
|
||||||
iounit = chan->msize-IOHDRSZ;
|
iounit = chan->msize-IOHDRSZ;
|
||||||
if(count < 0 || count > iounit){
|
if(count < 0 || count > iounit){
|
||||||
fprint(2, "fs_read %d %d\n", count, iounit);
|
|
||||||
error = Ecount;
|
error = Ecount;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1786,7 +1785,7 @@ fs_wstat(Chan* chan, Fcall* f, Fcall*, char* strs)
|
||||||
}
|
}
|
||||||
d->size = dir.length;
|
d->size = dir.length;
|
||||||
if(dir.name != d->name)
|
if(dir.name != d->name)
|
||||||
strncpy(d->name, dir.name, sizeof(d->name));
|
strncpy(d->name, dir.name, NAMELEN);
|
||||||
d->uid = uid;
|
d->uid = uid;
|
||||||
d->gid = gid;
|
d->gid = gid;
|
||||||
d->muid = muid;
|
d->muid = muid;
|
||||||
|
|
|
@ -14,7 +14,7 @@ consserve(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
strncpy(cons.chan->whochan, "console", sizeof(cons.chan->whochan));
|
snprint(cons.chan->whochan, sizeof(cons.chan->whochan), "console");
|
||||||
installcmds();
|
installcmds();
|
||||||
con_session();
|
con_session();
|
||||||
cmd_exec("cfs");
|
cmd_exec("cfs");
|
||||||
|
@ -312,8 +312,7 @@ cmd_who(int argc, char *argv[])
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("%3d: %10s %24s", cp->chan,
|
print("%3d: %10s %24s", cp->chan, cp->whoname, cp->whochan);
|
||||||
cp->whoname? cp->whoname: "<nowhoname>", cp->whochan);
|
|
||||||
if(cp->whoprint)
|
if(cp->whoprint)
|
||||||
cp->whoprint(cp);
|
cp->whoprint(cp);
|
||||||
print("\n");
|
print("\n");
|
||||||
|
|
|
@ -46,7 +46,7 @@ fs_chaninit(int count, int data)
|
||||||
chans = cp;
|
chans = cp;
|
||||||
cp->chan = cons.chano;
|
cp->chan = cons.chano;
|
||||||
cons.chano++;
|
cons.chano++;
|
||||||
strncpy(cp->whoname, "<none>", sizeof cp->whoname);
|
snprint(cp->whoname, sizeof(cp->whoname), "<none>");
|
||||||
wlock(&cp->reflock);
|
wlock(&cp->reflock);
|
||||||
wunlock(&cp->reflock);
|
wunlock(&cp->reflock);
|
||||||
rlock(&cp->reflock);
|
rlock(&cp->reflock);
|
||||||
|
|
Loading…
Reference in a new issue