pstat.c (ed0051823057e576a8e86f421232888b53559e82) | pstat.c (9c5cdfe0afd357dde6d63bc1780cf058764e3d72) |
---|---|
1/*- 2 * Copyright (c) 1980, 1991, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 30 unchanged lines hidden (view full) --- 39 40#ifndef lint 41static char sccsid[] = "@(#)pstat.c 8.16 (Berkeley) 5/9/95"; 42#endif /* not lint */ 43 44#include <sys/param.h> 45#include <sys/time.h> 46#include <sys/vnode.h> | 1/*- 2 * Copyright (c) 1980, 1991, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 30 unchanged lines hidden (view full) --- 39 40#ifndef lint 41static char sccsid[] = "@(#)pstat.c 8.16 (Berkeley) 5/9/95"; 42#endif /* not lint */ 43 44#include <sys/param.h> 45#include <sys/time.h> 46#include <sys/vnode.h> |
47#include <sys/map.h> | |
48#include <sys/ucred.h> 49#define KERNEL 50#include <sys/file.h> 51#include <ufs/ufs/quota.h> 52#include <ufs/ufs/inode.h> 53#define NFS 54#include <sys/mount.h> 55#undef NFS 56#include <sys/uio.h> 57#include <sys/namei.h> 58#include <miscfs/union/union.h> 59#undef KERNEL 60#include <sys/stat.h> 61#include <nfs/rpcv2.h> 62#include <nfs/nfsproto.h> | 47#include <sys/ucred.h> 48#define KERNEL 49#include <sys/file.h> 50#include <ufs/ufs/quota.h> 51#include <ufs/ufs/inode.h> 52#define NFS 53#include <sys/mount.h> 54#undef NFS 55#include <sys/uio.h> 56#include <sys/namei.h> 57#include <miscfs/union/union.h> 58#undef KERNEL 59#include <sys/stat.h> 60#include <nfs/rpcv2.h> 61#include <nfs/nfsproto.h> |
62#define KERNEL |
|
63#include <nfs/nfs.h> | 63#include <nfs/nfs.h> |
64#undef KERNEL |
|
64#include <nfs/nfsnode.h> 65#include <sys/ioctl.h> | 65#include <nfs/nfsnode.h> 66#include <sys/ioctl.h> |
67#include <sys/ioctl_compat.h> /* XXX NTTYDISC is too well hidden */ |
|
66#include <sys/tty.h> 67#include <sys/conf.h> | 68#include <sys/tty.h> 69#include <sys/conf.h> |
70#include <sys/rlist.h> |
|
68 | 71 |
72#include <sys/user.h> |
|
69#include <sys/sysctl.h> 70 71#include <err.h> | 73#include <sys/sysctl.h> 74 75#include <err.h> |
76#include <fcntl.h> |
|
72#include <kvm.h> 73#include <limits.h> 74#include <nlist.h> 75#include <stdio.h> 76#include <stdlib.h> 77#include <string.h> 78#include <unistd.h> 79 80struct nlist nl[] = { | 77#include <kvm.h> 78#include <limits.h> 79#include <nlist.h> 80#include <stdio.h> 81#include <stdlib.h> 82#include <string.h> 83#include <unistd.h> 84 85struct nlist nl[] = { |
81#define VM_SWAPMAP 0 82 { "_swapmap" }, /* list of free swap areas */ 83#define VM_NSWAPMAP 1 84 { "_nswapmap" },/* size of the swap map */ 85#define VM_SWDEVT 2 | 86#define VM_SWAPLIST 0 87 { "_swaplist" },/* list of free swap areas */ 88#define VM_SWDEVT 1 |
86 { "_swdevt" }, /* list of swap devices and sizes */ | 89 { "_swdevt" }, /* list of swap devices and sizes */ |
87#define VM_NSWAP 3 | 90#define VM_NSWAP 2 |
88 { "_nswap" }, /* size of largest swap device */ | 91 { "_nswap" }, /* size of largest swap device */ |
89#define VM_NSWDEV 4 | 92#define VM_NSWDEV 3 |
90 { "_nswdev" }, /* number of swap devices */ | 93 { "_nswdev" }, /* number of swap devices */ |
91#define VM_DMMAX 5 | 94#define VM_DMMAX 4 |
92 { "_dmmax" }, /* maximum size of a swap block */ | 95 { "_dmmax" }, /* maximum size of a swap block */ |
93#define V_MOUNTLIST 6 | 96#define V_MOUNTLIST 5 |
94 { "_mountlist" }, /* address of head of mount list. */ | 97 { "_mountlist" }, /* address of head of mount list. */ |
95#define V_NUMV 7 | 98#define V_NUMV 6 |
96 { "_numvnodes" }, | 99 { "_numvnodes" }, |
97#define FNL_NFILE 8 | 100#define FNL_NFILE 7 |
98 {"_nfiles"}, | 101 {"_nfiles"}, |
99#define FNL_MAXFILE 9 | 102#define FNL_MAXFILE 8 |
100 {"_maxfiles"}, 101#define NLMANDATORY FNL_MAXFILE /* names up to here are mandatory */ | 103 {"_maxfiles"}, 104#define NLMANDATORY FNL_MAXFILE /* names up to here are mandatory */ |
102#define VM_NISWAP NLMANDATORY + 1 103 { "_niswap" }, 104#define VM_NISWDEV NLMANDATORY + 2 105 { "_niswdev" }, 106#define SCONS NLMANDATORY + 3 | 105#define SCONS NLMANDATORY + 1 |
107 { "_cons" }, | 106 { "_cons" }, |
108#define SPTY NLMANDATORY + 4 | 107#define SPTY NLMANDATORY + 2 |
109 { "_pt_tty" }, | 108 { "_pt_tty" }, |
110#define SNPTY NLMANDATORY + 5 | 109#define SNPTY NLMANDATORY + 3 |
111 { "_npty" }, 112 113#ifdef hp300 114#define SDCA (SNPTY+1) 115 { "_dca_tty" }, 116#define SNDCA (SNPTY+2) 117 { "_ndca" }, 118#define SDCM (SNPTY+3) --- 12 unchanged lines hidden (view full) --- 131 132#ifdef mips 133#define SDC (SNPTY+1) 134 { "_dc_tty" }, 135#define SNDC (SNPTY+2) 136 { "_dc_cnt" }, 137#endif 138 | 110 { "_npty" }, 111 112#ifdef hp300 113#define SDCA (SNPTY+1) 114 { "_dca_tty" }, 115#define SNDCA (SNPTY+2) 116 { "_ndca" }, 117#define SDCM (SNPTY+3) --- 12 unchanged lines hidden (view full) --- 130 131#ifdef mips 132#define SDC (SNPTY+1) 133 { "_dc_tty" }, 134#define SNDC (SNPTY+2) 135 { "_dc_cnt" }, 136#endif 137 |
138#ifdef __FreeBSD__ 139#define SCCONS (SNPTY+1) 140 { "_sccons" }, 141#define NSCCONS (SNPTY+2) 142 { "_nsccons" }, 143#define SIO (SNPTY+3) 144 { "_sio_tty" }, 145#define NSIO (SNPTY+4) 146 { "_nsio_tty" }, 147#define RC (SNPTY+5) 148 { "_rc_tty" }, 149#define NRC (SNPTY+6) 150 { "_nrc_tty" }, 151#define CY (SNPTY+7) 152 { "_cy_tty" }, 153#define NCY (SNPTY+8) 154 { "_ncy_tty" }, 155#define SI (SNPTY+9) 156 { "_si_tty" }, 157#define NSI (SNPTY+10) 158 { "_si_Nports" }, 159#endif |
|
139 { "" } 140}; 141 142int usenumflag; 143int totalflag; 144char *nlistf = NULL; 145char *memf = NULL; 146kvm_t *kd; 147 | 160 { "" } 161}; 162 163int usenumflag; 164int totalflag; 165char *nlistf = NULL; 166char *memf = NULL; 167kvm_t *kd; 168 |
169char *usage; 170 |
|
148struct { 149 int m_flag; 150 const char *m_name; 151} mnt_flags[] = { 152 { MNT_RDONLY, "rdonly" }, 153 { MNT_SYNCHRONOUS, "sync" }, 154 { MNT_NOEXEC, "noexec" }, 155 { MNT_NOSUID, "nosuid" }, --- 9 unchanged lines hidden (view full) --- 165 { MNT_QUOTA, "quota" }, 166 { MNT_ROOTFS, "rootfs" }, 167 { MNT_UPDATE, "update" }, 168 { MNT_DELEXPORT }, 169 { MNT_UPDATE, "update" }, 170 { MNT_DELEXPORT, "delexport" }, 171 { MNT_RELOAD, "reload" }, 172 { MNT_FORCE, "force" }, | 171struct { 172 int m_flag; 173 const char *m_name; 174} mnt_flags[] = { 175 { MNT_RDONLY, "rdonly" }, 176 { MNT_SYNCHRONOUS, "sync" }, 177 { MNT_NOEXEC, "noexec" }, 178 { MNT_NOSUID, "nosuid" }, --- 9 unchanged lines hidden (view full) --- 188 { MNT_QUOTA, "quota" }, 189 { MNT_ROOTFS, "rootfs" }, 190 { MNT_UPDATE, "update" }, 191 { MNT_DELEXPORT }, 192 { MNT_UPDATE, "update" }, 193 { MNT_DELEXPORT, "delexport" }, 194 { MNT_RELOAD, "reload" }, 195 { MNT_FORCE, "force" }, |
196#if 0 |
|
173 { MNT_MLOCK, "mlock" }, | 197 { MNT_MLOCK, "mlock" }, |
198#endif |
|
174 { MNT_WAIT, "wait" }, | 199 { MNT_WAIT, "wait" }, |
200#if 0 |
|
175 { MNT_MPBUSY, "mpbusy" }, 176 { MNT_MPWANT, "mpwant" }, | 201 { MNT_MPBUSY, "mpbusy" }, 202 { MNT_MPWANT, "mpwant" }, |
203#endif |
|
177 { MNT_UNMOUNT, "unmount" }, 178 { MNT_WANTRDWR, "wantrdwr" }, 179 { 0 } 180}; 181 182 183#define SVAR(var) __STRING(var) /* to force expansion */ 184#define KGET(idx, var) \ --- 18 unchanged lines hidden (view full) --- 203struct e_vnode * 204 loadvnodes __P((int *)); 205void mount_print __P((struct mount *)); 206void nfs_header __P((void)); 207int nfs_print __P((struct vnode *)); 208void swapmode __P((void)); 209void ttymode __P((void)); 210void ttyprt __P((struct tty *, int)); | 204 { MNT_UNMOUNT, "unmount" }, 205 { MNT_WANTRDWR, "wantrdwr" }, 206 { 0 } 207}; 208 209 210#define SVAR(var) __STRING(var) /* to force expansion */ 211#define KGET(idx, var) \ --- 18 unchanged lines hidden (view full) --- 230struct e_vnode * 231 loadvnodes __P((int *)); 232void mount_print __P((struct mount *)); 233void nfs_header __P((void)); 234int nfs_print __P((struct vnode *)); 235void swapmode __P((void)); 236void ttymode __P((void)); 237void ttyprt __P((struct tty *, int)); |
211void ttytype __P((struct tty *, char *, int, int)); | 238void ttytype __P((struct tty *, char *, int, int, int)); |
212void ufs_header __P((void)); 213int ufs_print __P((struct vnode *)); 214void union_header __P((void)); 215int union_print __P((struct vnode *)); | 239void ufs_header __P((void)); 240int ufs_print __P((struct vnode *)); 241void union_header __P((void)); 242int union_print __P((struct vnode *)); |
216void usage __P((void)); | |
217void vnode_header __P((void)); 218void vnode_print __P((struct vnode *, struct vnode *)); 219void vnodemode __P((void)); 220 221int 222main(argc, argv) 223 int argc; 224 char *argv[]; 225{ 226 extern char *optarg; 227 extern int optind; 228 int ch, i, quit, ret; 229 int fileflag, swapflag, ttyflag, vnodeflag; | 243void vnode_header __P((void)); 244void vnode_print __P((struct vnode *, struct vnode *)); 245void vnodemode __P((void)); 246 247int 248main(argc, argv) 249 int argc; 250 char *argv[]; 251{ 252 extern char *optarg; 253 extern int optind; 254 int ch, i, quit, ret; 255 int fileflag, swapflag, ttyflag, vnodeflag; |
230 char buf[_POSIX2_LINE_MAX]; | 256 char buf[_POSIX2_LINE_MAX],*opts; |
231 232 fileflag = swapflag = ttyflag = vnodeflag = 0; | 257 258 fileflag = swapflag = ttyflag = vnodeflag = 0; |
233 while ((ch = getopt(argc, argv, "TM:N:finstv")) != EOF) | 259 260 /* We will behave like good old swapinfo if thus invoked */ 261 opts = strrchr(argv[0],'/'); 262 if (opts) 263 opts++; 264 else 265 opts = argv[0]; 266 if (!strcmp(opts,"swapinfo")) { 267 swapflag = 1; 268 opts = "kM:N:"; 269 usage = "usage: swapinfo [-k] [-M core] [-N system]\n"; 270 } else { 271 opts = "TM:N:fiknstv"; 272 usage = "usage: pstat [-Tfknstv] [-M core] [-N system]\n"; 273 } 274 275 while ((ch = getopt(argc, argv, opts)) != EOF) |
234 switch (ch) { 235 case 'f': 236 fileflag = 1; 237 break; | 276 switch (ch) { 277 case 'f': 278 fileflag = 1; 279 break; |
280 case 'k': 281 putenv("BLOCKSIZE=1K"); 282 break; |
|
238 case 'M': 239 memf = optarg; 240 break; 241 case 'N': 242 nlistf = optarg; 243 break; 244 case 'n': 245 usenumflag = 1; --- 7 unchanged lines hidden (view full) --- 253 case 't': 254 ttyflag = 1; 255 break; 256 case 'v': 257 case 'i': /* Backward compatibility. */ 258 vnodeflag = 1; 259 break; 260 default: | 283 case 'M': 284 memf = optarg; 285 break; 286 case 'N': 287 nlistf = optarg; 288 break; 289 case 'n': 290 usenumflag = 1; --- 7 unchanged lines hidden (view full) --- 298 case 't': 299 ttyflag = 1; 300 break; 301 case 'v': 302 case 'i': /* Backward compatibility. */ 303 vnodeflag = 1; 304 break; 305 default: |
261 usage(); | 306 (void)fprintf(stderr, usage); 307 exit(1); |
262 } 263 argc -= optind; 264 argv += optind; 265 266 /* 267 * Discard setgid privileges if not the running kernel so that bad 268 * guys can't print interesting stuff from kernel memory. 269 */ --- 8 unchanged lines hidden (view full) --- 278 for (i = quit = 0; i <= NLMANDATORY; i++) 279 if (!nl[i].n_value) { 280 quit = 1; 281 warnx("undefined symbol: %s\n", nl[i].n_name); 282 } 283 if (quit) 284 exit(1); 285 } | 308 } 309 argc -= optind; 310 argv += optind; 311 312 /* 313 * Discard setgid privileges if not the running kernel so that bad 314 * guys can't print interesting stuff from kernel memory. 315 */ --- 8 unchanged lines hidden (view full) --- 324 for (i = quit = 0; i <= NLMANDATORY; i++) 325 if (!nl[i].n_value) { 326 quit = 1; 327 warnx("undefined symbol: %s\n", nl[i].n_name); 328 } 329 if (quit) 330 exit(1); 331 } |
286 if (!(fileflag | vnodeflag | ttyflag | swapflag | totalflag)) 287 usage(); | 332 if (!(fileflag | vnodeflag | ttyflag | swapflag | totalflag)) { 333 (void)fprintf(stderr, usage); 334 exit(1); 335 } |
288 if (fileflag || totalflag) 289 filemode(); 290 if (vnodeflag || totalflag) 291 vnodemode(); 292 if (ttyflag) 293 ttymode(); 294 if (swapflag || totalflag) 295 swapmode(); --- 63 unchanged lines hidden (view full) --- 359 (void)printf("ADDR TYP VFLAG USE HOLD"); 360} 361 362void 363vnode_print(avnode, vp) 364 struct vnode *avnode; 365 struct vnode *vp; 366{ | 336 if (fileflag || totalflag) 337 filemode(); 338 if (vnodeflag || totalflag) 339 vnodemode(); 340 if (ttyflag) 341 ttymode(); 342 if (swapflag || totalflag) 343 swapmode(); --- 63 unchanged lines hidden (view full) --- 407 (void)printf("ADDR TYP VFLAG USE HOLD"); 408} 409 410void 411vnode_print(avnode, vp) 412 struct vnode *avnode; 413 struct vnode *vp; 414{ |
367 char *type, flags[16]; | 415 char *type, flags[16]; |
368 char *fp = flags; 369 int flag; 370 371 /* 372 * set type 373 */ 374 switch (vp->v_type) { 375 case VNON: --- 9 unchanged lines hidden (view full) --- 385 case VLNK: 386 type = "lnk"; break; 387 case VSOCK: 388 type = "soc"; break; 389 case VFIFO: 390 type = "fif"; break; 391 case VBAD: 392 type = "bad"; break; | 416 char *fp = flags; 417 int flag; 418 419 /* 420 * set type 421 */ 422 switch (vp->v_type) { 423 case VNON: --- 9 unchanged lines hidden (view full) --- 433 case VLNK: 434 type = "lnk"; break; 435 case VSOCK: 436 type = "soc"; break; 437 case VFIFO: 438 type = "fif"; break; 439 case VBAD: 440 type = "bad"; break; |
393 default: | 441 default: |
394 type = "unk"; break; 395 } 396 /* 397 * gather flags 398 */ 399 flag = vp->v_flag; 400 if (flag & VROOT) 401 *fp++ = 'R'; --- 12 unchanged lines hidden (view full) --- 414 if (flag == 0) 415 *fp++ = '-'; 416 *fp = '\0'; 417 (void)printf("%8x %s %5s %4d %4d", 418 avnode, type, flags, vp->v_usecount, vp->v_holdcnt); 419} 420 421void | 442 type = "unk"; break; 443 } 444 /* 445 * gather flags 446 */ 447 flag = vp->v_flag; 448 if (flag & VROOT) 449 *fp++ = 'R'; --- 12 unchanged lines hidden (view full) --- 462 if (flag == 0) 463 *fp++ = '-'; 464 *fp = '\0'; 465 (void)printf("%8x %s %5s %4d %4d", 466 avnode, type, flags, vp->v_usecount, vp->v_holdcnt); 467} 468 469void |
422ufs_header() | 470ufs_header() |
423{ 424 (void)printf(" FILEID IFLAG RDEV|SZ"); 425} 426 427int | 471{ 472 (void)printf(" FILEID IFLAG RDEV|SZ"); 473} 474 475int |
428ufs_print(vp) | 476ufs_print(vp) |
429 struct vnode *vp; 430{ 431 int flag; 432 struct inode inode, *ip = &inode; 433 char flagbuf[16], *flags = flagbuf; 434 char *name; 435 mode_t type; 436 437 KGETRET(VTOI(vp), &inode, sizeof(struct inode), "vnode's inode"); 438 flag = ip->i_flag; | 477 struct vnode *vp; 478{ 479 int flag; 480 struct inode inode, *ip = &inode; 481 char flagbuf[16], *flags = flagbuf; 482 char *name; 483 mode_t type; 484 485 KGETRET(VTOI(vp), &inode, sizeof(struct inode), "vnode's inode"); 486 flag = ip->i_flag; |
487#if 0 /* XXX */ |
|
439 if (flag & IN_LOCKED) 440 *flags++ = 'L'; 441 if (flag & IN_WANTED) 442 *flags++ = 'W'; | 488 if (flag & IN_LOCKED) 489 *flags++ = 'L'; 490 if (flag & IN_WANTED) 491 *flags++ = 'W'; |
492#endif |
|
443 if (flag & IN_RENAME) 444 *flags++ = 'R'; 445 if (flag & IN_UPDATE) 446 *flags++ = 'U'; 447 if (flag & IN_ACCESS) 448 *flags++ = 'A'; 449 if (flag & IN_CHANGE) 450 *flags++ = 'C'; 451 if (flag & IN_MODIFIED) 452 *flags++ = 'M'; 453 if (flag & IN_SHLOCK) 454 *flags++ = 'S'; 455 if (flag & IN_EXLOCK) 456 *flags++ = 'E'; | 493 if (flag & IN_RENAME) 494 *flags++ = 'R'; 495 if (flag & IN_UPDATE) 496 *flags++ = 'U'; 497 if (flag & IN_ACCESS) 498 *flags++ = 'A'; 499 if (flag & IN_CHANGE) 500 *flags++ = 'C'; 501 if (flag & IN_MODIFIED) 502 *flags++ = 'M'; 503 if (flag & IN_SHLOCK) 504 *flags++ = 'S'; 505 if (flag & IN_EXLOCK) 506 *flags++ = 'E'; |
507#if 0 |
|
457 if (flag & IN_LWAIT) 458 *flags++ = 'Z'; | 508 if (flag & IN_LWAIT) 509 *flags++ = 'Z'; |
510#endif |
|
459 if (flag == 0) 460 *flags++ = '-'; 461 *flags = '\0'; 462 463 (void)printf(" %6d %5s", ip->i_number, flagbuf); 464 type = ip->i_mode & S_IFMT; 465 if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode)) 466 if (usenumflag || ((name = devname(ip->i_rdev, type)) == NULL)) | 511 if (flag == 0) 512 *flags++ = '-'; 513 *flags = '\0'; 514 515 (void)printf(" %6d %5s", ip->i_number, flagbuf); 516 type = ip->i_mode & S_IFMT; 517 if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode)) 518 if (usenumflag || ((name = devname(ip->i_rdev, type)) == NULL)) |
467 (void)printf(" %2d,%-2d", | 519 (void)printf(" %2d,%-2d", |
468 major(ip->i_rdev), minor(ip->i_rdev)); 469 else 470 (void)printf(" %7s", name); 471 else 472 (void)printf(" %7qd", ip->i_size); 473 return (0); 474} 475 476void | 520 major(ip->i_rdev), minor(ip->i_rdev)); 521 else 522 (void)printf(" %7s", name); 523 else 524 (void)printf(" %7qd", ip->i_size); 525 return (0); 526} 527 528void |
477nfs_header() | 529nfs_header() |
478{ 479 (void)printf(" FILEID NFLAG RDEV|SZ"); 480} 481 482int | 530{ 531 (void)printf(" FILEID NFLAG RDEV|SZ"); 532} 533 534int |
483nfs_print(vp) | 535nfs_print(vp) |
484 struct vnode *vp; 485{ 486 struct nfsnode nfsnode, *np = &nfsnode; 487 char flagbuf[16], *flags = flagbuf; 488 int flag; 489 char *name; 490 mode_t type; 491 --- 17 unchanged lines hidden (view full) --- 509 *flags++ = '-'; 510 *flags = '\0'; 511 512#define VT np->n_vattr 513 (void)printf(" %6d %5s", VT.va_fileid, flagbuf); 514 type = VT.va_mode & S_IFMT; 515 if (S_ISCHR(VT.va_mode) || S_ISBLK(VT.va_mode)) 516 if (usenumflag || ((name = devname(VT.va_rdev, type)) == NULL)) | 536 struct vnode *vp; 537{ 538 struct nfsnode nfsnode, *np = &nfsnode; 539 char flagbuf[16], *flags = flagbuf; 540 int flag; 541 char *name; 542 mode_t type; 543 --- 17 unchanged lines hidden (view full) --- 561 *flags++ = '-'; 562 *flags = '\0'; 563 564#define VT np->n_vattr 565 (void)printf(" %6d %5s", VT.va_fileid, flagbuf); 566 type = VT.va_mode & S_IFMT; 567 if (S_ISCHR(VT.va_mode) || S_ISBLK(VT.va_mode)) 568 if (usenumflag || ((name = devname(VT.va_rdev, type)) == NULL)) |
517 (void)printf(" %2d,%-2d", | 569 (void)printf(" %2d,%-2d", |
518 major(VT.va_rdev), minor(VT.va_rdev)); 519 else 520 (void)printf(" %7s", name); 521 else 522 (void)printf(" %7qd", np->n_size); 523 return (0); 524} 525 --- 137 unchanged lines hidden (view full) --- 663 num++; 664 } 665 if (mp == mountlist.cqh_last) 666 break; 667 } 668 *avnodes = num; 669 return ((struct e_vnode *)vbuf); 670} | 570 major(VT.va_rdev), minor(VT.va_rdev)); 571 else 572 (void)printf(" %7s", name); 573 else 574 (void)printf(" %7qd", np->n_size); 575 return (0); 576} 577 --- 137 unchanged lines hidden (view full) --- 715 num++; 716 } 717 if (mp == mountlist.cqh_last) 718 break; 719 } 720 *avnodes = num; 721 return ((struct e_vnode *)vbuf); 722} |
671 | 723 |
672char hdr[]=" LINE RAW CAN OUT HWT LWT COL STATE SESS PGID DISC\n"; 673int ttyspace = 128; 674 675void 676ttymode() 677{ 678 struct tty *tty; 679 680 if ((tty = malloc(ttyspace * sizeof(*tty))) == NULL) 681 err(1, NULL); 682#if !defined(hp300) && !defined(mips) | 724char hdr[]=" LINE RAW CAN OUT HWT LWT COL STATE SESS PGID DISC\n"; 725int ttyspace = 128; 726 727void 728ttymode() 729{ 730 struct tty *tty; 731 732 if ((tty = malloc(ttyspace * sizeof(*tty))) == NULL) 733 err(1, NULL); 734#if !defined(hp300) && !defined(mips) |
683 (void)printf("1 console\n"); 684 KGET(SCONS, *tty); 685 (void)printf(hdr); 686 ttyprt(&tty[0], 0); | 735 if (nl[SCONS].n_type != 0) { 736 (void)printf("1 console\n"); 737 KGET(SCONS, *tty); 738 (void)printf(hdr); 739 ttyprt(&tty[0], 0); 740 } |
687#endif 688#ifdef vax | 741#endif 742#ifdef vax |
689 if (nl[SNQD].n_type != 0) | 743 if (nl[SNQD].n_type != 0) |
690 qdss(); 691 if (nl[SNDZ].n_type != 0) | 744 qdss(); 745 if (nl[SNDZ].n_type != 0) |
692 ttytype(tty, "dz", SDZ, SNDZ); | 746 ttytype(tty, "dz", SDZ, SNDZ, 0); |
693 if (nl[SNDH].n_type != 0) | 747 if (nl[SNDH].n_type != 0) |
694 ttytype(tty, "dh", SDH, SNDH); | 748 ttytype(tty, "dh", SDH, SNDH, 0); |
695 if (nl[SNDMF].n_type != 0) | 749 if (nl[SNDMF].n_type != 0) |
696 ttytype(tty, "dmf", SDMF, SNDMF); | 750 ttytype(tty, "dmf", SDMF, SNDMF, 0); |
697 if (nl[SNDHU].n_type != 0) | 751 if (nl[SNDHU].n_type != 0) |
698 ttytype(tty, "dhu", SDHU, SNDHU); | 752 ttytype(tty, "dhu", SDHU, SNDHU, 0); |
699 if (nl[SNDMZ].n_type != 0) | 753 if (nl[SNDMZ].n_type != 0) |
700 ttytype(tty, "dmz", SDMZ, SNDMZ); | 754 ttytype(tty, "dmz", SDMZ, SNDMZ, 0); |
701#endif 702#ifdef tahoe 703 if (nl[SNVX].n_type != 0) | 755#endif 756#ifdef tahoe 757 if (nl[SNVX].n_type != 0) |
704 ttytype(tty, "vx", SVX, SNVX); | 758 ttytype(tty, "vx", SVX, SNVX, 0); |
705 if (nl[SNMP].n_type != 0) | 759 if (nl[SNMP].n_type != 0) |
706 ttytype(tty, "mp", SMP, SNMP); | 760 ttytype(tty, "mp", SMP, SNMP, 0); |
707#endif 708#ifdef hp300 709 if (nl[SNITE].n_type != 0) | 761#endif 762#ifdef hp300 763 if (nl[SNITE].n_type != 0) |
710 ttytype(tty, "ite", SITE, SNITE); | 764 ttytype(tty, "ite", SITE, SNITE, 0); |
711 if (nl[SNDCA].n_type != 0) | 765 if (nl[SNDCA].n_type != 0) |
712 ttytype(tty, "dca", SDCA, SNDCA); | 766 ttytype(tty, "dca", SDCA, SNDCA, 0); |
713 if (nl[SNDCM].n_type != 0) | 767 if (nl[SNDCM].n_type != 0) |
714 ttytype(tty, "dcm", SDCM, SNDCM); | 768 ttytype(tty, "dcm", SDCM, SNDCM, 0); |
715 if (nl[SNDCL].n_type != 0) | 769 if (nl[SNDCL].n_type != 0) |
716 ttytype(tty, "dcl", SDCL, SNDCL); | 770 ttytype(tty, "dcl", SDCL, SNDCL, 0); |
717#endif 718#ifdef mips 719 if (nl[SNDC].n_type != 0) | 771#endif 772#ifdef mips 773 if (nl[SNDC].n_type != 0) |
720 ttytype(tty, "dc", SDC, SNDC); | 774 ttytype(tty, "dc", SDC, SNDC, 0); |
721#endif | 775#endif |
776#ifdef __FreeBSD__ 777 if (nl[NSCCONS].n_type != 0) 778 ttytype(tty, "vty", SCCONS, NSCCONS, 0); 779 if (nl[NSIO].n_type != 0) 780 ttytype(tty, "sio", SIO, NSIO, 0); 781 if (nl[NRC].n_type != 0) 782 ttytype(tty, "rc", RC, NRC, 0); 783 if (nl[NCY].n_type != 0) 784 ttytype(tty, "cy", CY, NCY, 0); 785 if (nl[NSI].n_type != 0) 786 ttytype(tty, "si", SI, NSI, 1); 787#endif |
|
722 if (nl[SNPTY].n_type != 0) | 788 if (nl[SNPTY].n_type != 0) |
723 ttytype(tty, "pty", SPTY, SNPTY); | 789 ttytype(tty, "pty", SPTY, SNPTY, 0); |
724} 725 726void | 790} 791 792void |
727ttytype(tty, name, type, number) | 793ttytype(tty, name, type, number, indir) |
728 struct tty *tty; 729 char *name; | 794 struct tty *tty; 795 char *name; |
730 int type, number; | 796 int type, number, indir; |
731{ 732 struct tty *tp; 733 int ntty; | 797{ 798 struct tty *tp; 799 int ntty; |
800 struct tty **ttyaddr; |
|
734 735 if (tty == NULL) 736 return; 737 KGET(number, ntty); 738 (void)printf("%d %s %s\n", ntty, name, (ntty == 1) ? "line" : "lines"); 739 if (ntty > ttyspace) { 740 ttyspace = ntty; 741 if ((tty = realloc(tty, ttyspace * sizeof(*tty))) == 0) 742 err(1, NULL); 743 } | 801 802 if (tty == NULL) 803 return; 804 KGET(number, ntty); 805 (void)printf("%d %s %s\n", ntty, name, (ntty == 1) ? "line" : "lines"); 806 if (ntty > ttyspace) { 807 ttyspace = ntty; 808 if ((tty = realloc(tty, ttyspace * sizeof(*tty))) == 0) 809 err(1, NULL); 810 } |
744 KGET1(type, tty, ntty * sizeof(struct tty), "tty structs"); | 811 if (indir) { 812 KGET(type, ttyaddr); 813 KGET2(ttyaddr, tty, ntty * sizeof(struct tty), "tty structs"); 814 } else { 815 KGET1(type, tty, ntty * sizeof(struct tty), "tty structs"); 816 } |
745 (void)printf(hdr); 746 for (tp = tty; tp < &tty[ntty]; tp++) 747 ttyprt(tp, tp - tty); 748} 749 750struct { 751 int flag; 752 char val; 753} ttystates[] = { | 817 (void)printf(hdr); 818 for (tp = tty; tp < &tty[ntty]; tp++) 819 ttyprt(tp, tp - tty); 820} 821 822struct { 823 int flag; 824 char val; 825} ttystates[] = { |
826#ifdef TS_WOPEN |
|
754 { TS_WOPEN, 'W'}, | 827 { TS_WOPEN, 'W'}, |
828#endif |
|
755 { TS_ISOPEN, 'O'}, 756 { TS_CARR_ON, 'C'}, | 829 { TS_ISOPEN, 'O'}, 830 { TS_CARR_ON, 'C'}, |
831#ifdef TS_CONNECTED 832 { TS_CONNECTED, 'c'}, 833#endif |
|
757 { TS_TIMEOUT, 'T'}, 758 { TS_FLUSH, 'F'}, 759 { TS_BUSY, 'B'}, | 834 { TS_TIMEOUT, 'T'}, 835 { TS_FLUSH, 'F'}, 836 { TS_BUSY, 'B'}, |
837#ifdef TS_ASLEEP |
|
760 { TS_ASLEEP, 'A'}, | 838 { TS_ASLEEP, 'A'}, |
839#endif 840#ifdef TS_SO_OLOWAT 841 { TS_SO_OLOWAT, 'A'}, 842#endif 843#ifdef TS_SO_OCOMPLETE 844 { TS_SO_OCOMPLETE, 'a'}, 845#endif |
|
761 { TS_XCLUDE, 'X'}, 762 { TS_TTSTOP, 'S'}, | 846 { TS_XCLUDE, 'X'}, 847 { TS_TTSTOP, 'S'}, |
848#ifdef TS_CAR_OFLOW 849 { TS_CAR_OFLOW, 'm'}, 850#endif 851#ifdef TS_CTS_OFLOW 852 { TS_CTS_OFLOW, 'o'}, 853#endif 854#ifdef TS_DSR_OFLOW 855 { TS_DSR_OFLOW, 'd'}, 856#endif |
|
763 { TS_TBLOCK, 'K'}, 764 { TS_ASYNC, 'Y'}, 765 { TS_BKSL, 'D'}, 766 { TS_ERASE, 'E'}, 767 { TS_LNCH, 'L'}, 768 { TS_TYPEN, 'P'}, 769 { TS_CNTTB, 'N'}, | 857 { TS_TBLOCK, 'K'}, 858 { TS_ASYNC, 'Y'}, 859 { TS_BKSL, 'D'}, 860 { TS_ERASE, 'E'}, 861 { TS_LNCH, 'L'}, 862 { TS_TYPEN, 'P'}, 863 { TS_CNTTB, 'N'}, |
864#ifdef TS_CAN_BYPASS_L_RINT 865 { TS_CAN_BYPASS_L_RINT, 'l'}, 866#endif 867#ifdef TS_SNOOP 868 { TS_SNOOP, 's'}, 869#endif 870#ifdef TS_ZOMBIE 871 { TS_ZOMBIE, 'Z'}, 872#endif |
|
770 { 0, '\0'}, 771}; 772 773void 774ttyprt(tp, line) 775 struct tty *tp; 776 int line; 777{ 778 int i, j; 779 pid_t pgid; 780 char *name, state[20]; 781 782 if (usenumflag || tp->t_dev == 0 || 783 (name = devname(tp->t_dev, S_IFCHR)) == NULL) | 873 { 0, '\0'}, 874}; 875 876void 877ttyprt(tp, line) 878 struct tty *tp; 879 int line; 880{ 881 int i, j; 882 pid_t pgid; 883 char *name, state[20]; 884 885 if (usenumflag || tp->t_dev == 0 || 886 (name = devname(tp->t_dev, S_IFCHR)) == NULL) |
784 (void)printf("%7d ", line); | 887 (void)printf("%7d ", line); |
785 else 786 (void)printf("%7s ", name); 787 (void)printf("%2d %3d ", tp->t_rawq.c_cc, tp->t_canq.c_cc); | 888 else 889 (void)printf("%7s ", name); 890 (void)printf("%2d %3d ", tp->t_rawq.c_cc, tp->t_canq.c_cc); |
788 (void)printf("%3d %4d %3d %7d ", tp->t_outq.c_cc, | 891 (void)printf("%3d %4d %3d %7d ", tp->t_outq.c_cc, |
789 tp->t_hiwat, tp->t_lowat, tp->t_column); 790 for (i = j = 0; ttystates[i].flag; i++) 791 if (tp->t_state&ttystates[i].flag) 792 state[j++] = ttystates[i].val; 793 if (j == 0) 794 state[j++] = '-'; 795 state[j] = '\0'; 796 (void)printf("%-6s %8x", state, (u_long)tp->t_session); 797 pgid = 0; 798 if (tp->t_pgrp != NULL) 799 KGET2(&tp->t_pgrp->pg_id, &pgid, sizeof(pid_t), "pgid"); 800 (void)printf("%6d ", pgid); 801 switch (tp->t_line) { 802 case TTYDISC: 803 (void)printf("term\n"); 804 break; | 892 tp->t_hiwat, tp->t_lowat, tp->t_column); 893 for (i = j = 0; ttystates[i].flag; i++) 894 if (tp->t_state&ttystates[i].flag) 895 state[j++] = ttystates[i].val; 896 if (j == 0) 897 state[j++] = '-'; 898 state[j] = '\0'; 899 (void)printf("%-6s %8x", state, (u_long)tp->t_session); 900 pgid = 0; 901 if (tp->t_pgrp != NULL) 902 KGET2(&tp->t_pgrp->pg_id, &pgid, sizeof(pid_t), "pgid"); 903 (void)printf("%6d ", pgid); 904 switch (tp->t_line) { 905 case TTYDISC: 906 (void)printf("term\n"); 907 break; |
908 case NTTYDISC: 909 (void)printf("ntty\n"); 910 break; |
|
805 case TABLDISC: 806 (void)printf("tab\n"); 807 break; 808 case SLIPDISC: 809 (void)printf("slip\n"); 810 break; | 911 case TABLDISC: 912 (void)printf("tab\n"); 913 break; 914 case SLIPDISC: 915 (void)printf("slip\n"); 916 break; |
917 case PPPDISC: 918 (void)printf("ppp\n"); 919 break; |
|
811 default: 812 (void)printf("%d\n", tp->t_line); 813 break; 814 } 815} 816 817void 818filemode() --- 15 unchanged lines hidden (view full) --- 834 /* 835 * Getfiles returns in malloc'd memory a pointer to the first file 836 * structure, and then an array of file structs (whose addresses are 837 * derivable from the previous entry). 838 */ 839 addr = ((struct filelist *)buf)->lh_first; 840 fp = (struct file *)(buf + sizeof(struct filelist)); 841 nfile = (len - sizeof(struct filelist)) / sizeof(struct file); | 920 default: 921 (void)printf("%d\n", tp->t_line); 922 break; 923 } 924} 925 926void 927filemode() --- 15 unchanged lines hidden (view full) --- 943 /* 944 * Getfiles returns in malloc'd memory a pointer to the first file 945 * structure, and then an array of file structs (whose addresses are 946 * derivable from the previous entry). 947 */ 948 addr = ((struct filelist *)buf)->lh_first; 949 fp = (struct file *)(buf + sizeof(struct filelist)); 950 nfile = (len - sizeof(struct filelist)) / sizeof(struct file); |
842 | 951 |
843 (void)printf("%d/%d open files\n", nfile, maxfile); 844 (void)printf(" LOC TYPE FLG CNT MSG DATA OFFSET\n"); 845 for (; (char *)fp < buf + len; addr = fp->f_list.le_next, fp++) { 846 if ((unsigned)fp->f_type > DTYPE_SOCKET) 847 continue; 848 (void)printf("%x ", addr); 849 (void)printf("%-8.8s", dtypes[fp->f_type]); 850 fbp = flagbuf; --- 59 unchanged lines hidden (view full) --- 910/* 911 * swapmode is based on a program called swapinfo written 912 * by Kevin Lahey <kml@rokkaku.atl.ga.us>. 913 */ 914void 915swapmode() 916{ 917 char *header, *p; | 952 (void)printf("%d/%d open files\n", nfile, maxfile); 953 (void)printf(" LOC TYPE FLG CNT MSG DATA OFFSET\n"); 954 for (; (char *)fp < buf + len; addr = fp->f_list.le_next, fp++) { 955 if ((unsigned)fp->f_type > DTYPE_SOCKET) 956 continue; 957 (void)printf("%x ", addr); 958 (void)printf("%-8.8s", dtypes[fp->f_type]); 959 fbp = flagbuf; --- 59 unchanged lines hidden (view full) --- 1019/* 1020 * swapmode is based on a program called swapinfo written 1021 * by Kevin Lahey <kml@rokkaku.atl.ga.us>. 1022 */ 1023void 1024swapmode() 1025{ 1026 char *header, *p; |
918 int hlen, nswap, nswdev, dmmax, nswapmap, niswap, niswdev; 919 int s, e, div, i, l, avail, nfree, npfree, used; | 1027 int hlen, nswap, nswdev, dmmax; 1028 int i, div, avail, nfree, npfree, used; |
920 struct swdevt *sw; 921 long blocksize, *perdev; | 1029 struct swdevt *sw; 1030 long blocksize, *perdev; |
922 struct map *swapmap, *kswapmap; 923 struct mapent *mp; | 1031 struct rlist head; 1032 struct rlisthdr swaplist; 1033 struct rlist *swapptr; 1034 u_long ptr; |
924 925 KGET(VM_NSWAP, nswap); 926 KGET(VM_NSWDEV, nswdev); 927 KGET(VM_DMMAX, dmmax); | 1035 1036 KGET(VM_NSWAP, nswap); 1037 KGET(VM_NSWDEV, nswdev); 1038 KGET(VM_DMMAX, dmmax); |
928 KGET(VM_NSWAPMAP, nswapmap); 929 KGET(VM_SWAPMAP, kswapmap); /* kernel `swapmap' is a pointer */ | 1039 KGET1(VM_SWAPLIST, &swaplist, sizeof swaplist, "swaplist"); |
930 if ((sw = malloc(nswdev * sizeof(*sw))) == NULL || | 1040 if ((sw = malloc(nswdev * sizeof(*sw))) == NULL || |
931 (perdev = malloc(nswdev * sizeof(*perdev))) == NULL || 932 (mp = malloc(nswapmap * sizeof(*mp))) == NULL) | 1041 (perdev = malloc(nswdev * sizeof(*perdev))) == NULL) |
933 err(1, "malloc"); | 1042 err(1, "malloc"); |
934 KGET1(VM_SWDEVT, sw, nswdev * sizeof(*sw), "swdevt"); 935 KGET2((long)kswapmap, mp, nswapmap * sizeof(*mp), "swapmap"); | 1043 KGET1(VM_SWDEVT, &ptr, sizeof ptr, "swdevt"); 1044 KGET2(ptr, sw, nswdev * sizeof(*sw), "*swdevt"); |
936 | 1045 |
937 /* Supports sequential swap */ 938 if (nl[VM_NISWAP].n_value != 0) { 939 KGET(VM_NISWAP, niswap); 940 KGET(VM_NISWDEV, niswdev); 941 } else { 942 niswap = nswap; 943 niswdev = nswdev; 944 } 945 946 /* First entry in map is `struct map'; rest are mapent's. */ 947 swapmap = (struct map *)mp; 948 if (nswapmap != swapmap->m_limit - (struct mapent *)kswapmap) 949 errx(1, "panic: nswapmap goof"); 950 | |
951 /* Count up swap space. */ 952 nfree = 0; 953 memset(perdev, 0, nswdev * sizeof(*perdev)); | 1046 /* Count up swap space. */ 1047 nfree = 0; 1048 memset(perdev, 0, nswdev * sizeof(*perdev)); |
954 for (mp++; mp->m_addr != 0; mp++) { 955 s = mp->m_addr; /* start of swap region */ 956 e = mp->m_addr + mp->m_size; /* end of region */ 957 nfree += mp->m_size; | 1049 swapptr = swaplist.rlh_list; 1050 while (swapptr) { 1051 int top, bottom, next_block; |
958 | 1052 |
1053 KGET2(swapptr, &head, sizeof(struct rlist), "swapptr"); 1054 1055 top = head.rl_end; 1056 bottom = head.rl_start; 1057 1058 nfree += top - bottom + 1; 1059 |
|
959 /* 960 * Swap space is split up among the configured disks. 961 * 962 * For interleaved swap devices, the first dmmax blocks 963 * of swap space some from the first disk, the next dmmax | 1060 /* 1061 * Swap space is split up among the configured disks. 1062 * 1063 * For interleaved swap devices, the first dmmax blocks 1064 * of swap space some from the first disk, the next dmmax |
964 * blocks from the next, and so on up to niswap blocks. | 1065 * blocks from the next, and so on up to nswap blocks. |
965 * | 1066 * |
966 * Sequential swap devices follow the interleaved devices 967 * (i.e. blocks starting at niswap) in the order in which 968 * they appear in the swdev table. The size of each device 969 * will be a multiple of dmmax. 970 * | |
971 * The list of free space joins adjacent free blocks, 972 * ignoring device boundries. If we want to keep track 973 * of this information per device, we'll just have to | 1067 * The list of free space joins adjacent free blocks, 1068 * ignoring device boundries. If we want to keep track 1069 * of this information per device, we'll just have to |
974 * extract it ourselves. We know that dmmax-sized chunks 975 * cannot span device boundaries (interleaved or sequential) 976 * so we loop over such chunks assigning them to devices. | 1070 * extract it ourselves. |
977 */ | 1071 */ |
978 i = -1; 979 while (s < e) { /* XXX this is inefficient */ 980 int bound = roundup(s+1, dmmax); 981 982 if (bound > e) 983 bound = e; 984 if (bound <= niswap) { 985 /* Interleaved swap chunk. */ 986 if (i == -1) 987 i = (s / dmmax) % niswdev; 988 perdev[i] += bound - s; 989 if (++i >= niswdev) 990 i = 0; 991 } else { 992 /* Sequential swap chunk. */ 993 if (i < niswdev) { 994 i = niswdev; 995 l = niswap + sw[i].sw_nblks; 996 } 997 while (s >= l) { 998 /* XXX don't die on bogus blocks */ 999 if (i == nswdev-1) 1000 break; 1001 l += sw[++i].sw_nblks; 1002 } 1003 perdev[i] += bound - s; 1004 } 1005 s = bound; | 1072 while (top / dmmax != bottom / dmmax) { 1073 next_block = ((bottom + dmmax) / dmmax); 1074 perdev[(bottom / dmmax) % nswdev] += 1075 next_block * dmmax - bottom; 1076 bottom = next_block * dmmax; |
1006 } | 1077 } |
1078 perdev[(bottom / dmmax) % nswdev] += 1079 top - bottom + 1; 1080 1081 swapptr = head.rl_next; |
|
1007 } 1008 1009 header = getbsize(&hlen, &blocksize); 1010 if (!totalflag) 1011 (void)printf("%-11s %*s %8s %8s %8s %s\n", 1012 "Device", hlen, header, 1013 "Used", "Avail", "Capacity", "Type"); 1014 div = blocksize / 512; 1015 avail = npfree = 0; 1016 for (i = 0; i < nswdev; i++) { 1017 int xsize, xfree; 1018 | 1082 } 1083 1084 header = getbsize(&hlen, &blocksize); 1085 if (!totalflag) 1086 (void)printf("%-11s %*s %8s %8s %8s %s\n", 1087 "Device", hlen, header, 1088 "Used", "Avail", "Capacity", "Type"); 1089 div = blocksize / 512; 1090 avail = npfree = 0; 1091 for (i = 0; i < nswdev; i++) { 1092 int xsize, xfree; 1093 |
1019 if (!totalflag) { 1020 p = devname(sw[i].sw_dev, S_IFBLK); 1021 (void)printf("/dev/%-6s %*d ", p == NULL ? "??" : p, 1022 hlen, sw[i].sw_nblks / div); 1023 } 1024 | |
1025 /* 1026 * Don't report statistics for partitions which have not 1027 * yet been activated via swapon(8). 1028 */ | 1094 /* 1095 * Don't report statistics for partitions which have not 1096 * yet been activated via swapon(8). 1097 */ |
1029 if (!(sw[i].sw_flags & SW_FREED)) { 1030 if (totalflag) 1031 continue; 1032 (void)printf(" *** not available for swapping ***\n"); | 1098 if (!(sw[i].sw_flags & SW_FREED)) |
1033 continue; | 1099 continue; |
1034 } 1035 xsize = sw[i].sw_nblks; | 1100 1101 if (!totalflag) 1102 if (sw[i].sw_dev != NODEV) { 1103 p = devname(sw[i].sw_dev, S_IFBLK); 1104 (void)printf("/dev/%-6s %*d ", 1105 p == NULL ? "??" : p, 1106 hlen, sw[i].sw_nblks / div); 1107 } else 1108 (void)printf("[NFS swap] %*d ", 1109 hlen, sw[i].sw_nblks / div); 1110 1111 /* The first dmmax is never allocated to avoid trashing of 1112 * disklabels 1113 */ 1114 xsize = sw[i].sw_nblks - dmmax; |
1036 xfree = perdev[i]; 1037 used = xsize - xfree; 1038 npfree++; 1039 avail += xsize; 1040 if (totalflag) 1041 continue; | 1115 xfree = perdev[i]; 1116 used = xsize - xfree; 1117 npfree++; 1118 avail += xsize; 1119 if (totalflag) 1120 continue; |
1042 (void)printf("%8d %8d %5.0f%% %s\n", | 1121 (void)printf("%8d %8d %5.0f%% %s\n", |
1043 used / div, xfree / div, 1044 (double)used / (double)xsize * 100.0, 1045 (sw[i].sw_flags & SW_SEQUENTIAL) ? 1046 "Sequential" : "Interleaved"); 1047 } 1048 | 1122 used / div, xfree / div, 1123 (double)used / (double)xsize * 100.0, 1124 (sw[i].sw_flags & SW_SEQUENTIAL) ? 1125 "Sequential" : "Interleaved"); 1126 } 1127 |
1049 /* | 1128 /* |
1050 * If only one partition has been set up via swapon(8), we don't 1051 * need to bother with totals. 1052 */ 1053 used = avail - nfree; | 1129 * If only one partition has been set up via swapon(8), we don't 1130 * need to bother with totals. 1131 */ 1132 used = avail - nfree; |
1133 free(sw); 1134 free(perdev); |
|
1054 if (totalflag) { 1055 (void)printf("%dM/%dM swap space\n", used / 2048, avail / 2048); 1056 return; 1057 } 1058 if (npfree > 1) { 1059 (void)printf("%-11s %*d %8d %8d %5.0f%%\n", 1060 "Total", hlen, avail / div, used / div, nfree / div, 1061 (double)used / (double)avail * 100.0); 1062 } 1063} | 1135 if (totalflag) { 1136 (void)printf("%dM/%dM swap space\n", used / 2048, avail / 2048); 1137 return; 1138 } 1139 if (npfree > 1) { 1140 (void)printf("%-11s %*d %8d %8d %5.0f%%\n", 1141 "Total", hlen, avail / div, used / div, nfree / div, 1142 (double)used / (double)avail * 100.0); 1143 } 1144} |
1064 1065void 1066usage() 1067{ 1068 (void)fprintf(stderr, 1069 "usage: pstat -Tfnstv [system] [-M core] [-N system]\n"); 1070 exit(1); 1071} | |