hjfs: simplify dprinting
This commit is contained in:
parent
2e64925b91
commit
3103efb8b0
|
@ -455,7 +455,7 @@ found:
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
erropt:
|
erropt:
|
||||||
dprint("hjfs: newuser: ignoring erroneous option %s\n", argv[i]);
|
dprint("newuser: ignoring erroneous option %s\n", argv[i]);
|
||||||
}
|
}
|
||||||
if(resort)
|
if(resort)
|
||||||
qsort(fs->udata, fs->nudata, sizeof(User), usercomp);
|
qsort(fs->udata, fs->nudata, sizeof(User), usercomp);
|
||||||
|
|
|
@ -274,7 +274,7 @@ getbuf(Dev *d, uvlong off, int type, int nodata)
|
||||||
if(nodata)
|
if(nodata)
|
||||||
b->type = type;
|
b->type = type;
|
||||||
if(b->type != type && type != -1){
|
if(b->type != type && type != -1){
|
||||||
dprint("hjfs: type mismatch, dev %s, block %lld, got %T, want %T, caller %#p\n",
|
dprint("type mismatch, dev %s, block %lld, got %T, want %T, caller %#p\n",
|
||||||
d->name, off, b->type, type, getcallerpc(&d));
|
d->name, off, b->type, type, getcallerpc(&d));
|
||||||
werrstr("phase error -- type mismatch");
|
werrstr("phase error -- type mismatch");
|
||||||
putbuf(b);
|
putbuf(b);
|
||||||
|
|
|
@ -67,7 +67,7 @@ int
|
||||||
cmdsync(int, char **)
|
cmdsync(int, char **)
|
||||||
{
|
{
|
||||||
sync(1);
|
sync(1);
|
||||||
dprint("hjfs: sync\n");
|
dprint("sync\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ int
|
||||||
cmddump(int, char **)
|
cmddump(int, char **)
|
||||||
{
|
{
|
||||||
fsdump(fsmain);
|
fsdump(fsmain);
|
||||||
dprint("hjfs: dumped\n");
|
dprint("dumped\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ int
|
||||||
cmdallow(int, char **)
|
cmdallow(int, char **)
|
||||||
{
|
{
|
||||||
fsmain->flags |= FSNOPERM | FSCHOWN;
|
fsmain->flags |= FSNOPERM | FSCHOWN;
|
||||||
dprint("hjfs: allow\n");
|
dprint("allow\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,15 +123,15 @@ checkfile(FLoc *l, Buf *b)
|
||||||
|
|
||||||
for(i = 0; i < d->size; i++){
|
for(i = 0; i < d->size; i++){
|
||||||
if(getblk(fsmain, l, b, i, &r, GBREAD) <= 0){
|
if(getblk(fsmain, l, b, i, &r, GBREAD) <= 0){
|
||||||
dprint("hjfs: %s in block %ulld at index %d has a bad block at index %ulld: %r\n", ftype, l->blk, l->deind, i);
|
dprint("%s in block %ulld at index %d has a bad block at index %ulld: %r\n", ftype, l->blk, l->deind, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
c = getbuf(fsmain->d, r, btype, 0);
|
c = getbuf(fsmain->d, r, btype, 0);
|
||||||
if(c == nil)
|
if(c == nil)
|
||||||
dprint("hjfs: %s in block %ulld at index %d has a bad block %ulld at directory index %ulld: %r\n", ftype, l->blk, l->deind, r, i);
|
dprint("%s in block %ulld at index %d has a bad block %ulld at directory index %ulld: %r\n", ftype, l->blk, l->deind, r, i);
|
||||||
putbuf(c);
|
putbuf(c);
|
||||||
if(chref(fsmain, r, 0) == 0)
|
if(chref(fsmain, r, 0) == 0)
|
||||||
dprint("hjfs: %s in block %ulld at index %d has a block %ulld at index %ulld whose reference count is 0", ftype, l->blk, l->deind, r, i);
|
dprint("%s in block %ulld at index %d has a block %ulld at index %ulld whose reference count is 0", ftype, l->blk, l->deind, r, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ checkblk(uvlong blk)
|
||||||
return -1;
|
return -1;
|
||||||
switch(type = b->type){
|
switch(type = b->type){
|
||||||
case TSUPERBLOCK:
|
case TSUPERBLOCK:
|
||||||
dprint("hjfs: checkblk: should not have found superblock at %ulld\n", blk);
|
dprint("checkblk: should not have found superblock at %ulld\n", blk);
|
||||||
break;
|
break;
|
||||||
case TDENTRY:
|
case TDENTRY:
|
||||||
l.blk = blk;
|
l.blk = blk;
|
||||||
|
@ -214,11 +214,11 @@ cmdcheck(int, char**)
|
||||||
putbuf(b);
|
putbuf(b);
|
||||||
}
|
}
|
||||||
wunlock(fsmain);
|
wunlock(fsmain);
|
||||||
dprint("hjfs: %T block count %ulld\n", TDENTRY, ndentry);
|
dprint("%T block count %ulld\n", TDENTRY, ndentry);
|
||||||
dprint("hjfs: %T block count %ulld\n", TINDIR, nindir);
|
dprint("%T block count %ulld\n", TINDIR, nindir);
|
||||||
dprint("hjfs: %T block count %ulld\n", TRAW, nraw);
|
dprint("%T block count %ulld\n", TRAW, nraw);
|
||||||
dprint("hjfs: %T block count %ulld\n", TREF, nref);
|
dprint("%T block count %ulld\n", TREF, nref);
|
||||||
dprint("hjfs: %T block count %ulld\n", TSUPERBLOCK, nsuperblock);
|
dprint("%T block count %ulld\n", TSUPERBLOCK, nsuperblock);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ int
|
||||||
cmddisallow(int, char **)
|
cmddisallow(int, char **)
|
||||||
{
|
{
|
||||||
fsmain->flags &= ~(FSNOPERM | FSCHOWN);
|
fsmain->flags &= ~(FSNOPERM | FSCHOWN);
|
||||||
dprint("hjfs: disallow\n");
|
dprint("disallow\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,9 +235,9 @@ cmdnoauth(int, char **)
|
||||||
{
|
{
|
||||||
fsmain->flags ^= FSNOAUTH;
|
fsmain->flags ^= FSNOAUTH;
|
||||||
if((fsmain->flags & FSNOAUTH) == 0)
|
if((fsmain->flags & FSNOAUTH) == 0)
|
||||||
dprint("hjfs: auth enabled\n");
|
dprint("auth enabled\n");
|
||||||
else
|
else
|
||||||
dprint("hjfs: auth disabled\n");
|
dprint("auth disabled\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,8 +317,8 @@ cmddf(int, char **)
|
||||||
n++;
|
n++;
|
||||||
putbuf(b);
|
putbuf(b);
|
||||||
}
|
}
|
||||||
dprint("hjfs: (blocks) free %ulld, used %ulld, total %ulld\n", n, sb->sb.size - n, sb->sb.size);
|
dprint("(blocks) free %ulld, used %ulld, total %ulld\n", n, sb->sb.size - n, sb->sb.size);
|
||||||
dprint("hjfs: (MB) free %ulld, used %ulld, total %ulld\n", n * BLOCK / 1048576, (sb->sb.size - n) * BLOCK / 1048576, sb->sb.size * BLOCK / 1048576);
|
dprint("(MB) free %ulld, used %ulld, total %ulld\n", n * BLOCK / 1048576, (sb->sb.size - n) * BLOCK / 1048576, sb->sb.size * BLOCK / 1048576);
|
||||||
putbuf(sb);
|
putbuf(sb);
|
||||||
wunlock(fsmain);
|
wunlock(fsmain);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -338,18 +338,18 @@ cmddebugdeind(int, char **argv)
|
||||||
if(walkpath(ch, argv[1], nil) < 0)
|
if(walkpath(ch, argv[1], nil) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
rlock(fsmain);
|
rlock(fsmain);
|
||||||
dprint("hjfs: loc %ulld / %uld, offset %ulld\n", ch->loc->blk, ch->loc->deind, BLOCK * ch->loc->blk + (RBLOCK - BLOCK) + DENTRYSIZ * ch->loc->deind);
|
dprint("loc %ulld / %uld, offset %ulld\n", ch->loc->blk, ch->loc->deind, BLOCK * ch->loc->blk + (RBLOCK - BLOCK) + DENTRYSIZ * ch->loc->deind);
|
||||||
b = getbuf(fsmain->d, ch->loc->blk, TDENTRY, 0);
|
b = getbuf(fsmain->d, ch->loc->blk, TDENTRY, 0);
|
||||||
if(b == nil){
|
if(b == nil){
|
||||||
runlock(fsmain);
|
runlock(fsmain);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
d = &b->de[ch->loc->deind];
|
d = &b->de[ch->loc->deind];
|
||||||
dprint("hjfs: name %s\n", d->name);
|
dprint("name %s\n", d->name);
|
||||||
dprint("hjfs: uid %d, muid %d, gid %d\n", d->uid, d->muid, d->gid);
|
dprint("uid %d, muid %d, gid %d\n", d->uid, d->muid, d->gid);
|
||||||
dprint("hjfs: mode %#o, qid %ulld, type %#x, version %d\n", d->mode, d->path, d->type, d->vers);
|
dprint("mode %#o, qid %ulld, type %#x, version %d\n", d->mode, d->path, d->type, d->vers);
|
||||||
dprint("hjfs: size %d\n", d->size);
|
dprint("size %d\n", d->size);
|
||||||
dprint("hjfs: atime %ulld, mtime %ulld\n", d->atime, d->mtime);
|
dprint("atime %ulld, mtime %ulld\n", d->atime, d->mtime);
|
||||||
putbuf(b);
|
putbuf(b);
|
||||||
runlock(fsmain);
|
runlock(fsmain);
|
||||||
chanclunk(ch);
|
chanclunk(ch);
|
||||||
|
@ -384,7 +384,7 @@ cmddebugchdeind(int, char **argv)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
c = (uchar *) &b->de[ch->loc->deind];
|
c = (uchar *) &b->de[ch->loc->deind];
|
||||||
dprint("hjfs: loc %d, old value %#.2x, new value %#.2x\n", loc, c[loc], new);
|
dprint("loc %d, old value %#.2x, new value %#.2x\n", loc, c[loc], new);
|
||||||
c[loc] = new;
|
c[loc] = new;
|
||||||
b->op |= BDELWRI;
|
b->op |= BDELWRI;
|
||||||
putbuf(b);
|
putbuf(b);
|
||||||
|
@ -426,11 +426,11 @@ cmddebuggetblk(int argc, char **argv)
|
||||||
for(i = start; i <= end; i++){
|
for(i = start; i <= end; i++){
|
||||||
rc = getblk(fsmain, ch->loc, b, i, &r, GBREAD);
|
rc = getblk(fsmain, ch->loc, b, i, &r, GBREAD);
|
||||||
if(rc > 0)
|
if(rc > 0)
|
||||||
dprint("hjfs: getblk %ulld = %ulld\n", i, r);
|
dprint("getblk %ulld = %ulld\n", i, r);
|
||||||
if(rc == 0)
|
if(rc == 0)
|
||||||
dprint("hjfs: getblk %ulld not found\n", i);
|
dprint("getblk %ulld not found\n", i);
|
||||||
if(rc < 0)
|
if(rc < 0)
|
||||||
dprint("hjfs: getblk %ulld: %r\n", i);
|
dprint("getblk %ulld: %r\n", i);
|
||||||
}
|
}
|
||||||
putbuf(b);
|
putbuf(b);
|
||||||
runlock(fsmain);
|
runlock(fsmain);
|
||||||
|
@ -484,7 +484,7 @@ consproc(void *v)
|
||||||
if(s == nil)
|
if(s == nil)
|
||||||
continue;
|
continue;
|
||||||
if(echo)
|
if(echo)
|
||||||
dprint("hjfs: >%s\n", s);
|
dprint(">%s\n", s);
|
||||||
rc = tokenize(s, args, MAXARGS);
|
rc = tokenize(s, args, MAXARGS);
|
||||||
if(rc == 0)
|
if(rc == 0)
|
||||||
goto syntax;
|
goto syntax;
|
||||||
|
@ -497,12 +497,12 @@ consproc(void *v)
|
||||||
if(rc == -9001)
|
if(rc == -9001)
|
||||||
goto syntax;
|
goto syntax;
|
||||||
if(rc < 0)
|
if(rc < 0)
|
||||||
dprint("hjfs: %r\n");
|
dprint("%r\n");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
syntax:
|
syntax:
|
||||||
dprint("hjfs: syntax error\n");
|
dprint("syntax error\n");
|
||||||
done:
|
done:
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ devwork(void *v)
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
pack(b, buf);
|
pack(b, buf);
|
||||||
if(pwrite(d->fd, buf, BLOCK, b->off*BLOCK) < BLOCK){
|
if(pwrite(d->fd, buf, BLOCK, b->off*BLOCK) < BLOCK){
|
||||||
dprint("hjfs: write: %r\n");
|
dprint("write: %r\n");
|
||||||
b->error = Eio;
|
b->error = Eio;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -44,7 +44,7 @@ devwork(void *v)
|
||||||
for(n = 0; n < BLOCK; n += m){
|
for(n = 0; n < BLOCK; n += m){
|
||||||
m = pread(d->fd, buf+n, BLOCK-n, b->off*BLOCK+n);
|
m = pread(d->fd, buf+n, BLOCK-n, b->off*BLOCK+n);
|
||||||
if(m < 0)
|
if(m < 0)
|
||||||
dprint("hjfs: read: %r\n");
|
dprint("read: %r\n");
|
||||||
if(m <= 0)
|
if(m <= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ again:
|
||||||
if(rc < 0)
|
if(rc < 0)
|
||||||
goto err;
|
goto err;
|
||||||
if(rc == 0){
|
if(rc == 0){
|
||||||
dprint("hjfs: willmodify: block %lld has refcount 0\n", l->blk);
|
dprint("willmodify: block %lld has refcount 0\n", l->blk);
|
||||||
werrstr("phase error -- willmodify");
|
werrstr("phase error -- willmodify");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,13 +50,13 @@ getdent(FLoc *l, Buf *b)
|
||||||
|
|
||||||
d = &b->de[l->deind];
|
d = &b->de[l->deind];
|
||||||
if((d->mode & (DGONE | DALLOC)) == 0){
|
if((d->mode & (DGONE | DALLOC)) == 0){
|
||||||
dprint("hjfs: getdent: file gone, d=%llux, l=%llud/%d %llux, callerpc %#p\n",
|
dprint("getdent: file gone, d=%llux, l=%llud/%d %llux, callerpc %#p\n",
|
||||||
d->path, l->blk, l->deind, l->path, getcallerpc(&l));
|
d->path, l->blk, l->deind, l->path, getcallerpc(&l));
|
||||||
werrstr("phase error -- directory entry for nonexistent file");
|
werrstr("phase error -- directory entry for nonexistent file");
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
if(qidcmp(d, l) != 0){
|
if(qidcmp(d, l) != 0){
|
||||||
dprint("hjfs: getdent: wrong qid d=%llux != l=%llud/%d %llux, callerpc %#p\n",
|
dprint("getdent: wrong qid d=%llux != l=%llud/%d %llux, callerpc %#p\n",
|
||||||
d->path, l->blk, l->deind, l->path, getcallerpc(&l));
|
d->path, l->blk, l->deind, l->path, getcallerpc(&l));
|
||||||
werrstr("phase error -- qid mismatch");
|
werrstr("phase error -- qid mismatch");
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -213,7 +213,7 @@ writeusers(Fs *fs)
|
||||||
error:
|
error:
|
||||||
if(ch != nil)
|
if(ch != nil)
|
||||||
chanclunk(ch);
|
chanclunk(ch);
|
||||||
dprint("hjfs: writeusers: %r\n");
|
dprint("writeusers: %r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -238,7 +238,7 @@ readusers(Fs *fs)
|
||||||
err:
|
err:
|
||||||
if(ch != nil)
|
if(ch != nil)
|
||||||
chanclunk(ch);
|
chanclunk(ch);
|
||||||
dprint("hjfs: readusers: %r\nhjfs: using default user db\n");
|
dprint("readusers: %r\nhjfs: using default user db\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -250,7 +250,7 @@ ream(Fs *fs)
|
||||||
int j, je;
|
int j, je;
|
||||||
|
|
||||||
d = fs->d;
|
d = fs->d;
|
||||||
dprint("hjfs: reaming %s\n", d->name);
|
dprint("reaming %s\n", d->name);
|
||||||
b = getbuf(d, SUPERBLK, TSUPERBLOCK, 1);
|
b = getbuf(d, SUPERBLK, TSUPERBLOCK, 1);
|
||||||
if(b == nil)
|
if(b == nil)
|
||||||
err:
|
err:
|
||||||
|
@ -292,7 +292,7 @@ ream(Fs *fs)
|
||||||
putbuf(b);
|
putbuf(b);
|
||||||
createroot(fs);
|
createroot(fs);
|
||||||
sync(1);
|
sync(1);
|
||||||
dprint("hjfs: ream successful\n");
|
dprint("ream successful\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Fs *
|
Fs *
|
||||||
|
@ -326,7 +326,7 @@ initfs(Dev *d, int doream, int flags)
|
||||||
if(doream)
|
if(doream)
|
||||||
writeusers(fs);
|
writeusers(fs);
|
||||||
readusers(fs);
|
readusers(fs);
|
||||||
dprint("hjfs: fs is %s\n", d->name);
|
dprint("fs is %s\n", d->name);
|
||||||
return fs;
|
return fs;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -569,7 +569,7 @@ getblk(Fs *fs, FLoc *L, Buf *bd, uvlong blk, uvlong *r, int mode)
|
||||||
b = bd;
|
b = bd;
|
||||||
d = getdent(L, b);
|
d = getdent(L, b);
|
||||||
if(d == nil){
|
if(d == nil){
|
||||||
dprint("hjfs: getblk: dirent gone\n");
|
dprint("getblk: dirent gone\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(blk < NDIRECT){
|
if(blk < NDIRECT){
|
||||||
|
@ -654,7 +654,7 @@ found:
|
||||||
if(rc < 0)
|
if(rc < 0)
|
||||||
goto end;
|
goto end;
|
||||||
if(rc == 0){
|
if(rc == 0){
|
||||||
dprint("hjfs: getblk: block %lld has refcount 0\n");
|
dprint("getblk: block %lld has refcount 0\n");
|
||||||
werrstr("phase error -- getblk");
|
werrstr("phase error -- getblk");
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -65,12 +65,17 @@ Fs *fsmain;
|
||||||
int
|
int
|
||||||
dprint(char *fmt, ...)
|
dprint(char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
static char buf[2048];
|
||||||
|
static QLock lk;
|
||||||
va_list va;
|
va_list va;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
qlock(lk);
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
rc = vfprint(2, fmt, va);
|
snprint(buf, 2048, "hjfs: %s", fmt);
|
||||||
|
rc = vfprint(2, buf, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
qunlock(lk);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +154,7 @@ shutdown(void)
|
||||||
{
|
{
|
||||||
wlock(fsmain);
|
wlock(fsmain);
|
||||||
sync(1);
|
sync(1);
|
||||||
dprint("hjfs: ending\n");
|
dprint("ending\n");
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
sync(1);
|
sync(1);
|
||||||
threadexitsall(nil);
|
threadexitsall(nil);
|
||||||
|
|
Loading…
Reference in a new issue