From owner-p4-projects Mon Oct 21 9:44: 9 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9C15837B404; Mon, 21 Oct 2002 09:44:06 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 33ED437B401 for ; Mon, 21 Oct 2002 09:44:06 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C6C9C43E75 for ; Mon, 21 Oct 2002 09:44:05 -0700 (PDT) (envelope-from green@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id g9LGhamV010375 for ; Mon, 21 Oct 2002 09:43:36 -0700 (PDT) (envelope-from green@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id g9LGhaXA010372 for perforce@freebsd.org; Mon, 21 Oct 2002 09:43:36 -0700 (PDT) Date: Mon, 21 Oct 2002 09:43:36 -0700 (PDT) Message-Id: <200210211643.g9LGhaXA010372@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to green@freebsd.org using -f From: Brian Feldman Subject: PERFORCE change 19798 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://perforce.freebsd.org/chv.cgi?CH=19798 Change 19798 by green@green_laptop_2 on 2002/10/21 09:42:38 Correct printing of MAC labels to justify/align properly. Affected files ... .. //depot/projects/trustedbsd/mac/bin/ps/extern.h#10 edit .. //depot/projects/trustedbsd/mac/bin/ps/keyword.c#12 edit .. //depot/projects/trustedbsd/mac/bin/ps/print.c#14 edit Differences ... ==== //depot/projects/trustedbsd/mac/bin/ps/extern.h#10 (text+ko) ==== @@ -71,6 +71,7 @@ void rgroupname(KINFO *, VARENT *); void runame(KINFO *, VARENT *); void rvar(KINFO *, VARENT *); +int s_label(KINFO *); int s_rgroupname(KINFO *); int s_runame(KINFO *); int s_uname(KINFO *); ==== //depot/projects/trustedbsd/mac/bin/ps/keyword.c#12 (text+ko) ==== @@ -95,7 +95,8 @@ 0}, {"ktrace", "KTRACE", NULL, 0, kvar, NULL, 8, KOFF(ki_traceflag), INT, "x", 0}, - {"label", "LABEL", NULL, LJUST, label, NULL, 0, 0, CHAR, NULL, 0}, + {"label", "LABEL", NULL, LJUST|DSIZ, label, s_label, SHRT_MAX, 0, CHAR, + NULL, 0}, {"lim", "LIM", NULL, 0, maxrss, NULL, 5, 0, CHAR, NULL, 0}, {"login", "LOGIN", NULL, LJUST, logname, NULL, MAXLOGNAME-1, 0, CHAR, NULL, 0}, ==== //depot/projects/trustedbsd/mac/bin/ps/print.c#14 (text+ko) ==== @@ -749,9 +749,34 @@ mac_free(label); out: - if (string != NULL) - (void)printf("%*s", v->width, string); - else - (void)printf("%*s", v->width, ""); + if (string != NULL) { + (void)printf("%-*s", v->width, string); + free(string); + } else + (void)printf("%-*s", v->width, ""); return; } + +int +s_label(KINFO *k) +{ + char *string = NULL; + mac_t label; + int error, size = 0; + + if (mac_prepare_process_label(&label) == -1) { + perror("mac_prepare_process_label"); + fprintf(stderr, "returning size %d for pid %d\n", 0, + k->ki_p->ki_pid); + return (0); + } + error = mac_get_pid(k->ki_p->ki_pid, label); + if (error == 0 && mac_to_text(label, &string) == 0) { + size = strlen(string); + free(string); + fprintf(stderr, "returning size %d for pid %d\n", size, + k->ki_p->ki_pid); + } + mac_free(label); + return (size); +} To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message