Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/0929/1

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


Handle new version of /dev/swap.
 [rsc] --rw-rw-r-- M 564876 glenda sys 28128 Sep 29 02:10 sys/src/cmd/stats.c
	/n/sourcesdump/2005/0929/plan9/sys/src/cmd/stats.c:27,37 - 
	/n/sourcesdump/2005/0930/plan9/sys/src/cmd/stats.c:27,38
	  
	  enum
	  {
	- 	/* /dev/swap */
	+ 	/* old /dev/swap */
	  	Mem		= 0,
	  	Maxmem,
	  	Swap,
	  	Maxswap,
	+ 	
	  	/* /dev/sysstats */
	  	Procno	= 0,
	  	Context,
	/n/sourcesdump/2005/0929/plan9/sys/src/cmd/stats.c:284,290 - 
	/n/sourcesdump/2005/0930/plan9/sys/src/cmd/stats.c:285,291
	  	if(*fd < 0)
	  		return 0;
	  	seek(*fd, 0, 0);
	- 	n = read(*fd, m->buf, sizeof m->buf);
	+ 	n = read(*fd, m->buf, sizeof m->buf-1);
	  	if(n <= 0){
	  		close(*fd);
	  		*fd = -1;
	/n/sourcesdump/2005/0929/plan9/sys/src/cmd/stats.c:292,297 - 
	/n/sourcesdump/2005/0930/plan9/sys/src/cmd/stats.c:293,299
	  	}
	  	m->bufp = m->buf;
	  	m->ebufp = m->buf+n;
	+ 	m->buf[n] = 0;
	  	return 1;
	  }
	  
	/n/sourcesdump/2005/0929/plan9/sys/src/cmd/stats.c:577,582 - 
	/n/sourcesdump/2005/0930/plan9/sys/src/cmd/stats.c:579,600
	  }
	  
	  int
	+ readswap(Machine *m, ulong *a)
	+ {
	+ 	if(strstr(m->buf, "memory\n")){
	+ 		/* new /dev/swap - skip first 3 numbers */
	+ 		if(!readnums(m, 7, a, 1))
	+ 			return 0;
	+ 		a[0] = a[3];
	+ 		a[1] = a[4];
	+ 		a[2] = a[5];
	+ 		a[3] = a[6];
	+ 		return 1;
	+ 	}
	+ 	return readnums(m, nelem(m->devswap), a, 0);
	+ }
	+ 
	+ int
	  initmach(Machine *m, char *name)
	  {
	  	int n, fd;
	/n/sourcesdump/2005/0929/plan9/sys/src/cmd/stats.c:612,618 - 
	/n/sourcesdump/2005/0930/plan9/sys/src/cmd/stats.c:630,636
	  
	  	snprint(buf, sizeof buf, "%s/dev/swap", mpt);
	  	m->swapfd = open(buf, OREAD);
	- 	if(loadbuf(m, &m->swapfd) && readnums(m, nelem(m->devswap), a, 0))
	+ 	if(loadbuf(m, &m->swapfd) && readswap(m, a))
	  		memmove(m->devswap, a, sizeof m->devswap);
	  	else
	  		m->devswap[Maxmem] = m->devswap[Maxswap] = 100;
	/n/sourcesdump/2005/0929/plan9/sys/src/cmd/stats.c:722,728 - 
	/n/sourcesdump/2005/0930/plan9/sys/src/cmd/stats.c:740,746
	  		notify(alarmed);
	  		alarm(5000);
	  	}
	- 	if(needswap(init) && loadbuf(m, &m->swapfd) && readnums(m, nelem(m->devswap), a, 0))
	+ 	if(needswap(init) && loadbuf(m, &m->swapfd) && readswap(m, a))
	  		memmove(m->devswap, a, sizeof m->devswap);
	  	if(needstat(init) && loadbuf(m, &m->statsfd)){
	  		memmove(m->prevsysstat, m->devsysstat, sizeof m->devsysstat);
 [sys] --rwxrwxr-x M 564876 glenda sys 190269 Sep 29 23:10 386/bin/stats
	/sys/src/cmd/stats.c:addgraph
	/sys/src/cmd/stats.c:addmachine
	/sys/src/cmd/stats.c:alarmed
	/sys/src/cmd/stats.c:dropgraph
	/sys/src/cmd/stats.c:eresized
	/sys/src/cmd/stats.c:initmach
	/sys/src/cmd/stats.c:labelstrs
	/sys/src/cmd/stats.c:loadbuf
	/sys/src/cmd/stats.c:main
	/sys/src/cmd/stats.c:mouseproc
	/sys/src/cmd/stats.c:readmach
	/sys/src/cmd/stats.c:readswap
	/sys/src/cmd/stats.c:resize
	/sys/src/cmd/stats.c:startproc
	/sys/src/cmd/stats.c:usage


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.