summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/Makefile1
-rw-r--r--usr.sbin/Makefile.mips3
-rw-r--r--usr.sbin/acpi/acpidb/Makefile19
-rw-r--r--usr.sbin/acpi/iasl/Makefile32
-rw-r--r--usr.sbin/ancontrol/ancontrol.82
-rw-r--r--usr.sbin/bsdinstall/Makefile6
-rwxr-xr-xusr.sbin/bsdinstall/bsdinstall43
-rw-r--r--usr.sbin/bsdinstall/distextract/Makefile10
-rw-r--r--usr.sbin/bsdinstall/distextract/distextract.c176
-rw-r--r--usr.sbin/bsdinstall/distfetch/Makefile10
-rw-r--r--usr.sbin/bsdinstall/distfetch/distfetch.c187
-rw-r--r--usr.sbin/bsdinstall/partedit/Makefile25
-rw-r--r--usr.sbin/bsdinstall/partedit/diskeditor.c261
-rw-r--r--usr.sbin/bsdinstall/partedit/diskeditor.h47
-rw-r--r--usr.sbin/bsdinstall/partedit/gpart_ops.c1092
-rw-r--r--usr.sbin/bsdinstall/partedit/part_wizard.c344
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit.c445
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit.h80
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_generic.c69
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_pc98.c69
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_powerpc.c63
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_sparc64.c63
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_x86.c79
-rw-r--r--usr.sbin/bsdinstall/scripts/Makefile9
-rwxr-xr-xusr.sbin/bsdinstall/scripts/adduser34
-rwxr-xr-xusr.sbin/bsdinstall/scripts/auto192
-rwxr-xr-xusr.sbin/bsdinstall/scripts/config32
-rwxr-xr-xusr.sbin/bsdinstall/scripts/hostname48
-rwxr-xr-xusr.sbin/bsdinstall/scripts/jail81
-rwxr-xr-xusr.sbin/bsdinstall/scripts/keymap32
-rwxr-xr-xusr.sbin/bsdinstall/scripts/mount55
-rwxr-xr-xusr.sbin/bsdinstall/scripts/netconfig121
-rwxr-xr-xusr.sbin/bsdinstall/scripts/rootpass37
-rwxr-xr-xusr.sbin/bsdinstall/scripts/services53
-rwxr-xr-xusr.sbin/bsdinstall/scripts/time29
-rwxr-xr-xusr.sbin/bsdinstall/scripts/umount42
-rwxr-xr-xusr.sbin/bsdinstall/scripts/wlanconfig137
-rw-r--r--usr.sbin/bsnmpd/bsnmpd/Makefile3
-rw-r--r--usr.sbin/bsnmpd/modules/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_tree.def10
-rwxr-xr-xusr.sbin/bsnmpd/modules/snmp_target/Makefile20
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_wlan/wlan_tree.def2
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/Makefile1
-rw-r--r--usr.sbin/config/config.y4
-rw-r--r--usr.sbin/config/configvers.h2
-rw-r--r--usr.sbin/config/mkmakefile.c2
-rw-r--r--usr.sbin/cpucontrol/cpucontrol.c9
-rw-r--r--usr.sbin/diskinfo/diskinfo.c26
-rw-r--r--usr.sbin/freebsd-update/freebsd-update.sh13
-rw-r--r--usr.sbin/fwcontrol/fwdv.c4
-rw-r--r--usr.sbin/fwcontrol/fwmpegts.c2
-rw-r--r--usr.sbin/gpioctl/gpioctl.84
-rw-r--r--usr.sbin/iostat/iostat.84
-rw-r--r--usr.sbin/iostat/iostat.c4
-rw-r--r--usr.sbin/kbdmap/kbdmap.c2
-rw-r--r--usr.sbin/lmcconfig/Makefile2
-rw-r--r--usr.sbin/lmcconfig/lmcconfig.c496
-rw-r--r--usr.sbin/lpr/common_source/displayq.c4
-rw-r--r--usr.sbin/lpr/common_source/lp.h4
-rw-r--r--usr.sbin/lpr/common_source/lp.local.h4
-rw-r--r--usr.sbin/lpr/common_source/pathnames.h6
-rw-r--r--usr.sbin/lpr/common_source/rmjob.c4
-rw-r--r--usr.sbin/lpr/common_source/startdaemon.c4
-rw-r--r--usr.sbin/lpr/filters/lpf.c4
-rw-r--r--usr.sbin/lpr/lpc/cmds.c4
-rw-r--r--usr.sbin/lpr/lpc/cmdtab.c4
-rw-r--r--usr.sbin/lpr/lpc/extern.h4
-rw-r--r--usr.sbin/lpr/lpc/lpc.84
-rw-r--r--usr.sbin/lpr/lpc/lpc.c4
-rw-r--r--usr.sbin/lpr/lpc/lpc.h4
-rw-r--r--usr.sbin/lpr/lpd/extern.h4
-rw-r--r--usr.sbin/lpr/lpd/lpd.84
-rw-r--r--usr.sbin/lpr/lpd/lpd.c4
-rw-r--r--usr.sbin/lpr/lpd/lpdchar.c4
-rw-r--r--usr.sbin/lpr/lpd/modes.c4
-rw-r--r--usr.sbin/lpr/lpd/printjob.c4
-rw-r--r--usr.sbin/lpr/lpd/recvjob.c4
-rw-r--r--usr.sbin/lpr/lpq/lpq.14
-rw-r--r--usr.sbin/lpr/lpq/lpq.c4
-rw-r--r--usr.sbin/lpr/lpr/lpr.14
-rw-r--r--usr.sbin/lpr/lpr/printcap.54
-rw-r--r--usr.sbin/lpr/lprm/lprm.14
-rw-r--r--usr.sbin/lpr/lprm/lprm.c4
-rw-r--r--usr.sbin/lpr/lptest/lptest.14
-rw-r--r--usr.sbin/lpr/lptest/lptest.c4
-rw-r--r--usr.sbin/lpr/pac/pac.84
-rw-r--r--usr.sbin/lpr/pac/pac.c4
-rw-r--r--usr.sbin/makefs/ffs.c1
-rw-r--r--usr.sbin/makefs/makefs.c1
-rw-r--r--usr.sbin/mld6query/mld6.c10
-rw-r--r--usr.sbin/mountd/mountd.c159
-rw-r--r--usr.sbin/ndp/ndp.c14
-rw-r--r--usr.sbin/newsyslog/newsyslog.83
-rw-r--r--usr.sbin/newsyslog/newsyslog.c216
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.59
-rw-r--r--usr.sbin/newsyslog/pathnames.h9
-rw-r--r--usr.sbin/nfsd/nfsd.c15
-rw-r--r--usr.sbin/ngctl/main.c10
-rw-r--r--usr.sbin/ngctl/msg.c6
-rwxr-xr-xusr.sbin/pc-sysinstall/backend-partmanager/create-part.sh56
-rwxr-xr-xusr.sbin/pc-sysinstall/backend-query/disk-part.sh10
-rwxr-xr-xusr.sbin/pc-sysinstall/backend-query/send-logs.sh4
-rwxr-xr-xusr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh17
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh347
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-cleanup.sh30
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-disk.sh46
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-localize.sh61
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-networking.sh57
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-users.sh13
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions.sh36
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/parseconfig.sh15
-rw-r--r--usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf4
-rw-r--r--usr.sbin/pc-sysinstall/examples/README29
-rwxr-xr-xusr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh2
-rw-r--r--usr.sbin/pkg_install/add/main.c4
-rw-r--r--usr.sbin/portsnap/portsnap/portsnap.sh10
-rw-r--r--usr.sbin/ppp/bundle.c4
-rw-r--r--usr.sbin/ppp/command.c20
-rw-r--r--usr.sbin/ppp/iface.c128
-rw-r--r--usr.sbin/ppp/iface.h4
-rw-r--r--usr.sbin/ppp/log.c25
-rw-r--r--usr.sbin/ppp/log.h2
-rw-r--r--usr.sbin/ppp/main.c11
-rw-r--r--usr.sbin/ppp/ppp.8.m47
-rw-r--r--usr.sbin/pw/pw_user.c10
-rw-r--r--usr.sbin/quot/quot.c2
-rw-r--r--usr.sbin/rpc.lockd/Makefile2
-rw-r--r--usr.sbin/rpc.lockd/lockd.c5
-rw-r--r--usr.sbin/rpc.lockd/lockd_lock.c3
-rw-r--r--usr.sbin/rtadvd/Makefile3
-rw-r--r--usr.sbin/rtadvd/rtadvd.824
-rw-r--r--usr.sbin/rtadvd/rtadvd.c39
-rw-r--r--usr.sbin/rtprio/rtprio.c50
-rw-r--r--usr.sbin/sade/Makefile6
-rw-r--r--usr.sbin/spkrtest/spkrtest.sh2
-rw-r--r--usr.sbin/sysinstall/Makefile6
-rw-r--r--usr.sbin/sysinstall/devices.c2
-rw-r--r--usr.sbin/sysinstall/install.c11
-rw-r--r--usr.sbin/sysinstall/media.c2
-rw-r--r--usr.sbin/sysinstall/menus.c29
-rw-r--r--usr.sbin/syslogd/syslogd.c5
-rw-r--r--usr.sbin/timed/timed/acksend.c4
-rw-r--r--usr.sbin/timed/timed/byteorder.c4
-rw-r--r--usr.sbin/timed/timed/candidate.c4
-rw-r--r--usr.sbin/timed/timed/cksum.c4
-rw-r--r--usr.sbin/timed/timed/correct.c4
-rw-r--r--usr.sbin/timed/timed/extern.h4
-rw-r--r--usr.sbin/timed/timed/globals.h4
-rw-r--r--usr.sbin/timed/timed/master.c4
-rw-r--r--usr.sbin/timed/timed/measure.c4
-rw-r--r--usr.sbin/timed/timed/networkdelta.c4
-rw-r--r--usr.sbin/timed/timed/pathnames.h4
-rw-r--r--usr.sbin/timed/timed/readmsg.c4
-rw-r--r--usr.sbin/timed/timed/slave.c4
-rw-r--r--usr.sbin/timed/timed/timed.84
-rw-r--r--usr.sbin/timed/timed/timed.c4
-rw-r--r--usr.sbin/timed/timedc/cmds.c4
-rw-r--r--usr.sbin/timed/timedc/cmdtab.c4
-rw-r--r--usr.sbin/timed/timedc/extern.h4
-rw-r--r--usr.sbin/timed/timedc/timedc.84
-rw-r--r--usr.sbin/timed/timedc/timedc.c4
-rw-r--r--usr.sbin/timed/timedc/timedc.h4
-rw-r--r--usr.sbin/traceroute6/traceroute6.c4
-rw-r--r--usr.sbin/tzsetup/Makefile6
-rw-r--r--usr.sbin/uathload/Makefile4
-rw-r--r--usr.sbin/usbdump/usbdump.877
-rw-r--r--usr.sbin/usbdump/usbdump.c11
-rw-r--r--usr.sbin/wpa/hostapd/driver_freebsd.c652
168 files changed, 5603 insertions, 1592 deletions
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index f3e853e..6209cb5 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -7,6 +7,7 @@ SUBDIR= adduser \
arp \
bootparamd \
burncd \
+ bsdinstall \
cdcontrol \
chkgrp \
chown \
diff --git a/usr.sbin/Makefile.mips b/usr.sbin/Makefile.mips
index 4d30e12..a946f3e 100644
--- a/usr.sbin/Makefile.mips
+++ b/usr.sbin/Makefile.mips
@@ -1,6 +1,7 @@
# $FreeBSD$
SUBDIR:= ${SUBDIR:Nsysinstall}
-.if defined(TARGET_ABI) && ${TARGET_ABI} == "n64"
+# uathload broken for n32 and n64 due to toolchain issues
+.if ${MACHINE_ARCH:Mmipse[lb]} == ""
SUBDIR:= ${SUBDIR:Nuathload}
.endif
diff --git a/usr.sbin/acpi/acpidb/Makefile b/usr.sbin/acpi/acpidb/Makefile
index 3ff837f..0bfb492 100644
--- a/usr.sbin/acpi/acpidb/Makefile
+++ b/usr.sbin/acpi/acpidb/Makefile
@@ -6,7 +6,8 @@ SRCS+= osunixxf.c
# debugger
SRCS+= dbcmds.c dbdisply.c dbexec.c dbfileio.c dbhistry.c \
- dbinput.c dbstats.c dbutils.c dbxface.c
+ dbinput.c dbmethod.c dbnames.c dbstats.c dbutils.c \
+ dbxface.c
# disassembler
SRCS+= dmbuffer.c dmnames.c dmobject.c dmopcode.c dmresrc.c \
@@ -15,16 +16,16 @@ SRCS+= dmbuffer.c dmnames.c dmobject.c dmopcode.c dmresrc.c \
# events
SRCS+= evevent.c evgpe.c evgpeblk.c evgpeinit.c evgpeutil.c \
evmisc.c evregion.c evrgnini.c evsci.c evxface.c \
- evxfevnt.c evxfregn.c
+ evxfevnt.c evxfgpe.c evxfregn.c
# hardware
SRCS+= hwacpi.c hwgpe.c hwpci.c hwregs.c hwsleep.c hwvalid.c \
hwxface.c
# interpreter/dispatcher
-SRCS+= dsfield.c dsinit.c dsmethod.c dsmthdat.c dsobject.c \
- dsopcode.c dsutils.c dswexec.c dswload.c dswscope.c \
- dswstate.c
+SRCS+= dsargs.c dscontrol.c dsfield.c dsinit.c dsmethod.c \
+ dsmthdat.c dsobject.c dsopcode.c dsutils.c dswexec.c \
+ dswload.c dswload2.c dswscope.c dswstate.c
# interpreter/executer
SRCS+= exconfig.c exconvrt.c excreate.c exdebug.c exdump.c \
@@ -53,10 +54,10 @@ SRCS+= tbfadt.c tbfind.c tbinstal.c tbutils.c tbxface.c \
tbxfroot.c
# utilities
-SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdelete.c \
- uteval.c utglobal.c utids.c utinit.c utlock.c utmath.c \
- utmisc.c utmutex.c utobject.c utosi.c utresrc.c \
- utstate.c uttrack.c utxface.c utxferror.c
+SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdecode.c \
+ utdelete.c uteval.c utglobal.c utids.c utinit.c \
+ utlock.c utmath.c utmisc.c utmutex.c utobject.c utosi.c \
+ utresrc.c utstate.c uttrack.c utxface.c utxferror.c
MAN= acpidb.8
WARNS?= 2
diff --git a/usr.sbin/acpi/iasl/Makefile b/usr.sbin/acpi/iasl/Makefile
index 76999fa..f91cbc8 100644
--- a/usr.sbin/acpi/iasl/Makefile
+++ b/usr.sbin/acpi/iasl/Makefile
@@ -9,15 +9,16 @@ SRCS+= dmextern.c dmrestag.c dmtable.c dmtbdump.c dmtbinfo.c \
getopt.c
# compiler
-SRCS+= aslanalyze.c aslcodegen.c aslcompile.c aslcompiler.y.h \
- aslcompilerlex.l aslcompilerparse.y aslerror.c \
- aslfiles.c aslfold.c asllength.c asllisting.c \
- aslload.c asllookup.c aslmain.c aslmap.c aslopcodes.c \
- asloperands.c aslopt.c aslpredef.c aslresource.c \
- aslrestype1.c aslrestype1i.c aslrestype2.c \
- aslrestype2d.c aslrestype2e.c aslrestype2q.c \
- aslrestype2w.c aslstartup.c aslstubs.c asltransform.c \
- asltree.c aslutils.c dtcompile.c dtfield.c dtio.c \
+SRCS+= aslanalyze.c aslbtypes.c aslcodegen.c aslcompile.c \
+ aslcompiler.y.h aslcompilerlex.l aslcompilerparse.y \
+ aslerror.c aslfiles.c aslfold.c asllength.c \
+ asllisting.c aslload.c asllookup.c aslmain.c aslmap.c \
+ aslopcodes.c asloperands.c aslopt.c aslpredef.c \
+ aslresource.c aslrestype1.c aslrestype1i.c \
+ aslrestype2.c aslrestype2d.c aslrestype2e.c \
+ aslrestype2q.c aslrestype2w.c aslstartup.c aslstubs.c \
+ asltransform.c asltree.c aslutils.c asluuid.c \
+ aslwalks.c dtcompile.c dtexpress.c dtfield.c dtio.c \
dtsubtable.c dttable.c dttemplate.c dtutils.c
# debugger
@@ -28,8 +29,9 @@ SRCS+= dmbuffer.c dmnames.c dmobject.c dmopcode.c dmresrc.c \
dmresrcl.c dmresrcs.c dmutils.c dmwalk.c
# interpreter/dispatcher
-SRCS+= dsfield.c dsobject.c dsopcode.c dsutils.c dswexec.c \
- dswload.c dswscope.c dswstate.c
+SRCS+= dsargs.c dscontrol.c dsfield.c dsobject.c dsopcode.c \
+ dsutils.c dswexec.c dswload.c dswload2.c dswscope.c \
+ dswstate.c
# interpreter/executer
SRCS+= exconvrt.c excreate.c exdump.c exmisc.c exmutex.c \
@@ -49,10 +51,10 @@ SRCS+= nsaccess.c nsalloc.c nsdump.c nsnames.c nsobject.c \
SRCS+= tbfadt.c tbinstal.c tbutils.c tbxface.c
# utilities
-SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdelete.c \
- utglobal.c utinit.c utlock.c utmath.c utmisc.c \
- utmutex.c utobject.c utosi.c utresrc.c utstate.c \
- utxface.c utxferror.c
+SRCS+= utalloc.c utcache.c utcopy.c utdebug.c utdecode.c \
+ utdelete.c utglobal.c utinit.c utlock.c utmath.c \
+ utmisc.c utmutex.c utobject.c utosi.c utresrc.c \
+ utstate.c utxface.c utxferror.c
WARNS?= 2
diff --git a/usr.sbin/ancontrol/ancontrol.8 b/usr.sbin/ancontrol/ancontrol.8
index 13da6ab..5ce4377 100644
--- a/usr.sbin/ancontrol/ancontrol.8
+++ b/usr.sbin/ancontrol/ancontrol.8
@@ -308,7 +308,7 @@ Set a WEP key.
For 40 bit prefix 10 hex character with 0x.
For 128 bit prefix 26 hex character with 0x.
Use
-.Qq \&
+.Qq
as the key to erase the key.
Supports 4 keys; even numbers are for permanent keys
and odd number are for temporary keys.
diff --git a/usr.sbin/bsdinstall/Makefile b/usr.sbin/bsdinstall/Makefile
new file mode 100644
index 0000000..5e39b0b
--- /dev/null
+++ b/usr.sbin/bsdinstall/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+SUBDIR= distextract distfetch partedit scripts
+SCRIPTS= bsdinstall
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdinstall/bsdinstall b/usr.sbin/bsdinstall/bsdinstall
new file mode 100755
index 0000000..04162c8
--- /dev/null
+++ b/usr.sbin/bsdinstall/bsdinstall
@@ -0,0 +1,43 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+: ${DISTRIBUTIONS="kernel.tgz world.tgz"}; export DISTRIBUTIONS
+: ${BSDINSTALL_LOG="/tmp/bsdinstall_log"}; export BSDINSTALL_LOG
+: ${BSDINSTALL_TMPETC="/tmp/bsdinstall_etc"}; export BSDINSTALL_TMPETC
+: ${PATH_FSTAB="$BSDINSTALL_TMPETC/fstab"}; export PATH_FSTAB
+: ${BSDINSTALL_DISTDIR="/usr/freebsd-dist"}; export BSDINSTALL_DISTDIR
+: ${BSDINSTALL_CHROOT="/mnt"}; export BSDINSTALL_CHROOT
+
+VERB=$1; shift
+
+if [ -z $VERB ]; then
+ VERB=auto
+fi
+
+exec /usr/libexec/bsdinstall/$VERB $@
+
diff --git a/usr.sbin/bsdinstall/distextract/Makefile b/usr.sbin/bsdinstall/distextract/Makefile
new file mode 100644
index 0000000..3ad1f98
--- /dev/null
+++ b/usr.sbin/bsdinstall/distextract/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+BINDIR= /usr/libexec/bsdinstall
+PROG= distextract
+LDADD= -larchive -lncursesw -ldialog -lm
+
+WARNS?= 6
+NO_MAN= true
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdinstall/distextract/distextract.c b/usr.sbin/bsdinstall/distextract/distextract.c
new file mode 100644
index 0000000..efd9a1b
--- /dev/null
+++ b/usr.sbin/bsdinstall/distextract/distextract.c
@@ -0,0 +1,176 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <limits.h>
+#include <archive.h>
+#include <dialog.h>
+
+static int extract_files(int nfiles, const char **files);
+
+int
+main(void)
+{
+ char *diststring = strdup(getenv("DISTRIBUTIONS"));
+ const char **dists;
+ int i, retval, ndists = 0;
+ for (i = 0; diststring[i] != 0; i++)
+ if (isspace(diststring[i]) && !isspace(diststring[i+1]))
+ ndists++;
+ ndists++; /* Last one */
+
+ dists = calloc(ndists, sizeof(const char *));
+ for (i = 0; i < ndists; i++)
+ dists[i] = strsep(&diststring, " \t");
+
+ chdir(getenv("BSDINSTALL_CHROOT"));
+ retval = extract_files(ndists, dists);
+
+ free(diststring);
+ free(dists);
+
+ return (retval);
+}
+
+static int
+extract_files(int nfiles, const char **files)
+{
+ const char *items[nfiles*2];
+ char path[PATH_MAX];
+ int archive_files[nfiles];
+ int total_files, current_files, archive_file;
+ struct archive *archive;
+ struct archive_entry *entry;
+ char errormsg[512];
+ char status[8];
+ int i, err, progress, last_progress;
+
+ err = 0;
+ progress = 0;
+
+ /* Make the transfer list for dialog */
+ for (i = 0; i < nfiles; i++) {
+ items[i*2] = strrchr(files[i], '/');
+ if (items[i*2] != NULL)
+ items[i*2]++;
+ else
+ items[i*2] = files[i];
+ items[i*2 + 1] = "Pending";
+ }
+
+ init_dialog(stdin, stdout);
+ dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer");
+ dlg_put_backtitle();
+ dialog_msgbox("",
+ "Checking distribution archives.\nPlease wait...", 0, 0, FALSE);
+
+ /* Open all the archives */
+ total_files = 0;
+ for (i = 0; i < nfiles; i++) {
+ archive = archive_read_new();
+ archive_read_support_format_all(archive);
+ archive_read_support_compression_all(archive);
+ sprintf(path, "%s/%s", getenv("BSDINSTALL_DISTDIR"), files[i]);
+ err = archive_read_open_filename(archive, path, 4096);
+ if (err != ARCHIVE_OK) {
+ snprintf(errormsg, sizeof(errormsg),
+ "Error while extracting %s: %s\n", items[i*2],
+ archive_error_string(archive));
+ items[i*2 + 1] = "Failed";
+ dialog_msgbox("Extract Error", errormsg, 0, 0,
+ TRUE);
+ goto exit;
+ }
+ archive_files[i] = 0;
+ while (archive_read_next_header(archive, &entry) == ARCHIVE_OK)
+ archive_files[i]++;
+ total_files += archive_files[i];
+ archive_read_free(archive);
+ }
+
+ current_files = 0;
+
+ for (i = 0; i < nfiles; i++) {
+ archive = archive_read_new();
+ archive_read_support_format_all(archive);
+ archive_read_support_compression_all(archive);
+ sprintf(path, "%s/%s", getenv("BSDINSTALL_DISTDIR"), files[i]);
+ err = archive_read_open_filename(archive, path, 4096);
+
+ items[i*2 + 1] = "In Progress";
+ archive_file = 0;
+
+ while ((err = archive_read_next_header(archive, &entry)) ==
+ ARCHIVE_OK) {
+ last_progress = progress;
+ progress = (current_files*100)/total_files;
+
+ sprintf(status, "-%d",
+ (archive_file*100)/archive_files[i]);
+ items[i*2 + 1] = status;
+
+ if (progress > last_progress)
+ dialog_mixedgauge("Archive Extraction",
+ "Extracting distribution files...", 0, 0,
+ progress, nfiles,
+ __DECONST(char **, items));
+
+ err = archive_read_extract(archive, entry,
+ ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_OWNER |
+ ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL |
+ ARCHIVE_EXTRACT_XATTR | ARCHIVE_EXTRACT_FFLAGS);
+
+ if (err != ARCHIVE_OK)
+ break;
+
+ archive_file++;
+ current_files++;
+ }
+
+ items[i*2 + 1] = "Done";
+
+ if (err != ARCHIVE_EOF) {
+ snprintf(errormsg, sizeof(errormsg),
+ "Error while extracting %s: %s\n", items[i*2],
+ archive_error_string(archive));
+ items[i*2 + 1] = "Failed";
+ dialog_msgbox("Extract Error", errormsg, 0, 0,
+ TRUE);
+ goto exit;
+ }
+
+ archive_read_free(archive);
+ }
+
+ err = 0;
+exit:
+ end_dialog();
+
+ return (err);
+}
diff --git a/usr.sbin/bsdinstall/distfetch/Makefile b/usr.sbin/bsdinstall/distfetch/Makefile
new file mode 100644
index 0000000..5a449ac1
--- /dev/null
+++ b/usr.sbin/bsdinstall/distfetch/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+BINDIR= /usr/libexec/bsdinstall
+PROG= distfetch
+LDADD= -lfetch -lncursesw -ldialog -lm
+
+WARNS?= 6
+NO_MAN= true
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdinstall/distfetch/distfetch.c b/usr.sbin/bsdinstall/distfetch/distfetch.c
new file mode 100644
index 0000000..2e1d1b3
--- /dev/null
+++ b/usr.sbin/bsdinstall/distfetch/distfetch.c
@@ -0,0 +1,187 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fetch.h>
+#include <dialog.h>
+
+static int fetch_files(int nfiles, char **urls);
+
+int
+main(void)
+{
+ char *diststring = strdup(getenv("DISTRIBUTIONS"));
+ char **urls;
+ int i, nfetched, ndists = 0;
+ for (i = 0; diststring[i] != 0; i++)
+ if (isspace(diststring[i]) && !isspace(diststring[i+1]))
+ ndists++;
+ ndists++; /* Last one */
+
+ urls = calloc(ndists, sizeof(const char *));
+ for (i = 0; i < ndists; i++) {
+ urls[i] = malloc(PATH_MAX);
+ sprintf(urls[i], "%s/%s", getenv("BSDINSTALL_DISTSITE"),
+ strsep(&diststring, " \t"));
+ }
+
+ chdir(getenv("BSDINSTALL_DISTDIR"));
+ nfetched = fetch_files(ndists, urls);
+
+ free(diststring);
+ for (i = 0; i < ndists; i++)
+ free(urls[i]);
+ free(urls);
+
+ return ((nfetched == ndists) ? 0 : 1);
+}
+
+static int
+fetch_files(int nfiles, char **urls)
+{
+ const char **items;
+ FILE *fetch_out, *file_out;
+ struct url_stat ustat;
+ off_t total_bytes, current_bytes, fsize;
+ char status[8];
+ char errormsg[512];
+ uint8_t block[4096];
+ size_t chunk;
+ int i, progress, last_progress;
+ int nsuccess = 0; /* Number of files successfully downloaded */
+
+ progress = 0;
+
+ /* Make the transfer list for dialog */
+ items = calloc(sizeof(char *), nfiles * 2);
+ for (i = 0; i < nfiles; i++) {
+ items[i*2] = strrchr(urls[i], '/');
+ if (items[i*2] != NULL)
+ items[i*2]++;
+ else
+ items[i*2] = urls[i];
+ items[i*2 + 1] = "Pending";
+ }
+
+ init_dialog(stdin, stdout);
+ dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer");
+ dlg_put_backtitle();
+
+ dialog_msgbox("", "Connecting to server.\nPlease wait...", 0, 0, FALSE);
+
+ /* Try to stat all the files */
+ total_bytes = 0;
+ for (i = 0; i < nfiles; i++) {
+ if (fetchStatURL(urls[i], &ustat, "") == 0 && ustat.size > 0)
+ total_bytes += ustat.size;
+ }
+
+ current_bytes = 0;
+ for (i = 0; i < nfiles; i++) {
+ last_progress = progress;
+ if (total_bytes == 0)
+ progress = (i*100)/nfiles;
+
+ fetchLastErrCode = 0;
+ fetch_out = fetchXGetURL(urls[i], &ustat, "");
+ if (fetch_out == NULL) {
+ snprintf(errormsg, sizeof(errormsg),
+ "Error while fetching %s: %s\n", urls[i],
+ fetchLastErrString);
+ items[i*2 + 1] = "Failed";
+ dialog_msgbox("Fetch Error", errormsg, 0, 0,
+ TRUE);
+ continue;
+ }
+
+ items[i*2 + 1] = "In Progress";
+ fsize = 0;
+ file_out = fopen(items[i*2], "w+");
+ if (file_out == NULL) {
+ snprintf(errormsg, sizeof(errormsg),
+ "Error while fetching %s: %s\n",
+ urls[i], strerror(errno));
+ items[i*2 + 1] = "Failed";
+ dialog_msgbox("Fetch Error", errormsg, 0, 0,
+ TRUE);
+ fclose(fetch_out);
+ continue;
+ }
+
+ while ((chunk = fread(block, 1, sizeof(block), fetch_out))
+ > 0) {
+ if (fwrite(block, 1, chunk, file_out) < chunk)
+ break;
+
+ current_bytes += chunk;
+ fsize += chunk;
+
+ if (total_bytes > 0) {
+ last_progress = progress;
+ progress = (current_bytes*100)/total_bytes;
+ }
+
+ if (ustat.size > 0) {
+ sprintf(status, "-%jd", (fsize*100)/ustat.size);
+ items[i*2 + 1] = status;
+ }
+
+ if (progress > last_progress)
+ dialog_mixedgauge("Fetching Distribution",
+ "Fetching distribution files...", 0, 0,
+ progress, nfiles,
+ __DECONST(char **, items));
+ }
+
+ if (ustat.size > 0 && fsize < ustat.size) {
+ if (fetchLastErrCode == 0)
+ snprintf(errormsg, sizeof(errormsg),
+ "Error while fetching %s: %s\n",
+ urls[i], strerror(errno));
+ else
+ snprintf(errormsg, sizeof(errormsg),
+ "Error while fetching %s: %s\n",
+ urls[i], fetchLastErrString);
+ items[i*2 + 1] = "Failed";
+ dialog_msgbox("Fetch Error", errormsg, 0, 0,
+ TRUE);
+ } else {
+ items[i*2 + 1] = "Done";
+ nsuccess++;
+ }
+
+ fclose(fetch_out);
+ fclose(file_out);
+ }
+ end_dialog();
+
+ free(items);
+ return (nsuccess);
+}
diff --git a/usr.sbin/bsdinstall/partedit/Makefile b/usr.sbin/bsdinstall/partedit/Makefile
new file mode 100644
index 0000000..80d89cc
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/Makefile
@@ -0,0 +1,25 @@
+# $FreeBSD$
+
+BINDIR= /usr/libexec/bsdinstall
+PROG= partedit
+LINKS= ${BINDIR}/partedit ${BINDIR}/autopart
+LDADD= -lgeom -lncursesw -lutil -ldialog -lm
+
+PARTEDIT_ARCH= ${MACHINE}
+.if ${MACHINE} == "i386" || ${MACHINE} == "amd64"
+PARTEDIT_ARCH= x86
+.endif
+.if ${MACHINE} == "sun4v"
+PARTEDIT_ARCH= sparc64
+.endif
+.if !exists(partedit_${PARTEDIT_ARCH}.c)
+PARTEDIT_ARCH= generic
+.endif
+
+SRCS= diskeditor.c partedit.c gpart_ops.c partedit_${PARTEDIT_ARCH}.c \
+ part_wizard.c
+
+WARNS?= 3
+NO_MAN= true
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdinstall/partedit/diskeditor.c b/usr.sbin/bsdinstall/partedit/diskeditor.c
new file mode 100644
index 0000000..c97b003
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/diskeditor.c
@@ -0,0 +1,261 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <libutil.h>
+#include <dialog.h>
+#include <dlg_keys.h>
+
+#include "diskeditor.h"
+
+static void
+print_partedit_item(WINDOW *partitions, struct partedit_item *items,
+ int item, int nscroll, int selected)
+{
+ chtype attr = A_NORMAL;
+ char sizetext[16];
+ int y = item - nscroll + 1;
+
+ wattrset(partitions, selected ? item_selected_attr : item_attr);
+ wmove(partitions, y, MARGIN + items[item].indentation*2);
+ dlg_print_text(partitions, items[item].name, 8, &attr);
+ wmove(partitions, y, 15);
+ wattrset(partitions, item_attr);
+
+ humanize_number(sizetext, 7, items[item].size, "B", HN_AUTOSCALE,
+ HN_DECIMAL);
+ dlg_print_text(partitions, sizetext, 8, &attr);
+ wmove(partitions, y, 25);
+ dlg_print_text(partitions, items[item].type, 15, &attr);
+ wmove(partitions, y, 40);
+ if (items[item].mountpoint != NULL)
+ dlg_print_text(partitions, items[item].mountpoint, 8, &attr);
+}
+
+int
+diskeditor_show(const char *title, const char *cprompt,
+ struct partedit_item *items, int nitems, int *selected, int *nscroll)
+{
+ WINDOW *dialog, *partitions;
+ char *prompt;
+ const char *buttons[] =
+ { "Create", "Delete", "Modify", "Revert", "Auto", "Exit", NULL };
+ int x, y;
+ int i;
+ int height, width, min_width;
+ int partlist_height, partlist_width, min_partlist_width;
+ int cur_scroll = 0;
+ int key, fkey;
+ int cur_button = 0, cur_part = 0;
+ int result = DLG_EXIT_UNKNOWN;
+
+ static DLG_KEYS_BINDING binding[] = {
+ ENTERKEY_BINDINGS,
+ DLG_KEYS_DATA( DLGK_ENTER, ' ' ),
+ DLG_KEYS_DATA( DLGK_ITEM_NEXT, KEY_DOWN ),
+ DLG_KEYS_DATA( DLGK_ITEM_PREV, KEY_UP ),
+ DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_RIGHT ),
+ DLG_KEYS_DATA( DLGK_FIELD_NEXT, TAB ),
+ DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_BTAB ),
+ DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_LEFT ),
+
+ SCROLLKEY_BINDINGS,
+ END_KEYS_BINDING
+ };
+
+ /*
+ * Set up editor window.
+ */
+ prompt = dlg_strclone(cprompt);
+
+ min_width = 50;
+ height = width = 0;
+ partlist_height = 10;
+ min_partlist_width = 0;
+ dlg_tab_correct_str(prompt);
+ dlg_button_layout(buttons, &min_width);
+ dlg_auto_size(title, prompt, &height, &width, 2, min_width);
+ height += partlist_height;
+ partlist_width = width - 2*MARGIN;
+ dlg_print_size(height, width);
+ dlg_ctl_size(height, width);
+
+ x = dlg_box_x_ordinate(width);
+ y = dlg_box_y_ordinate(height);
+
+ dialog = dlg_new_window(height, width, y, x);
+ dlg_register_window(dialog, "diskeditorbox", binding);
+ dlg_register_buttons(dialog, "diskeditorbox", buttons);
+
+ dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
+ dlg_draw_bottom_box(dialog);
+ dlg_draw_title(dialog, title);
+ wattrset(dialog, dialog_attr);
+
+ /* Partition list sub-window */
+ partitions = dlg_sub_window(dialog, partlist_height, partlist_width,
+ y + 3, x + 1);
+ dlg_register_window(partitions, "partlist", binding);
+ dlg_register_buttons(partitions, "partlist", buttons);
+ wattrset(partitions, menubox_attr);
+
+ dlg_draw_buttons(dialog, height - 2*MARGIN, 0, buttons,
+ cur_button, FALSE, width);
+ dlg_print_autowrap(dialog, prompt, height, width);
+
+ if (selected != NULL)
+ cur_part = *selected;
+ if (nscroll != NULL)
+ cur_scroll = *nscroll;
+ if (cur_part - cur_scroll >= partlist_height - 2 ||
+ cur_part - cur_scroll < 0)
+ cur_scroll = cur_part;
+
+repaint:
+ dlg_draw_box(dialog, 3, 1, partlist_height, partlist_width,
+ menubox_border_attr, menubox_attr);
+ for (i = cur_scroll; i < MIN(cur_scroll + partlist_height - 2, nitems);
+ i++)
+ print_partedit_item(partitions, items, i, cur_scroll,
+ i == cur_part);
+ if (nitems > partlist_height - 2)
+ dlg_draw_arrows(partitions, cur_scroll > 0,
+ nitems > cur_scroll + partlist_height - 2,
+ partlist_width - 5, 0, partlist_height - 1);
+ wrefresh(partitions);
+
+ while (result == DLG_EXIT_UNKNOWN) {
+ key = dlg_mouse_wgetch(dialog, &fkey);
+ if ((i = dlg_char_to_button(key, buttons)) >= 0) {
+ cur_button = i;
+ dlg_draw_buttons(dialog, height - 2*MARGIN, 0, buttons,
+ cur_button, FALSE, width);
+ break;
+ }
+
+ if (!fkey)
+ continue;
+
+ switch (key) {
+ case DLGK_FIELD_NEXT:
+ cur_button = dlg_next_button(buttons, cur_button);
+ if (cur_button < 0)
+ cur_button = 0;
+ dlg_draw_buttons(dialog, height - 2*MARGIN, 0, buttons,
+ cur_button, FALSE, width);
+ break;
+ case DLGK_FIELD_PREV:
+ cur_button = dlg_prev_button(buttons, cur_button);
+ if (cur_button < 0)
+ cur_button = 0;
+ dlg_draw_buttons(dialog, height - 2*MARGIN, 0, buttons,
+ cur_button, FALSE, width);
+ break;
+ case DLGK_ITEM_NEXT:
+ if (cur_part == nitems - 1)
+ break; /* End of list */
+
+ /* Deselect old item */
+ print_partedit_item(partitions, items, cur_part,
+ cur_scroll, 0);
+ /* Select new item */
+ cur_part++;
+ if (cur_part - cur_scroll >= partlist_height - 2) {
+ cur_scroll = cur_part;
+ goto repaint;
+ }
+ print_partedit_item(partitions, items, cur_part,
+ cur_scroll, 1);
+ wrefresh(partitions);
+ break;
+ case DLGK_ITEM_PREV:
+ if (cur_part == 0)
+ break; /* Start of list */
+
+ /* Deselect old item */
+ print_partedit_item(partitions, items, cur_part,
+ cur_scroll, 0);
+ /* Select new item */
+ cur_part--;
+ if (cur_part - cur_scroll < 0) {
+ cur_scroll = cur_part;
+ goto repaint;
+ }
+ print_partedit_item(partitions, items, cur_part,
+ cur_scroll, 1);
+ wrefresh(partitions);
+ break;
+ case DLGK_PAGE_NEXT:
+ cur_scroll += (partlist_height - 2);
+ if (cur_scroll + partlist_height - 2 >= nitems)
+ cur_scroll = nitems - (partlist_height - 2);
+ if (cur_part < cur_scroll)
+ cur_part = cur_scroll;
+ goto repaint;
+ case DLGK_PAGE_PREV:
+ cur_scroll -= (partlist_height - 2);
+ if (cur_scroll < 0)
+ cur_scroll = 0;
+ if (cur_part >= cur_scroll + partlist_height - 2)
+ cur_part = cur_scroll;
+ goto repaint;
+ case DLGK_PAGE_FIRST:
+ cur_scroll = 0;
+ cur_part = cur_scroll;
+ goto repaint;
+ case DLGK_PAGE_LAST:
+ cur_scroll = nitems - (partlist_height - 2);
+ cur_part = cur_scroll;
+ goto repaint;
+ case DLGK_ENTER:
+ goto done;
+ default:
+ if (is_DLGK_MOUSE(key)) {
+ cur_button = key - M_EVENT;
+ dlg_draw_buttons(dialog, height - 2*MARGIN, 0,
+ buttons, cur_button, FALSE, width);
+ goto done;
+ }
+ break;
+ }
+ }
+
+done:
+ if (selected != NULL)
+ *selected = cur_part;
+ if (nscroll != NULL)
+ *nscroll = cur_scroll;
+
+ dlg_del_window(partitions);
+ dlg_del_window(dialog);
+ dlg_mouse_free_regions();
+
+ return (cur_button);
+}
+
diff --git a/usr.sbin/bsdinstall/partedit/diskeditor.h b/usr.sbin/bsdinstall/partedit/diskeditor.h
new file mode 100644
index 0000000..f122267
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/diskeditor.h
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _PARTEDIT_DISKEDITOR_H
+#define _PARTEDIT_DISKEDITOR_H
+
+#include <inttypes.h>
+
+struct partedit_item {
+ int indentation;
+ const char *name;
+ intmax_t size;
+ const char *type;
+ char *mountpoint;
+
+ void *cookie;
+};
+
+int diskeditor_show(const char *title, const char *prompt,
+ struct partedit_item *items, int nitems, int *selected, int *scroll);
+
+#endif
diff --git a/usr.sbin/bsdinstall/partedit/gpart_ops.c b/usr.sbin/bsdinstall/partedit/gpart_ops.c
new file mode 100644
index 0000000..f6fcc08
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/gpart_ops.c
@@ -0,0 +1,1092 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <errno.h>
+#include <libutil.h>
+#include <inttypes.h>
+
+#include <libgeom.h>
+#include <dialog.h>
+#include <dlg_keys.h>
+
+#include "partedit.h"
+
+#define GPART_FLAGS "x" /* Do not commit changes by default */
+
+static void
+gpart_show_error(const char *title, const char *explanation, const char *errstr)
+{
+ char *errmsg;
+ char message[512];
+ int error;
+
+ if (explanation == NULL)
+ explanation = "";
+
+ error = strtol(errstr, &errmsg, 0);
+ if (errmsg != errstr) {
+ while (errmsg[0] == ' ')
+ errmsg++;
+ if (errmsg[0] != '\0')
+ sprintf(message, "%s%s. %s", explanation,
+ strerror(error), errmsg);
+ else
+ sprintf(message, "%s%s", explanation, strerror(error));
+ } else {
+ sprintf(message, "%s%s", explanation, errmsg);
+ }
+
+ dialog_msgbox(title, message, 0, 0, TRUE);
+}
+
+int
+gpart_partition(const char *lg_name, const char *scheme)
+{
+ int cancel, choice;
+ struct gctl_req *r;
+ const char *errstr;
+
+ DIALOG_LISTITEM items[] = {
+ {"APM", "Apple Partition Map",
+ "Bootable on PowerPC Apple Hardware", 0 },
+ {"BSD", "BSD Labels",
+ "Bootable on most x86 systems", 0 },
+ {"GPT", "GUID Partition Table",
+ "Bootable on most x86 systems", 0 },
+ {"MBR", "DOS Partitions",
+ "Bootable on most x86 systems", 0 },
+ {"PC98", "NEC PC9801 Partition Table",
+ "Bootable on NEC PC9801 systems", 0 },
+ {"VTOC8", "Sun VTOC8 Partition Table",
+ "Bootable on Sun SPARC systems", 0 },
+ };
+
+schememenu:
+ if (scheme == NULL) {
+ dialog_vars.default_item = __DECONST(char *, default_scheme());
+ cancel = dlg_menu("Partition Scheme",
+ "Select a partition scheme for this volume:", 0, 0, 0,
+ sizeof(items) / sizeof(items[0]), items, &choice, NULL);
+ dialog_vars.default_item = NULL;
+
+ if (cancel)
+ return (-1);
+
+ if (!is_scheme_bootable(items[choice].name)) {
+ char message[512];
+ sprintf(message, "This partition scheme (%s) is not "
+ "bootable on this platform. Are you sure you want "
+ "to proceed?", items[choice].name);
+ dialog_vars.defaultno = TRUE;
+ cancel = dialog_yesno("Warning", message, 0, 0);
+ dialog_vars.defaultno = FALSE;
+ if (cancel) /* cancel */
+ goto schememenu;
+ }
+
+ scheme = items[choice].name;
+ }
+
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ gctl_ro_param(r, "arg0", -1, lg_name);
+ gctl_ro_param(r, "flags", -1, GPART_FLAGS);
+ gctl_ro_param(r, "scheme", -1, scheme);
+ gctl_ro_param(r, "verb", -1, "create");
+
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0') {
+ gpart_show_error("Error", NULL, errstr);
+ gctl_free(r);
+ scheme = NULL;
+ goto schememenu;
+ }
+ gctl_free(r);
+
+ if (bootcode_path(scheme) != NULL)
+ get_part_metadata(lg_name, 1)->bootcode = 1;
+ return (0);
+}
+
+static void
+gpart_activate(struct gprovider *pp)
+{
+ struct gconfig *gc;
+ struct gctl_req *r;
+ const char *errstr, *scheme;
+ const char *attribute = NULL;
+ intmax_t idx;
+
+ /*
+ * Some partition schemes need this partition to be marked 'active'
+ * for it to be bootable.
+ */
+ LIST_FOREACH(gc, &pp->lg_geom->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "scheme") == 0) {
+ scheme = gc->lg_val;
+ break;
+ }
+ }
+
+ if (strcmp(scheme, "MBR") == 0 || strcmp(scheme, "EBR") == 0 ||
+ strcmp(scheme, "PC98") == 0)
+ attribute = "active";
+ else
+ return;
+
+ LIST_FOREACH(gc, &pp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "index") == 0) {
+ idx = atoi(gc->lg_val);
+ break;
+ }
+ }
+
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ gctl_ro_param(r, "arg0", -1, pp->lg_geom->lg_name);
+ gctl_ro_param(r, "verb", -1, "set");
+ gctl_ro_param(r, "attrib", -1, attribute);
+ gctl_ro_param(r, "index", sizeof(idx), &idx);
+
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0')
+ gpart_show_error("Error", "Error marking partition active:",
+ errstr);
+ gctl_free(r);
+}
+
+static void
+gpart_bootcode(struct ggeom *gp)
+{
+ const char *bootcode;
+ struct gconfig *gc;
+ struct gctl_req *r;
+ const char *errstr, *scheme;
+ uint8_t *boot;
+ size_t bootsize, bytes;
+ int bootfd;
+
+ /*
+ * Write default bootcode to the newly partitioned disk, if that
+ * applies on this platform.
+ */
+ LIST_FOREACH(gc, &gp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "scheme") == 0) {
+ scheme = gc->lg_val;
+ break;
+ }
+ }
+
+ bootcode = bootcode_path(scheme);
+ if (bootcode == NULL)
+ return;
+
+ bootfd = open(bootcode, O_RDONLY);
+ if (bootfd <= 0) {
+ dialog_msgbox("Bootcode Error", strerror(errno), 0, 0,
+ TRUE);
+ return;
+ }
+
+ bootsize = lseek(bootfd, 0, SEEK_END);
+ boot = malloc(bootsize);
+ lseek(bootfd, 0, SEEK_SET);
+ bytes = 0;
+ while (bytes < bootsize)
+ bytes += read(bootfd, boot + bytes, bootsize - bytes);
+ close(bootfd);
+
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ gctl_ro_param(r, "arg0", -1, gp->lg_name);
+ gctl_ro_param(r, "verb", -1, "bootcode");
+ gctl_ro_param(r, "bootcode", bootsize, boot);
+
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0')
+ gpart_show_error("Bootcode Error", NULL, errstr);
+ gctl_free(r);
+ free(boot);
+}
+
+static void
+gpart_partcode(struct gprovider *pp)
+{
+ struct gconfig *gc;
+ const char *scheme;
+ const char *indexstr;
+ char message[255], command[255];
+
+ LIST_FOREACH(gc, &pp->lg_geom->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "scheme") == 0) {
+ scheme = gc->lg_val;
+ break;
+ }
+ }
+
+ /* Make sure this partition scheme needs partcode on this platform */
+ if (partcode_path(scheme) == NULL)
+ return;
+
+ LIST_FOREACH(gc, &pp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "index") == 0) {
+ indexstr = gc->lg_val;
+ break;
+ }
+ }
+
+ /* Shell out to gpart for partcode for now */
+ sprintf(command, "gpart bootcode -p %s -i %s %s",
+ partcode_path(scheme), indexstr, pp->lg_geom->lg_name);
+ if (system(command) != 0) {
+ sprintf(message, "Error installing partcode on partition %s",
+ pp->lg_name);
+ dialog_msgbox("Error", message, 0, 0, TRUE);
+ }
+}
+
+void
+gpart_destroy(struct ggeom *lg_geom, int force)
+{
+ struct gprovider *pp;
+ struct gctl_req *r;
+ const char *errstr;
+
+ /* Begin with the hosing: delete all partitions */
+ LIST_FOREACH(pp, &lg_geom->lg_provider, lg_provider)
+ gpart_delete(pp);
+
+ /* Now destroy the geom itself */
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ gctl_ro_param(r, "arg0", -1, lg_geom->lg_name);
+ gctl_ro_param(r, "flags", -1, GPART_FLAGS);
+ gctl_ro_param(r, "verb", -1, "destroy");
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0')
+ gpart_show_error("Error", NULL, errstr);
+ gctl_free(r);
+
+ /* If asked, commit the change */
+ if (force) {
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ gctl_ro_param(r, "arg0", -1, lg_geom->lg_name);
+ gctl_ro_param(r, "verb", -1, "commit");
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0')
+ gpart_show_error("Error", NULL, errstr);
+ gctl_free(r);
+ }
+
+ /* And any metadata associated with the partition scheme itself */
+ delete_part_metadata(lg_geom->lg_name);
+}
+
+void
+gpart_edit(struct gprovider *pp)
+{
+ struct gctl_req *r;
+ struct gconfig *gc;
+ struct gconsumer *cp;
+ struct ggeom *geom;
+ const char *errstr, *oldtype, *scheme;
+ struct partition_metadata *md;
+ char sizestr[32];
+ intmax_t idx;
+ int hadlabel, choice, junk, nitems;
+ unsigned i;
+
+ DIALOG_FORMITEM items[] = {
+ {0, "Type:", 5, 0, 0, FALSE, "", 11, 0, 12, 15, 0,
+ FALSE, "Filesystem type (e.g. freebsd-ufs, freebsd-swap)",
+ FALSE},
+ {0, "Size:", 5, 1, 0, FALSE, "", 11, 1, 12, 0, 0,
+ FALSE, "Partition size. Append K, M, G for kilobytes, "
+ "megabytes or gigabytes.", FALSE},
+ {0, "Mountpoint:", 11, 2, 0, FALSE, "", 11, 2, 12, 15, 0,
+ FALSE, "Path at which to mount this partition (leave blank "
+ "for swap, set to / for root filesystem)", FALSE},
+ {0, "Label:", 7, 3, 0, FALSE, "", 11, 3, 12, 15, 0, FALSE,
+ "Partition name. Not all partition schemes support this.",
+ FALSE},
+ };
+
+ /*
+ * Find the PART geom we are manipulating. This may be a consumer of
+ * this provider, or its parent. Check the consumer case first.
+ */
+ geom = NULL;
+ LIST_FOREACH(cp, &pp->lg_consumers, lg_consumers)
+ if (strcmp(cp->lg_geom->lg_class->lg_name, "PART") == 0) {
+ char message[512];
+ /*
+ * The PART object is a consumer, so the user wants to
+ * edit the partition table. gpart doesn't really
+ * support this, so we have to hose the whole table
+ * first.
+ */
+
+ sprintf(message, "Changing the partition scheme on "
+ "this disk (%s) requires deleting all existing "
+ "partitions on this drive. This will PERMANENTLY "
+ "ERASE any data stored here. Are you sure you want "
+ "to proceed?", cp->lg_geom->lg_name);
+ dialog_vars.defaultno = TRUE;
+ choice = dialog_yesno("Warning", message, 0, 0);
+ dialog_vars.defaultno = FALSE;
+
+ if (choice == 1) /* cancel */
+ return;
+
+ /* Destroy the geom and all sub-partitions */
+ gpart_destroy(cp->lg_geom, 0);
+
+ /* Now re-partition and return */
+ gpart_partition(cp->lg_geom->lg_name, NULL);
+ return;
+ }
+
+ if (geom == NULL && strcmp(pp->lg_geom->lg_class->lg_name, "PART") == 0)
+ geom = pp->lg_geom;
+
+ if (geom == NULL) {
+ /* Disk not partitioned, so partition it */
+ gpart_partition(pp->lg_geom->lg_name, NULL);
+ return;
+ }
+
+ LIST_FOREACH(gc, &geom->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "scheme") == 0) {
+ scheme = gc->lg_val;
+ break;
+ }
+ }
+
+ /* Labels only supported on GPT and APM */
+ if (strcmp(scheme, "GPT") == 0 || strcmp(scheme, "APM") == 0)
+ nitems = 4;
+ else
+ nitems = 3;
+
+ /* Edit editable parameters of a partition */
+ hadlabel = 0;
+ LIST_FOREACH(gc, &pp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "type") == 0) {
+ oldtype = gc->lg_val;
+ items[0].text = gc->lg_val;
+ }
+ if (strcmp(gc->lg_name, "label") == 0 && gc->lg_val != NULL) {
+ hadlabel = 1;
+ items[3].text = gc->lg_val;
+ }
+ if (strcmp(gc->lg_name, "index") == 0)
+ idx = atoi(gc->lg_val);
+ }
+
+ TAILQ_FOREACH(md, &part_metadata, metadata) {
+ if (md->name != NULL && strcmp(md->name, pp->lg_name) == 0) {
+ if (md->fstab != NULL)
+ items[2].text = md->fstab->fs_file;
+ break;
+ }
+ }
+
+ humanize_number(sizestr, 7, pp->lg_mediasize, "B", HN_AUTOSCALE,
+ HN_NOSPACE | HN_DECIMAL);
+ items[1].text = sizestr;
+
+editpart:
+ choice = dlg_form("Edit Partition", "", 0, 0, 0, nitems, items, &junk);
+
+ if (choice) /* Cancel pressed */
+ return;
+
+ /* Check if the label has a / in it */
+ if (strchr(items[3].text, '/') != NULL) {
+ dialog_msgbox("Error", "Label contains a /, which is not an "
+ "allowed character.", 0, 0, TRUE);
+ goto editpart;
+ }
+
+ if (strncmp(items[0].text, "freebsd-", 8) != 0 &&
+ items[0].text[0] != '\0') {
+ char message[512];
+
+ sprintf(message, "Cannot mount unknown file system %s!\n",
+ items[0].text);
+ dialog_msgbox("Error", message, 0, 0, TRUE);
+ goto editpart;
+ }
+
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ gctl_ro_param(r, "arg0", -1, geom->lg_name);
+ gctl_ro_param(r, "flags", -1, GPART_FLAGS);
+ gctl_ro_param(r, "verb", -1, "modify");
+ gctl_ro_param(r, "index", sizeof(idx), &idx);
+ if (hadlabel || items[3].text[0] != '\0')
+ gctl_ro_param(r, "label", -1, items[3].text);
+ gctl_ro_param(r, "type", -1, items[0].text);
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0') {
+ gpart_show_error("Error", NULL, errstr);
+ gctl_free(r);
+ goto editpart;
+ }
+ gctl_free(r);
+
+ set_default_part_metadata(pp->lg_name, scheme, items[0].text,
+ items[2].text, strcmp(oldtype, items[0].text) != 0);
+
+ for (i = 0; i < (sizeof(items) / sizeof(items[0])); i++)
+ if (items[i].text_free)
+ free(items[i].text);
+}
+
+void
+set_default_part_metadata(const char *name, const char *scheme,
+ const char *type, const char *mountpoint, int newfs)
+{
+ struct partition_metadata *md;
+
+ /* Set part metadata */
+ md = get_part_metadata(name, 1);
+
+ if (newfs) {
+ if (md->newfs != NULL) {
+ free(md->newfs);
+ md->newfs = NULL;
+ }
+
+ if (strcmp(type, "freebsd-ufs") == 0) {
+ md->newfs = malloc(255);
+ sprintf(md->newfs, "newfs /dev/%s", name);
+ }
+ }
+
+ if (strcmp(type, "freebsd-swap") == 0)
+ mountpoint = "none";
+ if (strcmp(type, "freebsd-boot") == 0)
+ md->bootcode = 1;
+
+ /* VTOC8 needs partcode in UFS partitions */
+ if (strcmp(scheme, "VTOC8") == 0 && strcmp(type, "freebsd-ufs") == 0)
+ md->bootcode = 1;
+
+ if (mountpoint == NULL || mountpoint[0] == '\0') {
+ if (md->fstab != NULL) {
+ free(md->fstab->fs_spec);
+ free(md->fstab->fs_file);
+ free(md->fstab->fs_vfstype);
+ free(md->fstab->fs_mntops);
+ free(md->fstab->fs_type);
+ free(md->fstab);
+ md->fstab = NULL;
+ }
+ } else {
+ if (md->fstab == NULL) {
+ md->fstab = malloc(sizeof(struct fstab));
+ } else {
+ free(md->fstab->fs_spec);
+ free(md->fstab->fs_file);
+ free(md->fstab->fs_vfstype);
+ free(md->fstab->fs_mntops);
+ free(md->fstab->fs_type);
+ }
+ md->fstab->fs_spec = malloc(strlen(name) + 6);
+ sprintf(md->fstab->fs_spec, "/dev/%s", name);
+ md->fstab->fs_file = strdup(mountpoint);
+ /* Get VFS from text after freebsd-, if possible */
+ if (strncmp("freebsd-", type, 8))
+ md->fstab->fs_vfstype = strdup(&type[8]);
+ else
+ md->fstab->fs_vfstype = strdup(type); /* Guess */
+ md->fstab->fs_vfstype = strdup(&type[8]);
+ if (strcmp(type, "freebsd-swap") == 0) {
+ md->fstab->fs_type = strdup(FSTAB_SW);
+ md->fstab->fs_freq = 0;
+ md->fstab->fs_passno = 0;
+ } else {
+ md->fstab->fs_type = strdup(FSTAB_RW);
+ if (strcmp(mountpoint, "/") == 0) {
+ md->fstab->fs_freq = 1;
+ md->fstab->fs_passno = 1;
+ } else {
+ md->fstab->fs_freq = 2;
+ md->fstab->fs_passno = 2;
+ }
+ }
+ md->fstab->fs_mntops = strdup(md->fstab->fs_type);
+ }
+}
+
+static
+int part_compare(const void *xa, const void *xb)
+{
+ struct gprovider **a = (struct gprovider **)xa;
+ struct gprovider **b = (struct gprovider **)xb;
+ intmax_t astart, bstart;
+ struct gconfig *gc;
+
+ astart = bstart = 0;
+ LIST_FOREACH(gc, &(*a)->lg_config, lg_config)
+ if (strcmp(gc->lg_name, "start") == 0) {
+ astart = strtoimax(gc->lg_val, NULL, 0);
+ break;
+ }
+ LIST_FOREACH(gc, &(*b)->lg_config, lg_config)
+ if (strcmp(gc->lg_name, "start") == 0) {
+ bstart = strtoimax(gc->lg_val, NULL, 0);
+ break;
+ }
+
+ if (astart < bstart)
+ return -1;
+ else if (astart > bstart)
+ return 1;
+ else
+ return 0;
+}
+
+intmax_t
+gpart_max_free(struct ggeom *geom, intmax_t *npartstart)
+{
+ struct gconfig *gc;
+ struct gprovider *pp, **providers;
+ intmax_t lastend;
+ intmax_t start, end;
+ intmax_t maxsize, maxstart;
+ intmax_t partstart, partend;
+ int i, nparts;
+
+ /* Now get the maximum free size and free start */
+ start = end = 0;
+ LIST_FOREACH(gc, &geom->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "first") == 0)
+ start = strtoimax(gc->lg_val, NULL, 0);
+ if (strcmp(gc->lg_name, "last") == 0)
+ end = strtoimax(gc->lg_val, NULL, 0);
+ }
+
+ i = nparts = 0;
+ LIST_FOREACH(pp, &geom->lg_provider, lg_provider)
+ nparts++;
+ providers = calloc(nparts, sizeof(providers[0]));
+ LIST_FOREACH(pp, &geom->lg_provider, lg_provider)
+ providers[i++] = pp;
+ qsort(providers, nparts, sizeof(providers[0]), part_compare);
+
+ lastend = start - 1;
+ maxsize = 0;
+ for (i = 0; i < nparts; i++) {
+ pp = providers[i];
+
+ LIST_FOREACH(gc, &pp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "start") == 0)
+ partstart = strtoimax(gc->lg_val, NULL, 0);
+ if (strcmp(gc->lg_name, "end") == 0)
+ partend = strtoimax(gc->lg_val, NULL, 0);
+ }
+
+ if (partstart - lastend > maxsize) {
+ maxsize = partstart - lastend - 1;
+ maxstart = lastend + 1;
+ }
+
+ lastend = partend;
+ }
+
+ if (end - lastend > maxsize) {
+ maxsize = end - lastend - 1;
+ maxstart = lastend + 1;
+ }
+
+ pp = LIST_FIRST(&geom->lg_consumer)->lg_provider;
+
+ /* Compute beginning of new partition and maximum available space */
+ if (pp->lg_stripesize > 0 &&
+ (maxstart*pp->lg_sectorsize % pp->lg_stripesize) != 0) {
+ intmax_t offset = (pp->lg_stripesize -
+ ((maxstart*pp->lg_sectorsize) % pp->lg_stripesize)) /
+ pp->lg_sectorsize;
+ maxstart += offset;
+ maxsize -= offset;
+ }
+
+ if (npartstart != NULL)
+ *npartstart = maxstart;
+
+ return (maxsize);
+}
+
+void
+gpart_create(struct gprovider *pp, char *default_type, char *default_size,
+ char *default_mountpoint, char **partname, int interactive)
+{
+ struct gctl_req *r;
+ struct gconfig *gc;
+ struct gconsumer *cp;
+ struct ggeom *geom;
+ const char *errstr, *scheme;
+ char sizestr[32], startstr[32], output[64];
+ intmax_t maxsize, size, sector, firstfree, stripe;
+ uint64_t bytes;
+ int nitems, choice, junk;
+ unsigned i;
+
+ DIALOG_FORMITEM items[] = {
+ {0, "Type:", 5, 0, 0, FALSE, "freebsd-ufs", 11, 0, 12, 15, 0,
+ FALSE, "Filesystem type (e.g. freebsd-ufs, freebsd-swap)",
+ FALSE},
+ {0, "Size:", 5, 1, 0, FALSE, "", 11, 1, 12, 15, 0,
+ FALSE, "Partition size. Append K, M, G for kilobytes, "
+ "megabytes or gigabytes.", FALSE},
+ {0, "Mountpoint:", 11, 2, 0, FALSE, "", 11, 2, 12, 15, 0,
+ FALSE, "Path at which to mount partition (blank for "
+ "swap, / for root filesystem)", FALSE},
+ {0, "Label:", 7, 3, 0, FALSE, "", 11, 3, 12, 15, 0, FALSE,
+ "Partition name. Not all partition schemes support this.",
+ FALSE},
+ };
+
+ if (partname != NULL)
+ *partname = NULL;
+
+ /* Record sector and stripe sizes */
+ sector = pp->lg_sectorsize;
+ stripe = pp->lg_stripesize;
+
+ /*
+ * Find the PART geom we are manipulating. This may be a consumer of
+ * this provider, or its parent. Check the consumer case first.
+ */
+ geom = NULL;
+ LIST_FOREACH(cp, &pp->lg_consumers, lg_consumers)
+ if (strcmp(cp->lg_geom->lg_class->lg_name, "PART") == 0) {
+ geom = cp->lg_geom;
+ break;
+ }
+
+ if (geom == NULL && strcmp(pp->lg_geom->lg_class->lg_name, "PART") == 0)
+ geom = pp->lg_geom;
+
+ /* Now get the partition scheme */
+ scheme = NULL;
+ if (geom != NULL) {
+ LIST_FOREACH(gc, &geom->lg_config, lg_config)
+ if (strcmp(gc->lg_name, "scheme") == 0)
+ scheme = gc->lg_val;
+ }
+
+ if (geom == NULL || scheme == NULL || strcmp(scheme, "(none)") == 0) {
+ if (gpart_partition(pp->lg_geom->lg_name, NULL) == 0)
+ dialog_msgbox("",
+ "The partition table has been successfully created."
+ " Please press Create again to create partitions.",
+ 0, 0, TRUE);
+
+ return;
+ }
+
+ /*
+ * If we still don't have a geom, either the user has
+ * canceled partitioning or there has been an error which has already
+ * been displayed, so bail.
+ */
+ if (geom == NULL)
+ return;
+
+ maxsize = size = gpart_max_free(geom, &firstfree);
+ if (size <= 0) {
+ dialog_msgbox("Error", "No free space left on device.", 0, 0,
+ TRUE);
+ return;
+ }
+
+ humanize_number(sizestr, 7, size*sector, "B", HN_AUTOSCALE,
+ HN_NOSPACE | HN_DECIMAL);
+ items[1].text = sizestr;
+
+ /* Special-case the MBR default type for nested partitions */
+ if (strcmp(scheme, "MBR") == 0 || strcmp(scheme, "PC98") == 0)
+ items[0].text = "freebsd";
+
+ /* Labels only supported on GPT and APM */
+ if (strcmp(scheme, "GPT") == 0 || strcmp(scheme, "APM") == 0)
+ nitems = 4;
+ else
+ nitems = 3;
+
+ if (default_type != NULL)
+ items[0].text = default_type;
+ if (default_size != NULL)
+ items[1].text = default_size;
+ if (default_mountpoint != NULL)
+ items[2].text = default_mountpoint;
+
+addpartform:
+ if (interactive) {
+ choice = dlg_form("Add Partition", "", 0, 0, 0, nitems,
+ items, &junk);
+ if (choice) /* Cancel pressed */
+ return;
+ }
+
+ size = maxsize;
+ if (strlen(items[1].text) > 0) {
+ if (expand_number(items[1].text, &bytes) != 0) {
+ char error[512];
+
+ sprintf(error, "Invalid size: %s\n", strerror(errno));
+ dialog_msgbox("Error", error, 0, 0, TRUE);
+ goto addpartform;
+ }
+ size = MIN((intmax_t)(bytes/sector), maxsize);
+ }
+
+ /* Check if the label has a / in it */
+ if (strchr(items[3].text, '/') != NULL) {
+ dialog_msgbox("Error", "Label contains a /, which is not an "
+ "allowed character.", 0, 0, TRUE);
+ goto addpartform;
+ }
+
+ /* Warn if no mountpoint set */
+ if (strcmp(items[0].text, "freebsd-ufs") == 0 &&
+ items[2].text[0] != '/') {
+ dialog_vars.defaultno = TRUE;
+ choice = dialog_yesno("Warning",
+ "This partition does not have a valid mountpoint "
+ "(for the partition from which you intend to boot the "
+ "operating system, the mountpoint should be /). Are you "
+ "sure you want to continue?"
+ , 0, 0);
+ dialog_vars.defaultno = FALSE;
+ if (choice == 1) /* cancel */
+ goto addpartform;
+ }
+
+ /* If this is the root partition, check that this scheme is bootable */
+ if (strcmp(items[2].text, "/") == 0 && !is_scheme_bootable(scheme)) {
+ char message[512];
+ sprintf(message, "This partition scheme (%s) is not bootable "
+ "on this platform. Are you sure you want to proceed?",
+ scheme);
+ dialog_vars.defaultno = TRUE;
+ choice = dialog_yesno("Warning", message, 0, 0);
+ dialog_vars.defaultno = FALSE;
+ if (choice == 1) /* cancel */
+ goto addpartform;
+ }
+
+ /*
+ * If this is the root partition, and we need a boot partition, ask
+ * the user to add one.
+ */
+ if (strcmp(items[2].text, "/") == 0 && bootpart_size(scheme) > 0) {
+ if (interactive)
+ choice = dialog_yesno("Boot Partition",
+ "This partition scheme requires a boot partition "
+ "for the disk to be bootable. Would you like to "
+ "make one now?", 0, 0);
+ else
+ choice = 0;
+
+ if (choice == 0) { /* yes */
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ gctl_ro_param(r, "arg0", -1, geom->lg_name);
+ gctl_ro_param(r, "flags", -1, GPART_FLAGS);
+ gctl_ro_param(r, "verb", -1, "add");
+ gctl_ro_param(r, "type", -1, "freebsd-boot");
+ snprintf(sizestr, sizeof(sizestr), "%jd",
+ bootpart_size(scheme) / sector);
+ gctl_ro_param(r, "size", -1, sizestr);
+ snprintf(startstr, sizeof(startstr), "%jd", firstfree);
+ gctl_ro_param(r, "start", -1, startstr);
+ gctl_rw_param(r, "output", sizeof(output), output);
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0')
+ gpart_show_error("Error", NULL, errstr);
+ gctl_free(r);
+
+ get_part_metadata(strtok(output, " "), 1)->bootcode = 1;
+
+ /* Now adjust the part we are really adding forward */
+ firstfree += bootpart_size(scheme) / sector;
+ size -= (bootpart_size(scheme) + stripe)/sector;
+ if (stripe > 0 && (firstfree*sector % stripe) != 0)
+ firstfree += (stripe - ((firstfree*sector) %
+ stripe)) / sector;
+ }
+ }
+
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ gctl_ro_param(r, "arg0", -1, geom->lg_name);
+ gctl_ro_param(r, "flags", -1, GPART_FLAGS);
+ gctl_ro_param(r, "verb", -1, "add");
+
+ gctl_ro_param(r, "type", -1, items[0].text);
+ snprintf(sizestr, sizeof(sizestr), "%jd", size);
+ gctl_ro_param(r, "size", -1, sizestr);
+ snprintf(startstr, sizeof(startstr), "%jd", firstfree);
+ gctl_ro_param(r, "start", -1, startstr);
+ if (items[3].text[0] != '\0')
+ gctl_ro_param(r, "label", -1, items[3].text);
+ gctl_rw_param(r, "output", sizeof(output), output);
+
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0') {
+ gpart_show_error("Error", NULL, errstr);
+ gctl_free(r);
+ goto addpartform;
+ }
+
+ if (strcmp(items[0].text, "freebsd-boot") == 0)
+ get_part_metadata(strtok(output, " "), 1)->bootcode = 1;
+ else if (strcmp(items[0].text, "freebsd") == 0)
+ gpart_partition(strtok(output, " "), "BSD");
+ else
+ set_default_part_metadata(strtok(output, " "), scheme,
+ items[0].text, items[2].text, 1);
+
+ for (i = 0; i < (sizeof(items) / sizeof(items[0])); i++)
+ if (items[i].text_free)
+ free(items[i].text);
+ gctl_free(r);
+
+ if (partname != NULL)
+ *partname = strdup(strtok(output, " "));
+}
+
+void
+gpart_delete(struct gprovider *pp)
+{
+ struct gconfig *gc;
+ struct ggeom *geom;
+ struct gconsumer *cp;
+ struct gctl_req *r;
+ const char *errstr;
+ intmax_t idx;
+ int choice, is_partition;
+
+ /* Is it a partition? */
+ is_partition = (strcmp(pp->lg_geom->lg_class->lg_name, "PART") == 0);
+
+ /* Find out if this is the root of a gpart geom */
+ geom = NULL;
+ LIST_FOREACH(cp, &pp->lg_consumers, lg_consumers)
+ if (strcmp(cp->lg_geom->lg_class->lg_name, "PART") == 0) {
+ geom = cp->lg_geom;
+ break;
+ }
+
+ /* Destroy all consumers */
+ if (geom != NULL) {
+ if (is_partition) {
+ char message[512];
+ /*
+ * We have to actually really delete the sub-partition
+ * tree so that the consumers will go away and the
+ * partition can be deleted. Warn the user.
+ */
+
+ sprintf(message, "Deleting this partition (%s) "
+ "requires deleting all existing sub-partitions. "
+ "This will PERMANENTLY ERASE any data stored here "
+ "and CANNOT BE REVERTED. Are you sure you want to "
+ "proceed?", cp->lg_geom->lg_name);
+ dialog_vars.defaultno = TRUE;
+ choice = dialog_yesno("Warning", message, 0, 0);
+ dialog_vars.defaultno = FALSE;
+
+ if (choice == 1) /* cancel */
+ return;
+ }
+
+ gpart_destroy(geom, is_partition);
+ }
+
+ /*
+ * If this is not a partition, see if that is a problem, complain if
+ * necessary, and return always, since we need not do anything further,
+ * error or no.
+ */
+ if (!is_partition) {
+ if (geom == NULL)
+ dialog_msgbox("Error",
+ "Only partitions can be deleted.", 0, 0, TRUE);
+ return;
+ }
+
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, pp->lg_geom->lg_class->lg_name);
+ gctl_ro_param(r, "arg0", -1, pp->lg_geom->lg_name);
+ gctl_ro_param(r, "flags", -1, GPART_FLAGS);
+ gctl_ro_param(r, "verb", -1, "delete");
+
+ LIST_FOREACH(gc, &pp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "index") == 0) {
+ idx = atoi(gc->lg_val);
+ gctl_ro_param(r, "index", sizeof(idx), &idx);
+ break;
+ }
+ }
+
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0') {
+ gpart_show_error("Error", NULL, errstr);
+ gctl_free(r);
+ return;
+ }
+
+ gctl_free(r);
+
+ delete_part_metadata(pp->lg_name);
+}
+
+void
+gpart_revert_all(struct gmesh *mesh)
+{
+ struct gclass *classp;
+ struct gconfig *gc;
+ struct ggeom *gp;
+ struct gctl_req *r;
+ const char *errstr;
+ const char *modified;
+
+ LIST_FOREACH(classp, &mesh->lg_class, lg_class) {
+ if (strcmp(classp->lg_name, "PART") == 0)
+ break;
+ }
+
+ if (strcmp(classp->lg_name, "PART") != 0) {
+ dialog_msgbox("Error", "gpart not found!", 0, 0, TRUE);
+ return;
+ }
+
+ LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
+ modified = "true"; /* XXX: If we don't know (kernel too old),
+ * assume there are modifications. */
+ LIST_FOREACH(gc, &gp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "modified") == 0) {
+ modified = gc->lg_val;
+ break;
+ }
+ }
+
+ if (strcmp(modified, "false") == 0)
+ continue;
+
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ gctl_ro_param(r, "arg0", -1, gp->lg_name);
+ gctl_ro_param(r, "verb", -1, "undo");
+
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0')
+ gpart_show_error("Error", NULL, errstr);
+ gctl_free(r);
+ }
+}
+
+void
+gpart_commit(struct gmesh *mesh)
+{
+ struct partition_metadata *md;
+ struct gclass *classp;
+ struct ggeom *gp;
+ struct gconfig *gc;
+ struct gconsumer *cp;
+ struct gprovider *pp;
+ struct gctl_req *r;
+ const char *errstr;
+ const char *modified;
+
+ LIST_FOREACH(classp, &mesh->lg_class, lg_class) {
+ if (strcmp(classp->lg_name, "PART") == 0)
+ break;
+ }
+
+ if (strcmp(classp->lg_name, "PART") != 0) {
+ dialog_msgbox("Error", "gpart not found!", 0, 0, TRUE);
+ return;
+ }
+
+ LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
+ modified = "true"; /* XXX: If we don't know (kernel too old),
+ * assume there are modifications. */
+ LIST_FOREACH(gc, &gp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "modified") == 0) {
+ modified = gc->lg_val;
+ break;
+ }
+ }
+
+ if (strcmp(modified, "false") == 0)
+ continue;
+
+ /* Add bootcode if necessary, before the commit */
+ md = get_part_metadata(gp->lg_name, 0);
+ if (md != NULL && md->bootcode)
+ gpart_bootcode(gp);
+
+ /* Now install partcode on its partitions, if necessary */
+ LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
+ md = get_part_metadata(pp->lg_name, 0);
+ if (md == NULL || !md->bootcode)
+ continue;
+
+ /* Mark this partition active if that's required */
+ gpart_activate(pp);
+
+ /* Check if the partition has sub-partitions */
+ LIST_FOREACH(cp, &pp->lg_consumers, lg_consumers)
+ if (strcmp(cp->lg_geom->lg_class->lg_name,
+ "PART") == 0)
+ break;
+
+ if (cp == NULL) /* No sub-partitions */
+ gpart_partcode(pp);
+ }
+
+ r = gctl_get_handle();
+ gctl_ro_param(r, "class", -1, "PART");
+ gctl_ro_param(r, "arg0", -1, gp->lg_name);
+ gctl_ro_param(r, "verb", -1, "commit");
+
+ errstr = gctl_issue(r);
+ if (errstr != NULL && errstr[0] != '\0')
+ gpart_show_error("Error", NULL, errstr);
+ gctl_free(r);
+ }
+}
+
diff --git a/usr.sbin/bsdinstall/partedit/part_wizard.c b/usr.sbin/bsdinstall/partedit/part_wizard.c
new file mode 100644
index 0000000..e18293a
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/part_wizard.c
@@ -0,0 +1,344 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <errno.h>
+#include <libutil.h>
+#include <inttypes.h>
+
+#include <libgeom.h>
+#include <dialog.h>
+#include <dlg_keys.h>
+
+#include "partedit.h"
+
+#define MIN_FREE_SPACE (1024*1024*1024) /* 1 GB */
+#define SWAP_SIZE(available) MIN(available/20, 4*1024*1024*1024LL)
+
+static char *boot_disk(struct gmesh *mesh);
+static char *wizard_partition(struct gmesh *mesh, const char *disk);
+static int wizard_makeparts(struct gmesh *mesh, const char *disk);
+
+int
+part_wizard(void) {
+ int error;
+ struct gmesh mesh;
+ char *disk, *schemeroot;
+
+startwizard:
+ error = geom_gettree(&mesh);
+
+ dlg_put_backtitle();
+ error = geom_gettree(&mesh);
+ disk = boot_disk(&mesh);
+ if (disk == NULL)
+ return (1);
+
+ dlg_clear();
+ dlg_put_backtitle();
+ schemeroot = wizard_partition(&mesh, disk);
+ free(disk);
+ if (schemeroot == NULL)
+ return (1);
+
+ geom_deletetree(&mesh);
+ dlg_clear();
+ dlg_put_backtitle();
+ error = geom_gettree(&mesh);
+
+ error = wizard_makeparts(&mesh, schemeroot);
+ if (error)
+ goto startwizard;
+ free(schemeroot);
+
+ geom_deletetree(&mesh);
+
+ return (0);
+}
+
+static char *
+boot_disk(struct gmesh *mesh)
+{
+ struct gclass *classp;
+ struct gconfig *gc;
+ struct ggeom *gp;
+ struct gprovider *pp;
+ DIALOG_LISTITEM *disks = NULL;
+ const char *type;
+ char diskdesc[512];
+ char *chosen;
+ int i, err, selected, n = 0;
+
+ LIST_FOREACH(classp, &mesh->lg_class, lg_class) {
+ if (strcmp(classp->lg_name, "DISK") != 0 &&
+ strcmp(classp->lg_name, "MD") != 0)
+ continue;
+
+ LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
+ if (LIST_EMPTY(&gp->lg_provider))
+ continue;
+
+ LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
+ type = NULL;
+ LIST_FOREACH(gc, &pp->lg_config, lg_config)
+ if (strcmp(gc->lg_name, "type") == 0)
+ type = gc->lg_val;
+
+ /* Skip swap-backed md devices */
+ if (strcmp(classp->lg_name, "MD") == 0 &&
+ type != NULL && strcmp(type, "swap") == 0)
+ continue;
+
+ disks = realloc(disks, (++n)*sizeof(disks[0]));
+ disks[n-1].name = pp->lg_name;
+ humanize_number(diskdesc, 7, pp->lg_mediasize,
+ "B", HN_AUTOSCALE, HN_DECIMAL);
+ if (strncmp(pp->lg_name, "ad", 2) == 0)
+ strcat(diskdesc, " ATA Hard Disk");
+ else if (strncmp(pp->lg_name, "da", 2) == 0)
+ strcat(diskdesc, " SCSI Hard Disk");
+ else if (strncmp(pp->lg_name, "md", 2) == 0)
+ strcat(diskdesc, " Memory Disk");
+ else if (strncmp(pp->lg_name, "cd", 2) == 0) {
+ n--;
+ continue;
+ }
+ disks[n-1].text = strdup(diskdesc);
+ disks[n-1].help = NULL;
+ disks[n-1].state = 0;
+ }
+ }
+ }
+
+ if (n > 1) {
+ err = dlg_menu("Partitioning",
+ "Select the disk on which to install FreeBSD.", 0, 0, 0,
+ n, disks, &selected, NULL);
+
+ chosen = (err == 0) ? strdup(disks[selected].name) : NULL;
+ } else if (n == 1) {
+ chosen = strdup(disks[0].name);
+ } else {
+ chosen = NULL;
+ }
+
+ for (i = 0; i < n; i++)
+ free(disks[i].text);
+
+ return (chosen);
+}
+
+static struct gprovider *
+provider_for_name(struct gmesh *mesh, const char *name)
+{
+ struct gclass *classp;
+ struct gprovider *pp = NULL;
+ struct ggeom *gp;
+
+ LIST_FOREACH(classp, &mesh->lg_class, lg_class) {
+ if (strcmp(classp->lg_name, "DISK") != 0 &&
+ strcmp(classp->lg_name, "PART") != 0 &&
+ strcmp(classp->lg_name, "MD") != 0)
+ continue;
+
+ LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
+ if (LIST_EMPTY(&gp->lg_provider))
+ continue;
+
+ LIST_FOREACH(pp, &gp->lg_provider, lg_provider)
+ if (strcmp(pp->lg_name, name) == 0)
+ break;
+
+ if (pp != NULL) break;
+ }
+
+ if (pp != NULL) break;
+ }
+
+ return (pp);
+}
+
+static char *
+wizard_partition(struct gmesh *mesh, const char *disk)
+{
+ struct gclass *classp;
+ struct ggeom *gpart = NULL;
+ struct gconfig *gc;
+ char message[512];
+ const char *scheme = NULL;
+ char *retval = NULL;
+ int choice;
+
+ LIST_FOREACH(classp, &mesh->lg_class, lg_class)
+ if (strcmp(classp->lg_name, "PART") == 0)
+ break;
+
+ if (classp != NULL) {
+ LIST_FOREACH(gpart, &classp->lg_geom, lg_geom)
+ if (strcmp(gpart->lg_name, disk) == 0)
+ break;
+ }
+
+ if (gpart != NULL) {
+ LIST_FOREACH(gc, &gpart->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "scheme") == 0) {
+ scheme = gc->lg_val;
+ break;
+ }
+ }
+ }
+
+query:
+ dialog_vars.yes_label = "Entire Disk";
+ dialog_vars.no_label = "Partition";
+ if (gpart != NULL)
+ dialog_vars.defaultno = TRUE;
+
+ snprintf(message, sizeof(message), "Would you like to use this entire "
+ "disk (%s) for FreeBSD or partition it to share it with other "
+ "operating systems? Using the entire disk will erase any data "
+ "currently stored there.", disk);
+ choice = dialog_yesno("Partition", message, 0, 0);
+
+ dialog_vars.yes_label = NULL;
+ dialog_vars.no_label = NULL;
+ dialog_vars.defaultno = FALSE;
+
+ if (choice == 1 && scheme != NULL && !is_scheme_bootable(scheme)) {
+ char warning[512];
+ int subchoice;
+
+ sprintf(warning, "The existing partition scheme on this "
+ "disk (%s) is not bootable on this platform. To install "
+ "FreeBSD, it must be repartitioned. This will destroy all "
+ "data on the disk. Are you sure you want to proceed?",
+ scheme);
+ subchoice = dialog_yesno("Non-bootable Disk", warning, 0, 0);
+ if (subchoice != 0)
+ goto query;
+
+ gpart_destroy(gpart, 1);
+ gpart_partition(disk, default_scheme());
+ scheme = default_scheme();
+ }
+
+ if (scheme == NULL || strcmp(scheme, "(none)") == 0 || choice == 0) {
+ if (gpart != NULL) { /* Erase partitioned disk */
+ choice = dialog_yesno("Confirmation", "This will erase "
+ "the disk. Are you sure you want to proceed?", 0, 0);
+ if (choice != 0)
+ goto query;
+
+ gpart_destroy(gpart, 1);
+ }
+
+ gpart_partition(disk, default_scheme());
+ scheme = default_scheme();
+ }
+
+ if (strcmp(scheme, "PC98") == 0 || strcmp(scheme, "MBR") == 0) {
+ struct gmesh submesh;
+ geom_gettree(&submesh);
+ gpart_create(provider_for_name(&submesh, disk),
+ "freebsd", NULL, NULL, &retval,
+ choice /* Non-interactive for "Entire Disk" */);
+ geom_deletetree(&submesh);
+ } else {
+ retval = strdup(disk);
+ }
+
+ return (retval);
+}
+
+static int
+wizard_makeparts(struct gmesh *mesh, const char *disk)
+{
+ struct gmesh submesh;
+ struct gclass *classp;
+ struct ggeom *gp;
+ struct gconfig *gc;
+ const char *scheme;
+ struct gprovider *pp;
+ intmax_t swapsize, available;
+ char swapsizestr[10], rootsizestr[10];
+ int retval;
+
+ LIST_FOREACH(classp, &mesh->lg_class, lg_class)
+ if (strcmp(classp->lg_name, "PART") == 0)
+ break;
+
+ LIST_FOREACH(gp, &classp->lg_geom, lg_geom)
+ if (strcmp(gp->lg_name, disk) == 0)
+ break;
+
+ LIST_FOREACH(gc, &gp->lg_config, lg_config)
+ if (strcmp(gc->lg_name, "scheme") == 0)
+ scheme = gc->lg_val;
+
+ pp = provider_for_name(mesh, disk);
+
+ available = gpart_max_free(gp, NULL)*pp->lg_sectorsize;
+ if (available < MIN_FREE_SPACE) {
+ char availablestr[10], neededstr[10], message[512];
+ humanize_number(availablestr, 7, available, "B", HN_AUTOSCALE,
+ HN_DECIMAL);
+ humanize_number(neededstr, 7, MIN_FREE_SPACE, "B", HN_AUTOSCALE,
+ HN_DECIMAL);
+ sprintf(message, "There is not enough free space on %s to "
+ "install FreeBSD (%s free, %s required). Would you like "
+ "to choose another disk or to open the partition editor?",
+ disk, availablestr, neededstr);
+
+ dialog_vars.yes_label = "Another Disk";
+ dialog_vars.no_label = "Editor";
+ retval = dialog_yesno("Warning", message, 0, 0);
+ dialog_vars.yes_label = NULL;
+ dialog_vars.no_label = NULL;
+
+ return (!retval); /* Editor -> return 0 */
+ }
+
+ swapsize = SWAP_SIZE(available);
+ humanize_number(swapsizestr, 7, swapsize, "B", HN_AUTOSCALE,
+ HN_NOSPACE | HN_DECIMAL);
+ humanize_number(rootsizestr, 7, available - swapsize - 1024*1024,
+ "B", HN_AUTOSCALE, HN_NOSPACE | HN_DECIMAL);
+
+ geom_gettree(&submesh);
+ pp = provider_for_name(&submesh, disk);
+ gpart_create(pp, "freebsd-ufs", rootsizestr, "/", NULL, 0);
+ geom_deletetree(&submesh);
+
+ geom_gettree(&submesh);
+ pp = provider_for_name(&submesh, disk);
+ gpart_create(pp, "freebsd-swap", swapsizestr, NULL, NULL, 0);
+ geom_deletetree(&submesh);
+
+ return (0);
+}
+
diff --git a/usr.sbin/bsdinstall/partedit/partedit.c b/usr.sbin/bsdinstall/partedit/partedit.c
new file mode 100644
index 0000000..cb3c018
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/partedit.c
@@ -0,0 +1,445 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <libgen.h>
+#include <libutil.h>
+#include <inttypes.h>
+#include <errno.h>
+
+#include <fstab.h>
+#include <libgeom.h>
+#include <dialog.h>
+#include <dlg_keys.h>
+
+#include "diskeditor.h"
+#include "partedit.h"
+
+struct pmetadata_head part_metadata;
+
+static int apply_changes(struct gmesh *mesh);
+static struct partedit_item *read_geom_mesh(struct gmesh *mesh, int *nitems);
+static void add_geom_children(struct ggeom *gp, int recurse,
+ struct partedit_item **items, int *nitems);
+static void init_fstab_metadata(void);
+static void get_mount_points(struct partedit_item *items, int nitems);
+static int validate_setup(void);
+
+int
+main(int argc, const char **argv) {
+ struct partition_metadata *md;
+ const char *prompt;
+ struct partedit_item *items;
+ struct gmesh mesh;
+ int i, op, nitems, nscroll;
+ int error;
+
+ TAILQ_INIT(&part_metadata);
+
+ init_fstab_metadata();
+
+ init_dialog(stdin, stdout);
+ if (strcmp(basename(argv[0]), "sade") != 0)
+ dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer");
+ dialog_vars.item_help = TRUE;
+ nscroll = i = 0;
+
+ if (strcmp(basename(argv[0]), "autopart") == 0) { /* Guided */
+ prompt = "Please review the disk setup. When complete, press "
+ "the Exit button.";
+ part_wizard();
+ } else {
+ prompt = "Create partitions for FreeBSD. No changes will be "
+ "made until you select Exit.";
+ }
+
+ /* Show the part editor either immediately, or to confirm wizard */
+ while (1) {
+ error = geom_gettree(&mesh);
+ items = read_geom_mesh(&mesh, &nitems);
+ get_mount_points(items, nitems);
+ dlg_clear();
+ dlg_put_backtitle();
+
+ if (i >= nitems)
+ i = nitems - 1;
+ op = diskeditor_show("Partition Editor", prompt,
+ items, nitems, &i, &nscroll);
+
+ switch (op) {
+ case 0: /* Create */
+ gpart_create((struct gprovider *)(items[i].cookie),
+ NULL, NULL, NULL, NULL, 1);
+ break;
+ case 1: /* Delete */
+ gpart_delete((struct gprovider *)(items[i].cookie));
+ break;
+ case 2: /* Modify */
+ gpart_edit((struct gprovider *)(items[i].cookie));
+ break;
+ case 3: /* Revert */
+ gpart_revert_all(&mesh);
+ while ((md = TAILQ_FIRST(&part_metadata)) != NULL) {
+ if (md->fstab != NULL) {
+ free(md->fstab->fs_spec);
+ free(md->fstab->fs_file);
+ free(md->fstab->fs_vfstype);
+ free(md->fstab->fs_mntops);
+ free(md->fstab->fs_type);
+ free(md->fstab);
+ }
+ if (md->newfs != NULL)
+ free(md->newfs);
+ free(md->name);
+
+ TAILQ_REMOVE(&part_metadata, md, metadata);
+ free(md);
+ }
+ init_fstab_metadata();
+ break;
+ case 4: /* Auto */
+ part_wizard();
+ break;
+ }
+
+ error = 0;
+ if (op == 5 && validate_setup()) { /* Finished */
+ dialog_vars.extra_button = TRUE;
+ dialog_vars.extra_label =
+ __DECONST(char *, "Abort");
+ dialog_vars.ok_label = __DECONST(char *, "Save");
+ op = dialog_yesno("Confirmation", "Your changes will "
+ "now be written to disk. If you have chosen to "
+ "overwrite existing data, it will be PERMANENTLY "
+ "ERASED. Are you sure you want to proceed?", 0, 0);
+ dialog_vars.extra_button = FALSE;
+ dialog_vars.ok_label = NULL;
+
+ if (op == 0) { /* Save */
+ error = apply_changes(&mesh);
+ break;
+ } else if (op == 3) { /* Don't save => Quit */
+ gpart_revert_all(&mesh);
+ error = -1;
+ break;
+ }
+ }
+
+ geom_deletetree(&mesh);
+ free(items);
+ }
+
+
+ geom_deletetree(&mesh);
+ free(items);
+ end_dialog();
+
+ return (error);
+}
+
+struct partition_metadata *
+get_part_metadata(const char *name, int create)
+{
+ struct partition_metadata *md;
+
+ TAILQ_FOREACH(md, &part_metadata, metadata)
+ if (md->name != NULL && strcmp(md->name, name) == 0)
+ break;
+
+ if (md == NULL && create) {
+ md = calloc(1, sizeof(*md));
+ md->name = strdup(name);
+ TAILQ_INSERT_TAIL(&part_metadata, md, metadata);
+ }
+
+ return (md);
+}
+
+void
+delete_part_metadata(const char *name) {
+ struct partition_metadata *md;
+
+ TAILQ_FOREACH(md, &part_metadata, metadata) {
+ if (md->name != NULL && strcmp(md->name, name) == 0) {
+ if (md->fstab != NULL) {
+ free(md->fstab->fs_spec);
+ free(md->fstab->fs_file);
+ free(md->fstab->fs_vfstype);
+ free(md->fstab->fs_mntops);
+ free(md->fstab->fs_type);
+ free(md->fstab);
+ }
+ if (md->newfs != NULL)
+ free(md->newfs);
+ free(md->name);
+
+ TAILQ_REMOVE(&part_metadata, md, metadata);
+ free(md);
+ break;
+ }
+ }
+}
+
+static int
+validate_setup(void)
+{
+ struct partition_metadata *md;
+ int root_found = FALSE;
+
+ TAILQ_FOREACH(md, &part_metadata, metadata) {
+ if (md->fstab != NULL && strcmp(md->fstab->fs_file, "/") == 0)
+ root_found = TRUE;
+
+ /* XXX: Check for duplicate mountpoints */
+ }
+
+ if (!root_found) {
+ dialog_msgbox("Error", "No root partition was found. "
+ "The root FreeBSD partition must have a mountpoint of '/'.",
+ 0, 0, TRUE);
+ return (FALSE);
+ }
+
+ return (TRUE);
+}
+
+static int
+apply_changes(struct gmesh *mesh)
+{
+ struct partition_metadata *md;
+ char message[512];
+ int i, nitems, error;
+ const char **items;
+ const char *fstab_path;
+ FILE *fstab;
+
+ nitems = 1; /* Partition table changes */
+ TAILQ_FOREACH(md, &part_metadata, metadata) {
+ if (md->newfs != NULL)
+ nitems++;
+ }
+ items = calloc(nitems * 2, sizeof(const char *));
+ items[0] = "Writing partition tables";
+ items[1] = "7"; /* In progress */
+ i = 1;
+ TAILQ_FOREACH(md, &part_metadata, metadata) {
+ if (md->newfs != NULL) {
+ char *item;
+ item = malloc(255);
+ sprintf(item, "Initializing %s", md->name);
+ items[i*2] = item;
+ items[i*2 + 1] = "Pending";
+ i++;
+ }
+ }
+
+ i = 0;
+ dialog_mixedgauge("Initializing",
+ "Initializing file systems. Please wait.", 0, 0, i*100/nitems,
+ nitems, __DECONST(char **, items));
+ gpart_commit(mesh);
+ items[i*2 + 1] = "3";
+ i++;
+
+ if (getenv("BSDINSTALL_LOG") == NULL)
+ setenv("BSDINSTALL_LOG", "/dev/null", 1);
+
+ TAILQ_FOREACH(md, &part_metadata, metadata) {
+ if (md->newfs != NULL) {
+ items[i*2 + 1] = "7"; /* In progress */
+ dialog_mixedgauge("Initializing",
+ "Initializing file systems. Please wait.", 0, 0,
+ i*100/nitems, nitems, __DECONST(char **, items));
+ sprintf(message, "(echo %s; %s) >>%s 2>>%s",
+ md->newfs, md->newfs, getenv("BSDINSTALL_LOG"),
+ getenv("BSDINSTALL_LOG"));
+ error = system(message);
+ items[i*2 + 1] = (error == 0) ? "3" : "1";
+ i++;
+ }
+ }
+ dialog_mixedgauge("Initializing",
+ "Initializing file systems. Please wait.", 0, 0,
+ i*100/nitems, nitems, __DECONST(char **, items));
+
+ for (i = 1; i < nitems; i++)
+ free(__DECONST(char *, items[i*2]));
+ free(items);
+
+ if (getenv("PATH_FSTAB") != NULL)
+ fstab_path = getenv("PATH_FSTAB");
+ else
+ fstab_path = "/etc/fstab";
+ fstab = fopen(fstab_path, "w+");
+ if (fstab == NULL) {
+ sprintf(message, "Cannot open fstab file %s for writing (%s)\n",
+ getenv("PATH_FSTAB"), strerror(errno));
+ dialog_msgbox("Error", message, 0, 0, TRUE);
+ return (-1);
+ }
+ fprintf(fstab, "# Device\tMountpoint\tFStype\tOptions\tDump\tPass#\n");
+ TAILQ_FOREACH(md, &part_metadata, metadata) {
+ if (md->fstab != NULL)
+ fprintf(fstab, "%s\t%s\t%s\t%s\t%d\t%d\n",
+ md->fstab->fs_spec, md->fstab->fs_file,
+ md->fstab->fs_vfstype, md->fstab->fs_mntops,
+ md->fstab->fs_freq, md->fstab->fs_passno);
+ }
+ fclose(fstab);
+
+ return (0);
+}
+
+static struct partedit_item *
+read_geom_mesh(struct gmesh *mesh, int *nitems) {
+ struct gclass *classp;
+ struct ggeom *gp;
+ struct partedit_item *items;
+
+ *nitems = 0;
+ items = NULL;
+
+ /*
+ * Build the device table. First add all disks (and CDs).
+ */
+
+ LIST_FOREACH(classp, &mesh->lg_class, lg_class) {
+ if (strcmp(classp->lg_name, "DISK") != 0 &&
+ strcmp(classp->lg_name, "MD") != 0)
+ continue;
+
+ /* Now recurse into all children */
+ LIST_FOREACH(gp, &classp->lg_geom, lg_geom)
+ add_geom_children(gp, 0, &items, nitems);
+ }
+
+ return (items);
+}
+
+static void
+add_geom_children(struct ggeom *gp, int recurse, struct partedit_item **items,
+ int *nitems) {
+ struct gconsumer *cp;
+ struct gprovider *pp;
+ struct gconfig *gc;
+
+ if (strcmp(gp->lg_class->lg_name, "PART") == 0 &&
+ !LIST_EMPTY(&gp->lg_config)) {
+ LIST_FOREACH(gc, &gp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "scheme") == 0)
+ (*items)[*nitems-1].type = gc->lg_val;
+ }
+ }
+
+ if (LIST_EMPTY(&gp->lg_provider))
+ return;
+
+ LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
+ if (strcmp(gp->lg_class->lg_name, "LABEL") == 0)
+ continue;
+
+ /* Skip WORM media */
+ if (strncmp(pp->lg_name, "cd", 2) == 0)
+ continue;
+
+ *items = realloc(*items,
+ (*nitems+1)*sizeof(struct partedit_item));
+ (*items)[*nitems].indentation = recurse;
+ (*items)[*nitems].name = pp->lg_name;
+ (*items)[*nitems].size = pp->lg_mediasize;
+ (*items)[*nitems].mountpoint = NULL;
+ (*items)[*nitems].type = "";
+ (*items)[*nitems].cookie = pp;
+
+ LIST_FOREACH(gc, &pp->lg_config, lg_config) {
+ if (strcmp(gc->lg_name, "type") == 0)
+ (*items)[*nitems].type = gc->lg_val;
+ }
+
+ /* Skip swap-backed MD devices */
+ if (strcmp(gp->lg_class->lg_name, "MD") == 0 &&
+ strcmp((*items)[*nitems].type, "swap") == 0)
+ continue;
+
+ (*nitems)++;
+
+ LIST_FOREACH(cp, &pp->lg_consumers, lg_consumers)
+ add_geom_children(cp->lg_geom, recurse+1, items,
+ nitems);
+
+ /* Only use first provider for acd */
+ if (strcmp(gp->lg_class->lg_name, "ACD") == 0)
+ break;
+ }
+}
+
+static void
+init_fstab_metadata(void)
+{
+ struct fstab *fstab;
+ struct partition_metadata *md;
+
+ setfsent();
+ while ((fstab = getfsent()) != NULL) {
+ md = calloc(1, sizeof(struct partition_metadata));
+
+ md->name = NULL;
+ if (strncmp(fstab->fs_spec, "/dev/", 5) == 0)
+ md->name = strdup(&fstab->fs_spec[5]);
+
+ md->fstab = malloc(sizeof(struct fstab));
+ md->fstab->fs_spec = strdup(fstab->fs_spec);
+ md->fstab->fs_file = strdup(fstab->fs_file);
+ md->fstab->fs_vfstype = strdup(fstab->fs_vfstype);
+ md->fstab->fs_mntops = strdup(fstab->fs_mntops);
+ md->fstab->fs_type = strdup(fstab->fs_type);
+ md->fstab->fs_freq = fstab->fs_freq;
+ md->fstab->fs_passno = fstab->fs_passno;
+
+ md->newfs = NULL;
+
+ TAILQ_INSERT_TAIL(&part_metadata, md, metadata);
+ }
+}
+
+static void
+get_mount_points(struct partedit_item *items, int nitems)
+{
+ struct partition_metadata *md;
+ int i;
+
+ for (i = 0; i < nitems; i++) {
+ TAILQ_FOREACH(md, &part_metadata, metadata) {
+ if (md->name != NULL && md->fstab != NULL &&
+ strcmp(md->name, items[i].name) == 0) {
+ items[i].mountpoint = md->fstab->fs_file;
+ break;
+ }
+ }
+ }
+}
diff --git a/usr.sbin/bsdinstall/partedit/partedit.h b/usr.sbin/bsdinstall/partedit/partedit.h
new file mode 100644
index 0000000..6176d68
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/partedit.h
@@ -0,0 +1,80 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _PARTEDIT_PARTEDIT_H
+#define _PARTEDIT_PARTEDIT_H
+
+#include <sys/queue.h>
+#include <inttypes.h>
+#include <fstab.h>
+
+struct gprovider;
+struct gmesh;
+struct ggeom;
+
+TAILQ_HEAD(pmetadata_head, partition_metadata);
+extern struct pmetadata_head part_metadata;
+
+struct partition_metadata {
+ char *name; /* name of this partition, as in GEOM */
+
+ struct fstab *fstab; /* fstab data for this partition */
+ char *newfs; /* shell command to initialize partition */
+
+ int bootcode;
+
+ TAILQ_ENTRY(partition_metadata) metadata;
+};
+
+struct partition_metadata *get_part_metadata(const char *name, int create);
+void delete_part_metadata(const char *name);
+
+int part_wizard(void);
+
+/* gpart operations */
+void gpart_delete(struct gprovider *pp);
+void gpart_destroy(struct ggeom *lg_geom, int force);
+void gpart_edit(struct gprovider *pp);
+void gpart_create(struct gprovider *pp, char *default_type, char *default_size,
+ char *default_mountpoint, char **output, int interactive);
+intmax_t gpart_max_free(struct ggeom *gp, intmax_t *start);
+void gpart_revert(struct gprovider *pp);
+void gpart_revert_all(struct gmesh *mesh);
+void gpart_commit(struct gmesh *mesh);
+int gpart_partition(const char *lg_name, const char *scheme);
+void set_default_part_metadata(const char *name, const char *scheme,
+ const char *type, const char *mountpoint, int newfs);
+
+/* machine-dependent bootability checks */
+const char *default_scheme(void);
+int is_scheme_bootable(const char *part_type);
+size_t bootpart_size(const char *part_type);
+const char *bootcode_path(const char *part_type);
+const char *partcode_path(const char *part_type);
+
+#endif
diff --git a/usr.sbin/bsdinstall/partedit/partedit_generic.c b/usr.sbin/bsdinstall/partedit/partedit_generic.c
new file mode 100644
index 0000000..96faafa
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/partedit_generic.c
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <string.h>
+
+#include "partedit.h"
+
+const char *
+default_scheme(void) {
+ /*
+ * Our loader can parse GPT, so pick that as the default for lack of
+ * a better idea.
+ */
+
+ return ("GPT");
+}
+
+int
+is_scheme_bootable(const char *part_type) {
+ /*
+ * We don't know anything about this platform, so don't irritate the
+ * user by claiming the chosen partition scheme isn't bootable.
+ */
+
+ return (1);
+}
+
+/* No clue => no boot partition, bootcode, or partcode */
+
+size_t
+bootpart_size(const char *part_type) {
+ return (0);
+}
+
+const char *
+bootcode_path(const char *part_type) {
+ return (NULL);
+}
+
+const char *
+partcode_path(const char *part_type) {
+ return (NULL);
+}
+
diff --git a/usr.sbin/bsdinstall/partedit/partedit_pc98.c b/usr.sbin/bsdinstall/partedit/partedit_pc98.c
new file mode 100644
index 0000000..ec438f6
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/partedit_pc98.c
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <string.h>
+
+#include "partedit.h"
+
+const char *
+default_scheme(void) {
+ return ("PC98");
+}
+
+int
+is_scheme_bootable(const char *part_type) {
+ if (strcmp(part_type, "BSD") == 0)
+ return (1);
+ if (strcmp(part_type, "PC98") == 0)
+ return (1);
+
+ return (0);
+}
+
+size_t
+bootpart_size(const char *part_type) {
+ /* No boot partition */
+ return (0);
+}
+
+const char *
+bootcode_path(const char *part_type) {
+ if (strcmp(part_type, "PC98") == 0)
+ return ("/boot/pc98boot");
+ if (strcmp(part_type, "BSD") == 0)
+ return ("/boot/boot");
+
+ return (NULL);
+}
+
+const char *
+partcode_path(const char *part_type) {
+ /* No partcode */
+ return (NULL);
+}
+
diff --git a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
new file mode 100644
index 0000000..23bd8b6
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <string.h>
+
+#include "partedit.h"
+
+const char *
+default_scheme(void) {
+ return ("APM");
+}
+
+int
+is_scheme_bootable(const char *part_type) {
+ if (strcmp(part_type, "APM") == 0)
+ return (1);
+ return (0);
+}
+
+size_t
+bootpart_size(const char *part_type) {
+ if (strcmp(part_type, "APM") == 0)
+ return (800*1024);
+ return (0);
+}
+
+const char *
+bootcode_path(const char *part_type) {
+ return (NULL);
+}
+
+const char *
+partcode_path(const char *part_type) {
+ if (strcmp(part_type, "APM") == 0)
+ return ("/boot/boot1.hfs");
+ return (NULL);
+}
+
diff --git a/usr.sbin/bsdinstall/partedit/partedit_sparc64.c b/usr.sbin/bsdinstall/partedit/partedit_sparc64.c
new file mode 100644
index 0000000..b8ee052
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/partedit_sparc64.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <string.h>
+
+#include "partedit.h"
+
+const char *
+default_scheme(void) {
+ return ("VTOC8");
+}
+
+int
+is_scheme_bootable(const char *part_type) {
+ if (strcmp(part_type, "VTOC8") == 0)
+ return (1);
+ return (0);
+}
+
+size_t
+bootpart_size(const char *part_type) {
+ /* No standalone boot partition */
+
+ return (0);
+}
+
+const char *
+bootcode_path(const char *part_type) {
+ return (NULL);
+}
+
+const char *
+partcode_path(const char *part_type) {
+ if (strcmp(part_type, "VTOC8") == 0)
+ return ("/boot/boot1");
+ return (NULL);
+}
+
diff --git a/usr.sbin/bsdinstall/partedit/partedit_x86.c b/usr.sbin/bsdinstall/partedit/partedit_x86.c
new file mode 100644
index 0000000..a03a7a7
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/partedit_x86.c
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2011 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <string.h>
+
+#include "partedit.h"
+
+const char *
+default_scheme(void) {
+ return ("GPT");
+}
+
+int
+is_scheme_bootable(const char *part_type) {
+ if (strcmp(part_type, "BSD") == 0)
+ return (1);
+ if (strcmp(part_type, "GPT") == 0)
+ return (1);
+ if (strcmp(part_type, "MBR") == 0)
+ return (1);
+
+ return (0);
+}
+
+size_t
+bootpart_size(const char *part_type) {
+ if (strcmp(part_type, "GPT") == 0)
+ return (64*1024);
+
+ /* No partcode except for GPT */
+ return (0);
+}
+
+const char *
+bootcode_path(const char *part_type) {
+ if (strcmp(part_type, "GPT") == 0)
+ return ("/boot/pmbr");
+ if (strcmp(part_type, "MBR") == 0)
+ return ("/boot/mbr");
+ if (strcmp(part_type, "BSD") == 0)
+ return ("/boot/boot");
+
+ return (NULL);
+}
+
+const char *
+partcode_path(const char *part_type) {
+ if (strcmp(part_type, "GPT") == 0)
+ return ("/boot/gptboot");
+
+ /* No partcode except for GPT */
+ return (NULL);
+}
+
diff --git a/usr.sbin/bsdinstall/scripts/Makefile b/usr.sbin/bsdinstall/scripts/Makefile
new file mode 100644
index 0000000..d68ea5a
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+SCRIPTS= auto adduser config hostname jail keymap mount netconfig rootpass \
+ services time umount wlanconfig
+BINDIR= /usr/libexec/bsdinstall
+
+NO_MAN= true
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdinstall/scripts/adduser b/usr.sbin/bsdinstall/scripts/adduser
new file mode 100755
index 0000000..35c50ed
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/adduser
@@ -0,0 +1,34 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+clear
+echo "FreeBSD Installer"
+echo "========================"
+echo "Add Users"
+echo
+chroot $BSDINSTALL_CHROOT adduser
diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto
new file mode 100755
index 0000000..5fc8f0e
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/auto
@@ -0,0 +1,192 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+echo "Begun Installation at $(date)" > $BSDINSTALL_LOG
+
+error() {
+ dialog --backtitle "FreeBSD Installer" --title "Abort" \
+ --no-label "Exit" --yes-label "Restart" --yesno \
+ "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0
+ if [ $? -ne 0 ]; then
+ exit
+ else
+ test -f $PATH_FSTAB && bsdinstall umount
+ exec $0
+ fi
+}
+
+
+rm -rf $BSDINSTALL_TMPETC
+mkdir $BSDINSTALL_TMPETC
+
+trap true SIGINT # This section is optional
+bsdinstall keymap
+
+trap error SIGINT # Catch cntrl-C here
+bsdinstall hostname || error
+
+FETCH_DISTRIBUTIONS=""
+for dist in $DISTRIBUTIONS; do
+ if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then
+ FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist"
+ fi
+done
+
+if [ ! -z "$FETCH_DISTRIBUTIONS" -a ! -z $BSDINSTALL_CONFIGCURRENT ]; then
+ dialog --backtitle "FreeBSD Installer" --title "Network Installation" --msgbox "No installation files were found on the boot volume. The next few screens will allow you to configure networking so that they can be downloaded from the Internet." 0 0
+ bsdinstall netconfig || error
+ NETCONFIG_DONE=yes
+fi
+
+rm $PATH_FSTAB
+touch $PATH_FSTAB
+
+dialog --backtitle "FreeBSD Installer" --title "Partitioning" --extra-button \
+ --extra-label "Manual" --ok-label "Guided" --cancel-label "Shell" \
+ --yesno "Would you like to use the guided partitioning tool (recommended for beginners) or to set up partitions manually (experts)? You can also open a shell and set up partitions entirely by hand." 0 0
+
+case $? in
+0) # Guided
+ bsdinstall autopart || error
+ bsdinstall mount || error
+ ;;
+1) # Shell
+ clear
+ echo "Use this shell to set up partitions for the new system. When finished, mount the system at $BSDINSTALL_CHROOT and place an fstab file for the new system at $PATH_FSTAB. Then type 'exit'. You can also enter the partition editor at any time by entering 'bsdinstall partedit'."
+ sh
+ ;;
+3) # Manual
+ bsdinstall partedit || error
+ bsdinstall mount || error
+ ;;
+*)
+ error
+ ;;
+esac
+
+if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then
+ ALL_DISTRIBUTIONS="$DISTRIBUTIONS"
+
+ # Download to a directory in the new system as scratch space
+ BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/bsdinstall-dist"
+ mkdir -p "$BSDINSTALL_FETCHDEST" || error
+
+ export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS"
+ # Try to use any existing distfiles
+ [ -d $BSDINSTALL_DISTDIR -a "$FETCH_DISTRIBUTIONS" != "$ALL_DISTRIBUTIONS" ] && mount_unionfs "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR"
+
+ # Otherwise, fetch everything
+ if [ $? -ne 0 ]; then
+ export DISTRIBUTIONS="$ALL_DISTRIBUTIONS"
+ export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST"
+ fi
+
+ bsdinstall distfetch || error
+ export DISTRIBUTIONS="$ALL_DISTRIBUTIONS"
+fi
+
+bsdinstall distextract || error
+bsdinstall rootpass || error
+
+trap true SIGINT # This section is optional
+if [ "$NETCONFIG_DONE" != yes ]; then
+ bsdinstall netconfig # Don't check for errors -- the user may cancel
+fi
+bsdinstall time
+bsdinstall services
+
+dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
+ "Would you like to add users to the installed system now?" 0 0 && \
+ bsdinstall adduser
+
+finalconfig() {
+ exec 3>&1
+ REVISIT=$(dialog --backtitle "FreeBSD Installer" \
+ --title "Final Configuration" --no-cancel --menu \
+ "Setup of your FreeBSD system is nearly complete. You can now modify your configuration choices or apply more complex changes using a shell." 0 0 0 \
+ "Add User" "Add a user to the system" \
+ "Root Password" "Change root password" \
+ "Hostname" "Set system hostname" \
+ "Network" "Networking configuration" \
+ "Services" "Set daemons to run on startup" \
+ "Time Zone" "Set system timezone" \
+ "Shell" "Open a shell in the new system" \
+ "Reboot" "Apply configuration and reboot" 2>&1 1>&3)
+ exec 3>&-
+
+ case "$REVISIT" in
+ "Add User")
+ bsdinstall adduser
+ finalconfig
+ ;;
+ "Root Password")
+ bsdinstall rootpass
+ finalconfig
+ ;;
+ "Hostname")
+ bsdinstall hostname
+ finalconfig
+ ;;
+ "Network")
+ bsdinstall netconfig
+ finalconfig
+ ;;
+ "Services")
+ bsdinstall services
+ finalconfig
+ ;;
+ "Time Zone")
+ bsdinstall time
+ finalconfig
+ ;;
+ "Shell")
+ clear
+ echo This shell is operating in a chroot in the new system. \
+ When finished making configuration changes, type \"exit\".
+ chroot "$BSDINSTALL_CHROOT" /bin/sh
+ # Don't hose local rc.conf changes
+ cp $BSDINSTALL_CHROOT/etc/rc.conf $BSDINSTALL_TMPETC/rc.conf.manual
+ finalconfig
+ ;;
+ esac
+}
+
+# Allow user to change his mind
+finalconfig
+
+trap error SIGINT # SIGINT is bad again
+bsdinstall config || error
+
+if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then
+ [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \
+ umount "$BSDINSTALL_DISTDIR"
+ rm -rf "$BSDINSTALL_FETCHDEST"
+fi
+
+echo "Installation Completed at $(date)" >> $BSDINSTALL_LOG
+
diff --git a/usr.sbin/bsdinstall/scripts/config b/usr.sbin/bsdinstall/scripts/config
new file mode 100755
index 0000000..5d7c3ce
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/config
@@ -0,0 +1,32 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+cat $BSDINSTALL_TMPETC/rc.conf.* >> $BSDINSTALL_TMPETC/rc.conf
+rm $BSDINSTALL_TMPETC/rc.conf.*
+
+cp $BSDINSTALL_TMPETC/* $BSDINSTALL_CHROOT/etc
diff --git a/usr.sbin/bsdinstall/scripts/hostname b/usr.sbin/bsdinstall/scripts/hostname
new file mode 100755
index 0000000..a53fd80
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/hostname
@@ -0,0 +1,48 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+: ${DIALOG_OK=0}
+: ${DIALOG_CANCEL=1}
+: ${DIALOG_HELP=2}
+: ${DIALOG_EXTRA=3}
+: ${DIALOG_ITEM_HELP=4}
+: ${DIALOG_ESC=255}
+
+exec 3>&1
+HOSTNAME=`dialog --backtitle 'FreeBSD Installer' --title 'Set Hostname' --nocancel --inputbox \
+ 'Please choose a hostname for this machine.
+
+If you are running on a managed network, please ask your network administrator for an appropriate name.' \
+ 0 0 $(hostname) 2>&1 1>&3`
+if [ $? -eq $DIALOG_CANCEL ]; then exit 1; fi
+exec 3>&-
+
+echo "hostname=\"$HOSTNAME\"" > $BSDINSTALL_TMPETC/rc.conf.hostname
+if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
+ hostname -s "$HOSTNAME"
+fi
diff --git a/usr.sbin/bsdinstall/scripts/jail b/usr.sbin/bsdinstall/scripts/jail
new file mode 100755
index 0000000..d1adebb
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/jail
@@ -0,0 +1,81 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+echo "Begun Installation at $(date)" > $BSDINSTALL_LOG
+
+export BSDINSTALL_CHROOT=$1
+export DISTRIBUTIONS="`echo $DISTRIBUTIONS | sed 's/kernel\.[^ ]* //g'`"
+
+error() {
+ dialog --backtitle "FreeBSD Installer" --title "Abort" \
+ --no-label "Exit" --yes-label "Restart" --yesno \
+ "You have canceled an installation step. Would you like to restart the installation or exit the installer?" 0 0
+ if [ $? -ne 0 ]; then
+ exit
+ else
+ test -f $PATH_FSTAB && bsdinstall umount
+ exec $0
+ fi
+}
+
+
+rm -rf $BSDINSTALL_TMPETC
+mkdir $BSDINSTALL_TMPETC
+
+trap error SIGINT # SIGINT is bad
+
+FETCH_DISTRIBUTIONS=""
+for dist in $DISTRIBUTIONS; do
+ if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then
+ FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist"
+ fi
+done
+
+if [ ! -z $FETCH_DISTRIBUTIONS ]; then
+ ALL_DISTRIBUTIONS=$DISTRIBUTIONS
+ DISTRIBUTIONS=$FETCH_DISTRIBUTIONS
+ bsdinstall distfetch || error
+ DISTRIBUTIONS=$ALL_DISTRIBUTIONS
+fi
+
+bsdinstall distextract || error
+bsdinstall rootpass || error
+
+trap true SIGINT # This section is optional
+bsdinstall time
+bsdinstall services
+
+dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
+ "Would you like to add users to the installed system now?" 0 0 && \
+ bsdinstall adduser
+
+trap error SIGINT # SIGINT is bad again
+bsdinstall config || error
+
+echo "Installation Completed at $(date)" >> $BSDINSTALL_LOG
+
diff --git a/usr.sbin/bsdinstall/scripts/keymap b/usr.sbin/bsdinstall/scripts/keymap
new file mode 100755
index 0000000..501b1d1
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/keymap
@@ -0,0 +1,32 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+kbdcontrol -d >/dev/null 2>&1
+if [ $? -eq 0 ]; then
+ kbdmap 3>&2 2>&1 1>&3 | grep 'keymap=' > $BSDINSTALL_TMPETC/rc.conf.keymap
+fi
diff --git a/usr.sbin/bsdinstall/scripts/mount b/usr.sbin/bsdinstall/scripts/mount
new file mode 100755
index 0000000..fca8000
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/mount
@@ -0,0 +1,55 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+TMP_FSTAB=/tmp/bsdinstall-tmp-fstab
+
+cat $PATH_FSTAB | awk -v BSDINSTALL_CHROOT=$BSDINSTALL_CHROOT '{
+ if ($2 ~ "^/.*") {
+ fsname = $2;
+ if (fsname == "/")
+ fsname = ""
+ printf("%s\t%s%s\t%s\t%s\t%s\t%s\n", $1, BSDINSTALL_CHROOT,
+ fsname, $3, $4, $5, $6);
+ }
+}' > $TMP_FSTAB
+
+FILESYSTEMS=`cat $TMP_FSTAB | awk '/^[^#].*/ {if ($2 ~ "^/.*") printf("%s\n", $2);}' | sort -t /`
+
+for i in $FILESYSTEMS; do
+ mkdir -p $i 2>/dev/null
+ MNTERROR=`mount -F $TMP_FSTAB $i 2>&1`
+ if [ $? -ne 0 ]; then
+ dialog --backtitle "FreeBSD Installer" --title "Error" \
+ --msgbox "Error mounting partition $i:\n$MNTERROR" 0 0
+ exit 1
+ fi
+done
+
+# User might want a shell and require devfs, so mount it
+mkdir $BSDINSTALL_CHROOT/dev 2>/dev/null
+mount -t devfs devfs $BSDINSTALL_CHROOT/dev
diff --git a/usr.sbin/bsdinstall/scripts/netconfig b/usr.sbin/bsdinstall/scripts/netconfig
new file mode 100755
index 0000000..0374d12
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/netconfig
@@ -0,0 +1,121 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+INTERFACES=""
+DIALOG_TAGS=""
+
+: ${DIALOG_OK=0}
+: ${DIALOG_CANCEL=1}
+: ${DIALOG_HELP=2}
+: ${DIALOG_EXTRA=3}
+: ${DIALOG_ITEM_HELP=4}
+: ${DIALOG_ESC=255}
+
+echo -n > $BSDINSTALL_TMPETC/rc.conf.net
+
+for IF in `ifconfig -l`; do
+ test "$IF" = "lo0" && continue
+ (ifconfig -g wlan | egrep -wq $IF) && continue
+ INTERFACES="$INTERFACES $IF"
+ DESC=`sysctl -n dev.$(echo $IF | sed -E 's/([[:alpha:]]*)([[:digit:]]*)/\1.\2/g').%desc`
+ DIALOG_TAGS="$DIALOG_TAGS $IF \"$DESC\""
+done
+
+exec 3>&1
+INTERFACE=`echo $DIALOG_TAGS | xargs dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' --menu 'Please select a network interface to configure:' 0 0 0 2>&1 1>&3`
+if [ $? -eq $DIALOG_CANCEL ]; then exit 1; fi
+exec 3>&-
+
+# Do a dirty check to see if this a wireless interface -- there should be a
+# better way
+IFCONFIG_PREFIX=""
+if ifconfig $INTERFACE | grep -q 'media: IEEE 802.11 Wireless'; then
+ NEXT_WLAN_IFACE=wlan0 # XXX
+ echo wlans_$INTERFACE=\"$NEXT_WLAN_IFACE\" >> $BSDINSTALL_TMPETC/rc.conf.net
+ IFCONFIG_PREFIX="WPA "
+ if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
+ ifconfig $NEXT_WLAN_IFACE create wlandev $INTERFACE
+ ifconfig $NEXT_WLAN_IFACE up
+ fi
+ bsdinstall wlanconfig $NEXT_WLAN_IFACE || exec $0
+ INTERFACE="$NEXT_WLAN_IFACE"
+fi
+
+dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' --yesno 'Would you like to use DHCP to configure this interface?' 0 0
+if [ $? -eq $DIALOG_OK ]; then
+ echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> $BSDINSTALL_TMPETC/rc.conf.net
+
+ if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
+ dialog --backtitle 'FreeBSD Installer' --infobox "Acquiring DHCP lease..." 0 0
+ dhclient $INTERFACE 2>> $BSDINSTALL_LOG
+ if [ $? -ne 0 ]; then
+ dialog --backtitle 'FreeBSD Installer' --msgbox "DHCP lease acquisition failed." 0 0
+ exec $0
+ fi
+ fi
+ exit 0
+fi
+
+IP_ADDRESS=`ifconfig $INTERFACE inet | awk '/inet/ {printf("%s\n", $2); }'`
+NETMASK=`ifconfig $INTERFACE inet | awk '/inet/ {printf("%s\n", $4); }'`
+ROUTER=`netstat -rn -f inet | awk '/default/ {printf("%s\n", $2);}'`
+
+exec 3>&1
+IF_CONFIG=$(dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' --form 'Static Network Interface Configuration' 0 0 0 \
+ 'IP Address' 1 0 "$IP_ADDRESS" 1 20 16 0 \
+ 'Subnet Mask' 2 0 "$NETMASK" 2 20 16 0 \
+ 'Default Router' 3 0 "$ROUTER" 3 20 16 0 \
+ \
+ 'Nameserver' 5 0 "" 5 20 16 0 \
+ 'Search Domain' 6 0 "" 6 20 20 0 \
+2>&1 1>&3)
+if [ $? -eq $DIALOG_CANCEL ]; then exec $0; fi
+exec 3>&-
+
+echo $INTERFACE $IF_CONFIG |
+ awk -v prefix="$IFCONFIG_PREFIX" '{
+ printf("ifconfig_%s=\"%s%s netmask %s\"\n", $1, prefix, $2, $3);
+ printf("defaultrouter=\"%s\"\n", $4);
+ }' >> $BSDINSTALL_TMPETC/rc.conf.net
+
+if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
+ . $BSDINSTALL_TMPETC/rc.conf.net
+ ifconfig $INTERFACE `eval echo \\\$ifconfig_$INTERFACE`
+ route delete default
+ route add default $defaultrouter
+fi
+
+
+echo $IF_CONFIG |
+ awk '{
+ if ($4 != "")
+ printf("nameserver %s\n", $4);
+ if ($5 != "")
+ printf("search %s\n", $5);
+ }' > $BSDINSTALL_TMPETC/resolv.conf
+
diff --git a/usr.sbin/bsdinstall/scripts/rootpass b/usr.sbin/bsdinstall/scripts/rootpass
new file mode 100755
index 0000000..b7177fc
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/rootpass
@@ -0,0 +1,37 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+clear
+echo "FreeBSD Installer"
+echo "========================"
+echo
+
+echo "Please select a password for the system management account (root):"
+
+chroot $BSDINSTALL_CHROOT passwd root
+
diff --git a/usr.sbin/bsdinstall/scripts/services b/usr.sbin/bsdinstall/scripts/services
new file mode 100755
index 0000000..01c25fe
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/services
@@ -0,0 +1,53 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+if [ -f $BSDINSTALL_TMPETC/rc.conf.services ]; then
+ eval `sed -e s/YES/on/I -e s/NO/off/I $BSDINSTALL_TMPETC/rc.conf.services`
+else
+ # Default service states. Everything is off if not enabled.
+ sshd_enable="on"
+fi
+
+echo -n > $BSDINSTALL_TMPETC/rc.conf.services
+
+exec 3>&1
+DAEMONS=$(dialog --backtitle "FreeBSD Installer" \
+ --title "System Configuration" --nocancel --separate-output \
+ --checklist "Choose the services you would like to be started at boot:" \
+ 0 0 0 \
+ sshd "Secure shell daemon" ${sshd_enable:-off} \
+ moused "PS/2 mouse pointer on console" ${moused_enable:-off} \
+ ntpd "Synchronize system and network time" ${ntpd_enable:-off} \
+ powerd "Adjust CPU frequency dynamically" ${powerd_enable:-off} \
+2>&1 1>&3)
+exec 3>&-
+
+for daemon in $DAEMONS; do
+ echo ${daemon}_enable=\"YES\" >> $BSDINSTALL_TMPETC/rc.conf.services
+done
+
diff --git a/usr.sbin/bsdinstall/scripts/time b/usr.sbin/bsdinstall/scripts/time
new file mode 100755
index 0000000..74400b6
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/time
@@ -0,0 +1,29 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+chroot $BSDINSTALL_CHROOT tzsetup
diff --git a/usr.sbin/bsdinstall/scripts/umount b/usr.sbin/bsdinstall/scripts/umount
new file mode 100755
index 0000000..c19f6f3
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/umount
@@ -0,0 +1,42 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+TMP_FSTAB=/tmp/bsdinstall-tmp-fstab
+
+cat $PATH_FSTAB | awk -v BSDINSTALL_CHROOT=$BSDINSTALL_CHROOT '{
+ if ($2 ~ "^/.*") {
+ fsname = $2;
+ if (fsname == "/")
+ fsname = ""
+ printf("%s\t%s%s\t%s\t%s\t%s\t%s\n", $1, BSDINSTALL_CHROOT,
+ fsname, $3, $4, $5, $6);
+ }
+}' > $TMP_FSTAB
+
+umount $BSDINSTALL_CHROOT/dev 2>/dev/null
+umount -F $TMP_FSTAB -a 2>/dev/null
diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig
new file mode 100755
index 0000000..d95ccff
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/wlanconfig
@@ -0,0 +1,137 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+echo -n > $BSDINSTALL_TMPETC/wpa_supplicant.conf
+chmod 0600 $BSDINSTALL_TMPETC/wpa_supplicant.conf
+
+echo "ctrl_interface=/var/run/wpa_supplicant" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+echo "eapol_version=2" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+echo "ap_scan=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+echo "fast_reauth=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+echo >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+
+# Try to reach wpa_supplicant. If it isn't running and we can modify the
+# existing system, start it. Otherwise, fail.
+(wpa_cli ping >/dev/null 2>/dev/null || ([ ! -z $BSDINSTALL_CONFIGCURRENT ] && \
+ wpa_supplicant -B -i $1 -c $BSDINSTALL_TMPETC/wpa_supplicant.conf)) || \
+ (dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \
+ "Could not start wpa_supplicant!" 0 0; exit 1) || exit 1
+
+# See if we succeeded
+wpa_cli ping >/dev/null 2>/dev/null
+if [ $? -ne 0 -a -z $BSDINSTALL_CONFIGCURRENT ]; then
+ dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \
+ "Wireless cannot be configured without making changes to the local system!" \ 0 0
+ exit 1
+fi
+
+wpa_cli scan >>$BSDINSTALL_LOG
+dialog --backtitle "FreeBSD Installer" --title "Scanning" --ok-label "Skip" \
+ --pause "Waiting 5 seconds to scan for wireless networks..." \
+ 9 40 5 || exit 1
+
+SCAN_RESULTS=`wpa_cli scan_results`
+NETWORKS=`echo "$SCAN_RESULTS" | awk -F '\t' \
+ '/..:..:..:..:..:../ {if (length($5) > 0) printf("\"%s\"\t%s\n", $5, $4);}' |
+ sort | uniq`
+
+if [ -z $SCAN_RESULTS ]; then
+ dialog --backtitle "FreeBSD Installer" --title "Error" \
+ --yesno "No wireless networks were found. Rescan?" 0 0 && \
+ exec $0 $@
+ exit 1
+fi
+
+exec 3>&1
+NETWORK=`sh -c "dialog --extra-button --extra-label \"Rescan\" \
+ --backtitle \"FreeBSD Installer\" --title \"Network Selection\" --menu \
+ \"Select a wireless network to connect to.\" 0 0 0 \
+ $(echo $NETWORKS | tr '\n' ' ')" 2>&1 1>&3`
+case $? in
+0) # OK
+ ;;
+1) # Cancel
+ exit 1
+ ;;
+3) # Rescan
+ exec $0 $@
+ ;;
+esac
+exec 3>&-
+
+ENCRYPTION=`echo "$NETWORKS" | awk -F '\t' \
+ "/^\"$NETWORK\"\t/ {printf(\"%s\n\", \\\$2 );}"`
+
+if echo $ENCRYPTION | grep -q 'PSK'; then
+ exec 3>&1
+ PASS=`dialog --insecure --backtitle "FreeBSD Installer" \
+ --title "WPA Setup" --mixedform "" 0 0 0 \
+ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \
+ "Password" 2 0 "" 2 12 15 0 1 \
+ 2>&1 1>&3` \
+ || exec $0 $@
+ exec 3>&-
+echo "network={
+ ssid=\"$NETWORK\"
+ psk=\"$PASS\"
+ priority=5
+}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+elif echo $ENCRYPTION | grep -q WEP; then
+ echo FOO
+ exec 3>&1
+ WEPKEY=`dialog --insecure --backtitle "FreeBSD Installer" \
+ --title "WEP Setup" --mixedform "" 0 0 0 \
+ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \
+ "WEP Key 0" 2 0 "" 2 12 15 0 1 \
+ 2>&1 1>&3` \
+ || exec $0 $@
+echo "network={
+ ssid=\"$NETWORK\"
+ key_mgmt=NONE
+ wep_key0=\"$WEPKEY\"
+ wep_tx_keyidx=0
+ priority=5
+}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+else # Open
+echo "network={
+ ssid=\"$NETWORK\"
+ key_mgmt=NONE
+ priority=5
+}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+fi
+
+# Connect to any open networks policy
+echo "network={
+ priority=5
+ key_mgmt=NONE
+}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+
+# Bring up new network
+test ! -z $BSDINSTALL_CONFIGCURRENT && wpa_cli reconfigure >>$BSDINSTALL_LOG
+
+exit 0
diff --git a/usr.sbin/bsnmpd/bsnmpd/Makefile b/usr.sbin/bsnmpd/bsnmpd/Makefile
index f7e9b23..3e6df47 100644
--- a/usr.sbin/bsnmpd/bsnmpd/Makefile
+++ b/usr.sbin/bsnmpd/bsnmpd/Makefile
@@ -25,13 +25,14 @@ BMIBSDIR= ${SHAREDIR}/snmp/mibs
DEFS= tree.def
DEFSDIR= ${SHAREDIR}/snmp/defs
+CFLAGS+= -DSNMPTREE_TYPES
CFLAGS+= -I${CONTRIB}/lib -I${CONTRIB}/snmpd -I. -DUSE_LIBBEGEMOT
CFLAGS+= -DUSE_TCPWRAPPERS -DQUADFMT='"llu"' -DQUADXFMT='"llx"'
CFLAGS+= -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_ERR_H -DHAVE_STRLCPY
DPADD= ${LIBBEGEMOT} ${LIBBSNMP} ${LIBWRAP}
LDADD= -lbegemot -lbsnmp -lwrap
-LDFLAGS= -export-dynamic
+LDFLAGS= -Wl,-export-dynamic
.if ${MK_OPENSSL} != "no"
CFLAGS+= -DHAVE_LIBCRYPTO
diff --git a/usr.sbin/bsnmpd/modules/Makefile b/usr.sbin/bsnmpd/modules/Makefile
index f7deb77..ab378f0 100644
--- a/usr.sbin/bsnmpd/modules/Makefile
+++ b/usr.sbin/bsnmpd/modules/Makefile
@@ -13,6 +13,7 @@ SUBDIR= ${_snmp_atm} \
snmp_hostres \
snmp_mibII \
snmp_pf \
+ snmp_target \
snmp_usm \
snmp_vacm \
snmp_wlan
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_tree.def b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_tree.def
index cbebda0..2e88e5e 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_tree.def
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_tree.def
@@ -28,11 +28,6 @@
#include "tc.def"
-typedef TruthValue ENUM (
- 1 true
- 2 false
-)
-
typedef RowStatus ENUM (
1 active
2 notInService
@@ -42,6 +37,11 @@ typedef RowStatus ENUM (
6 destroy
)
+typedef TruthValue ENUM (
+ 1 true
+ 2 false
+)
+
typedef StpPortState ENUM (
1 disabled
2 blocking
diff --git a/usr.sbin/bsnmpd/modules/snmp_target/Makefile b/usr.sbin/bsnmpd/modules/snmp_target/Makefile
new file mode 100755
index 0000000..10141e5
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/snmp_target/Makefile
@@ -0,0 +1,20 @@
+# $FreeBSD$
+#
+# Author: Shteryana Shopova <syrinx@freebsd.org>
+
+CONTRIB= ${.CURDIR}/../../../../contrib/bsnmp
+.PATH: ${CONTRIB}/snmp_target
+
+MOD= target
+SRCS= target_snmp.c
+XSYM= snmpTargetMIB snmpNotificationMIB snmpUDPDomain
+
+MAN= snmp_target.3
+
+CFLAGS+= -I${CONTRIB}/lib -I${CONTRIB}/snmpd -DSNMPTREE_TYPES
+CFLAGS+= -DHAVE_ERR_H -DHAVE_GETADDRINFO -DHAVE_STRLCPY -DHAVE_SYS_TREE_H
+
+DEFS= ${MOD}_tree.def
+BMIBS=
+
+.include <bsd.snmpmod.mk>
diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_tree.def b/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_tree.def
index f267f76..7c695c4 100644
--- a/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_tree.def
+++ b/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_tree.def
@@ -29,6 +29,8 @@
# $FreeBSD$
#
+#include "tc.def"
+
typedef RowStatus ENUM (
1 active
2 notInService
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile b/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile
index f2b71b6..3551464 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile
@@ -7,7 +7,6 @@
LIB= bsnmptools
#INTERNALLIB=
SRCS= bsnmpimport.c bsnmpmap.c bsnmptools.c bsnmptc.c
-CFLAGS+= -g -Wall -Werror
SHLIB_MAJOR= 0
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index 808b673..81329d9 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -48,10 +48,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h
index 322e648..6e044b8 100644
--- a/usr.sbin/config/configvers.h
+++ b/usr.sbin/config/configvers.h
@@ -49,5 +49,5 @@
*
* $FreeBSD$
*/
-#define CONFIGVERS 600011
+#define CONFIGVERS 600012
#define MAJOR_VERS(x) ((x) / 100000)
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 08e1b63..dd7aaa9 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -140,6 +140,8 @@ makefile(void)
if (ofp == 0)
err(1, "%s", path("Makefile.new"));
fprintf(ofp, "KERN_IDENT=%s\n", ident);
+ fprintf(ofp, "MACHINE=%s\n", machinename);
+ fprintf(ofp, "MACHINE_ARCH=%s\n", machinearch);
SLIST_FOREACH_SAFE(op, &mkopt, op_next, t) {
fprintf(ofp, "%s=%s", op->op_name, op->op_value);
while ((op = SLIST_NEXT(op, op_append)) != NULL)
diff --git a/usr.sbin/cpucontrol/cpucontrol.c b/usr.sbin/cpucontrol/cpucontrol.c
index 7193080..82bbf05 100644
--- a/usr.sbin/cpucontrol/cpucontrol.c
+++ b/usr.sbin/cpucontrol/cpucontrol.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2008 Stanislav Sedov <stas@FreeBSD.org>.
+ * Copyright (c) 2008-2011 Stanislav Sedov <stas@FreeBSD.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -177,6 +177,7 @@ do_msr(const char *cmdarg, const char *dev)
unsigned long command;
int do_invert = 0, op;
int fd, error;
+ const char *command_name;
char *endptr;
char *p;
@@ -245,15 +246,19 @@ do_msr(const char *cmdarg, const char *dev)
switch (op) {
case OP_READ:
command = CPUCTL_RDMSR;
+ command_name = "RDMSR";
break;
case OP_WRITE:
command = CPUCTL_WRMSR;
+ command_name = "WRMSR";
break;
case OP_OR:
command = CPUCTL_MSRSBIT;
+ command_name = "MSRSBIT";
break;
case OP_AND:
command = CPUCTL_MSRCBIT;
+ command_name = "MSRCBIT";
break;
default:
abort();
@@ -266,7 +271,7 @@ do_msr(const char *cmdarg, const char *dev)
}
error = ioctl(fd, command, &args);
if (error < 0) {
- WARN(0, "ioctl(%s, %lu)", dev, command);
+ WARN(0, "ioctl(%s, CPUCTL_%s (%lu))", dev, command_name, command);
close(fd);
return (1);
}
diff --git a/usr.sbin/diskinfo/diskinfo.c b/usr.sbin/diskinfo/diskinfo.c
index 1f967b7..2f00936 100644
--- a/usr.sbin/diskinfo/diskinfo.c
+++ b/usr.sbin/diskinfo/diskinfo.c
@@ -56,7 +56,7 @@ static void commandtime(int fd, off_t mediasize, u_int sectorsize);
int
main(int argc, char **argv)
{
- int i, ch, fd, error;
+ int i, ch, fd, error, exitval = 0;
char buf[BUFSIZ], ident[DISK_IDENT_SIZE];
off_t mediasize, stripesize, stripeoffset;
u_int sectorsize, fwsectors, fwheads;
@@ -90,14 +90,23 @@ main(int argc, char **argv)
sprintf(buf, "%s%s", _PATH_DEV, argv[i]);
fd = open(buf, O_RDONLY);
}
- if (fd < 0)
- err(1, argv[i]);
+ if (fd < 0) {
+ warn("%s", argv[i]);
+ exitval = 1;
+ goto out;
+ }
error = ioctl(fd, DIOCGMEDIASIZE, &mediasize);
- if (error)
- err(1, "%s: ioctl(DIOCGMEDIASIZE) failed, probably not a disk.", argv[i]);
+ if (error) {
+ warn("%s: ioctl(DIOCGMEDIASIZE) failed, probably not a disk.", argv[i]);
+ exitval = 1;
+ goto out;
+ }
error = ioctl(fd, DIOCGSECTORSIZE, &sectorsize);
- if (error)
- err(1, "%s: DIOCGSECTORSIZE failed, probably not a disk.", argv[i]);
+ if (error) {
+ warn("%s: DIOCGSECTORSIZE failed, probably not a disk.", argv[i]);
+ exitval = 1;
+ goto out;
+ }
error = ioctl(fd, DIOCGFWSECTORS, &fwsectors);
if (error)
fwsectors = 0;
@@ -148,9 +157,10 @@ main(int argc, char **argv)
commandtime(fd, mediasize, sectorsize);
if (opt_t)
speeddisk(fd, mediasize, sectorsize);
+out:
close(fd);
}
- exit (0);
+ exit (exitval);
}
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh
index 97e4c57..0247e38 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -1875,7 +1875,7 @@ fetch_create_manifest () {
echo -n "been downloaded because the files have been "
echo "modified locally:"
cat modifiedfiles
- fi | more
+ fi | $PAGER
rm modifiedfiles
# If no files will be updated, tell the user and exit
@@ -1905,7 +1905,7 @@ fetch_create_manifest () {
echo -n "The following files will be removed "
echo "as part of updating to ${RELNUM}-p${RELPATCHNUM}:"
cat files.removed
- fi | more
+ fi | $PAGER
rm files.removed
# Report added files, if any
@@ -1914,7 +1914,7 @@ fetch_create_manifest () {
echo -n "The following files will be added "
echo "as part of updating to ${RELNUM}-p${RELPATCHNUM}:"
cat files.added
- fi | more
+ fi | $PAGER
rm files.added
# Report updated files, if any
@@ -1924,7 +1924,7 @@ fetch_create_manifest () {
echo "as part of updating to ${RELNUM}-p${RELPATCHNUM}:"
cat files.updated
- fi | more
+ fi | $PAGER
rm files.updated
# Create a directory for the install manifest.
@@ -3202,6 +3202,11 @@ cmd_IDS () {
# Make sure we find utilities from the base system
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:${PATH}
+# Set a pager if the user doesn't
+if [ -z "$PAGER" ]; then
+ PAGER=/usr/bin/more
+fi
+
# Set LC_ALL in order to avoid problems with character ranges like [A-Z].
export LC_ALL=C
diff --git a/usr.sbin/fwcontrol/fwdv.c b/usr.sbin/fwcontrol/fwdv.c
index 23237e5..afb3ada 100644
--- a/usr.sbin/fwcontrol/fwdv.c
+++ b/usr.sbin/fwcontrol/fwdv.c
@@ -110,7 +110,7 @@ dvrecv(int d, const char *filename, char ich, int count)
} else {
fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0660);
if (fd == -1)
- err(EX_NOINPUT, filename);
+ err(EX_NOINPUT, "%s", filename);
}
buf = malloc(RBUFSIZE);
pad = malloc(DSIZE*MAXBLOCKS);
@@ -270,7 +270,7 @@ dvsend(int d, const char *filename, char ich, int count)
fd = open(filename, O_RDONLY);
if (fd == -1)
- err(EX_NOINPUT, filename);
+ err(EX_NOINPUT, "%s", filename);
pbuf = malloc(DSIZE * TNBUF);
bzero(wbuf, sizeof(wbuf));
diff --git a/usr.sbin/fwcontrol/fwmpegts.c b/usr.sbin/fwcontrol/fwmpegts.c
index e92b799..d90b6dd 100644
--- a/usr.sbin/fwcontrol/fwmpegts.c
+++ b/usr.sbin/fwcontrol/fwmpegts.c
@@ -167,7 +167,7 @@ mpegtsrecv(int d, const char *filename, char ich, int count)
else {
fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0660);
if (fd == -1)
- err(EX_NOINPUT, filename);
+ err(EX_NOINPUT, "%s", filename);
}
buf = malloc(RBUFSIZE);
diff --git a/usr.sbin/gpioctl/gpioctl.8 b/usr.sbin/gpioctl/gpioctl.8
index 12bae3a..ca14bec 100644
--- a/usr.sbin/gpioctl/gpioctl.8
+++ b/usr.sbin/gpioctl/gpioctl.8
@@ -9,10 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/iostat/iostat.8 b/usr.sbin/iostat/iostat.8
index aab668a..d8957ef 100644
--- a/usr.sbin/iostat/iostat.8
+++ b/usr.sbin/iostat/iostat.8
@@ -38,10 +38,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index f415640..87099d9 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -43,10 +43,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/kbdmap/kbdmap.c b/usr.sbin/kbdmap/kbdmap.c
index cb00c6d..93c5a08 100644
--- a/usr.sbin/kbdmap/kbdmap.c
+++ b/usr.sbin/kbdmap/kbdmap.c
@@ -337,7 +337,7 @@ show_dialog(struct keymap **km_sorted, int num_keymaps)
exit(1);
}
asprintf(&dialog, "/usr/bin/dialog --clear --title \"Keyboard Menu\" "
- "--menu \"%s\" -1 -1 10", menu);
+ "--menu \"%s\" 0 0 0", menu);
ext = extract_name(dir);
diff --git a/usr.sbin/lmcconfig/Makefile b/usr.sbin/lmcconfig/Makefile
index 842431a..1ff5055 100644
--- a/usr.sbin/lmcconfig/Makefile
+++ b/usr.sbin/lmcconfig/Makefile
@@ -6,6 +6,6 @@ MAN= lmcconfig.8
DPADD= ${LIBNETGRAPH}
LDADD= -lnetgraph
-WARNS?= 0
+WARNS?= 3
.include <bsd.prog.mk>
diff --git a/usr.sbin/lmcconfig/lmcconfig.c b/usr.sbin/lmcconfig/lmcconfig.c
index 1fe63f7..ece19f7 100644
--- a/usr.sbin/lmcconfig/lmcconfig.c
+++ b/usr.sbin/lmcconfig/lmcconfig.c
@@ -65,20 +65,21 @@
* $FreeBSD$
*/
-#include <stdio.h>
+#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+
#include <errno.h>
+#include <inttypes.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
+#include <time.h>
#include <unistd.h>
#if defined(NETGRAPH)
# include <netgraph.h>
#endif
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
#include <net/if.h>
#include <dev/lmc/if_lmc.h>
@@ -95,8 +96,13 @@ int update = 0; /* update driver config */
int verbose = 0; /* verbose output */
u_int8_t checksum; /* gate array ucode file checksum */
-void usage()
- {
+/* Functions currently unused. Keep compiler happy and provide prototypes. */
+void ioctl_snmp_loop(u_int32_t);
+void init_srom(int);
+
+static void
+usage(void)
+{
fprintf(stderr, "Usage: %s interface [-abBcCdDeEfhiLmMpPsStTuUvVwWxXyYzZ?]\n", progname);
fprintf(stderr, "or\n");
fprintf(stderr, "Usage: %s interface -1 [-aABcdeEfFgiIlLpPstTuUvxX]\n", progname);
@@ -147,7 +153,7 @@ void usage()
fprintf(stderr, "The -1 switch precedes T1/E1 commands.\n");
fprintf(stderr, "\t-a <y|b|a> Stop sending Yellow|Blue|AIS signal\n");
- fprintf(stderr, "\t-A <y|b|a> Start sending Yellow|Blue}AIS signal\n");
+ fprintf(stderr, "\t-A <y|b|a> Start sending Yellow|Blue|AIS signal\n");
fprintf(stderr, "\t-B <number> Send BOP msg 25 times\n");
fprintf(stderr, "\t-c <number> Set cable length in meters\n");
fprintf(stderr, "\t-d Print status of T1 DSU/CSU\n");
@@ -209,10 +215,11 @@ void usage()
fprintf(stderr, "\t 1:OFF 2:DigitalLink|Kentrox 3:Larse\n");
fprintf(stderr, "\t-v Set verbose printout mode\n");
fprintf(stderr, "\t-V <number> Write to T3 VCXO freq control DAC\n");
- }
+}
-void call_driver(unsigned long cmd, struct iohdr *iohdr)
- {
+static void
+call_driver(unsigned long cmd, struct iohdr *iohdr)
+{
int error = 0;
strncpy(iohdr->ifname, ifname, sizeof(iohdr->ifname));
@@ -259,10 +266,11 @@ void call_driver(unsigned long cmd, struct iohdr *iohdr)
fprintf(stderr, "%s: This version of %s is incompatible with the device driver\n", progname, progname);
exit(1);
}
- }
+}
-u_int32_t read_pci_config(u_int8_t addr)
- {
+static u_int32_t
+read_pci_config(u_int8_t addr)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -273,10 +281,11 @@ u_int32_t read_pci_config(u_int8_t addr)
call_driver(LMCIOCREAD, &ioctl.iohdr);
return ioctl.data;
- }
+}
-void write_pci_config(u_int8_t addr, u_int32_t data)
- {
+static void
+write_pci_config(u_int8_t addr, u_int32_t data)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOW;
@@ -286,10 +295,11 @@ void write_pci_config(u_int8_t addr, u_int32_t data)
ioctl.data = data;
call_driver(LMCIOCWRITE, &ioctl.iohdr);
- }
+}
-u_int32_t read_csr(u_int8_t addr)
- {
+static u_int32_t
+read_csr(u_int8_t addr)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -300,10 +310,11 @@ u_int32_t read_csr(u_int8_t addr)
call_driver(LMCIOCREAD, &ioctl.iohdr);
return ioctl.data;
- }
+}
-void write_csr(u_int8_t addr, u_int32_t data)
- {
+static void
+write_csr(u_int8_t addr, u_int32_t data)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOW;
@@ -313,10 +324,11 @@ void write_csr(u_int8_t addr, u_int32_t data)
ioctl.data = data;
call_driver(LMCIOCWRITE, &ioctl.iohdr);
- }
+}
-u_int16_t read_srom(u_int8_t addr)
- {
+static u_int16_t
+read_srom(u_int8_t addr)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -327,10 +339,11 @@ u_int16_t read_srom(u_int8_t addr)
call_driver(LMCIOCREAD, &ioctl.iohdr);
return ioctl.data;
- }
+}
-void write_srom(u_int8_t addr, u_int16_t data)
- {
+static void
+write_srom(u_int8_t addr, u_int16_t data)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOW;
@@ -340,10 +353,11 @@ void write_srom(u_int8_t addr, u_int16_t data)
ioctl.data = data;
call_driver(LMCIOCWRITE, &ioctl.iohdr);
- }
+}
-u_int8_t read_bios_rom(u_int32_t addr)
- {
+static u_int8_t
+read_bios_rom(u_int32_t addr)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -354,10 +368,11 @@ u_int8_t read_bios_rom(u_int32_t addr)
call_driver(LMCIOCREAD, &ioctl.iohdr);
return ioctl.data;
- }
+}
-void write_bios_rom(u_int32_t addr, u_int8_t data)
- {
+static void
+write_bios_rom(u_int32_t addr, u_int8_t data)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOW;
@@ -367,10 +382,11 @@ void write_bios_rom(u_int32_t addr, u_int8_t data)
ioctl.data = data;
call_driver(LMCIOCWRITE, &ioctl.iohdr);
- }
+}
-u_int16_t read_mii(u_int8_t addr)
- {
+static u_int16_t
+read_mii(u_int8_t addr)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -381,10 +397,11 @@ u_int16_t read_mii(u_int8_t addr)
call_driver(LMCIOCREAD, &ioctl.iohdr);
return ioctl.data;
- }
+}
-void write_mii(u_int8_t addr, u_int16_t data)
- {
+static void
+write_mii(u_int8_t addr, u_int16_t data)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOW;
@@ -394,10 +411,11 @@ void write_mii(u_int8_t addr, u_int16_t data)
ioctl.data = data;
call_driver(LMCIOCWRITE, &ioctl.iohdr);
- }
+}
-unsigned char read_framer(u_int16_t addr)
- {
+static unsigned char
+read_framer(u_int16_t addr)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -408,10 +426,11 @@ unsigned char read_framer(u_int16_t addr)
call_driver(LMCIOCREAD, &ioctl.iohdr);
return ioctl.data;
- }
+}
-void write_framer(u_int16_t addr, u_int8_t data)
- {
+static void
+write_framer(u_int16_t addr, u_int8_t data)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOW;
@@ -421,10 +440,11 @@ void write_framer(u_int16_t addr, u_int8_t data)
ioctl.data = data;
call_driver(LMCIOCWRITE, &ioctl.iohdr);
- }
+}
-void write_synth(struct synth synth)
- {
+static void
+write_synth(struct synth synth)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOW;
@@ -433,10 +453,11 @@ void write_synth(struct synth synth)
bcopy(&synth, &ioctl.data, sizeof(synth));
call_driver(LMCIOCWRITE, &ioctl.iohdr);
- }
+}
-void write_dac(u_int16_t data)
- {
+static void
+write_dac(u_int16_t data)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOW;
@@ -445,10 +466,11 @@ void write_dac(u_int16_t data)
ioctl.data = data;
call_driver(LMCIOCWRITE, &ioctl.iohdr);
- }
+}
-void reset_xilinx()
- {
+static void
+reset_xilinx(void)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -456,10 +478,11 @@ void reset_xilinx()
ioctl.cmd = IOCTL_XILINX_RESET;
call_driver(LMCIOCTL, &ioctl.iohdr);
- }
+}
-void load_xilinx_from_rom()
- {
+static void
+load_xilinx_from_rom(void)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -467,10 +490,11 @@ void load_xilinx_from_rom()
ioctl.cmd = IOCTL_XILINX_ROM;
call_driver(LMCIOCTL, &ioctl.iohdr);
- }
+}
-void load_xilinx_from_file(char *ucode, u_int32_t len)
- {
+static void
+load_xilinx_from_file(char *ucode, u_int32_t len)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -480,10 +504,11 @@ void load_xilinx_from_file(char *ucode, u_int32_t len)
ioctl.ucode = ucode;
call_driver(LMCIOCTL, &ioctl.iohdr);
- }
+}
-void ioctl_snmp_send(u_int32_t send)
- {
+static void
+ioctl_snmp_send(u_int32_t send)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -492,10 +517,11 @@ void ioctl_snmp_send(u_int32_t send)
ioctl.data = send;
call_driver(LMCIOCTL, &ioctl.iohdr);
- }
+}
-void ioctl_snmp_loop(u_int32_t loop)
- {
+void
+ioctl_snmp_loop(u_int32_t loop)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -504,10 +530,11 @@ void ioctl_snmp_loop(u_int32_t loop)
ioctl.data = loop;
call_driver(LMCIOCTL, &ioctl.iohdr);
- }
+}
-void ioctl_reset_cntrs()
- {
+static void
+ioctl_reset_cntrs(void)
+{
struct ioctl ioctl;
ioctl.iohdr.direction = DIR_IOWR;
@@ -515,39 +542,44 @@ void ioctl_reset_cntrs()
ioctl.cmd = IOCTL_RESET_CNTRS;
call_driver(LMCIOCTL, &ioctl.iohdr);
- }
+}
-void ioctl_read_config()
- {
+static void
+ioctl_read_config(void)
+{
config.iohdr.direction = DIR_IOWR;
config.iohdr.length = sizeof(struct config);
call_driver(LMCIOCGCFG, &config.iohdr);
- }
+}
-void ioctl_write_config()
- {
+static void
+ioctl_write_config(void)
+{
config.iohdr.direction = DIR_IOW;
config.iohdr.length = sizeof(struct config);
call_driver(LMCIOCSCFG, &config.iohdr);
- }
+}
-void ioctl_read_status()
- {
+static void
+ioctl_read_status(void)
+{
status.iohdr.direction = DIR_IOWR;
status.iohdr.length = sizeof(struct status);
call_driver(LMCIOCGSTAT, &status.iohdr);
- }
+}
-void print_card_name()
- {
+static void
+print_card_name(void)
+{
printf("Card name:\t\t%s\n", ifname);
- }
+}
-void print_card_type()
- {
+static void
+print_card_type(void)
+{
printf("Card type:\t\t");
switch(status.card_type)
{
@@ -570,10 +602,11 @@ void print_card_type()
printf("unknown card_type: %d\n", status.card_type);
break;
}
- }
+}
-void print_status()
- {
+static void
+print_status(void)
+{
char *status_string;
if (status.oper_status == STATUS_UP)
@@ -585,21 +618,24 @@ void print_status()
else
status_string = "Unknown";
printf("Link status:\t\t%s\n", status_string);
- }
+}
-void print_tx_speed()
- {
+static void
+print_tx_speed(void)
+{
printf("Tx Speed:\t\t%u\n", status.tx_speed);
- }
+}
-void print_debug()
- {
+static void
+print_debug(void)
+{
if (config.debug != 0)
printf("Debug:\t\t\t%s\n", "On");
- }
+}
-void print_line_prot()
- {
+static void
+print_line_prot(void)
+{
char *on = "On", *off = "Off";
printf("Line Prot/Pkg:\t\t");
@@ -659,10 +695,11 @@ void print_line_prot()
if (status.line_pkg == PKG_SPPP)
printf("SPPP Keep-alives:\t%s\n",
config.keep_alive ? on : off);
- }
+}
-void print_crc_len()
- {
+static void
+print_crc_len(void)
+{
printf("CRC length:\t\t");
if (config.crc_len == CFG_CRC_0)
printf("no CRC\n");
@@ -672,10 +709,11 @@ void print_crc_len()
printf("32 bits\n");
else
printf("bad crc_len: %d\n", config.crc_len);
- }
+}
-void print_loop_back()
- {
+static void
+print_loop_back(void)
+{
printf("Loopback:\t\t");
switch (config.loop_back)
{
@@ -713,10 +751,11 @@ void print_loop_back()
printf("unknown loop_back: %d\n", config.loop_back);
break;
}
- }
+}
-void print_tx_clk_src()
- {
+static void
+print_tx_clk_src(void)
+{
printf("Tx Clk src:\t\t");
switch (config.tx_clk_src)
{
@@ -736,10 +775,11 @@ void print_tx_clk_src()
printf("unknown tx_clk_src: %d\n", config.tx_clk_src);
break;
}
- }
+}
-void print_format()
- {
+static void
+print_format(void)
+{
printf("Format-Frame/Code:\t");
switch (config.format)
{
@@ -774,10 +814,11 @@ void print_format()
printf("unknown format: %d\n", config.format);
break;
}
- }
+}
-void print_dte_dce()
- {
+static void
+print_dte_dce(void)
+{
printf("DTE or DCE:\t\t");
switch(config.dte_dce)
{
@@ -791,10 +832,11 @@ void print_dte_dce()
printf("unknown dte_dce: %d\n", config.dte_dce);
break;
}
- }
+}
-void print_synth_freq()
- {
+static void
+print_synth_freq(void)
+{
double Fref = 20e6;
double Fout, Fvco;
@@ -803,10 +845,11 @@ void print_synth_freq()
Fout = Fvco / (1<<(config.synth.x+config.synth.r+config.synth.prescale));
printf("Synth freq:\t\t%.0f\n", Fout);
- }
+}
-void synth_freq(unsigned long target)
- {
+static void
+synth_freq(unsigned long target)
+{
unsigned int n, m, v, x, r;
double Fout, Fvco, Ftarg;
double newdiff, olddiff;
@@ -849,29 +892,33 @@ void synth_freq(unsigned long target)
printf("N=%u, M=%u, V=%u, X=%u, R=%u\n", config.synth.n,
config.synth.m, config.synth.v, config.synth.x, config.synth.r);
#endif
- }
+}
-void print_cable_len()
- {
+static void
+print_cable_len(void)
+{
printf("Cable length:\t\t%d meters\n", config.cable_len);
- }
+}
-void print_cable_type()
- {
+static void
+print_cable_type(void)
+{
printf("Cable type:\t\t");
if (status.cable_type > 7)
printf("unknown cable_type: %d\n", status.cable_type);
else
printf("%s\n", ssi_cables[status.cable_type]);
- }
+}
-void print_time_slots()
- {
+static void
+print_time_slots(void)
+{
printf("TimeSlot [31-0]:\t0x%08X\n", config.time_slots);
- }
+}
-void print_scrambler()
- {
+static void
+print_scrambler(void)
+{
printf("Scrambler:\t\t");
if (config.scrambler == CFG_SCRAM_OFF)
printf("off\n");
@@ -881,21 +928,22 @@ void print_scrambler()
printf("Larse: X^20+X^17+1 w/28ZS\n");
else
printf("unknown scrambler: %d\n", config.scrambler);
- }
+}
-double vga_dbs(u_int8_t vga)
- {
+static double
+vga_dbs(u_int8_t vga)
+{
if (vga < 0x0F) return 0.0;
if ((vga >= 0x0F) && (vga <= 0x1B)) return 0.0 + 0.77 * (vga - 0x0F);
if ((vga >= 0x1C) && (vga <= 0x33)) return 10.0 + 1.25 * (vga - 0x1C);
if ((vga >= 0x34) && (vga <= 0x39)) return 40.0 + 1.67 * (vga - 0x34);
- if ((vga >= 0x3A) && (vga <= 0x3F)) return 50.0 + 2.80 * (vga - 0x3A);
- if (vga > 0x3F) return 64.0;
- return 0.0; /* suppress compiler warning */
- }
+ if ((vga >= 0x3A) && (vga < 0x3F)) return 50.0 + 2.80 * (vga - 0x3A);
+ return 64.0;
+}
-void print_rx_gain()
- {
+static void
+print_rx_gain(void)
+{
printf("Rx gain max:\t\t");
if (config.rx_gain == CFG_GAIN_AUTO)
@@ -903,10 +951,11 @@ void print_rx_gain()
vga_dbs(read_framer(Bt8370_VGA_MAX) & 0x3F));
else
printf("up to %02.1f dB\n", vga_dbs(config.rx_gain));
- }
+}
-void print_tx_lbo()
- {
+static void
+print_tx_lbo(void)
+{
u_int8_t saved_lbo = config.tx_lbo;
printf("LBO = ");
@@ -937,10 +986,11 @@ void print_tx_lbo()
if (saved_lbo == CFG_LBO_AUTO)
config.tx_lbo = saved_lbo;
- }
+}
-void print_tx_pulse()
- {
+static void
+print_tx_pulse(void)
+{
u_int8_t saved_pulse = config.tx_pulse;
printf("Tx pulse shape:\t\t");
@@ -984,10 +1034,11 @@ void print_tx_pulse()
if (saved_pulse == CFG_PULSE_AUTO)
config.tx_pulse = saved_pulse;
- }
+}
-void print_ssi_sigs()
- {
+static void
+print_ssi_sigs(void)
+{
u_int32_t mii16 = status.snmp.ssi.sigs;
char *on = "On", *off = "Off";
@@ -1002,10 +1053,11 @@ void print_ssi_sigs()
(mii16 & MII16_SSI_LL) ? on : off,
(mii16 & MII16_SSI_RL) ? on : off,
(mii16 & MII16_SSI_TM) ? on : off);
- }
+}
-void print_hssi_sigs()
- {
+static void
+print_hssi_sigs(void)
+{
u_int32_t mii16 = status.snmp.hssi.sigs;
char *on = "On", *off = "Off";
@@ -1017,10 +1069,11 @@ void print_hssi_sigs()
(mii16 & MII16_HSSI_LB) ? on : off,
(mii16 & MII16_HSSI_LC) ? on : off,
(mii16 & MII16_HSSI_TM) ? on : off);
- }
+}
-void print_events()
- {
+static void
+print_events(void)
+{
char *time;
struct timeval tv;
struct timezone tz;
@@ -1034,10 +1087,10 @@ void print_events()
time = (char *)ctime((time_t *)&status.cntrs.reset_time.tv_sec);
printf("Cntrs reset:\t\t%s", time);
- if (status.cntrs.ibytes) printf("Rx bytes:\t\t%qu\n", status.cntrs.ibytes);
- if (status.cntrs.obytes) printf("Tx bytes:\t\t%qu\n", status.cntrs.obytes);
- if (status.cntrs.ipackets) printf("Rx packets:\t\t%qu\n", status.cntrs.ipackets);
- if (status.cntrs.opackets) printf("Tx packets:\t\t%qu\n", status.cntrs.opackets);
+ if (status.cntrs.ibytes) printf("Rx bytes:\t\t%ju\n", (uintmax_t)status.cntrs.ibytes);
+ if (status.cntrs.obytes) printf("Tx bytes:\t\t%ju\n", (uintmax_t)status.cntrs.obytes);
+ if (status.cntrs.ipackets) printf("Rx packets:\t\t%ju\n", (uintmax_t)status.cntrs.ipackets);
+ if (status.cntrs.opackets) printf("Tx packets:\t\t%ju\n", (uintmax_t)status.cntrs.opackets);
if (status.cntrs.ierrors) printf("Rx errors:\t\t%u\n", status.cntrs.ierrors);
if (status.cntrs.oerrors) printf("Tx errors:\t\t%u\n", status.cntrs.oerrors);
if (status.cntrs.idiscards) printf("Rx discards:\t\t%u\n", status.cntrs.idiscards);
@@ -1062,10 +1115,11 @@ void print_events()
if (status.cntrs.lck_ioctl) printf("Lck ioctl:\t\t%u\n", status.cntrs.lck_ioctl);
if (status.cntrs.lck_intr) printf("Lck intr:\t\t%u\n", status.cntrs.lck_intr);
}
- }
+}
-void print_summary()
- {
+static void
+print_summary(void)
+{
switch(status.card_type)
{
case TLP_CSID_HSSI:
@@ -1158,10 +1212,11 @@ void print_summary()
break;
}
}
- }
+}
-char *print_t3_bop(int bop_code)
- {
+static char *
+print_t3_bop(int bop_code)
+{
switch(bop_code)
{
case 0x00:
@@ -1181,10 +1236,11 @@ char *print_t3_bop(int bop_code)
default:
return "Unknown BOP code";
}
- }
+}
-void print_t3_snmp()
- {
+static void
+print_t3_snmp(void)
+{
printf("SNMP performance data:\n");
printf(" LCV=%d", status.snmp.t3.lcv);
printf(" LOS=%d", (status.snmp.t3.line & TLINE_LOS) ? 1 : 0);
@@ -1196,10 +1252,11 @@ void print_t3_snmp()
printf(" FEBE=%d", status.snmp.t3.febe);
printf(" RAI=%d", (status.snmp.t3.line & TLINE_RX_RAI) ? 1 : 0);
printf("\n");
- }
+}
-void print_t3_dsu()
- {
+static void
+print_t3_dsu(void)
+{
char *no = "No", *yes = "Yes";
u_int16_t mii16 = read_mii(16);
u_int8_t ctl1 = read_framer(T3CSR_CTL1);
@@ -1244,10 +1301,11 @@ void print_t3_dsu()
read_framer(T3CSR_RX_FEAC) & 0x3F,
print_t3_bop(read_framer(T3CSR_RX_FEAC) & 0x3F));
print_t3_snmp();
- }
+}
-void t3_cmd(int argc, char **argv)
- {
+static void
+t3_cmd(int argc, char **argv)
+{
int ch;
while ((ch = getopt(argc, argv, "a:A:B:c:de:fF:lLsS:vV:")) != -1)
@@ -1428,10 +1486,11 @@ void t3_cmd(int argc, char **argv)
} /* case */
} /* switch */
} /* while */
- } /* proc */
+} /* proc */
-void print_test_pattern(int patt)
- {
+static void
+print_test_pattern(int patt)
+{
printf("Test Pattern:\t\t");
switch (patt)
{
@@ -1484,10 +1543,11 @@ void print_test_pattern(int patt)
printf("framed X^23+X^18+1 w/14ZS\n");
break;
}
- }
+}
-char *print_t1_bop(int bop_code)
- {
+static char *
+print_t1_bop(int bop_code)
+{
switch(bop_code)
{
case 0x00:
@@ -1507,10 +1567,11 @@ char *print_t1_bop(int bop_code)
default:
return "Unknown BOP code";
}
- }
+}
-void print_far_report(int index)
- {
+static void
+print_far_report(int index)
+{
u_int16_t far = status.snmp.t1.prm[index];
printf(" SEQ=%d ", (far & T1PRM_SEQ)>>8);
@@ -1527,10 +1588,11 @@ void print_far_report(int index)
printf(" SL=%d", (far & T1PRM_SL) ? 1 : 0);
printf(" LB=%d", (far & T1PRM_LB) ? 1 : 0);
printf("\n");
- }
+}
-void print_t1_snmp()
- {
+static void
+print_t1_snmp(void)
+{
printf("SNMP Near-end performance data:\n");
printf(" LCV=%d", status.snmp.t1.lcv);
printf(" LOS=%d", (status.snmp.t1.line & TLINE_LOS) ? 1 : 0);
@@ -1549,10 +1611,11 @@ void print_t1_snmp()
print_far_report(2);
print_far_report(3);
}
- }
+}
-void print_t1_dsu()
- {
+static void
+print_t1_dsu(void)
+{
char *no = "No", *yes = "Yes";
u_int16_t mii16 = read_mii(16);
u_int8_t isr0 = read_framer(Bt8370_ISR0);
@@ -1639,10 +1702,11 @@ void print_t1_dsu()
read_framer(Bt8370_RBOP), print_t1_bop(read_framer(Bt8370_RBOP)&0x3F));
}
print_t1_snmp();
- }
+}
-void t1_cmd(int argc, char **argv)
- {
+static void
+t1_cmd(int argc, char **argv)
+{
int ch;
while ((ch = getopt(argc, argv, "a:A:B:c:de:E:fF:g:iIlLpPstT:u:U:vxX")) != -1)
@@ -1919,11 +1983,12 @@ void t1_cmd(int argc, char **argv)
} /* case */
} /* switch */
} /* while */
- } /* proc */
+} /* proc */
/* used when reading Motorola S-Record format ROM files */
-unsigned char read_hex(FILE *f)
- {
+static unsigned char
+read_hex(FILE *f)
+{
unsigned char a, b, c;
for (a=0, b=0; a<2; a++)
{
@@ -1934,14 +1999,15 @@ unsigned char read_hex(FILE *f)
}
checksum += b;
return b;
- }
+}
-static void load_xilinx(char *name)
- {
+static void
+load_xilinx(char *name)
+{
FILE *f;
char *ucode;
int i, length;
- char c;
+ int c;
if (verbose) printf("Load firmware from file %s...\n", name);
if ((f = fopen(name, "r")) == 0)
@@ -2011,11 +2077,12 @@ static void load_xilinx(char *name)
}
load_xilinx_from_file(ucode, length);
- }
+}
/* 32-bit CRC calculated right-to-left over 8-bit bytes */
-u_int32_t crc32(char *bufp, int len)
- {
+static u_int32_t
+crc32(char *bufp, int len)
+{
int bit, i;
u_int32_t data;
u_int32_t crc = 0xFFFFFFFFL;
@@ -2026,11 +2093,12 @@ u_int32_t crc32(char *bufp, int len)
crc = (crc >> 1) ^ (((crc ^ data) & 1) ? poly : 0);
return crc;
- }
+}
/* 8-bit CRC calculated left-to-right over 16-bit words */
-u_int8_t crc8(u_int16_t *bufp, int len)
- {
+static u_int8_t
+crc8(u_int16_t *bufp, int len)
+{
int bit, i;
u_int16_t data;
u_int8_t crc = 0xFF;
@@ -2043,11 +2111,12 @@ u_int8_t crc8(u_int16_t *bufp, int len)
crc = (crc << 1) ^ ((((crc >> 7) ^ (data >> bit)) & 1) ? poly : 0);
}
return crc;
- }
+}
/* HSSI=3, DS3=4, SSI=5, T1E1=6, HSSIc=7, SDSL=8 */
-void init_srom(int board)
- {
+void
+init_srom(int board)
+{
int i;
u_int16_t srom[64];
@@ -2076,10 +2145,11 @@ void init_srom(int board)
}
printf("\n\n");
#endif
- }
+}
-int main(int argc, char **argv)
- {
+int
+main(int argc, char **argv)
+{
int i, error, ch;
char *optstring = "13a:bBcCdDeEf:Fhi:L:mM:pP:sS:tT:uUvVwW:xXyYzZ?";
@@ -2482,4 +2552,4 @@ int main(int argc, char **argv)
if (update) ioctl_write_config();
exit(0);
- }
+}
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index 62df9d3..061b370 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h
index 63f2ff1..b7ebff6 100644
--- a/usr.sbin/lpr/common_source/lp.h
+++ b/usr.sbin/lpr/common_source/lp.h
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/common_source/lp.local.h b/usr.sbin/lpr/common_source/lp.local.h
index 6f018b0..79cc52a 100644
--- a/usr.sbin/lpr/common_source/lp.local.h
+++ b/usr.sbin/lpr/common_source/lp.local.h
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/common_source/pathnames.h b/usr.sbin/lpr/common_source/pathnames.h
index 78ccc7b..0be302a 100644
--- a/usr.sbin/lpr/common_source/pathnames.h
+++ b/usr.sbin/lpr/common_source/pathnames.h
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
@@ -30,6 +26,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
+ * $FreeBSD$
+ *
* @(#)pathnames.h 8.1 (Berkeley) 6/6/93
*/
diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c
index 33fcdac..2a6b0e9 100644
--- a/usr.sbin/lpr/common_source/rmjob.c
+++ b/usr.sbin/lpr/common_source/rmjob.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/common_source/startdaemon.c b/usr.sbin/lpr/common_source/startdaemon.c
index 08c2e6f..b175d79 100644
--- a/usr.sbin/lpr/common_source/startdaemon.c
+++ b/usr.sbin/lpr/common_source/startdaemon.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/filters/lpf.c b/usr.sbin/lpr/filters/lpf.c
index 41879a2..f88752a 100644
--- a/usr.sbin/lpr/filters/lpf.c
+++ b/usr.sbin/lpr/filters/lpf.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpc/cmds.c b/usr.sbin/lpr/lpc/cmds.c
index 06ea4b0..f8843f9 100644
--- a/usr.sbin/lpr/lpc/cmds.c
+++ b/usr.sbin/lpr/lpc/cmds.c
@@ -11,10 +11,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpc/cmdtab.c b/usr.sbin/lpr/lpc/cmdtab.c
index 21dc6e1c..1e8e4da 100644
--- a/usr.sbin/lpr/lpc/cmdtab.c
+++ b/usr.sbin/lpr/lpc/cmdtab.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpc/extern.h b/usr.sbin/lpr/lpc/extern.h
index fe82d46..45844a5 100644
--- a/usr.sbin/lpr/lpc/extern.h
+++ b/usr.sbin/lpr/lpc/extern.h
@@ -11,10 +11,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpc/lpc.8 b/usr.sbin/lpr/lpc/lpc.8
index ea79241..5a66865 100644
--- a/usr.sbin/lpr/lpc/lpc.8
+++ b/usr.sbin/lpr/lpc/lpc.8
@@ -9,10 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c
index fda77aa..bd95c59 100644
--- a/usr.sbin/lpr/lpc/lpc.c
+++ b/usr.sbin/lpr/lpc/lpc.c
@@ -11,10 +11,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpc/lpc.h b/usr.sbin/lpr/lpc/lpc.h
index 73e4cc5..ee52903 100644
--- a/usr.sbin/lpr/lpc/lpc.h
+++ b/usr.sbin/lpr/lpc/lpc.h
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpd/extern.h b/usr.sbin/lpr/lpd/extern.h
index 14cb9e1..90eb0be 100644
--- a/usr.sbin/lpr/lpd/extern.h
+++ b/usr.sbin/lpr/lpd/extern.h
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpd/lpd.8 b/usr.sbin/lpr/lpd/lpd.8
index 7c7afab..34b0882 100644
--- a/usr.sbin/lpr/lpd/lpd.8
+++ b/usr.sbin/lpr/lpd/lpd.8
@@ -9,10 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index 087d5d1..4aa49ca 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -11,10 +11,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpd/lpdchar.c b/usr.sbin/lpr/lpd/lpdchar.c
index 5ebaabd..cb9f355 100644
--- a/usr.sbin/lpr/lpd/lpdchar.c
+++ b/usr.sbin/lpr/lpd/lpdchar.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpd/modes.c b/usr.sbin/lpr/lpd/modes.c
index 8a05212..52f1229 100644
--- a/usr.sbin/lpr/lpd/modes.c
+++ b/usr.sbin/lpr/lpd/modes.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index 7b50f65..2bc211c 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -11,10 +11,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c
index a76bb6d..ec8834c 100644
--- a/usr.sbin/lpr/lpd/recvjob.c
+++ b/usr.sbin/lpr/lpd/recvjob.c
@@ -11,10 +11,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpq/lpq.1 b/usr.sbin/lpr/lpq/lpq.1
index 7d682f3..0efc982 100644
--- a/usr.sbin/lpr/lpq/lpq.1
+++ b/usr.sbin/lpr/lpq/lpq.1
@@ -9,10 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/lpr/lpq/lpq.c b/usr.sbin/lpr/lpq/lpq.c
index e1809cf..33082e5 100644
--- a/usr.sbin/lpr/lpq/lpq.c
+++ b/usr.sbin/lpr/lpq/lpq.c
@@ -11,10 +11,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lpr/lpr.1 b/usr.sbin/lpr/lpr/lpr.1
index 00146ac..00695b9 100644
--- a/usr.sbin/lpr/lpr/lpr.1
+++ b/usr.sbin/lpr/lpr/lpr.1
@@ -9,10 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/lpr/lpr/printcap.5 b/usr.sbin/lpr/lpr/printcap.5
index 4434429..60e5520 100644
--- a/usr.sbin/lpr/lpr/printcap.5
+++ b/usr.sbin/lpr/lpr/printcap.5
@@ -9,10 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/lpr/lprm/lprm.1 b/usr.sbin/lpr/lprm/lprm.1
index 6f9d03d..9a8c640 100644
--- a/usr.sbin/lpr/lprm/lprm.1
+++ b/usr.sbin/lpr/lprm/lprm.1
@@ -9,10 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/lpr/lprm/lprm.c b/usr.sbin/lpr/lprm/lprm.c
index 47f233c..741a8fa 100644
--- a/usr.sbin/lpr/lprm/lprm.c
+++ b/usr.sbin/lpr/lprm/lprm.c
@@ -11,10 +11,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/lptest/lptest.1 b/usr.sbin/lpr/lptest/lptest.1
index c34934e..53fb98e 100644
--- a/usr.sbin/lpr/lptest/lptest.1
+++ b/usr.sbin/lpr/lptest/lptest.1
@@ -9,10 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/lpr/lptest/lptest.c b/usr.sbin/lpr/lptest/lptest.c
index 3042963..07c90d7 100644
--- a/usr.sbin/lpr/lptest/lptest.c
+++ b/usr.sbin/lpr/lptest/lptest.c
@@ -11,10 +11,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/lpr/pac/pac.8 b/usr.sbin/lpr/pac/pac.8
index b6e10a0..17777de 100644
--- a/usr.sbin/lpr/pac/pac.8
+++ b/usr.sbin/lpr/pac/pac.8
@@ -9,10 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/lpr/pac/pac.c b/usr.sbin/lpr/pac/pac.c
index 34a247f..9cc9708 100644
--- a/usr.sbin/lpr/pac/pac.c
+++ b/usr.sbin/lpr/pac/pac.c
@@ -11,10 +11,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c
index 4f3fded..a3c9d68 100644
--- a/usr.sbin/makefs/ffs.c
+++ b/usr.sbin/makefs/ffs.c
@@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
#include "makefs.h"
diff --git a/usr.sbin/makefs/makefs.c b/usr.sbin/makefs/makefs.c
index f2420b6..60b6916 100644
--- a/usr.sbin/makefs/makefs.c
+++ b/usr.sbin/makefs/makefs.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
#include "makefs.h"
diff --git a/usr.sbin/mld6query/mld6.c b/usr.sbin/mld6query/mld6.c
index 1f73203..53f38ae 100644
--- a/usr.sbin/mld6query/mld6.c
+++ b/usr.sbin/mld6query/mld6.c
@@ -1,5 +1,4 @@
/* $KAME: mld6.c,v 1.15 2003/04/02 11:29:54 suz Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (C) 1998 WIDE Project.
@@ -29,6 +28,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/param.h>
#include <sys/uio.h>
#include <sys/socket.h>
@@ -330,9 +333,8 @@ dump(int s)
fflush(stdout);
}
-/* ARGSUSED */
void
-quit(int signum)
+quit(int signum __unused)
{
mreq.ipv6mr_multiaddr = any;
mreq.ipv6mr_interface = ifindex;
@@ -344,7 +346,7 @@ quit(int signum)
}
void
-usage()
+usage(void)
{
(void)fprintf(stderr, "usage: mld6query ifname [addr]\n");
exit(1);
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 41a845f..1b98c7d 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -196,6 +196,7 @@ void mntsrv(struct svc_req *, SVCXPRT *);
void nextfield(char **, char **);
void out_of_mem(void);
void parsecred(char *, struct xucred *);
+int parsesec(char *, struct exportlist *);
int put_exlist(struct dirlist *, XDR *, struct dirlist *, int *, int);
void *sa_rawaddr(struct sockaddr *sa, int *nbytes);
int sacmp(struct sockaddr *sa1, struct sockaddr *sa2,
@@ -205,6 +206,7 @@ static void usage(void);
int xdr_dir(XDR *, char *);
int xdr_explist(XDR *, caddr_t);
int xdr_explist_brief(XDR *, caddr_t);
+int xdr_explist_common(XDR *, caddr_t, int);
int xdr_fhs(XDR *, caddr_t);
int xdr_mlist(XDR *, caddr_t);
void terminate(int);
@@ -269,9 +271,7 @@ int debug = 0;
* and "-n" to allow nonroot mount.
*/
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char **argv)
{
fd_set readfds;
struct netconfig *nconf;
@@ -729,7 +729,7 @@ create_service(struct netconfig *nconf)
}
static void
-usage()
+usage(void)
{
fprintf(stderr,
"usage: mountd [-2] [-d] [-e] [-l] [-n] [-p <port>] [-r] "
@@ -741,9 +741,7 @@ usage()
* The mount rpc service
*/
void
-mntsrv(rqstp, transp)
- struct svc_req *rqstp;
- SVCXPRT *transp;
+mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
{
struct exportlist *ep;
struct dirlist *dp;
@@ -949,9 +947,7 @@ mntsrv(rqstp, transp)
* Xdr conversion for a dirpath string
*/
int
-xdr_dir(xdrsp, dirp)
- XDR *xdrsp;
- char *dirp;
+xdr_dir(XDR *xdrsp, char *dirp)
{
return (xdr_string(xdrsp, &dirp, MNTPATHLEN));
}
@@ -960,9 +956,7 @@ xdr_dir(xdrsp, dirp)
* Xdr routine to generate file handle reply
*/
int
-xdr_fhs(xdrsp, cp)
- XDR *xdrsp;
- caddr_t cp;
+xdr_fhs(XDR *xdrsp, caddr_t cp)
{
struct fhreturn *fhrp = (struct fhreturn *)cp;
u_long ok = 0, len, auth;
@@ -998,9 +992,7 @@ xdr_fhs(xdrsp, cp)
}
int
-xdr_mlist(xdrsp, cp)
- XDR *xdrsp;
- caddr_t cp;
+xdr_mlist(XDR *xdrsp, caddr_t cp __unused)
{
struct mountlist *mlp;
int true = 1;
@@ -1028,10 +1020,7 @@ xdr_mlist(xdrsp, cp)
* Xdr conversion for export list
*/
int
-xdr_explist_common(xdrsp, cp, brief)
- XDR *xdrsp;
- caddr_t cp;
- int brief;
+xdr_explist_common(XDR *xdrsp, caddr_t cp __unused, int brief)
{
struct exportlist *ep;
int false = 0;
@@ -1067,12 +1056,8 @@ errout:
* directory paths.
*/
int
-put_exlist(dp, xdrsp, adp, putdefp, brief)
- struct dirlist *dp;
- XDR *xdrsp;
- struct dirlist *adp;
- int *putdefp;
- int brief;
+put_exlist(struct dirlist *dp, XDR *xdrsp, struct dirlist *adp, int *putdefp,
+ int brief)
{
struct grouplist *grp;
struct hostlist *hp;
@@ -1135,18 +1120,14 @@ put_exlist(dp, xdrsp, adp, putdefp, brief)
}
int
-xdr_explist(xdrsp, cp)
- XDR *xdrsp;
- caddr_t cp;
+xdr_explist(XDR *xdrsp, caddr_t cp)
{
return xdr_explist_common(xdrsp, cp, 0);
}
int
-xdr_explist_brief(xdrsp, cp)
- XDR *xdrsp;
- caddr_t cp;
+xdr_explist_brief(XDR *xdrsp, caddr_t cp)
{
return xdr_explist_common(xdrsp, cp, 1);
@@ -1160,7 +1141,7 @@ FILE *exp_file;
* Get the export list from one, currently open file
*/
static void
-get_exportlist_one()
+get_exportlist_one(void)
{
struct exportlist *ep, *ep2;
struct grouplist *grp, *tgrp;
@@ -1470,7 +1451,7 @@ nextline:
* Get the export list from all specified files
*/
void
-get_exportlist()
+get_exportlist(void)
{
struct exportlist *ep, *ep2;
struct grouplist *grp, *tgrp;
@@ -1621,7 +1602,7 @@ get_exportlist()
* Allocate an export list element
*/
struct exportlist *
-get_exp()
+get_exp(void)
{
struct exportlist *ep;
@@ -1636,7 +1617,7 @@ get_exp()
* Allocate a group list element
*/
struct grouplist *
-get_grp()
+get_grp(void)
{
struct grouplist *gp;
@@ -1651,9 +1632,7 @@ get_grp()
* Clean up upon an error in get_exportlist().
*/
void
-getexp_err(ep, grp)
- struct exportlist *ep;
- struct grouplist *grp;
+getexp_err(struct exportlist *ep, struct grouplist *grp)
{
struct grouplist *tgrp;
@@ -1672,8 +1651,7 @@ getexp_err(ep, grp)
* Search the export list for a matching fs.
*/
struct exportlist *
-ex_search(fsid)
- fsid_t *fsid;
+ex_search(fsid_t *fsid)
{
struct exportlist *ep;
@@ -1691,10 +1669,7 @@ ex_search(fsid)
* Add a directory path to the list.
*/
char *
-add_expdir(dpp, cp, len)
- struct dirlist **dpp;
- char *cp;
- int len;
+add_expdir(struct dirlist **dpp, char *cp, int len)
{
struct dirlist *dp;
@@ -1715,11 +1690,8 @@ add_expdir(dpp, cp, len)
* and update the entry for host.
*/
void
-hang_dirp(dp, grp, ep, flags)
- struct dirlist *dp;
- struct grouplist *grp;
- struct exportlist *ep;
- int flags;
+hang_dirp(struct dirlist *dp, struct grouplist *grp, struct exportlist *ep,
+ int flags)
{
struct hostlist *hp;
struct dirlist *dp2;
@@ -1756,11 +1728,8 @@ hang_dirp(dp, grp, ep, flags)
* for the new directory or adding the new node.
*/
void
-add_dlist(dpp, newdp, grp, flags)
- struct dirlist **dpp;
- struct dirlist *newdp;
- struct grouplist *grp;
- int flags;
+add_dlist(struct dirlist **dpp, struct dirlist *newdp, struct grouplist *grp,
+ int flags)
{
struct dirlist *dp;
struct hostlist *hp;
@@ -1803,9 +1772,7 @@ add_dlist(dpp, newdp, grp, flags)
* Search for a dirpath on the export point.
*/
struct dirlist *
-dirp_search(dp, dirp)
- struct dirlist *dp;
- char *dirp;
+dirp_search(struct dirlist *dp, char *dirp)
{
int cmp;
@@ -1825,11 +1792,8 @@ dirp_search(dp, dirp)
* Scan for a host match in a directory tree.
*/
int
-chk_host(dp, saddr, defsetp, hostsetp)
- struct dirlist *dp;
- struct sockaddr *saddr;
- int *defsetp;
- int *hostsetp;
+chk_host(struct dirlist *dp, struct sockaddr *saddr, int *defsetp,
+ int *hostsetp)
{
struct hostlist *hp;
struct grouplist *grp;
@@ -1872,9 +1836,7 @@ chk_host(dp, saddr, defsetp, hostsetp)
* Scan tree for a host that matches the address.
*/
int
-scan_tree(dp, saddr)
- struct dirlist *dp;
- struct sockaddr *saddr;
+scan_tree(struct dirlist *dp, struct sockaddr *saddr)
{
int defset, hostset;
@@ -1893,8 +1855,7 @@ scan_tree(dp, saddr)
* Traverse the dirlist tree and free it up.
*/
void
-free_dir(dp)
- struct dirlist *dp;
+free_dir(struct dirlist *dp)
{
if (dp) {
@@ -1909,9 +1870,7 @@ free_dir(dp)
* Parse a colon separated list of security flavors
*/
int
-parsesec(seclist, ep)
- char *seclist;
- struct exportlist *ep;
+parsesec(char *seclist, struct exportlist *ep)
{
char *cp, savedc;
int flavor;
@@ -1962,13 +1921,8 @@ parsesec(seclist, ep)
* -<option> <value>
*/
int
-do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
- char **cpp, **endcpp;
- struct exportlist *ep;
- struct grouplist *grp;
- int *has_hostp;
- int *exflagsp;
- struct xucred *cr;
+do_opt(char **cpp, char **endcpp, struct exportlist *ep, struct grouplist *grp,
+ int *has_hostp, int *exflagsp, struct xucred *cr)
{
char *cpoptarg, *cpoptend;
char *cp, *endcp, *cpopt, savedc, savedc2;
@@ -2080,10 +2034,7 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
* addresses for a hostname.
*/
int
-get_host(cp, grp, tgrp)
- char *cp;
- struct grouplist *grp;
- struct grouplist *tgrp;
+get_host(char *cp, struct grouplist *grp, struct grouplist *tgrp)
{
struct grouplist *checkgrp;
struct addrinfo *ai, *tai, hints;
@@ -2143,8 +2094,7 @@ get_host(cp, grp, tgrp)
* Free up an exports list component
*/
void
-free_exp(ep)
- struct exportlist *ep;
+free_exp(struct exportlist *ep)
{
if (ep->ex_defdir) {
@@ -2163,8 +2113,7 @@ free_exp(ep)
* Free hosts.
*/
void
-free_host(hp)
- struct hostlist *hp;
+free_host(struct hostlist *hp)
{
struct hostlist *hp2;
@@ -2176,7 +2125,7 @@ free_host(hp)
}
struct hostlist *
-get_ht()
+get_ht(void)
{
struct hostlist *hp;
@@ -2192,7 +2141,7 @@ get_ht()
* Out of memory, fatal
*/
void
-out_of_mem()
+out_of_mem(void)
{
syslog(LOG_ERR, "out of memory");
@@ -2438,10 +2387,7 @@ error_exit:
* If `maskflg' is nonzero, then `cp' is a netmask, not a network address.
*/
int
-get_net(cp, net, maskflg)
- char *cp;
- struct netmsk *net;
- int maskflg;
+get_net(char *cp, struct netmsk *net, int maskflg)
{
struct netent *np = NULL;
char *name, *p, *prefp;
@@ -2571,9 +2517,7 @@ fail:
* Parse out the next white space separated field
*/
void
-nextfield(cp, endcp)
- char **cp;
- char **endcp;
+nextfield(char **cp, char **endcp)
{
char *p;
@@ -2595,7 +2539,7 @@ nextfield(cp, endcp)
* continuations.
*/
int
-get_line()
+get_line(void)
{
char *p, *cp;
size_t len;
@@ -2639,9 +2583,7 @@ get_line()
* Parse a description of a credential.
*/
void
-parsecred(namelist, cr)
- char *namelist;
- struct xucred *cr;
+parsecred(char *namelist, struct xucred *cr)
{
char *name;
int cnt;
@@ -2722,7 +2664,7 @@ parsecred(namelist, cr)
* Routines that maintain the remote mounttab
*/
void
-get_mountlist()
+get_mountlist(void)
{
struct mountlist *mlp, **mlpp;
char *host, *dirp, *cp;
@@ -2795,8 +2737,7 @@ del_mlist(char *hostp, char *dirp)
}
void
-add_mlist(hostp, dirp)
- char *hostp, *dirp;
+add_mlist(char *hostp, char *dirp)
{
struct mountlist *mlp, **mlpp;
FILE *mlfile;
@@ -2830,8 +2771,7 @@ add_mlist(hostp, dirp)
* Free up a group list.
*/
void
-free_grp(grp)
- struct grouplist *grp;
+free_grp(struct grouplist *grp)
{
if (grp->gr_type == GT_HOST) {
if (grp->gr_ptr.gt_addrinfo != NULL)
@@ -2859,8 +2799,7 @@ SYSLOG(int pri, const char *fmt, ...)
* Check options for consistency.
*/
int
-check_options(dp)
- struct dirlist *dp;
+check_options(struct dirlist *dp)
{
if (v4root_phase == 0 && dp == NULL)
@@ -2898,8 +2837,7 @@ check_options(dp)
* Check an absolute directory path for any symbolic links. Return true
*/
int
-check_dirpath(dirp)
- char *dirp;
+check_dirpath(char *dirp)
{
char *cp;
int ret = 1;
@@ -3039,13 +2977,12 @@ sa_rawaddr(struct sockaddr *sa, int *nbytes) {
}
void
-huphandler(int sig)
+huphandler(int sig __unused)
{
got_sighup = 1;
}
-void terminate(sig)
-int sig;
+void terminate(int sig __unused)
{
pidfile_remove(pfh);
rpcb_unset(MOUNTPROG, MOUNTVERS, NULL);
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index 6926a27..1f62230 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -153,7 +153,6 @@ static void getdefif(void);
static void setdefif(char *);
#endif
static char *sec2str(time_t);
-static char *ether_str(struct sockaddr_dl *);
static void ts_print(const struct timeval *);
#ifdef ICMPV6CTL_ND6_DRLIST
@@ -820,17 +819,14 @@ getnbrinfo(addr, ifindex, warning)
}
static char *
-ether_str(sdl)
- struct sockaddr_dl *sdl;
+ether_str(struct sockaddr_dl *sdl)
{
static char hbuf[NI_MAXHOST];
- u_char *cp;
- if (sdl->sdl_alen) {
- cp = (u_char *)LLADDR(sdl);
- snprintf(hbuf, sizeof(hbuf), "%x:%x:%x:%x:%x:%x",
- cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]);
- } else
+ if (sdl->sdl_alen > 0)
+ strlcpy(hbuf, ether_ntoa((struct ether_addr *)LLADDR(sdl)),
+ sizeof(hbuf));
+ else
snprintf(hbuf, sizeof(hbuf), "(incomplete)");
return(hbuf);
diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8
index 312080b..d7dae49 100644
--- a/usr.sbin/newsyslog/newsyslog.8
+++ b/usr.sbin/newsyslog/newsyslog.8
@@ -17,7 +17,7 @@
.\" the suitability of this software for any purpose. It is
.\" provided "as is" without express or implied warranty.
.\"
-.Dd July 23, 2010
+.Dd January 31, 2011
.Dt NEWSYSLOG 8
.Os
.Sh NAME
@@ -279,6 +279,7 @@ accepted for backwards compatibility.
.Sh SEE ALSO
.Xr bzip2 1 ,
.Xr gzip 1 ,
+.Xr xz 1 ,
.Xr syslog 3 ,
.Xr newsyslog.conf 5 ,
.Xr chown 8 ,
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index 46158ef..b04cf1d 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -57,12 +57,6 @@
__FBSDID("$FreeBSD$");
#define OSF
-#ifndef COMPRESS_POSTFIX
-#define COMPRESS_POSTFIX ".gz"
-#endif
-#ifndef BZCOMPRESS_POSTFIX
-#define BZCOMPRESS_POSTFIX ".bz2"
-#endif
#include <sys/param.h>
#include <sys/queue.h>
@@ -92,10 +86,35 @@ __FBSDID("$FreeBSD$");
#include "extern.h"
/*
+ * Compression suffixes
+ */
+#ifndef COMPRESS_SUFFIX_GZ
+#define COMPRESS_SUFFIX_GZ ".gz"
+#endif
+
+#ifndef COMPRESS_SUFFIX_BZ2
+#define COMPRESS_SUFFIX_BZ2 ".bz2"
+#endif
+
+#ifndef COMPRESS_SUFFIX_XZ
+#define COMPRESS_SUFFIX_XZ ".xz"
+#endif
+
+#define COMPRESS_SUFFIX_MAXLEN MAX(MAX(sizeof(COMPRESS_SUFFIX_GZ),sizeof(COMPRESS_SUFFIX_BZ2)),sizeof(COMPRESS_SUFFIX_XZ))
+
+/*
+ * Compression types
+ */
+#define COMPRESS_TYPES 4 /* Number of supported compression types */
+
+#define COMPRESS_NONE 0
+#define COMPRESS_GZIP 1
+#define COMPRESS_BZIP2 2
+#define COMPRESS_XZ 3
+
+/*
* Bit-values for the 'flags' parsed from a config-file entry.
*/
-#define CE_COMPACT 0x0001 /* Compact the archived log files with gzip. */
-#define CE_BZCOMPACT 0x0002 /* Compact the archived log files with bzip2. */
#define CE_BINARY 0x0008 /* Logfile is in binary, do not add status */
/* messages to logfile(s) when rotating. */
#define CE_NOSIGNAL 0x0010 /* There is no process to signal when */
@@ -119,6 +138,19 @@ __FBSDID("$FreeBSD$");
#define MAX_OLDLOGS 65536 /* Default maximum number of old logfiles */
+struct compress_types {
+ const char *flag; /* Flag in configuration file */
+ const char *suffix; /* Compression suffix */
+ const char *path; /* Path to compression program */
+};
+
+const struct compress_types compress_type[COMPRESS_TYPES] = {
+ { "", "", "" }, /* no compression */
+ { "Z", COMPRESS_SUFFIX_GZ, _PATH_GZIP }, /* gzip compression */
+ { "J", COMPRESS_SUFFIX_BZ2, _PATH_BZIP2 }, /* bzip2 compression */
+ { "X", COMPRESS_SUFFIX_XZ, _PATH_XZ } /* xz compression */
+};
+
struct conf_entry {
STAILQ_ENTRY(conf_entry) cf_nextp;
char *log; /* Name of the log */
@@ -134,7 +166,8 @@ struct conf_entry {
int hours; /* Hours between log trimming */
struct ptime_data *trim_at; /* Specific time to do trimming */
unsigned int permissions; /* File permissions on the log */
- int flags; /* CE_COMPACT, CE_BZCOMPACT, CE_BINARY */
+ int flags; /* CE_BINARY */
+ int compress; /* Compression */
int sig; /* Signal to send */
int def_cfg; /* Using the <default> rule for this file */
};
@@ -218,6 +251,7 @@ static int isnumberstr(const char *);
static int isglobstr(const char *);
static char *missing_field(char *p, char *errline);
static void change_attrs(const char *, const struct conf_entry *);
+static const char *get_logfile_suffix(const char *logfile);
static fk_entry do_entry(struct conf_entry *);
static fk_entry do_rotate(const struct conf_entry *);
static void do_sigwork(struct sigwork_entry *);
@@ -367,6 +401,7 @@ init_entry(const char *fname, struct conf_entry *src_entry)
tempwork->trim_at = ptime_init(src_entry->trim_at);
tempwork->permissions = src_entry->permissions;
tempwork->flags = src_entry->flags;
+ tempwork->compress = src_entry->compress;
tempwork->sig = src_entry->sig;
tempwork->def_cfg = src_entry->def_cfg;
} else {
@@ -384,6 +419,7 @@ init_entry(const char *fname, struct conf_entry *src_entry)
tempwork->trim_at = NULL;
tempwork->permissions = 0;
tempwork->flags = 0;
+ tempwork->compress = COMPRESS_NONE;
tempwork->sig = SIGHUP;
tempwork->def_cfg = 0;
}
@@ -448,14 +484,9 @@ do_entry(struct conf_entry * ent)
char temp_reason[REASON_MAX];
free_or_keep = FREE_ENT;
- if (verbose) {
- if (ent->flags & CE_COMPACT)
- printf("%s <%dZ>: ", ent->log, ent->numlogs);
- else if (ent->flags & CE_BZCOMPACT)
- printf("%s <%dJ>: ", ent->log, ent->numlogs);
- else
- printf("%s <%d>: ", ent->log, ent->numlogs);
- }
+ if (verbose)
+ printf("%s <%d%s>: ", ent->log, ent->numlogs,
+ compress_type[ent->compress].flag);
ent->fsize = sizefile(ent->log);
modtime = age_old_log(ent->log);
ent->rotate = 0;
@@ -560,17 +591,10 @@ do_entry(struct conf_entry * ent)
ent->r_reason = strdup(temp_reason);
if (verbose)
printf("--> trimming log....\n");
- if (noaction && !verbose) {
- if (ent->flags & CE_COMPACT)
- printf("%s <%dZ>: trimming\n",
- ent->log, ent->numlogs);
- else if (ent->flags & CE_BZCOMPACT)
- printf("%s <%dJ>: trimming\n",
- ent->log, ent->numlogs);
- else
- printf("%s <%d>: trimming\n",
- ent->log, ent->numlogs);
- }
+ if (noaction && !verbose)
+ printf("%s <%d%s>: trimming\n", ent->log,
+ ent->numlogs,
+ compress_type[ent->compress].flag);
free_or_keep = do_rotate(ent);
} else {
if (verbose)
@@ -599,7 +623,7 @@ parse_args(int argc, char **argv)
*p = '\0';
/* Parse command line options. */
- while ((ch = getopt(argc, argv, "a:d:f:nrst:vCD:FNPR:")) != -1)
+ while ((ch = getopt(argc, argv, "a:d:f:nrst:vCD:FNPR:S:")) != -1)
switch (ch) {
case 'a':
archtodir++;
@@ -1183,6 +1207,7 @@ parse_file(FILE *cf, struct cflist *work_p, struct cflist *glob_p,
}
working->flags = 0;
+ working->compress = COMPRESS_NONE;
q = parse = missing_field(sob(++parse), errline);
parse = son(parse);
eol = !*parse;
@@ -1261,7 +1286,7 @@ no_trimat:
working->flags |= CE_GLOB;
break;
case 'j':
- working->flags |= CE_BZCOMPACT;
+ working->compress = COMPRESS_BZIP2;
break;
case 'n':
working->flags |= CE_NOSIGNAL;
@@ -1272,8 +1297,11 @@ no_trimat:
case 'w':
/* Depreciated flag - keep for compatibility purposes */
break;
+ case 'x':
+ working->compress = COMPRESS_XZ;
+ break;
case 'z':
- working->flags |= CE_COMPACT;
+ working->compress = COMPRESS_GZIP;
break;
case '-':
break;
@@ -1415,7 +1443,7 @@ static void
delete_oldest_timelog(const struct conf_entry *ent, const char *archive_dir)
{
char *logfname, *s, *dir, errbuf[80];
- int logcnt, max_logcnt, dirfd, i;
+ int dirfd, i, logcnt, max_logcnt, valid;
struct oldlog_entry *oldlogs;
size_t logfname_len;
struct dirent *dp;
@@ -1485,9 +1513,12 @@ delete_oldest_timelog(const struct conf_entry *ent, const char *archive_dir)
"match time format\n", dp->d_name);
continue;
}
- if (*s != '\0' && !(strcmp(s, BZCOMPRESS_POSTFIX) == 0 ||
- strcmp(s, COMPRESS_POSTFIX) == 0)) {
- if (verbose)
+
+ for (int c = 0; c < COMPRESS_TYPES; c++)
+ if (strcmp(s, compress_type[c].suffix) == 0)
+ valid = 1;
+ if (valid != 1) {
+ if (verbose)
printf("Ignoring %s which has unexpected "
"extension '%s'\n", dp->d_name, s);
continue;
@@ -1586,13 +1617,35 @@ add_to_queue(const char *fname, struct ilist *inclist)
STAILQ_INSERT_TAIL(inclist, inc, inc_nextp);
}
+/*
+ * Search for logfile and return its compression suffix (if supported)
+ * The suffix detection is first-match in the order of compress_types
+ *
+ * Note: if logfile without suffix exists (uncompressed, COMPRESS_NONE)
+ * a zero-length string is returned
+ */
+static const char *
+get_logfile_suffix(const char *logfile)
+{
+ struct stat st;
+ char zfile[MAXPATHLEN];
+
+ for (int c = 0; c < COMPRESS_TYPES; c++) {
+ (void) strlcpy(zfile, logfile, MAXPATHLEN);
+ (void) strlcat(zfile, compress_type[c].suffix, MAXPATHLEN);
+ if (lstat(zfile, &st) == 0)
+ return (compress_type[c].suffix);
+ }
+ return (NULL);
+}
+
static fk_entry
do_rotate(const struct conf_entry *ent)
{
char dirpart[MAXPATHLEN], namepart[MAXPATHLEN];
char file1[MAXPATHLEN], file2[MAXPATHLEN];
char zfile1[MAXPATHLEN], zfile2[MAXPATHLEN];
- char jfile1[MAXPATHLEN];
+ const char *logfile_suffix;
char datetimestr[30];
int flags, numlogs_c;
fk_entry free_or_keep;
@@ -1650,19 +1703,13 @@ do_rotate(const struct conf_entry *ent)
delete_oldest_timelog(ent, dirpart);
else {
/* name of oldest log */
- (void) snprintf(zfile1, sizeof(zfile1), "%s%s", file1,
- COMPRESS_POSTFIX);
- snprintf(jfile1, sizeof(jfile1), "%s%s", file1,
- BZCOMPRESS_POSTFIX);
-
- if (noaction) {
- printf("\trm -f %s\n", file1);
- printf("\trm -f %s\n", zfile1);
- printf("\trm -f %s\n", jfile1);
- } else {
- (void) unlink(file1);
- (void) unlink(zfile1);
- (void) unlink(jfile1);
+ for (int c = 0; c < COMPRESS_TYPES; c++) {
+ (void) snprintf(zfile1, sizeof(zfile1), "%s%s", file1,
+ compress_type[c].suffix);
+ if (noaction)
+ printf("\trm -f %s\n", zfile1);
+ else
+ (void) unlink(zfile1);
}
}
@@ -1697,24 +1744,14 @@ do_rotate(const struct conf_entry *ent)
(void) snprintf(file1, sizeof(file1), "%s.%d",
ent->log, numlogs_c);
- (void) strlcpy(zfile1, file1, sizeof(zfile1));
- (void) strlcpy(zfile2, file2, sizeof(zfile2));
- if (lstat(file1, &st)) {
- (void) strlcat(zfile1, COMPRESS_POSTFIX,
- sizeof(zfile1));
- (void) strlcat(zfile2, COMPRESS_POSTFIX,
- sizeof(zfile2));
- if (lstat(zfile1, &st)) {
- strlcpy(zfile1, file1, sizeof(zfile1));
- strlcpy(zfile2, file2, sizeof(zfile2));
- strlcat(zfile1, BZCOMPRESS_POSTFIX,
- sizeof(zfile1));
- strlcat(zfile2, BZCOMPRESS_POSTFIX,
- sizeof(zfile2));
- if (lstat(zfile1, &st))
- continue;
- }
- }
+ logfile_suffix = get_logfile_suffix(file1);
+ if (logfile_suffix == NULL)
+ continue;
+ (void) strlcpy(zfile1, file1, MAXPATHLEN);
+ (void) strlcpy(zfile2, file2, MAXPATHLEN);
+ (void) strlcat(zfile1, logfile_suffix, MAXPATHLEN);
+ (void) strlcat(zfile2, logfile_suffix, MAXPATHLEN);
+
if (noaction)
printf("\tmv %s %s\n", zfile1, zfile2);
else {
@@ -1760,7 +1797,7 @@ do_rotate(const struct conf_entry *ent)
swork = NULL;
if (ent->pid_file != NULL)
swork = save_sigwork(ent);
- if (ent->numlogs > 0 && (flags & (CE_COMPACT | CE_BZCOMPACT))) {
+ if (ent->numlogs > 0 && ent->compress > COMPRESS_NONE) {
/*
* The zipwork_entry will include a pointer to this
* conf_entry, so the conf_entry should not be freed.
@@ -1855,15 +1892,16 @@ do_zipwork(struct zipwork_entry *zwork)
pgm_path = NULL;
strlcpy(zresult, zwork->zw_fname, sizeof(zresult));
- if (zwork != NULL && zwork->zw_conf != NULL) {
- if (zwork->zw_conf->flags & CE_COMPACT) {
- pgm_path = _PATH_GZIP;
- strlcat(zresult, COMPRESS_POSTFIX, sizeof(zresult));
- } else if (zwork->zw_conf->flags & CE_BZCOMPACT) {
- pgm_path = _PATH_BZIP2;
- strlcat(zresult, BZCOMPRESS_POSTFIX, sizeof(zresult));
+ if (zwork != NULL && zwork->zw_conf != NULL &&
+ zwork->zw_conf->compress > COMPRESS_NONE)
+ for (int c = 1; c < COMPRESS_TYPES; c++) {
+ if (zwork->zw_conf->compress == c) {
+ pgm_path = compress_type[c].path;
+ (void) strlcat(zresult,
+ compress_type[c].suffix, sizeof(zresult));
+ break;
+ }
}
- }
if (pgm_path == NULL) {
warnx("invalid entry for %s in do_zipwork", zwork->zw_fname);
return;
@@ -2141,9 +2179,8 @@ static int
age_old_log(char *file)
{
struct stat sb;
- char *endp;
- char tmp[MAXPATHLEN + sizeof(".0") + sizeof(COMPRESS_POSTFIX) +
- sizeof(BZCOMPRESS_POSTFIX) + 1];
+ const char *logfile_suffix;
+ char tmp[MAXPATHLEN + sizeof(".0") + COMPRESS_SUFFIX_MAXLEN + 1];
if (archtodir) {
char *p;
@@ -2173,21 +2210,12 @@ age_old_log(char *file)
}
strlcat(tmp, ".0", sizeof(tmp));
- if (stat(tmp, &sb) < 0) {
- /*
- * A plain '.0' file does not exist. Try again, first
- * with the added suffix of '.gz', then with an added
- * suffix of '.bz2' instead of '.gz'.
- */
- endp = strchr(tmp, '\0');
- strlcat(tmp, COMPRESS_POSTFIX, sizeof(tmp));
- if (stat(tmp, &sb) < 0) {
- *endp = '\0'; /* Remove .gz */
- strlcat(tmp, BZCOMPRESS_POSTFIX, sizeof(tmp));
- if (stat(tmp, &sb) < 0)
- return (-1);
- }
- }
+ logfile_suffix = get_logfile_suffix(tmp);
+ if (logfile_suffix == NULL)
+ return (-1);
+ (void) strlcat(tmp, logfile_suffix, sizeof(tmp));
+ if (stat(tmp, &sb) < 0)
+ return (-1);
return ((int)(ptimeget_secs(timenow) - sb.st_mtime + 1800) / 3600);
}
diff --git a/usr.sbin/newsyslog/newsyslog.conf.5 b/usr.sbin/newsyslog/newsyslog.conf.5
index 5ce1f40..7c781ea 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.5
+++ b/usr.sbin/newsyslog/newsyslog.conf.5
@@ -21,7 +21,7 @@
.\" the suitability of this software for any purpose. It is
.\" provided "as is" without express or implied warranty.
.\"
-.Dd July 23, 2010
+.Dd January 31, 2011
.Dt NEWSYSLOG.CONF 5
.Os
.Sh NAME
@@ -292,6 +292,12 @@ indicates that
should attempt to save disk space by compressing the rotated
log file using
.Xr bzip2 1 .
+.It Cm X
+indicates that
+.Xr newsyslog 8
+should attempt to save disk space by compressing the rotated
+log file using
+.Xr xz 1 .
.It Cm N
indicates that there is no process which needs to be signaled
when this log file is rotated.
@@ -346,6 +352,7 @@ signal will be sent.
.Sh SEE ALSO
.Xr bzip2 1 ,
.Xr gzip 1 ,
+.Xr xz 1 ,
.Xr syslog 3 ,
.Xr chown 8 ,
.Xr newsyslog 8 ,
diff --git a/usr.sbin/newsyslog/pathnames.h b/usr.sbin/newsyslog/pathnames.h
index 3d2c6ff..9c4f885 100644
--- a/usr.sbin/newsyslog/pathnames.h
+++ b/usr.sbin/newsyslog/pathnames.h
@@ -22,7 +22,8 @@ provided "as is" without express or implied warranty.
*/
-#define _PATH_CONF "/etc/newsyslog.conf"
-#define _PATH_SYSLOGPID _PATH_VARRUN "syslog.pid"
-#define _PATH_BZIP2 "/usr/bin/bzip2"
-#define _PATH_GZIP "/usr/bin/gzip"
+#define _PATH_CONF "/etc/newsyslog.conf"
+#define _PATH_SYSLOGPID _PATH_VARRUN "syslog.pid"
+#define _PATH_BZIP2 "/usr/bin/bzip2"
+#define _PATH_GZIP "/usr/bin/gzip"
+#define _PATH_XZ "/usr/bin/xz"
diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c
index d86309f..364045d 100644
--- a/usr.sbin/nfsd/nfsd.c
+++ b/usr.sbin/nfsd/nfsd.c
@@ -134,7 +134,7 @@ main(int argc, char **argv)
socklen_t len;
int on = 1, unregister, reregister, sock;
int tcp6sock, ip6flag, tcpflag, tcpsock;
- int udpflag, ecode, s, srvcnt;
+ int udpflag, ecode, error, s, srvcnt;
int bindhostc, bindanyflag, rpcbreg, rpcbregcnt;
int stablefd, nfssvc_addsock;
char **bindhost = NULL;
@@ -738,8 +738,9 @@ main(int argc, char **argv)
if (connect_type_cnt > 1) {
if (select(maxsock + 1,
&ready, NULL, NULL, NULL) < 1) {
+ error = errno;
syslog(LOG_ERR, "select failed: %m");
- if (errno == EINTR)
+ if (error == EINTR)
continue;
nfsd_exit(1);
}
@@ -750,9 +751,10 @@ main(int argc, char **argv)
len = sizeof(inetpeer);
if ((msgsock = accept(tcpsock,
(struct sockaddr *)&inetpeer, &len)) < 0) {
+ error = errno;
syslog(LOG_ERR, "accept failed: %m");
- if (errno == ECONNABORTED ||
- errno == EINTR)
+ if (error == ECONNABORTED ||
+ error == EINTR)
continue;
nfsd_exit(1);
}
@@ -772,10 +774,11 @@ main(int argc, char **argv)
if ((msgsock = accept(tcpsock,
(struct sockaddr *)&inet6peer,
&len)) < 0) {
+ error = errno;
syslog(LOG_ERR,
"accept failed: %m");
- if (errno == ECONNABORTED ||
- errno == EINTR)
+ if (error == ECONNABORTED ||
+ error == EINTR)
continue;
nfsd_exit(1);
}
diff --git a/usr.sbin/ngctl/main.c b/usr.sbin/ngctl/main.c
index 9195546..3581386 100644
--- a/usr.sbin/ngctl/main.c
+++ b/usr.sbin/ngctl/main.c
@@ -34,10 +34,12 @@
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
- * $FreeBSD$
* $Whistle: main.c,v 1.12 1999/11/29 19:17:46 archie Exp $
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/select.h>
@@ -225,7 +227,7 @@ ReadFile(FILE *fp)
#ifdef EDITLINE
/* Signal handler for Monitor() thread. */
static void
-Unblock(int signal)
+Unblock(int signal __unused)
{
unblock = 1;
@@ -236,7 +238,7 @@ Unblock(int signal)
* can be blocked in el_gets().
*/
static void *
-Monitor(void *v)
+Monitor(void *v __unused)
{
struct sigaction act;
const int maxfd = MAX(csock, dsock) + 1;
@@ -270,7 +272,7 @@ Monitor(void *v)
}
static char *
-Prompt(EditLine *el)
+Prompt(EditLine *el __unused)
{
return (PROMPT);
diff --git a/usr.sbin/ngctl/msg.c b/usr.sbin/ngctl/msg.c
index f74efde..38f0db7 100644
--- a/usr.sbin/ngctl/msg.c
+++ b/usr.sbin/ngctl/msg.c
@@ -35,9 +35,11 @@
* OF SUCH DAMAGE.
*
* $Whistle: msg.c,v 1.2 1999/11/29 23:38:35 archie Exp $
- * $FreeBSD$
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <err.h>
#include <netgraph.h>
#include <stdio.h>
@@ -121,7 +123,7 @@ MsgCmd(int ac, char **av)
* Read and display the next incoming control message
*/
void
-MsgRead()
+MsgRead(void)
{
struct ng_mesg *m, *m2;
struct ng_mesg *ascii;
diff --git a/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh b/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh
index a4b2b25..407c9a4 100755
--- a/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh
+++ b/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh
@@ -25,7 +25,7 @@
#
# $FreeBSD$
-# Query a disk for partitions and display them
+# Create partitions on a target disk
#############################
. ${PROGDIR}/backend/functions.sh
@@ -47,46 +47,52 @@ fi
DISK="${1}"
MB="${2}"
+TYPE="${3}"
+STARTBLOCK="${4}"
TOTALBLOCKS="`expr $MB \* 2048`"
-
-# Lets figure out what number this slice will be
-LASTSLICE="`fdisk -s /dev/${DISK} 2>/dev/null | grep -v ${DISK} | grep ':' | tail -n 1 | cut -d ':' -f 1 | tr -s '\t' ' ' | tr -d ' '`"
+# If no TYPE specified, default to MBR
+if [ -z "$TYPE" ] ; then TYPE="mbr" ; fi
+
+# Sanity check the gpart type
+case $TYPE in
+ apm|APM) ;;
+ bsd|BSD) ;;
+ ebr|EBR) ;;
+ pc98|pc98) ;;
+ gpt|GPT) ;;
+ mbr|MBR) ;;
+ vtoc8|VTOC8) ;;
+ *) echo "Error: Unknown gpart type: $TYPE" ; exit 1 ;;
+esac
+
+# Lets figure out what number this partition will be
+LASTSLICE="`gpart show $DISK | grep -v -e $DISK -e '\- free \-' -e '^$' | awk 'END {print $3}'`"
if [ -z "${LASTSLICE}" ] ; then
LASTSLICE="1"
else
LASTSLICE="`expr $LASTSLICE + 1`"
fi
-if [ ${LASTSLICE} -gt "4" ] ; then
- echo "Error: FreeBSD MBR setups can only have a max of 4 slices"
- exit 1
-fi
-
-
SLICENUM="${LASTSLICE}"
-# Lets get the starting block
-if [ "${SLICENUM}" = "1" ] ; then
- STARTBLOCK="63"
-else
- # Lets figure out where the prior slice ends
- checkslice="`expr ${SLICENUM} - 1`"
-
- # Get starting block of this slice
- fdisk -s /dev/${DISK} | grep -v "${DISK}:" | grep "${checkslice}:" | tr -s " " >${TMPDIR}/pfdisk
- pstartblock="`cat ${TMPDIR}/pfdisk | cut -d ' ' -f 3`"
- psize="`cat ${TMPDIR}/pfdisk | cut -d ' ' -f 4`"
- STARTBLOCK="`expr ${pstartblock} + ${psize}`"
+# Set a 4k Aligned start block if none specified
+if [ "${SLICENUM}" = "1" -a -z "$STARTBLOCK" ] ; then
+ STARTBLOCK="2016"
fi
-# If this is an empty disk, see if we need to create a new MBR scheme for it
+# If this is an empty disk, see if we need to create a new scheme for it
gpart show ${DISK} >/dev/null 2>/dev/null
if [ "$?" != "0" -a "${SLICENUM}" = "1" ] ; then
- gpart create -s mbr ${DISK}
+ gpart create -s ${TYPE} ${DISK}
+fi
+
+# If we have a starting block, use it
+if [ -z "$STARTBLOCK" ] ; then
+ sBLOCK="-b $STARTBLOCK"
fi
-gpart add -b ${STARTBLOCK} -s ${TOTALBLOCKS} -t freebsd -i ${SLICENUM} ${DISK}
+gpart add ${sBLOCK} -s ${TOTALBLOCKS} -t freebsd -i ${SLICENUM} ${DISK}
exit "$?"
diff --git a/usr.sbin/pc-sysinstall/backend-query/disk-part.sh b/usr.sbin/pc-sysinstall/backend-query/disk-part.sh
index 900cbca..e5e7355 100755
--- a/usr.sbin/pc-sysinstall/backend-query/disk-part.sh
+++ b/usr.sbin/pc-sysinstall/backend-query/disk-part.sh
@@ -60,14 +60,8 @@ if [ "$?" != "0" ] ; then
fi
# Display if this is GPT or MBR formatted
-gpart show ${1} | grep "GPT" >/dev/null 2>/dev/null
-if [ "$?" = "0" ] ; then
- echo "${1}-format: GPT"
- TYPE="GPT"
-else
- echo "${1}-format: MBR"
- TYPE="MBR"
-fi
+TYPE=`gpart show ${1} | awk '/^=>/ { printf("%s",$5); }'`
+echo "${1}-format: $TYPE"
# Set some search flags
PART="0"
diff --git a/usr.sbin/pc-sysinstall/backend-query/send-logs.sh b/usr.sbin/pc-sysinstall/backend-query/send-logs.sh
index be2252d..b81087c 100755
--- a/usr.sbin/pc-sysinstall/backend-query/send-logs.sh
+++ b/usr.sbin/pc-sysinstall/backend-query/send-logs.sh
@@ -50,7 +50,7 @@ if [ -e "/tmp/sys-install.cfg" ]
then
echo "" >>${TMPLOG}
echo "# PC-SYSINSTALL CFG " >>${TMPLOG}
- cat /tmp/sys-install.cfg >> ${TMPLOG}
+ cat /tmp/sys-install.cfg | grep -vE 'rootPass|userPass' >> ${TMPLOG}
fi
# Save dmesg output
@@ -59,7 +59,7 @@ echo "# DMESG OUTPUT " >>${TMPLOG}
dmesg >> ${TMPLOG}
# Get gpart info on all disks
-for i in `${PROGDIR}/pc-sysinstall disk-list | cut -d ':' -f 1`
+for i in `pc-sysinstall disk-list | cut -d ':' -f 1`
do
echo "" >>${TMPLOG}
echo "# DISK INFO $i " >>${TMPLOG}
diff --git a/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh b/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh
index bf63a72..17821be 100755
--- a/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh
+++ b/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh
@@ -26,6 +26,12 @@
# $FreeBSD$
FOUND="0"
+TMPLIST="/tmp/.xkeyList.$$"
+XLST="/usr/local/share/X11/xkb/rules/xorg.lst"
+
+if [ ! -e "${XLST}" ] ; then
+ exit 1
+fi
# Lets parse the xorg.list file, and see what layouts are supported
while read line
@@ -36,9 +42,9 @@ do
echo $line | grep '! ' >/dev/null 2>/dev/null
if [ "$?" = "0" ]
then
- exit 0
+ break
else
- echo "$line"
+ echo "$line" >> ${TMPLIST}
fi
fi
@@ -51,6 +57,11 @@ do
fi
fi
-done < /usr/local/share/X11/xkb/rules/xorg.lst
+done < $XLST
+
+sort -b -d +1 $TMPLIST
+
+# Delete the tmp file
+rm $TMPLIST
exit 0
diff --git a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
index e801714..fceed33 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
@@ -158,227 +158,29 @@ gen_glabel_name()
export VAL
};
-# Function to setup / stamp a legacy MBR bsdlabel
-setup_mbr_partitions()
+# Function to setup partitions using gpart
+setup_gpart_partitions()
{
- DISKTAG="$1"
- WRKSLICE="$2"
+ local _dTag="$1"
+ local _pDisk="$2"
+ local _wSlice="$3"
+ local _sNum="$4"
+ local _pType="$5"
FOUNDPARTS="1"
- # Lets setup the BSDLABEL
- BSDLABEL="${TMPDIR}/bsdLabel-${WRKSLICE}"
- export BSDLABEL
- rm $BSDLABEL >/dev/null 2>/dev/null
- echo "# /dev/${WRKSLICE}" >>$BSDLABEL
- echo "8 partitions:" >>$BSDLABEL
- echo "# size offset fstype bsize bps/cpg" >>$BSDLABEL
-
- PARTLETTER="a"
-
- # Lets read in the config file now and populate this
- while read line
- do
- # Check for data on this slice
- echo $line | grep "^${DISKTAG}-part=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Found a slice- entry, lets get the slice info
- get_value_from_string "${line}"
- STRING="$VAL"
- FOUNDPARTS="0"
-
- # We need to split up the string now, and pick out the variables
- FS=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 1`
- SIZE=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2`
- MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 3`
-
- if echo $STRING | grep -E '^/.+' >/dev/null 2>&1
- then
- IMAGE=`echo ${STRING} | cut -f1 -d' '`
- fi
-
- # Check if we have a .eli extension on this FS
- echo ${FS} | grep ".eli" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- FS="`echo ${FS} | cut -d '.' -f 1`"
- ENC="ON"
- check_for_enc_pass "${line}"
- if [ "${VAL}" != "" ] ; then
- # We have a user supplied password, save it for later
- ENCPASS="${VAL}"
- fi
- else
- ENC="OFF"
- fi
-
- # Check if the user tried to setup / as an encrypted partition
- check_for_mount "${MNT}" "/"
- if [ "${?}" = "0" -a "${ENC}" = "ON" ]
- then
- USINGENCROOT="0" ; export USINGENCROOT
- fi
-
- if [ -n "${IMAGE}" ]
- then
- FS="IMAGE"
- SIZE=`ls -l "${IMAGE}" | awk '{ print $5 }'`
- MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2`
- SIZE=`convert_byte_to_megabyte $SIZE`
- fi
-
- # Now check that these values are sane
- case $FS in
- UFS|UFS+S|UFS+J|UFS+SUJ|ZFS|SWAP|IMAGE) ;;
- *) exit_err "ERROR: Invalid file system specified on $line" ;;
- esac
-
- # Check that we have a valid size number
- expr $SIZE + 1 >/dev/null 2>/dev/null
- if [ "$?" != "0" ]; then
- exit_err "ERROR: The size specified on $line is invalid"
- fi
-
- # Check that the mount-point starts with /
- echo "$MNT" | grep -e "^/" -e "^none" >/dev/null 2>/dev/null
- if [ "$?" != "0" ]; then
- exit_err "ERROR: The mount-point specified on $line is invalid"
- fi
-
- if [ "$SIZE" = "0" ]
- then
- SOUT="*"
- else
- SOUT="${SIZE}M"
- fi
-
- # OK, we passed all tests, now lets put these values into a config
- # If the part
- if [ "${PARTLETTER}" = "a" ]
- then
- if [ "$FS" = "SWAP" ]
- then
- echo "a: ${SOUT} * swap 0 0" >>${BSDLABEL}
- else
- echo "a: ${SOUT} 0 4.2BSD 0 0" >>${BSDLABEL}
- fi
-
- # Check if we found a valid root partition
- check_for_mount "${MNT}" "/"
- if [ "$?" = "0" ] ; then
- FOUNDROOT="0" ; export FOUNDROOT
- fi
-
- # Check if we have a "/boot" instead
- check_for_mount "${MNT}" "/boot"
- if [ "${?}" = "0" ] ; then
- USINGBOOTPART="0" ; export USINGBOOTPART
- if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" -a "${FS}" != "UFS+SUJ" ]
- then
- exit_err "/boot partition must be formatted with UFS"
- fi
- fi
-
- else
- # Done with the a: partitions
-
- # Check if we found a valid root partition not on a:
- check_for_mount "${MNT}" "/"
- if [ "${?}" = "0" ] ; then
- FOUNDROOT="1" ; export FOUNDROOT
- fi
-
- # Check if we have a /boot partition, and fail since its not first
- check_for_mount "${MNT}" "/boot"
- if [ "${?}" = "0" ] ; then
- exit_err "/boot partition must be first partition"
- fi
-
-
- if [ "$FS" = "SWAP" ]
- then
- echo "${PARTLETTER}: ${SOUT} * swap" >>${BSDLABEL}
- else
- echo "${PARTLETTER}: ${SOUT} * 4.2BSD" >>${BSDLABEL}
- fi
- fi
-
- # Generate a unique label name for this mount
- gen_glabel_name "${MNT}" "${FS}"
- PLABEL="${VAL}"
-
- # Get any extra options for this fs / line
- get_fs_line_xvars "${WRKSLICE}${PARTLETTER}" "${STRING}"
- XTRAOPTS="${VAR}"
-
- # Check if using zfs mirror
- echo ${XTRAOPTS} | grep "mirror" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
- XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${WRKSLICE}${PARTLETTER}")
- fi
-
- # Save this data to our partition config dir
- echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${WRKSLICE}${PARTLETTER}
-
- # If we have a enc password, save it as well
- if [ ! -z "${ENCPASS}" ] ; then
- echo "${ENCPASS}" >${PARTDIR}-enc/${WRKSLICE}${PARTLETTER}-encpass
- fi
-
- # This partition letter is used, get the next one
- case ${PARTLETTER} in
- a) PARTLETTER="b" ;;
- b) # When we hit b, add the special c: setup for bsdlabel
- echo "c: * * unused" >>${BSDLABEL}
- PARTLETTER="d" ;;
- d) PARTLETTER="e" ;;
- e) PARTLETTER="f" ;;
- f) PARTLETTER="g" ;;
- g) PARTLETTER="h" ;;
- h) PARTLETTER="ERR" ;;
- *) exit_err "ERROR: bsdlabel only supports up to letter h for partitions." ;;
- esac
-
- unset IMAGE
-
- fi # End of subsection locating a slice in config
-
- echo $line | grep "^commitDiskLabel" >/dev/null 2>/dev/null
- if [ "$?" = "0" -a "${FOUNDPARTS}" = "0" ]
- then
- # Found our flag to commit this label setup, check that we found at least 1 partition and do it
- if [ "${PARTLETTER}" != "a" ]
- then
- # Check if we only had 1 partition, and make sure we add "c:" section to label
- if [ "${PARTLETTER}" = "b" ]
- then
- echo "c: * * unused" >>${BSDLABEL}
- fi
-
- echo "bsdlabel -R -B /dev/${WRKSLICE} ${BSDLABEL}"
- bsdlabel -R -B ${WRKSLICE} ${BSDLABEL}
-
- break
- else
- exit_err "ERROR: commitDiskLabel was called without any partition entries for it!"
- fi
- fi
- done <${CFGF}
-};
-
-# Function to setup partitions using gpt
-setup_gpt_partitions()
-{
- DISKTAG="$1"
- DISK="$2"
- FOUNDPARTS="1"
+ # Lets read in the config file now and setup our partitions
+ if [ "${_pType}" = "gpt" ] ; then
+ CURPART="2"
+ else
+ PARTLETTER="a"
+ CURPART="1"
+ rc_halt "gpart create -s BSD ${_wSlice}"
+ fi
- # Lets read in the config file now and setup our GPT partitions
- CURPART="2"
while read line
do
# Check for data on this slice
- echo $line | grep "^${DISKTAG}-part=" >/dev/null 2>/dev/null
+ echo $line | grep "^${_dTag}-part=" >/dev/null 2>/dev/null
if [ "$?" = "0" ]
then
FOUNDPARTS="0"
@@ -441,24 +243,28 @@ setup_gpt_partitions()
# Check if we found a valid root partition
check_for_mount "${MNT}" "/"
if [ "${?}" = "0" ] ; then
- if [ "${CURPART}" = "2" ] ; then
+ FOUNDROOT="1" ; export FOUNDROOT
+ if [ "${CURPART}" = "2" -a "$_pType" = "gpt" ] ; then
+ FOUNDROOT="0" ; export FOUNDROOT
+ fi
+ if [ "${CURPART}" = "1" -a "$_pType" = "mbr" ] ; then
FOUNDROOT="0" ; export FOUNDROOT
- else
- FOUNDROOT="1" ; export FOUNDROOT
fi
fi
check_for_mount "${MNT}" "/boot"
if [ "${?}" = "0" ] ; then
- if [ "${CURPART}" = "2" ] ; then
- USINGBOOTPART="0" ; export USINGBOOTPART
- if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" -a "${FS}" != "UFS+SUJ" ]
- then
- exit_err "/boot partition must be formatted with UFS"
- fi
- else
+ USINGBOOTPART="0" ; export USINGBOOTPART
+ if [ "${CURPART}" != "2" -a "${_pType}" = "gpt" ] ; then
+ exit_err "/boot partition must be first partition"
+ fi
+ if [ "${CURPART}" != "1" -a "${_pType}" = "mbr" ] ; then
exit_err "/boot partition must be first partition"
fi
+
+ if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" -a "${FS}" != "UFS+SUJ" ] ; then
+ exit_err "/boot partition must be formatted with UFS"
+ fi
fi
# Generate a unique label name for this mount
@@ -466,13 +272,21 @@ setup_gpt_partitions()
PLABEL="${VAL}"
# Get any extra options for this fs / line
- get_fs_line_xvars "${DISK}p${CURPART}" "${STRING}"
+ if [ "${_pType}" = "gpt" ] ; then
+ get_fs_line_xvars "${_pDisk}p${CURPART}" "${STRING}"
+ else
+ get_fs_line_xvars "${_wSlice}" "${STRING}"
+ fi
XTRAOPTS="${VAR}"
# Check if using zfs mirror
echo ${XTRAOPTS} | grep "mirror" >/dev/null 2>/dev/null
if [ "$?" = "0" ] ; then
- XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${DISK}p${CURPART}")
+ if [ "${_pType}" = "gpt" ] ; then
+ XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}")
+ else
+ XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}")
+ fi
fi
# Figure out the gpart type to use
@@ -483,7 +297,16 @@ setup_gpt_partitions()
esac
# Create the partition
- rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${DISK}"
+ if [ "${_pType}" = "gpt" ] ; then
+ if [ "$CURPART" = "2" ] ; then
+ # If this is GPT, make sure first partition is aligned to 4k
+ rc_halt "gpart add -b 2016 ${SOUT} -t ${PARTYPE} ${_pDisk}"
+ else
+ rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}"
+ fi
+ else
+ rc_halt "gpart add ${SOUT} -t ${PARTYPE} -i ${CURPART} ${_wSlice}"
+ fi
# Check if this is a root / boot partition, and stamp the right loader
for TESTMNT in `echo ${MNT} | sed 's|,| |g'`
@@ -497,19 +320,53 @@ setup_gpt_partitions()
done
# Save this data to our partition config dir
- echo "${FS}:${MNT}:${ENC}:${PLABEL}:GPT:${XTRAOPTS}" >${PARTDIR}/${DISK}p${CURPART}
+ if [ "${_pType}" = "gpt" ] ; then
+ echo "${FS}:${MNT}:${ENC}:${PLABEL}:GPT:${XTRAOPTS}" >${PARTDIR}/${_pDisk}p${CURPART}
- # Clear out any headers
- sleep 2
- dd if=/dev/zero of=${DISK}p${CURPART} count=2048 >/dev/null 2>/dev/null
+ # Clear out any headers
+ sleep 2
+ dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 >/dev/null 2>/dev/null
- # If we have a enc password, save it as well
- if [ ! -z "${ENCPASS}" ] ; then
- echo "${ENCPASS}" >${PARTDIR}-enc/${DISK}p${CURPART}-encpass
+ # If we have a enc password, save it as well
+ if [ ! -z "${ENCPASS}" ] ; then
+ echo "${ENCPASS}" >${PARTDIR}-enc/${_pDisk}p${CURPART}-encpass
+ fi
+ else
+ # MBR Partition
+ echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${_wSlice}${PARTLETTER}
+ # Clear out any headers
+ sleep 2
+ dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 >/dev/null 2>/dev/null
+
+ # If we have a enc password, save it as well
+ if [ ! -z "${ENCPASS}" ] ; then
+ echo "${ENCPASS}" >${PARTDIR}-enc/${_wSlice}${PARTLETTER}-encpass
+ fi
fi
+
# Increment our parts counter
- CURPART="`expr ${CURPART} + 1`"
+ if [ "$_pType" = "gpt" ] ; then
+ CURPART="`expr ${CURPART} + 1`"
+ # If this is a gpt partition, we can continue and skip the MBR part letter stuff
+ continue
+ else
+ CURPART="`expr ${CURPART} + 1`"
+ if [ "$CURPART" = "3" ] ; then CURPART="4" ; fi
+ fi
+
+
+ # This partition letter is used, get the next one
+ case ${PARTLETTER} in
+ a) PARTLETTER="b" ;;
+ b) PARTLETTER="d" ;;
+ d) PARTLETTER="e" ;;
+ e) PARTLETTER="f" ;;
+ f) PARTLETTER="g" ;;
+ g) PARTLETTER="h" ;;
+ h) PARTLETTER="ERR" ;;
+ *) exit_err "ERROR: bsdlabel only supports up to letter h for partitions." ;;
+ esac
fi # End of subsection locating a slice in config
@@ -518,13 +375,17 @@ setup_gpt_partitions()
then
# If this is the boot disk, stamp the right gptboot
- if [ ! -z "${BOOTTYPE}" ] ; then
+ if [ ! -z "${BOOTTYPE}" -a "$_pType" = "gpt" ] ; then
case ${BOOTTYPE} in
- freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${DISK}" ;;
- freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${DISK}" ;;
+ freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${_pDisk}" ;;
+ freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${_pDisk}" ;;
esac
fi
+ # Make sure to stamp the MBR loader
+ if [ "$_pType" = "mbr" ] ; then
+ rc_halt "gpart bootcode -b /boot/boot ${_wSlice}"
+ fi
# Found our flag to commit this label setup, check that we found at least 1 partition
if [ "${CURPART}" = "2" ] ; then
@@ -564,15 +425,9 @@ populate_disk_label()
exit_err "ERROR: Missing SLICETAG data. This shouldn't happen - please let the developers know"
fi
- # Using Traditional MBR for dual-booting
- if [ "$type" = "mbr" ] ; then
- setup_mbr_partitions "${disktag}" "${wrkslice}"
- fi
- # Using entire disk mode, use GPT for this
- if [ "$type" = "gpt" ] ; then
- setup_gpt_partitions "${disktag}" "${disk}"
- fi
+ # Setup the partitions with gpart
+ setup_gpart_partitions "${disktag}" "${disk}" "${wrkslice}" "${slicenum}" "${type}"
};
diff --git a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh b/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
index bf2e467..7524692 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
@@ -233,7 +233,6 @@ setup_fstab()
then
echo "procfs /proc procfs rw 0 0" >> ${FSTAB}
echo "linprocfs /compat/linux/proc linprocfs rw 0 0" >> ${FSTAB}
- echo "tmpfs /tmp tmpfs rw,mode=1777 0 0" >> ${FSTAB}
fi
# If we have a dedicated /boot, run the post-install setup of it now
@@ -372,19 +371,32 @@ setup_gjournal()
# Function which sets the root password from the install config
set_root_pw()
{
+ # Get the plaintext string
get_value_from_cfg_with_spaces rootPass
- PW="${VAL}"
+ local PW="${VAL}"
+
+ # Get the encrypted string
+ get_value_from_cfg_with_spaces rootEncPass
+ local ENCPW="${VAL}"
# If we don't have a root pass, return
- if [ -z "${PW}" ]
- then
- return 0
- fi
+ if [ -z "${PW}" -a -z "${ENCPW}" ] ; then return 0 ; fi
echo_log "Setting root password"
- echo "${PW}" > ${FSMNT}/.rootpw
- run_chroot_cmd "cat /.rootpw | pw usermod root -h 0"
- rc_halt "rm ${FSMNT}/.rootpw"
+
+ # Check if setting plaintext password
+ if [ ! -z "${PW}" ] ; then
+ echo "${PW}" > ${FSMNT}/.rootpw
+ run_chroot_cmd "cat /.rootpw | pw usermod root -h 0"
+ rc_halt "rm ${FSMNT}/.rootpw"
+ fi
+
+ # Check if setting encrypted password
+ if [ ! -z "${ENCPW}" ] ; then
+ echo "${ENCPW}" > ${FSMNT}/.rootpw
+ run_chroot_cmd "cat /.rootpw | pw usermod root -H 0"
+ rc_halt "rm ${FSMNT}/.rootpw"
+ fi
};
diff --git a/usr.sbin/pc-sysinstall/backend/functions-disk.sh b/usr.sbin/pc-sysinstall/backend/functions-disk.sh
index 0b14591..545a689c 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-disk.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-disk.sh
@@ -180,12 +180,7 @@ get_disk_partitions()
return
fi
- gpart show ${1} | grep "MBR" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
- type="MBR"
- else
- type="GPT"
- fi
+ type=`gpart show ${1} | awk '/^=>/ { printf("%s",$5); }'`
SLICES="`gpart show ${1} | grep -v ${1} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 4 | sed '/^$/d'`"
for i in ${SLICES}
@@ -248,7 +243,7 @@ export_all_zpools()
delete_all_gpart()
{
echo_log "Deleting all gparts"
- DISK="$1"
+ local DISK="$1"
# Check for any swaps to stop
for i in `gpart show ${DISK} 2>/dev/null | grep 'freebsd-swap' | tr -s ' ' | cut -d ' ' -f 4`
@@ -265,6 +260,13 @@ delete_all_gpart()
fi
done
+ # Destroy the disk geom
+ rc_nohalt "gpart destroy ${DISK}"
+
+ # Make sure we clear any hidden gpt tables
+ clear_backup_gpt_table "${DISK}"
+
+ # Wipe out front of disk
rc_nohalt "dd if=/dev/zero of=/dev/${DISK} count=3000"
};
@@ -558,6 +560,24 @@ stop_gjournal()
fi
} ;
+
+# Function to wipe the potential backup gpt table from a disk
+clear_backup_gpt_table()
+{
+ # Get the disk block size
+ local dSize="`gpart show $1 | grep $1 | tr -s ' ' | cut -d ' ' -f 3`"
+
+ # Make sure this is a valid number
+ is_num "${dSize}" >/dev/null 2>/dev/null
+ if [ "$?" != "0" ] ; then return ; fi
+
+ # Die backup label, DIE
+ echo_log "Clearing gpt backup table location on disk"
+ rc_nohalt "dd if=/dev/zero of=${1} bs=512 seek=${dSize}"
+
+} ;
+
+
# Function which runs gpart and creates a single large GPT partition scheme
init_gpt_full_disk()
{
@@ -572,15 +592,11 @@ init_gpt_full_disk()
# Remove any existing partitions
delete_all_gpart "${_intDISK}"
- #Erase any existing bootloader
- echo_log "Cleaning up ${_intDISK}"
- rc_halt "dd if=/dev/zero of=/dev/${_intDISK} count=2048"
-
sleep 2
echo_log "Running gpart on ${_intDISK}"
rc_halt "gpart create -s GPT ${_intDISK}"
- rc_halt "gpart add -b 34 -s 128 -t freebsd-boot ${_intDISK}"
+ rc_halt "gpart add -b 34 -s 64 -t freebsd-boot ${_intDISK}"
echo_log "Stamping boot sector on ${_intDISK}"
rc_halt "gpart bootcode -b /boot/pmbr ${_intDISK}"
@@ -593,7 +609,7 @@ init_mbr_full_disk()
_intDISK=$1
_intBOOT=$2
- startblock="63"
+ startblock="2016"
# Set our sysctl so we can overwrite any geom using drives
sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT}
@@ -604,10 +620,6 @@ init_mbr_full_disk()
# Remove any existing partitions
delete_all_gpart "${_intDISK}"
- #Erase any existing bootloader
- echo_log "Cleaning up ${_intDISK}"
- rc_halt "dd if=/dev/zero of=/dev/${_intDISK} count=2048"
-
sleep 2
echo_log "Running gpart on ${_intDISK}"
diff --git a/usr.sbin/pc-sysinstall/backend/functions-localize.sh b/usr.sbin/pc-sysinstall/backend/functions-localize.sh
index fd14e8c..d7508d4 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-localize.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-localize.sh
@@ -38,25 +38,46 @@ localize_freebsd()
rm ${FSMNT}/etc/login.conf.bak
};
+localize_x_desktops() {
-# Function which localizes a PC-BSD install
-localize_pcbsd()
-{
- #Change the skel files
+ # Check for and customize KDE lang
##########################################################################
- sed -i.bak "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals
- sed -i.bak "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals
- sed -i.bak "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals
- sed -i.bak "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals
- #Change KDM Langs
+ # Check if we can localize KDE via skel
+ if [ -e "${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals" ] ; then
+ sed -i '' "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals
+ sed -i '' "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals
+ sed -i '' "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals
+ fi
+
+ # Check if we have a KDE root config
+ if [ -e "${FSMNT}/root/.kde4/share/config/kdeglobals" ] ; then
+ sed -i '' "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals
+ fi
+
+ # Check for KDM
+ if [ -e "${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc" ] ; then
+ sed -i '' "s/Language=en_US/Language=${LOCALE}.UTF-8/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc
+ fi
+
+ # Check for and customize GNOME / GDM lang
##########################################################################
- sed -i.bak "s/Language=en_US/Language=${LOCALE}.UTF-8/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc
+ # See if GDM is enabled and customize its lang
+ cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep "gdm_enable=\"YES\"" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ] ; then
+ echo "gdm_lang=\"${LOCALE}.UTF-8\"" >> ${FSMNT}/etc/rc.conf
+ fi
+
+};
+
+# Function which localizes a PC-BSD install
+localize_pcbsd()
+{
# Check if we have a localized splash screen and copy it
- if [ -e "${FSMNT}/usr/PCBSD/splash-screens/loading-screen-${SETLANG}.pcx" ]
+ if [ -e "${FSMNT}/usr/local/share/pcbsd/splash-screens/loading-screen-${SETLANG}.pcx" ]
then
- cp ${FSMNT}/usr/PCBSD/splash-screens/loading-screen-${SETLANG}.pcx ${FSMNT}/boot/loading-screen.pcx
+ cp ${FSMNT}/usr/local/share/pcbsd/splash-screens/loading-screen-${SETLANG}.pcx ${FSMNT}/boot/loading-screen.pcx
fi
};
@@ -117,12 +138,14 @@ localize_x_keyboard()
cp ${FSMNT}/usr/share/skel/.xprofile ${FSMNT}/root/.xprofile
# Save it for KDM
- echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup
+ if [ -e "${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup" ] ; then
+ echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup
+ fi
fi
-
- # Create the kxkbrc configuration using these options
- echo "[Layout]
+ # Create the kxkbrc configuration using these options
+ if [ -d "${FSMNT}/usr/share/skel/.kde4/share/config" ] ; then
+ echo "[Layout]
DisplayNames=${KXLAYOUT}${COUNTRY}
IndicatorOnly=false
LayoutList=${KXLAYOUT}${KXVAR}${COUNTRY}
@@ -133,6 +156,7 @@ ShowFlag=true
ShowSingle=false
SwitchMode=WinClass
Use=true " >${FSMNT}/usr/share/skel/.kde4/share/config/kxkbrc
+ fi
};
@@ -454,7 +478,12 @@ run_localize()
then
localize_pcbsd "$VAL"
fi
+
+ # Localize FreeBSD
localize_freebsd "$VAL"
+
+ # Localize any X pkgs
+ localize_x_desktops "$VAL"
fi
# Check if we need to do any keylayouts
diff --git a/usr.sbin/pc-sysinstall/backend/functions-networking.sh b/usr.sbin/pc-sysinstall/backend/functions-networking.sh
index 22602a9..419bd3f 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-networking.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-networking.sh
@@ -54,7 +54,7 @@ check_is_wifi()
fi
};
-# Function to get the first available wired nic, used for lagg0 setup
+# Function to get the first available wired nic, used for setup
get_first_wired_nic()
{
rm ${TMPDIR}/.niclist >/dev/null 2>/dev/null
@@ -78,8 +78,9 @@ get_first_wired_nic()
return
};
-# Function which simply enables plain dhcp on all detected nics, not fancy lagg interface
-enable_plain_dhcp_all()
+
+# Function which simply enables plain dhcp on all detected nics
+enable_dhcp_all()
{
rm ${TMPDIR}/.niclist >/dev/null 2>/dev/null
# start by getting a list of nics on this system
@@ -111,57 +112,11 @@ enable_plain_dhcp_all()
fi
};
-# Function which enables fancy lagg dhcp on specified wifi
-enable_lagg_dhcp()
-{
- WIFINIC="$1"
-
- # Get the first wired nic
- get_first_wired_nic
- WIRENIC=$VAL
- LAGGPORT="laggport ${WIFINIC}"
-
- echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf
- if [ ! -z "$WIRENIC" ]
- then
- echo "ifconfig_${WIRENIC}=\"up\"" >> ${FSMNT}/etc/rc.conf
- echo "ifconfig_${WIFINIC}=\"\`ifconfig ${WIRENIC} ether\`\"" >> ${FSMNT}/etc/rc.conf
- echo "ifconfig_${WIFINIC}=\"ether \${ifconfig_${WIFINIC}##*ether }\"" >> ${FSMNT}/etc/rc.conf
- LAGGPORT="laggport ${WIRENIC} ${LAGGPORT}"
- fi
-
- echo "wlans_${WIFINIC}=\"wlan0\"" >> ${FSMNT}/etc/rc.conf
- echo "cloned_interfaces=\"lagg0\"" >> ${FSMNT}/etc/rc.conf
- echo "ifconfig_lagg0=\"laggproto failover ${LAGGPORT} DHCP\"" >> ${FSMNT}/etc/rc.conf
-
-};
-# Function which detects available nics, and runs them to DHCP on the
+# Function which detects available nics, and enables dhcp on them
save_auto_dhcp()
{
- rm ${TMPDIR}/.niclist >/dev/null 2>/dev/null
- # start by getting a list of nics on this system
- ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist
- if [ -e "${TMPDIR}/.niclist" ]
- then
- while read line
- do
- NIC="`echo $line | cut -d ':' -f 1`"
- DESC="`echo $line | cut -d ':' -f 2`"
- check_is_wifi "${NIC}"
- if [ "$?" = "0" ]
- then
- # We have a wifi device, lets do fancy lagg interface
- enable_lagg_dhcp "${NIC}"
- return
- fi
-
- done < ${TMPDIR}/.niclist
- fi
-
- # Got here, looks like no wifi, so lets simply enable plain-ole-dhcp
- enable_plain_dhcp_all
-
+ enable_dhcp_all
};
diff --git a/usr.sbin/pc-sysinstall/backend/functions-users.sh b/usr.sbin/pc-sysinstall/backend/functions-users.sh
index 4ba8de5..0288ba9 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-users.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-users.sh
@@ -93,6 +93,13 @@ setup_users()
USERPASS="$VAL"
fi
+ echo $line | grep "^userEncPass=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ get_value_from_string "${line}"
+ USERENCPASS="$VAL"
+ fi
+
echo $line | grep "^userShell=" >/dev/null 2>/dev/null
if [ "$?" = "0" ]
then
@@ -135,6 +142,10 @@ setup_users()
then
ARGS="${ARGS} -h 0"
echo "${USERPASS}" >${FSMNT}/.tmpPass
+ elif [ ! -z "${USERENCPASS}" ]
+ then
+ ARGS="${ARGS} -H 0"
+ echo "${USERENCPASS}" >${FSMNT}/.tmpPass
else
ARGS="${ARGS} -h -"
rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null
@@ -160,7 +171,7 @@ setup_users()
add_user "${ARGS}"
# Unset our vars before looking for any more users
- unset USERNAME USERCOMMENT USERPASS USERSHELL USERHOME USERGROUPS
+ unset USERNAME USERCOMMENT USERPASS USERENCPASS USERSHELL USERHOME USERGROUPS
else
exit_err "ERROR: commitUser was called without any userName= entry!!!"
fi
diff --git a/usr.sbin/pc-sysinstall/backend/functions.sh b/usr.sbin/pc-sysinstall/backend/functions.sh
index 2b78bbc..c413968 100755
--- a/usr.sbin/pc-sysinstall/backend/functions.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions.sh
@@ -409,6 +409,7 @@ write_image()
fi
};
+# Setup and install on a new disk / partition
install_fresh()
{
# Lets start setting up the disk slices now
@@ -458,6 +459,39 @@ install_fresh()
echo_log "Installation finished!"
};
+# Extract the system to a pre-mounted directory
+install_extractonly()
+{
+ # We are ready to begin extraction, lets start now
+ init_extraction
+
+ # Check if we have any optional modules to load
+ install_components
+
+ # Check if we have any packages to install
+ install_packages
+
+ # Do any localization in configuration
+ run_localize
+
+ # Save any networking config on the installed system
+ save_networking_install
+
+ # Now add any users
+ setup_users
+
+ # Now run any commands specified
+ run_commands
+
+ # Set a hostname on the install system
+ setup_hostname
+
+ # Set the root_pw if it is specified
+ set_root_pw
+
+ echo_log "Installation finished!"
+};
+
install_image()
{
# We are ready to begin extraction, lets start now
@@ -478,7 +512,7 @@ install_upgrade()
# Do any localization in configuration
run_localize
- # ow run any commands specified
+ # Now run any commands specified
run_commands
# Merge any old configuration files
diff --git a/usr.sbin/pc-sysinstall/backend/parseconfig.sh b/usr.sbin/pc-sysinstall/backend/parseconfig.sh
index 15611fd..ad9c2d7 100755
--- a/usr.sbin/pc-sysinstall/backend/parseconfig.sh
+++ b/usr.sbin/pc-sysinstall/backend/parseconfig.sh
@@ -67,11 +67,10 @@ fi
export CFGF
# Start by doing a sanity check, which will catch any obvious mistakes in the config
-file_sanity_check "installMode disk0 installType installMedium packageType"
+file_sanity_check "installMode installType installMedium packageType"
# We passed the Sanity check, lets grab some of the universal config settings and store them
-check_value installMode "fresh upgrade"
-check_value bootManager "bsd none"
+check_value installMode "fresh upgrade extract"
check_value installType "PCBSD FreeBSD"
check_value installMedium "dvd usb ftp rsync image"
check_value packageType "uzip tar rsync split"
@@ -108,6 +107,16 @@ case "${INSTALLMODE}" in
fi
;;
+ extract)
+ # Extracting only, make sure we have a valid target directory
+ get_value_from_cfg installLocation
+ FSMNT="${VAL}" ; export FSMNT
+ if [ -z "$FSMNT" ] ; then exit_err "Missing installLocation=" ; fi
+ if [ ! -d "$FSMNT" ] ; then exit_err "No such directory: $FSMNT" ; fi
+
+ install_extractonly
+ ;;
+
upgrade)
install_upgrade
;;
diff --git a/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf b/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf
index 6a9f0cb..5d682dc 100644
--- a/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf
+++ b/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf
@@ -36,8 +36,8 @@ RSYNCTRIES="3"
export RSYNCTRIES
# Set our mount-points
-CDMNT="/cdmnt-install"
-FSMNT="/mnt"
+CDMNT=${CDMNT-/cdmnt-install}
+FSMNT=${FSMNT-/mnt}
UZIP_DIR="/usr"
BOOT_PART_MOUNT="/boot-mount"
export FSMNT CDMNT UZIP_DIR BOOT_PART_MOUNT
diff --git a/usr.sbin/pc-sysinstall/examples/README b/usr.sbin/pc-sysinstall/examples/README
index c972286..2eb1e6f 100644
--- a/usr.sbin/pc-sysinstall/examples/README
+++ b/usr.sbin/pc-sysinstall/examples/README
@@ -12,9 +12,9 @@ installed system
When hostname= is not present, pc-sysinstall will auto-generate
a hostname such as freebsd-XXXX or pcbsd-XXXX
-# installMode=(fresh or upgrade)
+# installMode=(fresh/upgrade/extract)
-Set the type of install we are doing, fresh or upgrade.
+Set the type of install we are doing.
Fresh installs will format and mount the target disks before
extracting the install images to the system. Using this mode
@@ -27,6 +27,19 @@ The conf/exclude-from-upgrade file can be used to specify
additional files to exclude from overwriting during the
install process.
+Extract will skip any disk setup, and perform an installation
+to the directory specified by "installLocation=". This location
+should be a directory with your pre-mounted file-systems ready
+for file extraction. When using the "extract" option, /etc/fstab
+on the installed system will *not* be automatically configured.
+
+# installLocation=
+
+Used only when installMode is set to extract.
+
+This is set to the location you want to extract your system to,
+and should already be mounted properly.
+
# installInteractive=(yes or no)
Set if the installer is running in interactive mode, and
@@ -286,7 +299,11 @@ Options for setting up usernames and passwords on the installed system
# rootPass=root
-Set the root password of the installed system to the specified string
+Set the root password of the installed system to the specified plaintext string
+
+# rootEncPass=<encryptedstring>
+
+Set the root password of the installed system to the specified encrypted string
The below variables are used to setup a user on the installed system
Be sure to call commitUser after after adding these values, and before
@@ -295,6 +312,8 @@ starting another user block
# userName=kris
# userComment=Kris Moore
# userPass=mypass
+or
+# userEncPass=<encryptedstring>
# userShell=/bin/csh
# userHome=/home/kris
# userGroups=wheel,operator
@@ -314,7 +333,7 @@ Run the specified command within chroot of the installed system
# runScript=
runScript will copy the specified script into FSMNT, and run it in chroot of the system
-Usefull when you have a 3rd party script on the DVD / USB, and you want to copy it into
+Useful when you have a 3rd party script on the DVD / USB, and you want to copy it into
the installed system and run
# runExtCommand=
@@ -324,7 +343,7 @@ The variable $FSMNT is set to the mount-point of your installed system
########################################################################
-# PC-BSD SPECIFC OPTIONS
+# PC-BSD SPECIFIC OPTIONS
########################################################################
Options for time-zones and NTP on the installed system
diff --git a/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh b/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh
index ff62a6f..2dc7093 100755
--- a/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh
+++ b/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh
@@ -125,7 +125,7 @@ case $1 in
;;
# The user is wanting to create a new partition
- create-part) ${PARTMANAGERDIR}/create-part.sh "${2}" "${3}"
+ create-part) ${PARTMANAGERDIR}/create-part.sh "${2}" "${3}" "${4}" "${5}"
;;
# The user is wanting to delete an existing partition
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index 759a479..b8b9b54 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -82,7 +82,11 @@ struct {
{ 700000, 700099, "/packages-7.0-release" },
{ 701000, 701099, "/packages-7.1-release" },
{ 702000, 702099, "/packages-7.2-release" },
+ { 703000, 703099, "/packages-7.3-release" },
+ { 704000, 704099, "/packages-7.4-release" },
{ 800000, 800499, "/packages-8.0-release" },
+ { 801000, 801499, "/packages-8.1-release" },
+ { 802000, 802499, "/packages-8.2-release" },
{ 300000, 399000, "/packages-3-stable" },
{ 400000, 499000, "/packages-4-stable" },
{ 502100, 502128, "/packages-5-current" },
diff --git a/usr.sbin/portsnap/portsnap/portsnap.sh b/usr.sbin/portsnap/portsnap/portsnap.sh
index f554809..60b20a0 100644
--- a/usr.sbin/portsnap/portsnap/portsnap.sh
+++ b/usr.sbin/portsnap/portsnap/portsnap.sh
@@ -632,7 +632,7 @@ fetch_snapshot() {
fetch -r http://${SERVERNAME}/s/${SNAPSHOTHASH}.tgz || return 1
echo -n "Extracting snapshot... "
- tar -xzf ${SNAPSHOTHASH}.tgz snap/ || return 1
+ tar -xz --numeric-owner -f ${SNAPSHOTHASH}.tgz snap/ || return 1
rm ${SNAPSHOTHASH}.tgz
echo "done."
@@ -896,12 +896,12 @@ extract_run() {
*/)
rm -rf ${PORTSDIR}/${FILE%/}
mkdir -p ${PORTSDIR}/${FILE}
- tar -xzf ${WORKDIR}/files/${HASH}.gz \
+ tar -xz --numeric-owner -f ${WORKDIR}/files/${HASH}.gz \
-C ${PORTSDIR}/${FILE}
;;
*)
rm -f ${PORTSDIR}/${FILE}
- tar -xzf ${WORKDIR}/files/${HASH}.gz \
+ tar -xz --numeric-owner -f ${WORKDIR}/files/${HASH}.gz \
-C ${PORTSDIR} ${FILE}
;;
esac
@@ -966,11 +966,11 @@ update_run() {
case ${FILE} in
*/)
mkdir -p ${PORTSDIR}/${FILE}
- tar -xzf ${WORKDIR}/files/${HASH}.gz \
+ tar -xz --numeric-owner -f ${WORKDIR}/files/${HASH}.gz \
-C ${PORTSDIR}/${FILE}
;;
*)
- tar -xzf ${WORKDIR}/files/${HASH}.gz \
+ tar -xz --numeric-owner -f ${WORKDIR}/files/${HASH}.gz \
-C ${PORTSDIR} ${FILE}
;;
esac
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c
index 912f855..c12209e 100644
--- a/usr.sbin/ppp/bundle.c
+++ b/usr.sbin/ppp/bundle.c
@@ -758,7 +758,7 @@ bundle_Create(const char *prefix, int type, int unit)
return NULL;
}
- log_SetTun(bundle.unit);
+ log_SetTun(bundle.unit, NULL);
ifname = strrchr(bundle.dev.Name, '/');
if (ifname == NULL)
@@ -849,7 +849,7 @@ bundle_Create(const char *prefix, int type, int unit)
bundle.links = datalink_Create("deflink", &bundle, type);
if (bundle.links == NULL) {
log_Printf(LogALERT, "Cannot create data link: %s\n", strerror(errno));
- iface_Destroy(bundle.iface);
+ iface_Free(bundle.iface);
bundle.iface = NULL;
close(bundle.dev.fd);
return NULL;
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index cc23518..0468b32 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -184,6 +184,7 @@ static int DeleteCommand(struct cmdargs const *);
static int NegotiateCommand(struct cmdargs const *);
static int ClearCommand(struct cmdargs const *);
static int RunListCommand(struct cmdargs const *);
+static int IfaceNameCommand(struct cmdargs const *arg);
static int IfaceAddCommand(struct cmdargs const *);
static int IfaceDeleteCommand(struct cmdargs const *);
static int IfaceClearCommand(struct cmdargs const *);
@@ -823,6 +824,10 @@ static struct cmdtab const IfaceCommands[] =
"Delete iface address", "iface delete addr", (void *)1},
{NULL, "delete!", IfaceDeleteCommand, LOCAL_AUTH,
"Delete iface address", "iface delete addr", (void *)1},
+ {"name", NULL, IfaceNameCommand, LOCAL_AUTH,
+ "Set iface name", "iface name name", NULL},
+ {"description", NULL, iface_Descr, LOCAL_AUTH,
+ "Set iface description", "iface description text", NULL},
{"show", NULL, iface_Show, LOCAL_AUTH,
"Show iface address(es)", "iface show", NULL},
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
@@ -3176,6 +3181,21 @@ RunListCommand(struct cmdargs const *arg)
}
static int
+IfaceNameCommand(struct cmdargs const *arg)
+{
+ int n = arg->argn;
+
+ if (arg->argc != n + 1)
+ return -1;
+
+ if (!iface_Name(arg->bundle->iface, arg->argv[n]))
+ return 1;
+
+ log_SetTun(arg->bundle->unit, arg->bundle->iface->name);
+ return 0;
+}
+
+static int
IfaceAddCommand(struct cmdargs const *arg)
{
struct ncpaddr peer, addr;
diff --git a/usr.sbin/ppp/iface.c b/usr.sbin/ppp/iface.c
index 32bb590..7437502 100644
--- a/usr.sbin/ppp/iface.c
+++ b/usr.sbin/ppp/iface.c
@@ -151,6 +151,7 @@ iface_Create(const char *name)
return NULL;
}
iface->name = strdup(name);
+ iface->descr = NULL;
iface->index = ifm->ifm_index;
iface->flags = ifm->ifm_flags;
iface->mtu = 0;
@@ -369,6 +370,103 @@ iface_addr_Add(const char *name, struct iface_addr *addr, int s)
return res != -1;
}
+int
+iface_Name(struct iface *iface, const char *name)
+{
+ struct ifreq ifr;
+ int s;
+ char *newname;
+
+ if ((newname = strdup(name)) == NULL) {
+ log_Printf(LogWARN, "iface name: strdup failed: %s\n", strerror(errno));
+ return 0;
+ }
+
+ if ((s = ID0socket(PF_INET, SOCK_DGRAM, 0)) == -1) {
+ log_Printf(LogERROR, "iface name: socket(): %s\n", strerror(errno));
+ free(newname);
+ return 0;
+ }
+
+ strlcpy(ifr.ifr_name, iface->name, sizeof(ifr.ifr_name));
+ ifr.ifr_data = newname;
+ if (ID0ioctl(s, SIOCSIFNAME, (caddr_t)&ifr) < 0) {
+ log_Printf(LogWARN, "iface name: ioctl(SIOCSIFNAME, %s -> %s): %s\n",
+ name, newname, strerror(errno));
+ free(newname);
+ return 0;
+ }
+
+ free(iface->name);
+ iface->name = newname;
+
+ return 1;
+}
+
+int
+iface_Descr(struct cmdargs const *arg)
+{
+ struct ifreq ifr;
+ struct iface *iface;
+ size_t sz, len;
+ int s, n, ifdescr_maxlen;
+ char *descr;
+
+ sz = sizeof(int);
+ if (sysctlbyname("net.ifdescr_maxlen", &ifdescr_maxlen, &sz, NULL, 0) < 0) {
+ log_Printf(LogERROR, "iface descr: sysctl failed: %s\n", strerror(errno));
+ return 1;
+ }
+
+ if (ifdescr_maxlen < 1) {
+ log_Printf(LogERROR, "iface descr: sysctl net.ifdescr_maxlen < 1\n");
+ return 1;
+ }
+
+ sz = sizeof(char) * ifdescr_maxlen;
+ if ((descr = malloc(sz)) == NULL) {
+ log_Printf(LogERROR, "iface descr: malloc failed: %s\n", strerror(errno));
+ return 1;
+ }
+
+ *descr = '\0';
+ n = arg->argn;
+ while (n < arg->argc) {
+ if (n > arg->argn && (len = strlcat(descr, " ", sz)) >= sz)
+ break;
+ if ((len = strlcat(descr, arg->argv[n], sz)) >= sz)
+ break;
+ ++n;
+ }
+ if (len >= sz) {
+ log_Printf(LogERROR, "iface descr: description exceeds maximum (%d)\n",
+ ifdescr_maxlen-1);
+ free(descr);
+ return 1;
+ }
+
+ if ((s = ID0socket(PF_INET, SOCK_DGRAM, 0)) == -1) {
+ log_Printf(LogERROR, "iface descr: socket(): %s\n", strerror(errno));
+ free(descr);
+ return 1;
+ }
+
+ iface = arg->bundle->iface;
+ strlcpy(ifr.ifr_name, iface->name, sizeof(ifr.ifr_name));
+ ifr.ifr_buffer.length = strlen(descr) + 1;
+ ifr.ifr_buffer.buffer = descr;
+ if (ID0ioctl(s, SIOCSIFDESCR, (caddr_t)&ifr) < 0) {
+ log_Printf(LogWARN, "iface descr: ioctl(SIOCSIFDESCR, %s): %s\n",
+ descr, strerror(errno));
+ free(descr);
+ return 1;
+ }
+
+ free(iface->descr);
+ iface->descr = descr;
+
+ return 0;
+}
void
iface_Clear(struct iface *iface, struct ncp *ncp, int family, int how)
@@ -608,18 +706,30 @@ iface_ClearFlags(const char *ifname, int flags)
}
void
-iface_Destroy(struct iface *iface)
+iface_Free(struct iface *iface)
{
- /*
- * iface_Clear(iface, IFACE_CLEAR_ALL) must be called manually
- * if that's what the user wants. It's better to leave the interface
- * allocated so that existing connections can continue to work.
- */
-
- if (iface != NULL) {
free(iface->name);
+ free(iface->descr);
free(iface->addr);
free(iface);
+}
+
+void
+iface_Destroy(struct iface *iface)
+{
+ struct ifreq ifr;
+ int s;
+
+ if (iface != NULL) {
+ if ((s = ID0socket(PF_INET, SOCK_DGRAM, 0)) == -1) {
+ log_Printf(LogERROR, "iface_Destroy: socket(): %s\n", strerror(errno));
+ } else {
+ strlcpy(ifr.ifr_name, iface->name, sizeof(ifr.ifr_name));
+ if (ID0ioctl(s, SIOCIFDESTROY, (caddr_t)&ifr) < 0)
+ log_Printf(LogWARN, "iface_Destroy: ioctl(SIOCIFDESTROY, %s): %s\n",
+ iface->name, strerror(errno));
+ }
+ iface_Free(iface);
}
}
@@ -661,7 +771,7 @@ iface_Show(struct cmdargs const *arg)
current = iface_Create(iface->name);
flags = iface->flags = current->flags;
- iface_Destroy(current);
+ iface_Free(current);
prompt_Printf(arg->prompt, "%s (idx %d) <", iface->name, iface->index);
for (f = 0; f < sizeof if_flags / sizeof if_flags[0]; f++)
diff --git a/usr.sbin/ppp/iface.h b/usr.sbin/ppp/iface.h
index 1fd0a70..ea3e06d 100644
--- a/usr.sbin/ppp/iface.h
+++ b/usr.sbin/ppp/iface.h
@@ -36,6 +36,7 @@ struct iface_addr {
struct iface {
char *name; /* Interface name (malloc'd) */
+ char *descr; /* Interface description (malloc'd) */
int index; /* Interface index */
int flags; /* Interface flags (IFF_*) */
unsigned long mtu; /* struct tuninfo MTU */
@@ -55,11 +56,14 @@ struct iface {
extern struct iface *iface_Create(const char *name);
extern void iface_Clear(struct iface *, struct ncp *, int, int);
+extern int iface_Name(struct iface *, const char *);
+extern int iface_Descr(struct cmdargs const *);
extern int iface_Add(struct iface *, struct ncp *, const struct ncprange *,
const struct ncpaddr *, int);
extern int iface_Delete(struct iface *, struct ncp *, const struct ncpaddr *);
extern int iface_Show(struct cmdargs const *);
extern int iface_SetFlags(const char *, int);
extern int iface_ClearFlags(const char *, int);
+extern void iface_Free(struct iface *);
extern void iface_Destroy(struct iface *);
extern void iface_ParseHdr(struct ifa_msghdr *, struct sockaddr *[RTAX_MAX]);
diff --git a/usr.sbin/ppp/log.c b/usr.sbin/ppp/log.c
index c90720b..76043b4 100644
--- a/usr.sbin/ppp/log.c
+++ b/usr.sbin/ppp/log.c
@@ -75,6 +75,7 @@ static const char *const LogNames[] = {
static u_long LogMask = MSK(LogPHASE);
static u_long LogMaskLocal = MSK(LogERROR) | MSK(LogALERT) | MSK(LogWARN);
static int LogTunno = -1;
+static const char *LogIfaceName;
static struct prompt *promptlist; /* Where to log local stuff */
struct prompt *log_PromptContext;
int log_PromptListChanged;
@@ -296,9 +297,10 @@ log_Open(const char *Name)
}
void
-log_SetTun(int tunno)
+log_SetTun(int tunno, const char *ifaceName)
{
LogTunno = tunno;
+ LogIfaceName = ifaceName;
}
void
@@ -306,6 +308,7 @@ log_Close()
{
closelog();
LogTunno = -1;
+ LogIfaceName = NULL;
}
void
@@ -319,10 +322,14 @@ log_Printf(int lev, const char *fmt,...)
va_start(ap, fmt);
if (promptlist && (log_IsKept(lev) & LOG_KEPT_LOCAL)) {
- if ((log_IsKept(LogTUN) & LOG_KEPT_LOCAL) && LogTunno != -1)
- snprintf(nfmt, sizeof nfmt, "%s%d: %s: %s", TUN_NAME,
+ if ((log_IsKept(LogTUN) & LOG_KEPT_LOCAL) && LogTunno != -1) {
+ if (LogIfaceName)
+ snprintf(nfmt, sizeof nfmt, "%s%d(%s): %s: %s", TUN_NAME,
+ LogTunno, LogIfaceName, log_Name(lev), fmt);
+ else
+ snprintf(nfmt, sizeof nfmt, "%s%d: %s: %s", TUN_NAME,
LogTunno, log_Name(lev), fmt);
- else
+ } else
snprintf(nfmt, sizeof nfmt, "%s: %s", log_Name(lev), fmt);
if (log_PromptContext && lev == LogWARN)
@@ -337,10 +344,14 @@ log_Printf(int lev, const char *fmt,...)
va_start(ap, fmt);
if ((log_IsKept(lev) & LOG_KEPT_SYSLOG) &&
(lev != LogWARN || !log_PromptContext)) {
- if ((log_IsKept(LogTUN) & LOG_KEPT_SYSLOG) && LogTunno != -1)
- snprintf(nfmt, sizeof nfmt, "%s%d: %s: %s", TUN_NAME,
+ if ((log_IsKept(LogTUN) & LOG_KEPT_SYSLOG) && LogTunno != -1) {
+ if (LogIfaceName)
+ snprintf(nfmt, sizeof nfmt, "%s%d(%s): %s: %s", TUN_NAME,
+ LogTunno, LogIfaceName, log_Name(lev), fmt);
+ else
+ snprintf(nfmt, sizeof nfmt, "%s%d: %s: %s", TUN_NAME,
LogTunno, log_Name(lev), fmt);
- else
+ } else
snprintf(nfmt, sizeof nfmt, "%s: %s", log_Name(lev), fmt);
vsyslog(syslogLevel(lev), nfmt, ap);
}
diff --git a/usr.sbin/ppp/log.h b/usr.sbin/ppp/log.h
index 0da4b8c..139863d 100644
--- a/usr.sbin/ppp/log.h
+++ b/usr.sbin/ppp/log.h
@@ -76,7 +76,7 @@ extern void log_DiscardAllLocal(u_long *);
extern int log_IsKept(int);
extern int log_IsKeptLocal(int, u_long);
extern void log_Open(const char *);
-extern void log_SetTun(int);
+extern void log_SetTun(int, const char *);
extern void log_Close(void);
#ifdef __GNUC__
extern void log_Printf(int, const char *,...)
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index fd826d0..de867ea 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -386,11 +386,6 @@ main(int argc, char **argv)
/* NOTE: We may now have changed argv[1] via a ``set proctitle'' */
- if (prompt) {
- prompt->bundle = bundle; /* couldn't do it earlier */
- if (!sw.quiet)
- prompt_Printf(prompt, "Using interface: %s\n", bundle->iface->name);
- }
SignalBundle = bundle;
bundle->NatEnabled = sw.nat;
if (sw.nat)
@@ -430,6 +425,12 @@ main(int argc, char **argv)
AbortProgram(EX_START);
}
+ if (prompt) {
+ prompt->bundle = bundle; /* couldn't do it earlier */
+ if (!sw.quiet)
+ prompt_Printf(prompt, "Using interface: %s\n", bundle->iface->name);
+ }
+
if (sw.mode != PHYS_INTERACTIVE) {
if (sw.mode != PHYS_DIRECT) {
if (!sw.fg) {
diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4
index a711d58..fcf62d6 100644
--- a/usr.sbin/ppp/ppp.8.m4
+++ b/usr.sbin/ppp/ppp.8.m4
@@ -3924,6 +3924,13 @@ If the
.Dq !\&
is used, no error is given if the address is not currently assigned to
the interface (and no deletion takes place).
+.It iface name Ar name
+Renames the interface to
+.Ar name .
+.It iface description Ar description
+Sets the interface description to
+.Ar description .
+Useful if you have many interfaces on your system.
.It iface show
Shows the current state and current addresses for the interface.
It is much the same as running
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index c8364ca..dd92c43 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -151,14 +151,14 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
cnf->home = arg->val;
}
+ dmode = S_IRWXU | S_IRWXG | S_IRWXO;
if ((arg = getarg(args, 'M')) != NULL) {
dmode_c = arg->val;
if ((set = setmode(dmode_c)) == NULL)
errx(EX_DATAERR, "invalid directory creation mode '%s'",
dmode_c);
- dmode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO);
+ cnf->homemode = getmode(set, dmode);
free(set);
- cnf->homemode = dmode;
}
/*
@@ -186,7 +186,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
if (strchr(cnf->home+1, '/') == NULL) {
strcpy(dbuf, "/usr");
strncat(dbuf, cnf->home, MAXPATHLEN-5);
- if (mkdir(dbuf, cnf->homemode) != -1 || errno == EEXIST) {
+ if (mkdir(dbuf, dmode) != -1 || errno == EEXIST) {
chown(dbuf, 0, 0);
/*
* Skip first "/" and create symlink:
@@ -202,7 +202,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
while ((p = strchr(++p, '/')) != NULL) {
*p = '\0';
if (stat(dbuf, &st) == -1) {
- if (mkdir(dbuf, cnf->homemode) == -1)
+ if (mkdir(dbuf, dmode) == -1)
goto direrr;
chown(dbuf, 0, 0);
} else if (!S_ISDIR(st.st_mode))
@@ -211,7 +211,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
}
}
if (stat(dbuf, &st) == -1) {
- if (mkdir(dbuf, cnf->homemode) == -1) {
+ if (mkdir(dbuf, dmode) == -1) {
direrr: err(EX_OSFILE, "mkdir '%s'", dbuf);
}
chown(dbuf, 0, 0);
diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c
index 4da58ba..979eef4 100644
--- a/usr.sbin/quot/quot.c
+++ b/usr.sbin/quot/quot.c
@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
#include <sys/stdint.h>
#include <sys/mount.h>
#include <sys/disklabel.h>
-#include <sys/time.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@@ -49,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
/* some flags of what to do: */
diff --git a/usr.sbin/rpc.lockd/Makefile b/usr.sbin/rpc.lockd/Makefile
index c81da82..e2185c8 100644
--- a/usr.sbin/rpc.lockd/Makefile
+++ b/usr.sbin/rpc.lockd/Makefile
@@ -7,7 +7,7 @@ MLINKS= rpc.lockd.8 lockd.8
SRCS= kern.c nlm_prot_svc.c lockd.c lock_proc.c lockd_lock.c
CFLAGS+= -I. -I${DESTDIR}/usr/include/rpcsvc
-WARNS?= 0
+WARNS?= 3
DPADD= ${LIBRPCSVC} ${LIBUTIL}
LDADD= -lrpcsvc -lutil
diff --git a/usr.sbin/rpc.lockd/lockd.c b/usr.sbin/rpc.lockd/lockd.c
index c111b58..fb9e536 100644
--- a/usr.sbin/rpc.lockd/lockd.c
+++ b/usr.sbin/rpc.lockd/lockd.c
@@ -88,6 +88,7 @@ int nhosts = 0;
int xcreated = 0;
char **addrs; /* actually (netid, uaddr) pairs */
int naddrs; /* count of how many (netid, uaddr) pairs */
+char localhost[] = "localhost";
void create_service(struct netconfig *nconf);
void lookup_addresses(struct netconfig *nconf);
@@ -626,11 +627,8 @@ lookup_addresses(struct netconfig *nconf)
struct sockaddr_in6 *sin6;
struct __rpc_sockinfo si;
struct netbuf servaddr;
- SVCXPRT *transp = NULL;
int aicode;
int nhostsbak;
- int r;
- int registered = 0;
u_int32_t host_addr[4]; /* IPv4 or IPv6 */
char *uaddr;
@@ -789,7 +787,6 @@ init_nsm(void)
my_id id;
sm_stat stat;
char name[] = "NFS NLM";
- char localhost[] = "localhost";
/*
* !!!
diff --git a/usr.sbin/rpc.lockd/lockd_lock.c b/usr.sbin/rpc.lockd/lockd_lock.c
index 5d37c32..5900bfa 100644
--- a/usr.sbin/rpc.lockd/lockd_lock.c
+++ b/usr.sbin/rpc.lockd/lockd_lock.c
@@ -197,6 +197,7 @@ enum hwlock_status lock_hwlock(struct file_lock *fl);
enum split_status split_nfslock(const struct file_lock *exist_lock,
const struct file_lock *unlock_lock, struct file_lock **left_lock,
struct file_lock **right_lock);
+int duplicate_block(struct file_lock *fl);
void add_blockingfilelock(struct file_lock *fl);
enum hwlock_status unlock_hwlock(const struct file_lock *fl);
enum hwlock_status test_hwlock(const struct file_lock *fl,
@@ -1198,7 +1199,7 @@ test_hwlock(fl, conflicting_fl)
int
duplicate_block(struct file_lock *fl)
{
- struct file_lock *ifl,*nfl;
+ struct file_lock *ifl;
int retval = 0;
debuglog("Entering duplicate_block");
diff --git a/usr.sbin/rtadvd/Makefile b/usr.sbin/rtadvd/Makefile
index 90b45f1..9dbfc99 100644
--- a/usr.sbin/rtadvd/Makefile
+++ b/usr.sbin/rtadvd/Makefile
@@ -18,6 +18,9 @@ PROG= rtadvd
MAN= rtadvd.conf.5 rtadvd.8
SRCS= rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c
+DPADD= ${LIBUTIL}
+LDADD= -lutil
+
CFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_POLL_H -DROUTEINFO
WARNS?= 1
diff --git a/usr.sbin/rtadvd/rtadvd.8 b/usr.sbin/rtadvd/rtadvd.8
index 4cabb4a..7bc3064 100644
--- a/usr.sbin/rtadvd/rtadvd.8
+++ b/usr.sbin/rtadvd/rtadvd.8
@@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 17, 1998
+.Dd December 22, 2010
.Dt RTADVD 8
.Os
.Sh NAME
@@ -39,6 +39,8 @@
.Nm
.Op Fl dDfMRs
.Op Fl c Ar configfile
+.Op Fl F Ar dumpfile
+.Op Fl p Ar pidfile
.Ar interface ...
.Sh DESCRIPTION
.Nm
@@ -126,6 +128,13 @@ Even more debugging information is printed.
.It Fl f
Foreground mode (useful when debugging).
Log messages will be dumped to stderr when this option is specified.
+.It Fl F
+Specify an alternative file in which to dump internal states when
+.Nm
+receives signal
+.Dv SIGUSR1 .
+The default is
+.Pa /var/run/rtadvd.dump .
.It Fl M
Specify an interface to join the all-routers site-local multicast group.
By default,
@@ -135,6 +144,10 @@ line.
This option has meaning only with the
.Fl R
option, which enables routing renumbering protocol support.
+.It Fl p
+Specify an alternative file in which to store the process ID.
+The default is
+.Pa /var/run/rtadvd.pid.
.It Fl R
Accept router renumbering requests.
If you enable it, certain IPsec setup is suggested for security reasons.
@@ -150,7 +163,9 @@ Upon receipt of signal
.Dv SIGUSR1 ,
.Nm
will dump the current internal state into
-.Pa /var/run/rtadvd.dump .
+.Pa /var/run/rtadvd.dump
+or the file specified with option
+.Fl F .
.Pp
Use
.Dv SIGTERM
@@ -167,10 +182,9 @@ to all the interfaces
.It Pa /etc/rtadvd.conf
The default configuration file.
.It Pa /var/run/rtadvd.pid
-contains the pid of the currently running
-.Nm .
+The default process ID file.
.It Pa /var/run/rtadvd.dump
-The file in which
+The default file in which
.Nm
dumps its internal state.
.El
diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c
index af72bb9..654f206 100644
--- a/usr.sbin/rtadvd/rtadvd.c
+++ b/usr.sbin/rtadvd/rtadvd.c
@@ -51,6 +51,7 @@
#include <stdio.h>
#include <err.h>
#include <errno.h>
+#include <libutil.h>
#include <string.h>
#include <stdlib.h>
#include <syslog.h>
@@ -79,8 +80,9 @@ struct iovec sndiov[2];
struct sockaddr_in6 rcvfrom;
struct sockaddr_in6 sin6_allnodes = {sizeof(sin6_allnodes), AF_INET6};
struct in6_addr in6a_site_allrouters;
-static char *dumpfilename = "/var/run/rtadvd.dump"; /* XXX: should be configurable */
-static char *pidfilename = "/var/run/rtadvd.pid"; /* should be configurable */
+static char *dumpfilename = "/var/run/rtadvd.dump";
+static char *pidfilename = "/var/run/rtadvd.pid";
+static struct pidfh *pfh;
static char *mcastif;
int sock;
int rtsock = -1;
@@ -159,11 +161,10 @@ main(argc, argv)
struct timeval *timeout;
int i, ch;
int fflag = 0, logopt;
- FILE *pidfp;
- pid_t pid;
+ pid_t pid, otherpid;
/* get command line options and arguments */
- while ((ch = getopt(argc, argv, "c:dDfM:Rs")) != -1) {
+ while ((ch = getopt(argc, argv, "c:dDF:fMp:Rs")) != -1) {
switch (ch) {
case 'c':
conffile = optarg;
@@ -189,6 +190,12 @@ main(argc, argv)
case 's':
sflag = 1;
break;
+ case 'p':
+ pidfilename = optarg;
+ break;
+ case 'F':
+ dumpfilename = optarg;
+ break;
}
}
argc -= optind;
@@ -196,7 +203,7 @@ main(argc, argv)
if (argc == 0) {
fprintf(stderr,
"usage: rtadvd [-dDfMRs] [-c conffile] "
- "interfaces...\n");
+ "[-F dumpfile] [-p pidfile] interfaces...\n");
exit(1);
}
@@ -234,6 +241,16 @@ main(argc, argv)
exit(1);
}
+ pfh = pidfile_open(pidfilename, 0600, &otherpid);
+ if (pfh == NULL) {
+ if (errno == EEXIST)
+ errx(1, "%s already running, pid: %d",
+ getprogname(), otherpid);
+ syslog(LOG_ERR,
+ "<%s> failed to open the pid log file, run anyway.",
+ __func__);
+ }
+
if (!fflag)
daemon(1, 0);
@@ -241,14 +258,7 @@ main(argc, argv)
/* record the current PID */
pid = getpid();
- if ((pidfp = fopen(pidfilename, "w")) == NULL) {
- syslog(LOG_ERR,
- "<%s> failed to open the pid log file, run anyway.",
- __func__);
- } else {
- fprintf(pidfp, "%d\n", pid);
- fclose(pidfp);
- }
+ pidfile_write(pfh);
#ifdef HAVE_POLL_H
set[0].fd = sock;
@@ -383,6 +393,7 @@ die()
ra_output(ra);
sleep(MIN_DELAY_BETWEEN_RAS);
}
+ pidfile_remove(pfh);
exit(0);
/*NOTREACHED*/
}
diff --git a/usr.sbin/rtprio/rtprio.c b/usr.sbin/rtprio/rtprio.c
index 245f714..38dade8 100644
--- a/usr.sbin/rtprio/rtprio.c
+++ b/usr.sbin/rtprio/rtprio.c
@@ -37,31 +37,31 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/rtprio.h>
-#include <sys/errno.h>
#include <ctype.h>
#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-static void usage();
+static int parseint(const char *, const char *);
+static void usage(void);
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char *argv[])
{
- char *p;
- int proc = 0;
struct rtprio rtp;
+ char *p;
+ pid_t proc;
/* find basename */
if ((p = rindex(argv[0], '/')) == NULL)
p = argv[0];
else
++p;
+ proc = 0;
if (!strcmp(p, "rtprio"))
rtp.type = RTP_PRIO_REALTIME;
@@ -70,12 +70,12 @@ main(argc, argv)
switch (argc) {
case 2:
- proc = abs(atoi(argv[1])); /* Should check if numeric
- * arg! */
+ proc = parseint(argv[1], "pid");
+ proc = abs(proc);
/* FALLTHROUGH */
case 1:
if (rtprio(RTP_LOOKUP, proc, &rtp) != 0)
- err(1, "%s", argv[0]);
+ err(1, "RTP_LOOKUP");
printf("%s: ", p);
switch (rtp.type) {
case RTP_PRIO_REALTIME:
@@ -103,19 +103,17 @@ main(argc, argv)
usage();
break;
}
- } else {
- rtp.prio = atoi(argv[1]);
- }
+ } else
+ rtp.prio = parseint(argv[1], "priority");
} else {
usage();
break;
}
if (argv[2][0] == '-')
- proc = -atoi(argv[2]);
-
+ proc = parseint(argv[2] + 1, "pid");
if (rtprio(RTP_SET, proc, &rtp) != 0)
- err(1, "%s", argv[0]);
+ err(1, "RTP_SET");
if (proc == 0) {
execvp(argv[2], &argv[2]);
@@ -123,12 +121,28 @@ main(argc, argv)
}
exit(0);
}
- exit (1);
+ exit(1);
+}
+
+static int
+parseint(const char *str, const char *errname)
+{
+ char *endp;
+ long res;
+
+ errno = 0;
+ res = strtol(str, &endp, 10);
+ if (errno != 0 || endp == str || *endp != '\0')
+ errx(1, "%s must be a number", errname);
+ if (res >= INT_MAX)
+ errx(1, "Integer overflow parsing %s", errname);
+ return (res);
}
static void
-usage()
+usage(void)
{
+
(void) fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n",
"usage: [id|rt]prio",
" [id|rt]prio [-]pid",
diff --git a/usr.sbin/sade/Makefile b/usr.sbin/sade/Makefile
index ad28489..1bcb073 100644
--- a/usr.sbin/sade/Makefile
+++ b/usr.sbin/sade/Makefile
@@ -19,9 +19,9 @@ WARNS?= 3
.if ${MACHINE} == "pc98"
CFLAGS+= -DPC98
.endif
-CFLAGS+= -I${.CURDIR}/../../gnu/lib/libdialog -I.
+CFLAGS+= -I${.CURDIR}/../../gnu/lib/libodialog -I.
-DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBUTIL} ${LIBDISK}
-LDADD= -ldialog -lncurses -lutil -ldisk
+DPADD= ${LIBODIALOG} ${LIBNCURSES} ${LIBUTIL} ${LIBDISK}
+LDADD= -lodialog -lncurses -lutil -ldisk
.include <bsd.prog.mk>
diff --git a/usr.sbin/spkrtest/spkrtest.sh b/usr.sbin/spkrtest/spkrtest.sh
index c682b03..f9f0f06 100644
--- a/usr.sbin/spkrtest/spkrtest.sh
+++ b/usr.sbin/spkrtest/spkrtest.sh
@@ -53,7 +53,7 @@ fi
/usr/bin/dialog --title "Speaker test" --checklist \
"Please select the melodies you wish to play (space for select)" \
- -1 -1 10 \
+ 0 0 0 \
reveille "Reveille" OFF \
contact "Contact theme from Close Encounters" OFF \
dance "Lord of the Dance (aka Simple Gifts)" OFF \
diff --git a/usr.sbin/sysinstall/Makefile b/usr.sbin/sysinstall/Makefile
index d18033a..9eb09e2 100644
--- a/usr.sbin/sysinstall/Makefile
+++ b/usr.sbin/sysinstall/Makefile
@@ -18,12 +18,12 @@ CFLAGS+= -DUSE_GZIP=1
.if ${MACHINE} == "pc98"
CFLAGS+= -DPC98
.endif
-CFLAGS+= -I${.CURDIR}/../../gnu/lib/libdialog -I.
+CFLAGS+= -I${.CURDIR}/../../gnu/lib/libodialog -I.
WARNS?= 2
-DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO}
-LDADD= -ldialog -lncurses -lutil -ldisk -lftpio
+DPADD= ${LIBODIALOG} ${LIBNCURSES} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO}
+LDADD= -lodialog -lncurses -lutil -ldisk -lftpio
CLEANFILES= makedevs.c rtermcap
CLEANFILES+= keymap.tmp keymap.h countries.tmp countries.h
diff --git a/usr.sbin/sysinstall/devices.c b/usr.sbin/sysinstall/devices.c
index 6fa34f2..53ebb89 100644
--- a/usr.sbin/sysinstall/devices.c
+++ b/usr.sbin/sysinstall/devices.c
@@ -109,6 +109,7 @@ static struct _devname {
NETWORK("cas", "Sun Cassini/Cassini+ or NS DP83065 Saturn Ethernet"),
NETWORK("cue", "CATC USB Ethernet adapter"),
NETWORK("cxgb", "Chelsio T3 10Gb Ethernet card"),
+ NETWORK("cxgbe", "Chelsio T4 10Gb Ethernet card"),
NETWORK("fpa", "DEC DEFPA PCI FDDI card"),
NETWORK("sr", "SDL T1/E1 sync serial PCI card"),
NETWORK("cc3i", "SDL HSSI sync serial PCI card"),
@@ -169,6 +170,7 @@ static struct _devname {
NETWORK("urtw", "Realtek 8187L USB wireless adapter"),
NETWORK("vge", "VIA VT612x PCI Gigabit Ethernet card"),
NETWORK("vr", "VIA VT3043/VT86C100A Rhine PCI Ethernet card"),
+ NETWORK("vte", "DM&P Vortex86 RDC R6040 Fast Ethernet"),
NETWORK("vlan", "IEEE 802.1Q VLAN network interface"),
NETWORK("vx", "3COM 3c590 / 3c595 Ethernet card"),
NETWORK("wb", "Winbond W89C840F PCI Ethernet card"),
diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c
index daacaa6..df48caa 100644
--- a/usr.sbin/sysinstall/install.c
+++ b/usr.sbin/sysinstall/install.c
@@ -637,10 +637,10 @@ installStandard(dialogMenuItem *self)
variable_set2(SYSTEM_STATE, "standard", 0);
dialog_clear_norefresh();
#ifdef WITH_SLICES
- msgConfirm("In the next menu, you will need to set up a DOS-style (\"fdisk\") partitioning\n"
+ msgConfirm("In the next menu, you will need to set up an MBR partitioning\n"
"scheme for your hard disk. If you simply wish to devote all disk space\n"
- "to FreeBSD (overwriting anything else that might be on the disk(s) selected)\n"
- "then use the (A)ll command to select the default partitioning scheme followed\n"
+ "to FreeBSD (overwriting anything else that might be on the disk selected)\n"
+ "then use the (A)ll command to create a single partition followed\n"
"by a (Q)uit. If you wish to allocate only free space to FreeBSD, move to a\n"
"partition marked \"unused\" and use the (C)reate command.");
@@ -655,7 +655,7 @@ nodisks:
goto nodisks;
}
- msgConfirm("Now you need to create BSD partitions inside of the fdisk partition(s)\n"
+ msgConfirm("Now you need to create BSD partitions inside of the MBR partition(s)\n"
"just created. If you have a reasonable amount of disk space (1GB or more)\n"
"and don't have any special requirements, simply use the (A)uto command to\n"
"allocate space automatically. If you have more specific needs or just don't\n"
@@ -872,6 +872,9 @@ installConfigure(void)
if (!msgNoYes("Visit the general configuration menu for a chance to set\n"
"any last options?"))
dmenuOpenSimple(&MenuConfigure, FALSE);
+ else
+ dmenuExit(NULL);
+
configRC_conf();
sync();
}
diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c
index e2f6c41..5b80f1d 100644
--- a/usr.sbin/sysinstall/media.c
+++ b/usr.sbin/sysinstall/media.c
@@ -239,7 +239,7 @@ mediaSetUSB(dialogMenuItem *self)
cnt = deviceCount(devs);
if (!cnt) {
- msgConfirm("No USB devices found!");
+ msgConfirm("No USB devices found (try Options/Re-scan Devices)");
return DITEM_FAILURE | DITEM_CONTINUE;
}
else if (cnt > 1) {
diff --git a/usr.sbin/sysinstall/menus.c b/usr.sbin/sysinstall/menus.c
index 2c669e8..05778c3 100644
--- a/usr.sbin/sysinstall/menus.c
+++ b/usr.sbin/sysinstall/menus.c
@@ -174,7 +174,7 @@ DMenu MenuIndex = {
#ifdef WITH_MICE
{ " Device, Mouse", "The mouse configuration menu.", NULL, dmenuSubmenu, NULL, &MenuMouse },
#endif
- { " Disklabel", "The disk Label editor", NULL, diskLabelEditor },
+ { " Disklabel", "The disk label editor", NULL, diskLabelEditor },
{ " Dists, All", "Root of the distribution tree.", NULL, dmenuSubmenu, NULL, &MenuDistributions },
{ " Dists, Basic", "Basic FreeBSD distribution menu.", NULL, dmenuSubmenu, NULL, &MenuSubDistributions },
{ " Dists, Developer", "Select developer's distribution.", checkDistDeveloper, distSetDeveloper },
@@ -213,7 +213,7 @@ DMenu MenuIndex = {
{ " Media, UFS", "Select UFS installation media.", NULL, mediaSetUFS },
{ " Media, FTP", "Select FTP installation media.", NULL, mediaSetFTP },
{ " Media, FTP Passive", "Select passive FTP installation media.", NULL, mediaSetFTPPassive },
- { " Media, HTTP", "Select FTP via HTTP proxy installation media.", NULL, mediaSetHTTP },
+ { " Media, HTTP", "Select FTP via HTTP proxy install media.", NULL, mediaSetHTTP },
{ " Network Interfaces", "Configure network interfaces", NULL, tcpMenuSelect },
{ " Networking Services", "The network services menu.", NULL, dmenuSubmenu, NULL, &MenuNetworking },
{ " NFS, client", "Set NFS client flag.", dmenuVarCheck, dmenuToggleVariable, NULL, "nfs_client_enable=YES" },
@@ -222,7 +222,7 @@ DMenu MenuIndex = {
{ " Options", "The options editor.", NULL, optionsEditor },
{ " Packages", "The packages collection", NULL, configPackages },
#ifdef WITH_SLICES
- { " Partition", "The disk Slice (PC-style partition) Editor", NULL, diskPartitionEditor },
+ { " Partition", "The disk slice (PC-style partition) editor", NULL, diskPartitionEditor },
#endif
{ " PCNFSD", "Run authentication server for PC-NFS.", dmenuVarCheck, configPCNFSD, NULL, "pcnfsd" },
{ " Root Password", "Set the system manager's password.", NULL, dmenuSystemCommand, NULL, "passwd root" },
@@ -1209,10 +1209,10 @@ DMenu MenuConfigure = {
{ " Root Password", "Set the system manager's password",
NULL, dmenuSystemCommand, NULL, "passwd root" },
#ifdef WITH_SLICES
- { " Fdisk", "The disk Slice (PC-style partition) Editor",
+ { " Fdisk", "The disk slice (PC-style partition) editor",
NULL, diskPartitionEditor },
#endif
- { " Label", "The disk Label editor",
+ { " Label", "The disk label editor",
NULL, diskLabelEditor },
{ " User Management", "Add user and group information",
NULL, dmenuSubmenu, NULL, &MenuUsermgmt },
@@ -1860,10 +1860,7 @@ DMenu MenuSysconsKeymap = {
"System Console Keymap",
"The system console driver for FreeBSD defaults to a standard\n"
"\"PC-98x1\" keyboard map. Users may wish to choose one of the\n"
- "other keymaps below.\n"
- "Note that sysinstall itself only uses the part of the keyboard map\n"
- "which is required to generate the ANSI character subset, but your\n"
- "choice of keymap will also be saved for later (fuller) use.",
+ "other keymaps below.",
"Choose a keyboard map",
NULL,
{ { "Japanese PC-98x1", "Japanese PC-98x1 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=jp.pc98" },
@@ -1875,12 +1872,8 @@ DMenu MenuSysconsKeymap = {
DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
"System Console Keymap",
"The system console driver for FreeBSD defaults to a standard\n"
- "\"American\" keyboard map. Users in other countries (or with\n"
- "different keyboard preferences) may wish to choose one of the\n"
- "other keymaps below.\n"
- "Note that sysinstall itself only uses the part of the keyboard map\n"
- "which is required to generate the ANSI character subset, but your\n"
- "choice of keymap will also be saved for later (fuller) use.",
+ "\"US\" keyboard map. Users may wish to choose one of the\n"
+ "other keymaps below.",
"Choose a keyboard map",
NULL,
{ { "Belgian", "Belgian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=be.iso" },
@@ -1958,7 +1951,7 @@ DMenu MenuSysconsKeyrate = {
{ "Normal", "\"Normal\" keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=normal" },
{ "Fast", "Fast keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=fast" },
{ "Default", "Use default keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=NO" },
- { NULL } },
+ { NULL } }
};
DMenu MenuSysconsSaver = {
@@ -1994,9 +1987,11 @@ DMenu MenuSysconsSaver = {
dmenuVarCheck, configSaver, NULL, "saver=star" },
{ "c Warp", "A \"stars warping\" effect",
dmenuVarCheck, configSaver, NULL, "saver=warp" },
+ { "d None", "Disable the screensaver",
+ dmenuVarCheck, configSaver, NULL, "saver=NO" },
{ "Timeout", "Set the screen saver timeout interval",
NULL, configSaverTimeout, NULL, NULL, ' ', ' ', ' ' },
- { NULL } },
+ { NULL } }
};
#ifndef PC98
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index e97f8dc..045da5b 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1093,8 +1093,9 @@ fprintlog(struct filed *f, int flags, const char *msg)
v->iov_len = snprintf(greetings, sizeof greetings,
"\r\n\7Message from syslogd@%s at %.24s ...\r\n",
f->f_prevhost, f->f_lasttime);
- if (v->iov_len > 0)
- v++;
+ if (v->iov_len >= sizeof greetings)
+ v->iov_len = sizeof greetings - 1;
+ v++;
v->iov_base = nul;
v->iov_len = 0;
v++;
diff --git a/usr.sbin/timed/timed/acksend.c b/usr.sbin/timed/timed/acksend.c
index 8bde743..fde1404 100644
--- a/usr.sbin/timed/timed/acksend.c
+++ b/usr.sbin/timed/timed/acksend.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/byteorder.c b/usr.sbin/timed/timed/byteorder.c
index 038dd56..a9fd151 100644
--- a/usr.sbin/timed/timed/byteorder.c
+++ b/usr.sbin/timed/timed/byteorder.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/candidate.c b/usr.sbin/timed/timed/candidate.c
index 79f1f5a..7eae18e 100644
--- a/usr.sbin/timed/timed/candidate.c
+++ b/usr.sbin/timed/timed/candidate.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/cksum.c b/usr.sbin/timed/timed/cksum.c
index 50a7da2..243ea38 100644
--- a/usr.sbin/timed/timed/cksum.c
+++ b/usr.sbin/timed/timed/cksum.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/correct.c b/usr.sbin/timed/timed/correct.c
index d948dee..b3bf474 100644
--- a/usr.sbin/timed/timed/correct.c
+++ b/usr.sbin/timed/timed/correct.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/extern.h b/usr.sbin/timed/timed/extern.h
index 870ef9e..b17afe0 100644
--- a/usr.sbin/timed/timed/extern.h
+++ b/usr.sbin/timed/timed/extern.h
@@ -12,10 +12,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/globals.h b/usr.sbin/timed/timed/globals.h
index 206e7f5..c273241 100644
--- a/usr.sbin/timed/timed/globals.h
+++ b/usr.sbin/timed/timed/globals.h
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/master.c b/usr.sbin/timed/timed/master.c
index 0537016..a7d74ee 100644
--- a/usr.sbin/timed/timed/master.c
+++ b/usr.sbin/timed/timed/master.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/measure.c b/usr.sbin/timed/timed/measure.c
index 05fb119..7f14e79 100644
--- a/usr.sbin/timed/timed/measure.c
+++ b/usr.sbin/timed/timed/measure.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/networkdelta.c b/usr.sbin/timed/timed/networkdelta.c
index 5919d62..2bfe2f5 100644
--- a/usr.sbin/timed/timed/networkdelta.c
+++ b/usr.sbin/timed/timed/networkdelta.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/pathnames.h b/usr.sbin/timed/timed/pathnames.h
index e5fdcde..a2396e1 100644
--- a/usr.sbin/timed/timed/pathnames.h
+++ b/usr.sbin/timed/timed/pathnames.h
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/readmsg.c b/usr.sbin/timed/timed/readmsg.c
index 74a6f5f..0d0d317 100644
--- a/usr.sbin/timed/timed/readmsg.c
+++ b/usr.sbin/timed/timed/readmsg.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/slave.c b/usr.sbin/timed/timed/slave.c
index 74a1723..9076d17 100644
--- a/usr.sbin/timed/timed/slave.c
+++ b/usr.sbin/timed/timed/slave.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timed/timed.8 b/usr.sbin/timed/timed/timed.8
index d289e46..119bbc4 100644
--- a/usr.sbin/timed/timed/timed.8
+++ b/usr.sbin/timed/timed/timed.8
@@ -9,10 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/timed/timed/timed.c b/usr.sbin/timed/timed/timed.c
index 92a1733..149255a 100644
--- a/usr.sbin/timed/timed/timed.c
+++ b/usr.sbin/timed/timed/timed.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timedc/cmds.c b/usr.sbin/timed/timedc/cmds.c
index 5d30fe3..ab73341 100644
--- a/usr.sbin/timed/timedc/cmds.c
+++ b/usr.sbin/timed/timedc/cmds.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timedc/cmdtab.c b/usr.sbin/timed/timedc/cmdtab.c
index 8e4c3d5..62c01da 100644
--- a/usr.sbin/timed/timedc/cmdtab.c
+++ b/usr.sbin/timed/timedc/cmdtab.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timedc/extern.h b/usr.sbin/timed/timedc/extern.h
index e1dbfe5..bbbd83e 100644
--- a/usr.sbin/timed/timedc/extern.h
+++ b/usr.sbin/timed/timedc/extern.h
@@ -12,10 +12,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timedc/timedc.8 b/usr.sbin/timed/timedc/timedc.8
index 0f3fcea..3b0aea1 100644
--- a/usr.sbin/timed/timedc/timedc.8
+++ b/usr.sbin/timed/timedc/timedc.8
@@ -9,10 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
diff --git a/usr.sbin/timed/timedc/timedc.c b/usr.sbin/timed/timedc/timedc.c
index 0911946..115cc52 100644
--- a/usr.sbin/timed/timedc/timedc.c
+++ b/usr.sbin/timed/timedc/timedc.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/timed/timedc/timedc.h b/usr.sbin/timed/timedc/timedc.h
index f6ee8a6..bfeef28 100644
--- a/usr.sbin/timed/timedc/timedc.h
+++ b/usr.sbin/timed/timedc/timedc.h
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c
index 1a67173..a1fc8f6 100644
--- a/usr.sbin/traceroute6/traceroute6.c
+++ b/usr.sbin/traceroute6/traceroute6.c
@@ -44,10 +44,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
diff --git a/usr.sbin/tzsetup/Makefile b/usr.sbin/tzsetup/Makefile
index a9da310..4bf9dd7 100644
--- a/usr.sbin/tzsetup/Makefile
+++ b/usr.sbin/tzsetup/Makefile
@@ -3,11 +3,11 @@
PROG= tzsetup
MAN= tzsetup.8
-CFLAGS+= -I${.CURDIR}
+CFLAGS+= -I${.CURDIR}/../../gnu/lib/libodialog -I.
WARNS?= 3
-DPADD= ${LIBDIALOG} ${LIBNCURSES}
-LDADD= -ldialog -lncurses
+DPADD= ${LIBODIALOG} ${LIBNCURSES}
+LDADD= -lodialog -lncurses
.include <bsd.prog.mk>
diff --git a/usr.sbin/uathload/Makefile b/usr.sbin/uathload/Makefile
index 4f9b99d..d7b808c 100644
--- a/usr.sbin/uathload/Makefile
+++ b/usr.sbin/uathload/Makefile
@@ -7,6 +7,10 @@ SRCS= uathload.c ar5523.bin
CLEANFILES= ar5523.bin
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64"
+LDFLAGS+= -Wl,-z,noexecstack
+.endif
+
ar5523.bin: ${.CURDIR}/../../sys/contrib/dev/uath/ar5523.bin.uu
uudecode -p ${.CURDIR}/../../sys/contrib/dev/uath/ar5523.bin.uu > ${.TARGET}
diff --git a/usr.sbin/usbdump/usbdump.8 b/usr.sbin/usbdump/usbdump.8
index edd883a..f2b00e4 100644
--- a/usr.sbin/usbdump/usbdump.8
+++ b/usr.sbin/usbdump/usbdump.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 14, 2010
+.Dd December 4, 2010
.Dt usbdump 8
.Os
.Sh NAME
@@ -41,24 +41,29 @@
.Sh DESCRIPTION
The
.Nm
-utility provides a way to dump USB packets on each host controller.
+utility provides a way to dump USB packets on host controllers.
.Pp
-The following options are accepted.
+The following options are accepted:
.Bl -tag -width ".Fl f Ar file"
.It Fl i Ar ifname
-Listen on USB bus interface.
+Listen on USB bus interface
+.Ar ifname .
.It Fl r Ar file
-Read the raw packets from file.
+Read the raw packets from
+.Ar file .
.It Fl s Ar snaplen
-Snapshot bytes from each packet.
+Snapshot
+.Ar snaplen
+bytes from each packet.
.It Fl v
Enable debugging messages.
-When it defined multiple times the verbose level increases.
+When defined multiple times the verbosity level increases.
.It Fl w Ar file
-Write the raw packets to file.
+Write the raw packets to
+.Ar file .
.El
.Sh EXAMPLES
-Captures the USB raw packets alive on usbus2:
+Captures USB raw packets on usbus2:
.Pp
.Dl "usbdump -i usbus2 -s 256 -v"
.Pp
@@ -67,11 +72,61 @@ size limit:
.Pp
.Dl "usbdump -i usbus2 -s 0 -w /tmp/dump_pkts"
.Pp
-Read the USB raw packets from the file:
+Read the USB raw packets from previous file:
.Pp
.Dl "usbdump -r /tmp/dump_pkts -v"
+.Sh OUTPUT FORMAT
+The output format of
+.Nm
+is as follows:
+.Pp
+.Dl "<time> <bus>.<addr> <ep> <xfertype> <S/D> (<frames>/<length>) <...>"
+.Pp
+The meaning of the output format elements is as follows:
+.Bl -tag -width "<xfertype>"
+.It <time>
+A timestamp preceding all output lines.
+The timestamp has the format "hh:mm:ss.frac" and is as accurate as
+the kernel's clock.
+.It <bus>
+The USB host controller's bus unit number.
+.It <addr>
+The unique number of the USB device as allocated by the host controller driver.
+.It <ep>
+The USB endpoint address that indicates whether the address is
+.Dv OUT
+or
+.Dv IN .
+.It <xfertype>
+The USB transfer type.
+Can be
+.Dv CTRL ,
+.Dv ISOC ,
+.Dv BULK
+or
+.Dv INTR .
+.It <S/D>
+`S' indicates a USB submit.
+`D' indicates a USB transfer done.
+.It <frames>
+Numbers of frames in this packets.
+If this is a USB submit, its value is
+.Li xfer->nframes
+which means how many frames are acceptable or registered to transfer.
+If this is a USB done,
+.Li xfer->aframes
+is the actual number of frames.
+.It <length>
+Total packet size.
+If this is a USB submit, its value is
+.Li xfer->sumlen .
+If this is a USB done, its value is
+.Li xfer->actlen .
+.It <...>
+Optional field used for printing an error string if the packet is from USB done.
+.El
.Sh SEE ALSO
.Xr usbconfig 8
.Sh AUTHORS
.An Weongyo Jeong
-.Aq weongyo@FreeBSD.org .
+.Aq weongyo@FreeBSD.org
diff --git a/usr.sbin/usbdump/usbdump.c b/usr.sbin/usbdump/usbdump.c
index c6f9048..c142f59 100644
--- a/usr.sbin/usbdump/usbdump.c
+++ b/usr.sbin/usbdump/usbdump.c
@@ -72,7 +72,7 @@ struct usbcap_filehdr {
static int doexit = 0;
static int pkt_captured = 0;
static int verbose = 0;
-static const char *i_arg = "usbus0";;
+static const char *i_arg = "usbus0";
static const char *r_arg = NULL;
static const char *w_arg = NULL;
static const char *errstr_table[USB_ERR_MAX] = {
@@ -185,11 +185,10 @@ static void
hexdump(const char *region, size_t len)
{
const char *line;
- int x, c;
- char lbuf[80];
-#define EMIT(fmt, args...) do { \
- sprintf(lbuf, fmt , ## args); \
- printf("%s", lbuf); \
+ int x;
+ int c;
+#define EMIT(fmt, ...) do { \
+ printf(fmt,## __VA_ARGS__); \
} while (0)
for (line = region; line < (region + len); line += 16) {
diff --git a/usr.sbin/wpa/hostapd/driver_freebsd.c b/usr.sbin/wpa/hostapd/driver_freebsd.c
index 81af8c0..5fb6f85 100644
--- a/usr.sbin/wpa/hostapd/driver_freebsd.c
+++ b/usr.sbin/wpa/hostapd/driver_freebsd.c
@@ -14,6 +14,7 @@
*
* $FreeBSD$
*/
+
#include "includes.h"
#include <sys/ioctl.h>
@@ -21,238 +22,184 @@
#include "driver.h"
#include "eloop.h"
#include "common/ieee802_11_defs.h"
+#include "common/wpa_common.h"
#include <sys/socket.h>
#include <net/if.h>
+#include <net/route.h>
#include <netinet/in.h>
#include <net80211/ieee80211_ioctl.h>
-
-#undef RSN_VERSION
-#undef WPA_VERSION
-#undef WPA_OUI_TYPE
-#undef WME_OUI_TYPE
+#include <net80211/ieee80211_freebsd.h>
#include "l2_packet/l2_packet.h"
struct bsd_driver_data {
- struct hostapd_data *hapd; /* back pointer */
+ struct hostapd_data *hapd; /* back pointer */
- int ioctl_sock; /* open socket for 802.11 ioctls */
- int wext_sock;
+ int sock; /* open socket for 802.11 ioctls */
struct l2_packet_data *sock_xmit;/* raw packet xmit socket */
- int route; /* routing socket for events */
- char iface[IFNAMSIZ+1]; /* interface name */
- unsigned int ifindex; /* interface index */
- void *ctx;
- struct wpa_driver_capa capa; /* driver capability */
- int is_ap; /* Access point mode */
- int prev_roaming; /* roaming state to restore on deinit */
- int prev_privacy; /* privacy state to restore on deinit */
- int prev_wpa; /* wpa state to restore on deinit */
+ int route; /* routing socket for events */
+ char ifname[IFNAMSIZ+1]; /* interface name */
+ unsigned int ifindex; /* interface index */
+ void *ctx;
+ struct wpa_driver_capa capa; /* driver capability */
+ int is_ap; /* Access point mode */
+ int prev_roaming; /* roaming state to restore on deinit */
+ int prev_privacy; /* privacy state to restore on deinit */
+ int prev_wpa; /* wpa state to restore on deinit */
};
-static const struct wpa_driver_ops bsd_driver_ops;
-
-static int bsd_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
- int reason_code);
-
static int
-set80211var(struct bsd_driver_data *drv, int op, const void *arg, int arg_len)
+bsd_set80211(void *priv, int op, int val, const void *arg, int arg_len)
{
+ struct bsd_driver_data *drv = priv;
struct ieee80211req ireq;
- memset(&ireq, 0, sizeof(ireq));
- strncpy(ireq.i_name, drv->iface, IFNAMSIZ);
+ os_memset(&ireq, 0, sizeof(ireq));
+ os_strlcpy(ireq.i_name, drv->ifname, sizeof(ireq.i_name));
ireq.i_type = op;
- ireq.i_len = arg_len;
+ ireq.i_val = val;
ireq.i_data = (void *) arg;
+ ireq.i_len = arg_len;
- if (ioctl(drv->ioctl_sock, SIOCS80211, &ireq) < 0) {
- perror("ioctl[SIOCS80211]");
+ if (ioctl(drv->sock, SIOCS80211, &ireq) < 0) {
+ wpa_printf(MSG_ERROR, "ioctl[SIOCS80211, op=%u, val=%u, "
+ "arg_len=%u]: %s", op, val, arg_len,
+ strerror(errno));
return -1;
}
return 0;
}
static int
-get80211var(struct bsd_driver_data *drv, int op, void *arg, int arg_len)
+bsd_get80211(void *priv, struct ieee80211req *ireq, int op, void *arg,
+ int arg_len)
{
- struct ieee80211req ireq;
+ struct bsd_driver_data *drv = priv;
- memset(&ireq, 0, sizeof(ireq));
- strncpy(ireq.i_name, drv->iface, IFNAMSIZ);
- ireq.i_type = op;
- ireq.i_len = arg_len;
- ireq.i_data = arg;
+ os_memset(ireq, 0, sizeof(*ireq));
+ os_strlcpy(ireq->i_name, drv->ifname, sizeof(ireq->i_name));
+ ireq->i_type = op;
+ ireq->i_len = arg_len;
+ ireq->i_data = arg;
- if (ioctl(drv->ioctl_sock, SIOCG80211, &ireq) < 0) {
- perror("ioctl[SIOCG80211]");
+ if (ioctl(drv->sock, SIOCG80211, ireq) < 0) {
+ wpa_printf(MSG_ERROR, "ioctl[SIOCS80211, op=%u, "
+ "arg_len=%u]: %s", op, arg_len, strerror(errno));
return -1;
}
- return ireq.i_len;
+ return 0;
}
static int
-set80211param(struct bsd_driver_data *drv, int op, int arg)
+get80211var(struct bsd_driver_data *drv, int op, void *arg, int arg_len)
{
struct ieee80211req ireq;
- memset(&ireq, 0, sizeof(ireq));
- strncpy(ireq.i_name, drv->iface, IFNAMSIZ);
- ireq.i_type = op;
- ireq.i_val = arg;
-
- if (ioctl(drv->ioctl_sock, SIOCS80211, &ireq) < 0) {
- perror("ioctl[SIOCS80211]");
+ if (bsd_get80211(drv, &ireq, op, arg, arg_len) < 0)
return -1;
- }
- return 0;
-}
-
-static const char *
-ether_sprintf(const u8 *addr)
-{
- static char buf[sizeof(MACSTR)];
-
- if (addr != NULL)
- snprintf(buf, sizeof(buf), MACSTR, MAC2STR(addr));
- else
- snprintf(buf, sizeof(buf), MACSTR, 0,0,0,0,0,0);
- return buf;
+ return ireq.i_len;
}
static int
-bsd_set_iface_flags(void *priv, int flags)
+set80211var(struct bsd_driver_data *drv, int op, const void *arg, int arg_len)
{
- struct bsd_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
- struct ifreq ifr;
-
- wpa_printf(MSG_DEBUG, "%s: flags=0x%x\n", __func__, flags);
-
- if (drv->ioctl_sock < 0)
- return -1;
-
- memset(&ifr, 0, sizeof(ifr));
- snprintf(ifr.ifr_name, IFNAMSIZ, "%s", drv->iface);
-
- if (ioctl(drv->ioctl_sock, SIOCGIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCGIFFLAGS]");
- return -1;
- }
-
- if (flags < 0) {
- flags = -flags;
- if ((ifr.ifr_flags & flags) == 0)
- return 0;
- ifr.ifr_flags &= ~flags;
- } else {
- if ((ifr.ifr_flags & flags) == flags)
- return 0;
- ifr.ifr_flags |= flags;
- }
-
- if (ioctl(drv->ioctl_sock, SIOCSIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCSIFFLAGS]");
- return -1;
- }
- return 0;
+ return bsd_set80211(drv, op, 0, arg, arg_len);
}
static int
-bsd_commit(void *priv)
+set80211param(struct bsd_driver_data *drv, int op, int arg)
{
- return bsd_set_iface_flags(priv, IFF_UP);
+ return bsd_set80211(drv, op, arg, NULL, 0);
}
static int
-bsd_set_ieee8021x(void *priv, struct wpa_bss_params *params)
+bsd_get_ssid(void *priv, u8 *ssid, int len)
{
- wpa_printf(MSG_DEBUG, "%s: enabled=%d\n", __func__, params->enabled);
+ struct bsd_driver_data *drv = priv;
- if (!params->enabled) {
- /* XXX restore state */
- return set80211param(priv, IEEE80211_IOC_AUTHMODE,
- IEEE80211_AUTH_AUTO);
- }
- if (!params->wpa && !params->ieee802_1x) {
- wpa_printf(MSG_ERROR, "%s: No 802.1X or WPA enabled",
- __func__);
- return -1;
- }
- if (params->wpa && set80211param(priv,IEEE80211_IOC_WPA, params->wpa)) {
- wpa_printf(MSG_ERROR, "%s: Failed to configure WPA state",
- __func__);
- return -1;
- }
- if (set80211param(priv, IEEE80211_IOC_AUTHMODE,
- (params->wpa ? IEEE80211_AUTH_WPA : IEEE80211_AUTH_8021X))) {
- wpa_printf(MSG_ERROR, "%s: Failed to enable WPA/802.1X",
- __func__);
- return -1;
- }
- return 0;
+ return get80211var(drv, IEEE80211_IOC_SSID, ssid, IEEE80211_NWID_LEN);
}
static int
-bsd_set_privacy(void *priv, int enabled)
+bsd_set_ssid(void *priv, const u8 *ssid, int ssid_len)
{
- wpa_printf(MSG_DEBUG, "%s: enabled=%d\n", __func__, enabled);
+ struct bsd_driver_data *drv = priv;
- return set80211param(priv, IEEE80211_IOC_PRIVACY, enabled);
+ return set80211var(drv, IEEE80211_IOC_SSID, ssid, ssid_len);
}
static int
-bsd_set_sta_authorized(void *priv, const u8 *addr, int authorized)
+bsd_del_key(void *priv, const u8 *addr, int key_idx)
{
- struct bsd_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
- struct ieee80211req_mlme mlme;
+ struct ieee80211req_del_key wk;
- wpa_printf(MSG_DEBUG, "%s: addr=%s authorized=%d\n",
- __func__, ether_sprintf(addr), authorized);
+ os_memset(&wk, 0, sizeof(wk));
+ if (addr == NULL) {
+ wpa_printf(MSG_DEBUG, "%s: key_idx=%d", __func__, key_idx);
+ wk.idk_keyix = key_idx;
+ } else {
+ wpa_printf(MSG_DEBUG, "%s: addr=" MACSTR, __func__,
+ MAC2STR(addr));
+ os_memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
+ wk.idk_keyix = (u_int8_t) IEEE80211_KEYIX_NONE; /* XXX */
+ }
- if (authorized)
- mlme.im_op = IEEE80211_MLME_AUTHORIZE;
- else
- mlme.im_op = IEEE80211_MLME_UNAUTHORIZE;
- mlme.im_reason = 0;
- memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
- return set80211var(priv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme));
+ return set80211var(priv, IEEE80211_IOC_DELKEY, &wk, sizeof(wk));
}
static int
-bsd_sta_set_flags(void *priv, const u8 *addr, int total_flags,
- int flags_or, int flags_and)
+bsd_send_mlme_param(void *priv, const u8 op, const u16 reason, const u8 *addr)
{
- /* For now, only support setting Authorized flag */
- if (flags_or & WPA_STA_AUTHORIZED)
- return bsd_set_sta_authorized(priv, addr, 1);
- if (!(flags_and & WPA_STA_AUTHORIZED))
- return bsd_set_sta_authorized(priv, addr, 0);
- return 0;
+ struct ieee80211req_mlme mlme;
+
+ os_memset(&mlme, 0, sizeof(mlme));
+ mlme.im_op = op;
+ mlme.im_reason = reason;
+ os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
+ return set80211var(priv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme));
}
static int
-bsd_del_key(void *priv, const unsigned char *addr, int key_idx)
+bsd_ctrl_iface(void *priv, int enable)
{
struct bsd_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
- struct ieee80211req_del_key wk;
+ struct ifreq ifr;
- wpa_printf(MSG_DEBUG, "%s: addr=%s key_idx=%d\n",
- __func__, ether_sprintf(addr), key_idx);
+ if (drv->sock < 0)
+ return -1;
- memset(&wk, 0, sizeof(wk));
- if (addr != NULL) {
- memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN);
- wk.idk_keyix = (u_int8_t) IEEE80211_KEYIX_NONE; /* XXX */
+ os_memset(&ifr, 0, sizeof(ifr));
+ os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
+
+ if (ioctl(drv->sock, SIOCGIFFLAGS, &ifr) < 0) {
+ perror("ioctl[SIOCGIFFLAGS]");
+ return -1;
+ }
+
+ if (enable) {
+ if ((ifr.ifr_flags & IFF_UP) == IFF_UP)
+ return 0;
+ ifr.ifr_flags |= IFF_UP;
} else {
- wk.idk_keyix = key_idx;
+ if ((ifr.ifr_flags & IFF_UP) == 0)
+ return 0;
+ ifr.ifr_flags &= ~IFF_UP;
}
- return set80211var(priv, IEEE80211_IOC_DELKEY, &wk, sizeof(wk));
+ if (ioctl(drv->sock, SIOCSIFFLAGS, &ifr) < 0) {
+ perror("ioctl[SIOCSIFFLAGS]");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+bsd_commit(void *priv)
+{
+ return bsd_ctrl_iface(priv, 1);
}
static int
@@ -263,8 +210,8 @@ bsd_set_key(const char *ifname, void *priv, enum wpa_alg alg,
struct ieee80211req_key wk;
wpa_printf(MSG_DEBUG, "%s: alg=%d addr=%p key_idx=%d set_tx=%d "
- "seq_len=%zu key_len=%zu", __func__, alg, addr, key_idx,
- set_tx, seq_len, key_len);
+ "seq_len=%zu key_len=%zu", __func__, alg, addr, key_idx,
+ set_tx, seq_len, key_len);
if (alg == WPA_ALG_NONE) {
return bsd_del_key(priv, addr, key_idx);
@@ -318,17 +265,153 @@ bsd_set_key(const char *ifname, void *priv, enum wpa_alg alg,
return set80211var(priv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk));
}
+static int
+bsd_configure_wpa(void *priv, struct wpa_bss_params *params)
+{
+ wpa_printf(MSG_DEBUG, "%s: enable WPA= 0x%x", __func__, params->wpa);
+ if (set80211param(priv, IEEE80211_IOC_WPA, params->wpa)) {
+ printf("Unable to set WPA to %u\n", params->wpa);
+ return -1;
+ }
+ return 0;
+}
+
+static int
+bsd_set_ieee8021x(void *priv, struct wpa_bss_params *params)
+{
+ wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, params->enabled);
+
+ if (!params->enabled) {
+ /* XXX restore state */
+ return set80211param(priv, IEEE80211_IOC_AUTHMODE,
+ IEEE80211_AUTH_AUTO);
+ }
+ if (!params->wpa && !params->ieee802_1x) {
+ wpa_printf(MSG_ERROR, "%s: No 802.1X or WPA enabled",
+ __func__);
+ return -1;
+ }
+ if (params->wpa && bsd_configure_wpa(priv, params) != 0) {
+ wpa_printf(MSG_ERROR, "%s: Failed to configure WPA state",
+ __func__);
+ return -1;
+ }
+ if (set80211param(priv, IEEE80211_IOC_AUTHMODE,
+ (params->wpa ? IEEE80211_AUTH_WPA : IEEE80211_AUTH_8021X))) {
+ wpa_printf(MSG_ERROR, "%s: Failed to enable WPA/802.1X",
+ __func__);
+ return -1;
+ }
+ return 0;
+}
+
+static int
+bsd_set_sta_authorized(void *priv, const u8 *addr,
+ int total_flags, int flags_or, int flags_and)
+{
+ int authorized = -1;
+
+ /* For now, only support setting Authorized flag */
+ if (flags_or & WPA_STA_AUTHORIZED)
+ authorized = 1;
+ if (!(flags_and & WPA_STA_AUTHORIZED))
+ authorized = 0;
+
+ if (authorized < 0)
+ return 0;
+
+ return bsd_send_mlme_param(priv, authorized ?
+ IEEE80211_MLME_AUTHORIZE :
+ IEEE80211_MLME_UNAUTHORIZE, 0, addr);
+}
+
+static void
+bsd_new_sta(void *priv, void *ctx, u8 addr[IEEE80211_ADDR_LEN])
+{
+ struct ieee80211req_wpaie ie;
+ int ielen = 0;
+ u8 *iebuf = NULL;
+
+ /*
+ * Fetch and validate any negotiated WPA/RSN parameters.
+ */
+ memset(&ie, 0, sizeof(ie));
+ memcpy(ie.wpa_macaddr, addr, IEEE80211_ADDR_LEN);
+ if (get80211var(priv, IEEE80211_IOC_WPAIE, &ie, sizeof(ie)) < 0) {
+ printf("Failed to get WPA/RSN information element.\n");
+ goto no_ie;
+ }
+ iebuf = ie.wpa_ie;
+ ielen = ie.wpa_ie[1];
+ if (ielen == 0)
+ iebuf = NULL;
+ else
+ ielen += 2;
+
+no_ie:
+ drv_event_assoc(ctx, addr, iebuf, ielen);
+}
+
+static int
+bsd_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
+ int encrypt, const u8 *own_addr)
+{
+ struct bsd_driver_data *drv = priv;
+
+ wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", data, data_len);
+
+ return l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, data,
+ data_len);
+}
+
+static int
+bsd_set_opt_ie(void *priv, const u8 *ie, size_t ie_len)
+{
+ wpa_printf(MSG_DEBUG, "%s: set WPA+RSN ie (len %lu)", __func__,
+ (unsigned long)ie_len);
+ return bsd_set80211(priv, IEEE80211_IOC_APPIE, IEEE80211_APPIE_WPA,
+ ie, ie_len);
+}
+
+/*
+ * Avoid conflicts with hostapd definitions by undefining couple of defines
+ * from net80211 header files.
+ */
+#undef RSN_VERSION
+#undef WPA_VERSION
+#undef WPA_OUI_TYPE
+
+static int bsd_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
+ int reason_code);
+
+static const char *
+ether_sprintf(const u8 *addr)
+{
+ static char buf[sizeof(MACSTR)];
+
+ if (addr != NULL)
+ snprintf(buf, sizeof(buf), MACSTR, MAC2STR(addr));
+ else
+ snprintf(buf, sizeof(buf), MACSTR, 0,0,0,0,0,0);
+ return buf;
+}
+
+static int
+bsd_set_privacy(void *priv, int enabled)
+{
+ wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
+
+ return set80211param(priv, IEEE80211_IOC_PRIVACY, enabled);
+}
static int
bsd_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
u8 *seq)
{
- struct bsd_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
struct ieee80211req_key wk;
- wpa_printf(MSG_DEBUG, "%s: addr=%s idx=%d\n",
- __func__, ether_sprintf(addr), idx);
+ wpa_printf(MSG_DEBUG, "%s: addr=%s idx=%d",
+ __func__, ether_sprintf(addr), idx);
memset(&wk, 0, sizeof(wk));
if (addr == NULL)
@@ -337,15 +420,28 @@ bsd_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
wk.ik_keyix = idx;
- if (get80211var(drv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk)) < 0) {
+ if (get80211var(priv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk)) < 0) {
printf("Failed to get encryption.\n");
return -1;
- } else {
- /* NB: upper layer expects tsc in network order */
- wk.ik_keytsc = htole64(wk.ik_keytsc);
- memcpy(seq, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
- return 0;
}
+
+#ifdef WORDS_BIGENDIAN
+ {
+ /*
+ * wk.ik_keytsc is in host byte order (big endian), need to
+ * swap it to match with the byte order used in WPA.
+ */
+ int i;
+ u8 tmp[WPA_KEY_RSC_LEN];
+ memcpy(tmp, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
+ for (i = 0; i < WPA_KEY_RSC_LEN; i++) {
+ seq[i] = tmp[WPA_KEY_RSC_LEN - i - 1];
+ }
+ }
+#else /* WORDS_BIGENDIAN */
+ memcpy(seq, &wk.ik_keytsc, sizeof(wk.ik_keytsc));
+#endif /* WORDS_BIGENDIAN */
+ return 0;
}
@@ -363,11 +459,11 @@ static int
bsd_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data,
const u8 *addr)
{
- struct bsd_driver_data *drv = priv;
struct ieee80211req_sta_stats stats;
memcpy(stats.is_u.macaddr, addr, IEEE80211_ADDR_LEN);
- if (get80211var(drv, IEEE80211_IOC_STA_STATS, &stats, sizeof(stats)) > 0) {
+ if (get80211var(priv, IEEE80211_IOC_STA_STATS, &stats, sizeof(stats))
+ > 0) {
/* XXX? do packets counts include non-data frames? */
data->rx_packets = stats.is_stats.ns_rx_data;
data->rx_bytes = stats.is_stats.ns_rx_bytes;
@@ -380,108 +476,36 @@ bsd_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data,
static int
bsd_sta_clear_stats(void *priv, const u8 *addr)
{
- struct bsd_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
struct ieee80211req_sta_stats stats;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s\n", __func__, ether_sprintf(addr));
+
+ wpa_printf(MSG_DEBUG, "%s: addr=%s", __func__, ether_sprintf(addr));
/* zero station statistics */
memset(&stats, 0, sizeof(stats));
memcpy(stats.is_u.macaddr, addr, IEEE80211_ADDR_LEN);
- return set80211var(drv, IEEE80211_IOC_STA_STATS, &stats, sizeof(stats));
-}
-
-static int
-bsd_set_opt_ie(void *priv, const u8 *ie, size_t ie_len)
-{
- struct bsd_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
- struct ieee80211req ireq;
-
- memset(&ireq, 0, sizeof(ireq));
- strncpy(ireq.i_name, drv->iface, IFNAMSIZ);
- ireq.i_type = IEEE80211_IOC_APPIE;
- ireq.i_val = IEEE80211_APPIE_WPA;
- ireq.i_data = (void *) ie;
- ireq.i_len = ie_len;
-
- wpa_printf(MSG_DEBUG, "%s: set WPA+RSN ie (len %d)\n",
- __func__, ie_len);
- if (ioctl(drv->ioctl_sock, SIOCS80211, &ireq) < 0) {
- printf("Unable to set WPA+RSN ie\n");
- return -1;
- }
- return 0;
+ return set80211var(priv, IEEE80211_IOC_STA_STATS, &stats,
+ sizeof(stats));
}
static int
bsd_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, int reason_code)
{
- struct bsd_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
- struct ieee80211req_mlme mlme;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%d\n",
- __func__, ether_sprintf(addr), reason_code);
-
- mlme.im_op = IEEE80211_MLME_DEAUTH;
- mlme.im_reason = reason_code;
- memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
- return set80211var(priv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme));
+ return bsd_send_mlme_param(priv, IEEE80211_MLME_DEAUTH, reason_code,
+ addr);
}
static int
-bsd_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr, int reason_code)
-{
- struct bsd_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
- struct ieee80211req_mlme mlme;
-
- wpa_printf(MSG_DEBUG, "%s: addr=%s reason_code=%d\n",
- __func__, ether_sprintf(addr), reason_code);
-
- mlme.im_reason = reason_code;
- memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
- return set80211var(priv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme));
-}
-
-static void
-bsd_new_sta(void *priv, void *ctx, u8 addr[IEEE80211_ADDR_LEN])
+bsd_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
+ int reason_code)
{
- struct ieee80211req_wpaie ie;
- int ielen = 0;
- u8 *iebuf = NULL;
-
- /*
- * Fetch and validate any negotiated WPA/RSN parameters.
- */
- memset(&ie, 0, sizeof(ie));
- memcpy(ie.wpa_macaddr, addr, IEEE80211_ADDR_LEN);
- if (get80211var(priv, IEEE80211_IOC_WPAIE, &ie, sizeof(ie)) < 0) {
- printf("Failed to get WPA/RSN information element.\n");
- goto no_ie;
- }
- iebuf = ie.wpa_ie;
- ielen = ie.wpa_ie[1];
- if (ielen == 0)
- iebuf = NULL;
- else
- ielen += 2;
-
-no_ie:
- drv_event_assoc(ctx, addr, iebuf, ielen);
-
+ return bsd_send_mlme_param(priv, IEEE80211_MLME_DISASSOC, reason_code,
+ addr);
}
-#include <net/route.h>
-#include <net80211/ieee80211_freebsd.h>
-
static void
bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
{
struct bsd_driver_data *drv = ctx;
- struct hostapd_data *hapd = drv->hapd;
char buf[2048];
struct if_announcemsghdr *ifan;
struct rt_msghdr *rtm;
@@ -553,12 +577,12 @@ bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
auth = (struct ieee80211_auth_event *) &ifan[1];
wpa_printf(MSG_DEBUG, "802.11 AUTH, STA = " MACSTR,
MAC2STR(auth->iev_addr));
- n = hostapd_allowed_address(hapd, auth->iev_addr,
+ n = hostapd_allowed_address(drv->hapd, auth->iev_addr,
NULL, 0, NULL, NULL, NULL);
switch (n) {
case HOSTAPD_ACL_ACCEPT:
case HOSTAPD_ACL_REJECT:
- hostapd_set_radius_acl_auth(hapd,
+ hostapd_set_radius_acl_auth(drv->hapd,
auth->iev_addr, n, 0);
wpa_printf(MSG_DEBUG,
"802.11 AUTH, STA = " MACSTR " hostapd says: %s",
@@ -579,49 +603,6 @@ bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
}
}
-static int
-bsd_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
- int encrypt, const u8 *own_addr)
-
-{
- struct bsd_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
- unsigned char buf[3000];
- unsigned char *bp = buf;
- struct l2_ethhdr *eth;
- size_t len;
- int status;
-
- /*
- * Prepend the Etherent header. If the caller left us
- * space at the front we could just insert it but since
- * we don't know we copy to a local buffer. Given the frequency
- * and size of frames this probably doesn't matter.
- */
- len = data_len + sizeof(struct l2_ethhdr);
- if (len > sizeof(buf)) {
- bp = malloc(len);
- if (bp == NULL) {
- printf("EAPOL frame discarded, cannot malloc temp "
- "buffer of size %u!\n", len);
- return -1;
- }
- }
- eth = (struct l2_ethhdr *) bp;
- memcpy(eth->h_dest, addr, ETH_ALEN);
- memcpy(eth->h_source, own_addr, ETH_ALEN);
- eth->h_proto = htons(ETH_P_EAPOL);
- memcpy(eth+1, data, data_len);
-
- wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", bp, len);
-
- status = l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, bp, len);
-
- if (bp != buf)
- free(bp);
- return status;
-}
-
static void
handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
{
@@ -630,35 +611,10 @@ handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
}
static int
-bsd_get_ssid(void *priv, u8 *buf, int len)
-{
- struct bsd_driver_data *drv = priv;
-
- int ssid_len = get80211var(priv, IEEE80211_IOC_SSID, buf, len);
-
- wpa_printf(MSG_DEBUG, "%s: ssid=\"%.*s\"\n", __func__, ssid_len, buf);
-
- return ssid_len;
-}
-
-static int
-bsd_set_ssid(void *priv, const u8 *buf, int len)
-{
- struct bsd_driver_data *drv = priv;
- struct hostapd_data *hapd = drv->hapd;
-
- wpa_printf(MSG_DEBUG, "%s: ssid=\"%.*s\"\n", __func__, len, buf);
-
- return set80211var(priv, IEEE80211_IOC_SSID, buf, len);
-}
-
-static int
bsd_set_countermeasures(void *priv, int enabled)
{
- struct bsd_driver_data *drv = priv;
-
wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled);
- return set80211param(drv, IEEE80211_IOC_COUNTERMEASURES, enabled);
+ return set80211param(priv, IEEE80211_IOC_COUNTERMEASURES, enabled);
}
#ifdef CONFIG_DRIVER_RADIUS_ACL_NOT_YET
@@ -734,12 +690,12 @@ bsd_init(struct hostapd_data *hapd, struct wpa_init_params *params)
}
drv->hapd = hapd;
- drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
- if (drv->ioctl_sock < 0) {
+ drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
+ if (drv->sock < 0) {
perror("socket[PF_INET,SOCK_DGRAM]");
goto bad;
}
- memcpy(drv->iface, params->ifname, sizeof(drv->iface));
+ os_strlcpy(drv->ifname, params->ifname, sizeof(drv->ifname));
/*
* NB: We require the interface name be mappable to an index.
* This implies we do not support having wpa_supplicant
@@ -747,21 +703,22 @@ bsd_init(struct hostapd_data *hapd, struct wpa_init_params *params)
* doesn't belong here; it's really the job of devd.
* XXXSCW: devd is FreeBSD-specific.
*/
- drv->ifindex = if_nametoindex(drv->iface);
+ drv->ifindex = if_nametoindex(drv->ifname);
if (drv->ifindex == 0) {
- printf("%s: interface %s does not exist", __func__, drv->iface);
+ printf("%s: interface %s does not exist", __func__,
+ drv->ifname);
goto bad;
}
- drv->sock_xmit = l2_packet_init(drv->iface, NULL, ETH_P_EAPOL,
- handle_read, drv, 1);
+ drv->sock_xmit = l2_packet_init(drv->ifname, NULL, ETH_P_EAPOL,
+ handle_read, drv, 0);
if (drv->sock_xmit == NULL)
goto bad;
if (l2_packet_get_own_addr(drv->sock_xmit, params->own_addr))
goto bad;
/* mark down during setup */
- if (bsd_set_iface_flags(drv, -IFF_UP) < 0)
+ if (bsd_ctrl_iface(drv, 0) < 0)
goto bad;
drv->route = socket(PF_ROUTE, SOCK_RAW, 0);
@@ -774,13 +731,13 @@ bsd_init(struct hostapd_data *hapd, struct wpa_init_params *params)
return drv;
bad:
- if (drv != NULL) {
- if (drv->sock_xmit != NULL)
- l2_packet_deinit(drv->sock_xmit);
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
- free(drv);
- }
+ if (drv == NULL)
+ return NULL;
+ if (drv->sock_xmit != NULL)
+ l2_packet_deinit(drv->sock_xmit);
+ if (drv->sock >= 0)
+ close(drv->sock);
+ os_free(drv);
return NULL;
}
@@ -794,33 +751,34 @@ bsd_deinit(void *priv)
eloop_unregister_read_sock(drv->route);
close(drv->route);
}
- (void) bsd_set_iface_flags(drv, -IFF_UP);
- if (drv->ioctl_sock >= 0)
- close(drv->ioctl_sock);
+ bsd_ctrl_iface(drv, 0);
+ if (drv->sock >= 0)
+ close(drv->sock);
if (drv->sock_xmit != NULL)
l2_packet_deinit(drv->sock_xmit);
- free(drv);
+ os_free(drv);
}
const struct wpa_driver_ops wpa_driver_bsd_ops = {
.name = "bsd",
+ .desc = "BSD 802.11 support",
.hapd_init = bsd_init,
.hapd_deinit = bsd_deinit,
- .set_ieee8021x = bsd_set_ieee8021x,
.set_privacy = bsd_set_privacy,
- .set_key = bsd_set_key,
.get_seqnum = bsd_get_seqnum,
.flush = bsd_flush,
- .set_generic_elem = bsd_set_opt_ie,
- .sta_set_flags = bsd_sta_set_flags,
.read_sta_data = bsd_read_sta_driver_data,
- .hapd_send_eapol = bsd_send_eapol,
+ .sta_clear_stats = bsd_sta_clear_stats,
.sta_disassoc = bsd_sta_disassoc,
.sta_deauth = bsd_sta_deauth,
+ .set_key = bsd_set_key,
+ .set_ieee8021x = bsd_set_ieee8021x,
.hapd_set_ssid = bsd_set_ssid,
.hapd_get_ssid = bsd_get_ssid,
+ .hapd_send_eapol = bsd_send_eapol,
+ .sta_set_flags = bsd_set_sta_authorized,
+ .set_generic_elem = bsd_set_opt_ie,
.set_countermeasures = bsd_set_countermeasures,
- .sta_clear_stats = bsd_sta_clear_stats,
.commit = bsd_commit,
#ifdef CONFIG_DRIVER_RADIUS_ACL_NOT_YET
.set_radius_acl_auth = bsd_set_radius_acl_auth,
OpenPOWER on IntegriCloud