Deleted Added
full compact
print.c (90110) print.c (90143)
1/*-
2 * Copyright (c) 1990, 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

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
1/*-
2 * Copyright (c) 1990, 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

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
34#include <sys/cdefs.h>
35
36__FBSDID("$FreeBSD: head/bin/ps/print.c 90143 2002-02-03 14:43:04Z markm $");
37
35#if 0
38#if 0
39#ifndef lint
36static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
40static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
37#endif
38static const char rcsid[] =
39 "$FreeBSD: head/bin/ps/print.c 90110 2002-02-02 06:48:10Z imp $";
40#endif /* not lint */
41#endif /* not lint */
42#endif
41
42#include <sys/param.h>
43#include <sys/time.h>
44#include <sys/resource.h>
45#include <sys/proc.h>
46#include <sys/stat.h>
47
43
44#include <sys/param.h>
45#include <sys/time.h>
46#include <sys/resource.h>
47#include <sys/proc.h>
48#include <sys/stat.h>
49
48#include <sys/ucred.h>
49#include <sys/user.h>
50#include <sys/sysctl.h>
50#include <sys/user.h>
51#include <sys/sysctl.h>
51#include <vm/vm.h>
52
53#include <err.h>
54#include <langinfo.h>
55#include <locale.h>
56#include <math.h>
57#include <nlist.h>
58#include <stddef.h>
59#include <stdio.h>
60#include <stdlib.h>
52
53#include <err.h>
54#include <langinfo.h>
55#include <locale.h>
56#include <math.h>
57#include <nlist.h>
58#include <stddef.h>
59#include <stdio.h>
60#include <stdlib.h>
61#include <unistd.h>
62#include <string.h>
61#include <string.h>
62#include <unistd.h>
63#include <vis.h>
64
65#include "lomac.h"
66#include "ps.h"
67
63#include <vis.h>
64
65#include "lomac.h"
66#include "ps.h"
67
68static void printval __P((char *, VAR *));
69
68void
69printheader(void)
70{
71 VAR *v;
72 struct varent *vent;
73
74 for (vent = vhead; vent; vent = vent->next) {
75 v = vent->var;

--- 343 unchanged lines hidden (view full) ---

419 VAR *v;
420
421 v = ve->var;
422 (void)printf("%*d", v->width,
423 (k->ki_p->ki_size/1024));
424}
425
426void
70void
71printheader(void)
72{
73 VAR *v;
74 struct varent *vent;
75
76 for (vent = vhead; vent; vent = vent->next) {
77 v = vent->var;

--- 343 unchanged lines hidden (view full) ---

421 VAR *v;
422
423 v = ve->var;
424 (void)printf("%*d", v->width,
425 (k->ki_p->ki_size/1024));
426}
427
428void
427rssize(KINFO *k, VARENT *ve)
428{
429 VAR *v;
430
431 v = ve->var;
432 /* XXX don't have info about shared */
433 (void)printf("%*lu", v->width,
434 (u_long)pgtok(k->ki_p->ki_rssize));
435}
436
437void
438p_rssize(KINFO *k, VARENT *ve) /* doesn't account for text */
439{
440 VAR *v;
441
442 v = ve->var;
443 (void)printf("%*ld", v->width, (long)pgtok(k->ki_p->ki_rssize));
444}
445
446void
447cputime(KINFO *k, VARENT *ve)
448{
449 VAR *v;
450 long secs;
451 long psecs; /* "parts" of a second. first micro, then centi */
452 char obuff[128];
453 static char decimal_point = 0;
454

--- 23 unchanged lines hidden (view full) ---

478 psecs = psecs % 100;
479 }
480 (void)snprintf(obuff, sizeof(obuff),
481 "%3ld:%02ld%c%02ld", secs/60, secs%60, decimal_point, psecs);
482 (void)printf("%*s", v->width, obuff);
483}
484
485double
429cputime(KINFO *k, VARENT *ve)
430{
431 VAR *v;
432 long secs;
433 long psecs; /* "parts" of a second. first micro, then centi */
434 char obuff[128];
435 static char decimal_point = 0;
436

--- 23 unchanged lines hidden (view full) ---

460 psecs = psecs % 100;
461 }
462 (void)snprintf(obuff, sizeof(obuff),
463 "%3ld:%02ld%c%02ld", secs/60, secs%60, decimal_point, psecs);
464 (void)printf("%*s", v->width, obuff);
465}
466
467double
486getpcpu(KINFO *k)
468getpcpu(const KINFO *k)
487{
488 static int failure;
489
490 if (!nlistread)
491 failure = donlist();
492 if (failure)
493 return (0.0);
494

--- 12 unchanged lines hidden (view full) ---

507pcpu(KINFO *k, VARENT *ve)
508{
509 VAR *v;
510
511 v = ve->var;
512 (void)printf("%*.1f", v->width, getpcpu(k));
513}
514
469{
470 static int failure;
471
472 if (!nlistread)
473 failure = donlist();
474 if (failure)
475 return (0.0);
476

--- 12 unchanged lines hidden (view full) ---

489pcpu(KINFO *k, VARENT *ve)
490{
491 VAR *v;
492
493 v = ve->var;
494 (void)printf("%*.1f", v->width, getpcpu(k));
495}
496
515double
497static double
516getpmem(KINFO *k)
517{
518 static int failure;
519 double fracmem;
520
521 if (!nlistread)
522 failure = donlist();
523 if (failure)

--- 21 unchanged lines hidden (view full) ---

545{
546 VAR *v;
547
548 v = ve->var;
549 (void)printf("%*ld", v->width,
550 k->ki_valid ? k->ki_p->ki_rusage.ru_majflt : 0);
551}
552
498getpmem(KINFO *k)
499{
500 static int failure;
501 double fracmem;
502
503 if (!nlistread)
504 failure = donlist();
505 if (failure)

--- 21 unchanged lines hidden (view full) ---

527{
528 VAR *v;
529
530 v = ve->var;
531 (void)printf("%*ld", v->width,
532 k->ki_valid ? k->ki_p->ki_rusage.ru_majflt : 0);
533}
534
535/* ARGSUSED */
553void
536void
554maxrss(KINFO *k, VARENT *ve)
537maxrss(KINFO *k __unused, VARENT *ve)
555{
556 VAR *v;
557
558 v = ve->var;
559 /* XXX not yet */
560 (void)printf("%*s", v->width, "-");
561}
562

--- 5 unchanged lines hidden (view full) ---

568 v = ve->var;
569 (void)printf("%*ld", v->width, (long)pgtok(k->ki_p->ki_tsize));
570}
571
572void
573priorityr(KINFO *k, VARENT *ve)
574{
575 VAR *v;
538{
539 VAR *v;
540
541 v = ve->var;
542 /* XXX not yet */
543 (void)printf("%*s", v->width, "-");
544}
545

--- 5 unchanged lines hidden (view full) ---

551 v = ve->var;
552 (void)printf("%*ld", v->width, (long)pgtok(k->ki_p->ki_tsize));
553}
554
555void
556priorityr(KINFO *k, VARENT *ve)
557{
558 VAR *v;
576 struct priority *pri;
559 struct priority *lpri;
577 char str[8];
578 unsigned class, level;
579
580 v = ve->var;
560 char str[8];
561 unsigned class, level;
562
563 v = ve->var;
581 pri = (struct priority *) ((char *)k + v->off);
582 class = pri->pri_class;
583 level = pri->pri_level;
564 lpri = (struct priority *) ((char *)k + v->off);
565 class = lpri->pri_class;
566 level = lpri->pri_level;
584 switch (class) {
585 case PRI_REALTIME:
586 snprintf(str, sizeof(str), "real:%u", level);
587 break;
588 case PRI_TIMESHARE:
589 strncpy(str, "normal", sizeof(str));
590 break;
591 case PRI_IDLE:

--- 89 unchanged lines hidden ---
567 switch (class) {
568 case PRI_REALTIME:
569 snprintf(str, sizeof(str), "real:%u", level);
570 break;
571 case PRI_TIMESHARE:
572 strncpy(str, "normal", sizeof(str));
573 break;
574 case PRI_IDLE:

--- 89 unchanged lines hidden ---