summaryrefslogtreecommitdiffstats
path: root/usr.sbin/jls
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/jls')
-rw-r--r--usr.sbin/jls/jls.88
-rw-r--r--usr.sbin/jls/jls.c32
2 files changed, 29 insertions, 11 deletions
diff --git a/usr.sbin/jls/jls.8 b/usr.sbin/jls/jls.8
index 2107405..3137654 100644
--- a/usr.sbin/jls/jls.8
+++ b/usr.sbin/jls/jls.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 8, 2009
+.Dd July 20, 2012
.Dt JLS 8
.Os
.Sh NAME
@@ -33,7 +33,7 @@
.Nd "list jails"
.Sh SYNOPSIS
.Nm
-.Op Fl dhnqsv
+.Op Fl dhNnqsv
.Op Fl j Ar jail
.Op Ar parameter ...
.Sh DESCRIPTION
@@ -71,6 +71,10 @@ Print a header line containing the parameters listed.
If no parameters are given on the command line,
.Va all
is assumed.
+.It Fl N
+In the standard display mode, print each jail's name instead of its
+numeric ID.
+If the jail does not have a name, the numeric ID is printed instead.
.It Fl n
Print parameters in
.Dq name=value
diff --git a/usr.sbin/jls/jls.c b/usr.sbin/jls/jls.c
index f16972c..ce07100 100644
--- a/usr.sbin/jls/jls.c
+++ b/usr.sbin/jls/jls.c
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
#define PRINT_QUOTED 0x08
#define PRINT_SKIP 0x10
#define PRINT_VERBOSE 0x20
+#define PRINT_JAIL_NAME 0x40
static struct jailparam *params;
static int *param_parent;
@@ -82,7 +83,7 @@ main(int argc, char **argv)
jname = NULL;
pflags = jflags = jid = 0;
- while ((c = getopt(argc, argv, "adj:hnqsv")) >= 0)
+ while ((c = getopt(argc, argv, "adj:hNnqsv")) >= 0)
switch (c) {
case 'a':
case 'd':
@@ -99,6 +100,9 @@ main(int argc, char **argv)
pflags = (pflags & ~(PRINT_SKIP | PRINT_VERBOSE)) |
PRINT_HEADER;
break;
+ case 'N':
+ pflags |= PRINT_JAIL_NAME;
+ break;
case 'n':
pflags = (pflags & ~PRINT_VERBOSE) | PRINT_NAMEVAL;
break;
@@ -115,7 +119,7 @@ main(int argc, char **argv)
PRINT_VERBOSE;
break;
default:
- errx(1, "usage: jls [-dhnqv] [-j jail] [param ...]");
+ errx(1, "usage: jls [-dhNnqv] [-j jail] [param ...]");
}
#ifdef INET6
@@ -149,7 +153,10 @@ main(int argc, char **argv)
#endif
} else {
pflags |= PRINT_DEFAULT;
- add_param("jid", NULL, (size_t)0, NULL, JP_USER);
+ if (pflags & PRINT_JAIL_NAME)
+ add_param("name", NULL, (size_t)0, NULL, JP_USER);
+ else
+ add_param("jid", NULL, (size_t)0, NULL, JP_USER);
#ifdef INET
if (ip4_ok)
add_param("ip4.addr", NULL, (size_t)0, NULL,
@@ -192,8 +199,12 @@ main(int argc, char **argv)
" CPUSetID\n"
" IP Address(es)\n");
else if (pflags & PRINT_DEFAULT)
- printf(" JID IP Address "
- "Hostname Path\n");
+ if (pflags & PRINT_JAIL_NAME)
+ printf(" JID IP Address "
+ "Hostname Path\n");
+ else
+ printf(" JID IP Address "
+ "Hostname Path\n");
else if (pflags & PRINT_HEADER) {
for (i = spc = 0; i < nparams; i++)
if (params[i].jp_flags & JP_USER) {
@@ -397,9 +408,12 @@ print_jail(int pflags, int jflags)
n++;
}
#endif
- } else if (pflags & PRINT_DEFAULT)
- printf("%6d %-15.15s %-29.29s %.74s\n",
- *(int *)params[0].jp_value,
+ } else if (pflags & PRINT_DEFAULT) {
+ if (pflags & PRINT_JAIL_NAME)
+ printf(" %-15s ", (char *)params[0].jp_value);
+ else
+ printf("%6d ", *(int *)params[0].jp_value);
+ printf("%-15.15s %-29.29s %.74s\n",
#ifdef INET
(!ip4_ok || params[1].jp_valuelen == 0) ? "-"
: inet_ntoa(*(struct in_addr *)params[1].jp_value),
@@ -410,7 +424,7 @@ print_jail(int pflags, int jflags)
(char *)params[1].jp_value,
(char *)params[2].jp_value);
#endif
- else {
+ } else {
param_values = alloca(nparams * sizeof(*param_values));
for (i = 0; i < nparams; i++) {
if (!(params[i].jp_flags & JP_USER))
OpenPOWER on IntegriCloud