aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/Makefile4
-rw-r--r--sbin/Makefile.amd642
-rw-r--r--sbin/Makefile.arm1
-rw-r--r--sbin/Makefile.i3862
-rw-r--r--sbin/Makefile.inc2
-rw-r--r--sbin/Makefile.powerpc641
-rw-r--r--sbin/adjkerntz/Makefile1
-rw-r--r--sbin/adjkerntz/Makefile.depend2
-rw-r--r--sbin/adjkerntz/adjkerntz.82
-rw-r--r--sbin/adjkerntz/adjkerntz.c14
-rw-r--r--sbin/adjkerntz/pathnames.h4
-rw-r--r--sbin/bectl/Makefile3
-rw-r--r--sbin/bectl/Makefile.depend1
-rw-r--r--sbin/bectl/bectl.8131
-rw-r--r--sbin/bectl/bectl.c40
-rw-r--r--sbin/bectl/bectl.h4
-rw-r--r--sbin/bectl/bectl_jail.c10
-rw-r--r--sbin/bectl/bectl_list.c20
-rw-r--r--sbin/bectl/tests/Makefile1
-rwxr-xr-xsbin/bectl/tests/bectl_test.sh57
-rw-r--r--sbin/bsdlabel/Makefile2
-rw-r--r--sbin/bsdlabel/Makefile.depend4
-rw-r--r--sbin/bsdlabel/bsdlabel.83
-rw-r--r--sbin/bsdlabel/bsdlabel.c25
-rw-r--r--sbin/bsdlabel/disktab1
-rw-r--r--sbin/bsdlabel/pathnames.h3
-rw-r--r--sbin/camcontrol/Makefile1
-rw-r--r--sbin/camcontrol/Makefile.depend2
-rw-r--r--sbin/camcontrol/attrib.c2
-rw-r--r--sbin/camcontrol/camcontrol.810
-rw-r--r--sbin/camcontrol/camcontrol.c319
-rw-r--r--sbin/camcontrol/camcontrol.h6
-rw-r--r--sbin/camcontrol/depop.c3
-rw-r--r--sbin/camcontrol/epc.c2
-rw-r--r--sbin/camcontrol/fwdownload.c15
-rw-r--r--sbin/camcontrol/modeedit.c18
-rw-r--r--sbin/camcontrol/persist.c2
-rw-r--r--sbin/camcontrol/progress.c4
-rw-r--r--sbin/camcontrol/progress.h4
-rw-r--r--sbin/camcontrol/timestamp.c3
-rw-r--r--sbin/camcontrol/util.c2
-rw-r--r--sbin/camcontrol/zone.c6
-rw-r--r--sbin/ccdconfig/Makefile1
-rw-r--r--sbin/ccdconfig/Makefile.depend4
-rw-r--r--sbin/ccdconfig/ccdconfig.81
-rw-r--r--sbin/ccdconfig/ccdconfig.c3
-rw-r--r--sbin/ccdconfig/pathnames.h3
-rw-r--r--sbin/clri/Makefile4
-rw-r--r--sbin/clri/Makefile.depend3
-rw-r--r--sbin/clri/clri.83
-rw-r--r--sbin/clri/clri.c15
-rw-r--r--sbin/comcontrol/Makefile2
-rw-r--r--sbin/comcontrol/Makefile.depend2
-rw-r--r--sbin/comcontrol/comcontrol.81
-rw-r--r--sbin/comcontrol/comcontrol.c6
-rw-r--r--sbin/conscontrol/Makefile1
-rw-r--r--sbin/conscontrol/Makefile.depend2
-rw-r--r--sbin/conscontrol/conscontrol.82
-rw-r--r--sbin/conscontrol/conscontrol.c5
-rw-r--r--sbin/ddb/Makefile1
-rw-r--r--sbin/ddb/Makefile.depend3
-rw-r--r--sbin/ddb/ddb.83
-rw-r--r--sbin/ddb/ddb.c4
-rw-r--r--sbin/ddb/ddb.conf1
-rw-r--r--sbin/ddb/ddb.h4
-rw-r--r--sbin/ddb/ddb_capture.c5
-rw-r--r--sbin/ddb/ddb_script.c5
-rw-r--r--sbin/decryptcore/Makefile2
-rw-r--r--sbin/decryptcore/Makefile.depend5
-rw-r--r--sbin/decryptcore/decryptcore.84
-rw-r--r--sbin/decryptcore/decryptcore.c8
-rw-r--r--sbin/devd/Makefile34
-rw-r--r--sbin/devd/Makefile.depend4
-rw-r--r--sbin/devd/apple.conf1
-rw-r--r--sbin/devd/asus.conf1
-rw-r--r--sbin/devd/autofs.conf9
-rw-r--r--sbin/devd/bluetooth.conf9
-rw-r--r--sbin/devd/devd.82
-rw-r--r--sbin/devd/devd.cc39
-rw-r--r--sbin/devd/devd.conf117
-rw-r--r--sbin/devd/devd.conf.516
-rw-r--r--sbin/devd/devd.h4
-rw-r--r--sbin/devd/devd.hh4
-rw-r--r--sbin/devd/devmatch.conf27
-rw-r--r--sbin/devd/dhclient.conf19
-rw-r--r--sbin/devd/hyperv.conf1
-rw-r--r--sbin/devd/moused.conf35
-rw-r--r--sbin/devd/parse.y4
-rw-r--r--sbin/devd/power_profile.conf6
-rw-r--r--sbin/devd/syscons.conf9
-rw-r--r--sbin/devd/tests/Makefile1
-rw-r--r--sbin/devd/tests/Makefile.depend1
-rw-r--r--sbin/devd/tests/client_test.c2
-rw-r--r--sbin/devd/token.l4
-rw-r--r--sbin/devd/uath.conf1
-rw-r--r--sbin/devd/ulpt.conf1
-rw-r--r--sbin/devd/zfs.conf1
-rw-r--r--sbin/devfs/Makefile1
-rw-r--r--sbin/devfs/Makefile.depend2
-rw-r--r--sbin/devfs/devfs.810
-rw-r--r--sbin/devfs/devfs.c5
-rw-r--r--sbin/devfs/devfs.conf1
-rw-r--r--sbin/devfs/devfs.rules1
-rw-r--r--sbin/devfs/extern.h4
-rw-r--r--sbin/devfs/rule.c5
-rw-r--r--sbin/devmatch/Makefile2
-rw-r--r--sbin/devmatch/Makefile.depend1
-rw-r--r--sbin/devmatch/devmatch.827
-rw-r--r--sbin/devmatch/devmatch.c19
-rw-r--r--sbin/dhclient/Makefile3
-rw-r--r--sbin/dhclient/Makefile.depend2
-rw-r--r--sbin/dhclient/Makefile.depend.options1
-rw-r--r--sbin/dhclient/alloc.c2
-rw-r--r--sbin/dhclient/bpf.c2
-rw-r--r--sbin/dhclient/clparse.c6
-rw-r--r--sbin/dhclient/conflex.c4
-rw-r--r--sbin/dhclient/convert.c2
-rwxr-xr-xsbin/dhclient/dhclient-script8
-rw-r--r--sbin/dhclient/dhclient-script.82
-rw-r--r--sbin/dhclient/dhclient.82
-rw-r--r--sbin/dhclient/dhclient.c21
-rw-r--r--sbin/dhclient/dhclient.conf1
-rw-r--r--sbin/dhclient/dhclient.conf.59
-rw-r--r--sbin/dhclient/dhclient.leases.52
-rw-r--r--sbin/dhclient/dhcp-options.52
-rw-r--r--sbin/dhclient/dhcp.h1
-rw-r--r--sbin/dhclient/dhcpd.h3
-rw-r--r--sbin/dhclient/dhctoken.h3
-rw-r--r--sbin/dhclient/dispatch.c29
-rw-r--r--sbin/dhclient/errwarn.c2
-rw-r--r--sbin/dhclient/hash.c2
-rw-r--r--sbin/dhclient/inet.c2
-rw-r--r--sbin/dhclient/options.c2
-rw-r--r--sbin/dhclient/packet.c2
-rw-r--r--sbin/dhclient/parse.c30
-rw-r--r--sbin/dhclient/privsep.c2
-rw-r--r--sbin/dhclient/privsep.h2
-rw-r--r--sbin/dhclient/tables.c2
-rw-r--r--sbin/dhclient/tests/Makefile7
-rw-r--r--sbin/dhclient/tests/Makefile.depend1
-rw-r--r--sbin/dhclient/tests/fake.c16
-rw-r--r--sbin/dhclient/tests/option-domain-search.c48
-rw-r--r--sbin/dhclient/tree.c2
-rw-r--r--sbin/dhclient/tree.h2
-rw-r--r--sbin/dmesg/Makefile2
-rw-r--r--sbin/dmesg/Makefile.depend3
-rw-r--r--sbin/dmesg/dmesg.83
-rw-r--r--sbin/dmesg/dmesg.c14
-rw-r--r--sbin/dump/Makefile4
-rw-r--r--sbin/dump/Makefile.depend3
-rw-r--r--sbin/dump/cache.c2
-rw-r--r--sbin/dump/dump.83
-rw-r--r--sbin/dump/dump.h4
-rw-r--r--sbin/dump/dumprmt.c8
-rw-r--r--sbin/dump/itime.c8
-rw-r--r--sbin/dump/main.c16
-rw-r--r--sbin/dump/optr.c8
-rw-r--r--sbin/dump/pathnames.h3
-rw-r--r--sbin/dump/tape.c62
-rw-r--r--sbin/dump/traverse.c8
-rw-r--r--sbin/dump/unctime.c8
-rw-r--r--sbin/dumpfs/Makefile4
-rw-r--r--sbin/dumpfs/Makefile.depend2
-rw-r--r--sbin/dumpfs/dumpfs.86
-rw-r--r--sbin/dumpfs/dumpfs.c84
-rw-r--r--sbin/dumpon/Makefile2
-rw-r--r--sbin/dumpon/Makefile.depend2
-rw-r--r--sbin/dumpon/Makefile.depend.options1
-rw-r--r--sbin/dumpon/dumpon.89
-rw-r--r--sbin/dumpon/dumpon.c22
-rw-r--r--sbin/etherswitchcfg/Makefile2
-rw-r--r--sbin/etherswitchcfg/Makefile.depend2
-rw-r--r--sbin/etherswitchcfg/etherswitchcfg.82
-rw-r--r--sbin/etherswitchcfg/etherswitchcfg.c6
-rw-r--r--sbin/etherswitchcfg/ifmedia.c1
-rw-r--r--sbin/fdisk/Makefile1
-rw-r--r--sbin/fdisk/Makefile.depend4
-rw-r--r--sbin/fdisk/fdisk.81
-rw-r--r--sbin/fdisk/fdisk.c18
-rw-r--r--sbin/fdisk/fdisk_mbr_enc.c5
-rw-r--r--sbin/fdisk/fdisk_mbr_enc.h4
-rw-r--r--sbin/fdisk/runtest.sh1
-rw-r--r--sbin/ffsinfo/Makefile5
-rw-r--r--sbin/ffsinfo/Makefile.depend2
-rw-r--r--sbin/ffsinfo/ffsinfo.81
-rw-r--r--sbin/ffsinfo/ffsinfo.c17
-rw-r--r--sbin/fsck/Makefile5
-rw-r--r--sbin/fsck/Makefile.depend2
-rw-r--r--sbin/fsck/fsck.82
-rw-r--r--sbin/fsck/fsck.c10
-rw-r--r--sbin/fsck/fsutil.c46
-rw-r--r--sbin/fsck/fsutil.h3
-rw-r--r--sbin/fsck/preen.c11
-rw-r--r--sbin/fsck_ffs/Makefile4
-rw-r--r--sbin/fsck_ffs/Makefile.depend2
-rw-r--r--sbin/fsck_ffs/dir.c193
-rw-r--r--sbin/fsck_ffs/ea.c12
-rw-r--r--sbin/fsck_ffs/fsck.h89
-rw-r--r--sbin/fsck_ffs/fsck_ffs.86
-rw-r--r--sbin/fsck_ffs/fsutil.c432
-rw-r--r--sbin/fsck_ffs/gjournal.c21
-rw-r--r--sbin/fsck_ffs/globs.c46
-rw-r--r--sbin/fsck_ffs/inode.c578
-rw-r--r--sbin/fsck_ffs/main.c178
-rw-r--r--sbin/fsck_ffs/pass1.c129
-rw-r--r--sbin/fsck_ffs/pass1b.c10
-rw-r--r--sbin/fsck_ffs/pass2.c169
-rw-r--r--sbin/fsck_ffs/pass3.c16
-rw-r--r--sbin/fsck_ffs/pass4.c8
-rw-r--r--sbin/fsck_ffs/pass5.c63
-rw-r--r--sbin/fsck_ffs/setup.c389
-rw-r--r--sbin/fsck_ffs/suj.c210
-rw-r--r--sbin/fsck_ffs/utilities.c8
-rw-r--r--sbin/fsck_msdosfs/Makefile1
-rw-r--r--sbin/fsck_msdosfs/Makefile.depend3
-rw-r--r--sbin/fsck_msdosfs/boot.c4
-rw-r--r--sbin/fsck_msdosfs/check.c4
-rw-r--r--sbin/fsck_msdosfs/dir.c4
-rw-r--r--sbin/fsck_msdosfs/dosfs.h3
-rw-r--r--sbin/fsck_msdosfs/ext.h3
-rw-r--r--sbin/fsck_msdosfs/fat.c2
-rw-r--r--sbin/fsck_msdosfs/fsck_msdosfs.82
-rw-r--r--sbin/fsck_msdosfs/main.c2
-rw-r--r--sbin/fsdb/Makefile4
-rw-r--r--sbin/fsdb/Makefile.depend3
-rw-r--r--sbin/fsdb/fsdb.82
-rw-r--r--sbin/fsdb/fsdb.c160
-rw-r--r--sbin/fsdb/fsdb.h5
-rw-r--r--sbin/fsdb/fsdbutil.c5
-rw-r--r--sbin/fsirand/Makefile3
-rw-r--r--sbin/fsirand/Makefile.depend3
-rw-r--r--sbin/fsirand/fsirand.81
-rw-r--r--sbin/fsirand/fsirand.c15
-rw-r--r--sbin/gbde/Makefile4
-rw-r--r--sbin/gbde/Makefile.depend4
-rw-r--r--sbin/gbde/gbde.82
-rw-r--r--sbin/gbde/gbde.c9
-rw-r--r--sbin/gbde/image.uu1
-rw-r--r--sbin/gbde/template.txt1
-rw-r--r--sbin/gbde/test.sh1
-rw-r--r--sbin/geom/Makefile3
-rw-r--r--sbin/geom/Makefile.depend1
-rw-r--r--sbin/geom/core/Makefile.depend1
-rw-r--r--sbin/geom/core/geom.819
-rw-r--r--sbin/geom/core/geom.c10
-rw-r--r--sbin/geom/core/geom.h4
-rw-r--r--sbin/geom/misc/subr.c7
-rw-r--r--sbin/geom/misc/subr.h4
-rw-r--r--sbin/ggate/Makefile1
-rw-r--r--sbin/ggate/Makefile.inc1
-rw-r--r--sbin/ggate/ggatec/Makefile1
-rw-r--r--sbin/ggate/ggatec/Makefile.depend4
-rw-r--r--sbin/ggate/ggatec/ggatec.82
-rw-r--r--sbin/ggate/ggatec/ggatec.c4
-rw-r--r--sbin/ggate/ggated/Makefile1
-rw-r--r--sbin/ggate/ggated/Makefile.depend2
-rw-r--r--sbin/ggate/ggated/ggated.82
-rw-r--r--sbin/ggate/ggated/ggated.c4
-rw-r--r--sbin/ggate/ggatel/Makefile1
-rw-r--r--sbin/ggate/ggatel/Makefile.depend4
-rw-r--r--sbin/ggate/ggatel/ggatel.82
-rw-r--r--sbin/ggate/ggatel/ggatel.c4
-rw-r--r--sbin/ggate/shared/ggate.c4
-rw-r--r--sbin/ggate/shared/ggate.h4
-rw-r--r--sbin/growfs/Makefile5
-rw-r--r--sbin/growfs/Makefile.depend2
-rw-r--r--sbin/growfs/debug.c5
-rw-r--r--sbin/growfs/debug.h1
-rw-r--r--sbin/growfs/growfs.87
-rw-r--r--sbin/growfs/growfs.c166
-rw-r--r--sbin/growfs/tests/Makefile1
-rw-r--r--sbin/growfs/tests/Makefile.depend1
-rwxr-xr-xsbin/growfs/tests/legacy_test.pl1
-rw-r--r--sbin/gvinum/Makefile3
-rw-r--r--sbin/gvinum/Makefile.depend7
-rw-r--r--sbin/gvinum/gvinum.84
-rw-r--r--sbin/gvinum/gvinum.c4
-rw-r--r--sbin/gvinum/gvinum.h1
-rw-r--r--sbin/hastctl/Makefile4
-rw-r--r--sbin/hastctl/Makefile.depend3
-rw-r--r--sbin/hastctl/hastctl.82
-rw-r--r--sbin/hastctl/hastctl.c5
-rw-r--r--sbin/hastd/Makefile5
-rw-r--r--sbin/hastd/Makefile.depend5
-rw-r--r--sbin/hastd/activemap.c5
-rw-r--r--sbin/hastd/activemap.h4
-rw-r--r--sbin/hastd/control.c5
-rw-r--r--sbin/hastd/control.h4
-rw-r--r--sbin/hastd/crc32.c115
-rw-r--r--sbin/hastd/crc32.h28
-rw-r--r--sbin/hastd/ebuf.c5
-rw-r--r--sbin/hastd/ebuf.h4
-rw-r--r--sbin/hastd/event.c4
-rw-r--r--sbin/hastd/event.h4
-rw-r--r--sbin/hastd/hast.conf.52
-rw-r--r--sbin/hastd/hast.h4
-rw-r--r--sbin/hastd/hast_checksum.c10
-rw-r--r--sbin/hastd/hast_checksum.h4
-rw-r--r--sbin/hastd/hast_compression.c4
-rw-r--r--sbin/hastd/hast_compression.h4
-rw-r--r--sbin/hastd/hast_proto.c4
-rw-r--r--sbin/hastd/hast_proto.h4
-rw-r--r--sbin/hastd/hastd.82
-rw-r--r--sbin/hastd/hastd.c5
-rw-r--r--sbin/hastd/hastd.h4
-rw-r--r--sbin/hastd/hooks.c5
-rw-r--r--sbin/hastd/hooks.h4
-rw-r--r--sbin/hastd/lzf.c2
-rw-r--r--sbin/hastd/lzf.h6
-rw-r--r--sbin/hastd/metadata.c4
-rw-r--r--sbin/hastd/metadata.h4
-rw-r--r--sbin/hastd/nv.c5
-rw-r--r--sbin/hastd/nv.h4
-rw-r--r--sbin/hastd/parse.y4
-rw-r--r--sbin/hastd/pjdlog.c5
-rw-r--r--sbin/hastd/pjdlog.h4
-rw-r--r--sbin/hastd/primary.c7
-rw-r--r--sbin/hastd/proto.c5
-rw-r--r--sbin/hastd/proto.h4
-rw-r--r--sbin/hastd/proto_common.c5
-rw-r--r--sbin/hastd/proto_impl.h4
-rw-r--r--sbin/hastd/proto_socketpair.c5
-rw-r--r--sbin/hastd/proto_tcp.c5
-rw-r--r--sbin/hastd/proto_uds.c4
-rw-r--r--sbin/hastd/rangelock.c4
-rw-r--r--sbin/hastd/rangelock.h4
-rw-r--r--sbin/hastd/refcnt.h4
-rw-r--r--sbin/hastd/secondary.c5
-rw-r--r--sbin/hastd/subr.c5
-rw-r--r--sbin/hastd/subr.h4
-rw-r--r--sbin/hastd/synch.h4
-rw-r--r--sbin/hastd/token.l4
-rw-r--r--sbin/ifconfig/Makefile9
-rw-r--r--sbin/ifconfig/Makefile.depend6
-rw-r--r--sbin/ifconfig/Makefile.depend.options1
-rw-r--r--sbin/ifconfig/af_inet.c384
-rw-r--r--sbin/ifconfig/af_inet6.c480
-rw-r--r--sbin/ifconfig/af_link.c139
-rw-r--r--sbin/ifconfig/af_nd6.c57
-rw-r--r--sbin/ifconfig/carp.c138
-rw-r--r--sbin/ifconfig/ifbridge.c195
-rw-r--r--sbin/ifconfig/ifclone.c40
-rw-r--r--sbin/ifconfig/ifconfig.8132
-rw-r--r--sbin/ifconfig/ifconfig.c1203
-rw-r--r--sbin/ifconfig/ifconfig.h187
-rw-r--r--sbin/ifconfig/ifconfig_netlink.c514
-rw-r--r--sbin/ifconfig/ifconfig_netlink.h37
-rw-r--r--sbin/ifconfig/iffib.c28
-rw-r--r--sbin/ifconfig/ifgif.c23
-rw-r--r--sbin/ifconfig/ifgre.c43
-rw-r--r--sbin/ifconfig/ifgroup.c46
-rw-r--r--sbin/ifconfig/ifieee80211.c1324
-rw-r--r--sbin/ifconfig/ifipsec.c18
-rw-r--r--sbin/ifconfig/iflagg.c89
-rw-r--r--sbin/ifconfig/ifmac.c14
-rw-r--r--sbin/ifconfig/ifmedia.c77
-rw-r--r--sbin/ifconfig/ifpfsync.c407
-rw-r--r--sbin/ifconfig/ifstf.c26
-rw-r--r--sbin/ifconfig/ifvlan.c110
-rw-r--r--sbin/ifconfig/ifvxlan.c166
-rw-r--r--sbin/ifconfig/sfp.c16
-rw-r--r--sbin/ifconfig/tests/Makefile1
-rw-r--r--sbin/ifconfig/tests/Makefile.depend1
-rw-r--r--sbin/init/Makefile2
-rw-r--r--sbin/init/Makefile.depend2
-rw-r--r--sbin/init/init.83
-rw-r--r--sbin/init/init.c73
-rw-r--r--sbin/init/pathnames.h3
-rw-r--r--sbin/init/ttys8
-rw-r--r--sbin/ipf/Makefile1
-rw-r--r--sbin/ipf/Makefile.inc2
-rw-r--r--sbin/ipf/common/genmask.c6
-rw-r--r--sbin/ipf/common/ipf.h12
-rw-r--r--sbin/ipf/common/ipf_y.y1
-rw-r--r--sbin/ipf/common/ipmon.h3
-rw-r--r--sbin/ipf/common/ipt.h1
-rw-r--r--sbin/ipf/common/kmem.h1
-rw-r--r--sbin/ipf/common/lexer.c4
-rw-r--r--sbin/ipf/common/lexer.h1
-rw-r--r--sbin/ipf/common/opts.h1
-rw-r--r--sbin/ipf/common/pcap-ipf.h1
-rw-r--r--sbin/ipf/ipf/Makefile2
-rw-r--r--sbin/ipf/ipf/Makefile.depend3
-rw-r--r--sbin/ipf/ipf/bpf-ipf.h5
-rw-r--r--sbin/ipf/ipf/bpf_filter.c26
-rw-r--r--sbin/ipf/ipf/ipf.43
-rw-r--r--sbin/ipf/ipf/ipf.51
-rw-r--r--sbin/ipf/ipf/ipf.81
-rw-r--r--sbin/ipf/ipf/ipf.c7
-rw-r--r--sbin/ipf/ipf/ipfcomp.c5
-rw-r--r--sbin/ipf/ipf/ipfilter.44
-rw-r--r--sbin/ipf/ipf/ipfilter.51
-rw-r--r--sbin/ipf/ipf/ipl.41
-rw-r--r--sbin/ipf/ipfs/Makefile1
-rw-r--r--sbin/ipf/ipfs/Makefile.depend3
-rw-r--r--sbin/ipf/ipfs/ipfs.81
-rw-r--r--sbin/ipf/ipfs/ipfs.c4
-rw-r--r--sbin/ipf/ipfstat/Makefile1
-rw-r--r--sbin/ipf/ipfstat/Makefile.depend6
-rw-r--r--sbin/ipf/ipfstat/ipfstat.81
-rw-r--r--sbin/ipf/ipfstat/ipfstat.c10
-rw-r--r--sbin/ipf/ipfsync/ipfsyncd.c4
-rw-r--r--sbin/ipf/ipfsync/ipsyncm.c5
-rw-r--r--sbin/ipf/ipfsync/ipsyncs.c5
-rw-r--r--sbin/ipf/ipftest/Makefile1
-rw-r--r--sbin/ipf/ipftest/Makefile.depend1
-rw-r--r--sbin/ipf/ipftest/ip_fil.c7
-rw-r--r--sbin/ipf/ipftest/ipftest.11
-rw-r--r--sbin/ipf/ipftest/ipftest.c5
-rw-r--r--sbin/ipf/ipftest/md5.c1
-rw-r--r--sbin/ipf/ipftest/md5.h1
-rw-r--r--sbin/ipf/iplang/iplang.h1
-rw-r--r--sbin/ipf/iplang/iplang_l.l1
-rw-r--r--sbin/ipf/iplang/iplang_y.y2
-rw-r--r--sbin/ipf/ipmon/Makefile2
-rw-r--r--sbin/ipf/ipmon/Makefile.depend3
-rw-r--r--sbin/ipf/ipmon/ipmon.51
-rw-r--r--sbin/ipf/ipmon/ipmon.81
-rw-r--r--sbin/ipf/ipmon/ipmon.c18
-rw-r--r--sbin/ipf/ipmon/ipmon_y.y1
-rw-r--r--sbin/ipf/ipnat/Makefile2
-rw-r--r--sbin/ipf/ipnat/Makefile.depend3
-rw-r--r--sbin/ipf/ipnat/ipnat.41
-rw-r--r--sbin/ipf/ipnat/ipnat.51
-rw-r--r--sbin/ipf/ipnat/ipnat.81
-rw-r--r--sbin/ipf/ipnat/ipnat.c5
-rw-r--r--sbin/ipf/ipnat/ipnat_y.y1
-rw-r--r--sbin/ipf/ippool/Makefile2
-rw-r--r--sbin/ipf/ippool/Makefile.depend3
-rw-r--r--sbin/ipf/ippool/ippool.51
-rw-r--r--sbin/ipf/ippool/ippool.87
-rw-r--r--sbin/ipf/ippool/ippool.c69
-rw-r--r--sbin/ipf/ippool/ippool_y.y1
-rw-r--r--sbin/ipf/ipresend/Makefile1
-rw-r--r--sbin/ipf/ipresend/Makefile.depend1
-rw-r--r--sbin/ipf/ipscan/Makefile1
-rw-r--r--sbin/ipf/ipscan/ipscan.51
-rw-r--r--sbin/ipf/ipscan/ipscan.81
-rw-r--r--sbin/ipf/ipscan/ipscan_y.y1
-rw-r--r--sbin/ipf/ipsend/44arp.c1
-rw-r--r--sbin/ipf/ipsend/arp.c5
-rw-r--r--sbin/ipf/ipsend/dlcommon.c1
-rw-r--r--sbin/ipf/ipsend/dltest.h1
-rw-r--r--sbin/ipf/ipsend/ip.c5
-rw-r--r--sbin/ipf/ipsend/ipresend.11
-rw-r--r--sbin/ipf/ipsend/ipresend.c5
-rw-r--r--sbin/ipf/ipsend/ipsend.11
-rw-r--r--sbin/ipf/ipsend/ipsend.51
-rw-r--r--sbin/ipf/ipsend/ipsend.c5
-rw-r--r--sbin/ipf/ipsend/ipsend.h3
-rw-r--r--sbin/ipf/ipsend/ipsopt.c5
-rw-r--r--sbin/ipf/ipsend/iptest.11
-rw-r--r--sbin/ipf/ipsend/iptest.c5
-rw-r--r--sbin/ipf/ipsend/iptests.c5
-rw-r--r--sbin/ipf/ipsend/resend.c5
-rw-r--r--sbin/ipf/ipsend/sbpf.c5
-rw-r--r--sbin/ipf/ipsend/sdlpi.c5
-rw-r--r--sbin/ipf/ipsend/snit.c5
-rw-r--r--sbin/ipf/ipsend/sock.c5
-rw-r--r--sbin/ipf/ipsend/sockraw.c4
-rw-r--r--sbin/ipf/libipf/Makefile1
-rw-r--r--sbin/ipf/libipf/Makefile.depend1
-rw-r--r--sbin/ipf/libipf/addicmp.c1
-rw-r--r--sbin/ipf/libipf/addipopt.c1
-rw-r--r--sbin/ipf/libipf/bcopywrap.c1
-rw-r--r--sbin/ipf/libipf/binprint.c1
-rw-r--r--sbin/ipf/libipf/buildopts.c1
-rw-r--r--sbin/ipf/libipf/checkrev.c1
-rw-r--r--sbin/ipf/libipf/connecttcp.c2
-rw-r--r--sbin/ipf/libipf/count4bits.c1
-rw-r--r--sbin/ipf/libipf/count6bits.c1
-rw-r--r--sbin/ipf/libipf/debug.c1
-rw-r--r--sbin/ipf/libipf/facpri.c4
-rw-r--r--sbin/ipf/libipf/facpri.h1
-rw-r--r--sbin/ipf/libipf/fill6bits.c1
-rw-r--r--sbin/ipf/libipf/flags.c1
-rw-r--r--sbin/ipf/libipf/gethost.c1
-rw-r--r--sbin/ipf/libipf/getifname.c1
-rw-r--r--sbin/ipf/libipf/getnattype.c4
-rw-r--r--sbin/ipf/libipf/getport.c1
-rw-r--r--sbin/ipf/libipf/getportproto.c1
-rw-r--r--sbin/ipf/libipf/getproto.c1
-rw-r--r--sbin/ipf/libipf/getsumd.c1
-rw-r--r--sbin/ipf/libipf/hostname.c1
-rw-r--r--sbin/ipf/libipf/icmpcode.c1
-rw-r--r--sbin/ipf/libipf/inet_addr.c5
-rw-r--r--sbin/ipf/libipf/initparse.c1
-rw-r--r--sbin/ipf/libipf/interror.c16
-rw-r--r--sbin/ipf/libipf/ionames.c1
-rw-r--r--sbin/ipf/libipf/ipf_dotuning.c1
-rw-r--r--sbin/ipf/libipf/ipft_hx.c5
-rw-r--r--sbin/ipf/libipf/ipft_pc.c4
-rw-r--r--sbin/ipf/libipf/ipft_tx.c5
-rw-r--r--sbin/ipf/libipf/ipoptsec.c1
-rw-r--r--sbin/ipf/libipf/kmem.c5
-rw-r--r--sbin/ipf/libipf/kmem.h1
-rw-r--r--sbin/ipf/libipf/kmemcpywrap.c1
-rw-r--r--sbin/ipf/libipf/kvatoname.c1
-rw-r--r--sbin/ipf/libipf/load_hash.c1
-rw-r--r--sbin/ipf/libipf/load_hashnode.c1
-rw-r--r--sbin/ipf/libipf/load_http.c3
-rw-r--r--sbin/ipf/libipf/load_pool.c1
-rw-r--r--sbin/ipf/libipf/load_poolnode.c1
-rw-r--r--sbin/ipf/libipf/mutex_emul.c6
-rw-r--r--sbin/ipf/libipf/nametokva.c1
-rw-r--r--sbin/ipf/libipf/nat_setgroupmap.c4
-rw-r--r--sbin/ipf/libipf/ntomask.c1
-rw-r--r--sbin/ipf/libipf/optname.c1
-rw-r--r--sbin/ipf/libipf/optprint.c1
-rw-r--r--sbin/ipf/libipf/optprintv6.c1
-rw-r--r--sbin/ipf/libipf/optvalue.c1
-rw-r--r--sbin/ipf/libipf/parseipfexpr.c6
-rw-r--r--sbin/ipf/libipf/poolio.c5
-rw-r--r--sbin/ipf/libipf/portname.c1
-rw-r--r--sbin/ipf/libipf/print_toif.c1
-rw-r--r--sbin/ipf/libipf/printactiveaddr.c3
-rw-r--r--sbin/ipf/libipf/printactivenat.c4
-rw-r--r--sbin/ipf/libipf/printaps.c4
-rw-r--r--sbin/ipf/libipf/printbuf.c1
-rw-r--r--sbin/ipf/libipf/printfr.c1
-rw-r--r--sbin/ipf/libipf/printfraginfo.c8
-rw-r--r--sbin/ipf/libipf/printhash.c1
-rw-r--r--sbin/ipf/libipf/printhashnode.c1
-rw-r--r--sbin/ipf/libipf/printhostmap.c1
-rw-r--r--sbin/ipf/libipf/printhostmask.c1
-rw-r--r--sbin/ipf/libipf/printifname.c1
-rw-r--r--sbin/ipf/libipf/printip.c1
-rw-r--r--sbin/ipf/libipf/printlog.c1
-rw-r--r--sbin/ipf/libipf/printmask.c1
-rw-r--r--sbin/ipf/libipf/printnat.c4
-rw-r--r--sbin/ipf/libipf/printnataddr.c3
-rw-r--r--sbin/ipf/libipf/printpacket.c1
-rw-r--r--sbin/ipf/libipf/printpacket6.c1
-rw-r--r--sbin/ipf/libipf/printpool.c1
-rw-r--r--sbin/ipf/libipf/printpool_live.c18
-rw-r--r--sbin/ipf/libipf/printpooldata.c10
-rw-r--r--sbin/ipf/libipf/printpoolnode.c1
-rw-r--r--sbin/ipf/libipf/printportcmp.c1
-rw-r--r--sbin/ipf/libipf/printproto.c3
-rw-r--r--sbin/ipf/libipf/printsbuf.c1
-rw-r--r--sbin/ipf/libipf/printstate.c1
-rw-r--r--sbin/ipf/libipf/printtunable.c1
-rw-r--r--sbin/ipf/libipf/remove_hash.c1
-rw-r--r--sbin/ipf/libipf/remove_hashnode.c1
-rw-r--r--sbin/ipf/libipf/remove_pool.c1
-rw-r--r--sbin/ipf/libipf/remove_poolnode.c1
-rw-r--r--sbin/ipf/libipf/resetlexer.c1
-rw-r--r--sbin/ipf/libipf/rwlock_emul.c1
-rw-r--r--sbin/ipf/libipf/tcp_flags.c1
-rw-r--r--sbin/ipf/libipf/tcpflags.c1
-rw-r--r--sbin/ipf/libipf/tcpoptnames.c1
-rw-r--r--sbin/ipf/libipf/v6ionames.c1
-rw-r--r--sbin/ipf/libipf/v6optvalue.c1
-rw-r--r--sbin/ipf/libipf/var.c4
-rw-r--r--sbin/ipf/libipf/verbose.c1
-rw-r--r--sbin/ipfw/Makefile1
-rw-r--r--sbin/ipfw/Makefile.depend3
-rw-r--r--sbin/ipfw/altq.c2
-rw-r--r--sbin/ipfw/dummynet.c2
-rw-r--r--sbin/ipfw/ipfw.8114
-rw-r--r--sbin/ipfw/ipfw2.c268
-rw-r--r--sbin/ipfw/ipfw2.h8
-rw-r--r--sbin/ipfw/ipv6.c9
-rw-r--r--sbin/ipfw/main.c11
-rw-r--r--sbin/ipfw/nat.c5
-rw-r--r--sbin/ipfw/nat64clat.c8
-rw-r--r--sbin/ipfw/nat64lsn.c8
-rw-r--r--sbin/ipfw/nat64stl.c8
-rw-r--r--sbin/ipfw/nptv6.c6
-rw-r--r--sbin/ipfw/tables.c57
-rw-r--r--sbin/ipfw/tests/Makefile5
-rwxr-xr-xsbin/ipfw/tests/test_add_rule.py492
-rw-r--r--sbin/kldconfig/Makefile1
-rw-r--r--sbin/kldconfig/Makefile.depend2
-rw-r--r--sbin/kldconfig/kldconfig.82
-rw-r--r--sbin/kldconfig/kldconfig.c5
-rw-r--r--sbin/kldload/Makefile1
-rw-r--r--sbin/kldload/Makefile.depend2
-rw-r--r--sbin/kldload/kldload.82
-rw-r--r--sbin/kldload/kldload.c5
-rw-r--r--sbin/kldstat/Makefile1
-rw-r--r--sbin/kldstat/Makefile.depend2
-rw-r--r--sbin/kldstat/kldstat.82
-rw-r--r--sbin/kldstat/kldstat.c5
-rw-r--r--sbin/kldunload/Makefile1
-rw-r--r--sbin/kldunload/Makefile.depend2
-rw-r--r--sbin/kldunload/kldunload.82
-rw-r--r--sbin/kldunload/kldunload.c5
-rw-r--r--sbin/ldconfig/Makefile1
-rw-r--r--sbin/ldconfig/Makefile.depend2
-rw-r--r--sbin/ldconfig/elfhints.c4
-rw-r--r--sbin/ldconfig/ldconfig.82
-rw-r--r--sbin/ldconfig/ldconfig.c4
-rw-r--r--sbin/ldconfig/ldconfig.h4
-rw-r--r--sbin/md5/Makefile12
-rw-r--r--sbin/md5/Makefile.depend3
-rw-r--r--sbin/md5/Makefile.depend.host11
-rw-r--r--sbin/md5/md5.1335
-rw-r--r--sbin/md5/md5.c689
-rw-r--r--sbin/md5/tests/1.inp0
-rw-r--r--sbin/md5/tests/1.sha512-p.chk1
-rw-r--r--sbin/md5/tests/1.sha512sum-p.chk1
-rw-r--r--sbin/md5/tests/2.inp1
-rw-r--r--sbin/md5/tests/2.sha512-p.chk1
-rw-r--r--sbin/md5/tests/2.sha512sum-p.chk1
-rw-r--r--sbin/md5/tests/3.inp1
-rw-r--r--sbin/md5/tests/3.sha512-p.chk1
-rw-r--r--sbin/md5/tests/3.sha512sum-p.chk1
-rw-r--r--sbin/md5/tests/4.inp1
-rw-r--r--sbin/md5/tests/4.sha512-p.chk1
-rw-r--r--sbin/md5/tests/4.sha512sum-p.chk1
-rw-r--r--sbin/md5/tests/5.inp1
-rw-r--r--sbin/md5/tests/5.sha512-p.chk1
-rw-r--r--sbin/md5/tests/5.sha512sum-p.chk1
-rw-r--r--sbin/md5/tests/6.inp1
-rw-r--r--sbin/md5/tests/6.sha512-p.chk1
-rw-r--r--sbin/md5/tests/6.sha512sum-p.chk1
-rw-r--r--sbin/md5/tests/7.inp1
-rw-r--r--sbin/md5/tests/7.sha512-p.chk1
-rw-r--r--sbin/md5/tests/7.sha512sum-p.chk1
-rw-r--r--sbin/md5/tests/8.inp1
-rw-r--r--sbin/md5/tests/8.sha512-p.chk1
-rw-r--r--sbin/md5/tests/8.sha512sum-p.chk1
-rw-r--r--sbin/md5/tests/Makefile36
-rw-r--r--sbin/md5/tests/algorithms.txt1
-rw-r--r--sbin/md5/tests/bsd-c-test.SH23
-rw-r--r--sbin/md5/tests/bsd-p-test.SH24
-rw-r--r--sbin/md5/tests/bsd-s-test.SH30
-rw-r--r--sbin/md5/tests/coreutils-c-test.SH21
-rw-r--r--sbin/md5/tests/md5.digest8
-rw-r--r--sbin/md5/tests/md5_test.sh374
-rw-r--r--sbin/md5/tests/md5sum.digest8
-rw-r--r--sbin/md5/tests/rmd160.digest8
-rw-r--r--sbin/md5/tests/rmd160sum.digest8
-rw-r--r--sbin/md5/tests/self-test.SH8
-rw-r--r--sbin/md5/tests/self-test.md5.chk9
-rw-r--r--sbin/md5/tests/self-test.rmd160.chk9
-rw-r--r--sbin/md5/tests/self-test.sh_inp8
-rw-r--r--sbin/md5/tests/self-test.sha1.chk9
-rw-r--r--sbin/md5/tests/self-test.sha224.chk9
-rw-r--r--sbin/md5/tests/self-test.sha256.chk9
-rw-r--r--sbin/md5/tests/self-test.sha384.chk9
-rw-r--r--sbin/md5/tests/self-test.sha512.chk9
-rw-r--r--sbin/md5/tests/self-test.sha512t256.chk9
-rw-r--r--sbin/md5/tests/self-test.skein1024.chk9
-rw-r--r--sbin/md5/tests/self-test.skein256.chk9
-rw-r--r--sbin/md5/tests/self-test.skein512.chk9
-rw-r--r--sbin/md5/tests/sha1.digest8
-rw-r--r--sbin/md5/tests/sha1sum.digest8
-rw-r--r--sbin/md5/tests/sha224.digest8
-rw-r--r--sbin/md5/tests/sha224sum.digest8
-rw-r--r--sbin/md5/tests/sha256.digest8
-rw-r--r--sbin/md5/tests/sha256sum.digest8
-rw-r--r--sbin/md5/tests/sha384.digest8
-rw-r--r--sbin/md5/tests/sha384sum.digest8
-rw-r--r--sbin/md5/tests/sha512.digest8
-rw-r--r--sbin/md5/tests/sha512sum.digest8
-rw-r--r--sbin/md5/tests/sha512t256.digest8
-rw-r--r--sbin/md5/tests/sha512t256sum.digest8
-rw-r--r--sbin/md5/tests/skein1024.digest8
-rw-r--r--sbin/md5/tests/skein1024sum.digest8
-rw-r--r--sbin/md5/tests/skein256.digest8
-rw-r--r--sbin/md5/tests/skein256sum.digest8
-rw-r--r--sbin/md5/tests/skein512.digest8
-rw-r--r--sbin/md5/tests/skein512sum.digest8
-rw-r--r--sbin/mdconfig/Makefile1
-rw-r--r--sbin/mdconfig/Makefile.depend4
-rw-r--r--sbin/mdconfig/mdconfig.84
-rw-r--r--sbin/mdconfig/mdconfig.c6
-rw-r--r--sbin/mdconfig/tests/Makefile1
-rw-r--r--sbin/mdconfig/tests/Makefile.depend1
-rwxr-xr-xsbin/mdconfig/tests/mdconfig_test.sh1
-rw-r--r--sbin/mdmfs/Makefile1
-rw-r--r--sbin/mdmfs/Makefile.depend2
-rw-r--r--sbin/mdmfs/mdmfs.82
-rw-r--r--sbin/mdmfs/mdmfs.c5
-rw-r--r--sbin/mknod/Makefile2
-rw-r--r--sbin/mknod/Makefile.depend2
-rw-r--r--sbin/mknod/mknod.83
-rw-r--r--sbin/mknod/mknod.c14
-rw-r--r--sbin/mksnap_ffs/Makefile3
-rw-r--r--sbin/mksnap_ffs/Makefile.depend2
-rw-r--r--sbin/mksnap_ffs/mksnap_ffs.832
-rw-r--r--sbin/mksnap_ffs/mksnap_ffs.c2
-rw-r--r--sbin/mount/Makefile13
-rw-r--r--sbin/mount/Makefile.depend3
-rw-r--r--sbin/mount/extern.h4
-rw-r--r--sbin/mount/getmntopts.3181
-rw-r--r--sbin/mount/getmntopts.c120
-rw-r--r--sbin/mount/mntopts.3379
-rw-r--r--sbin/mount/mntopts.h6
-rw-r--r--sbin/mount/mount.810
-rw-r--r--sbin/mount/mount.c53
-rw-r--r--sbin/mount/mount_fs.c14
-rw-r--r--sbin/mount/pathnames.h3
-rw-r--r--sbin/mount/vfslist.c8
-rw-r--r--sbin/mount_cd9660/Makefile2
-rw-r--r--sbin/mount_cd9660/Makefile.depend2
-rw-r--r--sbin/mount_cd9660/mount_cd9660.83
-rw-r--r--sbin/mount_cd9660/mount_cd9660.c16
-rw-r--r--sbin/mount_fusefs/Makefile1
-rw-r--r--sbin/mount_fusefs/Makefile.depend2
-rw-r--r--sbin/mount_fusefs/mount_fusefs.810
-rw-r--r--sbin/mount_fusefs/mount_fusefs.c5
-rw-r--r--sbin/mount_msdosfs/Makefile1
-rw-r--r--sbin/mount_msdosfs/Makefile.depend2
-rw-r--r--sbin/mount_msdosfs/mount_msdosfs.82
-rw-r--r--sbin/mount_msdosfs/mount_msdosfs.c5
-rw-r--r--sbin/mount_nfs/Makefile5
-rw-r--r--sbin/mount_nfs/Makefile.depend2
-rw-r--r--sbin/mount_nfs/mount_nfs.8109
-rw-r--r--sbin/mount_nfs/mount_nfs.c14
-rw-r--r--sbin/mount_nullfs/Makefile2
-rw-r--r--sbin/mount_nullfs/Makefile.depend2
-rw-r--r--sbin/mount_nullfs/mount_nullfs.820
-rw-r--r--sbin/mount_nullfs/mount_nullfs.c37
-rw-r--r--sbin/mount_udf/Makefile1
-rw-r--r--sbin/mount_udf/Makefile.depend2
-rw-r--r--sbin/mount_udf/mount_udf.82
-rw-r--r--sbin/mount_udf/mount_udf.c2
-rw-r--r--sbin/mount_unionfs/Makefile2
-rw-r--r--sbin/mount_unionfs/Makefile.depend2
-rw-r--r--sbin/mount_unionfs/mount_unionfs.89
-rw-r--r--sbin/mount_unionfs/mount_unionfs.c15
-rw-r--r--sbin/natd/Makefile1
-rw-r--r--sbin/natd/Makefile.depend2
-rw-r--r--sbin/natd/README1
-rw-r--r--sbin/natd/icmp.c2
-rw-r--r--sbin/natd/natd.81
-rw-r--r--sbin/natd/natd.c10
-rw-r--r--sbin/natd/natd.h2
-rw-r--r--sbin/natd/samples/natd.cf.sample1
-rw-r--r--sbin/newfs/Makefile3
-rw-r--r--sbin/newfs/Makefile.depend2
-rw-r--r--sbin/newfs/mkfs.c92
-rw-r--r--sbin/newfs/newfs.842
-rw-r--r--sbin/newfs/newfs.c26
-rw-r--r--sbin/newfs/newfs.h2
-rw-r--r--sbin/newfs/ref.test1
-rw-r--r--sbin/newfs/runtest00.sh1
-rw-r--r--sbin/newfs/runtest01.sh1
-rw-r--r--sbin/newfs_msdos/Makefile1
-rw-r--r--sbin/newfs_msdos/Makefile.depend2
-rw-r--r--sbin/newfs_msdos/mkfs_msdos.c5
-rw-r--r--sbin/newfs_msdos/mkfs_msdos.h1
-rw-r--r--sbin/newfs_msdos/newfs_msdos.82
-rw-r--r--sbin/newfs_msdos/newfs_msdos.c9
-rw-r--r--sbin/nfsiod/Makefile2
-rw-r--r--sbin/nfsiod/Makefile.depend2
-rw-r--r--sbin/nfsiod/nfsiod.83
-rw-r--r--sbin/nfsiod/nfsiod.c14
-rw-r--r--sbin/nos-tun/Makefile1
-rw-r--r--sbin/nos-tun/Makefile.depend2
-rw-r--r--sbin/nos-tun/nos-tun.82
-rw-r--r--sbin/nos-tun/nos-tun.c9
-rw-r--r--sbin/nvmecontrol/Makefile3
-rw-r--r--sbin/nvmecontrol/Makefile.depend3
-rw-r--r--sbin/nvmecontrol/comnd.c5
-rw-r--r--sbin/nvmecontrol/comnd.h4
-rw-r--r--sbin/nvmecontrol/devlist.c42
-rw-r--r--sbin/nvmecontrol/firmware.c5
-rw-r--r--sbin/nvmecontrol/format.c5
-rw-r--r--sbin/nvmecontrol/identify.c5
-rw-r--r--sbin/nvmecontrol/identify_ext.c19
-rw-r--r--sbin/nvmecontrol/logpage.c18
-rw-r--r--sbin/nvmecontrol/modules/Makefile3
-rw-r--r--sbin/nvmecontrol/modules/Makefile.inc3
-rw-r--r--sbin/nvmecontrol/modules/intel/Makefile1
-rw-r--r--sbin/nvmecontrol/modules/intel/intel.c15
-rw-r--r--sbin/nvmecontrol/modules/samsung/Makefile5
-rw-r--r--sbin/nvmecontrol/modules/samsung/samsung.c162
-rw-r--r--sbin/nvmecontrol/modules/wdc/Makefile1
-rw-r--r--sbin/nvmecontrol/modules/wdc/wdc.c15
-rw-r--r--sbin/nvmecontrol/nc_util.c4
-rw-r--r--sbin/nvmecontrol/ns.c61
-rw-r--r--sbin/nvmecontrol/nsid.c5
-rw-r--r--sbin/nvmecontrol/nvmecontrol.821
-rw-r--r--sbin/nvmecontrol/nvmecontrol.c5
-rw-r--r--sbin/nvmecontrol/nvmecontrol.h9
-rw-r--r--sbin/nvmecontrol/nvmecontrol_ext.h4
-rw-r--r--sbin/nvmecontrol/passthru.c7
-rw-r--r--sbin/nvmecontrol/perftest.c5
-rw-r--r--sbin/nvmecontrol/power.c8
-rw-r--r--sbin/nvmecontrol/reset.c5
-rw-r--r--sbin/nvmecontrol/resv.c9
-rw-r--r--sbin/nvmecontrol/sanitize.c5
-rw-r--r--sbin/nvmecontrol/selftest.c5
-rw-r--r--sbin/nvmecontrol/tests/Makefile1
-rwxr-xr-xsbin/nvmecontrol/tests/basic.sh3
-rw-r--r--sbin/pfctl/Makefile1
-rw-r--r--sbin/pfctl/Makefile.depend4
-rw-r--r--sbin/pfctl/parse.y293
-rw-r--r--sbin/pfctl/pf.os1
-rw-r--r--sbin/pfctl/pf_print_state.c92
-rw-r--r--sbin/pfctl/pf_ruleset.c3
-rw-r--r--sbin/pfctl/pfctl.815
-rw-r--r--sbin/pfctl/pfctl.c370
-rw-r--r--sbin/pfctl/pfctl.h3
-rw-r--r--sbin/pfctl/pfctl_altq.c4
-rw-r--r--sbin/pfctl/pfctl_optimize.c21
-rw-r--r--sbin/pfctl/pfctl_osfp.c3
-rw-r--r--sbin/pfctl/pfctl_parser.c132
-rw-r--r--sbin/pfctl/pfctl_parser.h14
-rw-r--r--sbin/pfctl/pfctl_qstats.c2
-rw-r--r--sbin/pfctl/pfctl_radix.c5
-rw-r--r--sbin/pfctl/pfctl_table.c5
-rw-r--r--sbin/pfctl/tests/Makefile1
-rw-r--r--sbin/pfctl/tests/Makefile.depend8
-rw-r--r--sbin/pfctl/tests/files/Makefile1
-rw-r--r--sbin/pfctl/tests/files/Makefile.depend1
-rw-r--r--sbin/pfctl/tests/files/pf0100.ok10
-rw-r--r--sbin/pfctl/tests/files/pf0102.ok4
-rw-r--r--sbin/pfctl/tests/files/pf1002.in5
-rw-r--r--sbin/pfctl/tests/files/pf1002.ok5
-rw-r--r--sbin/pfctl/tests/files/pf1010.in2
-rw-r--r--sbin/pfctl/tests/files/pf1010.ok2
-rw-r--r--sbin/pfctl/tests/files/pf1011.in1
-rw-r--r--sbin/pfctl/tests/files/pf1011.ok1
-rw-r--r--sbin/pfctl/tests/files/pf1012.in1
-rw-r--r--sbin/pfctl/tests/files/pf1012.ok1
-rw-r--r--sbin/pfctl/tests/files/pf1013.in1
-rw-r--r--sbin/pfctl/tests/files/pf1013.ok1
-rw-r--r--sbin/pfctl/tests/files/pf1014.in1
-rw-r--r--sbin/pfctl/tests/files/pf1014.ok1
-rw-r--r--sbin/pfctl/tests/files/pf1015.in1
-rw-r--r--sbin/pfctl/tests/files/pf1015.ok1
-rw-r--r--sbin/pfctl/tests/files/pf1016.in1
-rw-r--r--sbin/pfctl/tests/files/pf1016.ok1
-rw-r--r--sbin/pfctl/tests/files/pf1017.in1
-rw-r--r--sbin/pfctl/tests/files/pf1017.ok1
-rw-r--r--sbin/pfctl/tests/files/pf1018.in1
-rw-r--r--sbin/pfctl/tests/files/pf1018.ok2
-rwxr-xr-xsbin/pfctl/tests/macro.sh1
-rw-r--r--sbin/pfctl/tests/pfctl_test.c2
-rw-r--r--sbin/pfctl/tests/pfctl_test_list.inc11
-rw-r--r--sbin/pfilctl/Makefile1
-rw-r--r--sbin/pfilctl/pfilctl.82
-rw-r--r--sbin/pfilctl/pfilctl.c5
-rw-r--r--sbin/pflogd/Makefile1
-rw-r--r--sbin/pflogd/Makefile.depend3
-rw-r--r--sbin/ping/Makefile5
-rw-r--r--sbin/ping/Makefile.depend3
-rw-r--r--sbin/ping/Makefile.depend.options1
-rw-r--r--sbin/ping/main.c255
-rw-r--r--sbin/ping/main.h29
-rw-r--r--sbin/ping/ping.8148
-rw-r--r--sbin/ping/ping.c358
-rw-r--r--sbin/ping/ping.h4
-rw-r--r--sbin/ping/ping6.c147
-rw-r--r--sbin/ping/ping6.h4
-rw-r--r--sbin/ping/tests/Makefile6
-rw-r--r--sbin/ping/tests/in_cksum_test.c5
-rw-r--r--sbin/ping/tests/injection.py83
-rw-r--r--sbin/ping/tests/ping_6_c1_s8_t1.out6
-rw-r--r--sbin/ping/tests/ping_c1_s8_t1_S1.out6
-rw-r--r--sbin/ping/tests/ping_test.sh304
-rw-r--r--sbin/ping/tests/test_ping.py1456
-rw-r--r--sbin/ping/utils.c14
-rw-r--r--sbin/ping/utils.h4
-rw-r--r--sbin/ping6/Makefile.depend.options8
-rw-r--r--sbin/quotacheck/Makefile2
-rw-r--r--sbin/quotacheck/Makefile.depend3
-rw-r--r--sbin/quotacheck/preen.c11
-rw-r--r--sbin/quotacheck/quotacheck.83
-rw-r--r--sbin/quotacheck/quotacheck.c16
-rw-r--r--sbin/quotacheck/quotacheck.h2
-rw-r--r--sbin/rcorder/Makefile1
-rw-r--r--sbin/rcorder/Makefile.depend2
-rw-r--r--sbin/rcorder/ealloc.c1
-rw-r--r--sbin/rcorder/ealloc.h1
-rw-r--r--sbin/rcorder/hash.c14
-rw-r--r--sbin/rcorder/hash.h3
-rwxr-xr-xsbin/rcorder/rcorder-visualize.sh1
-rw-r--r--sbin/rcorder/rcorder.810
-rw-r--r--sbin/rcorder/rcorder.c4
-rw-r--r--sbin/rcorder/sprite.h3
-rw-r--r--sbin/reboot/Makefile2
-rw-r--r--sbin/reboot/Makefile.depend2
-rw-r--r--sbin/reboot/boot_i386.86
-rw-r--r--sbin/reboot/nextboot.82
-rw-r--r--sbin/reboot/nextboot.sh3
-rw-r--r--sbin/reboot/reboot.83
-rw-r--r--sbin/reboot/reboot.c28
-rw-r--r--sbin/recoverdisk/Makefile1
-rw-r--r--sbin/recoverdisk/Makefile.depend3
-rw-r--r--sbin/recoverdisk/recoverdisk.12
-rw-r--r--sbin/recoverdisk/recoverdisk.c2
-rw-r--r--sbin/resolvconf/Makefile3
-rw-r--r--sbin/resolvconf/Makefile.depend1
-rw-r--r--sbin/restore/Makefile4
-rw-r--r--sbin/restore/Makefile.depend2
-rw-r--r--sbin/restore/dirs.c18
-rw-r--r--sbin/restore/extern.h3
-rw-r--r--sbin/restore/interactive.c9
-rw-r--r--sbin/restore/main.c15
-rw-r--r--sbin/restore/restore.83
-rw-r--r--sbin/restore/restore.c9
-rw-r--r--sbin/restore/restore.h3
-rw-r--r--sbin/restore/symtab.c8
-rw-r--r--sbin/restore/tape.c25
-rw-r--r--sbin/restore/utilities.c8
-rw-r--r--sbin/route/Makefile13
-rw-r--r--sbin/route/Makefile.depend2
-rw-r--r--sbin/route/keywords2
-rw-r--r--sbin/route/route.895
-rw-r--r--sbin/route/route.c168
-rw-r--r--sbin/route/route_netlink.c913
-rw-r--r--sbin/route/tests/Makefile1
-rw-r--r--sbin/route/tests/basic.sh61
-rw-r--r--sbin/route/tests/utils.subr3
-rw-r--r--sbin/routed/Makefile1
-rw-r--r--sbin/routed/Makefile.depend2
-rw-r--r--sbin/routed/Makefile.inc1
-rw-r--r--sbin/routed/defs.h7
-rw-r--r--sbin/routed/if.c5
-rw-r--r--sbin/routed/input.c5
-rw-r--r--sbin/routed/main.c7
-rw-r--r--sbin/routed/output.c5
-rw-r--r--sbin/routed/parms.c5
-rw-r--r--sbin/routed/pathnames.h4
-rw-r--r--sbin/routed/radix.c7
-rw-r--r--sbin/routed/radix.h4
-rw-r--r--sbin/routed/rdisc.c5
-rw-r--r--sbin/routed/routed.83
-rw-r--r--sbin/routed/rtquery/Makefile1
-rw-r--r--sbin/routed/rtquery/Makefile.depend2
-rw-r--r--sbin/routed/rtquery/rtquery.81
-rw-r--r--sbin/routed/rtquery/rtquery.c23
-rw-r--r--sbin/routed/table.c5
-rw-r--r--sbin/routed/trace.c5
-rw-r--r--sbin/rtsol/Makefile1
-rw-r--r--sbin/rtsol/Makefile.depend1
-rw-r--r--sbin/rtsol/Makefile.depend.options1
-rw-r--r--sbin/savecore/Makefile1
-rw-r--r--sbin/savecore/Makefile.depend6
-rw-r--r--sbin/savecore/Makefile.depend.options1
-rw-r--r--sbin/savecore/savecore.83
-rw-r--r--sbin/savecore/savecore.c3
-rw-r--r--sbin/sconfig/Makefile10
-rw-r--r--sbin/sconfig/sconfig.8608
-rw-r--r--sbin/sconfig/sconfig.c1212
-rw-r--r--sbin/setkey/Makefile1
-rw-r--r--sbin/setkey/Makefile.depend4
-rw-r--r--sbin/setkey/parse.y197
-rw-r--r--sbin/setkey/sample.cf1
-rw-r--r--sbin/setkey/scriptdump.pl1
-rw-r--r--sbin/setkey/setkey.888
-rw-r--r--sbin/setkey/setkey.c18
-rw-r--r--sbin/setkey/test-pfkey.c1
-rw-r--r--sbin/setkey/test-policy.c2
-rw-r--r--sbin/setkey/token.l14
-rw-r--r--sbin/setkey/vchar.h1
-rw-r--r--sbin/shutdown/Makefile2
-rw-r--r--sbin/shutdown/Makefile.depend2
-rw-r--r--sbin/shutdown/shutdown.89
-rw-r--r--sbin/shutdown/shutdown.c14
-rw-r--r--sbin/swapon/Makefile2
-rw-r--r--sbin/swapon/Makefile.depend2
-rw-r--r--sbin/swapon/swapon.83
-rw-r--r--sbin/swapon/swapon.c16
-rw-r--r--sbin/sysctl/Makefile7
-rw-r--r--sbin/sysctl/Makefile.depend2
-rw-r--r--sbin/sysctl/sysctl.827
-rw-r--r--sbin/sysctl/sysctl.c106
-rw-r--r--sbin/sysctl/sysctl.conf1
-rw-r--r--sbin/sysctl/tests/Makefile4
-rw-r--r--sbin/sysctl/tests/Makefile.depend (renamed from sbin/sconfig/Makefile.depend)5
-rw-r--r--sbin/sysctl/tests/sysctl_test.sh116
-rw-r--r--sbin/tests/Makefile1
-rw-r--r--sbin/tests/Makefile.depend1
-rw-r--r--sbin/tunefs/Makefile4
-rw-r--r--sbin/tunefs/Makefile.depend2
-rw-r--r--sbin/tunefs/tunefs.842
-rw-r--r--sbin/tunefs/tunefs.c50
-rw-r--r--sbin/umount/Makefile3
-rw-r--r--sbin/umount/Makefile.depend2
-rw-r--r--sbin/umount/umount.83
-rw-r--r--sbin/umount/umount.c14
-rw-r--r--sbin/veriexec/Makefile1
-rw-r--r--sbin/veriexec/Makefile.depend3
-rw-r--r--sbin/veriexec/manifest_lexer.l2
-rw-r--r--sbin/veriexec/manifest_parser.y6
-rw-r--r--sbin/veriexec/veriexec.825
-rw-r--r--sbin/veriexec/veriexec.c71
-rw-r--r--sbin/veriexec/veriexec.h4
-rw-r--r--sbin/zfsbootcfg/Makefile2
-rw-r--r--sbin/zfsbootcfg/Makefile.depend17
-rw-r--r--sbin/zfsbootcfg/zfsbootcfg.82
-rw-r--r--sbin/zfsbootcfg/zfsbootcfg.c3
989 files changed, 14680 insertions, 10365 deletions
diff --git a/sbin/Makefile b/sbin/Makefile
index 69cf51a83e26..0c648f29badb 100644
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.5 (Berkeley) 3/31/94
-# $FreeBSD$
.include <src.opts.mk>
@@ -9,6 +7,7 @@ SUBDIR=adjkerntz \
comcontrol \
conscontrol \
ddb \
+ devd \
devfs \
devmatch \
dhclient \
@@ -72,7 +71,6 @@ SUBDIR+= ping
.endif
SUBDIR.${MK_CCD}+= ccdconfig
-SUBDIR.${MK_CXX}+= devd
SUBDIR.${MK_HAST}+= hastctl
SUBDIR.${MK_HAST}+= hastd
SUBDIR.${MK_INET6}+= rtsol
diff --git a/sbin/Makefile.amd64 b/sbin/Makefile.amd64
index 4135c44082c9..4904b2ebfe87 100644
--- a/sbin/Makefile.amd64
+++ b/sbin/Makefile.amd64
@@ -1,5 +1,3 @@
-# $FreeBSD$
SUBDIR += bsdlabel
SUBDIR += fdisk
-SUBDIR += sconfig
diff --git a/sbin/Makefile.arm b/sbin/Makefile.arm
index 2d231b0cb2b0..4904b2ebfe87 100644
--- a/sbin/Makefile.arm
+++ b/sbin/Makefile.arm
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR += bsdlabel
SUBDIR += fdisk
diff --git a/sbin/Makefile.i386 b/sbin/Makefile.i386
index 4135c44082c9..4904b2ebfe87 100644
--- a/sbin/Makefile.i386
+++ b/sbin/Makefile.i386
@@ -1,5 +1,3 @@
-# $FreeBSD$
SUBDIR += bsdlabel
SUBDIR += fdisk
-SUBDIR += sconfig
diff --git a/sbin/Makefile.inc b/sbin/Makefile.inc
index 401e2a8e3491..a9e857c046de 100644
--- a/sbin/Makefile.inc
+++ b/sbin/Makefile.inc
@@ -1,5 +1,3 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 6/8/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/sbin/Makefile.powerpc64 b/sbin/Makefile.powerpc64
index 2d231b0cb2b0..4904b2ebfe87 100644
--- a/sbin/Makefile.powerpc64
+++ b/sbin/Makefile.powerpc64
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR += bsdlabel
SUBDIR += fdisk
diff --git a/sbin/adjkerntz/Makefile b/sbin/adjkerntz/Makefile
index e30841e3ae2d..1fa9b74b90bc 100644
--- a/sbin/adjkerntz/Makefile
+++ b/sbin/adjkerntz/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE=runtime
PROG= adjkerntz
diff --git a/sbin/adjkerntz/Makefile.depend b/sbin/adjkerntz/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/sbin/adjkerntz/Makefile.depend
+++ b/sbin/adjkerntz/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/adjkerntz/adjkerntz.8 b/sbin/adjkerntz/adjkerntz.8
index 1bd1391b8ccb..787282348a91 100644
--- a/sbin/adjkerntz/adjkerntz.8
+++ b/sbin/adjkerntz/adjkerntz.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd March 8, 2012
.Dt ADJKERNTZ 8
.Os
diff --git a/sbin/adjkerntz/adjkerntz.c b/sbin/adjkerntz/adjkerntz.c
index e6cadcf7f189..b231e1647b33 100644
--- a/sbin/adjkerntz/adjkerntz.c
+++ b/sbin/adjkerntz/adjkerntz.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1993-1998 by Andrey A. Chernov, Moscow, Russia.
* All rights reserved.
@@ -26,16 +26,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#)Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia.\n\
- All rights reserved.\n";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Andrey A. Chernov <ache@astral.msk.su> Dec 20 1993
*
@@ -67,7 +57,7 @@ __FBSDID("$FreeBSD$");
#define REPORT_PERIOD (30*60)
static void fake(int);
-static void usage(void);
+static void usage(void) __dead2;
static void
fake(int unused __unused)
diff --git a/sbin/adjkerntz/pathnames.h b/sbin/adjkerntz/pathnames.h
index 43356cd357a9..3b6fa96149a5 100644
--- a/sbin/adjkerntz/pathnames.h
+++ b/sbin/adjkerntz/pathnames.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1993 by Andrew A. Chernov, Moscow, Russia.
* All rights reserved.
@@ -24,8 +24,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <paths.h>
diff --git a/sbin/bectl/Makefile b/sbin/bectl/Makefile
index 46d43306b9ca..d640de33bf72 100644
--- a/sbin/bectl/Makefile
+++ b/sbin/bectl/Makefile
@@ -1,8 +1,7 @@
-# $FreeBSD$
.include <src.opts.mk>
-PACKAGE=runtime
+PACKAGE=zfs
PROG= bectl
MAN= bectl.8
diff --git a/sbin/bectl/Makefile.depend b/sbin/bectl/Makefile.depend
index 125289c3cdc7..f04ca630e059 100644
--- a/sbin/bectl/Makefile.depend
+++ b/sbin/bectl/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/sbin/bectl/bectl.8 b/sbin/bectl/bectl.8
index 79bdec751a86..93244c52ce4d 100644
--- a/sbin/bectl/bectl.8
+++ b/sbin/bectl/bectl.8
@@ -1,5 +1,5 @@
.\"
-.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2017 Kyle J. Kneitinger <kyle@kneit.in>
.\"
@@ -13,11 +13,7 @@
.\" documentation and/or other materials provided with the distribution.
.\"
.\"
-.\" @(#)be.1
-.\"
-.\" $FreeBSD$
-.\"
-.Dd March 31, 2022
+.Dd October 5, 2023
.Dt BECTL 8
.Os
.Sh NAME
@@ -25,74 +21,105 @@
.Nd Utility to manage boot environments on ZFS
.Sh SYNOPSIS
.Nm
+.Op Fl h\&?
+.Nm
+.Op Fl r Ar beroot
.Cm activate
.Op Fl t | Fl T
.Ar beName
.Nm
+.Op Fl r Ar beroot
.Cm check
.Nm
+.Op Fl r Ar beroot
.Cm create
.Op Fl r
.Op Fl e Brq Ar nonActiveBe | Ar beName Ns Cm @ Ns Ar snapshot
.Ar newBeName
.Nm
+.Op Fl r Ar beroot
.Cm create
.Op Fl r
.Ar beName@snapshot
.Nm
+.Op Fl r Ar beroot
.Cm destroy
.Op Fl \&Fo
.Ar beName Ns Op Cm @ Ns Ar snapshot
.Nm
+.Op Fl r Ar beroot
.Cm export
.Ar sourceBe
.Nm
+.Op Fl r Ar beroot
.Cm import
.Ar targetBe
.Nm
+.Op Fl r Ar beroot
.Cm jail
.Op Fl bU
.Oo Bro Fl o Ar key Ns Cm = Ns Ar value | Fl u Ar key Brc Oc Ns ...
.Ar beName
.Op Ar utility Op Ar argument ...
.Nm
+.Op Fl r Ar beroot
.Cm list
.Op Fl aDHs
.Op Fl c Ar property
.Op Fl C Ar property
.Oo Bro Fl c Ar property | Fl C Ar property Brc Oc
.Nm
+.Op Fl r Ar beroot
.Cm mount
.Ar beName
.Op Ar mountpoint
.Nm
+.Op Fl r Ar beroot
.Cm rename
.Ar origBeName
.Ar newBeName
.Nm
+.Op Fl r Ar beroot
.Brq Cm ujail | unjail
.Brq Ar jailId | jailName | beName
.Nm
+.Op Fl r Ar beroot
.Brq Cm umount | unmount
.Op Fl f
.Ar beName
-.Pp
-.Nm
-.Op Fl h\&?
.Sh DESCRIPTION
The
.Nm
command is used to setup and interact with ZFS boot environments, which are
bootable clones of datasets.
.Pp
-Boot environments
-allow the system to be upgraded, while preserving the old system environment in
-a separate ZFS dataset.
+A boot environment allows the system to be upgraded, while preserving the
+pre-upgrade system environment.
.Pp
-The following commands are supported by
-.Nm :
+.Nm
+itself accepts an
+.Fl r
+flag specified before the command to indicate the
+.Ar beroot
+that should be used as the boot environment root, or the dataset whose children
+are all boot environments.
+Normally this information is derived from the bootfs property of the pool that
+is mounted at
+.Pa / ,
+but it is useful when the system has not been booted into a ZFS root or a
+different pool should be operated on.
+For instance, booting into the recovery media and manually importing a pool from
+one of the system's resident disks will require the
+.Fl r
+flag to work.
+.Ss Supported Subcommands and Flags
.Bl -tag -width activate
.It Xo
+.Fl h |
+.Fl \&?
+.Xc
+Print usage information.
+.It Xo
.Cm activate
.Op Fl t | Fl T
.Ar beName
@@ -141,11 +168,13 @@ flag is specified, the new environment will be cloned from the given
.Ar nonActiveBe
or
.Ar beName Ns Cm @ Ns Ar snapshot .
-Otherwise, the new environment will be created from the currently booted environment.
+Otherwise, the new environment will be created from the currently booted
+environment.
.Pp
If
.Nm
-is creating from another boot environment, a snapshot of that boot environment will be created to clone from.
+is creating from another boot environment, a snapshot of that boot environment
+will be created to clone from.
.It Xo
.Cm create
.Op Fl r
@@ -162,7 +191,7 @@ See
.Sx Boot Environment Structures
for a discussion on different layouts.
.Pp
-No new boot environment is created with this command.
+No new boot environment is created with this subcommand.
.It Xo
.Cm destroy
.Op Fl \&Fo
@@ -276,7 +305,6 @@ is used on next boot once
.Pq Em \&T ;
or combination of
.Pq Em \&NRT .
-.Pp
.Bl -tag -width indent
.It Fl a
Display all datasets.
@@ -290,18 +318,20 @@ arbitrary white space.
.It Fl s
Display all snapshots as well.
.It Fl c Ar property
-Sort boot environments by given property name.
+Sort boot environments by the given ZFS dataset property.
The following properties are supported:
.Pp
.Bl -tag -width 4n -offset indent -compact
-.It name (default output)
+.It name (the default)
.It creation
.It origin
.It used
-.It usedds
-.It usedsnap
-.It usedrefreserv
+.It usedbydataset
+.It usedbyrefreservation
+.It usedbysnapshots
.El
+.Pp
+Short forms usedds, usedrefreserv and usedsnap are also supported.
.It Fl C Ar property
Same as the
.Fl c
@@ -316,10 +346,28 @@ or
.Fl a
option is used.
.It Cm mount Ar beName Op Ar mountpoint
-Temporarily mount the boot environment.
-Mount at the specified
+Mount the given boot environment.
+.Pp
+If a nonexistent
+.Ar mountpoint
+is given:
+.Nm
+will make the directory, including intermediate directories as required.
+.Pp
+If no
.Ar mountpoint
-if provided.
+is given:
+.Nm
+will make a directory such as
+.Pa be_mount.c6Sf
+in
+.Pa /tmp .
+Randomness in the last four characters of the directory name will prevent
+mount point conflicts.
+Unmount of an environment, followed by mount of the same environment
+without giving a
+.Ar mountpoint ,
+will result in a different randomly-named mountpoint.
.It Cm rename Ar origBeName newBeName
Rename the given
.Ar origBeName
@@ -343,14 +391,9 @@ Unmount the given boot environment, if it is mounted.
Specifying
.Fl f
will force the unmount if busy.
-.El
.Pp
-.Nm
-prints usage information if
-.Fl h
-or
-.Fl \&?
-is specified.
+Unmount will not remove the mount point.
+.El
.Ss Boot Environment Structures
The traditional
.Fx
@@ -373,9 +416,10 @@ NAME CANMOUNT MOUNTPOINT
zroot
zroot/ROOT noauto none
zroot/ROOT/default noauto none
+zroot/home on /home
zroot/usr off /usr
-zroot/usr/home on /usr/home
-zroot/var on /var
+zroot/usr/src on /usr/src
+zroot/var off /var
.Ed
.Pp
In that example,
@@ -387,9 +431,9 @@ set to
thus files in
.Pa /usr
typically fall into the boot environment because this dataset is not mounted.
-.Pa zroot/usr/home
+.Pa zroot/usr/src
is mounted, thus files in
-.Pa /usr/home
+.Pa /usr/src
are not in the boot environment.
.Pp
The other style of boot environments in use, frequently called
@@ -423,7 +467,7 @@ In this example,
is excluded from the boot environment.
.Pp
.Nm
-commands that have their own
+subcommands that have their own
.Fl r
operate on this second,
.Dq deep
@@ -435,13 +479,14 @@ A future version of
may default to handling both styles and deprecate the various
.Fl r
flags.
-\" .Sh EXAMPLES
-\" .Bl -bullet
-\" .It
-\" To fill in with jail upgrade example when behavior is firm.
-\" .El
+.\" .Sh EXAMPLES
+.\" .Bl -bullet
+.\" .It
+.\" To fill in with jail upgrade example when behavior is firm.
+.\" .El
.Sh SEE ALSO
.Xr libbe 3 ,
+.Xr zfsprops 7 ,
.Xr beinstall.sh 8 ,
.Xr jail 8 ,
.Xr zfs 8 ,
diff --git a/sbin/bectl/bectl.c b/sbin/bectl/bectl.c
index 2b7af4e55419..e398e055a3b2 100644
--- a/sbin/bectl/bectl.c
+++ b/sbin/bectl/bectl.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2017 Kyle J. Kneitinger <kyle@kneit.in>
*
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/mount.h>
#include <errno.h>
@@ -69,23 +66,23 @@ usage(bool explicit)
fprintf(fp, "%s",
"Usage:\tbectl {-h | -? | subcommand [args...]}\n"
#if SOON
- "\tbectl add (path)*\n"
+ "\tbectl [-r beroot] add (path)*\n"
#endif
- "\tbectl activate [-t] beName\n"
- "\tbectl activate [-T]\n"
- "\tbectl check\n"
- "\tbectl create [-r] [-e {nonActiveBe | beName@snapshot}] beName\n"
- "\tbectl create [-r] beName@snapshot\n"
- "\tbectl destroy [-Fo] {beName | beName@snapshot}\n"
- "\tbectl export sourceBe\n"
- "\tbectl import targetBe\n"
- "\tbectl jail [-bU] [{-o key=value | -u key}]... beName\n"
+ "\tbectl [-r beroot] activate [-t] beName\n"
+ "\tbectl [-r beroot] activate [-T]\n"
+ "\tbectl [-r beroot] check\n"
+ "\tbectl [-r beroot] create [-r] [-e {nonActiveBe | beName@snapshot}] beName\n"
+ "\tbectl [-r beroot] create [-r] beName@snapshot\n"
+ "\tbectl [-r beroot] destroy [-Fo] {beName | beName@snapshot}\n"
+ "\tbectl [-r beroot] export sourceBe\n"
+ "\tbectl [-r beroot] import targetBe\n"
+ "\tbectl [-r beroot] jail [-bU] [{-o key=value | -u key}]... beName\n"
"\t [utility [argument ...]]\n"
- "\tbectl list [-aDHs] [{-c property | -C property}]\n"
- "\tbectl mount beName [mountpoint]\n"
- "\tbectl rename origBeName newBeName\n"
- "\tbectl {ujail | unjail} {jailID | jailName | beName}\n"
- "\tbectl {umount | unmount} [-f] beName\n");
+ "\tbectl [-r beroot] list [-aDHs] [{-c property | -C property}]\n"
+ "\tbectl [-r beroot] mount beName [mountpoint]\n"
+ "\tbectl [-r beroot] rename origBeName newBeName\n"
+ "\tbectl [-r beroot] {ujail | unjail} {jailID | jailName | beName}\n"
+ "\tbectl [-r beroot] {umount | unmount} [-f] beName\n");
return (explicit ? 0 : EX_USAGE);
}
@@ -362,7 +359,8 @@ static int
bectl_cmd_destroy(int argc, char *argv[])
{
nvlist_t *props;
- char *origin, *target, targetds[BE_MAXPATHLEN];
+ char *target, targetds[BE_MAXPATHLEN];
+ const char *origin;
int err, flags, opt;
flags = 0;
@@ -441,7 +439,7 @@ bectl_cmd_mount(int argc, char *argv[])
switch (err) {
case BE_ERR_SUCCESS:
- printf("Successfully mounted %s at %s\n", bootenv, result_loc);
+ printf("%s\n", result_loc);
break;
default:
fprintf(stderr,
diff --git a/sbin/bectl/bectl.h b/sbin/bectl/bectl.h
index 878af24f0cbb..b8b824b18010 100644
--- a/sbin/bectl/bectl.h
+++ b/sbin/bectl/bectl.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
*
@@ -23,8 +23,6 @@
* 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$
*/
int usage(bool explicit);
diff --git a/sbin/bectl/bectl_jail.c b/sbin/bectl/bectl_jail.c
index 1d7d4a1496a2..fa063962dada 100644
--- a/sbin/bectl/bectl_jail.c
+++ b/sbin/bectl/bectl_jail.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
*
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/jail.h>
#include <sys/mount.h>
@@ -133,7 +130,8 @@ jailparam_delarg(char *arg)
static int
build_jailcmd(char ***argvp, bool interactive, int argc, char *argv[])
{
- char *cmd, **jargv, *name, *val;
+ char *cmd, **jargv;
+ const char *name, *val;
nvpair_t *nvp;
size_t i, iarg, nargv;
@@ -404,7 +402,7 @@ static int
bectl_locate_jail(const char *ident)
{
nvlist_t *belist, *props;
- char *mnt;
+ const char *mnt;
int jid;
/* Try the easy-match first */
diff --git a/sbin/bectl/bectl_list.c b/sbin/bectl/bectl_list.c
index e43c3000d8f2..c158aa9b1600 100644
--- a/sbin/bectl/bectl_list.c
+++ b/sbin/bectl/bectl_list.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
*
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <stdbool.h>
#include <stdio.h>
@@ -39,8 +36,8 @@ __FBSDID("$FreeBSD$");
#include "bectl.h"
struct sort_column {
- char *name;
- char *val;
+ const char *name;
+ const char *val;
nvlist_t *nvl;
};
@@ -80,7 +77,7 @@ static unsigned long long dataset_space(const char *oname);
static const char *
get_origin_props(nvlist_t *dsprops, nvlist_t **originprops)
{
- char *propstr;
+ const char *propstr;
if (nvlist_lookup_string(dsprops, "origin", &propstr) == 0) {
if (be_prop_list_alloc(originprops) != 0) {
@@ -119,7 +116,8 @@ static unsigned long long
dataset_space(const char *oname)
{
unsigned long long space;
- char *dsname, *propstr, *sep;
+ char *dsname, *sep;
+ const char *propstr;
nvlist_t *dsprops;
space = 0;
@@ -179,8 +177,7 @@ print_info(const char *name, nvlist_t *dsprops, struct printc *pc)
char buf[BUFSZ];
unsigned long long ctimenum, space;
nvlist_t *originprops;
- const char *oname;
- char *dsname, *propstr;
+ const char *oname, *dsname, *propstr;
int active_colsz;
boolean_t active_now, active_reboot, bootonce;
@@ -293,10 +290,9 @@ print_info(const char *name, nvlist_t *dsprops, struct printc *pc)
static void
print_headers(nvlist_t *props, struct printc *pc)
{
- const char *chosen_be_header;
+ const char *chosen_be_header, *propstr;
nvpair_t *cur;
nvlist_t *dsprops;
- char *propstr;
size_t be_maxcol, mount_colsz;
if (pc->show_all_datasets || pc->show_snaps)
diff --git a/sbin/bectl/tests/Makefile b/sbin/bectl/tests/Makefile
index 10e23336d345..5da29657bea1 100644
--- a/sbin/bectl/tests/Makefile
+++ b/sbin/bectl/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/sbin/bectl/tests/bectl_test.sh b/sbin/bectl/tests/bectl_test.sh
index b101591c3ee9..0f167829cf46 100755
--- a/sbin/bectl/tests/bectl_test.sh
+++ b/sbin/bectl/tests/bectl_test.sh
@@ -1,5 +1,5 @@
#
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
#
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
ZPOOL_NAME_FILE=zpool_name
get_zpool_name()
@@ -525,6 +524,59 @@ bectl_jail_cleanup()
bectl_cleanup ${zpool}
}
+atf_test_case bectl_promotion cleanup
+bectl_promotion_head()
+{
+ atf_set "descr" "Check bectl promotion upon activation"
+ atf_set "require.user" root
+}
+bectl_promotion_body()
+{
+ if [ "$(atf_config_get ci false)" = "true" ] && \
+ [ "$(uname -p)" = "i386" ]; then
+ atf_skip "https://bugs.freebsd.org/249055"
+ fi
+
+ if [ "$(atf_config_get ci false)" = "true" ] && \
+ [ "$(uname -p)" = "armv7" ]; then
+ atf_skip "https://bugs.freebsd.org/249229"
+ fi
+
+ cwd=$(realpath .)
+ zpool=$(make_zpool_name)
+ disk=${cwd}/disk.img
+ mount=${cwd}/mnt
+ root=${mount}/root
+
+ bectl_create_deep_setup ${zpool} ${disk} ${mount}
+ atf_check mkdir -p ${root}
+
+ # Sleeps interspersed to workaround some naming quirks; notably,
+ # bectl will append a serial if two snapshots were created within
+ # the same second, but it can only do that for the one root it's
+ # operating on. It won't check that other roots don't have a snapshot
+ # with the same name, and the promotion will fail.
+ atf_check bectl -r ${zpool}/ROOT rename default A
+ sleep 1
+ atf_check bectl -r ${zpool}/ROOT create -r -e A B
+ sleep 1
+ atf_check bectl -r ${zpool}/ROOT create -r -e B C
+
+ # C should be a clone of B to start with
+ atf_check -o not-inline:"-" zfs list -Hr -o origin ${zpool}/ROOT/C
+
+ # Activating it should then promote it all the way out of clone-hood.
+ # This entails two promotes internally, as the first would promote it to
+ # a snapshot of A before finally promoting it the second time out of
+ # clone status.
+ atf_check -o not-empty bectl -r ${zpool}/ROOT activate C
+ atf_check -o inline:"-\n-\n" zfs list -Hr -o origin ${zpool}/ROOT/C
+}
+bectl_promotion_cleanup()
+{
+ bectl_cleanup $(get_zpool_name)
+}
+
atf_init_test_cases()
{
atf_add_test_case bectl_create
@@ -534,4 +586,5 @@ atf_init_test_cases()
atf_add_test_case bectl_mount
atf_add_test_case bectl_rename
atf_add_test_case bectl_jail
+ atf_add_test_case bectl_promotion
}
diff --git a/sbin/bsdlabel/Makefile b/sbin/bsdlabel/Makefile
index 6921a655af10..9bfa0fad6573 100644
--- a/sbin/bsdlabel/Makefile
+++ b/sbin/bsdlabel/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.2 (Berkeley) 3/17/94
-# $FreeBSD$
.PATH: ${SRCTOP}/sys/geom
diff --git a/sbin/bsdlabel/Makefile.depend b/sbin/bsdlabel/Makefile.depend
index 0220673c9076..0dd05cace3c0 100644
--- a/sbin/bsdlabel/Makefile.depend
+++ b/sbin/bsdlabel/Makefile.depend
@@ -1,16 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libexpat \
lib/libgeom \
- lib/libsbuf \
.include <dirdeps.mk>
diff --git a/sbin/bsdlabel/bsdlabel.8 b/sbin/bsdlabel/bsdlabel.8
index fe2e6825de03..0e5b35a0588c 100644
--- a/sbin/bsdlabel/bsdlabel.8
+++ b/sbin/bsdlabel/bsdlabel.8
@@ -28,9 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
-.\" $FreeBSD$
-.\"
.Dd October 5, 2016
.Dt BSDLABEL 8
.Os
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
index 943f37207fc2..2c03117e344a 100644
--- a/sbin/bsdlabel/bsdlabel.c
+++ b/sbin/bsdlabel/bsdlabel.c
@@ -42,21 +42,6 @@
* from: $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk $
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1987, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 1/7/94";
-/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <stdint.h>
#include <sys/file.h>
@@ -146,7 +131,7 @@ main(int argc, char *argv[])
FILE *t;
int ch, error, fd;
const char *name;
-
+
error = 0;
name = NULL;
@@ -1094,7 +1079,7 @@ checklabel(struct disklabel *lp)
struct partition *pp;
int i, errors = 0;
char part;
- u_long base_offset, needed, total_size, total_percent, current_offset;
+ u_long base_offset, needed, total_percent, current_offset;
long free_space;
int seen_default_offset;
int hog_part;
@@ -1173,7 +1158,6 @@ checklabel(struct disklabel *lp)
/* first allocate space to the partitions, then offsets */
- total_size = 0; /* in sectors */
total_percent = 0; /* in percent */
hog_part = -1;
/* find all fixed partitions */
@@ -1234,9 +1218,6 @@ checklabel(struct disklabel *lp)
size /= lp->d_secsize;
pp->p_size = size;
}
- /* else already in sectors */
- if (i != RAW_PART)
- total_size += size;
}
}
}
@@ -1272,7 +1253,6 @@ checklabel(struct disklabel *lp)
if (part_set[i] && part_size_type[i] == '%') {
/* careful of overflows! and integer roundoff */
pp->p_size = ((double)pp->p_size/100) * free_space;
- total_size += pp->p_size;
/* FIX we can lose a sector or so due to roundoff per
partition. A more complex algorithm could avoid that */
@@ -1328,7 +1308,6 @@ checklabel(struct disklabel *lp)
} else {
lp->d_partitions[hog_part].p_size = current_offset -
base_offset - needed;
- total_size += lp->d_partitions[hog_part].p_size;
}
}
diff --git a/sbin/bsdlabel/disktab b/sbin/bsdlabel/disktab
index cb0fba033699..72ff689c82ff 100644
--- a/sbin/bsdlabel/disktab
+++ b/sbin/bsdlabel/disktab
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Disk geometry and partition layout tables.
# See disktab(5) for format of this file.
diff --git a/sbin/bsdlabel/pathnames.h b/sbin/bsdlabel/pathnames.h
index 77ee59e0279e..4d215eb72e33 100644
--- a/sbin/bsdlabel/pathnames.h
+++ b/sbin/bsdlabel/pathnames.h
@@ -27,9 +27,6 @@
* 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.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/5/93
- * $FreeBSD$
*/
#include <paths.h>
diff --git a/sbin/camcontrol/Makefile b/sbin/camcontrol/Makefile
index 958f37714662..d47dbdc43bd7 100644
--- a/sbin/camcontrol/Makefile
+++ b/sbin/camcontrol/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/sbin/camcontrol/Makefile.depend b/sbin/camcontrol/Makefile.depend
index ee06e1c20939..0ef6390836dd 100644
--- a/sbin/camcontrol/Makefile.depend
+++ b/sbin/camcontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/camcontrol/attrib.c b/sbin/camcontrol/attrib.c
index 05cabb1b8145..7e89dbc3d48e 100644
--- a/sbin/camcontrol/attrib.c
+++ b/sbin/camcontrol/attrib.c
@@ -34,8 +34,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/ioctl.h>
#include <sys/stdint.h>
#include <sys/types.h>
diff --git a/sbin/camcontrol/camcontrol.8 b/sbin/camcontrol/camcontrol.8
index 3d65487cc60e..3bbd81dab033 100644
--- a/sbin/camcontrol/camcontrol.8
+++ b/sbin/camcontrol/camcontrol.8
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd October 20, 2021
+.Dd June 1, 2023
.Dt CAMCONTROL 8
.Os
.Sh NAME
@@ -377,9 +375,10 @@
.Sh DESCRIPTION
The
.Nm
-utility is designed to provide a way for users to access and control the
+utility allows users to access and control the
.Fx
-CAM subsystem.
+CAM subsystem described in
+.Xr cam 4 .
.Pp
The
.Nm
@@ -2971,6 +2970,7 @@ that was created using this format string.
.Xr cam 4 ,
.Xr pass 4 ,
.Xr xpt 4 ,
+.Xr diskinfo 8 ,
.Xr trim 8 ,
.Xr zonectl 8
.Sh HISTORY
diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c
index 489c3026537a..9417943afcb3 100644
--- a/sbin/camcontrol/camcontrol.c
+++ b/sbin/camcontrol/camcontrol.c
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/ioctl.h>
#include <sys/stdint.h>
#include <sys/types.h>
@@ -36,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/endian.h>
#include <sys/sbuf.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -123,18 +122,21 @@ typedef enum {
CAM_ARG_LUN = 0x00000010,
CAM_ARG_EJECT = 0x00000020,
CAM_ARG_UNIT = 0x00000040,
- CAM_ARG_FORMAT_BLOCK = 0x00000080,
- CAM_ARG_FORMAT_BFI = 0x00000100,
- CAM_ARG_FORMAT_PHYS = 0x00000200,
- CAM_ARG_PLIST = 0x00000400,
- CAM_ARG_GLIST = 0x00000800,
+ /* unused 0x00000080 */
+ /* unused 0x00000100 */
+ /* unused 0x00000200 */
+ /* unused 0x00000400 */
+ /* unused 0x00000800 */
CAM_ARG_GET_SERIAL = 0x00001000,
CAM_ARG_GET_STDINQ = 0x00002000,
CAM_ARG_GET_XFERRATE = 0x00004000,
CAM_ARG_INQ_MASK = 0x00007000,
+ /* unused 0x00008000 */
+ /* unused 0x00010000 */
CAM_ARG_TIMEOUT = 0x00020000,
CAM_ARG_CMD_IN = 0x00040000,
CAM_ARG_CMD_OUT = 0x00080000,
+ /* unused 0x00100000 */
CAM_ARG_ERR_RECOVER = 0x00200000,
CAM_ARG_RETRIES = 0x00400000,
CAM_ARG_START_UNIT = 0x00800000,
@@ -145,6 +147,7 @@ typedef enum {
CAM_ARG_DEBUG_XPT = 0x10000000,
CAM_ARG_DEBUG_PERIPH = 0x20000000,
CAM_ARG_DEBUG_PROBE = 0x40000000,
+ /* unused 0x80000000 */
} cam_argmask;
struct camcontrol_opts {
@@ -156,9 +159,9 @@ struct camcontrol_opts {
struct ata_set_max_pwd
{
- u_int16_t reserved1;
- u_int8_t password[32];
- u_int16_t reserved2[239];
+ uint16_t reserved1;
+ uint8_t password[32];
+ uint16_t reserved2[239];
};
static struct scsi_nv task_attrs[] = {
@@ -1042,7 +1045,7 @@ scsiinquiry(struct cam_device *device, int task_attr, int retry_count,
* - The SCSI spec says that when a length field is only 1 byte,
* a value of 0 will be interpreted as 256. Therefore
* scsi_inquiry() will convert an inq_len (which is passed in as
- * a u_int32_t, but the field in the CDB is only 1 byte) of 256
+ * a uint32_t, but the field in the CDB is only 1 byte) of 256
* to 0. Evidently, very few devices meet the spec in that
* regard. Some devices, like many Seagate disks, take the 0 as
* 0, and don't return any data. One Pioneer DVD-R drive
@@ -1070,7 +1073,7 @@ scsiinquiry(struct cam_device *device, int task_attr, int retry_count,
/* retries */ retry_count,
/* cbfcnp */ NULL,
/* tag_action */ task_attr,
- /* inq_buf */ (u_int8_t *)inq_buf,
+ /* inq_buf */ (uint8_t *)inq_buf,
/* inq_len */ SHORT_INQUIRY_LENGTH,
/* evpd */ 0,
/* page_code */ 0,
@@ -1143,7 +1146,7 @@ scsiserial(struct cam_device *device, int task_attr, int retry_count,
/*retries*/ retry_count,
/*cbfcnp*/ NULL,
/* tag_action */ task_attr,
- /* inq_buf */ (u_int8_t *)serial_buf,
+ /* inq_buf */ (uint8_t *)serial_buf,
/* inq_len */ sizeof(*serial_buf),
/* evpd */ 1,
/* page_code */ SVPD_UNIT_SERIAL_NUMBER,
@@ -1198,8 +1201,8 @@ int
camxferrate(struct cam_device *device)
{
struct ccb_pathinq cpi;
- u_int32_t freq = 0;
- u_int32_t speed = 0;
+ uint32_t freq = 0;
+ uint32_t speed = 0;
union ccb *ccb;
u_int mb;
int retval = 0;
@@ -1360,8 +1363,8 @@ xferrate_bailout:
static void
atahpa_print(struct ata_params *parm, u_int64_t hpasize, int header)
{
- u_int32_t lbasize = (u_int32_t)parm->lba_size_1 |
- ((u_int32_t)parm->lba_size_2 << 16);
+ uint32_t lbasize = (uint32_t)parm->lba_size_1 |
+ ((uint32_t)parm->lba_size_2 << 16);
u_int64_t lbasize48 = ((u_int64_t)parm->lba_size48_1) |
((u_int64_t)parm->lba_size48_2 << 16) |
@@ -1393,8 +1396,8 @@ atahpa_print(struct ata_params *parm, u_int64_t hpasize, int header)
static void
ataama_print(struct ata_params *parm, u_int64_t nativesize, int header)
{
- u_int32_t lbasize = (u_int32_t)parm->lba_size_1 |
- ((u_int32_t)parm->lba_size_2 << 16);
+ uint32_t lbasize = (uint32_t)parm->lba_size_1 |
+ ((uint32_t)parm->lba_size_2 << 16);
u_int64_t lbasize48 = ((u_int64_t)parm->lba_size48_1) |
((u_int64_t)parm->lba_size48_2 << 16) |
@@ -1432,8 +1435,8 @@ static void
atacapprint(struct ata_params *parm)
{
const char *proto;
- u_int32_t lbasize = (u_int32_t)parm->lba_size_1 |
- ((u_int32_t)parm->lba_size_2 << 16);
+ uint32_t lbasize = (uint32_t)parm->lba_size_1 |
+ ((uint32_t)parm->lba_size_2 << 16);
u_int64_t lbasize48 = ((u_int64_t)parm->lba_size48_1) |
((u_int64_t)parm->lba_size48_2 << 16) |
@@ -1750,7 +1753,7 @@ scsi_cam_pass_16_send(struct cam_device *device, union ccb *ccb)
/*
* Consider any non-CAM_REQ_CMP status as error and report it here,
- * unless caller set AP_FLAG_CHK_COND, in which case it is reponsible.
+ * unless caller set AP_FLAG_CHK_COND, in which case it is responsible.
*/
if (!(ata_pass_16->flags & AP_FLAG_CHK_COND) &&
(ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
@@ -1788,7 +1791,7 @@ ata_cam_send(struct cam_device *device, union ccb *ccb)
/*
* Consider any non-CAM_REQ_CMP status as error and report it here,
- * unless caller set AP_FLAG_CHK_COND, in which case it is reponsible.
+ * unless caller set AP_FLAG_CHK_COND, in which case it is responsible.
*/
if (!(ccb->ataio.cmd.flags & CAM_ATAIO_NEEDRESULT) &&
(ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
@@ -1805,10 +1808,10 @@ ata_cam_send(struct cam_device *device, union ccb *ccb)
static int
ata_do_pass_16(struct cam_device *device, union ccb *ccb, int retries,
- u_int32_t flags, u_int8_t protocol, u_int8_t ata_flags,
- u_int8_t tag_action, u_int8_t command, u_int16_t features,
- u_int64_t lba, u_int16_t sector_count, u_int8_t *data_ptr,
- u_int16_t dxfer_len, int timeout)
+ uint32_t flags, uint8_t protocol, uint8_t ata_flags,
+ uint8_t tag_action, uint8_t command, uint16_t features,
+ u_int64_t lba, uint16_t sector_count, uint8_t *data_ptr,
+ uint16_t dxfer_len, int timeout)
{
if (data_ptr != NULL) {
if (flags & CAM_DIR_OUT)
@@ -1862,10 +1865,10 @@ ata_try_pass_16(struct cam_device *device)
static int
ata_do_cmd(struct cam_device *device, union ccb *ccb, int retries,
- u_int32_t flags, u_int8_t protocol, u_int8_t ata_flags,
- u_int8_t tag_action, u_int8_t command, u_int16_t features,
- u_int64_t lba, u_int16_t sector_count, u_int8_t *data_ptr,
- u_int16_t dxfer_len, int timeout, int force48bit)
+ uint32_t flags, uint8_t protocol, uint8_t ata_flags,
+ uint8_t tag_action, uint8_t command, uint16_t features,
+ u_int64_t lba, uint16_t sector_count, uint8_t *data_ptr,
+ uint16_t dxfer_len, int timeout, int force48bit)
{
int retval;
@@ -1962,12 +1965,12 @@ atahpa_proc_resp(struct cam_device *device, union ccb *ccb, u_int64_t *hpasize)
static int
ata_read_native_max(struct cam_device *device, int retry_count,
- u_int32_t timeout, union ccb *ccb,
+ uint32_t timeout, union ccb *ccb,
struct ata_params *parm, u_int64_t *hpasize)
{
int error;
u_int cmd, is48bit;
- u_int8_t protocol;
+ uint8_t protocol;
is48bit = parm->support.command2 & ATA_SUPPORT_ADDRESS48;
protocol = AP_PROTO_NON_DATA;
@@ -2003,12 +2006,12 @@ ata_read_native_max(struct cam_device *device, int retry_count,
static int
atahpa_set_max(struct cam_device *device, int retry_count,
- u_int32_t timeout, union ccb *ccb,
+ uint32_t timeout, union ccb *ccb,
int is48bit, u_int64_t maxsize, int persist)
{
int error;
u_int cmd;
- u_int8_t protocol;
+ uint8_t protocol;
protocol = AP_PROTO_NON_DATA;
@@ -2047,11 +2050,11 @@ atahpa_set_max(struct cam_device *device, int retry_count,
static int
atahpa_password(struct cam_device *device, int retry_count,
- u_int32_t timeout, union ccb *ccb,
+ uint32_t timeout, union ccb *ccb,
int is48bit, struct ata_set_max_pwd *pwd)
{
u_int cmd;
- u_int8_t protocol;
+ uint8_t protocol;
protocol = AP_PROTO_PIO_OUT;
cmd = (is48bit) ? ATA_SET_MAX_ADDRESS48 : ATA_SET_MAX_ADDRESS;
@@ -2068,7 +2071,7 @@ atahpa_password(struct cam_device *device, int retry_count,
/*features*/ATA_HPA_FEAT_SET_PWD,
/*lba*/0,
/*sector_count*/sizeof(*pwd) / 512,
- /*data_ptr*/(u_int8_t*)pwd,
+ /*data_ptr*/(uint8_t*)pwd,
/*dxfer_len*/sizeof(*pwd),
timeout ? timeout : 1000,
is48bit));
@@ -2076,10 +2079,10 @@ atahpa_password(struct cam_device *device, int retry_count,
static int
atahpa_lock(struct cam_device *device, int retry_count,
- u_int32_t timeout, union ccb *ccb, int is48bit)
+ uint32_t timeout, union ccb *ccb, int is48bit)
{
u_int cmd;
- u_int8_t protocol;
+ uint8_t protocol;
protocol = AP_PROTO_NON_DATA;
cmd = (is48bit) ? ATA_SET_MAX_ADDRESS48 : ATA_SET_MAX_ADDRESS;
@@ -2103,11 +2106,11 @@ atahpa_lock(struct cam_device *device, int retry_count,
static int
atahpa_unlock(struct cam_device *device, int retry_count,
- u_int32_t timeout, union ccb *ccb,
+ uint32_t timeout, union ccb *ccb,
int is48bit, struct ata_set_max_pwd *pwd)
{
u_int cmd;
- u_int8_t protocol;
+ uint8_t protocol;
protocol = AP_PROTO_PIO_OUT;
cmd = (is48bit) ? ATA_SET_MAX_ADDRESS48 : ATA_SET_MAX_ADDRESS;
@@ -2124,7 +2127,7 @@ atahpa_unlock(struct cam_device *device, int retry_count,
/*features*/ATA_HPA_FEAT_UNLOCK,
/*lba*/0,
/*sector_count*/sizeof(*pwd) / 512,
- /*data_ptr*/(u_int8_t*)pwd,
+ /*data_ptr*/(uint8_t*)pwd,
/*dxfer_len*/sizeof(*pwd),
timeout ? timeout : 1000,
is48bit));
@@ -2132,10 +2135,10 @@ atahpa_unlock(struct cam_device *device, int retry_count,
static int
atahpa_freeze_lock(struct cam_device *device, int retry_count,
- u_int32_t timeout, union ccb *ccb, int is48bit)
+ uint32_t timeout, union ccb *ccb, int is48bit)
{
u_int cmd;
- u_int8_t protocol;
+ uint8_t protocol;
protocol = AP_PROTO_NON_DATA;
cmd = (is48bit) ? ATA_SET_MAX_ADDRESS48 : ATA_SET_MAX_ADDRESS;
@@ -2159,7 +2162,7 @@ atahpa_freeze_lock(struct cam_device *device, int retry_count,
static int
ata_get_native_max(struct cam_device *device, int retry_count,
- u_int32_t timeout, union ccb *ccb,
+ uint32_t timeout, union ccb *ccb,
u_int64_t *nativesize)
{
int error;
@@ -2188,7 +2191,7 @@ ata_get_native_max(struct cam_device *device, int retry_count,
static int
ataama_set(struct cam_device *device, int retry_count,
- u_int32_t timeout, union ccb *ccb, u_int64_t maxsize)
+ uint32_t timeout, union ccb *ccb, u_int64_t maxsize)
{
int error;
@@ -2220,7 +2223,7 @@ ataama_set(struct cam_device *device, int retry_count,
static int
ataama_freeze(struct cam_device *device, int retry_count,
- u_int32_t timeout, union ccb *ccb)
+ uint32_t timeout, union ccb *ccb)
{
return (ata_do_cmd(device,
@@ -2249,7 +2252,7 @@ ata_do_identify(struct cam_device *device, int retry_count, int timeout,
struct ccb_getdev cgd;
u_int i, error;
int16_t *ptr;
- u_int8_t command, retry_command;
+ uint8_t command, retry_command;
if (get_cpi(device, &cpi) != 0) {
warnx("couldn't get CPI");
@@ -2291,7 +2294,7 @@ retry:
/*features*/0,
/*lba*/0,
/*sector_count*/sizeof(struct ata_params) / 512,
- /*data_ptr*/(u_int8_t *)ptr,
+ /*data_ptr*/(uint8_t *)ptr,
/*dxfer_len*/sizeof(struct ata_params),
/*timeout*/timeout ? timeout : 30 * 1000,
/*force48bit*/0);
@@ -2417,7 +2420,7 @@ enum {
};
static void
-atasecurity_print_time(u_int16_t tw)
+atasecurity_print_time(uint16_t tw)
{
if (tw == 0)
@@ -2428,8 +2431,8 @@ atasecurity_print_time(u_int16_t tw)
printf("%i min", 2 * tw);
}
-static u_int32_t
-atasecurity_erase_timeout_msecs(u_int16_t timeout)
+static uint32_t
+atasecurity_erase_timeout_msecs(uint16_t timeout)
{
if (timeout == 0)
@@ -2442,7 +2445,7 @@ atasecurity_erase_timeout_msecs(u_int16_t timeout)
static void
-atasecurity_notify(u_int8_t command, struct ata_security_password *pwd)
+atasecurity_notify(uint8_t command, struct ata_security_password *pwd)
{
struct ata_cmd cmd;
@@ -2472,7 +2475,7 @@ atasecurity_notify(u_int8_t command, struct ata_security_password *pwd)
static int
atasecurity_freeze(struct cam_device *device, union ccb *ccb,
- int retry_count, u_int32_t timeout, int quiet)
+ int retry_count, uint32_t timeout, int quiet)
{
if (quiet == 0)
@@ -2497,7 +2500,7 @@ atasecurity_freeze(struct cam_device *device, union ccb *ccb,
static int
atasecurity_unlock(struct cam_device *device, union ccb *ccb,
- int retry_count, u_int32_t timeout,
+ int retry_count, uint32_t timeout,
struct ata_security_password *pwd, int quiet)
{
@@ -2516,7 +2519,7 @@ atasecurity_unlock(struct cam_device *device, union ccb *ccb,
/*features*/0,
/*lba*/0,
/*sector_count*/sizeof(*pwd) / 512,
- /*data_ptr*/(u_int8_t *)pwd,
+ /*data_ptr*/(uint8_t *)pwd,
/*dxfer_len*/sizeof(*pwd),
/*timeout*/timeout,
/*force48bit*/0);
@@ -2524,7 +2527,7 @@ atasecurity_unlock(struct cam_device *device, union ccb *ccb,
static int
atasecurity_disable(struct cam_device *device, union ccb *ccb,
- int retry_count, u_int32_t timeout,
+ int retry_count, uint32_t timeout,
struct ata_security_password *pwd, int quiet)
{
@@ -2542,7 +2545,7 @@ atasecurity_disable(struct cam_device *device, union ccb *ccb,
/*features*/0,
/*lba*/0,
/*sector_count*/sizeof(*pwd) / 512,
- /*data_ptr*/(u_int8_t *)pwd,
+ /*data_ptr*/(uint8_t *)pwd,
/*dxfer_len*/sizeof(*pwd),
/*timeout*/timeout,
/*force48bit*/0);
@@ -2582,8 +2585,8 @@ atasecurity_erase_confirm(struct cam_device *device,
static int
atasecurity_erase(struct cam_device *device, union ccb *ccb,
- int retry_count, u_int32_t timeout,
- u_int32_t erase_timeout,
+ int retry_count, uint32_t timeout,
+ uint32_t erase_timeout,
struct ata_security_password *pwd, int quiet)
{
int error;
@@ -2625,7 +2628,7 @@ atasecurity_erase(struct cam_device *device, union ccb *ccb,
/*features*/0,
/*lba*/0,
/*sector_count*/sizeof(*pwd) / 512,
- /*data_ptr*/(u_int8_t *)pwd,
+ /*data_ptr*/(uint8_t *)pwd,
/*dxfer_len*/sizeof(*pwd),
/*timeout*/erase_timeout,
/*force48bit*/0);
@@ -2638,7 +2641,7 @@ atasecurity_erase(struct cam_device *device, union ccb *ccb,
static int
atasecurity_set_password(struct cam_device *device, union ccb *ccb,
- int retry_count, u_int32_t timeout,
+ int retry_count, uint32_t timeout,
struct ata_security_password *pwd, int quiet)
{
@@ -2657,7 +2660,7 @@ atasecurity_set_password(struct cam_device *device, union ccb *ccb,
/*features*/0,
/*lba*/0,
/*sector_count*/sizeof(*pwd) / 512,
- /*data_ptr*/(u_int8_t *)pwd,
+ /*data_ptr*/(uint8_t *)pwd,
/*dxfer_len*/sizeof(*pwd),
/*timeout*/timeout,
/*force48bit*/0);
@@ -2706,7 +2709,7 @@ atasecurity_print(struct ata_params *parm)
* the data will still be copied but no null termination will occur.
*/
static int
-ata_getpwd(u_int8_t *passwd, int max, char opt)
+ata_getpwd(uint8_t *passwd, int max, char opt)
{
int len;
@@ -3823,23 +3826,20 @@ readdefects(struct cam_device *device, int argc, char **argv,
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_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;
+ uint8_t *defect_list = NULL;
+ uint8_t list_format = 0;
+ uint32_t dlist_length = 0;
+ uint32_t returned_length = 0, valid_len = 0;
+ uint32_t num_returned = 0, num_valid = 0;
+ uint32_t max_possible_size = 0, hdr_max = 0;
+ uint32_t starting_offset = 0;
+ uint8_t returned_format, returned_type;
unsigned int i;
- int summary = 0, quiet = 0;
int c, error = 0;
- int lists_specified = 0;
- int get_length = 1, first_pass = 1;
int mads = 0;
+ bool summary = false, quiet = false, list_type_set = false;
+ bool get_length = true, use_12byte = false, first_pass = true;
+ bool hex_format = false;
while ((c = getopt(argc, argv, combinedopt)) != -1) {
switch(c){
@@ -3848,15 +3848,21 @@ readdefects(struct cam_device *device, int argc, char **argv,
scsi_nv_status status;
int entry_num = 0;
+ if (list_type_set) {
+ warnx("%s: -f specified twice", __func__);
+ error = 1;
+ goto defect_bailout;
+ }
+
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[
+ list_format |= defect_list_type_map[
entry_num].value;
- list_type_set = 1;
+ list_type_set = true;
} else {
warnx("%s: %s %s option %s", __func__,
(status == SCSI_NV_AMBIGUOUS) ?
@@ -3868,16 +3874,16 @@ readdefects(struct cam_device *device, int argc, char **argv,
break;
}
case 'G':
- arglist |= CAM_ARG_GLIST;
+ list_format |= SRDD10_GLIST;
break;
case 'P':
- arglist |= CAM_ARG_PLIST;
+ list_format |= SRDD10_PLIST;
break;
case 'q':
- quiet = 1;
+ quiet = true;
break;
case 's':
- summary = 1;
+ summary = true;
break;
case 'S': {
char *endptr;
@@ -3888,52 +3894,48 @@ readdefects(struct cam_device *device, int argc, char **argv,
warnx("invalid starting offset %s", optarg);
goto defect_bailout;
}
+ use_12byte = true;
break;
}
case 'X':
- hex_format = 1;
+ hex_format = true;
break;
default:
break;
}
}
- if (list_type_set == 0) {
+ if (!list_type_set) {
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;
+ if ((list_format & ~SRDD10_DLIST_FORMAT_MASK) == 0)
+ summary = true;
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.
+ * 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. When we're retrying the with
+ * 12-byte command, we're always changing to the 12-byte command and
+ * need to get the length. Simplify the logic below by always setting
+ * use_12byte in this case with this slightly more complex logic here.
*/
- if (use_12byte == 0)
+ if (!use_12byte) {
dlist_length = sizeof(*hdr10);
- else
+ } else {
+retry_12byte:
+ get_length = true;
+ use_12byte = true;
dlist_length = sizeof(*hdr12);
+ }
retry:
if (defect_list != NULL) {
@@ -3979,7 +3981,7 @@ next_batch:
valid_len = ccb->csio.dxfer_len - ccb->csio.resid;
- if (use_12byte == 0) {
+ if (!use_12byte) {
hdr10 = (struct scsi_read_defect_data_hdr_10 *)defect_list;
hdr_size = sizeof(*hdr10);
hdr_max = SRDDH10_MAX_LENGTH;
@@ -4033,8 +4035,8 @@ next_batch:
num_valid = min(returned_length, valid_len - hdr_size);
num_valid /= entry_size;
- if (get_length != 0) {
- get_length = 0;
+ if (get_length) {
+ get_length = false;
if ((ccb->ccb_h.status & CAM_STATUS_MASK) ==
CAM_SCSI_STATUS_ERROR) {
@@ -4055,10 +4057,8 @@ next_batch:
if ((sense_key == SSD_KEY_RECOVERED_ERROR)
&& (asc == 0x1c) && (ascq == 0x00)
&& (returned_length > 0)) {
- if ((use_12byte == 0)
+ if (!use_12byte
&& (returned_length >= max_possible_size)) {
- get_length = 1;
- use_12byte = 1;
goto retry_12byte;
}
dlist_length = returned_length + hdr_size;
@@ -4073,9 +4073,7 @@ next_batch:
* command can support. Retry with the 12
* byte command.
*/
- if (use_12byte == 0) {
- get_length = 1;
- use_12byte = 1;
+ if (!use_12byte) {
goto retry_12byte;
}
dlist_length = returned_length + hdr_size;
@@ -4089,9 +4087,7 @@ next_batch:
* error and no data. Retry with the 12
* byte command.
*/
- if (use_12byte == 0) {
- get_length = 1;
- use_12byte = 1;
+ if (!use_12byte) {
goto retry_12byte;
}
dlist_length = returned_length + hdr_size;
@@ -4104,11 +4100,9 @@ next_batch:
if (returned_length == 0)
dlist_length = SRDD10_MAX_LENGTH;
else {
- if ((use_12byte == 0)
+ if (!use_12byte
&& (returned_length >=
max_possible_size)) {
- get_length = 1;
- use_12byte = 1;
goto retry_12byte;
}
dlist_length = returned_length +
@@ -4124,17 +4118,15 @@ next_batch:
CAM_EPF_ALL, stderr);
goto defect_bailout;
} else {
- if ((use_12byte == 0)
+ if (!use_12byte
&& (returned_length >= max_possible_size)) {
- get_length = 1;
- use_12byte = 1;
goto retry_12byte;
}
dlist_length = returned_length + hdr_size;
}
- if (summary != 0) {
+ if (summary) {
fprintf(stdout, "%u", num_returned);
- if (quiet == 0) {
+ if (!quiet) {
fprintf(stdout, " defect%s",
(num_returned != 1) ? "s" : "");
}
@@ -4218,10 +4210,10 @@ next_batch:
goto defect_bailout;
}
- if (first_pass != 0) {
+ if (first_pass) {
fprintf(stderr, "Got %d defect", num_returned);
- if ((lists_specified == 0) || (num_returned == 0)) {
+ if (!summary || (num_returned == 0)) {
fprintf(stderr, "s.\n");
goto defect_bailout;
} else if (num_returned == 1)
@@ -4229,7 +4221,7 @@ next_batch:
else
fprintf(stderr, "s:\n");
- first_pass = 0;
+ first_pass = false;
}
/*
@@ -4254,7 +4246,7 @@ next_batch:
0 : 1;
sector &= ~SDD_EXT_PHYS_FLAG_MASK;
}
- if (hex_format == 0)
+ if (!hex_format)
fprintf(stdout, "%d:%d:%d%s",
scsi_3btoul(dlist[i].cylinder),
dlist[i].head,
@@ -4290,7 +4282,7 @@ next_batch:
mads = (bfi & SDD_EXT_BFI_MADS) ? 1 : 0;
bfi &= ~SDD_EXT_BFI_FLAG_MASK;
}
- if (hex_format == 0)
+ if (!hex_format)
fprintf(stdout, "%d:%d:%d%s",
scsi_3btoul(dlist[i].cylinder),
dlist[i].head,
@@ -4319,7 +4311,7 @@ next_batch:
(defect_list + hdr_size);
for (i = 0; i < num_valid; i++) {
- if (hex_format == 0)
+ if (!hex_format)
fprintf(stdout, "%u\n",
scsi_4btoul(dlist[i].address));
else
@@ -4342,7 +4334,7 @@ next_batch:
(defect_list + hdr_size);
for (i = 0; i < num_valid; i++) {
- if (hex_format == 0)
+ if (!hex_format)
fprintf(stdout, "%ju\n",
(uintmax_t)scsi_8btou64(
dlist[i].address));
@@ -4377,7 +4369,7 @@ defect_bailout:
#if 0
void
-reassignblocks(struct cam_device *device, u_int32_t *blocks, int num_blocks)
+reassignblocks(struct cam_device *device, uint32_t *blocks, int num_blocks)
{
union ccb *ccb;
@@ -4390,7 +4382,7 @@ reassignblocks(struct cam_device *device, u_int32_t *blocks, int num_blocks)
void
mode_sense(struct cam_device *device, int *cdb_len, int dbd, int llbaa, int pc,
int page, int subpage, int task_attr, int retry_count, int timeout,
- u_int8_t *data, int datalen)
+ uint8_t *data, int datalen)
{
union ccb *ccb;
int error_code, sense_key, asc, ascq;
@@ -4402,7 +4394,7 @@ mode_sense(struct cam_device *device, int *cdb_len, int dbd, int llbaa, int pc,
retry:
/*
* MODE SENSE(6) can't handle more then 255 bytes. If there are more,
- * device must return error, so we should not get trucated data.
+ * device must return error, so we should not get truncated data.
*/
if (*cdb_len == 6 && datalen > 255)
datalen = 255;
@@ -4464,7 +4456,7 @@ retry:
void
mode_select(struct cam_device *device, int cdb_len, int save_pages,
- int task_attr, int retry_count, int timeout, u_int8_t *data, int datalen)
+ int task_attr, int retry_count, int timeout, uint8_t *data, int datalen)
{
union ccb *ccb;
int retval;
@@ -4589,10 +4581,10 @@ scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
int task_attr, int retry_count, int timeout)
{
union ccb *ccb;
- u_int32_t flags = CAM_DIR_NONE;
- u_int8_t *data_ptr = NULL;
- u_int8_t cdb[20];
- u_int8_t atacmd[12];
+ uint32_t flags = CAM_DIR_NONE;
+ uint8_t *data_ptr = NULL;
+ uint8_t cdb[20];
+ uint8_t atacmd[12];
struct get_hook hook;
int c, data_bytes = 0, valid_bytes;
int cdb_len = 0;
@@ -4693,7 +4685,7 @@ scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
&& (datastr[0] == '-'))
fd_data = 1;
- data_ptr = (u_int8_t *)malloc(data_bytes);
+ data_ptr = (uint8_t *)malloc(data_bytes);
if (data_ptr == NULL) {
warnx("can't malloc memory for data_ptr");
error = 1;
@@ -4720,7 +4712,7 @@ scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
hook.argv = argv + optind;
hook.got = 0;
datastr = cget(&hook, NULL);
- data_ptr = (u_int8_t *)malloc(data_bytes);
+ data_ptr = (uint8_t *)malloc(data_bytes);
if (data_ptr == NULL) {
warnx("can't malloc memory for data_ptr");
error = 1;
@@ -4761,7 +4753,7 @@ scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
if ((fd_data == 1) && (arglist & CAM_ARG_CMD_OUT)) {
ssize_t amt_read;
int amt_to_read = data_bytes;
- u_int8_t *buf_ptr = data_ptr;
+ uint8_t *buf_ptr = data_ptr;
for (amt_read = 0; amt_to_read > 0;
amt_read = read(STDIN_FILENO, buf_ptr, amt_to_read)) {
@@ -4910,7 +4902,7 @@ scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
} else {
ssize_t amt_written;
int amt_to_write = valid_bytes;
- u_int8_t *buf_ptr = data_ptr;
+ uint8_t *buf_ptr = data_ptr;
for (amt_written = 0; (amt_to_write > 0) &&
(amt_written =write(1, buf_ptr,amt_to_write))> 0;){
@@ -5419,7 +5411,7 @@ dev_has_vpd_page(struct cam_device *dev, uint8_t page_id, int retry_count,
/*retries*/ retry_count,
/*cbfcnp*/ NULL,
/* tag_action */ MSG_SIMPLE_Q_TAG,
- /* inq_buf */ (u_int8_t *)&sup_pages,
+ /* inq_buf */ (uint8_t *)&sup_pages,
/* inq_len */ sizeof(sup_pages),
/* evpd */ 1,
/* page_code */ SVPD_SUPPORTED_PAGE_LIST,
@@ -6324,9 +6316,9 @@ scsiformat(struct cam_device *device, int argc, char **argv,
int use_timeout = 10800 * 1000;
int immediate = 1;
struct format_defect_list_header fh;
- u_int8_t *data_ptr = NULL;
- u_int32_t dxfer_len = 0;
- u_int8_t byte2 = 0;
+ uint8_t *data_ptr = NULL;
+ uint32_t dxfer_len = 0;
+ uint8_t byte2 = 0;
int num_warnings = 0;
int reportonly = 0;
@@ -6423,7 +6415,7 @@ scsiformat(struct cam_device *device, int argc, char **argv,
*/
if (immediate != 0) {
fh.byte2 = FU_DLH_IMMED;
- data_ptr = (u_int8_t *)&fh;
+ data_ptr = (uint8_t *)&fh;
dxfer_len = sizeof(fh);
byte2 = FU_FMT_DATA;
} else if (quiet == 0) {
@@ -6795,7 +6787,7 @@ sanitize(struct cam_device *device, int argc, char **argv,
char *combinedopt, int task_attr, int retry_count, int timeout)
{
union ccb *ccb;
- u_int8_t action = 0;
+ uint8_t action = 0;
int c;
int ycount = 0, quiet = 0;
int error = 0;
@@ -6806,8 +6798,8 @@ sanitize(struct cam_device *device, int argc, char **argv,
int ause = 0;
int fd = -1;
const char *pattern = NULL;
- u_int8_t *data_ptr = NULL;
- u_int32_t dxfer_len = 0;
+ uint8_t *data_ptr = NULL;
+ uint32_t dxfer_len = 0;
uint8_t byte2;
uint16_t feature, count;
uint64_t lba;
@@ -7651,7 +7643,7 @@ smpcmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
&& (datastr[0] == '-'))
fd_response = 1;
- smp_response = (u_int8_t *)malloc(response_size);
+ smp_response = (uint8_t *)malloc(response_size);
if (smp_response == NULL) {
warn("can't malloc memory for SMP response");
error = 1;
@@ -7671,7 +7663,7 @@ smpcmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
hook.argv = argv + optind;
hook.got = 0;
datastr = cget(&hook, NULL);
- smp_request = (u_int8_t *)malloc(request_size);
+ smp_request = (uint8_t *)malloc(request_size);
if (smp_request == NULL) {
warn("can't malloc memory for SMP request");
error = 1;
@@ -7703,7 +7695,7 @@ smpcmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
if ((fd_request == 1) && (arglist & CAM_ARG_CMD_OUT)) {
ssize_t amt_read;
int amt_to_read = request_size;
- u_int8_t *buf_ptr = smp_request;
+ uint8_t *buf_ptr = smp_request;
for (amt_read = 0; amt_to_read > 0;
amt_read = read(STDIN_FILENO, buf_ptr, amt_to_read)) {
@@ -7763,7 +7755,7 @@ smpcmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
} else {
ssize_t amt_written;
int amt_to_write = response_size;
- u_int8_t *buf_ptr = smp_response;
+ uint8_t *buf_ptr = smp_response;
for (amt_written = 0; (amt_to_write > 0) &&
(amt_written = write(STDOUT_FILENO, buf_ptr,
@@ -9246,7 +9238,7 @@ atapm(struct cam_device *device, int argc, char **argv,
int retval = 0;
int t = -1;
int c;
- u_int8_t ata_flags = 0;
+ uint8_t ata_flags = 0;
u_char cmd, sc;
ccb = cam_getccb(device);
@@ -9312,12 +9304,11 @@ atapm(struct cam_device *device, int argc, char **argv,
/*timeout*/timeout ? timeout : 30 * 1000,
/*force48bit*/0);
- cam_freeccb(ccb);
-
- if (retval || cmd != ATA_CHECK_POWER_MODE)
- return (retval);
+ if (retval == 0 && cmd == ATA_CHECK_POWER_MODE)
+ retval = atapm_proc_resp(device, ccb);
- return (atapm_proc_resp(device, ccb));
+ cam_freeccb(ccb);
+ return (retval);
}
static int
diff --git a/sbin/camcontrol/camcontrol.h b/sbin/camcontrol/camcontrol.h
index b84587df7a3e..ebc6d4039f8f 100644
--- a/sbin/camcontrol/camcontrol.h
+++ b/sbin/camcontrol/camcontrol.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Kenneth D. Merry.
* All rights reserved.
@@ -26,8 +26,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _CAMCONTROL_H
@@ -95,7 +93,7 @@ void mode_sense(struct cam_device *device, int *cdb_len, int dbd, int llbaa,
int pc, int page, int subpage, int task_attr, int retry_count,
int timeout, uint8_t *data, int datalen);
void mode_select(struct cam_device *device, int cdb_len, int save_pages,
- int task_attr, int retry_count, int timeout, u_int8_t *data,
+ int task_attr, int retry_count, int timeout, uint8_t *data,
int datalen);
void mode_edit(struct cam_device *device, int cdb_len, int desc, int dbd,
int llbaa, int pc, int page, int subpage, int edit, int binary,
diff --git a/sbin/camcontrol/depop.c b/sbin/camcontrol/depop.c
index cf205ab6b471..4aff0284abe1 100644
--- a/sbin/camcontrol/depop.c
+++ b/sbin/camcontrol/depop.c
@@ -50,9 +50,6 @@
* 'depop' provides a wrapper around all these functions.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <err.h>
diff --git a/sbin/camcontrol/epc.c b/sbin/camcontrol/epc.c
index aac94ccaa4e5..206b34594f4f 100644
--- a/sbin/camcontrol/epc.c
+++ b/sbin/camcontrol/epc.c
@@ -34,8 +34,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/ioctl.h>
#include <sys/stdint.h>
#include <sys/types.h>
diff --git a/sbin/camcontrol/fwdownload.c b/sbin/camcontrol/fwdownload.c
index 02b60f25df04..2ab18c93392b 100644
--- a/sbin/camcontrol/fwdownload.c
+++ b/sbin/camcontrol/fwdownload.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Sandvine Incorporated. All rights reserved.
* Copyright (c) 2002-2011 Andre Albsmeier <andre@albsmeier.net>
@@ -49,9 +49,6 @@
* specified device.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
@@ -167,8 +164,8 @@ struct fw_vendor {
const char *pattern;
int dev_type;
int max_pkt_size;
- u_int8_t cdb_byte2;
- u_int8_t cdb_byte2_last;
+ uint8_t cdb_byte2;
+ uint8_t cdb_byte2_last;
int inc_cdb_buffer_id;
int inc_cdb_offset;
fw_tur_status tur_status;
@@ -474,7 +471,7 @@ fw_validate_ibm(struct cam_device *dev, int retry_count, int timeout, int fd,
/*retries*/ retry_count,
/*cbfcnp*/ NULL,
/* tag_action */ MSG_SIMPLE_Q_TAG,
- /* inq_buf */ (u_int8_t *)&vpd_page,
+ /* inq_buf */ (uint8_t *)&vpd_page,
/* inq_len */ sizeof(vpd_page),
/* evpd */ 1,
/* page_code */ SVPD_IBM_FW_DESIGNATION,
@@ -832,9 +829,9 @@ fw_download_img(struct cam_device *cam_dev, struct fw_vendor *vp,
union ccb *ccb = NULL;
int pkt_count = 0;
int max_pkt_size;
- u_int32_t pkt_size = 0;
+ uint32_t pkt_size = 0;
char *pkt_ptr = buf;
- u_int32_t offset;
+ uint32_t offset;
int last_pkt = 0;
int retval = 0;
diff --git a/sbin/camcontrol/modeedit.c b/sbin/camcontrol/modeedit.c
index 15e5c6608f47..46accea0da43 100644
--- a/sbin/camcontrol/modeedit.c
+++ b/sbin/camcontrol/modeedit.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2000 Kelly Yancey <kbyanc@posi.net>
* Derived from work done by Julian Elischer <julian@tfs.com,
@@ -29,8 +29,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/sbuf.h>
@@ -595,8 +593,8 @@ static void
editlist_populate(struct cam_device *device, int cdb_len, int dbd, int pc,
int page, int subpage, int task_attr, int retries, int timeout)
{
- u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */
- u_int8_t *mode_pars; /* Pointer to modepage params. */
+ uint8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */
+ uint8_t *mode_pars; /* Pointer to modepage params. */
struct scsi_mode_page_header *mph;
struct scsi_mode_page_header_sp *mphsp;
size_t len;
@@ -700,8 +698,8 @@ static void
editlist_save(struct cam_device *device, int cdb_len, int dbd, int pc,
int page, int subpage, int task_attr, int retries, int timeout)
{
- u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */
- u_int8_t *mode_pars; /* Pointer to modepage params. */
+ uint8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */
+ uint8_t *mode_pars; /* Pointer to modepage params. */
struct scsi_mode_page_header *mph;
struct scsi_mode_page_header_sp *mphsp;
size_t len, hlen, mphlen;
@@ -1003,8 +1001,8 @@ static void
modepage_dump(struct cam_device *device, int cdb_len, int dbd, int pc,
int page, int subpage, int task_attr, int retries, int timeout)
{
- u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */
- u_int8_t *mode_pars; /* Pointer to modepage params. */
+ uint8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */
+ uint8_t *mode_pars; /* Pointer to modepage params. */
struct scsi_mode_page_header *mph;
struct scsi_mode_page_header_sp *mphsp;
size_t indx, len;
@@ -1153,7 +1151,7 @@ void
mode_list(struct cam_device *device, int cdb_len, int dbd, int pc, int subpages,
int task_attr, int retry_count, int timeout)
{
- u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */
+ uint8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */
struct scsi_mode_page_header *mph;
struct scsi_mode_page_header_sp *mphsp;
struct pagename *nameentry;
diff --git a/sbin/camcontrol/persist.c b/sbin/camcontrol/persist.c
index f7ef30e06ede..d6fb9c6a5f2c 100644
--- a/sbin/camcontrol/persist.c
+++ b/sbin/camcontrol/persist.c
@@ -34,8 +34,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/ioctl.h>
#include <sys/stdint.h>
#include <sys/types.h>
diff --git a/sbin/camcontrol/progress.c b/sbin/camcontrol/progress.c
index 054b3f5391e7..c3c23fba428a 100644
--- a/sbin/camcontrol/progress.c
+++ b/sbin/camcontrol/progress.c
@@ -1,7 +1,7 @@
/* $NetBSD: progressbar.c,v 1.21 2009/04/12 10:18:52 lukem Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -44,8 +44,6 @@
#include <unistd.h>
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "progress.h"
static const char * const suffixes[] = {
diff --git a/sbin/camcontrol/progress.h b/sbin/camcontrol/progress.h
index 1234c1136eaf..b3b0453a93a9 100644
--- a/sbin/camcontrol/progress.h
+++ b/sbin/camcontrol/progress.h
@@ -1,7 +1,7 @@
/* $NetBSD: progressbar.c,v 1.21 2009/04/12 10:18:52 lukem Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997-2012 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -29,8 +29,6 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef PROGRESS_H_
diff --git a/sbin/camcontrol/timestamp.c b/sbin/camcontrol/timestamp.c
index 9667db832298..3130dec188dc 100644
--- a/sbin/camcontrol/timestamp.c
+++ b/sbin/camcontrol/timestamp.c
@@ -35,9 +35,6 @@
* SCSI tape drive timestamp support
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <assert.h>
diff --git a/sbin/camcontrol/util.c b/sbin/camcontrol/util.c
index 58fc93746fc7..08b4cb7630ca 100644
--- a/sbin/camcontrol/util.c
+++ b/sbin/camcontrol/util.c
@@ -46,8 +46,6 @@
* from: scsi.c,v 1.17 1998/01/12 07:57:57 charnier Exp $";
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/stdint.h>
#include <sys/types.h>
diff --git a/sbin/camcontrol/zone.c b/sbin/camcontrol/zone.c
index 3f7dfcec4f35..d651ca0e2acf 100644
--- a/sbin/camcontrol/zone.c
+++ b/sbin/camcontrol/zone.c
@@ -35,8 +35,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/ioctl.h>
#include <sys/stdint.h>
#include <sys/types.h>
@@ -138,7 +136,6 @@ zone_rz_print(uint8_t *data_ptr, uint32_t valid_len, int ata_format,
struct scsi_report_zones_desc *desc = NULL;
uint32_t hdr_len, len;
uint64_t max_lba, next_lba = 0;
- int more_data = 0;
zone_print_status status = ZONE_PRINT_OK;
char tmpstr[80];
int field_widths[ZONE_NUM_FIELDS];
@@ -168,7 +165,6 @@ zone_rz_print(uint8_t *data_ptr, uint32_t valid_len, int ata_format,
}
if (hdr_len > (valid_len + sizeof(*hdr))) {
- more_data = 1;
status = ZONE_PRINT_MORE_DATA;
}
@@ -592,7 +588,7 @@ restart_report:
/*retry_count*/ retry_count,
/*flags*/ CAM_DIR_NONE | CAM_DEV_QFRZDIS,
/*tag_action*/ task_attr,
- /*protocol*/ AP_PROTO_NON_DATA,
+ /*protocol*/ protocol,
/*ata_flags*/ AP_FLAG_BYT_BLOK_BYTES |
AP_FLAG_TLEN_NO_DATA,
/*features*/ features,
diff --git a/sbin/ccdconfig/Makefile b/sbin/ccdconfig/Makefile
index c01b0c55b178..6a27bb7e7cf4 100644
--- a/sbin/ccdconfig/Makefile
+++ b/sbin/ccdconfig/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE=ccdconfig
PROG= ccdconfig
diff --git a/sbin/ccdconfig/Makefile.depend b/sbin/ccdconfig/Makefile.depend
index 0220673c9076..0dd05cace3c0 100644
--- a/sbin/ccdconfig/Makefile.depend
+++ b/sbin/ccdconfig/Makefile.depend
@@ -1,16 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libexpat \
lib/libgeom \
- lib/libsbuf \
.include <dirdeps.mk>
diff --git a/sbin/ccdconfig/ccdconfig.8 b/sbin/ccdconfig/ccdconfig.8
index e73864bc1fef..2c7460f291f6 100644
--- a/sbin/ccdconfig/ccdconfig.8
+++ b/sbin/ccdconfig/ccdconfig.8
@@ -26,7 +26,6 @@
.\" SUCH DAMAGE.
.\"
.\" $NetBSD: ccdconfig.8,v 1.4 1996/02/28 01:01:17 thorpej Exp $
-.\" $FreeBSD$
.\"
.Dd March 17, 2022
.Dt CCDCONFIG 8
diff --git a/sbin/ccdconfig/ccdconfig.c b/sbin/ccdconfig/ccdconfig.c
index 1429426e8638..6b8086ef0213 100644
--- a/sbin/ccdconfig/ccdconfig.c
+++ b/sbin/ccdconfig/ccdconfig.c
@@ -32,9 +32,6 @@
* NetBSD: ccdconfig.c,v 1.6 1996/05/16 07:11:18 thorpej Exp $
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/linker.h>
#include <sys/module.h>
diff --git a/sbin/ccdconfig/pathnames.h b/sbin/ccdconfig/pathnames.h
index 85791ddbfcff..4924323e5a8e 100644
--- a/sbin/ccdconfig/pathnames.h
+++ b/sbin/ccdconfig/pathnames.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -29,7 +29,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* $NetBSD: pathnames.h,v 1.4 2008/04/28 20:23:07 martin Exp $
- * $FreeBSD$
*/
#define _PATH_CCDCONF "/etc/ccd.conf"
diff --git a/sbin/clri/Makefile b/sbin/clri/Makefile
index 5f8777f30391..ac3eda4cd597 100644
--- a/sbin/clri/Makefile
+++ b/sbin/clri/Makefile
@@ -1,7 +1,5 @@
-# @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
-PACKAGE=runtime
+PACKAGE=ufs
PROG= clri
MAN= clri.8
LIBADD= ufs
diff --git a/sbin/clri/Makefile.depend b/sbin/clri/Makefile.depend
index 6cfaab1c3644..910688a678fa 100644
--- a/sbin/clri/Makefile.depend
+++ b/sbin/clri/Makefile.depend
@@ -1,13 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libufs \
.include <dirdeps.mk>
diff --git a/sbin/clri/clri.8 b/sbin/clri/clri.8
index 61bdde7feb6a..9d1fb92e22ba 100644
--- a/sbin/clri/clri.8
+++ b/sbin/clri/clri.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)clri.8 8.2 (Berkeley) 4/19/94
-.\" $FreeBSD$
-.\"
.Dd October 5, 2016
.Dt CLRI 8
.Os
diff --git a/sbin/clri/clri.c b/sbin/clri/clri.c
index 7f9a4f09bfe0..331975b4cdce 100644
--- a/sbin/clri/clri.c
+++ b/sbin/clri/clri.c
@@ -32,21 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1990, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)clri.c 8.2 (Berkeley) 9/23/93";
-#endif /* not lint */
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/disklabel.h>
diff --git a/sbin/comcontrol/Makefile b/sbin/comcontrol/Makefile
index 9bfc4684dd6a..809f1060d183 100644
--- a/sbin/comcontrol/Makefile
+++ b/sbin/comcontrol/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 5.4 (Berkeley) 6/5/91
-# $FreeBSD$
PACKAGE=runtime
PROG= comcontrol
diff --git a/sbin/comcontrol/Makefile.depend b/sbin/comcontrol/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/sbin/comcontrol/Makefile.depend
+++ b/sbin/comcontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/comcontrol/comcontrol.8 b/sbin/comcontrol/comcontrol.8
index 84309a04960f..46c7f987d774 100644
--- a/sbin/comcontrol/comcontrol.8
+++ b/sbin/comcontrol/comcontrol.8
@@ -1,4 +1,3 @@
-.\" $FreeBSD$
.Dd May 15, 1994
.Dt COMCONTROL 8
.Os
diff --git a/sbin/comcontrol/comcontrol.c b/sbin/comcontrol/comcontrol.c
index 6bfb47b74c2d..7a03b3a569cf 100644
--- a/sbin/comcontrol/comcontrol.c
+++ b/sbin/comcontrol/comcontrol.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1992 Christopher G. Demetriou
* All rights reserved.
@@ -29,8 +29,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <err.h>
#include <errno.h>
@@ -42,7 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/ioctl.h>
-static void usage(void);
+static void usage(void) __dead2;
static void
usage(void)
diff --git a/sbin/conscontrol/Makefile b/sbin/conscontrol/Makefile
index 0bd82e695c31..072edf04a5c4 100644
--- a/sbin/conscontrol/Makefile
+++ b/sbin/conscontrol/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE=runtime
PROG= conscontrol
diff --git a/sbin/conscontrol/Makefile.depend b/sbin/conscontrol/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/sbin/conscontrol/Makefile.depend
+++ b/sbin/conscontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/conscontrol/conscontrol.8 b/sbin/conscontrol/conscontrol.8
index eb9b4dfdbc0f..54c89d5e5c1b 100644
--- a/sbin/conscontrol/conscontrol.8
+++ b/sbin/conscontrol/conscontrol.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 14, 2011
.Dt CONSCONTROL 8
.Os
diff --git a/sbin/conscontrol/conscontrol.c b/sbin/conscontrol/conscontrol.c
index f4298eb8a2cc..9c7ec9175910 100644
--- a/sbin/conscontrol/conscontrol.c
+++ b/sbin/conscontrol/conscontrol.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Jonathan Lemon <jlemon@FreeBSD.org>
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/ioctl.h>
diff --git a/sbin/ddb/Makefile b/sbin/ddb/Makefile
index f1bf75e41b36..d8d67602c3ef 100644
--- a/sbin/ddb/Makefile
+++ b/sbin/ddb/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
CONFS= ddb.conf
PACKAGE=runtime
diff --git a/sbin/ddb/Makefile.depend b/sbin/ddb/Makefile.depend
index 4a0ebeceed6f..124f2f93f8a6 100644
--- a/sbin/ddb/Makefile.depend
+++ b/sbin/ddb/Makefile.depend
@@ -1,14 +1,11 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libelf \
lib/libkvm \
diff --git a/sbin/ddb/ddb.8 b/sbin/ddb/ddb.8
index 0fb9687991e5..562251e0b448 100644
--- a/sbin/ddb/ddb.8
+++ b/sbin/ddb/ddb.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 24, 2008
.Dt DDB 8
.Os
@@ -150,6 +148,7 @@ and
manual pages.
.Sh SEE ALSO
.Xr ddb 4 ,
+.Xr mac_ddb 4 ,
.Xr textdump 4 ,
.Xr sysctl 8
.Sh HISTORY
diff --git a/sbin/ddb/ddb.c b/sbin/ddb/ddb.c
index a90a693e1b03..885921d7c51f 100644
--- a/sbin/ddb/ddb.c
+++ b/sbin/ddb/ddb.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2007 Robert N. M. Watson
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/sbin/ddb/ddb.conf b/sbin/ddb/ddb.conf
index 1246c0effdf4..7572a7a91915 100644
--- a/sbin/ddb/ddb.conf
+++ b/sbin/ddb/ddb.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# This file is read when going to multi-user and its contents piped thru
# ``ddb'' to define debugging scripts.
diff --git a/sbin/ddb/ddb.h b/sbin/ddb/ddb.h
index 6f9a6f99f04b..bd33b24c92cb 100644
--- a/sbin/ddb/ddb.h
+++ b/sbin/ddb/ddb.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2007 Robert N. M. Watson
* All rights reserved.
@@ -24,8 +24,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef DDB_H
diff --git a/sbin/ddb/ddb_capture.c b/sbin/ddb/ddb_capture.c
index 1bb27b5b7e93..ab8b2c1ed0bb 100644
--- a/sbin/ddb/ddb_capture.c
+++ b/sbin/ddb/ddb_capture.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Robert N. M. Watson
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/sysctl.h>
diff --git a/sbin/ddb/ddb_script.c b/sbin/ddb/ddb_script.c
index e36cb6606380..76724df8d772 100644
--- a/sbin/ddb/ddb_script.c
+++ b/sbin/ddb/ddb_script.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2007 Robert N. M. Watson
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/sysctl.h>
diff --git a/sbin/decryptcore/Makefile b/sbin/decryptcore/Makefile
index 3a3a6a029f87..885766f5cfc6 100644
--- a/sbin/decryptcore/Makefile
+++ b/sbin/decryptcore/Makefile
@@ -1,7 +1,7 @@
-# $FreeBSD$
PROG= decryptcore
+CFLAGS+=-DOPENSSL_API_COMPAT=0x10100000L
LIBADD= crypto pjdlog
MAN= decryptcore.8
diff --git a/sbin/decryptcore/Makefile.depend b/sbin/decryptcore/Makefile.depend
index d718b860472f..fa1f7fd358f0 100644
--- a/sbin/decryptcore/Makefile.depend
+++ b/sbin/decryptcore/Makefile.depend
@@ -1,15 +1,14 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
+ lib/libcasper/libcasper \
lib/libcompiler_rt \
lib/libpjdlog \
- lib/libutil \
secure/lib/libcrypto \
diff --git a/sbin/decryptcore/decryptcore.8 b/sbin/decryptcore/decryptcore.8
index fc6a1dadc7b5..057d3a0ed7ea 100644
--- a/sbin/decryptcore/decryptcore.8
+++ b/sbin/decryptcore/decryptcore.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 29, 2018
.Dt DECRYPTCORE 8
.Os
@@ -110,7 +108,7 @@ Specify a number of a crash dump to be decrypted.
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
-.Xr kgdb 1 ,
+.Xr kgdb 1 Pq Pa ports/devel/gdb ,
.Xr capsicum 4 ,
.Xr dumpon 8 ,
.Xr savecore 8 ,
diff --git a/sbin/decryptcore/decryptcore.c b/sbin/decryptcore/decryptcore.c
index fc6599fb0ecc..1e7cf4070e51 100644
--- a/sbin/decryptcore/decryptcore.c
+++ b/sbin/decryptcore/decryptcore.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/capsicum.h>
#include <sys/endian.h>
@@ -41,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
+#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
@@ -179,8 +177,10 @@ decrypt(int ofd, const char *privkeyfile, const char *keyfile,
unsigned char c[1];
RAND_bytes(c, 1);
}
-#endif
ERR_load_crypto_strings();
+#else
+ OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
+#endif
caph_cache_catpages();
if (caph_enter() < 0) {
diff --git a/sbin/devd/Makefile b/sbin/devd/Makefile
index 0bda9e1ecf95..68ff477f09c9 100644
--- a/sbin/devd/Makefile
+++ b/sbin/devd/Makefile
@@ -1,9 +1,8 @@
-# $FreeBSD$
.include <src.opts.mk>
-WARNS?= 3
-PACKAGE=runtime
+WARNS?= 6
+PACKAGE=devd
CONFGROUPS= CONFS DEVD
CONFS= devd.conf
DEVD= devmatch.conf
@@ -12,6 +11,33 @@ DEVDDIR= /etc/devd
DEVD+= asus.conf
.endif
+CONFGROUPS+= AUTOFS
+AUTOFSDIR= ${DEVDDIR}
+AUTOFS+= autofs.conf
+AUTOFSPACKAGE= autofs
+
+CONFGROUPS+= DHCLIENT
+DHCLIENTDIR= ${DEVDDIR}
+DHCLIENT+= dhclient.conf
+DHCLIENTPACKAGE= dhclient
+
+CONFGROUPS+= POWERPROFILE
+POWERPROFILEDIR= ${DEVDDIR}
+POWERPROFILE+= power_profile.conf
+POWERPROFILEPACKAGE= acpi
+
+CONFGROUPS+= CONSOLE
+CONSOLEDIR= ${DEVDDIR}
+CONSOLE+= moused.conf syscons.conf
+CONSOLEPACKAGE= console-tools
+
+.if ${MK_BLUETOOTH} != "no"
+CONFGROUPS+= BLUETOOTH
+BLUETOOTHDIR= ${DEVDDIR}
+BLUETOOTH+= bluetooth.conf
+BLUETOOTHPACKAGE= bluetooth
+.endif
+
.if ${MK_HYPERV} != "no"
CONFGROUPS+= HYPERV
HYPERVDIR=${DEVDDIR}
@@ -35,8 +61,6 @@ PROG_CXX=devd
SRCS= devd.cc token.l parse.y y.tab.h
MAN= devd.8 devd.conf.5
-NO_SHARED?=YES
-
LIBADD= util
YFLAGS+=-v
diff --git a/sbin/devd/Makefile.depend b/sbin/devd/Makefile.depend
index 8c3f699ac991..a5009d89b087 100644
--- a/sbin/devd/Makefile.depend
+++ b/sbin/devd/Makefile.depend
@@ -1,17 +1,15 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libc++ \
lib/libcompiler_rt \
+ lib/libcxxrt \
lib/libutil \
lib/msun \
- usr.bin/lex/lib \
usr.bin/yacc.host \
diff --git a/sbin/devd/apple.conf b/sbin/devd/apple.conf
index 0a9143f7b5a5..7a164c0ebfc7 100644
--- a/sbin/devd/apple.conf
+++ b/sbin/devd/apple.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# PowerPC Apple specific devd events
diff --git a/sbin/devd/asus.conf b/sbin/devd/asus.conf
index 0074e7a7c55f..0962af7df2e0 100644
--- a/sbin/devd/asus.conf
+++ b/sbin/devd/asus.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# ASUS specific devd events
diff --git a/sbin/devd/autofs.conf b/sbin/devd/autofs.conf
new file mode 100644
index 000000000000..a06ca7295d38
--- /dev/null
+++ b/sbin/devd/autofs.conf
@@ -0,0 +1,9 @@
+#
+# autofs(5) specific devd events
+
+# Discard autofs caches, useful for the -media special map.
+notify 100 {
+ match "system" "GEOM";
+ match "subsystem" "DEV";
+ action "/usr/sbin/automount -c";
+};
diff --git a/sbin/devd/bluetooth.conf b/sbin/devd/bluetooth.conf
new file mode 100644
index 000000000000..29bd51e36fca
--- /dev/null
+++ b/sbin/devd/bluetooth.conf
@@ -0,0 +1,9 @@
+# When a USB Bluetooth dongle appears, activate it
+attach 100 {
+ device-name "ubt[0-9]+";
+ action "service bluetooth quietstart $device-name";
+};
+detach 100 {
+ device-name "ubt[0-9]+";
+ action "service bluetooth quietstop $device-name";
+};
diff --git a/sbin/devd/devd.8 b/sbin/devd/devd.8
index 77c8e4aac2fb..f7e19df438ed 100644
--- a/sbin/devd/devd.8
+++ b/sbin/devd/devd.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 19, 2021
.Dt DEVD 8
.Os
diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc
index a1b6ee479921..8d621e42a232 100644
--- a/sbin/devd/devd.cc
+++ b/sbin/devd/devd.cc
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-Clause
*
* Copyright (c) 2002-2010 M. Warner Losh <imp@FreeBSD.org>
*
@@ -63,9 +63,6 @@
// - devd needs to document the unix domain socket
// - devd.conf needs more details on the supported statements.
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
@@ -173,6 +170,8 @@ delete_and_clear(vector<T *> &v)
static config cfg;
+static const char *curr_cf = NULL;
+
event_proc::event_proc() : _prio(-1)
{
_epsvec.reserve(4);
@@ -452,17 +451,28 @@ config::reset(void)
delete_and_clear(_notify_list);
}
+/*
+ * Called recursively as new files are included, so current stack of old names
+ * saved in each instance of 'old' on the call stack. Called single threaded
+ * so global varaibles curr_cf and lineno (and all of yacc's parser state)
+ * are safe to access w/o a lock.
+ */
void
config::parse_one_file(const char *fn)
{
+ const char *old;
+
devdlog(LOG_DEBUG, "Parsing %s\n", fn);
yyin = fopen(fn, "r");
+ old = curr_cf;
+ curr_cf = fn;
if (yyin == NULL)
err(1, "Cannot open config file %s", fn);
lineno = 1;
if (yyparse() != 0)
errx(1, "Cannot parse %s at line %d", fn, lineno);
fclose(yyin);
+ curr_cf = old;
}
void
@@ -1194,6 +1204,27 @@ new_action(const char *cmd)
eps *
new_match(const char *var, const char *re)
{
+ /*
+ * In FreeBSD 14, we changed the system=kern to system=kernel for the
+ * resume message to match all the other 'kernel' messages. Generate a
+ * warning for the life of 14.x that we've 'fixed' the file on the fly,
+ * but make it a fatal error in 15.x and newer.
+ */
+ if (strcmp(var, "kern") == 0) {
+#if __FreeBSD_version < 1500000
+ devdlog(LOG_WARNING,
+ "Changing deprecated system='kern' to new name 'kernel' in %s line %d.",
+ curr_cf, lineno);
+ free(const_cast<char *>(var));
+ var = strdup("kernel");
+#elif __FreeBSD_version < 1600000
+ errx(1, "Encountered deprecated system=\"kern\" rule in %s line %d",
+ curr_cf, lineno);
+#else
+#error "Remove this gross hack"
+#endif
+ }
+
eps *e = new match(cfg, var, re);
free(const_cast<char *>(var));
free(const_cast<char *>(re));
diff --git a/sbin/devd/devd.conf b/sbin/devd/devd.conf
index 15b37ee8fd90..08cbeb840b2f 100644
--- a/sbin/devd/devd.conf
+++ b/sbin/devd/devd.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Refer to devd.conf(5) and devd(8) man pages for the details on how to
# run and configure devd.
@@ -19,8 +18,8 @@ options {
# Setup some shorthand for regex that we use later in the file.
#XXX Yes, this is gross -- imp
set wifi-driver-regex
- "(ath|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|otus|ral|rsu|rtw|rtwn|rum|\
- run|uath|upgt|ural|urtw|wpi|wtap|zyd)[0-9]+";
+ "(ath|ath[0-9]+k|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|mt79|otus|\
+ ral|rsu|rtw|rtwn|rum|run|uath|upgt|ural|urtw|wpi|wtap|zyd)[0-9]+";
};
# Note that the attach/detach with the highest value wins, so that one can
@@ -45,19 +44,6 @@ notify 0 {
};
#
-# Try to start dhclient on Ethernet-like interfaces when the link comes
-# up. Only devices that are configured to support DHCP will actually
-# run it. No link down rule exists because dhclient automatically exits
-# when the link goes down.
-#
-notify 0 {
- match "system" "IFNET";
- match "type" "LINK_UP";
- media-type "ethernet";
- action "service dhclient quietstart $subsystem";
-};
-
-#
# Like Ethernet devices, but separate because 802.11 require spawning
# wlan(4) interface.
#
@@ -69,12 +55,6 @@ detach 0 {
device-name "$wifi-driver-regex";
action "/etc/pccard_ether $device-name stopchildren";
};
-notify 0 {
- match "system" "IFNET";
- match "type" "LINK_UP";
- media-type "802.11";
- action "service dhclient quietstart $subsystem";
-};
# An entry like this might be in a different file, but is included here
# as an example of how to override things. Normally 'ed50' would match
@@ -88,16 +68,6 @@ detach 100 {
device-name "ed50";
};
-# When a USB Bluetooth dongle appears, activate it
-attach 100 {
- device-name "ubt[0-9]+";
- action "service bluetooth quietstart $device-name";
-};
-detach 100 {
- device-name "ubt[0-9]+";
- action "service bluetooth quietstop $device-name";
-};
-
# Firmware downloader for Atheros AR3011 based USB Bluetooth devices
#attach 100 {
# match "vendor" "0x0cf3";
@@ -105,82 +75,6 @@ detach 100 {
# action "sleep 2 && /usr/sbin/ath3kfw -d $device-name -f /usr/local/etc/ath3k-1.fw";
#};
-# When a USB keyboard arrives, attach it as the console keyboard.
-attach 100 {
- device-name "ukbd0";
- action "service syscons setkeyboard /dev/ukbd0";
-};
-detach 100 {
- device-name "ukbd0";
- action "service syscons setkeyboard /dev/kbd0";
-};
-
-notify 100 {
- match "system" "DEVFS";
- match "subsystem" "CDEV";
- match "type" "CREATE";
- match "cdev" "atp[0-9]+";
-
- action "service moused quietstart $cdev";
-};
-
-notify 100 {
- match "system" "DEVFS";
- match "subsystem" "CDEV";
- match "type" "CREATE";
- match "cdev" "ums[0-9]+";
-
- action "service moused quietstart $cdev";
-};
-
-notify 100 {
- match "system" "DEVFS";
- match "subsystem" "CDEV";
- match "type" "CREATE";
- match "cdev" "wsp[0-9]+";
-
- action "service moused quietstart $cdev";
-};
-
-notify 100 {
- match "system" "DEVFS";
- match "subsystem" "CDEV";
- match "type" "DESTROY";
- match "cdev" "ums[0-9]+";
-
- action "service moused stop $cdev";
-};
-
-# Don't even try to second guess what to do about drivers that don't
-# match here. Instead, pass it off to syslog. Commented out for the
-# moment, as the pnpinfo variable isn't set in devd yet. Individual
-# variables within the bus supplied pnpinfo are set.
-nomatch 0 {
-# action "logger Unknown device: $pnpinfo $location $bus";
-};
-
-# Various logging of unknown devices.
-nomatch 10 {
- match "bus" "uhub[0-9]+";
- action "logger Unknown USB device: vendor $vendor product $product \
- bus $bus";
-};
-
-# Some Cardbus cards don't offer numerical manufacturer/product IDs, just
-# show the CIS info there.
-nomatch 10 {
- match "bus" "cardbus[0-9]+";
- action "logger Unknown Cardbus device: device $device class $class \
- vendor $vendor bus $bus";
-};
-
-# Switch power profiles when the AC line state changes.
-notify 10 {
- match "system" "ACPI";
- match "subsystem" "ACAD";
- action "service power_profile $notify";
-};
-
# Notify all users before beginning emergency shutdown when we get
# a _CRT or _HOT thermal event and we're going to power down the system
# very soon.
@@ -242,13 +136,6 @@ notify 0 {
action "service postgresql restart";
};
-# Discard autofs caches, useful for the -media special map.
-notify 100 {
- match "system" "GEOM";
- match "subsystem" "DEV";
- action "/usr/sbin/automount -c";
-};
-
# Handle userland coredumps.
# This commented out handler makes it possible to run an
# automated debugging session after the core dump is generated.
diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5
index dd9faa05c869..c9c421090ab9 100644
--- a/sbin/devd/devd.conf.5
+++ b/sbin/devd/devd.conf.5
@@ -21,8 +21,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.\" The section on comments was taken from named.conf.5, which has the
.\" following copyright:
.\" Copyright (c) 1999-2000 by Internet Software Consortium
@@ -40,7 +38,7 @@
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
.\" SOFTWARE.
.\"
-.Dd November 3, 2021
+.Dd December 1, 2022
.Dt DEVD.CONF 5
.Os
.Sh NAME
@@ -177,8 +175,6 @@ For network devices,
will match devices that have the given media type.
Valid media types are:
.Dq Li Ethernet ,
-.Dq Li Tokenring ,
-.Dq Li FDDI ,
.Dq Li 802.11 ,
and
.Dq Li ATM .
@@ -477,14 +473,6 @@ The network interface address removed.
.Pp
.Bl -column "System" "Subsystem" "1234567" -compact
.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
-.It Li kern Ta Li power Ta Li resume Ta
-Notification that the system has woken from the suspended state.
-Note: this notification is deprecated and will be removed in
-.Fx 14.0 .
-.El
-.Pp
-.Bl -column "System" "Subsystem" "1234567" -compact
-.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description"
.It Li kernel Ta Li signal Ta Li coredump Ta
Notification that a process has crashed and dumped core.
.It Li kernel Ta Li power Ta Li resume Ta
@@ -553,7 +541,7 @@ device has detected the lid openinging.
.It Li PMU Ta Li POWER Ta ACLINE Ta
The
.Xr pmc 4
-device has deteted an AC line state ($notify=0x00 is offline, 0x01 is online).
+device has detected an AC line state ($notify=0x00 is offline, 0x01 is online).
.It Li PMU Ta Li USB Ta overvoltage Ta
An over-voltage condition on the power lines for the USB power pins.
.It Li PMU Ta Li USB Ta plugged Ta
diff --git a/sbin/devd/devd.h b/sbin/devd/devd.h
index a291e8141298..6d6495c915de 100644
--- a/sbin/devd/devd.h
+++ b/sbin/devd/devd.h
@@ -1,7 +1,7 @@
/*-
* DEVD (Device action daemon)
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002 M. Warner Losh <imp@FreeBSD.org>
*
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef DEVD_H
diff --git a/sbin/devd/devd.hh b/sbin/devd/devd.hh
index 62511d8ec3a5..5ab7a190c0e5 100644
--- a/sbin/devd/devd.hh
+++ b/sbin/devd/devd.hh
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002-2003 M. Warner Losh <imp@FreeBSD.org>
*
@@ -23,8 +23,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef DEVD_HH
diff --git a/sbin/devd/devmatch.conf b/sbin/devd/devmatch.conf
index 902c96f33664..a7c27857c0bd 100644
--- a/sbin/devd/devmatch.conf
+++ b/sbin/devd/devmatch.conf
@@ -1,15 +1,32 @@
+# Implement the run-time component of devmatch by reacting to nomatch events.
+
#
-# $FreeBSD$
+# Ignore those devices that can't possibly match. When there's neither a
+# location, nor a pnpinfo string, we know that there's nothing devmatch can
+# match on. When it's only a location, it'd debateable, but for nomatch
+# events, we can't disambiguate between the two reliably.
#
+nomatch 101 {
+ match "_" " +at +on .*";
+};
#
-# Example devd configuration file for automatically
-# loading what modules we can based on nomatch
-# events.
+# Ignore ACPI devices whose _HID is none. These cannot tell us what to load,
+# since 'none' is not a valid id. There's no need to call devvmatch for these either.
+#
+nomatch 101 {
+ match "_HID" "none";
+ match "bus" "acpi[0-9]+";
+};
+
#
# Generic NOMATCH event
+#
+# Note: It would be better to have some internal-to-devd action that will do
+# what devmatch does without re-parsing loader.hints for each invocation
+#
nomatch 100 {
- action "service devmatch quietstart '?'$_";
+ action "service devmatch quietstart $*";
};
# Add the following to devd.conf to prevent this from running:
diff --git a/sbin/devd/dhclient.conf b/sbin/devd/dhclient.conf
new file mode 100644
index 000000000000..e90558295e1a
--- /dev/null
+++ b/sbin/devd/dhclient.conf
@@ -0,0 +1,19 @@
+#
+# Try to start dhclient on Ethernet-like interfaces when the link comes
+# up. Only devices that are configured to support DHCP will actually
+# run it. No link down rule exists because dhclient automatically exits
+# when the link goes down.
+#
+notify 0 {
+ match "system" "IFNET";
+ match "type" "LINK_UP";
+ media-type "ethernet";
+ action "service dhclient quietstart $subsystem";
+};
+
+notify 0 {
+ match "system" "IFNET";
+ match "type" "LINK_UP";
+ media-type "802.11";
+ action "service dhclient quietstart $subsystem";
+};
diff --git a/sbin/devd/hyperv.conf b/sbin/devd/hyperv.conf
index 7c3e92ed099f..13695a0c75b6 100644
--- a/sbin/devd/hyperv.conf
+++ b/sbin/devd/hyperv.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Hyper-V specific events
diff --git a/sbin/devd/moused.conf b/sbin/devd/moused.conf
new file mode 100644
index 000000000000..002edad9a8a9
--- /dev/null
+++ b/sbin/devd/moused.conf
@@ -0,0 +1,35 @@
+notify 100 {
+ match "system" "DEVFS";
+ match "subsystem" "CDEV";
+ match "type" "CREATE";
+ match "cdev" "atp[0-9]+";
+
+ action "service moused quietstart $cdev";
+};
+
+notify 100 {
+ match "system" "DEVFS";
+ match "subsystem" "CDEV";
+ match "type" "CREATE";
+ match "cdev" "ums[0-9]+";
+
+ action "service moused quietstart $cdev";
+};
+
+notify 100 {
+ match "system" "DEVFS";
+ match "subsystem" "CDEV";
+ match "type" "CREATE";
+ match "cdev" "wsp[0-9]+";
+
+ action "service moused quietstart $cdev";
+};
+
+notify 100 {
+ match "system" "DEVFS";
+ match "subsystem" "CDEV";
+ match "type" "DESTROY";
+ match "cdev" "ums[0-9]+";
+
+ action "service moused stop $cdev";
+};
diff --git a/sbin/devd/parse.y b/sbin/devd/parse.y
index 9b8fd592045a..1aa3c20b6b68 100644
--- a/sbin/devd/parse.y
+++ b/sbin/devd/parse.y
@@ -2,7 +2,7 @@
/*-
* DEVD (Device action daemon)
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002 M. Warner Losh <imp@FreeBSD.org>
*
@@ -26,8 +26,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <sys/cdefs.h>
diff --git a/sbin/devd/power_profile.conf b/sbin/devd/power_profile.conf
new file mode 100644
index 000000000000..294856071f00
--- /dev/null
+++ b/sbin/devd/power_profile.conf
@@ -0,0 +1,6 @@
+# Switch power profiles when the AC line state changes.
+notify 10 {
+ match "system" "ACPI";
+ match "subsystem" "ACAD";
+ action "service power_profile $notify";
+};
diff --git a/sbin/devd/syscons.conf b/sbin/devd/syscons.conf
new file mode 100644
index 000000000000..cd0c744955b9
--- /dev/null
+++ b/sbin/devd/syscons.conf
@@ -0,0 +1,9 @@
+# When a USB keyboard arrives, attach it as the console keyboard.
+attach 100 {
+ device-name "ukbd0";
+ action "service syscons setkeyboard /dev/ukbd0";
+};
+detach 100 {
+ device-name "ukbd0";
+ action "service syscons setkeyboard /dev/kbd0";
+};
diff --git a/sbin/devd/tests/Makefile b/sbin/devd/tests/Makefile
index c0a346f94d33..7a51f488ac68 100644
--- a/sbin/devd/tests/Makefile
+++ b/sbin/devd/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_C= client_test
TEST_METADATA.client_test= required_files="/var/run/devd.pid"
diff --git a/sbin/devd/tests/Makefile.depend b/sbin/devd/tests/Makefile.depend
index c062f6026d94..1af0c88e099c 100644
--- a/sbin/devd/tests/Makefile.depend
+++ b/sbin/devd/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/sbin/devd/tests/client_test.c b/sbin/devd/tests/client_test.c
index 90081d963f4b..729c7a2f8bad 100644
--- a/sbin/devd/tests/client_test.c
+++ b/sbin/devd/tests/client_test.c
@@ -23,8 +23,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdbool.h>
#include <stdio.h>
diff --git a/sbin/devd/token.l b/sbin/devd/token.l
index 30e48e815fe3..f60ee40dedb2 100644
--- a/sbin/devd/token.l
+++ b/sbin/devd/token.l
@@ -2,7 +2,7 @@
/*-
* DEVD (Device action daemon)
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002 M. Warner Losh <imp@FreeBSD.org>
*
@@ -26,8 +26,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <ctype.h>
diff --git a/sbin/devd/uath.conf b/sbin/devd/uath.conf
index 9f0cb939050b..13b50d44c739 100644
--- a/sbin/devd/uath.conf
+++ b/sbin/devd/uath.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Atheros USB wireless network device specific devd events
diff --git a/sbin/devd/ulpt.conf b/sbin/devd/ulpt.conf
index 2082726cbf47..f38398574a09 100644
--- a/sbin/devd/ulpt.conf
+++ b/sbin/devd/ulpt.conf
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
#
diff --git a/sbin/devd/zfs.conf b/sbin/devd/zfs.conf
index ef6a6c12b6a1..56e1e2b21acd 100644
--- a/sbin/devd/zfs.conf
+++ b/sbin/devd/zfs.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Sample ZFS problem reports handling.
diff --git a/sbin/devfs/Makefile b/sbin/devfs/Makefile
index cf1fa812d3d6..dc823abcaf18 100644
--- a/sbin/devfs/Makefile
+++ b/sbin/devfs/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
CONFS= devfs.conf devfs.rules
CONFSDIR_devfs.rules= /etc/defaults
diff --git a/sbin/devfs/Makefile.depend b/sbin/devfs/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/sbin/devfs/Makefile.depend
+++ b/sbin/devfs/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/devfs/devfs.8 b/sbin/devfs/devfs.8
index 4a9c42b7ebc5..598f2303a605 100644
--- a/sbin/devfs/devfs.8
+++ b/sbin/devfs/devfs.8
@@ -23,9 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd December 1, 2020
+.Dd October 18, 2023
.Dt DEVFS 8
.Os
.Sh NAME
@@ -250,7 +248,7 @@ will return the same information regardless of the mount-point specified with
The mount-point is only relevant when changing what its current ruleset is
or when using one of the apply commands.
.Sh FILES
-.Bl -tag -width "Pa /usr/share/examples/etc/devfs.conf" -compact
+.Bl -tag -width "Pa /etc/defaults/devfs.rules" -compact
.It Pa /etc/defaults/devfs.rules
Default
.Nm
@@ -266,10 +264,6 @@ with the same ruleset number, otherwise the two files are effectively merged.
Boot-time
.Nm
configuration file.
-.It Pa /usr/share/examples/etc/devfs.conf
-Example boot-time
-.Nm
-configuration file.
.El
.Sh EXAMPLES
When the system boots,
diff --git a/sbin/devfs/devfs.c b/sbin/devfs/devfs.c
index b5a6bf4015a2..ae8954e9d88b 100644
--- a/sbin/devfs/devfs.c
+++ b/sbin/devfs/devfs.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001, 2002 Dima Dorfman.
* All rights reserved.
@@ -30,9 +30,6 @@
* DEVFS control.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/queue.h>
diff --git a/sbin/devfs/devfs.conf b/sbin/devfs/devfs.conf
index d3d60752c0b1..d3430a2fe844 100644
--- a/sbin/devfs/devfs.conf
+++ b/sbin/devfs/devfs.conf
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
# These are examples of how to configure devices using /etc/rc.d/devfs.
# The first parameter is always the action to take, the second is always the
diff --git a/sbin/devfs/devfs.rules b/sbin/devfs/devfs.rules
index a92cd03a019b..f85940aaa7dd 100644
--- a/sbin/devfs/devfs.rules
+++ b/sbin/devfs/devfs.rules
@@ -13,7 +13,6 @@
# references must include a dollar sign '$' in front of the
# name to be expanded properly.
#
-# $FreeBSD$
#
# Very basic and secure ruleset: Hide everything.
diff --git a/sbin/devfs/extern.h b/sbin/devfs/extern.h
index c02a7afba30e..952bdafd44ea 100644
--- a/sbin/devfs/extern.h
+++ b/sbin/devfs/extern.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002 Dima Dorfman.
* All rights reserved.
@@ -24,8 +24,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef __DEVFS_H__
diff --git a/sbin/devfs/rule.c b/sbin/devfs/rule.c
index 0bfc7ffaf3c8..d07104d1de13 100644
--- a/sbin/devfs/rule.c
+++ b/sbin/devfs/rule.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002 Dima Dorfman.
* All rights reserved.
@@ -30,9 +30,6 @@
* Rule subsystem manipulation.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/ioctl.h>
diff --git a/sbin/devmatch/Makefile b/sbin/devmatch/Makefile
index 6622bdb284d1..bc0b2a7cba55 100644
--- a/sbin/devmatch/Makefile
+++ b/sbin/devmatch/Makefile
@@ -1,5 +1,5 @@
-# $FreeBSD$
+PACKAGE= devmatch
PROG= devmatch
MAN= devmatch.8
diff --git a/sbin/devmatch/Makefile.depend b/sbin/devmatch/Makefile.depend
index fe15dd35be95..a4d91ccfc657 100644
--- a/sbin/devmatch/Makefile.depend
+++ b/sbin/devmatch/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/sbin/devmatch/devmatch.8 b/sbin/devmatch/devmatch.8
index 11cf844bef9f..f5e3a5154a32 100644
--- a/sbin/devmatch/devmatch.8
+++ b/sbin/devmatch/devmatch.8
@@ -21,9 +21,7 @@
.\" (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 November 21, 2021
+.Dd August 13, 2023
.Dt DEVMATCH 8
.Os
.Sh NAME
@@ -31,13 +29,13 @@
.Nd print information about unattached devices
.Sh SYNOPSIS
.Nm
-.Op Fl adhpuv
-.Op Fl -all
-.Op Fl -dump
-.Op Fl -hints Ar file
-.Op Fl -nomatch Ar event
-.Op Fl -unbound
-.Op Fl -verbose
+.Op Fl a | -all
+.Op Fl d | -dump
+.Op Oo Fl h | -hints Oc Ar file
+.Op Oo Fl p | -nomatch Oc Ar event
+.Op Fl q | -quiet
+.Op Fl u | -unbound
+.Op Fl v | -verbose
.Sh DESCRIPTION
The
.Nm
@@ -60,9 +58,13 @@ guessed from the current module load path.
Parse and use a standard NOMATCH event from
.Xr devd 8
for matching instead of searching the device tree.
+.It Fl q Fl -quiet
+Suppress some error messages and simply return a non-zero exit code.
+This is helpful to avoid an endless list of warnings during bootup if
+no hints are available.
.It Fl u Fl -unbound
Attempt to produce a list of those drivers with PNP info whose driver
-tables with that PNP info can not be found.
+tables with that PNP info cannot be found.
.It Fl v Fl -verbose
Produce more verbose output.
.El
@@ -91,7 +93,8 @@ and will be reported twice.
The PNP string's attributes are evaluated once per PNP entry on that
bus rather than once.
.Pp
-The term PNP is overloaded in FreeBSD.
+The term PNP is overloaded in
+.Fx .
It means, generically, the identifying data the bus provides about a
device.
While this include old ISA PNP identifiers, it also includes the
diff --git a/sbin/devmatch/devmatch.c b/sbin/devmatch/devmatch.c
index 20a57353ecf6..d93a35e5633d 100644
--- a/sbin/devmatch/devmatch.c
+++ b/sbin/devmatch/devmatch.c
@@ -23,9 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <ctype.h>
#include <devinfo.h>
@@ -36,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sysexits.h>
#include <unistd.h>
#include <sys/linker.h>
#include <sys/module.h>
@@ -48,6 +46,7 @@ static struct option longopts[] = {
{ "dump", no_argument, NULL, 'd' },
{ "hints", required_argument, NULL, 'h' },
{ "nomatch", required_argument, NULL, 'p' },
+ { "quiet", no_argument, NULL, 'q' },
{ "unbound", no_argument, NULL, 'u' },
{ "verbose", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 }
@@ -59,6 +58,7 @@ static int all_flag;
static int dump_flag;
static char *linker_hints;
static char *nomatch_str;
+static int quiet_flag;
static int unbound_flag;
static int verbose_flag;
@@ -114,8 +114,12 @@ read_linker_hints(void)
continue;
break;
}
- if (q == NULL)
- errx(1, "Can't read linker hints file.");
+ if (q == NULL) {
+ if (quiet_flag)
+ exit(EX_UNAVAILABLE);
+ else
+ errx(EX_UNAVAILABLE, "Can't read linker hints file.");
+ }
} else {
hints = read_hints(linker_hints, &len);
if (hints == NULL)
@@ -565,7 +569,7 @@ main(int argc, char **argv)
{
int ch;
- while ((ch = getopt_long(argc, argv, "adh:p:uv",
+ while ((ch = getopt_long(argc, argv, "adh:p:quv",
longopts, NULL)) != -1) {
switch (ch) {
case 'a':
@@ -580,6 +584,9 @@ main(int argc, char **argv)
case 'p':
nomatch_str = optarg;
break;
+ case 'q':
+ quiet_flag++;
+ break;
case 'u':
unbound_flag++;
break;
diff --git a/sbin/dhclient/Makefile b/sbin/dhclient/Makefile
index cdf93b8b8145..27c81d9d9e6c 100644
--- a/sbin/dhclient/Makefile
+++ b/sbin/dhclient/Makefile
@@ -1,5 +1,4 @@
# $OpenBSD: Makefile,v 1.9 2004/05/04 12:52:05 henning Exp $
-# $FreeBSD$
#
# Copyright (c) 1996, 1997 The Internet Software Consortium.
# All rights reserved.
@@ -34,7 +33,7 @@
.include <src.opts.mk>
CONFS= dhclient.conf
-PACKAGE=runtime
+PACKAGE=dhclient
SRCS= dhclient.c clparse.c alloc.c dispatch.c hash.c bpf.c options.c \
tree.c conflex.c errwarn.c inet.c packet.c convert.c tables.c \
parse.c privsep.c
diff --git a/sbin/dhclient/Makefile.depend b/sbin/dhclient/Makefile.depend
index 7d9bf2cd046a..2326fec704fd 100644
--- a/sbin/dhclient/Makefile.depend
+++ b/sbin/dhclient/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
@@ -9,7 +8,6 @@ DIRDEPS = \
lib/libc \
lib/libcapsicum \
lib/libcompiler_rt \
- lib/libnv \
lib/libutil \
diff --git a/sbin/dhclient/Makefile.depend.options b/sbin/dhclient/Makefile.depend.options
index f61d5cffc555..ec521958a588 100644
--- a/sbin/dhclient/Makefile.depend.options
+++ b/sbin/dhclient/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= CASPER
diff --git a/sbin/dhclient/alloc.c b/sbin/dhclient/alloc.c
index c3ea309a5456..1926f7924170 100644
--- a/sbin/dhclient/alloc.c
+++ b/sbin/dhclient/alloc.c
@@ -43,8 +43,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
struct string_list *
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index d938b68c7c94..d4bbe56332c8 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -44,8 +44,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
#include "privsep.h"
#include <sys/capsicum.h>
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index c7b02a073aa3..c883e2a0ddb5 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -43,8 +43,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
#include "dhctoken.h"
@@ -186,6 +184,7 @@ read_client_leases(void)
* hardware-declaration |
* REQUEST option-list |
* REQUIRE option-list |
+ * IGNORE option-list |
* TIMEOUT number |
* RETRY number |
* REBOOT number |
@@ -249,6 +248,9 @@ parse_client_statement(FILE *cfile, struct interface_info *ip,
sizeof(config->required_options));
parse_option_list(cfile, config->required_options);
return;
+ case IGNORE:
+ parse_option_list(cfile, config->ignored_options);
+ return;
case TIMEOUT:
parse_lease_time(cfile, &config->timeout);
return;
diff --git a/sbin/dhclient/conflex.c b/sbin/dhclient/conflex.c
index c11c9189527e..377f7a1d440a 100644
--- a/sbin/dhclient/conflex.c
+++ b/sbin/dhclient/conflex.c
@@ -43,8 +43,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include "dhcpd.h"
@@ -413,6 +411,8 @@ intern(char *atom, int dfv)
return (HOSTNAME);
break;
case 'i':
+ if (!strcasecmp(atom + 1, "gnore"))
+ return (IGNORE);
if (!strcasecmp(atom + 1, "nitial-interval"))
return (INITIAL_INTERVAL);
if (!strcasecmp(atom + 1, "nterface"))
diff --git a/sbin/dhclient/convert.c b/sbin/dhclient/convert.c
index c30195254d4b..8401615b5bf0 100644
--- a/sbin/dhclient/convert.c
+++ b/sbin/dhclient/convert.c
@@ -46,8 +46,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
u_int32_t
diff --git a/sbin/dhclient/dhclient-script b/sbin/dhclient/dhclient-script
index 3439fd960773..27c424e18118 100755
--- a/sbin/dhclient/dhclient-script
+++ b/sbin/dhclient/dhclient-script
@@ -1,7 +1,6 @@
#!/bin/sh
#
# $OpenBSD: dhclient-script,v 1.6 2004/05/06 18:22:41 claudio Exp $
-# $FreeBSD$
#
# Copyright (c) 2003 Kenneth R Westerback <krw@openbsd.org>
#
@@ -173,6 +172,10 @@ add_new_routes() {
if [ "$new_ip_address" = "$router" ]; then
route add default -iface $router >/dev/null 2>&1
else
+ if [ "$new_subnet_mask" = "255.255.255.255" ]; then
+ route add "$router" -iface "$interface" >/dev/null 2>&1
+ fi
+
route add default $router >/dev/null 2>&1
fi
fi
@@ -314,13 +317,12 @@ fi
case $reason in
MEDIUM)
eval "$IFCONFIG $interface $medium"
- eval "$IFCONFIG $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
sleep 1
;;
PREINIT)
delete_old_alias
- $IFCONFIG $interface inet alias 0.0.0.0 netmask 255.0.0.0 broadcast 255.255.255.255 up
+ eval "$IFCONFIG $interface up"
;;
ARPCHECK|ARPSEND)
diff --git a/sbin/dhclient/dhclient-script.8 b/sbin/dhclient/dhclient-script.8
index 2fae9f67cbe5..dd3efd3e8698 100644
--- a/sbin/dhclient/dhclient-script.8
+++ b/sbin/dhclient/dhclient-script.8
@@ -36,8 +36,6 @@
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
.\" Enterprises, see ``http://www.vix.com''.
.\"
-.\" $FreeBSD$
-.\"
.Dd September 6, 2010
.Dt DHCLIENT-SCRIPT 8
.Os
diff --git a/sbin/dhclient/dhclient.8 b/sbin/dhclient/dhclient.8
index 3ea35e8eb472..a7328304fa68 100644
--- a/sbin/dhclient/dhclient.8
+++ b/sbin/dhclient/dhclient.8
@@ -36,8 +36,6 @@
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
.\" Enterprises, see ``http://www.vix.com''.
.\"
-.\" $FreeBSD$
-.\"
.Dd August 4, 2018
.Dt DHCLIENT 8
.Os
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index a1628f0ee22f..8179a5c34209 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -56,8 +56,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
#include "privsep.h"
@@ -798,7 +796,7 @@ dhcpack(struct packet *packet)
ACTION_SUPERSEDE)
ip->client->new->expiry = getULong(
ip->client->config->defaults[DHO_DHCP_LEASE_TIME].data);
- else if (ip->client->new->options[DHO_DHCP_LEASE_TIME].data)
+ else if (ip->client->new->options[DHO_DHCP_LEASE_TIME].len >= 4)
ip->client->new->expiry = getULong(
ip->client->new->options[DHO_DHCP_LEASE_TIME].data);
else
@@ -821,7 +819,7 @@ dhcpack(struct packet *packet)
ACTION_SUPERSEDE)
ip->client->new->renewal = getULong(
ip->client->config->defaults[DHO_DHCP_RENEWAL_TIME].data);
- else if (ip->client->new->options[DHO_DHCP_RENEWAL_TIME].len)
+ else if (ip->client->new->options[DHO_DHCP_RENEWAL_TIME].len >= 4)
ip->client->new->renewal = getULong(
ip->client->new->options[DHO_DHCP_RENEWAL_TIME].data);
else
@@ -835,7 +833,7 @@ dhcpack(struct packet *packet)
ACTION_SUPERSEDE)
ip->client->new->rebind = getULong(
ip->client->config->defaults[DHO_DHCP_REBINDING_TIME].data);
- else if (ip->client->new->options[DHO_DHCP_REBINDING_TIME].len)
+ else if (ip->client->new->options[DHO_DHCP_REBINDING_TIME].len >= 4)
ip->client->new->rebind = getULong(
ip->client->new->options[DHO_DHCP_REBINDING_TIME].data);
else
@@ -1039,7 +1037,6 @@ dhcpoffer(struct packet *packet)
note("%s from %s", name, piaddr(packet->client_addr));
-
/* If this lease doesn't supply the minimum required parameters,
blow it off. */
for (i = 0; ip->client->config->required_options[i]; i++) {
@@ -1141,8 +1138,9 @@ dhcpoffer(struct packet *packet)
struct client_lease *
packet_to_lease(struct packet *packet)
{
+ struct interface_info *ip = packet->interface;
struct client_lease *lease;
- int i;
+ int i, j;
lease = malloc(sizeof(struct client_lease));
@@ -1156,6 +1154,15 @@ packet_to_lease(struct packet *packet)
/* Copy the lease options. */
for (i = 0; i < 256; i++) {
if (packet->options[i].len) {
+ int ignored = 0;
+ for (j = 0; ip->client->config->ignored_options[j]; j++)
+ if (i ==
+ ip->client->config->ignored_options[j]) {
+ ignored = 1;
+ break;
+ }
+ if (ignored)
+ continue;
lease->options[i].data =
malloc(packet->options[i].len + 1);
if (!lease->options[i].data) {
diff --git a/sbin/dhclient/dhclient.conf b/sbin/dhclient/dhclient.conf
index a7639d904aad..4979cd470d5e 100644
--- a/sbin/dhclient/dhclient.conf
+++ b/sbin/dhclient/dhclient.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# This file is required by the ISC DHCP client.
# See ``man 5 dhclient.conf'' for details.
diff --git a/sbin/dhclient/dhclient.conf.5 b/sbin/dhclient/dhclient.conf.5
index 14a0de4111dd..b2190a8e076b 100644
--- a/sbin/dhclient/dhclient.conf.5
+++ b/sbin/dhclient/dhclient.conf.5
@@ -36,9 +36,7 @@
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
.\" Enterprises, see ``http://www.vix.com''.
.\"
-.\" $FreeBSD$
-.\"
-.Dd July 21, 2021
+.Dd March 17, 2023
.Dt DHCLIENT.CONF 5
.Os
.Sh NAME
@@ -200,6 +198,11 @@ option other than the default requested lease time, which is two hours.
The other obvious use for this statement is to send information to the server
that will allow it to differentiate between this client and other
clients or kinds of clients.
+.It Ic ignore Oo Ar option Oc Oo , Ar ... option Oc ;
+The
+.Ic ignore
+statement causes the client to disregard the specified options in any offer
+received, as though the server had never sent them at all.
.El
.Sh OPTION MODIFIERS
In some cases, a client may receive option data from the server which
diff --git a/sbin/dhclient/dhclient.leases.5 b/sbin/dhclient/dhclient.leases.5
index 38c8edb969c5..5aca3f10d6ae 100644
--- a/sbin/dhclient/dhclient.leases.5
+++ b/sbin/dhclient/dhclient.leases.5
@@ -36,8 +36,6 @@
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
.\" Enterprises, see ``http://www.vix.com''.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 1, 1997
.Dt DHCLIENT.LEASES 5
.Os
diff --git a/sbin/dhclient/dhcp-options.5 b/sbin/dhclient/dhcp-options.5
index 29b2e7234422..24604514a016 100644
--- a/sbin/dhclient/dhcp-options.5
+++ b/sbin/dhclient/dhcp-options.5
@@ -36,8 +36,6 @@
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
.\" Enterprises, see ``http://www.vix.com''.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 1, 1995
.Dt DHCP-OPTIONS 5
.Os
diff --git a/sbin/dhclient/dhcp.h b/sbin/dhclient/dhcp.h
index 9183a9c82aec..300deb464238 100644
--- a/sbin/dhclient/dhcp.h
+++ b/sbin/dhclient/dhcp.h
@@ -1,5 +1,4 @@
/* $OpenBSD: dhcp.h,v 1.5 2004/05/04 15:49:49 deraadt Exp $ */
-/* $FreeBSD$ */
/* Protocol structures... */
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index b151daa90a1c..399b5c1ecf6c 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -39,8 +39,6 @@
* Enterprises. To learn more about the Internet Software Consortium,
* see ``http://www.vix.com/isc''. To learn more about Vixie
* Enterprises, see ``http://www.vix.com''.
- *
- * $FreeBSD$
*/
#include <sys/param.h>
@@ -159,6 +157,7 @@ struct client_config {
u_int8_t required_options[256];
u_int8_t requested_options[256];
int requested_option_count;
+ u_int8_t ignored_options[256];
u_int vlan_pcp;
time_t timeout;
time_t initial_interval;
diff --git a/sbin/dhclient/dhctoken.h b/sbin/dhclient/dhctoken.h
index c929307c7e06..20ea515a49ae 100644
--- a/sbin/dhclient/dhctoken.h
+++ b/sbin/dhclient/dhctoken.h
@@ -40,8 +40,6 @@
* Enterprises. To learn more about the Internet Software Consortium,
* see ``http://www.vix.com/isc''. To learn more about Vixie
* Enterprises, see ``http://www.vix.com''.
- *
- * $FreeBSD$
*/
#define SEMI ';'
@@ -134,6 +132,7 @@
#define TOKEN_NOT 334
#define ALWAYS_REPLY_RFC1048 335
#define VLAN_PCP 336
+#define IGNORE 337
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
(x) != STRING && \
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 91f1694ec902..310f477f8a4f 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -42,8 +42,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
#include "privsep.h"
@@ -78,6 +76,7 @@ discover_interfaces(struct interface_info *iface)
{
struct ifaddrs *ifap, *ifa;
struct ifreq *tif;
+ int len = IFNAMSIZ + sizeof(struct sockaddr_storage);
if (getifaddrs(&ifap) != 0)
error("getifaddrs failed");
@@ -118,26 +117,14 @@ discover_interfaces(struct interface_info *iface)
iface->hw_address.htype = HTYPE_ETHER; /* XXX */
memcpy(iface->hw_address.haddr,
LLADDR(foo), foo->sdl_alen);
- } else if (ifa->ifa_addr->sa_family == AF_INET) {
- struct sockaddr_in foo;
- struct iaddr addr;
-
- memcpy(&foo, ifa->ifa_addr, sizeof(foo));
- if (foo.sin_addr.s_addr == htonl(INADDR_LOOPBACK))
- continue;
- if (!iface->ifp) {
- if ((tif = calloc(1, sizeof(struct ifreq)))
- == NULL)
- error("no space to remember ifp");
- strlcpy(tif->ifr_name, ifa->ifa_name, IFNAMSIZ);
- memcpy(&tif->ifr_addr, ifa->ifa_addr,
- ifa->ifa_addr->sa_len);
- iface->ifp = tif;
- iface->primary_address = foo.sin_addr;
- }
- addr.len = 4;
- memcpy(addr.iabuf, &foo.sin_addr.s_addr, addr.len);
}
+ if (!iface->ifp) {
+ if ((tif = calloc(1, len)) == NULL)
+ error("no space to remember ifp");
+ strlcpy(tif->ifr_name, ifa->ifa_name, IFNAMSIZ);
+ iface->ifp = tif;
+ }
+
}
if (!iface->ifp)
diff --git a/sbin/dhclient/errwarn.c b/sbin/dhclient/errwarn.c
index 824faafd75a3..c073d5997056 100644
--- a/sbin/dhclient/errwarn.c
+++ b/sbin/dhclient/errwarn.c
@@ -43,8 +43,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <errno.h>
#include "dhcpd.h"
diff --git a/sbin/dhclient/hash.c b/sbin/dhclient/hash.c
index 5d797cc96964..b2d72a5a299a 100644
--- a/sbin/dhclient/hash.c
+++ b/sbin/dhclient/hash.c
@@ -43,8 +43,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
static int do_hash(const unsigned char *, int, int);
diff --git a/sbin/dhclient/inet.c b/sbin/dhclient/inet.c
index c72a7f6b702e..1684994129b8 100644
--- a/sbin/dhclient/inet.c
+++ b/sbin/dhclient/inet.c
@@ -45,8 +45,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
/*
diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c
index afdb3985aa59..4bc26c007921 100644
--- a/sbin/dhclient/options.c
+++ b/sbin/dhclient/options.c
@@ -43,8 +43,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#define DHCP_OPTION_DATA
diff --git a/sbin/dhclient/packet.c b/sbin/dhclient/packet.c
index 276bb5c2457f..3d7390c06ee0 100644
--- a/sbin/dhclient/packet.c
+++ b/sbin/dhclient/packet.c
@@ -43,8 +43,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
#include <netinet/in_systm.h>
diff --git a/sbin/dhclient/parse.c b/sbin/dhclient/parse.c
index 4018f70f3a5d..da0c4aa754e1 100644
--- a/sbin/dhclient/parse.c
+++ b/sbin/dhclient/parse.c
@@ -43,8 +43,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdbool.h>
#include "dhcpd.h"
@@ -444,9 +442,7 @@ convert_num(unsigned char *buf, char *str, unsigned base, int size)
time_t
parse_date(FILE *cfile)
{
- static int months[11] = { 31, 59, 90, 120, 151, 181,
- 212, 243, 273, 304, 334 };
- int guess, token;
+ int token;
struct tm tm;
char *val;
@@ -570,27 +566,5 @@ parse_date(FILE *cfile)
return (0);
}
- /* Guess the time value... */
- guess = ((((((365 * (tm.tm_year - 70) + /* Days in years since '70 */
- (tm.tm_year - 69) / 4 + /* Leap days since '70 */
- (tm.tm_mon /* Days in months this year */
- ? months[tm.tm_mon - 1]
- : 0) +
- (tm.tm_mon > 1 && /* Leap day this year */
- !((tm.tm_year - 72) & 3)) +
- tm.tm_mday - 1) * 24) + /* Day of month */
- tm.tm_hour) * 60) +
- tm.tm_min) * 60) + tm.tm_sec;
-
- /*
- * This guess could be wrong because of leap seconds or other
- * weirdness we don't know about that the system does. For
- * now, we're just going to accept the guess, but at some point
- * it might be nice to do a successive approximation here to get
- * an exact value. Even if the error is small, if the server
- * is restarted frequently (and thus the lease database is
- * reread), the error could accumulate into something
- * significant.
- */
- return (guess);
+ return (timegm(&tm));
}
diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c
index a286b6900808..02d12a36a3d9 100644
--- a/sbin/dhclient/privsep.c
+++ b/sbin/dhclient/privsep.c
@@ -17,8 +17,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
#include "privsep.h"
diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h
index db6ec9b4acea..1e26daa3d83d 100644
--- a/sbin/dhclient/privsep.h
+++ b/sbin/dhclient/privsep.h
@@ -14,8 +14,6 @@
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE, ABUSE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/sbin/dhclient/tables.c b/sbin/dhclient/tables.c
index 9225c4fe2051..134b54fa3b56 100644
--- a/sbin/dhclient/tables.c
+++ b/sbin/dhclient/tables.c
@@ -43,8 +43,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
/*
diff --git a/sbin/dhclient/tests/Makefile b/sbin/dhclient/tests/Makefile
index ce4c7acb822e..7d4359d4b762 100644
--- a/sbin/dhclient/tests/Makefile
+++ b/sbin/dhclient/tests/Makefile
@@ -1,12 +1,15 @@
-# $FreeBSD$
.PATH: ${.CURDIR:H}
ATF_TESTS_SH= pcp
+# Tests assign a common IP address.
+TEST_METADATA.pcp+= is_exclusive=true
+
PLAIN_TESTS_C= option-domain-search_test
SRCS.option-domain-search_test= alloc.c convert.c hash.c options.c \
- tables.c fake.c option-domain-search.c
+ tables.c parse.c conflex.c tree.c fake.c \
+ option-domain-search.c
CFLAGS.option-domain-search_test+= -I${.CURDIR:H}
LIBADD.option-domain-search_test= util
diff --git a/sbin/dhclient/tests/Makefile.depend b/sbin/dhclient/tests/Makefile.depend
index 4fc5be2a35f0..28acae7b0d55 100644
--- a/sbin/dhclient/tests/Makefile.depend
+++ b/sbin/dhclient/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/sbin/dhclient/tests/fake.c b/sbin/dhclient/tests/fake.c
index 6a170953beb0..15ed04dde077 100644
--- a/sbin/dhclient/tests/fake.c
+++ b/sbin/dhclient/tests/fake.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#include <setjmp.h>
#include <stdarg.h>
@@ -7,6 +6,7 @@
#include "dhcpd.h"
extern jmp_buf env;
+int warnings_occurred;
void
error(const char *fmt, ...)
@@ -52,6 +52,20 @@ note(const char *fmt, ...)
return ret;
}
+int
+parse_warn(const char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+ va_start(ap, fmt);
+ ret = vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+
+ return ret;
+}
+
void
bootp(struct packet *packet)
{
diff --git a/sbin/dhclient/tests/option-domain-search.c b/sbin/dhclient/tests/option-domain-search.c
index b79f9a560137..6a7f92c8775d 100644
--- a/sbin/dhclient/tests/option-domain-search.c
+++ b/sbin/dhclient/tests/option-domain-search.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#include <setjmp.h>
#include <stdlib.h>
@@ -303,6 +302,51 @@ multiple_domains_valid()
free(option->data);
}
+static
+void
+parse_date_helper(const char *string, time_t timestamp)
+{
+ int ret = 0;
+ FILE *file = NULL;
+ time_t ts;
+
+ file = fopen("/tmp/dhclient.test", "w");
+ if (!file)
+ abort();
+
+ ret = fwrite(string, strlen(string), 1, file);
+ if (ret <= 0)
+ abort();
+
+ fclose(file);
+
+ file = fopen("/tmp/dhclient.test", "r");
+ if (!file)
+ abort();
+
+ new_parse("test");
+ ts = parse_date(file);
+ if (ts != timestamp)
+ abort();
+
+ fclose(file);
+}
+
+void
+parse_date_valid(void)
+{
+ int ret;
+
+ ret = setjmp(env);
+ if (ret != 0)
+ abort();
+
+ parse_date_helper(" 2 2024/7/2 20:25:50;\n", 1719951950);
+#ifndef __i386__
+ parse_date_helper(" 1 2091/7/2 20:25:50;\n", 3834246350);
+#endif
+}
+
int
main(int argc, char *argv[])
{
@@ -324,5 +368,7 @@ main(int argc, char *argv[])
multiple_domains_valid();
+ parse_date_valid();
+
return (0);
}
diff --git a/sbin/dhclient/tree.c b/sbin/dhclient/tree.c
index 9639cb87321b..0414129b2efb 100644
--- a/sbin/dhclient/tree.c
+++ b/sbin/dhclient/tree.c
@@ -43,8 +43,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "dhcpd.h"
pair
diff --git a/sbin/dhclient/tree.h b/sbin/dhclient/tree.h
index 7bbd1e4c3226..f51b0a7bfdf4 100644
--- a/sbin/dhclient/tree.h
+++ b/sbin/dhclient/tree.h
@@ -39,8 +39,6 @@
* Enterprises. To learn more about the Internet Software Consortium,
* see ``http://www.vix.com/isc''. To learn more about Vixie
* Enterprises, see ``http://www.vix.com''.
- *
- * $FreeBSD$
*/
/* A pair of pointers, suitable for making a linked list. */
diff --git a/sbin/dmesg/Makefile b/sbin/dmesg/Makefile
index a443225242d8..d1863f2b448c 100644
--- a/sbin/dmesg/Makefile
+++ b/sbin/dmesg/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
PACKAGE=runtime
PROG= dmesg
diff --git a/sbin/dmesg/Makefile.depend b/sbin/dmesg/Makefile.depend
index 4a0ebeceed6f..124f2f93f8a6 100644
--- a/sbin/dmesg/Makefile.depend
+++ b/sbin/dmesg/Makefile.depend
@@ -1,14 +1,11 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libelf \
lib/libkvm \
diff --git a/sbin/dmesg/dmesg.8 b/sbin/dmesg/dmesg.8
index 50b5e3e26404..2ef3be8b6610 100644
--- a/sbin/dmesg/dmesg.8
+++ b/sbin/dmesg/dmesg.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)dmesg.8 8.1 (Berkeley) 6/5/93
-.\" $FreeBSD$
-.\"
.Dd May 7, 2022
.Dt DMESG 8
.Os
diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c
index f266e6b98b39..65005a903154 100644
--- a/sbin/dmesg/dmesg.c
+++ b/sbin/dmesg/dmesg.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static const char sccsid[] = "@(#)dmesg.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/msgbuf.h>
#include <sys/sysctl.h>
diff --git a/sbin/dump/Makefile b/sbin/dump/Makefile
index f611d6b1ab47..d982e5bc033e 100644
--- a/sbin/dump/Makefile
+++ b/sbin/dump/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
# dump.h header file
# itime.c reads /etc/dumpdates
@@ -13,7 +11,7 @@
# DEBUG use local directory to find ddate and dumpdates
# TDEBUG trace out the process forking
-PACKAGE=runtime
+PACKAGE=ufs
PROG= dump
CONFS= /dev/null
CONFSGRP= operator
diff --git a/sbin/dump/Makefile.depend b/sbin/dump/Makefile.depend
index 4bd09984c29d..d26328b3bed1 100644
--- a/sbin/dump/Makefile.depend
+++ b/sbin/dump/Makefile.depend
@@ -1,14 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/protocols \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libufs \
.include <dirdeps.mk>
diff --git a/sbin/dump/cache.c b/sbin/dump/cache.c
index 906ac2716959..b0da1bcc1aa8 100644
--- a/sbin/dump/cache.c
+++ b/sbin/dump/cache.c
@@ -2,8 +2,6 @@
* CACHE.C
*
* Block cache for dump
- *
- * $FreeBSD$
*/
#include <sys/param.h>
diff --git a/sbin/dump/dump.8 b/sbin/dump/dump.8
index 80e8eae21d19..08b3c2e574d7 100644
--- a/sbin/dump/dump.8
+++ b/sbin/dump/dump.8
@@ -26,9 +26,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)dump.8 8.3 (Berkeley) 5/1/95
-.\" $FreeBSD$
-.\"
.Dd December 28, 2020
.Dt DUMP 8
.Os
diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h
index fc8c845fc576..9429704a1800 100644
--- a/sbin/dump/dump.h
+++ b/sbin/dump/dump.h
@@ -27,10 +27,6 @@
* 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.
- *
- * @(#)dump.h 8.2 (Berkeley) 4/28/95
- *
- * $FreeBSD$
*/
/*
diff --git a/sbin/dump/dumprmt.c b/sbin/dump/dumprmt.c
index d1769faa3daf..4f61905eb60e 100644
--- a/sbin/dump/dumprmt.c
+++ b/sbin/dump/dumprmt.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)dumprmt.c 8.3 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/mtio.h>
#include <sys/socket.h>
diff --git a/sbin/dump/itime.c b/sbin/dump/itime.c
index cb6d55625e6d..ba6ccaf47f04 100644
--- a/sbin/dump/itime.c
+++ b/sbin/dump/itime.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)itime.c 8.1 (Berkeley) 6/5/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/queue.h>
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index 8752f2c1bea5..0ff622125fdd 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1991, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/mount.h>
@@ -457,7 +443,7 @@ main(int argc, char *argv[])
msgtail("to %s\n", tape);
sync();
- if ((ret = sbget(diskfd, &sblock, STDSB)) != 0) {
+ if ((ret = sbget(diskfd, &sblock, UFS_STDSB, UFS_NOCSUM)) != 0) {
switch (ret) {
case ENOENT:
warn("Cannot find file system superblock");
diff --git a/sbin/dump/optr.c b/sbin/dump/optr.c
index 8eb163516c72..f263f48374ae 100644
--- a/sbin/dump/optr.c
+++ b/sbin/dump/optr.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)optr.c 8.2 (Berkeley) 1/6/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/wait.h>
diff --git a/sbin/dump/pathnames.h b/sbin/dump/pathnames.h
index 120bd72f5f11..e309643473a7 100644
--- a/sbin/dump/pathnames.h
+++ b/sbin/dump/pathnames.h
@@ -27,9 +27,6 @@
* 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.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/5/93
- * $FreeBSD$
*/
#include <paths.h>
diff --git a/sbin/dump/tape.c b/sbin/dump/tape.c
index 45ad0ee50487..e448bacf61b6 100644
--- a/sbin/dump/tape.c
+++ b/sbin/dump/tape.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)tape.c 8.4 (Berkeley) 5/1/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/wait.h>
@@ -74,7 +66,8 @@ static long blocksthisvol; /* number of blocks on current output file */
static char *nexttape;
static FILE *popenfp = NULL;
-static int atomic(ssize_t (*)(), int, char *, int);
+static int atomic_read(int, void *, int);
+static int atomic_write(int, const void *, int);
static void worker(int, int);
static void create_workers(void);
static void flushtape(void);
@@ -236,7 +229,7 @@ flushtape(void)
wp->req[trecno].count = 0; /* Sentinel */
- if (atomic(write, wp->fd, (char *)wp->req, siz) != siz)
+ if (atomic_write(wp->fd, (const void *)wp->req, siz) != siz)
quit("error writing command pipe: %s\n", strerror(errno));
wp->sent = 1; /* we sent a request, read the response later */
@@ -247,7 +240,7 @@ flushtape(void)
/* Read results back from next worker */
if (wp->sent) {
- if (atomic(read, wp->fd, (char *)&got, sizeof got)
+ if (atomic_read(wp->fd, (void *)&got, sizeof got)
!= sizeof got) {
perror(" DUMP: error reading command pipe in master");
dumpabort(0);
@@ -264,8 +257,8 @@ flushtape(void)
*/
for (i = 0; i < WORKERS; i++) {
if (workers[i].sent) {
- if (atomic(read, workers[i].fd,
- (char *)&got, sizeof got)
+ if (atomic_read(workers[i].fd,
+ (void *)&got, sizeof got)
!= sizeof got) {
perror(" DUMP: error reading command pipe in master");
dumpabort(0);
@@ -322,7 +315,7 @@ trewind(void)
* fixme: punt for now.
*/
if (workers[f].sent) {
- if (atomic(read, workers[f].fd, (char *)&got, sizeof got)
+ if (atomic_read(workers[f].fd, (void *)&got, sizeof got)
!= sizeof got) {
perror(" DUMP: error reading command pipe in master");
dumpabort(0);
@@ -446,7 +439,7 @@ rollforward(void)
lastspclrec = savedtapea - 1;
}
size = (char *)ntb - (char *)q;
- if (atomic(write, wp->fd, (char *)q, size) != size) {
+ if (atomic_write(wp->fd, (const void *)q, size) != size) {
perror(" DUMP: error writing command pipe");
dumpabort(0);
}
@@ -486,7 +479,7 @@ rollforward(void)
* worked ok, otherwise the tape is much too short!
*/
if (wp->sent) {
- if (atomic(read, wp->fd, (char *)&got, sizeof got)
+ if (atomic_read(wp->fd, (void *)&got, sizeof got)
!= sizeof got) {
perror(" DUMP: error reading command pipe in master");
dumpabort(0);
@@ -676,8 +669,7 @@ dumpabort(int signo __unused)
}
void
-Exit(status)
- int status;
+Exit(int status)
{
#ifdef TDEBUG
@@ -735,8 +727,8 @@ create_workers(void)
}
for (i = 0; i < WORKERS; i++)
- (void) atomic(write, workers[i].fd,
- (char *) &workers[(i + 1) % WORKERS].pid,
+ (void) atomic_write(workers[i].fd,
+ (const void *) &workers[(i + 1) % WORKERS].pid,
sizeof workers[0].pid);
master = 0;
@@ -777,7 +769,7 @@ worker(int cmd, int worker_number)
/*
* Need the pid of the next worker in the loop...
*/
- if ((nread = atomic(read, cmd, (char *)&nextworker, sizeof nextworker))
+ if ((nread = atomic_read(cmd, (void *)&nextworker, sizeof nextworker))
!= sizeof nextworker) {
quit("master/worker protocol botched - didn't get pid of next worker.\n");
}
@@ -785,7 +777,7 @@ worker(int cmd, int worker_number)
/*
* Get list of blocks to dump, read the blocks into tape buffer
*/
- while ((nread = atomic(read, cmd, (char *)wp->req, reqsiz)) == reqsiz) {
+ while ((nread = atomic_read(cmd, (void *)wp->req, reqsiz)) == reqsiz) {
struct req *p = wp->req;
for (trecno = 0; trecno < ntrec;
@@ -794,8 +786,8 @@ worker(int cmd, int worker_number)
blkread(p->dblk, wp->tblock[trecno],
p->count * TP_BSIZE);
} else {
- if (p->count != 1 || atomic(read, cmd,
- (char *)wp->tblock[trecno],
+ if (p->count != 1 || atomic_read(cmd,
+ (void *)wp->tblock[trecno],
TP_BSIZE) != TP_BSIZE)
quit("master/worker protocol botched.\n");
}
@@ -858,7 +850,8 @@ worker(int cmd, int worker_number)
* pass size of write back to master
* (for EOT handling)
*/
- (void) atomic(write, cmd, (char *)&size, sizeof size);
+ (void)atomic_write(cmd, (const void *)&size,
+ sizeof size);
}
/*
@@ -873,15 +866,28 @@ worker(int cmd, int worker_number)
/*
* Since a read from a pipe may not return all we asked for,
- * or a write may not write all we ask if we get a signal,
* loop until the count is satisfied (or error).
*/
static int
-atomic(ssize_t (*func)(), int fd, char *buf, int count)
+atomic_read(int fd, void *buf, int count)
+{
+ int got, need = count;
+
+ while ((got = read(fd, buf, need)) > 0 && (need -= got) > 0)
+ buf += got;
+ return (got < 0 ? got : count - need);
+}
+
+/*
+ * Since a write to a pipe may not write all we ask if we get a signal,
+ * loop until the count is satisfied (or error).
+ */
+static int
+atomic_write(int fd, const void *buf, int count)
{
int got, need = count;
- while ((got = (*func)(fd, buf, need)) > 0 && (need -= got) > 0)
+ while ((got = write(fd, buf, need)) > 0 && (need -= got) > 0)
buf += got;
return (got < 0 ? got : count - need);
}
diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c
index 08e902667759..ccc2d0a625e9 100644
--- a/sbin/dump/traverse.c
+++ b/sbin/dump/traverse.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)traverse.c 8.7 (Berkeley) 6/15/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/stat.h>
diff --git a/sbin/dump/unctime.c b/sbin/dump/unctime.c
index 3e03a65f1a7c..82ee12597c05 100644
--- a/sbin/dump/unctime.c
+++ b/sbin/dump/unctime.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)unctime.c 8.2 (Berkeley) 6/14/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <time.h>
/*
diff --git a/sbin/dumpfs/Makefile b/sbin/dumpfs/Makefile
index 03e1aae03b87..b416eb1cd588 100644
--- a/sbin/dumpfs/Makefile
+++ b/sbin/dumpfs/Makefile
@@ -1,7 +1,5 @@
-# @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
-PACKAGE=runtime
+PACKAGE=ufs
PROG= dumpfs
WARNS?= 2
LIBADD= ufs
diff --git a/sbin/dumpfs/Makefile.depend b/sbin/dumpfs/Makefile.depend
index 735bf03b75b6..910688a678fa 100644
--- a/sbin/dumpfs/Makefile.depend
+++ b/sbin/dumpfs/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/dumpfs/dumpfs.8 b/sbin/dumpfs/dumpfs.8
index ec5b12550447..768329315bc3 100644
--- a/sbin/dumpfs/dumpfs.8
+++ b/sbin/dumpfs/dumpfs.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)dumpfs.8 8.1 (Berkeley) 6/5/93
-.\" $FreeBSD$
-.\"
.Dd July 2, 2021
.Dt DUMPFS 8
.Os
@@ -89,7 +86,8 @@ and
are not handled and
.Fl p
is not useful in this case so is omitted.
-.Xr Newfs 8
+The
+.Xr newfs 8
options
.Fl n
and
diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c
index 7c43cf4489a8..c4988ded88d8 100644
--- a/sbin/dumpfs/dumpfs.c
+++ b/sbin/dumpfs/dumpfs.c
@@ -44,20 +44,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1992, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)dumpfs.c 8.5 (Berkeley) 4/29/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/time.h>
#include <sys/disklabel.h>
@@ -74,6 +60,7 @@ static const char rcsid[] =
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#define afs disk.d_fs
@@ -89,7 +76,7 @@ static void dumpfreespacecg(int);
static int marshal(const char *);
static void pbits(void *, int);
static void pblklist(void *, int, off_t, int);
-static void ufserr(const char *);
+static const char *ufserr(void);
static void usage(void) __dead2;
int
@@ -130,8 +117,9 @@ main(int argc, char *argv[])
usage();
while ((name = *argv++) != NULL) {
- if (ufs_disk_fillout(&disk, name) == -1) {
- ufserr(name);
+ if (ufs_disk_fillout_blank(&disk, name) == -1 ||
+ sbfind(&disk, 0) == -1) {
+ printf("\n%s: %s\n", name, ufserr());
eval |= 1;
continue;
}
@@ -162,7 +150,7 @@ dumpfs(const char *name, int dosb)
time_t fstime, fsmtime;
int64_t fssize;
int32_t fsflags;
- int i;
+ int i, ret;
switch (disk.d_ufs) {
case 2:
@@ -187,7 +175,8 @@ dumpfs(const char *name, int dosb)
afs.fs_ncg, (intmax_t)fssize, (intmax_t)afs.fs_dsize);
break;
default:
- goto err;
+ printf("Unknown filesystem type %d\n", disk.d_ufs);
+ return (1);
}
printf("bsize\t%d\tshift\t%d\tmask\t0x%08x\n",
afs.fs_bsize, afs.fs_bshift, afs.fs_bmask);
@@ -233,8 +222,8 @@ dumpfs(const char *name, int dosb)
printf("sbsize\t%d\tcgsize\t%d\tcgoffset %d\tcgmask\t0x%08x\n",
afs.fs_sbsize, afs.fs_cgsize, afs.fs_old_cgoffset,
afs.fs_old_cgmask);
- printf("csaddr\t%d\tcssize\t%d\n",
- afs.fs_old_csaddr, afs.fs_cssize);
+ printf("csaddr\t%jd\tcssize\t%d\n",
+ (intmax_t)afs.fs_csaddr, afs.fs_cssize);
printf("rotdelay %dms\trps\t%d\ttrackskew %d\tinterleave %d\n",
afs.fs_old_rotdelay, afs.fs_old_rps, afs.fs_old_trackskew,
afs.fs_old_interleave);
@@ -242,8 +231,11 @@ dumpfs(const char *name, int dosb)
afs.fs_old_nsect, afs.fs_old_npsect, afs.fs_old_spc);
break;
default:
- goto err;
+ printf("Unknown filesystem type %d\n", disk.d_ufs);
+ return (1);
}
+ printf("old_cpg\t%d\tsize_cg\t%zu\tCGSIZE\t%zu\n",
+ afs.fs_old_cpg, sizeof(struct cg), CGSIZE(&afs));
printf("sblkno\t%d\tcblkno\t%d\tiblkno\t%d\tdblkno\t%d\n",
afs.fs_sblkno, afs.fs_cblkno, afs.fs_iblkno, afs.fs_dblkno);
printf("cgrotor\t%d\tfmod\t%d\tronly\t%d\tclean\t%d\n",
@@ -308,9 +300,6 @@ dumpfs(const char *name, int dosb)
afs.fs_volname, (uintmax_t)afs.fs_swuid,
(uintmax_t)afs.fs_providersize);
printf("\ncs[].cs_(nbfree,ndir,nifree,nffree):\n\t");
- afs.fs_csp = calloc(1, afs.fs_cssize);
- if (bread(&disk, fsbtodb(&afs, afs.fs_csaddr), afs.fs_csp, afs.fs_cssize) == -1)
- goto err;
for (i = 0; i < afs.fs_ncg; i++) {
struct csum *cs = &afs.fs_cs(&afs, i);
if (i && i % 4 == 0)
@@ -329,14 +318,15 @@ dumpfs(const char *name, int dosb)
}
if (dosb)
return (0);
+ ret = 0;
while ((i = cgread(&disk)) != 0) {
- if (i == -1 || dumpcg())
- goto err;
+ if (i == -1) {
+ ret = 1;
+ printf("\ncg %d: %s\n", disk.d_lcg, ufserr());
+ } else if (dumpcg())
+ ret = 1;
}
- return (0);
-
-err: ufserr(name);
- return (1);
+ return (ret);
}
static int
@@ -402,17 +392,22 @@ dumpcg(void)
static int
dumpfreespace(const char *name, int fflag)
{
- int i;
+ intmax_t startblkno;
+ int i, ret;
+ ret = 0;
while ((i = cgread(&disk)) != 0) {
- if (i == -1)
- goto err;
- dumpfreespacecg(fflag);
+ if (i != -1) {
+ dumpfreespacecg(fflag);
+ } else {
+ startblkno = disk.d_lcg * afs.fs_fpg;
+ printf("\nBlocks %jd-%jd of cg %d skipped: %s\n",
+ startblkno, startblkno + afs.fs_fpg - 1,
+ disk.d_lcg, ufserr());
+ ret = 1;
+ }
}
- return (0);
-err:
- ufserr(name);
- return (1);
+ return (ret);
}
static void
@@ -521,13 +516,14 @@ pblklist(void *vp, int max, off_t offset, int fflag)
}
}
-static void
-ufserr(const char *name)
+static const char *
+ufserr(void)
{
if (disk.d_error != NULL)
- warnx("%s: %s", name, disk.d_error);
- else if (errno)
- warn("%s", name);
+ return(disk.d_error);
+ if (errno)
+ return (strerror(errno));
+ return ("unknown error");
}
static void
diff --git a/sbin/dumpon/Makefile b/sbin/dumpon/Makefile
index d0700ab16a89..346951f12b3c 100644
--- a/sbin/dumpon/Makefile
+++ b/sbin/dumpon/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
@@ -8,6 +7,7 @@ PROG= dumpon
.if ${MK_OPENSSL} != "no"
LIBADD= crypto
CFLAGS+=-DHAVE_CRYPTO
+CFLAGS+=-DOPENSSL_API_COMPAT=0x10100000L
.endif
MAN= dumpon.8
diff --git a/sbin/dumpon/Makefile.depend b/sbin/dumpon/Makefile.depend
index 9a1f7bd0d413..72007d65f40b 100644
--- a/sbin/dumpon/Makefile.depend
+++ b/sbin/dumpon/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
@@ -10,7 +9,6 @@ DIRDEPS = \
lib/libcapsicum \
lib/libcasper/libcasper \
lib/libcompiler_rt \
- lib/libthr \
.include <dirdeps.mk>
diff --git a/sbin/dumpon/Makefile.depend.options b/sbin/dumpon/Makefile.depend.options
index fa96b2506b2c..b374d7a1fd52 100644
--- a/sbin/dumpon/Makefile.depend.options
+++ b/sbin/dumpon/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= OPENSSL
diff --git a/sbin/dumpon/dumpon.8 b/sbin/dumpon/dumpon.8
index de9bd648e68b..a57dfef7096d 100644
--- a/sbin/dumpon/dumpon.8
+++ b/sbin/dumpon/dumpon.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93
-.\" $FreeBSD$
-.\"
.Dd April 23, 2020
.Dt DUMPON 8
.Os
@@ -312,7 +309,7 @@ or shorter:
The
.Pa vmcore.#
can be now examined using
-.Xr kgdb 1 :
+.Xr kgdb 1 Pq Pa ports/devel/gdb :
.Pp
.Dl # kgdb /boot/kernel/kernel vmcore.#
.Pp
@@ -321,7 +318,7 @@ or shorter:
.Dl # kgdb -n #
.Pp
The core was decrypted properly if
-.Xr kgdb 1
+.Xr kgdb 1 Pq Pa ports/devel/gdb
does not print any errors.
Note that the live kernel might be at a different path
which can be examined by looking at the
@@ -368,7 +365,7 @@ Be sure to fill in the server IP address and change the interface name if
needed.
.Sh SEE ALSO
.Xr gzip 1 ,
-.Xr kgdb 1 ,
+.Xr kgdb 1 Pq Pa ports/devel/gdb ,
.Xr zstd 1 ,
.Xr ddb 4 ,
.Xr netdump 4 ,
diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c
index 626350427595..dd772ca75049 100644
--- a/sbin/dumpon/dumpon.c
+++ b/sbin/dumpon/dumpon.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "From: @(#)swapon.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/capsicum.h>
#include <sys/disk.h>
@@ -270,7 +256,8 @@ _genkey(const char *pubkeyfile, struct diocskerneldump_arg *kdap)
fclose(fp);
fp = NULL;
if (pubkey == NULL)
- errx(1, "Unable to read data from %s.", pubkeyfile);
+ errx(1, "Unable to read data from %s: %s", pubkeyfile,
+ ERR_error_string(ERR_get_error(), NULL));
/*
* RSA keys under ~1024 bits are trivially factorable (2018). OpenSSL
@@ -565,7 +552,12 @@ main(int argc, char *argv[])
if (cipher != KERNELDUMP_ENC_NONE && pubkeyfile == NULL) {
errx(EX_USAGE, "-C option requires a public key file.");
} else if (pubkeyfile != NULL) {
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
ERR_load_crypto_strings();
+#else
+ if (!OPENSSL_init_crypto(0, NULL))
+ errx(EX_UNAVAILABLE, "Unable to initialize OpenSSL");
+#endif
}
#else
if (pubkeyfile != NULL)
diff --git a/sbin/etherswitchcfg/Makefile b/sbin/etherswitchcfg/Makefile
index 6ef9f5f8a2a0..6312f07b09d3 100644
--- a/sbin/etherswitchcfg/Makefile
+++ b/sbin/etherswitchcfg/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 5.4 (Berkeley) 6/5/91
-# $FreeBSD$
PACKAGE=runtime
PROG= etherswitchcfg
diff --git a/sbin/etherswitchcfg/Makefile.depend b/sbin/etherswitchcfg/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/sbin/etherswitchcfg/Makefile.depend
+++ b/sbin/etherswitchcfg/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/etherswitchcfg/etherswitchcfg.8 b/sbin/etherswitchcfg/etherswitchcfg.8
index 9380c1f4f055..f903975bd356 100644
--- a/sbin/etherswitchcfg/etherswitchcfg.8
+++ b/sbin/etherswitchcfg/etherswitchcfg.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 23, 2021
.Dt ETHERSWITCHCFG 8
.Os
diff --git a/sbin/etherswitchcfg/etherswitchcfg.c b/sbin/etherswitchcfg/etherswitchcfg.c
index 7f3403918fad..f47dff1f0de2 100644
--- a/sbin/etherswitchcfg/etherswitchcfg.c
+++ b/sbin/etherswitchcfg/etherswitchcfg.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011-2012 Stefan Bethke.
* All rights reserved.
@@ -24,13 +24,9 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <err.h>
#include <errno.h>
diff --git a/sbin/etherswitchcfg/ifmedia.c b/sbin/etherswitchcfg/ifmedia.c
index 03ed4e56ab79..a54857ee2437 100644
--- a/sbin/etherswitchcfg/ifmedia.c
+++ b/sbin/etherswitchcfg/ifmedia.c
@@ -1,5 +1,4 @@
/* $NetBSD: ifconfig.c,v 1.34 1997/04/21 01:17:58 lukem Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
diff --git a/sbin/fdisk/Makefile b/sbin/fdisk/Makefile
index eaed0aea04aa..322dfa33043c 100644
--- a/sbin/fdisk/Makefile
+++ b/sbin/fdisk/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE=runtime
PROG= fdisk
diff --git a/sbin/fdisk/Makefile.depend b/sbin/fdisk/Makefile.depend
index 0220673c9076..0dd05cace3c0 100644
--- a/sbin/fdisk/Makefile.depend
+++ b/sbin/fdisk/Makefile.depend
@@ -1,16 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libexpat \
lib/libgeom \
- lib/libsbuf \
.include <dirdeps.mk>
diff --git a/sbin/fdisk/fdisk.8 b/sbin/fdisk/fdisk.8
index 87862ec4949f..3c6a73318271 100644
--- a/sbin/fdisk/fdisk.8
+++ b/sbin/fdisk/fdisk.8
@@ -1,4 +1,3 @@
-.\" $FreeBSD$
.\"
.Dd October 5, 2016
.Dt FDISK 8
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index a9afd50ed441..6cfa2b510f22 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -25,8 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/diskmbr.h>
@@ -258,7 +256,7 @@ static int decimal(const char *str, int *num, int deflt, uint32_t maxval);
static int read_config(char *config_file);
static void reset_boot(void);
static int sanitize_partition(struct dos_partition *);
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char *argv[])
@@ -449,7 +447,7 @@ main(int argc, char *argv[])
}
static void
-usage()
+usage(void)
{
fprintf(stderr, "%s%s",
"usage: fdisk [-BIaipqstu] [-b bootcode] [-1234] [disk]\n",
@@ -610,7 +608,7 @@ change_part(int i)
}
static void
-print_params()
+print_params(void)
{
printf("parameters extracted from in-core disklabel are:\n");
printf("cylinders=%d heads=%d sectors/track=%d (%d blks/cyl)\n\n"
@@ -661,14 +659,14 @@ setactive:
}
static void
-change_code()
+change_code(void)
{
if (ok("Do you want to change the boot code?"))
init_boot();
}
void
-get_params_to_use()
+get_params_to_use(void)
{
int tmp;
print_params();
@@ -807,7 +805,7 @@ write_disk(off_t sector, void *buf)
}
static int
-get_params()
+get_params(void)
{
int error;
u_int u;
@@ -845,7 +843,7 @@ get_params()
}
static int
-read_s0()
+read_s0(void)
{
int i;
@@ -874,7 +872,7 @@ read_s0()
}
static int
-write_s0()
+write_s0(void)
{
int sector, i;
diff --git a/sbin/fdisk/fdisk_mbr_enc.c b/sbin/fdisk/fdisk_mbr_enc.c
index 1202896276c6..d621124c7a85 100644
--- a/sbin/fdisk/fdisk_mbr_enc.c
+++ b/sbin/fdisk/fdisk_mbr_enc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003 Poul-Henning Kamp
* All rights reserved.
@@ -33,9 +33,6 @@
* NB! This file must be usable both in kernel and userland.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/diskmbr.h>
#include <sys/endian.h>
diff --git a/sbin/fdisk/fdisk_mbr_enc.h b/sbin/fdisk/fdisk_mbr_enc.h
index 5a1a6bf70fce..f7b05b0ea1cc 100644
--- a/sbin/fdisk/fdisk_mbr_enc.h
+++ b/sbin/fdisk/fdisk_mbr_enc.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Conrad Meyer <cem@FreeBSD.org>
*
@@ -23,8 +23,6 @@
* 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$
*/
#pragma once
diff --git a/sbin/fdisk/runtest.sh b/sbin/fdisk/runtest.sh
index f25f4272bb0f..b89a59d18cd6 100644
--- a/sbin/fdisk/runtest.sh
+++ b/sbin/fdisk/runtest.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
set -e
MD=`mdconfig -a -t malloc -s 4m -x 63 -y 16`
diff --git a/sbin/ffsinfo/Makefile b/sbin/ffsinfo/Makefile
index 19aa71ab89c4..cc03ac9d08ca 100644
--- a/sbin/ffsinfo/Makefile
+++ b/sbin/ffsinfo/Makefile
@@ -1,13 +1,10 @@
-# @(#)Makefile 8.8 (Berkeley) 6/21/2000
-#
# $TSHeader: src/sbin/ffsinfo/Makefile,v 1.3 2000/12/05 19:45:10 tomsoft Exp $
-# $FreeBSD$
#
GROWFS= ${.CURDIR:H}/growfs
.PATH: ${GROWFS}
-PACKAGE=runtime
+PACKAGE=ufs
PROG= ffsinfo
SRCS= ffsinfo.c debug.c
MAN= ffsinfo.8
diff --git a/sbin/ffsinfo/Makefile.depend b/sbin/ffsinfo/Makefile.depend
index 735bf03b75b6..910688a678fa 100644
--- a/sbin/ffsinfo/Makefile.depend
+++ b/sbin/ffsinfo/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/ffsinfo/ffsinfo.8 b/sbin/ffsinfo/ffsinfo.8
index 90580f5767d5..4d76acd0ba0a 100644
--- a/sbin/ffsinfo/ffsinfo.8
+++ b/sbin/ffsinfo/ffsinfo.8
@@ -35,7 +35,6 @@
.\" SUCH DAMAGE.
.\"
.\" $TSHeader: src/sbin/ffsinfo/ffsinfo.8,v 1.3 2000/12/12 19:30:55 tomsoft Exp $
-.\" $FreeBSD$
.\"
.Dd September 8, 2000
.Dt FFSINFO 8
diff --git a/sbin/ffsinfo/ffsinfo.c b/sbin/ffsinfo/ffsinfo.c
index 33ec5f175cbd..f2b25e582bda 100644
--- a/sbin/ffsinfo/ffsinfo.c
+++ b/sbin/ffsinfo/ffsinfo.c
@@ -41,18 +41,6 @@
*
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz\n\
-Copyright (c) 1980, 1989, 1993 The Regents of the University of California.\n\
-All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
/* ********************************************************** INCLUDES ***** */
#include <sys/param.h>
#include <sys/disklabel.h>
@@ -223,8 +211,9 @@ main(int argc, char **argv)
device = special;
}
- if (ufs_disk_fillout(&disk, device) == -1)
- err(1, "ufs_disk_fillout(%s) failed: %s", device, disk.d_error);
+ if (ufs_disk_fillout_blank(&disk, device) == -1 ||
+ sbfind(&disk, 0) == -1)
+ err(1, "superblock fetch(%s) failed: %s", device, disk.d_error);
DBG_OPEN(out_file); /* already here we need a superblock */
diff --git a/sbin/fsck/Makefile b/sbin/fsck/Makefile
index 8d3dd214857e..3273ea730dc8 100644
--- a/sbin/fsck/Makefile
+++ b/sbin/fsck/Makefile
@@ -1,9 +1,12 @@
# $NetBSD: Makefile,v 1.14 1996/09/27 22:38:37 christos Exp $
-# $FreeBSD$
PACKAGE=runtime
PROG= fsck
SRCS= fsck.c fsutil.c preen.c
+SRCS+= getmntopts.c
MAN= fsck.8
+MOUNT= ${SRCTOP}/sbin/mount
+CFLAGS+= -I${MOUNT}
+.PATH: ${MOUNT}
.include <bsd.prog.mk>
diff --git a/sbin/fsck/Makefile.depend b/sbin/fsck/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/sbin/fsck/Makefile.depend
+++ b/sbin/fsck/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/fsck/fsck.8 b/sbin/fsck/fsck.8
index 5ec0c02bbbfd..271ac2843cd3 100644
--- a/sbin/fsck/fsck.8
+++ b/sbin/fsck/fsck.8
@@ -27,8 +27,6 @@
.\" (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 March 5, 2019
.Dt FSCK 8
.Os
diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c
index bb053fe56253..4c24cc9813e1 100644
--- a/sbin/fsck/fsck.c
+++ b/sbin/fsck/fsck.c
@@ -30,15 +30,10 @@
* 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.
- *
- * From: @(#)mount.c 8.19 (Berkeley) 4/19/94
* From: $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp
* $NetBSD: fsck.c,v 1.30 2003/08/07 10:04:15 agc Exp $
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/queue.h>
@@ -50,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <fstab.h>
#include <fcntl.h>
+#include <mntopts.h>
#include <paths.h>
#include <signal.h>
#include <stdio.h>
@@ -206,7 +202,7 @@ main(int argc, char *argv[])
_PATH_DEV, spec);
spec = device;
}
- mntp = getmntpt(spec);
+ mntp = getmntpoint(spec);
if (mntp != NULL) {
spec = mntp->f_mntfromname;
mntpt = mntp->f_mntonname;
@@ -269,7 +265,7 @@ isok(struct fstab *fs)
if (flags & DO_BACKGRD) {
if (!strcmp(fs->fs_type, FSTAB_RO))
return (0);
- if (getmntpt(fs->fs_spec) == NULL)
+ if (getmntpoint(fs->fs_spec) == NULL)
return (0);
if (checkfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, "-F", 0))
return (0);
diff --git a/sbin/fsck/fsutil.c b/sbin/fsck/fsutil.c
index 9644697e2530..9b011e0ed18e 100644
--- a/sbin/fsck/fsutil.c
+++ b/sbin/fsck/fsutil.c
@@ -35,8 +35,6 @@
#ifndef lint
__RCSID("$NetBSD: fsutil.c,v 1.15 2006/06/05 16:52:05 christos Exp $");
#endif /* not lint */
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/mount.h>
@@ -188,50 +186,6 @@ devcheck(const char *origname)
return (origname);
}
-/*
- * Get the mount point information for name.
- */
-struct statfs *
-getmntpt(const char *name)
-{
- struct stat devstat, mntdevstat;
- char device[sizeof(_PATH_DEV) - 1 + MNAMELEN];
- char *dev_name;
- struct statfs *mntbuf, *statfsp;
- int i, mntsize, isdev;
-
- if (stat(name, &devstat) != 0)
- return (NULL);
- if (S_ISCHR(devstat.st_mode) || S_ISBLK(devstat.st_mode))
- isdev = 1;
- else
- isdev = 0;
- mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
- for (i = 0; i < mntsize; i++) {
- statfsp = &mntbuf[i];
- dev_name = statfsp->f_mntfromname;
- if (*dev_name != '/') {
- if (strlen(_PATH_DEV) + strlen(dev_name) + 1 >
- sizeof(statfsp->f_mntfromname))
- continue;
- strcpy(device, _PATH_DEV);
- strcat(device, dev_name);
- strcpy(statfsp->f_mntfromname, device);
- }
- if (isdev == 0) {
- if (strcmp(name, statfsp->f_mntonname))
- continue;
- return (statfsp);
- }
- if (stat(dev_name, &mntdevstat) == 0 &&
- mntdevstat.st_rdev == devstat.st_rdev)
- return (statfsp);
- }
- statfsp = NULL;
- return (statfsp);
-}
-
-
void *
emalloc(size_t s)
{
diff --git a/sbin/fsck/fsutil.h b/sbin/fsck/fsutil.h
index e65f5ddecb01..8d35d09678e2 100644
--- a/sbin/fsck/fsutil.h
+++ b/sbin/fsck/fsutil.h
@@ -24,8 +24,6 @@
* 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$
*/
struct fstab;
@@ -39,7 +37,6 @@ void panic(const char *, ...) __dead2 __printflike(1, 2);
const char *devcheck(const char *);
const char *cdevname(void);
void setcdevname(const char *, int);
-struct statfs *getmntpt(const char *);
void *emalloc(size_t);
void *erealloc(void *, size_t);
char *estrdup(const char *);
diff --git a/sbin/fsck/preen.c b/sbin/fsck/preen.c
index c8a36a608695..574826f4d8f0 100644
--- a/sbin/fsck/preen.c
+++ b/sbin/fsck/preen.c
@@ -29,18 +29,9 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#include <sys/cdefs.h>
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)preen.c 8.5 (Berkeley) 4/28/95";
-#else
-__RCSID("$NetBSD: preen.c,v 1.18 1998/07/26 20:02:36 mycroft Exp $");
-#endif
-#endif /* not lint */
+/* $NetBSD: preen.c,v 1.18 1998/07/26 20:02:36 mycroft Exp $ */
#include <sys/param.h>
#include <sys/stat.h>
diff --git a/sbin/fsck_ffs/Makefile b/sbin/fsck_ffs/Makefile
index ba8a39a87e1f..59805dbbf3d6 100644
--- a/sbin/fsck_ffs/Makefile
+++ b/sbin/fsck_ffs/Makefile
@@ -1,7 +1,5 @@
-# $FreeBSD$
-# @(#)Makefile 8.2 (Berkeley) 4/27/95
-PACKAGE=runtime
+PACKAGE=ufs
PROG= fsck_ffs
LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_ufs
LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_4.2bsd
diff --git a/sbin/fsck_ffs/Makefile.depend b/sbin/fsck_ffs/Makefile.depend
index 735bf03b75b6..910688a678fa 100644
--- a/sbin/fsck_ffs/Makefile.depend
+++ b/sbin/fsck_ffs/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c
index 42ecf4112253..cc63aadae04c 100644
--- a/sbin/fsck_ffs/dir.c
+++ b/sbin/fsck_ffs/dir.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)dir.c 8.8 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -63,7 +55,6 @@ static struct dirtemplate dirhead = {
static int chgino(struct inodesc *);
static int dircheck(struct inodesc *, struct bufarea *, struct direct *);
static int expanddir(struct inode *ip, char *name);
-static void freedir(ino_t ino, ino_t parent);
static struct direct *fsck_readdir(struct inodesc *);
static struct bufarea *getdirblk(ufs2_daddr_t blkno, long size);
static int lftempname(char *bufp, ino_t ino);
@@ -89,6 +80,7 @@ propagate(void)
if (inoinfo(inp->i_parent)->ino_state == DFOUND &&
INO_IS_DUNFOUND(inp->i_number)) {
inoinfo(inp->i_number)->ino_state = DFOUND;
+ check_dirdepth(inp);
change++;
}
}
@@ -96,6 +88,105 @@ propagate(void)
}
/*
+ * Check that the recorded depth of the directory is correct.
+ */
+void
+check_dirdepth(struct inoinfo *inp)
+{
+ struct inoinfo *parentinp;
+ struct inode ip;
+ union dinode *dp;
+ int saveresolved;
+ size_t size;
+ static int updateasked, dirdepthupdate;
+
+ if ((parentinp = getinoinfo(inp->i_parent)) == NULL) {
+ pfatal("check_dirdepth: UNKNOWN PARENT DIR");
+ return;
+ }
+ /*
+ * If depth is correct, nothing to do.
+ */
+ if (parentinp->i_depth + 1 == inp->i_depth)
+ return;
+ /*
+ * Only the root inode should have depth of 0, so if any other
+ * directory has a depth of 0 then this is an old filesystem
+ * that has not been tracking directory depth. Ask just once
+ * whether it should start tracking directory depth.
+ */
+ if (inp->i_depth == 0 && updateasked == 0) {
+ updateasked = 1;
+ if (preen) {
+ pwarn("UPDATING FILESYSTEM TO TRACK DIRECTORY DEPTH\n");
+ dirdepthupdate = 1;
+ } else {
+ /*
+ * The file system can be marked clean even if
+ * a directory does not have the right depth.
+ * Hence, resolved should not be cleared when
+ * the filesystem does not update directory depths.
+ */
+ saveresolved = resolved;
+ dirdepthupdate =
+ reply("UPDATE FILESYSTEM TO TRACK DIRECTORY DEPTH");
+ resolved = saveresolved;
+ }
+ }
+ /*
+ * If we are not converting or we are running in no-write mode
+ * there is nothing more to do.
+ */
+ if ((inp->i_depth == 0 && dirdepthupdate == 0) ||
+ (fswritefd < 0 && bkgrdflag == 0))
+ return;
+ /*
+ * Individual directory at wrong depth. Report it and correct if
+ * in preen mode or ask if in interactive mode. Note that if a
+ * directory is renamed to a new location that is at a different
+ * level in the tree, its depth will be recalculated, but none of
+ * the directories that it contains will be updated. Thus it is
+ * not unexpected to find directories with incorrect depths. No
+ * operational harm will come from this though new directory
+ * placement in the subtree may not be as optimal until the depths
+ * of the affected directories are corrected.
+ *
+ * To avoid much spurious output on otherwise clean filesystems
+ * we only generate detailed output when the debug flag is given.
+ */
+ ginode(inp->i_number, &ip);
+ dp = ip.i_dp;
+ if (inp->i_depth != 0 && debug) {
+ pwarn("DIRECTORY");
+ prtinode(&ip);
+ printf(" DEPTH %d SHOULD BE %d", inp->i_depth,
+ parentinp->i_depth + 1);
+ if (preen == 0 && reply("ADJUST") == 0) {
+ irelse(&ip);
+ return;
+ }
+ if (preen)
+ printf(" (ADJUSTED)\n");
+ }
+ inp->i_depth = parentinp->i_depth + 1;
+ if (bkgrdflag == 0) {
+ DIP_SET(dp, di_dirdepth, inp->i_depth);
+ inodirty(&ip);
+ } else {
+ cmd.value = inp->i_number;
+ cmd.size = (int64_t)inp->i_depth - DIP(dp, di_dirdepth);
+ if (debug)
+ printf("adjdepth ino %ld amt %jd\n", (long)cmd.value,
+ (intmax_t)cmd.size);
+ size = MIBSIZE;
+ if (sysctlnametomib("vfs.ffs.adjdepth", adjdepth, &size) < 0 ||
+ sysctl(adjdepth, MIBSIZE, 0, 0, &cmd, sizeof cmd) == -1)
+ rwerror("ADJUST INODE DEPTH", cmd.value);
+ }
+ irelse(&ip);
+}
+
+/*
* Scan each entry in a directory block.
*/
int
@@ -338,7 +429,7 @@ fileerror(ino_t cwd, ino_t ino, const char *errmesg)
char pathbuf[MAXPATHLEN + 1];
pwarn("%s ", errmesg);
- if (ino < UFS_ROOTINO || ino > maxino) {
+ if (ino < UFS_ROOTINO || ino >= maxino) {
pfatal("out-of-range inode number %ju", (uintmax_t)ino);
return;
}
@@ -422,7 +513,8 @@ adjust(struct inodesc *idesc, int lcnt)
(long long)cmd.size);
if (sysctl(adjrefcnt, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
- rwerror("ADJUST INODE", cmd.value);
+ rwerror("ADJUST INODE LINK COUNT",
+ cmd.value);
}
}
}
@@ -472,8 +564,9 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
{
struct inode ip;
union dinode *dp;
- int lostdir;
+ int lostdir, depth;
ino_t oldlfdir;
+ struct inoinfo *inp;
struct inodesc idesc;
char tempname[BUFSIZ];
@@ -516,7 +609,7 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
if (preen)
printf(" (CREATED)\n");
} else {
- freedir(lfdir, UFS_ROOTINO);
+ freedirino(lfdir, UFS_ROOTINO);
lfdir = 0;
if (preen)
printf("\n");
@@ -525,6 +618,7 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
}
}
irelse(&ip);
+ free(idesc.id_name);
if (lfdir == 0) {
pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY");
printf("\n\n");
@@ -545,7 +639,7 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
irelse(&ip);
return (0);
}
- if ((changeino(UFS_ROOTINO, lfname, lfdir) & ALTERED) == 0) {
+ if ((changeino(UFS_ROOTINO, lfname, lfdir, 1) & ALTERED) == 0) {
pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n");
irelse(&ip);
return (0);
@@ -574,23 +668,27 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
}
inoinfo(orphan)->ino_linkcnt--;
if (lostdir) {
- if ((changeino(orphan, "..", lfdir) & ALTERED) == 0 &&
+ depth = DIP(dp, di_dirdepth) + 1;
+ if ((changeino(orphan, "..", lfdir, depth) & ALTERED) == 0 &&
parentdir != (ino_t)-1)
(void)makeentry(orphan, lfdir, "..");
DIP_SET(dp, di_nlink, DIP(dp, di_nlink) + 1);
inodirty(&ip);
inoinfo(lfdir)->ino_linkcnt++;
pwarn("DIR I=%lu CONNECTED. ", (u_long)orphan);
- if (parentdir != (ino_t)-1) {
+ inp = getinoinfo(parentdir);
+ if (parentdir != (ino_t)-1 && inp != NULL) {
printf("PARENT WAS I=%lu\n", (u_long)parentdir);
/*
- * The parent directory, because of the ordering
+ * If the parent directory did not have to
+ * be replaced then because of the ordering
* guarantees, has had the link count incremented
* for the child, but no entry was made. This
* fixes the parent link count so that fsck does
* not need to be rerun.
*/
- inoinfo(parentdir)->ino_linkcnt++;
+ if ((inp->i_flags & INFO_NEW) != 0)
+ inoinfo(parentdir)->ino_linkcnt++;
}
if (preen == 0)
printf("\n");
@@ -603,7 +701,7 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
* fix an entry in a directory.
*/
int
-changeino(ino_t dir, const char *name, ino_t newnum)
+changeino(ino_t dir, const char *name, ino_t newnum, int depth)
{
struct inodesc idesc;
struct inode ip;
@@ -617,7 +715,12 @@ changeino(ino_t dir, const char *name, ino_t newnum)
idesc.id_name = strdup(name);
idesc.id_parent = newnum; /* new value for name */
ginode(dir, &ip);
- error = ckinode(ip.i_dp, &idesc);
+ if (((error = ckinode(ip.i_dp, &idesc)) & ALTERED) && newnum != 0) {
+ DIP_SET(ip.i_dp, di_dirdepth, depth);
+ inodirty(&ip);
+ getinoinfo(dir)->i_depth = depth;
+ }
+ free(idesc.id_name);
irelse(&ip);
return (error);
}
@@ -652,15 +755,18 @@ makeentry(ino_t parent, ino_t ino, const char *name)
}
if ((ckinode(dp, &idesc) & ALTERED) != 0) {
irelse(&ip);
+ free(idesc.id_name);
return (1);
}
getpathname(pathbuf, parent, parent);
if (expanddir(&ip, pathbuf) == 0) {
irelse(&ip);
+ free(idesc.id_name);
return (0);
}
retval = ckinode(dp, &idesc) & ALTERED;
irelse(&ip);
+ free(idesc.id_name);
return (retval);
}
@@ -675,14 +781,17 @@ expanddir(struct inode *ip, char *name)
struct bufarea *bp, *nbp;
struct inodesc idesc;
union dinode *dp;
- int indiralloced;
+ long cg, indiralloced;
char *cp;
nbp = NULL;
indiralloced = newblk = indirblk = 0;
+ memset(&idesc, 0, sizeof(struct inodesc));
+ idesc.id_type = ADDR;
pwarn("NO SPACE LEFT IN %s", name);
if (!preen && reply("EXPAND") == 0)
return (0);
+ cg = ino_to_cg(&sblock, ip->i_number);
dp = ip->i_dp;
filesize = DIP(dp, di_size);
lastlbn = lblkno(&sblock, filesize);
@@ -701,7 +810,8 @@ expanddir(struct inode *ip, char *name)
bp = getdirblk(oldblk, lastlbnsize);
if (bp->b_errs)
goto bad;
- if ((newblk = allocblk(sblock.fs_frag)) == 0)
+ newblk = allocblk(cg, sblock.fs_frag, std_checkblkavail);
+ if (newblk == 0)
goto bad;
nbp = getdatablk(newblk, sblock.fs_bsize, BT_DIRDATA);
if (nbp->b_errs)
@@ -720,6 +830,7 @@ expanddir(struct inode *ip, char *name)
memmove(cp, &emptydir, sizeof emptydir);
dirty(nbp);
brelse(nbp);
+ binval(bp);
idesc.id_blkno = oldblk;
idesc.id_numfrags = numfrags(&sblock, lastlbnsize);
(void)freeblock(&idesc);
@@ -727,7 +838,7 @@ expanddir(struct inode *ip, char *name)
printf(" (EXPANDED)\n");
return (1);
}
- if ((newblk = allocblk(sblock.fs_frag)) == 0)
+ if ((newblk = allocblk(cg, sblock.fs_frag, std_checkblkavail)) == 0)
goto bad;
bp = getdirblk(newblk, sblock.fs_bsize);
if (bp->b_errs)
@@ -745,8 +856,12 @@ expanddir(struct inode *ip, char *name)
* Allocate indirect block if needed.
*/
if ((indirblk = DIP(dp, di_ib[0])) == 0) {
- if ((indirblk = allocblk(sblock.fs_frag)) == 0)
+ indirblk = allocblk(cg, sblock.fs_frag,
+ std_checkblkavail);
+ if (indirblk == 0) {
+ binval(bp);
goto bad;
+ }
indiralloced = 1;
}
nbp = getdatablk(indirblk, sblock.fs_bsize, BT_LEVEL1);
@@ -757,6 +872,7 @@ expanddir(struct inode *ip, char *name)
DIP_SET(dp, di_ib[0], indirblk);
DIP_SET(dp, di_blocks,
DIP(dp, di_blocks) + btodb(sblock.fs_bsize));
+ inodirty(ip);
}
IBLK_SET(nbp, lastlbn - UFS_NDADDR, newblk);
dirty(nbp);
@@ -770,8 +886,10 @@ expanddir(struct inode *ip, char *name)
return (1);
bad:
pfatal(" (EXPANSION FAILED)\n");
- if (nbp != NULL)
+ if (nbp != NULL) {
+ binval(bp);
brelse(nbp);
+ }
if (newblk != 0) {
idesc.id_blkno = newblk;
idesc.id_numfrags = sblock.fs_frag;
@@ -796,8 +914,8 @@ allocdir(ino_t parent, ino_t request, int mode)
struct inode ip;
union dinode *dp;
struct bufarea *bp;
- struct inoinfo *inp;
struct dirtemplate *dirp;
+ struct inoinfo *inp, *parentinp;
ino = allocino(request, IFDIR|mode);
if (ino == 0)
@@ -822,8 +940,12 @@ allocdir(ino_t parent, ino_t request, int mode)
DIP_SET(dp, di_nlink, 2);
inodirty(&ip);
if (ino == UFS_ROOTINO) {
+ inp = cacheino(dp, ino);
+ inp->i_parent = parent;
+ inp->i_dotdot = parent;
+ inp->i_flags |= INFO_NEW;
+ inoinfo(ino)->ino_type = DT_DIR;
inoinfo(ino)->ino_linkcnt = DIP(dp, di_nlink);
- cacheino(dp, ino);
irelse(&ip);
return(ino);
}
@@ -832,10 +954,18 @@ allocdir(ino_t parent, ino_t request, int mode)
irelse(&ip);
return (0);
}
- cacheino(dp, ino);
- inp = getinoinfo(ino);
+ inp = cacheino(dp, ino);
inp->i_parent = parent;
inp->i_dotdot = parent;
+ inp->i_flags |= INFO_NEW;
+ if ((parentinp = getinoinfo(inp->i_parent)) == NULL) {
+ pfatal("allocdir: UNKNOWN PARENT DIR");
+ } else {
+ inp->i_depth = parentinp->i_depth + 1;
+ DIP_SET(dp, di_dirdepth, inp->i_depth);
+ inodirty(&ip);
+ }
+ inoinfo(ino)->ino_type = DT_DIR;
inoinfo(ino)->ino_state = inoinfo(parent)->ino_state;
if (inoinfo(ino)->ino_state == DSTATE) {
inoinfo(ino)->ino_linkcnt = DIP(dp, di_nlink);
@@ -853,8 +983,8 @@ allocdir(ino_t parent, ino_t request, int mode)
/*
* free a directory inode
*/
-static void
-freedir(ino_t ino, ino_t parent)
+void
+freedirino(ino_t ino, ino_t parent)
{
struct inode ip;
union dinode *dp;
@@ -866,6 +996,7 @@ freedir(ino_t ino, ino_t parent)
inodirty(&ip);
irelse(&ip);
}
+ removecachedino(ino);
freeino(ino);
}
diff --git a/sbin/fsck_ffs/ea.c b/sbin/fsck_ffs/ea.c
index 54353005bdc0..f6ebc5c072fc 100644
--- a/sbin/fsck_ffs/ea.c
+++ b/sbin/fsck_ffs/ea.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-3-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 2002 Poul-Henning Kamp
* Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -35,9 +35,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
#include <sys/stdint.h>
@@ -61,10 +58,9 @@ eascan(struct inodesc *idesc, struct ufs2_dinode *dp)
return (0);
#else
struct bufarea *bp;
- u_int dsize, n;
+ u_int n;
u_char *cp;
long blksiz;
- char dbuf[DIRBLKSIZ];
printf("Inode %ju extsize %ju\n",
(intmax_t)idesc->id_number, (uintmax_t)dp->di_extsize);
@@ -74,8 +70,10 @@ eascan(struct inodesc *idesc, struct ufs2_dinode *dp)
blksiz = sblock.fs_fsize;
else
blksiz = sblock.fs_bsize;
- printf("blksiz = %ju\n", (intmax_t)blksiz);
bp = getdatablk(dp->di_extb[0], blksiz, BT_EXTATTR);
+ if (bp->b_errs)
+ return (STOP);
+ printf("blksiz = %ju\n", (intmax_t)blksiz);
cp = (u_char *)bp->b_un.b_buf;
for (n = 0; n < blksiz; n++) {
printf("%02x", cp[n]);
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
index 1fb0df0c5124..312142eab9a7 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-3-Clause and BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-3-Clause and BSD-2-Clause
*
* Copyright (c) 2002 Networks Associates Technology, Inc.
* All rights reserved.
@@ -57,9 +57,6 @@
* 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.
- *
- * @(#)fsck.h 8.4 (Berkeley) 5/9/95
- * $FreeBSD$
*/
#ifndef _FSCK_H_
@@ -68,6 +65,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
+#include <libufs.h>
#include <sys/queue.h>
@@ -112,7 +110,7 @@ struct inostat {
#define FSTATE 0x2 /* inode is file */
#define FZLINK 0x3 /* inode is file with a link count of zero */
#define DSTATE 0x4 /* inode is directory */
-#define DZLINK 0x5 /* inode is directory with a zero link count */
+#define DZLINK 0x5 /* inode is directory with a zero link count */
#define DFOUND 0x6 /* directory found during descent */
/* 0x7 UNUSED - see S_IS_DVALID() definition */
#define DCLEAR 0x8 /* directory is to be cleared */
@@ -200,8 +198,7 @@ struct bufarea {
#define BT_INODES 7 /* Buffer holds inodes */
#define BT_DIRDATA 8 /* Buffer holds directory data */
#define BT_DATA 9 /* Buffer holds user data */
-#define BT_EMPTY 10 /* Buffer allocated but not filled */
-#define BT_NUMBUFTYPES 11
+#define BT_NUMBUFTYPES 10
#define BT_NAMES { \
"unknown", \
"Superblock", \
@@ -212,8 +209,7 @@ struct bufarea {
"External Attribute", \
"Inode Block", \
"Directory Contents", \
- "User Data", \
- "Allocated but not filled" }
+ "User Data" }
extern char *buftype[];
#define BT_BUFTYPE(type) \
type < BT_NUMBUFTYPES ? buftype[type] : buftype[BT_UNKNOWN]
@@ -234,7 +230,7 @@ extern struct bufarea *pdirbp; /* current directory contents */
(bp)->b_flags |= B_DIRTY; \
} while (0)
#define initbarea(bp, type) do { \
- (bp)->b_bno = (ufs2_daddr_t)-1; \
+ (bp)->b_bno = (ufs2_daddr_t)-4; \
(bp)->b_size = 0; \
(bp)->b_errs = 0; \
(bp)->b_flags = 0; \
@@ -299,21 +295,30 @@ struct dups {
struct dups *next;
ufs2_daddr_t dup;
};
-extern struct dups *duplist; /* head of dup list */
-extern struct dups *muldup; /* end of unique duplicate dup block numbers */
+extern struct dups *duplist; /* head of dup list */
+extern struct dups *muldup; /* end of unique duplicate dup block numbers */
/*
* Inode cache data structures.
*/
-extern struct inoinfo {
- struct inoinfo *i_nexthash; /* next entry in hash chain */
+struct inoinfo {
+ SLIST_ENTRY(inoinfo) i_hash; /* hash list */
ino_t i_number; /* inode number of this entry */
ino_t i_parent; /* inode number of parent */
ino_t i_dotdot; /* inode number of `..' */
size_t i_isize; /* size of inode */
+ u_int i_depth; /* depth of directory from root */
+ u_int i_flags; /* flags, see below */
u_int i_numblks; /* size of block array in bytes */
ufs2_daddr_t i_blks[1]; /* actually longer */
-} **inphead, **inpsort;
+};
+extern SLIST_HEAD(inohash, inoinfo) *inphash;
+extern struct inoinfo **inpsort;
+/*
+ * flags for struct inoinfo
+ */
+#define INFO_NEW 0x0000001 /* replaced broken directory */
+
extern long dirhash, inplast;
extern unsigned long numdirs, listmax;
extern long countdirs; /* number of directories we actually found */
@@ -326,6 +331,7 @@ extern int adjnbfree[MIBSIZE]; /* MIB cmd to adjust number of free blocks */
extern int adjnifree[MIBSIZE]; /* MIB cmd to adjust number of free inodes */
extern int adjnffree[MIBSIZE]; /* MIB cmd to adjust number of free frags */
extern int adjnumclusters[MIBSIZE]; /* MIB cmd adjust number of free clusters */
+extern int adjdepth[MIBSIZE]; /* MIB cmd to adjust directory depth count */
extern int freefiles[MIBSIZE]; /* MIB cmd to free a set of files */
extern int freedirs[MIBSIZE]; /* MIB cmd to free a set of directories */
extern int freeblks[MIBSIZE]; /* MIB cmd to free a set of data blocks */
@@ -339,8 +345,10 @@ extern off_t bflag; /* location of alternate super block */
extern int bkgrdflag; /* use a snapshot to run on an active system */
extern char *blockmap; /* ptr to primary blk allocation map */
extern char *cdevname; /* name of device being checked */
+extern int cgheader_corrupt; /* one or more CG headers are corrupt */
extern char ckclean; /* only do work if not cleanly unmounted */
extern int ckhashadd; /* check hashes to be added */
+extern char *copybuf; /* buffer to copy snapshot blocks */
extern int cvtlevel; /* convert to newer file system format */
extern long dev_bsize; /* computed value of DEV_BSIZE */
extern u_int real_dev_bsize; /* actual disk sector size, not overridden */
@@ -363,10 +371,10 @@ extern char preen; /* just fix normal inconsistencies */
extern char rerun; /* rerun fsck. Only used in non-preen mode */
extern char resolved; /* cleared if unresolved changes => not clean */
extern int returntosingle; /* 1 => return to single user mode on exit */
-extern int sbhashfailed; /* when reading superblock check hash failed */
extern long secsize; /* actual disk sector size */
extern char skipclean; /* skip clean file systems if preening */
-extern char snapname[BUFSIZ]; /* when doing snapshots, the name of the file */
+extern int snapcnt; /* number of active snapshots */
+extern struct inode snaplist[FSMAXSNAP + 1]; /* list of active snapshots */
extern int sujrecovery; /* 1 => doing check using the journal */
extern int surrender; /* Give up if reads fail */
extern char usedsoftdep; /* just fix soft dependency inconsistencies */
@@ -415,6 +423,20 @@ Malloc(size_t size)
break;
return (retval);
}
+/*
+ * Allocate a block of memory to be used as an I/O buffer.
+ * Ensure that the buffer is aligned to the I/O subsystem requirements.
+ */
+static inline void*
+Balloc(size_t size)
+{
+ void *retval;
+
+ while ((retval = aligned_alloc(LIBUFS_BUFALIGN, size)) == NULL)
+ if (flushentry() == 0)
+ break;
+ return (retval);
+}
/*
* Wrapper for calloc() that flushes the cylinder group cache to try
@@ -436,9 +458,11 @@ struct fstab;
void adjust(struct inodesc *, int lcnt);
void alarmhandler(int sig);
-ufs2_daddr_t allocblk(long frags);
+ufs2_daddr_t allocblk(long cg, long frags, ufs2_daddr_t (*checkblkavail)
+ (ufs2_daddr_t blkno, long frags));
ino_t allocdir(ino_t parent, ino_t request, int mode);
ino_t allocino(ino_t request, int type);
+void binval(struct bufarea *);
void blkerror(ino_t ino, const char *type, ufs2_daddr_t blk);
char *blockcheck(char *name);
int blread(int fd, char *buf, ufs2_daddr_t blk, long size);
@@ -447,18 +471,24 @@ void blwrite(int fd, char *buf, ufs2_daddr_t blk, ssize_t size);
void blerase(int fd, ufs2_daddr_t blk, long size);
void blzero(int fd, ufs2_daddr_t blk, long size);
void brelse(struct bufarea *);
-void cacheino(union dinode *dp, ino_t inumber);
+struct inoinfo *cacheino(union dinode *dp, ino_t inumber);
void catch(int);
void catchquit(int);
void cgdirty(struct bufarea *);
struct bufarea *cglookup(int cg);
-int changeino(ino_t dir, const char *name, ino_t newnum);
-int check_cgmagic(int cg, struct bufarea *cgbp, int requestrebuild);
+int changeino(ino_t dir, const char *name, ino_t newnum, int depth);
+void check_blkcnt(struct inode *ip);
+int check_cgmagic(int cg, struct bufarea *cgbp);
+void rebuild_cg(int cg, struct bufarea *cgbp);
+void check_dirdepth(struct inoinfo *inp);
+int chkfilesize(mode_t mode, u_int64_t filesize);
int chkrange(ufs2_daddr_t blk, int cnt);
void ckfini(int markclean);
int ckinode(union dinode *dp, struct inodesc *);
void clri(struct inodesc *, const char *type, int flag);
int clearentry(struct inodesc *);
+void copyonwrite(struct fs *, struct bufarea *,
+ ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t, long));
void direrror(ino_t ino, const char *errmesg);
int dirscan(struct inodesc *);
int dofix(struct inodesc *, const char *msg);
@@ -469,16 +499,19 @@ int findino(struct inodesc *);
int findname(struct inodesc *);
void flush(int fd, struct bufarea *bp);
int freeblock(struct inodesc *);
+void freedirino(ino_t ino, ino_t parent);
void freeino(ino_t ino);
void freeinodebuf(void);
+void fsckinit(void);
void fsutilinit(void);
int ftypeok(union dinode *dp);
void getblk(struct bufarea *bp, ufs2_daddr_t blk, long size);
struct bufarea *getdatablk(ufs2_daddr_t blkno, long size, int type);
struct inoinfo *getinoinfo(ino_t inumber);
-union dinode *getnextinode(ino_t inumber, int rebuildcg);
+union dinode *getnextinode(ino_t inumber, int rebuiltcg);
void getpathname(char *namebuf, ino_t curdir, ino_t ino);
void ginode(ino_t, struct inode *);
+void gjournal_check(const char *filesys);
void infohandler(int sig);
void irelse(struct inode *);
ufs2_daddr_t ino_blkatoff(union dinode *, ino_t, ufs_lbn_t, int *,
@@ -500,17 +533,23 @@ void pass4(void);
void pass5(void);
void pfatal(const char *fmt, ...) __printflike(1, 2);
void propagate(void);
+void prtbuf(struct bufarea *, const char *, ...) __printflike(2, 3);
void prtinode(struct inode *);
void pwarn(const char *fmt, ...) __printflike(1, 2);
-int readsb(int listerr);
+int readsb(void);
+int removecachedino(ino_t);
int reply(const char *question);
void rwerror(const char *mesg, ufs2_daddr_t blk);
void sblock_init(void);
void setinodebuf(int, ino_t);
int setup(char *dev);
-void gjournal_check(const char *filesys);
+int snapblkfree(struct fs *, ufs2_daddr_t, long, ino_t,
+ ufs2_daddr_t (*)(ufs2_daddr_t, long));
+void snapremove(ino_t);
+void snapflush(ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t, long));
+ufs2_daddr_t std_checkblkavail(ufs2_daddr_t blkno, long frags);
+ufs2_daddr_t suj_checkblkavail(ufs2_daddr_t, long);
int suj_check(const char *filesys);
void update_maps(struct cg *, struct cg*, int);
-void fsckinit(void);
#endif /* !_FSCK_H_ */
diff --git a/sbin/fsck_ffs/fsck_ffs.8 b/sbin/fsck_ffs/fsck_ffs.8
index 35f3e112007b..1eb9ebeb3b9b 100644
--- a/sbin/fsck_ffs/fsck_ffs.8
+++ b/sbin/fsck_ffs/fsck_ffs.8
@@ -26,10 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fsck.8 8.4 (Berkeley) 5/9/95
-.\" $FreeBSD$
-.\"
-.Dd May 3, 2019
+.Dd November 17, 2023
.Dt FSCK_FFS 8
.Os
.Sh NAME
@@ -426,6 +423,7 @@ are fully enumerated and explained in Appendix A of
.Sh SEE ALSO
.Xr fs 5 ,
.Xr fstab 5 ,
+.Xr ffs 7 ,
.Xr fsck 8 ,
.Xr fsdb 8 ,
.Xr newfs 8 ,
diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index 711c9bb63549..aa536fb5dd4e 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -60,7 +52,6 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
-#include <libufs.h>
#include "fsck.h"
@@ -71,7 +62,6 @@ static void cg_write(struct bufarea *);
static void slowio_start(void);
static void slowio_end(void);
static void printIOstats(void);
-static void prtbuf(const char *, struct bufarea *);
static long diskreads, totaldiskreads, totalreads; /* Disk cache statistics */
static struct timespec startpass, finishpass;
@@ -79,11 +69,13 @@ struct timeval slowio_starttime;
int slowio_delay_usec = 10000; /* Initial IO delay for background fsck */
int slowio_pollcnt;
static struct bufarea cgblk; /* backup buffer for cylinder group blocks */
+static struct bufarea failedbuf; /* returned by failed getdatablk() */
static TAILQ_HEAD(bufqueue, bufarea) bufqueuehd; /* head of buffer cache LRU */
static LIST_HEAD(bufhash, bufarea) bufhashhd[HASHSIZE]; /* buffer hash list */
-static int numbufs; /* size of buffer cache */
-static int cachelookups; /* number of cache lookups */
-static int cachereads; /* number of cache reads */
+static struct bufhash freebufs; /* unused buffers */
+static int numbufs; /* size of buffer cache */
+static int cachelookups; /* number of cache lookups */
+static int cachereads; /* number of cache reads */
static int flushtries; /* number of tries to reclaim memory */
char *buftype[BT_NUMBUFTYPES] = BT_NAMES;
@@ -129,7 +121,8 @@ reply(const char *question)
if (preen)
pfatal("INTERNAL ERROR: GOT TO reply()");
- persevere = !strcmp(question, "CONTINUE");
+ persevere = strcmp(question, "CONTINUE") == 0 ||
+ strcmp(question, "LOOK FOR ALTERNATE SUPERBLOCKS") == 0;
printf("\n");
if (!persevere && (nflag || (fswritefd < 0 && bkgrdflag == 0))) {
printf("%s? no\n\n", question);
@@ -164,11 +157,11 @@ reply(const char *question)
struct inostat *
inoinfo(ino_t inum)
{
- static struct inostat unallocated = { USTATE, 0, 0 };
+ static struct inostat unallocated = { USTATE, 0, 0, 0 };
struct inostatlist *ilp;
int iloff;
- if (inum > maxino)
+ if (inum >= maxino)
errx(EEXIT, "inoinfo: inumber %ju out of range",
(uintmax_t)inum);
ilp = &inostathead[inum / sblock.fs_ipg];
@@ -186,11 +179,15 @@ bufinit(void)
{
int i;
- if ((cgblk.b_un.b_buf = Malloc((unsigned int)sblock.fs_bsize)) == NULL)
+ initbarea(&failedbuf, BT_UNKNOWN);
+ failedbuf.b_errs = -1;
+ failedbuf.b_un.b_buf = NULL;
+ if ((cgblk.b_un.b_buf = Balloc((unsigned int)sblock.fs_bsize)) == NULL)
errx(EEXIT, "Initial malloc(%d) failed", sblock.fs_bsize);
initbarea(&cgblk, BT_CYLGRP);
numbufs = cachelookups = cachereads = 0;
TAILQ_INIT(&bufqueuehd);
+ LIST_INIT(&freebufs);
for (i = 0; i < HASHSIZE; i++)
LIST_INIT(&bufhashhd[i]);
for (i = 0; i < BT_NUMBUFTYPES; i++) {
@@ -207,7 +204,7 @@ allocbuf(const char *failreason)
char *bufp;
bp = (struct bufarea *)Malloc(sizeof(struct bufarea));
- bufp = Malloc((unsigned int)sblock.fs_bsize);
+ bufp = Balloc((unsigned int)sblock.fs_bsize);
if (bp == NULL || bufp == NULL) {
errx(EEXIT, "%s", failreason);
/* NOTREACHED */
@@ -237,7 +234,7 @@ cglookup(int cg)
if ((unsigned) cg >= sblock.fs_ncg)
errx(EEXIT, "cglookup: out of range cylinder group %d", cg);
if (cgbufs == NULL) {
- cgbufs = calloc(sblock.fs_ncg, sizeof(struct bufarea));
+ cgbufs = Calloc(sblock.fs_ncg, sizeof(struct bufarea));
if (cgbufs == NULL)
errx(EEXIT, "Cannot allocate cylinder group buffers");
}
@@ -246,7 +243,7 @@ cglookup(int cg)
return (cgbp);
cgp = NULL;
if (flushtries == 0)
- cgp = Malloc((unsigned int)sblock.fs_cgsize);
+ cgp = Balloc((unsigned int)sblock.fs_cgsize);
if (cgp == NULL) {
if (sujrecovery)
errx(EEXIT,"Ran out of memory during journal recovery");
@@ -299,7 +296,7 @@ flushentry(void)
}
/*
- * Manage a cache of directory blocks.
+ * Manage a cache of filesystem disk blocks.
*/
struct bufarea *
getdatablk(ufs2_daddr_t blkno, long size, int type)
@@ -308,19 +305,25 @@ getdatablk(ufs2_daddr_t blkno, long size, int type)
struct bufhash *bhdp;
cachelookups++;
- /* If out of range, return empty buffer with b_err == -1 */
+ /*
+ * If out of range, return empty buffer with b_err == -1
+ *
+ * Skip check for inodes because chkrange() considers
+ * metadata areas invalid to write data.
+ */
if (type != BT_INODES && chkrange(blkno, size / sblock.fs_fsize)) {
- blkno = -1;
- type = BT_EMPTY;
+ failedbuf.b_refcnt++;
+ return (&failedbuf);
}
bhdp = &bufhashhd[HASH(blkno)];
LIST_FOREACH(bp, bhdp, b_hash)
if (bp->b_bno == fsbtodb(&sblock, blkno)) {
if (debug && bp->b_size != size) {
- prtbuf("getdatablk: size mismatch", bp);
+ prtbuf(bp, "getdatablk: size mismatch");
pfatal("getdatablk: b_size %d != size %ld\n",
bp->b_size, size);
}
+ TAILQ_REMOVE(&bufqueuehd, bp, b_list);
goto foundit;
}
/*
@@ -339,7 +342,9 @@ getdatablk(ufs2_daddr_t blkno, long size, int type)
if (size > sblock.fs_bsize)
errx(EEXIT, "Excessive buffer size %ld > %d\n", size,
sblock.fs_bsize);
- if (numbufs < MINBUFS) {
+ if ((bp = LIST_FIRST(&freebufs)) != NULL) {
+ LIST_REMOVE(bp, b_hash);
+ } else if (numbufs < MINBUFS) {
bp = allocbuf("cannot create minimal buffer pool");
} else if (sujrecovery) {
/*
@@ -367,6 +372,7 @@ getdatablk(ufs2_daddr_t blkno, long size, int type)
else
LIST_REMOVE(bp, b_hash);
}
+ TAILQ_REMOVE(&bufqueuehd, bp, b_list);
flush(fswritefd, bp);
bp->b_type = type;
LIST_INSERT_HEAD(bhdp, bp, b_hash);
@@ -374,13 +380,12 @@ getdatablk(ufs2_daddr_t blkno, long size, int type)
cachereads++;
/* fall through */
foundit:
+ TAILQ_INSERT_HEAD(&bufqueuehd, bp, b_list);
if (debug && bp->b_type != type) {
printf("getdatablk: buffer type changed to %s",
BT_BUFTYPE(type));
- prtbuf("", bp);
+ prtbuf(bp, "");
}
- TAILQ_REMOVE(&bufqueuehd, bp, b_list);
- TAILQ_INSERT_HEAD(&bufqueuehd, bp, b_list);
if (bp->b_errs == 0)
bp->b_refcnt++;
return (bp);
@@ -400,11 +405,7 @@ getblk(struct bufarea *bp, ufs2_daddr_t blk, long size)
readcnt[bp->b_type]++;
clock_gettime(CLOCK_REALTIME_PRECISE, &start);
}
- if (bp->b_type != BT_EMPTY)
- bp->b_errs =
- blread(fsreadfd, bp->b_un.b_buf, dblk, size);
- else
- bp->b_errs = -1;
+ bp->b_errs = blread(fsreadfd, bp->b_un.b_buf, dblk, size);
if (debug) {
clock_gettime(CLOCK_REALTIME_PRECISE, &finish);
timespecsub(&finish, &start, &finish);
@@ -421,11 +422,20 @@ brelse(struct bufarea *bp)
{
if (bp->b_refcnt <= 0)
- prtbuf("brelse: buffer with negative reference count", bp);
+ prtbuf(bp, "brelse: buffer with negative reference count");
bp->b_refcnt--;
}
void
+binval(struct bufarea *bp)
+{
+
+ bp->b_flags &= ~B_DIRTY;
+ LIST_REMOVE(bp, b_hash);
+ LIST_INSERT_HEAD(&freebufs, bp, b_hash);
+}
+
+void
flush(int fd, struct bufarea *bp)
{
struct inode ip;
@@ -450,10 +460,18 @@ flush(int fd, struct bufarea *bp)
if (bp != &sblk)
pfatal("BUFFER %p DOES NOT MATCH SBLK %p\n",
bp, &sblk);
+ /*
+ * Superblocks are always pre-copied so we do not need
+ * to check them for copy-on-write.
+ */
if (sbput(fd, bp->b_un.b_fs, 0) == 0)
fsmodified = 1;
break;
case BT_CYLGRP:
+ /*
+ * Cylinder groups are always pre-copied so we do not
+ * need to check them for copy-on-write.
+ */
if (sujrecovery)
cg_write(bp);
if (cgput(fswritefd, &sblock, bp->b_un.b_cg) == 0)
@@ -464,13 +482,13 @@ flush(int fd, struct bufarea *bp)
struct ufs2_dinode *dp = bp->b_un.b_dinode2;
int i;
- for (i = 0; i < INOPB(&sblock); dp++, i++) {
+ for (i = 0; i < bp->b_size; dp++, i += sizeof(*dp)) {
if (ffs_verify_dinode_ckhash(&sblock, dp) == 0)
continue;
pwarn("flush: INODE CHECK-HASH FAILED");
ip.i_bp = bp;
ip.i_dp = (union dinode *)dp;
- ip.i_number = bp->b_index + i;
+ ip.i_number = bp->b_index + (i / sizeof(*dp));
prtinode(&ip);
if (preen || reply("FIX") != 0) {
if (preen)
@@ -482,12 +500,39 @@ flush(int fd, struct bufarea *bp)
}
/* FALLTHROUGH */
default:
+ copyonwrite(&sblock, bp, std_checkblkavail);
blwrite(fd, bp->b_un.b_buf, bp->b_bno, bp->b_size);
break;
}
}
/*
+ * If there are any snapshots, ensure that all the blocks that they
+ * care about have been copied, then release the snapshot inodes.
+ * These operations need to be done before we rebuild the cylinder
+ * groups so that any block allocations are properly recorded.
+ * Since all the cylinder group maps have already been copied in
+ * the snapshots, no further snapshot copies will need to be done.
+ */
+void
+snapflush(ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t, long))
+{
+ struct bufarea *bp;
+ int cnt;
+
+ if (snapcnt > 0) {
+ if (debug)
+ printf("Check for snapshot copies\n");
+ TAILQ_FOREACH_REVERSE(bp, &bufqueuehd, bufqueue, b_list)
+ if ((bp->b_flags & B_DIRTY) != 0)
+ copyonwrite(&sblock, bp, checkblkavail);
+ for (cnt = 0; cnt < snapcnt; cnt++)
+ irelse(&snaplist[cnt]);
+ snapcnt = 0;
+ }
+}
+
+/*
* Journaled soft updates does not maintain cylinder group summary
* information during cleanup, so this routine recalculates the summary
* information and updates the superblock summary in preparation for
@@ -498,6 +543,7 @@ cg_write(struct bufarea *bp)
{
ufs1_daddr_t fragno, cgbno, maxbno;
u_int8_t *blksfree;
+ struct csum *csp;
struct cg *cgp;
int blk;
int i;
@@ -535,6 +581,11 @@ cg_write(struct bufarea *bp)
* Update the superblock cg summary from our now correct values
* before writing the block.
*/
+ csp = &sblock.fs_cs(&sblock, cgp->cg_cgx);
+ sblock.fs_cstotal.cs_ndir += cgp->cg_cs.cs_ndir - csp->cs_ndir;
+ sblock.fs_cstotal.cs_nbfree += cgp->cg_cs.cs_nbfree - csp->cs_nbfree;
+ sblock.fs_cstotal.cs_nifree += cgp->cg_cs.cs_nifree - csp->cs_nifree;
+ sblock.fs_cstotal.cs_nffree += cgp->cg_cs.cs_nffree - csp->cs_nffree;
sblock.fs_cs(&sblock, cgp->cg_cgx) = cgp->cg_cs;
}
@@ -555,11 +606,9 @@ void
ckfini(int markclean)
{
struct bufarea *bp, *nbp;
- struct inoinfo *inp, *ninp;
- int ofsmodified, cnt, cg, i;
+ int ofsmodified, cnt, cg;
if (bkgrdflag) {
- unlink(snapname);
if ((!(sblock.fs_flags & FS_UNCLEAN)) != markclean) {
cmd.value = FS_UNCLEAN;
cmd.size = markclean ? -1 : 1;
@@ -586,6 +635,7 @@ ckfini(int markclean)
(void)close(fsreadfd);
return;
}
+
/*
* To remain idempotent with partial truncations the buffers
* must be flushed in this order:
@@ -628,14 +678,9 @@ ckfini(int markclean)
case BT_SUPERBLK:
case BT_CYLGRP:
default:
- prtbuf("ckfini: improper buffer type on cache list",bp);
+ prtbuf(bp,"ckfini: improper buffer type on cache list");
continue;
/* These are the ones to flush in this step */
- case BT_EMPTY:
- if (bp->b_bno >= 0)
- pfatal("Unused BT_EMPTY buffer for block %jd\n",
- (intmax_t)bp->b_bno);
- /* FALLTHROUGH */
case BT_LEVEL1:
case BT_LEVEL2:
case BT_LEVEL3:
@@ -647,11 +692,10 @@ ckfini(int markclean)
case BT_INODES:
continue;
}
- if (debug && bp->b_refcnt != 0) {
- prtbuf("ckfini: clearing in-use buffer", bp);
- pfatal("ckfini: clearing in-use buffer\n");
- }
+ if (debug && bp->b_refcnt != 0)
+ prtbuf(bp, "ckfini: clearing in-use buffer");
TAILQ_REMOVE(&bufqueuehd, bp, b_list);
+ LIST_REMOVE(bp, b_hash);
cnt++;
flush(fswritefd, bp);
free(bp->b_un.b_buf);
@@ -665,11 +709,10 @@ ckfini(int markclean)
icachebp = NULL;
}
TAILQ_FOREACH_REVERSE_SAFE(bp, &bufqueuehd, bufqueue, b_list, nbp) {
- if (debug && bp->b_refcnt != 0) {
- prtbuf("ckfini: clearing in-use buffer", bp);
- pfatal("ckfini: clearing in-use buffer\n");
- }
+ if (debug && bp->b_refcnt != 0)
+ prtbuf(bp, "ckfini: clearing in-use buffer");
TAILQ_REMOVE(&bufqueuehd, bp, b_list);
+ LIST_REMOVE(bp, b_hash);
cnt++;
flush(fswritefd, bp);
free(bp->b_un.b_buf);
@@ -681,14 +724,17 @@ ckfini(int markclean)
if (debug)
printf("Flush the superblock\n");
flush(fswritefd, &sblk);
- if (havesb && cursnapshot == 0 && sblock.fs_magic == FS_UFS2_MAGIC &&
- sblk.b_bno != sblock.fs_sblockloc / dev_bsize &&
- !preen && reply("UPDATE STANDARD SUPERBLOCK")) {
- /* Change the write destination to standard superblock */
- sblock.fs_sblockactualloc = sblock.fs_sblockloc;
- sblk.b_bno = sblock.fs_sblockloc / dev_bsize;
- sbdirty();
- flush(fswritefd, &sblk);
+ if (havesb && cursnapshot == 0 &&
+ sblk.b_bno != sblock.fs_sblockloc / dev_bsize) {
+ if (preen || reply("UPDATE STANDARD SUPERBLOCK")) {
+ /* Change write destination to standard superblock */
+ sblock.fs_sblockactualloc = sblock.fs_sblockloc;
+ sblk.b_bno = sblock.fs_sblockloc / dev_bsize;
+ sbdirty();
+ flush(fswritefd, &sblk);
+ } else {
+ markclean = 0;
+ }
}
if (cursnapshot == 0 && sblock.fs_clean != markclean) {
if ((sblock.fs_clean = markclean) != 0) {
@@ -727,19 +773,7 @@ ckfini(int markclean)
free(inostathead);
}
inostathead = NULL;
- if (inpsort != NULL)
- free(inpsort);
- inpsort = NULL;
- if (inphead != NULL) {
- for (i = 0; i < dirhash; i++) {
- for (inp = inphead[i]; inp != NULL; inp = ninp) {
- ninp = inp->i_nexthash;
- free(inp);
- }
- }
- free(inphead);
- }
- inphead = NULL;
+ inocleanup();
finalIOstats();
(void)close(fsreadfd);
(void)close(fswritefd);
@@ -925,7 +959,7 @@ blzero(int fd, ufs2_daddr_t blk, long size)
if (fd < 0)
return;
if (zero == NULL) {
- zero = calloc(ZEROBUFSIZE, 1);
+ zero = Balloc(ZEROBUFSIZE);
if (zero == NULL)
errx(EEXIT, "cannot allocate buffer pool");
}
@@ -944,13 +978,26 @@ blzero(int fd, ufs2_daddr_t blk, long size)
/*
* Verify cylinder group's magic number and other parameters. If the
* test fails, offer an option to rebuild the whole cylinder group.
+ *
+ * Return 1 if the cylinder group is good or return 0 if it is bad.
*/
+#undef CHK
+#define CHK(lhs, op, rhs, fmt) \
+ if (lhs op rhs) { \
+ pwarn("UFS%d cylinder group %d failed: " \
+ "%s (" #fmt ") %s %s (" #fmt ")\n", \
+ sblock.fs_magic == FS_UFS1_MAGIC ? 1 : 2, cg, \
+ #lhs, (intmax_t)lhs, #op, #rhs, (intmax_t)rhs); \
+ error = 1; \
+ }
int
-check_cgmagic(int cg, struct bufarea *cgbp, int request_rebuild)
+check_cgmagic(int cg, struct bufarea *cgbp)
{
struct cg *cgp = cgbp->b_un.b_cg;
uint32_t cghash, calchash;
static int prevfailcg = -1;
+ long start;
+ int error;
/*
* Extended cylinder group checks.
@@ -963,32 +1010,71 @@ check_cgmagic(int cg, struct bufarea *cgbp, int request_rebuild)
calchash = calculate_crc32c(~0L, (void *)cgp, sblock.fs_cgsize);
cgp->cg_ckhash = cghash;
}
- if (cgp->cg_ckhash == calchash &&
- cg_chkmagic(cgp) &&
- cgp->cg_cgx == cg &&
- ((sblock.fs_magic == FS_UFS1_MAGIC &&
- cgp->cg_old_niblk == sblock.fs_ipg &&
- cgp->cg_ndblk <= sblock.fs_fpg &&
- cgp->cg_old_ncyl <= sblock.fs_old_cpg) ||
- (sblock.fs_magic == FS_UFS2_MAGIC &&
- cgp->cg_niblk == sblock.fs_ipg &&
- cgp->cg_ndblk <= sblock.fs_fpg &&
- cgp->cg_initediblk <= sblock.fs_ipg))) {
- return (1);
+ error = 0;
+ CHK(cgp->cg_ckhash, !=, calchash, "%jd");
+ CHK(cg_chkmagic(cgp), ==, 0, "%jd");
+ CHK(cgp->cg_cgx, !=, cg, "%jd");
+ CHK(cgp->cg_ndblk, >, sblock.fs_fpg, "%jd");
+ if (sblock.fs_magic == FS_UFS1_MAGIC) {
+ CHK(cgp->cg_old_niblk, !=, sblock.fs_ipg, "%jd");
+ CHK(cgp->cg_old_ncyl, >, sblock.fs_old_cpg, "%jd");
+ } else if (sblock.fs_magic == FS_UFS2_MAGIC) {
+ CHK(cgp->cg_niblk, !=, sblock.fs_ipg, "%jd");
+ CHK(cgp->cg_initediblk, >, sblock.fs_ipg, "%jd");
+ }
+ if (cgbase(&sblock, cg) + sblock.fs_fpg < sblock.fs_size) {
+ CHK(cgp->cg_ndblk, !=, sblock.fs_fpg, "%jd");
+ } else {
+ CHK(cgp->cg_ndblk, !=, sblock.fs_size - cgbase(&sblock, cg),
+ "%jd");
+ }
+ start = sizeof(*cgp);
+ if (sblock.fs_magic == FS_UFS2_MAGIC) {
+ CHK(cgp->cg_iusedoff, !=, start, "%jd");
+ } else if (sblock.fs_magic == FS_UFS1_MAGIC) {
+ CHK(cgp->cg_niblk, !=, 0, "%jd");
+ CHK(cgp->cg_initediblk, !=, 0, "%jd");
+ CHK(cgp->cg_old_ncyl, !=, sblock.fs_old_cpg, "%jd");
+ CHK(cgp->cg_old_niblk, !=, sblock.fs_ipg, "%jd");
+ CHK(cgp->cg_old_btotoff, !=, start, "%jd");
+ CHK(cgp->cg_old_boff, !=, cgp->cg_old_btotoff +
+ sblock.fs_old_cpg * sizeof(int32_t), "%jd");
+ CHK(cgp->cg_iusedoff, !=, cgp->cg_old_boff +
+ sblock.fs_old_cpg * sizeof(u_int16_t), "%jd");
}
+ CHK(cgp->cg_freeoff, !=,
+ cgp->cg_iusedoff + howmany(sblock.fs_ipg, CHAR_BIT), "%jd");
+ if (sblock.fs_contigsumsize == 0) {
+ CHK(cgp->cg_nextfreeoff, !=,
+ cgp->cg_freeoff + howmany(sblock.fs_fpg, CHAR_BIT), "%jd");
+ } else {
+ CHK(cgp->cg_nclusterblks, !=, cgp->cg_ndblk / sblock.fs_frag,
+ "%jd");
+ CHK(cgp->cg_clustersumoff, !=,
+ roundup(cgp->cg_freeoff + howmany(sblock.fs_fpg, CHAR_BIT),
+ sizeof(u_int32_t)) - sizeof(u_int32_t), "%jd");
+ CHK(cgp->cg_clusteroff, !=, cgp->cg_clustersumoff +
+ (sblock.fs_contigsumsize + 1) * sizeof(u_int32_t), "%jd");
+ CHK(cgp->cg_nextfreeoff, !=, cgp->cg_clusteroff +
+ howmany(fragstoblks(&sblock, sblock.fs_fpg), CHAR_BIT),
+ "%jd");
+ }
+ if (error == 0)
+ return (1);
if (prevfailcg == cg)
return (0);
prevfailcg = cg;
pfatal("CYLINDER GROUP %d: INTEGRITY CHECK FAILED", cg);
- if (!request_rebuild) {
- printf("\n");
- return (0);
- }
- if (!reply("REBUILD CYLINDER GROUP")) {
- printf("YOU WILL NEED TO RERUN FSCK.\n");
- rerun = 1;
- return (1);
- }
+ printf("\n");
+ return (0);
+}
+
+void
+rebuild_cg(int cg, struct bufarea *cgbp)
+{
+ struct cg *cgp = cgbp->b_un.b_cg;
+ long start;
+
/*
* Zero out the cylinder group and then initialize critical fields.
* Bit maps and summaries will be recalculated by later passes.
@@ -1002,13 +1088,15 @@ check_cgmagic(int cg, struct bufarea *cgbp, int request_rebuild)
cgp->cg_ndblk = sblock.fs_fpg;
else
cgp->cg_ndblk = sblock.fs_size - cgbase(&sblock, cg);
- cgp->cg_iusedoff = &cgp->cg_space[0] - (u_char *)(&cgp->cg_firstfield);
- if (sblock.fs_magic == FS_UFS1_MAGIC) {
+ start = sizeof(*cgp);
+ if (sblock.fs_magic == FS_UFS2_MAGIC) {
+ cgp->cg_iusedoff = start;
+ } else if (sblock.fs_magic == FS_UFS1_MAGIC) {
cgp->cg_niblk = 0;
cgp->cg_initediblk = 0;
cgp->cg_old_ncyl = sblock.fs_old_cpg;
cgp->cg_old_niblk = sblock.fs_ipg;
- cgp->cg_old_btotoff = cgp->cg_iusedoff;
+ cgp->cg_old_btotoff = start;
cgp->cg_old_boff = cgp->cg_old_btotoff +
sblock.fs_old_cpg * sizeof(int32_t);
cgp->cg_iusedoff = cgp->cg_old_boff +
@@ -1026,58 +1114,115 @@ check_cgmagic(int cg, struct bufarea *cgbp, int request_rebuild)
cgp->cg_nextfreeoff = cgp->cg_clusteroff +
howmany(fragstoblks(&sblock, sblock.fs_fpg), CHAR_BIT);
}
+ cgp->cg_ckhash = calculate_crc32c(~0L, (void *)cgp, sblock.fs_cgsize);
cgdirty(cgbp);
- return (0);
}
/*
* allocate a data block with the specified number of fragments
*/
ufs2_daddr_t
-allocblk(long frags)
+allocblk(long startcg, long frags,
+ ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags))
+{
+ ufs2_daddr_t blkno, newblk;
+
+ if (sujrecovery && checkblkavail == std_checkblkavail) {
+ pfatal("allocblk: std_checkblkavail used for SUJ recovery\n");
+ return (0);
+ }
+ if (frags <= 0 || frags > sblock.fs_frag)
+ return (0);
+ for (blkno = MAX(cgdata(&sblock, startcg), 0);
+ blkno < maxfsblock - sblock.fs_frag;
+ blkno += sblock.fs_frag) {
+ if ((newblk = (*checkblkavail)(blkno, frags)) == 0)
+ continue;
+ if (newblk > 0)
+ return (newblk);
+ if (newblk < 0)
+ blkno = -newblk;
+ }
+ for (blkno = MAX(cgdata(&sblock, 0), 0);
+ blkno < cgbase(&sblock, startcg) - sblock.fs_frag;
+ blkno += sblock.fs_frag) {
+ if ((newblk = (*checkblkavail)(blkno, frags)) == 0)
+ continue;
+ if (newblk > 0)
+ return (newblk);
+ if (newblk < 0)
+ blkno = -newblk;
+ }
+ return (0);
+}
+
+ufs2_daddr_t
+std_checkblkavail(ufs2_daddr_t blkno, long frags)
{
- int i, j, k, cg, baseblk;
struct bufarea *cgbp;
struct cg *cgp;
+ ufs2_daddr_t j, k, baseblk;
+ long cg;
- if (frags <= 0 || frags > sblock.fs_frag)
+ if ((u_int64_t)blkno > sblock.fs_size)
return (0);
- for (i = 0; i < maxfsblock - sblock.fs_frag; i += sblock.fs_frag) {
- for (j = 0; j <= sblock.fs_frag - frags; j++) {
- if (testbmap(i + j))
- continue;
- for (k = 1; k < frags; k++)
- if (testbmap(i + j + k))
- break;
- if (k < frags) {
- j += k;
- continue;
- }
- cg = dtog(&sblock, i + j);
- cgbp = cglookup(cg);
- cgp = cgbp->b_un.b_cg;
- if (!check_cgmagic(cg, cgbp, 0)) {
- i = (cg + 1) * sblock.fs_fpg - sblock.fs_frag;
- continue;
- }
- baseblk = dtogd(&sblock, i + j);
- for (k = 0; k < frags; k++) {
- setbmap(i + j + k);
- clrbit(cg_blksfree(cgp), baseblk + k);
- }
- n_blks += frags;
- if (frags == sblock.fs_frag)
- cgp->cg_cs.cs_nbfree--;
- else
- cgp->cg_cs.cs_nffree -= frags;
- cgdirty(cgbp);
- return (i + j);
+ for (j = 0; j <= sblock.fs_frag - frags; j++) {
+ if (testbmap(blkno + j))
+ continue;
+ for (k = 1; k < frags; k++)
+ if (testbmap(blkno + j + k))
+ break;
+ if (k < frags) {
+ j += k;
+ continue;
+ }
+ cg = dtog(&sblock, blkno + j);
+ cgbp = cglookup(cg);
+ cgp = cgbp->b_un.b_cg;
+ if (!check_cgmagic(cg, cgbp))
+ return (-((cg + 1) * sblock.fs_fpg - sblock.fs_frag));
+ baseblk = dtogd(&sblock, blkno + j);
+ for (k = 0; k < frags; k++) {
+ setbmap(blkno + j + k);
+ clrbit(cg_blksfree(cgp), baseblk + k);
}
+ n_blks += frags;
+ if (frags == sblock.fs_frag)
+ cgp->cg_cs.cs_nbfree--;
+ else
+ cgp->cg_cs.cs_nffree -= frags;
+ cgdirty(cgbp);
+ return (blkno + j);
}
return (0);
}
/*
+ * Check whether a file size is within the limits for the filesystem.
+ * Return 1 when valid and 0 when too big.
+ *
+ * This should match the file size limit in ffs_mountfs().
+ */
+int
+chkfilesize(mode_t mode, u_int64_t filesize)
+{
+ u_int64_t kernmaxfilesize;
+
+ if (sblock.fs_magic == FS_UFS1_MAGIC)
+ kernmaxfilesize = (off_t)0x40000000 * sblock.fs_bsize - 1;
+ else
+ kernmaxfilesize = sblock.fs_maxfilesize;
+ if (filesize > kernmaxfilesize ||
+ filesize > sblock.fs_maxfilesize ||
+ (mode == IFDIR && filesize > MAXDIRSIZE)) {
+ if (debug)
+ printf("bad file size %ju:", (uintmax_t)filesize);
+ return (0);
+ }
+ return (1);
+}
+
+/*
* Slow down IO so as to leave some disk bandwidth for other processes
*/
void
@@ -1151,9 +1296,11 @@ getpathname(char *namebuf, ino_t curdir, ino_t ino)
ginode(ino, &ip);
if ((ckinode(ip.i_dp, &idesc) & FOUND) == 0) {
irelse(&ip);
+ free(idesc.id_name);
break;
}
irelse(&ip);
+ free(idesc.id_name);
namelookup:
idesc.id_number = idesc.id_parent;
idesc.id_parent = ino;
@@ -1245,12 +1392,17 @@ dofix(struct inodesc *idesc, const char *msg)
/*
* Print details about a buffer.
*/
-static void
-prtbuf(const char *msg, struct bufarea *bp)
+void
+prtbuf(struct bufarea *bp, const char *fmt, ...)
{
-
- printf("%s: bp %p, type %s, bno %jd, size %d, refcnt %d, flags %s, "
- "index %jd\n", msg, bp, BT_BUFTYPE(bp->b_type), (intmax_t) bp->b_bno,
+ va_list ap;
+ va_start(ap, fmt);
+ if (preen)
+ (void)fprintf(stdout, "%s: ", cdevname);
+ (void)vfprintf(stdout, fmt, ap);
+ va_end(ap);
+ printf(": bp %p, type %s, bno %jd, size %d, refcnt %d, flags %s, "
+ "index %jd\n", bp, BT_BUFTYPE(bp->b_type), (intmax_t) bp->b_bno,
bp->b_size, bp->b_refcnt, bp->b_flags & B_DIRTY ? "dirty" : "clean",
(intmax_t) bp->b_index);
}
diff --git a/sbin/fsck_ffs/gjournal.c b/sbin/fsck_ffs/gjournal.c
index b65589b5bd08..b94f27758315 100644
--- a/sbin/fsck_ffs/gjournal.c
+++ b/sbin/fsck_ffs/gjournal.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-Clause
*
* Copyright (c) 2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.
@@ -54,8 +54,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <string.h>
#include <sys/stat.h>
#include <ufs/ffs/fs.h>
@@ -77,7 +75,6 @@ gjournal_check(const char *filesys)
fs = &sblock;
/* Are there any unreferenced inodes in this file system? */
if (fs->fs_unrefs == 0) {
- //printf("No unreferenced inodes.\n");
sbdirty();
ckfini(1);
return;
@@ -97,7 +94,7 @@ gjournal_check(const char *filesys)
}
cgbp = cglookup(cg);
cgp = cgbp->b_un.b_cg;
- if (!check_cgmagic(cg, cgbp, 0)) {
+ if (!check_cgmagic(cg, cgbp)) {
rerun = 1;
ckfini(0);
return;
@@ -105,7 +102,6 @@ gjournal_check(const char *filesys)
/* Are there any unreferenced inodes in this cylinder group? */
if (cgp->cg_unrefs == 0)
continue;
- //printf("Analizing cylinder group %d (count=%d)\n", cg, cgp->cg_unrefs);
/*
* Now go through the list of all inodes in this cylinder group
* to find unreferenced ones.
@@ -150,20 +146,15 @@ gjournal_check(const char *filesys)
inodirty(&ip);
irelse(&ip);
cgdirty(cgbp);
- if (cgp->cg_unrefs == 0) {
- //printf("No more unreferenced inodes in cg=%d.\n", cg);
+ if (cgp->cg_unrefs == 0)
break;
- }
}
/*
- * If there are no more unreferenced inodes, there is no need to
- * check other cylinder groups.
+ * If there are no more unreferenced inodes, there is no
+ * need to check other cylinder groups.
*/
- if (fs->fs_unrefs == 0) {
- //printf("No more unreferenced inodes (cg=%d/%d).\n", cg,
- // fs->fs_ncg);
+ if (fs->fs_unrefs == 0)
break;
- }
}
/* Write back updated statistics and super-block. */
sbdirty();
diff --git a/sbin/fsck_ffs/globs.c b/sbin/fsck_ffs/globs.c
index 09dbcc6694a2..1f04311e2e5c 100644
--- a/sbin/fsck_ffs/globs.c
+++ b/sbin/fsck_ffs/globs.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1986, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@@ -60,19 +46,19 @@ ino_t cursnapshot;
long dirhash, inplast;
unsigned long numdirs, listmax;
long countdirs; /* number of directories we actually found */
-int adjrefcnt[MIBSIZE]; /* MIB command to adjust inode reference cnt */
-int adjblkcnt[MIBSIZE]; /* MIB command to adjust inode block count */
-int setsize[MIBSIZE]; /* MIB command to set inode size */
-int adjndir[MIBSIZE]; /* MIB command to adjust number of directories */
-int adjnbfree[MIBSIZE]; /* MIB command to adjust number of free blocks */
-int adjnifree[MIBSIZE]; /* MIB command to adjust number of free inodes */
-int adjnffree[MIBSIZE]; /* MIB command to adjust number of free frags */
-int adjnumclusters[MIBSIZE]; /* MIB command to adjust number of free clusters */
-int freefiles[MIBSIZE]; /* MIB command to free a set of files */
-int freedirs[MIBSIZE]; /* MIB command to free a set of directories */
-int freeblks[MIBSIZE]; /* MIB command to free a set of data blocks */
+int adjrefcnt[MIBSIZE]; /* MIB cmd to adjust inode reference cnt */
+int adjblkcnt[MIBSIZE]; /* MIB cmd to adjust inode block count */
+int setsize[MIBSIZE]; /* MIB cmd to set inode size */
+int adjndir[MIBSIZE]; /* MIB cmd to adjust number of directories */
+int adjnbfree[MIBSIZE]; /* MIB cmd to adjust number of free blocks */
+int adjnifree[MIBSIZE]; /* MIB cmd to adjust number of free inodes */
+int adjnffree[MIBSIZE]; /* MIB cmd to adjust number of free frags */
+int adjnumclusters[MIBSIZE]; /* MIB cmd to adjust number of free clusters */
+int adjdepth[MIBSIZE]; /* MIB cmd to adjust directory depth count */
+int freefiles[MIBSIZE]; /* MIB cmd to free a set of files */
+int freedirs[MIBSIZE]; /* MIB cmd to free a set of directories */
+int freeblks[MIBSIZE]; /* MIB cmd to free a set of data blocks */
struct fsck_cmd cmd; /* sysctl file system update commands */
-char snapname[BUFSIZ]; /* when doing snapshots, the name of the file */
char *cdevname; /* name of device being checked */
long dev_bsize; /* computed value of DEV_BSIZE */
long secsize; /* actual disk sector size */
@@ -90,13 +76,12 @@ char ckclean; /* only do work if not cleanly unmounted */
int cvtlevel; /* convert to newer file system format */
int ckhashadd; /* check hashes to be added */
int bkgrdcheck; /* determine if background check is possible */
-int bkgrdsumadj; /* whether the kernel have ability to adjust superblock summary */
+int bkgrdsumadj; /* kernel able to adjust superblock summary */
char usedsoftdep; /* just fix soft dependency inconsistencies */
char preen; /* just fix normal inconsistencies */
char rerun; /* rerun fsck. Only used in non-preen mode */
int returntosingle; /* 1 => return to single user mode on exit */
char resolved; /* cleared if unresolved changes => not clean */
-int sbhashfailed; /* when reading superblock check hash failed */
char havesb; /* superblock has been read */
char skipclean; /* skip clean file systems if preening */
int fsmodified; /* 1 => write done to file system */
@@ -111,6 +96,7 @@ ino_t lfdir; /* lost & found directory inode number */
const char *lfname; /* lost & found directory name */
int lfmode; /* lost & found directory creation mode */
ufs2_daddr_t n_blks; /* number of blocks in use */
+int cgheader_corrupt; /* one or more CG headers are corrupt */
ino_t n_files; /* number of files in use */
volatile sig_atomic_t got_siginfo; /* received a SIGINFO */
volatile sig_atomic_t got_sigalarm; /* received a SIGALRM */
@@ -140,11 +126,11 @@ fsckinit(void)
bzero(adjnifree, sizeof(int) * MIBSIZE);
bzero(adjnffree, sizeof(int) * MIBSIZE);
bzero(adjnumclusters, sizeof(int) * MIBSIZE);
+ bzero(adjdepth, sizeof(int) * MIBSIZE);
bzero(freefiles, sizeof(int) * MIBSIZE);
bzero(freedirs, sizeof(int) * MIBSIZE);
bzero(freeblks, sizeof(int) * MIBSIZE);
bzero(&cmd, sizeof(struct fsck_cmd));
- bzero(snapname, sizeof(char) * BUFSIZ);
cdevname = NULL;
dev_bsize = 0;
secsize = 0;
@@ -156,7 +142,6 @@ fsckinit(void)
resolved = 0;
havesb = 0;
fsmodified = 0;
- sbhashfailed = 0;
fsreadfd = -1;
fswritefd = -1;
maxfsblock = 0;
@@ -166,6 +151,7 @@ fsckinit(void)
lfmode = 0700;
n_blks = 0;
n_files = 0;
+ cgheader_corrupt = 0;
got_siginfo = 0;
got_sigalarm = 0;
bzero(&zino.dp1, sizeof(struct ufs1_dinode));
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index 47f72c84a1f2..5b004cd29c90 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -29,15 +29,8 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
+#include <sys/stat.h>
#include <sys/stdint.h>
#include <sys/sysctl.h>
@@ -49,7 +42,6 @@ __FBSDID("$FreeBSD$");
#include <pwd.h>
#include <string.h>
#include <time.h>
-#include <libufs.h>
#include "fsck.h"
@@ -58,6 +50,9 @@ struct bufarea *icachebp; /* inode cache buffer */
static int iblock(struct inodesc *, off_t isize, int type);
static ufs2_daddr_t indir_blkatoff(ufs2_daddr_t, ino_t, ufs_lbn_t, ufs_lbn_t,
struct bufarea **);
+static int snapclean(struct inodesc *idesc);
+static void chkcopyonwrite(struct fs *, ufs2_daddr_t,
+ ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t, long));
int
ckinode(union dinode *dp, struct inodesc *idesc)
@@ -86,6 +81,10 @@ ckinode(union dinode *dp, struct inodesc *idesc)
dino.dp1 = dp->dp1;
else
dino.dp2 = dp->dp2;
+ if (DIP(&dino, di_size) < 0) {
+ pfatal("NEGATIVE INODE SIZE %jd\n", DIP(&dino, di_size));
+ return (STOP);
+ }
ndb = howmany(DIP(&dino, di_size), sblock.fs_bsize);
for (i = 0; i < UFS_NDADDR; i++) {
idesc->id_lbn++;
@@ -112,6 +111,7 @@ ckinode(union dinode *dp, struct inodesc *idesc)
inodirty(&ip);
irelse(&ip);
}
+ return (STOP);
}
continue;
}
@@ -377,9 +377,13 @@ chkrange(ufs2_daddr_t blk, int cnt)
{
int c;
- if (cnt <= 0 || blk <= 0 || blk > maxfsblock ||
- cnt - 1 > maxfsblock - blk)
+ if (cnt <= 0 || blk <= 0 || blk >= maxfsblock ||
+ cnt > maxfsblock - blk) {
+ if (debug)
+ printf("out of range: blk %ld, offset %i, size %d\n",
+ (long)blk, (int)fragnum(&sblock, blk), cnt);
return (1);
+ }
if (cnt > sblock.fs_frag ||
fragnum(&sblock, blk) + cnt > sblock.fs_frag) {
if (debug)
@@ -415,21 +419,33 @@ chkrange(ufs2_daddr_t blk, int cnt)
/*
* General purpose interface for reading inodes.
+ *
+ * firstinum and lastinum track contents of getnextino() cache (below).
*/
+static ino_t firstinum, lastinum;
+static struct bufarea inobuf;
+
void
ginode(ino_t inumber, struct inode *ip)
{
ufs2_daddr_t iblk;
+ struct ufs2_dinode *dp;
- if (inumber < UFS_ROOTINO || inumber > maxino)
+ if (inumber < UFS_ROOTINO || inumber >= maxino)
errx(EEXIT, "bad inode number %ju to ginode",
(uintmax_t)inumber);
ip->i_number = inumber;
- if (icachebp != NULL &&
+ if (inumber >= firstinum && inumber < lastinum) {
+ /* contents in getnextino() cache */
+ ip->i_bp = &inobuf;
+ inobuf.b_refcnt++;
+ inobuf.b_index = firstinum;
+ } else if (icachebp != NULL &&
inumber >= icachebp->b_index &&
inumber < icachebp->b_index + INOPB(&sblock)) {
/* take an additional reference for the returned inode */
icachebp->b_refcnt++;
+ ip->i_bp = icachebp;
} else {
iblk = ino_to_fsba(&sblock, inumber);
/* release our cache-hold reference on old icachebp */
@@ -445,23 +461,24 @@ ginode(ino_t inumber, struct inode *ip)
/* take a cache-hold reference on new icachebp */
icachebp->b_refcnt++;
icachebp->b_index = rounddown(inumber, INOPB(&sblock));
+ ip->i_bp = icachebp;
}
- ip->i_bp = icachebp;
if (sblock.fs_magic == FS_UFS1_MAGIC) {
ip->i_dp = (union dinode *)
- &icachebp->b_un.b_dinode1[inumber % INOPB(&sblock)];
+ &ip->i_bp->b_un.b_dinode1[inumber - ip->i_bp->b_index];
return;
}
ip->i_dp = (union dinode *)
- &icachebp->b_un.b_dinode2[inumber % INOPB(&sblock)];
- if (ffs_verify_dinode_ckhash(&sblock, (struct ufs2_dinode *)ip->i_dp)) {
+ &ip->i_bp->b_un.b_dinode2[inumber - ip->i_bp->b_index];
+ dp = (struct ufs2_dinode *)ip->i_dp;
+ /* Do not check hash of inodes being created */
+ if (dp->di_mode != 0 && ffs_verify_dinode_ckhash(&sblock, dp)) {
pwarn("INODE CHECK-HASH FAILED");
prtinode(ip);
if (preen || reply("FIX") != 0) {
if (preen)
printf(" (FIXED)\n");
- ffs_update_dinode_ckhash(&sblock,
- (struct ufs2_dinode *)ip->i_dp);
+ ffs_update_dinode_ckhash(&sblock, dp);
inodirty(ip);
}
}
@@ -474,6 +491,14 @@ void
irelse(struct inode *ip)
{
+ /* Check for failed inode read */
+ if (ip->i_bp == NULL)
+ return;
+ if (debug && sblock.fs_magic == FS_UFS2_MAGIC &&
+ ffs_verify_dinode_ckhash(&sblock, (struct ufs2_dinode *)ip->i_dp)) {
+ pwarn("irelse: releasing inode with bad check-hash");
+ prtinode(ip);
+ }
if (ip->i_bp->b_refcnt <= 0)
pfatal("irelse: releasing unreferenced ino %ju\n",
(uintmax_t) ip->i_number);
@@ -484,12 +509,11 @@ irelse(struct inode *ip)
* Special purpose version of ginode used to optimize first pass
* over all the inodes in numerical order.
*/
-static ino_t nextino, lastinum, lastvalidinum;
+static ino_t nextinum, lastvalidinum;
static long readcount, readpercg, fullcnt, inobufsize, partialcnt, partialsize;
-static struct bufarea inobuf;
union dinode *
-getnextinode(ino_t inumber, int rebuildcg)
+getnextinode(ino_t inumber, int rebuiltcg)
{
int j;
long size;
@@ -499,11 +523,12 @@ getnextinode(ino_t inumber, int rebuildcg)
struct inode ip;
static caddr_t nextinop;
- if (inumber != nextino++ || inumber > lastvalidinum)
+ if (inumber != nextinum++ || inumber > lastvalidinum)
errx(EEXIT, "bad inode number %ju to nextinode",
(uintmax_t)inumber);
if (inumber >= lastinum) {
readcount++;
+ firstinum = lastinum;
blk = ino_to_fsba(&sblock, lastinum);
if (readcount % readpercg == 0) {
size = partialsize;
@@ -517,6 +542,9 @@ getnextinode(ino_t inumber, int rebuildcg)
* If getblk encounters an error, it will already have zeroed
* out the buffer, so we do not need to do so here.
*/
+ if (inobuf.b_refcnt != 0)
+ pfatal("Non-zero getnextinode() ref count %d\n",
+ inobuf.b_refcnt);
flush(fswritefd, &inobuf);
getblk(&inobuf, blk, size);
nextinop = inobuf.b_un.b_buf;
@@ -544,7 +572,7 @@ getnextinode(ino_t inumber, int rebuildcg)
dirty(&inobuf);
}
}
- if (rebuildcg && (char *)dp == inobuf.b_un.b_buf) {
+ if (rebuiltcg && (char *)dp == inobuf.b_un.b_buf) {
/*
* Try to determine if we have reached the end of the
* allocated inodes.
@@ -601,7 +629,7 @@ setinodebuf(int cg, ino_t inosused)
inum = cg * sblock.fs_ipg;
lastvalidinum = inum + inosused - 1;
- nextino = inum;
+ nextinum = inum;
lastinum = inum;
readcount = 0;
/* Flush old contents in case they have been updated */
@@ -611,7 +639,7 @@ setinodebuf(int cg, ino_t inosused)
inobufsize = blkroundup(&sblock,
MAX(INOBUFSIZE, sblock.fs_bsize));
initbarea(&inobuf, BT_INODES);
- if ((inobuf.b_un.b_buf = Malloc((unsigned)inobufsize)) == NULL)
+ if ((inobuf.b_un.b_buf = Balloc((unsigned)inobufsize)) == NULL)
errx(EEXIT, "cannot allocate space for inode buffer");
}
fullcnt = inobufsize / ((sblock.fs_magic == FS_UFS1_MAGIC) ?
@@ -633,14 +661,23 @@ int
freeblock(struct inodesc *idesc)
{
struct dups *dlp;
+ struct bufarea *cgbp;
+ struct cg *cgp;
ufs2_daddr_t blkno;
- long nfrags, res;
+ long size, nfrags;
- res = KEEPON;
blkno = idesc->id_blkno;
+ if (idesc->id_type == SNAP) {
+ pfatal("clearing a snapshot dinode\n");
+ return (STOP);
+ }
+ size = lfragtosize(&sblock, idesc->id_numfrags);
+ if (snapblkfree(&sblock, blkno, size, idesc->id_number,
+ std_checkblkavail))
+ return (KEEPON);
for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
if (chkrange(blkno, 1)) {
- res = SKIP;
+ return (SKIP);
} else if (testbmap(blkno)) {
for (dlp = duplist; dlp; dlp = dlp->next) {
if (dlp->dup != blkno)
@@ -657,12 +694,401 @@ freeblock(struct inodesc *idesc)
}
}
}
- return (res);
+ /*
+ * If all successfully returned, account for them.
+ */
+ if (nfrags == 0) {
+ cgbp = cglookup(dtog(&sblock, idesc->id_blkno));
+ cgp = cgbp->b_un.b_cg;
+ if (idesc->id_numfrags == sblock.fs_frag)
+ cgp->cg_cs.cs_nbfree++;
+ else
+ cgp->cg_cs.cs_nffree += idesc->id_numfrags;
+ cgdirty(cgbp);
+ }
+ return (KEEPON);
+}
+
+/*
+ * Prepare a snapshot file for being removed.
+ */
+void
+snapremove(ino_t inum)
+{
+ struct inodesc idesc;
+ struct inode ip;
+ int i;
+
+ for (i = 0; i < snapcnt; i++)
+ if (snaplist[i].i_number == inum)
+ break;
+ if (i == snapcnt)
+ ginode(inum, &ip);
+ else
+ ip = snaplist[i];
+ if ((DIP(ip.i_dp, di_flags) & SF_SNAPSHOT) == 0) {
+ printf("snapremove: inode %jd is not a snapshot\n",
+ (intmax_t)inum);
+ if (i == snapcnt)
+ irelse(&ip);
+ return;
+ }
+ if (debug)
+ printf("snapremove: remove %sactive snapshot %jd\n",
+ i == snapcnt ? "in" : "", (intmax_t)inum);
+ /*
+ * If on active snapshot list, remove it.
+ */
+ if (i < snapcnt) {
+ for (i++; i < FSMAXSNAP; i++) {
+ if (sblock.fs_snapinum[i] == 0)
+ break;
+ snaplist[i - 1] = snaplist[i];
+ sblock.fs_snapinum[i - 1] = sblock.fs_snapinum[i];
+ }
+ sblock.fs_snapinum[i - 1] = 0;
+ bzero(&snaplist[i - 1], sizeof(struct inode));
+ snapcnt--;
+ }
+ memset(&idesc, 0, sizeof(struct inodesc));
+ idesc.id_type = SNAP;
+ idesc.id_func = snapclean;
+ idesc.id_number = inum;
+ (void)ckinode(ip.i_dp, &idesc);
+ DIP_SET(ip.i_dp, di_flags, DIP(ip.i_dp, di_flags) & ~SF_SNAPSHOT);
+ inodirty(&ip);
+ irelse(&ip);
+}
+
+static int
+snapclean(struct inodesc *idesc)
+{
+ ufs2_daddr_t blkno;
+ struct bufarea *bp;
+ union dinode *dp;
+
+ blkno = idesc->id_blkno;
+ if (blkno == 0)
+ return (KEEPON);
+
+ dp = idesc->id_dp;
+ if (blkno == BLK_NOCOPY || blkno == BLK_SNAP) {
+ if (idesc->id_lbn < UFS_NDADDR) {
+ DIP_SET(dp, di_db[idesc->id_lbn], 0);
+ } else {
+ bp = idesc->id_bp;
+ IBLK_SET(bp, bp->b_index, 0);
+ dirty(bp);
+ }
+ }
+ return (KEEPON);
+}
+
+/*
+ * Notification that a block is being freed. Return zero if the free
+ * should be allowed to proceed. Return non-zero if the snapshot file
+ * wants to claim the block. The block will be claimed if it is an
+ * uncopied part of one of the snapshots. It will be freed if it is
+ * either a BLK_NOCOPY or has already been copied in all of the snapshots.
+ * If a fragment is being freed, then all snapshots that care about
+ * it must make a copy since a snapshot file can only claim full sized
+ * blocks. Note that if more than one snapshot file maps the block,
+ * we can pick one at random to claim it. Since none of the snapshots
+ * can change, we are assurred that they will all see the same unmodified
+ * image. When deleting a snapshot file (see ino_trunc above), we
+ * must push any of these claimed blocks to one of the other snapshots
+ * that maps it. These claimed blocks are easily identified as they will
+ * have a block number equal to their logical block number within the
+ * snapshot. A copied block can never have this property because they
+ * must always have been allocated from a BLK_NOCOPY location.
+ */
+int
+snapblkfree(struct fs *fs, ufs2_daddr_t bno, long size, ino_t inum,
+ ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags))
+{
+ union dinode *dp;
+ struct inode ip;
+ struct bufarea *snapbp;
+ ufs_lbn_t lbn;
+ ufs2_daddr_t blkno, relblkno;
+ int i, frags, claimedblk, copydone;
+
+ /* If no snapshots, nothing to do */
+ if (snapcnt == 0)
+ return (0);
+ if (debug)
+ printf("snapblkfree: in ino %jd free blkno %jd, size %jd\n",
+ (intmax_t)inum, (intmax_t)bno, (intmax_t)size);
+ relblkno = blknum(fs, bno);
+ lbn = fragstoblks(fs, relblkno);
+ /* Direct blocks are always pre-copied */
+ if (lbn < UFS_NDADDR)
+ return (0);
+ copydone = 0;
+ claimedblk = 0;
+ for (i = 0; i < snapcnt; i++) {
+ /*
+ * Lookup block being freed.
+ */
+ ip = snaplist[i];
+ dp = ip.i_dp;
+ blkno = ino_blkatoff(dp, inum != 0 ? inum : ip.i_number,
+ lbn, &frags, &snapbp);
+ /*
+ * Check to see if block needs to be copied.
+ */
+ if (blkno == 0) {
+ /*
+ * A block that we map is being freed. If it has not
+ * been claimed yet, we will claim or copy it (below).
+ */
+ claimedblk = 1;
+ } else if (blkno == BLK_SNAP) {
+ /*
+ * No previous snapshot claimed the block,
+ * so it will be freed and become a BLK_NOCOPY
+ * (don't care) for us.
+ */
+ if (claimedblk)
+ pfatal("snapblkfree: inconsistent block type");
+ IBLK_SET(snapbp, snapbp->b_index, BLK_NOCOPY);
+ dirty(snapbp);
+ brelse(snapbp);
+ continue;
+ } else /* BLK_NOCOPY or default */ {
+ /*
+ * If the snapshot has already copied the block
+ * (default), or does not care about the block,
+ * it is not needed.
+ */
+ brelse(snapbp);
+ continue;
+ }
+ /*
+ * If this is a full size block, we will just grab it
+ * and assign it to the snapshot inode. Otherwise we
+ * will proceed to copy it. See explanation for this
+ * routine as to why only a single snapshot needs to
+ * claim this block.
+ */
+ if (size == fs->fs_bsize) {
+ if (debug)
+ printf("Grabonremove snapshot %ju lbn %jd "
+ "from inum %ju\n", (intmax_t)ip.i_number,
+ (intmax_t)lbn, (uintmax_t)inum);
+ IBLK_SET(snapbp, snapbp->b_index, relblkno);
+ dirty(snapbp);
+ brelse(snapbp);
+ DIP_SET(dp, di_blocks,
+ DIP(dp, di_blocks) + btodb(size));
+ inodirty(&ip);
+ return (1);
+ }
+
+ /* First time through, read the contents of the old block. */
+ if (copydone == 0) {
+ copydone = 1;
+ if (blread(fsreadfd, copybuf, fsbtodb(fs, relblkno),
+ fs->fs_bsize) != 0) {
+ pfatal("Could not read snapshot %ju block "
+ "%jd\n", (intmax_t)ip.i_number,
+ (intmax_t)relblkno);
+ continue;
+ }
+ }
+ /*
+ * This allocation will never require any additional
+ * allocations for the snapshot inode.
+ */
+ blkno = allocblk(dtog(fs, relblkno), fs->fs_frag,
+ checkblkavail);
+ if (blkno == 0) {
+ pfatal("Could not allocate block for snapshot %ju\n",
+ (intmax_t)ip.i_number);
+ continue;
+ }
+ if (debug)
+ printf("Copyonremove: snapino %jd lbn %jd for inum %ju "
+ "size %ld new blkno %jd\n", (intmax_t)ip.i_number,
+ (intmax_t)lbn, (uintmax_t)inum, size,
+ (intmax_t)blkno);
+ blwrite(fswritefd, copybuf, fsbtodb(fs, blkno), fs->fs_bsize);
+ IBLK_SET(snapbp, snapbp->b_index, blkno);
+ dirty(snapbp);
+ brelse(snapbp);
+ DIP_SET(dp, di_blocks,
+ DIP(dp, di_blocks) + btodb(fs->fs_bsize));
+ inodirty(&ip);
+ }
+ return (0);
+}
+
+/*
+ * Notification that a block is being written. Return if the block
+ * is part of a snapshot as snapshots never track other snapshots.
+ * The block will be copied in all of the snapshots that are tracking
+ * it and have not yet copied it. Some buffers may hold more than one
+ * block. Here we need to check each block in the buffer.
+ */
+void
+copyonwrite(struct fs *fs, struct bufarea *bp,
+ ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags))
+{
+ ufs2_daddr_t copyblkno;
+ long i, numblks;
+
+ /* If no snapshots, nothing to do. */
+ if (snapcnt == 0)
+ return;
+ numblks = blkroundup(fs, bp->b_size) / fs->fs_bsize;
+ if (debug)
+ prtbuf(bp, "copyonwrite: checking %jd block%s in buffer",
+ (intmax_t)numblks, numblks > 1 ? "s" : "");
+ copyblkno = blknum(fs, dbtofsb(fs, bp->b_bno));
+ for (i = 0; i < numblks; i++) {
+ chkcopyonwrite(fs, copyblkno, checkblkavail);
+ copyblkno += fs->fs_frag;
+ }
+}
+
+static void
+chkcopyonwrite(struct fs *fs, ufs2_daddr_t copyblkno,
+ ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags))
+{
+ struct inode ip;
+ union dinode *dp;
+ struct bufarea *snapbp;
+ ufs2_daddr_t blkno;
+ int i, frags, copydone;
+ ufs_lbn_t lbn;
+
+ lbn = fragstoblks(fs, copyblkno);
+ /* Direct blocks are always pre-copied */
+ if (lbn < UFS_NDADDR)
+ return;
+ copydone = 0;
+ for (i = 0; i < snapcnt; i++) {
+ /*
+ * Lookup block being freed.
+ */
+ ip = snaplist[i];
+ dp = ip.i_dp;
+ blkno = ino_blkatoff(dp, ip.i_number, lbn, &frags, &snapbp);
+ /*
+ * Check to see if block needs to be copied.
+ */
+ if (blkno != 0) {
+ /*
+ * A block that we have already copied or don't track.
+ */
+ brelse(snapbp);
+ continue;
+ }
+ /* First time through, read the contents of the old block. */
+ if (copydone == 0) {
+ copydone = 1;
+ if (blread(fsreadfd, copybuf, fsbtodb(fs, copyblkno),
+ fs->fs_bsize) != 0) {
+ pfatal("Could not read snapshot %ju block "
+ "%jd\n", (intmax_t)ip.i_number,
+ (intmax_t)copyblkno);
+ continue;
+ }
+ }
+ /*
+ * This allocation will never require any additional
+ * allocations for the snapshot inode.
+ */
+ if ((blkno = allocblk(dtog(fs, copyblkno), fs->fs_frag,
+ checkblkavail)) == 0) {
+ pfatal("Could not allocate block for snapshot %ju\n",
+ (intmax_t)ip.i_number);
+ continue;
+ }
+ if (debug)
+ prtbuf(snapbp, "Copyonwrite: snapino %jd lbn %jd using "
+ "blkno %ju setting in buffer",
+ (intmax_t)ip.i_number, (intmax_t)lbn,
+ (intmax_t)blkno);
+ blwrite(fswritefd, copybuf, fsbtodb(fs, blkno), fs->fs_bsize);
+ IBLK_SET(snapbp, snapbp->b_index, blkno);
+ dirty(snapbp);
+ brelse(snapbp);
+ DIP_SET(dp, di_blocks,
+ DIP(dp, di_blocks) + btodb(fs->fs_bsize));
+ inodirty(&ip);
+ }
+ return;
+}
+
+/*
+ * Traverse an inode and check that its block count is correct
+ * fixing it if necessary.
+ */
+void
+check_blkcnt(struct inode *ip)
+{
+ struct inodesc idesc;
+ union dinode *dp;
+ ufs2_daddr_t ndb;
+ int j, ret, offset;
+
+ dp = ip->i_dp;
+ memset(&idesc, 0, sizeof(struct inodesc));
+ idesc.id_func = pass1check;
+ idesc.id_number = ip->i_number;
+ idesc.id_type = (DIP(dp, di_flags) & SF_SNAPSHOT) == 0 ? ADDR : SNAP;
+ (void)ckinode(dp, &idesc);
+ if (sblock.fs_magic == FS_UFS2_MAGIC && dp->dp2.di_extsize > 0) {
+ ndb = howmany(dp->dp2.di_extsize, sblock.fs_bsize);
+ for (j = 0; j < UFS_NXADDR; j++) {
+ if (--ndb == 0 &&
+ (offset = blkoff(&sblock, dp->dp2.di_extsize)) != 0)
+ idesc.id_numfrags = numfrags(&sblock,
+ fragroundup(&sblock, offset));
+ else
+ idesc.id_numfrags = sblock.fs_frag;
+ if (dp->dp2.di_extb[j] == 0)
+ continue;
+ idesc.id_blkno = dp->dp2.di_extb[j];
+ ret = (*idesc.id_func)(&idesc);
+ if (ret & STOP)
+ break;
+ }
+ }
+ idesc.id_entryno *= btodb(sblock.fs_fsize);
+ if (DIP(dp, di_blocks) != idesc.id_entryno) {
+ if (!(sujrecovery && preen)) {
+ pwarn("INCORRECT BLOCK COUNT I=%lu (%ju should be %ju)",
+ (u_long)idesc.id_number,
+ (uintmax_t)DIP(dp, di_blocks),
+ (uintmax_t)idesc.id_entryno);
+ if (preen)
+ printf(" (CORRECTED)\n");
+ else if (reply("CORRECT") == 0)
+ return;
+ }
+ if (bkgrdflag == 0) {
+ DIP_SET(dp, di_blocks, idesc.id_entryno);
+ inodirty(ip);
+ } else {
+ cmd.value = idesc.id_number;
+ cmd.size = idesc.id_entryno - DIP(dp, di_blocks);
+ if (debug)
+ printf("adjblkcnt ino %ju amount %lld\n",
+ (uintmax_t)cmd.value, (long long)cmd.size);
+ if (sysctl(adjblkcnt, MIBSIZE, 0, 0,
+ &cmd, sizeof cmd) == -1)
+ rwerror("ADJUST INODE BLOCK COUNT", cmd.value);
+ }
+ }
}
void
freeinodebuf(void)
{
+ struct bufarea *bp;
+ int i;
/*
* Flush old contents in case they have been updated.
@@ -671,6 +1097,15 @@ freeinodebuf(void)
if (inobuf.b_un.b_buf != NULL)
free((char *)inobuf.b_un.b_buf);
inobuf.b_un.b_buf = NULL;
+ firstinum = lastinum = 0;
+ /*
+ * Reload the snapshot inodes in case any of them changed.
+ */
+ for (i = 0; i < snapcnt; i++) {
+ bp = snaplist[i].i_bp;
+ bp->b_errs = blread(fsreadfd, bp->b_un.b_buf, bp->b_bno,
+ bp->b_size);
+ }
}
/*
@@ -680,12 +1115,15 @@ freeinodebuf(void)
*
* Enter inodes into the cache.
*/
-void
+struct inoinfo *
cacheino(union dinode *dp, ino_t inumber)
{
- struct inoinfo *inp, **inpp;
+ struct inoinfo *inp;
int i, blks;
+ if (getinoinfo(inumber) != NULL)
+ pfatal("cacheino: duplicate entry for ino %jd\n",
+ (intmax_t)inumber);
if (howmany(DIP(dp, di_size), sblock.fs_bsize) > UFS_NDADDR)
blks = UFS_NDADDR + UFS_NIADDR;
else if (DIP(dp, di_size) > 0)
@@ -696,13 +1134,13 @@ cacheino(union dinode *dp, ino_t inumber)
Malloc(sizeof(*inp) + (blks - 1) * sizeof(ufs2_daddr_t));
if (inp == NULL)
errx(EEXIT, "cannot increase directory list");
- inpp = &inphead[inumber % dirhash];
- inp->i_nexthash = *inpp;
- *inpp = inp;
+ SLIST_INSERT_HEAD(&inphash[inumber % dirhash], inp, i_hash);
+ inp->i_flags = 0;
inp->i_parent = inumber == UFS_ROOTINO ? UFS_ROOTINO : (ino_t)0;
inp->i_dotdot = (ino_t)0;
inp->i_number = inumber;
inp->i_isize = DIP(dp, di_size);
+ inp->i_depth = DIP(dp, di_dirdepth);
inp->i_numblks = blks;
for (i = 0; i < MIN(blks, UFS_NDADDR); i++)
inp->i_blks[i] = DIP(dp, di_db[i]);
@@ -717,6 +1155,7 @@ cacheino(union dinode *dp, ino_t inumber)
errx(EEXIT, "cannot increase directory list");
}
inpsort[inplast++] = inp;
+ return (inp);
}
/*
@@ -727,13 +1166,43 @@ getinoinfo(ino_t inumber)
{
struct inoinfo *inp;
- for (inp = inphead[inumber % dirhash]; inp; inp = inp->i_nexthash) {
+ SLIST_FOREACH(inp, &inphash[inumber % dirhash], i_hash) {
if (inp->i_number != inumber)
continue;
return (inp);
}
- errx(EEXIT, "cannot find inode %ju", (uintmax_t)inumber);
- return ((struct inoinfo *)0);
+ return (NULL);
+}
+
+/*
+ * Remove an entry from the inode cache and disk-order sorted list.
+ * Return 0 on success and 1 on failure.
+ */
+int
+removecachedino(ino_t inumber)
+{
+ struct inoinfo *inp, **inpp;
+ char *listtype;
+
+ listtype = "hash";
+ SLIST_FOREACH(inp, &inphash[inumber % dirhash], i_hash) {
+ if (inp->i_number != inumber)
+ continue;
+ SLIST_REMOVE(&inphash[inumber % dirhash], inp, inoinfo, i_hash);
+ for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) {
+ if (*inpp != inp)
+ continue;
+ *inpp = inpsort[inplast - 1];
+ inplast--;
+ free(inp);
+ return (0);
+ }
+ listtype = "sort";
+ break;
+ }
+ pfatal("removecachedino: entry for ino %jd not found on %s list\n",
+ (intmax_t)inumber, listtype);
+ return (1);
}
/*
@@ -744,13 +1213,14 @@ inocleanup(void)
{
struct inoinfo **inpp;
- if (inphead == NULL)
+ if (inphash == NULL)
return;
for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--)
free((char *)(*inpp));
- free((char *)inphead);
+ free((char *)inphash);
+ inphash = NULL;
free((char *)inpsort);
- inphead = inpsort = NULL;
+ inpsort = NULL;
}
void
@@ -782,6 +1252,10 @@ clri(struct inodesc *idesc, const char *type, int flag)
printf(" (CLEARED)\n");
n_files--;
if (bkgrdflag == 0) {
+ if (idesc->id_type == SNAP) {
+ snapremove(idesc->id_number);
+ idesc->id_type = ADDR;
+ }
(void)ckinode(dp, idesc);
inoinfo(idesc->id_number)->ino_state = USTATE;
clearinode(dp);
@@ -821,7 +1295,7 @@ findino(struct inodesc *idesc)
if (dirp->d_ino == 0)
return (KEEPON);
if (strcmp(dirp->d_name, idesc->id_name) == 0 &&
- dirp->d_ino >= UFS_ROOTINO && dirp->d_ino <= maxino) {
+ dirp->d_ino >= UFS_ROOTINO && dirp->d_ino < maxino) {
idesc->id_parent = dirp->d_ino;
return (STOP|FOUND);
}
@@ -851,7 +1325,7 @@ prtinode(struct inode *ip)
dp = ip->i_dp;
printf(" I=%lu ", (u_long)ip->i_number);
- if (ip->i_number < UFS_ROOTINO || ip->i_number > maxino)
+ if (ip->i_number < UFS_ROOTINO || ip->i_number >= maxino)
return;
printf(" OWNER=");
if ((pw = getpwuid((int)DIP(dp, di_uid))) != NULL)
@@ -863,8 +1337,8 @@ prtinode(struct inode *ip)
printf("%s: ", cdevname);
printf("SIZE=%ju ", (uintmax_t)DIP(dp, di_size));
t = DIP(dp, di_mtime);
- p = ctime(&t);
- printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
+ if ((p = ctime(&t)) != NULL)
+ printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
}
void
@@ -923,7 +1397,7 @@ retry:
cg = ino_to_cg(&sblock, ino);
cgbp = cglookup(cg);
cgp = cgbp->b_un.b_cg;
- if (!check_cgmagic(cg, cgbp, 0)) {
+ if (!check_cgmagic(cg, cgbp)) {
if (anyino == 0)
return (0);
request = (cg + 1) * sblock.fs_ipg;
@@ -946,20 +1420,20 @@ retry:
cgdirty(cgbp);
ginode(ino, &ip);
dp = ip.i_dp;
- DIP_SET(dp, di_db[0], allocblk((long)1));
+ memset(dp, 0, ((sblock.fs_magic == FS_UFS1_MAGIC) ?
+ sizeof(struct ufs1_dinode) : sizeof(struct ufs2_dinode)));
+ DIP_SET(dp, di_db[0], allocblk(ino_to_cg(&sblock, ino), (long)1,
+ std_checkblkavail));
if (DIP(dp, di_db[0]) == 0) {
inoinfo(ino)->ino_state = USTATE;
+ inodirty(&ip);
irelse(&ip);
return (0);
}
DIP_SET(dp, di_mode, type);
- DIP_SET(dp, di_flags, 0);
DIP_SET(dp, di_atime, time(NULL));
DIP_SET(dp, di_ctime, DIP(dp, di_atime));
DIP_SET(dp, di_mtime, DIP(dp, di_ctime));
- DIP_SET(dp, di_mtimensec, 0);
- DIP_SET(dp, di_ctimensec, 0);
- DIP_SET(dp, di_atimensec, 0);
DIP_SET(dp, di_size, sblock.fs_fsize);
DIP_SET(dp, di_blocks, btodb(sblock.fs_fsize));
n_files++;
@@ -980,7 +1454,7 @@ freeino(ino_t ino)
struct inode ip;
memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = inoinfo(ino)->ino_idtype;
+ idesc.id_type = ADDR;
idesc.id_func = freeblock;
idesc.id_number = ino;
ginode(ino, &ip);
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
index 18634a93c05c..aabab489573e 100644
--- a/sbin/fsck_ffs/main.c
+++ b/sbin/fsck_ffs/main.c
@@ -29,21 +29,7 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1986, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#define IN_RTLD /* So we pickup the P_OSREL defines */
+#define _WANT_P_OSREL
#include <sys/param.h>
#include <sys/file.h>
#include <sys/mount.h>
@@ -61,7 +47,6 @@ __FBSDID("$FreeBSD$");
#include <fstab.h>
#include <grp.h>
#include <inttypes.h>
-#include <libufs.h>
#include <mntopts.h>
#include <paths.h>
#include <stdint.h>
@@ -70,14 +55,13 @@ __FBSDID("$FreeBSD$");
#include "fsck.h"
-static int restarts;
+static int restarts;
+static char snapname[BUFSIZ]; /* when doing snapshots, the name of the file */
static void usage(void) __dead2;
static intmax_t argtoimax(int flag, const char *req, const char *str, int base);
static int checkfilesys(char *filesys);
static int setup_bkgrdchk(struct statfs *mntp, int sbrdfailed, char **filesys);
-static int chkdoreload(struct statfs *mntp);
-static struct statfs *getmntpt(const char *);
int
main(int argc, char *argv[])
@@ -258,7 +242,7 @@ checkfilesys(char *filesys)
* if it is listed among the mounted file systems. Failing that
* check to see if it is listed in /etc/fstab.
*/
- mntp = getmntpt(filesys);
+ mntp = getmntpoint(filesys);
if (mntp != NULL)
filesys = mntp->f_mntfromname;
else
@@ -271,14 +255,21 @@ checkfilesys(char *filesys)
*/
sblock_init();
sbreadfailed = 0;
- if (openfilesys(filesys) == 0 || readsb(0) == 0)
+ if (openfilesys(filesys) == 0 || readsb() == 0)
sbreadfailed = 1;
if (bkgrdcheck) {
if (sbreadfailed)
exit(3); /* Cannot read superblock */
- /* Earlier background failed or journaled */
- if (sblock.fs_flags & (FS_NEEDSFSCK | FS_SUJ))
- exit(4);
+ if ((sblock.fs_flags & FS_NEEDSFSCK) == FS_NEEDSFSCK)
+ exit(4); /* Earlier background failed */
+ if ((sblock.fs_flags & FS_SUJ) == FS_SUJ) {
+ maxino = sblock.fs_ncg * sblock.fs_ipg;
+ maxfsblock = sblock.fs_size;
+ bufinit();
+ preen = 1;
+ if (suj_check(filesys) == 0)
+ exit(4); /* Journal good, run it now */
+ }
if ((sblock.fs_flags & FS_DOSOFTDEP) == 0)
exit(5); /* Not running soft updates */
size = MIBSIZE;
@@ -311,7 +302,7 @@ checkfilesys(char *filesys)
(FS_UNCLEAN | FS_NEEDSFSCK)) == 0) {
bufinit();
gjournal_check(filesys);
- if (chkdoreload(mntp) == 0)
+ if (chkdoreload(mntp, pwarn) == 0)
exit(0);
exit(4);
} else {
@@ -352,17 +343,19 @@ checkfilesys(char *filesys)
/*
* Determine if we can and should do journal recovery.
*/
- if ((sblock.fs_flags & FS_SUJ) == FS_SUJ) {
- if ((sblock.fs_flags & FS_NEEDSFSCK) != FS_NEEDSFSCK && skipclean) {
+ if (bkgrdflag == 0 && (sblock.fs_flags & FS_SUJ) == FS_SUJ) {
+ if ((sblock.fs_flags & FS_NEEDSFSCK) != FS_NEEDSFSCK &&
+ skipclean) {
sujrecovery = 1;
if (suj_check(filesys) == 0) {
- printf("\n***** FILE SYSTEM MARKED CLEAN *****\n");
- if (chkdoreload(mntp) == 0)
+ pwarn("\n**** FILE SYSTEM MARKED CLEAN ****\n");
+ if (chkdoreload(mntp, pwarn) == 0)
exit(0);
exit(4);
}
sujrecovery = 0;
- printf("** Skipping journal, falling through to full fsck\n\n");
+ pwarn("Skipping journal, "
+ "falling through to full fsck\n");
}
if (fswritefd != -1) {
/*
@@ -438,7 +431,7 @@ checkfilesys(char *filesys)
/*
* 1: scan inodes tallying blocks used
*/
- if (preen == 0) {
+ if (preen == 0 || debug) {
printf("** Last Mounted on %s\n", sblock.fs_fsmnt);
if (mntp != NULL && mntp->f_flags & MNT_ROOTFS)
printf("** Root file system\n");
@@ -457,7 +450,8 @@ checkfilesys(char *filesys)
preen ? "-p" : "",
(preen && usedsoftdep) ? " AND " : "",
usedsoftdep ? "SOFTUPDATES" : "");
- printf("** Phase 1b - Rescan For More DUPS\n");
+ if (preen == 0 || debug)
+ printf("** Phase 1b - Rescan For More DUPS\n");
pass1b();
IOstats("Pass1b");
}
@@ -465,7 +459,7 @@ checkfilesys(char *filesys)
/*
* 2: traverse directories from root to mark all connected directories
*/
- if (preen == 0)
+ if (preen == 0 || debug)
printf("** Phase 2 - Check Pathnames\n");
pass2();
IOstats("Pass2");
@@ -473,7 +467,7 @@ checkfilesys(char *filesys)
/*
* 3: scan inodes looking for disconnected directories
*/
- if (preen == 0)
+ if (preen == 0 || debug)
printf("** Phase 3 - Check Connectivity\n");
pass3();
IOstats("Pass3");
@@ -481,7 +475,7 @@ checkfilesys(char *filesys)
/*
* 4: scan inodes looking for disconnected files; check reference counts
*/
- if (preen == 0)
+ if (preen == 0 || debug)
printf("** Phase 4 - Check Reference Counts\n");
pass4();
IOstats("Pass4");
@@ -489,10 +483,16 @@ checkfilesys(char *filesys)
/*
* 5: check and repair resource counts in cylinder groups
*/
- if (preen == 0)
+ if (preen == 0 || debug)
printf("** Phase 5 - Check Cyl groups\n");
- pass5();
- IOstats("Pass5");
+ snapflush(std_checkblkavail);
+ if (cgheader_corrupt) {
+ printf("PHASE 5 SKIPPED DUE TO CORRUPT CYLINDER GROUP "
+ "HEADER(S)\n\n");
+ } else {
+ pass5();
+ IOstats("Pass5");
+ }
/*
* print out summary statistics
@@ -560,7 +560,7 @@ checkfilesys(char *filesys)
return (ERESTART);
printf("\n***** PLEASE RERUN FSCK *****\n");
}
- if (chkdoreload(mntp) != 0) {
+ if (chkdoreload(mntp, pwarn) != 0) {
if (!fsmodified)
return (0);
if (!preen)
@@ -612,10 +612,6 @@ setup_bkgrdchk(struct statfs *mntp, int sbreadfailed, char **filesys)
pwarn("FULL FSCK NEEDED, CANNOT RUN IN BACKGROUND\n");
return (0);
}
- if ((sblock.fs_flags & FS_SUJ) != 0) {
- pwarn("JOURNALED FILESYSTEM, CANNOT RUN IN BACKGROUND\n");
- return (0);
- }
if (skipclean && ckclean &&
(sblock.fs_flags & (FS_UNCLEAN|FS_NEEDSFSCK)) == 0) {
/*
@@ -656,8 +652,7 @@ setup_bkgrdchk(struct statfs *mntp, int sbreadfailed, char **filesys)
"SUPPORT\n");
}
/* Find or create the snapshot directory */
- snprintf(snapname, sizeof snapname, "%s/.snap",
- mntp->f_mntonname);
+ snprintf(snapname, sizeof snapname, "%s/.snap", mntp->f_mntonname);
if (stat(snapname, &snapdir) < 0) {
if (errno != ENOENT) {
pwarn("CANNOT FIND SNAPSHOT DIRECTORY %s: %s, CANNOT "
@@ -705,101 +700,20 @@ setup_bkgrdchk(struct statfs *mntp, int sbreadfailed, char **filesys)
"BACKGROUND\n", snapname, strerror(errno));
return (0);
}
+ /* Immediately unlink snapshot so that it will be deleted when closed */
+ unlink(snapname);
free(sblock.fs_csp);
free(sblock.fs_si);
- havesb = 0;
+ if (readsb() == 0) {
+ pwarn("CANNOT READ SNAPSHOT SUPERBLOCK\n");
+ return (0);
+ }
*filesys = snapname;
cmd.version = FFS_CMD_VERSION;
cmd.handle = fsreadfd;
return (1);
}
-static int
-chkdoreload(struct statfs *mntp)
-{
- struct iovec *iov;
- int iovlen;
- char errmsg[255];
-
- if (mntp == NULL)
- return (0);
-
- iov = NULL;
- iovlen = 0;
- errmsg[0] = '\0';
- /*
- * We modified a mounted file system. Do a mount update on
- * it unless it is read-write, so we can continue using it
- * as safely as possible.
- */
- if (mntp->f_flags & MNT_RDONLY) {
- build_iovec(&iov, &iovlen, "fstype", "ffs", 4);
- build_iovec(&iov, &iovlen, "from", mntp->f_mntfromname,
- (size_t)-1);
- build_iovec(&iov, &iovlen, "fspath", mntp->f_mntonname,
- (size_t)-1);
- build_iovec(&iov, &iovlen, "errmsg", errmsg,
- sizeof(errmsg));
- build_iovec(&iov, &iovlen, "update", NULL, 0);
- build_iovec(&iov, &iovlen, "reload", NULL, 0);
- /*
- * XX: We need the following line until we clean up
- * nmount parsing of root mounts and NFS root mounts.
- */
- build_iovec(&iov, &iovlen, "ro", NULL, 0);
- if (nmount(iov, iovlen, mntp->f_flags) == 0) {
- return (0);
- }
- pwarn("mount reload of '%s' failed: %s %s\n\n",
- mntp->f_mntonname, strerror(errno), errmsg);
- return (1);
- }
- return (0);
-}
-
-/*
- * Get the mount point information for name.
- */
-static struct statfs *
-getmntpt(const char *name)
-{
- struct stat devstat, mntdevstat;
- char device[sizeof(_PATH_DEV) - 1 + MNAMELEN];
- char *ddevname;
- struct statfs *mntbuf, *statfsp;
- int i, mntsize, isdev;
-
- if (stat(name, &devstat) != 0)
- return (NULL);
- if (S_ISCHR(devstat.st_mode) || S_ISBLK(devstat.st_mode))
- isdev = 1;
- else
- isdev = 0;
- mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
- for (i = 0; i < mntsize; i++) {
- statfsp = &mntbuf[i];
- ddevname = statfsp->f_mntfromname;
- if (*ddevname != '/') {
- if (strlen(_PATH_DEV) + strlen(ddevname) + 1 >
- sizeof(statfsp->f_mntfromname))
- continue;
- strcpy(device, _PATH_DEV);
- strcat(device, ddevname);
- strcpy(statfsp->f_mntfromname, device);
- }
- if (isdev == 0) {
- if (strcmp(name, statfsp->f_mntonname))
- continue;
- return (statfsp);
- }
- if (stat(ddevname, &mntdevstat) == 0 &&
- mntdevstat.st_rdev == devstat.st_rdev)
- return (statfsp);
- }
- statfsp = NULL;
- return (statfsp);
-}
-
static void
usage(void)
{
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
index 319a324cc070..f4f97a38097b 100644
--- a/sbin/fsck_ffs/pass1.c
+++ b/sbin/fsck_ffs/pass1.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass1.c 8.6 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
@@ -56,7 +48,7 @@ static ufs2_daddr_t badblk;
static ufs2_daddr_t dupblk;
static ino_t lastino; /* last inode in use */
-static int checkinode(ino_t inumber, struct inodesc *, int rebuildcg);
+static int checkinode(ino_t inumber, struct inodesc *, int rebuiltcg);
void
pass1(void)
@@ -68,7 +60,7 @@ pass1(void)
ino_t inumber, inosused, mininos;
ufs2_daddr_t i, cgd;
u_int8_t *cp;
- int c, rebuildcg;
+ int c, rebuiltcg;
badblk = dupblk = lastino = 0;
@@ -99,10 +91,20 @@ pass1(void)
inumber = c * sblock.fs_ipg;
cgbp = cglookup(c);
cgp = cgbp->b_un.b_cg;
- rebuildcg = 0;
- if (!check_cgmagic(c, cgbp, 1))
- rebuildcg = 1;
- if (!rebuildcg && sblock.fs_magic == FS_UFS2_MAGIC) {
+ rebuiltcg = 0;
+ if (!check_cgmagic(c, cgbp)) {
+ if (!reply("REBUILD CYLINDER GROUP")) {
+ cgheader_corrupt = 1;
+ if (!nflag) {
+ pwarn("YOU WILL NEED TO RERUN FSCK.\n");
+ rerun = 1;
+ }
+ } else {
+ rebuild_cg(c, cgbp);
+ rebuiltcg = 1;
+ }
+ }
+ if (!rebuiltcg && sblock.fs_magic == FS_UFS2_MAGIC) {
inosused = cgp->cg_initediblk;
if (inosused > sblock.fs_ipg) {
pfatal("Too many initialized inodes (%ju > %d) "
@@ -132,7 +134,7 @@ pass1(void)
* to find the inodes that are really in use, and then
* read only those inodes in from disk.
*/
- if ((preen || inoopt) && usedsoftdep && !rebuildcg) {
+ if ((preen || inoopt) && usedsoftdep && !rebuiltcg) {
cp = &cg_inosused(cgp)[(inosused - 1) / CHAR_BIT];
for ( ; inosused != 0; cp--) {
if (*cp == 0) {
@@ -169,7 +171,7 @@ pass1(void)
setinodebuf(c, inosused);
for (i = 0; i < inosused; i++, inumber++) {
if (inumber < UFS_ROOTINO) {
- (void)getnextinode(inumber, rebuildcg);
+ (void)getnextinode(inumber, rebuiltcg);
continue;
}
/*
@@ -178,7 +180,7 @@ pass1(void)
* We always keep trying until we get to the minimum
* valid number for this cylinder group.
*/
- if (checkinode(inumber, &idesc, rebuildcg) == 0 &&
+ if (checkinode(inumber, &idesc, rebuiltcg) == 0 &&
i > cgp->cg_initediblk)
break;
}
@@ -189,7 +191,7 @@ pass1(void)
* fewer in use.
*/
mininos = roundup(inosused + INOPB(&sblock), INOPB(&sblock));
- if (inoopt && !preen && !rebuildcg &&
+ if (inoopt && !preen && !rebuiltcg &&
sblock.fs_magic == FS_UFS2_MAGIC &&
cgp->cg_initediblk > 2 * INOPB(&sblock) &&
mininos < cgp->cg_initediblk) {
@@ -209,7 +211,7 @@ pass1(void)
inosused = 0;
else
inosused = lastino - (c * sblock.fs_ipg);
- if (rebuildcg && inosused > cgp->cg_initediblk &&
+ if (rebuiltcg && inosused > cgp->cg_initediblk &&
sblock.fs_magic == FS_UFS2_MAGIC) {
cgp->cg_initediblk = roundup(inosused, INOPB(&sblock));
pwarn("CYLINDER GROUP %d: FOUND %d VALID INODES\n", c,
@@ -219,9 +221,10 @@ pass1(void)
* If we were not able to determine in advance which inodes
* were in use, then reduce the size of the inoinfo structure
* to the size necessary to describe the inodes that we
- * really found.
+ * really found. Always leave map space in the first cylinder
+ * group in case we need to a root or lost+found directory.
*/
- if (inumber == lastino)
+ if (inumber == lastino || c == 0)
continue;
inostathead[c].il_numalloced = inosused;
if (inosused == 0) {
@@ -241,18 +244,19 @@ pass1(void)
}
static int
-checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)
+checkinode(ino_t inumber, struct inodesc *idesc, int rebuiltcg)
{
struct inode ip;
union dinode *dp;
- off_t kernmaxfilesize;
ufs2_daddr_t ndb;
mode_t mode;
intmax_t size, fixsize;
int j, ret, offset;
- if ((dp = getnextinode(inumber, rebuildcg)) == NULL)
+ if ((dp = getnextinode(inumber, rebuiltcg)) == NULL) {
+ pfatal("INVALID INODE");
goto unknown;
+ }
mode = DIP(dp, di_mode) & IFMT;
if (mode == 0) {
if ((sblock.fs_magic == FS_UFS1_MAGIC &&
@@ -280,16 +284,8 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)
return (1);
}
lastino = inumber;
- /* This should match the file size limit in ffs_mountfs(). */
- if (sblock.fs_magic == FS_UFS1_MAGIC)
- kernmaxfilesize = (off_t)0x40000000 * sblock.fs_bsize - 1;
- else
- kernmaxfilesize = sblock.fs_maxfilesize;
- if (DIP(dp, di_size) > kernmaxfilesize ||
- DIP(dp, di_size) > sblock.fs_maxfilesize ||
- (mode == IFDIR && DIP(dp, di_size) > MAXDIRSIZE)) {
- if (debug)
- printf("bad size %ju:", (uintmax_t)DIP(dp, di_size));
+ if (chkfilesize(mode, DIP(dp, di_size)) == 0) {
+ pfatal("BAD FILE SIZE");
goto unknown;
}
if (!preen && mode == IFMT && reply("HOLD BAD BLOCK") == 1) {
@@ -305,19 +301,22 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)
if (debug)
printf("bad special-file size %ju:",
(uintmax_t)DIP(dp, di_size));
+ pfatal("BAD SPECIAL-FILE SIZE");
goto unknown;
}
if ((mode == IFBLK || mode == IFCHR) &&
(dev_t)DIP(dp, di_rdev) == NODEV) {
if (debug)
printf("bad special-file rdev NODEV:");
+ pfatal("BAD SPECIAL-FILE RDEV");
goto unknown;
}
ndb = howmany(DIP(dp, di_size), sblock.fs_bsize);
if (ndb < 0) {
if (debug)
- printf("bad size %ju ndb %ju:",
+ printf("negative size %ju ndb %ju:",
(uintmax_t)DIP(dp, di_size), (uintmax_t)ndb);
+ pfatal("NEGATIVE FILE SIZE");
goto unknown;
}
if (mode == IFBLK || mode == IFCHR)
@@ -342,33 +341,52 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)
}
}
}
- for (j = ndb; ndb < UFS_NDADDR && j < UFS_NDADDR; j++)
- if (DIP(dp, di_db[j]) != 0) {
- if (debug)
- printf("bad direct addr[%d]: %ju\n", j,
- (uintmax_t)DIP(dp, di_db[j]));
- goto unknown;
+ for (j = ndb; ndb < UFS_NDADDR && j < UFS_NDADDR; j++) {
+ if (DIP(dp, di_db[j]) == 0)
+ continue;
+ if (debug)
+ printf("invalid direct addr[%d]: %ju\n", j,
+ (uintmax_t)DIP(dp, di_db[j]));
+ pfatal("INVALID DIRECT BLOCK");
+ ginode(inumber, &ip);
+ prtinode(&ip);
+ if (reply("CLEAR") == 1) {
+ DIP_SET(ip.i_dp, di_db[j], 0);
+ inodirty(&ip);
}
+ irelse(&ip);
+ }
for (j = 0, ndb -= UFS_NDADDR; ndb > 0; j++)
ndb /= NINDIR(&sblock);
- for (; j < UFS_NIADDR; j++)
- if (DIP(dp, di_ib[j]) != 0) {
- if (debug)
- printf("bad indirect addr: %ju\n",
- (uintmax_t)DIP(dp, di_ib[j]));
- goto unknown;
+ for (; j < UFS_NIADDR; j++) {
+ if (DIP(dp, di_ib[j]) == 0)
+ continue;
+ if (debug)
+ printf("invalid indirect addr: %ju\n",
+ (uintmax_t)DIP(dp, di_ib[j]));
+ pfatal("INVALID INDIRECT BLOCK");
+ ginode(inumber, &ip);
+ prtinode(&ip);
+ if (reply("CLEAR") == 1) {
+ DIP_SET(ip.i_dp, di_ib[j], 0);
+ inodirty(&ip);
}
- if (ftypeok(dp) == 0)
+ irelse(&ip);
+ }
+ if (ftypeok(dp) == 0) {
+ pfatal("UNKNOWN FILE TYPE");
goto unknown;
+ }
n_files++;
inoinfo(inumber)->ino_linkcnt = DIP(dp, di_nlink);
if (mode == IFDIR) {
- if (DIP(dp, di_size) == 0)
+ if (DIP(dp, di_size) == 0) {
inoinfo(inumber)->ino_state = DCLEAR;
- else if (DIP(dp, di_nlink) <= 0)
+ } else if (DIP(dp, di_nlink) == 0) {
inoinfo(inumber)->ino_state = DZLINK;
- else
+ } else {
inoinfo(inumber)->ino_state = DSTATE;
+ }
cacheino(dp, inumber);
countdirs++;
} else if (DIP(dp, di_nlink) <= 0)
@@ -483,15 +501,14 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg)
}
return (1);
unknown:
- pfatal("UNKNOWN FILE TYPE I=%lu", (u_long)inumber);
- inoinfo(inumber)->ino_state = FCLEAR;
+ ginode(inumber, &ip);
+ prtinode(&ip);
+ inoinfo(inumber)->ino_state = USTATE;
if (reply("CLEAR") == 1) {
- inoinfo(inumber)->ino_state = USTATE;
- ginode(inumber, &ip);
clearinode(ip.i_dp);
inodirty(&ip);
- irelse(&ip);
}
+ irelse(&ip);
return (1);
}
diff --git a/sbin/fsck_ffs/pass1b.c b/sbin/fsck_ffs/pass1b.c
index 17a3b6495dc4..3fb9cab89078 100644
--- a/sbin/fsck_ffs/pass1b.c
+++ b/sbin/fsck_ffs/pass1b.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass1b.c 8.4 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <ufs/ufs/dinode.h>
@@ -88,10 +80,12 @@ pass1b(void)
if (inoinfo(inumber)->ino_state != USTATE &&
(ckinode(dp, &idesc) & STOP)) {
rerun = 1;
+ freeinodebuf();
return;
}
}
}
+ freeinodebuf();
}
static int
diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c
index 8632cf4878b1..1755a1295a9e 100644
--- a/sbin/fsck_ffs/pass2.c
+++ b/sbin/fsck_ffs/pass2.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass2.c 8.9 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -85,7 +77,7 @@ pass2(void)
case DCLEAR:
pfatal("DUPS/BAD IN ROOT INODE");
if (reply("REALLOCATE")) {
- freeino(UFS_ROOTINO);
+ freedirino(UFS_ROOTINO, UFS_ROOTINO);
if (allocdir(UFS_ROOTINO, UFS_ROOTINO, 0755) !=
UFS_ROOTINO)
errx(EEXIT, "CANNOT ALLOCATE ROOT INODE");
@@ -210,16 +202,18 @@ pass2(void)
if (inp->i_parent == 0 || inp->i_isize == 0)
continue;
if (inoinfo(inp->i_parent)->ino_state == DFOUND &&
- INO_IS_DUNFOUND(inp->i_number))
+ INO_IS_DUNFOUND(inp->i_number)) {
inoinfo(inp->i_number)->ino_state = DFOUND;
+ check_dirdepth(inp);
+ }
if (inp->i_dotdot == inp->i_parent ||
inp->i_dotdot == (ino_t)-1)
continue;
if (inp->i_dotdot == 0) {
inp->i_dotdot = inp->i_parent;
- fileerror(inp->i_parent, inp->i_number, "MISSING '..'");
- if (reply("FIX") == 0)
- continue;
+ if (debug)
+ fileerror(inp->i_parent, inp->i_number,
+ "DEFERRED MISSING '..' FIX");
(void)makeentry(inp->i_number, inp->i_parent, "..");
inoinfo(inp->i_parent)->ino_linkcnt--;
continue;
@@ -271,7 +265,8 @@ pass2(void)
inoinfo(inp->i_dotdot)->ino_linkcnt++;
inoinfo(inp->i_parent)->ino_linkcnt--;
inp->i_dotdot = inp->i_parent;
- (void)changeino(inp->i_number, "..", inp->i_parent);
+ (void)changeino(inp->i_number, "..", inp->i_parent,
+ getinoinfo(inp->i_parent)->i_depth + 1);
}
/*
* Mark all the directories that can be found from the root.
@@ -289,57 +284,62 @@ pass2check(struct inodesc *idesc)
struct inode ip;
union dinode *dp;
const char *errmsg;
- struct direct proto;
+ struct direct proto, *newdirp;
/*
* check for "."
*/
- if (dirp->d_ino > maxino)
- goto chk2;
if (idesc->id_entryno != 0)
goto chk1;
if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") == 0) {
if (dirp->d_ino != idesc->id_number) {
direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'");
- dirp->d_ino = idesc->id_number;
- if (reply("FIX") == 1)
+ if (reply("FIX") == 1) {
+ dirp->d_ino = idesc->id_number;
ret |= ALTERED;
+ }
}
if (dirp->d_type != DT_DIR) {
direrror(idesc->id_number, "BAD TYPE VALUE FOR '.'");
- dirp->d_type = DT_DIR;
- if (reply("FIX") == 1)
+ if (reply("FIX") == 1) {
+ dirp->d_type = DT_DIR;
ret |= ALTERED;
+ }
}
goto chk1;
}
- direrror(idesc->id_number, "MISSING '.'");
proto.d_ino = idesc->id_number;
proto.d_type = DT_DIR;
proto.d_namlen = 1;
(void)strcpy(proto.d_name, ".");
entrysize = DIRSIZ(0, &proto);
- if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) {
- pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
- dirp->d_name);
- } else if (dirp->d_reclen < entrysize) {
- pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n");
- } else if (dirp->d_reclen < 2 * entrysize) {
+ direrror(idesc->id_number, "MISSING '.'");
+ errmsg = "ADD '.' ENTRY";
+ if (dirp->d_reclen < entrysize + DIRSIZ(0, dirp)) {
+ /* Not enough space to add '.', replace first entry with '.' */
+ if (dirp->d_ino != 0) {
+ pwarn("\nFIRST ENTRY IN DIRECTORY CONTAINS %s\n",
+ dirp->d_name);
+ errmsg = "REPLACE WITH '.'";
+ }
+ if (reply(errmsg) == 0)
+ goto chk1;
proto.d_reclen = dirp->d_reclen;
memmove(dirp, &proto, (size_t)entrysize);
- if (reply("FIX") == 1)
- ret |= ALTERED;
+ ret |= ALTERED;
} else {
- n = dirp->d_reclen - entrysize;
+ /* Move over first entry and add '.' entry */
+ if (reply(errmsg) == 0)
+ goto chk1;
+ newdirp = (struct direct *)((char *)(dirp) + entrysize);
+ dirp->d_reclen -= entrysize;
+ memmove(newdirp, dirp, dirp->d_reclen);
proto.d_reclen = entrysize;
memmove(dirp, &proto, (size_t)entrysize);
idesc->id_entryno++;
- inoinfo(dirp->d_ino)->ino_linkcnt--;
- dirp = (struct direct *)((char *)(dirp) + entrysize);
- memset(dirp, 0, (size_t)n);
- dirp->d_reclen = n;
- if (reply("FIX") == 1)
- ret |= ALTERED;
+ inoinfo(idesc->id_number)->ino_linkcnt--;
+ dirp = newdirp;
+ ret |= ALTERED;
}
chk1:
if (idesc->id_entryno > 1)
@@ -363,6 +363,20 @@ chk1:
dirp->d_reclen = proto.d_reclen;
}
if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") == 0) {
+ if (dirp->d_ino >= maxino) {
+ direrror(idesc->id_number, "BAD INODE NUMBER FOR '..'");
+ /*
+ * If we know parent set it now, otherwise let it
+ * point to the root inode and it will get cleaned
+ * up later if that is not correct.
+ */
+ if (inp->i_parent != 0)
+ dirp->d_ino = inp->i_parent;
+ else
+ dirp->d_ino = UFS_ROOTINO;
+ if (reply("FIX") == 1)
+ ret |= ALTERED;
+ }
inp->i_dotdot = dirp->d_ino;
if (dirp->d_type != DT_DIR) {
direrror(idesc->id_number, "BAD TYPE VALUE FOR '..'");
@@ -372,30 +386,60 @@ chk1:
}
goto chk2;
}
- if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") != 0) {
- fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
- pfatal("CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS %s\n",
- dirp->d_name);
- inp->i_dotdot = (ino_t)-1;
- } else if (dirp->d_reclen < entrysize) {
- fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
- pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '..'\n");
- inp->i_dotdot = (ino_t)-1;
- } else if (inp->i_parent != 0) {
- /*
- * We know the parent, so fix now.
- */
- inp->i_dotdot = inp->i_parent;
- fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
+ fileerror(inp->i_parent != 0 ? inp->i_parent : idesc->id_number,
+ idesc->id_number, "MISSING '..'");
+ errmsg = "ADD '..' ENTRY";
+ if (dirp->d_reclen < entrysize + DIRSIZ(0, dirp)) {
+ /* No space to add '..', replace second entry with '..' */
+ if (dirp->d_ino != 0) {
+ pfatal("SECOND ENTRY IN DIRECTORY CONTAINS %s\n",
+ dirp->d_name);
+ errmsg = "REPLACE WITH '..'";
+ }
+ if (reply(errmsg) == 0) {
+ inp->i_dotdot = (ino_t)-1;
+ goto chk2;
+ }
+ if (proto.d_ino == 0) {
+ /* Defer processing until parent known */
+ idesc->id_entryno++;
+ if (debug)
+ printf("(FIX DEFERRED)\n");
+ }
+ inp->i_dotdot = proto.d_ino;
proto.d_reclen = dirp->d_reclen;
memmove(dirp, &proto, (size_t)entrysize);
- if (reply("FIX") == 1)
- ret |= ALTERED;
+ ret |= ALTERED;
+ } else {
+ /* Move over second entry and add '..' entry */
+ if (reply(errmsg) == 0) {
+ inp->i_dotdot = (ino_t)-1;
+ goto chk2;
+ }
+ if (proto.d_ino == 0) {
+ /* Defer processing until parent known */
+ idesc->id_entryno++;
+ if (debug)
+ printf("(FIX DEFERRED)\n");
+ }
+ inp->i_dotdot = proto.d_ino;
+ if (dirp->d_ino == 0) {
+ proto.d_reclen = dirp->d_reclen;
+ memmove(dirp, &proto, (size_t)entrysize);
+ } else {
+ newdirp = (struct direct *)((char *)(dirp) + entrysize);
+ dirp->d_reclen -= entrysize;
+ memmove(newdirp, dirp, dirp->d_reclen);
+ proto.d_reclen = entrysize;
+ memmove(dirp, &proto, (size_t)entrysize);
+ if (dirp->d_ino != 0) {
+ idesc->id_entryno++;
+ inoinfo(dirp->d_ino)->ino_linkcnt--;
+ }
+ dirp = newdirp;
+ }
+ ret |= ALTERED;
}
- idesc->id_entryno++;
- if (dirp->d_ino != 0)
- inoinfo(dirp->d_ino)->ino_linkcnt--;
- return (ret|KEEPON);
chk2:
if (dirp->d_ino == 0)
return (ret|KEEPON);
@@ -419,7 +463,7 @@ chk2:
}
idesc->id_entryno++;
n = 0;
- if (dirp->d_ino > maxino) {
+ if (dirp->d_ino >= maxino) {
fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE");
n = reply("REMOVE");
} else if (((dirp->d_ino == UFS_WINO && dirp->d_type != DT_WHT) ||
@@ -499,10 +543,12 @@ again:
case DFOUND:
inp = getinoinfo(dirp->d_ino);
if (idesc->id_entryno > 2) {
- if (inp->i_parent == 0)
+ if (inp->i_parent == 0) {
inp->i_parent = idesc->id_number;
- else if ((n = fix_extraneous(inp, idesc)) == 1)
+ check_dirdepth(inp);
+ } else if ((n = fix_extraneous(inp, idesc))) {
break;
+ }
}
/* FALLTHROUGH */
@@ -553,6 +599,7 @@ fix_extraneous(struct inoinfo *inp, struct inodesc *idesc)
if ((ckinode(ip.i_dp, &dotdesc) & FOUND))
inp->i_dotdot = dotdesc.id_parent;
irelse(&ip);
+ free(dotdesc.id_name);
}
/*
* We have the previously found old name (inp->i_parent) and the
diff --git a/sbin/fsck_ffs/pass3.c b/sbin/fsck_ffs/pass3.c
index 22cb0393905b..853f5d62382f 100644
--- a/sbin/fsck_ffs/pass3.c
+++ b/sbin/fsck_ffs/pass3.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass3.c 8.2 (Berkeley) 4/27/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <ufs/ufs/dinode.h>
@@ -74,7 +66,7 @@ pass3(void)
if (inp->i_number == UFS_ROOTINO ||
(inp->i_parent != 0 && !S_IS_DUNFOUND(state)))
continue;
- if (state == DCLEAR)
+ if (state == DCLEAR || state == DZLINK)
continue;
/*
* If we are running with soft updates and we come
@@ -100,9 +92,10 @@ pass3(void)
if (linkup(orphan, inp->i_dotdot, NULL)) {
inp->i_parent = inp->i_dotdot = lfdir;
inoinfo(lfdir)->ino_linkcnt--;
+ inoinfo(orphan)->ino_state = DFOUND;
+ check_dirdepth(inp);
+ propagate();
}
- inoinfo(orphan)->ino_state = DFOUND;
- propagate();
continue;
}
pfatal("ORPHANED DIRECTORY LOOP DETECTED I=%lu",
@@ -127,6 +120,7 @@ pass3(void)
}
irelse(&ip);
inoinfo(orphan)->ino_state = DFOUND;
+ check_dirdepth(inp);
propagate();
}
}
diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c
index cfcd36296887..a261051c432a 100644
--- a/sbin/fsck_ffs/pass4.c
+++ b/sbin/fsck_ffs/pass4.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass4.c 8.4 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c
index 324e725929f6..528a6956c4a1 100644
--- a/sbin/fsck_ffs/pass5.c
+++ b/sbin/fsck_ffs/pass5.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)pass5.c 8.9 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -47,7 +39,6 @@ __FBSDID("$FreeBSD$");
#include <inttypes.h>
#include <limits.h>
#include <string.h>
-#include <libufs.h>
#include "fsck.h"
@@ -116,7 +107,7 @@ pass5(void)
}
}
}
- basesize = &newcg->cg_space[0] - (u_char *)(&newcg->cg_firstfield);
+ basesize = sizeof(*newcg);
if (sblock.fs_magic == FS_UFS2_MAGIC) {
newcg->cg_iusedoff = basesize;
} else {
@@ -131,7 +122,7 @@ pass5(void)
fs->fs_old_cpg * sizeof(int32_t);
newcg->cg_iusedoff = newcg->cg_old_boff +
fs->fs_old_cpg * fs->fs_old_nrpos * sizeof(u_int16_t);
- memset(&newcg->cg_space[0], 0, newcg->cg_iusedoff - basesize);
+ memset(&newcg[1], 0, newcg->cg_iusedoff - basesize);
}
inomapsize = howmany(fs->fs_ipg, CHAR_BIT);
newcg->cg_freeoff = newcg->cg_iusedoff + inomapsize;
@@ -375,6 +366,22 @@ pass5(void)
if (cursnapshot == 0 &&
memcmp(&cstotal, &fs->fs_cstotal, sizeof cstotal) != 0
&& dofix(&idesc[0], "SUMMARY BLK COUNT(S) WRONG IN SUPERBLK")) {
+ if (debug) {
+ printf("cstotal is currently: %jd dirs, %jd blks free, "
+ "%jd frags free, %jd inos free, %jd clusters\n",
+ (intmax_t)fs->fs_cstotal.cs_ndir,
+ (intmax_t)fs->fs_cstotal.cs_nbfree,
+ (intmax_t)fs->fs_cstotal.cs_nffree,
+ (intmax_t)fs->fs_cstotal.cs_nifree,
+ (intmax_t)fs->fs_cstotal.cs_numclusters);
+ printf("cstotal ought to be: %jd dirs, %jd blks free, "
+ "%jd frags free, %jd inos free, %jd clusters\n",
+ (intmax_t)cstotal.cs_ndir,
+ (intmax_t)cstotal.cs_nbfree,
+ (intmax_t)cstotal.cs_nffree,
+ (intmax_t)cstotal.cs_nifree,
+ (intmax_t)cstotal.cs_numclusters);
+ }
memmove(&fs->fs_cstotal, &cstotal, sizeof cstotal);
fs->fs_ronly = 0;
fs->fs_fmod = 0;
@@ -395,43 +402,53 @@ pass5(void)
printf("adjndir by %+" PRIi64 "\n", cmd.value);
if (bkgrdsumadj == 0 || sysctl(adjndir, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
- rwerror("ADJUST NUMBER OF DIRECTORIES", cmd.value);
+ rwerror("ADJUST NUMBER OF DIRECTORIES",
+ cmd.value);
}
cmd.value = cstotal.cs_nbfree - fs->fs_cstotal.cs_nbfree;
if (cmd.value != 0) {
if (debug)
- printf("adjnbfree by %+" PRIi64 "\n", cmd.value);
+ printf("adjnbfree by %+" PRIi64 "\n",
+ cmd.value);
if (bkgrdsumadj == 0 || sysctl(adjnbfree, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
- rwerror("ADJUST NUMBER OF FREE BLOCKS", cmd.value);
+ rwerror("ADJUST NUMBER OF FREE BLOCKS",
+ cmd.value);
}
cmd.value = cstotal.cs_nifree - fs->fs_cstotal.cs_nifree;
if (cmd.value != 0) {
if (debug)
- printf("adjnifree by %+" PRIi64 "\n", cmd.value);
+ printf("adjnifree by %+" PRIi64 "\n",
+ cmd.value);
if (bkgrdsumadj == 0 || sysctl(adjnifree, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
- rwerror("ADJUST NUMBER OF FREE INODES", cmd.value);
+ rwerror("ADJUST NUMBER OF FREE INODES",
+ cmd.value);
}
cmd.value = cstotal.cs_nffree - fs->fs_cstotal.cs_nffree;
if (cmd.value != 0) {
if (debug)
- printf("adjnffree by %+" PRIi64 "\n", cmd.value);
+ printf("adjnffree by %+" PRIi64 "\n",
+ cmd.value);
if (bkgrdsumadj == 0 || sysctl(adjnffree, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
- rwerror("ADJUST NUMBER OF FREE FRAGS", cmd.value);
+ rwerror("ADJUST NUMBER OF FREE FRAGS",
+ cmd.value);
}
- cmd.value = cstotal.cs_numclusters - fs->fs_cstotal.cs_numclusters;
+ cmd.value = cstotal.cs_numclusters -
+ fs->fs_cstotal.cs_numclusters;
if (cmd.value != 0) {
if (debug)
- printf("adjnumclusters by %+" PRIi64 "\n", cmd.value);
- if (bkgrdsumadj == 0 || sysctl(adjnumclusters, MIBSIZE, 0, 0,
- &cmd, sizeof cmd) == -1)
- rwerror("ADJUST NUMBER OF FREE CLUSTERS", cmd.value);
+ printf("adjnumclusters by %+" PRIi64 "\n",
+ cmd.value);
+ if (bkgrdsumadj == 0 || sysctl(adjnumclusters, MIBSIZE,
+ 0, 0, &cmd, sizeof cmd) == -1)
+ rwerror("ADJUST NUMBER OF FREE CLUSTERS",
+ cmd.value);
}
}
}
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index 0f0d9b61a076..f10f02d159c3 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/disk.h>
#include <sys/stat.h>
@@ -54,19 +46,23 @@ __FBSDID("$FreeBSD$");
#include <limits.h>
#include <stdint.h>
#include <string.h>
-#include <libufs.h>
#include "fsck.h"
-struct inoinfo **inphead, **inpsort; /* info about all inodes */
+struct inohash *inphash; /* hash list of directory inode info */
+struct inoinfo **inpsort; /* disk order list of directory inodes */
+struct inode snaplist[FSMAXSNAP + 1]; /* list of active snapshots */
+int snapcnt; /* number of active snapshots */
+char *copybuf; /* buffer to copy snapshot blocks */
-struct bufarea asblk;
-#define altsblock (*asblk.b_un.b_fs)
+static int sbhashfailed;
#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
static int calcsb(char *dev, int devfd, struct fs *fs);
static void saverecovery(int readfd, int writefd);
static int chkrecovery(int devfd);
+static int getlbnblkno(struct inodesc *);
+static int checksnapinfo(struct inode *);
/*
* Read in a superblock finding an alternate if necessary.
@@ -76,39 +72,20 @@ static int chkrecovery(int devfd);
int
setup(char *dev)
{
- long cg, bmapsize;
- struct fs proto;
+ long i, bmapsize;
+ struct inode ip;
/*
- * We are expected to have an open file descriptor
- */
- if (fsreadfd < 0)
- return (0);
- /*
- * If we do not yet have a superblock, read it in looking
- * for alternates if necessary.
+ * We are expected to have an open file descriptor and a superblock.
*/
- if (havesb == 0 && readsb(1) == 0) {
- skipclean = 0;
- if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0)
- return(0);
- if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0)
- return (0);
- for (cg = 0; cg < proto.fs_ncg; cg++) {
- bflag = fsbtodb(&proto, cgsblock(&proto, cg));
- if (readsb(0) != 0)
- break;
- }
- if (cg >= proto.fs_ncg) {
- printf("SEARCH FOR ALTERNATE SUPER-BLOCK FAILED. "
- "YOU MUST USE THE\n-b OPTION TO FSCK TO SPECIFY "
- "THE LOCATION OF AN ALTERNATE\nSUPER-BLOCK TO "
- "SUPPLY NEEDED INFORMATION; SEE fsck_ffs(8).\n");
- bflag = 0;
- return(0);
+ if (fsreadfd < 0 || havesb == 0) {
+ if (debug) {
+ if (fsreadfd < 0)
+ printf("setup: missing fsreadfd\n");
+ else
+ printf("setup: missing superblock\n");
}
- pwarn("USING ALTERNATE SUPERBLOCK AT %jd\n", bflag);
- bflag = 0;
+ return (0);
}
if (preen == 0)
printf("** %s", dev);
@@ -163,10 +140,6 @@ setup(char *dev)
pfatal("from before 2002 with the command ``fsck -c 2''\n");
exit(EEXIT);
}
- if ((asblk.b_flags & B_DIRTY) != 0 && !bflag) {
- memmove(&altsblock, &sblock, (size_t)sblock.fs_sbsize);
- flush(fswritefd, &asblk);
- }
if (preen == 0 && yflag == 0 && sblock.fs_magic == FS_UFS2_MAGIC &&
fswritefd != -1 && chkrecovery(fsreadfd) == 0 &&
reply("SAVE DATA TO FIND ALTERNATE SUPERBLOCKS") != 0)
@@ -174,6 +147,7 @@ setup(char *dev)
/*
* allocate and initialize the necessary maps
*/
+ bufinit();
bmapsize = roundup(howmany(maxfsblock, CHAR_BIT), sizeof(short));
blockmap = Calloc((unsigned)bmapsize, sizeof (char));
if (blockmap == NULL) {
@@ -187,22 +161,57 @@ setup(char *dev)
(unsigned)(sizeof(struct inostatlist) * (sblock.fs_ncg)));
goto badsb;
}
- numdirs = MAX(sblock.fs_cstotal.cs_ndir, 128);
- dirhash = numdirs;
+ numdirs = sblock.fs_cstotal.cs_ndir;
+ dirhash = MAX(numdirs / 2, 1);
inplast = 0;
listmax = numdirs + 10;
inpsort = (struct inoinfo **)Calloc(listmax, sizeof(struct inoinfo *));
- inphead = (struct inoinfo **)Calloc(numdirs, sizeof(struct inoinfo *));
- if (inpsort == NULL || inphead == NULL) {
- printf("cannot alloc %ju bytes for inphead\n",
+ inphash = (struct inohash *)Calloc(dirhash, sizeof(struct inohash));
+ if (inpsort == NULL || inphash == NULL) {
+ printf("cannot alloc %ju bytes for inphash\n",
(uintmax_t)numdirs * sizeof(struct inoinfo *));
goto badsb;
}
- bufinit();
if (sblock.fs_flags & FS_DOSOFTDEP)
usedsoftdep = 1;
else
usedsoftdep = 0;
+ /*
+ * Collect any snapshot inodes so that we can allow them to
+ * claim any blocks that we free. The code for doing this is
+ * imported here and into inode.c from sys/ufs/ffs/ffs_snapshot.c.
+ */
+ for (snapcnt = 0; snapcnt < FSMAXSNAP; snapcnt++) {
+ if (sblock.fs_snapinum[snapcnt] == 0)
+ break;
+ ginode(sblock.fs_snapinum[snapcnt], &ip);
+ if ((DIP(ip.i_dp, di_mode) & IFMT) == IFREG &&
+ (DIP(ip.i_dp, di_flags) & SF_SNAPSHOT) != 0 &&
+ checksnapinfo(&ip)) {
+ if (debug)
+ printf("Load snapshot %jd\n",
+ (intmax_t)sblock.fs_snapinum[snapcnt]);
+ snaplist[snapcnt] = ip;
+ continue;
+ }
+ printf("Removing non-snapshot inode %ju from snapshot list\n",
+ (uintmax_t)sblock.fs_snapinum[snapcnt]);
+ irelse(&ip);
+ for (i = snapcnt + 1; i < FSMAXSNAP; i++) {
+ if (sblock.fs_snapinum[i] == 0)
+ break;
+ sblock.fs_snapinum[i - 1] = sblock.fs_snapinum[i];
+ }
+ sblock.fs_snapinum[i - 1] = 0;
+ snapcnt--;
+ sbdirty();
+ }
+ if (snapcnt > 0 && copybuf == NULL) {
+ copybuf = Balloc(sblock.fs_bsize);
+ if (copybuf == NULL)
+ errx(EEXIT, "cannot allocate space for snapshot "
+ "copy buffer");
+ }
return (1);
badsb:
@@ -211,6 +220,146 @@ badsb:
}
/*
+ * Check for valid snapshot information.
+ *
+ * Each snapshot has a list of blocks that have been copied. This list
+ * is consulted before checking the snapshot inode. Its purpose is to
+ * speed checking of commonly checked blocks and to avoid recursive
+ * checks of the snapshot inode. In particular, the list must contain
+ * the superblock, the superblock summary information, and all the
+ * cylinder group blocks. The list may contain other commonly checked
+ * pointers such as those of the blocks that contain the snapshot inodes.
+ * The list is sorted into block order to allow binary search lookup.
+ *
+ * The twelve direct direct block pointers of the snapshot are always
+ * copied, so we test for them first before checking the list itself
+ * (i.e., they are not in the list).
+ *
+ * The checksnapinfo() routine needs to ensure that the list contains at
+ * least the super block, its summary information, and the cylinder groups.
+ * Here we check the list first for the superblock, zero or more cylinder
+ * groups up to the location of the superblock summary information, the
+ * summary group information, and any remaining cylinder group maps that
+ * follow it. We skip over any other entries in the list.
+ */
+#define CHKBLKINLIST(chkblk) \
+ /* All UFS_NDADDR blocks are copied */ \
+ if ((chkblk) >= UFS_NDADDR) { \
+ /* Skip over blocks that are not of interest */ \
+ while (*blkp < (chkblk) && blkp < lastblkp) \
+ blkp++; \
+ /* Fail if end of list and not all blocks found */ \
+ if (blkp >= lastblkp) { \
+ pwarn("UFS%d snapshot inode %jd failed: " \
+ "improper block list length (%jd)\n", \
+ sblock.fs_magic == FS_UFS1_MAGIC ? 1 : 2, \
+ (intmax_t)snapip->i_number, \
+ (intmax_t)(lastblkp - &snapblklist[0])); \
+ status = 0; \
+ } \
+ /* Fail if block we seek is missing */ \
+ else if (*blkp++ != (chkblk)) { \
+ pwarn("UFS%d snapshot inode %jd failed: " \
+ "block list (%jd) != %s (%jd)\n", \
+ sblock.fs_magic == FS_UFS1_MAGIC ? 1 : 2, \
+ (intmax_t)snapip->i_number, \
+ (intmax_t)blkp[-1], #chkblk, \
+ (intmax_t)chkblk); \
+ status = 0; \
+ } \
+ }
+
+static int
+checksnapinfo(struct inode *snapip)
+{
+ struct fs *fs;
+ struct bufarea *bp;
+ struct inodesc idesc;
+ daddr_t *snapblklist, *blkp, *lastblkp, csblkno;
+ int cg, loc, len, status;
+ ufs_lbn_t lbn;
+ size_t size;
+
+ fs = &sblock;
+ memset(&idesc, 0, sizeof(struct inodesc));
+ idesc.id_type = ADDR;
+ idesc.id_func = getlbnblkno;
+ idesc.id_number = snapip->i_number;
+ lbn = howmany(fs->fs_size, fs->fs_frag);
+ idesc.id_parent = lbn; /* sought after blkno */
+ if ((ckinode(snapip->i_dp, &idesc) & FOUND) == 0)
+ return (0);
+ size = fragroundup(fs,
+ DIP(snapip->i_dp, di_size) - lblktosize(fs, lbn));
+ bp = getdatablk(idesc.id_parent, size, BT_DATA);
+ if (bp->b_errs != 0)
+ return (0);
+ snapblklist = (daddr_t *)bp->b_un.b_buf;
+ /*
+ * snapblklist[0] is the size of the list
+ * snapblklist[1] is the first element of the list
+ *
+ * We need to be careful to bound the size of the list and verify
+ * that we have not run off the end of it if it or its size has
+ * been corrupted.
+ */
+ blkp = &snapblklist[1];
+ lastblkp = &snapblklist[MAX(0,
+ MIN(snapblklist[0] + 1, size / sizeof(daddr_t)))];
+ status = 1;
+ /* Check that the superblock is listed. */
+ CHKBLKINLIST(lblkno(fs, fs->fs_sblockloc));
+ if (status == 0)
+ goto out;
+ /*
+ * Calculate where the summary information is located.
+ * Usually it is in the first cylinder group, but growfs
+ * may move it to the first cylinder group that it adds.
+ *
+ * Check all cylinder groups up to the summary information.
+ */
+ csblkno = fragstoblks(fs, fs->fs_csaddr);
+ for (cg = 0; cg < fs->fs_ncg; cg++) {
+ if (fragstoblks(fs, cgtod(fs, cg)) > csblkno)
+ break;
+ CHKBLKINLIST(fragstoblks(fs, cgtod(fs, cg)));
+ if (status == 0)
+ goto out;
+ }
+ /* Check the summary information block(s). */
+ len = howmany(fs->fs_cssize, fs->fs_bsize);
+ for (loc = 0; loc < len; loc++) {
+ CHKBLKINLIST(csblkno + loc);
+ if (status == 0)
+ goto out;
+ }
+ /* Check the remaining cylinder groups. */
+ for (; cg < fs->fs_ncg; cg++) {
+ CHKBLKINLIST(fragstoblks(fs, cgtod(fs, cg)));
+ if (status == 0)
+ goto out;
+ }
+out:
+ brelse(bp);
+ return (status);
+}
+
+/*
+ * Return the block number associated with a specified inode lbn.
+ * Requested lbn is in id_parent. If found, block is returned in
+ * id_parent.
+ */
+static int
+getlbnblkno(struct inodesc *idesc)
+{
+
+ if (idesc->id_lbn < idesc->id_parent)
+ return (KEEPON);
+ idesc->id_parent = idesc->id_blkno;
+ return (STOP | FOUND);
+}
+
+/*
* Open a device or file to be checked by fsck.
*/
int
@@ -224,14 +373,14 @@ openfilesys(char *dev)
if ((statb.st_mode & S_IFMT) != S_IFCHR &&
(statb.st_mode & S_IFMT) != S_IFBLK) {
if (bkgrdflag != 0 && (statb.st_flags & SF_SNAPSHOT) == 0) {
- pfatal("BACKGROUND FSCK LACKS A SNAPSHOT\n");
- exit(EEXIT);
+ pwarn("BACKGROUND FSCK LACKS A SNAPSHOT\n");
+ return (0);
}
if (bkgrdflag != 0) {
cursnapshot = statb.st_ino;
} else {
- pfatal("%s IS NOT A DISK DEVICE\n", dev);
- if (reply("CONTINUE") == 0)
+ pwarn("%s IS NOT A DISK DEVICE\n", dev);
+ if (preen || reply("CONTINUE") == 0)
return (0);
}
}
@@ -249,38 +398,64 @@ openfilesys(char *dev)
* Read in the super block and its summary info.
*/
int
-readsb(int listerr)
+readsb(void)
{
- off_t super;
- int bad, ret;
struct fs *fs;
- super = bflag ? bflag * dev_bsize :
- sbhashfailed ? STDSB_NOHASHFAIL_NOMSG : STDSB_NOMSG;
+ sbhashfailed = 0;
readcnt[sblk.b_type]++;
- while ((ret = sbget(fsreadfd, &fs, super)) != 0) {
- switch (ret) {
+ /*
+ * If bflag is given, then check just that superblock.
+ */
+ if (bflag) {
+ switch (sbget(fsreadfd, &fs, bflag * dev_bsize, 0)) {
+ case 0:
+ goto goodsb;
case EINTEGRITY:
- if (bflag || super == STDSB_NOHASHFAIL_NOMSG)
- return (0);
- super = STDSB_NOHASHFAIL_NOMSG;
- sbhashfailed = 1;
- continue;
+ printf("Check hash failed for superblock at %jd\n",
+ bflag);
+ return (0);
case ENOENT:
- if (bflag)
- printf("%jd is not a file system "
- "superblock\n", super / dev_bsize);
- else
- printf("Cannot find file system "
- "superblock\n");
+ printf("%jd is not a file system superblock\n", bflag);
return (0);
case EIO:
default:
- printf("I/O error reading %jd\n",
- super / dev_bsize);
+ printf("I/O error reading %jd\n", bflag);
return (0);
}
}
+ /*
+ * Check for the standard superblock and use it if good.
+ */
+ if (sbget(fsreadfd, &fs, UFS_STDSB, UFS_NOMSG) == 0)
+ goto goodsb;
+ /*
+ * Check if the only problem is a check-hash failure.
+ */
+ skipclean = 0;
+ if (sbget(fsreadfd, &fs, UFS_STDSB, UFS_NOMSG | UFS_NOHASHFAIL) == 0) {
+ sbhashfailed = 1;
+ goto goodsb;
+ }
+ /*
+ * Do an exhaustive search for a usable superblock.
+ */
+ switch (sbsearch(fsreadfd, &fs, 0)) {
+ case 0:
+ goto goodsb;
+ case ENOENT:
+ printf("SEARCH FOR ALTERNATE SUPER-BLOCK FAILED. "
+ "YOU MUST USE THE\n-b OPTION TO FSCK TO SPECIFY "
+ "THE LOCATION OF AN ALTERNATE\nSUPER-BLOCK TO "
+ "SUPPLY NEEDED INFORMATION; SEE fsck_ffs(8).\n");
+ return (0);
+ case EIO:
+ default:
+ printf("I/O error reading a usable superblock\n");
+ return (0);
+ }
+
+goodsb:
memcpy(&sblock, fs, fs->fs_sbsize);
free(fs);
/*
@@ -292,58 +467,6 @@ readsb(int listerr)
sblk.b_bno = sblock.fs_sblockactualloc / dev_bsize;
sblk.b_size = SBLOCKSIZE;
/*
- * Compare all fields that should not differ in alternate super block.
- * When an alternate super-block is specified this check is skipped.
- */
- if (bflag)
- goto out;
- getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1), sblock.fs_sbsize);
- if (asblk.b_errs)
- return (0);
- bad = 0;
-#define CHK(x, y) \
- if (altsblock.x != sblock.x) { \
- bad++; \
- if (listerr && debug) \
- printf("SUPER BLOCK VS ALTERNATE MISMATCH %s: " y " vs " y "\n", \
- #x, (intmax_t)sblock.x, (intmax_t)altsblock.x); \
- }
- CHK(fs_sblkno, "%jd");
- CHK(fs_cblkno, "%jd");
- CHK(fs_iblkno, "%jd");
- CHK(fs_dblkno, "%jd");
- CHK(fs_ncg, "%jd");
- CHK(fs_bsize, "%jd");
- CHK(fs_fsize, "%jd");
- CHK(fs_frag, "%jd");
- CHK(fs_bmask, "%#jx");
- CHK(fs_fmask, "%#jx");
- CHK(fs_bshift, "%jd");
- CHK(fs_fshift, "%jd");
- CHK(fs_fragshift, "%jd");
- CHK(fs_fsbtodb, "%jd");
- CHK(fs_sbsize, "%jd");
- CHK(fs_nindir, "%jd");
- CHK(fs_inopb, "%jd");
- CHK(fs_cssize, "%jd");
- CHK(fs_ipg, "%jd");
- CHK(fs_fpg, "%jd");
- CHK(fs_magic, "%#jx");
-#undef CHK
- if (bad) {
- if (listerr == 0)
- return (0);
- if (preen)
- printf("%s: ", cdevname);
- printf(
- "VALUES IN SUPER BLOCK LSB=%jd DISAGREE WITH THOSE IN\n"
- "LAST ALTERNATE LSB=%jd\n",
- sblk.b_bno, asblk.b_bno);
- if (reply("IGNORE ALTERNATE SUPER BLOCK") == 0)
- return (0);
- }
-out:
- /*
* If not yet done, update UFS1 superblock with new wider fields.
*/
if (sblock.fs_magic == FS_UFS1_MAGIC &&
@@ -371,10 +494,8 @@ sblock_init(void)
fsmodified = 0;
lfdir = 0;
initbarea(&sblk, BT_SUPERBLK);
- initbarea(&asblk, BT_SUPERBLK);
- sblk.b_un.b_buf = Malloc(SBLOCKSIZE);
- asblk.b_un.b_buf = Malloc(SBLOCKSIZE);
- if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
+ sblk.b_un.b_buf = Balloc(SBLOCKSIZE);
+ if (sblk.b_un.b_buf == NULL)
errx(EEXIT, "cannot allocate space for superblock");
dev_bsize = secsize = DEV_BSIZE;
}
@@ -402,7 +523,7 @@ calcsb(char *dev, int devfd, struct fs *fs)
*/
if (ioctl(devfd, DIOCGSECTORSIZE, &secsize) == -1)
return (0);
- fsrbuf = Malloc(secsize);
+ fsrbuf = Balloc(secsize);
if (fsrbuf == NULL)
errx(EEXIT, "calcsb: cannot allocate recovery buffer");
if (blread(devfd, fsrbuf,
@@ -445,7 +566,7 @@ chkrecovery(int devfd)
rdsize = sblock.fs_fsize;
if (ioctl(devfd, DIOCGSECTORSIZE, &secsize) == -1 ||
rdsize % secsize != 0 ||
- (fsrbuf = Malloc(rdsize)) == NULL ||
+ (fsrbuf = Balloc(rdsize)) == NULL ||
blread(devfd, fsrbuf, (SBLOCK_UFS2 - rdsize) / dev_bsize,
rdsize) != 0) {
free(fsrbuf);
@@ -484,7 +605,7 @@ saverecovery(int readfd, int writefd)
if (sblock.fs_magic != FS_UFS2_MAGIC ||
ioctl(readfd, DIOCGSECTORSIZE, &secsize) == -1 ||
rdsize % secsize != 0 ||
- (fsrbuf = Malloc(rdsize)) == NULL ||
+ (fsrbuf = Balloc(rdsize)) == NULL ||
blread(readfd, fsrbuf, (SBLOCK_UFS2 - rdsize) / dev_bsize,
rdsize) != 0) {
printf("RECOVERY DATA COULD NOT BE CREATED\n");
diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c
index 4ad86b0dc14d..73be60c5e5b4 100644
--- a/sbin/fsck_ffs/suj.c
+++ b/sbin/fsck_ffs/suj.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright 2009, 2010 Jeffrey W. Roberson <jeff@FreeBSD.org>
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/disk.h>
#include <sys/disklabel.h>
@@ -49,7 +46,6 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
-#include <libufs.h>
#include <string.h>
#include <strings.h>
#include <sysexits.h>
@@ -115,6 +111,7 @@ static TAILQ_HEAD(seghd, suj_seg) allsegs;
static uint64_t oldseq;
static struct fs *fs = NULL;
static ino_t sujino;
+static char *joptype[JOP_NUMJOPTYPES] = JOP_NAMES;
/*
* Summary statistics.
@@ -183,7 +180,7 @@ cg_lookup(int cgx)
if (lastcg && lastcg->sc_cgx == cgx)
return (lastcg);
cgbp = cglookup(cgx);
- if (!check_cgmagic(cgx, cgbp, 0))
+ if (!check_cgmagic(cgx, cgbp))
err_suj("UNABLE TO REBUILD CYLINDER GROUP %d", cgx);
hd = &cghash[HASH(cgx)];
LIST_FOREACH(sc, hd, sc_next)
@@ -321,7 +318,7 @@ blk_freemask(ufs2_daddr_t blk, ino_t ino, ufs_lbn_t lbn, int frags)
* To be certain we're not freeing a reallocated block we lookup
* this block in the blk hash and see if there is an allocation
* journal record that overlaps with any fragments in the block
- * we're concerned with. If any fragments have ben reallocated
+ * we're concerned with. If any fragments have been reallocated
* the block has already been freed and re-used for another purpose.
*/
mask = 0;
@@ -379,6 +376,50 @@ blk_isindir(ufs2_daddr_t blk, ino_t ino, ufs_lbn_t lbn)
}
/*
+ * Check to see if the requested block is available.
+ * We can just check in the cylinder-group maps as
+ * they will only have usable blocks in them.
+ */
+ufs2_daddr_t
+suj_checkblkavail(ufs2_daddr_t blkno, long frags)
+{
+ struct bufarea *cgbp;
+ struct cg *cgp;
+ ufs2_daddr_t j, k, baseblk;
+ long cg;
+
+ if ((u_int64_t)blkno > sblock.fs_size)
+ return (0);
+ cg = dtog(&sblock, blkno);
+ cgbp = cglookup(cg);
+ cgp = cgbp->b_un.b_cg;
+ if (!check_cgmagic(cg, cgbp))
+ return (-((cg + 1) * sblock.fs_fpg - sblock.fs_frag));
+ baseblk = dtogd(&sblock, blkno);
+ for (j = 0; j <= sblock.fs_frag - frags; j++) {
+ if (!isset(cg_blksfree(cgp), baseblk + j))
+ continue;
+ for (k = 1; k < frags; k++)
+ if (!isset(cg_blksfree(cgp), baseblk + j + k))
+ break;
+ if (k < frags) {
+ j += k;
+ continue;
+ }
+ for (k = 0; k < frags; k++)
+ clrbit(cg_blksfree(cgp), baseblk + j + k);
+ n_blks += frags;
+ if (frags == sblock.fs_frag)
+ cgp->cg_cs.cs_nbfree--;
+ else
+ cgp->cg_cs.cs_nffree -= frags;
+ cgdirty(cgbp);
+ return ((cg * sblock.fs_fpg) + baseblk + j);
+ }
+ return (0);
+}
+
+/*
* Clear an inode from the cg bitmap. If the inode was already clear return
* 0 so the caller knows it does not have to check the inode contents.
*/
@@ -420,7 +461,7 @@ ino_free(ino_t ino, int mode)
* set in the mask.
*/
static void
-blk_free(ufs2_daddr_t bno, int mask, int frags)
+blk_free(ino_t ino, ufs2_daddr_t bno, int mask, int frags)
{
ufs1_daddr_t fragno, cgbno;
struct suj_cg *sc;
@@ -431,6 +472,13 @@ blk_free(ufs2_daddr_t bno, int mask, int frags)
if (debug)
printf("Freeing %d frags at blk %jd mask 0x%x\n",
frags, bno, mask);
+ /*
+ * Check to see if the block needs to be claimed by a snapshot.
+ * If wanted, the snapshot references it. Otherwise we free it.
+ */
+ if (snapblkfree(fs, bno, lfragtosize(fs, frags), ino,
+ suj_checkblkavail))
+ return;
cg = dtog(fs, bno);
sc = cg_lookup(cg);
cgp = sc->sc_cgp;
@@ -451,7 +499,8 @@ blk_free(ufs2_daddr_t bno, int mask, int frags)
* deallocate the fragment
*/
for (i = 0; i < frags; i++)
- if ((mask & (1 << i)) == 0 && isclr(blksfree, cgbno +i)) {
+ if ((mask & (1 << i)) == 0 &&
+ isclr(blksfree, cgbno +i)) {
freefrags++;
setbit(blksfree, cgbno + i);
}
@@ -685,7 +734,7 @@ indir_visit(ino_t ino, ufs_lbn_t lbn, ufs2_daddr_t blk, uint64_t *frags,
lbnadd *= NINDIR(fs);
bp = getdatablk(blk, fs->fs_bsize, BT_LEVEL1 + level);
if (bp->b_errs != 0)
- err_suj("indir_visit: UNRECOVERABLE I/O ERROR");
+ err_suj("indir_visit: UNRECOVERABLE I/O ERROR\n");
for (i = 0; i < NINDIR(fs); i++) {
if ((nblk = IBLK(bp, i)) == 0)
continue;
@@ -846,7 +895,7 @@ static void
blk_free_visit(ino_t ino, ufs_lbn_t lbn, ufs2_daddr_t blk, int frags)
{
- blk_free(blk, blk_freemask(blk, ino, lbn, frags), frags);
+ blk_free(ino, blk, blk_freemask(blk, ino, lbn, frags), frags);
}
/*
@@ -865,7 +914,7 @@ blk_free_lbn(ufs2_daddr_t blk, ino_t ino, ufs_lbn_t lbn, int frags, int follow)
if (lbn <= -UFS_NDADDR && follow && mask == 0)
indir_visit(ino, lbn, blk, &resid, blk_free_visit, VISIT_INDIR);
else
- blk_free(blk, mask, frags);
+ blk_free(ino, blk, mask, frags);
}
static void
@@ -997,6 +1046,8 @@ ino_reclaim(struct inode *ip, ino_t ino, int mode)
if ((DIP(dp, di_mode) & IFMT) == IFDIR)
ino_visit(dp, ino, ino_free_children, 0);
DIP_SET(dp, di_nlink, 0);
+ if ((DIP(dp, di_flags) & SF_SNAPSHOT) != 0)
+ snapremove(ino);
ino_visit(dp, ino, blk_free_visit, VISIT_EXT | VISIT_INDIR);
/* Here we have to clear the inode and release any blocks it holds. */
gen = DIP(dp, di_gen);
@@ -1209,7 +1260,7 @@ indir_trunc(ino_t ino, ufs_lbn_t lbn, ufs2_daddr_t blk, ufs_lbn_t lastlbn,
continue;
}
isdirty = 1;
- blk_free(nblk, 0, fs->fs_frag);
+ blk_free(ino, nblk, 0, fs->fs_frag);
IBLK_SET(bp, i, 0);
}
if (isdirty)
@@ -1245,9 +1296,14 @@ ino_trunc(ino_t ino, off_t size)
dp = ip.i_dp;
mode = DIP(dp, di_mode) & IFMT;
cursize = DIP(dp, di_size);
+ /* If no size change, nothing to do */
+ if (size == cursize) {
+ irelse(&ip);
+ return;
+ }
if (debug)
- printf("Truncating ino %ju, mode %o to size %jd from size %jd\n",
- (uintmax_t)ino, mode, size, cursize);
+ printf("Truncating ino %ju, mode %o to size %jd from "
+ "size %jd\n", (uintmax_t)ino, mode, size, cursize);
/* Skip datablocks for short links and devices. */
if (mode == 0 || mode == IFBLK || mode == IFCHR ||
@@ -1264,13 +1320,14 @@ ino_trunc(ino_t ino, off_t size)
if (size > 0)
err_suj("Partial truncation of ino %ju snapshot file\n",
(uintmax_t)ino);
+ snapremove(ino);
}
lastlbn = lblkno(fs, blkroundup(fs, size));
for (i = lastlbn; i < UFS_NDADDR; i++) {
if ((bn = DIP(dp, di_db[i])) == 0)
continue;
blksize = sblksize(fs, cursize, i);
- blk_free(bn, 0, numfrags(fs, blksize));
+ blk_free(ino, bn, 0, numfrags(fs, blksize));
DIP_SET(dp, di_db[i], 0);
}
/*
@@ -1283,13 +1340,13 @@ ino_trunc(ino_t ino, off_t size)
/* If we're not freeing any in this indirect range skip it. */
if (lastlbn >= nextlbn)
continue;
- if (DIP(dp, di_ib[i]) == 0)
- continue;
- indir_trunc(ino, -lbn - i, DIP(dp, di_ib[i]), lastlbn, dp);
- /* If we freed everything in this indirect free the indir. */
- if (lastlbn > lbn)
- continue;
- blk_free(DIP(dp, di_ib[i]), 0, fs->fs_frag);
+ if ((bn = DIP(dp, di_ib[i])) == 0)
+ continue;
+ indir_trunc(ino, -lbn - i, bn, lastlbn, dp);
+ /* If we freed everything in this indirect free the indir. */
+ if (lastlbn > lbn)
+ continue;
+ blk_free(ino, bn, 0, fs->fs_frag);
DIP_SET(dp, di_ib[i], 0);
}
/*
@@ -1319,7 +1376,7 @@ ino_trunc(ino_t ino, off_t size)
if (oldspace != newspace) {
bn += numfrags(fs, newspace);
frags = numfrags(fs, oldspace - newspace);
- blk_free(bn, 0, frags);
+ blk_free(ino, bn, 0, frags);
totalfrags -= frags;
}
}
@@ -1386,9 +1443,9 @@ ino_check(struct suj_ino *sino)
err_suj("Inode mode/directory type mismatch %o != %o\n",
mode, rrec->jr_mode);
if (debug)
- printf("jrefrec: op %d ino %ju, nlink %ju, parent %ju, "
+ printf("jrefrec: op %s ino %ju, nlink %ju, parent %ju, "
"diroff %jd, mode %o, isat %d, isdot %d\n",
- rrec->jr_op, (uintmax_t)rrec->jr_ino,
+ JOP_OPTYPE(rrec->jr_op), (uintmax_t)rrec->jr_ino,
(uintmax_t)rrec->jr_nlink,
(uintmax_t)rrec->jr_parent,
(uintmax_t)rrec->jr_diroff,
@@ -1452,9 +1509,10 @@ blk_check(struct suj_blk *sblk)
sino->si_blkadj = 1;
}
if (debug)
- printf("op %d blk %jd ino %ju lbn %jd frags %d isat %d (%d)\n",
- brec->jb_op, blk, (uintmax_t)brec->jb_ino,
- brec->jb_lbn, brec->jb_frags, isat, frags);
+ printf("op %s blk %jd ino %ju lbn %jd frags %d isat %d "
+ "(%d)\n", JOP_OPTYPE(brec->jb_op), blk,
+ (uintmax_t)brec->jb_ino, brec->jb_lbn,
+ brec->jb_frags, isat, frags);
/*
* If we found the block at this address we still have to
* determine if we need to free the tail end that was
@@ -1468,7 +1526,7 @@ blk_check(struct suj_blk *sblk)
mask >>= frags;
blk += frags;
frags = brec->jb_frags - frags;
- blk_free(blk, mask, frags);
+ blk_free(brec->jb_ino, blk, mask, frags);
continue;
}
/*
@@ -1636,9 +1694,9 @@ ino_append(union jrec *rec)
(uintmax_t)mvrec->jm_newoff, (uintmax_t)mvrec->jm_oldoff);
else if (debug &&
(refrec->jr_op == JOP_ADDREF || refrec->jr_op == JOP_REMREF))
- printf("ino ref: op %d, ino %ju, nlink %ju, "
+ printf("ino ref: op %s, ino %ju, nlink %ju, "
"parent %ju, diroff %jd\n",
- refrec->jr_op, (uintmax_t)refrec->jr_ino,
+ JOP_OPTYPE(refrec->jr_op), (uintmax_t)refrec->jr_ino,
(uintmax_t)refrec->jr_nlink,
(uintmax_t)refrec->jr_parent, (uintmax_t)refrec->jr_diroff);
sino = ino_lookup(((struct jrefrec *)rec)->jr_ino, 1);
@@ -1798,8 +1856,8 @@ ino_build_ref(struct suj_ino *sino, struct suj_rec *srec)
TAILQ_REMOVE(&sino->si_newrecs, srn, sr_next);
break;
default:
- err_suj("ino_build_ref: Unknown op %d\n",
- srn->sr_rec->rec_jrefrec.jr_op);
+ err_suj("ino_build_ref: Unknown op %s\n",
+ JOP_OPTYPE(srn->sr_rec->rec_jrefrec.jr_op));
}
}
ino_add_ref(sino, srec);
@@ -1828,8 +1886,8 @@ ino_build(struct suj_ino *sino)
TAILQ_INSERT_TAIL(&sino->si_movs, srec, sr_next);
break;
default:
- err_suj("ino_build: Unknown op %d\n",
- srec->sr_rec->rec_jrefrec.jr_op);
+ err_suj("ino_build: Unknown op %s\n",
+ JOP_OPTYPE(srec->sr_rec->rec_jrefrec.jr_op));
}
}
if (TAILQ_EMPTY(&sino->si_recs))
@@ -1851,14 +1909,17 @@ blk_build(struct jblkrec *blkrec)
int frag;
if (debug)
- printf("blk_build: op %d blkno %jd frags %d oldfrags %d "
+ printf("blk_build: op %s blkno %jd frags %d oldfrags %d "
"ino %ju lbn %jd\n",
- blkrec->jb_op, (uintmax_t)blkrec->jb_blkno,
+ JOP_OPTYPE(blkrec->jb_op), (uintmax_t)blkrec->jb_blkno,
blkrec->jb_frags, blkrec->jb_oldfrags,
(uintmax_t)blkrec->jb_ino, (uintmax_t)blkrec->jb_lbn);
blk = blknum(fs, blkrec->jb_blkno);
frag = fragnum(fs, blkrec->jb_blkno);
+ if (blkrec->jb_blkno < 0 || blk + fs->fs_frag - frag > fs->fs_size)
+ err_suj("Out-of-bounds journal block number %jd\n",
+ blkrec->jb_blkno);
sblk = blk_lookup(blk, 1);
/*
* Rewrite the record using oldfrags to indicate the offset into
@@ -1906,6 +1967,9 @@ ino_build_trunc(struct jtrncrec *rec)
printf("ino_build_trunc: op %d ino %ju, size %jd\n",
rec->jt_op, (uintmax_t)rec->jt_ino,
(uintmax_t)rec->jt_size);
+ if (chkfilesize(IFREG, rec->jt_size) == 0)
+ err_suj("ino_build: truncation size too large %ju\n",
+ (intmax_t)rec->jt_size);
sino = ino_lookup(rec->jt_ino, 1);
if (rec->jt_op == JOP_SYNC) {
sino->si_trunc = NULL;
@@ -1952,8 +2016,8 @@ suj_build(void)
ino_build_trunc((struct jtrncrec *)rec);
break;
default:
- err_suj("Unknown journal operation %d (%d)\n",
- rec->rec_jrefrec.jr_op, off);
+ err_suj("Unknown journal operation %s at %d\n",
+ JOP_OPTYPE(rec->rec_jrefrec.jr_op), off);
}
i++;
}
@@ -2067,7 +2131,9 @@ suj_verifyino(union dinode *dp)
}
if (DIP(dp, di_modrev) != fs->fs_mtime) {
- printf("Journal timestamp does not match fs mount time\n");
+ if (!bkgrdcheck || debug)
+ printf("Journal timestamp does not match "
+ "fs mount time\n");
return (-1);
}
@@ -2194,7 +2260,7 @@ jblocks_add(struct jblocks *jblocks, ufs2_daddr_t daddr, int blocks)
/*
* Add a file block from the journal to the extent map. We can't read
* each file block individually because the kernel treats it as a circular
- * buffer and segments may span mutliple contiguous blocks.
+ * buffer and segments may span multiple contiguous blocks.
*/
static void
suj_add_block(ino_t ino, ufs_lbn_t lbn, ufs2_daddr_t blk, int frags)
@@ -2206,7 +2272,7 @@ suj_add_block(ino_t ino, ufs_lbn_t lbn, ufs2_daddr_t blk, int frags)
static void
suj_read(void)
{
- uint8_t block[1 * 1024 * 1024];
+ uint8_t block[1 * 1024 * 1024] __aligned(LIBUFS_BUFALIGN);
struct suj_seg *seg;
struct jsegrec *recn;
struct jsegrec *rec;
@@ -2270,8 +2336,8 @@ restart:
recsize <= fs->fs_bsize)
goto restart;
if (debug)
- printf("Found invalid segsize %d > %d\n",
- recsize, size);
+ printf("Found invalid segsize "
+ "%d > %d\n", recsize, size);
recsize = real_dev_bsize;
jblocks_advance(suj_jblocks, recsize);
continue;
@@ -2312,7 +2378,7 @@ suj_check(const char *filesys)
{
struct inodesc idesc;
struct csum *cgsum;
- union dinode *jip;
+ union dinode *dp, *jip;
struct inode ip;
uint64_t blocks;
int i, retval;
@@ -2354,11 +2420,23 @@ suj_check(const char *filesys)
idesc.id_func = findino;
idesc.id_name = SUJ_FILE;
ginode(UFS_ROOTINO, &ip);
- if ((ckinode(ip.i_dp, &idesc) & FOUND) == FOUND) {
+ dp = ip.i_dp;
+ if ((DIP(dp, di_mode) & IFMT) != IFDIR) {
+ irelse(&ip);
+ err_suj("root inode is not a directory\n");
+ }
+ if (DIP(dp, di_size) < 0 || DIP(dp, di_size) > MAXDIRSIZE) {
+ irelse(&ip);
+ err_suj("negative or oversized root directory %jd\n",
+ (uintmax_t)DIP(dp, di_size));
+ }
+ if ((ckinode(dp, &idesc) & FOUND) == FOUND) {
sujino = idesc.id_parent;
irelse(&ip);
} else {
- printf("Journal inode removed. Use tunefs to re-create.\n");
+ if (!bkgrdcheck || debug)
+ printf("Journal inode removed. "
+ "Use tunefs to re-create.\n");
sblock.fs_flags &= ~FS_SUJ;
sblock.fs_sujfree = 0;
irelse(&ip);
@@ -2369,7 +2447,8 @@ suj_check(const char *filesys)
*/
ginode(sujino, &ip);
jip = ip.i_dp;
- printf("** SU+J Recovering %s\n", filesys);
+ if (!bkgrdcheck || debug)
+ printf("** SU+J Recovering %s\n", filesys);
if (suj_verifyino(jip) != 0 || (!preen && !reply("USE JOURNAL"))) {
irelse(&ip);
return (-1);
@@ -2378,15 +2457,23 @@ suj_check(const char *filesys)
* Build a list of journal blocks in jblocks before parsing the
* available journal blocks in with suj_read().
*/
- printf("** Reading %jd byte journal from inode %ju.\n",
- DIP(jip, di_size), (uintmax_t)sujino);
+ if (!bkgrdcheck || debug)
+ printf("** Reading %jd byte journal from inode %ju.\n",
+ DIP(jip, di_size), (uintmax_t)sujino);
suj_jblocks = jblocks_create();
blocks = ino_visit(jip, sujino, suj_add_block, 0);
if (blocks != numfrags(fs, DIP(jip, di_size))) {
- printf("Sparse journal inode %ju.\n", (uintmax_t)sujino);
+ if (!bkgrdcheck || debug)
+ printf("Sparse journal inode %ju.\n",
+ (uintmax_t)sujino);
irelse(&ip);
return (-1);
}
+ /* If journal is valid then do journal check rather than background */
+ if (bkgrdcheck) {
+ irelse(&ip);
+ return (0);
+ }
irelse(&ip);
suj_read();
jblocks_destroy(suj_jblocks);
@@ -2404,9 +2491,17 @@ suj_check(const char *filesys)
cg_apply(cg_adj_blk);
cg_apply(cg_check_ino);
}
- if (preen == 0 && (jrecs > 0 || jbytes > 0) && reply("WRITE CHANGES") == 0)
+ if (preen == 0 && (jrecs > 0 || jbytes > 0) &&
+ reply("WRITE CHANGES") == 0)
return (0);
/*
+ * Check block counts of snapshot inodes and
+ * make copies of any needed snapshot blocks.
+ */
+ for (i = 0; i < snapcnt; i++)
+ check_blkcnt(&snaplist[i]);
+ snapflush(suj_checkblkavail);
+ /*
* Recompute the fs summary info from correct cs summaries.
*/
bzero(&fs->fs_cstotal, sizeof(struct csum_total));
@@ -2425,10 +2520,11 @@ suj_check(const char *filesys)
sbdirty();
ckfini(1);
if (jrecs > 0 || jbytes > 0) {
- printf("** %jd journal records in %jd bytes for %.2f%% utilization\n",
- jrecs, jbytes, ((float)jrecs / (float)(jbytes / JREC_SIZE)) * 100);
- printf("** Freed %jd inodes (%jd dirs) %jd blocks, and %jd frags.\n",
- freeinos, freedir, freeblocks, freefrags);
+ printf("** %jd journal records in %jd bytes for %.2f%% "
+ "utilization\n", jrecs, jbytes,
+ ((float)jrecs / (float)(jbytes / JREC_SIZE)) * 100);
+ printf("** Freed %jd inodes (%jd dirs) %jd blocks, and %jd "
+ "frags.\n", freeinos, freedir, freeblocks, freefrags);
}
return (0);
diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c
index 4f56f1ed8c26..56655089b9d6 100644
--- a/sbin/fsck_ffs/utilities.c
+++ b/sbin/fsck_ffs/utilities.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/sbin/fsck_msdosfs/Makefile b/sbin/fsck_msdosfs/Makefile
index bce48211b586..d5fe24b220b7 100644
--- a/sbin/fsck_msdosfs/Makefile
+++ b/sbin/fsck_msdosfs/Makefile
@@ -1,5 +1,4 @@
# $NetBSD: Makefile,v 1.6 1997/05/08 21:11:11 gwr Exp $
-# $FreeBSD$
FSCK= ${.CURDIR:H}/fsck
.PATH: ${FSCK}
diff --git a/sbin/fsck_msdosfs/Makefile.depend b/sbin/fsck_msdosfs/Makefile.depend
index 6cfaab1c3644..678747db6f2c 100644
--- a/sbin/fsck_msdosfs/Makefile.depend
+++ b/sbin/fsck_msdosfs/Makefile.depend
@@ -1,13 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libutil \
.include <dirdeps.mk>
diff --git a/sbin/fsck_msdosfs/boot.c b/sbin/fsck_msdosfs/boot.c
index 887312ed7c41..f91609470ad7 100644
--- a/sbin/fsck_msdosfs/boot.c
+++ b/sbin/fsck_msdosfs/boot.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1995, 1997 Wolfgang Solfrank
* Copyright (c) 1995 Martin Husemann
@@ -29,8 +29,6 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: boot.c,v 1.22 2020/01/11 16:29:07 christos Exp $");
-static const char rcsid[] =
- "$FreeBSD$";
#endif /* not lint */
#include <sys/param.h>
diff --git a/sbin/fsck_msdosfs/check.c b/sbin/fsck_msdosfs/check.c
index 9519315672ab..f672a2ac515c 100644
--- a/sbin/fsck_msdosfs/check.c
+++ b/sbin/fsck_msdosfs/check.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
* Copyright (c) 1995 Martin Husemann
@@ -29,8 +29,6 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: check.c,v 1.14 2006/06/05 16:51:18 christos Exp $");
-static const char rcsid[] =
- "$FreeBSD$";
#endif /* not lint */
#ifdef HAVE_LIBUTIL_H
diff --git a/sbin/fsck_msdosfs/dir.c b/sbin/fsck_msdosfs/dir.c
index dbe4e0c7db2f..c60eaab59b12 100644
--- a/sbin/fsck_msdosfs/dir.c
+++ b/sbin/fsck_msdosfs/dir.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Google LLC
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
@@ -32,8 +32,6 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: dir.c,v 1.20 2006/06/05 16:51:18 christos Exp $");
-static const char rcsid[] =
- "$FreeBSD$";
#endif /* not lint */
#include <assert.h>
diff --git a/sbin/fsck_msdosfs/dosfs.h b/sbin/fsck_msdosfs/dosfs.h
index d89a08689825..a8da745b1ce3 100644
--- a/sbin/fsck_msdosfs/dosfs.h
+++ b/sbin/fsck_msdosfs/dosfs.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
* Copyright (c) 1995 Martin Husemann
@@ -26,7 +26,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* $NetBSD: dosfs.h,v 1.4 1997/01/03 14:32:48 ws Exp $
- * $FreeBSD$
*/
#ifndef DOSFS_H
diff --git a/sbin/fsck_msdosfs/ext.h b/sbin/fsck_msdosfs/ext.h
index 532e840acfc8..d0f4dd6279f7 100644
--- a/sbin/fsck_msdosfs/ext.h
+++ b/sbin/fsck_msdosfs/ext.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
* Copyright (c) 1995 Martin Husemann
@@ -24,7 +24,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* $NetBSD: ext.h,v 1.6 2000/04/25 23:02:51 jdolecek Exp $
- * $FreeBSD$
*/
#ifndef EXT_H
diff --git a/sbin/fsck_msdosfs/fat.c b/sbin/fsck_msdosfs/fat.c
index e35e2f27d305..567bfcd428cb 100644
--- a/sbin/fsck_msdosfs/fat.c
+++ b/sbin/fsck_msdosfs/fat.c
@@ -30,8 +30,6 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: fat.c,v 1.18 2006/06/05 16:51:18 christos Exp $");
-static const char rcsid[] =
- "$FreeBSD$";
#endif /* not lint */
#include <sys/endian.h>
diff --git a/sbin/fsck_msdosfs/fsck_msdosfs.8 b/sbin/fsck_msdosfs/fsck_msdosfs.8
index 602451b61374..963818ea8bd7 100644
--- a/sbin/fsck_msdosfs/fsck_msdosfs.8
+++ b/sbin/fsck_msdosfs/fsck_msdosfs.8
@@ -23,8 +23,6 @@
.\" (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 January 6, 2020
.Dt FSCK_MSDOSFS 8
.Os
diff --git a/sbin/fsck_msdosfs/main.c b/sbin/fsck_msdosfs/main.c
index de54cd18eae7..0713189daa2d 100644
--- a/sbin/fsck_msdosfs/main.c
+++ b/sbin/fsck_msdosfs/main.c
@@ -29,8 +29,6 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: main.c,v 1.10 1997/10/01 02:18:14 enami Exp $");
-static const char rcsid[] =
- "$FreeBSD$";
#endif /* not lint */
#include <stdlib.h>
diff --git a/sbin/fsdb/Makefile b/sbin/fsdb/Makefile
index a2e280420479..28016b4ccdfc 100644
--- a/sbin/fsdb/Makefile
+++ b/sbin/fsdb/Makefile
@@ -1,8 +1,6 @@
# $NetBSD: Makefile,v 1.1.1.1 1995/10/08 23:08:36 thorpej Exp $
-# @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
-PACKAGE=runtime
+PACKAGE=ufs
PROG= fsdb
MAN= fsdb.8
SRCS= fsdb.c fsdbutil.c \
diff --git a/sbin/fsdb/Makefile.depend b/sbin/fsdb/Makefile.depend
index 7fdfb8aa8455..8501b85f8689 100644
--- a/sbin/fsdb/Makefile.depend
+++ b/sbin/fsdb/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
@@ -10,7 +8,6 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libedit \
lib/libufs \
- lib/ncurses/ncursesw \
.include <dirdeps.mk>
diff --git a/sbin/fsdb/fsdb.8 b/sbin/fsdb/fsdb.8
index fdf98bf91aa5..6e6b87ae8ab2 100644
--- a/sbin/fsdb/fsdb.8
+++ b/sbin/fsdb/fsdb.8
@@ -26,8 +26,6 @@
.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 3, 2016
.Dt FSDB 8
.Os
diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c
index c935f88952b4..48526ad4044b 100644
--- a/sbin/fsdb/fsdb.c
+++ b/sbin/fsdb/fsdb.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <ctype.h>
#include <err.h>
@@ -63,6 +58,23 @@ static int find_blks64(uint64_t *buf, int size, uint64_t *blknum);
static int find_indirblks32(uint32_t blk, int ind_level, uint32_t *blknum);
static int find_indirblks64(uint64_t blk, int ind_level, uint64_t *blknum);
+/*
+ * Track modifications to the filesystem. Two types of changes are tracked.
+ * The first type of changes are those that are not critical to the integrity
+ * of the filesystem such as owner, group, time stamps, access mode, and
+ * generation number. The second type of changes are those that do affect
+ * the integrity of the filesystem including zeroing inodes, changing block
+ * pointers, directory entries, link counts, file lengths, file types and
+ * file flags.
+ *
+ * When quitting having made no changes or only changes to data that is not
+ * critical to filesystem integrity, the clean state of the filesystem is
+ * left unchanged. But if filesystem critical data are changed then fsdb
+ * will set the unclean flag which will require a full fsck to be run
+ * before the filesystem can be mounted.
+ */
+static int fsnoncritmodified; /* filesystem non-critical modifications */
+static int fscritmodified; /* filesystem integrity critical mods */
struct inode curip;
union dinode *curinode;
ino_t curinum, ocurrent;
@@ -111,7 +123,7 @@ main(int argc, char *argv[])
fsys = argv[0];
sblock_init();
- if (openfilesys(fsys) == 0 || readsb(0) == 0 || setup(fsys) == 0)
+ if (openfilesys(fsys) == 0 || readsb() == 0 || setup(fsys) == 0)
errx(1, "cannot set up file system `%s'", fsys);
if (fswritefd < 0)
nflag++;
@@ -119,9 +131,13 @@ main(int argc, char *argv[])
nflag? "Examining": "Editing", fsys, sblock.fs_fsmnt);
rval = cmdloop();
if (!nflag) {
- sblock.fs_clean = 0; /* mark it dirty */
- sbdirty();
- ckfini(0);
+ if (fscritmodified != 0) {
+ sblock.fs_clean = 0; /* mark it dirty */
+ sbdirty();
+ }
+ ckfini(fscritmodified ? 0 : sblock.fs_clean);
+ if (fscritmodified == 0)
+ exit(0);
printf("*** FILE SYSTEM MARKED DIRTY\n");
printf("*** BE SURE TO RUN FSCK TO CLEAN UP ANY DAMAGE\n");
printf("*** IF IT IS MOUNTED, RE-MOUNT WITH -u -o reload\n");
@@ -142,6 +158,7 @@ CMDFUNC(uplink); /* incr link */
CMDFUNC(downlink); /* decr link */
CMDFUNC(linkcount); /* set link count */
CMDFUNC(quit); /* quit */
+CMDFUNC(quitclean); /* quit with filesystem marked clean */
CMDFUNC(findblk); /* find block */
CMDFUNC(ls); /* list directory */
CMDFUNC(rm); /* remove name */
@@ -161,40 +178,42 @@ CMDFUNC(chatime); /* Change atime */
CMDFUNC(chinum); /* Change inode # of dirent */
CMDFUNC(chname); /* Change dirname of dirent */
CMDFUNC(chsize); /* Change size */
+CMDFUNC(chdb); /* Change direct block pointer */
struct cmdtable cmds[] = {
{ "help", "Print out help", 1, 1, FL_RO, helpfn },
{ "?", "Print out help", 1, 1, FL_RO, helpfn },
{ "inode", "Set active inode to INUM", 2, 2, FL_RO, focus },
- { "clri", "Clear inode INUM", 2, 2, FL_WR, zapi },
+ { "clri", "Clear inode INUM", 2, 2, FL_CWR, zapi },
{ "lookup", "Set active inode by looking up NAME", 2, 2, FL_RO | FL_ST, focusname },
{ "cd", "Set active inode by looking up NAME", 2, 2, FL_RO | FL_ST, focusname },
{ "back", "Go to previous active inode", 1, 1, FL_RO, back },
{ "active", "Print active inode", 1, 1, FL_RO, active },
{ "print", "Print active inode", 1, 1, FL_RO, active },
{ "blocks", "Print block numbers of active inode", 1, 1, FL_RO, blocks },
- { "uplink", "Increment link count", 1, 1, FL_WR, uplink },
- { "downlink", "Decrement link count", 1, 1, FL_WR, downlink },
- { "linkcount", "Set link count to COUNT", 2, 2, FL_WR, linkcount },
+ { "uplink", "Increment link count", 1, 1, FL_CWR, uplink },
+ { "downlink", "Decrement link count", 1, 1, FL_CWR, downlink },
+ { "linkcount", "Set link count to COUNT", 2, 2, FL_CWR, linkcount },
{ "findblk", "Find inode owning disk block(s)", 2, 33, FL_RO, findblk},
{ "ls", "List current inode as directory", 1, 1, FL_RO, ls },
- { "rm", "Remove NAME from current inode directory", 2, 2, FL_WR | FL_ST, rm },
- { "del", "Remove NAME from current inode directory", 2, 2, FL_WR | FL_ST, rm },
- { "ln", "Hardlink INO into current inode directory as NAME", 3, 3, FL_WR | FL_ST, ln },
- { "chinum", "Change dir entry number INDEX to INUM", 3, 3, FL_WR, chinum },
+ { "rm", "Remove NAME from current inode directory", 2, 2, FL_CWR | FL_ST, rm },
+ { "del", "Remove NAME from current inode directory", 2, 2, FL_CWR | FL_ST, rm },
+ { "ln", "Hardlink INO into current inode directory as NAME", 3, 3, FL_CWR | FL_ST, ln },
+ { "chinum", "Change dir entry number INDEX to INUM", 3, 3, FL_CWR, chinum },
{ "chname", "Change dir entry number INDEX to NAME", 3, 3, FL_WR | FL_ST, chname },
- { "chtype", "Change type of current inode to TYPE", 2, 2, FL_WR, newtype },
+ { "chtype", "Change type of current inode to TYPE", 2, 2, FL_CWR, newtype },
{ "chmod", "Change mode of current inode to MODE", 2, 2, FL_WR, chmode },
- { "chlen", "Change length of current inode to LENGTH", 2, 2, FL_WR, chlen },
{ "chown", "Change owner of current inode to OWNER", 2, 2, FL_WR, chowner },
{ "chgrp", "Change group of current inode to GROUP", 2, 2, FL_WR, chgroup },
- { "chflags", "Change flags of current inode to FLAGS", 2, 2, FL_WR, chaflags },
+ { "chflags", "Change flags of current inode to FLAGS", 2, 2, FL_CWR, chaflags },
{ "chgen", "Change generation number of current inode to GEN", 2, 2, FL_WR, chgen },
- { "chsize", "Change size of current inode to SIZE", 2, 2, FL_WR, chsize },
+ { "chsize", "Change size of current inode to SIZE", 2, 2, FL_CWR, chsize },
{ "btime", "Change btime of current inode to BTIME", 2, 2, FL_WR, chbtime },
{ "mtime", "Change mtime of current inode to MTIME", 2, 2, FL_WR, chmtime },
{ "ctime", "Change ctime of current inode to CTIME", 2, 2, FL_WR, chctime },
{ "atime", "Change atime of current inode to ATIME", 2, 2, FL_WR, chatime },
+ { "chdb", "Change db pointer N of current inode to BLKNO", 3, 3, FL_CWR, chdb },
+ { "quitclean", "Exit with filesystem marked clean", 1, 1, FL_RO, quitclean },
{ "quit", "Exit", 1, 1, FL_RO, quit },
{ "q", "Exit", 1, 1, FL_RO, quit },
{ "exit", "Exit", 1, 1, FL_RO, quit },
@@ -278,7 +297,7 @@ cmdloop(void)
known = 0;
for (cmdp = cmds; cmdp->cmd; cmdp++) {
if (!strcmp(cmdp->cmd, cmd_argv[0])) {
- if ((cmdp->flags & FL_WR) == FL_WR && nflag)
+ if ((cmdp->flags & (FL_CWR | FL_WR)) != 0 && nflag)
warnx("`%s' requires write access", cmd_argv[0]),
rval = 1;
else if (cmd_argc >= cmdp->minargc &&
@@ -292,6 +311,12 @@ cmdloop(void)
} else
rval = argcount(cmdp, cmd_argc, cmd_argv);
known = 1;
+ if (rval == 0) {
+ if ((cmdp->flags & FL_WR) != 0)
+ fsnoncritmodified = 1;
+ if ((cmdp->flags & FL_CWR) != 0)
+ fscritmodified = 1;
+ }
break;
}
}
@@ -306,7 +331,7 @@ cmdloop(void)
return 0;
}
if (rval)
- warnx("rval was %d", rval);
+ warnx("command failed, return value was %d", rval);
}
el_end(elptr);
history_end(hist);
@@ -374,6 +399,16 @@ CMDFUNCSTART(quit)
return -1;
}
+CMDFUNCSTART(quitclean)
+{
+ if (fscritmodified) {
+ printf("Warning: modified filesystem marked clean\n");
+ fscritmodified = 0;
+ sblock.fs_clean = 1;
+ }
+ return -1;
+}
+
CMDFUNCSTART(uplink)
{
if (!checkactive())
@@ -781,7 +816,7 @@ CMDFUNCSTART(rm)
if (!checkactivedir())
return 1;
- rval = changeino(curinum, argv[1], 0);
+ rval = changeino(curinum, argv[1], 0, 0);
if (rval & ALTERED) {
printf("Name `%s' removed\n", argv[1]);
return 0;
@@ -928,30 +963,8 @@ CMDFUNCSTART(newtype)
return 0;
}
-CMDFUNCSTART(chlen)
-{
- int rval = 1;
- long len;
- char *cp;
-
- if (!checkactive())
- return 1;
-
- len = strtol(argv[1], &cp, 0);
- if (cp == argv[1] || *cp != '\0' || len < 0) {
- warnx("bad length `%s'", argv[1]);
- return 1;
- }
-
- DIP_SET(curinode, di_size, len);
- inodirty(&curip);
- printactive(0);
- return rval;
-}
-
CMDFUNCSTART(chmode)
{
- int rval = 1;
long modebits;
char *cp;
@@ -968,12 +981,11 @@ CMDFUNCSTART(chmode)
DIP_SET(curinode, di_mode, DIP(curinode, di_mode) | modebits);
inodirty(&curip);
printactive(0);
- return rval;
+ return 0;
}
CMDFUNCSTART(chaflags)
{
- int rval = 1;
u_long flags;
char *cp;
@@ -993,12 +1005,11 @@ CMDFUNCSTART(chaflags)
DIP_SET(curinode, di_flags, flags);
inodirty(&curip);
printactive(0);
- return rval;
+ return 0;
}
CMDFUNCSTART(chgen)
{
- int rval = 1;
long gen;
char *cp;
@@ -1011,19 +1022,19 @@ CMDFUNCSTART(chgen)
return 1;
}
- if (gen > INT_MAX || gen < INT_MIN) {
- warnx("gen set beyond 32-bit range of field (%lx)\n", gen);
+ if (gen > UINT_MAX) {
+ warnx("gen set beyond 32-bit range of field (0x%lx), max is 0x%x\n",
+ gen, UINT_MAX);
return(1);
}
DIP_SET(curinode, di_gen, gen);
inodirty(&curip);
printactive(0);
- return rval;
+ return 0;
}
CMDFUNCSTART(chsize)
{
- int rval = 1;
off_t size;
char *cp;
@@ -1043,12 +1054,41 @@ CMDFUNCSTART(chsize)
DIP_SET(curinode, di_size, size);
inodirty(&curip);
printactive(0);
- return rval;
+ return 0;
+}
+
+CMDFUNC(chdb)
+{
+ unsigned int idx;
+ daddr_t bno;
+ char *cp;
+
+ if (!checkactive())
+ return 1;
+
+ idx = strtoull(argv[1], &cp, 0);
+ if (cp == argv[1] || *cp != '\0') {
+ warnx("bad pointer idx `%s'", argv[1]);
+ return 1;
+ }
+ bno = strtoll(argv[2], &cp, 0);
+ if (cp == argv[2] || *cp != '\0') {
+ warnx("bad block number `%s'", argv[2]);
+ return 1;
+ }
+ if (idx >= UFS_NDADDR) {
+ warnx("pointer index %d is out of range", idx);
+ return 1;
+ }
+
+ DIP_SET(curinode, di_db[idx], bno);
+ inodirty(&curip);
+ printactive(0);
+ return 0;
}
CMDFUNCSTART(linkcount)
{
- int rval = 1;
int lcnt;
char *cp;
@@ -1068,12 +1108,11 @@ CMDFUNCSTART(linkcount)
DIP_SET(curinode, di_nlink, lcnt);
inodirty(&curip);
printactive(0);
- return rval;
+ return 0;
}
CMDFUNCSTART(chowner)
{
- int rval = 1;
unsigned long uid;
char *cp;
struct passwd *pwd;
@@ -1095,12 +1134,11 @@ CMDFUNCSTART(chowner)
DIP_SET(curinode, di_uid, uid);
inodirty(&curip);
printactive(0);
- return rval;
+ return 0;
}
CMDFUNCSTART(chgroup)
{
- int rval = 1;
unsigned long gid;
char *cp;
struct group *grp;
@@ -1121,7 +1159,7 @@ CMDFUNCSTART(chgroup)
DIP_SET(curinode, di_gid, gid);
inodirty(&curip);
printactive(0);
- return rval;
+ return 0;
}
int
diff --git a/sbin/fsdb/fsdb.h b/sbin/fsdb/fsdb.h
index fee35886f675..1a8bc770005e 100644
--- a/sbin/fsdb/fsdb.h
+++ b/sbin/fsdb/fsdb.h
@@ -28,8 +28,6 @@
* 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$
*/
extern int blread(int fd, char *buf, ufs2_daddr_t blk, long size);
@@ -49,7 +47,8 @@ struct cmdtable {
unsigned int flags;
#define FL_RO 0x0000 /* for symmetry */
#define FL_WR 0x0001 /* wants to write */
-#define FL_ST 0x0002 /* resplit final string if argc > maxargc */
+#define FL_CWR 0x0002 /* wants to write critical data */
+#define FL_ST 0x0003 /* resplit final string if argc > maxargc */
int (*handler)(int argc, char *argv[]);
};
extern struct inode curip;
diff --git a/sbin/fsdb/fsdbutil.c b/sbin/fsdb/fsdbutil.c
index c8a3a8a525e3..737dabba643f 100644
--- a/sbin/fsdb/fsdbutil.c
+++ b/sbin/fsdb/fsdbutil.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <ctype.h>
#include <err.h>
diff --git a/sbin/fsirand/Makefile b/sbin/fsirand/Makefile
index 1fc54ff44687..04bff10f2314 100644
--- a/sbin/fsirand/Makefile
+++ b/sbin/fsirand/Makefile
@@ -1,7 +1,6 @@
# $OpenBSD: Makefile,v 1.1 1997/01/26 02:23:20 millert Exp $
-# $FreeBSD$
-PACKAGE=runtime
+PACKAGE=ufs
PROG= fsirand
MAN= fsirand.8
LIBADD= ufs
diff --git a/sbin/fsirand/Makefile.depend b/sbin/fsirand/Makefile.depend
index 6cfaab1c3644..910688a678fa 100644
--- a/sbin/fsirand/Makefile.depend
+++ b/sbin/fsirand/Makefile.depend
@@ -1,13 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libufs \
.include <dirdeps.mk>
diff --git a/sbin/fsirand/fsirand.8 b/sbin/fsirand/fsirand.8
index f3fbd8d6c153..5e826c6588a8 100644
--- a/sbin/fsirand/fsirand.8
+++ b/sbin/fsirand/fsirand.8
@@ -27,7 +27,6 @@
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $OpenBSD: fsirand.8,v 1.6 1997/02/23 03:58:26 millert Exp $
-.\" $FreeBSD$
.\"
.Dd January 25, 1997
.Dt FSIRAND 8
diff --git a/sbin/fsirand/fsirand.c b/sbin/fsirand/fsirand.c
index c4db8848f18b..2a5eb0c5136d 100644
--- a/sbin/fsirand/fsirand.c
+++ b/sbin/fsirand/fsirand.c
@@ -1,7 +1,7 @@
/* $OpenBSD: fsirand.c,v 1.9 1997/02/28 00:46:33 millert Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
* All rights reserved.
@@ -32,11 +32,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/resource.h>
@@ -112,7 +107,7 @@ fsirand(char *device)
struct fs *sblock;
ino_t inumber;
ufs2_daddr_t dblk;
- int devfd, n, cg, ret;
+ int devfd, n, cg;
u_int32_t bsize = DEV_BSIZE;
if ((devfd = open(device, printonly ? O_RDONLY : O_RDWR)) < 0) {
@@ -124,10 +119,10 @@ fsirand(char *device)
dp2 = NULL;
/* Read in master superblock */
- if ((ret = sbget(devfd, &sblock, STDSB)) != 0) {
- switch (ret) {
+ if ((errno = sbget(devfd, &sblock, UFS_STDSB, UFS_NOCSUM)) != 0) {
+ switch (errno) {
case ENOENT:
- warn("Cannot find file system superblock");
+ warnx("Cannot find file system superblock");
return (1);
default:
warn("Unable to read file system superblock");
diff --git a/sbin/gbde/Makefile b/sbin/gbde/Makefile
index dcc034fd7564..8c84781fc4ed 100644
--- a/sbin/gbde/Makefile
+++ b/sbin/gbde/Makefile
@@ -1,11 +1,9 @@
-# $FreeBSD$
-PACKAGE=runtime
+PACKAGE=geom
PROG= gbde
SRCS= gbde.c template.c
SRCS+= rijndael-alg-fst.c
SRCS+= rijndael-api-fst.c
-SRCS+= sha512c.c
SRCS+= g_bde_lock.c
# rijndael-fst.c does evil casting things which can results in warnings,
diff --git a/sbin/gbde/Makefile.depend b/sbin/gbde/Makefile.depend
index 262aec4302c7..2edf986e595a 100644
--- a/sbin/gbde/Makefile.depend
+++ b/sbin/gbde/Makefile.depend
@@ -1,17 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libexpat \
lib/libgeom \
lib/libmd \
- lib/libsbuf \
lib/libutil \
diff --git a/sbin/gbde/gbde.8 b/sbin/gbde/gbde.8
index cd34b6e02b54..1f3d41017307 100644
--- a/sbin/gbde/gbde.8
+++ b/sbin/gbde/gbde.8
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 3, 2016
.Dt GBDE 8
.Os
diff --git a/sbin/gbde/gbde.c b/sbin/gbde/gbde.c
index 421242c38c80..e173bb78ad90 100644
--- a/sbin/gbde/gbde.c
+++ b/sbin/gbde/gbde.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002 Poul-Henning Kamp
* Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -31,8 +31,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
* XXX: Future stuff
*
* Replace the template file options (-i & -f) with command-line variables
@@ -737,6 +735,11 @@ main(int argc, char **argv)
struct g_bde_key *gl;
struct g_bde_softc sc;
+ fprintf(stderr, "GBDE disk-encryption is deprecated,\n");
+ fprintf(stderr, "and will be removed in FreeBSD 15.0\n");
+ fprintf(stderr, "(continuing in 5 seconds)\n");
+ sleep(5);
+
if (argc < 3)
usage();
diff --git a/sbin/gbde/image.uu b/sbin/gbde/image.uu
index 82e6f2e47489..1c06d84f1e45 100644
--- a/sbin/gbde/image.uu
+++ b/sbin/gbde/image.uu
@@ -1,4 +1,3 @@
-$FreeBSD$
begin 644 gbde.image.bz2
M0EIH.3%!629364"&9H\`Y1=_____________________________________
diff --git a/sbin/gbde/template.txt b/sbin/gbde/template.txt
index 3d22007befd9..6de6c6b0b485 100644
--- a/