summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/Makefile27
-rw-r--r--sbin/atm/atmconfig/Makefile6
-rw-r--r--sbin/atm/atmconfig/atmconfig.84
-rw-r--r--sbin/badsect/Makefile3
-rw-r--r--sbin/bsdlabel/Makefile3
-rw-r--r--sbin/bsdlabel/bsdlabel.82
-rw-r--r--sbin/camcontrol/Makefile3
-rw-r--r--sbin/camcontrol/camcontrol.8101
-rw-r--r--sbin/camcontrol/camcontrol.c692
-rw-r--r--sbin/casperd/Makefile3
-rw-r--r--sbin/casperd/casperd.c2
-rw-r--r--sbin/casperd/zygote.c4
-rw-r--r--sbin/ccdconfig/Makefile3
-rw-r--r--sbin/ddb/Makefile3
-rw-r--r--sbin/devd/Makefile3
-rw-r--r--sbin/devd/Makefile.depend1
-rw-r--r--sbin/devd/devd.conf.551
-rw-r--r--sbin/dhclient/Makefile3
-rw-r--r--sbin/dhclient/dhclient.conf.52
-rw-r--r--sbin/dhclient/dhclient.leases.52
-rw-r--r--sbin/dmesg/Makefile3
-rw-r--r--sbin/dmesg/dmesg.c11
-rw-r--r--sbin/dumpfs/Makefile3
-rw-r--r--sbin/fdisk/Makefile3
-rw-r--r--sbin/fdisk_pc98/Makefile3
-rw-r--r--sbin/ffsinfo/Makefile3
-rw-r--r--sbin/ffsinfo/ffsinfo.c46
-rw-r--r--sbin/fsck/fsck.c54
-rw-r--r--sbin/fsck_ffs/Makefile3
-rw-r--r--sbin/fsck_ffs/dir.c1
-rw-r--r--sbin/fsck_ffs/setup.c91
-rw-r--r--sbin/fsdb/Makefile3
-rw-r--r--sbin/fsirand/fsirand.c11
-rw-r--r--sbin/gbde/Makefile3
-rw-r--r--sbin/geom/Makefile3
-rw-r--r--sbin/geom/class/eli/Makefile3
-rw-r--r--sbin/geom/class/journal/Makefile3
-rw-r--r--sbin/geom/class/label/glabel.84
-rw-r--r--sbin/geom/class/mirror/Makefile3
-rw-r--r--sbin/geom/class/mountver/geom_mountver.c4
-rw-r--r--sbin/geom/class/mountver/gmountver.815
-rw-r--r--sbin/geom/class/part/Makefile3
-rw-r--r--sbin/geom/class/part/geom_part.c15
-rw-r--r--sbin/geom/class/part/gpart.812
-rw-r--r--sbin/geom/class/raid/Makefile3
-rw-r--r--sbin/geom/class/raid3/Makefile3
-rw-r--r--sbin/geom/core/Makefile3
-rw-r--r--sbin/ggate/ggatec/Makefile3
-rw-r--r--sbin/ggate/ggatec/ggatec.831
-rw-r--r--sbin/ggate/ggated/Makefile3
-rw-r--r--sbin/ggate/ggatel/Makefile3
-rw-r--r--sbin/ggate/ggatel/ggatel.826
-rw-r--r--sbin/growfs/Makefile11
-rw-r--r--sbin/growfs/growfs.814
-rw-r--r--sbin/growfs/growfs.c4
-rw-r--r--sbin/gvinum/Makefile3
-rw-r--r--sbin/gvinum/Makefile.depend2
-rw-r--r--sbin/hastctl/Makefile6
-rw-r--r--sbin/hastctl/Makefile.depend1
-rw-r--r--sbin/hastd/Makefile6
-rw-r--r--sbin/hastd/Makefile.depend1
-rw-r--r--sbin/hastd/hast.conf.510
-rw-r--r--sbin/ifconfig/Makefile13
-rw-r--r--sbin/ifconfig/af_inet.c5
-rw-r--r--sbin/ifconfig/af_inet6.c49
-rw-r--r--sbin/ifconfig/af_nd6.c4
-rw-r--r--sbin/ifconfig/carp.c1
-rw-r--r--sbin/ifconfig/ifconfig.853
-rw-r--r--sbin/ifconfig/ifconfig.c188
-rw-r--r--sbin/ifconfig/iffib.c36
-rw-r--r--sbin/ifconfig/ifgif.c4
-rw-r--r--sbin/ifconfig/ifgroup.c5
-rw-r--r--sbin/ifconfig/ifmedia.c32
-rw-r--r--sbin/ifconfig/ifvlan.c1
-rw-r--r--sbin/ifconfig/ifvxlan.c55
-rw-r--r--sbin/ifconfig/sfp.c189
-rw-r--r--sbin/ifconfig/tests/Makefile13
-rw-r--r--sbin/init/Makefile3
-rw-r--r--sbin/ipf/Makefile.inc4
-rw-r--r--sbin/ipf/ipf/Makefile3
-rw-r--r--sbin/ipf/ipf/Makefile.depend1
-rw-r--r--sbin/ipf/ipfstat/Makefile3
-rw-r--r--sbin/ipf/ipfstat/Makefile.depend1
-rw-r--r--sbin/ipf/ipftest/Makefile.depend1
-rw-r--r--sbin/ipf/ipmon/Makefile.depend1
-rw-r--r--sbin/ipf/ipnat/Makefile.depend1
-rw-r--r--sbin/ipf/ippool/Makefile.depend1
-rw-r--r--sbin/ipf/ipsend/Makefile3
-rw-r--r--sbin/ipfw/Makefile3
-rw-r--r--sbin/ipfw/ipfw.815
-rw-r--r--sbin/ipfw/ipfw2.c144
-rw-r--r--sbin/ipfw/ipfw2.h2
-rw-r--r--sbin/ipfw/nat.c11
-rw-r--r--sbin/ipfw/tables.c203
-rw-r--r--sbin/iscontrol/Makefile5
-rw-r--r--sbin/iscontrol/iscontrol.86
-rw-r--r--sbin/iscontrol/iscsi.conf.5188
-rw-r--r--sbin/md5/Makefile6
-rw-r--r--sbin/md5/md5.c34
-rw-r--r--sbin/mdconfig/Makefile3
-rw-r--r--sbin/mdconfig/tests/Makefile9
-rw-r--r--sbin/mdconfig/tests/legacy_test.sh47
-rw-r--r--sbin/mdconfig/tests/mdconfig.test231
-rwxr-xr-xsbin/mdconfig/tests/mdconfig_test.sh281
-rw-r--r--sbin/mdconfig/tests/run.pl329
-rw-r--r--sbin/mount/Makefile3
-rw-r--r--sbin/mount/mount.87
-rw-r--r--sbin/mount/mount.c2
-rw-r--r--sbin/mount_cd9660/Makefile3
-rw-r--r--sbin/mount_fusefs/mount_fusefs.84
-rw-r--r--sbin/mount_fusefs/mount_fusefs.c7
-rw-r--r--sbin/mount_msdosfs/Makefile3
-rw-r--r--sbin/mount_nfs/Makefile3
-rw-r--r--sbin/mount_nfs/mount_nfs.88
-rw-r--r--sbin/mount_udf/Makefile3
-rw-r--r--sbin/nandfs/Makefile3
-rw-r--r--sbin/natd/Makefile3
-rw-r--r--sbin/newfs/Makefile3
-rw-r--r--sbin/newfs/newfs.84
-rw-r--r--sbin/newfs/newfs.c30
-rw-r--r--sbin/newfs_msdos/newfs_msdos.84
-rw-r--r--sbin/newfs_msdos/newfs_msdos.c38
-rw-r--r--sbin/newfs_nandfs/Makefile3
-rw-r--r--sbin/pfctl/Makefile3
-rw-r--r--sbin/pfctl/Makefile.depend1
-rw-r--r--sbin/pfctl/parse.y8
-rw-r--r--sbin/pfctl/pfctl.c2
-rw-r--r--sbin/pfctl/pfctl_altq.c8
-rw-r--r--sbin/pfctl/pfctl_qstats.c8
-rw-r--r--sbin/pflogd/Makefile3
-rw-r--r--sbin/ping/Makefile9
-rw-r--r--sbin/ping/ping.c7
-rw-r--r--sbin/ping6/Makefile3
-rw-r--r--sbin/ping6/ping6.c17
-rw-r--r--sbin/quotacheck/Makefile3
-rw-r--r--sbin/rcorder/Makefile12
-rw-r--r--sbin/rcorder/Makefile.depend2
-rw-r--r--sbin/rcorder/rcorder.c2
-rw-r--r--sbin/reboot/nextboot.88
-rw-r--r--sbin/resolvconf/Makefile2
-rw-r--r--sbin/restore/dirs.c16
-rw-r--r--sbin/restore/tape.c28
-rw-r--r--sbin/route/route.c10
-rw-r--r--sbin/routed/Makefile3
-rw-r--r--sbin/routed/input.c4
-rw-r--r--sbin/routed/routed.82
-rw-r--r--sbin/routed/rtquery/Makefile3
-rw-r--r--sbin/savecore/Makefile3
-rw-r--r--sbin/savecore/Makefile.depend1
-rw-r--r--sbin/savecore/savecore.c72
-rw-r--r--sbin/setkey/Makefile6
-rw-r--r--sbin/setkey/Makefile.depend1
-rw-r--r--sbin/shutdown/shutdown.811
-rw-r--r--sbin/shutdown/shutdown.c24
-rw-r--r--sbin/sunlabel/Makefile3
-rw-r--r--sbin/swapon/Makefile3
-rw-r--r--sbin/sysctl/sysctl.815
-rw-r--r--sbin/sysctl/sysctl.c30
-rw-r--r--sbin/tunefs/Makefile3
-rw-r--r--sbin/umount/umount.83
160 files changed, 2120 insertions, 1891 deletions
diff --git a/sbin/Makefile b/sbin/Makefile
index 3725270..c828b21 100644
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -8,7 +8,6 @@
SUBDIR=adjkerntz \
badsect \
camcontrol \
- ccdconfig \
clri \
comcontrol \
conscontrol \
@@ -31,11 +30,8 @@ SUBDIR=adjkerntz \
ggate \
growfs \
gvinum \
- hastctl \
- hastd \
ifconfig \
init \
- iscontrol \
kldconfig \
kldload \
kldstat \
@@ -82,10 +78,24 @@ SUBDIR+= atm
SUBDIR+= casperd
.endif
+.if ${MK_CCD} != "no"
+SUBDIR+= ccdconfig
+.endif
+
.if ${MK_CXX} != "no"
SUBDIR+= devd
.endif
+.if ${MK_HAST} != "no"
+SUBDIR+= hastctl
+SUBDIR+= hastd
+.endif
+
+.if ${MK_INET6} != "no"
+SUBDIR+= ping6
+SUBDIR+= rtsol
+.endif
+
.if ${MK_IPFILTER} != "no"
SUBDIR+= ipf
.endif
@@ -95,6 +105,10 @@ SUBDIR+= ipfw
SUBDIR+= natd
.endif
+.if ${MK_ISCSI} != "no"
+SUBDIR+= iscontrol
+.endif
+
.if ${MK_NAND} != "no"
SUBDIR+= nandfs
SUBDIR+= newfs_nandfs
@@ -105,11 +119,6 @@ SUBDIR+= pfctl
SUBDIR+= pflogd
.endif
-.if ${MK_INET6} != "no"
-SUBDIR+= ping6
-SUBDIR+= rtsol
-.endif
-
.if ${MK_QUOTAS} != "no"
SUBDIR+= quotacheck
.endif
diff --git a/sbin/atm/atmconfig/Makefile b/sbin/atm/atmconfig/Makefile
index ccf74d7..6ba1d31 100644
--- a/sbin/atm/atmconfig/Makefile
+++ b/sbin/atm/atmconfig/Makefile
@@ -17,11 +17,9 @@ CFLAGS+= -I.
.if !defined(RESCUE) && ${MK_BSNMP} != "no"
CFLAGS+= -DWITH_BSNMP
SRCS+= oid.h atmconfig_device.c
-DPADD+= ${LIBBSNMP}
-LDADD+= -lbsnmp
+LIBADD+= bsnmp
. if ${MK_DYNAMICROOT} == "no" && ${MK_OPENSSL} != "no"
-DPADD+= ${LIBCRYPTO}
-LDADD+= -lcrypto
+LIBADD+= crypto
. endif
.endif
diff --git a/sbin/atm/atmconfig/atmconfig.8 b/sbin/atm/atmconfig/atmconfig.8
index c8a740c..dc765ca 100644
--- a/sbin/atm/atmconfig/atmconfig.8
+++ b/sbin/atm/atmconfig/atmconfig.8
@@ -90,7 +90,7 @@ To get a list of options and arguments for a command use:
.Pp
To get a list of common options use:
.D1 Nm Ic help Cm options
-.Ss The Ic diag Ss Command
+.Ss The Ic diag Command
The
.Ic diag
command allows the inspection of the ATM interfaces on the local host
@@ -201,7 +201,7 @@ Print traffic parameters: PCR, SCR, MBS, MCR.
.It Nm Ic diag Cm stats Ar device
Print driver specific statistics.
.El
-.Ss The Ic natm Ss Command
+.Ss The Ic natm Command
The
.Ic natm
command is used to change
diff --git a/sbin/badsect/Makefile b/sbin/badsect/Makefile
index b6cb545..c11f8cba 100644
--- a/sbin/badsect/Makefile
+++ b/sbin/badsect/Makefile
@@ -2,8 +2,7 @@
# $FreeBSD$
PROG= badsect
-DPADD= ${LIBUFS}
-LDADD= -lufs
+LIBADD= ufs
MAN= badsect.8
WARNS?= 2
diff --git a/sbin/bsdlabel/Makefile b/sbin/bsdlabel/Makefile
index e51e928..42f0f1c 100644
--- a/sbin/bsdlabel/Makefile
+++ b/sbin/bsdlabel/Makefile
@@ -12,7 +12,6 @@ LINKS= ${BINDIR}/bsdlabel ${BINDIR}/disklabel
MLINKS= bsdlabel.8 disklabel.8
.endif
-DPADD= ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF}
-LDADD= -lgeom -lbsdxml -lsbuf
+LIBADD= geom
.include <bsd.prog.mk>
diff --git a/sbin/bsdlabel/bsdlabel.8 b/sbin/bsdlabel/bsdlabel.8
index e0f3752..54e2af2 100644
--- a/sbin/bsdlabel/bsdlabel.8
+++ b/sbin/bsdlabel/bsdlabel.8
@@ -109,7 +109,7 @@ argument forces
.Nm
to use a layout suitable for a different architecture.
Current valid values are
-.Cm i386 , amd64 ,
+.Cm i386 , amd64 ,
and
.Cm pc98 .
If this option is omitted,
diff --git a/sbin/camcontrol/Makefile b/sbin/camcontrol/Makefile
index 4f11f19..f23ef52 100644
--- a/sbin/camcontrol/Makefile
+++ b/sbin/camcontrol/Makefile
@@ -11,8 +11,7 @@ CFLAGS+= -DMINIMALISTIC
.if ${MACHINE_CPUARCH} == "arm"
WARNS?= 3
.endif
-DPADD= ${LIBCAM} ${LIBSBUF} ${LIBUTIL}
-LDADD= -lcam -lsbuf -lutil
+LIBADD= cam sbuf util
MAN= camcontrol.8
.include <bsd.prog.mk>
diff --git a/sbin/camcontrol/camcontrol.8 b/sbin/camcontrol/camcontrol.8
index 0fc7c1a..15e1862 100644
--- a/sbin/camcontrol/camcontrol.8
+++ b/sbin/camcontrol/camcontrol.8
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 31, 2014
+.Dd March 19, 2015
.Dt CAMCONTROL 8
.Os
.Sh NAME
@@ -110,6 +110,10 @@
.Aq Fl f Ar format
.Op Fl P
.Op Fl G
+.Op Fl q
+.Op Fl s
+.Op Fl S Ar offset
+.Op Fl X
.Nm
.Ic modepage
.Op device id
@@ -235,6 +239,16 @@
.Op device id
.Op generic args
.Nm
+.Ic apm
+.Op device id
+.Op generic args
+.Op Fl l Ar level
+.Nm
+.Ic aam
+.Op device id
+.Op generic args
+.Op Fl l Ar level
+.Nm
.Ic fwdownload
.Op device id
.Op generic args
@@ -513,18 +527,16 @@ connecting to that device.
Note that this can have a destructive impact
on the system.
.It Ic defects
-Send the SCSI READ DEFECT DATA (10) command (0x37) to the given device, and
+Send the
+.Tn SCSI
+READ DEFECT DATA (10) command (0x37) or the
+.Tn SCSI
+READ DEFECT DATA (12) command (0xB7) to the given device, and
print out any combination of: the total number of defects, the primary
defect list (PLIST), and the grown defect list (GLIST).
.Bl -tag -width 11n
.It Fl f Ar format
-The three format options are:
-.Em block ,
-to print out the list as logical blocks,
-.Em bfi ,
-to print out the list in bytes from index format, and
-.Em phys ,
-to print out the list in physical sector format.
+Specify the requested format of the defect list.
The format argument is
required.
Most drives support the physical sector format.
@@ -541,12 +553,51 @@ If the drive uses a non-standard sense code to report that it does not
support the requested format,
.Nm
will probably see the error as a failure to complete the request.
+.Pp
+The format options are:
+.Bl -tag -width 9n
+.It block
+Print out the list as logical blocks.
+This is limited to 32-bit block sizes, and isn't supported by many modern
+drives.
+.It longblock
+Print out the list as logical blocks.
+This option uses a 64-bit block size.
+.It bfi
+Print out the list in bytes from index format.
+.It extbfi
+Print out the list in extended bytes from index format.
+The extended format allows for ranges of blocks to be printed.
+.It phys
+Print out the list in physical sector format.
+Most drives support this format.
+.It extphys
+Print out the list in extended physical sector format.
+The extended format allows for ranges of blocks to be printed.
+.El
.It Fl G
Print out the grown defect list.
This is a list of bad blocks that have
been remapped since the disk left the factory.
.It Fl P
Print out the primary defect list.
+This is the list of defects that were present in the factory.
+.It Fl q
+When printing status information with
+.Fl s ,
+only print the number of defects.
+.It Fl s
+Just print the number of defects, not the list of defects.
+.It Fl S Ar offset
+Specify the starting offset into the defect list.
+This implies using the
+.Tn SCSI
+READ DEFECT DATA (12) command, as the 10 byte version of the command
+doesn't support the address descriptor index field.
+Not all drives support the 12 byte command, and some drives that support
+the 12 byte command don't support the address descriptor index field.
+.It Fl X
+Print out defects in hexadecimal (base 16) form instead of base 10 form.
.El
.Pp
If neither
@@ -1249,6 +1300,19 @@ Value 0 disables timer.
Put ATA device into SLEEP state.
Note that the only way get device out of
this state may be reset.
+.It Ic apm
+It optional parameter
+.Pq Fl l
+specified, enables and sets advanced power management level, where
+1 -- minimum power, 127 -- maximum performance with standby,
+128 -- minimum power without standby, 254 -- maximum performance.
+If not specified -- APM is disabled.
+.It Ic aam
+It optional parameter
+.Pq Fl l
+specified, enables and sets automatic acoustic management level, where
+1 -- minimum noise, 254 -- maximum performance.
+If not specified -- AAM is disabled.
.It Ic security
Update or report security settings, using an ATA identify command (0xec).
By default,
@@ -1364,8 +1428,8 @@ Defaults to
Confirm yes to dangerous options such as
.Fl e
without prompting for confirmation.
-.Pp
.El
+.Pp
If the password specified for any action commands does not match the configured
password for the specified user the command will fail.
.Pp
@@ -1434,8 +1498,8 @@ additional unlock calls until after a power-on reset.
Confirm yes to dangerous options such as
.Fl e
without prompting for confirmation
-.Pp
.El
+.Pp
The password for all HPA commands is limited to 32 characters, longer passwords
will fail.
.It Ic fwdownload
@@ -1613,7 +1677,7 @@ For example:
.It FC
A Fibre Channel Transport ID consists of
.Dq fcp,
-followed by a 64-bit Fibre Channel World Wide Name.
+followed by a 64-bit Fibre Channel World Wide Name.
For example:
.Pp
.Dl fcp,0x1234567812345678
@@ -1735,11 +1799,11 @@ May also be specified as
.Dq exclusive_access .
.It wr_ex_ro
Write Exclusive Registrants Only mode.
-May also be specified as
+May also be specified as
.Dq write_exclusive_reg_only .
.It ex_ac_ro
Exclusive Access Registrants Only mode.
-May also be specified as
+May also be specified as
.Dq exclusive_access_reg_only .
.It wr_ex_ar
Write Exclusive All Registrants mode.
@@ -1747,7 +1811,7 @@ May also be specified as
.Dq write_exclusive_all_regs .
.It ex_ac_ar
Exclusive Access All Registrants mode.
-May also be specified as
+May also be specified as
.Dq exclusive_access_all_regs .
.El
.It Fl U
@@ -1924,14 +1988,13 @@ power-on or hardware reset!
.Pp
.Em DO NOT
use this on a device which has an active filesystem!
-.Pp
.Bd -literal -offset indent
camcontrol persist da0 -v -i read_keys
.Ed
.Pp
This will read any persistent reservation keys registered with da0, and
display any errors encountered when sending the PERSISTENT RESERVE IN
-.Tn SCSI
+.Tn SCSI
command.
.Bd -literal -offset indent
camcontrol persist da0 -v -o register -a -K 0x12345678
@@ -1976,9 +2039,9 @@ camcontrol persist da0 -v -o register_move -k 0x87654321 \e
.Ed
.Pp
This will move the registration from the current initiator, whose
-Registration Key is 0x87654321, to the Fibre Channel initiator with the
+Registration Key is 0x87654321, to the Fibre Channel initiator with the
Fiber Channel World Wide Node Name 0x1234567812345678.
-A new registration key, 0x12345678, will be registered for the initiator
+A new registration key, 0x12345678, will be registered for the initiator
with the Fibre Channel World Wide Node Name 0x1234567812345678, and the
current initiator will be unregistered from the target.
The reservation will be moved to relative target port 2 on the target
diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c
index cdb379d..c0a1344 100644
--- a/sbin/camcontrol/camcontrol.c
+++ b/sbin/camcontrol/camcontrol.c
@@ -96,7 +96,9 @@ typedef enum {
CAM_CMD_SECURITY = 0x0000001d,
CAM_CMD_HPA = 0x0000001e,
CAM_CMD_SANITIZE = 0x0000001f,
- CAM_CMD_PERSIST = 0x00000020
+ CAM_CMD_PERSIST = 0x00000020,
+ CAM_CMD_APM = 0x00000021,
+ CAM_CMD_AAM = 0x00000022
} cam_cmdmask;
typedef enum {
@@ -167,7 +169,7 @@ struct ata_set_max_pwd
};
static const char scsicmd_opts[] = "a:c:dfi:o:r";
-static const char readdefect_opts[] = "f:GP";
+static const char readdefect_opts[] = "f:GPqsS:X";
static const char negotiate_opts[] = "acD:M:O:qR:T:UW:";
static const char smprg_opts[] = "l";
static const char smppc_opts[] = "a:A:d:lm:M:o:p:s:S:T:";
@@ -216,6 +218,8 @@ static struct camcontrol_opts option_table[] = {
{"idle", CAM_CMD_IDLE, CAM_ARG_NONE, "t:"},
{"standby", CAM_CMD_STANDBY, CAM_ARG_NONE, "t:"},
{"sleep", CAM_CMD_SLEEP, CAM_ARG_NONE, ""},
+ {"apm", CAM_CMD_APM, CAM_ARG_NONE, "l:"},
+ {"aam", CAM_CMD_AAM, CAM_ARG_NONE, "l:"},
{"fwdownload", CAM_CMD_DOWNLOAD_FW, CAM_ARG_NONE, "f:ys"},
{"security", CAM_CMD_SECURITY, CAM_ARG_NONE, "d:e:fh:k:l:qs:T:U:y"},
{"hpa", CAM_CMD_HPA, CAM_ARG_NONE, "Pflp:qs:U:y"},
@@ -1406,7 +1410,7 @@ atacapprint(struct ata_params *parm)
parm->enabled.command2 & ATA_SUPPORT_APM ? "yes" : "no");
if (parm->support.command2 & ATA_SUPPORT_APM) {
printf(" %d/0x%02X\n",
- parm->apm_value, parm->apm_value);
+ parm->apm_value & 0xff, parm->apm_value & 0xff);
} else
printf("\n");
printf("automatic acoustic management %s %s",
@@ -3369,39 +3373,64 @@ scanlun_or_reset_dev(path_id_t bus, target_id_t target, lun_id_t lun, int scan)
}
#ifndef MINIMALISTIC
+
+static struct scsi_nv defect_list_type_map[] = {
+ { "block", SRDD10_BLOCK_FORMAT },
+ { "extbfi", SRDD10_EXT_BFI_FORMAT },
+ { "extphys", SRDD10_EXT_PHYS_FORMAT },
+ { "longblock", SRDD10_LONG_BLOCK_FORMAT },
+ { "bfi", SRDD10_BYTES_FROM_INDEX_FORMAT },
+ { "phys", SRDD10_PHYSICAL_SECTOR_FORMAT }
+};
+
static int
readdefects(struct cam_device *device, int argc, char **argv,
char *combinedopt, int retry_count, int timeout)
{
union ccb *ccb = NULL;
- struct scsi_read_defect_data_10 *rdd_cdb;
+ struct scsi_read_defect_data_hdr_10 *hdr10 = NULL;
+ struct scsi_read_defect_data_hdr_12 *hdr12 = NULL;
+ size_t hdr_size = 0, entry_size = 0;
+ int use_12byte = 0;
+ int hex_format = 0;
u_int8_t *defect_list = NULL;
- u_int32_t max_dlist_length = SRDD10_MAX_LENGTH, dlist_length = 0;
- u_int32_t returned_length = 0;
- u_int32_t num_returned = 0;
- u_int8_t returned_format;
+ u_int8_t list_format = 0;
+ int list_type_set = 0;
+ u_int32_t dlist_length = 0;
+ u_int32_t returned_length = 0, valid_len = 0;
+ u_int32_t num_returned = 0, num_valid = 0;
+ u_int32_t max_possible_size = 0, hdr_max = 0;
+ u_int32_t starting_offset = 0;
+ u_int8_t returned_format, returned_type;
unsigned int i;
+ int summary = 0, quiet = 0;
int c, error = 0;
- int lists_specified;
- int get_length = 1;
+ int lists_specified = 0;
+ int get_length = 1, first_pass = 1;
+ int mads = 0;
while ((c = getopt(argc, argv, combinedopt)) != -1) {
switch(c){
case 'f':
{
- char *tstr;
- tstr = optarg;
- while (isspace(*tstr) && (*tstr != '\0'))
- tstr++;
- if (strcmp(tstr, "block") == 0)
- arglist |= CAM_ARG_FORMAT_BLOCK;
- else if (strcmp(tstr, "bfi") == 0)
- arglist |= CAM_ARG_FORMAT_BFI;
- else if (strcmp(tstr, "phys") == 0)
- arglist |= CAM_ARG_FORMAT_PHYS;
- else {
+ scsi_nv_status status;
+ int entry_num = 0;
+
+ status = scsi_get_nv(defect_list_type_map,
+ sizeof(defect_list_type_map) /
+ sizeof(defect_list_type_map[0]), optarg,
+ &entry_num, SCSI_NV_FLAG_IG_CASE);
+
+ if (status == SCSI_NV_FOUND) {
+ list_format = defect_list_type_map[
+ entry_num].value;
+ list_type_set = 1;
+ } else {
+ warnx("%s: %s %s option %s", __func__,
+ (status == SCSI_NV_AMBIGUOUS) ?
+ "ambiguous" : "invalid", "defect list type",
+ optarg);
error = 1;
- warnx("invalid defect format %s", tstr);
goto defect_bailout;
}
break;
@@ -3412,40 +3441,82 @@ readdefects(struct cam_device *device, int argc, char **argv,
case 'P':
arglist |= CAM_ARG_PLIST;
break;
+ case 'q':
+ quiet = 1;
+ break;
+ case 's':
+ summary = 1;
+ break;
+ case 'S': {
+ char *endptr;
+
+ starting_offset = strtoul(optarg, &endptr, 0);
+ if (*endptr != '\0') {
+ error = 1;
+ warnx("invalid starting offset %s", optarg);
+ goto defect_bailout;
+ }
+ break;
+ }
+ case 'X':
+ hex_format = 1;
+ break;
default:
break;
}
}
- ccb = cam_getccb(device);
-
- /*
- * Eventually we should probably support the 12 byte READ DEFECT
- * DATA command. It supports a longer parameter list, which may be
- * necessary on newer drives with lots of defects. According to
- * the SBC-3 spec, drives are supposed to return an illegal request
- * if they have more defect data than will fit in 64K.
- */
- defect_list = malloc(max_dlist_length);
- if (defect_list == NULL) {
- warnx("can't malloc memory for defect list");
+ if (list_type_set == 0) {
error = 1;
+ warnx("no defect list format specified");
goto defect_bailout;
}
+ if (arglist & CAM_ARG_PLIST) {
+ list_format |= SRDD10_PLIST;
+ lists_specified++;
+ }
+
+ if (arglist & CAM_ARG_GLIST) {
+ list_format |= SRDD10_GLIST;
+ lists_specified++;
+ }
+
+ /*
+ * This implies a summary, and was the previous behavior.
+ */
+ if (lists_specified == 0)
+ summary = 1;
+
+ ccb = cam_getccb(device);
+
+retry_12byte:
+
/*
* We start off asking for just the header to determine how much
* defect data is available. Some Hitachi drives return an error
* if you ask for more data than the drive has. Once we know the
* length, we retry the command with the returned length.
*/
- dlist_length = sizeof(struct scsi_read_defect_data_hdr_10);
-
- rdd_cdb =(struct scsi_read_defect_data_10 *)&ccb->csio.cdb_io.cdb_bytes;
+ if (use_12byte == 0)
+ dlist_length = sizeof(*hdr10);
+ else
+ dlist_length = sizeof(*hdr12);
retry:
+ if (defect_list != NULL) {
+ free(defect_list);
+ defect_list = NULL;
+ }
+ defect_list = malloc(dlist_length);
+ if (defect_list == NULL) {
+ warnx("can't malloc memory for defect list");
+ error = 1;
+ goto defect_bailout;
+ }
- lists_specified = 0;
+next_batch:
+ bzero(defect_list, dlist_length);
/*
* cam_getccb() zeros the CCB header only. So we need to zero the
@@ -3454,41 +3525,17 @@ retry:
bzero(&(&ccb->ccb_h)[1],
sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr));
- cam_fill_csio(&ccb->csio,
- /*retries*/ retry_count,
- /*cbfcnp*/ NULL,
- /*flags*/ CAM_DIR_IN | ((arglist & CAM_ARG_ERR_RECOVER) ?
- CAM_PASS_ERR_RECOVER : 0),
- /*tag_action*/ MSG_SIMPLE_Q_TAG,
- /*data_ptr*/ defect_list,
- /*dxfer_len*/ dlist_length,
- /*sense_len*/ SSD_FULL_SIZE,
- /*cdb_len*/ sizeof(struct scsi_read_defect_data_10),
- /*timeout*/ timeout ? timeout : 5000);
-
- rdd_cdb->opcode = READ_DEFECT_DATA_10;
- if (arglist & CAM_ARG_FORMAT_BLOCK)
- rdd_cdb->format = SRDD10_BLOCK_FORMAT;
- else if (arglist & CAM_ARG_FORMAT_BFI)
- rdd_cdb->format = SRDD10_BYTES_FROM_INDEX_FORMAT;
- else if (arglist & CAM_ARG_FORMAT_PHYS)
- rdd_cdb->format = SRDD10_PHYSICAL_SECTOR_FORMAT;
- else {
- error = 1;
- warnx("no defect list format specified");
- goto defect_bailout;
- }
- if (arglist & CAM_ARG_PLIST) {
- rdd_cdb->format |= SRDD10_PLIST;
- lists_specified++;
- }
-
- if (arglist & CAM_ARG_GLIST) {
- rdd_cdb->format |= SRDD10_GLIST;
- lists_specified++;
- }
-
- scsi_ulto2b(dlist_length, rdd_cdb->alloc_length);
+ scsi_read_defects(&ccb->csio,
+ /*retries*/ retry_count,
+ /*cbfcnp*/ NULL,
+ /*tag_action*/ MSG_SIMPLE_Q_TAG,
+ /*list_format*/ list_format,
+ /*addr_desc_index*/ starting_offset,
+ /*data_ptr*/ defect_list,
+ /*dxfer_len*/ dlist_length,
+ /*minimum_cmd_size*/ use_12byte ? 12 : 0,
+ /*sense_len*/ SSD_FULL_SIZE,
+ /*timeout*/ timeout ? timeout : 5000);
/* Disable freezing the device queue */
ccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
@@ -3505,8 +3552,61 @@ retry:
goto defect_bailout;
}
- returned_length = scsi_2btoul(((struct
- scsi_read_defect_data_hdr_10 *)defect_list)->length);
+ valid_len = ccb->csio.dxfer_len - ccb->csio.resid;
+
+ if (use_12byte == 0) {
+ hdr10 = (struct scsi_read_defect_data_hdr_10 *)defect_list;
+ hdr_size = sizeof(*hdr10);
+ hdr_max = SRDDH10_MAX_LENGTH;
+
+ if (valid_len >= hdr_size) {
+ returned_length = scsi_2btoul(hdr10->length);
+ returned_format = hdr10->format;
+ } else {
+ returned_length = 0;
+ returned_format = 0;
+ }
+ } else {
+ hdr12 = (struct scsi_read_defect_data_hdr_12 *)defect_list;
+ hdr_size = sizeof(*hdr12);
+ hdr_max = SRDDH12_MAX_LENGTH;
+
+ if (valid_len >= hdr_size) {
+ returned_length = scsi_4btoul(hdr12->length);
+ returned_format = hdr12->format;
+ } else {
+ returned_length = 0;
+ returned_format = 0;
+ }
+ }
+
+ returned_type = returned_format & SRDDH10_DLIST_FORMAT_MASK;
+ switch (returned_type) {
+ case SRDD10_BLOCK_FORMAT:
+ entry_size = sizeof(struct scsi_defect_desc_block);
+ break;
+ case SRDD10_LONG_BLOCK_FORMAT:
+ entry_size = sizeof(struct scsi_defect_desc_long_block);
+ break;
+ case SRDD10_EXT_PHYS_FORMAT:
+ case SRDD10_PHYSICAL_SECTOR_FORMAT:
+ entry_size = sizeof(struct scsi_defect_desc_phys_sector);
+ break;
+ case SRDD10_EXT_BFI_FORMAT:
+ case SRDD10_BYTES_FROM_INDEX_FORMAT:
+ entry_size = sizeof(struct scsi_defect_desc_bytes_from_index);
+ break;
+ default:
+ warnx("Unknown defect format 0x%x\n", returned_type);
+ error = 1;
+ goto defect_bailout;
+ break;
+ }
+
+ max_possible_size = (hdr_max / entry_size) * entry_size;
+ num_returned = returned_length / entry_size;
+ num_valid = min(returned_length, valid_len - hdr_size);
+ num_valid /= entry_size;
if (get_length != 0) {
get_length = 0;
@@ -3530,12 +3630,66 @@ retry:
if ((sense_key == SSD_KEY_RECOVERED_ERROR)
&& (asc == 0x1c) && (ascq == 0x00)
&& (returned_length > 0)) {
- dlist_length = returned_length +
- sizeof(struct scsi_read_defect_data_hdr_10);
- dlist_length = min(dlist_length,
- SRDD10_MAX_LENGTH);
- } else
- dlist_length = max_dlist_length;
+ if ((use_12byte == 0)
+ && (returned_length >= max_possible_size)) {
+ get_length = 1;
+ use_12byte = 1;
+ goto retry_12byte;
+ }
+ dlist_length = returned_length + hdr_size;
+ } else if ((sense_key == SSD_KEY_RECOVERED_ERROR)
+ && (asc == 0x1f) && (ascq == 0x00)
+ && (returned_length > 0)) {
+ /* Partial defect list transfer */
+ /*
+ * Hitachi drives return this error
+ * along with a partial defect list if they
+ * have more defects than the 10 byte
+ * command can support. Retry with the 12
+ * byte command.
+ */
+ if (use_12byte == 0) {
+ get_length = 1;
+ use_12byte = 1;
+ goto retry_12byte;
+ }
+ dlist_length = returned_length + hdr_size;
+ } else if ((sense_key == SSD_KEY_ILLEGAL_REQUEST)
+ && (asc == 0x24) && (ascq == 0x00)) {
+ /* Invalid field in CDB */
+ /*
+ * SBC-3 says that if the drive has more
+ * defects than can be reported with the
+ * 10 byte command, it should return this
+ * error and no data. Retry with the 12
+ * byte command.
+ */
+ if (use_12byte == 0) {
+ get_length = 1;
+ use_12byte = 1;
+ goto retry_12byte;
+ }
+ dlist_length = returned_length + hdr_size;
+ } else {
+ /*
+ * If we got a SCSI error and no valid length,
+ * just use the 10 byte maximum. The 12
+ * byte maximum is too large.
+ */
+ if (returned_length == 0)
+ dlist_length = SRDD10_MAX_LENGTH;
+ else {
+ if ((use_12byte == 0)
+ && (returned_length >=
+ max_possible_size)) {
+ get_length = 1;
+ use_12byte = 1;
+ goto retry_12byte;
+ }
+ dlist_length = returned_length +
+ hdr_size;
+ }
+ }
} else if ((ccb->ccb_h.status & CAM_STATUS_MASK) !=
CAM_REQ_CMP){
error = 1;
@@ -3545,16 +3699,40 @@ retry:
CAM_EPF_ALL, stderr);
goto defect_bailout;
} else {
- dlist_length = returned_length +
- sizeof(struct scsi_read_defect_data_hdr_10);
- dlist_length = min(dlist_length, SRDD10_MAX_LENGTH);
+ if ((use_12byte == 0)
+ && (returned_length >= max_possible_size)) {
+ get_length = 1;
+ use_12byte = 1;
+ goto retry_12byte;
+ }
+ dlist_length = returned_length + hdr_size;
}
+ if (summary != 0) {
+ fprintf(stdout, "%u", num_returned);
+ if (quiet == 0) {
+ fprintf(stdout, " defect%s",
+ (num_returned != 1) ? "s" : "");
+ }
+ fprintf(stdout, "\n");
+
+ goto defect_bailout;
+ }
+
+ /*
+ * We always limit the list length to the 10-byte maximum
+ * length (0xffff). The reason is that some controllers
+ * can't handle larger I/Os, and we can transfer the entire
+ * 10 byte list in one shot. For drives that support the 12
+ * byte read defects command, we'll step through the list
+ * by specifying a starting offset. For drives that don't
+ * support the 12 byte command's starting offset, we'll
+ * just display the first 64K.
+ */
+ dlist_length = min(dlist_length, SRDD10_MAX_LENGTH);
goto retry;
}
- returned_format = ((struct scsi_read_defect_data_hdr_10 *)
- defect_list)->format;
if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR)
&& (ccb->csio.scsi_status == SCSI_STATUS_CHECK_COND)
@@ -3571,32 +3749,32 @@ retry:
* According to the SCSI spec, if the disk doesn't support
* the requested format, it will generally return a sense
* key of RECOVERED ERROR, and an additional sense code
- * of "DEFECT LIST NOT FOUND". So, we check for that, and
- * also check to make sure that the returned length is
- * greater than 0, and then print out whatever format the
- * disk gave us.
+ * of "DEFECT LIST NOT FOUND". HGST drives also return
+ * Primary/Grown defect list not found errors. So just
+ * check for an ASC of 0x1c.
*/
if ((sense_key == SSD_KEY_RECOVERED_ERROR)
- && (asc == 0x1c) && (ascq == 0x00)
- && (returned_length > 0)) {
- warnx("requested defect format not available");
- switch(returned_format & SRDDH10_DLIST_FORMAT_MASK) {
- case SRDD10_BLOCK_FORMAT:
- warnx("Device returned block format");
- break;
- case SRDD10_BYTES_FROM_INDEX_FORMAT:
- warnx("Device returned bytes from index"
- " format");
- break;
- case SRDD10_PHYSICAL_SECTOR_FORMAT:
- warnx("Device returned physical sector format");
- break;
- default:
+ && (asc == 0x1c)) {
+ const char *format_str;
+
+ format_str = scsi_nv_to_str(defect_list_type_map,
+ sizeof(defect_list_type_map) /
+ sizeof(defect_list_type_map[0]),
+ list_format & SRDD10_DLIST_FORMAT_MASK);
+ warnx("requested defect format %s not available",
+ format_str ? format_str : "unknown");
+
+ format_str = scsi_nv_to_str(defect_list_type_map,
+ sizeof(defect_list_type_map) /
+ sizeof(defect_list_type_map[0]), returned_type);
+ if (format_str != NULL) {
+ warnx("Device returned %s format",
+ format_str);
+ } else {
error = 1;
warnx("Device returned unknown defect"
- " data format %#x", returned_format);
+ " data format %#x", returned_type);
goto defect_bailout;
- break; /* NOTREACHED */
}
} else {
error = 1;
@@ -3615,99 +3793,151 @@ retry:
goto defect_bailout;
}
+ if (first_pass != 0) {
+ fprintf(stderr, "Got %d defect", num_returned);
+
+ if ((lists_specified == 0) || (num_returned == 0)) {
+ fprintf(stderr, "s.\n");
+ goto defect_bailout;
+ } else if (num_returned == 1)
+ fprintf(stderr, ":\n");
+ else
+ fprintf(stderr, "s:\n");
+
+ first_pass = 0;
+ }
+
/*
* XXX KDM I should probably clean up the printout format for the
* disk defects.
*/
- switch (returned_format & SRDDH10_DLIST_FORMAT_MASK){
- case SRDDH10_PHYSICAL_SECTOR_FORMAT:
- {
- struct scsi_defect_desc_phys_sector *dlist;
-
- dlist = (struct scsi_defect_desc_phys_sector *)
- (defect_list +
- sizeof(struct scsi_read_defect_data_hdr_10));
-
- num_returned = returned_length /
- sizeof(struct scsi_defect_desc_phys_sector);
-
- fprintf(stderr, "Got %d defect", num_returned);
-
- if ((lists_specified == 0) || (num_returned == 0)) {
- fprintf(stderr, "s.\n");
- break;
- } else if (num_returned == 1)
- fprintf(stderr, ":\n");
+ switch (returned_type) {
+ case SRDD10_PHYSICAL_SECTOR_FORMAT:
+ case SRDD10_EXT_PHYS_FORMAT:
+ {
+ struct scsi_defect_desc_phys_sector *dlist;
+
+ dlist = (struct scsi_defect_desc_phys_sector *)
+ (defect_list + hdr_size);
+
+ for (i = 0; i < num_valid; i++) {
+ uint32_t sector;
+
+ sector = scsi_4btoul(dlist[i].sector);
+ if (returned_type == SRDD10_EXT_PHYS_FORMAT) {
+ mads = (sector & SDD_EXT_PHYS_MADS) ?
+ 0 : 1;
+ sector &= ~SDD_EXT_PHYS_FLAG_MASK;
+ }
+ if (hex_format == 0)
+ fprintf(stdout, "%d:%d:%d%s",
+ scsi_3btoul(dlist[i].cylinder),
+ dlist[i].head,
+ scsi_4btoul(dlist[i].sector),
+ mads ? " - " : "\n");
else
- fprintf(stderr, "s:\n");
-
- for (i = 0; i < num_returned; i++) {
- fprintf(stdout, "%d:%d:%d\n",
+ fprintf(stdout, "0x%x:0x%x:0x%x%s",
scsi_3btoul(dlist[i].cylinder),
dlist[i].head,
- scsi_4btoul(dlist[i].sector));
- }
- break;
+ scsi_4btoul(dlist[i].sector),
+ mads ? " - " : "\n");
+ mads = 0;
}
- case SRDDH10_BYTES_FROM_INDEX_FORMAT:
- {
- struct scsi_defect_desc_bytes_from_index *dlist;
-
- dlist = (struct scsi_defect_desc_bytes_from_index *)
- (defect_list +
- sizeof(struct scsi_read_defect_data_hdr_10));
+ if (num_valid < num_returned) {
+ starting_offset += num_valid;
+ goto next_batch;
+ }
+ break;
+ }
+ case SRDD10_BYTES_FROM_INDEX_FORMAT:
+ case SRDD10_EXT_BFI_FORMAT:
+ {
+ struct scsi_defect_desc_bytes_from_index *dlist;
- num_returned = returned_length /
- sizeof(struct scsi_defect_desc_bytes_from_index);
+ dlist = (struct scsi_defect_desc_bytes_from_index *)
+ (defect_list + hdr_size);
- fprintf(stderr, "Got %d defect", num_returned);
+ for (i = 0; i < num_valid; i++) {
+ uint32_t bfi;
- if ((lists_specified == 0) || (num_returned == 0)) {
- fprintf(stderr, "s.\n");
- break;
- } else if (num_returned == 1)
- fprintf(stderr, ":\n");
+ bfi = scsi_4btoul(dlist[i].bytes_from_index);
+ if (returned_type == SRDD10_EXT_BFI_FORMAT) {
+ mads = (bfi & SDD_EXT_BFI_MADS) ? 1 : 0;
+ bfi &= ~SDD_EXT_BFI_FLAG_MASK;
+ }
+ if (hex_format == 0)
+ fprintf(stdout, "%d:%d:%d%s",
+ scsi_3btoul(dlist[i].cylinder),
+ dlist[i].head,
+ scsi_4btoul(dlist[i].bytes_from_index),
+ mads ? " - " : "\n");
else
- fprintf(stderr, "s:\n");
-
- for (i = 0; i < num_returned; i++) {
- fprintf(stdout, "%d:%d:%d\n",
+ fprintf(stdout, "0x%x:0x%x:0x%x%s",
scsi_3btoul(dlist[i].cylinder),
dlist[i].head,
- scsi_4btoul(dlist[i].bytes_from_index));
- }
- break;
+ scsi_4btoul(dlist[i].bytes_from_index),
+ mads ? " - " : "\n");
+
+ mads = 0;
}
- case SRDDH10_BLOCK_FORMAT:
- {
- struct scsi_defect_desc_block *dlist;
+ if (num_valid < num_returned) {
+ starting_offset += num_valid;
+ goto next_batch;
+ }
+ break;
+ }
+ case SRDDH10_BLOCK_FORMAT:
+ {
+ struct scsi_defect_desc_block *dlist;
- dlist = (struct scsi_defect_desc_block *)(defect_list +
- sizeof(struct scsi_read_defect_data_hdr_10));
+ dlist = (struct scsi_defect_desc_block *)
+ (defect_list + hdr_size);
- num_returned = returned_length /
- sizeof(struct scsi_defect_desc_block);
+ for (i = 0; i < num_valid; i++) {
+ if (hex_format == 0)
+ fprintf(stdout, "%u\n",
+ scsi_4btoul(dlist[i].address));
+ else
+ fprintf(stdout, "0x%x\n",
+ scsi_4btoul(dlist[i].address));
+ }
- fprintf(stderr, "Got %d defect", num_returned);
+ if (num_valid < num_returned) {
+ starting_offset += num_valid;
+ goto next_batch;
+ }
- if ((lists_specified == 0) || (num_returned == 0)) {
- fprintf(stderr, "s.\n");
- break;
- } else if (num_returned == 1)
- fprintf(stderr, ":\n");
+ break;
+ }
+ case SRDD10_LONG_BLOCK_FORMAT:
+ {
+ struct scsi_defect_desc_long_block *dlist;
+
+ dlist = (struct scsi_defect_desc_long_block *)
+ (defect_list + hdr_size);
+
+ for (i = 0; i < num_valid; i++) {
+ if (hex_format == 0)
+ fprintf(stdout, "%ju\n",
+ (uintmax_t)scsi_8btou64(
+ dlist[i].address));
else
- fprintf(stderr, "s:\n");
+ fprintf(stdout, "0x%jx\n",
+ (uintmax_t)scsi_8btou64(
+ dlist[i].address));
+ }
- for (i = 0; i < num_returned; i++)
- fprintf(stdout, "%u\n",
- scsi_4btoul(dlist[i].address));
- break;
+ if (num_valid < num_returned) {
+ starting_offset += num_valid;
+ goto next_batch;
}
- default:
- fprintf(stderr, "Unknown defect format %d\n",
- returned_format & SRDDH10_DLIST_FORMAT_MASK);
- error = 1;
- break;
+ break;
+ }
+ default:
+ fprintf(stderr, "Unknown defect format 0x%x\n",
+ returned_type);
+ error = 1;
+ break;
}
defect_bailout:
@@ -7178,7 +7408,7 @@ getdevid(struct cam_devitem *item)
retry:
ccb->ccb_h.func_code = XPT_DEV_ADVINFO;
ccb->ccb_h.flags = CAM_DIR_IN;
- ccb->cdai.flags = 0;
+ ccb->cdai.flags = CDAI_FLAG_NONE;
ccb->cdai.buftype = CDAI_TYPE_SCSI_DEVID;
ccb->cdai.bufsiz = item->device_id_len;
if (item->device_id_len != 0)
@@ -7738,39 +7968,83 @@ atapm(struct cam_device *device, int argc, char **argv,
else
sc = 253;
- cam_fill_ataio(&ccb->ataio,
- retry_count,
- NULL,
- /*flags*/CAM_DIR_NONE,
- MSG_SIMPLE_Q_TAG,
- /*data_ptr*/NULL,
- /*dxfer_len*/0,
- timeout ? timeout : 30 * 1000);
- ata_28bit_cmd(&ccb->ataio, cmd, 0, 0, sc);
-
- /* Disable freezing the device queue */
- ccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
+ retval = ata_do_28bit_cmd(device,
+ ccb,
+ /*retries*/retry_count,
+ /*flags*/CAM_DIR_NONE,
+ /*protocol*/AP_PROTO_NON_DATA,
+ /*tag_action*/MSG_SIMPLE_Q_TAG,
+ /*command*/cmd,
+ /*features*/0,
+ /*lba*/0,
+ /*sector_count*/sc,
+ /*data_ptr*/NULL,
+ /*dxfer_len*/0,
+ /*timeout*/timeout ? timeout : 30 * 1000,
+ /*quiet*/1);
- if (arglist & CAM_ARG_ERR_RECOVER)
- ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER;
+ cam_freeccb(ccb);
+ return (retval);
+}
- if (cam_send_ccb(device, ccb) < 0) {
- warn("error sending command");
+static int
+ataaxm(struct cam_device *device, int argc, char **argv,
+ char *combinedopt, int retry_count, int timeout)
+{
+ union ccb *ccb;
+ int retval = 0;
+ int l = -1;
+ int c;
+ u_char cmd, sc;
- if (arglist & CAM_ARG_VERBOSE)
- cam_error_print(device, ccb, CAM_ESF_ALL,
- CAM_EPF_ALL, stderr);
+ ccb = cam_getccb(device);
- retval = 1;
- goto bailout;
+ if (ccb == NULL) {
+ warnx("%s: error allocating ccb", __func__);
+ return (1);
}
- if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
- cam_error_print(device, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr);
- retval = 1;
- goto bailout;
+ while ((c = getopt(argc, argv, combinedopt)) != -1) {
+ switch (c) {
+ case 'l':
+ l = atoi(optarg);
+ break;
+ default:
+ break;
+ }
}
-bailout:
+ sc = 0;
+ if (strcmp(argv[1], "apm") == 0) {
+ if (l == -1)
+ cmd = 0x85;
+ else {
+ cmd = 0x05;
+ sc = l;
+ }
+ } else /* aam */ {
+ if (l == -1)
+ cmd = 0xC2;
+ else {
+ cmd = 0x42;
+ sc = l;
+ }
+ }
+
+ retval = ata_do_28bit_cmd(device,
+ ccb,
+ /*retries*/retry_count,
+ /*flags*/CAM_DIR_NONE,
+ /*protocol*/AP_PROTO_NON_DATA,
+ /*tag_action*/MSG_SIMPLE_Q_TAG,
+ /*command*/ATA_SETFEATURES,
+ /*features*/cmd,
+ /*lba*/0,
+ /*sector_count*/sc,
+ /*data_ptr*/NULL,
+ /*dxfer_len*/0,
+ /*timeout*/timeout ? timeout : 30 * 1000,
+ /*quiet*/1);
+
cam_freeccb(ccb);
return (retval);
}
@@ -7801,6 +8075,7 @@ usage(int printlong)
" camcontrol reset <all | bus[:target:lun]>\n"
#ifndef MINIMALISTIC
" camcontrol defects [dev_id][generic args] <-f format> [-P][-G]\n"
+" [-q][-s][-S offset][-X]\n"
" camcontrol modepage [dev_id][generic args] <-m page | -l>\n"
" [-P pagectl][-e | -b][-d]\n"
" camcontrol cmd [dev_id][generic args]\n"
@@ -7831,6 +8106,8 @@ usage(int printlong)
" camcontrol idle [dev_id][generic args][-t time]\n"
" camcontrol standby [dev_id][generic args][-t time]\n"
" camcontrol sleep [dev_id][generic args]\n"
+" camcontrol apm [dev_id][generic args][-l level]\n"
+" camcontrol aam [dev_id][generic args][-l level]\n"
" camcontrol fwdownload [dev_id][generic args] <-f fw_image> [-y][-s]\n"
" camcontrol security [dev_id][generic args]\n"
" <-d pwd | -e pwd | -f | -h pwd | -k pwd>\n"
@@ -8351,6 +8628,11 @@ main(int argc, char **argv)
error = atapm(cam_dev, argc, argv,
combinedopt, retry_count, timeout);
break;
+ case CAM_CMD_APM:
+ case CAM_CMD_AAM:
+ error = ataaxm(cam_dev, argc, argv,
+ combinedopt, retry_count, timeout);
+ break;
case CAM_CMD_SECURITY:
error = atasecurity(cam_dev, retry_count, timeout,
argc, argv, combinedopt);
diff --git a/sbin/casperd/Makefile b/sbin/casperd/Makefile
index f5a8e05..93f145c 100644
--- a/sbin/casperd/Makefile
+++ b/sbin/casperd/Makefile
@@ -4,8 +4,7 @@ PROG= casperd
SRCS= casperd.c zygote.c
-DPADD= ${LIBCASPER} ${LIBCAPSICUM} ${LIBNV} ${LIBPJDLOG} ${LIBUTIL}
-LDADD= -lcasper -lcapsicum -lnv -lpjdlog -lutil
+LIBADD= casper nv pjdlog util
MAN= casperd.8
diff --git a/sbin/casperd/casperd.c b/sbin/casperd/casperd.c
index 4b9037b..f838811 100644
--- a/sbin/casperd/casperd.c
+++ b/sbin/casperd/casperd.c
@@ -357,7 +357,7 @@ service_external_execute(int chanfd)
int stderrfd, execfd, procfd;
nvlist_t *nvl;
- nvl = nvlist_recv(chanfd);
+ nvl = nvlist_recv(chanfd, 0);
if (nvl == NULL)
pjdlog_exit(1, "Unable to receive nvlist");
service = nvlist_take_string(nvl, "service");
diff --git a/sbin/casperd/zygote.c b/sbin/casperd/zygote.c
index be3d9e5..c460bd3 100644
--- a/sbin/casperd/zygote.c
+++ b/sbin/casperd/zygote.c
@@ -91,7 +91,7 @@ zygote_clone(zygote_func_t *func, int flags, int *chanfdp, int *procfdp)
nvl = nvlist_create(0);
nvlist_add_number(nvl, "func", (uint64_t)(uintptr_t)func);
nvlist_add_number(nvl, "flags", (uint64_t)flags);
- nvl = nvlist_xfer(zygote_sock, nvl);
+ nvl = nvlist_xfer(zygote_sock, nvl, 0);
if (nvl == NULL)
return (-1);
if (nvlist_exists_number(nvl, "error")) {
@@ -134,7 +134,7 @@ zygote_main(int sock)
closefrom(sock + 1);
for (;;) {
- nvlin = nvlist_recv(sock);
+ nvlin = nvlist_recv(sock, 0);
if (nvlin == NULL) {
if (errno == ENOTCONN) {
/* Casperd exited. */
diff --git a/sbin/ccdconfig/Makefile b/sbin/ccdconfig/Makefile
index 0feca54..3b64daf 100644
--- a/sbin/ccdconfig/Makefile
+++ b/sbin/ccdconfig/Makefile
@@ -3,7 +3,6 @@
PROG= ccdconfig
MAN= ccdconfig.8
-DPADD= ${LIBGEOM}
-LDADD= -lgeom
+LIBADD= geom
.include <bsd.prog.mk>
diff --git a/sbin/ddb/Makefile b/sbin/ddb/Makefile
index c556be1..72abbed 100644
--- a/sbin/ddb/Makefile
+++ b/sbin/ddb/Makefile
@@ -5,7 +5,6 @@ SRCS= ddb.c ddb_capture.c ddb_script.c
MAN= ddb.8
WARNS?= 3
-DPADD= ${LIBKVM}
-LDADD= -lkvm
+LIBADD= kvm
.include <bsd.prog.mk>
diff --git a/sbin/devd/Makefile b/sbin/devd/Makefile
index 518e5e2..fc00216 100644
--- a/sbin/devd/Makefile
+++ b/sbin/devd/Makefile
@@ -10,8 +10,7 @@ WARNS?= 3
NO_SHARED?=YES
-DPADD= ${LIBL} ${LIBUTIL}
-LDADD= -ll -lutil
+LIBADD= l util
YFLAGS+=-v
CFLAGS+=-I. -I${.CURDIR}
diff --git a/sbin/devd/Makefile.depend b/sbin/devd/Makefile.depend
index adc7292..9102b49 100644
--- a/sbin/devd/Makefile.depend
+++ b/sbin/devd/Makefile.depend
@@ -13,6 +13,7 @@ DIRDEPS = \
lib/libutil \
lib/msun \
usr.bin/lex/lib \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5
index 311228e..3956a73 100644
--- a/sbin/devd/devd.conf.5
+++ b/sbin/devd/devd.conf.5
@@ -41,7 +41,7 @@
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
.\" SOFTWARE.
.\"
-.Dd February 22, 2013
+.Dd May 13, 2015
.Dt DEVD.CONF 5
.Os
.Sh NAME
@@ -270,6 +270,8 @@ Interface Class (USB)
Interface Protocol (USB)
.It Li intsubclass
Interface Sub-class (USB)
+.It Li jail
+Jail name for the process triggering the rule (RCTL)
.It Li manufacturer
Manufacturer ID (pccard).
.It Li mode
@@ -280,12 +282,18 @@ Match the value of the
variable.
.It Li parent
Parent device
+.It Li pid
+PID of the process triggering the rule (RCTL)
.It Li port
Hub port number (USB)
.It Li product
Product ID (pccard/USB).
.It Li release
Hardware revision (USB)
+.It Li ruid
+Real UID of the process triggering the rule (RCTL)
+.It Li rule
+Rule (RCTL)
.It Li sernum
Serial Number (USB).
.It Li slot
@@ -370,6 +378,47 @@ node is destroyed.
.El
.El
.Pp
+.It Li GEOM
+Events related to the
+.Xr geom 4
+framework.
+The difference compared to
+.Li DEVFS
+is that
+.Li GEOM
+only includes disk-like devices.
+.Bl -tag -width ".Sy Subsystem" -compact
+.It Sy Subsystem
+.It Li DEV
+.Bl -tag -width ".Li MEDIACHANGE" -compact
+.It Sy Type
+.It Li CREATE
+A
+.Xr geom 4
+device node is created.
+.It Li DESTROY
+A
+.Xr geom 4
+device node is destroyed.
+.It Li MEDIACHANGE
+Physical media has changed.
+.El
+.El
+.Pp
+.It Li RCTL
+Events related to the
+.Xr rctl 8
+framework.
+.Bl -tag -width ".Sy Subsystem" -compact
+.It Sy Subsystem
+.It Li rule
+.Bl -tag -width ".Li matched" -compact
+.It Sy Type
+.It Li matched
+A rule with action specified as "devctl" was triggered.
+.El
+.El
+.Pp
.It Li USB
Events related to the USB subsystem.
.Bl -tag -width ".Sy Subsystem" -compact
diff --git a/sbin/dhclient/Makefile b/sbin/dhclient/Makefile
index 09f19db..868df6d 100644
--- a/sbin/dhclient/Makefile
+++ b/sbin/dhclient/Makefile
@@ -41,8 +41,7 @@ PROG= dhclient
SCRIPTS=dhclient-script
MAN= dhclient.8 dhclient.conf.5 dhclient.leases.5 dhcp-options.5 \
dhclient-script.8
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+LIBADD= util
WARNS?= 2
diff --git a/sbin/dhclient/dhclient.conf.5 b/sbin/dhclient/dhclient.conf.5
index 3b6ae04..fb9d9f1 100644
--- a/sbin/dhclient/dhclient.conf.5
+++ b/sbin/dhclient/dhclient.conf.5
@@ -524,8 +524,8 @@ In many cases, it is sufficient to just create an empty
file - the defaults are usually fine.
.Sh SEE ALSO
.Xr dhclient.leases 5 ,
-.Xr dhcpd.conf 5 ,
.Xr dhcp-options 5 ,
+.Xr dhcpd.conf 5 ,
.Xr dhclient 8 ,
.Xr dhcpd 8
.Rs
diff --git a/sbin/dhclient/dhclient.leases.5 b/sbin/dhclient/dhclient.leases.5
index f48b106..ebef819 100644
--- a/sbin/dhclient/dhclient.leases.5
+++ b/sbin/dhclient/dhclient.leases.5
@@ -75,8 +75,8 @@ Current lease file.
.El
.Sh SEE ALSO
.Xr dhclient.conf 5 ,
-.Xr dhcpd.conf 5 ,
.Xr dhcp-options 5 ,
+.Xr dhcpd.conf 5 ,
.Xr dhclient 8 ,
.Xr dhcpd 8
.Rs
diff --git a/sbin/dmesg/Makefile b/sbin/dmesg/Makefile
index 266551b..64a0155 100644
--- a/sbin/dmesg/Makefile
+++ b/sbin/dmesg/Makefile
@@ -4,7 +4,6 @@
PROG= dmesg
MAN= dmesg.8
-LDADD= -lkvm
-DPADD= ${LIBKVM}
+LIBADD= kvm
.include <bsd.prog.mk>
diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c
index f0fcb81..827ed8e 100644
--- a/sbin/dmesg/dmesg.c
+++ b/sbin/dmesg/dmesg.c
@@ -111,15 +111,22 @@ main(int argc, char *argv[])
if (memf == NULL) {
/*
- * Running kernel. Use sysctl. This gives an unwrapped
- * buffer as a side effect.
+ * Running kernel. Use sysctl. This gives an unwrapped buffer
+ * as a side effect. Remove nulterm (if present) so the value
+ * returned by sysctl is formatted as the rest of the code
+ * expects (the same as the value read from a core file below).
*/
if (sysctlbyname("kern.msgbuf", NULL, &buflen, NULL, 0) == -1)
err(1, "sysctl kern.msgbuf");
+ /* Allocate extra room for growth between the sysctl calls. */
+ buflen += buflen/8;
+ /* Allocate more than sysctl sees, for room to append \n\0. */
if ((bp = malloc(buflen + 2)) == NULL)
errx(1, "malloc failed");
if (sysctlbyname("kern.msgbuf", bp, &buflen, NULL, 0) == -1)
err(1, "sysctl kern.msgbuf");
+ if (buflen > 0 && bp[buflen - 1] == '\0')
+ buflen--;
if (clear)
if (sysctlbyname("kern.msgbuf_clear", NULL, NULL, &clear, sizeof(int)))
err(1, "sysctl kern.msgbuf_clear");
diff --git a/sbin/dumpfs/Makefile b/sbin/dumpfs/Makefile
index fe464e0..87eb89b 100644
--- a/sbin/dumpfs/Makefile
+++ b/sbin/dumpfs/Makefile
@@ -3,8 +3,7 @@
PROG= dumpfs
WARNS?= 2
-DPADD= ${LIBUFS}
-LDADD= -lufs
+LIBADD= ufs
MAN= dumpfs.8
.include <bsd.prog.mk>
diff --git a/sbin/fdisk/Makefile b/sbin/fdisk/Makefile
index 7953779..a49c699 100644
--- a/sbin/fdisk/Makefile
+++ b/sbin/fdisk/Makefile
@@ -7,8 +7,7 @@ MAN= fdisk.8
.PATH: ${.CURDIR}/../../sys/geom
-DPADD+= ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF}
-LDADD+= -lgeom -lbsdxml -lsbuf
+LIBADD= geom
.include <bsd.prog.mk>
diff --git a/sbin/fdisk_pc98/Makefile b/sbin/fdisk_pc98/Makefile
index 6961d31..9915267 100644
--- a/sbin/fdisk_pc98/Makefile
+++ b/sbin/fdisk_pc98/Makefile
@@ -7,7 +7,6 @@ MAN= fdisk.8
.PATH: ${.CURDIR}/../../sys/geom
-DPADD+= ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF}
-LDADD+= -lgeom -lbsdxml -lsbuf
+LIBADD= geom
.include <bsd.prog.mk>
diff --git a/sbin/ffsinfo/Makefile b/sbin/ffsinfo/Makefile
index cb4e8f9..7fd033d 100644
--- a/sbin/ffsinfo/Makefile
+++ b/sbin/ffsinfo/Makefile
@@ -13,7 +13,6 @@ MAN= ffsinfo.8
WARNS?= 1
CFLAGS+=-DFS_DEBUG -I${GROWFS}
-DPADD= ${LIBUFS}
-LDADD= -lufs
+LIBADD= ufs
.include <bsd.prog.mk>
diff --git a/sbin/ffsinfo/ffsinfo.c b/sbin/ffsinfo/ffsinfo.c
index 881fc1e..c1e7c87 100644
--- a/sbin/ffsinfo/ffsinfo.c
+++ b/sbin/ffsinfo/ffsinfo.c
@@ -67,6 +67,7 @@ static const char rcsid[] =
#include <fcntl.h>
#include <libufs.h>
#include <paths.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -361,7 +362,7 @@ dump_whole_ufs1_inode(ino_t inode, int level)
/*
* Dump the main inode structure.
*/
- snprintf(comment, sizeof(comment), "Inode 0x%08x", inode);
+ snprintf(comment, sizeof(comment), "Inode 0x%08jx", (uintmax_t)inode);
if (level & 0x100) {
DBG_DUMP_INO(&sblock,
comment,
@@ -385,8 +386,8 @@ dump_whole_ufs1_inode(ino_t inode, int level)
(size_t)sblock.fs_bsize) == -1) {
err(1, "bread: %s", disk.d_error);
}
- snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 0",
- inode);
+ snprintf(comment, sizeof(comment), "Inode 0x%08jx: indirect 0",
+ (uintmax_t)inode);
DBG_DUMP_IBLK(&sblock,
comment,
i1blk,
@@ -401,8 +402,8 @@ dump_whole_ufs1_inode(ino_t inode, int level)
(size_t)sblock.fs_bsize) == -1) {
err(1, "bread: %s", disk.d_error);
}
- snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 1",
- inode);
+ snprintf(comment, sizeof(comment), "Inode 0x%08jx: indirect 1",
+ (uintmax_t)inode);
DBG_DUMP_IBLK(&sblock,
comment,
i2blk,
@@ -416,7 +417,8 @@ dump_whole_ufs1_inode(ino_t inode, int level)
err(1, "bread: %s", disk.d_error);
}
snprintf(comment, sizeof(comment),
- "Inode 0x%08x: indirect 1->%d", inode, ind2ctr);
+ "Inode 0x%08jx: indirect 1->%d", (uintmax_t)inode,
+ ind2ctr);
DBG_DUMP_IBLK(&sblock,
comment,
i1blk,
@@ -432,8 +434,8 @@ dump_whole_ufs1_inode(ino_t inode, int level)
(size_t)sblock.fs_bsize) == -1) {
err(1, "bread: %s", disk.d_error);
}
- snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 2",
- inode);
+ snprintf(comment, sizeof(comment), "Inode 0x%08jx: indirect 2",
+ (uintmax_t)inode);
#define SQUARE(a) ((a)*(a))
DBG_DUMP_IBLK(&sblock,
comment,
@@ -450,7 +452,8 @@ dump_whole_ufs1_inode(ino_t inode, int level)
err(1, "bread: %s", disk.d_error);
}
snprintf(comment, sizeof(comment),
- "Inode 0x%08x: indirect 2->%d", inode, ind3ctr);
+ "Inode 0x%08jx: indirect 2->%d", (uintmax_t)inode,
+ ind3ctr);
DBG_DUMP_IBLK(&sblock,
comment,
i2blk,
@@ -466,8 +469,8 @@ dump_whole_ufs1_inode(ino_t inode, int level)
err(1, "bread: %s", disk.d_error);
}
snprintf(comment, sizeof(comment),
- "Inode 0x%08x: indirect 2->%d->%d", inode,
- ind3ctr, ind3ctr);
+ "Inode 0x%08jx: indirect 2->%d->%d",
+ (uintmax_t)inode, ind3ctr, ind3ctr);
DBG_DUMP_IBLK(&sblock,
comment,
i1blk,
@@ -513,7 +516,7 @@ dump_whole_ufs2_inode(ino_t inode, int level)
/*
* Dump the main inode structure.
*/
- snprintf(comment, sizeof(comment), "Inode 0x%08x", inode);
+ snprintf(comment, sizeof(comment), "Inode 0x%08jx", (uintmax_t)inode);
if (level & 0x100) {
DBG_DUMP_INO(&sblock, comment, ino);
}
@@ -535,7 +538,8 @@ dump_whole_ufs2_inode(ino_t inode, int level)
(size_t)sblock.fs_bsize) == -1) {
err(1, "bread: %s", disk.d_error);
}
- snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 0", inode);
+ snprintf(comment, sizeof(comment), "Inode 0x%08jx: indirect 0",
+ (uintmax_t)inode);
DBG_DUMP_IBLK(&sblock, comment, i1blk, (size_t)rb);
rb -= howmany(sblock.fs_bsize, sizeof(ufs2_daddr_t));
}
@@ -547,7 +551,8 @@ dump_whole_ufs2_inode(ino_t inode, int level)
(size_t)sblock.fs_bsize) == -1) {
err(1, "bread: %s", disk.d_error);
}
- snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 1", inode);
+ snprintf(comment, sizeof(comment), "Inode 0x%08jx: indirect 1",
+ (uintmax_t)inode);
DBG_DUMP_IBLK(&sblock,
comment,
i2blk,
@@ -561,7 +566,8 @@ dump_whole_ufs2_inode(ino_t inode, int level)
err(1, "bread: %s", disk.d_error);
}
snprintf(comment, sizeof(comment),
- "Inode 0x%08x: indirect 1->%d", inode, ind2ctr);
+ "Inode 0x%08jx: indirect 1->%d",
+ (uintmax_t)inode, ind2ctr);
DBG_DUMP_IBLK(&sblock, comment, i1blk, (size_t)rb);
rb -= howmany(sblock.fs_bsize, sizeof(ufs2_daddr_t));
}
@@ -574,7 +580,8 @@ dump_whole_ufs2_inode(ino_t inode, int level)
(size_t)sblock.fs_bsize) == -1) {
err(1, "bread: %s", disk.d_error);
}
- snprintf(comment, sizeof(comment), "Inode 0x%08x: indirect 2", inode);
+ snprintf(comment, sizeof(comment), "Inode 0x%08jx: indirect 2",
+ (uintmax_t)inode);
#define SQUARE(a) ((a)*(a))
DBG_DUMP_IBLK(&sblock,
comment,
@@ -591,7 +598,8 @@ dump_whole_ufs2_inode(ino_t inode, int level)
err(1, "bread: %s", disk.d_error);
}
snprintf(comment, sizeof(comment),
- "Inode 0x%08x: indirect 2->%d", inode, ind3ctr);
+ "Inode 0x%08jx: indirect 2->%d",
+ (uintmax_t)inode, ind3ctr);
DBG_DUMP_IBLK(&sblock,
comment,
i2blk,
@@ -605,8 +613,8 @@ dump_whole_ufs2_inode(ino_t inode, int level)
err(1, "bread: %s", disk.d_error);
}
snprintf(comment, sizeof(comment),
- "Inode 0x%08x: indirect 2->%d->%d", inode,
- ind3ctr, ind3ctr);
+ "Inode 0x%08jx: indirect 2->%d->%d",
+ (uintmax_t)inode, ind3ctr, ind3ctr);
DBG_DUMP_IBLK(&sblock, comment, i1blk, (size_t)rb);
rb -= howmany(sblock.fs_bsize, sizeof(ufs2_daddr_t));
}
diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c
index 6bc702e..63ff153 100644
--- a/sbin/fsck/fsck.c
+++ b/sbin/fsck/fsck.c
@@ -41,8 +41,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mount.h>
#include <sys/queue.h>
#include <sys/wait.h>
-#define FSTYPENAMES
-#include <sys/disklabel.h>
+#include <sys/disk.h>
#include <sys/ioctl.h>
#include <ctype.h>
@@ -81,10 +80,21 @@ static void addentry(struct fstypelist *, const char *, const char *);
static void maketypelist(char *);
static void catopt(char **, const char *);
static void mangle(char *, int *, const char ** volatile *, int *);
-static const char *getfslab(const char *);
+static const char *getfstype(const char *);
static void usage(void) __dead2;
static int isok(struct fstab *);
+static struct {
+ const char *ptype;
+ const char *name;
+} ptype_map[] = {
+ { "ufs", "ffs" },
+ { "ffs", "ffs" },
+ { "fat", "msdosfs" },
+ { "efi", "msdosfs" },
+ { NULL, NULL },
+};
+
int
main(int argc, char *argv[])
{
@@ -203,7 +213,7 @@ main(int argc, char *argv[])
if ((fs = getfsfile(spec)) == NULL &&
(fs = getfsspec(spec)) == NULL) {
if (vfstype == NULL)
- vfstype = getfslab(spec);
+ vfstype = getfstype(spec);
if (vfstype == NULL)
errx(1, "Could not determine filesystem type");
type = vfstype;
@@ -535,41 +545,27 @@ mangle(char *opts, int *argcp, const char ** volatile *argvp, int *maxargcp)
*maxargcp = maxargc;
}
-
static const char *
-getfslab(const char *str)
+getfstype(const char *str)
{
- struct disklabel dl;
- int fd;
- char p;
- const char *vfstype;
- u_char t;
+ struct diocgattr_arg attr;
+ int fd, i;
- /* deduce the file system type from the disk label */
if ((fd = open(str, O_RDONLY)) == -1)
err(1, "cannot open `%s'", str);
- if (ioctl(fd, DIOCGDINFO, &dl) == -1) {
+ strncpy(attr.name, "PART::type", sizeof(attr.name));
+ memset(&attr.value, 0, sizeof(attr.value));
+ attr.len = sizeof(attr.value);
+ if (ioctl(fd, DIOCGATTR, &attr) == -1) {
(void) close(fd);
return(NULL);
}
-
(void) close(fd);
-
- p = str[strlen(str) - 1];
-
- if ((p - 'a') >= dl.d_npartitions)
- errx(1, "partition `%s' is not defined on disk", str);
-
- if ((t = dl.d_partitions[p - 'a'].p_fstype) >= FSMAXTYPES)
- errx(1, "partition `%s' is not of a legal vfstype",
- str);
-
- if ((vfstype = fstypenames[t]) == NULL)
- errx(1, "vfstype `%s' on partition `%s' is not supported",
- fstypenames[t], str);
-
- return vfstype;
+ for (i = 0; ptype_map[i].ptype != NULL; i++)
+ if (strstr(attr.value.str, ptype_map[i].ptype) != NULL)
+ return (ptype_map[i].name);
+ return (NULL);
}
diff --git a/sbin/fsck_ffs/Makefile b/sbin/fsck_ffs/Makefile
index 028a486..0275469 100644
--- a/sbin/fsck_ffs/Makefile
+++ b/sbin/fsck_ffs/Makefile
@@ -9,8 +9,7 @@ MLINKS= fsck_ffs.8 fsck_ufs.8 fsck_ffs.8 fsck_4.2bsd.8
SRCS= dir.c ea.c fsutil.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c \
pass4.c pass5.c setup.c suj.c utilities.c gjournal.c getmntopts.c \
globs.c
-DPADD= ${LIBUFS}
-LDADD= -lufs
+LIBADD= ufs
WARNS?= 2
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../mount
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c
index 7640f70..9203000 100644
--- a/sbin/fsck_ffs/dir.c
+++ b/sbin/fsck_ffs/dir.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/time.h>
+#include <sys/types.h>
#include <sys/sysctl.h>
#include <ufs/ufs/dinode.h>
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index 85e9548..494e503 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -59,8 +59,6 @@ struct bufarea asblk;
#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
static void badsb(int listerr, const char *s);
-static int calcsb(char *dev, int devfd, struct fs *fs);
-static struct disklabel *getdisklabel(char *s, int fd);
/*
* Read in a superblock finding an alternate if necessary.
@@ -178,7 +176,7 @@ setup(char *dev)
*/
if (readsb(1) == 0) {
skipclean = 0;
- if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0)
+ if (bflag || preen)
return(0);
if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0)
return (0);
@@ -437,7 +435,6 @@ badsb(int listerr, const char *s)
void
sblock_init(void)
{
- struct disklabel *lp;
fswritefd = -1;
fsmodified = 0;
@@ -448,89 +445,5 @@ sblock_init(void)
asblk.b_un.b_buf = Malloc(SBLOCKSIZE);
if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
errx(EEXIT, "cannot allocate space for superblock");
- if ((lp = getdisklabel(NULL, fsreadfd)))
- real_dev_bsize = dev_bsize = secsize = lp->d_secsize;
- else
- dev_bsize = secsize = DEV_BSIZE;
-}
-
-/*
- * Calculate a prototype superblock based on information in the disk label.
- * When done the cgsblock macro can be calculated and the fs_ncg field
- * can be used. Do NOT attempt to use other macros without verifying that
- * their needed information is available!
- */
-static int
-calcsb(char *dev, int devfd, struct fs *fs)
-{
- struct disklabel *lp;
- struct partition *pp;
- char *cp;
- int i, nspf;
-
- cp = strchr(dev, '\0') - 1;
- if (cp == (char *)-1 || ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))) {
- pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev);
- return (0);
- }
- lp = getdisklabel(dev, devfd);
- if (isdigit(*cp))
- pp = &lp->d_partitions[0];
- else
- pp = &lp->d_partitions[*cp - 'a'];
- if (pp->p_fstype != FS_BSDFFS) {
- pfatal("%s: NOT LABELED AS A BSD FILE SYSTEM (%s)\n",
- dev, pp->p_fstype < FSMAXTYPES ?
- fstypenames[pp->p_fstype] : "unknown");
- return (0);
- }
- if (pp->p_fsize == 0 || pp->p_frag == 0 ||
- pp->p_cpg == 0 || pp->p_size == 0) {
- pfatal("%s: %s: type %s fsize %d, frag %d, cpg %d, size %d\n",
- dev, "INCOMPLETE LABEL", fstypenames[pp->p_fstype],
- pp->p_fsize, pp->p_frag, pp->p_cpg, pp->p_size);
- return (0);
- }
- memset(fs, 0, sizeof(struct fs));
- fs->fs_fsize = pp->p_fsize;
- fs->fs_frag = pp->p_frag;
- fs->fs_size = pp->p_size;
- fs->fs_sblkno = roundup(
- howmany(lp->d_bbsize + lp->d_sbsize, fs->fs_fsize),
- fs->fs_frag);
- nspf = fs->fs_fsize / lp->d_secsize;
- for (fs->fs_fsbtodb = 0, i = nspf; i > 1; i >>= 1)
- fs->fs_fsbtodb++;
- dev_bsize = lp->d_secsize;
- if (fs->fs_magic == FS_UFS2_MAGIC) {
- fs->fs_fpg = pp->p_cpg;
- fs->fs_ncg = howmany(fs->fs_size, fs->fs_fpg);
- } else /* if (fs->fs_magic == FS_UFS1_MAGIC) */ {
- fs->fs_old_cpg = pp->p_cpg;
- fs->fs_old_cgmask = 0xffffffff;
- for (i = lp->d_ntracks; i > 1; i >>= 1)
- fs->fs_old_cgmask <<= 1;
- if (!POWEROF2(lp->d_ntracks))
- fs->fs_old_cgmask <<= 1;
- fs->fs_old_cgoffset = roundup(howmany(lp->d_nsectors, nspf),
- fs->fs_frag);
- fs->fs_fpg = (fs->fs_old_cpg * lp->d_secpercyl) / nspf;
- fs->fs_ncg = howmany(fs->fs_size / lp->d_secpercyl,
- fs->fs_old_cpg);
- }
- return (1);
-}
-
-static struct disklabel *
-getdisklabel(char *s, int fd)
-{
- static struct disklabel lab;
-
- if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
- if (s == NULL)
- return ((struct disklabel *)NULL);
- pwarn("ioctl (GCINFO): %s\n", strerror(errno));
- errx(EEXIT, "%s: can't read disk label", s);
- }
- return (&lab);
+ dev_bsize = secsize = DEV_BSIZE;
}
diff --git a/sbin/fsdb/Makefile b/sbin/fsdb/Makefile
index 21ac09f..e0a9cc3 100644
--- a/sbin/fsdb/Makefile
+++ b/sbin/fsdb/Makefile
@@ -9,8 +9,7 @@ SRCS= fsdb.c fsdbutil.c \
pass5.c setup.c utilities.c ffs_subr.c ffs_tables.c globs.c
CFLAGS+= -I${.CURDIR}/../fsck_ffs
WARNS?= 2
-LDADD= -ledit -ltermcapw
-DPADD= ${LIBEDIT} ${LIBTERMCAPW}
+LIBADD= edit
.PATH: ${.CURDIR}/../fsck_ffs ${.CURDIR}/../../sys/ufs/ffs
.include <bsd.prog.mk>
diff --git a/sbin/fsirand/fsirand.c b/sbin/fsirand/fsirand.c
index c373c5b..0fea239 100644
--- a/sbin/fsirand/fsirand.c
+++ b/sbin/fsirand/fsirand.c
@@ -36,7 +36,6 @@ static const char rcsid[] =
#endif /* not lint */
#include <sys/param.h>
-#include <sys/disklabel.h>
#include <sys/resource.h>
#include <ufs/ufs/dinode.h>
@@ -120,22 +119,12 @@ fsirand(char *device)
char sbuf[SBLOCKSIZE], sbuftmp[SBLOCKSIZE];
int i, devfd, n, cg;
u_int32_t bsize = DEV_BSIZE;
- struct disklabel label;
if ((devfd = open(device, printonly ? O_RDONLY : O_RDWR)) < 0) {
warn("can't open %s", device);
return (1);
}
- /* Get block size (usually 512) from disklabel if possible */
- if (!ignorelabel) {
- if (ioctl(devfd, DIOCGDINFO, &label) < 0)
- warn("can't read disklabel, using sector size of %d",
- bsize);
- else
- bsize = label.d_secsize;
- }
-
dp1 = NULL;
dp2 = NULL;
diff --git a/sbin/gbde/Makefile b/sbin/gbde/Makefile
index 019ee18..c33136b 100644
--- a/sbin/gbde/Makefile
+++ b/sbin/gbde/Makefile
@@ -20,8 +20,7 @@ CFLAGS+= -I${.CURDIR}/../../sys
CLEANFILES+= template.c
MAN= gbde.8
-DPADD= ${LIBMD} ${LIBUTIL} ${LIBGEOM}
-LDADD= -lmd -lutil -lgeom
+LIBADD= md util geom
template.c: template.txt
file2c 'const char template[] = {' ',0};' \
diff --git a/sbin/geom/Makefile b/sbin/geom/Makefile
index ced5842..19a5636 100644
--- a/sbin/geom/Makefile
+++ b/sbin/geom/Makefile
@@ -14,8 +14,7 @@ MAN=
WARNS?= 2
CFLAGS+=-I${.CURDIR} -I${.CURDIR}/core -DSTATIC_GEOM_CLASSES
-DPADD= ${LIBGEOM} ${LIBSBUF} ${LIBBSDXML} ${LIBUTIL}
-LDADD= -lgeom -lsbuf -lbsdxml -lutil
+LIBADD= geom util
.include <bsd.prog.mk>
diff --git a/sbin/geom/class/eli/Makefile b/sbin/geom/class/eli/Makefile
index 1195668..f8e453d 100644
--- a/sbin/geom/class/eli/Makefile
+++ b/sbin/geom/class/eli/Makefile
@@ -8,8 +8,7 @@ SRCS+= g_eli_key.c
SRCS+= pkcs5v2.c
SRCS+= sha2.c
-DPADD= ${LIBMD} ${LIBCRYPTO}
-LDADD= -lmd -lcrypto
+LIBADD= md crypto
WARNS?= 3
diff --git a/sbin/geom/class/journal/Makefile b/sbin/geom/class/journal/Makefile
index 2db8d30..0e1a38ea 100644
--- a/sbin/geom/class/journal/Makefile
+++ b/sbin/geom/class/journal/Makefile
@@ -5,8 +5,7 @@
GEOM_CLASS= journal
SRCS+= geom_journal_ufs.c
-DPADD= ${LIBMD} ${LIBUFS}
-LDADD= -lmd -lufs
+LIBADD= ufs md
CFLAGS+=-I${.CURDIR}/../../../../sys
diff --git a/sbin/geom/class/label/glabel.8 b/sbin/geom/class/label/glabel.8
index c950e26..a2f665e 100644
--- a/sbin/geom/class/label/glabel.8
+++ b/sbin/geom/class/label/glabel.8
@@ -227,11 +227,11 @@ maximum amount of debug information is printed.
.It Va kern.geom.label.*.enable : No 1
Most
.Nm LABEL
-providers implement a
+providers implement a
.Xr sysctl 8
flag and a tunable variable named in the above format. This flag
controls if the label provider will be active, tasting devices
-and creating label nodes in the
+and creating label nodes in the
.Xr devfs 5
tree. It is sometimes desirable to disable certain label types if
they conflict with other classes in complex GEOM topologies.
diff --git a/sbin/geom/class/mirror/Makefile b/sbin/geom/class/mirror/Makefile
index e38d617..ce7ee64 100644
--- a/sbin/geom/class/mirror/Makefile
+++ b/sbin/geom/class/mirror/Makefile
@@ -4,7 +4,6 @@
GEOM_CLASS= mirror
-DPADD= ${LIBMD}
-LDADD= -lmd
+LIBADD= md
.include <bsd.lib.mk>
diff --git a/sbin/geom/class/mountver/geom_mountver.c b/sbin/geom/class/mountver/geom_mountver.c
index a1ed95d..bff69c5 100644
--- a/sbin/geom/class/mountver/geom_mountver.c
+++ b/sbin/geom/class/mountver/geom_mountver.c
@@ -43,14 +43,14 @@ struct g_command class_commands[] = {
{
G_OPT_SENTINEL
},
- "[-v] dev ..."
+ "[-v] prov ..."
},
{ "destroy", G_FLAG_VERBOSE, NULL,
{
{ 'f', "force", NULL, G_TYPE_BOOL },
G_OPT_SENTINEL
},
- "[-fv] prov ..."
+ "[-fv] name"
},
G_CMD_SENTINEL
};
diff --git a/sbin/geom/class/mountver/gmountver.8 b/sbin/geom/class/mountver/gmountver.8
index c9a9c0a..4c27a65 100644
--- a/sbin/geom/class/mountver/gmountver.8
+++ b/sbin/geom/class/mountver/gmountver.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 14, 2010
+.Dd May 18, 2015
.Dt GMOUNTVER 8
.Os
.Sh NAME
@@ -35,11 +35,11 @@
.Nm
.Cm create
.Op Fl v
-.Ar dev ...
+.Ar prov ...
.Nm
.Cm destroy
.Op Fl fv
-.Ar prov ...
+.Ar name
.Nm
.Cm list
.Nm
@@ -66,8 +66,11 @@ The first argument to
indicates an action to be performed:
.Bl -tag -width ".Cm destroy"
.It Cm create
-Cache the given devices with specified
-.Ar name .
+Enable mount verification for the given provider.
+If the operation succeeds, a new GEOM provider will be created using the
+given provider's name with a
+.Ql .mountver
+suffix.
The kernel module
.Pa geom_mountver.ko
will be loaded if it is not loaded already.
@@ -110,7 +113,7 @@ GEOM class.
This can be set to a number between 0 and 3 inclusive.
If set to 0 minimal debug information is printed, and if set to 3 the
maximum amount of debug information is printed.
-.It Va kern.geom.mountver.check.check_ident : No 1
+.It Va kern.geom.mountver.check_ident : No 1
This can be set to 0 or 1.
If set to 0,
.Nm
diff --git a/sbin/geom/class/part/Makefile b/sbin/geom/class/part/Makefile
index 341cd42..4b67de4 100644
--- a/sbin/geom/class/part/Makefile
+++ b/sbin/geom/class/part/Makefile
@@ -4,7 +4,6 @@
GEOM_CLASS= part
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+LIBADD= util
.include <bsd.lib.mk>
diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c
index ee4b2a9..133e8f8 100644
--- a/sbin/geom/class/part/geom_part.c
+++ b/sbin/geom/class/part/geom_part.c
@@ -207,15 +207,20 @@ find_class(struct gmesh *mesh, const char *name)
static struct ggeom *
find_geom(struct gclass *classp, const char *name)
{
- struct ggeom *gp;
+ struct ggeom *gp, *wgp;
if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
name += sizeof(_PATH_DEV) - 1;
+ wgp = NULL;
LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
- if (strcmp(gp->lg_name, name) == 0)
+ if (strcmp(gp->lg_name, name) != 0)
+ continue;
+ if (find_geomcfg(gp, "wither") == NULL)
return (gp);
+ else
+ wgp = gp;
}
- return (NULL);
+ return (wgp);
}
static const char *
@@ -561,7 +566,7 @@ gpart_autofill(struct gctl_req *req)
s = find_provcfg(pp, "end");
first = (off_t)strtoimax(s, NULL, 0) + 1;
- if (first > a_first)
+ if (first + offset > a_first)
a_first = ALIGNUP(first + offset, alignment);
}
if (a_first <= last) {
@@ -609,6 +614,8 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers)
off_t length, secsz;
int idx, wblocks, wname, wmax;
+ if (find_geomcfg(gp, "wither"))
+ return;
scheme = find_geomcfg(gp, "scheme");
if (scheme == NULL)
errx(EXIT_FAILURE, "Scheme not found for geom %s", gp->lg_name);
diff --git a/sbin/geom/class/part/gpart.8 b/sbin/geom/class/part/gpart.8
index e8c4dab..8e8f858 100644
--- a/sbin/geom/class/part/gpart.8
+++ b/sbin/geom/class/part/gpart.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 12, 2014
+.Dd May 5, 2015
.Dt GPART 8
.Os
.Sh NAME
@@ -659,9 +659,17 @@ Another symbolic names that can be used with
.Cm gpart
utility are:
.Bl -tag -width ".Cm dragonfly-disklabel64"
+.It Cm apple-core-storage
+An Apple Mac OS X partition used by logical volume manager known as
+Core Storage.
+The scheme-specific type is
+.Qq Li "!53746f72-6167-11aa-aa11-00306543ecac"
+for GPT.
.It Cm apple-hfs
An Apple Mac OS X partition that contains a HFS or HFS+ filesystem.
The scheme-specific types are
+.Qq Li "!175"
+for MBR,
.Qq Li "!Apple_HFS"
for APM and
.Qq Li "!48465300-0000-11aa-aa11-00306543ecac"
@@ -690,6 +698,8 @@ for GPT.
.It Cm apple-ufs
An Apple Mac OS X partition that contains a UFS filesystem.
The scheme-specific types are
+.Qq Li "!168"
+for MBR,
.Qq Li "!Apple_UNIX_SVR2"
for APM and
.Qq Li "!55465300-0000-11aa-aa11-00306543ecac"
diff --git a/sbin/geom/class/raid/Makefile b/sbin/geom/class/raid/Makefile
index 743f690..07d7140 100644
--- a/sbin/geom/class/raid/Makefile
+++ b/sbin/geom/class/raid/Makefile
@@ -4,7 +4,6 @@
GEOM_CLASS= raid
-DPADD= ${LIBMD}
-LDADD= -lmd
+LIBADD= md
.include <bsd.lib.mk>
diff --git a/sbin/geom/class/raid3/Makefile b/sbin/geom/class/raid3/Makefile
index d2405d4..74e1245 100644
--- a/sbin/geom/class/raid3/Makefile
+++ b/sbin/geom/class/raid3/Makefile
@@ -4,7 +4,6 @@
GEOM_CLASS= raid3
-DPADD= ${LIBMD}
-LDADD= -lmd
+LIBADD= md
.include <bsd.lib.mk>
diff --git a/sbin/geom/core/Makefile b/sbin/geom/core/Makefile
index 64edc79..0636d03 100644
--- a/sbin/geom/core/Makefile
+++ b/sbin/geom/core/Makefile
@@ -11,7 +11,6 @@ NO_SHARED=NO
CFLAGS+= -DGEOM_CLASS_DIR=\"${GEOM_CLASS_DIR}\"
CFLAGS+= -I${.CURDIR}/../../../sys -I${.CURDIR} -I${.CURDIR}/..
-DPADD= ${LIBGEOM} ${LIBSBUF} ${LIBBSDXML} ${LIBUTIL}
-LDADD= -lgeom -lsbuf -lbsdxml -lutil
+LIBADD= geom util
.include <bsd.prog.mk>
diff --git a/sbin/ggate/ggatec/Makefile b/sbin/ggate/ggatec/Makefile
index 4d8917f..e228fea 100644
--- a/sbin/ggate/ggatec/Makefile
+++ b/sbin/ggate/ggatec/Makefile
@@ -10,7 +10,6 @@ CFLAGS+= -DMAX_SEND_SIZE=32768
CFLAGS+= -DLIBGEOM
CFLAGS+= -I${.CURDIR}/../shared
-DPADD= ${LIBGEOM} ${LIBSBUF} ${LIBBSDXML} ${LIBUTIL} ${LIBPTHREAD}
-LDADD= -lgeom -lsbuf -lbsdxml -lutil -lpthread
+LIBADD= geom util pthread
.include <bsd.prog.mk>
diff --git a/sbin/ggate/ggatec/ggatec.8 b/sbin/ggate/ggatec/ggatec.8
index 72ae4c5..8545baf 100644
--- a/sbin/ggate/ggatec/ggatec.8
+++ b/sbin/ggate/ggatec/ggatec.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 26, 2004
+.Dd April 2, 2015
.Dt GGATEC 8
.Os
.Sh NAME
@@ -67,29 +67,29 @@
.Sh DESCRIPTION
The
.Nm
-utility is a network client for GEOM Gate class.
-It is responsible for creation of
+utility is a network client for the GEOM Gate class.
+It is responsible for the creation of
.Nm ggate
-devices and forwarding I/O requests between
+devices and forwarding I/O requests between the
.Nm geom_gate.ko
-kernel module and
+kernel module and the
.Xr ggated 8
network daemon.
Available commands:
.Bl -tag -width ".Cm destroy"
.It Cm create
-Connect to given
+Connect to a
.Xr ggated 8
-daemon and create a
+daemon on the specified host and create a
.Nm ggate
-provider related to the given remote file or device.
+provider for the specified remote file or device.
.It Cm rescue
-If
+Create a new connection after the
.Nm
-process died/has been killed, you can save situation with this
-command, which creates new connection to the
+process has died or been killed.
+The new connection to the
.Xr ggated 8
-daemon and will handle pending and future requests.
+daemon handles pending and future requests.
.It Cm destroy
Destroy the given
.Nm ggate
@@ -139,12 +139,11 @@ provider.
If not specified, it is taken from device, or set to 512 bytes for files.
.It Fl t Ar timeout
Number of seconds to wait before an I/O request will be canceled.
-0 means no timeout.
-Default is 0.
+Default is 0, which means no timeout.
.It Fl u Ar unit
Unit number to use.
.It Fl v
-Do not fork, run in foreground and print debug informations on standard
+Do not fork, run in foreground and print debug information on standard
output.
.It Ar host
Remote host to connect to.
@@ -159,7 +158,7 @@ should be called with the
.Fl v
option.
.Sh EXAMPLES
-Make use of CD-ROM device from remote host.
+Use a CD-ROM device on a remote host.
.Bd -literal -offset indent
server# cat /etc/gg.exports
client RO /dev/acd0
diff --git a/sbin/ggate/ggated/Makefile b/sbin/ggate/ggated/Makefile
index 4e7708e..af5c9bd 100644
--- a/sbin/ggate/ggated/Makefile
+++ b/sbin/ggate/ggated/Makefile
@@ -6,8 +6,7 @@ PROG= ggated
MAN= ggated.8
SRCS= ggated.c ggate.c
-DPADD= ${LIBPTHREAD}
-LDADD= -lpthread
+LIBADD= pthread
CFLAGS+= -I${.CURDIR}/../shared
diff --git a/sbin/ggate/ggatel/Makefile b/sbin/ggate/ggatel/Makefile
index 604a754..be88bd4 100644
--- a/sbin/ggate/ggatel/Makefile
+++ b/sbin/ggate/ggatel/Makefile
@@ -9,7 +9,6 @@ SRCS= ggatel.c ggate.c
CFLAGS+= -DLIBGEOM
CFLAGS+= -I${.CURDIR}/../shared
-DPADD= ${LIBGEOM} ${LIBSBUF} ${LIBBSDXML} ${LIBUTIL}
-LDADD= -lgeom -lsbuf -lbsdxml -lutil
+LIBADD= geom util
.include <bsd.prog.mk>
diff --git a/sbin/ggate/ggatel/ggatel.8 b/sbin/ggate/ggatel/ggatel.8
index 1463426..37e11cd 100644
--- a/sbin/ggate/ggatel/ggatel.8
+++ b/sbin/ggate/ggatel/ggatel.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 2, 2011
+.Dd April 9, 2015
.Dt GGATEL 8
.Os
.Sh NAME
@@ -40,12 +40,6 @@
.Op Fl u Ar unit
.Ar path
.Nm
-.Cm attach
-.Op Fl v
-.Op Fl o Cm ro | wo | rw
-.Fl u Ar unit
-.Ar path
-.Nm
.Cm destroy
.Op Fl f
.Fl u Ar unit
@@ -53,6 +47,12 @@
.Cm list
.Op Fl v
.Op Fl u Ar unit
+.Nm
+.Cm rescue
+.Op Fl v
+.Op Fl o Cm ro | wo | rw
+.Fl u Ar unit
+.Ar path
.Sh DESCRIPTION
The
.Nm
@@ -70,10 +70,6 @@ Available commands:
Create a
.Nm ggate
provider related to the given regular file or device.
-.It Cm attach
-Attach a worker process to an existing
-.Nm ggate
-provider.
.It Cm destroy
Destroy the given
.Nm ggate
@@ -82,6 +78,12 @@ provider.
List
.Nm ggate
providers.
+.It Cm rescue
+Take over a previously created provider and handle pending and future
+requests. This is useful if the initial
+.Nm
+process died. To prevent data loss, the given path must lead to the
+regular file or device that was used to create the provider.
.El
.Pp
Available options:
@@ -111,7 +113,7 @@ Default is 30.
.It Fl u Ar unit
Unit number to use.
.It Fl v
-Do not fork, run in foreground and print debug informations on standard
+Do not fork, run in foreground and print debug information on standard
output.
.It Ar path
Path to a regular file or device.
diff --git a/sbin/growfs/Makefile b/sbin/growfs/Makefile
index 025771f..e7017a7 100644
--- a/sbin/growfs/Makefile
+++ b/sbin/growfs/Makefile
@@ -4,8 +4,6 @@
# $FreeBSD$
#
-#GFSDBG=
-
.include <src.opts.mk>
.PATH: ${.CURDIR}/../mount
@@ -16,14 +14,15 @@ MAN= growfs.8
CFLAGS+=-I${.CURDIR}/../mount
.if defined(GFSDBG)
-SRCS+= debug.c
+SRCS+= debug.c
+CFLAGS+= -DFS_DEBUG
+NO_WCAST_ALIGN= yes
.endif
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+LIBADD= util
.if ${MK_TESTS} != "no"
SUBDIR+= tests
.endif
-.include <bsd.prog.mk>
+.include <bsd.prog.mk>
diff --git a/sbin/growfs/growfs.8 b/sbin/growfs/growfs.8
index 0dab89f..42dc530 100644
--- a/sbin/growfs/growfs.8
+++ b/sbin/growfs/growfs.8
@@ -37,7 +37,7 @@
.\" $TSHeader: src/sbin/growfs/growfs.8,v 1.3 2000/12/12 19:31:00 tomsoft Exp $
.\" $FreeBSD$
.\"
-.Dd November 26, 2013
+.Dd November 20, 2014
.Dt GROWFS 8
.Os
.Sh NAME
@@ -96,12 +96,14 @@ This value defaults to the size of the raw partition specified in
will enlarge the file system to the size of the entire partition).
.El
.Sh EXAMPLES
-.Dl growfs -s 2G /dev/ada0p1
+Expand root file system to fill up available space:
+.Dl growfs /
.Pp
-will enlarge
+Resize
.Pa /dev/ada0p1
-up to 2GB if there is enough space in
-.Pa /dev/ada0p1 .
+partition to 2GB and expand the file system:
+.Dl gpart resize -i 1 -s 2G ada0
+.Dl growfs -s 2G /dev/ada0p1
.Sh SEE ALSO
.Xr dumpfs 8 ,
.Xr ffsinfo 8 ,
@@ -115,7 +117,7 @@ The
.Nm
utility first appeared in
.Fx 4.4 .
-The ability to resize mounted filesystems was added in
+The ability to resize mounted file systems was added in
.Fx 10.0 .
.Sh AUTHORS
.An Christoph Herrmann Aq Mt chm@FreeBSD.org
diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c
index 96897e2..7b85b25 100644
--- a/sbin/growfs/growfs.c
+++ b/sbin/growfs/growfs.c
@@ -161,7 +161,7 @@ growfs(int fsi, int fso, unsigned int Nflag)
#ifdef FS_DEBUG
{
struct csum *dbg_csp;
- int dbg_csc;
+ u_int32_t dbg_csc;
char dbg_line[80];
dbg_csp = fscs;
@@ -242,7 +242,7 @@ growfs(int fsi, int fso, unsigned int Nflag)
#ifdef FS_DEBUG
{
struct csum *dbg_csp;
- int dbg_csc;
+ u_int32_t dbg_csc;
char dbg_line[80];
dbg_csp = fscs;
diff --git a/sbin/gvinum/Makefile b/sbin/gvinum/Makefile
index 1b5f948..0e56920 100644
--- a/sbin/gvinum/Makefile
+++ b/sbin/gvinum/Makefile
@@ -7,8 +7,7 @@ MAN= gvinum.8
WARNS?= 2
CFLAGS+= -I${.CURDIR}/../../sys -I${DESTDIR}/${INCLUDEDIR}/edit
-DPADD= ${LIBEDIT} ${LIBTERMCAPW} ${LIBDEVSTAT} ${LIBKVM} ${LIBGEOM}
-LDADD= -ledit -ltermcapw -ldevstat -lkvm -lgeom
+LIBADD= edit geom
.PATH: ${.CURDIR}/../../sys/geom/vinum
diff --git a/sbin/gvinum/Makefile.depend b/sbin/gvinum/Makefile.depend
index 95ff20c..4e1e335 100644
--- a/sbin/gvinum/Makefile.depend
+++ b/sbin/gvinum/Makefile.depend
@@ -10,12 +10,10 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libdevstat \
lib/libedit \
lib/libedit/edit/readline \
lib/libexpat \
lib/libgeom \
- lib/libkvm \
lib/libsbuf \
lib/ncurses/ncursesw \
diff --git a/sbin/hastctl/Makefile b/sbin/hastctl/Makefile
index 89b972e..41d443d 100644
--- a/sbin/hastctl/Makefile
+++ b/sbin/hastctl/Makefile
@@ -32,11 +32,9 @@ CFLAGS+=-DINET6
CFLAGS+=-DYY_NO_UNPUT
CFLAGS+=-DYY_NO_INPUT
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+LIBADD= util
.if ${MK_OPENSSL} != "no"
-DPADD+= ${LIBCRYPTO}
-LDADD+= -lcrypto
+LIBADD+= crypto
CFLAGS+=-DHAVE_CRYPTO
.endif
diff --git a/sbin/hastctl/Makefile.depend b/sbin/hastctl/Makefile.depend
index 55bb66c..dfbfa37 100644
--- a/sbin/hastctl/Makefile.depend
+++ b/sbin/hastctl/Makefile.depend
@@ -13,6 +13,7 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libutil \
secure/lib/libcrypto \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/sbin/hastd/Makefile b/sbin/hastd/Makefile
index 3604b5b..e3fed8d 100644
--- a/sbin/hastd/Makefile
+++ b/sbin/hastd/Makefile
@@ -30,11 +30,9 @@ CFLAGS+=-DINET
CFLAGS+=-DINET6
.endif
-DPADD= ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF} ${LIBPTHREAD} ${LIBUTIL}
-LDADD= -lgeom -lbsdxml -lsbuf -lpthread -lutil
+LIBADD= geom pthread util
.if ${MK_OPENSSL} != "no"
-DPADD+= ${LIBCRYPTO}
-LDADD+= -lcrypto
+LIBADD+= crypto
CFLAGS+=-DHAVE_CRYPTO
.endif
diff --git a/sbin/hastd/Makefile.depend b/sbin/hastd/Makefile.depend
index 8fc25fa..6e89123 100644
--- a/sbin/hastd/Makefile.depend
+++ b/sbin/hastd/Makefile.depend
@@ -17,6 +17,7 @@ DIRDEPS = \
lib/libthr \
lib/libutil \
secure/lib/libcrypto \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/sbin/hastd/hast.conf.5 b/sbin/hastd/hast.conf.5
index c7e2e33..9267e36 100644
--- a/sbin/hastd/hast.conf.5
+++ b/sbin/hastd/hast.conf.5
@@ -270,39 +270,33 @@ program is executed with:
.It Ic "<path> role <resource> <oldrole> <newrole>"
.Pp
Executed on both primary and secondary nodes when resource role is changed.
-.Pp
.It Ic "<path> connect <resource>"
.Pp
Executed on both primary and secondary nodes when connection for the given
resource between the nodes is established.
-.Pp
.It Ic "<path> disconnect <resource>"
.Pp
Executed on both primary and secondary nodes when connection for the given
resource between the nodes is lost.
-.Pp
.It Ic "<path> syncstart <resource>"
.Pp
Executed on primary node when synchronization process of secondary node is
started.
-.Pp
.It Ic "<path> syncdone <resource>"
.Pp
Executed on primary node when synchronization process of secondary node is
completed successfully.
-.Pp
.It Ic "<path> syncintr <resource>"
.Pp
Executed on primary node when synchronization process of secondary node is
interrupted, most likely due to secondary node outage or connection failure
between the nodes.
-.Pp
.It Ic "<path> split-brain <resource>"
.Pp
Executed on both primary and secondary nodes when split-brain condition is
detected.
-.Pp
.El
+.Pp
The
.Aq path
argument should contain full path to executable program.
@@ -330,7 +324,6 @@ It can be one of:
.Ar init ,
.Ar secondary ,
.Ar primary .
-.Pp
.It Ic metaflush on | off
.Pp
When set to
@@ -349,7 +342,6 @@ will disable
automatically.
The default value is
.Va on .
-.Pp
.It Ic name Aq name
.Pp
GEOM provider name that will appear as
diff --git a/sbin/ifconfig/Makefile b/sbin/ifconfig/Makefile
index 8aba6b4..ac7faf9 100644
--- a/sbin/ifconfig/Makefile
+++ b/sbin/ifconfig/Makefile
@@ -35,12 +35,10 @@ SRCS+= ifgre.c # GRE keys etc
SRCS+= ifgif.c # GIF reversed header workaround
SRCS+= sfp.c # SFP/SFP+ information
-DPADD+= ${LIBM}
-LDADD+= -lm
+LIBADD+= m
SRCS+= ifieee80211.c regdomain.c # SIOC[GS]IEEE80211 support
-DPADD+= ${LIBBSDXML} ${LIBSBUF}
-LDADD+= -lbsdxml -lsbuf
+LIBADD+= bsdxml sbuf
SRCS+= carp.c # SIOC[GS]VH support
SRCS+= ifgroup.c # ...
@@ -59,8 +57,7 @@ CFLAGS+= -DINET
.endif
.if ${MK_JAIL} != "no" && !defined(RELEASE_CRUNCH) && !defined(RESCUE)
CFLAGS+= -DJAIL
-DPADD+= ${LIBJAIL}
-LDADD+= -ljail
+LIBADD+= jail
.endif
MAN= ifconfig.8
@@ -68,4 +65,8 @@ MAN= ifconfig.8
CFLAGS+= -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wnested-externs
WARNS?= 2
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.prog.mk>
diff --git a/sbin/ifconfig/af_inet.c b/sbin/ifconfig/af_inet.c
index c733373..eff1ce5 100644
--- a/sbin/ifconfig/af_inet.c
+++ b/sbin/ifconfig/af_inet.c
@@ -32,7 +32,7 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
@@ -46,7 +46,6 @@ static const char rcsid[] =
#include <ifaddrs.h>
#include <netinet/in.h>
-#include <net/if_var.h> /* for struct ifaddr */
#include <netinet/in_var.h>
#include <arpa/inet.h>
#include <netdb.h>
@@ -101,7 +100,6 @@ static struct sockaddr_in *sintab[] = {
static void
in_getaddr(const char *s, int which)
{
-#define MIN(a,b) ((a)<(b)?(a):(b))
struct sockaddr_in *sin = sintab[which];
struct hostent *hp;
struct netent *np;
@@ -142,7 +140,6 @@ in_getaddr(const char *s, int which)
sin->sin_addr = inet_makeaddr(np->n_net, INADDR_ANY);
else
errx(1, "%s: bad value", s);
-#undef MIN
}
static void
diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c
index 0f8688a..6dd8622 100644
--- a/sbin/ifconfig/af_inet6.c
+++ b/sbin/ifconfig/af_inet6.c
@@ -48,7 +48,6 @@ static const char rcsid[] =
#include <arpa/inet.h>
#include <netinet/in.h>
-#include <net/if_var.h> /* for struct ifaddr */
#include <netinet/in_var.h>
#include <arpa/inet.h>
#include <netdb.h>
@@ -58,8 +57,8 @@ static const char rcsid[] =
#include "ifconfig.h"
static struct in6_ifreq in6_ridreq;
-static struct in6_aliasreq in6_addreq =
- { .ifra_flags = 0,
+static struct in6_aliasreq in6_addreq =
+ { .ifra_flags = 0,
.ifra_lifetime = { 0, 0, ND6_INFINITE_LIFETIME, ND6_INFINITE_LIFETIME } };
static int ip6lifetime;
@@ -265,14 +264,16 @@ in6_status(int s __unused, const struct ifaddrs *ifa)
printf("pltime ");
if (lifetime.ia6t_preferred) {
printf("%s ", lifetime.ia6t_preferred < now.tv_sec
- ? "0" : sec2str(lifetime.ia6t_preferred - now.tv_sec));
+ ? "0" :
+ sec2str(lifetime.ia6t_preferred - now.tv_sec));
} else
printf("infty ");
printf("vltime ");
if (lifetime.ia6t_expire) {
printf("%s ", lifetime.ia6t_expire < now.tv_sec
- ? "0" : sec2str(lifetime.ia6t_expire - now.tv_sec));
+ ? "0" :
+ sec2str(lifetime.ia6t_expire - now.tv_sec));
} else
printf("infty ");
}
@@ -347,25 +348,25 @@ in6_getaddr(const char *s, int which)
static int
prefix(void *val, int size)
{
- u_char *name = (u_char *)val;
- int byte, bit, plen = 0;
+ u_char *name = (u_char *)val;
+ int byte, bit, plen = 0;
- for (byte = 0; byte < size; byte++, plen += 8)
- if (name[byte] != 0xff)
- break;
+ for (byte = 0; byte < size; byte++, plen += 8)
+ if (name[byte] != 0xff)
+ break;
if (byte == size)
return (plen);
for (bit = 7; bit != 0; bit--, plen++)
- if (!(name[byte] & (1 << bit)))
- break;
- for (; bit != 0; bit--)
- if (name[byte] & (1 << bit))
- return(0);
- byte++;
- for (; byte < size; byte++)
- if (name[byte])
- return(0);
- return (plen);
+ if (!(name[byte] & (1 << bit)))
+ break;
+ for (; bit != 0; bit--)
+ if (name[byte] & (1 << bit))
+ return(0);
+ byte++;
+ for (; byte < size; byte++)
+ if (name[byte])
+ return(0);
+ return (plen);
}
static char *
@@ -483,6 +484,8 @@ static struct cmd inet6_cmds[] = {
DEF_CMD("-auto_linklocal",-ND6_IFF_AUTO_LINKLOCAL,setnd6flags),
DEF_CMD("no_prefer_iface",ND6_IFF_NO_PREFER_IFACE,setnd6flags),
DEF_CMD("-no_prefer_iface",-ND6_IFF_NO_PREFER_IFACE,setnd6flags),
+ DEF_CMD("no_dad", ND6_IFF_NO_DAD, setnd6flags),
+ DEF_CMD("-no_dad", -ND6_IFF_NO_DAD, setnd6flags),
DEF_CMD_ARG("pltime", setip6pltime),
DEF_CMD_ARG("vltime", setip6vltime),
DEF_CMD("eui64", 0, setip6eui64),
@@ -509,7 +512,11 @@ in6_Lopt_cb(const char *optarg __unused)
{
ip6lifetime++; /* print IPv6 address lifetime */
}
-static struct option in6_Lopt = { .opt = "L", .opt_usage = "[-L]", .cb = in6_Lopt_cb };
+static struct option in6_Lopt = {
+ .opt = "L",
+ .opt_usage = "[-L]",
+ .cb = in6_Lopt_cb
+};
static __constructor void
inet6_ctor(void)
diff --git a/sbin/ifconfig/af_nd6.c b/sbin/ifconfig/af_nd6.c
index b3db0a8..9a1be79 100644
--- a/sbin/ifconfig/af_nd6.c
+++ b/sbin/ifconfig/af_nd6.c
@@ -46,7 +46,6 @@ static const char rcsid[] =
#include <arpa/inet.h>
#include <netinet/in.h>
-#include <net/if_var.h>
#include <netinet/in_var.h>
#include <arpa/inet.h>
#include <netdb.h>
@@ -58,7 +57,8 @@ static const char rcsid[] =
#define MAX_SYSCTL_TRY 5
#define ND6BITS "\020\001PERFORMNUD\002ACCEPT_RTADV\003PREFER_SOURCE" \
"\004IFDISABLED\005DONT_SET_IFROUTE\006AUTO_LINKLOCAL" \
- "\007NO_RADR\010NO_PREFER_IFACE\020DEFAULTIF"
+ "\007NO_RADR\010NO_PREFER_IFACE\011IGNORELOOP\012NO_DAD" \
+ "\020DEFAULTIF"
static int isnd6defif(int);
void setnd6flags(const char *, int, int, const struct afswtch *);
diff --git a/sbin/ifconfig/carp.c b/sbin/ifconfig/carp.c
index 2c58fcb..adff153 100644
--- a/sbin/ifconfig/carp.c
+++ b/sbin/ifconfig/carp.c
@@ -36,7 +36,6 @@
#include <unistd.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <netinet/ip_carp.h>
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index 064a62d..56b5c14 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -28,7 +28,7 @@
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
.\" $FreeBSD$
.\"
-.Dd October 20, 2014
+.Dd May 15, 2015
.Dt IFCONFIG 8
.Os
.Sh NAME
@@ -316,6 +316,14 @@ using the
kernel configuration option, or the
.Va net.fibs
tunable.
+.It Cm tunnelfib Ar fib_number
+Specify tunnel FIB.
+A FIB
+.Ar fib_number
+is assigned to all packets encapsulated by tunnel interface, e.g.,
+.Xr gif 4
+and
+.Xr gre 4 .
.It Cm maclabel Ar label
If Mandatory Access Control support is enabled in the kernel,
set the MAC label to
@@ -687,6 +695,11 @@ policy table, configurable with
.It Cm -no_prefer_iface
Clear a flag
.Cm no_prefer_iface .
+.It Cm no_dad
+Set a flag to disable Duplicate Address Detection.
+.It Cm -no_dad
+Clear a flag
+.Cm no_dad .
.El
.Pp
The following parameters are specific for IPv6 addresses.
@@ -2415,6 +2428,14 @@ This is for backward compatibility with
.It Cm -accept_rev_ethip_ver
Clear a flag
.Cm accept_rev_ethip_ver .
+.It Cm ignore_source
+Set a flag to accept encapsulated packets destined to this host
+independently from source address.
+This may be useful for hosts, that receive encapsulated packets
+from the load balancers.
+.It Cm -ignore_source
+Clear a flag
+.Cm ignore_source .
.It Cm send_rev_ethip_ver
Set a flag to send EtherIP packets with reversed version
field intentionally.
@@ -2544,33 +2565,33 @@ The following parameters are used to configure
.Xr vxlan 4
interfaces.
.Bl -tag -width indent
-.It Cm vni Ar identifier
+.It Cm vxlanid Ar identifier
This value is a 24-bit VXLAN Network Identifier (VNI) that identifies the
virtual network segment membership of the interface.
-.It Cm local Ar address
+.It Cm vxlanlocal Ar address
The source address used in the encapsulating IPv4/IPv6 header.
The address should already be assigned to an existing interface.
When the interface is configured in unicast mode, the listening socket
is bound to this address.
-.It Cm remote Ar address
+.It Cm vxlanremote Ar address
The interface can be configured in a unicast, or point-to-point, mode
to create a tunnel between two hosts.
This is the IP address of the remote end of the tunnel.
-.It Cm group Ar address
+.It Cm vxlangroup Ar address
The interface can be configured in a multicast mode
to create a virtual network of hosts.
This is the IP multicast group address the interface will join.
-.It Cm localport Ar port
+.It Cm vxlanlocalport Ar port
The port number the interface will listen on.
The default port number is 4789.
-.It Cm remoteport Ar port
+.It Cm vxlanremoteport Ar port
The destination port number used in the encapsulating IPv4/IPv6 header.
The remote host should be listening on this port.
The default port number is 4789.
Note some other implementations, such as Linux,
do not default to the IANA assigned port,
but instead listen on port 8472.
-.It Cm portrange Ar low high
+.It Cm vxlanportrange Ar low high
The range of source ports used in the encapsulating IPv4/IPv6 header.
The port selected within the range is based on a hash of the inner frame.
A range is useful to provide entropy within the outer IP header
@@ -2581,32 +2602,32 @@ variables
.Va net.inet.ip.portrange.first
and
.Va net.inet.ip.portrange.last
-.It Cm timeout Ar timeout
+.It Cm vxlantimeout Ar timeout
The maximum time, in seconds, before an entry in the forwarding table
is pruned.
The default is 1200 seconds (20 minutes).
-.It Cm maxaddr Ar max
+.It Cm vxlanmaxaddr Ar max
The maximum number of entries in the forwarding table.
The default is 2000.
.It Cm vxlandev Ar dev
When the interface is configured in multicast mode, the
.Cm dev
interface is used to transmit IP multicast packets.
-.It Cm ttl Ar ttl
+.It Cm vxlanttl Ar ttl
The TTL used in the encapsulating IPv4/IPv6 header.
The default is 64.
-.It Cm learn
+.It Cm vxlanlearn
The source IP address and inner source Ethernet MAC address of
received packets are used to dynamically populate the forwarding table.
When in multicast mode, an entry in the forwarding table allows the
interface to send the frame directly to the remote host instead of
broadcasting the frame to the multicast group.
This is the default.
-.It Fl learn
+.It Fl vxlanlearn
The forwarding table is not populated by recevied packets.
-.It Cm flush
+.It Cm vxlanflush
Delete all dynamically-learned addresses from the forwarding table.
-.It Cm flushall
+.It Cm vxlanflushall
Delete all addresses, including static addresses, from the forwarding table.
.El
.Pp
@@ -2819,9 +2840,9 @@ tried to alter an interface's configuration.
.Xr devd.conf 5 ,
.\" .Xr eon 5 ,
.Xr devd 8 ,
+.Xr jail 8 ,
.Xr rc 8 ,
.Xr routed 8 ,
-.Xr jail 8 ,
.Xr sysctl 8
.Sh HISTORY
The
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 61fd155..4a79992 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -47,10 +47,10 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/module.h>
#include <sys/linker.h>
+#include <sys/queue.h>
#include <net/ethernet.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/route.h>
@@ -110,6 +110,15 @@ static void af_other_status(int);
static struct option *opts = NULL;
+struct ifa_order_elt {
+ int if_order;
+ int af_orders[255];
+ struct ifaddrs *ifa;
+ TAILQ_ENTRY(ifa_order_elt) link;
+};
+
+TAILQ_HEAD(ifa_queue, ifa_order_elt);
+
void
opt_register(struct option *p)
{
@@ -141,16 +150,165 @@ usage(void)
exit(1);
}
+#define ORDERS_SIZE(x) sizeof(x) / sizeof(x[0])
+
+static int
+calcorders(struct ifaddrs *ifa, struct ifa_queue *q)
+{
+ struct ifaddrs *prev;
+ struct ifa_order_elt *cur;
+ unsigned int ord, af, ifa_ord;
+
+ prev = NULL;
+ cur = NULL;
+ ord = 0;
+ ifa_ord = 0;
+
+ while (ifa != NULL) {
+ if (prev == NULL ||
+ strcmp(ifa->ifa_name, prev->ifa_name) != 0) {
+ cur = calloc(1, sizeof(*cur));
+
+ if (cur == NULL)
+ return (-1);
+
+ TAILQ_INSERT_TAIL(q, cur, link);
+ cur->if_order = ifa_ord ++;
+ cur->ifa = ifa;
+ ord = 0;
+ }
+
+ if (ifa->ifa_addr) {
+ af = ifa->ifa_addr->sa_family;
+
+ if (af < ORDERS_SIZE(cur->af_orders) &&
+ cur->af_orders[af] == 0)
+ cur->af_orders[af] = ++ord;
+ }
+ prev = ifa;
+ ifa = ifa->ifa_next;
+ }
+
+ return (0);
+}
+
+static int
+cmpifaddrs(struct ifaddrs *a, struct ifaddrs *b, struct ifa_queue *q)
+{
+ struct ifa_order_elt *cur, *e1, *e2;
+ unsigned int af1, af2;
+ int ret;
+
+ e1 = e2 = NULL;
+
+ ret = strcmp(a->ifa_name, b->ifa_name);
+ if (ret != 0) {
+ TAILQ_FOREACH(cur, q, link) {
+ if (e1 && e2)
+ break;
+
+ if (strcmp(cur->ifa->ifa_name, a->ifa_name) == 0)
+ e1 = cur;
+ else if (strcmp(cur->ifa->ifa_name, b->ifa_name) == 0)
+ e2 = cur;
+ }
+
+ if (!e1 || !e2)
+ return (0);
+ else
+ return (e1->if_order - e2->if_order);
+
+ } else if (a->ifa_addr != NULL && b->ifa_addr != NULL) {
+ TAILQ_FOREACH(cur, q, link) {
+ if (strcmp(cur->ifa->ifa_name, a->ifa_name) == 0) {
+ e1 = cur;
+ break;
+ }
+ }
+
+ if (!e1)
+ return (0);
+
+ af1 = a->ifa_addr->sa_family;
+ af2 = b->ifa_addr->sa_family;
+
+ if (af1 < ORDERS_SIZE(e1->af_orders) &&
+ af2 < ORDERS_SIZE(e1->af_orders))
+ return (e1->af_orders[af1] - e1->af_orders[af2]);
+ }
+
+ return (0);
+}
+
+#undef ORDERS_SIZE
+
+static struct ifaddrs *
+sortifaddrs(struct ifaddrs *list,
+ int (*compare)(struct ifaddrs *, struct ifaddrs *, struct ifa_queue *),
+ struct ifa_queue *q)
+{
+ struct ifaddrs *right, *temp, *last, *result, *next, *tail;
+
+ right = list;
+ temp = list;
+ last = list;
+ result = NULL;
+ next = NULL;
+ tail = NULL;
+
+ if (!list || !list->ifa_next)
+ return (list);
+
+ while (temp && temp->ifa_next) {
+ last = right;
+ right = right->ifa_next;
+ temp = temp->ifa_next->ifa_next;
+ }
+
+ last->ifa_next = NULL;
+
+ list = sortifaddrs(list, compare, q);
+ right = sortifaddrs(right, compare, q);
+
+ while (list || right) {
+
+ if (!right) {
+ next = list;
+ list = list->ifa_next;
+ } else if (!list) {
+ next = right;
+ right = right->ifa_next;
+ } else if (compare(list, right, q) <= 0) {
+ next = list;
+ list = list->ifa_next;
+ } else {
+ next = right;
+ right = right->ifa_next;
+ }
+
+ if (!result)
+ result = next;
+ else
+ tail->ifa_next = next;
+
+ tail = next;
+ }
+
+ return (result);
+}
+
int
main(int argc, char *argv[])
{
int c, all, namesonly, downonly, uponly;
const struct afswtch *afp = NULL;
int ifindex;
- struct ifaddrs *ifap, *ifa;
+ struct ifaddrs *ifap, *sifap, *ifa;
struct ifreq paifr;
const struct sockaddr_dl *sdl;
char options[1024], *cp, *namecp = NULL;
+ struct ifa_queue q = TAILQ_HEAD_INITIALIZER(q);
+ struct ifa_order_elt *cur, *tmp;
const char *ifname;
struct option *p;
size_t iflen;
@@ -285,9 +443,19 @@ main(int argc, char *argv[])
if (getifaddrs(&ifap) != 0)
err(EXIT_FAILURE, "getifaddrs");
+
cp = NULL;
+
+ if (calcorders(ifap, &q) != 0)
+ err(EXIT_FAILURE, "calcorders");
+
+ sifap = sortifaddrs(ifap, cmpifaddrs, &q);
+
+ TAILQ_FOREACH_SAFE(cur, &q, link, tmp)
+ free(cur);
+
ifindex = 0;
- for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
+ for (ifa = sifap; ifa; ifa = ifa->ifa_next) {
memset(&paifr, 0, sizeof(paifr));
strncpy(paifr.ifr_name, ifa->ifa_name, sizeof(paifr.ifr_name));
if (sizeof(paifr.ifr_addr) >= ifa->ifa_addr->sa_len) {
@@ -333,7 +501,8 @@ main(int argc, char *argv[])
sdl->sdl_alen != ETHER_ADDR_LEN)
continue;
} else {
- if (ifa->ifa_addr->sa_family != afp->af_af)
+ if (ifa->ifa_addr->sa_family
+ != afp->af_af)
continue;
}
}
@@ -669,7 +838,7 @@ settunnel(const char *src, const char *dst, int s, const struct afswtch *afp)
errx(1, "error in parsing address string: %s",
gai_strerror(ecode));
- if ((ecode = getaddrinfo(dst, NULL, NULL, &dstres)) != 0)
+ if ((ecode = getaddrinfo(dst, NULL, NULL, &dstres)) != 0)
errx(1, "error in parsing address string: %s",
gai_strerror(ecode));
@@ -1110,9 +1279,8 @@ ifmaybeload(const char *name)
}
/* turn interface and unit into module name */
- strcpy(ifkind, "if_");
- strlcpy(ifkind + MOD_PREFIX_LEN, ifname,
- sizeof(ifkind) - MOD_PREFIX_LEN);
+ strlcpy(ifkind, "if_", sizeof(ifkind));
+ strlcat(ifkind, ifname, sizeof(ifkind));
/* scan files in kernel */
mstat.version = sizeof(struct module_stat);
@@ -1129,8 +1297,8 @@ ifmaybeload(const char *name)
cp = mstat.name;
}
/* already loaded? */
- if (strncmp(ifname, cp, strlen(ifname) + 1) == 0 ||
- strncmp(ifkind, cp, strlen(ifkind) + 1) == 0)
+ if (strcmp(ifname, cp) == 0 ||
+ strcmp(ifkind, cp) == 0)
return;
}
}
diff --git a/sbin/ifconfig/iffib.c b/sbin/ifconfig/iffib.c
index f3498b4..07ded3c 100644
--- a/sbin/ifconfig/iffib.c
+++ b/sbin/ifconfig/iffib.c
@@ -50,15 +50,15 @@ fib_status(int s)
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCGIFFIB, (caddr_t)&ifr) == 0 &&
+ ifr.ifr_fib != RT_DEFAULT_FIB)
+ printf("\tfib: %u\n", ifr.ifr_fib);
- if (ioctl(s, SIOCGIFFIB, (caddr_t)&ifr) < 0)
- return;
-
- /* Ignore if it is the default. */
- if (ifr.ifr_fib == 0)
- return;
-
- printf("\tfib: %u\n", ifr.ifr_fib);
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCGTUNFIB, (caddr_t)&ifr) == 0 &&
+ ifr.ifr_fib != RT_DEFAULT_FIB)
+ printf("\ttunnelfib: %u\n", ifr.ifr_fib);
}
static void
@@ -80,8 +80,28 @@ setiffib(const char *val, int dummy __unused, int s,
warn("ioctl (SIOCSIFFIB)");
}
+static void
+settunfib(const char *val, int dummy __unused, int s,
+ const struct afswtch *afp)
+{
+ unsigned long fib;
+ char *ep;
+
+ fib = strtoul(val, &ep, 0);
+ if (*ep != '\0' || fib > UINT_MAX) {
+ warn("fib %s not valid", val);
+ return;
+ }
+
+ strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
+ ifr.ifr_fib = fib;
+ if (ioctl(s, SIOCSTUNFIB, (caddr_t)&ifr) < 0)
+ warn("ioctl (SIOCSTUNFIB)");
+}
+
static struct cmd fib_cmds[] = {
DEF_CMD_ARG("fib", setiffib),
+ DEF_CMD_ARG("tunnelfib", settunfib),
};
static struct afswtch af_fib = {
diff --git a/sbin/ifconfig/ifgif.c b/sbin/ifconfig/ifgif.c
index f91508b..91c433c 100644
--- a/sbin/ifconfig/ifgif.c
+++ b/sbin/ifconfig/ifgif.c
@@ -51,7 +51,7 @@ static const char rcsid[] =
#include "ifconfig.h"
-#define GIFBITS "\020\1ACCEPT_REV_ETHIP_VER\5SEND_REV_ETHIP_VER"
+#define GIFBITS "\020\1ACCEPT_REV_ETHIP_VER\2IGNORE_SOURCE\5SEND_REV_ETHIP_VER"
static void gif_status(int);
@@ -95,6 +95,8 @@ setgifopts(const char *val,
static struct cmd gif_cmds[] = {
DEF_CMD("accept_rev_ethip_ver", GIF_ACCEPT_REVETHIP, setgifopts),
DEF_CMD("-accept_rev_ethip_ver",-GIF_ACCEPT_REVETHIP, setgifopts),
+ DEF_CMD("ignore_source", GIF_IGNORE_SOURCE, setgifopts),
+ DEF_CMD("-ignore_source", -GIF_IGNORE_SOURCE, setgifopts),
DEF_CMD("send_rev_ethip_ver", GIF_SEND_REVETHIP, setgifopts),
DEF_CMD("-send_rev_ethip_ver", -GIF_SEND_REVETHIP, setgifopts),
};
diff --git a/sbin/ifconfig/ifgroup.c b/sbin/ifconfig/ifgroup.c
index f8b18b4..e3f271d 100644
--- a/sbin/ifconfig/ifgroup.c
+++ b/sbin/ifconfig/ifgroup.c
@@ -86,9 +86,6 @@ getifgroups(int s)
struct ifgroupreq ifgr;
struct ifg_req *ifg;
- if (!verbose)
- return;
-
memset(&ifgr, 0, sizeof(ifgr));
strlcpy(ifgr.ifgr_name, name, IFNAMSIZ);
@@ -121,6 +118,8 @@ getifgroups(int s)
}
if (cnt)
printf("\n");
+
+ free(ifgr.ifgr_groups);
}
static void
diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c
index 0b0daa3..eee3391 100644
--- a/sbin/ifconfig/ifmedia.c
+++ b/sbin/ifconfig/ifmedia.c
@@ -109,11 +109,17 @@ media_status(int s)
{
struct ifmediareq ifmr;
int *media_list, i;
+ int xmedia = 1;
(void) memset(&ifmr, 0, sizeof(ifmr));
(void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name));
- if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
+ /*
+ * Check if interface supports extended media types.
+ */
+ if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)&ifmr) < 0)
+ xmedia = 0;
+ if (xmedia == 0 && ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
/*
* Interface doesn't support SIOC{G,S}IFMEDIA.
*/
@@ -130,8 +136,13 @@ media_status(int s)
err(1, "malloc");
ifmr.ifm_ulist = media_list;
- if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0)
- err(1, "SIOCGIFMEDIA");
+ if (xmedia) {
+ if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)&ifmr) < 0)
+ err(1, "SIOCGIFXMEDIA");
+ } else {
+ if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0)
+ err(1, "SIOCGIFMEDIA");
+ }
printf("\tmedia: ");
print_media_word(ifmr.ifm_current, 1);
@@ -194,6 +205,7 @@ ifmedia_getstate(int s)
{
static struct ifmediareq *ifmr = NULL;
int *mwords;
+ int xmedia = 1;
if (ifmr == NULL) {
ifmr = (struct ifmediareq *)malloc(sizeof(struct ifmediareq));
@@ -213,7 +225,10 @@ ifmedia_getstate(int s)
* the current media type and the top-level type.
*/
- if (ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0) {
+ if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)ifmr) < 0) {
+ xmedia = 0;
+ }
+ if (xmedia == 0 && ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0) {
err(1, "SIOCGIFMEDIA");
}
@@ -225,8 +240,13 @@ ifmedia_getstate(int s)
err(1, "malloc");
ifmr->ifm_ulist = mwords;
- if (ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0)
- err(1, "SIOCGIFMEDIA");
+ if (xmedia) {
+ if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)ifmr) < 0)
+ err(1, "SIOCGIFXMEDIA");
+ } else {
+ if (ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0)
+ err(1, "SIOCGIFMEDIA");
+ }
}
return ifmr;
diff --git a/sbin/ifconfig/ifvlan.c b/sbin/ifconfig/ifvlan.c
index cefcbbc..1a3fbaa 100644
--- a/sbin/ifconfig/ifvlan.c
+++ b/sbin/ifconfig/ifvlan.c
@@ -40,7 +40,6 @@
#include <net/ethernet.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_vlan_var.h>
#include <net/route.h>
diff --git a/sbin/ifconfig/ifvxlan.c b/sbin/ifconfig/ifvxlan.c
index 7234667..48f5331 100644
--- a/sbin/ifconfig/ifvxlan.c
+++ b/sbin/ifconfig/ifvxlan.c
@@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_vxlan.h>
#include <net/route.h>
#include <netinet/in.h>
@@ -595,36 +594,36 @@ setvxlan_flush(const char *val, int d, int s, const struct afswtch *afp)
static struct cmd vxlan_cmds[] = {
- DEF_CLONE_CMD_ARG("vni", setvxlan_vni),
- DEF_CLONE_CMD_ARG("local", setvxlan_local),
- DEF_CLONE_CMD_ARG("remote", setvxlan_remote),
- DEF_CLONE_CMD_ARG("group", setvxlan_group),
- DEF_CLONE_CMD_ARG("localport", setvxlan_local_port),
- DEF_CLONE_CMD_ARG("remoteport", setvxlan_remote_port),
- DEF_CLONE_CMD_ARG2("portrange", setvxlan_port_range),
- DEF_CLONE_CMD_ARG("timeout", setvxlan_timeout),
- DEF_CLONE_CMD_ARG("maxaddr", setvxlan_maxaddr),
+ DEF_CLONE_CMD_ARG("vxlanid", setvxlan_vni),
+ DEF_CLONE_CMD_ARG("vxlanlocal", setvxlan_local),
+ DEF_CLONE_CMD_ARG("vxlanremote", setvxlan_remote),
+ DEF_CLONE_CMD_ARG("vxlangroup", setvxlan_group),
+ DEF_CLONE_CMD_ARG("vxlanlocalport", setvxlan_local_port),
+ DEF_CLONE_CMD_ARG("vxlanremoteport", setvxlan_remote_port),
+ DEF_CLONE_CMD_ARG2("vxlanportrange", setvxlan_port_range),
+ DEF_CLONE_CMD_ARG("vxlantimeout", setvxlan_timeout),
+ DEF_CLONE_CMD_ARG("vxlanmaxaddr", setvxlan_maxaddr),
DEF_CLONE_CMD_ARG("vxlandev", setvxlan_dev),
- DEF_CLONE_CMD_ARG("ttl", setvxlan_ttl),
- DEF_CLONE_CMD("learn", 1, setvxlan_learn),
- DEF_CLONE_CMD("-learn", 0, setvxlan_learn),
-
- DEF_CMD_ARG("vni", setvxlan_vni),
- DEF_CMD_ARG("local", setvxlan_local),
- DEF_CMD_ARG("remote", setvxlan_remote),
- DEF_CMD_ARG("group", setvxlan_group),
- DEF_CMD_ARG("localport", setvxlan_local_port),
- DEF_CMD_ARG("remoteport", setvxlan_remote_port),
- DEF_CMD_ARG2("portrange", setvxlan_port_range),
- DEF_CMD_ARG("timeout", setvxlan_timeout),
- DEF_CMD_ARG("maxaddr", setvxlan_maxaddr),
+ DEF_CLONE_CMD_ARG("vxlanttl", setvxlan_ttl),
+ DEF_CLONE_CMD("vxlanlearn", 1, setvxlan_learn),
+ DEF_CLONE_CMD("-vxlanlearn", 0, setvxlan_learn),
+
+ DEF_CMD_ARG("vxlanvni", setvxlan_vni),
+ DEF_CMD_ARG("vxlanlocal", setvxlan_local),
+ DEF_CMD_ARG("vxlanremote", setvxlan_remote),
+ DEF_CMD_ARG("vxlangroup", setvxlan_group),
+ DEF_CMD_ARG("vxlanlocalport", setvxlan_local_port),
+ DEF_CMD_ARG("vxlanremoteport", setvxlan_remote_port),
+ DEF_CMD_ARG2("vxlanportrange", setvxlan_port_range),
+ DEF_CMD_ARG("vxlantimeout", setvxlan_timeout),
+ DEF_CMD_ARG("vxlanmaxaddr", setvxlan_maxaddr),
DEF_CMD_ARG("vxlandev", setvxlan_dev),
- DEF_CMD_ARG("ttl", setvxlan_ttl),
- DEF_CMD("learn", 1, setvxlan_learn),
- DEF_CMD("-learn", 0, setvxlan_learn),
+ DEF_CMD_ARG("vxlanttl", setvxlan_ttl),
+ DEF_CMD("vxlanlearn", 1, setvxlan_learn),
+ DEF_CMD("-vxlanlearn", 0, setvxlan_learn),
- DEF_CMD("flush", 0, setvxlan_flush),
- DEF_CMD("flushall", 1, setvxlan_flush),
+ DEF_CMD("vxlanflush", 0, setvxlan_flush),
+ DEF_CMD("vxlanflushall", 1, setvxlan_flush),
};
static struct afswtch af_vxlan = {
diff --git a/sbin/ifconfig/sfp.c b/sbin/ifconfig/sfp.c
index d4da8c3..7c090e1 100644
--- a/sbin/ifconfig/sfp.c
+++ b/sbin/ifconfig/sfp.c
@@ -48,25 +48,16 @@ static const char rcsid[] =
#include "ifconfig.h"
-struct i2c_info;
-typedef int (read_i2c)(struct i2c_info *ii, uint8_t addr, uint8_t off,
- uint8_t len, caddr_t buf);
-
struct i2c_info {
- int s;
- int error;
- int bshift;
- int qsfp;
- int do_diag;
- struct ifreq *ifr;
- read_i2c *f;
- char *textbuf;
- size_t bufsize;
- int cfd;
- int port_id;
- int chip_id;
+ int fd; /* fd to issue SIOCGI2C */
+ int error; /* Store first error */
+ int qsfp; /* True if transceiver is QSFP */
+ int do_diag; /* True if we need to request DDM */
+ struct ifreq *ifr; /* Pointer to pre-filled ifreq */
};
+static int read_i2c(struct i2c_info *ii, uint8_t addr, uint8_t off,
+ uint8_t len, uint8_t *buf);
static void dump_i2c_data(struct i2c_info *ii, uint8_t addr, uint8_t off,
uint8_t len);
@@ -191,6 +182,18 @@ static struct _nv eth_1040g[] = {
{ 0, NULL }
};
+/* SFF-8636 Rev. 2.5 table 6.3: Revision compliance */
+static struct _nv rev_compl[] = {
+ { 0x1, "SFF-8436 rev <=4.8" },
+ { 0x2, "SFF-8436 rev <=4.8" },
+ { 0x3, "SFF-8636 rev <=1.3" },
+ { 0x4, "SFF-8636 rev <=1.4" },
+ { 0x5, "SFF-8636 rev <=1.5" },
+ { 0x6, "SFF-8636 rev <=2.0" },
+ { 0x7, "SFF-8636 rev <=2.5" },
+ { 0x0, "Unspecified" }
+};
+
const char *
find_value(struct _nv *x, int value)
{
@@ -255,11 +258,24 @@ convert_sff_connector(char *buf, size_t size, uint8_t value)
}
static void
+convert_sff_rev_compliance(char *buf, size_t size, uint8_t value)
+{
+ const char *x;
+
+ if (value > 0x07)
+ x = "Unallocated";
+ else
+ x = find_value(rev_compl, value);
+
+ snprintf(buf, size, "%s", x);
+}
+
+static void
get_sfp_identifier(struct i2c_info *ii, char *buf, size_t size)
{
uint8_t data;
- ii->f(ii, SFF_8472_BASE, SFF_8472_ID, 1, (caddr_t)&data);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_ID, 1, &data);
convert_sff_identifier(buf, size, data);
}
@@ -268,7 +284,7 @@ get_sfp_connector(struct i2c_info *ii, char *buf, size_t size)
{
uint8_t data;
- ii->f(ii, SFF_8472_BASE, SFF_8472_CONNECTOR, 1, (caddr_t)&data);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_CONNECTOR, 1, &data);
convert_sff_connector(buf, size, data);
}
@@ -277,7 +293,7 @@ get_qsfp_identifier(struct i2c_info *ii, char *buf, size_t size)
{
uint8_t data;
- ii->f(ii, SFF_8436_BASE, SFF_8436_ID, 1, (caddr_t)&data);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_ID, 1, &data);
convert_sff_identifier(buf, size, data);
}
@@ -286,7 +302,7 @@ get_qsfp_connector(struct i2c_info *ii, char *buf, size_t size)
{
uint8_t data;
- ii->f(ii, SFF_8436_BASE, SFF_8436_CONNECTOR, 1, (caddr_t)&data);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_CONNECTOR, 1, &data);
convert_sff_connector(buf, size, data);
}
@@ -303,7 +319,7 @@ printf_sfp_transceiver_descr(struct i2c_info *ii, char *buf, size_t size)
tech_speed = NULL;
/* Read bytes 3-10 at once */
- ii->f(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, &xbuf[3]);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, &xbuf[3]);
/* Check 10G ethernet first */
tech_class = find_zero_bit(eth_10g, xbuf[3], 1);
@@ -331,14 +347,14 @@ get_sfp_transceiver_class(struct i2c_info *ii, char *buf, size_t size)
uint8_t code;
unsigned char qbuf[8];
- ii->f(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, (caddr_t)qbuf);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, (uint8_t *)qbuf);
/* Check 10G Ethernet/IB first */
- ii->f(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 1, (caddr_t)&code);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 1, &code);
tech_class = find_zero_bit(eth_10g, code, 1);
if (tech_class == NULL) {
/* No match. Try Ethernet 1G */
- ii->f(ii, SFF_8472_BASE, SFF_8472_TRANS_START + 3,
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START + 3,
1, (caddr_t)&code);
tech_class = find_zero_bit(eth_compat, code, 1);
}
@@ -356,7 +372,7 @@ get_qsfp_transceiver_class(struct i2c_info *ii, char *buf, size_t size)
uint8_t code;
/* Check 10/40G Ethernet class only */
- ii->f(ii, SFF_8436_BASE, SFF_8436_CODE_E1040G, 1, (caddr_t)&code);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_CODE_E1040G, 1, &code);
tech_class = find_zero_bit(eth_1040g, code, 1);
if (tech_class == NULL)
tech_class = "Unknown";
@@ -393,7 +409,7 @@ get_sfp_vendor_name(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_BASE, SFF_8472_VENDOR_START, 16, xbuf);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_VENDOR_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -403,7 +419,7 @@ get_sfp_vendor_pn(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_BASE, SFF_8472_PN_START, 16, xbuf);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_PN_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -413,7 +429,7 @@ get_sfp_vendor_sn(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_BASE, SFF_8472_SN_START, 16, xbuf);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_SN_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -424,7 +440,7 @@ get_sfp_vendor_date(struct i2c_info *ii, char *buf, size_t size)
memset(xbuf, 0, sizeof(xbuf));
/* Date code, see Table 3.8 for description */
- ii->f(ii, SFF_8472_BASE, SFF_8472_DATE_START, 6, xbuf);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_DATE_START, 6, (uint8_t *)xbuf);
convert_sff_date(buf, size, xbuf);
}
@@ -434,7 +450,7 @@ get_qsfp_vendor_name(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_VENDOR_START, 16, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_VENDOR_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -444,7 +460,7 @@ get_qsfp_vendor_pn(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_PN_START, 16, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_PN_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -454,7 +470,7 @@ get_qsfp_vendor_sn(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_SN_START, 16, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_SN_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -464,7 +480,7 @@ get_qsfp_vendor_date(struct i2c_info *ii, char *buf, size_t size)
char xbuf[6];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_DATE_START, 6, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_DATE_START, 6, (uint8_t *)xbuf);
convert_sff_date(buf, size, xbuf);
}
@@ -501,12 +517,12 @@ print_sfp_vendor(struct i2c_info *ii, char *buf, size_t size)
*
*/
static void
-convert_sff_temp(char *buf, size_t size, char *xbuf)
+convert_sff_temp(char *buf, size_t size, uint8_t *xbuf)
{
double d;
- d = (double)(int8_t)xbuf[0];
- d += (double)(uint8_t)xbuf[1] / 256;
+ d = (double)xbuf[0];
+ d += (double)xbuf[1] / 256;
snprintf(buf, size, "%.2f C", d);
}
@@ -516,11 +532,11 @@ convert_sff_temp(char *buf, size_t size, char *xbuf)
* 16-bit usigned value, treated as range 0..+6.55 Volts
*/
static void
-convert_sff_voltage(char *buf, size_t size, char *xbuf)
+convert_sff_voltage(char *buf, size_t size, uint8_t *xbuf)
{
double d;
- d = (double)(((uint8_t)xbuf[0] << 8) | (uint8_t)xbuf[1]);
+ d = (double)((xbuf[0] << 8) | xbuf[1]);
snprintf(buf, size, "%.2f Volts", d / 10000);
}
@@ -529,12 +545,12 @@ convert_sff_voltage(char *buf, size_t size, char *xbuf)
* human representation.
*/
static void
-convert_sff_power(struct i2c_info *ii, char *buf, size_t size, char *xbuf)
+convert_sff_power(struct i2c_info *ii, char *buf, size_t size, uint8_t *xbuf)
{
uint16_t mW;
double dbm;
- mW = ((uint8_t)xbuf[0] << 8) + (uint8_t)xbuf[1];
+ mW = (xbuf[0] << 8) + xbuf[1];
/* Convert mw to dbm */
dbm = 10.0 * log10(1.0 * mW / 10000);
@@ -553,87 +569,116 @@ convert_sff_power(struct i2c_info *ii, char *buf, size_t size, char *xbuf)
static void
get_sfp_temp(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_DIAG, SFF_8472_TEMP, 2, xbuf);
+ read_i2c(ii, SFF_8472_DIAG, SFF_8472_TEMP, 2, xbuf);
convert_sff_temp(buf, size, xbuf);
}
static void
get_sfp_voltage(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_DIAG, SFF_8472_VCC, 2, xbuf);
+ read_i2c(ii, SFF_8472_DIAG, SFF_8472_VCC, 2, xbuf);
convert_sff_voltage(buf, size, xbuf);
}
static void
get_qsfp_temp(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_TEMP, 2, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_TEMP, 2, xbuf);
convert_sff_temp(buf, size, xbuf);
}
static void
get_qsfp_voltage(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_VCC, 2, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_VCC, 2, xbuf);
convert_sff_voltage(buf, size, xbuf);
}
static void
get_sfp_rx_power(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_DIAG, SFF_8472_RX_POWER, 2, xbuf);
+ read_i2c(ii, SFF_8472_DIAG, SFF_8472_RX_POWER, 2, xbuf);
convert_sff_power(ii, buf, size, xbuf);
}
static void
get_sfp_tx_power(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_DIAG, SFF_8472_TX_POWER, 2, xbuf);
+ read_i2c(ii, SFF_8472_DIAG, SFF_8472_TX_POWER, 2, xbuf);
convert_sff_power(ii, buf, size, xbuf);
}
static void
get_qsfp_rx_power(struct i2c_info *ii, char *buf, size_t size, int chan)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_RX_CH1_MSB + (chan - 1) * 2, 2, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_RX_CH1_MSB + (chan-1)*2, 2, xbuf);
convert_sff_power(ii, buf, size, xbuf);
}
static void
get_qsfp_tx_power(struct i2c_info *ii, char *buf, size_t size, int chan)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_TX_CH1_MSB + (chan -1) * 2, 2, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_TX_CH1_MSB + (chan-1)*2, 2, xbuf);
convert_sff_power(ii, buf, size, xbuf);
}
-/* Generic handler */
+static void
+get_qsfp_rev_compliance(struct i2c_info *ii, char *buf, size_t size)
+{
+ uint8_t xbuf;
+
+ xbuf = 0;
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_STATUS, 1, &xbuf);
+ convert_sff_rev_compliance(buf, size, xbuf);
+}
+
+static uint32_t
+get_qsfp_br(struct i2c_info *ii)
+{
+ uint8_t xbuf;
+ uint32_t rate;
+
+ xbuf = 0;
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_BITRATE, 1, &xbuf);
+ rate = xbuf * 100;
+ if (xbuf == 0xFF) {
+ read_i2c(ii, SFF_8436_BASE, SFF_8636_BITRATE, 1, &xbuf);
+ rate = xbuf * 250;
+ }
+
+ return (rate);
+}
+
+/*
+ * Reads i2c data from opened kernel socket.
+ */
static int
-read_i2c_generic(struct i2c_info *ii, uint8_t addr, uint8_t off, uint8_t len,
- caddr_t buf)
+read_i2c(struct i2c_info *ii, uint8_t addr, uint8_t off, uint8_t len,
+ uint8_t *buf)
{
struct ifi2creq req;
int i, l;
@@ -653,7 +698,7 @@ read_i2c_generic(struct i2c_info *ii, uint8_t addr, uint8_t off, uint8_t len,
while (len > 0) {
l = (len > sizeof(req.data)) ? sizeof(req.data) : len;
req.len = l;
- if (ioctl(ii->s, SIOCGI2C, ii->ifr) != 0) {
+ if (ioctl(ii->fd, SIOCGI2C, ii->ifr) != 0) {
ii->error = errno;
return (errno);
}
@@ -676,7 +721,7 @@ dump_i2c_data(struct i2c_info *ii, uint8_t addr, uint8_t off, uint8_t len)
while (len > 0) {
memset(buf, 0, sizeof(buf));
read = (len > sizeof(buf)) ? sizeof(buf) : len;
- ii->f(ii, addr, off, read, buf);
+ read_i2c(ii, addr, off, read, buf);
if (ii->error != 0) {
fprintf(stderr, "Error reading i2c info\n");
return;
@@ -696,10 +741,11 @@ print_qsfp_status(struct i2c_info *ii, int verbose)
{
char buf[80], buf2[40], buf3[40];
uint8_t diag_type;
+ uint32_t bitrate;
int i;
/* Read diagnostic monitoring type */
- ii->f(ii, SFF_8436_BASE, SFF_8436_DIAG_TYPE, 1, (caddr_t)&diag_type);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_DIAG_TYPE, 1, (caddr_t)&diag_type);
if (ii->error != 0)
return;
@@ -722,6 +768,16 @@ print_qsfp_status(struct i2c_info *ii, int verbose)
if (ii->error == 0)
printf("\t%s\n", buf);
+ if (verbose > 1) {
+ get_qsfp_rev_compliance(ii, buf, sizeof(buf));
+ if (ii->error == 0)
+ printf("\tcompliance level: %s\n", buf);
+
+ bitrate = get_qsfp_br(ii);
+ if (ii->error == 0 && bitrate > 0)
+ printf("\tnominal bitrate: %u Mbps\n", bitrate);
+ }
+
/* Request current measurements if they are provided: */
if (ii->do_diag != 0) {
get_qsfp_temp(ii, buf, sizeof(buf));
@@ -749,7 +805,7 @@ print_sfp_status(struct i2c_info *ii, int verbose)
uint8_t diag_type, flags;
/* Read diagnostic monitoring type */
- ii->f(ii, SFF_8472_BASE, SFF_8472_DIAG_TYPE, 1, (caddr_t)&diag_type);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_DIAG_TYPE, 1, (caddr_t)&diag_type);
if (ii->error != 0)
return;
@@ -797,11 +853,10 @@ sfp_status(int s, struct ifreq *ifr, int verbose)
struct i2c_info ii;
uint8_t id_byte;
+ /* Prepare necessary into pass to i2c reader */
memset(&ii, 0, sizeof(ii));
- /* Prepare necessary into to pass to NIC handler */
- ii.s = s;
+ ii.fd = s;
ii.ifr = ifr;
- ii.f = read_i2c_generic;
/*
* Try to read byte 0 from i2c:
@@ -811,7 +866,7 @@ sfp_status(int s, struct ifreq *ifr, int verbose)
* this might happen in case of empty transceiver slot.
*/
id_byte = 0;
- ii.f(&ii, SFF_8472_BASE, SFF_8472_ID, 1, (caddr_t)&id_byte);
+ read_i2c(&ii, SFF_8472_BASE, SFF_8472_ID, 1, (caddr_t)&id_byte);
if (ii.error != 0 || id_byte == 0)
return;
diff --git a/sbin/ifconfig/tests/Makefile b/sbin/ifconfig/tests/Makefile
new file mode 100644
index 0000000..044e979
--- /dev/null
+++ b/sbin/ifconfig/tests/Makefile
@@ -0,0 +1,13 @@
+# $FreeBSD$
+
+OBJTOP= ${.OBJDIR}/../../..
+SRCTOP= ${.CURDIR}/../../..
+TESTSRC= ${SRCTOP}/contrib/netbsd-tests/sbin/ifconfig
+
+TESTSDIR= ${TESTSBASE}/sbin/ifconfig
+
+NETBSD_ATF_TESTS_SH= nonexistent_test
+
+.include <netbsd-tests.test.mk>
+
+.include <bsd.test.mk>
diff --git a/sbin/init/Makefile b/sbin/init/Makefile
index 7497a4b..6e9c0fc 100644
--- a/sbin/init/Makefile
+++ b/sbin/init/Makefile
@@ -6,8 +6,7 @@ MAN= init.8
PRECIOUSPROG=
INSTALLFLAGS=-b -B.bak
CFLAGS+=-DDEBUGSHELL -DSECURE -DLOGIN_CAP -DCOMPAT_SYSV_INIT
-DPADD= ${LIBUTIL} ${LIBCRYPT}
-LDADD= -lutil -lcrypt
+LIBADD= util crypt
NO_SHARED?= YES
diff --git a/sbin/ipf/Makefile.inc b/sbin/ipf/Makefile.inc
index 2d7d7b1..79bdb8e 100644
--- a/sbin/ipf/Makefile.inc
+++ b/sbin/ipf/Makefile.inc
@@ -18,9 +18,7 @@ CFLAGS+= -DUSE_INET6
CFLAGS+= -DNOINET6
.endif
-LIBIPF= ${.OBJDIR}/../libipf/libipf.a
-DPADD+= ${LIBIPF} ${LIBKVM}
-LDADD+= ${LIBIPF} -lkvm
+LIBADD+= ipf
CLEANFILES+= y.tab.c y.tab.h
diff --git a/sbin/ipf/ipf/Makefile b/sbin/ipf/ipf/Makefile
index c3938c6..3ffd2b2 100644
--- a/sbin/ipf/ipf/Makefile
+++ b/sbin/ipf/ipf/Makefile
@@ -35,8 +35,7 @@ ipf_l.h: lexer.h
LIBIPF_SRCS!= cd ${.CURDIR}/../libipf && ${MAKE} -V SRCS
SRCS+= ${LIBIPF_SRCS}
.else
-DPADD+= ${LIBPCAP}
-LDADD+= -lpcap
+LIBADD+= pcap
.endif
.include <bsd.prog.mk>
diff --git a/sbin/ipf/ipf/Makefile.depend b/sbin/ipf/ipf/Makefile.depend
index f781eb1..6ca8be6 100644
--- a/sbin/ipf/ipf/Makefile.depend
+++ b/sbin/ipf/ipf/Makefile.depend
@@ -14,6 +14,7 @@ DIRDEPS = \
lib/libkvm \
lib/libpcap \
sbin/ipf/libipf \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/sbin/ipf/ipfstat/Makefile b/sbin/ipf/ipfstat/Makefile
index a33c5df..14823cf 100644
--- a/sbin/ipf/ipfstat/Makefile
+++ b/sbin/ipf/ipfstat/Makefile
@@ -5,7 +5,6 @@ NOGCCERROR= # defined
PROG= ipfstat
SRCS= ipfstat.c
MAN= ipfstat.8
-DPADD+= ${LIBCURSES}
-LDADD+= -lcurses
+LIBADD+= ncursesw
.include <bsd.prog.mk>
diff --git a/sbin/ipf/ipfstat/Makefile.depend b/sbin/ipf/ipfstat/Makefile.depend
index e2073f8..fd3e984 100644
--- a/sbin/ipf/ipfstat/Makefile.depend
+++ b/sbin/ipf/ipfstat/Makefile.depend
@@ -12,7 +12,6 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libkvm \
- lib/ncurses/ncurses \
lib/ncurses/ncursesw \
sbin/ipf/libipf \
diff --git a/sbin/ipf/ipftest/Makefile.depend b/sbin/ipf/ipftest/Makefile.depend
index 0ba17cd..549569e 100644
--- a/sbin/ipf/ipftest/Makefile.depend
+++ b/sbin/ipf/ipftest/Makefile.depend
@@ -13,6 +13,7 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libkvm \
sbin/ipf/libipf \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/sbin/ipf/ipmon/Makefile.depend b/sbin/ipf/ipmon/Makefile.depend
index 7f71b7a..69020e0 100644
--- a/sbin/ipf/ipmon/Makefile.depend
+++ b/sbin/ipf/ipmon/Makefile.depend
@@ -13,6 +13,7 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libkvm \
sbin/ipf/libipf \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/sbin/ipf/ipnat/Makefile.depend b/sbin/ipf/ipnat/Makefile.depend
index 6ba8eba..5be902b 100644
--- a/sbin/ipf/ipnat/Makefile.depend
+++ b/sbin/ipf/ipnat/Makefile.depend
@@ -13,6 +13,7 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libkvm \
sbin/ipf/libipf \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/sbin/ipf/ippool/Makefile.depend b/sbin/ipf/ippool/Makefile.depend
index 05af37b..4e4cedc 100644
--- a/sbin/ipf/ippool/Makefile.depend
+++ b/sbin/ipf/ippool/Makefile.depend
@@ -13,6 +13,7 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libkvm \
sbin/ipf/libipf \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/sbin/ipf/ipsend/Makefile b/sbin/ipf/ipsend/Makefile
index 4ae4c34..176cb10 100644
--- a/sbin/ipf/ipsend/Makefile
+++ b/sbin/ipf/ipsend/Makefile
@@ -8,8 +8,7 @@ PROG= ipsend
SRCS= ipsend.c ip.c ipsopt.c iplang_y.c iplang_l.l sbpf.c \
sock.c 44arp.c
MAN= ipsend.1 ipsend.5
-DPADD+= ${LIBL}
-LDADD+= -ll
+LIBADD+= l
CFLAGS+= -I${NETBSDSRCDIR}/dist/ipf/ipsend
CFLAGS+= -I${NETBSDSRCDIR}/dist/ipf/iplang
diff --git a/sbin/ipfw/Makefile b/sbin/ipfw/Makefile
index 9eb4511..efd99fc 100644
--- a/sbin/ipfw/Makefile
+++ b/sbin/ipfw/Makefile
@@ -11,8 +11,7 @@ SRCS+= altq.c
CFLAGS+=-DPF
.endif
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+LIBADD= util
MAN= ipfw.8
.include <bsd.prog.mk>
diff --git a/sbin/ipfw/ipfw.8 b/sbin/ipfw/ipfw.8
index 0c6edb2..63f04cf 100644
--- a/sbin/ipfw/ipfw.8
+++ b/sbin/ipfw/ipfw.8
@@ -1,7 +1,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd Aug 13, 2014
+.Dd March 13, 2015
.Dt IPFW 8
.Os
.Sh NAME
@@ -76,7 +76,7 @@ in-kernel NAT.
.Nm
.Oo Cm set Ar N Oc Cm table
.Brq Ar name | all
-.Cm info
+.Cm info
.Nm
.Oo Cm set Ar N Oc Cm table
.Brq Ar name | all
@@ -1642,7 +1642,6 @@ be specified as:
.Pp
Note that the ampersand character has a special meaning in many shells
and should generally be escaped.
-.Pp
.El
Note that the order of MAC addresses (destination first,
source second) is
@@ -1873,7 +1872,7 @@ addresses or other search keys (e.g., ports, jail IDs, interface names).
In the rest of this section we will use the term ``key''.
Table name needs to match the following spec:
.Ar table-name .
-Tables with the same name can be created in different
+Tables with the same name can be created in different
.Ar sets .
However, rule links to the tables in
.Ar set 0
@@ -1973,7 +1972,7 @@ command.
Addition of all items are performed atomically.
By default, error in addition of one entry does not influence
addition of other entries. However, non-zero error code is returned
-in that case.
+in that case.
Special
.Cm atomic
keyword may be specified before
@@ -1985,13 +1984,13 @@ One or more entries can be removed from a table at once using
command.
By default, error in removal of one entry does not influence
removing of other entries. However, non-zero error code is returned
-in that case.
+in that case.
.Pp
It may be possible to check what entry will be found on particular
.Ar table-key
using
.Cm lookup
-.Ae table-key
+.Ar table-key
command.
This functionality is optional and may be unsupported in some algorithms.
.Pp
@@ -2079,6 +2078,8 @@ hook number to move packet to.
maximum number of connections.
.It Cm ipv4
IPv4 nexthop to fwd packets to.
+.It Cm ipv6
+IPv6 nexthop to fwd packets to.
.El
.Pp
The
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index 2c98466..687d707 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -61,6 +61,7 @@ struct format_opts {
int bcwidth;
int pcwidth;
int show_counters;
+ int show_time; /* show timestamp */
uint32_t set_mask; /* enabled sets mask */
uint32_t flags; /* request flags */
uint32_t first; /* first rule to request */
@@ -374,6 +375,13 @@ static int ipfw_show_config(struct cmdline_opts *co, struct format_opts *fo,
ipfw_cfg_lheader *cfg, size_t sz, int ac, char **av);
static void ipfw_list_tifaces(void);
+struct tidx;
+static uint16_t pack_object(struct tidx *tstate, char *name, int otype);
+static uint16_t pack_table(struct tidx *tstate, char *name);
+
+static char *table_search_ctlv(ipfw_obj_ctlv *ctlv, uint16_t idx);
+static void object_sort_ctlv(ipfw_obj_ctlv *ctlv);
+
/*
* Simple string buffer API.
* Used to simplify buffer passing between function and for
@@ -1524,11 +1532,14 @@ show_static_rule(struct cmdline_opts *co, struct format_opts *fo,
case O_FORWARD_IP6:
{
- char buf[4 + INET6_ADDRSTRLEN + 1];
+ char buf[INET6_ADDRSTRLEN + IF_NAMESIZE + 2];
ipfw_insn_sa6 *s = (ipfw_insn_sa6 *)cmd;
- bprintf(bp, "fwd %s", inet_ntop(AF_INET6,
- &s->sa.sin6_addr, buf, sizeof(buf)));
+ bprintf(bp, "fwd ");
+ if (getnameinfo((const struct sockaddr *)&s->sa,
+ sizeof(struct sockaddr_in6), buf, sizeof(buf),
+ NULL, 0, NI_NUMERICHOST) == 0)
+ bprintf(bp, "%s", buf);
if (s->sa.sin6_port)
bprintf(bp, ",%d", s->sa.sin6_port);
}
@@ -2402,7 +2413,7 @@ list_static_range(struct cmdline_opts *co, struct format_opts *fo,
for (n = seen = 0; n < rcnt; n++,
rtlv = (ipfw_obj_tlv *)((caddr_t)rtlv + rtlv->length)) {
- if (fo->show_counters != 0) {
+ if ((fo->show_counters | fo->show_time) != 0) {
cntr = (struct ip_fw_bcounter *)(rtlv + 1);
r = (struct ip_fw_rule *)((caddr_t)cntr + cntr->size);
} else {
@@ -2504,10 +2515,11 @@ ipfw_list(int ac, char *av[], int show_counters)
/* get configuraion from kernel */
cfg = NULL;
sfo.show_counters = show_counters;
+ sfo.show_time = co.do_time;
sfo.flags = IPFW_CFG_GET_STATIC;
if (co.do_dynamic != 0)
sfo.flags |= IPFW_CFG_GET_STATES;
- if (sfo.show_counters != 0)
+ if ((sfo.show_counters | sfo.show_time) != 0)
sfo.flags |= IPFW_CFG_GET_COUNTERS;
if (ipfw_get_config(&co, &sfo, &cfg, &sz) != 0)
err(EX_OSERR, "retrieving config failed");
@@ -2553,6 +2565,7 @@ ipfw_show_config(struct cmdline_opts *co, struct format_opts *fo,
if (cfg->flags & IPFW_CFG_GET_STATIC) {
/* We've requested static rules */
if (ctlv->head.type == IPFW_TLV_TBLNAME_LIST) {
+ object_sort_ctlv(ctlv);
fo->tstate = ctlv;
readsz += ctlv->head.length;
ctlv = (ipfw_obj_ctlv *)((caddr_t)ctlv +
@@ -2719,19 +2732,18 @@ struct tidx {
};
static uint16_t
-pack_table(struct tidx *tstate, char *name)
+pack_object(struct tidx *tstate, char *name, int otype)
{
int i;
ipfw_obj_ntlv *ntlv;
- if (table_check_name(name) != 0)
- return (0);
-
for (i = 0; i < tstate->count; i++) {
if (strcmp(tstate->idx[i].name, name) != 0)
continue;
if (tstate->idx[i].set != tstate->set)
continue;
+ if (tstate->idx[i].head.type != otype)
+ continue;
return (tstate->idx[i].idx);
}
@@ -2747,7 +2759,7 @@ pack_table(struct tidx *tstate, char *name)
ntlv = &tstate->idx[i];
memset(ntlv, 0, sizeof(ipfw_obj_ntlv));
strlcpy(ntlv->name, name, sizeof(ntlv->name));
- ntlv->head.type = IPFW_TLV_TBL_NAME;
+ ntlv->head.type = otype;
ntlv->head.length = sizeof(ipfw_obj_ntlv);
ntlv->set = tstate->set;
ntlv->idx = ++tstate->counter;
@@ -2756,6 +2768,16 @@ pack_table(struct tidx *tstate, char *name)
return (ntlv->idx);
}
+static uint16_t
+pack_table(struct tidx *tstate, char *name)
+{
+
+ if (table_check_name(name) != 0)
+ return (0);
+
+ return (pack_object(tstate, name, IPFW_TLV_TBL_NAME));
+}
+
static void
fill_table(ipfw_insn *cmd, char *av, uint8_t opcode, struct tidx *tstate)
{
@@ -3606,7 +3628,6 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate)
break;
} else
goto chkarg;
-
case TOK_QUEUE:
action->opcode = O_QUEUE;
goto chkarg;
@@ -3739,8 +3760,8 @@ chkarg:
p->sa.sin6_family = AF_INET6;
p->sa.sin6_port = port_number;
p->sa.sin6_flowinfo = 0;
- p->sa.sin6_scope_id = 0;
- /* No table support for v6 yet. */
+ p->sa.sin6_scope_id =
+ ((struct sockaddr_in6 *)&result)->sin6_scope_id;
bcopy(&((struct sockaddr_in6*)&result)->sin6_addr,
&p->sa.sin6_addr, sizeof(p->sa.sin6_addr));
} else {
@@ -4651,6 +4672,101 @@ done:
*rbufsize = (char *)dst - (char *)rule;
}
+static int
+compare_ntlv(const void *_a, const void *_b)
+{
+ ipfw_obj_ntlv *a, *b;
+
+ a = (ipfw_obj_ntlv *)_a;
+ b = (ipfw_obj_ntlv *)_b;
+
+ if (a->set < b->set)
+ return (-1);
+ else if (a->set > b->set)
+ return (1);
+
+ if (a->idx < b->idx)
+ return (-1);
+ else if (a->idx > b->idx)
+ return (1);
+
+ if (a->head.type < b->head.type)
+ return (-1);
+ else if (a->head.type > b->head.type)
+ return (1);
+
+ return (0);
+}
+
+/*
+ * Provide kernel with sorted list of referenced objects
+ */
+static void
+object_sort_ctlv(ipfw_obj_ctlv *ctlv)
+{
+
+ qsort(ctlv + 1, ctlv->count, ctlv->objsize, compare_ntlv);
+}
+
+struct object_kt {
+ uint16_t uidx;
+ uint16_t type;
+};
+static int
+compare_object_kntlv(const void *k, const void *v)
+{
+ ipfw_obj_ntlv *ntlv;
+ struct object_kt key;
+
+ key = *((struct object_kt *)k);
+ ntlv = (ipfw_obj_ntlv *)v;
+
+ if (key.uidx < ntlv->idx)
+ return (-1);
+ else if (key.uidx > ntlv->idx)
+ return (1);
+
+ if (key.type < ntlv->head.type)
+ return (-1);
+ else if (key.type > ntlv->head.type)
+ return (1);
+
+ return (0);
+}
+
+/*
+ * Finds object name in @ctlv by @idx and @type.
+ * Uses the following facts:
+ * 1) All TLVs are the same size
+ * 2) Kernel implementation provides already sorted list.
+ *
+ * Returns table name or NULL.
+ */
+static char *
+object_search_ctlv(ipfw_obj_ctlv *ctlv, uint16_t idx, uint16_t type)
+{
+ ipfw_obj_ntlv *ntlv;
+ struct object_kt key;
+
+ key.uidx = idx;
+ key.type = type;
+
+ ntlv = bsearch(&key, (ctlv + 1), ctlv->count, ctlv->objsize,
+ compare_object_kntlv);
+
+ if (ntlv != 0)
+ return (ntlv->name);
+
+ return (NULL);
+}
+
+static char *
+table_search_ctlv(ipfw_obj_ctlv *ctlv, uint16_t idx)
+{
+
+ return (object_search_ctlv(ctlv, idx, IPFW_TLV_TBL_NAME));
+}
+
/*
* Adds one or more rules to ipfw chain.
* Data layout:
@@ -4719,7 +4835,7 @@ ipfw_add(char *av[])
ctlv->count = ts.count;
ctlv->objsize = sizeof(ipfw_obj_ntlv);
memcpy(ctlv + 1, ts.idx, tlen);
- table_sort_ctlv(ctlv);
+ object_sort_ctlv(ctlv);
tstate = ctlv;
/* Rule next */
ctlv = (ipfw_obj_ctlv *)((caddr_t)ctlv + ctlv->head.length);
diff --git a/sbin/ipfw/ipfw2.h b/sbin/ipfw/ipfw2.h
index 80970ef..5a08321 100644
--- a/sbin/ipfw/ipfw2.h
+++ b/sbin/ipfw/ipfw2.h
@@ -344,8 +344,6 @@ int fill_ext6hdr(struct _ipfw_insn *cmd, char *av);
/* tables.c */
struct _ipfw_obj_ctlv;
-char *table_search_ctlv(struct _ipfw_obj_ctlv *ctlv, uint16_t idx);
-void table_sort_ctlv(struct _ipfw_obj_ctlv *ctlv);
int table_check_name(char *tablename);
void ipfw_list_ta(int ac, char *av[]);
void ipfw_list_values(int ac, char *av[]);
diff --git a/sbin/ipfw/nat.c b/sbin/ipfw/nat.c
index 3bd0259..184b172 100644
--- a/sbin/ipfw/nat.c
+++ b/sbin/ipfw/nat.c
@@ -163,9 +163,9 @@ set_addr_dynamic(const char *ifn, struct nat44_cfg_nat *n)
}
}
if (sin == NULL)
- errx(1, "%s: cannot get interface address", ifn);
-
- n->ip = sin->sin_addr;
+ n->ip.s_addr = htonl(INADDR_ANY);
+ else
+ n->ip = sin->sin_addr;
strncpy(n->if_name, ifn, IF_NAMESIZE);
free(buf);
@@ -1008,11 +1008,10 @@ nat_foreach(nat_cb_t *f, void *arg, int sort)
olh->size = sz;
if (do_get3(IP_FW_NAT44_LIST_NAT, &olh->opheader, &sz) != 0) {
+ sz = olh->size;
free(olh);
- if (errno == ENOMEM) {
- sz = olh->size;
+ if (errno == ENOMEM)
continue;
- }
return (errno);
}
diff --git a/sbin/ipfw/tables.c b/sbin/ipfw/tables.c
index 4829fec..b3473fc 100644
--- a/sbin/ipfw/tables.c
+++ b/sbin/ipfw/tables.c
@@ -35,6 +35,7 @@
#include <netinet/in.h>
#include <netinet/ip_fw.h>
#include <arpa/inet.h>
+#include <netdb.h>
#include "ipfw2.h"
@@ -714,6 +715,7 @@ table_print_valheader(char *buf, size_t bufsize, uint32_t vmask)
return;
}
+ memset(buf, 0, bufsize);
print_flags_buffer(buf, bufsize, tablevaltypes, vmask);
}
@@ -1308,6 +1310,63 @@ tentry_fill_key_type(char *arg, ipfw_obj_tentry *tentry, uint8_t type,
tentry->masklen = masklen;
}
+/*
+ * Tries to guess table key type.
+ * This procedure is used in legacy table auto-create
+ * code AND in `ipfw -n` ruleset checking.
+ *
+ * Imported from old table_fill_xentry() parse code.
+ */
+static int
+guess_key_type(char *key, uint8_t *ptype)
+{
+ char *p;
+ struct in6_addr addr;
+ uint32_t kv;
+
+ if (ishexnumber(*key) != 0 || *key == ':') {
+ /* Remove / if exists */
+ if ((p = strchr(key, '/')) != NULL)
+ *p = '\0';
+
+ if ((inet_pton(AF_INET, key, &addr) == 1) ||
+ (inet_pton(AF_INET6, key, &addr) == 1)) {
+ *ptype = IPFW_TABLE_CIDR;
+ if (p != NULL)
+ *p = '/';
+ return (0);
+ } else {
+ /* Port or any other key */
+ /* Skip non-base 10 entries like 'fa1' */
+ kv = strtol(key, &p, 10);
+ if (*p == '\0') {
+ *ptype = IPFW_TABLE_NUMBER;
+ return (0);
+ } else if ((p != key) && (*p == '.')) {
+ /*
+ * Warn on IPv4 address strings
+ * which are "valid" for inet_aton() but not
+ * in inet_pton().
+ *
+ * Typical examples: '10.5' or '10.0.0.05'
+ */
+ return (1);
+ }
+ }
+ }
+
+ if (strchr(key, '.') == NULL) {
+ *ptype = IPFW_TABLE_INTERFACE;
+ return (0);
+ }
+
+ if (lookup_host(key, (struct in_addr *)&addr) != 0)
+ return (1);
+
+ *ptype = IPFW_TABLE_CIDR;
+ return (0);
+}
+
static void
tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key,
int add, uint8_t *ptype, uint32_t *pvmask, ipfw_xtable_info *xi)
@@ -1315,7 +1374,6 @@ tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key,
uint8_t type, tflags;
uint32_t vmask;
int error;
- char *del;
type = 0;
tflags = 0;
@@ -1327,10 +1385,24 @@ tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key,
error = 0;
if (error == 0) {
- /* Table found. */
- type = xi->type;
- tflags = xi->tflags;
- vmask = xi->vmask;
+ if (co.test_only == 0) {
+ /* Table found */
+ type = xi->type;
+ tflags = xi->tflags;
+ vmask = xi->vmask;
+ } else {
+ /*
+ * we're running `ipfw -n`
+ * Compability layer: try to guess key type
+ * before failing.
+ */
+ if (guess_key_type(key, &type) != 0) {
+ /* Inknown key */
+ errx(EX_USAGE, "Cannot guess "
+ "key '%s' type", key);
+ }
+ vmask = IPFW_VTYPE_LEGACY;
+ }
} else {
if (error != ESRCH)
errx(EX_OSERR, "Error requesting table %s info",
@@ -1339,24 +1411,16 @@ tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key,
errx(EX_DATAERR, "Table %s does not exist",
oh->ntlv.name);
/*
- * Table does not exist.
- * Compability layer: try to interpret data as ADDR
- * before failing.
+ * Table does not exist
+ * Compability layer: try to guess key type before failing.
*/
- if ((del = strchr(key, '/')) != NULL)
- *del = '\0';
- if (inet_pton(AF_INET, key, &tent->k.addr6) == 1 ||
- inet_pton(AF_INET6, key, &tent->k.addr6) == 1) {
- /* OK Prepare and send */
- type = IPFW_TABLE_ADDR;
- vmask = IPFW_VTYPE_LEGACY;
- } else {
+ if (guess_key_type(key, &type) != 0) {
/* Inknown key */
errx(EX_USAGE, "Table %s does not exist, cannot guess "
"key '%s' type", oh->ntlv.name, key);
}
- if (del != NULL)
- *del = '/';
+
+ vmask = IPFW_VTYPE_LEGACY;
}
tentry_fill_key_type(key, tent, type, tflags);
@@ -1384,6 +1448,7 @@ static void
tentry_fill_value(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *arg,
uint8_t type, uint32_t vmask)
{
+ struct addrinfo hints, *res;
uint32_t a4, flag, val, vm;
ipfw_table_value *v;
uint32_t i;
@@ -1494,9 +1559,19 @@ tentry_fill_value(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *arg,
}
break;
case IPFW_VTYPE_NH6:
- if (strchr(n, ':') != NULL &&
- inet_pton(AF_INET6, n, &v->nh6) == 1)
- break;
+ if (strchr(n, ':') != NULL) {
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET6;
+ hints.ai_flags = AI_NUMERICHOST;
+ if (getaddrinfo(n, NULL, &hints, &res) == 0) {
+ v->nh6 = ((struct sockaddr_in6 *)
+ res->ai_addr)->sin6_addr;
+ v->zoneid = ((struct sockaddr_in6 *)
+ res->ai_addr)->sin6_scope_id;
+ freeaddrinfo(res);
+ break;
+ }
+ }
etype = "ipv6";
break;
}
@@ -1643,10 +1718,11 @@ static void
table_show_value(char *buf, size_t bufsize, ipfw_table_value *v,
uint32_t vmask, int print_ip)
{
+ char abuf[INET6_ADDRSTRLEN + IF_NAMESIZE + 2];
+ struct sockaddr_in6 sa6;
uint32_t flag, i, l;
size_t sz;
struct in_addr a4;
- char abuf[INET6_ADDRSTRLEN];
sz = bufsize;
@@ -1702,8 +1778,15 @@ table_show_value(char *buf, size_t bufsize, ipfw_table_value *v,
l = snprintf(buf, sz, "%d,", v->dscp);
break;
case IPFW_VTYPE_NH6:
- inet_ntop(AF_INET6, &v->nh6, abuf, sizeof(abuf));
- l = snprintf(buf, sz, "%s,", abuf);
+ sa6.sin6_family = AF_INET6;
+ sa6.sin6_len = sizeof(sa6);
+ sa6.sin6_addr = v->nh6;
+ sa6.sin6_port = 0;
+ sa6.sin6_scope_id = v->zoneid;
+ if (getnameinfo((const struct sockaddr *)&sa6,
+ sa6.sin6_len, abuf, sizeof(abuf), NULL, 0,
+ NI_NUMERICHOST) == 0)
+ l = snprintf(buf, sz, "%s,", abuf);
break;
}
@@ -1862,11 +1945,12 @@ struct _table_value {
uint32_t nat; /* O_NAT */
uint32_t nh4;
uint8_t dscp;
- uint8_t spare0[3];
+ uint8_t spare0;
+ uint16_t spare1;
/* -- 32 bytes -- */
struct in6_addr nh6;
uint32_t limit; /* O_LIMIT */
- uint32_t spare1;
+ uint32_t zoneid;
uint64_t refcnt; /* Number of references */
};
@@ -1916,73 +2000,6 @@ ipfw_list_values(int ac, char *av[])
}
int
-compare_ntlv(const void *_a, const void *_b)
-{
- ipfw_obj_ntlv *a, *b;
-
- a = (ipfw_obj_ntlv *)_a;
- b = (ipfw_obj_ntlv *)_b;
-
- if (a->set < b->set)
- return (-1);
- else if (a->set > b->set)
- return (1);
-
- if (a->idx < b->idx)
- return (-1);
- else if (a->idx > b->idx)
- return (1);
-
- return (0);
-}
-
-int
-compare_kntlv(const void *k, const void *v)
-{
- ipfw_obj_ntlv *ntlv;
- uint16_t key;
-
- key = *((uint16_t *)k);
- ntlv = (ipfw_obj_ntlv *)v;
-
- if (key < ntlv->idx)
- return (-1);
- else if (key > ntlv->idx)
- return (1);
-
- return (0);
-}
-
-/*
- * Finds table name in @ctlv by @idx.
- * Uses the following facts:
- * 1) All TLVs are the same size
- * 2) Kernel implementation provides already sorted list.
- *
- * Returns table name or NULL.
- */
-char *
-table_search_ctlv(ipfw_obj_ctlv *ctlv, uint16_t idx)
-{
- ipfw_obj_ntlv *ntlv;
-
- ntlv = bsearch(&idx, (ctlv + 1), ctlv->count, ctlv->objsize,
- compare_kntlv);
-
- if (ntlv != 0)
- return (ntlv->name);
-
- return (NULL);
-}
-
-void
-table_sort_ctlv(ipfw_obj_ctlv *ctlv)
-{
-
- qsort(ctlv + 1, ctlv->count, ctlv->objsize, compare_ntlv);
-}
-
-int
table_check_name(char *tablename)
{
int c, i, l;
diff --git a/sbin/iscontrol/Makefile b/sbin/iscontrol/Makefile
index 9bdc29b..9c4d9f4 100644
--- a/sbin/iscontrol/Makefile
+++ b/sbin/iscontrol/Makefile
@@ -2,13 +2,12 @@
SRCS= iscontrol.c pdu.c fsm.c config.c login.c auth_subr.c misc.c
PROG= iscontrol
-DPADD= ${LIBCAM} ${LIBMD}
-LDADD= -lcam -lmd
+LIBADD= cam md
S= ${.CURDIR}/../../sys
WARNS?= 3
CFLAGS+= -I$S
-MAN= iscsi.conf.5 iscontrol.8
+MAN= iscontrol.8
.include <bsd.prog.mk>
diff --git a/sbin/iscontrol/iscontrol.8 b/sbin/iscontrol/iscontrol.8
index eee8776..36e0c47 100644
--- a/sbin/iscontrol/iscontrol.8
+++ b/sbin/iscontrol/iscontrol.8
@@ -43,7 +43,7 @@
.Sh DESCRIPTION
.Bf -symbolic
This command, along with its kernel counterpart
-.Xr iscsi_initiator 4 ,
+.Xr iscsi_initiator 4 ,
is obsolete.
Users are advised to use
.Xr iscsictl 8
@@ -121,8 +121,8 @@ whatever options are specified, and start an iscsi-session.
.Xr iscsi_initiator 4 ,
.Xr sa 4 ,
.Xr iscsi.conf 5 ,
-.Xr iscsictl 8 ,
-.Xr camcontrol 8
+.Xr camcontrol 8 ,
+.Xr iscsictl 8
.Sh STANDARDS
RFC 3720
.\"Sh HISTORY
diff --git a/sbin/iscontrol/iscsi.conf.5 b/sbin/iscontrol/iscsi.conf.5
deleted file mode 100644
index 2e7a68d..0000000
--- a/sbin/iscontrol/iscsi.conf.5
+++ /dev/null
@@ -1,188 +0,0 @@
-.\" Copyright (c) 2007-2010 Daniel Braniss <danny@cs.huji.ac.il>
-.\" 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$
-.\"
-.Dd December 17, 2013
-.Dt ISCSI.CONF 5
-.Os
-.Sh NAME
-.Nm iscsi.conf
-.Nd iSCSI initiator configuration file
-.Sh DESCRIPTION
-The file
-.Nm ,
-is used by the
-.Xr iscsictl 8
-and
-.Xr iscontrol 8
-utilities.
-It contains declarations and parameter/key-options.
-The syntax is very simple,
-.D1 Li variable = value;
-and they can be grouped via a
-.Em block
-declaration:
-.Bf Li
-.Bd -literal
- # this is a comment
- target_1 { # nickname
- variable = value;
- ...
- } # this must be on a line by itself.
-.Ed
-.Ef
-.Pp
-The following are specified in the iSCSI RFC 3720,
-for a full description see sections 11/12 of the RFC.
-.Bl -tag -width MaxConnections
-.It Cm AuthMethod
-currently only supported authentication method is CHAP, with
-digest either MD5 or SHA.
-Default is none.
-.It Cm HeaderDigest
-a
-.Em digest
-is calculated on the header of all iSCSI PDUs, and
-checked.
-Only CRC32C is implemented.
-Default is none.
-.It Cm DataDigest
-same as for HeaderDigest, but on the data part of the iSCSI PDU.
-(not yet tested)
-.It Cm TargetName
-is the name by which the target is known, not to be confused with
-target address, either obtained via the target administrator, or
-from a
-.Em discovery session .
-.It Cm InitiatorName
-if not specified, defaults to
-.Sy iqn.2005-01.il.ac.huji.cs:
-.Aq hostname .
-.It Cm TargetAddress
-is of the form
-.Sy domainname[:port][,portal-group-tag]
-to quote the RFC:
-.Bd -ragged -compact
-The domainname can be specified as either a DNS host name, a
-dotted-decimal IPv4 address, or a bracketed IPv6 address as specified
-in [RFC2732].
-.Ed
-Note: portal-group-tag is unused at the moment.
-.Em not implemented yet.
-.It Cm MaxRecvDataSegmentLength
-the maximum data segment length in
-bytes it can receive in an iSCSI PDU, default is 8192.
-.It Cm MaxOutstandingR2T
-is used to calculate/negotiate the
-.Em tag opening ,
-can be overridden by the
-.Sy tag
-option.
-.It Cm SessionType
-either Discovery or Normal, default is Normal, see the
-.Fl d
-flag of
-.Cm iscontrol .
-.El
-.sp
-The following are not specified in the
-.Sy RFC 3720
-.Bl -tag -width sockbufsize
-.It Cm port
-The iSCSI port used by the iSCSI protocol, defaults to 3260.
-.It Cm tags
-Sets the
-.Em tag opening
-to the value specified.
-.It Cm maxluns
-overrides the compiled value of
-.Sy luns ,
-see
-.Xr iscsi_initiator 4 .
-This value can only be reduced.
-.It Cm sockbufsize
-sets the receiver and transmitter socket buffer size to
-.Em size ,
-in kilobytes.
-The default is 128.
-.El
-.sp
-If
-.Em AuthMethod
-is set to
-.Cm CHAP ,
-then the following must also be set:
-.Bl -tag -width chapSecret
-.It Cm chapSecret
-this
-.Em shared-secret .
-Can be either an ASCII string (e.g. hello world), a hex string (e.g
-0xababcd0987654321...), or base64 string (eg 0b...)
-.It Cm chapIName
-the chap-name, defaults to
-.Em hostname .
-.It Cm chapDigest
-can be MD5 or SHA1.
-.It Cm tgtChapName/tgtChapSecret
-name and secret used for mutual CHAP; by default, mutual CHAP
-is not used.
-.El
-.Sh FILES
-.Bl -tag -width indent
-.It Pa /etc/iscsi.conf
-.El
-.Sh EXAMPLES
-.Bd -literal
-#
-# Globals
-#
-port = 3260
-#
-myiscsi { # nickname
- targetaddress = iscsi1
- targetname = iqn.1900.com.com:sn.123456
-}
-chaptest {
- targetaddress= 10.0.0.1;
- targetname = iqn.1900.com.com:sn.123456
- initiatorname= iqn.2005-01.il.ac.huji.cs:nobody
- authmethod = CHAP; chapDigest = SHA1;
- chapsecret = 0x3713c3336d9a224c2791c873d3d2b174
- tags = 256
-}
-.Ed
-.Sh SEE ALSO
-.Xr iscsi_initiator 4 ,
-.Xr iscsictl 8 ,
-.Xr iscontrol 8
-.Sh STANDARDS
-ISCSI RFC 3720
-.\"Sh HISTORY
-.\"Sh AUTHORS
-.Sh BUGS
-Some options have not been implemented, either they were found
-to be unnecessary, or not understood, this can change in the future.
-.br
-The tags opening value is difficult to calculate, use wisely.
diff --git a/sbin/md5/Makefile b/sbin/md5/Makefile
index eabf129..b6afe4e 100644
--- a/sbin/md5/Makefile
+++ b/sbin/md5/Makefile
@@ -13,10 +13,6 @@ MLINKS= md5.1 rmd160.1 \
md5.1 sha256.1 \
md5.1 sha512.1
-NO_WMISSING_VARIABLE_DECLARATIONS=
-WFORMAT?= 1
-
-DPADD= ${LIBMD}
-LDADD= -lmd
+LIBADD= md
.include <bsd.prog.mk>
diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c
index 823d09b..f4c56ac 100644
--- a/sbin/md5/md5.c
+++ b/sbin/md5/md5.c
@@ -42,11 +42,11 @@ __FBSDID("$FreeBSD$");
#define TEST_BLOCK_COUNT 100000
#define MDTESTCOUNT 8
-int qflag;
-int rflag;
-int sflag;
-unsigned char* checkAgainst;
-int checksFailed;
+static int qflag;
+static int rflag;
+static int sflag;
+static char* checkAgainst;
+static int checksFailed;
typedef void (DIGEST_Init)(void *);
typedef void (DIGEST_Update)(void *, const unsigned char *, size_t);
@@ -70,11 +70,11 @@ typedef struct Algorithm_t {
} Algorithm_t;
static void MD5_Update(MD5_CTX *, const unsigned char *, size_t);
-static void MDString(Algorithm_t *, const char *);
-static void MDTimeTrial(Algorithm_t *);
-static void MDTestSuite(Algorithm_t *);
-static void MDFilter(Algorithm_t *, int);
-static void usage(Algorithm_t *);
+static void MDString(const Algorithm_t *, const char *);
+static void MDTimeTrial(const Algorithm_t *);
+static void MDTestSuite(const Algorithm_t *);
+static void MDFilter(const Algorithm_t *, int);
+static void usage(const Algorithm_t *);
typedef union {
MD5_CTX md5;
@@ -91,7 +91,7 @@ typedef union {
/* algorithm function table */
-struct Algorithm_t Algorithm[] = {
+static const struct Algorithm_t Algorithm[] = {
{ "md5", "MD5", &MD5TestOutput, (DIGEST_Init*)&MD5Init,
(DIGEST_Update*)&MD5_Update, (DIGEST_End*)&MD5End,
&MD5Data, &MD5File },
@@ -216,7 +216,7 @@ main(int argc, char *argv[])
* Digests a string and prints the result.
*/
static void
-MDString(Algorithm_t *alg, const char *string)
+MDString(const Algorithm_t *alg, const char *string)
{
size_t len = strlen(string);
char buf[HEX_DIGEST_LENGTH];
@@ -240,7 +240,7 @@ MDString(Algorithm_t *alg, const char *string)
* Measures the time to digest TEST_BLOCK_COUNT TEST_BLOCK_LEN-byte blocks.
*/
static void
-MDTimeTrial(Algorithm_t *alg)
+MDTimeTrial(const Algorithm_t *alg)
{
DIGEST_CTX context;
struct rusage before, after;
@@ -282,7 +282,7 @@ MDTimeTrial(Algorithm_t *alg)
* Digests a reference suite of strings and prints the results.
*/
-const char *MDTestInput[MDTESTCOUNT] = {
+static const char *MDTestInput[MDTESTCOUNT] = {
"",
"a",
"abc",
@@ -350,7 +350,7 @@ const char *RIPEMD160_TestOutput[MDTESTCOUNT] = {
};
static void
-MDTestSuite(Algorithm_t *alg)
+MDTestSuite(const Algorithm_t *alg)
{
int i;
char buffer[HEX_DIGEST_LENGTH];
@@ -370,7 +370,7 @@ MDTestSuite(Algorithm_t *alg)
* Digests the standard input and prints the result.
*/
static void
-MDFilter(Algorithm_t *alg, int tee)
+MDFilter(const Algorithm_t *alg, int tee)
{
DIGEST_CTX context;
unsigned int len;
@@ -387,7 +387,7 @@ MDFilter(Algorithm_t *alg, int tee)
}
static void
-usage(Algorithm_t *alg)
+usage(const Algorithm_t *alg)
{
fprintf(stderr, "usage: %s [-pqrtx] [-c string] [-s string] [files ...]\n", alg->progname);
diff --git a/sbin/mdconfig/Makefile b/sbin/mdconfig/Makefile
index 69a688c..6be9129 100644
--- a/sbin/mdconfig/Makefile
+++ b/sbin/mdconfig/Makefile
@@ -5,8 +5,7 @@
PROG= mdconfig
MAN= mdconfig.8
-DPADD= ${LIBUTIL} ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF}
-LDADD= -lutil -lgeom -lbsdxml -lsbuf
+LIBADD= util geom
.if ${MK_TESTS} != "no"
SUBDIR+= tests
diff --git a/sbin/mdconfig/tests/Makefile b/sbin/mdconfig/tests/Makefile
index 17284bb..08a9e47 100644
--- a/sbin/mdconfig/tests/Makefile
+++ b/sbin/mdconfig/tests/Makefile
@@ -2,12 +2,9 @@
TESTSDIR= ${TESTSBASE}/sbin/mdconfig
-TAP_TESTS_SH= legacy_test
-TAP_TESTS_SH_SED_legacy_test= 's,__PERL__,${TAP_PERL_INTERPRETER},g'
-TEST_METADATA.legacy_test+= required_programs="${TAP_PERL_INTERPRETER}"
+ATF_TESTS_SH= mdconfig_test
-FILESDIR= ${TESTSDIR}
-FILES= mdconfig.test
-FILES+= run.pl
+
+TEST_METADATA.mdconfig_test+= required_user="root"
.include <bsd.test.mk>
diff --git a/sbin/mdconfig/tests/legacy_test.sh b/sbin/mdconfig/tests/legacy_test.sh
deleted file mode 100644
index 728224d..0000000
--- a/sbin/mdconfig/tests/legacy_test.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2012 Edward Tomasz Napierała <trasz@FreeBSD.org>
-# 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$
-#
-
-# This is a wrapper script to run mdconfig.test.
-
-echo "1..1"
-
-if [ `whoami` != "root" ]; then
- echo "ok 1 # skip You need to be root to run this test."
- exit 0
-fi
-
-TESTDIR=$(dirname $(realpath $0))
-
-__PERL__ -w -U $TESTDIR/run.pl $TESTDIR/mdconfig.test > /dev/null
-
-if [ $? -eq 0 ]; then
- echo "ok 1"
-else
- echo "not ok 1"
-fi
diff --git a/sbin/mdconfig/tests/mdconfig.test b/sbin/mdconfig/tests/mdconfig.test
deleted file mode 100644
index 65d3670..0000000
--- a/sbin/mdconfig/tests/mdconfig.test
+++ /dev/null
@@ -1,231 +0,0 @@
-# Copyright (c) 2012 Edward Tomasz Napierała <trasz@FreeBSD.org>
-# 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$
-#
-
-# This is a test for mdconfig(8) functionality. Run it as root:
-#
-# /usr/src/tools/regression/mdconfig/run /usr/src/tools/regression/mdconfig/mdconfig.test
-#
-# WARNING: Creates files in unsafe way.
-
-$ whoami
-> root
-$ umask 022
-$ truncate -s 1gb xxx
-
-$ mdconfig -l
-
-$ mdconfig -af xxx
-> md0
-
-# This awk thing is to strip the file path.
-$ mdconfig -lv | awk '{ print $1, $2, $3 }'
-> md0 vnode 1024M
-
-$ diskinfo -v /dev/md0 | expand
-> /dev/md0
-> 512 # sectorsize
-> 1073741824 # mediasize in bytes (1.0G)
-> 2097152 # mediasize in sectors
-> 0 # stripesize
-> 0 # stripeoffset
->
-
-$ mdconfig -du 0
-
-# Check different valid syntax variations: implicit -a.
-
-$ mdconfig xxx
-> md0
-
-$ mdconfig -lv | awk '{ print $1, $2, $3 }'
-> md0 vnode 1024M
-
-$ diskinfo -v /dev/md0 | expand
-> /dev/md0
-> 512 # sectorsize
-> 1073741824 # mediasize in bytes (1.0G)
-> 2097152 # mediasize in sectors
-> 0 # stripesize
-> 0 # stripeoffset
->
-
-$ mdconfig -du 0
-
-# Explicit -t vnode.
-
-$ mdconfig -a -t vnode -f xxx
-> md0
-
-$ mdconfig -lv | awk '{ print $1, $2, $3 }'
-> md0 vnode 1024M
-
-$ diskinfo -v /dev/md0 | expand
-> /dev/md0
-> 512 # sectorsize
-> 1073741824 # mediasize in bytes (1.0G)
-> 2097152 # mediasize in sectors
-> 0 # stripesize
-> 0 # stripeoffset
->
-
-$ mdconfig -du 0
-
-# Size for vnodes - smaller than the actual file.
-
-$ mdconfig -a -t vnode -f xxx -s 128m
-> md0
-
-$ mdconfig -lv | awk '{ print $1, $2, $3 }'
-> md0 vnode 128M
-
-$ diskinfo -v /dev/md0 | expand
-> /dev/md0
-> 512 # sectorsize
-> 134217728 # mediasize in bytes (128M)
-> 262144 # mediasize in sectors
-> 0 # stripesize
-> 0 # stripeoffset
->
-
-$ mdconfig -du 0
-
-# Size for vnodes - larger than the actual file.
-
-$ mdconfig -a -t vnode -f xxx -s 128g
-> md0
-
-$ mdconfig -lv | awk '{ print $1, $2, $3 }'
-> md0 vnode 128G
-
-$ diskinfo -v /dev/md0 | expand
-> /dev/md0
-> 512 # sectorsize
-> 137438953472 # mediasize in bytes (128G)
-> 268435456 # mediasize in sectors
-> 0 # stripesize
-> 0 # stripeoffset
->
-
-$ mdconfig -du 0
-
-# Sector size for vnodes.
-
-$ mdconfig -a -t vnode -f xxx -S 2048
-> md0
-
-$ mdconfig -lv | awk '{ print $1, $2, $3 }'
-> md0 vnode 1024M
-
-$ diskinfo -v /dev/md0 | expand
-> /dev/md0
-> 2048 # sectorsize
-> 1073741824 # mediasize in bytes (1.0G)
-> 524288 # mediasize in sectors
-> 0 # stripesize
-> 0 # stripeoffset
->
-
-$ mdconfig -du 0
-
-# Malloc type.
-
-$ mdconfig -a -t malloc -s 1g
-> md0
-
-$ mdconfig -lv | awk '{ print $1, $2, $3 }'
-> md0 malloc 1024M
-
-$ diskinfo -v /dev/md0 | expand
-> /dev/md0
-> 512 # sectorsize
-> 1073741824 # mediasize in bytes (1.0G)
-> 2097152 # mediasize in sectors
-> 0 # stripesize
-> 0 # stripeoffset
->
-
-$ mdconfig -du 0
-
-# Swap type.
-
-$ mdconfig -a -t swap -s 1g
-> md0
-
-$ mdconfig -lv | awk '{ print $1, $2, $3 }'
-> md0 swap 1024M
-
-$ diskinfo -v /dev/md0 | expand
-> /dev/md0
-> 512 # sectorsize
-> 1073741824 # mediasize in bytes (1.0G)
-> 2097152 # mediasize in sectors
-> 0 # stripesize
-> 0 # stripeoffset
->
-
-$ mdconfig -du 0
-
-# Attaching with a specific unit number.
-
-$ mdconfig -as 1g -u 42
-
-$ mdconfig -lv | awk '{ print $1, $2, $3 }'
-> md42 swap 1024M
-
-$ diskinfo -v /dev/md42 | expand
-> /dev/md42
-> 512 # sectorsize
-> 1073741824 # mediasize in bytes (1.0G)
-> 2097152 # mediasize in sectors
-> 0 # stripesize
-> 0 # stripeoffset
->
-
-$ mdconfig -du 42
-
-# Querying.
-
-$ mdconfig -as 1g
-> md0
-$ mdconfig -as 2g -u 42
-
-$ mdconfig -lv | awk '{ print $1, $2, $3 }'
-> md0 swap 1024M
-> md42 swap 2048M
-
-$ mdconfig -lvu 0 | awk '{ print $1, $2, $3 }'
-> md0 swap 1024M
-
-$ mdconfig -lvu 42 | awk '{ print $1, $2, $3 }'
-> md42 swap 2048M
-
-$ mdconfig -lvu 24 | awk '{ print $1, $2, $3 }'
-
-$ mdconfig -du 42
-$ mdconfig -du 0
-
-$ rm xxx
diff --git a/sbin/mdconfig/tests/mdconfig_test.sh b/sbin/mdconfig/tests/mdconfig_test.sh
new file mode 100755
index 0000000..d12e565
--- /dev/null
+++ b/sbin/mdconfig/tests/mdconfig_test.sh
@@ -0,0 +1,281 @@
+# Copyright (c) 2012 Edward Tomasz Napierała <trasz@FreeBSD.org>
+# 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$
+#
+
+check_diskinfo()
+{
+ local md=$1
+ local mediasize_in_bytes=$2
+ local mediasize_in_sectors=$3
+ local sectorsize=${4:-512}
+ local stripesize=${5:-0}
+ local stripeoffset=${6:-0}
+
+ atf_check -s exit:0 \
+ -o match:"/dev/$md *$sectorsize *$mediasize_in_bytes *$mediasize_in_sectors *$stripesize *$stripeoffset" \
+ -x "diskinfo /dev/$md | expand"
+}
+
+cleanup_common()
+{
+ if [ -f mdconfig.out ]; then
+ mdconfig -d -u $(sed -e 's/md//' mdconfig.out)
+ fi
+}
+
+atf_test_case attach_vnode_non_explicit_type cleanup
+attach_vnode_non_explicit_type_head()
+{
+ atf_set "descr" "Tests out -a / -f without -t"
+}
+attach_vnode_non_explicit_type_body()
+{
+ local md
+ local size_in_mb=1024
+
+ atf_check -s exit:0 -x "truncate -s ${size_in_mb}m xxx"
+ atf_check -s exit:0 -o save:mdconfig.out -x 'mdconfig -af xxx'
+ md=$(cat mdconfig.out)
+ atf_check -s exit:0 -o match:'^md[0-9]+$' -x "echo $md"
+ check_diskinfo "$md" "1073741824" "2097152"
+ # This awk strips the file path.
+ atf_check -s exit:0 -o match:"^$md vnode ${size_in_mb}M$" \
+ -x "mdconfig -lv | awk '\$1 == \"$md\" { print \$1, \$2, \$3 }'"
+}
+attach_vnode_non_explicit_type_cleanup()
+{
+ cleanup_common
+}
+
+atf_test_case attach_vnode_implicit_a_f cleanup
+attach_vnode_implicit_a_f_head()
+{
+ atf_set "descr" "Tests out implied -a / -f without -t"
+}
+attach_vnode_implicit_a_f_body()
+{
+ local md
+ local size_in_mb=1024
+
+ atf_check -s exit:0 -x "truncate -s ${size_in_mb}m xxx"
+ atf_check -s exit:0 -o save:mdconfig.out -x 'mdconfig xxx'
+ md=$(cat mdconfig.out)
+ atf_check -s exit:0 -o match:'^md[0-9]+$' -x "echo $md"
+ check_diskinfo "$md" "1073741824" "2097152"
+ # This awk strips the file path.
+ atf_check -s exit:0 -o match:"^$md vnode ${size_in_mb}M$" \
+ -x "mdconfig -lv | awk '\$1 == \"$md\" { print \$1, \$2, \$3 }'"
+}
+attach_vnode_implicit_a_f_cleanup()
+{
+ cleanup_common
+}
+
+atf_test_case attach_vnode_explicit_type cleanup
+attach_vnode_explicit_type_head()
+{
+ atf_set "descr" "Tests out implied -a / -f with -t vnode"
+}
+attach_vnode_explicit_type_body()
+{
+ local md
+ local size_in_mb=1024
+
+ atf_check -s exit:0 -x "truncate -s ${size_in_mb}m xxx"
+ atf_check -s exit:0 -o save:mdconfig.out -x 'mdconfig -af xxx -t vnode'
+ md=$(cat mdconfig.out)
+ atf_check -s exit:0 -o match:'^md[0-9]+$' -x "echo $md"
+ check_diskinfo "$md" "1073741824" "2097152"
+ # This awk strips the file path.
+ atf_check -s exit:0 -o match:"^$md vnode ${size_in_mb}M$" \
+ -x "mdconfig -lv | awk '\$1 == \"$md\" { print \$1, \$2, \$3 }'"
+}
+attach_vnode_explicit_type_cleanup()
+{
+ [ -f mdconfig.out ] && mdconfig -d -u $(sed -e 's/md//' mdconfig.out)
+ rm -f mdconfig.out xxx
+}
+
+atf_test_case attach_vnode_smaller_than_file cleanup
+attach_vnode_smaller_than_file_head()
+{
+ atf_set "descr" "Tests mdconfig -s with size less than the file size"
+}
+attach_vnode_smaller_than_file_body()
+{
+ local md
+ local size_in_mb=128
+
+ atf_check -s exit:0 -x "truncate -s 1024m xxx"
+ atf_check -s exit:0 -o save:mdconfig.out \
+ -x "mdconfig -af xxx -s ${size_in_mb}m"
+ md=$(cat mdconfig.out)
+ atf_check -s exit:0 -o match:'^md[0-9]+$' -x "echo $md"
+ check_diskinfo "$md" "134217728" "262144"
+ # This awk strips the file path.
+ atf_check -s exit:0 -o match:"^$md vnode ${size_in_mb}M$" \
+ -x "mdconfig -lv | awk '\$1 == \"$md\" { print \$1, \$2, \$3 }'"
+}
+attach_vnode_smaller_than_file_cleanup()
+{
+ cleanup_common
+}
+
+atf_test_case attach_vnode_larger_than_file cleanup
+attach_vnode_larger_than_file_head()
+{
+ atf_set "descr" "Tests mdconfig -s with size greater than the file size"
+}
+attach_vnode_larger_than_file_body()
+{
+ local md
+ local size_in_gb=128
+
+ atf_check -s exit:0 -x "truncate -s 1024m xxx"
+ atf_check -s exit:0 -o save:mdconfig.out \
+ -x "mdconfig -af xxx -s ${size_in_gb}g"
+ md=$(cat mdconfig.out)
+ atf_check -s exit:0 -o match:'^md[0-9]+$' -x "echo $md"
+ check_diskinfo "$md" "137438953472" "268435456"
+ # This awk strips the file path.
+ atf_check -s exit:0 -o match:"^$md vnode ${size_in_gb}G$" \
+ -x "mdconfig -lv | awk '\$1 == \"$md\" { print \$1, \$2, \$3 }'"
+}
+attach_vnode_larger_than_file_cleanup()
+{
+ cleanup_common
+}
+
+atf_test_case attach_vnode_sector_size cleanup
+attach_vnode_sector_size_head()
+{
+ atf_set "descr" "Tests mdconfig -s with size greater than the file size"
+}
+attach_vnode_sector_size_body()
+{
+ local md
+ local size_in_mb=1024
+
+ atf_check -s exit:0 -x "truncate -s ${size_in_mb}m xxx"
+ atf_check -s exit:0 -o save:mdconfig.out \
+ -x "mdconfig -af xxx -S 2048"
+ md=$(cat mdconfig.out)
+ atf_check -s exit:0 -o match:'^md[0-9]+$' -x "echo $md"
+ check_diskinfo "$md" "1073741824" "524288" "2048"
+ # This awk strips the file path.
+ atf_check -s exit:0 -o match:"^$md vnode ${size_in_mb}M$" \
+ -x "mdconfig -lv | awk '\$1 == \"$md\" { print \$1, \$2, \$3 }'"
+}
+attach_vnode_sector_size_cleanup()
+{
+ cleanup_common
+}
+
+atf_test_case attach_malloc cleanup
+attach_malloc_head()
+{
+ atf_set "descr" "Tests mdconfig with -t malloc"
+}
+attach_malloc_body()
+{
+ local md
+ local size_in_mb=1024
+
+ atf_check -s exit:0 -o save:mdconfig.out \
+ -x 'mdconfig -a -t malloc -s 1g'
+ md=$(cat mdconfig.out)
+ atf_check -s exit:0 -o match:'^md[0-9]+$' -x "echo $md"
+ check_diskinfo "$md" "1073741824" "2097152"
+ # This awk strips the file path.
+ atf_check -s exit:0 -o match:"^$md malloc ${size_in_mb}M$" \
+ -x "mdconfig -lv | awk '\$1 == \"$md\" { print \$1, \$2, \$3 }'"
+}
+attach_malloc_cleanup()
+{
+ cleanup_common
+}
+
+atf_test_case attach_swap cleanup
+attach_swap_head()
+{
+ atf_set "descr" "Tests mdconfig with -t swap"
+}
+attach_swap_body()
+{
+ local md
+ local size_in_mb=1024
+
+ atf_check -s exit:0 -o save:mdconfig.out \
+ -x 'mdconfig -a -t swap -s 1g'
+ md=$(cat mdconfig.out)
+ atf_check -s exit:0 -o match:'^md[0-9]+$' -x "echo $md"
+ check_diskinfo "$md" "1073741824" "2097152"
+ # This awk strips the file path.
+ atf_check -s exit:0 -o match:"^$md swap ${size_in_mb}M$" \
+ -x "mdconfig -lv | awk '\$1 == \"$md\" { print \$1, \$2, \$3 }'"
+}
+attach_swap_cleanup()
+{
+ cleanup_common
+}
+
+atf_test_case attach_with_specific_unit_number cleanup
+attach_with_specific_unit_number_head()
+{
+ atf_set "descr" "Tests mdconfig with a unit specified by -u"
+}
+attach_with_specific_unit_number_body()
+{
+ local md_unit=99
+ local size_in_mb=10
+
+ local md="md${md_unit}"
+
+ echo "$md" > mdconfig.out
+
+ atf_check -s exit:0 -o empty \
+ -x "mdconfig -a -t malloc -s ${size_in_mb}m -u $md_unit"
+ check_diskinfo "$md" "10485760" "20480"
+ # This awk strips the file path.
+ atf_check -s exit:0 -o match:"^$md malloc "$size_in_mb"M$" \
+ -x "mdconfig -lv | awk '\$1 == \"$md\" { print \$1, \$2, \$3 }'"
+}
+attach_with_specific_unit_number_cleanup()
+{
+ cleanup_common
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case attach_vnode_non_explicit_type
+ atf_add_test_case attach_vnode_explicit_type
+ atf_add_test_case attach_vnode_smaller_than_file
+ atf_add_test_case attach_vnode_larger_than_file
+ atf_add_test_case attach_vnode_sector_size
+ atf_add_test_case attach_malloc
+ atf_add_test_case attach_swap
+ atf_add_test_case attach_with_specific_unit_number
+}
diff --git a/sbin/mdconfig/tests/run.pl b/sbin/mdconfig/tests/run.pl
deleted file mode 100644
index 383f47e..0000000
--- a/sbin/mdconfig/tests/run.pl
+++ /dev/null
@@ -1,329 +0,0 @@
-#!/usr/bin/perl -w -U
-
-# Copyright (c) 2007, 2008 Andreas Gruenbacher.
-# 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,
-# without modification, immediately at the beginning of the file.
-# 2. The name of the author may not be used to endorse or promote products
-# derived from this software without specific prior written permission.
-#
-# Alternatively, this software may be distributed under the terms of the
-# GNU Public License ("GPL").
-#
-# 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$
-#
-
-#
-# Possible improvements:
-#
-# - distinguish stdout and stderr output
-# - add environment variable like assignments
-# - run up to a specific line
-# - resume at a specific line
-#
-
-use strict;
-use FileHandle;
-use Getopt::Std;
-use POSIX qw(isatty setuid getcwd);
-use vars qw($opt_l $opt_v);
-
-no warnings qw(taint);
-
-$opt_l = ~0; # a really huge number
-getopts('l:v');
-
-my ($OK, $FAILED) = ("ok", "failed");
-if (isatty(fileno(STDOUT))) {
- $OK = "\033[32m" . $OK . "\033[m";
- $FAILED = "\033[31m\033[1m" . $FAILED . "\033[m";
-}
-
-sub exec_test($$);
-sub process_test($$$$);
-
-my ($prog, $in, $out) = ([], [], []);
-my $prog_line = 0;
-my ($tests, $failed) = (0,0);
-my $lineno;
-my $width = ($ENV{COLUMNS} || 80) >> 1;
-
-for (;;) {
- my $line = <>; $lineno++;
- if (defined $line) {
- # Substitute %VAR and %{VAR} with environment variables.
- $line =~ s[%(\w+)][$ENV{$1}]eg;
- $line =~ s[%{(\w+)}][$ENV{$1}]eg;
- }
- if (defined $line) {
- if ($line =~ s/^\s*< ?//) {
- push @$in, $line;
- } elsif ($line =~ s/^\s*> ?//) {
- push @$out, $line;
- } else {
- process_test($prog, $prog_line, $in, $out);
- last if $prog_line >= $opt_l;
-
- $prog = [];
- $prog_line = 0;
- }
- if ($line =~ s/^\s*\$ ?//) {
- $prog = [ map { s/\\(.)/$1/g; $_ } split /(?<!\\)\s+/, $line ];
- $prog_line = $lineno;
- $in = [];
- $out = [];
- }
- } else {
- process_test($prog, $prog_line, $in, $out);
- last;
- }
-}
-
-my $status = sprintf("%d commands (%d passed, %d failed)",
- $tests, $tests-$failed, $failed);
-if (isatty(fileno(STDOUT))) {
- if ($failed) {
- $status = "\033[31m\033[1m" . $status . "\033[m";
- } else {
- $status = "\033[32m" . $status . "\033[m";
- }
-}
-print $status, "\n";
-exit $failed ? 1 : 0;
-
-
-sub process_test($$$$) {
- my ($prog, $prog_line, $in, $out) = @_;
-
- return unless @$prog;
-
- my $p = [ @$prog ];
- print "[$prog_line] \$ ", join(' ',
- map { s/\s/\\$&/g; $_ } @$p), " -- ";
- my $result = exec_test($prog, $in);
- my @good = ();
- my $nmax = (@$out > @$result) ? @$out : @$result;
- for (my $n=0; $n < $nmax; $n++) {
- my $use_re;
- if (defined $out->[$n] && $out->[$n] =~ /^~ /) {
- $use_re = 1;
- $out->[$n] =~ s/^~ //g;
- }
-
- if (!defined($out->[$n]) || !defined($result->[$n]) ||
- (!$use_re && $result->[$n] ne $out->[$n]) ||
- ( $use_re && $result->[$n] !~ /^$out->[$n]/)) {
- push @good, ($use_re ? '!~' : '!=');
- }
- else {
- push @good, ($use_re ? '=~' : '==');
- }
- }
- my $good = !(grep /!/, @good);
- $tests++;
- $failed++ unless $good;
- print $good ? $OK : $FAILED, "\n";
- if (!$good || $opt_v) {
- for (my $n=0; $n < $nmax; $n++) {
- my $l = defined($out->[$n]) ? $out->[$n] : "~";
- chomp $l;
- my $r = defined($result->[$n]) ? $result->[$n] : "~";
- chomp $r;
- print sprintf("%-" . ($width-3) . "s %s %s\n",
- $r, $good[$n], $l);
- }
- }
-}
-
-
-sub su($) {
- my ($user) = @_;
-
- $user ||= "root";
-
- my ($login, $pass, $uid, $gid) = getpwnam($user)
- or return [ "su: user $user does not exist\n" ];
- my @groups = ();
- my $fh = new FileHandle("/etc/group")
- or return [ "opening /etc/group: $!\n" ];
- while (<$fh>) {
- chomp;
- my ($group, $passwd, $gid, $users) = split /:/;
- foreach my $u (split /,/, $users) {
- push @groups, $gid
- if ($user eq $u);
- }
- }
- $fh->close;
-
- my $groups = join(" ", ($gid, $gid, @groups));
- #print STDERR "[[$groups]]\n";
- $! = 0; # reset errno
- $> = 0;
- $( = $gid;
- $) = $groups;
- if ($!) {
- return [ "su: $!\n" ];
- }
- if ($uid != 0) {
- $> = $uid;
- #$< = $uid;
- if ($!) {
- return [ "su: $prog->[1]: $!\n" ];
- }
- }
- #print STDERR "[($>,$<)($(,$))]";
- return [];
-}
-
-
-sub sg($) {
- my ($group) = @_;
-
- my $gid = getgrnam($group)
- or return [ "sg: group $group does not exist\n" ];
- my %groups = map { $_ eq $gid ? () : ($_ => 1) } (split /\s/, $));
-
- #print STDERR "<<", join("/", keys %groups), ">>\n";
- my $groups = join(" ", ($gid, $gid, keys %groups));
- #print STDERR "[[$groups]]\n";
- $! = 0; # reset errno
- if ($> != 0) {
- my $uid = $>;
- $> = 0;
- $( = $gid;
- $) = $groups;
- $> = $uid;
- } else {
- $( = $gid;
- $) = $groups;
- }
- if ($!) {
- return [ "sg: $!\n" ];
- }
- print STDERR "[($>,$<)($(,$))]";
- return [];
-}
-
-
-sub exec_test($$) {
- my ($prog, $in) = @_;
- local (*IN, *IN_DUP, *IN2, *OUT_DUP, *OUT, *OUT2);
- my $needs_shell = (join('', @$prog) =~ /[][|<>"'`\$\*\?]/);
-
- if ($prog->[0] eq "umask") {
- umask oct $prog->[1];
- return [];
- } elsif ($prog->[0] eq "cd") {
- if (!chdir $prog->[1]) {
- return [ "chdir: $prog->[1]: $!\n" ];
- }
- $ENV{PWD} = getcwd;
- return [];
- } elsif ($prog->[0] eq "su") {
- return su($prog->[1]);
- } elsif ($prog->[0] eq "sg") {
- return sg($prog->[1]);
- } elsif ($prog->[0] eq "export") {
- my ($name, $value) = split /=/, $prog->[1];
- # FIXME: need to evaluate $value, so that things like this will work:
- # export dir=$PWD/dir
- $ENV{$name} = $value;
- return [];
- } elsif ($prog->[0] eq "unset") {
- delete $ENV{$prog->[1]};
- return [];
- }
-
- pipe *IN2, *OUT
- or die "Can't create pipe for reading: $!";
- open *IN_DUP, "<&STDIN"
- or *IN_DUP = undef;
- open *STDIN, "<&IN2"
- or die "Can't duplicate pipe for reading: $!";
- close *IN2;
-
- open *OUT_DUP, ">&STDOUT"
- or die "Can't duplicate STDOUT: $!";
- pipe *IN, *OUT2
- or die "Can't create pipe for writing: $!";
- open *STDOUT, ">&OUT2"
- or die "Can't duplicate pipe for writing: $!";
- close *OUT2;
-
- *STDOUT->autoflush();
- *OUT->autoflush();
-
- $SIG{CHLD} = 'IGNORE';
-
- if (fork()) {
- # Server
- if (*IN_DUP) {
- open *STDIN, "<&IN_DUP"
- or die "Can't duplicate STDIN: $!";
- close *IN_DUP
- or die "Can't close STDIN duplicate: $!";
- }
- open *STDOUT, ">&OUT_DUP"
- or die "Can't duplicate STDOUT: $!";
- close *OUT_DUP
- or die "Can't close STDOUT duplicate: $!";
-
- foreach my $line (@$in) {
- #print "> $line";
- print OUT $line;
- }
- close *OUT
- or die "Can't close pipe for writing: $!";
-
- my $result = [];
- while (<IN>) {
- #print "< $_";
- if ($needs_shell) {
- s#^/bin/sh: line \d+: ##;
- }
- push @$result, $_;
- }
- return $result;
- } else {
- # Client
- $< = $>;
- close IN
- or die "Can't close read end for input pipe: $!";
- close OUT
- or die "Can't close write end for output pipe: $!";
- close OUT_DUP
- or die "Can't close STDOUT duplicate: $!";
- local *ERR_DUP;
- open ERR_DUP, ">&STDERR"
- or die "Can't duplicate STDERR: $!";
- open STDERR, ">&STDOUT"
- or die "Can't join STDOUT and STDERR: $!";
-
- if ($needs_shell) {
- exec ('/bin/sh', '-c', join(" ", @$prog));
- } else {
- exec @$prog;
- }
- print STDERR $prog->[0], ": $!\n";
- exit;
- }
-}
-
diff --git a/sbin/mount/Makefile b/sbin/mount/Makefile
index c4d98f0..f95085a 100644
--- a/sbin/mount/Makefile
+++ b/sbin/mount/Makefile
@@ -6,7 +6,6 @@ SRCS= mount.c mount_fs.c getmntopts.c vfslist.c
MAN= mount.8 mount.conf.8
# We do NOT install the getmntopts.3 man page.
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+LIBADD= util
.include <bsd.prog.mk>
diff --git a/sbin/mount/mount.8 b/sbin/mount/mount.8
index bfa70b6..2b1ac52 100644
--- a/sbin/mount/mount.8
+++ b/sbin/mount/mount.8
@@ -28,7 +28,7 @@
.\" @(#)mount.8 8.8 (Berkeley) 6/16/94
.\" $FreeBSD$
.\"
-.Dd August 20, 2014
+.Dd December 3, 2014
.Dt MOUNT 8
.Os
.Sh NAME
@@ -457,7 +457,6 @@ However, for the following file system types:
.Cm msdosfs ,
.Cm nfs ,
.Cm nullfs ,
-.Cm oldnfs ,
.Cm smbfs ,
.Cm udf ,
and
@@ -548,6 +547,9 @@ support for a particular file system might be provided either on a static
.Xr ext2fs 5 ,
.Xr fstab 5 ,
.Xr procfs 5 ,
+.Xr tmpfs 5 ,
+.Xr automount 8 ,
+.Xr fstyp 8 ,
.Xr kldload 8 ,
.Xr mount_cd9660 8 ,
.Xr mount_msdosfs 8 ,
@@ -556,7 +558,6 @@ support for a particular file system might be provided either on a static
.Xr mount_smbfs 8 ,
.Xr mount_udf 8 ,
.Xr mount_unionfs 8 ,
-.Xr tmpfs 5 ,
.Xr umount 8 ,
.Xr zfs 8 ,
.Xr zpool 8
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c
index 5ea45df..6427fc8 100644
--- a/sbin/mount/mount.c
+++ b/sbin/mount/mount.c
@@ -144,7 +144,7 @@ use_mountprog(const char *vfstype)
unsigned int i;
const char *fs[] = {
"cd9660", "mfs", "msdosfs", "nfs",
- "nullfs", "oldnfs", "smbfs", "udf", "unionfs",
+ "nullfs", "smbfs", "udf", "unionfs",
NULL
};
diff --git a/sbin/mount_cd9660/Makefile b/sbin/mount_cd9660/Makefile
index b889174..c70892c 100644
--- a/sbin/mount_cd9660/Makefile
+++ b/sbin/mount_cd9660/Makefile
@@ -4,8 +4,7 @@
PROG= mount_cd9660
SRCS= mount_cd9660.c getmntopts.c
MAN= mount_cd9660.8
-DPADD= ${LIBKICONV}
-LDADD= -lkiconv
+LIBADD= kiconv
MOUNT= ${.CURDIR}/../mount
CFLAGS+= -I${MOUNT}
diff --git a/sbin/mount_fusefs/mount_fusefs.8 b/sbin/mount_fusefs/mount_fusefs.8
index 3e11cf1..3faf618 100644
--- a/sbin/mount_fusefs/mount_fusefs.8
+++ b/sbin/mount_fusefs/mount_fusefs.8
@@ -326,8 +326,8 @@ does not call any external utility and also provides a hacky
.Sh SEE ALSO
.Xr fstat 1 ,
.Xr mount 8 ,
-.Xr umount 8 ,
-.Xr sudo 8
+.Xr sudo 8 ,
+.Xr umount 8
.Sh HISTORY
.Nm
appears as the part of the FreeBSD implementation of the Fuse userspace filesystem
diff --git a/sbin/mount_fusefs/mount_fusefs.c b/sbin/mount_fusefs/mount_fusefs.c
index 797aba7..7d4b9a1 100644
--- a/sbin/mount_fusefs/mount_fusefs.c
+++ b/sbin/mount_fusefs/mount_fusefs.c
@@ -73,6 +73,13 @@ static struct mntopt mopts[] = {
{ "subtype=", 0, ALTF_SUBTYPE, 1 },
#define ALTF_SYNC_UNMOUNT 0x80
{ "sync_unmount", 0, ALTF_SYNC_UNMOUNT, 1 },
+ /*
+ * MOPT_AUTOMOUNTED, included by MOPT_STDOPTS, does not fit into
+ * the 'flags' argument to nmount(2). We have to abuse altflags
+ * to pass it, as string, via iovec.
+ */
+ #define ALTF_AUTOMOUNTED 0x100
+ { "automounted", 0, ALTF_AUTOMOUNTED, 1 },
/* Linux specific options, we silently ignore them */
{ "fsname=", 0, 0x00, 1 },
{ "fd=", 0, 0x00, 1 },
diff --git a/sbin/mount_msdosfs/Makefile b/sbin/mount_msdosfs/Makefile
index c3e416a..ede86b4 100644
--- a/sbin/mount_msdosfs/Makefile
+++ b/sbin/mount_msdosfs/Makefile
@@ -5,8 +5,7 @@
PROG= mount_msdosfs
SRCS= mount_msdosfs.c getmntopts.c
MAN= mount_msdosfs.8
-DPADD= ${LIBKICONV}
-LDADD= -lkiconv
+LIBADD= kiconv
MOUNT= ${.CURDIR}/../mount
CFLAGS+= -I${MOUNT}
diff --git a/sbin/mount_nfs/Makefile b/sbin/mount_nfs/Makefile
index eceed2b..75f7817 100644
--- a/sbin/mount_nfs/Makefile
+++ b/sbin/mount_nfs/Makefile
@@ -5,14 +5,11 @@
PROG= mount_nfs
SRCS= mount_nfs.c getmntopts.c mounttab.c
MAN= mount_nfs.8
-MLINKS= mount_nfs.8 mount_oldnfs.8
MOUNT= ${.CURDIR}/../mount
UMNTALL= ${.CURDIR}/../../usr.sbin/rpc.umntall
CFLAGS+= -DNFS -I${MOUNT} -I${UMNTALL}
-LINKS= ${BINDIR}/mount_nfs ${BINDIR}/mount_oldnfs
-
.PATH: ${MOUNT} ${UMNTALL}
.include <bsd.prog.mk>
diff --git a/sbin/mount_nfs/mount_nfs.8 b/sbin/mount_nfs/mount_nfs.8
index 473f519..3a9cff5 100644
--- a/sbin/mount_nfs/mount_nfs.8
+++ b/sbin/mount_nfs/mount_nfs.8
@@ -63,12 +63,6 @@ It implements the mount protocol as described in RFC 1094, Appendix A and
.%T "NFS: Network File System Version 3 Protocol Specification" ,
Appendix I.
.Pp
-If the file system type is specified as ``oldnfs'', which implies this
-command is run as ``mount_oldnfs'', then it forces use of the old NFS
-client, which does not support the
-.Cm nfsv4
-option.
-.Pp
By default,
.Nm
keeps retrying until the mount succeeds.
@@ -393,7 +387,7 @@ Use the specified version number for NFS requests.
See the
.Cm nfsv2 ,
.Cm nfsv3 ,
-and
+and
.Cm nfsv4
options for details.
.It Cm wcommitsize Ns = Ns Aq Ar value
diff --git a/sbin/mount_udf/Makefile b/sbin/mount_udf/Makefile
index 06ad9a7..12d5d58 100644
--- a/sbin/mount_udf/Makefile
+++ b/sbin/mount_udf/Makefile
@@ -3,8 +3,7 @@
PROG= mount_udf
SRCS= mount_udf.c getmntopts.c
MAN= mount_udf.8
-DPADD= ${LIBKICONV}
-LDADD= -lkiconv
+LIBADD= kiconv
MOUNT= ${.CURDIR}/../mount
CFLAGS+= -I${MOUNT} -I${.CURDIR}/../../sys
diff --git a/sbin/nandfs/Makefile b/sbin/nandfs/Makefile
index 8474b09..5757f8c 100644
--- a/sbin/nandfs/Makefile
+++ b/sbin/nandfs/Makefile
@@ -4,7 +4,6 @@ PROG= nandfs
SRCS= nandfs.c lssnap.c mksnap.c rmsnap.c
MAN= nandfs.8
-DPADD= ${LIBNANDFS}
-LDADD= -lnandfs
+LIBADD= nandfs
.include <bsd.prog.mk>
diff --git a/sbin/natd/Makefile b/sbin/natd/Makefile
index 7d8b3e4..44e5b6f 100644
--- a/sbin/natd/Makefile
+++ b/sbin/natd/Makefile
@@ -3,8 +3,7 @@
PROG = natd
SRCS = natd.c icmp.c
WARNS?= 3
-LDADD = -lalias
-DPADD = ${LIBALIAS}
+LIBADD = alias
MAN = natd.8
.include <bsd.prog.mk>
diff --git a/sbin/newfs/Makefile b/sbin/newfs/Makefile
index d45143b..83801fd 100644
--- a/sbin/newfs/Makefile
+++ b/sbin/newfs/Makefile
@@ -4,8 +4,7 @@
.PATH: ${.CURDIR}/../../sys/geom
PROG= newfs
-DPADD= ${LIBUFS} ${LIBUTIL}
-LDADD= -lufs -lutil
+LIBADD= ufs util
SRCS= newfs.c mkfs.c geom_bsd_enc.c
WARNS?= 3
diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8
index 6764adc..a4c0358 100644
--- a/sbin/newfs/newfs.8
+++ b/sbin/newfs/newfs.8
@@ -310,10 +310,10 @@ on file systems that contain many small files.
.Xr fsck 8 ,
.Xr gjournal 8 ,
.Xr growfs 8 ,
+.Xr gvinum 8 ,
.Xr makefs 8 ,
.Xr mount 8 ,
-.Xr tunefs 8 ,
-.Xr gvinum 8
+.Xr tunefs 8
.Rs
.%A M. McKusick
.%A W. Joy
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index 59b7e61..658bd42 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -117,11 +117,9 @@ static u_char bootarea[BBSIZE];
static int is_file; /* work on a file, not a device */
static char *dkname;
static char *disktype;
-static int unlabeled;
static void getfssize(intmax_t *, const char *p, intmax_t, intmax_t);
static struct disklabel *getdisklabel(char *s);
-static void rewritelabel(char *s, struct disklabel *lp);
static void usage(void);
static int expand_number_int(const char *buf, int *num);
@@ -402,12 +400,6 @@ main(int argc, char *argv[])
pp->p_size *= secperblk;
}
mkfs(pp, special);
- if (!unlabeled) {
- if (realsectorsize != DEV_BSIZE)
- pp->p_size /= realsectorsize / DEV_BSIZE;
- if (!Nflag && bcmp(pp, &oldpartition, sizeof(oldpartition)))
- rewritelabel(special, lp);
- }
ufs_disk_close(&disk);
if (!jflag)
exit(0);
@@ -451,9 +443,6 @@ getdisklabel(char *s)
return &lab;
}
- if (ioctl(disk.d_fd, DIOCGDINFO, (char *)&lab) != -1)
- return (&lab);
- unlabeled++;
if (disktype) {
lp = getdiskbyname(disktype);
if (lp != NULL)
@@ -462,25 +451,6 @@ getdisklabel(char *s)
return (NULL);
}
-void
-rewritelabel(char *s, struct disklabel *lp)
-{
- if (unlabeled)
- return;
- lp->d_checksum = 0;
- lp->d_checksum = dkcksum(lp);
- if (is_file) {
- bsd_disklabel_le_enc(bootarea + 0 /* labeloffset */ +
- 1 /* labelsoffset */ * sectorsize, lp);
- lseek(disk.d_fd, 0, SEEK_SET);
- if (write(disk.d_fd, bootarea, BBSIZE) != BBSIZE)
- errx(1, "cannot write label");
- return;
- }
- if (ioctl(disk.d_fd, DIOCWDINFO, (char *)lp) == -1)
- warn("ioctl (WDINFO): %s: can't rewrite disk label", s);
-}
-
static void
usage()
{
diff --git a/sbin/newfs_msdos/newfs_msdos.8 b/sbin/newfs_msdos/newfs_msdos.8
index d61043a..0f1abb4 100644
--- a/sbin/newfs_msdos/newfs_msdos.8
+++ b/sbin/newfs_msdos/newfs_msdos.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 1, 2013
+.Dd April 9, 2015
.Dt NEWFS_MSDOS 8
.Os
.Sh NAME
@@ -112,7 +112,7 @@ only those characters permitted in regular DOS (8+3) filenames.
.It Fl O Ar OEM
OEM string (up to 8 characters).
The default is
-.Qq Li "BSD 4.4" .
+.Qq Li "BSD4.4 " .
.It Fl S Ar sector-size
Number of bytes per sector.
Acceptable values are powers of 2
diff --git a/sbin/newfs_msdos/newfs_msdos.c b/sbin/newfs_msdos/newfs_msdos.c
index f315d98..4685782 100644
--- a/sbin/newfs_msdos/newfs_msdos.c
+++ b/sbin/newfs_msdos/newfs_msdos.c
@@ -829,28 +829,26 @@ getdiskinfo(int fd, const char *fname, const char *dtype, __unused int oflag,
if (lp == NULL) {
if (bpb->bpbBytesPerSec)
dlp.d_secsize = bpb->bpbBytesPerSec;
- if (ioctl(fd, DIOCGDINFO, &dlp) == -1) {
- if (bpb->bpbBytesPerSec == 0 && ioctl(fd, DIOCGSECTORSIZE,
- &dlp.d_secsize) == -1)
- err(1, "cannot get sector size");
+ if (bpb->bpbBytesPerSec == 0 && ioctl(fd, DIOCGSECTORSIZE,
+ &dlp.d_secsize) == -1)
+ err(1, "cannot get sector size");
- dlp.d_secperunit = ms / dlp.d_secsize;
+ dlp.d_secperunit = ms / dlp.d_secsize;
- if (bpb->bpbSecPerTrack == 0 && ioctl(fd, DIOCGFWSECTORS,
- &dlp.d_nsectors) == -1) {
- warn("cannot get number of sectors per track");
- dlp.d_nsectors = 63;
- }
- if (bpb->bpbHeads == 0 &&
- ioctl(fd, DIOCGFWHEADS, &dlp.d_ntracks) == -1) {
- warn("cannot get number of heads");
- if (dlp.d_secperunit <= 63*1*1024)
- dlp.d_ntracks = 1;
- else if (dlp.d_secperunit <= 63*16*1024)
- dlp.d_ntracks = 16;
- else
- dlp.d_ntracks = 255;
- }
+ if (bpb->bpbSecPerTrack == 0 && ioctl(fd, DIOCGFWSECTORS,
+ &dlp.d_nsectors) == -1) {
+ warn("cannot get number of sectors per track");
+ dlp.d_nsectors = 63;
+ }
+ if (bpb->bpbHeads == 0 &&
+ ioctl(fd, DIOCGFWHEADS, &dlp.d_ntracks) == -1) {
+ warn("cannot get number of heads");
+ if (dlp.d_secperunit <= 63*1*1024)
+ dlp.d_ntracks = 1;
+ else if (dlp.d_secperunit <= 63*16*1024)
+ dlp.d_ntracks = 16;
+ else
+ dlp.d_ntracks = 255;
}
hs = (ms / dlp.d_secsize) - dlp.d_secperunit;
diff --git a/sbin/newfs_nandfs/Makefile b/sbin/newfs_nandfs/Makefile
index 1d990ed..7a39fbb 100644
--- a/sbin/newfs_nandfs/Makefile
+++ b/sbin/newfs_nandfs/Makefile
@@ -3,7 +3,6 @@
PROG= newfs_nandfs
MAN= newfs_nandfs.8
-LDADD+= -lgeom
-DPADD+= ${LIBGEOM}
+LIBADD= geom
.include <bsd.prog.mk>
diff --git a/sbin/pfctl/Makefile b/sbin/pfctl/Makefile
index 937f403..de3b7ec 100644
--- a/sbin/pfctl/Makefile
+++ b/sbin/pfctl/Makefile
@@ -28,7 +28,6 @@ CFLAGS+= -DWITH_INET
YFLAGS=
-LDADD+= -lm -lmd
-DPADD+= ${LIBM} ${LIBMD}
+LIBADD= m md
.include <bsd.prog.mk>
diff --git a/sbin/pfctl/Makefile.depend b/sbin/pfctl/Makefile.depend
index 3114c66..4ce935d 100644
--- a/sbin/pfctl/Makefile.depend
+++ b/sbin/pfctl/Makefile.depend
@@ -13,6 +13,7 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libmd \
lib/msun \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 99c26c0..aebf8a7 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -44,10 +44,10 @@ __FBSDID("$FreeBSD$");
#include <netinet/icmp6.h>
#include <net/pfvar.h>
#include <arpa/inet.h>
-#include <altq/altq.h>
-#include <altq/altq_cbq.h>
-#include <altq/altq_priq.h>
-#include <altq/altq_hfsc.h>
+#include <net/altq/altq.h>
+#include <net/altq/altq_cbq.h>
+#include <net/altq/altq_priq.h>
+#include <net/altq/altq_hfsc.h>
#include <stdio.h>
#include <unistd.h>
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index f90fd70..c1ba12f 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/in.h>
#include <net/pfvar.h>
#include <arpa/inet.h>
-#include <altq/altq.h>
+#include <net/altq/altq.h>
#include <sys/sysctl.h>
#include <err.h>
diff --git a/sbin/pfctl/pfctl_altq.c b/sbin/pfctl/pfctl_altq.c
index ae566f8..64f474c 100644
--- a/sbin/pfctl/pfctl_altq.c
+++ b/sbin/pfctl/pfctl_altq.c
@@ -38,10 +38,10 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-#include <altq/altq.h>
-#include <altq/altq_cbq.h>
-#include <altq/altq_priq.h>
-#include <altq/altq_hfsc.h>
+#include <net/altq/altq.h>
+#include <net/altq/altq_cbq.h>
+#include <net/altq/altq_priq.h>
+#include <net/altq/altq_hfsc.h>
#include "pfctl_parser.h"
#include "pfctl.h"
diff --git a/sbin/pfctl/pfctl_qstats.c b/sbin/pfctl/pfctl_qstats.c
index 95371e4..0921d47 100644
--- a/sbin/pfctl/pfctl_qstats.c
+++ b/sbin/pfctl/pfctl_qstats.c
@@ -34,10 +34,10 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-#include <altq/altq.h>
-#include <altq/altq_cbq.h>
-#include <altq/altq_priq.h>
-#include <altq/altq_hfsc.h>
+#include <net/altq/altq.h>
+#include <net/altq/altq_cbq.h>
+#include <net/altq/altq_priq.h>
+#include <net/altq/altq_hfsc.h>
#include "pfctl.h"
#include "pfctl_parser.h"
diff --git a/sbin/pflogd/Makefile b/sbin/pflogd/Makefile
index fcff8eb..49a311e 100644
--- a/sbin/pflogd/Makefile
+++ b/sbin/pflogd/Makefile
@@ -8,8 +8,7 @@ MAN= pflogd.8
CFLAGS+=-include ${.CURDIR}/../../lib/libpcap/config.h
-LDADD= -lpcap
-DPADD= ${LIBPCAP}
+LIBADD= pcap
WARNS?= 2
diff --git a/sbin/ping/Makefile b/sbin/ping/Makefile
index 57f82a8..533f8b8 100644
--- a/sbin/ping/Makefile
+++ b/sbin/ping/Makefile
@@ -8,19 +8,16 @@ MAN= ping.8
BINOWN= root
BINMODE=4555
WARNS?= 3
-DPADD= ${LIBM}
-LDADD= -lm
+LIBADD= m
.if ${MK_CASPER} != "no" && !defined(RESCUE)
-DPADD+= ${LIBCAPSICUM} ${LIBNV}
-LDADD+= -lcapsicum -lnv
+LIBADD+= capsicum
CFLAGS+=-DHAVE_LIBCAPSICUM
.endif
.if !defined(RELEASE_CRUNCH)
CFLAGS+=-DIPSEC
-DPADD+= ${LIBIPSEC}
-LDADD+= -lipsec
+LIBADD+= ipsec
.endif
.include <bsd.prog.mk>
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index aeb3014..23d5696 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -713,7 +713,7 @@ main(int argc, char *const *argv)
ip->ip_hl = sizeof(struct ip) >> 2;
ip->ip_tos = tos;
ip->ip_id = 0;
- ip->ip_off = df ? IP_DF : 0;
+ ip->ip_off = htons(df ? IP_DF : 0);
ip->ip_ttl = ttl;
ip->ip_p = IPPROTO_ICMP;
ip->ip_src.s_addr = source ? sock_in.sin_addr.s_addr : INADDR_ANY;
@@ -737,9 +737,6 @@ main(int argc, char *const *argv)
if (cansandbox && cap_enter() < 0 && errno != ENOSYS)
err(1, "cap_enter");
- if (cap_sandboxed())
- fprintf(stderr, "capability mode sandbox enabled\n");
-
cap_rights_init(&rights, CAP_RECV, CAP_EVENT, CAP_SETSOCKOPT);
if (cap_rights_limit(srecv, &rights) < 0 && errno != ENOSYS)
err(1, "cap_rights_limit srecv");
@@ -1078,7 +1075,7 @@ pinger(void)
if (options & F_HDRINCL) {
cc += sizeof(struct ip);
ip = (struct ip *)outpackhdr;
- ip->ip_len = cc;
+ ip->ip_len = htons(cc);
ip->ip_sum = in_cksum((u_short *)outpackhdr, cc);
packet = outpackhdr;
}
diff --git a/sbin/ping6/Makefile b/sbin/ping6/Makefile
index e40dc6e..35a76e4 100644
--- a/sbin/ping6/Makefile
+++ b/sbin/ping6/Makefile
@@ -10,7 +10,6 @@ WARNS?= 3
BINOWN= root
BINMODE=4555
-LDADD= -lipsec -lm -lmd
-DPADD= ${LIBIPSEC} ${LIBM} ${LIBMD}
+LIBADD= ipsec m md
.include <bsd.prog.mk>
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index fa314f6..d71c021 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -648,11 +648,20 @@ main(int argc, char *argv[])
err(1, "socket");
/* set the source address if specified. */
- if ((options & F_SRCADDR) &&
- bind(s, (struct sockaddr *)&src, srclen) != 0) {
- err(1, "bind");
+ if ((options & F_SRCADDR) != 0) {
+ /* properly fill sin6_scope_id */
+ if (IN6_IS_ADDR_LINKLOCAL(&src.sin6_addr) && (
+ IN6_IS_ADDR_LINKLOCAL(&dst.sin6_addr) ||
+ IN6_IS_ADDR_MC_LINKLOCAL(&dst.sin6_addr) ||
+ IN6_IS_ADDR_MC_NODELOCAL(&dst.sin6_addr))) {
+ if (src.sin6_scope_id == 0)
+ src.sin6_scope_id = dst.sin6_scope_id;
+ if (dst.sin6_scope_id == 0)
+ dst.sin6_scope_id = src.sin6_scope_id;
+ }
+ if (bind(s, (struct sockaddr *)&src, srclen) != 0)
+ err(1, "bind");
}
-
/* set the gateway (next hop) if specified */
if (gateway) {
memset(&hints, 0, sizeof(hints));
diff --git a/sbin/quotacheck/Makefile b/sbin/quotacheck/Makefile
index 51a88b7..7be3e35 100644
--- a/sbin/quotacheck/Makefile
+++ b/sbin/quotacheck/Makefile
@@ -5,8 +5,7 @@ PROG= quotacheck
SRCS= quotacheck.c preen.c fsutil.c utilities.c
WARNS?= 2
MAN= quotacheck.8
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+LIBADD= util
.PATH: ${.CURDIR}/../fsck ${.CURDIR}/../fsck_ffs
diff --git a/sbin/rcorder/Makefile b/sbin/rcorder/Makefile
index b71aa4b..2f1bbac 100644
--- a/sbin/rcorder/Makefile
+++ b/sbin/rcorder/Makefile
@@ -5,16 +5,10 @@ PROG= rcorder
SRCS= ealloc.c hash.c rcorder.c
MAN= rcorder.8
-LDADD= -lutil
-DPADD= ${LIBUTIL}
+LIBADD= util
-# XXX hack for make's hash.[ch]
-CFLAGS+= -DORDER -I.
+CFLAGS+= -DORDER
-SRCS+= util.h
-CLEANFILES+= util.h
-
-util.h:
- ln -sf ${.CURDIR}/../../lib/libutil/libutil.h ${.TARGET}
+#CFLAGS+= -DDEBUG
.include <bsd.prog.mk>
diff --git a/sbin/rcorder/Makefile.depend b/sbin/rcorder/Makefile.depend
index ed049c9..78b235b 100644
--- a/sbin/rcorder/Makefile.depend
+++ b/sbin/rcorder/Makefile.depend
@@ -17,6 +17,4 @@ DIRDEPS = \
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
# local dependencies - needed for -jN in clean tree
-rcorder.o: util.h
-rcorder.po: util.h
.endif
diff --git a/sbin/rcorder/rcorder.c b/sbin/rcorder/rcorder.c
index 83f6df8..8c46b4f 100644
--- a/sbin/rcorder/rcorder.c
+++ b/sbin/rcorder/rcorder.c
@@ -42,10 +42,10 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <stdio.h>
+#include <libutil.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <util.h>
#include "ealloc.h"
#include "sprite.h"
diff --git a/sbin/reboot/nextboot.8 b/sbin/reboot/nextboot.8
index 7d41352..14573e2 100644
--- a/sbin/reboot/nextboot.8
+++ b/sbin/reboot/nextboot.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 31, 2012
+.Dd March 17, 2015
.Dt NEXTBOOT 8
.Os
.Sh NAME
@@ -130,3 +130,9 @@ It is also my first attempt to write in Forth.
Finally, it does some evil things like writing to the file system before it
has been checked.
If it scrambles your file system, do not blame me.
+.Pp
+.Xr loader 8
+is only able to read ZFS, not write to it.
+.Pa nextboot.conf
+will NOT be reset in case of a kernel boot failure.
+
diff --git a/sbin/resolvconf/Makefile b/sbin/resolvconf/Makefile
index 18ef240..2d4701e 100644
--- a/sbin/resolvconf/Makefile
+++ b/sbin/resolvconf/Makefile
@@ -5,7 +5,7 @@ DIST= ${.CURDIR}/../../contrib/openresolv
SCRIPTS= resolvconf
-FILES= libc dnsmasq named pdnsd unbound
+FILES= libc dnsmasq named pdnsd pdns_recursor unbound
FILESDIR= /libexec/resolvconf
MAN= resolvconf.conf.5 resolvconf.8
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index b2cd8fd..7b308cd 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -80,8 +80,8 @@ static struct inotab *inotab[HASHSIZE];
*/
struct modeinfo {
ino_t ino;
- struct timeval ctimep[2];
- struct timeval mtimep[2];
+ struct timespec ctimep[2];
+ struct timespec mtimep[2];
mode_t mode;
uid_t uid;
gid_t gid;
@@ -656,8 +656,8 @@ setdirmodes(int flags)
else
(void) chown(cp, node.uid, node.gid);
(void) chmod(cp, node.mode);
- utimes(cp, node.ctimep);
- utimes(cp, node.mtimep);
+ utimensat(AT_FDCWD, cp, node.ctimep, 0);
+ utimensat(AT_FDCWD, cp, node.mtimep, 0);
(void) chflags(cp, node.flags);
}
ep->e_flags &= ~NEW;
@@ -746,13 +746,13 @@ allocinotab(struct context *ctxp, long seekpt)
return (itp);
node.ino = ctxp->ino;
node.mtimep[0].tv_sec = ctxp->atime_sec;
- node.mtimep[0].tv_usec = ctxp->atime_nsec / 1000;
+ node.mtimep[0].tv_nsec = ctxp->atime_nsec;
node.mtimep[1].tv_sec = ctxp->mtime_sec;
- node.mtimep[1].tv_usec = ctxp->mtime_nsec / 1000;
+ node.mtimep[1].tv_nsec = ctxp->mtime_nsec;
node.ctimep[0].tv_sec = ctxp->atime_sec;
- node.ctimep[0].tv_usec = ctxp->atime_nsec / 1000;
+ node.ctimep[0].tv_nsec = ctxp->atime_nsec;
node.ctimep[1].tv_sec = ctxp->birthtime_sec;
- node.ctimep[1].tv_usec = ctxp->birthtime_nsec / 1000;
+ node.ctimep[1].tv_nsec = ctxp->birthtime_nsec;
node.extsize = ctxp->extsize;
node.mode = ctxp->mode;
node.flags = ctxp->file_flags;
diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c
index 225fe32..9c9890f 100644
--- a/sbin/restore/tape.c
+++ b/sbin/restore/tape.c
@@ -569,20 +569,20 @@ extractfile(char *name)
gid_t gid;
mode_t mode;
int extsize;
- struct timeval mtimep[2], ctimep[2];
+ struct timespec mtimep[2], ctimep[2];
struct entry *ep;
char *buf;
curfile.name = name;
curfile.action = USING;
mtimep[0].tv_sec = curfile.atime_sec;
- mtimep[0].tv_usec = curfile.atime_nsec / 1000;
+ mtimep[0].tv_nsec = curfile.atime_nsec;
mtimep[1].tv_sec = curfile.mtime_sec;
- mtimep[1].tv_usec = curfile.mtime_nsec / 1000;
+ mtimep[1].tv_nsec = curfile.mtime_nsec;
ctimep[0].tv_sec = curfile.atime_sec;
- ctimep[0].tv_usec = curfile.atime_nsec / 1000;
+ ctimep[0].tv_nsec = curfile.atime_nsec;
ctimep[1].tv_sec = curfile.birthtime_sec;
- ctimep[1].tv_usec = curfile.birthtime_nsec / 1000;
+ ctimep[1].tv_nsec = curfile.birthtime_nsec;
extsize = curfile.extsize;
uid = getuid();
if (uid == 0)
@@ -628,8 +628,10 @@ extractfile(char *name)
set_extattr_link(name, buf, extsize);
(void) lchown(name, uid, gid);
(void) lchmod(name, mode);
- (void) lutimes(name, ctimep);
- (void) lutimes(name, mtimep);
+ (void) utimensat(AT_FDCWD, name, ctimep,
+ AT_SYMLINK_NOFOLLOW);
+ (void) utimensat(AT_FDCWD, name, mtimep,
+ AT_SYMLINK_NOFOLLOW);
(void) lchflags(name, flags);
return (GOOD);
}
@@ -658,8 +660,8 @@ extractfile(char *name)
}
(void) chown(name, uid, gid);
(void) chmod(name, mode);
- (void) utimes(name, ctimep);
- (void) utimes(name, mtimep);
+ (void) utimensat(AT_FDCWD, name, ctimep, 0);
+ (void) utimensat(AT_FDCWD, name, mtimep, 0);
(void) chflags(name, flags);
return (GOOD);
@@ -688,8 +690,8 @@ extractfile(char *name)
}
(void) chown(name, uid, gid);
(void) chmod(name, mode);
- (void) utimes(name, ctimep);
- (void) utimes(name, mtimep);
+ (void) utimensat(AT_FDCWD, name, ctimep, 0);
+ (void) utimensat(AT_FDCWD, name, mtimep, 0);
(void) chflags(name, flags);
return (GOOD);
@@ -714,8 +716,8 @@ extractfile(char *name)
set_extattr_fd(ofile, name, buf, extsize);
(void) fchown(ofile, uid, gid);
(void) fchmod(ofile, mode);
- (void) futimes(ofile, ctimep);
- (void) futimes(ofile, mtimep);
+ (void) futimens(ofile, ctimep);
+ (void) futimens(ofile, mtimep);
(void) fchflags(ofile, flags);
(void) close(ofile);
return (GOOD);
diff --git a/sbin/route/route.c b/sbin/route/route.c
index 53ec298..1bce41e 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1137,19 +1137,11 @@ inet_makenetandmask(u_long net, struct sockaddr_in *sin,
static int
inet6_makenetandmask(struct sockaddr_in6 *sin6, const char *plen)
{
- struct in6_addr in6;
if (plen == NULL) {
if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) &&
- sin6->sin6_scope_id == 0) {
+ sin6->sin6_scope_id == 0)
plen = "0";
- } else if ((sin6->sin6_addr.s6_addr[0] & 0xe0) == 0x20) {
- /* aggregatable global unicast - RFC2374 */
- memset(&in6, 0, sizeof(in6));
- if (!memcmp(&sin6->sin6_addr.s6_addr[8],
- &in6.s6_addr[8], 8))
- plen = "64";
- }
}
if (plen == NULL || strcmp(plen, "128") == 0)
diff --git a/sbin/routed/Makefile b/sbin/routed/Makefile
index 8f2a819..2308722 100644
--- a/sbin/routed/Makefile
+++ b/sbin/routed/Makefile
@@ -5,8 +5,7 @@ PROG= routed
MAN= routed.8
SRCS= if.c input.c main.c output.c parms.c radix.c rdisc.c table.c trace.c
WARNS?= 3
-DPADD= ${LIBMD}
-LDADD= -lmd
+LIBADD= md
SUBDIR= rtquery
diff --git a/sbin/routed/input.c b/sbin/routed/input.c
index 901c4f3..895ef50 100644
--- a/sbin/routed/input.c
+++ b/sbin/routed/input.c
@@ -288,6 +288,10 @@ input(struct sockaddr_in *from, /* received from this IP address */
/* Answer a query from a utility program
* with all we know.
*/
+ if (aifp == NULL) {
+ trace_pkt("ignore remote query");
+ return;
+ }
if (from->sin_port != htons(RIP_PORT)) {
/*
* insecure: query from non-router node
diff --git a/sbin/routed/routed.8 b/sbin/routed/routed.8
index ca5250b..68d3f96 100644
--- a/sbin/routed/routed.8
+++ b/sbin/routed/routed.8
@@ -254,7 +254,7 @@ The following options are available:
allow
.Nm
to accept a RIP request from non-router node.
-When specified once,
+When specified once,
.Nm
replies to a route information query from neighbor nodes.
When specified twice,
diff --git a/sbin/routed/rtquery/Makefile b/sbin/routed/rtquery/Makefile
index e5d0f5a..4df7dc2 100644
--- a/sbin/routed/rtquery/Makefile
+++ b/sbin/routed/rtquery/Makefile
@@ -4,8 +4,7 @@
PROG= rtquery
MAN= rtquery.8
-LDADD= -lmd
-DPADD= ${LIBMD}
+LIBADD= md
WARNS?= 3
NO_WARRAY_BOUNDS=
diff --git a/sbin/savecore/Makefile b/sbin/savecore/Makefile
index f257458..5134e4c 100644
--- a/sbin/savecore/Makefile
+++ b/sbin/savecore/Makefile
@@ -1,8 +1,7 @@
# $FreeBSD$
PROG= savecore
-DPADD= ${LIBZ}
-LDADD= -lz
+LIBADD= z xo
MAN= savecore.8
.include <bsd.prog.mk>
diff --git a/sbin/savecore/Makefile.depend b/sbin/savecore/Makefile.depend
index 4f4a210e3f..8639f83 100644
--- a/sbin/savecore/Makefile.depend
+++ b/sbin/savecore/Makefile.depend
@@ -10,6 +10,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libxo \
lib/libz \
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index 7a5fc4c..705261f 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$");
#include <syslog.h>
#include <time.h>
#include <unistd.h>
+#include <libxo/xo.h>
/* The size of the buffer used for I/O. */
#define BUFFERSIZE (1024*1024)
@@ -98,29 +99,28 @@ static sig_atomic_t got_siginfo;
static void infohandler(int);
static void
-printheader(FILE *f, const struct kerneldumpheader *h, const char *device,
+printheader(xo_handle_t *xo, const struct kerneldumpheader *h, const char *device,
int bounds, const int status)
{
uint64_t dumplen;
time_t t;
const char *stat_str;
- fprintf(f, "Dump header from device %s\n", device);
- fprintf(f, " Architecture: %s\n", h->architecture);
- fprintf(f, " Architecture Version: %u\n",
- dtoh32(h->architectureversion));
+ xo_flush_h(xo);
+ xo_emit_h(xo, "{Lwc:Dump header from device}{:dump_device/%s}\n", device);
+ xo_emit_h(xo, "{P: }{Lwc:Architecture}{:architecture/%s}\n", h->architecture);
+ xo_emit_h(xo, "{P: }{Lwc:Architecture Version}{:architecture_version/%u}\n", dtoh32(h->architectureversion));
dumplen = dtoh64(h->dumplength);
- fprintf(f, " Dump Length: %lldB (%lld MB)\n", (long long)dumplen,
- (long long)(dumplen >> 20));
- fprintf(f, " Blocksize: %d\n", dtoh32(h->blocksize));
+ xo_emit_h(xo, "{P: }{Lwc:Dump Length}{:dump_length_bytes/%lld}\n", (long long)dumplen);
+ xo_emit_h(xo, "{P: }{Lwc:Blocksize}{:blocksize/%d}\n", dtoh32(h->blocksize));
t = dtoh64(h->dumptime);
- fprintf(f, " Dumptime: %s", ctime(&t));
- fprintf(f, " Hostname: %s\n", h->hostname);
- fprintf(f, " Magic: %s\n", h->magic);
- fprintf(f, " Version String: %s", h->versionstring);
- fprintf(f, " Panic String: %s\n", h->panicstring);
- fprintf(f, " Dump Parity: %u\n", h->parity);
- fprintf(f, " Bounds: %d\n", bounds);
+ xo_emit_h(xo, "{P: }{Lwc:Dumptime}{:dumptime/%s}", ctime(&t));
+ xo_emit_h(xo, "{P: }{Lwc:Hostname}{:hostname/%s}\n", h->hostname);
+ xo_emit_h(xo, "{P: }{Lwc:Magic}{:magic/%s}\n", h->magic);
+ xo_emit_h(xo, "{P: }{Lwc:Version String}{:version_string/%s}", h->versionstring);
+ xo_emit_h(xo, "{P: }{Lwc:Panic String}{:panic_string/%s}\n", h->panicstring);
+ xo_emit_h(xo, "{P: }{Lwc:Dump Parity}{:dump_parity/%u}\n", h->parity);
+ xo_emit_h(xo, "{P: }{Lwc:Bounds}{:bounds/%d}\n", bounds);
switch(status) {
case STATUS_BAD:
@@ -132,8 +132,8 @@ printheader(FILE *f, const struct kerneldumpheader *h, const char *device,
default:
stat_str = "unknown";
}
- fprintf(f, " Dump Status: %s\n", stat_str);
- fflush(f);
+ xo_emit_h(xo, "{P: }{Lwc:Dump Status}{:dump_status/%s}\n", stat_str);
+ xo_flush_h(xo);
}
static int
@@ -434,6 +434,7 @@ DoTextdumpFile(int fd, off_t dumpsize, off_t lasthd, char *buf,
static void
DoFile(const char *savedir, const char *device)
{
+ xo_handle_t *xostdout, *xoinfo;
static char infoname[PATH_MAX], corename[PATH_MAX], linkname[PATH_MAX];
static char *buf = NULL;
struct kerneldumpheader kdhf, kdhl;
@@ -442,13 +443,19 @@ DoFile(const char *savedir, const char *device)
mode_t oumask;
int fd, fdinfo, error;
int bounds, status;
- u_int sectorsize;
+ u_int sectorsize, xostyle;
int istextdump;
bounds = getbounds();
mediasize = 0;
status = STATUS_UNKNOWN;
+ xostdout = xo_create_to_file(stdout, XO_STYLE_TEXT, 0);
+ if (xostdout == NULL) {
+ syslog(LOG_ERR, "%s: %m", infoname);
+ return;
+ }
+
if (maxdumps > 0 && bounds == maxdumps)
bounds = 0;
@@ -574,10 +581,10 @@ DoFile(const char *savedir, const char *device)
if (verbose >= 2) {
printf("First dump headers:\n");
- printheader(stdout, &kdhf, device, bounds, -1);
+ printheader(xostdout, &kdhf, device, bounds, -1);
printf("\nLast dump headers:\n");
- printheader(stdout, &kdhl, device, bounds, -1);
+ printheader(xostdout, &kdhl, device, bounds, -1);
printf("\n");
}
@@ -626,6 +633,7 @@ DoFile(const char *savedir, const char *device)
nerr++;
goto closefd;
}
+
oumask = umask(S_IRWXG|S_IRWXO); /* Restrict access to the core file.*/
if (compress) {
snprintf(corename, sizeof(corename), "%s.%d.gz",
@@ -652,10 +660,22 @@ DoFile(const char *savedir, const char *device)
goto closefd;
}
+ xostyle = xo_get_style(NULL);
+ xoinfo = xo_create_to_file(info, xostyle, 0);
+ if (xoinfo == NULL) {
+ syslog(LOG_ERR, "%s: %m", infoname);
+ nerr++;
+ goto closefd;
+ }
+ xo_open_container_h(xoinfo, "crashdump");
+
if (verbose)
- printheader(stdout, &kdhl, device, bounds, status);
+ printheader(xostdout, &kdhl, device, bounds, status);
- printheader(info, &kdhl, device, bounds, status);
+ printheader(xoinfo, &kdhl, device, bounds, status);
+ xo_close_container_h(xoinfo, "crashdump");
+ xo_flush_h(xoinfo);
+ xo_finish_h(xoinfo);
fclose(info);
syslog(LOG_NOTICE, "writing %score to %s/%s",
@@ -712,6 +732,8 @@ nuke:
syslog(LOG_ERR,
"error while clearing the dump header: %m");
}
+ xo_close_container_h(xostdout, "crashdump");
+ xo_finish_h(xostdout);
close(fd);
return;
@@ -725,7 +747,7 @@ closefd:
static void
usage(void)
{
- fprintf(stderr, "%s\n%s\n%s\n",
+ xo_error("%s\n%s\n%s\n",
"usage: savecore -c [-v] [device ...]",
" savecore -C [-v] [device ...]",
" savecore [-fkvz] [-m maxdumps] [directory [device ...]]");
@@ -745,6 +767,10 @@ main(int argc, char **argv)
openlog("savecore", LOG_PERROR, LOG_DAEMON);
signal(SIGINFO, infohandler);
+ argc = xo_parse_args(argc, argv);
+ if (argc < 0)
+ exit(1);
+
while ((ch = getopt(argc, argv, "Ccfkm:vz")) != -1)
switch(ch) {
case 'C':
diff --git a/sbin/setkey/Makefile b/sbin/setkey/Makefile
index bd04f07..e974af5 100644
--- a/sbin/setkey/Makefile
+++ b/sbin/setkey/Makefile
@@ -37,8 +37,7 @@ WARNS?= 1
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../../lib/libipsec
YFLAGS= -d
-DPADD= ${LIBL} ${LIBY}
-LDADD= -ll -ly
+LIBADD= l y
CLEANFILES= y.tab.c y.tab.h key_test.o keytest
@@ -55,8 +54,7 @@ CFLAGS+= -DIPSEC_DEBUG -DYY_NO_UNPUT
CFLAGS+= -DINET6
.endif
CFLAGS+= -I.
-DPADD+= ${LIBIPSEC}
-LDADD+= -lipsec
+LIBADD+= ipsec
CLEANFILES+= scriptdump y.tab.h
#SCRIPTS= scriptdump
diff --git a/sbin/setkey/Makefile.depend b/sbin/setkey/Makefile.depend
index 2c5ecea..a467db1d 100644
--- a/sbin/setkey/Makefile.depend
+++ b/sbin/setkey/Makefile.depend
@@ -14,6 +14,7 @@ DIRDEPS = \
lib/libipsec \
lib/liby \
usr.bin/lex/lib \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/sbin/shutdown/shutdown.8 b/sbin/shutdown/shutdown.8
index 871efbe..4145ba5 100644
--- a/sbin/shutdown/shutdown.8
+++ b/sbin/shutdown/shutdown.8
@@ -28,7 +28,7 @@
.\" @(#)shutdown.8 8.2 (Berkeley) 4/27/95
.\" $FreeBSD$
.\"
-.Dd March 19, 2013
+.Dd December 15, 2014
.Dt SHUTDOWN 8
.Os
.Sh NAME
@@ -118,6 +118,15 @@ to the current system values.
The first form brings the system down in
.Ar number
minutes and the second at the absolute time specified.
+.Ar +number
+may be specified in units other than minutes by appending the corresponding
+suffix:
+.Dq Li s ,
+.Dq Li sec ,
+.Dq Li m ,
+.Dq Li min .
+.Dq Li h ,
+.Dq Li hour .
.It Ar warning-message
Any other arguments comprise the warning message that is broadcast
to users currently logged into the system.
diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c
index f53b3d8..b04e0bd 100644
--- a/sbin/shutdown/shutdown.c
+++ b/sbin/shutdown/shutdown.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <paths.h>
#include <pwd.h>
@@ -322,7 +323,8 @@ timewarn(int timeleft)
(void)fprintf(pf, "System going down in %d minute%s\n\n",
timeleft / 60, (timeleft > 60) ? "s" : "");
else if (timeleft)
- (void)fprintf(pf, "System going down in 30 seconds\n\n");
+ (void)fprintf(pf, "System going down in %s30 seconds\n\n",
+ (offset > 0 && offset < 30 ? "less than " : ""));
else
(void)fprintf(pf, "System going down IMMEDIATELY\n\n");
@@ -415,6 +417,7 @@ getoffset(char *timearg)
char *p;
time_t now;
int this_year;
+ char *timeunit;
(void)time(&now);
@@ -427,8 +430,25 @@ getoffset(char *timearg)
if (*timearg == '+') { /* +minutes */
if (!isdigit(*++timearg))
badtime();
- if ((offset = atoi(timearg) * 60) < 0)
+ errno = 0;
+ offset = strtol(timearg, &timeunit, 10);
+ if (offset < 0 || offset == LONG_MAX || errno != 0)
badtime();
+ if (timeunit[0] == '\0' || strcasecmp(timeunit, "m") == 0 ||
+ strcasecmp(timeunit, "min") == 0 ||
+ strcasecmp(timeunit, "mins") == 0) {
+ offset *= 60;
+ } else if (strcasecmp(timeunit, "h") == 0 ||
+ strcasecmp(timeunit, "hour") == 0 ||
+ strcasecmp(timeunit, "hours") == 0) {
+ offset *= 60 * 60;
+ } else if (strcasecmp(timeunit, "s") == 0 ||
+ strcasecmp(timeunit, "sec") == 0 ||
+ strcasecmp(timeunit, "secs") == 0) {
+ offset *= 1;
+ } else {
+ badtime();
+ }
shuttime = now + offset;
return;
}
diff --git a/sbin/sunlabel/Makefile b/sbin/sunlabel/Makefile
index ed64bee..21ccfd7 100644
--- a/sbin/sunlabel/Makefile
+++ b/sbin/sunlabel/Makefile
@@ -11,8 +11,7 @@ LINKS= ${BINDIR}/sunlabel ${BINDIR}/disklabel
MLINKS= sunlabel.8 disklabel.8
.endif
-DPADD= ${LIBGEOM}
-LDADD= -lgeom
+LIBADD= geom
.include <bsd.prog.mk>
diff --git a/sbin/swapon/Makefile b/sbin/swapon/Makefile
index 6f8e8df..e9074be 100644
--- a/sbin/swapon/Makefile
+++ b/sbin/swapon/Makefile
@@ -8,7 +8,6 @@ LINKS+= ${BINDIR}/swapon ${BINDIR}/swapctl
MLINKS= swapon.8 swapoff.8
MLINKS+=swapon.8 swapctl.8
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+LIBADD= util
.include <bsd.prog.mk>
diff --git a/sbin/sysctl/sysctl.8 b/sbin/sysctl/sysctl.8
index b81de6e..cb8145e 100644
--- a/sbin/sysctl/sysctl.8
+++ b/sbin/sysctl/sysctl.8
@@ -28,7 +28,7 @@
.\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd December 13, 2012
+.Dd February 12, 2015
.Dt SYSCTL 8
.Os
.Sh NAME
@@ -37,11 +37,13 @@
.Sh SYNOPSIS
.Nm
.Op Fl bdehiNnoRTqx
+.Op Fl B Ar bufsize
.Op Fl f Ar filename
.Ar name Ns Op = Ns Ar value
.Ar ...
.Nm
.Op Fl bdehNnoRTqx
+.Op Fl B Ar bufsize
.Fl a
.Sh DESCRIPTION
The
@@ -68,6 +70,15 @@ the command line.
Force the value of the variable(s) to be output in raw, binary format.
No names are printed and no terminating newlines are output.
This is mostly useful with a single variable.
+.It Fl B Ar bufsize
+Set the buffer size to read from the
+.Nm
+to
+.Ar bufsize .
+This is necessary for a
+.Nm
+that has variable length, and the probe value of 0 is a valid length, such as
+.Va kern.arandom .
.It Fl d
Print the description of the variable instead of its value.
.It Fl e
@@ -128,7 +139,7 @@ Suppress some warnings generated by
.Nm
to standard error.
.It Fl T
-Display only variables that are setable via loader (CTLFLAG_TUN).
+Display only variables that are settable via loader (CTLFLAG_TUN).
.It Fl W
Display only writable variables that are not statistical.
Useful for determining the set of runtime tunable sysctls.
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index a6ea9f9..f321120 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -71,7 +71,7 @@ static const char rcsid[] =
static const char *conffile;
-static int aflag, bflag, dflag, eflag, hflag, iflag;
+static int aflag, bflag, Bflag, dflag, eflag, hflag, iflag;
static int Nflag, nflag, oflag, qflag, Tflag, Wflag, xflag;
static int oidfmt(int *, int, char *, u_int *);
@@ -112,8 +112,8 @@ usage(void)
{
(void)fprintf(stderr, "%s\n%s\n",
- "usage: sysctl [-bdehiNnoqTWx] [-f filename] name[=value] ...",
- " sysctl [-bdehNnoqTWx] -a");
+ "usage: sysctl [-bdehiNnoqTWx] [ -B <bufsize> ] [-f filename] name[=value] ...",
+ " sysctl [-bdehNnoqTWx] [ -B <bufsize> ] -a");
exit(1);
}
@@ -127,7 +127,7 @@ main(int argc, char **argv)
setbuf(stdout,0);
setbuf(stderr,0);
- while ((ch = getopt(argc, argv, "Aabdef:hiNnoqTwWxX")) != -1) {
+ while ((ch = getopt(argc, argv, "AabB:def:hiNnoqTwWxX")) != -1) {
switch (ch) {
case 'A':
/* compatibility */
@@ -139,6 +139,9 @@ main(int argc, char **argv)
case 'b':
bflag = 1;
break;
+ case 'B':
+ Bflag = strtol(optarg, NULL, 0);
+ break;
case 'd':
dflag = 1;
break;
@@ -222,7 +225,7 @@ parse(const char *string, int lineno)
unsigned int uintval;
long longval;
unsigned long ulongval;
- size_t newsize = 0;
+ size_t newsize = Bflag;
int64_t i64val;
uint64_t u64val;
int mib[CTL_MAXNAME];
@@ -679,15 +682,18 @@ strIKtoi(const char *str, char **endptrp)
p = &str[len - 1];
if (*p == 'C' || *p == 'F') {
temp = strtof(str, endptrp);
- if (*endptrp != str && *endptrp == p && errno != 0) {
+ if (*endptrp != str && *endptrp == p && errno == 0) {
if (*p == 'F')
temp = (temp - 32) * 5 / 9;
+ *endptrp = NULL;
return (temp * 10 + 2732);
}
} else {
kelv = (int)strtol(str, endptrp, 10);
- if (*endptrp != str && *endptrp == p && errno != 0)
+ if (*endptrp != str && *endptrp == p && errno == 0) {
+ *endptrp = NULL;
return (kelv);
+ }
}
errno = ERANGE;
@@ -812,9 +818,13 @@ show_var(int *oid, int nlen)
return (0);
}
/* find an estimate of how much we need for this var */
- j = 0;
- i = sysctl(oid, nlen, 0, &j, 0, 0);
- j += j; /* we want to be sure :-) */
+ if (Bflag)
+ j = Bflag;
+ else {
+ j = 0;
+ i = sysctl(oid, nlen, 0, &j, 0, 0);
+ j += j; /* we want to be sure :-) */
+ }
val = oval = malloc(j + 1);
if (val == NULL) {
diff --git a/sbin/tunefs/Makefile b/sbin/tunefs/Makefile
index d5313c4..07fe3b1 100644
--- a/sbin/tunefs/Makefile
+++ b/sbin/tunefs/Makefile
@@ -2,8 +2,7 @@
# $FreeBSD$
PROG= tunefs
-DPADD= ${LIBUFS}
-LDADD= -lufs
+LIBADD= ufs
MAN= tunefs.8
WARNS= 3
diff --git a/sbin/umount/umount.8 b/sbin/umount/umount.8
index cb3a97b..e62bcc5 100644
--- a/sbin/umount/umount.8
+++ b/sbin/umount/umount.8
@@ -28,7 +28,7 @@
.\" @(#)umount.8 8.2 (Berkeley) 5/8/95
.\" $FreeBSD$
.\"
-.Dd May 31, 2011
+.Dd November 22, 2014
.Dt UMOUNT 8
.Os
.Sh NAME
@@ -140,6 +140,7 @@ file system table
.Sh SEE ALSO
.Xr unmount 2 ,
.Xr fstab 5 ,
+.Xr autounmountd 8 ,
.Xr mount 8
.Sh HISTORY
A
OpenPOWER on IntegriCloud