Date: Sun, 14 Dec 2008 16:56:47 +0000 (UTC) From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r186085 - head/usr.sbin/jls Message-ID: <200812141656.mBEGulI4064249@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bz Date: Sun Dec 14 16:56:47 2008 New Revision: 186085 URL: http://svn.freebsd.org/changeset/base/186085 Log: Make sure that the direct jls invocations prints something reasonable close to and in the same format as it had always. r185435 said it would try that but I had been living with jail patches for too long to actually remember the single-line format when adding backwards compatibility back in p4. Reported by: Philipp Wuensche <cryx-freebsd@h3q.com> Tested by: Philipp Wuensche <cryx-freebsd@h3q.com> MFC after: 4 weeks (just for me to get the mail) Modified: head/usr.sbin/jls/jls.c Modified: head/usr.sbin/jls/jls.c ============================================================================== --- head/usr.sbin/jls/jls.c Sun Dec 14 16:49:40 2008 (r186084) +++ head/usr.sbin/jls/jls.c Sun Dec 14 16:56:47 2008 (r186085) @@ -48,7 +48,7 @@ #ifdef SUPPORT_OLD_XPRISON static -char *print_xprison_v1(void *p, char *end) +char *print_xprison_v1(void *p, char *end, unsigned flags) { struct xprison_v1 *xp; struct in_addr in; @@ -57,15 +57,18 @@ char *print_xprison_v1(void *p, char *en errx(1, "Invalid length for jail"); xp = (struct xprison_v1 *)p; - printf("%6d %-29.29s %.74s\n", - xp->pr_id, xp->pr_host, xp->pr_path); - - /* We are not printing an empty line here for state and name. */ - /* We are not printing an empty line here for cpusetid. */ - - /* IPv4 address. */ - in.s_addr = htonl(xp->pr_ip); - printf("%6s %-15.15s\n", "", inet_ntoa(in)); + if (flags & FLAG_V) { + printf("%6d %-29.29s %.74s\n", + xp->pr_id, xp->pr_host, xp->pr_path); + /* We are not printing an empty line here for state and name. */ + /* We are not printing an empty line here for cpusetid. */ + /* IPv4 address. */ + in.s_addr = htonl(xp->pr_ip); + printf("%6s %-15.15s\n", "", inet_ntoa(in)); + } else { + printf("%6d %-15.15s %-29.29s %.74s\n", + xp->pr_id, inet_ntoa(in), xp->pr_host, xp->pr_path); + } return ((char *)(xp + 1)); } @@ -104,8 +107,9 @@ char *print_xprison_v3(void *p, char *en return (q); } - printf("%6d %-29.29s %.74s\n", - xp->pr_id, xp->pr_host, xp->pr_path); + if (flags & FLAG_V) + printf("%6d %-29.29s %.74s\n", + xp->pr_id, xp->pr_host, xp->pr_path); /* Jail state and name. */ if (flags & FLAG_V) @@ -123,11 +127,12 @@ char *print_xprison_v3(void *p, char *en q += (xp->pr_ip4s * sizeof(struct in_addr)); if (q > end) errx(1, "Invalid length for jail"); + in.s_addr = 0; for (i = 0; i < xp->pr_ip4s; i++) { - if (i == 0 || flags & FLAG_V) { + if (i == 0 || flags & FLAG_V) in.s_addr = iap[i].s_addr; + if (flags & FLAG_V) printf("%6s %-15.15s\n", "", inet_ntoa(in)); - } } /* IPv6 addresses. */ ia6p = (struct in6_addr *)(void *)q; @@ -141,6 +146,12 @@ char *print_xprison_v3(void *p, char *en } } + /* If requested print the old style single line version. */ + if (!(flags & FLAG_V)) + printf("%6d %-15.15s %-29.29s %.74s\n", + xp->pr_id, (in.s_addr) ? inet_ntoa(in) : "", + xp->pr_host, xp->pr_path); + return (q); } @@ -206,12 +217,15 @@ main(int argc, char *argv[]) if (version > XPRISON_VERSION) errx(1, "Sci-Fi prison. Kernel/userland out of sync?"); - printf(" JID Hostname Path\n"); if (flags & FLAG_V) { + printf(" JID Hostname Path\n"); printf(" Name State\n"); printf(" CPUSetID\n"); + printf(" IP Address(es)\n"); + } else { + printf(" JID IP Address Hostname" + " Path\n"); } - printf(" IP Address(es)\n"); for (; q != NULL && (char *)q + sizeof(int) < (char *)p + len;) { version = *(int *)q; if (version > XPRISON_VERSION) @@ -219,7 +233,7 @@ main(int argc, char *argv[]) switch (version) { #ifdef SUPPORT_OLD_XPRISON case 1: - q = print_xprison_v1(q, (char *)p + len); + q = print_xprison_v1(q, (char *)p + len, flags); break; case 2: errx(1, "Version 2 was used by multi-IPv4 jail "
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812141656.mBEGulI4064249>