Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2006/0216/3

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


iostats: respect path, add fmts, more worker threads
 [rsc] --rw-rw-r-- M 1138436 glenda sys 10209 Feb 16 09:25 sys/src/cmd/iostats/iostats.c
	/n/sourcesdump/2006/0216/plan9/sys/src/cmd/iostats/iostats.c:146,151 - 
	/n/sourcesdump/2006/0217/plan9/sys/src/cmd/iostats/iostats.c:146,153
	  	for(n = 0; n < Maxrpc; n++)
	  		stats->rpc[n].lo = 10000000000LL;
	  
	+ 	fmtinstall('M', dirmodefmt);
	+ 	fmtinstall('D', dirfmt);
	  	fmtinstall('F', fcallfmt);
	  
	  	if(chdir("/") < 0)
	/n/sourcesdump/2006/0216/plan9/sys/src/cmd/iostats/iostats.c:496,509 - 
	/n/sourcesdump/2006/0217/plan9/sys/src/cmd/iostats/iostats.c:498,543
	  	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");
 [rsc] --rw-rw-r-- M 1138436 glenda sys 2626 Feb 16 09:25 sys/src/cmd/iostats/statfs.h
	/n/sourcesdump/2006/0216/plan9/sys/src/cmd/iostats/statfs.h:96,102 - 
	/n/sourcesdump/2006/0217/plan9/sys/src/cmd/iostats/statfs.h:96,102
	  
	  enum
	  {
	- 	Nr_workbufs 	= 16,
	+ 	Nr_workbufs 	= 40,
	  	Dsegpad		= 8192,
	  	Fidchunk	= 1000,
	  };


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].