aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bsdinstall/distfetch/distfetch.c2
-rw-r--r--usr.sbin/makefs/cd9660.c6
-rw-r--r--usr.sbin/makefs/ffs/ffs_bswap.c8
-rw-r--r--usr.sbin/makefs/makefs.867
-rwxr-xr-xusr.sbin/makefs/tests/makefs_cd9660_tests.sh60
-rwxr-xr-xusr.sbin/makefs/tests/makefs_ffs_tests.sh69
-rwxr-xr-xusr.sbin/makefs/tests/makefs_tests_common.sh9
-rw-r--r--usr.sbin/pciconf/cap.c4
-rw-r--r--usr.sbin/sysrc/sysrc181
-rw-r--r--usr.sbin/sysrc/sysrc.869
10 files changed, 427 insertions, 48 deletions
diff --git a/usr.sbin/bsdinstall/distfetch/distfetch.c b/usr.sbin/bsdinstall/distfetch/distfetch.c
index 4e870c8bbdbf..219847db6423 100644
--- a/usr.sbin/bsdinstall/distfetch/distfetch.c
+++ b/usr.sbin/bsdinstall/distfetch/distfetch.c
@@ -78,7 +78,7 @@ main(void)
if (chdir(getenv("BSDINSTALL_DISTDIR")) != 0) {
snprintf(error, sizeof(error),
- "Could could change to directory %s: %s\n",
+ "Could not change to directory %s: %s\n",
getenv("BSDINSTALL_DISTDIR"), strerror(errno));
dialog_msgbox("Error", error, 0, 0, TRUE);
end_dialog();
diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index b5be46906b09..e05e52ac32c9 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -296,8 +296,8 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
int rv;
/* Set up allowed options - integer options ONLY */
option_t cd9660_options[] = {
- { "l", &diskStructure.isoLevel, 1, 3, "ISO Level" },
- { "isolevel", &diskStructure.isoLevel, 1, 3, "ISO Level" },
+ { "l", &diskStructure.isoLevel, 1, 2, "ISO Level" },
+ { "isolevel", &diskStructure.isoLevel, 1, 2, "ISO Level" },
{ "verbose", &diskStructure.verbose_level, 0, 2,
"Turns on verbose output" },
{ "v", &diskStructure.verbose_level, 0 , 2,
@@ -1055,6 +1055,7 @@ cd9660_rename_filename(cd9660node *iter, int num, int delete_chars)
if (diskStructure.verbose_level > 0)
printf("Rename_filename called\n");
+ assert(1 <= diskStructure.isoLevel && diskStructure.isoLevel <= 2);
/* TODO : A LOT of chanes regarding 8.3 filenames */
if (diskStructure.isoLevel == 1)
maxlength = 8;
@@ -1730,6 +1731,7 @@ cd9660_joliet_convert_filename(const char *oldname, char *newname, int is_file)
static int
cd9660_convert_filename(const char *oldname, char *newname, int is_file)
{
+ assert(1 <= diskStructure.isoLevel && diskStructure.isoLevel <= 2);
/* NEW */
cd9660_filename_conversion_functor conversion_function = 0;
if (diskStructure.isoLevel == 1)
diff --git a/usr.sbin/makefs/ffs/ffs_bswap.c b/usr.sbin/makefs/ffs/ffs_bswap.c
index a1a1c46c5360..e62eb1957b9e 100644
--- a/usr.sbin/makefs/ffs/ffs_bswap.c
+++ b/usr.sbin/makefs/ffs/ffs_bswap.c
@@ -67,7 +67,7 @@ void ffs_csumtotal_swap(struct csum_total *o, struct csum_total *n);
void
ffs_sb_swap(struct fs *o, struct fs *n)
{
- int i;
+ size_t i;
u_int32_t *o32, *n32;
/*
@@ -97,7 +97,7 @@ ffs_sb_swap(struct fs *o, struct fs *n)
n->fs_csaddr = bswap64(o->fs_csaddr);
n->fs_pendingblocks = bswap64(o->fs_pendingblocks);
n->fs_pendinginodes = bswap32(o->fs_pendinginodes);
-
+
/* These fields overlap with the second half of the
* historic FS_42POSTBLFMT postbl table
*/
@@ -171,9 +171,9 @@ ffs_dinode2_swap(struct ufs2_dinode *o, struct ufs2_dinode *n)
void
ffs_csum_swap(struct csum *o, struct csum *n, int size)
{
- int i;
+ size_t i;
u_int32_t *oint, *nint;
-
+
oint = (u_int32_t*)o;
nint = (u_int32_t*)n;
diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8
index edecd4a63890..c9d6c0761a21 100644
--- a/usr.sbin/makefs/makefs.8
+++ b/usr.sbin/makefs/makefs.8
@@ -35,7 +35,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 29, 2015
+.Dd November 1, 2015
.Dt MAKEFS 8
.Os
.Sh NAME
@@ -44,10 +44,10 @@
.Sh SYNOPSIS
.Nm
.Op Fl DxZ
-.Op Fl B Ar byte-order
+.Op Fl B Ar endian
.Op Fl b Ar free-blocks
.Op Fl d Ar debug-mask
-.Op Fl F Ar specfile
+.Op Fl F Ar mtree-specfile
.Op Fl f Ar free-files
.Op Fl M Ar minimum-size
.Op Fl m Ar maximum-size
@@ -69,9 +69,9 @@ from the directory tree
.Ar directory
or from the mtree manifest
.Ar manifest .
-If optional directory tree
+If any optional directory trees are passed in the
.Ar extra-directory
-is passed, then the directory tree of each argument will be merged
+arguments, then the directory tree of each argument will be merged
into the
.Ar directory
or
@@ -82,9 +82,9 @@ No special devices or privileges are required to perform this task.
.Pp
The options are as follows:
.Bl -tag -width flag
-.It Fl B Ar byte-order
+.It Fl B Ar endian
Set the byte order of the image to
-.Ar byte-order .
+.Ar endian .
Valid byte orders are
.Ql 4321 ,
.Ql big ,
@@ -114,9 +114,9 @@ Enable various levels of debugging, depending upon which bits are
set in
.Ar debug-mask .
XXX: document these
-.It Fl F Ar specfile
+.It Fl F Ar mtree-specfile
Use
-.Ar specfile
+.Ar mtree-specfile
as an
.Xr mtree 8
.Sq specfile
@@ -174,13 +174,13 @@ Set the maximum size of the file system image to
.Ar maximum-size .
An error will be raised if the target file system needs to be larger
than this to accommodate the provided directory tree.
-.It Fl N Ar dbdir
+.It Fl N Ar userdb-dir
Use the user database text file
.Pa master.passwd
and group database text file
.Pa group
from
-.Ar dbdir ,
+.Ar userdb-dir ,
rather than using the results from the system's
.Xr getpwnam 3
and
@@ -226,7 +226,9 @@ ISO 9660 file system.
.It Fl x
Exclude file system nodes not explicitly listed in the specfile.
.It Fl Z
-Create the image as a sparse file.
+Create a sparse file for
+.Sy ffs .
+This is useful for virtual machine images.
.El
.Pp
Where sizes are specified, a decimal number of bytes is expected.
@@ -301,10 +303,10 @@ The following keywords are supported:
.It Sy allow-deep-trees
Allow the directory structure to exceed the maximum specified in
the spec.
-.\" .It Sy allow-illegal-chars
-.\" Unknown
-.\" .It Sy allow-lowercase
-.\" Unknown
+.It Sy allow-illegal-chars
+Allow illegal characters in filenames. This option is not implemented.
+.It Sy allow-lowercase
+Allow lowercase characters in filenames. This option is not implemented.
.It Sy allow-max-name
Allow 37 instead of 33 characters for filenames by omitting the
version id.
@@ -318,6 +320,8 @@ Use the
extension to encode
.Tn RISC OS
metadata.
+.It Sy bootimagedir
+Boot image directory. This option is not implemented.
.It Sy chrp-boot
Write an MBR partition table to the image to allow older CHRP hardware to
boot.
@@ -338,8 +342,18 @@ or
Load a generic boot image into the first 32K of the cd9660 image.
.It Sy hard-disk-boot
Boot image is a hard disk image.
+.It Sy isolevel
+An integer representing the ISO 9660 interchange level where
+.Dq level
+is either
+.Ql 1
+or
+.Ql 2 .
+.Dq level
+.Ql 3
+is not implemented.
.It Sy keep-bad-images
-Do not throw away images whose write was aborted due to an error.
+Don't throw away images whose write was aborted due to an error.
For debugging purposes.
.It Sy label
Label name of the image.
@@ -351,14 +365,16 @@ Boot image is a
ElTorito image.
.It Sy no-trailing-padding
Do not pad the image (apparently Linux needs the padding).
-.\" .It Sy omit-trailing-period
-.\" Unknown
+.It Sy omit-trailing-period
+Omit trailing periods in filenames.
.It Sy preparer
Preparer ID of the image.
.It Sy publisher
Publisher ID of the image.
.It Sy rockridge
Use RockRidge extensions (for longer filenames, etc.).
+.It Sy verbose
+Turns on verbose output.
.It Sy volumeid
Volume set identifier of the image.
.El
@@ -372,11 +388,12 @@ The
utility appeared in
.Nx 1.6 .
.Sh AUTHORS
-.An Luke Mewburn Aq Mt lukem@NetBSD.org
-(original program)
-.An Daniel Watt
-.An Walter Deignan
-.An Ryan Gabrys
-.An Alan Perez-Rathke
+.An Luke Mewburn
+.Aq lukem@NetBSD.org
+(original program),
+.An Daniel Watt ,
+.An Walter Deignan ,
+.An Ryan Gabrys ,
+.An Alan Perez-Rathke ,
.An Ram Vedam
(cd9660 support)
diff --git a/usr.sbin/makefs/tests/makefs_cd9660_tests.sh b/usr.sbin/makefs/tests/makefs_cd9660_tests.sh
index e476cf1bf8dd..161b56b12e7a 100755
--- a/usr.sbin/makefs/tests/makefs_cd9660_tests.sh
+++ b/usr.sbin/makefs/tests/makefs_cd9660_tests.sh
@@ -113,7 +113,7 @@ from_mtree_spec_file_body()
create_test_inputs
atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
- mtree -c -k type,link,size -p $TEST_INPUTS_DIR
+ mtree -c -k "$DEFAULT_MTREE_KEYWORDS" -p $TEST_INPUTS_DIR
cd $TEST_INPUTS_DIR
atf_check -e empty -o empty -s exit:0 \
$MAKEFS $TEST_IMAGE $TEST_SPEC_FILE
@@ -208,6 +208,61 @@ o_flag_allow_max_name_cleanup()
common_cleanup
}
+atf_test_case o_flag_isolevel_1 cleanup
+o_flag_isolevel_1_body()
+{
+ atf_expect_fail "this testcase needs work; the filenames generated seem incorrect/corrupt"
+
+ create_test_inputs
+
+ atf_check -e empty -o empty -s exit:0 \
+ $MAKEFS -o isolevel=1 $TEST_IMAGE $TEST_INPUTS_DIR
+
+ mount_image
+ check_base_iso9660_image_contents
+}
+o_flag_isolevel_1_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case o_flag_isolevel_2 cleanup
+o_flag_isolevel_2_body()
+{
+ create_test_inputs
+
+ atf_check -e empty -o empty -s exit:0 \
+ $MAKEFS -o isolevel=2 $TEST_IMAGE $TEST_INPUTS_DIR
+
+ mount_image
+ check_base_iso9660_image_contents
+}
+o_flag_isolevel_2_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case o_flag_isolevel_3 cleanup
+o_flag_isolevel_3_body()
+{
+ create_test_inputs
+
+ # XXX: isolevel=3 isn't implemented yet. See FreeBSD bug # 203645
+ if true; then
+ atf_check -e match:'makefs: ISO Level 3 is greater than 2\.' -o empty -s not-exit:0 \
+ $MAKEFS -o isolevel=3 $TEST_IMAGE $TEST_INPUTS_DIR
+ else
+ atf_check -e empty -o empty -s exit:0 \
+ $MAKEFS -o isolevel=3 $TEST_IMAGE $TEST_INPUTS_DIR
+ mount_image
+ check_base_iso9660_image_contents
+ fi
+}
+o_flag_isolevel_3_cleanup()
+{
+ common_cleanup
+}
+
atf_test_case o_flag_preparer
o_flag_preparer_body()
{
@@ -308,6 +363,9 @@ atf_init_test_cases()
atf_add_test_case o_flag_allow_deep_trees
atf_add_test_case o_flag_allow_max_name
+ atf_add_test_case o_flag_isolevel_1
+ atf_add_test_case o_flag_isolevel_2
+ atf_add_test_case o_flag_isolevel_3
atf_add_test_case o_flag_preparer
atf_add_test_case o_flag_publisher
atf_add_test_case o_flag_rockridge
diff --git a/usr.sbin/makefs/tests/makefs_ffs_tests.sh b/usr.sbin/makefs/tests/makefs_ffs_tests.sh
index 4bc3f5c25892..121c2a2d9eb8 100755
--- a/usr.sbin/makefs/tests/makefs_ffs_tests.sh
+++ b/usr.sbin/makefs/tests/makefs_ffs_tests.sh
@@ -105,7 +105,7 @@ from_mtree_spec_file_body()
create_test_inputs
atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
- mtree -c -k type,link,size -p $TEST_INPUTS_DIR
+ mtree -c -k "$DEFAULT_MTREE_KEYWORDS" -p $TEST_INPUTS_DIR
cd $TEST_INPUTS_DIR
atf_check -e empty -o not-empty -s exit:0 \
@@ -158,6 +158,70 @@ from_single_dir_cleanup()
common_cleanup
}
+atf_test_case o_flag_version_1 cleanup
+o_flag_version_1_body()
+{
+ ffs_version=1
+
+ platform=$(uname)
+ case "$platform" in
+ FreeBSD)
+ ffs_label=UFS${ffs_version}
+ ;;
+ NetBSD)
+ ffs_label=FFSv${ffs_version}
+ ;;
+ *)
+ atf_skip "Unsupported platform"
+ ;;
+ esac
+
+ create_test_inputs
+
+ atf_check -e empty -o not-empty -s exit:0 \
+ $MAKEFS -M 1m -o version=$ffs_version $TEST_IMAGE $TEST_INPUTS_DIR
+
+ mount_image
+ atf_check -e empty -o match:"$ffs_label" dumpfs $TEST_MOUNT_DIR
+ check_ffs_image_contents
+}
+o_flag_version_1_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case o_flag_version_2 cleanup
+o_flag_version_2_body()
+{
+ ffs_version=2
+
+ platform=$(uname)
+ case "$platform" in
+ FreeBSD)
+ ffs_label=UFS${ffs_version}
+ ;;
+ NetBSD)
+ ffs_label=FFSv${ffs_version}
+ ;;
+ *)
+ atf_skip "Unsupported platform"
+ ;;
+ esac
+
+ create_test_inputs
+
+ atf_check -e empty -o not-empty -s exit:0 \
+ $MAKEFS -M 1m -o version=$ffs_version $TEST_IMAGE $TEST_INPUTS_DIR
+
+ mount_image
+ atf_check -e empty -o match:"$ffs_label" dumpfs $TEST_MOUNT_DIR
+ check_ffs_image_contents
+}
+o_flag_version_2_cleanup()
+{
+ common_cleanup
+}
+
atf_init_test_cases()
{
@@ -168,5 +232,6 @@ atf_init_test_cases()
atf_add_test_case from_multiple_dirs
atf_add_test_case from_single_dir
-
+ atf_add_test_case o_flag_version_1
+ atf_add_test_case o_flag_version_2
}
diff --git a/usr.sbin/makefs/tests/makefs_tests_common.sh b/usr.sbin/makefs/tests/makefs_tests_common.sh
index d0099fd9c183..add0b88728e2 100755
--- a/usr.sbin/makefs/tests/makefs_tests_common.sh
+++ b/usr.sbin/makefs/tests/makefs_tests_common.sh
@@ -29,6 +29,13 @@
KB=1024
: ${TMPDIR=/tmp}
+# TODO: add mtree `time` support; get a lot of errors like this right now when
+# passing generating disk images with keyword mtree support, like:
+#
+# `[...]/mtree.spec:8: error: time: invalid value '1446458503'`
+#
+#DEFAULT_MTREE_KEYWORDS="type,mode,gid,uid,size,link,time"
+DEFAULT_MTREE_KEYWORDS="type,mode,gid,uid,size,link"
TEST_IMAGE="$TMPDIR/test.img"
TEST_INPUTS_DIR="$TMPDIR/inputs"
TEST_MD_DEVICE_FILE="$TMPDIR/md.output"
@@ -39,7 +46,7 @@ check_image_contents()
{
local directories=$TEST_INPUTS_DIR
local excludes mtree_excludes_arg mtree_file
- local mtree_keywords="type,link,size"
+ local mtree_keywords="$DEFAULT_MTREE_KEYWORDS"
while getopts "d:f:m:X:" flag; do
case "$flag" in
diff --git a/usr.sbin/pciconf/cap.c b/usr.sbin/pciconf/cap.c
index 2e2e359fb825..9ab6dd17ddbd 100644
--- a/usr.sbin/pciconf/cap.c
+++ b/usr.sbin/pciconf/cap.c
@@ -460,6 +460,10 @@ cap_express(int fd, struct pci_conf *p, uint8_t ptr)
MAX_PAYLOAD(cap & PCIEM_CAP_MAX_PAYLOAD));
if ((cap & PCIEM_CAP_FLR) != 0)
printf(" FLR");
+ if (ctl & PCIEM_CTL_RELAXED_ORD_ENABLE)
+ printf(" RO");
+ if (ctl & PCIEM_CTL_NOSNOOP_ENABLE)
+ printf(" NS");
cap = read_config(fd, &p->pc_sel, ptr + PCIER_LINK_CAP, 4);
sta = read_config(fd, &p->pc_sel, ptr + PCIER_LINK_STA, 2);
printf(" link x%d(x%d)", (sta & PCIEM_LINK_STA_WIDTH) >> 4,
diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc
index 2a245510ef64..e384dff93f6c 100644
--- a/usr.sbin/sysrc/sysrc
+++ b/usr.sbin/sysrc/sysrc
@@ -40,18 +40,23 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
#
# Version information
#
-SYSRC_VERSION="6.5 Sep-1,2015"
+SYSRC_VERSION="7.0 Sep-13,2015"
#
# Options
#
CHECK_ONLY=
+DEFAULT=
DELETE=
DESCRIBE=
+EXISTING_ONLY=
IGNORE_UNKNOWNS=
JAIL=
+LIST_SERVICE_CONFS=
+LIST_CONFS=
QUIET=
ROOTDIR=
+SERVICE=
SHOW_ALL=
SHOW_EQUALS=
SHOW_FILE=
@@ -80,7 +85,8 @@ die()
#
usage()
{
- f_err "Usage: %s [OPTIONS] name[[+|-]=value] ...\n" "$pgm"
+ f_err "Usage: %s [OPTIONS] %s\n" "$pgm" \
+ "{name[[+|-]=value] ... | -a | -A | -l | -L [name ...]}"
f_err "Try \`%s --help' for more information.\n" "$pgm"
die
}
@@ -95,6 +101,8 @@ help()
local envfmt="\t%-17s%s\n"
f_err "Usage: %s [OPTIONS] name[[+|-]=value] ...\n" "$pgm"
+ f_err "Usage: %s [OPTIONS] -a | -A\n" "$pgm"
+ f_err "Usage: %s [OPTIONS] -l | -L [name ...]\n" "$pgm"
f_err "OPTIONS:\n"
f_err "$optfmt" "-a" \
@@ -113,6 +121,8 @@ help()
"Print query results as \`var=value' (useful for producing"
f_err "$optfmt" "" \
"output to be fed back in). Ignored if \`-n' is specified."
+ f_err "$optfmt" "-E" \
+ "Existing files only with \`-[lL]' or when changing a setting."
f_err "$optfmt" "-f file" \
"Operate on the specified file(s) instead of rc_conf_files."
f_err "$optfmt" "" \
@@ -129,12 +139,20 @@ help()
"The jid or name of the jail to operate within (overrides"
f_err "$optfmt" "" \
"\`-R dir'; requires jexec(8))."
+ f_err "$optfmt" "-l" \
+ "List configuration files used at startup on stdout and exit."
+ f_err "$optfmt" "-L" \
+ "List all configuration files including rc.conf.d entries."
f_err "$optfmt" "-n" \
"Show only variable values, not their names."
f_err "$optfmt" "-N" \
"Show only variable names, not their values."
f_err "$optfmt" "-q" \
"Quiet. Disable verbose and hide certain errors."
+ f_err "$optfmt" "-s name" \
+ "Process additional \`rc.conf.d' entries for service name."
+ f_err "$optfmt" "" \
+ "Ignored if \`-f file' is given."
f_err "$optfmt" "-R dir" \
"Operate within the root directory \`dir' rather than \`/'."
f_err "$optfmt" "-v" \
@@ -245,27 +263,33 @@ unset arg
#
# Process command-line flags
#
-while getopts aAcdDef:Fhij:nNqR:vxX flag; do
+while getopts aAcdDeEf:Fhij:lLnNqR:s:vxX flag; do
case "$flag" in
a) SHOW_ALL=${SHOW_ALL:-1} ;;
A) SHOW_ALL=2 ;;
c) CHECK_ONLY=1 ;;
d) DESCRIBE=1 ;;
- D) RC_CONFS= ;;
+ D) DEFAULT=1 RC_CONFS= ;;
e) SHOW_EQUALS=1 ;;
- f) RC_CONFS="$RC_CONFS${RC_CONFS:+ }$OPTARG" ;;
+ E) EXISTING_ONLY=1 ;;
+ f) DEFAULT= RC_CONFS="$RC_CONFS${RC_CONFS:+ }$OPTARG" ;;
F) SHOW_FILE=1 ;;
h) usage ;; # NOTREACHED
i) IGNORE_UNKNOWNS=1 ;;
j) [ "$OPTARG" ] ||
die "%s: Missing or null argument to \`-j' flag" "$pgm"
JAIL="$OPTARG" ;;
+ l) LIST_CONFS=1 ;;
+ L) LIST_SERVICE_CONFS=1 ;;
n) SHOW_NAME= ;;
N) SHOW_VALUE= ;;
q) QUIET=1 VERBOSE= ;;
R) [ "$OPTARG" ] ||
die "%s: Missing or null argument to \`-R' flag" "$pgm"
ROOTDIR="$OPTARG" ;;
+ s) [ "$OPTARG" ] ||
+ die "%s: Missing or null argument to \`-s' flag" "$pgm"
+ SERVICE="$OPTARG" ;;
v) VERBOSE=1 QUIET= ;;
x) DELETE=${DELETE:-1} ;;
X) DELETE=2 ;;
@@ -275,6 +299,129 @@ done
shift $(( $OPTIND - 1 ))
#
+# Process `-L' flag
+#
+if [ "$LIST_SERVICE_CONFS" ]; then
+ list=
+
+ #
+ # List rc_conf_files if no service names given
+ #
+ files=
+ [ $# -eq 0 ] && files=$( f_sysrc_get rc_conf_files )
+ for file in $files; do
+ if [ "$EXISTING_ONLY" ]; then
+ [ -e "$file" -a ! -d "$file" ] || continue
+ fi
+ case "$list" in
+ "$file"|*" $file"|"$file "*|*" $file "*) continue ;;
+ esac
+ list="$list $file"
+ done
+ list="${list# }"
+ if [ $# -eq 0 ]; then
+ if [ "$VERBOSE" ]; then
+ echo rc_conf_files: $list
+ elif [ "$SHOW_EQUALS" ]; then
+ echo "rc_conf_files=\"$list\""
+ fi
+ fi
+
+ #
+ # List rc.conf.d entries
+ #
+ retval=$SUCCESS
+ for service in ${*:-$( service -l )}; do
+ slist=
+ f_sysrc_service_configs $service files || retval=$? continue
+ for file in $files; do
+ if [ "$EXISTING_ONLY" ]; then
+ [ -e "$file" -a ! -d "$file" ] || continue
+ fi
+ if [ ! "$VERBOSE" -a ! "$SHOW_EQUALS" ]; then
+ case "$list" in
+ "$file"|*" $file"|"$file "*|*" $file "*)
+ continue ;;
+ esac
+ fi
+ slist="$slist $file"
+ done
+ slist="${slist# }"
+ if [ $# -gt 0 ]; then
+ [ "$slist" ] || retval=$?
+ fi
+ if [ "$VERBOSE" ]; then
+ [ "$slist" ] && echo "$service: $slist"
+ continue
+ elif [ "$SHOW_EQUALS" ]; then
+ [ "$slist" ] && echo "$service=\"$slist\""
+ continue
+ fi
+ list="$list${slist:+ }$slist"
+ done
+ if [ ! "$VERBOSE" -a ! "$SHOW_EQUALS" ]; then
+ if [ $# -eq 0 -o ! "$QUIET" ]; then
+ list="${list# }"
+ [ "$list" ] && echo $list
+ fi
+ fi
+
+ exit $retval
+fi
+
+#
+# Process `-s name' argument
+#
+if [ "$SERVICE" -a ! "${RC_CONFS+set}" ]; then
+ if f_sysrc_service_configs "$SERVICE" RC_CONFS; then
+ rc_conf_files=$( f_sysrc_get rc_conf_files )
+ RC_CONFS="$rc_conf_files${RC_CONFS:+ }$RC_CONFS"
+ unset rc_conf_files
+ else
+ unset RC_CONFS
+ fi
+fi
+
+#
+# Process `-E' option flag
+#
+if [ "$EXISTING_ONLY" ]; then
+ #
+ # To get f_sysrc_*() to ignore missing rc_conf_files, we have to use
+ # RC_CONFS to override the unpreened value. If RC_CONFS already has a
+ # value (`-D', `-f file', `-s name', or inherited from parent), use it.
+ # Otherwise, include filtered contents of rc_conf_files.
+ #
+ RC_CONFS=$(
+ if [ "${RC_CONFS+set}" ]; then
+ set -- $RC_CONFS
+ else
+ set -- $( f_sysrc_get rc_conf_files )
+ fi
+ while [ $# -gt 0 ]; do
+ [ -f "$1" ] && echo -n " $1"
+ shift
+ done
+ )
+ RC_CONFS="${RC_CONFS# }"
+fi
+
+#
+# Process `-l' option flag
+#
+if [ "$LIST_CONFS" ]; then
+ [ $# -eq 0 ] || usage
+ if [ "$DEFAULT" ]; then
+ echo "$RC_DEFAULTS"
+ elif [ "${RC_CONFS+set}" ]; then
+ echo "$RC_CONFS"
+ else
+ f_sysrc_get rc_conf_files
+ fi
+ exit $SUCCESS
+fi
+
+#
# [More] Sanity checks (e.g., "sysrc --")
#
[ $# -eq 0 -a ! "$SHOW_ALL" ] && usage # NOTREACHED
@@ -344,6 +491,10 @@ if [ "$JAIL" -o "$ROOTDIR" ]; then
$( [ "$SHOW_ALL" = "1" ] && echo \ -a )
$( [ "$SHOW_ALL" = "2" ] && echo \ -A )
${CHECK_ONLY:+-c}
+ ${DEFAULT:+-D}
+ ${EXISTING_ONLY:+-E}
+ ${LIST_CONFS:+-l}
+ ${LIST_SERVICE_CONFS:+-L}
${DESCRIBE:+-d}
${SHOW_EQUALS:+-e}
${IGNORE_UNKNOWNS:+-i}
@@ -351,6 +502,11 @@ if [ "$JAIL" -o "$ROOTDIR" ]; then
$( [ "$SHOW_VALUE" ] || echo \ -N )
$( [ "$SHOW_FILE" ] && echo \ -F )
"
+ if [ "$SERVICE" ]; then
+ escape "$SERVICE" _SERVICE
+ args="$args -s '$_SERVICE'"
+ unset _SERVICE
+ fi
if [ "${RC_CONFS+set}" ]; then
escape "$RC_CONFS" _RC_CONFS
args="$args -f '$_RC_CONFS'"
@@ -454,9 +610,10 @@ if [ "$SHOW_ALL" ]; then
#
IFS="$IFS|"
EXCEPT="IFS|EXCEPT|PATH|RC_DEFAULTS|OPTIND|DESCRIBE|SEP"
- EXCEPT="$EXCEPT|DELETE|SHOW_ALL|SHOW_EQUALS|SHOW_NAME"
- EXCEPT="$EXCEPT|SHOW_VALUE|SHOW_FILE|VERBOSE|RC_CONFS"
- EXCEPT="$EXCEPT|pgm|SUCCESS|FAILURE|CHECK_ONLY"
+ EXCEPT="$EXCEPT|DELETE|SHOW_ALL|SHOW_EQUALS|SHOW_NAME|DEFAULT"
+ EXCEPT="$EXCEPT|SHOW_VALUE|SHOW_FILE|VERBOSE|RC_CONFS|SERVICE"
+ EXCEPT="$EXCEPT|pgm|SUCCESS|FAILURE|CHECK_ONLY|EXISTING_ONLY"
+ EXCEPT="$EXCEPT|LIST_CONFS|LIST_SERVICE_CONFS"
EXCEPT="$EXCEPT|f_sysrc_desc_awk|f_sysrc_delete_awk"
#
@@ -479,7 +636,13 @@ if [ "$SHOW_ALL" ]; then
# explicit value, modifying the default behavior of
# source_rc_confs().
#
- [ "${RC_CONFS+set}" ] && rc_conf_files="$RC_CONFS"
+ if [ "${RC_CONFS+set}" ]; then
+ [ "$SHOW_ALL" = "1" -a "$SERVICE" -a \
+ ! "$DEFAULT" ] || rc_conf_files=
+ rc_conf_files="$rc_conf_files $RC_CONFS"
+ rc_conf_files="${rc_conf_files# }"
+ rc_conf_files="${rc_conf_files% }"
+ fi
source_rc_confs
diff --git a/usr.sbin/sysrc/sysrc.8 b/usr.sbin/sysrc/sysrc.8
index b1767b856d4a..dbd0e4b3c326 100644
--- a/usr.sbin/sysrc/sysrc.8
+++ b/usr.sbin/sysrc/sysrc.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 2, 2015
+.Dd September 12, 2015
.Dt SYSRC 8
.Os
.Sh NAME
@@ -32,16 +32,27 @@
.Nd safely edit system rc files
.Sh SYNOPSIS
.Nm
-.Op Fl cdDeFhinNqvx
+.Op Fl cdDeEFhinNqvx
+.Op Fl s Ar name
.Op Fl f Ar file
.Op Fl j Ar jail | Fl R Ar dir
.Ar name Ns Op Ns Oo +|- Oc Ns = Ns Ar value
.Ar ...
.Nm
-.Op Fl cdDeFhinNqvx
+.Op Fl cdDeEFhinNqvx
+.Op Fl s Ar name
.Op Fl f Ar file
.Op Fl j Ar jail | Fl R Ar dir
.Fl a | A
+.Nm
+.Op Fl E
+.Op Fl s Ar name
+.Op Fl f Ar file
+.Fl l
+.Nm
+.Op Fl eEqv
+.Fl L
+.Op Ar name ...
.Sh DESCRIPTION
The
.Nm
@@ -81,6 +92,13 @@ Ignored if either
or
.Ql Fl F
is specified.
+.It Fl E
+When given
+.Sq Fl l
+or
+.Sq Fl L
+to list configuration files, only list those that exist.
+When changing a setting, prefer to modify existing files.
.It Fl f Ar file
Operate on the specified file(s) instead of the files obtained by reading the
.Sq rc_conf_files
@@ -105,6 +123,17 @@ or name of the
.Ar jail
to operate within
.Pq overrides So Fl R Ar dir Sc ; requires Xr jexec 8 .
+.It Fl l
+List configuration files used at startup on stdout and exit.
+.It Fl L
+List all configuration files including rc.conf.d entries on stdout and exit.
+Can be combined with
+.Sq Fl v
+or
+.Sq Fl e
+to show service names.
+.Nm
+exits with success if all named services are installed, failure otherwise.
.It Fl n
Show only variable values, not their names.
.It Fl N
@@ -112,11 +141,40 @@ Show only variable names, not their values.
.It Fl q
Quiet.
Disable verbose and hide certain errors.
+When combined with
+.Sq Fl L
+and one or more
+.Li Ar name
+arguments, provide only exit status and no output.
.It Fl R Ar dir
Operate within the root directory
.Sq Ar dir
rather than
.Sq / .
+.It Fl s Ar name
+If an
+.Li rc.d
+script of
+.Ar name
+exists
+.Po
+in
+.Dq /etc/rc.d
+or
+.Li local_startup
+directories
+.Pc ,
+process its
+.Dq rc.conf.d
+entries as potential overrides to
+.Sq rc_conf_files .
+See
+.Xr rc.subr 8
+for additional information on
+.Dq rc.conf.d .
+Can be combined with
+.Sq Fl l
+to list configuration files used by service at startup.
.It Fl v
Verbose.
Print the pathname of the specific
@@ -336,6 +394,10 @@ and
.It Pa /etc/defaults/rc.conf
.It Pa /etc/rc.conf
.It Pa /etc/rc.conf.local
+.It Pa /etc/rc.conf.d/name
+.It Pa /etc/rc.conf.d/name/*
+.It Pa /usr/local/etc/rc.conf.d/name
+.It Pa /usr/local/etc/rc.conf.d/name/*
.El
.Sh EXAMPLES
Below are some simple examples of how
@@ -397,6 +459,7 @@ cloned_interfaces+"alternate"
.Sh SEE ALSO
.Xr jls 1 ,
.Xr rc.conf 5 ,
+.Xr rc.subr 8 ,
.Xr jail 8 ,
.Xr jexec 8 ,
.Xr rc 8 ,