a few minor problems: - modes weren't printed properly (fcallfmt assumes dirmodefmt and dirfmt). - the number of workbufs wasn't sufficient for lots of parallel reads (e.g. when testing fcp) the fix should probably allow an indefinite number, but 40's better than 16! - it didn't follow $path when executing a file. i'm aware that $path's not so important in plan 9, but i (and perhaps others too) have path=(/bin .) and it can lead to surprises when iostats tries things the other way around. it's a pity that rdenv() is so painful, but i'm not aware of an alternative. Reference: /n/sources/patch/applied/iostats Date: Wed Feb 15 14:56:29 CET 2006 --- /sys/src/cmd/iostats/iostats.c Wed Feb 15 14:48:59 2006 +++ /sys/src/cmd/iostats/iostats.c Wed Feb 15 14:48:47 2006 @@ -146,6 +146,8 @@ for(n = 0; n < Maxrpc; n++) stats->rpc[n].lo = 10000000000LL; + fmtinstall('M', dirmodefmt); + fmtinstall('D', dirfmt); fmtinstall('F', fcallfmt); if(chdir("/") < 0) @@ -496,14 +498,46 @@ exits("fatal"); } +char* +rdenv(char *v, char **end) +{ + int fd, n; + char *buf; + Dir *d; + if((fd = open(v, OREAD)) == -1) + return nil; + d = dirfstat(fd); + if(d == nil || (buf = malloc(d->length + 1)) == nil) + return nil; + n = (int)d->length; + n = read(fd, buf, n); + close(fd); + if(n <= 0){ + free(buf); + buf = nil; + }else{ + if(buf[n-1] != '\0') + buf[n++] = '\0'; + *end = &buf[n]; + } + free(d); + return buf; +} + +char Defaultpath[] = ".\0/bin"; void runprog(char *argv[]) { - char arg0[128]; + char *path, *ep, *p; + char arg0[256]; - exec(argv[0], argv); - if (*argv[0] != '/' && strncmp(argv[0],"./",2) != 0) { - sprint(arg0, "/bin/%s", argv[0]); + path = rdenv("/env/path", &ep); + if(path == nil){ + path = Defaultpath; + ep = path+sizeof(Defaultpath); + } + for(p = path; p < ep; p += strlen(p)+1){ + snprint(arg0, sizeof arg0, "%s/%s", p, argv[0]); exec(arg0, argv); } fatal("exec"); --- /sys/src/cmd/iostats/statfs.h Wed Feb 15 14:49:49 2006 +++ /sys/src/cmd/iostats/statfs.h Wed Feb 15 14:49:38 2006 @@ -96,7 +96,7 @@ enum { - Nr_workbufs = 16, + Nr_workbufs = 40, Dsegpad = 8192, Fidchunk = 1000, };