aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/Makefile12
-rw-r--r--usr.sbin/Makefile.aarch646
-rw-r--r--usr.sbin/Makefile.amd649
-rw-r--r--usr.sbin/Makefile.arm3
-rw-r--r--usr.sbin/Makefile.i3864
-rw-r--r--usr.sbin/Makefile.inc2
-rw-r--r--usr.sbin/Makefile.mips3
-rw-r--r--usr.sbin/Makefile.powerpc2
-rw-r--r--usr.sbin/Makefile.riscv3
-rw-r--r--usr.sbin/ac/Makefile2
-rw-r--r--usr.sbin/ac/Makefile.depend2
-rw-r--r--usr.sbin/ac/ac.82
-rw-r--r--usr.sbin/ac/ac.c10
-rw-r--r--usr.sbin/accton/Makefile2
-rw-r--r--usr.sbin/accton/Makefile.depend2
-rw-r--r--usr.sbin/accton/accton.81
-rw-r--r--usr.sbin/accton/accton.c16
-rw-r--r--usr.sbin/acpi/Makefile1
-rw-r--r--usr.sbin/acpi/Makefile.inc1
-rw-r--r--usr.sbin/acpi/acpiconf/Makefile1
-rw-r--r--usr.sbin/acpi/acpiconf/Makefile.depend2
-rw-r--r--usr.sbin/acpi/acpiconf/acpiconf.819
-rw-r--r--usr.sbin/acpi/acpiconf/acpiconf.c5
-rw-r--r--usr.sbin/acpi/acpidb/Makefile19
-rw-r--r--usr.sbin/acpi/acpidb/Makefile.depend2
-rw-r--r--usr.sbin/acpi/acpidb/acpidb.82
-rw-r--r--usr.sbin/acpi/acpidb/acpidb.c4
-rw-r--r--usr.sbin/acpi/acpidump/Makefile2
-rw-r--r--usr.sbin/acpi/acpidump/Makefile.depend2
-rw-r--r--usr.sbin/acpi/acpidump/acpi.c414
-rw-r--r--usr.sbin/acpi/acpidump/acpi_user.c4
-rw-r--r--usr.sbin/acpi/acpidump/acpidump.82
-rw-r--r--usr.sbin/acpi/acpidump/acpidump.c4
-rw-r--r--usr.sbin/acpi/acpidump/acpidump.h7
-rw-r--r--usr.sbin/acpi/iasl/Makefile19
-rw-r--r--usr.sbin/acpi/iasl/Makefile.depend2
-rw-r--r--usr.sbin/acpi/iasl/iasl.82
-rw-r--r--usr.sbin/adduser/Makefile1
-rw-r--r--usr.sbin/adduser/Makefile.depend1
-rw-r--r--usr.sbin/adduser/adduser.812
-rw-r--r--usr.sbin/adduser/adduser.conf.54
-rw-r--r--usr.sbin/adduser/adduser.sh178
-rw-r--r--usr.sbin/adduser/rmuser.82
-rw-r--r--usr.sbin/adduser/rmuser.sh3
-rw-r--r--usr.sbin/apm/Makefile1
-rw-r--r--usr.sbin/apm/Makefile.depend2
-rw-r--r--usr.sbin/apm/apm.82
-rw-r--r--usr.sbin/apm/apm.c2
-rw-r--r--usr.sbin/apmd/Makefile1
-rw-r--r--usr.sbin/apmd/Makefile.depend1
-rw-r--r--usr.sbin/apmd/README2
-rw-r--r--usr.sbin/apmd/apmd.83
-rw-r--r--usr.sbin/apmd/apmd.c7
-rw-r--r--usr.sbin/apmd/apmd.conf1
-rw-r--r--usr.sbin/apmd/apmd.h4
-rw-r--r--usr.sbin/apmd/apmdlex.l4
-rw-r--r--usr.sbin/apmd/apmdparse.y4
-rw-r--r--usr.sbin/apmd/contrib/pccardq.c1
-rw-r--r--usr.sbin/arp/Makefile13
-rw-r--r--usr.sbin/arp/Makefile.depend5
-rw-r--r--usr.sbin/arp/arp.43
-rw-r--r--usr.sbin/arp/arp.83
-rw-r--r--usr.sbin/arp/arp.c255
-rw-r--r--usr.sbin/arp/arp.h23
-rw-r--r--usr.sbin/arp/arp_netlink.c440
-rw-r--r--usr.sbin/audit/Makefile1
-rw-r--r--usr.sbin/audit/Makefile.depend2
-rw-r--r--usr.sbin/auditd/Makefile1
-rw-r--r--usr.sbin/auditd/Makefile.depend2
-rw-r--r--usr.sbin/auditdistd/Makefile3
-rw-r--r--usr.sbin/auditdistd/Makefile.depend3
-rw-r--r--usr.sbin/auditreduce/Makefile1
-rw-r--r--usr.sbin/auditreduce/Makefile.depend2
-rw-r--r--usr.sbin/authpf/Makefile1
-rw-r--r--usr.sbin/authpf/Makefile.depend4
-rw-r--r--usr.sbin/autofs/Makefile1
-rw-r--r--usr.sbin/autofs/Makefile.depend2
-rw-r--r--usr.sbin/autofs/auto_master3
-rw-r--r--usr.sbin/autofs/auto_master.56
-rw-r--r--usr.sbin/autofs/autofs/Makefile1
-rw-r--r--usr.sbin/autofs/autofs/include_ldap1
-rw-r--r--usr.sbin/autofs/autofs/include_nis1
-rw-r--r--usr.sbin/autofs/autofs/include_nis_nullfs1
-rw-r--r--usr.sbin/autofs/autofs/special_hosts1
-rwxr-xr-xusr.sbin/autofs/autofs/special_media14
-rwxr-xr-xusr.sbin/autofs/autofs/special_noauto1
-rw-r--r--usr.sbin/autofs/autofs/special_null1
-rw-r--r--usr.sbin/autofs/automount.82
-rw-r--r--usr.sbin/autofs/automount.c27
-rw-r--r--usr.sbin/autofs/automountd.82
-rw-r--r--usr.sbin/autofs/automountd.c5
-rw-r--r--usr.sbin/autofs/autounmountd.82
-rw-r--r--usr.sbin/autofs/autounmountd.c5
-rw-r--r--usr.sbin/autofs/common.c5
-rw-r--r--usr.sbin/autofs/common.h4
-rw-r--r--usr.sbin/autofs/defined.c5
-rw-r--r--usr.sbin/autofs/log.c4
-rw-r--r--usr.sbin/autofs/popen.c3
-rw-r--r--usr.sbin/autofs/token.l4
-rw-r--r--usr.sbin/bhyve/Makefile98
-rw-r--r--usr.sbin/bhyve/Makefile.depend6
-rw-r--r--usr.sbin/bhyve/Makefile.depend.options1
-rw-r--r--usr.sbin/bhyve/aarch64/Makefile.inc9
-rw-r--r--usr.sbin/bhyve/aarch64/bhyverun_machdep.c409
-rw-r--r--usr.sbin/bhyve/aarch64/fdt.c394
-rw-r--r--usr.sbin/bhyve/aarch64/fdt.h48
-rw-r--r--usr.sbin/bhyve/aarch64/pci_irq.c66
-rw-r--r--usr.sbin/bhyve/aarch64/pci_irq_machdep.h49
-rw-r--r--usr.sbin/bhyve/aarch64/vmexit.c260
-rw-r--r--usr.sbin/bhyve/acpi.c965
-rw-r--r--usr.sbin/bhyve/acpi.h7
-rw-r--r--usr.sbin/bhyve/acpi_device.c213
-rw-r--r--usr.sbin/bhyve/acpi_device.h59
-rw-r--r--usr.sbin/bhyve/ahci.h4
-rw-r--r--usr.sbin/bhyve/amd64/Makefile.inc32
-rw-r--r--usr.sbin/bhyve/amd64/atkbdc.c (renamed from usr.sbin/bhyve/atkbdc.c)13
-rw-r--r--usr.sbin/bhyve/amd64/atkbdc.h (renamed from usr.sbin/bhyve/atkbdc.h)2
-rw-r--r--usr.sbin/bhyve/amd64/bhyverun_machdep.c368
-rw-r--r--usr.sbin/bhyve/amd64/e820.c491
-rw-r--r--usr.sbin/bhyve/amd64/e820.h45
-rw-r--r--usr.sbin/bhyve/amd64/fwctl.c (renamed from usr.sbin/bhyve/fwctl.c)91
-rw-r--r--usr.sbin/bhyve/amd64/fwctl.h (renamed from usr.sbin/bhyve/fwctl.h)4
-rw-r--r--usr.sbin/bhyve/amd64/inout.c (renamed from usr.sbin/bhyve/inout.c)36
-rw-r--r--usr.sbin/bhyve/amd64/inout.h (renamed from usr.sbin/bhyve/inout.h)9
-rw-r--r--usr.sbin/bhyve/amd64/ioapic.c (renamed from usr.sbin/bhyve/ioapic.c)5
-rw-r--r--usr.sbin/bhyve/amd64/ioapic.h (renamed from usr.sbin/bhyve/ioapic.h)4
-rw-r--r--usr.sbin/bhyve/amd64/kernemu_dev.c (renamed from usr.sbin/bhyve/kernemu_dev.c)10
-rw-r--r--usr.sbin/bhyve/amd64/kernemu_dev.h (renamed from usr.sbin/bhyve/kernemu_dev.h)4
-rw-r--r--usr.sbin/bhyve/amd64/mptbl.c (renamed from usr.sbin/bhyve/mptbl.c)11
-rw-r--r--usr.sbin/bhyve/amd64/mptbl.h (renamed from usr.sbin/bhyve/mptbl.h)4
-rw-r--r--usr.sbin/bhyve/amd64/pci_gvt-d-opregion.h186
-rw-r--r--usr.sbin/bhyve/amd64/pci_gvt-d.c304
-rw-r--r--usr.sbin/bhyve/amd64/pci_irq.c (renamed from usr.sbin/bhyve/pci_irq.c)83
-rw-r--r--usr.sbin/bhyve/amd64/pci_irq_machdep.h60
-rw-r--r--usr.sbin/bhyve/amd64/pci_lpc.c (renamed from usr.sbin/bhyve/pci_lpc.c)167
-rw-r--r--usr.sbin/bhyve/amd64/pci_lpc.h (renamed from usr.sbin/bhyve/pci_lpc.h)7
-rw-r--r--usr.sbin/bhyve/amd64/pm.c (renamed from usr.sbin/bhyve/pm.c)35
-rw-r--r--usr.sbin/bhyve/amd64/post.c (renamed from usr.sbin/bhyve/post.c)11
-rw-r--r--usr.sbin/bhyve/amd64/ps2kbd.c (renamed from usr.sbin/bhyve/ps2kbd.c)130
-rw-r--r--usr.sbin/bhyve/amd64/ps2kbd.h (renamed from usr.sbin/bhyve/ps2kbd.h)4
-rw-r--r--usr.sbin/bhyve/amd64/ps2mouse.c (renamed from usr.sbin/bhyve/ps2mouse.c)8
-rw-r--r--usr.sbin/bhyve/amd64/ps2mouse.h (renamed from usr.sbin/bhyve/ps2mouse.h)4
-rw-r--r--usr.sbin/bhyve/amd64/rtc.c (renamed from usr.sbin/bhyve/rtc.c)11
-rw-r--r--usr.sbin/bhyve/amd64/rtc.h (renamed from usr.sbin/bhyve/rtc.h)4
-rw-r--r--usr.sbin/bhyve/amd64/spinup_ap.c (renamed from usr.sbin/bhyve/spinup_ap.c)48
-rw-r--r--usr.sbin/bhyve/amd64/spinup_ap.h (renamed from usr.sbin/bhyve/spinup_ap.h)6
-rw-r--r--usr.sbin/bhyve/amd64/task_switch.c (renamed from usr.sbin/bhyve/task_switch.c)273
-rw-r--r--usr.sbin/bhyve/amd64/vga.c (renamed from usr.sbin/bhyve/vga.c)85
-rw-r--r--usr.sbin/bhyve/amd64/vga.h (renamed from usr.sbin/bhyve/vga.h)6
-rw-r--r--usr.sbin/bhyve/amd64/vmexit.c521
-rw-r--r--usr.sbin/bhyve/amd64/xmsr.c (renamed from usr.sbin/bhyve/xmsr.c)19
-rw-r--r--usr.sbin/bhyve/amd64/xmsr.h (renamed from usr.sbin/bhyve/xmsr.h)8
-rw-r--r--usr.sbin/bhyve/audio.c38
-rw-r--r--usr.sbin/bhyve/audio.h8
-rw-r--r--usr.sbin/bhyve/basl.c702
-rw-r--r--usr.sbin/bhyve/basl.h101
-rw-r--r--usr.sbin/bhyve/bhyve.8216
-rw-r--r--usr.sbin/bhyve/bhyve_config.5177
-rw-r--r--usr.sbin/bhyve/bhyvegc.c5
-rw-r--r--usr.sbin/bhyve/bhyvegc.h4
-rw-r--r--usr.sbin/bhyve/bhyverun.c1119
-rw-r--r--usr.sbin/bhyve/bhyverun.h46
-rw-r--r--usr.sbin/bhyve/block_if.c190
-rw-r--r--usr.sbin/bhyve/block_if.h10
-rw-r--r--usr.sbin/bhyve/bootrom.c29
-rw-r--r--usr.sbin/bhyve/bootrom.h4
-rw-r--r--usr.sbin/bhyve/config.c26
-rw-r--r--usr.sbin/bhyve/config.h6
-rw-r--r--usr.sbin/bhyve/console.c5
-rw-r--r--usr.sbin/bhyve/console.h4
-rw-r--r--usr.sbin/bhyve/debug.h4
-rw-r--r--usr.sbin/bhyve/gdb.c484
-rw-r--r--usr.sbin/bhyve/gdb.h13
-rw-r--r--usr.sbin/bhyve/gdb/Makefile23
-rw-r--r--usr.sbin/bhyve/gdb/amd64.xml165
-rw-r--r--usr.sbin/bhyve/hda_codec.c16
-rw-r--r--usr.sbin/bhyve/hda_reg.h4
-rw-r--r--usr.sbin/bhyve/hdac_reg.h4
-rw-r--r--usr.sbin/bhyve/iov.c9
-rw-r--r--usr.sbin/bhyve/iov.h4
-rw-r--r--usr.sbin/bhyve/ipc.h6
-rw-r--r--usr.sbin/bhyve/kbdlayout/Makefile1
-rw-r--r--usr.sbin/bhyve/kbdlayout/Makefile.depend1
-rw-r--r--usr.sbin/bhyve/kbdlayout/am1
-rw-r--r--usr.sbin/bhyve/kbdlayout/be1
-rw-r--r--usr.sbin/bhyve/kbdlayout/be_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/bg_bds1
-rw-r--r--usr.sbin/bhyve/kbdlayout/bg_phonetic1
-rw-r--r--usr.sbin/bhyve/kbdlayout/br1
-rw-r--r--usr.sbin/bhyve/kbdlayout/br_noacc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/centraleuropean1
-rw-r--r--usr.sbin/bhyve/kbdlayout/ch1
-rw-r--r--usr.sbin/bhyve/kbdlayout/ch-fr1
-rw-r--r--usr.sbin/bhyve/kbdlayout/ch-fr_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/ch_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/ch_macbook_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/cz1
-rw-r--r--usr.sbin/bhyve/kbdlayout/de4
-rw-r--r--usr.sbin/bhyve/kbdlayout/de_acc4
-rw-r--r--usr.sbin/bhyve/kbdlayout/de_noacc4
-rw-r--r--usr.sbin/bhyve/kbdlayout/default1
-rw-r--r--usr.sbin/bhyve/kbdlayout/dk1
-rw-r--r--usr.sbin/bhyve/kbdlayout/dk_macbook1
-rw-r--r--usr.sbin/bhyve/kbdlayout/ee1
-rw-r--r--usr.sbin/bhyve/kbdlayout/es1
-rw-r--r--usr.sbin/bhyve/kbdlayout/es_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/es_dvorak1
-rw-r--r--usr.sbin/bhyve/kbdlayout/fi1
-rw-r--r--usr.sbin/bhyve/kbdlayout/fr1
-rw-r--r--usr.sbin/bhyve/kbdlayout/fr_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/fr_dvorak1
-rw-r--r--usr.sbin/bhyve/kbdlayout/fr_dvorak_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/fr_macbook1
-rw-r--r--usr.sbin/bhyve/kbdlayout/gr1
-rw-r--r--usr.sbin/bhyve/kbdlayout/gr_101_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/gr_elot_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/hr1
-rw-r--r--usr.sbin/bhyve/kbdlayout/hu_1011
-rw-r--r--usr.sbin/bhyve/kbdlayout/hu_1021
-rw-r--r--usr.sbin/bhyve/kbdlayout/is1
-rw-r--r--usr.sbin/bhyve/kbdlayout/is_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/it1
-rw-r--r--usr.sbin/bhyve/kbdlayout/jp1
-rw-r--r--usr.sbin/bhyve/kbdlayout/jp_capsctrl1
-rw-r--r--usr.sbin/bhyve/kbdlayout/kz_io1
-rw-r--r--usr.sbin/bhyve/kbdlayout/kz_kst1
-rw-r--r--usr.sbin/bhyve/kbdlayout/latinamerican1
-rw-r--r--usr.sbin/bhyve/kbdlayout/latinamerican_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/lt1
-rw-r--r--usr.sbin/bhyve/kbdlayout/nl1
-rw-r--r--usr.sbin/bhyve/kbdlayout/no1
-rw-r--r--usr.sbin/bhyve/kbdlayout/no_dvorak1
-rw-r--r--usr.sbin/bhyve/kbdlayout/nordic_asus-eee1
-rw-r--r--usr.sbin/bhyve/kbdlayout/pl_dvorak1
-rw-r--r--usr.sbin/bhyve/kbdlayout/pt1
-rw-r--r--usr.sbin/bhyve/kbdlayout/pt_acc1
-rw-r--r--usr.sbin/bhyve/kbdlayout/ru1
-rw-r--r--usr.sbin/bhyve/kbdlayout/ru_shift1
-rw-r--r--usr.sbin/bhyve/kbdlayout/ru_win1
-rw-r--r--usr.sbin/bhyve/kbdlayout/se1
-rw-r--r--usr.sbin/bhyve/kbdlayout/si1
-rw-r--r--usr.sbin/bhyve/kbdlayout/tr1
-rw-r--r--usr.sbin/bhyve/kbdlayout/tr_f1
-rw-r--r--usr.sbin/bhyve/kbdlayout/ua1
-rw-r--r--usr.sbin/bhyve/kbdlayout/ua_shift_alt1
-rw-r--r--usr.sbin/bhyve/kbdlayout/uk1
-rw-r--r--usr.sbin/bhyve/kbdlayout/uk_capsctrl1
-rw-r--r--usr.sbin/bhyve/kbdlayout/uk_dvorak1
-rw-r--r--usr.sbin/bhyve/kbdlayout/uk_macbook1
-rw-r--r--usr.sbin/bhyve/kbdlayout/us_dvorak1
-rw-r--r--usr.sbin/bhyve/kbdlayout/us_dvorakl1
-rw-r--r--usr.sbin/bhyve/kbdlayout/us_dvorakp1
-rw-r--r--usr.sbin/bhyve/kbdlayout/us_dvorakr1
-rw-r--r--usr.sbin/bhyve/kbdlayout/us_dvorakx1
-rw-r--r--usr.sbin/bhyve/kbdlayout/us_emacs1
-rw-r--r--usr.sbin/bhyve/kbdlayout/us_unix1
-rw-r--r--usr.sbin/bhyve/libslirp.h365
-rw-r--r--usr.sbin/bhyve/mem.c67
-rw-r--r--usr.sbin/bhyve/mem.h16
-rw-r--r--usr.sbin/bhyve/mevent.c42
-rw-r--r--usr.sbin/bhyve/mevent.h5
-rw-r--r--usr.sbin/bhyve/mevent_test.c4
-rw-r--r--usr.sbin/bhyve/net_backend_netgraph.c191
-rw-r--r--usr.sbin/bhyve/net_backend_netmap.c384
-rw-r--r--usr.sbin/bhyve/net_backend_slirp.c664
-rw-r--r--usr.sbin/bhyve/net_backends.c752
-rw-r--r--usr.sbin/bhyve/net_backends.h13
-rw-r--r--usr.sbin/bhyve/net_backends_priv.h152
-rw-r--r--usr.sbin/bhyve/net_utils.c5
-rw-r--r--usr.sbin/bhyve/net_utils.h4
-rw-r--r--usr.sbin/bhyve/pci_ahci.c256
-rw-r--r--usr.sbin/bhyve/pci_e82545.c156
-rw-r--r--usr.sbin/bhyve/pci_emul.c607
-rw-r--r--usr.sbin/bhyve/pci_emul.h73
-rw-r--r--usr.sbin/bhyve/pci_fbuf.c84
-rw-r--r--usr.sbin/bhyve/pci_hda.c108
-rw-r--r--usr.sbin/bhyve/pci_hda.h16
-rw-r--r--usr.sbin/bhyve/pci_hostbridge.c41
-rw-r--r--usr.sbin/bhyve/pci_irq.h20
-rw-r--r--usr.sbin/bhyve/pci_nvme.c447
-rw-r--r--usr.sbin/bhyve/pci_passthru.c434
-rw-r--r--usr.sbin/bhyve/pci_passthru.h42
-rw-r--r--usr.sbin/bhyve/pci_uart.c34
-rw-r--r--usr.sbin/bhyve/pci_virtio_9p.c35
-rw-r--r--usr.sbin/bhyve/pci_virtio_block.c52
-rw-r--r--usr.sbin/bhyve/pci_virtio_console.c45
-rw-r--r--usr.sbin/bhyve/pci_virtio_input.c36
-rw-r--r--usr.sbin/bhyve/pci_virtio_net.c42
-rw-r--r--usr.sbin/bhyve/pci_virtio_rnd.c25
-rw-r--r--usr.sbin/bhyve/pci_virtio_scsi.c105
-rw-r--r--usr.sbin/bhyve/pci_xhci.c210
-rw-r--r--usr.sbin/bhyve/pci_xhci.h68
-rw-r--r--usr.sbin/bhyve/pctestdev.c34
-rw-r--r--usr.sbin/bhyve/pctestdev.h4
-rw-r--r--usr.sbin/bhyve/qemu_fwcfg.c634
-rw-r--r--usr.sbin/bhyve/qemu_fwcfg.h26
-rw-r--r--usr.sbin/bhyve/qemu_loader.c274
-rw-r--r--usr.sbin/bhyve/qemu_loader.h77
-rw-r--r--usr.sbin/bhyve/rfb.c48
-rw-r--r--usr.sbin/bhyve/rfb.h7
-rw-r--r--usr.sbin/bhyve/rtc_pl031.c279
-rw-r--r--usr.sbin/bhyve/rtc_pl031.h40
-rw-r--r--usr.sbin/bhyve/smbiostbl.c289
-rw-r--r--usr.sbin/bhyve/smbiostbl.h4
-rw-r--r--usr.sbin/bhyve/snapshot.c458
-rw-r--r--usr.sbin/bhyve/snapshot.h35
-rw-r--r--usr.sbin/bhyve/sockstream.c7
-rw-r--r--usr.sbin/bhyve/sockstream.h4
-rw-r--r--usr.sbin/bhyve/tpm_device.c256
-rw-r--r--usr.sbin/bhyve/tpm_device.h20
-rw-r--r--usr.sbin/bhyve/tpm_emul.h24
-rw-r--r--usr.sbin/bhyve/tpm_emul_passthru.c107
-rw-r--r--usr.sbin/bhyve/tpm_intf.h40
-rw-r--r--usr.sbin/bhyve/tpm_intf_crb.c580
-rw-r--r--usr.sbin/bhyve/tpm_ppi.h20
-rw-r--r--usr.sbin/bhyve/tpm_ppi_qemu.c475
-rw-r--r--usr.sbin/bhyve/uart_backend.c348
-rw-r--r--usr.sbin/bhyve/uart_backend.h55
-rw-r--r--usr.sbin/bhyve/uart_emul.c355
-rw-r--r--usr.sbin/bhyve/uart_emul.h35
-rw-r--r--usr.sbin/bhyve/uart_pl011.c394
-rw-r--r--usr.sbin/bhyve/usb_emul.c5
-rw-r--r--usr.sbin/bhyve/usb_emul.h10
-rw-r--r--usr.sbin/bhyve/usb_mouse.c18
-rw-r--r--usr.sbin/bhyve/virtio.c45
-rw-r--r--usr.sbin/bhyve/virtio.h27
-rw-r--r--usr.sbin/bhyve/vmexit.h34
-rw-r--r--usr.sbin/bhyve/vmgenc.c4
-rw-r--r--usr.sbin/bhyve/vmgenc.h4
-rw-r--r--usr.sbin/bhyvectl/Makefile3
-rw-r--r--usr.sbin/bhyvectl/Makefile.depend2
-rw-r--r--usr.sbin/bhyvectl/bhyvectl.82
-rw-r--r--usr.sbin/bhyvectl/bhyvectl.c924
-rw-r--r--usr.sbin/bhyveload/Makefile3
-rw-r--r--usr.sbin/bhyveload/Makefile.depend3
-rw-r--r--usr.sbin/bhyveload/bhyveload.844
-rw-r--r--usr.sbin/bhyveload/bhyveload.c321
-rw-r--r--usr.sbin/binmiscctl/Makefile1
-rw-r--r--usr.sbin/binmiscctl/Makefile.depend2
-rw-r--r--usr.sbin/binmiscctl/binmiscctl.810
-rw-r--r--usr.sbin/binmiscctl/binmiscctl.c18
-rw-r--r--usr.sbin/blacklistctl/Makefile9
-rw-r--r--usr.sbin/blacklistctl/Makefile.depend3
-rw-r--r--usr.sbin/blacklistd/Makefile9
-rw-r--r--usr.sbin/blacklistd/Makefile.depend3
-rw-r--r--usr.sbin/blacklistd/blacklistd.conf1
-rw-r--r--usr.sbin/bluetooth/Makefile1
-rw-r--r--usr.sbin/bluetooth/Makefile.inc1
-rw-r--r--usr.sbin/bluetooth/ath3kfw/Makefile1
-rw-r--r--usr.sbin/bluetooth/ath3kfw/Makefile.depend3
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3k_dbg.h2
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3k_fw.c4
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3k_fw.h2
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3k_hw.c2
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3k_hw.h2
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3kfw.82
-rw-r--r--usr.sbin/bluetooth/ath3kfw/main.c6
-rw-r--r--usr.sbin/bluetooth/bcmfw/BCM-LEGAL.txt1
-rw-r--r--usr.sbin/bluetooth/bcmfw/Makefile1
-rw-r--r--usr.sbin/bluetooth/bcmfw/Makefile.depend2
-rw-r--r--usr.sbin/bluetooth/bcmfw/README1
-rw-r--r--usr.sbin/bluetooth/bcmfw/bcmfw.81
-rw-r--r--usr.sbin/bluetooth/bcmfw/bcmfw.c3
-rw-r--r--usr.sbin/bluetooth/bluetooth-config/Makefile1
-rw-r--r--usr.sbin/bluetooth/bluetooth-config/bluetooth-config.82
-rwxr-xr-xusr.sbin/bluetooth/bluetooth-config/bluetooth-config.sh1
-rw-r--r--usr.sbin/bluetooth/bthidcontrol/Makefile1
-rw-r--r--usr.sbin/bluetooth/bthidcontrol/Makefile.depend2
-rw-r--r--usr.sbin/bluetooth/bthidcontrol/bthidcontrol.81
-rw-r--r--usr.sbin/bluetooth/bthidcontrol/bthidcontrol.c5
-rw-r--r--usr.sbin/bluetooth/bthidcontrol/bthidcontrol.h3
-rw-r--r--usr.sbin/bluetooth/bthidcontrol/hid.c3
-rw-r--r--usr.sbin/bluetooth/bthidcontrol/sdp.c5
-rw-r--r--usr.sbin/bluetooth/bthidd/Makefile1
-rw-r--r--usr.sbin/bluetooth/bthidd/Makefile.depend2
-rw-r--r--usr.sbin/bluetooth/bthidd/bthid_config.h3
-rw-r--r--usr.sbin/bluetooth/bthidd/bthidd.83
-rw-r--r--usr.sbin/bluetooth/bthidd/bthidd.c3
-rw-r--r--usr.sbin/bluetooth/bthidd/bthidd.conf.sample1
-rw-r--r--usr.sbin/bluetooth/bthidd/bthidd.h3
-rw-r--r--usr.sbin/bluetooth/bthidd/btuinput.c4
-rw-r--r--usr.sbin/bluetooth/bthidd/btuinput.h4
-rw-r--r--usr.sbin/bluetooth/bthidd/client.c3
-rw-r--r--usr.sbin/bluetooth/bthidd/hid.c3
-rw-r--r--usr.sbin/bluetooth/bthidd/kbd.c3
-rw-r--r--usr.sbin/bluetooth/bthidd/kbd.h3
-rw-r--r--usr.sbin/bluetooth/bthidd/lexer.l3
-rw-r--r--usr.sbin/bluetooth/bthidd/parser.y3
-rw-r--r--usr.sbin/bluetooth/bthidd/server.c5
-rw-r--r--usr.sbin/bluetooth/bthidd/session.c3
-rw-r--r--usr.sbin/bluetooth/btpand/Makefile1
-rw-r--r--usr.sbin/bluetooth/btpand/Makefile.depend2
-rw-r--r--usr.sbin/bluetooth/btpand/bnep.c3
-rw-r--r--usr.sbin/bluetooth/btpand/bnep.h3
-rw-r--r--usr.sbin/bluetooth/btpand/btpand.81
-rw-r--r--usr.sbin/bluetooth/btpand/btpand.c11
-rw-r--r--usr.sbin/bluetooth/btpand/btpand.h3
-rw-r--r--usr.sbin/bluetooth/btpand/channel.c3
-rw-r--r--usr.sbin/bluetooth/btpand/client.c3
-rw-r--r--usr.sbin/bluetooth/btpand/event.c3
-rw-r--r--usr.sbin/bluetooth/btpand/event.h3
-rw-r--r--usr.sbin/bluetooth/btpand/packet.c3
-rw-r--r--usr.sbin/bluetooth/btpand/sdp.c3
-rw-r--r--usr.sbin/bluetooth/btpand/sdp.h3
-rw-r--r--usr.sbin/bluetooth/btpand/server.c3
-rw-r--r--usr.sbin/bluetooth/btpand/tap.c3
-rw-r--r--usr.sbin/bluetooth/hccontrol/Makefile1
-rw-r--r--usr.sbin/bluetooth/hccontrol/Makefile.depend2
-rw-r--r--usr.sbin/bluetooth/hccontrol/adv_data.c3
-rw-r--r--usr.sbin/bluetooth/hccontrol/bluetooth.device.conf5
-rw-r--r--usr.sbin/bluetooth/hccontrol/hccontrol.83
-rw-r--r--usr.sbin/bluetooth/hccontrol/hccontrol.c3
-rw-r--r--usr.sbin/bluetooth/hccontrol/hccontrol.h3
-rw-r--r--usr.sbin/bluetooth/hccontrol/host_controller_baseband.c3
-rw-r--r--usr.sbin/bluetooth/hccontrol/info.c3
-rw-r--r--usr.sbin/bluetooth/hccontrol/le.c7
-rw-r--r--usr.sbin/bluetooth/hccontrol/link_control.c3
-rw-r--r--usr.sbin/bluetooth/hccontrol/link_policy.c5
-rw-r--r--usr.sbin/bluetooth/hccontrol/node.c3
-rw-r--r--usr.sbin/bluetooth/hccontrol/send_recv.c3
-rw-r--r--usr.sbin/bluetooth/hccontrol/status.c3
-rw-r--r--usr.sbin/bluetooth/hccontrol/util.c7
-rw-r--r--usr.sbin/bluetooth/hcsecd/Makefile1
-rw-r--r--usr.sbin/bluetooth/hcsecd/Makefile.depend2
-rw-r--r--usr.sbin/bluetooth/hcsecd/hcsecd.81
-rw-r--r--usr.sbin/bluetooth/hcsecd/hcsecd.c3
-rw-r--r--usr.sbin/bluetooth/hcsecd/hcsecd.conf1
-rw-r--r--usr.sbin/bluetooth/hcsecd/hcsecd.conf.51
-rw-r--r--usr.sbin/bluetooth/hcsecd/hcsecd.h3
-rw-r--r--usr.sbin/bluetooth/hcsecd/lexer.l3
-rw-r--r--usr.sbin/bluetooth/hcsecd/parser.y3
-rw-r--r--usr.sbin/bluetooth/iwmbtfw/Makefile1
-rw-r--r--usr.sbin/bluetooth/iwmbtfw/Makefile.depend (renamed from usr.sbin/zic/zdump/Makefile.depend)3
-rw-r--r--usr.sbin/bluetooth/iwmbtfw/iwmbt_dbg.h4
-rw-r--r--usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.c6
-rw-r--r--usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.h4
-rw-r--r--usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c4
-rw-r--r--usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.h4
-rw-r--r--usr.sbin/bluetooth/iwmbtfw/iwmbtfw.82
-rw-r--r--usr.sbin/bluetooth/iwmbtfw/iwmbtfw.conf1
-rw-r--r--usr.sbin/bluetooth/iwmbtfw/main.c6
-rw-r--r--usr.sbin/bluetooth/l2control/Makefile1
-rw-r--r--usr.sbin/bluetooth/l2control/Makefile.depend2
-rw-r--r--usr.sbin/bluetooth/l2control/l2cap.c3
-rw-r--r--usr.sbin/bluetooth/l2control/l2control.81
-rw-r--r--usr.sbin/bluetooth/l2control/l2control.c5
-rw-r--r--usr.sbin/bluetooth/l2control/l2control.h3
-rw-r--r--usr.sbin/bluetooth/l2ping/Makefile1
-rw-r--r--usr.sbin/bluetooth/l2ping/Makefile.depend2
-rw-r--r--usr.sbin/bluetooth/l2ping/l2ping.81
-rw-r--r--usr.sbin/bluetooth/l2ping/l2ping.c3
-rw-r--r--usr.sbin/bluetooth/rfcomm_pppd/Makefile1
-rw-r--r--usr.sbin/bluetooth/rfcomm_pppd/Makefile.depend2
-rw-r--r--usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.81
-rw-r--r--usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c3
-rw-r--r--usr.sbin/bluetooth/sdpcontrol/Makefile1
-rw-r--r--usr.sbin/bluetooth/sdpcontrol/Makefile.depend2
-rw-r--r--usr.sbin/bluetooth/sdpcontrol/sdpcontrol.81
-rw-r--r--usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c3
-rw-r--r--usr.sbin/bluetooth/sdpcontrol/sdpcontrol.h3
-rw-r--r--usr.sbin/bluetooth/sdpcontrol/search.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/Makefile1
-rw-r--r--usr.sbin/bluetooth/sdpd/Makefile.depend2
-rw-r--r--usr.sbin/bluetooth/sdpd/audio_sink.c4
-rw-r--r--usr.sbin/bluetooth/sdpd/audio_source.c4
-rw-r--r--usr.sbin/bluetooth/sdpd/bgd.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/dun.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/ftrn.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/gn.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/irmc.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/irmc_command.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/lan.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/log.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/log.h3
-rw-r--r--usr.sbin/bluetooth/sdpd/main.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/nap.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/opush.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/panu.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/profile.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/profile.h3
-rw-r--r--usr.sbin/bluetooth/sdpd/provider.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/provider.h3
-rw-r--r--usr.sbin/bluetooth/sdpd/sar.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/scr.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/sd.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/sdpd.81
-rw-r--r--usr.sbin/bluetooth/sdpd/server.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/server.h3
-rw-r--r--usr.sbin/bluetooth/sdpd/sp.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/srr.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/ssar.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/ssr.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/sur.c3
-rw-r--r--usr.sbin/bluetooth/sdpd/uuid-private.h3
-rw-r--r--usr.sbin/bluetooth/sdpd/uuid.c3
-rw-r--r--usr.sbin/boot0cfg/Makefile1
-rw-r--r--usr.sbin/boot0cfg/Makefile.depend4
-rw-r--r--usr.sbin/boot0cfg/boot0cfg.82
-rw-r--r--usr.sbin/boot0cfg/boot0cfg.c7
-rw-r--r--usr.sbin/bootparamd/Makefile1
-rw-r--r--usr.sbin/bootparamd/Makefile.inc2
-rw-r--r--usr.sbin/bootparamd/bootparamd/Makefile2
-rw-r--r--usr.sbin/bootparamd/bootparamd/Makefile.depend2
-rw-r--r--usr.sbin/bootparamd/bootparamd/README1
-rw-r--r--usr.sbin/bootparamd/bootparamd/bootparamd.82
-rw-r--r--usr.sbin/bootparamd/bootparamd/bootparamd.c2
-rw-r--r--usr.sbin/bootparamd/bootparamd/bootparams.51
-rw-r--r--usr.sbin/bootparamd/bootparamd/main.c4
-rw-r--r--usr.sbin/bootparamd/callbootd/Makefile2
-rw-r--r--usr.sbin/bootparamd/callbootd/Makefile.depend2
-rw-r--r--usr.sbin/bootparamd/callbootd/callbootd.c4
-rw-r--r--usr.sbin/boottrace/boottrace.82
-rw-r--r--usr.sbin/boottrace/boottrace.c2
-rw-r--r--usr.sbin/bsdconfig/Makefile1
-rw-r--r--usr.sbin/bsdconfig/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/USAGE1
-rwxr-xr-xusr.sbin/bsdconfig/bsdconfig1
-rw-r--r--usr.sbin/bsdconfig/bsdconfig.88
-rw-r--r--usr.sbin/bsdconfig/console/INDEX1
-rw-r--r--usr.sbin/bsdconfig/console/Makefile1
-rw-r--r--usr.sbin/bsdconfig/console/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/console/USAGE1
-rwxr-xr-xusr.sbin/bsdconfig/console/console1
-rwxr-xr-xusr.sbin/bsdconfig/console/font1
-rw-r--r--usr.sbin/bsdconfig/console/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/console/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/console/include/messages.subr1
-rwxr-xr-xusr.sbin/bsdconfig/console/keymap1
-rwxr-xr-xusr.sbin/bsdconfig/console/repeat1
-rwxr-xr-xusr.sbin/bsdconfig/console/saver1
-rwxr-xr-xusr.sbin/bsdconfig/console/screenmap1
-rwxr-xr-xusr.sbin/bsdconfig/console/ttys1
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/INDEX1
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/Makefile1
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/USAGE1
-rwxr-xr-xusr.sbin/bsdconfig/diskmgmt/diskmgmt1
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/include/messages.subr1
-rw-r--r--usr.sbin/bsdconfig/docsinstall/INDEX1
-rw-r--r--usr.sbin/bsdconfig/docsinstall/Makefile1
-rw-r--r--usr.sbin/bsdconfig/docsinstall/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/docsinstall/USAGE1
-rwxr-xr-xusr.sbin/bsdconfig/docsinstall/docsinstall1
-rw-r--r--usr.sbin/bsdconfig/docsinstall/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/docsinstall/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/docsinstall/include/messages.subr1
-rw-r--r--usr.sbin/bsdconfig/dot/INDEX1
-rw-r--r--usr.sbin/bsdconfig/dot/Makefile1
-rw-r--r--usr.sbin/bsdconfig/dot/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/dot/USAGE1
-rwxr-xr-xusr.sbin/bsdconfig/dot/dot1
-rw-r--r--usr.sbin/bsdconfig/dot/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/dot/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/dot/include/messages.subr1
-rw-r--r--usr.sbin/bsdconfig/examples/Makefile1
-rw-r--r--usr.sbin/bsdconfig/examples/Makefile.depend1
-rwxr-xr-xusr.sbin/bsdconfig/examples/add_some_packages.sh1
-rwxr-xr-xusr.sbin/bsdconfig/examples/browse_packages_http.sh1
-rw-r--r--usr.sbin/bsdconfig/examples/bsdconfigrc1
-rw-r--r--usr.sbin/bsdconfig/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/include/media.hlp23
-rw-r--r--usr.sbin/bsdconfig/include/messages.subr39
-rw-r--r--usr.sbin/bsdconfig/include/options.hlp4
-rw-r--r--usr.sbin/bsdconfig/includes/INDEX1
-rw-r--r--usr.sbin/bsdconfig/includes/Makefile1
-rw-r--r--usr.sbin/bsdconfig/includes/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/includes/USAGE1
-rw-r--r--usr.sbin/bsdconfig/includes/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/includes/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/includes/include/messages.subr1
-rwxr-xr-xusr.sbin/bsdconfig/includes/includes.sh1
-rw-r--r--usr.sbin/bsdconfig/mouse/INDEX1
-rw-r--r--usr.sbin/bsdconfig/mouse/Makefile1
-rw-r--r--usr.sbin/bsdconfig/mouse/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/mouse/USAGE1
-rwxr-xr-xusr.sbin/bsdconfig/mouse/disable1
-rwxr-xr-xusr.sbin/bsdconfig/mouse/enable1
-rwxr-xr-xusr.sbin/bsdconfig/mouse/flags1
-rw-r--r--usr.sbin/bsdconfig/mouse/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/mouse/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/mouse/include/messages.subr1
-rwxr-xr-xusr.sbin/bsdconfig/mouse/mouse1
-rwxr-xr-xusr.sbin/bsdconfig/mouse/port1
-rwxr-xr-xusr.sbin/bsdconfig/mouse/type1
-rw-r--r--usr.sbin/bsdconfig/networking/INDEX4
-rw-r--r--usr.sbin/bsdconfig/networking/Makefile1
-rw-r--r--usr.sbin/bsdconfig/networking/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/networking/USAGE1
-rwxr-xr-xusr.sbin/bsdconfig/networking/defaultrouter1
-rwxr-xr-xusr.sbin/bsdconfig/networking/devices1
-rwxr-xr-xusr.sbin/bsdconfig/networking/hostname1
-rw-r--r--usr.sbin/bsdconfig/networking/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/networking/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/networking/include/messages.subr1
-rwxr-xr-xusr.sbin/bsdconfig/networking/nameservers1
-rwxr-xr-xusr.sbin/bsdconfig/networking/networking1
-rw-r--r--usr.sbin/bsdconfig/networking/share/Makefile1
-rw-r--r--usr.sbin/bsdconfig/networking/share/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/networking/share/common.subr1
-rw-r--r--usr.sbin/bsdconfig/networking/share/device.subr1
-rw-r--r--usr.sbin/bsdconfig/networking/share/hostname.subr1
-rw-r--r--usr.sbin/bsdconfig/networking/share/ipaddr.subr1
-rw-r--r--usr.sbin/bsdconfig/networking/share/media.subr1
-rw-r--r--usr.sbin/bsdconfig/networking/share/netmask.subr1
-rw-r--r--usr.sbin/bsdconfig/networking/share/resolv.subr1
-rw-r--r--usr.sbin/bsdconfig/networking/share/routing.subr1
-rw-r--r--usr.sbin/bsdconfig/networking/share/services.subr1
-rwxr-xr-xusr.sbin/bsdconfig/networking/wlanconfig1
-rw-r--r--usr.sbin/bsdconfig/packages/INDEX1
-rw-r--r--usr.sbin/bsdconfig/packages/Makefile1
-rw-r--r--usr.sbin/bsdconfig/packages/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/packages/USAGE1
-rw-r--r--usr.sbin/bsdconfig/packages/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/packages/include/Makefile.depend1
-rwxr-xr-xusr.sbin/bsdconfig/packages/include/messages.subr1
-rwxr-xr-xusr.sbin/bsdconfig/packages/packages1
-rw-r--r--usr.sbin/bsdconfig/password/INDEX1
-rw-r--r--usr.sbin/bsdconfig/password/Makefile1
-rw-r--r--usr.sbin/bsdconfig/password/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/password/USAGE1
-rw-r--r--usr.sbin/bsdconfig/password/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/password/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/password/include/messages.subr1
-rwxr-xr-xusr.sbin/bsdconfig/password/password1
-rw-r--r--usr.sbin/bsdconfig/password/share/Makefile1
-rw-r--r--usr.sbin/bsdconfig/password/share/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/password/share/password.subr1
-rw-r--r--usr.sbin/bsdconfig/security/INDEX1
-rw-r--r--usr.sbin/bsdconfig/security/Makefile1
-rw-r--r--usr.sbin/bsdconfig/security/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/security/USAGE1
-rw-r--r--usr.sbin/bsdconfig/security/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/security/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/security/include/messages.subr1
-rwxr-xr-xusr.sbin/bsdconfig/security/kern_securelevel1
-rwxr-xr-xusr.sbin/bsdconfig/security/security1
-rw-r--r--usr.sbin/bsdconfig/share/Makefile1
-rw-r--r--usr.sbin/bsdconfig/share/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/share/common.subr11
-rw-r--r--usr.sbin/bsdconfig/share/device.subr15
-rw-r--r--usr.sbin/bsdconfig/share/dialog.subr18
-rw-r--r--usr.sbin/bsdconfig/share/geom.subr1
-rw-r--r--usr.sbin/bsdconfig/share/keymap.subr1
-rw-r--r--usr.sbin/bsdconfig/share/media/Makefile3
-rw-r--r--usr.sbin/bsdconfig/share/media/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/share/media/any.subr19
-rw-r--r--usr.sbin/bsdconfig/share/media/cdrom.subr1
-rw-r--r--usr.sbin/bsdconfig/share/media/common.subr1
-rw-r--r--usr.sbin/bsdconfig/share/media/directory.subr1
-rw-r--r--usr.sbin/bsdconfig/share/media/dos.subr1
-rw-r--r--usr.sbin/bsdconfig/share/media/floppy.subr229
-rw-r--r--usr.sbin/bsdconfig/share/media/ftp.subr897
-rw-r--r--usr.sbin/bsdconfig/share/media/http.subr2
-rw-r--r--usr.sbin/bsdconfig/share/media/httpproxy.subr2
-rw-r--r--usr.sbin/bsdconfig/share/media/network.subr1
-rw-r--r--usr.sbin/bsdconfig/share/media/nfs.subr1
-rw-r--r--usr.sbin/bsdconfig/share/media/options.subr11
-rw-r--r--usr.sbin/bsdconfig/share/media/tcpip.subr2
-rw-r--r--usr.sbin/bsdconfig/share/media/ufs.subr1
-rw-r--r--usr.sbin/bsdconfig/share/media/usb.subr1
-rw-r--r--usr.sbin/bsdconfig/share/media/wlan.subr11
-rw-r--r--usr.sbin/bsdconfig/share/mustberoot.subr1
-rw-r--r--usr.sbin/bsdconfig/share/packages/Makefile3
-rw-r--r--usr.sbin/bsdconfig/share/packages/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/share/packages/categories.subr1
-rw-r--r--usr.sbin/bsdconfig/share/packages/index.awk98
-rw-r--r--usr.sbin/bsdconfig/share/packages/index.subr144
-rw-r--r--usr.sbin/bsdconfig/share/packages/musthavepkg.subr35
-rw-r--r--usr.sbin/bsdconfig/share/packages/packages.subr13
-rw-r--r--usr.sbin/bsdconfig/share/script.subr8
-rw-r--r--usr.sbin/bsdconfig/share/strings.subr1
-rw-r--r--usr.sbin/bsdconfig/share/struct.subr1
-rw-r--r--usr.sbin/bsdconfig/share/sysrc.subr1
-rw-r--r--usr.sbin/bsdconfig/share/variable.subr12
-rw-r--r--usr.sbin/bsdconfig/startup/INDEX1
-rw-r--r--usr.sbin/bsdconfig/startup/Makefile1
-rw-r--r--usr.sbin/bsdconfig/startup/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/startup/USAGE1
-rw-r--r--usr.sbin/bsdconfig/startup/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/startup/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/startup/include/messages.subr1
-rwxr-xr-xusr.sbin/bsdconfig/startup/misc1
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcadd1
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcconf1
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcdelete1
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcedit1
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcvar1
-rw-r--r--usr.sbin/bsdconfig/startup/share/Makefile1
-rw-r--r--usr.sbin/bsdconfig/startup/share/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/startup/share/rcconf.subr1
-rw-r--r--usr.sbin/bsdconfig/startup/share/rcedit.subr1
-rw-r--r--usr.sbin/bsdconfig/startup/share/rcvar.subr1
-rwxr-xr-xusr.sbin/bsdconfig/startup/startup1
-rw-r--r--usr.sbin/bsdconfig/timezone/INDEX1
-rw-r--r--usr.sbin/bsdconfig/timezone/Makefile1
-rw-r--r--usr.sbin/bsdconfig/timezone/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/timezone/USAGE1
-rw-r--r--usr.sbin/bsdconfig/timezone/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/timezone/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/timezone/include/messages.subr1
-rw-r--r--usr.sbin/bsdconfig/timezone/share/Makefile1
-rw-r--r--usr.sbin/bsdconfig/timezone/share/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/timezone/share/continents.subr1
-rw-r--r--usr.sbin/bsdconfig/timezone/share/countries.subr1
-rw-r--r--usr.sbin/bsdconfig/timezone/share/iso3166.subr1
-rw-r--r--usr.sbin/bsdconfig/timezone/share/menus.subr1
-rw-r--r--usr.sbin/bsdconfig/timezone/share/zones.subr1
-rwxr-xr-xusr.sbin/bsdconfig/timezone/timezone1
-rw-r--r--usr.sbin/bsdconfig/ttys/INDEX1
-rw-r--r--usr.sbin/bsdconfig/ttys/Makefile1
-rw-r--r--usr.sbin/bsdconfig/ttys/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/ttys/USAGE1
-rw-r--r--usr.sbin/bsdconfig/ttys/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/ttys/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/ttys/include/messages.subr1
-rwxr-xr-xusr.sbin/bsdconfig/ttys/ttys1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/INDEX1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/Makefile1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/USAGE1
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupadd1
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupdel1
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupedit1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/include/Makefile1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/include/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/include/messages.subr1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/Makefile1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/Makefile.depend1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/group.subr1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/group_input.subr1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/user.subr1
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/user_input.subr1
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/useradd1
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/userdel1
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/useredit1
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/usermgmt1
-rw-r--r--usr.sbin/bsdinstall/Makefile18
-rw-r--r--usr.sbin/bsdinstall/Makefile.depend13
-rw-r--r--usr.sbin/bsdinstall/Makefile.inc3
-rwxr-xr-xusr.sbin/bsdinstall/bsdinstall1
-rw-r--r--usr.sbin/bsdinstall/bsdinstall.888
-rw-r--r--usr.sbin/bsdinstall/distextract/Makefile3
-rw-r--r--usr.sbin/bsdinstall/distextract/Makefile.depend15
-rw-r--r--usr.sbin/bsdinstall/distextract/distextract.c5
-rw-r--r--usr.sbin/bsdinstall/distfetch/Makefile2
-rw-r--r--usr.sbin/bsdinstall/distfetch/Makefile.depend9
-rw-r--r--usr.sbin/bsdinstall/distfetch/distfetch.c5
-rw-r--r--usr.sbin/bsdinstall/include/Makefile13
-rw-r--r--usr.sbin/bsdinstall/include/Makefile.depend (renamed from usr.sbin/portsnap/portsnap/Makefile.depend)1
-rw-r--r--usr.sbin/bsdinstall/partedit/Makefile2
-rw-r--r--usr.sbin/bsdinstall/partedit/Makefile.depend9
-rw-r--r--usr.sbin/bsdinstall/partedit/diskmenu.c16
-rw-r--r--usr.sbin/bsdinstall/partedit/diskmenu.h8
-rw-r--r--usr.sbin/bsdinstall/partedit/gpart_ops.c130
-rw-r--r--usr.sbin/bsdinstall/partedit/part_wizard.c60
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit.c45
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit.h4
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_efi.c2
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_generic.c4
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_powerpc.c4
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit_x86.c4
-rw-r--r--usr.sbin/bsdinstall/partedit/sade.82
-rw-r--r--usr.sbin/bsdinstall/partedit/scripted.c59
-rw-r--r--usr.sbin/bsdinstall/runconsoles/Makefile9
-rw-r--r--usr.sbin/bsdinstall/runconsoles/child.c386
-rw-r--r--usr.sbin/bsdinstall/runconsoles/child.h30
-rw-r--r--usr.sbin/bsdinstall/runconsoles/common.c56
-rw-r--r--usr.sbin/bsdinstall/runconsoles/common.h110
-rw-r--r--usr.sbin/bsdinstall/runconsoles/runconsoles.c647
-rw-r--r--usr.sbin/bsdinstall/scripts/Makefile2
-rw-r--r--usr.sbin/bsdinstall/scripts/Makefile.depend1
-rwxr-xr-xusr.sbin/bsdinstall/scripts/adduser1
-rwxr-xr-xusr.sbin/bsdinstall/scripts/auto120
-rwxr-xr-xusr.sbin/bsdinstall/scripts/bootconfig5
-rwxr-xr-xusr.sbin/bsdinstall/scripts/checksum21
-rwxr-xr-xusr.sbin/bsdinstall/scripts/config1
-rwxr-xr-xusr.sbin/bsdinstall/scripts/docsinstall4
-rwxr-xr-xusr.sbin/bsdinstall/scripts/entropy1
-rw-r--r--usr.sbin/bsdinstall/scripts/fetchmissingdists14
-rwxr-xr-xusr.sbin/bsdinstall/scripts/finalconfig82
-rwxr-xr-xusr.sbin/bsdinstall/scripts/hardening15
-rwxr-xr-xusr.sbin/bsdinstall/scripts/hostname15
-rwxr-xr-xusr.sbin/bsdinstall/scripts/jail42
-rwxr-xr-xusr.sbin/bsdinstall/scripts/keymap3
-rwxr-xr-xusr.sbin/bsdinstall/scripts/mirrorselect128
-rwxr-xr-xusr.sbin/bsdinstall/scripts/mount7
-rwxr-xr-xusr.sbin/bsdinstall/scripts/netconfig91
-rwxr-xr-xusr.sbin/bsdinstall/scripts/netconfig_ipv435
-rwxr-xr-xusr.sbin/bsdinstall/scripts/netconfig_ipv639
-rwxr-xr-xusr.sbin/bsdinstall/scripts/rootpass13
-rwxr-xr-xusr.sbin/bsdinstall/scripts/script28
-rwxr-xr-xusr.sbin/bsdinstall/scripts/services25
-rwxr-xr-xusr.sbin/bsdinstall/scripts/time15
-rwxr-xr-xusr.sbin/bsdinstall/scripts/umount8
-rwxr-xr-xusr.sbin/bsdinstall/scripts/wlanconfig1
-rwxr-xr-xusr.sbin/bsdinstall/scripts/zfsboot32
-rw-r--r--usr.sbin/bsdinstall/startbsdinstall114
-rw-r--r--usr.sbin/bsnmpd/Makefile1
-rw-r--r--usr.sbin/bsnmpd/Makefile.inc1
-rw-r--r--usr.sbin/bsnmpd/bsnmpd/Makefile1
-rw-r--r--usr.sbin/bsnmpd/bsnmpd/Makefile.depend3
-rw-r--r--usr.sbin/bsnmpd/bsnmpd/Makefile.depend.options1
-rw-r--r--usr.sbin/bsnmpd/bsnmpd/snmpd.config1
-rw-r--r--usr.sbin/bsnmpd/gensnmptree/Makefile1
-rw-r--r--usr.sbin/bsnmpd/gensnmptree/Makefile.depend2
-rw-r--r--usr.sbin/bsnmpd/modules/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/Makefile.inc1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/BRIDGE-MIB.txt2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/RSTP-MIB.txt2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c4
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c4
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_pf.c4
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c4
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_snmp.c4
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_snmp.h4
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c11
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/bridge_tree.def1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/snmp_bridge.32
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hast/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hast/Makefile.depend4
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c5
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.32
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/BEGEMOT-HOSTRES-MIB.txt2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend3
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_begemot.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_network_tbl.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_printer_tbl.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_processor_tbl.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c8
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h6
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c4
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swinstalled_tbl.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c8
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_tree.def1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/snmp_hostres.32
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_lm75/BEGEMOT-LM75-MIB.txt10
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_lm75/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_lm75/Makefile.depend3
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_lm75/lm75_tree.def1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_lm75/snmp_lm75.32
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_lm75/snmp_lm75.c5
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_mibII/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_netgraph/BEGEMOT-NETGRAPH.txt2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_netgraph/netgraph_tree.def1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.32
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.h2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend5
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c93
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_target/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend3
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_usm/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend3
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_vacm/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend3
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_wlan/BEGEMOT-WIRELESS-MIB.txt2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_wlan/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend3
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_wlan/snmp_wlan.32
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.c4
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.h4
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_wlan/wlan_sys.c8
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_wlan/wlan_tree.def1
-rw-r--r--usr.sbin/bsnmpd/tools/Makefile1
-rw-r--r--usr.sbin/bsnmpd/tools/Makefile.inc1
-rw-r--r--usr.sbin/bsnmpd/tools/bsnmptools/Makefile1
-rw-r--r--usr.sbin/bsnmpd/tools/bsnmptools/Makefile.depend3
-rw-r--r--usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.14
-rw-r--r--usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c2
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/Makefile1
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c2
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c4
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c2
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.h6
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c30
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.h2
-rw-r--r--usr.sbin/btxld/Makefile1
-rw-r--r--usr.sbin/btxld/Makefile.depend2
-rw-r--r--usr.sbin/btxld/btx.h4
-rw-r--r--usr.sbin/btxld/btxld.82
-rw-r--r--usr.sbin/btxld/btxld.c9
-rw-r--r--usr.sbin/btxld/elfh.c4
-rw-r--r--usr.sbin/btxld/elfh.h4
-rw-r--r--usr.sbin/camdd/Makefile1
-rw-r--r--usr.sbin/camdd/Makefile.depend3
-rw-r--r--usr.sbin/camdd/camdd.82
-rw-r--r--usr.sbin/camdd/camdd.c53
-rw-r--r--usr.sbin/cdcontrol/Makefile1
-rw-r--r--usr.sbin/cdcontrol/Makefile.depend3
-rw-r--r--usr.sbin/cdcontrol/cdcontrol.11
-rw-r--r--usr.sbin/cdcontrol/cdcontrol.c4
-rw-r--r--usr.sbin/certctl/Makefile3
-rw-r--r--usr.sbin/certctl/certctl.829
-rwxr-xr-xusr.sbin/certctl/certctl.sh265
-rw-r--r--usr.sbin/chkgrp/Makefile1
-rw-r--r--usr.sbin/chkgrp/Makefile.depend2
-rw-r--r--usr.sbin/chkgrp/chkgrp.84
-rw-r--r--usr.sbin/chkgrp/chkgrp.c4
-rw-r--r--usr.sbin/chown/Makefile2
-rw-r--r--usr.sbin/chown/Makefile.depend2
-rw-r--r--usr.sbin/chown/chgrp.13
-rw-r--r--usr.sbin/chown/chown.86
-rw-r--r--usr.sbin/chown/chown.c15
-rw-r--r--usr.sbin/chown/tests/Makefile1
-rw-r--r--usr.sbin/chown/tests/Makefile.depend1
-rwxr-xr-xusr.sbin/chown/tests/chown_test.sh1
-rw-r--r--usr.sbin/chroot/Makefile2
-rw-r--r--usr.sbin/chroot/Makefile.depend2
-rw-r--r--usr.sbin/chroot/chroot.83
-rw-r--r--usr.sbin/chroot/chroot.c16
-rw-r--r--usr.sbin/ckdist/Makefile1
-rw-r--r--usr.sbin/ckdist/Makefile.depend2
-rw-r--r--usr.sbin/ckdist/ckdist.12
-rw-r--r--usr.sbin/ckdist/ckdist.c9
-rw-r--r--usr.sbin/clear_locks/Makefile1
-rw-r--r--usr.sbin/clear_locks/Makefile.depend2
-rw-r--r--usr.sbin/clear_locks/clear_locks.82
-rw-r--r--usr.sbin/clear_locks/clear_locks.c4
-rw-r--r--usr.sbin/config/Makefile10
-rw-r--r--usr.sbin/config/Makefile.depend7
-rw-r--r--usr.sbin/config/config.56
-rw-r--r--usr.sbin/config/config.85
-rw-r--r--usr.sbin/config/config.h64
-rw-r--r--usr.sbin/config/config.y5
-rw-r--r--usr.sbin/config/configvers.h4
-rw-r--r--usr.sbin/config/kernconf.tmpl2
-rw-r--r--usr.sbin/config/lang.l5
-rw-r--r--usr.sbin/config/main.cc (renamed from usr.sbin/config/main.c)203
-rw-r--r--usr.sbin/config/mkheaders.c8
-rw-r--r--usr.sbin/config/mkmakefile.cc (renamed from usr.sbin/config/mkmakefile.c)162
-rw-r--r--usr.sbin/config/mkoptions.cc (renamed from usr.sbin/config/mkoptions.c)96
-rw-r--r--usr.sbin/cpucontrol/Makefile7
-rw-r--r--usr.sbin/cpucontrol/Makefile.depend2
-rw-r--r--usr.sbin/cpucontrol/amd.c4
-rw-r--r--usr.sbin/cpucontrol/amd.h45
-rw-r--r--usr.sbin/cpucontrol/amd10h.c144
-rw-r--r--usr.sbin/cpucontrol/cpucontrol.82
-rw-r--r--usr.sbin/cpucontrol/cpucontrol.c4
-rw-r--r--usr.sbin/cpucontrol/cpucontrol.h4
-rw-r--r--usr.sbin/cpucontrol/intel.c4
-rw-r--r--usr.sbin/cpucontrol/intel.h4
-rw-r--r--usr.sbin/cpucontrol/via.c4
-rw-r--r--usr.sbin/cpucontrol/via.h4
-rw-r--r--usr.sbin/crashinfo/Makefile1
-rw-r--r--usr.sbin/crashinfo/Makefile.depend1
-rw-r--r--usr.sbin/crashinfo/crashinfo.84
-rwxr-xr-xusr.sbin/crashinfo/crashinfo.sh34
-rw-r--r--usr.sbin/cron/Makefile1
-rw-r--r--usr.sbin/cron/Makefile.inc1
-rw-r--r--usr.sbin/cron/cron/Makefile1
-rw-r--r--usr.sbin/cron/cron/Makefile.depend2
-rw-r--r--usr.sbin/cron/cron/compat.h136
-rw-r--r--usr.sbin/cron/cron/config.h56
-rw-r--r--usr.sbin/cron/cron/cron.832
-rw-r--r--usr.sbin/cron/cron/cron.c156
-rw-r--r--usr.sbin/cron/cron/cron.h323
-rw-r--r--usr.sbin/cron/cron/crontab1
-rw-r--r--usr.sbin/cron/cron/database.c111
-rw-r--r--usr.sbin/cron/cron/do_command.c134
-rw-r--r--usr.sbin/cron/cron/externs.h199
-rw-r--r--usr.sbin/cron/cron/funcs.h70
-rw-r--r--usr.sbin/cron/cron/globals.h75
-rw-r--r--usr.sbin/cron/cron/job.c57
-rw-r--r--usr.sbin/cron/cron/macros.h134
-rw-r--r--usr.sbin/cron/cron/pathnames.h44
-rw-r--r--usr.sbin/cron/cron/popen.c40
-rw-r--r--usr.sbin/cron/cron/structs.h81
-rw-r--r--usr.sbin/cron/cron/user.c67
-rw-r--r--usr.sbin/cron/crontab/Makefile1
-rw-r--r--usr.sbin/cron/crontab/Makefile.depend2
-rw-r--r--usr.sbin/cron/crontab/crontab.132
-rw-r--r--usr.sbin/cron/crontab/crontab.530
-rw-r--r--usr.sbin/cron/crontab/crontab.c194
-rw-r--r--usr.sbin/cron/doc/CHANGES1
-rw-r--r--usr.sbin/cron/doc/CONVERSION1
-rw-r--r--usr.sbin/cron/doc/FEATURES1
-rw-r--r--usr.sbin/cron/doc/INSTALL28
-rw-r--r--usr.sbin/cron/doc/MAIL2
-rw-r--r--usr.sbin/cron/doc/Makefile.vixie68
-rw-r--r--usr.sbin/cron/doc/README46
-rw-r--r--usr.sbin/cron/lib/Makefile1
-rw-r--r--usr.sbin/cron/lib/Makefile.depend1
-rw-r--r--usr.sbin/cron/lib/compat.c225
-rw-r--r--usr.sbin/cron/lib/entry.c137
-rw-r--r--usr.sbin/cron/lib/env.c71
-rw-r--r--usr.sbin/cron/lib/misc.c138
-rw-r--r--usr.sbin/crunch/Makefile1
-rw-r--r--usr.sbin/crunch/Makefile.inc1
-rw-r--r--usr.sbin/crunch/README2
-rw-r--r--usr.sbin/crunch/crunchgen/Makefile1
-rw-r--r--usr.sbin/crunch/crunchgen/Makefile.depend2
-rw-r--r--usr.sbin/crunch/crunchgen/crunched_main.c3
-rw-r--r--usr.sbin/crunch/crunchgen/crunchgen.11
-rw-r--r--usr.sbin/crunch/crunchgen/crunchgen.c11
-rw-r--r--usr.sbin/crunch/crunchide/Makefile1
-rw-r--r--usr.sbin/crunch/crunchide/Makefile.depend2
-rw-r--r--usr.sbin/crunch/crunchide/crunchide.11
-rw-r--r--usr.sbin/crunch/crunchide/crunchide.c4
-rw-r--r--usr.sbin/crunch/crunchide/exec_elf32.c4
-rw-r--r--usr.sbin/crunch/crunchide/exec_elf64.c2
-rw-r--r--usr.sbin/crunch/crunchide/extern.h1
-rw-r--r--usr.sbin/crunch/examples/Makefile1
-rw-r--r--usr.sbin/crunch/examples/filesystem.conf3
-rw-r--r--usr.sbin/crunch/examples/fixit.conf3
-rw-r--r--usr.sbin/crunch/examples/kcopy.conf1
-rw-r--r--usr.sbin/crunch/examples/really-big.conf3
-rw-r--r--usr.sbin/ctladm/Makefile1
-rw-r--r--usr.sbin/ctladm/Makefile.depend3
-rw-r--r--usr.sbin/ctladm/ctladm.85
-rw-r--r--usr.sbin/ctladm/ctladm.c20
-rw-r--r--usr.sbin/ctladm/ctladm.h2
-rw-r--r--usr.sbin/ctladm/util.c2
-rw-r--r--usr.sbin/ctld/Makefile1
-rw-r--r--usr.sbin/ctld/Makefile.depend7
-rw-r--r--usr.sbin/ctld/ctl.conf.52
-rw-r--r--usr.sbin/ctld/ctld.82
-rw-r--r--usr.sbin/ctld/ctld.c10
-rw-r--r--usr.sbin/ctld/ctld.h4
-rw-r--r--usr.sbin/ctld/discovery.c4
-rw-r--r--usr.sbin/ctld/isns.c5
-rw-r--r--usr.sbin/ctld/isns.h2
-rw-r--r--usr.sbin/ctld/kernel.c5
-rw-r--r--usr.sbin/ctld/login.c4
-rw-r--r--usr.sbin/ctld/parse.y4
-rw-r--r--usr.sbin/ctld/token.l4
-rw-r--r--usr.sbin/ctld/uclparse.c30
-rw-r--r--usr.sbin/cxgbetool/Makefile1
-rw-r--r--usr.sbin/cxgbetool/Makefile.depend3
-rw-r--r--usr.sbin/cxgbetool/cxgbetool.82
-rw-r--r--usr.sbin/cxgbetool/cxgbetool.c56
-rw-r--r--usr.sbin/cxgbetool/reg_defs_t4.c2
-rw-r--r--usr.sbin/cxgbetool/reg_defs_t4vf.c2
-rw-r--r--usr.sbin/cxgbetool/reg_defs_t5.c2
-rw-r--r--usr.sbin/cxgbetool/reg_defs_t6.c2
-rw-r--r--usr.sbin/cxgbetool/tcb_common.c6
-rw-r--r--usr.sbin/cxgbetool/tcb_common.h4
-rw-r--r--usr.sbin/cxgbetool/tcbinfot4.c6
-rw-r--r--usr.sbin/cxgbetool/tcbinfot5.c6
-rw-r--r--usr.sbin/cxgbetool/tcbinfot6.c6
-rw-r--r--usr.sbin/cxgbetool/tcbshowt4.c6
-rw-r--r--usr.sbin/cxgbetool/tcbshowt5.c6
-rw-r--r--usr.sbin/cxgbetool/tcbshowt6.c6
-rw-r--r--usr.sbin/daemon/Makefile1
-rw-r--r--usr.sbin/daemon/Makefile.depend2
-rw-r--r--usr.sbin/daemon/daemon.8166
-rw-r--r--usr.sbin/daemon/daemon.c940
-rw-r--r--usr.sbin/daemon/tests/Makefile1
-rw-r--r--usr.sbin/daemon/tests/daemon_test.sh4
-rw-r--r--usr.sbin/dconschat/Makefile1
-rw-r--r--usr.sbin/dconschat/Makefile.depend3
-rw-r--r--usr.sbin/dconschat/dconschat.826
-rw-r--r--usr.sbin/dconschat/dconschat.c4
-rw-r--r--usr.sbin/devctl/Makefile1
-rw-r--r--usr.sbin/devctl/Makefile.depend2
-rw-r--r--usr.sbin/devctl/devctl.82
-rw-r--r--usr.sbin/devctl/devctl.c2
-rw-r--r--usr.sbin/devinfo/Makefile2
-rw-r--r--usr.sbin/devinfo/Makefile.depend3
-rw-r--r--usr.sbin/devinfo/devinfo.85
-rw-r--r--usr.sbin/devinfo/devinfo.c5
-rw-r--r--usr.sbin/diskinfo/Makefile1
-rw-r--r--usr.sbin/diskinfo/Makefile.depend2
-rw-r--r--usr.sbin/diskinfo/diskinfo.825
-rw-r--r--usr.sbin/diskinfo/diskinfo.c21
-rw-r--r--usr.sbin/dumpcis/Makefile1
-rw-r--r--usr.sbin/dumpcis/Makefile.depend2
-rw-r--r--usr.sbin/dumpcis/cardinfo.h1
-rw-r--r--usr.sbin/dumpcis/cis.h2
-rw-r--r--usr.sbin/dumpcis/dumpcis.82
-rw-r--r--usr.sbin/dumpcis/main.c4
-rw-r--r--usr.sbin/dumpcis/printcis.c2
-rw-r--r--usr.sbin/dumpcis/readcis.c2
-rw-r--r--usr.sbin/dumpcis/readcis.h2
-rw-r--r--usr.sbin/editmap/Makefile3
-rw-r--r--usr.sbin/editmap/Makefile.depend2
-rw-r--r--usr.sbin/edquota/Makefile2
-rw-r--r--usr.sbin/edquota/Makefile.depend2
-rw-r--r--usr.sbin/edquota/edquota.83
-rw-r--r--usr.sbin/edquota/edquota.c17
-rw-r--r--usr.sbin/edquota/pathnames.h3
-rw-r--r--usr.sbin/efibootmgr/Makefile1
-rw-r--r--usr.sbin/efibootmgr/efibootmgr.836
-rw-r--r--usr.sbin/efibootmgr/efibootmgr.c82
-rw-r--r--usr.sbin/efidp/Makefile1
-rw-r--r--usr.sbin/efidp/Makefile.depend3
-rw-r--r--usr.sbin/efidp/efidp.82
-rw-r--r--usr.sbin/efidp/efidp.c7
-rw-r--r--usr.sbin/efitable/Makefile1
-rw-r--r--usr.sbin/efitable/efitable.82
-rw-r--r--usr.sbin/efitable/efitable.c12
-rw-r--r--usr.sbin/efivar/Makefile1
-rw-r--r--usr.sbin/efivar/Makefile.depend3
-rw-r--r--usr.sbin/efivar/efiutil.c2
-rw-r--r--usr.sbin/efivar/efiutil.h2
-rw-r--r--usr.sbin/efivar/efivar.82
-rw-r--r--usr.sbin/efivar/efivar.c2
-rw-r--r--usr.sbin/efiwake/Makefile12
-rw-r--r--usr.sbin/efiwake/efiwake.899
-rw-r--r--usr.sbin/efiwake/efiwake.c140
-rw-r--r--usr.sbin/etcupdate/Makefile1
-rw-r--r--usr.sbin/etcupdate/Makefile.depend1
-rw-r--r--usr.sbin/etcupdate/etcupdate.838
-rwxr-xr-xusr.sbin/etcupdate/etcupdate.sh127
-rw-r--r--usr.sbin/etcupdate/tests/Makefile1
-rw-r--r--usr.sbin/etcupdate/tests/Makefile.depend1
-rw-r--r--usr.sbin/etcupdate/tests/always_test.sh1
-rw-r--r--usr.sbin/etcupdate/tests/conflicts_test.sh1
-rw-r--r--usr.sbin/etcupdate/tests/fbsdid_test.sh1
-rw-r--r--usr.sbin/etcupdate/tests/ignore_test.sh1
-rw-r--r--usr.sbin/etcupdate/tests/preworld_test.sh3
-rw-r--r--usr.sbin/etcupdate/tests/tests_test.sh1
-rw-r--r--usr.sbin/etcupdate/tests/tzsetup_test.sh6
-rw-r--r--usr.sbin/extattr/Makefile1
-rw-r--r--usr.sbin/extattr/Makefile.depend2
-rw-r--r--usr.sbin/extattr/rmextattr.82
-rw-r--r--usr.sbin/extattr/rmextattr.c3
-rw-r--r--usr.sbin/extattr/tests/Makefile1
-rw-r--r--usr.sbin/extattr/tests/Makefile.depend1
-rwxr-xr-xusr.sbin/extattr/tests/extattr_test.sh1
-rw-r--r--usr.sbin/extattrctl/Makefile1
-rw-r--r--usr.sbin/extattrctl/Makefile.depend2
-rw-r--r--usr.sbin/extattrctl/extattrctl.82
-rw-r--r--usr.sbin/extattrctl/extattrctl.c4
-rw-r--r--usr.sbin/fdcontrol/Makefile1
-rw-r--r--usr.sbin/fdcontrol/Makefile.depend2
-rw-r--r--usr.sbin/fdcontrol/fdcontrol.82
-rw-r--r--usr.sbin/fdcontrol/fdcontrol.c6
-rw-r--r--usr.sbin/fdformat/Makefile1
-rw-r--r--usr.sbin/fdformat/Makefile.depend2
-rw-r--r--usr.sbin/fdformat/fdformat.82
-rw-r--r--usr.sbin/fdformat/fdformat.c4
-rw-r--r--usr.sbin/fdread/Makefile1
-rw-r--r--usr.sbin/fdread/Makefile.depend2
-rw-r--r--usr.sbin/fdread/fdread.12
-rw-r--r--usr.sbin/fdread/fdread.c4
-rw-r--r--usr.sbin/fdread/fdutil.c4
-rw-r--r--usr.sbin/fdread/fdutil.h4
-rw-r--r--usr.sbin/fdwrite/Makefile1
-rw-r--r--usr.sbin/fdwrite/Makefile.depend2
-rw-r--r--usr.sbin/fdwrite/fdwrite.18
-rw-r--r--usr.sbin/fdwrite/fdwrite.c10
-rw-r--r--usr.sbin/fifolog/Makefile1
-rw-r--r--usr.sbin/fifolog/Makefile.inc1
-rw-r--r--usr.sbin/fifolog/fifolog_create/Makefile1
-rw-r--r--usr.sbin/fifolog/fifolog_create/Makefile.depend2
-rw-r--r--usr.sbin/fifolog/fifolog_create/fifolog.12
-rw-r--r--usr.sbin/fifolog/fifolog_create/fifolog_create.c4
-rw-r--r--usr.sbin/fifolog/fifolog_reader/Makefile1
-rw-r--r--usr.sbin/fifolog/fifolog_reader/Makefile.depend2
-rw-r--r--usr.sbin/fifolog/fifolog_reader/fifolog_reader.c4
-rw-r--r--usr.sbin/fifolog/fifolog_writer/Makefile1
-rw-r--r--usr.sbin/fifolog/fifolog_writer/Makefile.depend2
-rw-r--r--usr.sbin/fifolog/fifolog_writer/fifolog_writer.c4
-rw-r--r--usr.sbin/fifolog/lib/Makefile1
-rw-r--r--usr.sbin/fifolog/lib/Makefile.depend1
-rw-r--r--usr.sbin/fifolog/lib/fifolog.h4
-rw-r--r--usr.sbin/fifolog/lib/fifolog_create.c4
-rw-r--r--usr.sbin/fifolog/lib/fifolog_int.c4
-rw-r--r--usr.sbin/fifolog/lib/fifolog_reader.c4
-rw-r--r--usr.sbin/fifolog/lib/fifolog_write.h4
-rw-r--r--usr.sbin/fifolog/lib/fifolog_write_poll.c4
-rw-r--r--usr.sbin/fifolog/lib/getdate.y15
-rw-r--r--usr.sbin/fifolog/lib/libfifolog.h4
-rw-r--r--usr.sbin/fifolog/lib/libfifolog_int.h4
-rw-r--r--usr.sbin/fifolog/lib/miniobj.h4
-rw-r--r--usr.sbin/flowctl/Makefile3
-rw-r--r--usr.sbin/flowctl/Makefile.depend2
-rw-r--r--usr.sbin/flowctl/flowctl.82
-rw-r--r--usr.sbin/flowctl/flowctl.c7
-rw-r--r--usr.sbin/freebsd-update/Makefile1
-rw-r--r--usr.sbin/freebsd-update/Makefile.depend1
-rw-r--r--usr.sbin/freebsd-update/freebsd-update.881
-rw-r--r--usr.sbin/freebsd-update/freebsd-update.conf1
-rw-r--r--usr.sbin/freebsd-update/freebsd-update.sh185
-rw-r--r--usr.sbin/fstyp/Makefile1
-rw-r--r--usr.sbin/fstyp/Makefile.depend11
-rw-r--r--usr.sbin/fstyp/Makefile.depend.options1
-rw-r--r--usr.sbin/fstyp/apfs.c2
-rw-r--r--usr.sbin/fstyp/befs.c4
-rw-r--r--usr.sbin/fstyp/cd9660.c2
-rw-r--r--usr.sbin/fstyp/exfat.c3
-rw-r--r--usr.sbin/fstyp/ext2fs.c2
-rw-r--r--usr.sbin/fstyp/fstyp.82
-rw-r--r--usr.sbin/fstyp/fstyp.c3
-rw-r--r--usr.sbin/fstyp/fstyp.h2
-rw-r--r--usr.sbin/fstyp/geli.c2
-rw-r--r--usr.sbin/fstyp/hammer.c2
-rw-r--r--usr.sbin/fstyp/hammer2.c2
-rw-r--r--usr.sbin/fstyp/hammer2_disk.h8
-rw-r--r--usr.sbin/fstyp/hammer_disk.h5
-rw-r--r--usr.sbin/fstyp/hfsplus.c2
-rw-r--r--usr.sbin/fstyp/msdosfs.c2
-rw-r--r--usr.sbin/fstyp/msdosfs.h2
-rw-r--r--usr.sbin/fstyp/ntfs.c2
-rw-r--r--usr.sbin/fstyp/tests/Makefile1
-rw-r--r--usr.sbin/fstyp/tests/Makefile.depend1
-rwxr-xr-xusr.sbin/fstyp/tests/fstyp_test.sh4
-rw-r--r--usr.sbin/fstyp/ufs.c7
-rw-r--r--usr.sbin/fstyp/zfs.c5
-rw-r--r--usr.sbin/ftp-proxy/Makefile2
-rw-r--r--usr.sbin/ftp-proxy/Makefile.depend6
-rw-r--r--usr.sbin/fwcontrol/Makefile2
-rw-r--r--usr.sbin/fwcontrol/Makefile.depend2
-rw-r--r--usr.sbin/fwcontrol/fwcontrol.82
-rw-r--r--usr.sbin/fwcontrol/fwcontrol.c1
-rw-r--r--usr.sbin/fwcontrol/fwdv.c2
-rw-r--r--usr.sbin/fwcontrol/fwmethods.h2
-rw-r--r--usr.sbin/fwcontrol/fwmpegts.c1
-rw-r--r--usr.sbin/fwget/Makefile7
-rw-r--r--usr.sbin/fwget/fwget.864
-rw-r--r--usr.sbin/fwget/fwget.sh125
-rw-r--r--usr.sbin/fwget/pci/Makefile14
-rw-r--r--usr.sbin/fwget/pci/pci113
-rw-r--r--usr.sbin/fwget/pci/pci_network_mediatek72
-rw-r--r--usr.sbin/fwget/pci/pci_network_qca81
-rw-r--r--usr.sbin/fwget/pci/pci_network_realtek65
-rw-r--r--usr.sbin/fwget/pci/pci_video_amd154
-rw-r--r--usr.sbin/fwget/pci/pci_video_intel78
-rw-r--r--usr.sbin/getfmac/Makefile1
-rw-r--r--usr.sbin/getfmac/Makefile.depend2
-rw-r--r--usr.sbin/getfmac/getfmac.82
-rw-r--r--usr.sbin/getfmac/getfmac.c2
-rw-r--r--usr.sbin/getpmac/Makefile1
-rw-r--r--usr.sbin/getpmac/Makefile.depend2
-rw-r--r--usr.sbin/getpmac/getpmac.82
-rw-r--r--usr.sbin/getpmac/getpmac.c2
-rw-r--r--usr.sbin/gpioctl/Makefile1
-rw-r--r--usr.sbin/gpioctl/Makefile.depend2
-rw-r--r--usr.sbin/gpioctl/gpioctl.82
-rw-r--r--usr.sbin/gpioctl/gpioctl.c4
-rw-r--r--usr.sbin/gssd/Makefile1
-rw-r--r--usr.sbin/gssd/Makefile.depend5
-rw-r--r--usr.sbin/gssd/Makefile.depend.options1
-rw-r--r--usr.sbin/gssd/gssd.82
-rw-r--r--usr.sbin/gssd/gssd.c99
-rw-r--r--usr.sbin/gstat/Makefile1
-rw-r--r--usr.sbin/gstat/Makefile.depend8
-rw-r--r--usr.sbin/gstat/gstat.82
-rw-r--r--usr.sbin/gstat/gstat.c6
-rw-r--r--usr.sbin/hyperv/Makefile1
-rw-r--r--usr.sbin/hyperv/Makefile.inc1
-rw-r--r--usr.sbin/hyperv/tools/Makefile.inc1
-rw-r--r--usr.sbin/hyperv/tools/kvp/Makefile1
-rw-r--r--usr.sbin/hyperv/tools/kvp/Makefile.depend2
-rw-r--r--usr.sbin/hyperv/tools/vss/Makefile1
-rw-r--r--usr.sbin/hyperv/tools/vss/Makefile.depend2
-rw-r--r--usr.sbin/i2c/Makefile1
-rw-r--r--usr.sbin/i2c/Makefile.depend2
-rw-r--r--usr.sbin/i2c/i2c.84
-rw-r--r--usr.sbin/i2c/i2c.c4
-rw-r--r--usr.sbin/ifmcstat/Makefile2
-rw-r--r--usr.sbin/ifmcstat/Makefile.depend2
-rw-r--r--usr.sbin/ifmcstat/ifmcstat.82
-rw-r--r--usr.sbin/ifmcstat/ifmcstat.c3
-rw-r--r--usr.sbin/ifmcstat/printb.c2
-rw-r--r--usr.sbin/inetd/Makefile3
-rw-r--r--usr.sbin/inetd/Makefile.depend1
-rw-r--r--usr.sbin/inetd/Makefile.depend.options1
-rw-r--r--usr.sbin/inetd/builtins.c10
-rw-r--r--usr.sbin/inetd/inetd.87
-rw-r--r--usr.sbin/inetd/inetd.c14
-rw-r--r--usr.sbin/inetd/inetd.conf5
-rw-r--r--usr.sbin/inetd/inetd.h2
-rw-r--r--usr.sbin/inetd/pathnames.h3
-rw-r--r--usr.sbin/iostat/Makefile2
-rw-r--r--usr.sbin/iostat/Makefile.depend3
-rw-r--r--usr.sbin/iostat/iostat.8102
-rw-r--r--usr.sbin/iostat/iostat.c56
-rw-r--r--usr.sbin/iovctl/Makefile1
-rw-r--r--usr.sbin/iovctl/Makefile.depend2
-rw-r--r--usr.sbin/iovctl/iovctl.82
-rw-r--r--usr.sbin/iovctl/iovctl.c3
-rw-r--r--usr.sbin/iovctl/iovctl.conf.52
-rw-r--r--usr.sbin/iovctl/iovctl.h2
-rw-r--r--usr.sbin/iovctl/parse.c7
-rw-r--r--usr.sbin/iovctl/validate.c3
-rw-r--r--usr.sbin/ip6addrctl/Makefile1
-rw-r--r--usr.sbin/ip6addrctl/Makefile.depend2
-rw-r--r--usr.sbin/ip6addrctl/ip6addrctl.82
-rw-r--r--usr.sbin/ip6addrctl/ip6addrctl.c4
-rw-r--r--usr.sbin/ip6addrctl/ip6addrctl.conf.sample1
-rw-r--r--usr.sbin/ipfwpcap/Makefile1
-rw-r--r--usr.sbin/ipfwpcap/Makefile.depend3
-rw-r--r--usr.sbin/ipfwpcap/ipfwpcap.82
-rw-r--r--usr.sbin/ipfwpcap/ipfwpcap.c4
-rw-r--r--usr.sbin/iscsid/Makefile1
-rw-r--r--usr.sbin/iscsid/Makefile.depend6
-rw-r--r--usr.sbin/iscsid/discovery.c5
-rw-r--r--usr.sbin/iscsid/iscsid.82
-rw-r--r--usr.sbin/iscsid/iscsid.c5
-rw-r--r--usr.sbin/iscsid/iscsid.h4
-rw-r--r--usr.sbin/iscsid/login.c5
-rw-r--r--usr.sbin/jail/Makefile2
-rw-r--r--usr.sbin/jail/Makefile.depend4
-rw-r--r--usr.sbin/jail/command.c36
-rw-r--r--usr.sbin/jail/config.c95
-rw-r--r--usr.sbin/jail/jail.8170
-rw-r--r--usr.sbin/jail/jail.c182
-rw-r--r--usr.sbin/jail/jail.conf.537
-rw-r--r--usr.sbin/jail/jaillex.l80
-rw-r--r--usr.sbin/jail/jailp.h44
-rw-r--r--usr.sbin/jail/jailparse.y124
-rw-r--r--usr.sbin/jail/state.c8
-rw-r--r--usr.sbin/jail/tests/Makefile1
-rw-r--r--usr.sbin/jail/tests/commands.jail.conf1
-rwxr-xr-xusr.sbin/jail/tests/jail_basic_test.sh4
-rw-r--r--usr.sbin/jexec/Makefile1
-rw-r--r--usr.sbin/jexec/Makefile.depend2
-rw-r--r--usr.sbin/jexec/jexec.842
-rw-r--r--usr.sbin/jexec/jexec.c4
-rw-r--r--usr.sbin/jls/Makefile1
-rw-r--r--usr.sbin/jls/Makefile.depend5
-rw-r--r--usr.sbin/jls/jls.82
-rw-r--r--usr.sbin/jls/jls.c12
-rw-r--r--usr.sbin/kbdcontrol/Makefile10
-rw-r--r--usr.sbin/kbdcontrol/Makefile.depend3
-rw-r--r--usr.sbin/kbdcontrol/kbdcontrol.13
-rw-r--r--usr.sbin/kbdcontrol/kbdcontrol.c166
-rw-r--r--usr.sbin/kbdcontrol/kbdmap.52
-rw-r--r--usr.sbin/kbdcontrol/lex.h4
-rw-r--r--usr.sbin/kbdcontrol/lex.l4
-rw-r--r--usr.sbin/kbdcontrol/path.h1
-rw-r--r--usr.sbin/kbdmap/Makefile2
-rw-r--r--usr.sbin/kbdmap/Makefile.depend3
-rw-r--r--usr.sbin/kbdmap/TODO1
-rw-r--r--usr.sbin/kbdmap/kbdmap.12
-rw-r--r--usr.sbin/kbdmap/kbdmap.c9
-rw-r--r--usr.sbin/kbdmap/kbdmap.h4
-rw-r--r--usr.sbin/keyserv/Makefile1
-rw-r--r--usr.sbin/keyserv/Makefile.depend2
-rw-r--r--usr.sbin/keyserv/crypt_server.c16
-rw-r--r--usr.sbin/keyserv/keyserv.87
-rw-r--r--usr.sbin/keyserv/keyserv.c99
-rw-r--r--usr.sbin/keyserv/keyserv.h1
-rw-r--r--usr.sbin/keyserv/setkey.c95
-rw-r--r--usr.sbin/kldxref/Makefile16
-rw-r--r--usr.sbin/kldxref/Makefile.depend2
-rw-r--r--usr.sbin/kldxref/ef.c746
-rw-r--r--usr.sbin/kldxref/ef.h330
-rw-r--r--usr.sbin/kldxref/ef_aarch64.c49
-rw-r--r--usr.sbin/kldxref/ef_amd64.c79
-rw-r--r--usr.sbin/kldxref/ef_arm.c94
-rw-r--r--usr.sbin/kldxref/ef_i386.c71
-rw-r--r--usr.sbin/kldxref/ef_mips.c91
-rw-r--r--usr.sbin/kldxref/ef_obj.c431
-rw-r--r--usr.sbin/kldxref/ef_powerpc.c76
-rw-r--r--usr.sbin/kldxref/ef_riscv.c49
-rw-r--r--usr.sbin/kldxref/elf.c688
-rw-r--r--usr.sbin/kldxref/fileformat1
-rw-r--r--usr.sbin/kldxref/kldxref.814
-rw-r--r--usr.sbin/kldxref/kldxref.c446
-rw-r--r--usr.sbin/lastlogin/Makefile2
-rw-r--r--usr.sbin/lastlogin/Makefile.depend3
-rw-r--r--usr.sbin/lastlogin/lastlogin.81
-rw-r--r--usr.sbin/lastlogin/lastlogin.c1
-rw-r--r--usr.sbin/lpr/Makefile1
-rw-r--r--usr.sbin/lpr/Makefile.inc1
-rw-r--r--usr.sbin/lpr/chkprintcap/Makefile1
-rw-r--r--usr.sbin/lpr/chkprintcap/Makefile.depend2
-rw-r--r--usr.sbin/lpr/chkprintcap/chkprintcap.82
-rw-r--r--usr.sbin/lpr/chkprintcap/chkprintcap.c2
-rw-r--r--usr.sbin/lpr/chkprintcap/skimprintcap.c4
-rw-r--r--usr.sbin/lpr/chkprintcap/skimprintcap.h3
-rw-r--r--usr.sbin/lpr/common_source/Makefile1
-rw-r--r--usr.sbin/lpr/common_source/Makefile.depend1
-rw-r--r--usr.sbin/lpr/common_source/common.c10
-rw-r--r--usr.sbin/lpr/common_source/ctlinfo.c4
-rw-r--r--usr.sbin/lpr/common_source/ctlinfo.h5
-rw-r--r--usr.sbin/lpr/common_source/displayq.c8
-rw-r--r--usr.sbin/lpr/common_source/lp.cdefs.h17
-rw-r--r--usr.sbin/lpr/common_source/lp.h3
-rw-r--r--usr.sbin/lpr/common_source/lp.local.h5
-rw-r--r--usr.sbin/lpr/common_source/matchjobs.c4
-rw-r--r--usr.sbin/lpr/common_source/matchjobs.h3
-rw-r--r--usr.sbin/lpr/common_source/net.c4
-rw-r--r--usr.sbin/lpr/common_source/pathnames.h4
-rw-r--r--usr.sbin/lpr/common_source/printcap.c8
-rw-r--r--usr.sbin/lpr/common_source/request.c2
-rw-r--r--usr.sbin/lpr/common_source/rmjob.c8
-rw-r--r--usr.sbin/lpr/common_source/startdaemon.c8
-rw-r--r--usr.sbin/lpr/filters.ru/Makefile1
-rw-r--r--usr.sbin/lpr/filters.ru/Makefile.depend1
-rw-r--r--usr.sbin/lpr/filters.ru/Makefile.inc1
-rw-r--r--usr.sbin/lpr/filters.ru/koi2855/Makefile1
-rw-r--r--usr.sbin/lpr/filters.ru/koi2855/Makefile.depend2
-rw-r--r--usr.sbin/lpr/filters.ru/koi2855/koi2855.c4
-rw-r--r--usr.sbin/lpr/filters.ru/koi2alt/Makefile1
-rw-r--r--usr.sbin/lpr/filters.ru/koi2alt/Makefile.depend2
-rw-r--r--usr.sbin/lpr/filters.ru/koi2alt/koi2alt.c4
-rw-r--r--usr.sbin/lpr/filters/Makefile2
-rw-r--r--usr.sbin/lpr/filters/Makefile.depend2
-rw-r--r--usr.sbin/lpr/filters/lpf.c14
-rw-r--r--usr.sbin/lpr/lp/Makefile1
-rw-r--r--usr.sbin/lpr/lp/Makefile.depend1
-rw-r--r--usr.sbin/lpr/lp/lp.12
-rw-r--r--usr.sbin/lpr/lp/lp.sh1
-rw-r--r--usr.sbin/lpr/lpc/Makefile2
-rw-r--r--usr.sbin/lpr/lpc/Makefile.depend3
-rw-r--r--usr.sbin/lpr/lpc/cmds.c18
-rw-r--r--usr.sbin/lpr/lpc/cmdtab.c8
-rw-r--r--usr.sbin/lpr/lpc/extern.h4
-rw-r--r--usr.sbin/lpr/lpc/lpc.83
-rw-r--r--usr.sbin/lpr/lpc/lpc.c14
-rw-r--r--usr.sbin/lpr/lpc/lpc.h4
-rw-r--r--usr.sbin/lpr/lpc/movejobs.c4
-rw-r--r--usr.sbin/lpr/lpd/Makefile2
-rw-r--r--usr.sbin/lpr/lpd/Makefile.depend2
-rw-r--r--usr.sbin/lpr/lpd/extern.h3
-rw-r--r--usr.sbin/lpr/lpd/hosts.lpd1
-rw-r--r--usr.sbin/lpr/lpd/lpd.85
-rw-r--r--usr.sbin/lpr/lpd/lpd.c14
-rw-r--r--usr.sbin/lpr/lpd/lpdchar.c8
-rw-r--r--usr.sbin/lpr/lpd/modes.c8
-rw-r--r--usr.sbin/lpr/lpd/printcap2
-rw-r--r--usr.sbin/lpr/lpd/printjob.c14
-rw-r--r--usr.sbin/lpr/lpd/recvjob.c16
-rw-r--r--usr.sbin/lpr/lpq/Makefile2
-rw-r--r--usr.sbin/lpr/lpq/Makefile.depend2
-rw-r--r--usr.sbin/lpr/lpq/lpq.13
-rw-r--r--usr.sbin/lpr/lpq/lpq.c14
-rw-r--r--usr.sbin/lpr/lpr/Makefile2
-rw-r--r--usr.sbin/lpr/lpr/Makefile.depend2
-rw-r--r--usr.sbin/lpr/lpr/lpr.17
-rw-r--r--usr.sbin/lpr/lpr/lpr.c16
-rw-r--r--usr.sbin/lpr/lpr/printcap.53
-rw-r--r--usr.sbin/lpr/lprm/Makefile2
-rw-r--r--usr.sbin/lpr/lprm/Makefile.depend2
-rw-r--r--usr.sbin/lpr/lprm/lprm.13
-rw-r--r--usr.sbin/lpr/lprm/lprm.c14
-rw-r--r--usr.sbin/lpr/lptest/Makefile2
-rw-r--r--usr.sbin/lpr/lptest/Makefile.depend2
-rw-r--r--usr.sbin/lpr/lptest/lptest.13
-rw-r--r--usr.sbin/lpr/lptest/lptest.c14
-rw-r--r--usr.sbin/lpr/pac/Makefile2
-rw-r--r--usr.sbin/lpr/pac/Makefile.depend2
-rw-r--r--usr.sbin/lpr/pac/pac.83
-rw-r--r--usr.sbin/lpr/pac/pac.c14
-rw-r--r--usr.sbin/lptcontrol/Makefile1
-rw-r--r--usr.sbin/lptcontrol/Makefile.depend2
-rw-r--r--usr.sbin/lptcontrol/lptcontrol.82
-rw-r--r--usr.sbin/lptcontrol/lptcontrol.c2
-rw-r--r--usr.sbin/mailstats/Makefile4
-rw-r--r--usr.sbin/mailstats/Makefile.depend2
-rw-r--r--usr.sbin/mailwrapper/Makefile21
-rw-r--r--usr.sbin/mailwrapper/Makefile.depend2
-rw-r--r--usr.sbin/mailwrapper/mailwrapper.81
-rw-r--r--usr.sbin/mailwrapper/mailwrapper.c3
-rw-r--r--usr.sbin/mailwrapper/pathnames.h3
-rw-r--r--usr.sbin/makefs/Makefile17
-rw-r--r--usr.sbin/makefs/Makefile.depend1
-rw-r--r--usr.sbin/makefs/Makefile.depend.host11
-rw-r--r--usr.sbin/makefs/Makefile.depend.options6
-rw-r--r--usr.sbin/makefs/cd9660.c116
-rw-r--r--usr.sbin/makefs/cd9660.h42
-rw-r--r--usr.sbin/makefs/cd9660/Makefile.inc5
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_archimedes.c126
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_archimedes.h52
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_conversion.c4
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_debug.c4
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_eltorito.c43
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_eltorito.h8
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_strings.c8
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_write.c10
-rw-r--r--usr.sbin/makefs/cd9660/iso9660_rrip.c38
-rw-r--r--usr.sbin/makefs/cd9660/iso9660_rrip.h28
-rw-r--r--usr.sbin/makefs/ffs.c14
-rw-r--r--usr.sbin/makefs/ffs.h2
-rw-r--r--usr.sbin/makefs/ffs/Makefile.inc5
-rw-r--r--usr.sbin/makefs/ffs/buf.c45
-rw-r--r--usr.sbin/makefs/ffs/buf.h2
-rw-r--r--usr.sbin/makefs/ffs/ffs_alloc.c7
-rw-r--r--usr.sbin/makefs/ffs/ffs_balloc.c5
-rw-r--r--usr.sbin/makefs/ffs/ffs_bswap.c5
-rw-r--r--usr.sbin/makefs/ffs/ffs_extern.h3
-rw-r--r--usr.sbin/makefs/ffs/ffs_subr.c5
-rw-r--r--usr.sbin/makefs/ffs/mkfs.c36
-rw-r--r--usr.sbin/makefs/ffs/newfs_extern.h4
-rw-r--r--usr.sbin/makefs/ffs/ufs_bmap.c5
-rw-r--r--usr.sbin/makefs/ffs/ufs_bswap.h4
-rw-r--r--usr.sbin/makefs/ffs/ufs_inode.h5
-rw-r--r--usr.sbin/makefs/makefs.8113
-rw-r--r--usr.sbin/makefs/makefs.c11
-rw-r--r--usr.sbin/makefs/makefs.h9
-rw-r--r--usr.sbin/makefs/msdos.c5
-rw-r--r--usr.sbin/makefs/msdos.h1
-rw-r--r--usr.sbin/makefs/msdos/Makefile.inc3
-rw-r--r--usr.sbin/makefs/msdos/direntry.h1
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_conv.c3
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_denode.c3
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_fat.c7
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_lookup.c5
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_vfsops.c2
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_vnops.c3
-rw-r--r--usr.sbin/makefs/mtree.c18
-rw-r--r--usr.sbin/makefs/tests/Makefile13
-rw-r--r--usr.sbin/makefs/tests/Makefile.depend1
-rw-r--r--usr.sbin/makefs/tests/makefs_cd9660_tests.sh3
-rw-r--r--usr.sbin/makefs/tests/makefs_ffs_tests.sh3
-rw-r--r--usr.sbin/makefs/tests/makefs_tests_common.sh3
-rw-r--r--usr.sbin/makefs/tests/makefs_zfs_tests.sh868
-rw-r--r--usr.sbin/makefs/walk.c4
-rw-r--r--usr.sbin/makefs/zfs.c797
-rw-r--r--usr.sbin/makefs/zfs/Makefile.inc13
-rw-r--r--usr.sbin/makefs/zfs/dsl.c628
-rw-r--r--usr.sbin/makefs/zfs/fs.c1082
-rw-r--r--usr.sbin/makefs/zfs/objset.c262
-rw-r--r--usr.sbin/makefs/zfs/vdev.c436
-rw-r--r--usr.sbin/makefs/zfs/zap.c549
-rw-r--r--usr.sbin/makefs/zfs/zfs.h173
-rw-r--r--usr.sbin/makemap/Makefile4
-rw-r--r--usr.sbin/makemap/Makefile.depend2
-rw-r--r--usr.sbin/manctl/Makefile1
-rw-r--r--usr.sbin/manctl/Makefile.depend1
-rw-r--r--usr.sbin/manctl/manctl.82
-rw-r--r--usr.sbin/manctl/manctl.sh3
-rw-r--r--usr.sbin/memcontrol/Makefile1
-rw-r--r--usr.sbin/memcontrol/Makefile.depend2
-rw-r--r--usr.sbin/memcontrol/memcontrol.82
-rw-r--r--usr.sbin/memcontrol/memcontrol.c4
-rw-r--r--usr.sbin/mergemaster/Makefile1
-rw-r--r--usr.sbin/mergemaster/Makefile.depend1
-rw-r--r--usr.sbin/mergemaster/mergemaster.815
-rwxr-xr-xusr.sbin/mergemaster/mergemaster.sh8
-rw-r--r--usr.sbin/mfiutil/Makefile3
-rw-r--r--usr.sbin/mfiutil/Makefile.depend2
-rw-r--r--usr.sbin/mfiutil/mfi_bbu.c8
-rw-r--r--usr.sbin/mfiutil/mfi_cmd.c31
-rw-r--r--usr.sbin/mfiutil/mfi_config.c93
-rw-r--r--usr.sbin/mfiutil/mfi_drive.c16
-rw-r--r--usr.sbin/mfiutil/mfi_evt.c12
-rw-r--r--usr.sbin/mfiutil/mfi_flash.c6
-rw-r--r--usr.sbin/mfiutil/mfi_foreign.c62
-rw-r--r--usr.sbin/mfiutil/mfi_patrol.c10
-rw-r--r--usr.sbin/mfiutil/mfi_properties.c18
-rw-r--r--usr.sbin/mfiutil/mfi_show.c39
-rw-r--r--usr.sbin/mfiutil/mfi_volume.c12
-rw-r--r--usr.sbin/mfiutil/mfiutil.8127
-rw-r--r--usr.sbin/mfiutil/mfiutil.c45
-rw-r--r--usr.sbin/mfiutil/mfiutil.h13
-rw-r--r--usr.sbin/mixer/Makefile1
-rw-r--r--usr.sbin/mixer/Makefile.depend3
-rw-r--r--usr.sbin/mixer/mixer.882
-rw-r--r--usr.sbin/mixer/mixer.c130
-rw-r--r--usr.sbin/mld6query/Makefile1
-rw-r--r--usr.sbin/mld6query/Makefile.depend2
-rw-r--r--usr.sbin/mld6query/mld6.c11
-rw-r--r--usr.sbin/mld6query/mld6query.82
-rw-r--r--usr.sbin/mlx5tool/Makefile1
-rw-r--r--usr.sbin/mlx5tool/Makefile.depend (renamed from usr.sbin/trpt/Makefile.depend)3
-rw-r--r--usr.sbin/mlx5tool/mlx5tool.82
-rw-r--r--usr.sbin/mlx5tool/mlx5tool.c3
-rw-r--r--usr.sbin/mlxcontrol/Makefile1
-rw-r--r--usr.sbin/mlxcontrol/Makefile.depend2
-rw-r--r--usr.sbin/mlxcontrol/command.c4
-rw-r--r--usr.sbin/mlxcontrol/config.c4
-rw-r--r--usr.sbin/mlxcontrol/interface.c4
-rw-r--r--usr.sbin/mlxcontrol/mlxcontrol.82
-rw-r--r--usr.sbin/mlxcontrol/mlxcontrol.h4
-rw-r--r--usr.sbin/mlxcontrol/util.c4
-rw-r--r--usr.sbin/mount_smbfs/Makefile2
-rw-r--r--usr.sbin/mount_smbfs/Makefile.depend3
-rw-r--r--usr.sbin/mountd/Makefile2
-rw-r--r--usr.sbin/mountd/Makefile.depend2
-rw-r--r--usr.sbin/mountd/exports.568
-rw-r--r--usr.sbin/mountd/mountd.844
-rw-r--r--usr.sbin/mountd/mountd.c177
-rw-r--r--usr.sbin/mountd/netgroup.53
-rw-r--r--usr.sbin/mountd/pathnames.h3
-rw-r--r--usr.sbin/moused/Makefile2
-rw-r--r--usr.sbin/moused/Makefile.depend2
-rw-r--r--usr.sbin/moused/moused.82
-rw-r--r--usr.sbin/moused/moused.c7
-rw-r--r--usr.sbin/mpsutil/Makefile5
-rw-r--r--usr.sbin/mpsutil/Makefile.depend2
-rw-r--r--usr.sbin/mpsutil/mps_cmd.c43
-rw-r--r--usr.sbin/mpsutil/mps_debug.c4
-rw-r--r--usr.sbin/mpsutil/mps_flash.c2
-rw-r--r--usr.sbin/mpsutil/mps_set.c4
-rw-r--r--usr.sbin/mpsutil/mps_show.c6
-rw-r--r--usr.sbin/mpsutil/mps_slot.c2
-rw-r--r--usr.sbin/mpsutil/mpsutil.811
-rw-r--r--usr.sbin/mpsutil/mpsutil.c3
-rw-r--r--usr.sbin/mpsutil/mpsutil.h2
-rw-r--r--usr.sbin/mptable/Makefile1
-rw-r--r--usr.sbin/mptable/Makefile.depend2
-rw-r--r--usr.sbin/mptable/mptable.12
-rw-r--r--usr.sbin/mptable/mptable.c20
-rw-r--r--usr.sbin/mptutil/Makefile1
-rw-r--r--usr.sbin/mptutil/Makefile.depend3
-rw-r--r--usr.sbin/mptutil/mpt_cam.c3
-rw-r--r--usr.sbin/mptutil/mpt_cmd.c3
-rw-r--r--usr.sbin/mptutil/mpt_config.c3
-rw-r--r--usr.sbin/mptutil/mpt_drive.c3
-rw-r--r--usr.sbin/mptutil/mpt_evt.c3
-rw-r--r--usr.sbin/mptutil/mpt_show.c3
-rw-r--r--usr.sbin/mptutil/mpt_volume.c10
-rw-r--r--usr.sbin/mptutil/mptutil.88
-rw-r--r--usr.sbin/mptutil/mptutil.c3
-rw-r--r--usr.sbin/mptutil/mptutil.h2
-rw-r--r--usr.sbin/mtest/Makefile1
-rw-r--r--usr.sbin/mtest/Makefile.depend2
-rw-r--r--usr.sbin/mtest/mtest.82
-rw-r--r--usr.sbin/mtest/mtest.c5
-rw-r--r--usr.sbin/ndp/Makefile16
-rw-r--r--usr.sbin/ndp/Makefile.depend3
-rw-r--r--usr.sbin/ndp/ndp.82
-rw-r--r--usr.sbin/ndp/ndp.c623
-rw-r--r--usr.sbin/ndp/ndp.h27
-rw-r--r--usr.sbin/ndp/ndp_netlink.c516
-rw-r--r--usr.sbin/newsyslog/Makefile1
-rw-r--r--usr.sbin/newsyslog/Makefile.depend3
-rw-r--r--usr.sbin/newsyslog/extern.h3
-rw-r--r--usr.sbin/newsyslog/newsyslog.825
-rw-r--r--usr.sbin/newsyslog/newsyslog.c183
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf9
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.554
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.d/Makefile1
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.d/Makefile.depend1
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.d/amd.conf1
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.d/ftp.conf1
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.d/lpr.conf1
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.d/opensm.conf1
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.d/pf.conf1
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.d/ppp.conf1
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.d/sendmail.conf1
-rw-r--r--usr.sbin/newsyslog/pathnames.h2
-rw-r--r--usr.sbin/newsyslog/ptimes.c2
-rw-r--r--usr.sbin/newsyslog/tests/Makefile1
-rw-r--r--usr.sbin/newsyslog/tests/Makefile.depend1
-rw-r--r--usr.sbin/newsyslog/tests/legacy_test.sh2
-rw-r--r--usr.sbin/nfscbd/Makefile1
-rw-r--r--usr.sbin/nfscbd/Makefile.depend2
-rw-r--r--usr.sbin/nfscbd/nfscbd.82
-rw-r--r--usr.sbin/nfscbd/nfscbd.c3
-rw-r--r--usr.sbin/nfsd/Makefile2
-rw-r--r--usr.sbin/nfsd/Makefile.depend2
-rw-r--r--usr.sbin/nfsd/nfsd.844
-rw-r--r--usr.sbin/nfsd/nfsd.c34
-rw-r--r--usr.sbin/nfsd/nfsv4.431
-rw-r--r--usr.sbin/nfsd/pnfs.46
-rw-r--r--usr.sbin/nfsd/pnfsserver.42
-rw-r--r--usr.sbin/nfsd/stablerestart.52
-rw-r--r--usr.sbin/nfsdumpstate/Makefile1
-rw-r--r--usr.sbin/nfsdumpstate/Makefile.depend2
-rw-r--r--usr.sbin/nfsdumpstate/nfsdumpstate.82
-rw-r--r--usr.sbin/nfsdumpstate/nfsdumpstate.c5
-rw-r--r--usr.sbin/nfsrevoke/Makefile1
-rw-r--r--usr.sbin/nfsrevoke/Makefile.depend2
-rw-r--r--usr.sbin/nfsrevoke/nfsrevoke.82
-rw-r--r--usr.sbin/nfsrevoke/nfsrevoke.c5
-rw-r--r--usr.sbin/nfsuserd/Makefile1
-rw-r--r--usr.sbin/nfsuserd/Makefile.depend3
-rw-r--r--usr.sbin/nfsuserd/nfsuserd.818
-rw-r--r--usr.sbin/nfsuserd/nfsuserd.c52
-rw-r--r--usr.sbin/ngctl/Makefile1
-rw-r--r--usr.sbin/ngctl/Makefile.depend2
-rw-r--r--usr.sbin/ngctl/Makefile.depend.options1
-rw-r--r--usr.sbin/ngctl/config.c2
-rw-r--r--usr.sbin/ngctl/connect.c2
-rw-r--r--usr.sbin/ngctl/debug.c2
-rw-r--r--usr.sbin/ngctl/dot.c2
-rw-r--r--usr.sbin/ngctl/list.c2
-rw-r--r--usr.sbin/ngctl/main.c3
-rw-r--r--usr.sbin/ngctl/mkpeer.c2
-rw-r--r--usr.sbin/ngctl/msg.c2
-rw-r--r--usr.sbin/ngctl/name.c2
-rw-r--r--usr.sbin/ngctl/ngctl.82
-rw-r--r--usr.sbin/ngctl/ngctl.h2
-rw-r--r--usr.sbin/ngctl/rmhook.c2
-rw-r--r--usr.sbin/ngctl/show.c2
-rw-r--r--usr.sbin/ngctl/shutdown.c2
-rw-r--r--usr.sbin/ngctl/status.c2
-rw-r--r--usr.sbin/ngctl/types.c2
-rw-r--r--usr.sbin/ngctl/write.c2
-rw-r--r--usr.sbin/nghook/Makefile1
-rw-r--r--usr.sbin/nghook/Makefile.depend2
-rw-r--r--usr.sbin/nghook/main.c2
-rw-r--r--usr.sbin/nghook/nghook.82
-rw-r--r--usr.sbin/nmtree/Makefile1
-rw-r--r--usr.sbin/nmtree/Makefile.depend2
-rw-r--r--usr.sbin/nmtree/Makefile.depend.host12
-rw-r--r--usr.sbin/nmtree/mtree.53
-rw-r--r--usr.sbin/nmtree/tests/Makefile1
-rw-r--r--usr.sbin/nmtree/tests/Makefile.depend1
-rw-r--r--usr.sbin/nologin/Makefile2
-rw-r--r--usr.sbin/nologin/Makefile.depend2
-rw-r--r--usr.sbin/nologin/nologin.53
-rw-r--r--usr.sbin/nologin/nologin.83
-rw-r--r--usr.sbin/nologin/nologin.c2
-rw-r--r--usr.sbin/nscd/Makefile1
-rw-r--r--usr.sbin/nscd/Makefile.depend2
-rw-r--r--usr.sbin/nscd/agent.c2
-rw-r--r--usr.sbin/nscd/agent.h2
-rw-r--r--usr.sbin/nscd/agents/Makefile.inc1
-rw-r--r--usr.sbin/nscd/agents/group.c3
-rw-r--r--usr.sbin/nscd/agents/group.h2
-rw-r--r--usr.sbin/nscd/agents/passwd.c3
-rw-r--r--usr.sbin/nscd/agents/passwd.h2
-rw-r--r--usr.sbin/nscd/agents/services.c3
-rw-r--r--usr.sbin/nscd/agents/services.h2
-rw-r--r--usr.sbin/nscd/cachelib.c2
-rw-r--r--usr.sbin/nscd/cachelib.h2
-rw-r--r--usr.sbin/nscd/cacheplcs.c6
-rw-r--r--usr.sbin/nscd/cacheplcs.h2
-rw-r--r--usr.sbin/nscd/config.c2
-rw-r--r--usr.sbin/nscd/config.h4
-rw-r--r--usr.sbin/nscd/debug.c2
-rw-r--r--usr.sbin/nscd/debug.h2
-rw-r--r--usr.sbin/nscd/hashtable.h2
-rw-r--r--usr.sbin/nscd/log.c2
-rw-r--r--usr.sbin/nscd/log.h2
-rw-r--r--usr.sbin/nscd/mp_rs_query.c3
-rw-r--r--usr.sbin/nscd/mp_rs_query.h2
-rw-r--r--usr.sbin/nscd/mp_ws_query.c3
-rw-r--r--usr.sbin/nscd/mp_ws_query.h2
-rw-r--r--usr.sbin/nscd/nscd.82
-rw-r--r--usr.sbin/nscd/nscd.c10
-rw-r--r--usr.sbin/nscd/nscd.conf1
-rw-r--r--usr.sbin/nscd/nscd.conf.52
-rw-r--r--usr.sbin/nscd/nscdcli.c6
-rw-r--r--usr.sbin/nscd/nscdcli.h2
-rw-r--r--usr.sbin/nscd/parser.c4
-rw-r--r--usr.sbin/nscd/parser.h2
-rw-r--r--usr.sbin/nscd/protocol.c2
-rw-r--r--usr.sbin/nscd/protocol.h2
-rw-r--r--usr.sbin/nscd/query.c5
-rw-r--r--usr.sbin/nscd/query.h2
-rw-r--r--usr.sbin/nscd/singletons.c2
-rw-r--r--usr.sbin/nscd/singletons.h2
-rw-r--r--usr.sbin/ntp/Makefile1
-rw-r--r--usr.sbin/ntp/Makefile.inc1
-rw-r--r--usr.sbin/ntp/config.h11
-rw-r--r--usr.sbin/ntp/doc/Makefile1
-rw-r--r--usr.sbin/ntp/doc/Makefile.depend1
-rw-r--r--usr.sbin/ntp/doc/drivers/Makefile1
-rw-r--r--usr.sbin/ntp/doc/drivers/Makefile.depend1
-rw-r--r--usr.sbin/ntp/doc/drivers/icons/Makefile1
-rw-r--r--usr.sbin/ntp/doc/drivers/icons/Makefile.depend1
-rw-r--r--usr.sbin/ntp/doc/drivers/scripts/Makefile1
-rw-r--r--usr.sbin/ntp/doc/drivers/scripts/Makefile.depend1
-rw-r--r--usr.sbin/ntp/doc/hints/Makefile1
-rw-r--r--usr.sbin/ntp/doc/hints/Makefile.depend1
-rw-r--r--usr.sbin/ntp/doc/icons/Makefile1
-rw-r--r--usr.sbin/ntp/doc/icons/Makefile.depend1
-rw-r--r--usr.sbin/ntp/doc/ntp-keygen.82
-rw-r--r--usr.sbin/ntp/doc/ntp.conf.52
-rw-r--r--usr.sbin/ntp/doc/ntp.keys.52
-rw-r--r--usr.sbin/ntp/doc/ntpd.82
-rw-r--r--usr.sbin/ntp/doc/ntpdate.82
-rw-r--r--usr.sbin/ntp/doc/ntpdc.82
-rw-r--r--usr.sbin/ntp/doc/ntpq.82
-rw-r--r--usr.sbin/ntp/doc/ntptime.82
-rw-r--r--usr.sbin/ntp/doc/ntptrace.82
-rw-r--r--usr.sbin/ntp/doc/pic/Makefile1
-rw-r--r--usr.sbin/ntp/doc/pic/Makefile.depend1
-rw-r--r--usr.sbin/ntp/doc/scripts/Makefile1
-rw-r--r--usr.sbin/ntp/doc/scripts/Makefile.depend1
-rw-r--r--usr.sbin/ntp/doc/sntp.82
-rw-r--r--usr.sbin/ntp/libntp/Makefile18
-rw-r--r--usr.sbin/ntp/libntp/Makefile.depend2
-rw-r--r--usr.sbin/ntp/libntpevent/Makefile1
-rw-r--r--usr.sbin/ntp/libntpevent/Makefile.depend1
-rw-r--r--usr.sbin/ntp/libntpevent/event2/event-config.h1
-rw-r--r--usr.sbin/ntp/libopts/Makefile1
-rw-r--r--usr.sbin/ntp/libopts/Makefile.depend1
-rw-r--r--usr.sbin/ntp/libparse/Makefile5
-rw-r--r--usr.sbin/ntp/libparse/Makefile.depend1
-rw-r--r--usr.sbin/ntp/ntp-keygen/Makefile9
-rw-r--r--usr.sbin/ntp/ntp-keygen/Makefile.depend1
-rw-r--r--usr.sbin/ntp/ntp-keygen/Makefile.depend.options1
-rw-r--r--usr.sbin/ntp/ntpd/Makefile12
-rw-r--r--usr.sbin/ntp/ntpd/Makefile.depend2
-rw-r--r--usr.sbin/ntp/ntpd/Makefile.depend.options1
-rw-r--r--usr.sbin/ntp/ntpd/leap-seconds8
-rw-r--r--usr.sbin/ntp/ntpd/ntp.conf18
-rw-r--r--usr.sbin/ntp/ntpdate/Makefile7
-rw-r--r--usr.sbin/ntp/ntpdate/Makefile.depend2
-rw-r--r--usr.sbin/ntp/ntpdate/Makefile.depend.options1
-rw-r--r--usr.sbin/ntp/ntpdc/Makefile7
-rw-r--r--usr.sbin/ntp/ntpdc/Makefile.depend3
-rw-r--r--usr.sbin/ntp/ntpdc/Makefile.depend.options1
-rw-r--r--usr.sbin/ntp/ntpdc/nl.c1
-rw-r--r--usr.sbin/ntp/ntpq/Makefile9
-rw-r--r--usr.sbin/ntp/ntpq/Makefile.depend3
-rw-r--r--usr.sbin/ntp/ntpq/Makefile.depend.options1
-rw-r--r--usr.sbin/ntp/ntptime/Makefile7
-rw-r--r--usr.sbin/ntp/ntptime/Makefile.depend2
-rwxr-xr-xusr.sbin/ntp/scripts/mkver3
-rw-r--r--usr.sbin/ntp/scripts/ntptrace1
-rwxr-xr-xusr.sbin/ntp/scripts/ntpver1
-rw-r--r--usr.sbin/ntp/sntp/Makefile7
-rw-r--r--usr.sbin/ntp/sntp/Makefile.depend1
-rw-r--r--usr.sbin/ntp/sntp/Makefile.depend.options1
-rw-r--r--usr.sbin/nvram/Makefile1
-rw-r--r--usr.sbin/nvram/nvram.82
-rw-r--r--usr.sbin/nvram/nvram.c4
-rw-r--r--usr.sbin/ofwdump/Makefile1
-rw-r--r--usr.sbin/ofwdump/Makefile.depend1
-rw-r--r--usr.sbin/ofwdump/ofw_util.c3
-rw-r--r--usr.sbin/ofwdump/ofw_util.h2
-rw-r--r--usr.sbin/ofwdump/ofwdump.86
-rw-r--r--usr.sbin/ofwdump/ofwdump.c39
-rw-r--r--usr.sbin/ofwdump/pathnames.h2
-rw-r--r--usr.sbin/pciconf/Makefile1
-rw-r--r--usr.sbin/pciconf/Makefile.depend2
-rw-r--r--usr.sbin/pciconf/cap.c185
-rw-r--r--usr.sbin/pciconf/err.c7
-rw-r--r--usr.sbin/pciconf/pathnames.h1
-rw-r--r--usr.sbin/pciconf/pciconf.82
-rw-r--r--usr.sbin/pciconf/pciconf.c5
-rw-r--r--usr.sbin/pciconf/pciconf.h2
-rw-r--r--usr.sbin/periodic/Makefile1
-rw-r--r--usr.sbin/periodic/Makefile.depend1
-rw-r--r--usr.sbin/periodic/etc/Makefile1
-rw-r--r--usr.sbin/periodic/etc/Makefile.inc1
-rwxr-xr-xusr.sbin/periodic/etc/daily/100.clean-disks1
-rwxr-xr-xusr.sbin/periodic/etc/daily/110.clean-tmps1
-rwxr-xr-xusr.sbin/periodic/etc/daily/120.clean-preserve1
-rwxr-xr-xusr.sbin/periodic/etc/daily/130.clean-msgs1
-rwxr-xr-xusr.sbin/periodic/etc/daily/140.clean-rwho1
-rwxr-xr-xusr.sbin/periodic/etc/daily/150.clean-hoststat7
-rwxr-xr-xusr.sbin/periodic/etc/daily/200.backup-passwd5
-rwxr-xr-xusr.sbin/periodic/etc/daily/210.backup-aliases3
-rwxr-xr-xusr.sbin/periodic/etc/daily/221.backup-gpart4
-rwxr-xr-xusr.sbin/periodic/etc/daily/222.backup-gmirror4
-rwxr-xr-xusr.sbin/periodic/etc/daily/223.backup-zfs28
-rwxr-xr-xusr.sbin/periodic/etc/daily/300.calendar1
-rwxr-xr-xusr.sbin/periodic/etc/daily/310.accounting6
-rwxr-xr-xusr.sbin/periodic/etc/daily/400.status-disks1
-rwxr-xr-xusr.sbin/periodic/etc/daily/401.status-graid1
-rwxr-xr-xusr.sbin/periodic/etc/daily/404.status-zfs1
-rwxr-xr-xusr.sbin/periodic/etc/daily/406.status-gmirror1
-rwxr-xr-xusr.sbin/periodic/etc/daily/407.status-graid31
-rwxr-xr-xusr.sbin/periodic/etc/daily/408.status-gstripe1
-rwxr-xr-xusr.sbin/periodic/etc/daily/409.status-gconcat1
-rw-r--r--usr.sbin/periodic/etc/daily/410.status-mfi1
-rwxr-xr-xusr.sbin/periodic/etc/daily/420.status-network1
-rwxr-xr-xusr.sbin/periodic/etc/daily/430.status-uptime1
-rwxr-xr-xusr.sbin/periodic/etc/daily/440.status-mailq3
-rwxr-xr-xusr.sbin/periodic/etc/daily/450.status-security1
-rwxr-xr-xusr.sbin/periodic/etc/daily/460.status-mail-rejects1
-rwxr-xr-xusr.sbin/periodic/etc/daily/480.leapfile-ntpd5
-rwxr-xr-xusr.sbin/periodic/etc/daily/480.status-ntpd1
-rwxr-xr-xusr.sbin/periodic/etc/daily/500.queuerun1
-rwxr-xr-xusr.sbin/periodic/etc/daily/510.status-world-kernel1
-rwxr-xr-xusr.sbin/periodic/etc/daily/800.scrub-zfs1
-rwxr-xr-xusr.sbin/periodic/etc/daily/801.trim-zfs59
-rwxr-xr-xusr.sbin/periodic/etc/daily/999.local1
-rw-r--r--usr.sbin/periodic/etc/daily/Makefile4
-rwxr-xr-xusr.sbin/periodic/etc/monthly/200.accounting1
-rwxr-xr-xusr.sbin/periodic/etc/monthly/450.status-security1
-rwxr-xr-xusr.sbin/periodic/etc/monthly/999.local1
-rw-r--r--usr.sbin/periodic/etc/monthly/Makefile1
-rwxr-xr-xusr.sbin/periodic/etc/security/100.chksetuid3
-rwxr-xr-xusr.sbin/periodic/etc/security/110.neggrpperm3
-rwxr-xr-xusr.sbin/periodic/etc/security/200.chkmounts1
-rwxr-xr-xusr.sbin/periodic/etc/security/300.chkuid01
-rwxr-xr-xusr.sbin/periodic/etc/security/400.passwdless1
-rwxr-xr-xusr.sbin/periodic/etc/security/410.logincheck1
-rwxr-xr-xusr.sbin/periodic/etc/security/500.ipfwdenied1
-rwxr-xr-xusr.sbin/periodic/etc/security/510.ipfdenied1
-rwxr-xr-xusr.sbin/periodic/etc/security/520.pfdenied1
-rwxr-xr-xusr.sbin/periodic/etc/security/550.ipfwlimit1
-rwxr-xr-xusr.sbin/periodic/etc/security/610.ipf6denied1
-rwxr-xr-xusr.sbin/periodic/etc/security/700.kernelmsg1
-rwxr-xr-xusr.sbin/periodic/etc/security/800.loginfail8
-rwxr-xr-xusr.sbin/periodic/etc/security/900.tcpwrap8
-rw-r--r--usr.sbin/periodic/etc/security/Makefile3
-rw-r--r--usr.sbin/periodic/etc/security/security.functions1
-rwxr-xr-xusr.sbin/periodic/etc/weekly/310.locate30
-rwxr-xr-xusr.sbin/periodic/etc/weekly/320.whatis1
-rwxr-xr-xusr.sbin/periodic/etc/weekly/340.noid1
-rwxr-xr-xusr.sbin/periodic/etc/weekly/450.status-security1
-rwxr-xr-xusr.sbin/periodic/etc/weekly/999.local1
-rw-r--r--usr.sbin/periodic/etc/weekly/Makefile1
-rw-r--r--usr.sbin/periodic/periodic.811
-rw-r--r--usr.sbin/periodic/periodic.conf15
-rw-r--r--usr.sbin/periodic/periodic.sh11
-rw-r--r--usr.sbin/pkg/FreeBSD.conf.latest3
-rw-r--r--usr.sbin/pkg/FreeBSD.conf.quarterly3
-rw-r--r--usr.sbin/pkg/Makefile7
-rw-r--r--usr.sbin/pkg/Makefile.depend11
-rw-r--r--usr.sbin/pkg/config.c26
-rw-r--r--usr.sbin/pkg/config.h4
-rw-r--r--usr.sbin/pkg/dns_utils.c4
-rw-r--r--usr.sbin/pkg/dns_utils.h4
-rw-r--r--usr.sbin/pkg/hash.c47
-rw-r--r--usr.sbin/pkg/hash.h (renamed from usr.sbin/kldxref/ef_nop.c)22
-rw-r--r--usr.sbin/pkg/pkg.748
-rw-r--r--usr.sbin/pkg/pkg.c113
-rw-r--r--usr.sbin/pmc/Makefile10
-rw-r--r--usr.sbin/pmc/cmd_pmc.h4
-rw-r--r--usr.sbin/pmc/cmd_pmc_filter.cc8
-rw-r--r--usr.sbin/pmc/cmd_pmc_list.c5
-rw-r--r--usr.sbin/pmc/cmd_pmc_stat.c5
-rw-r--r--usr.sbin/pmc/cmd_pmc_summary.cc5
-rw-r--r--usr.sbin/pmc/pmc.c4
-rw-r--r--usr.sbin/pmc/pmc_util.c5
-rw-r--r--usr.sbin/pmcannotate/Makefile1
-rw-r--r--usr.sbin/pmcannotate/Makefile.depend2
-rw-r--r--usr.sbin/pmcannotate/pmcannotate.82
-rw-r--r--usr.sbin/pmcannotate/pmcannotate.c10
-rw-r--r--usr.sbin/pmccontrol/Makefile1
-rw-r--r--usr.sbin/pmccontrol/Makefile.depend5
-rw-r--r--usr.sbin/pmccontrol/pmccontrol.82
-rw-r--r--usr.sbin/pmccontrol/pmccontrol.c12
-rw-r--r--usr.sbin/pmcstat/Makefile1
-rw-r--r--usr.sbin/pmcstat/Makefile.depend7
-rw-r--r--usr.sbin/pmcstat/pmcpl_annotate.c5
-rw-r--r--usr.sbin/pmcstat/pmcpl_annotate.h4
-rw-r--r--usr.sbin/pmcstat/pmcpl_annotate_cg.c5
-rw-r--r--usr.sbin/pmcstat/pmcpl_annotate_cg.h4
-rw-r--r--usr.sbin/pmcstat/pmcpl_callgraph.c7
-rw-r--r--usr.sbin/pmcstat/pmcpl_callgraph.h4
-rw-r--r--usr.sbin/pmcstat/pmcpl_calltree.c5
-rw-r--r--usr.sbin/pmcstat/pmcpl_calltree.h4
-rw-r--r--usr.sbin/pmcstat/pmcpl_gprof.c5
-rw-r--r--usr.sbin/pmcstat/pmcpl_gprof.h4
-rw-r--r--usr.sbin/pmcstat/pmcstat.826
-rw-r--r--usr.sbin/pmcstat/pmcstat.c159
-rw-r--r--usr.sbin/pmcstat/pmcstat.h4
-rw-r--r--usr.sbin/pmcstat/pmcstat_log.c12
-rw-r--r--usr.sbin/pmcstat/pmcstat_log.h4
-rw-r--r--usr.sbin/pmcstat/pmcstat_top.h4
-rw-r--r--usr.sbin/pmcstudy/Makefile2
-rw-r--r--usr.sbin/pmcstudy/Makefile.depend2
-rw-r--r--usr.sbin/pmcstudy/eval_expr.c2
-rw-r--r--usr.sbin/pmcstudy/eval_expr.h2
-rw-r--r--usr.sbin/pmcstudy/pmcstudy.82
-rw-r--r--usr.sbin/pmcstudy/pmcstudy.c2
-rw-r--r--usr.sbin/pnfsdscopymr/Makefile1
-rw-r--r--usr.sbin/pnfsdscopymr/pnfsdscopymr.84
-rw-r--r--usr.sbin/pnfsdscopymr/pnfsdscopymr.c10
-rw-r--r--usr.sbin/pnfsdsfile/Makefile1
-rw-r--r--usr.sbin/pnfsdsfile/pnfsdsfile.82
-rw-r--r--usr.sbin/pnfsdsfile/pnfsdsfile.c6
-rw-r--r--usr.sbin/pnfsdskill/Makefile1
-rw-r--r--usr.sbin/pnfsdskill/pnfsdskill.82
-rw-r--r--usr.sbin/pnfsdskill/pnfsdskill.c6
-rw-r--r--usr.sbin/pnpinfo/Makefile1
-rw-r--r--usr.sbin/pnpinfo/Makefile.depend1
-rw-r--r--usr.sbin/portsnap/Makefile5
-rw-r--r--usr.sbin/portsnap/Makefile.inc5
-rw-r--r--usr.sbin/portsnap/make_index/Makefile8
-rw-r--r--usr.sbin/portsnap/make_index/make_index.c515
-rw-r--r--usr.sbin/portsnap/portsnap/Makefile7
-rw-r--r--usr.sbin/portsnap/portsnap/portsnap.8288
-rw-r--r--usr.sbin/portsnap/portsnap/portsnap.conf36
-rw-r--r--usr.sbin/portsnap/portsnap/portsnap.sh1156
-rw-r--r--usr.sbin/powerd/Makefile1
-rw-r--r--usr.sbin/powerd/Makefile.depend2
-rw-r--r--usr.sbin/powerd/powerd.86
-rw-r--r--usr.sbin/powerd/powerd.c5
-rw-r--r--usr.sbin/ppp/Makefile2
-rw-r--r--usr.sbin/ppp/Makefile.depend2
-rw-r--r--usr.sbin/ppp/README.changes2
-rw-r--r--usr.sbin/ppp/README.nat2
-rw-r--r--usr.sbin/ppp/acf.c4
-rw-r--r--usr.sbin/ppp/acf.h4
-rw-r--r--usr.sbin/ppp/arp.c4
-rw-r--r--usr.sbin/ppp/arp.h4
-rw-r--r--usr.sbin/ppp/async.c5
-rw-r--r--usr.sbin/ppp/async.h4
-rw-r--r--usr.sbin/ppp/auth.c4
-rw-r--r--usr.sbin/ppp/auth.h4
-rw-r--r--usr.sbin/ppp/bundle.c6
-rw-r--r--usr.sbin/ppp/bundle.h4
-rw-r--r--usr.sbin/ppp/cbcp.c4
-rw-r--r--usr.sbin/ppp/cbcp.h4
-rw-r--r--usr.sbin/ppp/ccp.c4
-rw-r--r--usr.sbin/ppp/ccp.h4
-rw-r--r--usr.sbin/ppp/chap.c4
-rw-r--r--usr.sbin/ppp/chap.h4
-rw-r--r--usr.sbin/ppp/chap_ms.c4
-rw-r--r--usr.sbin/ppp/chap_ms.h4
-rw-r--r--usr.sbin/ppp/chat.c4
-rw-r--r--usr.sbin/ppp/chat.h4
-rw-r--r--usr.sbin/ppp/command.c4
-rw-r--r--usr.sbin/ppp/command.h4
-rw-r--r--usr.sbin/ppp/datalink.c4
-rw-r--r--usr.sbin/ppp/datalink.h4
-rw-r--r--usr.sbin/ppp/deflate.c4
-rw-r--r--usr.sbin/ppp/deflate.h4
-rw-r--r--usr.sbin/ppp/defs.c6
-rw-r--r--usr.sbin/ppp/defs.h4
-rw-r--r--usr.sbin/ppp/descriptor.h4
-rw-r--r--usr.sbin/ppp/ether.c4
-rw-r--r--usr.sbin/ppp/ether.h4
-rw-r--r--usr.sbin/ppp/exec.c4
-rw-r--r--usr.sbin/ppp/exec.h4
-rw-r--r--usr.sbin/ppp/filter.c4
-rw-r--r--usr.sbin/ppp/filter.h4
-rw-r--r--usr.sbin/ppp/fsm.c4
-rw-r--r--usr.sbin/ppp/fsm.h4
-rw-r--r--usr.sbin/ppp/hdlc.c4
-rw-r--r--usr.sbin/ppp/hdlc.h4
-rw-r--r--usr.sbin/ppp/i4b.h4
-rw-r--r--usr.sbin/ppp/id.c8
-rw-r--r--usr.sbin/ppp/id.h4
-rw-r--r--usr.sbin/ppp/iface.c4
-rw-r--r--usr.sbin/ppp/iface.h4
-rw-r--r--usr.sbin/ppp/ip.c4
-rw-r--r--usr.sbin/ppp/ip.h4
-rw-r--r--usr.sbin/ppp/ipcp.c4
-rw-r--r--usr.sbin/ppp/ipcp.h4
-rw-r--r--usr.sbin/ppp/iplist.c4
-rw-r--r--usr.sbin/ppp/iplist.h4
-rw-r--r--usr.sbin/ppp/ipv6cp.c4
-rw-r--r--usr.sbin/ppp/ipv6cp.h4
-rw-r--r--usr.sbin/ppp/layer.h4
-rw-r--r--usr.sbin/ppp/lcp.c4
-rw-r--r--usr.sbin/ppp/lcp.h4
-rw-r--r--usr.sbin/ppp/link.c4
-rw-r--r--usr.sbin/ppp/link.h4
-rw-r--r--usr.sbin/ppp/log.c12
-rw-r--r--usr.sbin/ppp/log.h4
-rw-r--r--usr.sbin/ppp/lqr.c4
-rw-r--r--usr.sbin/ppp/lqr.h4
-rw-r--r--usr.sbin/ppp/main.c6
-rw-r--r--usr.sbin/ppp/main.h4
-rw-r--r--usr.sbin/ppp/mbuf.c4
-rw-r--r--usr.sbin/ppp/mbuf.h4
-rw-r--r--usr.sbin/ppp/mp.c4
-rw-r--r--usr.sbin/ppp/mp.h4
-rw-r--r--usr.sbin/ppp/mppe.c4
-rw-r--r--usr.sbin/ppp/mppe.h4
-rw-r--r--usr.sbin/ppp/nat_cmd.c4
-rw-r--r--usr.sbin/ppp/nat_cmd.h4
-rw-r--r--usr.sbin/ppp/ncp.c4
-rw-r--r--usr.sbin/ppp/ncp.h8
-rw-r--r--usr.sbin/ppp/ncpaddr.c4
-rw-r--r--usr.sbin/ppp/ncpaddr.h4
-rw-r--r--usr.sbin/ppp/netgraph.c4
-rw-r--r--usr.sbin/ppp/netgraph.h4
-rw-r--r--usr.sbin/ppp/pap.c4
-rw-r--r--usr.sbin/ppp/pap.h4
-rw-r--r--usr.sbin/ppp/physical.c4
-rw-r--r--usr.sbin/ppp/physical.h2
-rw-r--r--usr.sbin/ppp/ppp.810
-rw-r--r--usr.sbin/ppp/ppp.conf1
-rw-r--r--usr.sbin/ppp/pred.c4
-rw-r--r--usr.sbin/ppp/pred.h4
-rw-r--r--usr.sbin/ppp/probe.c6
-rw-r--r--usr.sbin/ppp/probe.h4
-rw-r--r--usr.sbin/ppp/prompt.c4
-rw-r--r--usr.sbin/ppp/prompt.h4
-rw-r--r--usr.sbin/ppp/proto.c4
-rw-r--r--usr.sbin/ppp/proto.h4
-rw-r--r--usr.sbin/ppp/radius.c4
-rw-r--r--usr.sbin/ppp/radius.h4
-rw-r--r--usr.sbin/ppp/route.c4
-rw-r--r--usr.sbin/ppp/route.h4
-rw-r--r--usr.sbin/ppp/server.c4
-rw-r--r--usr.sbin/ppp/server.h4
-rw-r--r--usr.sbin/ppp/sig.c6
-rw-r--r--usr.sbin/ppp/sig.h4
-rw-r--r--usr.sbin/ppp/slcompress.c4
-rw-r--r--usr.sbin/ppp/slcompress.h2
-rw-r--r--usr.sbin/ppp/sync.c4
-rw-r--r--usr.sbin/ppp/sync.h4
-rw-r--r--usr.sbin/ppp/systems.c4
-rw-r--r--usr.sbin/ppp/systems.h4
-rw-r--r--usr.sbin/ppp/tcp.c4
-rw-r--r--usr.sbin/ppp/tcp.h4
-rw-r--r--usr.sbin/ppp/tcpmss.c80
-rw-r--r--usr.sbin/ppp/tcpmss.h4
-rw-r--r--usr.sbin/ppp/throughput.c4
-rw-r--r--usr.sbin/ppp/throughput.h4
-rw-r--r--usr.sbin/ppp/timer.c4
-rw-r--r--usr.sbin/ppp/timer.h4
-rw-r--r--usr.sbin/ppp/tty.c4
-rw-r--r--usr.sbin/ppp/tty.h4
-rw-r--r--usr.sbin/ppp/tun.c4
-rw-r--r--usr.sbin/ppp/tun.h4
-rw-r--r--usr.sbin/ppp/ua.h4
-rw-r--r--usr.sbin/ppp/udp.c4
-rw-r--r--usr.sbin/ppp/udp.h4
-rw-r--r--usr.sbin/ppp/vjcomp.c4
-rw-r--r--usr.sbin/ppp/vjcomp.h4
-rw-r--r--usr.sbin/pppctl/Makefile1
-rw-r--r--usr.sbin/pppctl/Makefile.depend3
-rw-r--r--usr.sbin/pppctl/pppctl.81
-rw-r--r--usr.sbin/pppctl/pppctl.c5
-rw-r--r--usr.sbin/praliases/Makefile4
-rw-r--r--usr.sbin/praliases/Makefile.depend2
-rw-r--r--usr.sbin/praudit/Makefile1
-rw-r--r--usr.sbin/praudit/Makefile.depend2
-rw-r--r--usr.sbin/praudit/tests/Makefile1
-rw-r--r--usr.sbin/praudit/tests/praudit_test.sh1
-rw-r--r--usr.sbin/prometheus_sysctl_exporter/Makefile1
-rw-r--r--usr.sbin/prometheus_sysctl_exporter/Makefile.depend2
-rw-r--r--usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.82
-rw-r--r--usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c36
-rw-r--r--usr.sbin/pstat/Makefile2
-rw-r--r--usr.sbin/pstat/Makefile.depend3
-rw-r--r--usr.sbin/pstat/pstat.825
-rw-r--r--usr.sbin/pstat/pstat.c14
-rw-r--r--usr.sbin/pw/Makefile2
-rw-r--r--usr.sbin/pw/Makefile.depend3
-rw-r--r--usr.sbin/pw/README4
-rw-r--r--usr.sbin/pw/bitmap.c7
-rw-r--r--usr.sbin/pw/bitmap.h4
-rw-r--r--usr.sbin/pw/cpdir.c7
-rw-r--r--usr.sbin/pw/grupd.c7
-rw-r--r--usr.sbin/pw/psdate.c9
-rw-r--r--usr.sbin/pw/psdate.h4
-rw-r--r--usr.sbin/pw/pw.815
-rw-r--r--usr.sbin/pw/pw.c7
-rw-r--r--usr.sbin/pw/pw.conf.52
-rw-r--r--usr.sbin/pw/pw.h6
-rw-r--r--usr.sbin/pw/pw_conf.c7
-rw-r--r--usr.sbin/pw/pw_group.c22
-rw-r--r--usr.sbin/pw/pw_log.c7
-rw-r--r--usr.sbin/pw/pw_nis.c7
-rw-r--r--usr.sbin/pw/pw_user.c127
-rw-r--r--usr.sbin/pw/pw_utils.c2
-rw-r--r--usr.sbin/pw/pw_vpw.c7
-rw-r--r--usr.sbin/pw/pwupd.c7
-rw-r--r--usr.sbin/pw/pwupd.h5
-rw-r--r--usr.sbin/pw/rm_r.c7
-rw-r--r--usr.sbin/pw/strtounum.c2
-rw-r--r--usr.sbin/pw/tests/Makefile1
-rw-r--r--usr.sbin/pw/tests/Makefile.depend1
-rw-r--r--usr.sbin/pw/tests/crypt.c2
-rw-r--r--usr.sbin/pw/tests/group1
-rwxr-xr-xusr.sbin/pw/tests/helper_functions.shin1
-rw-r--r--usr.sbin/pw/tests/master.passwd1
-rwxr-xr-xusr.sbin/pw/tests/pw_config_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_etcdir_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_groupadd_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_groupdel_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_groupmod_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_groupshow_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_lock_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_useradd_test.sh47
-rwxr-xr-xusr.sbin/pw/tests/pw_userdel_test.sh3
-rwxr-xr-xusr.sbin/pw/tests/pw_usermod_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_usernext_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_usershow_test.sh1
-rw-r--r--usr.sbin/pwd_mkdb/Makefile2
-rw-r--r--usr.sbin/pwd_mkdb/Makefile.depend2
-rw-r--r--usr.sbin/pwd_mkdb/bootstrap/pwd.h2
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.841
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.c41
-rw-r--r--usr.sbin/pwm/Makefile1
-rw-r--r--usr.sbin/pwm/pwm.82
-rw-r--r--usr.sbin/pwm/pwm.c4
-rw-r--r--usr.sbin/quot/Makefile1
-rw-r--r--usr.sbin/quot/Makefile.depend3
-rw-r--r--usr.sbin/quot/quot.86
-rw-r--r--usr.sbin/quot/quot.c70
-rw-r--r--usr.sbin/quotaon/Makefile2
-rw-r--r--usr.sbin/quotaon/Makefile.depend2
-rw-r--r--usr.sbin/quotaon/quotaon.83
-rw-r--r--usr.sbin/quotaon/quotaon.c16
-rw-r--r--usr.sbin/rarpd/Makefile2
-rw-r--r--usr.sbin/rarpd/Makefile.depend2
-rw-r--r--usr.sbin/rarpd/rarpd.82
-rw-r--r--usr.sbin/rarpd/rarpd.c12
-rw-r--r--usr.sbin/repquota/Makefile2
-rw-r--r--usr.sbin/repquota/Makefile.depend2
-rw-r--r--usr.sbin/repquota/repquota.83
-rw-r--r--usr.sbin/repquota/repquota.c16
-rw-r--r--usr.sbin/rip6query/Makefile2
-rw-r--r--usr.sbin/rip6query/Makefile.depend2
-rw-r--r--usr.sbin/rip6query/rip6query.81
-rw-r--r--usr.sbin/rip6query/rip6query.c9
-rw-r--r--usr.sbin/rmt/Makefile2
-rw-r--r--usr.sbin/rmt/Makefile.depend2
-rw-r--r--usr.sbin/rmt/rmt.83
-rw-r--r--usr.sbin/rmt/rmt.c14
-rw-r--r--usr.sbin/route6d/Makefile2
-rw-r--r--usr.sbin/route6d/Makefile.depend2
-rwxr-xr-xusr.sbin/route6d/misc/chkrt1
-rw-r--r--usr.sbin/route6d/misc/cksum.c2
-rw-r--r--usr.sbin/route6d/route6d.82
-rw-r--r--usr.sbin/route6d/route6d.c8
-rw-r--r--usr.sbin/route6d/route6d.h1
-rw-r--r--usr.sbin/rpc.lockd/Makefile1
-rw-r--r--usr.sbin/rpc.lockd/Makefile.depend2
-rw-r--r--usr.sbin/rpc.lockd/kern.c8
-rw-r--r--usr.sbin/rpc.lockd/lock_proc.c13
-rw-r--r--usr.sbin/rpc.lockd/lockd.c8
-rw-r--r--usr.sbin/rpc.lockd/lockd.h1
-rw-r--r--usr.sbin/rpc.lockd/lockd_lock.c56
-rw-r--r--usr.sbin/rpc.lockd/lockd_lock.h1
-rw-r--r--usr.sbin/rpc.lockd/rpc.lockd.82
-rw-r--r--usr.sbin/rpc.lockd/test.c9
-rw-r--r--usr.sbin/rpc.statd/Makefile1
-rw-r--r--usr.sbin/rpc.statd/Makefile.depend2
-rw-r--r--usr.sbin/rpc.statd/file.c2
-rw-r--r--usr.sbin/rpc.statd/procs.c2
-rw-r--r--usr.sbin/rpc.statd/rpc.statd.82
-rw-r--r--usr.sbin/rpc.statd/statd.c4
-rw-r--r--usr.sbin/rpc.statd/statd.h2
-rw-r--r--usr.sbin/rpc.statd/test.c5
-rw-r--r--usr.sbin/rpc.tlsclntd/Makefile1
-rw-r--r--usr.sbin/rpc.tlsclntd/rpc.tlsclntd.86
-rw-r--r--usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c28
-rw-r--r--usr.sbin/rpc.tlsservd/Makefile1
-rw-r--r--usr.sbin/rpc.tlsservd/rpc.tlscommon.c4
-rw-r--r--usr.sbin/rpc.tlsservd/rpc.tlscommon.h4
-rw-r--r--usr.sbin/rpc.tlsservd/rpc.tlsservd.819
-rw-r--r--usr.sbin/rpc.tlsservd/rpc.tlsservd.c134
-rw-r--r--usr.sbin/rpc.umntall/Makefile2
-rw-r--r--usr.sbin/rpc.umntall/Makefile.depend2
-rw-r--r--usr.sbin/rpc.umntall/mounttab.c4
-rw-r--r--usr.sbin/rpc.umntall/mounttab.h4
-rw-r--r--usr.sbin/rpc.umntall/rpc.umntall.82
-rw-r--r--usr.sbin/rpc.umntall/rpc.umntall.c10
-rw-r--r--usr.sbin/rpc.yppasswdd/Makefile1
-rw-r--r--usr.sbin/rpc.yppasswdd/Makefile.depend2
-rw-r--r--usr.sbin/rpc.yppasswdd/rpc.yppasswdd.82
-rw-r--r--usr.sbin/rpc.yppasswdd/yppasswd_private.x1
-rw-r--r--usr.sbin/rpc.yppasswdd/yppasswdd_extern.h2
-rw-r--r--usr.sbin/rpc.yppasswdd/yppasswdd_main.c3
-rw-r--r--usr.sbin/rpc.yppasswdd/yppasswdd_server.c5
-rw-r--r--usr.sbin/rpc.yppasswdd/yppwupdate1
-rw-r--r--usr.sbin/rpc.ypupdated/Makefile1
-rw-r--r--usr.sbin/rpc.ypupdated/Makefile.depend2
-rw-r--r--usr.sbin/rpc.ypupdated/update.c8
-rw-r--r--usr.sbin/rpc.ypupdated/yp_dbdelete.c2
-rw-r--r--usr.sbin/rpc.ypupdated/yp_dbupdate.c2
-rwxr-xr-xusr.sbin/rpc.ypupdated/ypupdate1
-rw-r--r--usr.sbin/rpc.ypupdated/ypupdated_extern.h1
-rw-r--r--usr.sbin/rpc.ypupdated/ypupdated_main.c2
-rw-r--r--usr.sbin/rpc.ypupdated/ypupdated_server.c2
-rw-r--r--usr.sbin/rpc.ypxfrd/Makefile1
-rw-r--r--usr.sbin/rpc.ypxfrd/Makefile.depend2
-rw-r--r--usr.sbin/rpc.ypxfrd/rpc.ypxfrd.82
-rw-r--r--usr.sbin/rpc.ypxfrd/ypxfrd_extern.h2
-rw-r--r--usr.sbin/rpc.ypxfrd/ypxfrd_main.c3
-rw-r--r--usr.sbin/rpc.ypxfrd/ypxfrd_server.c2
-rw-r--r--usr.sbin/rpcbind/Makefile1
-rw-r--r--usr.sbin/rpcbind/Makefile.depend1
-rw-r--r--usr.sbin/rpcbind/Makefile.depend.options1
-rw-r--r--usr.sbin/rpcbind/check_bound.c20
-rw-r--r--usr.sbin/rpcbind/pmap_svc.c9
-rw-r--r--usr.sbin/rpcbind/rpcb_stat.c7
-rw-r--r--usr.sbin/rpcbind/rpcb_svc.c3
-rw-r--r--usr.sbin/rpcbind/rpcb_svc_4.c4
-rw-r--r--usr.sbin/rpcbind/rpcb_svc_com.c6
-rw-r--r--usr.sbin/rpcbind/rpcbind.811
-rw-r--r--usr.sbin/rpcbind/rpcbind.c17
-rw-r--r--usr.sbin/rpcbind/rpcbind.h3
-rw-r--r--usr.sbin/rpcbind/security.c1
-rw-r--r--usr.sbin/rpcbind/tests/Makefile1
-rw-r--r--usr.sbin/rpcbind/tests/Makefile.depend1
-rw-r--r--usr.sbin/rpcbind/tests/addrmerge_test.c2
-rw-r--r--usr.sbin/rpcbind/util.c19
-rw-r--r--usr.sbin/rpcbind/warmstart.c2
-rw-r--r--usr.sbin/rrenumd/Makefile1
-rw-r--r--usr.sbin/rrenumd/Makefile.depend4
-rw-r--r--usr.sbin/rrenumd/lexer.l2
-rw-r--r--usr.sbin/rrenumd/parser.y2
-rw-r--r--usr.sbin/rrenumd/rrenumd.82
-rw-r--r--usr.sbin/rrenumd/rrenumd.c6
-rw-r--r--usr.sbin/rrenumd/rrenumd.conf.52
-rw-r--r--usr.sbin/rrenumd/rrenumd.h2
-rw-r--r--usr.sbin/rtadvctl/Makefile1
-rw-r--r--usr.sbin/rtadvctl/Makefile.depend2
-rw-r--r--usr.sbin/rtadvctl/rtadvctl.82
-rw-r--r--usr.sbin/rtadvctl/rtadvctl.c4
-rw-r--r--usr.sbin/rtadvd/Makefile1
-rw-r--r--usr.sbin/rtadvd/Makefile.depend2
-rw-r--r--usr.sbin/rtadvd/advcap.c1
-rw-r--r--usr.sbin/rtadvd/advcap.h3
-rw-r--r--usr.sbin/rtadvd/config.c2
-rw-r--r--usr.sbin/rtadvd/config.h1
-rw-r--r--usr.sbin/rtadvd/control.c4
-rw-r--r--usr.sbin/rtadvd/control.h4
-rw-r--r--usr.sbin/rtadvd/control_client.c4
-rw-r--r--usr.sbin/rtadvd/control_client.h4
-rw-r--r--usr.sbin/rtadvd/control_server.c4
-rw-r--r--usr.sbin/rtadvd/control_server.h4
-rw-r--r--usr.sbin/rtadvd/if.c3
-rw-r--r--usr.sbin/rtadvd/if.h1
-rw-r--r--usr.sbin/rtadvd/pathnames.h1
-rw-r--r--usr.sbin/rtadvd/rrenum.c4
-rw-r--r--usr.sbin/rtadvd/rrenum.h1
-rw-r--r--usr.sbin/rtadvd/rtadvd.82
-rw-r--r--usr.sbin/rtadvd/rtadvd.c11
-rw-r--r--usr.sbin/rtadvd/rtadvd.conf1
-rw-r--r--usr.sbin/rtadvd/rtadvd.conf.52
-rw-r--r--usr.sbin/rtadvd/rtadvd.h1
-rw-r--r--usr.sbin/rtadvd/timer.c5
-rw-r--r--usr.sbin/rtadvd/timer.h1
-rw-r--r--usr.sbin/rtadvd/timer_subr.c1
-rw-r--r--usr.sbin/rtadvd/timer_subr.h1
-rw-r--r--usr.sbin/rtprio/Makefile2
-rw-r--r--usr.sbin/rtprio/Makefile.depend2
-rw-r--r--usr.sbin/rtprio/rtprio.12
-rw-r--r--usr.sbin/rtprio/rtprio.c5
-rw-r--r--usr.sbin/rtsold/Makefile1
-rw-r--r--usr.sbin/rtsold/Makefile.depend1
-rw-r--r--usr.sbin/rtsold/Makefile.depend.options1
-rw-r--r--usr.sbin/rtsold/cap_llflags.c3
-rw-r--r--usr.sbin/rtsold/cap_script.c3
-rw-r--r--usr.sbin/rtsold/cap_sendmsg.c2
-rw-r--r--usr.sbin/rtsold/dump.c2
-rw-r--r--usr.sbin/rtsold/if.c2
-rw-r--r--usr.sbin/rtsold/rtsock.c1
-rw-r--r--usr.sbin/rtsold/rtsol.c14
-rw-r--r--usr.sbin/rtsold/rtsold.820
-rw-r--r--usr.sbin/rtsold/rtsold.c21
-rw-r--r--usr.sbin/rtsold/rtsold.h4
-rw-r--r--usr.sbin/rwhod/Makefile2
-rw-r--r--usr.sbin/rwhod/Makefile.depend4
-rw-r--r--usr.sbin/rwhod/rwhod.83
-rw-r--r--usr.sbin/rwhod/rwhod.c17
-rw-r--r--usr.sbin/sa/Makefile1
-rw-r--r--usr.sbin/sa/Makefile.depend2
-rw-r--r--usr.sbin/sa/db.c5
-rw-r--r--usr.sbin/sa/extern.h2
-rw-r--r--usr.sbin/sa/main.c10
-rw-r--r--usr.sbin/sa/pathnames.h2
-rw-r--r--usr.sbin/sa/pdb.c3
-rw-r--r--usr.sbin/sa/sa.82
-rw-r--r--usr.sbin/sa/tests/Makefile1
-rw-r--r--usr.sbin/sa/tests/Makefile.depend1
-rw-r--r--usr.sbin/sa/tests/legacy_test.sh1
-rwxr-xr-xusr.sbin/sa/tests/prime.sh1
-rw-r--r--usr.sbin/sa/usrdb.c3
-rw-r--r--usr.sbin/sendmail/Makefile6
-rw-r--r--usr.sbin/sendmail/Makefile.depend2
-rw-r--r--usr.sbin/sendmail/Makefile.depend.options1
-rw-r--r--usr.sbin/service/Makefile1
-rw-r--r--usr.sbin/service/Makefile.depend1
-rw-r--r--usr.sbin/service/service.865
-rwxr-xr-xusr.sbin/service/service.sh27
-rw-r--r--usr.sbin/services_mkdb/Makefile1
-rw-r--r--usr.sbin/services_mkdb/Makefile.depend2
-rw-r--r--usr.sbin/services_mkdb/extern.h4
-rw-r--r--usr.sbin/services_mkdb/services4
-rw-r--r--usr.sbin/services_mkdb/services_mkdb.82
-rw-r--r--usr.sbin/services_mkdb/services_mkdb.c5
-rw-r--r--usr.sbin/services_mkdb/uniq.c4
-rw-r--r--usr.sbin/sesutil/Makefile1
-rw-r--r--usr.sbin/sesutil/Makefile.depend5
-rw-r--r--usr.sbin/sesutil/eltsub.c1
-rw-r--r--usr.sbin/sesutil/eltsub.h3
-rw-r--r--usr.sbin/sesutil/sesutil.866
-rw-r--r--usr.sbin/sesutil/sesutil.c59
-rw-r--r--usr.sbin/setfib/Makefile2
-rw-r--r--usr.sbin/setfib/Makefile.depend2
-rw-r--r--usr.sbin/setfib/setfib.12
-rw-r--r--usr.sbin/setfib/setfib.c4
-rw-r--r--usr.sbin/setfmac/Makefile1
-rw-r--r--usr.sbin/setfmac/Makefile.depend2
-rw-r--r--usr.sbin/setfmac/setfmac.82
-rw-r--r--usr.sbin/setfmac/setfmac.c4
-rw-r--r--usr.sbin/setfmac/setfsmac.82
-rw-r--r--usr.sbin/setpmac/Makefile1
-rw-r--r--usr.sbin/setpmac/Makefile.depend2
-rw-r--r--usr.sbin/setpmac/setpmac.82
-rw-r--r--usr.sbin/setpmac/setpmac.c2
-rw-r--r--usr.sbin/smbmsg/Makefile1
-rw-r--r--usr.sbin/smbmsg/Makefile.depend2
-rw-r--r--usr.sbin/smbmsg/pathnames.h4
-rw-r--r--usr.sbin/smbmsg/smbmsg.82
-rw-r--r--usr.sbin/smbmsg/smbmsg.c4
-rw-r--r--usr.sbin/snapinfo/Makefile2
-rw-r--r--usr.sbin/snapinfo/Makefile.depend2
-rw-r--r--usr.sbin/snapinfo/snapinfo.82
-rw-r--r--usr.sbin/snapinfo/snapinfo.c4
-rw-r--r--usr.sbin/spi/Makefile1
-rw-r--r--usr.sbin/spi/spi.82
-rw-r--r--usr.sbin/spi/spi.c3
-rw-r--r--usr.sbin/spkrtest/Makefile1
-rw-r--r--usr.sbin/spkrtest/Makefile.depend1
-rw-r--r--usr.sbin/spkrtest/spkrtest.814
-rw-r--r--usr.sbin/spkrtest/spkrtest.sh3
-rw-r--r--usr.sbin/spray/Makefile1
-rw-r--r--usr.sbin/spray/Makefile.depend2
-rw-r--r--usr.sbin/spray/spray.82
-rw-r--r--usr.sbin/spray/spray.c7
-rw-r--r--usr.sbin/syslogd/Makefile5
-rw-r--r--usr.sbin/syslogd/Makefile.depend2
-rw-r--r--usr.sbin/syslogd/ftp.conf1
-rw-r--r--usr.sbin/syslogd/lpr.conf1
-rw-r--r--usr.sbin/syslogd/pathnames.h3
-rw-r--r--usr.sbin/syslogd/ppp.conf1
-rw-r--r--usr.sbin/syslogd/syslog.conf1
-rw-r--r--usr.sbin/syslogd/syslog.conf.53
-rw-r--r--usr.sbin/syslogd/syslogd.83
-rw-r--r--usr.sbin/syslogd/syslogd.c1799
-rw-r--r--usr.sbin/syslogd/tests/Makefile5
-rw-r--r--usr.sbin/syslogd/tests/syslogd_test.sh299
-rw-r--r--usr.sbin/sysrc/Makefile1
-rw-r--r--usr.sbin/sysrc/Makefile.depend1
-rw-r--r--usr.sbin/sysrc/sysrc1
-rw-r--r--usr.sbin/sysrc/sysrc.82
-rw-r--r--usr.sbin/tcpdchk/Makefile1
-rw-r--r--usr.sbin/tcpdchk/Makefile.depend2
-rw-r--r--usr.sbin/tcpdmatch/Makefile1
-rw-r--r--usr.sbin/tcpdmatch/Makefile.depend2
-rw-r--r--usr.sbin/tcpdrop/Makefile1
-rw-r--r--usr.sbin/tcpdrop/Makefile.depend2
-rw-r--r--usr.sbin/tcpdrop/tcpdrop.82
-rw-r--r--usr.sbin/tcpdrop/tcpdrop.c5
-rw-r--r--usr.sbin/tcpdump/Makefile2
-rw-r--r--usr.sbin/tcpdump/Makefile.inc2
-rw-r--r--usr.sbin/tcpdump/tcpdump/Makefile27
-rw-r--r--usr.sbin/tcpdump/tcpdump/Makefile.depend6
-rw-r--r--usr.sbin/tcpdump/tcpdump/Makefile.depend.options1
-rw-r--r--usr.sbin/tcpdump/tcpdump/config.h206
-rw-r--r--usr.sbin/tcpsso/tcpsso.843
-rw-r--r--usr.sbin/tcpsso/tcpsso.c8
-rw-r--r--usr.sbin/tests/Makefile1
-rw-r--r--usr.sbin/tests/Makefile.depend1
-rw-r--r--usr.sbin/traceroute/Makefile21
-rw-r--r--usr.sbin/traceroute/Makefile.depend2
-rw-r--r--usr.sbin/traceroute/Makefile.depend.options1
-rw-r--r--usr.sbin/traceroute/as.c221
-rw-r--r--usr.sbin/traceroute/as.h34
-rw-r--r--usr.sbin/traceroute/findsaddr-socket.c184
-rw-r--r--usr.sbin/traceroute/findsaddr-udp.c4
-rw-r--r--usr.sbin/traceroute/findsaddr.h23
-rw-r--r--usr.sbin/traceroute/ifaddrlist.c160
-rw-r--r--usr.sbin/traceroute/ifaddrlist.h29
-rw-r--r--usr.sbin/traceroute/traceroute.8403
-rw-r--r--usr.sbin/traceroute/traceroute.c2078
-rw-r--r--usr.sbin/traceroute/traceroute.h26
-rw-r--r--usr.sbin/traceroute6/Makefile3
-rw-r--r--usr.sbin/traceroute6/Makefile.depend5
-rw-r--r--usr.sbin/traceroute6/traceroute6.883
-rw-r--r--usr.sbin/traceroute6/traceroute6.c123
-rw-r--r--usr.sbin/trim/Makefile1
-rw-r--r--usr.sbin/trim/trim.82
-rw-r--r--usr.sbin/trim/trim.c4
-rw-r--r--usr.sbin/trpt/Makefile19
-rw-r--r--usr.sbin/trpt/trpt.8144
-rw-r--r--usr.sbin/trpt/trpt.c446
-rw-r--r--usr.sbin/tzsetup/Makefile7
-rw-r--r--usr.sbin/tzsetup/Makefile.depend3
-rw-r--r--usr.sbin/tzsetup/Makefile.depend.options10
-rw-r--r--usr.sbin/tzsetup/baseline670
-rw-r--r--usr.sbin/tzsetup/tzsetup.854
-rw-r--r--usr.sbin/tzsetup/tzsetup.c529
-rw-r--r--usr.sbin/uathload/Makefile1
-rw-r--r--usr.sbin/uathload/Makefile.depend2
-rw-r--r--usr.sbin/uathload/uathload.82
-rw-r--r--usr.sbin/uathload/uathload.c4
-rw-r--r--usr.sbin/uefisign/Makefile1
-rw-r--r--usr.sbin/uefisign/Makefile.depend4
-rw-r--r--usr.sbin/uefisign/child.c5
-rw-r--r--usr.sbin/uefisign/magic.h4
-rw-r--r--usr.sbin/uefisign/pe.c4
-rw-r--r--usr.sbin/uefisign/uefisign.82
-rw-r--r--usr.sbin/uefisign/uefisign.c4
-rw-r--r--usr.sbin/uefisign/uefisign.h4
-rw-r--r--usr.sbin/ugidfw/Makefile1
-rw-r--r--usr.sbin/ugidfw/Makefile.depend2
-rw-r--r--usr.sbin/ugidfw/ugidfw.82
-rw-r--r--usr.sbin/ugidfw/ugidfw.c5
-rw-r--r--usr.sbin/uhsoctl/Makefile1
-rw-r--r--usr.sbin/uhsoctl/Makefile.depend2
-rw-r--r--usr.sbin/uhsoctl/uhsoctl.14
-rw-r--r--usr.sbin/uhsoctl/uhsoctl.c4
-rw-r--r--usr.sbin/unbound/Makefile1
-rw-r--r--usr.sbin/unbound/Makefile.inc1
-rw-r--r--usr.sbin/unbound/anchor/Makefile4
-rw-r--r--usr.sbin/unbound/anchor/Makefile.depend2
-rw-r--r--usr.sbin/unbound/checkconf/Makefile4
-rw-r--r--usr.sbin/unbound/checkconf/Makefile.depend4
-rw-r--r--usr.sbin/unbound/config.h1404
-rw-r--r--usr.sbin/unbound/control/Makefile4
-rw-r--r--usr.sbin/unbound/control/Makefile.depend2
-rw-r--r--usr.sbin/unbound/daemon/Makefile4
-rw-r--r--usr.sbin/unbound/daemon/Makefile.depend2
-rw-r--r--usr.sbin/unbound/setup/Makefile1
-rw-r--r--usr.sbin/unbound/setup/Makefile.depend1
-rwxr-xr-xusr.sbin/unbound/setup/local-unbound-setup.sh7
-rw-r--r--usr.sbin/usbconfig/Makefile1
-rw-r--r--usr.sbin/usbconfig/Makefile.depend3
-rw-r--r--usr.sbin/usbconfig/dump.c160
-rw-r--r--usr.sbin/usbconfig/dump.h3
-rw-r--r--usr.sbin/usbconfig/pathnames.h4
-rw-r--r--usr.sbin/usbconfig/usbconfig.81
-rw-r--r--usr.sbin/usbconfig/usbconfig.c8
-rw-r--r--usr.sbin/usbdump/Makefile1
-rw-r--r--usr.sbin/usbdump/Makefile.depend2
-rw-r--r--usr.sbin/usbdump/usbdump.82
-rw-r--r--usr.sbin/usbdump/usbdump.c4
-rw-r--r--usr.sbin/utx/Makefile3
-rw-r--r--usr.sbin/utx/Makefile.depend2
-rw-r--r--usr.sbin/utx/utx.82
-rw-r--r--usr.sbin/utx/utx.c4
-rw-r--r--usr.sbin/valectl/Makefile2
-rw-r--r--usr.sbin/valectl/valectl.82
-rw-r--r--usr.sbin/valectl/valectl.c1
-rw-r--r--usr.sbin/vidcontrol/Makefile2
-rw-r--r--usr.sbin/vidcontrol/Makefile.depend2
-rw-r--r--usr.sbin/vidcontrol/decode.c5
-rw-r--r--usr.sbin/vidcontrol/decode.h1
-rw-r--r--usr.sbin/vidcontrol/path.h1
-rw-r--r--usr.sbin/vidcontrol/vidcontrol.13
-rw-r--r--usr.sbin/vidcontrol/vidcontrol.c5
-rw-r--r--usr.sbin/vigr/Makefile1
-rw-r--r--usr.sbin/vigr/Makefile.depend1
-rw-r--r--usr.sbin/vigr/vigr.82
-rw-r--r--usr.sbin/vigr/vigr.sh1
-rw-r--r--usr.sbin/vipw/Makefile2
-rw-r--r--usr.sbin/vipw/Makefile.depend2
-rw-r--r--usr.sbin/vipw/vipw.818
-rw-r--r--usr.sbin/vipw/vipw.c14
-rw-r--r--usr.sbin/wake/Makefile1
-rw-r--r--usr.sbin/wake/Makefile.depend2
-rw-r--r--usr.sbin/wake/wake.82
-rw-r--r--usr.sbin/wake/wake.c4
-rw-r--r--usr.sbin/watch/Makefile1
-rw-r--r--usr.sbin/watch/Makefile.depend4
-rw-r--r--usr.sbin/watch/watch.82
-rw-r--r--usr.sbin/watch/watch.c3
-rw-r--r--usr.sbin/watchdogd/Makefile1
-rw-r--r--usr.sbin/watchdogd/Makefile.depend2
-rw-r--r--usr.sbin/watchdogd/watchdog.82
-rw-r--r--usr.sbin/watchdogd/watchdogd.82
-rw-r--r--usr.sbin/watchdogd/watchdogd.c4
-rw-r--r--usr.sbin/wlandebug/Makefile1
-rw-r--r--usr.sbin/wlandebug/Makefile.depend3
-rw-r--r--usr.sbin/wlandebug/wlandebug.82
-rw-r--r--usr.sbin/wlandebug/wlandebug.c6
-rw-r--r--usr.sbin/wpa/Makefile1
-rw-r--r--usr.sbin/wpa/Makefile.crypto1
-rw-r--r--usr.sbin/wpa/Makefile.depend0
-rw-r--r--usr.sbin/wpa/Makefile.depend.options1
-rw-r--r--usr.sbin/wpa/Makefile.inc4
-rw-r--r--usr.sbin/wpa/hostapd/Makefile1
-rw-r--r--usr.sbin/wpa/hostapd/Makefile.depend14
-rw-r--r--usr.sbin/wpa/hostapd/hostapd.83
-rw-r--r--usr.sbin/wpa/hostapd/hostapd.conf.52
-rw-r--r--usr.sbin/wpa/hostapd_cli/Makefile1
-rw-r--r--usr.sbin/wpa/hostapd_cli/Makefile.depend6
-rw-r--r--usr.sbin/wpa/hostapd_cli/hostapd_cli.82
-rw-r--r--usr.sbin/wpa/src/ap/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/common/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/crypto/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/drivers/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/eap_common/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/eap_peer/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/eap_server/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/eapol_auth/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/eapol_supp/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/l2_packet/Makefile.depend14
-rw-r--r--usr.sbin/wpa/src/radius/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/rsn_supp/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/tls/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/utils/Makefile.depend13
-rw-r--r--usr.sbin/wpa/src/wps/Makefile2
-rw-r--r--usr.sbin/wpa/src/wps/Makefile.depend13
-rw-r--r--usr.sbin/wpa/wpa_cli/Makefile1
-rw-r--r--usr.sbin/wpa/wpa_cli/Makefile.depend17
-rw-r--r--usr.sbin/wpa/wpa_cli/wpa_cli.82
-rw-r--r--usr.sbin/wpa/wpa_passphrase/Makefile1
-rw-r--r--usr.sbin/wpa/wpa_passphrase/Makefile.depend6
-rw-r--r--usr.sbin/wpa/wpa_passphrase/wpa_passphrase.82
-rw-r--r--usr.sbin/wpa/wpa_priv/Makefile1
-rw-r--r--usr.sbin/wpa/wpa_supplicant/Makefile1
-rw-r--r--usr.sbin/wpa/wpa_supplicant/Makefile.depend14
-rw-r--r--usr.sbin/wpa/wpa_supplicant/wpa_supplicant.84
-rw-r--r--usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.52
-rw-r--r--usr.sbin/yp_mkdb/Makefile1
-rw-r--r--usr.sbin/yp_mkdb/Makefile.depend2
-rw-r--r--usr.sbin/yp_mkdb/yp_mkdb.82
-rw-r--r--usr.sbin/yp_mkdb/yp_mkdb.c3
-rw-r--r--usr.sbin/ypbind/Makefile2
-rw-r--r--usr.sbin/ypbind/Makefile.depend2
-rw-r--r--usr.sbin/ypbind/yp_ping.c9
-rw-r--r--usr.sbin/ypbind/yp_ping.h1
-rw-r--r--usr.sbin/ypbind/ypbind.82
-rw-r--r--usr.sbin/ypbind/ypbind.c37
-rw-r--r--usr.sbin/ypldap/Makefile1
-rw-r--r--usr.sbin/ypldap/Makefile.depend4
-rw-r--r--usr.sbin/ypldap/aldap.c1
-rw-r--r--usr.sbin/ypldap/aldap.h1
-rw-r--r--usr.sbin/ypldap/ber.c1
-rw-r--r--usr.sbin/ypldap/ber.h1
-rw-r--r--usr.sbin/ypldap/entries.c6
-rw-r--r--usr.sbin/ypldap/ldapclient.c5
-rw-r--r--usr.sbin/ypldap/log.c1
-rw-r--r--usr.sbin/ypldap/parse.y1
-rw-r--r--usr.sbin/ypldap/yp.c4
-rw-r--r--usr.sbin/ypldap/ypldap.81
-rw-r--r--usr.sbin/ypldap/ypldap.c3
-rw-r--r--usr.sbin/ypldap/ypldap.conf.51
-rw-r--r--usr.sbin/ypldap/ypldap.h3
-rw-r--r--usr.sbin/ypldap/ypldap_dns.c1
-rw-r--r--usr.sbin/yppoll/Makefile2
-rw-r--r--usr.sbin/yppoll/Makefile.depend2
-rw-r--r--usr.sbin/yppoll/yppoll.81
-rw-r--r--usr.sbin/yppoll/yppoll.c3
-rw-r--r--usr.sbin/yppush/Makefile1
-rw-r--r--usr.sbin/yppush/Makefile.depend2
-rw-r--r--usr.sbin/yppush/yppush.82
-rw-r--r--usr.sbin/yppush/yppush_extern.h2
-rw-r--r--usr.sbin/yppush/yppush_main.c3
-rw-r--r--usr.sbin/ypserv/Makefile1
-rw-r--r--usr.sbin/ypserv/Makefile.depend1
-rw-r--r--usr.sbin/ypserv/Makefile.depend.options1
-rw-r--r--usr.sbin/ypserv/Makefile.yp1
-rw-r--r--usr.sbin/ypserv/common/yplib_host.c7
-rw-r--r--usr.sbin/ypserv/common/yplib_host.h2
-rw-r--r--usr.sbin/ypserv/yp_access.c2
-rw-r--r--usr.sbin/ypserv/yp_dblookup.c8
-rw-r--r--usr.sbin/ypserv/yp_dnslookup.c8
-rw-r--r--usr.sbin/ypserv/yp_error.c2
-rw-r--r--usr.sbin/ypserv/yp_extern.h4
-rw-r--r--usr.sbin/ypserv/yp_main.c3
-rw-r--r--usr.sbin/ypserv/yp_server.c4
-rw-r--r--usr.sbin/ypserv/yp_svc_udp.c2
-rw-r--r--usr.sbin/ypserv/ypinit.82
-rw-r--r--usr.sbin/ypserv/ypinit.sh1
-rw-r--r--usr.sbin/ypserv/ypserv.82
-rw-r--r--usr.sbin/ypset/Makefile2
-rw-r--r--usr.sbin/ypset/Makefile.depend2
-rw-r--r--usr.sbin/ypset/ypset.82
-rw-r--r--usr.sbin/ypset/ypset.c5
-rw-r--r--usr.sbin/zdump/Makefile10
-rw-r--r--usr.sbin/zdump/Makefile.depend (renamed from usr.sbin/portsnap/make_index/Makefile.depend)1
-rw-r--r--usr.sbin/zic/Makefile11
-rw-r--r--usr.sbin/zic/Makefile.depend (renamed from usr.sbin/zic/zic/Makefile.depend)1
-rw-r--r--usr.sbin/zic/Makefile.inc3
-rw-r--r--usr.sbin/zic/README88
-rw-r--r--usr.sbin/zic/zdump/Makefile15
-rw-r--r--usr.sbin/zic/zic/Makefile22
-rw-r--r--usr.sbin/zonectl/Makefile1
-rw-r--r--usr.sbin/zonectl/Makefile.depend2
-rw-r--r--usr.sbin/zonectl/zonectl.84
-rw-r--r--usr.sbin/zonectl/zonectl.c2
-rw-r--r--usr.sbin/zzz/Makefile1
-rw-r--r--usr.sbin/zzz/Makefile.depend1
-rw-r--r--usr.sbin/zzz/zzz.82
-rw-r--r--usr.sbin/zzz/zzz.sh11
2656 files changed, 40493 insertions, 25468 deletions
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index d57cb3bb9ea6..c3a4cc42f721 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -1,5 +1,3 @@
-# From: @(#)Makefile 5.20 (Berkeley) 6/12/93
-# $FreeBSD$
.include <src.opts.mk>
@@ -7,6 +5,7 @@ SUBDIR= adduser \
arp \
binmiscctl \
boottrace \
+ bsdconfig \
camdd \
cdcontrol \
chkgrp \
@@ -28,6 +27,7 @@ SUBDIR= adduser \
fifolog \
fstyp \
fwcontrol \
+ fwget \
getfmac \
getpmac \
gstat \
@@ -93,7 +93,6 @@ SUBDIR= adduser \
tcpsso \
traceroute \
trim \
- trpt \
tzsetup \
ugidfw \
valectl \
@@ -102,6 +101,7 @@ SUBDIR= adduser \
wake \
watch \
watchdogd \
+ zdump \
zic \
zonectl
@@ -128,11 +128,11 @@ SUBDIR.${MK_BSNMP}+= bsnmpd
SUBDIR.${MK_OPENSSL}+= certctl
.endif
SUBDIR.${MK_CXGBETOOL}+= cxgbetool
-SUBDIR.${MK_DIALOG}+= bsdconfig
-SUBDIR.${MK_EFI}+= efivar efidp efibootmgr efitable
+SUBDIR.${MK_EFI}+= efivar efidp efibootmgr efitable efiwake
.if ${MK_OPENSSL} != "no"
SUBDIR.${MK_EFI}+= uefisign
.endif
+SUBDIR.${MK_FDT}+= ofwdump
SUBDIR.${MK_FLOPPY}+= fdcontrol
SUBDIR.${MK_FLOPPY}+= fdformat
SUBDIR.${MK_FLOPPY}+= fdread
@@ -140,6 +140,7 @@ SUBDIR.${MK_FLOPPY}+= fdwrite
SUBDIR.${MK_FREEBSD_UPDATE}+= freebsd-update
SUBDIR.${MK_GSSAPI}+= gssd
SUBDIR.${MK_GPIO}+= gpioctl
+SUBDIR.${MK_HYPERV}+= hyperv
SUBDIR.${MK_INET6}+= ip6addrctl
SUBDIR.${MK_INET6}+= mld6query
SUBDIR.${MK_INET6}+= ndp
@@ -186,7 +187,6 @@ SUBDIR.${MK_OPENSSL_KTLS}+= rpc.tlsservd
SUBDIR.${MK_PF}+= ftp-proxy
SUBDIR.${MK_PKGBOOTSTRAP}+= pkg
SUBDIR.${MK_PMC}+= pmc pmcannotate pmccontrol pmcstat pmcstudy
-SUBDIR.${MK_PORTSNAP}+= portsnap
SUBDIR.${MK_PPP}+= ppp
SUBDIR.${MK_QUOTAS}+= edquota
SUBDIR.${MK_QUOTAS}+= quotaon
diff --git a/usr.sbin/Makefile.aarch64 b/usr.sbin/Makefile.aarch64
index c2d5f36a1738..6302b6a78ef7 100644
--- a/usr.sbin/Makefile.aarch64
+++ b/usr.sbin/Makefile.aarch64
@@ -1,6 +1,6 @@
-# $FreeBSD$
-
.if ${MK_ACPI} != "no"
SUBDIR+= acpi
.endif
-SUBDIR+= ofwdump
+.if ${MK_BHYVE} != "no"
+SUBDIR+= bhyve
+.endif
diff --git a/usr.sbin/Makefile.amd64 b/usr.sbin/Makefile.amd64
index 1f15259eb1ac..da4ffd2a6b00 100644
--- a/usr.sbin/Makefile.amd64
+++ b/usr.sbin/Makefile.amd64
@@ -1,17 +1,11 @@
-# $FreeBSD$
# mptable: broken (not 64 bit clean)
# pnpinfo: crashes (not really useful anyway)
-_ARCH_SUBDIR=amd64
.if ${MK_ACPI} != "no"
SUBDIR+= acpi
.endif
.if ${MK_APM} != "no"
SUBDIR+= apm
-# Link files to the architecture directory
-.for _manpage in ${:!/bin/sh -c "/bin/ls ${_ARCH_SUBDIR}/.8"!:E}
-MLINKS+=${_manpage} ${_ARCH_SUBDIR}/${_manpage}
-.endfor
.endif
.if ${MK_BHYVE} != "no"
SUBDIR+= bhyve
@@ -23,9 +17,6 @@ SUBDIR+= boot0cfg
SUBDIR+= btxld
.endif
SUBDIR+= cpucontrol
-.if ${MK_HYPERV} != "no"
-SUBDIR+= hyperv
-.endif
SUBDIR+= lptcontrol
SUBDIR+= mptable
SUBDIR+= spkrtest
diff --git a/usr.sbin/Makefile.arm b/usr.sbin/Makefile.arm
deleted file mode 100644
index 8987110dba31..000000000000
--- a/usr.sbin/Makefile.arm
+++ /dev/null
@@ -1,3 +0,0 @@
-# $FreeBSD$
-
-SUBDIR+= ofwdump
diff --git a/usr.sbin/Makefile.i386 b/usr.sbin/Makefile.i386
index 4705fcadb36f..da8f18efbef2 100644
--- a/usr.sbin/Makefile.i386
+++ b/usr.sbin/Makefile.i386
@@ -1,4 +1,3 @@
-# $FreeBSD$
.if ${MK_ACPI} != "no"
SUBDIR+= acpi
@@ -12,9 +11,6 @@ SUBDIR+= boot0cfg
SUBDIR+= btxld
.endif
SUBDIR+= cpucontrol
-.if ${MK_HYPERV} != "no"
-SUBDIR+= hyperv
-.endif
SUBDIR+= lptcontrol
SUBDIR+= mptable
SUBDIR+= pnpinfo
diff --git a/usr.sbin/Makefile.inc b/usr.sbin/Makefile.inc
index 4347591cf563..523a0dd44643 100644
--- a/usr.sbin/Makefile.inc
+++ b/usr.sbin/Makefile.inc
@@ -1,4 +1,2 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
BINDIR?= /usr/sbin
diff --git a/usr.sbin/Makefile.mips b/usr.sbin/Makefile.mips
deleted file mode 100644
index 8987110dba31..000000000000
--- a/usr.sbin/Makefile.mips
+++ /dev/null
@@ -1,3 +0,0 @@
-# $FreeBSD$
-
-SUBDIR+= ofwdump
diff --git a/usr.sbin/Makefile.powerpc b/usr.sbin/Makefile.powerpc
index 4e234ab8dce9..d6b05857e152 100644
--- a/usr.sbin/Makefile.powerpc
+++ b/usr.sbin/Makefile.powerpc
@@ -1,6 +1,4 @@
-# $FreeBSD$
.if ${MACHINE_ARCH} != "powerpcspe"
SUBDIR+= nvram
.endif
-SUBDIR+= ofwdump
diff --git a/usr.sbin/Makefile.riscv b/usr.sbin/Makefile.riscv
deleted file mode 100644
index 8987110dba31..000000000000
--- a/usr.sbin/Makefile.riscv
+++ /dev/null
@@ -1,3 +0,0 @@
-# $FreeBSD$
-
-SUBDIR+= ofwdump
diff --git a/usr.sbin/ac/Makefile b/usr.sbin/ac/Makefile
index 0fac2fbdbab9..9a90c4566433 100644
--- a/usr.sbin/ac/Makefile
+++ b/usr.sbin/ac/Makefile
@@ -1,6 +1,6 @@
-# $FreeBSD$
PROG= ac
+PACKAGE= acct
MAN= ac.8
# If "CONSOLE_TTY" is not defined, this program is compatible with the
diff --git a/usr.sbin/ac/Makefile.depend b/usr.sbin/ac/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/ac/Makefile.depend
+++ b/usr.sbin/ac/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/ac/ac.8 b/usr.sbin/ac/ac.8
index 0767e427d340..3011b71e7676 100644
--- a/usr.sbin/ac/ac.8
+++ b/usr.sbin/ac/ac.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 February 14, 2020
.Dt AC 8
.Os
diff --git a/usr.sbin/ac/ac.c b/usr.sbin/ac/ac.c
index 8e7ed2497937..1146475d5f14 100644
--- a/usr.sbin/ac/ac.c
+++ b/usr.sbin/ac/ac.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1994 Christopher G. Demetriou
* Copyright (c) 1994 Simon J. Gerraty
@@ -29,8 +29,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/queue.h>
#include <sys/time.h>
@@ -68,7 +66,7 @@ struct user_entry {
};
/*
- * this is for chosing whether to ignore a login
+ * this is for choosing whether to ignore a login
*/
struct tty_entry {
SLIST_ENTRY(tty_entry) next;
@@ -408,17 +406,15 @@ ac(const char *file)
struct utmpx *usr, usht;
struct tm *ltm;
struct timeval prev_secs, ut_timecopy, secs, clock_shift, now;
- int day, rfound;
+ int day;
day = -1;
timerclear(&prev_secs); /* Minimum acceptable date == 1970. */
timerclear(&secs);
timerclear(&clock_shift);
- rfound = 0;
if (setutxdb(UTXDB_LOG, file) != 0)
err(1, "%s", file);
while ((usr = getutxent()) != NULL) {
- rfound++;
ut_timecopy = usr->ut_tv;
/* Don't let the time run backwards. */
if (timercmp(&ut_timecopy, &prev_secs, <))
diff --git a/usr.sbin/accton/Makefile b/usr.sbin/accton/Makefile
index 94c87ac4ce36..01abcda32e02 100644
--- a/usr.sbin/accton/Makefile
+++ b/usr.sbin/accton/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= accton
MAN= accton.8
diff --git a/usr.sbin/accton/Makefile.depend b/usr.sbin/accton/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/accton/Makefile.depend
+++ b/usr.sbin/accton/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/accton/accton.8 b/usr.sbin/accton/accton.8
index 73c7d2926113..9967bfbd05a3 100644
--- a/usr.sbin/accton/accton.8
+++ b/usr.sbin/accton/accton.8
@@ -1,4 +1,3 @@
-.\" $FreeBSD$
.\"
.Dd May 21, 1993
.Dt ACCTON 8
diff --git a/usr.sbin/accton/accton.c b/usr.sbin/accton/accton.c
index 80823ecabbc5..98f5e9861286 100644
--- a/usr.sbin/accton/accton.c
+++ b/usr.sbin/accton/accton.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1988, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)accton.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <err.h>
#include <stdio.h>
@@ -50,7 +36,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char *argv[])
diff --git a/usr.sbin/acpi/Makefile b/usr.sbin/acpi/Makefile
index 8190bc7c3037..c44a4146f44b 100644
--- a/usr.sbin/acpi/Makefile
+++ b/usr.sbin/acpi/Makefile
@@ -1,6 +1,5 @@
# Makefile for acpi tools
# $Id: Makefile,v 1.1 2000/07/14 18:16:22 iwasaki Exp $
-# $FreeBSD$
SUBDIR= acpiconf acpidb acpidump iasl
diff --git a/usr.sbin/acpi/Makefile.inc b/usr.sbin/acpi/Makefile.inc
index 27e16d001380..6bc7076909a2 100644
--- a/usr.sbin/acpi/Makefile.inc
+++ b/usr.sbin/acpi/Makefile.inc
@@ -1,5 +1,4 @@
# $Id: Makefile.inc,v 1.1 2000/07/14 18:16:22 iwasaki Exp $
-# $FreeBSD$
ACPICA_DIR= ${SRCTOP}/sys/contrib/dev/acpica
CFLAGS+= -I${SRCTOP}/sys
diff --git a/usr.sbin/acpi/acpiconf/Makefile b/usr.sbin/acpi/acpiconf/Makefile
index 0bbadc1e8fb9..c9778bbc9032 100644
--- a/usr.sbin/acpi/acpiconf/Makefile
+++ b/usr.sbin/acpi/acpiconf/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.2 2000/07/14 18:16:25 iwasaki Exp $
-# $FreeBSD$
PROG= acpiconf
MAN= acpiconf.8
diff --git a/usr.sbin/acpi/acpiconf/Makefile.depend b/usr.sbin/acpi/acpiconf/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/acpi/acpiconf/Makefile.depend
+++ b/usr.sbin/acpi/acpiconf/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/acpi/acpiconf/acpiconf.8 b/usr.sbin/acpi/acpiconf/acpiconf.8
index 53888d8489ea..24af8b5c8719 100644
--- a/usr.sbin/acpi/acpiconf/acpiconf.8
+++ b/usr.sbin/acpi/acpiconf/acpiconf.8
@@ -1,5 +1,5 @@
.\"-
-.\" Copyright (c) 2000 Dag-Erling Coïdan Smørgrav
+.\" Copyright (c) 2000 Dag-Erling Smørgrav
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -25,9 +25,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 December 27, 2018
+.Dd June 16, 2023
.Dt ACPICONF 8
.Os
.Sh NAME
@@ -81,27 +79,30 @@ or
before and after entering the given sleep state.
.Pp
The
+.Pa /etc/rc.suspend
+and
.Pa /etc/rc.resume
-script uses the
+scripts use the
.Xr rcorder 8
utility to call scripts in
.Pa /etc/rc.d/
and the
.Va $local_startup
-directories that have a "resume" KEYWORD.
-Called scripts are supplied with single "resume"
-command line argument. See
+directories that have a "suspend" or "resume" KEYWORD, respectively.
+Called scripts are supplied with a single "suspend" / "resume"
+command line argument.
+See
.Xr rc.conf 5
for more information about
.Va $local_startup .
.El
.Sh SEE ALSO
.Xr acpi 4 ,
+.Xr rc.conf 5 ,
.Xr acpidump 8 ,
.Xr apm 8 ,
.Xr apmd 8 ,
.Xr devd 8 ,
-.Xr rc.conf 5 ,
.Xr rcorder 8
.Sh HISTORY
The
diff --git a/usr.sbin/acpi/acpiconf/acpiconf.c b/usr.sbin/acpi/acpiconf/acpiconf.c
index b239d5e91661..4f5cb08325dc 100644
--- a/usr.sbin/acpi/acpiconf/acpiconf.c
+++ b/usr.sbin/acpi/acpiconf/acpiconf.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
* All rights reserved.
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*
* $Id: acpiconf.c,v 1.5 2000/08/08 14:12:19 iwasaki Exp $
- * $FreeBSD$
*/
#include <sys/param.h>
@@ -132,7 +131,7 @@ acpi_battinfo(int num)
if (ACPI_BIX_REV_MIN_CHECK(battio.bix.rev, ACPI_BIX_REV_0)) {
if (battio.bix.cycles != ACPI_BATT_UNKNOWN)
printf("Cycle Count:\t\t%d\n", battio.bix.cycles);
- printf("Measurement Accuracy:\t%d %%\n",
+ printf("Measurement Accuracy:\t%d%%\n",
battio.bix.accuracy / 1000);
if (battio.bix.stmax != ACPI_BATT_UNKNOWN)
printf("Max Sampling Time:\t%d ms\n",
diff --git a/usr.sbin/acpi/acpidb/Makefile b/usr.sbin/acpi/acpidb/Makefile
index 5a6fceb2a4cb..dc3a871edf3f 100644
--- a/usr.sbin/acpi/acpidb/Makefile
+++ b/usr.sbin/acpi/acpidb/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= acpidb
SRCS= acpidb.c
@@ -62,13 +61,13 @@ SRCS+= tbdata.c tbfadt.c tbfind.c tbinstal.c tbprint.c \
# components/utilities
SRCS+= utaddress.c utalloc.c utascii.c utbuffer.c utcache.c \
- utcopy.c utdebug.c utdecode.c utdelete.c uterror.c \
- uteval.c utexcep.c utglobal.c uthex.c utids.c utinit.c \
- utlock.c utmath.c utmisc.c utmutex.c utnonansi.c \
- utobject.c utosi.c utownerid.c utpredef.c utresdecode.c \
- utresrc.c utstate.c utstring.c utstrsuppt.c \
- utstrtoul64.c uttrack.c utuuid.c utxface.c utxferror.c \
- utxfinit.c
+ utcksum.c utcopy.c utdebug.c utdecode.c utdelete.c \
+ uterror.c uteval.c utexcep.c utglobal.c uthex.c utids.c \
+ utinit.c utlock.c utmath.c utmisc.c utmutex.c \
+ utnonansi.c utobject.c utosi.c utownerid.c utpredef.c \
+ utresdecode.c utresrc.c utstate.c utstring.c \
+ utstrsuppt.c utstrtoul64.c uttrack.c utuuid.c utxface.c \
+ utxferror.c utxfinit.c
# os_specific/service_layers
SRCS+= osgendbg.c osunixxf.c
@@ -90,3 +89,7 @@ LIBADD= pthread
.if ${COMPILER_TYPE} == "clang"
CWARNFLAGS+= -Wno-null-pointer-arithmetic
.endif
+
+# AcpiUtInitStackPtrTrace intentionally leaks a pointer to an
+# on-stack variable.
+CWARNFLAGS.utdebug.c+= ${NO_WDANGLING_POINTER}
diff --git a/usr.sbin/acpi/acpidb/Makefile.depend b/usr.sbin/acpi/acpidb/Makefile.depend
index 8bb1973e0ff5..577dc5747f1e 100644
--- a/usr.sbin/acpi/acpidb/Makefile.depend
+++ b/usr.sbin/acpi/acpidb/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/acpi/acpidb/acpidb.8 b/usr.sbin/acpi/acpidb/acpidb.8
index 67fab31c346d..0b9163c5a010 100644
--- a/usr.sbin/acpi/acpidb/acpidb.8
+++ b/usr.sbin/acpi/acpidb/acpidb.8
@@ -25,8 +25,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 August 7, 2003
.Dt ACPIDB 8
.Os
diff --git a/usr.sbin/acpi/acpidb/acpidb.c b/usr.sbin/acpi/acpidb/acpidb.c
index 96ef446ab2dc..efd8099f467e 100644
--- a/usr.sbin/acpi/acpidb/acpidb.c
+++ b/usr.sbin/acpi/acpidb/acpidb.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2000-2002 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/acpi/acpidump/Makefile b/usr.sbin/acpi/acpidump/Makefile
index e258f8e34f05..d0bb14284c1a 100644
--- a/usr.sbin/acpi/acpidump/Makefile
+++ b/usr.sbin/acpi/acpidump/Makefile
@@ -1,8 +1,6 @@
-# $FreeBSD$
PROG= acpidump
MAN= acpidump.8
SRCS= acpi.c acpi_user.c acpidump.c
-WARNS?= 3
.include <bsd.prog.mk>
diff --git a/usr.sbin/acpi/acpidump/Makefile.depend b/usr.sbin/acpi/acpidump/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/acpi/acpidump/Makefile.depend
+++ b/usr.sbin/acpi/acpidump/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c
index 31baa3601338..0cc3f76ac018 100644
--- a/usr.sbin/acpi/acpidump/acpi.c
+++ b/usr.sbin/acpi/acpidump/acpi.c
@@ -1,11 +1,15 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Doug Rabson
* Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
* Copyright (c) 2020 Alexander Motin <mav@FreeBSD.org>
+ * Copyright (c) 2024 The FreeBSD Foundation
* All rights reserved.
*
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -26,8 +30,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/param.h>
@@ -38,6 +40,7 @@
#include <err.h>
#include <fcntl.h>
#include <paths.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -159,6 +162,18 @@ printflag(uint64_t var, uint64_t mask, const char *name)
}
static void
+printfield(uint64_t var, int lbit, int hbit, const char *name)
+{
+ uint64_t mask;
+ int len;
+
+ len = hbit - lbit + 1;
+ mask = ((1 << (len + 1)) - 1) << lbit;
+ printf("%c%s=%#jx", pf_sep, name, (uintmax_t)((var & mask) >> lbit));
+ pf_sep = ',';
+}
+
+static void
acpi_print_string(char *s, size_t length)
{
int c;
@@ -211,7 +226,7 @@ acpi_print_gas(ACPI_GENERIC_ADDRESS *gas)
/* The FADT revision indicates whether we use the DSDT or X_DSDT addresses. */
static int
-acpi_get_fadt_revision(ACPI_TABLE_FADT *fadt)
+acpi_get_fadt_revision(ACPI_TABLE_FADT *fadt __unused)
{
int fadt_revision;
@@ -555,7 +570,7 @@ acpi_print_madt(ACPI_SUBTABLE_HEADER *mp)
printf("\tGICR ADDR=%016jx\n",
(uintmax_t)gicc->GicrBaseAddress);
printf("\tMPIDR=%jx\n", (uintmax_t)gicc->ArmMpidr);
- printf("\tEfficency Class=%d\n", (u_int)gicc->EfficiencyClass);
+ printf("\tEfficiency Class=%d\n", (u_int)gicc->EfficiencyClass);
printf("\tSPE INTR=%d\n", gicc->SpeInterrupt);
break;
case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
@@ -1487,6 +1502,375 @@ acpi_handle_dmar(ACPI_TABLE_HEADER *sdp)
}
static void
+acpi_handle_ivrs_ivhd_header(ACPI_IVRS_HEADER *addr)
+{
+ printf("\n\tIVHD Type=%#x IOMMUId=%x\n\tFlags=",
+ addr->Type, addr->DeviceId);
+#define PRINTFLAG(flag, name) printflag(addr->Flags, flag, #name)
+ PRINTFLAG(ACPI_IVHD_TT_ENABLE, HtTunEn);
+ PRINTFLAG(ACPI_IVHD_ISOC, PassPW);
+ PRINTFLAG(ACPI_IVHD_RES_PASS_PW, ResPassPW);
+ PRINTFLAG(ACPI_IVHD_ISOC, Isoc);
+ PRINTFLAG(ACPI_IVHD_TT_ENABLE, IotlbSup);
+ PRINTFLAG((1 << 5), Coherent);
+ PRINTFLAG((1 << 6), PreFSup);
+ PRINTFLAG((1 << 7), PPRSup);
+#undef PRINTFLAG
+ PRINTFLAG_END();
+}
+
+static void
+acpi_handle_ivrs_ivhd_dte(UINT8 dte)
+{
+ if (dte == 0) {
+ printf("\n");
+ return;
+ }
+ printf(" DTE=");
+#define PRINTFLAG(flag, name) printflag(dte, flag, #name)
+ PRINTFLAG(ACPI_IVHD_INIT_PASS, INITPass);
+ PRINTFLAG(ACPI_IVHD_EINT_PASS, EIntPass);
+ PRINTFLAG(ACPI_IVHD_NMI_PASS, NMIPass);
+ PRINTFLAG(ACPI_IVHD_SYSTEM_MGMT, SysMgtPass);
+ PRINTFLAG(ACPI_IVHD_LINT0_PASS, Lint0Pass);
+ PRINTFLAG(ACPI_IVHD_LINT1_PASS, Lint1Pass);
+#undef PRINTFLAG
+ PRINTFLAG_END();
+}
+
+static void
+acpi_handle_ivrs_ivhd_edte(UINT32 edte)
+{
+ if (edte == 0)
+ return;
+ printf("\t\t ExtDTE=");
+#define PRINTFLAG(flag, name) printflag(edte, flag, #name)
+ PRINTFLAG(ACPI_IVHD_ATS_DISABLED, AtsDisabled);
+#undef PRINTFLAG
+ PRINTFLAG_END();
+}
+
+static const char *
+acpi_handle_ivrs_ivhd_variety(UINT8 v)
+{
+ switch (v) {
+ case ACPI_IVHD_IOAPIC:
+ return ("IOAPIC");
+ case ACPI_IVHD_HPET:
+ return ("HPET");
+ default:
+ return ("UNKNOWN");
+ }
+}
+
+static void
+acpi_handle_ivrs_ivhd_devs(ACPI_IVRS_DE_HEADER *d, char *de)
+{
+ char *db;
+ ACPI_IVRS_DEVICE4 *d4;
+ ACPI_IVRS_DEVICE8A *d8a;
+ ACPI_IVRS_DEVICE8B *d8b;
+ ACPI_IVRS_DEVICE8C *d8c;
+ ACPI_IVRS_DEVICE_HID *dh;
+ size_t len;
+ UINT32 x32;
+
+ for (; (char *)d < de; d = (ACPI_IVRS_DE_HEADER *)(db + len)) {
+ db = (char *)d;
+ if (d->Type == ACPI_IVRS_TYPE_PAD4) {
+ len = sizeof(*d4);
+ } else if (d->Type == ACPI_IVRS_TYPE_ALL) {
+ d4 = (ACPI_IVRS_DEVICE4 *)db;
+ len = sizeof(*d4);
+ printf("\t\tDev Type=%#x Id=ALL", d4->Header.Type);
+ acpi_handle_ivrs_ivhd_dte(d4->Header.DataSetting);
+ } else if (d->Type == ACPI_IVRS_TYPE_SELECT) {
+ d4 = (ACPI_IVRS_DEVICE4 *)db;
+ len = sizeof(*d4);
+ printf("\t\tDev Type=%#x Id=%#06x", d4->Header.Type,
+ d4->Header.Id);
+ acpi_handle_ivrs_ivhd_dte(d4->Header.DataSetting);
+ } else if (d->Type == ACPI_IVRS_TYPE_START) {
+ d4 = (ACPI_IVRS_DEVICE4 *)db;
+ len = 2 * sizeof(*d4);
+ printf("\t\tDev Type=%#x Id=%#06x-%#06x",
+ d4->Header.Type,
+ d4->Header.Id, (d4 + 1)->Header.Id);
+ acpi_handle_ivrs_ivhd_dte(d4->Header.DataSetting);
+ } else if (d->Type == ACPI_IVRS_TYPE_END) {
+ d4 = (ACPI_IVRS_DEVICE4 *)db;
+ len = 2 * sizeof(*d4);
+ printf("\t\tDev Type=%#x Id=%#06x BIOS BUG\n",
+ d4->Header.Type, d4->Header.Id);
+ } else if (d->Type == ACPI_IVRS_TYPE_PAD8) {
+ len = sizeof(*d8a);
+ } else if (d->Type == ACPI_IVRS_TYPE_ALIAS_SELECT) {
+ d8a = (ACPI_IVRS_DEVICE8A *)db;
+ len = sizeof(*d8a);
+ printf("\t\tDev Type=%#x Id=%#06x AliasId=%#06x",
+ d8a->Header.Type, d8a->Header.Id, d8a->UsedId);
+ acpi_handle_ivrs_ivhd_dte(d8a->Header.DataSetting);
+ } else if (d->Type == ACPI_IVRS_TYPE_ALIAS_START) {
+ d8a = (ACPI_IVRS_DEVICE8A *)db;
+ d4 = (ACPI_IVRS_DEVICE4 *)(db + sizeof(*d8a));
+ len = sizeof(*d8a) + sizeof(*d4);
+ printf("\t\tDev Type=%#x Id=%#06x-%#06x AliasId=%#06x",
+ d8a->Header.Type, d8a->Header.Id, d4->Header.Id,
+ d8a->UsedId);
+ acpi_handle_ivrs_ivhd_dte(d8a->Header.DataSetting);
+ } else if (d->Type == ACPI_IVRS_TYPE_EXT_SELECT) {
+ d8b = (ACPI_IVRS_DEVICE8B *)db;
+ len = sizeof(*d8b);
+ printf("\t\tDev Type=%#x Id=%#06x",
+ d8a->Header.Type, d8a->Header.Id);
+ acpi_handle_ivrs_ivhd_dte(d8b->Header.DataSetting);
+ printf("\t\t");
+ acpi_handle_ivrs_ivhd_edte(d8b->ExtendedData);
+ } else if (d->Type == ACPI_IVRS_TYPE_EXT_START) {
+ d8b = (ACPI_IVRS_DEVICE8B *)db;
+ len = sizeof(*d8b);
+ d4 = (ACPI_IVRS_DEVICE4 *)(db + sizeof(*d8a));
+ len = sizeof(*d8a) + sizeof(*d4);
+ printf("\t\tDev Type=%#x Id=%#06x-%#06x",
+ d8a->Header.Type, d8a->Header.Id, d4->Header.Id);
+ acpi_handle_ivrs_ivhd_dte(d8b->Header.DataSetting);
+ acpi_handle_ivrs_ivhd_edte(d8b->ExtendedData);
+ } else if (d->Type == ACPI_IVRS_TYPE_SPECIAL) {
+ d8c = (ACPI_IVRS_DEVICE8C *)db;
+ len = sizeof(*d8c);
+ printf("\t\tDev Type=%#x Id=%#06x Handle=%#x "
+ "Variety=%d(%s)",
+ d8c->Header.Type, d8c->UsedId, d8c->Handle,
+ d8c->Variety,
+ acpi_handle_ivrs_ivhd_variety(d8c->Variety));
+ acpi_handle_ivrs_ivhd_dte(d8c->Header.DataSetting);
+ } else if (d->Type == ACPI_IVRS_TYPE_HID) {
+ dh = (ACPI_IVRS_DEVICE_HID *)db;
+ len = sizeof(*dh) + dh->UidLength;
+ printf("\t\tDev Type=%#x Id=%#06x HID=",
+ dh->Header.Type, dh->Header.Id);
+ acpi_print_string((char *)&dh->AcpiHid,
+ sizeof(dh->AcpiHid));
+ printf(" CID=");
+ acpi_print_string((char *)&dh->AcpiCid,
+ sizeof(dh->AcpiCid));
+ printf(" UID=");
+ switch (dh->UidType) {
+ case ACPI_IVRS_UID_NOT_PRESENT:
+ default:
+ printf("none");
+ break;
+ case ACPI_IVRS_UID_IS_INTEGER:
+ memcpy(&x32, dh + 1, sizeof(x32));
+ printf("%#x", x32);
+ break;
+ case ACPI_IVRS_UID_IS_STRING:
+ acpi_print_string((char *)(dh + 1),
+ dh->UidLength);
+ break;
+ }
+ acpi_handle_ivrs_ivhd_dte(dh->Header.DataSetting);
+ } else {
+ printf("\t\tDev Type=%#x Unknown\n", d->Type);
+ if (d->Type <= 63)
+ len = sizeof(*d4);
+ else if (d->Type <= 127)
+ len = sizeof(*d8a);
+ else {
+ printf("Abort, cannot advance iterator.\n");
+ return;
+ }
+ }
+ }
+}
+
+static void
+acpi_handle_ivrs_ivhd_10(ACPI_IVRS_HARDWARE1 *addr, bool efrsup)
+{
+ acpi_handle_ivrs_ivhd_header(&addr->Header);
+ printf("\tCapOffset=%#x Base=%#jx PCISeg=%#x Unit=%#x MSIlog=%d\n",
+ addr->CapabilityOffset, (uintmax_t)addr->BaseAddress,
+ addr->PciSegmentGroup, (addr->Info & ACPI_IVHD_UNIT_ID_MASK) >> 8,
+ addr->Info & ACPI_IVHD_MSI_NUMBER_MASK);
+ if (efrsup) {
+#define PRINTFLAG(flag, name) printflag(addr->FeatureReporting, flag, #name)
+#define PRINTFIELD(lbit, hbit, name) \
+ printfield(addr->FeatureReporting, lbit, hbit, #name)
+ PRINTFIELD(30, 31, HATS);
+ PRINTFIELD(28, 29, GATS);
+ PRINTFIELD(23, 27, MsiNumPPR);
+ PRINTFIELD(17, 22, PNBanks);
+ PRINTFIELD(13, 16, PNCounters);
+ PRINTFIELD(8, 12, PASmax);
+ PRINTFLAG(1 << 7, HESup);
+ PRINTFLAG(1 << 6, GASup);
+ PRINTFLAG(1 << 5, UASup);
+ PRINTFIELD(3, 2, GLXSup);
+ PRINTFLAG(1 << 1, NXSup);
+ PRINTFLAG(1 << 0, XTSup);
+#undef PRINTFLAG
+#undef PRINTFIELD
+ PRINTFLAG_END();
+ }
+ acpi_handle_ivrs_ivhd_devs((ACPI_IVRS_DE_HEADER *)(addr + 1),
+ (char *)addr + addr->Header.Length);
+}
+
+static void
+acpi_handle_ivrs_ivhd_info_11(ACPI_IVRS_HARDWARE2 *addr)
+{
+ acpi_handle_ivrs_ivhd_header(&addr->Header);
+ printf("\tCapOffset=%#x Base=%#jx PCISeg=%#x Unit=%#x MSIlog=%d\n",
+ addr->CapabilityOffset, (uintmax_t)addr->BaseAddress,
+ addr->PciSegmentGroup, (addr->Info >> 8) & 0x1f,
+ addr->Info & 0x5);
+ printf("\tAttr=");
+#define PRINTFIELD(lbit, hbit, name) \
+ printfield(addr->Attributes, lbit, hbit, #name)
+ PRINTFIELD(23, 27, MsiNumPPR);
+ PRINTFIELD(17, 22, PNBanks);
+ PRINTFIELD(13, 16, PNCounters);
+#undef PRINTFIELD
+ PRINTFLAG_END();
+}
+
+static void
+acpi_handle_ivrs_ivhd_11(ACPI_IVRS_HARDWARE2 *addr)
+{
+ acpi_handle_ivrs_ivhd_info_11(addr);
+ printf("\tEFRreg=%#018jx\n", (uintmax_t)addr->EfrRegisterImage);
+ acpi_handle_ivrs_ivhd_devs((ACPI_IVRS_DE_HEADER *)(addr + 1),
+ (char *)addr + addr->Header.Length);
+}
+
+static void
+acpi_handle_ivrs_ivhd_40(ACPI_IVRS_HARDWARE2 *addr)
+{
+ acpi_handle_ivrs_ivhd_info_11(addr);
+ printf("\tEFRreg=%#018jx EFR2reg=%#018jx\n",
+ (uintmax_t)addr->EfrRegisterImage, (uintmax_t)addr->Reserved);
+ acpi_handle_ivrs_ivhd_devs((ACPI_IVRS_DE_HEADER *)(addr + 1),
+ (char *)addr + addr->Header.Length);
+}
+
+static const char *
+acpi_handle_ivrs_ivmd_type(ACPI_IVRS_MEMORY *addr)
+{
+ switch (addr->Header.Type) {
+ case ACPI_IVRS_TYPE_MEMORY1:
+ return ("ALL");
+ case ACPI_IVRS_TYPE_MEMORY2:
+ return ("specified");
+ case ACPI_IVRS_TYPE_MEMORY3:
+ return ("range");
+ default:
+ return ("unknown");
+ }
+}
+
+static void
+acpi_handle_ivrs_ivmd(ACPI_IVRS_MEMORY *addr)
+{
+ printf("\tMem Type=%#x(%s) ",
+ addr->Header.Type, acpi_handle_ivrs_ivmd_type(addr));
+ switch (addr->Header.Type) {
+ case ACPI_IVRS_TYPE_MEMORY2:
+ printf("Id=%#06x PCISeg=%#x ", addr->Header.DeviceId,
+ *(UINT16 *)&addr->Reserved);
+ break;
+ case ACPI_IVRS_TYPE_MEMORY3:
+ printf("Id=%#06x-%#06x PCISeg=%#x", addr->Header.DeviceId,
+ addr->AuxData, *(UINT16 *)&addr->Reserved);
+ break;
+ }
+ printf("Start=%#18jx Length=%#jx Flags=",
+ (uintmax_t)addr->StartAddress, (uintmax_t)addr->MemoryLength);
+#define PRINTFLAG(flag, name) printflag(addr->Header.Flags, flag, #name)
+ PRINTFLAG(ACPI_IVMD_EXCLUSION_RANGE, ExclusionRange);
+ PRINTFLAG(ACPI_IVMD_WRITE, IW);
+ PRINTFLAG(ACPI_IVMD_READ, IR);
+ PRINTFLAG(ACPI_IVMD_UNITY, Unity);
+#undef PRINTFLAG
+ PRINTFLAG_END();
+}
+
+static int
+acpi_handle_ivrs_blocks(void *addr, int remaining, bool efrsup)
+{
+ ACPI_IVRS_HEADER *hdr = addr;
+
+ if (remaining < (int)sizeof(ACPI_IVRS_HEADER))
+ return (-1);
+
+ if (remaining < hdr->Length)
+ return (-1);
+
+ switch (hdr->Type) {
+ case ACPI_IVRS_TYPE_HARDWARE1:
+ acpi_handle_ivrs_ivhd_10(addr, efrsup);
+ break;
+ case ACPI_IVRS_TYPE_HARDWARE2:
+ if (!efrsup)
+ printf("\t!! Found IVHD block 0x11 but !EFRsup\n");
+ acpi_handle_ivrs_ivhd_11(addr);
+ break;
+ case ACPI_IVRS_TYPE_HARDWARE3:
+ if (!efrsup)
+ printf("\t!! Found IVHD block 0x40 but !EFRsup\n");
+ acpi_handle_ivrs_ivhd_40(addr);
+ break;
+ case ACPI_IVRS_TYPE_MEMORY1:
+ case ACPI_IVRS_TYPE_MEMORY2:
+ case ACPI_IVRS_TYPE_MEMORY3:
+ acpi_handle_ivrs_ivmd(addr);
+ break;
+ default:
+ printf("\n");
+ printf("\tType=%d\n", hdr->Type);
+ printf("\tLength=%d\n", hdr->Length);
+ break;
+ }
+ return (hdr->Length);
+}
+
+#define ACPI_IVRS_DMAREMAP 0x00000002
+#define ACPI_IVRS_EFRSUP 0x00000001
+#define ACPI_IVRS_GVA_SIZE 0x000000e0
+
+static void
+acpi_handle_ivrs(ACPI_TABLE_HEADER *sdp)
+{
+ ACPI_TABLE_IVRS *ivrs;
+ char *cp;
+ int remaining, consumed;
+ bool efrsup;
+
+ printf(BEGIN_COMMENT);
+ acpi_print_sdt(sdp);
+ ivrs = (ACPI_TABLE_IVRS *)sdp;
+ efrsup = (ivrs->Info & ACPI_IVRS_EFRSUP) != 0;
+ printf("\tVAsize=%d PAsize=%d GVAsize=%d\n",
+ (ivrs->Info & ACPI_IVRS_VIRTUAL_SIZE) >> 15,
+ (ivrs->Info & ACPI_IVRS_PHYSICAL_SIZE) >> 8,
+ (ivrs->Info & ACPI_IVRS_GVA_SIZE) >> 5);
+ printf("\tATS_resp_res=%d DMA_preboot_remap=%d EFRsup=%d\n",
+ (ivrs->Info & ACPI_IVRS_ATS_RESERVED) != 0,
+ (ivrs->Info & ACPI_IVRS_DMAREMAP) != 0, efrsup);
+
+ remaining = sdp->Length - sizeof(ACPI_TABLE_IVRS);
+ while (remaining > 0) {
+ cp = (char *)sdp + sdp->Length - remaining;
+ consumed = acpi_handle_ivrs_blocks(cp, remaining, efrsup);
+ if (consumed <= 0)
+ break;
+ else
+ remaining -= consumed;
+ }
+
+ printf(END_COMMENT);
+}
+
+static void
acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp)
{
@@ -1578,12 +1962,11 @@ static void
acpi_print_nfit(ACPI_NFIT_HEADER *nfit)
{
char *uuidstr;
- uint32_t status;
+ uint32_t m, status;
ACPI_NFIT_SYSTEM_ADDRESS *sysaddr;
ACPI_NFIT_MEMORY_MAP *mmap;
ACPI_NFIT_INTERLEAVE *ileave;
- ACPI_NFIT_SMBIOS *smbios;
ACPI_NFIT_CONTROL_REGION *ctlreg;
ACPI_NFIT_DATA_REGION *datareg;
ACPI_NFIT_FLUSH_ADDRESS *fladdr;
@@ -1599,7 +1982,7 @@ acpi_print_nfit(ACPI_NFIT_HEADER *nfit)
printf("\tRangeIndex=%u\n", (u_int)sysaddr->RangeIndex);
printf("\tProximityDomain=%u\n",
(u_int)sysaddr->ProximityDomain);
- uuid_to_string((uuid_t *)(sysaddr->RangeGuid),
+ uuid_to_string((uuid_t *)(uintptr_t)(sysaddr->RangeGuid),
&uuidstr, &status);
if (status != uuid_s_ok)
errx(1, "uuid_to_string: status=%u", status);
@@ -1655,10 +2038,12 @@ acpi_print_nfit(ACPI_NFIT_HEADER *nfit)
(u_int)ileave->InterleaveIndex);
printf("\tLineCount=%u\n", (u_int)ileave->LineCount);
printf("\tLineSize=%u\n", (u_int)ileave->LineSize);
- /* XXX ileave->LineOffset[i] output is not supported */
+ for (m = 0; m < ileave->LineCount; m++) {
+ printf("\tLine%uOffset=0x%08x\n", (u_int)m + 1,
+ (u_int)ileave->LineOffset[m]);
+ }
break;
case ACPI_NFIT_TYPE_SMBIOS:
- smbios = (ACPI_NFIT_SMBIOS *)nfit;
/* XXX smbios->Data[x] output is not supported */
break;
case ACPI_NFIT_TYPE_CONTROL_REGION:
@@ -1716,7 +2101,10 @@ acpi_print_nfit(ACPI_NFIT_HEADER *nfit)
fladdr = (ACPI_NFIT_FLUSH_ADDRESS *)nfit;
printf("\tDeviceHandle=%u\n", (u_int)fladdr->DeviceHandle);
printf("\tHintCount=%u\n", (u_int)fladdr->HintCount);
- /* XXX fladdr->HintAddress[i] output is not supported */
+ for (m = 0; m < fladdr->HintCount; m++) {
+ printf("\tHintAddress%u=0x%016jx\n", (u_int)m + 1,
+ (uintmax_t)fladdr->HintAddress[m]);
+ }
break;
case ACPI_NFIT_TYPE_CAPABILITIES:
caps = (ACPI_NFIT_CAPABILITIES *)nfit;
@@ -2070,6 +2458,8 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp)
acpi_handle_tcpa(sdp);
else if (!memcmp(sdp->Signature, ACPI_SIG_DMAR, 4))
acpi_handle_dmar(sdp);
+ else if (!memcmp(sdp->Signature, ACPI_SIG_IVRS, 4))
+ acpi_handle_ivrs(sdp);
else if (!memcmp(sdp->Signature, ACPI_SIG_NFIT, 4))
acpi_handle_nfit(sdp);
else if (!memcmp(sdp->Signature, ACPI_SIG_WDDT, 4))
@@ -2229,7 +2619,7 @@ aml_disassemble(ACPI_TABLE_HEADER *rsdt, ACPI_TABLE_HEADER *dsdp)
goto out;
}
if (status != 0) {
- fprintf(stderr, "iast exit status = %d\n", status);
+ fprintf(stderr, "iasl exit status = %d\n", status);
}
/* Dump iasl's output to stdout */
diff --git a/usr.sbin/acpi/acpidump/acpi_user.c b/usr.sbin/acpi/acpidump/acpi_user.c
index afdba12ca7b8..4b9209e53507 100644
--- a/usr.sbin/acpi/acpidump/acpi_user.c
+++ b/usr.sbin/acpi/acpidump/acpi_user.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Doug Rabson
* Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@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$
*/
#include <sys/param.h>
diff --git a/usr.sbin/acpi/acpidump/acpidump.8 b/usr.sbin/acpi/acpidump/acpidump.8
index 438ef425b4df..dc8f724ea738 100644
--- a/usr.sbin/acpi/acpidump/acpidump.8
+++ b/usr.sbin/acpi/acpidump/acpidump.8
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 29, 2020
.Dt ACPIDUMP 8
.Os
diff --git a/usr.sbin/acpi/acpidump/acpidump.c b/usr.sbin/acpi/acpidump/acpidump.c
index bc541e117807..23978aca010b 100644
--- a/usr.sbin/acpi/acpidump/acpidump.c
+++ b/usr.sbin/acpi/acpidump/acpidump.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/acpi/acpidump/acpidump.h b/usr.sbin/acpi/acpidump/acpidump.h
index f717101aec63..80f86a748d76 100644
--- a/usr.sbin/acpi/acpidump/acpidump.h
+++ b/usr.sbin/acpi/acpidump/acpidump.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Doug Rabson
* Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
@@ -25,16 +25,17 @@
* 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 _ACPIDUMP_H_
#define _ACPIDUMP_H_
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/acconfig.h>
#include <contrib/dev/acpica/include/actbl1.h>
+#pragma GCC diagnostic pop
/* GAS address space ID constants. */
#define ACPI_GAS_MEMORY 0
diff --git a/usr.sbin/acpi/iasl/Makefile b/usr.sbin/acpi/iasl/Makefile
index 1807156475b1..79ea48dde8ef 100644
--- a/usr.sbin/acpi/iasl/Makefile
+++ b/usr.sbin/acpi/iasl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= iasl
@@ -66,12 +65,12 @@ SRCS+= tbdata.c tbfadt.c tbinstal.c tbprint.c tbutils.c \
# components/utilities
SRCS+= utaddress.c utalloc.c utascii.c utbuffer.c utcache.c \
- utcopy.c utdebug.c utdecode.c utdelete.c uterror.c \
- utexcep.c utglobal.c uthex.c utinit.c utlock.c utmath.c \
- utmisc.c utmutex.c utnonansi.c utobject.c utownerid.c \
- utpredef.c utresdecode.c utresrc.c utstate.c utstring.c \
- utstrsuppt.c utstrtoul64.c utuuid.c utxface.c \
- utxferror.c
+ utcksum.c utcopy.c utdebug.c utdecode.c utdelete.c \
+ uterror.c utexcep.c utglobal.c uthex.c utinit.c \
+ utlock.c utmath.c utmisc.c utmutex.c utnonansi.c \
+ utobject.c utownerid.c utpredef.c utresdecode.c \
+ utresrc.c utstate.c utstring.c utstrsuppt.c \
+ utstrtoul64.c utuuid.c utxface.c utxferror.c
# os_specific/service_layers
SRCS+= osunixxf.c
@@ -81,6 +80,8 @@ WARNS?= 2
MAN= iasl.8
CFLAGS+= -DACPI_ASL_COMPILER -I.
+CWARNFLAGS.aslrestype2s.c= ${NO_WUNUSED_BUT_SET_VARIABLE}
+CWARNFLAGS.dmextern.c= ${NO_WUNUSED_BUT_SET_VARIABLE}
LFLAGS= -i -s
DLFLAGS=-i
YFLAGS= -d
@@ -147,4 +148,8 @@ prparserparse.c prparserparse.h: prparser.y
prparser.y.h: prparserparse.h .NOMETA
ln -f ${.ALLSRC} ${.TARGET}
+# AcpiUtInitStackPtrTrace intentionally leaks a pointer to an
+# on-stack variable.
+CWARNFLAGS.utdebug.c+= ${NO_WDANGLING_POINTER}
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/acpi/iasl/Makefile.depend b/usr.sbin/acpi/iasl/Makefile.depend
index d084433f911c..c2fea3d32305 100644
--- a/usr.sbin/acpi/iasl/Makefile.depend
+++ b/usr.sbin/acpi/iasl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/acpi/iasl/iasl.8 b/usr.sbin/acpi/iasl/iasl.8
index bf16c8c0d948..3f096ebc0635 100644
--- a/usr.sbin/acpi/iasl/iasl.8
+++ b/usr.sbin/acpi/iasl/iasl.8
@@ -25,8 +25,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 May 20, 2008
.Dt IASL 8
.Os
diff --git a/usr.sbin/adduser/Makefile b/usr.sbin/adduser/Makefile
index 0ca2dae1e97b..2f18381073a0 100644
--- a/usr.sbin/adduser/Makefile
+++ b/usr.sbin/adduser/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SCRIPTS=adduser.sh rmuser.sh
MAN= adduser.conf.5 adduser.8 rmuser.8
diff --git a/usr.sbin/adduser/Makefile.depend b/usr.sbin/adduser/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/adduser/Makefile.depend
+++ b/usr.sbin/adduser/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/adduser/adduser.8 b/usr.sbin/adduser/adduser.8
index 6687ed0ef988..ed67e21f9430 100644
--- a/usr.sbin/adduser/adduser.8
+++ b/usr.sbin/adduser/adduser.8
@@ -24,9 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd September 15, 2012
+.Dd April 11, 2024
.Dt ADDUSER 8
.Os
.Sh NAME
@@ -34,7 +32,7 @@
.Nd command for adding new users
.Sh SYNOPSIS
.Nm
-.Op Fl CDENShq
+.Op Fl CDENSZhq
.Op Fl G Ar groups
.Op Fl L Ar login_class
.Op Fl M Ar mode
@@ -54,6 +52,10 @@ utility is a shell script, implemented around the
command, for adding new users.
It creates passwd/group entries, a home directory,
copies dotfiles and sends the new user a welcome message.
+On systems where the parent of home directory is a ZFS dataset,
+.Nm
+will create the home directory as a ZFS dataset by default,
+unless the system administrator specified otherwise.
It supports two modes of operation.
It may be used interactively
at the command line to add one user at a time, or it may be directed
@@ -297,6 +299,8 @@ In addition, it will be available for inclusion in the message file in the
.Va randompass
variable.
.El
+.It Fl Z
+Do not attempt to create ZFS home dataset.
.El
.Sh FORMAT
When the
diff --git a/usr.sbin/adduser/adduser.conf.5 b/usr.sbin/adduser/adduser.conf.5
index af9fe22cfb3a..09b80f2df021 100644
--- a/usr.sbin/adduser/adduser.conf.5
+++ b/usr.sbin/adduser/adduser.conf.5
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 12, 2007
.Dt ADDUSER.CONF 5
.Os
@@ -173,6 +171,8 @@ The default information to be held in the GECOS field of
.It Va uidstart
The default user ID setting.
This must be a number above 1000 and fewer than 65534.
+.It Va Zflag
+Do not attempt to create ZFS home dataset.
.El
.Sh EXAMPLES
The following is an example
diff --git a/usr.sbin/adduser/adduser.sh b/usr.sbin/adduser/adduser.sh
index 91a1b4b4cf01..0d5a628f8f33 100644
--- a/usr.sbin/adduser/adduser.sh
+++ b/usr.sbin/adduser/adduser.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2002-2004 Michael Telahun Makonnen. All rights reserved.
#
@@ -26,7 +26,6 @@
#
# Email: Mike Makonnen <mtm@FreeBSD.Org>
#
-# $FreeBSD$
#
# err msg
@@ -85,6 +84,7 @@ show_usage() {
echo " -L login class of the user"
echo " -M file permission for home directory"
echo " -N do not read configuration file"
+ echo " -Z do not attempt to create ZFS home dataset"
echo " -S a nonexistent shell is not an error"
echo " -d home directory"
echo " -f file from which input will be received"
@@ -284,6 +284,22 @@ add_user() {
;;
esac
+ # create ZFS dataset before home directory is created with pw
+ if [ "${Zcreate}" = "yes" ]; then
+ if [ "${Zencrypt}" = "yes" ]; then
+ echo "Enter encryption keyphrase for ZFS dataset (${zhome}):"
+ fi
+ if [ -n "$BSDINSTALL_CHROOT" ]; then
+ create_zfs_chrooted_dataset
+ else
+ create_zfs_dataset
+ if [ "$?" -ne 0 ]; then
+ err "There was an error adding user ($username)."
+ return 1
+ fi
+ fi
+ fi
+
_pwcmd="$_upasswd ${PWCMD} useradd $_uid $_name $_group $_grouplist $_comment"
_pwcmd="$_pwcmd $_shell $_class $_home $_dotdir $_passwdmethod $_passwd"
_pwcmd="$_pwcmd $_expire $_pwexpire"
@@ -307,6 +323,14 @@ add_user() {
fi
fi
+ # give newly created user permissions to their home zfs dataset
+ if [ "${Zcreate}" = "yes" ]; then
+ set_zfs_perms
+ if [ -n "$BSDINSTALL_CHROOT" ]; then
+ umount_legacy_zfs
+ fi
+ fi
+
_line=
_owner=
_perms=
@@ -480,6 +504,26 @@ get_homeperm() {
fi
}
+# get_zfs_home
+# Determine if homeprefix is located on a ZFS filesystem and if
+# so, enable ZFS home dataset creation.
+#
+get_zfs_home() {
+ # check if zfs kernel module is loaded before attempting to run zfs to
+ # prevent loading the kernel module on systems that don't use ZFS
+ if ! "$KLDSTATCMD" -q -m zfs; then
+ Zcreate="no"
+ return
+ fi
+ zfs_homeprefix=`${ZFSCMD} list -Ho name "${homeprefix}" 2>/dev/null`
+ if [ "$?" -ne 0 ]; then
+ Zcreate="no"
+ elif [ -z "${zfs_homeprefix}" ]; then
+ Zcreate="no"
+ fi
+ zhome="${zfs_homeprefix}/${username}"
+}
+
# get_uid
# Reads a numeric userid in an interactive or batch session. Automatically
# allocates one if it is not specified.
@@ -614,6 +658,81 @@ get_password() {
fi
}
+# get_zfs_encryption
+# Ask user if they want to enable encryption on their ZFS home dataset.
+#
+get_zfs_encryption() {
+ _input=
+ _prompt="Enable ZFS encryption? (yes/no) [${Zencrypt}]: "
+ while : ; do
+ echo -n "$_prompt"
+ read _input
+
+ [ -z "$_input" ] && _input=$Zencrypt
+ case $_input in
+ [Nn][Oo]|[Nn])
+ Zencrypt="no"
+ break
+ ;;
+ [Yy][Ee][Ss]|[Yy][Ee]|[Yy])
+ Zencrypt="yes"
+ break
+ ;;
+ *)
+ # invalid answer; repeat loop
+ continue
+ ;;
+ esac
+ done
+
+ if [ "${Zencrypt}" = "yes" ]; then
+ zfsopt="-o encryption=on -o keylocation=prompt -o keyformat=passphrase"
+ fi
+}
+
+# create_zfs_chrooted_dataset
+# Create ZFS dataset owned by the user that was just added within a bsdinstall chroot
+#
+create_zfs_chrooted_dataset() {
+ if ! ${ZFSCMD} create -u ${zfsopt} "${zhome}"; then
+ err "There was an error creating ZFS dataset (${zhome})."
+ return 1
+ fi
+ ${ZFSCMD} set mountpoint=legacy "${zhome}"
+ ${MKDIRCMD} -p "${uhome}"
+ ${MOUNTCMD} -t zfs "${zhome}" "${uhome}"
+}
+
+# umount_legacy_zfs
+# Unmount ZFS home directory created as a legacy mount and switch inheritance
+#
+umount_legacy_zfs() {
+ ${UMOUNTCMD} "${uhome}"
+ ${ZFSCMD} inherit mountpoint "${zhome}"
+}
+
+# create_zfs_dataset
+# Create ZFS dataset owned by the user that was just added.
+#
+create_zfs_dataset() {
+ if ! ${ZFSCMD} create ${zfsopt} "${zhome}"; then
+ err "There was an error creating ZFS dataset (${zhome})."
+ return 1
+ else
+ info "Successfully created ZFS dataset (${zhome})."
+ fi
+}
+
+# set_zfs_perms
+# Give new user ownership of newly created zfs dataset.
+#
+set_zfs_perms() {
+ if ! ${ZFSCMD} allow "${username}" create,destroy,mount,snapshot "${zhome}"; then
+ err "There was an error setting permissions on ZFS dataset (${zhome})."
+ return 1
+ fi
+}
+
# input_from_file
# Reads a line of account information from standard input and
# adds it to the user database.
@@ -633,6 +752,7 @@ input_from_file() {
get_class
get_shell
get_homedir
+ get_zfs_home
get_homeperm
get_password
get_expire_dates
@@ -657,6 +777,8 @@ input_interactive() {
_usepass="yes"
_logingroup_ok="no"
_groups_ok="no"
+ _all_ok="yes"
+ _another_user="no"
case $passwdtype in
none)
_emptypass="yes"
@@ -703,6 +825,8 @@ input_interactive() {
get_shell
get_homedir
get_homeperm
+ get_zfs_home
+ [ "$Zcreate" = "yes" ] && get_zfs_encryption
while : ; do
echo -n "Use password-based authentication? [$_usepass]: "
@@ -786,12 +910,12 @@ input_interactive() {
esac
break
done
-
+
# Display the information we have so far and prompt to
# commit it.
#
_disable=${disableflag:-"no"}
- [ -z "$configflag" ] && printf "%-10s : %s\n" Username $username
+ [ -z "$configflag" ] && printf "%-11s : %s\n" Username $username
case $passwdtype in
yes)
_pass='*****'
@@ -806,19 +930,24 @@ input_interactive() {
_pass='<random>'
;;
esac
- [ -z "$configflag" ] && printf "%-10s : %s\n" "Password" "$_pass"
- [ -n "$configflag" ] && printf "%-10s : %s\n" "Pass Type" "$passwdtype"
- [ -z "$configflag" ] && printf "%-10s : %s\n" "Full Name" "$ugecos"
- [ -z "$configflag" ] && printf "%-10s : %s\n" "Uid" "$uuid"
- printf "%-10s : %s\n" "Class" "$uclass"
- printf "%-10s : %s %s\n" "Groups" "${ulogingroup:-$username}" "$ugroups"
- printf "%-10s : %s\n" "Home" "$uhome"
- printf "%-10s : %s\n" "Home Mode" "$uhomeperm"
- printf "%-10s : %s\n" "Shell" "$ushell"
- printf "%-10s : %s\n" "Locked" "$_disable"
+ [ -z "$configflag" ] && printf "%-11s : %s\n" "Password" "$_pass"
+ [ -n "$configflag" ] && printf "%-11s : %s\n" "Pass Type" "$passwdtype"
+ [ -z "$configflag" ] && printf "%-11s : %s\n" "Full Name" "$ugecos"
+ [ -z "$configflag" ] && printf "%-11s : %s\n" "Uid" "$uuid"
+ [ "$Zcreate" = "yes" -a -z "$configflag" ] && printf "%-11s : %s\n" "ZFS dataset" "${zhome}"
+ [ "$Zencrypt" = "yes" -a -z "$configflag" ] && printf "%-11s : %s\n" "Encrypted" "${Zencrypt}"
+ printf "%-11s : %s\n" "Class" "$uclass"
+ printf "%-11s : %s %s\n" "Groups" "${ulogingroup:-$username}" "$ugroups"
+ printf "%-11s : %s\n" "Home" "$uhome"
+ printf "%-11s : %s\n" "Home Mode" "$uhomeperm"
+ printf "%-11s : %s\n" "Shell" "$ushell"
+ printf "%-11s : %s\n" "Locked" "$_disable"
while : ; do
- echo -n "OK? (yes/no): "
+ echo -n "OK? (yes/no) [$_all_ok]: "
read _input
+ if [ -z "$_input" ]; then
+ _input=$_all_ok
+ fi
case $_input in
[Nn][Oo]|[Nn])
return 1
@@ -848,6 +977,11 @@ NOLOGIN="nologin"
NOLOGIN_PATH="/usr/sbin/nologin"
GREPCMD="/usr/bin/grep"
DATECMD="/bin/date"
+MKDIRCMD="/bin/mkdir"
+MOUNTCMD="/sbin/mount"
+UMOUNTCMD="/sbin/umount"
+ZFSCMD="/sbin/zfs"
+KLDSTATCMD="/sbin/kldstat"
# Set default values
#
@@ -876,6 +1010,7 @@ infile=
disableflag=
Dflag=
Sflag=
+Zcreate="yes"
readconfig="yes"
homeprefix="/home"
randompass=
@@ -886,6 +1021,8 @@ defaultLgroup=
defaultgroups=
defaultshell="${DEFAULTSHELL}"
defaultHomePerm=
+zfsopt=
+Zencrypt="no"
# Make sure the user running this program is root. This isn't a security
# measure as much as it is a useful method of reminding the user to
@@ -1010,6 +1147,10 @@ for _switch ; do
uidstart=$2
shift; shift
;;
+ -Z)
+ Zcreate="no"
+ shift
+ ;;
esac
done
@@ -1030,11 +1171,14 @@ else
input_interactive
while : ; do
if [ -z "$configflag" ]; then
- echo -n "Add another user? (yes/no): "
+ echo -n "Add another user? (yes/no) [$_another_user]: "
else
- echo -n "Re-edit the default configuration? (yes/no): "
+ echo -n "Re-edit the default configuration? (yes/no) [$_another_user]: "
fi
read _input
+ if [ -z "$_input" ]; then
+ _input=$_another_user
+ fi
case $_input in
[Yy][Ee][Ss]|[Yy][Ee]|[Yy])
uidstart=`get_nextuid $uidstart`
diff --git a/usr.sbin/adduser/rmuser.8 b/usr.sbin/adduser/rmuser.8
index e24d5eedf868..e92392a82f29 100644
--- a/usr.sbin/adduser/rmuser.8
+++ b/usr.sbin/adduser/rmuser.8
@@ -24,8 +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.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 10, 2002
.Dt RMUSER 8
.Os
diff --git a/usr.sbin/adduser/rmuser.sh b/usr.sbin/adduser/rmuser.sh
index abaf004e7f66..4c1e4049763a 100644
--- a/usr.sbin/adduser/rmuser.sh
+++ b/usr.sbin/adduser/rmuser.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2002, 2003 Michael Telahun Makonnen. All rights reserved.
#
@@ -26,7 +26,6 @@
#
# Email: Mike Makonnen <mtm@FreeBSD.Org>
#
-# $FreeBSD$
#
ATJOBDIR="/var/at/jobs"
diff --git a/usr.sbin/apm/Makefile b/usr.sbin/apm/Makefile
index f52453c62522..c18a841b9c16 100644
--- a/usr.sbin/apm/Makefile
+++ b/usr.sbin/apm/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= apm
MAN= apm.8
diff --git a/usr.sbin/apm/Makefile.depend b/usr.sbin/apm/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/apm/Makefile.depend
+++ b/usr.sbin/apm/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/apm/apm.8 b/usr.sbin/apm/apm.8
index 96eb9732b7e6..d6ede22066da 100644
--- a/usr.sbin/apm/apm.8
+++ b/usr.sbin/apm/apm.8
@@ -9,8 +9,6 @@
.\" the author assume any responsibility for damages incurred with its
.\" use.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 22, 2009
.Dt APM 8 i386
.Os
diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c
index 05652da3f1c1..01e75eb1f8b1 100644
--- a/usr.sbin/apm/apm.c
+++ b/usr.sbin/apm/apm.c
@@ -14,8 +14,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/types.h>
diff --git a/usr.sbin/apmd/Makefile b/usr.sbin/apmd/Makefile
index 5bc28dd59835..57c07bff721d 100644
--- a/usr.sbin/apmd/Makefile
+++ b/usr.sbin/apmd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
CONFS= apmd.conf
PROG= apmd
diff --git a/usr.sbin/apmd/Makefile.depend b/usr.sbin/apmd/Makefile.depend
index c729e17c52db..77f8f90c31c3 100644
--- a/usr.sbin/apmd/Makefile.depend
+++ b/usr.sbin/apmd/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/apmd/README b/usr.sbin/apmd/README
index dd0a03a2989a..a8ceef164560 100644
--- a/usr.sbin/apmd/README
+++ b/usr.sbin/apmd/README
@@ -209,5 +209,3 @@ June 1, 1999
Created by: iwasaki@FreeBSD.org
Edited by: jkh@FreeBSD.org
nick@foobar.org
-
-$FreeBSD$
diff --git a/usr.sbin/apmd/apmd.8 b/usr.sbin/apmd/apmd.8
index afecd47a3759..94640046bb74 100644
--- a/usr.sbin/apmd/apmd.8
+++ b/usr.sbin/apmd/apmd.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)apmd.8 1.1 (FreeBSD) 6/28/99
-.\" $FreeBSD$
-.\"
.Dd June 28, 1999
.Dt APMD 8 i386
.Os
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c
index 1d2a964927b9..0a3fcf6315e0 100644
--- a/usr.sbin/apmd/apmd.c
+++ b/usr.sbin/apmd/apmd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* APM (Advanced Power Management) Event Dispatcher
*
@@ -29,11 +29,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/types.h>
#include <assert.h>
#include <bitstring.h>
diff --git a/usr.sbin/apmd/apmd.conf b/usr.sbin/apmd/apmd.conf
index be4a6c3ddd4c..28bb16de46e2 100644
--- a/usr.sbin/apmd/apmd.conf
+++ b/usr.sbin/apmd/apmd.conf
@@ -1,6 +1,5 @@
# apmd Configuration File
#
-# $FreeBSD$
#
apm_event SUSPENDREQ {
diff --git a/usr.sbin/apmd/apmd.h b/usr.sbin/apmd/apmd.h
index e56005e3c0f9..a6f3350f7df7 100644
--- a/usr.sbin/apmd/apmd.h
+++ b/usr.sbin/apmd/apmd.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* APM (Advanced Power Management) Event Dispatcher
*
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#define APMD_CONFIGFILE "/etc/apmd.conf"
diff --git a/usr.sbin/apmd/apmdlex.l b/usr.sbin/apmd/apmdlex.l
index 67cb52d5c309..4bee0b3e24fd 100644
--- a/usr.sbin/apmd/apmdlex.l
+++ b/usr.sbin/apmd/apmdlex.l
@@ -1,6 +1,6 @@
%{
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* APM (Advanced Power Management) Event Dispatcher
*
@@ -28,8 +28,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/types.h>
diff --git a/usr.sbin/apmd/apmdparse.y b/usr.sbin/apmd/apmdparse.y
index 6f135934388d..fd8fca365fc9 100644
--- a/usr.sbin/apmd/apmdparse.y
+++ b/usr.sbin/apmd/apmdparse.y
@@ -1,6 +1,6 @@
%{
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* APM (Advanced Power Management) Event Dispatcher
*
@@ -28,8 +28,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/types.h>
diff --git a/usr.sbin/apmd/contrib/pccardq.c b/usr.sbin/apmd/contrib/pccardq.c
index aebd1d544470..acdeaaecb261 100644
--- a/usr.sbin/apmd/contrib/pccardq.c
+++ b/usr.sbin/apmd/contrib/pccardq.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#include <err.h>
#include <errno.h>
diff --git a/usr.sbin/arp/Makefile b/usr.sbin/arp/Makefile
index b6ff7a3e253c..0730be75b894 100644
--- a/usr.sbin/arp/Makefile
+++ b/usr.sbin/arp/Makefile
@@ -1,9 +1,18 @@
-# @(#)Makefile 8.2 (Berkeley) 4/18/94
-# $FreeBSD$
+
+.include <src.opts.mk>
PROG= arp
MAN= arp.4 arp.8
+
+SRCS= arp.c
+
+.if ${MK_NETLINK_SUPPORT} != "no"
+SRCS+= arp_netlink.c
+.else
+CFLAGS+=-DWITHOUT_NETLINK
+.endif
+
LIBADD= xo
WARNS?= 3
diff --git a/usr.sbin/arp/Makefile.depend b/usr.sbin/arp/Makefile.depend
index a0d0ea100062..11a91dcad4b2 100644
--- a/usr.sbin/arp/Makefile.depend
+++ b/usr.sbin/arp/Makefile.depend
@@ -1,16 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libutil \
- lib/libxo \
+ lib/libxo/libxo \
.include <dirdeps.mk>
diff --git a/usr.sbin/arp/arp.4 b/usr.sbin/arp/arp.4
index c9c9002cf908..244f784dd028 100644
--- a/usr.sbin/arp/arp.4
+++ b/usr.sbin/arp/arp.4
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)arp4.4 6.5 (Berkeley) 4/18/94
-.\" $FreeBSD$
-.\"
.Dd October 7, 2016
.Dt ARP 4
.Os
diff --git a/usr.sbin/arp/arp.8 b/usr.sbin/arp/arp.8
index 443d28045d1b..e2b81c6a1bb9 100644
--- a/usr.sbin/arp/arp.8
+++ b/usr.sbin/arp/arp.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)arp.8 8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
-.\"
.Dd July 13, 2020
.Dt ARP 8
.Os
diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c
index f018baa2679e..e5b94ca053e1 100644
--- a/usr.sbin/arp/arp.c
+++ b/usr.sbin/arp/arp.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char const copyright[] =
-"@(#) Copyright (c) 1984, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char const sccsid[] = "@(#)from: arp.c 8.2 (Berkeley) 1/2/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* arp - display, set, and delete arp table entries
*/
@@ -74,39 +60,36 @@ __FBSDID("$FreeBSD$");
#include <netdb.h>
#include <nlist.h>
#include <paths.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
+#include <ifaddrs.h>
#include <libxo/xo.h>
+#include "arp.h"
typedef void (action_fn)(struct sockaddr_dl *sdl, struct sockaddr_in *s_in,
struct rt_msghdr *rtm);
-
-static int search(u_long addr, action_fn *action);
-static action_fn print_entry;
-static action_fn nuke_entry;
+static void nuke_entries(uint32_t ifindex, struct in_addr addr);
+static int print_entries(uint32_t ifindex, struct in_addr addr);
static int delete(char *host);
-static void usage(void);
+static void usage(void) __dead2;
static int set(int argc, char **argv);
static int get(char *host);
static int file(char *name);
static struct rt_msghdr *rtmsg(int cmd,
struct sockaddr_in *dst, struct sockaddr_dl *sdl);
static int get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr);
-static struct sockaddr_in *getaddr(char *host);
-static int valid_type(int type);
-
-static int nflag; /* no reverse dns lookups */
-static char *rifname;
-
-static time_t expire_time;
-static int flags, doing_proxy;
+static int set_rtsock(struct sockaddr_in *dst, struct sockaddr_dl *sdl_m,
+ char *host);
struct if_nameindex *ifnameindex;
+struct arp_opts opts = {};
+
/* which function we're supposed to do */
#define F_GET 1
#define F_SET 2
@@ -123,7 +106,6 @@ main(int argc, char *argv[])
{
int ch, func = 0;
int rtn = 0;
- int aflag = 0; /* do it for all entries */
argc = xo_parse_args(argc, argv);
if (argc < 0)
@@ -132,13 +114,13 @@ main(int argc, char *argv[])
while ((ch = getopt(argc, argv, "andfsSi:")) != -1)
switch(ch) {
case 'a':
- aflag = 1;
+ opts.aflag = true;
break;
case 'd':
SETFUNC(F_DELETE);
break;
case 'n':
- nflag = 1;
+ opts.nflag = true;
break;
case 'S':
SETFUNC(F_REPLACE);
@@ -150,7 +132,7 @@ main(int argc, char *argv[])
SETFUNC(F_FILESET);
break;
case 'i':
- rifname = optarg;
+ opts.rifname = optarg;
break;
case '?':
default:
@@ -161,20 +143,20 @@ main(int argc, char *argv[])
if (!func)
func = F_GET;
- if (rifname) {
- if (func != F_GET && !(func == F_DELETE && aflag))
+ if (opts.rifname) {
+ if (func != F_GET && !(func == F_DELETE && opts.aflag))
xo_errx(1, "-i not applicable to this operation");
- if (if_nametoindex(rifname) == 0) {
+ if ((opts.rifindex = if_nametoindex(opts.rifname)) == 0) {
if (errno == ENXIO)
xo_errx(1, "interface %s does not exist",
- rifname);
+ opts.rifname);
else
- xo_err(1, "if_nametoindex(%s)", rifname);
+ xo_err(1, "if_nametoindex(%s)", opts.rifname);
}
}
switch (func) {
case F_GET:
- if (aflag) {
+ if (opts.aflag) {
if (argc != 0)
usage();
@@ -182,7 +164,8 @@ main(int argc, char *argv[])
xo_open_container("arp");
xo_open_list("arp-cache");
- search(0, print_entry);
+ struct in_addr all_addrs = {};
+ print_entries(opts.rifindex, all_addrs);
xo_close_list("arp-cache");
xo_close_container("arp");
@@ -202,10 +185,11 @@ main(int argc, char *argv[])
rtn = set(argc, argv) ? 1 : 0;
break;
case F_DELETE:
- if (aflag) {
+ if (opts.aflag) {
if (argc != 0)
usage();
- search(0, nuke_entry);
+ struct in_addr all_addrs = {};
+ nuke_entries(0, all_addrs);
} else {
if (argc != 1)
usage();
@@ -268,7 +252,7 @@ file(char *name)
* the address of the host and returns a pointer to the
* structure.
*/
-static struct sockaddr_in *
+struct sockaddr_in *
getaddr(char *host)
{
struct hostent *hp;
@@ -289,10 +273,11 @@ getaddr(char *host)
return (&reply);
}
+int valid_type(int type);
/*
* Returns true if the type is a valid one for ARP.
*/
-static int
+int
valid_type(int type)
{
@@ -317,10 +302,7 @@ valid_type(int type)
static int
set(int argc, char **argv)
{
- struct sockaddr_in *addr;
struct sockaddr_in *dst; /* what are we looking for */
- struct sockaddr_dl *sdl;
- struct rt_msghdr *rtm;
struct ether_addr *ea;
char *host = argv[0], *eaddr = argv[1];
struct sockaddr_dl sdl_m;
@@ -335,21 +317,17 @@ set(int argc, char **argv)
dst = getaddr(host);
if (dst == NULL)
return (1);
- doing_proxy = flags = expire_time = 0;
while (argc-- > 0) {
if (strcmp(argv[0], "temp") == 0) {
- struct timespec tp;
int max_age;
size_t len = sizeof(max_age);
- clock_gettime(CLOCK_MONOTONIC, &tp);
if (sysctlbyname("net.link.ether.inet.max_age",
&max_age, &len, NULL, 0) != 0)
xo_err(1, "sysctlbyname");
- expire_time = tp.tv_sec + max_age;
+ opts.expire_time = max_age;
} else if (strcmp(argv[0], "pub") == 0) {
- flags |= RTF_ANNOUNCE;
- doing_proxy = 1;
+ opts.flags |= RTF_ANNOUNCE;
if (argc && strcmp(argv[1], "only") == 0) {
/*
* Compatibility: in pre FreeBSD 8 times
@@ -360,17 +338,17 @@ set(int argc, char **argv)
argc--; argv++;
}
} else if (strcmp(argv[0], "blackhole") == 0) {
- if (flags & RTF_REJECT) {
+ if (opts.flags & RTF_REJECT) {
xo_errx(1, "Choose one of blackhole or reject, "
"not both.");
}
- flags |= RTF_BLACKHOLE;
+ opts.flags |= RTF_BLACKHOLE;
} else if (strcmp(argv[0], "reject") == 0) {
- if (flags & RTF_BLACKHOLE) {
+ if (opts.flags & RTF_BLACKHOLE) {
xo_errx(1, "Choose one of blackhole or reject, "
"not both.");
}
- flags |= RTF_REJECT;
+ opts.flags |= RTF_REJECT;
} else {
xo_warnx("Invalid parameter '%s'", argv[0]);
usage();
@@ -378,7 +356,7 @@ set(int argc, char **argv)
argv++;
}
ea = (struct ether_addr *)LLADDR(&sdl_m);
- if (doing_proxy && !strcmp(eaddr, "auto")) {
+ if ((opts.flags & RTF_ANNOUNCE) && !strcmp(eaddr, "auto")) {
if (!get_ether_addr(dst->sin_addr.s_addr, ea)) {
xo_warnx("no interface found for %s",
inet_ntoa(dst->sin_addr));
@@ -396,6 +374,20 @@ set(int argc, char **argv)
sdl_m.sdl_alen = ETHER_ADDR_LEN;
}
}
+#ifndef WITHOUT_NETLINK
+ return (set_nl(0, dst, &sdl_m, host));
+#else
+ return (set_rtsock(dst, &sdl_m, host));
+#endif
+}
+
+#ifdef WITHOUT_NETLINK
+static int
+set_rtsock(struct sockaddr_in *dst, struct sockaddr_dl *sdl_m, char *host)
+{
+ struct sockaddr_in *addr;
+ struct sockaddr_dl *sdl;
+ struct rt_msghdr *rtm;
/*
* In the case a proxy-arp entry is being added for
@@ -419,10 +411,11 @@ set(int argc, char **argv)
xo_warnx("cannot intuit interface index and type for %s", host);
return (1);
}
- sdl_m.sdl_type = sdl->sdl_type;
- sdl_m.sdl_index = sdl->sdl_index;
- return (rtmsg(RTM_ADD, dst, &sdl_m) == NULL);
+ sdl_m->sdl_type = sdl->sdl_type;
+ sdl_m->sdl_index = sdl->sdl_index;
+ return (rtmsg(RTM_ADD, dst, sdl_m) == NULL);
}
+#endif
/*
* Display an individual arp entry
@@ -441,13 +434,13 @@ get(char *host)
xo_open_container("arp");
xo_open_list("arp-cache");
- found = search(addr->sin_addr.s_addr, print_entry);
+ found = print_entries(opts.rifindex, addr->sin_addr);
if (found == 0) {
xo_emit("{d:hostname/%s} ({d:ip-address/%s}) -- no entry",
host, inet_ntoa(addr->sin_addr));
- if (rifname)
- xo_emit(" on {d:interface/%s}", rifname);
+ if (opts.rifname)
+ xo_emit(" on {d:interface/%s}", opts.rifname);
xo_emit("\n");
}
@@ -461,8 +454,9 @@ get(char *host)
/*
* Delete an arp entry
*/
+#ifdef WITHOUT_NETLINK
static int
-delete(char *host)
+delete_rtsock(char *host)
{
struct sockaddr_in *addr, *dst;
struct rt_msghdr *rtm;
@@ -475,7 +469,7 @@ delete(char *host)
/*
* Perform a regular entry delete first.
*/
- flags &= ~RTF_ANNOUNCE;
+ opts.flags &= ~RTF_ANNOUNCE;
for (;;) { /* try twice */
rtm = rtmsg(RTM_GET, dst, NULL);
@@ -505,12 +499,12 @@ delete(char *host)
* Regular entry delete failed, now check if there
* is a proxy-arp entry to remove.
*/
- if (flags & RTF_ANNOUNCE) {
+ if (opts.flags & RTF_ANNOUNCE) {
xo_warnx("delete: cannot locate %s", host);
return (1);
}
- flags |= RTF_ANNOUNCE;
+ opts.flags |= RTF_ANNOUNCE;
}
rtm->rtm_flags |= RTF_LLDATA;
if (rtmsg(RTM_DELETE, dst, NULL) != NULL) {
@@ -519,6 +513,17 @@ delete(char *host)
}
return (1);
}
+#endif
+
+static int
+delete(char *host)
+{
+#ifdef WITHOUT_NETLINK
+ return (delete_rtsock(host));
+#else
+ return (delete_nl(0, host));
+#endif
+}
/*
@@ -533,7 +538,6 @@ search(u_long addr, action_fn *action)
struct rt_msghdr *rtm;
struct sockaddr_in *sin2;
struct sockaddr_dl *sdl;
- char ifname[IF_NAMESIZE];
int st, found_entry = 0;
mib[0] = CTL_NET;
@@ -567,14 +571,13 @@ search(u_long addr, action_fn *action)
rtm = (struct rt_msghdr *)next;
sin2 = (struct sockaddr_in *)(rtm + 1);
sdl = (struct sockaddr_dl *)((char *)sin2 + SA_SIZE(sin2));
- if (rifname && if_indextoname(sdl->sdl_index, ifname) &&
- strcmp(ifname, rifname))
+ if (opts.rifindex &&
+ (opts.rifindex != sdl->sdl_index))
continue;
- if (addr) {
- if (addr != sin2->sin_addr.s_addr)
- continue;
- found_entry = 1;
- }
+ if (addr &&
+ (addr != sin2->sin_addr.s_addr))
+ continue;
+ found_entry = 1;
(*action)(sdl, sin2, rtm);
}
free(buf);
@@ -599,7 +602,7 @@ print_entry(struct sockaddr_dl *sdl,
xo_open_instance("arp-cache");
- if (nflag == 0)
+ if (!opts.nflag)
hp = gethostbyaddr((caddr_t)&(addr->sin_addr),
sizeof addr->sin_addr, AF_INET);
else
@@ -609,7 +612,7 @@ print_entry(struct sockaddr_dl *sdl,
else {
host = "?";
if (h_errno == TRY_AGAIN)
- nflag = 1;
+ opts.nflag = true;
}
xo_emit("{:hostname/%s} ({:ip-address/%s}) at ", host,
inet_ntoa(addr->sin_addr));
@@ -639,6 +642,8 @@ print_entry(struct sockaddr_dl *sdl,
xo_emit("{d:/ permanent}{en:permanent/true}");
else {
static struct timespec tp;
+ time_t expire_time = 0;
+
if (tp.tv_sec == 0)
clock_gettime(CLOCK_MONOTONIC, &tp);
if ((expire_time = rtm->rtm_rmx.rmx_expire - tp.tv_sec) > 0)
@@ -682,6 +687,17 @@ print_entry(struct sockaddr_dl *sdl,
xo_close_instance("arp-cache");
}
+static int
+print_entries(uint32_t ifindex, struct in_addr addr)
+{
+#ifndef WITHOUT_NETLINK
+ return (print_entries_nl(ifindex, addr));
+#else
+ return (search(addr.s_addr, print_entry));
+#endif
+}
+
+
/*
* Nuke an arp entry
*/
@@ -699,6 +715,12 @@ nuke_entry(struct sockaddr_dl *sdl __unused,
}
static void
+nuke_entries(uint32_t ifindex, struct in_addr addr)
+{
+ search(addr.s_addr, nuke_entry);
+}
+
+static void
usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
@@ -744,7 +766,7 @@ rtmsg(int cmd, struct sockaddr_in *dst, struct sockaddr_dl *sdl)
if (cmd == RTM_DELETE)
goto doit;
bzero((char *)&m_rtmsg, sizeof(m_rtmsg));
- rtm->rtm_flags = flags;
+ rtm->rtm_flags = opts.flags;
rtm->rtm_version = RTM_VERSION;
switch (cmd) {
@@ -752,7 +774,12 @@ rtmsg(int cmd, struct sockaddr_in *dst, struct sockaddr_dl *sdl)
xo_errx(1, "internal wrong cmd");
case RTM_ADD:
rtm->rtm_addrs |= RTA_GATEWAY;
- rtm->rtm_rmx.rmx_expire = expire_time;
+ if (opts.expire_time != 0) {
+ struct timespec tp;
+
+ clock_gettime(CLOCK_MONOTONIC, &tp);
+ rtm->rtm_rmx.rmx_expire = opts.expire_time + tp.tv_sec;
+ }
rtm->rtm_inits = RTV_EXPIRE;
rtm->rtm_flags |= (RTF_HOST | RTF_STATIC | RTF_LLDATA);
/* FALLTHROUGH */
@@ -792,92 +819,72 @@ doit:
/*
* get_ether_addr - get the hardware address of an interface on the
- * the same subnet as ipaddr.
+ * same subnet as ipaddr.
*/
-#define MAX_IFS 32
-
static int
get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr)
{
- struct ifreq *ifr, *ifend, *ifp;
+ struct ifaddrs *ifa, *ifd, *ifas = NULL;
in_addr_t ina, mask;
struct sockaddr_dl *dla;
- struct ifreq ifreq;
- struct ifconf ifc;
- struct ifreq ifs[MAX_IFS];
- int sock;
int retval = 0;
- sock = socket(AF_INET, SOCK_DGRAM, 0);
- if (sock < 0)
- xo_err(1, "socket");
-
- ifc.ifc_len = sizeof(ifs);
- ifc.ifc_req = ifs;
- if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) {
- xo_warnx("ioctl(SIOCGIFCONF)");
- goto done;
- }
-
-#define NEXTIFR(i) \
- ((struct ifreq *)((char *)&(i)->ifr_addr \
- + MAX((i)->ifr_addr.sa_len, sizeof((i)->ifr_addr))) )
-
/*
* Scan through looking for an interface with an Internet
* address on the same subnet as `ipaddr'.
*/
- ifend = (struct ifreq *)(ifc.ifc_buf + ifc.ifc_len);
- for (ifr = ifc.ifc_req; ifr < ifend; ifr = NEXTIFR(ifr) ) {
- if (ifr->ifr_addr.sa_family != AF_INET)
+ if (getifaddrs(&ifas) < 0) {
+ xo_warnx("getifaddrs");
+ goto done;
+ }
+
+ for (ifa = ifas; ifa != NULL; ifa = ifa->ifa_next) {
+ if (ifa->ifa_addr == NULL || ifa->ifa_netmask == NULL)
+ continue;
+ if (ifa->ifa_addr->sa_family != AF_INET)
continue;
- strncpy(ifreq.ifr_name, ifr->ifr_name,
- sizeof(ifreq.ifr_name));
- ifreq.ifr_addr = ifr->ifr_addr;
/*
* Check that the interface is up,
* and not point-to-point or loopback.
*/
- if (ioctl(sock, SIOCGIFFLAGS, &ifreq) < 0)
- continue;
- if ((ifreq.ifr_flags &
+ if ((ifa->ifa_flags &
(IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|
IFF_LOOPBACK|IFF_NOARP)) != (IFF_UP|IFF_BROADCAST))
continue;
/* Get its netmask and check that it's on the right subnet. */
- if (ioctl(sock, SIOCGIFNETMASK, &ifreq) < 0)
- continue;
mask = ((struct sockaddr_in *)
- &ifreq.ifr_addr)->sin_addr.s_addr;
+ ifa->ifa_netmask)->sin_addr.s_addr;
ina = ((struct sockaddr_in *)
- &ifr->ifr_addr)->sin_addr.s_addr;
+ ifa->ifa_addr)->sin_addr.s_addr;
if ((ipaddr & mask) == (ina & mask))
break; /* ok, we got it! */
}
-
- if (ifr >= ifend)
+ if (ifa == NULL)
goto done;
/*
* Now scan through again looking for a link-level address
* for this interface.
*/
- ifp = ifr;
- for (ifr = ifc.ifc_req; ifr < ifend; ifr = NEXTIFR(ifr))
- if (strcmp(ifp->ifr_name, ifr->ifr_name) == 0 &&
- ifr->ifr_addr.sa_family == AF_LINK)
+ for (ifd = ifas; ifd != NULL; ifd = ifd->ifa_next) {
+ if (ifd->ifa_addr == NULL)
+ continue;
+ if (strcmp(ifa->ifa_name, ifd->ifa_name) == 0 &&
+ ifd->ifa_addr->sa_family == AF_LINK)
break;
- if (ifr >= ifend)
+ }
+ if (ifd == NULL)
goto done;
/*
* Found the link-level address - copy it out
*/
- dla = (struct sockaddr_dl *) &ifr->ifr_addr;
+ dla = (struct sockaddr_dl *)ifd->ifa_addr;
memcpy(hwaddr, LLADDR(dla), dla->sdl_alen);
- printf("using interface %s for proxy with address %s\n", ifp->ifr_name,
+ printf("using interface %s for proxy with address %s\n", ifa->ifa_name,
ether_ntoa(hwaddr));
retval = dla->sdl_alen;
done:
- close(sock);
+ if (ifas != NULL)
+ freeifaddrs(ifas);
return (retval);
}
diff --git a/usr.sbin/arp/arp.h b/usr.sbin/arp/arp.h
new file mode 100644
index 000000000000..487863be43e7
--- /dev/null
+++ b/usr.sbin/arp/arp.h
@@ -0,0 +1,23 @@
+#ifndef _USR_SBIN_ARP_ARP_H_
+#define _USR_SBIN_ARP_ARP_H_
+
+int valid_type(int type);
+struct sockaddr_in *getaddr(char *host);
+int print_entries_nl(uint32_t ifindex, struct in_addr addr);
+
+struct arp_opts {
+ bool aflag;
+ bool nflag;
+ time_t expire_time;
+ int flags;
+ char *rifname;
+ unsigned int rifindex;
+};
+extern struct arp_opts opts;
+
+int print_entries_nl(uint32_t ifindex, struct in_addr addr);
+int delete_nl(uint32_t ifindex, char *host);
+int set_nl(uint32_t ifindex, struct sockaddr_in *dst, struct sockaddr_dl *sdl,
+ char *host);
+
+#endif
diff --git a/usr.sbin/arp/arp_netlink.c b/usr.sbin/arp/arp_netlink.c
new file mode 100644
index 000000000000..8644f3722aed
--- /dev/null
+++ b/usr.sbin/arp/arp_netlink.c
@@ -0,0 +1,440 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <err.h>
+#include <errno.h>
+#include <netdb.h>
+
+#include <sys/bitcount.h>
+#include <sys/param.h>
+#include <sys/linker.h>
+#include <sys/module.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+#include <sys/time.h>
+#include <sys/types.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
+#include <netlink/netlink.h>
+#include <netlink/netlink_route.h>
+#include <netlink/netlink_snl.h>
+#include <netlink/netlink_snl_route.h>
+#include <netlink/netlink_snl_route_compat.h>
+#include <netlink/netlink_snl_route_parsers.h>
+
+#include <libxo/xo.h>
+#include "arp.h"
+
+#define RTF_ANNOUNCE RTF_PROTO2
+
+static void
+nl_init_socket(struct snl_state *ss)
+{
+ if (snl_init(ss, NETLINK_ROUTE))
+ return;
+
+ if (modfind("netlink") == -1 && errno == ENOENT) {
+ /* Try to load */
+ if (kldload("netlink") == -1)
+ err(1, "netlink is not loaded and load attempt failed");
+ if (snl_init(ss, NETLINK_ROUTE))
+ return;
+ }
+
+ err(1, "unable to open netlink socket");
+}
+
+static bool
+get_link_info(struct snl_state *ss, uint32_t ifindex,
+ struct snl_parsed_link_simple *link)
+{
+ struct snl_writer nw;
+
+ snl_init_writer(ss, &nw);
+
+ struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_GETLINK);
+ struct ifinfomsg *ifmsg = snl_reserve_msg_object(&nw, struct ifinfomsg);
+ if (ifmsg != NULL)
+ ifmsg->ifi_index = ifindex;
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(ss, hdr))
+ return (false);
+
+ hdr = snl_read_reply(ss, hdr->nlmsg_seq);
+
+ if (hdr == NULL || hdr->nlmsg_type != RTM_NEWLINK)
+ return (false);
+
+ if (!snl_parse_nlmsg(ss, hdr, &snl_rtm_link_parser_simple, link))
+ return (false);
+
+ return (true);
+}
+
+
+
+static bool
+has_l2(struct snl_state *ss, uint32_t ifindex)
+{
+ struct snl_parsed_link_simple link = {};
+
+ if (!get_link_info(ss, ifindex, &link))
+ return (false);
+
+ return (valid_type(link.ifi_type) != 0);
+}
+
+static uint32_t
+get_myfib(void)
+{
+ uint32_t fibnum = 0;
+ size_t len = sizeof(fibnum);
+
+ sysctlbyname("net.my_fibnum", (void *)&fibnum, &len, NULL, 0);
+
+ return (fibnum);
+}
+
+static int
+guess_ifindex(struct snl_state *ss, uint32_t fibnum, struct in_addr addr)
+{
+ struct snl_writer nw;
+
+ snl_init_writer(ss, &nw);
+
+ struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_GETROUTE);
+ struct rtmsg *rtm = snl_reserve_msg_object(&nw, struct rtmsg);
+ rtm->rtm_family = AF_INET;
+
+ struct sockaddr_in dst = { .sin_family = AF_INET, .sin_addr = addr };
+ snl_add_msg_attr_ip(&nw, RTA_DST, (struct sockaddr *)&dst);
+ snl_add_msg_attr_u32(&nw, RTA_TABLE, fibnum);
+
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(ss, hdr))
+ return (0);
+
+ hdr = snl_read_reply(ss, hdr->nlmsg_seq);
+
+ if (hdr->nlmsg_type != NL_RTM_NEWROUTE) {
+ /* No route found, unable to guess ifindex */
+ return (0);
+ }
+
+ struct snl_parsed_route r = {};
+ if (!snl_parse_nlmsg(ss, hdr, &snl_rtm_route_parser, &r))
+ return (0);
+
+ if (r.rta_multipath.num_nhops > 0 || (r.rta_rtflags & RTF_GATEWAY))
+ return (0);
+
+ /* Check if the interface is of supported type */
+ if (has_l2(ss, r.rta_oif))
+ return (r.rta_oif);
+
+ /* Check the case when we matched the loopback route for P2P */
+ snl_init_writer(ss, &nw);
+ hdr = snl_create_msg_request(&nw, RTM_GETNEXTHOP);
+ snl_reserve_msg_object(&nw, struct nhmsg);
+
+ int off = snl_add_msg_attr_nested(&nw, NHA_FREEBSD);
+ snl_add_msg_attr_u32(&nw, NHAF_KID, r.rta_knh_id);
+ snl_add_msg_attr_u8(&nw, NHAF_FAMILY, AF_INET);
+ snl_add_msg_attr_u32(&nw, NHAF_TABLE, fibnum);
+ snl_end_attr_nested(&nw, off);
+
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(ss, hdr))
+ return (0);
+
+ hdr = snl_read_reply(ss, hdr->nlmsg_seq);
+
+ if (hdr->nlmsg_type != NL_RTM_NEWNEXTHOP) {
+ /* No nexthop found, unable to guess ifindex */
+ return (0);
+ }
+
+ struct snl_parsed_nhop nh = {};
+ if (!snl_parse_nlmsg(ss, hdr, &snl_nhmsg_parser, &nh))
+ return (0);
+
+ return (nh.nhaf_aif);
+}
+
+static uint32_t
+fix_ifindex(struct snl_state *ss, uint32_t ifindex, struct in_addr addr)
+{
+ if (ifindex == 0)
+ ifindex = guess_ifindex(ss, get_myfib(), addr);
+ return (ifindex);
+}
+
+static void
+print_entry(struct snl_parsed_neigh *neigh, struct snl_parsed_link_simple *link)
+{
+ const char *host;
+ struct hostent *hp;
+ struct sockaddr_in *addr = (struct sockaddr_in *)neigh->nda_dst;
+
+ xo_open_instance("arp-cache");
+
+ if (!opts.nflag)
+ hp = gethostbyaddr((caddr_t)&(addr->sin_addr),
+ sizeof(addr->sin_addr), AF_INET);
+ else
+ hp = 0;
+ if (hp)
+ host = hp->h_name;
+ else {
+ host = "?";
+ if (h_errno == TRY_AGAIN)
+ opts.nflag = true;
+ }
+ xo_emit("{:hostname/%s} ({:ip-address/%s}) at ", host,
+ inet_ntoa(addr->sin_addr));
+ if (neigh->nda_lladdr != NULL) {
+ struct sockaddr_dl sdl = {
+ .sdl_family = AF_LINK,
+ .sdl_type = link->ifi_type,
+ .sdl_len = sizeof(struct sockaddr_dl),
+ .sdl_alen = NLA_DATA_LEN(neigh->nda_lladdr),
+ };
+ memcpy(sdl.sdl_data, NLA_DATA(neigh->nda_lladdr), sdl.sdl_alen);
+
+ if ((sdl.sdl_type == IFT_ETHER ||
+ sdl.sdl_type == IFT_L2VLAN ||
+ sdl.sdl_type == IFT_BRIDGE) &&
+ sdl.sdl_alen == ETHER_ADDR_LEN)
+ xo_emit("{:mac-address/%s}",
+ ether_ntoa((struct ether_addr *)LLADDR(&sdl)));
+ else {
+
+ xo_emit("{:mac-address/%s}", link_ntoa(&sdl));
+ }
+ } else
+ xo_emit("{d:/(incomplete)}{en:incomplete/true}");
+ xo_emit(" on {:interface/%s}", link->ifla_ifname);
+
+ if (neigh->ndaf_next_ts == 0)
+ xo_emit("{d:/ permanent}{en:permanent/true}");
+ else {
+ time_t expire_time;
+ struct timeval now;
+
+ gettimeofday(&now, 0);
+ if ((expire_time = neigh->ndaf_next_ts - now.tv_sec) > 0)
+ xo_emit(" expires in {:expires/%d} seconds",
+ (int)expire_time);
+ else
+ xo_emit("{d:/ expired}{en:expired/true}");
+ }
+
+ if (neigh->ndm_flags & NTF_PROXY)
+ xo_emit("{d:/ published}{en:published/true}");
+
+ switch(link->ifi_type) {
+ case IFT_ETHER:
+ xo_emit(" [{:type/ethernet}]");
+ break;
+ case IFT_FDDI:
+ xo_emit(" [{:type/fddi}]");
+ break;
+ case IFT_ATM:
+ xo_emit(" [{:type/atm}]");
+ break;
+ case IFT_L2VLAN:
+ xo_emit(" [{:type/vlan}]");
+ break;
+ case IFT_IEEE1394:
+ xo_emit(" [{:type/firewire}]");
+ break;
+ case IFT_BRIDGE:
+ xo_emit(" [{:type/bridge}]");
+ break;
+ case IFT_INFINIBAND:
+ xo_emit(" [{:type/infiniband}]");
+ break;
+ default:
+ break;
+ }
+
+ xo_emit("\n");
+
+ xo_close_instance("arp-cache");
+}
+
+int
+print_entries_nl(uint32_t ifindex, struct in_addr addr)
+{
+ struct snl_state ss_req = {}, ss_cmd = {};
+ struct snl_parsed_link_simple link = {};
+ struct snl_writer nw;
+
+ nl_init_socket(&ss_req);
+ snl_init_writer(&ss_req, &nw);
+
+ struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_GETNEIGH);
+ struct ndmsg *ndmsg = snl_reserve_msg_object(&nw, struct ndmsg);
+ if (ndmsg != NULL) {
+ ndmsg->ndm_family = AF_INET;
+ /* let kernel filter results by interface if provided */
+ ndmsg->ndm_ifindex = ifindex;
+ }
+
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(&ss_req, hdr)) {
+ snl_free(&ss_req);
+ return (0);
+ }
+
+ uint32_t nlmsg_seq = hdr->nlmsg_seq;
+ struct snl_errmsg_data e = {};
+ int count = 0;
+ nl_init_socket(&ss_cmd);
+
+ while ((hdr = snl_read_reply_multi(&ss_req, nlmsg_seq, &e)) != NULL) {
+ struct snl_parsed_neigh neigh = {};
+ struct sockaddr_in *neighaddr;
+
+ if (!snl_parse_nlmsg(&ss_req, hdr, &snl_rtm_neigh_parser, &neigh))
+ continue;
+
+ if (neigh.nda_ifindex != link.ifi_index) {
+ snl_clear_lb(&ss_cmd);
+ memset(&link, 0, sizeof(link));
+ if (!get_link_info(&ss_cmd, neigh.nda_ifindex, &link))
+ continue;
+ }
+
+ /* filter results based on host if provided */
+ neighaddr = (struct sockaddr_in *)neigh.nda_dst;
+ if (addr.s_addr &&
+ (addr.s_addr != neighaddr->sin_addr.s_addr))
+ continue;
+
+ print_entry(&neigh, &link);
+ count++;
+ snl_clear_lb(&ss_req);
+ }
+
+ snl_free(&ss_req);
+ snl_free(&ss_cmd);
+
+ return (count);
+}
+
+int
+delete_nl(uint32_t ifindex, char *host)
+{
+ struct snl_state ss = {};
+ struct snl_writer nw;
+ struct sockaddr_in *dst;
+
+ dst = getaddr(host);
+ if (dst == NULL)
+ return (1);
+
+ nl_init_socket(&ss);
+
+ ifindex = fix_ifindex(&ss, ifindex, dst->sin_addr);
+ if (ifindex == 0) {
+ xo_warnx("delete: cannot locate %s", host);
+ snl_free(&ss);
+ return (0);
+ }
+
+ snl_init_writer(&ss, &nw);
+ struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_DELNEIGH);
+ struct ndmsg *ndmsg = snl_reserve_msg_object(&nw, struct ndmsg);
+ if (ndmsg != NULL) {
+ ndmsg->ndm_family = AF_INET;
+ ndmsg->ndm_ifindex = ifindex;
+ }
+ snl_add_msg_attr_ip(&nw, NDA_DST, (struct sockaddr *)dst);
+
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(&ss, hdr)) {
+ snl_free(&ss);
+ return (1);
+ }
+
+ struct snl_errmsg_data e = {};
+ snl_read_reply_code(&ss, hdr->nlmsg_seq, &e);
+ if (e.error != 0) {
+ if (e.error_str != NULL)
+ xo_warnx("delete %s: %s (%s)", host, strerror(e.error), e.error_str);
+ else
+ xo_warnx("delete %s: %s", host, strerror(e.error));
+ } else
+ printf("%s (%s) deleted\n", host, inet_ntoa(dst->sin_addr));
+
+ snl_free(&ss);
+
+ return (e.error != 0);
+}
+
+int
+set_nl(uint32_t ifindex, struct sockaddr_in *dst, struct sockaddr_dl *sdl, char *host)
+{
+ struct snl_state ss = {};
+ struct snl_writer nw;
+
+ nl_init_socket(&ss);
+
+ ifindex = fix_ifindex(&ss, ifindex, dst->sin_addr);
+ if (ifindex == 0) {
+ xo_warnx("delete: cannot locate %s", host);
+ snl_free(&ss);
+ return (0);
+ }
+
+ snl_init_writer(&ss, &nw);
+ struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_NEWNEIGH);
+ hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE;
+ struct ndmsg *ndmsg = snl_reserve_msg_object(&nw, struct ndmsg);
+ if (ndmsg != NULL) {
+ uint8_t nl_flags = 0;
+
+ ndmsg->ndm_family = AF_INET;
+ ndmsg->ndm_ifindex = ifindex;
+ ndmsg->ndm_state = (opts.expire_time == 0) ? \
+ NUD_PERMANENT : NUD_NONE;
+
+ if (opts.flags & RTF_ANNOUNCE)
+ nl_flags |= NTF_PROXY;
+ if (opts.expire_time == 0)
+ nl_flags |= NTF_STICKY;
+ ndmsg->ndm_flags = nl_flags;
+ }
+ snl_add_msg_attr_ip(&nw, NDA_DST, (struct sockaddr *)dst);
+ snl_add_msg_attr(&nw, NDA_LLADDR, sdl->sdl_alen, LLADDR(sdl));
+
+ if (opts.expire_time != 0) {
+ struct timeval now;
+
+ gettimeofday(&now, 0);
+ int off = snl_add_msg_attr_nested(&nw, NDA_FREEBSD);
+ snl_add_msg_attr_u32(&nw, NDAF_NEXT_STATE_TS, now.tv_sec + opts.expire_time);
+ snl_end_attr_nested(&nw, off);
+ }
+
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(&ss, hdr)) {
+ snl_free(&ss);
+ return (1);
+ }
+
+ struct snl_errmsg_data e = {};
+ snl_read_reply_code(&ss, hdr->nlmsg_seq, &e);
+ if (e.error != 0) {
+ if (e.error_str != NULL)
+ xo_warnx("set: %s: %s (%s)", host, strerror(e.error), e.error_str);
+ else
+ xo_warnx("set %s: %s", host, strerror(e.error));
+ }
+ snl_free(&ss);
+
+ return (e.error != 0);
+}
+
diff --git a/usr.sbin/audit/Makefile b/usr.sbin/audit/Makefile
index 4fa6856e8cab..55ddfa4bc9a5 100644
--- a/usr.sbin/audit/Makefile
+++ b/usr.sbin/audit/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
OPENBSMDIR=${SRCTOP}/contrib/openbsm
diff --git a/usr.sbin/audit/Makefile.depend b/usr.sbin/audit/Makefile.depend
index 2511c90c76b0..9ec2c1a7a215 100644
--- a/usr.sbin/audit/Makefile.depend
+++ b/usr.sbin/audit/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/auditd/Makefile b/usr.sbin/auditd/Makefile
index 5385463a6e3b..b13ff5355c4b 100644
--- a/usr.sbin/auditd/Makefile
+++ b/usr.sbin/auditd/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
OPENBSMDIR=${SRCTOP}/contrib/openbsm
diff --git a/usr.sbin/auditd/Makefile.depend b/usr.sbin/auditd/Makefile.depend
index b5a4efa4ee85..e54b48453440 100644
--- a/usr.sbin/auditd/Makefile.depend
+++ b/usr.sbin/auditd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/auditdistd/Makefile b/usr.sbin/auditdistd/Makefile
index ef323152f171..9bfa3c444922 100644
--- a/usr.sbin/auditdistd/Makefile
+++ b/usr.sbin/auditdistd/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
OPENBSMDIR=${SRCTOP}/contrib/openbsm
@@ -9,6 +8,8 @@ OPENBSMDIR=${SRCTOP}/contrib/openbsm
# auditdistd.h. This seems like a makefile non-feature.
CFLAGS+=-I${OPENBSMDIR} -I${OPENBSMDIR}/bin/auditdistd
+CFLAGS+=-DOPENSSL_API_COMPAT=0x10100000L
+
NO_WFORMAT=
NO_WMISSING_VARIABLE_DECLARATIONS=
diff --git a/usr.sbin/auditdistd/Makefile.depend b/usr.sbin/auditdistd/Makefile.depend
index 5d5b308975cf..9db58793130d 100644
--- a/usr.sbin/auditdistd/Makefile.depend
+++ b/usr.sbin/auditdistd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -13,7 +11,6 @@ DIRDEPS = \
lib/libutil \
secure/lib/libcrypto \
secure/lib/libssl \
- usr.bin/lex/lib \
usr.bin/yacc.host \
diff --git a/usr.sbin/auditreduce/Makefile b/usr.sbin/auditreduce/Makefile
index d7f23285e69b..66bc55af87a9 100644
--- a/usr.sbin/auditreduce/Makefile
+++ b/usr.sbin/auditreduce/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
OPENBSMDIR=${SRCTOP}/contrib/openbsm
diff --git a/usr.sbin/auditreduce/Makefile.depend b/usr.sbin/auditreduce/Makefile.depend
index 2511c90c76b0..9ec2c1a7a215 100644
--- a/usr.sbin/auditreduce/Makefile.depend
+++ b/usr.sbin/auditreduce/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/authpf/Makefile b/usr.sbin/authpf/Makefile
index 62fe84086c16..aa6c6e1058a5 100644
--- a/usr.sbin/authpf/Makefile
+++ b/usr.sbin/authpf/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/contrib/pf/authpf
diff --git a/usr.sbin/authpf/Makefile.depend b/usr.sbin/authpf/Makefile.depend
index 0f7ec3606b47..04744f68798b 100644
--- a/usr.sbin/authpf/Makefile.depend
+++ b/usr.sbin/authpf/Makefile.depend
@@ -1,14 +1,14 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libnv \
+ lib/libpfctl \
lib/libutil \
lib/msun \
diff --git a/usr.sbin/autofs/Makefile b/usr.sbin/autofs/Makefile
index 3a649062ae6e..195281df7cf2 100644
--- a/usr.sbin/autofs/Makefile
+++ b/usr.sbin/autofs/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
CONFS= auto_master
PACKAGE=autofs
diff --git a/usr.sbin/autofs/Makefile.depend b/usr.sbin/autofs/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/autofs/Makefile.depend
+++ b/usr.sbin/autofs/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/autofs/auto_master b/usr.sbin/autofs/auto_master
index 9083001abba1..111836c058a5 100644
--- a/usr.sbin/autofs/auto_master
+++ b/usr.sbin/autofs/auto_master
@@ -1,9 +1,6 @@
-# $FreeBSD$
#
# Automounter master map, see auto_master(5) for details.
#
/net -hosts -nobrowse,nosuid,intr
-# When using the -media special map, make sure to edit devd.conf(5)
-# to move the call to "automount -c" out of the comments section.
#/media -media -nosuid,noatime,autoro
#/- -noauto
diff --git a/usr.sbin/autofs/auto_master.5 b/usr.sbin/autofs/auto_master.5
index 29a05d95b697..e826176f9f3f 100644
--- a/usr.sbin/autofs/auto_master.5
+++ b/usr.sbin/autofs/auto_master.5
@@ -24,14 +24,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd December 28, 2018
+.Dd December 27, 2023
.Dt AUTO_MASTER 5
.Os
.Sh NAME
.Nm auto_master
-.Nd auto_master and map file format
+.Nd autofs automounter configuration and map file format
.Sh DESCRIPTION
The automounter configuration consists of the
.Nm
diff --git a/usr.sbin/autofs/autofs/Makefile b/usr.sbin/autofs/autofs/Makefile
index 42060884f710..d602381bbced 100644
--- a/usr.sbin/autofs/autofs/Makefile
+++ b/usr.sbin/autofs/autofs/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= autofs
diff --git a/usr.sbin/autofs/autofs/include_ldap b/usr.sbin/autofs/autofs/include_ldap
index 4cf70bfeef81..46c873a57691 100644
--- a/usr.sbin/autofs/autofs/include_ldap
+++ b/usr.sbin/autofs/autofs/include_ldap
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# Modify this to suit your needs. The "$1" is the map name, eg. "auto_master".
diff --git a/usr.sbin/autofs/autofs/include_nis b/usr.sbin/autofs/autofs/include_nis
index 5289984639a1..fc9c19b7f0ca 100644
--- a/usr.sbin/autofs/autofs/include_nis
+++ b/usr.sbin/autofs/autofs/include_nis
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
if [ -n "$2" ]; then
diff --git a/usr.sbin/autofs/autofs/include_nis_nullfs b/usr.sbin/autofs/autofs/include_nis_nullfs
index 6ef815d57c6b..706f43e7e0b3 100644
--- a/usr.sbin/autofs/autofs/include_nis_nullfs
+++ b/usr.sbin/autofs/autofs/include_nis_nullfs
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
#
diff --git a/usr.sbin/autofs/autofs/special_hosts b/usr.sbin/autofs/autofs/special_hosts
index c49854681451..45e865c37c53 100644
--- a/usr.sbin/autofs/autofs/special_hosts
+++ b/usr.sbin/autofs/autofs/special_hosts
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
if [ $# -eq 0 ]; then
diff --git a/usr.sbin/autofs/autofs/special_media b/usr.sbin/autofs/autofs/special_media
index dbd7457b445f..b397a8889623 100755
--- a/usr.sbin/autofs/autofs/special_media
+++ b/usr.sbin/autofs/autofs/special_media
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# Print newline-separated list of devices available for mounting.
@@ -41,7 +40,7 @@ print_map_entry() {
case "${_fstype}" in
"exfat")
if [ -f "/usr/local/sbin/mount.exfat" ]; then
- echo "-mountprog=/usr/local/sbin/mount.exfat,fstype=${_fstype},nosuid :/dev/${_p}"
+ echo "-mountprog=/usr/local/sbin/mount.exfat,fstype=${_fstype},sync :/dev/${_p}"
else
/usr/bin/logger -p info -t "special_media[$$]" \
"Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-exfat first"
@@ -50,18 +49,21 @@ print_map_entry() {
;;
"ntfs")
if [ -f "/usr/local/bin/ntfs-3g" ]; then
- echo "-mountprog=/usr/local/bin/ntfs-3g,fstype=${_fstype},nosuid :/dev/${_p}"
+ echo "-mountprog=/usr/local/bin/ntfs-3g,fstype=${_fstype},sync :/dev/${_p}"
else
/usr/bin/logger -p info -t "special_media[$$]" \
"Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-ntfs first"
exit 1
fi
;;
- "ext2fs" | "msdosfs")
- echo "-fstype=${_fstype},nosuid,async :/dev/${_p}"
+ "msdosfs")
+ echo "-fstype=${_fstype},sync :/dev/${_p}"
+ ;;
+ "ext2fs")
+ echo "-fstype=${_fstype},async :/dev/${_p}"
;;
*)
- echo "-fstype=${_fstype},nosuid :/dev/${_p}"
+ echo "-fstype=${_fstype} :/dev/${_p}"
;;
esac
}
diff --git a/usr.sbin/autofs/autofs/special_noauto b/usr.sbin/autofs/autofs/special_noauto
index 219ec7ea6994..b24d08a4b148 100755
--- a/usr.sbin/autofs/autofs/special_noauto
+++ b/usr.sbin/autofs/autofs/special_noauto
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
print_available() {
diff --git a/usr.sbin/autofs/autofs/special_null b/usr.sbin/autofs/autofs/special_null
index 41c10001e676..e62b57ee17f7 100644
--- a/usr.sbin/autofs/autofs/special_null
+++ b/usr.sbin/autofs/autofs/special_null
@@ -1,4 +1,3 @@
#!/usr/bin/true
#
-# $FreeBSD$
#
diff --git a/usr.sbin/autofs/automount.8 b/usr.sbin/autofs/automount.8
index b2f2329fa733..3dc423c3054f 100644
--- a/usr.sbin/autofs/automount.8
+++ b/usr.sbin/autofs/automount.8
@@ -24,8 +24,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd November 22, 2014
.Dt AUTOMOUNT 8
.Os
diff --git a/usr.sbin/autofs/automount.c b/usr.sbin/autofs/automount.c
index cd29c910bce2..32aa2300d094 100644
--- a/usr.sbin/autofs/automount.c
+++ b/usr.sbin/autofs/automount.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -29,9 +29,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
@@ -231,7 +228,7 @@ mount_unmount(struct node *root)
}
static void
-flush_autofs(const char *fspath)
+flush_autofs(const char *fspath, const fsid_t *fsid)
{
struct iovec *iov = NULL;
char errmsg[255];
@@ -244,6 +241,8 @@ flush_autofs(const char *fspath)
__DECONST(void *, "autofs"), (size_t)-1);
build_iovec(&iov, &iovlen, "fspath",
__DECONST(void *, fspath), (size_t)-1);
+ build_iovec(&iov, &iovlen, "fsid",
+ __DECONST(void *, fsid), sizeof(*fsid));
build_iovec(&iov, &iovlen, "errmsg",
errmsg, sizeof(errmsg));
@@ -262,6 +261,7 @@ static void
flush_caches(void)
{
struct statfs *mntbuf;
+ struct statfs statbuf;
int i, nitems;
nitems = getmntinfo(&mntbuf, MNT_WAIT);
@@ -276,8 +276,23 @@ flush_caches(void)
mntbuf[i].f_mntonname);
continue;
}
+ /*
+ * A direct map mountpoint may have been mounted over, in
+ * which case we can't MNT_UPDATE it. There's an obvious race
+ * condition remaining here, but that has to be fixed in the
+ * kernel.
+ */
+ if (statfs(mntbuf[i].f_mntonname, &statbuf) != 0) {
+ log_err(1, "cannot statfs %s", mntbuf[i].f_mntonname);
+ continue;
+ }
+ if (strcmp(statbuf.f_fstypename, "autofs") != 0) {
+ log_debugx("skipping %s, filesystem type is not autofs",
+ mntbuf[i].f_mntonname);
+ continue;
+ }
- flush_autofs(mntbuf[i].f_mntonname);
+ flush_autofs(mntbuf[i].f_mntonname, &statbuf.f_fsid);
}
}
diff --git a/usr.sbin/autofs/automountd.8 b/usr.sbin/autofs/automountd.8
index 1b3c3eb0cc2a..4b2cf7d56336 100644
--- a/usr.sbin/autofs/automountd.8
+++ b/usr.sbin/autofs/automountd.8
@@ -24,8 +24,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd March 10, 2015
.Dt AUTOMOUNTD 8
.Os
diff --git a/usr.sbin/autofs/automountd.c b/usr.sbin/autofs/automountd.c
index b1ca746d405a..54e5558768b1 100644
--- a/usr.sbin/autofs/automountd.c
+++ b/usr.sbin/autofs/automountd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -29,9 +29,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
diff --git a/usr.sbin/autofs/autounmountd.8 b/usr.sbin/autofs/autounmountd.8
index 423639579a7e..69b4565703e6 100644
--- a/usr.sbin/autofs/autounmountd.8
+++ b/usr.sbin/autofs/autounmountd.8
@@ -24,8 +24,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 13, 2014
.Dt AUTOUNMOUNTD 8
.Os
diff --git a/usr.sbin/autofs/autounmountd.c b/usr.sbin/autofs/autounmountd.c
index 57375f04d743..0230510d6e78 100644
--- a/usr.sbin/autofs/autounmountd.c
+++ b/usr.sbin/autofs/autounmountd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -29,9 +29,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/event.h>
#include <sys/mount.h>
diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c
index 4581e5c4f2f9..18756752876c 100644
--- a/usr.sbin/autofs/common.c
+++ b/usr.sbin/autofs/common.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -29,9 +29,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
diff --git a/usr.sbin/autofs/common.h b/usr.sbin/autofs/common.h
index e68a0be5f7c8..5bd2abf5ef78 100644
--- a/usr.sbin/autofs/common.h
+++ b/usr.sbin/autofs/common.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -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 AUTOMOUNTD_H
diff --git a/usr.sbin/autofs/defined.c b/usr.sbin/autofs/defined.c
index 205378d2b15d..578684b589fd 100644
--- a/usr.sbin/autofs/defined.c
+++ b/usr.sbin/autofs/defined.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -34,9 +34,6 @@
* such as ${OSNAME}, in maps.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
diff --git a/usr.sbin/autofs/log.c b/usr.sbin/autofs/log.c
index fb20e43b302d..02a889bffbed 100644
--- a/usr.sbin/autofs/log.c
+++ b/usr.sbin/autofs/log.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 The FreeBSD Foundation
*
@@ -30,8 +30,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
diff --git a/usr.sbin/autofs/popen.c b/usr.sbin/autofs/popen.c
index f1be8ec9a4ca..38c4a10e327e 100644
--- a/usr.sbin/autofs/popen.c
+++ b/usr.sbin/autofs/popen.c
@@ -38,9 +38,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/wait.h>
diff --git a/usr.sbin/autofs/token.l b/usr.sbin/autofs/token.l
index b277d7759f94..367bcd5e609c 100644
--- a/usr.sbin/autofs/token.l
+++ b/usr.sbin/autofs/token.l
@@ -1,6 +1,6 @@
%{
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <stdio.h>
diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile
index 185568d3ea56..d5d7dfc26ab9 100644
--- a/usr.sbin/bhyve/Makefile
+++ b/usr.sbin/bhyve/Makefile
@@ -1,11 +1,7 @@
#
-# $FreeBSD$
#
.include <src.opts.mk>
-CFLAGS+=-I${.CURDIR}/../../contrib/lib9p
-CFLAGS+=-I${SRCTOP}/sys
-.PATH: ${SRCTOP}/sys/cam/ctl
PROG= bhyve
PACKAGE= bhyve
@@ -14,39 +10,41 @@ MAN= bhyve.8 bhyve_config.5
BHYVE_SYSDIR?=${SRCTOP}
+.PATH: ${.CURDIR}/${MACHINE_CPUARCH} \
+ ${SRCTOP}/sys/libkern \
+ ${SRCTOP}/sys/cam/ctl
+
SRCS= \
- atkbdc.c \
acpi.c \
+ acpi_device.c \
audio.c \
+ basl.c \
bhyvegc.c \
bhyverun.c \
+ bhyverun_machdep.c \
block_if.c \
bootrom.c \
config.c \
console.c \
- ctl_util.c \
+ crc16.c \
ctl_scsi_all.c \
- fwctl.c \
- gdb.c \
+ ctl_util.c \
hda_codec.c \
- inout.c \
- ioapic.c \
- kernemu_dev.c \
+ iov.c \
mem.c \
mevent.c \
- mptbl.c \
+ net_backend_netmap.c \
+ net_backend_slirp.c \
net_backends.c \
net_utils.c \
pci_ahci.c \
pci_e82545.c \
pci_emul.c \
pci_hda.c \
- pci_fbuf.c \
pci_hostbridge.c \
pci_irq.c \
- pci_lpc.c \
pci_nvme.c \
- pci_passthru.c \
+ pci_uart.c \
pci_virtio_9p.c \
pci_virtio_block.c \
pci_virtio_console.c \
@@ -54,46 +52,48 @@ SRCS= \
pci_virtio_net.c \
pci_virtio_rnd.c \
pci_virtio_scsi.c \
- pci_uart.c \
pci_xhci.c \
- pctestdev.c \
- pm.c \
- post.c \
- ps2kbd.c \
- ps2mouse.c \
- rfb.c \
- rtc.c \
+ qemu_fwcfg.c \
+ qemu_loader.c \
smbiostbl.c \
sockstream.c \
- task_switch.c \
+ tpm_device.c \
+ tpm_emul_passthru.c \
+ tpm_intf_crb.c \
+ tpm_ppi_qemu.c \
+ uart_backend.c \
uart_emul.c \
usb_emul.c \
usb_mouse.c \
virtio.c \
- vga.c \
- vmgenc.c \
- xmsr.c \
- spinup_ap.c \
- iov.c
+ vmexit.c \
+ vmgenc.c
.if ${MK_BHYVE_SNAPSHOT} != "no"
SRCS+= snapshot.c
.endif
-CFLAGS.kernemu_dev.c+= -I${SRCTOP}/sys/amd64
+.include "${MACHINE_CPUARCH}/Makefile.inc"
-.PATH: ${BHYVE_SYSDIR}/sys/amd64/vmm
-SRCS+= vmm_instruction_emul.c
-
-LIBADD= vmmapi md nv pthread z util sbuf cam 9p
+.if defined(BHYVE_FDT_SUPPORT)
+LIBADD+= fdt
+CFLAGS+= -I${SRCTOP}/sys/contrib/libfdt
+.endif
-.if ${MK_CASPER} != "no"
-LIBADD+= casper
-LIBADD+= cap_pwd
-LIBADD+= cap_grp
-# Temporary disable capsicum, until we integrate checkpoint code with it.
-#CFLAGS+=-DWITH_CASPER
+.if defined(BHYVE_GDB_SUPPORT)
+SRCS+= gdb.c
+CFLAGS+= -DBHYVE_GDB
+.ifdef GDB_LOG
+CFLAGS+=-DGDB_LOG
.endif
+SUBDIR+= gdb
+.endif
+
+CFLAGS+=-I${.CURDIR} \
+ -I${.CURDIR}/../../contrib/lib9p \
+ -I${SRCTOP}/sys
+
+LIBADD+= vmmapi md nv pthread z util sbuf cam 9p
.if ${MK_BHYVE_SNAPSHOT} != "no"
LIBADD+= ucl xo
@@ -106,13 +106,14 @@ CFLAGS+=-DINET
CFLAGS+=-DINET6
.endif
.if ${MK_NETGRAPH_SUPPORT} != "no"
-CFLAGS+=-DNETGRAPH
-LIBADD+= netgraph
+SRCS+= net_backend_netgraph.c
+LIBADD+= netgraph
.endif
.if ${MK_OPENSSL} == "no"
CFLAGS+=-DNO_OPENSSL
.else
LIBADD+= crypto
+CFLAGS+=-DOPENSSL_API_COMPAT=0x10100000L
.endif
CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/e1000
@@ -120,18 +121,13 @@ CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/mii
CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/usb/controller
.if ${MK_BHYVE_SNAPSHOT} != "no"
CFLAGS+= -I${SRCTOP}/contrib/libucl/include
-
-# Temporary disable capsicum, until we integrate checkpoint code with it.
-CFLAGS+= -DWITHOUT_CAPSICUM
-
CFLAGS+= -DBHYVE_SNAPSHOT
.endif
-.ifdef GDB_LOG
-CFLAGS+=-DGDB_LOG
-.endif
+# Disable thread safety analysis since it only finds very simple bugs and
+# yields many false positives.
+NO_WTHREAD_SAFETY=
-WARNS?= 2
+NO_WCAST_ALIGN=
-SUBDIR= kbdlayout
.include <bsd.prog.mk>
diff --git a/usr.sbin/bhyve/Makefile.depend b/usr.sbin/bhyve/Makefile.depend
index 8222ceb6ad25..13df110065a5 100644
--- a/usr.sbin/bhyve/Makefile.depend
+++ b/usr.sbin/bhyve/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
@@ -6,17 +5,18 @@ DIRDEPS = \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
+ lib/lib9p \
lib/libc \
lib/libcam \
lib/libcapsicum \
lib/libcasper/libcasper \
lib/libcompiler_rt \
+ lib/libnetgraph \
+ lib/libnv \
lib/libsbuf \
lib/libthr \
- lib/libucl \
lib/libutil \
lib/libvmmapi \
- lib/libxo \
lib/libz \
diff --git a/usr.sbin/bhyve/Makefile.depend.options b/usr.sbin/bhyve/Makefile.depend.options
index fa96b2506b2c..b374d7a1fd52 100644
--- a/usr.sbin/bhyve/Makefile.depend.options
+++ b/usr.sbin/bhyve/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= OPENSSL
diff --git a/usr.sbin/bhyve/aarch64/Makefile.inc b/usr.sbin/bhyve/aarch64/Makefile.inc
new file mode 100644
index 000000000000..e2ea4414ca19
--- /dev/null
+++ b/usr.sbin/bhyve/aarch64/Makefile.inc
@@ -0,0 +1,9 @@
+SRCS+= \
+ fdt.c \
+ rtc_pl031.c \
+ uart_pl011.c
+
+.PATH: ${BHYVE_SYSDIR}/sys/arm64/vmm
+SRCS+= vmm_instruction_emul.c
+
+BHYVE_FDT_SUPPORT=
diff --git a/usr.sbin/bhyve/aarch64/bhyverun_machdep.c b/usr.sbin/bhyve/aarch64/bhyverun_machdep.c
new file mode 100644
index 000000000000..a5fd3f054706
--- /dev/null
+++ b/usr.sbin/bhyve/aarch64/bhyverun_machdep.c
@@ -0,0 +1,409 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2011 NetApp, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+
+#include <assert.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+#include <vmmapi.h>
+
+#include "bhyverun.h"
+#include "config.h"
+#include "debug.h"
+#include "fdt.h"
+#include "mem.h"
+#include "pci_emul.h"
+#include "pci_irq.h"
+#include "rtc_pl031.h"
+#include "uart_emul.h"
+
+/* Start of mem + 1M */
+#define FDT_BASE 0x100000
+#define FDT_SIZE (64 * 1024)
+
+/* Start of lowmem + 64K */
+#define UART_MMIO_BASE 0x10000
+#define UART_MMIO_SIZE 0x1000
+#define UART_INTR 32
+#define RTC_MMIO_BASE 0x11000
+#define RTC_MMIO_SIZE 0x1000
+#define RTC_INTR 33
+
+#define GIC_DIST_BASE 0x2f000000
+#define GIC_DIST_SIZE 0x10000
+#define GIC_REDIST_BASE 0x2f100000
+#define GIC_REDIST_SIZE(ncpu) ((ncpu) * 2 * PAGE_SIZE_64K)
+
+#define PCIE_INTA 34
+#define PCIE_INTB 35
+#define PCIE_INTC 36
+#define PCIE_INTD 37
+
+void
+bhyve_init_config(void)
+{
+ init_config();
+
+ /* Set default values prior to option parsing. */
+ set_config_bool("acpi_tables", false);
+ set_config_bool("acpi_tables_in_memory", false);
+ set_config_value("memory.size", "256M");
+}
+
+void
+bhyve_usage(int code)
+{
+ const char *progname;
+
+ progname = getprogname();
+
+ fprintf(stderr,
+ "Usage: %s [-CDHhSW]\n"
+ " %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n"
+ " %*s [-k config_file] [-m mem] [-o var=value]\n"
+ " %*s [-p vcpu:hostcpu] [-r file] [-s pci] [-U uuid] vmname\n"
+ " -C: include guest memory in core file\n"
+ " -c: number of CPUs and/or topology specification\n"
+ " -D: destroy on power-off\n"
+ " -h: help\n"
+ " -k: key=value flat config file\n"
+ " -m: memory size\n"
+ " -o: set config 'var' to 'value'\n"
+ " -p: pin 'vcpu' to 'hostcpu'\n"
+ " -S: guest memory cannot be swapped\n"
+ " -s: <slot,driver,configinfo> PCI slot config\n"
+ " -U: UUID\n"
+ " -W: force virtio to use single-vector MSI\n",
+ progname, (int)strlen(progname), "", (int)strlen(progname), "",
+ (int)strlen(progname), "");
+ exit(code);
+}
+
+void
+bhyve_optparse(int argc, char **argv)
+{
+ const char *optstr;
+ int c;
+
+ optstr = "hCDSWk:f:o:p:c:s:m:U:";
+ while ((c = getopt(argc, argv, optstr)) != -1) {
+ switch (c) {
+ case 'c':
+ if (bhyve_topology_parse(optarg) != 0) {
+ errx(EX_USAGE, "invalid cpu topology '%s'",
+ optarg);
+ }
+ break;
+ case 'C':
+ set_config_bool("memory.guest_in_core", true);
+ break;
+ case 'D':
+ set_config_bool("destroy_on_poweroff", true);
+ break;
+ case 'k':
+ bhyve_parse_simple_config_file(optarg);
+ break;
+ case 'm':
+ set_config_value("memory.size", optarg);
+ break;
+ case 'o':
+ if (!bhyve_parse_config_option(optarg)) {
+ errx(EX_USAGE,
+ "invalid configuration option '%s'",
+ optarg);
+ }
+ break;
+ case 'p':
+ if (bhyve_pincpu_parse(optarg) != 0) {
+ errx(EX_USAGE,
+ "invalid vcpu pinning configuration '%s'",
+ optarg);
+ }
+ break;
+ case 's':
+ if (strncmp(optarg, "help", strlen(optarg)) == 0) {
+ pci_print_supported_devices();
+ exit(0);
+ } else if (pci_parse_slot(optarg) != 0)
+ exit(4);
+ else
+ break;
+ case 'S':
+ set_config_bool("memory.wired", true);
+ break;
+ case 'U':
+ set_config_value("uuid", optarg);
+ break;
+ case 'W':
+ set_config_bool("virtio_msix", false);
+ break;
+ case 'h':
+ bhyve_usage(0);
+ default:
+ bhyve_usage(1);
+ }
+ }
+}
+
+void
+bhyve_init_vcpu(struct vcpu *vcpu __unused)
+{
+}
+
+void
+bhyve_start_vcpu(struct vcpu *vcpu, bool bsp __unused)
+{
+ fbsdrun_addcpu(vcpu_id(vcpu));
+}
+
+/*
+ * Load the specified boot code at the beginning of high memory.
+ */
+static void
+load_bootrom(struct vmctx *ctx, const char *path, uint64_t *elrp)
+{
+ struct stat sb;
+ void *data, *gptr;
+ vm_paddr_t loadaddr;
+ off_t size;
+ int fd;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ err(1, "open(%s)", path);
+ if (fstat(fd, &sb) != 0)
+ err(1, "fstat(%s)", path);
+
+ size = sb.st_size;
+
+ loadaddr = vm_get_highmem_base(ctx);
+ gptr = vm_map_gpa(ctx, loadaddr, round_page(size));
+
+ data = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (data == MAP_FAILED)
+ err(1, "mmap(%s)", path);
+ (void)close(fd);
+ memcpy(gptr, data, size);
+
+ if (munmap(data, size) != 0)
+ err(1, "munmap(%s)", path);
+
+ *elrp = loadaddr;
+}
+
+static void
+mmio_uart_intr_assert(void *arg)
+{
+ struct vmctx *ctx = arg;
+
+ vm_assert_irq(ctx, UART_INTR);
+}
+
+static void
+mmio_uart_intr_deassert(void *arg)
+{
+ struct vmctx *ctx = arg;
+
+ vm_deassert_irq(ctx, UART_INTR);
+}
+
+static int
+mmio_uart_mem_handler(struct vcpu *vcpu __unused, int dir,
+ uint64_t addr, int size __unused, uint64_t *val, void *arg1, long arg2)
+{
+ struct uart_pl011_softc *sc = arg1;
+ long reg;
+
+ reg = (addr - arg2) >> 2;
+ if (dir == MEM_F_WRITE)
+ uart_pl011_write(sc, reg, *val);
+ else
+ *val = uart_pl011_read(sc, reg);
+
+ return (0);
+}
+
+static bool
+init_mmio_uart(struct vmctx *ctx)
+{
+ struct uart_pl011_softc *sc;
+ struct mem_range mr;
+ const char *path;
+ int error;
+
+ path = get_config_value("console");
+ if (path == NULL)
+ return (false);
+
+ sc = uart_pl011_init(mmio_uart_intr_assert, mmio_uart_intr_deassert,
+ ctx);
+ if (uart_pl011_tty_open(sc, path) != 0) {
+ EPRINTLN("Unable to initialize backend '%s' for mmio uart",
+ path);
+ assert(0);
+ }
+
+ bzero(&mr, sizeof(struct mem_range));
+ mr.name = "uart";
+ mr.base = UART_MMIO_BASE;
+ mr.size = UART_MMIO_SIZE;
+ mr.flags = MEM_F_RW;
+ mr.handler = mmio_uart_mem_handler;
+ mr.arg1 = sc;
+ mr.arg2 = mr.base;
+ error = register_mem(&mr);
+ assert(error == 0);
+
+ return (true);
+}
+
+static void
+mmio_rtc_intr_assert(void *arg)
+{
+ struct vmctx *ctx = arg;
+
+ vm_assert_irq(ctx, RTC_INTR);
+}
+
+static void
+mmio_rtc_intr_deassert(void *arg)
+{
+ struct vmctx *ctx = arg;
+
+ vm_deassert_irq(ctx, RTC_INTR);
+}
+
+static int
+mmio_rtc_mem_handler(struct vcpu *vcpu __unused, int dir,
+ uint64_t addr, int size __unused, uint64_t *val, void *arg1, long arg2)
+{
+ struct rtc_pl031_softc *sc = arg1;
+ long reg;
+
+ reg = addr - arg2;
+ if (dir == MEM_F_WRITE)
+ rtc_pl031_write(sc, reg, *val);
+ else
+ *val = rtc_pl031_read(sc, reg);
+
+ return (0);
+}
+
+static void
+init_mmio_rtc(struct vmctx *ctx)
+{
+ struct rtc_pl031_softc *sc;
+ struct mem_range mr;
+ int error;
+
+ sc = rtc_pl031_init(mmio_rtc_intr_assert, mmio_rtc_intr_deassert,
+ ctx);
+
+ bzero(&mr, sizeof(struct mem_range));
+ mr.name = "rtc";
+ mr.base = RTC_MMIO_BASE;
+ mr.size = RTC_MMIO_SIZE;
+ mr.flags = MEM_F_RW;
+ mr.handler = mmio_rtc_mem_handler;
+ mr.arg1 = sc;
+ mr.arg2 = mr.base;
+ error = register_mem(&mr);
+ assert(error == 0);
+}
+
+static vm_paddr_t
+fdt_gpa(struct vmctx *ctx)
+{
+ return (vm_get_highmem_base(ctx) + FDT_BASE);
+}
+
+int
+bhyve_init_platform(struct vmctx *ctx, struct vcpu *bsp)
+{
+ const char *bootrom;
+ uint64_t elr;
+ int error;
+ int pcie_intrs[4] = {PCIE_INTA, PCIE_INTB, PCIE_INTC, PCIE_INTD};
+
+ bootrom = get_config_value("bootrom");
+ if (bootrom == NULL) {
+ warnx("no bootrom specified");
+ return (ENOENT);
+ }
+ load_bootrom(ctx, bootrom, &elr);
+ error = vm_set_register(bsp, VM_REG_GUEST_PC, elr);
+ if (error != 0) {
+ warn("vm_set_register(GUEST_PC)");
+ return (error);
+ }
+
+ error = fdt_init(ctx, guest_ncpus, fdt_gpa(ctx), FDT_SIZE);
+ if (error != 0)
+ return (error);
+
+ fdt_add_gic(GIC_DIST_BASE, GIC_DIST_SIZE, GIC_REDIST_BASE,
+ GIC_REDIST_SIZE(guest_ncpus));
+ error = vm_attach_vgic(ctx, GIC_DIST_BASE, GIC_DIST_SIZE,
+ GIC_REDIST_BASE, GIC_REDIST_SIZE(guest_ncpus));
+ if (error != 0) {
+ warn("vm_attach_vgic()");
+ return (error);
+ }
+
+ if (init_mmio_uart(ctx))
+ fdt_add_uart(UART_MMIO_BASE, UART_MMIO_SIZE, UART_INTR);
+ init_mmio_rtc(ctx);
+ fdt_add_rtc(RTC_MMIO_BASE, RTC_MMIO_SIZE, RTC_INTR);
+ fdt_add_timer();
+ pci_irq_init(pcie_intrs);
+ fdt_add_pcie(pcie_intrs);
+
+ return (0);
+}
+
+int
+bhyve_init_platform_late(struct vmctx *ctx, struct vcpu *bsp __unused)
+{
+ int error;
+
+ fdt_finalize();
+
+ error = vm_set_register(bsp, VM_REG_GUEST_X0, fdt_gpa(ctx));
+ assert(error == 0);
+
+ return (0);
+}
diff --git a/usr.sbin/bhyve/aarch64/fdt.c b/usr.sbin/bhyve/aarch64/fdt.c
new file mode 100644
index 000000000000..3fb97a40c241
--- /dev/null
+++ b/usr.sbin/bhyve/aarch64/fdt.c
@@ -0,0 +1,394 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 The FreeBSD Foundation
+ *
+ * This software was developed by Andrew Turner under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <libfdt.h>
+#include <vmmapi.h>
+
+#include "config.h"
+#include "bhyverun.h"
+#include "fdt.h"
+
+#define SET_PROP_U32(prop, idx, val) \
+ ((uint32_t *)(prop))[(idx)] = cpu_to_fdt32(val)
+#define SET_PROP_U64(prop, idx, val) \
+ ((uint64_t *)(prop))[(idx)] = cpu_to_fdt64(val)
+
+#define GIC_SPI 0
+#define GIC_PPI 1
+#define IRQ_TYPE_LEVEL_HIGH 4
+#define IRQ_TYPE_LEVEL_LOW 8
+
+#define GIC_FIRST_PPI 16
+#define GIC_FIRST_SPI 32
+
+static void *fdtroot;
+static uint32_t gic_phandle = 0;
+static uint32_t apb_pclk_phandle;
+
+static uint32_t
+assign_phandle(void *fdt)
+{
+ static uint32_t next_phandle = 1;
+ uint32_t phandle;
+
+ phandle = next_phandle;
+ next_phandle++;
+ fdt_property_u32(fdt, "phandle", phandle);
+
+ return (phandle);
+}
+
+static void
+set_single_reg(void *fdt, uint64_t start, uint64_t len)
+{
+ void *reg;
+
+ fdt_property_placeholder(fdt, "reg", 2 * sizeof(uint64_t), &reg);
+ SET_PROP_U64(reg, 0, start);
+ SET_PROP_U64(reg, 1, len);
+}
+
+static void
+add_cpu(void *fdt, int cpuid)
+{
+ char node_name[16];
+
+ snprintf(node_name, sizeof(node_name), "cpu@%d", cpuid);
+
+ fdt_begin_node(fdt, node_name);
+ fdt_property_string(fdt, "device_type", "cpu");
+ fdt_property_string(fdt, "compatible", "arm,armv8");
+ fdt_property_u64(fdt, "reg", cpuid);
+ fdt_property_string(fdt, "enable-method", "psci");
+ fdt_end_node(fdt);
+}
+
+static void
+add_cpus(void *fdt, int ncpu)
+{
+ int cpuid;
+
+ fdt_begin_node(fdt, "cpus");
+ /* XXX: Needed given the root #address-cells? */
+ fdt_property_u32(fdt, "#address-cells", 2);
+ fdt_property_u32(fdt, "#size-cells", 0);
+
+ for (cpuid = 0; cpuid < ncpu; cpuid++) {
+ add_cpu(fdt, cpuid);
+ }
+ fdt_end_node(fdt);
+}
+
+int
+fdt_init(struct vmctx *ctx, int ncpu, vm_paddr_t fdtaddr, vm_size_t fdtsize)
+{
+ void *fdt;
+ const char *bootargs;
+
+ fdt = paddr_guest2host(ctx, fdtaddr, fdtsize);
+ if (fdt == NULL)
+ return (EFAULT);
+
+ fdt_create(fdt, (int)fdtsize);
+
+ /* Add the memory reserve map (needed even if none is reserved) */
+ fdt_finish_reservemap(fdt);
+
+ /* Create the root node */
+ fdt_begin_node(fdt, "");
+
+ fdt_property_string(fdt, "compatible", "freebsd,bhyve");
+ fdt_property_u32(fdt, "#address-cells", 2);
+ fdt_property_u32(fdt, "#size-cells", 2);
+
+ fdt_begin_node(fdt, "chosen");
+ fdt_property_string(fdt, "stdout-path", "serial0:115200n8");
+ bootargs = get_config_value("fdt.bootargs");
+ if (bootargs != NULL)
+ fdt_property_string(fdt, "bootargs", bootargs);
+ fdt_end_node(fdt);
+
+ fdt_begin_node(fdt, "memory");
+ fdt_property_string(fdt, "device_type", "memory");
+ /* There is no lowmem on arm64. */
+ assert(vm_get_lowmem_size(ctx) == 0);
+ set_single_reg(fdt, vm_get_highmem_base(ctx), vm_get_highmem_size(ctx));
+ fdt_end_node(fdt);
+
+ add_cpus(fdt, ncpu);
+
+ fdt_begin_node(fdt, "psci");
+ fdt_property_string(fdt, "compatible", "arm,psci-1.0");
+ fdt_property_string(fdt, "method", "hvc");
+ fdt_end_node(fdt);
+
+ fdt_begin_node(fdt, "apb-pclk");
+ fdt_property_string(fdt, "compatible", "fixed-clock");
+ fdt_property_string(fdt, "clock-output-names", "clk24mhz");
+ fdt_property_u32(fdt, "#clock-cells", 0);
+ fdt_property_u32(fdt, "clock-frequency", 24000000);
+ apb_pclk_phandle = assign_phandle(fdt);
+ fdt_end_node(fdt);
+
+ /* Finalized by fdt_finalized(). */
+ fdtroot = fdt;
+
+ return (0);
+}
+
+void
+fdt_add_gic(uint64_t dist_base, uint64_t dist_size,
+ uint64_t redist_base, uint64_t redist_size)
+{
+ char node_name[32];
+ void *fdt, *prop;
+
+ fdt = fdtroot;
+
+ snprintf(node_name, sizeof(node_name), "interrupt-controller@%lx",
+ (unsigned long)dist_base);
+ fdt_begin_node(fdt, node_name);
+
+ gic_phandle = assign_phandle(fdt);
+ fdt_property_string(fdt, "compatible", "arm,gic-v3");
+ fdt_property(fdt, "interrupt-controller", NULL, 0);
+ fdt_property(fdt, "msi-controller", NULL, 0);
+ /* XXX: Needed given the root #address-cells? */
+ fdt_property_u32(fdt, "#address-cells", 2);
+ fdt_property_u32(fdt, "#interrupt-cells", 3);
+ fdt_property_placeholder(fdt, "reg", 4 * sizeof(uint64_t), &prop);
+ /* GICD */
+ SET_PROP_U64(prop, 0, dist_base);
+ SET_PROP_U64(prop, 1, dist_size);
+ /* GICR */
+ SET_PROP_U64(prop, 2, redist_base);
+ SET_PROP_U64(prop, 3, redist_size);
+
+ fdt_property_placeholder(fdt, "mbi-ranges", 2 * sizeof(uint32_t),
+ &prop);
+ SET_PROP_U32(prop, 0, 256);
+ SET_PROP_U32(prop, 1, 64);
+
+ fdt_end_node(fdt);
+
+ fdt_property_u32(fdt, "interrupt-parent", gic_phandle);
+}
+
+void
+fdt_add_uart(uint64_t uart_base, uint64_t uart_size, int intr)
+{
+ void *fdt, *interrupts, *prop;
+ char node_name[32];
+
+ assert(gic_phandle != 0);
+ assert(apb_pclk_phandle != 0);
+ assert(intr >= GIC_FIRST_SPI);
+
+ fdt = fdtroot;
+
+ snprintf(node_name, sizeof(node_name), "serial@%lx", uart_base);
+ fdt_begin_node(fdt, node_name);
+#define UART_COMPAT "arm,pl011\0arm,primecell"
+ fdt_property(fdt, "compatible", UART_COMPAT, sizeof(UART_COMPAT));
+#undef UART_COMPAT
+ set_single_reg(fdt, uart_base, uart_size);
+ fdt_property_u32(fdt, "interrupt-parent", gic_phandle);
+ fdt_property_placeholder(fdt, "interrupts", 3 * sizeof(uint32_t),
+ &interrupts);
+ SET_PROP_U32(interrupts, 0, GIC_SPI);
+ SET_PROP_U32(interrupts, 1, intr - GIC_FIRST_SPI);
+ SET_PROP_U32(interrupts, 2, IRQ_TYPE_LEVEL_HIGH);
+ fdt_property_placeholder(fdt, "clocks", 2 * sizeof(uint32_t), &prop);
+ SET_PROP_U32(prop, 0, apb_pclk_phandle);
+ SET_PROP_U32(prop, 1, apb_pclk_phandle);
+#define UART_CLK_NAMES "uartclk\0apb_pclk"
+ fdt_property(fdt, "clock-names", UART_CLK_NAMES,
+ sizeof(UART_CLK_NAMES));
+#undef UART_CLK_NAMES
+
+ fdt_end_node(fdt);
+
+ snprintf(node_name, sizeof(node_name), "/serial@%lx", uart_base);
+ fdt_begin_node(fdt, "aliases");
+ fdt_property_string(fdt, "serial0", node_name);
+ fdt_end_node(fdt);
+}
+
+void
+fdt_add_rtc(uint64_t rtc_base, uint64_t rtc_size, int intr)
+{
+ void *fdt, *interrupts, *prop;
+ char node_name[32];
+
+ assert(gic_phandle != 0);
+ assert(apb_pclk_phandle != 0);
+ assert(intr >= GIC_FIRST_SPI);
+
+ fdt = fdtroot;
+
+ snprintf(node_name, sizeof(node_name), "rtc@%lx", rtc_base);
+ fdt_begin_node(fdt, node_name);
+#define RTC_COMPAT "arm,pl031\0arm,primecell"
+ fdt_property(fdt, "compatible", RTC_COMPAT, sizeof(RTC_COMPAT));
+#undef RTC_COMPAT
+ set_single_reg(fdt, rtc_base, rtc_size);
+ fdt_property_u32(fdt, "interrupt-parent", gic_phandle);
+ fdt_property_placeholder(fdt, "interrupts", 3 * sizeof(uint32_t),
+ &interrupts);
+ SET_PROP_U32(interrupts, 0, GIC_SPI);
+ SET_PROP_U32(interrupts, 1, intr - GIC_FIRST_SPI);
+ SET_PROP_U32(interrupts, 2, IRQ_TYPE_LEVEL_HIGH);
+ fdt_property_placeholder(fdt, "clocks", sizeof(uint32_t), &prop);
+ SET_PROP_U32(prop, 0, apb_pclk_phandle);
+ fdt_property_string(fdt, "clock-names", "apb_pclk");
+
+ fdt_end_node(fdt);
+}
+
+void
+fdt_add_timer(void)
+{
+ void *fdt, *interrupts;
+ uint32_t irqs[] = { 13, 14, 11 };
+
+ assert(gic_phandle != 0);
+
+ fdt = fdtroot;
+
+ fdt_begin_node(fdt, "timer");
+ fdt_property_string(fdt, "compatible", "arm,armv8-timer");
+ fdt_property_u32(fdt, "interrupt-parent", gic_phandle);
+ fdt_property_placeholder(fdt, "interrupts", 9 * sizeof(uint32_t),
+ &interrupts);
+ for (u_int i = 0; i < nitems(irqs); i++) {
+ SET_PROP_U32(interrupts, i * 3 + 0, GIC_PPI);
+ SET_PROP_U32(interrupts, i * 3 + 1, irqs[i]);
+ SET_PROP_U32(interrupts, i * 3 + 2, IRQ_TYPE_LEVEL_LOW);
+ }
+ fdt_end_node(fdt);
+}
+
+void
+fdt_add_pcie(int intrs[static 4])
+{
+ void *fdt, *prop;
+ int slot, pin, intr, i;
+
+ assert(gic_phandle != 0);
+
+ fdt = fdtroot;
+
+ fdt_begin_node(fdt, "pcie@1f0000000");
+ fdt_property_string(fdt, "compatible", "pci-host-ecam-generic");
+ fdt_property_u32(fdt, "#address-cells", 3);
+ fdt_property_u32(fdt, "#size-cells", 2);
+ fdt_property_string(fdt, "device_type", "pci");
+ fdt_property_u64(fdt, "bus-range", (0ul << 32) | 1);
+ set_single_reg(fdt, 0xe0000000, 0x10000000);
+ fdt_property_placeholder(fdt, "ranges",
+ 2 * 7 * sizeof(uint32_t), &prop);
+ SET_PROP_U32(prop, 0, 0x01000000);
+
+ SET_PROP_U32(prop, 1, 0);
+ SET_PROP_U32(prop, 2, 0xdf000000);
+
+ SET_PROP_U32(prop, 3, 0);
+ SET_PROP_U32(prop, 4, 0xdf000000);
+
+ SET_PROP_U32(prop, 5, 0);
+ SET_PROP_U32(prop, 6, 0x01000000);
+
+ SET_PROP_U32(prop, 7, 0x02000000);
+
+ SET_PROP_U32(prop, 8, 0);
+ SET_PROP_U32(prop, 9, 0xa0000000);
+
+ SET_PROP_U32(prop, 10, 0);
+ SET_PROP_U32(prop, 11, 0xa0000000);
+
+ SET_PROP_U32(prop, 12, 0);
+ SET_PROP_U32(prop, 13, 0x3f000000);
+
+ fdt_property_placeholder(fdt, "msi-map", 4 * sizeof(uint32_t), &prop);
+ SET_PROP_U32(prop, 0, 0); /* RID base */
+ SET_PROP_U32(prop, 1, gic_phandle); /* MSI parent */
+ SET_PROP_U32(prop, 2, 0); /* MSI base */
+ SET_PROP_U32(prop, 3, 0x10000); /* RID length */
+ fdt_property_u32(fdt, "msi-parent", gic_phandle);
+
+ fdt_property_u32(fdt, "#interrupt-cells", 1);
+ fdt_property_u32(fdt, "interrupt-parent", gic_phandle);
+
+ /*
+ * Describe standard swizzled interrupts routing (pins rotated by one
+ * for each consecutive slot). Must match pci_irq_route().
+ */
+ fdt_property_placeholder(fdt, "interrupt-map-mask",
+ 4 * sizeof(uint32_t), &prop);
+ SET_PROP_U32(prop, 0, 3 << 11);
+ SET_PROP_U32(prop, 1, 0);
+ SET_PROP_U32(prop, 2, 0);
+ SET_PROP_U32(prop, 3, 7);
+ fdt_property_placeholder(fdt, "interrupt-map",
+ 160 * sizeof(uint32_t), &prop);
+ for (i = 0; i < 16; ++i) {
+ pin = i % 4;
+ slot = i / 4;
+ intr = intrs[(pin + slot) % 4];
+ assert(intr >= GIC_FIRST_SPI);
+ SET_PROP_U32(prop, 10 * i + 0, slot << 11);
+ SET_PROP_U32(prop, 10 * i + 1, 0);
+ SET_PROP_U32(prop, 10 * i + 2, 0);
+ SET_PROP_U32(prop, 10 * i + 3, pin + 1);
+ SET_PROP_U32(prop, 10 * i + 4, gic_phandle);
+ SET_PROP_U32(prop, 10 * i + 5, 0);
+ SET_PROP_U32(prop, 10 * i + 6, 0);
+ SET_PROP_U32(prop, 10 * i + 7, GIC_SPI);
+ SET_PROP_U32(prop, 10 * i + 8, intr - GIC_FIRST_SPI);
+ SET_PROP_U32(prop, 10 * i + 9, IRQ_TYPE_LEVEL_HIGH);
+ }
+
+ fdt_end_node(fdt);
+}
+
+void
+fdt_finalize(void)
+{
+ fdt_end_node(fdtroot);
+
+ fdt_finish(fdtroot);
+}
diff --git a/usr.sbin/bhyve/aarch64/fdt.h b/usr.sbin/bhyve/aarch64/fdt.h
new file mode 100644
index 000000000000..c19d19d34a46
--- /dev/null
+++ b/usr.sbin/bhyve/aarch64/fdt.h
@@ -0,0 +1,48 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 The FreeBSD Foundation
+ *
+ * This software was developed by Andrew Turner under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _FDT_H_
+#define _FDT_H_
+
+#include <sys/types.h>
+
+struct vmctx;
+
+int fdt_init(struct vmctx *ctx, int ncpu, vm_paddr_t addrp,
+ vm_size_t size);
+void fdt_add_gic(uint64_t dist_base, uint64_t dist_size,
+ uint64_t redist_base, uint64_t redist_size);
+void fdt_add_timer(void);
+void fdt_add_pcie(int intrs[static 4]);
+void fdt_add_uart(uint64_t uart_base, uint64_t uart_size, int intr);
+void fdt_add_rtc(uint64_t rtc_base, uint64_t rtc_size, int intr);
+void fdt_finalize(void);
+
+#endif /* _FDT_H_ */
diff --git a/usr.sbin/bhyve/aarch64/pci_irq.c b/usr.sbin/bhyve/aarch64/pci_irq.c
new file mode 100644
index 000000000000..f2c4602fe2e9
--- /dev/null
+++ b/usr.sbin/bhyve/aarch64/pci_irq.c
@@ -0,0 +1,66 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Jessica Clarke <jrtc27@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <vmmapi.h>
+
+#include "pci_emul.h"
+#include "pci_irq.h"
+
+static int gic_irqs[4];
+
+void
+pci_irq_init(int intrs[static 4])
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ gic_irqs[i] = intrs[i];
+}
+
+void
+pci_irq_assert(struct pci_devinst *pi)
+{
+ vm_assert_irq(pi->pi_vmctx, pi->pi_lintr.irq.gic_irq);
+}
+
+void
+pci_irq_deassert(struct pci_devinst *pi)
+{
+ vm_deassert_irq(pi->pi_vmctx, pi->pi_lintr.irq.gic_irq);
+}
+
+void
+pci_irq_route(struct pci_devinst *pi, struct pci_irq *irq)
+{
+ /*
+ * Assign swizzled IRQ for this INTx if one is not yet assigned. Must
+ * match fdt_add_pcie().
+ */
+ if (irq->gic_irq == 0)
+ irq->gic_irq =
+ gic_irqs[(pi->pi_slot + pi->pi_lintr.pin - 1) % 4];
+}
diff --git a/usr.sbin/bhyve/aarch64/pci_irq_machdep.h b/usr.sbin/bhyve/aarch64/pci_irq_machdep.h
new file mode 100644
index 000000000000..c10af3aa53b2
--- /dev/null
+++ b/usr.sbin/bhyve/aarch64/pci_irq_machdep.h
@@ -0,0 +1,49 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Jessica Clarke <jrtc27@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __PCI_IRQ_MD_H__
+#define __PCI_IRQ_MD_H__
+
+struct pci_irq {
+ int gic_irq;
+};
+
+void pci_irq_init(int intrs[static 4]);
+
+static inline void
+pci_irq_init_irq(struct pci_irq *irq)
+{
+ irq->gic_irq = 0;
+}
+
+static inline uint8_t
+pci_irq_intline(struct pci_irq *irq __unused)
+{
+ return (255);
+}
+
+#endif
diff --git a/usr.sbin/bhyve/aarch64/vmexit.c b/usr.sbin/bhyve/aarch64/vmexit.c
new file mode 100644
index 000000000000..0d328ab4ff85
--- /dev/null
+++ b/usr.sbin/bhyve/aarch64/vmexit.c
@@ -0,0 +1,260 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2011 NetApp, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/cpuset.h>
+
+#include <dev/psci/psci.h>
+#include <dev/psci/smccc.h>
+
+#include <machine/armreg.h>
+#include <machine/cpu.h>
+#include <machine/vmm.h>
+#include <machine/vmm_dev.h>
+#include <machine/vmm_instruction_emul.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <vmmapi.h>
+
+#include "bhyverun.h"
+#include "config.h"
+#include "debug.h"
+#include "mem.h"
+#include "vmexit.h"
+
+static cpuset_t running_cpumask;
+
+static int
+vmexit_inst_emul(struct vmctx *ctx __unused, struct vcpu *vcpu,
+ struct vm_run *vmrun)
+{
+ struct vm_exit *vme;
+ struct vie *vie;
+ int err;
+
+ vme = vmrun->vm_exit;
+ vie = &vme->u.inst_emul.vie;
+
+ err = emulate_mem(vcpu, vme->u.inst_emul.gpa, vie,
+ &vme->u.inst_emul.paging);
+ if (err) {
+ if (err == ESRCH) {
+ EPRINTLN("Unhandled memory access to 0x%lx\n",
+ vme->u.inst_emul.gpa);
+ }
+ goto fail;
+ }
+
+ return (VMEXIT_CONTINUE);
+
+fail:
+ fprintf(stderr, "Failed to emulate instruction ");
+ FPRINTLN(stderr, "at 0x%lx", vme->pc);
+ return (VMEXIT_ABORT);
+}
+
+static int
+vmexit_suspend(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun)
+{
+ struct vm_exit *vme;
+ enum vm_suspend_how how;
+ int vcpuid = vcpu_id(vcpu);
+
+ vme = vmrun->vm_exit;
+ how = vme->u.suspended.how;
+
+ fbsdrun_deletecpu(vcpuid);
+
+ switch (how) {
+ case VM_SUSPEND_RESET:
+ exit(0);
+ case VM_SUSPEND_POWEROFF:
+ if (get_config_bool_default("destroy_on_poweroff", false))
+ vm_destroy(ctx);
+ exit(1);
+ case VM_SUSPEND_HALT:
+ exit(2);
+ default:
+ fprintf(stderr, "vmexit_suspend: invalid reason %d\n", how);
+ exit(100);
+ }
+ return (0); /* NOTREACHED */
+}
+
+static int
+vmexit_debug(struct vmctx *ctx __unused, struct vcpu *vcpu __unused,
+ struct vm_run *vmrun __unused)
+{
+ return (VMEXIT_CONTINUE);
+}
+
+static int
+vmexit_bogus(struct vmctx *ctx __unused, struct vcpu *vcpu __unused,
+ struct vm_run *vmrun __unused)
+{
+ return (VMEXIT_CONTINUE);
+}
+
+static uint64_t
+smccc_affinity_info(uint64_t target_affinity, uint32_t lowest_affinity_level)
+{
+ uint64_t cpu_aff, mask = 0;
+
+ switch (lowest_affinity_level) {
+ case 0:
+ mask |= CPU_AFF0_MASK;
+ /* FALLTHROUGH */
+ case 1:
+ mask |= CPU_AFF1_MASK;
+ /* FALLTHROUGH */
+ case 2:
+ mask |= CPU_AFF2_MASK;
+ /* FALLTHROUGH */
+ case 3:
+ mask |= CPU_AFF3_MASK;
+ break;
+ default:
+ return (PSCI_RETVAL_INVALID_PARAMS);
+ }
+
+ for (int vcpu = 0; vcpu < guest_ncpus; vcpu++) {
+ /* TODO: We should get this from the kernel */
+ cpu_aff = (vcpu & 0xf) << MPIDR_AFF0_SHIFT |
+ ((vcpu >> 4) & 0xff) << MPIDR_AFF1_SHIFT |
+ ((vcpu >> 12) & 0xff) << MPIDR_AFF2_SHIFT |
+ (uint64_t)((vcpu >> 20) & 0xff) << MPIDR_AFF3_SHIFT;
+
+ if ((cpu_aff & mask) == (target_affinity & mask) &&
+ CPU_ISSET(vcpu, &running_cpumask)) {
+ /* Return ON if any CPUs are on */
+ return (PSCI_AFFINITY_INFO_ON);
+ }
+ }
+
+ /* No CPUs in the affinity mask are on, return OFF */
+ return (PSCI_AFFINITY_INFO_OFF);
+}
+
+static int
+vmexit_smccc(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun)
+{
+ struct vcpu *newvcpu;
+ struct vm_exit *vme;
+ uint64_t newcpu, smccc_rv;
+ enum vm_suspend_how how;
+ int error;
+
+ /* Return the Unknown Function Identifier by default */
+ smccc_rv = SMCCC_RET_NOT_SUPPORTED;
+
+ vme = vmrun->vm_exit;
+ switch (vme->u.smccc_call.func_id) {
+ case PSCI_FNID_VERSION:
+ /* We implement PSCI 1.0 */
+ smccc_rv = PSCI_VER(1, 0);
+ break;
+ case PSCI_FNID_CPU_SUSPEND:
+ case PSCI_FNID_CPU_OFF:
+ break;
+ case PSCI_FNID_CPU_ON:
+ newcpu = vme->u.smccc_call.args[0];
+ if (newcpu > (uint64_t)guest_ncpus) {
+ smccc_rv = PSCI_RETVAL_INVALID_PARAMS;
+ break;
+ }
+
+ if (CPU_ISSET(newcpu, &running_cpumask)) {
+ smccc_rv = PSCI_RETVAL_ALREADY_ON;
+ break;
+ }
+
+ newvcpu = fbsdrun_vcpu(newcpu);
+ assert(newvcpu != NULL);
+
+ /* Set the context ID */
+ error = vm_set_register(newvcpu, VM_REG_GUEST_X0,
+ vme->u.smccc_call.args[2]);
+ assert(error == 0);
+
+ /* Set the start program counter */
+ error = vm_set_register(newvcpu, VM_REG_GUEST_PC,
+ vme->u.smccc_call.args[1]);
+ assert(error == 0);
+
+ vm_resume_cpu(newvcpu);
+ CPU_SET_ATOMIC(newcpu, &running_cpumask);
+
+ smccc_rv = PSCI_RETVAL_SUCCESS;
+ break;
+ case PSCI_FNID_AFFINITY_INFO:
+ smccc_rv = smccc_affinity_info(vme->u.smccc_call.args[0],
+ vme->u.smccc_call.args[1]);
+ break;
+ case PSCI_FNID_SYSTEM_OFF:
+ case PSCI_FNID_SYSTEM_RESET:
+ if (vme->u.smccc_call.func_id == PSCI_FNID_SYSTEM_OFF)
+ how = VM_SUSPEND_POWEROFF;
+ else
+ how = VM_SUSPEND_RESET;
+ vm_suspend(ctx, how);
+ break;
+ default:
+ break;
+ }
+
+ error = vm_set_register(vcpu, VM_REG_GUEST_X0, smccc_rv);
+ assert(error == 0);
+
+ return (VMEXIT_CONTINUE);
+}
+
+static int
+vmexit_hyp(struct vmctx *ctx __unused, struct vcpu *vcpu __unused,
+ struct vm_run *vmrun)
+{
+ struct vm_exit *vme;
+
+ vme = vmrun->vm_exit;
+ printf("unhandled exception: esr %#lx, far %#lx\n",
+ vme->u.hyp.esr_el2, vme->u.hyp.far_el2);
+ return (VMEXIT_ABORT);
+}
+
+const vmexit_handler_t vmexit_handlers[VM_EXITCODE_MAX] = {
+ [VM_EXITCODE_BOGUS] = vmexit_bogus,
+ [VM_EXITCODE_INST_EMUL] = vmexit_inst_emul,
+ [VM_EXITCODE_SUSPENDED] = vmexit_suspend,
+ [VM_EXITCODE_DEBUG] = vmexit_debug,
+ [VM_EXITCODE_SMCCC] = vmexit_smccc,
+ [VM_EXITCODE_HYP] = vmexit_hyp,
+};
diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c
index 35dbf4704aab..85864da57af2 100644
--- a/usr.sbin/bhyve/acpi.c
+++ b/usr.sbin/bhyve/acpi.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 NetApp, Inc.
* All rights reserved.
@@ -24,45 +24,27 @@
* 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$
*/
/*
* bhyve ACPI table generator.
*
* Create the minimal set of ACPI tables required to boot FreeBSD (and
- * hopefully other o/s's) by writing out ASL template files for each of
- * the tables and the compiling them to AML with the Intel iasl compiler.
- * The AML files are then read into guest memory.
+ * hopefully other o/s's).
*
- * The tables are placed in the guest's ROM area just below 1MB physical,
+ * The tables are placed in the guest's ROM area just below 1MB physical,
* above the MPTable.
- *
- * Layout (No longer correct at FADT and beyond due to properly
- * calculating the size of the MADT to allow for changes to
- * VM_MAXCPU above 21 which overflows this layout.)
- * ------
- * RSDP -> 0xf2400 (36 bytes fixed)
- * RSDT -> 0xf2440 (36 bytes + 4*7 table addrs, 4 used)
- * XSDT -> 0xf2480 (36 bytes + 8*7 table addrs, 4 used)
- * MADT -> 0xf2500 (depends on #CPUs)
- * FADT -> 0xf2600 (268 bytes)
- * HPET -> 0xf2740 (56 bytes)
- * MCFG -> 0xf2780 (60 bytes)
- * FACS -> 0xf27C0 (64 bytes)
- * DSDT -> 0xf2800 (variable - can go up to 0x100000)
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
+#include <sys/endian.h>
#include <sys/errno.h>
#include <sys/stat.h>
+#include <err.h>
#include <paths.h>
#include <stdarg.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -73,45 +55,21 @@ __FBSDID("$FreeBSD$");
#include "bhyverun.h"
#include "acpi.h"
+#include "basl.h"
#include "pci_emul.h"
#include "vmgenc.h"
-/*
- * Define the base address of the ACPI tables, the sizes of some tables,
- * and the offsets to the individual tables,
- */
-#define BHYVE_ACPI_BASE 0xf2400
-#define RSDT_OFFSET 0x040
-#define XSDT_OFFSET 0x080
-#define MADT_OFFSET 0x100
-/*
- * The MADT consists of:
- * 44 Fixed Header
- * 8 * maxcpu Processor Local APIC entries
- * 12 I/O APIC entry
- * 2 * 10 Interrupt Source Override entries
- * 6 Local APIC NMI entry
- */
-#define MADT_SIZE roundup2((44 + basl_ncpu*8 + 12 + 2*10 + 6), 0x100)
-#define FADT_OFFSET (MADT_OFFSET + MADT_SIZE)
-#define FADT_SIZE 0x140
-#define HPET_OFFSET (FADT_OFFSET + FADT_SIZE)
-#define HPET_SIZE 0x40
-#define MCFG_OFFSET (HPET_OFFSET + HPET_SIZE)
-#define MCFG_SIZE 0x40
-#define FACS_OFFSET (MCFG_OFFSET + MCFG_SIZE)
-#define FACS_SIZE 0x40
-#define DSDT_OFFSET (FACS_OFFSET + FACS_SIZE)
-
#define BHYVE_ASL_TEMPLATE "bhyve.XXXXXXX"
#define BHYVE_ASL_SUFFIX ".aml"
#define BHYVE_ASL_COMPILER "/usr/sbin/iasl"
+#define BHYVE_ADDRESS_IOAPIC 0xFEC00000
+#define BHYVE_ADDRESS_HPET 0xFED00000
+#define BHYVE_ADDRESS_LAPIC 0xFEE00000
+
static int basl_keep_temps;
static int basl_verbose_iasl;
static int basl_ncpu;
-static uint32_t basl_acpi_base = BHYVE_ACPI_BASE;
-static uint32_t hpet_capabilities;
/*
* Contains the full pathname of the template to be passed
@@ -134,517 +92,33 @@ struct basl_fio {
};
#define EFPRINTF(...) \
- if (fprintf(__VA_ARGS__) < 0) goto err_exit;
+ if (fprintf(__VA_ARGS__) < 0) goto err_exit
#define EFFLUSH(x) \
- if (fflush(x) != 0) goto err_exit;
-
-static int
-basl_fwrite_rsdp(FILE *fp)
-{
- EFPRINTF(fp, "/*\n");
- EFPRINTF(fp, " * bhyve RSDP template\n");
- EFPRINTF(fp, " */\n");
- EFPRINTF(fp, "[0008]\t\tSignature : \"RSD PTR \"\n");
- EFPRINTF(fp, "[0001]\t\tChecksum : 43\n");
- EFPRINTF(fp, "[0006]\t\tOem ID : \"BHYVE \"\n");
- EFPRINTF(fp, "[0001]\t\tRevision : 02\n");
- EFPRINTF(fp, "[0004]\t\tRSDT Address : %08X\n",
- basl_acpi_base + RSDT_OFFSET);
- EFPRINTF(fp, "[0004]\t\tLength : 00000024\n");
- EFPRINTF(fp, "[0008]\t\tXSDT Address : 00000000%08X\n",
- basl_acpi_base + XSDT_OFFSET);
- EFPRINTF(fp, "[0001]\t\tExtended Checksum : 00\n");
- EFPRINTF(fp, "[0003]\t\tReserved : 000000\n");
-
- EFFLUSH(fp);
+ if (fflush(x) != 0) goto err_exit
- return (0);
-
-err_exit:
- return (errno);
-}
-
-static int
-basl_fwrite_rsdt(FILE *fp)
-{
- EFPRINTF(fp, "/*\n");
- EFPRINTF(fp, " * bhyve RSDT template\n");
- EFPRINTF(fp, " */\n");
- EFPRINTF(fp, "[0004]\t\tSignature : \"RSDT\"\n");
- EFPRINTF(fp, "[0004]\t\tTable Length : 00000000\n");
- EFPRINTF(fp, "[0001]\t\tRevision : 01\n");
- EFPRINTF(fp, "[0001]\t\tChecksum : 00\n");
- EFPRINTF(fp, "[0006]\t\tOem ID : \"BHYVE \"\n");
- EFPRINTF(fp, "[0008]\t\tOem Table ID : \"BVRSDT \"\n");
- EFPRINTF(fp, "[0004]\t\tOem Revision : 00000001\n");
- /* iasl will fill in the compiler ID/revision fields */
- EFPRINTF(fp, "[0004]\t\tAsl Compiler ID : \"xxxx\"\n");
- EFPRINTF(fp, "[0004]\t\tAsl Compiler Revision : 00000000\n");
- EFPRINTF(fp, "\n");
-
- /* Add in pointers to the MADT, FADT and HPET */
- EFPRINTF(fp, "[0004]\t\tACPI Table Address 0 : %08X\n",
- basl_acpi_base + MADT_OFFSET);
- EFPRINTF(fp, "[0004]\t\tACPI Table Address 1 : %08X\n",
- basl_acpi_base + FADT_OFFSET);
- EFPRINTF(fp, "[0004]\t\tACPI Table Address 2 : %08X\n",
- basl_acpi_base + HPET_OFFSET);
- EFPRINTF(fp, "[0004]\t\tACPI Table Address 3 : %08X\n",
- basl_acpi_base + MCFG_OFFSET);
-
- EFFLUSH(fp);
-
- return (0);
-
-err_exit:
- return (errno);
-}
-
-static int
-basl_fwrite_xsdt(FILE *fp)
-{
- EFPRINTF(fp, "/*\n");
- EFPRINTF(fp, " * bhyve XSDT template\n");
- EFPRINTF(fp, " */\n");
- EFPRINTF(fp, "[0004]\t\tSignature : \"XSDT\"\n");
- EFPRINTF(fp, "[0004]\t\tTable Length : 00000000\n");
- EFPRINTF(fp, "[0001]\t\tRevision : 01\n");
- EFPRINTF(fp, "[0001]\t\tChecksum : 00\n");
- EFPRINTF(fp, "[0006]\t\tOem ID : \"BHYVE \"\n");
- EFPRINTF(fp, "[0008]\t\tOem Table ID : \"BVXSDT \"\n");
- EFPRINTF(fp, "[0004]\t\tOem Revision : 00000001\n");
- /* iasl will fill in the compiler ID/revision fields */
- EFPRINTF(fp, "[0004]\t\tAsl Compiler ID : \"xxxx\"\n");
- EFPRINTF(fp, "[0004]\t\tAsl Compiler Revision : 00000000\n");
- EFPRINTF(fp, "\n");
-
- /* Add in pointers to the MADT, FADT and HPET */
- EFPRINTF(fp, "[0004]\t\tACPI Table Address 0 : 00000000%08X\n",
- basl_acpi_base + MADT_OFFSET);
- EFPRINTF(fp, "[0004]\t\tACPI Table Address 1 : 00000000%08X\n",
- basl_acpi_base + FADT_OFFSET);
- EFPRINTF(fp, "[0004]\t\tACPI Table Address 2 : 00000000%08X\n",
- basl_acpi_base + HPET_OFFSET);
- EFPRINTF(fp, "[0004]\t\tACPI Table Address 3 : 00000000%08X\n",
- basl_acpi_base + MCFG_OFFSET);
-
- EFFLUSH(fp);
-
- return (0);
-
-err_exit:
- return (errno);
-}
+/*
+ * A list for additional ACPI devices like a TPM.
+ */
+struct acpi_device_list_entry {
+ SLIST_ENTRY(acpi_device_list_entry) chain;
+ const struct acpi_device *dev;
+};
+static SLIST_HEAD(acpi_device_list,
+ acpi_device_list_entry) acpi_devices = SLIST_HEAD_INITIALIZER(acpi_devices);
-static int
-basl_fwrite_madt(FILE *fp)
+int
+acpi_tables_add_device(const struct acpi_device *const dev)
{
- int i;
-
- EFPRINTF(fp, "/*\n");
- EFPRINTF(fp, " * bhyve MADT template\n");
- EFPRINTF(fp, " */\n");
- EFPRINTF(fp, "[0004]\t\tSignature : \"APIC\"\n");
- EFPRINTF(fp, "[0004]\t\tTable Length : 00000000\n");
- EFPRINTF(fp, "[0001]\t\tRevision : 01\n");
- EFPRINTF(fp, "[0001]\t\tChecksum : 00\n");
- EFPRINTF(fp, "[0006]\t\tOem ID : \"BHYVE \"\n");
- EFPRINTF(fp, "[0008]\t\tOem Table ID : \"BVMADT \"\n");
- EFPRINTF(fp, "[0004]\t\tOem Revision : 00000001\n");
-
- /* iasl will fill in the compiler ID/revision fields */
- EFPRINTF(fp, "[0004]\t\tAsl Compiler ID : \"xxxx\"\n");
- EFPRINTF(fp, "[0004]\t\tAsl Compiler Revision : 00000000\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp, "[0004]\t\tLocal Apic Address : FEE00000\n");
- EFPRINTF(fp, "[0004]\t\tFlags (decoded below) : 00000001\n");
- EFPRINTF(fp, "\t\t\tPC-AT Compatibility : 1\n");
- EFPRINTF(fp, "\n");
-
- /* Add a Processor Local APIC entry for each CPU */
- for (i = 0; i < basl_ncpu; i++) {
- EFPRINTF(fp, "[0001]\t\tSubtable Type : 00\n");
- EFPRINTF(fp, "[0001]\t\tLength : 08\n");
- /* iasl expects hex values for the proc and apic id's */
- EFPRINTF(fp, "[0001]\t\tProcessor ID : %02x\n", i);
- EFPRINTF(fp, "[0001]\t\tLocal Apic ID : %02x\n", i);
- EFPRINTF(fp, "[0004]\t\tFlags (decoded below) : 00000001\n");
- EFPRINTF(fp, "\t\t\tProcessor Enabled : 1\n");
- EFPRINTF(fp, "\t\t\tRuntime Online Capable : 0\n");
- EFPRINTF(fp, "\n");
+ struct acpi_device_list_entry *const entry = calloc(1, sizeof(*entry));
+ if (entry == NULL) {
+ return (ENOMEM);
}
- /* Always a single IOAPIC entry, with ID 0 */
- EFPRINTF(fp, "[0001]\t\tSubtable Type : 01\n");
- EFPRINTF(fp, "[0001]\t\tLength : 0C\n");
- /* iasl expects a hex value for the i/o apic id */
- EFPRINTF(fp, "[0001]\t\tI/O Apic ID : %02x\n", 0);
- EFPRINTF(fp, "[0001]\t\tReserved : 00\n");
- EFPRINTF(fp, "[0004]\t\tAddress : fec00000\n");
- EFPRINTF(fp, "[0004]\t\tInterrupt : 00000000\n");
- EFPRINTF(fp, "\n");
-
- /* Legacy IRQ0 is connected to pin 2 of the IOAPIC */
- EFPRINTF(fp, "[0001]\t\tSubtable Type : 02\n");
- EFPRINTF(fp, "[0001]\t\tLength : 0A\n");
- EFPRINTF(fp, "[0001]\t\tBus : 00\n");
- EFPRINTF(fp, "[0001]\t\tSource : 00\n");
- EFPRINTF(fp, "[0004]\t\tInterrupt : 00000002\n");
- EFPRINTF(fp, "[0002]\t\tFlags (decoded below) : 0005\n");
- EFPRINTF(fp, "\t\t\tPolarity : 1\n");
- EFPRINTF(fp, "\t\t\tTrigger Mode : 1\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp, "[0001]\t\tSubtable Type : 02\n");
- EFPRINTF(fp, "[0001]\t\tLength : 0A\n");
- EFPRINTF(fp, "[0001]\t\tBus : 00\n");
- EFPRINTF(fp, "[0001]\t\tSource : %02X\n", SCI_INT);
- EFPRINTF(fp, "[0004]\t\tInterrupt : %08X\n", SCI_INT);
- EFPRINTF(fp, "[0002]\t\tFlags (decoded below) : 0000\n");
- EFPRINTF(fp, "\t\t\tPolarity : 3\n");
- EFPRINTF(fp, "\t\t\tTrigger Mode : 3\n");
- EFPRINTF(fp, "\n");
-
- /* Local APIC NMI is connected to LINT 1 on all CPUs */
- EFPRINTF(fp, "[0001]\t\tSubtable Type : 04\n");
- EFPRINTF(fp, "[0001]\t\tLength : 06\n");
- EFPRINTF(fp, "[0001]\t\tProcessor ID : FF\n");
- EFPRINTF(fp, "[0002]\t\tFlags (decoded below) : 0005\n");
- EFPRINTF(fp, "\t\t\tPolarity : 1\n");
- EFPRINTF(fp, "\t\t\tTrigger Mode : 1\n");
- EFPRINTF(fp, "[0001]\t\tInterrupt Input LINT : 01\n");
- EFPRINTF(fp, "\n");
-
- EFFLUSH(fp);
-
- return (0);
-
-err_exit:
- return (errno);
-}
-
-static int
-basl_fwrite_fadt(FILE *fp)
-{
- EFPRINTF(fp, "/*\n");
- EFPRINTF(fp, " * bhyve FADT template\n");
- EFPRINTF(fp, " */\n");
- EFPRINTF(fp, "[0004]\t\tSignature : \"FACP\"\n");
- EFPRINTF(fp, "[0004]\t\tTable Length : 0000010C\n");
- EFPRINTF(fp, "[0001]\t\tRevision : 05\n");
- EFPRINTF(fp, "[0001]\t\tChecksum : 00\n");
- EFPRINTF(fp, "[0006]\t\tOem ID : \"BHYVE \"\n");
- EFPRINTF(fp, "[0008]\t\tOem Table ID : \"BVFACP \"\n");
- EFPRINTF(fp, "[0004]\t\tOem Revision : 00000001\n");
- /* iasl will fill in the compiler ID/revision fields */
- EFPRINTF(fp, "[0004]\t\tAsl Compiler ID : \"xxxx\"\n");
- EFPRINTF(fp, "[0004]\t\tAsl Compiler Revision : 00000000\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp, "[0004]\t\tFACS Address : %08X\n",
- basl_acpi_base + FACS_OFFSET);
- EFPRINTF(fp, "[0004]\t\tDSDT Address : %08X\n",
- basl_acpi_base + DSDT_OFFSET);
- EFPRINTF(fp, "[0001]\t\tModel : 01\n");
- EFPRINTF(fp, "[0001]\t\tPM Profile : 00 [Unspecified]\n");
- EFPRINTF(fp, "[0002]\t\tSCI Interrupt : %04X\n",
- SCI_INT);
- EFPRINTF(fp, "[0004]\t\tSMI Command Port : %08X\n",
- SMI_CMD);
- EFPRINTF(fp, "[0001]\t\tACPI Enable Value : %02X\n",
- BHYVE_ACPI_ENABLE);
- EFPRINTF(fp, "[0001]\t\tACPI Disable Value : %02X\n",
- BHYVE_ACPI_DISABLE);
- EFPRINTF(fp, "[0001]\t\tS4BIOS Command : 00\n");
- EFPRINTF(fp, "[0001]\t\tP-State Control : 00\n");
- EFPRINTF(fp, "[0004]\t\tPM1A Event Block Address : %08X\n",
- PM1A_EVT_ADDR);
- EFPRINTF(fp, "[0004]\t\tPM1B Event Block Address : 00000000\n");
- EFPRINTF(fp, "[0004]\t\tPM1A Control Block Address : %08X\n",
- PM1A_CNT_ADDR);
- EFPRINTF(fp, "[0004]\t\tPM1B Control Block Address : 00000000\n");
- EFPRINTF(fp, "[0004]\t\tPM2 Control Block Address : 00000000\n");
- EFPRINTF(fp, "[0004]\t\tPM Timer Block Address : %08X\n",
- IO_PMTMR);
- EFPRINTF(fp, "[0004]\t\tGPE0 Block Address : %08X\n", IO_GPE0_BLK);
- EFPRINTF(fp, "[0004]\t\tGPE1 Block Address : 00000000\n");
- EFPRINTF(fp, "[0001]\t\tPM1 Event Block Length : 04\n");
- EFPRINTF(fp, "[0001]\t\tPM1 Control Block Length : 02\n");
- EFPRINTF(fp, "[0001]\t\tPM2 Control Block Length : 00\n");
- EFPRINTF(fp, "[0001]\t\tPM Timer Block Length : 04\n");
- EFPRINTF(fp, "[0001]\t\tGPE0 Block Length : %02x\n", IO_GPE0_LEN);
- EFPRINTF(fp, "[0001]\t\tGPE1 Block Length : 00\n");
- EFPRINTF(fp, "[0001]\t\tGPE1 Base Offset : 00\n");
- EFPRINTF(fp, "[0001]\t\t_CST Support : 00\n");
- EFPRINTF(fp, "[0002]\t\tC2 Latency : 0000\n");
- EFPRINTF(fp, "[0002]\t\tC3 Latency : 0000\n");
- EFPRINTF(fp, "[0002]\t\tCPU Cache Size : 0000\n");
- EFPRINTF(fp, "[0002]\t\tCache Flush Stride : 0000\n");
- EFPRINTF(fp, "[0001]\t\tDuty Cycle Offset : 00\n");
- EFPRINTF(fp, "[0001]\t\tDuty Cycle Width : 00\n");
- EFPRINTF(fp, "[0001]\t\tRTC Day Alarm Index : 00\n");
- EFPRINTF(fp, "[0001]\t\tRTC Month Alarm Index : 00\n");
- EFPRINTF(fp, "[0001]\t\tRTC Century Index : 32\n");
- EFPRINTF(fp, "[0002]\t\tBoot Flags (decoded below) : 0000\n");
- EFPRINTF(fp, "\t\t\tLegacy Devices Supported (V2) : 0\n");
- EFPRINTF(fp, "\t\t\t8042 Present on ports 60/64 (V2) : 0\n");
- EFPRINTF(fp, "\t\t\tVGA Not Present (V4) : 1\n");
- EFPRINTF(fp, "\t\t\tMSI Not Supported (V4) : 0\n");
- EFPRINTF(fp, "\t\t\tPCIe ASPM Not Supported (V4) : 1\n");
- EFPRINTF(fp, "\t\t\tCMOS RTC Not Present (V5) : 0\n");
- EFPRINTF(fp, "[0001]\t\tReserved : 00\n");
- EFPRINTF(fp, "[0004]\t\tFlags (decoded below) : 00000000\n");
- EFPRINTF(fp, "\t\t\tWBINVD instruction is operational (V1) : 1\n");
- EFPRINTF(fp, "\t\t\tWBINVD flushes all caches (V1) : 0\n");
- EFPRINTF(fp, "\t\t\tAll CPUs support C1 (V1) : 1\n");
- EFPRINTF(fp, "\t\t\tC2 works on MP system (V1) : 0\n");
- EFPRINTF(fp, "\t\t\tControl Method Power Button (V1) : 0\n");
- EFPRINTF(fp, "\t\t\tControl Method Sleep Button (V1) : 1\n");
- EFPRINTF(fp, "\t\t\tRTC wake not in fixed reg space (V1) : 0\n");
- EFPRINTF(fp, "\t\t\tRTC can wake system from S4 (V1) : 0\n");
- EFPRINTF(fp, "\t\t\t32-bit PM Timer (V1) : 1\n");
- EFPRINTF(fp, "\t\t\tDocking Supported (V1) : 0\n");
- EFPRINTF(fp, "\t\t\tReset Register Supported (V2) : 1\n");
- EFPRINTF(fp, "\t\t\tSealed Case (V3) : 0\n");
- EFPRINTF(fp, "\t\t\tHeadless - No Video (V3) : 1\n");
- EFPRINTF(fp, "\t\t\tUse native instr after SLP_TYPx (V3) : 0\n");
- EFPRINTF(fp, "\t\t\tPCIEXP_WAK Bits Supported (V4) : 0\n");
- EFPRINTF(fp, "\t\t\tUse Platform Timer (V4) : 0\n");
- EFPRINTF(fp, "\t\t\tRTC_STS valid on S4 wake (V4) : 0\n");
- EFPRINTF(fp, "\t\t\tRemote Power-on capable (V4) : 0\n");
- EFPRINTF(fp, "\t\t\tUse APIC Cluster Model (V4) : 0\n");
- EFPRINTF(fp, "\t\t\tUse APIC Physical Destination Mode (V4) : 1\n");
- EFPRINTF(fp, "\t\t\tHardware Reduced (V5) : 0\n");
- EFPRINTF(fp, "\t\t\tLow Power S0 Idle (V5) : 0\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp,
- "[0012]\t\tReset Register : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 01 [SystemIO]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : 08\n");
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp, "[0001]\t\tEncoded Access Width : 01 [Byte Access:8]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : 0000000000000CF9\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp, "[0001]\t\tValue to cause reset : 06\n");
- EFPRINTF(fp, "[0002]\t\tARM Flags (decoded below): 0000\n");
- EFPRINTF(fp, "\t\t\tPSCI Compliant : 0\n");
- EFPRINTF(fp, "\t\t\tMust use HVC for PSCI : 0\n");
- EFPRINTF(fp, "[0001]\t\tFADT Minor Revision : 01\n");
- EFPRINTF(fp, "[0008]\t\tFACS Address : 00000000%08X\n",
- basl_acpi_base + FACS_OFFSET);
- EFPRINTF(fp, "[0008]\t\tDSDT Address : 00000000%08X\n",
- basl_acpi_base + DSDT_OFFSET);
- EFPRINTF(fp,
- "[0012]\t\tPM1A Event Block : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 01 [SystemIO]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : 20\n");
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp, "[0001]\t\tEncoded Access Width : 02 [Word Access:16]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : 00000000%08X\n",
- PM1A_EVT_ADDR);
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp,
- "[0012]\t\tPM1B Event Block : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 01 [SystemIO]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : 00\n");
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp,
- "[0001]\t\tEncoded Access Width : 00 [Undefined/Legacy]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : 0000000000000000\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp,
- "[0012]\t\tPM1A Control Block : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 01 [SystemIO]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : 10\n");
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp, "[0001]\t\tEncoded Access Width : 02 [Word Access:16]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : 00000000%08X\n",
- PM1A_CNT_ADDR);
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp,
- "[0012]\t\tPM1B Control Block : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 01 [SystemIO]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : 00\n");
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp,
- "[0001]\t\tEncoded Access Width : 00 [Undefined/Legacy]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : 0000000000000000\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp,
- "[0012]\t\tPM2 Control Block : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 01 [SystemIO]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : 08\n");
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp,
- "[0001]\t\tEncoded Access Width : 00 [Undefined/Legacy]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : 0000000000000000\n");
- EFPRINTF(fp, "\n");
-
- /* Valid for bhyve */
- EFPRINTF(fp,
- "[0012]\t\tPM Timer Block : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 01 [SystemIO]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : 20\n");
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp,
- "[0001]\t\tEncoded Access Width : 03 [DWord Access:32]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : 00000000%08X\n",
- IO_PMTMR);
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp, "[0012]\t\tGPE0 Block : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 01 [SystemIO]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : %02x\n", IO_GPE0_LEN * 8);
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp, "[0001]\t\tEncoded Access Width : 01 [Byte Access:8]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : %016X\n", IO_GPE0_BLK);
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp, "[0012]\t\tGPE1 Block : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 01 [SystemIO]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : 00\n");
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp,
- "[0001]\t\tEncoded Access Width : 00 [Undefined/Legacy]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : 0000000000000000\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp,
- "[0012]\t\tSleep Control Register : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 01 [SystemIO]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : 08\n");
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp, "[0001]\t\tEncoded Access Width : 01 [Byte Access:8]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : 0000000000000000\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp,
- "[0012]\t\tSleep Status Register : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 01 [SystemIO]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : 08\n");
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp, "[0001]\t\tEncoded Access Width : 01 [Byte Access:8]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : 0000000000000000\n");
-
- EFFLUSH(fp);
-
- return (0);
-
-err_exit:
- return (errno);
-}
-
-static int
-basl_fwrite_hpet(FILE *fp)
-{
- EFPRINTF(fp, "/*\n");
- EFPRINTF(fp, " * bhyve HPET template\n");
- EFPRINTF(fp, " */\n");
- EFPRINTF(fp, "[0004]\t\tSignature : \"HPET\"\n");
- EFPRINTF(fp, "[0004]\t\tTable Length : 00000000\n");
- EFPRINTF(fp, "[0001]\t\tRevision : 01\n");
- EFPRINTF(fp, "[0001]\t\tChecksum : 00\n");
- EFPRINTF(fp, "[0006]\t\tOem ID : \"BHYVE \"\n");
- EFPRINTF(fp, "[0008]\t\tOem Table ID : \"BVHPET \"\n");
- EFPRINTF(fp, "[0004]\t\tOem Revision : 00000001\n");
-
- /* iasl will fill in the compiler ID/revision fields */
- EFPRINTF(fp, "[0004]\t\tAsl Compiler ID : \"xxxx\"\n");
- EFPRINTF(fp, "[0004]\t\tAsl Compiler Revision : 00000000\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp, "[0004]\t\tHardware Block ID : %08X\n", hpet_capabilities);
- EFPRINTF(fp,
- "[0012]\t\tTimer Block Register : [Generic Address Structure]\n");
- EFPRINTF(fp, "[0001]\t\tSpace ID : 00 [SystemMemory]\n");
- EFPRINTF(fp, "[0001]\t\tBit Width : 00\n");
- EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n");
- EFPRINTF(fp,
- "[0001]\t\tEncoded Access Width : 00 [Undefined/Legacy]\n");
- EFPRINTF(fp, "[0008]\t\tAddress : 00000000FED00000\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp, "[0001]\t\tSequence Number : 00\n");
- EFPRINTF(fp, "[0002]\t\tMinimum Clock Ticks : 0000\n");
- EFPRINTF(fp, "[0004]\t\tFlags (decoded below) : 00000001\n");
- EFPRINTF(fp, "\t\t\t4K Page Protect : 1\n");
- EFPRINTF(fp, "\t\t\t64K Page Protect : 0\n");
- EFPRINTF(fp, "\n");
-
- EFFLUSH(fp);
+ entry->dev = dev;
+ SLIST_INSERT_HEAD(&acpi_devices, entry, chain);
return (0);
-
-err_exit:
- return (errno);
-}
-
-static int
-basl_fwrite_mcfg(FILE *fp)
-{
- EFPRINTF(fp, "/*\n");
- EFPRINTF(fp, " * bhyve MCFG template\n");
- EFPRINTF(fp, " */\n");
- EFPRINTF(fp, "[0004]\t\tSignature : \"MCFG\"\n");
- EFPRINTF(fp, "[0004]\t\tTable Length : 00000000\n");
- EFPRINTF(fp, "[0001]\t\tRevision : 01\n");
- EFPRINTF(fp, "[0001]\t\tChecksum : 00\n");
- EFPRINTF(fp, "[0006]\t\tOem ID : \"BHYVE \"\n");
- EFPRINTF(fp, "[0008]\t\tOem Table ID : \"BVMCFG \"\n");
- EFPRINTF(fp, "[0004]\t\tOem Revision : 00000001\n");
-
- /* iasl will fill in the compiler ID/revision fields */
- EFPRINTF(fp, "[0004]\t\tAsl Compiler ID : \"xxxx\"\n");
- EFPRINTF(fp, "[0004]\t\tAsl Compiler Revision : 00000000\n");
- EFPRINTF(fp, "[0008]\t\tReserved : 0\n");
- EFPRINTF(fp, "\n");
-
- EFPRINTF(fp, "[0008]\t\tBase Address : %016lX\n", pci_ecfg_base());
- EFPRINTF(fp, "[0002]\t\tSegment Group Number : 0000\n");
- EFPRINTF(fp, "[0001]\t\tStart Bus Number : 00\n");
- EFPRINTF(fp, "[0001]\t\tEnd Bus Number : FF\n");
- EFPRINTF(fp, "[0004]\t\tReserved : 0\n");
- EFFLUSH(fp);
- return (0);
-err_exit:
- return (errno);
-}
-
-static int
-basl_fwrite_facs(FILE *fp)
-{
- EFPRINTF(fp, "/*\n");
- EFPRINTF(fp, " * bhyve FACS template\n");
- EFPRINTF(fp, " */\n");
- EFPRINTF(fp, "[0004]\t\tSignature : \"FACS\"\n");
- EFPRINTF(fp, "[0004]\t\tLength : 00000040\n");
- EFPRINTF(fp, "[0004]\t\tHardware Signature : 00000000\n");
- EFPRINTF(fp, "[0004]\t\t32 Firmware Waking Vector : 00000000\n");
- EFPRINTF(fp, "[0004]\t\tGlobal Lock : 00000000\n");
- EFPRINTF(fp, "[0004]\t\tFlags (decoded below) : 00000000\n");
- EFPRINTF(fp, "\t\t\tS4BIOS Support Present : 0\n");
- EFPRINTF(fp, "\t\t\t64-bit Wake Supported (V2) : 0\n");
- EFPRINTF(fp,
- "[0008]\t\t64 Firmware Waking Vector : 0000000000000000\n");
- EFPRINTF(fp, "[0001]\t\tVersion : 02\n");
- EFPRINTF(fp, "[0003]\t\tReserved : 000000\n");
- EFPRINTF(fp, "[0004]\t\tOspmFlags (decoded below) : 00000000\n");
- EFPRINTF(fp, "\t\t\t64-bit Wake Env Required (V2) : 0\n");
-
- EFFLUSH(fp);
-
- return (0);
-
-err_exit:
- return (errno);
}
/*
@@ -742,6 +216,7 @@ basl_fwrite_dsdt(FILE *fp)
pci_write_dsdt();
+#ifdef __amd64__
dsdt_line("");
dsdt_line(" Scope (_SB.PC00)");
dsdt_line(" {");
@@ -757,9 +232,15 @@ basl_fwrite_dsdt(FILE *fp)
dsdt_line(" })");
dsdt_line(" }");
dsdt_line(" }");
+#endif
vmgenc_write_dsdt();
+ const struct acpi_device_list_entry *entry;
+ SLIST_FOREACH(entry, &acpi_devices, chain) {
+ BASL_EXEC(acpi_device_write_dsdt(entry->dev));
+ }
+
dsdt_line("}");
if (dsdt_error != 0)
@@ -835,30 +316,38 @@ basl_end(struct basl_fio *in, struct basl_fio *out)
}
static int
-basl_load(struct vmctx *ctx, int fd, uint64_t off)
+basl_load(struct vmctx *ctx, int fd)
{
struct stat sb;
- void *gaddr;
+ void *addr;
if (fstat(fd, &sb) < 0)
return (errno);
- gaddr = paddr_guest2host(ctx, basl_acpi_base + off, sb.st_size);
- if (gaddr == NULL)
- return (EFAULT);
+ addr = calloc(1, sb.st_size);
+ if (addr == NULL)
+ return (ENOMEM);
- if (read(fd, gaddr, sb.st_size) < 0)
+ if (read(fd, addr, sb.st_size) < 0)
return (errno);
+ struct basl_table *table;
+
+ uint8_t name[ACPI_NAMESEG_SIZE + 1] = { 0 };
+ memcpy(name, addr, sizeof(name) - 1 /* last char is '\0' */);
+ BASL_EXEC(basl_table_create(&table, ctx, name, BASL_TABLE_ALIGNMENT));
+ BASL_EXEC(basl_table_append_bytes(table, addr, sb.st_size));
+
+ free(addr);
return (0);
}
static int
-basl_compile(struct vmctx *ctx, int (*fwrite_section)(FILE *), uint64_t offset)
+basl_compile(struct vmctx *ctx, int (*fwrite_section)(FILE *))
{
struct basl_fio io[2];
static char iaslbuf[3*MAXPATHLEN + 10];
- char *fmt;
+ const char *fmt;
int err;
err = basl_start(&io[0], &io[1]);
@@ -888,7 +377,7 @@ basl_compile(struct vmctx *ctx, int (*fwrite_section)(FILE *), uint64_t offset)
* Copy the aml output file into guest
* memory at the specified location
*/
- err = basl_load(ctx, io[1].fd, offset);
+ err = basl_load(ctx, io[1].fd);
}
}
basl_end(&io[0], &io[1]);
@@ -927,7 +416,7 @@ basl_make_templates(void)
if (!err) {
/*
- * len has been intialized (and maybe adjusted) above
+ * len has been initialized (and maybe adjusted) above
*/
if ((len + sizeof(BHYVE_ASL_TEMPLATE) + 1 +
sizeof(BHYVE_ASL_SUFFIX)) < MAXPATHLEN) {
@@ -943,17 +432,305 @@ basl_make_templates(void)
return (err);
}
-int
-acpi_build(struct vmctx *ctx, int ncpu)
+static int
+build_dsdt(struct vmctx *const ctx)
{
- int err;
+ BASL_EXEC(basl_compile(ctx, basl_fwrite_dsdt));
- basl_ncpu = ncpu;
+ return (0);
+}
+
+static int
+build_facs(struct vmctx *const ctx)
+{
+ ACPI_TABLE_FACS facs;
+ struct basl_table *table;
+
+ BASL_EXEC(basl_table_create(&table, ctx, ACPI_SIG_FACS,
+ BASL_TABLE_ALIGNMENT_FACS));
+
+ memset(&facs, 0, sizeof(facs));
+ memcpy(facs.Signature, ACPI_SIG_FACS, ACPI_NAMESEG_SIZE);
+ facs.Length = sizeof(facs);
+ facs.Version = htole32(2);
+ BASL_EXEC(basl_table_append_bytes(table, &facs, sizeof(facs)));
+
+ return (0);
+}
+
+static int
+build_fadt(struct vmctx *const ctx)
+{
+ ACPI_TABLE_FADT fadt;
+ struct basl_table *table;
+
+ BASL_EXEC(basl_table_create(&table, ctx, ACPI_SIG_FADT,
+ BASL_TABLE_ALIGNMENT));
+
+ memset(&fadt, 0, sizeof(fadt));
+ BASL_EXEC(basl_table_append_header(table, ACPI_SIG_FADT, 5, 1));
+ fadt.Facs = htole32(0); /* patched by basl */
+ fadt.Dsdt = htole32(0); /* patched by basl */
+ fadt.SciInterrupt = htole16(SCI_INT);
+ fadt.SmiCommand = htole32(SMI_CMD);
+ fadt.AcpiEnable = BHYVE_ACPI_ENABLE;
+ fadt.AcpiDisable = BHYVE_ACPI_DISABLE;
+ fadt.Pm1aEventBlock = htole32(PM1A_EVT_ADDR);
+ fadt.Pm1aControlBlock = htole32(PM1A_CNT_ADDR);
+ fadt.PmTimerBlock = htole32(IO_PMTMR);
+ fadt.Gpe0Block = htole32(IO_GPE0_BLK);
+ fadt.Pm1EventLength = 4;
+ fadt.Pm1ControlLength = 2;
+ fadt.PmTimerLength = 4;
+ fadt.Gpe0BlockLength = IO_GPE0_LEN;
+ fadt.Century = 0x32;
+ fadt.BootFlags = htole16(ACPI_FADT_NO_VGA | ACPI_FADT_NO_ASPM);
+ fadt.Flags = htole32(ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED |
+ ACPI_FADT_SLEEP_BUTTON | ACPI_FADT_32BIT_TIMER |
+ ACPI_FADT_RESET_REGISTER | ACPI_FADT_HEADLESS |
+ ACPI_FADT_APIC_PHYSICAL);
+ basl_fill_gas(&fadt.ResetRegister, ACPI_ADR_SPACE_SYSTEM_IO, 8, 0,
+ ACPI_GAS_ACCESS_WIDTH_BYTE, 0xCF9);
+ fadt.ResetValue = 6;
+ fadt.MinorRevision = 1;
+ fadt.XFacs = htole64(0); /* patched by basl */
+ fadt.XDsdt = htole64(0); /* patched by basl */
+ basl_fill_gas(&fadt.XPm1aEventBlock, ACPI_ADR_SPACE_SYSTEM_IO, 0x20, 0,
+ ACPI_GAS_ACCESS_WIDTH_WORD, PM1A_EVT_ADDR);
+ basl_fill_gas(&fadt.XPm1bEventBlock, ACPI_ADR_SPACE_SYSTEM_IO, 0, 0,
+ ACPI_GAS_ACCESS_WIDTH_UNDEFINED, 0);
+ basl_fill_gas(&fadt.XPm1aControlBlock, ACPI_ADR_SPACE_SYSTEM_IO, 0x10,
+ 0, ACPI_GAS_ACCESS_WIDTH_WORD, PM1A_CNT_ADDR);
+ basl_fill_gas(&fadt.XPm1bControlBlock, ACPI_ADR_SPACE_SYSTEM_IO, 0, 0,
+ ACPI_GAS_ACCESS_WIDTH_UNDEFINED, 0);
+ basl_fill_gas(&fadt.XPm2ControlBlock, ACPI_ADR_SPACE_SYSTEM_IO, 8, 0,
+ ACPI_GAS_ACCESS_WIDTH_UNDEFINED, 0);
+ basl_fill_gas(&fadt.XPmTimerBlock, ACPI_ADR_SPACE_SYSTEM_IO, 0x20, 0,
+ ACPI_GAS_ACCESS_WIDTH_DWORD, IO_PMTMR);
+ basl_fill_gas(&fadt.XGpe0Block, ACPI_ADR_SPACE_SYSTEM_IO,
+ IO_GPE0_LEN * 8, 0, ACPI_GAS_ACCESS_WIDTH_BYTE, IO_GPE0_BLK);
+ basl_fill_gas(&fadt.XGpe1Block, ACPI_ADR_SPACE_SYSTEM_IO, 0, 0,
+ ACPI_GAS_ACCESS_WIDTH_UNDEFINED, 0);
+ basl_fill_gas(&fadt.SleepControl, ACPI_ADR_SPACE_SYSTEM_IO, 8, 0,
+ ACPI_GAS_ACCESS_WIDTH_BYTE, 0);
+ basl_fill_gas(&fadt.SleepStatus, ACPI_ADR_SPACE_SYSTEM_IO, 8, 0,
+ ACPI_GAS_ACCESS_WIDTH_BYTE, 0);
+ BASL_EXEC(basl_table_append_content(table, &fadt, sizeof(fadt)));
+
+ BASL_EXEC(basl_table_add_pointer(table, ACPI_SIG_FACS,
+ offsetof(ACPI_TABLE_FADT, Facs), sizeof(fadt.Facs)));
+ BASL_EXEC(basl_table_add_pointer(table, ACPI_SIG_DSDT,
+ offsetof(ACPI_TABLE_FADT, Dsdt), sizeof(fadt.Dsdt)));
+ BASL_EXEC(basl_table_add_pointer(table, ACPI_SIG_FACS,
+ offsetof(ACPI_TABLE_FADT, XFacs), sizeof(fadt.XFacs)));
+ BASL_EXEC(basl_table_add_pointer(table, ACPI_SIG_DSDT,
+ offsetof(ACPI_TABLE_FADT, XDsdt), sizeof(fadt.XDsdt)));
+
+ BASL_EXEC(basl_table_register_to_rsdt(table));
+
+ return (0);
+}
+
+#ifdef __amd64__
+static int
+build_hpet(struct vmctx *const ctx)
+{
+ ACPI_TABLE_HPET hpet;
+ struct basl_table *table;
+ uint32_t hpet_capabilities;
+ int err;
err = vm_get_hpet_capabilities(ctx, &hpet_capabilities);
if (err != 0)
return (err);
+ BASL_EXEC(basl_table_create(&table, ctx, ACPI_SIG_HPET,
+ BASL_TABLE_ALIGNMENT));
+
+ memset(&hpet, 0, sizeof(hpet));
+ BASL_EXEC(basl_table_append_header(table, ACPI_SIG_HPET, 1, 1));
+ hpet.Id = htole32(hpet_capabilities);
+ basl_fill_gas(&hpet.Address, ACPI_ADR_SPACE_SYSTEM_MEMORY, 0, 0,
+ ACPI_GAS_ACCESS_WIDTH_LEGACY, BHYVE_ADDRESS_HPET);
+ hpet.Flags = ACPI_HPET_PAGE_PROTECT4;
+ BASL_EXEC(basl_table_append_content(table, &hpet, sizeof(hpet)));
+
+ BASL_EXEC(basl_table_register_to_rsdt(table));
+
+ return (0);
+}
+#endif
+
+static int
+build_madt(struct vmctx *const ctx)
+{
+ ACPI_TABLE_MADT madt;
+ ACPI_MADT_LOCAL_APIC madt_lapic;
+ ACPI_MADT_IO_APIC madt_ioapic;
+ ACPI_MADT_INTERRUPT_OVERRIDE madt_irq_override;
+ ACPI_MADT_LOCAL_APIC_NMI madt_lapic_nmi;
+ struct basl_table *table;
+
+ BASL_EXEC(basl_table_create(&table, ctx, ACPI_SIG_MADT,
+ BASL_TABLE_ALIGNMENT));
+
+ memset(&madt, 0, sizeof(madt));
+ BASL_EXEC(basl_table_append_header(table, ACPI_SIG_MADT, 1, 1));
+ madt.Address = htole32(BHYVE_ADDRESS_LAPIC);
+ madt.Flags = htole32(ACPI_MADT_PCAT_COMPAT);
+ BASL_EXEC(basl_table_append_content(table, &madt, sizeof(madt)));
+
+ /* Local APIC for each CPU */
+ for (int i = 0; i < basl_ncpu; ++i) {
+ memset(&madt_lapic, 0, sizeof(madt_lapic));
+ madt_lapic.Header.Type = ACPI_MADT_TYPE_LOCAL_APIC;
+ madt_lapic.Header.Length = sizeof(madt_lapic);
+ madt_lapic.ProcessorId = i;
+ madt_lapic.Id = i;
+ madt_lapic.LapicFlags = htole32(ACPI_MADT_ENABLED);
+ BASL_EXEC(basl_table_append_bytes(table, &madt_lapic,
+ sizeof(madt_lapic)));
+ }
+
+ /* I/O APIC */
+ memset(&madt_ioapic, 0, sizeof(madt_ioapic));
+ madt_ioapic.Header.Type = ACPI_MADT_TYPE_IO_APIC;
+ madt_ioapic.Header.Length = sizeof(madt_ioapic);
+ madt_ioapic.Address = htole32(BHYVE_ADDRESS_IOAPIC);
+ BASL_EXEC(
+ basl_table_append_bytes(table, &madt_ioapic, sizeof(madt_ioapic)));
+
+ /* Legacy IRQ0 is connected to pin 2 of the I/O APIC */
+ memset(&madt_irq_override, 0, sizeof(madt_irq_override));
+ madt_irq_override.Header.Type = ACPI_MADT_TYPE_INTERRUPT_OVERRIDE;
+ madt_irq_override.Header.Length = sizeof(madt_irq_override);
+ madt_irq_override.GlobalIrq = htole32(2);
+ madt_irq_override.IntiFlags = htole16(
+ ACPI_MADT_POLARITY_ACTIVE_HIGH | ACPI_MADT_TRIGGER_EDGE);
+ BASL_EXEC(basl_table_append_bytes(table, &madt_irq_override,
+ sizeof(madt_irq_override)));
+
+ memset(&madt_irq_override, 0, sizeof(madt_irq_override));
+ madt_irq_override.Header.Type = ACPI_MADT_TYPE_INTERRUPT_OVERRIDE;
+ madt_irq_override.Header.Length = sizeof(madt_irq_override);
+ madt_irq_override.SourceIrq = SCI_INT;
+ madt_irq_override.GlobalIrq = htole32(SCI_INT);
+ madt_irq_override.IntiFlags = htole16(
+ ACPI_MADT_POLARITY_ACTIVE_LOW | ACPI_MADT_TRIGGER_LEVEL);
+ BASL_EXEC(basl_table_append_bytes(table, &madt_irq_override,
+ sizeof(madt_irq_override)));
+
+ /* Local APIC NMI is conntected to LINT 1 on all CPUs */
+ memset(&madt_lapic_nmi, 0, sizeof(madt_lapic_nmi));
+ madt_lapic_nmi.Header.Type = ACPI_MADT_TYPE_LOCAL_APIC_NMI;
+ madt_lapic_nmi.Header.Length = sizeof(madt_lapic_nmi);
+ madt_lapic_nmi.ProcessorId = 0xFF;
+ madt_lapic_nmi.IntiFlags = htole16(
+ ACPI_MADT_POLARITY_ACTIVE_HIGH | ACPI_MADT_TRIGGER_EDGE);
+ madt_lapic_nmi.Lint = 1;
+ BASL_EXEC(basl_table_append_bytes(table, &madt_lapic_nmi,
+ sizeof(madt_lapic_nmi)));
+
+ BASL_EXEC(basl_table_register_to_rsdt(table));
+
+ return (0);
+}
+
+static int
+build_mcfg(struct vmctx *const ctx)
+{
+ ACPI_TABLE_MCFG mcfg;
+ ACPI_MCFG_ALLOCATION mcfg_allocation;
+ struct basl_table *table;
+
+ BASL_EXEC(basl_table_create(&table, ctx, ACPI_SIG_MCFG,
+ BASL_TABLE_ALIGNMENT));
+
+ memset(&mcfg, 0, sizeof(mcfg));
+ BASL_EXEC(basl_table_append_header(table, ACPI_SIG_MCFG, 1, 1));
+ BASL_EXEC(basl_table_append_content(table, &mcfg, sizeof(mcfg)));
+
+ memset(&mcfg_allocation, 0, sizeof(mcfg_allocation));
+ mcfg_allocation.Address = htole64(pci_ecfg_base());
+ mcfg_allocation.EndBusNumber = 0xFF;
+ BASL_EXEC(basl_table_append_bytes(table, &mcfg_allocation,
+ sizeof(mcfg_allocation)));
+
+ BASL_EXEC(basl_table_register_to_rsdt(table));
+
+ return (0);
+}
+
+static int
+build_rsdp(struct vmctx *const ctx)
+{
+ ACPI_TABLE_RSDP rsdp;
+ struct basl_table *table;
+
+ BASL_EXEC(basl_table_create(&table, ctx, ACPI_RSDP_NAME,
+ BASL_TABLE_ALIGNMENT));
+
+ memset(&rsdp, 0, sizeof(rsdp));
+ memcpy(rsdp.Signature, ACPI_SIG_RSDP, 8);
+ rsdp.Checksum = 0; /* patched by basl */
+ memcpy(rsdp.OemId, "BHYVE ", ACPI_OEM_ID_SIZE);
+ rsdp.Revision = 2;
+ rsdp.RsdtPhysicalAddress = htole32(0); /* patched by basl */
+ rsdp.Length = htole32(0); /* patched by basl */
+ rsdp.XsdtPhysicalAddress = htole64(0); /* patched by basl */
+ rsdp.ExtendedChecksum = 0; /* patched by basl */
+ BASL_EXEC(basl_table_append_bytes(table, &rsdp, sizeof(rsdp)));
+
+ BASL_EXEC(basl_table_add_checksum(table,
+ offsetof(ACPI_TABLE_RSDP, Checksum), 0, 20));
+ BASL_EXEC(basl_table_add_pointer(table, ACPI_SIG_RSDT,
+ offsetof(ACPI_TABLE_RSDP, RsdtPhysicalAddress),
+ sizeof(rsdp.RsdtPhysicalAddress)));
+ BASL_EXEC(basl_table_add_length(table,
+ offsetof(ACPI_TABLE_RSDP, Length), sizeof(rsdp.Length)));
+ BASL_EXEC(basl_table_add_pointer(table, ACPI_SIG_XSDT,
+ offsetof(ACPI_TABLE_RSDP, XsdtPhysicalAddress),
+ sizeof(rsdp.XsdtPhysicalAddress)));
+ BASL_EXEC(basl_table_add_checksum(table,
+ offsetof(ACPI_TABLE_RSDP, ExtendedChecksum), 0,
+ BASL_TABLE_CHECKSUM_LEN_FULL_TABLE));
+
+ return (0);
+}
+
+static int
+build_spcr(struct vmctx *const ctx)
+{
+ ACPI_TABLE_SPCR spcr;
+ struct basl_table *table;
+
+ BASL_EXEC(basl_table_create(&table, ctx, ACPI_SIG_SPCR,
+ BASL_TABLE_ALIGNMENT));
+
+ memset(&spcr, 0, sizeof(spcr));
+ BASL_EXEC(basl_table_append_header(table, ACPI_SIG_SPCR, 1, 1));
+ spcr.InterfaceType = ACPI_DBG2_16550_COMPATIBLE;
+ basl_fill_gas(&spcr.SerialPort, ACPI_ADR_SPACE_SYSTEM_IO, 8, 0,
+ ACPI_GAS_ACCESS_WIDTH_LEGACY, 0x3F8);
+ spcr.InterruptType = ACPI_SPCR_INTERRUPT_TYPE_8259;
+ spcr.PcInterrupt = 4;
+ spcr.BaudRate = ACPI_SPCR_BAUD_RATE_115200;
+ spcr.Parity = ACPI_SPCR_PARITY_NO_PARITY;
+ spcr.StopBits = ACPI_SPCR_STOP_BITS_1;
+ spcr.FlowControl = 3; /* RTS/CTS | DCD */
+ spcr.TerminalType = ACPI_SPCR_TERMINAL_TYPE_VT_UTF8;
+ BASL_EXEC(basl_table_append_content(table, &spcr, sizeof(spcr)));
+
+ BASL_EXEC(basl_table_register_to_rsdt(table));
+
+ return (0);
+}
+
+int
+acpi_build(struct vmctx *ctx, int ncpu)
+{
+ basl_ncpu = ncpu;
+
/*
* For debug, allow the user to have iasl compiler output sent
* to stdout rather than /dev/null
@@ -968,30 +745,36 @@ acpi_build(struct vmctx *ctx, int ncpu)
if (getenv("BHYVE_ACPI_KEEPTMPS"))
basl_keep_temps = 1;
- err = basl_make_templates();
+ BASL_EXEC(basl_init(ctx));
+
+ BASL_EXEC(basl_make_templates());
/*
- * Run through all the ASL files, compiling them and
- * copying them into guest memory
+ * Generate ACPI tables and copy them into guest memory.
+ *
+ * According to UEFI Specification v6.3 chapter 5.1 the FADT should be
+ * the first table pointed to by XSDT. For that reason, build it as the
+ * first table after XSDT.
*/
- if (err == 0)
- err = basl_compile(ctx, basl_fwrite_rsdp, 0);
- if (err == 0)
- err = basl_compile(ctx, basl_fwrite_rsdt, RSDT_OFFSET);
- if (err == 0)
- err = basl_compile(ctx, basl_fwrite_xsdt, XSDT_OFFSET);
- if (err == 0)
- err = basl_compile(ctx, basl_fwrite_madt, MADT_OFFSET);
- if (err == 0)
- err = basl_compile(ctx, basl_fwrite_fadt, FADT_OFFSET);
- if (err == 0)
- err = basl_compile(ctx, basl_fwrite_hpet, HPET_OFFSET);
- if (err == 0)
- err = basl_compile(ctx, basl_fwrite_mcfg, MCFG_OFFSET);
- if (err == 0)
- err = basl_compile(ctx, basl_fwrite_facs, FACS_OFFSET);
- if (err == 0)
- err = basl_compile(ctx, basl_fwrite_dsdt, DSDT_OFFSET);
+ BASL_EXEC(build_rsdp(ctx));
+ BASL_EXEC(build_fadt(ctx));
+ BASL_EXEC(build_madt(ctx));
+#ifdef __amd64__
+ BASL_EXEC(build_hpet(ctx));
+#endif
+ BASL_EXEC(build_mcfg(ctx));
+ BASL_EXEC(build_facs(ctx));
+ BASL_EXEC(build_spcr(ctx));
+
+ /* Build ACPI device-specific tables such as a TPM2 table. */
+ const struct acpi_device_list_entry *entry;
+ SLIST_FOREACH(entry, &acpi_devices, chain) {
+ BASL_EXEC(acpi_device_build_table(entry->dev));
+ }
- return (err);
+ BASL_EXEC(build_dsdt(ctx));
+
+ BASL_EXEC(basl_finish());
+
+ return (0);
}
diff --git a/usr.sbin/bhyve/acpi.h b/usr.sbin/bhyve/acpi.h
index 50e5337f332a..4b557993d67f 100644
--- a/usr.sbin/bhyve/acpi.h
+++ b/usr.sbin/bhyve/acpi.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,13 @@
* 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 _ACPI_H_
#define _ACPI_H_
+#include "acpi_device.h"
+
#define SCI_INT 9
#define SMI_CMD 0xb2
@@ -55,6 +55,7 @@ struct vmctx;
int acpi_build(struct vmctx *ctx, int ncpu);
void acpi_raise_gpe(struct vmctx *ctx, unsigned bit);
+int acpi_tables_add_device(const struct acpi_device *const dev);
void dsdt_line(const char *fmt, ...);
void dsdt_fixed_ioport(uint16_t iobase, uint16_t length);
void dsdt_fixed_irq(uint8_t irq);
diff --git a/usr.sbin/bhyve/acpi_device.c b/usr.sbin/bhyve/acpi_device.c
new file mode 100644
index 000000000000..3def2cf31d8f
--- /dev/null
+++ b/usr.sbin/bhyve/acpi_device.c
@@ -0,0 +1,213 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#include <sys/param.h>
+#include <sys/queue.h>
+
+#include <machine/vmm.h>
+
+#include <assert.h>
+#include <err.h>
+#include <errno.h>
+#include <vmmapi.h>
+
+#include "acpi.h"
+#include "acpi_device.h"
+#include "basl.h"
+
+/**
+ * List entry to enumerate all resources used by an ACPI device.
+ *
+ * @param chain Used to chain multiple elements together.
+ * @param type Type of the ACPI resource.
+ * @param data Data of the ACPI resource.
+ */
+struct acpi_resource_list_entry {
+ SLIST_ENTRY(acpi_resource_list_entry) chain;
+ UINT32 type;
+ ACPI_RESOURCE_DATA data;
+};
+
+/**
+ * Holds information about an ACPI device.
+ *
+ * @param vm_ctx VM context the ACPI device was created in.
+ * @param softc A pointer to the software context of the ACPI device.
+ * @param emul Device emulation struct. It contains some information like the
+ name of the ACPI device and some device specific functions.
+ * @param crs Current resources used by the ACPI device.
+ */
+struct acpi_device {
+ struct vmctx *vm_ctx;
+ void *softc;
+ const struct acpi_device_emul *emul;
+ SLIST_HEAD(acpi_resource_list, acpi_resource_list_entry) crs;
+};
+
+int
+acpi_device_create(struct acpi_device **const new_dev, void *const softc,
+ struct vmctx *const vm_ctx, const struct acpi_device_emul *const emul)
+{
+ assert(new_dev != NULL);
+ assert(vm_ctx != NULL);
+ assert(emul != NULL);
+
+ struct acpi_device *const dev = calloc(1, sizeof(*dev));
+ if (dev == NULL) {
+ return (ENOMEM);
+ }
+
+ dev->vm_ctx = vm_ctx;
+ dev->softc = softc;
+ dev->emul = emul;
+ SLIST_INIT(&dev->crs);
+
+ const int error = acpi_tables_add_device(dev);
+ if (error) {
+ acpi_device_destroy(dev);
+ return (error);
+ }
+
+ *new_dev = dev;
+
+ return (0);
+}
+
+void
+acpi_device_destroy(struct acpi_device *const dev)
+{
+ if (dev == NULL) {
+ return;
+ }
+
+ struct acpi_resource_list_entry *res;
+ while (!SLIST_EMPTY(&dev->crs)) {
+ res = SLIST_FIRST(&dev->crs);
+ SLIST_REMOVE_HEAD(&dev->crs, chain);
+ free(res);
+ }
+
+ free(dev);
+}
+
+int
+acpi_device_add_res_fixed_ioport(struct acpi_device *const dev,
+ const UINT16 port, const UINT8 length)
+{
+ if (dev == NULL) {
+ return (EINVAL);
+ }
+
+ struct acpi_resource_list_entry *const res = calloc(1, sizeof(*res));
+ if (res == NULL) {
+ return (ENOMEM);
+ }
+
+ res->type = ACPI_RESOURCE_TYPE_FIXED_IO;
+ res->data.FixedIo.Address = port;
+ res->data.FixedIo.AddressLength = length;
+
+ SLIST_INSERT_HEAD(&dev->crs, res, chain);
+
+ return (0);
+}
+
+int
+acpi_device_add_res_fixed_memory32(struct acpi_device *const dev,
+ const UINT8 write_protected, const UINT32 address, const UINT32 length)
+{
+ if (dev == NULL) {
+ return (EINVAL);
+ }
+
+ struct acpi_resource_list_entry *const res = calloc(1, sizeof(*res));
+ if (res == NULL) {
+ return (ENOMEM);
+ }
+
+ res->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32;
+ res->data.FixedMemory32.WriteProtect = write_protected;
+ res->data.FixedMemory32.Address = address;
+ res->data.FixedMemory32.AddressLength = length;
+
+ SLIST_INSERT_HEAD(&dev->crs, res, chain);
+
+ return (0);
+}
+
+void *
+acpi_device_get_softc(const struct acpi_device *const dev)
+{
+ assert(dev != NULL);
+
+ return (dev->softc);
+}
+
+int
+acpi_device_build_table(const struct acpi_device *const dev)
+{
+ assert(dev != NULL);
+ assert(dev->emul != NULL);
+
+ if (dev->emul->build_table != NULL) {
+ return (dev->emul->build_table(dev));
+ }
+
+ return (0);
+}
+
+static int
+acpi_device_write_dsdt_crs(const struct acpi_device *const dev)
+{
+ const struct acpi_resource_list_entry *res;
+ SLIST_FOREACH(res, &dev->crs, chain) {
+ switch (res->type) {
+ case ACPI_RESOURCE_TYPE_FIXED_IO:
+ dsdt_fixed_ioport(res->data.FixedIo.Address,
+ res->data.FixedIo.AddressLength);
+ break;
+ case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
+ dsdt_fixed_mem32(res->data.FixedMemory32.Address,
+ res->data.FixedMemory32.AddressLength);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ }
+
+ return (0);
+}
+
+int
+acpi_device_write_dsdt(const struct acpi_device *const dev)
+{
+ assert(dev != NULL);
+
+ dsdt_line("");
+ dsdt_line(" Scope (\\_SB)");
+ dsdt_line(" {");
+ dsdt_line(" Device (%s)", dev->emul->name);
+ dsdt_line(" {");
+ dsdt_line(" Name (_HID, \"%s\")", dev->emul->hid);
+ dsdt_line(" Name (_STA, 0x0F)");
+ dsdt_line(" Name (_CRS, ResourceTemplate ()");
+ dsdt_line(" {");
+ dsdt_indent(4);
+ BASL_EXEC(acpi_device_write_dsdt_crs(dev));
+ dsdt_unindent(4);
+ dsdt_line(" })");
+ if (dev->emul->write_dsdt != NULL) {
+ dsdt_indent(3);
+ BASL_EXEC(dev->emul->write_dsdt(dev));
+ dsdt_unindent(3);
+ }
+ dsdt_line(" }");
+ dsdt_line(" }");
+
+ return (0);
+}
diff --git a/usr.sbin/bhyve/acpi_device.h b/usr.sbin/bhyve/acpi_device.h
new file mode 100644
index 000000000000..8d0ab89f9215
--- /dev/null
+++ b/usr.sbin/bhyve/acpi_device.h
@@ -0,0 +1,59 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#pragma once
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#include <contrib/dev/acpica/include/acpi.h>
+#pragma GCC diagnostic pop
+
+struct vmctx;
+
+struct acpi_device;
+
+/**
+ * Device specific information and emulation.
+ *
+ * @param name Used as device name in the DSDT.
+ * @param hid Used as _HID in the DSDT.
+ * @param build_table Called to build a device specific ACPI table like the TPM2
+ * table.
+ * @param write_dsdt Called to append the DSDT with device specific
+ * information.
+ */
+struct acpi_device_emul {
+ const char *name;
+ const char *hid;
+
+ int (*build_table)(const struct acpi_device *dev);
+ int (*write_dsdt)(const struct acpi_device *dev);
+};
+
+/**
+ * Creates an ACPI device.
+ *
+ * @param[out] new_dev Returns the newly create ACPI device.
+ * @param[in] softc Pointer to the software context of the ACPI device.
+ * @param[in] vm_ctx VM context the ACPI device is created in.
+ * @param[in] emul Device emulation struct. It contains some information
+ * like the name of the ACPI device and some device specific
+ * functions.
+ */
+int acpi_device_create(struct acpi_device **new_dev, void *softc,
+ struct vmctx *vm_ctx, const struct acpi_device_emul *emul);
+void acpi_device_destroy(struct acpi_device *dev);
+
+int acpi_device_add_res_fixed_ioport(struct acpi_device *dev, UINT16 port,
+ UINT8 length);
+int acpi_device_add_res_fixed_memory32(struct acpi_device *dev,
+ UINT8 write_protected, UINT32 address, UINT32 length);
+
+void *acpi_device_get_softc(const struct acpi_device *dev);
+
+int acpi_device_build_table(const struct acpi_device *dev);
+int acpi_device_write_dsdt(const struct acpi_device *dev);
diff --git a/usr.sbin/bhyve/ahci.h b/usr.sbin/bhyve/ahci.h
index 691d4bd438f4..9ebcc90a0494 100644
--- a/usr.sbin/bhyve/ahci.h
+++ b/usr.sbin/bhyve/ahci.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 - 2008 Søren Schmidt <sos@FreeBSD.org>
* Copyright (c) 2009-2012 Alexander Motin <mav@FreeBSD.org>
@@ -25,8 +25,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$
*/
#ifndef _AHCI_H_
diff --git a/usr.sbin/bhyve/amd64/Makefile.inc b/usr.sbin/bhyve/amd64/Makefile.inc
new file mode 100644
index 000000000000..53320a70178b
--- /dev/null
+++ b/usr.sbin/bhyve/amd64/Makefile.inc
@@ -0,0 +1,32 @@
+BHYVE_GDB_SUPPORT=
+
+SRCS+= \
+ atkbdc.c \
+ e820.c \
+ fwctl.c \
+ inout.c \
+ ioapic.c \
+ kernemu_dev.c \
+ mptbl.c \
+ pci_fbuf.c \
+ pci_gvt-d.c \
+ pci_lpc.c \
+ pci_passthru.c \
+ pctestdev.c \
+ pm.c \
+ post.c \
+ ps2kbd.c \
+ ps2mouse.c \
+ rfb.c \
+ rtc.c \
+ spinup_ap.c \
+ task_switch.c \
+ vga.c \
+ xmsr.c
+
+.PATH: ${BHYVE_SYSDIR}/sys/amd64/vmm
+SRCS+= vmm_instruction_emul.c
+
+CFLAGS.kernemu_dev.c+= -I${SRCTOP}/sys/amd64
+
+SUBDIR+= kbdlayout
diff --git a/usr.sbin/bhyve/atkbdc.c b/usr.sbin/bhyve/amd64/atkbdc.c
index a08f58f84b22..5fa7f3cb779a 100644
--- a/usr.sbin/bhyve/atkbdc.c
+++ b/usr.sbin/bhyve/amd64/atkbdc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* Copyright (c) 2015 Nahanni Systems Inc.
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <machine/vmm.h>
@@ -307,8 +304,8 @@ atkbdc_dequeue_data(struct atkbdc_softc *sc, uint8_t *buf)
}
static int
-atkbdc_data_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+atkbdc_data_handler(struct vmctx *ctx __unused, int in,
+ int port __unused, int bytes, uint32_t *eax, void *arg)
{
struct atkbdc_softc *sc;
uint8_t buf;
@@ -393,8 +390,8 @@ atkbdc_data_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
}
static int
-atkbdc_sts_ctl_handler(struct vmctx *ctx, int vcpu, int in, int port,
- int bytes, uint32_t *eax, void *arg)
+atkbdc_sts_ctl_handler(struct vmctx *ctx, int in,
+ int port __unused, int bytes, uint32_t *eax, void *arg)
{
struct atkbdc_softc *sc;
int error, retval;
diff --git a/usr.sbin/bhyve/atkbdc.h b/usr.sbin/bhyve/amd64/atkbdc.h
index 14c00ed9ae88..05d28d819120 100644
--- a/usr.sbin/bhyve/atkbdc.h
+++ b/usr.sbin/bhyve/amd64/atkbdc.h
@@ -22,8 +22,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 _ATKBDC_H_
diff --git a/usr.sbin/bhyve/amd64/bhyverun_machdep.c b/usr.sbin/bhyve/amd64/bhyverun_machdep.c
new file mode 100644
index 000000000000..fc2f91e31db7
--- /dev/null
+++ b/usr.sbin/bhyve/amd64/bhyverun_machdep.c
@@ -0,0 +1,368 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2011 NetApp, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <assert.h>
+#include <err.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <sysexits.h>
+
+#include <vmmapi.h>
+
+#include "acpi.h"
+#include "atkbdc.h"
+#include "bhyverun.h"
+#include "config.h"
+#include "debug.h"
+#include "e820.h"
+#include "fwctl.h"
+#include "ioapic.h"
+#include "inout.h"
+#include "kernemu_dev.h"
+#include "mptbl.h"
+#include "pci_emul.h"
+#include "pci_irq.h"
+#include "pci_lpc.h"
+#include "rtc.h"
+#include "smbiostbl.h"
+#include "xmsr.h"
+
+void
+bhyve_init_config(void)
+{
+ init_config();
+
+ /* Set default values prior to option parsing. */
+ set_config_bool("acpi_tables", true);
+ set_config_bool("acpi_tables_in_memory", true);
+ set_config_value("memory.size", "256M");
+ set_config_bool("x86.strictmsr", true);
+ set_config_value("lpc.fwcfg", "bhyve");
+}
+
+void
+bhyve_usage(int code)
+{
+ const char *progname;
+
+ progname = getprogname();
+
+ fprintf(stderr,
+ "Usage: %s [-AaCDeHhPSuWwxY]\n"
+ " %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n"
+ " %*s [-G port] [-k config_file] [-l lpc] [-m mem] [-o var=value]\n"
+ " %*s [-p vcpu:hostcpu] [-r file] [-s pci] [-U uuid] vmname\n"
+ " -A: create ACPI tables\n"
+ " -a: local apic is in xAPIC mode (deprecated)\n"
+ " -C: include guest memory in core file\n"
+ " -c: number of CPUs and/or topology specification\n"
+ " -D: destroy on power-off\n"
+ " -e: exit on unhandled I/O access\n"
+ " -G: start a debug server\n"
+ " -H: vmexit from the guest on HLT\n"
+ " -h: help\n"
+ " -k: key=value flat config file\n"
+ " -K: PS2 keyboard layout\n"
+ " -l: LPC device configuration\n"
+ " -m: memory size\n"
+ " -o: set config 'var' to 'value'\n"
+ " -P: vmexit from the guest on pause\n"
+ " -p: pin 'vcpu' to 'hostcpu'\n"
+#ifdef BHYVE_SNAPSHOT
+ " -r: path to checkpoint file\n"
+#endif
+ " -S: guest memory cannot be swapped\n"
+ " -s: <slot,driver,configinfo> PCI slot config\n"
+ " -U: UUID\n"
+ " -u: RTC keeps UTC time\n"
+ " -W: force virtio to use single-vector MSI\n"
+ " -w: ignore unimplemented MSRs\n"
+ " -x: local APIC is in x2APIC mode\n"
+ " -Y: disable MPtable generation\n",
+ progname, (int)strlen(progname), "", (int)strlen(progname), "",
+ (int)strlen(progname), "");
+ exit(code);
+}
+
+void
+bhyve_optparse(int argc, char **argv)
+{
+ const char *optstr;
+ int c;
+
+#ifdef BHYVE_SNAPSHOT
+ optstr = "aehuwxACDHIPSWYk:f:o:p:G:c:s:m:l:K:U:r:";
+#else
+ optstr = "aehuwxACDHIPSWYk:f:o:p:G:c:s:m:l:K:U:";
+#endif
+ while ((c = getopt(argc, argv, optstr)) != -1) {
+ switch (c) {
+ case 'a':
+ set_config_bool("x86.x2apic", false);
+ break;
+ case 'A':
+ /*
+ * NOP. For backward compatibility. Most systems don't
+ * work properly without sane ACPI tables. Therefore,
+ * we're always generating them.
+ */
+ break;
+ case 'D':
+ set_config_bool("destroy_on_poweroff", true);
+ break;
+ case 'p':
+ if (bhyve_pincpu_parse(optarg) != 0) {
+ errx(EX_USAGE, "invalid vcpu pinning "
+ "configuration '%s'", optarg);
+ }
+ break;
+ case 'c':
+ if (bhyve_topology_parse(optarg) != 0) {
+ errx(EX_USAGE, "invalid cpu topology "
+ "'%s'", optarg);
+ }
+ break;
+ case 'C':
+ set_config_bool("memory.guest_in_core", true);
+ break;
+ case 'f':
+ if (qemu_fwcfg_parse_cmdline_arg(optarg) != 0) {
+ errx(EX_USAGE, "invalid fwcfg item '%s'",
+ optarg);
+ }
+ break;
+ case 'G':
+ bhyve_parse_gdb_options(optarg);
+ break;
+ case 'k':
+ bhyve_parse_simple_config_file(optarg);
+ break;
+ case 'K':
+ set_config_value("keyboard.layout", optarg);
+ break;
+ case 'l':
+ if (strncmp(optarg, "help", strlen(optarg)) == 0) {
+ lpc_print_supported_devices();
+ exit(0);
+ } else if (lpc_device_parse(optarg) != 0) {
+ errx(EX_USAGE, "invalid lpc device "
+ "configuration '%s'", optarg);
+ }
+ break;
+#ifdef BHYVE_SNAPSHOT
+ case 'r':
+ restore_file = optarg;
+ break;
+#endif
+ case 's':
+ if (strncmp(optarg, "help", strlen(optarg)) == 0) {
+ pci_print_supported_devices();
+ exit(0);
+ } else if (pci_parse_slot(optarg) != 0)
+ exit(4);
+ else
+ break;
+ case 'S':
+ set_config_bool("memory.wired", true);
+ break;
+ case 'm':
+ set_config_value("memory.size", optarg);
+ break;
+ case 'o':
+ if (!bhyve_parse_config_option(optarg)) {
+ errx(EX_USAGE,
+ "invalid configuration option '%s'",
+ optarg);
+ }
+ break;
+ case 'H':
+ set_config_bool("x86.vmexit_on_hlt", true);
+ break;
+ case 'I':
+ /*
+ * The "-I" option was used to add an ioapic to the
+ * virtual machine.
+ *
+ * An ioapic is now provided unconditionally for each
+ * virtual machine and this option is now deprecated.
+ */
+ break;
+ case 'P':
+ set_config_bool("x86.vmexit_on_pause", true);
+ break;
+ case 'e':
+ set_config_bool("x86.strictio", true);
+ break;
+ case 'u':
+ set_config_bool("rtc.use_localtime", false);
+ break;
+ case 'U':
+ set_config_value("uuid", optarg);
+ break;
+ case 'w':
+ set_config_bool("x86.strictmsr", false);
+ break;
+ case 'W':
+ set_config_bool("virtio_msix", false);
+ break;
+ case 'x':
+ set_config_bool("x86.x2apic", true);
+ break;
+ case 'Y':
+ set_config_bool("x86.mptable", false);
+ break;
+ case 'h':
+ bhyve_usage(0);
+ default:
+ bhyve_usage(1);
+ }
+ }
+}
+
+void
+bhyve_init_vcpu(struct vcpu *vcpu)
+{
+ int err, tmp;
+
+ if (get_config_bool_default("x86.vmexit_on_hlt", false)) {
+ err = vm_get_capability(vcpu, VM_CAP_HALT_EXIT, &tmp);
+ if (err < 0) {
+ EPRINTLN("VM exit on HLT not supported");
+ exit(4);
+ }
+ vm_set_capability(vcpu, VM_CAP_HALT_EXIT, 1);
+ }
+
+ if (get_config_bool_default("x86.vmexit_on_pause", false)) {
+ /*
+ * pause exit support required for this mode
+ */
+ err = vm_get_capability(vcpu, VM_CAP_PAUSE_EXIT, &tmp);
+ if (err < 0) {
+ EPRINTLN("SMP mux requested, no pause support");
+ exit(4);
+ }
+ vm_set_capability(vcpu, VM_CAP_PAUSE_EXIT, 1);
+ }
+
+ if (get_config_bool_default("x86.x2apic", false))
+ err = vm_set_x2apic_state(vcpu, X2APIC_ENABLED);
+ else
+ err = vm_set_x2apic_state(vcpu, X2APIC_DISABLED);
+
+ if (err) {
+ EPRINTLN("Unable to set x2apic state (%d)", err);
+ exit(4);
+ }
+
+ vm_set_capability(vcpu, VM_CAP_ENABLE_INVPCID, 1);
+
+ err = vm_set_capability(vcpu, VM_CAP_IPI_EXIT, 1);
+ assert(err == 0);
+}
+
+void
+bhyve_start_vcpu(struct vcpu *vcpu, bool bsp)
+{
+ int error;
+
+ if (bsp) {
+ if (lpc_bootrom()) {
+ error = vm_set_capability(vcpu,
+ VM_CAP_UNRESTRICTED_GUEST, 1);
+ if (error != 0) {
+ err(4, "ROM boot failed: unrestricted guest "
+ "capability not available");
+ }
+ error = vcpu_reset(vcpu);
+ assert(error == 0);
+ }
+ } else {
+ bhyve_init_vcpu(vcpu);
+
+ /*
+ * Enable the 'unrestricted guest' mode for APs.
+ *
+ * APs startup in power-on 16-bit mode.
+ */
+ error = vm_set_capability(vcpu, VM_CAP_UNRESTRICTED_GUEST, 1);
+ assert(error == 0);
+ }
+
+ fbsdrun_addcpu(vcpu_id(vcpu));
+}
+
+int
+bhyve_init_platform(struct vmctx *ctx, struct vcpu *bsp __unused)
+{
+ int error;
+
+ error = init_msr();
+ if (error != 0)
+ return (error);
+ init_inout();
+ kernemu_dev_init();
+ atkbdc_init(ctx);
+ pci_irq_init(ctx);
+ ioapic_init(ctx);
+ rtc_init(ctx);
+ sci_init(ctx);
+ error = e820_init(ctx);
+ if (error != 0)
+ return (error);
+
+ return (0);
+}
+
+int
+bhyve_init_platform_late(struct vmctx *ctx, struct vcpu *bsp __unused)
+{
+ int error;
+
+ if (get_config_bool_default("x86.mptable", true)) {
+ error = mptable_build(ctx, guest_ncpus);
+ if (error != 0)
+ return (error);
+ }
+ error = smbios_build(ctx);
+ if (error != 0)
+ return (error);
+ error = e820_finalize();
+ if (error != 0)
+ return (error);
+
+ if (lpc_bootrom() && strcmp(lpc_fwcfg(), "bhyve") == 0)
+ fwctl_init();
+
+ if (get_config_bool("acpi_tables")) {
+ error = acpi_build(ctx, guest_ncpus);
+ assert(error == 0);
+ }
+
+ return (0);
+}
diff --git a/usr.sbin/bhyve/amd64/e820.c b/usr.sbin/bhyve/amd64/e820.c
new file mode 100644
index 000000000000..456ce0330b50
--- /dev/null
+++ b/usr.sbin/bhyve/amd64/e820.c
@@ -0,0 +1,491 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#include <sys/types.h>
+#include <sys/queue.h>
+
+#include <machine/vmm.h>
+
+#include <assert.h>
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "debug.h"
+#include "e820.h"
+#include "qemu_fwcfg.h"
+
+/*
+ * E820 always uses 64 bit entries. Emulation code will use vm_paddr_t since it
+ * works on physical addresses. If vm_paddr_t is larger than uint64_t E820 can't
+ * hold all possible physical addresses and we can get into trouble.
+ */
+static_assert(sizeof(vm_paddr_t) <= sizeof(uint64_t),
+ "Unable to represent physical memory by E820 table");
+
+#define E820_FWCFG_FILE_NAME "etc/e820"
+
+#define KB (1024UL)
+#define MB (1024 * KB)
+#define GB (1024 * MB)
+
+/*
+ * Fix E820 memory holes:
+ * [ A0000, C0000) VGA
+ * [ C0000, 100000) ROM
+ */
+#define E820_VGA_MEM_BASE 0xA0000
+#define E820_VGA_MEM_END 0xC0000
+#define E820_ROM_MEM_BASE 0xC0000
+#define E820_ROM_MEM_END 0x100000
+
+struct e820_element {
+ TAILQ_ENTRY(e820_element) chain;
+ uint64_t base;
+ uint64_t end;
+ enum e820_memory_type type;
+};
+static TAILQ_HEAD(e820_table, e820_element) e820_table = TAILQ_HEAD_INITIALIZER(
+ e820_table);
+
+static struct e820_element *
+e820_element_alloc(uint64_t base, uint64_t end, enum e820_memory_type type)
+{
+ struct e820_element *element;
+
+ element = calloc(1, sizeof(*element));
+ if (element == NULL) {
+ return (NULL);
+ }
+
+ element->base = base;
+ element->end = end;
+ element->type = type;
+
+ return (element);
+}
+
+static const char *
+e820_get_type_name(const enum e820_memory_type type)
+{
+ switch (type) {
+ case E820_TYPE_MEMORY:
+ return ("RAM");
+ case E820_TYPE_RESERVED:
+ return ("Reserved");
+ case E820_TYPE_ACPI:
+ return ("ACPI");
+ case E820_TYPE_NVS:
+ return ("NVS");
+ default:
+ return ("Unknown");
+ }
+}
+
+void
+e820_dump_table(void)
+{
+ struct e820_element *element;
+ uint64_t i;
+
+ EPRINTLN("E820 map:");
+
+ i = 0;
+ TAILQ_FOREACH(element, &e820_table, chain) {
+ EPRINTLN(" (%4lu) [%16lx, %16lx] %s", i,
+ element->base, element->end,
+ e820_get_type_name(element->type));
+
+ ++i;
+ }
+}
+
+static struct qemu_fwcfg_item *
+e820_get_fwcfg_item(void)
+{
+ struct qemu_fwcfg_item *fwcfg_item;
+ struct e820_element *element;
+ struct e820_entry *entries;
+ int count, i;
+
+ count = 0;
+ TAILQ_FOREACH(element, &e820_table, chain) {
+ ++count;
+ }
+ if (count == 0) {
+ warnx("%s: E820 table empty", __func__);
+ return (NULL);
+ }
+
+ fwcfg_item = calloc(1, sizeof(struct qemu_fwcfg_item));
+ if (fwcfg_item == NULL) {
+ return (NULL);
+ }
+
+ fwcfg_item->size = count * sizeof(struct e820_entry);
+ fwcfg_item->data = calloc(count, sizeof(struct e820_entry));
+ if (fwcfg_item->data == NULL) {
+ free(fwcfg_item);
+ return (NULL);
+ }
+
+ i = 0;
+ entries = (struct e820_entry *)fwcfg_item->data;
+ TAILQ_FOREACH(element, &e820_table, chain) {
+ struct e820_entry *entry = &entries[i];
+
+ entry->base = element->base;
+ entry->length = element->end - element->base;
+ entry->type = element->type;
+
+ ++i;
+ }
+
+ return (fwcfg_item);
+}
+
+static int
+e820_add_entry(const uint64_t base, const uint64_t end,
+ const enum e820_memory_type type)
+{
+ struct e820_element *new_element;
+ struct e820_element *element;
+ struct e820_element *ram_element;
+
+ assert(end >= base);
+
+ new_element = e820_element_alloc(base, end, type);
+ if (new_element == NULL) {
+ return (ENOMEM);
+ }
+
+ /*
+ * E820 table should always be sorted in ascending order. Therefore,
+ * search for a range whose end is larger than the base parameter.
+ */
+ TAILQ_FOREACH(element, &e820_table, chain) {
+ if (element->end > base) {
+ break;
+ }
+ }
+
+ /*
+ * System memory requires special handling.
+ */
+ if (type == E820_TYPE_MEMORY) {
+ /*
+ * base is larger than of any existing element. Add new system
+ * memory at the end of the table.
+ */
+ if (element == NULL) {
+ TAILQ_INSERT_TAIL(&e820_table, new_element, chain);
+ return (0);
+ }
+
+ /*
+ * System memory shouldn't overlap with any existing element.
+ */
+ assert(end >= element->base);
+
+ TAILQ_INSERT_BEFORE(element, new_element, chain);
+
+ return (0);
+ }
+
+ /*
+ * If some one tries to allocate a specific address, it could happen, that
+ * this address is not allocatable. Therefore, do some checks. If the
+ * address is not allocatable, don't panic. The user may have a fallback and
+ * tries to allocate another address. This is true for the GVT-d emulation
+ * which tries to reuse the host address of the graphics stolen memory and
+ * falls back to allocating the highest address below 4 GB.
+ */
+ if (element == NULL || element->type != E820_TYPE_MEMORY ||
+ (base < element->base || end > element->end))
+ return (ENOMEM);
+
+ if (base == element->base) {
+ /*
+ * New element at system memory base boundary. Add new
+ * element before current and adjust the base of the old
+ * element.
+ *
+ * Old table:
+ * [ 0x1000, 0x4000] RAM <-- element
+ * New table:
+ * [ 0x1000, 0x2000] Reserved
+ * [ 0x2000, 0x4000] RAM <-- element
+ */
+ TAILQ_INSERT_BEFORE(element, new_element, chain);
+ element->base = end;
+ } else if (end == element->end) {
+ /*
+ * New element at system memory end boundary. Add new
+ * element after current and adjust the end of the
+ * current element.
+ *
+ * Old table:
+ * [ 0x1000, 0x4000] RAM <-- element
+ * New table:
+ * [ 0x1000, 0x3000] RAM <-- element
+ * [ 0x3000, 0x4000] Reserved
+ */
+ TAILQ_INSERT_AFTER(&e820_table, element, new_element, chain);
+ element->end = base;
+ } else {
+ /*
+ * New element inside system memory entry. Split it by
+ * adding a system memory element and the new element
+ * before current.
+ *
+ * Old table:
+ * [ 0x1000, 0x4000] RAM <-- element
+ * New table:
+ * [ 0x1000, 0x2000] RAM
+ * [ 0x2000, 0x3000] Reserved
+ * [ 0x3000, 0x4000] RAM <-- element
+ */
+ ram_element = e820_element_alloc(element->base, base,
+ E820_TYPE_MEMORY);
+ if (ram_element == NULL) {
+ return (ENOMEM);
+ }
+ TAILQ_INSERT_BEFORE(element, ram_element, chain);
+ TAILQ_INSERT_BEFORE(element, new_element, chain);
+ element->base = end;
+ }
+
+ return (0);
+}
+
+static int
+e820_add_memory_hole(const uint64_t base, const uint64_t end)
+{
+ struct e820_element *element;
+ struct e820_element *ram_element;
+
+ assert(end >= base);
+
+ /*
+ * E820 table should be always sorted in ascending order. Therefore,
+ * search for an element which end is larger than the base parameter.
+ */
+ TAILQ_FOREACH(element, &e820_table, chain) {
+ if (element->end > base) {
+ break;
+ }
+ }
+
+ if (element == NULL || end <= element->base) {
+ /* Nothing to do. Hole already exists */
+ return (0);
+ }
+
+ /* Memory holes are only allowed in system memory */
+ assert(element->type == E820_TYPE_MEMORY);
+
+ if (base == element->base) {
+ /*
+ * New hole at system memory base boundary.
+ *
+ * Old table:
+ * [ 0x1000, 0x4000] RAM
+ * New table:
+ * [ 0x2000, 0x4000] RAM
+ */
+ element->base = end;
+ } else if (end == element->end) {
+ /*
+ * New hole at system memory end boundary.
+ *
+ * Old table:
+ * [ 0x1000, 0x4000] RAM
+ * New table:
+ * [ 0x1000, 0x3000] RAM
+ */
+ element->end = base;
+ } else {
+ /*
+ * New hole inside system memory entry. Split the system memory.
+ *
+ * Old table:
+ * [ 0x1000, 0x4000] RAM <-- element
+ * New table:
+ * [ 0x1000, 0x2000] RAM
+ * [ 0x3000, 0x4000] RAM <-- element
+ */
+ ram_element = e820_element_alloc(element->base, base,
+ E820_TYPE_MEMORY);
+ if (ram_element == NULL) {
+ return (ENOMEM);
+ }
+ TAILQ_INSERT_BEFORE(element, ram_element, chain);
+ element->base = end;
+ }
+
+ return (0);
+}
+
+static uint64_t
+e820_alloc_highest(const uint64_t max_address, const uint64_t length,
+ const uint64_t alignment, const enum e820_memory_type type)
+{
+ struct e820_element *element;
+
+ TAILQ_FOREACH_REVERSE(element, &e820_table, e820_table, chain) {
+ uint64_t address, base, end;
+
+ end = MIN(max_address, element->end);
+ base = roundup2(element->base, alignment);
+
+ /*
+ * If end - length == 0, we would allocate memory at address 0. This
+ * address is mostly unusable and we should avoid allocating it.
+ * Therefore, search for another block in that case.
+ */
+ if (element->type != E820_TYPE_MEMORY || end < base ||
+ end - base < length || end - length == 0) {
+ continue;
+ }
+
+ address = rounddown2(end - length, alignment);
+
+ if (e820_add_entry(address, address + length, type) != 0) {
+ return (0);
+ }
+
+ return (address);
+ }
+
+ return (0);
+}
+
+static uint64_t
+e820_alloc_lowest(const uint64_t min_address, const uint64_t length,
+ const uint64_t alignment, const enum e820_memory_type type)
+{
+ struct e820_element *element;
+
+ TAILQ_FOREACH(element, &e820_table, chain) {
+ uint64_t base, end;
+
+ end = element->end;
+ base = MAX(min_address, roundup2(element->base, alignment));
+
+ /*
+ * If base == 0, we would allocate memory at address 0. This
+ * address is mostly unusable and we should avoid allocating it.
+ * Therefore, search for another block in that case.
+ */
+ if (element->type != E820_TYPE_MEMORY || end < base ||
+ end - base < length || base == 0) {
+ continue;
+ }
+
+ if (e820_add_entry(base, base + length, type) != 0) {
+ return (0);
+ }
+
+ return (base);
+ }
+
+ return (0);
+}
+
+uint64_t
+e820_alloc(const uint64_t address, const uint64_t length,
+ const uint64_t alignment, const enum e820_memory_type type,
+ const enum e820_allocation_strategy strategy)
+{
+ assert(powerof2(alignment));
+ assert((address & (alignment - 1)) == 0);
+
+ switch (strategy) {
+ case E820_ALLOCATE_ANY:
+ /*
+ * Allocate any address. Therefore, ignore the address parameter
+ * and reuse the code path for allocating the lowest address.
+ */
+ return (e820_alloc_lowest(0, length, alignment, type));
+ case E820_ALLOCATE_LOWEST:
+ return (e820_alloc_lowest(address, length, alignment, type));
+ case E820_ALLOCATE_HIGHEST:
+ return (e820_alloc_highest(address, length, alignment, type));
+ case E820_ALLOCATE_SPECIFIC:
+ if (e820_add_entry(address, address + length, type) != 0) {
+ return (0);
+ }
+
+ return (address);
+ }
+
+ return (0);
+}
+
+int
+e820_init(struct vmctx *const ctx)
+{
+ uint64_t lowmem_size, highmem_size;
+ int error;
+
+ TAILQ_INIT(&e820_table);
+
+ lowmem_size = vm_get_lowmem_size(ctx);
+ error = e820_add_entry(0, lowmem_size, E820_TYPE_MEMORY);
+ if (error) {
+ warnx("%s: Could not add lowmem", __func__);
+ return (error);
+ }
+
+ highmem_size = vm_get_highmem_size(ctx);
+ if (highmem_size != 0) {
+ error = e820_add_entry(4 * GB, 4 * GB + highmem_size,
+ E820_TYPE_MEMORY);
+ if (error) {
+ warnx("%s: Could not add highmem", __func__);
+ return (error);
+ }
+ }
+
+ error = e820_add_memory_hole(E820_VGA_MEM_BASE, E820_VGA_MEM_END);
+ if (error) {
+ warnx("%s: Could not add VGA memory", __func__);
+ return (error);
+ }
+
+ error = e820_add_memory_hole(E820_ROM_MEM_BASE, E820_ROM_MEM_END);
+ if (error) {
+ warnx("%s: Could not add ROM area", __func__);
+ return (error);
+ }
+
+ return (0);
+}
+
+int
+e820_finalize(void)
+{
+ struct qemu_fwcfg_item *e820_fwcfg_item;
+ int error;
+
+ e820_fwcfg_item = e820_get_fwcfg_item();
+ if (e820_fwcfg_item == NULL) {
+ warnx("invalid e820 table");
+ return (ENOMEM);
+ }
+ error = qemu_fwcfg_add_file("etc/e820",
+ e820_fwcfg_item->size, e820_fwcfg_item->data);
+ if (error != 0) {
+ warnx("could not add qemu fwcfg etc/e820");
+ return (error);
+ }
+ free(e820_fwcfg_item);
+
+ return (0);
+}
diff --git a/usr.sbin/bhyve/amd64/e820.h b/usr.sbin/bhyve/amd64/e820.h
new file mode 100644
index 000000000000..ae68fe9040a9
--- /dev/null
+++ b/usr.sbin/bhyve/amd64/e820.h
@@ -0,0 +1,45 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#pragma once
+
+#include <vmmapi.h>
+
+#include "qemu_fwcfg.h"
+
+enum e820_memory_type {
+ E820_TYPE_MEMORY = 1,
+ E820_TYPE_RESERVED = 2,
+ E820_TYPE_ACPI = 3,
+ E820_TYPE_NVS = 4
+};
+
+enum e820_allocation_strategy {
+ /* allocate any address */
+ E820_ALLOCATE_ANY,
+ /* allocate lowest address larger than address */
+ E820_ALLOCATE_LOWEST,
+ /* allocate highest address lower than address */
+ E820_ALLOCATE_HIGHEST,
+ /* allocate a specific address */
+ E820_ALLOCATE_SPECIFIC
+};
+
+struct e820_entry {
+ uint64_t base;
+ uint64_t length;
+ uint32_t type;
+} __packed;
+
+#define E820_ALIGNMENT_NONE 1
+
+uint64_t e820_alloc(const uint64_t address, const uint64_t length,
+ const uint64_t alignment, const enum e820_memory_type type,
+ const enum e820_allocation_strategy strategy);
+void e820_dump_table(void);
+int e820_init(struct vmctx *const ctx);
+int e820_finalize(void);
diff --git a/usr.sbin/bhyve/fwctl.c b/usr.sbin/bhyve/amd64/fwctl.c
index f0f9aa3affc0..76e2eaf67849 100644
--- a/usr.sbin/bhyve/fwctl.c
+++ b/usr.sbin/bhyve/amd64/fwctl.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Peter Grehan <grehan@freebsd.org>
* All rights reserved.
@@ -24,16 +24,12 @@
* 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$
*/
/*
* Guest firmware interface. Uses i/o ports x510/x511 as Qemu does,
* but with a request/response messaging protocol.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/types.h>
@@ -66,13 +62,11 @@ __FBSDID("$FreeBSD$");
/*
* Back-end state-machine
*/
-enum state {
- DORMANT,
- IDENT_WAIT,
- IDENT_SEND,
+static enum state {
+ IDENT,
REQ,
RESP
-} be_state = DORMANT;
+} be_state;
static uint8_t sig[] = { 'B', 'H', 'Y', 'V' };
static u_int ident_idx;
@@ -80,7 +74,7 @@ static u_int ident_idx;
struct op_info {
int op;
int (*op_start)(uint32_t len);
- void (*op_data)(uint32_t data, uint32_t len);
+ void (*op_data)(uint32_t data);
int (*op_result)(struct iovec **data);
void (*op_done)(struct iovec *data);
};
@@ -88,20 +82,17 @@ static struct op_info *ops[OP_MAX+1];
/* Return 0-padded uint32_t */
static uint32_t
-fwctl_send_rest(uint32_t *data, size_t len)
+fwctl_send_rest(uint8_t *data, size_t len)
{
union {
uint8_t c[4];
uint32_t w;
} u;
- uint8_t *cdata;
- int i;
+ size_t i;
- cdata = (uint8_t *) data;
u.w = 0;
-
- for (i = 0, u.w = 0; i < len; i++)
- u.c[i] = *cdata++;
+ for (i = 0; i < len; i++)
+ u.c[i] = *data++;
return (u.w);
}
@@ -119,7 +110,7 @@ errop_set(int err)
}
static int
-errop_start(uint32_t len)
+errop_start(uint32_t len __unused)
{
errop_code = ENOENT;
@@ -128,7 +119,7 @@ errop_start(uint32_t len)
}
static void
-errop_data(uint32_t data, uint32_t len)
+errop_data(uint32_t data __unused)
{
/* ignore */
@@ -144,7 +135,7 @@ errop_result(struct iovec **data)
}
static void
-errop_done(struct iovec *data)
+errop_done(struct iovec *data __unused)
{
/* assert data is NULL */
@@ -200,10 +191,11 @@ fget_start(uint32_t len)
}
static void
-fget_data(uint32_t data, uint32_t len)
+fget_data(uint32_t data)
{
- *((uint32_t *) &fget_str[fget_cnt]) = data;
+ assert(fget_cnt + sizeof(uint32_t) <= sizeof(fget_str));
+ memcpy(&fget_str[fget_cnt], &data, sizeof(data));
fget_cnt += sizeof(uint32_t);
}
@@ -244,7 +236,7 @@ fget_result(struct iovec **data, int val)
}
static void
-fget_done(struct iovec *data)
+fget_done(struct iovec *data __unused)
{
/* nothing needs to be freed */
@@ -347,13 +339,14 @@ static int
fwctl_request_data(uint32_t value)
{
- /* Make sure remaining size is >= 0 */
+ /* Make sure remaining size is > 0 */
+ assert(rinfo.req_size > 0);
if (rinfo.req_size <= sizeof(uint32_t))
rinfo.req_size = 0;
else
rinfo.req_size -= sizeof(uint32_t);
- (*rinfo.req_op->op_data)(value, rinfo.req_size);
+ (*rinfo.req_op->op_data)(value);
if (rinfo.req_size < sizeof(uint32_t)) {
fwctl_request_done();
@@ -366,7 +359,6 @@ fwctl_request_data(uint32_t value)
static int
fwctl_request(uint32_t value)
{
-
int ret;
ret = 0;
@@ -401,7 +393,7 @@ fwctl_request(uint32_t value)
static int
fwctl_response(uint32_t *retval)
{
- uint32_t *dp;
+ uint8_t *dp;
ssize_t remlen;
switch(rinfo.resp_count) {
@@ -425,10 +417,9 @@ fwctl_response(uint32_t *retval)
break;
default:
remlen = rinfo.resp_size - rinfo.resp_off;
- dp = (uint32_t *)
- ((uint8_t *)rinfo.resp_biov->iov_base + rinfo.resp_off);
- if (remlen >= sizeof(uint32_t)) {
- *retval = *dp;
+ dp = (uint8_t *)rinfo.resp_biov->iov_base + rinfo.resp_off;
+ if (remlen >= (ssize_t)sizeof(uint32_t)) {
+ memcpy(retval, dp, sizeof(uint32_t));
} else if (remlen > 0) {
*retval = fwctl_send_rest(dp, remlen);
}
@@ -445,6 +436,27 @@ fwctl_response(uint32_t *retval)
return (0);
}
+static void
+fwctl_reset(void)
+{
+
+ switch (be_state) {
+ case RESP:
+ /* If a response was generated but not fully read, discard it. */
+ fwctl_response_done();
+ break;
+ case REQ:
+ /* Discard partially-received request. */
+ memset(&rinfo, 0, sizeof(rinfo));
+ break;
+ case IDENT:
+ break;
+ }
+
+ be_state = IDENT;
+ ident_idx = 0;
+}
+
/*
* i/o port handling.
@@ -457,7 +469,7 @@ fwctl_inb(void)
retval = 0xff;
switch (be_state) {
- case IDENT_SEND:
+ case IDENT:
retval = sig[ident_idx++];
if (ident_idx >= sizeof(sig))
be_state = REQ;
@@ -472,18 +484,13 @@ fwctl_inb(void)
static void
fwctl_outw(uint16_t val)
{
- if (be_state == DORMANT) {
- return;
- }
-
if (val == 0) {
/*
* The guest wants to read the signature. It's possible that the
* guest is unaware of the fwctl state at this moment. For that
* reason, reset the state machine unconditionally.
*/
- be_state = IDENT_SEND;
- ident_idx = 0;
+ fwctl_reset();
}
}
@@ -520,8 +527,8 @@ fwctl_outl(uint32_t val)
}
static int
-fwctl_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+fwctl_handler(struct vmctx *ctx __unused, int in,
+ int port __unused, int bytes, uint32_t *eax, void *arg __unused)
{
if (in) {
@@ -570,5 +577,5 @@ fwctl_init(void)
ops[OP_GET_LEN] = &fgetlen_info;
ops[OP_GET] = &fgetval_info;
- be_state = IDENT_WAIT;
+ be_state = IDENT;
}
diff --git a/usr.sbin/bhyve/fwctl.h b/usr.sbin/bhyve/amd64/fwctl.h
index 6dad2448119b..18cafaa59c42 100644
--- a/usr.sbin/bhyve/fwctl.h
+++ b/usr.sbin/bhyve/amd64/fwctl.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Peter Grehan <grehan@freebsd.org>
* 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 _FWCTL_H_
diff --git a/usr.sbin/bhyve/inout.c b/usr.sbin/bhyve/amd64/inout.c
index b65d273f4320..478678aae1fd 100644
--- a/usr.sbin/bhyve/inout.c
+++ b/usr.sbin/bhyve/amd64/inout.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,20 +24,14 @@
* 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 <sys/param.h>
#include <sys/linker_set.h>
#include <sys/_iovec.h>
#include <sys/mman.h>
#include <x86/psl.h>
-#include <x86/segments.h>
#include <machine/vmm.h>
#include <machine/vmm_instruction_emul.h>
@@ -66,8 +60,8 @@ static struct {
} inout_handlers[MAX_IOPORTS];
static int
-default_inout(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+default_inout(struct vmctx *ctx __unused, int in,
+ int port __unused, int bytes, uint32_t *eax, void *arg __unused)
{
if (in) {
switch (bytes) {
@@ -104,7 +98,7 @@ register_default_iohandler(int start, int size)
}
int
-emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit)
+emulate_inout(struct vmctx *ctx, struct vcpu *vcpu, struct vm_exit *vmexit)
{
int addrsize, bytes, flags, in, port, prot, rep;
uint32_t eax, val;
@@ -162,11 +156,11 @@ emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit)
if (vie_calculate_gla(vis->paging.cpu_mode,
vis->seg_name, &vis->seg_desc, index, bytes,
addrsize, prot, &gla)) {
- vm_inject_gp(ctx, vcpu);
+ vm_inject_gp(vcpu);
break;
}
- error = vm_copy_setup(ctx, vcpu, &vis->paging, gla,
+ error = vm_copy_setup(vcpu, &vis->paging, gla,
bytes, prot, iov, nitems(iov), &fault);
if (error) {
retval = -1; /* Unrecoverable error */
@@ -178,20 +172,20 @@ emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit)
if (vie_alignment_check(vis->paging.cpl, bytes,
vis->cr0, vis->rflags, gla)) {
- vm_inject_ac(ctx, vcpu, 0);
+ vm_inject_ac(vcpu, 0);
break;
}
val = 0;
if (!in)
- vm_copyin(ctx, vcpu, iov, &val, bytes);
+ vm_copyin(iov, &val, bytes);
- retval = handler(ctx, vcpu, in, port, bytes, &val, arg);
+ retval = handler(ctx, in, port, bytes, &val, arg);
if (retval != 0)
break;
if (in)
- vm_copyout(ctx, vcpu, &val, iov, bytes);
+ vm_copyout(&val, iov, bytes);
/* Update index */
if (vis->rflags & PSL_D)
@@ -204,7 +198,7 @@ emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit)
}
/* Update index register */
- error = vie_update_register(ctx, vcpu, idxreg, index, addrsize);
+ error = vie_update_register(vcpu, idxreg, index, addrsize);
assert(error == 0);
/*
@@ -212,24 +206,24 @@ emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit)
* prefix.
*/
if (rep) {
- error = vie_update_register(ctx, vcpu, VM_REG_GUEST_RCX,
+ error = vie_update_register(vcpu, VM_REG_GUEST_RCX,
count, addrsize);
assert(error == 0);
}
/* Restart the instruction if more iterations remain */
if (retval == 0 && count != 0) {
- error = vm_restart_instruction(ctx, vcpu);
+ error = vm_restart_instruction(vcpu);
assert(error == 0);
}
} else {
eax = vmexit->u.inout.eax;
val = eax & vie_size2mask(bytes);
- retval = handler(ctx, vcpu, in, port, bytes, &val, arg);
+ retval = handler(ctx, in, port, bytes, &val, arg);
if (retval == 0 && in) {
eax &= ~vie_size2mask(bytes);
eax |= val & vie_size2mask(bytes);
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX,
+ error = vm_set_register(vcpu, VM_REG_GUEST_RAX,
eax);
assert(error == 0);
}
diff --git a/usr.sbin/bhyve/inout.h b/usr.sbin/bhyve/amd64/inout.h
index 19b2975b94e5..0d6131c9e886 100644
--- a/usr.sbin/bhyve/inout.h
+++ b/usr.sbin/bhyve/amd64/inout.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* 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 _INOUT_H_
@@ -33,13 +31,14 @@
#include <sys/linker_set.h>
+struct vcpu;
struct vmctx;
struct vm_exit;
/*
* inout emulation handlers return 0 on success and -1 on failure.
*/
-typedef int (*inout_func_t)(struct vmctx *ctx, int vcpu, int in, int port,
+typedef int (*inout_func_t)(struct vmctx *ctx, int in, int port,
int bytes, uint32_t *eax, void *arg);
struct inout_port {
@@ -72,7 +71,7 @@ struct inout_port {
DATA_SET(inout_port_set, __CONCAT(__inout_port, __LINE__))
void init_inout(void);
-int emulate_inout(struct vmctx *, int vcpu, struct vm_exit *vmexit);
+int emulate_inout(struct vmctx *ctx, struct vcpu *vcpu, struct vm_exit *vmexit);
int register_inout(struct inout_port *iop);
int unregister_inout(struct inout_port *iop);
diff --git a/usr.sbin/bhyve/ioapic.c b/usr.sbin/bhyve/amd64/ioapic.c
index acdbb5111b2e..9ad1c501fbae 100644
--- a/usr.sbin/bhyve/ioapic.c
+++ b/usr.sbin/bhyve/amd64/ioapic.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Hudson River Trading LLC
* Written by: John H. Baldwin <jhb@FreeBSD.org>
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <stdio.h>
diff --git a/usr.sbin/bhyve/ioapic.h b/usr.sbin/bhyve/amd64/ioapic.h
index 3a7fa7619268..73e5c833eac4 100644
--- a/usr.sbin/bhyve/ioapic.h
+++ b/usr.sbin/bhyve/amd64/ioapic.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Hudson River Trading LLC
* Written by: John H. Baldwin <jhb@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 _IOAPIC_H_
diff --git a/usr.sbin/bhyve/kernemu_dev.c b/usr.sbin/bhyve/amd64/kernemu_dev.c
index 2fa0c3dc1f35..d1577a7b3e99 100644
--- a/usr.sbin/bhyve/kernemu_dev.c
+++ b/usr.sbin/bhyve/amd64/kernemu_dev.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright 2020 Conrad Meyer <cem@FreeBSD.org>. All rights reserved.
*
@@ -24,14 +24,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/tree.h>
-#include <amd64/include/vmm.h>
+#include <machine/vmm.h>
#include <x86/include/apicreg.h>
struct vm;
struct vm_hpet_cap;
@@ -46,10 +44,10 @@ struct vm_hpet_cap;
#include "mem.h"
static int
-apic_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr, int size,
+apic_handler(struct vcpu *vcpu, int dir, uint64_t addr, int size,
uint64_t *val, void *arg1 __unused, long arg2 __unused)
{
- if (vm_readwrite_kernemu_device(ctx, vcpu, addr, (dir == MEM_F_WRITE),
+ if (vm_readwrite_kernemu_device(vcpu, addr, (dir == MEM_F_WRITE),
size, val) != 0)
return (errno);
return (0);
diff --git a/usr.sbin/bhyve/kernemu_dev.h b/usr.sbin/bhyve/amd64/kernemu_dev.h
index 7927855da0cd..5f5cb24d17da 100644
--- a/usr.sbin/bhyve/kernemu_dev.h
+++ b/usr.sbin/bhyve/amd64/kernemu_dev.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright 2020 Conrad Meyer <cem@FreeBSD.org>. All rights reserved.
*
@@ -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/usr.sbin/bhyve/mptbl.c b/usr.sbin/bhyve/amd64/mptbl.c
index 56582256a857..328cc77980ac 100644
--- a/usr.sbin/bhyve/mptbl.c
+++ b/usr.sbin/bhyve/amd64/mptbl.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/types.h>
#include <sys/errno.h>
#include <x86/mptable.h>
@@ -213,7 +208,7 @@ mpt_count_ioint_entries(void)
}
static void
-mpt_generate_pci_int(int bus, int slot, int pin, int pirq_pin, int ioapic_irq,
+mpt_generate_pci_int(int bus, int slot, int pin, struct pci_irq *irq,
void *arg)
{
int_entry_ptr *mpiep, mpie;
@@ -231,7 +226,7 @@ mpt_generate_pci_int(int bus, int slot, int pin, int pirq_pin, int ioapic_irq,
mpie->src_bus_id = bus;
mpie->src_bus_irq = slot << 2 | (pin - 1);
mpie->dst_apic_id = mpie[-1].dst_apic_id;
- mpie->dst_apic_int = ioapic_irq;
+ mpie->dst_apic_int = irq->ioapic_irq;
*mpiep = mpie + 1;
}
diff --git a/usr.sbin/bhyve/mptbl.h b/usr.sbin/bhyve/amd64/mptbl.h
index ebc8d85ea8e0..002edb32e6cb 100644
--- a/usr.sbin/bhyve/mptbl.h
+++ b/usr.sbin/bhyve/amd64/mptbl.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 NetApp, Inc.
* 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 _MPTBL_H_
diff --git a/usr.sbin/bhyve/amd64/pci_gvt-d-opregion.h b/usr.sbin/bhyve/amd64/pci_gvt-d-opregion.h
new file mode 100644
index 000000000000..f506f1449e48
--- /dev/null
+++ b/usr.sbin/bhyve/amd64/pci_gvt-d-opregion.h
@@ -0,0 +1,186 @@
+/** @file
+ IGD OpRegion definition from Intel Integrated Graphics Device OpRegion
+ Specification.
+
+ https://01.org/sites/default/files/documentation/skl_opregion_rev0p5.pdf
+
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/*
+ * See
+ * <https://github.com/tianocore/edk2-platforms/blob/82979ab1ca44101e0b92a9c4bda1dfe64a8249f6/Silicon/Intel/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h>
+ */
+
+#pragma once
+
+#include <sys/types.h>
+
+#define IGD_OPREGION_HEADER_SIGN "IntelGraphicsMem"
+#define IGD_OPREGION_HEADER_MBOX1 BIT0
+#define IGD_OPREGION_HEADER_MBOX2 BIT1
+#define IGD_OPREGION_HEADER_MBOX3 BIT2
+#define IGD_OPREGION_HEADER_MBOX4 BIT3
+#define IGD_OPREGION_HEADER_MBOX5 BIT4
+
+#define IGD_OPREGION_VBT_SIZE_6K (6 * 1024UL)
+
+/**
+ OpRegion structures:
+ Sub-structures define the different parts of the OpRegion followed by the
+ main structure representing the entire OpRegion.
+ @note These structures are packed to 1 byte offsets because the exact
+ data location is required by the supporting design specification due to
+ the fact that the data is used by ASL and Graphics driver code compiled
+ separately.
+**/
+
+///
+/// OpRegion Mailbox 0 Header structure. The OpRegion Header is used to
+/// identify a block of memory as the graphics driver OpRegion.
+/// Offset 0x0, Size 0x100
+///
+struct igd_opregion_header {
+ int8_t sign[0x10]; ///< Offset 0x00 OpRegion Signature
+ uint32_t size; ///< Offset 0x10 OpRegion Size
+ uint32_t over; ///< Offset 0x14 OpRegion Structure Version
+ uint8_t sver[0x20]; ///< Offset 0x18 System BIOS Build Version
+ uint8_t vver[0x10]; ///< Offset 0x38 Video BIOS Build Version
+ uint8_t gver[0x10]; ///< Offset 0x48 Graphic Driver Build Version
+ uint32_t mbox; ///< Offset 0x58 Supported Mailboxes
+ uint32_t dmod; ///< Offset 0x5C Driver Model
+ uint32_t pcon; ///< Offset 0x60 Platform Configuration
+ int16_t dver[0x10]; ///< Offset 0x64 GOP Version
+ uint8_t rm01[0x7C]; ///< Offset 0x84 Reserved Must be zero
+} __packed;
+
+///
+/// OpRegion Mailbox 1 - Public ACPI Methods
+/// Offset 0x100, Size 0x100
+///
+struct igd_opregion_mbox1 {
+ uint32_t drdy; ///< Offset 0x100 Driver Readiness
+ uint32_t csts; ///< Offset 0x104 Status
+ uint32_t cevt; ///< Offset 0x108 Current Event
+ uint8_t rm11[0x14]; ///< Offset 0x10C Reserved Must be Zero
+ uint32_t didl[8]; ///< Offset 0x120 Supported Display Devices ID List
+ uint32_t
+ cpdl[8]; ///< Offset 0x140 Currently Attached Display Devices List
+ uint32_t
+ cadl[8]; ///< Offset 0x160 Currently Active Display Devices List
+ uint32_t nadl[8]; ///< Offset 0x180 Next Active Devices List
+ uint32_t aslp; ///< Offset 0x1A0 ASL Sleep Time Out
+ uint32_t tidx; ///< Offset 0x1A4 Toggle Table Index
+ uint32_t chpd; ///< Offset 0x1A8 Current Hotplug Enable Indicator
+ uint32_t clid; ///< Offset 0x1AC Current Lid State Indicator
+ uint32_t cdck; ///< Offset 0x1B0 Current Docking State Indicator
+ uint32_t sxsw; ///< Offset 0x1B4 Display Switch Notification on Sx
+ ///< StateResume
+ uint32_t evts; ///< Offset 0x1B8 Events supported by ASL
+ uint32_t cnot; ///< Offset 0x1BC Current OS Notification
+ uint32_t NRDY; ///< Offset 0x1C0 Driver Status
+ uint8_t did2[0x1C]; ///< Offset 0x1C4 Extended Supported Devices ID
+ ///< List(DOD)
+ uint8_t
+ cpd2[0x1C]; ///< Offset 0x1E0 Extended Attached Display Devices List
+ uint8_t rm12[4]; ///< Offset 0x1FC - 0x1FF Reserved Must be zero
+} __packed;
+
+///
+/// OpRegion Mailbox 2 - Software SCI Interface
+/// Offset 0x200, Size 0x100
+///
+struct igd_opregion_mbox2 {
+ uint32_t scic; ///< Offset 0x200 Software SCI Command / Status / Data
+ uint32_t parm; ///< Offset 0x204 Software SCI Parameters
+ uint32_t dslp; ///< Offset 0x208 Driver Sleep Time Out
+ uint8_t rm21[0xF4]; ///< Offset 0x20C - 0x2FF Reserved Must be zero
+} __packed;
+
+///
+/// OpRegion Mailbox 3 - BIOS/Driver Notification - ASLE Support
+/// Offset 0x300, Size 0x100
+///
+struct igd_opregion_mbox3 {
+ uint32_t ardy; ///< Offset 0x300 Driver Readiness
+ uint32_t aslc; ///< Offset 0x304 ASLE Interrupt Command / Status
+ uint32_t tche; ///< Offset 0x308 Technology Enabled Indicator
+ uint32_t alsi; ///< Offset 0x30C Current ALS Luminance Reading
+ uint32_t bclp; ///< Offset 0x310 Requested Backlight Brightness
+ uint32_t pfit; ///< Offset 0x314 Panel Fitting State or Request
+ uint32_t cblv; ///< Offset 0x318 Current Brightness Level
+ uint16_t bclm[0x14]; ///< Offset 0x31C Backlight Brightness Levels Duty
+ ///< Cycle Mapping Table
+ uint32_t cpfm; ///< Offset 0x344 Current Panel Fitting Mode
+ uint32_t epfm; ///< Offset 0x348 Enabled Panel Fitting Modes
+ uint8_t plut[0x4A]; ///< Offset 0x34C Panel Look Up Table & Identifier
+ uint32_t pfmb; ///< Offset 0x396 PWM Frequency and Minimum Brightness
+ uint32_t ccdv; ///< Offset 0x39A Color Correction Default Values
+ uint32_t pcft; ///< Offset 0x39E Power Conservation Features
+ uint32_t srot; ///< Offset 0x3A2 Supported Rotation Angles
+ uint32_t iuer; ///< Offset 0x3A6 Intel Ultrabook(TM) Event Register
+ uint64_t fdss; ///< Offset 0x3AA DSS Buffer address allocated for IFFS
+ ///< feature
+ uint32_t fdsp; ///< Offset 0x3B2 Size of DSS buffer
+ uint32_t stat; ///< Offset 0x3B6 State Indicator
+ uint64_t rvda; ///< Offset 0x3BA Absolute/Relative Address of Raw VBT
+ ///< Data from OpRegion Base
+ uint32_t rvds; ///< Offset 0x3C2 Raw VBT Data Size
+ uint8_t rsvd2[0x3A]; ///< Offset 0x3C6 - 0x3FF Reserved Must be zero.
+ ///< Bug in spec 0x45(69)
+} __packed;
+
+///
+/// OpRegion Mailbox 4 - VBT Video BIOS Table
+/// Offset 0x400, Size 0x1800
+///
+struct igd_opregion_mbox4 {
+ uint8_t rvbt[IGD_OPREGION_VBT_SIZE_6K]; ///< Offset 0x400 - 0x1BFF Raw
+ ///< VBT Data
+} __packed;
+
+///
+/// OpRegion Mailbox 5 - BIOS/Driver Notification - Data storage BIOS to Driver
+/// data sync Offset 0x1C00, Size 0x400
+///
+struct igd_opregion_mbox5 {
+ uint32_t phed; ///< Offset 0x1C00 Panel Header
+ uint8_t bddc[0x100]; ///< Offset 0x1C04 Panel EDID (DDC data)
+ uint8_t rm51[0x2FC]; ///< Offset 0x1D04 - 0x1FFF Reserved Must be zero
+} __packed;
+
+///
+/// IGD OpRegion Structure
+///
+struct igd_opregion {
+ struct igd_opregion_header
+ header; ///< OpRegion header (Offset 0x0, Size 0x100)
+ struct igd_opregion_mbox1 mbox1; ///< Mailbox 1: Public ACPI Methods
+ ///< (Offset 0x100, Size 0x100)
+ struct igd_opregion_mbox2 mbox2; ///< Mailbox 2: Software SCI Interface
+ ///< (Offset 0x200, Size 0x100)
+ struct igd_opregion_mbox3
+ mbox3; ///< Mailbox 3: BIOS to Driver Notification (Offset 0x300,
+ ///< Size 0x100)
+ struct igd_opregion_mbox4 mbox4; ///< Mailbox 4: Video BIOS Table (VBT)
+ ///< (Offset 0x400, Size 0x1800)
+ struct igd_opregion_mbox5
+ mbox5; ///< Mailbox 5: BIOS to Driver Notification Extension (Offset
+ ///< 0x1C00, Size 0x400)
+} __packed;
+
+///
+/// VBT Header Structure
+///
+struct vbt_header {
+ uint8_t product_string[20];
+ uint16_t version;
+ uint16_t header_size;
+ uint16_t table_size;
+ uint8_t checksum;
+ uint8_t reserved1;
+ uint32_t bios_data_offset;
+ uint32_t aim_data_offset[4];
+} __packed;
diff --git a/usr.sbin/bhyve/amd64/pci_gvt-d.c b/usr.sbin/bhyve/amd64/pci_gvt-d.c
new file mode 100644
index 000000000000..f64cc5984352
--- /dev/null
+++ b/usr.sbin/bhyve/amd64/pci_gvt-d.c
@@ -0,0 +1,304 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2020 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/sysctl.h>
+
+#include <dev/pci/pcireg.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "amd64/e820.h"
+#include "pci_gvt-d-opregion.h"
+#include "pci_passthru.h"
+
+#define KB (1024UL)
+#define MB (1024 * KB)
+#define GB (1024 * MB)
+
+#ifndef _PATH_MEM
+#define _PATH_MEM "/dev/mem"
+#endif
+
+#define PCI_VENDOR_INTEL 0x8086
+
+#define PCIR_BDSM 0x5C /* Base of Data Stolen Memory register */
+#define PCIR_ASLS_CTL 0xFC /* Opregion start address register */
+
+#define PCIM_BDSM_GSM_ALIGNMENT \
+ 0x00100000 /* Graphics Stolen Memory is 1 MB aligned */
+
+#define GVT_D_MAP_GSM 0
+#define GVT_D_MAP_OPREGION 1
+
+static int
+gvt_d_probe(struct pci_devinst *const pi)
+{
+ struct passthru_softc *sc;
+ uint16_t vendor;
+ uint8_t class;
+
+ sc = pi->pi_arg;
+
+ vendor = pci_host_read_config(passthru_get_sel(sc), PCIR_VENDOR, 0x02);
+ if (vendor != PCI_VENDOR_INTEL)
+ return (ENXIO);
+
+ class = pci_host_read_config(passthru_get_sel(sc), PCIR_CLASS, 0x01);
+ if (class != PCIC_DISPLAY)
+ return (ENXIO);
+
+ return (0);
+}
+
+static vm_paddr_t
+gvt_d_alloc_mmio_memory(const vm_paddr_t host_address, const vm_paddr_t length,
+ const vm_paddr_t alignment, const enum e820_memory_type type)
+{
+ vm_paddr_t address;
+
+ /* Try to reuse host address. */
+ address = e820_alloc(host_address, length, E820_ALIGNMENT_NONE, type,
+ E820_ALLOCATE_SPECIFIC);
+ if (address != 0) {
+ return (address);
+ }
+
+ /*
+ * We're not able to reuse the host address. Fall back to the highest usable
+ * address below 4 GB.
+ */
+ return (
+ e820_alloc(4 * GB, length, alignment, type, E820_ALLOCATE_HIGHEST));
+}
+
+/*
+ * Note that the graphics stolen memory is somehow confusing. On the one hand
+ * the Intel Open Source HD Graphics Programmers' Reference Manual states that
+ * it's only GPU accessible. As the CPU can't access the area, the guest
+ * shouldn't need it. On the other hand, the Intel GOP driver refuses to work
+ * properly, if it's not set to a proper address.
+ *
+ * Intel itself maps it into the guest by EPT [1]. At the moment, we're not
+ * aware of any situation where this EPT mapping is required, so we don't do it
+ * yet.
+ *
+ * Intel also states that the Windows driver for Tiger Lake reads the address of
+ * the graphics stolen memory [2]. As the GVT-d code doesn't support Tiger Lake
+ * in its first implementation, we can't check how it behaves. We should keep an
+ * eye on it.
+ *
+ * [1]
+ * https://github.com/projectacrn/acrn-hypervisor/blob/e28d6fbfdfd556ff1bc3ff330e41d4ddbaa0f897/devicemodel/hw/pci/passthrough.c#L655-L657
+ * [2]
+ * https://github.com/projectacrn/acrn-hypervisor/blob/e28d6fbfdfd556ff1bc3ff330e41d4ddbaa0f897/devicemodel/hw/pci/passthrough.c#L626-L629
+ */
+static int
+gvt_d_setup_gsm(struct pci_devinst *const pi)
+{
+ struct passthru_softc *sc;
+ struct passthru_mmio_mapping *gsm;
+ size_t sysctl_len;
+ uint32_t bdsm;
+ int error;
+
+ sc = pi->pi_arg;
+
+ gsm = passthru_get_mmio(sc, GVT_D_MAP_GSM);
+ if (gsm == NULL) {
+ warnx("%s: Unable to access gsm", __func__);
+ return (-1);
+ }
+
+ sysctl_len = sizeof(gsm->hpa);
+ error = sysctlbyname("hw.intel_graphics_stolen_base", &gsm->hpa,
+ &sysctl_len, NULL, 0);
+ if (error) {
+ warn("%s: Unable to get graphics stolen memory base",
+ __func__);
+ return (-1);
+ }
+ sysctl_len = sizeof(gsm->len);
+ error = sysctlbyname("hw.intel_graphics_stolen_size", &gsm->len,
+ &sysctl_len, NULL, 0);
+ if (error) {
+ warn("%s: Unable to get graphics stolen memory length",
+ __func__);
+ return (-1);
+ }
+ gsm->hva = NULL; /* unused */
+ gsm->gva = NULL; /* unused */
+ gsm->gpa = gvt_d_alloc_mmio_memory(gsm->hpa, gsm->len,
+ PCIM_BDSM_GSM_ALIGNMENT, E820_TYPE_RESERVED);
+ if (gsm->gpa == 0) {
+ warnx(
+ "%s: Unable to add Graphics Stolen Memory to E820 table (hpa 0x%lx len 0x%lx)",
+ __func__, gsm->hpa, gsm->len);
+ e820_dump_table();
+ return (-1);
+ }
+ if (gsm->gpa != gsm->hpa) {
+ /*
+ * ACRN source code implies that graphics driver for newer Intel
+ * platforms like Tiger Lake will read the Graphics Stolen Memory
+ * address from an MMIO register. We have three options to solve this
+ * issue:
+ * 1. Patch the value in the MMIO register
+ * This could have unintended side effects. Without any
+ * documentation how this register is used by the GPU, don't do
+ * it.
+ * 2. Trap the MMIO register
+ * It's not possible to trap a single MMIO register. We need to
+ * trap a whole page. Trapping a bunch of MMIO register could
+ * degrade the performance noticeably. We have to test it.
+ * 3. Use an 1:1 host to guest mapping
+ * Maybe not always possible. As far as we know, no supported
+ * platform requires a 1:1 mapping. For that reason, just log a
+ * warning.
+ */
+ warnx(
+ "Warning: Unable to reuse host address of Graphics Stolen Memory. GPU passthrough might not work properly.");
+ }
+
+ bdsm = pci_host_read_config(passthru_get_sel(sc), PCIR_BDSM, 4);
+ pci_set_cfgdata32(pi, PCIR_BDSM,
+ gsm->gpa | (bdsm & (PCIM_BDSM_GSM_ALIGNMENT - 1)));
+
+ return (set_pcir_handler(sc, PCIR_BDSM, 4, passthru_cfgread_emulate,
+ passthru_cfgwrite_emulate));
+}
+
+static int
+gvt_d_setup_opregion(struct pci_devinst *const pi)
+{
+ struct passthru_softc *sc;
+ struct passthru_mmio_mapping *opregion;
+ struct igd_opregion_header *header;
+ uint64_t asls;
+ int memfd;
+
+ sc = pi->pi_arg;
+
+ memfd = open(_PATH_MEM, O_RDONLY, 0);
+ if (memfd < 0) {
+ warn("%s: Failed to open %s", __func__, _PATH_MEM);
+ return (-1);
+ }
+
+ opregion = passthru_get_mmio(sc, GVT_D_MAP_OPREGION);
+ if (opregion == NULL) {
+ warnx("%s: Unable to access opregion", __func__);
+ close(memfd);
+ return (-1);
+ }
+
+ asls = pci_host_read_config(passthru_get_sel(sc), PCIR_ASLS_CTL, 4);
+
+ header = mmap(NULL, sizeof(*header), PROT_READ, MAP_SHARED, memfd,
+ asls);
+ if (header == MAP_FAILED) {
+ warn("%s: Unable to map OpRegion header", __func__);
+ close(memfd);
+ return (-1);
+ }
+ if (memcmp(header->sign, IGD_OPREGION_HEADER_SIGN,
+ sizeof(header->sign)) != 0) {
+ warnx("%s: Invalid OpRegion signature", __func__);
+ munmap(header, sizeof(*header));
+ close(memfd);
+ return (-1);
+ }
+
+ opregion->hpa = asls;
+ opregion->len = header->size * KB;
+ munmap(header, sizeof(header));
+
+ opregion->hva = mmap(NULL, opregion->len * KB, PROT_READ, MAP_SHARED,
+ memfd, opregion->hpa);
+ if (opregion->hva == MAP_FAILED) {
+ warn("%s: Unable to map host OpRegion", __func__);
+ close(memfd);
+ return (-1);
+ }
+ close(memfd);
+
+ opregion->gpa = gvt_d_alloc_mmio_memory(opregion->hpa, opregion->len,
+ E820_ALIGNMENT_NONE, E820_TYPE_NVS);
+ if (opregion->gpa == 0) {
+ warnx(
+ "%s: Unable to add OpRegion to E820 table (hpa 0x%lx len 0x%lx)",
+ __func__, opregion->hpa, opregion->len);
+ e820_dump_table();
+ return (-1);
+ }
+ opregion->gva = vm_map_gpa(pi->pi_vmctx, opregion->gpa, opregion->len);
+ if (opregion->gva == NULL) {
+ warnx("%s: Unable to map guest OpRegion", __func__);
+ return (-1);
+ }
+ if (opregion->gpa != opregion->hpa) {
+ /*
+ * A 1:1 host to guest mapping is not required but this could
+ * change in the future.
+ */
+ warnx(
+ "Warning: Unable to reuse host address of OpRegion. GPU passthrough might not work properly.");
+ }
+
+ memcpy(opregion->gva, opregion->hva, opregion->len);
+
+ pci_set_cfgdata32(pi, PCIR_ASLS_CTL, opregion->gpa);
+
+ return (set_pcir_handler(sc, PCIR_ASLS_CTL, 4, passthru_cfgread_emulate,
+ passthru_cfgwrite_emulate));
+}
+
+static int
+gvt_d_init(struct pci_devinst *const pi, nvlist_t *const nvl __unused)
+{
+ int error;
+
+ if ((error = gvt_d_setup_gsm(pi)) != 0) {
+ warnx("%s: Unable to setup Graphics Stolen Memory", __func__);
+ goto done;
+ }
+
+ if ((error = gvt_d_setup_opregion(pi)) != 0) {
+ warnx("%s: Unable to setup OpRegion", __func__);
+ goto done;
+ }
+
+done:
+ return (error);
+}
+
+static void
+gvt_d_deinit(struct pci_devinst *const pi)
+{
+ struct passthru_softc *sc;
+ struct passthru_mmio_mapping *opregion;
+
+ sc = pi->pi_arg;
+
+ opregion = passthru_get_mmio(sc, GVT_D_MAP_OPREGION);
+
+ /* HVA is only set, if it's initialized */
+ if (opregion->hva)
+ munmap((void *)opregion->hva, opregion->len);
+}
+
+static struct passthru_dev gvt_d_dev = {
+ .probe = gvt_d_probe,
+ .init = gvt_d_init,
+ .deinit = gvt_d_deinit,
+};
+PASSTHRU_DEV_SET(gvt_d_dev);
diff --git a/usr.sbin/bhyve/pci_irq.c b/usr.sbin/bhyve/amd64/pci_irq.c
index 4ecb3eddb07f..7e1aee7fbb1d 100644
--- a/usr.sbin/bhyve/pci_irq.c
+++ b/usr.sbin/bhyve/amd64/pci_irq.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Hudson River Trading LLC
* Written by: John H. Baldwin <jhb@FreeBSD.org>
@@ -27,10 +27,6 @@
* SUCH DAMAGE.
*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <machine/vmm.h>
@@ -43,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include "acpi.h"
#include "inout.h"
+#include "ioapic.h"
#include "pci_emul.h"
#include "pci_irq.h"
#include "pci_lpc.h"
@@ -63,14 +60,16 @@ __FBSDID("$FreeBSD$");
/* IRQ count to disable an IRQ. */
#define IRQ_DISABLED 0xff
+#define NPIRQS 8
static struct pirq {
uint8_t reg;
int use_count;
int active_count;
pthread_mutex_t lock;
-} pirqs[8];
+} pirqs[NPIRQS];
-static u_char irq_counts[16];
+#define NIRQ_COUNTS 16
+static u_char irq_counts[NIRQ_COUNTS];
static int pirq_cold = 1;
/*
@@ -91,7 +90,7 @@ uint8_t
pirq_read(int pin)
{
- assert(pin > 0 && pin <= nitems(pirqs));
+ assert(pin > 0 && pin <= NPIRQS);
return (pirqs[pin - 1].reg);
}
@@ -100,7 +99,7 @@ pirq_write(struct vmctx *ctx, int pin, uint8_t val)
{
struct pirq *pirq;
- assert(pin > 0 && pin <= nitems(pirqs));
+ assert(pin > 0 && pin <= NPIRQS);
pirq = &pirqs[pin - 1];
pthread_mutex_lock(&pirq->lock);
if (pirq->reg != (val & (PIRQ_DIS | PIRQ_IRQ))) {
@@ -117,7 +116,7 @@ void
pci_irq_reserve(int irq)
{
- assert(irq >= 0 && irq < nitems(irq_counts));
+ assert(irq >= 0 && irq < NIRQ_COUNTS);
assert(pirq_cold);
assert(irq_counts[irq] == 0 || irq_counts[irq] == IRQ_DISABLED);
irq_counts[irq] = IRQ_DISABLED;
@@ -127,24 +126,24 @@ void
pci_irq_use(int irq)
{
- assert(irq >= 0 && irq < nitems(irq_counts));
+ assert(irq >= 0 && irq < NIRQ_COUNTS);
assert(pirq_cold);
assert(irq_counts[irq] != IRQ_DISABLED);
irq_counts[irq]++;
}
void
-pci_irq_init(struct vmctx *ctx)
+pci_irq_init(struct vmctx *ctx __unused)
{
int i;
- for (i = 0; i < nitems(pirqs); i++) {
+ for (i = 0; i < NPIRQS; i++) {
pirqs[i].reg = PIRQ_DIS;
pirqs[i].use_count = 0;
pirqs[i].active_count = 0;
pthread_mutex_init(&pirqs[i].lock, NULL);
}
- for (i = 0; i < nitems(irq_counts); i++) {
+ for (i = 0; i < NIRQ_COUNTS; i++) {
if (IRQ_PERMITTED(i))
irq_counts[i] = 0;
else
@@ -156,45 +155,49 @@ void
pci_irq_assert(struct pci_devinst *pi)
{
struct pirq *pirq;
+ int pin;
- if (pi->pi_lintr.pirq_pin > 0) {
- assert(pi->pi_lintr.pirq_pin <= nitems(pirqs));
- pirq = &pirqs[pi->pi_lintr.pirq_pin - 1];
+ pin = pi->pi_lintr.irq.pirq_pin;
+ if (pin > 0) {
+ assert(pin <= NPIRQS);
+ pirq = &pirqs[pin - 1];
pthread_mutex_lock(&pirq->lock);
pirq->active_count++;
if (pirq->active_count == 1 && pirq_valid_irq(pirq->reg)) {
vm_isa_assert_irq(pi->pi_vmctx, pirq->reg & PIRQ_IRQ,
- pi->pi_lintr.ioapic_irq);
+ pi->pi_lintr.irq.ioapic_irq);
pthread_mutex_unlock(&pirq->lock);
return;
}
pthread_mutex_unlock(&pirq->lock);
}
- vm_ioapic_assert_irq(pi->pi_vmctx, pi->pi_lintr.ioapic_irq);
+ vm_ioapic_assert_irq(pi->pi_vmctx, pi->pi_lintr.irq.ioapic_irq);
}
void
pci_irq_deassert(struct pci_devinst *pi)
{
struct pirq *pirq;
+ int pin;
- if (pi->pi_lintr.pirq_pin > 0) {
- assert(pi->pi_lintr.pirq_pin <= nitems(pirqs));
- pirq = &pirqs[pi->pi_lintr.pirq_pin - 1];
+ pin = pi->pi_lintr.irq.pirq_pin;
+ if (pin > 0) {
+ assert(pin <= NPIRQS);
+ pirq = &pirqs[pin - 1];
pthread_mutex_lock(&pirq->lock);
pirq->active_count--;
if (pirq->active_count == 0 && pirq_valid_irq(pirq->reg)) {
vm_isa_deassert_irq(pi->pi_vmctx, pirq->reg & PIRQ_IRQ,
- pi->pi_lintr.ioapic_irq);
+ pi->pi_lintr.irq.ioapic_irq);
pthread_mutex_unlock(&pirq->lock);
return;
}
pthread_mutex_unlock(&pirq->lock);
}
- vm_ioapic_deassert_irq(pi->pi_vmctx, pi->pi_lintr.ioapic_irq);
+ vm_ioapic_deassert_irq(pi->pi_vmctx, pi->pi_lintr.irq.ioapic_irq);
}
-int
+static int
pirq_alloc_pin(struct pci_devinst *pi)
{
struct vmctx *ctx = pi->pi_vmctx;
@@ -209,7 +212,7 @@ pirq_alloc_pin(struct pci_devinst *pi)
/* Find the least-used PIRQ pin. */
best_pin = 0;
best_count = pirqs[0].use_count;
- for (pin = 1; pin < nitems(pirqs); pin++) {
+ for (pin = 1; pin < NPIRQS; pin++) {
if (pirqs[pin].use_count < best_count) {
best_pin = pin;
best_count = pirqs[pin].use_count;
@@ -222,7 +225,7 @@ pirq_alloc_pin(struct pci_devinst *pi)
if (pirqs[best_pin].reg == PIRQ_DIS) {
best_irq = -1;
best_count = 0;
- for (irq = 0; irq < nitems(irq_counts); irq++) {
+ for (irq = 0; irq < NIRQ_COUNTS; irq++) {
if (irq_counts[irq] == IRQ_DISABLED)
continue;
if (best_irq == -1 || irq_counts[irq] < best_count) {
@@ -242,10 +245,30 @@ pirq_alloc_pin(struct pci_devinst *pi)
int
pirq_irq(int pin)
{
- assert(pin > 0 && pin <= nitems(pirqs));
+ assert(pin > 0 && pin <= NPIRQS);
return (pirqs[pin - 1].reg & PIRQ_IRQ);
}
+void
+pci_irq_route(struct pci_devinst *pi, struct pci_irq *irq)
+{
+ /*
+ * Attempt to allocate an I/O APIC pin for this intpin if one
+ * is not yet assigned.
+ */
+ if (irq->ioapic_irq == 0)
+ irq->ioapic_irq = ioapic_pci_alloc_irq(pi);
+ assert(irq->ioapic_irq > 0);
+
+ /*
+ * Attempt to allocate a PIRQ pin for this intpin if one is
+ * not yet assigned.
+ */
+ if (irq->pirq_pin == 0)
+ irq->pirq_pin = pirq_alloc_pin(pi);
+ assert(irq->pirq_pin > 0);
+}
+
/* XXX: Generate $PIR table. */
static void
@@ -255,7 +278,7 @@ pirq_dsdt(void)
int irq, pin;
irq_prs = NULL;
- for (irq = 0; irq < nitems(irq_counts); irq++) {
+ for (irq = 0; irq < NIRQ_COUNTS; irq++) {
if (!IRQ_PERMITTED(irq))
continue;
if (irq_prs == NULL)
@@ -294,7 +317,7 @@ pirq_dsdt(void)
dsdt_line(" Return (0x01)");
dsdt_line("}");
- for (pin = 0; pin < nitems(pirqs); pin++) {
+ for (pin = 0; pin < NPIRQS; pin++) {
dsdt_line("");
dsdt_line("Device (LNK%c)", 'A' + pin);
dsdt_line("{");
diff --git a/usr.sbin/bhyve/amd64/pci_irq_machdep.h b/usr.sbin/bhyve/amd64/pci_irq_machdep.h
new file mode 100644
index 000000000000..c4be29babe34
--- /dev/null
+++ b/usr.sbin/bhyve/amd64/pci_irq_machdep.h
@@ -0,0 +1,60 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2014 Hudson River Trading LLC
+ * Written by: John H. Baldwin <jhb@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __PCI_IRQ_MD_H__
+#define __PCI_IRQ_MD_H__
+
+struct vmctx;
+
+struct pci_irq {
+ int pirq_pin;
+ int ioapic_irq;
+};
+
+void pci_irq_init(struct vmctx *ctx);
+void pci_irq_reserve(int irq);
+void pci_irq_use(int irq);
+int pirq_irq(int pin);
+uint8_t pirq_read(int pin);
+void pirq_write(struct vmctx *ctx, int pin, uint8_t val);
+
+static inline void
+pci_irq_init_irq(struct pci_irq *irq)
+{
+ irq->pirq_pin = 0;
+ irq->ioapic_irq = 0;
+}
+
+static inline uint8_t
+pci_irq_intline(struct pci_irq *irq)
+{
+ return (pirq_irq(irq->pirq_pin));
+}
+
+#endif
diff --git a/usr.sbin/bhyve/pci_lpc.c b/usr.sbin/bhyve/amd64/pci_lpc.c
index 5c3aa238f43d..57d2333edcc6 100644
--- a/usr.sbin/bhyve/pci_lpc.c
+++ b/usr.sbin/bhyve/amd64/pci_lpc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Neel Natu <neel@freebsd.org>
* Copyright (c) 2013 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
@@ -25,13 +25,8 @@
* 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 <sys/types.h>
#include <machine/vmm.h>
#include <machine/vmm_snapshot.h>
@@ -51,7 +46,9 @@ __FBSDID("$FreeBSD$");
#include "pci_emul.h"
#include "pci_irq.h"
#include "pci_lpc.h"
+#include "pci_passthru.h"
#include "pctestdev.h"
+#include "tpm_device.h"
#include "uart_emul.h"
#define IO_ICU1 0x20
@@ -72,7 +69,7 @@ static struct pci_devinst *lpc_bridge;
#define LPC_UART_NUM 4
static struct lpc_uart_softc {
- struct uart_softc *uart_softc;
+ struct uart_ns16550_softc *uart_softc;
int iobase;
int irq;
int enabled;
@@ -96,7 +93,7 @@ lpc_device_parse(const char *opts)
{
int unit, error;
char *str, *cpy, *lpcdev, *node_name;
- const char *romfile, *varfile;
+ const char *romfile, *varfile, *tpm_type, *tpm_path;
error = -1;
str = cpy = strdup(opts);
@@ -110,10 +107,41 @@ lpc_device_parse(const char *opts)
set_config_value("lpc.bootrom", romfile);
varfile = strsep(&str, ",");
- if (varfile != NULL) {
+ if (varfile == NULL) {
+ error = 0;
+ goto done;
+ }
+ if (strchr(varfile, '=') == NULL) {
set_config_value("lpc.bootvars", varfile);
+ } else {
+ /* varfile doesn't exist, it's another config
+ * option */
+ pci_parse_legacy_config(find_config_node("lpc"),
+ varfile);
+ }
+
+ pci_parse_legacy_config(find_config_node("lpc"), str);
+ error = 0;
+ goto done;
+ }
+ if (strcasecmp(lpcdev, "tpm") == 0) {
+ nvlist_t *nvl = create_config_node("tpm");
+
+ tpm_type = strsep(&str, ",");
+ if (tpm_type == NULL) {
+ errx(4, "invalid tpm type \"%s\"", opts);
}
+ set_config_value_node(nvl, "type", tpm_type);
+
+ tpm_path = strsep(&str, ",");
+ if (tpm_path == NULL) {
+ errx(4, "invalid tpm path \"%s\"", opts);
+ }
+ set_config_value_node(nvl, "path", tpm_path);
+
+ pci_parse_legacy_config(find_config_node("tpm"), str);
+ set_config_value_node_if_unset(nvl, "version", "2.0");
error = 0;
goto done;
}
@@ -143,13 +171,14 @@ done:
}
void
-lpc_print_supported_devices()
+lpc_print_supported_devices(void)
{
size_t i;
printf("bootrom\n");
for (i = 0; i < LPC_UART_NUM; i++)
printf("%s\n", lpc_uart_names[i]);
+ printf("tpm\n");
printf("%s\n", pctestdev_getname());
}
@@ -160,6 +189,12 @@ lpc_bootrom(void)
return (get_config_value("lpc.bootrom"));
}
+const char *
+lpc_fwcfg(void)
+{
+ return (get_config_value("lpc.fwcfg"));
+}
+
static void
lpc_uart_intr_assert(void *arg)
{
@@ -171,7 +206,7 @@ lpc_uart_intr_assert(void *arg)
}
static void
-lpc_uart_intr_deassert(void *arg)
+lpc_uart_intr_deassert(void *arg __unused)
{
/*
* The COM devices on the LPC bus generate edge triggered interrupts,
@@ -180,8 +215,8 @@ lpc_uart_intr_deassert(void *arg)
}
static int
-lpc_uart_io_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+lpc_uart_io_handler(struct vmctx *ctx __unused, int in,
+ int port, int bytes, uint32_t *eax, void *arg)
{
int offset;
struct lpc_uart_softc *sc = arg;
@@ -191,17 +226,19 @@ lpc_uart_io_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
switch (bytes) {
case 1:
if (in)
- *eax = uart_read(sc->uart_softc, offset);
+ *eax = uart_ns16550_read(sc->uart_softc, offset);
else
- uart_write(sc->uart_softc, offset, *eax);
+ uart_ns16550_write(sc->uart_softc, offset, *eax);
break;
case 2:
if (in) {
- *eax = uart_read(sc->uart_softc, offset);
- *eax |= uart_read(sc->uart_softc, offset + 1) << 8;
+ *eax = uart_ns16550_read(sc->uart_softc, offset);
+ *eax |=
+ uart_ns16550_read(sc->uart_softc, offset + 1) << 8;
} else {
- uart_write(sc->uart_softc, offset, *eax);
- uart_write(sc->uart_softc, offset + 1, *eax >> 8);
+ uart_ns16550_write(sc->uart_softc, offset, *eax);
+ uart_ns16550_write(sc->uart_softc, offset + 1,
+ *eax >> 8);
}
break;
default:
@@ -240,13 +277,14 @@ lpc_init(struct vmctx *ctx)
}
pci_irq_reserve(sc->irq);
- sc->uart_softc = uart_init(lpc_uart_intr_assert,
- lpc_uart_intr_deassert, sc);
+ sc->uart_softc = uart_ns16550_init(lpc_uart_intr_assert,
+ lpc_uart_intr_deassert, sc);
asprintf(&node_name, "lpc.%s.path", name);
backend = get_config_value(node_name);
free(node_name);
- if (uart_set_backend(sc->uart_softc, backend) != 0) {
+ if (backend != NULL &&
+ uart_ns16550_tty_open(sc->uart_softc, backend) != 0) {
EPRINTLN("Unable to initialize backend '%s' "
"for LPC device %s", backend, name);
return (-1);
@@ -255,7 +293,7 @@ lpc_init(struct vmctx *ctx)
bzero(&iop, sizeof(struct inout_port));
iop.name = name;
iop.port = sc->iobase;
- iop.size = UART_IO_BAR_SIZE;
+ iop.size = UART_NS16550_IO_BAR_SIZE;
iop.flags = IOPORT_F_INOUT;
iop.handler = lpc_uart_io_handler;
iop.arg = sc;
@@ -388,7 +426,7 @@ pci_lpc_uart_dsdt(void)
dsdt_line(" Name (_CRS, ResourceTemplate ()");
dsdt_line(" {");
dsdt_indent(2);
- dsdt_fixed_ioport(sc->iobase, UART_IO_BAR_SIZE);
+ dsdt_fixed_ioport(sc->iobase, UART_NS16550_IO_BAR_SIZE);
dsdt_fixed_irq(sc->irq);
dsdt_unindent(2);
dsdt_line(" })");
@@ -398,8 +436,7 @@ pci_lpc_uart_dsdt(void)
LPC_DSDT(pci_lpc_uart_dsdt);
static int
-pci_lpc_cfgwrite(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int coff, int bytes, uint32_t val)
+pci_lpc_cfgwrite(struct pci_devinst *pi, int coff, int bytes, uint32_t val)
{
int pirq_pin;
@@ -410,7 +447,7 @@ pci_lpc_cfgwrite(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
if (coff >= 0x68 && coff <= 0x6b)
pirq_pin = coff - 0x68 + 5;
if (pirq_pin != 0) {
- pirq_write(ctx, pirq_pin, val);
+ pirq_write(pi->pi_vmctx, pirq_pin, val);
pci_set_cfgdata8(pi, coff, pirq_read(pirq_pin));
return (0);
}
@@ -419,24 +456,64 @@ pci_lpc_cfgwrite(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
}
static void
-pci_lpc_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size, uint64_t value)
+pci_lpc_write(struct pci_devinst *pi __unused, int baridx __unused,
+ uint64_t offset __unused, int size __unused, uint64_t value __unused)
{
}
static uint64_t
-pci_lpc_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size)
+pci_lpc_read(struct pci_devinst *pi __unused, int baridx __unused,
+ uint64_t offset __unused, int size __unused)
{
return (0);
}
#define LPC_DEV 0x7000
#define LPC_VENDOR 0x8086
+#define LPC_REVID 0x00
+#define LPC_SUBVEND_0 0x0000
+#define LPC_SUBDEV_0 0x0000
static int
-pci_lpc_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_lpc_get_sel(struct pcisel *const sel)
{
+ assert(sel != NULL);
+
+ memset(sel, 0, sizeof(*sel));
+
+ for (uint8_t slot = 0; slot <= PCI_SLOTMAX; ++slot) {
+ uint8_t max_func = 0;
+
+ sel->pc_dev = slot;
+ sel->pc_func = 0;
+
+ if (pci_host_read_config(sel, PCIR_HDRTYPE, 1) & PCIM_MFDEV)
+ max_func = PCI_FUNCMAX;
+
+ for (uint8_t func = 0; func <= max_func; ++func) {
+ sel->pc_func = func;
+
+ if (pci_host_read_config(sel, PCIR_CLASS, 1) ==
+ PCIC_BRIDGE &&
+ pci_host_read_config(sel, PCIR_SUBCLASS, 1) ==
+ PCIS_BRIDGE_ISA) {
+ return (0);
+ }
+ }
+ }
+
+ warnx("%s: Unable to find host selector of LPC bridge.", __func__);
+
+ return (-1);
+}
+
+static int
+pci_lpc_init(struct pci_devinst *pi, nvlist_t *nvl)
+{
+ struct pcisel sel = { 0 };
+ struct pcisel *selp = NULL;
+ uint16_t device, subdevice, subvendor, vendor;
+ uint8_t revid;
/*
* Do not allow more than one LPC bridge to be configured.
@@ -456,14 +533,28 @@ pci_lpc_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
return (-1);
}
- if (lpc_init(ctx) != 0)
+ if (lpc_init(pi->pi_vmctx) != 0)
return (-1);
+ if (pci_lpc_get_sel(&sel) == 0)
+ selp = &sel;
+
+ vendor = pci_config_read_reg(selp, nvl, PCIR_VENDOR, 2, LPC_VENDOR);
+ device = pci_config_read_reg(selp, nvl, PCIR_DEVICE, 2, LPC_DEV);
+ revid = pci_config_read_reg(selp, nvl, PCIR_REVID, 1, LPC_REVID);
+ subvendor = pci_config_read_reg(selp, nvl, PCIR_SUBVEND_0, 2,
+ LPC_SUBVEND_0);
+ subdevice = pci_config_read_reg(selp, nvl, PCIR_SUBDEV_0, 2,
+ LPC_SUBDEV_0);
+
/* initialize config space */
- pci_set_cfgdata16(pi, PCIR_DEVICE, LPC_DEV);
- pci_set_cfgdata16(pi, PCIR_VENDOR, LPC_VENDOR);
+ pci_set_cfgdata16(pi, PCIR_VENDOR, vendor);
+ pci_set_cfgdata16(pi, PCIR_DEVICE, device);
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_BRIDGE);
pci_set_cfgdata8(pi, PCIR_SUBCLASS, PCIS_BRIDGE_ISA);
+ pci_set_cfgdata8(pi, PCIR_REVID, revid);
+ pci_set_cfgdata16(pi, PCIR_SUBVEND_0, subvendor);
+ pci_set_cfgdata16(pi, PCIR_SUBDEV_0, subdevice);
lpc_bridge = pi;
@@ -500,12 +591,12 @@ static int
pci_lpc_snapshot(struct vm_snapshot_meta *meta)
{
int unit, ret;
- struct uart_softc *sc;
+ struct uart_ns16550_softc *sc;
for (unit = 0; unit < LPC_UART_NUM; unit++) {
sc = lpc_uart_softc[unit].uart_softc;
- ret = uart_snapshot(sc, meta);
+ ret = uart_ns16550_snapshot(sc, meta);
if (ret != 0)
goto done;
}
@@ -515,7 +606,7 @@ done:
}
#endif
-struct pci_devemu pci_de_lpc = {
+static const struct pci_devemu pci_de_lpc = {
.pe_emu = "lpc",
.pe_init = pci_lpc_init,
.pe_write_dsdt = pci_lpc_write_dsdt,
diff --git a/usr.sbin/bhyve/pci_lpc.h b/usr.sbin/bhyve/amd64/pci_lpc.h
index 9041f79c507a..2dca8f7bec24 100644
--- a/usr.sbin/bhyve/pci_lpc.h
+++ b/usr.sbin/bhyve/amd64/pci_lpc.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Neel Natu <neel@freebsd.org>
* 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 _LPC_H_
@@ -68,9 +66,10 @@ struct lpc_sysres {
#define SYSRES_MEM(base, length) LPC_SYSRES(LPC_SYSRES_MEM, base, length)
int lpc_device_parse(const char *opt);
-void lpc_print_supported_devices();
+void lpc_print_supported_devices(void);
char *lpc_pirq_name(int pin);
void lpc_pirq_routed(void);
const char *lpc_bootrom(void);
+const char *lpc_fwcfg(void);
#endif
diff --git a/usr.sbin/bhyve/pm.c b/usr.sbin/bhyve/amd64/pm.c
index 9f467cb591e8..80882e3b8082 100644
--- a/usr.sbin/bhyve/pm.c
+++ b/usr.sbin/bhyve/amd64/pm.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Hudson River Trading LLC
* Written by: John H. Baldwin <jhb@FreeBSD.org>
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <machine/vmm.h>
@@ -60,8 +57,8 @@ static const unsigned gpe0_valid = (1u << GPE_VMGENC);
* reset.
*/
static int
-reset_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+reset_handler(struct vmctx *ctx __unused, int in,
+ int port __unused, int bytes, uint32_t *eax, void *arg __unused)
{
int error;
@@ -158,8 +155,8 @@ sci_update(struct vmctx *ctx)
}
static int
-pm1_status_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+pm1_status_handler(struct vmctx *ctx, int in,
+ int port __unused, int bytes, uint32_t *eax, void *arg __unused)
{
if (bytes != 2)
@@ -182,8 +179,8 @@ pm1_status_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
}
static int
-pm1_enable_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+pm1_enable_handler(struct vmctx *ctx, int in,
+ int port __unused, int bytes, uint32_t *eax, void *arg __unused)
{
if (bytes != 2)
@@ -208,7 +205,7 @@ INOUT_PORT(pm1_status, PM1A_EVT_ADDR, IOPORT_F_INOUT, pm1_status_handler);
INOUT_PORT(pm1_enable, PM1A_EVT_ADDR + 2, IOPORT_F_INOUT, pm1_enable_handler);
static void
-power_button_handler(int signal, enum ev_type type, void *arg)
+power_button_handler(int signal __unused, enum ev_type type __unused, void *arg)
{
struct vmctx *ctx;
@@ -235,8 +232,8 @@ static uint16_t pm1_control;
#define PM1_ALWAYS_ZERO 0xc003
static int
-pm1_control_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+pm1_control_handler(struct vmctx *ctx, int in,
+ int port __unused, int bytes, uint32_t *eax, void *arg __unused)
{
int error;
@@ -285,8 +282,8 @@ acpi_raise_gpe(struct vmctx *ctx, unsigned bit)
}
static int
-gpe0_sts(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+gpe0_sts(struct vmctx *ctx, int in, int port __unused,
+ int bytes, uint32_t *eax, void *arg __unused)
{
/*
* ACPI 6.2 specifies the GPE register blocks are accessed
@@ -309,8 +306,8 @@ gpe0_sts(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
INOUT_PORT(gpe0_sts, IO_GPE0_STS, IOPORT_F_INOUT, gpe0_sts);
static int
-gpe0_en(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+gpe0_en(struct vmctx *ctx, int in, int port __unused,
+ int bytes, uint32_t *eax, void *arg __unused)
{
if (bytes != 1)
return (-1);
@@ -333,8 +330,8 @@ INOUT_PORT(gpe0_en, IO_GPE0_EN, IOPORT_F_INOUT, gpe0_en);
* This write-only register is used to enable and disable ACPI.
*/
static int
-smi_cmd_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+smi_cmd_handler(struct vmctx *ctx, int in, int port __unused,
+ int bytes, uint32_t *eax, void *arg __unused)
{
assert(!in);
diff --git a/usr.sbin/bhyve/post.c b/usr.sbin/bhyve/amd64/post.c
index d3040a8df76f..6e44bb47bd3b 100644
--- a/usr.sbin/bhyve/post.c
+++ b/usr.sbin/bhyve/amd64/post.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/types.h>
#include <assert.h>
@@ -39,8 +34,8 @@ __FBSDID("$FreeBSD$");
#include "pci_lpc.h"
static int
-post_data_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+post_data_handler(struct vmctx *ctx __unused, int in,
+ int port __unused, int bytes, uint32_t *eax, void *arg __unused)
{
assert(in == 1);
diff --git a/usr.sbin/bhyve/ps2kbd.c b/usr.sbin/bhyve/amd64/ps2kbd.c
index 619bed81c412..27b5ccd0b316 100644
--- a/usr.sbin/bhyve/ps2kbd.c
+++ b/usr.sbin/bhyve/amd64/ps2kbd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* Copyright (c) 2015 Nahanni Systems Inc.
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
@@ -46,14 +43,16 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include <fcntl.h>
-#include "bhyverun.h"
#include "atkbdc.h"
-#include "debug.h"
+#include "bhyverun.h"
#include "config.h"
#include "console.h"
+#include "debug.h"
+#include "ps2kbd.h"
/* keyboard device commands */
#define PS2KC_RESET_DEV 0xff
+#define PS2KC_SET_DEFAULTS 0xf6
#define PS2KC_DISABLE 0xf5
#define PS2KC_ENABLE 0xf4
#define PS2KC_SET_TYPEMATIC 0xf3
@@ -100,10 +99,10 @@ struct extended_translation {
* FIXME: Pause/break and Print Screen/SysRq require special handling.
*/
static struct extended_translation extended_translations[128] = {
- {0xff08, 0x66}, /* Back space */
- {0xff09, 0x0d}, /* Tab */
- {0xff0d, 0x5a}, /* Return */
- {0xff1b, 0x76}, /* Escape */
+ {0xff08, 0x66, 0}, /* Back space */
+ {0xff09, 0x0d, 0}, /* Tab */
+ {0xff0d, 0x5a, 0}, /* Return */
+ {0xff1b, 0x76, 0}, /* Escape */
{0xff50, 0x6c, SCANCODE_E0_PREFIX}, /* Home */
{0xff51, 0x6b, SCANCODE_E0_PREFIX}, /* Left arrow */
{0xff52, 0x75, SCANCODE_E0_PREFIX}, /* Up arrow */
@@ -114,59 +113,59 @@ static struct extended_translation extended_translations[128] = {
{0xff57, 0x69, SCANCODE_E0_PREFIX}, /* End */
{0xff63, 0x70, SCANCODE_E0_PREFIX}, /* Ins */
{0xff8d, 0x5a, SCANCODE_E0_PREFIX}, /* Keypad Enter */
- {0xffe1, 0x12}, /* Left shift */
- {0xffe2, 0x59}, /* Right shift */
- {0xffe3, 0x14}, /* Left control */
+ {0xffe1, 0x12, 0}, /* Left shift */
+ {0xffe2, 0x59, 0}, /* Right shift */
+ {0xffe3, 0x14, 0}, /* Left control */
{0xffe4, 0x14, SCANCODE_E0_PREFIX}, /* Right control */
/* {0xffe7, XXX}, Left meta */
/* {0xffe8, XXX}, Right meta */
- {0xffe9, 0x11}, /* Left alt */
+ {0xffe9, 0x11, 0}, /* Left alt */
{0xfe03, 0x11, SCANCODE_E0_PREFIX}, /* AltGr */
{0xffea, 0x11, SCANCODE_E0_PREFIX}, /* Right alt */
{0xffeb, 0x1f, SCANCODE_E0_PREFIX}, /* Left Windows */
{0xffec, 0x27, SCANCODE_E0_PREFIX}, /* Right Windows */
- {0xffbe, 0x05}, /* F1 */
- {0xffbf, 0x06}, /* F2 */
- {0xffc0, 0x04}, /* F3 */
- {0xffc1, 0x0c}, /* F4 */
- {0xffc2, 0x03}, /* F5 */
- {0xffc3, 0x0b}, /* F6 */
- {0xffc4, 0x83}, /* F7 */
- {0xffc5, 0x0a}, /* F8 */
- {0xffc6, 0x01}, /* F9 */
- {0xffc7, 0x09}, /* F10 */
- {0xffc8, 0x78}, /* F11 */
- {0xffc9, 0x07}, /* F12 */
+ {0xffbe, 0x05, 0}, /* F1 */
+ {0xffbf, 0x06, 0}, /* F2 */
+ {0xffc0, 0x04, 0}, /* F3 */
+ {0xffc1, 0x0c, 0}, /* F4 */
+ {0xffc2, 0x03, 0}, /* F5 */
+ {0xffc3, 0x0b, 0}, /* F6 */
+ {0xffc4, 0x83, 0}, /* F7 */
+ {0xffc5, 0x0a, 0}, /* F8 */
+ {0xffc6, 0x01, 0}, /* F9 */
+ {0xffc7, 0x09, 0}, /* F10 */
+ {0xffc8, 0x78, 0}, /* F11 */
+ {0xffc9, 0x07, 0}, /* F12 */
{0xffff, 0x71, SCANCODE_E0_PREFIX}, /* Del */
- {0xff14, 0x7e}, /* ScrollLock */
+ {0xff14, 0x7e, 0}, /* ScrollLock */
/* NumLock and Keypads*/
- {0xff7f, 0x77}, /* NumLock */
+ {0xff7f, 0x77, 0}, /* NumLock */
{0xffaf, 0x4a, SCANCODE_E0_PREFIX}, /* Keypad slash */
- {0xffaa, 0x7c}, /* Keypad asterisk */
- {0xffad, 0x7b}, /* Keypad minus */
- {0xffab, 0x79}, /* Keypad plus */
- {0xffb7, 0x6c}, /* Keypad 7 */
- {0xff95, 0x6c}, /* Keypad home */
- {0xffb8, 0x75}, /* Keypad 8 */
- {0xff97, 0x75}, /* Keypad up arrow */
- {0xffb9, 0x7d}, /* Keypad 9 */
- {0xff9a, 0x7d}, /* Keypad PgUp */
- {0xffb4, 0x6b}, /* Keypad 4 */
- {0xff96, 0x6b}, /* Keypad left arrow */
- {0xffb5, 0x73}, /* Keypad 5 */
- {0xff9d, 0x73}, /* Keypad empty */
- {0xffb6, 0x74}, /* Keypad 6 */
- {0xff98, 0x74}, /* Keypad right arrow */
- {0xffb1, 0x69}, /* Keypad 1 */
- {0xff9c, 0x69}, /* Keypad end */
- {0xffb2, 0x72}, /* Keypad 2 */
- {0xff99, 0x72}, /* Keypad down arrow */
- {0xffb3, 0x7a}, /* Keypad 3 */
- {0xff9b, 0x7a}, /* Keypad PgDown */
- {0xffb0, 0x70}, /* Keypad 0 */
- {0xff9e, 0x70}, /* Keypad ins */
- {0xffae, 0x71}, /* Keypad . */
- {0xff9f, 0x71}, /* Keypad del */
+ {0xffaa, 0x7c, 0}, /* Keypad asterisk */
+ {0xffad, 0x7b, 0}, /* Keypad minus */
+ {0xffab, 0x79, 0}, /* Keypad plus */
+ {0xffb7, 0x6c, 0}, /* Keypad 7 */
+ {0xff95, 0x6c, 0}, /* Keypad home */
+ {0xffb8, 0x75, 0}, /* Keypad 8 */
+ {0xff97, 0x75, 0}, /* Keypad up arrow */
+ {0xffb9, 0x7d, 0}, /* Keypad 9 */
+ {0xff9a, 0x7d, 0}, /* Keypad PgUp */
+ {0xffb4, 0x6b, 0}, /* Keypad 4 */
+ {0xff96, 0x6b, 0}, /* Keypad left arrow */
+ {0xffb5, 0x73, 0}, /* Keypad 5 */
+ {0xff9d, 0x73, 0}, /* Keypad empty */
+ {0xffb6, 0x74, 0}, /* Keypad 6 */
+ {0xff98, 0x74, 0}, /* Keypad right arrow */
+ {0xffb1, 0x69, 0}, /* Keypad 1 */
+ {0xff9c, 0x69, 0}, /* Keypad end */
+ {0xffb2, 0x72, 0}, /* Keypad 2 */
+ {0xff99, 0x72, 0}, /* Keypad down arrow */
+ {0xffb3, 0x7a, 0}, /* Keypad 3 */
+ {0xff9b, 0x7a, 0}, /* Keypad PgDown */
+ {0xffb0, 0x70, 0}, /* Keypad 0 */
+ {0xff9e, 0x70, 0}, /* Keypad ins */
+ {0xffae, 0x71, 0}, /* Keypad . */
+ {0xff9f, 0x71, 0}, /* Keypad del */
{0, 0, 0} /* Terminator */
};
@@ -191,7 +190,7 @@ static uint8_t ascii_translations[128] = {
};
/* ScanCode set1 to set2 lookup table */
-const uint8_t keyset1to2_translations[128] = {
+static const uint8_t keyset1to2_translations[128] = {
0, 0x76, 0x16, 0x1E, 0x26, 0x25, 0x2e, 0x36,
0x3d, 0x3e, 0x46, 0x45, 0x4e, 0x55, 0x66, 0x0d,
0x15, 0x1d, 0x24, 0x2d, 0x2c, 0x35, 0x3c, 0x43,
@@ -301,6 +300,10 @@ ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val)
fifo_put(sc, PS2KC_ACK);
fifo_put(sc, PS2KC_BAT_SUCCESS);
break;
+ case PS2KC_SET_DEFAULTS:
+ fifo_reset(sc);
+ fifo_put(sc, PS2KC_ACK);
+ break;
case PS2KC_DISABLE:
sc->enabled = false;
fifo_put(sc, PS2KC_ACK);
@@ -346,10 +349,11 @@ static void
ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
int down, uint32_t keysym, uint32_t keycode)
{
- assert(pthread_mutex_isowned_np(&sc->mtx));
+ const struct extended_translation *trans;
int e0_prefix, found;
uint8_t code;
- struct extended_translation *trans;
+
+ assert(pthread_mutex_isowned_np(&sc->mtx));
if (keycode) {
code = keyset1to2_translations[(uint8_t)(keycode & 0x7f)];
@@ -362,8 +366,8 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
e0_prefix = 0;
found = 1;
} else {
- for (trans = &(extended_translations[0]); trans->keysym != 0;
- trans++) {
+ for (trans = &extended_translations[0];
+ trans->keysym != 0; trans++) {
if (keysym == trans->keysym) {
code = trans->scancode;
e0_prefix = trans->flags & SCANCODE_E0_PREFIX;
@@ -410,10 +414,10 @@ ps2kbd_update_extended_translation(uint32_t keycode, uint32_t scancode, uint32_t
{
int i = 0;
- do {
+ do {
if (extended_translations[i].keysym == keycode)
break;
- } while(extended_translations[++i].keysym);
+ } while (extended_translations[++i].keysym);
if (i == (sizeof(extended_translations) / sizeof(struct extended_translation) - 1))
return;
@@ -438,7 +442,7 @@ ps2kbd_setkbdlayout(void)
char path[MAX_PATHNAME];
char *buf, *next, *line;
struct stat sb;
- size_t sz;
+ ssize_t sz;
uint8_t ascii;
uint32_t keycode, scancode, prefix;
@@ -456,11 +460,11 @@ ps2kbd_setkbdlayout(void)
if (fd == -1)
goto out;
- sz = read(fd, buf, sb.st_size );
+ sz = read(fd, buf, sb.st_size);
close(fd);
- if (sz != sb.st_size )
+ if (sz < 0 || sz != sb.st_size)
goto out;
next = buf;
diff --git a/usr.sbin/bhyve/ps2kbd.h b/usr.sbin/bhyve/amd64/ps2kbd.h
index 3cf87be1b7f3..a9e25c213826 100644
--- a/usr.sbin/bhyve/ps2kbd.h
+++ b/usr.sbin/bhyve/amd64/ps2kbd.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* 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 _PS2KBD_H_
diff --git a/usr.sbin/bhyve/ps2mouse.c b/usr.sbin/bhyve/amd64/ps2mouse.c
index afe817710f30..e99c5c21b6f0 100644
--- a/usr.sbin/bhyve/ps2mouse.c
+++ b/usr.sbin/bhyve/amd64/ps2mouse.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* Copyright (c) 2015 Nahanni Systems Inc.
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <machine/vmm_snapshot.h>
@@ -44,8 +41,9 @@ __FBSDID("$FreeBSD$");
#include <pthread_np.h>
#include "atkbdc.h"
-#include "debug.h"
#include "console.h"
+#include "debug.h"
+#include "ps2mouse.h"
/* mouse device commands */
#define PS2MC_RESET_DEV 0xff
diff --git a/usr.sbin/bhyve/ps2mouse.h b/usr.sbin/bhyve/amd64/ps2mouse.h
index 01f2bfa9ca0f..a4fae96aa4e6 100644
--- a/usr.sbin/bhyve/ps2mouse.h
+++ b/usr.sbin/bhyve/amd64/ps2mouse.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* 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 _PS2MOUSE_H_
diff --git a/usr.sbin/bhyve/rtc.c b/usr.sbin/bhyve/amd64/rtc.c
index 9125b4f86a10..21c3099740bb 100644
--- a/usr.sbin/bhyve/rtc.c
+++ b/usr.sbin/bhyve/amd64/rtc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/types.h>
#include <time.h>
@@ -60,7 +55,7 @@ __FBSDID("$FreeBSD$");
* Returns the current RTC time as number of seconds since 00:00:00 Jan 1, 1970
*/
static time_t
-rtc_time(struct vmctx *ctx)
+rtc_time(void)
{
struct tm tm;
time_t t;
@@ -102,7 +97,7 @@ rtc_init(struct vmctx *ctx)
err = vm_rtc_write(ctx, RTC_HMEM_MSB, himem >> 16);
assert(err == 0);
- err = vm_rtc_settime(ctx, rtc_time(ctx));
+ err = vm_rtc_settime(ctx, rtc_time());
assert(err == 0);
}
diff --git a/usr.sbin/bhyve/rtc.h b/usr.sbin/bhyve/amd64/rtc.h
index c8b3572e93c6..44f776741fb7 100644
--- a/usr.sbin/bhyve/rtc.h
+++ b/usr.sbin/bhyve/amd64/rtc.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Peter Grehan <grehan@freebsd.org>
* 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 _RTC_H_
diff --git a/usr.sbin/bhyve/spinup_ap.c b/usr.sbin/bhyve/amd64/spinup_ap.c
index 7c4186f5ed15..294775bb2c96 100644
--- a/usr.sbin/bhyve/spinup_ap.c
+++ b/usr.sbin/bhyve/amd64/spinup_ap.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/param.h>
#include <sys/types.h>
@@ -45,62 +40,45 @@ __FBSDID("$FreeBSD$");
#include "spinup_ap.h"
static void
-spinup_ap_realmode(struct vmctx *ctx, int newcpu, uint64_t *rip)
+spinup_ap_realmode(struct vcpu *newcpu, uint64_t rip)
{
int vector, error;
uint16_t cs;
uint64_t desc_base;
uint32_t desc_limit, desc_access;
- vector = *rip >> PAGE_SHIFT;
- *rip = 0;
+ vector = rip >> PAGE_SHIFT;
/*
* Update the %cs and %rip of the guest so that it starts
- * executing real mode code at at 'vector << 12'.
+ * executing real mode code at 'vector << 12'.
*/
- error = vm_set_register(ctx, newcpu, VM_REG_GUEST_RIP, *rip);
+ error = vm_set_register(newcpu, VM_REG_GUEST_RIP, 0);
assert(error == 0);
- error = vm_get_desc(ctx, newcpu, VM_REG_GUEST_CS, &desc_base,
+ error = vm_get_desc(newcpu, VM_REG_GUEST_CS, &desc_base,
&desc_limit, &desc_access);
assert(error == 0);
desc_base = vector << PAGE_SHIFT;
- error = vm_set_desc(ctx, newcpu, VM_REG_GUEST_CS,
+ error = vm_set_desc(newcpu, VM_REG_GUEST_CS,
desc_base, desc_limit, desc_access);
assert(error == 0);
cs = (vector << PAGE_SHIFT) >> 4;
- error = vm_set_register(ctx, newcpu, VM_REG_GUEST_CS, cs);
+ error = vm_set_register(newcpu, VM_REG_GUEST_CS, cs);
assert(error == 0);
}
-int
-spinup_ap(struct vmctx *ctx, int vcpu, int newcpu, uint64_t rip)
+void
+spinup_ap(struct vcpu *newcpu, uint64_t rip)
{
int error;
- assert(newcpu != 0);
- assert(newcpu < guest_ncpus);
-
- error = vcpu_reset(ctx, newcpu);
+ error = vcpu_reset(newcpu);
assert(error == 0);
- fbsdrun_set_capabilities(ctx, newcpu);
-
- /*
- * Enable the 'unrestricted guest' mode for 'newcpu'.
- *
- * Set up the processor state in power-on 16-bit mode, with the CS:IP
- * init'd to the specified low-mem 4K page.
- */
- error = vm_set_capability(ctx, newcpu, VM_CAP_UNRESTRICTED_GUEST, 1);
- assert(error == 0);
-
- spinup_ap_realmode(ctx, newcpu, &rip);
-
- fbsdrun_addcpu(ctx, vcpu, newcpu, rip);
+ spinup_ap_realmode(newcpu, rip);
- return (newcpu);
+ vm_resume_cpu(newcpu);
}
diff --git a/usr.sbin/bhyve/spinup_ap.h b/usr.sbin/bhyve/amd64/spinup_ap.h
index 226542f6c331..5877446297c2 100644
--- a/usr.sbin/bhyve/spinup_ap.h
+++ b/usr.sbin/bhyve/amd64/spinup_ap.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,11 @@
* 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 _SPINUP_AP_H_
#define _SPINUP_AP_H_
-int spinup_ap(struct vmctx *ctx, int vcpu, int newcpu, uint64_t rip);
+void spinup_ap(struct vcpu *newcpu, uint64_t rip);
#endif
diff --git a/usr.sbin/bhyve/task_switch.c b/usr.sbin/bhyve/amd64/task_switch.c
index f1b564d560c5..d311d2b1b6c3 100644
--- a/usr.sbin/bhyve/task_switch.c
+++ b/usr.sbin/bhyve/amd64/task_switch.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Neel Natu <neel@freebsd.org>
* All rights reserved.
@@ -26,15 +26,11 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/_iovec.h>
#include <sys/mman.h>
#include <x86/psl.h>
-#include <x86/segments.h>
#include <x86/specialreg.h>
#include <machine/vmm.h>
#include <machine/vmm_instruction_emul.h>
@@ -101,22 +97,22 @@ static_assert(sizeof(struct tss32) == 104, "compile-time assertion failed");
#define TSS_BUSY(type) (((type) & 0x2) != 0)
static uint64_t
-GETREG(struct vmctx *ctx, int vcpu, int reg)
+GETREG(struct vcpu *vcpu, int reg)
{
uint64_t val;
int error;
- error = vm_get_register(ctx, vcpu, reg, &val);
+ error = vm_get_register(vcpu, reg, &val);
assert(error == 0);
return (val);
}
static void
-SETREG(struct vmctx *ctx, int vcpu, int reg, uint64_t val)
+SETREG(struct vcpu *vcpu, int reg, uint64_t val)
{
int error;
- error = vm_set_register(ctx, vcpu, reg, val);
+ error = vm_set_register(vcpu, reg, val);
assert(error == 0);
}
@@ -152,7 +148,7 @@ usd_to_seg_desc(struct user_segment_descriptor *usd)
* Bit 2(GDT/LDT) has the usual interpretation of Table Indicator (TI).
*/
static void
-sel_exception(struct vmctx *ctx, int vcpu, int vector, uint16_t sel, int ext)
+sel_exception(struct vcpu *vcpu, int vector, uint16_t sel, int ext)
{
/*
* Bit 2 from the selector is retained as-is in the error code.
@@ -166,7 +162,7 @@ sel_exception(struct vmctx *ctx, int vcpu, int vector, uint16_t sel, int ext)
sel &= ~0x3;
if (ext)
sel |= 0x1;
- vm_inject_fault(ctx, vcpu, vector, 1, sel);
+ vm_inject_fault(vcpu, vector, 1, sel);
}
/*
@@ -174,14 +170,14 @@ sel_exception(struct vmctx *ctx, int vcpu, int vector, uint16_t sel, int ext)
* and non-zero otherwise.
*/
static int
-desc_table_limit_check(struct vmctx *ctx, int vcpu, uint16_t sel)
+desc_table_limit_check(struct vcpu *vcpu, uint16_t sel)
{
uint64_t base;
uint32_t limit, access;
int error, reg;
reg = ISLDT(sel) ? VM_REG_GUEST_LDTR : VM_REG_GUEST_GDTR;
- error = vm_get_desc(ctx, vcpu, reg, &base, &limit, &access);
+ error = vm_get_desc(vcpu, reg, &base, &limit, &access);
assert(error == 0);
if (reg == VM_REG_GUEST_LDTR) {
@@ -204,7 +200,7 @@ desc_table_limit_check(struct vmctx *ctx, int vcpu, uint16_t sel)
* Returns -1 otherwise.
*/
static int
-desc_table_rw(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
+desc_table_rw(struct vcpu *vcpu, struct vm_guest_paging *paging,
uint16_t sel, struct user_segment_descriptor *desc, bool doread,
int *faultptr)
{
@@ -214,35 +210,35 @@ desc_table_rw(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
int error, reg;
reg = ISLDT(sel) ? VM_REG_GUEST_LDTR : VM_REG_GUEST_GDTR;
- error = vm_get_desc(ctx, vcpu, reg, &base, &limit, &access);
+ error = vm_get_desc(vcpu, reg, &base, &limit, &access);
assert(error == 0);
assert(limit >= SEL_LIMIT(sel));
- error = vm_copy_setup(ctx, vcpu, paging, base + SEL_START(sel),
+ error = vm_copy_setup(vcpu, paging, base + SEL_START(sel),
sizeof(*desc), doread ? PROT_READ : PROT_WRITE, iov, nitems(iov),
faultptr);
if (error || *faultptr)
return (error);
if (doread)
- vm_copyin(ctx, vcpu, iov, desc, sizeof(*desc));
+ vm_copyin(iov, desc, sizeof(*desc));
else
- vm_copyout(ctx, vcpu, desc, iov, sizeof(*desc));
+ vm_copyout(desc, iov, sizeof(*desc));
return (0);
}
static int
-desc_table_read(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
+desc_table_read(struct vcpu *vcpu, struct vm_guest_paging *paging,
uint16_t sel, struct user_segment_descriptor *desc, int *faultptr)
{
- return (desc_table_rw(ctx, vcpu, paging, sel, desc, true, faultptr));
+ return (desc_table_rw(vcpu, paging, sel, desc, true, faultptr));
}
static int
-desc_table_write(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
+desc_table_write(struct vcpu *vcpu, struct vm_guest_paging *paging,
uint16_t sel, struct user_segment_descriptor *desc, int *faultptr)
{
- return (desc_table_rw(ctx, vcpu, paging, sel, desc, false, faultptr));
+ return (desc_table_rw(vcpu, paging, sel, desc, false, faultptr));
}
/*
@@ -253,7 +249,7 @@ desc_table_write(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
* Returns -1 otherwise.
*/
static int
-read_tss_descriptor(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
+read_tss_descriptor(struct vcpu *vcpu, struct vm_task_switch *ts,
uint16_t sel, struct user_segment_descriptor *desc, int *faultptr)
{
struct vm_guest_paging sup_paging;
@@ -263,17 +259,17 @@ read_tss_descriptor(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
assert(IDXSEL(sel) != 0);
/* Fetch the new TSS descriptor */
- if (desc_table_limit_check(ctx, vcpu, sel)) {
+ if (desc_table_limit_check(vcpu, sel)) {
if (ts->reason == TSR_IRET)
- sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext);
+ sel_exception(vcpu, IDT_TS, sel, ts->ext);
else
- sel_exception(ctx, vcpu, IDT_GP, sel, ts->ext);
+ sel_exception(vcpu, IDT_GP, sel, ts->ext);
return (1);
}
sup_paging = ts->paging;
sup_paging.cpl = 0; /* implicit supervisor mode */
- error = desc_table_read(ctx, vcpu, &sup_paging, sel, desc, faultptr);
+ error = desc_table_read(vcpu, &sup_paging, sel, desc, faultptr);
return (error);
}
@@ -309,7 +305,7 @@ ldt_desc(int sd_type)
* Validate the descriptor 'seg_desc' associated with 'segment'.
*/
static int
-validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
+validate_seg_desc(struct vcpu *vcpu, struct vm_task_switch *ts,
int segment, struct seg_desc *seg_desc, int *faultptr)
{
struct vm_guest_paging sup_paging;
@@ -341,17 +337,17 @@ validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
}
/* Get the segment selector */
- sel = GETREG(ctx, vcpu, segment);
+ sel = GETREG(vcpu, segment);
/* LDT selector must point into the GDT */
if (ldtseg && ISLDT(sel)) {
- sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext);
+ sel_exception(vcpu, IDT_TS, sel, ts->ext);
return (1);
}
/* Descriptor table limit check */
- if (desc_table_limit_check(ctx, vcpu, sel)) {
- sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext);
+ if (desc_table_limit_check(vcpu, sel)) {
+ sel_exception(vcpu, IDT_TS, sel, ts->ext);
return (1);
}
@@ -359,7 +355,7 @@ validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
if (IDXSEL(sel) == 0) {
/* Code and stack segment selectors cannot be NULL */
if (codeseg || stackseg) {
- sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext);
+ sel_exception(vcpu, IDT_TS, sel, ts->ext);
return (1);
}
seg_desc->base = 0;
@@ -371,7 +367,7 @@ validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
/* Read the descriptor from the GDT/LDT */
sup_paging = ts->paging;
sup_paging.cpl = 0; /* implicit supervisor mode */
- error = desc_table_read(ctx, vcpu, &sup_paging, sel, &usd, faultptr);
+ error = desc_table_read(vcpu, &sup_paging, sel, &usd, faultptr);
if (error || *faultptr)
return (error);
@@ -380,7 +376,7 @@ validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
(codeseg && !code_desc(usd.sd_type)) ||
(dataseg && !data_desc(usd.sd_type)) ||
(stackseg && !stack_desc(usd.sd_type))) {
- sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext);
+ sel_exception(vcpu, IDT_TS, sel, ts->ext);
return (1);
}
@@ -392,17 +388,17 @@ validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
idtvec = IDT_SS;
else
idtvec = IDT_NP;
- sel_exception(ctx, vcpu, idtvec, sel, ts->ext);
+ sel_exception(vcpu, idtvec, sel, ts->ext);
return (1);
}
- cs = GETREG(ctx, vcpu, VM_REG_GUEST_CS);
+ cs = GETREG(vcpu, VM_REG_GUEST_CS);
cpl = cs & SEL_RPL_MASK;
rpl = sel & SEL_RPL_MASK;
dpl = usd.sd_dpl;
if (stackseg && (rpl != cpl || dpl != cpl)) {
- sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext);
+ sel_exception(vcpu, IDT_TS, sel, ts->ext);
return (1);
}
@@ -410,7 +406,7 @@ validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
conforming = (usd.sd_type & 0x4) ? true : false;
if ((conforming && (cpl < dpl)) ||
(!conforming && (cpl != dpl))) {
- sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext);
+ sel_exception(vcpu, IDT_TS, sel, ts->ext);
return (1);
}
}
@@ -426,7 +422,7 @@ validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
conforming = false;
if (!conforming && (rpl > dpl || cpl > dpl)) {
- sel_exception(ctx, vcpu, IDT_TS, sel, ts->ext);
+ sel_exception(vcpu, IDT_TS, sel, ts->ext);
return (1);
}
}
@@ -435,44 +431,44 @@ validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
}
static void
-tss32_save(struct vmctx *ctx, int vcpu, struct vm_task_switch *task_switch,
+tss32_save(struct vcpu *vcpu, struct vm_task_switch *task_switch,
uint32_t eip, struct tss32 *tss, struct iovec *iov)
{
/* General purpose registers */
- tss->tss_eax = GETREG(ctx, vcpu, VM_REG_GUEST_RAX);
- tss->tss_ecx = GETREG(ctx, vcpu, VM_REG_GUEST_RCX);
- tss->tss_edx = GETREG(ctx, vcpu, VM_REG_GUEST_RDX);
- tss->tss_ebx = GETREG(ctx, vcpu, VM_REG_GUEST_RBX);
- tss->tss_esp = GETREG(ctx, vcpu, VM_REG_GUEST_RSP);
- tss->tss_ebp = GETREG(ctx, vcpu, VM_REG_GUEST_RBP);
- tss->tss_esi = GETREG(ctx, vcpu, VM_REG_GUEST_RSI);
- tss->tss_edi = GETREG(ctx, vcpu, VM_REG_GUEST_RDI);
+ tss->tss_eax = GETREG(vcpu, VM_REG_GUEST_RAX);
+ tss->tss_ecx = GETREG(vcpu, VM_REG_GUEST_RCX);
+ tss->tss_edx = GETREG(vcpu, VM_REG_GUEST_RDX);
+ tss->tss_ebx = GETREG(vcpu, VM_REG_GUEST_RBX);
+ tss->tss_esp = GETREG(vcpu, VM_REG_GUEST_RSP);
+ tss->tss_ebp = GETREG(vcpu, VM_REG_GUEST_RBP);
+ tss->tss_esi = GETREG(vcpu, VM_REG_GUEST_RSI);
+ tss->tss_edi = GETREG(vcpu, VM_REG_GUEST_RDI);
/* Segment selectors */
- tss->tss_es = GETREG(ctx, vcpu, VM_REG_GUEST_ES);
- tss->tss_cs = GETREG(ctx, vcpu, VM_REG_GUEST_CS);
- tss->tss_ss = GETREG(ctx, vcpu, VM_REG_GUEST_SS);
- tss->tss_ds = GETREG(ctx, vcpu, VM_REG_GUEST_DS);
- tss->tss_fs = GETREG(ctx, vcpu, VM_REG_GUEST_FS);
- tss->tss_gs = GETREG(ctx, vcpu, VM_REG_GUEST_GS);
+ tss->tss_es = GETREG(vcpu, VM_REG_GUEST_ES);
+ tss->tss_cs = GETREG(vcpu, VM_REG_GUEST_CS);
+ tss->tss_ss = GETREG(vcpu, VM_REG_GUEST_SS);
+ tss->tss_ds = GETREG(vcpu, VM_REG_GUEST_DS);
+ tss->tss_fs = GETREG(vcpu, VM_REG_GUEST_FS);
+ tss->tss_gs = GETREG(vcpu, VM_REG_GUEST_GS);
/* eflags and eip */
- tss->tss_eflags = GETREG(ctx, vcpu, VM_REG_GUEST_RFLAGS);
+ tss->tss_eflags = GETREG(vcpu, VM_REG_GUEST_RFLAGS);
if (task_switch->reason == TSR_IRET)
tss->tss_eflags &= ~PSL_NT;
tss->tss_eip = eip;
/* Copy updated old TSS into guest memory */
- vm_copyout(ctx, vcpu, tss, iov, sizeof(struct tss32));
+ vm_copyout(tss, iov, sizeof(struct tss32));
}
static void
-update_seg_desc(struct vmctx *ctx, int vcpu, int reg, struct seg_desc *sd)
+update_seg_desc(struct vcpu *vcpu, int reg, struct seg_desc *sd)
{
int error;
- error = vm_set_desc(ctx, vcpu, reg, sd->base, sd->limit, sd->access);
+ error = vm_set_desc(vcpu, reg, sd->base, sd->limit, sd->access);
assert(error == 0);
}
@@ -480,7 +476,7 @@ update_seg_desc(struct vmctx *ctx, int vcpu, int reg, struct seg_desc *sd)
* Update the vcpu registers to reflect the state of the new task.
*/
static int
-tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
+tss32_restore(struct vmctx *ctx, struct vcpu *vcpu, struct vm_task_switch *ts,
uint16_t ot_sel, struct tss32 *tss, struct iovec *iov, int *faultptr)
{
struct seg_desc seg_desc, seg_desc2;
@@ -500,7 +496,7 @@ tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
eflags |= PSL_NT;
/* LDTR */
- SETREG(ctx, vcpu, VM_REG_GUEST_LDTR, tss->tss_ldt);
+ SETREG(vcpu, VM_REG_GUEST_LDTR, tss->tss_ldt);
/* PBDR */
if (ts->paging.paging_mode != PAGING_MODE_FLAT) {
@@ -520,54 +516,54 @@ tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
*/
reserved = ~maxphyaddr | 0x1E6;
if (pdpte[i] & reserved) {
- vm_inject_gp(ctx, vcpu);
+ vm_inject_gp(vcpu);
return (1);
}
}
- SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE0, pdpte[0]);
- SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE1, pdpte[1]);
- SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE2, pdpte[2]);
- SETREG(ctx, vcpu, VM_REG_GUEST_PDPTE3, pdpte[3]);
+ SETREG(vcpu, VM_REG_GUEST_PDPTE0, pdpte[0]);
+ SETREG(vcpu, VM_REG_GUEST_PDPTE1, pdpte[1]);
+ SETREG(vcpu, VM_REG_GUEST_PDPTE2, pdpte[2]);
+ SETREG(vcpu, VM_REG_GUEST_PDPTE3, pdpte[3]);
}
- SETREG(ctx, vcpu, VM_REG_GUEST_CR3, tss->tss_cr3);
+ SETREG(vcpu, VM_REG_GUEST_CR3, tss->tss_cr3);
ts->paging.cr3 = tss->tss_cr3;
}
/* eflags and eip */
- SETREG(ctx, vcpu, VM_REG_GUEST_RFLAGS, eflags);
- SETREG(ctx, vcpu, VM_REG_GUEST_RIP, tss->tss_eip);
+ SETREG(vcpu, VM_REG_GUEST_RFLAGS, eflags);
+ SETREG(vcpu, VM_REG_GUEST_RIP, tss->tss_eip);
/* General purpose registers */
- SETREG(ctx, vcpu, VM_REG_GUEST_RAX, tss->tss_eax);
- SETREG(ctx, vcpu, VM_REG_GUEST_RCX, tss->tss_ecx);
- SETREG(ctx, vcpu, VM_REG_GUEST_RDX, tss->tss_edx);
- SETREG(ctx, vcpu, VM_REG_GUEST_RBX, tss->tss_ebx);
- SETREG(ctx, vcpu, VM_REG_GUEST_RSP, tss->tss_esp);
- SETREG(ctx, vcpu, VM_REG_GUEST_RBP, tss->tss_ebp);
- SETREG(ctx, vcpu, VM_REG_GUEST_RSI, tss->tss_esi);
- SETREG(ctx, vcpu, VM_REG_GUEST_RDI, tss->tss_edi);
+ SETREG(vcpu, VM_REG_GUEST_RAX, tss->tss_eax);
+ SETREG(vcpu, VM_REG_GUEST_RCX, tss->tss_ecx);
+ SETREG(vcpu, VM_REG_GUEST_RDX, tss->tss_edx);
+ SETREG(vcpu, VM_REG_GUEST_RBX, tss->tss_ebx);
+ SETREG(vcpu, VM_REG_GUEST_RSP, tss->tss_esp);
+ SETREG(vcpu, VM_REG_GUEST_RBP, tss->tss_ebp);
+ SETREG(vcpu, VM_REG_GUEST_RSI, tss->tss_esi);
+ SETREG(vcpu, VM_REG_GUEST_RDI, tss->tss_edi);
/* Segment selectors */
- SETREG(ctx, vcpu, VM_REG_GUEST_ES, tss->tss_es);
- SETREG(ctx, vcpu, VM_REG_GUEST_CS, tss->tss_cs);
- SETREG(ctx, vcpu, VM_REG_GUEST_SS, tss->tss_ss);
- SETREG(ctx, vcpu, VM_REG_GUEST_DS, tss->tss_ds);
- SETREG(ctx, vcpu, VM_REG_GUEST_FS, tss->tss_fs);
- SETREG(ctx, vcpu, VM_REG_GUEST_GS, tss->tss_gs);
+ SETREG(vcpu, VM_REG_GUEST_ES, tss->tss_es);
+ SETREG(vcpu, VM_REG_GUEST_CS, tss->tss_cs);
+ SETREG(vcpu, VM_REG_GUEST_SS, tss->tss_ss);
+ SETREG(vcpu, VM_REG_GUEST_DS, tss->tss_ds);
+ SETREG(vcpu, VM_REG_GUEST_FS, tss->tss_fs);
+ SETREG(vcpu, VM_REG_GUEST_GS, tss->tss_gs);
/*
* If this is a nested task then write out the new TSS to update
* the previous link field.
*/
if (nested)
- vm_copyout(ctx, vcpu, tss, iov, sizeof(*tss));
+ vm_copyout(tss, iov, sizeof(*tss));
/* Validate segment descriptors */
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_LDTR, &seg_desc,
+ error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_LDTR, &seg_desc,
faultptr);
if (error || *faultptr)
return (error);
- update_seg_desc(ctx, vcpu, VM_REG_GUEST_LDTR, &seg_desc);
+ update_seg_desc(vcpu, VM_REG_GUEST_LDTR, &seg_desc);
/*
* Section "Checks on Guest Segment Registers", Intel SDM, Vol 3.
@@ -578,42 +574,42 @@ tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
* VM-entry checks so the guest can handle any exception injected
* during task switch emulation.
*/
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_CS, &seg_desc,
+ error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_CS, &seg_desc,
faultptr);
if (error || *faultptr)
return (error);
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_SS, &seg_desc2,
+ error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_SS, &seg_desc2,
faultptr);
if (error || *faultptr)
return (error);
- update_seg_desc(ctx, vcpu, VM_REG_GUEST_CS, &seg_desc);
- update_seg_desc(ctx, vcpu, VM_REG_GUEST_SS, &seg_desc2);
+ update_seg_desc(vcpu, VM_REG_GUEST_CS, &seg_desc);
+ update_seg_desc(vcpu, VM_REG_GUEST_SS, &seg_desc2);
ts->paging.cpl = tss->tss_cs & SEL_RPL_MASK;
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_DS, &seg_desc,
+ error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_DS, &seg_desc,
faultptr);
if (error || *faultptr)
return (error);
- update_seg_desc(ctx, vcpu, VM_REG_GUEST_DS, &seg_desc);
+ update_seg_desc(vcpu, VM_REG_GUEST_DS, &seg_desc);
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_ES, &seg_desc,
+ error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_ES, &seg_desc,
faultptr);
if (error || *faultptr)
return (error);
- update_seg_desc(ctx, vcpu, VM_REG_GUEST_ES, &seg_desc);
+ update_seg_desc(vcpu, VM_REG_GUEST_ES, &seg_desc);
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_FS, &seg_desc,
+ error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_FS, &seg_desc,
faultptr);
if (error || *faultptr)
return (error);
- update_seg_desc(ctx, vcpu, VM_REG_GUEST_FS, &seg_desc);
+ update_seg_desc(vcpu, VM_REG_GUEST_FS, &seg_desc);
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_GS, &seg_desc,
+ error = validate_seg_desc(vcpu, ts, VM_REG_GUEST_GS, &seg_desc,
faultptr);
if (error || *faultptr)
return (error);
- update_seg_desc(ctx, vcpu, VM_REG_GUEST_GS, &seg_desc);
+ update_seg_desc(vcpu, VM_REG_GUEST_GS, &seg_desc);
return (0);
}
@@ -624,7 +620,7 @@ tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
* code to be saved (e.g. #PF).
*/
static int
-push_errcode(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
+push_errcode(struct vcpu *vcpu, struct vm_guest_paging *paging,
int task_type, uint32_t errcode, int *faultptr)
{
struct iovec iov[2];
@@ -636,11 +632,11 @@ push_errcode(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
*faultptr = 0;
- cr0 = GETREG(ctx, vcpu, VM_REG_GUEST_CR0);
- rflags = GETREG(ctx, vcpu, VM_REG_GUEST_RFLAGS);
- stacksel = GETREG(ctx, vcpu, VM_REG_GUEST_SS);
+ cr0 = GETREG(vcpu, VM_REG_GUEST_CR0);
+ rflags = GETREG(vcpu, VM_REG_GUEST_RFLAGS);
+ stacksel = GETREG(vcpu, VM_REG_GUEST_SS);
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_SS, &seg_desc.base,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_SS, &seg_desc.base,
&seg_desc.limit, &seg_desc.access);
assert(error == 0);
@@ -664,29 +660,29 @@ push_errcode(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
else
stacksize = 2;
- esp = GETREG(ctx, vcpu, VM_REG_GUEST_RSP);
+ esp = GETREG(vcpu, VM_REG_GUEST_RSP);
esp -= bytes;
if (vie_calculate_gla(paging->cpu_mode, VM_REG_GUEST_SS,
&seg_desc, esp, bytes, stacksize, PROT_WRITE, &gla)) {
- sel_exception(ctx, vcpu, IDT_SS, stacksel, 1);
+ sel_exception(vcpu, IDT_SS, stacksel, 1);
*faultptr = 1;
return (0);
}
if (vie_alignment_check(paging->cpl, bytes, cr0, rflags, gla)) {
- vm_inject_ac(ctx, vcpu, 1);
+ vm_inject_ac(vcpu, 1);
*faultptr = 1;
return (0);
}
- error = vm_copy_setup(ctx, vcpu, paging, gla, bytes, PROT_WRITE,
+ error = vm_copy_setup(vcpu, paging, gla, bytes, PROT_WRITE,
iov, nitems(iov), faultptr);
if (error || *faultptr)
return (error);
- vm_copyout(ctx, vcpu, &errcode, iov, bytes);
- SETREG(ctx, vcpu, VM_REG_GUEST_RSP, esp);
+ vm_copyout(&errcode, iov, bytes);
+ SETREG(vcpu, VM_REG_GUEST_RSP, esp);
return (0);
}
@@ -703,8 +699,10 @@ push_errcode(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
return (VMEXIT_CONTINUE); \
} while (0)
+int vmexit_task_switch(struct vmctx *, struct vcpu *, struct vm_run *);
+
int
-vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
+vmexit_task_switch(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun)
{
struct seg_desc nt;
struct tss32 oldtss, newtss;
@@ -712,18 +710,19 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
struct vm_guest_paging *paging, sup_paging;
struct user_segment_descriptor nt_desc, ot_desc;
struct iovec nt_iov[2], ot_iov[2];
+ struct vm_exit *vmexit;
uint64_t cr0, ot_base;
uint32_t eip, ot_lim, access;
- int error, ext, fault, minlimit, nt_type, ot_type, vcpu;
+ int error, ext, fault, minlimit, nt_type, ot_type;
enum task_switch_reason reason;
uint16_t nt_sel, ot_sel;
+ vmexit = vmrun->vm_exit;
task_switch = &vmexit->u.task_switch;
nt_sel = task_switch->tsssel;
ext = vmexit->u.task_switch.ext;
reason = vmexit->u.task_switch.reason;
paging = &vmexit->u.task_switch.paging;
- vcpu = *pvcpu;
assert(paging->cpu_mode == CPU_MODE_PROTECTED);
@@ -742,7 +741,7 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
sup_paging.cpl = 0; /* implicit supervisor mode */
/* Fetch the new TSS descriptor */
- error = read_tss_descriptor(ctx, vcpu, task_switch, nt_sel, &nt_desc,
+ error = read_tss_descriptor(vcpu, task_switch, nt_sel, &nt_desc,
&fault);
CHKERR(error, fault);
@@ -752,13 +751,13 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
nt_type = SEG_DESC_TYPE(nt.access);
if (nt_type != SDT_SYS386BSY && nt_type != SDT_SYS386TSS &&
nt_type != SDT_SYS286BSY && nt_type != SDT_SYS286TSS) {
- sel_exception(ctx, vcpu, IDT_TS, nt_sel, ext);
+ sel_exception(vcpu, IDT_TS, nt_sel, ext);
goto done;
}
/* TSS descriptor must have present bit set */
if (!SEG_DESC_PRESENT(nt.access)) {
- sel_exception(ctx, vcpu, IDT_NP, nt_sel, ext);
+ sel_exception(vcpu, IDT_NP, nt_sel, ext);
goto done;
}
@@ -774,14 +773,14 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
minlimit = 0;
assert(minlimit > 0);
- if (nt.limit < minlimit) {
- sel_exception(ctx, vcpu, IDT_TS, nt_sel, ext);
+ if (nt.limit < (unsigned int)minlimit) {
+ sel_exception(vcpu, IDT_TS, nt_sel, ext);
goto done;
}
/* TSS must be busy if task switch is due to IRET */
if (reason == TSR_IRET && !TSS_BUSY(nt_type)) {
- sel_exception(ctx, vcpu, IDT_TS, nt_sel, ext);
+ sel_exception(vcpu, IDT_TS, nt_sel, ext);
goto done;
}
@@ -790,18 +789,18 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
* CALL, JMP, exception or interrupt.
*/
if (reason != TSR_IRET && TSS_BUSY(nt_type)) {
- sel_exception(ctx, vcpu, IDT_GP, nt_sel, ext);
+ sel_exception(vcpu, IDT_GP, nt_sel, ext);
goto done;
}
/* Fetch the new TSS */
- error = vm_copy_setup(ctx, vcpu, &sup_paging, nt.base, minlimit + 1,
+ error = vm_copy_setup(vcpu, &sup_paging, nt.base, minlimit + 1,
PROT_READ | PROT_WRITE, nt_iov, nitems(nt_iov), &fault);
CHKERR(error, fault);
- vm_copyin(ctx, vcpu, nt_iov, &newtss, minlimit + 1);
+ vm_copyin(nt_iov, &newtss, minlimit + 1);
/* Get the old TSS selector from the guest's task register */
- ot_sel = GETREG(ctx, vcpu, VM_REG_GUEST_TR);
+ ot_sel = GETREG(vcpu, VM_REG_GUEST_TR);
if (ISLDT(ot_sel) || IDXSEL(ot_sel) == 0) {
/*
* This might happen if a task switch was attempted without
@@ -809,12 +808,12 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
* TR would contain the values from power-on:
* (sel = 0, base = 0, limit = 0xffff).
*/
- sel_exception(ctx, vcpu, IDT_TS, ot_sel, task_switch->ext);
+ sel_exception(vcpu, IDT_TS, ot_sel, task_switch->ext);
goto done;
}
/* Get the old TSS base and limit from the guest's task register */
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_TR, &ot_base, &ot_lim,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_TR, &ot_base, &ot_lim,
&access);
assert(error == 0);
assert(!SEG_DESC_UNUSABLE(access) && SEG_DESC_PRESENT(access));
@@ -822,15 +821,15 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
assert(ot_type == SDT_SYS386BSY || ot_type == SDT_SYS286BSY);
/* Fetch the old TSS descriptor */
- error = read_tss_descriptor(ctx, vcpu, task_switch, ot_sel, &ot_desc,
+ error = read_tss_descriptor(vcpu, task_switch, ot_sel, &ot_desc,
&fault);
CHKERR(error, fault);
/* Get the old TSS */
- error = vm_copy_setup(ctx, vcpu, &sup_paging, ot_base, minlimit + 1,
+ error = vm_copy_setup(vcpu, &sup_paging, ot_base, minlimit + 1,
PROT_READ | PROT_WRITE, ot_iov, nitems(ot_iov), &fault);
CHKERR(error, fault);
- vm_copyin(ctx, vcpu, ot_iov, &oldtss, minlimit + 1);
+ vm_copyin(ot_iov, &oldtss, minlimit + 1);
/*
* Clear the busy bit in the old TSS descriptor if the task switch
@@ -838,7 +837,7 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
*/
if (reason == TSR_IRET || reason == TSR_JMP) {
ot_desc.sd_type &= ~0x2;
- error = desc_table_write(ctx, vcpu, &sup_paging, ot_sel,
+ error = desc_table_write(vcpu, &sup_paging, ot_sel,
&ot_desc, &fault);
CHKERR(error, fault);
}
@@ -849,7 +848,7 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
}
/* Save processor state in old TSS */
- tss32_save(ctx, vcpu, task_switch, eip, &oldtss, ot_iov);
+ tss32_save(vcpu, task_switch, eip, &oldtss, ot_iov);
/*
* If the task switch was triggered for any reason other than IRET
@@ -857,28 +856,28 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
*/
if (reason != TSR_IRET) {
nt_desc.sd_type |= 0x2;
- error = desc_table_write(ctx, vcpu, &sup_paging, nt_sel,
+ error = desc_table_write(vcpu, &sup_paging, nt_sel,
&nt_desc, &fault);
CHKERR(error, fault);
}
/* Update task register to point at the new TSS */
- SETREG(ctx, vcpu, VM_REG_GUEST_TR, nt_sel);
+ SETREG(vcpu, VM_REG_GUEST_TR, nt_sel);
/* Update the hidden descriptor state of the task register */
nt = usd_to_seg_desc(&nt_desc);
- update_seg_desc(ctx, vcpu, VM_REG_GUEST_TR, &nt);
+ update_seg_desc(vcpu, VM_REG_GUEST_TR, &nt);
/* Set CR0.TS */
- cr0 = GETREG(ctx, vcpu, VM_REG_GUEST_CR0);
- SETREG(ctx, vcpu, VM_REG_GUEST_CR0, cr0 | CR0_TS);
+ cr0 = GETREG(vcpu, VM_REG_GUEST_CR0);
+ SETREG(vcpu, VM_REG_GUEST_CR0, cr0 | CR0_TS);
/*
* We are now committed to the task switch. Any exceptions encountered
* after this point will be handled in the context of the new task and
* the saved instruction pointer will belong to the new task.
*/
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, newtss.tss_eip);
+ error = vm_set_register(vcpu, VM_REG_GUEST_RIP, newtss.tss_eip);
assert(error == 0);
/* Load processor state from new TSS */
@@ -894,7 +893,7 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
if (task_switch->errcode_valid) {
assert(task_switch->ext);
assert(task_switch->reason == TSR_IDT_GATE);
- error = push_errcode(ctx, vcpu, &task_switch->paging, nt_type,
+ error = push_errcode(vcpu, &task_switch->paging, nt_type,
task_switch->errcode, &fault);
CHKERR(error, fault);
}
@@ -930,7 +929,7 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
* exitintinfo.
*/
if (task_switch->reason == TSR_IDT_GATE) {
- error = vm_set_intinfo(ctx, vcpu, 0);
+ error = vm_set_intinfo(vcpu, 0);
assert(error == 0);
}
diff --git a/usr.sbin/bhyve/vga.c b/usr.sbin/bhyve/amd64/vga.c
index 24864f32e8b9..7c43ad8f3bd6 100644
--- a/usr.sbin/bhyve/vga.c
+++ b/usr.sbin/bhyve/amd64/vga.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <assert.h>
@@ -339,7 +336,7 @@ vga_render(struct bhyvegc *gc, void *arg)
}
static uint64_t
-vga_mem_rd_handler(struct vmctx *ctx, uint64_t addr, void *arg1)
+vga_mem_rd_handler(uint64_t addr, void *arg1)
{
struct vga_softc *sc = arg1;
uint8_t map_sel;
@@ -399,7 +396,7 @@ vga_mem_rd_handler(struct vmctx *ctx, uint64_t addr, void *arg1)
}
static void
-vga_mem_wr_handler(struct vmctx *ctx, uint64_t addr, uint8_t val, void *arg1)
+vga_mem_wr_handler(uint64_t addr, uint8_t val, void *arg1)
{
struct vga_softc *sc = arg1;
uint8_t c0, c1, c2, c3;
@@ -653,59 +650,59 @@ vga_mem_wr_handler(struct vmctx *ctx, uint64_t addr, uint8_t val, void *arg1)
}
static int
-vga_mem_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
- int size, uint64_t *val, void *arg1, long arg2)
+vga_mem_handler(struct vcpu *vcpu __unused, int dir, uint64_t addr, int size,
+ uint64_t *val, void *arg1, long arg2 __unused)
{
if (dir == MEM_F_WRITE) {
switch (size) {
case 1:
- vga_mem_wr_handler(ctx, addr, *val, arg1);
+ vga_mem_wr_handler(addr, *val, arg1);
break;
case 2:
- vga_mem_wr_handler(ctx, addr, *val, arg1);
- vga_mem_wr_handler(ctx, addr + 1, *val >> 8, arg1);
+ vga_mem_wr_handler(addr, *val, arg1);
+ vga_mem_wr_handler(addr + 1, *val >> 8, arg1);
break;
case 4:
- vga_mem_wr_handler(ctx, addr, *val, arg1);
- vga_mem_wr_handler(ctx, addr + 1, *val >> 8, arg1);
- vga_mem_wr_handler(ctx, addr + 2, *val >> 16, arg1);
- vga_mem_wr_handler(ctx, addr + 3, *val >> 24, arg1);
+ vga_mem_wr_handler(addr, *val, arg1);
+ vga_mem_wr_handler(addr + 1, *val >> 8, arg1);
+ vga_mem_wr_handler(addr + 2, *val >> 16, arg1);
+ vga_mem_wr_handler(addr + 3, *val >> 24, arg1);
break;
case 8:
- vga_mem_wr_handler(ctx, addr, *val, arg1);
- vga_mem_wr_handler(ctx, addr + 1, *val >> 8, arg1);
- vga_mem_wr_handler(ctx, addr + 2, *val >> 16, arg1);
- vga_mem_wr_handler(ctx, addr + 3, *val >> 24, arg1);
- vga_mem_wr_handler(ctx, addr + 4, *val >> 32, arg1);
- vga_mem_wr_handler(ctx, addr + 5, *val >> 40, arg1);
- vga_mem_wr_handler(ctx, addr + 6, *val >> 48, arg1);
- vga_mem_wr_handler(ctx, addr + 7, *val >> 56, arg1);
+ vga_mem_wr_handler(addr, *val, arg1);
+ vga_mem_wr_handler(addr + 1, *val >> 8, arg1);
+ vga_mem_wr_handler(addr + 2, *val >> 16, arg1);
+ vga_mem_wr_handler(addr + 3, *val >> 24, arg1);
+ vga_mem_wr_handler(addr + 4, *val >> 32, arg1);
+ vga_mem_wr_handler(addr + 5, *val >> 40, arg1);
+ vga_mem_wr_handler(addr + 6, *val >> 48, arg1);
+ vga_mem_wr_handler(addr + 7, *val >> 56, arg1);
break;
}
} else {
switch (size) {
case 1:
- *val = vga_mem_rd_handler(ctx, addr, arg1);
+ *val = vga_mem_rd_handler(addr, arg1);
break;
case 2:
- *val = vga_mem_rd_handler(ctx, addr, arg1);
- *val |= vga_mem_rd_handler(ctx, addr + 1, arg1) << 8;
+ *val = vga_mem_rd_handler(addr, arg1);
+ *val |= vga_mem_rd_handler(addr + 1, arg1) << 8;
break;
case 4:
- *val = vga_mem_rd_handler(ctx, addr, arg1);
- *val |= vga_mem_rd_handler(ctx, addr + 1, arg1) << 8;
- *val |= vga_mem_rd_handler(ctx, addr + 2, arg1) << 16;
- *val |= vga_mem_rd_handler(ctx, addr + 3, arg1) << 24;
+ *val = vga_mem_rd_handler(addr, arg1);
+ *val |= vga_mem_rd_handler(addr + 1, arg1) << 8;
+ *val |= vga_mem_rd_handler(addr + 2, arg1) << 16;
+ *val |= vga_mem_rd_handler(addr + 3, arg1) << 24;
break;
case 8:
- *val = vga_mem_rd_handler(ctx, addr, arg1);
- *val |= vga_mem_rd_handler(ctx, addr + 1, arg1) << 8;
- *val |= vga_mem_rd_handler(ctx, addr + 2, arg1) << 16;
- *val |= vga_mem_rd_handler(ctx, addr + 3, arg1) << 24;
- *val |= vga_mem_rd_handler(ctx, addr + 4, arg1) << 32;
- *val |= vga_mem_rd_handler(ctx, addr + 5, arg1) << 40;
- *val |= vga_mem_rd_handler(ctx, addr + 6, arg1) << 48;
- *val |= vga_mem_rd_handler(ctx, addr + 7, arg1) << 56;
+ *val = vga_mem_rd_handler(addr, arg1);
+ *val |= vga_mem_rd_handler(addr + 1, arg1) << 8;
+ *val |= vga_mem_rd_handler(addr + 2, arg1) << 16;
+ *val |= vga_mem_rd_handler(addr + 3, arg1) << 24;
+ *val |= vga_mem_rd_handler(addr + 4, arg1) << 32;
+ *val |= vga_mem_rd_handler(addr + 5, arg1) << 40;
+ *val |= vga_mem_rd_handler(addr + 6, arg1) << 48;
+ *val |= vga_mem_rd_handler(addr + 7, arg1) << 56;
break;
}
}
@@ -714,8 +711,8 @@ vga_mem_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
}
static int
-vga_port_in_handler(struct vmctx *ctx, int in, int port, int bytes,
- uint8_t *val, void *arg)
+vga_port_in_handler(struct vmctx *ctx __unused, int in __unused, int port,
+ int bytes __unused, uint8_t *val, void *arg)
{
struct vga_softc *sc = arg;
@@ -941,8 +938,8 @@ vga_port_in_handler(struct vmctx *ctx, int in, int port, int bytes,
}
static int
-vga_port_out_handler(struct vmctx *ctx, int in, int port, int bytes,
- uint8_t val, void *arg)
+vga_port_out_handler(struct vmctx *ctx __unused, int in __unused, int port,
+ int bytes __unused, uint8_t val, void *arg)
{
struct vga_softc *sc = arg;
@@ -1214,8 +1211,8 @@ vga_port_out_handler(struct vmctx *ctx, int in, int port, int bytes,
}
static int
-vga_port_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+vga_port_handler(struct vmctx *ctx, int in, int port,
+ int bytes, uint32_t *eax, void *arg)
{
uint8_t val;
int error;
diff --git a/usr.sbin/bhyve/vga.h b/usr.sbin/bhyve/amd64/vga.h
index 36c6dc15fa9e..86a4c4ad1022 100644
--- a/usr.sbin/bhyve/vga.h
+++ b/usr.sbin/bhyve/amd64/vga.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* 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 _VGA_H_
@@ -157,6 +155,8 @@
#define DAC_IDX_WR_PORT 0x3c8
#define DAC_DATA_PORT 0x3c9
+struct bhyvegc;
void *vga_init(int io_only);
+void vga_render(struct bhyvegc *gc, void *arg);
#endif /* _VGA_H_ */
diff --git a/usr.sbin/bhyve/amd64/vmexit.c b/usr.sbin/bhyve/amd64/vmexit.c
new file mode 100644
index 000000000000..e0b9aec2d17a
--- /dev/null
+++ b/usr.sbin/bhyve/amd64/vmexit.c
@@ -0,0 +1,521 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2011 NetApp, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+
+#include <machine/vmm.h>
+#include <machine/vmm_dev.h>
+#include <machine/vmm_instruction_emul.h>
+#include <amd64/vmm/intel/vmcs.h>
+#include <x86/apicreg.h>
+
+#include <assert.h>
+#include <err.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <unistd.h>
+
+#include <vmmapi.h>
+
+#include "bhyverun.h"
+#include "config.h"
+#include "debug.h"
+#include "gdb.h"
+#include "inout.h"
+#include "mem.h"
+#ifdef BHYVE_SNAPSHOT
+#include "snapshot.h"
+#endif
+#include "spinup_ap.h"
+#include "vmexit.h"
+#include "xmsr.h"
+
+void
+vm_inject_fault(struct vcpu *vcpu, int vector, int errcode_valid,
+ int errcode)
+{
+ int error, restart_instruction;
+
+ restart_instruction = 1;
+
+ error = vm_inject_exception(vcpu, vector, errcode_valid, errcode,
+ restart_instruction);
+ assert(error == 0);
+}
+
+static int
+vmexit_inout(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun)
+{
+ struct vm_exit *vme;
+ int error;
+ int bytes, port, in;
+
+ vme = vmrun->vm_exit;
+ port = vme->u.inout.port;
+ bytes = vme->u.inout.bytes;
+ in = vme->u.inout.in;
+
+ error = emulate_inout(ctx, vcpu, vme);
+ if (error) {
+ EPRINTLN("Unhandled %s%c 0x%04x at 0x%lx",
+ in ? "in" : "out",
+ bytes == 1 ? 'b' : (bytes == 2 ? 'w' : 'l'),
+ port, vme->rip);
+ return (VMEXIT_ABORT);
+ } else {
+ return (VMEXIT_CONTINUE);
+ }
+}
+
+static int
+vmexit_rdmsr(struct vmctx *ctx __unused, struct vcpu *vcpu,
+ struct vm_run *vmrun)
+{
+ struct vm_exit *vme;
+ uint64_t val;
+ uint32_t eax, edx;
+ int error;
+
+ vme = vmrun->vm_exit;
+
+ val = 0;
+ error = emulate_rdmsr(vcpu, vme->u.msr.code, &val);
+ if (error != 0) {
+ EPRINTLN("rdmsr to register %#x on vcpu %d",
+ vme->u.msr.code, vcpu_id(vcpu));
+ if (get_config_bool("x86.strictmsr")) {
+ vm_inject_gp(vcpu);
+ return (VMEXIT_CONTINUE);
+ }
+ }
+
+ eax = val;
+ error = vm_set_register(vcpu, VM_REG_GUEST_RAX, eax);
+ assert(error == 0);
+
+ edx = val >> 32;
+ error = vm_set_register(vcpu, VM_REG_GUEST_RDX, edx);
+ assert(error == 0);
+
+ return (VMEXIT_CONTINUE);
+}
+
+static int
+vmexit_wrmsr(struct vmctx *ctx __unused, struct vcpu *vcpu,
+ struct vm_run *vmrun)
+{
+ struct vm_exit *vme;
+ int error;
+
+ vme = vmrun->vm_exit;
+
+ error = emulate_wrmsr(vcpu, vme->u.msr.code, vme->u.msr.wval);
+ if (error != 0) {
+ EPRINTLN("wrmsr to register %#x(%#lx) on vcpu %d",
+ vme->u.msr.code, vme->u.msr.wval, vcpu_id(vcpu));
+ if (get_config_bool("x86.strictmsr")) {
+ vm_inject_gp(vcpu);
+ return (VMEXIT_CONTINUE);
+ }
+ }
+ return (VMEXIT_CONTINUE);
+}
+
+static const char * const vmx_exit_reason_desc[] = {
+ [EXIT_REASON_EXCEPTION] = "Exception or non-maskable interrupt (NMI)",
+ [EXIT_REASON_EXT_INTR] = "External interrupt",
+ [EXIT_REASON_TRIPLE_FAULT] = "Triple fault",
+ [EXIT_REASON_INIT] = "INIT signal",
+ [EXIT_REASON_SIPI] = "Start-up IPI (SIPI)",
+ [EXIT_REASON_IO_SMI] = "I/O system-management interrupt (SMI)",
+ [EXIT_REASON_SMI] = "Other SMI",
+ [EXIT_REASON_INTR_WINDOW] = "Interrupt window",
+ [EXIT_REASON_NMI_WINDOW] = "NMI window",
+ [EXIT_REASON_TASK_SWITCH] = "Task switch",
+ [EXIT_REASON_CPUID] = "CPUID",
+ [EXIT_REASON_GETSEC] = "GETSEC",
+ [EXIT_REASON_HLT] = "HLT",
+ [EXIT_REASON_INVD] = "INVD",
+ [EXIT_REASON_INVLPG] = "INVLPG",
+ [EXIT_REASON_RDPMC] = "RDPMC",
+ [EXIT_REASON_RDTSC] = "RDTSC",
+ [EXIT_REASON_RSM] = "RSM",
+ [EXIT_REASON_VMCALL] = "VMCALL",
+ [EXIT_REASON_VMCLEAR] = "VMCLEAR",
+ [EXIT_REASON_VMLAUNCH] = "VMLAUNCH",
+ [EXIT_REASON_VMPTRLD] = "VMPTRLD",
+ [EXIT_REASON_VMPTRST] = "VMPTRST",
+ [EXIT_REASON_VMREAD] = "VMREAD",
+ [EXIT_REASON_VMRESUME] = "VMRESUME",
+ [EXIT_REASON_VMWRITE] = "VMWRITE",
+ [EXIT_REASON_VMXOFF] = "VMXOFF",
+ [EXIT_REASON_VMXON] = "VMXON",
+ [EXIT_REASON_CR_ACCESS] = "Control-register accesses",
+ [EXIT_REASON_DR_ACCESS] = "MOV DR",
+ [EXIT_REASON_INOUT] = "I/O instruction",
+ [EXIT_REASON_RDMSR] = "RDMSR",
+ [EXIT_REASON_WRMSR] = "WRMSR",
+ [EXIT_REASON_INVAL_VMCS] =
+ "VM-entry failure due to invalid guest state",
+ [EXIT_REASON_INVAL_MSR] = "VM-entry failure due to MSR loading",
+ [EXIT_REASON_MWAIT] = "MWAIT",
+ [EXIT_REASON_MTF] = "Monitor trap flag",
+ [EXIT_REASON_MONITOR] = "MONITOR",
+ [EXIT_REASON_PAUSE] = "PAUSE",
+ [EXIT_REASON_MCE_DURING_ENTRY] =
+ "VM-entry failure due to machine-check event",
+ [EXIT_REASON_TPR] = "TPR below threshold",
+ [EXIT_REASON_APIC_ACCESS] = "APIC access",
+ [EXIT_REASON_VIRTUALIZED_EOI] = "Virtualized EOI",
+ [EXIT_REASON_GDTR_IDTR] = "Access to GDTR or IDTR",
+ [EXIT_REASON_LDTR_TR] = "Access to LDTR or TR",
+ [EXIT_REASON_EPT_FAULT] = "EPT violation",
+ [EXIT_REASON_EPT_MISCONFIG] = "EPT misconfiguration",
+ [EXIT_REASON_INVEPT] = "INVEPT",
+ [EXIT_REASON_RDTSCP] = "RDTSCP",
+ [EXIT_REASON_VMX_PREEMPT] = "VMX-preemption timer expired",
+ [EXIT_REASON_INVVPID] = "INVVPID",
+ [EXIT_REASON_WBINVD] = "WBINVD",
+ [EXIT_REASON_XSETBV] = "XSETBV",
+ [EXIT_REASON_APIC_WRITE] = "APIC write",
+ [EXIT_REASON_RDRAND] = "RDRAND",
+ [EXIT_REASON_INVPCID] = "INVPCID",
+ [EXIT_REASON_VMFUNC] = "VMFUNC",
+ [EXIT_REASON_ENCLS] = "ENCLS",
+ [EXIT_REASON_RDSEED] = "RDSEED",
+ [EXIT_REASON_PM_LOG_FULL] = "Page-modification log full",
+ [EXIT_REASON_XSAVES] = "XSAVES",
+ [EXIT_REASON_XRSTORS] = "XRSTORS"
+};
+
+static const char *
+vmexit_vmx_desc(uint32_t exit_reason)
+{
+
+ if (exit_reason >= nitems(vmx_exit_reason_desc) ||
+ vmx_exit_reason_desc[exit_reason] == NULL)
+ return ("Unknown");
+ return (vmx_exit_reason_desc[exit_reason]);
+}
+
+#define DEBUG_EPT_MISCONFIG
+#ifdef DEBUG_EPT_MISCONFIG
+#define VMCS_GUEST_PHYSICAL_ADDRESS 0x00002400
+
+static uint64_t ept_misconfig_gpa, ept_misconfig_pte[4];
+static int ept_misconfig_ptenum;
+#endif
+
+static int
+vmexit_vmx(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun)
+{
+ struct vm_exit *vme;
+
+ vme = vmrun->vm_exit;
+
+ EPRINTLN("vm exit[%d]", vcpu_id(vcpu));
+ EPRINTLN("\treason\t\tVMX");
+ EPRINTLN("\trip\t\t0x%016lx", vme->rip);
+ EPRINTLN("\tinst_length\t%d", vme->inst_length);
+ EPRINTLN("\tstatus\t\t%d", vme->u.vmx.status);
+ EPRINTLN("\texit_reason\t%u (%s)", vme->u.vmx.exit_reason,
+ vmexit_vmx_desc(vme->u.vmx.exit_reason));
+ EPRINTLN("\tqualification\t0x%016lx",
+ vme->u.vmx.exit_qualification);
+ EPRINTLN("\tinst_type\t\t%d", vme->u.vmx.inst_type);
+ EPRINTLN("\tinst_error\t\t%d", vme->u.vmx.inst_error);
+#ifdef DEBUG_EPT_MISCONFIG
+ if (vme->u.vmx.exit_reason == EXIT_REASON_EPT_MISCONFIG) {
+ vm_get_register(vcpu,
+ VMCS_IDENT(VMCS_GUEST_PHYSICAL_ADDRESS),
+ &ept_misconfig_gpa);
+ vm_get_gpa_pmap(ctx, ept_misconfig_gpa, ept_misconfig_pte,
+ &ept_misconfig_ptenum);
+ EPRINTLN("\tEPT misconfiguration:");
+ EPRINTLN("\t\tGPA: %#lx", ept_misconfig_gpa);
+ EPRINTLN("\t\tPTE(%d): %#lx %#lx %#lx %#lx",
+ ept_misconfig_ptenum, ept_misconfig_pte[0],
+ ept_misconfig_pte[1], ept_misconfig_pte[2],
+ ept_misconfig_pte[3]);
+ }
+#endif /* DEBUG_EPT_MISCONFIG */
+ return (VMEXIT_ABORT);
+}
+
+static int
+vmexit_svm(struct vmctx *ctx __unused, struct vcpu *vcpu, struct vm_run *vmrun)
+{
+ struct vm_exit *vme;
+
+ vme = vmrun->vm_exit;
+
+ EPRINTLN("vm exit[%d]", vcpu_id(vcpu));
+ EPRINTLN("\treason\t\tSVM");
+ EPRINTLN("\trip\t\t0x%016lx", vme->rip);
+ EPRINTLN("\tinst_length\t%d", vme->inst_length);
+ EPRINTLN("\texitcode\t%#lx", vme->u.svm.exitcode);
+ EPRINTLN("\texitinfo1\t%#lx", vme->u.svm.exitinfo1);
+ EPRINTLN("\texitinfo2\t%#lx", vme->u.svm.exitinfo2);
+ return (VMEXIT_ABORT);
+}
+
+static int
+vmexit_bogus(struct vmctx *ctx __unused, struct vcpu *vcpu __unused,
+ struct vm_run *vmrun)
+{
+ assert(vmrun->vm_exit->inst_length == 0);
+
+ return (VMEXIT_CONTINUE);
+}
+
+static int
+vmexit_reqidle(struct vmctx *ctx __unused, struct vcpu *vcpu __unused,
+ struct vm_run *vmrun)
+{
+ assert(vmrun->vm_exit->inst_length == 0);
+
+ return (VMEXIT_CONTINUE);
+}
+
+static int
+vmexit_hlt(struct vmctx *ctx __unused, struct vcpu *vcpu __unused,
+ struct vm_run *vmrun __unused)
+{
+ /*
+ * Just continue execution with the next instruction. We use
+ * the HLT VM exit as a way to be friendly with the host
+ * scheduler.
+ */
+ return (VMEXIT_CONTINUE);
+}
+
+static int
+vmexit_pause(struct vmctx *ctx __unused, struct vcpu *vcpu __unused,
+ struct vm_run *vmrun __unused)
+{
+ return (VMEXIT_CONTINUE);
+}
+
+static int
+vmexit_mtrap(struct vmctx *ctx __unused, struct vcpu *vcpu,
+ struct vm_run *vmrun)
+{
+ assert(vmrun->vm_exit->inst_length == 0);
+
+#ifdef BHYVE_SNAPSHOT
+ checkpoint_cpu_suspend(vcpu_id(vcpu));
+#endif
+ gdb_cpu_mtrap(vcpu);
+#ifdef BHYVE_SNAPSHOT
+ checkpoint_cpu_resume(vcpu_id(vcpu));
+#endif
+
+ return (VMEXIT_CONTINUE);
+}
+
+static int
+vmexit_inst_emul(struct vmctx *ctx __unused, struct vcpu *vcpu,
+ struct vm_run *vmrun)
+{
+ struct vm_exit *vme;
+ struct vie *vie;
+ int err, i, cs_d;
+ enum vm_cpu_mode mode;
+
+ vme = vmrun->vm_exit;
+
+ vie = &vme->u.inst_emul.vie;
+ if (!vie->decoded) {
+ /*
+ * Attempt to decode in userspace as a fallback. This allows
+ * updating instruction decode in bhyve without rebooting the
+ * kernel (rapid prototyping), albeit with much slower
+ * emulation.
+ */
+ vie_restart(vie);
+ mode = vme->u.inst_emul.paging.cpu_mode;
+ cs_d = vme->u.inst_emul.cs_d;
+ if (vmm_decode_instruction(mode, cs_d, vie) != 0)
+ goto fail;
+ if (vm_set_register(vcpu, VM_REG_GUEST_RIP,
+ vme->rip + vie->num_processed) != 0)
+ goto fail;
+ }
+
+ err = emulate_mem(vcpu, vme->u.inst_emul.gpa, vie,
+ &vme->u.inst_emul.paging);
+ if (err) {
+ if (err == ESRCH) {
+ EPRINTLN("Unhandled memory access to 0x%lx\n",
+ vme->u.inst_emul.gpa);
+ }
+ goto fail;
+ }
+
+ return (VMEXIT_CONTINUE);
+
+fail:
+ fprintf(stderr, "Failed to emulate instruction sequence [ ");
+ for (i = 0; i < vie->num_valid; i++)
+ fprintf(stderr, "%02x", vie->inst[i]);
+ FPRINTLN(stderr, " ] at 0x%lx", vme->rip);
+ return (VMEXIT_ABORT);
+}
+
+static int
+vmexit_suspend(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun)
+{
+ struct vm_exit *vme;
+ enum vm_suspend_how how;
+ int vcpuid = vcpu_id(vcpu);
+
+ vme = vmrun->vm_exit;
+
+ how = vme->u.suspended.how;
+
+ fbsdrun_deletecpu(vcpuid);
+
+ switch (how) {
+ case VM_SUSPEND_RESET:
+ exit(0);
+ case VM_SUSPEND_POWEROFF:
+ if (get_config_bool_default("destroy_on_poweroff", false))
+ vm_destroy(ctx);
+ exit(1);
+ case VM_SUSPEND_HALT:
+ exit(2);
+ case VM_SUSPEND_TRIPLEFAULT:
+ exit(3);
+ default:
+ EPRINTLN("vmexit_suspend: invalid reason %d", how);
+ exit(100);
+ }
+ return (0); /* NOTREACHED */
+}
+
+static int
+vmexit_debug(struct vmctx *ctx __unused, struct vcpu *vcpu,
+ struct vm_run *vmrun __unused)
+{
+
+#ifdef BHYVE_SNAPSHOT
+ checkpoint_cpu_suspend(vcpu_id(vcpu));
+#endif
+ gdb_cpu_suspend(vcpu);
+#ifdef BHYVE_SNAPSHOT
+ checkpoint_cpu_resume(vcpu_id(vcpu));
+#endif
+ /*
+ * XXX-MJ sleep for a short period to avoid chewing up the CPU in the
+ * window between activation of the vCPU thread and the STARTUP IPI.
+ */
+ usleep(1000);
+ return (VMEXIT_CONTINUE);
+}
+
+static int
+vmexit_db(struct vmctx *ctx __unused, struct vcpu *vcpu, struct vm_run *vmrun)
+{
+
+#ifdef BHYVE_SNAPSHOT
+ checkpoint_cpu_suspend(vcpu_id(vcpu));
+#endif
+ gdb_cpu_debug(vcpu, vmrun->vm_exit);
+#ifdef BHYVE_SNAPSHOT
+ checkpoint_cpu_resume(vcpu_id(vcpu));
+#endif
+ return (VMEXIT_CONTINUE);
+}
+
+static int
+vmexit_breakpoint(struct vmctx *ctx __unused, struct vcpu *vcpu,
+ struct vm_run *vmrun)
+{
+ gdb_cpu_breakpoint(vcpu, vmrun->vm_exit);
+ return (VMEXIT_CONTINUE);
+}
+
+static int
+vmexit_ipi(struct vmctx *ctx __unused, struct vcpu *vcpu __unused,
+ struct vm_run *vmrun)
+{
+ struct vm_exit *vme;
+ cpuset_t *dmask;
+ int error = -1;
+ int i;
+
+ dmask = vmrun->cpuset;
+ vme = vmrun->vm_exit;
+
+ switch (vme->u.ipi.mode) {
+ case APIC_DELMODE_INIT:
+ CPU_FOREACH_ISSET(i, dmask) {
+ error = fbsdrun_suspendcpu(i);
+ if (error) {
+ warnx("failed to suspend cpu %d", i);
+ break;
+ }
+ }
+ break;
+ case APIC_DELMODE_STARTUP:
+ CPU_FOREACH_ISSET(i, dmask) {
+ spinup_ap(fbsdrun_vcpu(i),
+ vme->u.ipi.vector << PAGE_SHIFT);
+ }
+ error = 0;
+ break;
+ default:
+ break;
+ }
+
+ return (error);
+}
+
+int vmexit_task_switch(struct vmctx *, struct vcpu *, struct vm_run *);
+
+const vmexit_handler_t vmexit_handlers[VM_EXITCODE_MAX] = {
+ [VM_EXITCODE_INOUT] = vmexit_inout,
+ [VM_EXITCODE_INOUT_STR] = vmexit_inout,
+ [VM_EXITCODE_VMX] = vmexit_vmx,
+ [VM_EXITCODE_SVM] = vmexit_svm,
+ [VM_EXITCODE_BOGUS] = vmexit_bogus,
+ [VM_EXITCODE_REQIDLE] = vmexit_reqidle,
+ [VM_EXITCODE_RDMSR] = vmexit_rdmsr,
+ [VM_EXITCODE_WRMSR] = vmexit_wrmsr,
+ [VM_EXITCODE_MTRAP] = vmexit_mtrap,
+ [VM_EXITCODE_INST_EMUL] = vmexit_inst_emul,
+ [VM_EXITCODE_SUSPENDED] = vmexit_suspend,
+ [VM_EXITCODE_TASK_SWITCH] = vmexit_task_switch,
+ [VM_EXITCODE_DEBUG] = vmexit_debug,
+ [VM_EXITCODE_BPT] = vmexit_breakpoint,
+ [VM_EXITCODE_IPI] = vmexit_ipi,
+ [VM_EXITCODE_HLT] = vmexit_hlt,
+ [VM_EXITCODE_PAUSE] = vmexit_pause,
+ [VM_EXITCODE_DB] = vmexit_db,
+};
diff --git a/usr.sbin/bhyve/xmsr.c b/usr.sbin/bhyve/amd64/xmsr.c
index 1a7f98ee222a..cd80e4ef782e 100644
--- a/usr.sbin/bhyve/xmsr.c
+++ b/usr.sbin/bhyve/amd64/xmsr.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,32 +24,28 @@
* 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 <sys/types.h>
#include <machine/cpufunc.h>
#include <machine/vmm.h>
#include <machine/specialreg.h>
-#include <vmmapi.h>
-
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <vmmapi.h>
+
#include "debug.h"
#include "xmsr.h"
static int cpu_vendor_intel, cpu_vendor_amd, cpu_vendor_hygon;
int
-emulate_wrmsr(struct vmctx *ctx, int vcpu, uint32_t num, uint64_t val)
+emulate_wrmsr(struct vcpu *vcpu __unused, uint32_t num, uint64_t val __unused)
{
if (cpu_vendor_intel) {
@@ -103,7 +99,7 @@ emulate_wrmsr(struct vmctx *ctx, int vcpu, uint32_t num, uint64_t val)
}
int
-emulate_rdmsr(struct vmctx *ctx, int vcpu, uint32_t num, uint64_t *val)
+emulate_rdmsr(struct vcpu *vcpu __unused, uint32_t num, uint64_t *val)
{
int error = 0;
@@ -115,6 +111,7 @@ emulate_rdmsr(struct vmctx *ctx, int vcpu, uint32_t num, uint64_t *val)
case MSR_PP0_ENERGY_STATUS:
case MSR_PP1_ENERGY_STATUS:
case MSR_DRAM_ENERGY_STATUS:
+ case MSR_MISC_FEATURE_ENABLES:
*val = 0;
break;
case MSR_RAPL_POWER_UNIT:
@@ -239,7 +236,7 @@ init_msr(void)
cpu_vendor_intel = 1;
} else {
EPRINTLN("Unknown cpu vendor \"%s\"", cpu_vendor);
- error = -1;
+ error = ENOENT;
}
return (error);
}
diff --git a/usr.sbin/bhyve/xmsr.h b/usr.sbin/bhyve/amd64/xmsr.h
index 1fb47c3ae2f0..e0b3492559d5 100644
--- a/usr.sbin/bhyve/xmsr.h
+++ b/usr.sbin/bhyve/amd64/xmsr.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,15 +24,13 @@
* 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 _XMSR_H_
#define _XMSR_H_
int init_msr(void);
-int emulate_wrmsr(struct vmctx *ctx, int vcpu, uint32_t code, uint64_t val);
-int emulate_rdmsr(struct vmctx *ctx, int vcpu, uint32_t code, uint64_t *val);
+int emulate_wrmsr(struct vcpu *vcpu, uint32_t code, uint64_t val);
+int emulate_rdmsr(struct vcpu *vcpu, uint32_t code, uint64_t *val);
#endif
diff --git a/usr.sbin/bhyve/audio.c b/usr.sbin/bhyve/audio.c
index ee6bdabc541c..4613f3583116 100644
--- a/usr.sbin/bhyve/audio.c
+++ b/usr.sbin/bhyve/audio.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 Alex Teaca <iateaca@FreeBSD.org>
* All rights reserved.
@@ -28,8 +28,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
#include <capsicum_helpers.h>
@@ -82,6 +80,7 @@ audio_init(const char *dev_name, uint8_t dir)
#endif
};
#endif
+ size_t nlen;
assert(dev_name);
@@ -89,8 +88,9 @@ audio_init(const char *dev_name, uint8_t dir)
if (!aud)
return NULL;
- if (strlen(dev_name) < sizeof(aud->dev_name))
- memcpy(aud->dev_name, dev_name, strlen(dev_name) + 1);
+ nlen = strlen(dev_name);
+ if (nlen < sizeof(aud->dev_name))
+ memcpy(aud->dev_name, dev_name, nlen + 1);
else {
DPRINTF("dev_name too big");
free(aud);
@@ -221,10 +221,11 @@ audio_set_params(struct audio *aud, struct audio_params *params)
* @count - the number of bytes in buffer
*/
int
-audio_playback(struct audio *aud, const void *buf, size_t count)
+audio_playback(struct audio *aud, const uint8_t *buf, size_t count)
{
- int audio_fd = -1;
- ssize_t len = 0, total = 0;
+ ssize_t len;
+ size_t total;
+ int audio_fd;
assert(aud);
assert(aud->dir);
@@ -233,16 +234,13 @@ audio_playback(struct audio *aud, const void *buf, size_t count)
audio_fd = aud->fd;
assert(audio_fd != -1);
- total = 0;
- while (total < count) {
+ for (total = 0; total < count; total += len) {
len = write(audio_fd, buf + total, count - total);
- if (len == -1) {
+ if (len < 0) {
DPRINTF("Fail to write to fd: %d, errno: %d",
audio_fd, errno);
return -1;
}
-
- total += len;
}
return 0;
@@ -257,10 +255,11 @@ audio_playback(struct audio *aud, const void *buf, size_t count)
* Returns -1 on error and 0 on success
*/
int
-audio_record(struct audio *aud, void *buf, size_t count)
+audio_record(struct audio *aud, uint8_t *buf, size_t count)
{
- int audio_fd = -1;
- ssize_t len = 0, total = 0;
+ ssize_t len;
+ size_t total;
+ int audio_fd;
assert(aud);
assert(!aud->dir);
@@ -269,16 +268,13 @@ audio_record(struct audio *aud, void *buf, size_t count)
audio_fd = aud->fd;
assert(audio_fd != -1);
- total = 0;
- while (total < count) {
+ for (total = 0; total < count; total += len) {
len = read(audio_fd, buf + total, count - total);
- if (len == -1) {
+ if (len < 0) {
DPRINTF("Fail to write to fd: %d, errno: %d",
audio_fd, errno);
return -1;
}
-
- total += len;
}
return 0;
diff --git a/usr.sbin/bhyve/audio.h b/usr.sbin/bhyve/audio.h
index 88f4dc8709c4..a7bb8cebc1a1 100644
--- a/usr.sbin/bhyve/audio.h
+++ b/usr.sbin/bhyve/audio.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 Alex Teaca <iateaca@FreeBSD.org>
* 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 _AUDIO_EMUL_H_
@@ -73,7 +71,7 @@ int audio_set_params(struct audio *aud, struct audio_params *params);
* @count - the number of bytes in buffer
* Returns -1 on error and 0 on success
*/
-int audio_playback(struct audio *aud, const void *buf, size_t count);
+int audio_playback(struct audio *aud, const uint8_t *buf, size_t count);
/*
* audio_record - records samples from the sound device using blocking
@@ -83,6 +81,6 @@ int audio_playback(struct audio *aud, const void *buf, size_t count);
* @count - the number of bytes to capture in buffer
* Returns -1 on error and 0 on success
*/
-int audio_record(struct audio *aud, void *buf, size_t count);
+int audio_record(struct audio *aud, uint8_t *buf, size_t count);
#endif /* _AUDIO_EMUL_H_ */
diff --git a/usr.sbin/bhyve/basl.c b/usr.sbin/bhyve/basl.c
new file mode 100644
index 000000000000..c20a52571937
--- /dev/null
+++ b/usr.sbin/bhyve/basl.c
@@ -0,0 +1,702 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 Beckhoff Automation GmbH & Co. KG
+ */
+
+#include <sys/param.h>
+#include <sys/endian.h>
+#include <sys/errno.h>
+#include <sys/queue.h>
+#include <sys/stat.h>
+
+#include <machine/vmm.h>
+
+#include <assert.h>
+#include <err.h>
+#include <libutil.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <vmmapi.h>
+
+#include "basl.h"
+#include "config.h"
+#include "qemu_loader.h"
+
+struct basl_table_checksum {
+ STAILQ_ENTRY(basl_table_checksum) chain;
+ uint32_t off;
+ uint32_t start;
+ uint32_t len;
+};
+
+struct basl_table_length {
+ STAILQ_ENTRY(basl_table_length) chain;
+ uint32_t off;
+ uint8_t size;
+};
+
+struct basl_table_pointer {
+ STAILQ_ENTRY(basl_table_pointer) chain;
+ uint8_t src_signature[ACPI_NAMESEG_SIZE];
+ uint32_t off;
+ uint8_t size;
+};
+
+struct basl_table {
+ STAILQ_ENTRY(basl_table) chain;
+ struct vmctx *ctx;
+ uint8_t fwcfg_name[QEMU_FWCFG_MAX_NAME];
+ void *data;
+ uint32_t len;
+ uint32_t off;
+ uint32_t alignment;
+ STAILQ_HEAD(basl_table_checksum_list, basl_table_checksum) checksums;
+ STAILQ_HEAD(basl_table_length_list, basl_table_length) lengths;
+ STAILQ_HEAD(basl_table_pointer_list, basl_table_pointer) pointers;
+};
+static STAILQ_HEAD(basl_table_list, basl_table) basl_tables = STAILQ_HEAD_INITIALIZER(
+ basl_tables);
+
+static struct qemu_loader *basl_loader;
+static struct basl_table *rsdt;
+static struct basl_table *xsdt;
+static bool load_into_memory;
+
+static __inline uint64_t
+basl_le_dec(void *pp, size_t len)
+{
+ assert(len <= 8);
+
+ switch (len) {
+ case 1:
+ return ((uint8_t *)pp)[0];
+ case 2:
+ return le16dec(pp);
+ case 4:
+ return le32dec(pp);
+ case 8:
+ return le64dec(pp);
+ }
+
+ return 0;
+}
+
+static __inline void
+basl_le_enc(void *pp, uint64_t val, size_t len)
+{
+ char buf[8];
+
+ assert(len <= 8);
+
+ le64enc(buf, val);
+ memcpy(pp, buf, len);
+}
+
+static int
+basl_dump_table(const struct basl_table *const table, const bool mem)
+{
+ const ACPI_TABLE_HEADER *const header = table->data;
+ const uint8_t *data;
+
+ if (!mem) {
+ data = table->data;
+ } else {
+ data = vm_map_gpa(table->ctx, BHYVE_ACPI_BASE + table->off,
+ table->len);
+ if (data == NULL) {
+ return (ENOMEM);
+ }
+ }
+
+ printf("%.4s @ %8x (%s)\n", header->Signature,
+ BHYVE_ACPI_BASE + table->off, mem ? "Memory" : "FwCfg");
+ hexdump(data, table->len, NULL, 0);
+
+ return (0);
+}
+
+static int __unused
+basl_dump(const bool mem)
+{
+ struct basl_table *table;
+
+ STAILQ_FOREACH(table, &basl_tables, chain) {
+ BASL_EXEC(basl_dump_table(table, mem));
+ }
+
+ return (0);
+}
+
+void
+basl_fill_gas(ACPI_GENERIC_ADDRESS *const gas, const uint8_t space_id,
+ const uint8_t bit_width, const uint8_t bit_offset,
+ const uint8_t access_width, const uint64_t address)
+{
+ assert(gas != NULL);
+
+ gas->SpaceId = space_id;
+ gas->BitWidth = bit_width;
+ gas->BitOffset = bit_offset;
+ gas->AccessWidth = access_width;
+ gas->Address = htole64(address);
+}
+
+static int
+basl_finish_install_guest_tables(struct basl_table *const table, uint32_t *const off)
+{
+ void *gva;
+
+ table->off = roundup2(*off, table->alignment);
+ *off = table->off + table->len;
+ if (*off <= table->off) {
+ warnx("%s: invalid table length 0x%8x @ offset 0x%8x", __func__,
+ table->len, table->off);
+ return (EFAULT);
+ }
+
+ /* Cause guest BIOS to copy the ACPI table into guest memory. */
+ BASL_EXEC(
+ qemu_fwcfg_add_file(table->fwcfg_name, table->len, table->data));
+ BASL_EXEC(qemu_loader_alloc(basl_loader, table->fwcfg_name,
+ table->alignment, QEMU_LOADER_ALLOC_HIGH));
+
+ if (!load_into_memory) {
+ return (0);
+ }
+
+ /*
+ * Install ACPI tables directly in guest memory for use by guests which
+ * do not boot via EFI. EFI ROMs provide a pointer to the firmware
+ * generated ACPI tables instead, but it doesn't hurt to install the
+ * tables always.
+ */
+ gva = vm_map_gpa(table->ctx, BHYVE_ACPI_BASE + table->off, table->len);
+ if (gva == NULL) {
+ warnx("%s: could not map gpa [ 0x%16lx, 0x%16lx ]", __func__,
+ (uint64_t)BHYVE_ACPI_BASE + table->off,
+ (uint64_t)BHYVE_ACPI_BASE + table->off + table->len);
+ return (ENOMEM);
+ }
+ memcpy(gva, table->data, table->len);
+
+ return (0);
+}
+
+static int
+basl_finish_patch_checksums(struct basl_table *const table)
+{
+ struct basl_table_checksum *checksum;
+
+ STAILQ_FOREACH(checksum, &table->checksums, chain) {
+ uint8_t *gva, *checksum_gva;
+ uint64_t gpa;
+ uint32_t len;
+ uint8_t sum;
+
+ len = checksum->len;
+ if (len == BASL_TABLE_CHECKSUM_LEN_FULL_TABLE) {
+ len = table->len;
+ }
+
+ assert(checksum->off < table->len);
+ assert(checksum->start < table->len);
+ assert(checksum->start + len <= table->len);
+
+ /* Cause guest BIOS to patch the checksum. */
+ BASL_EXEC(qemu_loader_add_checksum(basl_loader,
+ table->fwcfg_name, checksum->off, checksum->start, len));
+
+ if (!load_into_memory) {
+ continue;
+ }
+
+ /*
+ * Install ACPI tables directly in guest memory for use by
+ * guests which do not boot via EFI. EFI ROMs provide a pointer
+ * to the firmware generated ACPI tables instead, but it doesn't
+ * hurt to install the tables always.
+ */
+ gpa = BHYVE_ACPI_BASE + table->off + checksum->start;
+ if ((gpa < BHYVE_ACPI_BASE) ||
+ (gpa < BHYVE_ACPI_BASE + table->off)) {
+ warnx("%s: invalid gpa (off 0x%8x start 0x%8x)",
+ __func__, table->off, checksum->start);
+ return (EFAULT);
+ }
+
+ gva = vm_map_gpa(table->ctx, gpa, len);
+ if (gva == NULL) {
+ warnx("%s: could not map gpa [ 0x%16lx, 0x%16lx ]",
+ __func__, gpa, gpa + len);
+ return (ENOMEM);
+ }
+
+ checksum_gva = gva + checksum->off;
+ if (checksum_gva < gva) {
+ warnx("%s: invalid checksum offset 0x%8x", __func__,
+ checksum->off);
+ return (EFAULT);
+ }
+
+ sum = 0;
+ for (uint32_t i = 0; i < len; ++i) {
+ sum += *(gva + i);
+ }
+ *checksum_gva = -sum;
+ }
+
+ return (0);
+}
+
+static struct basl_table *
+basl_get_table_by_signature(const uint8_t signature[ACPI_NAMESEG_SIZE])
+{
+ struct basl_table *table;
+
+ STAILQ_FOREACH(table, &basl_tables, chain) {
+ const ACPI_TABLE_HEADER *const header =
+ (const ACPI_TABLE_HEADER *)table->data;
+
+ if (strncmp(header->Signature, signature,
+ sizeof(header->Signature)) == 0) {
+ return (table);
+ }
+ }
+
+ warnx("%s: %.4s not found", __func__, signature);
+ return (NULL);
+}
+
+static int
+basl_finish_patch_pointers(struct basl_table *const table)
+{
+ struct basl_table_pointer *pointer;
+
+ STAILQ_FOREACH(pointer, &table->pointers, chain) {
+ const struct basl_table *src_table;
+ uint8_t *gva;
+ uint64_t gpa, val;
+
+ assert(pointer->off < table->len);
+ assert(pointer->off + pointer->size <= table->len);
+
+ src_table = basl_get_table_by_signature(pointer->src_signature);
+ if (src_table == NULL) {
+ warnx("%s: could not find ACPI table %.4s", __func__,
+ pointer->src_signature);
+ return (EFAULT);
+ }
+
+ /* Cause guest BIOS to patch the pointer. */
+ BASL_EXEC(
+ qemu_loader_add_pointer(basl_loader, table->fwcfg_name,
+ src_table->fwcfg_name, pointer->off, pointer->size));
+
+ if (!load_into_memory) {
+ continue;
+ }
+
+ /*
+ * Install ACPI tables directly in guest memory for use by
+ * guests which do not boot via EFI. EFI ROMs provide a pointer
+ * to the firmware generated ACPI tables instead, but it doesn't
+ * hurt to install the tables always.
+ */
+ gpa = BHYVE_ACPI_BASE + table->off;
+ if (gpa < BHYVE_ACPI_BASE) {
+ warnx("%s: table offset of 0x%8x is too large",
+ __func__, table->off);
+ return (EFAULT);
+ }
+
+ gva = vm_map_gpa(table->ctx, gpa, table->len);
+ if (gva == NULL) {
+ warnx("%s: could not map gpa [ 0x%16lx, 0x%16lx ]",
+ __func__, gpa, gpa + table->len);
+ return (ENOMEM);
+ }
+
+ val = basl_le_dec(gva + pointer->off, pointer->size);
+ val += BHYVE_ACPI_BASE + src_table->off;
+ basl_le_enc(gva + pointer->off, val, pointer->size);
+ }
+
+ return (0);
+}
+
+static int
+basl_finish_set_length(struct basl_table *const table)
+{
+ struct basl_table_length *length;
+
+ STAILQ_FOREACH(length, &table->lengths, chain) {
+ assert(length->off < table->len);
+ assert(length->off + length->size <= table->len);
+
+ basl_le_enc((uint8_t *)table->data + length->off, table->len,
+ length->size);
+ }
+
+ return (0);
+}
+
+int
+basl_finish(void)
+{
+ struct basl_table *table;
+ uint32_t off = 0;
+
+ if (STAILQ_EMPTY(&basl_tables)) {
+ warnx("%s: no ACPI tables found", __func__);
+ return (EINVAL);
+ }
+
+ /*
+ * If we install ACPI tables by FwCfg and by memory, Windows will use
+ * the tables from memory. This can cause issues when using advanced
+ * features like a TPM log because we aren't able to patch the memory
+ * tables accordingly.
+ */
+ load_into_memory = get_config_bool_default("acpi_tables_in_memory",
+ true);
+
+ /*
+ * We have to install all tables before we can patch them. Therefore,
+ * use two loops. The first one installs all tables and the second one
+ * patches them.
+ */
+ STAILQ_FOREACH(table, &basl_tables, chain) {
+ BASL_EXEC(basl_finish_set_length(table));
+ BASL_EXEC(basl_finish_install_guest_tables(table, &off));
+ }
+ STAILQ_FOREACH(table, &basl_tables, chain) {
+ BASL_EXEC(basl_finish_patch_pointers(table));
+
+ /*
+ * Calculate the checksum as last step!
+ */
+ BASL_EXEC(basl_finish_patch_checksums(table));
+ }
+ BASL_EXEC(qemu_loader_finish(basl_loader));
+
+ return (0);
+}
+
+static int
+basl_init_rsdt(struct vmctx *const ctx)
+{
+ BASL_EXEC(
+ basl_table_create(&rsdt, ctx, ACPI_SIG_RSDT, BASL_TABLE_ALIGNMENT));
+
+ /* Header */
+ BASL_EXEC(basl_table_append_header(rsdt, ACPI_SIG_RSDT, 1, 1));
+ /* Pointers (added by basl_table_register_to_rsdt) */
+
+ return (0);
+}
+
+static int
+basl_init_xsdt(struct vmctx *const ctx)
+{
+ BASL_EXEC(
+ basl_table_create(&xsdt, ctx, ACPI_SIG_XSDT, BASL_TABLE_ALIGNMENT));
+
+ /* Header */
+ BASL_EXEC(basl_table_append_header(xsdt, ACPI_SIG_XSDT, 1, 1));
+ /* Pointers (added by basl_table_register_to_rsdt) */
+
+ return (0);
+}
+
+int
+basl_init(struct vmctx *const ctx)
+{
+ BASL_EXEC(basl_init_rsdt(ctx));
+ BASL_EXEC(basl_init_xsdt(ctx));
+ BASL_EXEC(
+ qemu_loader_create(&basl_loader, QEMU_FWCFG_FILE_TABLE_LOADER));
+
+ return (0);
+}
+
+int
+basl_table_add_checksum(struct basl_table *const table, const uint32_t off,
+ const uint32_t start, const uint32_t len)
+{
+ struct basl_table_checksum *checksum;
+
+ assert(table != NULL);
+
+ checksum = calloc(1, sizeof(struct basl_table_checksum));
+ if (checksum == NULL) {
+ warnx("%s: failed to allocate checksum", __func__);
+ return (ENOMEM);
+ }
+
+ checksum->off = off;
+ checksum->start = start;
+ checksum->len = len;
+
+ STAILQ_INSERT_TAIL(&table->checksums, checksum, chain);
+
+ return (0);
+}
+
+int
+basl_table_add_length(struct basl_table *const table, const uint32_t off,
+ const uint8_t size)
+{
+ struct basl_table_length *length;
+
+ assert(table != NULL);
+ assert(size == 4 || size == 8);
+
+ length = calloc(1, sizeof(struct basl_table_length));
+ if (length == NULL) {
+ warnx("%s: failed to allocate length", __func__);
+ return (ENOMEM);
+ }
+
+ length->off = off;
+ length->size = size;
+
+ STAILQ_INSERT_TAIL(&table->lengths, length, chain);
+
+ return (0);
+}
+
+int
+basl_table_add_pointer(struct basl_table *const table,
+ const uint8_t src_signature[ACPI_NAMESEG_SIZE], const uint32_t off,
+ const uint8_t size)
+{
+ struct basl_table_pointer *pointer;
+
+ assert(table != NULL);
+ assert(size == 4 || size == 8);
+
+ pointer = calloc(1, sizeof(struct basl_table_pointer));
+ if (pointer == NULL) {
+ warnx("%s: failed to allocate pointer", __func__);
+ return (ENOMEM);
+ }
+
+ memcpy(pointer->src_signature, src_signature,
+ sizeof(pointer->src_signature));
+ pointer->off = off;
+ pointer->size = size;
+
+ STAILQ_INSERT_TAIL(&table->pointers, pointer, chain);
+
+ return (0);
+}
+
+int
+basl_table_append_bytes(struct basl_table *const table, const void *const bytes,
+ const uint32_t len)
+{
+ void *end;
+
+ assert(table != NULL);
+ assert(bytes != NULL);
+
+ if (table->len + len <= table->len) {
+ warnx("%s: table too large (table->len 0x%8x len 0x%8x)",
+ __func__, table->len, len);
+ return (EFAULT);
+ }
+
+ table->data = reallocf(table->data, table->len + len);
+ if (table->data == NULL) {
+ warnx("%s: failed to realloc table to length 0x%8x", __func__,
+ table->len + len);
+ table->len = 0;
+ return (ENOMEM);
+ }
+
+ end = (uint8_t *)table->data + table->len;
+ table->len += len;
+
+ memcpy(end, bytes, len);
+
+ return (0);
+}
+
+int
+basl_table_append_checksum(struct basl_table *const table, const uint32_t start,
+ const uint32_t len)
+{
+ assert(table != NULL);
+
+ BASL_EXEC(basl_table_add_checksum(table, table->len, start, len));
+ BASL_EXEC(basl_table_append_int(table, 0, 1));
+
+ return (0);
+}
+
+int
+basl_table_append_content(struct basl_table *table, void *data, uint32_t len)
+{
+ assert(data != NULL);
+ assert(len >= sizeof(ACPI_TABLE_HEADER));
+
+ return (basl_table_append_bytes(table,
+ (void *)((uintptr_t)(data) + sizeof(ACPI_TABLE_HEADER)),
+ len - sizeof(ACPI_TABLE_HEADER)));
+}
+
+int
+basl_table_append_fwcfg(struct basl_table *const table,
+ const uint8_t *fwcfg_name, const uint32_t alignment, const uint8_t size)
+{
+ assert(table != NULL);
+ assert(fwcfg_name != NULL);
+ assert(size <= sizeof(uint64_t));
+
+ BASL_EXEC(qemu_loader_alloc(basl_loader, fwcfg_name, alignment,
+ QEMU_LOADER_ALLOC_HIGH));
+ BASL_EXEC(qemu_loader_add_pointer(basl_loader, table->fwcfg_name,
+ fwcfg_name, table->len, size));
+ BASL_EXEC(basl_table_append_int(table, 0, size));
+
+ return (0);
+}
+
+int
+basl_table_append_gas(struct basl_table *const table, const uint8_t space_id,
+ const uint8_t bit_width, const uint8_t bit_offset,
+ const uint8_t access_width, const uint64_t address)
+{
+ ACPI_GENERIC_ADDRESS gas_le = {
+ .SpaceId = space_id,
+ .BitWidth = bit_width,
+ .BitOffset = bit_offset,
+ .AccessWidth = access_width,
+ .Address = htole64(address),
+ };
+
+ return (basl_table_append_bytes(table, &gas_le, sizeof(gas_le)));
+}
+
+int
+basl_table_append_header(struct basl_table *const table,
+ const uint8_t signature[ACPI_NAMESEG_SIZE], const uint8_t revision,
+ const uint32_t oem_revision)
+{
+ ACPI_TABLE_HEADER header_le;
+ /* + 1 is required for the null terminator */
+ char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1];
+
+ assert(table != NULL);
+ assert(table->len == 0);
+
+ memcpy(header_le.Signature, signature, ACPI_NAMESEG_SIZE);
+ header_le.Length = 0; /* patched by basl_finish */
+ header_le.Revision = revision;
+ header_le.Checksum = 0; /* patched by basl_finish */
+ memcpy(header_le.OemId, "BHYVE ", ACPI_OEM_ID_SIZE);
+ snprintf(oem_table_id, ACPI_OEM_TABLE_ID_SIZE, "BV%.4s ", signature);
+ memcpy(header_le.OemTableId, oem_table_id,
+ sizeof(header_le.OemTableId));
+ header_le.OemRevision = htole32(oem_revision);
+ memcpy(header_le.AslCompilerId, "BASL", ACPI_NAMESEG_SIZE);
+ header_le.AslCompilerRevision = htole32(0x20220504);
+
+ BASL_EXEC(
+ basl_table_append_bytes(table, &header_le, sizeof(header_le)));
+
+ BASL_EXEC(basl_table_add_length(table,
+ offsetof(ACPI_TABLE_HEADER, Length), sizeof(header_le.Length)));
+ BASL_EXEC(basl_table_add_checksum(table,
+ offsetof(ACPI_TABLE_HEADER, Checksum), 0,
+ BASL_TABLE_CHECKSUM_LEN_FULL_TABLE));
+
+ return (0);
+}
+
+int
+basl_table_append_int(struct basl_table *const table, const uint64_t val,
+ const uint8_t size)
+{
+ char buf[8];
+
+ assert(size <= sizeof(val));
+
+ basl_le_enc(buf, val, size);
+ return (basl_table_append_bytes(table, buf, size));
+}
+
+int
+basl_table_append_length(struct basl_table *const table, const uint8_t size)
+{
+ assert(table != NULL);
+ assert(size <= sizeof(table->len));
+
+ BASL_EXEC(basl_table_add_length(table, table->len, size));
+ BASL_EXEC(basl_table_append_int(table, 0, size));
+
+ return (0);
+}
+
+int
+basl_table_append_pointer(struct basl_table *const table,
+ const uint8_t src_signature[ACPI_NAMESEG_SIZE], const uint8_t size)
+{
+ assert(table != NULL);
+ assert(size == 4 || size == 8);
+
+ BASL_EXEC(basl_table_add_pointer(table, src_signature, table->len, size));
+ BASL_EXEC(basl_table_append_int(table, 0, size));
+
+ return (0);
+}
+
+int
+basl_table_create(struct basl_table **const table, struct vmctx *ctx,
+ const uint8_t *const name, const uint32_t alignment)
+{
+ struct basl_table *new_table;
+
+ assert(table != NULL);
+
+ new_table = calloc(1, sizeof(struct basl_table));
+ if (new_table == NULL) {
+ warnx("%s: failed to allocate table", __func__);
+ return (ENOMEM);
+ }
+
+ new_table->ctx = ctx;
+
+ snprintf(new_table->fwcfg_name, sizeof(new_table->fwcfg_name),
+ "etc/acpi/%s", name);
+
+ new_table->alignment = alignment;
+
+ STAILQ_INIT(&new_table->checksums);
+ STAILQ_INIT(&new_table->lengths);
+ STAILQ_INIT(&new_table->pointers);
+
+ STAILQ_INSERT_TAIL(&basl_tables, new_table, chain);
+
+ *table = new_table;
+
+ return (0);
+}
+
+int
+basl_table_register_to_rsdt(struct basl_table *table)
+{
+ const ACPI_TABLE_HEADER *header;
+
+ assert(table != NULL);
+
+ header = (const ACPI_TABLE_HEADER *)table->data;
+
+ BASL_EXEC(basl_table_append_pointer(rsdt, header->Signature,
+ ACPI_RSDT_ENTRY_SIZE));
+ BASL_EXEC(basl_table_append_pointer(xsdt, header->Signature,
+ ACPI_XSDT_ENTRY_SIZE));
+
+ return (0);
+}
diff --git a/usr.sbin/bhyve/basl.h b/usr.sbin/bhyve/basl.h
new file mode 100644
index 000000000000..62502be22e13
--- /dev/null
+++ b/usr.sbin/bhyve/basl.h
@@ -0,0 +1,101 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 Beckhoff Automation GmbH & Co. KG
+ */
+
+#pragma once
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#include <contrib/dev/acpica/include/acpi.h>
+#pragma GCC diagnostic pop
+
+#include "qemu_fwcfg.h"
+
+#define ACPI_GAS_ACCESS_WIDTH_LEGACY 0
+#define ACPI_GAS_ACCESS_WIDTH_UNDEFINED 0
+#define ACPI_GAS_ACCESS_WIDTH_BYTE 1
+#define ACPI_GAS_ACCESS_WIDTH_WORD 2
+#define ACPI_GAS_ACCESS_WIDTH_DWORD 3
+#define ACPI_GAS_ACCESS_WIDTH_QWORD 4
+
+#define ACPI_SPCR_INTERRUPT_TYPE_8259 0x1
+#define ACPI_SPCR_INTERRUPT_TYPE_APIC 0x2
+#define ACPI_SPCR_INTERRUPT_TYPE_SAPIC 0x4
+#define ACPI_SPCR_INTERRUPT_TYPE_GIC 0x8
+
+#define ACPI_SPCR_BAUD_RATE_9600 3
+#define ACPI_SPCR_BAUD_RATE_19200 4
+#define ACPI_SPCR_BAUD_RATE_57600 6
+#define ACPI_SPCR_BAUD_RATE_115200 7
+
+#define ACPI_SPCR_PARITY_NO_PARITY 0
+
+#define ACPI_SPCR_STOP_BITS_1 1
+
+#define ACPI_SPCR_FLOW_CONTROL_DCD 0x1
+#define ACPI_SPCR_FLOW_CONTROL_RTS_CTS 0x2
+#define ACPI_SPCR_FLOW_CONTROL_XON_XOFF 0x4
+
+#define ACPI_SPCR_TERMINAL_TYPE_VT100 0
+#define ACPI_SPCR_TERMINAL_TYPE_VT100_PLUS 1
+#define ACPI_SPCR_TERMINAL_TYPE_VT_UTF8 2
+#define ACPI_SPCR_TERMINAL_TYPE_ANSI 3
+
+#define BHYVE_ACPI_BASE 0xf2400
+
+#define BASL_TABLE_ALIGNMENT 0x10
+#define BASL_TABLE_ALIGNMENT_FACS 0x40
+
+#define BASL_TABLE_CHECKSUM_LEN_FULL_TABLE (-1U)
+
+#define BASL_EXEC(x) \
+ do { \
+ const int error = (x); \
+ if (error) { \
+ warnc(error, \
+ "BASL failed @ %s:%d\n Failed to execute %s", \
+ __func__, __LINE__, #x); \
+ return (error); \
+ } \
+ } while (0)
+
+struct basl_table;
+
+void basl_fill_gas(ACPI_GENERIC_ADDRESS *gas, uint8_t space_id,
+ uint8_t bit_width, uint8_t bit_offset, uint8_t access_width,
+ uint64_t address);
+int basl_finish(void);
+int basl_init(struct vmctx *ctx);
+int basl_table_add_checksum(struct basl_table *const table, const uint32_t off,
+ const uint32_t start, const uint32_t len);
+int basl_table_add_length(struct basl_table *const table, const uint32_t off,
+ const uint8_t size);
+int basl_table_add_pointer(struct basl_table *const table,
+ const uint8_t src_signature[ACPI_NAMESEG_SIZE], const uint32_t off,
+ const uint8_t size);
+int basl_table_append_bytes(struct basl_table *table, const void *bytes,
+ uint32_t len);
+int basl_table_append_checksum(struct basl_table *table, uint32_t start,
+ uint32_t len);
+/* Add an ACPI_TABLE_* to basl without its header. */
+int basl_table_append_content(struct basl_table *table, void *data,
+ uint32_t len);
+int basl_table_append_fwcfg(struct basl_table *table,
+ const uint8_t *fwcfg_name, uint32_t alignment,
+ uint8_t size);
+int basl_table_append_gas(struct basl_table *table, uint8_t space_id,
+ uint8_t bit_width, uint8_t bit_offset, uint8_t access_width,
+ uint64_t address);
+int basl_table_append_header(struct basl_table *table,
+ const uint8_t signature[ACPI_NAMESEG_SIZE], uint8_t revision,
+ uint32_t oem_revision);
+int basl_table_append_int(struct basl_table *table, uint64_t val, uint8_t size);
+int basl_table_append_length(struct basl_table *table, uint8_t size);
+int basl_table_append_pointer(struct basl_table *table,
+ const uint8_t src_signature[ACPI_NAMESEG_SIZE], uint8_t size);
+int basl_table_create(struct basl_table **table, struct vmctx *ctx,
+ const uint8_t *name, uint32_t alignment);
+/* Adds the table to RSDT and XSDT */
+int basl_table_register_to_rsdt(struct basl_table *table);
diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8
index 92534d226499..12e3f3ba926e 100644
--- a/usr.sbin/bhyve/bhyve.8
+++ b/usr.sbin/bhyve/bhyve.8
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd November 28, 2021
+.Dd December 29, 2023
.Dt BHYVE 8
.Os
.Sh NAME
@@ -45,6 +43,15 @@
.Op Cm ,threads= Ar n
.Oc
.Sm on
+.Oo Fl f
+.Sm off
+.Ar name Cm \&,
+.Oo
+.Cm string No | Cm file
+.Oc
+.Cm \&= Ar data
+.Sm on
+.Oc
.Oo
.Sm off
.Fl G\~
@@ -105,9 +112,7 @@ exit is detected.
.Bl -tag -width 10n
.It Fl A
Generate ACPI tables.
-Required for
-.Fx Ns /amd64
-guests.
+bhyve always generates ACPI tables so this option is obsolete.
.It Fl a
The guest's local APIC is configured in xAPIC mode.
The xAPIC mode is the default setting so this option is redundant.
@@ -124,7 +129,6 @@ The default value for each of
and
.Ar threads
is 1.
-The current maximum number of guest virtual CPUs is 16.
If
.Ar numcpus
is not specified then it will be calculated from the other arguments.
@@ -138,6 +142,15 @@ and
If a
.Ar setting
is specified more than once the last one has precedence.
+.Pp
+The maximum number of virtual CPUs defaults to the number of active
+physical CPUs in the system available via the
+.Va hw.vmm.maxcpu
+.Xr sysctl 8
+variable.
+The limit can be adjusted via the
+.Va hw.vmm.maxcpu
+loader tunable.
.It Fl D
Destroy the VM on guest initiated power-off.
.It Fl e
@@ -145,6 +158,16 @@ Force
.Nm
to exit when a guest issues an access to an I/O port that is not emulated.
This is intended for debug purposes.
+.It Fl f Ar name Ns Cm \&, Ns Oo Cm string Ns No | Ns Cm file Ns Oc Ns Cm \&= Ns Ar data
+Add a fw_cfg file
+.Ar name
+to the fw_cfg interface.
+If a
+.Cm string
+is specified, the fw_cfg file contains the string as data.
+If a
+.Cm file
+is specified, bhyve reads the file and adds the file content as fw_cfg data.
.It Fl G Xo
.Sm off
.Oo Ar w Oc
@@ -173,13 +196,6 @@ Print help message and exit.
Set configuration variables from a simple, key-value config file.
Each line of the config file is expected to consist of a config variable
name, an equals sign
-.It Fl K Ar layout
-Specify the keyboard layout.
-The value that can be specified sets the file name in
-.Ar /usr/share/bhyve/kbdlayout .
-This specification only works when loaded with UEFI mode for VNC.
-When using a VNC client that supports QEMU Extended Key Event Message (e.g. TigerVNC), this option isn't needed.
-When using a VNC client that doesn't support QEMU Extended Key Event Message (e.g. tightVNC), the layout defaults to the US keyboard unless specified otherwise.
.Pq Sq = ,
and a value.
No spaces are permitted between the variable name, equals sign, or
@@ -190,6 +206,16 @@ are ignored.
See
.Xr bhyve_config 5
for more details.
+.It Fl K Ar layout
+Specify the keyboard layout.
+The value that can be specified sets the file name in
+.Ar /usr/share/bhyve/kbdlayout .
+This specification only works when loaded with UEFI mode for VNC.
+When using a VNC client that supports QEMU Extended Key Event Message (e.g.
+TigerVNC), this option isn't needed.
+When using a VNC client that doesn't support QEMU Extended Key Event Message
+(e.g. tightVNC), the layout defaults to the US keyboard unless specified
+otherwise.
.It Fl l Cm help
Print a list of supported LPC devices.
.It Fl l Ar lpcdev Ns Op Cm \&, Ns Ar conf
@@ -198,9 +224,13 @@ The only supported devices are the TTY-class devices
.Cm com1 , com2 , com3 ,
and
.Cm com4 ,
+the TPM module
+.Cm tpm ,
the boot ROM device
.Cm bootrom ,
-and the debug/test device
+the
+.Cm fwcfg
+type and the debug/test device
.Cm pc-testdev .
.Pp
The possible values for the
@@ -215,7 +245,7 @@ flag description.
.Sm on
.Oc
.Xc
-Set the guest physical memory size
+Set the guest physical memory size.
This must be the same size that was given to
.Xr bhyveload 8 .
.Pp
@@ -240,6 +270,14 @@ Pin guest's virtual CPU
.Em vcpu
to
.Em hostcpu .
+Host CPUs and guest virtual CPUs are numbered starting from 0.
+A
+.Fl p
+option is required for every guest vCPU to be pinned.
+To map a 4 vCPU guest to host CPUs 12-15:
+.Bd -literal
+-p 0:12 -p 1:13 -p 2:14 -p 3:15
+.Ed
.It Fl r Ar file
Resume a guest from a snapshot.
The guest memory contents are restored from
@@ -247,9 +285,9 @@ The guest memory contents are restored from
and the guest device and vCPU state are restored from the file
.Dq Ar file Ns .kern .
.Pp
-Note that the current snapshot file format requires that the configuration of
-devices in the new VM match the VM from which the snapshot was taken by specifying the
-same
+Note that the current snapshot file format requires that the
+configuration of devices in the new VM match the VM from which the
+snapshot was taken by specifying the same
.Fl s
and
.Fl l
@@ -345,7 +383,7 @@ PCI 16550 serial device.
.It Cm lpc
LPC PCI-ISA bridge with COM1, COM2, COM3, and COM4 16550 serial ports,
a boot ROM, and,
-optionally, the debug/test device.
+optionally, a fwcfg type and the debug/test device.
The LPC bridge emulation can only be configured on bus 0.
.It Cm fbuf
Raw framebuffer device attached to VNC server.
@@ -388,8 +426,13 @@ Network device backends:
.Op Cm \&,mac= Ar xx:xx:xx:xx:xx:xx
.Op Cm \&,mtu= Ar N
.Xc
+.It
+.Xo
+.Cm slirp,hostfwd= Ar proto : Ar hostaddr : Ar hostport - Ar guestaddr : Ar guestport
+.Xc
.El
.Sm on
+.Pp
If
.Cm mac
is not specified, the MAC address is derived from a fixed OUI and the
@@ -430,6 +473,20 @@ must comply with
.Xr netgraph 4
addressing rules.
.Pp
+The slirp backend can be used to provide a NATed network to the guest.
+This backend has poor performance but does not require any network
+configuration on the host system.
+It depends on the
+.Pa net/libslirp
+port.
+The
+.Cm hostfwd
+option takes a 5-tuple describing how connections from the host are to be
+forwarded to the guest.
+Multiple rules can be specified, separated by semicolons.
+Note that semicolons must be escaped or quoted to prevent the shell from
+interpreting them.
+.Pp
Block storage device backends:
.Sm off
.Bl -bullet
@@ -460,6 +517,12 @@ if not explicitly specified.
Disable emulation of guest trim requests via
.Dv DIOCGDELETE
requests.
+.It Li bootindex= Ns Ar index
+Add the device to the bootorder at
+.Ar index .
+A fwcfg file is used to specify the bootorder.
+The guest firmware may ignore or doesn't support this fwcfg file.
+In that case, this feature doesn't work as expected.
.El
.Pp
SCSI device backends:
@@ -477,6 +540,12 @@ are:
.It Cm iid= Ns Ar IID
Initiator ID to use when sending requests to specified CTL port.
The default value is 0.
+.It Li bootindex= Ns Ar index
+Add the device to the bootorder at
+.Ar index .
+A fwcfg file is used to specify the bootorder.
+The guest firmware may ignore or doesn't support this fwcfg file.
+In that case, this feature doesn't work as expected.
.El
.Pp
9P device backends:
@@ -506,6 +575,22 @@ process.
Use the host TTY device for serial port I/O.
.El
.Pp
+TPM device backends:
+.Bl -tag -width 10n
+.It Ar type Ns \&, Ns Ar path Ns Op Cm \&, Ns Ar tpm-device-options
+Emulate a TPM device.
+.El
+.Pp
+The
+.Ar tpm-device-options
+are:
+.Bl -tag -width 10n
+.It Cm version= Ns Ar version
+Version of the TPM device according to the TCG specification.
+Defaults to
+.Cm 2.0
+.El
+.Pp
Boot ROM device backends:
.Bl -tag -width 10n
.It Ar romfile Ns Op Cm \&, Ns Ar varfile
@@ -519,20 +604,72 @@ address space, and any modifications the guest makes will be saved
to that file.
.El
.Pp
-Pass-through device backends:
+Fwcfg types:
.Bl -tag -width 10n
-.It Ns Ar slot Ns Cm \&/ Ns Ar bus Ns Cm \&/ Ns Ar function
-Connect to a PCI device on the host at the selector described by
+.It Ar fwcfg
+The fwcfg interface is used to pass information such as the CPU count
+or ACPI tables to the guest firmware.
+Supported values are
+.Ql bhyve
+and
+.Ql qemu .
+Due to backward compatibility reasons,
+.Ql bhyve
+is the default option.
+When
+.Ql bhyve
+is used, bhyve's fwctl interface is used.
+It currently reports only the CPU count to the guest firmware.
+The
+.Ql qemu
+option uses QEMU's fwcfg interface.
+This interface is widely used and allows user-defined information to
+be passed to the guest.
+It is used for passing the CPU count, ACPI tables, a boot order and
+many other things to the guest.
+Some operating systems such as Fedora CoreOS can be configured by
+qemu's fwcfg interface as well.
+.El
+.Pp
+Pass-through device backends:
+.Sm off
+.Bl -bullet
+.It
+.Cm ppt Ar N Oo , Ar passthru-device-options Oc
+.It
+.Ns Ar bus Cm \&/ Ar slot Cm \&/ Ar function
+.Op , Ar passthru-device-options
+.It
+.Cm pci Ar bus Cm : Ar slot Cm : Ns Ar function
+.Op , Ar passthru-device-options
+.El
+.Sm on
+.Pp
+Connect to a PCI device on the host either named ppt
+.Ns Ar N
+or at the selector described by
.Ar slot ,
.Ar bus ,
and
.Ar function
numbers.
+.Pp
+The
+.Ar passthru-device-options
+are:
+.Bl -tag -width 10n
.It Cm rom= Ns Ar romfile
Add
.Ar romfile
as option ROM to the PCI device.
-The ROM will be loaded by firmware and should be capable of initializing the device.
+The ROM will be loaded by firmware and should be capable of
+initializing the device.
+.It Li bootindex= Ns Ar index
+Add the device to the bootorder at
+.Ar index .
+A fwcfg file is used to specify the bootorder.
+The guest firmware may ignore or doesn't support this fwcfg file.
+In that case, this feature doesn't work as expected.
.El
.Pp
Guest memory must be wired using the
@@ -544,6 +681,26 @@ The host device must have been reserved at boot-time using the
loader variable as described in
.Xr vmm 4 .
.Pp
+TPM devices:
+.Bl -tag -width 10n
+.It Ns Ar type
+Specifies the type of the TPM device.
+.Pp
+Supported types:
+.Bl -tag -width 10n
+.It Cm passthru
+.El
+.It Cm version= Ns Ar version
+The
+.Ar version
+of the emulated TPM device according to the TCG specification.
+.Pp
+Supported versions:
+.Bl -tag -width 10n
+.It Cm 2.0
+.El
+.El
+.Pp
Virtio console device backends:
.Bl -bullet
.Sm off
@@ -621,7 +778,7 @@ optional zone identifier.
A display resolution, width and height, respectively.
If not specified, a default resolution of 1024x768 pixels will be used.
Minimal supported resolution is 640x480 pixels,
-and maximum is 1920x1200 pixels.
+and maximum is 3840x2160 pixels.
.It Cm vga= Ns Ar vgaconf
Possible values for this option are
.Cm io
@@ -825,9 +982,10 @@ Each virtual CPU is exposed to the debugger as a thread.
General purpose registers can be queried for each virtual CPU, but other
registers such as floating-point and system registers cannot be queried.
.Ss Memory
-Memory (including memory mapped I/O regions) can be read and written by the debugger.
-Memory operations use virtual addresses that are resolved to physical addresses
-via the current virtual CPU's active address translation.
+Memory (including memory mapped I/O regions) can be read and written
+by the debugger.
+Memory operations use virtual addresses that are resolved to physical
+addresses via the current virtual CPU's active address translation.
.Ss Control
The running guest can be interrupted by the debugger at any time
.Pq for example, by pressing Ctrl-C in the debugger .
@@ -944,7 +1102,7 @@ Be sure to create a per-guest copy of the template VARS file from
.Bd -literal -offset indent
bhyve -c 2 -m 4g -w -H \\
-s 0,hostbridge \\
- -s 31,lpc -p com1,stdio \\
+ -s 31,lpc -l com1,stdio \\
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CODE.fd,BHYVE_UEFI_VARS.fd
uefivm
.Ed
diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5
index bdf12d0aae16..d0e5c8ae47d3 100644
--- a/usr.sbin/bhyve/bhyve_config.5
+++ b/usr.sbin/bhyve/bhyve_config.5
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 2, 2022
+.Dd November 20, 2023
.Dt BHYVE_CONFIG 5
.Os
.Sh NAME
@@ -120,8 +120,15 @@ The value must be formatted as described in
.Xr expand_number 3 .
.It Va memory.wired Ta bool Ta false Ta
Wire guest memory.
-.It Va acpi_tables Ta bool Ta false Ta
+.It Va acpi_tables Ta bool Ta true Ta
Generate ACPI tables.
+.It Va acpi_tables_in_memory Ta bool Ta true Ta
+.Xr bhyve 8
+always exposes ACPI tables by FwCfg.
+For backward compatibility bhyve copies them into the guest memory as well.
+This can cause problems if the guest uses the in-memory version, since certain
+advanced features, such as TPM emulation, are exposed only via FwCfg.
+Therefore, it is recommended to set this flag to false when running Windows guests.
.It Va destroy_on_poweroff Ta bool Ta false Ta
Destroy the VM on guest-initiated power-off.
.It Va gdb.address Ta string Ta localhost Ta
@@ -139,6 +146,15 @@ Specify the keyboard layout name with the file name in
This value only works when loaded with UEFI mode for VNC, and
used a VNC client that don't support QEMU Extended Key Event
Message (e.g. TightVNC).
+.It Va tpm.path Ta string Ta Ta
+Path to the host TPM device.
+This is typically /dev/tpm0.
+.It Va tpm.type Ta string Ta Ta
+Type of the TPM device passed to the guest.
+Currently, only "passthru" is supported.
+.It Va tpm.version Ta string Ta 2.0 Ta
+Version of the TPM device according to the TCG specification.
+Currently, only version 2.0 is supported.
.It Va rtc.use_localtime Ta bool Ta true Ta
The real time clock uses the local time of the host.
If this is set to false, the real time clock uses UTC.
@@ -158,6 +174,52 @@ then
.Xr bhyve 8
will write all of its configuration variables to stdout and exit.
No VM will be started.
+.It Va bios.vendor Ta string Ta BHYVE Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va bios.version Ta string Ta 14.0 Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va bios.release_date Ta string Ta 10/17/2021 Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.family_name Ta string Ta Virtual Machine Ta
+Family the computer belongs to.
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.manufacturer Ta string Ta FreeBSD Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.product_name Ta string Ta BHYVE Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.serial_number Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.sku Ta string Ta None Ta
+Stock keeping unit of the computer.
+It's also called product ID or purchase order number.
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va system.version Ta string Ta 1.0 Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.manufacturer Ta string Ta FreeBSD Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.product_name Ta string Ta BHYVE Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.version Ta string Ta 1.0 Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.serial_number Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.asset_tag Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va board.location Ta string Ta None Ta
+Describes the board's location within the chassis.
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va chassis.manufacturer Ta string Ta FreeBSD Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va chassis.version Ta string Ta 1.0 Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va chassis.serial_number Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va chassis.asset_tag Ta string Ta None Ta
+This value is used for the guest's System Management BIOS System Information structure.
+.It Va chassis.sku Ta string Ta None Ta
+Stock keeping unit of the chassis.
+It's also called product ID or purchase order number.
+This value is used for the guest's System Management BIOS System Information structure.
.El
.Ss x86-Specific Settings
.Bl -column "x86.vmexit_on_pause" "integer" "Default"
@@ -213,6 +275,7 @@ VGA framebuffer device attached to VNC server.
.It Li lpc
LPC PCI-ISA bridge with COM1-COM4 16550 serial ports,
a boot ROM,
+an optional fwcfg type,
and an optional debug/test device.
This device must be configured on bus 0.
.It Li hda
@@ -290,16 +353,21 @@ The backend is responsible for passing packets between the device model
and a desired destination.
Configuring a backend requires setting the
.Va backend
-variable to one of the following values:
-.Bl -tag
-.It tap Ns Va N
-Use the named
+variable.
+The type of a backend can either be set explicitly via the
+.Va type
+variable
+or it can be inferred from the value of
+.Va backend .
+.Pp
+The following types of backends are supported:
+.Bl -tag -width "netgraph"
+.It tap
+Use the
.Xr tap 4
-interface as the backend.
-.It vmnet Ns Va N
-Use the named
-.Xr vmnet 4
-interface as the backend.
+interface named in
+.Va backend
+as the backend.
.It netgraph
Use a
.Xr netgraph 4
@@ -322,14 +390,51 @@ The name of the source hook on the created
.Xr ng_socket 4
node.
.El
-.It netmap: Ns Va interface
+.It netmap
Use
.Xr netmap 4
-on a network interface as the backend.
-.It vale Ns Va bridge : Ns Va port
-Use a port on a
+either on a network interface or a port on a
.Xr vale 4
bridge as the backend.
+The value of
+.Va backend
+is passed to
+.Xr nm_open
+to connect to a netmap port.
+.It slirp
+Use the slirp backend to provide a userspace network stack.
+The
+.Va hostfwd
+variable is used to configure how packets from the host are translated
+before being sent to the guest.
+.Bl -column "peerhook" "Format" "Default"
+.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description
+.It Va hostfwd Ta string Ta Ta
+A semicolon-separated list of host forwarding rules, each of the form
+.Ar proto:haddr:hport-gaddr:gport ,
+where
+.Ar proto
+is either
+.Ql tcp
+or
+.Ql udp .
+If the guest address is equal to the empty string, packets will be
+forwarded to the first DHCP-assigned address in the guest.
+.El
+.El
+.Pp
+If
+.Va type
+is not specified explicitly, then it is inferred from
+.Va backend
+based on the following patterns:
+.Bl -column -offset indent "valuebridge:port"
+.It Sy Pattern Ta Sy Type
+.It tap Ns Va N Ta tap
+.It vmnet Ns Va N Ta tap
+.It netgraph Ta netgraph
+.It netmap: Ns Va interface Ta netmap
+.It vale Ns Va bridge : Ns Va port Ta netmap
.El
.Ss UART Device Settings
.Bl -column "Name" "Format" "Default"
@@ -343,12 +448,15 @@ to use standard input and output of the
process.
.El
.Ss Host Bridge Settings
-.Bl -column "vendor" "integer" "Default"
+.Bl -column "pcireg.*" "integer" "Default"
.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description
+.It Va pcireg.* Ta integer Ta Ta
+Values of PCI register.
+.Bl -column "device" "Default"
+.It Sy Name Ta Sy Default
.It Va vendor Ta integer Ta 0x1275 Ta
-PCI vendor ID.
-.It Va devid Ta integer Ta 0x1275 Ta
-PCI device ID.
+.It Va device Ta integer Ta 0x1275 Ta
+.El
.El
.Ss AHCI Controller Settings
AHCI controller devices contain zero or more ports each of which
@@ -461,8 +569,29 @@ Settings for the COM2 serial port device.
Settings for the COM3 serial port device.
.It Va com4 Ta node Ta Ta
Settings for the COM4 serial port device.
+.It Va fwcfg Ta string Ta bhyve Ta
+The fwcfg type to be used.
+Supported values are
+.Dq bhyve
+for fwctl and
+.Dq qemu
+for fwcfg.
.It Va pc-testdev Ta bool Ta false Ta
Enable the PC debug/test device.
+.It Va pcireg.* Ta integer Ta Ta
+Values of PCI register.
+It also accepts the value
+.Ar host
+to use the pci id of the host system.
+This value is required for the Intel GOP driver to work properly.
+.Bl -column "subvendor" "Default"
+.It Sy Name Ta Sy Default
+.It Va vendor Ta 0x8086
+.It Va device Ta 0x7000
+.It Va revid Ta 0
+.It Va subvendor Ta 0
+.It Va subdevice Ta 0
+.El
.El
.Ss NVMe Controller Settings
Each NVMe controller supports a single storage device.
@@ -507,6 +636,12 @@ If set, allocate a memory disk as the backing store.
The value of this variable is the size of the memory disk in megabytes.
.El
.Ss PCI Passthrough Settings
+The
+.Xr ppt 4
+device driver must be attached to the
+PCI device being passed through.
+The device to pass through can be identified either by name or its
+host PCI bus location.
.Bl -column "Name" "integer" "Default"
.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description
.It Va bus Ta integer Ta Ta
@@ -515,6 +650,10 @@ Host PCI bus address of device to pass through.
Host PCI slot address of device to pass through.
.It Va func Ta integer Ta Ta
Host PCI function address of device to pass through.
+.It Va pptdev Ta string Ta Ta
+Name of a
+.Xr ppt 4
+device to pass through.
.It Va rom Ta path Ta Ta
ROM file of the device which will be executed by OVMF to init the device.
.El
diff --git a/usr.sbin/bhyve/bhyvegc.c b/usr.sbin/bhyve/bhyvegc.c
index 4bd49ded7970..860a4b115eb1 100644
--- a/usr.sbin/bhyve/bhyvegc.c
+++ b/usr.sbin/bhyve/bhyvegc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <stdlib.h>
diff --git a/usr.sbin/bhyve/bhyvegc.h b/usr.sbin/bhyve/bhyvegc.h
index 11323586dfaf..5344473a05bd 100644
--- a/usr.sbin/bhyve/bhyvegc.h
+++ b/usr.sbin/bhyve/bhyvegc.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* 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 _BHYVEGC_H_
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index a412785f5a01..1c3b810efb02 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/types.h>
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
@@ -45,10 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/un.h>
#endif
-#include <amd64/vmm/intel/vmcs.h>
-
#include <machine/atomic.h>
-#include <machine/segments.h>
#ifndef WITHOUT_CAPSICUM
#include <capsicum_helpers.h>
@@ -76,189 +68,52 @@ __FBSDID("$FreeBSD$");
#include <libxo/xo.h>
#endif
-#include <machine/vmm.h>
-#ifndef WITHOUT_CAPSICUM
-#include <machine/vmm_dev.h>
-#endif
-#include <machine/vmm_instruction_emul.h>
#include <vmmapi.h>
-#include "bhyverun.h"
#include "acpi.h"
-#include "atkbdc.h"
+#include "bhyverun.h"
#include "bootrom.h"
#include "config.h"
-#include "inout.h"
#include "debug.h"
-#include "fwctl.h"
+#ifdef BHYVE_GDB
#include "gdb.h"
-#include "ioapic.h"
-#include "kernemu_dev.h"
+#endif
#include "mem.h"
#include "mevent.h"
-#include "mptbl.h"
#include "pci_emul.h"
-#include "pci_irq.h"
-#include "pci_lpc.h"
-#include "smbiostbl.h"
+#ifdef __amd64__
+#include "amd64/pci_lpc.h"
+#endif
+#include "qemu_fwcfg.h"
#ifdef BHYVE_SNAPSHOT
#include "snapshot.h"
#endif
-#include "xmsr.h"
-#include "spinup_ap.h"
-#include "rtc.h"
+#include "tpm_device.h"
#include "vmgenc.h"
-
-#define GUEST_NIO_PORT 0x488 /* guest upcalls via i/o port */
+#include "vmexit.h"
#define MB (1024UL * 1024)
#define GB (1024UL * MB)
-static const char * const vmx_exit_reason_desc[] = {
- [EXIT_REASON_EXCEPTION] = "Exception or non-maskable interrupt (NMI)",
- [EXIT_REASON_EXT_INTR] = "External interrupt",
- [EXIT_REASON_TRIPLE_FAULT] = "Triple fault",
- [EXIT_REASON_INIT] = "INIT signal",
- [EXIT_REASON_SIPI] = "Start-up IPI (SIPI)",
- [EXIT_REASON_IO_SMI] = "I/O system-management interrupt (SMI)",
- [EXIT_REASON_SMI] = "Other SMI",
- [EXIT_REASON_INTR_WINDOW] = "Interrupt window",
- [EXIT_REASON_NMI_WINDOW] = "NMI window",
- [EXIT_REASON_TASK_SWITCH] = "Task switch",
- [EXIT_REASON_CPUID] = "CPUID",
- [EXIT_REASON_GETSEC] = "GETSEC",
- [EXIT_REASON_HLT] = "HLT",
- [EXIT_REASON_INVD] = "INVD",
- [EXIT_REASON_INVLPG] = "INVLPG",
- [EXIT_REASON_RDPMC] = "RDPMC",
- [EXIT_REASON_RDTSC] = "RDTSC",
- [EXIT_REASON_RSM] = "RSM",
- [EXIT_REASON_VMCALL] = "VMCALL",
- [EXIT_REASON_VMCLEAR] = "VMCLEAR",
- [EXIT_REASON_VMLAUNCH] = "VMLAUNCH",
- [EXIT_REASON_VMPTRLD] = "VMPTRLD",
- [EXIT_REASON_VMPTRST] = "VMPTRST",
- [EXIT_REASON_VMREAD] = "VMREAD",
- [EXIT_REASON_VMRESUME] = "VMRESUME",
- [EXIT_REASON_VMWRITE] = "VMWRITE",
- [EXIT_REASON_VMXOFF] = "VMXOFF",
- [EXIT_REASON_VMXON] = "VMXON",
- [EXIT_REASON_CR_ACCESS] = "Control-register accesses",
- [EXIT_REASON_DR_ACCESS] = "MOV DR",
- [EXIT_REASON_INOUT] = "I/O instruction",
- [EXIT_REASON_RDMSR] = "RDMSR",
- [EXIT_REASON_WRMSR] = "WRMSR",
- [EXIT_REASON_INVAL_VMCS] =
- "VM-entry failure due to invalid guest state",
- [EXIT_REASON_INVAL_MSR] = "VM-entry failure due to MSR loading",
- [EXIT_REASON_MWAIT] = "MWAIT",
- [EXIT_REASON_MTF] = "Monitor trap flag",
- [EXIT_REASON_MONITOR] = "MONITOR",
- [EXIT_REASON_PAUSE] = "PAUSE",
- [EXIT_REASON_MCE_DURING_ENTRY] =
- "VM-entry failure due to machine-check event",
- [EXIT_REASON_TPR] = "TPR below threshold",
- [EXIT_REASON_APIC_ACCESS] = "APIC access",
- [EXIT_REASON_VIRTUALIZED_EOI] = "Virtualized EOI",
- [EXIT_REASON_GDTR_IDTR] = "Access to GDTR or IDTR",
- [EXIT_REASON_LDTR_TR] = "Access to LDTR or TR",
- [EXIT_REASON_EPT_FAULT] = "EPT violation",
- [EXIT_REASON_EPT_MISCONFIG] = "EPT misconfiguration",
- [EXIT_REASON_INVEPT] = "INVEPT",
- [EXIT_REASON_RDTSCP] = "RDTSCP",
- [EXIT_REASON_VMX_PREEMPT] = "VMX-preemption timer expired",
- [EXIT_REASON_INVVPID] = "INVVPID",
- [EXIT_REASON_WBINVD] = "WBINVD",
- [EXIT_REASON_XSETBV] = "XSETBV",
- [EXIT_REASON_APIC_WRITE] = "APIC write",
- [EXIT_REASON_RDRAND] = "RDRAND",
- [EXIT_REASON_INVPCID] = "INVPCID",
- [EXIT_REASON_VMFUNC] = "VMFUNC",
- [EXIT_REASON_ENCLS] = "ENCLS",
- [EXIT_REASON_RDSEED] = "RDSEED",
- [EXIT_REASON_PM_LOG_FULL] = "Page-modification log full",
- [EXIT_REASON_XSAVES] = "XSAVES",
- [EXIT_REASON_XRSTORS] = "XRSTORS"
-};
-
-typedef int (*vmexit_handler_t)(struct vmctx *, struct vm_exit *, int *vcpu);
-extern int vmexit_task_switch(struct vmctx *, struct vm_exit *, int *vcpu);
-
int guest_ncpus;
-uint16_t cores, maxcpus, sockets, threads;
+uint16_t cpu_cores, cpu_sockets, cpu_threads;
int raw_stdio = 0;
-static char *progname;
static const int BSP = 0;
static cpuset_t cpumask;
-static void vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip);
+static void vm_loop(struct vmctx *ctx, struct vcpu *vcpu);
-static struct vm_exit *vmexit;
-
-struct bhyvestats {
- uint64_t vmexit_bogus;
- uint64_t vmexit_reqidle;
- uint64_t vmexit_hlt;
- uint64_t vmexit_pause;
- uint64_t vmexit_mtrap;
- uint64_t vmexit_inst_emul;
- uint64_t cpu_switch_rotate;
- uint64_t cpu_switch_direct;
-} stats;
-
-struct mt_vmm_info {
- pthread_t mt_thr;
- struct vmctx *mt_ctx;
- int mt_vcpu;
-} *mt_vmm_info;
+static struct vcpu_info {
+ struct vmctx *ctx;
+ struct vcpu *vcpu;
+ int vcpuid;
+} *vcpu_info;
static cpuset_t **vcpumap;
-static void
-usage(int code)
-{
-
- fprintf(stderr,
- "Usage: %s [-AaCDeHhPSuWwxY]\n"
- " %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n"
- " %*s [-G port] [-k config_file] [-l lpc] [-m mem] [-o var=value]\n"
- " %*s [-p vcpu:hostcpu] [-r file] [-s pci] [-U uuid] vmname\n"
- " -A: create ACPI tables\n"
- " -a: local apic is in xAPIC mode (deprecated)\n"
- " -C: include guest memory in core file\n"
- " -c: number of CPUs and/or topology specification\n"
- " -D: destroy on power-off\n"
- " -e: exit on unhandled I/O access\n"
- " -G: start a debug server\n"
- " -H: vmexit from the guest on HLT\n"
- " -h: help\n"
- " -k: key=value flat config file\n"
- " -K: PS2 keyboard layout\n"
- " -l: LPC device configuration\n"
- " -m: memory size\n"
- " -o: set config 'var' to 'value'\n"
- " -P: vmexit from the guest on pause\n"
- " -p: pin 'vcpu' to 'hostcpu'\n"
-#ifdef BHYVE_SNAPSHOT
- " -r: path to checkpoint file\n"
-#endif
- " -S: guest memory cannot be swapped\n"
- " -s: <slot,driver,configinfo> PCI slot config\n"
- " -U: UUID\n"
- " -u: RTC keeps UTC time\n"
- " -W: force virtio to use single-vector MSI\n"
- " -w: ignore unimplemented MSRs\n"
- " -x: local APIC is in x2APIC mode\n"
- " -Y: disable MPtable generation\n",
- progname, (int)strlen(progname), "", (int)strlen(progname), "",
- (int)strlen(progname), "");
-
- exit(code);
-}
-
/*
* XXX This parser is known to have the following issues:
* 1. It accepts null key=value tokens ",," as setting "cpus" to an
@@ -267,8 +122,8 @@ usage(int code)
* The acceptance of a null specification ('-c ""') is by design to match the
* manual page syntax specification, this results in a topology of 1 vCPU.
*/
-static int
-topology_parse(const char *opt)
+int
+bhyve_topology_parse(const char *opt)
{
char *cp, *str, *tofree;
@@ -293,10 +148,6 @@ topology_parse(const char *opt)
set_config_value("cores", cp + strlen("cores="));
else if (strncmp(cp, "threads=", strlen("threads=")) == 0)
set_config_value("threads", cp + strlen("threads="));
-#ifdef notyet /* Do not expose this until vmm.ko implements it */
- else if (strncmp(cp, "maxcpus=", strlen("maxcpus=")) == 0)
- set_config_value("maxcpus", cp + strlen("maxcpus="));
-#endif
else if (strchr(cp, '=') != NULL)
goto out;
else
@@ -332,7 +183,7 @@ parse_int_value(const char *key, const char *value, int minval, int maxval)
* vm_set_topology(). vmm.ko may enforce tighter limits.
*/
static void
-calc_topolopgy(void)
+calc_topology(void)
{
const char *value;
bool explicit_cpus;
@@ -348,40 +199,41 @@ calc_topolopgy(void)
}
value = get_config_value("cores");
if (value != NULL)
- cores = parse_int_value("cores", value, 1, UINT16_MAX);
+ cpu_cores = parse_int_value("cores", value, 1, UINT16_MAX);
else
- cores = 1;
+ cpu_cores = 1;
value = get_config_value("threads");
if (value != NULL)
- threads = parse_int_value("threads", value, 1, UINT16_MAX);
+ cpu_threads = parse_int_value("threads", value, 1, UINT16_MAX);
else
- threads = 1;
+ cpu_threads = 1;
value = get_config_value("sockets");
if (value != NULL)
- sockets = parse_int_value("sockets", value, 1, UINT16_MAX);
+ cpu_sockets = parse_int_value("sockets", value, 1, UINT16_MAX);
else
- sockets = guest_ncpus;
+ cpu_sockets = guest_ncpus;
/*
* Compute sockets * cores * threads avoiding overflow. The
* range check above insures these are 16 bit values.
*/
- ncpus = (uint64_t)sockets * cores * threads;
+ ncpus = (uint64_t)cpu_sockets * cpu_cores * cpu_threads;
if (ncpus > UINT16_MAX)
errx(4, "Computed number of vCPUs too high: %ju",
(uintmax_t)ncpus);
if (explicit_cpus) {
- if (guest_ncpus != ncpus)
+ if (guest_ncpus != (int)ncpus)
errx(4, "Topology (%d sockets, %d cores, %d threads) "
- "does not match %d vCPUs", sockets, cores, threads,
+ "does not match %d vCPUs",
+ cpu_sockets, cpu_cores, cpu_threads,
guest_ncpus);
} else
guest_ncpus = ncpus;
}
-static int
-pincpu_parse(const char *opt)
+int
+bhyve_pincpu_parse(const char *opt)
{
const char *value;
char *newval;
@@ -442,12 +294,12 @@ parse_cpuset(int vcpu, const char *list, cpuset_t *set)
errx(4, "Invalid hostcpu range %d-%d",
start, pcpu);
while (start < pcpu) {
- CPU_SET(start, vcpumap[vcpu]);
+ CPU_SET(start, set);
start++;
}
start = -1;
}
- CPU_SET(pcpu, vcpumap[vcpu]);
+ CPU_SET(pcpu, set);
break;
case '-':
if (start >= 0)
@@ -484,21 +336,6 @@ build_vcpumaps(void)
}
}
-void
-vm_inject_fault(void *arg, int vcpu, int vector, int errcode_valid,
- int errcode)
-{
- struct vmctx *ctx;
- int error, restart_instruction;
-
- ctx = arg;
- restart_instruction = 1;
-
- error = vm_inject_exception(ctx, vcpu, vector, errcode_valid, errcode,
- restart_instruction);
- assert(error == 0);
-}
-
void *
paddr_guest2host(struct vmctx *ctx, uintptr_t gaddr, size_t len)
{
@@ -521,25 +358,36 @@ fbsdrun_virtio_msix(void)
return (get_config_bool_default("virtio_msix", true));
}
+struct vcpu *
+fbsdrun_vcpu(int vcpuid)
+{
+ return (vcpu_info[vcpuid].vcpu);
+}
+
static void *
fbsdrun_start_thread(void *param)
{
char tname[MAXCOMLEN + 1];
- struct mt_vmm_info *mtp;
- int vcpu;
+ struct vcpu_info *vi = param;
+ int error;
- mtp = param;
- vcpu = mtp->mt_vcpu;
+ snprintf(tname, sizeof(tname), "vcpu %d", vi->vcpuid);
+ pthread_set_name_np(pthread_self(), tname);
- snprintf(tname, sizeof(tname), "vcpu %d", vcpu);
- pthread_set_name_np(mtp->mt_thr, tname);
+ if (vcpumap[vi->vcpuid] != NULL) {
+ error = pthread_setaffinity_np(pthread_self(),
+ sizeof(cpuset_t), vcpumap[vi->vcpuid]);
+ assert(error == 0);
+ }
#ifdef BHYVE_SNAPSHOT
- checkpoint_cpu_add(vcpu);
+ checkpoint_cpu_add(vi->vcpuid);
+#endif
+#ifdef BHYVE_GDB
+ gdb_cpu_add(vi->vcpu);
#endif
- gdb_cpu_add(vcpu);
- vm_loop(mtp->mt_ctx, vcpu, vmexit[vcpu].rip);
+ vm_loop(vi->ctx, vi->vcpu);
/* not reached */
exit(1);
@@ -547,444 +395,88 @@ fbsdrun_start_thread(void *param)
}
void
-fbsdrun_addcpu(struct vmctx *ctx, int fromcpu, int newcpu, uint64_t rip)
+fbsdrun_addcpu(int vcpuid)
{
+ struct vcpu_info *vi;
+ pthread_t thr;
int error;
- assert(fromcpu == BSP);
+ vi = &vcpu_info[vcpuid];
- /*
- * The 'newcpu' must be activated in the context of 'fromcpu'. If
- * vm_activate_cpu() is delayed until newcpu's pthread starts running
- * then vmm.ko is out-of-sync with bhyve and this can create a race
- * with vm_suspend().
- */
- error = vm_activate_cpu(ctx, newcpu);
+ error = vm_activate_cpu(vi->vcpu);
if (error != 0)
- err(EX_OSERR, "could not activate CPU %d", newcpu);
-
- CPU_SET_ATOMIC(newcpu, &cpumask);
+ err(EX_OSERR, "could not activate CPU %d", vi->vcpuid);
- /*
- * Set up the vmexit struct to allow execution to start
- * at the given RIP
- */
- vmexit[newcpu].rip = rip;
- vmexit[newcpu].inst_length = 0;
+ CPU_SET_ATOMIC(vcpuid, &cpumask);
- mt_vmm_info[newcpu].mt_ctx = ctx;
- mt_vmm_info[newcpu].mt_vcpu = newcpu;
+ vm_suspend_cpu(vi->vcpu);
- error = pthread_create(&mt_vmm_info[newcpu].mt_thr, NULL,
- fbsdrun_start_thread, &mt_vmm_info[newcpu]);
+ error = pthread_create(&thr, NULL, fbsdrun_start_thread, vi);
assert(error == 0);
}
-static int
-fbsdrun_deletecpu(struct vmctx *ctx, int vcpu)
+void
+fbsdrun_deletecpu(int vcpu)
{
+ static pthread_mutex_t resetcpu_mtx = PTHREAD_MUTEX_INITIALIZER;
+ static pthread_cond_t resetcpu_cond = PTHREAD_COND_INITIALIZER;
+ pthread_mutex_lock(&resetcpu_mtx);
if (!CPU_ISSET(vcpu, &cpumask)) {
- fprintf(stderr, "Attempting to delete unknown cpu %d\n", vcpu);
+ EPRINTLN("Attempting to delete unknown cpu %d", vcpu);
exit(4);
}
- CPU_CLR_ATOMIC(vcpu, &cpumask);
- return (CPU_EMPTY(&cpumask));
-}
-
-static int
-vmexit_handle_notify(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu,
- uint32_t eax)
-{
-#if BHYVE_DEBUG
- /*
- * put guest-driven debug here
- */
-#endif
- return (VMEXIT_CONTINUE);
-}
-
-static int
-vmexit_inout(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
-{
- int error;
- int bytes, port, in, out;
- int vcpu;
-
- vcpu = *pvcpu;
-
- port = vme->u.inout.port;
- bytes = vme->u.inout.bytes;
- in = vme->u.inout.in;
- out = !in;
-
- /* Extra-special case of host notifications */
- if (out && port == GUEST_NIO_PORT) {
- error = vmexit_handle_notify(ctx, vme, pvcpu, vme->u.inout.eax);
- return (error);
- }
-
- error = emulate_inout(ctx, vcpu, vme);
- if (error) {
- fprintf(stderr, "Unhandled %s%c 0x%04x at 0x%lx\n",
- in ? "in" : "out",
- bytes == 1 ? 'b' : (bytes == 2 ? 'w' : 'l'),
- port, vmexit->rip);
- return (VMEXIT_ABORT);
- } else {
- return (VMEXIT_CONTINUE);
- }
-}
-
-static int
-vmexit_rdmsr(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
-{
- uint64_t val;
- uint32_t eax, edx;
- int error;
-
- val = 0;
- error = emulate_rdmsr(ctx, *pvcpu, vme->u.msr.code, &val);
- if (error != 0) {
- fprintf(stderr, "rdmsr to register %#x on vcpu %d\n",
- vme->u.msr.code, *pvcpu);
- if (get_config_bool("x86.strictmsr")) {
- vm_inject_gp(ctx, *pvcpu);
- return (VMEXIT_CONTINUE);
- }
- }
-
- eax = val;
- error = vm_set_register(ctx, *pvcpu, VM_REG_GUEST_RAX, eax);
- assert(error == 0);
-
- edx = val >> 32;
- error = vm_set_register(ctx, *pvcpu, VM_REG_GUEST_RDX, edx);
- assert(error == 0);
-
- return (VMEXIT_CONTINUE);
-}
-
-static int
-vmexit_wrmsr(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
-{
- int error;
-
- error = emulate_wrmsr(ctx, *pvcpu, vme->u.msr.code, vme->u.msr.wval);
- if (error != 0) {
- fprintf(stderr, "wrmsr to register %#x(%#lx) on vcpu %d\n",
- vme->u.msr.code, vme->u.msr.wval, *pvcpu);
- if (get_config_bool("x86.strictmsr")) {
- vm_inject_gp(ctx, *pvcpu);
- return (VMEXIT_CONTINUE);
- }
- }
- return (VMEXIT_CONTINUE);
-}
-
-static int
-vmexit_spinup_ap(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
-{
-
- (void)spinup_ap(ctx, *pvcpu,
- vme->u.spinup_ap.vcpu, vme->u.spinup_ap.rip);
-
- return (VMEXIT_CONTINUE);
-}
-
-#define DEBUG_EPT_MISCONFIG
-#ifdef DEBUG_EPT_MISCONFIG
-#define VMCS_GUEST_PHYSICAL_ADDRESS 0x00002400
-
-static uint64_t ept_misconfig_gpa, ept_misconfig_pte[4];
-static int ept_misconfig_ptenum;
-#endif
-
-static const char *
-vmexit_vmx_desc(uint32_t exit_reason)
-{
-
- if (exit_reason >= nitems(vmx_exit_reason_desc) ||
- vmx_exit_reason_desc[exit_reason] == NULL)
- return ("Unknown");
- return (vmx_exit_reason_desc[exit_reason]);
-}
-
-static int
-vmexit_vmx(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
-
- fprintf(stderr, "vm exit[%d]\n", *pvcpu);
- fprintf(stderr, "\treason\t\tVMX\n");
- fprintf(stderr, "\trip\t\t0x%016lx\n", vmexit->rip);
- fprintf(stderr, "\tinst_length\t%d\n", vmexit->inst_length);
- fprintf(stderr, "\tstatus\t\t%d\n", vmexit->u.vmx.status);
- fprintf(stderr, "\texit_reason\t%u (%s)\n", vmexit->u.vmx.exit_reason,
- vmexit_vmx_desc(vmexit->u.vmx.exit_reason));
- fprintf(stderr, "\tqualification\t0x%016lx\n",
- vmexit->u.vmx.exit_qualification);
- fprintf(stderr, "\tinst_type\t\t%d\n", vmexit->u.vmx.inst_type);
- fprintf(stderr, "\tinst_error\t\t%d\n", vmexit->u.vmx.inst_error);
-#ifdef DEBUG_EPT_MISCONFIG
- if (vmexit->u.vmx.exit_reason == EXIT_REASON_EPT_MISCONFIG) {
- vm_get_register(ctx, *pvcpu,
- VMCS_IDENT(VMCS_GUEST_PHYSICAL_ADDRESS),
- &ept_misconfig_gpa);
- vm_get_gpa_pmap(ctx, ept_misconfig_gpa, ept_misconfig_pte,
- &ept_misconfig_ptenum);
- fprintf(stderr, "\tEPT misconfiguration:\n");
- fprintf(stderr, "\t\tGPA: %#lx\n", ept_misconfig_gpa);
- fprintf(stderr, "\t\tPTE(%d): %#lx %#lx %#lx %#lx\n",
- ept_misconfig_ptenum, ept_misconfig_pte[0],
- ept_misconfig_pte[1], ept_misconfig_pte[2],
- ept_misconfig_pte[3]);
- }
-#endif /* DEBUG_EPT_MISCONFIG */
- return (VMEXIT_ABORT);
-}
-
-static int
-vmexit_svm(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
-
- fprintf(stderr, "vm exit[%d]\n", *pvcpu);
- fprintf(stderr, "\treason\t\tSVM\n");
- fprintf(stderr, "\trip\t\t0x%016lx\n", vmexit->rip);
- fprintf(stderr, "\tinst_length\t%d\n", vmexit->inst_length);
- fprintf(stderr, "\texitcode\t%#lx\n", vmexit->u.svm.exitcode);
- fprintf(stderr, "\texitinfo1\t%#lx\n", vmexit->u.svm.exitinfo1);
- fprintf(stderr, "\texitinfo2\t%#lx\n", vmexit->u.svm.exitinfo2);
- return (VMEXIT_ABORT);
-}
-
-static int
-vmexit_bogus(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
-
- assert(vmexit->inst_length == 0);
-
- stats.vmexit_bogus++;
-
- return (VMEXIT_CONTINUE);
-}
-
-static int
-vmexit_reqidle(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
-
- assert(vmexit->inst_length == 0);
-
- stats.vmexit_reqidle++;
-
- return (VMEXIT_CONTINUE);
-}
-
-static int
-vmexit_hlt(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
-
- stats.vmexit_hlt++;
-
- /*
- * Just continue execution with the next instruction. We use
- * the HLT VM exit as a way to be friendly with the host
- * scheduler.
- */
- return (VMEXIT_CONTINUE);
-}
-
-static int
-vmexit_pause(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
-
- stats.vmexit_pause++;
-
- return (VMEXIT_CONTINUE);
-}
-
-static int
-vmexit_mtrap(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
-
- assert(vmexit->inst_length == 0);
-
- stats.vmexit_mtrap++;
-
-#ifdef BHYVE_SNAPSHOT
- checkpoint_cpu_suspend(*pvcpu);
-#endif
- gdb_cpu_mtrap(*pvcpu);
-#ifdef BHYVE_SNAPSHOT
- checkpoint_cpu_resume(*pvcpu);
-#endif
-
- return (VMEXIT_CONTINUE);
-}
-
-static int
-vmexit_inst_emul(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
- int err, i, cs_d;
- struct vie *vie;
- enum vm_cpu_mode mode;
-
- stats.vmexit_inst_emul++;
-
- vie = &vmexit->u.inst_emul.vie;
- if (!vie->decoded) {
- /*
- * Attempt to decode in userspace as a fallback. This allows
- * updating instruction decode in bhyve without rebooting the
- * kernel (rapid prototyping), albeit with much slower
- * emulation.
- */
- vie_restart(vie);
- mode = vmexit->u.inst_emul.paging.cpu_mode;
- cs_d = vmexit->u.inst_emul.cs_d;
- if (vmm_decode_instruction(mode, cs_d, vie) != 0)
- goto fail;
- if (vm_set_register(ctx, *pvcpu, VM_REG_GUEST_RIP,
- vmexit->rip + vie->num_processed) != 0)
- goto fail;
- }
-
- err = emulate_mem(ctx, *pvcpu, vmexit->u.inst_emul.gpa,
- vie, &vmexit->u.inst_emul.paging);
-
- if (err) {
- if (err == ESRCH) {
- EPRINTLN("Unhandled memory access to 0x%lx\n",
- vmexit->u.inst_emul.gpa);
- }
- goto fail;
- }
-
- return (VMEXIT_CONTINUE);
-
-fail:
- fprintf(stderr, "Failed to emulate instruction sequence [ ");
- for (i = 0; i < vie->num_valid; i++)
- fprintf(stderr, "%02x", vie->inst[i]);
- FPRINTLN(stderr, " ] at 0x%lx", vmexit->rip);
- return (VMEXIT_ABORT);
-}
-
-static pthread_mutex_t resetcpu_mtx = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t resetcpu_cond = PTHREAD_COND_INITIALIZER;
-
-static int
-vmexit_suspend(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
- enum vm_suspend_how how;
-
- how = vmexit->u.suspended.how;
-
- fbsdrun_deletecpu(ctx, *pvcpu);
+ CPU_CLR(vcpu, &cpumask);
- if (*pvcpu != BSP) {
- pthread_mutex_lock(&resetcpu_mtx);
+ if (vcpu != BSP) {
pthread_cond_signal(&resetcpu_cond);
pthread_mutex_unlock(&resetcpu_mtx);
pthread_exit(NULL);
+ /* NOTREACHED */
}
- pthread_mutex_lock(&resetcpu_mtx);
while (!CPU_EMPTY(&cpumask)) {
pthread_cond_wait(&resetcpu_cond, &resetcpu_mtx);
}
pthread_mutex_unlock(&resetcpu_mtx);
-
- switch (how) {
- case VM_SUSPEND_RESET:
- exit(0);
- case VM_SUSPEND_POWEROFF:
- if (get_config_bool_default("destroy_on_poweroff", false))
- vm_destroy(ctx);
- exit(1);
- case VM_SUSPEND_HALT:
- exit(2);
- case VM_SUSPEND_TRIPLEFAULT:
- exit(3);
- default:
- fprintf(stderr, "vmexit_suspend: invalid reason %d\n", how);
- exit(100);
- }
- return (0); /* NOTREACHED */
-}
-
-static int
-vmexit_debug(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
-{
-
-#ifdef BHYVE_SNAPSHOT
- checkpoint_cpu_suspend(*pvcpu);
-#endif
- gdb_cpu_suspend(*pvcpu);
-#ifdef BHYVE_SNAPSHOT
- checkpoint_cpu_resume(*pvcpu);
-#endif
- return (VMEXIT_CONTINUE);
}
-static int
-vmexit_breakpoint(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
+int
+fbsdrun_suspendcpu(int vcpuid)
{
-
- gdb_cpu_breakpoint(*pvcpu, vmexit);
- return (VMEXIT_CONTINUE);
+ return (vm_suspend_cpu(vcpu_info[vcpuid].vcpu));
}
-static vmexit_handler_t handler[VM_EXITCODE_MAX] = {
- [VM_EXITCODE_INOUT] = vmexit_inout,
- [VM_EXITCODE_INOUT_STR] = vmexit_inout,
- [VM_EXITCODE_VMX] = vmexit_vmx,
- [VM_EXITCODE_SVM] = vmexit_svm,
- [VM_EXITCODE_BOGUS] = vmexit_bogus,
- [VM_EXITCODE_REQIDLE] = vmexit_reqidle,
- [VM_EXITCODE_RDMSR] = vmexit_rdmsr,
- [VM_EXITCODE_WRMSR] = vmexit_wrmsr,
- [VM_EXITCODE_MTRAP] = vmexit_mtrap,
- [VM_EXITCODE_INST_EMUL] = vmexit_inst_emul,
- [VM_EXITCODE_SPINUP_AP] = vmexit_spinup_ap,
- [VM_EXITCODE_SUSPENDED] = vmexit_suspend,
- [VM_EXITCODE_TASK_SWITCH] = vmexit_task_switch,
- [VM_EXITCODE_DEBUG] = vmexit_debug,
- [VM_EXITCODE_BPT] = vmexit_breakpoint,
-};
-
static void
-vm_loop(struct vmctx *ctx, int vcpu, uint64_t startrip)
+vm_loop(struct vmctx *ctx, struct vcpu *vcpu)
{
+ struct vm_exit vme;
+ struct vm_run vmrun;
int error, rc;
enum vm_exitcode exitcode;
- cpuset_t active_cpus;
-
- if (vcpumap[vcpu] != NULL) {
- error = pthread_setaffinity_np(pthread_self(),
- sizeof(cpuset_t), vcpumap[vcpu]);
- assert(error == 0);
- }
+ cpuset_t active_cpus, dmask;
error = vm_active_cpus(ctx, &active_cpus);
- assert(CPU_ISSET(vcpu, &active_cpus));
+ assert(CPU_ISSET(vcpu_id(vcpu), &active_cpus));
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, startrip);
- assert(error == 0);
+ vmrun.vm_exit = &vme;
+ vmrun.cpuset = &dmask;
+ vmrun.cpusetsize = sizeof(dmask);
while (1) {
- error = vm_run(ctx, vcpu, &vmexit[vcpu]);
+ error = vm_run(vcpu, &vmrun);
if (error != 0)
break;
- exitcode = vmexit[vcpu].exitcode;
- if (exitcode >= VM_EXITCODE_MAX || handler[exitcode] == NULL) {
- fprintf(stderr, "vm_loop: unexpected exitcode 0x%x\n",
- exitcode);
+ exitcode = vme.exitcode;
+ if (exitcode >= VM_EXITCODE_MAX ||
+ vmexit_handlers[exitcode] == NULL) {
+ warnx("vm_loop: unexpected exitcode 0x%x", exitcode);
exit(4);
}
- rc = (*handler[exitcode])(ctx, &vmexit[vcpu], &vcpu);
+ rc = (*vmexit_handlers[exitcode])(ctx, vcpu, &vmrun);
switch (rc) {
case VMEXIT_CONTINUE:
@@ -995,11 +487,11 @@ vm_loop(struct vmctx *ctx, int vcpu, uint64_t startrip)
exit(4);
}
}
- fprintf(stderr, "vm_run error %d, errno %d\n", error, errno);
+ EPRINTLN("vm_run error %d, errno %d", error, errno);
}
static int
-num_vcpus_allowed(struct vmctx *ctx)
+num_vcpus_allowed(struct vmctx *ctx, struct vcpu *vcpu)
{
uint16_t sockets, cores, threads, maxcpus;
int tmp, error;
@@ -1008,7 +500,7 @@ num_vcpus_allowed(struct vmctx *ctx)
* The guest is allowed to spinup more than one processor only if the
* UNRESTRICTED_GUEST capability is available.
*/
- error = vm_get_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, &tmp);
+ error = vm_get_capability(vcpu, VM_CAP_UNRESTRICTED_GUEST, &tmp);
if (error != 0)
return (1);
@@ -1019,66 +511,20 @@ num_vcpus_allowed(struct vmctx *ctx)
return (1);
}
-void
-fbsdrun_set_capabilities(struct vmctx *ctx, int cpu)
-{
- int err, tmp;
-
- if (get_config_bool_default("x86.vmexit_on_hlt", false)) {
- err = vm_get_capability(ctx, cpu, VM_CAP_HALT_EXIT, &tmp);
- if (err < 0) {
- fprintf(stderr, "VM exit on HLT not supported\n");
- exit(4);
- }
- vm_set_capability(ctx, cpu, VM_CAP_HALT_EXIT, 1);
- if (cpu == BSP)
- handler[VM_EXITCODE_HLT] = vmexit_hlt;
- }
-
- if (get_config_bool_default("x86.vmexit_on_pause", false)) {
- /*
- * pause exit support required for this mode
- */
- err = vm_get_capability(ctx, cpu, VM_CAP_PAUSE_EXIT, &tmp);
- if (err < 0) {
- fprintf(stderr,
- "SMP mux requested, no pause support\n");
- exit(4);
- }
- vm_set_capability(ctx, cpu, VM_CAP_PAUSE_EXIT, 1);
- if (cpu == BSP)
- handler[VM_EXITCODE_PAUSE] = vmexit_pause;
- }
-
- if (get_config_bool_default("x86.x2apic", false))
- err = vm_set_x2apic_state(ctx, cpu, X2APIC_ENABLED);
- else
- err = vm_set_x2apic_state(ctx, cpu, X2APIC_DISABLED);
-
- if (err) {
- fprintf(stderr, "Unable to set x2apic state (%d)\n", err);
- exit(4);
- }
-
- vm_set_capability(ctx, cpu, VM_CAP_ENABLE_INVPCID, 1);
-}
-
static struct vmctx *
do_open(const char *vmname)
{
struct vmctx *ctx;
int error;
bool reinit, romboot;
-#ifndef WITHOUT_CAPSICUM
- cap_rights_t rights;
- const cap_ioctl_t *cmds;
- size_t ncmds;
-#endif
- reinit = romboot = false;
+ reinit = false;
- if (lpc_bootrom())
- romboot = true;
+#ifdef __amd64__
+ romboot = lpc_bootrom() != NULL;
+#else
+ romboot = true;
+#endif
error = vm_create(vmname);
if (error) {
@@ -1113,16 +559,8 @@ do_open(const char *vmname)
}
#ifndef WITHOUT_CAPSICUM
- cap_rights_init(&rights, CAP_IOCTL, CAP_MMAP_RW);
- if (caph_rights_limit(vm_get_device_fd(ctx), &rights) == -1)
- errx(EX_OSERR, "Unable to apply rights for sandbox");
- vm_get_ioctls(&ncmds);
- cmds = vm_get_ioctls(NULL);
- if (cmds == NULL)
- errx(EX_OSERR, "out of memory");
- if (caph_ioctls_limit(vm_get_device_fd(ctx), cmds, ncmds) == -1)
- errx(EX_OSERR, "Unable to apply rights for sandbox");
- free((cap_ioctl_t *)cmds);
+ if (vm_limit_rights(ctx) != 0)
+ err(EX_OSERR, "vm_limit_rights");
#endif
if (reinit) {
@@ -1132,30 +570,14 @@ do_open(const char *vmname)
exit(4);
}
}
- error = vm_set_topology(ctx, sockets, cores, threads, maxcpus);
+ error = vm_set_topology(ctx, cpu_sockets, cpu_cores, cpu_threads, 0);
if (error)
errx(EX_OSERR, "vm_set_topology");
return (ctx);
}
-void
-spinup_vcpu(struct vmctx *ctx, int vcpu)
-{
- int error;
- uint64_t rip;
-
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RIP, &rip);
- assert(error == 0);
-
- fbsdrun_set_capabilities(ctx, vcpu);
- error = vm_set_capability(ctx, vcpu, VM_CAP_UNRESTRICTED_GUEST, 1);
- assert(error == 0);
-
- fbsdrun_addcpu(ctx, BSP, vcpu, rip);
-}
-
-static bool
-parse_config_option(const char *option)
+bool
+bhyve_parse_config_option(const char *option)
{
const char *value;
char *path;
@@ -1170,8 +592,8 @@ parse_config_option(const char *option)
return (true);
}
-static void
-parse_simple_config_file(const char *path)
+void
+bhyve_parse_simple_config_file(const char *path)
{
FILE *fp;
char *line, *cp;
@@ -1190,7 +612,7 @@ parse_simple_config_file(const char *path)
cp = strchr(line, '\n');
if (cp != NULL)
*cp = '\0';
- if (!parse_config_option(line))
+ if (!bhyve_parse_config_option(line))
errx(4, "%s line %u: invalid config option '%s'", path,
lineno, line);
}
@@ -1198,180 +620,55 @@ parse_simple_config_file(const char *path)
fclose(fp);
}
-static void
-parse_gdb_options(char *optarg)
+#ifdef BHYVE_GDB
+void
+bhyve_parse_gdb_options(const char *opt)
{
const char *sport;
char *colon;
- if (optarg[0] == 'w') {
+ if (opt[0] == 'w') {
set_config_bool("gdb.wait", true);
- optarg++;
+ opt++;
}
- colon = strrchr(optarg, ':');
+ colon = strrchr(opt, ':');
if (colon == NULL) {
- sport = optarg;
+ sport = opt;
} else {
*colon = '\0';
colon++;
sport = colon;
- set_config_value("gdb.address", optarg);
+ set_config_value("gdb.address", opt);
}
set_config_value("gdb.port", sport);
}
-
-static void
-set_defaults(void)
-{
-
- set_config_bool("acpi_tables", false);
- set_config_value("memory.size", "256M");
- set_config_bool("x86.strictmsr", true);
-}
+#endif
int
main(int argc, char *argv[])
{
- int c, error, err;
+ int error;
int max_vcpus, memflags;
+ struct vcpu *bsp;
struct vmctx *ctx;
- uint64_t rip;
size_t memsize;
const char *value, *vmname;
- char *optstr;
#ifdef BHYVE_SNAPSHOT
char *restore_file;
struct restore_state rstate;
- int vcpu;
restore_file = NULL;
#endif
- init_config();
- set_defaults();
- progname = basename(argv[0]);
-
-#ifdef BHYVE_SNAPSHOT
- optstr = "aehuwxACDHIPSWYk:o:p:G:c:s:m:l:K:U:r:";
-#else
- optstr = "aehuwxACDHIPSWYk:o:p:G:c:s:m:l:K:U:";
-#endif
- while ((c = getopt(argc, argv, optstr)) != -1) {
- switch (c) {
- case 'a':
- set_config_bool("x86.x2apic", false);
- break;
- case 'A':
- set_config_bool("acpi_tables", true);
- break;
- case 'D':
- set_config_bool("destroy_on_poweroff", true);
- break;
- case 'p':
- if (pincpu_parse(optarg) != 0) {
- errx(EX_USAGE, "invalid vcpu pinning "
- "configuration '%s'", optarg);
- }
- break;
- case 'c':
- if (topology_parse(optarg) != 0) {
- errx(EX_USAGE, "invalid cpu topology "
- "'%s'", optarg);
- }
- break;
- case 'C':
- set_config_bool("memory.guest_in_core", true);
- break;
- case 'G':
- parse_gdb_options(optarg);
- break;
- case 'k':
- parse_simple_config_file(optarg);
- break;
- case 'K':
- set_config_value("keyboard.layout", optarg);
- break;
- case 'l':
- if (strncmp(optarg, "help", strlen(optarg)) == 0) {
- lpc_print_supported_devices();
- exit(0);
- } else if (lpc_device_parse(optarg) != 0) {
- errx(EX_USAGE, "invalid lpc device "
- "configuration '%s'", optarg);
- }
- break;
-#ifdef BHYVE_SNAPSHOT
- case 'r':
- restore_file = optarg;
- break;
-#endif
- case 's':
- if (strncmp(optarg, "help", strlen(optarg)) == 0) {
- pci_print_supported_devices();
- exit(0);
- } else if (pci_parse_slot(optarg) != 0)
- exit(4);
- else
- break;
- case 'S':
- set_config_bool("memory.wired", true);
- break;
- case 'm':
- set_config_value("memory.size", optarg);
- break;
- case 'o':
- if (!parse_config_option(optarg))
- errx(EX_USAGE, "invalid configuration option '%s'", optarg);
- break;
- case 'H':
- set_config_bool("x86.vmexit_on_hlt", true);
- break;
- case 'I':
- /*
- * The "-I" option was used to add an ioapic to the
- * virtual machine.
- *
- * An ioapic is now provided unconditionally for each
- * virtual machine and this option is now deprecated.
- */
- break;
- case 'P':
- set_config_bool("x86.vmexit_on_pause", true);
- break;
- case 'e':
- set_config_bool("x86.strictio", true);
- break;
- case 'u':
- set_config_bool("rtc.use_localtime", false);
- break;
- case 'U':
- set_config_value("uuid", optarg);
- break;
- case 'w':
- set_config_bool("x86.strictmsr", false);
- break;
- case 'W':
- set_config_bool("virtio_msix", false);
- break;
- case 'x':
- set_config_bool("x86.x2apic", true);
- break;
- case 'Y':
- set_config_bool("x86.mptable", false);
- break;
- case 'h':
- usage(0);
- default:
- usage(1);
- }
- }
+ bhyve_init_config();
+ bhyve_optparse(argc, argv);
argc -= optind;
argv += optind;
if (argc > 1)
- usage(1);
+ bhyve_usage(1);
#ifdef BHYVE_SNAPSHOT
if (restore_file != NULL) {
@@ -1392,14 +689,14 @@ main(int argc, char *argv[])
vmname = get_config_value("name");
if (vmname == NULL)
- usage(1);
+ bhyve_usage(1);
if (get_config_bool_default("config.dump", false)) {
dump_config();
exit(1);
}
- calc_topolopgy();
+ calc_topology();
build_vcpumaps();
value = get_config_value("memory.size");
@@ -1422,14 +719,26 @@ main(int argc, char *argv[])
}
#endif
- max_vcpus = num_vcpus_allowed(ctx);
+ bsp = vm_vcpu_open(ctx, BSP);
+ max_vcpus = num_vcpus_allowed(ctx, bsp);
if (guest_ncpus > max_vcpus) {
fprintf(stderr, "%d vCPUs requested but only %d available\n",
guest_ncpus, max_vcpus);
exit(4);
}
- fbsdrun_set_capabilities(ctx, BSP);
+ bhyve_init_vcpu(bsp);
+
+ /* Allocate per-VCPU resources. */
+ vcpu_info = calloc(guest_ncpus, sizeof(*vcpu_info));
+ for (int vcpuid = 0; vcpuid < guest_ncpus; vcpuid++) {
+ vcpu_info[vcpuid].ctx = ctx;
+ vcpu_info[vcpuid].vcpuid = vcpuid;
+ if (vcpuid == BSP)
+ vcpu_info[vcpuid].vcpu = bsp;
+ else
+ vcpu_info[vcpuid].vcpu = vm_vcpu_open(ctx, vcpuid);
+ }
memflags = 0;
if (get_config_bool_default("memory.wired", false))
@@ -1437,34 +746,38 @@ main(int argc, char *argv[])
if (get_config_bool_default("memory.guest_in_core", false))
memflags |= VM_MEM_F_INCORE;
vm_set_memflags(ctx, memflags);
- err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
- if (err) {
- fprintf(stderr, "Unable to setup memory (%d)\n", errno);
- exit(4);
- }
-
- error = init_msr();
+ error = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
if (error) {
- fprintf(stderr, "init_msr error %d", error);
+ fprintf(stderr, "Unable to setup memory (%d)\n", errno);
exit(4);
}
init_mem(guest_ncpus);
- init_inout();
- kernemu_dev_init();
init_bootrom(ctx);
- atkbdc_init(ctx);
- pci_irq_init(ctx);
- ioapic_init(ctx);
+ if (bhyve_init_platform(ctx, bsp) != 0)
+ exit(4);
- rtc_init(ctx);
- sci_init(ctx);
+ if (qemu_fwcfg_init(ctx) != 0) {
+ fprintf(stderr, "qemu fwcfg initialization error\n");
+ exit(4);
+ }
+
+ if (qemu_fwcfg_add_file("opt/bhyve/hw.ncpu", sizeof(guest_ncpus),
+ &guest_ncpus) != 0) {
+ fprintf(stderr, "Could not add qemu fwcfg opt/bhyve/hw.ncpu\n");
+ exit(4);
+ }
/*
- * Exit if a device emulation finds an error in its initilization
+ * Exit if a device emulation finds an error in its initialization
*/
if (init_pci(ctx) != 0) {
- perror("device emulation initialization error");
+ EPRINTLN("Device emulation initialization error: %s",
+ strerror(errno));
+ exit(4);
+ }
+ if (init_tpm(ctx) != 0) {
+ EPRINTLN("Failed to init TPM device");
exit(4);
}
@@ -1475,81 +788,65 @@ main(int argc, char *argv[])
if (get_config_bool("acpi_tables"))
vmgenc_init(ctx);
+#ifdef BHYVE_GDB
init_gdb(ctx);
+#endif
- if (lpc_bootrom()) {
- if (vm_set_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, 1)) {
- fprintf(stderr, "ROM boot failed: unrestricted guest "
- "capability not available\n");
- exit(4);
- }
- error = vcpu_reset(ctx, BSP);
- assert(error == 0);
- }
+ /*
+ * Add all vCPUs.
+ */
+ for (int vcpuid = 0; vcpuid < guest_ncpus; vcpuid++)
+ bhyve_start_vcpu(vcpu_info[vcpuid].vcpu, vcpuid == BSP);
#ifdef BHYVE_SNAPSHOT
if (restore_file != NULL) {
- fprintf(stdout, "Pausing pci devs...\r\n");
- if (vm_pause_user_devs(ctx) != 0) {
- fprintf(stderr, "Failed to pause PCI device state.\n");
+ FPRINTLN(stdout, "Pausing pci devs...");
+ if (vm_pause_devices() != 0) {
+ EPRINTLN("Failed to pause PCI device state.");
exit(1);
}
- fprintf(stdout, "Restoring vm mem...\r\n");
+ FPRINTLN(stdout, "Restoring vm mem...");
if (restore_vm_mem(ctx, &rstate) != 0) {
- fprintf(stderr, "Failed to restore VM memory.\n");
+ EPRINTLN("Failed to restore VM memory.");
exit(1);
}
- fprintf(stdout, "Restoring pci devs...\r\n");
- if (vm_restore_user_devs(ctx, &rstate) != 0) {
- fprintf(stderr, "Failed to restore PCI device state.\n");
+ FPRINTLN(stdout, "Restoring pci devs...");
+ if (vm_restore_devices(&rstate) != 0) {
+ EPRINTLN("Failed to restore PCI device state.");
exit(1);
}
- fprintf(stdout, "Restoring kernel structs...\r\n");
+ FPRINTLN(stdout, "Restoring kernel structs...");
if (vm_restore_kern_structs(ctx, &rstate) != 0) {
- fprintf(stderr, "Failed to restore kernel structs.\n");
+ EPRINTLN("Failed to restore kernel structs.");
exit(1);
}
- fprintf(stdout, "Resuming pci devs...\r\n");
- if (vm_resume_user_devs(ctx) != 0) {
- fprintf(stderr, "Failed to resume PCI device state.\n");
+ FPRINTLN(stdout, "Resuming pci devs...");
+ if (vm_resume_devices() != 0) {
+ EPRINTLN("Failed to resume PCI device state.");
exit(1);
}
}
#endif
- error = vm_get_register(ctx, BSP, VM_REG_GUEST_RIP, &rip);
- assert(error == 0);
+ if (bhyve_init_platform_late(ctx, bsp) != 0)
+ exit(4);
/*
- * build the guest tables, MP etc.
+ * Change the proc title to include the VM name.
*/
- if (get_config_bool_default("x86.mptable", true)) {
- error = mptable_build(ctx, guest_ncpus);
- if (error) {
- perror("error to build the guest tables");
- exit(4);
- }
- }
-
- error = smbios_build(ctx);
- assert(error == 0);
-
- if (get_config_bool("acpi_tables")) {
- error = acpi_build(ctx, guest_ncpus);
- assert(error == 0);
- }
-
- if (lpc_bootrom())
- fwctl_init();
+ setproctitle("%s", vmname);
+#ifdef BHYVE_SNAPSHOT
/*
- * Change the proc title to include the VM name.
+ * checkpointing thread for communication with bhyvectl
*/
- setproctitle("%s", vmname);
+ if (init_checkpoint_thread(ctx) != 0)
+ errx(EX_OSERR, "Failed to start checkpoint thread");
+#endif
#ifndef WITHOUT_CAPSICUM
caph_cache_catpages();
@@ -1562,46 +859,16 @@ main(int argc, char *argv[])
#endif
#ifdef BHYVE_SNAPSHOT
- if (restore_file != NULL)
- destroy_restore_state(&rstate);
-
- /* initialize mutex/cond variables */
- init_snapshot();
-
- /*
- * checkpointing thread for communication with bhyvectl
- */
- if (init_checkpoint_thread(ctx) < 0)
- printf("Failed to start checkpoint thread!\r\n");
-
- if (restore_file != NULL)
- vm_restore_time(ctx);
-#endif
-
- /* Allocate per-VCPU resources. */
- vmexit = calloc(guest_ncpus, sizeof(*vmexit));
- mt_vmm_info = calloc(guest_ncpus, sizeof(*mt_vmm_info));
-
- /*
- * Add CPU 0
- */
- fbsdrun_addcpu(ctx, BSP, BSP, rip);
-
-#ifdef BHYVE_SNAPSHOT
- /*
- * If we restore a VM, start all vCPUs now (including APs), otherwise,
- * let the guest OS to spin them up later via vmexits.
- */
if (restore_file != NULL) {
- for (vcpu = 0; vcpu < guest_ncpus; vcpu++) {
- if (vcpu == BSP)
- continue;
+ destroy_restore_state(&rstate);
+ if (vm_restore_time(ctx) < 0)
+ err(EX_OSERR, "Unable to restore time");
- fprintf(stdout, "spinning up vcpu no %d...\r\n", vcpu);
- spinup_vcpu(ctx, vcpu);
- }
- }
+ for (int vcpuid = 0; vcpuid < guest_ncpus; vcpuid++)
+ vm_resume_cpu(vcpu_info[vcpuid].vcpu);
+ } else
#endif
+ vm_resume_cpu(bsp);
/*
* Head off to the main event dispatch loop
diff --git a/usr.sbin/bhyve/bhyverun.h b/usr.sbin/bhyve/bhyverun.h
index 9b0c9fb533e2..e6ff90e5daa0 100644
--- a/usr.sbin/bhyve/bhyverun.h
+++ b/usr.sbin/bhyve/bhyverun.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,27 +24,55 @@
* 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 _FBSDRUN_H_
-#define _FBSDRUN_H_
+#ifndef _BHYVERUN_H_
+#define _BHYVERUN_H_
+
+#include <stdbool.h>
#define VMEXIT_CONTINUE (0)
#define VMEXIT_ABORT (-1)
-struct vmctx;
extern int guest_ncpus;
-extern uint16_t cores, sockets, threads;
+extern uint16_t cpu_cores, cpu_sockets, cpu_threads;
+
+struct vcpu;
+struct vmctx;
+struct vm_run;
void *paddr_guest2host(struct vmctx *ctx, uintptr_t addr, size_t len);
#ifdef BHYVE_SNAPSHOT
uintptr_t paddr_host2guest(struct vmctx *ctx, void *addr);
#endif
-void fbsdrun_set_capabilities(struct vmctx *ctx, int cpu);
-void fbsdrun_addcpu(struct vmctx *ctx, int fromcpu, int newcpu, uint64_t rip);
+struct vcpu;
+struct vcpu *fbsdrun_vcpu(int vcpuid);
+void fbsdrun_addcpu(int vcpuid);
+void fbsdrun_deletecpu(int vcpuid);
+int fbsdrun_suspendcpu(int vcpuid);
+
int fbsdrun_virtio_msix(void);
+typedef int (*vmexit_handler_t)(struct vmctx *, struct vcpu *, struct vm_run *);
+
+/* Interfaces implemented by machine-dependent code. */
+void bhyve_init_config(void);
+void bhyve_optparse(int argc, char **argv);
+void bhyve_usage(int code);
+
+/* Interfaces used by command-line option-parsing code. */
+bool bhyve_parse_config_option(const char *option);
+void bhyve_parse_simple_config_file(const char *path);
+#ifdef BHYVE_GDB
+void bhyve_parse_gdb_options(const char *opt);
+#endif
+int bhyve_pincpu_parse(const char *opt);
+int bhyve_topology_parse(const char *opt);
+
+void bhyve_init_vcpu(struct vcpu *vcpu);
+void bhyve_start_vcpu(struct vcpu *vcpu, bool bsp);
+int bhyve_init_platform(struct vmctx *ctx, struct vcpu *bsp);
+int bhyve_init_platform_late(struct vmctx *ctx, struct vcpu *bsp);
+
#endif
diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c
index 06c3cb50fb13..32543f9f3a18 100644
--- a/usr.sbin/bhyve/block_if.c
+++ b/usr.sbin/bhyve/block_if.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Peter Grehan <grehan@freebsd.org>
* All rights reserved.
@@ -25,13 +25,8 @@
* 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 <sys/param.h>
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
@@ -97,7 +92,7 @@ struct blockif_elem {
};
struct blockif_ctxt {
- int bc_magic;
+ unsigned int bc_magic;
int bc_fd;
int bc_ischr;
int bc_isgeom;
@@ -109,11 +104,9 @@ struct blockif_ctxt {
int bc_psectoff;
int bc_closing;
int bc_paused;
- int bc_work_count;
pthread_t bc_btid[BLOCKIF_NUMTHR];
pthread_mutex_t bc_mtx;
pthread_cond_t bc_cond;
- pthread_cond_t bc_paused_cond;
pthread_cond_t bc_work_done_cond;
blockif_resize_cb *bc_resize_cb;
void *bc_resize_cb_arg;
@@ -124,6 +117,7 @@ struct blockif_ctxt {
TAILQ_HEAD(, blockif_elem) bc_pendq;
TAILQ_HEAD(, blockif_elem) bc_busyq;
struct blockif_elem bc_reqs[BLOCKIF_MAXREQ];
+ int bc_bootindex;
};
static pthread_once_t blockif_once = PTHREAD_ONCE_INIT;
@@ -235,40 +229,44 @@ blockif_flush_bc(struct blockif_ctxt *bc)
static void
blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf)
{
+ struct spacectl_range range;
struct blockif_req *br;
off_t arg[2];
- ssize_t clen, len, off, boff, voff;
+ ssize_t n;
+ size_t clen, len, off, boff, voff;
int i, err;
- struct spacectl_range range;
br = be->be_req;
+ assert(br->br_resid >= 0);
+
if (br->br_iovcnt <= 1)
buf = NULL;
err = 0;
switch (be->be_op) {
case BOP_READ:
if (buf == NULL) {
- if ((len = preadv(bc->bc_fd, br->br_iov, br->br_iovcnt,
- br->br_offset)) < 0)
+ if ((n = preadv(bc->bc_fd, br->br_iov, br->br_iovcnt,
+ br->br_offset)) < 0)
err = errno;
else
- br->br_resid -= len;
+ br->br_resid -= n;
break;
}
i = 0;
off = voff = 0;
while (br->br_resid > 0) {
len = MIN(br->br_resid, MAXPHYS);
- if (pread(bc->bc_fd, buf, len, br->br_offset +
- off) < 0) {
+ n = pread(bc->bc_fd, buf, len, br->br_offset + off);
+ if (n < 0) {
err = errno;
break;
}
+ len = (size_t)n;
boff = 0;
do {
clen = MIN(len - boff, br->br_iov[i].iov_len -
voff);
- memcpy(br->br_iov[i].iov_base + voff,
+ memcpy((uint8_t *)br->br_iov[i].iov_base + voff,
buf + boff, clen);
if (clen < br->br_iov[i].iov_len - voff)
voff += clen;
@@ -288,11 +286,11 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf)
break;
}
if (buf == NULL) {
- if ((len = pwritev(bc->bc_fd, br->br_iov, br->br_iovcnt,
- br->br_offset)) < 0)
+ if ((n = pwritev(bc->bc_fd, br->br_iov, br->br_iovcnt,
+ br->br_offset)) < 0)
err = errno;
else
- br->br_resid -= len;
+ br->br_resid -= n;
break;
}
i = 0;
@@ -304,7 +302,8 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf)
clen = MIN(len - boff, br->br_iov[i].iov_len -
voff);
memcpy(buf + boff,
- br->br_iov[i].iov_base + voff, clen);
+ (uint8_t *)br->br_iov[i].iov_base + voff,
+ clen);
if (clen < br->br_iov[i].iov_len - voff)
voff += clen;
else {
@@ -313,13 +312,14 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf)
}
boff += clen;
} while (boff < len);
- if (pwrite(bc->bc_fd, buf, len, br->br_offset +
- off) < 0) {
+
+ n = pwrite(bc->bc_fd, buf, len, br->br_offset + off);
+ if (n < 0) {
err = errno;
break;
}
- off += len;
- br->br_resid -= len;
+ off += n;
+ br->br_resid -= n;
}
break;
case BOP_FLUSH:
@@ -362,6 +362,12 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf)
(*br->br_callback)(br, err);
}
+static inline bool
+blockif_empty(const struct blockif_ctxt *bc)
+{
+ return (TAILQ_EMPTY(&bc->bc_pendq) && TAILQ_EMPTY(&bc->bc_busyq));
+}
+
static void *
blockif_thr(void *arg)
{
@@ -379,30 +385,21 @@ blockif_thr(void *arg)
pthread_mutex_lock(&bc->bc_mtx);
for (;;) {
- bc->bc_work_count++;
-
- /* We cannot process work if the interface is paused */
- while (!bc->bc_paused && blockif_dequeue(bc, t, &be)) {
+ while (blockif_dequeue(bc, t, &be)) {
pthread_mutex_unlock(&bc->bc_mtx);
blockif_proc(bc, be, buf);
pthread_mutex_lock(&bc->bc_mtx);
blockif_complete(bc, be);
}
- bc->bc_work_count--;
-
- /* If none of the workers are busy, notify the main thread */
- if (bc->bc_work_count == 0)
+ /* If none to work, notify the main thread */
+ if (blockif_empty(bc))
pthread_cond_broadcast(&bc->bc_work_done_cond);
/* Check ctxt status here to see if exit requested */
if (bc->bc_closing)
break;
- /* Make all worker threads wait here if the device is paused */
- while (bc->bc_paused)
- pthread_cond_wait(&bc->bc_paused_cond, &bc->bc_mtx);
-
pthread_cond_wait(&bc->bc_cond, &bc->bc_mtx);
}
pthread_mutex_unlock(&bc->bc_mtx);
@@ -414,7 +411,8 @@ blockif_thr(void *arg)
}
static void
-blockif_sigcont_handler(int signal, enum ev_type type, void *arg)
+blockif_sigcont_handler(int signal __unused, enum ev_type type __unused,
+ void *arg __unused)
{
struct blockif_sig_elem *bse;
@@ -464,12 +462,22 @@ blockif_legacy_config(nvlist_t *nvl, const char *opts)
return (pci_parse_legacy_config(nvl, cp + 1));
}
+int
+blockif_add_boot_device(struct pci_devinst *const pi,
+ struct blockif_ctxt *const bc)
+{
+ if (bc->bc_bootindex < 0)
+ return (0);
+
+ return (pci_emul_add_boot_device(pi, bc->bc_bootindex));
+}
+
struct blockif_ctxt *
blockif_open(nvlist_t *nvl, const char *ident)
{
char tname[MAXCOMLEN + 1];
char name[MAXPATHLEN];
- const char *path, *pssval, *ssval;
+ const char *path, *pssval, *ssval, *bootindex_val;
char *cp;
struct blockif_ctxt *bc;
struct stat sbuf;
@@ -478,6 +486,7 @@ blockif_open(nvlist_t *nvl, const char *ident)
int extra, fd, i, sectsz;
int ro, candelete, geom, ssopt, pssopt;
int nodelete;
+ int bootindex;
#ifndef WITHOUT_CAPSICUM
cap_rights_t rights;
@@ -491,6 +500,7 @@ blockif_open(nvlist_t *nvl, const char *ident)
ssopt = 0;
ro = 0;
nodelete = 0;
+ bootindex = -1;
if (get_config_bool_node_default(nvl, "nocache", false))
extra |= O_DIRECT;
@@ -523,6 +533,11 @@ blockif_open(nvlist_t *nvl, const char *ident)
}
}
+ bootindex_val = get_config_value_node(nvl, "bootindex");
+ if (bootindex_val != NULL) {
+ bootindex = atoi(bootindex_val);
+ }
+
path = get_config_value_node(nvl, "path");
if (path == NULL) {
EPRINTLN("Missing \"path\" for block device.");
@@ -638,12 +653,11 @@ blockif_open(nvlist_t *nvl, const char *ident)
pthread_mutex_init(&bc->bc_mtx, NULL);
pthread_cond_init(&bc->bc_cond, NULL);
bc->bc_paused = 0;
- bc->bc_work_count = 0;
- pthread_cond_init(&bc->bc_paused_cond, NULL);
pthread_cond_init(&bc->bc_work_done_cond, NULL);
TAILQ_INIT(&bc->bc_freeq);
TAILQ_INIT(&bc->bc_pendq);
TAILQ_INIT(&bc->bc_busyq);
+ bc->bc_bootindex = bootindex;
for (i = 0; i < BLOCKIF_MAXREQ; i++) {
bc->bc_reqs[i].be_status = BST_FREE;
TAILQ_INSERT_HEAD(&bc->bc_freeq, &bc->bc_reqs[i], be_link);
@@ -663,7 +677,7 @@ err:
}
static void
-blockif_resized(int fd, enum ev_type type, void *arg)
+blockif_resized(int fd, enum ev_type type __unused, void *arg)
{
struct blockif_ctxt *bc;
struct stat sb;
@@ -700,6 +714,8 @@ blockif_register_resize_callback(struct blockif_ctxt *bc, blockif_resize_cb *cb,
if (cb == NULL)
return (EINVAL);
+ err = 0;
+
pthread_mutex_lock(&bc->bc_mtx);
if (bc->bc_resize_cb != NULL) {
err = EBUSY;
@@ -737,6 +753,7 @@ blockif_request(struct blockif_ctxt *bc, struct blockif_req *breq,
err = 0;
pthread_mutex_lock(&bc->bc_mtx);
+ assert(!bc->bc_paused);
if (!TAILQ_EMPTY(&bc->bc_freeq)) {
/*
* Enqueue and inform the block i/o thread
@@ -761,7 +778,6 @@ blockif_request(struct blockif_ctxt *bc, struct blockif_req *breq,
int
blockif_read(struct blockif_ctxt *bc, struct blockif_req *breq)
{
-
assert(bc->bc_magic == BLOCKIF_SIG);
return (blockif_request(bc, breq, BOP_READ));
}
@@ -769,7 +785,6 @@ blockif_read(struct blockif_ctxt *bc, struct blockif_req *breq)
int
blockif_write(struct blockif_ctxt *bc, struct blockif_req *breq)
{
-
assert(bc->bc_magic == BLOCKIF_SIG);
return (blockif_request(bc, breq, BOP_WRITE));
}
@@ -777,7 +792,6 @@ blockif_write(struct blockif_ctxt *bc, struct blockif_req *breq)
int
blockif_flush(struct blockif_ctxt *bc, struct blockif_req *breq)
{
-
assert(bc->bc_magic == BLOCKIF_SIG);
return (blockif_request(bc, breq, BOP_FLUSH));
}
@@ -785,7 +799,6 @@ blockif_flush(struct blockif_ctxt *bc, struct blockif_req *breq)
int
blockif_delete(struct blockif_ctxt *bc, struct blockif_req *breq)
{
-
assert(bc->bc_magic == BLOCKIF_SIG);
return (blockif_request(bc, breq, BOP_DELETE));
}
@@ -917,10 +930,10 @@ blockif_chs(struct blockif_ctxt *bc, uint16_t *c, uint8_t *h, uint8_t *s)
sectors = bc->bc_size / bc->bc_sectsz;
/* Clamp the size to the largest possible with CHS */
- if (sectors > 65535UL*16*255)
- sectors = 65535UL*16*255;
+ if (sectors > 65535L * 16 * 255)
+ sectors = 65535L * 16 * 255;
- if (sectors >= 65536UL*16*63) {
+ if (sectors >= 65536L * 16 * 63) {
secpt = 255;
heads = 16;
hcyl = sectors / secpt;
@@ -955,7 +968,6 @@ blockif_chs(struct blockif_ctxt *bc, uint16_t *c, uint8_t *h, uint8_t *s)
off_t
blockif_size(struct blockif_ctxt *bc)
{
-
assert(bc->bc_magic == BLOCKIF_SIG);
return (bc->bc_size);
}
@@ -963,7 +975,6 @@ blockif_size(struct blockif_ctxt *bc)
int
blockif_sectsz(struct blockif_ctxt *bc)
{
-
assert(bc->bc_magic == BLOCKIF_SIG);
return (bc->bc_sectsz);
}
@@ -971,7 +982,6 @@ blockif_sectsz(struct blockif_ctxt *bc)
void
blockif_psectsz(struct blockif_ctxt *bc, int *size, int *off)
{
-
assert(bc->bc_magic == BLOCKIF_SIG);
*size = bc->bc_psectsz;
*off = bc->bc_psectoff;
@@ -980,7 +990,6 @@ blockif_psectsz(struct blockif_ctxt *bc, int *size, int *off)
int
blockif_queuesz(struct blockif_ctxt *bc)
{
-
assert(bc->bc_magic == BLOCKIF_SIG);
return (BLOCKIF_MAXREQ - 1);
}
@@ -988,7 +997,6 @@ blockif_queuesz(struct blockif_ctxt *bc)
int
blockif_is_ro(struct blockif_ctxt *bc)
{
-
assert(bc->bc_magic == BLOCKIF_SIG);
return (bc->bc_rdonly);
}
@@ -996,7 +1004,6 @@ blockif_is_ro(struct blockif_ctxt *bc)
int
blockif_candelete(struct blockif_ctxt *bc)
{
-
assert(bc->bc_magic == BLOCKIF_SIG);
return (bc->bc_candelete);
}
@@ -1012,12 +1019,12 @@ blockif_pause(struct blockif_ctxt *bc)
bc->bc_paused = 1;
/* The interface is paused. Wait for workers to finish their work */
- while (bc->bc_work_count)
+ while (!blockif_empty(bc))
pthread_cond_wait(&bc->bc_work_done_cond, &bc->bc_mtx);
pthread_mutex_unlock(&bc->bc_mtx);
- if (blockif_flush_bc(bc))
- fprintf(stderr, "%s: [WARN] failed to flush backing file.\r\n",
+ if (!bc->bc_rdonly && blockif_flush_bc(bc))
+ EPRINTLN("%s: [WARN] failed to flush backing file.",
__func__);
}
@@ -1029,71 +1036,6 @@ blockif_resume(struct blockif_ctxt *bc)
pthread_mutex_lock(&bc->bc_mtx);
bc->bc_paused = 0;
- /* resume the threads waiting for paused */
- pthread_cond_broadcast(&bc->bc_paused_cond);
- /* kick the threads after restore */
- pthread_cond_broadcast(&bc->bc_cond);
- pthread_mutex_unlock(&bc->bc_mtx);
-}
-
-int
-blockif_snapshot_req(struct blockif_req *br, struct vm_snapshot_meta *meta)
-{
- int i;
- struct iovec *iov;
- int ret;
-
- SNAPSHOT_VAR_OR_LEAVE(br->br_iovcnt, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(br->br_offset, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(br->br_resid, meta, ret, done);
-
- /*
- * XXX: The callback and parameter must be filled by the virtualized
- * device that uses the interface, during its init; we're not touching
- * them here.
- */
-
- /* Snapshot the iovecs. */
- for (i = 0; i < br->br_iovcnt; i++) {
- iov = &br->br_iov[i];
-
- SNAPSHOT_VAR_OR_LEAVE(iov->iov_len, meta, ret, done);
-
- /* We assume the iov is a guest-mapped address. */
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(iov->iov_base, iov->iov_len,
- false, meta, ret, done);
- }
-
-done:
- return (ret);
-}
-
-int
-blockif_snapshot(struct blockif_ctxt *bc, struct vm_snapshot_meta *meta)
-{
- int ret;
-
- if (bc->bc_paused == 0) {
- fprintf(stderr, "%s: Snapshot failed: "
- "interface not paused.\r\n", __func__);
- return (ENXIO);
- }
-
- pthread_mutex_lock(&bc->bc_mtx);
-
- SNAPSHOT_VAR_OR_LEAVE(bc->bc_magic, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(bc->bc_ischr, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(bc->bc_isgeom, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(bc->bc_candelete, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(bc->bc_rdonly, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(bc->bc_size, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(bc->bc_sectsz, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(bc->bc_psectsz, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(bc->bc_psectoff, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(bc->bc_closing, meta, ret, done);
-
-done:
pthread_mutex_unlock(&bc->bc_mtx);
- return (ret);
}
-#endif
+#endif /* BHYVE_SNAPSHOT */
diff --git a/usr.sbin/bhyve/block_if.h b/usr.sbin/bhyve/block_if.h
index 0407ff43cf94..9a1a65a1bfe9 100644
--- a/usr.sbin/bhyve/block_if.h
+++ b/usr.sbin/bhyve/block_if.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Peter Grehan <grehan@freebsd.org>
* 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$
*/
/*
@@ -62,11 +60,13 @@ struct blockif_req {
struct iovec br_iov[BLOCKIF_IOV_MAX];
};
+struct pci_devinst;
struct blockif_ctxt;
typedef void blockif_resize_cb(struct blockif_ctxt *, void *, size_t);
int blockif_legacy_config(nvlist_t *nvl, const char *opts);
+int blockif_add_boot_device(struct pci_devinst *const pi, struct blockif_ctxt *const bc);
struct blockif_ctxt *blockif_open(nvlist_t *nvl, const char *ident);
int blockif_register_resize_callback(struct blockif_ctxt *bc,
blockif_resize_cb *cb, void *cb_arg);
@@ -87,10 +87,6 @@ int blockif_close(struct blockif_ctxt *bc);
#ifdef BHYVE_SNAPSHOT
void blockif_pause(struct blockif_ctxt *bc);
void blockif_resume(struct blockif_ctxt *bc);
-int blockif_snapshot_req(struct blockif_req *br,
- struct vm_snapshot_meta *meta);
-int blockif_snapshot(struct blockif_ctxt *bc,
- struct vm_snapshot_meta *meta);
#endif
#endif /* _BLOCK_IF_H_ */
diff --git a/usr.sbin/bhyve/bootrom.c b/usr.sbin/bhyve/bootrom.c
index 2406d4539e55..1d461ba76597 100644
--- a/usr.sbin/bhyve/bootrom.c
+++ b/usr.sbin/bhyve/bootrom.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Neel Natu <neel@freebsd.org>
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/param.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -84,8 +82,8 @@ static struct bootrom_var_state {
* that the Firmware Volume area is writable and persistent.
*/
static int
-bootrom_var_mem_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
- int size, uint64_t *val, void *arg1, long arg2)
+bootrom_var_mem_handler(struct vcpu *vcpu __unused, int dir, uint64_t addr,
+ int size, uint64_t *val, void *arg1 __unused, long arg2 __unused)
{
off_t offset;
@@ -120,12 +118,15 @@ bootrom_var_mem_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
void
init_bootrom(struct vmctx *ctx)
{
+ vm_paddr_t highmem;
+
romptr = vm_create_devmem(ctx, VM_BOOTROM, "bootrom", BOOTROM_SIZE);
if (romptr == MAP_FAILED)
err(4, "%s: vm_create_devmem", __func__);
- gpa_base = (1ULL << 32) - BOOTROM_SIZE;
+ highmem = vm_get_highmem_base(ctx);
+ gpa_base = highmem - BOOTROM_SIZE;
gpa_allocbot = gpa_base;
- gpa_alloctop = (1ULL << 32) - 1;
+ gpa_alloctop = highmem - 1;
}
int
@@ -239,14 +240,14 @@ bootrom_loadrom(struct vmctx *ctx, const nvlist_t *nvl)
if (varfile != NULL) {
varfd = open(varfile, O_RDWR);
if (varfd < 0) {
- fprintf(stderr, "Error opening bootrom variable file "
- "\"%s\": %s\n", varfile, strerror(errno));
+ EPRINTLN("Error opening bootrom variable file "
+ "\"%s\": %s", varfile, strerror(errno));
goto done;
}
if (fstat(varfd, &sbuf) < 0) {
- fprintf(stderr,
- "Could not fstat bootrom variable file \"%s\": %s\n",
+ EPRINTLN(
+ "Could not fstat bootrom variable file \"%s\": %s",
varfile, strerror(errno));
goto done;
}
@@ -256,7 +257,7 @@ bootrom_loadrom(struct vmctx *ctx, const nvlist_t *nvl)
if (var_size > BOOTROM_SIZE ||
(var_size != 0 && var_size < PAGE_SIZE)) {
- fprintf(stderr, "Invalid bootrom variable size %ld\n",
+ EPRINTLN("Invalid bootrom variable size %ld",
var_size);
goto done;
}
@@ -264,8 +265,8 @@ bootrom_loadrom(struct vmctx *ctx, const nvlist_t *nvl)
total_size = rom_size + var_size;
if (total_size > BOOTROM_SIZE) {
- fprintf(stderr, "Invalid bootrom and variable aggregate size "
- "%ld\n", total_size);
+ EPRINTLN("Invalid bootrom and variable aggregate size %ld",
+ total_size);
goto done;
}
diff --git a/usr.sbin/bhyve/bootrom.h b/usr.sbin/bhyve/bootrom.h
index f718d5728c84..d22ac3718fa2 100644
--- a/usr.sbin/bhyve/bootrom.h
+++ b/usr.sbin/bhyve/bootrom.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Neel Natu <neel@freebsd.org>
* 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 _BOOTROM_H_
diff --git a/usr.sbin/bhyve/config.c b/usr.sbin/bhyve/config.c
index cdea2f4fed01..cc9311624e5e 100644
--- a/usr.sbin/bhyve/config.c
+++ b/usr.sbin/bhyve/config.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021 John H. Baldwin <jhb@FreeBSD.org>
*
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <err.h>
#include <stdio.h>
@@ -65,7 +63,17 @@ _lookup_config_node(nvlist_t *parent, const char *path, bool create)
break;
}
if (nvlist_exists_nvlist(nvl, name))
- nvl = (nvlist_t *)nvlist_get_nvlist(nvl, name);
+ /*
+ * XXX-MJ it is incorrect to cast away the const
+ * qualifier like this since the contract with nvlist
+ * says that values are immutable, and some consumers
+ * will indeed add nodes to the returned nvlist. In
+ * practice, however, it appears to be harmless with the
+ * current nvlist implementation, so we just live with
+ * it until the implementation is reworked.
+ */
+ nvl = __DECONST(nvlist_t *,
+ nvlist_get_nvlist(nvl, name));
else if (nvlist_exists(nvl, name)) {
for (copy = tofree; copy < name; copy++)
if (*copy == '\0')
@@ -76,6 +84,10 @@ _lookup_config_node(nvlist_t *parent, const char *path, bool create)
nvl = NULL;
break;
} else if (create) {
+ /*
+ * XXX-MJ as with the case above, "new_nvl" shouldn't be
+ * mutated after its ownership is given to "nvl".
+ */
new_nvl = nvlist_create(0);
if (new_nvl == NULL)
errx(4, "Failed to allocate memory");
@@ -130,7 +142,7 @@ set_config_value_node(nvlist_t *parent, const char *name, const char *value)
nvlist_free_string(parent, name);
else if (nvlist_exists(parent, name))
errx(4,
- "Attemping to add value %s to existing node %s of list %p",
+ "Attempting to add value %s to existing node %s of list %p",
value, name, parent);
nvlist_add_string(parent, name, value);
}
@@ -305,7 +317,7 @@ _expand_config_value(const char *value, int depth)
return (valbuf);
}
-const char *
+static const char *
expand_config_value(const char *value)
{
static char *valbuf;
@@ -346,7 +358,7 @@ get_config_value_node(const nvlist_t *parent, const char *name)
return (expand_config_value(nvlist_get_string(parent, name)));
}
-bool
+static bool
_bool_value(const char *name, const char *value)
{
diff --git a/usr.sbin/bhyve/config.h b/usr.sbin/bhyve/config.h
index 8d3f6f90b2dc..35882e65ace7 100644
--- a/usr.sbin/bhyve/config.h
+++ b/usr.sbin/bhyve/config.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021 John H. Baldwin <jhb@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 __CONFIG_H__
@@ -38,7 +36,7 @@
* The database only stores string values. Callers should parse
* values into other types if needed. String values can reference
* other configuration variables using a '%(name)' syntax. In this
- * case, the name must be the the full path of the configuration
+ * case, the name must be the full path of the configuration
* variable. The % character can be escaped with a preceding \ to
* avoid expansion. Any \ characters must be escaped.
*
diff --git a/usr.sbin/bhyve/console.c b/usr.sbin/bhyve/console.c
index d845df754048..1440c0604787 100644
--- a/usr.sbin/bhyve/console.c
+++ b/usr.sbin/bhyve/console.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include "bhyvegc.h"
diff --git a/usr.sbin/bhyve/console.h b/usr.sbin/bhyve/console.h
index 8029c28ab8a9..70935cb6e58e 100644
--- a/usr.sbin/bhyve/console.h
+++ b/usr.sbin/bhyve/console.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* 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 _CONSOLE_H_
diff --git a/usr.sbin/bhyve/debug.h b/usr.sbin/bhyve/debug.h
index f63e0a9ef129..ea866f283e41 100644
--- a/usr.sbin/bhyve/debug.h
+++ b/usr.sbin/bhyve/debug.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Vincenzo Maffione <vmaffione@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 _DEBUG_H_
diff --git a/usr.sbin/bhyve/gdb.c b/usr.sbin/bhyve/gdb.c
index 3842a1d58dec..fbd62413e2c2 100644
--- a/usr.sbin/bhyve/gdb.c
+++ b/usr.sbin/bhyve/gdb.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2017-2018 John H. Baldwin <jhb@FreeBSD.org>
*
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
@@ -37,6 +34,8 @@ __FBSDID("$FreeBSD$");
#include <sys/mman.h>
#include <sys/queue.h>
#include <sys/socket.h>
+#include <sys/stat.h>
+
#include <machine/atomic.h>
#include <machine/specialreg.h>
#include <machine/vmm.h>
@@ -61,16 +60,26 @@ __FBSDID("$FreeBSD$");
#include "bhyverun.h"
#include "config.h"
+#include "debug.h"
#include "gdb.h"
#include "mem.h"
#include "mevent.h"
+#define _PATH_GDB_XML "/usr/share/bhyve/gdb"
+
/*
* GDB_SIGNAL_* numbers are part of the GDB remote protocol. Most stops
* use SIGTRAP.
*/
#define GDB_SIGNAL_TRAP 5
+#define GDB_BP_SIZE 1
+#define GDB_BP_INSTR (uint8_t []){0xcc}
+#define GDB_PC_REGNAME VM_REG_GUEST_RIP
+
+_Static_assert(sizeof(GDB_BP_INSTR) == GDB_BP_SIZE,
+ "GDB_BP_INSTR has wrong size");
+
static void gdb_resume_vcpus(void);
static void check_command(int fd);
@@ -80,6 +89,7 @@ static cpuset_t vcpus_active, vcpus_suspended, vcpus_waiting;
static pthread_mutex_t gdb_lock;
static pthread_cond_t idle_vcpus;
static bool first_stop, report_next_stop, swbreak_enabled;
+static int xml_dfd = -1;
/*
* An I/O buffer contains 'capacity' bytes of room at 'data'. For a
@@ -97,7 +107,7 @@ struct io_buffer {
struct breakpoint {
uint64_t gpa;
- uint8_t shadow_inst;
+ uint8_t shadow_inst[GDB_BP_SIZE];
TAILQ_ENTRY(breakpoint) link;
};
@@ -132,63 +142,57 @@ static struct vmctx *ctx;
static int cur_fd = -1;
static TAILQ_HEAD(, breakpoint) breakpoints;
static struct vcpu_state *vcpu_state;
+static struct vcpu **vcpus;
static int cur_vcpu, stopped_vcpu;
static bool gdb_active = false;
-const int gdb_regset[] = {
- VM_REG_GUEST_RAX,
- VM_REG_GUEST_RBX,
- VM_REG_GUEST_RCX,
- VM_REG_GUEST_RDX,
- VM_REG_GUEST_RSI,
- VM_REG_GUEST_RDI,
- VM_REG_GUEST_RBP,
- VM_REG_GUEST_RSP,
- VM_REG_GUEST_R8,
- VM_REG_GUEST_R9,
- VM_REG_GUEST_R10,
- VM_REG_GUEST_R11,
- VM_REG_GUEST_R12,
- VM_REG_GUEST_R13,
- VM_REG_GUEST_R14,
- VM_REG_GUEST_R15,
- VM_REG_GUEST_RIP,
- VM_REG_GUEST_RFLAGS,
- VM_REG_GUEST_CS,
- VM_REG_GUEST_SS,
- VM_REG_GUEST_DS,
- VM_REG_GUEST_ES,
- VM_REG_GUEST_FS,
- VM_REG_GUEST_GS
-};
-
-const int gdb_regsize[] = {
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 4,
- 4,
- 4,
- 4,
- 4,
- 4,
- 4
+static const struct gdb_reg {
+ enum vm_reg_name id;
+ int size;
+} gdb_regset[] = {
+ { .id = VM_REG_GUEST_RAX, .size = 8 },
+ { .id = VM_REG_GUEST_RBX, .size = 8 },
+ { .id = VM_REG_GUEST_RCX, .size = 8 },
+ { .id = VM_REG_GUEST_RDX, .size = 8 },
+ { .id = VM_REG_GUEST_RSI, .size = 8 },
+ { .id = VM_REG_GUEST_RDI, .size = 8 },
+ { .id = VM_REG_GUEST_RBP, .size = 8 },
+ { .id = VM_REG_GUEST_RSP, .size = 8 },
+ { .id = VM_REG_GUEST_R8, .size = 8 },
+ { .id = VM_REG_GUEST_R9, .size = 8 },
+ { .id = VM_REG_GUEST_R10, .size = 8 },
+ { .id = VM_REG_GUEST_R11, .size = 8 },
+ { .id = VM_REG_GUEST_R12, .size = 8 },
+ { .id = VM_REG_GUEST_R13, .size = 8 },
+ { .id = VM_REG_GUEST_R14, .size = 8 },
+ { .id = VM_REG_GUEST_R15, .size = 8 },
+ { .id = VM_REG_GUEST_RIP, .size = 8 },
+ { .id = VM_REG_GUEST_RFLAGS, .size = 4 },
+ { .id = VM_REG_GUEST_CS, .size = 4 },
+ { .id = VM_REG_GUEST_SS, .size = 4 },
+ { .id = VM_REG_GUEST_DS, .size = 4 },
+ { .id = VM_REG_GUEST_ES, .size = 4 },
+ { .id = VM_REG_GUEST_FS, .size = 4 },
+ { .id = VM_REG_GUEST_GS, .size = 4 },
+ /*
+ * Registers past this point are not included in a reply to a 'g' query,
+ * to provide compatibility with debuggers that do not fetch a target
+ * description. The debugger can query them individually with 'p' if it
+ * knows about them.
+ */
+#define GDB_REG_FIRST_EXT VM_REG_GUEST_FS_BASE
+ { .id = VM_REG_GUEST_FS_BASE, .size = 8 },
+ { .id = VM_REG_GUEST_GS_BASE, .size = 8 },
+ { .id = VM_REG_GUEST_KGS_BASE, .size = 8 },
+ { .id = VM_REG_GUEST_CR0, .size = 8 },
+ { .id = VM_REG_GUEST_CR2, .size = 8 },
+ { .id = VM_REG_GUEST_CR3, .size = 8 },
+ { .id = VM_REG_GUEST_CR4, .size = 8 },
+ { .id = VM_REG_GUEST_TPR, .size = 8 },
+ { .id = VM_REG_GUEST_EFER, .size = 8 },
};
+#define GDB_LOG
#ifdef GDB_LOG
#include <stdarg.h>
#include <stdio.h>
@@ -223,7 +227,7 @@ debug(const char *fmt, ...)
static void remove_all_sw_breakpoints(void);
static int
-guest_paging_info(int vcpu, struct vm_guest_paging *paging)
+guest_paging_info(struct vcpu *vcpu, struct vm_guest_paging *paging)
{
uint64_t regs[4];
const int regset[4] = {
@@ -233,7 +237,7 @@ guest_paging_info(int vcpu, struct vm_guest_paging *paging)
VM_REG_GUEST_EFER
};
- if (vm_get_register_set(ctx, vcpu, nitems(regset), regset, regs) == -1)
+ if (vm_get_register_set(vcpu, nitems(regset), regset, regs) == -1)
return (-1);
/*
@@ -268,7 +272,7 @@ guest_paging_info(int vcpu, struct vm_guest_paging *paging)
* return -1.
*/
static int
-guest_vaddr2paddr(int vcpu, uint64_t vaddr, uint64_t *paddr)
+guest_vaddr2paddr(struct vcpu *vcpu, uint64_t vaddr, uint64_t *paddr)
{
struct vm_guest_paging paging;
int fault;
@@ -280,7 +284,7 @@ guest_vaddr2paddr(int vcpu, uint64_t vaddr, uint64_t *paddr)
* Always use PROT_READ. We really care if the VA is
* accessible, not if the current vCPU can write.
*/
- if (vm_gla2gpa_nofault(ctx, vcpu, &paging, vaddr, PROT_READ, paddr,
+ if (vm_gla2gpa_nofault(vcpu, &paging, vaddr, PROT_READ, paddr,
&fault) == -1)
return (-1);
if (fault)
@@ -288,6 +292,12 @@ guest_vaddr2paddr(int vcpu, uint64_t vaddr, uint64_t *paddr)
return (1);
}
+static uint64_t
+guest_pc(struct vm_exit *vme)
+{
+ return (vme->rip);
+}
+
static void
io_buffer_reset(struct io_buffer *io)
{
@@ -730,17 +740,55 @@ gdb_finish_suspend_vcpus(void)
* as long as the debug server keeps them suspended.
*/
static void
-_gdb_cpu_suspend(int vcpu, bool report_stop)
+_gdb_cpu_suspend(struct vcpu *vcpu, bool report_stop)
{
+ int vcpuid = vcpu_id(vcpu);
- debug("$vCPU %d suspending\n", vcpu);
- CPU_SET(vcpu, &vcpus_waiting);
+ debug("$vCPU %d suspending\n", vcpuid);
+ CPU_SET(vcpuid, &vcpus_waiting);
if (report_stop && CPU_CMP(&vcpus_waiting, &vcpus_suspended) == 0)
gdb_finish_suspend_vcpus();
- while (CPU_ISSET(vcpu, &vcpus_suspended))
+ while (CPU_ISSET(vcpuid, &vcpus_suspended))
pthread_cond_wait(&idle_vcpus, &gdb_lock);
- CPU_CLR(vcpu, &vcpus_waiting);
- debug("$vCPU %d resuming\n", vcpu);
+ CPU_CLR(vcpuid, &vcpus_waiting);
+ debug("$vCPU %d resuming\n", vcpuid);
+}
+
+/*
+ * Requests vCPU single-stepping using a
+ * VMEXIT suitable for the host platform.
+ */
+static int
+_gdb_set_step(struct vcpu *vcpu, int val)
+{
+ int error;
+
+ /*
+ * If the MTRAP cap fails, we are running on an AMD host.
+ * In that case, we request DB exits caused by RFLAGS.TF.
+ */
+ error = vm_set_capability(vcpu, VM_CAP_MTRAP_EXIT, val);
+ if (error != 0)
+ error = vm_set_capability(vcpu, VM_CAP_RFLAGS_TF, val);
+ if (error == 0)
+ (void)vm_set_capability(vcpu, VM_CAP_MASK_HWINTR, val);
+
+ return (error);
+}
+
+/*
+ * Checks whether single-stepping is enabled for a given vCPU.
+ */
+static int
+_gdb_check_step(struct vcpu *vcpu)
+{
+ int val;
+
+ if (vm_get_capability(vcpu, VM_CAP_MTRAP_EXIT, &val) != 0) {
+ if (vm_get_capability(vcpu, VM_CAP_RFLAGS_TF, &val) != 0)
+ return -1;
+ }
+ return 0;
}
/*
@@ -748,18 +796,22 @@ _gdb_cpu_suspend(int vcpu, bool report_stop)
* debug server about the new thread.
*/
void
-gdb_cpu_add(int vcpu)
+gdb_cpu_add(struct vcpu *vcpu)
{
+ int vcpuid;
if (!gdb_active)
return;
- debug("$vCPU %d starting\n", vcpu);
+ vcpuid = vcpu_id(vcpu);
+ debug("$vCPU %d starting\n", vcpuid);
pthread_mutex_lock(&gdb_lock);
- assert(vcpu < guest_ncpus);
- CPU_SET(vcpu, &vcpus_active);
+ assert(vcpuid < guest_ncpus);
+ assert(vcpus[vcpuid] == NULL);
+ vcpus[vcpuid] = vcpu;
+ CPU_SET(vcpuid, &vcpus_active);
if (!TAILQ_EMPTY(&breakpoints)) {
- vm_set_capability(ctx, vcpu, VM_CAP_BPT_EXIT, 1);
- debug("$vCPU %d enabled breakpoint exits\n", vcpu);
+ vm_set_capability(vcpu, VM_CAP_BPT_EXIT, 1);
+ debug("$vCPU %d enabled breakpoint exits\n", vcpuid);
}
/*
@@ -768,7 +820,7 @@ gdb_cpu_add(int vcpu)
* executing the first instruction.
*/
if (!CPU_EMPTY(&vcpus_suspended)) {
- CPU_SET(vcpu, &vcpus_suspended);
+ CPU_SET(vcpuid, &vcpus_suspended);
_gdb_cpu_suspend(vcpu, false);
}
pthread_mutex_unlock(&gdb_lock);
@@ -779,12 +831,12 @@ gdb_cpu_add(int vcpu)
* if the vCPU is marked as stepping.
*/
static void
-gdb_cpu_resume(int vcpu)
+gdb_cpu_resume(struct vcpu *vcpu)
{
struct vcpu_state *vs;
int error;
- vs = &vcpu_state[vcpu];
+ vs = &vcpu_state[vcpu_id(vcpu)];
/*
* Any pending event should already be reported before
@@ -793,7 +845,7 @@ gdb_cpu_resume(int vcpu)
assert(vs->hit_swbreak == false);
assert(vs->stepped == false);
if (vs->stepping) {
- error = vm_set_capability(ctx, vcpu, VM_CAP_MTRAP_EXIT, 1);
+ error = _gdb_set_step(vcpu, 1);
assert(error == 0);
}
}
@@ -804,7 +856,7 @@ gdb_cpu_resume(int vcpu)
* to a guest-wide suspend such as Ctrl-C or the stop on attach.
*/
void
-gdb_cpu_suspend(int vcpu)
+gdb_cpu_suspend(struct vcpu *vcpu)
{
if (!gdb_active)
@@ -822,33 +874,35 @@ gdb_suspend_vcpus(void)
assert(pthread_mutex_isowned_np(&gdb_lock));
debug("suspending all CPUs\n");
vcpus_suspended = vcpus_active;
- vm_suspend_cpu(ctx, -1);
+ vm_suspend_all_cpus(ctx);
if (CPU_CMP(&vcpus_waiting, &vcpus_suspended) == 0)
gdb_finish_suspend_vcpus();
}
/*
- * Handler for VM_EXITCODE_MTRAP reported when a vCPU single-steps via
- * the VT-x-specific MTRAP exit.
+ * Invoked each time a vmexit handler needs to step a vCPU.
+ * Handles MTRAP and RFLAGS.TF vmexits.
*/
-void
-gdb_cpu_mtrap(int vcpu)
+static void
+gdb_cpu_step(struct vcpu *vcpu)
{
struct vcpu_state *vs;
+ int vcpuid = vcpu_id(vcpu);
+ int error;
- if (!gdb_active)
- return;
- debug("$vCPU %d MTRAP\n", vcpu);
+ debug("$vCPU %d stepped\n", vcpuid);
pthread_mutex_lock(&gdb_lock);
- vs = &vcpu_state[vcpu];
+ vs = &vcpu_state[vcpuid];
if (vs->stepping) {
vs->stepping = false;
vs->stepped = true;
- vm_set_capability(ctx, vcpu, VM_CAP_MTRAP_EXIT, 0);
+ error = _gdb_set_step(vcpu, 0);
+ assert(error == 0);
+
while (vs->stepped) {
if (stopped_vcpu == -1) {
- debug("$vCPU %d reporting step\n", vcpu);
- stopped_vcpu = vcpu;
+ debug("$vCPU %d reporting step\n", vcpuid);
+ stopped_vcpu = vcpuid;
gdb_suspend_vcpus();
}
_gdb_cpu_suspend(vcpu, true);
@@ -858,6 +912,34 @@ gdb_cpu_mtrap(int vcpu)
pthread_mutex_unlock(&gdb_lock);
}
+/*
+ * A general handler for VM_EXITCODE_DB.
+ * Handles RFLAGS.TF exits on AMD SVM.
+ */
+void
+gdb_cpu_debug(struct vcpu *vcpu, struct vm_exit *vmexit)
+{
+ if (!gdb_active)
+ return;
+
+ /* RFLAGS.TF exit? */
+ if (vmexit->u.dbg.trace_trap) {
+ gdb_cpu_step(vcpu);
+ }
+}
+
+/*
+ * Handler for VM_EXITCODE_MTRAP reported when a vCPU single-steps via
+ * the VT-x-specific MTRAP exit.
+ */
+void
+gdb_cpu_mtrap(struct vcpu *vcpu)
+{
+ if (!gdb_active)
+ return;
+ gdb_cpu_step(vcpu);
+}
+
static struct breakpoint *
find_breakpoint(uint64_t gpa)
{
@@ -871,33 +953,34 @@ find_breakpoint(uint64_t gpa)
}
void
-gdb_cpu_breakpoint(int vcpu, struct vm_exit *vmexit)
+gdb_cpu_breakpoint(struct vcpu *vcpu, struct vm_exit *vmexit)
{
struct breakpoint *bp;
struct vcpu_state *vs;
uint64_t gpa;
- int error;
+ int error, vcpuid;
if (!gdb_active) {
- fprintf(stderr, "vm_loop: unexpected VMEXIT_DEBUG\n");
+ EPRINTLN("vm_loop: unexpected VMEXIT_DEBUG");
exit(4);
}
+ vcpuid = vcpu_id(vcpu);
pthread_mutex_lock(&gdb_lock);
- error = guest_vaddr2paddr(vcpu, vmexit->rip, &gpa);
+ error = guest_vaddr2paddr(vcpu, guest_pc(vmexit), &gpa);
assert(error == 1);
bp = find_breakpoint(gpa);
if (bp != NULL) {
- vs = &vcpu_state[vcpu];
+ vs = &vcpu_state[vcpuid];
assert(vs->stepping == false);
assert(vs->stepped == false);
assert(vs->hit_swbreak == false);
vs->hit_swbreak = true;
- vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, vmexit->rip);
+ vm_set_register(vcpu, GDB_PC_REGNAME, guest_pc(vmexit));
for (;;) {
if (stopped_vcpu == -1) {
- debug("$vCPU %d reporting breakpoint at rip %#lx\n", vcpu,
- vmexit->rip);
- stopped_vcpu = vcpu;
+ debug("$vCPU %d reporting breakpoint at rip %#lx\n",
+ vcpuid, guest_pc(vmexit));
+ stopped_vcpu = vcpuid;
gdb_suspend_vcpus();
}
_gdb_cpu_suspend(vcpu, true);
@@ -914,31 +997,32 @@ gdb_cpu_breakpoint(int vcpu, struct vm_exit *vmexit)
}
gdb_cpu_resume(vcpu);
} else {
- debug("$vCPU %d injecting breakpoint at rip %#lx\n", vcpu,
- vmexit->rip);
- error = vm_set_register(ctx, vcpu,
- VM_REG_GUEST_ENTRY_INST_LENGTH, vmexit->u.bpt.inst_length);
+ debug("$vCPU %d injecting breakpoint at rip %#lx\n", vcpuid,
+ guest_pc(vmexit));
+ error = vm_set_register(vcpu, VM_REG_GUEST_ENTRY_INST_LENGTH,
+ vmexit->u.bpt.inst_length);
assert(error == 0);
- error = vm_inject_exception(ctx, vcpu, IDT_BP, 0, 0, 0);
+ error = vm_inject_exception(vcpu, IDT_BP, 0, 0, 0);
assert(error == 0);
}
pthread_mutex_unlock(&gdb_lock);
}
static bool
-gdb_step_vcpu(int vcpu)
+gdb_step_vcpu(struct vcpu *vcpu)
{
- int error, val;
+ int error, vcpuid;
- debug("$vCPU %d step\n", vcpu);
- error = vm_get_capability(ctx, vcpu, VM_CAP_MTRAP_EXIT, &val);
+ vcpuid = vcpu_id(vcpu);
+ debug("$vCPU %d step\n", vcpuid);
+ error = _gdb_check_step(vcpu);
if (error < 0)
return (false);
discard_stop();
- vcpu_state[vcpu].stepping = true;
- vm_resume_cpu(ctx, vcpu);
- CPU_CLR(vcpu, &vcpus_suspended);
+ vcpu_state[vcpuid].stepping = true;
+ vm_resume_cpu(vcpu);
+ CPU_CLR(vcpuid, &vcpus_suspended);
pthread_cond_broadcast(&idle_vcpus);
return (true);
}
@@ -948,7 +1032,7 @@ gdb_resume_vcpus(void)
{
assert(pthread_mutex_isowned_np(&gdb_lock));
- vm_resume_cpu(ctx, -1);
+ vm_resume_all_cpus(ctx);
debug("resuming all CPUs\n");
CPU_ZERO(&vcpus_suspended);
pthread_cond_broadcast(&idle_vcpus);
@@ -958,16 +1042,45 @@ static void
gdb_read_regs(void)
{
uint64_t regvals[nitems(gdb_regset)];
- int i;
+ int regnums[nitems(gdb_regset)];
+
+ for (size_t i = 0; i < nitems(gdb_regset); i++)
+ regnums[i] = gdb_regset[i].id;
+ if (vm_get_register_set(vcpus[cur_vcpu], nitems(gdb_regset),
+ regnums, regvals) == -1) {
+ send_error(errno);
+ return;
+ }
+
+ start_packet();
+ for (size_t i = 0; i < nitems(gdb_regset); i++) {
+ if (gdb_regset[i].id == GDB_REG_FIRST_EXT)
+ break;
+ append_unsigned_native(regvals[i], gdb_regset[i].size);
+ }
+ finish_packet();
+}
+
+static void
+gdb_read_one_reg(const uint8_t *data, size_t len)
+{
+ uint64_t regval;
+ uintmax_t reg;
+
+ reg = parse_integer(data, len);
+ if (reg >= nitems(gdb_regset)) {
+ send_error(EINVAL);
+ return;
+ }
- if (vm_get_register_set(ctx, cur_vcpu, nitems(gdb_regset),
- gdb_regset, regvals) == -1) {
+ if (vm_get_register(vcpus[cur_vcpu], gdb_regset[reg].id, &regval) ==
+ -1) {
send_error(errno);
return;
}
+
start_packet();
- for (i = 0; i < nitems(regvals); i++)
- append_unsigned_native(regvals[i], gdb_regsize[i]);
+ append_unsigned_native(regval, gdb_regset[reg].size);
finish_packet();
}
@@ -980,6 +1093,8 @@ gdb_read_mem(const uint8_t *data, size_t len)
bool started;
int error;
+ assert(len >= 1);
+
/* Skip 'm' */
data += 1;
len -= 1;
@@ -999,7 +1114,7 @@ gdb_read_mem(const uint8_t *data, size_t len)
started = false;
while (resid > 0) {
- error = guest_vaddr2paddr(cur_vcpu, gva, &gpa);
+ error = guest_vaddr2paddr(vcpus[cur_vcpu], gva, &gpa);
if (error == -1) {
if (started)
finish_packet();
@@ -1051,7 +1166,7 @@ gdb_read_mem(const uint8_t *data, size_t len)
bytes = 2;
else
bytes = 4;
- error = read_mem(ctx, cur_vcpu, gpa, &val,
+ error = read_mem(vcpus[cur_vcpu], gpa, &val,
bytes);
if (error == 0) {
if (!started) {
@@ -1091,6 +1206,8 @@ gdb_write_mem(const uint8_t *data, size_t len)
size_t resid, todo, bytes;
int error;
+ assert(len >= 1);
+
/* Skip 'M' */
data += 1;
len -= 1;
@@ -1122,7 +1239,7 @@ gdb_write_mem(const uint8_t *data, size_t len)
}
while (resid > 0) {
- error = guest_vaddr2paddr(cur_vcpu, gva, &gpa);
+ error = guest_vaddr2paddr(vcpus[cur_vcpu], gva, &gpa);
if (error == -1) {
send_error(errno);
return;
@@ -1171,7 +1288,7 @@ gdb_write_mem(const uint8_t *data, size_t len)
bytes = 4;
val = be32toh(parse_integer(data, 8));
}
- error = write_mem(ctx, cur_vcpu, gpa, val,
+ error = write_mem(vcpus[cur_vcpu], gpa, val,
bytes);
if (error == 0) {
gpa += bytes;
@@ -1202,7 +1319,7 @@ set_breakpoint_caps(bool enable)
while (!CPU_EMPTY(&mask)) {
vcpu = CPU_FFS(&mask) - 1;
CPU_CLR(vcpu, &mask);
- if (vm_set_capability(ctx, vcpu, VM_CAP_BPT_EXIT,
+ if (vm_set_capability(vcpus[vcpu], VM_CAP_BPT_EXIT,
enable ? 1 : 0) < 0)
return (false);
debug("$vCPU %d %sabled breakpoint exits\n", vcpu,
@@ -1222,8 +1339,8 @@ remove_all_sw_breakpoints(void)
TAILQ_FOREACH_SAFE(bp, &breakpoints, link, nbp) {
debug("remove breakpoint at %#lx\n", bp->gpa);
- cp = paddr_guest2host(ctx, bp->gpa, 1);
- *cp = bp->shadow_inst;
+ cp = paddr_guest2host(ctx, bp->gpa, sizeof(bp->shadow_inst));
+ memcpy(cp, bp->shadow_inst, sizeof(bp->shadow_inst));
TAILQ_REMOVE(&breakpoints, bp, link);
free(bp);
}
@@ -1239,12 +1356,12 @@ update_sw_breakpoint(uint64_t gva, int kind, bool insert)
uint8_t *cp;
int error;
- if (kind != 1) {
+ if (kind != GDB_BP_SIZE) {
send_error(EINVAL);
return;
}
- error = guest_vaddr2paddr(cur_vcpu, gva, &gpa);
+ error = guest_vaddr2paddr(vcpus[cur_vcpu], gva, &gpa);
if (error == -1) {
send_error(errno);
return;
@@ -1254,7 +1371,7 @@ update_sw_breakpoint(uint64_t gva, int kind, bool insert)
return;
}
- cp = paddr_guest2host(ctx, gpa, 1);
+ cp = paddr_guest2host(ctx, gpa, sizeof(bp->shadow_inst));
/* Only permit breakpoints in guest RAM. */
if (cp == NULL) {
@@ -1278,15 +1395,15 @@ update_sw_breakpoint(uint64_t gva, int kind, bool insert)
}
bp = malloc(sizeof(*bp));
bp->gpa = gpa;
- bp->shadow_inst = *cp;
- *cp = 0xcc; /* INT 3 */
+ memcpy(bp->shadow_inst, cp, sizeof(bp->shadow_inst));
+ memcpy(cp, GDB_BP_INSTR, sizeof(bp->shadow_inst));
TAILQ_INSERT_TAIL(&breakpoints, bp, link);
debug("new breakpoint at %#lx\n", gpa);
}
} else {
if (bp != NULL) {
debug("remove breakpoint at %#lx\n", gpa);
- *cp = bp->shadow_inst;
+ memcpy(cp, bp->shadow_inst, sizeof(bp->shadow_inst));
TAILQ_REMOVE(&breakpoints, bp, link);
free(bp);
if (TAILQ_EMPTY(&breakpoints))
@@ -1428,6 +1545,7 @@ check_features(const uint8_t *data, size_t len)
/* This is an arbitrary limit. */
append_string("PacketSize=4096");
append_string(";swbreak+");
+ append_string(";qXfer:features:read+");
finish_packet();
}
@@ -1485,7 +1603,7 @@ gdb_query(const uint8_t *data, size_t len)
data += strlen("qThreadExtraInfo");
len -= strlen("qThreadExtraInfo");
- if (*data != ',') {
+ if (len == 0 || *data != ',') {
send_error(EINVAL);
return;
}
@@ -1499,6 +1617,71 @@ gdb_query(const uint8_t *data, size_t len)
start_packet();
append_asciihex(buf);
finish_packet();
+ } else if (command_equals(data, len, "qXfer:features:read:")) {
+ struct stat sb;
+ const char *xml;
+ const uint8_t *pathend;
+ char buf[64], path[PATH_MAX];
+ size_t xmllen;
+ unsigned int doff, dlen;
+ int fd;
+
+ data += strlen("qXfer:features:read:");
+ len -= strlen("qXfer:features:read:");
+
+ pathend = memchr(data, ':', len);
+ if (pathend == NULL ||
+ (size_t)(pathend - data) >= sizeof(path) - 1) {
+ send_error(EINVAL);
+ return;
+ }
+ memcpy(path, data, pathend - data);
+ path[pathend - data] = '\0';
+ data += (pathend - data) + 1;
+ len -= (pathend - data) + 1;
+
+ if (len > sizeof(buf) - 1) {
+ send_error(EINVAL);
+ return;
+ }
+ memcpy(buf, data, len);
+ buf[len] = '\0';
+ if (sscanf(buf, "%x,%x", &doff, &dlen) != 2) {
+ send_error(EINVAL);
+ return;
+ }
+
+ fd = openat(xml_dfd, path, O_RDONLY | O_RESOLVE_BENEATH);
+ if (fd < 0) {
+ send_error(errno);
+ return;
+ }
+ if (fstat(fd, &sb) < 0) {
+ send_error(errno);
+ close(fd);
+ return;
+ }
+ xml = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
+ if (xml == MAP_FAILED) {
+ send_error(errno);
+ close(fd);
+ return;
+ }
+ close(fd);
+ xmllen = sb.st_size;
+
+ start_packet();
+ if (doff >= xmllen) {
+ append_char('l');
+ } else if (doff + dlen >= xmllen) {
+ append_char('l');
+ append_packet_data(xml + doff, xmllen - doff);
+ } else {
+ append_char('m');
+ append_packet_data(xml + doff, dlen);
+ }
+ finish_packet();
+ (void)munmap(__DECONST(void *, xml), xmllen);
} else
send_empty_response();
}
@@ -1529,14 +1712,16 @@ handle_command(const uint8_t *data, size_t len)
/* TODO: Resume any stopped CPUs. */
break;
- case 'g': {
+ case 'g':
gdb_read_regs();
break;
- }
+ case 'p':
+ gdb_read_one_reg(data + 1, len - 1);
+ break;
case 'H': {
int tid;
- if (data[1] != 'g' && data[1] != 'c') {
+ if (len < 2 || (data[1] != 'g' && data[1] != 'c')) {
send_error(EINVAL);
break;
}
@@ -1588,7 +1773,7 @@ handle_command(const uint8_t *data, size_t len)
}
/* Don't send a reply until a stop occurs. */
- if (!gdb_step_vcpu(cur_vcpu)) {
+ if (!gdb_step_vcpu(vcpus[cur_vcpu])) {
send_error(EOPNOTSUPP);
break;
}
@@ -1604,7 +1789,6 @@ handle_command(const uint8_t *data, size_t len)
case 'v':
/* Handle 'vCont' */
/* 'vCtrlC' */
- case 'p': /* TODO */
case 'P': /* TODO */
case 'Q': /* TODO */
case 't': /* TODO */
@@ -1704,15 +1888,18 @@ check_command(int fd)
}
static void
-gdb_readable(int fd, enum ev_type event, void *arg)
+gdb_readable(int fd, enum ev_type event __unused, void *arg __unused)
{
+ size_t pending;
ssize_t nread;
- int pending;
+ int n;
- if (ioctl(fd, FIONREAD, &pending) == -1) {
+ if (ioctl(fd, FIONREAD, &n) == -1) {
warn("FIONREAD on GDB socket");
return;
}
+ assert(n >= 0);
+ pending = n;
/*
* 'pending' might be zero due to EOF. We need to call read
@@ -1743,14 +1930,14 @@ gdb_readable(int fd, enum ev_type event, void *arg)
}
static void
-gdb_writable(int fd, enum ev_type event, void *arg)
+gdb_writable(int fd, enum ev_type event __unused, void *arg __unused)
{
send_pending_data(fd);
}
static void
-new_connection(int fd, enum ev_type event, void *arg)
+new_connection(int fd, enum ev_type event __unused, void *arg)
{
int optval, s;
@@ -1804,7 +1991,7 @@ new_connection(int fd, enum ev_type event, void *arg)
}
#ifndef WITHOUT_CAPSICUM
-void
+static void
limit_gdb_socket(int s)
{
cap_rights_t rights;
@@ -1822,6 +2009,9 @@ limit_gdb_socket(int s)
void
init_gdb(struct vmctx *_ctx)
{
+#ifndef WITHOUT_CAPSICUM
+ cap_rights_t rights;
+#endif
int error, flags, optval, s;
struct addrinfo hints;
struct addrinfo *gdbaddr;
@@ -1878,6 +2068,7 @@ init_gdb(struct vmctx *_ctx)
stopped_vcpu = -1;
TAILQ_INIT(&breakpoints);
+ vcpus = calloc(guest_ncpus, sizeof(*vcpus));
vcpu_state = calloc(guest_ncpus, sizeof(*vcpu_state));
if (wait) {
/*
@@ -1901,4 +2092,13 @@ init_gdb(struct vmctx *_ctx)
gdb_active = true;
freeaddrinfo(gdbaddr);
free(sport);
+
+ xml_dfd = open(_PATH_GDB_XML, O_DIRECTORY);
+ if (xml_dfd == -1)
+ err(1, "Failed to open gdb xml directory");
+#ifndef WITHOUT_CAPSICUM
+ cap_rights_init(&rights, CAP_FSTAT, CAP_LOOKUP, CAP_MMAP_R, CAP_PREAD);
+ if (caph_rights_limit(xml_dfd, &rights) == -1)
+ err(1, "cap_rights_init");
+#endif
}
diff --git a/usr.sbin/bhyve/gdb.h b/usr.sbin/bhyve/gdb.h
index c5fa522c63e0..98f9ece2f60c 100644
--- a/usr.sbin/bhyve/gdb.h
+++ b/usr.sbin/bhyve/gdb.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2017 John H. Baldwin <jhb@FreeBSD.org>
*
@@ -23,17 +23,16 @@
* 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 __GDB_H__
#define __GDB_H__
-void gdb_cpu_add(int vcpu);
-void gdb_cpu_breakpoint(int vcpu, struct vm_exit *vmexit);
-void gdb_cpu_mtrap(int vcpu);
-void gdb_cpu_suspend(int vcpu);
+void gdb_cpu_add(struct vcpu *vcpu);
+void gdb_cpu_breakpoint(struct vcpu *vcpu, struct vm_exit *vmexit);
+void gdb_cpu_mtrap(struct vcpu *vcpu);
+void gdb_cpu_suspend(struct vcpu *vcpu);
+void gdb_cpu_debug(struct vcpu *vcpu, struct vm_exit *vmexit);
void init_gdb(struct vmctx *ctx);
#endif /* !__GDB_H__ */
diff --git a/usr.sbin/bhyve/gdb/Makefile b/usr.sbin/bhyve/gdb/Makefile
new file mode 100644
index 000000000000..cc9ba4d224da
--- /dev/null
+++ b/usr.sbin/bhyve/gdb/Makefile
@@ -0,0 +1,23 @@
+PACKAGE= bhyve
+FILESDIR= ${SHAREDIR}/bhyve/gdb
+
+FILES+= target.xml
+
+.if ${MACHINE_ARCH} == "amd64"
+XMLARCH= i386:x86-64
+FILES+= amd64.xml
+.endif
+
+.if !make(install*)
+target.xml: .PHONY
+ @echo "<?xml version=\"1.0\"?>" > ${.TARGET}
+ @echo "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">" >> ${.TARGET}
+ @echo "<target>" >> ${.TARGET}
+ @echo " <architecture>${XMLARCH}</architecture>" >> ${.TARGET}
+.for file in ${FILES:Ntarget.xml}
+ @echo " <xi:include href=\"${file}\"/>" >> ${.TARGET}
+.endfor
+ @echo "</target>" >> ${.TARGET}
+.endif
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bhyve/gdb/amd64.xml b/usr.sbin/bhyve/gdb/amd64.xml
new file mode 100644
index 000000000000..15bd270120d8
--- /dev/null
+++ b/usr.sbin/bhyve/gdb/amd64.xml
@@ -0,0 +1,165 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2010-2017 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. -->
+
+<!-- x86_64 64bit -->
+
+<!DOCTYPE target SYSTEM "gdb-target.dtd">
+
+<feature name="org.gnu.gdb.i386.core">
+ <flags id="x64_eflags" size="4">
+ <field name="" start="22" end="31"/>
+ <field name="ID" start="21" end="21"/>
+ <field name="VIP" start="20" end="20"/>
+ <field name="VIF" start="19" end="19"/>
+ <field name="AC" start="18" end="18"/>
+ <field name="VM" start="17" end="17"/>
+ <field name="RF" start="16" end="16"/>
+ <field name="" start="15" end="15"/>
+ <field name="NT" start="14" end="14"/>
+ <field name="IOPL" start="12" end="13"/>
+ <field name="OF" start="11" end="11"/>
+ <field name="DF" start="10" end="10"/>
+ <field name="IF" start="9" end="9"/>
+ <field name="TF" start="8" end="8"/>
+ <field name="SF" start="7" end="7"/>
+ <field name="ZF" start="6" end="6"/>
+ <field name="" start="5" end="5"/>
+ <field name="AF" start="4" end="4"/>
+ <field name="" start="3" end="3"/>
+ <field name="PF" start="2" end="2"/>
+ <field name="" start="1" end="1"/>
+ <field name="CF" start="0" end="0"/>
+ </flags>
+
+ <!-- General registers -->
+
+ <reg name="rax" bitsize="64" type="int64" regnum="0"/>
+ <reg name="rbx" bitsize="64" type="int64"/>
+ <reg name="rcx" bitsize="64" type="int64"/>
+ <reg name="rdx" bitsize="64" type="int64"/>
+ <reg name="rsi" bitsize="64" type="int64"/>
+ <reg name="rdi" bitsize="64" type="int64"/>
+ <reg name="rbp" bitsize="64" type="data_ptr"/>
+ <reg name="rsp" bitsize="64" type="data_ptr"/>
+ <reg name="r8" bitsize="64" type="int64"/>
+ <reg name="r9" bitsize="64" type="int64"/>
+ <reg name="r10" bitsize="64" type="int64"/>
+ <reg name="r11" bitsize="64" type="int64"/>
+ <reg name="r12" bitsize="64" type="int64"/>
+ <reg name="r13" bitsize="64" type="int64"/>
+ <reg name="r14" bitsize="64" type="int64"/>
+ <reg name="r15" bitsize="64" type="int64"/>
+
+ <reg name="rip" bitsize="64" type="code_ptr"/>
+ <reg name="eflags" bitsize="32" type="x64_eflags"/>
+
+ <!-- Segment registers -->
+
+ <reg name="cs" bitsize="32" type="int32"/>
+ <reg name="ss" bitsize="32" type="int32"/>
+ <reg name="ds" bitsize="32" type="int32"/>
+ <reg name="es" bitsize="32" type="int32"/>
+ <reg name="fs" bitsize="32" type="int32"/>
+ <reg name="gs" bitsize="32" type="int32"/>
+
+ <!-- Segment descriptor caches and TLS base MSRs -->
+
+ <!--reg name="cs_base" bitsize="64" type="int64"/>
+ <reg name="ss_base" bitsize="64" type="int64"/>
+ <reg name="ds_base" bitsize="64" type="int64"/>
+ <reg name="es_base" bitsize="64" type="int64"/-->
+ <reg name="fs_base" bitsize="64" type="int64"/>
+ <reg name="gs_base" bitsize="64" type="int64"/>
+ <reg name="k_gs_base" bitsize="64" type="int64"/>
+
+ <!-- Control registers -->
+
+ <flags id="x64_cr0" size="8">
+ <field name="PG" start="31" end="31"/>
+ <field name="CD" start="30" end="30"/>
+ <field name="NW" start="29" end="29"/>
+ <field name="AM" start="18" end="18"/>
+ <field name="WP" start="16" end="16"/>
+ <field name="NE" start="5" end="5"/>
+ <field name="ET" start="4" end="4"/>
+ <field name="TS" start="3" end="3"/>
+ <field name="EM" start="2" end="2"/>
+ <field name="MP" start="1" end="1"/>
+ <field name="PE" start="0" end="0"/>
+ </flags>
+
+ <flags id="x64_cr3" size="8">
+ <field name="PDBR" start="12" end="63"/>
+ <!--field name="" start="3" end="11"/>
+ <field name="WT" start="2" end="2"/>
+ <field name="CD" start="1" end="1"/>
+ <field name="" start="0" end="0"/-->
+ <field name="PCID" start="0" end="11"/>
+ </flags>
+
+ <flags id="x64_cr4" size="8">
+ <field name="PKE" start="22" end="22"/>
+ <field name="SMAP" start="21" end="21"/>
+ <field name="SMEP" start="20" end="20"/>
+ <field name="OSXSAVE" start="18" end="18"/>
+ <field name="PCIDE" start="17" end="17"/>
+ <field name="FSGSBASE" start="16" end="16"/>
+ <field name="SMXE" start="14" end="14"/>
+ <field name="VMXE" start="13" end="13"/>
+ <field name="LA57" start="12" end="12"/>
+ <field name="UMIP" start="11" end="11"/>
+ <field name="OSXMMEXCPT" start="10" end="10"/>
+ <field name="OSFXSR" start="9" end="9"/>
+ <field name="PCE" start="8" end="8"/>
+ <field name="PGE" start="7" end="7"/>
+ <field name="MCE" start="6" end="6"/>
+ <field name="PAE" start="5" end="5"/>
+ <field name="PSE" start="4" end="4"/>
+ <field name="DE" start="3" end="3"/>
+ <field name="TSD" start="2" end="2"/>
+ <field name="PVI" start="1" end="1"/>
+ <field name="VME" start="0" end="0"/>
+ </flags>
+
+ <flags id="x64_efer" size="8">
+ <field name="TCE" start="15" end="15"/>
+ <field name="FFXSR" start="14" end="14"/>
+ <field name="LMSLE" start="13" end="13"/>
+ <field name="SVME" start="12" end="12"/>
+ <field name="NXE" start="11" end="11"/>
+ <field name="LMA" start="10" end="10"/>
+ <field name="LME" start="8" end="8"/>
+ <field name="SCE" start="0" end="0"/>
+ </flags>
+
+ <reg name="cr0" bitsize="64" type="x64_cr0"/>
+ <reg name="cr2" bitsize="64" type="int64"/>
+ <reg name="cr3" bitsize="64" type="x64_cr3"/>
+ <reg name="cr4" bitsize="64" type="x64_cr4"/>
+ <reg name="cr8" bitsize="64" type="int64"/>
+ <reg name="efer" bitsize="64" type="x64_efer"/>
+
+ <!-- x87 FPU -->
+
+ <reg name="st0" bitsize="80" type="i387_ext"/>
+ <reg name="st1" bitsize="80" type="i387_ext"/>
+ <reg name="st2" bitsize="80" type="i387_ext"/>
+ <reg name="st3" bitsize="80" type="i387_ext"/>
+ <reg name="st4" bitsize="80" type="i387_ext"/>
+ <reg name="st5" bitsize="80" type="i387_ext"/>
+ <reg name="st6" bitsize="80" type="i387_ext"/>
+ <reg name="st7" bitsize="80" type="i387_ext"/>
+
+ <reg name="fctrl" bitsize="32" type="int" group="float"/>
+ <reg name="fstat" bitsize="32" type="int" group="float"/>
+ <reg name="ftag" bitsize="32" type="int" group="float"/>
+ <reg name="fiseg" bitsize="32" type="int" group="float"/>
+ <reg name="fioff" bitsize="32" type="int" group="float"/>
+ <reg name="foseg" bitsize="32" type="int" group="float"/>
+ <reg name="fooff" bitsize="32" type="int" group="float"/>
+ <reg name="fop" bitsize="32" type="int" group="float"/>
+</feature>
diff --git a/usr.sbin/bhyve/hda_codec.c b/usr.sbin/bhyve/hda_codec.c
index 7a6ba345d8ec..1866149c020a 100644
--- a/usr.sbin/bhyve/hda_codec.c
+++ b/usr.sbin/bhyve/hda_codec.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 Alex Teaca <iateaca@FreeBSD.org>
* All rights reserved.
@@ -28,8 +28,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <pthread.h>
#include <pthread_np.h>
#include <unistd.h>
@@ -465,7 +463,7 @@ hda_codec_init(struct hda_codec_inst *hci, const char *play,
static int
hda_codec_reset(struct hda_codec_inst *hci)
{
- struct hda_ops *hops = NULL;
+ const struct hda_ops *hops = NULL;
struct hda_codec_softc *sc = NULL;
struct hda_codec_stream *st = NULL;
int i;
@@ -500,8 +498,8 @@ hda_codec_reset(struct hda_codec_inst *hci)
static int
hda_codec_command(struct hda_codec_inst *hci, uint32_t cmd_data)
{
+ const struct hda_ops *hops = NULL;
struct hda_codec_softc *sc = NULL;
- struct hda_ops *hops = NULL;
uint8_t cad = 0, nid = 0;
uint16_t verb = 0, payload = 0;
uint32_t res = 0;
@@ -677,9 +675,9 @@ hda_codec_audio_output_nid(struct hda_codec_softc *sc, uint16_t verb,
static void
hda_codec_audio_output_do_transfer(void *arg)
{
+ const struct hda_ops *hops = NULL;
struct hda_codec_softc *sc = (struct hda_codec_softc *)arg;
struct hda_codec_inst *hci = NULL;
- struct hda_ops *hops = NULL;
struct hda_codec_stream *st = NULL;
struct audio *aud = NULL;
int err;
@@ -738,9 +736,9 @@ hda_codec_audio_input_nid(struct hda_codec_softc *sc, uint16_t verb,
static void
hda_codec_audio_input_do_transfer(void *arg)
{
+ const struct hda_ops *hops = NULL;
struct hda_codec_softc *sc = (struct hda_codec_softc *)arg;
struct hda_codec_inst *hci = NULL;
- struct hda_ops *hops = NULL;
struct hda_codec_stream *st = NULL;
struct audio *aud = NULL;
int err;
@@ -845,17 +843,15 @@ hda_codec_audio_inout_nid(struct hda_codec_stream *st, uint16_t verb,
return (res);
}
-struct hda_codec_class hda_codec = {
+static const struct hda_codec_class hda_codec = {
.name = "hda_codec",
.init = hda_codec_init,
.reset = hda_codec_reset,
.command = hda_codec_command,
.notify = hda_codec_notify,
};
-
HDA_EMUL_SET(hda_codec);
-
/*
* HDA Audio Context module function definitions
*/
diff --git a/usr.sbin/bhyve/hda_reg.h b/usr.sbin/bhyve/hda_reg.h
index c309056c6f5d..039afdaeb51c 100644
--- a/usr.sbin/bhyve/hda_reg.h
+++ b/usr.sbin/bhyve/hda_reg.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Stephane E. Potvin <sepotvin@videotron.ca>
* 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 _HDA_REG_H_
diff --git a/usr.sbin/bhyve/hdac_reg.h b/usr.sbin/bhyve/hdac_reg.h
index 35272e5135cb..c851bf4c7656 100644
--- a/usr.sbin/bhyve/hdac_reg.h
+++ b/usr.sbin/bhyve/hdac_reg.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Stephane E. Potvin <sepotvin@videotron.ca>
* 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 _HDAC_REG_H_
diff --git a/usr.sbin/bhyve/iov.c b/usr.sbin/bhyve/iov.c
index af36cb056229..5ebc426227a6 100644
--- a/usr.sbin/bhyve/iov.c
+++ b/usr.sbin/bhyve/iov.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 Jakub Klama <jceel@FreeBSD.org>.
* Copyright (c) 2018 Alexander Motin <mav@FreeBSD.org>
@@ -28,9 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/types.h>
#include <sys/uio.h>
@@ -111,7 +108,7 @@ iov_to_buf(const struct iovec *iov, int niov, void **buf)
return (-1);
for (i = 0, ptr = 0; i < niov; i++) {
- memcpy(*buf + ptr, iov[i].iov_base, iov[i].iov_len);
+ memcpy((uint8_t *)*buf + ptr, iov[i].iov_base, iov[i].iov_len);
ptr += iov[i].iov_len;
}
@@ -137,7 +134,7 @@ buf_to_iov(const void *buf, size_t buflen, const struct iovec *iov, int niov,
for (i = 0; i < niov && off < buflen; i++) {
len = MIN(iov[i].iov_len, buflen - off);
- memcpy(iov[i].iov_base, buf + off, len);
+ memcpy(iov[i].iov_base, (const uint8_t *)buf + off, len);
off += len;
}
diff --git a/usr.sbin/bhyve/iov.h b/usr.sbin/bhyve/iov.h
index f46b04b71eb5..aef0a2e1ee49 100644
--- a/usr.sbin/bhyve/iov.h
+++ b/usr.sbin/bhyve/iov.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 Jakub Klama <jceel@FreeBSD.org>.
* Copyright (c) 2018 Alexander Motin <mav@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$
*/
#ifndef _IOV_H_
diff --git a/usr.sbin/bhyve/ipc.h b/usr.sbin/bhyve/ipc.h
index 38faf69eb5f4..d7a3a173e068 100644
--- a/usr.sbin/bhyve/ipc.h
+++ b/usr.sbin/bhyve/ipc.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 Rob Wing <rew@FreeBSD.org>
*
@@ -34,14 +34,14 @@
#include <sys/nv.h>
struct ipc_command {
- char *name;
+ const char *name;
int (*handler)(struct vmctx *ctx, const nvlist_t *nvl);
};
#define IPC_COMMAND(set, name, function) \
static struct ipc_command name ## _ipc_command = \
{ #name, function }; \
- DATA_SET(set, name ## _ipc_command);
+ DATA_SET(set, name ## _ipc_command)
#define IPC_COMMAND_FOREACH(pvar, set) SET_FOREACH(pvar, set)
diff --git a/usr.sbin/bhyve/kbdlayout/Makefile b/usr.sbin/bhyve/kbdlayout/Makefile
index 4fa9c220747c..ed3f3dc9fbc4 100644
--- a/usr.sbin/bhyve/kbdlayout/Makefile
+++ b/usr.sbin/bhyve/kbdlayout/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= bhyve
FILESDIR= ${SHAREDIR}/bhyve/kbdlayout
diff --git a/usr.sbin/bhyve/kbdlayout/Makefile.depend b/usr.sbin/bhyve/kbdlayout/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bhyve/kbdlayout/Makefile.depend
+++ b/usr.sbin/bhyve/kbdlayout/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bhyve/kbdlayout/am b/usr.sbin/bhyve/kbdlayout/am
index c102fb10801a..a49e33e99aff 100644
--- a/usr.sbin/bhyve/kbdlayout/am
+++ b/usr.sbin/bhyve/kbdlayout/am
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
')',0x87; ) (0x29)
'+',0xce; + (0x2b)
diff --git a/usr.sbin/bhyve/kbdlayout/be b/usr.sbin/bhyve/kbdlayout/be
index 26f8cdc3acbc..5cc0669ea036 100644
--- a/usr.sbin/bhyve/kbdlayout/be
+++ b/usr.sbin/bhyve/kbdlayout/be
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x3e; ! (0x21)
'"',0x26; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/be_acc b/usr.sbin/bhyve/kbdlayout/be_acc
index adf136634eb2..b9190d76a3d2 100644
--- a/usr.sbin/bhyve/kbdlayout/be_acc
+++ b/usr.sbin/bhyve/kbdlayout/be_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x3e; ! (0x21)
'"',0x26; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/bg_bds b/usr.sbin/bhyve/kbdlayout/bg_bds
index 9c25ed4640d3..c1207ebc6768 100644
--- a/usr.sbin/bhyve/kbdlayout/bg_bds
+++ b/usr.sbin/bhyve/kbdlayout/bg_bds
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'(',0xa9; ( (0x28)
'*',0xb7; * (0x2a)
diff --git a/usr.sbin/bhyve/kbdlayout/bg_phonetic b/usr.sbin/bhyve/kbdlayout/bg_phonetic
index dfe972db5b5b..0ce3e5604f8e 100644
--- a/usr.sbin/bhyve/kbdlayout/bg_phonetic
+++ b/usr.sbin/bhyve/kbdlayout/bg_phonetic
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'*',0xb7; * (0x2a)
diff --git a/usr.sbin/bhyve/kbdlayout/br b/usr.sbin/bhyve/kbdlayout/br
index b4605e1748c3..35a6f84537b2 100644
--- a/usr.sbin/bhyve/kbdlayout/br
+++ b/usr.sbin/bhyve/kbdlayout/br
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x0e; " (0x22)
''',0x0e; ' (0x27)
diff --git a/usr.sbin/bhyve/kbdlayout/br_noacc b/usr.sbin/bhyve/kbdlayout/br_noacc
index 62bea6254ced..4d69b285af0b 100644
--- a/usr.sbin/bhyve/kbdlayout/br_noacc
+++ b/usr.sbin/bhyve/kbdlayout/br_noacc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x0e; " (0x22)
''',0x0e; ' (0x27)
diff --git a/usr.sbin/bhyve/kbdlayout/centraleuropean b/usr.sbin/bhyve/kbdlayout/centraleuropean
index 7b3a2f883aaa..1098198c8db0 100644
--- a/usr.sbin/bhyve/kbdlayout/centraleuropean
+++ b/usr.sbin/bhyve/kbdlayout/centraleuropean
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'Y',0x1a; Y (0x59)
'Z',0x35; Z (0x5a)
diff --git a/usr.sbin/bhyve/kbdlayout/ch b/usr.sbin/bhyve/kbdlayout/ch
index c68f78a49ede..40de835af9d2 100644
--- a/usr.sbin/bhyve/kbdlayout/ch
+++ b/usr.sbin/bhyve/kbdlayout/ch
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x5b; ! (0x21)
'"',0x1e; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/ch-fr b/usr.sbin/bhyve/kbdlayout/ch-fr
index 33d747f58f5a..a434255e9b58 100644
--- a/usr.sbin/bhyve/kbdlayout/ch-fr
+++ b/usr.sbin/bhyve/kbdlayout/ch-fr
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x5b; ! (0x21)
'"',0x1e; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/ch-fr_acc b/usr.sbin/bhyve/kbdlayout/ch-fr_acc
index 3d081fb6711c..52a22ff173d3 100644
--- a/usr.sbin/bhyve/kbdlayout/ch-fr_acc
+++ b/usr.sbin/bhyve/kbdlayout/ch-fr_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x5b; ! (0x21)
'"',0x1e; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/ch_acc b/usr.sbin/bhyve/kbdlayout/ch_acc
index 5b916d444e6f..9e0acd51d443 100644
--- a/usr.sbin/bhyve/kbdlayout/ch_acc
+++ b/usr.sbin/bhyve/kbdlayout/ch_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x5b; ! (0x21)
'"',0x1e; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/ch_macbook_acc b/usr.sbin/bhyve/kbdlayout/ch_macbook_acc
index 3c7a032bebe6..5496a990d6eb 100644
--- a/usr.sbin/bhyve/kbdlayout/ch_macbook_acc
+++ b/usr.sbin/bhyve/kbdlayout/ch_macbook_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x5b; ! (0x21)
'"',0x1e; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/cz b/usr.sbin/bhyve/kbdlayout/cz
index 98f6108231ee..53e435de965c 100644
--- a/usr.sbin/bhyve/kbdlayout/cz
+++ b/usr.sbin/bhyve/kbdlayout/cz
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
')',0x9b; ) (0x29)
'*',0xb7; * (0x2a)
diff --git a/usr.sbin/bhyve/kbdlayout/de b/usr.sbin/bhyve/kbdlayout/de
index 745f826a9de2..e1c8f6682322 100644
--- a/usr.sbin/bhyve/kbdlayout/de
+++ b/usr.sbin/bhyve/kbdlayout/de
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'#',0x5d; # (0x23)
@@ -14,6 +13,7 @@
'*',0x5b; * (0x2a)
'+',0x5b; + (0x2b)
'-',0x4a; - (0x2d)
+'/',0x3d; / (0x2f)
':',0x49; : (0x3a)
';',0x41; ; (0x3b)
'<',0x61; < (0x3c)
@@ -35,3 +35,5 @@
'}',0x45; } (0x7d)
'~',0x5b; ~ (0x7e)
+# Language Specific Keys ------------------------------------------------------
+0xa7,0x26; section sign (§)
diff --git a/usr.sbin/bhyve/kbdlayout/de_acc b/usr.sbin/bhyve/kbdlayout/de_acc
index 2ba06f3d166b..bc39e6ef1c11 100644
--- a/usr.sbin/bhyve/kbdlayout/de_acc
+++ b/usr.sbin/bhyve/kbdlayout/de_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'#',0x5d; # (0x23)
@@ -14,6 +13,7 @@
'*',0x5b; * (0x2a)
'+',0x5b; + (0x2b)
'-',0x4a; - (0x2d)
+'/',0x3d; / (0x2f)
':',0x49; : (0x3a)
';',0x41; ; (0x3b)
'<',0x61; < (0x3c)
@@ -34,3 +34,5 @@
'|',0x61; | (0x7c)
'}',0x45; } (0x7d)
+# Language Specific Keys ------------------------------------------------------
+0xa7,0x26; section sign (§)
diff --git a/usr.sbin/bhyve/kbdlayout/de_noacc b/usr.sbin/bhyve/kbdlayout/de_noacc
index 4d215116e2a7..b6312d77b0f0 100644
--- a/usr.sbin/bhyve/kbdlayout/de_noacc
+++ b/usr.sbin/bhyve/kbdlayout/de_noacc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'#',0x5d; # (0x23)
@@ -14,6 +13,7 @@
'*',0x5b; * (0x2a)
'+',0x5b; + (0x2b)
'-',0x4a; - (0x2d)
+'/',0x3d; / (0x2f)
':',0x49; : (0x3a)
';',0x41; ; (0x3b)
'<',0x61; < (0x3c)
@@ -36,3 +36,5 @@
'}',0x45; } (0x7d)
'~',0x5b; ~ (0x7e)
+# Language Specific Keys ------------------------------------------------------
+0xa7,0x26; section sign (§)
diff --git a/usr.sbin/bhyve/kbdlayout/default b/usr.sbin/bhyve/kbdlayout/default
index 8674c280280b..2c6356d588ee 100644
--- a/usr.sbin/bhyve/kbdlayout/default
+++ b/usr.sbin/bhyve/kbdlayout/default
@@ -2,7 +2,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
# for those who create the Keyboard Layout File. ******************************
# To create the keyboard layout file, first copy this 'default' file into the
diff --git a/usr.sbin/bhyve/kbdlayout/dk b/usr.sbin/bhyve/kbdlayout/dk
index 5183691bfb78..ac7a1696efce 100644
--- a/usr.sbin/bhyve/kbdlayout/dk
+++ b/usr.sbin/bhyve/kbdlayout/dk
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x5b; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/dk_macbook b/usr.sbin/bhyve/kbdlayout/dk_macbook
index a9d9c1b7435e..3757f9c17127 100644
--- a/usr.sbin/bhyve/kbdlayout/dk_macbook
+++ b/usr.sbin/bhyve/kbdlayout/dk_macbook
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'$',0x0e; $ (0x24)
diff --git a/usr.sbin/bhyve/kbdlayout/ee b/usr.sbin/bhyve/kbdlayout/ee
index c2ebbdb08116..03bf2b724f9c 100644
--- a/usr.sbin/bhyve/kbdlayout/ee
+++ b/usr.sbin/bhyve/kbdlayout/ee
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/es b/usr.sbin/bhyve/kbdlayout/es
index 54ffb24bfc10..26745c952666 100644
--- a/usr.sbin/bhyve/kbdlayout/es
+++ b/usr.sbin/bhyve/kbdlayout/es
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/es_acc b/usr.sbin/bhyve/kbdlayout/es_acc
index cd091791c055..70e6ea44c158 100644
--- a/usr.sbin/bhyve/kbdlayout/es_acc
+++ b/usr.sbin/bhyve/kbdlayout/es_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/es_dvorak b/usr.sbin/bhyve/kbdlayout/es_dvorak
index b84e95c91354..c98e907b9d1e 100644
--- a/usr.sbin/bhyve/kbdlayout/es_dvorak
+++ b/usr.sbin/bhyve/kbdlayout/es_dvorak
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/fi b/usr.sbin/bhyve/kbdlayout/fi
index c4bdea09a617..6fe5beb58890 100644
--- a/usr.sbin/bhyve/kbdlayout/fi
+++ b/usr.sbin/bhyve/kbdlayout/fi
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/fr b/usr.sbin/bhyve/kbdlayout/fr
index 6009090ff090..0efb1c72ec52 100644
--- a/usr.sbin/bhyve/kbdlayout/fr
+++ b/usr.sbin/bhyve/kbdlayout/fr
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x4a; ! (0x21)
'"',0x26; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/fr_acc b/usr.sbin/bhyve/kbdlayout/fr_acc
index ef8730f62f46..85ef4e4c8d1a 100644
--- a/usr.sbin/bhyve/kbdlayout/fr_acc
+++ b/usr.sbin/bhyve/kbdlayout/fr_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x4a; ! (0x21)
'"',0x26; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/fr_dvorak b/usr.sbin/bhyve/kbdlayout/fr_dvorak
index f739c8e15502..9d7726aeb4f3 100644
--- a/usr.sbin/bhyve/kbdlayout/fr_dvorak
+++ b/usr.sbin/bhyve/kbdlayout/fr_dvorak
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x2c; ! (0x21)
'"',0x45; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/fr_dvorak_acc b/usr.sbin/bhyve/kbdlayout/fr_dvorak_acc
index c126572b7e16..b22ad12a47bb 100644
--- a/usr.sbin/bhyve/kbdlayout/fr_dvorak_acc
+++ b/usr.sbin/bhyve/kbdlayout/fr_dvorak_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x2c; ! (0x21)
'"',0x45; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/fr_macbook b/usr.sbin/bhyve/kbdlayout/fr_macbook
index ddb756c8a648..ed4425259061 100644
--- a/usr.sbin/bhyve/kbdlayout/fr_macbook
+++ b/usr.sbin/bhyve/kbdlayout/fr_macbook
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x3e; ! (0x21)
'"',0x26; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/gr b/usr.sbin/bhyve/kbdlayout/gr
index cba917509594..3a8b3355ca47 100644
--- a/usr.sbin/bhyve/kbdlayout/gr
+++ b/usr.sbin/bhyve/kbdlayout/gr
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'*',0xb7; * (0x2a)
diff --git a/usr.sbin/bhyve/kbdlayout/gr_101_acc b/usr.sbin/bhyve/kbdlayout/gr_101_acc
index 1a4ef7657f1d..b274990410ee 100644
--- a/usr.sbin/bhyve/kbdlayout/gr_101_acc
+++ b/usr.sbin/bhyve/kbdlayout/gr_101_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'*',0xb7; * (0x2a)
diff --git a/usr.sbin/bhyve/kbdlayout/gr_elot_acc b/usr.sbin/bhyve/kbdlayout/gr_elot_acc
index 2e84a99633dc..459ef8173f21 100644
--- a/usr.sbin/bhyve/kbdlayout/gr_elot_acc
+++ b/usr.sbin/bhyve/kbdlayout/gr_elot_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'#',0x5d; # (0x23)
diff --git a/usr.sbin/bhyve/kbdlayout/hr b/usr.sbin/bhyve/kbdlayout/hr
index 8ec2e11dcbd3..695c8a3b2c05 100644
--- a/usr.sbin/bhyve/kbdlayout/hr
+++ b/usr.sbin/bhyve/kbdlayout/hr
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/hu_101 b/usr.sbin/bhyve/kbdlayout/hu_101
index 00d4176d1bca..939a3146490b 100644
--- a/usr.sbin/bhyve/kbdlayout/hu_101
+++ b/usr.sbin/bhyve/kbdlayout/hu_101
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'*',0xb7; * (0x2a)
diff --git a/usr.sbin/bhyve/kbdlayout/hu_102 b/usr.sbin/bhyve/kbdlayout/hu_102
index eb9d0ae4e465..8e020192a714 100644
--- a/usr.sbin/bhyve/kbdlayout/hu_102
+++ b/usr.sbin/bhyve/kbdlayout/hu_102
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x25; ! (0x21)
'"',0x1e; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/is b/usr.sbin/bhyve/kbdlayout/is
index 4cfd793f7326..32aa9257b389 100644
--- a/usr.sbin/bhyve/kbdlayout/is
+++ b/usr.sbin/bhyve/kbdlayout/is
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/is_acc b/usr.sbin/bhyve/kbdlayout/is_acc
index f7391b35298f..69a63a4e2da9 100644
--- a/usr.sbin/bhyve/kbdlayout/is_acc
+++ b/usr.sbin/bhyve/kbdlayout/is_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/it b/usr.sbin/bhyve/kbdlayout/it
index a286bf8684fa..e7d5b6f73d69 100644
--- a/usr.sbin/bhyve/kbdlayout/it
+++ b/usr.sbin/bhyve/kbdlayout/it
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'#',0x52; # (0x23)
diff --git a/usr.sbin/bhyve/kbdlayout/jp b/usr.sbin/bhyve/kbdlayout/jp
index 550571ea1dfe..f01adc0b86f8 100644
--- a/usr.sbin/bhyve/kbdlayout/jp
+++ b/usr.sbin/bhyve/kbdlayout/jp
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
# Alphabet/Number/Sign Keys ---------------------------------------------------
'"',0x1e; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/jp_capsctrl b/usr.sbin/bhyve/kbdlayout/jp_capsctrl
index 46fd6e154a38..12316ef407ef 100644
--- a/usr.sbin/bhyve/kbdlayout/jp_capsctrl
+++ b/usr.sbin/bhyve/kbdlayout/jp_capsctrl
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
# Alphabet/Number/Sign Keys ---------------------------------------------------
'"',0x1e; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/kz_io b/usr.sbin/bhyve/kbdlayout/kz_io
index c158028e0ad5..58a7b5b6f5cd 100644
--- a/usr.sbin/bhyve/kbdlayout/kz_io
+++ b/usr.sbin/bhyve/kbdlayout/kz_io
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x82; " (0x22)
'(',0xa9; ( (0x28)
diff --git a/usr.sbin/bhyve/kbdlayout/kz_kst b/usr.sbin/bhyve/kbdlayout/kz_kst
index 7c1281a7dc4d..3ef3b89d3e89 100644
--- a/usr.sbin/bhyve/kbdlayout/kz_kst
+++ b/usr.sbin/bhyve/kbdlayout/kz_kst
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x82; " (0x22)
'(',0xa9; ( (0x28)
diff --git a/usr.sbin/bhyve/kbdlayout/latinamerican b/usr.sbin/bhyve/kbdlayout/latinamerican
index ac2920ab4af7..092579bec60e 100644
--- a/usr.sbin/bhyve/kbdlayout/latinamerican
+++ b/usr.sbin/bhyve/kbdlayout/latinamerican
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/latinamerican_acc b/usr.sbin/bhyve/kbdlayout/latinamerican_acc
index 7fd97dc3dba8..904575f3689f 100644
--- a/usr.sbin/bhyve/kbdlayout/latinamerican_acc
+++ b/usr.sbin/bhyve/kbdlayout/latinamerican_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/lt b/usr.sbin/bhyve/kbdlayout/lt
index 114d0624dfe2..b876d27f4ab0 100644
--- a/usr.sbin/bhyve/kbdlayout/lt
+++ b/usr.sbin/bhyve/kbdlayout/lt
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'*',0xb7; * (0x2a)
0xffea,0x61; Right alt
diff --git a/usr.sbin/bhyve/kbdlayout/nl b/usr.sbin/bhyve/kbdlayout/nl
index f715494337e4..b9b8138fae23 100644
--- a/usr.sbin/bhyve/kbdlayout/nl
+++ b/usr.sbin/bhyve/kbdlayout/nl
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/no b/usr.sbin/bhyve/kbdlayout/no
index bd2620631616..0d2be75ef415 100644
--- a/usr.sbin/bhyve/kbdlayout/no
+++ b/usr.sbin/bhyve/kbdlayout/no
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/no_dvorak b/usr.sbin/bhyve/kbdlayout/no_dvorak
index f4197864590e..ac62fd4ae73e 100644
--- a/usr.sbin/bhyve/kbdlayout/no_dvorak
+++ b/usr.sbin/bhyve/kbdlayout/no_dvorak
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/nordic_asus-eee b/usr.sbin/bhyve/kbdlayout/nordic_asus-eee
index c0fb79ca4fdd..368d9d6c3406 100644
--- a/usr.sbin/bhyve/kbdlayout/nordic_asus-eee
+++ b/usr.sbin/bhyve/kbdlayout/nordic_asus-eee
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/pl_dvorak b/usr.sbin/bhyve/kbdlayout/pl_dvorak
index 4162839eb89d..9a9daaef652d 100644
--- a/usr.sbin/bhyve/kbdlayout/pl_dvorak
+++ b/usr.sbin/bhyve/kbdlayout/pl_dvorak
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x15; " (0x22)
''',0x15; ' (0x27)
diff --git a/usr.sbin/bhyve/kbdlayout/pt b/usr.sbin/bhyve/kbdlayout/pt
index 9ca6dc125a6b..ab568361a7f9 100644
--- a/usr.sbin/bhyve/kbdlayout/pt
+++ b/usr.sbin/bhyve/kbdlayout/pt
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/pt_acc b/usr.sbin/bhyve/kbdlayout/pt_acc
index 85ca7485afa9..1f179e73cc5f 100644
--- a/usr.sbin/bhyve/kbdlayout/pt_acc
+++ b/usr.sbin/bhyve/kbdlayout/pt_acc
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/ru b/usr.sbin/bhyve/kbdlayout/ru
index 32bcf88dcf79..99552914963a 100644
--- a/usr.sbin/bhyve/kbdlayout/ru
+++ b/usr.sbin/bhyve/kbdlayout/ru
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x82; ! (0x21)
'"',0x00; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/ru_shift b/usr.sbin/bhyve/kbdlayout/ru_shift
index 1edc9310d2b0..572c378b4e38 100644
--- a/usr.sbin/bhyve/kbdlayout/ru_shift
+++ b/usr.sbin/bhyve/kbdlayout/ru_shift
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'*',0xb7; * (0x2a)
diff --git a/usr.sbin/bhyve/kbdlayout/ru_win b/usr.sbin/bhyve/kbdlayout/ru_win
index 04b2775bf79f..56b555968b60 100644
--- a/usr.sbin/bhyve/kbdlayout/ru_win
+++ b/usr.sbin/bhyve/kbdlayout/ru_win
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'*',0xb7; * (0x2a)
diff --git a/usr.sbin/bhyve/kbdlayout/se b/usr.sbin/bhyve/kbdlayout/se
index afd0aca06cd9..e833a3d8e395 100644
--- a/usr.sbin/bhyve/kbdlayout/se
+++ b/usr.sbin/bhyve/kbdlayout/se
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/si b/usr.sbin/bhyve/kbdlayout/si
index 4c3f119e0351..42482784314a 100644
--- a/usr.sbin/bhyve/kbdlayout/si
+++ b/usr.sbin/bhyve/kbdlayout/si
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/tr b/usr.sbin/bhyve/kbdlayout/tr
index 5c80df6b5067..c5dec89fc2a4 100644
--- a/usr.sbin/bhyve/kbdlayout/tr
+++ b/usr.sbin/bhyve/kbdlayout/tr
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x0e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/tr_f b/usr.sbin/bhyve/kbdlayout/tr_f
index 9f4fe1512b48..5451203e8dbb 100644
--- a/usr.sbin/bhyve/kbdlayout/tr_f
+++ b/usr.sbin/bhyve/kbdlayout/tr_f
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'&',0x36; & (0x26)
diff --git a/usr.sbin/bhyve/kbdlayout/ua b/usr.sbin/bhyve/kbdlayout/ua
index 683b39c5053b..244c3484eea6 100644
--- a/usr.sbin/bhyve/kbdlayout/ua
+++ b/usr.sbin/bhyve/kbdlayout/ua
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'*',0xb7; * (0x2a)
diff --git a/usr.sbin/bhyve/kbdlayout/ua_shift_alt b/usr.sbin/bhyve/kbdlayout/ua_shift_alt
index be5d7041078f..02df04ecacea 100644
--- a/usr.sbin/bhyve/kbdlayout/ua_shift_alt
+++ b/usr.sbin/bhyve/kbdlayout/ua_shift_alt
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'*',0xb7; * (0x2a)
0xffb5,0x71; Keypad 5
diff --git a/usr.sbin/bhyve/kbdlayout/uk b/usr.sbin/bhyve/kbdlayout/uk
index 25289fa6d255..2a71f6726d6a 100644
--- a/usr.sbin/bhyve/kbdlayout/uk
+++ b/usr.sbin/bhyve/kbdlayout/uk
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'#',0x5d; # (0x23)
diff --git a/usr.sbin/bhyve/kbdlayout/uk_capsctrl b/usr.sbin/bhyve/kbdlayout/uk_capsctrl
index 8b869bf88308..ea3b462609c9 100644
--- a/usr.sbin/bhyve/kbdlayout/uk_capsctrl
+++ b/usr.sbin/bhyve/kbdlayout/uk_capsctrl
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'#',0x5d; # (0x23)
diff --git a/usr.sbin/bhyve/kbdlayout/uk_dvorak b/usr.sbin/bhyve/kbdlayout/uk_dvorak
index 0b365b7ead4d..4a7fdd78e4ee 100644
--- a/usr.sbin/bhyve/kbdlayout/uk_dvorak
+++ b/usr.sbin/bhyve/kbdlayout/uk_dvorak
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x1e; " (0x22)
'#',0x5d; # (0x23)
diff --git a/usr.sbin/bhyve/kbdlayout/uk_macbook b/usr.sbin/bhyve/kbdlayout/uk_macbook
index 6283842afa5e..73ef5bc454e9 100644
--- a/usr.sbin/bhyve/kbdlayout/uk_macbook
+++ b/usr.sbin/bhyve/kbdlayout/uk_macbook
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'`',0x61; ` (0x60)
'~',0x61; ~ (0x7e)
diff --git a/usr.sbin/bhyve/kbdlayout/us_dvorak b/usr.sbin/bhyve/kbdlayout/us_dvorak
index 6fa21a2bca75..fea168bf8be3 100644
--- a/usr.sbin/bhyve/kbdlayout/us_dvorak
+++ b/usr.sbin/bhyve/kbdlayout/us_dvorak
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x15; " (0x22)
''',0x15; ' (0x27)
diff --git a/usr.sbin/bhyve/kbdlayout/us_dvorakl b/usr.sbin/bhyve/kbdlayout/us_dvorakl
index 38e6857f69ab..255102e866c8 100644
--- a/usr.sbin/bhyve/kbdlayout/us_dvorakl
+++ b/usr.sbin/bhyve/kbdlayout/us_dvorakl
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x55; ! (0x21)
'"',0x1a; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/us_dvorakp b/usr.sbin/bhyve/kbdlayout/us_dvorakp
index c66c9d5e4b03..9ebfbccdd005 100644
--- a/usr.sbin/bhyve/kbdlayout/us_dvorakp
+++ b/usr.sbin/bhyve/kbdlayout/us_dvorakp
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'!',0x4e; ! (0x21)
'"',0x1a; " (0x22)
diff --git a/usr.sbin/bhyve/kbdlayout/us_dvorakr b/usr.sbin/bhyve/kbdlayout/us_dvorakr
index 95485730c460..5eade8ad2f60 100644
--- a/usr.sbin/bhyve/kbdlayout/us_dvorakr
+++ b/usr.sbin/bhyve/kbdlayout/us_dvorakr
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x4a; " (0x22)
'%',0x15; % (0x25)
diff --git a/usr.sbin/bhyve/kbdlayout/us_dvorakx b/usr.sbin/bhyve/kbdlayout/us_dvorakx
index 24195875001a..7d74526b94a9 100644
--- a/usr.sbin/bhyve/kbdlayout/us_dvorakx
+++ b/usr.sbin/bhyve/kbdlayout/us_dvorakx
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'"',0x15; " (0x22)
''',0x15; ' (0x27)
diff --git a/usr.sbin/bhyve/kbdlayout/us_emacs b/usr.sbin/bhyve/kbdlayout/us_emacs
index 01b108583fc3..f43a4f28cc16 100644
--- a/usr.sbin/bhyve/kbdlayout/us_emacs
+++ b/usr.sbin/bhyve/kbdlayout/us_emacs
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
0xffff,0x66; Del
diff --git a/usr.sbin/bhyve/kbdlayout/us_unix b/usr.sbin/bhyve/kbdlayout/us_unix
index c4b2739ad194..bdf5a50be15f 100644
--- a/usr.sbin/bhyve/kbdlayout/us_unix
+++ b/usr.sbin/bhyve/kbdlayout/us_unix
@@ -3,7 +3,6 @@
#
# Created by: Koine Yuusuke(koinec) <koinec@users.osdn.me>
#
-# $FreeBSD$
'`',0x76; ` (0x60)
'~',0x76; ~ (0x7e)
diff --git a/usr.sbin/bhyve/libslirp.h b/usr.sbin/bhyve/libslirp.h
new file mode 100644
index 000000000000..a679c4db7913
--- /dev/null
+++ b/usr.sbin/bhyve/libslirp.h
@@ -0,0 +1,365 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1995,1996 Danny Gasparovski. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * DANNY GASPAROVSKI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBSLIRP_H
+#define LIBSLIRP_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+#ifdef _WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <in6addr.h>
+#include <basetsd.h>
+typedef SSIZE_T slirp_ssize_t;
+#ifdef BUILDING_LIBSLIRP
+# define SLIRP_EXPORT __declspec(dllexport)
+#else
+# define SLIRP_EXPORT __declspec(dllimport)
+#endif
+#else
+#include <sys/types.h>
+typedef ssize_t slirp_ssize_t;
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#define SLIRP_EXPORT
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Opaque structure containing the slirp state */
+typedef struct Slirp Slirp;
+
+/* Flags passed to SlirpAddPollCb and to be returned by SlirpGetREventsCb. */
+enum {
+ SLIRP_POLL_IN = 1 << 0,
+ SLIRP_POLL_OUT = 1 << 1,
+ SLIRP_POLL_PRI = 1 << 2,
+ SLIRP_POLL_ERR = 1 << 3,
+ SLIRP_POLL_HUP = 1 << 4,
+};
+
+/* Callback for application to get data from the guest */
+typedef slirp_ssize_t (*SlirpReadCb)(void *buf, size_t len, void *opaque);
+/* Callback for application to send data to the guest */
+typedef slirp_ssize_t (*SlirpWriteCb)(const void *buf, size_t len, void *opaque);
+/* Timer callback */
+typedef void (*SlirpTimerCb)(void *opaque);
+/* Callback for libslirp to register polling callbacks */
+typedef int (*SlirpAddPollCb)(int fd, int events, void *opaque);
+/* Callback for libslirp to get polling result */
+typedef int (*SlirpGetREventsCb)(int idx, void *opaque);
+
+/* For now libslirp creates only a timer for the IPv6 RA */
+typedef enum SlirpTimerId {
+ SLIRP_TIMER_RA,
+ SLIRP_TIMER_NUM,
+} SlirpTimerId;
+
+/*
+ * Callbacks from slirp, to be set by the application.
+ *
+ * The opaque parameter is set to the opaque pointer given in the slirp_new /
+ * slirp_init call.
+ */
+typedef struct SlirpCb {
+ /*
+ * Send an ethernet frame to the guest network. The opaque parameter is the
+ * one given to slirp_init(). If the guest is not ready to receive a frame,
+ * the function can just drop the data. TCP will then handle retransmissions
+ * at a lower pace.
+ * <0 reports an IO error.
+ */
+ SlirpWriteCb send_packet;
+ /* Print a message for an error due to guest misbehavior. */
+ void (*guest_error)(const char *msg, void *opaque);
+ /* Return the virtual clock value in nanoseconds */
+ int64_t (*clock_get_ns)(void *opaque);
+ /* Create a new timer with the given callback and opaque data. Not
+ * needed if timer_new_opaque is provided. */
+ void *(*timer_new)(SlirpTimerCb cb, void *cb_opaque, void *opaque);
+ /* Remove and free a timer */
+ void (*timer_free)(void *timer, void *opaque);
+ /* Modify a timer to expire at @expire_time (ms) */
+ void (*timer_mod)(void *timer, int64_t expire_time, void *opaque);
+ /* Register a fd for future polling */
+ void (*register_poll_fd)(int fd, void *opaque);
+ /* Unregister a fd */
+ void (*unregister_poll_fd)(int fd, void *opaque);
+ /* Kick the io-thread, to signal that new events may be processed because some TCP buffer
+ * can now receive more data, i.e. slirp_socket_can_recv will return 1. */
+ void (*notify)(void *opaque);
+
+ /*
+ * Fields introduced in SlirpConfig version 4 begin
+ */
+
+ /* Initialization has completed and a Slirp* has been created. */
+ void (*init_completed)(Slirp *slirp, void *opaque);
+ /* Create a new timer. When the timer fires, the application passes
+ * the SlirpTimerId and cb_opaque to slirp_handle_timer. */
+ void *(*timer_new_opaque)(SlirpTimerId id, void *cb_opaque, void *opaque);
+} SlirpCb;
+
+#define SLIRP_CONFIG_VERSION_MIN 1
+#define SLIRP_CONFIG_VERSION_MAX 5
+
+typedef struct SlirpConfig {
+ /* Version must be provided */
+ uint32_t version;
+ /*
+ * Fields introduced in SlirpConfig version 1 begin
+ */
+ /* Whether to prevent the guest from accessing the Internet */
+ int restricted;
+ /* Whether IPv4 is enabled */
+ bool in_enabled;
+ /* Virtual network for the guest */
+ struct in_addr vnetwork;
+ /* Mask for the virtual network for the guest */
+ struct in_addr vnetmask;
+ /* Virtual address for the host exposed to the guest */
+ struct in_addr vhost;
+ /* Whether IPv6 is enabled */
+ bool in6_enabled;
+ /* Virtual IPv6 network for the guest */
+ struct in6_addr vprefix_addr6;
+ /* Len of the virtual IPv6 network for the guest */
+ uint8_t vprefix_len;
+ /* Virtual address for the host exposed to the guest */
+ struct in6_addr vhost6;
+ /* Hostname exposed to the guest in DHCP hostname option */
+ const char *vhostname;
+ /* Hostname exposed to the guest in the DHCP TFTP server name option */
+ const char *tftp_server_name;
+ /* Path of the files served by TFTP */
+ const char *tftp_path;
+ /* Boot file name exposed to the guest via DHCP */
+ const char *bootfile;
+ /* Start of the DHCP range */
+ struct in_addr vdhcp_start;
+ /* Virtual address for the DNS server exposed to the guest */
+ struct in_addr vnameserver;
+ /* Virtual IPv6 address for the DNS server exposed to the guest */
+ struct in6_addr vnameserver6;
+ /* DNS search names exposed to the guest via DHCP */
+ const char **vdnssearch;
+ /* Domain name exposed to the guest via DHCP */
+ const char *vdomainname;
+ /* MTU when sending packets to the guest */
+ /* Default: IF_MTU_DEFAULT */
+ size_t if_mtu;
+ /* MRU when receiving packets from the guest */
+ /* Default: IF_MRU_DEFAULT */
+ size_t if_mru;
+ /* Prohibit connecting to 127.0.0.1:* */
+ bool disable_host_loopback;
+ /*
+ * Enable emulation code (*warning*: this code isn't safe, it is not
+ * recommended to enable it)
+ */
+ bool enable_emu;
+
+ /*
+ * Fields introduced in SlirpConfig version 2 begin
+ */
+ /* Address to be used when sending data to the Internet */
+ struct sockaddr_in *outbound_addr;
+ /* IPv6 Address to be used when sending data to the Internet */
+ struct sockaddr_in6 *outbound_addr6;
+
+ /*
+ * Fields introduced in SlirpConfig version 3 begin
+ */
+ /* slirp will not redirect/serve any DNS packet */
+ bool disable_dns;
+
+ /*
+ * Fields introduced in SlirpConfig version 4 begin
+ */
+ /* slirp will not reply to any DHCP requests */
+ bool disable_dhcp;
+
+ /*
+ * Fields introduced in SlirpConfig version 5 begin
+ */
+ /* Manufacturer ID (IANA Private Enterprise number) */
+ uint32_t mfr_id;
+ /*
+ * MAC address allocated for an out-of-band management controller, to be
+ * retrieved through NC-SI.
+ */
+ uint8_t oob_eth_addr[6];
+} SlirpConfig;
+
+/* Create a new instance of a slirp stack */
+SLIRP_EXPORT
+Slirp *slirp_new(const SlirpConfig *cfg, const SlirpCb *callbacks,
+ void *opaque);
+/* slirp_init is deprecated in favor of slirp_new */
+SLIRP_EXPORT
+Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork,
+ struct in_addr vnetmask, struct in_addr vhost,
+ bool in6_enabled, struct in6_addr vprefix_addr6,
+ uint8_t vprefix_len, struct in6_addr vhost6,
+ const char *vhostname, const char *tftp_server_name,
+ const char *tftp_path, const char *bootfile,
+ struct in_addr vdhcp_start, struct in_addr vnameserver,
+ struct in6_addr vnameserver6, const char **vdnssearch,
+ const char *vdomainname, const SlirpCb *callbacks,
+ void *opaque);
+/* Shut down an instance of a slirp stack */
+SLIRP_EXPORT
+void slirp_cleanup(Slirp *slirp);
+
+/* This is called by the application when it is about to sleep through poll().
+ * *timeout is set to the amount of virtual time (in ms) that the application intends to
+ * wait (UINT32_MAX if infinite). slirp_pollfds_fill updates it according to
+ * e.g. TCP timers, so the application knows it should sleep a smaller amount of
+ * time. slirp_pollfds_fill calls add_poll for each file descriptor
+ * that should be monitored along the sleep. The opaque pointer is passed as
+ * such to add_poll, and add_poll returns an index. */
+SLIRP_EXPORT
+void slirp_pollfds_fill(Slirp *slirp, uint32_t *timeout,
+ SlirpAddPollCb add_poll, void *opaque);
+
+/* This is called by the application after sleeping, to report which file
+ * descriptors are available. slirp_pollfds_poll calls get_revents on each file
+ * descriptor, giving it the index that add_poll returned during the
+ * slirp_pollfds_fill call, to know whether the descriptor is available for
+ * read/write/etc. (SLIRP_POLL_*)
+ * select_error should be passed 1 if poll() returned an error. */
+SLIRP_EXPORT
+void slirp_pollfds_poll(Slirp *slirp, int select_error,
+ SlirpGetREventsCb get_revents, void *opaque);
+
+/* This is called by the application when the guest emits a packet on the
+ * guest network, to be interpreted by slirp. */
+SLIRP_EXPORT
+void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len);
+
+/* This is called by the application when a timer expires, if it provides
+ * the timer_new_opaque callback. It is not needed if the application only
+ * uses timer_new. */
+SLIRP_EXPORT
+void slirp_handle_timer(Slirp *slirp, SlirpTimerId id, void *cb_opaque);
+
+/* These set up / remove port forwarding between a host port in the real world
+ * and the guest network. */
+SLIRP_EXPORT
+int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr,
+ int host_port, struct in_addr guest_addr, int guest_port);
+SLIRP_EXPORT
+int slirp_remove_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr,
+ int host_port);
+
+#define SLIRP_HOSTFWD_UDP 1
+#define SLIRP_HOSTFWD_V6ONLY 2
+SLIRP_EXPORT
+int slirp_add_hostxfwd(Slirp *slirp,
+ const struct sockaddr *haddr, socklen_t haddrlen,
+ const struct sockaddr *gaddr, socklen_t gaddrlen,
+ int flags);
+SLIRP_EXPORT
+int slirp_remove_hostxfwd(Slirp *slirp,
+ const struct sockaddr *haddr, socklen_t haddrlen,
+ int flags);
+
+/* Set up port forwarding between a port in the guest network and a
+ * command running on the host */
+SLIRP_EXPORT
+int slirp_add_exec(Slirp *slirp, const char *cmdline,
+ struct in_addr *guest_addr, int guest_port);
+/* Set up port forwarding between a port in the guest network and a
+ * Unix port on the host */
+SLIRP_EXPORT
+int slirp_add_unix(Slirp *slirp, const char *unixsock,
+ struct in_addr *guest_addr, int guest_port);
+/* Set up port forwarding between a port in the guest network and a
+ * callback that will receive the data coming from the port */
+SLIRP_EXPORT
+int slirp_add_guestfwd(Slirp *slirp, SlirpWriteCb write_cb, void *opaque,
+ struct in_addr *guest_addr, int guest_port);
+
+/* TODO: rather identify a guestfwd through an opaque pointer instead of through
+ * the guest_addr */
+
+/* This is called by the application for a guestfwd, to determine how much data
+ * can be received by the forwarded port through a call to slirp_socket_recv. */
+SLIRP_EXPORT
+size_t slirp_socket_can_recv(Slirp *slirp, struct in_addr guest_addr,
+ int guest_port);
+/* This is called by the application for a guestfwd, to provide the data to be
+ * sent on the forwarded port */
+SLIRP_EXPORT
+void slirp_socket_recv(Slirp *slirp, struct in_addr guest_addr, int guest_port,
+ const uint8_t *buf, int size);
+
+/* Remove entries added by slirp_add_exec, slirp_add_unix or slirp_add_guestfwd */
+SLIRP_EXPORT
+int slirp_remove_guestfwd(Slirp *slirp, struct in_addr guest_addr,
+ int guest_port);
+
+/* Return a human-readable state of the slirp stack */
+SLIRP_EXPORT
+char *slirp_connection_info(Slirp *slirp);
+
+/* Return a human-readable state of the NDP/ARP tables */
+SLIRP_EXPORT
+char *slirp_neighbor_info(Slirp *slirp);
+
+/* Save the slirp state through the write_cb. The opaque pointer is passed as
+ * such to the write_cb. */
+SLIRP_EXPORT
+int slirp_state_save(Slirp *s, SlirpWriteCb write_cb, void *opaque);
+
+/* Returns the version of the slirp state, to be saved along the state */
+SLIRP_EXPORT
+int slirp_state_version(void);
+
+/* Load the slirp state through the read_cb. The opaque pointer is passed as
+ * such to the read_cb. The version should be given as it was obtained from
+ * slirp_state_version when slirp_state_save was called. */
+SLIRP_EXPORT
+int slirp_state_load(Slirp *s, int version_id, SlirpReadCb read_cb,
+ void *opaque);
+
+/* Return the version of the slirp implementation */
+SLIRP_EXPORT
+const char *slirp_version_string(void);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* LIBSLIRP_H */
diff --git a/usr.sbin/bhyve/mem.c b/usr.sbin/bhyve/mem.c
index 0a1c4e29972b..b0c09dbf5ddf 100644
--- a/usr.sbin/bhyve/mem.c
+++ b/usr.sbin/bhyve/mem.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 NetApp, Inc.
* 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$
*/
/*
@@ -34,9 +32,6 @@
* so it can be searched within the range.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/tree.h>
@@ -48,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include <vmmapi.h>
#include "mem.h"
@@ -61,7 +57,7 @@ struct mmio_rb_range {
struct mmio_rb_tree;
RB_PROTOTYPE(mmio_rb_tree, mmio_rb_range, mr_link, mmio_rb_range_compare);
-RB_HEAD(mmio_rb_tree, mmio_rb_range) mmio_rb_root, mmio_rb_fallback;
+static RB_HEAD(mmio_rb_tree, mmio_rb_range) mmio_rb_root, mmio_rb_fallback;
/*
* Per-vCPU cache. Since most accesses from a vCPU will be to
@@ -142,53 +138,53 @@ mmio_rb_dump(struct mmio_rb_tree *rbt)
RB_GENERATE(mmio_rb_tree, mmio_rb_range, mr_link, mmio_rb_range_compare);
-typedef int (mem_cb_t)(struct vmctx *ctx, int vcpu, uint64_t gpa,
- struct mem_range *mr, void *arg);
+typedef int (mem_cb_t)(struct vcpu *vcpu, uint64_t gpa, struct mem_range *mr,
+ void *arg);
static int
-mem_read(void *ctx, int vcpu, uint64_t gpa, uint64_t *rval, int size, void *arg)
+mem_read(struct vcpu *vcpu, uint64_t gpa, uint64_t *rval, int size, void *arg)
{
int error;
struct mem_range *mr = arg;
- error = (*mr->handler)(ctx, vcpu, MEM_F_READ, gpa, size,
- rval, mr->arg1, mr->arg2);
+ error = (*mr->handler)(vcpu, MEM_F_READ, gpa, size, rval, mr->arg1,
+ mr->arg2);
return (error);
}
static int
-mem_write(void *ctx, int vcpu, uint64_t gpa, uint64_t wval, int size, void *arg)
+mem_write(struct vcpu *vcpu, uint64_t gpa, uint64_t wval, int size, void *arg)
{
int error;
struct mem_range *mr = arg;
- error = (*mr->handler)(ctx, vcpu, MEM_F_WRITE, gpa, size,
- &wval, mr->arg1, mr->arg2);
+ error = (*mr->handler)(vcpu, MEM_F_WRITE, gpa, size, &wval, mr->arg1,
+ mr->arg2);
return (error);
}
static int
-access_memory(struct vmctx *ctx, int vcpu, uint64_t paddr, mem_cb_t *cb,
- void *arg)
+access_memory(struct vcpu *vcpu, uint64_t paddr, mem_cb_t *cb, void *arg)
{
struct mmio_rb_range *entry;
- int err, perror, immutable;
+ int err, perror, immutable, vcpuid;
+ vcpuid = vcpu_id(vcpu);
pthread_rwlock_rdlock(&mmio_rwlock);
/*
* First check the per-vCPU cache
*/
- if (mmio_hint[vcpu] &&
- paddr >= mmio_hint[vcpu]->mr_base &&
- paddr <= mmio_hint[vcpu]->mr_end) {
- entry = mmio_hint[vcpu];
+ if (mmio_hint[vcpuid] &&
+ paddr >= mmio_hint[vcpuid]->mr_base &&
+ paddr <= mmio_hint[vcpuid]->mr_end) {
+ entry = mmio_hint[vcpuid];
} else
entry = NULL;
if (entry == NULL) {
if (mmio_rb_lookup(&mmio_rb_root, paddr, &entry) == 0) {
/* Update the per-vCPU cache */
- mmio_hint[vcpu] = entry;
+ mmio_hint[vcpuid] = entry;
} else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) {
perror = pthread_rwlock_unlock(&mmio_rwlock);
assert(perror == 0);
@@ -215,14 +211,13 @@ access_memory(struct vmctx *ctx, int vcpu, uint64_t paddr, mem_cb_t *cb,
assert(perror == 0);
}
- err = cb(ctx, vcpu, paddr, &entry->mr_param, arg);
+ err = cb(vcpu, paddr, &entry->mr_param, arg);
if (!immutable) {
perror = pthread_rwlock_unlock(&mmio_rwlock);
assert(perror == 0);
}
-
return (err);
}
@@ -232,26 +227,25 @@ struct emulate_mem_args {
};
static int
-emulate_mem_cb(struct vmctx *ctx, int vcpu, uint64_t paddr, struct mem_range *mr,
+emulate_mem_cb(struct vcpu *vcpu, uint64_t paddr, struct mem_range *mr,
void *arg)
{
struct emulate_mem_args *ema;
ema = arg;
- return (vmm_emulate_instruction(ctx, vcpu, paddr, ema->vie, ema->paging,
+ return (vmm_emulate_instruction(vcpu, paddr, ema->vie, ema->paging,
mem_read, mem_write, mr));
}
int
-emulate_mem(struct vmctx *ctx, int vcpu, uint64_t paddr, struct vie *vie,
+emulate_mem(struct vcpu *vcpu, uint64_t paddr, struct vie *vie,
struct vm_guest_paging *paging)
-
{
struct emulate_mem_args ema;
ema.vie = vie;
ema.paging = paging;
- return (access_memory(ctx, vcpu, paddr, emulate_mem_cb, &ema));
+ return (access_memory(vcpu, paddr, emulate_mem_cb, &ema));
}
struct rw_mem_args {
@@ -261,36 +255,35 @@ struct rw_mem_args {
};
static int
-rw_mem_cb(struct vmctx *ctx, int vcpu, uint64_t paddr, struct mem_range *mr,
- void *arg)
+rw_mem_cb(struct vcpu *vcpu, uint64_t paddr, struct mem_range *mr, void *arg)
{
struct rw_mem_args *rma;
rma = arg;
- return (mr->handler(ctx, vcpu, rma->operation, paddr, rma->size,
+ return (mr->handler(vcpu, rma->operation, paddr, rma->size,
rma->val, mr->arg1, mr->arg2));
}
int
-read_mem(struct vmctx *ctx, int vcpu, uint64_t gpa, uint64_t *rval, int size)
+read_mem(struct vcpu *vcpu, uint64_t gpa, uint64_t *rval, int size)
{
struct rw_mem_args rma;
rma.val = rval;
rma.size = size;
rma.operation = MEM_F_READ;
- return (access_memory(ctx, vcpu, gpa, rw_mem_cb, &rma));
+ return (access_memory(vcpu, gpa, rw_mem_cb, &rma));
}
int
-write_mem(struct vmctx *ctx, int vcpu, uint64_t gpa, uint64_t wval, int size)
+write_mem(struct vcpu *vcpu, uint64_t gpa, uint64_t wval, int size)
{
struct rw_mem_args rma;
rma.val = &wval;
rma.size = size;
rma.operation = MEM_F_WRITE;
- return (access_memory(ctx, vcpu, gpa, rw_mem_cb, &rma));
+ return (access_memory(vcpu, gpa, rw_mem_cb, &rma));
}
static int
diff --git a/usr.sbin/bhyve/mem.h b/usr.sbin/bhyve/mem.h
index 965079107476..90172d1c9124 100644
--- a/usr.sbin/bhyve/mem.h
+++ b/usr.sbin/bhyve/mem.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 NetApp, Inc.
* 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 _MEM_H_
@@ -33,9 +31,9 @@
#include <sys/linker_set.h>
-struct vmctx;
+struct vcpu;
-typedef int (*mem_func_t)(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
+typedef int (*mem_func_t)(struct vcpu *vcpu, int dir, uint64_t addr,
int size, uint64_t *val, void *arg1, long arg2);
struct mem_range {
@@ -53,15 +51,13 @@ struct mem_range {
#define MEM_F_IMMUTABLE 0x4 /* mem_range cannot be unregistered */
void init_mem(int ncpu);
-int emulate_mem(struct vmctx *, int vcpu, uint64_t paddr, struct vie *vie,
+int emulate_mem(struct vcpu *vcpu, uint64_t paddr, struct vie *vie,
struct vm_guest_paging *paging);
-int read_mem(struct vmctx *ctx, int vcpu, uint64_t gpa, uint64_t *rval,
- int size);
+int read_mem(struct vcpu *vpu, uint64_t gpa, uint64_t *rval, int size);
int register_mem(struct mem_range *memp);
int register_mem_fallback(struct mem_range *memp);
int unregister_mem(struct mem_range *memp);
-int write_mem(struct vmctx *ctx, int vcpu, uint64_t gpa, uint64_t wval,
- int size);
+int write_mem(struct vcpu *vcpu, uint64_t gpa, uint64_t wval, int size);
#endif /* _MEM_H_ */
diff --git a/usr.sbin/bhyve/mevent.c b/usr.sbin/bhyve/mevent.c
index b7749ed67745..dbcc39148ca1 100644
--- a/usr.sbin/bhyve/mevent.c
+++ b/usr.sbin/bhyve/mevent.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* 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$
*/
/*
@@ -34,8 +32,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#ifndef WITHOUT_CAPSICUM
#include <capsicum_helpers.h>
@@ -84,6 +80,12 @@ struct mevent {
LIST_ENTRY(mevent) me_list;
};
+enum mevent_update_type {
+ UPDATE_ENABLE,
+ UPDATE_DISABLE,
+ UPDATE_TIMER,
+};
+
static LIST_HEAD(listhead, mevent) global_head, change_head;
static void
@@ -99,7 +101,7 @@ mevent_qunlock(void)
}
static void
-mevent_pipe_read(int fd, enum ev_type type, void *param)
+mevent_pipe_read(int fd, enum ev_type type __unused, void *param __unused)
{
char buf[MEVENT_MAX];
int status;
@@ -241,7 +243,6 @@ mevent_build(struct kevent *kev)
*/
close(mevp->me_fd);
} else {
- assert((mevp->me_state & EV_ADD) == 0);
mevent_populate(mevp, &kev[i]);
i++;
}
@@ -379,30 +380,35 @@ mevent_add_disabled(int tfd, enum ev_type type,
}
static int
-mevent_update(struct mevent *evp, bool enable)
+mevent_update(struct mevent *evp, enum mevent_update_type type, int msecs)
{
int newstate;
mevent_qlock();
/*
- * It's not possible to enable/disable a deleted event
+ * It's not possible to update a deleted event
*/
assert((evp->me_state & EV_DELETE) == 0);
newstate = evp->me_state;
- if (enable) {
+ if (type == UPDATE_ENABLE) {
newstate |= EV_ENABLE;
newstate &= ~EV_DISABLE;
- } else {
+ } else if (type == UPDATE_DISABLE) {
newstate |= EV_DISABLE;
newstate &= ~EV_ENABLE;
+ } else {
+ assert(type == UPDATE_TIMER);
+ assert(evp->me_type == EVF_TIMER);
+ newstate |= EV_ADD;
+ evp->me_msecs = msecs;
}
/*
- * No update needed if state isn't changing
+ * No update needed if enable/disable had no effect
*/
- if (evp->me_state != newstate) {
+ if (evp->me_state != newstate || type == UPDATE_TIMER) {
evp->me_state = newstate;
/*
@@ -425,15 +431,19 @@ mevent_update(struct mevent *evp, bool enable)
int
mevent_enable(struct mevent *evp)
{
-
- return (mevent_update(evp, true));
+ return (mevent_update(evp, UPDATE_ENABLE, -1));
}
int
mevent_disable(struct mevent *evp)
{
+ return (mevent_update(evp, UPDATE_DISABLE, -1));
+}
- return (mevent_update(evp, false));
+int
+mevent_timer_update(struct mevent *evp, int msecs)
+{
+ return (mevent_update(evp, UPDATE_TIMER, msecs));
}
static int
diff --git a/usr.sbin/bhyve/mevent.h b/usr.sbin/bhyve/mevent.h
index 8c3db9db54a0..23107fc55982 100644
--- a/usr.sbin/bhyve/mevent.h
+++ b/usr.sbin/bhyve/mevent.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* 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 _MEVENT_H_
@@ -57,6 +55,7 @@ int mevent_enable(struct mevent *evp);
int mevent_disable(struct mevent *evp);
int mevent_delete(struct mevent *evp);
int mevent_delete_close(struct mevent *evp);
+int mevent_timer_update(struct mevent *evp, int msecs);
void mevent_dispatch(void);
diff --git a/usr.sbin/bhyve/mevent_test.c b/usr.sbin/bhyve/mevent_test.c
index eda1c100e8a3..60aab4ad849a 100644
--- a/usr.sbin/bhyve/mevent_test.c
+++ b/usr.sbin/bhyve/mevent_test.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* 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$
*/
/*
diff --git a/usr.sbin/bhyve/net_backend_netgraph.c b/usr.sbin/bhyve/net_backend_netgraph.c
new file mode 100644
index 000000000000..7d1659d611e3
--- /dev/null
+++ b/usr.sbin/bhyve/net_backend_netgraph.c
@@ -0,0 +1,191 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019 Vincenzo Maffione <vmaffione@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WITHOUT_CAPSICUM
+#include <sys/capsicum.h>
+#endif
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+
+#ifndef WITHOUT_CAPSICUM
+#include <capsicum_helpers.h>
+#endif
+#include <err.h>
+#include <netgraph.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "debug.h"
+#include "net_backends.h"
+#include "net_backends_priv.h"
+
+#define NG_SBUF_MAX_SIZE (4 * 1024 * 1024)
+
+static int
+ng_init(struct net_backend *be, const char *devname __unused,
+ nvlist_t *nvl, net_be_rxeof_t cb, void *param)
+{
+ struct tap_priv *p = NET_BE_PRIV(be);
+ struct ngm_connect ngc;
+ const char *value, *nodename;
+ int sbsz;
+ int ctrl_sock;
+ int flags;
+ unsigned long maxsbsz;
+ size_t msbsz;
+#ifndef WITHOUT_CAPSICUM
+ cap_rights_t rights;
+#endif
+
+ if (cb == NULL) {
+ EPRINTLN("Netgraph backend requires non-NULL callback");
+ return (-1);
+ }
+
+ be->fd = -1;
+
+ memset(&ngc, 0, sizeof(ngc));
+
+ value = get_config_value_node(nvl, "path");
+ if (value == NULL) {
+ EPRINTLN("path must be provided");
+ return (-1);
+ }
+ strncpy(ngc.path, value, NG_PATHSIZ - 1);
+
+ value = get_config_value_node(nvl, "hook");
+ if (value == NULL)
+ value = "vmlink";
+ strncpy(ngc.ourhook, value, NG_HOOKSIZ - 1);
+
+ value = get_config_value_node(nvl, "peerhook");
+ if (value == NULL) {
+ EPRINTLN("peer hook must be provided");
+ return (-1);
+ }
+ strncpy(ngc.peerhook, value, NG_HOOKSIZ - 1);
+
+ nodename = get_config_value_node(nvl, "socket");
+ if (NgMkSockNode(nodename,
+ &ctrl_sock, &be->fd) < 0) {
+ EPRINTLN("can't get Netgraph sockets");
+ return (-1);
+ }
+
+ if (NgSendMsg(ctrl_sock, ".",
+ NGM_GENERIC_COOKIE,
+ NGM_CONNECT, &ngc, sizeof(ngc)) < 0) {
+ EPRINTLN("can't connect to node");
+ close(ctrl_sock);
+ goto error;
+ }
+
+ close(ctrl_sock);
+
+ flags = fcntl(be->fd, F_GETFL);
+
+ if (flags < 0) {
+ EPRINTLN("can't get socket flags");
+ goto error;
+ }
+
+ if (fcntl(be->fd, F_SETFL, flags | O_NONBLOCK) < 0) {
+ EPRINTLN("can't set O_NONBLOCK flag");
+ goto error;
+ }
+
+ /*
+ * The default ng_socket(4) buffer's size is too low.
+ * Calculate the minimum value between NG_SBUF_MAX_SIZE
+ * and kern.ipc.maxsockbuf.
+ */
+ msbsz = sizeof(maxsbsz);
+ if (sysctlbyname("kern.ipc.maxsockbuf", &maxsbsz, &msbsz,
+ NULL, 0) < 0) {
+ EPRINTLN("can't get 'kern.ipc.maxsockbuf' value");
+ goto error;
+ }
+
+ /*
+ * We can't set the socket buffer size to kern.ipc.maxsockbuf value,
+ * as it takes into account the mbuf(9) overhead.
+ */
+ maxsbsz = maxsbsz * MCLBYTES / (MSIZE + MCLBYTES);
+
+ sbsz = MIN(NG_SBUF_MAX_SIZE, maxsbsz);
+
+ if (setsockopt(be->fd, SOL_SOCKET, SO_SNDBUF, &sbsz,
+ sizeof(sbsz)) < 0) {
+ EPRINTLN("can't set TX buffer size");
+ goto error;
+ }
+
+ if (setsockopt(be->fd, SOL_SOCKET, SO_RCVBUF, &sbsz,
+ sizeof(sbsz)) < 0) {
+ EPRINTLN("can't set RX buffer size");
+ goto error;
+ }
+
+#ifndef WITHOUT_CAPSICUM
+ cap_rights_init(&rights, CAP_EVENT, CAP_READ, CAP_WRITE);
+ if (caph_rights_limit(be->fd, &rights) == -1)
+ errx(EX_OSERR, "Unable to apply rights for sandbox");
+#endif
+
+ memset(p->bbuf, 0, sizeof(p->bbuf));
+ p->bbuflen = 0;
+
+ p->mevp = mevent_add_disabled(be->fd, EVF_READ, cb, param);
+ if (p->mevp == NULL) {
+ EPRINTLN("Could not register event");
+ goto error;
+ }
+
+ return (0);
+
+error:
+ tap_cleanup(be);
+ return (-1);
+}
+
+static struct net_backend ng_backend = {
+ .prefix = "netgraph",
+ .priv_size = sizeof(struct tap_priv),
+ .init = ng_init,
+ .cleanup = tap_cleanup,
+ .send = tap_send,
+ .peek_recvlen = tap_peek_recvlen,
+ .recv = tap_recv,
+ .recv_enable = tap_recv_enable,
+ .recv_disable = tap_recv_disable,
+ .get_cap = tap_get_cap,
+ .set_cap = tap_set_cap,
+};
+
+DATA_SET(net_backend_set, ng_backend);
diff --git a/usr.sbin/bhyve/net_backend_netmap.c b/usr.sbin/bhyve/net_backend_netmap.c
new file mode 100644
index 000000000000..5ba11b96797c
--- /dev/null
+++ b/usr.sbin/bhyve/net_backend_netmap.c
@@ -0,0 +1,384 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019 Vincenzo Maffione <vmaffione@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <net/if.h>
+#include <net/netmap.h>
+#include <net/netmap_virt.h>
+#define NETMAP_WITH_LIBS
+#include <net/netmap_user.h>
+
+#include <assert.h>
+
+#include "debug.h"
+#include "iov.h"
+#include "mevent.h"
+#include "net_backends.h"
+#include "net_backends_priv.h"
+
+/* The virtio-net features supported by netmap. */
+#define NETMAP_FEATURES (VIRTIO_NET_F_CSUM | VIRTIO_NET_F_HOST_TSO4 | \
+ VIRTIO_NET_F_HOST_TSO6 | VIRTIO_NET_F_HOST_UFO | \
+ VIRTIO_NET_F_GUEST_CSUM | VIRTIO_NET_F_GUEST_TSO4 | \
+ VIRTIO_NET_F_GUEST_TSO6 | VIRTIO_NET_F_GUEST_UFO)
+
+struct netmap_priv {
+ char ifname[IFNAMSIZ];
+ struct nm_desc *nmd;
+ uint16_t memid;
+ struct netmap_ring *rx;
+ struct netmap_ring *tx;
+ struct mevent *mevp;
+ net_be_rxeof_t cb;
+ void *cb_param;
+};
+
+static void
+nmreq_init(struct nmreq *req, char *ifname)
+{
+
+ memset(req, 0, sizeof(*req));
+ strlcpy(req->nr_name, ifname, sizeof(req->nr_name));
+ req->nr_version = NETMAP_API;
+}
+
+static int
+netmap_set_vnet_hdr_len(struct net_backend *be, int vnet_hdr_len)
+{
+ int err;
+ struct nmreq req;
+ struct netmap_priv *priv = NET_BE_PRIV(be);
+
+ nmreq_init(&req, priv->ifname);
+ req.nr_cmd = NETMAP_BDG_VNET_HDR;
+ req.nr_arg1 = vnet_hdr_len;
+ err = ioctl(be->fd, NIOCREGIF, &req);
+ if (err) {
+ EPRINTLN("Unable to set vnet header length %d", vnet_hdr_len);
+ return (err);
+ }
+
+ be->be_vnet_hdr_len = vnet_hdr_len;
+
+ return (0);
+}
+
+static int
+netmap_has_vnet_hdr_len(struct net_backend *be, unsigned vnet_hdr_len)
+{
+ unsigned prev_hdr_len = be->be_vnet_hdr_len;
+ int ret;
+
+ if (vnet_hdr_len == prev_hdr_len) {
+ return (1);
+ }
+
+ ret = netmap_set_vnet_hdr_len(be, vnet_hdr_len);
+ if (ret) {
+ return (0);
+ }
+
+ netmap_set_vnet_hdr_len(be, prev_hdr_len);
+
+ return (1);
+}
+
+static uint64_t
+netmap_get_cap(struct net_backend *be)
+{
+
+ return (netmap_has_vnet_hdr_len(be, VNET_HDR_LEN) ?
+ NETMAP_FEATURES : 0);
+}
+
+static int
+netmap_set_cap(struct net_backend *be, uint64_t features __unused,
+ unsigned vnet_hdr_len)
+{
+
+ return (netmap_set_vnet_hdr_len(be, vnet_hdr_len));
+}
+
+static int
+netmap_init(struct net_backend *be, const char *devname,
+ nvlist_t *nvl __unused, net_be_rxeof_t cb, void *param)
+{
+ struct netmap_priv *priv = NET_BE_PRIV(be);
+
+ strlcpy(priv->ifname, devname, sizeof(priv->ifname));
+ priv->ifname[sizeof(priv->ifname) - 1] = '\0';
+
+ priv->nmd = nm_open(priv->ifname, NULL, NETMAP_NO_TX_POLL, NULL);
+ if (priv->nmd == NULL) {
+ EPRINTLN("Unable to nm_open(): interface '%s', errno (%s)",
+ devname, strerror(errno));
+ return (-1);
+ }
+
+ priv->memid = priv->nmd->req.nr_arg2;
+ priv->tx = NETMAP_TXRING(priv->nmd->nifp, 0);
+ priv->rx = NETMAP_RXRING(priv->nmd->nifp, 0);
+ priv->cb = cb;
+ priv->cb_param = param;
+ be->fd = priv->nmd->fd;
+
+ priv->mevp = mevent_add_disabled(be->fd, EVF_READ, cb, param);
+ if (priv->mevp == NULL) {
+ EPRINTLN("Could not register event");
+ return (-1);
+ }
+
+ return (0);
+}
+
+static void
+netmap_cleanup(struct net_backend *be)
+{
+ struct netmap_priv *priv = NET_BE_PRIV(be);
+
+ if (priv->mevp) {
+ mevent_delete(priv->mevp);
+ }
+ if (priv->nmd) {
+ nm_close(priv->nmd);
+ }
+ be->fd = -1;
+}
+
+static ssize_t
+netmap_send(struct net_backend *be, const struct iovec *iov,
+ int iovcnt)
+{
+ struct netmap_priv *priv = NET_BE_PRIV(be);
+ struct netmap_ring *ring;
+ ssize_t totlen = 0;
+ int nm_buf_size;
+ int nm_buf_len;
+ uint32_t head;
+ uint8_t *nm_buf;
+ int j;
+
+ ring = priv->tx;
+ head = ring->head;
+ if (head == ring->tail) {
+ EPRINTLN("No space, drop %zu bytes", count_iov(iov, iovcnt));
+ goto txsync;
+ }
+ nm_buf = NETMAP_BUF(ring, ring->slot[head].buf_idx);
+ nm_buf_size = ring->nr_buf_size;
+ nm_buf_len = 0;
+
+ for (j = 0; j < iovcnt; j++) {
+ uint8_t *iov_frag_buf = iov[j].iov_base;
+ int iov_frag_size = iov[j].iov_len;
+
+ totlen += iov_frag_size;
+
+ /*
+ * Split each iovec fragment over more netmap slots, if
+ * necessary.
+ */
+ for (;;) {
+ int copylen;
+
+ copylen = iov_frag_size < nm_buf_size ? iov_frag_size : nm_buf_size;
+ memcpy(nm_buf, iov_frag_buf, copylen);
+
+ iov_frag_buf += copylen;
+ iov_frag_size -= copylen;
+ nm_buf += copylen;
+ nm_buf_size -= copylen;
+ nm_buf_len += copylen;
+
+ if (iov_frag_size == 0) {
+ break;
+ }
+
+ ring->slot[head].len = nm_buf_len;
+ ring->slot[head].flags = NS_MOREFRAG;
+ head = nm_ring_next(ring, head);
+ if (head == ring->tail) {
+ /*
+ * We ran out of netmap slots while
+ * splitting the iovec fragments.
+ */
+ EPRINTLN("No space, drop %zu bytes",
+ count_iov(iov, iovcnt));
+ goto txsync;
+ }
+ nm_buf = NETMAP_BUF(ring, ring->slot[head].buf_idx);
+ nm_buf_size = ring->nr_buf_size;
+ nm_buf_len = 0;
+ }
+ }
+
+ /* Complete the last slot, which must not have NS_MOREFRAG set. */
+ ring->slot[head].len = nm_buf_len;
+ ring->slot[head].flags = 0;
+ head = nm_ring_next(ring, head);
+
+ /* Now update ring->head and ring->cur. */
+ ring->head = ring->cur = head;
+txsync:
+ ioctl(be->fd, NIOCTXSYNC, NULL);
+
+ return (totlen);
+}
+
+static ssize_t
+netmap_peek_recvlen(struct net_backend *be)
+{
+ struct netmap_priv *priv = NET_BE_PRIV(be);
+ struct netmap_ring *ring = priv->rx;
+ uint32_t head = ring->head;
+ ssize_t totlen = 0;
+
+ while (head != ring->tail) {
+ struct netmap_slot *slot = ring->slot + head;
+
+ totlen += slot->len;
+ if ((slot->flags & NS_MOREFRAG) == 0)
+ break;
+ head = nm_ring_next(ring, head);
+ }
+
+ return (totlen);
+}
+
+static ssize_t
+netmap_recv(struct net_backend *be, const struct iovec *iov, int iovcnt)
+{
+ struct netmap_priv *priv = NET_BE_PRIV(be);
+ struct netmap_slot *slot = NULL;
+ struct netmap_ring *ring;
+ uint8_t *iov_frag_buf;
+ int iov_frag_size;
+ ssize_t totlen = 0;
+ uint32_t head;
+
+ assert(iovcnt);
+
+ ring = priv->rx;
+ head = ring->head;
+ iov_frag_buf = iov->iov_base;
+ iov_frag_size = iov->iov_len;
+
+ do {
+ uint8_t *nm_buf;
+ int nm_buf_len;
+
+ if (head == ring->tail) {
+ return (0);
+ }
+
+ slot = ring->slot + head;
+ nm_buf = NETMAP_BUF(ring, slot->buf_idx);
+ nm_buf_len = slot->len;
+
+ for (;;) {
+ int copylen = nm_buf_len < iov_frag_size ?
+ nm_buf_len : iov_frag_size;
+
+ memcpy(iov_frag_buf, nm_buf, copylen);
+ nm_buf += copylen;
+ nm_buf_len -= copylen;
+ iov_frag_buf += copylen;
+ iov_frag_size -= copylen;
+ totlen += copylen;
+
+ if (nm_buf_len == 0) {
+ break;
+ }
+
+ iov++;
+ iovcnt--;
+ if (iovcnt == 0) {
+ /* No space to receive. */
+ EPRINTLN("Short iov, drop %zd bytes",
+ totlen);
+ return (-ENOSPC);
+ }
+ iov_frag_buf = iov->iov_base;
+ iov_frag_size = iov->iov_len;
+ }
+
+ head = nm_ring_next(ring, head);
+
+ } while (slot->flags & NS_MOREFRAG);
+
+ /* Release slots to netmap. */
+ ring->head = ring->cur = head;
+
+ return (totlen);
+}
+
+static void
+netmap_recv_enable(struct net_backend *be)
+{
+ struct netmap_priv *priv = NET_BE_PRIV(be);
+
+ mevent_enable(priv->mevp);
+}
+
+static void
+netmap_recv_disable(struct net_backend *be)
+{
+ struct netmap_priv *priv = NET_BE_PRIV(be);
+
+ mevent_disable(priv->mevp);
+}
+
+static struct net_backend netmap_backend = {
+ .prefix = "netmap",
+ .priv_size = sizeof(struct netmap_priv),
+ .init = netmap_init,
+ .cleanup = netmap_cleanup,
+ .send = netmap_send,
+ .peek_recvlen = netmap_peek_recvlen,
+ .recv = netmap_recv,
+ .recv_enable = netmap_recv_enable,
+ .recv_disable = netmap_recv_disable,
+ .get_cap = netmap_get_cap,
+ .set_cap = netmap_set_cap,
+};
+
+/* A clone of the netmap backend, with a different prefix. */
+static struct net_backend vale_backend = {
+ .prefix = "vale",
+ .priv_size = sizeof(struct netmap_priv),
+ .init = netmap_init,
+ .cleanup = netmap_cleanup,
+ .send = netmap_send,
+ .peek_recvlen = netmap_peek_recvlen,
+ .recv = netmap_recv,
+ .recv_enable = netmap_recv_enable,
+ .recv_disable = netmap_recv_disable,
+ .get_cap = netmap_get_cap,
+ .set_cap = netmap_set_cap,
+};
+
+DATA_SET(net_backend_set, netmap_backend);
+DATA_SET(net_backend_set, vale_backend);
diff --git a/usr.sbin/bhyve/net_backend_slirp.c b/usr.sbin/bhyve/net_backend_slirp.c
new file mode 100644
index 000000000000..5ae33801387c
--- /dev/null
+++ b/usr.sbin/bhyve/net_backend_slirp.c
@@ -0,0 +1,664 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Mark Johnston <markj@FreeBSD.org>
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory (Department of Computer Science and Technology) under Innovate
+ * UK project 105694, "Digital Security by Design (DSbD) Technology Platform
+ * Prototype".
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * The slirp backend enables unprivileged networking via libslirp, which must be
+ * installed on the host system via pkg or the ports tree. bhyve dlopen()s
+ * libslirp.so upon instantiating the slirp backend. Various network parameters
+ * are hard-coded in _slirp_init().
+ *
+ * Packets received from the guest (i.e., transmitted by the frontend, such as a
+ * virtio NIC device model) are injected into the slirp backend via slirp_send().
+ * Packets to be transmitted to the guest (i.e., inserted into the frontend's
+ * receive buffers) are buffered in a per-interface socket pair and read by the
+ * mevent loop. Sockets instantiated by libslirp are monitored by a thread
+ * which uses poll() and slirp_pollfds_poll() to drive libslirp events; this
+ * thread also handles timeout events from the libslirp context.
+ */
+
+#include <sys/socket.h>
+
+#include <assert.h>
+#include <capsicum_helpers.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <poll.h>
+#include <pthread.h>
+#include <pthread_np.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "debug.h"
+#include "libslirp.h"
+#include "mevent.h"
+#include "net_backends.h"
+#include "net_backends_priv.h"
+
+typedef int (*slirp_add_hostxfwd_p_t)(Slirp *,
+ const struct sockaddr *, socklen_t, const struct sockaddr *, socklen_t,
+ int);
+typedef void (*slirp_cleanup_p_t)(Slirp *);
+typedef void (*slirp_input_p_t)(Slirp *, const uint8_t *, int);
+typedef Slirp *(*slirp_new_p_t)(const SlirpConfig *, const SlirpCb *, void *);
+typedef void (*slirp_pollfds_fill_p_t)(Slirp *, uint32_t *timeout,
+ SlirpAddPollCb, void *);
+typedef void (*slirp_pollfds_poll_p_t)(Slirp *, int, SlirpGetREventsCb, void *);
+
+/* Function pointer table, initialized by slirp_init_once(). */
+static slirp_add_hostxfwd_p_t slirp_add_hostxfwd_p;
+static slirp_cleanup_p_t slirp_cleanup_p;
+static slirp_input_p_t slirp_input_p;
+static slirp_new_p_t slirp_new_p;
+static slirp_pollfds_fill_p_t slirp_pollfds_fill_p;
+static slirp_pollfds_poll_p_t slirp_pollfds_poll_p;
+
+static int
+slirp_init_once(void)
+{
+ static void *handle = NULL;
+
+ if (handle != NULL)
+ return (0);
+ handle = dlopen("libslirp.so.0", RTLD_LAZY);
+ if (handle == NULL) {
+ EPRINTLN("Unable to open libslirp.so.0: %s", dlerror());
+ return (-1);
+ }
+
+#define IMPORT_SYM(sym) do { \
+ sym##_p = (sym##_p_t)dlsym(handle, #sym); \
+ if (sym##_p == NULL) { \
+ EPRINTLN("failed to resolve %s", #sym); \
+ goto err; \
+ } \
+} while (0)
+ IMPORT_SYM(slirp_add_hostxfwd);
+ IMPORT_SYM(slirp_cleanup);
+ IMPORT_SYM(slirp_input);
+ IMPORT_SYM(slirp_new);
+ IMPORT_SYM(slirp_pollfds_fill);
+ IMPORT_SYM(slirp_pollfds_poll);
+#undef IMPORT_SYM
+
+ /*
+ * libslirp uses glib, which uses tzdata to format log messages. Help
+ * it out.
+ *
+ * XXX-MJ glib will also look for charset files, not sure what we can do
+ * about that...
+ */
+ caph_cache_tzdata();
+
+ return (0);
+
+err:
+ dlclose(handle);
+ handle = NULL;
+ return (-1);
+}
+
+struct slirp_priv {
+ Slirp *slirp;
+
+#define SLIRP_MTU 2048
+ struct mevent *mevp;
+ int pipe[2];
+
+ pthread_t pollfd_td;
+ struct pollfd *pollfds;
+ size_t npollfds;
+
+ /* Serializes libslirp calls. */
+ pthread_mutex_t mtx;
+};
+
+static void
+slirp_priv_init(struct slirp_priv *priv)
+{
+ int error;
+
+ memset(priv, 0, sizeof(*priv));
+ priv->pipe[0] = priv->pipe[1] = -1;
+ error = pthread_mutex_init(&priv->mtx, NULL);
+ assert(error == 0);
+}
+
+static void
+slirp_priv_cleanup(struct slirp_priv *priv)
+{
+ int error;
+
+ if (priv->pipe[0] != -1) {
+ error = close(priv->pipe[0]);
+ assert(error == 0);
+ }
+ if (priv->pipe[1] != -1) {
+ error = close(priv->pipe[1]);
+ assert(error == 0);
+ }
+ if (priv->mevp)
+ mevent_delete(priv->mevp);
+ if (priv->slirp != NULL)
+ slirp_cleanup_p(priv->slirp);
+ error = pthread_mutex_destroy(&priv->mtx);
+ assert(error == 0);
+}
+
+static int64_t
+slirp_cb_clock_get_ns(void *param __unused)
+{
+ struct timespec ts;
+ int error;
+
+ error = clock_gettime(CLOCK_MONOTONIC, &ts);
+ assert(error == 0);
+ return ((int64_t)(ts.tv_sec * 1000000000L + ts.tv_nsec));
+}
+
+static void
+slirp_cb_notify(void *param __unused)
+{
+}
+
+static void
+slirp_cb_register_poll_fd(int fd, void *param __unused)
+{
+ const int one = 1;
+
+ (void)setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof(int));
+}
+
+static ssize_t
+slirp_cb_send_packet(const void *buf, size_t len, void *param)
+{
+ struct slirp_priv *priv;
+ ssize_t n;
+
+ priv = param;
+
+ assert(len <= SLIRP_MTU);
+ n = send(priv->pipe[1], buf, len, 0);
+ if (n < 0) {
+ EPRINTLN("slirp_cb_send_packet: send: %s", strerror(errno));
+ return (n);
+ }
+ assert((size_t)n == len);
+
+ return (n);
+}
+
+static void
+slirp_cb_unregister_poll_fd(int fd __unused, void *opaque __unused)
+{
+}
+
+/* Callbacks invoked from within libslirp. */
+static const struct SlirpCb slirp_cbs = {
+ .clock_get_ns = slirp_cb_clock_get_ns,
+ .notify = slirp_cb_notify,
+ .register_poll_fd = slirp_cb_register_poll_fd,
+ .send_packet = slirp_cb_send_packet,
+ .unregister_poll_fd = slirp_cb_unregister_poll_fd,
+};
+
+static int
+slirpev2pollev(int events)
+{
+ int ret;
+
+ ret = 0;
+ if (events & SLIRP_POLL_IN)
+ ret |= POLLIN;
+ if (events & SLIRP_POLL_OUT)
+ ret |= POLLOUT;
+ if (events & SLIRP_POLL_PRI)
+ ret |= POLLPRI;
+ if (events & SLIRP_POLL_ERR)
+ ret |= POLLERR;
+ if (events & SLIRP_POLL_HUP)
+ ret |= POLLHUP;
+ return (ret);
+}
+
+static int
+pollev2slirpev(int events)
+{
+ int ret;
+
+ ret = 0;
+ if (events & POLLIN)
+ ret |= SLIRP_POLL_IN;
+ if (events & POLLOUT)
+ ret |= SLIRP_POLL_OUT;
+ if (events & POLLPRI)
+ ret |= SLIRP_POLL_PRI;
+ if (events & POLLERR)
+ ret |= SLIRP_POLL_ERR;
+ if (events & POLLHUP)
+ ret |= SLIRP_POLL_HUP;
+ return (ret);
+}
+
+static int
+slirp_addpoll_cb(int fd, int events, void *param)
+{
+ struct slirp_priv *priv;
+ struct pollfd *pollfd, *pollfds;
+ size_t i;
+
+ priv = param;
+
+ for (i = 0; i < priv->npollfds; i++)
+ if (priv->pollfds[i].fd == -1)
+ break;
+ if (i == priv->npollfds) {
+ const size_t POLLFD_GROW = 4;
+
+ priv->npollfds += POLLFD_GROW;
+ pollfds = realloc(priv->pollfds,
+ sizeof(*pollfds) * priv->npollfds);
+ if (pollfds == NULL)
+ return (-1);
+ for (i = priv->npollfds - POLLFD_GROW; i < priv->npollfds; i++)
+ pollfds[i].fd = -1;
+ priv->pollfds = pollfds;
+
+ i = priv->npollfds - POLLFD_GROW;
+ }
+ pollfd = &priv->pollfds[i];
+ pollfd->fd = fd;
+ pollfd->events = slirpev2pollev(events);
+ pollfd->revents = 0;
+
+ return ((int)i);
+}
+
+static int
+slirp_poll_revents(int idx, void *param)
+{
+ struct slirp_priv *priv;
+ struct pollfd *pollfd;
+
+ priv = param;
+ pollfd = &priv->pollfds[idx];
+ assert(pollfd->fd != -1);
+ return (pollev2slirpev(pollfd->revents));
+}
+
+static void *
+slirp_pollfd_td_loop(void *param)
+{
+ struct slirp_priv *priv;
+ struct pollfd *pollfds;
+ size_t npollfds;
+ uint32_t timeout;
+ int error;
+
+ pthread_set_name_np(pthread_self(), "slirp pollfd");
+ priv = param;
+
+ pthread_mutex_lock(&priv->mtx);
+ for (;;) {
+ for (size_t i = 0; i < priv->npollfds; i++)
+ priv->pollfds[i].fd = -1;
+
+ timeout = UINT32_MAX;
+ slirp_pollfds_fill_p(priv->slirp, &timeout, slirp_addpoll_cb,
+ priv);
+
+ pollfds = priv->pollfds;
+ npollfds = priv->npollfds;
+ pthread_mutex_unlock(&priv->mtx);
+ for (;;) {
+ error = poll(pollfds, npollfds, timeout);
+ if (error == -1) {
+ if (errno != EINTR) {
+ EPRINTLN("poll: %s", strerror(errno));
+ exit(1);
+ }
+ continue;
+ }
+ break;
+ }
+ pthread_mutex_lock(&priv->mtx);
+ slirp_pollfds_poll_p(priv->slirp, error == -1,
+ slirp_poll_revents, priv);
+ }
+}
+
+static int
+parse_addr(char *addr, struct sockaddr_in *sinp)
+{
+ char *port;
+ int error, porti;
+
+ memset(sinp, 0, sizeof(*sinp));
+ sinp->sin_family = AF_INET;
+ sinp->sin_len = sizeof(struct sockaddr_in);
+
+ port = strchr(addr, ':');
+ if (port == NULL)
+ return (EINVAL);
+ *port++ = '\0';
+
+ if (strlen(addr) > 0) {
+ error = inet_pton(AF_INET, addr, &sinp->sin_addr);
+ if (error != 1)
+ return (error == 0 ? EPFNOSUPPORT : errno);
+ } else {
+ sinp->sin_addr.s_addr = htonl(INADDR_ANY);
+ }
+
+ porti = strlen(port) > 0 ? atoi(port) : 0;
+ if (porti < 0 || porti > UINT16_MAX)
+ return (EINVAL);
+ sinp->sin_port = htons(porti);
+
+ return (0);
+}
+
+static int
+parse_hostfwd_rule(const char *descr, int *is_udp, struct sockaddr *hostaddr,
+ struct sockaddr *guestaddr)
+{
+ struct sockaddr_in *hostaddrp, *guestaddrp;
+ const char *proto;
+ char *p, *host, *guest;
+ int error;
+
+ error = 0;
+ *is_udp = 0;
+
+ p = strdup(descr);
+ if (p == NULL)
+ return (ENOMEM);
+
+ host = strchr(p, ':');
+ if (host == NULL) {
+ error = EINVAL;
+ goto out;
+ }
+ *host++ = '\0';
+
+ proto = p;
+ *is_udp = strcmp(proto, "udp") == 0;
+
+ guest = strchr(host, '-');
+ if (guest == NULL) {
+ error = EINVAL;
+ goto out;
+ }
+ *guest++ = '\0';
+
+ hostaddrp = (struct sockaddr_in *)hostaddr;
+ error = parse_addr(host, hostaddrp);
+ if (error != 0)
+ goto out;
+
+ guestaddrp = (struct sockaddr_in *)guestaddr;
+ error = parse_addr(guest, guestaddrp);
+ if (error != 0)
+ goto out;
+
+out:
+ free(p);
+ return (error);
+}
+
+static int
+config_one_hostfwd(struct slirp_priv *priv, const char *rule)
+{
+ struct sockaddr hostaddr, guestaddr;
+ int error, is_udp;
+
+ error = parse_hostfwd_rule(rule, &is_udp, &hostaddr, &guestaddr);
+ if (error != 0) {
+ EPRINTLN("Unable to parse hostfwd rule '%s': %s",
+ rule, strerror(error));
+ return (error);
+ }
+
+ error = slirp_add_hostxfwd_p(priv->slirp, &hostaddr, hostaddr.sa_len,
+ &guestaddr, guestaddr.sa_len, is_udp ? SLIRP_HOSTFWD_UDP : 0);
+ if (error != 0) {
+ EPRINTLN("Unable to add hostfwd rule '%s': %s",
+ rule, strerror(errno));
+ return (error);
+ }
+
+ return (0);
+}
+
+static int
+_slirp_init(struct net_backend *be, const char *devname __unused,
+ nvlist_t *nvl, net_be_rxeof_t cb, void *param)
+{
+ struct slirp_priv *priv = NET_BE_PRIV(be);
+ SlirpConfig config = {
+ .version = 4,
+ .if_mtu = SLIRP_MTU,
+ .restricted = true,
+ .in_enabled = true,
+ .vnetwork.s_addr = htonl(0x0a000200), /* 10.0.2.0/24 */
+ .vnetmask.s_addr = htonl(0xffffff00),
+ .vdhcp_start.s_addr = htonl(0x0a00020f),/* 10.0.2.15 */
+ .vhost.s_addr = htonl(0x0a000202), /* 10.0.2.2 */
+ .enable_emu = false,
+ };
+ const char *hostfwd;
+ int error, sndbuf;
+
+ error = slirp_init_once();
+ if (error != 0)
+ return (error);
+
+ slirp_priv_init(priv);
+
+ priv->slirp = slirp_new_p(&config, &slirp_cbs, priv);
+ if (priv->slirp == NULL) {
+ EPRINTLN("Unable to create slirp instance");
+ goto err;
+ }
+
+ hostfwd = get_config_value_node(nvl, "hostfwd");
+ if (hostfwd != NULL) {
+ char *rules, *tofree;
+ const char *rule;
+
+ tofree = rules = strdup(hostfwd);
+ if (rules == NULL)
+ goto err;
+ while ((rule = strsep(&rules, ";")) != NULL) {
+ error = config_one_hostfwd(priv, rule);
+ if (error != 0) {
+ free(tofree);
+ goto err;
+ }
+ }
+ free(tofree);
+ }
+
+ error = socketpair(PF_LOCAL, SOCK_DGRAM, 0, priv->pipe);
+ if (error != 0) {
+ EPRINTLN("Unable to create pipe: %s", strerror(errno));
+ goto err;
+ }
+
+ /*
+ * Try to avoid dropping buffered packets in slirp_cb_send_packet().
+ */
+ sndbuf = 1024 * 1024;
+ error = setsockopt(priv->pipe[1], SOL_SOCKET, SO_SNDBUF, &sndbuf,
+ sizeof(sndbuf));
+ if (error != 0) {
+ EPRINTLN("Could not set socket buffer size: %s",
+ strerror(errno));
+ goto err;
+ }
+
+ be->fd = priv->pipe[0];
+ priv->mevp = mevent_add_disabled(be->fd, EVF_READ, cb, param);
+ if (priv->mevp == NULL) {
+ EPRINTLN("Could not register event");
+ goto err;
+ }
+
+ error = pthread_create(&priv->pollfd_td, NULL, slirp_pollfd_td_loop,
+ priv);
+ if (error != 0) {
+ EPRINTLN("Unable to create pollfd thread: %s", strerror(error));
+ goto err;
+ }
+
+ return (0);
+
+err:
+ slirp_priv_cleanup(priv);
+ return (-1);
+}
+
+static ssize_t
+slirp_send(struct net_backend *be, const struct iovec *iov, int iovcnt)
+{
+ struct slirp_priv *priv = NET_BE_PRIV(be);
+
+ if (iovcnt == 1) {
+ /* We can avoid copying if there's a single segment. */
+ pthread_mutex_lock(&priv->mtx);
+ slirp_input_p(priv->slirp, iov->iov_base,
+ (int)iov->iov_len);
+ pthread_mutex_unlock(&priv->mtx);
+ return (iov[0].iov_len);
+ } else {
+ uint8_t *pkt;
+ size_t pktlen;
+
+ pktlen = 0;
+ for (int i = 0; i < iovcnt; i++)
+ pktlen += iov[i].iov_len;
+ pkt = malloc(pktlen);
+ if (pkt == NULL)
+ return (-1);
+ pktlen = 0;
+ for (int i = 0; i < iovcnt; i++) {
+ memcpy(pkt + pktlen, iov[i].iov_base, iov[i].iov_len);
+ pktlen += iov[i].iov_len;
+ }
+ pthread_mutex_lock(&priv->mtx);
+ slirp_input_p(priv->slirp, pkt, (int)pktlen);
+ pthread_mutex_unlock(&priv->mtx);
+ free(pkt);
+ return (pktlen);
+ }
+}
+
+static void
+_slirp_cleanup(struct net_backend *be)
+{
+ struct slirp_priv *priv = NET_BE_PRIV(be);
+
+ slirp_priv_cleanup(priv);
+}
+
+static ssize_t
+slirp_peek_recvlen(struct net_backend *be)
+{
+ struct slirp_priv *priv = NET_BE_PRIV(be);
+ ssize_t n;
+
+ n = recv(priv->pipe[0], NULL, 0, MSG_PEEK | MSG_DONTWAIT | MSG_TRUNC);
+ if (n < 0)
+ return (errno == EWOULDBLOCK ? 0 : -1);
+ assert((size_t)n <= SLIRP_MTU);
+ return (n);
+}
+
+static ssize_t
+slirp_recv(struct net_backend *be, const struct iovec *iov, int iovcnt)
+{
+ struct slirp_priv *priv = NET_BE_PRIV(be);
+ ssize_t n;
+
+ n = readv(priv->pipe[0], iov, iovcnt);
+ if (n < 0)
+ return (-1);
+ assert(n <= SLIRP_MTU);
+ return (n);
+}
+
+static void
+slirp_recv_enable(struct net_backend *be)
+{
+ struct slirp_priv *priv = NET_BE_PRIV(be);
+
+ mevent_enable(priv->mevp);
+}
+
+static void
+slirp_recv_disable(struct net_backend *be)
+{
+ struct slirp_priv *priv = NET_BE_PRIV(be);
+
+ mevent_disable(priv->mevp);
+}
+
+static uint64_t
+slirp_get_cap(struct net_backend *be __unused)
+{
+ return (0);
+}
+
+static int
+slirp_set_cap(struct net_backend *be __unused, uint64_t features __unused,
+ unsigned int vnet_hdr_len __unused)
+{
+ return ((features || vnet_hdr_len) ? -1 : 0);
+}
+
+static struct net_backend slirp_backend = {
+ .prefix = "slirp",
+ .priv_size = sizeof(struct slirp_priv),
+ .init = _slirp_init,
+ .cleanup = _slirp_cleanup,
+ .send = slirp_send,
+ .peek_recvlen = slirp_peek_recvlen,
+ .recv = slirp_recv,
+ .recv_enable = slirp_recv_enable,
+ .recv_disable = slirp_recv_disable,
+ .get_cap = slirp_get_cap,
+ .set_cap = slirp_set_cap,
+};
+
+DATA_SET(net_backend_set, slirp_backend);
diff --git a/usr.sbin/bhyve/net_backends.c b/usr.sbin/bhyve/net_backends.c
index ca4c96b10239..2d11c45f217a 100644
--- a/usr.sbin/bhyve/net_backends.c
+++ b/usr.sbin/bhyve/net_backends.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Vincenzo Maffione <vmaffione@FreeBSD.org>
*
@@ -23,8 +23,6 @@
* 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$
*/
/*
@@ -34,10 +32,7 @@
* features) is exported by net_backends.h.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h> /* u_short etc */
+#include <sys/types.h>
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
#endif
@@ -46,168 +41,39 @@ __FBSDID("$FreeBSD$");
#include <sys/uio.h>
#include <net/if.h>
-#if defined(INET6) || defined(INET)
#include <net/if_tap.h>
-#endif
-#include <net/netmap.h>
-#include <net/netmap_virt.h>
-#define NETMAP_WITH_LIBS
-#include <net/netmap_user.h>
+#include <assert.h>
#ifndef WITHOUT_CAPSICUM
#include <capsicum_helpers.h>
#endif
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <poll.h>
+#include <pthread.h>
+#include <pthread_np.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
-#include <unistd.h>
#include <sysexits.h>
-#include <assert.h>
-#include <pthread.h>
-#include <pthread_np.h>
-#include <poll.h>
-#include <assert.h>
-
-#ifdef NETGRAPH
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <netgraph.h>
-#endif
+#include <unistd.h>
#include "config.h"
#include "debug.h"
#include "iov.h"
#include "mevent.h"
#include "net_backends.h"
+#include "net_backends_priv.h"
#include "pci_emul.h"
-#include <sys/linker_set.h>
-
-/*
- * Each network backend registers a set of function pointers that are
- * used to implement the net backends API.
- * This might need to be exposed if we implement backends in separate files.
- */
-struct net_backend {
- const char *prefix; /* prefix matching this backend */
-
- /*
- * Routines used to initialize and cleanup the resources needed
- * by a backend. The cleanup function is used internally,
- * and should not be called by the frontend.
- */
- int (*init)(struct net_backend *be, const char *devname,
- nvlist_t *nvl, net_be_rxeof_t cb, void *param);
- void (*cleanup)(struct net_backend *be);
-
- /*
- * Called to serve a guest transmit request. The scatter-gather
- * vector provided by the caller has 'iovcnt' elements and contains
- * the packet to send.
- */
- ssize_t (*send)(struct net_backend *be, const struct iovec *iov,
- int iovcnt);
-
- /*
- * Get the length of the next packet that can be received from
- * the backend. If no packets are currently available, this
- * function returns 0.
- */
- ssize_t (*peek_recvlen)(struct net_backend *be);
-
- /*
- * Called to receive a packet from the backend. When the function
- * returns a positive value 'len', the scatter-gather vector
- * provided by the caller contains a packet with such length.
- * The function returns 0 if the backend doesn't have a new packet to
- * receive.
- */
- ssize_t (*recv)(struct net_backend *be, const struct iovec *iov,
- int iovcnt);
+#define NET_BE_SIZE(be) (sizeof(*be) + (be)->priv_size)
- /*
- * Ask the backend to enable or disable receive operation in the
- * backend. On return from a disable operation, it is guaranteed
- * that the receive callback won't be called until receive is
- * enabled again. Note however that it is up to the caller to make
- * sure that netbe_recv() is not currently being executed by another
- * thread.
- */
- void (*recv_enable)(struct net_backend *be);
- void (*recv_disable)(struct net_backend *be);
-
- /*
- * Ask the backend for the virtio-net features it is able to
- * support. Possible features are TSO, UFO and checksum offloading
- * in both rx and tx direction and for both IPv4 and IPv6.
- */
- uint64_t (*get_cap)(struct net_backend *be);
-
- /*
- * Tell the backend to enable/disable the specified virtio-net
- * features (capabilities).
- */
- int (*set_cap)(struct net_backend *be, uint64_t features,
- unsigned int vnet_hdr_len);
-
- struct pci_vtnet_softc *sc;
- int fd;
-
- /*
- * Length of the virtio-net header used by the backend and the
- * frontend, respectively. A zero value means that the header
- * is not used.
- */
- unsigned int be_vnet_hdr_len;
- unsigned int fe_vnet_hdr_len;
-
- /* Size of backend-specific private data. */
- size_t priv_size;
-
- /* Room for backend-specific data. */
- char opaque[0];
-};
-
-SET_DECLARE(net_backend_set, struct net_backend);
-
-#define VNET_HDR_LEN sizeof(struct virtio_net_rxhdr)
-
-#define WPRINTF(params) PRINTLN params
-
-/*
- * The tap backend
- */
-
-#if defined(INET6) || defined(INET)
-const int pf_list[] = {
-#if defined(INET6)
- PF_INET6,
-#endif
-#if defined(INET)
- PF_INET,
-#endif
-};
-#endif
-
-struct tap_priv {
- struct mevent *mevp;
- /*
- * A bounce buffer that allows us to implement the peek_recvlen
- * callback. In the future we may get the same information from
- * the kevent data.
- */
- char bbuf[1 << 16];
- ssize_t bbuflen;
-};
-
-static void
+void
tap_cleanup(struct net_backend *be)
{
- struct tap_priv *priv = (struct tap_priv *)be->opaque;
+ struct tap_priv *priv = NET_BE_PRIV(be);
if (priv->mevp) {
mevent_delete(priv->mevp);
@@ -220,21 +86,18 @@ tap_cleanup(struct net_backend *be)
static int
tap_init(struct net_backend *be, const char *devname,
- nvlist_t *nvl, net_be_rxeof_t cb, void *param)
+ nvlist_t *nvl __unused, net_be_rxeof_t cb, void *param)
{
- struct tap_priv *priv = (struct tap_priv *)be->opaque;
+ struct tap_priv *priv = NET_BE_PRIV(be);
char tbuf[80];
- int opt = 1;
-#if defined(INET6) || defined(INET)
- struct ifreq ifrq;
- int i, s;
-#endif
+ int opt = 1, up = IFF_UP;
+
#ifndef WITHOUT_CAPSICUM
cap_rights_t rights;
#endif
if (cb == NULL) {
- WPRINTF(("TAP backend requires non-NULL callback"));
+ EPRINTLN("TAP backend requires non-NULL callback");
return (-1);
}
@@ -243,7 +106,7 @@ tap_init(struct net_backend *be, const char *devname,
be->fd = open(tbuf, O_RDWR);
if (be->fd == -1) {
- WPRINTF(("open of tap device %s failed", tbuf));
+ EPRINTLN("open of tap device %s failed", tbuf);
goto error;
}
@@ -252,42 +115,14 @@ tap_init(struct net_backend *be, const char *devname,
* notifications with the event loop
*/
if (ioctl(be->fd, FIONBIO, &opt) < 0) {
- WPRINTF(("tap device O_NONBLOCK failed"));
- goto error;
- }
-
-#if defined(INET6) || defined(INET)
- /*
- * Try to UP the interface rather than relying on
- * net.link.tap.up_on_open.
- */
- bzero(&ifrq, sizeof(ifrq));
- if (ioctl(be->fd, TAPGIFNAME, &ifrq) < 0) {
- WPRINTF(("Could not get interface name"));
- goto error;
- }
-
- s = -1;
- for (i = 0; s == -1 && i < nitems(pf_list); i++)
- s = socket(pf_list[i], SOCK_DGRAM, 0);
- if (s == -1) {
- WPRINTF(("Could open socket"));
+ EPRINTLN("tap device O_NONBLOCK failed");
goto error;
}
- if (ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) {
- (void)close(s);
- WPRINTF(("Could not get interface flags"));
- goto error;
- }
- ifrq.ifr_flags |= IFF_UP;
- if (ioctl(s, SIOCSIFFLAGS, &ifrq) < 0) {
- (void)close(s);
- WPRINTF(("Could not set interface flags"));
+ if (ioctl(be->fd, VMIO_SIOCSIFFLAGS, up)) {
+ EPRINTLN("tap device link up failed");
goto error;
}
- (void)close(s);
-#endif
#ifndef WITHOUT_CAPSICUM
cap_rights_init(&rights, CAP_EVENT, CAP_READ, CAP_WRITE);
@@ -300,7 +135,7 @@ tap_init(struct net_backend *be, const char *devname,
priv->mevp = mevent_add_disabled(be->fd, EVF_READ, cb, param);
if (priv->mevp == NULL) {
- WPRINTF(("Could not register event"));
+ EPRINTLN("Could not register event");
goto error;
}
@@ -314,16 +149,16 @@ error:
/*
* Called to send a buffer chain out to the tap device
*/
-static ssize_t
+ssize_t
tap_send(struct net_backend *be, const struct iovec *iov, int iovcnt)
{
return (writev(be->fd, iov, iovcnt));
}
-static ssize_t
+ssize_t
tap_peek_recvlen(struct net_backend *be)
{
- struct tap_priv *priv = (struct tap_priv *)be->opaque;
+ struct tap_priv *priv = NET_BE_PRIV(be);
ssize_t ret;
if (priv->bbuflen > 0) {
@@ -350,10 +185,10 @@ tap_peek_recvlen(struct net_backend *be)
return (ret);
}
-static ssize_t
+ssize_t
tap_recv(struct net_backend *be, const struct iovec *iov, int iovcnt)
{
- struct tap_priv *priv = (struct tap_priv *)be->opaque;
+ struct tap_priv *priv = NET_BE_PRIV(be);
ssize_t ret;
if (priv->bbuflen > 0) {
@@ -378,32 +213,32 @@ tap_recv(struct net_backend *be, const struct iovec *iov, int iovcnt)
return (ret);
}
-static void
+void
tap_recv_enable(struct net_backend *be)
{
- struct tap_priv *priv = (struct tap_priv *)be->opaque;
+ struct tap_priv *priv = NET_BE_PRIV(be);
mevent_enable(priv->mevp);
}
-static void
+void
tap_recv_disable(struct net_backend *be)
{
- struct tap_priv *priv = (struct tap_priv *)be->opaque;
+ struct tap_priv *priv = NET_BE_PRIV(be);
mevent_disable(priv->mevp);
}
-static uint64_t
-tap_get_cap(struct net_backend *be)
+uint64_t
+tap_get_cap(struct net_backend *be __unused)
{
return (0); /* no capabilities for now */
}
-static int
-tap_set_cap(struct net_backend *be, uint64_t features,
- unsigned vnet_hdr_len)
+int
+tap_set_cap(struct net_backend *be __unused, uint64_t features,
+ unsigned vnet_hdr_len)
{
return ((features || vnet_hdr_len) ? -1 : 0);
@@ -441,509 +276,6 @@ static struct net_backend vmnet_backend = {
DATA_SET(net_backend_set, tap_backend);
DATA_SET(net_backend_set, vmnet_backend);
-#ifdef NETGRAPH
-
-/*
- * Netgraph backend
- */
-
-#define NG_SBUF_MAX_SIZE (4 * 1024 * 1024)
-
-static int
-ng_init(struct net_backend *be, const char *devname,
- nvlist_t *nvl, net_be_rxeof_t cb, void *param)
-{
- struct tap_priv *p = (struct tap_priv *)be->opaque;
- struct ngm_connect ngc;
- const char *value, *nodename;
- int sbsz;
- int ctrl_sock;
- int flags;
- unsigned long maxsbsz;
- size_t msbsz;
-#ifndef WITHOUT_CAPSICUM
- cap_rights_t rights;
-#endif
-
- if (cb == NULL) {
- WPRINTF(("Netgraph backend requires non-NULL callback"));
- return (-1);
- }
-
- be->fd = -1;
-
- memset(&ngc, 0, sizeof(ngc));
-
- value = get_config_value_node(nvl, "path");
- if (value == NULL) {
- WPRINTF(("path must be provided"));
- return (-1);
- }
- strncpy(ngc.path, value, NG_PATHSIZ - 1);
-
- value = get_config_value_node(nvl, "hook");
- if (value == NULL)
- value = "vmlink";
- strncpy(ngc.ourhook, value, NG_HOOKSIZ - 1);
-
- value = get_config_value_node(nvl, "peerhook");
- if (value == NULL) {
- WPRINTF(("peer hook must be provided"));
- return (-1);
- }
- strncpy(ngc.peerhook, value, NG_HOOKSIZ - 1);
-
- nodename = get_config_value_node(nvl, "socket");
- if (NgMkSockNode(nodename,
- &ctrl_sock, &be->fd) < 0) {
- WPRINTF(("can't get Netgraph sockets"));
- return (-1);
- }
-
- if (NgSendMsg(ctrl_sock, ".",
- NGM_GENERIC_COOKIE,
- NGM_CONNECT, &ngc, sizeof(ngc)) < 0) {
- WPRINTF(("can't connect to node"));
- close(ctrl_sock);
- goto error;
- }
-
- close(ctrl_sock);
-
- flags = fcntl(be->fd, F_GETFL);
-
- if (flags < 0) {
- WPRINTF(("can't get socket flags"));
- goto error;
- }
-
- if (fcntl(be->fd, F_SETFL, flags | O_NONBLOCK) < 0) {
- WPRINTF(("can't set O_NONBLOCK flag"));
- goto error;
- }
-
- /*
- * The default ng_socket(4) buffer's size is too low.
- * Calculate the minimum value between NG_SBUF_MAX_SIZE
- * and kern.ipc.maxsockbuf.
- */
- msbsz = sizeof(maxsbsz);
- if (sysctlbyname("kern.ipc.maxsockbuf", &maxsbsz, &msbsz,
- NULL, 0) < 0) {
- WPRINTF(("can't get 'kern.ipc.maxsockbuf' value"));
- goto error;
- }
-
- /*
- * We can't set the socket buffer size to kern.ipc.maxsockbuf value,
- * as it takes into account the mbuf(9) overhead.
- */
- maxsbsz = maxsbsz * MCLBYTES / (MSIZE + MCLBYTES);
-
- sbsz = MIN(NG_SBUF_MAX_SIZE, maxsbsz);
-
- if (setsockopt(be->fd, SOL_SOCKET, SO_SNDBUF, &sbsz,
- sizeof(sbsz)) < 0) {
- WPRINTF(("can't set TX buffer size"));
- goto error;
- }
-
- if (setsockopt(be->fd, SOL_SOCKET, SO_RCVBUF, &sbsz,
- sizeof(sbsz)) < 0) {
- WPRINTF(("can't set RX buffer size"));
- goto error;
- }
-
-#ifndef WITHOUT_CAPSICUM
- cap_rights_init(&rights, CAP_EVENT, CAP_READ, CAP_WRITE);
- if (caph_rights_limit(be->fd, &rights) == -1)
- errx(EX_OSERR, "Unable to apply rights for sandbox");
-#endif
-
- memset(p->bbuf, 0, sizeof(p->bbuf));
- p->bbuflen = 0;
-
- p->mevp = mevent_add_disabled(be->fd, EVF_READ, cb, param);
- if (p->mevp == NULL) {
- WPRINTF(("Could not register event"));
- goto error;
- }
-
- return (0);
-
-error:
- tap_cleanup(be);
- return (-1);
-}
-
-static struct net_backend ng_backend = {
- .prefix = "netgraph",
- .priv_size = sizeof(struct tap_priv),
- .init = ng_init,
- .cleanup = tap_cleanup,
- .send = tap_send,
- .peek_recvlen = tap_peek_recvlen,
- .recv = tap_recv,
- .recv_enable = tap_recv_enable,
- .recv_disable = tap_recv_disable,
- .get_cap = tap_get_cap,
- .set_cap = tap_set_cap,
-};
-
-DATA_SET(net_backend_set, ng_backend);
-
-#endif /* NETGRAPH */
-
-/*
- * The netmap backend
- */
-
-/* The virtio-net features supported by netmap. */
-#define NETMAP_FEATURES (VIRTIO_NET_F_CSUM | VIRTIO_NET_F_HOST_TSO4 | \
- VIRTIO_NET_F_HOST_TSO6 | VIRTIO_NET_F_HOST_UFO | \
- VIRTIO_NET_F_GUEST_CSUM | VIRTIO_NET_F_GUEST_TSO4 | \
- VIRTIO_NET_F_GUEST_TSO6 | VIRTIO_NET_F_GUEST_UFO)
-
-struct netmap_priv {
- char ifname[IFNAMSIZ];
- struct nm_desc *nmd;
- uint16_t memid;
- struct netmap_ring *rx;
- struct netmap_ring *tx;
- struct mevent *mevp;
- net_be_rxeof_t cb;
- void *cb_param;
-};
-
-static void
-nmreq_init(struct nmreq *req, char *ifname)
-{
-
- memset(req, 0, sizeof(*req));
- strlcpy(req->nr_name, ifname, sizeof(req->nr_name));
- req->nr_version = NETMAP_API;
-}
-
-static int
-netmap_set_vnet_hdr_len(struct net_backend *be, int vnet_hdr_len)
-{
- int err;
- struct nmreq req;
- struct netmap_priv *priv = (struct netmap_priv *)be->opaque;
-
- nmreq_init(&req, priv->ifname);
- req.nr_cmd = NETMAP_BDG_VNET_HDR;
- req.nr_arg1 = vnet_hdr_len;
- err = ioctl(be->fd, NIOCREGIF, &req);
- if (err) {
- WPRINTF(("Unable to set vnet header length %d",
- vnet_hdr_len));
- return (err);
- }
-
- be->be_vnet_hdr_len = vnet_hdr_len;
-
- return (0);
-}
-
-static int
-netmap_has_vnet_hdr_len(struct net_backend *be, unsigned vnet_hdr_len)
-{
- int prev_hdr_len = be->be_vnet_hdr_len;
- int ret;
-
- if (vnet_hdr_len == prev_hdr_len) {
- return (1);
- }
-
- ret = netmap_set_vnet_hdr_len(be, vnet_hdr_len);
- if (ret) {
- return (0);
- }
-
- netmap_set_vnet_hdr_len(be, prev_hdr_len);
-
- return (1);
-}
-
-static uint64_t
-netmap_get_cap(struct net_backend *be)
-{
-
- return (netmap_has_vnet_hdr_len(be, VNET_HDR_LEN) ?
- NETMAP_FEATURES : 0);
-}
-
-static int
-netmap_set_cap(struct net_backend *be, uint64_t features,
- unsigned vnet_hdr_len)
-{
-
- return (netmap_set_vnet_hdr_len(be, vnet_hdr_len));
-}
-
-static int
-netmap_init(struct net_backend *be, const char *devname,
- nvlist_t *nvl, net_be_rxeof_t cb, void *param)
-{
- struct netmap_priv *priv = (struct netmap_priv *)be->opaque;
-
- strlcpy(priv->ifname, devname, sizeof(priv->ifname));
- priv->ifname[sizeof(priv->ifname) - 1] = '\0';
-
- priv->nmd = nm_open(priv->ifname, NULL, NETMAP_NO_TX_POLL, NULL);
- if (priv->nmd == NULL) {
- WPRINTF(("Unable to nm_open(): interface '%s', errno (%s)",
- devname, strerror(errno)));
- free(priv);
- return (-1);
- }
-
- priv->memid = priv->nmd->req.nr_arg2;
- priv->tx = NETMAP_TXRING(priv->nmd->nifp, 0);
- priv->rx = NETMAP_RXRING(priv->nmd->nifp, 0);
- priv->cb = cb;
- priv->cb_param = param;
- be->fd = priv->nmd->fd;
-
- priv->mevp = mevent_add_disabled(be->fd, EVF_READ, cb, param);
- if (priv->mevp == NULL) {
- WPRINTF(("Could not register event"));
- return (-1);
- }
-
- return (0);
-}
-
-static void
-netmap_cleanup(struct net_backend *be)
-{
- struct netmap_priv *priv = (struct netmap_priv *)be->opaque;
-
- if (priv->mevp) {
- mevent_delete(priv->mevp);
- }
- if (priv->nmd) {
- nm_close(priv->nmd);
- }
- be->fd = -1;
-}
-
-static ssize_t
-netmap_send(struct net_backend *be, const struct iovec *iov,
- int iovcnt)
-{
- struct netmap_priv *priv = (struct netmap_priv *)be->opaque;
- struct netmap_ring *ring;
- ssize_t totlen = 0;
- int nm_buf_size;
- int nm_buf_len;
- uint32_t head;
- void *nm_buf;
- int j;
-
- ring = priv->tx;
- head = ring->head;
- if (head == ring->tail) {
- WPRINTF(("No space, drop %zu bytes", count_iov(iov, iovcnt)));
- goto txsync;
- }
- nm_buf = NETMAP_BUF(ring, ring->slot[head].buf_idx);
- nm_buf_size = ring->nr_buf_size;
- nm_buf_len = 0;
-
- for (j = 0; j < iovcnt; j++) {
- int iov_frag_size = iov[j].iov_len;
- void *iov_frag_buf = iov[j].iov_base;
-
- totlen += iov_frag_size;
-
- /*
- * Split each iovec fragment over more netmap slots, if
- * necessary.
- */
- for (;;) {
- int copylen;
-
- copylen = iov_frag_size < nm_buf_size ? iov_frag_size : nm_buf_size;
- memcpy(nm_buf, iov_frag_buf, copylen);
-
- iov_frag_buf += copylen;
- iov_frag_size -= copylen;
- nm_buf += copylen;
- nm_buf_size -= copylen;
- nm_buf_len += copylen;
-
- if (iov_frag_size == 0) {
- break;
- }
-
- ring->slot[head].len = nm_buf_len;
- ring->slot[head].flags = NS_MOREFRAG;
- head = nm_ring_next(ring, head);
- if (head == ring->tail) {
- /*
- * We ran out of netmap slots while
- * splitting the iovec fragments.
- */
- WPRINTF(("No space, drop %zu bytes",
- count_iov(iov, iovcnt)));
- goto txsync;
- }
- nm_buf = NETMAP_BUF(ring, ring->slot[head].buf_idx);
- nm_buf_size = ring->nr_buf_size;
- nm_buf_len = 0;
- }
- }
-
- /* Complete the last slot, which must not have NS_MOREFRAG set. */
- ring->slot[head].len = nm_buf_len;
- ring->slot[head].flags = 0;
- head = nm_ring_next(ring, head);
-
- /* Now update ring->head and ring->cur. */
- ring->head = ring->cur = head;
-txsync:
- ioctl(be->fd, NIOCTXSYNC, NULL);
-
- return (totlen);
-}
-
-static ssize_t
-netmap_peek_recvlen(struct net_backend *be)
-{
- struct netmap_priv *priv = (struct netmap_priv *)be->opaque;
- struct netmap_ring *ring = priv->rx;
- uint32_t head = ring->head;
- ssize_t totlen = 0;
-
- while (head != ring->tail) {
- struct netmap_slot *slot = ring->slot + head;
-
- totlen += slot->len;
- if ((slot->flags & NS_MOREFRAG) == 0)
- break;
- head = nm_ring_next(ring, head);
- }
-
- return (totlen);
-}
-
-static ssize_t
-netmap_recv(struct net_backend *be, const struct iovec *iov, int iovcnt)
-{
- struct netmap_priv *priv = (struct netmap_priv *)be->opaque;
- struct netmap_slot *slot = NULL;
- struct netmap_ring *ring;
- void *iov_frag_buf;
- int iov_frag_size;
- ssize_t totlen = 0;
- uint32_t head;
-
- assert(iovcnt);
-
- ring = priv->rx;
- head = ring->head;
- iov_frag_buf = iov->iov_base;
- iov_frag_size = iov->iov_len;
-
- do {
- int nm_buf_len;
- void *nm_buf;
-
- if (head == ring->tail) {
- return (0);
- }
-
- slot = ring->slot + head;
- nm_buf = NETMAP_BUF(ring, slot->buf_idx);
- nm_buf_len = slot->len;
-
- for (;;) {
- int copylen = nm_buf_len < iov_frag_size ?
- nm_buf_len : iov_frag_size;
-
- memcpy(iov_frag_buf, nm_buf, copylen);
- nm_buf += copylen;
- nm_buf_len -= copylen;
- iov_frag_buf += copylen;
- iov_frag_size -= copylen;
- totlen += copylen;
-
- if (nm_buf_len == 0) {
- break;
- }
-
- iov++;
- iovcnt--;
- if (iovcnt == 0) {
- /* No space to receive. */
- WPRINTF(("Short iov, drop %zd bytes",
- totlen));
- return (-ENOSPC);
- }
- iov_frag_buf = iov->iov_base;
- iov_frag_size = iov->iov_len;
- }
-
- head = nm_ring_next(ring, head);
-
- } while (slot->flags & NS_MOREFRAG);
-
- /* Release slots to netmap. */
- ring->head = ring->cur = head;
-
- return (totlen);
-}
-
-static void
-netmap_recv_enable(struct net_backend *be)
-{
- struct netmap_priv *priv = (struct netmap_priv *)be->opaque;
-
- mevent_enable(priv->mevp);
-}
-
-static void
-netmap_recv_disable(struct net_backend *be)
-{
- struct netmap_priv *priv = (struct netmap_priv *)be->opaque;
-
- mevent_disable(priv->mevp);
-}
-
-static struct net_backend netmap_backend = {
- .prefix = "netmap",
- .priv_size = sizeof(struct netmap_priv),
- .init = netmap_init,
- .cleanup = netmap_cleanup,
- .send = netmap_send,
- .peek_recvlen = netmap_peek_recvlen,
- .recv = netmap_recv,
- .recv_enable = netmap_recv_enable,
- .recv_disable = netmap_recv_disable,
- .get_cap = netmap_get_cap,
- .set_cap = netmap_set_cap,
-};
-
-/* A clone of the netmap backend, with a different prefix. */
-static struct net_backend vale_backend = {
- .prefix = "vale",
- .priv_size = sizeof(struct netmap_priv),
- .init = netmap_init,
- .cleanup = netmap_cleanup,
- .send = netmap_send,
- .peek_recvlen = netmap_peek_recvlen,
- .recv = netmap_recv,
- .recv_enable = netmap_recv_enable,
- .recv_disable = netmap_recv_disable,
- .get_cap = netmap_get_cap,
- .set_cap = netmap_set_cap,
-};
-
-DATA_SET(net_backend_set, netmap_backend);
-DATA_SET(net_backend_set, vale_backend);
-
int
netbe_legacy_config(nvlist_t *nvl, const char *opts)
{
@@ -980,7 +312,7 @@ netbe_init(struct net_backend **ret, nvlist_t *nvl, net_be_rxeof_t cb,
void *param)
{
struct net_backend **pbe, *nbe, *tbe = NULL;
- const char *value;
+ const char *value, *type;
char *devname;
int err;
@@ -991,11 +323,19 @@ netbe_init(struct net_backend **ret, nvlist_t *nvl, net_be_rxeof_t cb,
devname = strdup(value);
/*
+ * Use the type given by configuration if exists; otherwise
+ * use the prefix of the backend as the type.
+ */
+ type = get_config_value_node(nvl, "type");
+ if (type == NULL)
+ type = devname;
+
+ /*
* Find the network backend that matches the user-provided
* device name. net_backend_set is built using a linker set.
*/
SET_FOREACH(pbe, net_backend_set) {
- if (strncmp(devname, (*pbe)->prefix,
+ if (strncmp(type, (*pbe)->prefix,
strlen((*pbe)->prefix)) == 0) {
tbe = *pbe;
assert(tbe->init != NULL);
@@ -1014,7 +354,7 @@ netbe_init(struct net_backend **ret, nvlist_t *nvl, net_be_rxeof_t cb,
return (EINVAL);
}
- nbe = calloc(1, sizeof(*nbe) + tbe->priv_size);
+ nbe = calloc(1, NET_BE_SIZE(tbe));
*nbe = *tbe; /* copy the template */
nbe->fd = -1;
nbe->sc = param;
diff --git a/usr.sbin/bhyve/net_backends.h b/usr.sbin/bhyve/net_backends.h
index bc7834546bc1..e623b7c64637 100644
--- a/usr.sbin/bhyve/net_backends.h
+++ b/usr.sbin/bhyve/net_backends.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Vincenzo Maffione <vmaffione@FreeBSD.org>
*
@@ -23,14 +23,16 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef __NET_BACKENDS_H__
#define __NET_BACKENDS_H__
-#include <stdint.h>
+#include <sys/nv.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+
+#include "mevent.h"
/* Opaque type representing a network backend. */
typedef struct net_backend net_backend_t;
@@ -55,7 +57,7 @@ void netbe_rx_enable(net_backend_t *be);
/*
* Network device capabilities taken from the VirtIO standard.
- * Despite the name, these capabilities can be used by different frontents
+ * Despite the name, these capabilities can be used by different frontends
* (virtio-net, ptnet) and supported by different backends (netmap, tap, ...).
*/
#define VIRTIO_NET_F_CSUM (1 << 0) /* host handles partial cksum */
@@ -92,5 +94,6 @@ struct virtio_net_rxhdr {
uint16_t vrh_csum_offset;
uint16_t vrh_bufs;
} __packed;
+#define VNET_HDR_LEN sizeof(struct virtio_net_rxhdr)
#endif /* __NET_BACKENDS_H__ */
diff --git a/usr.sbin/bhyve/net_backends_priv.h b/usr.sbin/bhyve/net_backends_priv.h
new file mode 100644
index 000000000000..4b3f4e4358a3
--- /dev/null
+++ b/usr.sbin/bhyve/net_backends_priv.h
@@ -0,0 +1,152 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019 Vincenzo Maffione <vmaffione@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __NET_BACKENDS_PRIV_H__
+#define __NET_BACKENDS_PRIV_H__
+
+#include <sys/linker_set.h>
+
+/*
+ * Each network backend registers a set of function pointers that are
+ * used to implement the net backends API. Frontends should not invoke
+ * these functions directly, but should instead use the interface provided by
+ * net_backends.h.
+ */
+struct net_backend {
+ const char *prefix; /* prefix matching this backend */
+
+ /*
+ * Routines used to initialize and cleanup the resources needed
+ * by a backend. The cleanup function is used internally,
+ * and should not be called by the frontend.
+ */
+ int (*init)(struct net_backend *be, const char *devname,
+ nvlist_t *nvl, net_be_rxeof_t cb, void *param);
+ void (*cleanup)(struct net_backend *be);
+
+ /*
+ * Called to serve a guest transmit request. The scatter-gather
+ * vector provided by the caller has 'iovcnt' elements and contains
+ * the packet to send.
+ */
+ ssize_t (*send)(struct net_backend *be, const struct iovec *iov,
+ int iovcnt);
+
+ /*
+ * Get the length of the next packet that can be received from
+ * the backend. If no packets are currently available, this
+ * function returns 0.
+ */
+ ssize_t (*peek_recvlen)(struct net_backend *be);
+
+ /*
+ * Called to receive a packet from the backend. When the function
+ * returns a positive value 'len', the scatter-gather vector
+ * provided by the caller contains a packet with such length.
+ * The function returns 0 if the backend doesn't have a new packet to
+ * receive.
+ */
+ ssize_t (*recv)(struct net_backend *be, const struct iovec *iov,
+ int iovcnt);
+
+ /*
+ * Ask the backend to enable or disable receive operation in the
+ * backend. On return from a disable operation, it is guaranteed
+ * that the receive callback won't be called until receive is
+ * enabled again. Note however that it is up to the caller to make
+ * sure that netbe_recv() is not currently being executed by another
+ * thread.
+ */
+ void (*recv_enable)(struct net_backend *be);
+ void (*recv_disable)(struct net_backend *be);
+
+ /*
+ * Ask the backend for the virtio-net features it is able to
+ * support. Possible features are TSO, UFO and checksum offloading
+ * in both rx and tx direction and for both IPv4 and IPv6.
+ */
+ uint64_t (*get_cap)(struct net_backend *be);
+
+ /*
+ * Tell the backend to enable/disable the specified virtio-net
+ * features (capabilities).
+ */
+ int (*set_cap)(struct net_backend *be, uint64_t features,
+ unsigned int vnet_hdr_len);
+
+ struct pci_vtnet_softc *sc;
+ int fd;
+
+ /*
+ * Length of the virtio-net header used by the backend and the
+ * frontend, respectively. A zero value means that the header
+ * is not used.
+ */
+ unsigned int be_vnet_hdr_len;
+ unsigned int fe_vnet_hdr_len;
+
+ /* Size of backend-specific private data. */
+ size_t priv_size;
+
+ /* Backend-specific private data follows. */
+};
+
+#define NET_BE_PRIV(be) ((void *)((be) + 1))
+
+SET_DECLARE(net_backend_set, struct net_backend);
+
+#define VNET_HDR_LEN sizeof(struct virtio_net_rxhdr)
+
+/*
+ * Export the tap backend routines for the benefit of other backends which have
+ * a similar interface to the kernel, i.e., they send and receive data using
+ * standard I/O system calls with a single file descriptor.
+ */
+
+struct tap_priv {
+ struct mevent *mevp;
+ /*
+ * A bounce buffer that allows us to implement the peek_recvlen
+ * callback. In the future we may get the same information from
+ * the kevent data.
+ */
+ char bbuf[1 << 16];
+ ssize_t bbuflen;
+};
+
+void tap_cleanup(struct net_backend *be);
+ssize_t tap_send(struct net_backend *be, const struct iovec *iov, int iovcnt);
+ssize_t tap_recv(struct net_backend *be, const struct iovec *iov, int iovcnt);
+ssize_t tap_peek_recvlen(struct net_backend *be);
+void tap_recv_enable(struct net_backend *be);
+ssize_t tap_recv(struct net_backend *be, const struct iovec *iov, int iovcnt);
+void tap_recv_disable(struct net_backend *be);
+uint64_t tap_get_cap(struct net_backend *be);
+int tap_set_cap(struct net_backend *be, uint64_t features,
+ unsigned vnet_hdr_len);
+
+#endif /* !__NET_BACKENDS_PRIV_H__ */
diff --git a/usr.sbin/bhyve/net_utils.c b/usr.sbin/bhyve/net_utils.c
index 8088fa89a50f..7dc37dce06b3 100644
--- a/usr.sbin/bhyve/net_utils.c
+++ b/usr.sbin/bhyve/net_utils.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
*
@@ -25,9 +25,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <net/ethernet.h>
diff --git a/usr.sbin/bhyve/net_utils.h b/usr.sbin/bhyve/net_utils.h
index 3dd44572588c..055412990e74 100644
--- a/usr.sbin/bhyve/net_utils.h
+++ b/usr.sbin/bhyve/net_utils.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Vincenzo Maffione <v.maffione@gmail.com>
*
@@ -23,8 +23,6 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _NET_UTILS_H_
diff --git a/usr.sbin/bhyve/pci_ahci.c b/usr.sbin/bhyve/pci_ahci.c
index d07b1f085e3d..636df5c6e9b1 100644
--- a/usr.sbin/bhyve/pci_ahci.c
+++ b/usr.sbin/bhyve/pci_ahci.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Zhixiang Yu <zcore@freebsd.org>
* Copyright (c) 2015-2016 Alexander Motin <mav@FreeBSD.org>
@@ -25,13 +25,8 @@
* 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 <sys/param.h>
#include <sys/linker_set.h>
#include <sys/stat.h>
@@ -41,8 +36,6 @@ __FBSDID("$FreeBSD$");
#include <sys/ata.h>
#include <sys/endian.h>
-#include <machine/vmm_snapshot.h>
-
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -61,6 +54,9 @@ __FBSDID("$FreeBSD$");
#include "config.h"
#include "debug.h"
#include "pci_emul.h"
+#ifdef BHYVE_SNAPSHOT
+#include "snapshot.h"
+#endif
#include "ahci.h"
#include "block_if.h"
@@ -121,7 +117,6 @@ static FILE *dbg;
#else
#define DPRINTF(format, arg...)
#endif
-#define WPRINTF(format, arg...) printf(format, ##arg)
#define AHCI_PORT_IDENT 20 + 1
@@ -346,7 +341,7 @@ ahci_write_fis(struct ahci_port *p, enum sata_fis_type ft, uint8_t *fis)
irq = (fis[1] & (1 << 6)) ? AHCI_P_IX_PS : 0;
break;
default:
- WPRINTF("unsupported fis type %d", ft);
+ EPRINTLN("unsupported fis type %d", ft);
return;
}
if (fis[2] & ATA_S_ERROR) {
@@ -615,8 +610,10 @@ ahci_build_iov(struct ahci_port *p, struct ahci_ioreq *aior,
struct ahci_prdt_entry *prdt, uint16_t prdtl)
{
struct blockif_req *breq = &aior->io_req;
- int i, j, skip, todo, left, extra;
- uint32_t dbcsz;
+ uint32_t dbcsz, extra, left, skip, todo;
+ int i, j;
+
+ assert(aior->len >= aior->done);
/* Copy part of PRDT between 'done' and 'len' bytes into the iov. */
skip = aior->done;
@@ -785,13 +782,14 @@ ahci_handle_flush(struct ahci_port *p, int slot, uint8_t *cfis)
}
static inline void
-read_prdt(struct ahci_port *p, int slot, uint8_t *cfis,
- void *buf, int size)
+read_prdt(struct ahci_port *p, int slot, uint8_t *cfis, void *buf,
+ unsigned int size)
{
struct ahci_cmd_hdr *hdr;
struct ahci_prdt_entry *prdt;
- void *to;
- int i, len;
+ uint8_t *to;
+ unsigned int len;
+ int i;
hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE);
len = size;
@@ -800,7 +798,7 @@ read_prdt(struct ahci_port *p, int slot, uint8_t *cfis,
for (i = 0; i < hdr->prdtl && len; i++) {
uint8_t *ptr;
uint32_t dbcsz;
- int sublen;
+ unsigned int sublen;
dbcsz = (prdt->dbc & DBCMASK) + 1;
ptr = paddr_guest2host(ahci_ctx(p->pr_sc), prdt->dba, dbcsz);
@@ -899,13 +897,14 @@ next:
}
static inline void
-write_prdt(struct ahci_port *p, int slot, uint8_t *cfis,
- void *buf, int size)
+write_prdt(struct ahci_port *p, int slot, uint8_t *cfis, void *buf,
+ unsigned int size)
{
struct ahci_cmd_hdr *hdr;
struct ahci_prdt_entry *prdt;
- void *from;
- int i, len;
+ uint8_t *from;
+ unsigned int len;
+ int i;
hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE);
len = size;
@@ -1142,7 +1141,7 @@ atapi_inquiry(struct ahci_port *p, int slot, uint8_t *cfis)
{
uint8_t buf[36];
uint8_t *acmd;
- int len;
+ unsigned int len;
uint32_t tfd;
acmd = cfis + 0x40;
@@ -1204,7 +1203,7 @@ atapi_read_toc(struct ahci_port *p, int slot, uint8_t *cfis)
{
uint8_t *acmd;
uint8_t format;
- int len;
+ unsigned int len;
acmd = cfis + 0x40;
@@ -1213,7 +1212,8 @@ atapi_read_toc(struct ahci_port *p, int slot, uint8_t *cfis)
switch (format) {
case 0:
{
- int msf, size;
+ size_t size;
+ int msf;
uint64_t sectors;
uint8_t start_track, buf[20], *bp;
@@ -1287,7 +1287,8 @@ atapi_read_toc(struct ahci_port *p, int slot, uint8_t *cfis)
}
case 2:
{
- int msf, size;
+ size_t size;
+ int msf;
uint64_t sectors;
uint8_t *bp, buf[50];
@@ -1450,7 +1451,7 @@ atapi_request_sense(struct ahci_port *p, int slot, uint8_t *cfis)
{
uint8_t buf[64];
uint8_t *acmd;
- int len;
+ unsigned int len;
acmd = cfis + 0x40;
len = acmd[4];
@@ -1496,7 +1497,7 @@ atapi_mode_sense(struct ahci_port *p, int slot, uint8_t *cfis)
uint8_t *acmd;
uint32_t tfd;
uint8_t pc, code;
- int len;
+ unsigned int len;
acmd = cfis + 0x40;
len = be16dec(acmd + 7);
@@ -1581,7 +1582,7 @@ atapi_get_event_status_notification(struct ahci_port *p, int slot,
tfd = (p->sense_key << 12) | ATA_S_READY | ATA_S_ERROR;
} else {
uint8_t buf[8];
- int len;
+ unsigned int len;
len = be16dec(acmd + 7);
if (len > sizeof(buf))
@@ -1799,7 +1800,7 @@ ahci_handle_cmd(struct ahci_port *p, int slot, uint8_t *cfis)
handle_packet_cmd(p, slot, cfis);
break;
default:
- WPRINTF("Unsupported cmd:%02x", cfis[2]);
+ EPRINTLN("Unsupported cmd:%02x", cfis[2]);
ahci_write_fis_d2h(p, slot, cfis,
(ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR);
break;
@@ -1844,7 +1845,7 @@ ahci_handle_slot(struct ahci_port *p, int slot)
#endif
if (cfis[0] != FIS_TYPE_REGH2D) {
- WPRINTF("Not a H2D FIS:%02x", cfis[0]);
+ EPRINTLN("Not a H2D FIS:%02x", cfis[0]);
return;
}
@@ -2131,7 +2132,7 @@ pci_ahci_port_write(struct pci_ahci_softc *sc, uint64_t offset, uint64_t value)
case AHCI_P_TFD:
case AHCI_P_SIG:
case AHCI_P_SSTS:
- WPRINTF("pci_ahci_port: read only registers 0x%"PRIx64"", offset);
+ EPRINTLN("pci_ahci_port: read only registers 0x%"PRIx64"", offset);
break;
case AHCI_P_SCTL:
p->sctl = value;
@@ -2191,8 +2192,8 @@ pci_ahci_host_write(struct pci_ahci_softc *sc, uint64_t offset, uint64_t value)
}
static void
-pci_ahci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size, uint64_t value)
+pci_ahci_write(struct pci_devinst *pi, int baridx, uint64_t offset, int size,
+ uint64_t value)
{
struct pci_ahci_softc *sc = pi->pi_arg;
@@ -2203,10 +2204,10 @@ pci_ahci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
if (offset < AHCI_OFFSET)
pci_ahci_host_write(sc, offset, value);
- else if (offset < AHCI_OFFSET + sc->ports * AHCI_STEP)
+ else if (offset < (uint64_t)AHCI_OFFSET + sc->ports * AHCI_STEP)
pci_ahci_port_write(sc, offset, value);
else
- WPRINTF("pci_ahci: unknown i/o write offset 0x%"PRIx64"", offset);
+ EPRINTLN("pci_ahci: unknown i/o write offset 0x%"PRIx64"", offset);
pthread_mutex_unlock(&sc->mtx);
}
@@ -2285,8 +2286,7 @@ pci_ahci_port_read(struct pci_ahci_softc *sc, uint64_t offset)
}
static uint64_t
-pci_ahci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
- uint64_t regoff, int size)
+pci_ahci_read(struct pci_devinst *pi, int baridx, uint64_t regoff, int size)
{
struct pci_ahci_softc *sc = pi->pi_arg;
uint64_t offset;
@@ -2301,11 +2301,11 @@ pci_ahci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
offset = regoff & ~0x3; /* round down to a multiple of 4 bytes */
if (offset < AHCI_OFFSET)
value = pci_ahci_host_read(sc, offset);
- else if (offset < AHCI_OFFSET + sc->ports * AHCI_STEP)
+ else if (offset < (uint64_t)AHCI_OFFSET + sc->ports * AHCI_STEP)
value = pci_ahci_port_read(sc, offset);
else {
value = 0;
- WPRINTF("pci_ahci: unknown i/o read offset 0x%"PRIx64"",
+ EPRINTLN("pci_ahci: unknown i/o read offset 0x%"PRIx64"",
regoff);
}
value >>= 8 * (regoff & 0x3);
@@ -2413,9 +2413,9 @@ pci_ahci_hd_legacy_config(nvlist_t *nvl, const char *opts)
}
static int
-pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_ahci_init(struct pci_devinst *pi, nvlist_t *nvl)
{
- char bident[sizeof("XX:XX:XX")];
+ char bident[sizeof("XXX:XXX:XXX")];
char node_name[sizeof("XX")];
struct blockif_ctxt *bctxt;
struct pci_ahci_softc *sc;
@@ -2462,7 +2462,7 @@ pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
* Attempt to open the backing image. Use the PCI slot/func
* and the port number for the identifier string.
*/
- snprintf(bident, sizeof(bident), "%d:%d:%d", pi->pi_slot,
+ snprintf(bident, sizeof(bident), "%u:%u:%u", pi->pi_slot,
pi->pi_func, p);
bctxt = blockif_open(port_nvl, bident);
@@ -2471,6 +2471,13 @@ pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
ret = 1;
goto open_fail;
}
+
+ ret = blockif_add_boot_device(pi, bctxt);
+ if (ret) {
+ sc->ports = p;
+ goto open_fail;
+ }
+
sc->port[p].bctx = bctxt;
sc->port[p].pr_sc = sc;
sc->port[p].port = p;
@@ -2563,113 +2570,13 @@ open_fail:
#ifdef BHYVE_SNAPSHOT
static int
-pci_ahci_snapshot_save_queues(struct ahci_port *port,
- struct vm_snapshot_meta *meta)
-{
- int ret;
- int idx;
- struct ahci_ioreq *ioreq;
-
- STAILQ_FOREACH(ioreq, &port->iofhd, io_flist) {
- idx = ((void *) ioreq - (void *) port->ioreq) / sizeof(*ioreq);
- SNAPSHOT_VAR_OR_LEAVE(idx, meta, ret, done);
- }
-
- idx = -1;
- SNAPSHOT_VAR_OR_LEAVE(idx, meta, ret, done);
-
- TAILQ_FOREACH(ioreq, &port->iobhd, io_blist) {
- idx = ((void *) ioreq - (void *) port->ioreq) / sizeof(*ioreq);
- SNAPSHOT_VAR_OR_LEAVE(idx, meta, ret, done);
-
- /*
- * Snapshot only the busy requests; other requests are
- * not valid.
- */
- ret = blockif_snapshot_req(&ioreq->io_req, meta);
- if (ret != 0) {
- fprintf(stderr, "%s: failed to snapshot req\r\n",
- __func__);
- goto done;
- }
- }
-
- idx = -1;
- SNAPSHOT_VAR_OR_LEAVE(idx, meta, ret, done);
-
-done:
- return (ret);
-}
-
-static int
-pci_ahci_snapshot_restore_queues(struct ahci_port *port,
- struct vm_snapshot_meta *meta)
-{
- int ret;
- int idx;
- struct ahci_ioreq *ioreq;
-
- /* Empty the free queue before restoring. */
- while (!STAILQ_EMPTY(&port->iofhd))
- STAILQ_REMOVE_HEAD(&port->iofhd, io_flist);
-
- /* Restore the free queue. */
- while (1) {
- SNAPSHOT_VAR_OR_LEAVE(idx, meta, ret, done);
- if (idx == -1)
- break;
-
- STAILQ_INSERT_TAIL(&port->iofhd, &port->ioreq[idx], io_flist);
- }
-
- /* Restore the busy queue. */
- while (1) {
- SNAPSHOT_VAR_OR_LEAVE(idx, meta, ret, done);
- if (idx == -1)
- break;
-
- ioreq = &port->ioreq[idx];
- TAILQ_INSERT_TAIL(&port->iobhd, ioreq, io_blist);
-
- /*
- * Restore only the busy requests; other requests are
- * not valid.
- */
- ret = blockif_snapshot_req(&ioreq->io_req, meta);
- if (ret != 0) {
- fprintf(stderr, "%s: failed to restore request\r\n",
- __func__);
- goto done;
- }
-
- /* Re-enqueue the requests in the block interface. */
- if (ioreq->readop)
- ret = blockif_read(port->bctx, &ioreq->io_req);
- else
- ret = blockif_write(port->bctx, &ioreq->io_req);
-
- if (ret != 0) {
- fprintf(stderr,
- "%s: failed to re-enqueue request\r\n",
- __func__);
- goto done;
- }
- }
-
-done:
- return (ret);
-}
-
-static int
pci_ahci_snapshot(struct vm_snapshot_meta *meta)
{
- int i, j, ret;
+ int i, ret;
void *bctx;
struct pci_devinst *pi;
struct pci_ahci_softc *sc;
struct ahci_port *port;
- struct ahci_cmd_hdr *hdr;
- struct ahci_ioreq *ioreq;
pi = meta->dev_data;
sc = pi->pi_arg;
@@ -2702,7 +2609,7 @@ pci_ahci_snapshot(struct vm_snapshot_meta *meta)
/* Mostly for restore; save is ensured by the lines above. */
if (((bctx == NULL) && (port->bctx != NULL)) ||
((bctx != NULL) && (port->bctx == NULL))) {
- fprintf(stderr, "%s: ports not matching\r\n", __func__);
+ EPRINTLN("%s: ports not matching", __func__);
ret = EINVAL;
goto done;
}
@@ -2711,17 +2618,16 @@ pci_ahci_snapshot(struct vm_snapshot_meta *meta)
continue;
if (port->port != i) {
- fprintf(stderr, "%s: ports not matching: "
- "actual: %d expected: %d\r\n",
- __func__, port->port, i);
+ EPRINTLN("%s: ports not matching: "
+ "actual: %d expected: %d", __func__, port->port, i);
ret = EINVAL;
goto done;
}
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(port->cmd_lst,
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(pi->pi_vmctx, port->cmd_lst,
AHCI_CL_SIZE * AHCI_MAX_SLOTS, false, meta, ret, done);
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(port->rfis, 256, false, meta,
- ret, done);
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(pi->pi_vmctx, port->rfis, 256,
+ false, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(port->ata_ident, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(port->atapi, meta, ret, done);
@@ -2753,43 +2659,7 @@ pci_ahci_snapshot(struct vm_snapshot_meta *meta)
SNAPSHOT_VAR_OR_LEAVE(port->fbs, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(port->ioqsz, meta, ret, done);
- for (j = 0; j < port->ioqsz; j++) {
- ioreq = &port->ioreq[j];
-
- /* blockif_req snapshot done only for busy requests. */
- hdr = (struct ahci_cmd_hdr *)(port->cmd_lst +
- ioreq->slot * AHCI_CL_SIZE);
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(ioreq->cfis,
- 0x80 + hdr->prdtl * sizeof(struct ahci_prdt_entry),
- false, meta, ret, done);
-
- SNAPSHOT_VAR_OR_LEAVE(ioreq->len, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(ioreq->done, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(ioreq->slot, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(ioreq->more, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(ioreq->readop, meta, ret, done);
- }
-
- /* Perform save / restore specific operations. */
- if (meta->op == VM_SNAPSHOT_SAVE) {
- ret = pci_ahci_snapshot_save_queues(port, meta);
- if (ret != 0)
- goto done;
- } else if (meta->op == VM_SNAPSHOT_RESTORE) {
- ret = pci_ahci_snapshot_restore_queues(port, meta);
- if (ret != 0)
- goto done;
- } else {
- ret = EINVAL;
- goto done;
- }
-
- ret = blockif_snapshot(port->bctx, meta);
- if (ret != 0) {
- fprintf(stderr, "%s: failed to restore blockif\r\n",
- __func__);
- goto done;
- }
+ assert(TAILQ_EMPTY(&port->iobhd));
}
done:
@@ -2797,7 +2667,7 @@ done:
}
static int
-pci_ahci_pause(struct vmctx *ctx, struct pci_devinst *pi)
+pci_ahci_pause(struct pci_devinst *pi)
{
struct pci_ahci_softc *sc;
struct blockif_ctxt *bctxt;
@@ -2817,7 +2687,7 @@ pci_ahci_pause(struct vmctx *ctx, struct pci_devinst *pi)
}
static int
-pci_ahci_resume(struct vmctx *ctx, struct pci_devinst *pi)
+pci_ahci_resume(struct pci_devinst *pi)
{
struct pci_ahci_softc *sc;
struct blockif_ctxt *bctxt;
@@ -2835,12 +2705,12 @@ pci_ahci_resume(struct vmctx *ctx, struct pci_devinst *pi)
return (0);
}
-#endif
+#endif /* BHYVE_SNAPSHOT */
/*
* Use separate emulation names to distinguish drive and atapi devices
*/
-struct pci_devemu pci_de_ahci = {
+static const struct pci_devemu pci_de_ahci = {
.pe_emu = "ahci",
.pe_init = pci_ahci_init,
.pe_legacy_config = pci_ahci_legacy_config,
@@ -2854,14 +2724,14 @@ struct pci_devemu pci_de_ahci = {
};
PCI_EMUL_SET(pci_de_ahci);
-struct pci_devemu pci_de_ahci_hd = {
+static const struct pci_devemu pci_de_ahci_hd = {
.pe_emu = "ahci-hd",
.pe_legacy_config = pci_ahci_hd_legacy_config,
.pe_alias = "ahci",
};
PCI_EMUL_SET(pci_de_ahci_hd);
-struct pci_devemu pci_de_ahci_cd = {
+static const struct pci_devemu pci_de_ahci_cd = {
.pe_emu = "ahci-cd",
.pe_legacy_config = pci_ahci_cd_legacy_config,
.pe_alias = "ahci",
diff --git a/usr.sbin/bhyve/pci_e82545.c b/usr.sbin/bhyve/pci_e82545.c
index 1df2f31be200..1afcb559f2bb 100644
--- a/usr.sbin/bhyve/pci_e82545.c
+++ b/usr.sbin/bhyve/pci_e82545.c
@@ -1,5 +1,5 @@
/*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 Alexander Motin <mav@FreeBSD.org>
* Copyright (c) 2015 Peter Grehan <grehan@freebsd.org>
@@ -29,9 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
@@ -46,7 +43,6 @@ __FBSDID("$FreeBSD$");
#ifndef WITHOUT_CAPSICUM
#include <capsicum_helpers.h>
#endif
-#include <machine/vmm_snapshot.h>
#include <err.h>
#include <errno.h>
@@ -68,6 +64,9 @@ __FBSDID("$FreeBSD$");
#include "config.h"
#include "debug.h"
#include "pci_emul.h"
+#ifdef BHYVE_SNAPSHOT
+#include "snapshot.h"
+#endif
#include "mevent.h"
#include "net_utils.h"
#include "net_backends.h"
@@ -233,7 +232,7 @@ struct ck_info {
* Debug printf
*/
static int e82545_debug = 0;
-#define WPRINTF(msg,params...) PRINTLN("e82545: " msg, params)
+#define WPRINTF(msg,params...) PRINTLN("e82545: " msg, ##params)
#define DPRINTF(msg,params...) if (e82545_debug) WPRINTF(msg, params)
#define MIN(a,b) (((a)<(b))?(a):(b))
@@ -364,7 +363,7 @@ static void e82545_tx_start(struct e82545_softc *sc);
static void e82545_tx_enable(struct e82545_softc *sc);
static void e82545_tx_disable(struct e82545_softc *sc);
-static inline int
+static inline int __unused
e82545_size_stat_index(uint32_t size)
{
if (size <= 64) {
@@ -407,15 +406,15 @@ e82545_init_eeprom(struct e82545_softc *sc)
}
static void
-e82545_write_mdi(struct e82545_softc *sc, uint8_t reg_addr,
- uint8_t phy_addr, uint32_t data)
+e82545_write_mdi(struct e82545_softc *sc __unused, uint8_t reg_addr,
+ uint8_t phy_addr, uint32_t data)
{
DPRINTF("Write mdi reg:0x%x phy:0x%x data: 0x%x", reg_addr, phy_addr, data);
}
static uint32_t
-e82545_read_mdi(struct e82545_softc *sc, uint8_t reg_addr,
- uint8_t phy_addr)
+e82545_read_mdi(struct e82545_softc *sc __unused, uint8_t reg_addr,
+ uint8_t phy_addr)
{
//DPRINTF("Read mdi reg:0x%x phy:0x%x", reg_addr, phy_addr);
switch (reg_addr) {
@@ -554,7 +553,7 @@ e82545_eecd_strobe(struct e82545_softc *sc)
}
static void
-e82545_itr_callback(int fd, enum ev_type type, void *param)
+e82545_itr_callback(int fd __unused, enum ev_type type __unused, void *param)
{
uint32_t new;
struct e82545_softc *sc = param;
@@ -812,7 +811,7 @@ e82545_tx_ctl(struct e82545_softc *sc, uint32_t val)
sc->esc_TCTL = val & ~0xFE800005;
}
-int
+static int
e82545_bufsz(uint32_t rctl)
{
@@ -830,12 +829,13 @@ e82545_bufsz(uint32_t rctl)
/* XXX one packet at a time until this is debugged */
static void
-e82545_rx_callback(int fd, enum ev_type type, void *param)
+e82545_rx_callback(int fd __unused, enum ev_type type __unused, void *param)
{
struct e82545_softc *sc = param;
struct e1000_rx_desc *rxd;
struct iovec vec[64];
- int left, len, lim, maxpktsz, maxpktdesc, bufsz, i, n, size;
+ ssize_t len;
+ int left, lim, maxpktsz, maxpktdesc, bufsz, i, n, size;
uint32_t cause = 0;
uint16_t *tp, tag, head;
@@ -877,7 +877,7 @@ e82545_rx_callback(int fd, enum ev_type type, void *param)
}
len = netbe_recv(sc->esc_be, vec, maxpktdesc);
if (len <= 0) {
- DPRINTF("netbe_recv() returned %d", len);
+ DPRINTF("netbe_recv() returned %zd", len);
goto done;
}
@@ -892,7 +892,7 @@ e82545_rx_callback(int fd, enum ev_type type, void *param)
len += ETHER_CRC_LEN;
n = (len + bufsz - 1) / bufsz;
- DPRINTF("packet read %d bytes, %d segs, head %d",
+ DPRINTF("packet read %zd bytes, %d segs, head %d",
len, n, head);
/* Apply VLAN filter. */
@@ -929,7 +929,7 @@ e82545_rx_callback(int fd, enum ev_type type, void *param)
E1000_RXD_STAT_EOP | E1000_RXD_STAT_DD;
/* Schedule receive interrupts. */
- if (len <= sc->esc_RSRPD) {
+ if ((uint32_t)len <= sc->esc_RSRPD) {
cause |= E1000_ICR_SRPD | E1000_ICR_RXT0;
} else {
/* XXX: RDRT and RADV timers should be here. */
@@ -976,7 +976,7 @@ e82545_buf_checksum(uint8_t *buf, int len)
uint32_t sum = 0;
/* Checksum all the pairs of bytes first... */
- for (i = 0; i < (len & ~1U); i += 2)
+ for (i = 0; i < (len & ~1); i += 2)
sum += *((u_int16_t *)(buf + i));
/*
@@ -991,9 +991,10 @@ e82545_buf_checksum(uint8_t *buf, int len)
}
static uint16_t
-e82545_iov_checksum(struct iovec *iov, int iovcnt, int off, int len)
+e82545_iov_checksum(struct iovec *iov, int iovcnt, unsigned int off,
+ unsigned int len)
{
- int now, odd;
+ unsigned int now, odd;
uint32_t sum = 0, s;
/* Skip completely unneeded vectors. */
@@ -1007,7 +1008,7 @@ e82545_iov_checksum(struct iovec *iov, int iovcnt, int off, int len)
odd = 0;
while (len > 0 && iovcnt > 0) {
now = MIN(len, iov->iov_len - off);
- s = e82545_buf_checksum(iov->iov_base + off, now);
+ s = e82545_buf_checksum((uint8_t *)iov->iov_base + off, now);
sum += odd ? (s << 8) : s;
odd ^= (now & 1);
len -= now;
@@ -1022,7 +1023,7 @@ e82545_iov_checksum(struct iovec *iov, int iovcnt, int off, int len)
/*
* Return the transmit descriptor type.
*/
-int
+static int
e82545_txdesc_type(uint32_t lower)
{
int type;
@@ -1039,11 +1040,11 @@ static void
e82545_transmit_checksum(struct iovec *iov, int iovcnt, struct ck_info *ck)
{
uint16_t cksum;
- int cklen;
+ unsigned int cklen;
DPRINTF("tx cksum: iovcnt/s/off/len %d/%d/%d/%d",
iovcnt, ck->ck_start, ck->ck_off, ck->ck_len);
- cklen = ck->ck_len ? ck->ck_len - ck->ck_start + 1 : INT_MAX;
+ cklen = ck->ck_len ? ck->ck_len - ck->ck_start + 1U : UINT_MAX;
cksum = e82545_iov_checksum(iov, iovcnt, ck->ck_start, cklen);
*(uint16_t *)((uint8_t *)iov[0].iov_base + ck->ck_off) = ~cksum;
}
@@ -1084,17 +1085,19 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail,
struct ck_info ckinfo[2];
struct iovec *iov;
union e1000_tx_udesc *dsc;
- int desc, dtype, len, ntype, iovcnt, tcp, tso;
- int mss, paylen, seg, tiovcnt, left, now, nleft, nnow, pv, pvoff;
- unsigned hdrlen, vlen;
+ int desc, dtype, ntype, iovcnt, tcp, tso, paylen, seg, tiovcnt, pv;
+ unsigned hdrlen, vlen, pktlen, len, left, mss, now, nnow, nleft, pvoff;
uint32_t tcpsum, tcpseq;
uint16_t ipcs, tcpcs, ipid, ohead;
+ bool invalid;
ckinfo[0].ck_valid = ckinfo[1].ck_valid = 0;
iovcnt = 0;
ntype = 0;
tso = 0;
+ pktlen = 0;
ohead = head;
+ invalid = false;
/* iovb[0/1] may be used for writable copy of headers. */
iov = &iovb[2];
@@ -1144,17 +1147,23 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail,
len = (dtype == E1000_TXD_TYP_L) ? dsc->td.lower.flags.length :
dsc->dd.lower.data & 0xFFFFF;
- if (len > 0) {
- /* Strip checksum supplied by guest. */
- if ((dsc->td.lower.data & E1000_TXD_CMD_EOP) != 0 &&
- (dsc->td.lower.data & E1000_TXD_CMD_IFCS) == 0)
+ /* Strip checksum supplied by guest. */
+ if ((dsc->td.lower.data & E1000_TXD_CMD_EOP) != 0 &&
+ (dsc->td.lower.data & E1000_TXD_CMD_IFCS) == 0) {
+ if (len <= 2) {
+ WPRINTF("final descriptor too short (%d) -- dropped",
+ len);
+ invalid = true;
+ } else
len -= 2;
- if (iovcnt < I82545_MAX_TXSEGS) {
- iov[iovcnt].iov_base = paddr_guest2host(
- sc->esc_ctx, dsc->td.buffer_addr, len);
- iov[iovcnt].iov_len = len;
- }
+ }
+
+ if (len > 0 && iovcnt < I82545_MAX_TXSEGS) {
+ iov[iovcnt].iov_base = paddr_guest2host(sc->esc_ctx,
+ dsc->td.buffer_addr, len);
+ iov[iovcnt].iov_len = len;
iovcnt++;
+ pktlen += len;
}
/*
@@ -1202,6 +1211,9 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail,
}
}
+ if (invalid)
+ goto done;
+
if (iovcnt > I82545_MAX_TXSEGS) {
WPRINTF("tx too many descriptors (%d > %d) -- dropped",
iovcnt, I82545_MAX_TXSEGS);
@@ -1218,9 +1230,9 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail,
if (!tso) {
/* Estimate required writable space for checksums. */
if (ckinfo[0].ck_valid)
- hdrlen = MAX(hdrlen, ckinfo[0].ck_off + 2);
+ hdrlen = MAX(hdrlen, ckinfo[0].ck_off + 2U);
if (ckinfo[1].ck_valid)
- hdrlen = MAX(hdrlen, ckinfo[1].ck_off + 2);
+ hdrlen = MAX(hdrlen, ckinfo[1].ck_off + 2U);
/* Round up writable space to the first vector. */
if (hdrlen != 0 && iov[0].iov_len > hdrlen &&
iov[0].iov_len < hdrlen + 100)
@@ -1269,41 +1281,46 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail,
* TCP | flags | 13 | 1
* UDP | len | 4 | 4
*/
- if (hdrlen < ckinfo[0].ck_start + 6 ||
- hdrlen < ckinfo[0].ck_off + 2) {
+ if (hdrlen < ckinfo[0].ck_start + 6U ||
+ hdrlen < ckinfo[0].ck_off + 2U) {
WPRINTF("TSO hdrlen too small for IP fields (%d) "
"-- dropped", hdrlen);
goto done;
}
if (sc->esc_txctx.cmd_and_length & E1000_TXD_CMD_TCP) {
- if (hdrlen < ckinfo[1].ck_start + 14) {
+ if (hdrlen < ckinfo[1].ck_start + 14U) {
WPRINTF("TSO hdrlen too small for TCP fields "
"(%d) -- dropped", hdrlen);
goto done;
}
} else {
- if (hdrlen < ckinfo[1].ck_start + 8) {
+ if (hdrlen < ckinfo[1].ck_start + 8U) {
WPRINTF("TSO hdrlen too small for UDP fields "
"(%d) -- dropped", hdrlen);
goto done;
}
}
- if (ckinfo[1].ck_valid && hdrlen < ckinfo[1].ck_off + 2) {
+ if (ckinfo[1].ck_valid && hdrlen < ckinfo[1].ck_off + 2U) {
WPRINTF("TSO hdrlen too small for TCP/UDP fields "
"(%d) -- dropped", hdrlen);
goto done;
}
}
+ if (pktlen < hdrlen + vlen) {
+ WPRINTF("packet too small for writable header");
+ goto done;
+ }
+
/* Allocate, fill and prepend writable header vector. */
- if (hdrlen != 0) {
+ if (hdrlen + vlen != 0) {
hdr = __builtin_alloca(hdrlen + vlen);
hdr += vlen;
for (left = hdrlen, hdrp = hdr; left > 0;
left -= now, hdrp += now) {
now = MIN(left, iov->iov_len);
memcpy(hdrp, iov->iov_base, now);
- iov->iov_base += now;
+ iov->iov_base = (uint8_t *)iov->iov_base + now;
iov->iov_len -= now;
if (iov->iov_len == 0) {
iov++;
@@ -1354,7 +1371,7 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail,
tcp = (sc->esc_txctx.cmd_and_length & E1000_TXD_CMD_TCP) != 0;
mss = sc->esc_txctx.tcp_seg_setup.fields.mss;
paylen = (sc->esc_txctx.cmd_and_length & 0x000fffff);
- DPRINTF("tx %s segmentation offload %d+%d/%d bytes %d iovs",
+ DPRINTF("tx %s segmentation offload %d+%d/%u bytes %d iovs",
tcp ? "TCP" : "UDP", hdrlen, paylen, mss, iovcnt);
ipid = ntohs(*(uint16_t *)&hdr[ckinfo[0].ck_start + 4]);
tcpseq = 0;
@@ -1377,7 +1394,8 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail,
/* Include respective part of payload IOV. */
for (nleft = now; pv < iovcnt && nleft > 0; nleft -= nnow) {
nnow = MIN(nleft, iov[pv].iov_len - pvoff);
- tiov[tiovcnt].iov_base = iov[pv].iov_base + pvoff;
+ tiov[tiovcnt].iov_base = (uint8_t *)iov[pv].iov_base +
+ pvoff;
tiov[tiovcnt++].iov_len = nnow;
if (pvoff + nnow == iov[pv].iov_len) {
pv++;
@@ -1449,9 +1467,12 @@ e82545_tx_run(struct e82545_softc *sc)
uint16_t head, rhead, tail, size;
int lim, tdwb, sent;
- head = sc->esc_TDH;
- tail = sc->esc_TDT;
size = sc->esc_TDLEN / 16;
+ if (size == 0)
+ return;
+
+ head = sc->esc_TDH % size;
+ tail = sc->esc_TDT % size;
DPRINTF("tx_run: head %x, rhead %x, tail %x",
sc->esc_TDH, sc->esc_TDHr, sc->esc_TDT);
@@ -1717,12 +1738,17 @@ e82545_write_register(struct e82545_softc *sc, uint32_t offset, uint32_t value)
e82545_tx_update_tdba(sc);
break;
case E1000_TDH(0):
- //assert(!sc->esc_tx_enabled);
- /* XXX should only ever be zero ? Range check ? */
+ if (sc->esc_tx_enabled) {
+ WPRINTF("ignoring write to TDH while transmit enabled");
+ break;
+ }
+ if (value != 0) {
+ WPRINTF("ignoring non-zero value written to TDH");
+ break;
+ }
sc->esc_TDHr = sc->esc_TDH = value;
break;
case E1000_TDT(0):
- /* XXX range check ? */
sc->esc_TDT = value;
if (sc->esc_tx_enabled)
e82545_tx_start(sc);
@@ -2085,8 +2111,8 @@ e82545_read_register(struct e82545_softc *sc, uint32_t offset)
}
static void
-e82545_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
- uint64_t offset, int size, uint64_t value)
+e82545_write(struct pci_devinst *pi, int baridx, uint64_t offset, int size,
+ uint64_t value)
{
struct e82545_softc *sc;
@@ -2135,8 +2161,7 @@ e82545_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
}
static uint64_t
-e82545_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
- uint64_t offset, int size)
+e82545_read(struct pci_devinst *pi, int baridx, uint64_t offset, int size)
{
struct e82545_softc *sc;
uint64_t retval;
@@ -2279,7 +2304,7 @@ e82545_reset(struct e82545_softc *sc, int drvr)
}
static int
-e82545_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+e82545_init(struct pci_devinst *pi, nvlist_t *nvl)
{
char nstr[80];
struct e82545_softc *sc;
@@ -2291,7 +2316,7 @@ e82545_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
pi->pi_arg = sc;
sc->esc_pi = pi;
- sc->esc_ctx = ctx;
+ sc->esc_ctx = pi->pi_vmctx;
pthread_mutex_init(&sc->esc_mtx, NULL);
pthread_cond_init(&sc->esc_rx_cond, NULL);
@@ -2410,11 +2435,11 @@ e82545_snapshot(struct vm_snapshot_meta *meta)
SNAPSHOT_VAR_OR_LEAVE(sc->esc_TADV, meta, ret, done);
/* Has dependency on esc_TDLEN; reoreder of fields from struct. */
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(sc->esc_txdesc, sc->esc_TDLEN,
- true, meta, ret, done);
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(pi->pi_vmctx, sc->esc_txdesc,
+ sc->esc_TDLEN, true, meta, ret, done);
/* L2 frame acceptance */
- for (i = 0; i < nitems(sc->esc_uni); i++) {
+ for (i = 0; i < (int)nitems(sc->esc_uni); i++) {
SNAPSHOT_VAR_OR_LEAVE(sc->esc_uni[i].eu_valid, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(sc->esc_uni[i].eu_addrsel, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(sc->esc_uni[i].eu_eth, meta, ret, done);
@@ -2445,8 +2470,8 @@ e82545_snapshot(struct vm_snapshot_meta *meta)
SNAPSHOT_VAR_OR_LEAVE(sc->esc_RXCSUM, meta, ret, done);
/* Has dependency on esc_RDLEN; reoreder of fields from struct. */
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(sc->esc_rxdesc, sc->esc_TDLEN,
- true, meta, ret, done);
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(pi->pi_vmctx, sc->esc_rxdesc,
+ sc->esc_TDLEN, true, meta, ret, done);
/* IO Port register access */
SNAPSHOT_VAR_OR_LEAVE(sc->io_addr, meta, ret, done);
@@ -2500,7 +2525,7 @@ done:
}
#endif
-struct pci_devemu pci_de_e82545 = {
+static const struct pci_devemu pci_de_e82545 = {
.pe_emu = "e1000",
.pe_init = e82545_init,
.pe_legacy_config = netbe_legacy_config,
@@ -2511,4 +2536,3 @@ struct pci_devemu pci_de_e82545 = {
#endif
};
PCI_EMUL_SET(pci_de_e82545);
-
diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c
index 9bcd3223007a..00e9138d3910 100644
--- a/usr.sbin/bhyve/pci_emul.c
+++ b/usr.sbin/bhyve/pci_emul.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/param.h>
#include <sys/linker_set.h>
#include <sys/mman.h>
@@ -55,12 +50,16 @@ __FBSDID("$FreeBSD$");
#include "bhyverun.h"
#include "config.h"
#include "debug.h"
-#include "inout.h"
-#include "ioapic.h"
+#ifdef __amd64__
+#include "amd64/inout.h"
+#endif
#include "mem.h"
#include "pci_emul.h"
-#include "pci_irq.h"
-#include "pci_lpc.h"
+#ifdef __amd64__
+#include "amd64/pci_lpc.h"
+#include "pci_passthru.h"
+#endif
+#include "qemu_fwcfg.h"
#define CONF1_ADDR_PORT 0x0cf8
#define CONF1_DATA_PORT 0x0cfc
@@ -80,9 +79,8 @@ struct funcinfo {
};
struct intxinfo {
- int ii_count;
- int ii_pirq_pin;
- int ii_ioapic_irq;
+ int ii_count;
+ struct pci_irq ii_irq;
};
struct slotinfo {
@@ -116,31 +114,52 @@ struct pci_bar_allocation {
enum pcibar_type type;
uint64_t size;
};
-TAILQ_HEAD(pci_bar_list, pci_bar_allocation) pci_bars = TAILQ_HEAD_INITIALIZER(
- pci_bars);
+static TAILQ_HEAD(pci_bar_list, pci_bar_allocation) pci_bars =
+ TAILQ_HEAD_INITIALIZER(pci_bars);
+
+struct boot_device {
+ TAILQ_ENTRY(boot_device) boot_device_chain;
+ struct pci_devinst *pdi;
+ int bootindex;
+};
+static TAILQ_HEAD(boot_list, boot_device) boot_devices = TAILQ_HEAD_INITIALIZER(
+ boot_devices);
+
+#if defined(__amd64__)
#define PCI_EMUL_IOBASE 0x2000
#define PCI_EMUL_IOLIMIT 0x10000
+#define PCI_EMUL_IOMASK 0xffff
+/*
+ * OVMF always uses 0xc0000000 as base address for 32 bit PCI MMIO. Don't
+ * change this address without changing it in OVMF.
+ */
+#define PCI_EMUL_MEMBASE32 0xc0000000
+#elif defined(__aarch64__)
+#define PCI_EMUL_IOBASE 0xdf000000UL
+#define PCI_EMUL_IOLIMIT 0xe0000000UL
+#define PCI_EMUL_MEMBASE32 0xa0000000UL
+#else
+#error Unsupported platform
+#endif
-#define PCI_EMUL_ROMSIZE 0x10000000
+#define PCI_EMUL_ROMSIZE 0x10000000
#define PCI_EMUL_ECFG_BASE 0xE0000000 /* 3.5GB */
#define PCI_EMUL_ECFG_SIZE (MAXBUSES * 1024 * 1024) /* 1MB per bus */
+#ifdef __amd64__
SYSRES_MEM(PCI_EMUL_ECFG_BASE, PCI_EMUL_ECFG_SIZE);
+#endif
-/*
- * OVMF always uses 0xC0000000 as base address for 32 bit PCI MMIO. Don't
- * change this address without changing it in OVMF.
- */
-#define PCI_EMUL_MEMBASE32 0xC0000000
#define PCI_EMUL_MEMLIMIT32 PCI_EMUL_ECFG_BASE
#define PCI_EMUL_MEMSIZE64 (32*GB)
-static struct pci_devemu *pci_emul_finddev(const char *name);
static void pci_lintr_route(struct pci_devinst *pi);
static void pci_lintr_update(struct pci_devinst *pi);
-static void pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot,
- int func, int coff, int bytes, uint32_t *val);
+
+static struct pci_devemu *pci_emul_finddev(const char *name);
+static void pci_cfgrw(int in, int bus, int slot, int func, int coff,
+ int bytes, uint32_t *val);
static __inline void
CFGWRITE(struct pci_devinst *pi, int coff, uint32_t val, int bytes)
@@ -321,7 +340,7 @@ done:
}
void
-pci_print_supported_devices()
+pci_print_supported_devices(void)
{
struct pci_devemu **pdpp, *pdp;
@@ -331,6 +350,53 @@ pci_print_supported_devices()
}
}
+uint32_t
+pci_config_read_reg(const struct pcisel *const host_sel, nvlist_t *nvl,
+ const uint32_t reg, const uint8_t size, const uint32_t def)
+{
+ const char *config;
+ const nvlist_t *pci_regs;
+
+ assert(size == 1 || size == 2 || size == 4);
+
+ pci_regs = find_relative_config_node(nvl, "pcireg");
+ if (pci_regs == NULL) {
+ return def;
+ }
+
+ switch (reg) {
+ case PCIR_DEVICE:
+ config = get_config_value_node(pci_regs, "device");
+ break;
+ case PCIR_VENDOR:
+ config = get_config_value_node(pci_regs, "vendor");
+ break;
+ case PCIR_REVID:
+ config = get_config_value_node(pci_regs, "revid");
+ break;
+ case PCIR_SUBVEND_0:
+ config = get_config_value_node(pci_regs, "subvendor");
+ break;
+ case PCIR_SUBDEV_0:
+ config = get_config_value_node(pci_regs, "subdevice");
+ break;
+ default:
+ return (-1);
+ }
+
+ if (config == NULL) {
+ return def;
+ } else if (host_sel != NULL && strcmp(config, "host") == 0) {
+#ifdef __amd64__
+ return pci_host_read_config(host_sel, reg, size);
+#else
+ errx(1, "cannot fetch host PCI configuration");
+#endif
+ } else {
+ return strtol(config, NULL, 16);
+ }
+}
+
static int
pci_valid_pba_offset(struct pci_devinst *pi, uint64_t offset)
{
@@ -445,40 +511,69 @@ pci_msix_pba_bar(struct pci_devinst *pi)
return (-1);
}
+#ifdef __amd64__
static int
-pci_emul_io_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+pci_emul_io_handler(struct vmctx *ctx __unused, int in, int port,
+ int bytes, uint32_t *eax, void *arg)
{
struct pci_devinst *pdi = arg;
struct pci_devemu *pe = pdi->pi_d;
uint64_t offset;
int i;
+ assert(port >= 0);
+
for (i = 0; i <= PCI_BARMAX; i++) {
if (pdi->pi_bar[i].type == PCIBAR_IO &&
- port >= pdi->pi_bar[i].addr &&
- port + bytes <= pdi->pi_bar[i].addr + pdi->pi_bar[i].size) {
+ (uint64_t)port >= pdi->pi_bar[i].addr &&
+ (uint64_t)port + bytes <=
+ pdi->pi_bar[i].addr + pdi->pi_bar[i].size) {
offset = port - pdi->pi_bar[i].addr;
if (in)
- *eax = (*pe->pe_barread)(ctx, vcpu, pdi, i,
+ *eax = (*pe->pe_barread)(pdi, i,
offset, bytes);
else
- (*pe->pe_barwrite)(ctx, vcpu, pdi, i, offset,
+ (*pe->pe_barwrite)(pdi, i, offset,
bytes, *eax);
return (0);
}
}
return (-1);
}
+#else
+static int
+pci_emul_iomem_handler(struct vcpu *vcpu __unused, int dir,
+ uint64_t addr, int size, uint64_t *val, void *arg1, long arg2)
+{
+ struct pci_devinst *pdi = arg1;
+ struct pci_devemu *pe = pdi->pi_d;
+ uint64_t offset;
+ int bidx = (int)arg2;
+
+ assert(bidx <= PCI_BARMAX);
+ assert(pdi->pi_bar[bidx].type == PCIBAR_IO);
+ assert(addr >= pdi->pi_bar[bidx].addr &&
+ addr + size <= pdi->pi_bar[bidx].addr + pdi->pi_bar[bidx].size);
+ assert(size == 1 || size == 2 || size == 4);
+
+ offset = addr - pdi->pi_bar[bidx].addr;
+ if (dir == MEM_F_READ)
+ *val = (*pe->pe_barread)(pdi, bidx, offset, size);
+ else
+ (*pe->pe_barwrite)(pdi, bidx, offset, size, *val);
+
+ return (0);
+}
+#endif /* !__amd64__ */
static int
-pci_emul_mem_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
- int size, uint64_t *val, void *arg1, long arg2)
+pci_emul_mem_handler(struct vcpu *vcpu __unused, int dir,
+ uint64_t addr, int size, uint64_t *val, void *arg1, long arg2)
{
struct pci_devinst *pdi = arg1;
struct pci_devemu *pe = pdi->pi_d;
uint64_t offset;
- int bidx = (int) arg2;
+ int bidx = (int)arg2;
assert(bidx <= PCI_BARMAX);
assert(pdi->pi_bar[bidx].type == PCIBAR_MEM32 ||
@@ -490,22 +585,22 @@ pci_emul_mem_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
if (dir == MEM_F_WRITE) {
if (size == 8) {
- (*pe->pe_barwrite)(ctx, vcpu, pdi, bidx, offset,
+ (*pe->pe_barwrite)(pdi, bidx, offset,
4, *val & 0xffffffff);
- (*pe->pe_barwrite)(ctx, vcpu, pdi, bidx, offset + 4,
+ (*pe->pe_barwrite)(pdi, bidx, offset + 4,
4, *val >> 32);
} else {
- (*pe->pe_barwrite)(ctx, vcpu, pdi, bidx, offset,
+ (*pe->pe_barwrite)(pdi, bidx, offset,
size, *val);
}
} else {
if (size == 8) {
- *val = (*pe->pe_barread)(ctx, vcpu, pdi, bidx,
+ *val = (*pe->pe_barread)(pdi, bidx,
offset, 4);
- *val |= (*pe->pe_barread)(ctx, vcpu, pdi, bidx,
+ *val |= (*pe->pe_barread)(pdi, bidx,
offset + 4, 4) << 32;
} else {
- *val = (*pe->pe_barread)(ctx, vcpu, pdi, bidx,
+ *val = (*pe->pe_barread)(pdi, bidx,
offset, size);
}
}
@@ -541,12 +636,16 @@ modify_bar_registration(struct pci_devinst *pi, int idx, int registration)
{
struct pci_devemu *pe;
int error;
- struct inout_port iop;
- struct mem_range mr;
+ enum pcibar_type type;
pe = pi->pi_d;
- switch (pi->pi_bar[idx].type) {
+ type = pi->pi_bar[idx].type;
+ switch (type) {
case PCIBAR_IO:
+ {
+#ifdef __amd64__
+ struct inout_port iop;
+
bzero(&iop, sizeof(struct inout_port));
iop.name = pi->pi_name;
iop.port = pi->pi_bar[idx].addr;
@@ -558,12 +657,29 @@ modify_bar_registration(struct pci_devinst *pi, int idx, int registration)
error = register_inout(&iop);
} else
error = unregister_inout(&iop);
- if (pe->pe_baraddr != NULL)
- (*pe->pe_baraddr)(pi->pi_vmctx, pi, idx, registration,
- pi->pi_bar[idx].addr);
+#else
+ struct mem_range mr;
+
+ bzero(&mr, sizeof(struct mem_range));
+ mr.name = pi->pi_name;
+ mr.base = pi->pi_bar[idx].addr;
+ mr.size = pi->pi_bar[idx].size;
+ if (registration) {
+ mr.flags = MEM_F_RW;
+ mr.handler = pci_emul_iomem_handler;
+ mr.arg1 = pi;
+ mr.arg2 = idx;
+ error = register_mem(&mr);
+ } else
+ error = unregister_mem(&mr);
+#endif
break;
+ }
case PCIBAR_MEM32:
case PCIBAR_MEM64:
+ {
+ struct mem_range mr;
+
bzero(&mr, sizeof(struct mem_range));
mr.name = pi->pi_name;
mr.base = pi->pi_bar[idx].addr;
@@ -576,21 +692,19 @@ modify_bar_registration(struct pci_devinst *pi, int idx, int registration)
error = register_mem(&mr);
} else
error = unregister_mem(&mr);
- if (pe->pe_baraddr != NULL)
- (*pe->pe_baraddr)(pi->pi_vmctx, pi, idx, registration,
- pi->pi_bar[idx].addr);
break;
+ }
case PCIBAR_ROM:
error = 0;
- if (pe->pe_baraddr != NULL)
- (*pe->pe_baraddr)(pi->pi_vmctx, pi, idx, registration,
- pi->pi_bar[idx].addr);
break;
default:
error = EINVAL;
break;
}
assert(error == 0);
+
+ if (pe->pe_baraddr != NULL)
+ (*pe->pe_baraddr)(pi, idx, registration, pi->pi_bar[idx].addr);
}
static void
@@ -907,6 +1021,45 @@ pci_emul_alloc_rom(struct pci_devinst *const pdi, const uint64_t size,
return (0);
}
+int
+pci_emul_add_boot_device(struct pci_devinst *pi, int bootindex)
+{
+ struct boot_device *new_device, *device;
+
+ /* don't permit a negative bootindex */
+ if (bootindex < 0) {
+ errx(4, "Invalid bootindex %d for %s", bootindex, pi->pi_name);
+ }
+
+ /* alloc new boot device */
+ new_device = calloc(1, sizeof(struct boot_device));
+ if (new_device == NULL) {
+ return (ENOMEM);
+ }
+ new_device->pdi = pi;
+ new_device->bootindex = bootindex;
+
+ /* search for boot device with higher boot index */
+ TAILQ_FOREACH(device, &boot_devices, boot_device_chain) {
+ if (device->bootindex == bootindex) {
+ errx(4,
+ "Could not set bootindex %d for %s. Bootindex already occupied by %s",
+ bootindex, pi->pi_name, device->pdi->pi_name);
+ } else if (device->bootindex > bootindex) {
+ break;
+ }
+ }
+
+ /* add boot device to queue */
+ if (device == NULL) {
+ TAILQ_INSERT_TAIL(&boot_devices, new_device, boot_device_chain);
+ } else {
+ TAILQ_INSERT_BEFORE(device, new_device, boot_device_chain);
+ }
+
+ return (0);
+}
+
#define CAP_START_OFFSET 0x40
static int
pci_emul_add_capability(struct pci_devinst *pi, u_char *capdata, int caplen)
@@ -978,10 +1131,10 @@ pci_emul_init(struct vmctx *ctx, struct pci_devemu *pde, int bus, int slot,
pthread_mutex_init(&pdi->pi_lintr.lock, NULL);
pdi->pi_lintr.pin = 0;
pdi->pi_lintr.state = IDLE;
- pdi->pi_lintr.pirq_pin = 0;
- pdi->pi_lintr.ioapic_irq = 0;
+ pci_irq_init_irq(&pdi->pi_lintr.irq);
pdi->pi_d = pde;
- snprintf(pdi->pi_name, PI_NAMESZ, "%s-pci-%d", pde->pe_emu, slot);
+ snprintf(pdi->pi_name, PI_NAMESZ, "%s@pci.%d.%d.%d", pde->pe_emu, bus,
+ slot, func);
/* Disable legacy interrupts */
pci_set_cfgdata8(pdi, PCIR_INTLINE, 255);
@@ -989,7 +1142,7 @@ pci_emul_init(struct vmctx *ctx, struct pci_devemu *pde, int bus, int slot,
pci_set_cfgdata8(pdi, PCIR_COMMAND, PCIM_CMD_BUSMASTEREN);
- err = (*pde->pe_init)(ctx, pdi, fi->fi_config);
+ err = (*pde->pe_init)(pdi, fi->fi_config);
if (err == 0)
fi->fi_devi = pdi;
else
@@ -1161,9 +1314,9 @@ msicap_cfgwrite(struct pci_devinst *pi, int capoff, int offset,
pci_lintr_update(pi);
}
-void
-pciecap_cfgwrite(struct pci_devinst *pi, int capoff, int offset,
- int bytes, uint32_t val)
+static void
+pciecap_cfgwrite(struct pci_devinst *pi, int capoff __unused, int offset,
+ int bytes, uint32_t val)
{
/* XXX don't write to the readonly parts */
@@ -1274,8 +1427,9 @@ pci_emul_iscap(struct pci_devinst *pi, int offset)
}
static int
-pci_emul_fallback_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
- int size, uint64_t *val, void *arg1, long arg2)
+pci_emul_fallback_handler(struct vcpu *vcpu __unused, int dir,
+ uint64_t addr __unused, int size __unused, uint64_t *val,
+ void *arg1 __unused, long arg2 __unused)
{
/*
* Ignore writes; return 0xff's for reads. The mem read code
@@ -1289,8 +1443,8 @@ pci_emul_fallback_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
}
static int
-pci_emul_ecfg_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
- int bytes, uint64_t *val, void *arg1, long arg2)
+pci_emul_ecfg_handler(struct vcpu *vcpu __unused, int dir, uint64_t addr,
+ int bytes, uint64_t *val, void *arg1 __unused, long arg2 __unused)
{
int bus, slot, func, coff, in;
@@ -1301,7 +1455,7 @@ pci_emul_ecfg_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
in = (dir == MEM_F_READ);
if (in)
*val = ~0UL;
- pci_cfgrw(ctx, vcpu, in, bus, slot, func, coff, bytes, (uint32_t *)val);
+ pci_cfgrw(in, bus, slot, func, coff, bytes, (uint32_t *)val);
return (0);
}
@@ -1312,6 +1466,27 @@ pci_ecfg_base(void)
return (PCI_EMUL_ECFG_BASE);
}
+static int
+init_bootorder(void)
+{
+ struct boot_device *device;
+ FILE *fp;
+ char *bootorder;
+ size_t bootorder_len;
+
+ if (TAILQ_EMPTY(&boot_devices))
+ return (0);
+
+ fp = open_memstream(&bootorder, &bootorder_len);
+ TAILQ_FOREACH(device, &boot_devices, boot_device_chain) {
+ fprintf(fp, "/pci@i0cf8/pci@%d,%d\n",
+ device->pdi->pi_slot, device->pdi->pi_func);
+ }
+ fclose(fp);
+
+ return (qemu_fwcfg_add_file("bootorder", bootorder_len, bootorder));
+}
+
#define BUSIO_ROUNDUP 32
#define BUSMEM32_ROUNDUP (1024 * 1024)
#define BUSMEM64_ROUNDUP (512 * 1024 * 1024)
@@ -1337,10 +1512,13 @@ init_pci(struct vmctx *ctx)
pci_emul_iobase = PCI_EMUL_IOBASE;
pci_emul_membase32 = PCI_EMUL_MEMBASE32;
- pci_emul_membase64 = 4*GB + vm_get_highmem_size(ctx);
+ pci_emul_membase64 = vm_get_highmem_base(ctx) +
+ vm_get_highmem_size(ctx);
pci_emul_membase64 = roundup2(pci_emul_membase64, PCI_EMUL_MEMSIZE64);
pci_emul_memlim64 = pci_emul_membase64 + PCI_EMUL_MEMSIZE64;
+ TAILQ_INIT(&boot_devices);
+
for (bus = 0; bus < MAXBUSES; bus++) {
snprintf(node_name, sizeof(node_name), "pci.%d", bus);
nvl = find_config_node(node_name);
@@ -1446,16 +1624,35 @@ init_pci(struct vmctx *ctx)
}
}
}
+#ifdef __amd64__
lpc_pirq_routed();
+#endif
+
+ if ((error = init_bootorder()) != 0) {
+ warnx("%s: Unable to init bootorder", __func__);
+ return (error);
+ }
/*
- * The guest physical memory map looks like the following:
+ * The guest physical memory map looks like the following on amd64:
* [0, lowmem) guest system memory
* [lowmem, 0xC0000000) memory hole (may be absent)
* [0xC0000000, 0xE0000000) PCI hole (32-bit BAR allocation)
* [0xE0000000, 0xF0000000) PCI extended config window
* [0xF0000000, 4GB) LAPIC, IOAPIC, HPET, firmware
- * [4GB, 4GB + highmem)
+ * [4GB, 4GB + highmem) guest system memory
+ * [roundup(4GB + highmem, 32GB), ...) PCI 64-bit BAR allocation
+ *
+ * On arm64 the guest physical memory map looks like this:
+ * [0x0DF00000, 0x10000000) PCI I/O memory
+ * [0xA0000000, 0xE0000000) PCI 32-bit BAR allocation
+ * [0xE0000000, 0xF0000000) PCI extended config window
+ * [4GB, 4GB + highmem) guest system memory
+ * [roundup(4GB + highmem, 32GB), ...) PCI 64-bit BAR allocation
+ *
+ * "lowmem" is guest memory below 0xC0000000. amd64 guests provisioned
+ * with less than 3GB of RAM will have no memory above the 4GB boundary.
+ * System memory for arm64 guests is all above the 4GB boundary.
*/
/*
@@ -1485,9 +1682,10 @@ init_pci(struct vmctx *ctx)
return (0);
}
+#ifdef __amd64__
static void
-pci_apic_prt_entry(int bus, int slot, int pin, int pirq_pin, int ioapic_irq,
- void *arg)
+pci_apic_prt_entry(int bus __unused, int slot, int pin, struct pci_irq *irq,
+ void *arg __unused)
{
dsdt_line(" Package ()");
@@ -1495,17 +1693,17 @@ pci_apic_prt_entry(int bus, int slot, int pin, int pirq_pin, int ioapic_irq,
dsdt_line(" 0x%X,", slot << 16 | 0xffff);
dsdt_line(" 0x%02X,", pin - 1);
dsdt_line(" Zero,");
- dsdt_line(" 0x%X", ioapic_irq);
+ dsdt_line(" 0x%X", irq->ioapic_irq);
dsdt_line(" },");
}
static void
-pci_pirq_prt_entry(int bus, int slot, int pin, int pirq_pin, int ioapic_irq,
- void *arg)
+pci_pirq_prt_entry(int bus __unused, int slot, int pin, struct pci_irq *irq,
+ void *arg __unused)
{
char *name;
- name = lpc_pirq_name(pirq_pin);
+ name = lpc_pirq_name(irq->pirq_pin);
if (name == NULL)
return;
dsdt_line(" Package ()");
@@ -1517,6 +1715,7 @@ pci_pirq_prt_entry(int bus, int slot, int pin, int pirq_pin, int ioapic_irq,
dsdt_line(" },");
free(name);
}
+#endif
/*
* A bhyve virtual machine has a flat PCI hierarchy with a root port
@@ -1528,7 +1727,7 @@ pci_bus_write_dsdt(int bus)
struct businfo *bi;
struct slotinfo *si;
struct pci_devinst *pi;
- int count, func, slot;
+ int func, slot;
/*
* If there are no devices on this 'bus' then just return.
@@ -1562,6 +1761,7 @@ pci_bus_write_dsdt(int bus)
dsdt_line(" 0x0001, // Length");
dsdt_line(" ,, )");
+#ifdef __amd64__
if (bus == 0) {
dsdt_indent(3);
dsdt_fixed_ioport(0xCF8, 8);
@@ -1592,6 +1792,7 @@ pci_bus_write_dsdt(int bus)
goto done;
}
}
+#endif
assert(bi != NULL);
/* i/o window */
@@ -1631,8 +1832,8 @@ pci_bus_write_dsdt(int bus)
dsdt_line(" ,, , AddressRangeMemory, TypeStatic)");
dsdt_line(" })");
- count = pci_count_lintr(bus);
- if (count != 0) {
+#ifdef __amd64__
+ if (pci_count_lintr(bus) != 0) {
dsdt_indent(2);
dsdt_line("Name (PPRT, Package ()");
dsdt_line("{");
@@ -1655,6 +1856,7 @@ pci_bus_write_dsdt(int bus)
dsdt_line("}");
dsdt_unindent(2);
}
+#endif
dsdt_indent(2);
for (slot = 0; slot < MAXSLOTS; slot++) {
@@ -1666,7 +1868,9 @@ pci_bus_write_dsdt(int bus)
}
}
dsdt_unindent(2);
+#ifdef __amd64__
done:
+#endif
dsdt_line(" }");
}
@@ -1736,7 +1940,8 @@ pci_generate_msix(struct pci_devinst *pi, int index)
mte = &pi->pi_msix.table[index];
if ((mte->vector_control & PCIM_MSIX_VCTRL_MASK) == 0) {
/* XXX Set PBA bit if interrupt is disabled */
- vm_lapic_msi(pi->pi_vmctx, mte->addr, mte->msg_data);
+ vm_raise_msi(pi->pi_vmctx, mte->addr, mte->msg_data,
+ pi->pi_bus, pi->pi_slot, pi->pi_func);
}
}
@@ -1745,8 +1950,9 @@ pci_generate_msi(struct pci_devinst *pi, int index)
{
if (pci_msi_enabled(pi) && index < pci_msi_maxmsgnum(pi)) {
- vm_lapic_msi(pi->pi_vmctx, pi->pi_msi.addr,
- pi->pi_msi.msg_data + index);
+ vm_raise_msi(pi->pi_vmctx, pi->pi_msi.addr,
+ pi->pi_msi.msg_data + index,
+ pi->pi_bus, pi->pi_slot, pi->pi_func);
}
}
@@ -1794,6 +2000,7 @@ pci_lintr_route(struct pci_devinst *pi)
{
struct businfo *bi;
struct intxinfo *ii;
+ struct pci_irq *irq;
if (pi->pi_lintr.pin == 0)
return;
@@ -1801,26 +2008,10 @@ pci_lintr_route(struct pci_devinst *pi)
bi = pci_businfo[pi->pi_bus];
assert(bi != NULL);
ii = &bi->slotinfo[pi->pi_slot].si_intpins[pi->pi_lintr.pin - 1];
-
- /*
- * Attempt to allocate an I/O APIC pin for this intpin if one
- * is not yet assigned.
- */
- if (ii->ii_ioapic_irq == 0)
- ii->ii_ioapic_irq = ioapic_pci_alloc_irq(pi);
- assert(ii->ii_ioapic_irq > 0);
-
- /*
- * Attempt to allocate a PIRQ pin for this intpin if one is
- * not yet assigned.
- */
- if (ii->ii_pirq_pin == 0)
- ii->ii_pirq_pin = pirq_alloc_pin(pi);
- assert(ii->ii_pirq_pin > 0);
-
- pi->pi_lintr.ioapic_irq = ii->ii_ioapic_irq;
- pi->pi_lintr.pirq_pin = ii->ii_pirq_pin;
- pci_set_cfgdata8(pi, PCIR_INTLINE, pirq_irq(ii->ii_pirq_pin));
+ irq = &ii->ii_irq;
+ pci_irq_route(pi, irq);
+ pi->pi_lintr.irq = *irq;
+ pci_set_cfgdata8(pi, PCIR_INTLINE, pci_irq_intline(irq));
}
void
@@ -1905,8 +2096,7 @@ pci_walk_lintr(int bus, pci_lintr_cb cb, void *arg)
for (pin = 0; pin < 4; pin++) {
ii = &si->si_intpins[pin];
if (ii->ii_count != 0)
- cb(bus, slot, pin + 1, ii->ii_pirq_pin,
- ii->ii_ioapic_irq, arg);
+ cb(bus, slot, pin + 1, &ii->ii_irq, arg);
}
}
}
@@ -2048,8 +2238,8 @@ pci_emul_cmdsts_write(struct pci_devinst *pi, int coff, uint32_t new, int bytes)
}
static void
-pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
- int coff, int bytes, uint32_t *eax)
+pci_cfgrw(int in, int bus, int slot, int func, int coff, int bytes,
+ uint32_t *valp)
{
struct businfo *bi;
struct slotinfo *si;
@@ -2066,12 +2256,12 @@ pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
/*
* Just return if there is no device at this slot:func or if the
- * the guest is doing an un-aligned access.
+ * guest is doing an un-aligned access.
*/
if (pi == NULL || (bytes != 1 && bytes != 2 && bytes != 4) ||
(coff & (bytes - 1)) != 0) {
if (in)
- *eax = 0xffffffff;
+ *valp = 0xffffffff;
return;
}
@@ -2081,7 +2271,7 @@ pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
*/
if (coff >= PCI_REGMAX + 1) {
if (in) {
- *eax = 0xffffffff;
+ *valp = 0xffffffff;
/*
* Extended capabilities begin at offset 256 in config
* space. Absence of extended capabilities is signaled
@@ -2089,7 +2279,7 @@ pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
* offset 256.
*/
if (coff <= PCI_REGMAX + 4)
- *eax = 0x00000000;
+ *valp = 0x00000000;
}
return;
}
@@ -2102,20 +2292,19 @@ pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
if (in) {
/* Let the device emulation override the default handler */
if (pe->pe_cfgread != NULL) {
- needcfg = pe->pe_cfgread(ctx, vcpu, pi, coff, bytes,
- eax);
+ needcfg = pe->pe_cfgread(pi, coff, bytes, valp);
} else {
needcfg = 1;
}
if (needcfg)
- *eax = CFGREAD(pi, coff, bytes);
+ *valp = CFGREAD(pi, coff, bytes);
- pci_emul_hdrtype_fixup(bus, slot, coff, bytes, eax);
+ pci_emul_hdrtype_fixup(bus, slot, coff, bytes, valp);
} else {
/* Let the device emulation override the default handler */
if (pe->pe_cfgwrite != NULL &&
- (*pe->pe_cfgwrite)(ctx, vcpu, pi, coff, bytes, *eax) == 0)
+ (*pe->pe_cfgwrite)(pi, coff, bytes, *valp) == 0)
return;
/*
@@ -2144,8 +2333,10 @@ pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
pi->pi_bar[idx].addr = bar = 0;
break;
case PCIBAR_IO:
- addr = *eax & mask;
- addr &= 0xffff;
+ addr = *valp & mask;
+#if defined(PCI_EMUL_IOMASK)
+ addr &= PCI_EMUL_IOMASK;
+#endif
bar = addr | pi->pi_bar[idx].lobits;
/*
* Register the new BAR value for interception
@@ -2156,7 +2347,7 @@ pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
}
break;
case PCIBAR_MEM32:
- addr = bar = *eax & mask;
+ addr = bar = *valp & mask;
bar |= pi->pi_bar[idx].lobits;
if (addr != pi->pi_bar[idx].addr) {
update_bar_address(pi, addr, idx,
@@ -2164,7 +2355,7 @@ pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
}
break;
case PCIBAR_MEM64:
- addr = bar = *eax & mask;
+ addr = bar = *valp & mask;
bar |= pi->pi_bar[idx].lobits;
if (addr != (uint32_t)pi->pi_bar[idx].addr) {
update_bar_address(pi, addr, idx,
@@ -2173,7 +2364,7 @@ pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
break;
case PCIBAR_MEMHI64:
mask = ~(pi->pi_bar[idx - 1].size - 1);
- addr = ((uint64_t)*eax << 32) & mask;
+ addr = ((uint64_t)*valp << 32) & mask;
bar = addr >> 32;
if (bar != pi->pi_bar[idx - 1].addr >> 32) {
update_bar_address(pi, addr, idx - 1,
@@ -2181,12 +2372,12 @@ pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
}
break;
case PCIBAR_ROM:
- addr = bar = *eax & mask;
+ addr = bar = *valp & mask;
if (memen(pi) && romen(pi)) {
unregister_bar(pi, idx);
}
pi->pi_bar[idx].addr = addr;
- pi->pi_bar[idx].lobits = *eax &
+ pi->pi_bar[idx].lobits = *valp &
PCIM_BIOS_ENABLE;
/* romen could have changed it value */
if (memen(pi) && romen(pi)) {
@@ -2200,20 +2391,21 @@ pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
pci_set_cfgdata32(pi, coff, bar);
} else if (pci_emul_iscap(pi, coff)) {
- pci_emul_capwrite(pi, coff, bytes, *eax, 0, 0);
+ pci_emul_capwrite(pi, coff, bytes, *valp, 0, 0);
} else if (coff >= PCIR_COMMAND && coff < PCIR_REVID) {
- pci_emul_cmdsts_write(pi, coff, *eax, bytes);
+ pci_emul_cmdsts_write(pi, coff, *valp, bytes);
} else {
- CFGWRITE(pi, coff, *eax, bytes);
+ CFGWRITE(pi, coff, *valp, bytes);
}
}
}
+#ifdef __amd64__
static int cfgenable, cfgbus, cfgslot, cfgfunc, cfgoff;
static int
-pci_emul_cfgaddr(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+pci_emul_cfgaddr(struct vmctx *ctx __unused, int in,
+ int port __unused, int bytes, uint32_t *eax, void *arg __unused)
{
uint32_t x;
@@ -2242,8 +2434,8 @@ pci_emul_cfgaddr(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
INOUT_PORT(pci_cfgaddr, CONF1_ADDR_PORT, IOPORT_F_INOUT, pci_emul_cfgaddr);
static int
-pci_emul_cfgdata(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+pci_emul_cfgdata(struct vmctx *ctx __unused, int in, int port,
+ int bytes, uint32_t *eax, void *arg __unused)
{
int coff;
@@ -2251,8 +2443,7 @@ pci_emul_cfgdata(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
coff = cfgoff + (port - CONF1_DATA_PORT);
if (cfgenable) {
- pci_cfgrw(ctx, vcpu, in, cfgbus, cfgslot, cfgfunc, coff, bytes,
- eax);
+ pci_cfgrw(in, cfgbus, cfgslot, cfgfunc, coff, bytes, eax);
} else {
/* Ignore accesses to cfgdata if not enabled by cfgaddr */
if (in)
@@ -2265,6 +2456,7 @@ INOUT_PORT(pci_cfgdata, CONF1_DATA_PORT+0, IOPORT_F_INOUT, pci_emul_cfgdata);
INOUT_PORT(pci_cfgdata, CONF1_DATA_PORT+1, IOPORT_F_INOUT, pci_emul_cfgdata);
INOUT_PORT(pci_cfgdata, CONF1_DATA_PORT+2, IOPORT_F_INOUT, pci_emul_cfgdata);
INOUT_PORT(pci_cfgdata, CONF1_DATA_PORT+3, IOPORT_F_INOUT, pci_emul_cfgdata);
+#endif
#ifdef BHYVE_SNAPSHOT
/*
@@ -2296,7 +2488,7 @@ pci_snapshot_pci_dev(struct vm_snapshot_meta *meta)
SNAPSHOT_BUF_OR_LEAVE(pi->pi_cfgdata, sizeof(pi->pi_cfgdata),
meta, ret, done);
- for (i = 0; i < nitems(pi->pi_bar); i++) {
+ for (i = 0; i < (int)nitems(pi->pi_bar); i++) {
SNAPSHOT_VAR_OR_LEAVE(pi->pi_bar[i].type, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(pi->pi_bar[i].size, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(pi->pi_bar[i].addr, meta, ret, done);
@@ -2316,42 +2508,6 @@ done:
return (ret);
}
-static int
-pci_find_slotted_dev(const char *dev_name, struct pci_devemu **pde,
- struct pci_devinst **pdi)
-{
- struct businfo *bi;
- struct slotinfo *si;
- struct funcinfo *fi;
- int bus, slot, func;
-
- assert(dev_name != NULL);
- assert(pde != NULL);
- assert(pdi != NULL);
-
- for (bus = 0; bus < MAXBUSES; bus++) {
- if ((bi = pci_businfo[bus]) == NULL)
- continue;
-
- for (slot = 0; slot < MAXSLOTS; slot++) {
- si = &bi->slotinfo[slot];
- for (func = 0; func < MAXFUNCS; func++) {
- fi = &si->si_funcs[func];
- if (fi->fi_pde == NULL)
- continue;
- if (strcmp(dev_name, fi->fi_pde->pe_emu) != 0)
- continue;
-
- *pde = fi->fi_pde;
- *pdi = fi->fi_devi;
- return (0);
- }
- }
- }
-
- return (EINVAL);
-}
-
int
pci_snapshot(struct vm_snapshot_meta *meta)
{
@@ -2361,90 +2517,43 @@ pci_snapshot(struct vm_snapshot_meta *meta)
assert(meta->dev_name != NULL);
- ret = pci_find_slotted_dev(meta->dev_name, &pde, &pdi);
- if (ret != 0) {
- fprintf(stderr, "%s: no such name: %s\r\n",
- __func__, meta->dev_name);
- memset(meta->buffer.buf_start, 0, meta->buffer.buf_size);
- return (0);
- }
+ pdi = meta->dev_data;
+ pde = pdi->pi_d;
- meta->dev_data = pdi;
-
- if (pde->pe_snapshot == NULL) {
- fprintf(stderr, "%s: not implemented yet for: %s\r\n",
- __func__, meta->dev_name);
- return (-1);
- }
+ if (pde->pe_snapshot == NULL)
+ return (ENOTSUP);
ret = pci_snapshot_pci_dev(meta);
- if (ret != 0) {
- fprintf(stderr, "%s: failed to snapshot pci dev\r\n",
- __func__);
- return (-1);
- }
-
- ret = (*pde->pe_snapshot)(meta);
+ if (ret == 0)
+ ret = (*pde->pe_snapshot)(meta);
return (ret);
}
int
-pci_pause(struct vmctx *ctx, const char *dev_name)
+pci_pause(struct pci_devinst *pdi)
{
- struct pci_devemu *pde;
- struct pci_devinst *pdi;
- int ret;
-
- assert(dev_name != NULL);
-
- ret = pci_find_slotted_dev(dev_name, &pde, &pdi);
- if (ret != 0) {
- /*
- * It is possible to call this function without
- * checking that the device is inserted first.
- */
- fprintf(stderr, "%s: no such name: %s\n", __func__, dev_name);
- return (0);
- }
+ struct pci_devemu *pde = pdi->pi_d;
if (pde->pe_pause == NULL) {
/* The pause/resume functionality is optional. */
- fprintf(stderr, "%s: not implemented for: %s\n",
- __func__, dev_name);
return (0);
}
- return (*pde->pe_pause)(ctx, pdi);
+ return (*pde->pe_pause)(pdi);
}
int
-pci_resume(struct vmctx *ctx, const char *dev_name)
+pci_resume(struct pci_devinst *pdi)
{
- struct pci_devemu *pde;
- struct pci_devinst *pdi;
- int ret;
-
- assert(dev_name != NULL);
-
- ret = pci_find_slotted_dev(dev_name, &pde, &pdi);
- if (ret != 0) {
- /*
- * It is possible to call this function without
- * checking that the device is inserted first.
- */
- fprintf(stderr, "%s: no such name: %s\n", __func__, dev_name);
- return (0);
- }
+ struct pci_devemu *pde = pdi->pi_d;
if (pde->pe_resume == NULL) {
/* The pause/resume functionality is optional. */
- fprintf(stderr, "%s: not implemented for: %s\n",
- __func__, dev_name);
return (0);
}
- return (*pde->pe_resume)(ctx, pdi);
+ return (*pde->pe_resume)(pdi);
}
#endif
@@ -2464,7 +2573,7 @@ struct pci_emul_dsoftc {
#define PCI_EMUL_MSIX_MSGS 16
static int
-pci_emul_dinit(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_emul_dinit(struct pci_devinst *pi, nvlist_t *nvl __unused)
{
int error;
struct pci_emul_dsoftc *sc;
@@ -2493,8 +2602,8 @@ pci_emul_dinit(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
}
static void
-pci_emul_diow(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
- uint64_t offset, int size, uint64_t value)
+pci_emul_diow(struct pci_devinst *pi, int baridx, uint64_t offset, int size,
+ uint64_t value)
{
int i;
struct pci_emul_dsoftc *sc = pi->pi_arg;
@@ -2560,8 +2669,7 @@ pci_emul_diow(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
}
static uint64_t
-pci_emul_dior(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
- uint64_t offset, int size)
+pci_emul_dior(struct pci_devinst *pi, int baridx, uint64_t offset, int size)
{
struct pci_emul_dsoftc *sc = pi->pi_arg;
uint32_t value;
@@ -2618,15 +2726,50 @@ pci_emul_dior(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
}
#ifdef BHYVE_SNAPSHOT
-int
-pci_emul_snapshot(struct vm_snapshot_meta *meta)
+struct pci_devinst *
+pci_next(const struct pci_devinst *cursor)
{
+ unsigned bus = 0, slot = 0, func = 0;
+ struct businfo *bi;
+ struct slotinfo *si;
+ struct funcinfo *fi;
+
+ bus = cursor ? cursor->pi_bus : 0;
+ slot = cursor ? cursor->pi_slot : 0;
+ func = cursor ? (cursor->pi_func + 1) : 0;
+ for (; bus < MAXBUSES; bus++) {
+ if ((bi = pci_businfo[bus]) == NULL)
+ continue;
+
+ if (slot >= MAXSLOTS)
+ slot = 0;
+
+ for (; slot < MAXSLOTS; slot++) {
+ si = &bi->slotinfo[slot];
+ if (func >= MAXFUNCS)
+ func = 0;
+ for (; func < MAXFUNCS; func++) {
+ fi = &si->si_funcs[func];
+ if (fi->fi_devi == NULL)
+ continue;
+
+ return (fi->fi_devi);
+ }
+ }
+ }
+
+ return (NULL);
+}
+
+static int
+pci_emul_snapshot(struct vm_snapshot_meta *meta __unused)
+{
return (0);
}
#endif
-struct pci_devemu pci_dummy = {
+static const struct pci_devemu pci_dummy = {
.pe_emu = "dummy",
.pe_init = pci_emul_dinit,
.pe_barwrite = pci_emul_diow,
diff --git a/usr.sbin/bhyve/pci_emul.h b/usr.sbin/bhyve/pci_emul.h
index b8cfabefda2b..063b4b84e044 100644
--- a/usr.sbin/bhyve/pci_emul.h
+++ b/usr.sbin/bhyve/pci_emul.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* 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 _PCI_EMUL_H_
@@ -35,12 +33,15 @@
#include <sys/queue.h>
#include <sys/kernel.h>
#include <sys/nv.h>
+#include <sys/pciio.h>
#include <sys/_pthreadtypes.h>
#include <dev/pci/pcireg.h>
#include <assert.h>
+#include "pci_irq.h"
+
#define PCI_BARMAX PCIR_MAX_BAR_0 /* BAR registers in a Type 0 header */
#define PCI_BARMAX_WITH_ROM (PCI_BARMAX + 1)
#define PCI_ROM_IDX (PCI_BARMAX + 1)
@@ -51,11 +52,10 @@ struct memory_region;
struct vm_snapshot_meta;
struct pci_devemu {
- char *pe_emu; /* Name of device emulation */
+ const char *pe_emu; /* Name of device emulation */
/* instance creation */
- int (*pe_init)(struct vmctx *, struct pci_devinst *,
- nvlist_t *);
+ int (*pe_init)(struct pci_devinst *, nvlist_t *);
int (*pe_legacy_config)(nvlist_t *, const char *);
const char *pe_alias;
@@ -63,31 +63,27 @@ struct pci_devemu {
void (*pe_write_dsdt)(struct pci_devinst *);
/* config space read/write callbacks */
- int (*pe_cfgwrite)(struct vmctx *ctx, int vcpu,
- struct pci_devinst *pi, int offset,
+ int (*pe_cfgwrite)(struct pci_devinst *pi, int offset,
int bytes, uint32_t val);
- int (*pe_cfgread)(struct vmctx *ctx, int vcpu,
- struct pci_devinst *pi, int offset,
+ int (*pe_cfgread)(struct pci_devinst *pi, int offset,
int bytes, uint32_t *retval);
/* BAR read/write callbacks */
- void (*pe_barwrite)(struct vmctx *ctx, int vcpu,
- struct pci_devinst *pi, int baridx,
+ void (*pe_barwrite)(struct pci_devinst *pi, int baridx,
uint64_t offset, int size, uint64_t value);
- uint64_t (*pe_barread)(struct vmctx *ctx, int vcpu,
- struct pci_devinst *pi, int baridx,
+ uint64_t (*pe_barread)(struct pci_devinst *pi, int baridx,
uint64_t offset, int size);
- void (*pe_baraddr)(struct vmctx *ctx, struct pci_devinst *pi,
+ void (*pe_baraddr)(struct pci_devinst *pi,
int baridx, int enabled, uint64_t address);
/* Save/restore device state */
int (*pe_snapshot)(struct vm_snapshot_meta *meta);
- int (*pe_pause)(struct vmctx *ctx, struct pci_devinst *pi);
- int (*pe_resume)(struct vmctx *ctx, struct pci_devinst *pi);
+ int (*pe_pause)(struct pci_devinst *pi);
+ int (*pe_resume)(struct pci_devinst *pi);
};
-#define PCI_EMUL_SET(x) DATA_SET(pci_devemu_set, x);
+#define PCI_EMUL_SET(x) DATA_SET(pci_devemu_set, x)
enum pcibar_type {
PCIBAR_NONE,
@@ -121,12 +117,6 @@ struct msix_table_entry {
#define MAX_MSIX_TABLE_ENTRIES 2048
#define PBA_SIZE(msgnum) (roundup2((msgnum), 64) / 8)
-enum lintr_stat {
- IDLE,
- ASSERTED,
- PENDING
-};
-
struct pci_devinst {
struct pci_devemu *pi_d;
struct vmctx *pi_vmctx;
@@ -138,9 +128,12 @@ struct pci_devinst {
struct {
int8_t pin;
- enum lintr_stat state;
- int pirq_pin;
- int ioapic_irq;
+ enum {
+ IDLE,
+ ASSERTED,
+ PENDING,
+ } state;
+ struct pci_irq irq;
pthread_mutex_t lock;
} pi_lintr;
@@ -227,15 +220,24 @@ struct pciecap {
} __packed;
static_assert(sizeof(struct pciecap) == 60, "compile-time assertion failed");
-typedef void (*pci_lintr_cb)(int b, int s, int pin, int pirq_pin,
- int ioapic_irq, void *arg);
+typedef void (*pci_lintr_cb)(int b, int s, int pin, struct pci_irq *irq,
+ void *arg);
+void pci_lintr_assert(struct pci_devinst *pi);
+void pci_lintr_deassert(struct pci_devinst *pi);
+void pci_lintr_request(struct pci_devinst *pi);
+int pci_count_lintr(int bus);
+void pci_walk_lintr(int bus, pci_lintr_cb cb, void *arg);
int init_pci(struct vmctx *ctx);
void pci_callback(void);
+uint32_t pci_config_read_reg(const struct pcisel *host_sel, nvlist_t *nvl,
+ uint32_t reg, uint8_t size, uint32_t def);
int pci_emul_alloc_bar(struct pci_devinst *pdi, int idx,
enum pcibar_type type, uint64_t size);
int pci_emul_alloc_rom(struct pci_devinst *const pdi, const uint64_t size,
void **const addr);
+int pci_emul_add_boot_device(struct pci_devinst *const pi,
+ const int bootindex);
int pci_emul_add_msicap(struct pci_devinst *pi, int msgnum);
int pci_emul_add_pciecap(struct pci_devinst *pi, int pcie_device_type);
void pci_emul_capwrite(struct pci_devinst *pi, int offset, int bytes,
@@ -243,9 +245,6 @@ void pci_emul_capwrite(struct pci_devinst *pi, int offset, int bytes,
void pci_emul_cmd_changed(struct pci_devinst *pi, uint16_t old);
void pci_generate_msi(struct pci_devinst *pi, int msgnum);
void pci_generate_msix(struct pci_devinst *pi, int msgnum);
-void pci_lintr_assert(struct pci_devinst *pi);
-void pci_lintr_deassert(struct pci_devinst *pi);
-void pci_lintr_request(struct pci_devinst *pi);
int pci_msi_enabled(struct pci_devinst *pi);
int pci_msix_enabled(struct pci_devinst *pi);
int pci_msix_table_bar(struct pci_devinst *pi);
@@ -253,21 +252,21 @@ int pci_msix_pba_bar(struct pci_devinst *pi);
int pci_msi_maxmsgnum(struct pci_devinst *pi);
int pci_parse_legacy_config(nvlist_t *nvl, const char *opt);
int pci_parse_slot(char *opt);
-void pci_print_supported_devices();
+void pci_print_supported_devices(void);
void pci_populate_msicap(struct msicap *cap, int msgs, int nextptr);
int pci_emul_add_msixcap(struct pci_devinst *pi, int msgnum, int barnum);
int pci_emul_msix_twrite(struct pci_devinst *pi, uint64_t offset, int size,
uint64_t value);
uint64_t pci_emul_msix_tread(struct pci_devinst *pi, uint64_t offset, int size);
-int pci_count_lintr(int bus);
-void pci_walk_lintr(int bus, pci_lintr_cb cb, void *arg);
void pci_write_dsdt(void);
uint64_t pci_ecfg_base(void);
int pci_bus_configured(int bus);
+
#ifdef BHYVE_SNAPSHOT
+struct pci_devinst *pci_next(const struct pci_devinst *cursor);
int pci_snapshot(struct vm_snapshot_meta *meta);
-int pci_pause(struct vmctx *ctx, const char *dev_name);
-int pci_resume(struct vmctx *ctx, const char *dev_name);
+int pci_pause(struct pci_devinst *pdi);
+int pci_resume(struct pci_devinst *pdi);
#endif
static __inline void
diff --git a/usr.sbin/bhyve/pci_fbuf.c b/usr.sbin/bhyve/pci_fbuf.c
index e0d8167a5928..798e9b41f0b0 100644
--- a/usr.sbin/bhyve/pci_fbuf.c
+++ b/usr.sbin/bhyve/pci_fbuf.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Nahanni Systems, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/types.h>
#include <sys/mman.h>
@@ -50,10 +45,11 @@ __FBSDID("$FreeBSD$");
#include "config.h"
#include "debug.h"
#include "console.h"
-#include "inout.h"
#include "pci_emul.h"
#include "rfb.h"
-#include "vga.h"
+#ifdef __amd64__
+#include "amd64/vga.h"
+#endif
/*
* bhyve Framebuffer device emulation.
@@ -74,10 +70,10 @@ static int fbuf_debug = 1;
#define DMEMSZ 128
-#define FB_SIZE (16*MB)
+#define FB_SIZE (32*MB)
-#define COLS_MAX 1920
-#define ROWS_MAX 1200
+#define COLS_MAX 3840
+#define ROWS_MAX 2160
#define COLS_DEFAULT 1024
#define ROWS_DEFAULT 768
@@ -117,8 +113,8 @@ static struct pci_fbuf_softc *fbuf_sc;
#define PCI_FBUF_MSI_MSGS 4
static void
-pci_fbuf_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size, uint64_t value)
+pci_fbuf_write(struct pci_devinst *pi, int baridx, uint64_t offset, int size,
+ uint64_t value)
{
struct pci_fbuf_softc *sc;
uint8_t *p;
@@ -170,9 +166,8 @@ pci_fbuf_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
}
}
-uint64_t
-pci_fbuf_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size)
+static uint64_t
+pci_fbuf_read(struct pci_devinst *pi, int baridx, uint64_t offset, int size)
{
struct pci_fbuf_softc *sc;
uint8_t *p;
@@ -217,8 +212,8 @@ pci_fbuf_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
}
static void
-pci_fbuf_baraddr(struct vmctx *ctx, struct pci_devinst *pi, int baridx,
- int enabled, uint64_t address)
+pci_fbuf_baraddr(struct pci_devinst *pi, int baridx, int enabled,
+ uint64_t address)
{
struct pci_fbuf_softc *sc;
int prot;
@@ -228,12 +223,13 @@ pci_fbuf_baraddr(struct vmctx *ctx, struct pci_devinst *pi, int baridx,
sc = pi->pi_arg;
if (!enabled) {
- if (vm_munmap_memseg(ctx, sc->fbaddr, FB_SIZE) != 0)
+ if (vm_munmap_memseg(pi->pi_vmctx, sc->fbaddr, FB_SIZE) != 0)
EPRINTLN("pci_fbuf: munmap_memseg failed");
sc->fbaddr = 0;
} else {
prot = PROT_READ | PROT_WRITE;
- if (vm_mmap_memseg(ctx, address, VM_FRAMEBUFFER, 0, FB_SIZE, prot) != 0)
+ if (vm_mmap_memseg(pi->pi_vmctx, address, VM_FRAMEBUFFER, 0,
+ FB_SIZE, prot) != 0)
EPRINTLN("pci_fbuf: mmap_memseg failed");
sc->fbaddr = address;
}
@@ -316,26 +312,23 @@ pci_fbuf_parse_config(struct pci_fbuf_softc *sc, nvlist_t *nvl)
}
value = get_config_value_node(nvl, "w");
- if (value != NULL) {
- sc->memregs.width = atoi(value);
- if (sc->memregs.width > COLS_MAX) {
- EPRINTLN("fbuf: width %d too large", sc->memregs.width);
- return (-1);
- }
- if (sc->memregs.width == 0)
- sc->memregs.width = 1920;
- }
+ if (value != NULL)
+ sc->memregs.width = strtol(value, NULL, 10);
value = get_config_value_node(nvl, "h");
- if (value != NULL) {
- sc->memregs.height = atoi(value);
- if (sc->memregs.height > ROWS_MAX) {
- EPRINTLN("fbuf: height %d too large",
- sc->memregs.height);
- return (-1);
- }
- if (sc->memregs.height == 0)
- sc->memregs.height = 1080;
+ if (value != NULL)
+ sc->memregs.height = strtol(value, NULL, 10);
+
+ if (sc->memregs.width > COLS_MAX ||
+ sc->memregs.height > ROWS_MAX) {
+ EPRINTLN("fbuf: max resolution is %ux%u", COLS_MAX, ROWS_MAX);
+ return (-1);
+ }
+ if (sc->memregs.width < COLS_MIN ||
+ sc->memregs.height < ROWS_MIN) {
+ EPRINTLN("fbuf: minimum resolution is %ux%u",
+ COLS_MIN, ROWS_MIN);
+ return (-1);
}
value = get_config_value_node(nvl, "password");
@@ -345,10 +338,7 @@ pci_fbuf_parse_config(struct pci_fbuf_softc *sc, nvlist_t *nvl)
return (0);
}
-
-extern void vga_render(struct bhyvegc *gc, void *arg);
-
-void
+static void
pci_fbuf_render(struct bhyvegc *gc, void *arg)
{
struct pci_fbuf_softc *sc;
@@ -368,12 +358,10 @@ pci_fbuf_render(struct bhyvegc *gc, void *arg)
sc->gc_width = sc->memregs.width;
sc->gc_height = sc->memregs.height;
}
-
- return;
}
static int
-pci_fbuf_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_fbuf_init(struct pci_devinst *pi, nvlist_t *nvl)
{
int error;
struct pci_fbuf_softc *sc;
@@ -393,8 +381,8 @@ pci_fbuf_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_DISPLAY);
pci_set_cfgdata8(pi, PCIR_SUBCLASS, PCIS_DISPLAY_VGA);
- sc->fb_base = vm_create_devmem(
- ctx, VM_FRAMEBUFFER, "framebuffer", FB_SIZE);
+ sc->fb_base = vm_create_devmem(pi->pi_vmctx, VM_FRAMEBUFFER,
+ "framebuffer", FB_SIZE);
if (sc->fb_base == MAP_FAILED) {
error = -1;
goto done;
@@ -464,7 +452,7 @@ err:
}
#endif
-struct pci_devemu pci_fbuf = {
+static const struct pci_devemu pci_fbuf = {
.pe_emu = "fbuf",
.pe_init = pci_fbuf_init,
.pe_barwrite = pci_fbuf_write,
diff --git a/usr.sbin/bhyve/pci_hda.c b/usr.sbin/bhyve/pci_hda.c
index 7491944fedd0..8bd84a5113eb 100644
--- a/usr.sbin/bhyve/pci_hda.c
+++ b/usr.sbin/bhyve/pci_hda.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 Alex Teaca <iateaca@FreeBSD.org>
* All rights reserved.
@@ -27,9 +27,7 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
+#include <sys/param.h>
#include <time.h>
#include "pci_hda.h"
@@ -51,8 +49,6 @@ __FBSDID("$FreeBSD$");
#define HDA_CODEC_MAX 0x0f
#define HDA_LAST_OFFSET \
(0x2084 + ((HDA_ISS_NO) * 0x20) + ((HDA_OSS_NO) * 0x20))
-#define HDA_SET_REG_TABLE_SZ \
- (0x80 + ((HDA_ISS_NO) * 0x20) + ((HDA_OSS_NO) * 0x20))
#define HDA_CORB_ENTRY_LEN 0x04
#define HDA_RIRB_ENTRY_LEN 0x08
#define HDA_BDL_ENTRY_LEN 0x10
@@ -94,7 +90,7 @@ struct hda_bdle_desc {
};
struct hda_codec_cmd_ctl {
- char *name;
+ const char *name;
void *dma_vaddr;
uint8_t run;
uint16_t rp;
@@ -201,7 +197,7 @@ static int hda_signal_state_change(struct hda_codec_inst *hci);
static int hda_response(struct hda_codec_inst *hci, uint32_t response,
uint8_t unsol);
static int hda_transfer(struct hda_codec_inst *hci, uint8_t stream,
- uint8_t dir, void *buf, size_t count);
+ uint8_t dir, uint8_t *buf, size_t count);
static void hda_set_pib(struct hda_softc *sc, uint8_t stream_ind, uint32_t pib);
static uint64_t hda_get_clock_ns(void);
@@ -209,11 +205,11 @@ static uint64_t hda_get_clock_ns(void);
/*
* PCI HDA function declarations
*/
-static int pci_hda_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl);
-static void pci_hda_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size, uint64_t value);
-static uint64_t pci_hda_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size);
+static int pci_hda_init(struct pci_devinst *pi, nvlist_t *nvl);
+static void pci_hda_write(struct pci_devinst *pi, int baridx, uint64_t offset,
+ int size, uint64_t value);
+static uint64_t pci_hda_read(struct pci_devinst *pi, int baridx,
+ uint64_t offset, int size);
/*
* HDA global data
*/
@@ -246,8 +242,6 @@ static const hda_set_reg_handler hda_set_reg_table[] = {
HDAC_OSTREAM(1, HDA_ISS_NO, HDA_OSS_NO)
HDAC_OSTREAM(2, HDA_ISS_NO, HDA_OSS_NO)
HDAC_OSTREAM(3, HDA_ISS_NO, HDA_OSS_NO)
-
- [HDA_SET_REG_TABLE_SZ] = NULL,
};
static const uint16_t hda_corb_sizes[] = {
@@ -264,19 +258,18 @@ static const uint16_t hda_rirb_sizes[] = {
[HDAC_RIRBSIZE_RIRBSIZE_MASK] = 0,
};
-static struct hda_ops hops = {
+static const struct hda_ops hops = {
.signal = hda_signal_state_change,
.response = hda_response,
.transfer = hda_transfer,
};
-struct pci_devemu pci_de_hda = {
+static const struct pci_devemu pci_de_hda = {
.pe_emu = "hda",
.pe_init = pci_hda_init,
.pe_barwrite = pci_hda_write,
.pe_barread = pci_hda_read
};
-
PCI_EMUL_SET(pci_de_hda);
SET_DECLARE(hda_codec_class_set, struct hda_codec_class);
@@ -328,7 +321,7 @@ hda_init(nvlist_t *nvl)
int err;
#if DEBUG_HDA == 1
- dbg = fopen("/tmp/bhyve_hda.log", "w+");
+ dbg = fopen(DEBUG_HDA_FILE, "w+");
#endif
sc = calloc(1, sizeof(*sc));
@@ -479,12 +472,14 @@ hda_send_command(struct hda_softc *sc, uint32_t verb)
struct hda_codec_class *codec = NULL;
uint8_t cad = (verb >> HDA_CMD_CAD_SHIFT) & 0x0f;
- hci = sc->codecs[cad];
- if (!hci)
+ if (cad >= sc->codecs_no)
return (-1);
DPRINTF("cad: 0x%x verb: 0x%x", cad, verb);
+ hci = sc->codecs[cad];
+ assert(hci);
+
codec = hci->codec;
assert(codec);
@@ -616,7 +611,6 @@ hda_stream_start(struct hda_softc *sc, uint8_t stream_ind)
uint32_t sdctl = 0;
uint8_t strm = 0;
uint8_t dir = 0;
- int i;
assert(!st->run);
@@ -641,7 +635,7 @@ hda_stream_start(struct hda_softc *sc, uint8_t stream_ind)
st->bdl_cnt = bdl_cnt;
bdle = (struct hda_bdle *)bdl_vaddr;
- for (i = 0; i < bdl_cnt; i++, bdle++) {
+ for (size_t i = 0; i < bdl_cnt; i++, bdle++) {
bdle_sz = bdle->len;
assert(!(bdle_sz % HDA_DMA_ACCESS_LEN));
@@ -660,7 +654,7 @@ hda_stream_start(struct hda_softc *sc, uint8_t stream_ind)
bdle_desc->len = bdle_sz;
bdle_desc->ioc = bdle->ioc;
- DPRINTF("bdle: 0x%x bdle_sz: 0x%x", i, bdle_sz);
+ DPRINTF("bdle: 0x%zx bdle_sz: 0x%x", i, bdle_sz);
}
sdctl = hda_get_reg_by_offset(sc, off + HDAC_SDCTL0);
@@ -716,7 +710,10 @@ hda_write(struct hda_softc *sc, uint32_t offset, uint8_t size, uint32_t value)
uint32_t old = hda_get_reg_by_offset(sc, offset);
uint32_t masks[] = {0x00000000, 0x000000ff, 0x0000ffff,
0x00ffffff, 0xffffffff};
- hda_set_reg_handler set_reg_handler = hda_set_reg_table[offset];
+ hda_set_reg_handler set_reg_handler = NULL;
+
+ if (offset < nitems(hda_set_reg_table))
+ set_reg_handler = hda_set_reg_table[offset];
hda_set_field_by_offset(sc, offset, masks[size], value);
@@ -726,17 +723,19 @@ hda_write(struct hda_softc *sc, uint32_t offset, uint8_t size, uint32_t value)
return (0);
}
+#if DEBUG_HDA == 1
static inline void
hda_print_cmd_ctl_data(struct hda_codec_cmd_ctl *p)
{
-#if DEBUG_HDA == 1
- char *name = p->name;
-#endif
- DPRINTF("%s size: %d", name, p->size);
- DPRINTF("%s dma_vaddr: %p", name, p->dma_vaddr);
- DPRINTF("%s wp: 0x%x", name, p->wp);
- DPRINTF("%s rp: 0x%x", name, p->rp);
+ DPRINTF("%s size: %d", p->name, p->size);
+ DPRINTF("%s dma_vaddr: %p", p->name, p->dma_vaddr);
+ DPRINTF("%s wp: 0x%x", p->name, p->wp);
+ DPRINTF("%s rp: 0x%x", p->name, p->rp);
}
+#else
+static inline void
+hda_print_cmd_ctl_data(struct hda_codec_cmd_ctl *p __unused) {}
+#endif
static int
hda_corb_start(struct hda_softc *sc)
@@ -794,8 +793,8 @@ hda_corb_run(struct hda_softc *sc)
corb->rp++;
corb->rp %= corb->size;
- verb = hda_dma_ld_dword(corb->dma_vaddr + \
- HDA_CORB_ENTRY_LEN * corb->rp);
+ verb = hda_dma_ld_dword((uint8_t *)corb->dma_vaddr +
+ HDA_CORB_ENTRY_LEN * corb->rp);
err = hda_send_command(sc, verb);
assert(!err);
@@ -891,7 +890,7 @@ hda_get_offset_stream(uint8_t stream_ind)
}
static void
-hda_set_gctl(struct hda_softc *sc, uint32_t offset, uint32_t old)
+hda_set_gctl(struct hda_softc *sc, uint32_t offset, uint32_t old __unused)
{
uint32_t value = hda_get_reg_by_offset(sc, offset);
@@ -914,7 +913,8 @@ hda_set_statests(struct hda_softc *sc, uint32_t offset, uint32_t old)
}
static void
-hda_set_corbwp(struct hda_softc *sc, uint32_t offset, uint32_t old)
+hda_set_corbwp(struct hda_softc *sc, uint32_t offset __unused,
+ uint32_t old __unused)
{
hda_corb_run(sc);
}
@@ -940,7 +940,7 @@ hda_set_corbctl(struct hda_softc *sc, uint32_t offset, uint32_t old)
}
static void
-hda_set_rirbctl(struct hda_softc *sc, uint32_t offset, uint32_t old)
+hda_set_rirbctl(struct hda_softc *sc, uint32_t offset, uint32_t old __unused)
{
uint32_t value = hda_get_reg_by_offset(sc, offset);
int err;
@@ -1026,7 +1026,7 @@ hda_set_sdctl(struct hda_softc *sc, uint32_t offset, uint32_t old)
}
static void
-hda_set_sdctl2(struct hda_softc *sc, uint32_t offset, uint32_t old)
+hda_set_sdctl2(struct hda_softc *sc, uint32_t offset, uint32_t old __unused)
{
uint32_t value = hda_get_reg_by_offset(sc, offset);
@@ -1088,10 +1088,10 @@ hda_response(struct hda_codec_inst *hci, uint32_t response, uint8_t unsol)
rirb->wp++;
rirb->wp %= rirb->size;
- hda_dma_st_dword(rirb->dma_vaddr + HDA_RIRB_ENTRY_LEN * \
- rirb->wp, response);
- hda_dma_st_dword(rirb->dma_vaddr + HDA_RIRB_ENTRY_LEN * \
- rirb->wp + 0x04, response_ex);
+ hda_dma_st_dword((uint8_t *)rirb->dma_vaddr +
+ HDA_RIRB_ENTRY_LEN * rirb->wp, response);
+ hda_dma_st_dword((uint8_t *)rirb->dma_vaddr +
+ HDA_RIRB_ENTRY_LEN * rirb->wp + 0x04, response_ex);
hda_set_reg_by_offset(sc, HDAC_RIRBWP, rirb->wp);
@@ -1107,7 +1107,7 @@ hda_response(struct hda_codec_inst *hci, uint32_t response, uint8_t unsol)
static int
hda_transfer(struct hda_codec_inst *hci, uint8_t stream, uint8_t dir,
- void *buf, size_t count)
+ uint8_t *buf, size_t count)
{
struct hda_softc *sc = NULL;
struct hda_stream_desc *st = NULL;
@@ -1161,11 +1161,11 @@ hda_transfer(struct hda_codec_inst *hci, uint8_t stream, uint8_t dir,
bdle_desc = &bdl[st->be];
if (dir)
- *(uint32_t *)buf = \
- hda_dma_ld_dword(bdle_desc->addr + st->bp);
+ *(uint32_t *)buf = hda_dma_ld_dword(
+ (uint8_t *)bdle_desc->addr + st->bp);
else
- hda_dma_st_dword(bdle_desc->addr + st->bp,
- *(uint32_t *)buf);
+ hda_dma_st_dword((uint8_t *)bdle_desc->addr +
+ st->bp, *(uint32_t *)buf);
buf += HDA_DMA_ACCESS_LEN;
st->bp += HDA_DMA_ACCESS_LEN;
@@ -1205,8 +1205,8 @@ hda_set_pib(struct hda_softc *sc, uint8_t stream_ind, uint32_t pib)
/* LPIB Alias */
hda_set_reg_by_offset(sc, 0x2000 + off + HDAC_SDLPIB, pib);
if (sc->dma_pib_vaddr)
- *(uint32_t *)(sc->dma_pib_vaddr + stream_ind * \
- HDA_DMA_PIB_ENTRY_LEN) = pib;
+ *(uint32_t *)((uint8_t *)sc->dma_pib_vaddr + stream_ind *
+ HDA_DMA_PIB_ENTRY_LEN) = pib;
}
static uint64_t hda_get_clock_ns(void)
@@ -1224,11 +1224,10 @@ static uint64_t hda_get_clock_ns(void)
* PCI HDA function definitions
*/
static int
-pci_hda_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_hda_init(struct pci_devinst *pi, nvlist_t *nvl)
{
struct hda_softc *sc = NULL;
- assert(ctx != NULL);
assert(pi != NULL);
pci_set_cfgdata16(pi, PCIR_VENDOR, INTEL_VENDORID);
@@ -1257,8 +1256,8 @@ pci_hda_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
}
static void
-pci_hda_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size, uint64_t value)
+pci_hda_write(struct pci_devinst *pi, int baridx, uint64_t offset, int size,
+ uint64_t value)
{
struct hda_softc *sc = pi->pi_arg;
int err;
@@ -1274,8 +1273,7 @@ pci_hda_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
}
static uint64_t
-pci_hda_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size)
+pci_hda_read(struct pci_devinst *pi, int baridx, uint64_t offset, int size)
{
struct hda_softc *sc = pi->pi_arg;
uint64_t value = 0;
diff --git a/usr.sbin/bhyve/pci_hda.h b/usr.sbin/bhyve/pci_hda.h
index a34366dedc5a..178dfdd9d410 100644
--- a/usr.sbin/bhyve/pci_hda.h
+++ b/usr.sbin/bhyve/pci_hda.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 Alex Teaca <iateaca@FreeBSD.org>
* 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 _HDA_EMUL_H_
@@ -46,12 +44,14 @@
/*
* HDA Debug Log
*/
-#define DEBUG_HDA 1
#if DEBUG_HDA == 1
extern FILE *dbg;
#define DPRINTF(fmt, arg...) \
do {fprintf(dbg, "%s-%d: " fmt "\n", __func__, __LINE__, ##arg); \
fflush(dbg); } while (0)
+#ifndef DEBUG_HDA_FILE
+#define DEBUG_HDA_FILE "/tmp/bhyve_hda.log"
+#endif
#else
#define DPRINTF(fmt, arg...)
#endif
@@ -65,12 +65,12 @@ struct hda_codec_inst {
uint8_t cad;
struct hda_codec_class *codec;
struct hda_softc *hda;
- struct hda_ops *hops;
+ const struct hda_ops *hops;
void *priv;
};
struct hda_codec_class {
- char *name;
+ const char *name;
int (*init)(struct hda_codec_inst *hci, const char *play,
const char *rec);
int (*reset)(struct hda_codec_inst *hci);
@@ -84,9 +84,9 @@ struct hda_ops {
int (*response)(struct hda_codec_inst *hci, uint32_t response,
uint8_t unsol);
int (*transfer)(struct hda_codec_inst *hci, uint8_t stream,
- uint8_t dir, void *buf, size_t count);
+ uint8_t dir, uint8_t *buf, size_t count);
};
-#define HDA_EMUL_SET(x) DATA_SET(hda_codec_class_set, x);
+#define HDA_EMUL_SET(x) DATA_SET(hda_codec_class_set, x)
#endif /* _HDA_EMUL_H_ */
diff --git a/usr.sbin/bhyve/pci_hostbridge.c b/usr.sbin/bhyve/pci_hostbridge.c
index 9fce225bb1d6..df75da4283a5 100644
--- a/usr.sbin/bhyve/pci_hostbridge.c
+++ b/usr.sbin/bhyve/pci_hostbridge.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,20 +24,17 @@
* 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 <err.h>
#include <stdlib.h>
#include "config.h"
#include "pci_emul.h"
static int
-pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_hostbridge_init(struct pci_devinst *pi, nvlist_t *nvl)
{
const char *value;
u_int vendor, device;
@@ -48,9 +45,13 @@ pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
value = get_config_value_node(nvl, "vendor");
if (value != NULL)
vendor = strtol(value, NULL, 0);
+ else
+ vendor = pci_config_read_reg(NULL, nvl, PCIR_VENDOR, 2, vendor);
value = get_config_value_node(nvl, "devid");
if (value != NULL)
device = strtol(value, NULL, 0);
+ else
+ device = pci_config_read_reg(NULL, nvl, PCIR_DEVICE, 2, device);
/* config space */
pci_set_cfgdata16(pi, PCIR_VENDOR, vendor);
@@ -65,24 +66,42 @@ pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
}
static int
-pci_amd_hostbridge_legacy_config(nvlist_t *nvl, const char *opts)
+pci_amd_hostbridge_legacy_config(nvlist_t *nvl, const char *opts __unused)
{
+ nvlist_t *pci_regs;
+
+ pci_regs = create_relative_config_node(nvl, "pcireg");
+ if (pci_regs == NULL) {
+ warnx("amd_hostbridge: failed to create pciregs node");
+ return (-1);
+ }
+
+ set_config_value_node(pci_regs, "vendor", "0x1022"); /* AMD */
+ set_config_value_node(pci_regs, "device", "0x7432"); /* made up */
- set_config_value_node(nvl, "vendor", "0x1022"); /* AMD */
- set_config_value_node(nvl, "devid", "0x7432"); /* made up */
+ return (0);
+}
+#ifdef BHYVE_SNAPSHOT
+static int
+pci_de_snapshot(struct vm_snapshot_meta *meta __unused)
+{
return (0);
}
+#endif
-struct pci_devemu pci_de_amd_hostbridge = {
+static const struct pci_devemu pci_de_amd_hostbridge = {
.pe_emu = "amd_hostbridge",
.pe_legacy_config = pci_amd_hostbridge_legacy_config,
.pe_alias = "hostbridge",
};
PCI_EMUL_SET(pci_de_amd_hostbridge);
-struct pci_devemu pci_de_hostbridge = {
+static const struct pci_devemu pci_de_hostbridge = {
.pe_emu = "hostbridge",
.pe_init = pci_hostbridge_init,
+#ifdef BHYVE_SNAPSHOT
+ .pe_snapshot = pci_de_snapshot,
+#endif
};
PCI_EMUL_SET(pci_de_hostbridge);
diff --git a/usr.sbin/bhyve/pci_irq.h b/usr.sbin/bhyve/pci_irq.h
index 1ae56efc8f2a..8b556ddc91a2 100644
--- a/usr.sbin/bhyve/pci_irq.h
+++ b/usr.sbin/bhyve/pci_irq.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Hudson River Trading LLC
* Written by: John H. Baldwin <jhb@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 __PCI_IRQ_H__
@@ -34,14 +32,16 @@
struct pci_devinst;
+#if defined(__amd64__)
+#include "amd64/pci_irq_machdep.h"
+#elif defined(__aarch64__)
+#include "aarch64/pci_irq_machdep.h"
+#else
+#error Unsupported platform
+#endif
+
void pci_irq_assert(struct pci_devinst *pi);
void pci_irq_deassert(struct pci_devinst *pi);
-void pci_irq_init(struct vmctx *ctx);
-void pci_irq_reserve(int irq);
-void pci_irq_use(int irq);
-int pirq_alloc_pin(struct pci_devinst *pi);
-int pirq_irq(int pin);
-uint8_t pirq_read(int pin);
-void pirq_write(struct vmctx *ctx, int pin, uint8_t val);
+void pci_irq_route(struct pci_devinst *pi, struct pci_irq *irq);
#endif
diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
index 098f0aba1084..45ab1b11fda4 100644
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -1,13 +1,10 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2017 Shunsuke Mie
* Copyright (c) 2018 Leon Dang
* Copyright (c) 2020 Chuck Tuffli
*
- * Function crc16 Copyright (c) 2017, Fedor Uporov
- * Obtained from function ext2_crc16() in sys/fs/ext2fs/ext2_csum.c
- *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -57,10 +54,9 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/errno.h>
#include <sys/types.h>
+#include <sys/crc16.h>
#include <net/ieee_oui.h>
#include <assert.h>
@@ -129,7 +125,7 @@ static int nvme_debug = 0;
/* Encode number of SQ's and CQ's for Set/Get Features */
#define NVME_FEATURE_NUM_QUEUES(sc) \
(ZERO_BASED((sc)->num_squeues) & 0xffff) | \
- (ZERO_BASED((sc)->num_cqueues) & 0xffff) << 16;
+ (ZERO_BASED((sc)->num_cqueues) & 0xffff) << 16
#define NVME_DOORBELL_OFFSET offsetof(struct nvme_registers, doorbell)
@@ -373,40 +369,40 @@ static void pci_nvme_io_done(struct blockif_req *, int);
/* Controller Configuration utils */
#define NVME_CC_GET_EN(cc) \
- ((cc) >> NVME_CC_REG_EN_SHIFT & NVME_CC_REG_EN_MASK)
+ NVMEV(NVME_CC_REG_EN, cc)
#define NVME_CC_GET_CSS(cc) \
- ((cc) >> NVME_CC_REG_CSS_SHIFT & NVME_CC_REG_CSS_MASK)
+ NVMEV(NVME_CC_REG_CSS, cc)
#define NVME_CC_GET_SHN(cc) \
- ((cc) >> NVME_CC_REG_SHN_SHIFT & NVME_CC_REG_SHN_MASK)
+ NVMEV(NVME_CC_REG_SHN, cc)
#define NVME_CC_GET_IOSQES(cc) \
- ((cc) >> NVME_CC_REG_IOSQES_SHIFT & NVME_CC_REG_IOSQES_MASK)
+ NVMEV(NVME_CC_REG_IOSQES, cc)
#define NVME_CC_GET_IOCQES(cc) \
- ((cc) >> NVME_CC_REG_IOCQES_SHIFT & NVME_CC_REG_IOCQES_MASK)
+ NVMEV(NVME_CC_REG_IOCQES, cc)
#define NVME_CC_WRITE_MASK \
- ((NVME_CC_REG_EN_MASK << NVME_CC_REG_EN_SHIFT) | \
- (NVME_CC_REG_IOSQES_MASK << NVME_CC_REG_IOSQES_SHIFT) | \
- (NVME_CC_REG_IOCQES_MASK << NVME_CC_REG_IOCQES_SHIFT))
+ (NVMEM(NVME_CC_REG_EN) | \
+ NVMEM(NVME_CC_REG_IOSQES) | \
+ NVMEM(NVME_CC_REG_IOCQES))
#define NVME_CC_NEN_WRITE_MASK \
- ((NVME_CC_REG_CSS_MASK << NVME_CC_REG_CSS_SHIFT) | \
- (NVME_CC_REG_MPS_MASK << NVME_CC_REG_MPS_SHIFT) | \
- (NVME_CC_REG_AMS_MASK << NVME_CC_REG_AMS_SHIFT))
+ (NVMEM(NVME_CC_REG_CSS) | \
+ NVMEM(NVME_CC_REG_MPS) | \
+ NVMEM(NVME_CC_REG_AMS))
/* Controller Status utils */
#define NVME_CSTS_GET_RDY(sts) \
- ((sts) >> NVME_CSTS_REG_RDY_SHIFT & NVME_CSTS_REG_RDY_MASK)
+ NVMEV(NVME_CSTS_REG_RDY, sts)
-#define NVME_CSTS_RDY (1 << NVME_CSTS_REG_RDY_SHIFT)
+#define NVME_CSTS_RDY (NVMEF(NVME_CSTS_REG_RDY, 1))
+#define NVME_CSTS_CFS (NVMEF(NVME_CSTS_REG_CFS, 1))
/* Completion Queue status word utils */
-#define NVME_STATUS_P (1 << NVME_STATUS_P_SHIFT)
+#define NVME_STATUS_P (NVMEF(NVME_STATUS_P, 1))
#define NVME_STATUS_MASK \
- ((NVME_STATUS_SCT_MASK << NVME_STATUS_SCT_SHIFT) |\
- (NVME_STATUS_SC_MASK << NVME_STATUS_SC_SHIFT))
+ (NVMEM(NVME_STATUS_SCT) | \
+ NVMEM(NVME_STATUS_SC))
-#define NVME_ONCS_DSM (NVME_CTRLR_DATA_ONCS_DSM_MASK << \
- NVME_CTRLR_DATA_ONCS_DSM_SHIFT)
+#define NVME_ONCS_DSM NVMEM(NVME_CTRLR_DATA_ONCS_DSM)
static void nvme_feature_invalid_cb(struct pci_nvme_softc *,
struct nvme_feature_obj *,
@@ -446,8 +442,7 @@ pci_nvme_status_tc(uint16_t *status, uint16_t type, uint16_t code)
{
*status &= ~NVME_STATUS_MASK;
- *status |= (type & NVME_STATUS_SCT_MASK) << NVME_STATUS_SCT_SHIFT |
- (code & NVME_STATUS_SC_MASK) << NVME_STATUS_SC_SHIFT;
+ *status |= NVMEF(NVME_STATUS_SCT, type) | NVMEF(NVME_STATUS_SC, code);
}
static __inline void
@@ -517,6 +512,7 @@ static void
pci_nvme_init_ctrldata(struct pci_nvme_softc *sc)
{
struct nvme_controller_data *cd = &sc->ctrldata;
+ int ret;
cd->vid = 0xFB5D;
cd->ssvid = 0x0000;
@@ -528,9 +524,9 @@ pci_nvme_init_ctrldata(struct pci_nvme_softc *sc)
cd->rab = 4;
/* FreeBSD OUI */
- cd->ieee[0] = 0x58;
+ cd->ieee[0] = 0xfc;
cd->ieee[1] = 0x9c;
- cd->ieee[2] = 0xfc;
+ cd->ieee[2] = 0x58;
cd->mic = 0;
@@ -539,26 +535,34 @@ pci_nvme_init_ctrldata(struct pci_nvme_softc *sc)
cd->ver = NVME_REV(1,4);
cd->cntrltype = NVME_CNTRLTYPE_IO;
- cd->oacs = 1 << NVME_CTRLR_DATA_OACS_FORMAT_SHIFT;
- cd->oaes = NVMEB(NVME_CTRLR_DATA_OAES_NS_ATTR);
+ cd->oacs = NVMEF(NVME_CTRLR_DATA_OACS_FORMAT, 1);
+ cd->oaes = NVMEM(NVME_CTRLR_DATA_OAES_NS_ATTR);
cd->acl = 2;
cd->aerl = 4;
/* Advertise 1, Read-only firmware slot */
- cd->frmw = NVME_CTRLR_DATA_FRMW_SLOT1_RO_MASK |
- (1 << NVME_CTRLR_DATA_FRMW_NUM_SLOTS_SHIFT);
+ cd->frmw = NVMEM(NVME_CTRLR_DATA_FRMW_SLOT1_RO) |
+ NVMEF(NVME_CTRLR_DATA_FRMW_NUM_SLOTS, 1);
cd->lpa = 0; /* TODO: support some simple things like SMART */
cd->elpe = 0; /* max error log page entries */
- cd->npss = 1; /* number of power states support */
+ /*
+ * Report a single power state (zero-based value)
+ * power_state[] values are left as zero to indicate "Not reported"
+ */
+ cd->npss = 0;
/* Warning Composite Temperature Threshold */
cd->wctemp = 0x0157;
cd->cctemp = 0x0157;
- cd->sqes = (6 << NVME_CTRLR_DATA_SQES_MAX_SHIFT) |
- (6 << NVME_CTRLR_DATA_SQES_MIN_SHIFT);
- cd->cqes = (4 << NVME_CTRLR_DATA_CQES_MAX_SHIFT) |
- (4 << NVME_CTRLR_DATA_CQES_MIN_SHIFT);
+ /* SANICAP must not be 0 for Revision 1.4 and later NVMe Controllers */
+ cd->sanicap = NVMEF(NVME_CTRLR_DATA_SANICAP_NODMMAS,
+ NVME_CTRLR_DATA_SANICAP_NODMMAS_NO);
+
+ cd->sqes = NVMEF(NVME_CTRLR_DATA_SQES_MAX, 6) |
+ NVMEF(NVME_CTRLR_DATA_SQES_MIN, 6);
+ cd->cqes = NVMEF(NVME_CTRLR_DATA_CQES_MAX, 4) |
+ NVMEF(NVME_CTRLR_DATA_CQES_MIN, 4);
cd->nn = 1; /* number of namespaces */
cd->oncs = 0;
@@ -574,62 +578,16 @@ pci_nvme_init_ctrldata(struct pci_nvme_softc *sc)
break;
}
- cd->fna = NVME_CTRLR_DATA_FNA_FORMAT_ALL_MASK <<
- NVME_CTRLR_DATA_FNA_FORMAT_ALL_SHIFT;
-
- cd->vwc = NVME_CTRLR_DATA_VWC_ALL_NO << NVME_CTRLR_DATA_VWC_ALL_SHIFT;
+ cd->fna = NVMEM(NVME_CTRLR_DATA_FNA_FORMAT_ALL);
- cd->power_state[0].mp = 10;
-}
+ cd->vwc = NVMEF(NVME_CTRLR_DATA_VWC_ALL, NVME_CTRLR_DATA_VWC_ALL_NO);
-/*
- * Calculate the CRC-16 of the given buffer
- * See copyright attribution at top of file
- */
-static uint16_t
-crc16(uint16_t crc, const void *buffer, unsigned int len)
-{
- const unsigned char *cp = buffer;
- /* CRC table for the CRC-16. The poly is 0x8005 (x16 + x15 + x2 + 1). */
- static uint16_t const crc16_table[256] = {
- 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
- 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
- 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
- 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
- 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
- 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
- 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
- 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
- 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
- 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
- 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
- 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
- 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
- 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
- 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
- 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
- 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
- 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
- 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
- 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
- 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
- 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
- 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
- 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
- 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
- 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
- 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
- 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
- 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
- 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
- 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
- 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
- };
-
- while (len--)
- crc = (((crc >> 8) & 0xffU) ^
- crc16_table[(crc ^ *cp++) & 0xffU]) & 0x0000ffffU;
- return crc;
+ ret = snprintf(cd->subnqn, sizeof(cd->subnqn),
+ "nqn.2013-12.org.freebsd:bhyve-%s-%u-%u-%u",
+ get_config_value("name"), sc->nsc_pi->pi_bus,
+ sc->nsc_pi->pi_slot, sc->nsc_pi->pi_func);
+ if ((ret < 0) || ((unsigned)ret > sizeof(cd->subnqn)))
+ EPRINTLN("%s: error setting subnqn (%d)", __func__, ret);
}
static void
@@ -675,12 +633,13 @@ pci_nvme_init_nsdata(struct pci_nvme_softc *sc,
be64enc(nd->eui64, nvstore->eui64);
/* LBA data-sz = 2^lbads */
- nd->lbaf[0] = nvstore->sectsz_bits << NVME_NS_DATA_LBAF_LBADS_SHIFT;
+ nd->lbaf[0] = NVMEF(NVME_NS_DATA_LBAF_LBADS, nvstore->sectsz_bits);
}
static void
pci_nvme_init_logpages(struct pci_nvme_softc *sc)
{
+ __uint128_t power_cycles = 1;
memset(&sc->err_log, 0, sizeof(sc->err_log));
memset(&sc->health_log, 0, sizeof(sc->health_log));
@@ -695,6 +654,14 @@ pci_nvme_init_logpages(struct pci_nvme_softc *sc)
sc->health_log.temperature = NVME_TEMPERATURE;
sc->health_log.available_spare = 100;
sc->health_log.available_spare_threshold = 10;
+
+ /* Set Active Firmware Info to slot 1 */
+ sc->fw_log.afi = NVMEF(NVME_FIRMWARE_PAGE_AFI_SLOT, 1);
+ memcpy(&sc->fw_log.revision[0], sc->ctrldata.fr,
+ sizeof(sc->fw_log.revision[0]));
+
+ memcpy(&sc->health_log.power_cycles, &power_cycles,
+ sizeof(sc->health_log.power_cycles));
}
static void
@@ -782,7 +749,7 @@ pci_nvme_aer_limit_reached(struct pci_nvme_softc *sc)
struct nvme_controller_data *cd = &sc->ctrldata;
/* AERL is a zero based value while aer_count is one's based */
- return (sc->aer_count == (cd->aerl + 1));
+ return (sc->aer_count == (cd->aerl + 1U));
}
/*
@@ -953,6 +920,7 @@ pci_nvme_aen_process(struct pci_nvme_softc *sc)
EPRINTLN("%s unknown AEN notice type %u",
__func__, aen->event_data);
status = NVME_SC_INTERNAL_DEVICE_ERROR;
+ lid = 0;
break;
}
if ((PCI_NVME_AEI_NOTICE_MASK(aen->event_data) & mask) == 0)
@@ -987,6 +955,7 @@ pci_nvme_aen_process(struct pci_nvme_softc *sc)
/* bad type?!? */
EPRINTLN("%s unknown AEN type %u", __func__, atype);
status = NVME_SC_INTERNAL_DEVICE_ERROR;
+ lid = 0;
break;
}
@@ -1033,10 +1002,10 @@ pci_nvme_reset_locked(struct pci_nvme_softc *sc)
DPRINTF("%s", __func__);
sc->regs.cap_lo = (ZERO_BASED(sc->max_qentries) & NVME_CAP_LO_REG_MQES_MASK) |
- (1 << NVME_CAP_LO_REG_CQR_SHIFT) |
- (60 << NVME_CAP_LO_REG_TO_SHIFT);
+ NVMEF(NVME_CAP_LO_REG_CQR, 1) |
+ NVMEF(NVME_CAP_LO_REG_TO, 60);
- sc->regs.cap_hi = 1 << NVME_CAP_HI_REG_CSS_NVM_SHIFT;
+ sc->regs.cap_hi = NVMEF(NVME_CAP_HI_REG_CSS_NVM, 1);
sc->regs.vs = NVME_REV(1,4); /* NVMe v1.4 */
@@ -1081,30 +1050,60 @@ pci_nvme_reset(struct pci_nvme_softc *sc)
pthread_mutex_unlock(&sc->mtx);
}
-static void
-pci_nvme_init_controller(struct vmctx *ctx, struct pci_nvme_softc *sc)
+static int
+pci_nvme_init_controller(struct pci_nvme_softc *sc)
{
uint16_t acqs, asqs;
DPRINTF("%s", __func__);
- asqs = (sc->regs.aqa & NVME_AQA_REG_ASQS_MASK) + 1;
+ /*
+ * NVMe 2.0 states that "enabling a controller while this field is
+ * cleared to 0h produces undefined results" for both ACQS and
+ * ASQS. If zero, set CFS and do not become ready.
+ */
+ asqs = ONE_BASED(NVMEV(NVME_AQA_REG_ASQS, sc->regs.aqa));
+ if (asqs < 2) {
+ EPRINTLN("%s: illegal ASQS value %#x (aqa=%#x)", __func__,
+ asqs - 1, sc->regs.aqa);
+ sc->regs.csts |= NVME_CSTS_CFS;
+ return (-1);
+ }
sc->submit_queues[0].size = asqs;
- sc->submit_queues[0].qbase = vm_map_gpa(ctx, sc->regs.asq,
- sizeof(struct nvme_command) * asqs);
+ sc->submit_queues[0].qbase = vm_map_gpa(sc->nsc_pi->pi_vmctx,
+ sc->regs.asq, sizeof(struct nvme_command) * asqs);
+ if (sc->submit_queues[0].qbase == NULL) {
+ EPRINTLN("%s: ASQ vm_map_gpa(%lx) failed", __func__,
+ sc->regs.asq);
+ sc->regs.csts |= NVME_CSTS_CFS;
+ return (-1);
+ }
DPRINTF("%s mapping Admin-SQ guest 0x%lx, host: %p",
__func__, sc->regs.asq, sc->submit_queues[0].qbase);
- acqs = ((sc->regs.aqa >> NVME_AQA_REG_ACQS_SHIFT) &
- NVME_AQA_REG_ACQS_MASK) + 1;
+ acqs = ONE_BASED(NVMEV(NVME_AQA_REG_ACQS, sc->regs.aqa));
+ if (acqs < 2) {
+ EPRINTLN("%s: illegal ACQS value %#x (aqa=%#x)", __func__,
+ acqs - 1, sc->regs.aqa);
+ sc->regs.csts |= NVME_CSTS_CFS;
+ return (-1);
+ }
sc->compl_queues[0].size = acqs;
- sc->compl_queues[0].qbase = vm_map_gpa(ctx, sc->regs.acq,
- sizeof(struct nvme_completion) * acqs);
+ sc->compl_queues[0].qbase = vm_map_gpa(sc->nsc_pi->pi_vmctx,
+ sc->regs.acq, sizeof(struct nvme_completion) * acqs);
+ if (sc->compl_queues[0].qbase == NULL) {
+ EPRINTLN("%s: ACQ vm_map_gpa(%lx) failed", __func__,
+ sc->regs.acq);
+ sc->regs.csts |= NVME_CSTS_CFS;
+ return (-1);
+ }
sc->compl_queues[0].intr_en = NVME_CQ_INTEN;
DPRINTF("%s mapping Admin-CQ guest 0x%lx, host: %p",
__func__, sc->regs.acq, sc->compl_queues[0].qbase);
+
+ return (0);
}
static int
@@ -1386,9 +1385,7 @@ nvme_opc_get_log_page(struct pci_nvme_softc* sc, struct nvme_command* command,
{
uint64_t logoff;
uint32_t logsize;
- uint8_t logpage = command->cdw10 & 0xFF;
-
- DPRINTF("%s log page %u len %u", __func__, logpage, logsize);
+ uint8_t logpage;
pci_nvme_status_genc(&compl->status, NVME_SC_SUCCESS);
@@ -1396,10 +1393,13 @@ nvme_opc_get_log_page(struct pci_nvme_softc* sc, struct nvme_command* command,
* Command specifies the number of dwords to return in fields NUMDU
* and NUMDL. This is a zero-based value.
*/
+ logpage = command->cdw10 & 0xFF;
logsize = ((command->cdw11 << 16) | (command->cdw10 >> 16)) + 1;
logsize *= sizeof(uint32_t);
logoff = ((uint64_t)(command->cdw13) << 32) | command->cdw12;
+ DPRINTF("%s log page %u len %u", __func__, logpage, logsize);
+
switch (logpage) {
case NVME_LOG_ERROR:
if (logoff >= sizeof(sc->err_log)) {
@@ -1482,6 +1482,7 @@ nvme_opc_identify(struct pci_nvme_softc* sc, struct nvme_command* command,
DPRINTF("%s identify 0x%x nsid 0x%x", __func__,
command->cdw10 & 0xFF, command->nsid);
+ status = 0;
pci_nvme_status_genc(&status, NVME_SC_SUCCESS);
switch (command->cdw10 & 0xFF) {
@@ -1506,7 +1507,7 @@ nvme_opc_identify(struct pci_nvme_softc* sc, struct nvme_command* command,
dest = vm_map_gpa(sc->nsc_pi->pi_vmctx, command->prp1,
sizeof(uint32_t) * 1024);
/* All unused entries shall be zero */
- bzero(dest, sizeof(uint32_t) * 1024);
+ memset(dest, 0, sizeof(uint32_t) * 1024);
((uint32_t *)dest)[0] = 1;
break;
case 0x03: /* list of NSID structures in CDW1.NSID, 4096 bytes */
@@ -1518,12 +1519,21 @@ nvme_opc_identify(struct pci_nvme_softc* sc, struct nvme_command* command,
dest = vm_map_gpa(sc->nsc_pi->pi_vmctx, command->prp1,
sizeof(uint32_t) * 1024);
/* All bytes after the descriptor shall be zero */
- bzero(dest, sizeof(uint32_t) * 1024);
+ memset(dest, 0, sizeof(uint32_t) * 1024);
/* Return NIDT=1 (i.e. EUI64) descriptor */
((uint8_t *)dest)[0] = 1;
((uint8_t *)dest)[1] = sizeof(uint64_t);
- bcopy(sc->nsdata.eui64, ((uint8_t *)dest) + 4, sizeof(uint64_t));
+ memcpy(((uint8_t *)dest) + 4, sc->nsdata.eui64, sizeof(uint64_t));
+ break;
+ case 0x13:
+ /*
+ * Controller list is optional but used by UNH tests. Return
+ * a valid but empty list.
+ */
+ dest = vm_map_gpa(sc->nsc_pi->pi_vmctx, command->prp1,
+ sizeof(uint16_t) * 2048);
+ memset(dest, 0, sizeof(uint16_t) * 2048);
break;
default:
DPRINTF("%s unsupported identify command requested 0x%x",
@@ -1638,18 +1648,17 @@ nvme_fid_to_name(uint8_t fid)
}
static void
-nvme_feature_invalid_cb(struct pci_nvme_softc *sc,
- struct nvme_feature_obj *feat,
- struct nvme_command *command,
+nvme_feature_invalid_cb(struct pci_nvme_softc *sc __unused,
+ struct nvme_feature_obj *feat __unused,
+ struct nvme_command *command __unused,
struct nvme_completion *compl)
{
-
pci_nvme_status_genc(&compl->status, NVME_SC_INVALID_FIELD);
}
static void
nvme_feature_iv_config(struct pci_nvme_softc *sc,
- struct nvme_feature_obj *feat,
+ struct nvme_feature_obj *feat __unused,
struct nvme_command *command,
struct nvme_completion *compl)
{
@@ -1681,12 +1690,11 @@ nvme_feature_iv_config(struct pci_nvme_softc *sc,
#define NVME_ASYNC_EVENT_ENDURANCE_GROUP (0x4000)
static void
-nvme_feature_async_event(struct pci_nvme_softc *sc,
- struct nvme_feature_obj *feat,
+nvme_feature_async_event(struct pci_nvme_softc *sc __unused,
+ struct nvme_feature_obj *feat __unused,
struct nvme_command *command,
struct nvme_completion *compl)
{
-
if (command->cdw11 & NVME_ASYNC_EVENT_ENDURANCE_GROUP)
pci_nvme_status_genc(&compl->status, NVME_SC_INVALID_FIELD);
}
@@ -1695,7 +1703,7 @@ nvme_feature_async_event(struct pci_nvme_softc *sc,
#define NVME_TEMP_THRESH_UNDER 1
static void
nvme_feature_temperature(struct pci_nvme_softc *sc,
- struct nvme_feature_obj *feat,
+ struct nvme_feature_obj *feat __unused,
struct nvme_command *command,
struct nvme_completion *compl)
{
@@ -1703,6 +1711,7 @@ nvme_feature_temperature(struct pci_nvme_softc *sc,
uint8_t tmpsel; /* Threshold Temperature Select */
uint8_t thsel; /* Threshold Type Select */
bool set_crit = false;
+ bool report_crit;
tmpth = command->cdw11 & 0xffff;
tmpsel = (command->cdw11 >> 16) & 0xf;
@@ -1730,17 +1739,19 @@ nvme_feature_temperature(struct pci_nvme_softc *sc,
~NVME_CRIT_WARN_ST_TEMPERATURE;
pthread_mutex_unlock(&sc->mtx);
- if (set_crit)
+ report_crit = sc->feat[NVME_FEAT_ASYNC_EVENT_CONFIGURATION].cdw11 &
+ NVME_CRIT_WARN_ST_TEMPERATURE;
+
+ if (set_crit && report_crit)
pci_nvme_aen_post(sc, PCI_NVME_AE_TYPE_SMART,
sc->health_log.critical_warning);
-
DPRINTF("%s: set_crit=%c critical_warning=%#x status=%#x", __func__, set_crit ? 'T':'F', sc->health_log.critical_warning, compl->status);
}
static void
nvme_feature_num_queues(struct pci_nvme_softc *sc,
- struct nvme_feature_obj *feat,
+ struct nvme_feature_obj *feat __unused,
struct nvme_command *command,
struct nvme_completion *compl)
{
@@ -1794,7 +1805,8 @@ nvme_opc_set_features(struct pci_nvme_softc *sc, struct nvme_command *command,
{
struct nvme_feature_obj *feat;
uint32_t nsid = command->nsid;
- uint8_t fid = command->cdw10 & 0xFF;
+ uint8_t fid = NVMEV(NVME_FEAT_SET_FID, command->cdw10);
+ bool sv = NVMEV(NVME_FEAT_SET_SV, command->cdw10);
DPRINTF("%s: Feature ID 0x%x (%s)", __func__, fid, nvme_fid_to_name(fid));
@@ -1803,6 +1815,13 @@ nvme_opc_set_features(struct pci_nvme_softc *sc, struct nvme_command *command,
pci_nvme_status_genc(&compl->status, NVME_SC_INVALID_FIELD);
return (1);
}
+
+ if (sv) {
+ pci_nvme_status_tc(&compl->status, NVME_SCT_COMMAND_SPECIFIC,
+ NVME_SC_FEATURE_NOT_SAVEABLE);
+ return (1);
+ }
+
feat = &sc->feat[fid];
if (feat->namespace_specific && (nsid == NVME_GLOBAL_NAMESPACE_TAG)) {
@@ -1822,6 +1841,11 @@ nvme_opc_set_features(struct pci_nvme_softc *sc, struct nvme_command *command,
if (feat->set)
feat->set(sc, feat, command, compl);
+ else {
+ pci_nvme_status_tc(&compl->status, NVME_SCT_COMMAND_SPECIFIC,
+ NVME_SC_FEATURE_NOT_CHANGEABLE);
+ return (1);
+ }
DPRINTF("%s: status=%#x cdw11=%#x", __func__, compl->status, command->cdw11);
if (compl->status == NVME_SC_SUCCESS) {
@@ -1892,7 +1916,7 @@ nvme_opc_format_nvm(struct pci_nvme_softc* sc, struct nvme_command* command,
return (1);
}
- /* Doesn't support Protection Infomation */
+ /* Doesn't support Protection Information */
pi = (command->cdw10 >> 5) & 0x7;
if (pi != 0) {
pci_nvme_status_genc(&compl->status, NVME_SC_INVALID_FIELD);
@@ -1938,8 +1962,8 @@ nvme_opc_format_nvm(struct pci_nvme_softc* sc, struct nvme_command* command,
}
static int
-nvme_opc_abort(struct pci_nvme_softc* sc, struct nvme_command* command,
- struct nvme_completion* compl)
+nvme_opc_abort(struct pci_nvme_softc *sc __unused, struct nvme_command *command,
+ struct nvme_completion *compl)
{
DPRINTF("%s submission queue %u, command ID 0x%x", __func__,
command->cdw10 & 0xFFFF, (command->cdw10 >> 16) & 0xFFFF);
@@ -2055,8 +2079,8 @@ pci_nvme_handle_admin_cmd(struct pci_nvme_softc* sc, uint64_t value)
break;
case NVME_OPC_FORMAT_NVM:
DPRINTF("%s command FORMAT_NVM", __func__);
- if ((sc->ctrldata.oacs &
- (1 << NVME_CTRLR_DATA_OACS_FORMAT_SHIFT)) == 0) {
+ if (NVMEV(NVME_CTRLR_DATA_OACS_FORMAT,
+ sc->ctrldata.oacs) == 0) {
pci_nvme_status_genc(&compl.status, NVME_SC_INVALID_OPCODE);
break;
}
@@ -2102,7 +2126,7 @@ pci_nvme_handle_admin_cmd(struct pci_nvme_softc* sc, uint64_t value)
*
* NVMe defines "data unit" as thousand's of 512 byte blocks and is rounded up.
* E.g. 1 data unit is 1 - 1,000 512 byte blocks. 3 data units are 2,001 - 3,000
- * 512 byte blocks. Rounding up is acheived by initializing the remainder to 999.
+ * 512 byte blocks. Rounding up is achieved by initializing the remainder to 999.
*/
static void
pci_nvme_stats_write_read_update(struct pci_nvme_softc *sc, uint8_t opc,
@@ -2167,10 +2191,11 @@ pci_nvme_out_of_range(struct pci_nvme_blockstore *nvstore, uint64_t slba,
}
static int
-pci_nvme_append_iov_req(struct pci_nvme_softc *sc, struct pci_nvme_ioreq *req,
- uint64_t gpaddr, size_t size, int do_write, uint64_t lba)
+pci_nvme_append_iov_req(struct pci_nvme_softc *sc __unused,
+ struct pci_nvme_ioreq *req, uint64_t gpaddr, size_t size, uint64_t offset)
{
int iovidx;
+ bool range_is_contiguous;
if (req == NULL)
return (-1);
@@ -2179,13 +2204,24 @@ pci_nvme_append_iov_req(struct pci_nvme_softc *sc, struct pci_nvme_ioreq *req,
return (-1);
}
- /* concatenate contig block-iovs to minimize number of iovs */
- if ((req->prev_gpaddr + req->prev_size) == gpaddr) {
+ /*
+ * Minimize the number of IOVs by concatenating contiguous address
+ * ranges. If the IOV count is zero, there is no previous range to
+ * concatenate.
+ */
+ if (req->io_req.br_iovcnt == 0)
+ range_is_contiguous = false;
+ else
+ range_is_contiguous = (req->prev_gpaddr + req->prev_size) == gpaddr;
+
+ if (range_is_contiguous) {
iovidx = req->io_req.br_iovcnt - 1;
req->io_req.br_iov[iovidx].iov_base =
paddr_guest2host(req->sc->nsc_pi->pi_vmctx,
req->prev_gpaddr, size);
+ if (req->io_req.br_iov[iovidx].iov_base == NULL)
+ return (-1);
req->prev_size += size;
req->io_req.br_resid += size;
@@ -2194,7 +2230,7 @@ pci_nvme_append_iov_req(struct pci_nvme_softc *sc, struct pci_nvme_ioreq *req,
} else {
iovidx = req->io_req.br_iovcnt;
if (iovidx == 0) {
- req->io_req.br_offset = lba;
+ req->io_req.br_offset = offset;
req->io_req.br_resid = 0;
req->io_req.br_param = req;
}
@@ -2202,6 +2238,8 @@ pci_nvme_append_iov_req(struct pci_nvme_softc *sc, struct pci_nvme_ioreq *req,
req->io_req.br_iov[iovidx].iov_base =
paddr_guest2host(req->sc->nsc_pi->pi_vmctx,
gpaddr, size);
+ if (req->io_req.br_iov[iovidx].iov_base == NULL)
+ return (-1);
req->io_req.br_iov[iovidx].iov_len = size;
@@ -2217,8 +2255,7 @@ pci_nvme_append_iov_req(struct pci_nvme_softc *sc, struct pci_nvme_ioreq *req,
static void
pci_nvme_set_completion(struct pci_nvme_softc *sc,
- struct nvme_submission_queue *sq, int sqid, uint16_t cid,
- uint32_t cdw0, uint16_t status)
+ struct nvme_submission_queue *sq, int sqid, uint16_t cid, uint16_t status)
{
struct nvme_completion_queue *cq = &sc->compl_queues[sq->cqid];
@@ -2226,11 +2263,7 @@ pci_nvme_set_completion(struct pci_nvme_softc *sc,
__func__, sqid, sq->cqid, cid, NVME_STATUS_GET_SCT(status),
NVME_STATUS_GET_SC(status));
- pci_nvme_cq_update(sc, cq,
- 0, /* CDW0 */
- cid,
- sqid,
- status);
+ pci_nvme_cq_update(sc, cq, 0, cid, sqid, status);
if (cq->head != cq->tail) {
if (cq->intr_en & NVME_CQ_INTEN) {
@@ -2303,9 +2336,10 @@ pci_nvme_io_done(struct blockif_req *br, int err)
/* TODO return correct error */
code = err ? NVME_SC_DATA_TRANSFER_ERROR : NVME_SC_SUCCESS;
+ status = 0;
pci_nvme_status_genc(&status, code);
- pci_nvme_set_completion(req->sc, sq, req->sqid, req->cid, 0, status);
+ pci_nvme_set_completion(req->sc, sq, req->sqid, req->cid, status);
pci_nvme_stats_write_read_update(req->sc, req->opc,
req->bytes, status);
pci_nvme_release_ioreq(req->sc, req);
@@ -2320,8 +2354,8 @@ pci_nvme_io_done(struct blockif_req *br, int err)
* not supported (i.e. RAM or as indicated by the blockif).
*/
static bool
-nvme_opc_flush(struct pci_nvme_softc *sc,
- struct nvme_command *cmd,
+nvme_opc_flush(struct pci_nvme_softc *sc __unused,
+ struct nvme_command *cmd __unused,
struct pci_nvme_blockstore *nvstore,
struct pci_nvme_ioreq *req,
uint16_t *status)
@@ -2367,6 +2401,7 @@ nvme_write_read_ram(struct pci_nvme_softc *sc,
else
dir = NVME_COPY_FROM_PRP;
+ status = 0;
if (nvme_prp_memcpy(sc->nsc_pi->pi_vmctx, prp1, prp2,
buf + offset, bytes, dir))
pci_nvme_status_genc(&status,
@@ -2390,10 +2425,8 @@ nvme_write_read_blockif(struct pci_nvme_softc *sc,
uint16_t status = NVME_NO_STATUS;
size = MIN(PAGE_SIZE - (prp1 % PAGE_SIZE), bytes);
- if (pci_nvme_append_iov_req(sc, req, prp1,
- size, is_write, offset)) {
- pci_nvme_status_genc(&status,
- NVME_SC_DATA_TRANSFER_ERROR);
+ if (pci_nvme_append_iov_req(sc, req, prp1, size, offset)) {
+ err = -1;
goto out;
}
@@ -2404,10 +2437,8 @@ nvme_write_read_blockif(struct pci_nvme_softc *sc,
;
} else if (bytes <= PAGE_SIZE) {
size = bytes;
- if (pci_nvme_append_iov_req(sc, req, prp2,
- size, is_write, offset)) {
- pci_nvme_status_genc(&status,
- NVME_SC_DATA_TRANSFER_ERROR);
+ if (pci_nvme_append_iov_req(sc, req, prp2, size, offset)) {
+ err = -1;
goto out;
}
} else {
@@ -2423,15 +2454,18 @@ nvme_write_read_blockif(struct pci_nvme_softc *sc,
prp_list = paddr_guest2host(vmctx, prp,
PAGE_SIZE - (prp % PAGE_SIZE));
+ if (prp_list == NULL) {
+ err = -1;
+ goto out;
+ }
last = prp_list + (NVME_PRP2_ITEMS - 1);
}
size = MIN(bytes, PAGE_SIZE);
- if (pci_nvme_append_iov_req(sc, req, *prp_list,
- size, is_write, offset)) {
- pci_nvme_status_genc(&status,
- NVME_SC_DATA_TRANSFER_ERROR);
+ if (pci_nvme_append_iov_req(sc, req, *prp_list, size,
+ offset)) {
+ err = -1;
goto out;
}
@@ -2446,10 +2480,10 @@ nvme_write_read_blockif(struct pci_nvme_softc *sc,
err = blockif_write(nvstore->ctx, &req->io_req);
else
err = blockif_read(nvstore->ctx, &req->io_req);
-
+out:
if (err)
pci_nvme_status_genc(&status, NVME_SC_DATA_TRANSFER_ERROR);
-out:
+
return (status);
}
@@ -2467,6 +2501,12 @@ nvme_opc_write_read(struct pci_nvme_softc *sc,
lba = ((uint64_t)cmd->cdw11 << 32) | cmd->cdw10;
nblocks = (cmd->cdw12 & 0xFFFF) + 1;
+ bytes = nblocks << nvstore->sectsz_bits;
+ if (bytes > NVME_MAX_DATA_SIZE) {
+ WPRINTF("%s command would exceed MDTS", __func__);
+ pci_nvme_status_genc(status, NVME_SC_INVALID_FIELD);
+ goto out;
+ }
if (pci_nvme_out_of_range(nvstore, lba, nblocks)) {
WPRINTF("%s command would exceed LBA range(slba=%#lx nblocks=%#lx)",
@@ -2475,13 +2515,6 @@ nvme_opc_write_read(struct pci_nvme_softc *sc,
goto out;
}
- bytes = nblocks << nvstore->sectsz_bits;
- if (bytes > NVME_MAX_DATA_SIZE) {
- WPRINTF("%s command would exceed MDTS", __func__);
- pci_nvme_status_genc(status, NVME_SC_INVALID_FIELD);
- goto out;
- }
-
offset = lba << nvstore->sectsz_bits;
req->bytes = bytes;
@@ -2516,6 +2549,7 @@ pci_nvme_dealloc_sm(struct blockif_req *br, int err)
bool done = true;
uint16_t status;
+ status = 0;
if (err) {
pci_nvme_status_genc(&status, NVME_SC_INTERNAL_DEVICE_ERROR);
} else if ((req->prev_gpaddr + 1) == (req->prev_size)) {
@@ -2537,8 +2571,8 @@ pci_nvme_dealloc_sm(struct blockif_req *br, int err)
}
if (done) {
- pci_nvme_set_completion(sc, req->nvme_sq, req->sqid,
- req->cid, 0, status);
+ pci_nvme_set_completion(sc, req->nvme_sq, req->sqid, req->cid,
+ status);
pci_nvme_release_ioreq(sc, req);
}
}
@@ -2550,7 +2584,7 @@ nvme_opc_dataset_mgmt(struct pci_nvme_softc *sc,
struct pci_nvme_ioreq *req,
uint16_t *status)
{
- struct nvme_dsm_range *range;
+ struct nvme_dsm_range *range = NULL;
uint32_t nr, r, non_zero, dr;
int err;
bool pending = false;
@@ -2695,8 +2729,7 @@ pci_nvme_handle_io_cmd(struct pci_nvme_softc* sc, uint16_t idx)
if ((nsid == 0) || (nsid > sc->ctrldata.nn)) {
pci_nvme_status_genc(&status,
NVME_SC_INVALID_NAMESPACE_OR_FORMAT);
- status |=
- NVME_STATUS_DNR_MASK << NVME_STATUS_DNR_SHIFT;
+ status |= NVMEM(NVME_STATUS_DNR);
goto complete;
}
@@ -2740,8 +2773,7 @@ pci_nvme_handle_io_cmd(struct pci_nvme_softc* sc, uint16_t idx)
}
complete:
if (!pending) {
- pci_nvme_set_completion(sc, sq, idx, cmd->cid, 0,
- status);
+ pci_nvme_set_completion(sc, sq, idx, cmd->cid, status);
if (req != NULL)
pci_nvme_release_ioreq(sc, req);
}
@@ -2753,7 +2785,7 @@ complete:
}
static void
-pci_nvme_handle_doorbell(struct vmctx *ctx, struct pci_nvme_softc* sc,
+pci_nvme_handle_doorbell(struct pci_nvme_softc* sc,
uint64_t idx, int is_sq, uint64_t value)
{
DPRINTF("nvme doorbell %lu, %s, val 0x%lx",
@@ -2847,8 +2879,8 @@ pci_nvme_bar0_reg_dumps(const char *func, uint64_t offset, int iswrite)
}
static void
-pci_nvme_write_bar_0(struct vmctx *ctx, struct pci_nvme_softc* sc,
- uint64_t offset, int size, uint64_t value)
+pci_nvme_write_bar_0(struct pci_nvme_softc *sc, uint64_t offset, int size,
+ uint64_t value)
{
uint32_t ccreg;
@@ -2857,6 +2889,12 @@ pci_nvme_write_bar_0(struct vmctx *ctx, struct pci_nvme_softc* sc,
uint64_t idx = belloffset / 8; /* door bell size = 2*int */
int is_sq = (belloffset % 8) < 4;
+ if ((sc->regs.csts & NVME_CSTS_RDY) == 0) {
+ WPRINTF("doorbell write prior to RDY (offset=%#lx)\n",
+ offset);
+ return;
+ }
+
if (belloffset > ((sc->max_queues+1) * 8 - 4)) {
WPRINTF("guest attempted an overflow write offset "
"0x%lx, val 0x%lx in %s",
@@ -2864,7 +2902,13 @@ pci_nvme_write_bar_0(struct vmctx *ctx, struct pci_nvme_softc* sc,
return;
}
- pci_nvme_handle_doorbell(ctx, sc, idx, is_sq, value);
+ if (is_sq) {
+ if (sc->submit_queues[idx].qbase == NULL)
+ return;
+ } else if (sc->compl_queues[idx].qbase == NULL)
+ return;
+
+ pci_nvme_handle_doorbell(sc, idx, is_sq, value);
return;
}
@@ -2909,17 +2953,16 @@ pci_nvme_write_bar_0(struct vmctx *ctx, struct pci_nvme_softc* sc,
if (NVME_CC_GET_SHN(ccreg)) {
/* perform shutdown - flush out data to backend */
- sc->regs.csts &= ~(NVME_CSTS_REG_SHST_MASK <<
- NVME_CSTS_REG_SHST_SHIFT);
- sc->regs.csts |= NVME_SHST_COMPLETE <<
- NVME_CSTS_REG_SHST_SHIFT;
+ sc->regs.csts &= ~NVMEM(NVME_CSTS_REG_SHST);
+ sc->regs.csts |= NVMEF(NVME_CSTS_REG_SHST,
+ NVME_SHST_COMPLETE);
}
if (NVME_CC_GET_EN(ccreg) != NVME_CC_GET_EN(sc->regs.cc)) {
if (NVME_CC_GET_EN(ccreg) == 0)
/* transition 1-> causes controller reset */
pci_nvme_reset_locked(sc);
else
- pci_nvme_init_controller(ctx, sc);
+ pci_nvme_init_controller(sc);
}
/* Insert the iocqes, iosqes and en bits from the write */
@@ -2930,7 +2973,8 @@ pci_nvme_write_bar_0(struct vmctx *ctx, struct pci_nvme_softc* sc,
sc->regs.cc &= ~NVME_CC_NEN_WRITE_MASK;
sc->regs.cc |= ccreg & NVME_CC_NEN_WRITE_MASK;
sc->regs.csts &= ~NVME_CSTS_RDY;
- } else if (sc->pending_ios == 0) {
+ } else if ((sc->pending_ios == 0) &&
+ !(sc->regs.csts & NVME_CSTS_CFS)) {
sc->regs.csts |= NVME_CSTS_RDY;
}
break;
@@ -2966,8 +3010,8 @@ pci_nvme_write_bar_0(struct vmctx *ctx, struct pci_nvme_softc* sc,
}
static void
-pci_nvme_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size, uint64_t value)
+pci_nvme_write(struct pci_devinst *pi, int baridx, uint64_t offset, int size,
+ uint64_t value)
{
struct pci_nvme_softc* sc = pi->pi_arg;
@@ -2982,7 +3026,7 @@ pci_nvme_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
switch (baridx) {
case 0:
- pci_nvme_write_bar_0(ctx, sc, offset, size, value);
+ pci_nvme_write_bar_0(sc, offset, size, value);
break;
default:
@@ -3029,8 +3073,7 @@ static uint64_t pci_nvme_read_bar_0(struct pci_nvme_softc* sc,
static uint64_t
-pci_nvme_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
- uint64_t offset, int size)
+pci_nvme_read(struct pci_devinst *pi, int baridx, uint64_t offset, int size)
{
struct pci_nvme_softc* sc = pi->pi_arg;
@@ -3056,7 +3099,7 @@ pci_nvme_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
static int
pci_nvme_parse_config(struct pci_nvme_softc *sc, nvlist_t *nvl)
{
- char bident[sizeof("XX:X:X")];
+ char bident[sizeof("XXX:XXX")];
const char *value;
uint32_t sectsz;
@@ -3116,6 +3159,14 @@ pci_nvme_parse_config(struct pci_nvme_softc *sc, nvlist_t *nvl)
sc->dataset_management = NVME_DATASET_MANAGEMENT_DISABLE;
}
+ value = get_config_value_node(nvl, "bootindex");
+ if (value != NULL) {
+ if (pci_emul_add_boot_device(sc->nsc_pi, atoi(value))) {
+ EPRINTLN("Invalid bootindex %d", atoi(value));
+ return (-1);
+ }
+ }
+
value = get_config_value_node(nvl, "ram");
if (value != NULL) {
uint64_t sz = strtoull(value, NULL, 10);
@@ -3130,7 +3181,7 @@ pci_nvme_parse_config(struct pci_nvme_softc *sc, nvlist_t *nvl)
return (-1);
}
} else {
- snprintf(bident, sizeof(bident), "%d:%d",
+ snprintf(bident, sizeof(bident), "%u:%u",
sc->nsc_pi->pi_slot, sc->nsc_pi->pi_func);
sc->nvstore.ctx = blockif_open(nvl, bident);
if (sc->nvstore.ctx == NULL) {
@@ -3147,7 +3198,7 @@ pci_nvme_parse_config(struct pci_nvme_softc *sc, nvlist_t *nvl)
else if (sc->nvstore.type != NVME_STOR_RAM)
sc->nvstore.sectsz = blockif_sectsz(sc->nvstore.ctx);
for (sc->nvstore.sectsz_bits = 9;
- (1 << sc->nvstore.sectsz_bits) < sc->nvstore.sectsz;
+ (1U << sc->nvstore.sectsz_bits) < sc->nvstore.sectsz;
sc->nvstore.sectsz_bits++);
if (sc->max_queues <= 0 || sc->max_queues > NVME_QUEUES)
@@ -3157,7 +3208,8 @@ pci_nvme_parse_config(struct pci_nvme_softc *sc, nvlist_t *nvl)
}
static void
-pci_nvme_resized(struct blockif_ctxt *bctxt, void *arg, size_t new_size)
+pci_nvme_resized(struct blockif_ctxt *bctxt __unused, void *arg,
+ size_t new_size)
{
struct pci_nvme_softc *sc;
struct pci_nvme_blockstore *nvstore;
@@ -3179,7 +3231,7 @@ pci_nvme_resized(struct blockif_ctxt *bctxt, void *arg, size_t new_size)
}
static int
-pci_nvme_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_nvme_init(struct pci_devinst *pi, nvlist_t *nvl)
{
struct pci_nvme_softc *sc;
uint32_t pci_membar_sz;
@@ -3199,7 +3251,7 @@ pci_nvme_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
STAILQ_INIT(&sc->ioreqs_free);
sc->ioreqs = calloc(sc->ioslots, sizeof(struct pci_nvme_ioreq));
- for (int i = 0; i < sc->ioslots; i++) {
+ for (uint32_t i = 0; i < sc->ioslots; i++) {
STAILQ_INSERT_TAIL(&sc->ioreqs_free, &sc->ioreqs[i], link);
}
@@ -3259,9 +3311,6 @@ pci_nvme_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
pci_nvme_aen_init(sc);
pci_nvme_reset(sc);
-
- pci_lintr_request(pi);
-
done:
return (error);
}
@@ -3288,7 +3337,7 @@ pci_nvme_legacy_config(nvlist_t *nvl, const char *opts)
return (blockif_legacy_config(nvl, opts));
}
-struct pci_devemu pci_de_nvme = {
+static const struct pci_devemu pci_de_nvme = {
.pe_emu = "nvme",
.pe_init = pci_nvme_init,
.pe_legacy_config = pci_nvme_legacy_config,
diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c
index 153554f97e43..13d422eaa59c 100644
--- a/usr.sbin/bhyve/pci_passthru.c
+++ b/usr.sbin/bhyve/pci_passthru.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/param.h>
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
@@ -52,6 +47,7 @@ __FBSDID("$FreeBSD$");
#ifndef WITHOUT_CAPSICUM
#include <capsicum_helpers.h>
#endif
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -63,7 +59,6 @@ __FBSDID("$FreeBSD$");
#include <machine/vmm.h>
-#include "config.h"
#include "debug.h"
#include "mem.h"
#include "pci_passthru.h"
@@ -77,8 +72,12 @@ __FBSDID("$FreeBSD$");
#define MSIX_TABLE_COUNT(ctrl) (((ctrl) & PCIM_MSIXCTRL_TABLE_SIZE) + 1)
#define MSIX_CAPLEN 12
+#define PASSTHRU_MMIO_MAX 2
+
static int pcifd = -1;
+SET_DECLARE(passthru_dev_set, struct passthru_dev);
+
struct passthru_softc {
struct pci_devinst *psc_pi;
/* ROM is handled like a BAR */
@@ -92,6 +91,10 @@ struct passthru_softc {
int capoff;
} psc_msix;
struct pcisel psc_sel;
+
+ struct passthru_mmio_mapping psc_mmio_map[PASSTHRU_MMIO_MAX];
+ cfgread_handler psc_pcir_rhandler[PCI_REGMAX + 1];
+ cfgwrite_handler psc_pcir_whandler[PCI_REGMAX + 1];
};
static int
@@ -117,7 +120,8 @@ msi_caplen(int msgctrl)
}
static int
-pcifd_init() {
+pcifd_init(void)
+{
pcifd = open(_PATH_DEVPCI, O_RDWR, 0);
if (pcifd < 0) {
warn("failed to open %s", _PATH_DEVPCI);
@@ -131,7 +135,7 @@ pcifd_init() {
errx(EX_OSERR, "Unable to apply rights for sandbox");
const cap_ioctl_t pcifd_ioctls[] = { PCIOCREAD, PCIOCWRITE, PCIOCGETBAR,
- PCIOCBARIO, PCIOCBARMMAP };
+ PCIOCBARIO, PCIOCBARMMAP, PCIOCGETCONF };
if (caph_ioctls_limit(pcifd, pcifd_ioctls, nitems(pcifd_ioctls)) == -1)
errx(EX_OSERR, "Unable to apply rights for sandbox");
#endif
@@ -140,14 +144,14 @@ pcifd_init() {
}
uint32_t
-read_config(const struct pcisel *sel, long reg, int width)
+pci_host_read_config(const struct pcisel *sel, long reg, int width)
{
+ struct pci_io pi;
+
if (pcifd < 0 && pcifd_init()) {
return (0);
}
- struct pci_io pi;
-
bzero(&pi, sizeof(pi));
pi.pi_sel = *sel;
pi.pi_reg = reg;
@@ -160,14 +164,15 @@ read_config(const struct pcisel *sel, long reg, int width)
}
void
-write_config(const struct pcisel *sel, long reg, int width, uint32_t data)
+pci_host_write_config(const struct pcisel *sel, long reg, int width,
+ uint32_t data)
{
+ struct pci_io pi;
+
if (pcifd < 0 && pcifd_init()) {
return;
}
- struct pci_io pi;
-
bzero(&pi, sizeof(pi));
pi.pi_sel = *sel;
pi.pi_reg = reg;
@@ -181,7 +186,7 @@ write_config(const struct pcisel *sel, long reg, int width, uint32_t data)
static int
passthru_add_msicap(struct pci_devinst *pi, int msgnum, int nextptr)
{
- int capoff, i;
+ int capoff;
struct msicap msicap;
u_char *capdata;
@@ -195,7 +200,7 @@ passthru_add_msicap(struct pci_devinst *pi, int msgnum, int nextptr)
*/
capoff = 256 - roundup(sizeof(msicap), 4);
capdata = (u_char *)&msicap;
- for (i = 0; i < sizeof(msicap); i++)
+ for (size_t i = 0; i < sizeof(msicap); i++)
pci_set_cfgdata8(pi, capoff + i, capdata[i]);
return (capoff);
@@ -210,7 +215,7 @@ cfginitmsi(struct passthru_softc *sc)
struct pcisel sel;
struct pci_devinst *pi;
struct msixcap msixcap;
- uint32_t *msixcap_ptr;
+ char *msixcap_ptr;
pi = sc->psc_pi;
sel = sc->psc_sel;
@@ -219,24 +224,25 @@ cfginitmsi(struct passthru_softc *sc)
* Parse the capabilities and cache the location of the MSI
* and MSI-X capabilities.
*/
- sts = read_config(&sel, PCIR_STATUS, 2);
+ sts = pci_host_read_config(&sel, PCIR_STATUS, 2);
if (sts & PCIM_STATUS_CAPPRESENT) {
- ptr = read_config(&sel, PCIR_CAP_PTR, 1);
+ ptr = pci_host_read_config(&sel, PCIR_CAP_PTR, 1);
while (ptr != 0 && ptr != 0xff) {
- cap = read_config(&sel, ptr + PCICAP_ID, 1);
+ cap = pci_host_read_config(&sel, ptr + PCICAP_ID, 1);
if (cap == PCIY_MSI) {
/*
* Copy the MSI capability into the config
* space of the emulated pci device
*/
sc->psc_msi.capoff = ptr;
- sc->psc_msi.msgctrl = read_config(&sel,
- ptr + 2, 2);
+ sc->psc_msi.msgctrl = pci_host_read_config(&sel,
+ ptr + 2, 2);
sc->psc_msi.emulated = 0;
caplen = msi_caplen(sc->psc_msi.msgctrl);
capptr = ptr;
while (caplen > 0) {
- u32 = read_config(&sel, capptr, 4);
+ u32 = pci_host_read_config(&sel, capptr,
+ 4);
pci_set_cfgdata32(pi, capptr, u32);
caplen -= 4;
capptr += 4;
@@ -247,18 +253,20 @@ cfginitmsi(struct passthru_softc *sc)
*/
sc->psc_msix.capoff = ptr;
caplen = 12;
- msixcap_ptr = (uint32_t*) &msixcap;
+ msixcap_ptr = (char *)&msixcap;
capptr = ptr;
while (caplen > 0) {
- u32 = read_config(&sel, capptr, 4);
- *msixcap_ptr = u32;
+ u32 = pci_host_read_config(&sel, capptr,
+ 4);
+ memcpy(msixcap_ptr, &u32, 4);
pci_set_cfgdata32(pi, capptr, u32);
caplen -= 4;
capptr += 4;
- msixcap_ptr++;
+ msixcap_ptr += 4;
}
}
- ptr = read_config(&sel, ptr + PCICAP_NEXTPTR, 1);
+ ptr = pci_host_read_config(&sel, ptr + PCICAP_NEXTPTR,
+ 1);
}
}
@@ -293,7 +301,7 @@ cfginitmsi(struct passthru_softc *sc)
*/
if ((sts & PCIM_STATUS_CAPPRESENT) != 0 && sc->psc_msi.capoff == 0) {
int origptr, msiptr;
- origptr = read_config(&sel, PCIR_CAP_PTR, 1);
+ origptr = pci_host_read_config(&sel, PCIR_CAP_PTR, 1);
msiptr = passthru_add_msicap(pi, 1, origptr);
sc->psc_msi.capoff = msiptr;
sc->psc_msi.msgctrl = pci_get_cfgdata16(pi, msiptr + 2);
@@ -384,8 +392,8 @@ msix_table_read(struct passthru_softc *sc, uint64_t offset, int size)
}
static void
-msix_table_write(struct vmctx *ctx, int vcpu, struct passthru_softc *sc,
- uint64_t offset, int size, uint64_t data)
+msix_table_write(struct passthru_softc *sc, uint64_t offset, int size,
+ uint64_t data)
{
struct pci_devinst *pi;
struct msix_table_entry *entry;
@@ -436,14 +444,14 @@ msix_table_write(struct vmctx *ctx, int vcpu, struct passthru_softc *sc,
assert(entry_offset % 4 == 0);
vector_control = entry->vector_control;
- dest32 = (uint32_t *)((void *)entry + entry_offset);
+ dest32 = (uint32_t *)((uint8_t *)entry + entry_offset);
*dest32 = data;
/* If MSI-X hasn't been enabled, do nothing */
if (pi->pi_msix.enabled) {
/* If the entry is masked, don't set it up */
if ((entry->vector_control & PCIM_MSIX_VCTRL_MASK) == 0 ||
(vector_control & PCIM_MSIX_VCTRL_MASK) == 0) {
- (void)vm_setup_pptdev_msix(ctx, vcpu,
+ (void)vm_setup_pptdev_msix(sc->psc_pi->pi_vmctx,
sc->psc_sel.pc_bus, sc->psc_sel.pc_dev,
sc->psc_sel.pc_func, index, entry->addr,
entry->msg_data, entry->vector_control);
@@ -452,7 +460,7 @@ msix_table_write(struct vmctx *ctx, int vcpu, struct passthru_softc *sc,
}
static int
-init_msix_table(struct vmctx *ctx, struct passthru_softc *sc)
+init_msix_table(struct passthru_softc *sc)
{
struct pci_devinst *pi = sc->psc_pi;
struct pci_bar_mmap pbm;
@@ -513,7 +521,7 @@ init_msix_table(struct vmctx *ctx, struct passthru_softc *sc)
}
static int
-cfginitbar(struct vmctx *ctx, struct passthru_softc *sc)
+cfginitbar(struct passthru_softc *sc)
{
int i, error;
struct pci_devinst *pi;
@@ -572,7 +580,8 @@ cfginitbar(struct vmctx *ctx, struct passthru_softc *sc)
return (-1);
/* Use same lobits as physical bar */
- uint8_t lobits = read_config(&sc->psc_sel, PCIR_BAR(i), 0x01);
+ uint8_t lobits = pci_host_read_config(&sc->psc_sel, PCIR_BAR(i),
+ 0x01);
if (bartype == PCIBAR_MEM32 || bartype == PCIBAR_MEM64) {
lobits &= ~PCIM_BAR_MEM_BASE;
} else {
@@ -594,10 +603,11 @@ cfginitbar(struct vmctx *ctx, struct passthru_softc *sc)
}
static int
-cfginit(struct vmctx *ctx, struct pci_devinst *pi, int bus, int slot, int func)
+cfginit(struct pci_devinst *pi, int bus, int slot, int func)
{
int error;
struct passthru_softc *sc;
+ uint8_t intline, intpin;
error = 1;
sc = pi->pi_arg;
@@ -607,19 +617,33 @@ cfginit(struct vmctx *ctx, struct pci_devinst *pi, int bus, int slot, int func)
sc->psc_sel.pc_dev = slot;
sc->psc_sel.pc_func = func;
+ /*
+ * Copy physical PCI header to virtual config space. INTLINE and INTPIN
+ * shouldn't be aligned with their physical value and they are already set by
+ * pci_emul_init().
+ */
+ intline = pci_get_cfgdata8(pi, PCIR_INTLINE);
+ intpin = pci_get_cfgdata8(pi, PCIR_INTPIN);
+ for (int i = 0; i <= PCIR_MAXLAT; i += 4) {
+ pci_set_cfgdata32(pi, i,
+ pci_host_read_config(&sc->psc_sel, i, 4));
+ }
+ pci_set_cfgdata8(pi, PCIR_INTLINE, intline);
+ pci_set_cfgdata8(pi, PCIR_INTPIN, intpin);
+
if (cfginitmsi(sc) != 0) {
warnx("failed to initialize MSI for PCI %d/%d/%d",
bus, slot, func);
goto done;
}
- if (cfginitbar(ctx, sc) != 0) {
+ if (cfginitbar(sc) != 0) {
warnx("failed to initialize BARs for PCI %d/%d/%d",
bus, slot, func);
goto done;
}
- write_config(&sc->psc_sel, PCIR_COMMAND, 2,
+ pci_host_write_config(&sc->psc_sel, PCIR_COMMAND, 2,
pci_get_cfgdata16(pi, PCIR_COMMAND));
/*
@@ -627,7 +651,7 @@ cfginit(struct vmctx *ctx, struct pci_devinst *pi, int bus, int slot, int func)
* a BAR was enabled, as otherwise the PCIOCBARMMAP might fail on us.
*/
if (pci_msix_table_bar(pi) >= 0) {
- error = init_msix_table(ctx, sc);
+ error = init_msix_table(sc);
if (error != 0) {
warnx(
"failed to initialize MSI-X table for PCI %d/%d/%d: %d",
@@ -641,38 +665,80 @@ done:
return (error);
}
+struct passthru_mmio_mapping *
+passthru_get_mmio(struct passthru_softc *sc, int num)
+{
+ assert(sc != NULL);
+ assert(num < PASSTHRU_MMIO_MAX);
+
+ return (&sc->psc_mmio_map[num]);
+}
+
+struct pcisel *
+passthru_get_sel(struct passthru_softc *sc)
+{
+ assert(sc != NULL);
+
+ return (&sc->psc_sel);
+}
+
+int
+set_pcir_handler(struct passthru_softc *sc, int reg, int len,
+ cfgread_handler rhandler, cfgwrite_handler whandler)
+{
+ if (reg > PCI_REGMAX || reg + len > PCI_REGMAX + 1)
+ return (-1);
+
+ for (int i = reg; i < reg + len; ++i) {
+ assert(sc->psc_pcir_rhandler[i] == NULL || rhandler == NULL);
+ assert(sc->psc_pcir_whandler[i] == NULL || whandler == NULL);
+ sc->psc_pcir_rhandler[i] = rhandler;
+ sc->psc_pcir_whandler[i] = whandler;
+ }
+
+ return (0);
+}
+
static int
passthru_legacy_config(nvlist_t *nvl, const char *opts)
{
+ const char *cp;
+ char *tofree;
char value[16];
int bus, slot, func;
if (opts == NULL)
return (0);
- if (sscanf(opts, "%d/%d/%d", &bus, &slot, &func) != 3) {
+ cp = strchr(opts, ',');
+
+ if (strncmp(opts, "ppt", strlen("ppt")) == 0) {
+ tofree = strndup(opts, cp - opts);
+ set_config_value_node(nvl, "pptdev", tofree);
+ free(tofree);
+ } else if (sscanf(opts, "pci0:%d:%d:%d", &bus, &slot, &func) == 3 ||
+ sscanf(opts, "pci%d:%d:%d", &bus, &slot, &func) == 3 ||
+ sscanf(opts, "%d/%d/%d", &bus, &slot, &func) == 3) {
+ snprintf(value, sizeof(value), "%d", bus);
+ set_config_value_node(nvl, "bus", value);
+ snprintf(value, sizeof(value), "%d", slot);
+ set_config_value_node(nvl, "slot", value);
+ snprintf(value, sizeof(value), "%d", func);
+ set_config_value_node(nvl, "func", value);
+ } else {
EPRINTLN("passthru: invalid options \"%s\"", opts);
return (-1);
}
- snprintf(value, sizeof(value), "%d", bus);
- set_config_value_node(nvl, "bus", value);
- snprintf(value, sizeof(value), "%d", slot);
- set_config_value_node(nvl, "slot", value);
- snprintf(value, sizeof(value), "%d", func);
- set_config_value_node(nvl, "func", value);
-
- opts = strchr(opts, ',');
- if (opts == NULL) {
+ if (cp == NULL) {
return (0);
}
- return pci_parse_legacy_config(nvl, opts + 1);
+ return (pci_parse_legacy_config(nvl, cp + 1));
}
static int
-passthru_init_rom(struct vmctx *const ctx, struct passthru_softc *const sc,
- const char *const romfile)
+passthru_init_rom(struct passthru_softc *const sc, const char *const romfile)
{
if (romfile == NULL) {
return (0);
@@ -721,17 +787,85 @@ passthru_init_rom(struct vmctx *const ctx, struct passthru_softc *const sc,
return (0);
}
+static bool
+passthru_lookup_pptdev(const char *name, int *bus, int *slot, int *func)
+{
+ struct pci_conf_io pc;
+ struct pci_conf conf[1];
+ struct pci_match_conf patterns[1];
+ char *cp;
+
+ bzero(&pc, sizeof(struct pci_conf_io));
+ pc.match_buf_len = sizeof(conf);
+ pc.matches = conf;
+
+ bzero(&patterns, sizeof(patterns));
+
+ /*
+ * The pattern structure requires the unit to be split out from
+ * the driver name. Walk backwards from the end of the name to
+ * find the start of the unit.
+ */
+ cp = strchr(name, '\0');
+ assert(cp != NULL);
+ while (cp != name && isdigit(cp[-1]))
+ cp--;
+ if (cp == name || !isdigit(*cp)) {
+ EPRINTLN("Invalid passthru device name %s", name);
+ return (false);
+ }
+ if ((size_t)(cp - name) + 1 > sizeof(patterns[0].pd_name)) {
+ EPRINTLN("Passthru device name %s is too long", name);
+ return (false);
+ }
+ memcpy(patterns[0].pd_name, name, cp - name);
+ patterns[0].pd_unit = strtol(cp, &cp, 10);
+ if (*cp != '\0') {
+ EPRINTLN("Invalid passthru device name %s", name);
+ return (false);
+ }
+ patterns[0].flags = PCI_GETCONF_MATCH_NAME | PCI_GETCONF_MATCH_UNIT;
+ pc.num_patterns = 1;
+ pc.pat_buf_len = sizeof(patterns);
+ pc.patterns = patterns;
+
+ if (ioctl(pcifd, PCIOCGETCONF, &pc) == -1) {
+ EPRINTLN("ioctl(PCIOCGETCONF): %s", strerror(errno));
+ return (false);
+ }
+ if (pc.status != PCI_GETCONF_LAST_DEVICE &&
+ pc.status != PCI_GETCONF_MORE_DEVS) {
+ EPRINTLN("error returned from PCIOCGETCONF ioctl");
+ return (false);
+ }
+ if (pc.num_matches == 0) {
+ EPRINTLN("Passthru device %s not found", name);
+ return (false);
+ }
+
+ if (conf[0].pc_sel.pc_domain != 0) {
+ EPRINTLN("Passthru device %s on unsupported domain", name);
+ return (false);
+ }
+ *bus = conf[0].pc_sel.pc_bus;
+ *slot = conf[0].pc_sel.pc_dev;
+ *func = conf[0].pc_sel.pc_func;
+ return (true);
+}
+
static int
-passthru_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+passthru_init(struct pci_devinst *pi, nvlist_t *nvl)
{
int bus, slot, func, error, memflags;
struct passthru_softc *sc;
+ struct passthru_dev **devpp;
+ struct passthru_dev *devp, *dev = NULL;
const char *value;
sc = NULL;
error = 1;
- memflags = vm_get_memflags(ctx);
+ memflags = vm_get_memflags(pi->pi_vmctx);
if (!(memflags & VM_MEM_F_WIRED)) {
warnx("passthru requires guest memory to be wired");
return (error);
@@ -750,11 +884,17 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
var = atoi(value); \
} while (0)
- GET_INT_CONFIG(bus, "bus");
- GET_INT_CONFIG(slot, "slot");
- GET_INT_CONFIG(func, "func");
+ value = get_config_value_node(nvl, "pptdev");
+ if (value != NULL) {
+ if (!passthru_lookup_pptdev(value, &bus, &slot, &func))
+ return (error);
+ } else {
+ GET_INT_CONFIG(bus, "bus");
+ GET_INT_CONFIG(slot, "slot");
+ GET_INT_CONFIG(func, "func");
+ }
- if (vm_assign_pptdev(ctx, bus, slot, func) != 0) {
+ if (vm_assign_pptdev(pi->pi_vmctx, bus, slot, func) != 0) {
warnx("PCI device at %d/%d/%d is not using the ppt(4) driver",
bus, slot, func);
goto done;
@@ -766,34 +906,50 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
sc->psc_pi = pi;
/* initialize config space */
- if ((error = cfginit(ctx, pi, bus, slot, func)) != 0)
+ if ((error = cfginit(pi, bus, slot, func)) != 0)
goto done;
/* initialize ROM */
- if ((error = passthru_init_rom(ctx, sc,
+ if ((error = passthru_init_rom(sc,
get_config_value_node(nvl, "rom"))) != 0)
goto done;
+ /* Emulate most PCI header register. */
+ if ((error = set_pcir_handler(sc, 0, PCIR_MAXLAT + 1,
+ passthru_cfgread_emulate, passthru_cfgwrite_emulate)) != 0)
+ goto done;
+
+ /* Allow access to the physical command and status register. */
+ if ((error = set_pcir_handler(sc, PCIR_COMMAND, 0x04, NULL, NULL)) != 0)
+ goto done;
+
+ SET_FOREACH(devpp, passthru_dev_set) {
+ devp = *devpp;
+ assert(devp->probe != NULL);
+ if (devp->probe(pi) == 0) {
+ dev = devp;
+ break;
+ }
+ }
+
+ if (dev != NULL) {
+ error = dev->init(pi, nvl);
+ if (error != 0)
+ goto done;
+ }
+
error = 0; /* success */
done:
if (error) {
+ if (dev != NULL)
+ dev->deinit(pi);
free(sc);
- vm_unassign_pptdev(ctx, bus, slot, func);
+ vm_unassign_pptdev(pi->pi_vmctx, bus, slot, func);
}
return (error);
}
static int
-bar_access(int coff)
-{
- if ((coff >= PCIR_BAR(0) && coff < PCIR_BAR(PCI_BARMAX + 1)) ||
- coff == PCIR_BIOS)
- return (1);
- else
- return (0);
-}
-
-static int
msicap_access(struct passthru_softc *sc, int coff)
{
int caplen;
@@ -820,31 +976,15 @@ msixcap_access(struct passthru_softc *sc, int coff)
}
static int
-passthru_cfgread(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int coff, int bytes, uint32_t *rv)
+passthru_cfgread_default(struct passthru_softc *sc,
+ struct pci_devinst *pi __unused, int coff, int bytes, uint32_t *rv)
{
- struct passthru_softc *sc;
-
- sc = pi->pi_arg;
-
/*
- * PCI BARs and MSI capability is emulated.
+ * MSI capability is emulated.
*/
- if (bar_access(coff) || msicap_access(sc, coff) ||
- msixcap_access(sc, coff))
+ if (msicap_access(sc, coff) || msixcap_access(sc, coff))
return (-1);
-#ifdef LEGACY_SUPPORT
- /*
- * Emulate PCIR_CAP_PTR if this device does not support MSI capability
- * natively.
- */
- if (sc->psc_msi.emulated) {
- if (coff >= PCIR_CAP_PTR && coff < PCIR_CAP_PTR + 4)
- return (-1);
- }
-#endif
-
/*
* Emulate the command register. If a single read reads both the
* command and status registers, read the status register from the
@@ -853,32 +993,44 @@ passthru_cfgread(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
if (coff == PCIR_COMMAND) {
if (bytes <= 2)
return (-1);
- *rv = read_config(&sc->psc_sel, PCIR_STATUS, 2) << 16 |
+ *rv = pci_host_read_config(&sc->psc_sel, PCIR_STATUS, 2) << 16 |
pci_get_cfgdata16(pi, PCIR_COMMAND);
return (0);
}
/* Everything else just read from the device's config space */
- *rv = read_config(&sc->psc_sel, coff, bytes);
+ *rv = pci_host_read_config(&sc->psc_sel, coff, bytes);
return (0);
}
+int
+passthru_cfgread_emulate(struct passthru_softc *sc __unused,
+ struct pci_devinst *pi __unused, int coff __unused, int bytes __unused,
+ uint32_t *rv __unused)
+{
+ return (-1);
+}
+
static int
-passthru_cfgwrite(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int coff, int bytes, uint32_t val)
+passthru_cfgread(struct pci_devinst *pi, int coff, int bytes, uint32_t *rv)
{
- int error, msix_table_entries, i;
struct passthru_softc *sc;
- uint16_t cmd_old;
sc = pi->pi_arg;
- /*
- * PCI BARs are emulated
- */
- if (bar_access(coff))
- return (-1);
+ if (sc->psc_pcir_rhandler[coff] != NULL)
+ return (sc->psc_pcir_rhandler[coff](sc, pi, coff, bytes, rv));
+
+ return (passthru_cfgread_default(sc, pi, coff, bytes, rv));
+}
+
+static int
+passthru_cfgwrite_default(struct passthru_softc *sc, struct pci_devinst *pi,
+ int coff, int bytes, uint32_t val)
+{
+ int error, msix_table_entries, i;
+ uint16_t cmd_old;
/*
* MSI capability is emulated
@@ -886,7 +1038,7 @@ passthru_cfgwrite(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
if (msicap_access(sc, coff)) {
pci_emul_capwrite(pi, coff, bytes, val, sc->psc_msi.capoff,
PCIY_MSI);
- error = vm_setup_pptdev_msi(ctx, vcpu, sc->psc_sel.pc_bus,
+ error = vm_setup_pptdev_msi(pi->pi_vmctx, sc->psc_sel.pc_bus,
sc->psc_sel.pc_dev, sc->psc_sel.pc_func,
pi->pi_msi.addr, pi->pi_msi.msg_data,
pi->pi_msi.maxmsgnum);
@@ -901,7 +1053,7 @@ passthru_cfgwrite(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
if (pi->pi_msix.enabled) {
msix_table_entries = pi->pi_msix.table_count;
for (i = 0; i < msix_table_entries; i++) {
- error = vm_setup_pptdev_msix(ctx, vcpu,
+ error = vm_setup_pptdev_msix(pi->pi_vmctx,
sc->psc_sel.pc_bus, sc->psc_sel.pc_dev,
sc->psc_sel.pc_func, i,
pi->pi_msix.table[i].addr,
@@ -912,8 +1064,9 @@ passthru_cfgwrite(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
err(1, "vm_setup_pptdev_msix");
}
} else {
- error = vm_disable_pptdev_msix(ctx, sc->psc_sel.pc_bus,
- sc->psc_sel.pc_dev, sc->psc_sel.pc_func);
+ error = vm_disable_pptdev_msix(pi->pi_vmctx,
+ sc->psc_sel.pc_bus, sc->psc_sel.pc_dev,
+ sc->psc_sel.pc_func);
if (error)
err(1, "vm_disable_pptdev_msix");
}
@@ -932,7 +1085,7 @@ passthru_cfgwrite(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
}
#endif
- write_config(&sc->psc_sel, coff, bytes, val);
+ pci_host_write_config(&sc->psc_sel, coff, bytes, val);
if (coff == PCIR_COMMAND) {
cmd_old = pci_get_cfgdata16(pi, PCIR_COMMAND);
if (bytes == 1)
@@ -945,9 +1098,30 @@ passthru_cfgwrite(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
return (0);
}
+int
+passthru_cfgwrite_emulate(struct passthru_softc *sc __unused,
+ struct pci_devinst *pi __unused, int coff __unused, int bytes __unused,
+ uint32_t val __unused)
+{
+ return (-1);
+}
+
+static int
+passthru_cfgwrite(struct pci_devinst *pi, int coff, int bytes, uint32_t val)
+{
+ struct passthru_softc *sc;
+
+ sc = pi->pi_arg;
+
+ if (sc->psc_pcir_whandler[coff] != NULL)
+ return (sc->psc_pcir_whandler[coff](sc, pi, coff, bytes, val));
+
+ return (passthru_cfgwrite_default(sc, pi, coff, bytes, val));
+}
+
static void
-passthru_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
- uint64_t offset, int size, uint64_t value)
+passthru_write(struct pci_devinst *pi, int baridx, uint64_t offset, int size,
+ uint64_t value)
{
struct passthru_softc *sc;
struct pci_bar_ioreq pio;
@@ -955,7 +1129,7 @@ passthru_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
sc = pi->pi_arg;
if (baridx == pci_msix_table_bar(pi)) {
- msix_table_write(ctx, vcpu, sc, offset, size, value);
+ msix_table_write(sc, offset, size, value);
} else {
assert(pi->pi_bar[baridx].type == PCIBAR_IO);
assert(size == 1 || size == 2 || size == 4);
@@ -974,8 +1148,7 @@ passthru_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
}
static uint64_t
-passthru_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
- uint64_t offset, int size)
+passthru_read(struct pci_devinst *pi, int baridx, uint64_t offset, int size)
{
struct passthru_softc *sc;
struct pci_bar_ioreq pio;
@@ -1006,8 +1179,8 @@ passthru_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
}
static void
-passthru_msix_addr(struct vmctx *ctx, struct pci_devinst *pi, int baridx,
- int enabled, uint64_t address)
+passthru_msix_addr(struct pci_devinst *pi, int baridx, int enabled,
+ uint64_t address)
{
struct passthru_softc *sc;
size_t remaining;
@@ -1017,13 +1190,14 @@ passthru_msix_addr(struct vmctx *ctx, struct pci_devinst *pi, int baridx,
table_offset = rounddown2(pi->pi_msix.table_offset, 4096);
if (table_offset > 0) {
if (!enabled) {
- if (vm_unmap_pptdev_mmio(ctx, sc->psc_sel.pc_bus,
+ if (vm_unmap_pptdev_mmio(pi->pi_vmctx,
+ sc->psc_sel.pc_bus,
sc->psc_sel.pc_dev,
sc->psc_sel.pc_func, address,
table_offset) != 0)
warnx("pci_passthru: unmap_pptdev_mmio failed");
} else {
- if (vm_map_pptdev_mmio(ctx, sc->psc_sel.pc_bus,
+ if (vm_map_pptdev_mmio(pi->pi_vmctx, sc->psc_sel.pc_bus,
sc->psc_sel.pc_dev,
sc->psc_sel.pc_func, address,
table_offset,
@@ -1038,13 +1212,14 @@ passthru_msix_addr(struct vmctx *ctx, struct pci_devinst *pi, int baridx,
if (remaining > 0) {
address += table_offset + table_size;
if (!enabled) {
- if (vm_unmap_pptdev_mmio(ctx, sc->psc_sel.pc_bus,
+ if (vm_unmap_pptdev_mmio(pi->pi_vmctx,
+ sc->psc_sel.pc_bus,
sc->psc_sel.pc_dev,
sc->psc_sel.pc_func, address,
remaining) != 0)
warnx("pci_passthru: unmap_pptdev_mmio failed");
} else {
- if (vm_map_pptdev_mmio(ctx, sc->psc_sel.pc_bus,
+ if (vm_map_pptdev_mmio(pi->pi_vmctx, sc->psc_sel.pc_bus,
sc->psc_sel.pc_dev,
sc->psc_sel.pc_func, address,
remaining,
@@ -1056,20 +1231,20 @@ passthru_msix_addr(struct vmctx *ctx, struct pci_devinst *pi, int baridx,
}
static void
-passthru_mmio_addr(struct vmctx *ctx, struct pci_devinst *pi, int baridx,
- int enabled, uint64_t address)
+passthru_mmio_addr(struct pci_devinst *pi, int baridx, int enabled,
+ uint64_t address)
{
struct passthru_softc *sc;
sc = pi->pi_arg;
if (!enabled) {
- if (vm_unmap_pptdev_mmio(ctx, sc->psc_sel.pc_bus,
+ if (vm_unmap_pptdev_mmio(pi->pi_vmctx, sc->psc_sel.pc_bus,
sc->psc_sel.pc_dev,
sc->psc_sel.pc_func, address,
sc->psc_bar[baridx].size) != 0)
warnx("pci_passthru: unmap_pptdev_mmio failed");
} else {
- if (vm_map_pptdev_mmio(ctx, sc->psc_sel.pc_bus,
+ if (vm_map_pptdev_mmio(pi->pi_vmctx, sc->psc_sel.pc_bus,
sc->psc_sel.pc_dev,
sc->psc_sel.pc_func, address,
sc->psc_bar[baridx].size,
@@ -1094,15 +1269,14 @@ passthru_addr_rom(struct pci_devinst *const pi, const int idx,
} else {
if (vm_mmap_memseg(pi->pi_vmctx, addr, VM_PCIROM,
pi->pi_romoffset, size, PROT_READ | PROT_EXEC) != 0) {
- errx(4, "%s: mnmap_memseg @ [%016lx - %016lx] failed",
+ errx(4, "%s: mmap_memseg @ [%016lx - %016lx] failed",
__func__, addr, addr + size);
}
}
}
static void
-passthru_addr(struct vmctx *ctx, struct pci_devinst *pi, int baridx,
- int enabled, uint64_t address)
+passthru_addr(struct pci_devinst *pi, int baridx, int enabled, uint64_t address)
{
switch (pi->pi_bar[baridx].type) {
case PCIBAR_IO:
@@ -1114,9 +1288,9 @@ passthru_addr(struct vmctx *ctx, struct pci_devinst *pi, int baridx,
case PCIBAR_MEM32:
case PCIBAR_MEM64:
if (baridx == pci_msix_table_bar(pi))
- passthru_msix_addr(ctx, pi, baridx, enabled, address);
+ passthru_msix_addr(pi, baridx, enabled, address);
else
- passthru_mmio_addr(ctx, pi, baridx, enabled, address);
+ passthru_mmio_addr(pi, baridx, enabled, address);
break;
default:
errx(4, "%s: invalid BAR type %d", __func__,
@@ -1124,7 +1298,7 @@ passthru_addr(struct vmctx *ctx, struct pci_devinst *pi, int baridx,
}
}
-struct pci_devemu passthru = {
+static const struct pci_devemu passthru = {
.pe_emu = "passthru",
.pe_init = passthru_init,
.pe_legacy_config = passthru_legacy_config,
diff --git a/usr.sbin/bhyve/pci_passthru.h b/usr.sbin/bhyve/pci_passthru.h
index bdc8dc3cd0e2..a89ad287cbc5 100644
--- a/usr.sbin/bhyve/pci_passthru.h
+++ b/usr.sbin/bhyve/pci_passthru.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020 Beckhoff Automation GmbH & Co. KG
* Author: Corvin Köhne <c.koehne@beckhoff.com>
@@ -7,9 +7,45 @@
#pragma once
+#include <sys/linker_set.h>
+
#include <vmmapi.h>
+#include "config.h"
#include "pci_emul.h"
-uint32_t read_config(const struct pcisel *sel, long reg, int width);
-void write_config(const struct pcisel *sel, long reg, int width, uint32_t data);
+struct passthru_mmio_mapping {
+ vm_paddr_t gpa; /* guest physical address */
+ void *gva; /* guest virtual address */
+ vm_paddr_t hpa; /* host physical address */
+ void *hva; /* guest virtual address */
+ vm_paddr_t len;
+};
+
+struct passthru_softc;
+
+struct passthru_dev {
+ int (*probe)(struct pci_devinst *pi);
+ int (*init)(struct pci_devinst *pi, nvlist_t *nvl);
+ void (*deinit)(struct pci_devinst *pi);
+};
+#define PASSTHRU_DEV_SET(x) DATA_SET(passthru_dev_set, x)
+
+typedef int (*cfgread_handler)(struct passthru_softc *sc,
+ struct pci_devinst *pi, int coff, int bytes, uint32_t *rv);
+typedef int (*cfgwrite_handler)(struct passthru_softc *sc,
+ struct pci_devinst *pi, int coff, int bytes, uint32_t val);
+
+uint32_t pci_host_read_config(const struct pcisel *sel, long reg, int width);
+void pci_host_write_config(const struct pcisel *sel, long reg, int width,
+ uint32_t data);
+
+int passthru_cfgread_emulate(struct passthru_softc *sc, struct pci_devinst *pi,
+ int coff, int bytes, uint32_t *rv);
+int passthru_cfgwrite_emulate(struct passthru_softc *sc, struct pci_devinst *pi,
+ int coff, int bytes, uint32_t val);
+struct passthru_mmio_mapping *passthru_get_mmio(struct passthru_softc *sc,
+ int num);
+struct pcisel *passthru_get_sel(struct passthru_softc *sc);
+int set_pcir_handler(struct passthru_softc *sc, int reg, int len,
+ cfgread_handler rhandler, cfgwrite_handler whandler);
diff --git a/usr.sbin/bhyve/pci_uart.c b/usr.sbin/bhyve/pci_uart.c
index 25ef1ed66217..f0f05c731a18 100644
--- a/usr.sbin/bhyve/pci_uart.c
+++ b/usr.sbin/bhyve/pci_uart.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/types.h>
#include <stdio.h>
@@ -66,26 +61,24 @@ pci_uart_intr_deassert(void *arg)
}
static void
-pci_uart_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size, uint64_t value)
+pci_uart_write(struct pci_devinst *pi, int baridx, uint64_t offset, int size,
+ uint64_t value)
{
-
assert(baridx == 0);
assert(size == 1);
- uart_write(pi->pi_arg, offset, value);
+ uart_ns16550_write(pi->pi_arg, offset, value);
}
-uint64_t
-pci_uart_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size)
+static uint64_t
+pci_uart_read(struct pci_devinst *pi, int baridx, uint64_t offset, int size)
{
uint8_t val;
assert(baridx == 0);
assert(size == 1);
- val = uart_read(pi->pi_arg, offset);
+ val = uart_ns16550_read(pi->pi_arg, offset);
return (val);
}
@@ -99,12 +92,12 @@ pci_uart_legacy_config(nvlist_t *nvl, const char *opts)
}
static int
-pci_uart_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_uart_init(struct pci_devinst *pi, nvlist_t *nvl)
{
- struct uart_softc *sc;
+ struct uart_ns16550_softc *sc;
const char *device;
- pci_emul_alloc_bar(pi, 0, PCIBAR_IO, UART_IO_BAR_SIZE);
+ pci_emul_alloc_bar(pi, 0, PCIBAR_IO, UART_NS16550_IO_BAR_SIZE);
pci_lintr_request(pi);
/* initialize config space */
@@ -112,11 +105,12 @@ pci_uart_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
pci_set_cfgdata16(pi, PCIR_VENDOR, COM_VENDOR);
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_SIMPLECOMM);
- sc = uart_init(pci_uart_intr_assert, pci_uart_intr_deassert, pi);
+ sc = uart_ns16550_init(pci_uart_intr_assert, pci_uart_intr_deassert,
+ pi);
pi->pi_arg = sc;
device = get_config_value_node(nvl, "path");
- if (uart_set_backend(sc, device) != 0) {
+ if (device != NULL && uart_ns16550_tty_open(sc, device) != 0) {
EPRINTLN("Unable to initialize backend '%s' for "
"pci uart at %d:%d", device, pi->pi_slot, pi->pi_func);
return (-1);
@@ -125,7 +119,7 @@ pci_uart_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
return (0);
}
-struct pci_devemu pci_de_com = {
+static const struct pci_devemu pci_de_com = {
.pe_emu = "uart",
.pe_init = pci_uart_init,
.pe_legacy_config = pci_uart_legacy_config,
diff --git a/usr.sbin/bhyve/pci_virtio_9p.c b/usr.sbin/bhyve/pci_virtio_9p.c
index 3ec7eaa06c39..3db7c86e0eb2 100644
--- a/usr.sbin/bhyve/pci_virtio_9p.c
+++ b/usr.sbin/bhyve/pci_virtio_9p.c
@@ -30,9 +30,6 @@
* VirtIO filesystem passthrough using 9p protocol.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/linker_set.h>
#include <sys/uio.h>
@@ -105,18 +102,16 @@ static int pci_vt9p_cfgread(void *, int, int, uint32_t *);
static void pci_vt9p_neg_features(void *, uint64_t);
static struct virtio_consts vt9p_vi_consts = {
- "vt9p", /* our name */
- 1, /* we support 1 virtqueue */
- VT9P_CONFIGSPACESZ, /* config reg size */
- pci_vt9p_reset, /* reset */
- pci_vt9p_notify, /* device-wide qnotify */
- pci_vt9p_cfgread, /* read virtio config */
- NULL, /* write virtio config */
- pci_vt9p_neg_features, /* apply negotiated features */
- (1 << 0), /* our capabilities */
+ .vc_name = "vt9p",
+ .vc_nvq = 1,
+ .vc_cfgsize = VT9P_CONFIGSPACESZ,
+ .vc_reset = pci_vt9p_reset,
+ .vc_qnotify = pci_vt9p_notify,
+ .vc_cfgread = pci_vt9p_cfgread,
+ .vc_apply_features = pci_vt9p_neg_features,
+ .vc_hv_caps = (1 << 0),
};
-
static void
pci_vt9p_reset(void *vsc)
{
@@ -149,7 +144,7 @@ pci_vt9p_cfgread(void *vsc, int offset, int size, uint32_t *retval)
static int
pci_vt9p_get_buffer(struct l9p_request *req, struct iovec *iov, size_t *niov,
- void *arg)
+ void *arg __unused)
{
struct pci_vt9p_request *preq = req->lr_aux;
size_t n = preq->vsr_niov - preq->vsr_respidx;
@@ -161,8 +156,8 @@ pci_vt9p_get_buffer(struct l9p_request *req, struct iovec *iov, size_t *niov,
}
static int
-pci_vt9p_send(struct l9p_request *req, const struct iovec *iov,
- const size_t niov, const size_t iolen, void *arg)
+pci_vt9p_send(struct l9p_request *req, const struct iovec *iov __unused,
+ const size_t niov __unused, const size_t iolen, void *arg __unused)
{
struct pci_vt9p_request *preq = req->lr_aux;
struct pci_vt9p_softc *sc = preq->vsr_sc;
@@ -178,8 +173,8 @@ pci_vt9p_send(struct l9p_request *req, const struct iovec *iov,
}
static void
-pci_vt9p_drop(struct l9p_request *req, const struct iovec *iov, size_t niov,
- void *arg)
+pci_vt9p_drop(struct l9p_request *req, const struct iovec *iov __unused,
+ size_t niov __unused, void *arg __unused)
{
struct pci_vt9p_request *preq = req->lr_aux;
struct pci_vt9p_softc *sc = preq->vsr_sc;
@@ -250,7 +245,7 @@ pci_vt9p_legacy_config(nvlist_t *nvl, const char *opts)
}
static int
-pci_vt9p_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_vt9p_init(struct pci_devinst *pi, nvlist_t *nvl)
{
struct pci_vt9p_softc *sc;
const char *value;
@@ -343,7 +338,7 @@ pci_vt9p_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
return (0);
}
-struct pci_devemu pci_de_v9p = {
+static const struct pci_devemu pci_de_v9p = {
.pe_emu = "virtio-9p",
.pe_legacy_config = pci_vt9p_legacy_config,
.pe_init = pci_vt9p_init,
diff --git a/usr.sbin/bhyve/pci_virtio_block.c b/usr.sbin/bhyve/pci_virtio_block.c
index 385b812be84c..ff1920600ae5 100644
--- a/usr.sbin/bhyve/pci_virtio_block.c
+++ b/usr.sbin/bhyve/pci_virtio_block.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -25,13 +25,8 @@
* 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 <sys/param.h>
#include <sys/linker_set.h>
#include <sys/stat.h>
@@ -208,19 +203,19 @@ static int pci_vtblk_snapshot(void *, struct vm_snapshot_meta *);
#endif
static struct virtio_consts vtblk_vi_consts = {
- "vtblk", /* our name */
- 1, /* we support 1 virtqueue */
- sizeof(struct vtblk_config), /* config reg size */
- pci_vtblk_reset, /* reset */
- pci_vtblk_notify, /* device-wide qnotify */
- pci_vtblk_cfgread, /* read PCI config */
- pci_vtblk_cfgwrite, /* write PCI config */
- NULL, /* apply negotiated features */
- VTBLK_S_HOSTCAPS, /* our capabilities */
+ .vc_name = "vtblk",
+ .vc_nvq = 1,
+ .vc_cfgsize = sizeof(struct vtblk_config),
+ .vc_reset = pci_vtblk_reset,
+ .vc_qnotify = pci_vtblk_notify,
+ .vc_cfgread = pci_vtblk_cfgread,
+ .vc_cfgwrite = pci_vtblk_cfgwrite,
+ .vc_apply_features = NULL,
+ .vc_hv_caps = VTBLK_S_HOSTCAPS,
#ifdef BHYVE_SNAPSHOT
- pci_vtblk_pause, /* pause blockif threads */
- pci_vtblk_resume, /* resume blockif threads */
- pci_vtblk_snapshot, /* save / restore device state */
+ .vc_pause = pci_vtblk_pause,
+ .vc_resume = pci_vtblk_resume,
+ .vc_snapshot = pci_vtblk_snapshot,
#endif
};
@@ -437,7 +432,8 @@ pci_vtblk_notify(void *vsc, struct vqueue_info *vq)
}
static void
-pci_vtblk_resized(struct blockif_ctxt *bctxt, void *arg, size_t new_size)
+pci_vtblk_resized(struct blockif_ctxt *bctxt __unused, void *arg,
+ size_t new_size)
{
struct pci_vtblk_softc *sc;
@@ -449,9 +445,9 @@ pci_vtblk_resized(struct blockif_ctxt *bctxt, void *arg, size_t new_size)
}
static int
-pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_vtblk_init(struct pci_devinst *pi, nvlist_t *nvl)
{
- char bident[sizeof("XX:X:X")];
+ char bident[sizeof("XXX:XXX")];
struct blockif_ctxt *bctxt;
const char *path, *serial;
MD5_CTX mdctx;
@@ -463,13 +459,18 @@ pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
/*
* The supplied backing file has to exist
*/
- snprintf(bident, sizeof(bident), "%d:%d", pi->pi_slot, pi->pi_func);
+ snprintf(bident, sizeof(bident), "%u:%u", pi->pi_slot, pi->pi_func);
bctxt = blockif_open(nvl, bident);
if (bctxt == NULL) {
perror("Could not open backing file");
return (1);
}
+ if (blockif_add_boot_device(pi, bctxt)) {
+ perror("Invalid boot device");
+ return (1);
+ }
+
size = blockif_size(bctxt);
sectsz = blockif_sectsz(bctxt);
blockif_psectsz(bctxt, &sts, &sto);
@@ -565,7 +566,8 @@ pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
}
static int
-pci_vtblk_cfgwrite(void *vsc, int offset, int size, uint32_t value)
+pci_vtblk_cfgwrite(void *vsc __unused, int offset, int size __unused,
+ uint32_t value __unused)
{
DPRINTF(("vtblk: write to readonly reg %d", offset));
@@ -584,7 +586,7 @@ pci_vtblk_cfgread(void *vsc, int offset, int size, uint32_t *retval)
return (0);
}
-struct pci_devemu pci_de_vblk = {
+static const struct pci_devemu pci_de_vblk = {
.pe_emu = "virtio-blk",
.pe_init = pci_vtblk_init,
.pe_legacy_config = blockif_legacy_config,
@@ -592,6 +594,8 @@ struct pci_devemu pci_de_vblk = {
.pe_barread = vi_pci_read,
#ifdef BHYVE_SNAPSHOT
.pe_snapshot = vi_pci_snapshot,
+ .pe_pause = vi_pci_pause,
+ .pe_resume = vi_pci_resume,
#endif
};
PCI_EMUL_SET(pci_de_vblk);
diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c
index 8bac2a24bba0..921cb29032cf 100644
--- a/usr.sbin/bhyve/pci_virtio_console.c
+++ b/usr.sbin/bhyve/pci_virtio_console.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 iXsystems Inc.
* All rights reserved.
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
@@ -169,18 +166,16 @@ static void pci_vtcon_announce_port(struct pci_vtcon_port *);
static void pci_vtcon_open_port(struct pci_vtcon_port *, bool);
static struct virtio_consts vtcon_vi_consts = {
- "vtcon", /* our name */
- VTCON_MAXQ, /* we support VTCON_MAXQ virtqueues */
- sizeof(struct pci_vtcon_config), /* config reg size */
- pci_vtcon_reset, /* reset */
- NULL, /* device-wide qnotify */
- pci_vtcon_cfgread, /* read virtio config */
- pci_vtcon_cfgwrite, /* write virtio config */
- pci_vtcon_neg_features, /* apply negotiated features */
- VTCON_S_HOSTCAPS, /* our capabilities */
+ .vc_name = "vtcon",
+ .vc_nvq = VTCON_MAXQ,
+ .vc_cfgsize = sizeof(struct pci_vtcon_config),
+ .vc_reset = pci_vtcon_reset,
+ .vc_cfgread = pci_vtcon_cfgread,
+ .vc_cfgwrite = pci_vtcon_cfgwrite,
+ .vc_apply_features = pci_vtcon_neg_features,
+ .vc_hv_caps = VTCON_S_HOSTCAPS,
};
-
static void
pci_vtcon_reset(void *vsc)
{
@@ -212,9 +207,9 @@ pci_vtcon_cfgread(void *vsc, int offset, int size, uint32_t *retval)
}
static int
-pci_vtcon_cfgwrite(void *vsc, int offset, int size, uint32_t val)
+pci_vtcon_cfgwrite(void *vsc __unused, int offset __unused, int size __unused,
+ uint32_t val __unused)
{
-
return (0);
}
@@ -275,7 +270,7 @@ static int
pci_vtcon_sock_add(struct pci_vtcon_softc *sc, const char *port_name,
const nvlist_t *nvl)
{
- struct pci_vtcon_sock *sock;
+ struct pci_vtcon_sock *sock = NULL;
struct sockaddr_un sun;
const char *name, *path;
char *cp, *pathcopy;
@@ -466,8 +461,8 @@ close:
}
static void
-pci_vtcon_sock_tx(struct pci_vtcon_port *port, void *arg, struct iovec *iov,
- int niov)
+pci_vtcon_sock_tx(struct pci_vtcon_port *port __unused, void *arg __unused,
+ struct iovec *iov, int niov)
{
struct pci_vtcon_sock *sock;
int i, ret;
@@ -492,8 +487,8 @@ pci_vtcon_sock_tx(struct pci_vtcon_port *port, void *arg, struct iovec *iov,
}
static void
-pci_vtcon_control_tx(struct pci_vtcon_port *port, void *arg, struct iovec *iov,
- int niov)
+pci_vtcon_control_tx(struct pci_vtcon_port *port, void *arg __unused,
+ struct iovec *iov, int niov)
{
struct pci_vtcon_softc *sc;
struct pci_vtcon_port *tmp;
@@ -587,8 +582,8 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc,
memcpy(iov.iov_base, ctrl, sizeof(struct pci_vtcon_control));
if (payload != NULL && len > 0)
- memcpy(iov.iov_base + sizeof(struct pci_vtcon_control),
- payload, len);
+ memcpy((uint8_t *)iov.iov_base +
+ sizeof(struct pci_vtcon_control), payload, len);
vq_relchain(vq, req.idx, sizeof(struct pci_vtcon_control) + len);
vq_endchains(vq, 1);
@@ -686,7 +681,7 @@ pci_vtcon_legacy_config(nvlist_t *nvl, const char *opts)
}
static int
-pci_vtcon_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_vtcon_init(struct pci_devinst *pi, nvlist_t *nvl)
{
struct pci_vtcon_softc *sc;
nvlist_t *ports_nvl;
@@ -752,7 +747,7 @@ pci_vtcon_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
return (0);
}
-struct pci_devemu pci_de_vcon = {
+static const struct pci_devemu pci_de_vcon = {
.pe_emu = "virtio-console",
.pe_init = pci_vtcon_init,
.pe_barwrite = vi_pci_write,
diff --git a/usr.sbin/bhyve/pci_virtio_input.c b/usr.sbin/bhyve/pci_virtio_input.c
index 4517333b1603..2da773df90be 100644
--- a/usr.sbin/bhyve/pci_virtio_input.c
+++ b/usr.sbin/bhyve/pci_virtio_input.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG
* All rights reserved.
@@ -31,9 +31,6 @@
* virtio input device emulation.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
@@ -159,15 +156,13 @@ static int pci_vtinput_cfgread(void *, int, int, uint32_t *);
static int pci_vtinput_cfgwrite(void *, int, int, uint32_t);
static struct virtio_consts vtinput_vi_consts = {
- "vtinput", /* our name */
- VTINPUT_MAXQ, /* we support 1 virtqueue */
- sizeof(struct vtinput_config), /* config reg size */
- pci_vtinput_reset, /* reset */
- NULL, /* device-wide qnotify -- not used */
- pci_vtinput_cfgread, /* read virtio config */
- pci_vtinput_cfgwrite, /* write virtio config */
- NULL, /* apply negotiated features */
- 0, /* our capabilities */
+ .vc_name = "vtinput",
+ .vc_nvq = VTINPUT_MAXQ,
+ .vc_cfgsize = sizeof(struct vtinput_config),
+ .vc_reset = pci_vtinput_reset,
+ .vc_cfgread = pci_vtinput_cfgread,
+ .vc_cfgwrite = pci_vtinput_cfgwrite,
+ .vc_hv_caps = 0,
};
static void
@@ -180,7 +175,7 @@ pci_vtinput_reset(void *vsc)
}
static void
-pci_vtinput_notify_eventq(void *vsc, struct vqueue_info *vq)
+pci_vtinput_notify_eventq(void *vsc __unused, struct vqueue_info *vq __unused)
{
DPRINTF(("%s", __func__));
}
@@ -423,7 +418,7 @@ pci_vtinput_cfgread(void *vsc, int offset, int size, uint32_t *retval)
struct pci_vtinput_softc *sc = vsc;
/* check for valid offset and size */
- if (offset + size > sizeof(struct vtinput_config)) {
+ if (offset + size > (int)sizeof(struct vtinput_config)) {
WPRINTF(("%s: read to invalid offset/size %d/%d", __func__,
offset, size));
memset(retval, 0, size);
@@ -476,15 +471,14 @@ vtinput_eventqueue_add_event(
if (queue->idx >= queue->size) {
/* alloc new elements for queue */
const uint32_t newSize = queue->idx;
- const void *newPtr = realloc(queue->events,
+ void *newPtr = realloc(queue->events,
queue->size * sizeof(struct vtinput_event_elem));
if (newPtr == NULL) {
WPRINTF(("%s: realloc memory for eventqueue failed!",
__func__));
return (1);
}
- /* save new size and eventqueue */
- queue->events = (struct vtinput_event_elem *)newPtr;
+ queue->events = newPtr;
queue->size = newSize;
}
@@ -570,8 +564,6 @@ done:
/* clear queue and send interrupt to guest */
vtinput_eventqueue_clear(queue);
vq_endchains(vq, 1);
-
- return;
}
static int
@@ -641,7 +633,7 @@ pci_vtinput_legacy_config(nvlist_t *nvl, const char *opts)
}
static int
-pci_vtinput_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_vtinput_init(struct pci_devinst *pi, nvlist_t *nvl)
{
struct pci_vtinput_softc *sc;
@@ -772,7 +764,7 @@ failed:
return (-1);
}
-struct pci_devemu pci_de_vinput = {
+static const struct pci_devemu pci_de_vinput = {
.pe_emu = "virtio-input",
.pe_init = pci_vtinput_init,
.pe_legacy_config = pci_vtinput_legacy_config,
diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c
index 9d3c8aa6d541..20977e90d32f 100644
--- a/usr.sbin/bhyve/pci_virtio_net.c
+++ b/usr.sbin/bhyve/pci_virtio_net.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/param.h>
#include <sys/linker_set.h>
#include <sys/select.h>
@@ -145,19 +140,18 @@ static int pci_vtnet_snapshot(void *, struct vm_snapshot_meta *);
#endif
static struct virtio_consts vtnet_vi_consts = {
- "vtnet", /* our name */
- VTNET_MAXQ - 1, /* we currently support 2 virtqueues */
- sizeof(struct virtio_net_config), /* config reg size */
- pci_vtnet_reset, /* reset */
- NULL, /* device-wide qnotify -- not used */
- pci_vtnet_cfgread, /* read PCI config */
- pci_vtnet_cfgwrite, /* write PCI config */
- pci_vtnet_neg_features, /* apply negotiated features */
- VTNET_S_HOSTCAPS, /* our capabilities */
+ .vc_name = "vtnet",
+ .vc_nvq = VTNET_MAXQ - 1,
+ .vc_cfgsize = sizeof(struct virtio_net_config),
+ .vc_reset = pci_vtnet_reset,
+ .vc_cfgread = pci_vtnet_cfgread,
+ .vc_cfgwrite = pci_vtnet_cfgwrite,
+ .vc_apply_features = pci_vtnet_neg_features,
+ .vc_hv_caps = VTNET_S_HOSTCAPS,
#ifdef BHYVE_SNAPSHOT
- pci_vtnet_pause, /* pause rx/tx threads */
- pci_vtnet_resume, /* resume rx/tx threads */
- pci_vtnet_snapshot, /* save / restore device state */
+ .vc_pause = pci_vtnet_pause,
+ .vc_resume = pci_vtnet_resume,
+ .vc_snapshot = pci_vtnet_snapshot,
#endif
};
@@ -400,7 +394,7 @@ pci_vtnet_rx(struct pci_vtnet_softc *sc)
* an entire ethernet frame + rx header.
*/
static void
-pci_vtnet_rx_callback(int fd, enum ev_type type, void *param)
+pci_vtnet_rx_callback(int fd __unused, enum ev_type type __unused, void *param)
{
struct pci_vtnet_softc *sc = param;
@@ -561,7 +555,7 @@ pci_vtnet_ping_ctlq(void *vsc, struct vqueue_info *vq)
#endif
static int
-pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_vtnet_init(struct pci_devinst *pi, nvlist_t *nvl)
{
struct pci_vtnet_softc *sc;
const char *value;
@@ -786,9 +780,11 @@ pci_vtnet_snapshot(void *vsc, struct vm_snapshot_meta *meta)
*/
SNAPSHOT_VAR_OR_LEAVE(sc->vsc_features, meta, ret, done);
+ SNAPSHOT_VAR_OR_LEAVE(sc->features_negotiated, meta, ret, done);
- /* Force reapply negociated features at restore time */
- if (meta->op == VM_SNAPSHOT_RESTORE) {
+ /* Force reapply negotiated features at restore time */
+ if (meta->op == VM_SNAPSHOT_RESTORE &&
+ sc->features_negotiated) {
pci_vtnet_neg_features(sc, sc->vsc_features);
netbe_rx_enable(sc->vsc_be);
}
@@ -804,7 +800,7 @@ done:
}
#endif
-static struct pci_devemu pci_de_vnet = {
+static const struct pci_devemu pci_de_vnet = {
.pe_emu = "virtio-net",
.pe_init = pci_vtnet_init,
.pe_legacy_config = netbe_legacy_config,
diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c
index 7023e0e03b0c..78da5d39528e 100644
--- a/usr.sbin/bhyve/pci_virtio_rnd.c
+++ b/usr.sbin/bhyve/pci_virtio_rnd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Nahanni Systems Inc.
* All rights reserved.
@@ -33,9 +33,6 @@
* once it has been seeded at bootup.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
@@ -84,18 +81,14 @@ static void pci_vtrnd_reset(void *);
static void pci_vtrnd_notify(void *, struct vqueue_info *);
static struct virtio_consts vtrnd_vi_consts = {
- "vtrnd", /* our name */
- 1, /* we support 1 virtqueue */
- 0, /* config reg size */
- pci_vtrnd_reset, /* reset */
- pci_vtrnd_notify, /* device-wide qnotify */
- NULL, /* read virtio config */
- NULL, /* write virtio config */
- NULL, /* apply negotiated features */
- 0, /* our capabilities */
+ .vc_name = "vtrnd",
+ .vc_nvq = 1,
+ .vc_cfgsize = 0,
+ .vc_reset = pci_vtrnd_reset,
+ .vc_qnotify = pci_vtrnd_notify,
+ .vc_hv_caps = 0,
};
-
static void
pci_vtrnd_reset(void *vsc)
{
@@ -144,7 +137,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq)
static int
-pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_vtrnd_init(struct pci_devinst *pi, nvlist_t *nvl __unused)
{
struct pci_vtrnd_softc *sc;
int fd;
@@ -204,7 +197,7 @@ pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
}
-struct pci_devemu pci_de_vrnd = {
+static const struct pci_devemu pci_de_vrnd = {
.pe_emu = "virtio-rnd",
.pe_init = pci_vtrnd_init,
.pe_barwrite = vi_pci_write,
diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c
index 6f00f5881198..409e8c1c21ae 100644
--- a/usr.sbin/bhyve/pci_virtio_scsi.c
+++ b/usr.sbin/bhyve/pci_virtio_scsi.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 Jakub Klama <jceel@FreeBSD.org>.
* Copyright (c) 2018 Marcelo Araujo <araujo@FreeBSD.org>.
@@ -28,9 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/linker_set.h>
#include <sys/types.h>
@@ -88,8 +85,8 @@ __FBSDID("$FreeBSD$");
#define VIRTIO_SCSI_F_CHANGE (1 << 2)
static int pci_vtscsi_debug = 0;
-#define DPRINTF(params) if (pci_vtscsi_debug) PRINTLN params
-#define WPRINTF(params) PRINTLN params
+#define WPRINTF(msg, params...) PRINTLN("virtio-scsi: " msg, ##params)
+#define DPRINTF(msg, params...) if (pci_vtscsi_debug) WPRINTF(msg, ##params)
struct pci_vtscsi_config {
uint32_t num_queues;
@@ -245,18 +242,17 @@ static void pci_vtscsi_eventq_notify(void *, struct vqueue_info *);
static void pci_vtscsi_requestq_notify(void *, struct vqueue_info *);
static int pci_vtscsi_init_queue(struct pci_vtscsi_softc *,
struct pci_vtscsi_queue *, int);
-static int pci_vtscsi_init(struct vmctx *, struct pci_devinst *, nvlist_t *);
+static int pci_vtscsi_init(struct pci_devinst *, nvlist_t *);
static struct virtio_consts vtscsi_vi_consts = {
- "vtscsi", /* our name */
- VTSCSI_MAXQ, /* we support 2+n virtqueues */
- sizeof(struct pci_vtscsi_config), /* config reg size */
- pci_vtscsi_reset, /* reset */
- NULL, /* device-wide qnotify */
- pci_vtscsi_cfgread, /* read virtio config */
- pci_vtscsi_cfgwrite, /* write virtio config */
- pci_vtscsi_neg_features, /* apply negotiated features */
- 0, /* our capabilities */
+ .vc_name = "vtscsi",
+ .vc_nvq = VTSCSI_MAXQ,
+ .vc_cfgsize = sizeof(struct pci_vtscsi_config),
+ .vc_reset = pci_vtscsi_reset,
+ .vc_cfgread = pci_vtscsi_cfgread,
+ .vc_cfgwrite = pci_vtscsi_cfgwrite,
+ .vc_apply_features = pci_vtscsi_neg_features,
+ .vc_hv_caps = 0,
};
static void *
@@ -289,8 +285,7 @@ pci_vtscsi_proc(void *arg)
vq_endchains(q->vsq_vq, 0);
pthread_mutex_unlock(&q->vsq_qmtx);
- DPRINTF(("virtio-scsi: request <idx=%d> completed",
- req->vsr_idx));
+ DPRINTF("request <idx=%d> completed", req->vsr_idx);
free(req);
}
@@ -305,7 +300,7 @@ pci_vtscsi_reset(void *vsc)
sc = vsc;
- DPRINTF(("vtscsi: device reset requested"));
+ DPRINTF("device reset requested");
vi_reset_dev(&sc->vss_vs);
/* initialize config structure */
@@ -344,9 +339,9 @@ pci_vtscsi_cfgread(void *vsc, int offset, int size, uint32_t *retval)
}
static int
-pci_vtscsi_cfgwrite(void *vsc, int offset, int size, uint32_t val)
+pci_vtscsi_cfgwrite(void *vsc __unused, int offset __unused, int size __unused,
+ uint32_t val __unused)
{
-
return (0);
}
@@ -365,14 +360,27 @@ pci_vtscsi_control_handle(struct pci_vtscsi_softc *sc, void *buf,
struct pci_vtscsi_ctrl_an *an;
uint32_t type;
+ if (bufsize < sizeof(uint32_t)) {
+ WPRINTF("ignoring truncated control request");
+ return (0);
+ }
+
type = *(uint32_t *)buf;
if (type == VIRTIO_SCSI_T_TMF) {
+ if (bufsize != sizeof(*tmf)) {
+ WPRINTF("ignoring tmf request with size %zu", bufsize);
+ return (0);
+ }
tmf = (struct pci_vtscsi_ctrl_tmf *)buf;
return (pci_vtscsi_tmf_handle(sc, tmf));
}
if (type == VIRTIO_SCSI_T_AN_QUERY) {
+ if (bufsize != sizeof(*an)) {
+ WPRINTF("ignoring AN request with size %zu", bufsize);
+ return (0);
+ }
an = (struct pci_vtscsi_ctrl_an *)buf;
return (pci_vtscsi_an_handle(sc, an));
}
@@ -394,7 +402,8 @@ pci_vtscsi_tmf_handle(struct pci_vtscsi_softc *sc,
io->io_hdr.nexus.initid = sc->vss_iid;
io->io_hdr.nexus.targ_lun = pci_vtscsi_get_lun(tmf->lun);
io->taskio.tag_type = CTL_TAG_SIMPLE;
- io->taskio.tag_num = (uint32_t)tmf->id;
+ io->taskio.tag_num = tmf->id;
+ io->io_hdr.flags |= CTL_FLAG_USER_TAG;
switch (tmf->subtype) {
case VIRTIO_SCSI_T_TMF_ABORT_TASK:
@@ -434,13 +443,13 @@ pci_vtscsi_tmf_handle(struct pci_vtscsi_softc *sc,
struct sbuf *sb = sbuf_new_auto();
ctl_io_sbuf(io, sb);
sbuf_finish(sb);
- DPRINTF(("pci_virtio_scsi: %s", sbuf_data(sb)));
+ DPRINTF("%s", sbuf_data(sb));
sbuf_delete(sb);
}
err = ioctl(sc->vss_ctl_fd, CTL_IO, io);
if (err != 0)
- WPRINTF(("CTL_IO: err=%d (%s)", errno, strerror(errno)));
+ WPRINTF("CTL_IO: err=%d (%s)", errno, strerror(errno));
tmf->response = io->taskio.task_status;
ctl_scsi_free_io(io);
@@ -448,10 +457,9 @@ pci_vtscsi_tmf_handle(struct pci_vtscsi_softc *sc,
}
static int
-pci_vtscsi_an_handle(struct pci_vtscsi_softc *sc,
- struct pci_vtscsi_ctrl_an *an)
+pci_vtscsi_an_handle(struct pci_vtscsi_softc *sc __unused,
+ struct pci_vtscsi_ctrl_an *an __unused)
{
-
return (0);
}
@@ -469,6 +477,15 @@ pci_vtscsi_request_handle(struct pci_vtscsi_queue *q, struct iovec *iov_in,
uint32_t ext_data_len = 0, ext_sg_entries = 0;
int err, nxferred;
+ if (count_iov(iov_out, niov_out) < VTSCSI_OUT_HEADER_LEN(sc)) {
+ WPRINTF("ignoring request with insufficient output");
+ return (0);
+ }
+ if (count_iov(iov_in, niov_in) < VTSCSI_IN_HEADER_LEN(sc)) {
+ WPRINTF("ignoring request with incomplete header");
+ return (0);
+ }
+
seek_iov(iov_in, niov_in, data_iov_in, &data_niov_in,
VTSCSI_IN_HEADER_LEN(sc));
seek_iov(iov_out, niov_out, data_iov_out, &data_niov_out,
@@ -478,7 +495,7 @@ pci_vtscsi_request_handle(struct pci_vtscsi_queue *q, struct iovec *iov_in,
truncate_iov(iov_out, &niov_out, VTSCSI_OUT_HEADER_LEN(sc));
iov_to_buf(iov_in, niov_in, (void **)&cmd_rd);
- cmd_wr = malloc(VTSCSI_OUT_HEADER_LEN(sc));
+ cmd_wr = calloc(1, VTSCSI_OUT_HEADER_LEN(sc));
io = ctl_scsi_alloc_io(sc->vss_iid);
ctl_scsi_zero_io(io);
@@ -500,7 +517,8 @@ pci_vtscsi_request_handle(struct pci_vtscsi_queue *q, struct iovec *iov_in,
}
io->scsiio.sense_len = sc->vss_config.sense_size;
- io->scsiio.tag_num = (uint32_t)cmd_rd->id;
+ io->scsiio.tag_num = cmd_rd->id;
+ io->io_hdr.flags |= CTL_FLAG_USER_TAG;
switch (cmd_rd->task_attr) {
case VIRTIO_SCSI_S_ORDERED:
io->scsiio.tag_type = CTL_TAG_ORDERED;
@@ -527,18 +545,18 @@ pci_vtscsi_request_handle(struct pci_vtscsi_queue *q, struct iovec *iov_in,
struct sbuf *sb = sbuf_new_auto();
ctl_io_sbuf(io, sb);
sbuf_finish(sb);
- DPRINTF(("pci_virtio_scsi: %s", sbuf_data(sb)));
+ DPRINTF("%s", sbuf_data(sb));
sbuf_delete(sb);
}
err = ioctl(sc->vss_ctl_fd, CTL_IO, io);
if (err != 0) {
- WPRINTF(("CTL_IO: err=%d (%s)", errno, strerror(errno)));
+ WPRINTF("CTL_IO: err=%d (%s)", errno, strerror(errno));
cmd_wr->response = VIRTIO_SCSI_S_FAILURE;
} else {
cmd_wr->sense_len = MIN(io->scsiio.sense_len,
sc->vss_config.sense_size);
- cmd_wr->residual = io->scsiio.residual;
+ cmd_wr->residual = ext_data_len - io->scsiio.ext_data_filled;
cmd_wr->status = io->scsiio.scsi_status;
cmd_wr->response = VIRTIO_SCSI_S_OK;
memcpy(&cmd_wr->sense, &io->scsiio.sense_data,
@@ -571,7 +589,7 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq)
bufsize = iov_to_buf(iov, n, &buf);
iolen = pci_vtscsi_control_handle(sc, buf, bufsize);
- buf_to_iov(buf + bufsize - iolen, iolen, iov, n,
+ buf_to_iov((uint8_t *)buf + bufsize - iolen, iolen, iov, n,
bufsize - iolen);
/*
@@ -584,9 +602,8 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq)
}
static void
-pci_vtscsi_eventq_notify(void *vsc, struct vqueue_info *vq)
+pci_vtscsi_eventq_notify(void *vsc __unused, struct vqueue_info *vq)
{
-
vq_kick_disable(vq);
}
@@ -622,8 +639,7 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq)
pthread_cond_signal(&q->vsq_cv);
pthread_mutex_unlock(&q->vsq_mtx);
- DPRINTF(("virtio-scsi: request <idx=%d> enqueued",
- vireq.idx));
+ DPRINTF("request <idx=%d> enqueued", vireq.idx);
}
}
@@ -679,7 +695,7 @@ pci_vtscsi_legacy_config(nvlist_t *nvl, const char *opts)
}
static int
-pci_vtscsi_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_vtscsi_init(struct pci_devinst *pi, nvlist_t *nvl)
{
struct pci_vtscsi_softc *sc;
const char *devname, *value;
@@ -690,12 +706,21 @@ pci_vtscsi_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
if (value != NULL)
sc->vss_iid = strtoul(value, NULL, 10);
+ value = get_config_value_node(nvl, "bootindex");
+ if (value != NULL) {
+ if (pci_emul_add_boot_device(pi, atoi(value))) {
+ EPRINTLN("Invalid bootindex %d", atoi(value));
+ free(sc);
+ return (-1);
+ }
+ }
+
devname = get_config_value_node(nvl, "dev");
if (devname == NULL)
devname = "/dev/cam/ctl";
sc->vss_ctl_fd = open(devname, O_RDWR);
if (sc->vss_ctl_fd < 0) {
- WPRINTF(("cannot open %s: %s", devname, strerror(errno)));
+ WPRINTF("cannot open %s: %s", devname, strerror(errno));
free(sc);
return (1);
}
@@ -735,7 +760,7 @@ pci_vtscsi_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
}
-struct pci_devemu pci_de_vscsi = {
+static const struct pci_devemu pci_de_vscsi = {
.pe_emu = "virtio-scsi",
.pe_init = pci_vtscsi_init,
.pe_legacy_config = pci_vtscsi_legacy_config,
diff --git a/usr.sbin/bhyve/pci_xhci.c b/usr.sbin/bhyve/pci_xhci.c
index c3dd5d4c3601..8654dd9e7a14 100644
--- a/usr.sbin/bhyve/pci_xhci.c
+++ b/usr.sbin/bhyve/pci_xhci.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Leon Dang <ldang@nahannisys.com>
* All rights reserved.
@@ -32,8 +32,6 @@
devices:
tablet USB tablet mouse
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/uio.h>
@@ -48,8 +46,6 @@ __FBSDID("$FreeBSD$");
#include <pthread.h>
#include <unistd.h>
-#include <machine/vmm_snapshot.h>
-
#include <dev/usb/usbdi.h>
#include <dev/usb/usb.h>
#include <dev/usb/usb_freebsd.h>
@@ -60,6 +56,9 @@ __FBSDID("$FreeBSD$");
#include "debug.h"
#include "pci_emul.h"
#include "pci_xhci.h"
+#ifdef BHYVE_SNAPSHOT
+#include "snapshot.h"
+#endif
#include "usb_emul.h"
@@ -170,6 +169,13 @@ struct pci_xhci_dev_ep {
#define ep_tr _ep_trbsctx._epu_tr
#define ep_sctx _ep_trbsctx._epu_sctx
+ /*
+ * Caches the value of MaxPStreams from the endpoint context
+ * when an endpoint is initialized and is used to validate the
+ * use of ep_ringaddr vs ep_sctx_trbs[] as well as the length
+ * of ep_sctx_trbs[].
+ */
+ uint32_t ep_MaxPStreams;
union {
struct pci_xhci_trb_ring _epu_trb;
struct pci_xhci_trb_ring *_epu_sctx_trbs;
@@ -283,10 +289,10 @@ struct pci_xhci_softc {
};
-/* portregs and devices arrays are set up to start from idx=1 */
-#define XHCI_PORTREG_PTR(x,n) &(x)->portregs[(n)]
-#define XHCI_DEVINST_PTR(x,n) (x)->devices[(n)]
-#define XHCI_SLOTDEV_PTR(x,n) (x)->slots[(n)]
+/* port and slot numbering start from 1 */
+#define XHCI_PORTREG_PTR(x,n) &((x)->portregs[(n) - 1])
+#define XHCI_DEVINST_PTR(x,n) ((x)->devices[(n) - 1])
+#define XHCI_SLOTDEV_PTR(x,n) ((x)->slots[(n) - 1])
#define XHCI_HALTED(sc) ((sc)->opregs.usbsts & XHCI_STS_HCH)
@@ -561,10 +567,14 @@ pci_xhci_portregs_write(struct pci_xhci_softc *sc, uint64_t offset,
*/
p->porthlpmc = value;
break;
+ default:
+ DPRINTF(("pci_xhci: unaligned portreg write offset %#lx",
+ offset));
+ break;
}
}
-struct xhci_dev_ctx *
+static struct xhci_dev_ctx *
pci_xhci_get_dev_ctx(struct pci_xhci_softc *sc, uint32_t slot)
{
uint64_t devctx_addr;
@@ -588,7 +598,7 @@ pci_xhci_get_dev_ctx(struct pci_xhci_softc *sc, uint32_t slot)
return (devctx);
}
-struct xhci_trb *
+static struct xhci_trb *
pci_xhci_trb_next(struct pci_xhci_softc *sc, struct xhci_trb *curtrb,
uint64_t *guestaddr)
{
@@ -643,8 +653,7 @@ pci_xhci_init_ep(struct pci_xhci_dev_emu *dev, int epid)
struct xhci_dev_ctx *dev_ctx;
struct pci_xhci_dev_ep *devep;
struct xhci_endp_ctx *ep_ctx;
- uint32_t pstreams;
- int i;
+ uint32_t i, pstreams;
dev_ctx = dev->dev_ctx;
ep_ctx = &dev_ctx->ctx_ep[epid];
@@ -673,6 +682,7 @@ pci_xhci_init_ep(struct pci_xhci_dev_emu *dev, int epid)
devep->ep_tr = XHCI_GADDR(dev->xsc, devep->ep_ringaddr);
DPRINTF(("init_ep tr DCS %x", devep->ep_ccs));
}
+ devep->ep_MaxPStreams = pstreams;
if (devep->ep_xfer == NULL) {
devep->ep_xfer = malloc(sizeof(struct usb_data_xfer));
@@ -694,9 +704,8 @@ pci_xhci_disable_ep(struct pci_xhci_dev_emu *dev, int epid)
ep_ctx->dwEpCtx0 = (ep_ctx->dwEpCtx0 & ~0x7) | XHCI_ST_EPCTX_DISABLED;
devep = &dev->eps[epid];
- if (XHCI_EPCTX_0_MAXP_STREAMS_GET(ep_ctx->dwEpCtx0) > 0 &&
- devep->ep_sctx_trbs != NULL)
- free(devep->ep_sctx_trbs);
+ if (devep->ep_MaxPStreams > 0)
+ free(devep->ep_sctx_trbs);
if (devep->ep_xfer != NULL) {
free(devep->ep_xfer);
@@ -1156,7 +1165,7 @@ pci_xhci_cmd_reset_ep(struct pci_xhci_softc *sc, uint32_t slot,
ep_ctx->dwEpCtx0 = (ep_ctx->dwEpCtx0 & ~0x7) | XHCI_ST_EPCTX_STOPPED;
- if (XHCI_EPCTX_0_MAXP_STREAMS_GET(ep_ctx->dwEpCtx0) == 0)
+ if (devep->ep_MaxPStreams == 0)
ep_ctx->qwEpCtx2 = devep->ep_ringaddr | devep->ep_ccs;
DPRINTF(("pci_xhci: reset ep[%u] %08x %08x %016lx %08x",
@@ -1177,16 +1186,14 @@ done:
static uint32_t
pci_xhci_find_stream(struct pci_xhci_softc *sc, struct xhci_endp_ctx *ep,
- uint32_t streamid, struct xhci_stream_ctx **osctx)
+ struct pci_xhci_dev_ep *devep, uint32_t streamid)
{
struct xhci_stream_ctx *sctx;
- uint32_t maxpstreams;
- maxpstreams = XHCI_EPCTX_0_MAXP_STREAMS_GET(ep->dwEpCtx0);
- if (maxpstreams == 0)
+ if (devep->ep_MaxPStreams == 0)
return (XHCI_TRB_ERROR_TRB);
- if (maxpstreams > XHCI_STREAMS_MAX)
+ if (devep->ep_MaxPStreams > XHCI_STREAMS_MAX)
return (XHCI_TRB_ERROR_INVALID_SID);
if (XHCI_EPCTX_0_LSA_GET(ep->dwEpCtx0) == 0) {
@@ -1195,15 +1202,14 @@ pci_xhci_find_stream(struct pci_xhci_softc *sc, struct xhci_endp_ctx *ep,
}
/* only support primary stream */
- if (streamid > maxpstreams)
+ if (streamid > devep->ep_MaxPStreams)
return (XHCI_TRB_ERROR_STREAM_TYPE);
- sctx = XHCI_GADDR(sc, ep->qwEpCtx2 & ~0xFUL) + streamid;
+ sctx = (struct xhci_stream_ctx *)XHCI_GADDR(sc, ep->qwEpCtx2 & ~0xFUL) +
+ streamid;
if (!XHCI_SCTX_0_SCT_GET(sctx->qwSctx0))
return (XHCI_TRB_ERROR_STREAM_TYPE);
- *osctx = sctx;
-
return (XHCI_TRB_ERROR_SUCCESS);
}
@@ -1257,12 +1263,9 @@ pci_xhci_cmd_set_tr(struct pci_xhci_softc *sc, uint32_t slot,
}
streamid = XHCI_TRB_2_STREAM_GET(trb->dwTrb2);
- if (XHCI_EPCTX_0_MAXP_STREAMS_GET(ep_ctx->dwEpCtx0) > 0) {
- struct xhci_stream_ctx *sctx;
-
- sctx = NULL;
- cmderr = pci_xhci_find_stream(sc, ep_ctx, streamid, &sctx);
- if (sctx != NULL) {
+ if (devep->ep_MaxPStreams > 0) {
+ cmderr = pci_xhci_find_stream(sc, ep_ctx, devep, streamid);
+ if (cmderr == XHCI_TRB_ERROR_SUCCESS) {
assert(devep->ep_sctx != NULL);
devep->ep_sctx[streamid].qwSctx0 = trb->qwTrb0;
@@ -1626,12 +1629,12 @@ pci_xhci_xfer_complete(struct pci_xhci_softc *sc, struct usb_data_xfer *xfer,
}
static void
-pci_xhci_update_ep_ring(struct pci_xhci_softc *sc, struct pci_xhci_dev_emu *dev,
- struct pci_xhci_dev_ep *devep, struct xhci_endp_ctx *ep_ctx,
- uint32_t streamid, uint64_t ringaddr, int ccs)
+pci_xhci_update_ep_ring(struct pci_xhci_softc *sc,
+ struct pci_xhci_dev_emu *dev __unused, struct pci_xhci_dev_ep *devep,
+ struct xhci_endp_ctx *ep_ctx, uint32_t streamid, uint64_t ringaddr, int ccs)
{
- if (XHCI_EPCTX_0_MAXP_STREAMS_GET(ep_ctx->dwEpCtx0) != 0) {
+ if (devep->ep_MaxPStreams != 0) {
devep->ep_sctx[streamid].qwSctx0 = (ringaddr & ~0xFUL) |
(ccs & 0x1);
@@ -1725,7 +1728,7 @@ pci_xhci_handle_transfer(struct pci_xhci_softc *sc,
DPRINTF(("pci_xhci handle_transfer slot %u", slot));
retry:
- err = 0;
+ err = XHCI_TRB_ERROR_INVALID;
do_retry = 0;
do_intr = 0;
setup_trb = NULL;
@@ -1849,24 +1852,26 @@ retry:
goto errout;
if (epid == 1) {
- err = USB_ERR_NOT_STARTED;
+ int usberr;
+
if (dev->dev_ue->ue_request != NULL)
- err = dev->dev_ue->ue_request(dev->dev_sc, xfer);
- setup_trb = NULL;
+ usberr = dev->dev_ue->ue_request(dev->dev_sc, xfer);
+ else
+ usberr = USB_ERR_NOT_STARTED;
+ err = USB_TO_XHCI_ERR(usberr);
+ if (err == XHCI_TRB_ERROR_SUCCESS ||
+ err == XHCI_TRB_ERROR_STALL ||
+ err == XHCI_TRB_ERROR_SHORT_PKT) {
+ err = pci_xhci_xfer_complete(sc, xfer, slot, epid,
+ &do_intr);
+ if (err != XHCI_TRB_ERROR_SUCCESS)
+ do_retry = 0;
+ }
+
} else {
/* handle data transfer */
pci_xhci_try_usb_xfer(sc, dev, devep, ep_ctx, slot, epid);
err = XHCI_TRB_ERROR_SUCCESS;
- goto errout;
- }
-
- err = USB_TO_XHCI_ERR(err);
- if ((err == XHCI_TRB_ERROR_SUCCESS) ||
- (err == XHCI_TRB_ERROR_STALL) ||
- (err == XHCI_TRB_ERROR_SHORT_PKT)) {
- err = pci_xhci_xfer_complete(sc, xfer, slot, epid, &do_intr);
- if (err != XHCI_TRB_ERROR_SUCCESS)
- do_retry = 0;
}
errout:
@@ -1904,6 +1909,7 @@ pci_xhci_device_doorbell(struct pci_xhci_softc *sc, uint32_t slot,
struct xhci_trb *trb;
uint64_t ringaddr;
uint32_t ccs;
+ int error;
DPRINTF(("pci_xhci doorbell slot %u epid %u stream %u",
slot, epid, streamid));
@@ -1942,9 +1948,7 @@ pci_xhci_device_doorbell(struct pci_xhci_softc *sc, uint32_t slot,
}
/* get next trb work item */
- if (XHCI_EPCTX_0_MAXP_STREAMS_GET(ep_ctx->dwEpCtx0) != 0) {
- struct xhci_stream_ctx *sctx;
-
+ if (devep->ep_MaxPStreams != 0) {
/*
* Stream IDs of 0, 65535 (any stream), and 65534
* (prime) are invalid.
@@ -1954,10 +1958,10 @@ pci_xhci_device_doorbell(struct pci_xhci_softc *sc, uint32_t slot,
return;
}
- sctx = NULL;
- pci_xhci_find_stream(sc, ep_ctx, streamid, &sctx);
- if (sctx == NULL) {
- DPRINTF(("pci_xhci: invalid stream %u", streamid));
+ error = pci_xhci_find_stream(sc, ep_ctx, devep, streamid);
+ if (error != XHCI_TRB_ERROR_SUCCESS) {
+ DPRINTF(("pci_xhci: invalid stream %u: %d",
+ streamid, error));
return;
}
sctx_tr = &devep->ep_sctx_trbs[streamid];
@@ -2100,7 +2104,7 @@ pci_xhci_rtsregs_write(struct pci_xhci_softc *sc, uint64_t offset,
if (rts->er_events_cnt > 0) {
uint64_t erdp;
- uint32_t erdp_i;
+ int erdp_i;
erdp = rts->intrreg.erdp & ~0xF;
erdp_i = (erdp - rts->erstba_p->qwEvrsTablePtr) /
@@ -2129,13 +2133,15 @@ pci_xhci_rtsregs_write(struct pci_xhci_softc *sc, uint64_t offset,
static uint64_t
pci_xhci_portregs_read(struct pci_xhci_softc *sc, uint64_t offset)
{
+ struct pci_xhci_portregs *portregs;
int port;
- uint32_t *p;
+ uint32_t reg;
if (sc->portregs == NULL)
return (0);
- port = (offset - 0x3F0) / 0x10;
+ port = (offset - XHCI_PORTREGS_PORT0) / XHCI_PORTREGS_SETSZ;
+ offset = (offset - XHCI_PORTREGS_PORT0) % XHCI_PORTREGS_SETSZ;
if (port > XHCI_MAX_DEVS) {
DPRINTF(("pci_xhci: portregs_read port %d >= XHCI_MAX_DEVS",
@@ -2145,15 +2151,31 @@ pci_xhci_portregs_read(struct pci_xhci_softc *sc, uint64_t offset)
return (XHCI_PS_SPEED_SET(3));
}
- offset = (offset - 0x3F0) % 0x10;
-
- p = &sc->portregs[port].portsc;
- p += offset / sizeof(uint32_t);
+ portregs = XHCI_PORTREG_PTR(sc, port);
+ switch (offset) {
+ case 0:
+ reg = portregs->portsc;
+ break;
+ case 4:
+ reg = portregs->portpmsc;
+ break;
+ case 8:
+ reg = portregs->portli;
+ break;
+ case 12:
+ reg = portregs->porthlpmc;
+ break;
+ default:
+ DPRINTF(("pci_xhci: unaligned portregs read offset %#lx",
+ offset));
+ reg = 0xffffffff;
+ break;
+ }
DPRINTF(("pci_xhci: portregs read offset 0x%lx port %u -> 0x%x",
- offset, port, *p));
+ offset, port, reg));
- return (*p);
+ return (reg);
}
static void
@@ -2244,8 +2266,8 @@ pci_xhci_hostop_write(struct pci_xhci_softc *sc, uint64_t offset,
static void
-pci_xhci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size, uint64_t value)
+pci_xhci_write(struct pci_devinst *pi, int baridx, uint64_t offset,
+ int size __unused, uint64_t value)
{
struct pci_xhci_softc *sc;
@@ -2378,9 +2400,9 @@ pci_xhci_hostop_read(struct pci_xhci_softc *sc, uint64_t offset)
}
static uint64_t
-pci_xhci_dbregs_read(struct pci_xhci_softc *sc, uint64_t offset)
+pci_xhci_dbregs_read(struct pci_xhci_softc *sc __unused,
+ uint64_t offset __unused)
{
-
/* read doorbell always returns 0 */
return (0);
}
@@ -2465,8 +2487,7 @@ pci_xhci_xecp_read(struct pci_xhci_softc *sc, uint64_t offset)
static uint64_t
-pci_xhci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
- uint64_t offset, int size)
+pci_xhci_read(struct pci_devinst *pi, int baridx, uint64_t offset, int size)
{
struct pci_xhci_softc *sc;
uint32_t value;
@@ -2638,9 +2659,9 @@ done:
}
static int
-pci_xhci_dev_event(struct usb_hci *hci, enum hci_usbev evid, void *param)
+pci_xhci_dev_event(struct usb_hci *hci, enum hci_usbev evid __unused,
+ void *param __unused)
{
-
DPRINTF(("xhci device event port %d", hci->hci_port));
return (0);
}
@@ -2714,10 +2735,6 @@ pci_xhci_parse_devices(struct pci_xhci_softc *sc, nvlist_t *nvl)
sc->devices = calloc(XHCI_MAX_DEVS, sizeof(struct pci_xhci_dev_emu *));
sc->slots = calloc(XHCI_MAX_SLOTS, sizeof(struct pci_xhci_dev_emu *));
- /* port and slot numbering start from 1 */
- sc->devices--;
- sc->slots--;
-
ndevices = 0;
slots_nvl = find_relative_config_node(nvl, "slot");
@@ -2811,7 +2828,6 @@ pci_xhci_parse_devices(struct pci_xhci_softc *sc, nvlist_t *nvl)
portsfinal:
sc->portregs = calloc(XHCI_MAX_DEVS, sizeof(struct pci_xhci_portregs));
- sc->portregs--;
if (ndevices > 0) {
for (i = 1; i <= XHCI_MAX_DEVS; i++) {
@@ -2827,14 +2843,14 @@ bad:
free(XHCI_DEVINST_PTR(sc, i));
}
- free(sc->devices + 1);
- free(sc->slots + 1);
+ free(sc->devices);
+ free(sc->slots);
return (-1);
}
static int
-pci_xhci_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_xhci_init(struct pci_devinst *pi, nvlist_t *nvl)
{
struct pci_xhci_softc *sc;
int error;
@@ -2949,7 +2965,7 @@ pci_xhci_map_devs_slots(struct pci_xhci_softc *sc, int maps[])
static int
pci_xhci_snapshot_ep(struct pci_xhci_softc *sc, struct pci_xhci_dev_emu *dev,
- int idx, struct vm_snapshot_meta *meta)
+ int idx, struct vm_snapshot_meta *meta)
{
int k;
int ret;
@@ -2975,9 +2991,9 @@ pci_xhci_snapshot_ep(struct pci_xhci_softc *sc, struct pci_xhci_dev_emu *dev,
for (k = 0; k < USB_MAX_XFER_BLOCKS; k++) {
xfer_block = &xfer->data[k];
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(xfer_block->buf,
- XHCI_GADDR_SIZE(xfer_block->buf), true, meta, ret,
- done);
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(sc->xsc_pi->pi_vmctx,
+ xfer_block->buf, XHCI_GADDR_SIZE(xfer_block->buf), true,
+ meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(xfer_block->blen, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(xfer_block->bdone, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(xfer_block->processed, meta, ret, done);
@@ -3042,11 +3058,11 @@ pci_xhci_snapshot(struct vm_snapshot_meta *meta)
SNAPSHOT_VAR_OR_LEAVE(sc->opregs.config, meta, ret, done);
/* opregs.cr_p */
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(sc->opregs.cr_p,
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(pi->pi_vmctx, sc->opregs.cr_p,
XHCI_GADDR_SIZE(sc->opregs.cr_p), true, meta, ret, done);
/* opregs.dcbaa_p */
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(sc->opregs.dcbaa_p,
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(pi->pi_vmctx, sc->opregs.dcbaa_p,
XHCI_GADDR_SIZE(sc->opregs.dcbaa_p), true, meta, ret, done);
/* rtsregs */
@@ -3061,11 +3077,11 @@ pci_xhci_snapshot(struct vm_snapshot_meta *meta)
SNAPSHOT_VAR_OR_LEAVE(sc->rtsregs.intrreg.erdp, meta, ret, done);
/* rtsregs.erstba_p */
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(sc->rtsregs.erstba_p,
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(pi->pi_vmctx, sc->rtsregs.erstba_p,
XHCI_GADDR_SIZE(sc->rtsregs.erstba_p), true, meta, ret, done);
/* rtsregs.erst_p */
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(sc->rtsregs.erst_p,
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(pi->pi_vmctx, sc->rtsregs.erst_p,
XHCI_GADDR_SIZE(sc->rtsregs.erst_p), true, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(sc->rtsregs.er_deq_seg, meta, ret, done);
@@ -3086,8 +3102,8 @@ pci_xhci_snapshot(struct vm_snapshot_meta *meta)
/* check if the restored device (when restoring) is sane */
if (restore_idx != i) {
- fprintf(stderr, "%s: idx not matching: actual: %d, "
- "expected: %d\r\n", __func__, restore_idx, i);
+ EPRINTLN("%s: idx not matching: actual: %d, "
+ "expected: %d", __func__, restore_idx, i);
ret = EINVAL;
goto done;
}
@@ -3102,9 +3118,9 @@ pci_xhci_snapshot(struct vm_snapshot_meta *meta)
if (meta->op == VM_SNAPSHOT_RESTORE) {
dname[sizeof(dname) - 1] = '\0';
if (strcmp(dev->dev_ue->ue_emu, dname)) {
- fprintf(stderr, "%s: device names mismatch: "
- "actual: %s, expected: %s\r\n",
- __func__, dname, dev->dev_ue->ue_emu);
+ EPRINTLN("%s: device names mismatch: "
+ "actual: %s, expected: %s",
+ __func__, dname, dev->dev_ue->ue_emu);
ret = EINVAL;
goto done;
@@ -3151,7 +3167,7 @@ pci_xhci_snapshot(struct vm_snapshot_meta *meta)
if (dev == NULL)
continue;
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(dev->dev_ctx,
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(pi->pi_vmctx, dev->dev_ctx,
XHCI_GADDR_SIZE(dev->dev_ctx), true, meta, ret, done);
if (dev->dev_ctx != NULL) {
@@ -3180,7 +3196,7 @@ done:
}
#endif
-struct pci_devemu pci_de_xhci = {
+static const struct pci_devemu pci_de_xhci = {
.pe_emu = "xhci",
.pe_init = pci_xhci_init,
.pe_legacy_config = pci_xhci_legacy_config,
diff --git a/usr.sbin/bhyve/pci_xhci.h b/usr.sbin/bhyve/pci_xhci.h
index 7502f9396abb..21cccf5c2bec 100644
--- a/usr.sbin/bhyve/pci_xhci.h
+++ b/usr.sbin/bhyve/pci_xhci.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Leon Dang <ldang@nahannisys.com>
* 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 _PCI_XHCI_H_
@@ -90,7 +88,7 @@ enum {
#define XHCI_PAGE_SIZE 4096 /* bytes */
struct xhci_slot_ctx {
- volatile uint32_t dwSctx0;
+ uint32_t dwSctx0;
#define XHCI_SCTX_0_ROUTE_SET(x) ((x) & 0xFFFFF)
#define XHCI_SCTX_0_ROUTE_GET(x) ((x) & 0xFFFFF)
#define XHCI_SCTX_0_SPEED_SET(x) (((x) & 0xF) << 20)
@@ -101,14 +99,14 @@ struct xhci_slot_ctx {
#define XHCI_SCTX_0_HUB_GET(x) (((x) >> 26) & 0x1)
#define XHCI_SCTX_0_CTX_NUM_SET(x) (((x) & 0x1F) << 27)
#define XHCI_SCTX_0_CTX_NUM_GET(x) (((x) >> 27) & 0x1F)
- volatile uint32_t dwSctx1;
+ uint32_t dwSctx1;
#define XHCI_SCTX_1_MAX_EL_SET(x) ((x) & 0xFFFF)
#define XHCI_SCTX_1_MAX_EL_GET(x) ((x) & 0xFFFF)
#define XHCI_SCTX_1_RH_PORT_SET(x) (((x) & 0xFF) << 16)
#define XHCI_SCTX_1_RH_PORT_GET(x) (((x) >> 16) & 0xFF)
#define XHCI_SCTX_1_NUM_PORTS_SET(x) (((x) & 0xFF) << 24)
#define XHCI_SCTX_1_NUM_PORTS_GET(x) (((x) >> 24) & 0xFF)
- volatile uint32_t dwSctx2;
+ uint32_t dwSctx2;
#define XHCI_SCTX_2_TT_HUB_SID_SET(x) ((x) & 0xFF)
#define XHCI_SCTX_2_TT_HUB_SID_GET(x) ((x) & 0xFF)
#define XHCI_SCTX_2_TT_PORT_NUM_SET(x) (((x) & 0xFF) << 8)
@@ -117,19 +115,19 @@ struct xhci_slot_ctx {
#define XHCI_SCTX_2_TT_THINK_TIME_GET(x) (((x) >> 16) & 0x3)
#define XHCI_SCTX_2_IRQ_TARGET_SET(x) (((x) & 0x3FF) << 22)
#define XHCI_SCTX_2_IRQ_TARGET_GET(x) (((x) >> 22) & 0x3FF)
- volatile uint32_t dwSctx3;
+ uint32_t dwSctx3;
#define XHCI_SCTX_3_DEV_ADDR_SET(x) ((x) & 0xFF)
#define XHCI_SCTX_3_DEV_ADDR_GET(x) ((x) & 0xFF)
#define XHCI_SCTX_3_SLOT_STATE_SET(x) (((x) & 0x1F) << 27)
#define XHCI_SCTX_3_SLOT_STATE_GET(x) (((x) >> 27) & 0x1F)
- volatile uint32_t dwSctx4;
- volatile uint32_t dwSctx5;
- volatile uint32_t dwSctx6;
- volatile uint32_t dwSctx7;
+ uint32_t dwSctx4;
+ uint32_t dwSctx5;
+ uint32_t dwSctx6;
+ uint32_t dwSctx7;
};
struct xhci_endp_ctx {
- volatile uint32_t dwEpCtx0;
+ uint32_t dwEpCtx0;
#define XHCI_EPCTX_0_EPSTATE_SET(x) ((x) & 0x7)
#define XHCI_EPCTX_0_EPSTATE_GET(x) ((x) & 0x7)
#define XHCI_EPCTX_0_MULT_SET(x) (((x) & 0x3) << 8)
@@ -140,7 +138,7 @@ struct xhci_endp_ctx {
#define XHCI_EPCTX_0_LSA_GET(x) (((x) >> 15) & 0x1)
#define XHCI_EPCTX_0_IVAL_SET(x) (((x) & 0xFF) << 16)
#define XHCI_EPCTX_0_IVAL_GET(x) (((x) >> 16) & 0xFF)
- volatile uint32_t dwEpCtx1;
+ uint32_t dwEpCtx1;
#define XHCI_EPCTX_1_CERR_SET(x) (((x) & 0x3) << 1)
#define XHCI_EPCTX_1_CERR_GET(x) (((x) >> 1) & 0x3)
#define XHCI_EPCTX_1_EPTYPE_SET(x) (((x) & 0x7) << 3)
@@ -151,32 +149,32 @@ struct xhci_endp_ctx {
#define XHCI_EPCTX_1_MAXB_GET(x) (((x) >> 8) & 0xFF)
#define XHCI_EPCTX_1_MAXP_SIZE_SET(x) (((x) & 0xFFFF) << 16)
#define XHCI_EPCTX_1_MAXP_SIZE_GET(x) (((x) >> 16) & 0xFFFF)
- volatile uint64_t qwEpCtx2;
+ uint64_t qwEpCtx2;
#define XHCI_EPCTX_2_DCS_SET(x) ((x) & 0x1)
#define XHCI_EPCTX_2_DCS_GET(x) ((x) & 0x1)
#define XHCI_EPCTX_2_TR_DQ_PTR_MASK 0xFFFFFFFFFFFFFFF0U
- volatile uint32_t dwEpCtx4;
+ uint32_t dwEpCtx4;
#define XHCI_EPCTX_4_AVG_TRB_LEN_SET(x) ((x) & 0xFFFF)
#define XHCI_EPCTX_4_AVG_TRB_LEN_GET(x) ((x) & 0xFFFF)
#define XHCI_EPCTX_4_MAX_ESIT_PAYLOAD_SET(x) (((x) & 0xFFFF) << 16)
#define XHCI_EPCTX_4_MAX_ESIT_PAYLOAD_GET(x) (((x) >> 16) & 0xFFFF)
- volatile uint32_t dwEpCtx5;
- volatile uint32_t dwEpCtx6;
- volatile uint32_t dwEpCtx7;
+ uint32_t dwEpCtx5;
+ uint32_t dwEpCtx6;
+ uint32_t dwEpCtx7;
};
struct xhci_input_ctx {
#define XHCI_INCTX_NON_CTRL_MASK 0xFFFFFFFCU
- volatile uint32_t dwInCtx0;
+ uint32_t dwInCtx0;
#define XHCI_INCTX_0_DROP_MASK(n) (1U << (n))
- volatile uint32_t dwInCtx1;
+ uint32_t dwInCtx1;
#define XHCI_INCTX_1_ADD_MASK(n) (1U << (n))
- volatile uint32_t dwInCtx2;
- volatile uint32_t dwInCtx3;
- volatile uint32_t dwInCtx4;
- volatile uint32_t dwInCtx5;
- volatile uint32_t dwInCtx6;
- volatile uint32_t dwInCtx7;
+ uint32_t dwInCtx2;
+ uint32_t dwInCtx3;
+ uint32_t dwInCtx4;
+ uint32_t dwInCtx5;
+ uint32_t dwInCtx6;
+ uint32_t dwInCtx7;
};
struct xhci_input_dev_ctx {
@@ -197,7 +195,7 @@ struct xhci_dev_ctx {
#define ctx_ep ctx_dev_slep.u_ep
struct xhci_stream_ctx {
- volatile uint64_t qwSctx0;
+ uint64_t qwSctx0;
#define XHCI_SCTX_0_DCS_GET(x) ((x) & 0x1)
#define XHCI_SCTX_0_DCS_SET(x) ((x) & 0x1)
#define XHCI_SCTX_0_SCT_SET(x) (((x) & 0x7) << 1)
@@ -211,15 +209,15 @@ struct xhci_stream_ctx {
#define XHCI_SCTX_0_SCT_PRIM_SSA_128 0x6
#define XHCI_SCTX_0_SCT_PRIM_SSA_256 0x7
#define XHCI_SCTX_0_TR_DQ_PTR_MASK 0xFFFFFFFFFFFFFFF0U
- volatile uint32_t dwSctx2;
- volatile uint32_t dwSctx3;
+ uint32_t dwSctx2;
+ uint32_t dwSctx3;
};
struct xhci_trb {
- volatile uint64_t qwTrb0;
+ uint64_t qwTrb0;
#define XHCI_TRB_0_DIR_IN_MASK (0x80ULL << 0)
#define XHCI_TRB_0_WLENGTH_MASK (0xFFFFULL << 48)
- volatile uint32_t dwTrb2;
+ uint32_t dwTrb2;
#define XHCI_TRB_2_ERROR_GET(x) (((x) >> 24) & 0xFF)
#define XHCI_TRB_2_ERROR_SET(x) (((x) & 0xFF) << 24)
#define XHCI_TRB_2_TDSZ_GET(x) (((x) >> 17) & 0x1F)
@@ -233,7 +231,7 @@ struct xhci_trb {
#define XHCI_TRB_2_STREAM_GET(x) (((x) >> 16) & 0xFFFF)
#define XHCI_TRB_2_STREAM_SET(x) (((x) & 0xFFFF) << 16)
- volatile uint32_t dwTrb3;
+ uint32_t dwTrb3;
#define XHCI_TRB_3_TYPE_GET(x) (((x) >> 10) & 0x3F)
#define XHCI_TRB_3_TYPE_SET(x) (((x) & 0x3F) << 10)
#define XHCI_TRB_3_CYCLE_BIT (1U << 0)
@@ -347,9 +345,9 @@ struct xhci_dev_endpoint_trbs {
};
struct xhci_event_ring_seg {
- volatile uint64_t qwEvrsTablePtr;
- volatile uint32_t dwEvrsTableSize;
- volatile uint32_t dwEvrsReserved;
+ uint64_t qwEvrsTablePtr;
+ uint32_t dwEvrsTableSize;
+ uint32_t dwEvrsReserved;
};
#endif /* _PCI_XHCI_H_ */
diff --git a/usr.sbin/bhyve/pctestdev.c b/usr.sbin/bhyve/pctestdev.c
index 49e03b2a4343..55bc06f8e5b4 100644
--- a/usr.sbin/bhyve/pctestdev.c
+++ b/usr.sbin/bhyve/pctestdev.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020 Adam Fenn <adam@fenn.io>
*
@@ -29,9 +29,6 @@
* Emulation of selected legacy test/debug interfaces expected by KVM-unit-tests
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/mman.h>
#include <machine/vmm.h>
@@ -45,7 +42,9 @@ __FBSDID("$FreeBSD$");
#include <vmmapi.h>
#include "debug.h"
-#include "inout.h"
+#ifdef __amd64__
+#include "amd64/inout.h"
+#endif
#include "mem.h"
#include "pctestdev.h"
@@ -72,14 +71,14 @@ static bool pctestdev_inited;
static uint8_t pctestdev_iomem_buf[IOMEM_LEN];
static uint32_t pctestdev_ioport_data;
-static int pctestdev_debugexit_io(struct vmctx *ctx, int vcpu, int in,
+static int pctestdev_debugexit_io(struct vmctx *ctx, int in,
int port, int bytes, uint32_t *eax, void *arg);
-static int pctestdev_iomem_io(struct vmctx *ctx, int vcpu, int dir,
+static int pctestdev_iomem_io(struct vcpu *vcpu, int dir,
uint64_t addr, int size, uint64_t *val, void *arg1,
long arg2);
-static int pctestdev_ioport_io(struct vmctx *ctx, int vcpu, int in,
+static int pctestdev_ioport_io(struct vmctx *ctx, int in,
int port, int bytes, uint32_t *eax, void *arg);
-static int pctestdev_irq_io(struct vmctx *ctx, int vcpu, int in,
+static int pctestdev_irq_io(struct vmctx *ctx, int in,
int port, int bytes, uint32_t *eax, void *arg);
const char *
@@ -178,8 +177,8 @@ fail:
}
static int
-pctestdev_debugexit_io(struct vmctx *ctx, int vcpu, int in, int port,
- int bytes, uint32_t *eax, void *arg)
+pctestdev_debugexit_io(struct vmctx *ctx __unused, int in,
+ int port __unused, int bytes __unused, uint32_t *eax, void *arg __unused)
{
if (in)
*eax = 0;
@@ -190,8 +189,9 @@ pctestdev_debugexit_io(struct vmctx *ctx, int vcpu, int in, int port,
}
static int
-pctestdev_iomem_io(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
- int size, uint64_t *val, void *arg1, long arg2)
+pctestdev_iomem_io(struct vcpu *vcpu __unused, int dir,
+ uint64_t addr, int size, uint64_t *val, void *arg1 __unused,
+ long arg2 __unused)
{
uint64_t offset;
@@ -210,8 +210,8 @@ pctestdev_iomem_io(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
}
static int
-pctestdev_ioport_io(struct vmctx *ctx, int vcpu, int in, int port,
- int bytes, uint32_t *eax, void *arg)
+pctestdev_ioport_io(struct vmctx *ctx __unused, int in,
+ int port, int bytes, uint32_t *eax, void *arg __unused)
{
uint32_t mask;
int lsb;
@@ -233,8 +233,8 @@ pctestdev_ioport_io(struct vmctx *ctx, int vcpu, int in, int port,
}
static int
-pctestdev_irq_io(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
- uint32_t *eax, void *arg)
+pctestdev_irq_io(struct vmctx *ctx, int in, int port,
+ int bytes, uint32_t *eax, void *arg __unused)
{
int irq;
diff --git a/usr.sbin/bhyve/pctestdev.h b/usr.sbin/bhyve/pctestdev.h
index 5808abe6e356..80d58a9f00ec 100644
--- a/usr.sbin/bhyve/pctestdev.h
+++ b/usr.sbin/bhyve/pctestdev.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020 Adam Fenn <adam@fenn.io>
*
@@ -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$
*/
/*
diff --git a/usr.sbin/bhyve/qemu_fwcfg.c b/usr.sbin/bhyve/qemu_fwcfg.c
new file mode 100644
index 000000000000..5b33dfab037d
--- /dev/null
+++ b/usr.sbin/bhyve/qemu_fwcfg.c
@@ -0,0 +1,634 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#include <sys/param.h>
+#include <sys/endian.h>
+#include <sys/queue.h>
+#include <sys/stat.h>
+
+#include <machine/vmm.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "acpi_device.h"
+#include "bhyverun.h"
+#ifdef __amd64__
+#include "amd64/inout.h"
+#include "amd64/pci_lpc.h"
+#endif
+#include "qemu_fwcfg.h"
+
+#define QEMU_FWCFG_ACPI_DEVICE_NAME "FWCF"
+#define QEMU_FWCFG_ACPI_HARDWARE_ID "QEMU0002"
+
+#define QEMU_FWCFG_SELECTOR_PORT_NUMBER 0x510
+#define QEMU_FWCFG_SELECTOR_PORT_SIZE 1
+#define QEMU_FWCFG_SELECTOR_PORT_FLAGS IOPORT_F_INOUT
+#define QEMU_FWCFG_DATA_PORT_NUMBER 0x511
+#define QEMU_FWCFG_DATA_PORT_SIZE 1
+#define QEMU_FWCFG_DATA_PORT_FLAGS \
+ IOPORT_F_INOUT /* QEMU v2.4+ ignores writes */
+
+#define QEMU_FWCFG_ARCHITECTURE_MASK 0x0001
+#define QEMU_FWCFG_INDEX_MASK 0x3FFF
+
+#define QEMU_FWCFG_SELECT_READ 0
+#define QEMU_FWCFG_SELECT_WRITE 1
+
+#define QEMU_FWCFG_ARCHITECTURE_GENERIC 0
+#define QEMU_FWCFG_ARCHITECTURE_SPECIFIC 1
+
+#define QEMU_FWCFG_INDEX_SIGNATURE 0x00
+#define QEMU_FWCFG_INDEX_ID 0x01
+#define QEMU_FWCFG_INDEX_NB_CPUS 0x05
+#define QEMU_FWCFG_INDEX_MAX_CPUS 0x0F
+#define QEMU_FWCFG_INDEX_FILE_DIR 0x19
+
+#define QEMU_FWCFG_FIRST_FILE_INDEX 0x20
+
+#define QEMU_FWCFG_MIN_FILES 10
+
+#pragma pack(1)
+
+union qemu_fwcfg_selector {
+ struct {
+ uint16_t index : 14;
+ uint16_t writeable : 1;
+ uint16_t architecture : 1;
+ };
+ uint16_t bits;
+};
+
+struct qemu_fwcfg_signature {
+ uint8_t signature[4];
+};
+
+struct qemu_fwcfg_id {
+ uint32_t interface : 1; /* always set */
+ uint32_t DMA : 1;
+ uint32_t reserved : 30;
+};
+
+struct qemu_fwcfg_file {
+ uint32_t be_size;
+ uint16_t be_selector;
+ uint16_t reserved;
+ uint8_t name[QEMU_FWCFG_MAX_NAME];
+};
+
+struct qemu_fwcfg_directory {
+ uint32_t be_count;
+ struct qemu_fwcfg_file files[0];
+};
+
+#pragma pack()
+
+struct qemu_fwcfg_softc {
+ struct acpi_device *acpi_dev;
+
+ uint32_t data_offset;
+ union qemu_fwcfg_selector selector;
+ struct qemu_fwcfg_item items[QEMU_FWCFG_MAX_ARCHS]
+ [QEMU_FWCFG_MAX_ENTRIES];
+ struct qemu_fwcfg_directory *directory;
+};
+
+static struct qemu_fwcfg_softc fwcfg_sc;
+
+struct qemu_fwcfg_user_file {
+ STAILQ_ENTRY(qemu_fwcfg_user_file) chain;
+ uint8_t name[QEMU_FWCFG_MAX_NAME];
+ uint32_t size;
+ void *data;
+};
+static STAILQ_HEAD(qemu_fwcfg_user_file_list,
+ qemu_fwcfg_user_file) user_files = STAILQ_HEAD_INITIALIZER(user_files);
+
+#ifdef __amd64__
+static int
+qemu_fwcfg_selector_port_handler(struct vmctx *const ctx __unused, const int in,
+ const int port __unused, const int bytes, uint32_t *const eax,
+ void *const arg __unused)
+{
+ if (bytes != sizeof(uint16_t)) {
+ warnx("%s: invalid size (%d) of IO port access", __func__,
+ bytes);
+ return (-1);
+ }
+
+ if (in) {
+ *eax = htole16(fwcfg_sc.selector.bits);
+ return (0);
+ }
+
+ fwcfg_sc.data_offset = 0;
+ fwcfg_sc.selector.bits = le16toh(*eax);
+
+ return (0);
+}
+
+static int
+qemu_fwcfg_data_port_handler(struct vmctx *const ctx __unused, const int in,
+ const int port __unused, const int bytes, uint32_t *const eax,
+ void *const arg __unused)
+{
+ if (bytes != sizeof(uint8_t)) {
+ warnx("%s: invalid size (%d) of IO port access", __func__,
+ bytes);
+ return (-1);
+ }
+
+ if (!in) {
+ warnx("%s: Writes to qemu fwcfg data port aren't allowed",
+ __func__);
+ return (-1);
+ }
+
+ /* get fwcfg item */
+ struct qemu_fwcfg_item *const item =
+ &fwcfg_sc.items[fwcfg_sc.selector.architecture]
+ [fwcfg_sc.selector.index];
+ if (item->data == NULL) {
+ warnx(
+ "%s: qemu fwcfg item doesn't exist (architecture %s index 0x%x)",
+ __func__,
+ fwcfg_sc.selector.architecture ? "specific" : "generic",
+ fwcfg_sc.selector.index);
+ *eax = 0x00;
+ return (0);
+ } else if (fwcfg_sc.data_offset >= item->size) {
+ warnx(
+ "%s: qemu fwcfg item read exceeds size (architecture %s index 0x%x size 0x%x offset 0x%x)",
+ __func__,
+ fwcfg_sc.selector.architecture ? "specific" : "generic",
+ fwcfg_sc.selector.index, item->size, fwcfg_sc.data_offset);
+ *eax = 0x00;
+ return (0);
+ }
+
+ /* return item data */
+ *eax = item->data[fwcfg_sc.data_offset];
+ fwcfg_sc.data_offset++;
+
+ return (0);
+}
+#endif
+
+static int
+qemu_fwcfg_add_item(const uint16_t architecture, const uint16_t index,
+ const uint32_t size, void *const data)
+{
+ /* truncate architecture and index to their desired size */
+ const uint16_t arch = architecture & QEMU_FWCFG_ARCHITECTURE_MASK;
+ const uint16_t idx = index & QEMU_FWCFG_INDEX_MASK;
+
+ /* get pointer to item specified by selector */
+ struct qemu_fwcfg_item *const fwcfg_item = &fwcfg_sc.items[arch][idx];
+
+ /* check if item is already used */
+ if (fwcfg_item->data != NULL) {
+ warnx("%s: qemu fwcfg item exists (architecture %s index 0x%x)",
+ __func__, arch ? "specific" : "generic", idx);
+ return (EEXIST);
+ }
+
+ /* save data of the item */
+ fwcfg_item->size = size;
+ fwcfg_item->data = data;
+
+ return (0);
+}
+
+static int
+qemu_fwcfg_add_item_file_dir(void)
+{
+ const size_t size = sizeof(struct qemu_fwcfg_directory) +
+ QEMU_FWCFG_MIN_FILES * sizeof(struct qemu_fwcfg_file);
+ struct qemu_fwcfg_directory *const fwcfg_directory = calloc(1, size);
+ if (fwcfg_directory == NULL) {
+ return (ENOMEM);
+ }
+
+ fwcfg_sc.directory = fwcfg_directory;
+
+ return (qemu_fwcfg_add_item(QEMU_FWCFG_ARCHITECTURE_GENERIC,
+ QEMU_FWCFG_INDEX_FILE_DIR, sizeof(struct qemu_fwcfg_directory),
+ (uint8_t *)fwcfg_sc.directory));
+}
+
+static int
+qemu_fwcfg_add_item_id(void)
+{
+ struct qemu_fwcfg_id *const fwcfg_id = calloc(1,
+ sizeof(struct qemu_fwcfg_id));
+ if (fwcfg_id == NULL) {
+ return (ENOMEM);
+ }
+
+ fwcfg_id->interface = 1;
+ fwcfg_id->DMA = 0;
+
+ uint32_t *const le_fwcfg_id_ptr = (uint32_t *)fwcfg_id;
+ *le_fwcfg_id_ptr = htole32(*le_fwcfg_id_ptr);
+
+ return (qemu_fwcfg_add_item(QEMU_FWCFG_ARCHITECTURE_GENERIC,
+ QEMU_FWCFG_INDEX_ID, sizeof(struct qemu_fwcfg_id),
+ (uint8_t *)fwcfg_id));
+}
+
+static int
+qemu_fwcfg_add_item_max_cpus(void)
+{
+ uint16_t *fwcfg_max_cpus = calloc(1, sizeof(uint16_t));
+ if (fwcfg_max_cpus == NULL) {
+ return (ENOMEM);
+ }
+
+ /*
+ * We don't support cpu hotplug yet. For that reason, use guest_ncpus instead
+ * of maxcpus.
+ */
+ *fwcfg_max_cpus = htole16(guest_ncpus);
+
+ return (qemu_fwcfg_add_item(QEMU_FWCFG_ARCHITECTURE_GENERIC,
+ QEMU_FWCFG_INDEX_MAX_CPUS, sizeof(uint16_t), fwcfg_max_cpus));
+}
+
+static int
+qemu_fwcfg_add_item_nb_cpus(void)
+{
+ uint16_t *fwcfg_max_cpus = calloc(1, sizeof(uint16_t));
+ if (fwcfg_max_cpus == NULL) {
+ return (ENOMEM);
+ }
+
+ *fwcfg_max_cpus = htole16(guest_ncpus);
+
+ return (qemu_fwcfg_add_item(QEMU_FWCFG_ARCHITECTURE_GENERIC,
+ QEMU_FWCFG_INDEX_NB_CPUS, sizeof(uint16_t), fwcfg_max_cpus));
+}
+
+static int
+qemu_fwcfg_add_item_signature(void)
+{
+ struct qemu_fwcfg_signature *const fwcfg_signature = calloc(1,
+ sizeof(struct qemu_fwcfg_signature));
+ if (fwcfg_signature == NULL) {
+ return (ENOMEM);
+ }
+
+ fwcfg_signature->signature[0] = 'Q';
+ fwcfg_signature->signature[1] = 'E';
+ fwcfg_signature->signature[2] = 'M';
+ fwcfg_signature->signature[3] = 'U';
+
+ return (qemu_fwcfg_add_item(QEMU_FWCFG_ARCHITECTURE_GENERIC,
+ QEMU_FWCFG_INDEX_SIGNATURE, sizeof(struct qemu_fwcfg_signature),
+ (uint8_t *)fwcfg_signature));
+}
+
+#ifdef __amd64__
+static int
+qemu_fwcfg_register_port(const char *const name, const int port, const int size,
+ const int flags, const inout_func_t handler)
+{
+ struct inout_port iop;
+
+ bzero(&iop, sizeof(iop));
+ iop.name = name;
+ iop.port = port;
+ iop.size = size;
+ iop.flags = flags;
+ iop.handler = handler;
+
+ return (register_inout(&iop));
+}
+#endif
+
+int
+qemu_fwcfg_add_file(const char *name, const uint32_t size, void *const data)
+{
+ if (strlen(name) >= QEMU_FWCFG_MAX_NAME)
+ return (EINVAL);
+
+ /*
+ * QEMU specifies count as big endian.
+ * Convert it to host endian to work with it.
+ */
+ const uint32_t count = be32toh(fwcfg_sc.directory->be_count) + 1;
+
+ /* add file to items list */
+ const uint32_t index = QEMU_FWCFG_FIRST_FILE_INDEX + count - 1;
+ const int error = qemu_fwcfg_add_item(QEMU_FWCFG_ARCHITECTURE_GENERIC,
+ index, size, data);
+ if (error != 0) {
+ return (error);
+ }
+
+ /*
+ * files should be sorted alphabetical, get index for new file
+ */
+ uint32_t file_index;
+ for (file_index = 0; file_index < count - 1; ++file_index) {
+ if (strcmp(name, fwcfg_sc.directory->files[file_index].name) <
+ 0)
+ break;
+ }
+
+ if (count > QEMU_FWCFG_MIN_FILES) {
+ /* alloc new file directory */
+ const uint64_t new_size = sizeof(struct qemu_fwcfg_directory) +
+ count * sizeof(struct qemu_fwcfg_file);
+ struct qemu_fwcfg_directory *const new_directory = calloc(1,
+ new_size);
+ if (new_directory == NULL) {
+ warnx(
+ "%s: Unable to allocate a new qemu fwcfg files directory (count %d)",
+ __func__, count);
+ return (ENOMEM);
+ }
+
+ /* copy files below file_index to new directory */
+ memcpy(new_directory->files, fwcfg_sc.directory->files,
+ file_index * sizeof(struct qemu_fwcfg_file));
+
+ /* copy files above file_index to directory */
+ memcpy(&new_directory->files[file_index + 1],
+ &fwcfg_sc.directory->files[file_index],
+ (count - file_index - 1) * sizeof(struct qemu_fwcfg_file));
+
+ /* free old directory */
+ free(fwcfg_sc.directory);
+
+ /* set directory pointer to new directory */
+ fwcfg_sc.directory = new_directory;
+
+ /* adjust directory pointer */
+ fwcfg_sc.items[0][QEMU_FWCFG_INDEX_FILE_DIR].data =
+ (uint8_t *)fwcfg_sc.directory;
+ } else {
+ /* shift files behind file_index */
+ for (uint32_t i = QEMU_FWCFG_MIN_FILES - 1; i > file_index;
+ --i) {
+ memcpy(&fwcfg_sc.directory->files[i],
+ &fwcfg_sc.directory->files[i - 1],
+ sizeof(struct qemu_fwcfg_file));
+ }
+ }
+
+ /*
+ * QEMU specifies count, size and index as big endian.
+ * Save these values in big endian to simplify guest reads of these
+ * values.
+ */
+ fwcfg_sc.directory->be_count = htobe32(count);
+ fwcfg_sc.directory->files[file_index].be_size = htobe32(size);
+ fwcfg_sc.directory->files[file_index].be_selector = htobe16(index);
+ strcpy(fwcfg_sc.directory->files[file_index].name, name);
+
+ /* set new size for the fwcfg_file_directory */
+ fwcfg_sc.items[0][QEMU_FWCFG_INDEX_FILE_DIR].size =
+ sizeof(struct qemu_fwcfg_directory) +
+ count * sizeof(struct qemu_fwcfg_file);
+
+ return (0);
+}
+
+static int
+qemu_fwcfg_add_user_files(void)
+{
+ const struct qemu_fwcfg_user_file *fwcfg_file;
+ int error;
+
+ STAILQ_FOREACH(fwcfg_file, &user_files, chain) {
+ error = qemu_fwcfg_add_file(fwcfg_file->name, fwcfg_file->size,
+ fwcfg_file->data);
+ if (error)
+ return (error);
+ }
+
+ return (0);
+}
+
+static const struct acpi_device_emul qemu_fwcfg_acpi_device_emul = {
+ .name = QEMU_FWCFG_ACPI_DEVICE_NAME,
+ .hid = QEMU_FWCFG_ACPI_HARDWARE_ID,
+};
+
+int
+qemu_fwcfg_init(struct vmctx *const ctx)
+{
+ int error;
+ bool fwcfg_enabled;
+
+ /*
+ * The fwcfg implementation currently only provides an I/O port
+ * interface and thus is amd64-specific for now. An MMIO interface is
+ * required for other platforms.
+ */
+#ifdef __amd64__
+ fwcfg_enabled = strcmp(lpc_fwcfg(), "qemu") == 0;
+#else
+ fwcfg_enabled = false;
+#endif
+
+ /*
+ * Bhyve supports fwctl (bhyve) and fwcfg (qemu) as firmware interfaces.
+ * Both are using the same ports. So, it's not possible to provide both
+ * interfaces at the same time to the guest. Therefore, only create acpi
+ * tables and register io ports for fwcfg, if it's used.
+ */
+ if (fwcfg_enabled) {
+ error = acpi_device_create(&fwcfg_sc.acpi_dev, &fwcfg_sc, ctx,
+ &qemu_fwcfg_acpi_device_emul);
+ if (error) {
+ warnx("%s: failed to create ACPI device for QEMU FwCfg",
+ __func__);
+ goto done;
+ }
+
+ error = acpi_device_add_res_fixed_ioport(fwcfg_sc.acpi_dev,
+ QEMU_FWCFG_SELECTOR_PORT_NUMBER, 2);
+ if (error) {
+ warnx("%s: failed to add fixed IO port for QEMU FwCfg",
+ __func__);
+ goto done;
+ }
+
+#ifdef __amd64__
+ if ((error = qemu_fwcfg_register_port("qemu_fwcfg_selector",
+ QEMU_FWCFG_SELECTOR_PORT_NUMBER,
+ QEMU_FWCFG_SELECTOR_PORT_SIZE,
+ QEMU_FWCFG_SELECTOR_PORT_FLAGS,
+ qemu_fwcfg_selector_port_handler)) != 0) {
+ warnx(
+ "%s: Unable to register qemu fwcfg selector port 0x%x",
+ __func__, QEMU_FWCFG_SELECTOR_PORT_NUMBER);
+ goto done;
+ }
+ if ((error = qemu_fwcfg_register_port("qemu_fwcfg_data",
+ QEMU_FWCFG_DATA_PORT_NUMBER, QEMU_FWCFG_DATA_PORT_SIZE,
+ QEMU_FWCFG_DATA_PORT_FLAGS,
+ qemu_fwcfg_data_port_handler)) != 0) {
+ warnx(
+ "%s: Unable to register qemu fwcfg data port 0x%x",
+ __func__, QEMU_FWCFG_DATA_PORT_NUMBER);
+ goto done;
+ }
+#endif
+ }
+
+ /* add common fwcfg items */
+ if ((error = qemu_fwcfg_add_item_signature()) != 0) {
+ warnx("%s: Unable to add signature item", __func__);
+ goto done;
+ }
+ if ((error = qemu_fwcfg_add_item_id()) != 0) {
+ warnx("%s: Unable to add id item", __func__);
+ goto done;
+ }
+ if ((error = qemu_fwcfg_add_item_nb_cpus()) != 0) {
+ warnx("%s: Unable to add nb_cpus item", __func__);
+ goto done;
+ }
+ if ((error = qemu_fwcfg_add_item_max_cpus()) != 0) {
+ warnx("%s: Unable to add max_cpus item", __func__);
+ goto done;
+ }
+ if ((error = qemu_fwcfg_add_item_file_dir()) != 0) {
+ warnx("%s: Unable to add file_dir item", __func__);
+ }
+
+ /* add user defined fwcfg files */
+ if ((error = qemu_fwcfg_add_user_files()) != 0) {
+ warnx("%s: Unable to add user files", __func__);
+ goto done;
+ }
+
+done:
+ if (error) {
+ acpi_device_destroy(fwcfg_sc.acpi_dev);
+ }
+
+ return (error);
+}
+
+static void
+qemu_fwcfg_usage(const char *opt)
+{
+ warnx("Invalid fw_cfg option \"%s\"", opt);
+ warnx("-f [name=]<name>,(string|file)=<value>");
+}
+
+/*
+ * Parses the cmdline argument for user defined fw_cfg items. The cmdline
+ * argument has the format:
+ * "-f [name=]<name>,(string|file)=<value>"
+ *
+ * E.g.: "-f opt/com.page/example,string=Hello"
+ */
+int
+qemu_fwcfg_parse_cmdline_arg(const char *opt)
+{
+ struct qemu_fwcfg_user_file *fwcfg_file;
+ struct stat sb;
+ const char *opt_ptr, *opt_end;
+ ssize_t bytes_read;
+ int fd;
+
+ fwcfg_file = malloc(sizeof(*fwcfg_file));
+ if (fwcfg_file == NULL) {
+ warnx("Unable to allocate fw_cfg_user_file");
+ return (ENOMEM);
+ }
+
+ /* get pointer to <name> */
+ opt_ptr = opt;
+ /* If [name=] is specified, skip it */
+ if (strncmp(opt_ptr, "name=", sizeof("name=") - 1) == 0) {
+ opt_ptr += sizeof("name=") - 1;
+ }
+
+ /* get the end of <name> */
+ opt_end = strchr(opt_ptr, ',');
+ if (opt_end == NULL) {
+ qemu_fwcfg_usage(opt);
+ return (EINVAL);
+ }
+
+ /* check if <name> is too long */
+ if (opt_end - opt_ptr >= QEMU_FWCFG_MAX_NAME) {
+ warnx("fw_cfg name too long: \"%s\"", opt);
+ return (EINVAL);
+ }
+
+ /* save <name> */
+ strncpy(fwcfg_file->name, opt_ptr, opt_end - opt_ptr);
+ fwcfg_file->name[opt_end - opt_ptr] = '\0';
+
+ /* set opt_ptr and opt_end to <value> */
+ opt_ptr = opt_end + 1;
+ opt_end = opt_ptr + strlen(opt_ptr);
+
+ if (strncmp(opt_ptr, "string=", sizeof("string=") - 1) == 0) {
+ opt_ptr += sizeof("string=") - 1;
+ fwcfg_file->data = strdup(opt_ptr);
+ if (fwcfg_file->data == NULL) {
+ warnx("Can't duplicate fw_cfg_user_file string \"%s\"",
+ opt_ptr);
+ return (ENOMEM);
+ }
+ fwcfg_file->size = strlen(opt_ptr) + 1;
+ } else if (strncmp(opt_ptr, "file=", sizeof("file=") - 1) == 0) {
+ opt_ptr += sizeof("file=") - 1;
+
+ fd = open(opt_ptr, O_RDONLY);
+ if (fd < 0) {
+ warn("Can't open fw_cfg_user_file file \"%s\"",
+ opt_ptr);
+ return (EINVAL);
+ }
+
+ if (fstat(fd, &sb) < 0) {
+ warn("Unable to get size of file \"%s\"", opt_ptr);
+ close(fd);
+ return (-1);
+ }
+
+ fwcfg_file->data = malloc(sb.st_size);
+ if (fwcfg_file->data == NULL) {
+ warnx(
+ "Can't allocate fw_cfg_user_file file \"%s\" (size: 0x%16lx)",
+ opt_ptr, sb.st_size);
+ close(fd);
+ return (ENOMEM);
+ }
+ bytes_read = read(fd, fwcfg_file->data, sb.st_size);
+ if (bytes_read < 0 || bytes_read != sb.st_size) {
+ warn("Unable to read file \"%s\"", opt_ptr);
+ free(fwcfg_file->data);
+ close(fd);
+ return (-1);
+ }
+ fwcfg_file->size = bytes_read;
+
+ close(fd);
+ } else {
+ qemu_fwcfg_usage(opt);
+ return (EINVAL);
+ }
+
+ STAILQ_INSERT_TAIL(&user_files, fwcfg_file, chain);
+
+ return (0);
+}
diff --git a/usr.sbin/bhyve/qemu_fwcfg.h b/usr.sbin/bhyve/qemu_fwcfg.h
new file mode 100644
index 000000000000..5c73e8309c6e
--- /dev/null
+++ b/usr.sbin/bhyve/qemu_fwcfg.h
@@ -0,0 +1,26 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#pragma once
+
+#include <vmmapi.h>
+
+#define QEMU_FWCFG_MAX_ARCHS 0x2
+#define QEMU_FWCFG_MAX_ENTRIES 0x4000
+#define QEMU_FWCFG_MAX_NAME 56
+
+#define QEMU_FWCFG_FILE_TABLE_LOADER "etc/table-loader"
+
+struct qemu_fwcfg_item {
+ uint32_t size;
+ uint8_t *data;
+};
+
+int qemu_fwcfg_add_file(const char *name,
+ const uint32_t size, void *const data);
+int qemu_fwcfg_init(struct vmctx *const ctx);
+int qemu_fwcfg_parse_cmdline_arg(const char *opt);
diff --git a/usr.sbin/bhyve/qemu_loader.c b/usr.sbin/bhyve/qemu_loader.c
new file mode 100644
index 000000000000..b0e1197a4b6b
--- /dev/null
+++ b/usr.sbin/bhyve/qemu_loader.c
@@ -0,0 +1,274 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/endian.h>
+#include <sys/queue.h>
+
+#include <machine/vmm.h>
+
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <vmmapi.h>
+
+#include "qemu_fwcfg.h"
+#include "qemu_loader.h"
+
+struct qemu_loader_entry {
+ uint32_t cmd_le;
+ union {
+ struct {
+ uint8_t name[QEMU_FWCFG_MAX_NAME];
+ uint32_t alignment_le;
+ uint8_t zone;
+ } alloc;
+ struct {
+ uint8_t dest_name[QEMU_FWCFG_MAX_NAME];
+ uint8_t src_name[QEMU_FWCFG_MAX_NAME];
+ uint32_t off_le;
+ uint8_t size;
+ } add_pointer;
+ struct {
+ uint8_t name[QEMU_FWCFG_MAX_NAME];
+ uint32_t off_le;
+ uint32_t start_le;
+ uint32_t len_le;
+ } add_checksum;
+ struct {
+ uint8_t dest_name[QEMU_FWCFG_MAX_NAME];
+ uint8_t src_name[QEMU_FWCFG_MAX_NAME];
+ uint32_t dest_off_le;
+ uint32_t src_off_le;
+ uint8_t size;
+ } write_pointer;
+
+ /* padding */
+ uint8_t pad[124];
+ };
+} __packed;
+
+enum qemu_loader_command {
+ QEMU_LOADER_CMD_ALLOC = 0x1,
+ QEMU_LOADER_CMD_ADD_POINTER = 0x2,
+ QEMU_LOADER_CMD_ADD_CHECKSUM = 0x3,
+ QEMU_LOADER_CMD_WRITE_POINTER = 0x4,
+};
+
+struct qemu_loader_element {
+ STAILQ_ENTRY(qemu_loader_element) chain;
+ struct qemu_loader_entry entry;
+};
+
+struct qemu_loader {
+ uint8_t fwcfg_name[QEMU_FWCFG_MAX_NAME];
+ STAILQ_HEAD(qemu_loader_list, qemu_loader_element) list;
+};
+
+int
+qemu_loader_alloc(struct qemu_loader *const loader, const uint8_t *name,
+ const uint32_t alignment, const enum qemu_loader_zone zone)
+{
+ struct qemu_loader_element *element;
+
+ if (strlen(name) >= QEMU_FWCFG_MAX_NAME)
+ return (EINVAL);
+
+ element = calloc(1, sizeof(struct qemu_loader_element));
+ if (element == NULL) {
+ warnx("%s: failed to allocate command", __func__);
+ return (ENOMEM);
+ }
+
+ element->entry.cmd_le = htole32(QEMU_LOADER_CMD_ALLOC);
+ strncpy(element->entry.alloc.name, name, QEMU_FWCFG_MAX_NAME);
+ element->entry.alloc.alignment_le = htole32(alignment);
+ element->entry.alloc.zone = zone;
+
+ /*
+ * The guest always works on copies of the fwcfg item, which where
+ * loaded into guest memory. Loading a fwcfg item is caused by ALLOC.
+ * For that reason, ALLOC should be scheduled in front of any other
+ * commands.
+ */
+ STAILQ_INSERT_HEAD(&loader->list, element, chain);
+
+ return (0);
+}
+
+int
+qemu_loader_add_checksum(struct qemu_loader *const loader, const uint8_t *name,
+ const uint32_t off, const uint32_t start, const uint32_t len)
+{
+ struct qemu_loader_element *element;
+
+ if (strlen(name) >= QEMU_FWCFG_MAX_NAME)
+ return (EINVAL);
+
+ element = calloc(1, sizeof(struct qemu_loader_element));
+ if (element == NULL) {
+ warnx("%s: failed to allocate command", __func__);
+ return (ENOMEM);
+ }
+
+ element->entry.cmd_le = htole32(QEMU_LOADER_CMD_ADD_CHECKSUM);
+ strncpy(element->entry.add_checksum.name, name, QEMU_FWCFG_MAX_NAME);
+ element->entry.add_checksum.off_le = htole32(off);
+ element->entry.add_checksum.start_le = htole32(start);
+ element->entry.add_checksum.len_le = htole32(len);
+
+ STAILQ_INSERT_TAIL(&loader->list, element, chain);
+
+ return (0);
+}
+
+int
+qemu_loader_add_pointer(struct qemu_loader *const loader,
+ const uint8_t *dest_name, const uint8_t *src_name, const uint32_t off,
+ const uint8_t size)
+{
+ struct qemu_loader_element *element;
+
+ if (strlen(dest_name) >= QEMU_FWCFG_MAX_NAME ||
+ strlen(src_name) >= QEMU_FWCFG_MAX_NAME)
+ return (EINVAL);
+
+ element = calloc(1, sizeof(struct qemu_loader_element));
+ if (element == NULL) {
+ warnx("%s: failed to allocate command", __func__);
+ return (ENOMEM);
+ }
+
+ element->entry.cmd_le = htole32(QEMU_LOADER_CMD_ADD_POINTER);
+ strncpy(element->entry.add_pointer.dest_name, dest_name,
+ QEMU_FWCFG_MAX_NAME);
+ strncpy(element->entry.add_pointer.src_name, src_name,
+ QEMU_FWCFG_MAX_NAME);
+ element->entry.add_pointer.off_le = htole32(off);
+ element->entry.add_pointer.size = size;
+
+ STAILQ_INSERT_TAIL(&loader->list, element, chain);
+
+ return (0);
+}
+
+int
+qemu_loader_create(struct qemu_loader **const new_loader,
+ const uint8_t *fwcfg_name)
+{
+ struct qemu_loader *loader;
+
+ if (new_loader == NULL || strlen(fwcfg_name) >= QEMU_FWCFG_MAX_NAME) {
+ return (EINVAL);
+ }
+
+ loader = calloc(1, sizeof(struct qemu_loader));
+ if (loader == NULL) {
+ warnx("%s: failed to allocate loader", __func__);
+ return (ENOMEM);
+ }
+
+ strncpy(loader->fwcfg_name, fwcfg_name, QEMU_FWCFG_MAX_NAME);
+ STAILQ_INIT(&loader->list);
+
+ *new_loader = loader;
+
+ return (0);
+}
+
+static const uint8_t *
+qemu_loader_get_zone_name(const enum qemu_loader_zone zone)
+{
+ switch (zone) {
+ case QEMU_LOADER_ALLOC_HIGH:
+ return ("HIGH");
+ case QEMU_LOADER_ALLOC_FSEG:
+ return ("FSEG");
+ default:
+ return ("Unknown");
+ }
+}
+
+static void __unused
+qemu_loader_dump_entry(const struct qemu_loader_entry *const entry)
+{
+ switch (le32toh(entry->cmd_le)) {
+ case QEMU_LOADER_CMD_ALLOC:
+ printf("CMD_ALLOC\n\r");
+ printf(" name : %s\n\r", entry->alloc.name);
+ printf(" alignment: %8x\n\r",
+ le32toh(entry->alloc.alignment_le));
+ printf(" zone : %s\n\r",
+ qemu_loader_get_zone_name(entry->alloc.zone));
+ break;
+ case QEMU_LOADER_CMD_ADD_POINTER:
+ printf("CMD_ADD_POINTER\n\r");
+ printf(" dest_name: %s\n\r", entry->add_pointer.dest_name);
+ printf(" src_name : %s\n\r", entry->add_pointer.src_name);
+ printf(" off : %8x\n\r",
+ le32toh(entry->add_pointer.off_le));
+ printf(" size : %8x\n\r", entry->add_pointer.size);
+ break;
+ case QEMU_LOADER_CMD_ADD_CHECKSUM:
+ printf("CMD_ADD_CHECKSUM\n\r");
+ printf(" name : %s\n\r", entry->add_checksum.name);
+ printf(" off : %8x\n\r",
+ le32toh(entry->add_checksum.off_le));
+ printf(" start : %8x\n\r",
+ le32toh(entry->add_checksum.start_le));
+ printf(" length : %8x\n\r",
+ le32toh(entry->add_checksum.len_le));
+ break;
+ case QEMU_LOADER_CMD_WRITE_POINTER:
+ printf("CMD_WRITE_POINTER\n\r");
+ printf(" dest_name: %s\n\r", entry->write_pointer.dest_name);
+ printf(" src_name : %s\n\r", entry->write_pointer.src_name);
+ printf(" dest_off : %8x\n\r",
+ le32toh(entry->write_pointer.dest_off_le));
+ printf(" src_off : %8x\n\r",
+ le32toh(entry->write_pointer.src_off_le));
+ printf(" size : %8x\n\r", entry->write_pointer.size);
+ break;
+ default:
+ printf("UNKNOWN\n\r");
+ break;
+ }
+}
+
+int
+qemu_loader_finish(struct qemu_loader *const loader)
+{
+ struct qemu_loader_element *element;
+ struct qemu_loader_entry *data;
+ size_t len = 0;
+
+ STAILQ_FOREACH(element, &loader->list, chain) {
+ len += sizeof(struct qemu_loader_entry);
+ }
+ if (len == 0) {
+ warnx("%s: bios loader empty", __func__);
+ return (EFAULT);
+ }
+
+ data = calloc(1, len);
+ if (data == NULL) {
+ warnx("%s: failed to allocate fwcfg data", __func__);
+ return (ENOMEM);
+ }
+
+ int i = 0;
+ STAILQ_FOREACH(element, &loader->list, chain) {
+ memcpy(&data[i], &element->entry,
+ sizeof(struct qemu_loader_entry));
+ ++i;
+ }
+
+ return (qemu_fwcfg_add_file(loader->fwcfg_name, len, data));
+}
diff --git a/usr.sbin/bhyve/qemu_loader.h b/usr.sbin/bhyve/qemu_loader.h
new file mode 100644
index 000000000000..b6ce48ad0871
--- /dev/null
+++ b/usr.sbin/bhyve/qemu_loader.h
@@ -0,0 +1,77 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#pragma once
+
+#include "qemu_fwcfg.h"
+
+struct qemu_loader;
+
+/*
+ * Some guest bios like seabios assume the RSDP to be located in the FSEG. Bhyve
+ * only supports OVMF which has no such requirement.
+ */
+enum qemu_loader_zone {
+ QEMU_LOADER_ALLOC_HIGH = 1,
+ QEMU_LOADER_ALLOC_FSEG, /* 0x0F000000 - 0x100000 */
+};
+
+/**
+ * Loads a fwcfg item into guest memory. This command has to be issued before
+ * any subsequent command can be used.
+ *
+ * @param loader Qemu loader instance the command should be added to.
+ * @param name Name of the fwcfg item which should be allocated.
+ * @param alignment Alignment required by the data.
+ * @param zone Memory zone in which it should be loaded.
+ */
+int qemu_loader_alloc(struct qemu_loader *loader, const uint8_t *name,
+ uint32_t alignment, enum qemu_loader_zone zone);
+/**
+ * Calculates a checksum for @p name and writes it to @p name + @p off . The
+ * checksum calculation ranges from @p start to @p start + @p len. The checksum
+ * field is always one byte large and all bytes in the specified range,
+ * including the checksum, have to sum up to 0.
+ *
+ * @param loader Qemu loader instance the command should be added to.
+ * @param name Name of the fwcfg item which should be patched.
+ * @param off Offset into @p name .
+ * @param start Start offset of checksum calculation.
+ * @param len Length of the checksum calculation.
+ */
+int qemu_loader_add_checksum(struct qemu_loader *loader, const uint8_t *name,
+ uint32_t off, uint32_t start, uint32_t len);
+/**
+ * Adds the address of @p src_name to the value at @p dest_name + @p off . The
+ * size of the pointer is determined by @p dest_size and should be 1, 2, 4 or 8.
+ *
+ * @param loader Qemu loader instance the command should be added to.
+ * @param dest_name Name of the fwcfg item which should be patched.
+ * @param src_name Name of the fwcfg item which address should be written to
+ * @p dest_name + @p off.
+ * @param off Offset into @p dest_name .
+ * @param size Size of the pointer (1, 2, 4 or 8).
+ */
+int qemu_loader_add_pointer(struct qemu_loader *loader,
+ const uint8_t *dest_name, const uint8_t *src_name, uint32_t off,
+ uint8_t size);
+
+/**
+ * Creates a qemu loader instance.
+ *
+ * @param new_loader Returns the newly created qemu loader instance.
+ * @param fwcfg_name Name of the FwCfg item which represents the qemu loader
+ */
+int qemu_loader_create(struct qemu_loader **new_loader,
+ const uint8_t *fwcfg_name);
+/**
+ * Signals that all commands are written to the qemu loader. This function
+ * creates a proper FwCfg item and registers it.
+ *
+ * @param loader Qemu loader instance which should be finished.
+ */
+int qemu_loader_finish(struct qemu_loader *loader);
diff --git a/usr.sbin/bhyve/rfb.c b/usr.sbin/bhyve/rfb.c
index b5556aad45a0..bb989a33f484 100644
--- a/usr.sbin/bhyve/rfb.c
+++ b/usr.sbin/bhyve/rfb.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* Copyright (c) 2015 Leon Dang
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
@@ -114,7 +111,7 @@ struct rfb_softc {
int width, height;
- char *password;
+ const char *password;
bool enc_raw_ok;
bool enc_zlib_ok;
@@ -318,14 +315,14 @@ rfb_send_extended_keyevent_update_msg(struct rfb_softc *rc, int cfd)
}
static void
-rfb_recv_set_pixfmt_msg(struct rfb_softc *rc, int cfd)
+rfb_recv_set_pixfmt_msg(struct rfb_softc *rc __unused, int cfd)
{
struct rfb_pixfmt_msg pixfmt_msg;
- (void)stream_read(cfd, ((void *)&pixfmt_msg)+1, sizeof(pixfmt_msg)-1);
+ (void)stream_read(cfd, (uint8_t *)&pixfmt_msg + 1,
+ sizeof(pixfmt_msg) - 1);
}
-
static void
rfb_recv_set_encodings_msg(struct rfb_softc *rc, int cfd)
{
@@ -333,7 +330,7 @@ rfb_recv_set_encodings_msg(struct rfb_softc *rc, int cfd)
int i;
uint32_t encoding;
- (void)stream_read(cfd, ((void *)&enc_msg)+1, sizeof(enc_msg)-1);
+ (void)stream_read(cfd, (uint8_t *)&enc_msg + 1, sizeof(enc_msg) - 1);
for (i = 0; i < htons(enc_msg.numencs); i++) {
(void)stream_read(cfd, &encoding, sizeof(encoding));
@@ -379,7 +376,7 @@ fast_crc32(void *buf, int len, uint32_t crcval)
}
static int
-rfb_send_update_header(struct rfb_softc *rc, int cfd, int numrects)
+rfb_send_update_header(struct rfb_softc *rc __unused, int cfd, int numrects)
{
struct rfb_srvr_updt_msg supdt_msg;
@@ -728,7 +725,7 @@ rfb_recv_update_msg(struct rfb_softc *rc, int cfd)
{
struct rfb_updt_msg updt_msg;
- (void)stream_read(cfd, ((void *)&updt_msg) + 1 , sizeof(updt_msg) - 1);
+ (void)stream_read(cfd, (uint8_t *)&updt_msg + 1 , sizeof(updt_msg) - 1);
if (rc->enc_extkeyevent_ok && (!rc->enc_extkeyevent_send)) {
rfb_send_extended_keyevent_update_msg(rc, cfd);
@@ -745,7 +742,7 @@ rfb_recv_key_msg(struct rfb_softc *rc, int cfd)
{
struct rfb_key_msg key_msg;
- (void)stream_read(cfd, ((void *)&key_msg) + 1, sizeof(key_msg) - 1);
+ (void)stream_read(cfd, (uint8_t *)&key_msg + 1, sizeof(key_msg) - 1);
console_key_event(key_msg.down, htonl(key_msg.sym), htonl(0));
rc->input_detected = true;
@@ -757,10 +754,12 @@ rfb_recv_client_msg(struct rfb_softc *rc, int cfd)
struct rfb_client_msg client_msg;
struct rfb_extended_key_msg extkey_msg;
- (void)stream_read(cfd, ((void *)&client_msg) + 1, sizeof(client_msg) - 1);
+ (void)stream_read(cfd, (uint8_t *)&client_msg + 1,
+ sizeof(client_msg) - 1);
- if (client_msg.subtype == RFB_CLIENTMSG_EXT_KEYEVENT ) {
- (void)stream_read(cfd, ((void *)&extkey_msg) + 2, sizeof(extkey_msg) - 2);
+ if (client_msg.subtype == RFB_CLIENTMSG_EXT_KEYEVENT) {
+ (void)stream_read(cfd, (uint8_t *)&extkey_msg + 2,
+ sizeof(extkey_msg) - 2);
console_key_event((int)extkey_msg.down, htonl(extkey_msg.sym), htonl(extkey_msg.code));
rc->input_detected = true;
}
@@ -771,20 +770,20 @@ rfb_recv_ptr_msg(struct rfb_softc *rc, int cfd)
{
struct rfb_ptr_msg ptr_msg;
- (void)stream_read(cfd, ((void *)&ptr_msg) + 1, sizeof(ptr_msg) - 1);
+ (void)stream_read(cfd, (uint8_t *)&ptr_msg + 1, sizeof(ptr_msg) - 1);
console_ptr_event(ptr_msg.button, htons(ptr_msg.x), htons(ptr_msg.y));
rc->input_detected = true;
}
static void
-rfb_recv_cuttext_msg(struct rfb_softc *rc, int cfd)
+rfb_recv_cuttext_msg(struct rfb_softc *rc __unused, int cfd)
{
struct rfb_cuttext_msg ct_msg;
unsigned char buf[32];
int len;
- len = stream_read(cfd, ((void *)&ct_msg) + 1, sizeof(ct_msg) - 1);
+ len = stream_read(cfd, (uint8_t *)&ct_msg + 1, sizeof(ct_msg) - 1);
ct_msg.length = htonl(ct_msg.length);
while (ct_msg.length > 0) {
len = stream_read(cfd, buf, ct_msg.length > sizeof(buf) ?
@@ -854,12 +853,12 @@ rfb_wr_thr(void *arg)
return (NULL);
}
-void
+static void
rfb_handle(struct rfb_softc *rc, int cfd)
{
const char *vbuf = "RFB 003.008\n";
unsigned char buf[80];
- unsigned char *message = NULL;
+ unsigned const char *message;
#ifndef NO_OPENSSL
unsigned char challenge[AUTH_LENGTH];
@@ -883,9 +882,12 @@ rfb_handle(struct rfb_softc *rc, int cfd)
/* 1b. Read client version */
len = stream_read(cfd, buf, VERSION_LENGTH);
- if (len == VERSION_LENGTH && !strncmp(vbuf, buf, VERSION_LENGTH - 2)) {
- client_ver = buf[VERSION_LENGTH - 2];
+ if (len != VERSION_LENGTH ||
+ strncmp(vbuf, buf, VERSION_LENGTH - 2) != 0) {
+ goto done;
}
+
+ client_ver = buf[VERSION_LENGTH - 2];
if (client_ver != CVERS_3_8 && client_ver != CVERS_3_7) {
/* only recognize 3.3, 3.7 & 3.8. Others dflt to 3.3 */
client_ver = CVERS_3_3;
@@ -1130,7 +1132,7 @@ sse42_supported(void)
}
int
-rfb_init(char *hostname, int port, int wait, char *password)
+rfb_init(const char *hostname, int port, int wait, const char *password)
{
int e;
char servname[6];
diff --git a/usr.sbin/bhyve/rfb.h b/usr.sbin/bhyve/rfb.h
index dae43b2ec395..347ced083a22 100644
--- a/usr.sbin/bhyve/rfb.h
+++ b/usr.sbin/bhyve/rfb.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* 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 _RFB_H_
@@ -33,6 +31,7 @@
#define RFB_PORT 5900
-int rfb_init(char *hostname, int port, int wait, char *password);
+int rfb_init(const char *hostname, int port, int wait,
+ const char *password);
#endif /* _RFB_H_ */
diff --git a/usr.sbin/bhyve/rtc_pl031.c b/usr.sbin/bhyve/rtc_pl031.c
new file mode 100644
index 000000000000..e334de6f92bb
--- /dev/null
+++ b/usr.sbin/bhyve/rtc_pl031.c
@@ -0,0 +1,279 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Jessica Clarke <jrtc27@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+
+#include <assert.h>
+#include <limits.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "config.h"
+#include "mevent.h"
+#include "rtc_pl031.h"
+
+#define RTCDR 0x000
+#define RTCMR 0x004
+#define RTCLR 0x008
+#define RTCCR 0x00C
+#define RTCIMSC 0x010
+#define RTCRIS 0x014
+#define RTCMIS 0x018
+#define RTCICR 0x01C
+
+#define RTCPeriphID0 0xFE0
+#define RTCPeriphID1 0xFE4
+#define RTCPeriphID2 0xFE8
+#define RTCPeriphID3 0xFEC
+#define _RTCPeriphID_VAL 0x00141031
+#define RTCPeriphID_VAL(_n) ((_RTCPeriphID_VAL >> (8 * (_n))) & 0xff)
+
+#define RTCCellID0 0xFF0
+#define RTCCellID1 0xFF4
+#define RTCCellID2 0xFF8
+#define RTCCellID3 0xFFC
+#define _RTCCellID_VAL 0xb105f00d
+#define RTCCellID_VAL(_n) ((_RTCCellID_VAL >> (8 * (_n))) & 0xff)
+
+struct rtc_pl031_softc {
+ pthread_mutex_t mtx;
+
+ time_t last_tick;
+ uint32_t dr;
+ uint32_t mr;
+ uint32_t lr;
+ uint8_t imsc;
+ uint8_t ris;
+ uint8_t prev_mis;
+
+ struct mevent *mevp;
+
+ void *arg;
+ rtc_pl031_intr_func_t intr_assert;
+ rtc_pl031_intr_func_t intr_deassert;
+};
+
+static void rtc_pl031_callback(int fd, enum ev_type type, void *param);
+
+/*
+ * Returns the current RTC time as number of seconds since 00:00:00 Jan 1, 1970
+ */
+static time_t
+rtc_pl031_time(void)
+{
+ struct tm tm;
+ time_t t;
+
+ time(&t);
+ if (get_config_bool_default("rtc.use_localtime", false)) {
+ localtime_r(&t, &tm);
+ t = timegm(&tm);
+ }
+ return (t);
+}
+
+static void
+rtc_pl031_update_mis(struct rtc_pl031_softc *sc)
+{
+ uint8_t mis;
+
+ mis = sc->ris & sc->imsc;
+ if (mis == sc->prev_mis)
+ return;
+
+ sc->prev_mis = mis;
+ if (mis)
+ (*sc->intr_assert)(sc->arg);
+ else
+ (*sc->intr_deassert)(sc->arg);
+}
+
+static uint64_t
+rtc_pl031_next_match_ticks(struct rtc_pl031_softc *sc)
+{
+ uint32_t ticks;
+
+ ticks = sc->mr - sc->dr;
+ if (ticks == 0)
+ return ((uint64_t)1 << 32);
+
+ return (ticks);
+}
+
+static int
+rtc_pl031_next_timer_msecs(struct rtc_pl031_softc *sc)
+{
+ uint64_t ticks;
+
+ ticks = rtc_pl031_next_match_ticks(sc);
+ return (MIN(ticks * 1000, INT_MAX));
+}
+
+static void
+rtc_pl031_update_timer(struct rtc_pl031_softc *sc)
+{
+ mevent_timer_update(sc->mevp, rtc_pl031_next_timer_msecs(sc));
+}
+
+static void
+rtc_pl031_tick(struct rtc_pl031_softc *sc, bool from_timer)
+{
+ bool match;
+ time_t now, ticks;
+
+ now = rtc_pl031_time();
+ ticks = now - sc->last_tick;
+ match = ticks >= 0 &&
+ (uint64_t)ticks >= rtc_pl031_next_match_ticks(sc);
+ sc->dr += ticks;
+ sc->last_tick = now;
+
+ if (match) {
+ sc->ris = 1;
+ rtc_pl031_update_mis(sc);
+ }
+
+ if (match || from_timer || ticks < 0)
+ rtc_pl031_update_timer(sc);
+}
+
+static void
+rtc_pl031_callback(int fd __unused, enum ev_type type __unused, void *param)
+{
+ struct rtc_pl031_softc *sc = param;
+
+ pthread_mutex_lock(&sc->mtx);
+ rtc_pl031_tick(sc, true);
+ pthread_mutex_unlock(&sc->mtx);
+}
+
+void
+rtc_pl031_write(struct rtc_pl031_softc *sc, int offset, uint32_t value)
+{
+ pthread_mutex_lock(&sc->mtx);
+ rtc_pl031_tick(sc, false);
+ switch (offset) {
+ case RTCMR:
+ sc->mr = value;
+ rtc_pl031_update_timer(sc);
+ break;
+ case RTCLR:
+ sc->lr = value;
+ sc->dr = sc->lr;
+ rtc_pl031_update_timer(sc);
+ break;
+ case RTCIMSC:
+ sc->imsc = value & 1;
+ rtc_pl031_update_mis(sc);
+ break;
+ case RTCICR:
+ sc->ris &= ~value;
+ rtc_pl031_update_mis(sc);
+ break;
+ default:
+ /* Ignore writes to read-only/unassigned/ID registers */
+ break;
+ }
+ pthread_mutex_unlock(&sc->mtx);
+}
+
+uint32_t
+rtc_pl031_read(struct rtc_pl031_softc *sc, int offset)
+{
+ uint32_t reg;
+
+ pthread_mutex_lock(&sc->mtx);
+ rtc_pl031_tick(sc, false);
+ switch (offset) {
+ case RTCDR:
+ reg = sc->dr;
+ break;
+ case RTCMR:
+ reg = sc->mr;
+ break;
+ case RTCLR:
+ reg = sc->lr;
+ break;
+ case RTCCR:
+ /* RTC enabled from reset */
+ reg = 1;
+ break;
+ case RTCIMSC:
+ reg = sc->imsc;
+ break;
+ case RTCRIS:
+ reg = sc->ris;
+ break;
+ case RTCMIS:
+ reg = sc->ris & sc->imsc;
+ break;
+ case RTCPeriphID0:
+ case RTCPeriphID1:
+ case RTCPeriphID2:
+ case RTCPeriphID3:
+ reg = RTCPeriphID_VAL(offset - RTCPeriphID0);
+ break;
+ case RTCCellID0:
+ case RTCCellID1:
+ case RTCCellID2:
+ case RTCCellID3:
+ reg = RTCCellID_VAL(offset - RTCCellID0);
+ break;
+ default:
+ /* Return 0 in reads from unasigned registers */
+ reg = 0;
+ break;
+ }
+ pthread_mutex_unlock(&sc->mtx);
+
+ return (reg);
+}
+
+struct rtc_pl031_softc *
+rtc_pl031_init(rtc_pl031_intr_func_t intr_assert,
+ rtc_pl031_intr_func_t intr_deassert, void *arg)
+{
+ struct rtc_pl031_softc *sc;
+ time_t now;
+
+ sc = calloc(1, sizeof(struct rtc_pl031_softc));
+
+ pthread_mutex_init(&sc->mtx, NULL);
+
+ now = rtc_pl031_time();
+ sc->dr = now;
+ sc->last_tick = now;
+ sc->arg = arg;
+ sc->intr_assert = intr_assert;
+ sc->intr_deassert = intr_deassert;
+
+ sc->mevp = mevent_add(rtc_pl031_next_timer_msecs(sc), EVF_TIMER,
+ rtc_pl031_callback, sc);
+
+ return (sc);
+}
diff --git a/usr.sbin/bhyve/rtc_pl031.h b/usr.sbin/bhyve/rtc_pl031.h
new file mode 100644
index 000000000000..8e4ef685908a
--- /dev/null
+++ b/usr.sbin/bhyve/rtc_pl031.h
@@ -0,0 +1,40 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Jessica Clarke <jrtc27@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RTC_PL031_H_
+#define _RTC_PL031_H_
+
+struct rtc_pl031_softc;
+typedef void (*rtc_pl031_intr_func_t)(void *arg);
+
+struct rtc_pl031_softc *rtc_pl031_init(rtc_pl031_intr_func_t intr_assert,
+ rtc_pl031_intr_func_t intr_deassert, void *arg);
+void rtc_pl031_write(struct rtc_pl031_softc *sc, int offset,
+ uint32_t value);
+uint32_t rtc_pl031_read(struct rtc_pl031_softc *sc, int offset);
+
+#endif /* _RTC_PL031_H_ */
diff --git a/usr.sbin/bhyve/smbiostbl.c b/usr.sbin/bhyve/smbiostbl.c
index 2dc50e6e6f01..e09fbc95fc9e 100644
--- a/usr.sbin/bhyve/smbiostbl.c
+++ b/usr.sbin/bhyve/smbiostbl.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <assert.h>
@@ -76,14 +73,19 @@ struct smbios_structure {
uint16_t handle;
} __packed;
-typedef int (*initializer_func_t)(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size);
+struct smbios_string {
+ const char *node;
+ const char *value;
+};
+
+typedef int (*initializer_func_t)(const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n);
struct smbios_template_entry {
- struct smbios_structure *entry;
- const char **strings;
- initializer_func_t initializer;
+ const struct smbios_structure *entry;
+ const struct smbios_string *strings;
+ initializer_func_t initializer;
};
/*
@@ -334,7 +336,7 @@ struct smbios_table_type127 {
struct smbios_structure header;
} __packed;
-struct smbios_table_type0 smbios_type0_template = {
+static const struct smbios_table_type0 smbios_type0_template = {
{ SMBIOS_TYPE_BIOS, sizeof (struct smbios_table_type0), 0 },
1, /* bios vendor string */
2, /* bios version string */
@@ -350,14 +352,14 @@ struct smbios_table_type0 smbios_type0_template = {
0xff /* embedded controller firmware minor release */
};
-const char *smbios_type0_strings[] = {
- "BHYVE", /* vendor string */
- FIRMWARE_VERSION, /* bios version string */
- FIRMWARE_RELEASE_DATE, /* bios release date string */
- NULL
+static const struct smbios_string smbios_type0_strings[] = {
+ { "bios.vendor", "BHYVE" }, /* vendor string */
+ { "bios.version", FIRMWARE_VERSION }, /* bios version string */
+ { "bios.release_date", FIRMWARE_RELEASE_DATE }, /* bios release date string */
+ { 0 }
};
-struct smbios_table_type1 smbios_type1_template = {
+static const struct smbios_table_type1 smbios_type1_template = {
{ SMBIOS_TYPE_SYSTEM, sizeof (struct smbios_table_type1), 0 },
1, /* manufacturer string */
2, /* product string */
@@ -369,21 +371,21 @@ struct smbios_table_type1 smbios_type1_template = {
6 /* family string */
};
-static int smbios_type1_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size);
-
-const char *smbios_type1_strings[] = {
- "FreeBSD", /* manufacturer string */
- "BHYVE", /* product name string */
- "1.0", /* version string */
- "None", /* serial number string */
- "None", /* sku string */
- "Virtual Machine", /* family name string */
- NULL
+static int smbios_type1_initializer(const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n);
+
+static const struct smbios_string smbios_type1_strings[] = {
+ { "system.manufacturer", "FreeBSD" }, /* manufacturer string */
+ { "system.product_name", "BHYVE" }, /* product string */
+ { "system.version", "1.0" }, /* version string */
+ { "system.serial_number", "None" }, /* serial number string */
+ { "system.sku", "None" }, /* sku string */
+ { "system.family_name", "Virtual Machine" }, /* family string */
+ { 0 }
};
-struct smbios_table_type2 smbios_type2_template = {
+static const struct smbios_table_type2 smbios_type2_template = {
{ SMBIOS_TYPE_BOARD, sizeof (struct smbios_table_type2), 0 },
1, /* manufacturer string */
2, /* product string */
@@ -397,17 +399,17 @@ struct smbios_table_type2 smbios_type2_template = {
0
};
-const char *smbios_type2_strings[] = {
- "FreeBSD", /* manufacturer string */
- "BHYVE", /* product name string */
- "1.0", /* version string */
- "None", /* serial number string */
- "None", /* asset tag string */
- "None", /* location string */
- NULL
+static const struct smbios_string smbios_type2_strings[] = {
+ { "board.manufacturer", "FreeBSD" }, /* manufacturer string */
+ { "board.product_name", "BHYVE" }, /* product name string */
+ { "board.version", "1.0" }, /* version string */
+ { "board.serial_number", "None" }, /* serial number string */
+ { "board.asset_tag", "None" }, /* asset tag string */
+ { "board.location", "None" }, /* location string */
+ { 0 }
};
-struct smbios_table_type3 smbios_type3_template = {
+static const struct smbios_table_type3 smbios_type3_template = {
{ SMBIOS_TYPE_CHASSIS, sizeof (struct smbios_table_type3), 0 },
1, /* manufacturer string */
SMBIOS_CHT_UNKNOWN,
@@ -426,16 +428,16 @@ struct smbios_table_type3 smbios_type3_template = {
5 /* sku number string */
};
-const char *smbios_type3_strings[] = {
- "FreeBSD", /* manufacturer string */
- "1.0", /* version string */
- "None", /* serial number string */
- "None", /* asset tag string */
- "None", /* sku number string */
- NULL
+static const struct smbios_string smbios_type3_strings[] = {
+ { "chassis.manufacturer", "FreeBSD" }, /* manufacturer string */
+ { "chassis.version", "1.0" }, /* version string */
+ { "chassis.serial_number", "None" }, /* serial number string */
+ { "chassis.asset_tag", "None" }, /* asset tag string */
+ { "chassis.sku", "None" }, /* sku number string */
+ { 0 }
};
-struct smbios_table_type4 smbios_type4_template = {
+static const struct smbios_table_type4 smbios_type4_template = {
{ SMBIOS_TYPE_PROCESSOR, sizeof (struct smbios_table_type4), 0 },
1, /* socket designation string */
SMBIOS_PRT_CENTRAL,
@@ -462,21 +464,22 @@ struct smbios_table_type4 smbios_type4_template = {
SMBIOS_PRF_OTHER
};
-const char *smbios_type4_strings[] = {
- " ", /* socket designation string */
- " ", /* manufacturer string */
- " ", /* version string */
- "None", /* serial number string */
- "None", /* asset tag string */
- "None", /* part number string */
- NULL
+static const struct smbios_string smbios_type4_strings[] = {
+ { NULL, " " }, /* socket designation string */
+ { NULL, " " }, /* manufacturer string */
+ { NULL, " " }, /* version string */
+ { NULL, "None" }, /* serial number string */
+ { NULL, "None" }, /* asset tag string */
+ { NULL, "None" }, /* part number string */
+ { 0 }
};
-static int smbios_type4_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size);
+static int smbios_type4_initializer(
+ const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n);
-struct smbios_table_type16 smbios_type16_template = {
+static const struct smbios_table_type16 smbios_type16_template = {
{ SMBIOS_TYPE_MEMARRAY, sizeof (struct smbios_table_type16), 0 },
SMBIOS_MAL_SYSMB,
SMBIOS_MAU_SYSTEM,
@@ -487,11 +490,12 @@ struct smbios_table_type16 smbios_type16_template = {
0 /* extended maximum memory capacity in bytes (TBD) */
};
-static int smbios_type16_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size);
+static int smbios_type16_initializer(
+ const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n);
-struct smbios_table_type17 smbios_type17_template = {
+static const struct smbios_table_type17 smbios_type17_template = {
{ SMBIOS_TYPE_MEMDEVICE, sizeof (struct smbios_table_type17), 0 },
-1, /* handle of physical memory array */
-1, /* handle of memory error data */
@@ -517,21 +521,22 @@ struct smbios_table_type17 smbios_type17_template = {
0 /* configured voltage in mv (0=unknown) */
};
-const char *smbios_type17_strings[] = {
- " ", /* device locator string */
- " ", /* physical bank locator string */
- " ", /* manufacturer string */
- "None", /* serial number string */
- "None", /* asset tag string */
- "None", /* part number string */
- NULL
+static const struct smbios_string smbios_type17_strings[] = {
+ { NULL, " " }, /* device locator string */
+ { NULL, " " }, /* physical bank locator string */
+ { NULL, " " }, /* manufacturer string */
+ { NULL, "None" }, /* serial number string */
+ { NULL, "None" }, /* asset tag string */
+ { NULL, "None" }, /* part number string */
+ { 0 }
};
-static int smbios_type17_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size);
+static int smbios_type17_initializer(
+ const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n);
-struct smbios_table_type19 smbios_type19_template = {
+static const struct smbios_table_type19 smbios_type19_template = {
{ SMBIOS_TYPE_MEMARRAYMAP, sizeof (struct smbios_table_type19), 0 },
0xffffffff, /* starting phys addr in kb (0xffffffff=use ext) */
0xffffffff, /* ending phys addr in kb (0xffffffff=use ext) */
@@ -541,65 +546,67 @@ struct smbios_table_type19 smbios_type19_template = {
0 /* extended ending phys addr in bytes (TDB) */
};
-static int smbios_type19_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size);
+static int smbios_type19_initializer(
+ const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n);
-struct smbios_table_type32 smbios_type32_template = {
+static struct smbios_table_type32 smbios_type32_template = {
{ SMBIOS_TYPE_BOOT, sizeof (struct smbios_table_type32), 0 },
{ 0, 0, 0, 0, 0, 0 },
SMBIOS_BOOT_NORMAL
};
-struct smbios_table_type127 smbios_type127_template = {
+static const struct smbios_table_type127 smbios_type127_template = {
{ SMBIOS_TYPE_EOT, sizeof (struct smbios_table_type127), 0 }
};
-static int smbios_generic_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size);
+static int smbios_generic_initializer(
+ const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n);
static struct smbios_template_entry smbios_template[] = {
- { (struct smbios_structure *)&smbios_type0_template,
+ { (const struct smbios_structure *)&smbios_type0_template,
smbios_type0_strings,
smbios_generic_initializer },
- { (struct smbios_structure *)&smbios_type1_template,
+ { (const struct smbios_structure *)&smbios_type1_template,
smbios_type1_strings,
smbios_type1_initializer },
- { (struct smbios_structure *)&smbios_type2_template,
+ { (const struct smbios_structure *)&smbios_type2_template,
smbios_type2_strings,
smbios_generic_initializer },
- { (struct smbios_structure *)&smbios_type3_template,
+ { (const struct smbios_structure *)&smbios_type3_template,
smbios_type3_strings,
smbios_generic_initializer },
- { (struct smbios_structure *)&smbios_type4_template,
+ { (const struct smbios_structure *)&smbios_type4_template,
smbios_type4_strings,
smbios_type4_initializer },
- { (struct smbios_structure *)&smbios_type16_template,
+ { (const struct smbios_structure *)&smbios_type16_template,
NULL,
smbios_type16_initializer },
- { (struct smbios_structure *)&smbios_type17_template,
+ { (const struct smbios_structure *)&smbios_type17_template,
smbios_type17_strings,
smbios_type17_initializer },
- { (struct smbios_structure *)&smbios_type19_template,
+ { (const struct smbios_structure *)&smbios_type19_template,
NULL,
smbios_type19_initializer },
- { (struct smbios_structure *)&smbios_type32_template,
+ { (const struct smbios_structure *)&smbios_type32_template,
NULL,
smbios_generic_initializer },
- { (struct smbios_structure *)&smbios_type127_template,
+ { (const struct smbios_structure *)&smbios_type127_template,
NULL,
smbios_generic_initializer },
{ NULL,NULL, NULL }
};
-static uint64_t guest_lomem, guest_himem;
+static uint64_t guest_lomem, guest_himem, guest_himem_base;
static uint16_t type16_handle;
static int
-smbios_generic_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size)
+smbios_generic_initializer(const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n)
{
struct smbios_structure *entry;
@@ -610,11 +617,20 @@ smbios_generic_initializer(struct smbios_structure *template_entry,
if (template_strings != NULL) {
int i;
- for (i = 0; template_strings[i] != NULL; i++) {
+ for (i = 0; template_strings[i].value != NULL; i++) {
const char *string;
int len;
- string = template_strings[i];
+ if (template_strings[i].node == NULL) {
+ string = template_strings[i].value;
+ } else {
+ set_config_value_if_unset(
+ template_strings[i].node,
+ template_strings[i].value);
+ string = get_config_value(
+ template_strings[i].node);
+ }
+
len = strlen(string) + 1;
memcpy(curaddr, string, len);
curaddr += len;
@@ -635,15 +651,15 @@ smbios_generic_initializer(struct smbios_structure *template_entry,
}
static int
-smbios_type1_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size)
+smbios_type1_initializer(const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n)
{
struct smbios_table_type1 *type1;
const char *guest_uuid_str;
smbios_generic_initializer(template_entry, template_strings,
- curaddr, endaddr, n, size);
+ curaddr, endaddr, n);
type1 = (struct smbios_table_type1 *)curaddr;
guest_uuid_str = get_config_value("uuid");
@@ -652,8 +668,10 @@ smbios_type1_initializer(struct smbios_structure *template_entry,
uint32_t status;
uuid_from_string(guest_uuid_str, &uuid, &status);
- if (status != uuid_s_ok)
+ if (status != uuid_s_ok) {
+ EPRINTLN("Invalid UUID");
return (-1);
+ }
uuid_enc_le(&type1->uuid, &uuid);
} else {
@@ -691,19 +709,19 @@ smbios_type1_initializer(struct smbios_structure *template_entry,
}
static int
-smbios_type4_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size)
+smbios_type4_initializer(const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n)
{
int i;
- for (i = 0; i < sockets; i++) {
+ for (i = 0; i < cpu_sockets; i++) {
struct smbios_table_type4 *type4;
char *p;
int nstrings, len;
smbios_generic_initializer(template_entry, template_strings,
- curaddr, endaddr, n, size);
+ curaddr, endaddr, n);
type4 = (struct smbios_table_type4 *)curaddr;
p = curaddr + sizeof (struct smbios_table_type4);
nstrings = 0;
@@ -717,15 +735,15 @@ smbios_type4_initializer(struct smbios_structure *template_entry,
(*endaddr)++;
type4->socket = nstrings + 1;
/* Revise cores and threads after update to smbios 3.0 */
- if (cores > 254)
+ if (cpu_cores > 254)
type4->cores = 0;
else
- type4->cores = cores;
+ type4->cores = cpu_cores;
/* This threads is total threads in a socket */
- if ((cores * threads) > 254)
+ if (cpu_cores * cpu_threads > 254)
type4->threads = 0;
else
- type4->threads = (cores * threads);
+ type4->threads = cpu_cores * cpu_threads;
curaddr = *endaddr;
}
@@ -733,15 +751,15 @@ smbios_type4_initializer(struct smbios_structure *template_entry,
}
static int
-smbios_type16_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size)
+smbios_type16_initializer(const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n)
{
struct smbios_table_type16 *type16;
type16_handle = *n;
smbios_generic_initializer(template_entry, template_strings,
- curaddr, endaddr, n, size);
+ curaddr, endaddr, n);
type16 = (struct smbios_table_type16 *)curaddr;
type16->xsize = guest_lomem + guest_himem;
type16->ndevs = guest_himem > 0 ? 2 : 1;
@@ -750,15 +768,15 @@ smbios_type16_initializer(struct smbios_structure *template_entry,
}
static int
-smbios_type17_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size)
+smbios_type17_initializer(const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n)
{
struct smbios_table_type17 *type17;
uint64_t memsize, size_KB, size_MB;
smbios_generic_initializer(template_entry, template_strings,
- curaddr, endaddr, n, size);
+ curaddr, endaddr, n);
type17 = (struct smbios_table_type17 *)curaddr;
type17->arrayhand = type16_handle;
@@ -794,14 +812,14 @@ smbios_type17_initializer(struct smbios_structure *template_entry,
}
static int
-smbios_type19_initializer(struct smbios_structure *template_entry,
- const char **template_strings, char *curaddr, char **endaddr,
- uint16_t *n, uint16_t *size)
+smbios_type19_initializer(const struct smbios_structure *template_entry,
+ const struct smbios_string *template_strings, char *curaddr, char **endaddr,
+ uint16_t *n)
{
struct smbios_table_type19 *type19;
smbios_generic_initializer(template_entry, template_strings,
- curaddr, endaddr, n, size);
+ curaddr, endaddr, n);
type19 = (struct smbios_table_type19 *)curaddr;
type19->arrayhand = type16_handle;
type19->xsaddr = 0;
@@ -810,11 +828,11 @@ smbios_type19_initializer(struct smbios_structure *template_entry,
if (guest_himem > 0) {
curaddr = *endaddr;
smbios_generic_initializer(template_entry, template_strings,
- curaddr, endaddr, n, size);
+ curaddr, endaddr, n);
type19 = (struct smbios_table_type19 *)curaddr;
type19->arrayhand = type16_handle;
- type19->xsaddr = 4*GB;
- type19->xeaddr = type19->xsaddr + guest_himem;
+ type19->xsaddr = guest_himem_base;
+ type19->xeaddr = guest_himem_base + guest_himem;
}
return (0);
@@ -873,6 +891,7 @@ smbios_build(struct vmctx *ctx)
guest_lomem = vm_get_lowmem_size(ctx);
guest_himem = vm_get_highmem_size(ctx);
+ guest_himem_base = vm_get_highmem_base(ctx);
startaddr = paddr_guest2host(ctx, SMBIOS_BASE, SMBIOS_MAX_LENGTH);
if (startaddr == NULL) {
@@ -891,24 +910,24 @@ smbios_build(struct vmctx *ctx)
n = 0;
maxssize = 0;
for (i = 0; smbios_template[i].entry != NULL; i++) {
- struct smbios_structure *entry;
- const char **strings;
+ const struct smbios_structure *entry;
+ const struct smbios_string *strings;
initializer_func_t initializer;
char *endaddr;
- uint16_t size;
+ size_t size;
entry = smbios_template[i].entry;
strings = smbios_template[i].strings;
initializer = smbios_template[i].initializer;
- err = (*initializer)(entry, strings, curaddr, &endaddr,
- &n, &size);
+ err = (*initializer)(entry, strings, curaddr, &endaddr, &n);
if (err != 0)
return (err);
+ size = endaddr - curaddr;
+ assert(size <= UINT16_MAX);
if (size > maxssize)
- maxssize = size;
-
+ maxssize = (uint16_t)size;
curaddr = endaddr;
}
diff --git a/usr.sbin/bhyve/smbiostbl.h b/usr.sbin/bhyve/smbiostbl.h
index 027f600e09a9..4725354f60f8 100644
--- a/usr.sbin/bhyve/smbiostbl.h
+++ b/usr.sbin/bhyve/smbiostbl.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* 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 _SMBIOSTBL_H_
diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c
index 37486ba368e3..997faa254284 100644
--- a/usr.sbin/bhyve/snapshot.c
+++ b/usr.sbin/bhyve/snapshot.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 Flavius Anton
* Copyright (c) 2016 Mihai Tiganus
@@ -33,9 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#ifndef WITHOUT_CAPSICUM
#include <sys/capsicum.h>
@@ -46,9 +43,6 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <sys/un.h>
-#include <machine/atomic.h>
-#include <machine/segments.h>
-
#ifndef WITHOUT_CAPSICUM
#include <capsicum_helpers.h>
#endif
@@ -78,23 +72,14 @@ __FBSDID("$FreeBSD$");
#include "bhyverun.h"
#include "acpi.h"
-#include "atkbdc.h"
+#ifdef __amd64__
+#include "amd64/atkbdc.h"
+#endif
#include "debug.h"
-#include "inout.h"
#include "ipc.h"
-#include "fwctl.h"
-#include "ioapic.h"
#include "mem.h"
-#include "mevent.h"
-#include "mptbl.h"
#include "pci_emul.h"
-#include "pci_irq.h"
-#include "pci_lpc.h"
-#include "smbiostbl.h"
#include "snapshot.h"
-#include "xmsr.h"
-#include "spinup_ap.h"
-#include "rtc.h"
#include <libxo/xo.h>
#include <ucl.h>
@@ -117,12 +102,12 @@ static sig_t old_winch_handler;
#define SNAPSHOT_CHUNK (4 * MB)
#define PROG_BUF_SZ (8192)
-#define SNAPSHOT_BUFFER_SIZE (20 * MB)
+#define SNAPSHOT_BUFFER_SIZE (40 * MB)
-#define JSON_STRUCT_ARR_KEY "structs"
+#define JSON_KERNEL_ARR_KEY "kern_structs"
#define JSON_DEV_ARR_KEY "devices"
#define JSON_BASIC_METADATA_KEY "basic metadata"
-#define JSON_SNAPSHOT_REQ_KEY "snapshot_req"
+#define JSON_SNAPSHOT_REQ_KEY "device"
#define JSON_SIZE_KEY "size"
#define JSON_FILE_OFFSET_KEY "file_offset"
@@ -138,24 +123,9 @@ static sig_t old_winch_handler;
_a < _b ? _a : _b; \
})
-const struct vm_snapshot_dev_info snapshot_devs[] = {
- { "atkbdc", atkbdc_snapshot, NULL, NULL },
- { "virtio-net", pci_snapshot, pci_pause, pci_resume },
- { "virtio-blk", pci_snapshot, pci_pause, pci_resume },
- { "virtio-rnd", pci_snapshot, NULL, NULL },
- { "lpc", pci_snapshot, NULL, NULL },
- { "fbuf", pci_snapshot, NULL, NULL },
- { "xhci", pci_snapshot, NULL, NULL },
- { "e1000", pci_snapshot, NULL, NULL },
- { "ahci", pci_snapshot, pci_pause, pci_resume },
- { "ahci-hd", pci_snapshot, pci_pause, pci_resume },
- { "ahci-cd", pci_snapshot, pci_pause, pci_resume },
-};
-
-const struct vm_snapshot_kern_info snapshot_kern_structs[] = {
+static const struct vm_snapshot_kern_info snapshot_kern_structs[] = {
{ "vhpet", STRUCT_VHPET },
{ "vm", STRUCT_VM },
- { "vmx", STRUCT_VMX },
{ "vioapic", STRUCT_VIOAPIC },
{ "vlapic", STRUCT_VLAPIC },
{ "vmcx", STRUCT_VMCX },
@@ -166,8 +136,9 @@ const struct vm_snapshot_kern_info snapshot_kern_structs[] = {
};
static cpuset_t vcpus_active, vcpus_suspended;
-static pthread_mutex_t vcpu_lock;
-static pthread_cond_t vcpus_idle, vcpus_can_run;
+static pthread_mutex_t vcpu_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t vcpus_idle = PTHREAD_COND_INITIALIZER;
+static pthread_cond_t vcpus_can_run = PTHREAD_COND_INITIALIZER;
static bool checkpoint_active;
/*
@@ -184,13 +155,13 @@ strcat_extension(const char *base_str, const char *ext)
ext_len = strnlen(ext, NAME_MAX);
if (base_len + ext_len > NAME_MAX) {
- fprintf(stderr, "Filename exceeds maximum length.\n");
+ EPRINTLN("Filename exceeds maximum length.");
return (NULL);
}
res = malloc(base_len + ext_len + 1);
if (res == NULL) {
- perror("Failed to allocate memory.");
+ EPRINTLN("Failed to allocate memory: %s", strerror(errno));
return (NULL);
}
@@ -205,7 +176,7 @@ void
destroy_restore_state(struct restore_state *rstate)
{
if (rstate == NULL) {
- fprintf(stderr, "Attempting to destroy NULL restore struct.\n");
+ EPRINTLN("Attempting to destroy NULL restore struct.");
return;
}
@@ -298,13 +269,14 @@ err_load_kdata:
static int
load_metadata_file(const char *filename, struct restore_state *rstate)
{
- const ucl_object_t *obj;
+ ucl_object_t *obj;
struct ucl_parser *parser;
int err;
parser = ucl_parser_new(UCL_PARSER_DEFAULT);
if (parser == NULL) {
fprintf(stderr, "Failed to initialize UCL parser.\n");
+ err = -1;
goto err_load_metadata;
}
@@ -416,50 +388,6 @@ do { \
} while(0)
static void *
-lookup_struct(enum snapshot_req struct_id, struct restore_state *rstate,
- size_t *struct_size)
-{
- const ucl_object_t *structs = NULL, *obj = NULL;
- ucl_object_iter_t it = NULL;
- int64_t snapshot_req, size, file_offset;
-
- structs = ucl_object_lookup(rstate->meta_root_obj, JSON_STRUCT_ARR_KEY);
- if (structs == NULL) {
- fprintf(stderr, "Failed to find '%s' object.\n",
- JSON_STRUCT_ARR_KEY);
- return (NULL);
- }
-
- if (ucl_object_type((ucl_object_t *)structs) != UCL_ARRAY) {
- fprintf(stderr, "Object '%s' is not an array.\n",
- JSON_STRUCT_ARR_KEY);
- return (NULL);
- }
-
- while ((obj = ucl_object_iterate(structs, &it, true)) != NULL) {
- snapshot_req = -1;
- JSON_GET_INT_OR_RETURN(JSON_SNAPSHOT_REQ_KEY, obj,
- &snapshot_req, NULL);
- assert(snapshot_req >= 0);
- if ((enum snapshot_req) snapshot_req == struct_id) {
- JSON_GET_INT_OR_RETURN(JSON_SIZE_KEY, obj,
- &size, NULL);
- assert(size >= 0);
-
- JSON_GET_INT_OR_RETURN(JSON_FILE_OFFSET_KEY, obj,
- &file_offset, NULL);
- assert(file_offset >= 0);
- assert(file_offset + size <= rstate->kdata_len);
-
- *struct_size = (size_t)size;
- return (rstate->kdata_map + file_offset);
- }
- }
-
- return (NULL);
-}
-
-static void *
lookup_check_dev(const char *dev_name, struct restore_state *rstate,
const ucl_object_t *obj, size_t *data_size)
{
@@ -478,31 +406,31 @@ lookup_check_dev(const char *dev_name, struct restore_state *rstate,
JSON_GET_INT_OR_RETURN(JSON_FILE_OFFSET_KEY, obj,
&file_offset, NULL);
assert(file_offset >= 0);
- assert(file_offset + size <= rstate->kdata_len);
+ assert((uint64_t)file_offset + size <= rstate->kdata_len);
*data_size = (size_t)size;
- return (rstate->kdata_map + file_offset);
+ return ((uint8_t *)rstate->kdata_map + file_offset);
}
return (NULL);
}
-static void*
-lookup_dev(const char *dev_name, struct restore_state *rstate,
- size_t *data_size)
+static void *
+lookup_dev(const char *dev_name, const char *key, struct restore_state *rstate,
+ size_t *data_size)
{
const ucl_object_t *devs = NULL, *obj = NULL;
ucl_object_iter_t it = NULL;
void *ret;
- devs = ucl_object_lookup(rstate->meta_root_obj, JSON_DEV_ARR_KEY);
+ devs = ucl_object_lookup(rstate->meta_root_obj, key);
if (devs == NULL) {
fprintf(stderr, "Failed to find '%s' object.\n",
JSON_DEV_ARR_KEY);
return (NULL);
}
- if (ucl_object_type((ucl_object_t *)devs) != UCL_ARRAY) {
+ if (ucl_object_type(devs) != UCL_ARRAY) {
fprintf(stderr, "Object '%s' is not an array.\n",
JSON_DEV_ARR_KEY);
return (NULL);
@@ -530,7 +458,7 @@ lookup_basic_metadata_object(struct restore_state *rstate)
return (NULL);
}
- if (ucl_object_type((ucl_object_t *)basic_meta_obj) != UCL_OBJECT) {
+ if (ucl_object_type(basic_meta_obj) != UCL_OBJECT) {
fprintf(stderr, "Object '%s' is not a JSON object.\n",
JSON_BASIC_METADATA_KEY);
return (NULL);
@@ -601,7 +529,7 @@ lookup_guest_ncpus(struct restore_state *rstate)
}
static void
-winch_handler(int signal)
+winch_handler(int signal __unused)
{
#ifdef TIOCGWINSZ
ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize);
@@ -620,7 +548,7 @@ print_progress(size_t crtval, const size_t maxval)
static const size_t len = sizeof(prog_buf);
static size_t div;
- static char *div_str;
+ static const char *div_str;
static char wip_bar[] = { '/', '-', '\\', '|' };
static int wip_idx = 0;
@@ -777,7 +705,7 @@ vm_snapshot_mem_part(const int snapfd, const size_t foff, void *src,
return (-1);
}
- src += done;
+ src = (uint8_t *)src + done;
part_done += done;
rem -= done;
}
@@ -830,8 +758,8 @@ vm_snapshot_mem(struct vmctx *ctx, int snapfd, size_t memsz, const bool op_wr)
if (highmem == 0)
goto done;
- ret = vm_snapshot_mem_part(snapfd, lowmem, baseaddr + 4*GB,
- highmem, totalmem, op_wr);
+ ret = vm_snapshot_mem_part(snapfd, lowmem,
+ baseaddr + vm_get_highmem_base(ctx), highmem, totalmem, op_wr);
if (ret) {
fprintf(stderr, "%s: Could not %s highmem\r\n",
__func__, op_wr ? "write" : "read");
@@ -860,97 +788,69 @@ restore_vm_mem(struct vmctx *ctx, struct restore_state *rstate)
return (0);
}
-static int
-vm_restore_kern_struct(struct vmctx *ctx, struct restore_state *rstate,
- const struct vm_snapshot_kern_info *info)
+int
+vm_restore_kern_structs(struct vmctx *ctx, struct restore_state *rstate)
{
- void *struct_ptr;
- size_t struct_size;
- int ret;
- struct vm_snapshot_meta *meta;
-
- struct_ptr = lookup_struct(info->req, rstate, &struct_size);
- if (struct_ptr == NULL) {
- fprintf(stderr, "%s: Failed to lookup struct %s\r\n",
- __func__, info->struct_name);
- ret = -1;
- goto done;
- }
-
- if (struct_size == 0) {
- fprintf(stderr, "%s: Kernel struct size was 0 for: %s\r\n",
- __func__, info->struct_name);
- ret = -1;
- goto done;
- }
+ for (unsigned i = 0; i < nitems(snapshot_kern_structs); i++) {
+ const struct vm_snapshot_kern_info *info;
+ struct vm_snapshot_meta *meta;
+ void *data;
+ size_t size;
- meta = &(struct vm_snapshot_meta) {
- .ctx = ctx,
- .dev_name = info->struct_name,
- .dev_req = info->req,
+ info = &snapshot_kern_structs[i];
+ data = lookup_dev(info->struct_name, JSON_KERNEL_ARR_KEY, rstate, &size);
+ if (data == NULL)
+ errx(EX_DATAERR, "Cannot find kern struct %s",
+ info->struct_name);
- .buffer.buf_start = struct_ptr,
- .buffer.buf_size = struct_size,
+ if (size == 0)
+ errx(EX_DATAERR, "data with zero size for %s",
+ info->struct_name);
- .buffer.buf = struct_ptr,
- .buffer.buf_rem = struct_size,
+ meta = &(struct vm_snapshot_meta) {
+ .dev_name = info->struct_name,
+ .dev_req = info->req,
- .op = VM_SNAPSHOT_RESTORE,
- };
+ .buffer.buf_start = data,
+ .buffer.buf_size = size,
- ret = vm_snapshot_req(meta);
- if (ret != 0) {
- fprintf(stderr, "%s: Failed to restore struct: %s\r\n",
- __func__, info->struct_name);
- goto done;
- }
+ .buffer.buf = data,
+ .buffer.buf_rem = size,
-done:
- return (ret);
-}
-
-int
-vm_restore_kern_structs(struct vmctx *ctx, struct restore_state *rstate)
-{
- int ret;
- int i;
+ .op = VM_SNAPSHOT_RESTORE,
+ };
- for (i = 0; i < nitems(snapshot_kern_structs); i++) {
- ret = vm_restore_kern_struct(ctx, rstate,
- &snapshot_kern_structs[i]);
- if (ret != 0)
- return (ret);
+ if (vm_snapshot_req(ctx, meta))
+ err(EX_DATAERR, "Failed to restore %s",
+ info->struct_name);
}
-
return (0);
}
-int
-vm_restore_user_dev(struct vmctx *ctx, struct restore_state *rstate,
- const struct vm_snapshot_dev_info *info)
+static int
+vm_restore_device(struct restore_state *rstate, vm_snapshot_dev_cb func,
+ const char *name, void *data)
{
void *dev_ptr;
size_t dev_size;
int ret;
struct vm_snapshot_meta *meta;
- dev_ptr = lookup_dev(info->dev_name, rstate, &dev_size);
+ dev_ptr = lookup_dev(name, JSON_DEV_ARR_KEY, rstate, &dev_size);
+
if (dev_ptr == NULL) {
- fprintf(stderr, "Failed to lookup dev: %s\r\n", info->dev_name);
- fprintf(stderr, "Continuing the restore/migration process\r\n");
- return (0);
+ EPRINTLN("Failed to lookup dev: %s", name);
+ return (EINVAL);
}
if (dev_size == 0) {
- fprintf(stderr, "%s: Device size is 0. "
- "Assuming %s is not used\r\n",
- __func__, info->dev_name);
- return (0);
+ EPRINTLN("Restore device size is 0: %s", name);
+ return (EINVAL);
}
meta = &(struct vm_snapshot_meta) {
- .ctx = ctx,
- .dev_name = info->dev_name,
+ .dev_name = name,
+ .dev_data = data,
.buffer.buf_start = dev_ptr,
.buffer.buf_size = dev_size,
@@ -961,81 +861,78 @@ vm_restore_user_dev(struct vmctx *ctx, struct restore_state *rstate,
.op = VM_SNAPSHOT_RESTORE,
};
- ret = (*info->snapshot_cb)(meta);
+ ret = func(meta);
if (ret != 0) {
- fprintf(stderr, "Failed to restore dev: %s\r\n",
- info->dev_name);
- return (-1);
+ EPRINTLN("Failed to restore dev: %s %d", name, ret);
+ return (ret);
}
return (0);
}
-
int
-vm_restore_user_devs(struct vmctx *ctx, struct restore_state *rstate)
+vm_restore_devices(struct restore_state *rstate)
{
int ret;
- int i;
+ struct pci_devinst *pdi = NULL;
- for (i = 0; i < nitems(snapshot_devs); i++) {
- ret = vm_restore_user_dev(ctx, rstate, &snapshot_devs[i]);
- if (ret != 0)
+ while ((pdi = pci_next(pdi)) != NULL) {
+ ret = vm_restore_device(rstate, pci_snapshot, pdi->pi_name, pdi);
+ if (ret)
return (ret);
}
- return 0;
+#ifdef __amd64__
+ ret = vm_restore_device(rstate, atkbdc_snapshot, "atkbdc", NULL);
+#else
+ ret = 0;
+#endif
+ return (ret);
}
int
-vm_pause_user_devs(struct vmctx *ctx)
+vm_pause_devices(void)
{
- const struct vm_snapshot_dev_info *info;
int ret;
- int i;
-
- for (i = 0; i < nitems(snapshot_devs); i++) {
- info = &snapshot_devs[i];
- if (info->pause_cb == NULL)
- continue;
+ struct pci_devinst *pdi = NULL;
- ret = info->pause_cb(ctx, info->dev_name);
- if (ret != 0)
+ while ((pdi = pci_next(pdi)) != NULL) {
+ ret = pci_pause(pdi);
+ if (ret) {
+ EPRINTLN("Cannot pause dev %s: %d", pdi->pi_name, ret);
return (ret);
+ }
}
return (0);
}
int
-vm_resume_user_devs(struct vmctx *ctx)
+vm_resume_devices(void)
{
- const struct vm_snapshot_dev_info *info;
int ret;
- int i;
-
- for (i = 0; i < nitems(snapshot_devs); i++) {
- info = &snapshot_devs[i];
- if (info->resume_cb == NULL)
- continue;
+ struct pci_devinst *pdi = NULL;
- ret = info->resume_cb(ctx, info->dev_name);
- if (ret != 0)
+ while ((pdi = pci_next(pdi)) != NULL) {
+ ret = pci_resume(pdi);
+ if (ret) {
+ EPRINTLN("Cannot resume '%s': %d", pdi->pi_name, ret);
return (ret);
+ }
}
return (0);
}
static int
-vm_snapshot_kern_struct(int data_fd, xo_handle_t *xop, const char *array_key,
- struct vm_snapshot_meta *meta, off_t *offset)
+vm_save_kern_struct(struct vmctx *ctx, int data_fd, xo_handle_t *xop,
+ const char *array_key, struct vm_snapshot_meta *meta, off_t *offset)
{
int ret;
size_t data_size;
ssize_t write_cnt;
- ret = vm_snapshot_req(meta);
+ ret = vm_snapshot_req(ctx, meta);
if (ret != 0) {
fprintf(stderr, "%s: Failed to snapshot struct %s\r\n",
__func__, meta->dev_name);
@@ -1045,8 +942,9 @@ vm_snapshot_kern_struct(int data_fd, xo_handle_t *xop, const char *array_key,
data_size = vm_get_snapshot_size(meta);
+ /* XXX-MJ no handling for short writes. */
write_cnt = write(data_fd, meta->buffer.buf_start, data_size);
- if (write_cnt != data_size) {
+ if (write_cnt < 0 || (size_t)write_cnt != data_size) {
perror("Failed to write all snapshotted data.");
ret = -1;
goto done;
@@ -1054,12 +952,11 @@ vm_snapshot_kern_struct(int data_fd, xo_handle_t *xop, const char *array_key,
/* Write metadata. */
xo_open_instance_h(xop, array_key);
- xo_emit_h(xop, "{:debug_name/%s}\n", meta->dev_name);
- xo_emit_h(xop, "{:" JSON_SNAPSHOT_REQ_KEY "/%d}\n",
- meta->dev_req);
+ xo_emit_h(xop, "{:" JSON_SNAPSHOT_REQ_KEY "/%s}\n",
+ meta->dev_name);
xo_emit_h(xop, "{:" JSON_SIZE_KEY "/%lu}\n", data_size);
xo_emit_h(xop, "{:" JSON_FILE_OFFSET_KEY "/%lu}\n", *offset);
- xo_close_instance_h(xop, JSON_STRUCT_ARR_KEY);
+ xo_close_instance_h(xop, JSON_KERNEL_ARR_KEY);
*offset += data_size;
@@ -1068,10 +965,10 @@ done:
}
static int
-vm_snapshot_kern_structs(struct vmctx *ctx, int data_fd, xo_handle_t *xop)
+vm_save_kern_structs(struct vmctx *ctx, int data_fd, xo_handle_t *xop)
{
- int ret, i, error;
- size_t offset, buf_size;
+ int ret, error;
+ size_t buf_size, i, offset;
char *buffer;
struct vm_snapshot_meta *meta;
@@ -1087,15 +984,13 @@ vm_snapshot_kern_structs(struct vmctx *ctx, int data_fd, xo_handle_t *xop)
}
meta = &(struct vm_snapshot_meta) {
- .ctx = ctx,
-
.buffer.buf_start = buffer,
.buffer.buf_size = buf_size,
.op = VM_SNAPSHOT_SAVE,
};
- xo_open_list_h(xop, JSON_STRUCT_ARR_KEY);
+ xo_open_list_h(xop, JSON_KERNEL_ARR_KEY);
for (i = 0; i < nitems(snapshot_kern_structs); i++) {
meta->dev_name = snapshot_kern_structs[i].struct_name;
meta->dev_req = snapshot_kern_structs[i].req;
@@ -1104,14 +999,14 @@ vm_snapshot_kern_structs(struct vmctx *ctx, int data_fd, xo_handle_t *xop)
meta->buffer.buf = meta->buffer.buf_start;
meta->buffer.buf_rem = meta->buffer.buf_size;
- ret = vm_snapshot_kern_struct(data_fd, xop, JSON_DEV_ARR_KEY,
- meta, &offset);
+ ret = vm_save_kern_struct(ctx, data_fd, xop,
+ JSON_DEV_ARR_KEY, meta, &offset);
if (ret != 0) {
error = -1;
goto err_vm_snapshot_kern_data;
}
}
- xo_close_list_h(xop, JSON_STRUCT_ARR_KEY);
+ xo_close_list_h(xop, JSON_KERNEL_ARR_KEY);
err_vm_snapshot_kern_data:
if (buffer != NULL)
@@ -1137,13 +1032,14 @@ static int
vm_snapshot_dev_write_data(int data_fd, xo_handle_t *xop, const char *array_key,
struct vm_snapshot_meta *meta, off_t *offset)
{
- int ret;
+ ssize_t ret;
size_t data_size;
data_size = vm_get_snapshot_size(meta);
+ /* XXX-MJ no handling for short writes. */
ret = write(data_fd, meta->buffer.buf_start, data_size);
- if (ret != data_size) {
+ if (ret < 0 || (size_t)ret != data_size) {
perror("Failed to write all snapshotted data.");
return (-1);
}
@@ -1161,16 +1057,21 @@ vm_snapshot_dev_write_data(int data_fd, xo_handle_t *xop, const char *array_key,
}
static int
-vm_snapshot_user_dev(const struct vm_snapshot_dev_info *info,
- int data_fd, xo_handle_t *xop,
- struct vm_snapshot_meta *meta, off_t *offset)
+vm_snapshot_device(vm_snapshot_dev_cb func, const char *dev_name,
+ void *devdata, int data_fd, xo_handle_t *xop,
+ struct vm_snapshot_meta *meta, off_t *offset)
{
int ret;
- ret = (*info->snapshot_cb)(meta);
+ memset(meta->buffer.buf_start, 0, meta->buffer.buf_size);
+ meta->buffer.buf = meta->buffer.buf_start;
+ meta->buffer.buf_rem = meta->buffer.buf_size;
+ meta->dev_name = dev_name;
+ meta->dev_data = devdata;
+
+ ret = func(meta);
if (ret != 0) {
- fprintf(stderr, "Failed to snapshot %s; ret=%d\r\n",
- meta->dev_name, ret);
+ EPRINTLN("Failed to snapshot %s; ret=%d", dev_name, ret);
return (ret);
}
@@ -1183,13 +1084,14 @@ vm_snapshot_user_dev(const struct vm_snapshot_dev_info *info,
}
static int
-vm_snapshot_user_devs(struct vmctx *ctx, int data_fd, xo_handle_t *xop)
+vm_snapshot_devices(int data_fd, xo_handle_t *xop)
{
- int ret, i;
+ int ret;
off_t offset;
void *buffer;
size_t buf_size;
struct vm_snapshot_meta *meta;
+ struct pci_devinst *pdi;
buf_size = SNAPSHOT_BUFFER_SIZE;
@@ -1207,8 +1109,6 @@ vm_snapshot_user_devs(struct vmctx *ctx, int data_fd, xo_handle_t *xop)
}
meta = &(struct vm_snapshot_meta) {
- .ctx = ctx,
-
.buffer.buf_start = buffer,
.buffer.buf_size = buf_size,
@@ -1217,20 +1117,22 @@ vm_snapshot_user_devs(struct vmctx *ctx, int data_fd, xo_handle_t *xop)
xo_open_list_h(xop, JSON_DEV_ARR_KEY);
- /* Restore other devices that support this feature */
- for (i = 0; i < nitems(snapshot_devs); i++) {
- meta->dev_name = snapshot_devs[i].dev_name;
-
- memset(meta->buffer.buf_start, 0, meta->buffer.buf_size);
- meta->buffer.buf = meta->buffer.buf_start;
- meta->buffer.buf_rem = meta->buffer.buf_size;
-
- ret = vm_snapshot_user_dev(&snapshot_devs[i], data_fd, xop,
- meta, &offset);
+ /* Save PCI devices */
+ pdi = NULL;
+ while ((pdi = pci_next(pdi)) != NULL) {
+ ret = vm_snapshot_device(pci_snapshot, pdi->pi_name, pdi,
+ data_fd, xop, meta, &offset);
if (ret != 0)
goto snapshot_err;
}
+#ifdef __amd64__
+ ret = vm_snapshot_device(atkbdc_snapshot, "atkbdc", NULL,
+ data_fd, xop, meta, &offset);
+#else
+ ret = 0;
+#endif
+
xo_close_list_h(xop, JSON_DEV_ARR_KEY);
snapshot_err:
@@ -1293,7 +1195,7 @@ vm_vcpu_pause(struct vmctx *ctx)
pthread_mutex_lock(&vcpu_lock);
checkpoint_active = true;
- vm_suspend_cpu(ctx, -1);
+ vm_suspend_all_cpus(ctx);
while (CPU_CMP(&vcpus_active, &vcpus_suspended) != 0)
pthread_cond_wait(&vcpus_idle, &vcpu_lock);
pthread_mutex_unlock(&vcpu_lock);
@@ -1306,14 +1208,15 @@ vm_vcpu_resume(struct vmctx *ctx)
pthread_mutex_lock(&vcpu_lock);
checkpoint_active = false;
pthread_mutex_unlock(&vcpu_lock);
- vm_resume_cpu(ctx, -1);
+ vm_resume_all_cpus(ctx);
pthread_cond_broadcast(&vcpus_can_run);
}
static int
-vm_checkpoint(struct vmctx *ctx, const char *checkpoint_file, bool stop_vm)
+vm_checkpoint(struct vmctx *ctx, int fddir, const char *checkpoint_file,
+ bool stop_vm)
{
- int fd_checkpoint = 0, kdata_fd = 0;
+ int fd_checkpoint = 0, kdata_fd = 0, fd_meta;
int ret = 0;
int error = 0;
size_t memsz;
@@ -1328,14 +1231,14 @@ vm_checkpoint(struct vmctx *ctx, const char *checkpoint_file, bool stop_vm)
return (-1);
}
- kdata_fd = open(kdata_filename, O_WRONLY | O_CREAT | O_TRUNC, 0700);
+ kdata_fd = openat(fddir, kdata_filename, O_WRONLY | O_CREAT | O_TRUNC, 0700);
if (kdata_fd < 0) {
perror("Failed to open kernel data snapshot file.");
error = -1;
goto done;
}
- fd_checkpoint = open(checkpoint_file, O_RDWR | O_CREAT | O_TRUNC, 0700);
+ fd_checkpoint = openat(fddir, checkpoint_file, O_RDWR | O_CREAT | O_TRUNC, 0700);
if (fd_checkpoint < 0) {
perror("Failed to create checkpoint file");
@@ -1349,9 +1252,12 @@ vm_checkpoint(struct vmctx *ctx, const char *checkpoint_file, bool stop_vm)
goto done;
}
- meta_file = fopen(meta_filename, "w");
+ fd_meta = openat(fddir, meta_filename, O_WRONLY | O_CREAT | O_TRUNC, 0700);
+ if (fd_meta != -1)
+ meta_file = fdopen(fd_meta, "w");
if (meta_file == NULL) {
perror("Failed to open vm metadata snapshot file.");
+ close(fd_meta);
goto done;
}
@@ -1363,7 +1269,7 @@ vm_checkpoint(struct vmctx *ctx, const char *checkpoint_file, bool stop_vm)
vm_vcpu_pause(ctx);
- ret = vm_pause_user_devs(ctx);
+ ret = vm_pause_devices();
if (ret != 0) {
fprintf(stderr, "Could not pause devices\r\n");
error = ret;
@@ -1384,15 +1290,14 @@ vm_checkpoint(struct vmctx *ctx, const char *checkpoint_file, bool stop_vm)
goto done;
}
-
- ret = vm_snapshot_kern_structs(ctx, kdata_fd, xop);
+ ret = vm_save_kern_structs(ctx, kdata_fd, xop);
if (ret != 0) {
fprintf(stderr, "Failed to snapshot vm kernel data.\n");
error = -1;
goto done;
}
- ret = vm_snapshot_user_devs(ctx, kdata_fd, xop);
+ ret = vm_snapshot_devices(kdata_fd, xop);
if (ret != 0) {
fprintf(stderr, "Failed to snapshot device state.\n");
error = -1;
@@ -1407,7 +1312,7 @@ vm_checkpoint(struct vmctx *ctx, const char *checkpoint_file, bool stop_vm)
}
done:
- ret = vm_resume_user_devs(ctx);
+ ret = vm_resume_devices();
if (ret != 0)
fprintf(stderr, "Could not resume devices\r\n");
vm_vcpu_resume(ctx);
@@ -1477,32 +1382,19 @@ vm_do_checkpoint(struct vmctx *ctx, const nvlist_t *nvl)
int error;
if (!nvlist_exists_string(nvl, "filename") ||
- !nvlist_exists_bool(nvl, "suspend"))
+ !nvlist_exists_bool(nvl, "suspend") ||
+ !nvlist_exists_descriptor(nvl, "fddir"))
error = EINVAL;
else
- error = vm_checkpoint(ctx, nvlist_get_string(nvl, "filename"),
+ error = vm_checkpoint(ctx,
+ nvlist_get_descriptor(nvl, "fddir"),
+ nvlist_get_string(nvl, "filename"),
nvlist_get_bool(nvl, "suspend"));
return (error);
}
IPC_COMMAND(ipc_cmd_set, checkpoint, vm_do_checkpoint);
-void
-init_snapshot(void)
-{
- int err;
-
- err = pthread_mutex_init(&vcpu_lock, NULL);
- if (err != 0)
- errc(1, err, "checkpoint mutex init");
- err = pthread_cond_init(&vcpus_idle, NULL);
- if (err != 0)
- errc(1, err, "checkpoint cv init (vcpus_idle)");
- err = pthread_cond_init(&vcpus_can_run, NULL);
- if (err != 0)
- errc(1, err, "checkpoint cv init (vcpus_can_run)");
-}
-
/*
* Create the listening socket for IPC with bhyvectl
*/
@@ -1514,6 +1406,9 @@ init_checkpoint_thread(struct vmctx *ctx)
int socket_fd;
pthread_t checkpoint_pthread;
int err;
+#ifndef WITHOUT_CAPSICUM
+ cap_rights_t rights;
+#endif
memset(&addr, 0, sizeof(addr));
@@ -1544,6 +1439,13 @@ init_checkpoint_thread(struct vmctx *ctx)
goto fail;
}
+#ifndef WITHOUT_CAPSICUM
+ cap_rights_init(&rights, CAP_ACCEPT, CAP_READ, CAP_RECV, CAP_WRITE,
+ CAP_SEND, CAP_GETSOCKOPT);
+
+ if (caph_rights_limit(socket_fd, &rights) == -1)
+ errx(EX_OSERR, "Unable to apply rights for sandbox");
+#endif
checkpoint_info = calloc(1, sizeof(*checkpoint_info));
checkpoint_info->ctx = ctx;
checkpoint_info->socket_fd = socket_fd;
@@ -1580,8 +1482,7 @@ vm_snapshot_buf_err(const char *bufname, const enum vm_snapshot_op op)
}
int
-vm_snapshot_buf(volatile void *data, size_t data_size,
- struct vm_snapshot_meta *meta)
+vm_snapshot_buf(void *data, size_t data_size, struct vm_snapshot_meta *meta)
{
struct vm_snapshot_buffer *buffer;
int op;
@@ -1595,9 +1496,9 @@ vm_snapshot_buf(volatile void *data, size_t data_size,
}
if (op == VM_SNAPSHOT_SAVE)
- memcpy(buffer->buf, (uint8_t *) data, data_size);
+ memcpy(buffer->buf, data, data_size);
else if (op == VM_SNAPSHOT_RESTORE)
- memcpy((uint8_t *) data, buffer->buf, data_size);
+ memcpy(data, buffer->buf, data_size);
else
return (EINVAL);
@@ -1627,14 +1528,14 @@ vm_get_snapshot_size(struct vm_snapshot_meta *meta)
}
int
-vm_snapshot_guest2host_addr(void **addrp, size_t len, bool restore_null,
- struct vm_snapshot_meta *meta)
+vm_snapshot_guest2host_addr(struct vmctx *ctx, void **addrp, size_t len,
+ bool restore_null, struct vm_snapshot_meta *meta)
{
int ret;
vm_paddr_t gaddr;
if (meta->op == VM_SNAPSHOT_SAVE) {
- gaddr = paddr_host2guest(meta->ctx, *addrp);
+ gaddr = paddr_host2guest(ctx, *addrp);
if (gaddr == (vm_paddr_t) -1) {
if (!restore_null ||
(restore_null && (*addrp != NULL))) {
@@ -1653,7 +1554,7 @@ vm_snapshot_guest2host_addr(void **addrp, size_t len, bool restore_null,
}
}
- *addrp = paddr_guest2host(meta->ctx, gaddr, len);
+ *addrp = paddr_guest2host(ctx, gaddr, len);
} else {
ret = EINVAL;
}
@@ -1663,8 +1564,7 @@ done:
}
int
-vm_snapshot_buf_cmp(volatile void *data, size_t data_size,
- struct vm_snapshot_meta *meta)
+vm_snapshot_buf_cmp(void *data, size_t data_size, struct vm_snapshot_meta *meta)
{
struct vm_snapshot_buffer *buffer;
int op;
@@ -1681,9 +1581,9 @@ vm_snapshot_buf_cmp(volatile void *data, size_t data_size,
if (op == VM_SNAPSHOT_SAVE) {
ret = 0;
- memcpy(buffer->buf, (uint8_t *) data, data_size);
+ memcpy(buffer->buf, data, data_size);
} else if (op == VM_SNAPSHOT_RESTORE) {
- ret = memcmp((uint8_t *) data, buffer->buf, data_size);
+ ret = memcmp(data, buffer->buf, data_size);
} else {
ret = EINVAL;
goto done;
diff --git a/usr.sbin/bhyve/snapshot.h b/usr.sbin/bhyve/snapshot.h
index 718e48467f56..8bebdafd6117 100644
--- a/usr.sbin/bhyve/snapshot.h
+++ b/usr.sbin/bhyve/snapshot.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2016 Flavius Anton
* Copyright (c) 2016 Mihai Tiganus
@@ -31,8 +31,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 _BHYVE_SNAPSHOT_
@@ -66,8 +64,8 @@ struct checkpoint_thread_info {
};
typedef int (*vm_snapshot_dev_cb)(struct vm_snapshot_meta *);
-typedef int (*vm_pause_dev_cb) (struct vmctx *, const char *);
-typedef int (*vm_resume_dev_cb) (struct vmctx *, const char *);
+typedef int (*vm_pause_dev_cb) (const char *);
+typedef int (*vm_resume_dev_cb) (const char *);
struct vm_snapshot_dev_info {
const char *dev_name; /* device name */
@@ -95,15 +93,34 @@ void checkpoint_cpu_suspend(int vcpu);
int restore_vm_mem(struct vmctx *ctx, struct restore_state *rstate);
int vm_restore_kern_structs(struct vmctx *ctx, struct restore_state *rstate);
-int vm_restore_user_devs(struct vmctx *ctx, struct restore_state *rstate);
-int vm_pause_user_devs(struct vmctx *ctx);
-int vm_resume_user_devs(struct vmctx *ctx);
+int vm_restore_devices(struct restore_state *rstate);
+int vm_pause_devices(void);
+int vm_resume_devices(void);
int get_checkpoint_msg(int conn_fd, struct vmctx *ctx);
void *checkpoint_thread(void *param);
int init_checkpoint_thread(struct vmctx *ctx);
-void init_snapshot(void);
int load_restore_file(const char *filename, struct restore_state *rstate);
+int vm_snapshot_guest2host_addr(struct vmctx *ctx, void **addrp, size_t len,
+ bool restore_null, struct vm_snapshot_meta *meta);
+
+/*
+ * Address variables are pointers to guest memory.
+ *
+ * When RNULL != 0, do not enforce invalid address checks; instead, make the
+ * pointer NULL at restore time.
+ */
+#define SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(CTX, ADDR, LEN, RNULL, META, RES, LABEL) \
+do { \
+ (RES) = vm_snapshot_guest2host_addr((CTX), (void **)&(ADDR), (LEN), \
+ (RNULL), (META)); \
+ if ((RES) != 0) { \
+ if ((RES) == EFAULT) \
+ EPRINTLN("%s: invalid address: %s", __func__, #ADDR); \
+ goto LABEL; \
+ } \
+} while (0)
+
#endif
diff --git a/usr.sbin/bhyve/sockstream.c b/usr.sbin/bhyve/sockstream.c
index b592bce9aa5a..9a93c6c27c9e 100644
--- a/usr.sbin/bhyve/sockstream.c
+++ b/usr.sbin/bhyve/sockstream.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Nahanni Systems, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/types.h>
#include <unistd.h>
diff --git a/usr.sbin/bhyve/sockstream.h b/usr.sbin/bhyve/sockstream.h
index ecea849471a3..048c0145e412 100644
--- a/usr.sbin/bhyve/sockstream.h
+++ b/usr.sbin/bhyve/sockstream.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 Nahanni Systems, Inc.
* 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 <sys/types.h>
diff --git a/usr.sbin/bhyve/tpm_device.c b/usr.sbin/bhyve/tpm_device.c
new file mode 100644
index 000000000000..3a4a8c577345
--- /dev/null
+++ b/usr.sbin/bhyve/tpm_device.c
@@ -0,0 +1,256 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <corvink@FreeBSD.org>
+ */
+
+#include <sys/types.h>
+
+#include <assert.h>
+#include <err.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <vmmapi.h>
+
+#include "acpi.h"
+#include "acpi_device.h"
+#include "config.h"
+#include "tpm_device.h"
+#include "tpm_emul.h"
+#include "tpm_intf.h"
+#include "tpm_ppi.h"
+
+#define TPM_ACPI_DEVICE_NAME "TPM"
+#define TPM_ACPI_HARDWARE_ID "MSFT0101"
+
+SET_DECLARE(tpm_emul_set, struct tpm_emul);
+SET_DECLARE(tpm_intf_set, struct tpm_intf);
+SET_DECLARE(tpm_ppi_set, struct tpm_ppi);
+
+struct tpm_device {
+ struct vmctx *vm_ctx;
+ struct acpi_device *acpi_dev;
+ struct tpm_emul *emul;
+ void *emul_sc;
+ struct tpm_intf *intf;
+ void *intf_sc;
+ struct tpm_ppi *ppi;
+ void *ppi_sc;
+};
+
+static int
+tpm_build_acpi_table(const struct acpi_device *const dev)
+{
+ const struct tpm_device *const tpm = acpi_device_get_softc(dev);
+
+ if (tpm->intf->build_acpi_table == NULL) {
+ return (0);
+ }
+
+ return (tpm->intf->build_acpi_table(tpm->intf_sc, tpm->vm_ctx));
+}
+
+static int
+tpm_write_dsdt(const struct acpi_device *const dev)
+{
+ int error;
+
+ const struct tpm_device *const tpm = acpi_device_get_softc(dev);
+ const struct tpm_ppi *const ppi = tpm->ppi;
+
+ /*
+ * packages for returns
+ */
+ dsdt_line("Name(TPM2, Package(2) {0, 0})");
+ dsdt_line("Name(TPM3, Package(3) {0, 0, 0})");
+
+ if (ppi->write_dsdt_regions) {
+ error = ppi->write_dsdt_regions(tpm->ppi_sc);
+ if (error) {
+ warnx("%s: failed to write ppi dsdt regions\n",
+ __func__);
+ return (error);
+ }
+ }
+
+ /*
+ * Device Specific Method
+ * Arg0: UUID
+ * Arg1: Revision ID
+ * Arg2: Function Index
+ * Arg3: Arguments
+ */
+ dsdt_line("Method(_DSM, 4, Serialized)");
+ dsdt_line("{");
+ dsdt_indent(1);
+ if (ppi->write_dsdt_dsm) {
+ error = ppi->write_dsdt_dsm(tpm->ppi_sc);
+ if (error) {
+ warnx("%s: failed to write ppi dsdt dsm\n", __func__);
+ return (error);
+ }
+ }
+ dsdt_unindent(1);
+ dsdt_line("}");
+
+ return (0);
+}
+
+static const struct acpi_device_emul tpm_acpi_device_emul = {
+ .name = TPM_ACPI_DEVICE_NAME,
+ .hid = TPM_ACPI_HARDWARE_ID,
+ .build_table = tpm_build_acpi_table,
+ .write_dsdt = tpm_write_dsdt,
+};
+
+void
+tpm_device_destroy(struct tpm_device *const dev)
+{
+ if (dev == NULL)
+ return;
+
+ if (dev->ppi != NULL && dev->ppi->deinit != NULL)
+ dev->ppi->deinit(dev->ppi_sc);
+ if (dev->intf != NULL && dev->intf->deinit != NULL)
+ dev->intf->deinit(dev->intf_sc);
+ if (dev->emul != NULL && dev->emul->deinit != NULL)
+ dev->emul->deinit(dev->emul_sc);
+
+ acpi_device_destroy(dev->acpi_dev);
+ free(dev);
+}
+
+int
+tpm_device_create(struct tpm_device **const new_dev, struct vmctx *const vm_ctx,
+ nvlist_t *const nvl)
+{
+ struct tpm_device *dev = NULL;
+ struct tpm_emul **ppemul;
+ struct tpm_intf **ppintf;
+ struct tpm_ppi **pp_ppi;
+ const char *value;
+ int error;
+
+ if (new_dev == NULL || vm_ctx == NULL) {
+ error = EINVAL;
+ goto err_out;
+ }
+
+ set_config_value_node_if_unset(nvl, "intf", "crb");
+ set_config_value_node_if_unset(nvl, "ppi", "qemu");
+
+ value = get_config_value_node(nvl, "version");
+ assert(value != NULL);
+ if (strcmp(value, "2.0")) {
+ warnx("%s: unsupported tpm version %s", __func__, value);
+ error = EINVAL;
+ goto err_out;
+ }
+
+ dev = calloc(1, sizeof(*dev));
+ if (dev == NULL) {
+ error = ENOMEM;
+ goto err_out;
+ }
+
+ dev->vm_ctx = vm_ctx;
+
+ error = acpi_device_create(&dev->acpi_dev, dev, dev->vm_ctx,
+ &tpm_acpi_device_emul);
+ if (error)
+ goto err_out;
+
+ value = get_config_value_node(nvl, "type");
+ assert(value != NULL);
+ SET_FOREACH(ppemul, tpm_emul_set) {
+ if (strcmp(value, (*ppemul)->name))
+ continue;
+ dev->emul = *ppemul;
+ break;
+ }
+ if (dev->emul == NULL) {
+ warnx("TPM emulation \"%s\" not found", value);
+ error = EINVAL;
+ goto err_out;
+ }
+
+ if (dev->emul->init) {
+ error = dev->emul->init(&dev->emul_sc, nvl);
+ if (error)
+ goto err_out;
+ }
+
+ value = get_config_value_node(nvl, "intf");
+ SET_FOREACH(ppintf, tpm_intf_set) {
+ if (strcmp(value, (*ppintf)->name)) {
+ continue;
+ }
+ dev->intf = *ppintf;
+ break;
+ }
+ if (dev->intf == NULL) {
+ warnx("TPM interface \"%s\" not found", value);
+ error = EINVAL;
+ goto err_out;
+ }
+
+ if (dev->intf->init) {
+ error = dev->intf->init(&dev->intf_sc, dev->emul, dev->emul_sc,
+ dev->acpi_dev);
+ if (error)
+ goto err_out;
+ }
+
+ value = get_config_value_node(nvl, "ppi");
+ SET_FOREACH(pp_ppi, tpm_ppi_set) {
+ if (strcmp(value, (*pp_ppi)->name)) {
+ continue;
+ }
+ dev->ppi = *pp_ppi;
+ break;
+ }
+ if (dev->ppi == NULL) {
+ warnx("TPM PPI \"%s\" not found\n", value);
+ error = EINVAL;
+ goto err_out;
+ }
+
+ if (dev->ppi->init) {
+ error = dev->ppi->init(&dev->ppi_sc);
+ if (error)
+ goto err_out;
+ }
+
+ *new_dev = dev;
+
+ return (0);
+
+err_out:
+ tpm_device_destroy(dev);
+
+ return (error);
+}
+
+static struct tpm_device *lpc_tpm;
+
+int
+init_tpm(struct vmctx *ctx)
+{
+ nvlist_t *nvl;
+ int error;
+
+ nvl = find_config_node("tpm");
+ if (nvl == NULL)
+ return (0);
+
+ error = tpm_device_create(&lpc_tpm, ctx, nvl);
+ if (error) {
+ warnx("%s: unable to create a TPM device (%d)",
+ __func__, error);
+ return (error);
+ }
+
+ return (0);
+}
diff --git a/usr.sbin/bhyve/tpm_device.h b/usr.sbin/bhyve/tpm_device.h
new file mode 100644
index 000000000000..0dd4c27999df
--- /dev/null
+++ b/usr.sbin/bhyve/tpm_device.h
@@ -0,0 +1,20 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <corvink@FreeBSD.org>
+ */
+
+#pragma once
+
+#include <vmmapi.h>
+
+#include "config.h"
+
+struct tpm_device;
+
+int tpm_device_create(struct tpm_device **new_dev, struct vmctx *vm_ctx,
+ nvlist_t *nvl);
+void tpm_device_destroy(struct tpm_device *dev);
+
+int init_tpm(struct vmctx *ctx);
diff --git a/usr.sbin/bhyve/tpm_emul.h b/usr.sbin/bhyve/tpm_emul.h
new file mode 100644
index 000000000000..24452c92d3b8
--- /dev/null
+++ b/usr.sbin/bhyve/tpm_emul.h
@@ -0,0 +1,24 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <corvink@FreeBSD.org>
+ */
+
+#pragma once
+
+#include <sys/linker_set.h>
+
+#include "config.h"
+
+struct tpm_device;
+
+struct tpm_emul {
+ const char *name;
+
+ int (*init)(void **sc, nvlist_t *nvl);
+ void (*deinit)(void *sc);
+ int (*execute_cmd)(void *sc, void *cmd, uint32_t cmd_size, void *rsp,
+ uint32_t rsp_size);
+};
+#define TPM_EMUL_SET(x) DATA_SET(tpm_emul_set, x)
diff --git a/usr.sbin/bhyve/tpm_emul_passthru.c b/usr.sbin/bhyve/tpm_emul_passthru.c
new file mode 100644
index 000000000000..084d31d5fa9f
--- /dev/null
+++ b/usr.sbin/bhyve/tpm_emul_passthru.c
@@ -0,0 +1,107 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <corvink@FreeBSD.org>
+ */
+
+#include <sys/types.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <malloc_np.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "tpm_device.h"
+#include "tpm_emul.h"
+
+struct tpm_passthru {
+ int fd;
+};
+
+struct tpm_resp_hdr {
+ uint16_t tag;
+ uint32_t len;
+ uint32_t errcode;
+} __packed;
+
+static int
+tpm_passthru_init(void **sc, nvlist_t *nvl)
+{
+ struct tpm_passthru *tpm;
+ const char *path;
+
+ tpm = calloc(1, sizeof(struct tpm_passthru));
+ if (tpm == NULL) {
+ warnx("%s: failed to allocate tpm passthru", __func__);
+ return (ENOMEM);
+ }
+
+ path = get_config_value_node(nvl, "path");
+ tpm->fd = open(path, O_RDWR);
+ if (tpm->fd < 0) {
+ warnx("%s: unable to open tpm device \"%s\"", __func__, path);
+ return (ENOENT);
+ }
+
+ *sc = tpm;
+
+ return (0);
+}
+
+static int
+tpm_passthru_execute_cmd(void *sc, void *cmd, uint32_t cmd_size, void *rsp,
+ uint32_t rsp_size)
+{
+ struct tpm_passthru *tpm;
+ ssize_t len;
+
+ if (rsp_size < (ssize_t)sizeof(struct tpm_resp_hdr)) {
+ warn("%s: rsp_size of %u is too small", __func__, rsp_size);
+ return (EINVAL);
+ }
+
+ tpm = sc;
+
+ len = write(tpm->fd, cmd, cmd_size);
+ if (len != cmd_size) {
+ warn("%s: cmd write failed (bytes written: %zd / %d)", __func__,
+ len, cmd_size);
+ return (EFAULT);
+ }
+
+ len = read(tpm->fd, rsp, rsp_size);
+ if (len < (ssize_t)sizeof(struct tpm_resp_hdr)) {
+ warn("%s: rsp read failed (bytes read: %zd / %d)", __func__,
+ len, rsp_size);
+ return (EFAULT);
+ }
+
+ return (0);
+}
+
+static void
+tpm_passthru_deinit(void *sc)
+{
+ struct tpm_passthru *tpm;
+
+ tpm = sc;
+ if (tpm == NULL)
+ return;
+
+ if (tpm->fd >= 0)
+ close(tpm->fd);
+
+ free(tpm);
+}
+
+static const struct tpm_emul tpm_emul_passthru = {
+ .name = "passthru",
+ .init = tpm_passthru_init,
+ .deinit = tpm_passthru_deinit,
+ .execute_cmd = tpm_passthru_execute_cmd,
+};
+TPM_EMUL_SET(tpm_emul_passthru);
diff --git a/usr.sbin/bhyve/tpm_intf.h b/usr.sbin/bhyve/tpm_intf.h
new file mode 100644
index 000000000000..8f50297138d9
--- /dev/null
+++ b/usr.sbin/bhyve/tpm_intf.h
@@ -0,0 +1,40 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#pragma once
+
+#include <vmmapi.h>
+
+#include "acpi_device.h"
+#include "config.h"
+#include "tpm_device.h"
+#include "tpm_emul.h"
+
+#define TPM_INTF_TYPE_FIFO_PTP 0x0
+#define TPM_INTF_TYPE_CRB 0x1
+#define TPM_INTF_TYPE_FIFO_TIS 0xF
+
+#define TPM_INTF_VERSION_FIFO 0
+#define TPM_INTF_VERSION_CRB 1
+
+#define TPM_INTF_CAP_CRB_DATA_XFER_SIZE_4 0
+#define TPM_INTF_CAP_CRB_DATA_XFER_SIZE_8 1
+#define TPM_INTF_CAP_CRB_DATA_XFER_SIZE_32 2
+#define TPM_INTF_CAP_CRB_DATA_XFER_SIZE_64 3
+
+#define TPM_INTF_SELECTOR_FIFO 0
+#define TPM_INTF_SELECTOR_CRB 1
+
+struct tpm_intf {
+ const char *name;
+
+ int (*init)(void **sc, struct tpm_emul *emul, void *emul_sc,
+ struct acpi_device *acpi_dev);
+ void (*deinit)(void *sc);
+ int (*build_acpi_table)(void *sc, struct vmctx *vm_ctx);
+};
+#define TPM_INTF_SET(x) DATA_SET(tpm_intf_set, x)
diff --git a/usr.sbin/bhyve/tpm_intf_crb.c b/usr.sbin/bhyve/tpm_intf_crb.c
new file mode 100644
index 000000000000..af0214dd1760
--- /dev/null
+++ b/usr.sbin/bhyve/tpm_intf_crb.c
@@ -0,0 +1,580 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/linker_set.h>
+
+#include <machine/vmm.h>
+
+#include <assert.h>
+#include <err.h>
+#include <errno.h>
+#include <pthread.h>
+#include <pthread_np.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <vmmapi.h>
+
+#include "basl.h"
+#include "config.h"
+#include "mem.h"
+#include "qemu_fwcfg.h"
+#include "tpm_device.h"
+#include "tpm_intf.h"
+
+#define TPM_CRB_ADDRESS 0xFED40000
+#define TPM_CRB_REGS_SIZE 0x1000
+
+#define TPM_CRB_CONTROL_AREA_ADDRESS \
+ (TPM_CRB_ADDRESS + offsetof(struct tpm_crb_regs, ctrl_req))
+#define TPM_CRB_CONTROL_AREA_SIZE TPM_CRB_REGS_SIZE
+
+#define TPM_CRB_DATA_BUFFER_ADDRESS \
+ (TPM_CRB_ADDRESS + offsetof(struct tpm_crb_regs, data_buffer))
+#define TPM_CRB_DATA_BUFFER_SIZE 0xF80
+
+#define TPM_CRB_LOCALITIES_MAX 5
+
+#define TPM_CRB_LOG_AREA_MINIMUM_SIZE (64 * 1024)
+
+#define TPM_CRB_LOG_AREA_FWCFG_NAME "etc/tpm/log"
+
+#define TPM_CRB_INTF_NAME "crb"
+
+struct tpm_crb_regs {
+ union tpm_crb_reg_loc_state {
+ struct {
+ uint32_t tpm_established : 1;
+ uint32_t loc_assigned : 1;
+ uint32_t active_locality : 3;
+ uint32_t _reserved : 2;
+ uint32_t tpm_req_valid_sts : 1;
+ };
+ uint32_t val;
+ } loc_state; /* 0h */
+ uint8_t _reserved1[4]; /* 4h */
+ union tpm_crb_reg_loc_ctrl {
+ struct {
+ uint32_t request_access : 1;
+ uint32_t relinquish : 1;
+ uint32_t seize : 1;
+ uint32_t reset_establishment_bit : 1;
+ };
+ uint32_t val;
+ } loc_ctrl; /* 8h */
+ union tpm_crb_reg_loc_sts {
+ struct {
+ uint32_t granted : 1;
+ uint32_t been_seized : 1;
+ };
+ uint32_t val;
+ } loc_sts; /* Ch */
+ uint8_t _reserved2[0x20]; /* 10h */
+ union tpm_crb_reg_intf_id {
+ struct {
+ uint64_t interface_type : 4;
+ uint64_t interface_version : 4;
+ uint64_t cap_locality : 1;
+ uint64_t cap_crb_idle_bypass : 1;
+ uint64_t _reserved1 : 1;
+ uint64_t cap_data_xfer_size_support : 2;
+ uint64_t cap_fifo : 1;
+ uint64_t cap_crb : 1;
+ uint64_t _reserved2 : 2;
+ uint64_t interface_selector : 2;
+ uint64_t intf_sel_lock : 1;
+ uint64_t _reserved3 : 4;
+ uint64_t rid : 8;
+ uint64_t vid : 16;
+ uint64_t did : 16;
+ };
+ uint64_t val;
+ } intf_id; /* 30h */
+ union tpm_crb_reg_ctrl_ext {
+ struct {
+ uint32_t clear;
+ uint32_t remaining_bytes;
+ };
+ uint64_t val;
+ } ctrl_ext; /* 38 */
+ union tpm_crb_reg_ctrl_req {
+ struct {
+ uint32_t cmd_ready : 1;
+ uint32_t go_idle : 1;
+ };
+ uint32_t val;
+ } ctrl_req; /* 40h */
+ union tpm_crb_reg_ctrl_sts {
+ struct {
+ uint32_t tpm_sts : 1;
+ uint32_t tpm_idle : 1;
+ };
+ uint32_t val;
+ } ctrl_sts; /* 44h */
+ union tpm_crb_reg_ctrl_cancel {
+ struct {
+ uint32_t cancel : 1;
+ };
+ uint32_t val;
+ } ctrl_cancel; /* 48h */
+ union tpm_crb_reg_ctrl_start {
+ struct {
+ uint32_t start : 1;
+ };
+ uint32_t val;
+ } ctrl_start; /* 4Ch*/
+ uint32_t int_enable; /* 50h */
+ uint32_t int_sts; /* 54h */
+ uint32_t cmd_size; /* 58h */
+ uint32_t cmd_addr_lo; /* 5Ch */
+ uint32_t cmd_addr_hi; /* 60h */
+ uint32_t rsp_size; /* 64h */
+ uint64_t rsp_addr; /* 68h */
+ uint8_t _reserved3[0x10]; /* 70h */
+ uint8_t data_buffer[TPM_CRB_DATA_BUFFER_SIZE]; /* 80h */
+} __packed;
+static_assert(sizeof(struct tpm_crb_regs) == TPM_CRB_REGS_SIZE,
+ "Invalid size of tpm_crb");
+
+#define CRB_CMD_SIZE_READ(regs) (regs.cmd_size)
+#define CRB_CMD_SIZE_WRITE(regs, val) \
+ do { \
+ regs.cmd_size = val; \
+ } while (0)
+#define CRB_CMD_ADDR_READ(regs) \
+ (((uint64_t)regs.cmd_addr_hi << 32) | regs.cmd_addr_lo)
+#define CRB_CMD_ADDR_WRITE(regs, val) \
+ do { \
+ regs.cmd_addr_lo = val & 0xFFFFFFFF; \
+ regs.cmd_addr_hi = val >> 32; \
+ } while (0)
+#define CRB_RSP_SIZE_READ(regs) (regs.rsp_size)
+#define CRB_RSP_SIZE_WRITE(regs, val) \
+ do { \
+ regs.rsp_size = val; \
+ } while (0)
+#define CRB_RSP_ADDR_READ(regs) (regs.rsp_addr)
+#define CRB_RSP_ADDR_WRITE(regs, val) \
+ do { \
+ regs.rsp_addr = val; \
+ } while (0)
+
+struct tpm_crb {
+ struct tpm_emul *emul;
+ void *emul_sc;
+ uint8_t tpm_log_area[TPM_CRB_LOG_AREA_MINIMUM_SIZE];
+ struct tpm_crb_regs regs;
+ pthread_t thread;
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ bool closing;
+};
+
+static void *
+tpm_crb_thread(void *const arg)
+{
+ struct tpm_crb *const crb = arg;
+
+ pthread_mutex_lock(&crb->mutex);
+ for (;;) {
+ /*
+ * We're releasing the lock after wake up. Therefore, we have to
+ * check the closing condition before and after going to sleep.
+ */
+ if (crb->closing)
+ break;
+
+ pthread_cond_wait(&crb->cond, &crb->mutex);
+
+ if (crb->closing)
+ break;
+
+ const uint64_t cmd_addr = CRB_CMD_ADDR_READ(crb->regs);
+ const uint64_t rsp_addr = CRB_RSP_ADDR_READ(crb->regs);
+ const uint32_t cmd_size = CRB_CMD_SIZE_READ(crb->regs);
+ const uint32_t rsp_size = CRB_RSP_SIZE_READ(crb->regs);
+
+ const uint64_t cmd_off = cmd_addr - TPM_CRB_DATA_BUFFER_ADDRESS;
+ const uint64_t rsp_off = rsp_addr - TPM_CRB_DATA_BUFFER_ADDRESS;
+
+ if (cmd_off > TPM_CRB_DATA_BUFFER_SIZE ||
+ cmd_off + cmd_size > TPM_CRB_DATA_BUFFER_SIZE ||
+ rsp_off > TPM_CRB_DATA_BUFFER_SIZE ||
+ rsp_off + rsp_size > TPM_CRB_DATA_BUFFER_SIZE) {
+ warnx(
+ "%s: invalid cmd [%16lx, %16lx] --> [%16lx, %16lx]\n\r",
+ __func__, cmd_addr, cmd_addr + cmd_size, rsp_addr,
+ rsp_addr + rsp_size);
+ break;
+ }
+
+ uint8_t cmd[TPM_CRB_DATA_BUFFER_SIZE];
+ memcpy(cmd, crb->regs.data_buffer, TPM_CRB_DATA_BUFFER_SIZE);
+
+ /*
+ * A TPM command can take multiple seconds to execute. As we've
+ * copied all required values and buffers at this point, we can
+ * release the mutex.
+ */
+ pthread_mutex_unlock(&crb->mutex);
+
+ /*
+ * The command response buffer interface uses a single buffer
+ * for sending a command to and receiving a response from the
+ * tpm. To avoid reading old data from the command buffer which
+ * might be a security issue, we zero out the command buffer
+ * before writing the response into it. The rsp_size parameter
+ * is controlled by the guest and it's not guaranteed that the
+ * response has a size of rsp_size (e.g. if the tpm returned an
+ * error, the response would have a different size than
+ * expected). For that reason, use a second buffer for the
+ * response.
+ */
+ uint8_t rsp[TPM_CRB_DATA_BUFFER_SIZE] = { 0 };
+ crb->emul->execute_cmd(crb->emul_sc, &cmd[cmd_off], cmd_size,
+ &rsp[rsp_off], rsp_size);
+
+ pthread_mutex_lock(&crb->mutex);
+ memset(crb->regs.data_buffer, 0, TPM_CRB_DATA_BUFFER_SIZE);
+ memcpy(&crb->regs.data_buffer[rsp_off], &rsp[rsp_off], rsp_size);
+
+ crb->regs.ctrl_start.start = false;
+ }
+ pthread_mutex_unlock(&crb->mutex);
+
+ return (NULL);
+}
+
+static int
+tpm_crb_mmiocpy(void *const dst, void *const src, const int size)
+{
+ if (!(size == 1 || size == 2 || size == 4 || size == 8))
+ return (EINVAL);
+ memcpy(dst, src, size);
+
+ return (0);
+}
+
+static int
+tpm_crb_mem_handler(struct vcpu *vcpu __unused, const int dir,
+ const uint64_t addr, const int size, uint64_t *const val, void *const arg1,
+ const long arg2 __unused)
+{
+ struct tpm_crb *crb;
+ uint8_t *ptr;
+ uint64_t off, shift;
+ int error = 0;
+
+ if ((addr & (size - 1)) != 0) {
+ warnx("%s: unaligned %s access @ %16lx [size = %x]", __func__,
+ (dir == MEM_F_READ) ? "read" : "write", addr, size);
+ return (EINVAL);
+ }
+
+ crb = arg1;
+
+ off = addr - TPM_CRB_ADDRESS;
+ if (off > TPM_CRB_REGS_SIZE || off + size >= TPM_CRB_REGS_SIZE) {
+ return (EINVAL);
+ }
+
+ shift = 8 * (off & 3);
+ ptr = (uint8_t *)&crb->regs + off;
+
+ if (dir == MEM_F_READ) {
+ error = tpm_crb_mmiocpy(val, ptr, size);
+ if (error)
+ goto err_out;
+ } else {
+ switch (off & ~0x3) {
+ case offsetof(struct tpm_crb_regs, loc_ctrl): {
+ union tpm_crb_reg_loc_ctrl loc_ctrl;
+
+ if ((size_t)size > sizeof(loc_ctrl))
+ goto err_out;
+
+ *val = *val << shift;
+ tpm_crb_mmiocpy(&loc_ctrl, val, size);
+
+ if (loc_ctrl.relinquish) {
+ crb->regs.loc_sts.granted = false;
+ crb->regs.loc_state.loc_assigned = false;
+ } else if (loc_ctrl.request_access) {
+ crb->regs.loc_sts.granted = true;
+ crb->regs.loc_state.loc_assigned = true;
+ }
+
+ break;
+ }
+ case offsetof(struct tpm_crb_regs, ctrl_req): {
+ union tpm_crb_reg_ctrl_req req;
+
+ if ((size_t)size > sizeof(req))
+ goto err_out;
+
+ *val = *val << shift;
+ tpm_crb_mmiocpy(&req, val, size);
+
+ if (req.cmd_ready && !req.go_idle) {
+ crb->regs.ctrl_sts.tpm_idle = false;
+ } else if (!req.cmd_ready && req.go_idle) {
+ crb->regs.ctrl_sts.tpm_idle = true;
+ }
+
+ break;
+ }
+ case offsetof(struct tpm_crb_regs, ctrl_cancel): {
+ /* TODO: cancel the tpm command */
+ warnx(
+ "%s: cancelling a TPM command is not implemented yet",
+ __func__);
+
+ break;
+ }
+ case offsetof(struct tpm_crb_regs, ctrl_start): {
+ union tpm_crb_reg_ctrl_start start;
+
+ if ((size_t)size > sizeof(start))
+ goto err_out;
+
+ *val = *val << shift;
+
+ pthread_mutex_lock(&crb->mutex);
+ tpm_crb_mmiocpy(&start, val, size);
+
+ if (!start.start || crb->regs.ctrl_start.start)
+ break;
+
+ crb->regs.ctrl_start.start = true;
+
+ pthread_cond_signal(&crb->cond);
+ pthread_mutex_unlock(&crb->mutex);
+
+ break;
+ }
+ case offsetof(struct tpm_crb_regs, cmd_size):
+ case offsetof(struct tpm_crb_regs, cmd_addr_lo):
+ case offsetof(struct tpm_crb_regs, cmd_addr_hi):
+ case offsetof(struct tpm_crb_regs, rsp_size):
+ case offsetof(struct tpm_crb_regs,
+ rsp_addr) ... offsetof(struct tpm_crb_regs, rsp_addr) +
+ 4:
+ case offsetof(struct tpm_crb_regs,
+ data_buffer) ... offsetof(struct tpm_crb_regs, data_buffer) +
+ TPM_CRB_DATA_BUFFER_SIZE / 4:
+ /*
+ * Those fields are used to execute a TPM command. The
+ * crb_thread will access them. For that reason, we have
+ * to acquire the crb mutex in order to write them.
+ */
+ pthread_mutex_lock(&crb->mutex);
+ error = tpm_crb_mmiocpy(ptr, val, size);
+ pthread_mutex_unlock(&crb->mutex);
+ if (error)
+ goto err_out;
+ break;
+ default:
+ /*
+ * The other fields are either readonly or we do not
+ * support writing them.
+ */
+ error = EINVAL;
+ goto err_out;
+ }
+ }
+
+ return (0);
+
+err_out:
+ warnx("%s: invalid %s @ %16lx [size = %d]", __func__,
+ dir == MEM_F_READ ? "read" : "write", addr, size);
+
+ return (error);
+}
+
+static int
+tpm_crb_modify_mmio_registration(const bool registration, void *const arg1)
+{
+ struct mem_range crb_mmio = {
+ .name = "crb-mmio",
+ .base = TPM_CRB_ADDRESS,
+ .size = TPM_CRB_LOCALITIES_MAX * TPM_CRB_CONTROL_AREA_SIZE,
+ .flags = MEM_F_RW,
+ .arg1 = arg1,
+ .handler = tpm_crb_mem_handler,
+ };
+
+ if (registration)
+ return (register_mem(&crb_mmio));
+ else
+ return (unregister_mem(&crb_mmio));
+}
+
+static int
+tpm_crb_init(void **sc, struct tpm_emul *emul, void *emul_sc,
+ struct acpi_device *acpi_dev)
+{
+ struct tpm_crb *crb = NULL;
+ int error;
+
+ assert(sc != NULL);
+ assert(emul != NULL);
+
+ crb = calloc(1, sizeof(struct tpm_crb));
+ if (crb == NULL) {
+ warnx("%s: failed to allocate tpm crb", __func__);
+ error = ENOMEM;
+ goto err_out;
+ }
+
+ memset(crb, 0, sizeof(*crb));
+
+ crb->emul = emul;
+ crb->emul_sc = emul_sc;
+
+ crb->regs.loc_state.tpm_req_valid_sts = true;
+ crb->regs.loc_state.tpm_established = true;
+
+ crb->regs.intf_id.interface_type = TPM_INTF_TYPE_CRB;
+ crb->regs.intf_id.interface_version = TPM_INTF_VERSION_CRB;
+ crb->regs.intf_id.cap_locality = false;
+ crb->regs.intf_id.cap_crb_idle_bypass = false;
+ crb->regs.intf_id.cap_data_xfer_size_support =
+ TPM_INTF_CAP_CRB_DATA_XFER_SIZE_64;
+ crb->regs.intf_id.cap_fifo = false;
+ crb->regs.intf_id.cap_crb = true;
+ crb->regs.intf_id.interface_selector = TPM_INTF_SELECTOR_CRB;
+ crb->regs.intf_id.intf_sel_lock = false;
+ crb->regs.intf_id.rid = 0;
+ crb->regs.intf_id.vid = 0x1014; /* IBM */
+ crb->regs.intf_id.did = 0x1014; /* IBM */
+
+ crb->regs.ctrl_sts.tpm_idle = true;
+
+ CRB_CMD_SIZE_WRITE(crb->regs, TPM_CRB_DATA_BUFFER_SIZE);
+ CRB_CMD_ADDR_WRITE(crb->regs, TPM_CRB_DATA_BUFFER_ADDRESS);
+ CRB_RSP_SIZE_WRITE(crb->regs, TPM_CRB_DATA_BUFFER_SIZE);
+ CRB_RSP_ADDR_WRITE(crb->regs, TPM_CRB_DATA_BUFFER_ADDRESS);
+
+ error = qemu_fwcfg_add_file(TPM_CRB_LOG_AREA_FWCFG_NAME,
+ TPM_CRB_LOG_AREA_MINIMUM_SIZE, crb->tpm_log_area);
+ if (error) {
+ warnx("%s: failed to add fwcfg file", __func__);
+ goto err_out;
+ }
+
+ error = acpi_device_add_res_fixed_memory32(acpi_dev, false,
+ TPM_CRB_ADDRESS, TPM_CRB_CONTROL_AREA_SIZE);
+ if (error) {
+ warnx("%s: failed to add acpi resources\n", __func__);
+ goto err_out;
+ }
+
+ error = tpm_crb_modify_mmio_registration(true, crb);
+ if (error) {
+ warnx("%s: failed to register crb mmio", __func__);
+ goto err_out;
+ }
+
+ error = pthread_mutex_init(&crb->mutex, NULL);
+ if (error) {
+ warnc(error, "%s: failed to init mutex", __func__);
+ goto err_out;
+ }
+
+ error = pthread_cond_init(&crb->cond, NULL);
+ if (error) {
+ warnc(error, "%s: failed to init cond", __func__);
+ goto err_out;
+ }
+
+ error = pthread_create(&crb->thread, NULL, tpm_crb_thread, crb);
+ if (error) {
+ warnx("%s: failed to create thread\n", __func__);
+ goto err_out;
+ }
+
+ pthread_set_name_np(crb->thread, "tpm_intf_crb");
+
+ *sc = crb;
+
+ return (0);
+
+err_out:
+ free(crb);
+
+ return (error);
+}
+
+static void
+tpm_crb_deinit(void *sc)
+{
+ struct tpm_crb *crb;
+ int error;
+
+ if (sc == NULL) {
+ return;
+ }
+
+ crb = sc;
+
+ crb->closing = true;
+ pthread_cond_signal(&crb->cond);
+ pthread_join(crb->thread, NULL);
+
+ pthread_cond_destroy(&crb->cond);
+ pthread_mutex_destroy(&crb->mutex);
+
+ error = tpm_crb_modify_mmio_registration(false, NULL);
+ assert(error == 0);
+
+ free(crb);
+}
+
+static int
+tpm_crb_build_acpi_table(void *sc __unused, struct vmctx *vm_ctx)
+{
+ struct basl_table *table;
+
+ BASL_EXEC(basl_table_create(&table, vm_ctx, ACPI_SIG_TPM2,
+ BASL_TABLE_ALIGNMENT));
+
+ /* Header */
+ BASL_EXEC(basl_table_append_header(table, ACPI_SIG_TPM2, 4, 1));
+ /* Platform Class */
+ BASL_EXEC(basl_table_append_int(table, 0, 2));
+ /* Reserved */
+ BASL_EXEC(basl_table_append_int(table, 0, 2));
+ /* Control Address */
+ BASL_EXEC(
+ basl_table_append_int(table, TPM_CRB_CONTROL_AREA_ADDRESS, 8));
+ /* Start Method == (7) Command Response Buffer */
+ BASL_EXEC(basl_table_append_int(table, 7, 4));
+ /* Start Method Specific Parameters */
+ uint8_t parameters[12] = { 0 };
+ BASL_EXEC(basl_table_append_bytes(table, parameters, 12));
+ /* Log Area Minimum Length */
+ BASL_EXEC(
+ basl_table_append_int(table, TPM_CRB_LOG_AREA_MINIMUM_SIZE, 4));
+ /* Log Area Start Address */
+ BASL_EXEC(
+ basl_table_append_fwcfg(table, TPM_CRB_LOG_AREA_FWCFG_NAME, 1, 8));
+
+ BASL_EXEC(basl_table_register_to_rsdt(table));
+
+ return (0);
+}
+
+static struct tpm_intf tpm_intf_crb = {
+ .name = TPM_CRB_INTF_NAME,
+ .init = tpm_crb_init,
+ .deinit = tpm_crb_deinit,
+ .build_acpi_table = tpm_crb_build_acpi_table,
+};
+TPM_INTF_SET(tpm_intf_crb);
diff --git a/usr.sbin/bhyve/tpm_ppi.h b/usr.sbin/bhyve/tpm_ppi.h
new file mode 100644
index 000000000000..3c54c2f6c223
--- /dev/null
+++ b/usr.sbin/bhyve/tpm_ppi.h
@@ -0,0 +1,20 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2022 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#pragma once
+
+#include "config.h"
+
+struct tpm_ppi {
+ const char *name;
+
+ int (*init)(void **sc);
+ void (*deinit)(void *sc);
+ int (*write_dsdt_regions)(void *sc);
+ int (*write_dsdt_dsm)(void *sc);
+};
+#define TPM_PPI_SET(x) DATA_SET(tpm_ppi_set, x)
diff --git a/usr.sbin/bhyve/tpm_ppi_qemu.c b/usr.sbin/bhyve/tpm_ppi_qemu.c
new file mode 100644
index 000000000000..ad66ecb09683
--- /dev/null
+++ b/usr.sbin/bhyve/tpm_ppi_qemu.c
@@ -0,0 +1,475 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2022 Beckhoff Automation GmbH & Co. KG
+ * Author: Corvin Köhne <c.koehne@beckhoff.com>
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/endian.h>
+#include <sys/linker_set.h>
+
+#include <machine/vmm.h>
+
+#include <assert.h>
+#include <err.h>
+#include <errno.h>
+#include <vmmapi.h>
+
+#include "acpi.h"
+#include "acpi_device.h"
+#include "config.h"
+#include "mem.h"
+#include "qemu_fwcfg.h"
+#include "tpm_ppi.h"
+
+#define TPM_PPI_ADDRESS 0xFED45000
+#define TPM_PPI_SIZE 0x1000
+
+#define TPM_PPI_FWCFG_FILE "etc/tpm/config"
+
+#define TPM_PPI_QEMU_NAME "qemu"
+
+struct tpm_ppi_qemu {
+ uint8_t func[256]; // FUNC
+ uint8_t in; // PPIN
+ uint32_t ip; // PPIP
+ uint32_t response; // PPRP
+ uint32_t request; // PPRQ
+ uint32_t request_parameter; // PPRM
+ uint32_t last_request; // LPPR
+ uint32_t func_ret; // FRET
+ uint8_t _reserved1[0x40]; // RES1
+ uint8_t next_step; // next_step
+} __packed;
+static_assert(sizeof(struct tpm_ppi_qemu) <= TPM_PPI_SIZE,
+ "Wrong size of tpm_ppi_qemu");
+
+struct tpm_ppi_fwcfg {
+ uint32_t ppi_address;
+ uint8_t tpm_version;
+ uint8_t ppi_version;
+} __packed;
+
+static int
+tpm_ppi_mem_handler(struct vcpu *const vcpu __unused, const int dir,
+ const uint64_t addr, const int size, uint64_t *const val, void *const arg1,
+ const long arg2 __unused)
+{
+ struct tpm_ppi_qemu *ppi;
+ uint8_t *ptr;
+ uint64_t off;
+
+ if ((addr & (size - 1)) != 0) {
+ warnx("%s: unaligned %s access @ %16lx [size = %x]", __func__,
+ (dir == MEM_F_READ) ? "read" : "write", addr, size);
+ }
+
+ ppi = arg1;
+
+ off = addr - TPM_PPI_ADDRESS;
+ ptr = (uint8_t *)ppi + off;
+
+ if (off > TPM_PPI_SIZE || off + size > TPM_PPI_SIZE) {
+ return (EINVAL);
+ }
+
+ assert(size == 1 || size == 2 || size == 4 || size == 8);
+ if (dir == MEM_F_READ) {
+ memcpy(val, ptr, size);
+ } else {
+ memcpy(ptr, val, size);
+ }
+
+ return (0);
+}
+
+static struct mem_range ppi_mmio = {
+ .name = "ppi-mmio",
+ .base = TPM_PPI_ADDRESS,
+ .size = TPM_PPI_SIZE,
+ .flags = MEM_F_RW,
+ .handler = tpm_ppi_mem_handler,
+};
+
+static int
+tpm_ppi_init(void **sc)
+{
+ struct tpm_ppi_qemu *ppi = NULL;
+ struct tpm_ppi_fwcfg *fwcfg = NULL;
+ int error;
+
+ ppi = calloc(1, sizeof(*ppi));
+ if (ppi == NULL) {
+ warnx("%s: failed to allocate acpi region for ppi", __func__);
+ error = ENOMEM;
+ goto err_out;
+ }
+
+ fwcfg = calloc(1, sizeof(struct tpm_ppi_fwcfg));
+ if (fwcfg == NULL) {
+ warnx("%s: failed to allocate fwcfg item", __func__);
+ error = ENOMEM;
+ goto err_out;
+ }
+
+ fwcfg->ppi_address = htole32(TPM_PPI_ADDRESS);
+ fwcfg->tpm_version = 2;
+ fwcfg->ppi_version = 1;
+
+ error = qemu_fwcfg_add_file(TPM_PPI_FWCFG_FILE,
+ sizeof(struct tpm_ppi_fwcfg), fwcfg);
+ if (error) {
+ warnx("%s: failed to add fwcfg file", __func__);
+ goto err_out;
+ }
+
+ /*
+ * We would just need to create some guest memory for the PPI region.
+ * Sadly, bhyve has a strange memory interface. We can't just add more
+ * memory to the VM. So, create a trap instead which reads and writes to
+ * the ppi region. It's very slow but ppi shouldn't be used frequently.
+ */
+ ppi_mmio.arg1 = ppi;
+ error = register_mem(&ppi_mmio);
+ if (error) {
+ warnx("%s: failed to create trap for ppi accesses", __func__);
+ goto err_out;
+ }
+
+ *sc = ppi;
+
+ return (0);
+
+err_out:
+ free(fwcfg);
+ free(ppi);
+
+ return (error);
+}
+
+static void
+tpm_ppi_deinit(void *sc)
+{
+ struct tpm_ppi_qemu *ppi;
+ int error;
+
+ if (sc == NULL)
+ return;
+
+ ppi = sc;
+
+ error = unregister_mem(&ppi_mmio);
+ assert(error = 0);
+
+ free(ppi);
+}
+
+static int
+tpm_ppi_write_dsdt_regions(void *sc __unused)
+{
+ /*
+ * struct tpm_ppi_qemu
+ */
+ /*
+ * According to qemu the Windows ACPI parser has a bug that DerefOf is
+ * broken for SYSTEM_MEMORY. Due to that bug, qemu uses a dynamic
+ * operation region inside a method.
+ */
+ dsdt_line("Method(TPFN, 1, Serialized)");
+ dsdt_line("{");
+ dsdt_line(" If(LGreaterEqual(Arg0, 0x100))");
+ dsdt_line(" {");
+ dsdt_line(" Return(Zero)");
+ dsdt_line(" }");
+ dsdt_line(
+ " OperationRegion(TPP1, SystemMemory, Add(0x%8x, Arg0), One)",
+ TPM_PPI_ADDRESS);
+ dsdt_line(" Field(TPP1, ByteAcc, NoLock, Preserve)");
+ dsdt_line(" {");
+ dsdt_line(" TPPF, 8,");
+ dsdt_line(" }");
+ dsdt_line(" Return(TPPF)");
+ dsdt_line("}");
+ dsdt_line("OperationRegion(TPP2, SystemMemory, 0x%8x, 0x%x)",
+ TPM_PPI_ADDRESS + 0x100, 0x5A);
+ dsdt_line("Field(TPP2, AnyAcc, NoLock, Preserve)");
+ dsdt_line("{");
+ dsdt_line(" PPIN, 8,");
+ dsdt_line(" PPIP, 32,");
+ dsdt_line(" PPRP, 32,");
+ dsdt_line(" PPRQ, 32,");
+ dsdt_line(" PPRM, 32,");
+ dsdt_line(" LPPR, 32,");
+ dsdt_line("}");
+ /*
+ * Used for TCG Platform Reset Attack Mitigation
+ */
+ dsdt_line("OperationRegion(TPP3, SystemMemory, 0x%8x, 1)",
+ TPM_PPI_ADDRESS + sizeof(struct tpm_ppi_qemu));
+ dsdt_line("Field(TPP3, ByteAcc, NoLock, Preserve)");
+ dsdt_line("{");
+ dsdt_line(" MOVV, 8,");
+ dsdt_line("}");
+
+ return (0);
+}
+
+static int
+tpm_ppi_write_dsdt_dsm(void *sc __unused)
+{
+ /*
+ * Physical Presence Interface
+ */
+ dsdt_line(
+ "If(LEqual(Arg0, ToUUID(\"3DDDFAA6-361B-4EB4-A424-8D10089D1653\"))) /* UUID */");
+ dsdt_line("{");
+ /*
+ * Function 0 - _DSM Query Function
+ * Arguments:
+ * Empty Package
+ * Return:
+ * Buffer - Index field of supported functions
+ */
+ dsdt_line(" If(LEqual(Arg2, 0)) /* Function */");
+ dsdt_line(" {");
+ dsdt_line(" Return(Buffer(0x02)");
+ dsdt_line(" {");
+ dsdt_line(" 0xFF, 0x01");
+ dsdt_line(" })");
+ dsdt_line(" }");
+ /*
+ * Function 1 - Get Physical Presence Interface Version
+ * Arguments:
+ * Empty Package
+ * Return:
+ * String - Supported Physical Presence Interface revision
+ */
+ dsdt_line(" If(LEqual(Arg2, 1)) /* Function */");
+ dsdt_line(" {");
+ dsdt_line(" Return(\"1.3\")");
+ dsdt_line(" }");
+ /*
+ * Function 2 - Submit TPM Operation Request to Pre-OS Environment
+ * !!!DEPRECATED BUT MANDATORY!!!
+ * Arguments:
+ * Integer - Operation Value of the Request
+ * Return:
+ * Integer - Function Return Code
+ * 0 - Success
+ * 1 - Operation Value of the Request Not Supported
+ * 2 - General Failure
+ */
+ dsdt_line(" If(LEqual(Arg2, 2)) /* Function */");
+ dsdt_line(" {");
+ dsdt_line(" Store(DerefOf(Index(Arg3, 0)), Local0)");
+ dsdt_line(" Store(TPFN(Local0), Local1)");
+ dsdt_line(" If (LEqual(And(Local1, 7), 0))");
+ dsdt_line(" {");
+ dsdt_line(" Return(1)");
+ dsdt_line(" }");
+ dsdt_line(" Store(Local0, PPRQ)");
+ dsdt_line(" Store(0, PPRM)");
+ dsdt_line(" Return(0)");
+ dsdt_line(" }");
+ /*
+ * Function 3 - Get Pending TPM Operation Request By the OS
+ * Arguments:
+ * Empty Package
+ * Return:
+ * Package
+ * Integer 1 - Function Return Code
+ * 0 - Success
+ * 1 - General Failure
+ * Integer 2 - Pending operation requested by the OS
+ * 0 - None
+ * >0 - Operation Value of the Pending Request
+ * Integer 3 - Optional argument to pending operation requested by
+ * the OS
+ * 0 - None
+ * >0 - Argument of the Pending Request
+ */
+ dsdt_line(" If(LEqual(Arg2, 3)) /* Function */");
+ dsdt_line(" {");
+ dsdt_line(" If(LEqual(Arg1, 1)) /* Revision */");
+ dsdt_line(" {");
+ dsdt_line(" Store(PPRQ, Index(TPM2, 1))");
+ dsdt_line(" Return(TPM2)");
+ dsdt_line(" }");
+ dsdt_line(" If(LEqual(Arg1, 2)) /* Revision */");
+ dsdt_line(" {");
+ dsdt_line(" Store(PPRQ, Index(TPM3, 1))");
+ dsdt_line(" Store(PPRM, Index(TPM3, 2))");
+ dsdt_line(" Return(TPM3)");
+ dsdt_line(" }");
+ dsdt_line(" }");
+ /*
+ * Function 4 - Get Platform-Specific Action to Transition to Pre-OS
+ * Environment
+ * Arguments:
+ * Empty Package
+ * Return:
+ * Integer - Action that the OS should take to transition to the
+ * pre-OS environment for execution of a requested operation
+ * 0 - None
+ * 1 - Shutdown
+ * 2 - Reboot
+ * 3 - OS Vendor-specific
+ */
+ dsdt_line(" If(LEqual(Arg2, 4)) /* Function */");
+ dsdt_line(" {");
+ dsdt_line(" Return(2)");
+ dsdt_line(" }");
+ /*
+ * Function 5 - Return TPM Operation Response to OS Environment
+ * Arguments:
+ * Empty Package
+ * Return:
+ * Package
+ * Integer 1 - Function Return Code
+ * 0 - Success
+ * 1 - General Failure
+ * Integer 2 - Most recent operation request
+ * 0 - None
+ * >0 - Operation value of the most recent request
+ * Integer 3 - Response to the most recent operation request
+ * 0 - Success
+ * 0x00000001..0x000000FF - Corresponding TPM error code
+ * 0xFFFFFFF0 - User Abort or timeout of dialog
+ * 0xFFFFFFF1 - firmware failure
+ */
+ dsdt_line(" If(LEqual(Arg2, 5)) /* Function */");
+ dsdt_line(" {");
+ dsdt_line(" Store(LPPR, Index(TPM3, 1))");
+ dsdt_line(" Store(PPRP, Index(TPM3, 2))");
+ dsdt_line(" Return(TPM3)");
+ dsdt_line(" }");
+ /*
+ * Function 6 - Submit preferred user language
+ * !!!DEPRECATED BUT MANDATORY!!!
+ * Arguments:
+ * Package
+ * String - Preferred language code
+ * Return:
+ * Integer
+ * 3 - Not implemented
+ */
+ dsdt_line(" If(LEqual(Arg2, 6)) /* Function */");
+ dsdt_line(" {");
+ dsdt_line(" Return(3)");
+ dsdt_line(" }");
+ /*
+ * Function 7 - Submit TPM Operation Request to Pre-OS Environment 2
+ * Arguments:
+ * Package
+ * Integer 1 - Operation Value of the Request
+ * Integer 2 - Argument for Operation
+ * Return:
+ * Integer - Function Return Code
+ * 0 - Success
+ * 1 - Not Implemented
+ * 2 - General Failure
+ * 3 - Operation blocked by current firmware settings
+ */
+ dsdt_line(" If(LEqual(Arg2, 7)) /* Function */");
+ dsdt_line(" {");
+ dsdt_line(" Store(DerefOf(Index(Arg3, 0)), Local0)");
+ dsdt_line(" Store(TPFN(Local0), Local1)");
+ dsdt_line(" If (LEqual(And(Local1, 7), 0)) /* Not Implemented */");
+ dsdt_line(" {");
+ dsdt_line(" Return(1)");
+ dsdt_line(" }");
+ dsdt_line(" If (LEqual(And(Local1, 7), 2)) /* Blocked */ ");
+ dsdt_line(" {");
+ dsdt_line(" Return(3)");
+ dsdt_line(" }");
+ dsdt_line(" If(LEqual(Arg1, 1)) /* Revision */");
+ dsdt_line(" {");
+ dsdt_line(" Store(Local0, PPRQ)");
+ dsdt_line(" Store(0, PPRM)");
+ dsdt_line(" }");
+ dsdt_line(" If(LEqual(Arg1, 2)) /* Revision */");
+ dsdt_line(" {");
+ dsdt_line(" Store(Local0, PPRQ)");
+ dsdt_line(" Store(DerefOf(Index(Arg3, 1)), PPRM)");
+ dsdt_line(" }");
+ dsdt_line(" Return(0)");
+ dsdt_line(" }");
+ /*
+ * Function 8 - Get User Confirmation Status for Operation
+ * Arguments:
+ * Package
+ * Integer - Operation Value that may need user confirmation
+ * Return:
+ * Integer - Function Return Code
+ * 0 - Not implemented
+ * 1 - Firmware only
+ * 2 - Blocked for OS by firmware configuration
+ * 3 - Allowed and physically present user required
+ * 4 - Allowed and physically present user not required
+ */
+ dsdt_line(" If(LEqual(Arg2, 8)) /* Function */");
+ dsdt_line(" {");
+ dsdt_line(" Store(DerefOf(Index(Arg3, 0)), Local0)");
+ dsdt_line(" Store(TPFN(Local0), Local1)");
+ dsdt_line(" Return(And(Local1, 7))");
+ dsdt_line(" }");
+ /*
+ * Unknown function
+ */
+ dsdt_line(" Return(Buffer(1)");
+ dsdt_line(" {");
+ dsdt_line(" 0x00");
+ dsdt_line(" })");
+ dsdt_line("}");
+
+ /*
+ * TCG Platform Reset Attack Mitigation
+ */
+ dsdt_line(
+ "If(LEqual(Arg0, ToUUID(\"376054ED-CC13-4675-901C-4756D7F2D45D\"))) /* UUID */");
+ dsdt_line("{");
+ /*
+ * Function 0 - _DSM Query Function
+ * Arguments:
+ * Empty Package
+ * Return:
+ * Buffer - Index field of supported functions
+ */
+ dsdt_line(" If(LEqual(Arg2, 0)) /* Function */");
+ dsdt_line(" {");
+ dsdt_line(" Return(Buffer(1)");
+ dsdt_line(" {");
+ dsdt_line(" 0x03");
+ dsdt_line(" })");
+ dsdt_line(" }");
+ /*
+ * Function 1 - Memory Clear
+ * Arguments:
+ * Package
+ * Integer - Operation Value of the Request
+ * Return:
+ * Integer - Function Return Code
+ * 0 - Success
+ * 1 - General Failure
+ */
+ dsdt_line(" If(LEqual(Arg2, 1)) /* Function */");
+ dsdt_line(" {");
+ dsdt_line(" Store(DerefOf(Index(Arg3, 0)), Local0)");
+ dsdt_line(" Store(Local0, MOVV)");
+ dsdt_line(" Return(0)");
+ dsdt_line(" }");
+ dsdt_line("}");
+
+ return (0);
+}
+
+static struct tpm_ppi tpm_ppi_qemu = {
+ .name = TPM_PPI_QEMU_NAME,
+ .init = tpm_ppi_init,
+ .deinit = tpm_ppi_deinit,
+ .write_dsdt_regions = tpm_ppi_write_dsdt_regions,
+ .write_dsdt_dsm = tpm_ppi_write_dsdt_dsm,
+};
+TPM_PPI_SET(tpm_ppi_qemu);
diff --git a/usr.sbin/bhyve/uart_backend.c b/usr.sbin/bhyve/uart_backend.c
new file mode 100644
index 000000000000..8d91f4f671e1
--- /dev/null
+++ b/usr.sbin/bhyve/uart_backend.c
@@ -0,0 +1,348 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2012 NetApp, Inc.
+ * Copyright (c) 2013 Neel Natu <neel@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+
+#include <machine/vmm.h>
+#include <machine/vmm_snapshot.h>
+
+#include <assert.h>
+#include <capsicum_helpers.h>
+#include <err.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <termios.h>
+#include <unistd.h>
+
+#include "debug.h"
+#include "mevent.h"
+#include "uart_backend.h"
+
+struct ttyfd {
+ bool opened;
+ int rfd; /* fd for reading */
+ int wfd; /* fd for writing, may be == rfd */
+};
+
+#define FIFOSZ 16
+
+struct fifo {
+ uint8_t buf[FIFOSZ];
+ int rindex; /* index to read from */
+ int windex; /* index to write to */
+ int num; /* number of characters in the fifo */
+ int size; /* size of the fifo */
+};
+
+struct uart_softc {
+ struct ttyfd tty;
+ struct fifo rxfifo;
+ struct mevent *mev;
+};
+
+static bool uart_stdio; /* stdio in use for i/o */
+static struct termios tio_stdio_orig;
+
+static void
+ttyclose(void)
+{
+ tcsetattr(STDIN_FILENO, TCSANOW, &tio_stdio_orig);
+}
+
+static void
+ttyopen(struct ttyfd *tf)
+{
+ struct termios orig, new;
+
+ tcgetattr(tf->rfd, &orig);
+ new = orig;
+ cfmakeraw(&new);
+ new.c_cflag |= CLOCAL;
+ tcsetattr(tf->rfd, TCSANOW, &new);
+ if (uart_stdio) {
+ tio_stdio_orig = orig;
+ atexit(ttyclose);
+ }
+ raw_stdio = 1;
+}
+
+static int
+ttyread(struct ttyfd *tf)
+{
+ unsigned char rb;
+
+ if (read(tf->rfd, &rb, 1) == 1)
+ return (rb);
+ else
+ return (-1);
+}
+
+static void
+ttywrite(struct ttyfd *tf, unsigned char wb)
+{
+ (void)write(tf->wfd, &wb, 1);
+}
+
+static bool
+rxfifo_available(struct uart_softc *sc)
+{
+ return (sc->rxfifo.num < sc->rxfifo.size);
+}
+
+int
+uart_rxfifo_getchar(struct uart_softc *sc)
+{
+ struct fifo *fifo;
+ int c, error, wasfull;
+
+ wasfull = 0;
+ fifo = &sc->rxfifo;
+ if (fifo->num > 0) {
+ if (!rxfifo_available(sc))
+ wasfull = 1;
+ c = fifo->buf[fifo->rindex];
+ fifo->rindex = (fifo->rindex + 1) % fifo->size;
+ fifo->num--;
+ if (wasfull) {
+ if (sc->tty.opened) {
+ error = mevent_enable(sc->mev);
+ assert(error == 0);
+ }
+ }
+ return (c);
+ } else
+ return (-1);
+}
+
+int
+uart_rxfifo_numchars(struct uart_softc *sc)
+{
+ return (sc->rxfifo.num);
+}
+
+static int
+rxfifo_putchar(struct uart_softc *sc, uint8_t ch)
+{
+ struct fifo *fifo;
+ int error;
+
+ fifo = &sc->rxfifo;
+
+ if (fifo->num < fifo->size) {
+ fifo->buf[fifo->windex] = ch;
+ fifo->windex = (fifo->windex + 1) % fifo->size;
+ fifo->num++;
+ if (!rxfifo_available(sc)) {
+ if (sc->tty.opened) {
+ /*
+ * Disable mevent callback if the FIFO is full.
+ */
+ error = mevent_disable(sc->mev);
+ assert(error == 0);
+ }
+ }
+ return (0);
+ } else
+ return (-1);
+}
+
+void
+uart_rxfifo_drain(struct uart_softc *sc, bool loopback)
+{
+ int ch;
+
+ if (loopback) {
+ (void)ttyread(&sc->tty);
+ } else {
+ while (rxfifo_available(sc) &&
+ ((ch = ttyread(&sc->tty)) != -1))
+ rxfifo_putchar(sc, ch);
+ }
+}
+
+int
+uart_rxfifo_putchar(struct uart_softc *sc, uint8_t ch, bool loopback)
+{
+ if (loopback) {
+ return (rxfifo_putchar(sc, ch));
+ } else if (sc->tty.opened) {
+ ttywrite(&sc->tty, ch);
+ return (0);
+ } else {
+ /* Drop on the floor. */
+ return (0);
+ }
+}
+
+void
+uart_rxfifo_reset(struct uart_softc *sc, int size)
+{
+ char flushbuf[32];
+ struct fifo *fifo;
+ ssize_t nread;
+ int error;
+
+ fifo = &sc->rxfifo;
+ bzero(fifo, sizeof(struct fifo));
+ fifo->size = size;
+
+ if (sc->tty.opened) {
+ /*
+ * Flush any unread input from the tty buffer.
+ */
+ while (1) {
+ nread = read(sc->tty.rfd, flushbuf, sizeof(flushbuf));
+ if (nread != sizeof(flushbuf))
+ break;
+ }
+
+ /*
+ * Enable mevent to trigger when new characters are available
+ * on the tty fd.
+ */
+ error = mevent_enable(sc->mev);
+ assert(error == 0);
+ }
+}
+
+int
+uart_rxfifo_size(struct uart_softc *sc __unused)
+{
+ return (FIFOSZ);
+}
+
+#ifdef BHYVE_SNAPSHOT
+int
+uart_rxfifo_snapshot(struct uart_softc *sc, struct vm_snapshot_meta *meta)
+{
+ int ret;
+
+ SNAPSHOT_VAR_OR_LEAVE(sc->rxfifo.rindex, meta, ret, done);
+ SNAPSHOT_VAR_OR_LEAVE(sc->rxfifo.windex, meta, ret, done);
+ SNAPSHOT_VAR_OR_LEAVE(sc->rxfifo.num, meta, ret, done);
+ SNAPSHOT_VAR_OR_LEAVE(sc->rxfifo.size, meta, ret, done);
+ SNAPSHOT_BUF_OR_LEAVE(sc->rxfifo.buf, sizeof(sc->rxfifo.buf),
+ meta, ret, done);
+
+done:
+ return (ret);
+}
+#endif
+
+static int
+uart_stdio_backend(struct uart_softc *sc)
+{
+#ifndef WITHOUT_CAPSICUM
+ cap_rights_t rights;
+ cap_ioctl_t cmds[] = { TIOCGETA, TIOCSETA, TIOCGWINSZ };
+#endif
+
+ if (uart_stdio)
+ return (-1);
+
+ sc->tty.rfd = STDIN_FILENO;
+ sc->tty.wfd = STDOUT_FILENO;
+ sc->tty.opened = true;
+
+ if (fcntl(sc->tty.rfd, F_SETFL, O_NONBLOCK) != 0)
+ return (-1);
+ if (fcntl(sc->tty.wfd, F_SETFL, O_NONBLOCK) != 0)
+ return (-1);
+
+#ifndef WITHOUT_CAPSICUM
+ cap_rights_init(&rights, CAP_EVENT, CAP_IOCTL, CAP_READ);
+ if (caph_rights_limit(sc->tty.rfd, &rights) == -1)
+ errx(EX_OSERR, "Unable to apply rights for sandbox");
+ if (caph_ioctls_limit(sc->tty.rfd, cmds, nitems(cmds)) == -1)
+ errx(EX_OSERR, "Unable to apply rights for sandbox");
+#endif
+
+ uart_stdio = true;
+
+ return (0);
+}
+
+static int
+uart_tty_backend(struct uart_softc *sc, const char *path)
+{
+#ifndef WITHOUT_CAPSICUM
+ cap_rights_t rights;
+ cap_ioctl_t cmds[] = { TIOCGETA, TIOCSETA, TIOCGWINSZ };
+#endif
+ int fd;
+
+ fd = open(path, O_RDWR | O_NONBLOCK);
+ if (fd < 0)
+ return (-1);
+
+ if (!isatty(fd)) {
+ close(fd);
+ return (-1);
+ }
+
+ sc->tty.rfd = sc->tty.wfd = fd;
+ sc->tty.opened = true;
+
+#ifndef WITHOUT_CAPSICUM
+ cap_rights_init(&rights, CAP_EVENT, CAP_IOCTL, CAP_READ, CAP_WRITE);
+ if (caph_rights_limit(fd, &rights) == -1)
+ errx(EX_OSERR, "Unable to apply rights for sandbox");
+ if (caph_ioctls_limit(fd, cmds, nitems(cmds)) == -1)
+ errx(EX_OSERR, "Unable to apply rights for sandbox");
+#endif
+
+ return (0);
+}
+
+struct uart_softc *
+uart_init(void)
+{
+ return (calloc(1, sizeof(struct uart_softc)));
+}
+
+int
+uart_tty_open(struct uart_softc *sc, const char *path,
+ void (*drain)(int, enum ev_type, void *), void *arg)
+{
+ int retval;
+
+ if (strcmp("stdio", path) == 0)
+ retval = uart_stdio_backend(sc);
+ else
+ retval = uart_tty_backend(sc, path);
+ if (retval == 0) {
+ ttyopen(&sc->tty);
+ sc->mev = mevent_add(sc->tty.rfd, EVF_READ, drain, arg);
+ assert(sc->mev != NULL);
+ }
+
+ return (retval);
+}
diff --git a/usr.sbin/bhyve/uart_backend.h b/usr.sbin/bhyve/uart_backend.h
new file mode 100644
index 000000000000..fa7949ad6d1c
--- /dev/null
+++ b/usr.sbin/bhyve/uart_backend.h
@@ -0,0 +1,55 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2012 NetApp, Inc.
+ * Copyright (c) 2013 Neel Natu <neel@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _UART_BACKEND_H_
+#define _UART_BACKEND_H_
+
+#include <stdbool.h>
+
+#include "mevent.h"
+
+struct uart_softc;
+struct vm_snapshot_meta;
+
+void uart_rxfifo_drain(struct uart_softc *sc, bool loopback);
+int uart_rxfifo_getchar(struct uart_softc *sc);
+int uart_rxfifo_numchars(struct uart_softc *sc);
+int uart_rxfifo_putchar(struct uart_softc *sc, uint8_t ch, bool loopback);
+void uart_rxfifo_reset(struct uart_softc *sc, int size);
+int uart_rxfifo_size(struct uart_softc *sc);
+#ifdef BHYVE_SNAPSHOT
+int uart_rxfifo_snapshot(struct uart_softc *sc,
+ struct vm_snapshot_meta *meta);
+#endif
+
+struct uart_softc *uart_init(void);
+int uart_tty_open(struct uart_softc *sc, const char *path,
+ void (*drain)(int, enum ev_type, void *), void *arg);
+
+#endif /* _UART_BACKEND_H_ */
diff --git a/usr.sbin/bhyve/uart_emul.c b/usr.sbin/bhyve/uart_emul.c
index 725a789a5898..58d6697e4fea 100644
--- a/usr.sbin/bhyve/uart_emul.c
+++ b/usr.sbin/bhyve/uart_emul.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 NetApp, Inc.
* Copyright (c) 2013 Neel Natu <neel@freebsd.org>
@@ -25,38 +25,24 @@
* 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 <sys/types.h>
#include <dev/ic/ns16550.h>
-#ifndef WITHOUT_CAPSICUM
-#include <sys/capsicum.h>
-#include <capsicum_helpers.h>
-#endif
#include <machine/vmm_snapshot.h>
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
-#include <assert.h>
-#include <err.h>
#include <errno.h>
-#include <fcntl.h>
-#include <termios.h>
#include <unistd.h>
#include <stdbool.h>
#include <string.h>
#include <pthread.h>
-#include <sysexits.h>
-#include "mevent.h"
+#include "uart_backend.h"
#include "uart_emul.h"
-#include "debug.h"
#define COM1_BASE 0x3F8
#define COM1_IRQ 4
@@ -68,7 +54,7 @@ __FBSDID("$FreeBSD$");
#define COM4_IRQ 3
#define DEFAULT_RCLK 1843200
-#define DEFAULT_BAUD 9600
+#define DEFAULT_BAUD 115200
#define FCR_RX_MASK 0xC0
@@ -81,11 +67,6 @@ __FBSDID("$FreeBSD$");
#define REG_SCR com_scr
#endif
-#define FIFOSZ 16
-
-static bool uart_stdio; /* stdio in use for i/o */
-static struct termios tio_stdio_orig;
-
static struct {
int baseaddr;
int irq;
@@ -99,21 +80,9 @@ static struct {
#define UART_NLDEVS (sizeof(uart_lres) / sizeof(uart_lres[0]))
-struct fifo {
- uint8_t buf[FIFOSZ];
- int rindex; /* index to read from */
- int windex; /* index to write to */
- int num; /* number of characters in the fifo */
- int size; /* size of the fifo */
-};
-
-struct ttyfd {
- bool opened;
- int rfd; /* fd for reading */
- int wfd; /* fd for writing, may be == rfd */
-};
+struct uart_ns16550_softc {
+ struct uart_softc *backend;
-struct uart_softc {
pthread_mutex_t mtx; /* protects all softc elements */
uint8_t data; /* Data register (R/W) */
uint8_t ier; /* Interrupt enable register (R/W) */
@@ -127,10 +96,6 @@ struct uart_softc {
uint8_t dll; /* Baudrate divisor latch LSB */
uint8_t dlh; /* Baudrate divisor latch MSB */
- struct fifo rxfifo;
- struct mevent *mev;
-
- struct ttyfd tty;
bool thre_int_pending; /* THRE interrupt pending */
void *arg;
@@ -138,158 +103,6 @@ struct uart_softc {
uart_intr_func_t intr_deassert;
};
-static void uart_drain(int fd, enum ev_type ev, void *arg);
-
-static void
-ttyclose(void)
-{
-
- tcsetattr(STDIN_FILENO, TCSANOW, &tio_stdio_orig);
-}
-
-static void
-ttyopen(struct ttyfd *tf)
-{
- struct termios orig, new;
-
- tcgetattr(tf->rfd, &orig);
- new = orig;
- cfmakeraw(&new);
- new.c_cflag |= CLOCAL;
- tcsetattr(tf->rfd, TCSANOW, &new);
- if (uart_stdio) {
- tio_stdio_orig = orig;
- atexit(ttyclose);
- }
- raw_stdio = 1;
-}
-
-static int
-ttyread(struct ttyfd *tf)
-{
- unsigned char rb;
-
- if (read(tf->rfd, &rb, 1) == 1)
- return (rb);
- else
- return (-1);
-}
-
-static void
-ttywrite(struct ttyfd *tf, unsigned char wb)
-{
-
- (void)write(tf->wfd, &wb, 1);
-}
-
-static void
-rxfifo_reset(struct uart_softc *sc, int size)
-{
- char flushbuf[32];
- struct fifo *fifo;
- ssize_t nread;
- int error;
-
- fifo = &sc->rxfifo;
- bzero(fifo, sizeof(struct fifo));
- fifo->size = size;
-
- if (sc->tty.opened) {
- /*
- * Flush any unread input from the tty buffer.
- */
- while (1) {
- nread = read(sc->tty.rfd, flushbuf, sizeof(flushbuf));
- if (nread != sizeof(flushbuf))
- break;
- }
-
- /*
- * Enable mevent to trigger when new characters are available
- * on the tty fd.
- */
- error = mevent_enable(sc->mev);
- assert(error == 0);
- }
-}
-
-static int
-rxfifo_available(struct uart_softc *sc)
-{
- struct fifo *fifo;
-
- fifo = &sc->rxfifo;
- return (fifo->num < fifo->size);
-}
-
-static int
-rxfifo_putchar(struct uart_softc *sc, uint8_t ch)
-{
- struct fifo *fifo;
- int error;
-
- fifo = &sc->rxfifo;
-
- if (fifo->num < fifo->size) {
- fifo->buf[fifo->windex] = ch;
- fifo->windex = (fifo->windex + 1) % fifo->size;
- fifo->num++;
- if (!rxfifo_available(sc)) {
- if (sc->tty.opened) {
- /*
- * Disable mevent callback if the FIFO is full.
- */
- error = mevent_disable(sc->mev);
- assert(error == 0);
- }
- }
- return (0);
- } else
- return (-1);
-}
-
-static int
-rxfifo_getchar(struct uart_softc *sc)
-{
- struct fifo *fifo;
- int c, error, wasfull;
-
- wasfull = 0;
- fifo = &sc->rxfifo;
- if (fifo->num > 0) {
- if (!rxfifo_available(sc))
- wasfull = 1;
- c = fifo->buf[fifo->rindex];
- fifo->rindex = (fifo->rindex + 1) % fifo->size;
- fifo->num--;
- if (wasfull) {
- if (sc->tty.opened) {
- error = mevent_enable(sc->mev);
- assert(error == 0);
- }
- }
- return (c);
- } else
- return (-1);
-}
-
-static int
-rxfifo_numchars(struct uart_softc *sc)
-{
- struct fifo *fifo = &sc->rxfifo;
-
- return (fifo->num);
-}
-
-static void
-uart_opentty(struct uart_softc *sc)
-{
-
- ttyopen(&sc->tty);
- sc->mev = mevent_add(sc->tty.rfd, EVF_READ, uart_drain, sc);
- assert(sc->mev != NULL);
-}
-
static uint8_t
modem_status(uint8_t mcr)
{
@@ -330,12 +143,13 @@ modem_status(uint8_t mcr)
* Return an interrupt reason if one is available.
*/
static int
-uart_intr_reason(struct uart_softc *sc)
+uart_intr_reason(struct uart_ns16550_softc *sc)
{
if ((sc->lsr & LSR_OE) != 0 && (sc->ier & IER_ERLS) != 0)
return (IIR_RLS);
- else if (rxfifo_numchars(sc) > 0 && (sc->ier & IER_ERXRDY) != 0)
+ else if (uart_rxfifo_numchars(sc->backend) > 0 &&
+ (sc->ier & IER_ERXRDY) != 0)
return (IIR_RXTOUT);
else if (sc->thre_int_pending && (sc->ier & IER_ETXRDY) != 0)
return (IIR_TXRDY);
@@ -346,7 +160,7 @@ uart_intr_reason(struct uart_softc *sc)
}
static void
-uart_reset(struct uart_softc *sc)
+uart_reset(struct uart_ns16550_softc *sc)
{
uint16_t divisor;
@@ -355,7 +169,7 @@ uart_reset(struct uart_softc *sc)
sc->dlh = divisor >> 16;
sc->msr = modem_status(sc->mcr);
- rxfifo_reset(sc, 1); /* no fifo until enabled by software */
+ uart_rxfifo_reset(sc->backend, 1);
}
/*
@@ -363,7 +177,7 @@ uart_reset(struct uart_softc *sc)
* interrupt condition to report to the processor.
*/
static void
-uart_toggle_intr(struct uart_softc *sc)
+uart_toggle_intr(struct uart_ns16550_softc *sc)
{
uint8_t intr_reason;
@@ -376,14 +190,13 @@ uart_toggle_intr(struct uart_softc *sc)
}
static void
-uart_drain(int fd, enum ev_type ev, void *arg)
+uart_drain(int fd __unused, enum ev_type ev, void *arg)
{
- struct uart_softc *sc;
- int ch;
+ struct uart_ns16550_softc *sc;
+ bool loopback;
sc = arg;
- assert(fd == sc->tty.rfd);
assert(ev == EVF_READ);
/*
@@ -393,21 +206,16 @@ uart_drain(int fd, enum ev_type ev, void *arg)
*/
pthread_mutex_lock(&sc->mtx);
- if ((sc->mcr & MCR_LOOPBACK) != 0) {
- (void) ttyread(&sc->tty);
- } else {
- while (rxfifo_available(sc) &&
- ((ch = ttyread(&sc->tty)) != -1)) {
- rxfifo_putchar(sc, ch);
- }
+ loopback = (sc->mcr & MCR_LOOPBACK) != 0;
+ uart_rxfifo_drain(sc->backend, loopback);
+ if (!loopback)
uart_toggle_intr(sc);
- }
pthread_mutex_unlock(&sc->mtx);
}
void
-uart_write(struct uart_softc *sc, int offset, uint8_t value)
+uart_ns16550_write(struct uart_ns16550_softc *sc, int offset, uint8_t value)
{
int fifosz;
uint8_t msr;
@@ -431,12 +239,9 @@ uart_write(struct uart_softc *sc, int offset, uint8_t value)
switch (offset) {
case REG_DATA:
- if (sc->mcr & MCR_LOOPBACK) {
- if (rxfifo_putchar(sc, value) != 0)
- sc->lsr |= LSR_OE;
- } else if (sc->tty.opened) {
- ttywrite(&sc->tty, value);
- } /* else drop on floor */
+ if (uart_rxfifo_putchar(sc->backend, value,
+ (sc->mcr & MCR_LOOPBACK) != 0))
+ sc->lsr |= LSR_OE;
sc->thre_int_pending = true;
break;
case REG_IER:
@@ -455,8 +260,9 @@ uart_write(struct uart_softc *sc, int offset, uint8_t value)
* the FIFO contents are reset.
*/
if ((sc->fcr & FCR_ENABLE) ^ (value & FCR_ENABLE)) {
- fifosz = (value & FCR_ENABLE) ? FIFOSZ : 1;
- rxfifo_reset(sc, fifosz);
+ fifosz = (value & FCR_ENABLE) ?
+ uart_rxfifo_size(sc->backend) : 1;
+ uart_rxfifo_reset(sc->backend, fifosz);
}
/*
@@ -467,7 +273,8 @@ uart_write(struct uart_softc *sc, int offset, uint8_t value)
sc->fcr = 0;
} else {
if ((value & FCR_RCV_RST) != 0)
- rxfifo_reset(sc, FIFOSZ);
+ uart_rxfifo_reset(sc->backend,
+ uart_rxfifo_size(sc->backend));
sc->fcr = value &
(FCR_ENABLE | FCR_DMA | FCR_RX_MASK);
@@ -526,7 +333,7 @@ done:
}
uint8_t
-uart_read(struct uart_softc *sc, int offset)
+uart_ns16550_read(struct uart_ns16550_softc *sc, int offset)
{
uint8_t iir, intr_reason, reg;
@@ -549,7 +356,7 @@ uart_read(struct uart_softc *sc, int offset)
switch (offset) {
case REG_DATA:
- reg = rxfifo_getchar(sc);
+ reg = uart_rxfifo_getchar(sc->backend);
break;
case REG_IER:
reg = sc->ier;
@@ -580,7 +387,7 @@ uart_read(struct uart_softc *sc, int offset)
sc->lsr |= LSR_TEMT | LSR_THRE;
/* Check for new receive data */
- if (rxfifo_numchars(sc) > 0)
+ if (uart_rxfifo_numchars(sc->backend) > 0)
sc->lsr |= LSR_RXRDY;
else
sc->lsr &= ~LSR_RXRDY;
@@ -616,7 +423,7 @@ int
uart_legacy_alloc(int which, int *baseaddr, int *irq)
{
- if (which < 0 || which >= UART_NLDEVS || uart_lres[which].inuse)
+ if (which < 0 || which >= (int)UART_NLDEVS || uart_lres[which].inuse)
return (-1);
uart_lres[which].inuse = true;
@@ -626,17 +433,18 @@ uart_legacy_alloc(int which, int *baseaddr, int *irq)
return (0);
}
-struct uart_softc *
-uart_init(uart_intr_func_t intr_assert, uart_intr_func_t intr_deassert,
+struct uart_ns16550_softc *
+uart_ns16550_init(uart_intr_func_t intr_assert, uart_intr_func_t intr_deassert,
void *arg)
{
- struct uart_softc *sc;
+ struct uart_ns16550_softc *sc;
- sc = calloc(1, sizeof(struct uart_softc));
+ sc = calloc(1, sizeof(struct uart_ns16550_softc));
sc->arg = arg;
sc->intr_assert = intr_assert;
sc->intr_deassert = intr_deassert;
+ sc->backend = uart_init();
pthread_mutex_init(&sc->mtx, NULL);
@@ -645,92 +453,16 @@ uart_init(uart_intr_func_t intr_assert, uart_intr_func_t intr_deassert,
return (sc);
}
-static int
-uart_stdio_backend(struct uart_softc *sc)
-{
-#ifndef WITHOUT_CAPSICUM
- cap_rights_t rights;
- cap_ioctl_t cmds[] = { TIOCGETA, TIOCSETA, TIOCGWINSZ };
-#endif
-
- if (uart_stdio)
- return (-1);
-
- sc->tty.rfd = STDIN_FILENO;
- sc->tty.wfd = STDOUT_FILENO;
- sc->tty.opened = true;
-
- if (fcntl(sc->tty.rfd, F_SETFL, O_NONBLOCK) != 0)
- return (-1);
- if (fcntl(sc->tty.wfd, F_SETFL, O_NONBLOCK) != 0)
- return (-1);
-
-#ifndef WITHOUT_CAPSICUM
- cap_rights_init(&rights, CAP_EVENT, CAP_IOCTL, CAP_READ);
- if (caph_rights_limit(sc->tty.rfd, &rights) == -1)
- errx(EX_OSERR, "Unable to apply rights for sandbox");
- if (caph_ioctls_limit(sc->tty.rfd, cmds, nitems(cmds)) == -1)
- errx(EX_OSERR, "Unable to apply rights for sandbox");
-#endif
-
- uart_stdio = true;
-
- return (0);
-}
-
-static int
-uart_tty_backend(struct uart_softc *sc, const char *path)
-{
-#ifndef WITHOUT_CAPSICUM
- cap_rights_t rights;
- cap_ioctl_t cmds[] = { TIOCGETA, TIOCSETA, TIOCGWINSZ };
-#endif
- int fd;
-
- fd = open(path, O_RDWR | O_NONBLOCK);
- if (fd < 0)
- return (-1);
-
- if (!isatty(fd)) {
- close(fd);
- return (-1);
- }
-
- sc->tty.rfd = sc->tty.wfd = fd;
- sc->tty.opened = true;
-
-#ifndef WITHOUT_CAPSICUM
- cap_rights_init(&rights, CAP_EVENT, CAP_IOCTL, CAP_READ, CAP_WRITE);
- if (caph_rights_limit(fd, &rights) == -1)
- errx(EX_OSERR, "Unable to apply rights for sandbox");
- if (caph_ioctls_limit(fd, cmds, nitems(cmds)) == -1)
- errx(EX_OSERR, "Unable to apply rights for sandbox");
-#endif
-
- return (0);
-}
-
int
-uart_set_backend(struct uart_softc *sc, const char *device)
+uart_ns16550_tty_open(struct uart_ns16550_softc *sc, const char *device)
{
- int retval;
-
- if (device == NULL)
- return (0);
-
- if (strcmp("stdio", device) == 0)
- retval = uart_stdio_backend(sc);
- else
- retval = uart_tty_backend(sc, device);
- if (retval == 0)
- uart_opentty(sc);
-
- return (retval);
+ return (uart_tty_open(sc->backend, device, uart_drain, sc));
}
#ifdef BHYVE_SNAPSHOT
int
-uart_snapshot(struct uart_softc *sc, struct vm_snapshot_meta *meta)
+uart_ns16550_snapshot(struct uart_ns16550_softc *sc,
+ struct vm_snapshot_meta *meta)
{
int ret;
@@ -746,12 +478,7 @@ uart_snapshot(struct uart_softc *sc, struct vm_snapshot_meta *meta)
SNAPSHOT_VAR_OR_LEAVE(sc->dll, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(sc->dlh, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(sc->rxfifo.rindex, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(sc->rxfifo.windex, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(sc->rxfifo.num, meta, ret, done);
- SNAPSHOT_VAR_OR_LEAVE(sc->rxfifo.size, meta, ret, done);
- SNAPSHOT_BUF_OR_LEAVE(sc->rxfifo.buf, sizeof(sc->rxfifo.buf),
- meta, ret, done);
+ ret = uart_rxfifo_snapshot(sc->backend, meta);
sc->thre_int_pending = 1;
diff --git a/usr.sbin/bhyve/uart_emul.h b/usr.sbin/bhyve/uart_emul.h
index a66701c18580..129314153d3f 100644
--- a/usr.sbin/bhyve/uart_emul.h
+++ b/usr.sbin/bhyve/uart_emul.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Neel Natu <neel@freebsd.org>
* All rights reserved.
@@ -24,27 +24,38 @@
* 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 _UART_EMUL_H_
#define _UART_EMUL_H_
-#define UART_IO_BAR_SIZE 8
+#define UART_NS16550_IO_BAR_SIZE 8
-struct uart_softc;
+struct uart_ns16550_softc;
+struct uart_pl011_softc;
struct vm_snapshot_meta;
typedef void (*uart_intr_func_t)(void *arg);
-struct uart_softc *uart_init(uart_intr_func_t intr_assert,
- uart_intr_func_t intr_deassert, void *arg);
int uart_legacy_alloc(int unit, int *ioaddr, int *irq);
-uint8_t uart_read(struct uart_softc *sc, int offset);
-void uart_write(struct uart_softc *sc, int offset, uint8_t value);
-int uart_set_backend(struct uart_softc *sc, const char *device);
+
+struct uart_ns16550_softc *uart_ns16550_init(uart_intr_func_t intr_assert,
+ uart_intr_func_t intr_deassert, void *arg);
+uint8_t uart_ns16550_read(struct uart_ns16550_softc *sc, int offset);
+void uart_ns16550_write(struct uart_ns16550_softc *sc, int offset,
+ uint8_t value);
+int uart_ns16550_tty_open(struct uart_ns16550_softc *sc,
+ const char *device);
#ifdef BHYVE_SNAPSHOT
-int uart_snapshot(struct uart_softc *sc, struct vm_snapshot_meta *meta);
-#endif
+int uart_ns16550_snapshot(struct uart_ns16550_softc *sc,
+ struct vm_snapshot_meta *meta);
#endif
+
+uint32_t uart_pl011_read(struct uart_pl011_softc *sc, int offset);
+void uart_pl011_write(struct uart_pl011_softc *sc, int offset,
+ uint32_t value);
+struct uart_pl011_softc *uart_pl011_init(uart_intr_func_t intr_assert,
+ uart_intr_func_t intr_deassert, void *arg);
+int uart_pl011_tty_open(struct uart_pl011_softc *sc, const char *device);
+
+#endif /* _UART_EMUL_H_ */
diff --git a/usr.sbin/bhyve/uart_pl011.c b/usr.sbin/bhyve/uart_pl011.c
new file mode 100644
index 000000000000..e2d5c8bf5657
--- /dev/null
+++ b/usr.sbin/bhyve/uart_pl011.c
@@ -0,0 +1,394 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2020 Andrew Turner
+ *
+ * This work was supported by Innovate UK project 105694, "Digital Security
+ * by Design (DSbD) Technology Platform Prototype".
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+
+#include <assert.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "uart_backend.h"
+#include "uart_emul.h"
+
+#define UART_FIFO_SIZE 16
+
+#define UARTDR 0x00
+#define UARTDR_RSR_SHIFT 8
+
+#define UARTRSR 0x01
+#define UARTRSR_OE (1 << 3)
+
+#define UARTFR 0x06
+#define UARTFR_TXFE (1 << 7)
+#define UARTFR_RXFF (1 << 6)
+#define UARTFR_TXFF (1 << 5)
+#define UARTFR_RXFE (1 << 4)
+
+#define UARTRTINTR (1 << 6)
+#define UARTTXINTR (1 << 5)
+#define UARTRXINTR (1 << 4)
+
+#define UARTIBRD 0x09
+
+#define UARTFBRD 0x0a
+#define UARTFBRD_MASK 0x003f
+
+#define UARTLCR_H 0x0b
+#define UARTLCR_H_MASK 0x00ff
+#define UARTLCR_H_FEN (1 << 4)
+
+#define UARTCR 0x0c
+/* TODO: Check the flags in the UARTCR register */
+#define UARTCR_MASK 0xffc7
+#define UARTCR_LBE (1 << 7)
+
+#define UARTIFLS 0x0d
+#define UARTIFLS_MASK 0x003f
+#define UARTIFLS_RXIFLSEL(x) (((x) >> 3) & 0x7)
+#define UARTIFLS_TXIFLSEL(x) (((x) >> 0) & 0x7)
+
+#define UARTIMSC 0x0e
+#define UARTIMSC_MASK 0x07ff
+
+#define UARTRIS 0x0f
+#define UARTMIS 0x10
+
+#define UARTICR 0x11
+
+#define UARTPeriphID 0x00241011
+#define UARTPeriphID0 0x3f8
+#define UARTPeriphID0_VAL (((UARTPeriphID) >> 0) & 0xff)
+#define UARTPeriphID1 0x3f9
+#define UARTPeriphID1_VAL (((UARTPeriphID) >> 8) & 0xff)
+#define UARTPeriphID2 0x3fa
+#define UARTPeriphID2_VAL (((UARTPeriphID) >> 16) & 0xff)
+#define UARTPeriphID3 0x3fb
+#define UARTPeriphID3_VAL (((UARTPeriphID) >> 24) & 0xff)
+
+#define UARTPCellID 0xb105f00d
+#define UARTPCellID0 0x3fc
+#define UARTPCellID0_VAL (((UARTPCellID) >> 0) & 0xff)
+#define UARTPCellID1 0x3fd
+#define UARTPCellID1_VAL (((UARTPCellID) >> 8) & 0xff)
+#define UARTPCellID2 0x3fe
+#define UARTPCellID2_VAL (((UARTPCellID) >> 16) & 0xff)
+#define UARTPCellID3 0x3ff
+#define UARTPCellID3_VAL (((UARTPCellID) >> 24) & 0xff)
+
+struct uart_pl011_softc {
+ struct uart_softc *backend;
+ pthread_mutex_t mtx; /* protects all softc elements */
+
+ uint16_t irq_state;
+
+ uint16_t rsr;
+
+ uint16_t cr;
+ uint16_t ifls;
+ uint16_t imsc;
+ uint16_t lcr_h;
+
+ uint16_t ibrd;
+ uint16_t fbrd;
+
+ void *arg;
+ uart_intr_func_t intr_assert;
+ uart_intr_func_t intr_deassert;
+};
+
+static void
+uart_reset(struct uart_pl011_softc *sc)
+{
+ sc->ifls = 0x12;
+
+ /* no fifo until enabled by software */
+ uart_rxfifo_reset(sc->backend, 1);
+}
+
+static int
+uart_rx_trigger_level(struct uart_pl011_softc *sc)
+{
+ /* If the FIFO is disabled trigger when we have any data */
+ if ((sc->lcr_h & UARTLCR_H_FEN) != 0)
+ return (1);
+
+ /* Trigger base on how full the fifo is */
+ switch (UARTIFLS_RXIFLSEL(sc->ifls)) {
+ case 0:
+ return (UART_FIFO_SIZE / 8);
+ case 1:
+ return (UART_FIFO_SIZE / 4);
+ case 2:
+ return (UART_FIFO_SIZE / 2);
+ case 3:
+ return (UART_FIFO_SIZE * 3 / 4);
+ case 4:
+ return (UART_FIFO_SIZE * 7 / 8);
+ default:
+ /* TODO: Find out what happens in this case */
+ return (UART_FIFO_SIZE);
+ }
+}
+
+static void
+uart_toggle_intr(struct uart_pl011_softc *sc)
+{
+ if ((sc->irq_state & sc->imsc) == 0)
+ (*sc->intr_deassert)(sc->arg);
+ else
+ (*sc->intr_assert)(sc->arg);
+}
+
+static void
+uart_drain(int fd __unused, enum ev_type ev, void *arg)
+{
+ struct uart_pl011_softc *sc;
+ int old_size, trig_lvl;
+ bool loopback;
+
+ sc = arg;
+
+ assert(ev == EVF_READ);
+
+ /*
+ * This routine is called in the context of the mevent thread
+ * to take out the softc lock to protect against concurrent
+ * access from a vCPU i/o exit
+ */
+ pthread_mutex_lock(&sc->mtx);
+
+ old_size = uart_rxfifo_numchars(sc->backend);
+
+ loopback = (sc->cr & UARTCR_LBE) != 0;
+ uart_rxfifo_drain(sc->backend, loopback);
+
+ /* If we cross the trigger level raise UARTRXINTR */
+ trig_lvl = uart_rx_trigger_level(sc);
+ if (old_size < trig_lvl &&
+ uart_rxfifo_numchars(sc->backend) >= trig_lvl)
+ sc->irq_state |= UARTRXINTR;
+
+ if (uart_rxfifo_numchars(sc->backend) > 0)
+ sc->irq_state |= UARTRTINTR;
+ if (!loopback)
+ uart_toggle_intr(sc);
+
+ pthread_mutex_unlock(&sc->mtx);
+}
+
+void
+uart_pl011_write(struct uart_pl011_softc *sc, int offset, uint32_t value)
+{
+ bool loopback;
+
+ pthread_mutex_lock(&sc->mtx);
+ switch (offset) {
+ case UARTDR:
+ loopback = (sc->cr & UARTCR_LBE) != 0;
+ if (uart_rxfifo_putchar(sc->backend, value & 0xff, loopback))
+ sc->rsr |= UARTRSR_OE;
+
+ /* We don't have a TX fifo, so trigger when we have data */
+ sc->irq_state |= UARTTXINTR;
+ break;
+ case UARTRSR:
+ /* Any write clears this register */
+ sc->rsr = 0;
+ break;
+ case UARTFR:
+ /* UARTFR is a read-only register */
+ break;
+ /* TODO: UARTILPR */
+ case UARTIBRD:
+ sc->ibrd = value;
+ break;
+ case UARTFBRD:
+ sc->fbrd = value & UARTFBRD_MASK;
+ break;
+ case UARTLCR_H:
+ /* Check if the FIFO enable bit changed */
+ if (((sc->lcr_h ^ value) & UARTLCR_H_FEN) != 0) {
+ if ((value & UARTLCR_H_FEN) != 0) {
+ uart_rxfifo_reset(sc->backend, UART_FIFO_SIZE);
+ } else {
+ uart_rxfifo_reset(sc->backend, 1);
+ }
+ }
+ sc->lcr_h = value & UARTLCR_H_MASK;
+ break;
+ case UARTCR:
+ sc->cr = value & UARTCR_MASK;
+ break;
+ case UARTIFLS:
+ sc->ifls = value & UARTCR_MASK;
+ break;
+ case UARTIMSC:
+ sc->imsc = value & UARTIMSC_MASK;
+ break;
+ case UARTRIS:
+ case UARTMIS:
+ /* UARTRIS and UARTMIS are read-only registers */
+ break;
+ case UARTICR:
+ sc->irq_state &= ~value;
+ break;
+ default:
+ /* Ignore writes to unassigned/ID registers */
+ break;
+ }
+ uart_toggle_intr(sc);
+ pthread_mutex_unlock(&sc->mtx);
+}
+
+uint32_t
+uart_pl011_read(struct uart_pl011_softc *sc, int offset)
+{
+ uint32_t reg;
+ int fifo_sz;
+
+ reg = 0;
+ pthread_mutex_lock(&sc->mtx);
+ switch (offset) {
+ case UARTDR:
+ reg = uart_rxfifo_getchar(sc->backend);
+ /* Deassert the irq if below the trigger level */
+ fifo_sz = uart_rxfifo_numchars(sc->backend);
+ if (fifo_sz < uart_rx_trigger_level(sc))
+ sc->irq_state &= ~UARTRXINTR;
+ if (fifo_sz == 0)
+ sc->irq_state &= ~UARTRTINTR;
+
+ reg |= sc->rsr << UARTDR_RSR_SHIFT;
+
+ /* After reading from the fifo there is now space in it */
+ sc->rsr &= UARTRSR_OE;
+ break;
+ case UARTRSR:
+ /* Any write clears this register */
+ reg = sc->rsr;
+ break;
+ case UARTFR:
+ /* Transmit is intstant, so the fifo is always empty */
+ reg = UARTFR_TXFE;
+
+ /* Set the receive fifo full/empty flags */
+ fifo_sz = uart_rxfifo_numchars(sc->backend);
+ if (fifo_sz == UART_FIFO_SIZE)
+ reg |= UARTFR_RXFF;
+ else if (fifo_sz == 0)
+ reg |= UARTFR_RXFE;
+ break;
+ /* TODO: UARTILPR */
+ case UARTIBRD:
+ reg = sc->ibrd;
+ break;
+ case UARTFBRD:
+ reg = sc->fbrd;
+ break;
+ case UARTLCR_H:
+ reg = sc->lcr_h;
+ break;
+ case UARTCR:
+ reg = sc->cr;
+ break;
+ case UARTIMSC:
+ reg = sc->imsc;
+ break;
+ case UARTRIS:
+ reg = sc->irq_state;
+ break;
+ case UARTMIS:
+ reg = sc->irq_state & sc->imsc;
+ break;
+ case UARTICR:
+ reg = 0;
+ break;
+ case UARTPeriphID0:
+ reg = UARTPeriphID0_VAL;
+ break;
+ case UARTPeriphID1:
+ reg =UARTPeriphID1_VAL;
+ break;
+ case UARTPeriphID2:
+ reg = UARTPeriphID2_VAL;
+ break;
+ case UARTPeriphID3:
+ reg = UARTPeriphID3_VAL;
+ break;
+ case UARTPCellID0:
+ reg = UARTPCellID0_VAL;
+ break;
+ case UARTPCellID1:
+ reg = UARTPCellID1_VAL;
+ break;
+ case UARTPCellID2:
+ reg = UARTPCellID2_VAL;
+ break;
+ case UARTPCellID3:
+ reg = UARTPCellID3_VAL;
+ break;
+ default:
+ /* Return 0 in reads from unasigned registers */
+ reg = 0;
+ break;
+ }
+ uart_toggle_intr(sc);
+ pthread_mutex_unlock(&sc->mtx);
+
+ return (reg);
+}
+
+struct uart_pl011_softc *
+uart_pl011_init(uart_intr_func_t intr_assert, uart_intr_func_t intr_deassert,
+ void *arg)
+{
+ struct uart_pl011_softc *sc;
+
+ sc = calloc(1, sizeof(struct uart_pl011_softc));
+
+ sc->arg = arg;
+ sc->intr_assert = intr_assert;
+ sc->intr_deassert = intr_deassert;
+ sc->backend = uart_init();
+
+ pthread_mutex_init(&sc->mtx, NULL);
+
+ uart_reset(sc);
+
+ return (sc);
+}
+
+int
+uart_pl011_tty_open(struct uart_pl011_softc *sc, const char *device)
+{
+ return (uart_tty_open(sc->backend, device, uart_drain, sc));
+}
diff --git a/usr.sbin/bhyve/usb_emul.c b/usr.sbin/bhyve/usb_emul.c
index d97d7b38d2f8..1cb9d3043209 100644
--- a/usr.sbin/bhyve/usb_emul.c
+++ b/usr.sbin/bhyve/usb_emul.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Nahanni Systems Inc.
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/queue.h>
diff --git a/usr.sbin/bhyve/usb_emul.h b/usr.sbin/bhyve/usb_emul.h
index 67f4f3ff08f1..8e0afcb2878b 100644
--- a/usr.sbin/bhyve/usb_emul.h
+++ b/usr.sbin/bhyve/usb_emul.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Leon Dang <ldang@nahannisys.com>
* 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 _USB_EMUL_H_
@@ -49,7 +47,7 @@ struct vm_snapshot_meta;
/* Device emulation handlers */
struct usb_devemu {
- char *ue_emu; /* name of device emulation */
+ const char *ue_emu; /* name of device emulation */
int ue_usbver; /* usb version: 2 or 3 */
int ue_usbspeed; /* usb device speed */
@@ -65,7 +63,7 @@ struct usb_devemu {
int (*ue_stop)(void *sc);
int (*ue_snapshot)(void *scarg, struct vm_snapshot_meta *meta);
};
-#define USB_EMUL_SET(x) DATA_SET(usb_emu_set, x);
+#define USB_EMUL_SET(x) DATA_SET(usb_emu_set, x)
/*
* USB device events to notify HCI when state changes
@@ -91,7 +89,7 @@ struct usb_hci {
/*
* Each xfer block is mapped to the hci transfer block.
- * On input into the device handler, blen is set to the lenght of buf.
+ * On input into the device handler, blen is set to the length of buf.
* The device handler is to update blen to reflect on the residual size
* of the buffer, i.e. len(buf) - len(consumed).
*/
diff --git a/usr.sbin/bhyve/usb_mouse.c b/usr.sbin/bhyve/usb_mouse.c
index fbda9ef2579b..a37941c0cd9d 100644
--- a/usr.sbin/bhyve/usb_mouse.c
+++ b/usr.sbin/bhyve/usb_mouse.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Leon Dang <ldang@nahannisys.com>
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/time.h>
#include <machine/vmm_snapshot.h>
@@ -156,7 +154,7 @@ static struct usb_device_descriptor umouse_dev_desc = {
.bLength = sizeof(umouse_dev_desc),
.bDescriptorType = UDESC_DEVICE,
MSETW(.bcdUSB, UD_USB_3_0),
- .bMaxPacketSize = 8, /* max packet size */
+ .bMaxPacketSize = 9, /* max pkt size, 2^9 = 512 */
MSETW(.idVendor, 0xFB5D), /* vendor */
MSETW(.idProduct, 0x0001), /* product */
MSETW(.bcdDevice, 0), /* device version */
@@ -218,7 +216,7 @@ struct umouse_bos_desc {
} __packed;
-struct umouse_bos_desc umouse_bosd = {
+static struct umouse_bos_desc umouse_bosd = {
.bosd = {
.bLength = sizeof(umouse_bosd.bosd),
.bDescriptorType = UDESC_BOS,
@@ -297,7 +295,7 @@ umouse_event(uint8_t button, int x, int y, void *arg)
}
static void *
-umouse_init(struct usb_hci *hci, nvlist_t *nvl)
+umouse_init(struct usb_hci *hci, nvlist_t *nvl __unused)
{
struct umouse_softc *sc;
@@ -774,16 +772,14 @@ umouse_reset(void *scarg)
}
static int
-umouse_remove(void *scarg)
+umouse_remove(void *scarg __unused)
{
-
return (0);
}
static int
-umouse_stop(void *scarg)
+umouse_stop(void *scarg __unused)
{
-
return (0);
}
@@ -811,7 +807,7 @@ done:
}
#endif
-struct usb_devemu ue_mouse = {
+static struct usb_devemu ue_mouse = {
.ue_emu = "tablet",
.ue_usbver = 3,
.ue_usbspeed = USB_SPEED_HIGH,
diff --git a/usr.sbin/bhyve/virtio.c b/usr.sbin/bhyve/virtio.c
index ec7ddfe38f2e..26df39ceb5b3 100644
--- a/usr.sbin/bhyve/virtio.c
+++ b/usr.sbin/bhyve/virtio.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Chris Torek <torek @ torek net>
* All rights reserved.
@@ -27,14 +27,10 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/uio.h>
#include <machine/atomic.h>
-#include <machine/vmm_snapshot.h>
#include <dev/virtio/pci/virtio_pci_legacy_var.h>
@@ -47,6 +43,9 @@ __FBSDID("$FreeBSD$");
#include "bhyverun.h"
#include "debug.h"
#include "pci_emul.h"
+#ifdef BHYVE_SNAPSHOT
+#include "snapshot.h"
+#endif
#include "virtio.h"
/*
@@ -174,7 +173,7 @@ vi_intr_init(struct virtio_softc *vs, int barnum, int use_msix)
* The guest just gave us a page frame number, from which we can
* calculate the addresses of the queue.
*/
-void
+static void
vi_vq_init(struct virtio_softc *vs, uint32_t pfn)
{
struct vqueue_info *vq;
@@ -214,10 +213,9 @@ vi_vq_init(struct virtio_softc *vs, uint32_t pfn)
* descriptor.
*/
static inline void
-_vq_record(int i, volatile struct vring_desc *vd,
- struct vmctx *ctx, struct iovec *iov, int n_iov,
- struct vi_req *reqp) {
-
+_vq_record(int i, struct vring_desc *vd, struct vmctx *ctx, struct iovec *iov,
+ int n_iov, struct vi_req *reqp)
+{
if (i >= n_iov)
return;
iov[i].iov_base = paddr_guest2host(ctx, vd->addr, vd->len);
@@ -271,7 +269,7 @@ vq_getchain(struct vqueue_info *vq, struct iovec *iov, int niov,
u_int ndesc, n_indir;
u_int idx, next;
struct vi_req req;
- volatile struct vring_desc *vdir, *vindir, *vp;
+ struct vring_desc *vdir, *vindir, *vp;
struct vmctx *ctx;
struct virtio_softc *vs;
const char *name;
@@ -409,8 +407,8 @@ vq_retchains(struct vqueue_info *vq, uint16_t n_chains)
void
vq_relchain_prepare(struct vqueue_info *vq, uint16_t idx, uint32_t iolen)
{
- volatile struct vring_used *vuh;
- volatile struct vring_used_elem *vue;
+ struct vring_used *vuh;
+ struct vring_used_elem *vue;
uint16_t mask;
/*
@@ -559,8 +557,7 @@ vi_find_cr(int offset) {
* Otherwise dispatch to the actual driver.
*/
uint64_t
-vi_pci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size)
+vi_pci_read(struct pci_devinst *pi, int baridx, uint64_t offset, int size)
{
struct virtio_softc *vs = pi->pi_arg;
struct virtio_consts *vc;
@@ -679,8 +676,8 @@ done:
* Otherwise dispatch to the actual driver.
*/
void
-vi_pci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size, uint64_t value)
+vi_pci_write(struct pci_devinst *pi, int baridx, uint64_t offset, int size,
+ uint64_t value)
{
struct virtio_softc *vs = pi->pi_arg;
struct vqueue_info *vq;
@@ -772,7 +769,7 @@ bad:
vs->vs_curq = value;
break;
case VIRTIO_PCI_QUEUE_NOTIFY:
- if (value >= vc->vc_nvq) {
+ if (value >= (unsigned int)vc->vc_nvq) {
EPRINTLN("%s: queue %d notify out of range",
name, (int)value);
goto done;
@@ -815,7 +812,7 @@ done:
#ifdef BHYVE_SNAPSHOT
int
-vi_pci_pause(struct vmctx *ctx, struct pci_devinst *pi)
+vi_pci_pause(struct pci_devinst *pi)
{
struct virtio_softc *vs;
struct virtio_consts *vc;
@@ -831,7 +828,7 @@ vi_pci_pause(struct vmctx *ctx, struct pci_devinst *pi)
}
int
-vi_pci_resume(struct vmctx *ctx, struct pci_devinst *pi)
+vi_pci_resume(struct pci_devinst *pi)
{
struct virtio_softc *vs;
struct virtio_consts *vc;
@@ -882,8 +879,10 @@ vi_pci_snapshot_queues(struct virtio_softc *vs, struct vm_snapshot_meta *meta)
int ret;
struct virtio_consts *vc;
struct vqueue_info *vq;
+ struct vmctx *ctx;
uint64_t addr_size;
+ ctx = vs->vs_pi->pi_vmctx;
vc = vs->vs_vc;
/* Save virtio queue info */
@@ -905,15 +904,15 @@ vi_pci_snapshot_queues(struct virtio_softc *vs, struct vm_snapshot_meta *meta)
continue;
addr_size = vq->vq_qsize * sizeof(struct vring_desc);
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(vq->vq_desc, addr_size,
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(ctx, vq->vq_desc, addr_size,
false, meta, ret, done);
addr_size = (2 + vq->vq_qsize + 1) * sizeof(uint16_t);
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(vq->vq_avail, addr_size,
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(ctx, vq->vq_avail, addr_size,
false, meta, ret, done);
addr_size = (2 + 2 * vq->vq_qsize + 1) * sizeof(uint16_t);
- SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(vq->vq_used, addr_size,
+ SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(ctx, vq->vq_used, addr_size,
false, meta, ret, done);
SNAPSHOT_BUF_OR_LEAVE(vq->vq_desc,
diff --git a/usr.sbin/bhyve/virtio.h b/usr.sbin/bhyve/virtio.h
index 5300fb5dbef3..a4f37034d93d 100644
--- a/usr.sbin/bhyve/virtio.h
+++ b/usr.sbin/bhyve/virtio.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Chris Torek <torek @ torek net>
* 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 _BHYVE_VIRTIO_H_
@@ -99,7 +97,7 @@
* begin with a 16-bit <flags> field and 16-bit index <idx>, then
* have <N> 16-bit <ring> values, followed by one final 16-bit
* field <used_event>. The <N> <ring> entries are simply indices
- * indices into the descriptor ring (and thus must meet the same
+ * into the descriptor ring (and thus must meet the same
* constraints as each <next> value). However, <idx> is counted
* up from 0 (initially) and simply wraps around after 65535; it
* is taken mod <N> to find the next available entry.
@@ -195,7 +193,6 @@ vring_size_aligned(u_int qsz)
return (roundup2(vring_size(qsz, VRING_ALIGN), VRING_ALIGN));
}
-struct vmctx;
struct pci_devinst;
struct vqueue_info;
struct vm_snapshot_meta;
@@ -314,14 +311,14 @@ struct vqueue_info {
uint32_t vq_pfn; /* PFN of virt queue (not shifted!) */
- volatile struct vring_desc *vq_desc; /* descriptor array */
- volatile struct vring_avail *vq_avail; /* the "avail" ring */
- volatile struct vring_used *vq_used; /* the "used" ring */
+ struct vring_desc *vq_desc; /* descriptor array */
+ struct vring_avail *vq_avail; /* the "avail" ring */
+ struct vring_used *vq_used; /* the "used" ring */
};
/* as noted above, these are sort of backwards, name-wise */
#define VQ_AVAIL_EVENT_IDX(vq) \
- (*(volatile uint16_t *)&(vq)->vq_used->ring[(vq)->vq_qsize])
+ (*(uint16_t *)&(vq)->vq_used->ring[(vq)->vq_qsize])
#define VQ_USED_EVENT_IDX(vq) \
((vq)->vq_avail->ring[(vq)->vq_qsize])
@@ -426,13 +423,13 @@ void vq_relchain_publish(struct vqueue_info *vq);
void vq_relchain(struct vqueue_info *vq, uint16_t idx, uint32_t iolen);
void vq_endchains(struct vqueue_info *vq, int used_all_avail);
-uint64_t vi_pci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size);
-void vi_pci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
- int baridx, uint64_t offset, int size, uint64_t value);
+uint64_t vi_pci_read(struct pci_devinst *pi, int baridx, uint64_t offset,
+ int size);
+void vi_pci_write(struct pci_devinst *pi, int baridx, uint64_t offset,
+ int size, uint64_t value);
#ifdef BHYVE_SNAPSHOT
int vi_pci_snapshot(struct vm_snapshot_meta *meta);
-int vi_pci_pause(struct vmctx *ctx, struct pci_devinst *pi);
-int vi_pci_resume(struct vmctx *ctx, struct pci_devinst *pi);
+int vi_pci_pause(struct pci_devinst *pi);
+int vi_pci_resume(struct pci_devinst *pi);
#endif
#endif /* _BHYVE_VIRTIO_H_ */
diff --git a/usr.sbin/bhyve/vmexit.h b/usr.sbin/bhyve/vmexit.h
new file mode 100644
index 000000000000..c5c0d7ad5266
--- /dev/null
+++ b/usr.sbin/bhyve/vmexit.h
@@ -0,0 +1,34 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2011 NetApp, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _VMEXIT_H_
+#define _VMEXIT_H_
+
+extern const vmexit_handler_t vmexit_handlers[VM_EXITCODE_MAX];
+
+#endif /* !_VMEXIT_H_ */
diff --git a/usr.sbin/bhyve/vmgenc.c b/usr.sbin/bhyve/vmgenc.c
index 7d0b2faf246a..4dbbc7533f8b 100644
--- a/usr.sbin/bhyve/vmgenc.c
+++ b/usr.sbin/bhyve/vmgenc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright 2020 Conrad Meyer <cem@FreeBSD.org>. All rights reserved.
*
@@ -24,8 +24,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/mman.h>
diff --git a/usr.sbin/bhyve/vmgenc.h b/usr.sbin/bhyve/vmgenc.h
index 437824c1025d..0af79b5dfcf5 100644
--- a/usr.sbin/bhyve/vmgenc.h
+++ b/usr.sbin/bhyve/vmgenc.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright 2020 Conrad Meyer <cem@FreeBSD.org>. All rights reserved.
*
@@ -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
void vmgenc_init(struct vmctx *);
diff --git a/usr.sbin/bhyvectl/Makefile b/usr.sbin/bhyvectl/Makefile
index c004d603c8db..4f15bc35adf8 100644
--- a/usr.sbin/bhyvectl/Makefile
+++ b/usr.sbin/bhyvectl/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
.include <src.opts.mk>
@@ -12,8 +11,6 @@ MAN= bhyvectl.8
LIBADD= vmmapi util
-WARNS?= 3
-
CFLAGS+= -I${SRCTOP}/sys/amd64/vmm
.if ${MK_BHYVE_SNAPSHOT} != "no"
diff --git a/usr.sbin/bhyvectl/Makefile.depend b/usr.sbin/bhyvectl/Makefile.depend
index 0550c3e85424..1b63a1152a59 100644
--- a/usr.sbin/bhyvectl/Makefile.depend
+++ b/usr.sbin/bhyvectl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/bhyvectl/bhyvectl.8 b/usr.sbin/bhyvectl/bhyvectl.8
index 636529a7a53b..c5282a98a767 100644
--- a/usr.sbin/bhyvectl/bhyvectl.8
+++ b/usr.sbin/bhyvectl/bhyvectl.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 4, 2020
.Dt BHYVECTL 8
.Os
diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index 14ab6c7ad33e..90c9d51c2138 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,13 +24,8 @@
* 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 <sys/param.h>
#include <sys/types.h>
#include <sys/cpuset.h>
@@ -76,184 +71,6 @@ __FBSDID("$FreeBSD$");
static const char *progname;
-static void
-usage(bool cpu_intel)
-{
-
- (void)fprintf(stderr,
- "Usage: %s --vm=<vmname>\n"
- " [--cpu=<vcpu_number>]\n"
- " [--create]\n"
- " [--destroy]\n"
-#ifdef BHYVE_SNAPSHOT
- " [--checkpoint=<filename>]\n"
- " [--suspend=<filename>]\n"
-#endif
- " [--get-all]\n"
- " [--get-stats]\n"
- " [--set-desc-ds]\n"
- " [--get-desc-ds]\n"
- " [--set-desc-es]\n"
- " [--get-desc-es]\n"
- " [--set-desc-gs]\n"
- " [--get-desc-gs]\n"
- " [--set-desc-fs]\n"
- " [--get-desc-fs]\n"
- " [--set-desc-cs]\n"
- " [--get-desc-cs]\n"
- " [--set-desc-ss]\n"
- " [--get-desc-ss]\n"
- " [--set-desc-tr]\n"
- " [--get-desc-tr]\n"
- " [--set-desc-ldtr]\n"
- " [--get-desc-ldtr]\n"
- " [--set-desc-gdtr]\n"
- " [--get-desc-gdtr]\n"
- " [--set-desc-idtr]\n"
- " [--get-desc-idtr]\n"
- " [--run]\n"
- " [--capname=<capname>]\n"
- " [--getcap]\n"
- " [--setcap=<0|1>]\n"
- " [--desc-base=<BASE>]\n"
- " [--desc-limit=<LIMIT>]\n"
- " [--desc-access=<ACCESS>]\n"
- " [--set-cr0=<CR0>]\n"
- " [--get-cr0]\n"
- " [--set-cr2=<CR2>]\n"
- " [--get-cr2]\n"
- " [--set-cr3=<CR3>]\n"
- " [--get-cr3]\n"
- " [--set-cr4=<CR4>]\n"
- " [--get-cr4]\n"
- " [--set-dr0=<DR0>]\n"
- " [--get-dr0]\n"
- " [--set-dr1=<DR1>]\n"
- " [--get-dr1]\n"
- " [--set-dr2=<DR2>]\n"
- " [--get-dr2]\n"
- " [--set-dr3=<DR3>]\n"
- " [--get-dr3]\n"
- " [--set-dr6=<DR6>]\n"
- " [--get-dr6]\n"
- " [--set-dr7=<DR7>]\n"
- " [--get-dr7]\n"
- " [--set-rsp=<RSP>]\n"
- " [--get-rsp]\n"
- " [--set-rip=<RIP>]\n"
- " [--get-rip]\n"
- " [--get-rax]\n"
- " [--set-rax=<RAX>]\n"
- " [--get-rbx]\n"
- " [--get-rcx]\n"
- " [--get-rdx]\n"
- " [--get-rsi]\n"
- " [--get-rdi]\n"
- " [--get-rbp]\n"
- " [--get-r8]\n"
- " [--get-r9]\n"
- " [--get-r10]\n"
- " [--get-r11]\n"
- " [--get-r12]\n"
- " [--get-r13]\n"
- " [--get-r14]\n"
- " [--get-r15]\n"
- " [--set-rflags=<RFLAGS>]\n"
- " [--get-rflags]\n"
- " [--set-cs]\n"
- " [--get-cs]\n"
- " [--set-ds]\n"
- " [--get-ds]\n"
- " [--set-es]\n"
- " [--get-es]\n"
- " [--set-fs]\n"
- " [--get-fs]\n"
- " [--set-gs]\n"
- " [--get-gs]\n"
- " [--set-ss]\n"
- " [--get-ss]\n"
- " [--get-tr]\n"
- " [--get-ldtr]\n"
- " [--set-x2apic-state=<state>]\n"
- " [--get-x2apic-state]\n"
- " [--unassign-pptdev=<bus/slot/func>]\n"
- " [--set-mem=<memory in units of MB>]\n"
- " [--get-lowmem]\n"
- " [--get-highmem]\n"
- " [--get-gpa-pmap]\n"
- " [--assert-lapic-lvt=<pin>]\n"
- " [--inject-nmi]\n"
- " [--force-reset]\n"
- " [--force-poweroff]\n"
- " [--get-rtc-time]\n"
- " [--set-rtc-time=<secs>]\n"
- " [--get-rtc-nvram]\n"
- " [--set-rtc-nvram=<val>]\n"
- " [--rtc-nvram-offset=<offset>]\n"
- " [--get-active-cpus]\n"
- " [--get-suspended-cpus]\n"
- " [--get-intinfo]\n"
- " [--get-eptp]\n"
- " [--set-exception-bitmap]\n"
- " [--get-exception-bitmap]\n"
- " [--get-tsc-offset]\n"
- " [--get-guest-pat]\n"
- " [--get-io-bitmap-address]\n"
- " [--get-msr-bitmap]\n"
- " [--get-msr-bitmap-address]\n"
- " [--get-guest-sysenter]\n"
- " [--get-exit-reason]\n"
- " [--get-cpu-topology]\n",
- progname);
-
- if (cpu_intel) {
- (void)fprintf(stderr,
- " [--get-vmcs-pinbased-ctls]\n"
- " [--get-vmcs-procbased-ctls]\n"
- " [--get-vmcs-procbased-ctls2]\n"
- " [--get-vmcs-entry-interruption-info]\n"
- " [--set-vmcs-entry-interruption-info=<info>]\n"
- " [--get-vmcs-guest-physical-address\n"
- " [--get-vmcs-guest-linear-address\n"
- " [--get-vmcs-host-pat]\n"
- " [--get-vmcs-host-cr0]\n"
- " [--get-vmcs-host-cr3]\n"
- " [--get-vmcs-host-cr4]\n"
- " [--get-vmcs-host-rip]\n"
- " [--get-vmcs-host-rsp]\n"
- " [--get-vmcs-cr0-mask]\n"
- " [--get-vmcs-cr0-shadow]\n"
- " [--get-vmcs-cr4-mask]\n"
- " [--get-vmcs-cr4-shadow]\n"
- " [--get-vmcs-cr3-targets]\n"
- " [--get-vmcs-apic-access-address]\n"
- " [--get-vmcs-virtual-apic-address]\n"
- " [--get-vmcs-tpr-threshold]\n"
- " [--get-vmcs-vpid]\n"
- " [--get-vmcs-instruction-error]\n"
- " [--get-vmcs-exit-ctls]\n"
- " [--get-vmcs-entry-ctls]\n"
- " [--get-vmcs-link]\n"
- " [--get-vmcs-exit-qualification]\n"
- " [--get-vmcs-exit-interruption-info]\n"
- " [--get-vmcs-exit-interruption-error]\n"
- " [--get-vmcs-interruptibility]\n"
- );
- } else {
- (void)fprintf(stderr,
- " [--get-vmcb-intercepts]\n"
- " [--get-vmcb-asid]\n"
- " [--get-vmcb-exit-details]\n"
- " [--get-vmcb-tlb-ctrl]\n"
- " [--get-vmcb-virq]\n"
- " [--get-avic-apic-bar]\n"
- " [--get-avic-backing-page]\n"
- " [--get-avic-table]\n"
- );
- }
- exit(1);
-}
-
static int get_rtc_time, set_rtc_time;
static int get_rtc_nvram, set_rtc_nvram;
static int rtc_nvram_offset;
@@ -266,7 +83,7 @@ static int force_reset, force_poweroff;
static const char *capname;
static int create, destroy, get_memmap, get_memseg;
static int get_intinfo;
-static int get_active_cpus, get_suspended_cpus;
+static int get_active_cpus, get_debug_cpus, get_suspended_cpus;
static uint64_t memsize;
static int set_cr0, get_cr0, set_cr2, get_cr2, set_cr3, get_cr3;
static int set_cr4, get_cr4;
@@ -294,12 +111,11 @@ static int set_desc_ldtr, get_desc_ldtr;
static int set_cs, set_ds, set_es, set_fs, set_gs, set_ss, set_tr, set_ldtr;
static int get_cs, get_ds, get_es, get_fs, get_gs, get_ss, get_tr, get_ldtr;
static int set_x2apic_state, get_x2apic_state;
-enum x2apic_state x2apic_state;
+static enum x2apic_state x2apic_state;
static int unassign_pptdev, bus, slot, func;
static int run;
static int get_cpu_topology;
#ifdef BHYVE_SNAPSHOT
-static int vm_checkpoint_opt;
static int vm_suspend_opt;
#endif
@@ -316,7 +132,6 @@ static int get_pinbased_ctls, get_procbased_ctls, get_procbased_ctls2;
static int get_eptp, get_io_bitmap, get_tsc_offset;
static int get_vmcs_entry_interruption_info;
static int get_vmcs_interruptibility;
-uint32_t vmcs_entry_interruption_info;
static int get_vmcs_gpa, get_vmcs_gla;
static int get_exception_bitmap;
static int get_cr0_mask, get_cr0_shadow;
@@ -497,8 +312,8 @@ dump_intel_msr_pm(const char *bitmap, int vcpu)
static int
dump_msr_bitmap(int vcpu, uint64_t addr, bool cpu_intel)
{
+ char *bitmap;
int error, fd, map_size;
- const char *bitmap;
error = -1;
bitmap = MAP_FAILED;
@@ -536,18 +351,18 @@ done:
}
static int
-vm_get_vmcs_field(struct vmctx *ctx, int vcpu, int field, uint64_t *ret_val)
+vm_get_vmcs_field(struct vcpu *vcpu, int field, uint64_t *ret_val)
{
- return (vm_get_register(ctx, vcpu, VMCS_IDENT(field), ret_val));
+ return (vm_get_register(vcpu, VMCS_IDENT(field), ret_val));
}
static int
-vm_get_vmcb_field(struct vmctx *ctx, int vcpu, int off, int bytes,
+vm_get_vmcb_field(struct vcpu *vcpu, int off, int bytes,
uint64_t *ret_val)
{
- return (vm_get_register(ctx, vcpu, VMCB_ACCESS(off, bytes), ret_val));
+ return (vm_get_register(vcpu, VMCB_ACCESS(off, bytes), ret_val));
}
enum {
@@ -648,29 +463,24 @@ print_intinfo(const char *banner, uint64_t info)
static bool
cpu_vendor_intel(void)
{
- u_int regs[4];
- char cpu_vendor[13];
+ u_int regs[4], v[3];
do_cpuid(0, regs);
- ((u_int *)&cpu_vendor)[0] = regs[1];
- ((u_int *)&cpu_vendor)[1] = regs[3];
- ((u_int *)&cpu_vendor)[2] = regs[2];
- cpu_vendor[12] = '\0';
+ v[0] = regs[1];
+ v[1] = regs[3];
+ v[2] = regs[2];
- if (strcmp(cpu_vendor, "AuthenticAMD") == 0) {
- return (false);
- } else if (strcmp(cpu_vendor, "HygonGenuine") == 0) {
- return (false);
- } else if (strcmp(cpu_vendor, "GenuineIntel") == 0) {
+ if (memcmp(v, "GenuineIntel", sizeof(v)) == 0)
return (true);
- } else {
- fprintf(stderr, "Unknown cpu vendor \"%s\"\n", cpu_vendor);
- exit(1);
- }
+ if (memcmp(v, "AuthenticAMD", sizeof(v)) == 0 ||
+ memcmp(v, "HygonGenuine", sizeof(v)) == 0)
+ return (false);
+ fprintf(stderr, "Unknown cpu vendor \"%s\"\n", (const char *)v);
+ exit(1);
}
static int
-get_all_registers(struct vmctx *ctx, int vcpu)
+get_all_registers(struct vcpu *vcpu, int vcpuid)
{
uint64_t cr0, cr2, cr3, cr4, dr0, dr1, dr2, dr3, dr6, dr7;
uint64_t rsp, rip, rflags, efer;
@@ -679,651 +489,651 @@ get_all_registers(struct vmctx *ctx, int vcpu)
int error = 0;
if (!error && (get_efer || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_EFER, &efer);
+ error = vm_get_register(vcpu, VM_REG_GUEST_EFER, &efer);
if (error == 0)
- printf("efer[%d]\t\t0x%016lx\n", vcpu, efer);
+ printf("efer[%d]\t\t0x%016lx\n", vcpuid, efer);
}
if (!error && (get_cr0 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_CR0, &cr0);
+ error = vm_get_register(vcpu, VM_REG_GUEST_CR0, &cr0);
if (error == 0)
- printf("cr0[%d]\t\t0x%016lx\n", vcpu, cr0);
+ printf("cr0[%d]\t\t0x%016lx\n", vcpuid, cr0);
}
if (!error && (get_cr2 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_CR2, &cr2);
+ error = vm_get_register(vcpu, VM_REG_GUEST_CR2, &cr2);
if (error == 0)
- printf("cr2[%d]\t\t0x%016lx\n", vcpu, cr2);
+ printf("cr2[%d]\t\t0x%016lx\n", vcpuid, cr2);
}
if (!error && (get_cr3 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_CR3, &cr3);
+ error = vm_get_register(vcpu, VM_REG_GUEST_CR3, &cr3);
if (error == 0)
- printf("cr3[%d]\t\t0x%016lx\n", vcpu, cr3);
+ printf("cr3[%d]\t\t0x%016lx\n", vcpuid, cr3);
}
if (!error && (get_cr4 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_CR4, &cr4);
+ error = vm_get_register(vcpu, VM_REG_GUEST_CR4, &cr4);
if (error == 0)
- printf("cr4[%d]\t\t0x%016lx\n", vcpu, cr4);
+ printf("cr4[%d]\t\t0x%016lx\n", vcpuid, cr4);
}
if (!error && (get_dr0 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_DR0, &dr0);
+ error = vm_get_register(vcpu, VM_REG_GUEST_DR0, &dr0);
if (error == 0)
- printf("dr0[%d]\t\t0x%016lx\n", vcpu, dr0);
+ printf("dr0[%d]\t\t0x%016lx\n", vcpuid, dr0);
}
if (!error && (get_dr1 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_DR1, &dr1);
+ error = vm_get_register(vcpu, VM_REG_GUEST_DR1, &dr1);
if (error == 0)
- printf("dr1[%d]\t\t0x%016lx\n", vcpu, dr1);
+ printf("dr1[%d]\t\t0x%016lx\n", vcpuid, dr1);
}
if (!error && (get_dr2 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_DR2, &dr2);
+ error = vm_get_register(vcpu, VM_REG_GUEST_DR2, &dr2);
if (error == 0)
- printf("dr2[%d]\t\t0x%016lx\n", vcpu, dr2);
+ printf("dr2[%d]\t\t0x%016lx\n", vcpuid, dr2);
}
if (!error && (get_dr3 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_DR3, &dr3);
+ error = vm_get_register(vcpu, VM_REG_GUEST_DR3, &dr3);
if (error == 0)
- printf("dr3[%d]\t\t0x%016lx\n", vcpu, dr3);
+ printf("dr3[%d]\t\t0x%016lx\n", vcpuid, dr3);
}
if (!error && (get_dr6 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_DR6, &dr6);
+ error = vm_get_register(vcpu, VM_REG_GUEST_DR6, &dr6);
if (error == 0)
- printf("dr6[%d]\t\t0x%016lx\n", vcpu, dr6);
+ printf("dr6[%d]\t\t0x%016lx\n", vcpuid, dr6);
}
if (!error && (get_dr7 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_DR7, &dr7);
+ error = vm_get_register(vcpu, VM_REG_GUEST_DR7, &dr7);
if (error == 0)
- printf("dr7[%d]\t\t0x%016lx\n", vcpu, dr7);
+ printf("dr7[%d]\t\t0x%016lx\n", vcpuid, dr7);
}
if (!error && (get_rsp || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RSP, &rsp);
+ error = vm_get_register(vcpu, VM_REG_GUEST_RSP, &rsp);
if (error == 0)
- printf("rsp[%d]\t\t0x%016lx\n", vcpu, rsp);
+ printf("rsp[%d]\t\t0x%016lx\n", vcpuid, rsp);
}
if (!error && (get_rip || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RIP, &rip);
+ error = vm_get_register(vcpu, VM_REG_GUEST_RIP, &rip);
if (error == 0)
- printf("rip[%d]\t\t0x%016lx\n", vcpu, rip);
+ printf("rip[%d]\t\t0x%016lx\n", vcpuid, rip);
}
if (!error && (get_rax || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RAX, &rax);
+ error = vm_get_register(vcpu, VM_REG_GUEST_RAX, &rax);
if (error == 0)
- printf("rax[%d]\t\t0x%016lx\n", vcpu, rax);
+ printf("rax[%d]\t\t0x%016lx\n", vcpuid, rax);
}
if (!error && (get_rbx || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RBX, &rbx);
+ error = vm_get_register(vcpu, VM_REG_GUEST_RBX, &rbx);
if (error == 0)
- printf("rbx[%d]\t\t0x%016lx\n", vcpu, rbx);
+ printf("rbx[%d]\t\t0x%016lx\n", vcpuid, rbx);
}
if (!error && (get_rcx || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RCX, &rcx);
+ error = vm_get_register(vcpu, VM_REG_GUEST_RCX, &rcx);
if (error == 0)
- printf("rcx[%d]\t\t0x%016lx\n", vcpu, rcx);
+ printf("rcx[%d]\t\t0x%016lx\n", vcpuid, rcx);
}
if (!error && (get_rdx || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RDX, &rdx);
+ error = vm_get_register(vcpu, VM_REG_GUEST_RDX, &rdx);
if (error == 0)
- printf("rdx[%d]\t\t0x%016lx\n", vcpu, rdx);
+ printf("rdx[%d]\t\t0x%016lx\n", vcpuid, rdx);
}
if (!error && (get_rsi || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RSI, &rsi);
+ error = vm_get_register(vcpu, VM_REG_GUEST_RSI, &rsi);
if (error == 0)
- printf("rsi[%d]\t\t0x%016lx\n", vcpu, rsi);
+ printf("rsi[%d]\t\t0x%016lx\n", vcpuid, rsi);
}
if (!error && (get_rdi || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RDI, &rdi);
+ error = vm_get_register(vcpu, VM_REG_GUEST_RDI, &rdi);
if (error == 0)
- printf("rdi[%d]\t\t0x%016lx\n", vcpu, rdi);
+ printf("rdi[%d]\t\t0x%016lx\n", vcpuid, rdi);
}
if (!error && (get_rbp || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RBP, &rbp);
+ error = vm_get_register(vcpu, VM_REG_GUEST_RBP, &rbp);
if (error == 0)
- printf("rbp[%d]\t\t0x%016lx\n", vcpu, rbp);
+ printf("rbp[%d]\t\t0x%016lx\n", vcpuid, rbp);
}
if (!error && (get_r8 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_R8, &r8);
+ error = vm_get_register(vcpu, VM_REG_GUEST_R8, &r8);
if (error == 0)
- printf("r8[%d]\t\t0x%016lx\n", vcpu, r8);
+ printf("r8[%d]\t\t0x%016lx\n", vcpuid, r8);
}
if (!error && (get_r9 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_R9, &r9);
+ error = vm_get_register(vcpu, VM_REG_GUEST_R9, &r9);
if (error == 0)
- printf("r9[%d]\t\t0x%016lx\n", vcpu, r9);
+ printf("r9[%d]\t\t0x%016lx\n", vcpuid, r9);
}
if (!error && (get_r10 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_R10, &r10);
+ error = vm_get_register(vcpu, VM_REG_GUEST_R10, &r10);
if (error == 0)
- printf("r10[%d]\t\t0x%016lx\n", vcpu, r10);
+ printf("r10[%d]\t\t0x%016lx\n", vcpuid, r10);
}
if (!error && (get_r11 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_R11, &r11);
+ error = vm_get_register(vcpu, VM_REG_GUEST_R11, &r11);
if (error == 0)
- printf("r11[%d]\t\t0x%016lx\n", vcpu, r11);
+ printf("r11[%d]\t\t0x%016lx\n", vcpuid, r11);
}
if (!error && (get_r12 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_R12, &r12);
+ error = vm_get_register(vcpu, VM_REG_GUEST_R12, &r12);
if (error == 0)
- printf("r12[%d]\t\t0x%016lx\n", vcpu, r12);
+ printf("r12[%d]\t\t0x%016lx\n", vcpuid, r12);
}
if (!error && (get_r13 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_R13, &r13);
+ error = vm_get_register(vcpu, VM_REG_GUEST_R13, &r13);
if (error == 0)
- printf("r13[%d]\t\t0x%016lx\n", vcpu, r13);
+ printf("r13[%d]\t\t0x%016lx\n", vcpuid, r13);
}
if (!error && (get_r14 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_R14, &r14);
+ error = vm_get_register(vcpu, VM_REG_GUEST_R14, &r14);
if (error == 0)
- printf("r14[%d]\t\t0x%016lx\n", vcpu, r14);
+ printf("r14[%d]\t\t0x%016lx\n", vcpuid, r14);
}
if (!error && (get_r15 || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_R15, &r15);
+ error = vm_get_register(vcpu, VM_REG_GUEST_R15, &r15);
if (error == 0)
- printf("r15[%d]\t\t0x%016lx\n", vcpu, r15);
+ printf("r15[%d]\t\t0x%016lx\n", vcpuid, r15);
}
if (!error && (get_rflags || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RFLAGS,
+ error = vm_get_register(vcpu, VM_REG_GUEST_RFLAGS,
&rflags);
if (error == 0)
- printf("rflags[%d]\t0x%016lx\n", vcpu, rflags);
+ printf("rflags[%d]\t0x%016lx\n", vcpuid, rflags);
}
return (error);
}
static int
-get_all_segments(struct vmctx *ctx, int vcpu)
+get_all_segments(struct vcpu *vcpu, int vcpuid)
{
uint64_t cs, ds, es, fs, gs, ss, tr, ldtr;
int error = 0;
if (!error && (get_desc_ds || get_all)) {
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_DS,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_DS,
&desc_base, &desc_limit, &desc_access);
if (error == 0) {
printf("ds desc[%d]\t0x%016lx/0x%08x/0x%08x\n",
- vcpu, desc_base, desc_limit, desc_access);
+ vcpuid, desc_base, desc_limit, desc_access);
}
}
if (!error && (get_desc_es || get_all)) {
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_ES,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_ES,
&desc_base, &desc_limit, &desc_access);
if (error == 0) {
printf("es desc[%d]\t0x%016lx/0x%08x/0x%08x\n",
- vcpu, desc_base, desc_limit, desc_access);
+ vcpuid, desc_base, desc_limit, desc_access);
}
}
if (!error && (get_desc_fs || get_all)) {
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_FS,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_FS,
&desc_base, &desc_limit, &desc_access);
if (error == 0) {
printf("fs desc[%d]\t0x%016lx/0x%08x/0x%08x\n",
- vcpu, desc_base, desc_limit, desc_access);
+ vcpuid, desc_base, desc_limit, desc_access);
}
}
if (!error && (get_desc_gs || get_all)) {
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_GS,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_GS,
&desc_base, &desc_limit, &desc_access);
if (error == 0) {
printf("gs desc[%d]\t0x%016lx/0x%08x/0x%08x\n",
- vcpu, desc_base, desc_limit, desc_access);
+ vcpuid, desc_base, desc_limit, desc_access);
}
}
if (!error && (get_desc_ss || get_all)) {
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_SS,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_SS,
&desc_base, &desc_limit, &desc_access);
if (error == 0) {
printf("ss desc[%d]\t0x%016lx/0x%08x/0x%08x\n",
- vcpu, desc_base, desc_limit, desc_access);
+ vcpuid, desc_base, desc_limit, desc_access);
}
}
if (!error && (get_desc_cs || get_all)) {
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_CS,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_CS,
&desc_base, &desc_limit, &desc_access);
if (error == 0) {
printf("cs desc[%d]\t0x%016lx/0x%08x/0x%08x\n",
- vcpu, desc_base, desc_limit, desc_access);
+ vcpuid, desc_base, desc_limit, desc_access);
}
}
if (!error && (get_desc_tr || get_all)) {
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_TR,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_TR,
&desc_base, &desc_limit, &desc_access);
if (error == 0) {
printf("tr desc[%d]\t0x%016lx/0x%08x/0x%08x\n",
- vcpu, desc_base, desc_limit, desc_access);
+ vcpuid, desc_base, desc_limit, desc_access);
}
}
if (!error && (get_desc_ldtr || get_all)) {
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_LDTR,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_LDTR,
&desc_base, &desc_limit, &desc_access);
if (error == 0) {
printf("ldtr desc[%d]\t0x%016lx/0x%08x/0x%08x\n",
- vcpu, desc_base, desc_limit, desc_access);
+ vcpuid, desc_base, desc_limit, desc_access);
}
}
if (!error && (get_desc_gdtr || get_all)) {
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_GDTR,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_GDTR,
&desc_base, &desc_limit, &desc_access);
if (error == 0) {
printf("gdtr[%d]\t\t0x%016lx/0x%08x\n",
- vcpu, desc_base, desc_limit);
+ vcpuid, desc_base, desc_limit);
}
}
if (!error && (get_desc_idtr || get_all)) {
- error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_IDTR,
+ error = vm_get_desc(vcpu, VM_REG_GUEST_IDTR,
&desc_base, &desc_limit, &desc_access);
if (error == 0) {
printf("idtr[%d]\t\t0x%016lx/0x%08x\n",
- vcpu, desc_base, desc_limit);
+ vcpuid, desc_base, desc_limit);
}
}
if (!error && (get_cs || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_CS, &cs);
+ error = vm_get_register(vcpu, VM_REG_GUEST_CS, &cs);
if (error == 0)
- printf("cs[%d]\t\t0x%04lx\n", vcpu, cs);
+ printf("cs[%d]\t\t0x%04lx\n", vcpuid, cs);
}
if (!error && (get_ds || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_DS, &ds);
+ error = vm_get_register(vcpu, VM_REG_GUEST_DS, &ds);
if (error == 0)
- printf("ds[%d]\t\t0x%04lx\n", vcpu, ds);
+ printf("ds[%d]\t\t0x%04lx\n", vcpuid, ds);
}
if (!error && (get_es || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_ES, &es);
+ error = vm_get_register(vcpu, VM_REG_GUEST_ES, &es);
if (error == 0)
- printf("es[%d]\t\t0x%04lx\n", vcpu, es);
+ printf("es[%d]\t\t0x%04lx\n", vcpuid, es);
}
if (!error && (get_fs || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_FS, &fs);
+ error = vm_get_register(vcpu, VM_REG_GUEST_FS, &fs);
if (error == 0)
- printf("fs[%d]\t\t0x%04lx\n", vcpu, fs);
+ printf("fs[%d]\t\t0x%04lx\n", vcpuid, fs);
}
if (!error && (get_gs || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_GS, &gs);
+ error = vm_get_register(vcpu, VM_REG_GUEST_GS, &gs);
if (error == 0)
- printf("gs[%d]\t\t0x%04lx\n", vcpu, gs);
+ printf("gs[%d]\t\t0x%04lx\n", vcpuid, gs);
}
if (!error && (get_ss || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_SS, &ss);
+ error = vm_get_register(vcpu, VM_REG_GUEST_SS, &ss);
if (error == 0)
- printf("ss[%d]\t\t0x%04lx\n", vcpu, ss);
+ printf("ss[%d]\t\t0x%04lx\n", vcpuid, ss);
}
if (!error && (get_tr || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_TR, &tr);
+ error = vm_get_register(vcpu, VM_REG_GUEST_TR, &tr);
if (error == 0)
- printf("tr[%d]\t\t0x%04lx\n", vcpu, tr);
+ printf("tr[%d]\t\t0x%04lx\n", vcpuid, tr);
}
if (!error && (get_ldtr || get_all)) {
- error = vm_get_register(ctx, vcpu, VM_REG_GUEST_LDTR, &ldtr);
+ error = vm_get_register(vcpu, VM_REG_GUEST_LDTR, &ldtr);
if (error == 0)
- printf("ldtr[%d]\t\t0x%04lx\n", vcpu, ldtr);
+ printf("ldtr[%d]\t\t0x%04lx\n", vcpuid, ldtr);
}
return (error);
}
static int
-get_misc_vmcs(struct vmctx *ctx, int vcpu)
+get_misc_vmcs(struct vcpu *vcpu, int vcpuid)
{
uint64_t ctl, cr0, cr3, cr4, rsp, rip, pat, addr, u64;
int error = 0;
if (!error && (get_cr0_mask || get_all)) {
uint64_t cr0mask;
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_CR0_MASK, &cr0mask);
+ error = vm_get_vmcs_field(vcpu, VMCS_CR0_MASK, &cr0mask);
if (error == 0)
- printf("cr0_mask[%d]\t\t0x%016lx\n", vcpu, cr0mask);
+ printf("cr0_mask[%d]\t\t0x%016lx\n", vcpuid, cr0mask);
}
if (!error && (get_cr0_shadow || get_all)) {
uint64_t cr0shadow;
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_CR0_SHADOW,
+ error = vm_get_vmcs_field(vcpu, VMCS_CR0_SHADOW,
&cr0shadow);
if (error == 0)
- printf("cr0_shadow[%d]\t\t0x%016lx\n", vcpu, cr0shadow);
+ printf("cr0_shadow[%d]\t\t0x%016lx\n", vcpuid, cr0shadow);
}
if (!error && (get_cr4_mask || get_all)) {
uint64_t cr4mask;
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_CR4_MASK, &cr4mask);
+ error = vm_get_vmcs_field(vcpu, VMCS_CR4_MASK, &cr4mask);
if (error == 0)
- printf("cr4_mask[%d]\t\t0x%016lx\n", vcpu, cr4mask);
+ printf("cr4_mask[%d]\t\t0x%016lx\n", vcpuid, cr4mask);
}
if (!error && (get_cr4_shadow || get_all)) {
uint64_t cr4shadow;
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_CR4_SHADOW,
+ error = vm_get_vmcs_field(vcpu, VMCS_CR4_SHADOW,
&cr4shadow);
if (error == 0)
- printf("cr4_shadow[%d]\t\t0x%016lx\n", vcpu, cr4shadow);
+ printf("cr4_shadow[%d]\t\t0x%016lx\n", vcpuid, cr4shadow);
}
if (!error && (get_cr3_targets || get_all)) {
uint64_t target_count, target_addr;
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_CR3_TARGET_COUNT,
+ error = vm_get_vmcs_field(vcpu, VMCS_CR3_TARGET_COUNT,
&target_count);
if (error == 0) {
printf("cr3_target_count[%d]\t0x%016lx\n",
- vcpu, target_count);
+ vcpuid, target_count);
}
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_CR3_TARGET0,
+ error = vm_get_vmcs_field(vcpu, VMCS_CR3_TARGET0,
&target_addr);
if (error == 0) {
printf("cr3_target0[%d]\t\t0x%016lx\n",
- vcpu, target_addr);
+ vcpuid, target_addr);
}
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_CR3_TARGET1,
+ error = vm_get_vmcs_field(vcpu, VMCS_CR3_TARGET1,
&target_addr);
if (error == 0) {
printf("cr3_target1[%d]\t\t0x%016lx\n",
- vcpu, target_addr);
+ vcpuid, target_addr);
}
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_CR3_TARGET2,
+ error = vm_get_vmcs_field(vcpu, VMCS_CR3_TARGET2,
&target_addr);
if (error == 0) {
printf("cr3_target2[%d]\t\t0x%016lx\n",
- vcpu, target_addr);
+ vcpuid, target_addr);
}
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_CR3_TARGET3,
+ error = vm_get_vmcs_field(vcpu, VMCS_CR3_TARGET3,
&target_addr);
if (error == 0) {
printf("cr3_target3[%d]\t\t0x%016lx\n",
- vcpu, target_addr);
+ vcpuid, target_addr);
}
}
if (!error && (get_pinbased_ctls || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_PIN_BASED_CTLS, &ctl);
+ error = vm_get_vmcs_field(vcpu, VMCS_PIN_BASED_CTLS, &ctl);
if (error == 0)
- printf("pinbased_ctls[%d]\t0x%016lx\n", vcpu, ctl);
+ printf("pinbased_ctls[%d]\t0x%016lx\n", vcpuid, ctl);
}
if (!error && (get_procbased_ctls || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_PRI_PROC_BASED_CTLS, &ctl);
if (error == 0)
- printf("procbased_ctls[%d]\t0x%016lx\n", vcpu, ctl);
+ printf("procbased_ctls[%d]\t0x%016lx\n", vcpuid, ctl);
}
if (!error && (get_procbased_ctls2 || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_SEC_PROC_BASED_CTLS, &ctl);
if (error == 0)
- printf("procbased_ctls2[%d]\t0x%016lx\n", vcpu, ctl);
+ printf("procbased_ctls2[%d]\t0x%016lx\n", vcpuid, ctl);
}
if (!error && (get_vmcs_gla || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_GUEST_LINEAR_ADDRESS, &u64);
if (error == 0)
- printf("gla[%d]\t\t0x%016lx\n", vcpu, u64);
+ printf("gla[%d]\t\t0x%016lx\n", vcpuid, u64);
}
if (!error && (get_vmcs_gpa || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_GUEST_PHYSICAL_ADDRESS, &u64);
if (error == 0)
- printf("gpa[%d]\t\t0x%016lx\n", vcpu, u64);
+ printf("gpa[%d]\t\t0x%016lx\n", vcpuid, u64);
}
if (!error && (get_vmcs_entry_interruption_info ||
get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_ENTRY_INTR_INFO,&u64);
+ error = vm_get_vmcs_field(vcpu, VMCS_ENTRY_INTR_INFO,&u64);
if (error == 0) {
printf("entry_interruption_info[%d]\t0x%016lx\n",
- vcpu, u64);
+ vcpuid, u64);
}
}
if (!error && (get_tpr_threshold || get_all)) {
uint64_t threshold;
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_TPR_THRESHOLD,
+ error = vm_get_vmcs_field(vcpu, VMCS_TPR_THRESHOLD,
&threshold);
if (error == 0)
- printf("tpr_threshold[%d]\t0x%016lx\n", vcpu, threshold);
+ printf("tpr_threshold[%d]\t0x%016lx\n", vcpuid, threshold);
}
if (!error && (get_inst_err || get_all)) {
uint64_t insterr;
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_INSTRUCTION_ERROR,
+ error = vm_get_vmcs_field(vcpu, VMCS_INSTRUCTION_ERROR,
&insterr);
if (error == 0) {
printf("instruction_error[%d]\t0x%016lx\n",
- vcpu, insterr);
+ vcpuid, insterr);
}
}
if (!error && (get_exit_ctls || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_EXIT_CTLS, &ctl);
+ error = vm_get_vmcs_field(vcpu, VMCS_EXIT_CTLS, &ctl);
if (error == 0)
- printf("exit_ctls[%d]\t\t0x%016lx\n", vcpu, ctl);
+ printf("exit_ctls[%d]\t\t0x%016lx\n", vcpuid, ctl);
}
if (!error && (get_entry_ctls || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_ENTRY_CTLS, &ctl);
+ error = vm_get_vmcs_field(vcpu, VMCS_ENTRY_CTLS, &ctl);
if (error == 0)
- printf("entry_ctls[%d]\t\t0x%016lx\n", vcpu, ctl);
+ printf("entry_ctls[%d]\t\t0x%016lx\n", vcpuid, ctl);
}
if (!error && (get_host_pat || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_HOST_IA32_PAT, &pat);
+ error = vm_get_vmcs_field(vcpu, VMCS_HOST_IA32_PAT, &pat);
if (error == 0)
- printf("host_pat[%d]\t\t0x%016lx\n", vcpu, pat);
+ printf("host_pat[%d]\t\t0x%016lx\n", vcpuid, pat);
}
if (!error && (get_host_cr0 || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_HOST_CR0, &cr0);
+ error = vm_get_vmcs_field(vcpu, VMCS_HOST_CR0, &cr0);
if (error == 0)
- printf("host_cr0[%d]\t\t0x%016lx\n", vcpu, cr0);
+ printf("host_cr0[%d]\t\t0x%016lx\n", vcpuid, cr0);
}
if (!error && (get_host_cr3 || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_HOST_CR3, &cr3);
+ error = vm_get_vmcs_field(vcpu, VMCS_HOST_CR3, &cr3);
if (error == 0)
- printf("host_cr3[%d]\t\t0x%016lx\n", vcpu, cr3);
+ printf("host_cr3[%d]\t\t0x%016lx\n", vcpuid, cr3);
}
if (!error && (get_host_cr4 || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_HOST_CR4, &cr4);
+ error = vm_get_vmcs_field(vcpu, VMCS_HOST_CR4, &cr4);
if (error == 0)
- printf("host_cr4[%d]\t\t0x%016lx\n", vcpu, cr4);
+ printf("host_cr4[%d]\t\t0x%016lx\n", vcpuid, cr4);
}
if (!error && (get_host_rip || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_HOST_RIP, &rip);
+ error = vm_get_vmcs_field(vcpu, VMCS_HOST_RIP, &rip);
if (error == 0)
- printf("host_rip[%d]\t\t0x%016lx\n", vcpu, rip);
+ printf("host_rip[%d]\t\t0x%016lx\n", vcpuid, rip);
}
if (!error && (get_host_rsp || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_HOST_RSP, &rsp);
+ error = vm_get_vmcs_field(vcpu, VMCS_HOST_RSP, &rsp);
if (error == 0)
- printf("host_rsp[%d]\t\t0x%016lx\n", vcpu, rsp);
+ printf("host_rsp[%d]\t\t0x%016lx\n", vcpuid, rsp);
}
if (!error && (get_vmcs_link || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_LINK_POINTER, &addr);
+ error = vm_get_vmcs_field(vcpu, VMCS_LINK_POINTER, &addr);
if (error == 0)
- printf("vmcs_pointer[%d]\t0x%016lx\n", vcpu, addr);
+ printf("vmcs_pointer[%d]\t0x%016lx\n", vcpuid, addr);
}
if (!error && (get_vmcs_exit_interruption_info || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_EXIT_INTR_INFO, &u64);
+ error = vm_get_vmcs_field(vcpu, VMCS_EXIT_INTR_INFO, &u64);
if (error == 0) {
printf("vmcs_exit_interruption_info[%d]\t0x%016lx\n",
- vcpu, u64);
+ vcpuid, u64);
}
}
if (!error && (get_vmcs_exit_interruption_error || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_EXIT_INTR_ERRCODE,
+ error = vm_get_vmcs_field(vcpu, VMCS_EXIT_INTR_ERRCODE,
&u64);
if (error == 0) {
printf("vmcs_exit_interruption_error[%d]\t0x%016lx\n",
- vcpu, u64);
+ vcpuid, u64);
}
}
if (!error && (get_vmcs_interruptibility || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_GUEST_INTERRUPTIBILITY, &u64);
if (error == 0) {
printf("vmcs_guest_interruptibility[%d]\t0x%016lx\n",
- vcpu, u64);
+ vcpuid, u64);
}
}
if (!error && (get_vmcs_exit_inst_length || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_EXIT_INSTRUCTION_LENGTH, &u64);
if (error == 0)
- printf("vmcs_exit_inst_length[%d]\t0x%08x\n", vcpu,
+ printf("vmcs_exit_inst_length[%d]\t0x%08x\n", vcpuid,
(uint32_t)u64);
}
if (!error && (get_vmcs_exit_qualification || get_all)) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_EXIT_QUALIFICATION,
+ error = vm_get_vmcs_field(vcpu, VMCS_EXIT_QUALIFICATION,
&u64);
if (error == 0)
printf("vmcs_exit_qualification[%d]\t0x%016lx\n",
- vcpu, u64);
+ vcpuid, u64);
}
return (error);
}
static int
-get_misc_vmcb(struct vmctx *ctx, int vcpu)
+get_misc_vmcb(struct vcpu *vcpu, int vcpuid)
{
uint64_t ctl, addr;
int error = 0;
if (!error && (get_vmcb_intercept || get_all)) {
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_CR_INTERCEPT, 4,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_CR_INTERCEPT, 4,
&ctl);
if (error == 0)
- printf("cr_intercept[%d]\t0x%08x\n", vcpu, (int)ctl);
+ printf("cr_intercept[%d]\t0x%08x\n", vcpuid, (int)ctl);
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_DR_INTERCEPT, 4,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_DR_INTERCEPT, 4,
&ctl);
if (error == 0)
- printf("dr_intercept[%d]\t0x%08x\n", vcpu, (int)ctl);
+ printf("dr_intercept[%d]\t0x%08x\n", vcpuid, (int)ctl);
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_EXC_INTERCEPT, 4,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_EXC_INTERCEPT, 4,
&ctl);
if (error == 0)
- printf("exc_intercept[%d]\t0x%08x\n", vcpu, (int)ctl);
+ printf("exc_intercept[%d]\t0x%08x\n", vcpuid, (int)ctl);
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_INST1_INTERCEPT,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_INST1_INTERCEPT,
4, &ctl);
if (error == 0)
- printf("inst1_intercept[%d]\t0x%08x\n", vcpu, (int)ctl);
+ printf("inst1_intercept[%d]\t0x%08x\n", vcpuid, (int)ctl);
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_INST2_INTERCEPT,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_INST2_INTERCEPT,
4, &ctl);
if (error == 0)
- printf("inst2_intercept[%d]\t0x%08x\n", vcpu, (int)ctl);
+ printf("inst2_intercept[%d]\t0x%08x\n", vcpuid, (int)ctl);
}
if (!error && (get_vmcb_tlb_ctrl || get_all)) {
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_TLB_CTRL,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_TLB_CTRL,
4, &ctl);
if (error == 0)
- printf("TLB ctrl[%d]\t0x%016lx\n", vcpu, ctl);
+ printf("TLB ctrl[%d]\t0x%016lx\n", vcpuid, ctl);
}
if (!error && (get_vmcb_exit_details || get_all)) {
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_EXITINFO1,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_EXITINFO1,
8, &ctl);
if (error == 0)
- printf("exitinfo1[%d]\t0x%016lx\n", vcpu, ctl);
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_EXITINFO2,
+ printf("exitinfo1[%d]\t0x%016lx\n", vcpuid, ctl);
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_EXITINFO2,
8, &ctl);
if (error == 0)
- printf("exitinfo2[%d]\t0x%016lx\n", vcpu, ctl);
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_EXITINTINFO,
+ printf("exitinfo2[%d]\t0x%016lx\n", vcpuid, ctl);
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_EXITINTINFO,
8, &ctl);
if (error == 0)
- printf("exitintinfo[%d]\t0x%016lx\n", vcpu, ctl);
+ printf("exitintinfo[%d]\t0x%016lx\n", vcpuid, ctl);
}
if (!error && (get_vmcb_virq || get_all)) {
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_VIRQ,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_VIRQ,
8, &ctl);
if (error == 0)
- printf("v_irq/tpr[%d]\t0x%016lx\n", vcpu, ctl);
+ printf("v_irq/tpr[%d]\t0x%016lx\n", vcpuid, ctl);
}
if (!error && (get_apic_access_addr || get_all)) {
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_AVIC_BAR, 8,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_AVIC_BAR, 8,
&addr);
if (error == 0)
- printf("AVIC apic_bar[%d]\t0x%016lx\n", vcpu, addr);
+ printf("AVIC apic_bar[%d]\t0x%016lx\n", vcpuid, addr);
}
if (!error && (get_virtual_apic_addr || get_all)) {
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_AVIC_PAGE, 8,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_AVIC_PAGE, 8,
&addr);
if (error == 0)
- printf("AVIC backing page[%d]\t0x%016lx\n", vcpu, addr);
+ printf("AVIC backing page[%d]\t0x%016lx\n", vcpuid, addr);
}
if (!error && (get_avic_table || get_all)) {
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_AVIC_LT, 8,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_AVIC_LT, 8,
&addr);
if (error == 0)
printf("AVIC logical table[%d]\t0x%016lx\n",
- vcpu, addr);
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_AVIC_PT, 8,
+ vcpuid, addr);
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_AVIC_PT, 8,
&addr);
if (error == 0)
printf("AVIC physical table[%d]\t0x%016lx\n",
- vcpu, addr);
+ vcpuid, addr);
}
return (error);
@@ -1458,6 +1268,7 @@ setup_options(bool cpu_intel)
{ "force-reset", NO_ARG, &force_reset, 1 },
{ "force-poweroff", NO_ARG, &force_poweroff, 1 },
{ "get-active-cpus", NO_ARG, &get_active_cpus, 1 },
+ { "get-debug-cpus", NO_ARG, &get_debug_cpus, 1 },
{ "get-suspended-cpus", NO_ARG, &get_suspended_cpus, 1 },
{ "get-intinfo", NO_ARG, &get_intinfo, 1 },
{ "get-cpu-topology", NO_ARG, &get_cpu_topology, 1 },
@@ -1577,6 +1388,65 @@ setup_options(bool cpu_intel)
return (all_opts);
}
+static void
+usage(const struct option *opts)
+{
+ static const char *set_desc[] = {
+ [VCPU] = "vcpu_number",
+ [SET_MEM] = "memory in units of MB",
+ [SET_EFER] = "EFER",
+ [SET_CR0] = "CR0",
+ [SET_CR2] = "CR2",
+ [SET_CR3] = "CR3",
+ [SET_CR4] = "CR4",
+ [SET_DR0] = "DR0",
+ [SET_DR1] = "DR1",
+ [SET_DR2] = "DR2",
+ [SET_DR3] = "DR3",
+ [SET_DR6] = "DR6",
+ [SET_DR7] = "DR7",
+ [SET_RSP] = "RSP",
+ [SET_RIP] = "RIP",
+ [SET_RAX] = "RAX",
+ [SET_RFLAGS] = "RFLAGS",
+ [DESC_BASE] = "BASE",
+ [DESC_LIMIT] = "LIMIT",
+ [DESC_ACCESS] = "ACCESS",
+ [SET_CS] = "CS",
+ [SET_DS] = "DS",
+ [SET_ES] = "ES",
+ [SET_FS] = "FS",
+ [SET_GS] = "GS",
+ [SET_SS] = "SS",
+ [SET_TR] = "TR",
+ [SET_LDTR] = "LDTR",
+ [SET_X2APIC_STATE] = "state",
+ [SET_CAP] = "0|1",
+ [CAPNAME] = "capname",
+ [UNASSIGN_PPTDEV] = "bus/slot.func",
+ [GET_GPA_PMAP] = "gpa",
+ [ASSERT_LAPIC_LVT] = "pin",
+ [SET_RTC_TIME] = "secs",
+ [SET_RTC_NVRAM] = "val",
+ [RTC_NVRAM_OFFSET] = "offset",
+#ifdef BHYVE_SNAPSHOT
+ [SET_CHECKPOINT_FILE] = "filename",
+ [SET_SUSPEND_FILE] = "filename",
+#endif
+ };
+ (void)fprintf(stderr, "Usage: %s --vm=<vmname>\n", progname);
+ for (const struct option *o = opts; o->name; o++) {
+ if (strcmp(o->name, "vm") == 0)
+ continue;
+ if (o->has_arg == REQ_ARG)
+ (void)fprintf(stderr, " [--%s=<%s>]\n",
+ o->name, set_desc[o->val]);
+ else
+ (void)fprintf(stderr, " [--%s]\n", o->name);
+ }
+ exit(1);
+}
+
static const char *
wday_str(int idx)
{
@@ -1685,12 +1555,12 @@ static int
send_message(const char *vmname, nvlist_t *nvl)
{
struct sockaddr_un addr;
- int err, socket_fd;
+ int err = 0, socket_fd;
socket_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (socket_fd < 0) {
perror("Error creating bhyvectl socket");
- err = -1;
+ err = errno;
goto done;
}
@@ -1706,25 +1576,48 @@ send_message(const char *vmname, nvlist_t *nvl)
goto done;
}
- if (nvlist_send(socket_fd, nvl) < 0)
+ if (nvlist_send(socket_fd, nvl) < 0) {
perror("nvlist_send() failed");
+ err = errno;
+ }
+done:
nvlist_destroy(nvl);
-done:
- if (socket_fd > 0)
+ if (socket_fd >= 0)
close(socket_fd);
return (err);
}
static int
-snapshot_request(const char *vmname, const char *file, bool suspend)
+open_directory(const char *file)
+{
+ char *path;
+ int fd;
+
+ if ((path = strdup(file)) == NULL)
+ return (-1);
+
+ dirname(path);
+ fd = open(path, O_DIRECTORY);
+ free(path);
+
+ return (fd);
+}
+
+static int
+snapshot_request(const char *vmname, char *file, bool suspend)
{
nvlist_t *nvl;
+ int fd;
+
+ if ((fd = open_directory(file)) < 0)
+ return (errno);
nvl = nvlist_create(0);
nvlist_add_string(nvl, "cmd", "checkpoint");
- nvlist_add_string(nvl, "filename", file);
+ nvlist_add_string(nvl, "filename", basename(file));
nvlist_add_bool(nvl, "suspend", suspend);
+ nvlist_move_descriptor(nvl, "fddir", fd);
return (send_message(vmname, nvl));
}
@@ -1734,26 +1627,27 @@ int
main(int argc, char *argv[])
{
char *vmname;
- int error, ch, vcpu, ptenum;
+ int error, ch, vcpuid, ptenum;
vm_paddr_t gpa_pmap;
- struct vm_exit vmexit;
+ struct vm_run vmrun;
uint64_t rax, cr0, cr2, cr3, cr4, dr0, dr1, dr2, dr3, dr6, dr7;
uint64_t rsp, rip, rflags, efer, pat;
uint64_t eptp, bm, addr, u64, pteval[4], *pte, info[2];
struct vmctx *ctx;
+ struct vcpu *vcpu;
cpuset_t cpus;
bool cpu_intel;
uint64_t cs, ds, es, fs, gs, ss, tr, ldtr;
struct tm tm;
struct option *opts;
#ifdef BHYVE_SNAPSHOT
- char *checkpoint_file, *suspend_file;
+ char *checkpoint_file = NULL;
#endif
cpu_intel = cpu_vendor_intel();
opts = setup_options(cpu_intel);
- vcpu = 0;
+ vcpuid = 0;
vmname = NULL;
assert_lapic_lvt = -1;
progname = basename(argv[0]);
@@ -1766,7 +1660,7 @@ main(int argc, char *argv[])
vmname = optarg;
break;
case VCPU:
- vcpu = atoi(optarg);
+ vcpuid = atoi(optarg);
break;
case SET_MEM:
memsize = atoi(optarg) * MB;
@@ -1902,30 +1796,30 @@ main(int argc, char *argv[])
case UNASSIGN_PPTDEV:
unassign_pptdev = 1;
if (sscanf(optarg, "%d/%d/%d", &bus, &slot, &func) != 3)
- usage(cpu_intel);
+ usage(opts);
break;
case ASSERT_LAPIC_LVT:
assert_lapic_lvt = atoi(optarg);
break;
#ifdef BHYVE_SNAPSHOT
case SET_CHECKPOINT_FILE:
- vm_checkpoint_opt = 1;
- checkpoint_file = optarg;
- break;
case SET_SUSPEND_FILE:
- vm_suspend_opt = 1;
- suspend_file = optarg;
+ if (checkpoint_file != NULL)
+ usage(opts);
+
+ checkpoint_file = optarg;
+ vm_suspend_opt = (ch == SET_SUSPEND_FILE);
break;
#endif
default:
- usage(cpu_intel);
+ usage(opts);
}
}
argc -= optind;
argv += optind;
if (vmname == NULL)
- usage(cpu_intel);
+ usage(opts);
error = 0;
@@ -1940,144 +1834,145 @@ main(int argc, char *argv[])
vmname, strerror(errno));
exit (1);
}
+ vcpu = vm_vcpu_open(ctx, vcpuid);
}
if (!error && memsize)
error = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
if (!error && set_efer)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_EFER, efer);
+ error = vm_set_register(vcpu, VM_REG_GUEST_EFER, efer);
if (!error && set_cr0)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_CR0, cr0);
+ error = vm_set_register(vcpu, VM_REG_GUEST_CR0, cr0);
if (!error && set_cr2)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_CR2, cr2);
+ error = vm_set_register(vcpu, VM_REG_GUEST_CR2, cr2);
if (!error && set_cr3)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_CR3, cr3);
+ error = vm_set_register(vcpu, VM_REG_GUEST_CR3, cr3);
if (!error && set_cr4)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_CR4, cr4);
+ error = vm_set_register(vcpu, VM_REG_GUEST_CR4, cr4);
if (!error && set_dr0)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_DR0, dr0);
+ error = vm_set_register(vcpu, VM_REG_GUEST_DR0, dr0);
if (!error && set_dr1)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_DR1, dr1);
+ error = vm_set_register(vcpu, VM_REG_GUEST_DR1, dr1);
if (!error && set_dr2)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_DR2, dr2);
+ error = vm_set_register(vcpu, VM_REG_GUEST_DR2, dr2);
if (!error && set_dr3)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_DR3, dr3);
+ error = vm_set_register(vcpu, VM_REG_GUEST_DR3, dr3);
if (!error && set_dr6)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_DR6, dr6);
+ error = vm_set_register(vcpu, VM_REG_GUEST_DR6, dr6);
if (!error && set_dr7)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_DR7, dr7);
+ error = vm_set_register(vcpu, VM_REG_GUEST_DR7, dr7);
if (!error && set_rsp)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RSP, rsp);
+ error = vm_set_register(vcpu, VM_REG_GUEST_RSP, rsp);
if (!error && set_rip)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, rip);
+ error = vm_set_register(vcpu, VM_REG_GUEST_RIP, rip);
if (!error && set_rax)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, rax);
+ error = vm_set_register(vcpu, VM_REG_GUEST_RAX, rax);
if (!error && set_rflags) {
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RFLAGS,
+ error = vm_set_register(vcpu, VM_REG_GUEST_RFLAGS,
rflags);
}
if (!error && set_desc_ds) {
- error = vm_set_desc(ctx, vcpu, VM_REG_GUEST_DS,
+ error = vm_set_desc(vcpu, VM_REG_GUEST_DS,
desc_base, desc_limit, desc_access);
}
if (!error && set_desc_es) {
- error = vm_set_desc(ctx, vcpu, VM_REG_GUEST_ES,
+ error = vm_set_desc(vcpu, VM_REG_GUEST_ES,
desc_base, desc_limit, desc_access);
}
if (!error && set_desc_ss) {
- error = vm_set_desc(ctx, vcpu, VM_REG_GUEST_SS,
+ error = vm_set_desc(vcpu, VM_REG_GUEST_SS,
desc_base, desc_limit, desc_access);
}
if (!error && set_desc_cs) {
- error = vm_set_desc(ctx, vcpu, VM_REG_GUEST_CS,
+ error = vm_set_desc(vcpu, VM_REG_GUEST_CS,
desc_base, desc_limit, desc_access);
}
if (!error && set_desc_fs) {
- error = vm_set_desc(ctx, vcpu, VM_REG_GUEST_FS,
+ error = vm_set_desc(vcpu, VM_REG_GUEST_FS,
desc_base, desc_limit, desc_access);
}
if (!error && set_desc_gs) {
- error = vm_set_desc(ctx, vcpu, VM_REG_GUEST_GS,
+ error = vm_set_desc(vcpu, VM_REG_GUEST_GS,
desc_base, desc_limit, desc_access);
}
if (!error && set_desc_tr) {
- error = vm_set_desc(ctx, vcpu, VM_REG_GUEST_TR,
+ error = vm_set_desc(vcpu, VM_REG_GUEST_TR,
desc_base, desc_limit, desc_access);
}
if (!error && set_desc_ldtr) {
- error = vm_set_desc(ctx, vcpu, VM_REG_GUEST_LDTR,
+ error = vm_set_desc(vcpu, VM_REG_GUEST_LDTR,
desc_base, desc_limit, desc_access);
}
if (!error && set_desc_gdtr) {
- error = vm_set_desc(ctx, vcpu, VM_REG_GUEST_GDTR,
+ error = vm_set_desc(vcpu, VM_REG_GUEST_GDTR,
desc_base, desc_limit, 0);
}
if (!error && set_desc_idtr) {
- error = vm_set_desc(ctx, vcpu, VM_REG_GUEST_IDTR,
+ error = vm_set_desc(vcpu, VM_REG_GUEST_IDTR,
desc_base, desc_limit, 0);
}
if (!error && set_cs)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_CS, cs);
+ error = vm_set_register(vcpu, VM_REG_GUEST_CS, cs);
if (!error && set_ds)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_DS, ds);
+ error = vm_set_register(vcpu, VM_REG_GUEST_DS, ds);
if (!error && set_es)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_ES, es);
+ error = vm_set_register(vcpu, VM_REG_GUEST_ES, es);
if (!error && set_fs)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_FS, fs);
+ error = vm_set_register(vcpu, VM_REG_GUEST_FS, fs);
if (!error && set_gs)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_GS, gs);
+ error = vm_set_register(vcpu, VM_REG_GUEST_GS, gs);
if (!error && set_ss)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_SS, ss);
+ error = vm_set_register(vcpu, VM_REG_GUEST_SS, ss);
if (!error && set_tr)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_TR, tr);
+ error = vm_set_register(vcpu, VM_REG_GUEST_TR, tr);
if (!error && set_ldtr)
- error = vm_set_register(ctx, vcpu, VM_REG_GUEST_LDTR, ldtr);
+ error = vm_set_register(vcpu, VM_REG_GUEST_LDTR, ldtr);
if (!error && set_x2apic_state)
- error = vm_set_x2apic_state(ctx, vcpu, x2apic_state);
+ error = vm_set_x2apic_state(vcpu, x2apic_state);
if (!error && unassign_pptdev)
error = vm_unassign_pptdev(ctx, bus, slot, func);
if (!error && inject_nmi) {
- error = vm_inject_nmi(ctx, vcpu);
+ error = vm_inject_nmi(vcpu);
}
if (!error && assert_lapic_lvt != -1) {
- error = vm_lapic_local_irq(ctx, vcpu, assert_lapic_lvt);
+ error = vm_lapic_local_irq(vcpu, assert_lapic_lvt);
}
if (!error && (get_memseg || get_all))
@@ -2087,177 +1982,177 @@ main(int argc, char *argv[])
error = show_memmap(ctx);
if (!error)
- error = get_all_registers(ctx, vcpu);
+ error = get_all_registers(vcpu, vcpuid);
if (!error)
- error = get_all_segments(ctx, vcpu);
+ error = get_all_segments(vcpu, vcpuid);
if (!error) {
if (cpu_intel)
- error = get_misc_vmcs(ctx, vcpu);
+ error = get_misc_vmcs(vcpu, vcpuid);
else
- error = get_misc_vmcb(ctx, vcpu);
+ error = get_misc_vmcb(vcpu, vcpuid);
}
if (!error && (get_x2apic_state || get_all)) {
- error = vm_get_x2apic_state(ctx, vcpu, &x2apic_state);
+ error = vm_get_x2apic_state(vcpu, &x2apic_state);
if (error == 0)
- printf("x2apic_state[%d]\t%d\n", vcpu, x2apic_state);
+ printf("x2apic_state[%d]\t%d\n", vcpuid, x2apic_state);
}
if (!error && (get_eptp || get_all)) {
if (cpu_intel)
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_EPTP, &eptp);
+ error = vm_get_vmcs_field(vcpu, VMCS_EPTP, &eptp);
else
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_NPT_BASE,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_NPT_BASE,
8, &eptp);
if (error == 0)
printf("%s[%d]\t\t0x%016lx\n",
- cpu_intel ? "eptp" : "rvi/npt", vcpu, eptp);
+ cpu_intel ? "eptp" : "rvi/npt", vcpuid, eptp);
}
if (!error && (get_exception_bitmap || get_all)) {
if(cpu_intel)
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_EXCEPTION_BITMAP, &bm);
else
- error = vm_get_vmcb_field(ctx, vcpu,
+ error = vm_get_vmcb_field(vcpu,
VMCB_OFF_EXC_INTERCEPT,
4, &bm);
if (error == 0)
- printf("exception_bitmap[%d]\t%#lx\n", vcpu, bm);
+ printf("exception_bitmap[%d]\t%#lx\n", vcpuid, bm);
}
if (!error && (get_io_bitmap || get_all)) {
if (cpu_intel) {
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_IO_BITMAP_A,
+ error = vm_get_vmcs_field(vcpu, VMCS_IO_BITMAP_A,
&bm);
if (error == 0)
- printf("io_bitmap_a[%d]\t%#lx\n", vcpu, bm);
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_IO_BITMAP_B,
+ printf("io_bitmap_a[%d]\t%#lx\n", vcpuid, bm);
+ error = vm_get_vmcs_field(vcpu, VMCS_IO_BITMAP_B,
&bm);
if (error == 0)
- printf("io_bitmap_b[%d]\t%#lx\n", vcpu, bm);
+ printf("io_bitmap_b[%d]\t%#lx\n", vcpuid, bm);
} else {
- error = vm_get_vmcb_field(ctx, vcpu,
+ error = vm_get_vmcb_field(vcpu,
VMCB_OFF_IO_PERM, 8, &bm);
if (error == 0)
- printf("io_bitmap[%d]\t%#lx\n", vcpu, bm);
+ printf("io_bitmap[%d]\t%#lx\n", vcpuid, bm);
}
}
if (!error && (get_tsc_offset || get_all)) {
uint64_t tscoff;
if (cpu_intel)
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_TSC_OFFSET,
+ error = vm_get_vmcs_field(vcpu, VMCS_TSC_OFFSET,
&tscoff);
else
- error = vm_get_vmcb_field(ctx, vcpu,
+ error = vm_get_vmcb_field(vcpu,
VMCB_OFF_TSC_OFFSET,
8, &tscoff);
if (error == 0)
- printf("tsc_offset[%d]\t0x%016lx\n", vcpu, tscoff);
+ printf("tsc_offset[%d]\t0x%016lx\n", vcpuid, tscoff);
}
if (!error && (get_msr_bitmap_address || get_all)) {
if (cpu_intel)
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_MSR_BITMAP,
+ error = vm_get_vmcs_field(vcpu, VMCS_MSR_BITMAP,
&addr);
else
- error = vm_get_vmcb_field(ctx, vcpu,
+ error = vm_get_vmcb_field(vcpu,
VMCB_OFF_MSR_PERM, 8, &addr);
if (error == 0)
- printf("msr_bitmap[%d]\t\t%#lx\n", vcpu, addr);
+ printf("msr_bitmap[%d]\t\t%#lx\n", vcpuid, addr);
}
if (!error && (get_msr_bitmap || get_all)) {
if (cpu_intel) {
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_MSR_BITMAP, &addr);
} else {
- error = vm_get_vmcb_field(ctx, vcpu,
+ error = vm_get_vmcb_field(vcpu,
VMCB_OFF_MSR_PERM, 8,
&addr);
}
if (error == 0)
- error = dump_msr_bitmap(vcpu, addr, cpu_intel);
+ error = dump_msr_bitmap(vcpuid, addr, cpu_intel);
}
if (!error && (get_vpid_asid || get_all)) {
uint64_t vpid;
if (cpu_intel)
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_VPID, &vpid);
+ error = vm_get_vmcs_field(vcpu, VMCS_VPID, &vpid);
else
- error = vm_get_vmcb_field(ctx, vcpu, VMCB_OFF_ASID,
+ error = vm_get_vmcb_field(vcpu, VMCB_OFF_ASID,
4, &vpid);
if (error == 0)
printf("%s[%d]\t\t0x%04lx\n",
- cpu_intel ? "vpid" : "asid", vcpu, vpid);
+ cpu_intel ? "vpid" : "asid", vcpuid, vpid);
}
if (!error && (get_guest_pat || get_all)) {
if (cpu_intel)
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_GUEST_IA32_PAT, &pat);
else
- error = vm_get_vmcb_field(ctx, vcpu,
+ error = vm_get_vmcb_field(vcpu,
VMCB_OFF_GUEST_PAT, 8, &pat);
if (error == 0)
- printf("guest_pat[%d]\t\t0x%016lx\n", vcpu, pat);
+ printf("guest_pat[%d]\t\t0x%016lx\n", vcpuid, pat);
}
if (!error && (get_guest_sysenter || get_all)) {
if (cpu_intel)
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_GUEST_IA32_SYSENTER_CS,
&cs);
else
- error = vm_get_vmcb_field(ctx, vcpu,
+ error = vm_get_vmcb_field(vcpu,
VMCB_OFF_SYSENTER_CS, 8,
&cs);
if (error == 0)
- printf("guest_sysenter_cs[%d]\t%#lx\n", vcpu, cs);
+ printf("guest_sysenter_cs[%d]\t%#lx\n", vcpuid, cs);
if (cpu_intel)
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_GUEST_IA32_SYSENTER_ESP,
&rsp);
else
- error = vm_get_vmcb_field(ctx, vcpu,
+ error = vm_get_vmcb_field(vcpu,
VMCB_OFF_SYSENTER_ESP, 8,
&rsp);
if (error == 0)
- printf("guest_sysenter_sp[%d]\t%#lx\n", vcpu, rsp);
+ printf("guest_sysenter_sp[%d]\t%#lx\n", vcpuid, rsp);
if (cpu_intel)
- error = vm_get_vmcs_field(ctx, vcpu,
+ error = vm_get_vmcs_field(vcpu,
VMCS_GUEST_IA32_SYSENTER_EIP,
&rip);
else
- error = vm_get_vmcb_field(ctx, vcpu,
+ error = vm_get_vmcb_field(vcpu,
VMCB_OFF_SYSENTER_EIP, 8,
&rip);
if (error == 0)
- printf("guest_sysenter_ip[%d]\t%#lx\n", vcpu, rip);
+ printf("guest_sysenter_ip[%d]\t%#lx\n", vcpuid, rip);
}
if (!error && (get_exit_reason || get_all)) {
if (cpu_intel)
- error = vm_get_vmcs_field(ctx, vcpu, VMCS_EXIT_REASON,
+ error = vm_get_vmcs_field(vcpu, VMCS_EXIT_REASON,
&u64);
else
- error = vm_get_vmcb_field(ctx, vcpu,
+ error = vm_get_vmcb_field(vcpu,
VMCB_OFF_EXIT_REASON, 8,
&u64);
if (error == 0)
- printf("exit_reason[%d]\t%#lx\n", vcpu, u64);
+ printf("exit_reason[%d]\t%#lx\n", vcpuid, u64);
}
if (!error && setcap) {
int captype;
captype = vm_capability_name2type(capname);
- error = vm_set_capability(ctx, vcpu, captype, capval);
+ error = vm_set_capability(vcpu, captype, capval);
if (error != 0 && errno == ENOENT)
printf("Capability \"%s\" is not available\n", capname);
}
@@ -2309,11 +2204,11 @@ main(int argc, char *argv[])
for (captype = 0; captype < VM_CAP_MAX; captype++) {
if (getcaptype >= 0 && captype != getcaptype)
continue;
- error = vm_get_capability(ctx, vcpu, captype, &val);
+ error = vm_get_capability(vcpu, captype, &val);
if (error == 0) {
printf("Capability \"%s\" is %s on vcpu %d\n",
vm_capability_type2name(captype),
- val ? "set" : "not set", vcpu);
+ val ? "set" : "not set", vcpuid);
} else if (errno == ENOENT) {
error = 0;
printf("Capability \"%s\" is not available\n",
@@ -2330,6 +2225,12 @@ main(int argc, char *argv[])
print_cpus("active cpus", &cpus);
}
+ if (!error && (get_debug_cpus || get_all)) {
+ error = vm_debug_cpus(ctx, &cpus);
+ if (!error)
+ print_cpus("debug cpus", &cpus);
+ }
+
if (!error && (get_suspended_cpus || get_all)) {
error = vm_suspended_cpus(ctx, &cpus);
if (!error)
@@ -2337,7 +2238,7 @@ main(int argc, char *argv[])
}
if (!error && (get_intinfo || get_all)) {
- error = vm_get_intinfo(ctx, vcpu, &info[0], &info[1]);
+ error = vm_get_intinfo(vcpu, &info[0], &info[1]);
if (!error) {
print_intinfo("pending", info[0]);
print_intinfo("current", info[1]);
@@ -2350,9 +2251,9 @@ main(int argc, char *argv[])
struct timeval tv;
const char *desc;
- stats = vm_get_stats(ctx, vcpu, &tv, &num_stats);
+ stats = vm_get_stats(vcpu, &tv, &num_stats);
if (stats != NULL) {
- printf("vcpu%d stats:\n", vcpu);
+ printf("vcpu%d stats:\n", vcpuid);
for (i = 0; i < num_stats; i++) {
desc = vm_get_stat_desc(ctx, i);
printf("%-40s\t%ld\n", desc, stats[i]);
@@ -2369,9 +2270,15 @@ main(int argc, char *argv[])
}
if (!error && run) {
- error = vm_run(ctx, vcpu, &vmexit);
+ struct vm_exit vmexit;
+ cpuset_t cpuset;
+
+ vmrun.vm_exit = &vmexit;
+ vmrun.cpuset = &cpuset;
+ vmrun.cpusetsize = sizeof(cpuset);
+ error = vm_run(vcpu, &vmrun);
if (error == 0)
- dump_vm_run_exitcode(&vmexit, vcpu);
+ dump_vm_run_exitcode(&vmexit, vcpuid);
else
printf("vm_run error %d\n", error);
}
@@ -2389,11 +2296,8 @@ main(int argc, char *argv[])
vm_destroy(ctx);
#ifdef BHYVE_SNAPSHOT
- if (!error && vm_checkpoint_opt)
- error = snapshot_request(vmname, checkpoint_file, false);
-
- if (!error && vm_suspend_opt)
- error = snapshot_request(vmname, suspend_file, true);
+ if (!error && checkpoint_file)
+ error = snapshot_request(vmname, checkpoint_file, vm_suspend_opt);
#endif
free (opts);
diff --git a/usr.sbin/bhyveload/Makefile b/usr.sbin/bhyveload/Makefile
index 48bed64c26e4..f4091f8a092d 100644
--- a/usr.sbin/bhyveload/Makefile
+++ b/usr.sbin/bhyveload/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= bhyveload
SRCS= bhyveload.c
@@ -7,8 +6,6 @@ PACKAGE= bhyve
LIBADD= vmmapi
-WARNS?= 3
-
CFLAGS+=-I${SRCTOP}/stand/userboot
.include <bsd.prog.mk>
diff --git a/usr.sbin/bhyveload/Makefile.depend b/usr.sbin/bhyveload/Makefile.depend
index 0550c3e85424..3d34ce71d39b 100644
--- a/usr.sbin/bhyveload/Makefile.depend
+++ b/usr.sbin/bhyveload/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/libutil \
lib/libvmmapi \
diff --git a/usr.sbin/bhyveload/bhyveload.8 b/usr.sbin/bhyveload/bhyveload.8
index 519c16b3cca6..54e326e49c8c 100644
--- a/usr.sbin/bhyveload/bhyveload.8
+++ b/usr.sbin/bhyveload/bhyveload.8
@@ -23,9 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd June 24, 2016
+.Dd January 12, 2024
.Dt BHYVELOAD 8
.Os
.Sh NAME
@@ -173,3 +171,43 @@ at NetApp Inc with a lot of help from
can only load
.Fx
as a guest.
+.Sh SECURITY CONSIDERATIONS
+Note that in some configurations,
+.Nm
+will execute guest loader scripts in the context of the host machine.
+Note, however, that
+.Nm
+will enter a
+.Xr capsicum 4
+sandbox before it loads the
+.Ar os-loader
+or executes any loader scripts.
+On the host filesystem, the sandbox will only have access to the path specified
+by the
+.Fl h
+flag, the contents of the
+.Pa /boot
+directory if
+.Fl l
+was not specified, and the chosen console device.
+.Pp
+Note that the guest loader scripts are already subject to some limitations that
+are not relaxed simply because we are running in userland.
+For instance, any I/O on the loader's
+.Dq host
+device that can be done in loader scripts is limited to the interface that
+.Nm
+provides, which itself will restrict paths that can be touched to those within
+a specified
+.Fl h
+directory, if any.
+Access to files within
+.Pa /boot
+inside the sandbox would require arbitrary code execution in userboot, and
+userboot is usually provided by the host machine rather than anything that is
+a part of the guest image.
+All access to the
+.Fl h
+directory as well as
+.Pa /boot
+is strictly read-only in the sandbox.
diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c
index db7d995f2466..5250e2120938 100644
--- a/usr.sbin/bhyveload/bhyveload.c
+++ b/usr.sbin/bhyveload/bhyveload.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* 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$
*/
/*-
@@ -52,13 +50,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 <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/disk.h>
@@ -67,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <machine/specialreg.h>
#include <machine/vmm.h>
+#include <assert.h>
#include <dirent.h>
#include <dlfcn.h>
#include <errno.h>
@@ -83,6 +78,7 @@ __FBSDID("$FreeBSD$");
#include <termios.h>
#include <unistd.h>
+#include <capsicum_helpers.h>
#include <vmmapi.h>
#include "userboot.h"
@@ -93,21 +89,30 @@ __FBSDID("$FreeBSD$");
#define NDISKS 32
-static char *host_base;
+/*
+ * Reason for our loader reload and reentry, though these aren't really used
+ * at the moment.
+ */
+enum {
+ /* 0 cannot be allocated; setjmp(3) return. */
+ JMP_SWAPLOADER = 0x01,
+ JMP_REBOOT,
+};
+
static struct termios term, oldterm;
static int disk_fd[NDISKS];
static int ndisks;
static int consin_fd, consout_fd;
-
-static int need_reinit;
+static int hostbase_fd = -1;
static void *loader_hdl;
static char *loader;
-static int explicit_loader;
+static int explicit_loader_fd = -1;
static jmp_buf jb;
static char *vmname, *progname;
static struct vmctx *ctx;
+static struct vcpu *vcpu;
static uint64_t gdtbase, cr3, rsp;
@@ -118,7 +123,7 @@ static void cb_exit(void *arg, int v);
*/
static void
-cb_putc(void *arg, int ch)
+cb_putc(void *arg __unused, int ch)
{
char c = ch;
@@ -126,7 +131,7 @@ cb_putc(void *arg, int ch)
}
static int
-cb_getc(void *arg)
+cb_getc(void *arg __unused)
{
char c;
@@ -136,7 +141,7 @@ cb_getc(void *arg)
}
static int
-cb_poll(void *arg)
+cb_poll(void *arg __unused)
{
int n;
@@ -160,49 +165,68 @@ struct cb_file {
};
static int
-cb_open(void *arg, const char *filename, void **hp)
+cb_open(void *arg __unused, const char *filename, void **hp)
{
struct cb_file *cf;
- char path[PATH_MAX];
+ struct stat sb;
+ int fd, flags;
- if (!host_base)
+ cf = NULL;
+ fd = -1;
+ flags = O_RDONLY | O_RESOLVE_BENEATH;
+ if (hostbase_fd == -1)
return (ENOENT);
- strlcpy(path, host_base, PATH_MAX);
- if (path[strlen(path) - 1] == '/')
- path[strlen(path) - 1] = 0;
- strlcat(path, filename, PATH_MAX);
- cf = malloc(sizeof(struct cb_file));
- if (stat(path, &cf->cf_stat) < 0) {
- free(cf);
+ /* Absolute paths are relative to our hostbase, chop off leading /. */
+ if (filename[0] == '/')
+ filename++;
+
+ /* Lookup of /, use . instead. */
+ if (filename[0] == '\0')
+ filename = ".";
+
+ if (fstatat(hostbase_fd, filename, &sb, AT_RESOLVE_BENEATH) < 0)
+ return (errno);
+
+ if (!S_ISDIR(sb.st_mode) && !S_ISREG(sb.st_mode))
+ return (EINVAL);
+
+ if (S_ISDIR(sb.st_mode))
+ flags |= O_DIRECTORY;
+
+ /* May be opening the root dir */
+ fd = openat(hostbase_fd, filename, flags);
+ if (fd < 0)
return (errno);
+
+ cf = malloc(sizeof(struct cb_file));
+ if (cf == NULL) {
+ close(fd);
+ return (ENOMEM);
}
+ cf->cf_stat = sb;
cf->cf_size = cf->cf_stat.st_size;
+
if (S_ISDIR(cf->cf_stat.st_mode)) {
cf->cf_isdir = 1;
- cf->cf_u.dir = opendir(path);
- if (!cf->cf_u.dir)
- goto out;
- *hp = cf;
- return (0);
- }
- if (S_ISREG(cf->cf_stat.st_mode)) {
+ cf->cf_u.dir = fdopendir(fd);
+ if (cf->cf_u.dir == NULL) {
+ close(fd);
+ free(cf);
+ return (ENOMEM);
+ }
+ } else {
+ assert(S_ISREG(cf->cf_stat.st_mode));
cf->cf_isdir = 0;
- cf->cf_u.fd = open(path, O_RDONLY);
- if (cf->cf_u.fd < 0)
- goto out;
- *hp = cf;
- return (0);
+ cf->cf_u.fd = fd;
}
-
-out:
- free(cf);
- return (EINVAL);
+ *hp = cf;
+ return (0);
}
static int
-cb_close(void *arg, void *h)
+cb_close(void *arg __unused, void *h)
{
struct cb_file *cf = h;
@@ -216,7 +240,7 @@ cb_close(void *arg, void *h)
}
static int
-cb_isdir(void *arg, void *h)
+cb_isdir(void *arg __unused, void *h)
{
struct cb_file *cf = h;
@@ -224,7 +248,7 @@ cb_isdir(void *arg, void *h)
}
static int
-cb_read(void *arg, void *h, void *buf, size_t size, size_t *resid)
+cb_read(void *arg __unused, void *h, void *buf, size_t size, size_t *resid)
{
struct cb_file *cf = h;
ssize_t sz;
@@ -239,8 +263,8 @@ cb_read(void *arg, void *h, void *buf, size_t size, size_t *resid)
}
static int
-cb_readdir(void *arg, void *h, uint32_t *fileno_return, uint8_t *type_return,
- size_t *namelen_return, char *name)
+cb_readdir(void *arg __unused, void *h, uint32_t *fileno_return,
+ uint8_t *type_return, size_t *namelen_return, char *name)
{
struct cb_file *cf = h;
struct dirent *dp;
@@ -266,7 +290,7 @@ cb_readdir(void *arg, void *h, uint32_t *fileno_return, uint8_t *type_return,
}
static int
-cb_seek(void *arg, void *h, uint64_t offset, int whence)
+cb_seek(void *arg __unused, void *h, uint64_t offset, int whence)
{
struct cb_file *cf = h;
@@ -278,7 +302,7 @@ cb_seek(void *arg, void *h, uint64_t offset, int whence)
}
static int
-cb_stat(void *arg, void *h, struct stat *sbp)
+cb_stat(void *arg __unused, void *h, struct stat *sbp)
{
struct cb_file *cf = h;
@@ -299,7 +323,7 @@ cb_stat(void *arg, void *h, struct stat *sbp)
*/
static int
-cb_diskread(void *arg, int unit, uint64_t from, void *to, size_t size,
+cb_diskread(void *arg __unused, int unit, uint64_t from, void *to, size_t size,
size_t *resid)
{
ssize_t n;
@@ -314,8 +338,8 @@ cb_diskread(void *arg, int unit, uint64_t from, void *to, size_t size,
}
static int
-cb_diskwrite(void *arg, int unit, uint64_t offset, void *src, size_t size,
- size_t *resid)
+cb_diskwrite(void *arg __unused, int unit, uint64_t offset, void *src,
+ size_t size, size_t *resid)
{
ssize_t n;
@@ -329,7 +353,7 @@ cb_diskwrite(void *arg, int unit, uint64_t offset, void *src, size_t size,
}
static int
-cb_diskioctl(void *arg, int unit, u_long cmd, void *data)
+cb_diskioctl(void *arg __unused, int unit, u_long cmd, void *data)
{
struct stat sb;
@@ -359,7 +383,7 @@ cb_diskioctl(void *arg, int unit, u_long cmd, void *data)
* Guest virtual machine i/o callbacks
*/
static int
-cb_copyin(void *arg, const void *from, uint64_t to, size_t size)
+cb_copyin(void *arg __unused, const void *from, uint64_t to, size_t size)
{
char *ptr;
@@ -374,7 +398,7 @@ cb_copyin(void *arg, const void *from, uint64_t to, size_t size)
}
static int
-cb_copyout(void *arg, uint64_t from, void *to, size_t size)
+cb_copyout(void *arg __unused, uint64_t from, void *to, size_t size)
{
char *ptr;
@@ -389,7 +413,7 @@ cb_copyout(void *arg, uint64_t from, void *to, size_t size)
}
static void
-cb_setreg(void *arg, int r, uint64_t v)
+cb_setreg(void *arg __unused, int r, uint64_t v)
{
int error;
enum vm_reg_name vmreg;
@@ -410,7 +434,7 @@ cb_setreg(void *arg, int r, uint64_t v)
cb_exit(NULL, USERBOOT_EXIT_QUIT);
}
- error = vm_set_register(ctx, BSP, vmreg, v);
+ error = vm_set_register(vcpu, vmreg, v);
if (error) {
perror("vm_set_register");
cb_exit(NULL, USERBOOT_EXIT_QUIT);
@@ -418,7 +442,7 @@ cb_setreg(void *arg, int r, uint64_t v)
}
static void
-cb_setmsr(void *arg, int r, uint64_t v)
+cb_setmsr(void *arg __unused, int r, uint64_t v)
{
int error;
enum vm_reg_name vmreg;
@@ -438,7 +462,7 @@ cb_setmsr(void *arg, int r, uint64_t v)
cb_exit(NULL, USERBOOT_EXIT_QUIT);
}
- error = vm_set_register(ctx, BSP, vmreg, v);
+ error = vm_set_register(vcpu, vmreg, v);
if (error) {
perror("vm_set_msr");
cb_exit(NULL, USERBOOT_EXIT_QUIT);
@@ -446,7 +470,7 @@ cb_setmsr(void *arg, int r, uint64_t v)
}
static void
-cb_setcr(void *arg, int r, uint64_t v)
+cb_setcr(void *arg __unused, int r, uint64_t v)
{
int error;
enum vm_reg_name vmreg;
@@ -473,7 +497,7 @@ cb_setcr(void *arg, int r, uint64_t v)
cb_exit(NULL, USERBOOT_EXIT_QUIT);
}
- error = vm_set_register(ctx, BSP, vmreg, v);
+ error = vm_set_register(vcpu, vmreg, v);
if (error) {
perror("vm_set_cr");
cb_exit(NULL, USERBOOT_EXIT_QUIT);
@@ -481,11 +505,11 @@ cb_setcr(void *arg, int r, uint64_t v)
}
static void
-cb_setgdt(void *arg, uint64_t base, size_t size)
+cb_setgdt(void *arg __unused, uint64_t base, size_t size)
{
int error;
- error = vm_set_desc(ctx, BSP, VM_REG_GUEST_GDTR, base, size - 1, 0);
+ error = vm_set_desc(vcpu, VM_REG_GUEST_GDTR, base, size - 1, 0);
if (error != 0) {
perror("vm_set_desc(gdt)");
cb_exit(NULL, USERBOOT_EXIT_QUIT);
@@ -495,15 +519,15 @@ cb_setgdt(void *arg, uint64_t base, size_t size)
}
static void
-cb_exec(void *arg, uint64_t rip)
+cb_exec(void *arg __unused, uint64_t rip)
{
int error;
if (cr3 == 0)
- error = vm_setup_freebsd_registers_i386(ctx, BSP, rip, gdtbase,
+ error = vm_setup_freebsd_registers_i386(vcpu, rip, gdtbase,
rsp);
else
- error = vm_setup_freebsd_registers(ctx, BSP, rip, cr3, gdtbase,
+ error = vm_setup_freebsd_registers(vcpu, rip, cr3, gdtbase,
rsp);
if (error) {
perror("vm_setup_freebsd_registers");
@@ -518,22 +542,24 @@ cb_exec(void *arg, uint64_t rip)
*/
static void
-cb_delay(void *arg, int usec)
+cb_delay(void *arg __unused, int usec)
{
usleep(usec);
}
static void
-cb_exit(void *arg, int v)
+cb_exit(void *arg __unused, int v)
{
tcsetattr(consout_fd, TCSAFLUSH, &oldterm);
+ if (v == USERBOOT_EXIT_REBOOT)
+ longjmp(jb, JMP_REBOOT);
exit(v);
}
static void
-cb_getmem(void *arg, uint64_t *ret_lowmem, uint64_t *ret_highmem)
+cb_getmem(void *arg __unused, uint64_t *ret_lowmem, uint64_t *ret_highmem)
{
*ret_lowmem = vm_get_lowmem_size(ctx);
@@ -548,17 +574,21 @@ struct env {
static SLIST_HEAD(envhead, env) envhead;
static void
-addenv(char *str)
+addenv(const char *str)
{
struct env *env;
env = malloc(sizeof(struct env));
- env->str = str;
+ if (env == NULL)
+ err(EX_OSERR, "malloc");
+ env->str = strdup(str);
+ if (env->str == NULL)
+ err(EX_OSERR, "strdup");
SLIST_INSERT_HEAD(&envhead, env, next);
}
static char *
-cb_getenv(void *arg, int num)
+cb_getenv(void *arg __unused, int num)
{
int i;
struct env *env;
@@ -574,22 +604,24 @@ cb_getenv(void *arg, int num)
}
static int
-cb_vm_set_register(void *arg, int vcpu, int reg, uint64_t val)
+cb_vm_set_register(void *arg __unused, int vcpuid, int reg, uint64_t val)
{
- return (vm_set_register(ctx, vcpu, reg, val));
+ assert(vcpuid == BSP);
+ return (vm_set_register(vcpu, reg, val));
}
static int
-cb_vm_set_desc(void *arg, int vcpu, int reg, uint64_t base, u_int limit,
- u_int access)
+cb_vm_set_desc(void *arg __unused, int vcpuid, int reg, uint64_t base,
+ u_int limit, u_int access)
{
- return (vm_set_desc(ctx, vcpu, reg, base, limit, access));
+ assert(vcpuid == BSP);
+ return (vm_set_desc(vcpu, reg, base, limit, access));
}
static void
-cb_swap_interpreter(void *arg, const char *interp_req)
+cb_swap_interpreter(void *arg __unused, const char *interp_req)
{
/*
@@ -597,7 +629,7 @@ cb_swap_interpreter(void *arg, const char *interp_req)
* not try to pivot to a different loader on them.
*/
free(loader);
- if (explicit_loader == 1) {
+ if (explicit_loader_fd != -1) {
perror("requested loader interpreter does not match guest userboot");
cb_exit(NULL, 1);
}
@@ -606,10 +638,9 @@ cb_swap_interpreter(void *arg, const char *interp_req)
cb_exit(NULL, 1);
}
- if (asprintf(&loader, "/boot/userboot_%s.so", interp_req) == -1)
+ if (asprintf(&loader, "userboot_%s.so", interp_req) == -1)
err(EX_OSERR, "malloc");
- need_reinit = 1;
- longjmp(jb, 1);
+ longjmp(jb, JMP_SWAPLOADER);
}
static struct loader_callbacks cb = {
@@ -690,7 +721,7 @@ disk_open(char *path)
if (ndisks >= NDISKS)
return (ERANGE);
- fd = open(path, O_RDONLY);
+ fd = open(path, O_RDWR);
if (fd < 0)
return (errno);
@@ -712,13 +743,56 @@ usage(void)
exit(1);
}
+static void
+hostbase_open(const char *base)
+{
+ cap_rights_t rights;
+
+ if (hostbase_fd != -1)
+ close(hostbase_fd);
+ hostbase_fd = open(base, O_DIRECTORY | O_PATH);
+ if (hostbase_fd == -1)
+ err(EX_OSERR, "open");
+
+ if (caph_rights_limit(hostbase_fd, cap_rights_init(&rights, CAP_FSTATAT,
+ CAP_LOOKUP, CAP_PREAD)) < 0)
+ err(EX_OSERR, "caph_rights_limit");
+}
+
+static void
+loader_open(int bootfd)
+{
+ int fd;
+
+ if (loader == NULL) {
+ loader = strdup("userboot.so");
+ if (loader == NULL)
+ err(EX_OSERR, "malloc");
+ }
+
+ assert(bootfd >= 0 || explicit_loader_fd >= 0);
+ if (explicit_loader_fd >= 0)
+ fd = explicit_loader_fd;
+ else
+ fd = openat(bootfd, loader, O_RDONLY | O_RESOLVE_BENEATH);
+ if (fd == -1)
+ err(EX_OSERR, "openat");
+
+ loader_hdl = fdlopen(fd, RTLD_LOCAL);
+ if (!loader_hdl)
+ errx(EX_OSERR, "dlopen: %s", dlerror());
+ if (fd != explicit_loader_fd)
+ close(fd);
+}
+
int
main(int argc, char** argv)
{
void (*func)(struct loader_callbacks *, void *, int, int);
uint64_t mem_size;
- int opt, error, memflags;
+ int bootfd, opt, error, memflags, need_reinit;
+ bootfd = -1;
progname = basename(argv[0]);
memflags = 0;
@@ -746,7 +820,7 @@ main(int argc, char** argv)
break;
case 'h':
- host_base = optarg;
+ hostbase_open(optarg);
break;
case 'l':
@@ -755,7 +829,9 @@ main(int argc, char** argv)
loader = strdup(optarg);
if (loader == NULL)
err(EX_OSERR, "malloc");
- explicit_loader = 1;
+ explicit_loader_fd = open(loader, O_RDONLY);
+ if (explicit_loader_fd == -1)
+ err(EX_OSERR, "%s", loader);
break;
case 'm':
@@ -785,60 +861,69 @@ main(int argc, char** argv)
need_reinit = 0;
error = vm_create(vmname);
if (error) {
- if (errno != EEXIST) {
- perror("vm_create");
- exit(1);
- }
+ if (errno != EEXIST)
+ err(1, "vm_create");
need_reinit = 1;
}
ctx = vm_open(vmname);
- if (ctx == NULL) {
- perror("vm_open");
- exit(1);
+ if (ctx == NULL)
+ err(1, "vm_open");
+
+ /*
+ * If we weren't given an explicit loader to use, we need to support the
+ * guest requesting a different one.
+ */
+ if (explicit_loader_fd == -1) {
+ cap_rights_t rights;
+
+ bootfd = open("/boot", O_DIRECTORY | O_PATH);
+ if (bootfd == -1)
+ err(1, "open");
+
+ /*
+ * bootfd will be used to do a lookup of our loader and do an
+ * fdlopen(3) on the loader; thus, we need mmap(2) in addition
+ * to the more usual lookup rights.
+ */
+ if (caph_rights_limit(bootfd, cap_rights_init(&rights,
+ CAP_FSTATAT, CAP_LOOKUP, CAP_MMAP_RX, CAP_PREAD)) < 0)
+ err(1, "caph_rights_limit");
}
+ vcpu = vm_vcpu_open(ctx, BSP);
+
+ caph_cache_catpages();
+ if (caph_enter() < 0)
+ err(1, "caph_enter");
+
/*
* setjmp in the case the guest wants to swap out interpreter,
* cb_swap_interpreter will swap out loader as appropriate and set
* need_reinit so that we end up in a clean state once again.
*/
- setjmp(jb);
+ if (setjmp(jb) != 0) {
+ dlclose(loader_hdl);
+ loader_hdl = NULL;
+
+ need_reinit = 1;
+ }
if (need_reinit) {
error = vm_reinit(ctx);
- if (error) {
- perror("vm_reinit");
- exit(1);
- }
+ if (error)
+ err(1, "vm_reinit");
}
vm_set_memflags(ctx, memflags);
error = vm_setup_memory(ctx, mem_size, VM_MMAP_ALL);
- if (error) {
- perror("vm_setup_memory");
- exit(1);
- }
+ if (error)
+ err(1, "vm_setup_memory");
- if (loader == NULL) {
- loader = strdup("/boot/userboot.so");
- if (loader == NULL)
- err(EX_OSERR, "malloc");
- }
- if (loader_hdl != NULL)
- dlclose(loader_hdl);
- loader_hdl = dlopen(loader, RTLD_LOCAL);
- if (!loader_hdl) {
- printf("%s\n", dlerror());
- free(loader);
- return (1);
- }
+ loader_open(bootfd);
func = dlsym(loader_hdl, "loader_main");
- if (!func) {
- printf("%s\n", dlerror());
- free(loader);
- return (1);
- }
+ if (!func)
+ errx(1, "dlsym: %s", dlerror());
tcgetattr(consout_fd, &term);
oldterm = term;
diff --git a/usr.sbin/binmiscctl/Makefile b/usr.sbin/binmiscctl/Makefile
index 867fc5f045d2..157f21378c7a 100644
--- a/usr.sbin/binmiscctl/Makefile
+++ b/usr.sbin/binmiscctl/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
.include <bsd.own.mk>
diff --git a/usr.sbin/binmiscctl/Makefile.depend b/usr.sbin/binmiscctl/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/binmiscctl/Makefile.depend
+++ b/usr.sbin/binmiscctl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/binmiscctl/binmiscctl.8 b/usr.sbin/binmiscctl/binmiscctl.8
index 82624cccd9ed..36b69f5d3375 100644
--- a/usr.sbin/binmiscctl/binmiscctl.8
+++ b/usr.sbin/binmiscctl/binmiscctl.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.\" Support for miscellaneous binary image activators
.\"
.Dd April 30, 2020
@@ -46,6 +44,7 @@
.Op Fl -mask Ar mask
.Op Fl -offset Ar offset
.Op Fl -set-enabled
+.Op Fl -pre-open
.Nm
.Cm disable
.Ar name
@@ -87,6 +86,7 @@ Operation must be one of the following:
.Op Fl -mask Ar mask
.Op Fl -offset Ar offset
.Op Fl -set-enabled
+.Op Fl -pre-open
.Xc
Add a new activator entry in the kernel.
You must specify a
@@ -124,6 +124,12 @@ To enable the activator entry the
option is used.
The activator default state is disabled.
.Pp
+To make the interpreter automatically available in jails and chroots,
+use the
+.Fl -pre-open
+option to allow the kernel to open the binary at configuration time
+rather then lazily when the the interpreted program is started.
+.Pp
The interpreter
.Ar path
may also contain arguments for the interpreter including
diff --git a/usr.sbin/binmiscctl/binmiscctl.c b/usr.sbin/binmiscctl/binmiscctl.c
index 3c5e19def67b..6a4950c9bf3a 100644
--- a/usr.sbin/binmiscctl/binmiscctl.c
+++ b/usr.sbin/binmiscctl/binmiscctl.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/imgact_binmisc.h>
#include <sys/linker.h>
@@ -75,7 +72,8 @@ static const struct {
"<name> --interpreter <path_and_arguments> \\\n"
"\t\t--magic <magic_bytes> [--mask <mask_bytes>] \\\n"
"\t\t--size <magic_size> [--offset <magic_offset>] \\\n"
- "\t\t[--set-enabled]"
+ "\t\t[--set-enabled] \\\n"
+ "\t\t[--pre-open]"
},
{
CMD_REMOVE,
@@ -122,6 +120,7 @@ add_opts[] = {
{ "magic", required_argument, NULL, 'm' },
{ "offset", required_argument, NULL, 'o' },
{ "size", required_argument, NULL, 's' },
+ { "pre-open", no_argument, NULL, 'p' },
{ NULL, 0, NULL, 0 }
};
@@ -192,8 +191,9 @@ printxbe(ximgact_binmisc_entry_t *xbe)
printf("name: %s\n", xbe->xbe_name);
printf("interpreter: %s\n", xbe->xbe_interpreter);
- printf("flags: %s%s\n", (flags & IBF_ENABLED) ? "ENABLED " : "",
- (flags & IBF_USE_MASK) ? "USE_MASK " : "");
+ printf("flags: %s%s%s\n", (flags & IBF_ENABLED) ? "ENABLED " : "",
+ (flags & IBF_USE_MASK) ? "USE_MASK " : "",
+ (flags & IBF_PRE_OPEN) ? "PRE_OPEN " : "");
printf("magic size: %u\n", xbe->xbe_msize);
printf("magic offset: %u\n", xbe->xbe_moffset);
@@ -291,7 +291,7 @@ add_cmd(__unused int argc, char *argv[], ximgact_binmisc_entry_t *xbe)
IBE_NAME_MAX);
strlcpy(&xbe->xbe_name[0], argv[0], IBE_NAME_MAX);
- while ((ch = getopt_long(argc, argv, "ei:m:M:o:s:", add_opts, NULL))
+ while ((ch = getopt_long(argc, argv, "epi:m:M:o:s:", add_opts, NULL))
!= -1) {
switch(ch) {
@@ -328,6 +328,10 @@ add_cmd(__unused int argc, char *argv[], ximgact_binmisc_entry_t *xbe)
xbe->xbe_msize);
break;
+ case 'p':
+ xbe->xbe_flags |= IBF_PRE_OPEN;
+ break;
+
default:
usage("Unknown argument: '%c'", ch);
}
diff --git a/usr.sbin/blacklistctl/Makefile b/usr.sbin/blacklistctl/Makefile
index fd63b85cecbe..065c17843cee 100644
--- a/usr.sbin/blacklistctl/Makefile
+++ b/usr.sbin/blacklistctl/Makefile
@@ -1,7 +1,8 @@
-# $FreeBSD$
-BLACKLIST_DIR=${SRCTOP}/contrib/blacklist
-.PATH: ${BLACKLIST_DIR}/bin ${BLACKLIST_DIR}/port
+BLOCKLIST_DIR=${SRCTOP}/contrib/blocklist
+.PATH: ${BLOCKLIST_DIR}/bin ${BLOCKLIST_DIR}/port
+
+PACKAGE= blocklist
PROG= blacklistctl
SRCS= blacklistctl.c conf.c state.c support.c internal.c \
@@ -11,7 +12,7 @@ MAN= blacklistctl.8
LDFLAGS+=-L${LIBBLACKLISTDIR}
LIBADD+= blacklist util
-CFLAGS+=-I${BLACKLIST_DIR}/include -I${BLACKLIST_DIR}/port \
+CFLAGS+=-I${BLOCKLIST_DIR}/include -I${BLOCKLIST_DIR}/port \
-D_PATH_BLCONTROL=\"/usr/libexec/blacklistd-helper\" \
-DHAVE_CONFIG_H -DHAVE_DB_H -DHAVE_LIBUTIL_H \
-DHAVE_CLOCK_GETTIME -DHAVE_FGETLN -DHAVE_FPARSELN \
diff --git a/usr.sbin/blacklistctl/Makefile.depend b/usr.sbin/blacklistctl/Makefile.depend
index 741c9b987127..9e525b6acefc 100644
--- a/usr.sbin/blacklistctl/Makefile.depend
+++ b/usr.sbin/blacklistctl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -10,7 +8,6 @@ DIRDEPS = \
lib/libblacklist \
lib/libc \
lib/libcompiler_rt \
- lib/libthr \
lib/libutil \
diff --git a/usr.sbin/blacklistd/Makefile b/usr.sbin/blacklistd/Makefile
index 8c9a354a7fb3..92928ca3e60f 100644
--- a/usr.sbin/blacklistd/Makefile
+++ b/usr.sbin/blacklistd/Makefile
@@ -1,7 +1,8 @@
-# $FreeBSD$
-BLACKLIST_DIR=${SRCTOP}/contrib/blacklist
-.PATH: ${BLACKLIST_DIR}/bin ${BLACKLIST_DIR}/port
+BLOCKLIST_DIR=${SRCTOP}/contrib/blocklist
+.PATH: ${BLOCKLIST_DIR}/bin ${BLOCKLIST_DIR}/port
+
+PACKAGE= blocklist
CONFS= blacklistd.conf
PROG= blacklistd
@@ -12,7 +13,7 @@ MAN= blacklistd.8 blacklistd.conf.5
LDFLAGS+=-L${LIBBLACKLISTDIR}
LIBADD+= blacklist util
-CFLAGS+=-I${BLACKLIST_DIR}/include -I${BLACKLIST_DIR}/port \
+CFLAGS+=-I${BLOCKLIST_DIR}/include -I${BLOCKLIST_DIR}/port \
-D_PATH_BLCONTROL=\"/usr/libexec/blacklistd-helper\" \
-DHAVE_CONFIG_H -DHAVE_DB_H -DHAVE_LIBUTIL_H \
-DHAVE_CLOCK_GETTIME -DHAVE_FGETLN -DHAVE_FPARSELN \
diff --git a/usr.sbin/blacklistd/Makefile.depend b/usr.sbin/blacklistd/Makefile.depend
index 741c9b987127..9e525b6acefc 100644
--- a/usr.sbin/blacklistd/Makefile.depend
+++ b/usr.sbin/blacklistd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -10,7 +8,6 @@ DIRDEPS = \
lib/libblacklist \
lib/libc \
lib/libcompiler_rt \
- lib/libthr \
lib/libutil \
diff --git a/usr.sbin/blacklistd/blacklistd.conf b/usr.sbin/blacklistd/blacklistd.conf
index 2b1cf87e60c9..b8dee6768cc7 100644
--- a/usr.sbin/blacklistd/blacklistd.conf
+++ b/usr.sbin/blacklistd/blacklistd.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Blacklist rule
# adr/mask:port type proto owner name nfail disable
diff --git a/usr.sbin/bluetooth/Makefile b/usr.sbin/bluetooth/Makefile
index 99f2a2eb9087..fb660029b3d1 100644
--- a/usr.sbin/bluetooth/Makefile
+++ b/usr.sbin/bluetooth/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.5 2003/09/08 02:28:35 max Exp $
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/bluetooth/Makefile.inc b/usr.sbin/bluetooth/Makefile.inc
index 993a2f3616ab..ebb2c23220d8 100644
--- a/usr.sbin/bluetooth/Makefile.inc
+++ b/usr.sbin/bluetooth/Makefile.inc
@@ -1,3 +1,2 @@
-# $FreeBSD$
.include "${.CURDIR:H:H}/Makefile.inc"
diff --git a/usr.sbin/bluetooth/ath3kfw/Makefile b/usr.sbin/bluetooth/ath3kfw/Makefile
index 7b2f2c2086bd..97f2f0083914 100644
--- a/usr.sbin/bluetooth/ath3kfw/Makefile
+++ b/usr.sbin/bluetooth/ath3kfw/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= bluetooth
PROG= ath3kfw
diff --git a/usr.sbin/bluetooth/ath3kfw/Makefile.depend b/usr.sbin/bluetooth/ath3kfw/Makefile.depend
index a93901938c4b..34fbfadfcfb6 100644
--- a/usr.sbin/bluetooth/ath3kfw/Makefile.depend
+++ b/usr.sbin/bluetooth/ath3kfw/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/libthr \
lib/libusb \
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3k_dbg.h b/usr.sbin/bluetooth/ath3kfw/ath3k_dbg.h
index 3aaf3b3f925e..06b0b3c58515 100644
--- a/usr.sbin/bluetooth/ath3kfw/ath3k_dbg.h
+++ b/usr.sbin/bluetooth/ath3kfw/ath3k_dbg.h
@@ -25,8 +25,6 @@
* 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 DAMAGES.
- *
- * $FreeBSD$
*/
#ifndef __ATH3K_DEBUG_H__
#define __ATH3K_DEBUG_H__
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3k_fw.c b/usr.sbin/bluetooth/ath3kfw/ath3k_fw.c
index 2c480044c2d7..d67006760098 100644
--- a/usr.sbin/bluetooth/ath3kfw/ath3k_fw.c
+++ b/usr.sbin/bluetooth/ath3kfw/ath3k_fw.c
@@ -25,8 +25,6 @@
* 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 DAMAGES.
- *
- * $FreeBSD$
*/
#include <stdio.h>
@@ -49,7 +47,6 @@ ath3k_fw_read(struct ath3k_firmware *fw, const char *fwname)
struct stat sb;
unsigned char *buf;
ssize_t r;
- int i;
fd = open(fwname, O_RDONLY);
if (fd < 0) {
@@ -70,7 +67,6 @@ ath3k_fw_read(struct ath3k_firmware *fw, const char *fwname)
return (0);
}
- i = 0;
/* XXX handle partial reads */
r = read(fd, buf, sb.st_size);
if (r < 0) {
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3k_fw.h b/usr.sbin/bluetooth/ath3kfw/ath3k_fw.h
index eddc0b7e4216..f9d2c53e883d 100644
--- a/usr.sbin/bluetooth/ath3kfw/ath3k_fw.h
+++ b/usr.sbin/bluetooth/ath3kfw/ath3k_fw.h
@@ -25,8 +25,6 @@
* 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 DAMAGES.
- *
- * $FreeBSD$
*/
#ifndef __ATH3K_FW_H__
#define __ATH3K_FW_H__
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3k_hw.c b/usr.sbin/bluetooth/ath3kfw/ath3k_hw.c
index 890e2dbf75a2..cb32059e61d5 100644
--- a/usr.sbin/bluetooth/ath3kfw/ath3k_hw.c
+++ b/usr.sbin/bluetooth/ath3kfw/ath3k_hw.c
@@ -25,8 +25,6 @@
* 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 DAMAGES.
- *
- * $FreeBSD$
*/
#include <stdio.h>
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3k_hw.h b/usr.sbin/bluetooth/ath3kfw/ath3k_hw.h
index 2d72f3f16cfd..b4d8fc3e462b 100644
--- a/usr.sbin/bluetooth/ath3kfw/ath3k_hw.h
+++ b/usr.sbin/bluetooth/ath3kfw/ath3k_hw.h
@@ -25,8 +25,6 @@
* 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 DAMAGES.
- *
- * $FreeBSD$
*/
#ifndef __ATH3K_HW_H__
#define __ATH3K_HW_H__
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3kfw.8 b/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
index 74855831a702..340871d31df8 100644
--- a/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
+++ b/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 4, 2016
.Dt ATH3KFW 8
.Os
diff --git a/usr.sbin/bluetooth/ath3kfw/main.c b/usr.sbin/bluetooth/ath3kfw/main.c
index 6ca5206b1507..c04ce2baafd1 100644
--- a/usr.sbin/bluetooth/ath3kfw/main.c
+++ b/usr.sbin/bluetooth/ath3kfw/main.c
@@ -25,8 +25,6 @@
* 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 DAMAGES.
- *
- * $FreeBSD$
*/
#include <stdio.h>
@@ -155,7 +153,7 @@ ath3k_init_ar3012(libusb_device_handle *hdl, const char *fw_path)
ret = ath3k_load_patch(hdl, fw_path);
if (ret < 0) {
ath3k_err("Loading patch file failed\n");
- return (ret);
+ return (ret);
}
ret = ath3k_load_syscfg(hdl, fw_path);
@@ -199,7 +197,7 @@ ath3k_init_firmware(libusb_device_handle *hdl, const char *file_prefix)
/* free it */
ath3k_fw_free(&fw);
- return (0);
+ return (ret);
}
/*
diff --git a/usr.sbin/bluetooth/bcmfw/BCM-LEGAL.txt b/usr.sbin/bluetooth/bcmfw/BCM-LEGAL.txt
index e3a235e0d82e..02ff4badbbdf 100644
--- a/usr.sbin/bluetooth/bcmfw/BCM-LEGAL.txt
+++ b/usr.sbin/bluetooth/bcmfw/BCM-LEGAL.txt
@@ -1,4 +1,3 @@
-$FreeBSD$
BCM firmware version 2.15
Copyright (c) 2000-2002 Broadcom Corporation
diff --git a/usr.sbin/bluetooth/bcmfw/Makefile b/usr.sbin/bluetooth/bcmfw/Makefile
index c88450bdc187..9d186d9f8869 100644
--- a/usr.sbin/bluetooth/bcmfw/Makefile
+++ b/usr.sbin/bluetooth/bcmfw/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.6 2003/08/14 20:05:58 max Exp $
-# $FreeBSD$
PACKAGE= bluetooth
PROG= bcmfw
diff --git a/usr.sbin/bluetooth/bcmfw/Makefile.depend b/usr.sbin/bluetooth/bcmfw/Makefile.depend
index 3f4cb50e1709..208c47654297 100644
--- a/usr.sbin/bluetooth/bcmfw/Makefile.depend
+++ b/usr.sbin/bluetooth/bcmfw/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/bluetooth/bcmfw/README b/usr.sbin/bluetooth/bcmfw/README
index 0d769d8e9036..cfaf4781d419 100644
--- a/usr.sbin/bluetooth/bcmfw/README
+++ b/usr.sbin/bluetooth/bcmfw/README
@@ -1,4 +1,3 @@
-$FreeBSD$
This directory will eventually also contain copies of the broadcom firmware.
diff --git a/usr.sbin/bluetooth/bcmfw/bcmfw.8 b/usr.sbin/bluetooth/bcmfw/bcmfw.8
index d82d701531b3..22d793641759 100644
--- a/usr.sbin/bluetooth/bcmfw/bcmfw.8
+++ b/usr.sbin/bluetooth/bcmfw/bcmfw.8
@@ -23,7 +23,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: bcmfw.8,v 1.7 2003/05/21 00:33:40 max Exp $
-.\" $FreeBSD$
.\"
.Dd March 31, 2003
.Dt BCMFW 8
diff --git a/usr.sbin/bluetooth/bcmfw/bcmfw.c b/usr.sbin/bluetooth/bcmfw/bcmfw.c
index f385eae0d9ea..1361c7fe6d51 100644
--- a/usr.sbin/bluetooth/bcmfw/bcmfw.c
+++ b/usr.sbin/bluetooth/bcmfw/bcmfw.c
@@ -1,7 +1,7 @@
/*-
* bcmfw.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: bcmfw.c,v 1.4 2003/04/27 19:28:09 max Exp $
- * $FreeBSD$
*
* Based on Linux BlueZ BlueFW-0.9 package
*
diff --git a/usr.sbin/bluetooth/bluetooth-config/Makefile b/usr.sbin/bluetooth/bluetooth-config/Makefile
index b567026890e7..19598ebb112c 100644
--- a/usr.sbin/bluetooth/bluetooth-config/Makefile
+++ b/usr.sbin/bluetooth/bluetooth-config/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= bluetooth
SCRIPTS=bluetooth-config.sh
diff --git a/usr.sbin/bluetooth/bluetooth-config/bluetooth-config.8 b/usr.sbin/bluetooth/bluetooth-config/bluetooth-config.8
index fe5785265ce8..fcf40b392d06 100644
--- a/usr.sbin/bluetooth/bluetooth-config/bluetooth-config.8
+++ b/usr.sbin/bluetooth/bluetooth-config/bluetooth-config.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 7, 2019
.Dt BLUETOOTH-CONFIG 8
.Os
diff --git a/usr.sbin/bluetooth/bluetooth-config/bluetooth-config.sh b/usr.sbin/bluetooth/bluetooth-config/bluetooth-config.sh
index f010c29c6025..48a399a82fc7 100755
--- a/usr.sbin/bluetooth/bluetooth-config/bluetooth-config.sh
+++ b/usr.sbin/bluetooth/bluetooth-config/bluetooth-config.sh
@@ -7,7 +7,6 @@
# this stuff is worth it, you can buy me a beer in return Poul-Henning Kamp
# ----------------------------------------------------------------------------
#
-# $FreeBSD$
#
# define our bail out shortcut
diff --git a/usr.sbin/bluetooth/bthidcontrol/Makefile b/usr.sbin/bluetooth/bthidcontrol/Makefile
index 0bdfed6fa682..bc6cc15ab9e7 100644
--- a/usr.sbin/bluetooth/bthidcontrol/Makefile
+++ b/usr.sbin/bluetooth/bthidcontrol/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.2 2004/02/13 21:44:41 max Exp $
-# $FreeBSD$
.PATH: ${.CURDIR:H}/bthidd
diff --git a/usr.sbin/bluetooth/bthidcontrol/Makefile.depend b/usr.sbin/bluetooth/bthidcontrol/Makefile.depend
index 025b326c97f5..0269d05a05a0 100644
--- a/usr.sbin/bluetooth/bthidcontrol/Makefile.depend
+++ b/usr.sbin/bluetooth/bthidcontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.8 b/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.8
index 50774f18d03b..c74a93f99082 100644
--- a/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.8
+++ b/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.8
@@ -23,7 +23,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: bthidcontrol.8,v 1.1 2004/02/13 21:44:41 max Exp $
-.\" $FreeBSD$
.\"
.Dd October 30, 2006
.Dt BTHIDCONTROL 8
diff --git a/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.c b/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.c
index c7b3a0634eb0..40ece6ce0635 100644
--- a/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.c
+++ b/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.c
@@ -1,7 +1,7 @@
/*-
* bthidcontrol.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: bthidcontrol.c,v 1.2 2004/02/13 21:44:41 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
@@ -48,7 +47,7 @@
static int do_bthid_command(bdaddr_p bdaddr, int argc, char **argv);
static struct bthid_command * find_bthid_command(char const *command, struct bthid_command *category);
static void print_bthid_command(struct bthid_command *category);
-static void usage(void);
+static void usage(void) __dead2;
int32_t hid_sdp_query(bdaddr_t const *local, bdaddr_t const *remote, int32_t *error);
diff --git a/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.h b/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.h
index a35e07021335..e44b670f8f7e 100644
--- a/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.h
+++ b/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.h
@@ -1,7 +1,7 @@
/*-
* bthidcontrol.h
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: bthidcontrol.h,v 1.1 2004/02/12 23:25:51 max Exp $
- * $FreeBSD$
*/
#ifndef __BTHIDCONTROL_H__
diff --git a/usr.sbin/bluetooth/bthidcontrol/hid.c b/usr.sbin/bluetooth/bthidcontrol/hid.c
index 793d17430084..727eb8a716e7 100644
--- a/usr.sbin/bluetooth/bthidcontrol/hid.c
+++ b/usr.sbin/bluetooth/bthidcontrol/hid.c
@@ -1,7 +1,7 @@
/*-
* hid.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: hid.c,v 1.3 2004/02/17 22:14:57 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/bthidcontrol/sdp.c b/usr.sbin/bluetooth/bthidcontrol/sdp.c
index c63ddd5efa0a..dc83229f080c 100644
--- a/usr.sbin/bluetooth/bthidcontrol/sdp.c
+++ b/usr.sbin/bluetooth/bthidcontrol/sdp.c
@@ -1,7 +1,7 @@
/*-
* sdp.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: sdp.c,v 1.3 2004/02/17 22:14:57 max Exp $
- * $FreeBSD$
*/
#include <sys/types.h>
@@ -52,7 +51,7 @@ static int32_t hid_sdp_parse_hid_descriptor (sdp_attr_p a);
static int32_t hid_sdp_parse_boolean (sdp_attr_p a);
/*
- * Hard coded attibute IDs taken from the
+ * Hard coded attribute IDs taken from the
* DEVICE IDENTIFICATION PROFILE SPECIFICATION V13 p.12
*/
diff --git a/usr.sbin/bluetooth/bthidd/Makefile b/usr.sbin/bluetooth/bthidd/Makefile
index d92b4cff1693..b924d1985e9d 100644
--- a/usr.sbin/bluetooth/bthidd/Makefile
+++ b/usr.sbin/bluetooth/bthidd/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.6 2006/09/07 21:36:55 max Exp $
-# $FreeBSD$
PACKAGE= bluetooth
PROG= bthidd
diff --git a/usr.sbin/bluetooth/bthidd/Makefile.depend b/usr.sbin/bluetooth/bthidd/Makefile.depend
index 1549057016d2..595af15e5072 100644
--- a/usr.sbin/bluetooth/bthidd/Makefile.depend
+++ b/usr.sbin/bluetooth/bthidd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/bluetooth/bthidd/bthid_config.h b/usr.sbin/bluetooth/bthidd/bthid_config.h
index 8a53329333be..829af57aff45 100644
--- a/usr.sbin/bluetooth/bthidd/bthid_config.h
+++ b/usr.sbin/bluetooth/bthidd/bthid_config.h
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: bthid_config.h,v 1.4 2006/09/07 21:06:53 max Exp $
- * $FreeBSD$
*/
#ifndef _BTHID_CONFIG_H_
diff --git a/usr.sbin/bluetooth/bthidd/bthidd.8 b/usr.sbin/bluetooth/bthidd/bthidd.8
index 695eb0676e42..1d609948d1b8 100644
--- a/usr.sbin/bluetooth/bthidd/bthidd.8
+++ b/usr.sbin/bluetooth/bthidd/bthidd.8
@@ -23,7 +23,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: bthidd.8,v 1.1 2006/09/07 21:36:55 max Exp $
-.\" $FreeBSD$
.\"
.Dd April 30, 2018
.Dt BTHIDD 8
@@ -94,7 +93,7 @@ The
.Nm
daemon currently does not handle key auto repeat and double click mouse events.
Those events work under
-.Xr X 7
+.Xr X 7 Pq Pa ports/x11/xorg-docs
just fine,
but not in text console.
.Pp
diff --git a/usr.sbin/bluetooth/bthidd/bthidd.c b/usr.sbin/bluetooth/bthidd/bthidd.c
index 1910a91732fd..fad467667bd1 100644
--- a/usr.sbin/bluetooth/bthidd/bthidd.c
+++ b/usr.sbin/bluetooth/bthidd/bthidd.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: bthidd.c,v 1.8 2006/09/07 21:06:53 max Exp $
- * $FreeBSD$
*/
#include <sys/time.h>
diff --git a/usr.sbin/bluetooth/bthidd/bthidd.conf.sample b/usr.sbin/bluetooth/bthidd/bthidd.conf.sample
index deb414870da0..63b3ced5edce 100644
--- a/usr.sbin/bluetooth/bthidd/bthidd.conf.sample
+++ b/usr.sbin/bluetooth/bthidd/bthidd.conf.sample
@@ -1,4 +1,3 @@
-# $FreeBSD$
device {
bdaddr 00:50:f2:e5:68:84;
diff --git a/usr.sbin/bluetooth/bthidd/bthidd.h b/usr.sbin/bluetooth/bthidd/bthidd.h
index 9ceeb050f2ed..55fd03e57334 100644
--- a/usr.sbin/bluetooth/bthidd/bthidd.h
+++ b/usr.sbin/bluetooth/bthidd/bthidd.h
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: bthidd.h,v 1.7 2006/09/07 21:06:53 max Exp $
- * $FreeBSD$
*/
#ifndef _BTHIDD_H_
diff --git a/usr.sbin/bluetooth/bthidd/btuinput.c b/usr.sbin/bluetooth/bthidd/btuinput.c
index c51ce8dd0ffc..497a5527e3aa 100644
--- a/usr.sbin/bluetooth/bthidd/btuinput.c
+++ b/usr.sbin/bluetooth/bthidd/btuinput.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015-2017 Vladimir Kondratyev <wulf@FreeBSD.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/bluetooth/bthidd/btuinput.h b/usr.sbin/bluetooth/bthidd/btuinput.h
index c17814b36146..caa11fc65c46 100644
--- a/usr.sbin/bluetooth/bthidd/btuinput.h
+++ b/usr.sbin/bluetooth/bthidd/btuinput.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015-2017 Vladimir Kondratyev <wulf@FreeBSD.org>
* 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 _UINPUT_H_
diff --git a/usr.sbin/bluetooth/bthidd/client.c b/usr.sbin/bluetooth/bthidd/client.c
index 2d8a1162d468..63fef5867b98 100644
--- a/usr.sbin/bluetooth/bthidd/client.c
+++ b/usr.sbin/bluetooth/bthidd/client.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: client.c,v 1.7 2006/09/07 21:06:53 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/bthidd/hid.c b/usr.sbin/bluetooth/bthidd/hid.c
index e5695578b27d..4de3c07119e2 100644
--- a/usr.sbin/bluetooth/bthidd/hid.c
+++ b/usr.sbin/bluetooth/bthidd/hid.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: hid.c,v 1.5 2006/09/07 21:06:53 max Exp $
- * $FreeBSD$
*/
#include <sys/consio.h>
diff --git a/usr.sbin/bluetooth/bthidd/kbd.c b/usr.sbin/bluetooth/bthidd/kbd.c
index 814c130a7ccd..c1616c7e4bd3 100644
--- a/usr.sbin/bluetooth/bthidd/kbd.c
+++ b/usr.sbin/bluetooth/bthidd/kbd.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: kbd.c,v 1.4 2006/09/07 21:06:53 max Exp $
- * $FreeBSD$
*/
#include <sys/consio.h>
diff --git a/usr.sbin/bluetooth/bthidd/kbd.h b/usr.sbin/bluetooth/bthidd/kbd.h
index a13e0b09886c..d12d51d0e62f 100644
--- a/usr.sbin/bluetooth/bthidd/kbd.h
+++ b/usr.sbin/bluetooth/bthidd/kbd.h
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: kbd.h,v 1.3 2006/09/07 21:06:53 max Exp $
- * $FreeBSD$
*/
#ifndef _KBD_H_
diff --git a/usr.sbin/bluetooth/bthidd/lexer.l b/usr.sbin/bluetooth/bthidd/lexer.l
index 22b5d2d18651..d8933e4ea5d7 100644
--- a/usr.sbin/bluetooth/bthidd/lexer.l
+++ b/usr.sbin/bluetooth/bthidd/lexer.l
@@ -4,7 +4,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*
* $Id: lexer.l,v 1.3 2006/09/07 21:06:53 max Exp $
- * $FreeBSD$
*/
#define L2CAP_SOCKET_CHECKED
#include <bluetooth.h>
diff --git a/usr.sbin/bluetooth/bthidd/parser.y b/usr.sbin/bluetooth/bthidd/parser.y
index bbb6202909fe..a18ef3515b8b 100644
--- a/usr.sbin/bluetooth/bthidd/parser.y
+++ b/usr.sbin/bluetooth/bthidd/parser.y
@@ -4,7 +4,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*
* $Id: parser.y,v 1.7 2006/09/07 21:06:53 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/bthidd/server.c b/usr.sbin/bluetooth/bthidd/server.c
index 33915307db0e..c532561265cd 100644
--- a/usr.sbin/bluetooth/bthidd/server.c
+++ b/usr.sbin/bluetooth/bthidd/server.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: server.c,v 1.9 2006/09/07 21:06:53 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
@@ -114,7 +113,7 @@ server_init(bthid_server_p srv)
return (-1);
}
- /* Create intrrupt socket */
+ /* Create interrupt socket */
srv->intr = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BLUETOOTH_PROTO_L2CAP);
if (srv->intr < 0) {
syslog(LOG_ERR, "Could not create interrupt L2CAP socket. " \
diff --git a/usr.sbin/bluetooth/bthidd/session.c b/usr.sbin/bluetooth/bthidd/session.c
index aa3552c4dc10..ab9fa59dab65 100644
--- a/usr.sbin/bluetooth/bthidd/session.c
+++ b/usr.sbin/bluetooth/bthidd/session.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: session.c,v 1.3 2006/09/07 21:06:53 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/btpand/Makefile b/usr.sbin/bluetooth/btpand/Makefile
index e24a9fe7f795..14848e66e42a 100644
--- a/usr.sbin/bluetooth/btpand/Makefile
+++ b/usr.sbin/bluetooth/btpand/Makefile
@@ -1,5 +1,4 @@
# $NetBSD: Makefile,v 1.2 2008/08/18 08:25:32 plunky Exp $
-# $FreeBSD$
PACKAGE= bluetooth
PROG= btpand
diff --git a/usr.sbin/bluetooth/btpand/Makefile.depend b/usr.sbin/bluetooth/btpand/Makefile.depend
index b4d153024640..8c9bfd44959f 100644
--- a/usr.sbin/bluetooth/btpand/Makefile.depend
+++ b/usr.sbin/bluetooth/btpand/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/bluetooth/btpand/bnep.c b/usr.sbin/bluetooth/btpand/bnep.c
index 16a3faaec4ac..5fdcd9407525 100644
--- a/usr.sbin/bluetooth/btpand/bnep.c
+++ b/usr.sbin/bluetooth/btpand/bnep.c
@@ -1,7 +1,7 @@
/* $NetBSD: bnep.c,v 1.1 2008/08/17 13:20:57 plunky Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Iain Hibbert
* All rights reserved.
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
#include <sys/cdefs.h>
__RCSID("$NetBSD: bnep.c,v 1.1 2008/08/17 13:20:57 plunky Exp $");
diff --git a/usr.sbin/bluetooth/btpand/bnep.h b/usr.sbin/bluetooth/btpand/bnep.h
index 9fc60932e34c..7a187e551eed 100644
--- a/usr.sbin/bluetooth/btpand/bnep.h
+++ b/usr.sbin/bluetooth/btpand/bnep.h
@@ -1,7 +1,7 @@
/* $NetBSD: bnep.h,v 1.1 2008/08/17 13:20:57 plunky Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Iain Hibbert
* All rights reserved.
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
/*
* Constants defined in the Bluetooth Network Encapsulation
diff --git a/usr.sbin/bluetooth/btpand/btpand.8 b/usr.sbin/bluetooth/btpand/btpand.8
index 4f6ede6ac2d2..8993b221361f 100644
--- a/usr.sbin/bluetooth/btpand/btpand.8
+++ b/usr.sbin/bluetooth/btpand/btpand.8
@@ -1,5 +1,4 @@
.\" $NetBSD: btpand.8,v 1.3 2008/08/17 14:43:07 plunky Exp $
-.\" $FreeBSD$
.\"
.\" Copyright (c) 2008 Iain Hibbert
.\" All rights reserved.
diff --git a/usr.sbin/bluetooth/btpand/btpand.c b/usr.sbin/bluetooth/btpand/btpand.c
index e24152d92e96..d4bc15823290 100644
--- a/usr.sbin/bluetooth/btpand/btpand.c
+++ b/usr.sbin/bluetooth/btpand/btpand.c
@@ -1,7 +1,7 @@
/* $NetBSD: btpand.c,v 1.1 2008/08/17 13:20:57 plunky Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Iain Hibbert
* All rights reserved.
@@ -27,11 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
-
-#include <sys/cdefs.h>
-__COPYRIGHT("@(#) Copyright (c) 2008 Iain Hibbert. All rights reserved.");
-__RCSID("$NetBSD: btpand.c,v 1.1 2008/08/17 13:20:57 plunky Exp $");
#include <sys/wait.h>
@@ -72,9 +67,9 @@ static const struct {
{ "GN", SDP_SERVICE_CLASS_GN, "Group Network" },
};
-static void main_exit(int);
+static void main_exit(int) __dead2;
static void main_detach(void);
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char *argv[])
diff --git a/usr.sbin/bluetooth/btpand/btpand.h b/usr.sbin/bluetooth/btpand/btpand.h
index 566fac3f60b8..a3beb7f211da 100644
--- a/usr.sbin/bluetooth/btpand/btpand.h
+++ b/usr.sbin/bluetooth/btpand/btpand.h
@@ -1,7 +1,7 @@
/* $NetBSD: btpand.h,v 1.1 2008/08/17 13:20:57 plunky Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Iain Hibbert
* All rights reserved.
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
#include <sys/types.h>
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/btpand/channel.c b/usr.sbin/bluetooth/btpand/channel.c
index a8a0d6ac8a06..960b1ae30152 100644
--- a/usr.sbin/bluetooth/btpand/channel.c
+++ b/usr.sbin/bluetooth/btpand/channel.c
@@ -1,7 +1,7 @@
/* $NetBSD: channel.c,v 1.1 2008/08/17 13:20:57 plunky Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Iain Hibbert
* All rights reserved.
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
#include <sys/cdefs.h>
__RCSID("$NetBSD: channel.c,v 1.1 2008/08/17 13:20:57 plunky Exp $");
diff --git a/usr.sbin/bluetooth/btpand/client.c b/usr.sbin/bluetooth/btpand/client.c
index bf61dfc9e798..ecef7e9c3c14 100644
--- a/usr.sbin/bluetooth/btpand/client.c
+++ b/usr.sbin/bluetooth/btpand/client.c
@@ -1,7 +1,7 @@
/* $NetBSD: client.c,v 1.2 2008/12/06 20:01:14 plunky Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Iain Hibbert
* All rights reserved.
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
#include <sys/cdefs.h>
__RCSID("$NetBSD: client.c,v 1.2 2008/12/06 20:01:14 plunky Exp $");
diff --git a/usr.sbin/bluetooth/btpand/event.c b/usr.sbin/bluetooth/btpand/event.c
index 502b73eaee46..61825b63a3fc 100644
--- a/usr.sbin/bluetooth/btpand/event.c
+++ b/usr.sbin/bluetooth/btpand/event.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2009 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-/* $FreeBSD$ */
/*
* Hack to provide libevent (see devel/libevent port) like API.
diff --git a/usr.sbin/bluetooth/btpand/event.h b/usr.sbin/bluetooth/btpand/event.h
index e70b7ce3e02a..dd588e86f6bf 100644
--- a/usr.sbin/bluetooth/btpand/event.h
+++ b/usr.sbin/bluetooth/btpand/event.h
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2009 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-/* $FreeBSD$ */
/*
* Hack to provide libevent (see devel/libevent port) like API.
diff --git a/usr.sbin/bluetooth/btpand/packet.c b/usr.sbin/bluetooth/btpand/packet.c
index 8e20696ad443..3051b0fbaecd 100644
--- a/usr.sbin/bluetooth/btpand/packet.c
+++ b/usr.sbin/bluetooth/btpand/packet.c
@@ -1,7 +1,7 @@
/* $NetBSD: packet.c,v 1.1 2008/08/17 13:20:57 plunky Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Iain Hibbert
* All rights reserved.
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
#include <sys/cdefs.h>
__RCSID("$NetBSD: packet.c,v 1.1 2008/08/17 13:20:57 plunky Exp $");
diff --git a/usr.sbin/bluetooth/btpand/sdp.c b/usr.sbin/bluetooth/btpand/sdp.c
index 82fc5baaf59f..a21710781cf2 100644
--- a/usr.sbin/bluetooth/btpand/sdp.c
+++ b/usr.sbin/bluetooth/btpand/sdp.c
@@ -1,7 +1,7 @@
/* $NetBSD: sdp.c,v 1.2 2008/12/06 20:01:14 plunky Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Iain Hibbert
* All rights reserved.
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
#include <sys/cdefs.h>
__RCSID("$NetBSD: sdp.c,v 1.2 2008/12/06 20:01:14 plunky Exp $");
diff --git a/usr.sbin/bluetooth/btpand/sdp.h b/usr.sbin/bluetooth/btpand/sdp.h
index a1a9758edec8..66c5c601bd1a 100644
--- a/usr.sbin/bluetooth/btpand/sdp.h
+++ b/usr.sbin/bluetooth/btpand/sdp.h
@@ -1,7 +1,7 @@
/* $NetBSD: sdp.h,v 1.2 2008/12/06 20:01:15 plunky Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Iain Hibbert
* All rights reserved.
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
#include <bluetooth.h>
#include <sdp.h>
diff --git a/usr.sbin/bluetooth/btpand/server.c b/usr.sbin/bluetooth/btpand/server.c
index 583017a2d543..f0967d058ca4 100644
--- a/usr.sbin/bluetooth/btpand/server.c
+++ b/usr.sbin/bluetooth/btpand/server.c
@@ -1,7 +1,7 @@
/* $NetBSD: server.c,v 1.2 2009/01/24 17:29:28 plunky Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Iain Hibbert
* All rights reserved.
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
#include <sys/cdefs.h>
__RCSID("$NetBSD: server.c,v 1.2 2009/01/24 17:29:28 plunky Exp $");
diff --git a/usr.sbin/bluetooth/btpand/tap.c b/usr.sbin/bluetooth/btpand/tap.c
index d9d9a3e90af1..011ae3989154 100644
--- a/usr.sbin/bluetooth/btpand/tap.c
+++ b/usr.sbin/bluetooth/btpand/tap.c
@@ -1,7 +1,7 @@
/* $NetBSD: tap.c,v 1.1 2008/08/17 13:20:57 plunky Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Iain Hibbert
* All rights reserved.
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
#include <sys/cdefs.h>
__RCSID("$NetBSD: tap.c,v 1.1 2008/08/17 13:20:57 plunky Exp $");
diff --git a/usr.sbin/bluetooth/hccontrol/Makefile b/usr.sbin/bluetooth/hccontrol/Makefile
index 9191b656ff02..b662bc9fbbc2 100644
--- a/usr.sbin/bluetooth/hccontrol/Makefile
+++ b/usr.sbin/bluetooth/hccontrol/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.7 2003/08/14 20:06:17 max Exp $
-# $FreeBSD$
PACKAGE= bluetooth
CONFS= bluetooth.device.conf
diff --git a/usr.sbin/bluetooth/hccontrol/Makefile.depend b/usr.sbin/bluetooth/hccontrol/Makefile.depend
index f556d37ea8e6..5d0531350f25 100644
--- a/usr.sbin/bluetooth/hccontrol/Makefile.depend
+++ b/usr.sbin/bluetooth/hccontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/bluetooth/hccontrol/adv_data.c b/usr.sbin/bluetooth/hccontrol/adv_data.c
index 8f11d99a397f..e8d91ff59151 100644
--- a/usr.sbin/bluetooth/hccontrol/adv_data.c
+++ b/usr.sbin/bluetooth/hccontrol/adv_data.c
@@ -1,7 +1,7 @@
/*-
* adv_data.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
* Copyright (c) 2020 Marc Veldman <marc@bumblingdork.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id$
- * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.sbin/bluetooth/hccontrol/bluetooth.device.conf b/usr.sbin/bluetooth/hccontrol/bluetooth.device.conf
index 330548f97bb5..c400a3bf2e50 100644
--- a/usr.sbin/bluetooth/hccontrol/bluetooth.device.conf
+++ b/usr.sbin/bluetooth/hccontrol/bluetooth.device.conf
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
# The authentication_enable parameter controls if the device requires to
# authenticate the remote device at connection setup. At connection setup,
@@ -62,8 +61,8 @@
#
# Possible values:
#
-# NO or 0 do not scan for inquiry requests;
-# YES or 1 scan for inquiry requests (default).
+# NO or 0 do not scan for inquiry requests (default);
+# YES or 1 scan for inquiry requests.
# discoverable="NO"
diff --git a/usr.sbin/bluetooth/hccontrol/hccontrol.8 b/usr.sbin/bluetooth/hccontrol/hccontrol.8
index 1d6e519f6acc..28143ecf34a3 100644
--- a/usr.sbin/bluetooth/hccontrol/hccontrol.8
+++ b/usr.sbin/bluetooth/hccontrol/hccontrol.8
@@ -23,7 +23,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: hccontrol.8,v 1.6 2003/08/06 21:26:38 max Exp $
-.\" $FreeBSD$
.\"
.Dd May 3, 2020
.Dt HCCONTROL 8
@@ -156,7 +155,7 @@ are:
.It Cm LE_Set_Scan_Enable
.It Cm LE_Read_Supported_States
.It Cm LE_Read_Buffer_Size
-.It Cm LE Scan
+.It Cm LE_Scan
.It Cm LE_Read_White_List_Size
.It Cm LE_Clear_White_List
.It Cm LE_Add_Device_To_White_List
diff --git a/usr.sbin/bluetooth/hccontrol/hccontrol.c b/usr.sbin/bluetooth/hccontrol/hccontrol.c
index 4fc78054fd7b..c1ce016e6246 100644
--- a/usr.sbin/bluetooth/hccontrol/hccontrol.c
+++ b/usr.sbin/bluetooth/hccontrol/hccontrol.c
@@ -1,7 +1,7 @@
/*-
* hccontrol.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: hccontrol.c,v 1.5 2003/09/05 00:38:24 max Exp $
- * $FreeBSD$
*/
#define L2CAP_SOCKET_CHECKED
diff --git a/usr.sbin/bluetooth/hccontrol/hccontrol.h b/usr.sbin/bluetooth/hccontrol/hccontrol.h
index 912bf26a04a5..9dd6345dd59f 100644
--- a/usr.sbin/bluetooth/hccontrol/hccontrol.h
+++ b/usr.sbin/bluetooth/hccontrol/hccontrol.h
@@ -1,7 +1,7 @@
/*-
* hccontrol.h
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: hccontrol.h,v 1.2 2003/05/19 17:29:29 max Exp $
- * $FreeBSD$
*/
#ifndef _HCCONTROL_H_
diff --git a/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c b/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c
index 6f912c2238ba..38bfcc321046 100644
--- a/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c
+++ b/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c
@@ -1,7 +1,7 @@
/*-
* host_controller_baseband.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: host_controller_baseband.c,v 1.4 2003/08/18 19:19:53 max Exp $
- * $FreeBSD$
*/
#define L2CAP_SOCKET_CHECKED
diff --git a/usr.sbin/bluetooth/hccontrol/info.c b/usr.sbin/bluetooth/hccontrol/info.c
index aa9ce17bc75b..b1b2aa36c593 100644
--- a/usr.sbin/bluetooth/hccontrol/info.c
+++ b/usr.sbin/bluetooth/hccontrol/info.c
@@ -1,7 +1,7 @@
/*-
* info.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: info.c,v 1.3 2003/08/18 19:19:54 max Exp $
- * $FreeBSD$
*/
#define L2CAP_SOCKET_CHECKED
diff --git a/usr.sbin/bluetooth/hccontrol/le.c b/usr.sbin/bluetooth/hccontrol/le.c
index ba8809213c06..6d5440643b45 100644
--- a/usr.sbin/bluetooth/hccontrol/le.c
+++ b/usr.sbin/bluetooth/hccontrol/le.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*
* $Id: hccontrol.c,v 1.5 2003/09/05 00:38:24 max Exp $
- * $FreeBSD$
*/
#include <sys/types.h>
@@ -1086,7 +1085,6 @@ static void handle_le_connection_event(ng_hci_event_pkt_t* e, bool verbose)
conn_event->master_clock_accuracy));
}
}
- return;
}
static int
@@ -1208,8 +1206,6 @@ static void handle_le_remote_features_event(ng_hci_event_pkt_t* e)
hci_le_features2str(feat_event->features,
buffer, sizeof(buffer)));
}
-
- return;
} /* handle_le_remote_features_event */
static int le_rand(int s, int argc, char *argv[])
@@ -1368,4 +1364,7 @@ struct hci_command le_commands[] = {
"Generate 64 bits of random data",
&le_rand
},
+ {
+ NULL,
+ }
};
diff --git a/usr.sbin/bluetooth/hccontrol/link_control.c b/usr.sbin/bluetooth/hccontrol/link_control.c
index edf47814a968..b43515aa0d5b 100644
--- a/usr.sbin/bluetooth/hccontrol/link_control.c
+++ b/usr.sbin/bluetooth/hccontrol/link_control.c
@@ -1,7 +1,7 @@
/*-
* link_control.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: link_control.c,v 1.4 2003/08/18 19:19:54 max Exp $
- * $FreeBSD$
*/
#define L2CAP_SOCKET_CHECKED
diff --git a/usr.sbin/bluetooth/hccontrol/link_policy.c b/usr.sbin/bluetooth/hccontrol/link_policy.c
index 52e02e3c2bf4..b99ef2196eb8 100644
--- a/usr.sbin/bluetooth/hccontrol/link_policy.c
+++ b/usr.sbin/bluetooth/hccontrol/link_policy.c
@@ -1,7 +1,7 @@
/*-
* link_policy.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: link_policy.c,v 1.3 2003/08/18 19:19:54 max Exp $
- * $FreeBSD$
*/
#define L2CAP_SOCKET_CHECKED
@@ -82,7 +81,7 @@ hci_role_discovery(int s, int argc, char **argv)
return (OK);
} /* hci_role_discovery */
-/* Send Swith Role to the unit */
+/* Send Switch Role to the unit */
static int
hci_switch_role(int s, int argc, char **argv)
{
diff --git a/usr.sbin/bluetooth/hccontrol/node.c b/usr.sbin/bluetooth/hccontrol/node.c
index 2b41171bbd16..b100900f527d 100644
--- a/usr.sbin/bluetooth/hccontrol/node.c
+++ b/usr.sbin/bluetooth/hccontrol/node.c
@@ -1,7 +1,7 @@
/*-
* node.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: node.c,v 1.6 2003/07/22 21:14:02 max Exp $
- * $FreeBSD$
*/
#include <sys/ioctl.h>
diff --git a/usr.sbin/bluetooth/hccontrol/send_recv.c b/usr.sbin/bluetooth/hccontrol/send_recv.c
index dd9a7aa5b570..4f9bb05aec48 100644
--- a/usr.sbin/bluetooth/hccontrol/send_recv.c
+++ b/usr.sbin/bluetooth/hccontrol/send_recv.c
@@ -1,7 +1,7 @@
/*-
* send_recv.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: send_recv.c,v 1.2 2003/05/21 22:40:30 max Exp $
- * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.sbin/bluetooth/hccontrol/status.c b/usr.sbin/bluetooth/hccontrol/status.c
index fe5dfb7360f0..9306c10fec85 100644
--- a/usr.sbin/bluetooth/hccontrol/status.c
+++ b/usr.sbin/bluetooth/hccontrol/status.c
@@ -1,7 +1,7 @@
/*-
* status.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: status.c,v 1.2 2003/05/21 22:40:30 max Exp $
- * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.sbin/bluetooth/hccontrol/util.c b/usr.sbin/bluetooth/hccontrol/util.c
index 10d781936564..029ced6e28fa 100644
--- a/usr.sbin/bluetooth/hccontrol/util.c
+++ b/usr.sbin/bluetooth/hccontrol/util.c
@@ -1,7 +1,7 @@
/*-
* util.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: util.c,v 1.2 2003/05/19 17:29:29 max Exp $
- * $FreeBSD$
*/
#include <sys/param.h>
@@ -616,7 +615,7 @@ hci_manufacturer2str(int m)
/* 0419 */ "EROAD",
/* 0420 */ "Mine Safety Appliances",
/* 0421 */ "Icon Health and Fitness",
- /* 0422 */ "Wille Engineering (formely as Asandoo GmbH)",
+ /* 0422 */ "Wille Engineering (formerly as Asandoo GmbH)",
/* 0423 */ "ENERGOUS CORPORATION",
/* 0424 */ "Taobao",
/* 0425 */ "Canon Inc.",
@@ -1591,7 +1590,7 @@ hci_manufacturer2str(int m)
/* 1394 */ "AntTail.com",
/* 1395 */ "Lighting Science Group Corp.",
/* 1396 */ "AFFORDABLE ELECTRONICS INC",
- /* 1397 */ "Integral Memroy Plc",
+ /* 1397 */ "Integral Memory Plc",
/* 1398 */ "Globalstar, Inc.",
/* 1399 */ "True Wearables, Inc.",
/* 1400 */ "Wellington Drive Technologies Ltd",
diff --git a/usr.sbin/bluetooth/hcsecd/Makefile b/usr.sbin/bluetooth/hcsecd/Makefile
index b571162a1907..b32e3c670aa1 100644
--- a/usr.sbin/bluetooth/hcsecd/Makefile
+++ b/usr.sbin/bluetooth/hcsecd/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.8 2003/08/14 20:06:20 max Exp $
-# $FreeBSD$
PACKAGE= bluetooth
CONFS= hcsecd.conf
diff --git a/usr.sbin/bluetooth/hcsecd/Makefile.depend b/usr.sbin/bluetooth/hcsecd/Makefile.depend
index 0ef8a0651b9f..5cf06f846a48 100644
--- a/usr.sbin/bluetooth/hcsecd/Makefile.depend
+++ b/usr.sbin/bluetooth/hcsecd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/bluetooth/hcsecd/hcsecd.8 b/usr.sbin/bluetooth/hcsecd/hcsecd.8
index 2550fa1a143e..9f8d3c7bf971 100644
--- a/usr.sbin/bluetooth/hcsecd/hcsecd.8
+++ b/usr.sbin/bluetooth/hcsecd/hcsecd.8
@@ -23,7 +23,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: hcsecd.8,v 1.8 2003/09/08 18:54:20 max Exp $
-.\" $FreeBSD$
.\"
.Dd November 16, 2002
.Dt HCSECD 8
diff --git a/usr.sbin/bluetooth/hcsecd/hcsecd.c b/usr.sbin/bluetooth/hcsecd/hcsecd.c
index 160b77e1b040..824b0ba6971b 100644
--- a/usr.sbin/bluetooth/hcsecd/hcsecd.c
+++ b/usr.sbin/bluetooth/hcsecd/hcsecd.c
@@ -1,7 +1,7 @@
/*-
* hcsecd.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: hcsecd.c,v 1.6 2003/08/18 19:19:55 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/hcsecd/hcsecd.conf b/usr.sbin/bluetooth/hcsecd/hcsecd.conf
index e6b95998f33b..36ec516ae019 100644
--- a/usr.sbin/bluetooth/hcsecd/hcsecd.conf
+++ b/usr.sbin/bluetooth/hcsecd/hcsecd.conf
@@ -1,5 +1,4 @@
# $Id: hcsecd.conf,v 1.1 2003/05/26 22:50:47 max Exp $
-# $FreeBSD$
#
# HCI security daemon configuration file
#
diff --git a/usr.sbin/bluetooth/hcsecd/hcsecd.conf.5 b/usr.sbin/bluetooth/hcsecd/hcsecd.conf.5
index a6342aa67cf3..306aea6cbb5b 100644
--- a/usr.sbin/bluetooth/hcsecd/hcsecd.conf.5
+++ b/usr.sbin/bluetooth/hcsecd/hcsecd.conf.5
@@ -23,7 +23,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: hcsecd.conf.5,v 1.1 2003/05/26 22:49:23 max Exp $
-.\" $FreeBSD$
.\"
.Dd May 26, 2003
.Dt HCSECD.CONF 5
diff --git a/usr.sbin/bluetooth/hcsecd/hcsecd.h b/usr.sbin/bluetooth/hcsecd/hcsecd.h
index 1500c008477f..e13139e7cf1a 100644
--- a/usr.sbin/bluetooth/hcsecd/hcsecd.h
+++ b/usr.sbin/bluetooth/hcsecd/hcsecd.h
@@ -1,7 +1,7 @@
/*-
* hcsecd.h
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: hcsecd.h,v 1.3 2003/09/08 18:54:21 max Exp $
- * $FreeBSD$
*/
#ifndef _HCSECD_H_
diff --git a/usr.sbin/bluetooth/hcsecd/lexer.l b/usr.sbin/bluetooth/hcsecd/lexer.l
index d2fecc4fb6ec..71bfd7d5c7b1 100644
--- a/usr.sbin/bluetooth/hcsecd/lexer.l
+++ b/usr.sbin/bluetooth/hcsecd/lexer.l
@@ -2,7 +2,7 @@
/*-
* lexer.l
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*
* $Id: lexer.l,v 1.1 2002/11/24 20:22:39 max Exp $
- * $FreeBSD$
*/
#include <string.h>
diff --git a/usr.sbin/bluetooth/hcsecd/parser.y b/usr.sbin/bluetooth/hcsecd/parser.y
index 3ff9bac6e0f9..bf8d33f565bc 100644
--- a/usr.sbin/bluetooth/hcsecd/parser.y
+++ b/usr.sbin/bluetooth/hcsecd/parser.y
@@ -2,7 +2,7 @@
/*-
* parser.y
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*
* $Id: parser.y,v 1.5 2003/06/07 21:22:30 max Exp $
- * $FreeBSD$
*/
#include <sys/fcntl.h>
diff --git a/usr.sbin/bluetooth/iwmbtfw/Makefile b/usr.sbin/bluetooth/iwmbtfw/Makefile
index 03b608edc63f..0a81d7fdbc32 100644
--- a/usr.sbin/bluetooth/iwmbtfw/Makefile
+++ b/usr.sbin/bluetooth/iwmbtfw/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= bluetooth
CONFS= iwmbtfw.conf
diff --git a/usr.sbin/zic/zdump/Makefile.depend b/usr.sbin/bluetooth/iwmbtfw/Makefile.depend
index 6cfaab1c3644..34fbfadfcfb6 100644
--- a/usr.sbin/zic/zdump/Makefile.depend
+++ b/usr.sbin/bluetooth/iwmbtfw/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/libusb \
.include <dirdeps.mk>
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbt_dbg.h b/usr.sbin/bluetooth/iwmbtfw/iwmbt_dbg.h
index 2a93b306ce5d..9cfded6f33cf 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbt_dbg.h
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbt_dbg.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Adrian Chadd <adrian@freebsd.org>
* Copyright (c) 2019 Vladimir Kondratyev <wulf@FreeBSD.org>
@@ -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 __IWMBT_DEBUG_H__
#define __IWMBT_DEBUG_H__
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.c b/usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.c
index 963d5d5d9008..6816b152912d 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.c
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Adrian Chadd <adrian@freebsd.org>
* Copyright (c) 2019 Vladimir Kondratyev <wulf@FreeBSD.org>
@@ -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 <sys/types.h>
@@ -50,7 +48,6 @@ iwmbt_fw_read(struct iwmbt_firmware *fw, const char *fwname)
struct stat sb;
unsigned char *buf;
ssize_t r;
- int i;
fd = open(fwname, O_RDONLY);
if (fd < 0) {
@@ -71,7 +68,6 @@ iwmbt_fw_read(struct iwmbt_firmware *fw, const char *fwname)
return (0);
}
- i = 0;
/* XXX handle partial reads */
r = read(fd, buf, sb.st_size);
if (r < 0) {
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.h b/usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.h
index 8291fed427f2..f737c1c0c2c8 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.h
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Adrian Chadd <adrian@freebsd.org>
* Copyright (c) 2019 Vladimir Kondratyev <wulf@FreeBSD.org>
@@ -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 __IWMBT_FW_H__
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c b/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c
index 218fd28b74a2..ea732c9925ee 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Vladimir Kondratyev <wulf@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$
*/
#include <sys/param.h>
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.h b/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.h
index 5bc1d15181cd..eafb2c3f31d8 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.h
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Vladimir Kondratyev <wulf@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 __IWMBT_HW_H__
#define __IWMBT_HW_H__
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8 b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
index 10e68040e0e4..368a3865a0eb 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 3, 2021
.Dt IWMBTFW 8
.Os
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.conf b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.conf
index 6b417089c68b..ef8d5263383b 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.conf
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Download Intel Wireless 8260/8265 bluetooth adaptor firmware
diff --git a/usr.sbin/bluetooth/iwmbtfw/main.c b/usr.sbin/bluetooth/iwmbtfw/main.c
index 202894740805..9ef31b906b77 100644
--- a/usr.sbin/bluetooth/iwmbtfw/main.c
+++ b/usr.sbin/bluetooth/iwmbtfw/main.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Adrian Chadd <adrian@freebsd.org>
* Copyright (c) 2019 Vladimir Kondratyev <wulf@FreeBSD.org>
@@ -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 <sys/param.h>
@@ -572,7 +570,7 @@ shutdown:
libusb_exit(ctx);
if (retcode == 0)
- iwmbt_info("Firmware download is succesful!");
+ iwmbt_info("Firmware download is successful!");
else
iwmbt_err("Firmware download failed!");
diff --git a/usr.sbin/bluetooth/l2control/Makefile b/usr.sbin/bluetooth/l2control/Makefile
index 8dab32051c04..e81bed589420 100644
--- a/usr.sbin/bluetooth/l2control/Makefile
+++ b/usr.sbin/bluetooth/l2control/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.7 2003/08/14 20:06:22 max Exp $
-# $FreeBSD$
PACKAGE= bluetooth
PROG= l2control
diff --git a/usr.sbin/bluetooth/l2control/Makefile.depend b/usr.sbin/bluetooth/l2control/Makefile.depend
index f556d37ea8e6..5d0531350f25 100644
--- a/usr.sbin/bluetooth/l2control/Makefile.depend
+++ b/usr.sbin/bluetooth/l2control/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/bluetooth/l2control/l2cap.c b/usr.sbin/bluetooth/l2control/l2cap.c
index cc92c77ec5dc..0f410d3c6a85 100644
--- a/usr.sbin/bluetooth/l2control/l2cap.c
+++ b/usr.sbin/bluetooth/l2control/l2cap.c
@@ -1,7 +1,7 @@
/*-
* l2cap.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: l2cap.c,v 1.5 2003/05/16 19:52:37 max Exp $
- * $FreeBSD$
*/
#include <sys/ioctl.h>
diff --git a/usr.sbin/bluetooth/l2control/l2control.8 b/usr.sbin/bluetooth/l2control/l2control.8
index 5974167439d1..478a97f89d99 100644
--- a/usr.sbin/bluetooth/l2control/l2control.8
+++ b/usr.sbin/bluetooth/l2control/l2control.8
@@ -23,7 +23,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: l2control.8,v 1.5 2003/05/21 00:53:00 max Exp $
-.\" $FreeBSD$
.\"
.Dd April 9, 2011
.Dt L2CONTROL 8
diff --git a/usr.sbin/bluetooth/l2control/l2control.c b/usr.sbin/bluetooth/l2control/l2control.c
index a8dceb16a6d3..7312371345ec 100644
--- a/usr.sbin/bluetooth/l2control/l2control.c
+++ b/usr.sbin/bluetooth/l2control/l2control.c
@@ -1,7 +1,7 @@
/*-
* l2control.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: l2control.c,v 1.6 2003/09/05 00:38:25 max Exp $
- * $FreeBSD$
*/
#include <assert.h>
@@ -147,7 +146,7 @@ do_l2cap_command(bdaddr_p bdaddr, int argc, char **argv)
e = 0x0ffff;
if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &e, sizeof(e)) < 0)
- err(3, "Coult not setsockopt(RCVBUF, %d)", e);
+ err(3, "Could not setsockopt(RCVBUF, %d)", e);
e = (c->handler)(s, -- argc, ++ argv);
diff --git a/usr.sbin/bluetooth/l2control/l2control.h b/usr.sbin/bluetooth/l2control/l2control.h
index 00eeef505328..e18691d84ca3 100644
--- a/usr.sbin/bluetooth/l2control/l2control.h
+++ b/usr.sbin/bluetooth/l2control/l2control.h
@@ -1,7 +1,7 @@
/*-
* l2control.h
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: l2control.h,v 1.1 2002/11/24 20:22:41 max Exp $
- * $FreeBSD$
*/
#ifndef _L2CONTROL_H_
diff --git a/usr.sbin/bluetooth/l2ping/Makefile b/usr.sbin/bluetooth/l2ping/Makefile
index 9e3e0bd50a47..70b8d19bc609 100644
--- a/usr.sbin/bluetooth/l2ping/Makefile
+++ b/usr.sbin/bluetooth/l2ping/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.6 2003/08/14 20:06:24 max Exp $
-# $FreeBSD$
PACKAGE= bluetooth
PROG= l2ping
diff --git a/usr.sbin/bluetooth/l2ping/Makefile.depend b/usr.sbin/bluetooth/l2ping/Makefile.depend
index 3dfd9699a934..a1fc9c8c3375 100644
--- a/usr.sbin/bluetooth/l2ping/Makefile.depend
+++ b/usr.sbin/bluetooth/l2ping/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/bluetooth/l2ping/l2ping.8 b/usr.sbin/bluetooth/l2ping/l2ping.8
index b6233e8407da..07ba6547a424 100644
--- a/usr.sbin/bluetooth/l2ping/l2ping.8
+++ b/usr.sbin/bluetooth/l2ping/l2ping.8
@@ -23,7 +23,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: l2ping.8,v 1.3 2003/05/21 01:00:19 max Exp $
-.\" $FreeBSD$
.\"
.Dd March 29, 2011
.Dt L2PING 8
diff --git a/usr.sbin/bluetooth/l2ping/l2ping.c b/usr.sbin/bluetooth/l2ping/l2ping.c
index 49e900588d99..25ddf06e8532 100644
--- a/usr.sbin/bluetooth/l2ping/l2ping.c
+++ b/usr.sbin/bluetooth/l2ping/l2ping.c
@@ -1,7 +1,7 @@
/*-
* l2ping.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: l2ping.c,v 1.5 2003/05/16 19:54:40 max Exp $
- * $FreeBSD$
*/
#include <sys/ioctl.h>
diff --git a/usr.sbin/bluetooth/rfcomm_pppd/Makefile b/usr.sbin/bluetooth/rfcomm_pppd/Makefile
index 8974f8a3daef..ea3f211ae7dc 100644
--- a/usr.sbin/bluetooth/rfcomm_pppd/Makefile
+++ b/usr.sbin/bluetooth/rfcomm_pppd/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.7 2003/09/07 18:32:11 max Exp $
-# $FreeBSD$
.PATH: ${SRCTOP}/usr.bin/bluetooth/rfcomm_sppd
diff --git a/usr.sbin/bluetooth/rfcomm_pppd/Makefile.depend b/usr.sbin/bluetooth/rfcomm_pppd/Makefile.depend
index 65af16d12ab3..ccc9ef8b7fa3 100644
--- a/usr.sbin/bluetooth/rfcomm_pppd/Makefile.depend
+++ b/usr.sbin/bluetooth/rfcomm_pppd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.8 b/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.8
index 46e48ade8548..804070c7e31b 100644
--- a/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.8
+++ b/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.8
@@ -23,7 +23,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: rfcomm_pppd.8,v 1.7 2003/09/07 18:32:11 max Exp $
-.\" $FreeBSD$
.\"
.Dd February 4, 2003
.Dt RFCOMM_PPPD 8
diff --git a/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c b/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c
index b1077727b503..439b4157f59e 100644
--- a/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c
+++ b/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2008 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: rfcomm_pppd.c,v 1.5 2003/09/07 18:32:11 max Exp $
- * $FreeBSD$
*/
#define L2CAP_SOCKET_CHECKED
#include <bluetooth.h>
diff --git a/usr.sbin/bluetooth/sdpcontrol/Makefile b/usr.sbin/bluetooth/sdpcontrol/Makefile
index 8250cd0e9127..7f1fe3f05b43 100644
--- a/usr.sbin/bluetooth/sdpcontrol/Makefile
+++ b/usr.sbin/bluetooth/sdpcontrol/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.1 2003/09/08 02:27:27 max Exp $
-# $FreeBSD$
PACKAGE= bluetooth
PROG= sdpcontrol
diff --git a/usr.sbin/bluetooth/sdpcontrol/Makefile.depend b/usr.sbin/bluetooth/sdpcontrol/Makefile.depend
index 65af16d12ab3..ccc9ef8b7fa3 100644
--- a/usr.sbin/bluetooth/sdpcontrol/Makefile.depend
+++ b/usr.sbin/bluetooth/sdpcontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.8 b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.8
index 82aafad5d6d3..1a7e4fe574fb 100644
--- a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.8
+++ b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.8
@@ -23,7 +23,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: sdpcontrol.8,v 1.1 2003/09/08 02:27:27 max Exp $
-.\" $FreeBSD$
.\"
.Dd February 7, 2015
.Dt SDPCONTROL 8
diff --git a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c
index 8a3c4d33cc41..890e6e3cfdba 100644
--- a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c
+++ b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c
@@ -1,7 +1,7 @@
/*-
* sdpcontrol.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: sdpcontrol.c,v 1.1 2003/09/08 02:27:27 max Exp $
- * $FreeBSD$
*/
#include <assert.h>
diff --git a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.h b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.h
index ec0c829a89ea..818005ee34ce 100644
--- a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.h
+++ b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.h
@@ -1,7 +1,7 @@
/*-
* sdpcontrol.h
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: sdpcontrol.h,v 1.1 2003/09/08 02:27:27 max Exp $
- * $FreeBSD$
*/
#ifndef __SDPCONTROL_H__
diff --git a/usr.sbin/bluetooth/sdpcontrol/search.c b/usr.sbin/bluetooth/sdpcontrol/search.c
index 1d143e0bc818..94c34828a949 100644
--- a/usr.sbin/bluetooth/sdpcontrol/search.c
+++ b/usr.sbin/bluetooth/sdpcontrol/search.c
@@ -1,7 +1,7 @@
/*-
* search.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: search.c,v 1.2 2003/09/08 17:35:15 max Exp $
- * $FreeBSD$
*/
#include <netinet/in.h>
diff --git a/usr.sbin/bluetooth/sdpd/Makefile b/usr.sbin/bluetooth/sdpd/Makefile
index 65c1df35d12c..aabb16d4c3ca 100644
--- a/usr.sbin/bluetooth/sdpd/Makefile
+++ b/usr.sbin/bluetooth/sdpd/Makefile
@@ -1,5 +1,4 @@
# $Id: Makefile,v 1.1 2004/01/20 21:27:55 max Exp $
-# $FreeBSD$
PACKAGE= bluetooth
PROG= sdpd
diff --git a/usr.sbin/bluetooth/sdpd/Makefile.depend b/usr.sbin/bluetooth/sdpd/Makefile.depend
index feddf3a700bc..de7bb33fd2e5 100644
--- a/usr.sbin/bluetooth/sdpd/Makefile.depend
+++ b/usr.sbin/bluetooth/sdpd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/bluetooth/sdpd/audio_sink.c b/usr.sbin/bluetooth/sdpd/audio_sink.c
index 0ffdfa88146b..3b631376d02a 100644
--- a/usr.sbin/bluetooth/sdpd/audio_sink.c
+++ b/usr.sbin/bluetooth/sdpd/audio_sink.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Hans Petter Selasky <hselasky@freebsd.org>
* 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 <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/audio_source.c b/usr.sbin/bluetooth/sdpd/audio_source.c
index 1d58a323f8cb..be827527732d 100644
--- a/usr.sbin/bluetooth/sdpd/audio_source.c
+++ b/usr.sbin/bluetooth/sdpd/audio_source.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Hans Petter Selasky <hselasky@freebsd.org>
* 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 <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/bgd.c b/usr.sbin/bluetooth/sdpd/bgd.c
index 75306ce49c6d..628389efc8e1 100644
--- a/usr.sbin/bluetooth/sdpd/bgd.c
+++ b/usr.sbin/bluetooth/sdpd/bgd.c
@@ -1,7 +1,7 @@
/*-
* bgd.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: bgd.c,v 1.4 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#define L2CAP_SOCKET_CHECKED
#include <bluetooth.h>
diff --git a/usr.sbin/bluetooth/sdpd/dun.c b/usr.sbin/bluetooth/sdpd/dun.c
index 8c21604a05aa..3f4159926275 100644
--- a/usr.sbin/bluetooth/sdpd/dun.c
+++ b/usr.sbin/bluetooth/sdpd/dun.c
@@ -1,7 +1,7 @@
/*-
* dun.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: dun.c,v 1.5 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/ftrn.c b/usr.sbin/bluetooth/sdpd/ftrn.c
index 23cfab4eceb5..32b4912f25ed 100644
--- a/usr.sbin/bluetooth/sdpd/ftrn.c
+++ b/usr.sbin/bluetooth/sdpd/ftrn.c
@@ -1,7 +1,7 @@
/*-
* ftrn.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: ftrn.c,v 1.5 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/gn.c b/usr.sbin/bluetooth/sdpd/gn.c
index 894701b81481..17879c4fb193 100644
--- a/usr.sbin/bluetooth/sdpd/gn.c
+++ b/usr.sbin/bluetooth/sdpd/gn.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: gn.c,v 1.1 2008/03/11 00:02:42 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/irmc.c b/usr.sbin/bluetooth/sdpd/irmc.c
index ee91335dbe38..90155e065492 100644
--- a/usr.sbin/bluetooth/sdpd/irmc.c
+++ b/usr.sbin/bluetooth/sdpd/irmc.c
@@ -1,7 +1,7 @@
/*-
* irmc.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: irmc.c,v 1.6 2004/01/13 19:31:54 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/irmc_command.c b/usr.sbin/bluetooth/sdpd/irmc_command.c
index 3b7e38bdf7f9..e8d0723fa8a4 100644
--- a/usr.sbin/bluetooth/sdpd/irmc_command.c
+++ b/usr.sbin/bluetooth/sdpd/irmc_command.c
@@ -1,7 +1,7 @@
/*-
* irmc_command_command_command.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: irmc_command.c,v 1.5 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/lan.c b/usr.sbin/bluetooth/sdpd/lan.c
index 86ef71f64f2e..66a71754ef48 100644
--- a/usr.sbin/bluetooth/sdpd/lan.c
+++ b/usr.sbin/bluetooth/sdpd/lan.c
@@ -1,7 +1,7 @@
/*-
* lan.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: lan.c,v 1.5 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <arpa/inet.h>
diff --git a/usr.sbin/bluetooth/sdpd/log.c b/usr.sbin/bluetooth/sdpd/log.c
index 98d3526e9121..f7d4fa350c65 100644
--- a/usr.sbin/bluetooth/sdpd/log.c
+++ b/usr.sbin/bluetooth/sdpd/log.c
@@ -1,7 +1,7 @@
/*-
* log.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: log.c,v 1.1 2004/01/07 23:15:00 max Exp $
- * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.sbin/bluetooth/sdpd/log.h b/usr.sbin/bluetooth/sdpd/log.h
index b2c780e5e83e..e00ed4d8c838 100644
--- a/usr.sbin/bluetooth/sdpd/log.h
+++ b/usr.sbin/bluetooth/sdpd/log.h
@@ -1,7 +1,7 @@
/*-
* log.h
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: log.h,v 1.1 2004/01/07 23:15:00 max Exp $
- * $FreeBSD$
*/
#ifndef _LOG_H_
diff --git a/usr.sbin/bluetooth/sdpd/main.c b/usr.sbin/bluetooth/sdpd/main.c
index a041795e9846..cc21b314f486 100644
--- a/usr.sbin/bluetooth/sdpd/main.c
+++ b/usr.sbin/bluetooth/sdpd/main.c
@@ -1,7 +1,7 @@
/*-
* main.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: main.c,v 1.8 2004/01/13 19:31:54 max Exp $
- * $FreeBSD$
*/
#include <sys/select.h>
diff --git a/usr.sbin/bluetooth/sdpd/nap.c b/usr.sbin/bluetooth/sdpd/nap.c
index 16054af657fe..229600b9c950 100644
--- a/usr.sbin/bluetooth/sdpd/nap.c
+++ b/usr.sbin/bluetooth/sdpd/nap.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: nap.c,v 1.1 2008/03/11 00:02:42 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/opush.c b/usr.sbin/bluetooth/sdpd/opush.c
index 91e08af30d4d..6f2464191292 100644
--- a/usr.sbin/bluetooth/sdpd/opush.c
+++ b/usr.sbin/bluetooth/sdpd/opush.c
@@ -1,7 +1,7 @@
/*-
* opush.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: opush.c,v 1.6 2004/01/13 19:31:54 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/panu.c b/usr.sbin/bluetooth/sdpd/panu.c
index 353c28709e03..bba1dbd45d1d 100644
--- a/usr.sbin/bluetooth/sdpd/panu.c
+++ b/usr.sbin/bluetooth/sdpd/panu.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: panu.c,v 1.1 2008/03/11 00:02:42 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/profile.c b/usr.sbin/bluetooth/sdpd/profile.c
index cef9a03ceea6..3c6ada6871c7 100644
--- a/usr.sbin/bluetooth/sdpd/profile.c
+++ b/usr.sbin/bluetooth/sdpd/profile.c
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: profile.c,v 1.6 2004/01/13 19:31:54 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/profile.h b/usr.sbin/bluetooth/sdpd/profile.h
index 82e0e37f853d..7184c0fd742e 100644
--- a/usr.sbin/bluetooth/sdpd/profile.h
+++ b/usr.sbin/bluetooth/sdpd/profile.h
@@ -3,7 +3,7 @@
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*
* $Id: profile.h,v 1.6 2004/01/13 19:31:54 max Exp $
- * $FreeBSD$
*/
#ifndef _PROFILE_H_
diff --git a/usr.sbin/bluetooth/sdpd/provider.c b/usr.sbin/bluetooth/sdpd/provider.c
index 532cdac8cd9f..7ac800a85006 100644
--- a/usr.sbin/bluetooth/sdpd/provider.c
+++ b/usr.sbin/bluetooth/sdpd/provider.c
@@ -1,7 +1,7 @@
/*-
* provider.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: provider.c,v 1.5 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/provider.h b/usr.sbin/bluetooth/sdpd/provider.h
index 6f6bed3e820a..b4f3bb0a46d0 100644
--- a/usr.sbin/bluetooth/sdpd/provider.h
+++ b/usr.sbin/bluetooth/sdpd/provider.h
@@ -1,7 +1,7 @@
/*-
* provider.h
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: provider.h,v 1.6 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#ifndef _PROVIDER_H_
diff --git a/usr.sbin/bluetooth/sdpd/sar.c b/usr.sbin/bluetooth/sdpd/sar.c
index ce911911b503..0470109ebc07 100644
--- a/usr.sbin/bluetooth/sdpd/sar.c
+++ b/usr.sbin/bluetooth/sdpd/sar.c
@@ -1,7 +1,7 @@
/*-
* sar.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: sar.c,v 1.2 2004/01/08 23:46:51 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/scr.c b/usr.sbin/bluetooth/sdpd/scr.c
index b3442915341f..a5bced947f8e 100644
--- a/usr.sbin/bluetooth/sdpd/scr.c
+++ b/usr.sbin/bluetooth/sdpd/scr.c
@@ -1,7 +1,7 @@
/*-
* scr.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: scr.c,v 1.1 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/sd.c b/usr.sbin/bluetooth/sdpd/sd.c
index e69e3366fa4c..cd4f7fa3364b 100644
--- a/usr.sbin/bluetooth/sdpd/sd.c
+++ b/usr.sbin/bluetooth/sdpd/sd.c
@@ -1,7 +1,7 @@
/*-
* sd.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: sd.c,v 1.4 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/sdpd.8 b/usr.sbin/bluetooth/sdpd/sdpd.8
index 17040663a7ac..b5915f729e46 100644
--- a/usr.sbin/bluetooth/sdpd/sdpd.8
+++ b/usr.sbin/bluetooth/sdpd/sdpd.8
@@ -23,7 +23,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: sdpd.8,v 1.1 2004/01/13 19:31:54 max Exp $
-.\" $FreeBSD$
.\"
.Dd January 13, 2004
.Dt SDPD 8
diff --git a/usr.sbin/bluetooth/sdpd/server.c b/usr.sbin/bluetooth/sdpd/server.c
index 6910807953f5..ab398cd9339f 100644
--- a/usr.sbin/bluetooth/sdpd/server.c
+++ b/usr.sbin/bluetooth/sdpd/server.c
@@ -1,7 +1,7 @@
/*-
* server.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: server.c,v 1.6 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <sys/param.h>
diff --git a/usr.sbin/bluetooth/sdpd/server.h b/usr.sbin/bluetooth/sdpd/server.h
index 01629e89a789..9a1cb86eb3da 100644
--- a/usr.sbin/bluetooth/sdpd/server.h
+++ b/usr.sbin/bluetooth/sdpd/server.h
@@ -1,7 +1,7 @@
/*-
* server.h
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: server.h,v 1.5 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#ifndef _SERVER_H_
diff --git a/usr.sbin/bluetooth/sdpd/sp.c b/usr.sbin/bluetooth/sdpd/sp.c
index a909cd181ed1..3c79dd93965d 100644
--- a/usr.sbin/bluetooth/sdpd/sp.c
+++ b/usr.sbin/bluetooth/sdpd/sp.c
@@ -1,7 +1,7 @@
/*-
* sp.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: sp.c,v 1.5 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/srr.c b/usr.sbin/bluetooth/sdpd/srr.c
index 4f031f5933b1..8e887a4841de 100644
--- a/usr.sbin/bluetooth/sdpd/srr.c
+++ b/usr.sbin/bluetooth/sdpd/srr.c
@@ -1,7 +1,7 @@
/*-
* srr.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: srr.c,v 1.1 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/ssar.c b/usr.sbin/bluetooth/sdpd/ssar.c
index 68cfa2facd21..fad498c2b34a 100644
--- a/usr.sbin/bluetooth/sdpd/ssar.c
+++ b/usr.sbin/bluetooth/sdpd/ssar.c
@@ -1,7 +1,7 @@
/*-
* ssar.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: ssar.c,v 1.4 2004/01/12 22:54:31 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/ssr.c b/usr.sbin/bluetooth/sdpd/ssr.c
index 939283dbb809..c6b3a1f65fe1 100644
--- a/usr.sbin/bluetooth/sdpd/ssr.c
+++ b/usr.sbin/bluetooth/sdpd/ssr.c
@@ -1,7 +1,7 @@
/*-
* ssr.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: ssr.c,v 1.5 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/sur.c b/usr.sbin/bluetooth/sdpd/sur.c
index ca561f693e1c..43581be0bbf1 100644
--- a/usr.sbin/bluetooth/sdpd/sur.c
+++ b/usr.sbin/bluetooth/sdpd/sur.c
@@ -1,7 +1,7 @@
/*-
* sur.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: sur.c,v 1.1 2004/01/13 01:54:39 max Exp $
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bluetooth/sdpd/uuid-private.h b/usr.sbin/bluetooth/sdpd/uuid-private.h
index 7f3d299e8dbf..8a3f9bb1c62b 100644
--- a/usr.sbin/bluetooth/sdpd/uuid-private.h
+++ b/usr.sbin/bluetooth/sdpd/uuid-private.h
@@ -1,7 +1,7 @@
/*-
* uuid-private.h
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: uuid-private.h,v 1.1 2004/12/09 18:20:26 max Exp $
- * $FreeBSD$
*/
#ifndef _UUID_PRIVATE_H_
diff --git a/usr.sbin/bluetooth/sdpd/uuid.c b/usr.sbin/bluetooth/sdpd/uuid.c
index 3d41ea3e15b3..90a6d5b17322 100644
--- a/usr.sbin/bluetooth/sdpd/uuid.c
+++ b/usr.sbin/bluetooth/sdpd/uuid.c
@@ -1,7 +1,7 @@
/*-
* uuid.c
*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*
* $Id: uuid.c,v 1.1 2004/12/09 18:20:26 max Exp $
- * $FreeBSD$
*/
#define L2CAP_SOCKET_CHECKED
#include <bluetooth.h>
diff --git a/usr.sbin/boot0cfg/Makefile b/usr.sbin/boot0cfg/Makefile
index d41945a655a9..3fa3344aeb0e 100644
--- a/usr.sbin/boot0cfg/Makefile
+++ b/usr.sbin/boot0cfg/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= boot0cfg
MAN= boot0cfg.8
diff --git a/usr.sbin/boot0cfg/Makefile.depend b/usr.sbin/boot0cfg/Makefile.depend
index 0220673c9076..0dd05cace3c0 100644
--- a/usr.sbin/boot0cfg/Makefile.depend
+++ b/usr.sbin/boot0cfg/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/usr.sbin/boot0cfg/boot0cfg.8 b/usr.sbin/boot0cfg/boot0cfg.8
index bf0d35d489a6..d2e01ada3552 100644
--- a/usr.sbin/boot0cfg/boot0cfg.8
+++ b/usr.sbin/boot0cfg/boot0cfg.8
@@ -22,8 +22,6 @@
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 1, 2013
.Dt BOOT0CFG 8
.Os
diff --git a/usr.sbin/boot0cfg/boot0cfg.c b/usr.sbin/boot0cfg/boot0cfg.c
index 16bc46b5ec12..2a919f0b2f2e 100644
--- a/usr.sbin/boot0cfg/boot0cfg.c
+++ b/usr.sbin/boot0cfg/boot0cfg.c
@@ -1,5 +1,5 @@
/*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Luigi Rizzo
* Copyright (c) 1999 Robert Nordier
@@ -27,9 +27,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/disklabel.h>
#include <sys/diskmbr.h>
@@ -107,7 +104,7 @@ static int boot0bs(const u_int8_t *);
static void stropt(const char *, int *, int *);
static int argtoi(const char *, int, int, int);
static int set_bell(u_int8_t *, int, int);
-static void usage(void);
+static void usage(void) __dead2;
static unsigned vol_id[5]; /* 4 plus 1 for flag */
diff --git a/usr.sbin/bootparamd/Makefile b/usr.sbin/bootparamd/Makefile
index c4e3361ecfab..c4f61985a209 100644
--- a/usr.sbin/bootparamd/Makefile
+++ b/usr.sbin/bootparamd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= bootparamd callbootd
diff --git a/usr.sbin/bootparamd/Makefile.inc b/usr.sbin/bootparamd/Makefile.inc
index de7ed1c2f55c..e5b8262ffd7d 100644
--- a/usr.sbin/bootparamd/Makefile.inc
+++ b/usr.sbin/bootparamd/Makefile.inc
@@ -1,5 +1,3 @@
-# @(#)Makefile.inc 5.1 (Berkeley) 5/11/90
-# $FreeBSD$
BINDIR?= /usr/sbin
diff --git a/usr.sbin/bootparamd/bootparamd/Makefile b/usr.sbin/bootparamd/bootparamd/Makefile
index 9bdb70fb1cce..ca1b26b62bc6 100644
--- a/usr.sbin/bootparamd/bootparamd/Makefile
+++ b/usr.sbin/bootparamd/bootparamd/Makefile
@@ -1,5 +1,3 @@
-# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/bootparamd/bootparamd/Makefile.depend b/usr.sbin/bootparamd/bootparamd/Makefile.depend
index faed4b4cc2aa..732a025c9552 100644
--- a/usr.sbin/bootparamd/bootparamd/Makefile.depend
+++ b/usr.sbin/bootparamd/bootparamd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
diff --git a/usr.sbin/bootparamd/bootparamd/README b/usr.sbin/bootparamd/bootparamd/README
index c49b990a14b7..8428cf8634be 100644
--- a/usr.sbin/bootparamd/bootparamd/README
+++ b/usr.sbin/bootparamd/bootparamd/README
@@ -1,4 +1,3 @@
-$FreeBSD$
This directory contains a version of the rpc.bootparamd, which have been
written using the Sun's RPC protocol for bootparamd. To use it you must
diff --git a/usr.sbin/bootparamd/bootparamd/bootparamd.8 b/usr.sbin/bootparamd/bootparamd/bootparamd.8
index 183302aa4748..45fa7d2aa918 100644
--- a/usr.sbin/bootparamd/bootparamd/bootparamd.8
+++ b/usr.sbin/bootparamd/bootparamd/bootparamd.8
@@ -1,5 +1,3 @@
-.\" @(#)bootparamd.8
-.\" $FreeBSD$
.Dd December 14, 2000
.Dt BOOTPARAMD 8
.Os
diff --git a/usr.sbin/bootparamd/bootparamd/bootparamd.c b/usr.sbin/bootparamd/bootparamd/bootparamd.c
index 5bbd5b4becef..5100c64b5d3d 100644
--- a/usr.sbin/bootparamd/bootparamd/bootparamd.c
+++ b/usr.sbin/bootparamd/bootparamd/bootparamd.c
@@ -8,8 +8,6 @@ use and modify. Please send modifications and/or suggestions + bug fixes to
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#ifdef YP
#include <rpc/rpc.h>
#include <rpcsvc/yp_prot.h>
diff --git a/usr.sbin/bootparamd/bootparamd/bootparams.5 b/usr.sbin/bootparamd/bootparamd/bootparams.5
index c7c6785f47e1..1e9c9b5e3166 100644
--- a/usr.sbin/bootparamd/bootparamd/bootparams.5
+++ b/usr.sbin/bootparamd/bootparamd/bootparams.5
@@ -25,7 +25,6 @@
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" from: Id: bootparams.5,v 1.2 1994/10/03 19:26:13 gwr Exp
-.\" $FreeBSD$
.\"
.Dd October 2, 1994
.Dt BOOTPARAMS 5
diff --git a/usr.sbin/bootparamd/bootparamd/main.c b/usr.sbin/bootparamd/bootparamd/main.c
index 95b49f8f39a0..e0aa85f4b40a 100644
--- a/usr.sbin/bootparamd/bootparamd/main.c
+++ b/usr.sbin/bootparamd/bootparamd/main.c
@@ -8,8 +8,6 @@ use and modify. Please send modifications and/or suggestions + bug fixes to
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <err.h>
#include <netdb.h>
@@ -39,7 +37,7 @@ const char *bootpfile = "/etc/bootparams";
static struct sockaddr_in my_addr;
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char **argv)
diff --git a/usr.sbin/bootparamd/callbootd/Makefile b/usr.sbin/bootparamd/callbootd/Makefile
index b9c984ffd538..f5e102a5a60b 100644
--- a/usr.sbin/bootparamd/callbootd/Makefile
+++ b/usr.sbin/bootparamd/callbootd/Makefile
@@ -1,5 +1,3 @@
-# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
-# $FreeBSD$
PROG= callbootd
MAN=
diff --git a/usr.sbin/bootparamd/callbootd/Makefile.depend b/usr.sbin/bootparamd/callbootd/Makefile.depend
index faed4b4cc2aa..732a025c9552 100644
--- a/usr.sbin/bootparamd/callbootd/Makefile.depend
+++ b/usr.sbin/bootparamd/callbootd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
diff --git a/usr.sbin/bootparamd/callbootd/callbootd.c b/usr.sbin/bootparamd/callbootd/callbootd.c
index ea1432c3140a..f9939d83cab9 100644
--- a/usr.sbin/bootparamd/callbootd/callbootd.c
+++ b/usr.sbin/bootparamd/callbootd/callbootd.c
@@ -8,8 +8,6 @@ use and modify. Please send modifications and/or suggestions + bug fixes to
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "bootparam_prot.h"
#include <rpc/rpc.h>
#include <sys/types.h>
@@ -30,7 +28,7 @@ static char cln[MAX_MACHINE_NAME+1];
static char dmn[MAX_MACHINE_NAME+1];
static char path[MAX_PATH_LEN+1];
-static void usage(void);
+static void usage(void) __dead2;
int printgetfile(bp_getfile_res *);
int printwhoami(bp_whoami_res *);
diff --git a/usr.sbin/boottrace/boottrace.8 b/usr.sbin/boottrace/boottrace.8
index 7e7ea7b82bd1..143b22f37d69 100644
--- a/usr.sbin/boottrace/boottrace.8
+++ b/usr.sbin/boottrace/boottrace.8
@@ -1,4 +1,4 @@
-.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2022 NetApp, Inc.
.\"
diff --git a/usr.sbin/boottrace/boottrace.c b/usr.sbin/boottrace/boottrace.c
index 7696d96e0d96..fda678249da2 100644
--- a/usr.sbin/boottrace/boottrace.c
+++ b/usr.sbin/boottrace/boottrace.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 NetApp, Inc.
*
diff --git a/usr.sbin/bsdconfig/Makefile b/usr.sbin/bsdconfig/Makefile
index a203c9aab328..0e2586d276cb 100644
--- a/usr.sbin/bsdconfig/Makefile
+++ b/usr.sbin/bsdconfig/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/bsdconfig/Makefile.depend b/usr.sbin/bsdconfig/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/Makefile.depend
+++ b/usr.sbin/bsdconfig/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/USAGE b/usr.sbin/bsdconfig/USAGE
index 6b70bd6450c8..a41c21fc4394 100644
--- a/usr.sbin/bsdconfig/USAGE
+++ b/usr.sbin/bsdconfig/USAGE
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage:
@PROGRAM_NAME@ [-h]
diff --git a/usr.sbin/bsdconfig/bsdconfig b/usr.sbin/bsdconfig/bsdconfig
index f132c0370264..b3a77ea499e4 100755
--- a/usr.sbin/bsdconfig/bsdconfig
+++ b/usr.sbin/bsdconfig/bsdconfig
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/bsdconfig.8 b/usr.sbin/bsdconfig/bsdconfig.8
index 9f5481cac65d..c4fb1e612dbb 100644
--- a/usr.sbin/bsdconfig/bsdconfig.8
+++ b/usr.sbin/bsdconfig/bsdconfig.8
@@ -23,8 +23,6 @@
.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 12, 2020
.Dt BSDCONFIG 8
.Os
@@ -75,11 +73,11 @@ Print usage statement and exit.
Secure X11 mode
.Pq implies Fl X .
As root, always prompt-for and validate
-.Xr sudo 8
+.Xr sudo 8 Pq Pa ports/security/sudo
username/password before starting.
.It Fl X
Use
-.Xr Xdialog 1
+.Xr Xdialog 1 Pq Pa ports/x11/xdialog
in place of
.Xr dialog 1 .
.El
@@ -110,7 +108,7 @@ sub-utility to allow installation/re-installation of the FreeBSD Documentation
set(s).
.It Cm dot
Generate a graphviz
-.Xr dot 1
+.Xr dot 1 Pq Pa ports/graphics/graphviz
language file
.Pq printed on stdout
visualizing the
diff --git a/usr.sbin/bsdconfig/console/INDEX b/usr.sbin/bsdconfig/console/INDEX
index e298f340e63c..f99056d0adb7 100644
--- a/usr.sbin/bsdconfig/console/INDEX
+++ b/usr.sbin/bsdconfig/console/INDEX
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/console/Makefile b/usr.sbin/bsdconfig/console/Makefile
index bcb2ebd44185..dbe69e4f2a3b 100644
--- a/usr.sbin/bsdconfig/console/Makefile
+++ b/usr.sbin/bsdconfig/console/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include
diff --git a/usr.sbin/bsdconfig/console/Makefile.depend b/usr.sbin/bsdconfig/console/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/console/Makefile.depend
+++ b/usr.sbin/bsdconfig/console/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/console/USAGE b/usr.sbin/bsdconfig/console/USAGE
index a06d8af24928..66793a155c5c 100644
--- a/usr.sbin/bsdconfig/console/USAGE
+++ b/usr.sbin/bsdconfig/console/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/console/console b/usr.sbin/bsdconfig/console/console
index cfa44bee1abc..87c32cc47fe8 100755
--- a/usr.sbin/bsdconfig/console/console
+++ b/usr.sbin/bsdconfig/console/console
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/console/font b/usr.sbin/bsdconfig/console/font
index ce16730dd258..f72ff32e5e50 100755
--- a/usr.sbin/bsdconfig/console/font
+++ b/usr.sbin/bsdconfig/console/font
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/console/include/Makefile b/usr.sbin/bsdconfig/console/include/Makefile
index 52cb0be9c6e8..771c54f0a8cf 100644
--- a/usr.sbin/bsdconfig/console/include/Makefile
+++ b/usr.sbin/bsdconfig/console/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/080.console/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/console/include/Makefile.depend b/usr.sbin/bsdconfig/console/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/console/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/console/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/console/include/messages.subr b/usr.sbin/bsdconfig/console/include/messages.subr
index 295f3e302db8..e9d5293b8b48 100644
--- a/usr.sbin/bsdconfig/console/include/messages.subr
+++ b/usr.sbin/bsdconfig/console/include/messages.subr
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
hline_choose_a_font="Choose a font"
hline_choose_a_keyboard_map="Choose a keyboard map"
diff --git a/usr.sbin/bsdconfig/console/keymap b/usr.sbin/bsdconfig/console/keymap
index 28c0500cf8ac..bcba46fe63ac 100755
--- a/usr.sbin/bsdconfig/console/keymap
+++ b/usr.sbin/bsdconfig/console/keymap
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/console/repeat b/usr.sbin/bsdconfig/console/repeat
index ff000234dc74..4698531f0f30 100755
--- a/usr.sbin/bsdconfig/console/repeat
+++ b/usr.sbin/bsdconfig/console/repeat
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/console/saver b/usr.sbin/bsdconfig/console/saver
index 0df487c9583d..4227e768edec 100755
--- a/usr.sbin/bsdconfig/console/saver
+++ b/usr.sbin/bsdconfig/console/saver
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/console/screenmap b/usr.sbin/bsdconfig/console/screenmap
index 5bf5bd872da0..70fd19cdba9d 100755
--- a/usr.sbin/bsdconfig/console/screenmap
+++ b/usr.sbin/bsdconfig/console/screenmap
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/console/ttys b/usr.sbin/bsdconfig/console/ttys
index 54dcb66bdd99..b365308134ed 100755
--- a/usr.sbin/bsdconfig/console/ttys
+++ b/usr.sbin/bsdconfig/console/ttys
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/diskmgmt/INDEX b/usr.sbin/bsdconfig/diskmgmt/INDEX
index e04bb79dafe2..8c7cb9123b31 100644
--- a/usr.sbin/bsdconfig/diskmgmt/INDEX
+++ b/usr.sbin/bsdconfig/diskmgmt/INDEX
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/diskmgmt/Makefile b/usr.sbin/bsdconfig/diskmgmt/Makefile
index 16a89009bb6e..cdeafba6a559 100644
--- a/usr.sbin/bsdconfig/diskmgmt/Makefile
+++ b/usr.sbin/bsdconfig/diskmgmt/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include
diff --git a/usr.sbin/bsdconfig/diskmgmt/Makefile.depend b/usr.sbin/bsdconfig/diskmgmt/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/diskmgmt/Makefile.depend
+++ b/usr.sbin/bsdconfig/diskmgmt/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/diskmgmt/USAGE b/usr.sbin/bsdconfig/diskmgmt/USAGE
index a06d8af24928..66793a155c5c 100644
--- a/usr.sbin/bsdconfig/diskmgmt/USAGE
+++ b/usr.sbin/bsdconfig/diskmgmt/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/diskmgmt/diskmgmt b/usr.sbin/bsdconfig/diskmgmt/diskmgmt
index ec567f550e77..1e5912c95490 100755
--- a/usr.sbin/bsdconfig/diskmgmt/diskmgmt
+++ b/usr.sbin/bsdconfig/diskmgmt/diskmgmt
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/diskmgmt/include/Makefile b/usr.sbin/bsdconfig/diskmgmt/include/Makefile
index c9271532ff8c..40afa94a21d3 100644
--- a/usr.sbin/bsdconfig/diskmgmt/include/Makefile
+++ b/usr.sbin/bsdconfig/diskmgmt/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/050.diskmgmt/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/diskmgmt/include/Makefile.depend b/usr.sbin/bsdconfig/diskmgmt/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/diskmgmt/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/diskmgmt/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/diskmgmt/include/messages.subr b/usr.sbin/bsdconfig/diskmgmt/include/messages.subr
index f0b563f970a8..c370d5c29b11 100644
--- a/usr.sbin/bsdconfig/diskmgmt/include/messages.subr
+++ b/usr.sbin/bsdconfig/diskmgmt/include/messages.subr
@@ -22,6 +22,5 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
msg_no_such_file_or_directory="%s: %s: No such file or directory"
diff --git a/usr.sbin/bsdconfig/docsinstall/INDEX b/usr.sbin/bsdconfig/docsinstall/INDEX
index 6308f30cecf7..adce6b038c5c 100644
--- a/usr.sbin/bsdconfig/docsinstall/INDEX
+++ b/usr.sbin/bsdconfig/docsinstall/INDEX
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/docsinstall/Makefile b/usr.sbin/bsdconfig/docsinstall/Makefile
index 2ab3a680a4eb..0a4b3a62061c 100644
--- a/usr.sbin/bsdconfig/docsinstall/Makefile
+++ b/usr.sbin/bsdconfig/docsinstall/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include
diff --git a/usr.sbin/bsdconfig/docsinstall/Makefile.depend b/usr.sbin/bsdconfig/docsinstall/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/docsinstall/Makefile.depend
+++ b/usr.sbin/bsdconfig/docsinstall/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/docsinstall/USAGE b/usr.sbin/bsdconfig/docsinstall/USAGE
index a06d8af24928..66793a155c5c 100644
--- a/usr.sbin/bsdconfig/docsinstall/USAGE
+++ b/usr.sbin/bsdconfig/docsinstall/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/docsinstall/docsinstall b/usr.sbin/bsdconfig/docsinstall/docsinstall
index 19128fed6562..65e8741f640c 100755
--- a/usr.sbin/bsdconfig/docsinstall/docsinstall
+++ b/usr.sbin/bsdconfig/docsinstall/docsinstall
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/docsinstall/include/Makefile b/usr.sbin/bsdconfig/docsinstall/include/Makefile
index a3ca529a7cc4..17ee3a491497 100644
--- a/usr.sbin/bsdconfig/docsinstall/include/Makefile
+++ b/usr.sbin/bsdconfig/docsinstall/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/020.docsinstall/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/docsinstall/include/Makefile.depend b/usr.sbin/bsdconfig/docsinstall/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/docsinstall/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/docsinstall/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/docsinstall/include/messages.subr b/usr.sbin/bsdconfig/docsinstall/include/messages.subr
index 4c55f0fc078a..2531c276c100 100644
--- a/usr.sbin/bsdconfig/docsinstall/include/messages.subr
+++ b/usr.sbin/bsdconfig/docsinstall/include/messages.subr
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
msg_no_such_file_or_directory="%s: %s: No such file or directory"
msg_permission_denied="%s: %s: permission denied"
diff --git a/usr.sbin/bsdconfig/dot/INDEX b/usr.sbin/bsdconfig/dot/INDEX
index fa641e01f120..8bada1852433 100644
--- a/usr.sbin/bsdconfig/dot/INDEX
+++ b/usr.sbin/bsdconfig/dot/INDEX
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/dot/Makefile b/usr.sbin/bsdconfig/dot/Makefile
index ccd10b449cb6..51bca33942ca 100644
--- a/usr.sbin/bsdconfig/dot/Makefile
+++ b/usr.sbin/bsdconfig/dot/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include
diff --git a/usr.sbin/bsdconfig/dot/Makefile.depend b/usr.sbin/bsdconfig/dot/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/dot/Makefile.depend
+++ b/usr.sbin/bsdconfig/dot/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/dot/USAGE b/usr.sbin/bsdconfig/dot/USAGE
index 5bc38cc57071..6de68c1dc3bb 100644
--- a/usr.sbin/bsdconfig/dot/USAGE
+++ b/usr.sbin/bsdconfig/dot/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/dot/dot b/usr.sbin/bsdconfig/dot/dot
index f71c0e81487f..d56629591acd 100755
--- a/usr.sbin/bsdconfig/dot/dot
+++ b/usr.sbin/bsdconfig/dot/dot
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/dot/include/Makefile b/usr.sbin/bsdconfig/dot/include/Makefile
index b687b88cf254..b9ff1af38cb6 100644
--- a/usr.sbin/bsdconfig/dot/include/Makefile
+++ b/usr.sbin/bsdconfig/dot/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/dot/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/dot/include/Makefile.depend b/usr.sbin/bsdconfig/dot/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/dot/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/dot/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/dot/include/messages.subr b/usr.sbin/bsdconfig/dot/include/messages.subr
index f1095f7e4995..5f3887ce72e7 100644
--- a/usr.sbin/bsdconfig/dot/include/messages.subr
+++ b/usr.sbin/bsdconfig/dot/include/messages.subr
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
msg_graph_label_with_command="bsdconfig(8)\\\ndot(1) output generated by \`\`%s''"
msg_graph_label_with_command_and_date="bsdconfig(8)\\\ndot(1) output generated by \`\`%s'' on\\\n%s"
diff --git a/usr.sbin/bsdconfig/examples/Makefile b/usr.sbin/bsdconfig/examples/Makefile
index f66c2b19eff7..8a716f9553ce 100644
--- a/usr.sbin/bsdconfig/examples/Makefile
+++ b/usr.sbin/bsdconfig/examples/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${SHAREDIR}/examples/bsdconfig
FILES= add_some_packages.sh browse_packages_http.sh bsdconfigrc
diff --git a/usr.sbin/bsdconfig/examples/Makefile.depend b/usr.sbin/bsdconfig/examples/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/examples/Makefile.depend
+++ b/usr.sbin/bsdconfig/examples/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/examples/add_some_packages.sh b/usr.sbin/bsdconfig/examples/add_some_packages.sh
index 8750908dbb2c..b9bb8418610b 100755
--- a/usr.sbin/bsdconfig/examples/add_some_packages.sh
+++ b/usr.sbin/bsdconfig/examples/add_some_packages.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
#
# This sample installs a short list of packages from the main HTTP site.
#
diff --git a/usr.sbin/bsdconfig/examples/browse_packages_http.sh b/usr.sbin/bsdconfig/examples/browse_packages_http.sh
index 91b928d183bb..258e63d25c6a 100755
--- a/usr.sbin/bsdconfig/examples/browse_packages_http.sh
+++ b/usr.sbin/bsdconfig/examples/browse_packages_http.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
#
# This sample downloads the package digests.txz and packagesite.txz files from
# HTTP to /tmp (if they don't already exist) and then displays the package
diff --git a/usr.sbin/bsdconfig/examples/bsdconfigrc b/usr.sbin/bsdconfig/examples/bsdconfigrc
index 2e3155fda779..b36031b484ec 100644
--- a/usr.sbin/bsdconfig/examples/bsdconfigrc
+++ b/usr.sbin/bsdconfig/examples/bsdconfigrc
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
# This file allows you to customize the behavior of bsdconfig.
# Copy it to your $HOME/.bsdconfigrc and edit to suit.
diff --git a/usr.sbin/bsdconfig/include/Makefile b/usr.sbin/bsdconfig/include/Makefile
index 913481c856ef..00ebf0b7e37e 100644
--- a/usr.sbin/bsdconfig/include/Makefile
+++ b/usr.sbin/bsdconfig/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/include
FILES= bsdconfig.hlp media.hlp messages.subr network_device.hlp \
diff --git a/usr.sbin/bsdconfig/include/Makefile.depend b/usr.sbin/bsdconfig/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/include/media.hlp b/usr.sbin/bsdconfig/include/media.hlp
index 6fd609473810..ec92e035f833 100644
--- a/usr.sbin/bsdconfig/include/media.hlp
+++ b/usr.sbin/bsdconfig/include/media.hlp
@@ -16,29 +16,6 @@ You can install from the following types of media:
get the distribution files from there.
- Floppy Get distribution files from one or more DOS or UFS
- formatted floppies. Such floppies are assumed to
- contain the appropriate distribution pieces - see
- ABOUT.TXT for more information about making floppy
- distribution media.
-
-
- FTP Get the distribution files from an anonymous ftp server
- (you will be presented with a list). Please note that
- you may invoke FTP in "Active"/"Passive" auto-mode, or
- via an HTTP proxy.
-
- By default, ftp(1) will automatically use the best mode
- for the server. Using an HTTP proxy is sometimes necessary
- for firewalls which block all FTP connections.
-
- If you chose to enter your own URL in the FTP menu, please
- note that all paths are *relative* to the home directory
- of the user being logged in as. By default, this is the
- user "ftp" (anonymous ftp) but you may change this in the
- Options screen.
-
-
HTTP Direct
Get the distribution files directly from an HTTP server.
diff --git a/usr.sbin/bsdconfig/include/messages.subr b/usr.sbin/bsdconfig/include/messages.subr
index 9d910032616d..267743e87b0a 100644
--- a/usr.sbin/bsdconfig/include/messages.subr
+++ b/usr.sbin/bsdconfig/include/messages.subr
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
field_password="Password:"
field_username="Username:"
@@ -67,7 +66,7 @@ msg_canada="Canada"
msg_cancel="Cancel"
msg_cancel_exit="Cancel/Exit"
msg_cannot_create_permission_denied="%s: cannot create %s: Permission denied"
-msg_cannot_edit_wireless_ssid="Cannot edit wireless configuration; no matches for\nSSID \`%s' in wpa_supplicants.conf(5)"
+msg_cannot_edit_wireless_ssid="Cannot edit wireless configuration; no matches for\nSSID \`%s' in wpa_supplicant.conf(5)"
msg_cannot_resolve_hostname="Cannot resolve \`%s'! Are you sure that your\nname server, gateway and network interface are correctly configured?"
msg_cant_find_distribution="Warning: Can't find the \`%s' distribution on this\nFTP server. You may need to visit a different server for\nthe release you are trying to fetch or go to the Options\nmenu and set the release name to explicitly match what's\navailable on %s (or set to \"any\").\n\nWould you like to select another FTP server?"
msg_cant_seem_to_write_out_resolv_conf="Can't seem to write out %s. Net cannot be used."
@@ -75,11 +74,9 @@ msg_cant_start_wpa_supplicant="Can't start wpa_supplicant(8). Please create a wl
msg_cd_dvd="CD/DVD"
msg_cdrom="CDROM"
msg_checking_access_to="Checking access to\n %s"
-msg_china="China"
msg_chinese_desc="Ported software for the Chinese market."
msg_choose_a_cd_dvd_type="Choose a CD/DVD type"
msg_choose_a_dos_partition="Choose a DOS partition"
-msg_choose_a_floppy_drive="Choose a Floppy drive"
msg_choose_a_ufs_partition="Choose a UFS partition"
msg_choose_a_usb_drive="Choose a USB drive"
msg_choose_installation_media="Choose Installation Media"
@@ -96,10 +93,8 @@ msg_could_not_unmount_the_cdrom_dvd="Could not unmount the CDROM/DVD from %s: %s
msg_could_not_unmount_the_dos_partition="Could not unmount the DOS partition from %s: %s"
msg_could_not_unmount_the_nfs_partition="Could not unmount the NFS partition from %s: %s"
msg_could_not_unmount_the_ufs_partition="Could not unmount the UFS partition from %s: %s"
-msg_couldnt_connect_to_ftp_server="Couldn't connect to FTP server"
msg_couldnt_connect_to_proxy="Couldn't connect to proxy"
msg_couldnt_connect_to_server="Couldn't connect to server"
-msg_couldnt_open_ftp_connection="Couldn't open FTP connection to %s:\n %s."
msg_create_new="Create New"
msg_created_path="Created %s"
msg_czech_republic="Czech Republic"
@@ -131,7 +126,6 @@ msg_enter_a_fully_qualified_pathname_for_the_directory="Enter a fully qualified
msg_enter_the_device_name_of_a_ufs_formatted_partition="Enter the device-name of a UFS formatted partition"
msg_error="Error"
msg_error_mounting_device="Error mounting %s on %s: %s"
-msg_error_mounting_floppy_device="Error mounting floppy %s (%s) on %s: %s"
msg_error_mounting_usb_drive="Error mounting USB drive %s on %s: %s"
msg_error_when_requesting_url="Error when requesting %s, you could try an other server"
msg_estonia="Estonia"
@@ -143,17 +137,14 @@ msg_failed_to_reach_wpa_supplicant="Failed to reach wpa_supplicant: %s"
msg_file_system="File System"
msg_finance_desc="Monetary, financial and related applications."
msg_finland="Finland"
-msg_floppy="Floppy"
msg_forget_all="Forget All"
-msg_forget_all_confirm="WARNING! Are you really sure you want to forget all known networks\nby re-initializing wpa_supplicants.conf(5)? This cannot be undone."
+msg_forget_all_confirm="WARNING! Are you really sure you want to forget all known networks\nby re-initializing wpa_supplicant.conf(5)? This cannot be undone."
msg_forget_all_help="Reset wpa_supplicant(8) configuration, forgetting all known networks"
msg_found="found"
msg_france="France"
msg_french_desc="Ported software for French countries."
msg_ftp="FTP"
msg_ftp_desc="FTP client and server utilities."
-msg_ftp_passive="FTP Passive"
-msg_ftp_username="FTP username"
msg_generating_index_from_pkg_database="Generating INDEX from pkg(8) database\n(this can take a while)..."
msg_geography_desc="Geography-related software."
msg_german_desc="Ported software for Germanic countries."
@@ -173,12 +164,9 @@ msg_http_proxy="HTTP Proxy"
msg_hungarian_desc="Ported software for the Hungarian market."
msg_iceland="Iceland"
msg_install_from_a_dos_partition="Install from a DOS partition"
-msg_install_from_a_floppy_disk_set="Install from a floppy disk set"
msg_install_from_a_freebsd_cd_dvd="Install from a FreeBSD CD/DVD"
msg_install_from_a_ufs_partition="Install from a UFS partition"
msg_install_from_a_usb_drive="Install from a USB drive"
-msg_install_from_an_ftp_server="Install from an FTP server"
-msg_install_from_an_ftp_server_thru_firewall="Install from an FTP server through a firewall"
msg_install_from_an_ftp_server_thru_proxy="Install from an FTP server through an HTTP proxy"
msg_install_from_an_http_server="Install from an HTTP server"
msg_install_from_the_existing_filesystem="Install from the existing filesystem"
@@ -200,7 +188,6 @@ msg_ipv6="IPv6"
msg_ipv6_desc="IPv6-related software."
msg_ipv6_ready="IPv6 ready"
msg_irc_desc="Internet Relay Chat utilities."
-msg_ireland="Ireland"
msg_israel="Israel"
msg_japan="Japan"
msg_japanese_desc="Ported software for the Japanese market."
@@ -222,7 +209,7 @@ msg_looking_for_keymap_files="Looking for keymap files..."
msg_looking_up_host="Looking up host %s"
msg_mail_desc="Electronic mail packages and utilities."
msg_main_menu="Main Menu"
-msg_main_site="Main Site"
+msg_main_site="Main Site (GeoDNS)"
msg_manually_connect="Manually Connect"
msg_manually_connect_help="Connect to a wireless network that may be unlisted"
msg_math_desc="Mathematical computation software."
@@ -231,7 +218,6 @@ msg_media_timeout="Media Timeout"
msg_media_type="Media Type"
msg_menu_text="If you've already installed FreeBSD, you may use\nthis menu to customize it somewhat to suit your\nparticular configuration. Most importantly, you\ncan use the Packages utility to load extra '3rd\nparty' software not provided in the base\ndistributions."
msg_misc_desc="Miscellaneous utilities."
-msg_missing_ftp_host_or_directory="Missing FTP host or directory specification. FTP media not initialized."
msg_multimedia_desc="Multimedia software."
msg_must_be_root_to_execute="%s: must be root to execute"
msg_must_have_pkg_to_execute="%s: must have pkg(8) to execute"
@@ -260,7 +246,6 @@ msg_no="No"
msg_no_cd_dvd_devices_found="No CD/DVD devices found! Please check that your system's\nconfiguration is correct and that the CD/DVD drive is of a\nsupported type. For more information, consult the hardware\nguide in the Doc menu."
msg_no_description_provided="No description provided"
msg_no_dos_primary_partitions_found="No DOS primary partitions found! This installation method is unavailable"
-msg_no_floppy_devices_found="No floppy devices found! Please check that your system's configuration\nis correct. For more information, consult the hardware guide in the Doc\nmenu."
msg_no_gateway_has_been_set="No gateway has been set. You will be unable to access hosts\nnot on your local network"
msg_no_network_devices="No network devices available!"
msg_no_package_name_passed_in_package_variable="No package name passed in package variable"
@@ -300,17 +285,13 @@ msg_please_enter_the_full_nfs_file_specification="Please enter the full NFS file
msg_please_enter_the_password_for_this_user="Please enter the password for this user:"
msg_please_enter_the_username_you_wish_to_login_as="Please enter the username you wish to login as:"
msg_please_enter_username_password="Please enter a username and password for sudo(8):"
-msg_please_insert_floppy_containing="Please insert floppy containing %s in %s"
-msg_please_insert_floppy_in_drive="Please insert floppy in %s"
msg_please_select_a_category_to_display="Please select a category to display."
msg_please_select_a_cd_dvd_drive="FreeBSD can be installed directly from a CD/DVD containing a valid\nFreeBSD distribution. If you are seeing this menu it is because\nmore than one CD/DVD drive was found on your system. Please select\none of the following CD/DVD drives as your installation drive."
-msg_please_select_a_floppy_drive="You have more than one floppy drive. Please choose which drive\nyou would like to use."
-msg_please_select_a_freebsd_ftp_distribution_site="Please select a FreeBSD FTP distribution site"
msg_please_select_a_freebsd_http_distribution_site="Please select a FreeBSD HTTP distribution site"
msg_please_select_a_usb_drive="You have more than one USB drive. Please choose which drive\nyou would like to use."
msg_please_select_dos_partition="FreeBSD can be installed directly from a DOS partition assuming,\nof course, that you have copied the relevant distributions into\nyour DOS partition before starting this installation. If this is\nnot the case then you should reboot DOS at this time and copy the\ndistributions you wish to install into a \"FREEBSD\" subdirectory\non one of your DOS partitions. Otherwise, please select the DOS\npartition containing the FreeBSD distribution files."
msg_please_select_ethernet_device_to_configure="Please select the ethernet or PLIP device to configure."
-msg_please_select_the_site_closest_to_you_or_other="Please select the site closest to you or \"other\" if you'd like to\nspecify a different choice. Also note that not every site listed here\ncarries more than the base distribution kits. Only Primary sites are\nguaranteed to carry the full range of possible distributions."
+msg_please_select_the_site_closest_to_you_or_other="Please select the best suitable site for you or \"other\" if you want to\nspecify a different choice. The \"Main Site\" directs users to the nearest\nproject managed mirror via GeoDNS (they carry the full range of possible\ndistributions and support both IPv4 and IPv6). All other sites are known\nas \"Community Mirrors\"; not every site listed here carries more than the\nbase distribution kits. Select a site!"
msg_please_select_ufs_partition="FreeBSD can be installed directly from another FreeBSD partition\nthat is UFS formatted assuming, of course, that you have copied\nthe relevant distributions into said partition before starting\ninstallation."
msg_please_specify_a_temporary_directory="Please specify a temporary directory with lots of free space:"
msg_please_specify_the_name_of_the_text_editor="Please specify the name of the text editor you wish to use:"
@@ -324,7 +305,6 @@ msg_ports_mgmt_desc="Utilities for managing ports and packages."
msg_portuguese_desc="Ported software for the Portuguese market."
msg_previous_page="Previous page"
msg_previous_syntax_errors="%s: Not overwriting \`%s' due to previous syntax errors"
-msg_primary="Primary"
msg_print_desc="Utilities for dealing with printing."
msg_probing_devices_please_wait_this_can_take_a_while="Probing devices, please wait (this can take a while)..."
msg_proceed="Proceed"
@@ -343,7 +323,6 @@ msg_rescan_devices="Re-scan Devices"
msg_reset="RESET!"
msg_reset_all_values_to_startup_defaults="Reset all values to startup defaults"
msg_return_to_previous_menu="Return to previous menu"
-msg_reuse_old_ftp_site_selection_values="Re-use old FTP site selection values?"
msg_reuse_old_http_site_settings="Re-use old HTTP site settings?"
msg_review="Review"
msg_review_desc="Review/perform pending actions"
@@ -362,7 +341,7 @@ msg_secure_mode_requires_root="Secure-mode requires root-access!"
msg_secure_mode_requires_x11="Secure-mode requires X11 (use \`-X')!"
msg_security_desc="System security software."
msg_select="Select"
-msg_select_a_site_thats_close="Select a site that's close!"
+msg_select_a_site_thats_close="Select a site!"
msg_select_the_configuration_you_would_like="Select the configuration you would like to edit:\nAddional network information displayed in help line."
msg_select_wlan_interfaces_for="Select wlan interfaces for %s:"
msg_selected="selected"
@@ -371,11 +350,10 @@ msg_shells_desc="Various shells (tcsh, bash, etc)."
msg_show_all="Show All"
msg_show_all_help="Show wireless networks without an SSID and all BSSIDs"
msg_show_configured="Show Configured"
-msg_show_configured_help="Show networks configured in wpa_supplicants.conf(5)"
+msg_show_configured_help="Show networks configured in wpa_supplicant.conf(5)"
msg_show_scan_results="Show Scan Results"
msg_show_scan_results_help="Show wpa_cli(8) scan results"
msg_skip="Skip"
-msg_slovak_republic="Slovak Republic"
msg_slovenia="Slovenia"
msg_sorry_invalid_url="Sorry, %s is an invalid URL!"
msg_sorry_package_was_not_found_in_the_index="Sorry, package %s was not found in the INDEX."
@@ -383,10 +361,8 @@ msg_sorry_try_again="Sorry, try again."
msg_south_africa="South Africa"
msg_spain="Spain"
msg_spanish_desc="Ported software for the Spanish market."
-msg_specify_some_other_ftp_site="Specify some other ftp site by URL"
msg_specify_some_other_http_site="Specify some other http site by URL"
msg_sweden="Sweden"
-msg_switzerland="Switzerland"
msg_sysutils_desc="Various system utilities."
msg_taiwan="Taiwan"
msg_tcl_desc="TCL and packages that depend on it."
@@ -404,7 +380,6 @@ msg_ukrainian_desc="Ported software for the Ukrainian market."
msg_unable_to_configure_device="Unable to configure the %s interface!\nThis installation method cannot be used."
msg_unable_to_fetch_package_from_selected_media="Unable to fetch package %s from selected media.\nNo package add will be done."
msg_unable_to_get_file_from_selected_media="Unable to get %s file from selected media.\n\nThis may be because the packages collection is not available\non the distribution media you've chosen, most likely an FTP site\nwithout the packages collection mirrored. Please verify that\nyour media, or your path to the media, is correct and try again."
-msg_unable_to_get_proper_ftp_path="Unable to get proper FTP path. FTP media not initialized."
msg_unable_to_initialize_media_type_for_package_extract="Unable to initialize media type for package extract."
msg_unable_to_make_directory_mountpoint="Unable to make %s directory mountpoint for %s!"
msg_unable_to_open="Unable to open %s"
@@ -427,6 +402,7 @@ msg_user_is_using_a_slow_pc_or_ethernet_card="User is using a slow PC or Etherne
msg_username_and_password_to_use="Username and password to use instead of anonymous"
msg_using_interface="Using interface %s"
msg_using_usb_device="Using USB device: %s"
+msg_v6="- IPv6"
msg_vietnamese_desc="Ported software for the Vietnamese market."
msg_view_set_various_media_options="View/Set various media options"
msg_warning_no_wireless_devices="WARNING! No wireless devices found."
@@ -452,7 +428,6 @@ msg_xfce_desc="Software related to the Xfce Desktop Environment."
msg_yes="Yes"
msg_yes_to_all="Yes to All"
msg_you_are_not_root_but="You are not root but %s can use sudo(8).\nWhat would you like to do?"
-msg_you_may_remove_the_floppy="You may remove the floppy from %s"
msg_youve_already_done_the_network_configuration="You've already done the network configuration once,\nwould you like to skip over it now?"
msg_zope_desc="Software related to the Zope platform."
tcplayout_extras_help="Any interface-specific options to ifconfig you would like to add"
diff --git a/usr.sbin/bsdconfig/include/options.hlp b/usr.sbin/bsdconfig/include/options.hlp
index f47df27a6b88..257c5011fb9e 100644
--- a/usr.sbin/bsdconfig/include/options.hlp
+++ b/usr.sbin/bsdconfig/include/options.hlp
@@ -85,9 +85,7 @@ Release Name: Which release to attempt to load from installation media.
You should only change this option if you're really sure you know
what you are doing! This will change the release name used by
- bsdconfig when fetching components of any distributions, and
- is a useful way of using a more recent installation boot floppy
- with an older release (say, on CDROM).
+ bsdconfig when fetching components of any distributions.
Media Type: Which media type is being used.
diff --git a/usr.sbin/bsdconfig/includes/INDEX b/usr.sbin/bsdconfig/includes/INDEX
index a6a6c49212a4..628a597c66fa 100644
--- a/usr.sbin/bsdconfig/includes/INDEX
+++ b/usr.sbin/bsdconfig/includes/INDEX
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/includes/Makefile b/usr.sbin/bsdconfig/includes/Makefile
index 367776c245a8..a477fce4362f 100644
--- a/usr.sbin/bsdconfig/includes/Makefile
+++ b/usr.sbin/bsdconfig/includes/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include
diff --git a/usr.sbin/bsdconfig/includes/Makefile.depend b/usr.sbin/bsdconfig/includes/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/includes/Makefile.depend
+++ b/usr.sbin/bsdconfig/includes/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/includes/USAGE b/usr.sbin/bsdconfig/includes/USAGE
index 4af1b732c718..19999fcd7992 100644
--- a/usr.sbin/bsdconfig/includes/USAGE
+++ b/usr.sbin/bsdconfig/includes/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS] [include ...]
diff --git a/usr.sbin/bsdconfig/includes/include/Makefile b/usr.sbin/bsdconfig/includes/include/Makefile
index 3b8b3ec66f27..2a0c1d234e76 100644
--- a/usr.sbin/bsdconfig/includes/include/Makefile
+++ b/usr.sbin/bsdconfig/includes/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/includes/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/includes/include/Makefile.depend b/usr.sbin/bsdconfig/includes/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/includes/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/includes/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/includes/include/messages.subr b/usr.sbin/bsdconfig/includes/include/messages.subr
index 8fa881b4cf15..6b84634208d4 100644
--- a/usr.sbin/bsdconfig/includes/include/messages.subr
+++ b/usr.sbin/bsdconfig/includes/include/messages.subr
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
msg_functions_in="Functions in %s:"
msg_functions_in_matching="Functions in %s matching \`%s':"
diff --git a/usr.sbin/bsdconfig/includes/includes.sh b/usr.sbin/bsdconfig/includes/includes.sh
index 6e9906fd0420..a48ff99aa298 100755
--- a/usr.sbin/bsdconfig/includes/includes.sh
+++ b/usr.sbin/bsdconfig/includes/includes.sh
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/mouse/INDEX b/usr.sbin/bsdconfig/mouse/INDEX
index 4a33a792976e..39ab0366a658 100644
--- a/usr.sbin/bsdconfig/mouse/INDEX
+++ b/usr.sbin/bsdconfig/mouse/INDEX
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/mouse/Makefile b/usr.sbin/bsdconfig/mouse/Makefile
index 97fa52b60520..e31a29b34032 100644
--- a/usr.sbin/bsdconfig/mouse/Makefile
+++ b/usr.sbin/bsdconfig/mouse/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include
diff --git a/usr.sbin/bsdconfig/mouse/Makefile.depend b/usr.sbin/bsdconfig/mouse/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/mouse/Makefile.depend
+++ b/usr.sbin/bsdconfig/mouse/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/mouse/USAGE b/usr.sbin/bsdconfig/mouse/USAGE
index a06d8af24928..66793a155c5c 100644
--- a/usr.sbin/bsdconfig/mouse/USAGE
+++ b/usr.sbin/bsdconfig/mouse/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/mouse/disable b/usr.sbin/bsdconfig/mouse/disable
index f2c528f2b7bf..14b401cf633b 100755
--- a/usr.sbin/bsdconfig/mouse/disable
+++ b/usr.sbin/bsdconfig/mouse/disable
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/mouse/enable b/usr.sbin/bsdconfig/mouse/enable
index 9ad6857e139b..f04c6b257b07 100755
--- a/usr.sbin/bsdconfig/mouse/enable
+++ b/usr.sbin/bsdconfig/mouse/enable
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/mouse/flags b/usr.sbin/bsdconfig/mouse/flags
index 181ee3f41c57..7f0732e747ab 100755
--- a/usr.sbin/bsdconfig/mouse/flags
+++ b/usr.sbin/bsdconfig/mouse/flags
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/mouse/include/Makefile b/usr.sbin/bsdconfig/mouse/include/Makefile
index 2cc852f9ac67..0d33ec61c8ed 100644
--- a/usr.sbin/bsdconfig/mouse/include/Makefile
+++ b/usr.sbin/bsdconfig/mouse/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/110.mouse/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/mouse/include/Makefile.depend b/usr.sbin/bsdconfig/mouse/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/mouse/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/mouse/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/mouse/include/messages.subr b/usr.sbin/bsdconfig/mouse/include/messages.subr
index 2699b9a5471c..b5e7f10d38dc 100644
--- a/usr.sbin/bsdconfig/mouse/include/messages.subr
+++ b/usr.sbin/bsdconfig/mouse/include/messages.subr
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
hline_press_enter_or_space="Press enter or space"
msg_auto="Auto"
diff --git a/usr.sbin/bsdconfig/mouse/mouse b/usr.sbin/bsdconfig/mouse/mouse
index 0dce574feea2..22aab33dba26 100755
--- a/usr.sbin/bsdconfig/mouse/mouse
+++ b/usr.sbin/bsdconfig/mouse/mouse
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/mouse/port b/usr.sbin/bsdconfig/mouse/port
index 92c7ff25ea1f..1793179a523c 100755
--- a/usr.sbin/bsdconfig/mouse/port
+++ b/usr.sbin/bsdconfig/mouse/port
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/mouse/type b/usr.sbin/bsdconfig/mouse/type
index 7d99753a62be..0772eb5a823d 100755
--- a/usr.sbin/bsdconfig/mouse/type
+++ b/usr.sbin/bsdconfig/mouse/type
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/INDEX b/usr.sbin/bsdconfig/networking/INDEX
index d05d4948606e..0b80c163e1fd 100644
--- a/usr.sbin/bsdconfig/networking/INDEX
+++ b/usr.sbin/bsdconfig/networking/INDEX
@@ -1,5 +1,5 @@
# Copyright (c) 2012 Ron McDowell
-# Copyright (c) 2012-2016 Devin Teske
+# Copyright (c) 2012-2023 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
@@ -46,6 +45,7 @@ menu_help="Setup Networking interfaces, services, etc."
# can be i18n'ed but `command' is the name of a script.
#
menu_selection="networking|networking"
+menu_selection="network|networking"
menu_selection="defaultrouter|defaultrouter"
menu_selection="hostname|hostname"
menu_selection="nameservers|nameservers"
diff --git a/usr.sbin/bsdconfig/networking/Makefile b/usr.sbin/bsdconfig/networking/Makefile
index 6a1eedda8a9f..f870d3df63a5 100644
--- a/usr.sbin/bsdconfig/networking/Makefile
+++ b/usr.sbin/bsdconfig/networking/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include share
diff --git a/usr.sbin/bsdconfig/networking/Makefile.depend b/usr.sbin/bsdconfig/networking/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/networking/Makefile.depend
+++ b/usr.sbin/bsdconfig/networking/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/networking/USAGE b/usr.sbin/bsdconfig/networking/USAGE
index 872094666bb0..c4c14e52d026 100644
--- a/usr.sbin/bsdconfig/networking/USAGE
+++ b/usr.sbin/bsdconfig/networking/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/networking/defaultrouter b/usr.sbin/bsdconfig/networking/defaultrouter
index b65981f604f2..e2ba61a86435 100755
--- a/usr.sbin/bsdconfig/networking/defaultrouter
+++ b/usr.sbin/bsdconfig/networking/defaultrouter
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/devices b/usr.sbin/bsdconfig/networking/devices
index 433f25c75fa0..e9a5dbf31fc3 100755
--- a/usr.sbin/bsdconfig/networking/devices
+++ b/usr.sbin/bsdconfig/networking/devices
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/hostname b/usr.sbin/bsdconfig/networking/hostname
index d0fff0120eea..8f15d4cb656a 100755
--- a/usr.sbin/bsdconfig/networking/hostname
+++ b/usr.sbin/bsdconfig/networking/hostname
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/include/Makefile b/usr.sbin/bsdconfig/networking/include/Makefile
index 54f66e128407..22fd0ea262f3 100644
--- a/usr.sbin/bsdconfig/networking/include/Makefile
+++ b/usr.sbin/bsdconfig/networking/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/120.networking/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/networking/include/Makefile.depend b/usr.sbin/bsdconfig/networking/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/networking/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/networking/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/networking/include/messages.subr b/usr.sbin/bsdconfig/networking/include/messages.subr
index 55881ffa63f7..3c411c7938cb 100644
--- a/usr.sbin/bsdconfig/networking/include/messages.subr
+++ b/usr.sbin/bsdconfig/networking/include/messages.subr
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER"
hline_arrows_tab_enter="Press arrows, TAB or ENTER"
diff --git a/usr.sbin/bsdconfig/networking/nameservers b/usr.sbin/bsdconfig/networking/nameservers
index e18f00493efb..604652e4964a 100755
--- a/usr.sbin/bsdconfig/networking/nameservers
+++ b/usr.sbin/bsdconfig/networking/nameservers
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/networking b/usr.sbin/bsdconfig/networking/networking
index af37caaf3d6c..ff4a675731b9 100755
--- a/usr.sbin/bsdconfig/networking/networking
+++ b/usr.sbin/bsdconfig/networking/networking
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/share/Makefile b/usr.sbin/bsdconfig/networking/share/Makefile
index 6d77f25c5e9e..8b8a4cc71929 100644
--- a/usr.sbin/bsdconfig/networking/share/Makefile
+++ b/usr.sbin/bsdconfig/networking/share/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${SHAREDIR}/bsdconfig/networking
FILES= common.subr device.subr hostname.subr ipaddr.subr media.subr \
diff --git a/usr.sbin/bsdconfig/networking/share/Makefile.depend b/usr.sbin/bsdconfig/networking/share/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/networking/share/Makefile.depend
+++ b/usr.sbin/bsdconfig/networking/share/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/networking/share/common.subr b/usr.sbin/bsdconfig/networking/share/common.subr
index 152d1aceb03b..120799d552a0 100644
--- a/usr.sbin/bsdconfig/networking/share/common.subr
+++ b/usr.sbin/bsdconfig/networking/share/common.subr
@@ -24,7 +24,6 @@ if [ ! "$_NETWORKING_COMMON_SUBR" ]; then _NETWORKING_COMMON_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr
index 41ea29def67c..52e7f3c8a71b 100644
--- a/usr.sbin/bsdconfig/networking/share/device.subr
+++ b/usr.sbin/bsdconfig/networking/share/device.subr
@@ -24,7 +24,6 @@ if [ ! "$_NETWORKING_DEVICE_SUBR" ]; then _NETWORKING_DEVICE_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/share/hostname.subr b/usr.sbin/bsdconfig/networking/share/hostname.subr
index 34bfd6e1d572..811c6042ed93 100644
--- a/usr.sbin/bsdconfig/networking/share/hostname.subr
+++ b/usr.sbin/bsdconfig/networking/share/hostname.subr
@@ -24,7 +24,6 @@ if [ ! "$_NETWORKING_HOSTNAME_SUBR" ]; then _NETWORKING_HOSTNAME_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/share/ipaddr.subr b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
index b7624cc792d4..1b959fc16765 100644
--- a/usr.sbin/bsdconfig/networking/share/ipaddr.subr
+++ b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
@@ -24,7 +24,6 @@ if [ ! "$_NETWORKING_IPADDR_SUBR" ]; then _NETWORKING_IPADDR_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/share/media.subr b/usr.sbin/bsdconfig/networking/share/media.subr
index 028944b5eb6b..8ecb25e4d1d1 100644
--- a/usr.sbin/bsdconfig/networking/share/media.subr
+++ b/usr.sbin/bsdconfig/networking/share/media.subr
@@ -24,7 +24,6 @@ if [ ! "$_NETWORKING_MEDIA_SUBR" ]; then _NETWORKING_MEDIA_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/share/netmask.subr b/usr.sbin/bsdconfig/networking/share/netmask.subr
index a7d44a55e00a..ba0c5e906565 100644
--- a/usr.sbin/bsdconfig/networking/share/netmask.subr
+++ b/usr.sbin/bsdconfig/networking/share/netmask.subr
@@ -24,7 +24,6 @@ if [ ! "$_NETWORKING_NETMASK_SUBR" ]; then _NETWORKING_NETMASK_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/share/resolv.subr b/usr.sbin/bsdconfig/networking/share/resolv.subr
index 779863c9981d..056a665ce607 100644
--- a/usr.sbin/bsdconfig/networking/share/resolv.subr
+++ b/usr.sbin/bsdconfig/networking/share/resolv.subr
@@ -24,7 +24,6 @@ if [ ! "$_NETWORKING_RESOLV_SUBR" ]; then _NETWORKING_RESOLV_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/share/routing.subr b/usr.sbin/bsdconfig/networking/share/routing.subr
index 826ac6e10baf..9632af6b0139 100644
--- a/usr.sbin/bsdconfig/networking/share/routing.subr
+++ b/usr.sbin/bsdconfig/networking/share/routing.subr
@@ -24,7 +24,6 @@ if [ ! "$_NETWORKING_ROUTING_SUBR" ]; then _NETWORKING_ROUTING_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/share/services.subr b/usr.sbin/bsdconfig/networking/share/services.subr
index 246d8956e322..263be6dc41ae 100644
--- a/usr.sbin/bsdconfig/networking/share/services.subr
+++ b/usr.sbin/bsdconfig/networking/share/services.subr
@@ -24,7 +24,6 @@ if [ ! "$_NETWORKING_SERVICES_SUBR" ]; then _NETWORKING_SERVICES_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/networking/wlanconfig b/usr.sbin/bsdconfig/networking/wlanconfig
index 989bb794fb8e..72d530ea0a6d 100755
--- a/usr.sbin/bsdconfig/networking/wlanconfig
+++ b/usr.sbin/bsdconfig/networking/wlanconfig
@@ -26,7 +26,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/packages/INDEX b/usr.sbin/bsdconfig/packages/INDEX
index 80434779f202..414eb0a57e82 100644
--- a/usr.sbin/bsdconfig/packages/INDEX
+++ b/usr.sbin/bsdconfig/packages/INDEX
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/packages/Makefile b/usr.sbin/bsdconfig/packages/Makefile
index fa5bd302c6d7..e5d4796de5fa 100644
--- a/usr.sbin/bsdconfig/packages/Makefile
+++ b/usr.sbin/bsdconfig/packages/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include
diff --git a/usr.sbin/bsdconfig/packages/Makefile.depend b/usr.sbin/bsdconfig/packages/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/packages/Makefile.depend
+++ b/usr.sbin/bsdconfig/packages/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/packages/USAGE b/usr.sbin/bsdconfig/packages/USAGE
index 5f99b3826454..1a460cb97054 100644
--- a/usr.sbin/bsdconfig/packages/USAGE
+++ b/usr.sbin/bsdconfig/packages/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/packages/include/Makefile b/usr.sbin/bsdconfig/packages/include/Makefile
index 3d30fd2b4a5f..80fe431c56f3 100644
--- a/usr.sbin/bsdconfig/packages/include/Makefile
+++ b/usr.sbin/bsdconfig/packages/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/030.packages/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/packages/include/Makefile.depend b/usr.sbin/bsdconfig/packages/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/packages/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/packages/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/packages/include/messages.subr b/usr.sbin/bsdconfig/packages/include/messages.subr
index 8e945acc8ab6..d9348d1a38e3 100755
--- a/usr.sbin/bsdconfig/packages/include/messages.subr
+++ b/usr.sbin/bsdconfig/packages/include/messages.subr
@@ -22,6 +22,5 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
msg_package_selection="Package Selection"
diff --git a/usr.sbin/bsdconfig/packages/packages b/usr.sbin/bsdconfig/packages/packages
index ec429f282462..9228ff9f59af 100755
--- a/usr.sbin/bsdconfig/packages/packages
+++ b/usr.sbin/bsdconfig/packages/packages
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/password/INDEX b/usr.sbin/bsdconfig/password/INDEX
index 10f23db67b0b..29432bc7392c 100644
--- a/usr.sbin/bsdconfig/password/INDEX
+++ b/usr.sbin/bsdconfig/password/INDEX
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/password/Makefile b/usr.sbin/bsdconfig/password/Makefile
index d660e452a659..d31ca8a906be 100644
--- a/usr.sbin/bsdconfig/password/Makefile
+++ b/usr.sbin/bsdconfig/password/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include share
diff --git a/usr.sbin/bsdconfig/password/Makefile.depend b/usr.sbin/bsdconfig/password/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/password/Makefile.depend
+++ b/usr.sbin/bsdconfig/password/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/password/USAGE b/usr.sbin/bsdconfig/password/USAGE
index a06d8af24928..66793a155c5c 100644
--- a/usr.sbin/bsdconfig/password/USAGE
+++ b/usr.sbin/bsdconfig/password/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/password/include/Makefile b/usr.sbin/bsdconfig/password/include/Makefile
index a146eb230ae9..530a41bdc326 100644
--- a/usr.sbin/bsdconfig/password/include/Makefile
+++ b/usr.sbin/bsdconfig/password/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/040.password/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/password/include/Makefile.depend b/usr.sbin/bsdconfig/password/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/password/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/password/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/password/include/messages.subr b/usr.sbin/bsdconfig/password/include/messages.subr
index 655160de0724..455419dd0936 100644
--- a/usr.sbin/bsdconfig/password/include/messages.subr
+++ b/usr.sbin/bsdconfig/password/include/messages.subr
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER"
msg_cancel="Cancel"
diff --git a/usr.sbin/bsdconfig/password/password b/usr.sbin/bsdconfig/password/password
index b73a8d0936f0..14f5fabbc2b0 100755
--- a/usr.sbin/bsdconfig/password/password
+++ b/usr.sbin/bsdconfig/password/password
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/password/share/Makefile b/usr.sbin/bsdconfig/password/share/Makefile
index 65f9e8c5c0f1..49edf9ae212e 100644
--- a/usr.sbin/bsdconfig/password/share/Makefile
+++ b/usr.sbin/bsdconfig/password/share/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${SHAREDIR}/bsdconfig/password
FILES= password.subr
diff --git a/usr.sbin/bsdconfig/password/share/Makefile.depend b/usr.sbin/bsdconfig/password/share/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/password/share/Makefile.depend
+++ b/usr.sbin/bsdconfig/password/share/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/password/share/password.subr b/usr.sbin/bsdconfig/password/share/password.subr
index 22803394fc30..2ae3ea275f8b 100644
--- a/usr.sbin/bsdconfig/password/share/password.subr
+++ b/usr.sbin/bsdconfig/password/share/password.subr
@@ -24,7 +24,6 @@ if [ ! "$_PASSWORD_PASSWORD_SUBR" ]; then _PASSWORD_PASSWORD_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/security/INDEX b/usr.sbin/bsdconfig/security/INDEX
index 9e7718690622..e286af7f81b5 100644
--- a/usr.sbin/bsdconfig/security/INDEX
+++ b/usr.sbin/bsdconfig/security/INDEX
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/security/Makefile b/usr.sbin/bsdconfig/security/Makefile
index af83cee47158..46742f93ba67 100644
--- a/usr.sbin/bsdconfig/security/Makefile
+++ b/usr.sbin/bsdconfig/security/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include
diff --git a/usr.sbin/bsdconfig/security/Makefile.depend b/usr.sbin/bsdconfig/security/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/security/Makefile.depend
+++ b/usr.sbin/bsdconfig/security/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/security/USAGE b/usr.sbin/bsdconfig/security/USAGE
index a06d8af24928..66793a155c5c 100644
--- a/usr.sbin/bsdconfig/security/USAGE
+++ b/usr.sbin/bsdconfig/security/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/security/include/Makefile b/usr.sbin/bsdconfig/security/include/Makefile
index 2efcc0f8a399..55a9ec018b00 100644
--- a/usr.sbin/bsdconfig/security/include/Makefile
+++ b/usr.sbin/bsdconfig/security/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/130.security/include
FILES= messages.subr securelevel.hlp
diff --git a/usr.sbin/bsdconfig/security/include/Makefile.depend b/usr.sbin/bsdconfig/security/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/security/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/security/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/security/include/messages.subr b/usr.sbin/bsdconfig/security/include/messages.subr
index 1ab2333c1fb8..b86c5dd7d718 100644
--- a/usr.sbin/bsdconfig/security/include/messages.subr
+++ b/usr.sbin/bsdconfig/security/include/messages.subr
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
hline_arrows_tab_enter="Press arrows, TAB or ENTER"
hline_select_securelevel_to_operate_at="Select a securelevel to operate at"
diff --git a/usr.sbin/bsdconfig/security/kern_securelevel b/usr.sbin/bsdconfig/security/kern_securelevel
index 9aa79b7de8f7..353e09fb4f37 100755
--- a/usr.sbin/bsdconfig/security/kern_securelevel
+++ b/usr.sbin/bsdconfig/security/kern_securelevel
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/security/security b/usr.sbin/bsdconfig/security/security
index e045ad8a2027..630108babc27 100755
--- a/usr.sbin/bsdconfig/security/security
+++ b/usr.sbin/bsdconfig/security/security
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/Makefile b/usr.sbin/bsdconfig/share/Makefile
index a09697a29d0d..69d045c6f1bc 100644
--- a/usr.sbin/bsdconfig/share/Makefile
+++ b/usr.sbin/bsdconfig/share/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= media packages
diff --git a/usr.sbin/bsdconfig/share/Makefile.depend b/usr.sbin/bsdconfig/share/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/share/Makefile.depend
+++ b/usr.sbin/bsdconfig/share/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/share/common.subr b/usr.sbin/bsdconfig/share/common.subr
index fe403f045db3..830279168ff2 100644
--- a/usr.sbin/bsdconfig/share/common.subr
+++ b/usr.sbin/bsdconfig/share/common.subr
@@ -25,7 +25,6 @@ if [ ! "$_COMMON_SUBR" ]; then _COMMON_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ CONFIGURATION
@@ -370,7 +369,7 @@ f_show_info()
if f_have f_dialog_info; then
f_dialog_info "$msg"
else
- dialog --infobox "$msg" 0 0
+ bsddialog --infobox "$msg" 0 0
fi
}
@@ -391,7 +390,7 @@ f_show_msg()
if f_have f_dialog_msgbox; then
f_dialog_msgbox "$msg"
else
- dialog --msgbox "$msg" 0 0
+ bsddialog --msgbox "$msg" 0 0
fi
}
@@ -434,7 +433,7 @@ f_yesno()
if f_have f_dialog_yesno; then
f_dialog_yesno "$msg"
else
- dialog --yesno "$msg" 0 0
+ bsddialog --yesno "$msg" 0 0
fi
}
@@ -456,7 +455,7 @@ f_noyes()
if f_have f_dialog_noyes; then
f_dialog_noyes "$msg"
else
- dialog --defaultno --yesno "$msg" 0 0
+ bsddialog --defaultno --yesno "$msg" 0 0
fi
}
@@ -487,7 +486,7 @@ f_show_help()
if f_have f_dialog_textbox; then
f_dialog_textbox "$file"
else
- dialog --msgbox "$( cat "$file" 2>&1 )" 0 0
+ bsddialog --msgbox "$( cat "$file" 2>&1 )" 0 0
fi
}
diff --git a/usr.sbin/bsdconfig/share/device.subr b/usr.sbin/bsdconfig/share/device.subr
index 97e878424703..4ca2a80c69a5 100644
--- a/usr.sbin/bsdconfig/share/device.subr
+++ b/usr.sbin/bsdconfig/share/device.subr
@@ -24,7 +24,6 @@ if [ ! "$_DEVICE_SUBR" ]; then _DEVICE_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -78,7 +77,6 @@ f_struct_define DEVICE_INFO \
setvar DEVICE_TYPE_ANY "any" # Any
setvar DEVICE_TYPE_NONE "NONE" # Unknown
setvar DEVICE_TYPE_DISK "DISK" # GEOM `DISK'
-setvar DEVICE_TYPE_FLOPPY "FD" # GEOM `FD'
setvar DEVICE_TYPE_FTP "FTP" # Dynamic network device
setvar DEVICE_TYPE_NETWORK "NETWORK" # See f_device_get_all_network
setvar DEVICE_TYPE_CDROM "CDROM" # GEOM `DISK'
@@ -441,14 +439,6 @@ f_device_probe_geom()
return $retval
;;
- $GEOM_CLASS_FD)
- f_dprintf "Found floppy device named %s" "$devname"
- debug= f_device_register device "$devname" "$desc" \
- "/dev/$devname" $DEVICE_TYPE_FLOPPY 1 \
- f_media_init_floppy f_media_get_floppy \
- f_media_shutdown_floppy "" "$capacity"
- return $?
- ;;
$GEOM_CLASS_LABEL)
: fall through to below section # reduces indentation level
;;
@@ -937,7 +927,6 @@ f_device_desc()
case "$__type" in
$DEVICE_TYPE_CDROM) __cp="<unknown cdrom device type>" ;;
$DEVICE_TYPE_DISK) __cp="<unknown disk device type>" ;;
- $DEVICE_TYPE_FLOPPY) __cp="<unknown floppy device type>" ;;
$DEVICE_TYPE_USB) __cp="<unknown USB storage device type>" ;;
$DEVICE_TYPE_NETWORK) __cp="<unknown network interface type>" ;;
*)
@@ -1248,7 +1237,6 @@ f_device_menu()
#
f_cdrom() { f_device_catalog_set $DEVICE_TYPE_CDROM "$1" "$2"; }
f_disk() { f_device_catalog_set $DEVICE_TYPE_DISK "$1" "$2"; }
-f_floppy() { f_device_catalog_set $DEVICE_TYPE_FLOPPY "$1" "$2"; }
f_usb() { f_device_catalog_set $DEVICE_TYPE_USB "$1" "$2"; }
f_network() { f_device_catalog_set $DEVICE_TYPE_NETWORK "$1" "$2"; }
@@ -1263,7 +1251,7 @@ f_network() { f_device_catalog_set $DEVICE_TYPE_NETWORK "$1" "$2"; }
DEVICE_CATALOG_APPEND_ONLY=1 # Make initial loading faster
-# CDROM, Disk, Floppy, and USB devices/names
+# CDROM, Disk, and USB devices/names
f_cdrom "cd%d" "SCSI CDROM drive"
f_cdrom "mcd%d" "Mitsumi (old model) CDROM drive"
f_cdrom "scd%d" "Sony CDROM drive - CDU31/33A type"
@@ -1278,7 +1266,6 @@ f_disk "mfid%d" "LSI MegaRAID SAS array"
f_disk "mlxd%d" "Mylex RAID disk"
f_disk "twed%d" "3ware ATA RAID array"
f_disk "vtbd%d" "VirtIO Block Device"
-f_floppy "fd%d" "Floppy Drive unit A"
f_usb "da%da" "USB Mass Storage Device"
# Network interfaces/names
diff --git a/usr.sbin/bsdconfig/share/dialog.subr b/usr.sbin/bsdconfig/share/dialog.subr
index 5b5c8a32984e..cac0a3e24e53 100644
--- a/usr.sbin/bsdconfig/share/dialog.subr
+++ b/usr.sbin/bsdconfig/share/dialog.subr
@@ -24,7 +24,6 @@ if [ ! "$_DIALOG_SUBR" ]; then _DIALOG_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -52,7 +51,7 @@ f_include_lang $BSDCFG_LIBE/include/messages.subr
# Default name of dialog(1) utility
# NOTE: This is changed to "Xdialog" by the optional `-X' argument
#
-DIALOG="dialog"
+DIALOG="bsddialog"
#
# Default dialog(1) title and backtitle text
@@ -85,6 +84,15 @@ export DIALOG_ERROR=254 # sh(1) can't handle the default of `-1'
DIALOG_ESC=255
#
+# Set bsddialog(1) compatibility with dialog(1): exit codes and use_shadow
+#
+export BSDDIALOG_TIMEOUT=0
+export BSDDIALOG_ITEM_HELP=4
+export BSDDIALOG_ERROR=254
+export BSDDIALOG_ESC=255
+export BSDDIALOG_COMPATRC=".dialogrc"
+
+#
# Default behavior is to call f_dialog_init() automatically when loaded.
#
: ${DIALOG_SELF_INITIALIZE=1}
@@ -2230,7 +2238,7 @@ f_dialog_init()
if ! f_have $DIALOG; then
unset USE_XDIALOG
local failed_dialog="$DIALOG"
- DIALOG=dialog
+ DIALOG=bsddialog
f_die 1 "$msg_no_such_file_or_directory" "$pgm" "$failed_dialog"
fi
@@ -2262,7 +2270,7 @@ f_dialog_init()
if ! f_have xauth; then
# Die gracefully, as we [likely] can't use Xdialog(1)
unset USE_XDIALOG
- DIALOG=dialog
+ DIALOG=bsddialog
f_die 1 "$msg_no_such_file_or_directory" "$pgm" "xauth"
fi
HOSTNAME=$( hostname )
@@ -2289,7 +2297,7 @@ f_dialog_init()
local height width
f_dialog_buttonbox_size height width \
"$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$maxsize"
- dialog \
+ bsddialog \
--title "$DIALOG_TITLE" \
--backtitle "$DIALOG_BACKTITLE" \
--ok-label "$msg_ok" \
diff --git a/usr.sbin/bsdconfig/share/geom.subr b/usr.sbin/bsdconfig/share/geom.subr
index d6486c6d6543..fda918f920f9 100644
--- a/usr.sbin/bsdconfig/share/geom.subr
+++ b/usr.sbin/bsdconfig/share/geom.subr
@@ -24,7 +24,6 @@ if [ ! "$_GEOM_SUBR" ]; then _GEOM_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/keymap.subr b/usr.sbin/bsdconfig/share/keymap.subr
index ca6f3c8df841..7a159199c6fd 100644
--- a/usr.sbin/bsdconfig/share/keymap.subr
+++ b/usr.sbin/bsdconfig/share/keymap.subr
@@ -24,7 +24,6 @@ if [ ! "$_KEYMAP_SUBR" ]; then _KEYMAP_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/media/Makefile b/usr.sbin/bsdconfig/share/media/Makefile
index e8ec319a0ae4..e90b87f70cc2 100644
--- a/usr.sbin/bsdconfig/share/media/Makefile
+++ b/usr.sbin/bsdconfig/share/media/Makefile
@@ -1,8 +1,7 @@
-# $FreeBSD$
FILESDIR= ${SHAREDIR}/bsdconfig/media
FILES= any.subr cdrom.subr common.subr directory.subr dos.subr \
- floppy.subr ftp.subr http.subr httpproxy.subr network.subr \
+ http.subr httpproxy.subr network.subr \
nfs.subr options.subr tcpip.subr ufs.subr usb.subr wlan.subr
.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/share/media/Makefile.depend b/usr.sbin/bsdconfig/share/media/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/share/media/Makefile.depend
+++ b/usr.sbin/bsdconfig/share/media/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/share/media/any.subr b/usr.sbin/bsdconfig/share/media/any.subr
index 516d2d2bd4ba..2c6720be364d 100644
--- a/usr.sbin/bsdconfig/share/media/any.subr
+++ b/usr.sbin/bsdconfig/share/media/any.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_ANY_SUBR" ]; then _MEDIA_ANY_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -35,8 +34,6 @@ f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/media/cdrom.subr
f_include $BSDCFG_SHARE/media/directory.subr
f_include $BSDCFG_SHARE/media/dos.subr
-f_include $BSDCFG_SHARE/media/floppy.subr
-f_include $BSDCFG_SHARE/media/ftp.subr
f_include $BSDCFG_SHARE/media/http.subr
f_include $BSDCFG_SHARE/media/httpproxy.subr
f_include $BSDCFG_SHARE/media/nfs.subr
@@ -71,16 +68,14 @@ f_media_get_type()
local prompt="$msg_choose_installation_media_description"
local menu_list="
'1 $msg_cd_dvd' '$msg_install_from_a_freebsd_cd_dvd'
- '2 $msg_ftp' '$msg_install_from_an_ftp_server'
- '3 $msg_http_proxy'
+ '2 $msg_http_proxy'
'$msg_install_from_an_ftp_server_thru_proxy'
- '4 $msg_http_direct' '$msg_install_from_an_http_server'
- '5 $msg_directory' '$msg_install_from_the_existing_filesystem'
+ '3 $msg_http_direct' '$msg_install_from_an_http_server'
+ '4 $msg_directory' '$msg_install_from_the_existing_filesystem'
'6 $msg_nfs' '$msg_install_over_nfs'
- '7 $msg_dos' '$msg_install_from_a_dos_partition'
- '8 $msg_ufs' '$msg_install_from_a_ufs_partition'
- '9 $msg_floppy' '$msg_install_from_a_floppy_disk_set'
- 'A $msg_usb' '$msg_install_from_a_usb_drive'
+ '6 $msg_dos' '$msg_install_from_a_dos_partition'
+ '7 $msg_ufs' '$msg_install_from_a_ufs_partition'
+ '8 $msg_usb' '$msg_install_from_a_usb_drive'
'X $msg_options' '$msg_view_set_various_media_options'
" # END-QUOTE
local hline="$hline_choose_help_for_more_information_on_media_types"
@@ -122,14 +117,12 @@ f_media_get_type()
case "$mtag" in
?" $msg_cd_dvd") f_media_set_cdrom ;;
- ?" $msg_ftp") f_media_set_ftp ;;
?" $msg_http_proxy") f_media_set_http_proxy ;;
?" $msg_http_direct") f_media_set_http ;;
?" $msg_directory") f_media_set_directory ;;
?" $msg_dos") f_media_set_dos ;;
?" $msg_nfs") f_media_set_nfs ;;
?" $msg_ufs") f_media_set_ufs ;;
- ?" $msg_floppy") f_media_set_floppy ;;
?" $msg_usb") f_media_set_usb ;;
?" $msg_options")
f_media_options_menu
diff --git a/usr.sbin/bsdconfig/share/media/cdrom.subr b/usr.sbin/bsdconfig/share/media/cdrom.subr
index bbbd638fec6e..acdf54af9cc3 100644
--- a/usr.sbin/bsdconfig/share/media/cdrom.subr
+++ b/usr.sbin/bsdconfig/share/media/cdrom.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_CDROM_SUBR" ]; then _MEDIA_CDROM_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/media/common.subr b/usr.sbin/bsdconfig/share/media/common.subr
index 0bd420d58b38..5b932ec003e7 100644
--- a/usr.sbin/bsdconfig/share/media/common.subr
+++ b/usr.sbin/bsdconfig/share/media/common.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_COMMON_SUBR" ]; then _MEDIA_COMMON_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/media/directory.subr b/usr.sbin/bsdconfig/share/media/directory.subr
index 004cb74bb07e..ca87173dae1d 100644
--- a/usr.sbin/bsdconfig/share/media/directory.subr
+++ b/usr.sbin/bsdconfig/share/media/directory.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_DIRECTORY_SUBR" ]; then _MEDIA_DIRECTORY_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/media/dos.subr b/usr.sbin/bsdconfig/share/media/dos.subr
index df91aebcd814..802d9e46ac3b 100644
--- a/usr.sbin/bsdconfig/share/media/dos.subr
+++ b/usr.sbin/bsdconfig/share/media/dos.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_DOS_SUBR" ]; then _MEDIA_DOS_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/media/floppy.subr b/usr.sbin/bsdconfig/share/media/floppy.subr
deleted file mode 100644
index bf402e533d33..000000000000
--- a/usr.sbin/bsdconfig/share/media/floppy.subr
+++ /dev/null
@@ -1,229 +0,0 @@
-if [ ! "$_MEDIA_FLOPPY_SUBR" ]; then _MEDIA_FLOPPY_SUBR=1
-#
-# Copyright (c) 2012-2013 Devin Teske
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# $FreeBSD$
-#
-############################################################ INCLUDES
-
-BSDCFG_SHARE="/usr/share/bsdconfig"
-. $BSDCFG_SHARE/common.subr || exit 1
-f_dprintf "%s: loading includes..." media/floppy.subr
-f_include $BSDCFG_SHARE/device.subr
-f_include $BSDCFG_SHARE/dialog.subr
-f_include $BSDCFG_SHARE/media/common.subr
-f_include $BSDCFG_SHARE/struct.subr
-f_include $BSDCFG_SHARE/variable.subr
-
-BSDCFG_LIBE="/usr/libexec/bsdconfig"
-f_include_lang $BSDCFG_LIBE/include/messages.subr
-
-############################################################ GLOBALS
-
-FLOPPY_MOUNTED=
-FLOPPY_DISTWANTED=
-
-############################################################ FUNCTIONS
-
-# f_media_set_floppy
-#
-# Return success if we both found and set the media type to be a floppy.
-#
-f_media_set_floppy()
-{
- f_media_close
-
- local devs ndevs
- f_device_find "" $DEVICE_TYPE_FLOPPY devs
- f_count ndevs $devs
-
- if [ ${ndevs:=0} -eq 0 ]; then
- f_interactive && f_show_msg "$msg_no_floppy_devices_found"
- return $FAILURE
- elif [ $ndevs -eq 1 ]; then
- f_struct_copy $devs device_media
- else
- local dev
- local title="$msg_choose_a_floppy_drive"
- local prompt="$msg_please_select_a_floppy_drive"
- local hline=
-
- dev=$( f_device_menu \
- "$title" "$prompt" "$hline" $DEVICE_TYPE_FLOPPY \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) ||
- return $FAILURE
-
- f_struct_copy "$dev" device_media
- fi
-
- f_struct device_media &&
- device_media unset private
-
- f_struct device_media || return $FAILURE
-}
-
-# f_media_init_floppy $device
-#
-# Initializes the Floppy media device. Returns success if able to mount the
-# Floppy disk device using either mount_msdosfs(8) or mount(8) (tried in that
-# order).
-#
-f_media_init_floppy()
-{
- local funcname=f_media_init_floppy
- local dev="$1" devname err
-
- $dev get devname devname || return $FAILURE
- f_dprintf "Init floppy called for %s distribution. devname=[%s]" \
- "${FLOPPY_DISTWANTED:-some}" "$devname"
-
- if [ "$FLOPPY_MOUNTED" ]; then
- f_dprintf "Floppy device already mounted."
- return $SUCCESS
- fi
-
- local mp
- $dev get private mp
- if [ ! -e "${mp:=$MOUNTPOINT}" ] && ! f_quietly mkdir -p "$mp"; then
- f_show_msg "$msg_unable_to_make_directory_mountpoint" \
- "$mp" "$devname"
- return $FAILURE
- fi
-
- if f_interactive; then
- local desc
- $dev get desc desc
- if [ "$FLOPPY_DISTWANTED" ]; then
- f_show_msg "$msg_please_insert_floppy_in_drive" "$desc"
- else
- f_show_msg "$msg_please_insert_floppy_containing" \
- "$FLOPPY_DISTWANTED" "$desc"
- fi
- fi
-
- if ! {
- f_eval_catch -dk err $funcname mount_msdosfs \
- 'mount_msdosfs -o ro -m 0777 -u 0 -g 0 "%s" "%s"' \
- "$devname" "$mp" ||
- f_eval_catch -dk err $funcname mount \
- 'mount -o ro "%s" "%s"' "$devname" "$mp"
- }; then
- err="${err#mount: }"; err="${err#*: }"
- local name
- $dev get name name
- f_show_msg "$msg_error_mounting_floppy_device" \
- "$name" "$devname" "$mp" "$err"
- return $FAILURE
- fi
- FLOPPY_MOUNTED=1
- FLOPPY_DISTWANTED=
- return $SUCCESS
-}
-
-# f_media_get_floppy $device $file [$probe_type]
-#
-# Returns data from $file on a mounted Floppy disk device. Similar to cat(1).
-# If $probe_type is present and non-NULL, limits retries to zero and returns
-# success if $file exists. If $probe_type is equal to $PROBE_SIZE, prints the
-# size of $file in bytes to standard-out.
-#
-f_media_get_floppy()
-{
- local funcname=f_media_get_floppy
- local dev="$1" file="$2" probe_type="$3"
- local name
-
- $dev get name name
- f_dprintf "f_media_get_floppy: dev=[%s] file=[%s] probe_type=%s" \
- "$name" "$file" "$probe_type"
-
- #
- # floppies don't use f_media_generic_get() because it's too expensive
- # to speculatively open files on a floppy disk. Make user get it
- # right or give up with floppies.
- #
- local mp
- $dev get private mp
- local fp="${mp:=$MOUNTPOINT}/$file"
- if ! [ -f "$fp" -a -r "$fp" ]; then
- local nretries=4
- [ "$probe_type" = "$PROBE_SIZE" ] && echo "-1"
- [ "$probe_type" ] && return $FAILURE
- while ! [ -f "$fp" -a -r "$fp" ]; do
- if [ $nretries -eq 0 ]; then
- f_show_msg "$msg_failed_to_get_floppy_file" \
- "$fp"
- [ "$probe_type" = "$PROBE_SIZE" ] && echo "-1"
- return $FAILURE
- fi
- FLOPPY_DISTWANTED="$fp"
- f_media_shutdown_floppy "$dev"
- f_media_init_floppy "$dev" || return $FAILURE
- nretries=$(( $nretries - 1 ))
- done
- fi
- #
- # If we reach here, $file exists
- #
- if [ "$probe_type" = "$PROBE_SIZE" ]; then
- local size
- f_eval_catch -dk size $funcname stat 'stat -f %%z "%s"' "$fp"
- f_isinteger "$size" || size=-1
- echo "$size"
- fi
- [ "$probe_type" ] && return $SUCCESS
- cat "$fp"
-}
-
-# f_media_shutdown_floppy $device
-#
-# Shuts down the Floppy disk device using umount(8). Return status should be
-# ignored.
-#
-f_media_shutdown_floppy()
-{
- local funcname=f_media_shutdown_floppy
- local dev="$1" err mp
-
- [ "$FLOPPY_MOUNTED" ] || return $FAILURE
-
- $dev get private mp
- if f_eval_catch -d $funcname umount \
- 'umount -f "%s"' "${mp:=$MOUNTPOINT}"
- then
- FLOPPY_MOUNTED=
- if f_interactive && [ "$_systemState" != "fixit" ]; then
- local desc
- $dev get desc desc
- f_show_msg "$msg_you_may_remove_the_floppy" "$desc"
- fi
- fi
-}
-
-############################################################ MAIN
-
-f_dprintf "%s: Successfully loaded." media/floppy.subr
-
-fi # ! $_MEDIA_FLOPPY_SUBR
diff --git a/usr.sbin/bsdconfig/share/media/ftp.subr b/usr.sbin/bsdconfig/share/media/ftp.subr
deleted file mode 100644
index 1f6f216eb0a9..000000000000
--- a/usr.sbin/bsdconfig/share/media/ftp.subr
+++ /dev/null
@@ -1,897 +0,0 @@
-if [ ! "$_MEDIA_FTP_SUBR" ]; then _MEDIA_FTP_SUBR=1
-#
-# Copyright (c) 2012-2013 Devin Teske
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# $FreeBSD$
-#
-############################################################ INCLUDES
-
-BSDCFG_SHARE="/usr/share/bsdconfig"
-. $BSDCFG_SHARE/common.subr || exit 1
-f_dprintf "%s: loading includes..." media/ftp.subr
-f_include $BSDCFG_SHARE/device.subr
-f_include $BSDCFG_SHARE/dialog.subr
-f_include $BSDCFG_SHARE/media/common.subr
-f_include $BSDCFG_SHARE/media/tcpip.subr
-f_include $BSDCFG_SHARE/strings.subr
-f_include $BSDCFG_SHARE/struct.subr
-f_include $BSDCFG_SHARE/variable.subr
-
-BSDCFG_LIBE="/usr/libexec/bsdconfig"
-f_include_lang $BSDCFG_LIBE/include/messages.subr
-
-############################################################ GLOBALS
-
-FTP_SKIP_RESOLV=
-
-URL_MAX=261261 # according to actual fetch(1) test-results
-
-FTP_DIRS="
- .
- releases/$UNAME_P
- snapshots/$UNAME_P
- pub/FreeBSD
- pub/FreeBSD/releases/$UNAME_P
- pub/FreeBSD/snapshots/$UNAME_P
- pub/FreeBSD-Archive/old-releases/$UNAME_P
-" # END-QUOTE
-
-############################################################ FUNCTIONS
-
-# f_dialog_menu_media_ftp
-#
-# Prompt the user to select from a range of ``built-in'' FTP servers or specify
-# their own. If the user makes a choice and doesn't cancel or press Esc, stores
-# the user's choice in VAR_FTP_PATH (see variables.subr) and returns success.
-#
-f_dialog_menu_media_ftp()
-{
- f_dialog_title "$msg_please_select_a_freebsd_ftp_distribution_site"
- local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
- f_dialog_title_restore
- local prompt="$msg_please_select_the_site_closest_to_you_or_other"
- local menu_list="
- '$msg_main_site' 'ftp.freebsd.org'
- 'URL' '$msg_specify_some_other_ftp_site'
- 'IPv6 $msg_main_site' 'ftp.freebsd.org'
- ' IPv6 $msg_france' 'ftp4.fr.freebsd.org'
- ' IPv6 $msg_france #8' 'ftp8.fr.freebsd.org'
- ' IPv6 $msg_ireland' 'ftp3.ie.freebsd.org'
- ' IPv6 $msg_japan' 'ftp2.jp.freebsd.org'
- ' IPv6 $msg_sweden' 'ftp4.se.freebsd.org'
- ' IPv6 $msg_usa' 'ftp4.us.freebsd.org'
- '$msg_primary' 'ftp1.freebsd.org'
- ' $msg_primary #2' 'ftp2.freebsd.org'
- ' $msg_primary #3' 'ftp3.freebsd.org'
- ' $msg_primary #4' 'ftp4.freebsd.org'
- ' $msg_primary #5' 'ftp5.freebsd.org'
- ' $msg_primary #6' 'ftp6.freebsd.org'
- ' $msg_primary #7' 'ftp7.freebsd.org'
- ' $msg_primary #10' 'ftp10.freebsd.org'
- ' $msg_primary #11' 'ftp11.freebsd.org'
- ' $msg_primary #12' 'ftp12.freebsd.org'
- ' $msg_primary #13' 'ftp13.freebsd.org'
- ' $msg_primary #14' 'ftp14.freebsd.org'
- '$msg_australia' 'ftp.au.freebsd.org'
- ' $msg_australia #2' 'ftp2.au.freebsd.org'
- ' $msg_australia #3' 'ftp3.au.freebsd.org'
- '$msg_austria' 'ftp.at.freebsd.org'
- '$msg_brazil' 'ftp2.br.freebsd.org'
- ' $msg_brazil #3' 'ftp3.br.freebsd.org'
- ' $msg_brazil #4' 'ftp4.br.freebsd.org'
- '$msg_bulgaria' 'ftp.bg.freebsd.org'
- '$msg_china' 'ftp.cn.freebsd.org'
- '$msg_czech_republic' 'ftp.cz.freebsd.org'
- '$msg_denmark' 'ftp.dk.freebsd.org'
- '$msg_finland' 'ftp.fi.freebsd.org'
- '$msg_france' 'ftp.fr.freebsd.org'
- ' $msg_france #3' 'ftp3.fr.freebsd.org'
- ' $msg_france #4' 'ftp4.fr.freebsd.org'
- ' $msg_france #5' 'ftp5.fr.freebsd.org'
- ' $msg_france #6' 'ftp6.fr.freebsd.org'
- ' $msg_france #7' 'ftp7.fr.freebsd.org'
- ' $msg_france #8' 'ftp8.fr.freebsd.org'
- '$msg_germany' 'ftp.de.freebsd.org'
- ' $msg_germany #2' 'ftp2.de.freebsd.org'
- ' $msg_germany #4' 'ftp4.de.freebsd.org'
- ' $msg_germany #5' 'ftp5.de.freebsd.org'
- ' $msg_germany #7' 'ftp7.de.freebsd.org'
- ' $msg_germany #8' 'ftp8.de.freebsd.org'
- '$msg_greece' 'ftp.gr.freebsd.org'
- ' $msg_greece #2' 'ftp2.gr.freebsd.org'
- '$msg_ireland' 'ftp3.ie.freebsd.org'
- '$msg_japan' 'ftp.jp.freebsd.org'
- ' $msg_japan #2' 'ftp2.jp.freebsd.org'
- ' $msg_japan #3' 'ftp3.jp.freebsd.org'
- ' $msg_japan #4' 'ftp4.jp.freebsd.org'
- ' $msg_japan #5' 'ftp5.jp.freebsd.org'
- ' $msg_japan #6' 'ftp6.jp.freebsd.org'
- ' $msg_japan #7' 'ftp7.jp.freebsd.org'
- ' $msg_japan #8' 'ftp8.jp.freebsd.org'
- ' $msg_japan #9' 'ftp9.jp.freebsd.org'
- '$msg_korea' 'ftp.kr.freebsd.org'
- ' $msg_korea #2' 'ftp2.kr.freebsd.org'
- '$msg_latvia' 'ftp.lv.freebsd.org'
- '$msg_netherlands' 'ftp.nl.freebsd.org'
- ' $msg_netherlands #2' 'ftp2.nl.freebsd.org'
- '$msg_new_zealand' 'ftp.nz.freebsd.org'
- '$msg_norway' 'ftp.no.freebsd.org'
- '$msg_poland' 'ftp.pl.freebsd.org'
- '$msg_russia' 'ftp.ru.freebsd.org'
- ' $msg_russia #2' 'ftp2.ru.freebsd.org'
- ' $msg_russia #5' 'ftp5.ru.freebsd.org'
- ' $msg_russia #6' 'ftp6.ru.freebsd.org'
- '$msg_slovak_republic' 'ftp.sk.freebsd.org'
- ' $msg_slovak_republic #2' 'ftp2.sk.freebsd.org'
- '$msg_slovenia' 'ftp.si.freebsd.org'
- '$msg_south_africa' 'ftp.za.freebsd.org'
- ' $msg_south_africa #2' 'ftp2.za.freebsd.org'
- ' $msg_south_africa #4' 'ftp4.za.freebsd.org'
- '$msg_sweden' 'ftp.se.freebsd.org'
- ' $msg_sweden #2' 'ftp2.se.freebsd.org'
- ' $msg_sweden #4' 'ftp4.se.freebsd.org'
- '$msg_switzerland' 'ftp.ch.freebsd.org'
- '$msg_taiwan' 'ftp.tw.freebsd.org'
- ' $msg_taiwan #2' 'ftp2.tw.freebsd.org'
- ' $msg_taiwan #3' 'ftp3.tw.freebsd.org'
- ' $msg_taiwan #4' 'ftp4.tw.freebsd.org'
- ' $msg_taiwan #6' 'ftp6.tw.freebsd.org'
- ' $msg_taiwan #11' 'ftp11.tw.freebsd.org'
- '$msg_uk' 'ftp.uk.freebsd.org'
- ' $msg_uk #2' 'ftp2.uk.freebsd.org'
- ' $msg_uk #3' 'ftp3.uk.freebsd.org'
- ' $msg_uk #4' 'ftp4.uk.freebsd.org'
- ' $msg_uk #5' 'ftp5.uk.freebsd.org'
- '$msg_ukraine' 'ftp.ua.freebsd.org'
- '$msg_usa #1' 'ftp1.us.freebsd.org'
- ' $msg_usa #2' 'ftp2.us.freebsd.org'
- ' $msg_usa #3' 'ftp3.us.freebsd.org'
- ' $msg_usa #4' 'ftp4.us.freebsd.org'
- ' $msg_usa #5' 'ftp5.us.freebsd.org'
- ' $msg_usa #6' 'ftp6.us.freebsd.org'
- ' $msg_usa #8' 'ftp8.us.freebsd.org'
- ' $msg_usa #10' 'ftp10.us.freebsd.org'
- ' $msg_usa #11' 'ftp11.us.freebsd.org'
- ' $msg_usa #13' 'ftp13.us.freebsd.org'
- ' $msg_usa #14' 'ftp14.us.freebsd.org'
- ' $msg_usa #15' 'ftp15.us.freebsd.org'
- " # END-QUOTE
- local hline="$msg_select_a_site_thats_close"
-
- local height width rows
- eval f_dialog_menu_size height width rows \
- \"\$title\" \
- \"\$btitle\" \
- \"\$prompt\" \
- \"\$hline\" \
- $menu_list
-
- local mtag
- mtag=$( eval $DIALOG \
- --title \"\$title\" \
- --backtitle \"\$btitle\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --menu \"\$prompt\" \
- $height $width $rows \
- $menu_list \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- ) || return $DIALOG_CANCEL
- f_dialog_data_sanitize mtag
-
- case "$mtag" in
- URL) setvar $VAR_FTP_PATH "other" ;;
- *)
- local value
- value=$( eval f_dialog_menutag2item \"\$mtag\" $menu_list )
- setvar $VAR_FTP_PATH "ftp://$value"
- esac
-
- return $DIALOG_OK
-}
-
-# f_media_set_ftp
-#
-# Return success if we both found and set the media type to be an FTP server.
-# Variables from variable.subr that can be used to script user input:
-#
-# VAR_FTP_PATH
-# Can be a URL (including "ftp://" protocol-prefix) or "other"
-# (user is prompted to enter FTP URL). If a URL, can optionally
-# contain directory prefix after hostname/port. Valid examples
-# include:
-# ftp://myhost
-# ftp://somename:21/pub/
-# ftp://192.168.2.3/pub/
-# ftp://[::1]:21/
-# The default port if not specified is 21.
-# VAR_NAMESERVER [Optional]
-# If set, overrides resolv.conf(5) and sets the nameserver that
-# is used to convert names into addresses (when a name converts
-# into multiple addresses, the first address to successfully
-# connect is used).
-#
-# Meanwhile, the following variables from variable.subr are set after
-# successful execution:
-#
-# VAR_FTP_HOST
-# The FTP host to connect to, parsed from VAR_FTP_PATH. In the
-# example case of IPv6 where VAR_FTP_PATH is "ftp://[::1]", this
-# variable will be set to "::1" (the outer brackets are removed).
-# VAR_FTP_PORT
-# The TCP port to connect to, parsed from VAR_FTP_PATH. Usually
-# 21 unless VAR_FTP_PATH was of one of the following forms:
-# ftp://hostname:OTHER_PORT
-# ftp://hostname:OTHER_PORT/*
-# ftp://ip:OTHER_PORT
-# ftp://ip:OTHER_PORT/*
-# ftp://[ip6]:OTHER_PORT
-# ftp://[ip6]:OTHER_PORT/*
-# VAR_FTP_DIR
-# If VAR_FTP_PATH contained a directory element (e.g.,
-# "ftp://localhost/pub") this variable contains only the
-# directory element (e.g., "/pub").
-#
-f_media_set_ftp()
-{
- f_media_close
-
- local url
- f_getvar $VAR_FTP_PATH url
-
- # If we've been through here before ...
- if f_struct device_network && [ "${url#$msg_other}" ]; then
- f_dialog_yesno "$msg_reuse_old_ftp_site_selection_values" ||
- url=
- fi
-
- if [ ! "$url" ]; then
- f_dialog_menu_media_ftp || return $FAILURE
- f_getvar $VAR_FTP_PATH url
- fi
- [ "$url" ] || return $FAILURE
-
- case "$url" in
- other)
- setvar $VAR_FTP_PATH "ftp://"
- f_variable_get_value $VAR_FTP_PATH \
- "$msg_please_specify_url_of_a_freebsd_distribution"
- f_getvar $VAR_FTP_PATH url
- if [ ! "${url#ftp://}" ]; then
- unset $VAR_FTP_PATH
- return $FAILURE
- fi
- if [ ${#url} -gt ${URL_MAX:-261261} ]; then
- f_show_msg "$msg_length_of_specified_url_is_too_long" \
- ${#url} ${URL_MAX:-261261}
- unset $VAR_FTP_PATH
- return $FAILURE
- fi
- case "$url" in
- ftp://*) : valid URL ;;
- *)
- f_show_msg "$msg_sorry_invalid_url" "$url"
- unset $VAR_FTP_PATH
- return $FAILURE
- esac
- esac
- case "$url" in
- ftp://*) : valid URL ;;
- *)
- f_show_msg "$msg_sorry_invalid_url" "$url"
- unset $VAR_FTP_PATH
- return $FAILURE
- esac
-
- # Set the name of the FTP device to the URL
- f_struct_new DEVICE device_ftp
- device_ftp set name "$url"
-
- if ! f_struct device_network ||
- ! f_dialog_yesno "$msg_youve_already_done_the_network_configuration"
- then
- f_struct device_network &&
- f_device_shutdown device_network
- if ! f_device_select_tcp; then
- unset $VAR_FTP_PATH
- return $FAILURE
- fi
- local dev if
- f_getvar $VAR_NETWORK_DEVICE if
- f_device_find -1 "$if" $DEVICE_TYPE_NETWORK dev
- f_struct_copy "$dev" device_network
- fi
- if ! f_device_init device_network; then
- f_dprintf "f_media_set_ftp: %s" "$msg_net_device_init_failed"
- unset $VAR_FTP_PATH
- return $FAILURE
- fi
-
- local hostname="${url#*://}" port=21 dir=/
- case "$hostname" in
- #
- # The order in-which the below individual cases appear is important!
- #
- "["*"]":*/*) # IPv6 address with port and directory
- f_dprintf "Looks like an IPv6 addr with port/dir: %s" \
- "$hostname"
- hostname="${hostname#\[}"
- port="${hostname#*\]:}"
- port="${port%%[!0-9]*}"
- dir="/${hostname#*/}"
- hostname="${hostname%%\]:*}"
- ;;
- "["*"]":*) # IPv6 address with port
- f_dprintf "Looks like an IPv6 addr with port: %s" "$hostname"
- hostname="${hostname#\[}"
- port="${hostname#*\]:}"
- port="${port%%[!0-9]*}"
- hostname="${hostname%%\]:*}"
- ;;
- "["*"]"/*) # IPv6 address with directory
- f_dprintf "Looks like an IPv6 addr with dir: %s" "$hostname"
- hostname="${hostname#\[}"
- dir="/${hostname#*/}"
- hostname="${hostname%%\]*}"
- ;;
- "["*"]") # IPv6 address
- f_dprintf "Looks like an IPv6 addr: %s" "$hostname"
- hostname="${hostname#\[}"
- hostname="${hostname%\]}"
- ;;
- #
- # ^^^ IPv6 above / DNS Name or IPv4 below vvv
- #
- *:*/*) # DNS name or IPv4 address with port and directory
- f_dprintf "Looks like a %s with port/dir: %s" \
- "DNS name or IPv4 addr" "$hostname"
- port="${hostname#*:}"
- port="${port%%[!0-9]*}"
- dir="/${hostname#*/}"
- hostname="${hostname%%:*}"
- ;;
- *:*) # DNS name or IPv4 address with port
- f_dprintf "Looks like a DNS name or IPv4 addr with port: %s" \
- "$hostname"
- port="${hostname#*:}"
- hostname="${hostname%%:*}"
- ;;
- */*) # DNS name or IPv4 address with directory
- f_dprintf "Looks like a DNS name or IPv4 addr with dir: %s" \
- "$hostname"
- dir="/${hostname#*/}"
- hostname="${hostname%%/*}"
- ;;
- *) # DNS name or IPv4 address
- f_dprintf "Looks like a DNS name or IPv4 addr: %s" "$hostname"
- : leave hostname as-is
- esac
-
- f_dprintf "hostname = \`%s'" "$hostname"
- f_dprintf "dir = \`%s'" "$dir"
- f_dprintf "port \# = \`%d'" "$port"
-
- local ns
- f_getvar $VAR_NAMESERVER ns
- [ "$ns" ] || f_resolv_conf_nameservers ns
- if [ "$ns" -a ! "$FTP_SKIP_RESOLV" ] && ! {
- f_validate_ipaddr "$hostname" ||
- f_validate_ipaddr6 "$hostname"
- }; then
- f_show_info "$msg_looking_up_host" "$hostname"
- f_dprintf "%s: Looking up hostname, %s, using host(1)" \
- "f_media_set_ftp" "$hostname"
- if ! f_quietly f_host_lookup "$hostname"; then
- f_show_msg "$msg_cannot_resolve_hostname" "$hostname"
- f_struct device_network &&
- f_device_shutdown device_network
- f_struct_free device_network
- unset $VAR_FTP_PATH
- return $FAILURE
- fi
- f_dprintf "Found DNS entry for %s successfully." "$hostname"
- fi
-
- setvar $VAR_FTP_HOST "$hostname"
- setvar $VAR_FTP_PORT "$port"
- setvar $VAR_FTP_DIR "$dir"
-
- device_ftp set type $DEVICE_TYPE_FTP
- device_ftp set init f_media_init_ftp
- device_ftp set get f_media_get_ftp
- device_ftp set shutdown f_media_shutdown_ftp
- device_ftp set private device_network
- f_struct_copy device_ftp device_media
- f_struct_free device_ftp
-
- return $SUCCESS
-}
-
-# f_media_set_ftp_active
-#
-# Wrapper to f_media_set_ftp to access FTP servers actively.
-#
-f_media_set_ftp_active()
-{
- setvar $VAR_FTP_STATE "active"
- f_media_set_ftp
-}
-
-# f_media_set_ftp_passive
-#
-# Wrapper to f_media_set_ftp to access FTP servers passively.
-#
-f_media_set_ftp_passive()
-{
- setvar $VAR_FTP_STATE "passive"
- f_media_set_ftp
-}
-
-# f_media_set_ftp_userpass
-#
-# Prompt the user to enter/confirm the username/password variables that will
-# be used to communicate with the FTP servers. Returns success if the user does
-# not cancel or press Esc to either username or password.
-#
-# Variables from variable.subr that can be used to script user input:
-#
-# VAR_FTP_USER
-# The username to send via ftp(1) when connecting to an FTP
-# server.
-# VAR_FTP_PASS
-# The password to send with the above username.
-#
-# Does not prompt for confirmation of values if VAR_NONINTERACTIVE is set (see
-# variable.subr for more information).
-#
-f_media_set_ftp_userpass()
-{
- local user pass
- f_variable_get_value $VAR_FTP_USER \
- "$msg_please_enter_the_username_you_wish_to_login_as"
- f_getvar $VAR_FTP_USER user
- if [ "$user" ]; then
- f_variable_get_value $VAR_FTP_PASS \
- "$msg_please_enter_the_password_for_this_user"
- f_getvar $VAR_FTP_PASS pass
- else
- pass=
- fi
- [ "$pass" ] # Return status
-}
-
-# f_device_network_up $device
-#
-# Brings up attached network device, if any - takes FTP device as arg.
-#
-f_device_network_up()
-{
- local dev="$1" netDev
- f_struct "$dev" || return $FAILURE
- $dev get private netDev || return $SUCCESS # No net == happy net
-debug=1 f_dprintf "netDev=[$netDev]"
- f_device_init $netDev
-}
-
-# f_device_network_down $device
-#
-# Brings down attached network device, if any - takes FTP device as arg.
-#
-f_device_network_down()
-{
- local dev="$1" netDev
- f_struct "$dev" || return $FAILURE
- $dev get private netDev || return $SUCCESS
- f_device_shutdown $netDev
-}
-
-# f_media_init_ftp $device
-#
-# Initializes the FTP media device. Returns success if both able to log into
-# the FTP server and confirm the existence of at least one known release path
-# using ftp(1).
-#
-# Variables from variable.subr used to initialize the connection are as follows
-# (all of which are configured by f_media_set_ftp above):
-#
-# VAR_FTP_PATH
-# The unparsed FTP URL representing the server to contact.
-# Usually "ftp://server" for example. Can contain TCP port number
-# and/or directory path (but should not contain username/password
-# info).
-# VAR_FTP_HOST
-# The FTP host to connect to. Can be an IPv4 address (e.g.,
-# 127.0.0.1), IPv6 address (e.g., ::1), or DNS hostname. Usually
-# set automatically in f_media_set_ftp() by parsing VAR_FTP_PATH.
-# VAR_FTP_PORT
-# The TCP port to connect to. Usually set automatically in
-# f_media_set_ftp() by parsing VAR_FTP_PATH.
-# VAR_FTP_DIR
-# The base FTP directory to use when downloading files from the
-# FTP server. Usually set automatically in f_media_set_ftp() by
-# parsing VAR_FTP_PATH.
-# VAR_FTP_USER [Optional]
-# If unset, defaults to using anonymous access.
-# VAR_FTP_PASS [Optional]
-# If unset, defaults to a sensible value.
-#
-# In addition, the following (managed either manually or by f_media_set_ftp_*):
-#
-# VAR_FTP_STATE
-# Sets FTPMODE for ftp(1) and can be one of:
-# active active mode FTP only
-# auto automatic determination of passive or active
-# (this is the default)
-# gate gate-ftp mode
-# passive passive mode FTP only
-# See ftp(1) for additional information.
-#
-# And last, but not least (managed automatically or manually):
-#
-# VAR_RELNAME
-# Defaults to being set to $(uname -r) but can be overridden.
-# This sets the name of a release to look for as part of a well
-# known set of paths to search for release data once connected
-# via FTP. If set to "__RELEASE" or "any" then the VAR_FTP_DIR is
-# taken as the absolute path to the release and no further
-# searching is done (see FTP_DIRS above in the GLOBALS section
-# for a list of well known paths that are used when searching for
-# a VAR_RELNAME sub-directory).
-#
-f_media_init_ftp()
-{
- local dev="$1"
- local url
-
- $dev get name url
- f_dprintf "Init routine called for FTP device. url=[%s]" "$url"
-
- if [ "$FTP_INITIALIZED" ]; then
- f_dprintf "FTP device already initialized."
- return $SUCCESS
- fi
-
- # If we can't initialize the network, bag it!
- f_device_network_up $dev || return $FAILURE
-
- local cp
- while :; do
- f_getvar $VAR_FTP_PATH cp
- if [ ! "$cp" ]; then
- if ! f_media_set_ftp ||
- ! f_getvar $VAR_FTP_PATH cp ||
- [ ! "$cp" ]
- then
- f_show_msg "$msg_unable_to_get_proper_ftp_path"
- f_device_network_down $dev
- return $FAILURE
- fi
- fi
-
- local ftp_host ftp_dir
- if ! {
- f_getvar $VAR_FTP_HOST ftp_host &&
- f_getvar $VAR_FTP_DIR ftp_dir
- }; then
- f_show_msg "$msg_missing_ftp_host_or_directory"
- f_device_network_down $dev
- return $FAILURE
- fi
-
- local ftp_port
- f_getvar $VAR_FTP_PORT ftp_port
- local host="$ftp_host" port="${ftp_port:+:$ftp_port}"
- case "$host" in *:*) host="[$host]"; esac
-
- local user pass use_anon=
- f_getvar $VAR_FTP_USER user
- if [ ! "$user" ]; then
- user="anonymous"
- use_anon=1
- fi
- if ! f_getvar $VAR_FTP_PASS pass; then
- f_getvar $VAR_HOSTNAME cp
- if f_running_as_init; then
- pass="installer@$cp"
- else
- local name="$( id -un 2> /dev/null )"
- pass="${name:-ftp}@$cp"
- fi
- fi
-
- f_show_info "$msg_logging_in_to_user_at_host" \
- "$user" "$ftp_host"
-
- local userpass=""
- if [ ! "$use_anon" ] && [ "$user" -o "$pass" ]; then
- userpass="$user${pass:+:$( f_uriencode "$pass" )}"
- userpass="$userpass${userpass:+@}"
- fi
-
- local mode rx
- f_getvar $VAR_FTP_STATE mode
-
- if [ "$ftp_dir" ]; then
- if ! rx=$(
- printf 'cd "%s"\npwd\n' "$ftp_dir" | eval \
- FTPMODE=\"\$mode\" \
- ${use_anon:+FTPANONPASS=\"\$pass\"} \
- ftp -V ${use_anon:+-a} \
- \"ftp://\$userpass\$host\$port\" \
- 2>&1
- ); then
- f_show_msg "$msg_couldnt_open_ftp_connection" \
- "$ftp_host" "$rx"
- break # to failure
- fi
- if echo "$rx" | awk -v dir="/${ftp_dir#/}" '
- BEGIN {
- found = 0
- if ( dir != "/" ) sub("/$", "", dir)
- }
- /^Remote directory: / {
- sub(/^[^:]*:[[:space:]]*/, "")
- if ($0 != dir) next
- found = 1; exit
- }
- END { exit ! found }
- '; then
- setvar $VAR_FTP_DIR "$ftp_dir"
- setvar $VAR_FTP_PATH \
- "ftp://$ftp_host/${ftp_dir#/}"
- else
- f_show_msg \
- "$msg_please_check_the_url_and_try_again" \
- "ftp://$ftp_host/${ftp_dir#/}"
- break # to failure
- fi
- fi
-
- #
- # Now that we've verified that the path we're given is ok,
- # let's try to be a bit intelligent in locating the release we
- # are looking for. First off, if the release is specified as
- # "__RELEASE" or "any", then just assume that the current
- # directory is the one we want and give up.
- #
- local rel
- f_getvar $VAR_RELNAME rel
- f_dprintf "f_media_init_ftp: rel=[%s]" "$rel"
-
- case "$rel" in
- __RELEASE|any)
- FTP_INITIALIZED=YES
- return $SUCCESS
- ;;
- *)
- #
- # Ok, since we have a release variable, let's walk
- # through the list of directories looking for a release
- # directory. First successful CWD wins.
- #
- if ! rx=$(
- for dir in $FTP_DIRS; do
- # Avoid confusing some servers
- [ "$dir" = "." ] && continue
- printf 'cd "/%s/%s"\npwd\n' \
- "$dir" "$rel"
- done | eval \
- FTPMODE=\"\$mode\" \
- ${use_anon:+FTPANONPASS=\"\$pass\"} \
- ftp -V ${use_anon:+-a} \
- \"ftp://\$userpass\$host\$port\" \
- 2>&1
- ); then
- f_show_msg "$msg_couldnt_open_ftp_connection" \
- "$ftp_host" "$rx"
- break # to failure
- fi
-
- local fdir
- if fdir=$( echo "$rx" | awk '
- /^Remote directory: / {
- sub(/^[^:]*:[[:space:]]*/, "")
- if ($0 == "/") next
- # Exit after the first dir
- found++; print; exit
- }
- END { exit ! found }
- ' ); then
- setvar $VAR_FTP_DIR "$fdir"
- setvar $VAR_FTP_PATH "ftp://$ftp_host$fdir"
- FTP_INITIALIZED=YES
- return $SUCCESS
- else
- f_yesno "$msg_cant_find_distribution" \
- "$rel" "$ftp_host"
- if [ $? -eq $DIALOG_OK ]; then
- unset $VAR_FTP_PATH
- f_media_set_ftp && continue
- fi
- fi
- esac
- break # to failure
- done
-
- unset FTP_INITIALIZED $VAR_FTP_PATH
- f_device_network_down $dev
- return $FAILURE
-}
-
-# f_media_get_ftp $device $file [$probe_type]
-#
-# Returns data from $file on an FTP server using ftp(1). Please note that
-# $device is unused but must be present (even if null). Information is instead
-# gathered from the environment. If $probe_type is present and non-NULL,
-# returns success if $file exists. If $probe_type is equal to $PROBE_SIZE,
-# prints the size of $file in bytes to standard-out.
-#
-# Variables from variable.subr used to configure the connection are as follows
-# (all of which are configured by f_media_set_ftp above):
-#
-# VAR_FTP_HOST
-# FTP host to connect to. Can be an IPv4 address, IPv6 address,
-# or DNS hostname of your choice.
-# VAR_FTP_PORT
-# TCP port to connect on; see f_media_set_ftp() above.
-# VAR_FTP_USER [Optional]
-# If unset, defaults to using anonymous access.
-# VAR_FTP_PASS [Optional]
-# If unset, defaults to a sensible value.
-#
-# In addition, the following (managed either manually or by f_media_set_ftp_*):
-#
-# VAR_FTP_STATE
-# Sets FTPMODE for ftp(1) and can be one of:
-# active active mode FTP only
-# auto automatic determination of passive or active
-# (this is the default)
-# gate gate-ftp mode
-# passive passive mode FTP only
-# See ftp(1) for additional information.
-#
-# See variable.subr for additional information.
-#
-# Example usage:
-# f_media_set_ftp
-# f_media_get_ftp media $file
-#
-f_media_get_ftp()
-{
- local funcname=f_media_get_ftp
- local dev="$1" file="$2" probe_type="$3" hosts=
-
- f_dprintf "f_media_get_ftp: dev=[%s] file=[%s] probe_type=%s" \
- "$dev" "$file" "$probe_type"
-
- local ftp_host ftp_port
- f_getvar $VAR_FTP_HOST ftp_host
- f_getvar $VAR_FTP_PORT ftp_port
-
- if [ ! "$FTP_INITIALIZED" ]; then
- f_dprintf "No FTP connection open, can't get file %s" "$file"
- return $FAILURE
- fi
-
- if ! {
- f_validate_ipaddr "$ftp_host" ||
- f_validate_ipaddr6 "$ftp_host" ||
- {
- f_dprintf "%s: Looking up hostname, %s, using host(1)" \
- "f_media_get_ftp" "$ftp_host"
- f_host_lookup "$ftp_host" hosts
- }
- }; then
- # All the above validations failed
- [ "$hosts" ] && f_dialog_msgbox "$hosts"
- return $FAILURE
- elif [ ! "$hosts" ]; then
- # One of the first two validations passed
- hosts="$ftp_host"
- fi
-
- local host connected=
- for host in $hosts; do
- f_quietly nc -nz "$host" "$ftp_port" || continue
- connected=1; break
- done
- if [ ! "$connected" ]; then
- f_show_msg "$msg_couldnt_connect_to_ftp_server %s:%s" \
- "$ftp_host" "$ftp_port"
- return $FAILURE
- fi
-
- local user pass use_anon=
- f_getvar $VAR_FTP_USER user
- if [ ! "$user" ]; then
- user="anonymous"
- use_anon=1
- fi
- if ! f_getvar $VAR_FTP_PASS pass; then
- f_getvar $VAR_HOSTNAME cp
- if f_running_as_init; then
- pass="installer@$cp"
- else
- local name="$( id -un 2> /dev/null )"
- pass="${name:-ftp}@$cp"
- fi
- fi
-
- local userpass=""
- if [ ! "$use_anon" ] && [ "$user" -o "$pass" ]; then
- userpass="$user${pass:+:$( f_uriencode "$pass" )}"
- userpass="$userpass${userpass:+@}"
- fi
-
- local dir mode rx
- f_getvar $VAR_FTP_DIR\#/ dir
- f_getvar $VAR_FTP_STATE mode
-
- local port="${ftp_port:+:$ftp_port}"
- case "$host" in *:*) host="[$host]"; esac
-
- f_dprintf "sending ftp request for: %s" "ftp://$host$port/$dir/$file"
-
- if [ "$probe_type" ]; then
- local url="ftp://$userpass$host$port/$dir/$file" size
- [ "$use_anon" ] && url="ftp://$host$port/$dir/$file"
- if ! f_eval_catch -dk size $funcname fetch \
- 'fetch -s "%s"' "$url" || ! f_isinteger "$size"
- then
- f_dprintf "size request failed!"
- [ "$probe_type" = "$PROBE_SIZE" ] && echo "-1"
- return $FAILURE
- fi
- [ "$probe_type" = "$PROBE_SIZE" ] && echo "$size"
- return $SUCCESS
- fi
-
- eval FTPMODE=\"\$mode\" ${use_anon:+FTPANONPASS=\"\$pass\"} \
- ftp -V ${use_anon:+-a} -o - \
- \"ftp://\$userpass\$host\$port/\$dir/\$file\" 2> /dev/null
- local retval=$?
-
- [ $retval -eq $SUCCESS ] || f_dprintf "request failed!"
- return $retval
-}
-
-# f_media_shutdown_ftp $device
-#
-# Shuts down the FTP device. Return status should be ignored. Note that since
-# we don't maintain an open connection to the FTP server there's nothing to do.
-#
-f_media_shutdown_ftp()
-{
- [ "$FTP_INITIALIZED" ] || return $SUCCESS
-
- unset FTP_INITIALIZED
-}
-
-############################################################ MAIN
-
-f_dprintf "%s: Successfully loaded." media/ftp.subr
-
-fi # ! $_MEDIA_FTP_SUBR
diff --git a/usr.sbin/bsdconfig/share/media/http.subr b/usr.sbin/bsdconfig/share/media/http.subr
index b928f7d6a78f..e23f1abe27db 100644
--- a/usr.sbin/bsdconfig/share/media/http.subr
+++ b/usr.sbin/bsdconfig/share/media/http.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_HTTP_SUBR" ]; then _MEDIA_HTTP_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -77,7 +76,6 @@ f_dialog_menu_media_http()
f_dialog_title_restore
local prompt="$msg_please_select_the_site_closest_to_you_or_other"
local menu_list="
- 'dist $msg_main_site' 'ftp.freebsd.org'
'pkg $msg_main_site' 'pkg.freebsd.org'
'URL' '$msg_specify_some_other_http_site'
" # END-QUOTE
diff --git a/usr.sbin/bsdconfig/share/media/httpproxy.subr b/usr.sbin/bsdconfig/share/media/httpproxy.subr
index 1ef516f76463..442e29404e61 100644
--- a/usr.sbin/bsdconfig/share/media/httpproxy.subr
+++ b/usr.sbin/bsdconfig/share/media/httpproxy.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_HTTPPROXY_SUBR" ]; then _MEDIA_HTTPPROXY_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -32,7 +31,6 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
f_dprintf "%s: loading includes..." media/httpproxy.subr
f_include $BSDCFG_SHARE/dialog.subr
-f_include $BSDCFG_SHARE/media/ftp.subr
f_include $BSDCFG_SHARE/media/tcpip.subr
f_include $BSDCFG_SHARE/variable.subr
diff --git a/usr.sbin/bsdconfig/share/media/network.subr b/usr.sbin/bsdconfig/share/media/network.subr
index 5a03d80e8163..7d0e757b1cdb 100644
--- a/usr.sbin/bsdconfig/share/media/network.subr
+++ b/usr.sbin/bsdconfig/share/media/network.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_NETWORK_SUBR" ]; then _MEDIA_NETWORK_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/media/nfs.subr b/usr.sbin/bsdconfig/share/media/nfs.subr
index d83661f46b69..8c9f8c627433 100644
--- a/usr.sbin/bsdconfig/share/media/nfs.subr
+++ b/usr.sbin/bsdconfig/share/media/nfs.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_NFS_SUBR" ]; then _MEDIA_NFS_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/media/options.subr b/usr.sbin/bsdconfig/share/media/options.subr
index bc9568e65102..0e9e06af6fb2 100644
--- a/usr.sbin/bsdconfig/share/media/options.subr
+++ b/usr.sbin/bsdconfig/share/media/options.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_OPTIONS_SUBR" ]; then _MEDIA_OPTIONS_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -33,7 +32,6 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
f_dprintf "%s: loading includes..." media/options.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/media/any.subr
-f_include $BSDCFG_SHARE/media/ftp.subr
f_include $BSDCFG_SHARE/struct.subr
f_include $BSDCFG_SHARE/variable.subr
@@ -139,11 +137,6 @@ f_media_options_menu()
'$msg_attempt_ipv6_configuration_of_interfaces'"
fi
- f_getvar $VAR_FTP_USER cp
- menu_list="$menu_list
- ' $msg_ftp_username' '$cp'
- '$msg_username_and_password_to_use'"
-
f_getvar $VAR_EDITOR cp
menu_list="$menu_list
' $msg_editor' '$cp' '$msg_which_text_editor_to_use'"
@@ -159,8 +152,6 @@ f_media_options_menu()
$DEVICE_TYPE_UFS|$DEVICE_TYPE_DISK)
cp="$msg_file_system" ;;
$DEVICE_TYPE_DIRECTORY) cp="$msg_directory" ;;
- $DEVICE_TYPE_FLOPPY) cp="$msg_floppy" ;;
- $DEVICE_TYPE_FTP) cp="$msg_ftp" ;;
$DEVICE_TYPE_HTTP_PROXY) cp="$msg_http_proxy" ;;
$DEVICE_TYPE_HTTP) cp="$msg_http_direct" ;;
$DEVICE_TYPE_CDROM) cp="$msg_cdrom" ;;
@@ -286,8 +277,6 @@ f_media_options_menu()
else
export $VAR_TRY_RTSOL="YES"
fi ;;
- " $msg_ftp_username")
- f_media_set_ftp_userpass ;;
" $msg_editor")
f_variable_get_value $VAR_EDITOR \
"$msg_please_specify_the_name_of_the_text_editor"
diff --git a/usr.sbin/bsdconfig/share/media/tcpip.subr b/usr.sbin/bsdconfig/share/media/tcpip.subr
index d149bc6036d1..85e35fd5b272 100644
--- a/usr.sbin/bsdconfig/share/media/tcpip.subr
+++ b/usr.sbin/bsdconfig/share/media/tcpip.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_TCPIP_SUBR" ]; then _MEDIA_TCPIP_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -1030,7 +1029,6 @@ f_host_lookup()
{ f_quietly f_getvar $VAR_HTTP_PATH ||
f_quietly f_getvar $VAR_HTTP_PROXY_PATH
} && __srvtypes="$__srvtypes _http._tcp"
- f_quietly f_getvar $VAR_FTP_PATH && __srvtypes="$__srvtypes _ftp._tcp"
f_quietly f_getvar $VAR_NFS_PATH &&
__srvtypes="$__srvtypes _nfs._tcp _nfs._udp"
diff --git a/usr.sbin/bsdconfig/share/media/ufs.subr b/usr.sbin/bsdconfig/share/media/ufs.subr
index 27e2f275b182..5d30d9a02d2e 100644
--- a/usr.sbin/bsdconfig/share/media/ufs.subr
+++ b/usr.sbin/bsdconfig/share/media/ufs.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_UFS_SUBR" ]; then _MEDIA_UFS_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/media/usb.subr b/usr.sbin/bsdconfig/share/media/usb.subr
index 5ee9bc043800..99efac236a29 100644
--- a/usr.sbin/bsdconfig/share/media/usb.subr
+++ b/usr.sbin/bsdconfig/share/media/usb.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_USB_SUBR" ]; then _MEDIA_USB_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/media/wlan.subr b/usr.sbin/bsdconfig/share/media/wlan.subr
index f25cddff94cd..5847356d1925 100644
--- a/usr.sbin/bsdconfig/share/media/wlan.subr
+++ b/usr.sbin/bsdconfig/share/media/wlan.subr
@@ -24,7 +24,6 @@ if [ ! "$_MEDIA_WLAN_SUBR" ]; then _MEDIA_WLAN_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -781,7 +780,7 @@ f_dialog_scan_wireless()
# f_dialog_wireless_edit $ssid
#
# Display a menu to allow the user to either create a new entry for the
-# wpa_supplicants.conf(5) file, or to edit values for an existing entry.
+# wpa_supplicant.conf(5) file, or to edit values for an existing entry.
#
# If more than one wireless network is found to match $ssid, a sub-menu is
# presented, allowing the user to select the desired network.
@@ -914,7 +913,7 @@ f_dialog_wireless_edit()
#
# XXXDT Unfinished
# This is where we display a menu that edits the entry
- # And then we modify the wpa_supplicants.conf(5) config file
+ # And then we modify the wpa_supplicant.conf(5) config file
# XXXDT Unfinished
#
@@ -1208,7 +1207,7 @@ f_menu_wpa_scan_results()
# f_dialog_menu_wireless_edit
#
-# Display a list of wireless networks configured in wpa_supplicants.conf(5) and
+# Display a list of wireless networks configured in wpa_supplicant.conf(5) and
# (if wpa_supplicant(8) is running) also displays scan results for unconfigured
# wireless networks.
#
@@ -1247,7 +1246,7 @@ f_dialog_menu_wireless_edit()
fi
if [ "$do_parse" -a "$DIALOG_MENU_WLAN_SHOW_CONFIGURED" ]
then
- f_dprintf "$funcname: Parsing wpa_supplicants.conf(5)"
+ f_dprintf "$funcname: Parsing wpa_supplicant.conf(5)"
f_wpa_supplicant_parse "$conf_file" \
WIRELESS_ NWIRELESS_CONFIGS
f_dprintf "%s: Parsed %i wireless configurations" \
@@ -1262,7 +1261,7 @@ f_dialog_menu_wireless_edit()
#
# Add both items scanned from the airwaves and networks
- # parsed from wpa_supplicants.conf(5). Latter items are
+ # parsed from wpa_supplicant.conf(5). Latter items are
# marked, sorted, and added to top of list above the
# former (which are unmarked and sorted separately).
#
diff --git a/usr.sbin/bsdconfig/share/mustberoot.subr b/usr.sbin/bsdconfig/share/mustberoot.subr
index 88ff81868d45..000e6cfb2c6f 100644
--- a/usr.sbin/bsdconfig/share/mustberoot.subr
+++ b/usr.sbin/bsdconfig/share/mustberoot.subr
@@ -24,7 +24,6 @@ if [ ! "$_MUSTBEROOT_SUBR" ]; then _MUSTBEROOT_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/packages/Makefile b/usr.sbin/bsdconfig/share/packages/Makefile
index bc0e59ad63cd..c8e710902bec 100644
--- a/usr.sbin/bsdconfig/share/packages/Makefile
+++ b/usr.sbin/bsdconfig/share/packages/Makefile
@@ -1,6 +1,5 @@
-# $FreeBSD$
FILESDIR= ${SHAREDIR}/bsdconfig/packages
-FILES= categories.subr index.subr musthavepkg.subr packages.subr
+FILES= categories.subr index.awk index.subr musthavepkg.subr packages.subr
.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/share/packages/Makefile.depend b/usr.sbin/bsdconfig/share/packages/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/share/packages/Makefile.depend
+++ b/usr.sbin/bsdconfig/share/packages/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/share/packages/categories.subr b/usr.sbin/bsdconfig/share/packages/categories.subr
index 474c41d948ed..96abaef7f16e 100644
--- a/usr.sbin/bsdconfig/share/packages/categories.subr
+++ b/usr.sbin/bsdconfig/share/packages/categories.subr
@@ -24,7 +24,6 @@ if [ ! "$_PACKAGES_CATEGORIES_SUBR" ]; then _PACKAGES_CATEGORIES_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/packages/index.awk b/usr.sbin/bsdconfig/share/packages/index.awk
new file mode 100644
index 000000000000..f22aa150bd63
--- /dev/null
+++ b/usr.sbin/bsdconfig/share/packages/index.awk
@@ -0,0 +1,98 @@
+function _asorti(src, dest)
+{
+ k = nitems = 0
+
+ # Copy src indices to dest and calculate array length
+ for (i in src) dest[++nitems] = i
+
+ # Sort the array of indices (dest) using insertion sort method
+ for (i = 1; i <= nitems; k = i++)
+ {
+ idx = dest[i]
+ while ((k > 0) && (dest[k] > idx))
+ {
+ dest[k+1] = dest[k]
+ k--
+ }
+ dest[k+1] = idx
+ }
+
+ return nitems
+}
+
+function print_category(category, npkgs, desc)
+{
+ cat = category
+ # Accent the category if the first page has been
+ # cached (also acting as a visitation indicator)
+ if ( ENVIRON["_index_page_" varcat "_1"] )
+ cat = cat "*"
+ printf "'\''%s'\'' '\''%s " packages "'\'' '\''%s'\''\n",
+ cat, npkgs, desc >>tmpfile
+}
+
+BEGIN{
+ cnt=0
+ div=int(npkg / 100)
+ last=0
+ prefix = ""
+}
+{
+ cnt+=1
+ i = int(cnt / div)
+ if (i > last) {
+ last = i
+ print "XXX"
+ print i
+ print msg
+ print "XXX"
+ fflush("/dev/stdout");
+ }
+ varpkg = $1
+ gsub("[^" valid_chars "]", "_", varpkg)
+ print "_categories_" varpkg "=\"" $7 "\"" >> tmpfile
+ split($7, pkg_categories, /[[:space:]]+/)
+ for (pkg_category in pkg_categories)
+ categories[pkg_categories[pkg_category]]++
+ print "_rundeps_" varpkg "=\"" $9 "\"" >> tmpfile
+
+}
+END {
+ n = _asorti(categories, categories_sorted)
+ # Produce package counts for each category
+ for (i = 1; i <= n; i++)
+ {
+ cat = varcat = categories_sorted[i]
+ npkgs = categories[cat]
+ gsub("[^" valid_chars "]", "_", varcat)
+ print "_npkgs_" varcat "=\"" npkgs "\"" >>tmpfile
+ }
+ #
+ # Create menu list and generate list of categories at same time
+ print "CATEGORY_MENU_LIST=\"" >>tmpfile
+ print_category(msg_all, npkg, msg_all_desc)
+ category_list = ""
+ for (i = 1; i <= n; i++)
+ {
+ cat = varcat = categories_sorted[i]
+ npkgs = categories[cat]
+ cur_prefix = tolower(substr(cat, 1, 1))
+ if ( prefix != cur_prefix )
+ prefix = cur_prefix
+ else
+ cat = " " cat
+ gsub("[^" valid_chars "]", "_", varcat)
+ desc = ENVIRON["_category_" varcat]
+ if ( ! desc ) desc = default_desc
+ print_category(cat, npkgs, desc)
+ category_list = category_list " " cat
+ }
+ print "\"" >>tmpfile
+
+ # Produce the list of categories (calculated in above block)
+ sub(/^ /, "", category_list)
+ print "PACKAGE_CATEGORIES=\"" category_list "\"" >> tmpfile
+ print "_npkgs=\""npkg"\"" >>tmpfile
+
+ print "EOF"
+}
diff --git a/usr.sbin/bsdconfig/share/packages/index.subr b/usr.sbin/bsdconfig/share/packages/index.subr
index 95260da0de05..04f28603426b 100644
--- a/usr.sbin/bsdconfig/share/packages/index.subr
+++ b/usr.sbin/bsdconfig/share/packages/index.subr
@@ -24,7 +24,6 @@ if [ ! "$_PACKAGES_INDEX_SUBR" ]; then _PACKAGES_INDEX_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -91,11 +90,6 @@ f_index_initialize()
case "$__type" in
$DEVICE_TYPE_DIRECTORY)
__site="file://$__data/packages/$PKG_ABI" ;;
- $DEVICE_TYPE_FLOPPY)
- __site="file://${__data:-$MOUNTPOINT}/packages/$PKG_ABI" ;;
- $DEVICE_TYPE_FTP)
- f_getvar $VAR_FTP_PATH __site
- __site="$__site/packages/$PKG_ABI" ;;
$DEVICE_TYPE_HTTP)
f_getvar $VAR_HTTP_PATH __site
__site="$__site/$PKG_ABI/latest" ;;
@@ -152,7 +146,7 @@ f_index_initialize()
# one populate the environment from the on-disk
# cache and provide success exit status.
#
- if [ "$digest" = "$__sqlite_digest" ]; then
+ if [ "$digest" = "#$__sqlite_digest" ]; then
cat
exit $SUCCESS
else
@@ -177,24 +171,27 @@ f_index_initialize()
# If we reach this point, we need to generate the data from scratch
#
- eval "$__var_to_set"='$( pkg rquery -I | (
- exec 2<&1; dpv -ko /dev/stderr >&$TERMINAL_STDOUT_PASSTHRU \
- -b "$DIALOG_BACKTITLE" \
- -- "$msg_generating_index_from_pkg_database"
- ) | sort )'
-
- #
- # Attempt to create the persistent on-disk cache
- #
-
# Create a new temporary file to write to
local __tmpfile
if f_eval_catch -dk __tmpfile $__funcname mktemp \
- 'mktemp -t "%s"' "$pgm"
- then
+ 'mktemp -t "%s"' "$pgm"; then
+ local _npkg
# Write the temporary file contents
- echo "$__sqlite_digest" > "$__tmpfile"
- debug= f_getvar "$__var_to_set" >> "$__tmpfile"
+ echo "#$__sqlite_digest" > "$__tmpfile"
+ f_eval_catch -k _npkg $__funcname pkg \
+ "pkg stat -r | awk '%s'" '/Packages available/ { print $3 }'
+ pkg rquery -I | awk -v npkg=$_npkg \
+ -v msg="$msg_generating_index_from_pkg_database" \
+ -v tmpfile="$__tmpfile" \
+ -v valid_chars="$VALID_VARNAME_CHARS" \
+ -v default_desc="$msg_no_description_provided" \
+ -v packages="$msg_packages" \
+ -v msg_all="$msg_all" \
+ -v msg_all_desc="$msg_all_desc" \
+ -F "|" \
+ -f $BSDCFG_SHARE/packages/index.awk | \
+ $DIALOG --backtitle "$DIALOG_BACKTITLE" \
+ --gauge "$msg_generating_index_from_pkg_database" 0 0
# Finally, move the temporary file into place
case "$PACKAGES_INDEX_CACHEFILE" in
@@ -203,10 +200,13 @@ f_index_initialize()
esac
f_eval_catch -d $__funcname mv 'mv -f "%s" "%s"' \
"$__tmpfile" "$PACKAGES_INDEX_CACHEFILE"
+ else
+ return $FAILURE
fi
if ! f_index_read "$__var_to_set"; then
- f_show_err "$msg_io_or_format_error_on_index_file"
+ f_show_err \
+ "$msg_io_or_format_error_on_index_file"
return $FAILURE
fi
@@ -240,98 +240,7 @@ f_index_read()
export VALID_VARNAME_CHARS
export msg_packages
- eval "$( debug= f_getvar "$var_to_get" | awk -F'|' '
- function _asorti(src, dest)
- {
- k = nitems = 0
-
- # Copy src indices to dest and calculate array length
- for (i in src) dest[++nitems] = i
-
- # Sort the array of indices (dest) using insertion sort method
- for (i = 1; i <= nitems; k = i++)
- {
- idx = dest[i]
- while ((k > 0) && (dest[k] > idx))
- {
- dest[k+1] = dest[k]
- k--
- }
- dest[k+1] = idx
- }
-
- return nitems
- }
- function print_category(category, npkgs, desc)
- {
- cat = category
- # Accent the category if the first page has been
- # cached (also acting as a visitation indicator)
- if ( ENVIRON["_index_page_" varcat "_1"] )
- cat = cat "*"
- printf "'\''%s'\'' '\''%s " packages "'\'' '\''%s'\''\n",
- cat, npkgs, desc
- }
- BEGIN {
- valid_chars = ENVIRON["VALID_VARNAME_CHARS"]
- default_desc = ENVIRON["msg_no_description_provided"]
- packages = ENVIRON["msg_packages"]
- tpkgs = 0
- prefix = ""
- }
- {
- tpkgs++
- varpkg = $1
- gsub("[^" valid_chars "]", "_", varpkg)
- print "_categories_" varpkg "=\"" $7 "\""
- split($7, pkg_categories, /[[:space:]]+/)
- for (pkg_category in pkg_categories)
- categories[pkg_categories[pkg_category]]++
- print "_rundeps_" varpkg "=\"" $9 "\""
- }
- END {
- print "_npkgs=" tpkgs # For convenience, total package count
-
- n = _asorti(categories, categories_sorted)
-
- # Produce package counts for each category
- for (i = 1; i <= n; i++)
- {
- cat = varcat = categories_sorted[i]
- npkgs = categories[cat]
- gsub("[^" valid_chars "]", "_", varcat)
- print "_npkgs_" varcat "=\"" npkgs "\""
- }
-
- # Create menu list and generate list of categories at same time
- print "CATEGORY_MENU_LIST=\""
- print_category(ENVIRON["msg_all"], tpkgs,
- ENVIRON["msg_all_desc"])
- category_list = ""
- for (i = 1; i <= n; i++)
- {
- cat = varcat = categories_sorted[i]
- npkgs = categories[cat]
- cur_prefix = tolower(substr(cat, 1, 1))
- if ( prefix != cur_prefix )
- prefix = cur_prefix
- else
- cat = " " cat
- gsub("[^" valid_chars "]", "_", varcat)
- desc = ENVIRON["_category_" varcat]
- if ( ! desc ) desc = default_desc
- print_category(cat, npkgs, desc)
- category_list = category_list " " cat
- }
- print "\""
-
- # Produce the list of categories (calculated in above block)
- sub(/^ /, "", category_list)
- print "PACKAGE_CATEGORIES=\"" category_list "\""
-
- }' | ( exec 2<&1; dpv -ko /dev/stderr >&$TERMINAL_STDOUT_PASSTHRU \
- -b "$DIALOG_BACKTITLE" -- "$msg_reading_package_index_data"
- ) )" # End-Quote
+ . $PACKAGES_INDEX_CACHEFILE
}
# f_index_extract_pages $var_to_get $var_basename $pagesize [$category]
@@ -348,19 +257,14 @@ f_index_read()
f_index_extract_pages()
{
local var_to_get="${1:-PACKAGE_INDEX}" var_basename="$2" pagesize="$3"
- local category="$4" # Optional
eval "$(
debug= f_getvar "$var_to_get" | awk -F'|' \
- -v cat="$category" \
-v pagesize="$pagesize" \
- -v var_basename="$var_basename" \
- -v i18n_all="$msg_all" '
+ -v var_basename="$var_basename" ' \
BEGIN { n = page = 0 }
/'\''/{ gsub(/'\''/, "'\''\\'\'\''") }
{
- if ( cat !~ "(^$|^" i18n_all "$)" && $7 !~ \
- "(^|[[:space:]])" cat "([[:space:]]|$)" ) next
starting_new_page = (n++ == (pagesize * page))
if ( starting_new_page )
printf "%s%s", ( n > 1 ? "'\''\n" : "" ),
diff --git a/usr.sbin/bsdconfig/share/packages/musthavepkg.subr b/usr.sbin/bsdconfig/share/packages/musthavepkg.subr
index b336d26d9c2e..0a1026afe86c 100644
--- a/usr.sbin/bsdconfig/share/packages/musthavepkg.subr
+++ b/usr.sbin/bsdconfig/share/packages/musthavepkg.subr
@@ -24,7 +24,6 @@ if [ ! "$_PACKAGES_MUSTHAVEPKG_SUBR" ]; then _PACKAGES_MUSTHAVEPKG_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -45,26 +44,16 @@ f_include $BSDCFG_SHARE/mustberoot.subr
f_musthavepkg_init()
{
local funcname=f_musthavepkg_init
- local pkg_abi_awk=' # BEGIN-AWK
- $1 ~ /^ABI/ && $0 = $NF, sub(/^"/, "") && sub(/".*/, "") {
- print; found = 1; exit
- } END { exit ! found }
- ' # END-AWK
- if [ "$PKG_ABI" ]; then # Already set
- f_dprintf "PKG_ABI=[%s]" "$PKG_ABI"
- export PKG_ABI
- f_quietly pkg -N -vv # return status (pkg(8) functional?)
- return $?
- fi
-
- # Attempt to get PKG_ABI without prematurely bootstrapping pkg(8)
- if f_eval_catch -k PKG_ABI $funcname pkg \
- "pkg -N -vv | awk '%s'" "$pkg_abi_awk"
- then
- f_dprintf "PKG_ABI=[%s]" "$PKG_ABI"
- export PKG_ABI
- return $SUCCESS
+ if f_quietly pkg -N; then
+ if [ -n "$PKG_ABI" ]; then
+ export PKG_ABI
+ return $SUCCESS
+ fi
+ if f_eval_catch -k PKG_ABI $funcname pkg "pkg config abi"; then
+ export PKG_ABI
+ return $SUCCESS
+ fi
fi
# pkg(8) not yet bootstrapped; ask for permission unless nonInteractive
@@ -75,10 +64,10 @@ f_musthavepkg_init()
# Bootstrap pkg(8)
f_dialog_info "$msg_bootstrapping_pkg"
- f_eval_catch -k PKG_ABI $funcname pkg \
- "ASSUME_ALWAYS_YES=1 pkg -vv | awk '%s'" "$pkg_abi_awk" ||
+ f_eval_catch $funcname pkg \
+ "pkg bootstrap -y" ||
f_die 1 "$msg_must_have_pkg_to_execute" "$pgm"
-
+ f_eval_catch -k PKG_ABI $funcname pkg "pkg config abi"
f_dprintf "PKG_ABI=[%s]" "$PKG_ABI"
export PKG_ABI
return $SUCCESS
diff --git a/usr.sbin/bsdconfig/share/packages/packages.subr b/usr.sbin/bsdconfig/share/packages/packages.subr
index a22edd8bbb27..38059d4748a6 100644
--- a/usr.sbin/bsdconfig/share/packages/packages.subr
+++ b/usr.sbin/bsdconfig/share/packages/packages.subr
@@ -24,7 +24,6 @@ if [ ! "$_PACKAGES_PACKAGES_SUBR" ]; then _PACKAGES_PACKAGES_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -379,6 +378,7 @@ f_package_index_get_page()
#
f_package_menu_select()
{
+ local __funcname=f_package_menu_deselect
local category="$1" page="${2:-1}"
local prompt= # Calculated below
local menu_list # Calculated below
@@ -425,8 +425,15 @@ f_package_menu_select()
next_page="$next_page*"
fi
- local index_page
- f_package_index_get_page "$category" $page index_page
+ local index_page __index
+ if [ "$category" = "$msg_all" ]; then
+ f_eval_catch -k __index $__funcname pkg \
+ "pkg rquery -a '%s'" "%n|%o||%c"
+ else
+ f_eval_catch -k __index $__funcname pkg \
+ "pkg rquery -g '%s' '%s/\*'" "%n|%o||%c" "$category"
+ fi
+ f_package_index_get_page "$category" $page index_page __index
menu_list="
${add_prev:+'> $previous_page' '' ${SHOW_DESC:+''}}
diff --git a/usr.sbin/bsdconfig/share/script.subr b/usr.sbin/bsdconfig/share/script.subr
index b562e99b7303..c395fc5395cc 100644
--- a/usr.sbin/bsdconfig/share/script.subr
+++ b/usr.sbin/bsdconfig/share/script.subr
@@ -24,7 +24,6 @@ if [ ! "$_SCRIPT_SUBR" ]; then _SCRIPT_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -172,19 +171,12 @@ f_resword_new mediaGetType f_media_get_type # media/any.subr
f_resword_new mediaSetCDROM f_media_set_cdrom # media/cdrom.subr
f_resword_new mediaSetDOS f_media_set_dos # media/dos.subr
f_resword_new mediaSetDirectory f_media_set_directory # media/directory.subr
-f_resword_new mediaSetFloppy f_media_set_floppy # media/floppy.subr
f_resword_new mediaSetNFS f_media_set_nfs # media/nfs.subr
f_resword_new mediaSetUFS f_media_set_ufs # media/ufs.subr
f_resword_new mediaSetUSB f_media_set_usb # media/usb.subr
f_resword_new optionsEditor f_media_options_menu # media/options.subr
f_resword_new tcpMenuSelect f_dialog_menu_select_tcp # media/tcp.subr
-# media/ftp.subr
-f_resword_new mediaSetFTP f_media_set_ftp
-f_resword_new mediaSetFTPActive f_media_set_ftp_active
-f_resword_new mediaSetFTPPassive f_media_set_ftp_passive
-f_resword_new mediaSetFTPUserPass f_media_set_ftp_userpass
-
# media/http.subr
f_resword_new mediaSetHTTP f_media_set_http
diff --git a/usr.sbin/bsdconfig/share/strings.subr b/usr.sbin/bsdconfig/share/strings.subr
index f33f4df566ad..b926e8cd2c91 100644
--- a/usr.sbin/bsdconfig/share/strings.subr
+++ b/usr.sbin/bsdconfig/share/strings.subr
@@ -24,7 +24,6 @@ if [ ! "$_STRINGS_SUBR" ]; then _STRINGS_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/struct.subr b/usr.sbin/bsdconfig/share/struct.subr
index 78c785fc2b51..87e00e1c8e01 100644
--- a/usr.sbin/bsdconfig/share/struct.subr
+++ b/usr.sbin/bsdconfig/share/struct.subr
@@ -24,7 +24,6 @@ if [ ! "$_STRUCT_SUBR" ]; then _STRUCT_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/sysrc.subr b/usr.sbin/bsdconfig/share/sysrc.subr
index 11298f00f47a..5d2a3cd97f7c 100644
--- a/usr.sbin/bsdconfig/share/sysrc.subr
+++ b/usr.sbin/bsdconfig/share/sysrc.subr
@@ -24,7 +24,6 @@ if [ ! "$_SYSRC_SUBR" ]; then _SYSRC_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/share/variable.subr b/usr.sbin/bsdconfig/share/variable.subr
index c453f674ee57..2a81200e8d01 100644
--- a/usr.sbin/bsdconfig/share/variable.subr
+++ b/usr.sbin/bsdconfig/share/variable.subr
@@ -24,7 +24,6 @@ if [ ! "$_VARIABLE_SUBR" ]; then _VARIABLE_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -112,8 +111,6 @@ f_variable_set_defaults()
# Initialize various user-edittable values to their defaults
#
setvar $VAR_EDITOR "${EDITOR:-/usr/bin/ee}"
- setvar $VAR_FTP_STATE "auto"
- setvar $VAR_FTP_USER "ftp"
setvar $VAR_HOSTNAME "$( hostname )"
setvar $VAR_MEDIA_TIMEOUT "300"
setvar $VAR_NFS_SECURE "NO"
@@ -129,8 +126,6 @@ f_variable_set_defaults()
local var
for var in \
$VAR_EDITOR \
- $VAR_FTP_STATE \
- $VAR_FTP_USER \
$VAR_HOSTNAME \
$VAR_MEDIA_TIMEOUT \
$VAR_NFS_SECURE \
@@ -233,13 +228,6 @@ f_variable_new VAR_DIRECTORY_PATH _directoryPath
f_variable_new VAR_DOMAINNAME domainname
f_variable_new VAR_EDITOR editor
f_variable_new VAR_EXTRAS ifconfig_
-f_variable_new VAR_FTP_DIR ftpDirectory
-f_variable_new VAR_FTP_HOST ftpHost
-f_variable_new VAR_FTP_PASS ftpPass
-f_variable_new VAR_FTP_PATH _ftpPath
-f_variable_new VAR_FTP_PORT ftpPort
-f_variable_new VAR_FTP_STATE ftpState
-f_variable_new VAR_FTP_USER ftpUser
f_variable_new VAR_GATEWAY defaultrouter
f_variable_new VAR_GROUP group
f_variable_new VAR_GROUP_GID groupGid
diff --git a/usr.sbin/bsdconfig/startup/INDEX b/usr.sbin/bsdconfig/startup/INDEX
index afad3483313a..28bb14edcb2a 100644
--- a/usr.sbin/bsdconfig/startup/INDEX
+++ b/usr.sbin/bsdconfig/startup/INDEX
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/startup/Makefile b/usr.sbin/bsdconfig/startup/Makefile
index 62a9e7141efc..b9fd43a101e2 100644
--- a/usr.sbin/bsdconfig/startup/Makefile
+++ b/usr.sbin/bsdconfig/startup/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include share
diff --git a/usr.sbin/bsdconfig/startup/Makefile.depend b/usr.sbin/bsdconfig/startup/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/startup/Makefile.depend
+++ b/usr.sbin/bsdconfig/startup/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/startup/USAGE b/usr.sbin/bsdconfig/startup/USAGE
index a06d8af24928..66793a155c5c 100644
--- a/usr.sbin/bsdconfig/startup/USAGE
+++ b/usr.sbin/bsdconfig/startup/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/startup/include/Makefile b/usr.sbin/bsdconfig/startup/include/Makefile
index aab9842035cc..7edef4f2406f 100644
--- a/usr.sbin/bsdconfig/startup/include/Makefile
+++ b/usr.sbin/bsdconfig/startup/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/140.startup/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/startup/include/Makefile.depend b/usr.sbin/bsdconfig/startup/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/startup/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/startup/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/startup/include/messages.subr b/usr.sbin/bsdconfig/startup/include/messages.subr
index 66b8bf6c731d..ed5e79741739 100644
--- a/usr.sbin/bsdconfig/startup/include/messages.subr
+++ b/usr.sbin/bsdconfig/startup/include/messages.subr
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER"
hline_arrows_tab_enter="Press arrows, TAB or ENTER"
diff --git a/usr.sbin/bsdconfig/startup/misc b/usr.sbin/bsdconfig/startup/misc
index 24638bfe7e2c..91d18ccead3f 100755
--- a/usr.sbin/bsdconfig/startup/misc
+++ b/usr.sbin/bsdconfig/startup/misc
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/startup/rcadd b/usr.sbin/bsdconfig/startup/rcadd
index 7b536c2be9c5..8286586222ff 100755
--- a/usr.sbin/bsdconfig/startup/rcadd
+++ b/usr.sbin/bsdconfig/startup/rcadd
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/startup/rcconf b/usr.sbin/bsdconfig/startup/rcconf
index 6a6247b818e4..5b9770b9cc70 100755
--- a/usr.sbin/bsdconfig/startup/rcconf
+++ b/usr.sbin/bsdconfig/startup/rcconf
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/startup/rcdelete b/usr.sbin/bsdconfig/startup/rcdelete
index ccc15ba3380f..1ce41c53a113 100755
--- a/usr.sbin/bsdconfig/startup/rcdelete
+++ b/usr.sbin/bsdconfig/startup/rcdelete
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/startup/rcedit b/usr.sbin/bsdconfig/startup/rcedit
index 54061b54e0ad..63a89533a991 100755
--- a/usr.sbin/bsdconfig/startup/rcedit
+++ b/usr.sbin/bsdconfig/startup/rcedit
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/startup/rcvar b/usr.sbin/bsdconfig/startup/rcvar
index ddca9066e6e3..5e6b89c8070d 100755
--- a/usr.sbin/bsdconfig/startup/rcvar
+++ b/usr.sbin/bsdconfig/startup/rcvar
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/startup/share/Makefile b/usr.sbin/bsdconfig/startup/share/Makefile
index 134914cb0880..b58fbf2f53a8 100644
--- a/usr.sbin/bsdconfig/startup/share/Makefile
+++ b/usr.sbin/bsdconfig/startup/share/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${SHAREDIR}/bsdconfig/startup
FILES= rcconf.subr rcedit.subr rcvar.subr
diff --git a/usr.sbin/bsdconfig/startup/share/Makefile.depend b/usr.sbin/bsdconfig/startup/share/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/startup/share/Makefile.depend
+++ b/usr.sbin/bsdconfig/startup/share/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/startup/share/rcconf.subr b/usr.sbin/bsdconfig/startup/share/rcconf.subr
index 80b6504994cc..71ca6f2fbf71 100644
--- a/usr.sbin/bsdconfig/startup/share/rcconf.subr
+++ b/usr.sbin/bsdconfig/startup/share/rcconf.subr
@@ -24,7 +24,6 @@ if [ ! "$_STARTUP_RCCONF_SUBR" ]; then _STARTUP_RCCONF_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/startup/share/rcedit.subr b/usr.sbin/bsdconfig/startup/share/rcedit.subr
index 1adca477ebf4..a5436e7389e5 100644
--- a/usr.sbin/bsdconfig/startup/share/rcedit.subr
+++ b/usr.sbin/bsdconfig/startup/share/rcedit.subr
@@ -24,7 +24,6 @@ if [ ! "$_STARTUP_RCEDIT_SUBR" ]; then _STARTUP_RCEDIT_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/startup/share/rcvar.subr b/usr.sbin/bsdconfig/startup/share/rcvar.subr
index c1a6ff2443e2..6b9665e5d47c 100644
--- a/usr.sbin/bsdconfig/startup/share/rcvar.subr
+++ b/usr.sbin/bsdconfig/startup/share/rcvar.subr
@@ -24,7 +24,6 @@ if [ ! "$_STARTUP_RCVAR_SUBR" ]; then _STARTUP_RCVAR_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/startup/startup b/usr.sbin/bsdconfig/startup/startup
index 17755d120852..458a01d26f3b 100755
--- a/usr.sbin/bsdconfig/startup/startup
+++ b/usr.sbin/bsdconfig/startup/startup
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/timezone/INDEX b/usr.sbin/bsdconfig/timezone/INDEX
index 67fc50b0dcb6..50ac8174d442 100644
--- a/usr.sbin/bsdconfig/timezone/INDEX
+++ b/usr.sbin/bsdconfig/timezone/INDEX
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/timezone/Makefile b/usr.sbin/bsdconfig/timezone/Makefile
index 1569e7e49569..4d01453e4ce7 100644
--- a/usr.sbin/bsdconfig/timezone/Makefile
+++ b/usr.sbin/bsdconfig/timezone/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include share
diff --git a/usr.sbin/bsdconfig/timezone/Makefile.depend b/usr.sbin/bsdconfig/timezone/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/timezone/Makefile.depend
+++ b/usr.sbin/bsdconfig/timezone/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/timezone/USAGE b/usr.sbin/bsdconfig/timezone/USAGE
index 6dbe96d3997d..6a0765e673b6 100644
--- a/usr.sbin/bsdconfig/timezone/USAGE
+++ b/usr.sbin/bsdconfig/timezone/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [-ehnrSsvX] [-C chroot_dir] [zinfo_file | zinfo_name]
OPTIONS:
diff --git a/usr.sbin/bsdconfig/timezone/include/Makefile b/usr.sbin/bsdconfig/timezone/include/Makefile
index 8fc6dfc84535..1137f01da109 100644
--- a/usr.sbin/bsdconfig/timezone/include/Makefile
+++ b/usr.sbin/bsdconfig/timezone/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/090.timezone/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/timezone/include/Makefile.depend b/usr.sbin/bsdconfig/timezone/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/timezone/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/timezone/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/timezone/include/messages.subr b/usr.sbin/bsdconfig/timezone/include/messages.subr
index 6a7f045cd4f2..a37e5a43c17c 100644
--- a/usr.sbin/bsdconfig/timezone/include/messages.subr
+++ b/usr.sbin/bsdconfig/timezone/include/messages.subr
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
continent_africa_title="Africa"
continent_america_title="America -- North and South"
diff --git a/usr.sbin/bsdconfig/timezone/share/Makefile b/usr.sbin/bsdconfig/timezone/share/Makefile
index 166fb1020d29..1a9557a1c101 100644
--- a/usr.sbin/bsdconfig/timezone/share/Makefile
+++ b/usr.sbin/bsdconfig/timezone/share/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${SHAREDIR}/bsdconfig/timezone
FILES= continents.subr countries.subr iso3166.subr menus.subr \
diff --git a/usr.sbin/bsdconfig/timezone/share/Makefile.depend b/usr.sbin/bsdconfig/timezone/share/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/timezone/share/Makefile.depend
+++ b/usr.sbin/bsdconfig/timezone/share/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/timezone/share/continents.subr b/usr.sbin/bsdconfig/timezone/share/continents.subr
index 764f33fc6c50..8cdf4bf1645d 100644
--- a/usr.sbin/bsdconfig/timezone/share/continents.subr
+++ b/usr.sbin/bsdconfig/timezone/share/continents.subr
@@ -24,7 +24,6 @@ if [ ! "$_TIMEZONE_CONTINENTS_SUBR" ]; then _TIMEZONE_CONTINENTS_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/timezone/share/countries.subr b/usr.sbin/bsdconfig/timezone/share/countries.subr
index 8958e877c3d8..1eaf34354736 100644
--- a/usr.sbin/bsdconfig/timezone/share/countries.subr
+++ b/usr.sbin/bsdconfig/timezone/share/countries.subr
@@ -24,7 +24,6 @@ if [ ! "$_TIMEZONE_COUNTRIES_SUBR" ]; then _TIMEZONE_COUNTRIES_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ FUNCTIONS
diff --git a/usr.sbin/bsdconfig/timezone/share/iso3166.subr b/usr.sbin/bsdconfig/timezone/share/iso3166.subr
index 205d5f5046fd..d68ed141b19d 100644
--- a/usr.sbin/bsdconfig/timezone/share/iso3166.subr
+++ b/usr.sbin/bsdconfig/timezone/share/iso3166.subr
@@ -24,7 +24,6 @@ if [ ! "$_TIMEZONE_ISO3166_SUBR" ]; then _TIMEZONE_ISO3166_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/timezone/share/menus.subr b/usr.sbin/bsdconfig/timezone/share/menus.subr
index ef3979be49a5..268945a73a59 100644
--- a/usr.sbin/bsdconfig/timezone/share/menus.subr
+++ b/usr.sbin/bsdconfig/timezone/share/menus.subr
@@ -24,7 +24,6 @@ if [ ! "$_TIMEZONE_MENUS_SUBR" ]; then _TIMEZONE_MENUS_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/timezone/share/zones.subr b/usr.sbin/bsdconfig/timezone/share/zones.subr
index 59a933013e57..4cad5ef02425 100644
--- a/usr.sbin/bsdconfig/timezone/share/zones.subr
+++ b/usr.sbin/bsdconfig/timezone/share/zones.subr
@@ -24,7 +24,6 @@ if [ ! "$_TIMEZONE_ZONES_SUBR" ]; then _TIMEZONE_ZONES_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/timezone/timezone b/usr.sbin/bsdconfig/timezone/timezone
index a2914429846e..93cb7a8ec153 100755
--- a/usr.sbin/bsdconfig/timezone/timezone
+++ b/usr.sbin/bsdconfig/timezone/timezone
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/ttys/INDEX b/usr.sbin/bsdconfig/ttys/INDEX
index 83ca0211bd80..64d3304cfcd5 100644
--- a/usr.sbin/bsdconfig/ttys/INDEX
+++ b/usr.sbin/bsdconfig/ttys/INDEX
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/ttys/Makefile b/usr.sbin/bsdconfig/ttys/Makefile
index 044fdcf8ca7b..c9e1081c99e0 100644
--- a/usr.sbin/bsdconfig/ttys/Makefile
+++ b/usr.sbin/bsdconfig/ttys/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include
diff --git a/usr.sbin/bsdconfig/ttys/Makefile.depend b/usr.sbin/bsdconfig/ttys/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/ttys/Makefile.depend
+++ b/usr.sbin/bsdconfig/ttys/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/ttys/USAGE b/usr.sbin/bsdconfig/ttys/USAGE
index a06d8af24928..66793a155c5c 100644
--- a/usr.sbin/bsdconfig/ttys/USAGE
+++ b/usr.sbin/bsdconfig/ttys/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/ttys/include/Makefile b/usr.sbin/bsdconfig/ttys/include/Makefile
index 45c72adf4f13..df8b5c262684 100644
--- a/usr.sbin/bsdconfig/ttys/include/Makefile
+++ b/usr.sbin/bsdconfig/ttys/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/150.ttys/include
FILES= messages.subr
diff --git a/usr.sbin/bsdconfig/ttys/include/Makefile.depend b/usr.sbin/bsdconfig/ttys/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/ttys/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/ttys/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/ttys/include/messages.subr b/usr.sbin/bsdconfig/ttys/include/messages.subr
index 296f75602f71..944f5e0fc3a0 100644
--- a/usr.sbin/bsdconfig/ttys/include/messages.subr
+++ b/usr.sbin/bsdconfig/ttys/include/messages.subr
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
msg_configure_ttys="Configure TTYs"
msg_help_text="Configuration of system TTYs requires editing the /etc/ttys file.\nTypical configuration activities might include enabling getty(8)\non the first serial port to allow login via serial console after\nreboot, or to enable xdm. The default ttys file enables normal\nvirtual consoles, and most sites will not need to perform manual\nconfiguration.\n\nTo load /etc/ttys in the editor, select [Yes], otherwise, [No]."
diff --git a/usr.sbin/bsdconfig/ttys/ttys b/usr.sbin/bsdconfig/ttys/ttys
index ed7ba756b785..d751aa1daa2d 100755
--- a/usr.sbin/bsdconfig/ttys/ttys
+++ b/usr.sbin/bsdconfig/ttys/ttys
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/usermgmt/INDEX b/usr.sbin/bsdconfig/usermgmt/INDEX
index 6fc61eaa131f..b22bd1e8e3be 100644
--- a/usr.sbin/bsdconfig/usermgmt/INDEX
+++ b/usr.sbin/bsdconfig/usermgmt/INDEX
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Title that will be shown in the bsdconfig menu.
diff --git a/usr.sbin/bsdconfig/usermgmt/Makefile b/usr.sbin/bsdconfig/usermgmt/Makefile
index 127c874fbaf6..2408331a508f 100644
--- a/usr.sbin/bsdconfig/usermgmt/Makefile
+++ b/usr.sbin/bsdconfig/usermgmt/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= include share
diff --git a/usr.sbin/bsdconfig/usermgmt/Makefile.depend b/usr.sbin/bsdconfig/usermgmt/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/usermgmt/Makefile.depend
+++ b/usr.sbin/bsdconfig/usermgmt/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/usermgmt/USAGE b/usr.sbin/bsdconfig/usermgmt/USAGE
index a06d8af24928..66793a155c5c 100644
--- a/usr.sbin/bsdconfig/usermgmt/USAGE
+++ b/usr.sbin/bsdconfig/usermgmt/USAGE
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
diff --git a/usr.sbin/bsdconfig/usermgmt/groupadd b/usr.sbin/bsdconfig/usermgmt/groupadd
index cba0f2bf7533..60a714fa938c 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupadd
+++ b/usr.sbin/bsdconfig/usermgmt/groupadd
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/usermgmt/groupdel b/usr.sbin/bsdconfig/usermgmt/groupdel
index ea5548970c84..491384675234 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupdel
+++ b/usr.sbin/bsdconfig/usermgmt/groupdel
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/usermgmt/groupedit b/usr.sbin/bsdconfig/usermgmt/groupedit
index 2338d5732270..fb7c4d9c1b9e 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupedit
+++ b/usr.sbin/bsdconfig/usermgmt/groupedit
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/usermgmt/include/Makefile b/usr.sbin/bsdconfig/usermgmt/include/Makefile
index 48396540a331..be07c74cb89b 100644
--- a/usr.sbin/bsdconfig/usermgmt/include/Makefile
+++ b/usr.sbin/bsdconfig/usermgmt/include/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${LIBEXECDIR}/bsdconfig/070.usermgmt/include
FILES= messages.subr usermgmt.hlp
diff --git a/usr.sbin/bsdconfig/usermgmt/include/Makefile.depend b/usr.sbin/bsdconfig/usermgmt/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/usermgmt/include/Makefile.depend
+++ b/usr.sbin/bsdconfig/usermgmt/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/usermgmt/include/messages.subr b/usr.sbin/bsdconfig/usermgmt/include/messages.subr
index f56b8443fbda..621cb8cf4f97 100644
--- a/usr.sbin/bsdconfig/usermgmt/include/messages.subr
+++ b/usr.sbin/bsdconfig/usermgmt/include/messages.subr
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER"
hline_alnum_space_tab_enter="Use alpha-numeric, SPACE, TAB or ENTER"
diff --git a/usr.sbin/bsdconfig/usermgmt/share/Makefile b/usr.sbin/bsdconfig/usermgmt/share/Makefile
index eba7c1cf0eb6..62230e9a0d25 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/Makefile
+++ b/usr.sbin/bsdconfig/usermgmt/share/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
FILESDIR= ${SHAREDIR}/bsdconfig/usermgmt
FILES= group.subr group_input.subr user.subr user_input.subr
diff --git a/usr.sbin/bsdconfig/usermgmt/share/Makefile.depend b/usr.sbin/bsdconfig/usermgmt/share/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/Makefile.depend
+++ b/usr.sbin/bsdconfig/usermgmt/share/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdconfig/usermgmt/share/group.subr b/usr.sbin/bsdconfig/usermgmt/share/group.subr
index e9c8b1637bc5..fb77938f847d 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/group.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/group.subr
@@ -25,7 +25,6 @@ if [ ! "$_USERMGMT_GROUP_SUBR" ]; then _USERMGMT_GROUP_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/usermgmt/share/group_input.subr b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
index 2e8c08647adb..0af624249f7a 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
@@ -25,7 +25,6 @@ if [ ! "$_USERMGMT_GROUP_INPUT_SUBR" ]; then _USERMGMT_GROUP_INPUT_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/usermgmt/share/user.subr b/usr.sbin/bsdconfig/usermgmt/share/user.subr
index 27d9d665319e..7d65264919e6 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/user.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/user.subr
@@ -25,7 +25,6 @@ if [ ! "$_USERMGMT_USER_SUBR" ]; then _USERMGMT_USER_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/usermgmt/share/user_input.subr b/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
index 4f2342ab4b23..37cabb65d191 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
@@ -25,7 +25,6 @@ if [ ! "$_USERMGMT_USER_INPUT_SUBR" ]; then _USERMGMT_USER_INPUT_SUBR=1
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/usermgmt/useradd b/usr.sbin/bsdconfig/usermgmt/useradd
index d372be4694b8..3e8d7d2bcf95 100755
--- a/usr.sbin/bsdconfig/usermgmt/useradd
+++ b/usr.sbin/bsdconfig/usermgmt/useradd
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/usermgmt/userdel b/usr.sbin/bsdconfig/usermgmt/userdel
index 9425c7bb4244..75def79555b2 100755
--- a/usr.sbin/bsdconfig/usermgmt/userdel
+++ b/usr.sbin/bsdconfig/usermgmt/userdel
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/usermgmt/useredit b/usr.sbin/bsdconfig/usermgmt/useredit
index 612f3a653d76..5205344b97da 100755
--- a/usr.sbin/bsdconfig/usermgmt/useredit
+++ b/usr.sbin/bsdconfig/usermgmt/useredit
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdconfig/usermgmt/usermgmt b/usr.sbin/bsdconfig/usermgmt/usermgmt
index 79fbc955133c..abe30198bd3e 100755
--- a/usr.sbin/bsdconfig/usermgmt/usermgmt
+++ b/usr.sbin/bsdconfig/usermgmt/usermgmt
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdinstall/Makefile b/usr.sbin/bsdinstall/Makefile
index 761051a5f48f..ec7ff2aebafa 100644
--- a/usr.sbin/bsdinstall/Makefile
+++ b/usr.sbin/bsdinstall/Makefile
@@ -1,18 +1,16 @@
-# $FreeBSD$
-OSNAME?= FreeBSD
-SUBDIR= distextract distfetch partedit scripts
+SUBDIR= distextract distfetch include partedit runconsoles scripts
SUBDIR_PARALLEL=
+SUBDIR_DEPEND_distextract = include
+SUBDIR_DEPEND_distfetch = include
+SUBDIR_DEPEND_partedit = include
SCRIPTS= bsdinstall
MAN= bsdinstall.8
PACKAGE= bsdinstall
-GENHDRS= opt_osname.h
-SRCS+= ${GENHDRS}
-CLEANFILES+= ${GENHDRS}
-opt_osname.h: .PHONY
- if ! grep -q "^#define OSNAME \"${OSNAME}\"$"" ${.TARGET}; then \
- echo "#define OSNAME \"${OSNAME}\"" > ${.TARGET}; \
- fi
+SCRIPTS+= startbsdinstall
+SCRIPTSDIR_startbsdinstall= ${LIBEXECDIR}/bsdinstall
+
+UPDATE_DEPENDFILE= no
.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdinstall/Makefile.depend b/usr.sbin/bsdinstall/Makefile.depend
index f80275d86ab1..6ce3965b1642 100644
--- a/usr.sbin/bsdinstall/Makefile.depend
+++ b/usr.sbin/bsdinstall/Makefile.depend
@@ -1,11 +1,12 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
+# Not autogenerated - take care
DIRDEPS = \
+ usr.sbin/bsdinstall/distextract \
+ usr.sbin/bsdinstall/distfetch \
+ usr.sbin/bsdinstall/include \
+ usr.sbin/bsdinstall/partedit \
+ usr.sbin/bsdinstall/runconsoles \
+ usr.sbin/bsdinstall/scripts \
.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/usr.sbin/bsdinstall/Makefile.inc b/usr.sbin/bsdinstall/Makefile.inc
index dc4e35b73799..c0907ffac469 100644
--- a/usr.sbin/bsdinstall/Makefile.inc
+++ b/usr.sbin/bsdinstall/Makefile.inc
@@ -1 +1,4 @@
PACKAGE=bsdinstall
+
+CFLAGS+= -I${SRCTOP}/contrib/bsddialog/lib -I${.OBJDIR}/../include
+
diff --git a/usr.sbin/bsdinstall/bsdinstall b/usr.sbin/bsdinstall/bsdinstall
index 1ca03f5c9593..19e27c929aee 100755
--- a/usr.sbin/bsdinstall/bsdinstall
+++ b/usr.sbin/bsdinstall/bsdinstall
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdinstall/bsdinstall.8 b/usr.sbin/bsdinstall/bsdinstall.8
index e2f4f5675ea9..c8bf143322ae 100644
--- a/usr.sbin/bsdinstall/bsdinstall.8
+++ b/usr.sbin/bsdinstall/bsdinstall.8
@@ -23,9 +23,7 @@
.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd March 23, 2022
+.Dd November 18, 2023
.Dt BSDINSTALL 8
.Os
.Sh NAME
@@ -71,7 +69,7 @@ For interactive use, most users will be interested only in the
and
.Cm script
targets.
-.Bl -tag -width ".Cm jail Ar destination"
+.Bl -tag -width "jail destination"
.It Cm auto
Run the standard interactive installation, including disk partitioning.
.It Cm jail Ar destination
@@ -125,9 +123,9 @@ Provides a ZFS-only automatic interactive disk partitioner.
Creates a single
.Ic zpool
with separate datasets for
+.Pa /home ,
.Pa /tmp ,
.Pa /usr ,
-.Pa /usr/home ,
.Pa /usr/ports ,
.Pa /usr/src ,
and
@@ -274,7 +272,7 @@ Many are used internally during installation and have reasonable default values
for most installation scenarios.
Others are set by various interactive user prompts, and can be usefully
overridden when making scripted or customized installers.
-.Bl -tag -width ".Ev BSDINSTALL_DISTSITE"
+.Bl -tag -width "BSDINSTALL_DISTSITE"
.It Ev TMPDIR
The directory to use for temporary files.
Default:
@@ -313,7 +311,9 @@ that prompt for a
mirror will skip that step if this variable is already defined in the
environment.
Example:
-.Pa ftp://ftp.freebsd.org/pub/FreeBSD/releases/powerpc/powerpc64/9.1-RELEASE
+.Pa https://download.freebsd.org/ftp/releases/powerpc/powerpc64/13.1-RELEASE/
+or
+.Pa http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/amd64/12.2-RELEASE/ .
.It Ev BSDINSTALL_CHROOT
The directory into which the distribution files should be unpacked and the
directory at which the root file system of the new system should be mounted.
@@ -323,6 +323,58 @@ Default:
Path to a log file for the installation.
Default:
.Dq Pa $TMPDIR/bsdinstall_log
+.It Ev BSDINSTALL_SKIP_HARDENING
+If not empty, the
+.Cm auto
+target
+will not invoke the
+.Cm hardening
+target.
+.It Ev BSDINSTALL_SKIP_HOSTNAME
+If not empty, the
+.Cm auto
+target
+will not invoke the
+.Cm hostname
+target.
+.It Ev BSDINSTALL_SKIP_KEYMAP
+If not empty, the
+.Cm auto
+target
+will not invoke the
+.Cm keymap
+target.
+.It Ev BSDINSTALL_SKIP_MANUAL
+If not empty, the
+.Cm auto
+target will not offer to open a shell in the new system
+for final manual modifications.
+.It Ev BSDINSTALL_SKIP_SERVICES
+If not empty, the
+.Cm auto
+target
+will not invoke the
+.Cm services
+target.
+.It Ev BSDINSTALL_SKIP_TIME
+If not empty, the
+.Cm auto
+target
+will not invoke the
+.Cm time
+target.
+.It Ev BSDINSTALL_SKIP_USERS
+If not empty, the
+.Cm auto
+target
+will not invoke the
+.Cm adduser
+target.
+.It Ev BSDINSTALL_SKIP_FINALCONFIG
+If not empty, the
+.Cm auto
+target will not show the final configuration dialog,
+where earlier configuration choices can be revisited.
.It Ev BSDINSTALL_TMPETC
Directory where files destined for the new system's
.Pa /etc
@@ -341,6 +393,15 @@ target is executed.
If this directory does not already exist, it will be created.
Default:
.Dq Pa $TMPDIR/bsdinstall_boot
+.It Ev ROOTPASS_ENC
+Encrypted string to set the root password to in the format expected by
+.Xr pw 8
+.Fl H Ar 0 .
+This option is used if both it and
+.Ev ROOTPASS_PLAIN
+are set.
+.It Ev ROOTPASS_PLAIN
+Plain text string to set the root password to.
.It Ev ZFSBOOT_POOL_NAME
Name for the pool containing the base system.
Default:
@@ -372,8 +433,11 @@ or raidz3 (RAID-Z3 Triple Redundancy RAID).
Default:
.Dq stripe
.It Ev ZFSBOOT_FORCE_4K_SECTORS
-Indicates either the pool will use 4K or 512 sectors.
-If this variable is not empty, 4K sectors will be used.
+Controls the minimum sector size of the pool.
+If this variable is not empty, the minimum sector size is 4K.
+If this variable is empty, the minimum sector size is 512.
+Note that the sector size of the pool will always be at least
+the sector size of the backing disks.
Default:
.Dq 1
.It Ev ZFSBOOT_GELI_ENCRYPTION
@@ -587,15 +651,15 @@ is:
/$ZFSBOOT_BEROOT_NAME mountpoint=none
/$ZFSBOOT_BEROOT_NAME/$ZFSBOOT_BOOTFS_NAME mountpoint=/
+# Home directories separated so they are common to all BEs
+/home mountpoint=/home
+
# Compress /tmp, allow exec but not setuid
/tmp mountpoint=/tmp,exec=on,setuid=off
# Do not mount /usr so that 'base' files go to the BEROOT
/usr mountpoint=/usr,canmount=off
-# Home directories separated so they are common to all BEs
-/usr/home # NB: /home is a symlink to /usr/home
-
# Ports tree
/usr/ports setuid=off
diff --git a/usr.sbin/bsdinstall/distextract/Makefile b/usr.sbin/bsdinstall/distextract/Makefile
index 6ae9bb65e8fb..6813c9a79391 100644
--- a/usr.sbin/bsdinstall/distextract/Makefile
+++ b/usr.sbin/bsdinstall/distextract/Makefile
@@ -1,9 +1,8 @@
-# $FreeBSD$
BINDIR= ${LIBEXECDIR}/bsdinstall
PROG= distextract
-CFLAGS+= -I${SRCTOP}/contrib/bsddialog/lib -I${.OBJDIR}/..
LIBADD= archive bsddialog m
+SRCS= distextract.c
MAN=
diff --git a/usr.sbin/bsdinstall/distextract/Makefile.depend b/usr.sbin/bsdinstall/distextract/Makefile.depend
index 78020ffb2489..dd87c979eb80 100644
--- a/usr.sbin/bsdinstall/distextract/Makefile.depend
+++ b/usr.sbin/bsdinstall/distextract/Makefile.depend
@@ -1,26 +1,15 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
- gnu/lib/libdialog \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libarchive \
- lib/libbz2 \
+ lib/libbsddialog \
lib/libc \
lib/libcompiler_rt \
- lib/libdpv \
- lib/libexpat \
- lib/libfigpar \
- lib/liblzma \
- lib/libthr \
- lib/libutil \
- lib/libz \
lib/msun \
- lib/ncurses/ncursesw \
- secure/lib/libcrypto \
+ usr.sbin/bsdinstall/include \
.include <dirdeps.mk>
diff --git a/usr.sbin/bsdinstall/distextract/distextract.c b/usr.sbin/bsdinstall/distextract/distextract.c
index 30400ba0f021..32bd9453eb80 100644
--- a/usr.sbin/bsdinstall/distextract/distextract.c
+++ b/usr.sbin/bsdinstall/distextract/distextract.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Nathan Whitehorn
* Copyright (c) 2014 Devin Teske <dteske@FreeBSD.org>
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <archive.h>
diff --git a/usr.sbin/bsdinstall/distfetch/Makefile b/usr.sbin/bsdinstall/distfetch/Makefile
index 0104df0e3aec..8a9011734592 100644
--- a/usr.sbin/bsdinstall/distfetch/Makefile
+++ b/usr.sbin/bsdinstall/distfetch/Makefile
@@ -1,8 +1,6 @@
-# $FreeBSD$
BINDIR= ${LIBEXECDIR}/bsdinstall
PROG= distfetch
-CFLAGS+= -I${SRCTOP}/contrib/bsddialog/lib -I${.OBJDIR}/..
LIBADD= fetch bsddialog
MAN=
diff --git a/usr.sbin/bsdinstall/distfetch/Makefile.depend b/usr.sbin/bsdinstall/distfetch/Makefile.depend
index c1195d955ced..9e9ac6d1bae8 100644
--- a/usr.sbin/bsdinstall/distfetch/Makefile.depend
+++ b/usr.sbin/bsdinstall/distfetch/Makefile.depend
@@ -1,19 +1,14 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
- gnu/lib/libdialog \
include \
include/xlocale \
lib/${CSU_DIR} \
+ lib/libbsddialog \
lib/libc \
lib/libcompiler_rt \
lib/libfetch \
- lib/msun \
- lib/ncurses/ncursesw \
- secure/lib/libcrypto \
- secure/lib/libssl \
+ usr.sbin/bsdinstall/include \
.include <dirdeps.mk>
diff --git a/usr.sbin/bsdinstall/distfetch/distfetch.c b/usr.sbin/bsdinstall/distfetch/distfetch.c
index 6963ee08968f..c431e187799d 100644
--- a/usr.sbin/bsdinstall/distfetch/distfetch.c
+++ b/usr.sbin/bsdinstall/distfetch/distfetch.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Nathan Whitehorn
* Copyright (c) 2014 Devin Teske <dteske@FreeBSD.org>
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <bsddialog.h>
diff --git a/usr.sbin/bsdinstall/include/Makefile b/usr.sbin/bsdinstall/include/Makefile
new file mode 100644
index 000000000000..15f947defa9b
--- /dev/null
+++ b/usr.sbin/bsdinstall/include/Makefile
@@ -0,0 +1,13 @@
+OSNAME?= FreeBSD
+GENHDRS= opt_osname.h
+SRCS+= ${GENHDRS}
+CLEANFILES+= ${GENHDRS}
+
+opt_osname.h: ${META_NOPHONY}
+ @if ! grep -q "^#define OSNAME \"${OSNAME}\"$"" ${.TARGET} 2> /dev/null; then \
+ echo "#define OSNAME \"${OSNAME}\"" > ${.TARGET}; \
+ fi
+
+MK_STAGING= no
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/portsnap/portsnap/Makefile.depend b/usr.sbin/bsdinstall/include/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/portsnap/portsnap/Makefile.depend
+++ b/usr.sbin/bsdinstall/include/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdinstall/partedit/Makefile b/usr.sbin/bsdinstall/partedit/Makefile
index 96c4ddb53961..397e404a126f 100644
--- a/usr.sbin/bsdinstall/partedit/Makefile
+++ b/usr.sbin/bsdinstall/partedit/Makefile
@@ -1,11 +1,9 @@
-# $FreeBSD$
BINDIR= ${LIBEXECDIR}/bsdinstall
PROG= partedit
LINKS= ${BINDIR}/partedit ${BINDIR}/autopart \
${BINDIR}/partedit ${BINDIR}/scriptedpart
SYMLINKS= ../libexec/bsdinstall/partedit /usr/sbin/sade
-CFLAGS+= -I${SRCTOP}/contrib/bsddialog/lib -I${.OBJDIR}/..
LIBADD+= geom util bsddialog
PARTEDIT_ARCH= ${MACHINE}
diff --git a/usr.sbin/bsdinstall/partedit/Makefile.depend b/usr.sbin/bsdinstall/partedit/Makefile.depend
index 2c3bc47c6d42..68a44a4d87a7 100644
--- a/usr.sbin/bsdinstall/partedit/Makefile.depend
+++ b/usr.sbin/bsdinstall/partedit/Makefile.depend
@@ -1,20 +1,15 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
- gnu/lib/libdialog \
include \
include/xlocale \
lib/${CSU_DIR} \
+ lib/libbsddialog \
lib/libc \
lib/libcompiler_rt \
- lib/libexpat \
lib/libgeom \
- lib/libsbuf \
lib/libutil \
- lib/msun \
- lib/ncurses/ncursesw \
+ usr.sbin/bsdinstall/include \
.include <dirdeps.mk>
diff --git a/usr.sbin/bsdinstall/partedit/diskmenu.c b/usr.sbin/bsdinstall/partedit/diskmenu.c
index 9e16ef96171a..55ef5a200658 100644
--- a/usr.sbin/bsdinstall/partedit/diskmenu.c
+++ b/usr.sbin/bsdinstall/partedit/diskmenu.c
@@ -48,24 +48,24 @@ diskmenu_show(const char *title, const char *text, struct partedit_item *items,
for (i = 0; i < nitems; i++) {
bsditems[i].prefix = "";
bsditems[i].on = false;
- bsditems[i].depth = items[i].indentation;
+ bsditems[i].depth = 2 * items[i].indentation;
/* old menu sets max namelen to 10 */
bsditems[i].name = items[i].name;
humanize_number(size, 7, items[i].size, "B",
HN_AUTOSCALE, HN_DECIMAL);
mp = items[i].mountpoint != NULL ? items[i].mountpoint : "";
- asprintf(__DECONST(char**, &bsditems[i].desc), "%s %-15s %-10s",
- size, items[i].type, mp);
+ asprintf(__DECONST(char**, &bsditems[i].desc),
+ " %-9s %-15s %s", size, items[i].type, mp);
bsditems[i].bottomdesc = "";
}
bsddialog_initconf(&conf);
conf.title = title;
conf.menu.align_left = true;
- conf.text.highlight = true;
+ conf.text.escape = true;
conf.key.f1_message="[\\Z1\\ZbC\\Znreate]: a new partition.\n"
"[\\Z1\\ZbD\\Znelete]: selected partition(s).\n"
- "[\\Z1\\ZbC\\Znhange]: partition type or mountpoint.\n"
+ "[\\Z1\\ZbM\\Znodify]: partition type or mountpoint.\n"
"[\\Z1\\ZbR\\Znevert]: changes to disk setup.\n"
"[\\Z1\\ZbA\\Znuto]: guided partitioning tool.\n"
"[\\Z1\\ZbF\\Zninish]: will ask to apply changes.";
@@ -76,8 +76,8 @@ diskmenu_show(const char *title, const char *text, struct partedit_item *items,
conf.button.cancel_label = "Modify";
conf.button.with_help = true;
conf.button.help_label = "Revert";
- conf.button.generic1_label = "Auto";
- conf.button.generic2_label = "Finish";
+ conf.button.right1_label = "Auto";
+ conf.button.right2_label = "Finish";
conf.button.default_label = "Finish";
output = bsddialog_menu(&conf, text, 20, 0, 10, nitems, bsditems,
focusitem);
@@ -86,5 +86,5 @@ diskmenu_show(const char *title, const char *text, struct partedit_item *items,
free((char *)bsditems[i].desc);
free(bsditems);
- return output;
+ return (output);
}
diff --git a/usr.sbin/bsdinstall/partedit/diskmenu.h b/usr.sbin/bsdinstall/partedit/diskmenu.h
index 77077c8c1e05..9fce2e813214 100644
--- a/usr.sbin/bsdinstall/partedit/diskmenu.h
+++ b/usr.sbin/bsdinstall/partedit/diskmenu.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Nathan Whitehorn
* 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 _PARTEDIT_DISKMENU_H
@@ -35,8 +33,8 @@
#define BUTTON_DELETE BSDDIALOG_EXTRA
#define BUTTON_MODIFY BSDDIALOG_CANCEL
#define BUTTON_REVERT BSDDIALOG_HELP
-#define BUTTON_AUTO BSDDIALOG_GENERIC1
-#define BUTTON_FINISH BSDDIALOG_GENERIC2
+#define BUTTON_AUTO BSDDIALOG_RIGHT1
+#define BUTTON_FINISH BSDDIALOG_RIGHT2
struct partedit_item {
int indentation;
diff --git a/usr.sbin/bsdinstall/partedit/gpart_ops.c b/usr.sbin/bsdinstall/partedit/gpart_ops.c
index 26aedb58ef39..0bcd17950daf 100644
--- a/usr.sbin/bsdinstall/partedit/gpart_ops.c
+++ b/usr.sbin/bsdinstall/partedit/gpart_ops.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Nathan Whitehorn
* 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 <sys/param.h>
@@ -64,12 +62,13 @@ gpart_show_error(const char *title, const char *explanation, const char *errstr)
while (errmsg[0] == ' ')
errmsg++;
if (errmsg[0] != '\0')
- sprintf(message, "%s%s. %s", explanation,
- strerror(error), errmsg);
+ snprintf(message, sizeof(message), "%s%s. %s",
+ explanation, strerror(error), errmsg);
else
- sprintf(message, "%s%s", explanation, strerror(error));
+ snprintf(message, sizeof(message), "%s%s", explanation,
+ strerror(error));
} else {
- sprintf(message, "%s%s", explanation, errmsg);
+ snprintf(message, sizeof(message), "%s%s", explanation, errmsg);
}
bsddialog_initconf(&conf);
@@ -88,12 +87,16 @@ scheme_supports_labels(const char *scheme)
return (0);
}
-static void
-newfs_command(const char *fstype, char *command, int use_default)
+static char *
+newfs_command(const char *fstype, int use_default)
{
struct bsddialog_conf conf;
+ FILE *fp;
+ char *buf;
+ size_t len;
bsddialog_initconf(&conf);
+ fp = open_memstream(&buf, &len);
if (strcmp(fstype, "freebsd-ufs") == 0) {
int i;
@@ -117,21 +120,21 @@ newfs_command(const char *fstype, char *command, int use_default)
choice = bsddialog_checklist(&conf, "", 0, 0, 0,
nitems(items), items, NULL);
if (choice == BSDDIALOG_CANCEL)
- return;
+ goto out;
}
- strcpy(command, "newfs ");
+ fputs("newfs ", fp);
for (i = 0; i < (int)nitems(items); i++) {
if (items[i].on == false)
continue;
if (strcmp(items[i].name, "UFS1") == 0)
- strcat(command, "-O1 ");
+ fputs("-O1 ", fp);
else if (strcmp(items[i].name, "SU") == 0)
- strcat(command, "-U ");
+ fputs("-U ", fp);
else if (strcmp(items[i].name, "SUJ") == 0)
- strcat(command, "-j ");
+ fputs("-j ", fp);
else if (strcmp(items[i].name, "TRIM") == 0)
- strcat(command, "-t ");
+ fputs("-t ", fp);
}
} else if (strcmp(fstype, "freebsd-zfs") == 0) {
int i;
@@ -155,30 +158,31 @@ newfs_command(const char *fstype, char *command, int use_default)
choice = bsddialog_checklist(&conf, "", 0, 0, 0,
nitems(items), items, NULL);
if (choice == BSDDIALOG_CANCEL)
- return;
+ goto out;
}
- strcpy(command, "zpool create -f -m none ");
+ fputs("zpool create -f -m none ", fp);
if (getenv("BSDINSTALL_TMPBOOT") != NULL) {
char zfsboot_path[MAXPATHLEN];
+
snprintf(zfsboot_path, sizeof(zfsboot_path), "%s/zfs",
getenv("BSDINSTALL_TMPBOOT"));
mkdir(zfsboot_path, S_IRWXU | S_IRGRP | S_IXGRP |
S_IROTH | S_IXOTH);
- sprintf(command, "%s -o cachefile=%s/zpool.cache ",
- command, zfsboot_path);
+ fprintf(fp, " -o cachefile=%s/zpool.cache ",
+ zfsboot_path);
}
for (i = 0; i < (int)nitems(items); i++) {
if (items[i].on == false)
continue;
if (strcmp(items[i].name, "fletcher4") == 0)
- strcat(command, "-O checksum=fletcher4 ");
+ fputs("-O checksum=fletcher4 ", fp);
else if (strcmp(items[i].name, "fletcher2") == 0)
- strcat(command, "-O checksum=fletcher2 ");
+ fputs("-O checksum=fletcher2 ", fp);
else if (strcmp(items[i].name, "sha256") == 0)
- strcat(command, "-O checksum=sha256 ");
+ fputs("-O checksum=sha256 ", fp);
else if (strcmp(items[i].name, "atime") == 0)
- strcat(command, "-O atime=off ");
+ fputs("-O atime=off ", fp);
}
} else if (strcmp(fstype, "fat32") == 0 || strcmp(fstype, "efi") == 0 ||
strcmp(fstype, "ms-basic-data") == 0) {
@@ -198,19 +202,19 @@ newfs_command(const char *fstype, char *command, int use_default)
choice = bsddialog_radiolist(&conf, "", 0, 0, 0,
nitems(items), items, NULL);
if (choice == BSDDIALOG_CANCEL)
- return;
+ goto out;
}
- strcpy(command, "newfs_msdos ");
+ fputs("newfs_msdos ", fp);
for (i = 0; i < (int)nitems(items); i++) {
if (items[i].on == false)
continue;
if (strcmp(items[i].name, "FAT32") == 0)
- strcat(command, "-F 32 -c 1");
+ fputs("-F 32 -c 1", fp);
else if (strcmp(items[i].name, "FAT16") == 0)
- strcat(command, "-F 16 ");
+ fputs("-F 16 ", fp);
else if (strcmp(items[i].name, "FAT12") == 0)
- strcat(command, "-F 12 ");
+ fputs("-F 12 ", fp);
}
} else {
if (!use_default) {
@@ -218,8 +222,11 @@ newfs_command(const char *fstype, char *command, int use_default)
bsddialog_msgbox(&conf, "No configurable options exist "
"for this filesystem.", 0, 0);
}
- command[0] = '\0';
}
+
+out:
+ fclose(fp);
+ return (buf);
}
const char *
@@ -257,7 +264,9 @@ parttypemenu:
if (!is_scheme_bootable(items[choice].name)) {
char message[512];
- sprintf(message, "This partition scheme (%s) is not "
+
+ snprintf(message, sizeof(message),
+ "This partition scheme (%s) is not "
"bootable on this platform. Are you sure you want "
"to proceed?", items[choice].name);
conf.button.default_cancel = true;
@@ -292,7 +301,9 @@ schememenu:
if (!is_scheme_bootable(scheme)) {
char message[512];
- sprintf(message, "This partition scheme (%s) is not "
+
+ snprintf(message, sizeof(message),
+ "This partition scheme (%s) is not "
"bootable on this platform. Are you sure you want "
"to proceed?", scheme);
conf.button.default_cancel = true;
@@ -478,10 +489,11 @@ gpart_partcode(struct gprovider *pp, const char *fstype)
}
/* Shell out to gpart for partcode for now */
- sprintf(command, "gpart bootcode -p %s -i %s %s",
+ snprintf(command, sizeof(command), "gpart bootcode -p %s -i %s %s",
partcode_path(scheme, fstype), indexstr, pp->lg_geom->lg_name);
if (system(command) != 0) {
- sprintf(message, "Error installing partcode on partition %s",
+ snprintf(message, sizeof(message),
+ "Error installing partcode on partition %s",
pp->lg_name);
bsddialog_initconf(&conf);
conf.title = "Error";
@@ -541,7 +553,7 @@ gpart_edit(struct gprovider *pp)
const char *errstr, *oldtype, *scheme;
struct partition_metadata *md;
char sizestr[32];
- char newfs[255];
+ char *newfs;
intmax_t idx;
int hadlabel, choice, nitems;
unsigned i;
@@ -641,9 +653,10 @@ gpart_edit(struct gprovider *pp)
items[1].init = sizestr;
editpart:
- conf.form.value_without_ok = true;
+ conf.button.always_active = true;
conf.title = "Edit Partition";
- choice = bsddialog_form(&conf, "", 0, 0, 0, nitems, items);
+ choice = bsddialog_form(&conf, "", 0, 0, 0, nitems, items, NULL);
+ conf.button.always_active = false;
if (choice == BSDDIALOG_CANCEL)
goto endedit;
@@ -652,7 +665,9 @@ editpart:
if (strcmp(items[2].value, "/") == 0 && !is_fs_bootable(scheme,
items[0].value)) {
char message[512];
- sprintf(message, "This file system (%s) is not bootable "
+
+ snprintf(message, sizeof(message),
+ "This file system (%s) is not bootable "
"on this system. Are you sure you want to proceed?",
items[0].value);
conf.button.default_cancel = true;
@@ -688,10 +703,11 @@ editpart:
}
gctl_free(r);
- newfs_command(items[0].value, newfs, 1);
+ newfs = newfs_command(items[0].value, 1);
set_default_part_metadata(pp->lg_name, scheme, items[0].value,
items[2].value, (strcmp(oldtype, items[0].value) != 0) ?
newfs : NULL);
+ free(newfs);
endedit:
if (strcmp(oldtype, items[0].value) != 0 && cp != NULL)
@@ -724,18 +740,16 @@ set_default_part_metadata(const char *name, const char *scheme,
}
if (newfs != NULL && newfs[0] != '\0') {
- md->newfs = malloc(strlen(newfs) + strlen(" /dev/") +
- strlen(mountpoint) + 5 + strlen(name) + 1);
if (strcmp("freebsd-zfs", type) == 0) {
zpool_name = strdup((strlen(mountpoint) == 1) ?
"root" : &mountpoint[1]);
for (i = 0; zpool_name[i] != 0; i++)
if (!isalnum(zpool_name[i]))
zpool_name[i] = '_';
- sprintf(md->newfs, "%s %s /dev/%s", newfs,
+ asprintf(&md->newfs, "%s %s /dev/%s", newfs,
zpool_name, name);
} else {
- sprintf(md->newfs, "%s /dev/%s", newfs, name);
+ asprintf(&md->newfs, "%s /dev/%s", newfs, name);
}
}
}
@@ -772,9 +786,7 @@ set_default_part_metadata(const char *name, const char *scheme,
if (strcmp("freebsd-zfs", type) == 0) {
md->fstab->fs_spec = strdup(zpool_name);
} else {
- md->fstab->fs_spec = malloc(strlen(name) +
- strlen("/dev/") + 1);
- sprintf(md->fstab->fs_spec, "/dev/%s", name);
+ asprintf(&md->fstab->fs_spec, "/dev/%s", name);
}
md->fstab->fs_file = strdup(mountpoint);
/* Get VFS from text after freebsd-, if possible */
@@ -1023,7 +1035,7 @@ gpart_create(struct gprovider *pp, const char *default_type,
struct ggeom *geom;
const char *errstr, *scheme;
char sizestr[32], startstr[32], output[64], *newpartname;
- char newfs[255], options_fstype[64];
+ char *newfs, options_fstype[64];
intmax_t maxsize, size, sector, firstfree, stripe;
uint64_t bytes;
int nitems, choice, junk;
@@ -1124,28 +1136,29 @@ gpart_create(struct gprovider *pp, const char *default_type,
/* Default options */
strncpy(options_fstype, items[0].init,
sizeof(options_fstype));
- newfs_command(options_fstype, newfs, 1);
+ newfs = newfs_command(options_fstype, 1);
init_allocated = false;
addpartform:
if (interactive) {
conf.button.with_extra = true;
conf.button.extra_label = "Options";
- conf.form.value_without_ok = true;
+ conf.button.always_active = true;
conf.title = "Add Partition";
- choice = bsddialog_form(&conf, "", 0, 0, 0, nitems, items);
+ choice = bsddialog_form(&conf, "", 0, 0, 0, nitems, items, NULL);
conf.button.with_extra = false;
conf.button.extra_label = NULL;
- conf.form.value_without_ok = false;
+ conf.button.always_active = false;
switch (choice) {
case BSDDIALOG_OK:
break;
case BSDDIALOG_CANCEL:
return;
case BSDDIALOG_EXTRA: /* Options */
+ free(newfs);
strncpy(options_fstype, items[0].value,
sizeof(options_fstype));
- newfs_command(options_fstype, newfs, 0);
+ newfs = newfs_command(options_fstype, 0);
for (i = 0; i < nitems(items); i++) {
if (init_allocated)
free((char*)items[i].init);
@@ -1167,8 +1180,9 @@ addpartform:
* their choices in favor of the new filesystem's defaults.
*/
if (strcmp(options_fstype, items[0].value) != 0) {
+ free(newfs);
strncpy(options_fstype, items[0].value, sizeof(options_fstype));
- newfs_command(options_fstype, newfs, 1);
+ newfs = newfs_command(options_fstype, 1);
}
size = maxsize;
@@ -1176,7 +1190,8 @@ addpartform:
if (expand_number(items[1].value, &bytes) != 0) {
char error[512];
- sprintf(error, "Invalid size: %s\n", strerror(errno));
+ snprintf(error, sizeof(error), "Invalid size: %s\n",
+ strerror(errno));
conf.title = "Error";
bsddialog_msgbox(&conf, error, 0, 0);
goto addpartform;
@@ -1228,7 +1243,9 @@ addpartform:
/* If this is the root partition, check that this scheme is bootable */
if (strcmp(items[2].value, "/") == 0 && !is_scheme_bootable(scheme)) {
char message[512];
- sprintf(message, "This partition scheme (%s) is not bootable "
+
+ snprintf(message, sizeof(message),
+ "This partition scheme (%s) is not bootable "
"on this platform. Are you sure you want to proceed?",
scheme);
conf.button.default_cancel = true;
@@ -1243,7 +1260,9 @@ addpartform:
if (strcmp(items[2].value, "/") == 0 && !is_fs_bootable(scheme,
items[0].value)) {
char message[512];
- sprintf(message, "This file system (%s) is not bootable "
+
+ snprintf(message, sizeof(message),
+ "This file system (%s) is not bootable "
"on this system. Are you sure you want to proceed?",
items[0].value);
conf.button.default_cancel = true;
@@ -1320,6 +1339,7 @@ addpartform:
else
set_default_part_metadata(newpartname, scheme,
items[0].value, items[2].value, newfs);
+ free(newfs);
for (i = 0; i < nitems(items); i++) {
if (items[i].value != NULL) {
diff --git a/usr.sbin/bsdinstall/partedit/part_wizard.c b/usr.sbin/bsdinstall/partedit/part_wizard.c
index 83fc29eb0359..44d9a08b0c78 100644
--- a/usr.sbin/bsdinstall/partedit/part_wizard.c
+++ b/usr.sbin/bsdinstall/partedit/part_wizard.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Nathan Whitehorn
* 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 <sys/param.h>
@@ -65,31 +63,37 @@ part_wizard(const char *fsreq)
startwizard:
error = geom_gettree(&mesh);
+ if (error != 0)
+ return (1);
- bsddialog_backtitle(&conf, "FreeBSD Installer");
- error = geom_gettree(&mesh);
+ bsddialog_backtitle(&conf, OSNAME " Installer");
disk = boot_disk_select(&mesh);
- if (disk == NULL)
+ if (disk == NULL) {
+ geom_deletetree(&mesh);
return (1);
+ }
- bsddialog_clearterminal();
- bsddialog_backtitle(&conf, "FreeBSD Installer");
+ bsddialog_clear(0);
+ bsddialog_backtitle(&conf, OSNAME " Installer");
schemeroot = wizard_partition(&mesh, disk);
free(disk);
+ geom_deletetree(&mesh);
if (schemeroot == NULL)
return (1);
- geom_deletetree(&mesh);
- bsddialog_clearterminal();
- bsddialog_backtitle(&conf, "FreeBSD Installer");
+ bsddialog_clear(0);
+ bsddialog_backtitle(&conf, OSNAME " Installer");
error = geom_gettree(&mesh);
+ if (error != 0) {
+ free(schemeroot);
+ return (1);
+ }
error = wizard_makeparts(&mesh, schemeroot, fstype, 1);
- if (error)
- goto startwizard;
free(schemeroot);
-
geom_deletetree(&mesh);
+ if (error)
+ goto startwizard;
return (0);
}
@@ -273,7 +277,8 @@ query:
char warning[512];
int subchoice;
- sprintf(warning, "The existing partition scheme on this "
+ snprintf(warning, sizeof(warning),
+ "The existing partition scheme on this "
"disk (%s) is not bootable on this platform. To install "
OSNAME ", it must be repartitioned. This will destroy all "
"data on the disk. Are you sure you want to proceed?",
@@ -310,11 +315,13 @@ query:
if (strcmp(scheme, "MBR") == 0) {
struct gmesh submesh;
- geom_gettree(&submesh);
- gpart_create(provider_for_name(&submesh, disk),
- "freebsd", NULL, NULL, &retval,
- choice /* Non-interactive for "Entire Disk" */);
- geom_deletetree(&submesh);
+
+ if (geom_gettree(&submesh) == 0) {
+ gpart_create(provider_for_name(&submesh, disk),
+ "freebsd", NULL, NULL, &retval,
+ choice /* Non-interactive for "Entire Disk" */);
+ geom_deletetree(&submesh);
+ }
} else {
retval = strdup(disk);
}
@@ -334,7 +341,7 @@ wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype,
struct gmesh submesh;
char swapsizestr[10], rootsizestr[10];
intmax_t swapsize, available;
- int retval;
+ int error, retval;
struct bsddialog_conf conf;
if (strcmp(fstype, "zfs") == 0) {
@@ -361,7 +368,8 @@ wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype,
HN_DECIMAL);
humanize_number(neededstr, 7, MIN_FREE_SPACE, "B", HN_AUTOSCALE,
HN_DECIMAL);
- sprintf(message, "There is not enough free space on %s to "
+ snprintf(message, sizeof(message),
+ "There is not enough free space on %s to "
"install " OSNAME " (%s free, %s required). Would you like "
"to choose another disk or to open the partition editor?",
disk, availablestr, neededstr);
@@ -381,12 +389,16 @@ wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype,
humanize_number(rootsizestr, 7, available - swapsize - 1024*1024,
"B", HN_AUTOSCALE, HN_NOSPACE | HN_DECIMAL);
- geom_gettree(&submesh);
+ error = geom_gettree(&submesh);
+ if (error != 0)
+ return (error);
pp = provider_for_name(&submesh, disk);
gpart_create(pp, fsname, rootsizestr, "/", NULL, 0);
geom_deletetree(&submesh);
- geom_gettree(&submesh);
+ error = geom_gettree(&submesh);
+ if (error != 0)
+ return (error);
pp = provider_for_name(&submesh, disk);
gpart_create(pp, "freebsd-swap", swapsizestr, NULL, NULL, 0);
geom_deletetree(&submesh);
diff --git a/usr.sbin/bsdinstall/partedit/partedit.c b/usr.sbin/bsdinstall/partedit/partedit.c
index 22d1dbfca194..148cb74edc75 100644
--- a/usr.sbin/bsdinstall/partedit/partedit.c
+++ b/usr.sbin/bsdinstall/partedit/partedit.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Nathan Whitehorn
* 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 <sys/param.h>
@@ -63,9 +61,10 @@ sigint_handler(int sig)
struct gmesh mesh;
/* Revert all changes and exit dialog-mode cleanly on SIGINT */
- geom_gettree(&mesh);
- gpart_revert_all(&mesh);
- geom_deletetree(&mesh);
+ if (geom_gettree(&mesh) == 0) {
+ gpart_revert_all(&mesh);
+ geom_deletetree(&mesh);
+ }
bsddialog_end();
@@ -124,9 +123,9 @@ main(int argc, const char **argv)
/* Show the part editor either immediately, or to confirm wizard */
while (prompt != NULL) {
- bsddialog_clearterminal();
+ bsddialog_clear(0);
if (!sade_mode)
- bsddialog_backtitle(&conf, "FreeBSD Installer");
+ bsddialog_backtitle(&conf, OSNAME " Installer");
error = geom_gettree(&mesh);
if (error == 0)
@@ -138,7 +137,7 @@ main(int argc, const char **argv)
"installation menu.", 0, 0);
break;
}
-
+
get_mount_points(items, nitems);
if (i >= nitems)
@@ -216,16 +215,17 @@ main(int argc, const char **argv)
if (prompt == NULL) {
error = geom_gettree(&mesh);
- if (validate_setup()) {
- error = apply_changes(&mesh);
- } else {
- gpart_revert_all(&mesh);
- error = -1;
+ if (error == 0) {
+ if (validate_setup()) {
+ error = apply_changes(&mesh);
+ } else {
+ gpart_revert_all(&mesh);
+ error = -1;
+ }
+ geom_deletetree(&mesh);
}
}
- geom_deletetree(&mesh);
- free(items);
bsddialog_end();
return (error);
@@ -345,6 +345,7 @@ apply_changes(struct gmesh *mesh)
const char **minilabel;
const char *fstab_path;
FILE *fstab;
+ char *command;
struct bsddialog_conf conf;
nitems = 1; /* Partition table changes */
@@ -360,8 +361,8 @@ apply_changes(struct gmesh *mesh)
TAILQ_FOREACH(md, &part_metadata, metadata) {
if (md->newfs != NULL) {
char *item;
- item = malloc(255);
- sprintf(item, "Initializing %s", md->name);
+
+ asprintf(&item, "Initializing %s", md->name);
minilabel[i] = item;
miniperc[i] = BSDDIALOG_MG_PENDING;
i++;
@@ -387,10 +388,11 @@ apply_changes(struct gmesh *mesh)
bsddialog_mixedgauge(&conf,
"Initializing file systems. Please wait.", 0, 0,
i * 100 / nitems, nitems, minilabel, miniperc);
- sprintf(message, "(echo %s; %s) >>%s 2>>%s",
+ asprintf(&command, "(echo %s; %s) >>%s 2>>%s",
md->newfs, md->newfs, getenv("BSDINSTALL_LOG"),
getenv("BSDINSTALL_LOG"));
- error = system(message);
+ error = system(command);
+ free(command);
miniperc[i] = (error == 0) ?
BSDDIALOG_MG_COMPLETED : BSDDIALOG_MG_FAILED;
i++;
@@ -434,7 +436,8 @@ apply_changes(struct gmesh *mesh)
fstab_path = "/etc/fstab";
fstab = fopen(fstab_path, "w+");
if (fstab == NULL) {
- sprintf(message, "Cannot open fstab file %s for writing (%s)\n",
+ snprintf(message, sizeof(message),
+ "Cannot open fstab file %s for writing (%s)\n",
getenv("PATH_FSTAB"), strerror(errno));
conf.title = "Error";
bsddialog_msgbox(&conf, message, 0, 0);
diff --git a/usr.sbin/bsdinstall/partedit/partedit.h b/usr.sbin/bsdinstall/partedit/partedit.h
index aa1ec285ff80..57f590113f43 100644
--- a/usr.sbin/bsdinstall/partedit/partedit.h
+++ b/usr.sbin/bsdinstall/partedit/partedit.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Nathan Whitehorn
* 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 _PARTEDIT_PARTEDIT_H
diff --git a/usr.sbin/bsdinstall/partedit/partedit_efi.c b/usr.sbin/bsdinstall/partedit/partedit_efi.c
index 074475e07152..7c4f85a69b8b 100644
--- a/usr.sbin/bsdinstall/partedit/partedit_efi.c
+++ b/usr.sbin/bsdinstall/partedit/partedit_efi.c
@@ -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$
*/
#include <sys/types.h>
diff --git a/usr.sbin/bsdinstall/partedit/partedit_generic.c b/usr.sbin/bsdinstall/partedit/partedit_generic.c
index e25784592a9b..dd6a44b96e91 100644
--- a/usr.sbin/bsdinstall/partedit/partedit_generic.c
+++ b/usr.sbin/bsdinstall/partedit/partedit_generic.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Nathan Whitehorn
* 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 <string.h>
diff --git a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
index 5a3041df5b0c..27fc9c2bde6e 100644
--- a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
+++ b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Nathan Whitehorn
* 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 <sys/types.h>
diff --git a/usr.sbin/bsdinstall/partedit/partedit_x86.c b/usr.sbin/bsdinstall/partedit/partedit_x86.c
index 6983188ba34f..6a536271c25e 100644
--- a/usr.sbin/bsdinstall/partedit/partedit_x86.c
+++ b/usr.sbin/bsdinstall/partedit/partedit_x86.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Nathan Whitehorn
* 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 <sys/types.h>
diff --git a/usr.sbin/bsdinstall/partedit/sade.8 b/usr.sbin/bsdinstall/partedit/sade.8
index f80f8c5fb7d0..2e676c19ba4b 100644
--- a/usr.sbin/bsdinstall/partedit/sade.8
+++ b/usr.sbin/bsdinstall/partedit/sade.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 30, 2012
.Dt SADE 8
.Os
diff --git a/usr.sbin/bsdinstall/partedit/scripted.c b/usr.sbin/bsdinstall/partedit/scripted.c
index 956855eb6e54..9527f3828135 100644
--- a/usr.sbin/bsdinstall/partedit/scripted.c
+++ b/usr.sbin/bsdinstall/partedit/scripted.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Nathan Whitehorn
* 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 <sys/param.h>
@@ -76,6 +74,8 @@ part_config(char *disk, const char *scheme, char *config)
scheme = default_scheme();
error = geom_gettree(&mesh);
+ if (error != 0)
+ return (-1);
if (provider_for_name(&mesh, disk) == NULL) {
fprintf(stderr, "GEOM provider %s not found\n", disk);
geom_deletetree(&mesh);
@@ -97,16 +97,22 @@ part_config(char *disk, const char *scheme, char *config)
if (strcmp(scheme, "MBR") == 0) {
struct gmesh submesh;
- geom_gettree(&submesh);
- gpart_create(provider_for_name(&submesh, disk),
- "freebsd", NULL, NULL, &disk, 0);
- geom_deletetree(&submesh);
+
+ if (geom_gettree(&submesh) == 0) {
+ gpart_create(provider_for_name(&submesh, disk),
+ "freebsd", NULL, NULL, &disk, 0);
+ geom_deletetree(&submesh);
+ }
} else {
- disk= strdup(disk);
+ disk = strdup(disk);
}
geom_deletetree(&mesh);
error = geom_gettree(&mesh);
+ if (error != 0) {
+ free(disk);
+ return (-1);
+ }
/* Create partitions */
if (config == NULL) {
@@ -133,6 +139,10 @@ part_config(char *disk, const char *scheme, char *config)
NULL, 0);
geom_deletetree(&mesh);
error = geom_gettree(&mesh);
+ if (error != 0) {
+ free(disk);
+ return (-1);
+ }
size = type = mount = NULL;
}
@@ -143,8 +153,8 @@ finished:
return (0);
}
-static
-int parse_disk_config(char *input)
+static int
+parse_disk_config(char *input)
{
char *ap;
char *disk = NULL, *scheme = NULL, *partconfig = NULL;
@@ -184,9 +194,11 @@ int parse_disk_config(char *input)
if (disk == NULL || strcmp(disk, "DEFAULT") == 0) {
struct gmesh mesh;
- geom_gettree(&mesh);
- disk = boot_disk_select(&mesh);
- geom_deletetree(&mesh);
+
+ if (geom_gettree(&mesh) == 0) {
+ disk = boot_disk_select(&mesh);
+ geom_deletetree(&mesh);
+ }
}
return (part_config(disk, scheme, partconfig));
@@ -195,23 +207,26 @@ int parse_disk_config(char *input)
int
scripted_editor(int argc, const char **argv)
{
- char *token;
- int i, error = 0, len = 0;
+ FILE *fp;
+ char *input, *token;
+ size_t len;
+ int i, error = 0;
- for (i = 1; i < argc; i++)
- len += strlen(argv[i]) + 1;
- char inputbuf[len], *input = inputbuf;
- strcpy(input, argv[1]);
+ fp = open_memstream(&input, &len);
+ fputs(argv[1], fp);
for (i = 2; i < argc; i++) {
- strcat(input, " ");
- strcat(input, argv[i]);
+ fprintf(fp, " %s", argv[i]);
}
+ fclose(fp);
while ((token = strsep(&input, ";")) != NULL) {
error = parse_disk_config(token);
- if (error != 0)
+ if (error != 0) {
+ free(input);
return (error);
+ }
}
+ free(input);
return (0);
}
diff --git a/usr.sbin/bsdinstall/runconsoles/Makefile b/usr.sbin/bsdinstall/runconsoles/Makefile
new file mode 100644
index 000000000000..49666c6b8d80
--- /dev/null
+++ b/usr.sbin/bsdinstall/runconsoles/Makefile
@@ -0,0 +1,9 @@
+BINDIR= ${LIBEXECDIR}/bsdinstall
+PROG= runconsoles
+MAN=
+
+SRCS= child.c \
+ common.c \
+ runconsoles.c
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdinstall/runconsoles/child.c b/usr.sbin/bsdinstall/runconsoles/child.c
new file mode 100644
index 000000000000..45b62e0c8841
--- /dev/null
+++ b/usr.sbin/bsdinstall/runconsoles/child.c
@@ -0,0 +1,386 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 Jessica Clarke <jrtc27@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/errno.h>
+#include <sys/procctl.h>
+#include <sys/queue.h>
+#include <sys/resource.h>
+#include <sys/sysctl.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <termios.h>
+#include <ttyent.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "child.h"
+
+/* -1: not started, 0: reaped */
+static volatile pid_t grandchild_pid = -1;
+static volatile int grandchild_status;
+
+static struct pipe_barrier wait_grandchild_barrier;
+static struct pipe_barrier wait_all_descendants_barrier;
+
+static void
+kill_descendants(int sig)
+{
+ struct procctl_reaper_kill rk;
+
+ rk.rk_sig = sig;
+ rk.rk_flags = 0;
+ procctl(P_PID, getpid(), PROC_REAP_KILL, &rk);
+}
+
+static void
+sigalrm_handler(int sig __unused)
+{
+ int saved_errno;
+
+ saved_errno = errno;
+ kill_descendants(SIGKILL);
+ errno = saved_errno;
+}
+
+static void
+wait_all_descendants(void)
+{
+ sigset_t set, oset;
+
+ err_set_exit(NULL);
+
+ /*
+ * We may be run in a context where SIGALRM is blocked; temporarily
+ * unblock so we can SIGKILL. Similarly, SIGCHLD may be blocked, but if
+ * we're waiting on the pipe we need to make sure it's not.
+ */
+ sigemptyset(&set);
+ sigaddset(&set, SIGALRM);
+ sigaddset(&set, SIGCHLD);
+ sigprocmask(SIG_UNBLOCK, &set, &oset);
+ alarm(KILL_TIMEOUT);
+ pipe_barrier_wait(&wait_all_descendants_barrier);
+ alarm(0);
+ sigprocmask(SIG_SETMASK, &oset, NULL);
+}
+
+static void
+sigchld_handler(int sig __unused)
+{
+ int status, saved_errno;
+ pid_t pid;
+
+ saved_errno = errno;
+
+ while ((void)(pid = waitpid(-1, &status, WNOHANG)),
+ pid != -1 && pid != 0) {
+ /* NB: No need to check grandchild_pid due to the pid checks */
+ if (pid == grandchild_pid) {
+ grandchild_status = status;
+ grandchild_pid = 0;
+ pipe_barrier_ready(&wait_grandchild_barrier);
+ }
+ }
+
+ /*
+ * Another process calling kill(..., SIGCHLD) could cause us to get
+ * here before we've spawned the grandchild; only ready when we have no
+ * children if the grandchild has been reaped.
+ */
+ if (pid == -1 && errno == ECHILD && grandchild_pid == 0)
+ pipe_barrier_ready(&wait_all_descendants_barrier);
+
+ errno = saved_errno;
+}
+
+static void
+exit_signal_handler(int sig)
+{
+ int saved_errno;
+
+ /*
+ * If we get killed before we've started the grandchild then just exit
+ * with that signal, otherwise kill all our descendants with that
+ * signal and let the main program pick up the grandchild's death.
+ */
+ if (grandchild_pid == -1) {
+ reproduce_signal_death(sig);
+ exit(EXIT_FAILURE);
+ }
+
+ saved_errno = errno;
+ kill_descendants(sig);
+ errno = saved_errno;
+}
+
+static void
+kill_wait_all_descendants(int sig)
+{
+ kill_descendants(sig);
+ wait_all_descendants();
+}
+
+static void
+kill_wait_all_descendants_err_exit(int eval __unused)
+{
+ kill_wait_all_descendants(SIGTERM);
+}
+
+static void __dead2
+grandchild_run(const char **argv, const sigset_t *oset)
+{
+ sig_t orig;
+
+ /* Restore signals */
+ orig = signal(SIGALRM, SIG_DFL);
+ if (orig == SIG_ERR)
+ err(EX_OSERR, "could not restore SIGALRM");
+ orig = signal(SIGCHLD, SIG_DFL);
+ if (orig == SIG_ERR)
+ err(EX_OSERR, "could not restore SIGCHLD");
+ orig = signal(SIGTERM, SIG_DFL);
+ if (orig == SIG_ERR)
+ err(EX_OSERR, "could not restore SIGTERM");
+ orig = signal(SIGINT, SIG_DFL);
+ if (orig == SIG_ERR)
+ err(EX_OSERR, "could not restore SIGINT");
+ orig = signal(SIGQUIT, SIG_DFL);
+ if (orig == SIG_ERR)
+ err(EX_OSERR, "could not restore SIGQUIT");
+ orig = signal(SIGPIPE, SIG_DFL);
+ if (orig == SIG_ERR)
+ err(EX_OSERR, "could not restore SIGPIPE");
+ orig = signal(SIGTTOU, SIG_DFL);
+ if (orig == SIG_ERR)
+ err(EX_OSERR, "could not restore SIGTTOU");
+
+ /* Now safe to unmask signals */
+ sigprocmask(SIG_SETMASK, oset, NULL);
+
+ /* Only run with stdin/stdout/stderr */
+ closefrom(3);
+
+ /* Ready to execute the requested program */
+ execvp(argv[0], __DECONST(char * const *, argv));
+ err(EX_OSERR, "cannot execvp %s", argv[0]);
+}
+
+static int
+wait_grandchild_descendants(void)
+{
+ pipe_barrier_wait(&wait_grandchild_barrier);
+
+ /*
+ * Once the grandchild itself has exited, kill any lingering
+ * descendants and wait until we've reaped them all.
+ */
+ kill_wait_all_descendants(SIGTERM);
+
+ if (grandchild_pid != 0)
+ errx(EX_SOFTWARE, "failed to reap grandchild");
+
+ return (grandchild_status);
+}
+
+void
+child_leader_run(const char *name, int fd, bool new_session, const char **argv,
+ const sigset_t *oset, struct pipe_barrier *start_children_barrier)
+{
+ struct pipe_barrier start_grandchild_barrier;
+ pid_t pid, sid, pgid;
+ struct sigaction sa;
+ int error, status;
+ sigset_t set;
+
+ setproctitle("%s [%s]", getprogname(), name);
+
+ error = procctl(P_PID, getpid(), PROC_REAP_ACQUIRE, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not acquire reaper status");
+
+ /*
+ * Set up our own signal handlers for everything the parent overrides
+ * other than SIGPIPE and SIGTTOU which we leave as ignored, since we
+ * also use pipe-based synchronisation and want to be able to print
+ * errors.
+ */
+ sa.sa_flags = SA_RESTART;
+ sa.sa_handler = sigchld_handler;
+ sigfillset(&sa.sa_mask);
+ error = sigaction(SIGCHLD, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not enable SIGCHLD handler");
+ sa.sa_handler = sigalrm_handler;
+ error = sigaction(SIGALRM, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not enable SIGALRM handler");
+ sa.sa_handler = exit_signal_handler;
+ error = sigaction(SIGTERM, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not enable SIGTERM handler");
+ error = sigaction(SIGINT, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not enable SIGINT handler");
+ error = sigaction(SIGQUIT, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not enable SIGQUIT handler");
+
+ /*
+ * Now safe to unmask signals. Note that creating the barriers used by
+ * the SIGCHLD handler with signals unmasked is safe since they won't
+ * be used if the grandchild hasn't been forked (and reaped), which
+ * comes later.
+ */
+ sigprocmask(SIG_SETMASK, oset, NULL);
+
+ error = pipe_barrier_init(&start_grandchild_barrier);
+ if (error != 0)
+ err(EX_OSERR, "could not create start grandchild barrier");
+
+ error = pipe_barrier_init(&wait_grandchild_barrier);
+ if (error != 0)
+ err(EX_OSERR, "could not create wait grandchild barrier");
+
+ error = pipe_barrier_init(&wait_all_descendants_barrier);
+ if (error != 0)
+ err(EX_OSERR, "could not create wait all descendants barrier");
+
+ /*
+ * Create a new session if this is on a different terminal to
+ * the current one, otherwise just create a new process group to keep
+ * things as similar as possible between the two cases.
+ */
+ if (new_session) {
+ sid = setsid();
+ pgid = sid;
+ if (sid == -1)
+ err(EX_OSERR, "could not create session");
+ } else {
+ sid = -1;
+ pgid = getpid();
+ error = setpgid(0, pgid);
+ if (error == -1)
+ err(EX_OSERR, "could not create process group");
+ }
+
+ /* Wait until parent is ready for us to start */
+ pipe_barrier_destroy_ready(start_children_barrier);
+ pipe_barrier_wait(start_children_barrier);
+
+ /*
+ * Use the console for stdin/stdout/stderr.
+ *
+ * NB: dup2(2) is a no-op if the two fds are equal, and the call to
+ * closefrom(2) later in the grandchild will close the fd if it isn't
+ * one of stdin/stdout/stderr already. This means we do not need to
+ * handle that special case differently.
+ */
+ error = dup2(fd, STDIN_FILENO);
+ if (error == -1)
+ err(EX_IOERR, "could not dup %s to stdin", name);
+ error = dup2(fd, STDOUT_FILENO);
+ if (error == -1)
+ err(EX_IOERR, "could not dup %s to stdout", name);
+ error = dup2(fd, STDERR_FILENO);
+ if (error == -1)
+ err(EX_IOERR, "could not dup %s to stderr", name);
+
+ /*
+ * If we created a new session, make the console our controlling
+ * terminal. Either way, also make this the foreground process group.
+ */
+ if (new_session) {
+ error = tcsetsid(STDIN_FILENO, sid);
+ if (error != 0)
+ err(EX_IOERR, "could not set session for %s", name);
+ } else {
+ error = tcsetpgrp(STDIN_FILENO, pgid);
+ if (error != 0)
+ err(EX_IOERR, "could not set process group for %s",
+ name);
+ }
+
+ /*
+ * Temporarily block signals again; forking, setting grandchild_pid and
+ * calling err_set_exit need to all be atomic for similar reasons as
+ * the parent when forking us.
+ */
+ sigfillset(&set);
+ sigprocmask(SIG_BLOCK, &set, NULL);
+ pid = fork();
+ if (pid == -1)
+ err(EX_OSERR, "could not fork");
+
+ if (pid == 0) {
+ /*
+ * We need to destroy the ready ends so we don't block these
+ * child leader-only self-pipes, and might as well destroy the
+ * wait ends too given we're not going to use them.
+ */
+ pipe_barrier_destroy(&wait_grandchild_barrier);
+ pipe_barrier_destroy(&wait_all_descendants_barrier);
+
+ /* Wait until the parent has put us in a new process group */
+ pipe_barrier_destroy_ready(&start_grandchild_barrier);
+ pipe_barrier_wait(&start_grandchild_barrier);
+ grandchild_run(argv, oset);
+ }
+
+ grandchild_pid = pid;
+
+ /*
+ * Now the grandchild exists make sure to clean it up, and any of its
+ * descendants, on exit.
+ */
+ err_set_exit(kill_wait_all_descendants_err_exit);
+
+ sigprocmask(SIG_SETMASK, oset, NULL);
+
+ /* Start the grandchild and wait for it and its descendants to exit */
+ pipe_barrier_ready(&start_grandchild_barrier);
+
+ status = wait_grandchild_descendants();
+
+ if (WIFSIGNALED(status))
+ reproduce_signal_death(WTERMSIG(status));
+
+ if (WIFEXITED(status))
+ exit(WEXITSTATUS(status));
+
+ exit(EXIT_FAILURE);
+}
diff --git a/usr.sbin/bsdinstall/runconsoles/child.h b/usr.sbin/bsdinstall/runconsoles/child.h
new file mode 100644
index 000000000000..40d6b9d6cbf1
--- /dev/null
+++ b/usr.sbin/bsdinstall/runconsoles/child.h
@@ -0,0 +1,30 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 Jessica Clarke <jrtc27@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+void child_leader_run(const char *name, int fd, bool new_session,
+ const char **argv, const sigset_t *oset,
+ struct pipe_barrier *start_barrier) __dead2;
diff --git a/usr.sbin/bsdinstall/runconsoles/common.c b/usr.sbin/bsdinstall/runconsoles/common.c
new file mode 100644
index 000000000000..843cee70ba82
--- /dev/null
+++ b/usr.sbin/bsdinstall/runconsoles/common.c
@@ -0,0 +1,56 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 Jessica Clarke <jrtc27@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/resource.h>
+
+#include <err.h>
+#include <errno.h>
+#include <signal.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+#include "common.h"
+
+void
+reproduce_signal_death(int sig)
+{
+ struct rlimit rl;
+
+ if (signal(sig, SIG_DFL) == SIG_ERR)
+ err(EX_OSERR,
+ "cannot set action to reproduce signal %d",
+ sig);
+ rl.rlim_cur = 0;
+ rl.rlim_max = 0;
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ err(EX_OSERR,
+ "cannot disable core dumps to reproduce signal %d",
+ sig);
+ kill(getpid(), sig);
+}
+
diff --git a/usr.sbin/bsdinstall/runconsoles/common.h b/usr.sbin/bsdinstall/runconsoles/common.h
new file mode 100644
index 000000000000..5c3623f15cba
--- /dev/null
+++ b/usr.sbin/bsdinstall/runconsoles/common.h
@@ -0,0 +1,110 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 Jessica Clarke <jrtc27@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#define KILL_TIMEOUT 10
+
+/*
+ * NB: Most of these do not need to be volatile, but a handful are used in
+ * signal handler contexts, so for simplicity we make them all volatile rather
+ * than duplicate the implementation.
+ */
+struct pipe_barrier {
+ volatile int fds[2];
+};
+
+static __inline int
+pipe_barrier_init(struct pipe_barrier *p)
+{
+ int error, fds[2], i;
+
+ error = pipe(fds);
+ if (error != 0)
+ return (error);
+
+ for (i = 0; i < 2; ++i)
+ p->fds[i] = fds[i];
+
+ return (0);
+}
+
+static __inline void
+pipe_barrier_wait(struct pipe_barrier *p)
+{
+ ssize_t ret;
+ char temp;
+ int fd;
+
+ fd = p->fds[0];
+ p->fds[0] = -1;
+ do {
+ ret = read(fd, &temp, 1);
+ } while (ret == -1 && errno == EINTR);
+ close(fd);
+}
+
+static __inline void
+pipe_barrier_ready(struct pipe_barrier *p)
+{
+ int fd;
+
+ fd = p->fds[1];
+ p->fds[1] = -1;
+ close(fd);
+}
+
+static __inline void
+pipe_barrier_destroy_impl(struct pipe_barrier *p, int i)
+{
+ int fd;
+
+ fd = p->fds[i];
+ if (fd != -1) {
+ p->fds[i] = -1;
+ close(fd);
+ }
+}
+
+static __inline void
+pipe_barrier_destroy_wait(struct pipe_barrier *p)
+{
+ pipe_barrier_destroy_impl(p, 0);
+}
+
+static __inline void
+pipe_barrier_destroy_ready(struct pipe_barrier *p)
+{
+ pipe_barrier_destroy_impl(p, 1);
+}
+
+static __inline void
+pipe_barrier_destroy(struct pipe_barrier *p)
+{
+ pipe_barrier_destroy_wait(p);
+ pipe_barrier_destroy_ready(p);
+}
+
+void reproduce_signal_death(int sig);
diff --git a/usr.sbin/bsdinstall/runconsoles/runconsoles.c b/usr.sbin/bsdinstall/runconsoles/runconsoles.c
new file mode 100644
index 000000000000..7051bb5a8ed0
--- /dev/null
+++ b/usr.sbin/bsdinstall/runconsoles/runconsoles.c
@@ -0,0 +1,647 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 Jessica Clarke <jrtc27@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * We create the following process hierarchy:
+ *
+ * runconsoles utility
+ * |-- runconsoles [ttyX]
+ * | `-- utility primary
+ * |-- runconsoles [ttyY]
+ * | `-- utility secondary
+ * ...
+ * `-- runconsoles [ttyZ]
+ * `-- utility secondary
+ *
+ * Whilst the intermediate processes might seem unnecessary, they are important
+ * so we can ensure the session leader stays around until the actual program
+ * being run and all its children have exited when killing them (and, in the
+ * case of our controlling terminal, that nothing in our current session goes
+ * on to write to it before then), giving them a chance to clean up the
+ * terminal (important if a dialog box is showing).
+ *
+ * Each of the intermediate processes acquires reaper status, allowing it to
+ * kill its descendants, not just a single process group, and wait until all
+ * have finished, not just its immediate child.
+ */
+
+#include <sys/param.h>
+#include <sys/errno.h>
+#include <sys/queue.h>
+#include <sys/resource.h>
+#include <sys/sysctl.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <termios.h>
+#include <ttyent.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "child.h"
+
+struct consinfo {
+ const char *name;
+ STAILQ_ENTRY(consinfo) link;
+ int fd;
+ /* -1: not started, 0: reaped */
+ volatile pid_t pid;
+ volatile int exitstatus;
+};
+
+STAILQ_HEAD(consinfo_list, consinfo);
+
+static struct consinfo_list consinfos;
+static struct consinfo *primary_consinfo;
+static struct consinfo *controlling_consinfo;
+
+static struct consinfo * volatile first_sigchld_consinfo;
+
+static struct pipe_barrier wait_first_child_barrier;
+static struct pipe_barrier wait_all_children_barrier;
+
+static const char primary[] = "primary";
+static const char secondary[] = "secondary";
+
+static const struct option longopts[] = {
+ { "help", no_argument, NULL, 'h' },
+ { NULL, 0, NULL, 0 }
+};
+
+static void
+kill_consoles(int sig)
+{
+ struct consinfo *consinfo;
+ sigset_t set, oset;
+
+ /* Temporarily block signals so PID reading and killing are atomic */
+ sigfillset(&set);
+ sigprocmask(SIG_BLOCK, &set, &oset);
+ STAILQ_FOREACH(consinfo, &consinfos, link) {
+ if (consinfo->pid != -1 && consinfo->pid != 0)
+ kill(consinfo->pid, sig);
+ }
+ sigprocmask(SIG_SETMASK, &oset, NULL);
+}
+
+static void
+sigalrm_handler(int code __unused)
+{
+ int saved_errno;
+
+ saved_errno = errno;
+ kill_consoles(SIGKILL);
+ errno = saved_errno;
+}
+
+static void
+wait_all_consoles(void)
+{
+ sigset_t set, oset;
+ int error;
+
+ err_set_exit(NULL);
+
+ /*
+ * We may be run in a context where SIGALRM is blocked; temporarily
+ * unblock so we can SIGKILL. Similarly, SIGCHLD may be blocked, but if
+ * we're waiting on the pipe we need to make sure it's not.
+ */
+ sigemptyset(&set);
+ sigaddset(&set, SIGALRM);
+ sigaddset(&set, SIGCHLD);
+ sigprocmask(SIG_UNBLOCK, &set, &oset);
+ alarm(KILL_TIMEOUT);
+ pipe_barrier_wait(&wait_all_children_barrier);
+ alarm(0);
+ sigprocmask(SIG_SETMASK, &oset, NULL);
+
+ if (controlling_consinfo != NULL) {
+ error = tcsetpgrp(controlling_consinfo->fd,
+ getpgrp());
+ if (error != 0)
+ err(EX_OSERR, "could not give up control of %s",
+ controlling_consinfo->name);
+ }
+}
+
+static void
+kill_wait_all_consoles(int sig)
+{
+ kill_consoles(sig);
+ wait_all_consoles();
+}
+
+static void
+kill_wait_all_consoles_err_exit(int eval __unused)
+{
+ kill_wait_all_consoles(SIGTERM);
+}
+
+static void __dead2
+exit_signal_handler(int code)
+{
+ struct consinfo *consinfo;
+ bool started_console;
+
+ started_console = false;
+ STAILQ_FOREACH(consinfo, &consinfos, link) {
+ if (consinfo->pid != -1) {
+ started_console = true;
+ break;
+ }
+ }
+
+ /*
+ * If we haven't yet started a console, don't wait for them, since
+ * we'll never get a SIGCHLD that will wake us up.
+ */
+ if (started_console)
+ kill_wait_all_consoles(SIGTERM);
+
+ reproduce_signal_death(code);
+ exit(EXIT_FAILURE);
+}
+
+static void
+sigchld_handler_reaped_one(pid_t pid, int status)
+{
+ struct consinfo *consinfo, *child_consinfo;
+ bool others;
+
+ child_consinfo = NULL;
+ others = false;
+ STAILQ_FOREACH(consinfo, &consinfos, link) {
+ /*
+ * NB: No need to check consinfo->pid as the caller is
+ * responsible for passing a valid PID
+ */
+ if (consinfo->pid == pid)
+ child_consinfo = consinfo;
+ else if (consinfo->pid != -1 && consinfo->pid != 0)
+ others = true;
+ }
+
+ if (child_consinfo == NULL)
+ return;
+
+ child_consinfo->pid = 0;
+ child_consinfo->exitstatus = status;
+
+ if (first_sigchld_consinfo == NULL) {
+ first_sigchld_consinfo = child_consinfo;
+ pipe_barrier_ready(&wait_first_child_barrier);
+ }
+
+ if (others)
+ return;
+
+ pipe_barrier_ready(&wait_all_children_barrier);
+}
+
+static void
+sigchld_handler(int code __unused)
+{
+ int status, saved_errno;
+ pid_t pid;
+
+ saved_errno = errno;
+ while ((void)(pid = waitpid(-1, &status, WNOHANG)),
+ pid != -1 && pid != 0)
+ sigchld_handler_reaped_one(pid, status);
+ errno = saved_errno;
+}
+
+static const char *
+read_primary_console(void)
+{
+ char *buf, *p, *cons;
+ size_t len;
+ int error;
+
+ /*
+ * NB: Format is "cons,...cons,/cons,...cons,", with the list before
+ * the / being the set of configured consoles, and the list after being
+ * the list of available consoles.
+ */
+ error = sysctlbyname("kern.console", NULL, &len, NULL, 0);
+ if (error == -1)
+ err(EX_OSERR, "could not read kern.console length");
+ buf = malloc(len);
+ if (buf == NULL)
+ err(EX_OSERR, "could not allocate kern.console buffer");
+ error = sysctlbyname("kern.console", buf, &len, NULL, 0);
+ if (error == -1)
+ err(EX_OSERR, "could not read kern.console");
+
+ /* Truncate at / to get just the configured consoles */
+ p = strchr(buf, '/');
+ if (p == NULL)
+ errx(EX_OSERR, "kern.console malformed: no / found");
+ *p = '\0';
+
+ /*
+ * Truncate at , to get just the first configured console, the primary
+ * ("high level") one.
+ */
+ p = strchr(buf, ',');
+ if (p != NULL)
+ *p = '\0';
+
+ if (*buf != '\0')
+ cons = strdup(buf);
+ else
+ cons = NULL;
+
+ free(buf);
+
+ return (cons);
+}
+
+static void
+read_consoles(void)
+{
+ const char *primary_console;
+ struct consinfo *consinfo;
+ int fd, error, flags;
+ struct ttyent *tty;
+ char *dev, *name;
+ pid_t pgrp;
+
+ primary_console = read_primary_console();
+
+ STAILQ_INIT(&consinfos);
+ while ((tty = getttyent()) != NULL) {
+ if ((tty->ty_status & TTY_ON) == 0)
+ continue;
+
+ /*
+ * Only use the first VTY; starting on others is pointless as
+ * they're multiplexed, and they get used to show the install
+ * log and start a shell.
+ */
+ if (strncmp(tty->ty_name, "ttyv", 4) == 0 &&
+ strcmp(tty->ty_name + 4, "0") != 0)
+ continue;
+
+ consinfo = malloc(sizeof(struct consinfo));
+ if (consinfo == NULL)
+ err(EX_OSERR, "could not allocate consinfo");
+
+ asprintf(&dev, "/dev/%s", tty->ty_name);
+ if (dev == NULL)
+ err(EX_OSERR, "could not allocate dev path");
+
+ name = dev + 5;
+ fd = open(dev, O_RDWR | O_NONBLOCK);
+ if (fd == -1)
+ err(EX_IOERR, "could not open %s", dev);
+
+ flags = fcntl(fd, F_GETFL);
+ if (flags == -1)
+ err(EX_IOERR, "could not get flags for %s", dev);
+
+ error = fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
+ if (error == -1)
+ err(EX_IOERR, "could not set flags for %s", dev);
+
+ if (tcgetsid(fd) != -1) {
+ /*
+ * No need to check controlling session is ours as
+ * tcgetsid fails with ENOTTY if not.
+ */
+ pgrp = tcgetpgrp(fd);
+ if (pgrp == -1)
+ err(EX_IOERR, "could not get pgrp of %s",
+ dev);
+ else if (pgrp != getpgrp())
+ errx(EX_IOERR, "%s controlled by another group",
+ dev);
+
+ if (controlling_consinfo != NULL)
+ errx(EX_OSERR,
+ "multiple controlling terminals %s and %s",
+ controlling_consinfo->name, name);
+
+ controlling_consinfo = consinfo;
+ }
+
+ consinfo->name = name;
+ consinfo->pid = -1;
+ consinfo->fd = fd;
+ consinfo->exitstatus = -1;
+ STAILQ_INSERT_TAIL(&consinfos, consinfo, link);
+
+ if (primary_console != NULL &&
+ strcmp(consinfo->name, primary_console) == 0)
+ primary_consinfo = consinfo;
+ }
+
+ endttyent();
+ free(__DECONST(char *, primary_console));
+
+ if (STAILQ_EMPTY(&consinfos))
+ errx(EX_OSERR, "no consoles found");
+
+ if (primary_consinfo == NULL) {
+ warnx("no primary console found, using first");
+ primary_consinfo = STAILQ_FIRST(&consinfos);
+ }
+}
+
+static void
+start_console(struct consinfo *consinfo, const char **argv,
+ char *primary_secondary, struct pipe_barrier *start_barrier,
+ const sigset_t *oset)
+{
+ pid_t pid;
+
+ if (consinfo == primary_consinfo)
+ strcpy(primary_secondary, primary);
+ else
+ strcpy(primary_secondary, secondary);
+
+ fprintf(stderr, "Starting %s installer on %s\n", primary_secondary,
+ consinfo->name);
+
+ pid = fork();
+ if (pid == -1)
+ err(EX_OSERR, "could not fork");
+
+ if (pid == 0) {
+ /* Redundant for the first fork but not subsequent ones */
+ err_set_exit(NULL);
+
+ /*
+ * We need to destroy the ready ends so we don't block these
+ * parent-only self-pipes, and might as well destroy the wait
+ * ends too given we're not going to use them.
+ */
+ pipe_barrier_destroy(&wait_first_child_barrier);
+ pipe_barrier_destroy(&wait_all_children_barrier);
+
+ child_leader_run(consinfo->name, consinfo->fd,
+ consinfo != controlling_consinfo, argv, oset,
+ start_barrier);
+ }
+
+ consinfo->pid = pid;
+
+ /*
+ * We have at least one child now so make sure we kill children on
+ * exit. We also must not do this until we have at least one since
+ * otherwise we will never receive a SIGCHLD that will ready the pipe
+ * barrier and thus we will wait forever.
+ */
+ err_set_exit(kill_wait_all_consoles_err_exit);
+}
+
+static void
+start_consoles(int argc, char **argv)
+{
+ struct pipe_barrier start_barrier;
+ struct consinfo *consinfo;
+ char *primary_secondary;
+ const char **newargv;
+ struct sigaction sa;
+ sigset_t set, oset;
+ int error, i;
+
+ error = pipe_barrier_init(&start_barrier);
+ if (error != 0)
+ err(EX_OSERR, "could not create start children barrier");
+
+ error = pipe_barrier_init(&wait_first_child_barrier);
+ if (error != 0)
+ err(EX_OSERR, "could not create wait first child barrier");
+
+ error = pipe_barrier_init(&wait_all_children_barrier);
+ if (error != 0)
+ err(EX_OSERR, "could not create wait all children barrier");
+
+ /*
+ * About to start children, so use our SIGCHLD handler to get notified
+ * when we need to stop. Once the first child has started we will have
+ * registered kill_wait_all_consoles_err_exit which needs our SIGALRM handler to
+ * SIGKILL the children on timeout; do it up front so we can err if it
+ * fails beforehand.
+ *
+ * Also set up our SIGTERM (and SIGINT and SIGQUIT if we're keeping
+ * control of this terminal) handler before we start children so we can
+ * clean them up when signalled.
+ */
+ sa.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+ sa.sa_handler = sigchld_handler;
+ sigfillset(&sa.sa_mask);
+ error = sigaction(SIGCHLD, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not enable SIGCHLD handler");
+ sa.sa_flags = SA_RESTART;
+ sa.sa_handler = sigalrm_handler;
+ error = sigaction(SIGALRM, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not enable SIGALRM handler");
+ sa.sa_handler = exit_signal_handler;
+ error = sigaction(SIGTERM, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not enable SIGTERM handler");
+ if (controlling_consinfo == NULL) {
+ error = sigaction(SIGINT, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not enable SIGINT handler");
+ error = sigaction(SIGQUIT, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not enable SIGQUIT handler");
+ }
+
+ /*
+ * Ignore SIGINT/SIGQUIT in parent if a child leader will take control
+ * of this terminal so only it gets them, and ignore SIGPIPE in parent,
+ * and child until unblocked, since we're using pipes internally as
+ * synchronisation barriers between parent and children.
+ *
+ * Also ignore SIGTTOU so we can print errors if needed after the child
+ * has started.
+ */
+ sa.sa_flags = SA_RESTART;
+ sa.sa_handler = SIG_IGN;
+ if (controlling_consinfo != NULL) {
+ error = sigaction(SIGINT, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not ignore SIGINT");
+ error = sigaction(SIGQUIT, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not ignore SIGQUIT");
+ }
+ error = sigaction(SIGPIPE, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not ignore SIGPIPE");
+ error = sigaction(SIGTTOU, &sa, NULL);
+ if (error != 0)
+ err(EX_OSERR, "could not ignore SIGTTOU");
+
+ /*
+ * Create a fresh copy of the argument array and perform %-substitution;
+ * a literal % will be replaced with primary_secondary, and any other
+ * string that starts % will have the leading % removed (thus arguments
+ * that should start with a % should be escaped with an additional %).
+ *
+ * Having all % arguments use primary_secondary means that copying
+ * either "primary" or "secondary" to it will yield the final argument
+ * array for the child in constant time, regardless of how many appear.
+ */
+ newargv = malloc(((size_t)argc + 1) * sizeof(char *));
+ if (newargv == NULL)
+ err(EX_OSERR, "could not allocate newargv");
+
+ primary_secondary = malloc(MAX(sizeof(primary), sizeof(secondary)));
+ if (primary_secondary == NULL)
+ err(EX_OSERR, "could not allocate primary_secondary");
+
+ newargv[0] = argv[0];
+ for (i = 1; i < argc; ++i) {
+ switch (argv[i][0]) {
+ case '%':
+ if (argv[i][1] == '\0')
+ newargv[i] = primary_secondary;
+ else
+ newargv[i] = argv[i] + 1;
+ break;
+ default:
+ newargv[i] = argv[i];
+ break;
+ }
+ }
+ newargv[argc] = NULL;
+
+ /*
+ * Temporarily block signals. The parent needs forking, assigning
+ * consinfo->pid and, for the first iteration, calling err_set_exit, to
+ * be atomic, and the child leader shouldn't have signals re-enabled
+ * until it has configured its signal handlers appropriately as the
+ * current ones are for the parent's handling of children.
+ */
+ sigfillset(&set);
+ sigprocmask(SIG_BLOCK, &set, &oset);
+ STAILQ_FOREACH(consinfo, &consinfos, link)
+ start_console(consinfo, newargv, primary_secondary,
+ &start_barrier, &oset);
+ sigprocmask(SIG_SETMASK, &oset, NULL);
+
+ /* Now ready for children to start */
+ pipe_barrier_ready(&start_barrier);
+}
+
+static int
+wait_consoles(void)
+{
+ pipe_barrier_wait(&wait_first_child_barrier);
+
+ /*
+ * Once one of our children has exited, kill off the rest and wait for
+ * them all to exit. This will also set the foreground process group of
+ * the controlling terminal back to ours if it's one of the consoles.
+ */
+ kill_wait_all_consoles(SIGTERM);
+
+ if (first_sigchld_consinfo == NULL)
+ errx(EX_SOFTWARE, "failed to find first child that exited");
+
+ return (first_sigchld_consinfo->exitstatus);
+}
+
+static void __dead2
+usage(void)
+{
+ fprintf(stderr, "usage: %s utility [argument ...]", getprogname());
+ exit(EX_USAGE);
+}
+
+int
+main(int argc, char **argv)
+{
+ int ch, status;
+
+ while ((ch = getopt_long(argc, argv, "+h", longopts, NULL)) != -1) {
+ switch (ch) {
+ case 'h':
+ default:
+ usage();
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2)
+ usage();
+
+ /*
+ * Gather the list of enabled consoles from /etc/ttys, ignoring VTYs
+ * other than ttyv0 since they're used for other purposes when the
+ * installer is running, and there would be no point having multiple
+ * copies on each of the multiplexed virtual consoles anyway.
+ */
+ read_consoles();
+
+ /*
+ * Start the installer on all the consoles. Do not print after this
+ * point until our process group is in the foreground again unless
+ * necessary (we ignore SIGTTOU so we can print errors, but don't want
+ * to garble a child's output).
+ */
+ start_consoles(argc, argv);
+
+ /*
+ * Wait for one of the installers to exit, kill the rest, become the
+ * foreground process group again and get the exit code of the first
+ * child to exit.
+ */
+ status = wait_consoles();
+
+ /*
+ * Reproduce the exit code of the first child to exit, including
+ * whether it was a fatal signal or normal termination.
+ */
+ if (WIFSIGNALED(status))
+ reproduce_signal_death(WTERMSIG(status));
+
+ if (WIFEXITED(status))
+ return (WEXITSTATUS(status));
+
+ return (EXIT_FAILURE);
+}
diff --git a/usr.sbin/bsdinstall/scripts/Makefile b/usr.sbin/bsdinstall/scripts/Makefile
index 329351c4cf29..e4ef00ecba59 100644
--- a/usr.sbin/bsdinstall/scripts/Makefile
+++ b/usr.sbin/bsdinstall/scripts/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SCRIPTS=auto \
adduser \
@@ -8,6 +7,7 @@ SCRIPTS=auto \
docsinstall \
entropy \
fetchmissingdists \
+ finalconfig \
hardening \
hostname \
jail \
diff --git a/usr.sbin/bsdinstall/scripts/Makefile.depend b/usr.sbin/bsdinstall/scripts/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsdinstall/scripts/Makefile.depend
+++ b/usr.sbin/bsdinstall/scripts/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsdinstall/scripts/adduser b/usr.sbin/bsdinstall/scripts/adduser
index 9d1e95ec0cd9..df802156b992 100755
--- a/usr.sbin/bsdinstall/scripts/adduser
+++ b/usr.sbin/bsdinstall/scripts/adduser
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto
index 7398f382273c..9f4b5b52fe5d 100755
--- a/usr.sbin/bsdinstall/scripts/auto
+++ b/usr.sbin/bsdinstall/scripts/auto
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -146,25 +145,27 @@ f_dprintf "Began Installation at %s" "$( date )"
rm -rf $BSDINSTALL_TMPETC
mkdir $BSDINSTALL_TMPETC
+[ -f /usr/libexec/bsdinstall/local.pre-everything ] && f_dprintf "Running local.pre-everything" && sh /usr/libexec/bsdinstall/local.pre-everything "$BSDINSTALL_CHROOT"
+
trap true SIGINT # This section is optional
-bsdinstall keymap
+[ -z "$BSDINSTALL_SKIP_KEYMAP" ] && bsdinstall keymap
trap error SIGINT # Catch cntrl-C here
-bsdinstall hostname || error "Set hostname failed"
+if [ -z "$BSDINSTALL_SKIP_HOSTNAME" ]; then bsdinstall hostname || error "Set hostname failed"; fi
-export DISTRIBUTIONS="base.txz kernel.txz"
+export DISTRIBUTIONS="${DISTRIBUTIONS:-base.txz kernel.txz}"
if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
DISTMENU=`awk -F'\t' '!/^(kernel\.txz|base\.txz)/{print $1,$5,$6}' $BSDINSTALL_DISTDIR/MANIFEST`
DISTMENU="$(echo ${DISTMENU} | sed -E 's/\.txz//g')"
if [ -n "$DISTMENU" ]; then
- exec 3>&1
- EXTRA_DISTS=$( eval dialog \
+ exec 5>&1
+ EXTRA_DISTS=$( eval bsddialog \
--backtitle \"$OSNAME Installer\" \
--title \"Distribution Select\" --nocancel --separate-output \
--checklist \"Choose optional system components to install:\" \
0 0 0 $DISTMENU \
- 2>&1 1>&3 )
+ 2>&1 1>&5 )
for dist in $EXTRA_DISTS; do
export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz"
done
@@ -179,7 +180,7 @@ for dist in $DISTRIBUTIONS; do
done
if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then
- dialog --backtitle "$OSNAME Installer" --title "Network Installation" --msgbox "Some installation files were not found on the boot volume. The next few screens will allow you to configure networking so that they can be downloaded from the Internet." 0 0
+ bsddialog --backtitle "$OSNAME Installer" --title "Network Installation" --msgbox "Some installation files were not found on the boot volume. The next few screens will allow you to configure networking so that they can be downloaded from the Internet." 0 0
bsdinstall netconfig || error
NETCONFIG_DONE=yes
fi
@@ -187,6 +188,8 @@ fi
rm -f $PATH_FSTAB
touch $PATH_FSTAB
+[ -f /usr/libexec/bsdinstall/local.pre-partition ] && f_dprintf "Running local.pre-partition" && sh /usr/libexec/bsdinstall/local.pre-partition "$BSDINSTALL_CHROOT"
+
#
# Try to detect known broken platforms and apply their workarounds
#
@@ -298,13 +301,13 @@ case $CURARCH in
;;
esac
-exec 3>&1
-PARTMODE=`echo $PMODES | xargs dialog --backtitle "$OSNAME Installer" \
+exec 5>&1
+PARTMODE=`echo $PMODES | xargs -o bsddialog --backtitle "$OSNAME Installer" \
--title "Partitioning" \
--item-help \
--menu "How would you like to partition your disk?" \
- 0 0 0 2>&1 1>&3` || exit 1
-exec 3>&-
+ 0 0 0 2>&1 1>&5` || exit 1
+exec 5>&-
case "$PARTMODE" in
"$msg_auto_zfs") # ZFS
@@ -334,11 +337,13 @@ case "$PARTMODE" in
;;
esac
+[ -f /usr/libexec/bsdinstall/local.pre-fetch ] && f_dprintf "Running local.pre-fetch" && sh /usr/libexec/bsdinstall/local.pre-fetch "$BSDINSTALL_CHROOT"
+
if [ -n "$FETCH_DISTRIBUTIONS" ]; then
- exec 3>&1
- export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&3)
+ exec 5>&1
+ export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&5)
FETCH_RESULT=$?
- exec 3>&-
+ exec 5>&-
[ $FETCH_RESULT -ne 0 ] && error "Could not fetch remote distributions"
fi
@@ -348,74 +353,25 @@ bsdinstall distextract || error "Distribution extract failed"
# Set up boot loader
bsdinstall bootconfig || error "Failed to configure bootloader"
+[ -f /usr/libexec/bsdinstall/local.pre-configure ] && f_dprintf "Running local.pre-configure" && sh /usr/libexec/bsdinstall/local.pre-configure "$BSDINSTALL_CHROOT"
+
bsdinstall rootpass || error "Could not set root password"
trap true SIGINT # This section is optional
if [ "$NETCONFIG_DONE" != yes ]; then
bsdinstall netconfig # Don't check for errors -- the user may cancel
fi
-bsdinstall time
-bsdinstall services
-bsdinstall hardening
+[ -z "$BSDINSTALL_SKIP_TIME" ] && bsdinstall time
+[ -z "$BSDINSTALL_SKIP_SERVICES" ] && bsdinstall services
+[ -z "$BSDINSTALL_SKIP_HARDENING" ] && bsdinstall hardening
-dialog --backtitle "$OSNAME Installer" --title "Add User Accounts" --yesno \
+[ -z "$BSDINSTALL_SKIP_USERS" ] && bsddialog --backtitle "$OSNAME Installer" \
+ --title "Add User Accounts" --yesno \
"Would you like to add users to the installed system now?" 0 0 && \
bsdinstall adduser
-finalconfig() {
- exec 3>&1
- REVISIT=$(dialog --backtitle "$OSNAME Installer" \
- --title "Final Configuration" --no-cancel --menu \
- "Setup of your $OSNAME system is nearly complete. You can now modify your configuration choices. After this screen, you will have an opportunity to make more complex changes using a shell." 0 0 0 \
- "Exit" "Apply configuration and exit installer" \
- "Add User" "Add a user to the system" \
- "Root Password" "Change root password" \
- "Hostname" "Set system hostname" \
- "Network" "Networking configuration" \
- "Services" "Set daemons to run on startup" \
- "System Hardening" "Set security options" \
- "Time Zone" "Set system timezone" \
- "Handbook" "Install $OSNAME Handbook (requires network)" 2>&1 1>&3)
- exec 3>&-
-
- case "$REVISIT" in
- "Add User")
- bsdinstall adduser
- finalconfig
- ;;
- "Root Password")
- bsdinstall rootpass
- finalconfig
- ;;
- "Hostname")
- bsdinstall hostname
- finalconfig
- ;;
- "Network")
- bsdinstall netconfig
- finalconfig
- ;;
- "Services")
- bsdinstall services
- finalconfig
- ;;
- "System Hardening")
- bsdinstall hardening
- finalconfig
- ;;
- "Time Zone")
- bsdinstall time
- finalconfig
- ;;
- "Handbook")
- bsdinstall docsinstall
- finalconfig
- ;;
- esac
-}
-
# Allow user to change his mind
-finalconfig
+[ -z "$BSDINSTALL_SKIP_FINALCONFIG" ] && bsdinstall finalconfig
trap error SIGINT # SIGINT is bad again
bsdinstall config || error "Failed to save config"
@@ -424,14 +380,18 @@ if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then
rm -rf "$BSDINSTALL_FETCHDEST"
fi
-dialog --backtitle "$OSNAME Installer" --title "Manual Configuration" \
- --default-button no --yesno \
- "The installation is now finished. Before exiting the installer, would you like to open a shell in the new system to make any final manual modifications?" 0 0
-if [ $? -eq 0 ]; then
- clear
- echo This shell is operating in a chroot in the new system. \
- When finished making configuration changes, type \"exit\".
- chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1
+[ -f /usr/libexec/bsdinstall/local.post-configure ] && f_dprintf "Running local.post-configure" && sh /usr/libexec/bsdinstall/local.post-configure "$BSDINSTALL_CHROOT"
+
+if [ -z "$BSDINSTALL_SKIP_MANUAL" ]; then
+ bsddialog --backtitle "$OSNAME Installer" --title "Manual Configuration" \
+ --default-no --yesno \
+ "The installation is now finished. Before exiting the installer, would you like to open a shell in the new system to make any final manual modifications?" 0 0
+ if [ $? -eq 0 ]; then
+ clear
+ echo This shell is operating in a chroot in the new system. \
+ When finished making configuration changes, type \"exit\".
+ chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1
+ fi
fi
bsdinstall entropy
diff --git a/usr.sbin/bsdinstall/scripts/bootconfig b/usr.sbin/bsdinstall/scripts/bootconfig
index cb641beaa89e..bd69195f76ff 100755
--- a/usr.sbin/bsdinstall/scripts/bootconfig
+++ b/usr.sbin/bsdinstall/scripts/bootconfig
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
BSDCFG_SHARE="/usr/share/bsdconfig"
@@ -71,7 +70,7 @@ update_uefi_bootentry()
return
fi
- $DIALOG --backtitle "$OSNAME Installer" --title 'Boot configuration' \
+ $DIALOG --backtitle "$OSNAME Installer" --title 'Boot Configuration' \
--yesno "There are multiple \"$OSNAME\" EFI boot entries. Would you like to remove them all and add a new one?" 0 0
if [ $? -eq $DIALOG_OK ]; then
for entry in $(efibootmgr | awk "\$NF == \"$EFI_LABEL_NAME\" { sub(/.*Boot/,\"\", \$1); sub(/\*/,\"\", \$1); print \$1 }"); do
@@ -86,7 +85,7 @@ update_uefi_bootentry()
efibootmgr --create --activate --label "$FREEBSD_BOOTLABEL" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null
}
-f_dialog_title "Boot configuration"
+f_dialog_title "Boot Configuration"
f_dialog_backtitle "$OSNAME Installer"
if [ `uname -m` == powerpc ]; then
diff --git a/usr.sbin/bsdinstall/scripts/checksum b/usr.sbin/bsdinstall/scripts/checksum
index 003ef608254d..ee93cb342f25 100755
--- a/usr.sbin/bsdinstall/scripts/checksum
+++ b/usr.sbin/bsdinstall/scripts/checksum
@@ -24,21 +24,26 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
test -f $BSDINSTALL_DISTDIR/MANIFEST || exit 0
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+dist_to_statusvar()
+{
+ printf 'status_'
+ echo "$1" | sed 's/_/__/g;s/\./_dot_/g;s/-/_dash_/g'
+}
+
percentage=0
for dist in $DISTRIBUTIONS; do
- distname=$(basename $dist .txz)
- eval "status_$distname=-8"
+ statusvar=$(dist_to_statusvar $dist)
+ eval "$statusvar=-8"
items=""
for i in $DISTRIBUTIONS; do
- items="$items $i `eval echo \\\${status_$(basename $i .txz):--11}`"
+ items="$items $i `eval echo \\\${$(dist_to_statusvar $i):--11}`"
done
bsddialog --backtitle "$OSNAME Installer" --title "Checksum Verification" \
--mixedgauge "\nVerifying checksums of selected distributions.\n" \
@@ -58,17 +63,17 @@ for dist in $DISTRIBUTIONS; do
CK_VALID=$?
if [ $CK_VALID -le 1 ]; then
if [ $CK_VALID -eq 0 ]; then
- eval "status_$distname=-3"
+ eval "$statusvar=-3"
else
- eval "status_$distname=-7"
+ eval "$statusvar=-7"
fi
percentage=$(echo $percentage + 100/`echo $DISTRIBUTIONS | wc -w` | bc)
else
- eval "status_$distname=-2"
+ eval "$statusvar=-2"
case $(/bin/freebsd-version -u) in
*-ALPHA*|*-CURRENT|*-STABLE|*-PRERELEASE)
bsddialog --backtitle "$OSNAME Installer" --title "Error" \
- --msgbox "The checksum for $dist does not match. It may have become corrupted, or it may be from a newer version of FreeBSD. Please check for a newer snapshot." 0 0
+ --msgbox "The checksum for $dist does not match. It may have become corrupted, or it may be from a newer version of $OSNAME. Please check for a newer snapshot." 0 0
;;
*)
bsddialog --backtitle "$OSNAME Installer" --title "Error" \
diff --git a/usr.sbin/bsdinstall/scripts/config b/usr.sbin/bsdinstall/scripts/config
index a909c3faee63..093d38ee0a59 100755
--- a/usr.sbin/bsdinstall/scripts/config
+++ b/usr.sbin/bsdinstall/scripts/config
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ MAIN
diff --git a/usr.sbin/bsdinstall/scripts/docsinstall b/usr.sbin/bsdinstall/scripts/docsinstall
index c24941658a88..8d22fdaa07b6 100755
--- a/usr.sbin/bsdinstall/scripts/docsinstall
+++ b/usr.sbin/bsdinstall/scripts/docsinstall
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -42,7 +41,7 @@ f_include $BSDCFG_SHARE/packages/packages.subr
# List of languages to display (descriptions pulled from $msg_{lang}doc_desc)
#
: ${DOCSINSTALL_LANGS:=\
- bn da de el en es fr hu it ja ko mn nl pl pt ru tr zh_cn zh_tw \
+ bn da de el en es fr hu id it ja ko mn nl pl pt ru tr zh_cn zh_tw \
}
############################################################ GLOBALS
@@ -63,6 +62,7 @@ msg_frdoc_desc="French Documentation"
msg_freebsd_documentation_installation="$OSNAME Documentation Installation"
msg_freebsd_installer="$OSNAME Installer"
msg_hudoc_desc="Hungarian Documentation"
+msg_iddoc_desc="Indonesian Documentation"
msg_itdoc_desc="Italian Documentation"
msg_jadoc_desc="Japanese Documentation"
msg_kodoc_desc="Korean Documentation"
diff --git a/usr.sbin/bsdinstall/scripts/entropy b/usr.sbin/bsdinstall/scripts/entropy
index d3938f12cb33..91ccbf99fbcc 100755
--- a/usr.sbin/bsdinstall/scripts/entropy
+++ b/usr.sbin/bsdinstall/scripts/entropy
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
umask 077
for i in /entropy /boot/entropy; do
diff --git a/usr.sbin/bsdinstall/scripts/fetchmissingdists b/usr.sbin/bsdinstall/scripts/fetchmissingdists
index a553eacd00c9..d37acc96b92c 100644
--- a/usr.sbin/bsdinstall/scripts/fetchmissingdists
+++ b/usr.sbin/bsdinstall/scripts/fetchmissingdists
@@ -25,12 +25,14 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+
error()
{
- bsddialog --backtitle "FreeBSD Installer" --title "Error" --msgbox "$1" 0 0
+ bsddialog --backtitle "$OSNAME Installer" --title "Error" --msgbox "$1" 0 0
exit 1
}
@@ -59,10 +61,10 @@ BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist"
mkdir -p "$BSDINSTALL_FETCHDEST" || error "Could not create directory $BSDINSTALL_FETCHDEST"
if [ -z "$BSDINSTALL_DISTSITE" ]; then
- exec 3>&1
- BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
+ exec 5>&1
+ BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&5)
MIRROR_BUTTON=$?
- exec 3>&-
+ exec 5>&-
test $MIRROR_BUTTON -eq 0 || error "No mirror selected"
export BSDINSTALL_DISTSITE
fi
@@ -85,7 +87,7 @@ fi
if [ ! -z "$LOCAL_DISTRIBUTIONS" ]; then
# Copy local stuff first
env DISTRIBUTIONS="$LOCAL_DISTRIBUTIONS" \
- BSDINSTALL_DISTSITE="file://$BSDINSTALL_DISTDIR" \
+ BSDINSTALL_DISTSITE="file://$BSDINSTALL_DISTDIR_ORIG" \
bsdinstall distfetch || \
error "Failed to fetch distribution from local media"
fi
diff --git a/usr.sbin/bsdinstall/scripts/finalconfig b/usr.sbin/bsdinstall/scripts/finalconfig
new file mode 100755
index 000000000000..d7c4a1569d39
--- /dev/null
+++ b/usr.sbin/bsdinstall/scripts/finalconfig
@@ -0,0 +1,82 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011 Nathan Whitehorn
+# Copyright (c) 2013-2018 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+
+: ${BSDDIALOG_OK=0}
+
+while true; do
+ exec 5>&1
+ REVISIT=$(bsddialog --backtitle "$OSNAME Installer" \
+ --title "Final Configuration" --ok-label "Select" \
+ --cancel-label "Finish" --default-no --menu \
+ "Setup of your $OSNAME system is nearly complete. You can now modify your configuration choices. After this screen, you will have an opportunity to make more complex changes using a shell." 0 0 0 \
+ "Add User" "Add a user to the system" \
+ "Root Password" "Change root password" \
+ "Hostname" "Set system hostname" \
+ "Network" "Networking configuration" \
+ "Services" "Set daemons to run on startup" \
+ "System Hardening" "Set security options" \
+ "Time Zone" "Set system timezone" \
+ "Handbook" "Install $OSNAME Handbook (requires network)" 2>&1 1>&5)
+ retval=$?
+ exec 5>&-
+
+ if [ $retval -ne $BSDDIALOG_OK ]; then
+ break
+ fi
+
+ case "$REVISIT" in
+ "Add User")
+ bsdinstall adduser
+ ;;
+ "Root Password")
+ bsdinstall rootpass
+ ;;
+ "Hostname")
+ bsdinstall hostname
+ ;;
+ "Network")
+ bsdinstall netconfig
+ ;;
+ "Services")
+ bsdinstall services
+ ;;
+ "System Hardening")
+ bsdinstall hardening
+ ;;
+ "Time Zone")
+ bsdinstall time
+ ;;
+ "Handbook")
+ bsdinstall docsinstall
+ ;;
+ esac
+done
diff --git a/usr.sbin/bsdinstall/scripts/hardening b/usr.sbin/bsdinstall/scripts/hardening
index 4ee738fe0166..a77fcdeaf540 100755
--- a/usr.sbin/bsdinstall/scripts/hardening
+++ b/usr.sbin/bsdinstall/scripts/hardening
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
@@ -35,7 +34,7 @@ echo -n > $BSDINSTALL_TMPETC/rc.conf.hardening
echo -n > $BSDINSTALL_TMPETC/sysctl.conf.hardening
echo -n > $BSDINSTALL_TMPBOOT/loader.conf.hardening
-exec 3>&1
+exec 5>&1
FEATURES=$( bsddialog --backtitle "$OSNAME Installer" \
--title "System Hardening" --nocancel --separate-output \
--checklist "Choose system security hardening options:" \
@@ -48,12 +47,11 @@ FEATURES=$( bsddialog --backtitle "$OSNAME Installer" \
"5 random_pid" "Randomize the PID of newly created processes" ${random_pid:-off} \
"6 clear_tmp" "Clean the /tmp filesystem on system startup" ${clear_tmp:-off} \
"7 disable_syslogd" "Disable opening Syslogd network socket (disables remote logging)" ${disable_syslogd:-off} \
- "8 disable_sendmail" "Disable Sendmail service" ${disable_sendmail:-off} \
- "9 secure_console" "Enable console password prompt" ${secure_console:-off} \
- "10 disable_ddtrace" "Disallow DTrace destructive-mode" ${disable_ddtrace:-off} \
-2>&1 1>&3 )
+ "8 secure_console" "Enable console password prompt" ${secure_console:-off} \
+ "9 disable_ddtrace" "Disallow DTrace destructive-mode" ${disable_ddtrace:-off} \
+2>&1 1>&5 )
retval=$?
-exec 3>&-
+exec 5>&-
if [ $retval -ne $BSDDIALOG_OK ]; then
exit 1
@@ -85,9 +83,6 @@ for feature in $FEATURES; do
disable_syslogd)
echo 'syslogd_flags="-ss"' >> $BSDINSTALL_TMPETC/rc.conf.hardening
;;
- disable_sendmail)
- echo 'sendmail_enable="NONE"' >> $BSDINSTALL_TMPETC/rc.conf.hardening
- ;;
secure_console)
sed "s/unknown off secure/unknown off insecure/g" $BSDINSTALL_CHROOT/etc/ttys > $BSDINSTALL_TMPETC/ttys.hardening
;;
diff --git a/usr.sbin/bsdinstall/scripts/hostname b/usr.sbin/bsdinstall/scripts/hostname
index eff2bc28e586..19df8885893b 100755
--- a/usr.sbin/bsdinstall/scripts/hostname
+++ b/usr.sbin/bsdinstall/scripts/hostname
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -48,8 +47,6 @@ f_include $BSDCFG_SHARE/dialog.subr
############################################################ GLOBALS
-: ${BSDDIALOG_CANCEL=1}
-
#
# Strings that should be moved to an i18n file and loaded with f_include_lang()
#
@@ -73,17 +70,21 @@ SET_HOSTNAME='hostname -s "%s"'
dialog_hostname()
{
local prompt="$msg_please_choose_a_hostname"
- local hline="Use TAB and Enter to select $msg_ok"
+ local hline=
local value="$*"
- bsddialog \
+ local height width
+ f_dialog_inputbox_size height width \
+ "$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$prompt" "$value" "$hline"
+
+ $DIALOG \
--title "$DIALOG_TITLE" \
--backtitle "$DIALOG_BACKTITLE" \
--hline "$hline" \
--ok-label "$msg_ok" \
--no-cancel \
--inputbox "$prompt" \
- 0 56 "$value" \
+ $height $width "$value" \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
}
@@ -99,7 +100,7 @@ f_dialog_backtitle "$msg_freebsd_installer"
# Get user input
#
HOSTNAME=$( dialog_hostname "$HOSTNAME" )
-[ $? -eq $BSDDIALOG_CANCEL ] && exit 1
+[ $? -eq $DIALOG_CANCEL ] && exit 1
#
# Store the user's choice
diff --git a/usr.sbin/bsdinstall/scripts/jail b/usr.sbin/bsdinstall/scripts/jail
index 97460d92034a..9acea20a34d8 100755
--- a/usr.sbin/bsdinstall/scripts/jail
+++ b/usr.sbin/bsdinstall/scripts/jail
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -37,7 +36,6 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
: ${BSDDIALOG_OK=0}
f_dprintf "Began Installation at %s" "$( date )"
-export BSDINSTALL_CHROOT=$1
error() {
local msg
@@ -50,27 +48,38 @@ error() {
if [ $? -ne $BSDDIALOG_OK ]; then
exit
else
+ [ -z "$MIRROR_BUTTON" ] || unset BSDINSTALL_DISTSITE
exec $0 $BSDINSTALL_CHROOT
fi
}
+if [ -z "$1" ]; then
+ error "Directory can not be empty\n\nUsage:\nbsdinstall jail directory"
+fi
+export BSDINSTALL_CHROOT=$1
+
rm -rf $BSDINSTALL_TMPETC
mkdir $BSDINSTALL_TMPETC
mkdir -p $1 || error "mkdir failed for $1"
+rm -f $TMPDIR/bsdinstall-installscript-setup
-if [ -n "$SCRIPT" ]
-then
- split -a 2 -p '^#!.*' "$SCRIPT" $TMPDIR/bsdinstall-installscript-
- . $TMPDIR/bsdinstall-installscript-aa
+if [ -n "$SCRIPT" ]; then
+ # split script into preamble and setup script at first shebang
+ awk 'BEGIN {pathb=ARGV[2]; ARGV[2]=""} /^#!/{b=1} {
+ if (b) print >pathb; else print}' \
+ "$SCRIPT" $TMPDIR/bsdinstall-installscript-setup \
+ >$TMPDIR/bsdinstall-installscript-preamble
+
+ . $TMPDIR/bsdinstall-installscript-preamble
fi
test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR
if [ ! -f $BSDINSTALL_DISTDIR/MANIFEST -a -z "$BSDINSTALL_DISTSITE" ]; then
- exec 3>&1
- BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
+ exec 5>&1
+ BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&5)
MIRROR_BUTTON=$?
- exec 3>&-
+ exec 5>&-
test $MIRROR_BUTTON -eq 0 || error "No mirror selected"
export BSDINSTALL_DISTSITE
fetch -o $BSDINSTALL_DISTDIR/MANIFEST $BSDINSTALL_DISTSITE/MANIFEST || error "Could not download $BSDINSTALL_DISTSITE/MANIFEST"
@@ -82,13 +91,13 @@ if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
if [ ! "$nonInteractive" == "YES" ]
then
- exec 3>&1
+ exec 5>&1
EXTRA_DISTS=$(echo $DISTMENU | xargs -o bsddialog \
--backtitle "$OSNAME Installer" \
--title "Distribution Select" --no-cancel --separate-output \
--checklist "Choose optional system components to install:" \
0 0 0 \
- 2>&1 1>&3)
+ 2>&1 1>&5)
for dist in $EXTRA_DISTS; do
export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz"
done
@@ -104,10 +113,10 @@ done
FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space
if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then
- exec 3>&1
- BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
+ exec 5>&1
+ BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&5)
MIRROR_BUTTON=$?
- exec 3>&-
+ exec 5>&-
test $MIRROR_BUTTON -eq 0 || error "No mirror selected"
export BSDINSTALL_DISTSITE
fi
@@ -142,8 +151,9 @@ cp /etc/localtime $1/etc
cp /var/db/zoneinfo $1/var/db
# Run post-install script
-if [ -f $TMPDIR/bsdinstall-installscript-ab ]; then
- cp $TMPDIR/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript
+if [ -f $TMPDIR/bsdinstall-installscript-setup ]; then
+ cp $TMPDIR/bsdinstall-installscript-setup \
+ $BSDINSTALL_CHROOT/tmp/installscript
chmod a+x $BSDINSTALL_CHROOT/tmp/installscript
mount -t devfs devfs "$BSDINSTALL_CHROOT/dev"
chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1
diff --git a/usr.sbin/bsdinstall/scripts/keymap b/usr.sbin/bsdinstall/scripts/keymap
index 691e5221953f..6f4060c0772e 100755
--- a/usr.sbin/bsdinstall/scripts/keymap
+++ b/usr.sbin/bsdinstall/scripts/keymap
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -196,7 +195,7 @@ while :; do
--default-item \"\$defaultitem\" \
--menu \"\$prompt\" \
$height $width $rows \
- $menu_list \
+ ${USE_DIALOG:+--} $menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
) || {
f_quietly rm -f "$KEYMAPFILE"
diff --git a/usr.sbin/bsdinstall/scripts/mirrorselect b/usr.sbin/bsdinstall/scripts/mirrorselect
index a613a097e69a..05eff9fee56e 100755
--- a/usr.sbin/bsdinstall/scripts/mirrorselect
+++ b/usr.sbin/bsdinstall/scripts/mirrorselect
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
@@ -36,114 +35,61 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
: ${BSDDIALOG_ESC=5}
: ${BSDDIALOG_ERROR=255}
-exec 3>&1
+exec 5>&1
MIRROR=`bsddialog --backtitle "$OSNAME Installer" \
--title "Mirror Selection" --extra-button --extra-label "Other" \
- --menu "Please select the site closest to you or \"other\" if you'd like to specify a different choice. Also note that not every site listed here carries more than the base distribution kits. Only Primary sites are guaranteed to carry the full range of possible distributions. Select a site that's close!" \
+ --menu "Please select the best suitable site for you or \"other\" if you want to specify a different choice. The \"Main Site\" directs users to the nearest project managed mirror via GeoDNS (they carry the full range of possible distributions and support both IPv4 and IPv6). All other sites are known as \"Community Mirrors\"; not every site listed here carries more than the base distribution kits. Select a site!" \
0 0 16 \
- ftp://ftp.freebsd.org "Main Site"\
- ftp://ftp.freebsd.org "IPv6 Main Site"\
- ftp://ftp3.ie.freebsd.org "IPv6 Ireland"\
- ftp://ftp2.jp.freebsd.org "IPv6 Japan"\
- ftp://ftp4.se.freebsd.org "IPv6 Sweden"\
- ftp://ftp4.us.freebsd.org "IPv6 USA"\
- ftp://ftp1.freebsd.org "Primary"\
- ftp://ftp2.freebsd.org "Primary #2"\
- ftp://ftp3.freebsd.org "Primary #3"\
- ftp://ftp4.freebsd.org "Primary #4"\
- ftp://ftp5.freebsd.org "Primary #5"\
- ftp://ftp6.freebsd.org "Primary #6"\
- ftp://ftp7.freebsd.org "Primary #7"\
- ftp://ftp10.freebsd.org "Primary #10"\
- ftp://ftp11.freebsd.org "Primary #11"\
- ftp://ftp12.freebsd.org "Primary #12"\
- ftp://ftp13.freebsd.org "Primary #13"\
- ftp://ftp14.freebsd.org "Primary #14"\
- ftp://ftp.au.freebsd.org "Australia"\
- ftp://ftp2.au.freebsd.org "Australia #2"\
+ http://ftp.freebsd.org "Main Site (GeoDNS, HTTP)"\
+ ftp://ftp.freebsd.org "Main Site (GeoDNS, FTP)"\
+ http://ftp.au.freebsd.org "Australia - IPv6"\
ftp://ftp3.au.freebsd.org "Australia #3"\
- ftp://ftp.at.freebsd.org "Austria"\
+ ftp://ftp.at.freebsd.org "Austria - IPv6"\
ftp://ftp2.br.freebsd.org "Brazil #2"\
ftp://ftp3.br.freebsd.org "Brazil #3"\
- ftp://ftp4.br.freebsd.org "Brazil #4"\
- ftp://ftp.bg.freebsd.org "Bulgaria"\
- ftp://ftp.cn.freebsd.org "China"\
- ftp://ftp.cz.freebsd.org "Czech Republic"\
- ftp://ftp.dk.freebsd.org "Denmark"\
+ ftp://ftp.bg.freebsd.org "Bulgaria - IPv6"\
+ ftp://ftp.cz.freebsd.org "Czech Republic - IPv6"\
+ ftp://ftp.dk.freebsd.org "Denmark - IPv6"\
ftp://ftp.fi.freebsd.org "Finland"\
- ftp://ftp.fr.freebsd.org "France"\
+ ftp://ftp.fr.freebsd.org "France - IPv6"\
ftp://ftp3.fr.freebsd.org "France #3"\
- ftp://ftp4.fr.freebsd.org "IPv6 France #4"\
- ftp://ftp5.fr.freebsd.org "France #5"\
ftp://ftp6.fr.freebsd.org "France #6"\
- ftp://ftp7.fr.freebsd.org "France #7"\
- ftp://ftp8.fr.freebsd.org "IPv6 France #8"\
- ftp://ftp.de.freebsd.org "Germany"\
- ftp://ftp2.de.freebsd.org "Germany #2"\
- ftp://ftp4.de.freebsd.org "Germany #4"\
- ftp://ftp5.de.freebsd.org "Germany #5"\
- ftp://ftp7.de.freebsd.org "Germany #7"\
- ftp://ftp8.de.freebsd.org "Germany #8"\
- ftp://ftp.gr.freebsd.org "Greece"\
- ftp://ftp2.gr.freebsd.org "Greece #2"\
- ftp://ftp3.ie.freebsd.org "Ireland #3"\
- ftp://ftp.jp.freebsd.org "Japan"\
+ ftp://ftp.de.freebsd.org "Germany - IPv6"\
+ ftp://ftp1.de.freebsd.org "Germany #1 - IPv6"\
+ ftp://ftp2.de.freebsd.org "Germany #2 - IPv6"\
+ ftp://ftp5.de.freebsd.org "Germany #5 - IPv6"\
+ ftp://ftp7.de.freebsd.org "Germany #7 - IPv6"\
+ ftp://ftp.gr.freebsd.org "Greece - IPv6"\
+ ftp://ftp2.gr.freebsd.org "Greece #2 - IPv6"\
+ ftp://ftp.jp.freebsd.org "Japan - IPv6"\
ftp://ftp2.jp.freebsd.org "Japan #2"\
ftp://ftp3.jp.freebsd.org "Japan #3"\
ftp://ftp4.jp.freebsd.org "Japan #4"\
- ftp://ftp5.jp.freebsd.org "Japan #5"\
- ftp://ftp6.jp.freebsd.org "Japan #6"\
- ftp://ftp7.jp.freebsd.org "Japan #7"\
- ftp://ftp8.jp.freebsd.org "Japan #8"\
- ftp://ftp9.jp.freebsd.org "Japan #9"\
+ ftp://ftp6.jp.freebsd.org "Japan #6 - IPv6"\
ftp://ftp.kr.freebsd.org "Korea"\
ftp://ftp2.kr.freebsd.org "Korea #2"\
ftp://ftp.lv.freebsd.org "Latvia"\
- ftp://ftp.nl.freebsd.org "Netherlands"\
+ ftp://ftp.nl.freebsd.org "Netherlands - IPv6"\
ftp://ftp2.nl.freebsd.org "Netherlands #2"\
ftp://ftp.nz.freebsd.org "New Zealand"\
- ftp://ftp.no.freebsd.org "Norway"\
- ftp://ftp.pl.freebsd.org "Poland"\
- ftp://ftp.ru.freebsd.org "Russia"\
+ ftp://ftp.no.freebsd.org "Norway - IPv6"\
+ ftp://ftp.pl.freebsd.org "Poland - IPv6"\
+ ftp://ftp.ru.freebsd.org "Russia - IPv6"\
ftp://ftp2.ru.freebsd.org "Russia #2"\
- ftp://ftp5.ru.freebsd.org "Russia #5"\
- ftp://ftp6.ru.freebsd.org "Russia #6"\
- ftp://ftp.sk.freebsd.org "Slovak Republic"\
- ftp://ftp2.sk.freebsd.org "Slovak Republic #2"\
- ftp://ftp.si.freebsd.org "Slovenia"\
- ftp://ftp.za.freebsd.org "South Africa"\
- ftp://ftp2.za.freebsd.org "South Africa #2"\
+ ftp://ftp.si.freebsd.org "Slovenia - IPv6"\
+ ftp://ftp.za.freebsd.org "South Africa - IPv6"\
+ ftp://ftp2.za.freebsd.org "South Africa #2 - IPv6"\
ftp://ftp4.za.freebsd.org "South Africa #4"\
- ftp://ftp.se.freebsd.org "Sweden"\
- ftp://ftp4.se.freebsd.org "Sweden #4"\
- ftp://ftp.ch.freebsd.org "Switzerland"\
- ftp://ftp.tw.freebsd.org "Taiwan"\
- ftp://ftp2.tw.freebsd.org "Taiwan #2"\
- ftp://ftp3.tw.freebsd.org "Taiwan #3"\
+ ftp://ftp.se.freebsd.org "Sweden - IPv6"\
ftp://ftp4.tw.freebsd.org "Taiwan #4"\
- ftp://ftp6.tw.freebsd.org "Taiwan #6"\
- ftp://ftp11.tw.freebsd.org "Taiwan #11"\
- ftp://ftp.uk.freebsd.org "UK"\
- ftp://ftp2.uk.freebsd.org "UK #2"\
- ftp://ftp3.uk.freebsd.org "UK #3"\
- ftp://ftp4.uk.freebsd.org "UK #4"\
- ftp://ftp5.uk.freebsd.org "UK #5"\
- ftp://ftp.ua.freebsd.org "Ukraine"\
- ftp://ftp1.us.freebsd.org "USA #1"\
- ftp://ftp2.us.freebsd.org "USA #2"\
- ftp://ftp3.us.freebsd.org "USA #3"\
- ftp://ftp4.us.freebsd.org "USA #4"\
- ftp://ftp5.us.freebsd.org "USA #5"\
- ftp://ftp6.us.freebsd.org "USA #6"\
- ftp://ftp8.us.freebsd.org "USA #8"\
- ftp://ftp10.us.freebsd.org "USA #10"\
- ftp://ftp11.us.freebsd.org "USA #11"\
- ftp://ftp13.us.freebsd.org "USA #13"\
- ftp://ftp14.us.freebsd.org "USA #14"\
- ftp://ftp15.us.freebsd.org "USA #15"\
- 2>&1 1>&3`
+ ftp://ftp5.tw.freebsd.org "Taiwan #5"\
+ ftp://ftp.uk.freebsd.org "UK - IPv6"\
+ ftp://ftp2.uk.freebsd.org "UK #2 - IPv6"\
+ ftp://ftp.ua.FreeBSD.org "Ukraine - IPv6"\
+ ftp://ftp5.us.freebsd.org "USA #5 - IPv6"\
+ 2>&1 1>&5`
MIRROR_BUTTON=$?
-exec 3>&-
+exec 5>&-
_UNAME_R=`uname -r`
_UNAME_R=${_UNAME_R%-p*}
@@ -166,13 +112,13 @@ $BSDDIALOG_ERROR | $BSDDIALOG_CANCEL | $BSDDIALOG_ESC)
$BSDDIALOG_OK)
;;
$BSDDIALOG_EXTRA)
- exec 3>&1
+ exec 5>&1
BSDINSTALL_DISTSITE=`bsddialog --backtitle "$OSNAME Installer" \
--title "Mirror Selection" \
--inputbox "Please enter the URL to an alternate $OSNAME mirror:" \
- 0 74 "$BSDINSTALL_DISTSITE" 2>&1 1>&3`
+ 0 74 "$BSDINSTALL_DISTSITE" 2>&1 1>&5`
MIRROR_BUTTON=$?
- exec 3>&-
+ exec 5>&-
test $MIRROR_BUTTON -eq $BSDDIALOG_OK || exec $0 $@
;;
esac
diff --git a/usr.sbin/bsdinstall/scripts/mount b/usr.sbin/bsdinstall/scripts/mount
index 2d7ce14fe045..fd13e13c6a77 100755
--- a/usr.sbin/bsdinstall/scripts/mount
+++ b/usr.sbin/bsdinstall/scripts/mount
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
@@ -56,3 +55,9 @@ done
# User might want a shell and require devfs, so mount it
mkdir $BSDINSTALL_CHROOT/dev 2>/dev/null
mount -t devfs devfs $BSDINSTALL_CHROOT/dev
+
+# If installing from the DVD, mount packages where they'll be accessible
+if [ -d /packages ]; then
+ mkdir -p $BSDINSTALL_CHROOT/dist/packages
+ mount -t nullfs /packages $BSDINSTALL_CHROOT/dist/packages
+fi
diff --git a/usr.sbin/bsdinstall/scripts/netconfig b/usr.sbin/bsdinstall/scripts/netconfig
index c5b41dcdef6a..0f23ae134cb6 100755
--- a/usr.sbin/bsdinstall/scripts/netconfig
+++ b/usr.sbin/bsdinstall/scripts/netconfig
@@ -29,7 +29,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
@@ -50,7 +49,8 @@ for IF in `ifconfig -l`; do
INTERFACES="$INTERFACES $IF"
done
-INTERFACES="$INTERFACES $(sysctl -in net.wlan.devices)"
+WIRELESS_INTERFACES="$(sysctl -in net.wlan.devices)"
+INTERFACES="$INTERFACES${WIRELESS_INTERFACES:+ }$WIRELESS_INTERFACES"
is_wireless_if() {
for IF in $(sysctl -in net.wlan.devices); do
if [ $IF = $1 ]; then
@@ -67,22 +67,35 @@ done
if [ -z "$INTERFACES" ]; then
bsddialog --backtitle "$OSNAME Installer" \
- --title 'Network Configuration Error' \
+ --title 'Network Configuration' \
--msgbox 'No network interfaces present to configure.' 0 0
exit 1
fi
-exec 3>&1
-INTERFACE=`echo $BSDDIALOG_ITEMS | xargs -o bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' --menu 'Please select a network interface to configure:' 0 0 0 2>&1 1>&3`
-if [ $? -eq $BSDDIALOG_CANCEL ]; then exit 1; fi
-exec 3>&-
+exec 5>&1
+INTERFACE=$(echo $BSDDIALOG_ITEMS | xargs -o bsddialog \
+ --backtitle "$OSNAME Installer" --title 'Network Configuration' \
+ --ok-label 'Auto' --extra-button --extra-label 'Manual' \
+ --menu 'Please select a network interface and configuration mode:' 0 0 0 2>&1 1>&5)
+# xargs collapses exit codes to 0/1 (ignoring signals and 255), so exploit
+# bsddialog output being empty when cancelling to distinguish Manual (Extra)
+# from Cancel.
+if [ $? -eq $BSDDIALOG_OK ]; then
+ AUTO=auto
+else
+ if [ -z "$INTERFACE" ]; then
+ exit 1
+ fi
+ AUTO=
+fi
+exec 5>&-
: > $BSDINSTALL_TMPETC/._rc.conf.net
IFCONFIG_PREFIX=""
if is_wireless_if $INTERFACE; then
NEXT_WLAN_IFACE=wlan0 # XXX
- echo wlans_$INTERFACE=\"$NEXT_WLAN_IFACE\" >> $BSDINSTALL_TMPETC/._rc.conf.net
+ sysrc -f $BSDINSTALL_TMPETC/._rc.conf.net wlans_$INTERFACE="$NEXT_WLAN_IFACE"
IFCONFIG_PREFIX="WPA "
if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
ifconfig $NEXT_WLAN_IFACE create wlandev $INTERFACE
@@ -103,28 +116,44 @@ case $? in
0) IPV4_AVAIL=1 ;;
esac
-if [ ${IPV4_AVAIL} -eq 1 ]; then
+AUTO_FAIL=
+if [ ${IPV4_AVAIL} -eq 1 -a -z "$AUTO" ]; then
bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \
--yesno 'Would you like to configure IPv4 for this interface?' 0 0
- if [ $? -eq $BSDDIALOG_OK ]; then
- bsdinstall netconfig_ipv4 ${INTERFACE} "${IFCONFIG_PREFIX}" || \
- exec $0
- else
+ if [ $? -ne $BSDDIALOG_OK ]; then
+ IPV4_AVAIL=0
+ fi
+fi
+if [ ${IPV4_AVAIL} -eq 1 ]; then
+ bsdinstall netconfig_ipv4 ${INTERFACE} "${IFCONFIG_PREFIX}" $AUTO
+ if [ $? -ne $BSDDIALOG_OK ]; then
+ if [ -z "$AUTO" ]; then
+ exec $0
+ fi
IPV4_AVAIL=0
+ AUTO_FAIL="$AUTO_FAIL${AUTO_FAIL:+, }IPv4"
fi
fi
# In case wlanconfig left an option and we do not support IPv4 we need to write
# it out on its own. We cannot write it out with IPv6 as that suffix.
if [ ${IPV4_AVAIL} -eq 0 -a -n ${IFCONFIG_PREFIX} ]; then
- echo ifconfig_${INTERFACE}=\"${IFCONFIG_PREFIX}\" >> $BSDINSTALL_TMPETC/._rc.conf.net
+ sysrc -f $BSDINSTALL_TMPETC/._rc.conf.net ifconfig_$INTERFACE="${IFCONFIG_PREFIX}"
fi
-if [ ${IPV6_AVAIL} -eq 1 ]; then
+if [ ${IPV6_AVAIL} -eq 1 -a -z "$AUTO" ]; then
bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \
--yesno 'Would you like to configure IPv6 for this interface?' 0 0
- if [ $? -eq $BSDDIALOG_OK ]; then
- bsdinstall netconfig_ipv6 ${INTERFACE} || exec $0
- else
+ if [ $? -ne $BSDDIALOG_OK ]; then
+ IPV6_AVAIL=0
+ fi
+fi
+if [ ${IPV6_AVAIL} -eq 1 ]; then
+ bsdinstall netconfig_ipv6 ${INTERFACE} $AUTO
+ if [ $? -ne $BSDDIALOG_OK ]; then
+ if [ -z "$AUTO" ]; then
+ exec $0
+ fi
IPV6_AVAIL=0
+ AUTO_FAIL="$AUTO_FAIL${AUTO_FAIL:+, }IPv6"
fi
fi
@@ -180,16 +209,28 @@ elif [ ${IPV4_AVAIL} -eq 1 ]; then
'IPv4 DNS #1' 2 1 \"${IP4_1}\" 2 16 16 16 0
'IPv4 DNS #2' 3 1 \"${IP4_2}\" 3 16 16 16 0"
else
+ if [ -n "$AUTO_FAIL" ]; then
+ bsddialog --backtitle "$OSNAME Installer" \
+ --msgbox "Failed to automatically configure interface (tried $AUTO_FAIL)." 0 0
+ exec $0
+ fi
exit 0
fi
-exec 3>&1
-RESOLV=$(echo "${RESOLV}" | xargs -o bsddialog --backtitle "$OSNAME Installer" \
- --title 'Network Configuration' \
- --mixedform 'Resolver Configuration' 0 0 0 \
-2>&1 1>&3)
-if [ $? -eq $BSDDIALOG_CANCEL ]; then exec $0; fi
-exec 3>&-
+# Auto only guaranteed to have IPv4 and/or IPv6 address; may not have
+# nameserver available
+if [ -n "$AUTO" ] && [ -n "${IP4_1}" -o -n "${IP6_1}" ]; then
+ # Convert from bsddialog arguments to default output
+ RESOLV=$(echo "${RESOLV}" | xargs -n9 sh -c 'echo "$4"' '')
+else
+ exec 5>&1
+ RESOLV=$(echo "${RESOLV}" | xargs -o bsddialog --backtitle "$OSNAME Installer" \
+ --title 'Network Configuration' \
+ --mixedform 'Resolver Configuration' 0 0 0 \
+ 2>&1 1>&5)
+ if [ $? -eq $BSDDIALOG_CANCEL ]; then exec $0; fi
+ exec 5>&-
+fi
echo ${RESOLV} | tr ' ' '\n' | \
awk '
diff --git a/usr.sbin/bsdinstall/scripts/netconfig_ipv4 b/usr.sbin/bsdinstall/scripts/netconfig_ipv4
index b3d6c23d8d77..7e3669f697d9 100755
--- a/usr.sbin/bsdinstall/scripts/netconfig_ipv4
+++ b/usr.sbin/bsdinstall/scripts/netconfig_ipv4
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -41,6 +40,7 @@ f_include $BSDCFG_SHARE/dialog.subr
INTERFACE=$1
IFCONFIG_PREFIX="$2"
+AUTO="${3:-}"
test -z "$IFCONFIG_PREFIX" || IFCONFIG_PREFIX="$2 "
case "${INTERFACE}" in
"") bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \
@@ -48,9 +48,27 @@ case "${INTERFACE}" in
exit 1
;;
esac
+case "$AUTO" in
+""|auto)
+ ;;
+*)
+ bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \
+ --msgbox "Bad auto option '$AUTO'." 0 0
+ exit 1
+ ;;
+esac
-bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' --yesno 'Would you like to use DHCP to configure this interface?' 0 0
-if [ $? -eq $BSDDIALOG_OK ]; then
+if [ -n "$AUTO" ]; then
+ DHCP=1
+else
+ bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' --yesno 'Would you like to use DHCP to configure this interface?' 0 0
+ if [ $? -eq $BSDDIALOG_OK ]; then
+ DHCP=1
+ else
+ DHCP=0
+ fi
+fi
+if [ $DHCP -eq 1 ]; then
if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
# XXX: get interface down otherwise after installation restart
# dhclient does not build a new resolv.conf (see PR262262).
@@ -60,11 +78,14 @@ if [ $? -eq $BSDDIALOG_OK ]; then
err=$( pkill -F /var/run/dhclient/dhclient.${INTERFACE}.pid; dhclient $INTERFACE 2>&1 )
if [ $? -ne 0 ]; then
f_dprintf "%s" "$err"
+ if [ -n "$AUTO" ]; then
+ exit 1
+ fi
bsddialog --backtitle "$OSNAME Installer" --msgbox "DHCP lease acquisition failed." 0 0
exec $0 ${INTERFACE} "${IFCONFIG_PREFIX}"
fi
fi
- echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> $BSDINSTALL_TMPETC/._rc.conf.net
+ sysrc -f $BSDINSTALL_TMPETC/._rc.conf.net ifconfig_$INTERFACE="${IFCONFIG_PREFIX}DHCP"
exit 0
fi
@@ -72,14 +93,14 @@ IP_ADDRESS=`ifconfig $INTERFACE inet | awk '/inet/ {printf("%s\n", $2); }'`
NETMASK=`ifconfig $INTERFACE inet | awk '/inet/ {printf("%s\n", $4); }'`
ROUTER=`netstat -rn -f inet | awk '/default/ {printf("%s\n", $2);}'`
-exec 3>&1
+exec 5>&1
IF_CONFIG=$(bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' --form 'Static Network Interface Configuration' 0 0 0 \
'IP Address' 1 1 "$IP_ADDRESS" 1 20 16 0 \
'Subnet Mask' 2 1 "$NETMASK" 2 20 16 0 \
'Default Router' 3 1 "$ROUTER" 3 20 16 0 \
-2>&1 1>&3)
+2>&1 1>&5)
if [ $? -eq $BSDDIALOG_CANCEL ]; then exit 1; fi
-exec 3>&-
+exec 5>&-
echo $INTERFACE $IF_CONFIG |
awk -v prefix="$IFCONFIG_PREFIX" '{
diff --git a/usr.sbin/bsdinstall/scripts/netconfig_ipv6 b/usr.sbin/bsdinstall/scripts/netconfig_ipv6
index 1a360e00f306..d60a3014ccc4 100755
--- a/usr.sbin/bsdinstall/scripts/netconfig_ipv6
+++ b/usr.sbin/bsdinstall/scripts/netconfig_ipv6
@@ -29,7 +29,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -49,19 +48,38 @@ f_include $BSDCFG_SHARE/dialog.subr
#
INTERFACE=$1
+AUTO="${2:-}"
case "${INTERFACE}" in
"") bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \
--msgbox 'No interface specified for IPv6 configuration.' 0 0
exit 1
;;
esac
+case "$AUTO" in
+""|auto)
+ ;;
+*)
+ bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \
+ --msgbox "Bad auto option '$AUTO'." 0 0
+ exit 1
+ ;;
+esac
AGAIN=""
while : ; do
- MSG="Would you like to try stateless address autoconfiguration (SLAAC)${AGAIN}?"
- bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \
- --yesno "${MSG}" 0 0
- if [ $? -eq $BSDDIALOG_OK ]; then
+ if [ -n "$AUTO" ]; then
+ SLAAC=1
+ else
+ MSG="Would you like to try stateless address autoconfiguration (SLAAC)${AGAIN}?"
+ bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \
+ --yesno "${MSG}" 0 0
+ if [ $? -eq $BSDDIALOG_OK ]; then
+ SLAAC=1
+ else
+ SLAAC=0
+ fi
+ fi
+ if [ $SLAAC -eq 1 ]; then
if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
bsddialog --backtitle "$OSNAME Installer" \
--infobox "Sending Router Solicitation ..." 0 0
@@ -69,12 +87,15 @@ while : ; do
err=$( rtsol -F $INTERFACE 2>&1 )
if [ $? -ne 0 ]; then
f_dprintf "%s" "$err"
+ if [ -n "$AUTO" ]; then
+ exit 1
+ fi
bsddialog --backtitle "$OSNAME Installer" --msgbox "SLAAC failed." 0 0
AGAIN=" again"
continue
fi
fi
- echo ifconfig_${INTERFACE}_ipv6=\"inet6 accept_rtadv\" >> $BSDINSTALL_TMPETC/._rc.conf.net
+ sysrc -f $BSDINSTALL_TMPETC/._rc.conf.net ifconfig_${INTERFACE}_ipv6="inet6 accept_rtadv"
exit 0
else
break
@@ -108,13 +129,13 @@ END {
printf "\"Default Router\" %d 1 \"%s\" %d 16 50 50 0 ", n, dfr, n;
}'`
-exec 3>&1
+exec 5>&1
IF_CONFIG=$(echo ${ADDRS} | xargs -o bsddialog --backtitle "$OSNAME Installer" \
--title 'Network Configuration' \
--mixedform 'Static IPv6 Network Interface Configuration' 0 0 0 \
-2>&1 1>&3)
+2>&1 1>&5)
if [ $? -eq $BSDDIALOG_CANCEL ]; then exit 1; fi
-exec 3>&-
+exec 5>&-
echo ${IF_CONFIG} | tr ' ' '\n' | \
awk -v iface="${INTERFACE}" '
diff --git a/usr.sbin/bsdinstall/scripts/rootpass b/usr.sbin/bsdinstall/scripts/rootpass
index 308c60e47a4c..93523a9880d3 100755
--- a/usr.sbin/bsdinstall/scripts/rootpass
+++ b/usr.sbin/bsdinstall/scripts/rootpass
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
@@ -33,7 +32,13 @@ echo "$OSNAME Installer"
echo "========================"
echo
-echo "Please select a password for the system management account (root):"
-echo "Typed characters will not be visible."
+if [ -n "$ROOTPASS_ENC" ]; then
+ printf '%s\n' "$ROOTPASS_ENC" | pw -R $BSDINSTALL_CHROOT usermod root -H 0
+elif [ -n "$ROOTPASS_PLAIN" ]; then
+ printf '%s\n' "$ROOTPASS_PLAIN" | pw -R $BSDINSTALL_CHROOT usermod root -h 0
+else
+ echo "Please select a password for the system management account (root):"
+ echo "Typed characters will not be visible."
-chroot $BSDINSTALL_CHROOT passwd root 2>&1
+ chroot $BSDINSTALL_CHROOT passwd root 2>&1
+fi
diff --git a/usr.sbin/bsdinstall/scripts/script b/usr.sbin/bsdinstall/scripts/script
index 24469589d1a5..00ded5f8e24d 100755
--- a/usr.sbin/bsdinstall/scripts/script
+++ b/usr.sbin/bsdinstall/scripts/script
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -89,10 +88,15 @@ shift
f_dprintf "Began Installation at %s" "$( date )"
rm -rf $BSDINSTALL_TMPETC
mkdir $BSDINSTALL_TMPETC
+rm -f $TMPDIR/bsdinstall-installscript-setup
-split -a 2 -p '^#!.*' "$SCRIPT" $TMPDIR/bsdinstall-installscript-
+# split script into preamble and setup script at first shebang
+awk 'BEGIN {pathb=ARGV[2]; ARGV[2]=""} /^#!/{b=1} {
+ if (b) print >pathb; else print}' \
+ "$SCRIPT" $TMPDIR/bsdinstall-installscript-setup \
+ >$TMPDIR/bsdinstall-installscript-preamble
-. $TMPDIR/bsdinstall-installscript-aa
+. $TMPDIR/bsdinstall-installscript-preamble
: ${DISTRIBUTIONS="kernel.txz base.txz"}; export DISTRIBUTIONS
export BSDINSTALL_DISTDIR
@@ -115,13 +119,12 @@ fi
bsdinstall mount
# Fetch missing distribution files, if any
-(
- exec 3>&1
- export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&3)
- FETCH_RESULT=$?
- exec 3>&-
- return $FETCH_RESULT
-) || error "Could not fetch remote distributions"
+exec 5>&1
+export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&5)
+FETCH_RESULT=$?
+exec 5>&-
+
+[ $FETCH_RESULT -ne 0 ] && error "Could not fetch remote distributions"
# Unpack distributions
bsdinstall checksum
@@ -160,8 +163,9 @@ if [ ! -f $BSDINSTALL_CHROOT/etc/resolv.conf -a -f /etc/resolv.conf ]; then
fi
# Run post-install script
-if [ -f $TMPDIR/bsdinstall-installscript-ab ]; then
- cp $TMPDIR/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript
+if [ -f $TMPDIR/bsdinstall-installscript-setup ]; then
+ cp $TMPDIR/bsdinstall-installscript-setup \
+ $BSDINSTALL_CHROOT/tmp/installscript
chmod a+x $BSDINSTALL_CHROOT/tmp/installscript
chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1
rm $BSDINSTALL_CHROOT/tmp/installscript
diff --git a/usr.sbin/bsdinstall/scripts/services b/usr.sbin/bsdinstall/scripts/services
index f18f65b2afb0..93282effbb3f 100755
--- a/usr.sbin/bsdinstall/scripts/services
+++ b/usr.sbin/bsdinstall/scripts/services
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
@@ -32,8 +31,8 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
: ${BSDDIALOG_OK=0}
if [ -f $BSDINSTALL_TMPETC/rc.conf.services ]; then
- eval $( sed -e s/YES/on/i -e s/NO/off/i \
- $BSDINSTALL_TMPETC/rc.conf.services )
+ eval "$( sed -E -e 's/\<(YES|AUTO)\>/on/i' -e 's/\<NO\>/off/i' \
+ $BSDINSTALL_TMPETC/rc.conf.services )"
else
# Default service states. Everything is off if not enabled.
sshd_enable="on"
@@ -41,23 +40,24 @@ fi
echo -n > $BSDINSTALL_TMPETC/rc.conf.services
-exec 3>&1
+exec 5>&1
DAEMONS=$( bsddialog --backtitle "$OSNAME Installer" \
--title "System Configuration" --no-cancel --separate-output \
--checklist "Choose the services you would like to be started at boot:" \
0 0 0 \
- local_unbound "Local caching validating resolver" ${local_unbound:-off} \
+ local_unbound "Local caching validating resolver" \
+ ${local_unbound_enable:-off} \
sshd "Secure shell daemon" ${sshd_enable:-off} \
moused "PS/2 mouse pointer on console" ${moused_enable:-off} \
- ntpdate "Synchronize system and network time at bootime" \
- ${ntpdate_enable:-off} \
ntpd "Synchronize system and network time" ${ntpd_enable:-off} \
+ ntpd_sync_on_start "Sync time on ntpd startup, even if offset is high" \
+ ${ntpd_sync_on_start:-off} \
powerd "Adjust CPU frequency dynamically if supported" \
${powerd_enable:-off} \
dumpdev "Enable kernel crash dumps to /var/crash" ${dumpdev:-on} \
-2>&1 1>&3 )
+2>&1 1>&5 )
retval=$?
-exec 3>&-
+exec 5>&-
if [ $retval -ne $BSDDIALOG_OK ]; then
exit 1
@@ -68,7 +68,12 @@ havemouse=
for daemon in $DAEMONS; do
[ "$daemon" = "dumpdev" ] && havedump=1 continue
[ "$daemon" = "moused" ] && havemouse=1
- echo ${daemon}_enable=\"YES\" >> $BSDINSTALL_TMPETC/rc.conf.services
+ if [ "$daemon" = "ntpd_sync_on_start" ]; then
+ rcvar=${daemon}
+ else
+ rcvar=${daemon}_enable
+ fi
+ echo ${rcvar}=\"YES\" >> $BSDINSTALL_TMPETC/rc.conf.services
done
if [ ! "$havemouse" ]; then
diff --git a/usr.sbin/bsdinstall/scripts/time b/usr.sbin/bsdinstall/scripts/time
index 5715ab2d9d4e..fe82ce274729 100755
--- a/usr.sbin/bsdinstall/scripts/time
+++ b/usr.sbin/bsdinstall/scripts/time
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
@@ -38,19 +37,19 @@ TZ="${BSDINSTALL_CHROOT}/etc/localtime"
export TZ
# Set date
-exec 3>&1
+exec 5>&1
DATE=$(bsddialog --backtitle "$OSNAME Installer" \
--title 'Time & Date' \
--ok-label 'Set Date' \
--cancel-label 'Skip' \
--default-no \
--date-format '%Y%m%d%H%M.%S' \
- --datebox '' 0 40 \
-2>&1 1>&3) && date $DATE
-exec 3>&-
+ --calendar '' 0 40 \
+2>&1 1>&5) && date $DATE
+exec 5>&-
# Set time
-exec 3>&1
+exec 5>&1
TIME=$(bsddialog --backtitle "$OSNAME Installer" \
--title 'Time & Date' \
--ok-label 'Set Time' \
@@ -58,8 +57,8 @@ TIME=$(bsddialog --backtitle "$OSNAME Installer" \
--default-no \
--time-format '%H%M.%S' \
--timebox '' 0 40 \
-2>&1 1>&3) && date $TIME
-exec 3>&-
+2>&1 1>&5) && date $TIME
+exec 5>&-
# Switch back
if [ -n "$saved_TZ" ]; then
diff --git a/usr.sbin/bsdinstall/scripts/umount b/usr.sbin/bsdinstall/scripts/umount
index 3c33eff7e105..345cd1938b0d 100755
--- a/usr.sbin/bsdinstall/scripts/umount
+++ b/usr.sbin/bsdinstall/scripts/umount
@@ -24,7 +24,13 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
+
+# If we mounted the DVD packages, unmount them
+if [ -d $BSDINSTALL_CHROOT/dist/packages ]; then
+ umount $BSDINSTALL_CHROOT/dist/packages
+ rmdir $BSDINSTALL_CHROOT/dist/packages
+ rmdir $BSDINSTALL_CHROOT/dist
+fi
TMP_FSTAB=${TMPDIR:-"/tmp"}/bsdinstall-tmp-fstab
diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig
index eea31ad093bb..338e4f0a4109 100755
--- a/usr.sbin/bsdinstall/scripts/wlanconfig
+++ b/usr.sbin/bsdinstall/scripts/wlanconfig
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot
index a98cf4a33f28..1d38db2d0f15 100755
--- a/usr.sbin/bsdinstall/scripts/zfsboot
+++ b/usr.sbin/bsdinstall/scripts/zfsboot
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
@@ -72,7 +71,7 @@ f_include $BSDCFG_SHARE/variable.subr
#
# Should we use sysctl(8) vfs.zfs.min_auto_ashift=12 to force 4K sectors?
#
-: ${ZFSBOOT_FORCE_4K_SECTORS:=1}
+: ${ZFSBOOT_FORCE_4K_SECTORS=1}
#
# Should we use geli(8) to encrypt the drives?
@@ -150,15 +149,15 @@ f_isset ZFSBOOT_DATASETS || ZFSBOOT_DATASETS="
/$ZFSBOOT_BEROOT_NAME mountpoint=none
/$ZFSBOOT_BEROOT_NAME/$ZFSBOOT_BOOTFS_NAME mountpoint=/
+ # Home directories separated so they are common to all BEs
+ /home mountpoint=/home
+
# Compress /tmp, allow exec but not setuid
/tmp mountpoint=/tmp,exec=on,setuid=off
# Don't mount /usr so that 'base' files go to the BEROOT
/usr mountpoint=/usr,canmount=off
- # Home directories separated so they are common to all BEs
- /usr/home # NB: /home is a symlink to /usr/home
-
# Ports tree
/usr/ports setuid=off
@@ -318,7 +317,7 @@ msg_swap_mirror="Mirror Swap?"
msg_swap_mirror_help="Mirror swap partitions for redundancy, breaks crash dumps"
msg_swap_size="Swap Size"
msg_swap_size_help="Customize how much swap space is allocated to each selected disk"
-msg_swap_toosmall="The selected swap size (%s) is to small. Please enter a value greater than 100MB or enter 0 for no swap"
+msg_swap_toosmall="The selected swap size (%s) is too small. Please enter a value greater than 100MB or enter 0 for no swap"
msg_these_disks_are_too_small="These disks are smaller than the amount of requested\nswap (%s) and/or geli(8) (%s) partitions, which would\ntake 100%% or more of each of the following selected disks:\n\n %s\n\nRecommend changing partition size(s) and/or selecting a\ndifferent set of disks."
msg_unable_to_get_disk_capacity="Unable to get disk capacity of \`%s'"
msg_unsupported_partition_scheme="%s is an unsupported partition scheme"
@@ -397,7 +396,7 @@ dialog_menu_main()
--default-item \"\$defaultitem\" \
--menu \"\$prompt\" \
$height $width $rows \
- $menu_list \
+ ${USE_DIALOG:+--} $menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
@@ -659,7 +658,7 @@ dialog_menu_layout()
while :; do
# Loop over list of available disks, resetting state
for disk in $disks; do
- f_isset _${disk}_status && _${disk}_status=
+ f_isset _${disk}_status && setvar _${disk}_status
done
# Loop over list of selected disks and create temporary
@@ -669,7 +668,7 @@ dialog_menu_layout()
$disk $DEVICE_TYPE_DISK disk
f_isset _${disk}_status ||
local _${disk}_status
- _${disk}_status=on
+ setvar _${disk}_status on
done
# Create the checklist menu of discovered disk devices
@@ -1473,9 +1472,18 @@ zfs_create_boot()
# Set canmount=noauto so that the default Boot Environment (BE) does
# not get mounted if a different BE is selected from the beastie menu
#
- f_dprintf "$funcname: Set canmount=noauto for the root of the pool..."
- f_eval_catch $funcname zfs "$ZFS_SET" "canmount=noauto" \
- "$zroot_name/$ZFSBOOT_BEROOT_NAME/$ZFSBOOT_BOOTFS_NAME"
+ f_dprintf "$funcname: Set canmount=noauto for any datasets under the BE..."
+ echo "$ZFSBOOT_DATASETS" | while read dataset options; do
+ # Skip blank lines and comments
+ case "$dataset" in "#"*|"") continue; esac
+ options="${options%%#*}"
+ #
+ case "$dataset" in "/$ZFSBOOT_BEROOT_NAME/$ZFSBOOT_BOOTFS_NAME"*)
+ f_eval_catch $funcname zfs "$ZFS_SET" "canmount=noauto" \
+ "$zroot_name$dataset" || return $FAILURE ;;
+ *) continue ;;
+ esac
+ done
# Last, but not least... required lines for rc.conf(5)/loader.conf(5)
# NOTE: We later concatenate these into their destination
diff --git a/usr.sbin/bsdinstall/startbsdinstall b/usr.sbin/bsdinstall/startbsdinstall
new file mode 100644
index 000000000000..ab78c2941256
--- /dev/null
+++ b/usr.sbin/bsdinstall/startbsdinstall
@@ -0,0 +1,114 @@
+#!/bin/sh
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+
+: ${BSDDIALOG_OK=0}
+: ${BSDDIALOG_CANCEL=1}
+: ${BSDDIALOG_HELP=2}
+: ${BSDDIALOG_EXTRA=3}
+: ${BSDDIALOG_ESC=5}
+: ${BSDDIALOG_ERROR=255}
+
+kbdcontrol -d >/dev/null 2>&1
+if [ $? -eq 0 ]; then
+ # Syscons: use xterm, start interesting things on other VTYs
+ TERM=xterm
+
+ # Don't send ESC on function-key 62/63 (left/right command key)
+ kbdcontrol -f 62 '' > /dev/null 2>&1
+ kbdcontrol -f 63 '' > /dev/null 2>&1
+
+ if [ -z "$EXTERNAL_VTY_STARTED" ]; then
+ # Init will clean these processes up if/when the system
+ # goes multiuser
+ touch /tmp/bsdinstall_log
+ tail -f /tmp/bsdinstall_log > /dev/ttyv2 &
+ /usr/libexec/getty autologin ttyv3 &
+ EXTERNAL_VTY_STARTED=1
+ fi
+else
+ # Serial or other console
+ echo
+ echo "Welcome to ${OSNAME}!"
+ echo
+ echo "Please choose the appropriate terminal type for your system."
+ echo "Common console types are:"
+ echo " ansi Standard ANSI terminal"
+ echo " vt100 VT100 or compatible terminal"
+ echo " xterm xterm terminal emulator (or compatible)"
+ echo
+ echo -n "Console type [vt100]: "
+ read TERM
+ TERM=${TERM:-vt100}
+fi
+export TERM
+
+# Query terminal size; useful for serial lines.
+resizewin -z
+
+if [ -f /etc/installerconfig ]; then
+ if [ "$1" != "primary" ]; then
+ bsddialog --backtitle "${OSNAME} Installer" --title "Installing" --msgbox "${OSNAME} is being installed from a script; please use the primary console." 0 0
+ . "$0"
+ elif bsdinstall script /etc/installerconfig; then
+ bsddialog --backtitle "${OSNAME} Installer" --title "Complete" --no-cancel --ok-label "Reboot" --pause "Installation of ${OSNAME} complete! Rebooting in 10 seconds" 10 30 10
+ reboot
+ else
+ bsddialog --backtitle "${OSNAME} Installer" --title "Error" --textbox /tmp/bsdinstall_log 0 0
+ fi
+ exit
+fi
+
+bsddialog --backtitle "${OSNAME} Installer" --title "Welcome" --extra-button --extra-label "Shell" --ok-label "Install" --cancel-label "Live System" --yesno "Welcome to ${OSNAME}! Would you like to begin an installation or use the live system?" 0 0
+
+case $? in
+$BSDDIALOG_OK) # Install
+ # If not netbooting, have the installer configure the network
+ dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
+ if [ ${dlv:=0} -eq 0 -a ! -f /etc/diskless ]; then
+ BSDINSTALL_CONFIGCURRENT=yes; export BSDINSTALL_CONFIGCURRENT
+ fi
+
+ trap true SIGINT # Ignore cntrl-C here
+ bsdinstall
+ if [ $? -eq 0 ]; then
+ bsddialog --backtitle "${OSNAME} Installer" --title "Complete" --ok-label "Reboot" --extra-button --extra-label "Shutdown" --cancel-label "Live System" --yesno "Installation of ${OSNAME} complete! Would you like to reboot into the installed system now?" 0 0
+
+ case $? in
+ $BSDDIALOG_OK) # Reboot
+ reboot
+ ;;
+ $BSDDIALOG_EXTRA) # Shutdown
+ shutdown -p now
+ # shutdown(8) daemonizes, with the actual signal to
+ # init(8) happening in the child, but if we exit the
+ # script then runconsoles will clean up its children
+ # thinking we're trying to go multiuser (and if the
+ # user has disabled multiple console support we'll
+ # still start trying to go multi-user, which gives
+ # confusing output on the console if the daemon is slow
+ # to run). Thus we spin while the daemon runs.
+ while true; do
+ sleep 1
+ done
+ ;;
+ $BSDDIALOG_CANCEL) # Live System
+ exit 0
+ ;;
+ esac
+ else
+ . "$0"
+ fi
+ ;;
+$BSDDIALOG_CANCEL) # Live System
+ exit 0
+ ;;
+$BSDDIALOG_EXTRA) # Shell
+ clear
+ echo "When finished, type 'exit' to return to the installer."
+ /bin/sh
+ . "$0"
+ ;;
+esac
+
diff --git a/usr.sbin/bsnmpd/Makefile b/usr.sbin/bsnmpd/Makefile
index 632753ddc9ea..0ce03a3a4dc4 100644
--- a/usr.sbin/bsnmpd/Makefile
+++ b/usr.sbin/bsnmpd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= gensnmptree \
bsnmpd \
diff --git a/usr.sbin/bsnmpd/Makefile.inc b/usr.sbin/bsnmpd/Makefile.inc
index 3718a5aaf44d..62cabd439578 100644
--- a/usr.sbin/bsnmpd/Makefile.inc
+++ b/usr.sbin/bsnmpd/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= bsnmp
.include "../Makefile.inc"
diff --git a/usr.sbin/bsnmpd/bsnmpd/Makefile b/usr.sbin/bsnmpd/bsnmpd/Makefile
index 05d617279ff0..245ffc51002f 100644
--- a/usr.sbin/bsnmpd/bsnmpd/Makefile
+++ b/usr.sbin/bsnmpd/bsnmpd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Author: Harti Brandt <harti@freebsd.org>
diff --git a/usr.sbin/bsnmpd/bsnmpd/Makefile.depend b/usr.sbin/bsnmpd/bsnmpd/Makefile.depend
index 382b25c6a944..a80635645285 100644
--- a/usr.sbin/bsnmpd/bsnmpd/Makefile.depend
+++ b/usr.sbin/bsnmpd/bsnmpd/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
@@ -10,8 +9,6 @@ DIRDEPS = \
lib/libbsnmp/libbsnmp \
lib/libc \
lib/libcompiler_rt \
- lib/libthr \
- secure/lib/libcrypto \
usr.sbin/bsnmpd/gensnmptree.host \
diff --git a/usr.sbin/bsnmpd/bsnmpd/Makefile.depend.options b/usr.sbin/bsnmpd/bsnmpd/Makefile.depend.options
index a62a5692d70a..fbc21670804e 100644
--- a/usr.sbin/bsnmpd/bsnmpd/Makefile.depend.options
+++ b/usr.sbin/bsnmpd/bsnmpd/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= TCP_WRAPPERS
diff --git a/usr.sbin/bsnmpd/bsnmpd/snmpd.config b/usr.sbin/bsnmpd/bsnmpd/snmpd.config
index c1a8fa9fe55a..ace83e9c4e2e 100644
--- a/usr.sbin/bsnmpd/bsnmpd/snmpd.config
+++ b/usr.sbin/bsnmpd/bsnmpd/snmpd.config
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Example configuration file for bsnmpd(1).
#
diff --git a/usr.sbin/bsnmpd/gensnmptree/Makefile b/usr.sbin/bsnmpd/gensnmptree/Makefile
index 52b77f60f2a6..ea58c108edfb 100644
--- a/usr.sbin/bsnmpd/gensnmptree/Makefile
+++ b/usr.sbin/bsnmpd/gensnmptree/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Author: Harti Brandt <harti@freebsd.org>
diff --git a/usr.sbin/bsnmpd/gensnmptree/Makefile.depend b/usr.sbin/bsnmpd/gensnmptree/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/bsnmpd/gensnmptree/Makefile.depend
+++ b/usr.sbin/bsnmpd/gensnmptree/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/bsnmpd/modules/Makefile b/usr.sbin/bsnmpd/modules/Makefile
index 6640bb62d112..ac1d4ecc647b 100644
--- a/usr.sbin/bsnmpd/modules/Makefile
+++ b/usr.sbin/bsnmpd/modules/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/bsnmpd/modules/Makefile.depend b/usr.sbin/bsnmpd/modules/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/bsnmpd/modules/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsnmpd/modules/Makefile.inc b/usr.sbin/bsnmpd/modules/Makefile.inc
index bf633958e82b..abdd059b3683 100644
--- a/usr.sbin/bsnmpd/modules/Makefile.inc
+++ b/usr.sbin/bsnmpd/modules/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
SHLIB_MAJOR= 6
PACKAGE= bsnmp
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt
index bde89b6ee73b..77de04446a54 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/BEGEMOT-BRIDGE-MIB.txt
@@ -23,8 +23,6 @@
-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-- SUCH DAMAGE.
--
--- $FreeBSD$
---
BEGEMOT-BRIDGE-MIB DEFINITIONS ::= BEGIN
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/BRIDGE-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_bridge/BRIDGE-MIB.txt
index 9f87b6557c0a..345117db2e39 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/BRIDGE-MIB.txt
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/BRIDGE-MIB.txt
@@ -13,8 +13,6 @@
-- INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
-- WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
--
--- $FreeBSD$
---
BRIDGE-MIB DEFINITIONS ::= BEGIN
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile b/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile
index d072c933074f..1b40edb1d8ce 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
MOD= bridge
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend
index 290addd65b07..39bad4aa8eb1 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/RSTP-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_bridge/RSTP-MIB.txt
index ea6648e031b2..b0a44858ff32 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/RSTP-MIB.txt
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/RSTP-MIB.txt
@@ -13,8 +13,6 @@
-- INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
-- WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
--
--- $FreeBSD$
---
RSTP-MIB DEFINITIONS ::= BEGIN
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c
index ae106015b562..47475b693685 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_addrs.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Shteryana Shopova <syrinx@FreeBSD.org>
* All rights reserved.
@@ -27,8 +27,6 @@
*
* Bridge MIB implementation for SNMPd.
* Bridge addresses.
- *
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c
index a9986874b308..f7680f5a368a 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Shteryana Shopova <syrinx@FreeBSD.org>
* All rights reserved.
@@ -27,8 +27,6 @@
*
* Bridge MIB implementation for SNMPd.
* Bridge interface objects.
- *
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_pf.c b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_pf.c
index 650b16ff7714..bd3dc86343ce 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_pf.c
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_pf.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Shteryana Shopova <syrinx@FreeBSD.org>
* All rights reserved.
@@ -27,8 +27,6 @@
*
* Bridge MIB implementation for SNMPd.
* Bridge pfil controls.
- *
- * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c
index 1e87406a9a27..11d9a12e281e 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Shteryana Shopova <syrinx@FreeBSD.org>
* All rights reserved.
@@ -27,8 +27,6 @@
*
* Bridge MIB implementation for SNMPd.
* Bridge ports.
- *
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_snmp.c b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_snmp.c
index 65f7b8e85cc8..4f50953f0f6d 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_snmp.c
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_snmp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Shteryana Shopova <syrinx@FreeBSD.org>
* All rights reserved.
@@ -26,8 +26,6 @@
* SUCH DAMAGE.
*
* Bridge MIB implementation for SNMPd.
- *
- * $FreeBSD$
*/
#include <sys/param.h>
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_snmp.h b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_snmp.h
index 0f5dd34f51e5..1f00216dd16a 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_snmp.h
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_snmp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Shteryana Shopova <syrinx@FreeBSD.org>
* All rights reserved.
@@ -26,8 +26,6 @@
* SUCH DAMAGE.
*
* Bridge MIB implementation for SNMPd.
- *
- * $FreeBSD$
*/
#ifndef SNMP_BRIDGE_H
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c
index f30cb71816bf..8b833204afe8 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_sys.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Shteryana Shopova <syrinx@FreeBSD.org>
* All rights reserved.
@@ -27,8 +27,6 @@
*
* Bridge MIB implementation for SNMPd.
* Bridge OS specific ioctls.
- *
- * $FreeBSD$
*/
#include <sys/ioctl.h>
@@ -312,7 +310,7 @@ bridge_set_priority(struct bridge_if *bif, int32_t priority)
* 1/256 seconds, the following algorithm should be used:
* b = floor( (n * 256) / 100)
* The conversion to 1/256 of a second happens in the kernel -
- * just make sure we correctly convert the seconds to Timout
+ * just make sure we correctly convert the seconds to Timeout
* and vice versa.
*/
static uint32_t
@@ -1223,7 +1221,7 @@ bridge_getinfo_bif_ports(struct bridge_if *bif)
int
bridge_update_memif(struct bridge_if *bif)
{
- int added, updated;
+ int updated;
uint32_t i;
int32_t buf_len;
struct ifbreq *b_req_buf, *b_req;
@@ -1234,7 +1232,7 @@ bridge_update_memif(struct bridge_if *bif)
if ((buf_len = bridge_port_get_iflist(bif, &b_req_buf)) < 0)
return (-1);
- added = updated = 0;
+ updated = 0;
#define BP_FOUND 0x01
for (i = 0; i < buf_len / sizeof(struct ifbreq); i++) {
@@ -1249,7 +1247,6 @@ bridge_update_memif(struct bridge_if *bif)
if ((bp = bridge_port_find(m_if->index, bif)) == NULL &&
(bp = bridge_new_port(m_if, bif)) != NULL) {
bp->status = RowStatus_active;
- added++;
}
if (bp != NULL) {
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_tree.def b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_tree.def
index 2e88e5ed54fb..70abb4ef9b26 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_tree.def
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_tree.def
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
#include "tc.def"
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/snmp_bridge.3 b/usr.sbin/bsnmpd/modules/snmp_bridge/snmp_bridge.3
index 4f3c5e7e46fb..11708fba8efd 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/snmp_bridge.3
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/snmp_bridge.3
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd August 6, 2007
.Dt SNMP_BRIDGE 3
.Os
diff --git a/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
index 0f330c171aaf..44ada542a69d 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
+++ b/usr.sbin/bsnmpd/modules/snmp_hast/BEGEMOT-HAST-MIB.txt
@@ -23,8 +23,6 @@
-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-- SUCH DAMAGE.
--
--- $FreeBSD$
---
BEGEMOT-HAST-MIB DEFINITIONS ::= BEGIN
diff --git a/usr.sbin/bsnmpd/modules/snmp_hast/Makefile b/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
index 72213704e935..9fabe06d3f45 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/bsnmpd/modules/snmp_hast/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_hast/Makefile.depend
index 3202aed9b615..20d81f6f7b50 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hast/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_hast/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -11,6 +9,8 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libutil \
+ usr.bin/yacc.host \
+ usr.sbin/bsnmpd/gensnmptree.host \
usr.sbin/bsnmpd/modules \
diff --git a/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c b/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
index 402a87852348..4332f02156c1 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hast/hast_snmp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Mikolaj Golub <trociny@FreeBSD.org>
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/queue.h>
diff --git a/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def b/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def
index 980de92ff8b0..38da27db97c9 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def
+++ b/usr.sbin/bsnmpd/modules/snmp_hast/hast_tree.def
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
(1 internet
diff --git a/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3 b/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3
index 44a1590562b3..81d51c022edb 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3
+++ b/usr.sbin/bsnmpd/modules/snmp_hast/snmp_hast.3
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 31, 2014
.Dt SNMP_HAST 3
.Os
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/BEGEMOT-HOSTRES-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_hostres/BEGEMOT-HOSTRES-MIB.txt
index 3c15e090e1fd..f05ae47f081d 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/BEGEMOT-HOSTRES-MIB.txt
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/BEGEMOT-HOSTRES-MIB.txt
@@ -26,8 +26,6 @@
-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-- SUCH DAMAGE.
--
--- $FreeBSD$
---
-- Additional stuff for the HOST-RESOURCES MIB.
--
BEGEMOT-HOSTRES-MIB DEFINITIONS ::= BEGIN
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile b/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile
index 7166a4e41eb4..85c94e18a6d9 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
LPRSRC= ${SRCTOP}/usr.sbin/lpr/common_source
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend
index 2d5480637707..86aacabb1b20 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
@@ -14,6 +12,7 @@ DIRDEPS = \
lib/libkvm \
lib/libmemstat \
lib/msun \
+ usr.sbin/bsnmpd/gensnmptree.host \
usr.sbin/bsnmpd/modules \
usr.sbin/bsnmpd/modules/snmp_mibII \
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_begemot.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_begemot.c
index f1cc5e3e33d6..1f407e8b6ec7 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_begemot.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_begemot.c
@@ -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 <stdlib.h>
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c
index 70d2cf6998ee..b769b17484a4 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c
@@ -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$
*/
/*
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c
index 567535092846..5a07d94d8a51 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c
@@ -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$
*/
/*
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c
index b88541f3a440..bdc20d19a372 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c
@@ -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$
*/
/*
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_network_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_network_tbl.c
index 4329a1cc3920..932ab4211f74 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_network_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_network_tbl.c
@@ -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$
*/
/*
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c
index 63289f3a146c..a3395227870c 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c
@@ -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$
*/
/*
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_printer_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_printer_tbl.c
index 33a54b58fb1f..00444362e9fb 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_printer_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_printer_tbl.c
@@ -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$
*/
/*
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_processor_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_processor_tbl.c
index e75b55ea9045..77e617b65219 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_processor_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_processor_tbl.c
@@ -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$
*/
/*
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
index 872b8a5da329..156222b1eca0 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
@@ -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$
*/
/*
@@ -248,7 +246,7 @@ OS_getSystemMaxProcesses(uint32_t *mproc)
}
/*
- * Get the physical memeory size in Kbytes.
+ * Get the physical memory size in Kbytes.
* Returns SNMP error code.
*/
static int
@@ -342,7 +340,7 @@ OS_setSystemDate(const struct timeval *timeval_to_set)
}
/*
- * prototype of this function was genrated by gensnmptree tool in header file
+ * prototype of this function was generated by gensnmptree tool in header file
* hostres_tree.h
* Returns SNMP_ERR_NOERROR on success
*/
@@ -437,7 +435,7 @@ op_hrSystem(struct snmp_context *ctx, struct snmp_value *value,
}
/*
- * prototype of this function was genrated by gensnmptree tool
+ * prototype of this function was generated by gensnmptree tool
* in the header file hostres_tree.h
* Returns SNMP_ERR_NOERROR on success
*/
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c
index 662aa6e44611..45b240394ac3 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c
@@ -38,8 +38,6 @@
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
- *
- * $FreeBSD$
*/
/*
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h
index 5c11573df198..4ea6db1403ab 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h
@@ -27,8 +27,6 @@
* SUCH DAMAGE.
*
* Host Resources MIB for SNMPd.
- *
- * $FreeBSD$
*/
#ifndef HOSTRES_SNMP_H_1132245017
@@ -127,7 +125,7 @@ struct device_entry {
uint32_t errors;
#define HR_DEVICE_FOUND 0x001
- /* not dectected by libdevice, so don't try to refresh it*/
+ /* not detected by libdevice, so don't try to refresh it*/
#define HR_DEVICE_IMMUTABLE 0x002
/* next 3 are not from the SNMP mib table, only to be used internally */
@@ -210,7 +208,7 @@ const struct asn_oid *fs_get_type(const struct statfs *);
* refreshing hrFSTable by refreshing hrStorageTable.
* When one entry "of type" fs from hrStorageTable is refreshed
* then the corresponding entry from hrFSTable is refreshed
- * FS_tbl_pre_refresh_v() is called before refeshing fs part of hrStorageTable
+ * FS_tbl_pre_refresh_v() is called before refreshing fs part of hrStorageTable
*/
void fs_tbl_pre_refresh(void);
void fs_tbl_process_statfs_entry(const struct statfs *, int32_t);
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c
index f7b6537c289d..647ecd002e96 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c
@@ -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$
*/
/*
@@ -56,7 +54,7 @@
#include "hostres_oid.h"
#include "hostres_tree.h"
-/* maximum length for descritpion string according to MIB */
+/* maximum length for description string according to MIB */
#define SE_DESC_MLEN (255 + 1)
/*
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swinstalled_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swinstalled_tbl.c
index c7eecc5c1c4a..8b7e4608d673 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swinstalled_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swinstalled_tbl.c
@@ -26,8 +26,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
* Host Resources MIB implementation for SNMPd: instrumentation for
* hrSWInstalledTable
*/
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c
index f1a2f09e440f..0f69703dfcdc 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c
@@ -26,8 +26,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
* Host Resources MIB for SNMPd. Implementation for hrSWRunTable
*/
@@ -479,7 +477,7 @@ invalidate_swrun_entry(struct swrun_entry *entry, int commit)
if (entry->index >= NO_PID + 1) {
/* this is a kernel item */
- HRDBG("atempt to unload KLD %d",
+ HRDBG("attempt to unload KLD %d",
entry->index - NO_PID - 1);
if (entry->index == SWOSIndex) {
@@ -548,7 +546,7 @@ invalidate_swrun_entry(struct swrun_entry *entry, int commit)
}
/**
- * Popuplate the hrSWRunTable.
+ * Populate the hrSWRunTable.
*/
void
init_swrun_tbl(void)
@@ -575,7 +573,7 @@ fini_swrun_tbl(void)
/*
* This is the implementation for a generated (by a SNMP tool)
* function prototype, see hostres_tree.h
- * It hanldes the SNMP operations for hrSWRunTable
+ * It handles the SNMP operations for hrSWRunTable
*/
int
op_hrSWRunTable(struct snmp_context *ctx __unused, struct snmp_value *value,
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_tree.def b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_tree.def
index 83c187b48499..844c0a8d69e9 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_tree.def
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_tree.def
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# This is the .def file for both HOST-RESOURCES-MIB and HOST-RESOURCES-TYPES
#
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/snmp_hostres.3 b/usr.sbin/bsnmpd/modules/snmp_hostres/snmp_hostres.3
index cebb06b29d65..01d7a600acd5 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/snmp_hostres.3
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/snmp_hostres.3
@@ -26,8 +26,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 3, 2006
.Dt SNMP_HOSTRES 3
.Os
diff --git a/usr.sbin/bsnmpd/modules/snmp_lm75/BEGEMOT-LM75-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_lm75/BEGEMOT-LM75-MIB.txt
index f8f52a639be0..7966f6535f15 100644
--- a/usr.sbin/bsnmpd/modules/snmp_lm75/BEGEMOT-LM75-MIB.txt
+++ b/usr.sbin/bsnmpd/modules/snmp_lm75/BEGEMOT-LM75-MIB.txt
@@ -23,8 +23,6 @@
-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-- SUCH DAMAGE.
--
--- $FreeBSD$
---
BEGEMOT-LM75-MIB DEFINITIONS ::= BEGIN
@@ -37,7 +35,7 @@ IMPORTS
begemot
FROM BEGEMOT-MIB;
-begemotLoos MODULE-IDENTITY
+begemotLm75 MODULE-IDENTITY
LAST-UPDATED "201402240000Z"
ORGANIZATION "FreeBSD"
CONTACT-INFO
@@ -61,7 +59,7 @@ begemotLm75Objects OBJECT IDENTIFIER ::= { begemotLm75 1 }
-- Configuration parameters
-- ---------------------------------------------------------- --
-lm75Sensor OBJECT IDENTIFIER ::= { begemotlm75Objects 1 }
+lm75Sensor OBJECT IDENTIFIER ::= { begemotLm75Objects 1 }
lm75Sensors OBJECT-TYPE
SYNTAX Integer32
@@ -69,7 +67,7 @@ lm75Sensors OBJECT-TYPE
STATUS current
DESCRIPTION
"Number of LM75 sensors in the system."
- ::= { lm75Sensors 1 }
+ ::= { lm75Sensor 1 }
-- ---------------------------------------------------------- --
-- TempSensor Table
@@ -82,7 +80,7 @@ lm75SensorTable OBJECT-TYPE
"A table containing information about all temperature sensors."
::= { begemotLm75Objects 2 }
-loosTempSensorEntry OBJECT-TYPE
+lm75SensorEntry OBJECT-TYPE
SYNTAX Lm75SensorEntry
MAX-ACCESS not-accessible
STATUS current
diff --git a/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile b/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile
index f9ee77d37883..d6eb9caab74f 100644
--- a/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <bsd.own.mk>
diff --git a/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile.depend
index b9ab90d16f85..655c0287dd8a 100644
--- a/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile.depend
@@ -1,14 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libbsnmp/libbsnmp \
lib/libc \
lib/libcompiler_rt \
+ usr.sbin/bsnmpd/gensnmptree.host \
usr.sbin/bsnmpd/modules \
diff --git a/usr.sbin/bsnmpd/modules/snmp_lm75/lm75_tree.def b/usr.sbin/bsnmpd/modules/snmp_lm75/lm75_tree.def
index 3bfcd8d3bbcd..c3b1a4fc114a 100644
--- a/usr.sbin/bsnmpd/modules/snmp_lm75/lm75_tree.def
+++ b/usr.sbin/bsnmpd/modules/snmp_lm75/lm75_tree.def
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
(1 internet
diff --git a/usr.sbin/bsnmpd/modules/snmp_lm75/snmp_lm75.3 b/usr.sbin/bsnmpd/modules/snmp_lm75/snmp_lm75.3
index cd9d5796d4cb..53f19f0fe6d1 100644
--- a/usr.sbin/bsnmpd/modules/snmp_lm75/snmp_lm75.3
+++ b/usr.sbin/bsnmpd/modules/snmp_lm75/snmp_lm75.3
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 2, 2014
.Dt SNMP_LM75 3
.Os
diff --git a/usr.sbin/bsnmpd/modules/snmp_lm75/snmp_lm75.c b/usr.sbin/bsnmpd/modules/snmp_lm75/snmp_lm75.c
index a55050b851d3..0d0fdb1ce670 100644
--- a/usr.sbin/bsnmpd/modules/snmp_lm75/snmp_lm75.c
+++ b/usr.sbin/bsnmpd/modules/snmp_lm75/snmp_lm75.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/sysctl.h>
@@ -283,7 +280,7 @@ update_sensors(void)
free(oid);
return (0);
}
- /* Alocate and read the next mib. */
+ /* Allocate and read the next mib. */
next = (int *)malloc(nextlen);
if (next == NULL) {
syslog(LOG_ERR,
diff --git a/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile b/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile
index 22be4123110b..289226bfe1e9 100644
--- a/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Author: Harti Brandt <harti@freebsd.org>
diff --git a/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend
index b8b0801c6960..b2b57046f232 100644
--- a/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsnmpd/modules/snmp_netgraph/BEGEMOT-NETGRAPH.txt b/usr.sbin/bsnmpd/modules/snmp_netgraph/BEGEMOT-NETGRAPH.txt
index b4f0e2a3f993..572fe1820e0c 100644
--- a/usr.sbin/bsnmpd/modules/snmp_netgraph/BEGEMOT-NETGRAPH.txt
+++ b/usr.sbin/bsnmpd/modules/snmp_netgraph/BEGEMOT-NETGRAPH.txt
@@ -27,8 +27,6 @@
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
--- $FreeBSD$
---
-- Private MIB for netgraph part of Begemot SNMP daemon.
--
BEGEMOT-NETGRAPH-MIB DEFINITIONS ::= BEGIN
diff --git a/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile b/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile
index 85057c96eb0a..aa96d6adacc2 100644
--- a/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Author: Harti Brandt <harti@freebsd.org>
diff --git a/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend
index 10b5e77fe5f7..8b4b4703541d 100644
--- a/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsnmpd/modules/snmp_netgraph/netgraph_tree.def b/usr.sbin/bsnmpd/modules/snmp_netgraph/netgraph_tree.def
index eff59ff15c7c..8b1cebe20df0 100644
--- a/usr.sbin/bsnmpd/modules/snmp_netgraph/netgraph_tree.def
+++ b/usr.sbin/bsnmpd/modules/snmp_netgraph/netgraph_tree.def
@@ -27,7 +27,6 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
-# $FreeBSD$
#
# Definition of the tree implemented by snmp_netgraph.
#
diff --git a/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.3 b/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.3
index d40aef5e2425..c787a9e006a1 100644
--- a/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.3
+++ b/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.3
@@ -27,8 +27,6 @@
.\" 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 14, 2003
.Dt SNMP_NETGRAPH 3
.Os
diff --git a/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.c b/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.c
index 4b1da05ea122..3dc655ef6283 100644
--- a/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.c
+++ b/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.c
@@ -27,8 +27,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
- *
* Netgraph interface for SNMPd.
*/
#include <sys/types.h>
diff --git a/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.h b/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.h
index 21e553c30916..4add4b3a1e5a 100644
--- a/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.h
+++ b/usr.sbin/bsnmpd/modules/snmp_netgraph/snmp_netgraph.h
@@ -27,8 +27,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
- *
* Netgraph interface for SNMPd. Exported stuff.
*/
#ifndef SNMP_NETGRAPH_H_
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt
index d92b6ac7d0c6..13a4a646a669 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt
@@ -6,8 +6,6 @@
-- this stuff is worth it, you can buy me a beer in return. -Philip Paeps
-- ----------------------------------------------------------------------------
--
--- $FreeBSD$
---
BEGEMOT-PF-MIB DEFINITIONS ::= BEGIN
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/Makefile b/usr.sbin/bsnmpd/modules/snmp_pf/Makefile
index 3ab6e436aa75..4a726ff1cf44 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Author: Philip Paeps <philip@freebsd.org>
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend
index b9ab90d16f85..b175be6afebe 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend
@@ -1,14 +1,15 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libbsnmp/libbsnmp \
lib/libc \
lib/libcompiler_rt \
+ lib/libnv \
+ lib/libpfctl \
+ usr.sbin/bsnmpd/gensnmptree.host \
usr.sbin/bsnmpd/modules \
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
index 4ef35ac1eec2..bb064dd549d2 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Philip Paeps <philip@FreeBSD.org>
* 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$
*/
#define PFIOC_USE_LATEST
@@ -56,7 +54,7 @@ static int dev = -1;
static int started;
static uint64_t pf_tick;
-static struct pf_status pfs;
+static struct pfctl_status *pfs;
enum { IN, OUT };
enum { IPV4, IPV6 };
@@ -168,18 +166,18 @@ pf_status(struct snmp_context __unused *ctx, struct snmp_value *val,
switch (which) {
case LEAF_pfStatusRunning:
- val->v.uint32 = pfs.running;
+ val->v.uint32 = pfs->running;
break;
case LEAF_pfStatusRuntime:
- runtime = (pfs.since > 0) ?
- time(NULL) - pfs.since : 0;
+ runtime = (pfs->since > 0) ?
+ time(NULL) - pfs->since : 0;
val->v.uint32 = runtime * 100;
break;
case LEAF_pfStatusDebug:
- val->v.uint32 = pfs.debug;
+ val->v.uint32 = pfs->debug;
break;
case LEAF_pfStatusHostId:
- sprintf(str, "0x%08x", ntohl(pfs.hostid));
+ sprintf(str, "0x%08x", ntohl(pfs->hostid));
return (string_get(val, str, strlen(str)));
default:
@@ -207,22 +205,22 @@ pf_counter(struct snmp_context __unused *ctx, struct snmp_value *val,
switch (which) {
case LEAF_pfCounterMatch:
- val->v.counter64 = pfs.counters[PFRES_MATCH];
+ val->v.counter64 = pfctl_status_counter(pfs, PFRES_MATCH);
break;
case LEAF_pfCounterBadOffset:
- val->v.counter64 = pfs.counters[PFRES_BADOFF];
+ val->v.counter64 = pfctl_status_counter(pfs, PFRES_BADOFF);
break;
case LEAF_pfCounterFragment:
- val->v.counter64 = pfs.counters[PFRES_FRAG];
+ val->v.counter64 = pfctl_status_counter(pfs, PFRES_FRAG);
break;
case LEAF_pfCounterShort:
- val->v.counter64 = pfs.counters[PFRES_SHORT];
+ val->v.counter64 = pfctl_status_counter(pfs, PFRES_SHORT);
break;
case LEAF_pfCounterNormalize:
- val->v.counter64 = pfs.counters[PFRES_NORM];
+ val->v.counter64 = pfctl_status_counter(pfs, PFRES_NORM);
break;
case LEAF_pfCounterMemDrop:
- val->v.counter64 = pfs.counters[PFRES_MEMORY];
+ val->v.counter64 = pfctl_status_counter(pfs, PFRES_MEMORY);
break;
default:
@@ -250,19 +248,19 @@ pf_statetable(struct snmp_context __unused *ctx, struct snmp_value *val,
switch (which) {
case LEAF_pfStateTableCount:
- val->v.uint32 = pfs.states;
+ val->v.uint32 = pfs->states;
break;
case LEAF_pfStateTableSearches:
val->v.counter64 =
- pfs.fcounters[FCNT_STATE_SEARCH];
+ pfctl_status_fcounter(pfs, FCNT_STATE_SEARCH);
break;
case LEAF_pfStateTableInserts:
val->v.counter64 =
- pfs.fcounters[FCNT_STATE_INSERT];
+ pfctl_status_fcounter(pfs, FCNT_STATE_INSERT);
break;
case LEAF_pfStateTableRemovals:
val->v.counter64 =
- pfs.fcounters[FCNT_STATE_REMOVALS];
+ pfctl_status_fcounter(pfs, FCNT_STATE_REMOVALS);
break;
default:
@@ -290,19 +288,19 @@ pf_srcnodes(struct snmp_context __unused *ctx, struct snmp_value *val,
switch (which) {
case LEAF_pfSrcNodesCount:
- val->v.uint32 = pfs.src_nodes;
+ val->v.uint32 = pfs->src_nodes;
break;
case LEAF_pfSrcNodesSearches:
val->v.counter64 =
- pfs.scounters[SCNT_SRC_NODE_SEARCH];
+ pfctl_status_scounter(pfs, SCNT_SRC_NODE_SEARCH);
break;
case LEAF_pfSrcNodesInserts:
val->v.counter64 =
- pfs.scounters[SCNT_SRC_NODE_INSERT];
+ pfctl_status_scounter(pfs, SCNT_SRC_NODE_INSERT);
break;
case LEAF_pfSrcNodesRemovals:
val->v.counter64 =
- pfs.scounters[SCNT_SRC_NODE_REMOVALS];
+ pfctl_status_scounter(pfs, SCNT_SRC_NODE_REMOVALS);
break;
default:
@@ -463,51 +461,51 @@ pf_logif(struct snmp_context __unused *ctx, struct snmp_value *val,
switch (which) {
case LEAF_pfLogInterfaceName:
- strlcpy(str, pfs.ifname, sizeof str);
+ strlcpy(str, pfs->ifname, sizeof str);
return (string_get(val, str, strlen(str)));
case LEAF_pfLogInterfaceIp4BytesIn:
- val->v.counter64 = pfs.bcounters[IPV4][IN];
+ val->v.counter64 = pfs->bcounters[IPV4][IN];
break;
case LEAF_pfLogInterfaceIp4BytesOut:
- val->v.counter64 = pfs.bcounters[IPV4][OUT];
+ val->v.counter64 = pfs->bcounters[IPV4][OUT];
break;
case LEAF_pfLogInterfaceIp4PktsInPass:
val->v.counter64 =
- pfs.pcounters[IPV4][IN][PF_PASS];
+ pfs->pcounters[IPV4][IN][PF_PASS];
break;
case LEAF_pfLogInterfaceIp4PktsInDrop:
val->v.counter64 =
- pfs.pcounters[IPV4][IN][PF_DROP];
+ pfs->pcounters[IPV4][IN][PF_DROP];
break;
case LEAF_pfLogInterfaceIp4PktsOutPass:
val->v.counter64 =
- pfs.pcounters[IPV4][OUT][PF_PASS];
+ pfs->pcounters[IPV4][OUT][PF_PASS];
break;
case LEAF_pfLogInterfaceIp4PktsOutDrop:
val->v.counter64 =
- pfs.pcounters[IPV4][OUT][PF_DROP];
+ pfs->pcounters[IPV4][OUT][PF_DROP];
break;
case LEAF_pfLogInterfaceIp6BytesIn:
- val->v.counter64 = pfs.bcounters[IPV6][IN];
+ val->v.counter64 = pfs->bcounters[IPV6][IN];
break;
case LEAF_pfLogInterfaceIp6BytesOut:
- val->v.counter64 = pfs.bcounters[IPV6][OUT];
+ val->v.counter64 = pfs->bcounters[IPV6][OUT];
break;
case LEAF_pfLogInterfaceIp6PktsInPass:
val->v.counter64 =
- pfs.pcounters[IPV6][IN][PF_PASS];
+ pfs->pcounters[IPV6][IN][PF_PASS];
break;
case LEAF_pfLogInterfaceIp6PktsInDrop:
val->v.counter64 =
- pfs.pcounters[IPV6][IN][PF_DROP];
+ pfs->pcounters[IPV6][IN][PF_DROP];
break;
case LEAF_pfLogInterfaceIp6PktsOutPass:
val->v.counter64 =
- pfs.pcounters[IPV6][OUT][PF_PASS];
+ pfs->pcounters[IPV6][OUT][PF_PASS];
break;
case LEAF_pfLogInterfaceIp6PktsOutDrop:
val->v.counter64 =
- pfs.pcounters[IPV6][OUT][PF_DROP];
+ pfs->pcounters[IPV6][OUT][PF_DROP];
break;
default:
@@ -1288,9 +1286,10 @@ pfs_refresh(void)
if (started && this_tick <= pf_tick)
return (0);
- bzero(&pfs, sizeof(struct pf_status));
+ pfctl_free_status(pfs);
+ pfs = pfctl_get_status(dev);
- if (ioctl(dev, DIOCGETSTATUS, &pfs)) {
+ if (pfs == NULL) {
syslog(LOG_ERR, "pfs_refresh(): ioctl(): %s",
strerror(errno));
return (-1);
@@ -1514,24 +1513,21 @@ err2:
static int
pfl_scan_ruleset(const char *path)
{
- struct pfioc_rule pr;
+ struct pfctl_rules_info rules;
struct pfctl_rule rule;
+ char anchor_call[MAXPATHLEN] = "";
struct pfl_entry *e;
u_int32_t nr, i;
- bzero(&pr, sizeof(pr));
- strlcpy(pr.anchor, path, sizeof(pr.anchor));
- pr.rule.action = PF_PASS;
- if (ioctl(dev, DIOCGETRULES, &pr)) {
+ if (pfctl_get_rules_info(dev, &rules, PF_PASS, path)) {
syslog(LOG_ERR, "pfl_scan_ruleset: ioctl(DIOCGETRULES): %s",
strerror(errno));
goto err;
}
- for (nr = pr.nr, i = 0; i < nr; i++) {
- pr.nr = i;
- if (pfctl_get_rule(dev, pr.nr, pr.ticket, pr.anchor,
- PF_PASS, &rule, pr.anchor_call)) {
+ for (nr = rules.nr, i = 0; i < nr; i++) {
+ if (pfctl_get_rule(dev, i, rules.ticket, path,
+ PF_PASS, &rule, anchor_call)) {
syslog(LOG_ERR, "pfl_scan_ruleset: ioctl(DIOCGETRULE):"
" %s", strerror(errno));
goto err;
@@ -1757,6 +1753,9 @@ pf_fini(void)
l1 = l2;
}
+ pfctl_free_status(pfs);
+ pfs = NULL;
+
close(dev);
return (0);
}
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def b/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def
index b545c1e79fae..dcdf676aa752 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
(1 internet
diff --git a/usr.sbin/bsnmpd/modules/snmp_target/Makefile b/usr.sbin/bsnmpd/modules/snmp_target/Makefile
index 610e746541f7..4a0589979f08 100644
--- a/usr.sbin/bsnmpd/modules/snmp_target/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_target/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Author: Shteryana Shopova <syrinx@freebsd.org>
diff --git a/usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend
index 8abd5d2de4ea..42ad098101e4 100644
--- a/usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend
@@ -1,14 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libbsnmp/libbsnmp \
lib/libc \
lib/libcompiler_rt \
+ usr.sbin/bsnmpd/gensnmptree.host \
.include <dirdeps.mk>
diff --git a/usr.sbin/bsnmpd/modules/snmp_usm/Makefile b/usr.sbin/bsnmpd/modules/snmp_usm/Makefile
index a5e8e8cf9237..40107dba189d 100644
--- a/usr.sbin/bsnmpd/modules/snmp_usm/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_usm/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Author: Shteryana Shopova <syrinx@freebsd.org>
diff --git a/usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend
index 8abd5d2de4ea..42ad098101e4 100644
--- a/usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend
@@ -1,14 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libbsnmp/libbsnmp \
lib/libc \
lib/libcompiler_rt \
+ usr.sbin/bsnmpd/gensnmptree.host \
.include <dirdeps.mk>
diff --git a/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile b/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile
index d35842bb44f6..5dced04d3362 100644
--- a/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Author: Shteryana Shopova <syrinx@freebsd.org>
diff --git a/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend
index 8abd5d2de4ea..42ad098101e4 100644
--- a/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend
@@ -1,14 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libbsnmp/libbsnmp \
lib/libc \
lib/libcompiler_rt \
+ usr.sbin/bsnmpd/gensnmptree.host \
.include <dirdeps.mk>
diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/BEGEMOT-WIRELESS-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_wlan/BEGEMOT-WIRELESS-MIB.txt
index 69873eddf33d..a377b7b6988d 100644
--- a/usr.sbin/bsnmpd/modules/snmp_wlan/BEGEMOT-WIRELESS-MIB.txt
+++ b/usr.sbin/bsnmpd/modules/snmp_wlan/BEGEMOT-WIRELESS-MIB.txt
@@ -25,8 +25,6 @@
-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-- SUCH DAMAGE.
--
--- $FreeBSD$
---
BEGEMOT-WIRELESS-MIB DEFINITIONS ::= BEGIN
diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile b/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile
index eb6b230210e9..82bcba690416 100644
--- a/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
MOD= wlan
diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend
index f927b80bbaed..39bad4aa8eb1 100644
--- a/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend
@@ -1,14 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libbsnmp/libbsnmp \
lib/libc \
lib/libcompiler_rt \
+ usr.sbin/bsnmpd/gensnmptree.host \
usr.sbin/bsnmpd/modules \
usr.sbin/bsnmpd/modules/snmp_mibII \
diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/snmp_wlan.3 b/usr.sbin/bsnmpd/modules/snmp_wlan/snmp_wlan.3
index f1bf983f579b..284762048903 100644
--- a/usr.sbin/bsnmpd/modules/snmp_wlan/snmp_wlan.3
+++ b/usr.sbin/bsnmpd/modules/snmp_wlan/snmp_wlan.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 28, 2010
.Dt SNMP_WLAN 3
.Os
diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.c b/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.c
index aaa2b3071352..5e27aaee8aee 100644
--- a/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.c
+++ b/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2010 The FreeBSD Foundation
*
@@ -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/queue.h>
diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.h b/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.h
index f5fce0e3a01f..6c156b840c6d 100644
--- a/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.h
+++ b/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2010 The FreeBSD Foundation
*
@@ -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$
*/
#define WLAN_IFMODE_MAX WlanIfaceOperatingModeType_tdma
diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_sys.c b/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_sys.c
index 3ac2d63d105d..b129e42b9d85 100644
--- a/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_sys.c
+++ b/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_sys.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2010 The FreeBSD Foundation
*
@@ -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/ioctl.h>
@@ -70,8 +68,8 @@ static uint32_t wlan_cryptocaps_to_snmp(uint32_t);
static uint32_t wlan_htcaps_to_snmp(uint32_t);
static uint32_t wlan_peerstate_to_snmp(uint32_t);
static uint32_t wlan_peercaps_to_snmp(uint32_t );
-static uint32_t wlan_channel_flags_to_snmp_phy(uint32_t);
-static uint32_t wlan_regdomain_to_snmp(int);
+static enum WlanIfPhyMode wlan_channel_flags_to_snmp_phy(uint32_t);
+static enum WlanRegDomainCode wlan_regdomain_to_snmp(int);
static uint32_t wlan_snmp_to_scan_flags(int);
static int wlan_config_snmp2ioctl(int);
static int wlan_snmp_to_regdomain(enum WlanRegDomainCode);
diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_tree.def b/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_tree.def
index 630e46392f77..c977135d4f63 100644
--- a/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_tree.def
+++ b/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_tree.def
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
#include "tc.def"
diff --git a/usr.sbin/bsnmpd/tools/Makefile b/usr.sbin/bsnmpd/tools/Makefile
index cba5cee47ea9..30cc032e2557 100644
--- a/usr.sbin/bsnmpd/tools/Makefile
+++ b/usr.sbin/bsnmpd/tools/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Author: Shteryana Shopova <syrinx@FreeBSD.org>
SUBDIR= libbsnmptools \
diff --git a/usr.sbin/bsnmpd/tools/Makefile.inc b/usr.sbin/bsnmpd/tools/Makefile.inc
index db12061896d2..67bb48436ae1 100644
--- a/usr.sbin/bsnmpd/tools/Makefile.inc
+++ b/usr.sbin/bsnmpd/tools/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Author: Shteryana Shopova <syrinx@FreeBSD.org>
BINDIR?= /usr/bin
diff --git a/usr.sbin/bsnmpd/tools/bsnmptools/Makefile b/usr.sbin/bsnmpd/tools/bsnmptools/Makefile
index 09280a48a3b5..55dc768dc16b 100644
--- a/usr.sbin/bsnmpd/tools/bsnmptools/Makefile
+++ b/usr.sbin/bsnmpd/tools/bsnmptools/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Author: Shteryana Shopova <syrinx@FreeBSD.org>
.include <src.opts.mk>
diff --git a/usr.sbin/bsnmpd/tools/bsnmptools/Makefile.depend b/usr.sbin/bsnmpd/tools/bsnmptools/Makefile.depend
index 8bc992fec38f..043c4c9ddc54 100644
--- a/usr.sbin/bsnmpd/tools/bsnmptools/Makefile.depend
+++ b/usr.sbin/bsnmpd/tools/bsnmptools/Makefile.depend
@@ -1,15 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libbsnmp/libbsnmp \
lib/libc \
lib/libcompiler_rt \
- secure/lib/libcrypto \
usr.sbin/bsnmpd/tools/libbsnmptools \
diff --git a/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1 b/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1
index 95abc87a5720..b67e9bf4b34b 100644
--- a/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1
+++ b/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.1
@@ -31,8 +31,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 10, 2012
.Dt BSNMPGET 1
.Os
@@ -136,7 +134,7 @@ digest.
By default SNMPv3 PDUs are sent unauthenticated.
.It Fl a
Skip any sanity checks when adding OIDs to a Protocol Data Unit (PDU):
-ingore syntax/access type, allow adding of non-leaf objects for GetPdu and
+ignore syntax/access type, allow adding of non-leaf objects for GetPdu and
read-only objects to a SetPDU.
.It Fl b Ar buffersize
Tune the size of buffers used to send and receive packets.
diff --git a/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c b/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
index cc8cc33511cf..81108387d3a4 100644
--- a/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
+++ b/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
@@ -28,8 +28,6 @@
*
* Bsnmpget and bsnmpwalk are simple tools for querying SNMP agents,
* bsnmpset can be used to set MIB objects in an agent.
- *
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile b/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile
index 970a2e8f0bf8..6be5be8aff6a 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
.PATH: ${.CURDIR}
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend b/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend
index b69d36eac75e..57aa342ba52f 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c
index 77785313ff92..5eb7890178d0 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c
@@ -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$
*/
/*
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c
index abee9c231089..e203490fb4c3 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c
@@ -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$
*/
#include <sys/param.h>
@@ -288,7 +286,7 @@ enum_pair_insert(struct enum_pairs *headp, int32_t enum_val, char *enum_str)
/*
* Insert an entry in a list - entries are lexicographicaly order by asn_oid.
* Returns 1 on success, -1 if list is not initialized, 0 if a matching oid already
- * exists. Error cheking is left to calling function.
+ * exists. Error checking is left to calling function.
*/
static int
snmp_mapping_insert(struct snmp_mapping *headp, struct snmp_oid2str *entry)
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
index dcc4361d2192..354ea2ece83a 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
@@ -27,8 +27,6 @@
* SUCH DAMAGE.
*
* Textual conventions for OctetStrings
- *
- * $FreeBSD$
*/
#include <sys/param.h>
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.h b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.h
index fd066762ad7d..676d6c83bd24 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.h
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.h
@@ -27,8 +27,6 @@
* SUCH DAMAGE.
*
* Textual conventions for snmp
- *
- * $FreeBSD$
*/
#ifndef _BSNMP_TEXT_CONV_H_
@@ -39,14 +37,14 @@
/*
* 11 bytes - octets that represent DateAndTime Textual convention
- * and the size of string used to diplay that.
+ * and the size of string used to display that.
*/
#define SNMP_DATETIME_OCTETS 11
#define SNMP_DATETIME_STRSZ 32
/*
* 6 bytes - octets that represent PhysAddress Textual convention
- * and the size of string used to diplay that.
+ * and the size of string used to display that.
*/
#define SNMP_PHYSADDR_OCTETS 6
#define SNMP_PHYSADDR_STRSZ 19
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
index bd2034a0f156..a9d44cee4364 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
@@ -27,8 +27,6 @@
* SUCH DAMAGE.
*
* Helper functions for snmp client tools
- *
- * $FreeBSD$
*/
#include <sys/param.h>
@@ -52,7 +50,7 @@
#include "bsnmptc.h"
#include "bsnmptools.h"
-/* Internal varibale to turn on library debugging for testing and to
+/* Internal variable to turn on library debugging for testing and to
* find bugs. It is not exported via the header file.
* XXX should we cover it by some #ifdef BSNMPTOOLS_DEBUG? */
int _bsnmptools_debug = 0;
@@ -483,7 +481,7 @@ parse_ascii(char *ascii, uint8_t *binstr, size_t binlen)
int32_t
parse_authentication(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
{
- int32_t count, subopt;
+ int32_t /* count, */ subopt;
char *val, *option;
const char *const subopts[] = {
"proto",
@@ -492,7 +490,7 @@ parse_authentication(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
};
assert(opt_arg != NULL);
- count = 1;
+ /* count = 1; */
while ((subopt = getsubopt1(&opt_arg, subopts, &val, &option)) != EOF) {
switch (subopt) {
case 0:
@@ -530,7 +528,7 @@ parse_authentication(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
warnx("Unknown suboption - '%s'", suboptarg);
return (-1);
}
- count += 1;
+ /* count += 1; */
}
return (2/* count */);
}
@@ -538,7 +536,7 @@ parse_authentication(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
int32_t
parse_privacy(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
{
- int32_t count, subopt;
+ int32_t /* count, */ subopt;
char *val, *option;
const char *const subopts[] = {
"proto",
@@ -547,7 +545,7 @@ parse_privacy(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
};
assert(opt_arg != NULL);
- count = 1;
+ /* count = 1; */
while ((subopt = getsubopt1(&opt_arg, subopts, &val, &option)) != EOF) {
switch (subopt) {
case 0:
@@ -583,7 +581,7 @@ parse_privacy(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
warnx("Unknown suboption - '%s'", suboptarg);
return (-1);
}
- count += 1;
+ /* count += 1; */
}
return (2/* count */);
}
@@ -591,7 +589,7 @@ parse_privacy(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
int32_t
parse_context(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
{
- int32_t count, subopt;
+ int32_t /* count, */ subopt;
char *val, *option;
const char *const subopts[] = {
"context",
@@ -600,7 +598,7 @@ parse_context(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
};
assert(opt_arg != NULL);
- count = 1;
+ /* count = 1; */
while ((subopt = getsubopt1(&opt_arg, subopts, &val, &option)) != EOF) {
switch (subopt) {
case 0:
@@ -625,7 +623,7 @@ parse_context(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
warnx("Unknown suboption - '%s'", suboptarg);
return (-1);
}
- count += 1;
+ /* count += 1; */
}
return (2/* count */);
}
@@ -633,7 +631,7 @@ parse_context(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
int32_t
parse_user_security(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
{
- int32_t count, subopt, saved_errno;
+ int32_t /* count, */ subopt, saved_errno;
char *val, *option;
const char *const subopts[] = {
"engine",
@@ -644,7 +642,7 @@ parse_user_security(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
};
assert(opt_arg != NULL);
- count = 1;
+ /* count = 1; */
while ((subopt = getsubopt1(&opt_arg, subopts, &val, &option)) != EOF) {
switch (subopt) {
case 0:
@@ -697,7 +695,7 @@ parse_user_security(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg)
warnx("Unknown suboption - '%s'", suboptarg);
return (-1);
}
- count += 1;
+ /* count += 1; */
}
return (2/* count */);
}
@@ -1340,7 +1338,7 @@ snmp_suboid_pop(struct asn_oid *var)
}
/*
- * Parse the command-line provided string into an OID - alocate memory for a new
+ * Parse the command-line provided string into an OID - allocate memory for a new
* snmp object, fill in its fields and insert it in the object list. A
* (snmp_verify_inoid_f) function must be provided to validate the input string.
*/
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.h b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.h
index 9c0e3d031b04..2874f311fbd0 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.h
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.h
@@ -27,8 +27,6 @@
* SUCH DAMAGE.
*
* Helper functions common for all tools.
- *
- * $FreeBSD$
*/
#ifndef _BSNMP_TOOLS_H_
diff --git a/usr.sbin/btxld/Makefile b/usr.sbin/btxld/Makefile
index 32cf99d5edac..ec28d20b49df 100644
--- a/usr.sbin/btxld/Makefile
+++ b/usr.sbin/btxld/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= btxld
MAN= btxld.8
diff --git a/usr.sbin/btxld/Makefile.depend b/usr.sbin/btxld/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/btxld/Makefile.depend
+++ b/usr.sbin/btxld/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/btxld/btx.h b/usr.sbin/btxld/btx.h
index 54b165a4fc92..6e101b89d933 100644
--- a/usr.sbin/btxld/btx.h
+++ b/usr.sbin/btxld/btx.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Robert Nordier
* All rights reserved.
@@ -24,8 +24,6 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _BTX_H_
diff --git a/usr.sbin/btxld/btxld.8 b/usr.sbin/btxld/btxld.8
index cfa4623e49d9..1127b17179bb 100644
--- a/usr.sbin/btxld/btxld.8
+++ b/usr.sbin/btxld/btxld.8
@@ -22,8 +22,6 @@
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd September 12, 1998
.Dt BTXLD 8
.Os
diff --git a/usr.sbin/btxld/btxld.c b/usr.sbin/btxld/btxld.c
index 931a224fe998..86d380926e90 100644
--- a/usr.sbin/btxld/btxld.c
+++ b/usr.sbin/btxld/btxld.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Robert Nordier
* All rights reserved.
@@ -26,11 +26,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/stat.h>
@@ -127,7 +122,7 @@ static unsigned int optfmt(const char *);
static uint32_t optaddr(const char *);
static int optpage(const char *, int);
static void Warn(const char *, const char *, ...);
-static void usage(void);
+static void usage(void) __dead2;
/*
* A link editor for BTX clients.
diff --git a/usr.sbin/btxld/elfh.c b/usr.sbin/btxld/elfh.c
index 115329e55a16..8e9ea16c2cf6 100644
--- a/usr.sbin/btxld/elfh.c
+++ b/usr.sbin/btxld/elfh.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Robert Nordier
* All rights reserved.
@@ -24,8 +24,6 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.sbin/btxld/elfh.h b/usr.sbin/btxld/elfh.h
index 03b7d959acd4..c59e5ed4dd9f 100644
--- a/usr.sbin/btxld/elfh.h
+++ b/usr.sbin/btxld/elfh.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Robert Nordier
* All rights reserved.
@@ -24,8 +24,6 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <sys/elf32.h>
diff --git a/usr.sbin/camdd/Makefile b/usr.sbin/camdd/Makefile
index 4719130703ee..3762762ad528 100644
--- a/usr.sbin/camdd/Makefile
+++ b/usr.sbin/camdd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= camdd
SRCS= camdd.c
diff --git a/usr.sbin/camdd/Makefile.depend b/usr.sbin/camdd/Makefile.depend
index 0c2bad278bed..fa29a0952b34 100644
--- a/usr.sbin/camdd/Makefile.depend
+++ b/usr.sbin/camdd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
@@ -11,7 +9,6 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libexpat \
lib/libmt \
- lib/libsbuf \
lib/libthr \
lib/libutil \
lib/libz \
diff --git a/usr.sbin/camdd/camdd.8 b/usr.sbin/camdd/camdd.8
index c8c8a9934ab4..9071d531ba9b 100644
--- a/usr.sbin/camdd/camdd.8
+++ b/usr.sbin/camdd/camdd.8
@@ -29,8 +29,6 @@
.\"
.\" Authors: Ken Merry (Spectra Logic Corporation)
.\"
-.\" $FreeBSD$
-.\"
.Dd November 11, 2015
.Dt CAMDD 8
.Os
diff --git a/usr.sbin/camdd/camdd.c b/usr.sbin/camdd/camdd.c
index caf06ba9a596..1f067113c562 100644
--- a/usr.sbin/camdd/camdd.c
+++ b/usr.sbin/camdd/camdd.c
@@ -38,8 +38,6 @@
* - An example of how to use the asynchronous pass(4) driver interface.
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/ioctl.h>
#include <sys/stdint.h>
#include <sys/types.h>
@@ -95,14 +93,7 @@ typedef enum {
typedef enum {
CAMDD_ARG_NONE = 0x00000000,
CAMDD_ARG_VERBOSE = 0x00000001,
- CAMDD_ARG_DEVICE = 0x00000002,
- CAMDD_ARG_BUS = 0x00000004,
- CAMDD_ARG_TARGET = 0x00000008,
- CAMDD_ARG_LUN = 0x00000010,
- CAMDD_ARG_UNIT = 0x00000020,
- CAMDD_ARG_TIMEOUT = 0x00000040,
CAMDD_ARG_ERR_RECOVER = 0x00000080,
- CAMDD_ARG_RETRIES = 0x00000100
} camdd_argmask;
typedef enum {
@@ -444,8 +435,7 @@ static sig_atomic_t need_status = 0;
#define CAMDD_PASS_DEFAULT_DEPTH 6
#define CAMDD_PASS_RW_TIMEOUT 60 * 1000
-static int parse_btl(char *tstr, int *bus, int *target, int *lun,
- camdd_argmask *arglst);
+static int parse_btl(char *tstr, int *bus, int *target, int *lun);
void camdd_free_dev(struct camdd_dev *dev);
struct camdd_dev *camdd_alloc_dev(camdd_dev_type dev_type,
struct kevent *new_ke, int num_ke,
@@ -500,8 +490,8 @@ void camdd_sig_handler(int sig);
void camdd_print_status(struct camdd_dev *camdd_dev,
struct camdd_dev *other_dev,
struct timespec *start_time);
-int camdd_rw(struct camdd_io_opts *io_opts, int num_io_opts,
- uint64_t max_io, int retry_count, int timeout);
+int camdd_rw(struct camdd_io_opts *io_opts, camdd_argmask arglist,
+ int num_io_opts, uint64_t max_io, int retry_count, int timeout);
int camdd_parse_io_opts(char *args, int is_write,
struct camdd_io_opts *io_opts);
void usage(void);
@@ -516,7 +506,7 @@ void usage(void);
* Returns the number of parsed components, or 0.
*/
static int
-parse_btl(char *tstr, int *bus, int *target, int *lun, camdd_argmask *arglst)
+parse_btl(char *tstr, int *bus, int *target, int *lun)
{
char *tmpstr;
int convs = 0;
@@ -527,17 +517,14 @@ parse_btl(char *tstr, int *bus, int *target, int *lun, camdd_argmask *arglst)
tmpstr = (char *)strtok(tstr, ":");
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
*bus = strtol(tmpstr, NULL, 0);
- *arglst |= CAMDD_ARG_BUS;
convs++;
tmpstr = (char *)strtok(NULL, ":");
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
*target = strtol(tmpstr, NULL, 0);
- *arglst |= CAMDD_ARG_TARGET;
convs++;
tmpstr = (char *)strtok(NULL, ":");
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
*lun = strtol(tmpstr, NULL, 0);
- *arglst |= CAMDD_ARG_LUN;
convs++;
}
}
@@ -1443,9 +1430,8 @@ camdd_probe_pass_nvme(struct cam_device *cam_dev, union ccb *ccb,
*maxsector = nsdata.nsze;
/* The LBA Data Size (LBADS) is reported as a power of 2 */
- format = nsdata.flbas & NVME_NS_DATA_FLBAS_FORMAT_MASK;
- lbads = (nsdata.lbaf[format] >> NVME_NS_DATA_LBAF_LBADS_SHIFT) &
- NVME_NS_DATA_LBAF_LBADS_MASK;
+ format = NVMEV(NVME_NS_DATA_FLBAS_FORMAT, nsdata.flbas);
+ lbads = NVMEV(NVME_NS_DATA_LBAF_LBADS, nsdata.lbaf[format]);
*block_len = 1 << lbads;
retval = 0;
@@ -2748,12 +2734,9 @@ bailout:
int
camdd_get_next_lba_len(struct camdd_dev *dev, uint64_t *lba, ssize_t *len)
{
- struct camdd_dev_pass *pass_dev;
uint32_t num_blocks;
int retval = 0;
- pass_dev = &dev->dev_spec.pass;
-
*lba = dev->next_io_pos_bytes / dev->sector_size;
*len = dev->blocksize;
num_blocks = *len / dev->sector_size;
@@ -2810,15 +2793,11 @@ camdd_queue(struct camdd_dev *dev, struct camdd_buf *read_buf)
{
struct camdd_buf *buf = NULL;
struct camdd_buf_data *data;
- struct camdd_dev_pass *pass_dev;
size_t new_len;
struct camdd_buf_data *rb_data;
int is_write = dev->write_dev;
int eof_flush_needed = 0;
int retval = 0;
- int error;
-
- pass_dev = &dev->dev_spec.pass;
/*
* If we've gotten EOF or our partner has, we should not continue
@@ -2839,7 +2818,7 @@ camdd_queue(struct camdd_dev *dev, struct camdd_buf *read_buf)
if (is_write) {
read_buf->status = CAMDD_STATUS_EOF;
- error = camdd_complete_peer_buf(dev, read_buf);
+ camdd_complete_peer_buf(dev, read_buf);
}
goto bailout;
}
@@ -2908,7 +2887,7 @@ camdd_queue(struct camdd_dev *dev, struct camdd_buf *read_buf)
if (len == 0) {
dev->flags |= CAMDD_DEV_FLAG_EOF;
- error = camdd_complete_peer_buf(dev, read_buf);
+ camdd_complete_peer_buf(dev, read_buf);
goto bailout;
}
}
@@ -3215,8 +3194,8 @@ camdd_print_status(struct camdd_dev *camdd_dev, struct camdd_dev *other_dev,
}
int
-camdd_rw(struct camdd_io_opts *io_opts, int num_io_opts, uint64_t max_io,
- int retry_count, int timeout)
+camdd_rw(struct camdd_io_opts *io_opts, camdd_argmask arglist, int num_io_opts,
+ uint64_t max_io, int retry_count, int timeout)
{
struct cam_device *new_cam_dev = NULL;
struct camdd_dev *devs[2];
@@ -3238,13 +3217,12 @@ camdd_rw(struct camdd_io_opts *io_opts, int num_io_opts, uint64_t max_io,
switch (io_opts[i].dev_type) {
case CAMDD_DEV_PASS: {
if (isdigit(io_opts[i].dev_name[0])) {
- camdd_argmask new_arglist = CAMDD_ARG_NONE;
int bus = 0, target = 0, lun = 0;
int rv;
/* device specified as bus:target[:lun] */
rv = parse_btl(io_opts[i].dev_name, &bus,
- &target, &lun, &new_arglist);
+ &target, &lun);
if (rv < 2) {
warnx("numeric device specification "
"must be either bus:target, or "
@@ -3253,9 +3231,8 @@ camdd_rw(struct camdd_io_opts *io_opts, int num_io_opts, uint64_t max_io,
goto bailout;
}
/* default to 0 if lun was not specified */
- if ((new_arglist & CAMDD_ARG_LUN) == 0) {
+ if (rv == 2) {
lun = 0;
- new_arglist |= CAMDD_ARG_LUN;
}
new_cam_dev = cam_open_btl(bus, target, lun,
O_RDWR, NULL);
@@ -3280,7 +3257,7 @@ camdd_rw(struct camdd_io_opts *io_opts, int num_io_opts, uint64_t max_io,
devs[i] = camdd_probe_pass(new_cam_dev,
/*io_opts*/ &io_opts[i],
- CAMDD_ARG_ERR_RECOVER,
+ arglist,
/*probe_retry_count*/ 3,
/*probe_timeout*/ 5000,
/*io_retry_count*/ retry_count,
@@ -3585,7 +3562,6 @@ main(int argc, char **argv)
if (retry_count < 0)
errx(1, "retry count %d is < 0",
retry_count);
- arglist |= CAMDD_ARG_RETRIES;
break;
case 'E':
arglist |= CAMDD_ARG_ERR_RECOVER;
@@ -3618,7 +3594,6 @@ main(int argc, char **argv)
errx(1, "invalid timeout %d", timeout);
/* Convert the timeout from seconds to ms */
timeout *= 1000;
- arglist |= CAMDD_ARG_TIMEOUT;
break;
case 'v':
arglist |= CAMDD_ARG_VERBOSE;
@@ -3641,7 +3616,7 @@ main(int argc, char **argv)
if (timeout == 0)
timeout = CAMDD_PASS_RW_TIMEOUT;
- error = camdd_rw(opt_list, 2, max_io, retry_count, timeout);
+ error = camdd_rw(opt_list, arglist, 2, max_io, retry_count, timeout);
bailout:
free(opt_list);
diff --git a/usr.sbin/cdcontrol/Makefile b/usr.sbin/cdcontrol/Makefile
index de9560644501..8bbd515f4683 100644
--- a/usr.sbin/cdcontrol/Makefile
+++ b/usr.sbin/cdcontrol/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= cdcontrol
diff --git a/usr.sbin/cdcontrol/Makefile.depend b/usr.sbin/cdcontrol/Makefile.depend
index 965e3a120be6..771ed4075eda 100644
--- a/usr.sbin/cdcontrol/Makefile.depend
+++ b/usr.sbin/cdcontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -10,7 +8,6 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libedit \
- lib/ncurses/ncursesw \
.include <dirdeps.mk>
diff --git a/usr.sbin/cdcontrol/cdcontrol.1 b/usr.sbin/cdcontrol/cdcontrol.1
index 4af7d7095a26..8f451dc4f88f 100644
--- a/usr.sbin/cdcontrol/cdcontrol.1
+++ b/usr.sbin/cdcontrol/cdcontrol.1
@@ -1,4 +1,3 @@
-.\" $FreeBSD$
.\"
.Dd August 25, 2016
.Dt CDCONTROL 1
diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c
index 546c20b6f94a..c63ec3ee49f3 100644
--- a/usr.sbin/cdcontrol/cdcontrol.c
+++ b/usr.sbin/cdcontrol/cdcontrol.c
@@ -32,8 +32,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/cdio.h>
#include <sys/cdrio.h>
#include <sys/file.h>
@@ -520,7 +518,7 @@ play(char *arg)
/*
* Play MSF m1:s1 [ .f1 ] [ m2:s2 [ .f2 ] ]
*
- * Will now also undestand timed addresses relative
+ * Will now also understand timed addresses relative
* to the beginning of a track in the form...
*
* tr1 m1:s1[.f1] [[tr2] [m2:s2[.f2]]]
diff --git a/usr.sbin/certctl/Makefile b/usr.sbin/certctl/Makefile
index df5acb606143..69894f8a8234 100644
--- a/usr.sbin/certctl/Makefile
+++ b/usr.sbin/certctl/Makefile
@@ -1,6 +1,5 @@
-# $FreeBSD$
-PACKAGE= caroot
+PACKAGE= certctl
SCRIPTS=certctl.sh
MAN= certctl.8
diff --git a/usr.sbin/certctl/certctl.8 b/usr.sbin/certctl/certctl.8
index 9af2adaba757..286072c1b4d6 100644
--- a/usr.sbin/certctl/certctl.8
+++ b/usr.sbin/certctl/certctl.8
@@ -1,5 +1,5 @@
.\"
-.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright 2018 Allan Jude <allanjude@freebsd.org>
.\"
@@ -24,9 +24,7 @@
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd June 18, 2021
+.Dd October 10, 2023
.Dt CERTCTL 8
.Os
.Sh NAME
@@ -60,6 +58,8 @@ Flags:
.Bl -tag -width 4n
.It Fl D Ar destdir
Specify the DESTDIR (overriding values from the environment).
+.It Fl d Ar distbase
+Specify the DISTBASE (overriding values from the environment).
.It Fl M Ar metalog
Specify the path of the METALOG file (default: $DESTDIR/METALOG).
.It Fl n
@@ -96,25 +96,32 @@ Remove the specified file from the untrusted list.
.Bl -tag -width UNTRUSTDESTDIR
.It Ev DESTDIR
Alternate destination directory to operate on.
+.It Ev DISTBASE
+Additional path component to include when operating on certificate directories.
+.It Ev LOCALBASE
+Location for local programs.
+Defaults to the value of the user.localbase sysctl which is usually
+.Pa /usr/local .
.It Ev TRUSTPATH
List of paths to search for trusted certificates.
Default:
-.Pa <DESTDIR>/usr/share/certs/trusted
-.Pa <DESTDIR>/usr/local/share/certs <DESTDIR>/usr/local/etc/ssl/certs
+.Pa <DESTDIR><DISTBASE>/usr/share/certs/trusted
+.Pa <DESTDIR><DISTBASE>/usr/local/share/certs
+.Pa <DESTDIR><DISTBASE><LOCALBASE>/etc/ssl/certs
.It Ev UNTRUSTPATH
List of paths to search for untrusted certificates.
Default:
-.Pa <DESTDIR>/usr/share/certs/untrusted
-.Pa <DESTDIR>/usr/local/etc/ssl/untrusted
-.Pa <DESTDIR>/usr/local/etc/ssl/blacklisted
+.Pa <DESTDIR><DISTBASE>/usr/share/certs/untrusted
+.Pa <DESTDIR><DISTBASE><LOCALBASE>/etc/ssl/untrusted
+.Pa <DESTDIR><DISTBASE><LOCALBASE>/etc/ssl/blacklisted
.It Ev CERTDESTDIR
Destination directory for symbolic links to trusted certificates.
Default:
-.Pa <DESTDIR>/etc/ssl/certs
+.Pa <DESTDIR><DISTBASE>/etc/ssl/certs
.It Ev UNTRUSTDESTDIR
Destination directory for symbolic links to untrusted certificates.
Default:
-.Pa <DESTDIR>/etc/ssl/untrusted
+.Pa <DESTDIR><DISTBASE>/etc/ssl/untrusted
.It Ev EXTENSIONS
List of file extensions to read as certificate files.
Default: *.pem *.crt *.cer *.crl *.0
diff --git a/usr.sbin/certctl/certctl.sh b/usr.sbin/certctl/certctl.sh
index 327eaa6381a6..f95b4561d852 100755
--- a/usr.sbin/certctl/certctl.sh
+++ b/usr.sbin/certctl/certctl.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#-
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright 2018 Allan Jude <allanjude@freebsd.org>
#
@@ -25,33 +25,67 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
-# $FreeBSD$
+
+set -u
############################################################ CONFIGURATION
: ${DESTDIR:=}
-: ${FILEPAT:="\.pem$|\.crt$|\.cer$|\.crl$"}
-: ${VERBOSE:=0}
+: ${DISTBASE:=}
############################################################ GLOBALS
SCRIPTNAME="${0##*/}"
ERRORS=0
-NOOP=0
-UNPRIV=0
+NOOP=false
+UNPRIV=false
+VERBOSE=false
############################################################ FUNCTIONS
+info()
+{
+ echo "${0##*/}: $@" >&2
+}
+
+verbose()
+{
+ if "${VERBOSE}" ; then
+ info "$@"
+ fi
+}
+
+perform()
+{
+ if ! "${NOOP}" ; then
+ "$@"
+ fi
+}
+
+cert_files_in()
+{
+ find -L "$@" -type f \( \
+ -name '*.pem' -or \
+ -name '*.crt' -or \
+ -name '*.cer' \
+ \) 2>/dev/null
+}
+
+eolcvt()
+{
+ cat "$@" | tr -s '\r' '\n'
+}
+
do_hash()
{
local hash
- if hash=$( openssl x509 -noout -subject_hash -in "$1" ); then
+ if hash=$(openssl x509 -noout -subject_hash -in "$1") ; then
echo "$hash"
return 0
else
- echo "Error: $1" >&2
- ERRORS=$(( $ERRORS + 1 ))
+ info "Error: $1"
+ ERRORS=$((ERRORS + 1))
return 1
fi
}
@@ -64,7 +98,7 @@ get_decimal()
hash=$2
decimal=0
- while [ -e "$checkdir/$hash.$decimal" ]; do
+ while [ -e "$checkdir/$hash.$decimal" ] ; do
decimal=$((decimal + 1))
done
@@ -72,24 +106,32 @@ get_decimal()
return 0
}
-create_trusted_link()
+create_trusted()
{
- local blisthash certhash hash
+ local hash certhash otherfile otherhash
local suffix
-
- hash=$( do_hash "$1" ) || return
- certhash=$( openssl x509 -sha1 -in "$1" -noout -fingerprint )
- for blistfile in $(find $UNTRUSTDESTDIR -name "$hash.*"); do
- blisthash=$( openssl x509 -sha1 -in "$blistfile" -noout -fingerprint )
- if [ "$certhash" = "$blisthash" ]; then
- echo "Skipping untrusted certificate $1 ($blistfile)"
- return 1
+ local link=${2:+-lrs}
+
+ hash=$(do_hash "$1") || return
+ certhash=$(openssl x509 -sha1 -in "$1" -noout -fingerprint)
+ for otherfile in $(find $UNTRUSTDESTDIR -name "$hash.*") ; do
+ otherhash=$(openssl x509 -sha1 -in "$otherfile" -noout -fingerprint)
+ if [ "$certhash" = "$otherhash" ] ; then
+ info "Skipping untrusted certificate $hash ($otherfile)"
+ return 0
+ fi
+ done
+ for otherfile in $(find $CERTDESTDIR -name "$hash.*") ; do
+ otherhash=$(openssl x509 -sha1 -in "$otherfile" -noout -fingerprint)
+ if [ "$certhash" = "$otherhash" ] ; then
+ verbose "Skipping duplicate entry for certificate $hash"
+ return 0
fi
done
suffix=$(get_decimal "$CERTDESTDIR" "$hash")
- [ $VERBOSE -gt 0 ] && echo "Adding $hash.$suffix to trust store"
- [ $NOOP -eq 0 ] && \
- install ${INSTALLFLAGS} -lrs $(realpath "$1") "$CERTDESTDIR/$hash.$suffix"
+ verbose "Adding $hash.$suffix to trust store"
+ perform install ${INSTALLFLAGS} -m 0444 ${link} \
+ "$(realpath "$1")" "$CERTDESTDIR/$hash.$suffix"
}
# Accepts either dot-hash form from `certctl list` or a path to a valid cert.
@@ -99,13 +141,13 @@ resolve_certname()
local suffix
# If it exists as a file, we'll try that; otherwise, we'll scan
- if [ -e "$1" ]; then
- hash=$( do_hash "$1" ) || return
+ if [ -e "$1" ] ; then
+ hash=$(do_hash "$1") || return
srcfile=$(realpath "$1")
suffix=$(get_decimal "$UNTRUSTDESTDIR" "$hash")
filename="$hash.$suffix"
echo "$srcfile" "$hash.$suffix"
- elif [ -e "${CERTDESTDIR}/$1" ]; then
+ elif [ -e "${CERTDESTDIR}/$1" ] ; then
srcfile=$(realpath "${CERTDESTDIR}/$1")
hash=$(echo "$1" | sed -Ee 's/\.([0-9])+$//')
suffix=$(get_decimal "$UNTRUSTDESTDIR" "$hash")
@@ -117,22 +159,24 @@ resolve_certname()
create_untrusted()
{
local srcfile filename
+ local link=${2:+-lrs}
set -- $(resolve_certname "$1")
srcfile=$1
filename=$2
- if [ -z "$srcfile" -o -z "$filename" ]; then
+ if [ -z "$srcfile" -o -z "$filename" ] ; then
return
fi
- [ $VERBOSE -gt 0 ] && echo "Adding $filename to untrusted list"
- [ $NOOP -eq 0 ] && install ${INSTALLFLAGS} -lrs "$srcfile" "$UNTRUSTDESTDIR/$filename"
+ verbose "Adding $filename to untrusted list"
+ perform install ${INSTALLFLAGS} -m 0444 ${link} \
+ "$srcfile" "$UNTRUSTDESTDIR/$filename"
}
do_scan()
{
- local CFUNC CSEARCH CPATH CFILE
+ local CFUNC CSEARCH CPATH CFILE CERT SPLITDIR
local oldIFS="$IFS"
CFUNC="$1"
CSEARCH="$2"
@@ -140,14 +184,25 @@ do_scan()
IFS=:
set -- $CSEARCH
IFS="$oldIFS"
- for CPATH in "$@"; do
- [ -d "$CPATH" ] || continue
- echo "Scanning $CPATH for certificates..."
- for CFILE in $(ls -1 "${CPATH}" | grep -Ee "${FILEPAT}"); do
- [ -e "$CPATH/$CFILE" ] || continue
- [ $VERBOSE -gt 0 ] && echo "Reading $CFILE"
- "$CFUNC" "$CPATH/$CFILE"
- done
+ for CFILE in $(cert_files_in "$@") ; do
+ verbose "Reading $CFILE"
+ case $(eolcvt "$CFILE" | egrep -c '^-+BEGIN CERTIFICATE-+$') in
+ 0)
+ ;;
+ 1)
+ "$CFUNC" "$CFILE" link
+ ;;
+ *)
+ verbose "Multiple certificates found, splitting..."
+ SPLITDIR=$(mktemp -d)
+ eolcvt "$CFILE" | egrep '^(---|[0-9A-Za-z/+=]+$)' | \
+ split -p '^-+BEGIN CERTIFICATE-+$' - "$SPLITDIR/x"
+ for CERT in $(find "$SPLITDIR" -type f) ; do
+ "$CFUNC" "$CERT"
+ done
+ rm -rf "$SPLITDIR"
+ ;;
+ esac
done
}
@@ -155,94 +210,88 @@ do_list()
{
local CFILE subject
- if [ -e "$1" ]; then
- cd "$1"
- for CFILE in *.[0-9]; do
- if [ ! -s "$CFILE" ]; then
- echo "Unable to read $CFILE" >&2
- ERRORS=$(( $ERRORS + 1 ))
- continue
- fi
- subject=
- if [ $VERBOSE -eq 0 ]; then
- subject=$( openssl x509 -noout -subject -nameopt multiline -in "$CFILE" |
- sed -n '/commonName/s/.*= //p' )
- fi
- [ "$subject" ] ||
- subject=$( openssl x509 -noout -subject -in "$CFILE" )
- printf "%s\t%s\n" "$CFILE" "$subject"
- done
- cd -
- fi
+ for CFILE in $(find "$@" \( -type f -or -type l \) -name '*.[0-9]') ; do
+ if [ ! -s "$CFILE" ] ; then
+ info "Unable to read $CFILE"
+ ERRORS=$((ERRORS + 1))
+ continue
+ fi
+ subject=
+ if ! "$VERBOSE" ; then
+ subject=$(openssl x509 -noout -subject -nameopt multiline -in "$CFILE" | sed -n '/commonName/s/.*= //p')
+ fi
+ if [ -z "$subject" ] ; then
+ subject=$(openssl x509 -noout -subject -in "$CFILE")
+ fi
+ printf "%s\t%s\n" "${CFILE##*/}" "$subject"
+ done
}
cmd_rehash()
{
- if [ $NOOP -eq 0 ]; then
- if [ -e "$CERTDESTDIR" ]; then
- find "$CERTDESTDIR" -type link -delete
- else
- mkdir -p "$CERTDESTDIR"
- fi
- if [ -e "$UNTRUSTDESTDIR" ]; then
- find "$UNTRUSTDESTDIR" -type link -delete
- else
- mkdir -p "$UNTRUSTDESTDIR"
- fi
+ if [ -e "$CERTDESTDIR" ] ; then
+ perform find "$CERTDESTDIR" \( -type f -or -type l \) -delete
+ else
+ perform install -d -m 0755 "$CERTDESTDIR"
+ fi
+ if [ -e "$UNTRUSTDESTDIR" ] ; then
+ perform find "$UNTRUSTDESTDIR" \( -type f -or -type l \) -delete
+ else
+ perform install -d -m 0755 "$UNTRUSTDESTDIR"
fi
do_scan create_untrusted "$UNTRUSTPATH"
- do_scan create_trusted_link "$TRUSTPATH"
+ do_scan create_trusted "$TRUSTPATH"
}
cmd_list()
{
- echo "Listing Trusted Certificates:"
+ info "Listing Trusted Certificates:"
do_list "$CERTDESTDIR"
}
cmd_untrust()
{
- local BPATH
+ local UTFILE
shift # verb
- [ $NOOP -eq 0 ] && mkdir -p "$UNTRUSTDESTDIR"
- for BFILE in "$@"; do
- echo "Adding $BFILE to untrusted list"
- create_untrusted "$BFILE"
+ perform install -d -m 0755 "$UNTRUSTDESTDIR"
+ for UTFILE in "$@"; do
+ info "Adding $UTFILE to untrusted list"
+ create_untrusted "$UTFILE"
done
}
cmd_trust()
{
- local BFILE blisthash certhash hash
+ local UTFILE untrustedhash certhash hash
shift # verb
- for BFILE in "$@"; do
- if [ -s "$BFILE" ]; then
- hash=$( do_hash "$BFILE" )
- certhash=$( openssl x509 -sha1 -in "$BFILE" -noout -fingerprint )
- for BLISTEDFILE in $(find $UNTRUSTDESTDIR -name "$hash.*"); do
- blisthash=$( openssl x509 -sha1 -in "$BLISTEDFILE" -noout -fingerprint )
- if [ "$certhash" = "$blisthash" ]; then
- echo "Removing $(basename "$BLISTEDFILE") from untrusted list"
- [ $NOOP -eq 0 ] && rm -f $BLISTEDFILE
+ for UTFILE in "$@"; do
+ if [ -s "$UTFILE" ] ; then
+ hash=$(do_hash "$UTFILE")
+ certhash=$(openssl x509 -sha1 -in "$UTFILE" -noout -fingerprint)
+ for UNTRUSTEDFILE in $(find $UNTRUSTDESTDIR -name "$hash.*") ; do
+ untrustedhash=$(openssl x509 -sha1 -in "$UNTRUSTEDFILE" -noout -fingerprint)
+ if [ "$certhash" = "$untrustedhash" ] ; then
+ info "Removing $(basename "$UNTRUSTEDFILE") from untrusted list"
+ perform rm -f $UNTRUSTEDFILE
fi
done
- elif [ -e "$UNTRUSTDESTDIR/$BFILE" ]; then
- echo "Removing $BFILE from untrusted list"
- [ $NOOP -eq 0 ] && rm -f "$UNTRUSTDESTDIR/$BFILE"
+ elif [ -e "$UNTRUSTDESTDIR/$UTFILE" ] ; then
+ info "Removing $UTFILE from untrusted list"
+ perform rm -f "$UNTRUSTDESTDIR/$UTFILE"
else
- echo "Cannot find $BFILE" >&2
- ERRORS=$(( $ERRORS + 1 ))
+ info "Cannot find $UTFILE"
+ ERRORS=$((ERRORS + 1))
fi
done
}
cmd_untrusted()
{
- echo "Listing Untrusted Certificates:"
+ info "Listing Untrusted Certificates:"
do_list "$UNTRUSTDESTDIR"
}
@@ -254,7 +303,7 @@ usage()
echo " List trusted certificates"
echo " $SCRIPTNAME [-v] untrusted"
echo " List untrusted certificates"
- echo " $SCRIPTNAME [-nUv] [-D <destdir>] [-M <metalog>] rehash"
+ echo " $SCRIPTNAME [-nUv] [-D <destdir>] [-d <distbase>] [-M <metalog>] rehash"
echo " Generate hash links for all certificates"
echo " $SCRIPTNAME [-nv] untrust <file>"
echo " Add <file> to the list of untrusted certificates"
@@ -265,25 +314,33 @@ usage()
############################################################ MAIN
-while getopts D:M:nUv flag; do
+while getopts D:d:M:nUv flag; do
case "$flag" in
D) DESTDIR=${OPTARG} ;;
+ d) DISTBASE=${OPTARG} ;;
M) METALOG=${OPTARG} ;;
- n) NOOP=1 ;;
- U) UNPRIV=1 ;;
- v) VERBOSE=$(( $VERBOSE + 1 )) ;;
+ n) NOOP=true ;;
+ U) UNPRIV=true ;;
+ v) VERBOSE=true ;;
esac
done
-shift $(( $OPTIND - 1 ))
+shift $((OPTIND - 1))
+
+DESTDIR=${DESTDIR%/}
+if ! [ -z "${CERTCTL_VERBOSE:-}" ] ; then
+ VERBOSE=true
+fi
: ${METALOG:=${DESTDIR}/METALOG}
INSTALLFLAGS=
-[ $UNPRIV -eq 1 ] && INSTALLFLAGS="-U -M ${METALOG} -D ${DESTDIR}"
+if "$UNPRIV" ; then
+ INSTALLFLAGS="-U -M ${METALOG} -D ${DESTDIR}"
+fi
: ${LOCALBASE:=$(sysctl -n user.localbase)}
-: ${TRUSTPATH:=${DESTDIR}/usr/share/certs/trusted:${DESTDIR}${LOCALBASE}/share/certs:${DESTDIR}${LOCALBASE}/etc/ssl/certs}
-: ${UNTRUSTPATH:=${DESTDIR}/usr/share/certs/untrusted:${DESTDIR}${LOCALBASE}/etc/ssl/untrusted:${DESTDIR}${LOCALBASE}/etc/ssl/blacklisted}
-: ${CERTDESTDIR:=${DESTDIR}/etc/ssl/certs}
-: ${UNTRUSTDESTDIR:=${DESTDIR}/etc/ssl/untrusted}
+: ${TRUSTPATH:=${DESTDIR}${DISTBASE}/usr/share/certs/trusted:${DESTDIR}${LOCALBASE}/share/certs:${DESTDIR}${LOCALBASE}/etc/ssl/certs}
+: ${UNTRUSTPATH:=${DESTDIR}${DISTBASE}/usr/share/certs/untrusted:${DESTDIR}${LOCALBASE}/etc/ssl/untrusted:${DESTDIR}${LOCALBASE}/etc/ssl/blacklisted}
+: ${CERTDESTDIR:=${DESTDIR}${DISTBASE}/etc/ssl/certs}
+: ${UNTRUSTDESTDIR:=${DESTDIR}${DISTBASE}/etc/ssl/untrusted}
[ $# -gt 0 ] || usage
case "$1" in
@@ -299,7 +356,9 @@ blacklisted) cmd_untrusted ;;
esac
retval=$?
-[ $ERRORS -gt 0 ] && echo "Encountered $ERRORS errors" >&2
+if [ $ERRORS -gt 0 ] ; then
+ info "Encountered $ERRORS errors"
+fi
exit $retval
################################################################################
diff --git a/usr.sbin/chkgrp/Makefile b/usr.sbin/chkgrp/Makefile
index a7bfc548ced1..a079ddb7b185 100644
--- a/usr.sbin/chkgrp/Makefile
+++ b/usr.sbin/chkgrp/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= chkgrp
MAN= chkgrp.8
diff --git a/usr.sbin/chkgrp/Makefile.depend b/usr.sbin/chkgrp/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/chkgrp/Makefile.depend
+++ b/usr.sbin/chkgrp/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/chkgrp/chkgrp.8 b/usr.sbin/chkgrp/chkgrp.8
index c0d71562b4f9..3837e5fe6803 100644
--- a/usr.sbin/chkgrp/chkgrp.8
+++ b/usr.sbin/chkgrp/chkgrp.8
@@ -1,4 +1,4 @@
-.\" Copyright (c) 1998 Dag-Erling Coïdan Smørgrav
+.\" Copyright (c) 1998 Dag-Erling Smørgrav
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,8 +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.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 26, 2005
.Dt CHKGRP 8
.Os
diff --git a/usr.sbin/chkgrp/chkgrp.c b/usr.sbin/chkgrp/chkgrp.c
index 06e78d440556..69eff6e7574d 100644
--- a/usr.sbin/chkgrp/chkgrp.c
+++ b/usr.sbin/chkgrp/chkgrp.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-3-Clause
*
- * Copyright (c) 1998 Dag-Erling Coïdan Smørgrav
+ * Copyright (c) 1998 Dag-Erling Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,8 +29,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <errno.h>
#include <ctype.h>
diff --git a/usr.sbin/chown/Makefile b/usr.sbin/chown/Makefile
index b9dff0785363..705e20fa6552 100644
--- a/usr.sbin/chown/Makefile
+++ b/usr.sbin/chown/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/chown/Makefile.depend b/usr.sbin/chown/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/chown/Makefile.depend
+++ b/usr.sbin/chown/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/chown/chgrp.1 b/usr.sbin/chown/chgrp.1
index 5bb81e6ecbcb..f05c81e4bae7 100644
--- a/usr.sbin/chown/chgrp.1
+++ b/usr.sbin/chown/chgrp.1
@@ -28,9 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)chgrp.1 8.3 (Berkeley) 3/31/94
-.\" $FreeBSD$
-.\"
.Dd January 7, 2017
.Dt CHGRP 1
.Os
diff --git a/usr.sbin/chown/chown.8 b/usr.sbin/chown/chown.8
index 0bf549bb86d8..9f4cfafb6852 100644
--- a/usr.sbin/chown/chown.8
+++ b/usr.sbin/chown/chown.8
@@ -25,10 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)chown.8 8.3 (Berkeley) 3/31/94
-.\" $FreeBSD$
-.\"
-.Dd January 7, 2017
+.Dd August 24, 2022
.Dt CHOWN 8
.Os
.Sh NAME
@@ -165,6 +162,7 @@ and
options are non-standard and their use in scripts is not recommended.
.Sh SEE ALSO
.Xr chgrp 1 ,
+.Xr chmod 1 ,
.Xr find 1 ,
.Xr chown 2 ,
.Xr fts 3 ,
diff --git a/usr.sbin/chown/chown.c b/usr.sbin/chown/chown.c
index a3fe5d351320..4e497714c1b3 100644
--- a/usr.sbin/chown/chown.c
+++ b/usr.sbin/chown/chown.c
@@ -29,21 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1988, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)chown.c 8.8 (Berkeley) 4/4/94";
-#endif /* not lint */
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
diff --git a/usr.sbin/chown/tests/Makefile b/usr.sbin/chown/tests/Makefile
index 506d81cbaa8b..f0c8eb8a318c 100644
--- a/usr.sbin/chown/tests/Makefile
+++ b/usr.sbin/chown/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH+= chown_test
diff --git a/usr.sbin/chown/tests/Makefile.depend b/usr.sbin/chown/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/chown/tests/Makefile.depend
+++ b/usr.sbin/chown/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/chown/tests/chown_test.sh b/usr.sbin/chown/tests/chown_test.sh
index b8b85ab47b6b..d890d7b4dec5 100755
--- a/usr.sbin/chown/tests/chown_test.sh
+++ b/usr.sbin/chown/tests/chown_test.sh
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
get_filesystem()
{
diff --git a/usr.sbin/chroot/Makefile b/usr.sbin/chroot/Makefile
index 652de797cec4..7935fa4b568a 100644
--- a/usr.sbin/chroot/Makefile
+++ b/usr.sbin/chroot/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= chroot
MAN= chroot.8
diff --git a/usr.sbin/chroot/Makefile.depend b/usr.sbin/chroot/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/chroot/Makefile.depend
+++ b/usr.sbin/chroot/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/chroot/chroot.8 b/usr.sbin/chroot/chroot.8
index 9f5b2f380376..f26b7e937da9 100644
--- a/usr.sbin/chroot/chroot.8
+++ b/usr.sbin/chroot/chroot.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)chroot.8 8.1 (Berkeley) 6/9/93
-.\" $FreeBSD$
-.\"
.Dd July 20, 2021
.Dt CHROOT 8
.Os
diff --git a/usr.sbin/chroot/chroot.c b/usr.sbin/chroot/chroot.c
index b14e1cbf4597..32becaf12588 100644
--- a/usr.sbin/chroot/chroot.c
+++ b/usr.sbin/chroot/chroot.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1988, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)chroot.c 8.1 (Berkeley) 6/9/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/procctl.h>
@@ -58,7 +44,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char *argv[])
diff --git a/usr.sbin/ckdist/Makefile b/usr.sbin/ckdist/Makefile
index e8a9213d4f6c..14ed52e5f274 100644
--- a/usr.sbin/ckdist/Makefile
+++ b/usr.sbin/ckdist/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/usr.bin/cksum
diff --git a/usr.sbin/ckdist/Makefile.depend b/usr.sbin/ckdist/Makefile.depend
index 31fbf9bc2f9f..9ec4dd51323e 100644
--- a/usr.sbin/ckdist/Makefile.depend
+++ b/usr.sbin/ckdist/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/ckdist/ckdist.1 b/usr.sbin/ckdist/ckdist.1
index 86175c996307..9acb86ab6276 100644
--- a/usr.sbin/ckdist/ckdist.1
+++ b/usr.sbin/ckdist/ckdist.1
@@ -1,8 +1,6 @@
.\" Copyright (c) 1997 Robert Nordier
.\" All rights reserved.
.\"
-.\" $FreeBSD$
-.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
diff --git a/usr.sbin/ckdist/ckdist.c b/usr.sbin/ckdist/ckdist.c
index d3a0bc313a5f..ccd3a7ddf298 100644
--- a/usr.sbin/ckdist/ckdist.c
+++ b/usr.sbin/ckdist/ckdist.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Robert Nordier
* All rights reserved.
@@ -27,11 +27,6 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/stat.h>
@@ -86,7 +81,7 @@ static const char *stripath(const char *path);
static int distfile(const char *path);
static int disttype(const char *name);
static int fail(const char *path, const char *msg);
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char *argv[])
diff --git a/usr.sbin/clear_locks/Makefile b/usr.sbin/clear_locks/Makefile
index a9355ed2ba29..93eb95d8cad0 100644
--- a/usr.sbin/clear_locks/Makefile
+++ b/usr.sbin/clear_locks/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= nfs
diff --git a/usr.sbin/clear_locks/Makefile.depend b/usr.sbin/clear_locks/Makefile.depend
index 5b0587ae477a..352a225b19c6 100644
--- a/usr.sbin/clear_locks/Makefile.depend
+++ b/usr.sbin/clear_locks/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/rpc \
include/rpcsvc \
diff --git a/usr.sbin/clear_locks/clear_locks.8 b/usr.sbin/clear_locks/clear_locks.8
index 6b601eacfe41..3da49b3c7a8f 100644
--- a/usr.sbin/clear_locks/clear_locks.8
+++ b/usr.sbin/clear_locks/clear_locks.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd March 19, 2008
.Dt CLEAR_LOCKS 8
.Os
diff --git a/usr.sbin/clear_locks/clear_locks.c b/usr.sbin/clear_locks/clear_locks.c
index af4132c27ad0..f2abfeb2d816 100644
--- a/usr.sbin/clear_locks/clear_locks.c
+++ b/usr.sbin/clear_locks/clear_locks.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Isilon Inc http://www.isilon.com/
* Authors: Doug Rabson <dfr@rabson.org>
@@ -28,8 +28,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/usr.sbin/config/Makefile b/usr.sbin/config/Makefile
index 32bfa8de0a0e..5b10ac40df74 100644
--- a/usr.sbin/config/Makefile
+++ b/usr.sbin/config/Makefile
@@ -1,12 +1,10 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
SRCDIR:=${.PARSEDIR:tA}
-PROG= config
+PROG_CXX= config
MAN= config.5 config.8
-SRCS= config.y main.c lang.l mkmakefile.c mkheaders.c \
- mkoptions.c y.tab.h kernconf.c
+SRCS= config.y main.cc lang.l mkmakefile.cc mkheaders.c \
+ mkoptions.cc y.tab.h kernconf.c
FILE2C?=file2c
@@ -18,8 +16,6 @@ CFLAGS+= -I. -I${SRCDIR}
NO_WMISSING_VARIABLE_DECLARATIONS=
-LIBADD= nv sbuf
-
CLEANFILES+= kernconf.c
mkmakefile.o: configvers.h
diff --git a/usr.sbin/config/Makefile.depend b/usr.sbin/config/Makefile.depend
index 7d98418717a1..4b9cd9863363 100644
--- a/usr.sbin/config/Makefile.depend
+++ b/usr.sbin/config/Makefile.depend
@@ -1,15 +1,14 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libc++ \
lib/libcompiler_rt \
- lib/libsbuf \
- usr.bin/lex/lib \
+ lib/libcxxrt \
+ lib/msun \
usr.bin/yacc.host \
diff --git a/usr.sbin/config/config.5 b/usr.sbin/config/config.5
index 134e321831d8..f77b79a31510 100644
--- a/usr.sbin/config/config.5
+++ b/usr.sbin/config/config.5
@@ -21,9 +21,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd October 28, 2021
+.Dd October 17, 2022
.Dt CONFIG 5
.Os
.Sh NAME
@@ -259,8 +257,6 @@ The ARM architecture
The AMD x86-64 architecture.
.It Cm i386
The Intel x86 based PC architecture.
-.It Cm mips
-The MIPS architecture.
.It Cm powerpc
The IBM PowerPC architecture.
.It Cm riscv
diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8
index 929607712ef8..ccb61cdf2786 100644
--- a/usr.sbin/config/config.8
+++ b/usr.sbin/config/config.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)config.8 8.2 (Berkeley) 4/19/94
-.\" $FreeBSD$
-.\"
.Dd April 9, 2021
.Dt CONFIG 8
.Os
@@ -178,7 +175,7 @@ debuggers available prior to
.Bx 4.4 Lite
were able to find some information
from a normal kernel;
-.Xr gdb 1
+.Xr gdb 1 Pq Pa ports/devel/gdb
provides very little support for normal kernels, and a debug kernel is needed
for any meaningful analysis.
.Pp
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index 79d0a788bae7..16562a7f8210 100644
--- a/usr.sbin/config/config.h
+++ b/usr.sbin/config/config.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.
- *
- * @(#)config.h 8.1 (Berkeley) 6/6/93
- * $FreeBSD$
*/
/*
@@ -41,6 +38,62 @@
#include <stdlib.h>
#include <string.h>
+#ifdef __cplusplus
+#include <string>
+
+class configword {
+private:
+ std::string cw_word;
+ bool cw_eof;
+ bool cw_eol;
+public:
+ configword() : cw_word(""), cw_eof(false), cw_eol(false) {}
+ configword(std::string &&word) : cw_word(word), cw_eof(false), cw_eol(false) {}
+
+ bool eof() const {
+ return (cw_eof);
+ }
+
+ bool eol() const {
+ return (cw_eol);
+ }
+
+ configword &eof(bool eof) {
+ cw_eof = eof;
+ return (*this);
+ }
+
+ configword &eol(bool eol) {
+ cw_eol = eol;
+ return (*this);
+ }
+
+ char operator[](int idx) {
+ return (cw_word[idx]);
+ }
+
+ operator const char*() const {
+ return (cw_word.c_str());
+ }
+
+ const std::string &operator*() const {
+ return (cw_word);
+ }
+
+ const std::string *operator->() const {
+ return (&cw_word);
+ }
+};
+
+/*
+ * Is it ugly to limit these to C++ files? Yes.
+ */
+configword get_word(FILE *);
+configword get_quoted_word(FILE *);
+#endif
+
+__BEGIN_DECLS
+
struct cfgfile {
STAILQ_ENTRY(cfgfile) cfg_next;
char *cfg_path;
@@ -183,13 +236,12 @@ extern char kernconfstr[];
extern int do_trace;
extern int incignore;
-char *get_word(FILE *);
-char *get_quoted_word(FILE *);
char *path(const char *);
char *raisestr(char *);
void remember(const char *);
void moveifchanged(const char *, const char *);
int yylex(void);
+int yyparse(void);
void options(void);
void makefile(void);
void makeenv(void);
@@ -218,5 +270,7 @@ extern int versreq;
extern char *PREFIX; /* Config file name - for error messages */
extern char srcdir[]; /* root of the kernel source tree */
+__END_DECLS;
+
#define eq(a,b) (!strcmp(a,b))
#define ns(s) strdup(s)
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index 0ffeb653d722..a5a9e1546c36 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -66,9 +66,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.
- *
- * @(#)config.y 8.1 (Berkeley) 6/6/93
- * $FreeBSD$
*/
#include <assert.h>
@@ -188,8 +185,6 @@ Config_spec:
|
NOMAKEOPTION Save_id { rmopt_schedule(&mkopt, $2); } |
IDENT ID { ident = $2; } |
- System_spec
- |
MAXUSERS NUMBER { maxusers = $2; } |
ENV ID { newenvvar($2, true); } |
ENVVAR ENVLINE { newenvvar($2, false); } |
diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h
index daa57062b1b2..5d73e1064eda 100644
--- a/usr.sbin/config/configvers.h
+++ b/usr.sbin/config/configvers.h
@@ -1,7 +1,5 @@
/*-
* This file is in the public domain
- *
- * $FreeBSD$
*/
/*
@@ -46,8 +44,6 @@
* When a new feature is actually used by the build system, update the
* %VERSREQ field in the Makefile.$ARCH of all the affected makefiles
* (typically all of them).
- *
- * $FreeBSD$
*/
#define CONFIGVERS 600018
#define MAJOR_VERS(x) ((x) / 100000)
diff --git a/usr.sbin/config/kernconf.tmpl b/usr.sbin/config/kernconf.tmpl
index 182614b937b0..ce3437677092 100644
--- a/usr.sbin/config/kernconf.tmpl
+++ b/usr.sbin/config/kernconf.tmpl
@@ -1,8 +1,6 @@
/*
* This file acts as a template for config.c that will be generated in the
* kernel build directory after config(8) has been successfully run.
- *
- * $FreeBSD$
*/
#include "opt_config.h"
#ifdef INCLUDE_CONFIG_FILE
diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l
index ed0b2aa794b3..a6558237db5a 100644
--- a/usr.sbin/config/lang.l
+++ b/usr.sbin/config/lang.l
@@ -28,9 +28,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.
- *
- * @(#)lang.l 8.1 (Berkeley) 6/6/93
- * $FreeBSD$
*/
#include <assert.h>
@@ -297,6 +294,8 @@ include(const char *fname, int ateof)
return (-1);
}
cfgfile_add(fnamebuf == NULL ? fname : fnamebuf);
+ free(fnamebuf);
+
in = malloc(sizeof(*in));
assert(in != NULL);
in->in_prev = inclp;
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.cc
index 60bafb0b46ba..0c0b9bb27dc3 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.cc
@@ -29,35 +29,23 @@
* SUCH DAMAGE.
*/
-#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
-#if 0
-static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/sbuf.h>
#include <sys/file.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <assert.h>
#include <ctype.h>
+#include <dirent.h>
#include <err.h>
+#include <iostream>
+#include <sstream>
#include <stdio.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
-#include <dirent.h>
+
#include "y.tab.h"
#include "config.h"
#include "configvers.h"
@@ -105,14 +93,13 @@ static void cleanheaders(char *);
static void kernconfdump(const char *);
static void badversion(void);
static void checkversion(void);
-extern int yyparse(void);
struct hdr_list {
- char *h_name;
+ const char *h_name;
struct hdr_list *h_next;
} *htab;
-static struct sbuf *line_buf = NULL;
+static std::stringstream line_buf;
/*
* Config builds a set of files for building a UNIX
@@ -314,24 +301,21 @@ usage(void)
static void
init_line_buf(void)
{
- if (line_buf == NULL) {
- line_buf = sbuf_new(NULL, NULL, 80, SBUF_AUTOEXTEND);
- if (line_buf == NULL) {
- errx(EXIT_FAILURE, "failed to allocate line buffer");
- }
- } else {
- sbuf_clear(line_buf);
- }
+
+ line_buf.str("");
}
-static char *
+static std::string
get_line_buf(void)
{
- if (sbuf_finish(line_buf) != 0) {
+
+ line_buf.flush();
+ if (!line_buf.good()) {
errx(EXIT_FAILURE, "failed to generate line buffer, "
- "partial line = %s", sbuf_data(line_buf));
+ "partial line = %s", line_buf.str().c_str());
}
- return sbuf_data(line_buf);
+
+ return line_buf.str();
}
/*
@@ -340,7 +324,7 @@ get_line_buf(void)
* NULL on end of line
* pointer to the word otherwise
*/
-char *
+configword
get_word(FILE *fp)
{
int ch;
@@ -352,7 +336,7 @@ begin:
if (ch != ' ' && ch != '\t')
break;
if (ch == EOF)
- return ((char *)EOF);
+ return (configword().eof(true));
if (ch == '\\'){
escaped_nl = 1;
goto begin;
@@ -363,22 +347,22 @@ begin:
goto begin;
}
else
- return (NULL);
+ return (configword().eol(true));
}
- sbuf_putc(line_buf, ch);
+ line_buf << (char)ch;
/* Negation operator is a word by itself. */
if (ch == '!') {
- return get_line_buf();
+ return (configword(get_line_buf()));
}
while ((ch = getc(fp)) != EOF) {
if (isspace(ch))
break;
- sbuf_putc(line_buf, ch);
+ line_buf << (char)ch;
}
if (ch == EOF)
- return ((char *)EOF);
+ return (configword().eof(true));
(void) ungetc(ch, fp);
- return (get_line_buf());
+ return (configword(get_line_buf()));
}
/*
@@ -386,7 +370,7 @@ begin:
* like get_word but will accept something in double or single quotes
* (to allow embedded spaces).
*/
-char *
+configword
get_quoted_word(FILE *fp)
{
int ch;
@@ -398,7 +382,7 @@ begin:
if (ch != ' ' && ch != '\t')
break;
if (ch == EOF)
- return ((char *)EOF);
+ return (configword().eof(true));
if (ch == '\\'){
escaped_nl = 1;
goto begin;
@@ -409,7 +393,7 @@ begin:
goto begin;
}
else
- return (NULL);
+ return (configword().eol(true));
}
if (ch == '"' || ch == '\'') {
int quote = ch;
@@ -420,7 +404,7 @@ begin:
break;
if (ch == '\n' && !escaped_nl) {
printf("config: missing quote reading `%s'\n",
- get_line_buf());
+ get_line_buf().c_str());
exit(2);
}
if (ch == '\\' && !escaped_nl) {
@@ -428,23 +412,23 @@ begin:
continue;
}
if (ch != quote && escaped_nl)
- sbuf_putc(line_buf, '\\');
- sbuf_putc(line_buf, ch);
+ line_buf << "\\";
+ line_buf << (char)ch;
escaped_nl = 0;
}
} else {
- sbuf_putc(line_buf, ch);
+ line_buf << (char)ch;
while ((ch = getc(fp)) != EOF) {
if (isspace(ch))
break;
- sbuf_putc(line_buf, ch);
+ line_buf << (char)ch;
}
if (ch != EOF)
(void) ungetc(ch, fp);
}
if (ch == EOF)
- return ((char *)EOF);
- return (get_line_buf());
+ return (configword().eof(true));
+ return (configword(get_line_buf()));
}
/*
@@ -459,6 +443,8 @@ path(const char *file)
asprintf(&cp, "%s/%s", destdir, file);
else
cp = strdup(destdir);
+ if (cp == NULL)
+ err(EXIT_FAILURE, "malloc");
return (cp);
}
@@ -467,7 +453,7 @@ path(const char *file)
* will be able to obtain and build conifguration file with one command.
*/
static void
-configfile_dynamic(struct sbuf *sb)
+configfile_dynamic(std::ostringstream &cfg)
{
struct cputype *cput;
struct device *d;
@@ -477,38 +463,35 @@ configfile_dynamic(struct sbuf *sb)
asprintf(&lend, "\\n\\\n");
assert(lend != NULL);
- sbuf_printf(sb, "options\t%s%s", OPT_AUTOGEN, lend);
- sbuf_printf(sb, "ident\t%s%s", ident, lend);
- sbuf_printf(sb, "machine\t%s%s", machinename, lend);
+ cfg << "options\t" << OPT_AUTOGEN << lend;
+ cfg << "ident\t" << ident << lend;
+ cfg << "machine\t" << machinename << lend;
SLIST_FOREACH(cput, &cputype, cpu_next)
- sbuf_printf(sb, "cpu\t%s%s", cput->cpu_name, lend);
+ cfg << "cpu\t" << cput->cpu_name << lend;
SLIST_FOREACH(ol, &mkopt, op_next)
- sbuf_printf(sb, "makeoptions\t%s=%s%s", ol->op_name,
- ol->op_value, lend);
+ cfg << "makeoptions\t" << ol->op_name << '=' <<
+ ol->op_value << lend;
SLIST_FOREACH(ol, &opt, op_next) {
if (strncmp(ol->op_name, "DEV_", 4) == 0)
continue;
- sbuf_printf(sb, "options\t%s", ol->op_name);
+ cfg << "options\t" << ol->op_name;
if (ol->op_value != NULL) {
- sbuf_putc(sb, '=');
+ cfg << '=';
for (i = 0; i < strlen(ol->op_value); i++) {
if (ol->op_value[i] == '"')
- sbuf_printf(sb, "\\%c",
- ol->op_value[i]);
+ cfg << '\\' << ol->op_value[i];
else
- sbuf_printf(sb, "%c",
- ol->op_value[i]);
+ cfg << ol->op_value[i];
}
- sbuf_printf(sb, "%s", lend);
- } else {
- sbuf_printf(sb, "%s", lend);
}
+
+ cfg << lend;
}
/*
* Mark this file as containing everything we need.
*/
STAILQ_FOREACH(d, &dtab, d_next)
- sbuf_printf(sb, "device\t%s%s", d->d_name, lend);
+ cfg << "device\t" << d->d_name << lend;
free(lend);
}
@@ -516,7 +499,7 @@ configfile_dynamic(struct sbuf *sb)
* Generate file from the configuration files.
*/
static void
-configfile_filebased(struct sbuf *sb)
+configfile_filebased(std::ostringstream &cfg)
{
FILE *cff;
struct cfgfile *cf;
@@ -535,11 +518,11 @@ configfile_filebased(struct sbuf *sb)
}
while ((i = getc(cff)) != EOF) {
if (i == '\n')
- sbuf_printf(sb, "\\n\\\n");
+ cfg << "\\n\\\n";
else if (i == '"' || i == '\'')
- sbuf_printf(sb, "\\%c", i);
+ cfg << '\\' << i;
else
- sbuf_putc(sb, i);
+ cfg << i;
}
fclose(cff);
}
@@ -549,7 +532,7 @@ static void
configfile(void)
{
FILE *fo;
- struct sbuf *sb;
+ std::ostringstream cfg;
char *p;
/* Add main configuration file to the list of files to be included */
@@ -558,16 +541,16 @@ configfile(void)
fo = fopen(p, "w");
if (!fo)
err(2, "%s", p);
- sb = sbuf_new(NULL, NULL, 2048, SBUF_AUTOEXTEND);
- assert(sb != NULL);
- sbuf_clear(sb);
+ free(p);
+
if (filebased) {
/* Is needed, can be used for backward compatibility. */
- configfile_filebased(sb);
+ configfile_filebased(cfg);
} else {
- configfile_dynamic(sb);
+ configfile_dynamic(cfg);
}
- sbuf_finish(sb);
+
+ cfg.flush();
/*
* We print first part of the template, replace our tag with
* configuration files content and later continue writing our
@@ -578,12 +561,11 @@ configfile(void)
errx(EXIT_FAILURE, "Something went terribly wrong!");
*p = '\0';
fprintf(fo, "%s", kernconfstr);
- fprintf(fo, "%s", sbuf_data(sb));
+ fprintf(fo, "%s", cfg.str().c_str());
p += strlen(KERNCONFTAG);
fprintf(fo, "%s", p);
- sbuf_delete(sb);
fclose(fo);
- moveifchanged(path("config.c.new"), path("config.c"));
+ moveifchanged("config.c.new", "config.c");
cfgfile_removeall();
}
@@ -595,6 +577,7 @@ void
moveifchanged(const char *from_name, const char *to_name)
{
char *p, *q;
+ char *from_path, *to_path;
int changed;
size_t tsize;
struct stat from_sb, to_sb;
@@ -602,42 +585,54 @@ moveifchanged(const char *from_name, const char *to_name)
changed = 0;
- if ((from_fd = open(from_name, O_RDONLY)) < 0)
+ from_path = path(from_name);
+ to_path = path(to_name);
+ if ((from_fd = open(from_path, O_RDONLY)) < 0)
err(EX_OSERR, "moveifchanged open(%s)", from_name);
- if ((to_fd = open(to_name, O_RDONLY)) < 0)
+ if ((to_fd = open(to_path, O_RDONLY)) < 0)
changed++;
if (!changed && fstat(from_fd, &from_sb) < 0)
- err(EX_OSERR, "moveifchanged fstat(%s)", from_name);
+ err(EX_OSERR, "moveifchanged fstat(%s)", from_path);
if (!changed && fstat(to_fd, &to_sb) < 0)
- err(EX_OSERR, "moveifchanged fstat(%s)", to_name);
+ err(EX_OSERR, "moveifchanged fstat(%s)", to_path);
if (!changed && from_sb.st_size != to_sb.st_size)
changed++;
- tsize = (size_t)from_sb.st_size;
-
if (!changed) {
- p = mmap(NULL, tsize, PROT_READ, MAP_SHARED, from_fd, (off_t)0);
+ tsize = (size_t)from_sb.st_size;
+
+ p = (char *)mmap(NULL, tsize, PROT_READ, MAP_SHARED, from_fd,
+ (off_t)0);
if (p == MAP_FAILED)
- err(EX_OSERR, "mmap %s", from_name);
- q = mmap(NULL, tsize, PROT_READ, MAP_SHARED, to_fd, (off_t)0);
+ err(EX_OSERR, "mmap %s", from_path);
+ q = (char *)mmap(NULL, tsize, PROT_READ, MAP_SHARED, to_fd,
+ (off_t)0);
if (q == MAP_FAILED)
- err(EX_OSERR, "mmap %s", to_name);
+ err(EX_OSERR, "mmap %s", to_path);
changed = memcmp(p, q, tsize);
munmap(p, tsize);
munmap(q, tsize);
}
+
if (changed) {
- if (rename(from_name, to_name) < 0)
- err(EX_OSERR, "rename(%s, %s)", from_name, to_name);
+ if (rename(from_path, to_path) < 0)
+ err(EX_OSERR, "rename(%s, %s)", from_path, to_path);
} else {
- if (unlink(from_name) < 0)
- err(EX_OSERR, "unlink(%s)", from_name);
+ if (unlink(from_path) < 0)
+ err(EX_OSERR, "unlink(%s)", from_path);
}
+
+ close(from_fd);
+ if (to_fd >= 0)
+ close(to_fd);
+
+ free(from_path);
+ free(to_path);
}
static void
@@ -679,8 +674,10 @@ cleanheaders(char *p)
if (hl)
continue;
printf("Removing stale header: %s\n", dp->d_name);
- if (unlink(path(dp->d_name)) == -1)
+ p = path(dp->d_name);
+ if (unlink(p) == -1)
warn("unlink %s", dp->d_name);
+ free(p);
}
(void)closedir(dirp);
}
@@ -688,7 +685,7 @@ cleanheaders(char *p)
void
remember(const char *file)
{
- char *s;
+ const char *s;
struct hdr_list *hl;
if ((s = strrchr(file, '/')) != NULL)
@@ -697,16 +694,16 @@ remember(const char *file)
s = ns(file);
if (strchr(s, '_') && strncmp(s, "opt_", 4) != 0) {
- free(s);
+ free(__DECONST(char *, s));
return;
}
for (hl = htab; hl != NULL; hl = hl->h_next) {
if (eq(s, hl->h_name)) {
- free(s);
+ free(__DECONST(char *, s));
return;
}
}
- hl = calloc(1, sizeof(*hl));
+ hl = (struct hdr_list *)calloc(1, sizeof(*hl));
if (hl == NULL)
err(EXIT_FAILURE, "calloc");
hl->h_name = s;
@@ -725,7 +722,7 @@ kernconfdump(const char *file)
struct stat st;
FILE *fp, *pp;
int error, osz, r;
- unsigned int i, off, size, t1, t2, align;
+ size_t i, off, size, t1, t2, align;
char *cmd, *o;
r = open(file, O_RDONLY);
@@ -740,7 +737,7 @@ kernconfdump(const char *file)
if (fp == NULL)
err(EXIT_FAILURE, "fdopen() failed");
osz = 1024;
- o = calloc(1, osz);
+ o = (char *)calloc(1, osz);
if (o == NULL)
err(EXIT_FAILURE, "Couldn't allocate memory");
/* ELF note section header. */
@@ -754,8 +751,10 @@ kernconfdump(const char *file)
free(cmd);
(void)fread(o, osz, 1, pp);
pclose(pp);
- r = sscanf(o, "%d%d%d%d%d", &off, &size, &t1, &t2, &align);
+ r = sscanf(o, "%zu%zu%zu%zu%zu", &off, &size, &t1, &t2, &align);
free(o);
+ if (size > SIZE_MAX - off || off + size > (size_t)st.st_size)
+ errx(EXIT_FAILURE, "%s: incoherent ELF headers", file);
if (r != 5)
errx(EXIT_FAILURE, "File %s doesn't contain configuration "
"file. Either unsupported, or not compiled with "
diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c
index 5dfde12c1db8..8ff81072c5d7 100644
--- a/usr.sbin/config/mkheaders.c
+++ b/usr.sbin/config/mkheaders.c
@@ -29,14 +29,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mkheaders.c 8.1 (Berkeley) 6/6/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
/*
* This used to generate a bunch of headers files related to devices when
* device counters were supported. Support for that was removed in 2005.
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.cc
index 4f3bd13ffca3..060f08230550 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.cc
@@ -29,33 +29,29 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mkmakefile.c 8.1 (Berkeley) 6/6/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
/*
* Build the makefile for the system, from
* the information in the files files and the
* additional files for the machine being compiled to.
*/
+#include <sys/param.h>
+#include <cerrno>
#include <ctype.h>
#include <err.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
-#include <sys/cnv.h>
-#include <sys/nv.h>
-#include <sys/param.h>
+#include <string>
+#include <unordered_map>
+
#include "y.tab.h"
#include "config.h"
#include "configvers.h"
+typedef std::unordered_map<std::string, std::string> env_map;
+
static char *tail(char *);
static void do_clean(FILE *);
static void do_rules(FILE *);
@@ -66,10 +62,11 @@ static void read_files(void);
static void sanitize_envline(char *result, const char *src);
static bool preprocess(char *line, char *result);
static void process_into_file(char *line, FILE *ofp);
-static void process_into_nvlist(char *line, nvlist_t *nvl);
-static void dump_nvlist(nvlist_t *nvl, FILE *ofp);
+static int process_into_map(char *line, env_map &emap);
+static void dump_map(env_map &emap, FILE *ofp);
-static void errout(const char *fmt, ...)
+static void __printflike(1, 2)
+errout(const char *fmt, ...)
{
va_list ap;
@@ -181,7 +178,7 @@ makefile(void)
}
(void) fclose(ifp);
(void) fclose(ofp);
- moveifchanged(path("Makefile.new"), path("Makefile"));
+ moveifchanged("Makefile.new", "Makefile");
}
static void
@@ -266,36 +263,29 @@ process_into_file(char *line, FILE *ofp)
fprintf(ofp, "\"%s\\0\"\n", result);
}
-static void
-process_into_nvlist(char *line, nvlist_t *nvl)
+static int
+process_into_map(char *line, env_map &emap)
{
char result[BUFSIZ], *s;
if (preprocess(line, result)) {
s = strchr(result, '=');
+ if (s == NULL)
+ return (EINVAL);
*s = '\0';
- if (nvlist_exists(nvl, result))
- nvlist_free(nvl, result);
- nvlist_add_string(nvl, result, s + 1);
+ emap[result] = s + 1;
}
+
+ return (0);
}
static void
-dump_nvlist(nvlist_t *nvl, FILE *ofp)
+dump_map(env_map &emap, FILE *ofp)
{
- const char *name;
- void *cookie;
-
- if (nvl == NULL)
- return;
- while (!nvlist_empty(nvl)) {
- cookie = NULL;
- name = nvlist_next(nvl, NULL, &cookie);
- fprintf(ofp, "\"%s=%s\\0\"\n", name,
- cnvlist_get_string(cookie));
-
- cnvlist_free_string(cookie);
+ for (auto iter : emap) {
+ fprintf(ofp, "\"%s=%s\\0\"\n", iter.first.c_str(),
+ iter.second.c_str());
}
}
@@ -306,7 +296,7 @@ void
makehints(void)
{
FILE *ifp, *ofp;
- nvlist_t *nvl;
+ env_map emap;
char line[BUFSIZ];
struct hint *hint;
@@ -324,20 +314,21 @@ makehints(void)
fprintf(ofp, "int hintmode = %d;\n",
!STAILQ_EMPTY(&hints) ? 1 : 0);
fprintf(ofp, "char static_hints[] = {\n");
- nvl = nvlist_create(0);
STAILQ_FOREACH(hint, &hints, hint_next) {
ifp = fopen(hint->hint_name, "r");
if (ifp == NULL)
err(1, "%s", hint->hint_name);
- while (fgets(line, BUFSIZ, ifp) != NULL)
- process_into_nvlist(line, nvl);
- dump_nvlist(nvl, ofp);
+ while (fgets(line, BUFSIZ, ifp) != NULL) {
+ if (process_into_map(line, emap) != 0)
+ errout("%s: malformed line: %s\n",
+ hint->hint_name, line);
+ }
+ dump_map(emap, ofp);
fclose(ifp);
}
- nvlist_destroy(nvl);
fprintf(ofp, "\"\\0\"\n};\n");
fclose(ofp);
- moveifchanged(path("hints.c.new"), path("hints.c"));
+ moveifchanged("hints.c.new", "hints.c");
}
/*
@@ -347,7 +338,7 @@ void
makeenv(void)
{
FILE *ifp, *ofp;
- nvlist_t *nvl;
+ env_map emap;
char line[BUFSIZ];
struct envvar *envvar;
@@ -365,23 +356,24 @@ makeenv(void)
fprintf(ofp, "int envmode = %d;\n",
!STAILQ_EMPTY(&envvars) ? 1 : 0);
fprintf(ofp, "char static_env[] = {\n");
- nvl = nvlist_create(0);
STAILQ_FOREACH(envvar, &envvars, envvar_next) {
if (envvar->env_is_file) {
ifp = fopen(envvar->env_str, "r");
if (ifp == NULL)
err(1, "%s", envvar->env_str);
- while (fgets(line, BUFSIZ, ifp) != NULL)
- process_into_nvlist(line, nvl);
- dump_nvlist(nvl, ofp);
+ while (fgets(line, BUFSIZ, ifp) != NULL) {
+ if (process_into_map(line, emap) != 0)
+ errout("%s: malformed line: %s\n",
+ envvar->env_str, line);
+ }
+ dump_map(emap, ofp);
fclose(ifp);
} else
process_into_file(envvar->env_str, ofp);
}
- nvlist_destroy(nvl);
fprintf(ofp, "\"\\0\"\n};\n");
fclose(ofp);
- moveifchanged(path("env.c.new"), path("env.c"));
+ moveifchanged("env.c.new", "env.c");
}
static void
@@ -392,9 +384,10 @@ read_file(char *fname)
struct file_list *tp;
struct device *dp;
struct opt *op;
- char *wd, *this, *compilewith, *depends, *clean, *warning;
+ configword wd;
+ char *rfile, *compilewith, *depends, *clean, *warning;
const char *objprefix;
- int compile, match, nreqs, std, filetype, not,
+ int compile, match, nreqs, std, filetype, negate,
imp_rule, no_ctfconvert, no_obj, before_depend, nowerror;
fp = fopen(fname, "r");
@@ -412,35 +405,36 @@ next:
* [ nowerror ] [ local ]
*/
wd = get_word(fp);
- if (wd == (char *)EOF) {
+ if (wd.eof()) {
(void) fclose(fp);
return;
}
- if (wd == NULL)
+ if (wd.eol())
goto next;
if (wd[0] == '#')
{
- while (((wd = get_word(fp)) != (char *)EOF) && wd)
+ while (!(wd = get_word(fp)).eof() && !wd.eol())
;
goto next;
}
if (eq(wd, "include")) {
wd = get_quoted_word(fp);
- if (wd == (char *)EOF || wd == NULL)
+ if (wd.eof() || wd.eol())
errout("%s: missing include filename.\n", fname);
- (void) snprintf(ifname, sizeof(ifname), "../../%s", wd);
+ (void) snprintf(ifname, sizeof(ifname), "../../%s",
+ wd->c_str());
read_file(ifname);
- while (((wd = get_word(fp)) != (char *)EOF) && wd)
+ while (!(wd = get_word(fp)).eof() && !wd.eol())
;
goto next;
}
- this = ns(wd);
+ rfile = ns(wd);
wd = get_word(fp);
- if (wd == (char *)EOF)
+ if (wd.eof())
return;
- if (wd == NULL)
- errout("%s: No type for %s.\n", fname, this);
- tp = fl_lookup(this);
+ if (wd.eol())
+ errout("%s: No type for %s.\n", fname, rfile);
+ tp = fl_lookup(rfile);
compile = 0;
match = 1;
nreqs = 0;
@@ -454,25 +448,25 @@ next:
no_obj = 0;
before_depend = 0;
nowerror = 0;
- not = 0;
+ negate = 0;
filetype = NORMAL;
objprefix = "";
if (eq(wd, "standard"))
std = 1;
else if (!eq(wd, "optional"))
errout("%s: \"%s\" %s must be optional or standard\n",
- fname, wd, this);
- for (wd = get_word(fp); wd; wd = get_word(fp)) {
- if (wd == (char *)EOF)
+ fname, wd->c_str(), rfile);
+ for (wd = get_word(fp); !wd.eol(); wd = get_word(fp)) {
+ if (wd.eof())
return;
if (eq(wd, "!")) {
- not = 1;
+ negate = 1;
continue;
}
if (eq(wd, "|")) {
if (nreqs == 0)
errout("%s: syntax error describing %s\n",
- fname, this);
+ fname, rfile);
compile += match;
match = 1;
nreqs = 0;
@@ -491,7 +485,7 @@ next:
errout("%s: alternate rule required when "
"\"no-implicit-rule\" is specified for"
" %s.\n",
- fname, this);
+ fname, rfile);
imp_rule++;
continue;
}
@@ -501,41 +495,41 @@ next:
}
if (eq(wd, "dependency")) {
wd = get_quoted_word(fp);
- if (wd == (char *)EOF || wd == NULL)
+ if (wd.eof() || wd.eol())
errout("%s: %s missing dependency string.\n",
- fname, this);
+ fname, rfile);
depends = ns(wd);
continue;
}
if (eq(wd, "clean")) {
wd = get_quoted_word(fp);
- if (wd == (char *)EOF || wd == NULL)
+ if (wd.eof() || wd.eol())
errout("%s: %s missing clean file list.\n",
- fname, this);
+ fname, rfile);
clean = ns(wd);
continue;
}
if (eq(wd, "compile-with")) {
wd = get_quoted_word(fp);
- if (wd == (char *)EOF || wd == NULL)
+ if (wd.eof() || wd.eol())
errout("%s: %s missing compile command string.\n",
- fname, this);
+ fname, rfile);
compilewith = ns(wd);
continue;
}
if (eq(wd, "warning")) {
wd = get_quoted_word(fp);
- if (wd == (char *)EOF || wd == NULL)
+ if (wd.eof() || wd.eol())
errout("%s: %s missing warning text string.\n",
- fname, this);
+ fname, rfile);
warning = ns(wd);
continue;
}
if (eq(wd, "obj-prefix")) {
wd = get_quoted_word(fp);
- if (wd == (char *)EOF || wd == NULL)
+ if (wd.eof() || wd.eol())
errout("%s: %s missing object prefix string.\n",
- fname, this);
+ fname, rfile);
objprefix = ns(wd);
continue;
}
@@ -554,10 +548,10 @@ next:
nreqs++;
if (std)
errout("standard entry %s has optional inclusion specifier %s!\n",
- this, wd);
+ rfile, wd->c_str());
STAILQ_FOREACH(dp, &dtab, d_next)
if (eq(dp->d_name, wd)) {
- if (not)
+ if (negate)
match = 0;
else
dp->d_done |= DEVDONE;
@@ -566,21 +560,21 @@ next:
SLIST_FOREACH(op, &opt, op_next)
if (op->op_value == 0 &&
strcasecmp(op->op_name, wd) == 0) {
- if (not)
+ if (negate)
match = 0;
goto nextparam;
}
- match &= not;
+ match &= negate;
nextparam:;
- not = 0;
+ negate = 0;
}
compile += match;
if (compile && tp == NULL) {
if (std == 0 && nreqs == 0)
errout("%s: what is %s optional on?\n",
- fname, this);
+ fname, rfile);
tp = new_fent();
- tp->f_fn = this;
+ tp->f_fn = rfile;
tp->f_type = filetype;
if (filetype == LOCAL)
tp->f_srcprefix = "";
diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.cc
index bf611cdb12c3..1580700dc08d 100644
--- a/usr.sbin/config/mkoptions.c
+++ b/usr.sbin/config/mkoptions.cc
@@ -30,14 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mkheaders.c 8.1 (Berkeley) 6/6/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
/*
* Make all the .h files for the optional entries
*/
@@ -141,7 +133,7 @@ options(void)
static void
do_option(char *name)
{
- char *file, *inw;
+ char *file;
const char *basefile;
struct opt_list *ol;
struct opt *op;
@@ -198,18 +190,17 @@ do_option(char *name)
seen = 0;
tidy = 0;
for (;;) {
- char *cp;
+ configword cp, inw;
char *invalue;
/* get the #define */
- if ((inw = get_word(inf)) == NULL || inw == (char *)EOF)
+ if ((inw = get_word(inf)).eol() || inw.eof())
break;
/* get the option name */
- if ((inw = get_word(inf)) == NULL || inw == (char *)EOF)
+ if ((inw = get_word(inf)).eol() || inw.eof())
break;
- inw = ns(inw);
/* get the option value */
- if ((cp = get_word(inf)) == NULL || cp == (char *)EOF)
+ if ((cp = get_word(inf)).eol() || cp.eof())
break;
/* option value */
invalue = ns(cp); /* malloced */
@@ -224,25 +215,25 @@ do_option(char *name)
if (!eq(inw, name) && !ol) {
fprintf(stderr,
"WARNING: unknown option `%s' removed from %s\n",
- inw, file);
+ inw->c_str(), file);
tidy++;
} else if (ol != NULL && !eq(basefile, ol->o_file)) {
fprintf(stderr,
"WARNING: option `%s' moved from %s to %s\n",
- inw, basefile, ol->o_file);
+ inw->c_str(), basefile, ol->o_file);
tidy++;
} else {
op = (struct opt *) calloc(1, sizeof *op);
if (op == NULL)
err(EXIT_FAILURE, "calloc");
- op->op_name = inw;
+ op->op_name = ns(inw);
op->op_value = invalue;
SLIST_INSERT_HEAD(&op_head, op, op_next);
}
/* EOL? */
cp = get_word(inf);
- if (cp == (char *)EOF)
+ if (cp.eof())
break;
}
(void)fclose(inf);
@@ -264,7 +255,7 @@ do_option(char *name)
if (op == NULL)
err(EXIT_FAILURE, "calloc");
op->op_name = ns(name);
- op->op_value = value ? ns(value) : NULL;
+ op->op_value = ns(value);
SLIST_INSERT_HEAD(&op_head, op, op_next);
}
@@ -295,6 +286,7 @@ tooption(char *name)
static char hbuf[MAXPATHLEN];
char nbuf[MAXPATHLEN];
struct opt_list *po;
+ char *fpath;
/* "cannot happen"? the otab list should be complete.. */
(void)strlcpy(nbuf, "options.h", sizeof(nbuf));
@@ -306,47 +298,49 @@ tooption(char *name)
}
}
- (void)strlcpy(hbuf, path(nbuf), sizeof(hbuf));
+ fpath = path(nbuf);
+ (void)strlcpy(hbuf, fpath, sizeof(hbuf));
+ free(fpath);
return (hbuf);
}
static void
-check_duplicate(const char *fname, const char *this)
+check_duplicate(const char *fname, const char *chkopt)
{
struct opt_list *po;
SLIST_FOREACH(po, &otab, o_next) {
- if (eq(po->o_name, this)) {
+ if (eq(po->o_name, chkopt)) {
fprintf(stderr, "%s: Duplicate option %s.\n",
- fname, this);
+ fname, chkopt);
exit(1);
}
}
}
static void
-insert_option(const char *fname, char *this, char *val)
+insert_option(const char *fname, char *optname, char *val)
{
struct opt_list *po;
- check_duplicate(fname, this);
+ check_duplicate(fname, optname);
po = (struct opt_list *) calloc(1, sizeof *po);
if (po == NULL)
err(EXIT_FAILURE, "calloc");
- po->o_name = this;
+ po->o_name = optname;
po->o_file = val;
po->o_flags = 0;
SLIST_INSERT_HEAD(&otab, po, o_next);
}
static void
-update_option(const char *this, char *val, int flags)
+update_option(const char *optname, char *val, int flags)
{
struct opt_list *po;
SLIST_FOREACH(po, &otab, o_next) {
- if (eq(po->o_name, this)) {
+ if (eq(po->o_name, optname)) {
free(po->o_file);
po->o_file = val;
po->o_flags = flags;
@@ -364,41 +358,53 @@ static int
read_option_file(const char *fname, int flags)
{
FILE *fp;
- char *wd, *this, *val;
+ configword wd;
+ char *optname, *val;
char genopt[MAXPATHLEN];
fp = fopen(fname, "r");
if (fp == NULL)
return (0);
- while ((wd = get_word(fp)) != (char *)EOF) {
- if (wd == NULL)
+ while (!(wd = get_word(fp)).eof()) {
+ if (wd.eol())
continue;
if (wd[0] == '#') {
- while (((wd = get_word(fp)) != (char *)EOF) && wd)
+ while (!(wd = get_word(fp)).eof() && !wd.eol())
continue;
continue;
}
- this = ns(wd);
- val = get_word(fp);
- if (val == (char *)EOF)
- return (1);
- if (val == NULL) {
+ optname = ns(wd);
+ wd = get_word(fp);
+ if (wd.eof()) {
+ free(optname);
+ break;
+ }
+ if (wd.eol()) {
if (flags) {
fprintf(stderr, "%s: compat file requires two"
- " words per line at %s\n", fname, this);
+ " words per line at %s\n", fname, optname);
exit(1);
}
- char *s = ns(this);
+ char *s = ns(optname);
(void)snprintf(genopt, sizeof(genopt), "opt_%s.h",
lower(s));
- val = genopt;
+ val = ns(genopt);
free(s);
+ } else {
+ val = ns(wd);
+ }
+
+ if (flags == 0) {
+ /*
+ * insert_option takes possession of `optname` in the
+ * new option instead of making yet another copy.
+ */
+ insert_option(fname, optname, val);
+ } else {
+ update_option(optname, val, flags);
+ free(optname);
+ optname = NULL;
}
- val = ns(val);
- if (flags == 0)
- insert_option(fname, this, val);
- else
- update_option(this, val, flags);
}
(void)fclose(fp);
return (1);
diff --git a/usr.sbin/cpucontrol/Makefile b/usr.sbin/cpucontrol/Makefile
index df84f7082e87..a468ca59b461 100644
--- a/usr.sbin/cpucontrol/Makefile
+++ b/usr.sbin/cpucontrol/Makefile
@@ -1,9 +1,12 @@
-# $FreeBSD$
PROG= cpucontrol
MAN= cpucontrol.8
-SRCS= cpucontrol.c intel.c amd.c amd10h.c via.c
+SRCS= cpucontrol.c intel.c amd.c amd10h.c via.c ucode_subr.c
+
+.PATH: ${SRCTOP}/sys/x86/x86
NO_WCAST_ALIGN=
+CFLAGS+= -I${.CURDIR}
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/cpucontrol/Makefile.depend b/usr.sbin/cpucontrol/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/cpucontrol/Makefile.depend
+++ b/usr.sbin/cpucontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/cpucontrol/amd.c b/usr.sbin/cpucontrol/amd.c
index 9191f261564b..21a3389ced2f 100644
--- a/usr.sbin/cpucontrol/amd.c
+++ b/usr.sbin/cpucontrol/amd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006, 2008 Stanislav Sedov <stas@FreeBSD.org>.
* All rights reserved.
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.sbin/cpucontrol/amd.h b/usr.sbin/cpucontrol/amd.h
index dd836874ab3d..8e4efe60dca6 100644
--- a/usr.sbin/cpucontrol/amd.h
+++ b/usr.sbin/cpucontrol/amd.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006, 2008 Stanislav Sedov <stas@FreeBSD.org>.
* All rights reserved.
@@ -23,8 +23,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$
*/
#ifndef AMD_H
@@ -50,45 +48,4 @@ typedef struct amd_fw_header {
#define AMD_MAGIC 0xaaaaaa
-/*
- * AMD family 10h and later.
- */
-typedef struct amd_10h_fw_header {
- uint32_t data_code;
- uint32_t patch_id;
- uint16_t mc_patch_data_id;
- uint8_t mc_patch_data_len;
- uint8_t init_flag;
- uint32_t mc_patch_data_checksum;
- uint32_t nb_dev_id;
- uint32_t sb_dev_id;
- uint16_t processor_rev_id;
- uint8_t nb_rev_id;
- uint8_t sb_rev_id;
- uint8_t bios_api_rev;
- uint8_t reserved1[3];
- uint32_t match_reg[8];
-} amd_10h_fw_header_t;
-
-typedef struct equiv_cpu_entry {
- uint32_t installed_cpu;
- uint32_t fixed_errata_mask;
- uint32_t fixed_errata_compare;
- uint16_t equiv_cpu;
- uint16_t res;
-} equiv_cpu_entry_t;
-
-typedef struct section_header {
- uint32_t type;
- uint32_t size;
-} section_header_t;
-
-typedef struct container_header {
- uint32_t magic;
-} container_header_t;
-
-#define AMD_10H_MAGIC 0x414d44
-#define AMD_10H_EQUIV_TABLE_TYPE 0
-#define AMD_10H_uCODE_TYPE 1
-
#endif /* !AMD_H */
diff --git a/usr.sbin/cpucontrol/amd10h.c b/usr.sbin/cpucontrol/amd10h.c
index 5d3c4a1ac003..4fda44f0b797 100644
--- a/usr.sbin/cpucontrol/amd10h.c
+++ b/usr.sbin/cpucontrol/amd10h.c
@@ -23,9 +23,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
@@ -36,6 +33,8 @@ __FBSDID("$FreeBSD$");
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
+#include <x86/ucode.h>
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -82,33 +81,21 @@ amd10h_probe(int fd)
return (0);
}
-/*
- * NB: the format of microcode update files is not documented by AMD.
- * It has been reverse engineered from studying Coreboot, illumos and Linux
- * source code.
- */
void
amd10h_update(const struct ucode_update_params *params)
{
cpuctl_cpuid_args_t idargs;
cpuctl_msr_args_t msrargs;
cpuctl_update_args_t args;
- const amd_10h_fw_header_t *fw_header;
- const amd_10h_fw_header_t *selected_fw;
- const equiv_cpu_entry_t *equiv_cpu_table;
- const section_header_t *section_header;
- const container_header_t *container_header;
- const uint8_t *fw_data;
const uint8_t *fw_image;
const char *dev, *path;
+ const void *selected_fw;
size_t fw_size;
size_t selected_size;
uint32_t revision;
uint32_t new_rev;
uint32_t signature;
- uint16_t equiv_id;
int devfd;
- unsigned int i;
int error;
dev = params->dev_path;
@@ -136,129 +123,8 @@ amd10h_update(const struct ucode_update_params *params)
}
revision = (uint32_t)msrargs.data;
- WARNX(1, "found cpu family %#x model %#x "
- "stepping %#x extfamily %#x extmodel %#x.",
- ((signature >> 8) & 0x0f) + ((signature >> 20) & 0xff),
- (signature >> 4) & 0x0f,
- (signature >> 0) & 0x0f, (signature >> 20) & 0xff,
- (signature >> 16) & 0x0f);
- WARNX(1, "microcode revision %#x", revision);
-
- /*
- * Open the firmware file.
- */
- WARNX(1, "checking %s for update.", path);
- if (fw_size <
- (sizeof(*container_header) + sizeof(*section_header))) {
- WARNX(2, "file too short: %s", path);
- goto done;
- }
-
- /*
- * mmap the whole image.
- */
- fw_data = fw_image;
- container_header = (const container_header_t *)fw_data;
- if (container_header->magic != AMD_10H_MAGIC) {
- WARNX(2, "%s is not a valid amd firmware: bad magic", path);
- goto done;
- }
- fw_data += sizeof(*container_header);
- fw_size -= sizeof(*container_header);
-
- section_header = (const section_header_t *)fw_data;
- if (section_header->type != AMD_10H_EQUIV_TABLE_TYPE) {
- WARNX(2, "%s is not a valid amd firmware: "
- "first section is not CPU equivalence table", path);
- goto done;
- }
- if (section_header->size == 0) {
- WARNX(2, "%s is not a valid amd firmware: "
- "first section is empty", path);
- goto done;
- }
- fw_data += sizeof(*section_header);
- fw_size -= sizeof(*section_header);
-
- if (section_header->size > fw_size) {
- WARNX(2, "%s is not a valid amd firmware: "
- "file is truncated", path);
- goto done;
- }
- if (section_header->size < sizeof(*equiv_cpu_table)) {
- WARNX(2, "%s is not a valid amd firmware: "
- "first section is too short", path);
- goto done;
- }
- equiv_cpu_table = (const equiv_cpu_entry_t *)fw_data;
- fw_data += section_header->size;
- fw_size -= section_header->size;
-
- equiv_id = 0;
- for (i = 0; equiv_cpu_table[i].installed_cpu != 0; i++) {
- if (signature == equiv_cpu_table[i].installed_cpu) {
- equiv_id = equiv_cpu_table[i].equiv_cpu;
- WARNX(3, "equiv_id: %x, signature %8x,"
- " equiv_cpu_table[%d] %8x", equiv_id, signature,
- i, equiv_cpu_table[i].installed_cpu);
- break;
- }
- }
- if (equiv_id == 0) {
- WARNX(2, "CPU is not found in the equivalence table");
- goto done;
- }
-
- selected_fw = NULL;
- selected_size = 0;
- while (fw_size >= sizeof(*section_header)) {
- section_header = (const section_header_t *)fw_data;
- fw_data += sizeof(*section_header);
- fw_size -= sizeof(*section_header);
- if (section_header->type != AMD_10H_uCODE_TYPE) {
- WARNX(2, "%s is not a valid amd firmware: "
- "section has incorrect type", path);
- goto done;
- }
- if (section_header->size > fw_size) {
- WARNX(2, "%s is not a valid amd firmware: "
- "file is truncated", path);
- goto done;
- }
- if (section_header->size < sizeof(*fw_header)) {
- WARNX(2, "%s is not a valid amd firmware: "
- "section is too short", path);
- goto done;
- }
- fw_header = (const amd_10h_fw_header_t *)fw_data;
- fw_data += section_header->size;
- fw_size -= section_header->size;
-
- if (fw_header->processor_rev_id != equiv_id) {
- WARNX(1, "firmware processor_rev_id %x, equiv_id %x",
- fw_header->processor_rev_id, equiv_id);
- continue; /* different cpu */
- }
- if (fw_header->patch_id <= revision) {
- WARNX(1, "patch_id %x, revision %x",
- fw_header->patch_id, revision);
- continue; /* not newer revision */
- }
- if (fw_header->nb_dev_id != 0 || fw_header->sb_dev_id != 0) {
- WARNX(2, "Chipset-specific microcode is not supported");
- }
-
- WARNX(3, "selecting revision: %x", fw_header->patch_id);
- revision = fw_header->patch_id;
- selected_fw = fw_header;
- selected_size = section_header->size;
- }
-
- if (fw_size != 0) {
- WARNX(2, "%s is not a valid amd firmware: "
- "file is truncated", path);
- goto done;
- }
+ selected_fw = ucode_amd_find(path, signature, revision, fw_image,
+ fw_size, &selected_size);
if (selected_fw != NULL) {
WARNX(1, "selected ucode size is %zu", selected_size);
diff --git a/usr.sbin/cpucontrol/cpucontrol.8 b/usr.sbin/cpucontrol/cpucontrol.8
index e347d5e49bfe..6f99224bd3a3 100644
--- a/usr.sbin/cpucontrol/cpucontrol.8
+++ b/usr.sbin/cpucontrol/cpucontrol.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 5, 2018
.Dt CPUCONTROL 8
.Os
diff --git a/usr.sbin/cpucontrol/cpucontrol.c b/usr.sbin/cpucontrol/cpucontrol.c
index 09948cc95d6c..9cc3968de01d 100644
--- a/usr.sbin/cpucontrol/cpucontrol.c
+++ b/usr.sbin/cpucontrol/cpucontrol.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008-2011 Stanislav Sedov <stas@FreeBSD.org>.
* All rights reserved.
@@ -31,8 +31,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <err.h>
#include <errno.h>
diff --git a/usr.sbin/cpucontrol/cpucontrol.h b/usr.sbin/cpucontrol/cpucontrol.h
index 8620d5ade19d..a4b3a94c19e6 100644
--- a/usr.sbin/cpucontrol/cpucontrol.h
+++ b/usr.sbin/cpucontrol/cpucontrol.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Stanislav Sedov <stas@FreeBSD.org>.
* All rights reserved.
@@ -23,8 +23,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$
*/
#ifndef CPUCONTROL_H
diff --git a/usr.sbin/cpucontrol/intel.c b/usr.sbin/cpucontrol/intel.c
index f4700898d5eb..d775d66d33aa 100644
--- a/usr.sbin/cpucontrol/intel.c
+++ b/usr.sbin/cpucontrol/intel.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006, 2008 Stanislav Sedov <stas@FreeBSD.org>.
* All rights reserved.
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.sbin/cpucontrol/intel.h b/usr.sbin/cpucontrol/intel.h
index a30fc505cb0b..7aa58b333de4 100644
--- a/usr.sbin/cpucontrol/intel.h
+++ b/usr.sbin/cpucontrol/intel.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006, 2008 Stanislav Sedov <stas@FreeBSD.org>.
* All rights reserved.
@@ -23,8 +23,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$
*/
#ifndef INTEL_H
diff --git a/usr.sbin/cpucontrol/via.c b/usr.sbin/cpucontrol/via.c
index b03790a0b4df..432399c69e35 100644
--- a/usr.sbin/cpucontrol/via.c
+++ b/usr.sbin/cpucontrol/via.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Fabien Thomas <fabient@FreeBSD.org>.
* All rights reserved.
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.sbin/cpucontrol/via.h b/usr.sbin/cpucontrol/via.h
index 4427ff3885e1..d2e5c82878b8 100644
--- a/usr.sbin/cpucontrol/via.h
+++ b/usr.sbin/cpucontrol/via.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Fabien Thomas <fabient@FreeBSD.org>.
* All rights reserved.
@@ -23,8 +23,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$
*/
#ifndef VIA_H
diff --git a/usr.sbin/crashinfo/Makefile b/usr.sbin/crashinfo/Makefile
index fa2a19c60c5f..f65bed154872 100644
--- a/usr.sbin/crashinfo/Makefile
+++ b/usr.sbin/crashinfo/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SCRIPTS= crashinfo.sh
MAN= crashinfo.8
diff --git a/usr.sbin/crashinfo/Makefile.depend b/usr.sbin/crashinfo/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/crashinfo/Makefile.depend
+++ b/usr.sbin/crashinfo/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/crashinfo/crashinfo.8 b/usr.sbin/crashinfo/crashinfo.8
index 3915bb1b44e1..44e52d1663ef 100644
--- a/usr.sbin/crashinfo/crashinfo.8
+++ b/usr.sbin/crashinfo/crashinfo.8
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 2, 2020
.Dt CRASHINFO 8
.Os
@@ -78,7 +76,7 @@ it uses several utilities to analyze the core including
.Xr fstat 1 ,
.Xr iostat 8 ,
.Xr ipcs 1 ,
-.Xr kgdb 1 ,
+.Xr kgdb 1 Pq Pa ports/devel/gdb ,
.Xr netstat 1 ,
.Xr nfsstat 1 ,
.Xr ps 1 ,
diff --git a/usr.sbin/crashinfo/crashinfo.sh b/usr.sbin/crashinfo/crashinfo.sh
index 5c67a29bee73..3bb1e1456462 100755
--- a/usr.sbin/crashinfo/crashinfo.sh
+++ b/usr.sbin/crashinfo/crashinfo.sh
@@ -29,7 +29,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
usage()
{
@@ -45,19 +44,6 @@ cleanup()
[ -e $VMCORE ] && rm -f $VMCORE
}
-# Find a gdb binary to use and save the value in GDB.
-find_gdb()
-{
- local binary
-
- for binary in /usr/local/bin/gdb /usr/libexec/gdb; do
- if [ -x ${binary} ]; then
- GDB=${binary}
- return
- fi
- done
-}
-
# Run a single gdb command against a kernel file in batch mode.
# The kernel file is specified as the first argument and the command
# is given in the remaining arguments.
@@ -67,11 +53,7 @@ gdb_command()
k=$1 ; shift
- if [ ${GDB} = /usr/local/bin/gdb ]; then
- ${GDB} -batch -ex "$@" $k
- else
- echo -e "$@" | ${GDB} -x /dev/stdin -batch $k
- fi
+ ${GDB} -batch -ex "$@" $k
}
find_kernel()
@@ -174,8 +156,8 @@ if $BATCH; then
exec > $FILE 2>&1
fi
-find_gdb
-if [ -z "$GDB" ]; then
+GDB=/usr/local/bin/gdb
+if [ ! -x "$GDB" ]; then
echo "Unable to find a kernel debugger."
echo "Please install the devel/gdb port or gdb package."
exit 1
@@ -233,13 +215,15 @@ echo
sed -ne '/^ Panic String: /{s//panic: /;p;}' $INFO
echo
-# XXX: /bin/sh on 7.0+ is broken so we can't simply pipe the commands to
-# kgdb via stdin and have to use a temporary file instead.
file=`mktemp /tmp/crashinfo.XXXXXX`
if [ $? -eq 0 ]; then
- echo "bt" >> $file
+ scriptdir=/usr/libexec/kgdb
+
+ echo "bt -full" >> $file
+ echo "source ${scriptdir}/acttrace.py" >> $file
+ echo "acttrace" >> $file
echo "quit" >> $file
- ${GDB%gdb}kgdb $KERNEL $VMCORE < $file
+ ${GDB%gdb}kgdb -q $KERNEL $VMCORE < $file
rm -f $file
echo
fi
diff --git a/usr.sbin/cron/Makefile b/usr.sbin/cron/Makefile
index 62f853cd2673..e24c33cb1a80 100644
--- a/usr.sbin/cron/Makefile
+++ b/usr.sbin/cron/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= lib cron crontab
diff --git a/usr.sbin/cron/Makefile.inc b/usr.sbin/cron/Makefile.inc
index 265f86d1ed55..d3b5cbd3a79b 100644
--- a/usr.sbin/cron/Makefile.inc
+++ b/usr.sbin/cron/Makefile.inc
@@ -1,3 +1,2 @@
-# $FreeBSD$
.include "../Makefile.inc"
diff --git a/usr.sbin/cron/cron/Makefile b/usr.sbin/cron/cron/Makefile
index 87c6bab7b495..673ae49e01a1 100644
--- a/usr.sbin/cron/cron/Makefile
+++ b/usr.sbin/cron/cron/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
CONFS= crontab
PROG= cron
diff --git a/usr.sbin/cron/cron/Makefile.depend b/usr.sbin/cron/cron/Makefile.depend
index c4674852688f..474d85363f7c 100644
--- a/usr.sbin/cron/cron/Makefile.depend
+++ b/usr.sbin/cron/cron/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/cron/cron/compat.h b/usr.sbin/cron/cron/compat.h
deleted file mode 100644
index ba32a31b417e..000000000000
--- a/usr.sbin/cron/cron/compat.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright 1993,1994 by Paul Vixie
- * All rights reserved
- *
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
- *
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
- */
-
-/*
- * $FreeBSD$
- */
-
-#ifndef __P
-# ifdef __STDC__
-# define __P(x) x
-# else
-# define __P(x) ()
-# define const
-# endif
-#endif
-
-#if defined(UNIXPC) || defined(unixpc)
-# define UNIXPC 1
-# define ATT 1
-#endif
-
-#if defined(hpux) || defined(_hpux) || defined(__hpux)
-# define HPUX 1
-# define seteuid(e) setresuid(-1,e,-1)
-# define setreuid(r,e) setresuid(r,e,-1)
-#endif
-
-#if defined(_IBMR2)
-# define AIX 1
-#endif
-
-#if defined(__convex__)
-# define CONVEX 1
-#endif
-
-#if defined(sgi) || defined(_sgi) || defined(__sgi)
-# define IRIX 1
-/* IRIX 4 hdrs are broken: one cannot #include both <stdio.h>
- * and <stdlib.h> because they disagree on system(), perror().
- * Therefore we must zap the "const" keyword BEFORE including
- * either of them.
- */
-# define const
-#endif
-
-#if defined(_UNICOS)
-# define UNICOS 1
-#endif
-
-#ifndef POSIX
-# if (BSD >= 199103) || defined(__linux) || defined(ultrix) || defined(AIX) ||\
- defined(HPUX) || defined(CONVEX) || defined(IRIX)
-# define POSIX
-# endif
-#endif
-
-#ifndef BSD
-# if defined(ultrix)
-# define BSD 198902
-# endif
-#endif
-
-/*****************************************************************/
-
-#if (!defined(BSD) || (BSD < 198902)) && !defined(__linux) && \
- !defined(IRIX) && !defined(NeXT) && !defined(HPUX)
-# define NEED_STRCASECMP
-#endif
-
-#if (!defined(BSD) || (BSD < 198911)) && !defined(__linux) &&\
- !defined(IRIX) && !defined(UNICOS) && !defined(HPUX)
-# define NEED_STRDUP
-#endif
-
-#if (!defined(BSD) || (BSD < 198911)) && !defined(POSIX) && !defined(NeXT)
-# define NEED_STRERROR
-#endif
-
-#if defined(HPUX) || defined(AIX) || defined(UNIXPC)
-# define NEED_FLOCK
-#endif
-
-#ifndef POSIX
-# define NEED_SETSID
-#endif
-
-#if (defined(POSIX) && !defined(BSD)) && !defined(__linux)
-# define NEED_GETDTABLESIZE
-#endif
-
-#ifdef POSIX
-#include <unistd.h>
-#ifdef _POSIX_SAVED_IDS
-# define HAVE_SAVED_UIDS
-#endif
-#endif
-
-#if !defined(ATT) && !defined(__linux) && !defined(IRIX) && !defined(UNICOS)
-# define USE_SIGCHLD
-#endif
-
-#if !defined(AIX) && !defined(UNICOS)
-# define SYS_TIME_H 1
-#else
-# define SYS_TIME_H 0
-#endif
-
-#if defined(BSD) && !defined(POSIX)
-# define USE_UTIMES
-#endif
-
-#if defined(AIX) || defined(HPUX) || defined(IRIX)
-# define NEED_SETENV
-#endif
-
-#if !defined(UNICOS) && !defined(UNIXPC)
-# define HAS_FCHOWN
-#endif
-
-#if !defined(UNICOS) && !defined(UNIXPC)
-# define HAS_FCHMOD
-#endif
diff --git a/usr.sbin/cron/cron/config.h b/usr.sbin/cron/cron/config.h
index 6d77da27580d..ea30c8def194 100644
--- a/usr.sbin/cron/cron/config.h
+++ b/usr.sbin/cron/cron/config.h
@@ -1,29 +1,29 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
/* config.h - configurables for Vixie Cron
*
- * $FreeBSD$
+ * $Id: config.h,v 1.2 1998/08/14 00:32:36 vixie Exp $
*/
-#if !defined(_PATH_SENDMAIL)
-# define _PATH_SENDMAIL "/usr/lib/sendmail"
-#endif /*SENDMAIL*/
-
/*
* these are site-dependent
*/
@@ -33,35 +33,35 @@
#endif
/*
- * choose one of these MAILCMD commands. I use
+ * choose one of these mailer commands. some use
* /bin/mail for speed; it makes biff bark but doesn't
- * do aliasing. /usr/lib/sendmail does aliasing but is
+ * do aliasing. sendmail does do aliasing but is
* a hog for short messages. aliasing is not needed
* if you make use of the MAILTO= feature in crontabs.
* (hint: MAILTO= was added for this reason).
*/
-#define MAILCMD _PATH_SENDMAIL /*-*/
-#define MAILARGS "%s -FCronDaemon -odi -oem -oi -t" /*-*/
+#define MAILFMT "%s -FCronDaemon -odi -oem -oi -t" /*-*/
/* -Fx = set full-name of sender
* -odi = Option Deliverymode Interactive
* -oem = Option Errors Mailedtosender
- * -oi = Option dot message terminator
- * -t = read recipients from header of message
+ * -or0s = Option Readtimeout -- don't time out
+ * -t = Get recipient from headers
*/
+#define MAILARG _PATH_SENDMAIL /*-*/
-/* #define MAILCMD "/bin/mail" */ /*-*/
-/* #define MAILARGS "%s -d %s" */ /*-*/
+/* #define MAILFMT "%s -d %s" */ /*-*/
/* -d = undocumented but common flag: deliver locally?
*/
+/* #define MAILARG "/bin/mail",mailto */
-/* #define MAILCMD "/usr/mmdf/bin/submit" */ /*-*/
-/* #define MAILARGS "%s -mlrxto %s" */ /*-*/
+/* #define MAILFMT "%s -mlrxto %s" */ /*-*/
+/* #define MAILARG "/usr/mmdf/bin/submit",mailto */ /*-*/
/* #define MAIL_DATE */ /*-*/
/* should we include an ersatz Date: header in
* generated mail? if you are using sendmail
- * for MAILCMD, it is better to let sendmail
+ * as the mailer, it is better to let sendmail
* generate the Date: header.
*/
@@ -69,7 +69,7 @@
* defined but neither exists, should crontab(1) be
* usable only by root?
*/
-/* #define ALLOW_ONLY_ROOT */ /*-*/
+/*#define ALLOW_ONLY_ROOT */ /*-*/
/* if you want to use syslog(3) instead of appending
* to CRONDIR/LOG_FILE (/var/cron/log, e.g.), define
diff --git a/usr.sbin/cron/cron/cron.8 b/usr.sbin/cron/cron/cron.8
index 15e930439564..782bbce2fb6e 100644
--- a/usr.sbin/cron/cron/cron.8
+++ b/usr.sbin/cron/cron/cron.8
@@ -1,21 +1,23 @@
-.\"/* Copyright 1988,1990,1993 by Paul Vixie
+.\"/* Copyright 1988,1990,1993,1996 by Paul Vixie
.\" * All rights reserved
-.\" *
-.\" * Distribute freely, except: don't remove my name from the source or
-.\" * documentation (don't take credit for my work), mark your changes (don't
-.\" * get me blamed for your possible bugs), don't alter or remove this
-.\" * notice. May be sold if buildable source is provided to buyer. No
-.\" * warrantee of any kind, express or implied, is included with this
-.\" * software; use at your own risk, responsibility for damages (if any) to
-.\" * anyone resulting from the use of this software rests entirely with the
-.\" * user.
-.\" *
-.\" * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
-.\" * I'll try to keep a version up to date. I can be reached as follows:
-.\" * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
.\" */
.\"
-.\" $FreeBSD$
+.\"Copyright (c) 1997 by Internet Software Consortium
+.\"
+.\"Permission to use, copy, modify, and distribute this software for any
+.\"purpose with or without fee is hereby granted, provided that the above
+.\"copyright notice and this permission notice appear in all copies.
+.\"
+.\"THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+.\"ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+.\"OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+.\"CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+.\"DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+.\"PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+.\"ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+.\"SOFTWARE.
+.\"
+.\" $Id: cron.8,v 1.2 1998/08/14 00:32:36 vixie Exp $
.\"
.Dd February 9, 2022
.Dt CRON 8
diff --git a/usr.sbin/cron/cron/cron.c b/usr.sbin/cron/cron/cron.c
index 460dd58dbd0d..46ed984711a5 100644
--- a/usr.sbin/cron/cron/cron.c
+++ b/usr.sbin/cron/cron/cron.c
@@ -1,37 +1,33 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
#if !defined(lint) && !defined(LINT)
static const char rcsid[] =
- "$FreeBSD$";
+ "$Id: cron.c,v 1.3 1998/08/14 00:32:36 vixie Exp $";
#endif
#define MAIN_PROGRAM
-
#include "cron.h"
#include <sys/mman.h>
-#include <sys/signal.h>
-#if SYS_TIME_H
-# include <sys/time.h>
-#else
-# include <time.h>
-#endif
-
static void usage(void),
run_reboot_jobs(cron_db *),
@@ -39,9 +35,7 @@ static void usage(void),
cron_sync(int),
cron_sleep(cron_db *, int),
cron_clean(cron_db *),
-#ifdef USE_SIGCHLD
sigchld_handler(int),
-#endif
sighup_handler(int),
parse_args(int c, char *v[]);
@@ -55,9 +49,10 @@ static int dont_daemonize = 0;
struct pidfh *pfh;
static void
-usage() {
+usage(void)
+{
#if DEBUGGING
- char **dflags;
+ const char **dflags;
#endif
fprintf(stderr, "usage: cron [-j jitter] [-J rootjitter] "
@@ -65,7 +60,7 @@ usage() {
#if DEBUGGING
fprintf(stderr, "\ndebugflags: ");
- for(dflags = DebugFlagNames; *dflags; dflags++) {
+ for (dflags = DebugFlagNames; *dflags; dflags++) {
fprintf(stderr, "%s ", *dflags);
}
fprintf(stderr, "\n");
@@ -77,11 +72,10 @@ usage() {
static void
open_pidfile(void)
{
- char pidfile[MAX_FNAME];
+ const char *pidfile = PIDDIR PIDFILE;
char buf[MAX_TEMPSTR];
int otherpid;
- (void) snprintf(pidfile, sizeof(pidfile), PIDFILE, PIDDIR);
pfh = pidfile_open(pidfile, 0600, &otherpid);
if (pfh == NULL) {
if (errno == EEXIST) {
@@ -98,9 +92,7 @@ open_pidfile(void)
}
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int runnum;
int secres1, secres2;
@@ -115,20 +107,14 @@ main(argc, argv)
parse_args(argc, argv);
-#ifdef USE_SIGCHLD
(void) signal(SIGCHLD, sigchld_handler);
-#else
- (void) signal(SIGCLD, SIG_IGN);
-#endif
(void) signal(SIGHUP, sighup_handler);
open_pidfile();
set_cron_uid();
set_cron_cwd();
-#if defined(POSIX)
- setenv("PATH", _PATH_DEFPATH, 1);
-#endif
+ putenv("PATH="_PATH_DEFPATH);
/* if there are no debug flags turned on, fork as a daemon should.
*/
@@ -198,16 +184,14 @@ main(argc, argv)
}
}
-
static void
-run_reboot_jobs(db)
- cron_db *db;
+run_reboot_jobs(cron_db *db)
{
- register user *u;
- register entry *e;
+ user *u;
+ entry *e;
- for (u = db->head; u != NULL; u = u->next) {
- for (e = u->crontab; e != NULL; e = e->next) {
+ for (u = db->head; u != NULL; u = u->next) {
+ for (e = u->crontab; e != NULL; e = e->next) {
if (e->flags & WHEN_REBOOT) {
job_add(e, u);
}
@@ -219,19 +203,21 @@ run_reboot_jobs(db)
(void) job_runqueue();
}
-
static void
cron_tick(cron_db *db, int secres)
{
- static struct tm lasttm;
- static time_t diff = 0, /* time difference in seconds from the last offset change */
- difflimit = 0; /* end point for the time zone correction */
- struct tm otztm; /* time in the old time zone */
- int otzsecond, otzminute, otzhour, otzdom, otzmonth, otzdow;
- register struct tm *tm = localtime(&TargetTime);
- register int second, minute, hour, dom, month, dow;
- register user *u;
- register entry *e;
+ static struct tm lasttm;
+ /* time difference in seconds from the last offset change */
+ static time_t diff = 0;
+ /* end point for the time zone correction */
+ static time_t difflimit = 0;
+ /* time in the old time zone */
+ struct tm otztm;
+ int otzsecond, otzminute, otzhour, otzdom, otzmonth, otzdow;
+ struct tm *tm = localtime(&TargetTime);
+ int second, minute, hour, dom, month, dow;
+ user *u;
+ entry *e;
/* make 0-based values out of these so we can use them as indices
*/
@@ -254,8 +240,8 @@ cron_tick(cron_db *db, int secres)
if ( diff > 0 ) { /* ST->DST */
/* mark jobs for an earlier run */
difflimit = TargetTime + diff;
- for (u = db->head; u != NULL; u = u->next) {
- for (e = u->crontab; e != NULL; e = e->next) {
+ for (u = db->head; u != NULL; u = u->next) {
+ for (e = u->crontab; e != NULL; e = e->next) {
e->flags &= ~NOT_UNTIL;
if ( e->lastrun >= TargetTime )
e->lastrun = 0;
@@ -269,8 +255,8 @@ cron_tick(cron_db *db, int secres)
} else { /* diff < 0 : DST->ST */
/* mark jobs for skipping */
difflimit = TargetTime - diff;
- for (u = db->head; u != NULL; u = u->next) {
- for (e = u->crontab; e != NULL; e = e->next) {
+ for (u = db->head; u != NULL; u = u->next) {
+ for (e = u->crontab; e != NULL; e = e->next) {
e->flags |= NOT_UNTIL;
e->flags &= ~RUN_AT;
}
@@ -284,8 +270,8 @@ cron_tick(cron_db *db, int secres)
/* disable the TZ switch checks */
diff = 0;
difflimit = 0;
- for (u = db->head; u != NULL; u = u->next) {
- for (e = u->crontab; e != NULL; e = e->next) {
+ for (u = db->head; u != NULL; u = u->next) {
+ for (e = u->crontab; e != NULL; e = e->next) {
e->flags &= ~(RUN_AT|NOT_UNTIL);
}
}
@@ -311,8 +297,8 @@ cron_tick(cron_db *db, int secres)
* is why we keep 'e->dow_star' and 'e->dom_star'. yes, it's bizarre.
* like many bizarre things, it's the standard.
*/
- for (u = db->head; u != NULL; u = u->next) {
- for (e = u->crontab; e != NULL; e = e->next) {
+ for (u = db->head; u != NULL; u = u->next) {
+ for (e = u->crontab; e != NULL; e = e->next) {
Debug(DSCH|DEXT, ("user [%s:%d:%d:...] cmd=\"%s\"\n",
env_get("LOGNAME", e->envp),
e->uid, e->gid, e->cmd))
@@ -325,11 +311,11 @@ cron_tick(cron_db *db, int secres)
}
if ( diff != 0 && (e->flags & (RUN_AT|NOT_UNTIL)) ) {
- if (bit_test(e->second, otzsecond)
- && bit_test(e->minute, otzminute)
- && bit_test(e->hour, otzhour)
- && bit_test(e->month, otzmonth)
- && ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
+ if (bit_test(e->second, otzsecond) &&
+ bit_test(e->minute, otzminute) &&
+ bit_test(e->hour, otzhour) &&
+ bit_test(e->month, otzmonth) &&
+ ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
? (bit_test(e->dow,otzdow) && bit_test(e->dom,otzdom))
: (bit_test(e->dow,otzdow) || bit_test(e->dom,otzdom))
)
@@ -345,11 +331,11 @@ cron_tick(cron_db *db, int secres)
continue;
}
- if (bit_test(e->second, second)
- && bit_test(e->minute, minute)
- && bit_test(e->hour, hour)
- && bit_test(e->month, month)
- && ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
+ if (bit_test(e->second, second) &&
+ bit_test(e->minute, minute) &&
+ bit_test(e->hour, hour) &&
+ bit_test(e->month, month) &&
+ ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
? (bit_test(e->dow,dow) && bit_test(e->dom,dom))
: (bit_test(e->dow,dow) || bit_test(e->dom,dom))
)
@@ -365,7 +351,6 @@ cron_tick(cron_db *db, int secres)
lasttm = *tm;
}
-
/* the task here is to figure out how long it's going to be until :00 of the
* following minute and initialize TargetTime to this value. TargetTime
* will subsequently slide 60 seconds at a time, with correction applied
@@ -377,7 +362,7 @@ cron_tick(cron_db *db, int secres)
*/
static void
cron_sync(int secres) {
- struct tm *tm;
+ struct tm *tm;
TargetTime = time((time_t*)0);
if (secres != 0) {
@@ -462,8 +447,7 @@ cron_sleep(cron_db *db, int secres)
*/
static void
-cron_clean(db)
- cron_db *db;
+cron_clean(cron_db *db)
{
user *u;
entry *e;
@@ -477,19 +461,14 @@ cron_clean(db)
}
}
-#ifdef USE_SIGCHLD
static void
sigchld_handler(int x)
{
- WAIT_T waiter;
- PID_T pid;
+ WAIT_T waiter;
+ PID_T pid;
for (;;) {
-#ifdef POSIX
pid = waitpid(-1, &waiter, WNOHANG);
-#else
- pid = wait3(&waiter, WNOHANG, (struct rusage *)0);
-#endif
switch (pid) {
case -1:
Debug(DPROC,
@@ -507,8 +486,6 @@ sigchld_handler(int x)
}
}
}
-#endif /*USE_SIGCHLD*/
-
static void
sighup_handler(int x)
@@ -516,14 +493,11 @@ sighup_handler(int x)
log_close();
}
-
static void
-parse_args(argc, argv)
- int argc;
- char *argv[];
+parse_args(int argc, char *argv[])
{
- int argch;
- char *endp;
+ int argch;
+ char *endp;
while ((argch = getopt(argc, argv, "j:J:m:nosx:")) != -1) {
switch (argch) {
diff --git a/usr.sbin/cron/cron/cron.h b/usr.sbin/cron/cron/cron.h
index f0f9e88d6b59..67d91b57750e 100644
--- a/usr.sbin/cron/cron/cron.h
+++ b/usr.sbin/cron/cron/cron.h
@@ -1,318 +1,37 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
/* cron.h - header for vixie's cron
*
- * $FreeBSD$
+ * $Id: cron.h,v 1.3 1998/08/14 00:32:37 vixie Exp $
*
* vix 14nov88 [rest of log is in RCS]
* vix 14jan87 [0 or 7 can be sunday; thanks, mwm@berkeley]
* vix 30dec86 [written]
*/
-/* reorder these #include's at your peril */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include "compat.h"
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <libutil.h>
-#include <pwd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <time.h>
-#include <sys/wait.h>
-
-#include "pathnames.h"
#include "config.h"
#include "externs.h"
-
- /* these are really immutable, and are
- * defined for symbolic convenience only
- * TRUE, FALSE, and ERR must be distinct
- * ERR must be < OK.
- */
-#define TRUE 1
-#define FALSE 0
- /* system calls return this on success */
-#define OK 0
- /* or this on error */
-#define ERR (-1)
-
- /* turn this on to get '-x' code */
-#ifndef DEBUGGING
-#define DEBUGGING FALSE
-#endif
-
-#define READ_PIPE 0 /* which end of a pipe pair do you read? */
-#define WRITE_PIPE 1 /* or write to? */
-#define STDIN 0 /* what is stdin's file descriptor? */
-#define STDOUT 1 /* stdout's? */
-#define STDERR 2 /* stderr's? */
-#define ERROR_EXIT 1 /* exit() with this will scare the shell */
-#define OK_EXIT 0 /* exit() with this is considered 'normal' */
-#define MAX_FNAME 100 /* max length of internally generated fn */
-#define MAX_COMMAND 1000 /* max length of internally generated cmd */
-#define MAX_ENVSTR 1000 /* max length of envvar=value\0 strings */
-#define MAX_TEMPSTR 100 /* obvious */
-#define ROOT_UID 0 /* don't change this, it really must be root */
-#define ROOT_USER "root" /* ditto */
-#define SYS_NAME "*system*" /* magic owner name for system crontab */
-
- /* NOTE: these correspond to DebugFlagNames,
- * defined below.
- */
-#define DEXT 0x0001 /* extend flag for other debug masks */
-#define DSCH 0x0002 /* scheduling debug mask */
-#define DPROC 0x0004 /* process control debug mask */
-#define DPARS 0x0008 /* parsing debug mask */
-#define DLOAD 0x0010 /* database loading debug mask */
-#define DMISC 0x0020 /* misc debug mask */
-#define DTEST 0x0040 /* test mode: don't execute any commands */
-#define DBIT 0x0080 /* bit twiddling shown (long) */
-
-#define CRON_TAB(u) "%s/%s", SPOOL_DIR, u
-#define REG register
-#define PPC_NULL ((char **)NULL)
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif
-
-#define Skip_Blanks(c, f) \
- while (c == '\t' || c == ' ') \
- c = get_char(f);
-
-#define Skip_Nonblanks(c, f) \
- while (c!='\t' && c!=' ' && c!='\n' && c != EOF) \
- c = get_char(f);
-
-#define Skip_Line(c, f) \
- do {c = get_char(f);} while (c != '\n' && c != EOF);
-
-#if DEBUGGING
-# define Debug(mask, message) \
- if ( (DebugFlags & (mask) ) == (mask) ) \
- printf message;
-#else /* !DEBUGGING */
-# define Debug(mask, message) \
- ;
-#endif /* DEBUGGING */
-
-#define MkLower(ch) (isupper(ch) ? tolower(ch) : ch)
-#define MkUpper(ch) (islower(ch) ? toupper(ch) : ch)
-#define Set_LineNum(ln) {Debug(DPARS|DEXT,("linenum=%d\n",ln)); \
- LineNumber = ln; \
- }
-
-#define FIRST_SECOND 0
-#define LAST_SECOND 59
-#define SECOND_COUNT (LAST_SECOND - FIRST_SECOND + 1)
-
-#define FIRST_MINUTE 0
-#define LAST_MINUTE 59
-#define MINUTE_COUNT (LAST_MINUTE - FIRST_MINUTE + 1)
-
-#define FIRST_HOUR 0
-#define LAST_HOUR 23
-#define HOUR_COUNT (LAST_HOUR - FIRST_HOUR + 1)
-
-#define FIRST_DOM 1
-#define LAST_DOM 31
-#define DOM_COUNT (LAST_DOM - FIRST_DOM + 1)
-
-#define FIRST_MONTH 1
-#define LAST_MONTH 12
-#define MONTH_COUNT (LAST_MONTH - FIRST_MONTH + 1)
-
-/* note on DOW: 0 and 7 are both Sunday, for compatibility reasons. */
-#define FIRST_DOW 0
-#define LAST_DOW 7
-#define DOW_COUNT (LAST_DOW - FIRST_DOW + 1)
-
-#ifdef LOGIN_CAP
-/* see init.c */
-#define RESOURCE_RC "daemon"
-#endif
-
- /* each user's crontab will be held as a list of
- * the following structure.
- *
- * These are the cron commands.
- */
-
-typedef struct _entry {
- struct _entry *next;
- uid_t uid;
- gid_t gid;
-#ifdef LOGIN_CAP
- char *class;
-#endif
- char **envp;
- char *cmd;
- union {
- struct {
- bitstr_t bit_decl(second, SECOND_COUNT);
- bitstr_t bit_decl(minute, MINUTE_COUNT);
- bitstr_t bit_decl(hour, HOUR_COUNT);
- bitstr_t bit_decl(dom, DOM_COUNT);
- bitstr_t bit_decl(month, MONTH_COUNT);
- bitstr_t bit_decl(dow, DOW_COUNT);
- };
- struct {
- time_t lastexit;
- time_t interval;
- pid_t child;
- };
- };
- int flags;
-#define DOM_STAR 0x01
-#define DOW_STAR 0x02
-#define WHEN_REBOOT 0x04
-#define RUN_AT 0x08
-#define NOT_UNTIL 0x10
-#define SEC_RES 0x20
-#define INTERVAL 0x40
-#define DONT_LOG 0x80
-#define MAIL_WHEN_ERR 0x100
- time_t lastrun;
-} entry;
-
- /* the crontab database will be a list of the
- * following structure, one element per user
- * plus one for the system.
- *
- * These are the crontabs.
- */
-
-typedef struct _user {
- struct _user *next, *prev; /* links */
- char *name;
- time_t mtime; /* last modtime of crontab */
- entry *crontab; /* this person's crontab */
-} user;
-
-typedef struct _cron_db {
- user *head, *tail; /* links */
- time_t mtime; /* last modtime on spooldir */
-} cron_db;
-
-
-void set_cron_uid(void),
- set_cron_cwd(void),
- load_database(cron_db *),
- open_logfile(void),
- sigpipe_func(void),
- job_add(entry *, user *),
- do_command(entry *, user *),
- link_user(cron_db *, user *),
- unlink_user(cron_db *, user *),
- free_user(user *),
- env_free(char **),
- unget_char(int, FILE *),
- free_entry(entry *),
- skip_comments(FILE *),
- log_it(char *, int, char *, const char *),
- log_close(void);
-
-int job_runqueue(void),
- set_debug_flags(char *),
- get_char(FILE *),
- get_string(char *, int, FILE *, char *),
- swap_uids(void),
- swap_uids_back(void),
- load_env(char *, FILE *),
- cron_pclose(FILE *),
- strcmp_until(char *, char *, int),
- allowed(char *),
- strdtb(char *);
-
-char *env_get(char *, char **),
- *arpadate(time_t *),
- *mkprints(unsigned char *, unsigned int),
- *first_word(char *, char *),
- **env_init(void),
- **env_copy(char **),
- **env_set(char **, char *);
-
-user *load_user(int, struct passwd *, char *),
- *find_user(cron_db *, char *);
-
-entry *load_entry(FILE *, void (*)(char *),
- struct passwd *, char **);
-
-FILE *cron_popen(char *, char *, entry *, PID_T *);
-
-
- /* in the C tradition, we only create
- * variables for the main program, just
- * extern them elsewhere.
- */
-
-#ifdef MAIN_PROGRAM
-# if !defined(LINT) && !defined(lint)
-char *copyright[] = {
- "@(#) Copyright 1988,1989,1990,1993,1994 by Paul Vixie",
- "@(#) All rights reserved"
- };
-# endif
-
-char *MonthNames[] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
- NULL
- };
-
-char *DowNames[] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
- NULL
- };
-
-char *ProgramName,
- *defmailto;
-int LineNumber;
-unsigned Jitter,
- RootJitter;
-time_t TargetTime;
-
-# if DEBUGGING
-int DebugFlags;
-char *DebugFlagNames[] = { /* sync with #defines */
- "ext", "sch", "proc", "pars", "load", "misc", "test", "bit",
- NULL /* NULL must be last element */
- };
-# endif /* DEBUGGING */
-#else /*MAIN_PROGRAM*/
-extern char *copyright[],
- *MonthNames[],
- *DowNames[],
- *ProgramName,
- *defmailto;
-extern int LineNumber;
-extern unsigned Jitter,
- RootJitter;
-extern time_t TargetTime;
-extern struct pidfh *pfh;
-# if DEBUGGING
-extern int DebugFlags;
-extern char *DebugFlagNames[];
-# endif /* DEBUGGING */
-#endif /*MAIN_PROGRAM*/
+#include "pathnames.h"
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
+#include "globals.h"
diff --git a/usr.sbin/cron/cron/crontab b/usr.sbin/cron/cron/crontab
index 994d4ae6af00..2f4bc71d8722 100644
--- a/usr.sbin/cron/cron/crontab
+++ b/usr.sbin/cron/cron/crontab
@@ -1,6 +1,5 @@
# /etc/crontab - root's crontab for FreeBSD
#
-# $FreeBSD$
#
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
diff --git a/usr.sbin/cron/cron/database.c b/usr.sbin/cron/cron/database.c
index ce1f916c2042..35e5fad3524d 100644
--- a/usr.sbin/cron/cron/database.c
+++ b/usr.sbin/cron/cron/database.c
@@ -1,54 +1,49 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
#if !defined(lint) && !defined(LINT)
static const char rcsid[] =
- "$FreeBSD$";
+ "$Id: database.c,v 1.3 1998/08/14 00:32:38 vixie Exp $";
#endif
/* vix 26jan87 [RCS has the log]
*/
-
#include "cron.h"
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-
#define TMAX(a,b) ((a)>(b)?(a):(b))
-
-static void process_crontab(char *, char *, char *,
- struct stat *,
- cron_db *, cron_db *);
-
+static void process_crontab(const char *, const char *,
+ const char *, struct stat *,
+ cron_db *, cron_db *);
void
-load_database(old_db)
- cron_db *old_db;
+load_database(cron_db *old_db)
{
- DIR *dir;
- struct stat statbuf;
- struct stat syscron_stat, st;
- time_t maxmtime;
- DIR_T *dp;
- cron_db new_db;
- user *u, *nu;
+ struct stat statbuf, syscron_stat, st;
+ cron_db new_db;
+ DIR_T *dp;
+ DIR *dir;
+ user *u, *nu;
+ time_t maxmtime;
struct {
const char *name;
struct stat st;
@@ -157,8 +152,7 @@ load_database(old_db)
}
while (NULL != (dp = readdir(dir))) {
- char fname[MAXNAMLEN+1],
- tabname[MAXNAMLEN+1];
+ char fname[MAXNAMLEN+1], tabname[MAXNAMLEN+1];
/* avoid file names beginning with ".". this is good
* because we would otherwise waste two guaranteed calls
@@ -170,7 +164,10 @@ load_database(old_db)
(void) strncpy(fname, dp->d_name, sizeof(fname));
fname[sizeof(fname)-1] = '\0';
- (void) snprintf(tabname, sizeof tabname, CRON_TAB(fname));
+
+ if (snprintf(tabname, sizeof tabname, CRON_TAB(fname))
+ >= sizeof(tabname))
+ continue; /* XXX log? */
process_crontab(fname, fname, tabname,
&statbuf, &new_db, old_db);
@@ -199,11 +196,8 @@ load_database(old_db)
Debug(DLOAD, ("load_database is done\n"))
}
-
void
-link_user(db, u)
- cron_db *db;
- user *u;
+link_user(cron_db *db, user *u)
{
if (db->head == NULL)
db->head = u;
@@ -214,11 +208,8 @@ link_user(db, u)
db->tail = u;
}
-
void
-unlink_user(db, u)
- cron_db *db;
- user *u;
+unlink_user(cron_db *db, user *u)
{
if (u->prev == NULL)
db->head = u->next;
@@ -231,38 +222,28 @@ unlink_user(db, u)
u->next->prev = u->prev;
}
-
user *
-find_user(db, name)
- cron_db *db;
- char *name;
+find_user(cron_db *db, const char *name)
{
- char *env_get();
- user *u;
+ user *u;
for (u = db->head; u != NULL; u = u->next)
- if (!strcmp(u->name, name))
+ if (strcmp(u->name, name) == 0)
break;
- return u;
+ return (u);
}
-
static void
-process_crontab(uname, fname, tabname, statbuf, new_db, old_db)
- char *uname;
- char *fname;
- char *tabname;
- struct stat *statbuf;
- cron_db *new_db;
- cron_db *old_db;
+process_crontab(const char *uname, const char *fname, const char *tabname,
+ struct stat *statbuf, cron_db *new_db, cron_db *old_db)
{
- struct passwd *pw = NULL;
- int crontab_fd = OK - 1;
- user *u;
- entry *e;
- time_t now;
+ struct passwd *pw = NULL;
+ int crontab_fd = OK - 1;
+ user *u;
+ entry *e;
+ time_t now;
- if (strcmp(fname, SYS_NAME) && !(pw = getpwnam(uname))) {
+ if (strcmp(fname, SYS_NAME) != 0 && !(pw = getpwnam(uname))) {
/* file doesn't have a user in passwd file.
*/
log_it(fname, getpid(), "ORPHAN", "no passwd entry");
@@ -327,7 +308,7 @@ process_crontab(uname, fname, tabname, statbuf, new_db, old_db)
link_user(new_db, u);
}
-next_crontab:
+ next_crontab:
if (crontab_fd >= OK) {
Debug(DLOAD, (" [done]\n"))
close(crontab_fd);
diff --git a/usr.sbin/cron/cron/do_command.c b/usr.sbin/cron/cron/do_command.c
index 4dcbce2c1165..43b3269d3087 100644
--- a/usr.sbin/cron/cron/do_command.c
+++ b/usr.sbin/cron/cron/do_command.c
@@ -1,34 +1,30 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
#if !defined(lint) && !defined(LINT)
static const char rcsid[] =
- "$FreeBSD$";
+ "$Id: do_command.c,v 1.3 1998/08/14 00:32:39 vixie Exp $";
#endif
-
#include "cron.h"
-#include <sys/signal.h>
-#if defined(sequent)
-# include <sys/universe.h>
-#endif
-#if defined(SYSLOG)
-# include <syslog.h>
-#endif
#if defined(LOGIN_CAP)
# include <login_cap.h>
#endif
@@ -37,17 +33,13 @@ static const char rcsid[] =
# include <security/openpam.h>
#endif
-
static void child_process(entry *, user *);
-
static WAIT_T wait_on_child(PID_T, const char *);
extern char *environ;
void
-do_command(e, u)
- entry *e;
- user *u;
+do_command(entry *e, user *u)
{
pid_t pid;
@@ -60,7 +52,7 @@ do_command(e, u)
*/
switch ((pid = fork())) {
case -1:
- log_it("CRON",getpid(),"error","can't fork");
+ log_it("CRON", getpid(), "error", "can't fork");
if (e->flags & INTERVAL)
e->lastexit = time(NULL);
break;
@@ -86,20 +78,18 @@ do_command(e, u)
static void
-child_process(e, u)
- entry *e;
- user *u;
+child_process(entry *e, user *u)
{
- int stdin_pipe[2], stdout_pipe[2];
- register char *input_data;
- char *usernm, *mailto, *mailfrom;
- PID_T jobpid, stdinjob, mailpid;
- register FILE *mail;
- register int bytes = 1;
- int status = 0;
- const char *homedir = NULL;
+ int stdin_pipe[2], stdout_pipe[2];
+ char *input_data;
+ const char *usernm, *mailto, *mailfrom;
+ PID_T jobpid, stdinjob, mailpid;
+ FILE *mail;
+ int bytes = 1;
+ int status = 0;
+ const char *homedir = NULL;
# if defined(LOGIN_CAP)
- struct passwd *pwd;
+ struct passwd *pwd;
login_cap_t *lc;
# endif
@@ -158,20 +148,12 @@ child_process(e, u)
}
#endif
-#ifdef USE_SIGCHLD
/* our parent is watching for our death by catching SIGCHLD. we
* do not care to watch for our children's deaths this way -- we
* use wait() explicitly. so we have to disable the signal (which
* was inherited from the parent).
*/
(void) signal(SIGCHLD, SIG_DFL);
-#else
- /* on system-V systems, we are ignoring SIGCLD. we have to stop
- * ignoring it now or the wait() in cron_pclose() won't work.
- * because of this, we have to wait() for our children here, as well.
- */
- (void) signal(SIGCLD, SIG_DFL);
-#endif /*BSD*/
/* create some pipes to talk to our future child
*/
@@ -191,14 +173,15 @@ child_process(e, u)
* If there are escaped %'s, remove the escape character.
*/
/*local*/{
- register int escaped = FALSE;
- register int ch;
- register char *p;
+ int escaped = FALSE;
+ int ch;
+ char *p;
- for (input_data = p = e->cmd; (ch = *input_data);
+ for (input_data = p = e->cmd;
+ (ch = *input_data) != '\0';
input_data++, p++) {
if (p != input_data)
- *p = ch;
+ *p = ch;
if (escaped) {
if (ch == '%' || ch == '\\')
*--p = ch;
@@ -221,7 +204,7 @@ child_process(e, u)
*/
switch (jobpid = fork()) {
case -1:
- log_it("CRON",getpid(),"error","can't fork");
+ log_it("CRON", getpid(), "error", "can't fork");
exit(ERROR_EXIT);
/*NOTREACHED*/
case 0:
@@ -316,13 +299,11 @@ child_process(e, u)
"error", "setgid failed");
_exit(ERROR_EXIT);
}
-# if defined(BSD)
if (initgroups(usernm, e->gid) != 0) {
log_it(usernm, getpid(),
"error", "initgroups failed");
_exit(ERROR_EXIT);
}
-# endif
if (setlogin(usernm) != 0) {
log_it(usernm, getpid(),
"error", "setlogin failed");
@@ -441,10 +422,10 @@ child_process(e, u)
*/
if (*input_data && (stdinjob = fork()) == 0) {
- register FILE *out = fdopen(stdin_pipe[WRITE_PIPE], "w");
- register int need_newline = FALSE;
- register int escaped = FALSE;
- register int ch;
+ FILE *out = fdopen(stdin_pipe[WRITE_PIPE], "w");
+ int need_newline = FALSE;
+ int escaped = FALSE;
+ int ch;
if (out == NULL) {
warn("fdopen failed in child2");
@@ -463,7 +444,7 @@ child_process(e, u)
* % -> \n
* \x -> \x for all x != %
*/
- while ((ch = *input_data++)) {
+ while ((ch = *input_data++) != '\0') {
if (escaped) {
if (ch != '%')
putc('\\', out);
@@ -506,8 +487,8 @@ child_process(e, u)
Debug(DPROC, ("[%d] child reading output from grandchild\n", getpid()))
/*local*/{
- register FILE *in = fdopen(stdout_pipe[READ_PIPE], "r");
- register int ch;
+ FILE *in = fdopen(stdout_pipe[READ_PIPE], "r");
+ int ch;
if (in == NULL) {
warn("fdopen failed in child");
@@ -527,7 +508,7 @@ child_process(e, u)
*/
if (mailto == NULL) {
/* MAILTO not present, set to USER,
- * unless globally overriden.
+ * unless globally overridden.
*/
if (defmailto)
mailto = defmailto;
@@ -543,17 +524,20 @@ child_process(e, u)
*/
if (mailto) {
- register char **env;
- auto char mailcmd[MAX_COMMAND];
- auto char hostname[MAXHOSTNAMELEN];
+ char **env;
+ char mailcmd[MAX_COMMAND];
+ char hostname[MAXHOSTNAMELEN];
if (gethostname(hostname, MAXHOSTNAMELEN) == -1)
hostname[0] = '\0';
hostname[sizeof(hostname) - 1] = '\0';
- (void) snprintf(mailcmd, sizeof(mailcmd),
- MAILARGS, MAILCMD);
+ if (snprintf(mailcmd, sizeof(mailcmd), MAILFMT,
+ MAILARG) >= sizeof(mailcmd)) {
+ warnx("mail command too long");
+ (void) _exit(ERROR_EXIT);
+ }
if (!(mail = cron_popen(mailcmd, "w", e, &mailpid))) {
- warn("%s", MAILCMD);
+ warn("%s", mailcmd);
(void) _exit(ERROR_EXIT);
}
if (mailfrom == NULL || *mailfrom == '\0')
@@ -566,10 +550,10 @@ child_process(e, u)
fprintf(mail, "Subject: Cron <%s@%s> %s\n",
usernm, first_word(hostname, "."),
e->cmd);
-# if defined(MAIL_DATE)
+#ifdef MAIL_DATE
fprintf(mail, "Date: %s\n",
arpadate(&TargetTime));
-# endif /* MAIL_DATE */
+#endif /*MAIL_DATE*/
for (env = e->envp; *env; env++)
fprintf(mail, "X-Cron-Env: <%s>\n",
*env);
@@ -602,7 +586,7 @@ child_process(e, u)
/* wait for children to die.
*/
if (jobpid > 0) {
- WAIT_T waiter;
+ WAIT_T waiter;
waiter = wait_on_child(jobpid, "grandchild command job");
@@ -619,7 +603,6 @@ child_process(e, u)
mail = NULL;
}
-
/* only close pipe if we opened it -- i.e., we're
* mailing...
*/
@@ -656,9 +639,10 @@ child_process(e, u)
}
static WAIT_T
-wait_on_child(PID_T childpid, const char *name) {
- WAIT_T waiter;
- PID_T pid;
+wait_on_child(PID_T childpid, const char *name)
+{
+ WAIT_T waiter;
+ PID_T pid;
Debug(DPROC, ("[%d] waiting for %s (%d) to finish\n",
getpid(), name, childpid))
diff --git a/usr.sbin/cron/cron/externs.h b/usr.sbin/cron/cron/externs.h
index 8b1ff71b36e2..343848240f4f 100644
--- a/usr.sbin/cron/cron/externs.h
+++ b/usr.sbin/cron/cron/externs.h
@@ -1,69 +1,96 @@
-/* $FreeBSD$ */
-
/* Copyright 1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
-#if defined(POSIX) || defined(ATT)
-# include <stdlib.h>
-# include <unistd.h>
-# include <string.h>
-# include <dirent.h>
-# define DIR_T struct dirent
-# define WAIT_T int
-# define WAIT_IS_INT 1
+/* reorder these #include's at your peril */
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <sys/fcntl.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+
+#include <bitstring.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <libutil.h>
+#include <locale.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <utime.h>
+
+#if defined(SYSLOG)
+# include <syslog.h>
+#endif
+
+#if (defined(BSD)) && (BSD >= 199103) || defined(__linux) || defined(AIX)
+# include <paths.h>
+#endif /*BSD*/
+
+#if !defined(_PATH_SENDMAIL)
+# define _PATH_SENDMAIL "/usr/lib/sendmail"
+#endif /*SENDMAIL*/
+
+#if defined(__bsdi__) && (_BSDI_VERSION > 199510)
+#include <login_cap.h>
+#endif /* __bsdi__ */
+
+#define DIR_T struct dirent
+#define WAIT_T int
+#define SIG_T sig_t
+#define TIME_T time_t
+#define PID_T pid_t
+
+#ifndef TZNAME_ALREADY_DEFINED
extern char *tzname[2];
-# define TZONE(tm) tzname[(tm).tm_isdst]
#endif
+#define TZONE(tm) tzname[(tm).tm_isdst]
-#if defined(UNIXPC)
-# undef WAIT_T
-# undef WAIT_IS_INT
-# define WAIT_T union wait
+#if (BSD >= 198606)
+# define HAVE_FCHOWN
+# define HAVE_FCHMOD
#endif
-#if defined(POSIX)
-# define SIG_T sig_t
-# define TIME_T time_t
-# define PID_T pid_t
+#if (BSD >= 199103)
+# define HAVE_SAVED_UIDS
#endif
-#if defined(ATT)
-# define SIG_T void
-# define TIME_T long
-# define PID_T int
-#endif
+#define MY_UID(pw) getuid()
+#define MY_GID(pw) getgid()
-#if !defined(POSIX) && !defined(ATT)
-/* classic BSD */
-extern time_t time();
-extern unsigned sleep();
-extern struct tm *localtime();
-extern struct passwd *getpwnam();
-extern int errno;
-extern void perror(), exit(), free();
-extern char *getenv(), *strcpy(), *strchr(), *strtok();
-extern void *malloc(), *realloc();
-# define SIG_T void
-# define TIME_T long
-# define PID_T int
-# define WAIT_T union wait
-# define DIR_T struct direct
-# include <sys/dir.h>
-# define TZONE(tm) (tm).tm_zone
+#if !defined(AIX) && !defined(UNICOS)
+# define SYS_TIME_H 1
+#else
+# define SYS_TIME_H 0
#endif
/* getopt() isn't part of POSIX. some systems define it in <stdlib.h> anyway.
@@ -72,7 +99,7 @@ extern void *malloc(), *realloc();
* in ways that we cannot predict or comprehend, yet do not define the adjunct
* external variables needed for the interface.
*/
-#if (!defined(BSD) || (BSD < 198911)) && !defined(ATT) && !defined(UNICOS)
+#if (!defined(BSD) || (BSD < 198911))
int getopt(int, char * const *, const char *);
#endif
@@ -81,63 +108,21 @@ extern char *optarg;
extern int optind, opterr, optopt;
#endif
-#if WAIT_IS_INT
-# ifndef WEXITSTATUS
-# define WEXITSTATUS(x) (((x) >> 8) & 0xff)
-# endif
-# ifndef WTERMSIG
-# define WTERMSIG(x) ((x) & 0x7f)
-# endif
-# ifndef WCOREDUMP
-# define WCOREDUMP(x) ((x) & 0x80)
-# endif
-#else /*WAIT_IS_INT*/
-# ifndef WEXITSTATUS
-# define WEXITSTATUS(x) ((x).w_retcode)
-# endif
-# ifndef WTERMSIG
-# define WTERMSIG(x) ((x).w_termsig)
-# endif
-# ifndef WCOREDUMP
-# define WCOREDUMP(x) ((x).w_coredump)
-# endif
-#endif /*WAIT_IS_INT*/
-
-#ifndef WIFSIGNALED
-#define WIFSIGNALED(x) (WTERMSIG(x) != 0)
-#endif
-#ifndef WIFEXITED
-#define WIFEXITED(x) (WTERMSIG(x) == 0)
-#endif
-
-#ifdef NEED_STRCASECMP
-extern int strcasecmp(char *, char *);
-#endif
-
-#ifdef NEED_STRDUP
-extern char *strdup(char *);
-#endif
-
-#ifdef NEED_STRERROR
-extern char *strerror(int);
-#endif
-
-#ifdef NEED_FLOCK
+/* digital unix needs this but does not give us a way to identify it.
+ */
extern int flock(int, int);
+
+/* not all systems who provice flock() provide these definitions.
+ */
+#ifndef LOCK_SH
# define LOCK_SH 1
-# define LOCK_EX 2
-# define LOCK_NB 4
-# define LOCK_UN 8
#endif
-
-#ifdef NEED_SETSID
-extern int setsid(void);
+#ifndef LOCK_EX
+# define LOCK_EX 2
#endif
-
-#ifdef NEED_GETDTABLESIZE
-extern int getdtablesize(void);
+#ifndef LOCK_NB
+# define LOCK_NB 4
#endif
-
-#ifdef NEED_SETENV
-extern int setenv(char *, char *, int);
+#ifndef LOCK_UN
+# define LOCK_UN 8
#endif
diff --git a/usr.sbin/cron/cron/funcs.h b/usr.sbin/cron/cron/funcs.h
new file mode 100644
index 000000000000..8a29513a0b31
--- /dev/null
+++ b/usr.sbin/cron/cron/funcs.h
@@ -0,0 +1,70 @@
+/*
+ * $Id: funcs.h,v 1.1 1998/08/14 00:31:24 vixie Exp $
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* Notes:
+ * This file has to be included by cron.h after data structure defs.
+ * We should reorg this into sections by module.
+ */
+
+void set_cron_uid(void),
+ set_cron_cwd(void),
+ load_database(cron_db *),
+ open_logfile(void),
+ sigpipe_func(void),
+ job_add(entry *, user *),
+ do_command(entry *, user *),
+ link_user(cron_db *, user *),
+ unlink_user(cron_db *, user *),
+ free_user(user *),
+ env_free(char **),
+ unget_char(int, FILE *),
+ free_entry(entry *),
+ skip_comments(FILE *),
+ log_it(const char *, int, const char *, const char *),
+ log_close(void);
+
+int job_runqueue(void),
+ set_debug_flags(char *),
+ get_char(FILE *),
+ get_string(char *, int, FILE *, char *),
+ swap_uids(void),
+ swap_uids_back(void),
+ load_env(char *, FILE *),
+ cron_pclose(FILE *),
+ strcmp_until(const char *, const char *, int),
+ allowed(char *),
+ strdtb(char *);
+
+char *env_get(char *, char **),
+ *arpadate(time_t *),
+ *mkprints(unsigned char *, unsigned int),
+ *first_word(char *, char *),
+ **env_init(void),
+ **env_copy(char **),
+ **env_set(char **, char *);
+
+user *load_user(int, struct passwd *, const char *),
+ *find_user(cron_db *, const char *);
+
+entry *load_entry(FILE *, void (*)(const char *),
+ struct passwd *, char **);
+
+FILE *cron_popen(char *, char *, entry *, PID_T *);
diff --git a/usr.sbin/cron/cron/globals.h b/usr.sbin/cron/cron/globals.h
new file mode 100644
index 000000000000..77b9bf7798ae
--- /dev/null
+++ b/usr.sbin/cron/cron/globals.h
@@ -0,0 +1,75 @@
+/*
+ * $Id: globals.h,v 1.1 1998/08/14 00:31:23 vixie Exp $
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifdef MAIN_PROGRAM
+# define XTRN
+# define INIT(x) = x
+#else
+# define XTRN extern
+# define INIT(x)
+#endif
+
+XTRN const char *copyright[]
+#ifdef MAIN_PROGRAM
+ = {
+ NULL
+ }
+#endif
+ ;
+
+XTRN const char *MonthNames[]
+#ifdef MAIN_PROGRAM
+ = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",\
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",\
+ NULL
+ }
+#endif
+ ;
+
+XTRN const char *DowNames[]
+#ifdef MAIN_PROGRAM
+ = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",\
+ NULL
+ }
+#endif
+ ;
+
+XTRN const char *ProgramName INIT("amnesia");
+XTRN const char *defmailto;
+XTRN int LineNumber INIT(0);
+XTRN unsigned Jitter;
+XTRN unsigned RootJitter;
+XTRN time_t TargetTime INIT(0);
+XTRN struct pidfh *pfh;
+
+#if DEBUGGING
+XTRN int DebugFlags INIT(0);
+XTRN const char *DebugFlagNames[]
+#ifdef MAIN_PROGRAM
+ = {
+ "ext", "sch", "proc", "pars", "load", "misc", "test", "bit",\
+ NULL
+ }
+#endif
+ ;
+#endif /* DEBUGGING */
diff --git a/usr.sbin/cron/cron/job.c b/usr.sbin/cron/cron/job.c
index 6d1b1af6e474..9579cd9d755d 100644
--- a/usr.sbin/cron/cron/job.c
+++ b/usr.sbin/cron/cron/job.c
@@ -1,24 +1,24 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
-#if !defined(lint) && !defined(LINT)
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
#include "cron.h"
@@ -35,15 +35,14 @@ static job *jhead = NULL, *jtail = NULL;
void
-job_add(e, u)
- register entry *e;
- register user *u;
+job_add(entry *e, user *u)
{
- register job *j;
+ job *j;
/* if already on queue, keep going */
- for (j=jhead; j; j=j->next)
- if (j->e == e && j->u == u) { return; }
+ for (j = jhead; j != NULL; j = j->next)
+ if (j->e == e && j->u == u)
+ return;
/* build a job queue element */
if ((j = (job*)malloc(sizeof(job))) == NULL)
@@ -53,24 +52,26 @@ job_add(e, u)
j->u = u;
/* add it to the tail */
- if (!jhead) { jhead=j; }
- else { jtail->next=j; }
+ if (jhead == NULL)
+ jhead = j;
+ else
+ jtail->next = j;
jtail = j;
}
int
-job_runqueue()
+job_runqueue(void)
{
- register job *j, *jn;
- register int run = 0;
+ job *j, *jn;
+ int run = 0;
- for (j=jhead; j; j=jn) {
+ for (j = jhead; j; j = jn) {
do_command(j->e, j->u);
jn = j->next;
free(j);
run++;
}
jhead = jtail = NULL;
- return run;
+ return (run);
}
diff --git a/usr.sbin/cron/cron/macros.h b/usr.sbin/cron/cron/macros.h
new file mode 100644
index 000000000000..6ce680818b31
--- /dev/null
+++ b/usr.sbin/cron/cron/macros.h
@@ -0,0 +1,134 @@
+/*
+ * $Id: macros.h,v 1.1 1998/08/14 00:31:24 vixie Exp $
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+ /* these are really immutable, and are
+ * defined for symbolic convenience only
+ * TRUE, FALSE, and ERR must be distinct
+ * ERR must be < OK.
+ */
+#define TRUE 1
+#define FALSE 0
+ /* system calls return this on success */
+#define OK 0
+ /* or this on error */
+#define ERR (-1)
+
+ /* turn this on to get '-x' code */
+#ifndef DEBUGGING
+#define DEBUGGING FALSE
+#endif
+
+#define READ_PIPE 0 /* which end of a pipe pair do you read? */
+#define WRITE_PIPE 1 /* or write to? */
+#define STDIN 0 /* what is stdin's file descriptor? */
+#define STDOUT 1 /* stdout's? */
+#define STDERR 2 /* stderr's? */
+#define ERROR_EXIT 1 /* exit() with this will scare the shell */
+#define OK_EXIT 0 /* exit() with this is considered 'normal' */
+#define MAX_FNAME 100 /* max length of internally generated fn */
+#define MAX_COMMAND 1000 /* max length of internally generated cmd */
+#define MAX_ENVSTR 1000 /* max length of envvar=value\0 strings */
+#define MAX_TEMPSTR 100 /* obvious */
+#define ROOT_UID 0 /* don't change this, it really must be root */
+#define ROOT_USER "root" /* ditto */
+#define SYS_NAME "*system*" /* magic owner name for system crontab */
+
+ /* NOTE: these correspond to DebugFlagNames,
+ * defined below.
+ */
+#define DEXT 0x0001 /* extend flag for other debug masks */
+#define DSCH 0x0002 /* scheduling debug mask */
+#define DPROC 0x0004 /* process control debug mask */
+#define DPARS 0x0008 /* parsing debug mask */
+#define DLOAD 0x0010 /* database loading debug mask */
+#define DMISC 0x0020 /* misc debug mask */
+#define DTEST 0x0040 /* test mode: don't execute any commands */
+#define DBIT 0x0080 /* bit twiddling shown (long) */
+
+#define CRON_TAB(u) "%s/%s", SPOOL_DIR, u
+#define PPC_NULL ((const char **)NULL)
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 256
+#endif
+
+#define Skip_Blanks(c, f) \
+ while (c == '\t' || c == ' ') \
+ c = get_char(f);
+
+#define Skip_Nonblanks(c, f) \
+ while (c!='\t' && c!=' ' && c!='\n' && c != EOF) \
+ c = get_char(f);
+
+#define Skip_Line(c, f) \
+ do {c = get_char(f);} while (c != '\n' && c != EOF);
+
+#if DEBUGGING
+# define Debug(mask, message) \
+ if ( (DebugFlags & (mask) ) == (mask) ) \
+ printf message;
+#else /* !DEBUGGING */
+# define Debug(mask, message) \
+ ;
+#endif /* DEBUGGING */
+
+#define MkLower(ch) (isupper(ch) ? tolower(ch) : ch)
+#define MkUpper(ch) (islower(ch) ? toupper(ch) : ch)
+#define Set_LineNum(ln) {Debug(DPARS|DEXT,("linenum=%d\n",ln)); \
+ LineNumber = ln; \
+ }
+
+#define FIRST_SECOND 0
+#define LAST_SECOND 59
+#define SECOND_COUNT (LAST_SECOND - FIRST_SECOND + 1)
+
+#define FIRST_MINUTE 0
+#define LAST_MINUTE 59
+#define MINUTE_COUNT (LAST_MINUTE - FIRST_MINUTE + 1)
+
+#define FIRST_HOUR 0
+#define LAST_HOUR 23
+#define HOUR_COUNT (LAST_HOUR - FIRST_HOUR + 1)
+
+#define FIRST_DOM 1
+#define LAST_DOM 31
+#define DOM_COUNT (LAST_DOM - FIRST_DOM + 1)
+
+#define FIRST_MONTH 1
+#define LAST_MONTH 12
+#define MONTH_COUNT (LAST_MONTH - FIRST_MONTH + 1)
+
+/* note on DOW: 0 and 7 are both Sunday, for compatibility reasons. */
+#define FIRST_DOW 0
+#define LAST_DOW 7
+#define DOW_COUNT (LAST_DOW - FIRST_DOW + 1)
+
+#ifdef LOGIN_CAP
+/* see init.c */
+#define RESOURCE_RC "daemon"
+#endif
+
+ /* each user's crontab will be held as a list of
+ * the following structure.
+ *
+ * These are the cron commands.
+ */
+
diff --git a/usr.sbin/cron/cron/pathnames.h b/usr.sbin/cron/cron/pathnames.h
index b0edbd897a28..2906d8728692 100644
--- a/usr.sbin/cron/cron/pathnames.h
+++ b/usr.sbin/cron/cron/pathnames.h
@@ -1,28 +1,28 @@
/* Copyright 1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
/*
- * $FreeBSD$
+ * $Id: pathnames.h,v 1.4 1998/08/14 00:32:41 vixie Exp $
*/
-#if (defined(BSD)) && (BSD >= 199103) || defined(__linux) || defined(AIX)
-# include <paths.h>
-#endif /*BSD*/
-
#ifndef CRONDIR
/* CRONDIR is where crond(8) and crontab(1) both chdir
* to; SPOOL_DIR, ALLOW_FILE, DENY_FILE, and LOG_FILE
@@ -45,16 +45,18 @@
* that ALLOW_FILE and DENY_FILE must both be defined
* in order to enable the allow/deny code. If neither
* LOG_FILE or SYSLOG is defined, we don't log. If
- * both are defined, we log both ways.
+ * both are defined, we log both ways. Note that if
+ * LOG_CRON is defined by <syslog.h>, LOG_FILE will not
+ * be used.
*/
-#define ALLOW_FILE "allow" /*-*/
-#define DENY_FILE "deny" /*-*/
-/*#define LOG_FILE "log"*/ /*-*/
+#define ALLOW_FILE "allow"
+#define DENY_FILE "deny"
+#define LOG_FILE "log"
/* where should the daemon stick its PID?
*/
#define PIDDIR _PATH_VARRUN
-#define PIDFILE "%scron.pid"
+#define PIDFILE "cron.pid"
/* 4.3BSD-style crontab */
#define SYSCRONTAB "/etc/crontab"
diff --git a/usr.sbin/cron/cron/popen.c b/usr.sbin/cron/cron/popen.c
index 44aaa0c990f6..72d4afc4d1f3 100644
--- a/usr.sbin/cron/cron/popen.c
+++ b/usr.sbin/cron/cron/popen.c
@@ -24,25 +24,15 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)popen.c 5.7 (Berkeley) 2/14/89";
-#endif
static const char rcsid[] =
- "$FreeBSD$";
+ "$Id: popen.c,v 1.3 1998/08/14 00:32:41 vixie Exp $";
#endif /* not lint */
#include "cron.h"
-#include <sys/signal.h>
-#include <fcntl.h>
-#include <paths.h>
-#if defined(SYSLOG)
-# include <syslog.h>
-#endif
#if defined(LOGIN_CAP)
# include <login_cap.h>
#endif
-
#define MAX_ARGS 100
#define WANT_GLOBBING 0
@@ -55,12 +45,9 @@ static PID_T *pids;
static int fds;
FILE *
-cron_popen(program, type, e, pidptr)
- char *program, *type;
- entry *e;
- PID_T *pidptr;
+cron_popen(char *program, char *type, entry *e, PID_T *pidptr)
{
- register char *cp;
+ char *cp;
FILE *iop;
int argc, pdes[2];
PID_T pid;
@@ -77,17 +64,17 @@ cron_popen(program, type, e, pidptr)
extern char **glob(), **copyblk();
#endif
- if ((*type != 'r' && *type != 'w') || type[1])
- return(NULL);
+ if ((*type != 'r' && *type != 'w') || type[1] != '\0')
+ return (NULL);
if (!pids) {
- if ((fds = getdtablesize()) <= 0)
- return(NULL);
+ if ((fds = sysconf(_SC_OPEN_MAX)) <= 0)
+ return (NULL);
if (!(pids = calloc(fds, sizeof(PID_T))))
- return(NULL);
+ return (NULL);
}
if (pipe(pdes) < 0)
- return(NULL);
+ return (NULL);
/* break up string into pieces */
for (argc = 0, cp = program; argc < MAX_ARGS; cp = NULL)
@@ -222,14 +209,13 @@ pfree:
*pidptr = pid;
- return(iop);
+ return (iop);
}
int
-cron_pclose(iop)
- FILE *iop;
+cron_pclose(FILE *iop)
{
- register int fdes;
+ int fdes;
int omask;
WAIT_T stat_loc;
PID_T pid;
@@ -239,7 +225,7 @@ cron_pclose(iop)
* `popened' command, or, if already `pclosed'.
*/
if (pids == 0 || pids[fdes = fileno(iop)] == 0)
- return(-1);
+ return (-1);
(void)fclose(iop);
omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
while ((pid = wait(&stat_loc)) != pids[fdes] && pid != -1)
diff --git a/usr.sbin/cron/cron/structs.h b/usr.sbin/cron/cron/structs.h
new file mode 100644
index 000000000000..c9644e95064d
--- /dev/null
+++ b/usr.sbin/cron/cron/structs.h
@@ -0,0 +1,81 @@
+/*
+ * $Id: structs.h,v 1.1 1998/08/14 00:31:24 vixie Exp $
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+typedef struct _entry {
+ struct _entry *next;
+ uid_t uid;
+ gid_t gid;
+#ifdef LOGIN_CAP
+ char *class;
+#endif
+ char **envp;
+ char *cmd;
+ union {
+ struct {
+ bitstr_t bit_decl(second, SECOND_COUNT);
+ bitstr_t bit_decl(minute, MINUTE_COUNT);
+ bitstr_t bit_decl(hour, HOUR_COUNT);
+ bitstr_t bit_decl(dom, DOM_COUNT);
+ bitstr_t bit_decl(month, MONTH_COUNT);
+ bitstr_t bit_decl(dow, DOW_COUNT);
+ };
+ struct {
+ time_t lastexit;
+ time_t interval;
+ pid_t child;
+ };
+ };
+ int flags;
+#define DOM_STAR 0x01
+#define DOW_STAR 0x02
+#define WHEN_REBOOT 0x04
+#define DONT_LOG 0x08
+#define NOT_UNTIL 0x10
+#define SEC_RES 0x20
+#define INTERVAL 0x40
+#define RUN_AT 0x80
+#define MAIL_WHEN_ERR 0x100
+ time_t lastrun;
+} entry;
+
+ /* the crontab database will be a list of the
+ * following structure, one element per user
+ * plus one for the system.
+ *
+ * These are the crontabs.
+ */
+
+typedef struct _user {
+ struct _user *next, *prev; /* links */
+ char *name;
+ time_t mtime; /* last modtime of crontab */
+ entry *crontab; /* this person's crontab */
+} user;
+
+typedef struct _cron_db {
+ user *head, *tail; /* links */
+ time_t mtime; /* last modtime on spooldir */
+} cron_db;
+ /* in the C tradition, we only create
+ * variables for the main program, just
+ * extern them elsewhere.
+ */
+
diff --git a/usr.sbin/cron/cron/user.c b/usr.sbin/cron/cron/user.c
index 16fd61723a86..35c4f684f013 100644
--- a/usr.sbin/cron/cron/user.c
+++ b/usr.sbin/cron/cron/user.c
@@ -1,38 +1,36 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
-#if !defined(lint) && !defined(LINT)
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
/* vix 26jan87 [log is in RCS file]
*/
-
#include "cron.h"
static char *User_name;
void
-free_user(u)
- user *u;
+free_user(user *u)
{
- entry *e, *ne;
+ entry *e, *ne;
free(u->name);
for (e = u->crontab; e != NULL; e = ne) {
@@ -43,28 +41,25 @@ free_user(u)
}
static void
-log_error(msg)
- char *msg;
+log_error(const char *msg)
{
log_it(User_name, getpid(), "PARSE", msg);
}
+/* NULL pw implies syscrontab */
user *
-load_user(crontab_fd, pw, name)
- int crontab_fd;
- struct passwd *pw; /* NULL implies syscrontab */
- char *name;
+load_user(int crontab_fd, struct passwd *pw, const char *name)
{
- char envstr[MAX_ENVSTR];
- FILE *file;
- user *u;
- entry *e;
- int status;
- char **envp, **tenvp;
+ char envstr[MAX_ENVSTR];
+ FILE *file;
+ user *u;
+ entry *e;
+ int status;
+ char **envp, **tenvp;
if (!(file = fdopen(crontab_fd, "r"))) {
warn("fdopen on crontab_fd in load_user");
- return NULL;
+ return (NULL);
}
Debug(DPARS, ("load_user()\n"))
@@ -73,12 +68,12 @@ load_user(crontab_fd, pw, name)
*/
if ((u = (user *) malloc(sizeof(user))) == NULL) {
errno = ENOMEM;
- return NULL;
+ return (NULL);
}
if ((u->name = strdup(name)) == NULL) {
free(u);
errno = ENOMEM;
- return NULL;
+ return (NULL);
}
u->crontab = NULL;
@@ -88,7 +83,7 @@ load_user(crontab_fd, pw, name)
if ((envp = env_init()) == NULL) {
free(u->name);
free(u);
- return NULL;
+ return (NULL);
}
/*
@@ -124,5 +119,5 @@ load_user(crontab_fd, pw, name)
env_free(envp);
fclose(file);
Debug(DPARS, ("...load_user() done\n"))
- return u;
+ return (u);
}
diff --git a/usr.sbin/cron/crontab/Makefile b/usr.sbin/cron/crontab/Makefile
index 7b780edc80e3..7b4901b7a281 100644
--- a/usr.sbin/cron/crontab/Makefile
+++ b/usr.sbin/cron/crontab/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
BINDIR= /usr/bin
diff --git a/usr.sbin/cron/crontab/Makefile.depend b/usr.sbin/cron/crontab/Makefile.depend
index cfb82e7beff4..e1fa9e85dcb0 100644
--- a/usr.sbin/cron/crontab/Makefile.depend
+++ b/usr.sbin/cron/crontab/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/cron/crontab/crontab.1 b/usr.sbin/cron/crontab/crontab.1
index f4792bf78cc4..3919486c7c71 100644
--- a/usr.sbin/cron/crontab/crontab.1
+++ b/usr.sbin/cron/crontab/crontab.1
@@ -1,21 +1,23 @@
.\"/* Copyright 1988,1990,1993 by Paul Vixie
.\" * All rights reserved
-.\" *
-.\" * Distribute freely, except: don't remove my name from the source or
-.\" * documentation (don't take credit for my work), mark your changes (don't
-.\" * get me blamed for your possible bugs), don't alter or remove this
-.\" * notice. May be sold if buildable source is provided to buyer. No
-.\" * warrantee of any kind, express or implied, is included with this
-.\" * software; use at your own risk, responsibility for damages (if any) to
-.\" * anyone resulting from the use of this software rests entirely with the
-.\" * user.
-.\" *
-.\" * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
-.\" * I'll try to keep a version up to date. I can be reached as follows:
-.\" * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
.\" */
.\"
-.\" $FreeBSD$
+.\"Copyright (c) 1997 by Internet Software Consortium
+.\"
+.\"Permission to use, copy, modify, and distribute this software for any
+.\"purpose with or without fee is hereby granted, provided that the above
+.\"copyright notice and this permission notice appear in all copies.
+.\"
+.\"THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+.\"ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+.\"OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+.\"CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+.\"DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+.\"PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+.\"ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+.\"SOFTWARE.
+.\"
+.\" $Id: crontab.1,v 1.2 1998/08/14 00:32:37 vixie Exp $
.\"
.Dd December 20, 2016
.Dt CRONTAB 1
@@ -44,7 +46,7 @@ used to drive the
daemon in Vixie Cron.
Each user can have their own crontab, and though
these are files in
-.Pa /var ,
+.Pa /var/cron/tabs ,
they are not intended to be edited directly.
.Pp
If the
diff --git a/usr.sbin/cron/crontab/crontab.5 b/usr.sbin/cron/crontab/crontab.5
index 0e48a0d804f4..12caa45cff46 100644
--- a/usr.sbin/cron/crontab/crontab.5
+++ b/usr.sbin/cron/crontab/crontab.5
@@ -1,21 +1,23 @@
.\"/* Copyright 1988,1990,1993,1994 by Paul Vixie
.\" * All rights reserved
-.\" *
-.\" * Distribute freely, except: don't remove my name from the source or
-.\" * documentation (don't take credit for my work), mark your changes (don't
-.\" * get me blamed for your possible bugs), don't alter or remove this
-.\" * notice. May be sold if buildable source is provided to buyer. No
-.\" * warrantee of any kind, express or implied, is included with this
-.\" * software; use at your own risk, responsibility for damages (if any) to
-.\" * anyone resulting from the use of this software rests entirely with the
-.\" * user.
-.\" *
-.\" * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
-.\" * I'll try to keep a version up to date. I can be reached as follows:
-.\" * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
.\" */
.\"
-.\" $FreeBSD$
+.\"Copyright (c) 1997 by Internet Software Consortium
+.\"
+.\"Permission to use, copy, modify, and distribute this software for any
+.\"purpose with or without fee is hereby granted, provided that the above
+.\"copyright notice and this permission notice appear in all copies.
+.\"
+.\"THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+.\"ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+.\"OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+.\"CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+.\"DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+.\"PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+.\"ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+.\"SOFTWARE.
+.\"
+.\" $Id: crontab.5,v 1.2 1998/08/14 00:32:38 vixie Exp $
.\"
.Dd March 29, 2020
.Dt CRONTAB 5
diff --git a/usr.sbin/cron/crontab/crontab.c b/usr.sbin/cron/crontab/crontab.c
index 53c58403406a..0975a2ae8c79 100644
--- a/usr.sbin/cron/crontab/crontab.c
+++ b/usr.sbin/cron/crontab/crontab.c
@@ -1,24 +1,27 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
- * From Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
#if !defined(lint) && !defined(LINT)
static const char rcsid[] =
- "$FreeBSD$";
+ "$Id: crontab.c,v 1.3 1998/08/14 00:32:38 vixie Exp $";
#endif
/* crontab - install and manage per-user crontab files
@@ -28,35 +31,18 @@ static const char rcsid[] =
#define MAIN_PROGRAM
-#include <sys/param.h>
#include "cron.h"
-#include <errno.h>
-#include <fcntl.h>
#include <md5.h>
-#include <paths.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#ifdef USE_UTIMES
-# include <sys/time.h>
-#else
-# include <time.h>
-# include <utime.h>
-#endif
-#if defined(POSIX)
-# include <locale.h>
-#endif
#define MD5_SIZE 33
#define NHEADER_LINES 3
-
enum opt_t { opt_unknown, opt_list, opt_delete, opt_edit, opt_replace };
#if DEBUGGING
static char *Options[] = { "???", "list", "delete", "edit", "replace" };
#endif
-
static PID_T Pid;
static char User[MAXLOGNAME], RealUser[MAXLOGNAME];
static char Filename[MAX_FNAME];
@@ -69,13 +55,12 @@ static void list_cmd(void),
delete_cmd(void),
edit_cmd(void),
poke_daemon(void),
- check_error(char *),
+ check_error(const char *),
parse_args(int c, char *v[]);
static int replace_cmd(void);
-
static void
-usage(char *msg)
+usage(const char *msg)
{
fprintf(stderr, "crontab: usage error: %s\n", msg);
fprintf(stderr, "%s\n%s\n",
@@ -84,7 +69,6 @@ usage(char *msg)
exit(ERROR_EXIT);
}
-
int
main(int argc, char *argv[])
{
@@ -93,9 +77,7 @@ main(int argc, char *argv[])
Pid = getpid();
ProgramName = argv[0];
-#if defined(POSIX)
setlocale(LC_ALL, "");
-#endif
#if defined(BSD)
setlinebuf(stderr);
@@ -110,30 +92,32 @@ main(int argc, char *argv[])
}
exitstatus = OK_EXIT;
switch (Option) {
- case opt_list: list_cmd();
- break;
- case opt_delete: delete_cmd();
- break;
- case opt_edit: edit_cmd();
- break;
- case opt_replace: if (replace_cmd() < 0)
- exitstatus = ERROR_EXIT;
- break;
+ case opt_list:
+ list_cmd();
+ break;
+ case opt_delete:
+ delete_cmd();
+ break;
+ case opt_edit:
+ edit_cmd();
+ break;
+ case opt_replace:
+ if (replace_cmd() < 0)
+ exitstatus = ERROR_EXIT;
+ break;
case opt_unknown:
- break;
+ default:
+ abort();
}
exit(exitstatus);
/*NOTREACHED*/
}
-
static void
-parse_args(argc, argv)
- int argc;
- char *argv[];
+parse_args(int argc, char *argv[])
{
- int argch;
- char resolved_path[PATH_MAX];
+ int argch;
+ char resolved_path[PATH_MAX];
if (!(pw = getpwuid(getuid())))
errx(ERROR_EXIT, "your UID isn't in the passwd file, bailing out");
@@ -232,13 +216,14 @@ parse_args(argc, argv)
}
static void
-copy_file(FILE *in, FILE *out) {
- int x, ch;
+copy_file(FILE *in, FILE *out)
+{
+ int x, ch;
Set_LineNum(1)
/* ignore the top few comments since we probably put them there.
*/
- for (x = 0; x < NHEADER_LINES; x++) {
+ for (x = 0; x < NHEADER_LINES; x++) {
ch = get_char(in);
if (EOF == ch)
break;
@@ -261,9 +246,10 @@ copy_file(FILE *in, FILE *out) {
}
static void
-list_cmd() {
- char n[MAX_FNAME];
- FILE *f;
+list_cmd(void)
+{
+ char n[MAX_FNAME];
+ FILE *f;
log_it(RealUser, Pid, "LIST", User);
(void) snprintf(n, sizeof(n), CRON_TAB(User));
@@ -280,10 +266,10 @@ list_cmd() {
fclose(f);
}
-
static void
-delete_cmd() {
- char n[MAX_FNAME];
+delete_cmd(void)
+{
+ char n[MAX_FNAME];
int ch, first;
if (!fflag && isatty(STDIN_FILENO)) {
@@ -296,8 +282,9 @@ delete_cmd() {
}
log_it(RealUser, Pid, "DELETE", User);
- (void) snprintf(n, sizeof(n), CRON_TAB(User));
- if (unlink(n)) {
+ if (snprintf(n, sizeof(n), CRON_TAB(User)) >= (int)sizeof(n))
+ errx(ERROR_EXIT, "path too long");
+ if (unlink(n) != 0) {
if (errno == ENOENT)
errx(ERROR_EXIT, "no crontab for %s", User);
else
@@ -306,31 +293,30 @@ delete_cmd() {
poke_daemon();
}
-
static void
-check_error(msg)
- char *msg;
+check_error(const char *msg)
{
CheckErrorCount++;
fprintf(stderr, "\"%s\":%d: %s\n", Filename, LineNumber-1, msg);
}
-
static void
-edit_cmd() {
- char n[MAX_FNAME], q[MAX_TEMPSTR], *editor;
- FILE *f;
- int t;
- struct stat statbuf, fsbuf;
- WAIT_T waiter;
- PID_T pid, xpid;
- mode_t um;
- int syntax_error = 0;
- char orig_md5[MD5_SIZE];
- char new_md5[MD5_SIZE];
+edit_cmd(void)
+{
+ char n[MAX_FNAME], q[MAX_TEMPSTR], *editor;
+ FILE *f;
+ int t;
+ struct stat statbuf, fsbuf;
+ WAIT_T waiter;
+ PID_T pid, xpid;
+ mode_t um;
+ int syntax_error = 0;
+ char orig_md5[MD5_SIZE];
+ char new_md5[MD5_SIZE];
log_it(RealUser, Pid, "BEGIN EDIT", User);
- (void) snprintf(n, sizeof(n), CRON_TAB(User));
+ if (snprintf(n, sizeof(n), CRON_TAB(User)) >= (int)sizeof(n))
+ errx(ERROR_EXIT, "path too long");
if (!(f = fopen(n, "r"))) {
if (errno != ENOENT)
err(ERROR_EXIT, "%s", n);
@@ -373,7 +359,8 @@ edit_cmd() {
err(ERROR_EXIT, "swapping uids");
if (stat(Filename, &statbuf) < 0) {
warn("stat");
- fatal: unlink(Filename);
+ fatal:
+ unlink(Filename);
exit(ERROR_EXIT);
}
if (swap_uids_back() < OK)
@@ -385,9 +372,8 @@ edit_cmd() {
goto fatal;
}
- if ((!(editor = getenv("VISUAL")))
- && (!(editor = getenv("EDITOR")))
- ) {
+ if ((editor = getenv("VISUAL")) == NULL &&
+ (editor = getenv("EDITOR")) == NULL) {
editor = EDITOR;
}
@@ -502,13 +488,14 @@ edit_cmd() {
* -2 on install error
*/
static int
-replace_cmd() {
- char n[MAX_FNAME], envstr[MAX_ENVSTR], tn[MAX_FNAME];
- FILE *tmp;
- int ch, eof;
- entry *e;
- time_t now = time(NULL);
- char **envp = env_init();
+replace_cmd(void)
+{
+ char n[MAX_FNAME], envstr[MAX_ENVSTR], tn[MAX_FNAME];
+ FILE *tmp;
+ int ch, eof;
+ entry *e;
+ time_t now = time(NULL);
+ char **envp = env_init();
if (envp == NULL) {
warnx("cannot allocate memory");
@@ -516,7 +503,10 @@ replace_cmd() {
}
(void) snprintf(n, sizeof(n), "tmp.%d", Pid);
- (void) snprintf(tn, sizeof(tn), CRON_TAB(n));
+ if (snprintf(tn, sizeof(tn), CRON_TAB(n)) >= (int)sizeof(tn)) {
+ warnx("path too long");
+ return (-2);
+ }
if (!(tmp = fopen(tn, "w+"))) {
warn("%s", tn);
@@ -604,7 +594,12 @@ replace_cmd() {
return (-2);
}
- (void) snprintf(n, sizeof(n), CRON_TAB(User));
+ if (snprintf(n, sizeof(n), CRON_TAB(User)) >= (int)sizeof(n)) {
+ warnx("path too long");
+ unlink(tn);
+ return (-2);
+ }
+
if (rename(tn, n)) {
warn("error renaming %s to %s", tn, n);
unlink(tn);
@@ -627,22 +622,11 @@ replace_cmd() {
return (0);
}
-
static void
-poke_daemon() {
-#ifdef USE_UTIMES
- struct timeval tvs[2];
-
- (void)gettimeofday(&tvs[0], NULL);
- tvs[1] = tvs[0];
- if (utimes(SPOOL_DIR, tvs) < OK) {
- warn("can't update mtime on spooldir %s", SPOOL_DIR);
- return;
- }
-#else
+poke_daemon(void)
+{
if (utime(SPOOL_DIR, NULL) < OK) {
warn("can't update mtime on spooldir %s", SPOOL_DIR);
return;
}
-#endif /*USE_UTIMES*/
}
diff --git a/usr.sbin/cron/doc/CHANGES b/usr.sbin/cron/doc/CHANGES
index ed52a65fe9ed..84146a59b2be 100644
--- a/usr.sbin/cron/doc/CHANGES
+++ b/usr.sbin/cron/doc/CHANGES
@@ -1,4 +1,3 @@
-$FreeBSD$
--------
Vixie Cron Changes from V2 to V3
diff --git a/usr.sbin/cron/doc/CONVERSION b/usr.sbin/cron/doc/CONVERSION
index f30df7d19750..6067650fa683 100644
--- a/usr.sbin/cron/doc/CONVERSION
+++ b/usr.sbin/cron/doc/CONVERSION
@@ -1,4 +1,3 @@
-$FreeBSD$
Conversion of BSD 4.[23] crontab files:
diff --git a/usr.sbin/cron/doc/FEATURES b/usr.sbin/cron/doc/FEATURES
index 821d1f3a3af2..71b1486a8e01 100644
--- a/usr.sbin/cron/doc/FEATURES
+++ b/usr.sbin/cron/doc/FEATURES
@@ -1,4 +1,3 @@
-$FreeBSD$
Features of Vixie's cron relative to BSD 4.[23] and SysV crons:
diff --git a/usr.sbin/cron/doc/INSTALL b/usr.sbin/cron/doc/INSTALL
index 7f4c9974da64..326be482dd71 100644
--- a/usr.sbin/cron/doc/INSTALL
+++ b/usr.sbin/cron/doc/INSTALL
@@ -1,21 +1,25 @@
/* Copyright 1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
-$FreeBSD$
+$Id: INSTALL,v 1.2 1998/08/14 00:32:35 vixie Exp $
Read the comments at the top of the Makefile, then edit the area marked
'configurable stuff'.
diff --git a/usr.sbin/cron/doc/MAIL b/usr.sbin/cron/doc/MAIL
index b4aa96b6aee2..149e5527171c 100644
--- a/usr.sbin/cron/doc/MAIL
+++ b/usr.sbin/cron/doc/MAIL
@@ -3,8 +3,6 @@
version of cron. it is presented here for its entertainment value.
--vix ]
-$FreeBSD$
-
From ptsfa!lll-crg!ames!acornrc!bob Wed Dec 31 10:07:08 1986
Date: Wed, 31 Dec 86 08:59:31 pst
From: lll-crg!ames!acornrc!bob (Bob Weissman)
diff --git a/usr.sbin/cron/doc/Makefile.vixie b/usr.sbin/cron/doc/Makefile.vixie
index 8df1301c689d..53b8e9b9bcc5 100644
--- a/usr.sbin/cron/doc/Makefile.vixie
+++ b/usr.sbin/cron/doc/Makefile.vixie
@@ -1,23 +1,25 @@
#/* Copyright 1988,1990,1993,1994 by Paul Vixie
# * All rights reserved
-# *
-# * Distribute freely, except: don't remove my name from the source or
-# * documentation (don't take credit for my work), mark your changes (don't
-# * get me blamed for your possible bugs), don't alter or remove this
-# * notice. May be sold if buildable source is provided to buyer. No
-# * warrantee of any kind, express or implied, is included with this
-# * software; use at your own risk, responsibility for damages (if any) to
-# * anyone resulting from the use of this software rests entirely with the
-# * user.
-# *
-# * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
-# * I'll try to keep a version up to date. I can be reached as follows:
-# * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
# */
+## Copyright (c) 1997 by Internet Software Consortium.
+##
+## Permission to use, copy, modify, and distribute this software for any
+## purpose with or without fee is hereby granted, provided that the above
+## copyright notice and this permission notice appear in all copies.
+##
+## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+## SOFTWARE.
+
# Makefile for vixie's cron
#
-# $FreeBSD$
+# $Id: Makefile,v 1.2 1998/08/14 00:32:35 vixie Exp $
#
# vix 03mar88 [moved to RCS, rest of log is in there]
# vix 30mar87 [goodbye, time.c; hello, getopt]
@@ -35,7 +37,7 @@
# SHELL is for the 'augumented make' systems where 'make' imports
# SHELL from the environment and then uses it to run its commands.
# if your environment SHELL variable is /bin/csh, make goes real
-# slow and sometimes does the wrong thing.
+# slow and sometimes does the wrong thing.
#
# this package needs the 'bitstring macros' library, which is
# available from me or from the comp.sources.unix archive. if you
@@ -57,19 +59,12 @@ INCLUDE = -I.
#<<need getopt()>>
LIBS =
#<<optimize or debug?>>
-#OPTIM = -O
-OPTIM = -g
-#<<ATT or BSD or POSIX?>>
-# (ATT untested)
-#COMPAT = -DATT
-#(BSD is only needed if <sys/params.h> does not define it, as on ULTRIX)
-#COMPAT = -DBSD
-# (POSIX)
-#COMPAT = -DPOSIX
+#CDEBUG = -O
+CDEBUG = -g
#<<lint flags of choice?>>
-LINTFLAGS = -hbxa $(INCLUDE) $(COMPAT) $(DEBUGGING)
+LINTFLAGS = -hbxa $(INCLUDE) $(DEBUGGING)
#<<want to use a nonstandard CC?>>
-#CC = vcc
+CC = gcc -Wall -Wno-unused -Wno-comment
#<<manifest defines>>
DEFS =
#(SGI IRIX systems need this)
@@ -82,21 +77,20 @@ LDFLAGS =
#################################### end configurable stuff
SHELL = /bin/sh
-CFLAGS = $(OPTIM) $(INCLUDE) $(COMPAT) $(DEFS)
+CFLAGS = $(CDEBUG) $(INCLUDE) $(DEFS)
INFOS = README CHANGES FEATURES INSTALL CONVERSION THANKS MAIL
MANPAGES = bitstring.3 crontab.5 crontab.1 cron.8 putman.sh
-HEADERS = bitstring.h cron.h config.h pathnames.h \
- externs.h compat.h
+HEADERS = bitstring.h cron.h config.h pathnames.h externs.h
SOURCES = cron.c crontab.c database.c do_command.c entry.c \
- env.c job.c user.c popen.c misc.c compat.c
+ env.c job.c user.c popen.c misc.c
SHAR_SOURCE = $(INFOS) $(MANPAGES) Makefile $(HEADERS) $(SOURCES)
-LINT_CRON = cron.c database.c user.c entry.c compat.c \
+LINT_CRON = cron.c database.c user.c entry.c \
misc.c job.c do_command.c env.c popen.c
-LINT_CRONTAB = crontab.c misc.c entry.c env.c compat.c
+LINT_CRONTAB = crontab.c misc.c entry.c env.c
CRON_OBJ = cron.o database.o user.o entry.o job.o do_command.o \
- misc.o env.o popen.o compat.o
-CRONTAB_OBJ = crontab.o misc.o entry.o env.o compat.o
+ misc.o env.o popen.o
+CRONTAB_OBJ = crontab.o misc.o entry.o env.o
all : cron crontab
@@ -121,8 +115,10 @@ install : all
clean :; rm -f *.o cron crontab a.out core tags *~ #*
+tags :; ctags ${SOURCES}
+
kit : $(SHAR_SOURCE)
makekit -m -s99k $(SHAR_SOURCE)
-$(CRON_OBJ) : cron.h compat.h config.h externs.h pathnames.h Makefile
-$(CRONTAB_OBJ) : cron.h compat.h config.h externs.h pathnames.h Makefile
+$(CRON_OBJ) : cron.h config.h externs.h pathnames.h Makefile
+$(CRONTAB_OBJ) : cron.h config.h externs.h pathnames.h Makefile
diff --git a/usr.sbin/cron/doc/README b/usr.sbin/cron/doc/README
index eaced9e65d94..ebd8849a52a0 100644
--- a/usr.sbin/cron/doc/README
+++ b/usr.sbin/cron/doc/README
@@ -1,22 +1,25 @@
-#/* Copyright 1988,1990,1993 by Paul Vixie
+#/* Copyright 1988,1990,1993 by Paul Vixie <paul@vix.com>
# * All rights reserved
-# *
-# * Distribute freely, except: don't remove my name from the source or
-# * documentation (don't take credit for my work), mark your changes (don't
-# * get me blamed for your possible bugs), don't alter or remove this
-# * notice. May be sold if buildable source is provided to buyer. No
-# * warrantee of any kind, express or implied, is included with this
-# * software; use at your own risk, responsibility for damages (if any) to
-# * anyone resulting from the use of this software rests entirely with the
-# * user.
-# *
-# * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
-# * I'll try to keep a version up to date. I can be reached as follows:
-# * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
# */
-Vixie Cron V3.0
-December 27, 1993
+## Copyright (c) 1997 by Internet Software Consortium.
+##
+## Permission to use, copy, modify, and distribute this software for any
+## purpose with or without fee is hereby granted, provided that the above
+## copyright notice and this permission notice appear in all copies.
+##
+## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+## SOFTWARE.
+
+Vixie Cron V4.0 - September 7, 1997
+[V3.1 was some time after 1993]
+[V3.0 was December 27, 1993]
[V2.2 was some time in 1992]
[V2.1 was May 29, 1991]
[V2.0 was July 5, 1990]
@@ -24,7 +27,7 @@ December 27, 1993
[V1.0 was May 6, 1987]
Paul Vixie
-This is a version of 'cron' that is known to run on BSD 4.[23] systems. It
+This is a version of 'cron' that is known to run on most systems. It
is functionally based on the SysV cron, which means that each user can have
their own crontab file (all crontab files are stored in a read-protected
directory, usually /var/cron/tabs). No direct support is provided for
@@ -36,13 +39,6 @@ A messages is logged each time a command is executed; also, the files
"crontab" command (which installs crontabs). It hasn't been tested on
SysV, although some effort has gone into making the port an easy one.
-This is more or less the copyright that USENET contributed software usually
-has. Since ATT couldn't use this version if they had to freely distribute
-source, and since I'd love to see them use it, I'll offer some rediculously
-low license fee just to have them take it. In the unlikely event that they
-do this, I will continue to support and distribute the pseudo-PD version, so
-please, don't flame me for wanting my work to see a wider distribution.
-
To use this: Sorry, folks, there is no cutesy 'Configure' script. You'll
have to go edit a couple of files... So, here's the checklist:
@@ -69,4 +65,4 @@ have to go edit a couple of files... So, here's the checklist:
if you like it, change your /etc/{rc,rc.local} to use it instead of
the old one.
-$FreeBSD$
+$Id: README,v 1.2 1998/08/14 00:32:35 vixie Exp $
diff --git a/usr.sbin/cron/lib/Makefile b/usr.sbin/cron/lib/Makefile
index d8203c5a4df7..cf41f2e72d2c 100644
--- a/usr.sbin/cron/lib/Makefile
+++ b/usr.sbin/cron/lib/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
LIB= cron
INTERNALLIB=
diff --git a/usr.sbin/cron/lib/Makefile.depend b/usr.sbin/cron/lib/Makefile.depend
index cf2961c09880..217d6b6b7bd8 100644
--- a/usr.sbin/cron/lib/Makefile.depend
+++ b/usr.sbin/cron/lib/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/cron/lib/compat.c b/usr.sbin/cron/lib/compat.c
deleted file mode 100644
index 3cdbae920d47..000000000000
--- a/usr.sbin/cron/lib/compat.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/* Copyright 1988,1990,1993,1994 by Paul Vixie
- * All rights reserved
- *
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
- *
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
- */
-
-#if !defined(lint) && !defined(LINT)
-static char rcsid[] = "$FreeBSD$";
-#endif
-
-/* vix 30dec93 [broke this out of misc.c - see RCS log for history]
- * vix 15jan87 [added TIOCNOTTY, thanks csg@pyramid]
- */
-
-
-#include "cron.h"
-#ifdef NEED_GETDTABLESIZE
-# include <limits.h>
-#endif
-#if defined(NEED_SETSID) && defined(BSD)
-# include <sys/ioctl.h>
-#endif
-#include <errno.h>
-#include <paths.h>
-
-
-#ifdef NEED_STRDUP
-char *
-strdup(str)
- char *str;
-{
- char *temp;
-
- if ((temp = malloc(strlen(str) + 1)) == NULL) {
- errno = ENOMEM;
- return NULL;
- }
- (void) strcpy(temp, str);
- return temp;
-}
-#endif
-
-
-#ifdef NEED_STRERROR
-char *
-strerror(error)
- int error;
-{
- extern char *sys_errlist[];
- extern int sys_nerr;
- static char buf[32];
-
- if ((error <= sys_nerr) && (error > 0)) {
- return sys_errlist[error];
- }
-
- sprintf(buf, "Unknown error: %d", error);
- return buf;
-}
-#endif
-
-
-#ifdef NEED_STRCASECMP
-int
-strcasecmp(left, right)
- char *left;
- char *right;
-{
- while (*left && (MkLower(*left) == MkLower(*right))) {
- left++;
- right++;
- }
- return MkLower(*left) - MkLower(*right);
-}
-#endif
-
-
-#ifdef NEED_SETSID
-int
-setsid()
-{
- int newpgrp;
-# if defined(BSD)
- int fd;
-# if defined(POSIX)
- newpgrp = setpgid((pid_t)0, getpid());
-# else
- newpgrp = setpgrp(0, getpid());
-# endif
- if ((fd = open(_PATH_TTY, 2)) >= 0)
- {
- (void) ioctl(fd, TIOCNOTTY, (char*)0);
- (void) close(fd);
- }
-# else /*BSD*/
- newpgrp = setpgrp();
-
- (void) close(STDIN); (void) open(_PATH_DEVNULL, 0);
- (void) close(STDOUT); (void) open(_PATH_DEVNULL, 1);
- (void) close(STDERR); (void) open(_PATH_DEVNULL, 2);
-# endif /*BSD*/
- return newpgrp;
-}
-#endif /*NEED_SETSID*/
-
-
-#ifdef NEED_GETDTABLESIZE
-int
-getdtablesize() {
-#ifdef _SC_OPEN_MAX
- return sysconf(_SC_OPEN_MAX);
-#else
- return _POSIX_OPEN_MAX;
-#endif
-}
-#endif
-
-
-#ifdef NEED_FLOCK
-/* The following flock() emulation snarfed intact *) from the HP-UX
- * "BSD to HP-UX porting tricks" maintained by
- * system@alchemy.chem.utoronto.ca (System Admin (Mike Peterson))
- * from the version "last updated: 11-Jan-1993"
- * Snarfage done by Jarkko Hietaniemi <Jarkko.Hietaniemi@hut.fi>
- * *) well, almost, had to K&R the function entry, HPUX "cc"
- * does not grok ANSI function prototypes */
-
-/*
- * flock (fd, operation)
- *
- * This routine performs some file locking like the BSD 'flock'
- * on the object described by the int file descriptor 'fd',
- * which must already be open.
- *
- * The operations that are available are:
- *
- * LOCK_SH - get a shared lock.
- * LOCK_EX - get an exclusive lock.
- * LOCK_NB - don't block (must be ORed with LOCK_SH or LOCK_EX).
- * LOCK_UN - release a lock.
- *
- * Return value: 0 if lock successful, -1 if failed.
- *
- * Note that whether the locks are enforced or advisory is
- * controlled by the presence or absence of the SETGID bit on
- * the executable.
- *
- * Note that there is no difference between shared and exclusive
- * locks, since the 'lockf' system call in SYSV doesn't make any
- * distinction.
- *
- * The file "<sys/file.h>" should be modified to contain the definitions
- * of the available operations, which must be added manually (see below
- * for the values).
- */
-
-/* this code has been reformatted by vixie */
-
-int
-flock(fd, operation)
- int fd;
- int operation;
-{
- int i;
-
- switch (operation) {
- case LOCK_SH: /* get a shared lock */
- case LOCK_EX: /* get an exclusive lock */
- i = lockf (fd, F_LOCK, 0);
- break;
-
- case LOCK_SH|LOCK_NB: /* get a non-blocking shared lock */
- case LOCK_EX|LOCK_NB: /* get a non-blocking exclusive lock */
- i = lockf (fd, F_TLOCK, 0);
- if (i == -1)
- if ((errno == EAGAIN) || (errno == EACCES))
- errno = EWOULDBLOCK;
- break;
-
- case LOCK_UN: /* unlock */
- i = lockf (fd, F_ULOCK, 0);
- break;
-
- default: /* can't decipher operation */
- i = -1;
- errno = EINVAL;
- break;
- }
-
- return (i);
-}
-#endif /*NEED_FLOCK*/
-
-
-#ifdef NEED_SETENV
-int
-setenv(name, value, overwrite)
- char *name, *value;
- int overwrite;
-{
- char *tmp;
-
- if (overwrite && getenv(name))
- return -1;
-
- if (!(tmp = malloc(strlen(name) + strlen(value) + 2))) {
- errno = ENOMEM;
- return -1;
- }
-
- sprintf(tmp, "%s=%s", name, value);
- return putenv(tmp); /* intentionally orphan 'tmp' storage */
-}
-#endif
diff --git a/usr.sbin/cron/lib/entry.c b/usr.sbin/cron/lib/entry.c
index 2693c9c8d07a..9d9572c56dc8 100644
--- a/usr.sbin/cron/lib/entry.c
+++ b/usr.sbin/cron/lib/entry.c
@@ -1,23 +1,28 @@
-/* Copyright 1988,1990,1993,1994 by Paul Vixie
+/*
+ * Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
#if !defined(lint) && !defined(LINT)
static const char rcsid[] =
- "$FreeBSD$";
+ "$Id: entry.c,v 1.3 1998/08/14 00:32:39 vixie Exp $";
#endif
/* vix 26jan87 [RCS'd; rest of log is in RCS file]
@@ -42,12 +47,7 @@ typedef enum ecode {
#endif
} ecode_e;
-static char get_list(bitstr_t *, int, int, char *[], int, FILE *),
- get_range(bitstr_t *, int, int, char *[], int, FILE *),
- get_number(int *, int, char *[], int, FILE *);
-static int set_element(bitstr_t *, int, int, int);
-
-static char *ecodes[] =
+static const char *ecodes[] =
{
"no error",
"bad minute",
@@ -66,10 +66,13 @@ static char *ecodes[] =
#endif
};
+static char get_list(bitstr_t *, int, int, const char *[], int, FILE *),
+ get_range(bitstr_t *, int, int, const char *[], int, FILE *),
+ get_number(int *, int, const char *[], int, FILE *);
+static int set_element(bitstr_t *, int, int, int);
void
-free_entry(e)
- entry *e;
+free_entry(entry *e)
{
#ifdef LOGIN_CAP
if (e->class != NULL)
@@ -87,11 +90,8 @@ free_entry(e)
* otherwise return a pointer to a new entry.
*/
entry *
-load_entry(file, error_func, pw, envp)
- FILE *file;
- void (*error_func)(char *);
- struct passwd *pw;
- char **envp;
+load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw,
+ char **envp)
{
/* this function reads one crontab entry -- the next -- from a file.
* it skips any leading blank lines, ignores comments, and returns
@@ -109,6 +109,7 @@ load_entry(file, error_func, pw, envp)
ecode_e ecode = e_none;
entry *e;
int ch;
+ int len;
char cmd[MAX_COMMAND];
char envstr[MAX_ENVSTR];
char **prev_env;
@@ -383,10 +384,9 @@ load_entry(file, error_func, pw, envp)
}
if (!env_get("SHELL", e->envp)) {
prev_env = e->envp;
- sprintf(envstr, "SHELL=%s", _PATH_BSHELL);
- e->envp = env_set(e->envp, envstr);
+ e->envp = env_set(e->envp, "SHELL=" _PATH_BSHELL);
if (e->envp == NULL) {
- warn("env_set(%s)", envstr);
+ warn("env_set(%s)", "SHELL=" _PATH_BSHELL);
env_free(prev_env);
ecode = e_mem;
goto eof;
@@ -398,9 +398,10 @@ load_entry(file, error_func, pw, envp)
#ifndef LOGIN_CAP
if (!env_get("HOME", e->envp)) {
prev_env = e->envp;
- sprintf(envstr, "HOME=%s", pw->pw_dir);
- e->envp = env_set(e->envp, envstr);
- if (e->envp == NULL) {
+ len = snprintf(envstr, sizeof(envstr), "HOME=%s", pw->pw_dir);
+ if (len < (int)sizeof(envstr))
+ e->envp = env_set(e->envp, envstr);
+ if (len >= (int)sizeof(envstr) || e->envp == NULL) {
warn("env_set(%s)", envstr);
env_free(prev_env);
ecode = e_mem;
@@ -409,9 +410,10 @@ load_entry(file, error_func, pw, envp)
}
#endif
prev_env = e->envp;
- sprintf(envstr, "%s=%s", "LOGNAME", pw->pw_name);
- e->envp = env_set(e->envp, envstr);
- if (e->envp == NULL) {
+ len = snprintf(envstr, sizeof(envstr), "LOGNAME=%s", pw->pw_name);
+ if (len < (int)sizeof(envstr))
+ e->envp = env_set(e->envp, envstr);
+ if (len >= (int)sizeof(envstr) || e->envp == NULL) {
warn("env_set(%s)", envstr);
env_free(prev_env);
ecode = e_mem;
@@ -419,9 +421,10 @@ load_entry(file, error_func, pw, envp)
}
#if defined(BSD)
prev_env = e->envp;
- sprintf(envstr, "%s=%s", "USER", pw->pw_name);
- e->envp = env_set(e->envp, envstr);
- if (e->envp == NULL) {
+ len = snprintf(envstr, sizeof(envstr), "USER=%s", pw->pw_name);
+ if (len < (int)sizeof(envstr))
+ e->envp = env_set(e->envp, envstr);
+ if (len >= (int)sizeof(envstr) || e->envp == NULL) {
warn("env_set(%s)", envstr);
env_free(prev_env);
ecode = e_mem;
@@ -481,7 +484,6 @@ load_entry(file, error_func, pw, envp)
/* Everything up to the next \n or EOF is part of the command...
* too bad we don't know in advance how long it will be, since we
* need to malloc a string for it... so, we limit it to MAX_COMMAND.
- * XXX - should use realloc().
*/
ch = get_string(cmd, MAX_COMMAND, file, "\n");
@@ -516,15 +518,18 @@ load_entry(file, error_func, pw, envp)
}
+/*
+ * bits one bit per flag, default=FALSE
+ * low, high bounds, impl. offset for bitstr
+ * names NULL or names for these elements
+ * ch current character being processed
+ * file file being read
+ */
static char
-get_list(bits, low, high, names, ch, file)
- bitstr_t *bits; /* one bit per flag, default=FALSE */
- int low, high; /* bounds, impl. offset for bitstr */
- char *names[]; /* NULL or *[] of names for these elements */
- int ch; /* current character being processed */
- FILE *file; /* file being read */
+get_list(bitstr_t *bits, int low, int high, const char *names[], int ch,
+ FILE *file)
{
- register int done;
+ int done;
/* we know that we point to a non-blank character here;
* must do a Skip_Blanks before we exit, so that the
@@ -563,19 +568,21 @@ get_list(bits, low, high, names, ch, file)
}
+/*
+ * bits one bit per flag, default=FALSE
+ * low, high bounds, impl. offset for bitstr
+ * names NULL or names for these elements
+ * ch current character being processed
+ * file file being read
+ */
static char
-get_range(bits, low, high, names, ch, file)
- bitstr_t *bits; /* one bit per flag, default=FALSE */
- int low, high; /* bounds, impl. offset for bitstr */
- char *names[]; /* NULL or names of elements */
- int ch; /* current character being processed */
- FILE *file; /* file being read */
+get_range(bitstr_t *bits, int low, int high, const char *names[], int ch,
+ FILE *file)
{
/* range = number | number "-" number [ "/" number ]
*/
- register int i;
- auto int num1, num2, num3;
+ int i, num1, num2, num3;
Debug(DPARS|DEXT, ("get_range()...entering, exit won't show\n"))
@@ -640,7 +647,7 @@ get_range(bits, low, high, names, ch, file)
/* range. set all elements from num1 to num2, stepping
* by num3. (the step is a downward-compatible extension
* proposed conceptually by bob@acornrc, syntactically
- * designed then implmented by paul vixie).
+ * designed then implemented by paul vixie).
*/
for (i = num1; i <= num2; i += num3)
if (EOF == set_element(bits, low, high, i))
@@ -650,13 +657,15 @@ get_range(bits, low, high, names, ch, file)
}
+/*
+ * numptr where does the result go?
+ * low offset applied to enum result
+ * names symbolic names, if any, for enums
+ * ch current character
+ * file source
+ */
static char
-get_number(numptr, low, names, ch, file)
- int *numptr; /* where does the result go? */
- int low; /* offset applied to result if symbolic enum used */
- char *names[]; /* symbolic names, if any, for enums */
- int ch; /* current character */
- FILE *file; /* source */
+get_number(int *numptr, int low, const char *names[], int ch, FILE *file)
{
char temp[MAX_TEMPSTR], *pc;
int len, i, all_digits;
@@ -708,11 +717,7 @@ get_number(numptr, low, names, ch, file)
static int
-set_element(bits, low, high, number)
- bitstr_t *bits; /* one bit per flag, default=FALSE */
- int low;
- int high;
- int number;
+set_element(bitstr_t *bits, int low, int high, int number)
{
Debug(DPARS|DEXT, ("set_element(?,%d,%d,%d)\n", low, high, number))
diff --git a/usr.sbin/cron/lib/env.c b/usr.sbin/cron/lib/env.c
index fd358176b124..287dd8636293 100644
--- a/usr.sbin/cron/lib/env.c
+++ b/usr.sbin/cron/lib/env.c
@@ -1,33 +1,33 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
-#if !defined(lint) && !defined(LINT)
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
#include "cron.h"
char **
-env_init()
+env_init(void)
{
- register char **p = (char **) malloc(sizeof(char *));
+ char **p = (char **) malloc(sizeof(char **));
if (p)
p[0] = NULL;
@@ -36,8 +36,7 @@ env_init()
void
-env_free(envp)
- char **envp;
+env_free(char **envp)
{
char **p;
@@ -49,11 +48,10 @@ env_free(envp)
char **
-env_copy(envp)
- register char **envp;
+env_copy(char **envp)
{
- register int count, i;
- register char **p;
+ int count, i;
+ char **p;
for (count = 0; envp[count] != NULL; count++)
;
@@ -76,13 +74,11 @@ env_copy(envp)
char **
-env_set(envp, envstr)
- char **envp;
- char *envstr;
+env_set(char **envp, char *envstr)
{
- register int count, found;
- register char **p;
- char *q;
+ int count, found;
+ char **p;
+ char *q;
/*
* count the number of elements, including the null pointer;
@@ -138,9 +134,7 @@ env_set(envp, envstr)
* TRUE = was an env setting
*/
int
-load_env(envstr, f)
- char *envstr;
- FILE *f;
+load_env(char *envstr, FILE *f)
{
long filepos;
int fileline;
@@ -243,23 +237,20 @@ load_env(envstr, f)
/* 2 fields from parser; looks like an env setting */
- if (strlen(name) + 1 + strlen(val) >= MAX_ENVSTR-1)
+ if (snprintf(envstr, MAX_ENVSTR, "%s=%s", name, val) >= MAX_ENVSTR)
return (FALSE);
- (void) sprintf(envstr, "%s=%s", name, val);
Debug(DPARS, ("load_env, <%s> <%s> -> <%s>\n", name, val, envstr))
return (TRUE);
}
char *
-env_get(name, envp)
- register char *name;
- register char **envp;
+env_get(char *name, char **envp)
{
- register int len = strlen(name);
- register char *p, *q;
+ int len = strlen(name);
+ char *p, *q;
- while ((p = *envp++)) {
+ while ((p = *envp++) != NULL) {
if (!(q = strchr(p, '=')))
continue;
if ((q - p) == len && !strncmp(p, name, len))
diff --git a/usr.sbin/cron/lib/misc.c b/usr.sbin/cron/lib/misc.c
index 6a0b8acbd742..a67753cc1ff8 100644
--- a/usr.sbin/cron/lib/misc.c
+++ b/usr.sbin/cron/lib/misc.c
@@ -1,24 +1,24 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
*
- * Distribute freely, except: don't remove my name from the source or
- * documentation (don't take credit for my work), mark your changes (don't
- * get me blamed for your possible bugs), don't alter or remove this
- * notice. May be sold if buildable source is provided to buyer. No
- * warrantee of any kind, express or implied, is included with this
- * software; use at your own risk, responsibility for damages (if any) to
- * anyone resulting from the use of this software rests entirely with the
- * user.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
- * I'll try to keep a version up to date. I can be reached as follows:
- * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
-#if !defined(lint) && !defined(LINT)
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
/* vix 26jan87 [RCS has the rest of the log]
* vix 30dec86 [written]
@@ -33,7 +33,6 @@ static const char rcsid[] =
#endif
#include <sys/file.h>
#include <sys/stat.h>
-#include <err.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
@@ -42,8 +41,12 @@ static const char rcsid[] =
#endif
+#if defined(LOG_CRON) && defined(LOG_FILE)
+# undef LOG_FILE
+#endif
+
#if defined(LOG_DAEMON) && !defined(LOG_CRON)
-#define LOG_CRON LOG_DAEMON
+# define LOG_CRON LOG_DAEMON
#endif
@@ -51,13 +54,8 @@ static int LogFD = ERR;
int
-strcmp_until(left, right, until)
- char *left;
- char *right;
- int until;
+strcmp_until(const char *left, const char *right, int until)
{
- register int diff;
-
while (*left && *left != until && *left == *right) {
left++;
right++;
@@ -65,20 +63,16 @@ strcmp_until(left, right, until)
if ((*left=='\0' || *left == until) &&
(*right=='\0' || *right == until)) {
- diff = 0;
- } else {
- diff = *left - *right;
+ return (0);
}
-
- return diff;
+ return (*left - *right);
}
/* strdtb(s) - delete trailing blanks in string 's' and return new length
*/
int
-strdtb(s)
- char *s;
+strdtb(char *s)
{
char *x = s;
@@ -106,8 +100,7 @@ strdtb(s)
int
-set_debug_flags(flags)
- char *flags;
+set_debug_flags(char *flags)
{
/* debug flags are of the form flag[,flag ...]
*
@@ -127,13 +120,13 @@ set_debug_flags(flags)
DebugFlags = 0;
while (*pc) {
- char **test;
- int mask;
+ const char **test;
+ int mask;
/* try to find debug flag name in our list.
*/
for ( test = DebugFlagNames, mask = 1;
- *test && strcmp_until(*test, pc, ',');
+ *test != NULL && strcmp_until(*test, pc, ',');
test++, mask <<= 1
)
;
@@ -173,7 +166,7 @@ set_debug_flags(flags)
void
-set_cron_uid()
+set_cron_uid(void)
{
#if defined(BSD) || defined(POSIX)
if (seteuid(ROOT_UID) < OK)
@@ -186,7 +179,7 @@ set_cron_uid()
void
-set_cron_cwd()
+set_cron_cwd(void)
{
struct stat sb;
@@ -225,8 +218,7 @@ set_cron_cwd()
/* get_char(file) : like getc() but increment LineNumber on newlines
*/
int
-get_char(file)
- FILE *file;
+get_char(FILE *file)
{
int ch;
@@ -240,9 +232,7 @@ get_char(file)
/* unget_char(ch, file) : like ungetc but do LineNumber processing
*/
void
-unget_char(ch, file)
- int ch;
- FILE *file;
+unget_char(int ch, FILE *file)
{
ungetc(ch, file);
if (ch == '\n')
@@ -257,11 +247,7 @@ unget_char(ch, file)
* (4) returns EOF or terminating character, whichever
*/
int
-get_string(string, size, file, terms)
- char *string;
- int size;
- FILE *file;
- char *terms;
+get_string(char *string, int size, FILE *file, char *terms)
{
int ch;
@@ -282,8 +268,7 @@ get_string(string, size, file, terms)
/* skip_comments(file) : read past comment (if any)
*/
void
-skip_comments(file)
- FILE *file;
+skip_comments(FILE *file)
{
int ch;
@@ -346,8 +331,7 @@ in_file(char *string, FILE *file)
* or (neither file exists but user=="root" so it's okay)
*/
int
-allowed(username)
- char *username;
+allowed(char *username)
{
FILE *allow, *deny;
int isallowed;
@@ -385,19 +369,19 @@ out: if (allow)
void
-log_it(char *username, int xpid, char *event, const char *detail)
+log_it(const char *username, int xpid, const char *event, const char *detail)
{
#if defined(LOG_FILE) || DEBUGGING
- PID_T pid = xpid;
+ PID_T pid = xpid;
#endif
#if defined(LOG_FILE)
- char *msg;
- TIME_T now = time((TIME_T) 0);
- register struct tm *t = localtime(&now);
+ char *msg;
+ TIME_T now = time((TIME_T) 0);
+ struct tm *t = localtime(&now);
#endif /*LOG_FILE*/
#if defined(SYSLOG)
- static int syslog_open = 0;
+ static int syslog_open = 0;
#endif
#if defined(LOG_FILE)
@@ -471,7 +455,8 @@ log_it(char *username, int xpid, char *event, const char *detail)
void
-log_close() {
+log_close(void)
+{
if (LogFD != ERR) {
close(LogFD);
LogFD = ERR;
@@ -482,15 +467,16 @@ log_close() {
/* two warnings:
* (1) this routine is fairly slow
* (2) it returns a pointer to static storage
+ * parameters:
+ * s: string we want the first word of
+ * t: terminators, implicitly including \0
*/
char *
-first_word(s, t)
- register char *s; /* string we want the first word of */
- register char *t; /* terminators, implicitly including \0 */
+first_word(char *s, char *t)
{
static char retbuf[2][MAX_TEMPSTR + 1]; /* sure wish C had GC */
static int retsel = 0;
- register char *rb, *rp;
+ char *rb, *rp;
/* select a return buffer */
retsel = 1-retsel;
@@ -517,11 +503,16 @@ first_word(s, t)
* heavily ascii-dependent.
*/
static void
-mkprint(register char *dst, register unsigned char *src, register int len)
+mkprint(char *dst, unsigned char *src, int len)
{
+ /*
+ * XXX
+ * We know this routine can't overflow the dst buffer because mkprints()
+ * allocated enough space for the worst case.
+ */
while (len-- > 0)
{
- register unsigned char ch = *src++;
+ unsigned char ch = *src++;
if (ch < ' ') { /* control character */
*dst++ = '^';
@@ -544,11 +535,9 @@ mkprint(register char *dst, register unsigned char *src, register int len)
* returns a pointer to malloc'd storage, you must call free yourself.
*/
char *
-mkprints(src, len)
- register unsigned char *src;
- register unsigned int len;
+mkprints(unsigned char *src, unsigned int len)
{
- register char *dst = malloc(len*4 + 1);
+ char *dst = malloc(len*4 + 1);
if (dst != NULL)
mkprint(dst, src, len);
@@ -562,12 +551,11 @@ mkprints(src, len)
* 123456789012345678901234567
*/
char *
-arpadate(clock)
- time_t *clock;
+arpadate(time_t *clock)
{
time_t t = clock ?*clock :time(0L);
struct tm *tm = localtime(&t);
- static char ret[32]; /* zone name might be >3 chars */
+ static char ret[60]; /* zone name might be >3 chars */
if (tm->tm_year >= 100)
tm->tm_year += 1900;
@@ -588,9 +576,9 @@ arpadate(clock)
#ifdef HAVE_SAVED_UIDS
static int save_euid;
-int swap_uids() { save_euid = geteuid(); return seteuid(getuid()); }
-int swap_uids_back() { return seteuid(save_euid); }
+int swap_uids(void) { save_euid = geteuid(); return seteuid(getuid()); }
+int swap_uids_back(void) { return seteuid(save_euid); }
#else /*HAVE_SAVED_UIDS*/
-int swap_uids() { return setreuid(geteuid(), getuid()); }
-int swap_uids_back() { return swap_uids(); }
+int swap_uids(void) { return setreuid(geteuid(), getuid()); }
+int swap_uids_back(void) { return swap_uids(); }
#endif /*HAVE_SAVED_UIDS*/
diff --git a/usr.sbin/crunch/Makefile b/usr.sbin/crunch/Makefile
index 6bf600fce66b..79c2ab096bbb 100644
--- a/usr.sbin/crunch/Makefile
+++ b/usr.sbin/crunch/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= crunchgen crunchide
diff --git a/usr.sbin/crunch/Makefile.inc b/usr.sbin/crunch/Makefile.inc
index f8ffe675db6e..880f05576e1b 100644
--- a/usr.sbin/crunch/Makefile.inc
+++ b/usr.sbin/crunch/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
# modify to taste
BINDIR?= /usr/bin
diff --git a/usr.sbin/crunch/README b/usr.sbin/crunch/README
index 27c2d0298afb..0845f1f56e3f 100644
--- a/usr.sbin/crunch/README
+++ b/usr.sbin/crunch/README
@@ -69,7 +69,7 @@ bringing together a solid, state of the art development environment.
Thanks to the FreeBSD guys; Rod Grimes, Nate Williams and Jordan
Hubbard; and to Bruce Evans, for immediate and detailed feedback on
-crunch 0.1, and for pressing me to make the prototype more useable.
+crunch 0.1, and for pressing me to make the prototype more usable.
Crunch was written for the Maruti Hard Real-Time Operating System
project at the University of Maryland, to help make for better install
diff --git a/usr.sbin/crunch/crunchgen/Makefile b/usr.sbin/crunch/crunchgen/Makefile
index 8d0a78b19027..93d067461d74 100644
--- a/usr.sbin/crunch/crunchgen/Makefile
+++ b/usr.sbin/crunch/crunchgen/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= crunchgen
SRCS= crunchgen.c crunched_skel.c
diff --git a/usr.sbin/crunch/crunchgen/Makefile.depend b/usr.sbin/crunch/crunchgen/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/crunch/crunchgen/Makefile.depend
+++ b/usr.sbin/crunch/crunchgen/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/crunch/crunchgen/crunched_main.c b/usr.sbin/crunch/crunchgen/crunched_main.c
index 45f61baae23e..7de99b270ac7 100644
--- a/usr.sbin/crunch/crunchgen/crunched_main.c
+++ b/usr.sbin/crunch/crunchgen/crunched_main.c
@@ -64,9 +64,6 @@
* the crunched binary without creating all the links.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/auxv.h>
#include <sys/sysctl.h>
diff --git a/usr.sbin/crunch/crunchgen/crunchgen.1 b/usr.sbin/crunch/crunchgen/crunchgen.1
index b015f373f671..b74426935210 100644
--- a/usr.sbin/crunch/crunchgen/crunchgen.1
+++ b/usr.sbin/crunch/crunchgen/crunchgen.1
@@ -22,7 +22,6 @@
.\" Author: James da Silva, Systems Design and Analysis Group
.\" Computer Science Department
.\" University of Maryland at College Park
-.\" $FreeBSD$
.\"
.Dd January 6, 2017
.Dt CRUNCHGEN 1
diff --git a/usr.sbin/crunch/crunchgen/crunchgen.c b/usr.sbin/crunch/crunchgen/crunchgen.c
index 63ce727496b7..462a13f9c897 100644
--- a/usr.sbin/crunch/crunchgen/crunchgen.c
+++ b/usr.sbin/crunch/crunchgen/crunchgen.c
@@ -31,9 +31,6 @@
* from specs given in a .conf file.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
@@ -659,7 +656,7 @@ fillin_program(prog_t *p)
}
/* Unless the option to make object files was specified the
- * the objects will be built in the source directory unless
+ * objects will be built in the source directory unless
* an object directory already exists.
*/
if (!makeobj && !p->objdir && p->srcdir) {
@@ -1117,8 +1114,8 @@ prog_makefile_rules(FILE *outmk, prog_t *p)
"int _crunched_%s_stub(int argc, char **argv, char **envp)"
"{return main(argc,argv,envp);}\" >%s_stub.c\n",
p->ident, p->ident, p->name);
- fprintf(outmk, "%s.lo: %s_stub.o $(%s_OBJPATHS)",
- p->name, p->name, p->ident);
+ fprintf(outmk, "%s.lo: %s_stub.o $(%s_OBJPATHS) %s",
+ p->name, p->name, p->ident, outmkname);
if (p->libs)
fprintf(outmk, " $(%s_LIBS)", p->ident);
@@ -1130,7 +1127,7 @@ prog_makefile_rules(FILE *outmk, prog_t *p)
fprintf(outmk, "\n");
fprintf(outmk, "\tcrunchide -k _crunched_%s_stub ", p->ident);
for (lst = p->keeplist; lst != NULL; lst = lst->next)
- fprintf(outmk, "-k _%s ", lst->str);
+ fprintf(outmk, "-k %s ", lst->str);
fprintf(outmk, "%s.lo\n", p->name);
}
diff --git a/usr.sbin/crunch/crunchide/Makefile b/usr.sbin/crunch/crunchide/Makefile
index 467b0b6d1865..6467e951e0c7 100644
--- a/usr.sbin/crunch/crunchide/Makefile
+++ b/usr.sbin/crunch/crunchide/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= crunchide
SRCS= crunchide.c exec_elf32.c exec_elf64.c
diff --git a/usr.sbin/crunch/crunchide/Makefile.depend b/usr.sbin/crunch/crunchide/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/crunch/crunchide/Makefile.depend
+++ b/usr.sbin/crunch/crunchide/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/crunch/crunchide/crunchide.1 b/usr.sbin/crunch/crunchide/crunchide.1
index 4bdda5f451d7..57271f31972e 100644
--- a/usr.sbin/crunch/crunchide/crunchide.1
+++ b/usr.sbin/crunch/crunchide/crunchide.1
@@ -22,7 +22,6 @@
.\" Author: James da Silva, Systems Design and Analysis Group
.\" Computer Science Department
.\" University of Maryland at College Park
-.\" $FreeBSD$
.\"
.Dd June 14, 1994
.Dt CRUNCHIDE 1
diff --git a/usr.sbin/crunch/crunchide/crunchide.c b/usr.sbin/crunch/crunchide/crunchide.c
index bd663e1d57bd..eec9f19847ab 100644
--- a/usr.sbin/crunch/crunchide/crunchide.c
+++ b/usr.sbin/crunch/crunchide/crunchide.c
@@ -61,8 +61,6 @@
#ifndef lint
__RCSID("$NetBSD: crunchide.c,v 1.8 1997/11/01 06:51:45 lukem Exp $");
#endif
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/errno.h>
@@ -76,7 +74,7 @@ __FBSDID("$FreeBSD$");
static const char *pname = "crunchide";
-static void usage(void);
+static void usage(void) __dead2;
static void add_to_keep_list(char *symbol);
static void add_file_to_keep_list(char *filename);
diff --git a/usr.sbin/crunch/crunchide/exec_elf32.c b/usr.sbin/crunch/crunchide/exec_elf32.c
index f7b8601911fe..c67129f34a83 100644
--- a/usr.sbin/crunch/crunchide/exec_elf32.c
+++ b/usr.sbin/crunch/crunchide/exec_elf32.c
@@ -36,8 +36,6 @@
__RCSID("$NetBSD: exec_elf32.c,v 1.6 1999/09/20 04:12:16 christos Exp $");
#endif
#endif
-__FBSDID("$FreeBSD$");
-
#ifndef ELFSIZE
#define ELFSIZE 32
#endif
@@ -162,7 +160,7 @@ ELFNAMEEND(check)(int fd, const char *fn __unused)
unsigned char data;
/*
- * Check the header to maek sure it's an ELF file (of the
+ * Check the header to make sure it's an ELF file (of the
* appropriate size).
*/
if (fstat(fd, &sb) == -1)
diff --git a/usr.sbin/crunch/crunchide/exec_elf64.c b/usr.sbin/crunch/crunchide/exec_elf64.c
index c447116ccf5e..30bd16fd65d8 100644
--- a/usr.sbin/crunch/crunchide/exec_elf64.c
+++ b/usr.sbin/crunch/crunchide/exec_elf64.c
@@ -36,8 +36,6 @@
#ifndef lint
__IDSTRING(elf64rcsid, "$NetBSD: exec_elf64.c,v 1.2 1997/08/02 21:30:19 perry Exp $");
#endif
-__FBSDID("$FreeBSD$");
-
#define ELFSIZE 64
#include "exec_elf32.c"
diff --git a/usr.sbin/crunch/crunchide/extern.h b/usr.sbin/crunch/crunchide/extern.h
index b5f9165a1e1b..86e96ae47be5 100644
--- a/usr.sbin/crunch/crunchide/extern.h
+++ b/usr.sbin/crunch/crunchide/extern.h
@@ -1,5 +1,4 @@
/* $NetBSD: extern.h,v 1.5 1998/05/06 13:16:57 mycroft Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
diff --git a/usr.sbin/crunch/examples/Makefile b/usr.sbin/crunch/examples/Makefile
index 01b924226c45..baef8f899cfc 100644
--- a/usr.sbin/crunch/examples/Makefile
+++ b/usr.sbin/crunch/examples/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
CRUNCHED= fixit
diff --git a/usr.sbin/crunch/examples/filesystem.conf b/usr.sbin/crunch/examples/filesystem.conf
index 1fb93856c7f1..c9a6cf0ce018 100644
--- a/usr.sbin/crunch/examples/filesystem.conf
+++ b/usr.sbin/crunch/examples/filesystem.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
srcdirs /usr/src/bin /usr/src/sbin /usr/src/gnu/usr.bin /usr/src/usr.sbin
srcdirs /usr/src/sbin/i386
@@ -13,7 +12,7 @@ ln sh -
ln sh -sh
# /sbin
-progs disklabel fdisk init mount newfs reboot umount
+progs disklabel init mount newfs reboot umount
ln reboot halt
ln reboot fastboot
ln reboot fasthalt
diff --git a/usr.sbin/crunch/examples/fixit.conf b/usr.sbin/crunch/examples/fixit.conf
index 889f2e6e7854..7c6539cf8aa5 100644
--- a/usr.sbin/crunch/examples/fixit.conf
+++ b/usr.sbin/crunch/examples/fixit.conf
@@ -1,5 +1,4 @@
# fixit.conf - put in anything we think we might want on a fixit floppy
-# $FreeBSD$
# first, we list the source dirs that our programs reside in. These are
# searched in order listed to find the dir containing each program.
@@ -22,7 +21,7 @@ ln sh -sh # init invokes the shell this way
# /sbin stuff
-progs chown clri disklabel dump dmesg fdisk fsck ifconfig init
+progs chown clri disklabel dump dmesg fsck ifconfig init
progs mknod mount newfs ping reboot restore swapon umount
ln dump rdump
ln restore rrestore
diff --git a/usr.sbin/crunch/examples/kcopy.conf b/usr.sbin/crunch/examples/kcopy.conf
index 3284e868c51b..78e92191fc0a 100644
--- a/usr.sbin/crunch/examples/kcopy.conf
+++ b/usr.sbin/crunch/examples/kcopy.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
srcdirs /usr/src/bin /usr/src/sbin
diff --git a/usr.sbin/crunch/examples/really-big.conf b/usr.sbin/crunch/examples/really-big.conf
index e83680fcd556..12c08b73936f 100644
--- a/usr.sbin/crunch/examples/really-big.conf
+++ b/usr.sbin/crunch/examples/really-big.conf
@@ -5,7 +5,6 @@
#
# This produces a 4608000 byte binary. Pretty sick and twisted, eh?
#
-# $FreeBSD$
#
# =========================================================================
@@ -23,7 +22,7 @@ ln sh -sh
srcdirs /usr/src/sbin
-progs bim clri disklabel dmesg dump dumpfs fdisk fsck halt
+progs bim clri disklabel dmesg dump dumpfs fsck halt
progs ifconfig init mknod modload modunload mount mount_isofs
progs mount_lofs mount_msdosfs mountd
progs newfs nfsd nfsiod ping quotacheck reboot restore route routed savecore
diff --git a/usr.sbin/ctladm/Makefile b/usr.sbin/ctladm/Makefile
index c98643b50dcb..f9ddd251f96c 100644
--- a/usr.sbin/ctladm/Makefile
+++ b/usr.sbin/ctladm/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ctladm/Makefile.depend b/usr.sbin/ctladm/Makefile.depend
index 89190e05b84a..275fc173c482 100644
--- a/usr.sbin/ctladm/Makefile.depend
+++ b/usr.sbin/ctladm/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
@@ -10,6 +8,7 @@ DIRDEPS = \
lib/libcam \
lib/libcompiler_rt \
lib/libexpat \
+ lib/libnv \
lib/libsbuf \
lib/libutil \
diff --git a/usr.sbin/ctladm/ctladm.8 b/usr.sbin/ctladm/ctladm.8
index b8b90ad200fe..ba2712cb278c 100644
--- a/usr.sbin/ctladm/ctladm.8
+++ b/usr.sbin/ctladm/ctladm.8
@@ -34,9 +34,8 @@
.\" Author: Ken Merry <ken@FreeBSD.org>
.\"
.\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
-.\" $FreeBSD$
.\"
-.Dd March 9, 2021
+.Dd December 27, 2023
.Dt CTLADM 8
.Os
.Sh NAME
@@ -168,7 +167,7 @@
.Op Fl W Ar wwnn
.Op Fl O Ar pp|vp
.Op Fl p Ar targ_port
-.Op Fl r Ar targ_port
+.Op Fl r
.Op Fl t Ar fe_type
.Nm
.Ic portlist
diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c
index 69124383d413..9d2f14de28ed 100644
--- a/usr.sbin/ctladm/ctladm.c
+++ b/usr.sbin/ctladm/ctladm.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003, 2004 Silicon Graphics International Corp.
* Copyright (c) 1997-2007 Kenneth D. Merry
@@ -43,9 +43,6 @@
* Author: Ken Merry <ken@FreeBSD.org>
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/callout.h>
#include <sys/ioctl.h>
@@ -336,7 +333,7 @@ retry:
if (ts.tv_nsec > 0)
cmd_latency += ts.tv_nsec / 1000000;
- fprintf(stdout, "LUN %jd tag 0x%04x%s%s%s%s%s%s%s: %s. CDB: %s "
+ fprintf(stdout, "LUN %jd tag 0x%jx%s%s%s%s%s%s%s: %s. CDB: %s "
"(%0.0Lf ms)\n",
(intmax_t)entry->lun_num, entry->tag_num,
(entry->cmd_flags & CTL_OOACMD_FLAG_BLOCKED) ?
@@ -576,10 +573,11 @@ cctl_port(int fd, int argc, char **argv, char *combinedopt)
}
case CCTL_PORT_MODE_REMOVE:
if (targ_port == -1) {
- warnx("%s: -r require -p", __func__);
+ warnx("%s: -r requires -p", __func__);
retval = 1;
goto bailout;
}
+ /* FALLTHROUGH */
case CCTL_PORT_MODE_CREATE: {
bzero(&req, sizeof(req));
strlcpy(req.driver, driver, sizeof(req.driver));
@@ -3964,7 +3962,7 @@ usage(int error)
"-x : output port list in XML format\n"
"lunmap options:\n"
"-p targ_port : specify target port number\n"
-"-L pLUN : specify port-visible LUN\n"
+"-l pLUN : specify port-visible LUN\n"
"-L cLUN : specify CTL LUN\n",
CTL_DEFAULT_DEV);
}
@@ -4146,10 +4144,16 @@ main(int argc, char **argv)
goto bailout;
}
#ifdef WANT_ISCSI
- else {
+ switch (command) {
+ case CTLADM_CMD_ISLIST:
+ case CTLADM_CMD_ISLOGOUT:
+ case CTLADM_CMD_ISTERMINATE:
if (modfind("cfiscsi") == -1 &&
kldload("cfiscsi") == -1)
warn("couldn't load cfiscsi");
+ break;
+ default:
+ break;
}
#endif
} else if ((command != CTLADM_CMD_HELP)
diff --git a/usr.sbin/ctladm/ctladm.h b/usr.sbin/ctladm/ctladm.h
index ce945eccb41e..52dcadb0980e 100644
--- a/usr.sbin/ctladm/ctladm.h
+++ b/usr.sbin/ctladm/ctladm.h
@@ -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$
* $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.h#1 $
*/
diff --git a/usr.sbin/ctladm/util.c b/usr.sbin/ctladm/util.c
index 60293e499475..23723c2a2286 100644
--- a/usr.sbin/ctladm/util.c
+++ b/usr.sbin/ctladm/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/usr.sbin/ctld/Makefile b/usr.sbin/ctld/Makefile
index 45b9e93be756..b14daccff257 100644
--- a/usr.sbin/ctld/Makefile
+++ b/usr.sbin/ctld/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ctld/Makefile.depend b/usr.sbin/ctld/Makefile.depend
index b19183257618..55c3ad8688c8 100644
--- a/usr.sbin/ctld/Makefile.depend
+++ b/usr.sbin/ctld/Makefile.depend
@@ -1,21 +1,22 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
+ lib/libcasper/libcasper \
lib/libcompiler_rt \
lib/libexpat \
+ lib/libiscsiutil \
lib/libmd \
+ lib/libnv \
lib/libsbuf \
lib/libucl \
lib/libutil \
lib/msun \
- usr.bin/lex/lib \
usr.bin/yacc.host \
diff --git a/usr.sbin/ctld/ctl.conf.5 b/usr.sbin/ctld/ctl.conf.5
index f4827d042ac1..0be873fe512c 100644
--- a/usr.sbin/ctld/ctl.conf.5
+++ b/usr.sbin/ctld/ctl.conf.5
@@ -26,8 +26,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 13, 2020
.Dt CTL.CONF 5
.Os
diff --git a/usr.sbin/ctld/ctld.8 b/usr.sbin/ctld/ctld.8
index 2c2ce7a4ee43..632ff136699e 100644
--- a/usr.sbin/ctld/ctld.8
+++ b/usr.sbin/ctld/ctld.8
@@ -24,8 +24,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd March 31, 2020
.Dt CTLD 8
.Os
diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c
index 3f4bca632512..c31ac328c84e 100644
--- a/usr.sbin/ctld/ctld.c
+++ b/usr.sbin/ctld/ctld.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 The FreeBSD Foundation
*
@@ -29,9 +29,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
@@ -535,6 +532,7 @@ auth_group_find(const struct conf *conf, const char *name)
{
struct auth_group *ag;
+ assert(name != NULL);
TAILQ_FOREACH(ag, &conf->conf_auth_groups, ag_next) {
if (ag->ag_name != NULL && strcmp(ag->ag_name, name) == 0)
return (ag);
@@ -2113,7 +2111,7 @@ conf_apply(struct conf *oldconf, struct conf *newconf)
/*
* Now add new ports or modify existing ones.
*/
- TAILQ_FOREACH(newport, &newconf->conf_ports, p_next) {
+ TAILQ_FOREACH_SAFE(newport, &newconf->conf_ports, p_next, tmpport) {
if (port_is_dummy(newport))
continue;
oldport = port_find(oldconf, newport->p_name);
@@ -2130,6 +2128,8 @@ conf_apply(struct conf *oldconf, struct conf *newconf)
log_warnx("failed to %s port %s",
(oldport == NULL) ? "add" : "update",
newport->p_name);
+ if (oldport == NULL || port_is_dummy(oldport))
+ port_delete(newport);
/*
* XXX: Uncomment after fixing the root cause.
*
diff --git a/usr.sbin/ctld/ctld.h b/usr.sbin/ctld/ctld.h
index de2f480af30b..bcc3c1956dc4 100644
--- a/usr.sbin/ctld/ctld.h
+++ b/usr.sbin/ctld/ctld.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 The FreeBSD Foundation
*
@@ -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 CTLD_H
diff --git a/usr.sbin/ctld/discovery.c b/usr.sbin/ctld/discovery.c
index 3a713c1afac0..f548b41d5cba 100644
--- a/usr.sbin/ctld/discovery.c
+++ b/usr.sbin/ctld/discovery.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 The FreeBSD Foundation
*
@@ -30,8 +30,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.sbin/ctld/isns.c b/usr.sbin/ctld/isns.c
index 4d44ceaa05a9..71150a8ae06f 100644
--- a/usr.sbin/ctld/isns.c
+++ b/usr.sbin/ctld/isns.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Alexander Motin <mav@FreeBSD.org>
* All rights reserved.
@@ -27,9 +27,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
diff --git a/usr.sbin/ctld/isns.h b/usr.sbin/ctld/isns.h
index 00e6b50806a9..70404b6f74e1 100644
--- a/usr.sbin/ctld/isns.h
+++ b/usr.sbin/ctld/isns.h
@@ -22,8 +22,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 _ISNS_H
diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c
index 7e5d2a386878..cdc0b0fa187d 100644
--- a/usr.sbin/ctld/kernel.c
+++ b/usr.sbin/ctld/kernel.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003, 2004 Silicon Graphics International Corp.
* Copyright (c) 1997-2007 Kenneth D. Merry
@@ -37,9 +37,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/capsicum.h>
#include <sys/callout.h>
diff --git a/usr.sbin/ctld/login.c b/usr.sbin/ctld/login.c
index c52733f7894a..afd3210a828a 100644
--- a/usr.sbin/ctld/login.c
+++ b/usr.sbin/ctld/login.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 The FreeBSD Foundation
*
@@ -30,8 +30,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
diff --git a/usr.sbin/ctld/parse.y b/usr.sbin/ctld/parse.y
index 2995dabb095f..8909df2a8345 100644
--- a/usr.sbin/ctld/parse.y
+++ b/usr.sbin/ctld/parse.y
@@ -1,6 +1,6 @@
%{
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 The FreeBSD Foundation
*
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/ctld/token.l b/usr.sbin/ctld/token.l
index 3a9f28f4e2af..c8f54103db55 100644
--- a/usr.sbin/ctld/token.l
+++ b/usr.sbin/ctld/token.l
@@ -1,6 +1,6 @@
%{
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 The FreeBSD Foundation
*
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <stdio.h>
diff --git a/usr.sbin/ctld/uclparse.c b/usr.sbin/ctld/uclparse.c
index d02530d1b808..8bd1ca88d166 100644
--- a/usr.sbin/ctld/uclparse.c
+++ b/usr.sbin/ctld/uclparse.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2015 iXsystems Inc.
* All rights reserved.
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <sys/queue.h>
@@ -62,6 +60,7 @@ uclparse_chap(struct auth_group *auth_group, const ucl_object_t *obj)
const struct auth *ca;
const ucl_object_t *user, *secret;
+ assert(auth_group != NULL);
user = ucl_object_find_key(obj, "user");
if (!user || user->type != UCL_STRING) {
log_warnx("chap section in auth-group \"%s\" is missing "
@@ -92,6 +91,7 @@ uclparse_chap_mutual(struct auth_group *auth_group, const ucl_object_t *obj)
const ucl_object_t *user, *secret, *mutual_user;
const ucl_object_t *mutual_secret;
+ assert(auth_group != NULL);
user = ucl_object_find_key(obj, "user");
if (!user || user->type != UCL_STRING) {
log_warnx("chap-mutual section in auth-group \"%s\" is missing "
@@ -716,6 +716,8 @@ uclparse_target(const char *name, const ucl_object_t *top)
}
if (!strcmp(key, "auth-group")) {
+ const char *ag;
+
if (target->t_auth_group != NULL) {
if (target->t_auth_group->ag_name != NULL)
log_warnx("auth-group for target \"%s\" "
@@ -727,8 +729,12 @@ uclparse_target(const char *name, const ucl_object_t *top)
"target \"%s\"", target->t_name);
return (1);
}
- target->t_auth_group = auth_group_find(conf,
- ucl_object_tostring(obj));
+ ag = ucl_object_tostring(obj);
+ if (!ag) {
+ log_warnx("auth-group must be a string");
+ return (1);
+ }
+ target->t_auth_group = auth_group_find(conf, ag);
if (target->t_auth_group == NULL) {
log_warnx("unknown auth-group \"%s\" for target "
"\"%s\"", ucl_object_tostring(obj),
@@ -761,6 +767,20 @@ uclparse_target(const char *name, const ucl_object_t *top)
}
if (!strcmp(key, "chap")) {
+ if (target->t_auth_group != NULL) {
+ if (target->t_auth_group->ag_name != NULL) {
+ log_warnx("cannot use both auth-group "
+ "and chap for target \"%s\"",
+ target->t_name);
+ return (1);
+ }
+ } else {
+ target->t_auth_group = auth_group_new(conf, NULL);
+ if (target->t_auth_group == NULL) {
+ return (1);
+ }
+ target->t_auth_group->ag_target = target;
+ }
if (uclparse_chap(target->t_auth_group, obj) != 0)
return (1);
}
diff --git a/usr.sbin/cxgbetool/Makefile b/usr.sbin/cxgbetool/Makefile
index ed0f90d1ef33..356e93c910a4 100644
--- a/usr.sbin/cxgbetool/Makefile
+++ b/usr.sbin/cxgbetool/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= cxgbe-tools
PROG= cxgbetool
diff --git a/usr.sbin/cxgbetool/Makefile.depend b/usr.sbin/cxgbetool/Makefile.depend
index d5ed563ecfc8..cf48f0c1690f 100644
--- a/usr.sbin/cxgbetool/Makefile.depend
+++ b/usr.sbin/cxgbetool/Makefile.depend
@@ -1,14 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libpcap \
.include <dirdeps.mk>
diff --git a/usr.sbin/cxgbetool/cxgbetool.8 b/usr.sbin/cxgbetool/cxgbetool.8
index 96e66632e758..a25a227669ed 100644
--- a/usr.sbin/cxgbetool/cxgbetool.8
+++ b/usr.sbin/cxgbetool/cxgbetool.8
@@ -29,8 +29,6 @@
.\"
.\" * Other names and brands may be claimed as the property of others.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 14, 2022
.Dt CXGBETOOL 8
.Os
diff --git a/usr.sbin/cxgbetool/cxgbetool.c b/usr.sbin/cxgbetool/cxgbetool.c
index 53de8f8ff89a..bef99ff0f3da 100644
--- a/usr.sbin/cxgbetool/cxgbetool.c
+++ b/usr.sbin/cxgbetool/cxgbetool.c
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
@@ -124,7 +121,7 @@ usage(FILE *fp)
"\tsched-queue <port> <queue> <class> bind NIC queues to TX Scheduling class\n"
"\tstdio interactive mode\n"
"\ttcb <tid> read TCB\n"
- "\ttracer <idx> tx<n>|rx<n> set and enable a tracer\n"
+ "\ttracer <idx> tx<n>|rx<n>|lo<n> set and enable a tracer\n"
"\ttracer <idx> disable|enable disable or enable a tracer\n"
"\ttracer list list all tracers\n"
);
@@ -544,46 +541,36 @@ do_show_info_header(uint32_t mode)
case T4_FILTER_FCoE:
printf(" FCoE");
break;
-
case T4_FILTER_PORT:
printf(" Port");
break;
-
case T4_FILTER_VNIC:
if (mode & T4_FILTER_IC_VNIC)
printf(" VFvld:PF:VF");
else
printf(" vld:oVLAN");
break;
-
case T4_FILTER_VLAN:
printf(" vld:VLAN");
break;
-
case T4_FILTER_IP_TOS:
printf(" TOS");
break;
-
case T4_FILTER_IP_PROTO:
printf(" Prot");
break;
-
case T4_FILTER_ETH_TYPE:
printf(" EthType");
break;
-
case T4_FILTER_MAC_IDX:
printf(" MACIdx");
break;
-
case T4_FILTER_MPS_HIT_TYPE:
printf(" MPS");
break;
-
case T4_FILTER_IP_FRAGMENT:
printf(" Frag");
break;
-
default:
/* compressed filter field not enabled */
break;
@@ -825,11 +812,9 @@ do_show_one_filter_info(struct t4_filter *t, uint32_t mode)
case T4_FILTER_FCoE:
printf(" %1d/%1d", t->fs.val.fcoe, t->fs.mask.fcoe);
break;
-
case T4_FILTER_PORT:
printf(" %1d/%1d", t->fs.val.iport, t->fs.mask.iport);
break;
-
case T4_FILTER_VNIC:
if (mode & T4_FILTER_IC_VNIC) {
printf(" %1d:%1x:%02x/%1d:%1x:%02x",
@@ -845,40 +830,32 @@ do_show_one_filter_info(struct t4_filter *t, uint32_t mode)
t->fs.mask.ovlan_vld, t->fs.mask.vnic);
}
break;
-
case T4_FILTER_VLAN:
printf(" %1d:%04x/%1d:%04x",
t->fs.val.vlan_vld, t->fs.val.vlan,
t->fs.mask.vlan_vld, t->fs.mask.vlan);
break;
-
case T4_FILTER_IP_TOS:
printf(" %02x/%02x", t->fs.val.tos, t->fs.mask.tos);
break;
-
case T4_FILTER_IP_PROTO:
printf(" %02x/%02x", t->fs.val.proto, t->fs.mask.proto);
break;
-
case T4_FILTER_ETH_TYPE:
printf(" %04x/%04x", t->fs.val.ethtype,
t->fs.mask.ethtype);
break;
-
case T4_FILTER_MAC_IDX:
printf(" %03x/%03x", t->fs.val.macidx,
t->fs.mask.macidx);
break;
-
case T4_FILTER_MPS_HIT_TYPE:
printf(" %1x/%1x", t->fs.val.matchtype,
t->fs.mask.matchtype);
break;
-
case T4_FILTER_IP_FRAGMENT:
printf(" %1d/%1d", t->fs.val.frag, t->fs.mask.frag);
break;
-
default:
/* compressed filter field not enabled */
break;
@@ -1010,43 +987,30 @@ get_filter_mode(int hashfilter)
if (mode & T4_FILTER_IPv4)
printf("ipv4 ");
-
if (mode & T4_FILTER_IPv6)
printf("ipv6 ");
-
if (mode & T4_FILTER_IP_SADDR)
printf("sip ");
-
if (mode & T4_FILTER_IP_DADDR)
printf("dip ");
-
if (mode & T4_FILTER_IP_SPORT)
printf("sport ");
-
if (mode & T4_FILTER_IP_DPORT)
printf("dport ");
-
if (mode & T4_FILTER_IP_FRAGMENT)
printf("frag ");
-
if (mode & T4_FILTER_MPS_HIT_TYPE)
printf("matchtype ");
-
if (mode & T4_FILTER_MAC_IDX)
printf("macidx ");
-
if (mode & T4_FILTER_ETH_TYPE)
printf("ethtype ");
-
if (mode & T4_FILTER_IP_PROTO)
printf("proto ");
-
if (mode & T4_FILTER_IP_TOS)
printf("tos ");
-
if (mode & T4_FILTER_VLAN)
printf("vlan ");
-
if (mode & T4_FILTER_VNIC) {
if (mode & T4_FILTER_IC_VNIC)
printf("vnic_id ");
@@ -1055,13 +1019,10 @@ get_filter_mode(int hashfilter)
else
printf("ovlan ");
}
-
if (mode & T4_FILTER_PORT)
printf("iport ");
-
if (mode & T4_FILTER_FCoE)
printf("fcoe ");
-
printf("\n");
return (0);
@@ -1448,7 +1409,7 @@ filter_cmd(int argc, const char *argv[], int hashfilter)
/*
* No numeric index means this must be a request to
* create a new hashfilter and we are already at the
- * paramter/value list.
+ * parameter/value list.
*/
idx = (uint32_t) -1;
goto setf;
@@ -2514,17 +2475,24 @@ set_tracer(uint8_t idx, int argc, const char *argv[])
t.valid = 1;
if (argc != 1) {
- warnx("must specify tx<n> or rx<n>.");
+ warnx("must specify one of tx/rx/lo<n>");
return (EINVAL);
}
len = strlen(argv[0]);
if (len != 3) {
- warnx("argument must be 3 characters (tx<n> or rx<n>)");
+ warnx("argument must be 3 characters (tx/rx/lo<n>). eg. tx0");
return (EINVAL);
}
- if (strncmp(argv[0], "tx", 2) == 0) {
+ if (strncmp(argv[0], "lo", 2) == 0) {
+ port = argv[0][2] - '0';
+ if (port < 0 || port > 3) {
+ warnx("'%c' in %s is invalid", argv[0][2], argv[0]);
+ return (EINVAL);
+ }
+ port += 8;
+ } else if (strncmp(argv[0], "tx", 2) == 0) {
port = argv[0][2] - '0';
if (port < 0 || port > 3) {
warnx("'%c' in %s is invalid", argv[0][2], argv[0]);
diff --git a/usr.sbin/cxgbetool/reg_defs_t4.c b/usr.sbin/cxgbetool/reg_defs_t4.c
index 5207073b2498..dac485778be1 100644
--- a/usr.sbin/cxgbetool/reg_defs_t4.c
+++ b/usr.sbin/cxgbetool/reg_defs_t4.c
@@ -1,8 +1,6 @@
/* This file is automatically generated --- changes will be lost */
/* Generation Date : Tue Dec 8 09:33:01 IST 2015 */
/* Directory name: t4_reg.txt, Changeset: */
-__FBSDID("$FreeBSD$");
-
struct reg_info t4_sge_regs[] = {
{ "SGE_PF_KDOORBELL", 0x1e000, 0 },
{ "QID", 15, 17 },
diff --git a/usr.sbin/cxgbetool/reg_defs_t4vf.c b/usr.sbin/cxgbetool/reg_defs_t4vf.c
index 34909036d42b..5ea7d4f276dd 100644
--- a/usr.sbin/cxgbetool/reg_defs_t4vf.c
+++ b/usr.sbin/cxgbetool/reg_defs_t4vf.c
@@ -3,8 +3,6 @@
* Virtual Function register map definitions in t4vf_defs.h in the common
* code.
*/
-__FBSDID("$FreeBSD$");
-
struct reg_info t4vf_sge_regs[] = {
{ "SGE_KDOORBELL", 0x000, 0 },
{ "QID", 15, 17 },
diff --git a/usr.sbin/cxgbetool/reg_defs_t5.c b/usr.sbin/cxgbetool/reg_defs_t5.c
index f5f64da7ebd2..3c31a66e2360 100644
--- a/usr.sbin/cxgbetool/reg_defs_t5.c
+++ b/usr.sbin/cxgbetool/reg_defs_t5.c
@@ -1,8 +1,6 @@
/* This file is automatically generated --- changes will be lost */
/* Generation Date : Tue Jan 28 03:02:12 IST 2020 */
/* Directory name: t5_reg.txt, Changeset: 6941:9063655afd44 */
-__FBSDID("$FreeBSD$");
-
struct reg_info t5_sge_regs[] = {
{ "SGE_PF_KDOORBELL", 0x1e000, 0 },
{ "QID", 15, 17 },
diff --git a/usr.sbin/cxgbetool/reg_defs_t6.c b/usr.sbin/cxgbetool/reg_defs_t6.c
index 23a3d6d44a5a..ffa2c9c57689 100644
--- a/usr.sbin/cxgbetool/reg_defs_t6.c
+++ b/usr.sbin/cxgbetool/reg_defs_t6.c
@@ -1,8 +1,6 @@
/* This file is automatically generated --- changes will be lost */
/* Generation Date : Tue Jan 28 03:02:08 IST 2020 */
/* Directory name: t6_reg.txt, Changeset: 4272:a648ba4d5c0c */
-__FBSDID("$FreeBSD$");
-
struct reg_info t6_sge_regs[] = {
{ "SGE_PF_KDOORBELL", 0x1e000, 0 },
{ "QID", 15, 17 },
diff --git a/usr.sbin/cxgbetool/tcb_common.c b/usr.sbin/cxgbetool/tcb_common.c
index c6c3fed19c3e..53422c994584 100644
--- a/usr.sbin/cxgbetool/tcb_common.c
+++ b/usr.sbin/cxgbetool/tcb_common.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Chelsio Communications, Inc.
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "tcb_common.h"
/***:-----------------------------------------------------------------------
@@ -300,7 +298,7 @@ decompress_val(_TCBVAR *tvp,unsigned ulp_type,unsigned tx_max,
PM_MODE_IANDP==ulp_type) {
/* TP does this internally. Not sure if I should show the
* unaltered value or the raw value. For now I
- * will diplay the raw value. For now I've added the code
+ * will display the raw value. For now I've added the code
* mainly to stop windows compiler from warning about ulp_type
* being an unreferenced parameter.
*/
diff --git a/usr.sbin/cxgbetool/tcb_common.h b/usr.sbin/cxgbetool/tcb_common.h
index 60f2acfe0887..047dc85e08dd 100644
--- a/usr.sbin/cxgbetool/tcb_common.h
+++ b/usr.sbin/cxgbetool/tcb_common.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Chelsio Communications, Inc.
* All rights reserved.
@@ -25,8 +25,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#ifndef __tcb_common_h
diff --git a/usr.sbin/cxgbetool/tcbinfot4.c b/usr.sbin/cxgbetool/tcbinfot4.c
index 9daff0af3338..ed7ea18dcf88 100644
--- a/usr.sbin/cxgbetool/tcbinfot4.c
+++ b/usr.sbin/cxgbetool/tcbinfot4.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Chelsio Communications, Inc.
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* Auto-generated file. Avoid direct editing. */
/* Edits will be lost when file regenerated. */
#include <stdio.h>
@@ -872,7 +870,7 @@ _TCBVAR g_tcb_info4[]={
NULL , 0, 0, /* faka,flo,fhi */
"rq_start" , /* aka */
COMP_NONE , /* comp */
- "DW aligned starting addres of RQ", /*desc*/
+ "DW aligned starting address of RQ", /*desc*/
NULL, /*akadesc */
},
{"rq_MSN" , 2, 986, 998, /* name,aux,lo,hi */
diff --git a/usr.sbin/cxgbetool/tcbinfot5.c b/usr.sbin/cxgbetool/tcbinfot5.c
index b4baa31a82e2..de20bc1e2cf0 100644
--- a/usr.sbin/cxgbetool/tcbinfot5.c
+++ b/usr.sbin/cxgbetool/tcbinfot5.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Chelsio Communications, Inc.
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* Auto-generated file. Avoid direct editing. */
/* Edits will be lost when file regenerated. */
#include <stdio.h>
@@ -879,7 +877,7 @@ _TCBVAR g_tcb_info5[]={
NULL , 0, 0, /* faka,flo,fhi */
"rq_start" , /* aka */
COMP_NONE , /* comp */
- "DW aligned starting addres of RQ", /*desc*/
+ "DW aligned starting address of RQ", /*desc*/
NULL, /*akadesc */
},
{"rq_MSN" , 2, 986, 998, /* name,aux,lo,hi */
diff --git a/usr.sbin/cxgbetool/tcbinfot6.c b/usr.sbin/cxgbetool/tcbinfot6.c
index 81499136807a..ab44205c4046 100644
--- a/usr.sbin/cxgbetool/tcbinfot6.c
+++ b/usr.sbin/cxgbetool/tcbinfot6.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Chelsio Communications, Inc.
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* Auto-generated file. Avoid direct editing. */
/* Edits will be lost when file regenerated. */
#include <stdio.h>
@@ -879,7 +877,7 @@ _TCBVAR g_tcb_info6[]={
NULL , 0, 0, /* faka,flo,fhi */
"rq_start" , /* aka */
COMP_NONE , /* comp */
- "DW aligned starting addres of RQ", /*desc*/
+ "DW aligned starting address of RQ", /*desc*/
NULL, /*akadesc */
},
{"rq_MSN" , 2, 986, 998, /* name,aux,lo,hi */
diff --git a/usr.sbin/cxgbetool/tcbshowt4.c b/usr.sbin/cxgbetool/tcbshowt4.c
index 4237b64fb0b8..819b68c37e12 100644
--- a/usr.sbin/cxgbetool/tcbshowt4.c
+++ b/usr.sbin/cxgbetool/tcbshowt4.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Chelsio Communications, Inc.
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* Auto-generated file. Avoid direct editing. */
/* Edits will be lost when file regenerated. */
#include <stdio.h>
@@ -220,7 +218,7 @@ void t4_display_tcb_aux_0 (_TCBVAR *tvp, int aux)
val("rx_flow_control_ddp"));
- PR("MISCELANEOUS:\n"); /* *************************** */
+ PR("MISCELLANEOUS:\n"); /* *************************** */
PR(" pend_ctl: 0x%1x, unused_flags: 0x%x, main_slush: 0x%x\n",
((val("pend_ctl2")<<2) | (val("pend_ctl1")<<1) |
val("pend_ctl0")),
diff --git a/usr.sbin/cxgbetool/tcbshowt5.c b/usr.sbin/cxgbetool/tcbshowt5.c
index 3f5aa8474226..698345ce0d67 100644
--- a/usr.sbin/cxgbetool/tcbshowt5.c
+++ b/usr.sbin/cxgbetool/tcbshowt5.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Chelsio Communications, Inc.
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* Auto-generated file. Avoid direct editing. */
/* Edits will be lost when file regenerated. */
#include <stdio.h>
@@ -220,7 +218,7 @@ void t5_display_tcb_aux_0 (_TCBVAR *tvp, int aux)
val("rx_flow_control_ddp"));
- PR("MISCELANEOUS:\n"); /* *************************** */
+ PR("MISCELLANEOUS:\n"); /* *************************** */
PR(" pend_ctl: 0x%1x, unused_flags: 0x%x, main_slush: 0x%x\n",
((val("pend_ctl2")<<2) | (val("pend_ctl1")<<1) |
val("pend_ctl0")),
diff --git a/usr.sbin/cxgbetool/tcbshowt6.c b/usr.sbin/cxgbetool/tcbshowt6.c
index 2aa6a6afab56..18a5c6f39440 100644
--- a/usr.sbin/cxgbetool/tcbshowt6.c
+++ b/usr.sbin/cxgbetool/tcbshowt6.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Chelsio Communications, Inc.
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* Auto-generated file. Avoid direct editing. */
/* Edits will be lost when file regenerated. */
#include <stdio.h>
@@ -221,7 +219,7 @@ void t6_display_tcb_aux_0 (_TCBVAR *tvp, int aux)
val("rx_flow_control_ddp"));
- PR("MISCELANEOUS:\n"); /* *************************** */
+ PR("MISCELLANEOUS:\n"); /* *************************** */
PR(" pend_ctl: 0x%1x, core_bypass: 0x%x, main_slush: 0x%x\n",
((val("pend_ctl2")<<2) | (val("pend_ctl1")<<1) |
val("pend_ctl0")),
diff --git a/usr.sbin/daemon/Makefile b/usr.sbin/daemon/Makefile
index 0bf34c351932..f839079be4e8 100644
--- a/usr.sbin/daemon/Makefile
+++ b/usr.sbin/daemon/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= daemon
MAN= daemon.8
diff --git a/usr.sbin/daemon/Makefile.depend b/usr.sbin/daemon/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/daemon/Makefile.depend
+++ b/usr.sbin/daemon/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/daemon/daemon.8 b/usr.sbin/daemon/daemon.8
index c4f20548d4a2..4fafb8528f18 100644
--- a/usr.sbin/daemon/daemon.8
+++ b/usr.sbin/daemon/daemon.8
@@ -24,9 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd January 14, 2021
+.Dd December 27, 2023
.Dt DAEMON 8
.Os
.Sh NAME
@@ -57,10 +55,10 @@ log file.
.Pp
The options are as follows:
.Bl -tag -width indent
-.It Fl c
+.It Fl c , Fl -change-dir
Change the current working directory to the root
.Pq Dq Pa / .
-.It Fl f
+.It Fl f , Fl -close-fds
Redirect standard input, standard output and standard error to
.Pa /dev/null .
When this option is used together with any of the options related to file
@@ -68,109 +66,137 @@ or syslog output, the standard file descriptors are first redirected to
.Pa /dev/null ,
then stdout and/or stderr is redirected to a file or to syslog as
specified by the other options.
-.It Fl H
+.It Fl H , Fl -sighup
Close
.Pa output_file
-and re-open it when signal SIGHUP is received, for interoperability with
+and re-open it when signal
+.Dv SIGHUP
+is received, for interoperability with
.Xr newsyslog 1
and similar log rotation / archival mechanisms. If
-.Fl o
+.Fl -output-file
is not specified, this flag is ignored.
-.It Fl S
-Enable syslog output.
-This is implicitly applied if other syslog parameters are provided.
-The default values are daemon, notice, and daemon for facility, priority, and
-tag, respectively.
-.It Fl o Ar output_file
+.It Fl l , Fl -syslog-facility Ar syslog_facility
+These facilities are accepted:
+.Cm auth , authpriv , console , cron , daemon ,
+.Cm ftp , kern , lpr , mail , news , ntp , security ,
+.Cm syslog , user , uucp ,
+and
+local facilities from
+.Cm local0
+to
+.Cm local7 .
+The default is
+.Cm daemon .
+.It Fl m , Fl -output-mask Ar output_mask
+Redirect output from the child process stdout
+.Pq Cm 1 ,
+stderr
+.Pq Cm 2 ,
+or both
+.Pq Cm 3 .
+This value specifies what is sent to syslog and the log file.
+The default is
+.Cm 3 .
+.It Fl o , Fl -output-file Ar output_file
Append output from the daemonized process to
.Pa output_file .
If the file does not exist, it is created with permissions 0600.
When this option is used together with options
-.Fl c
+.Fl -change-dir
and
-.Fl H
+.Fl -sighup
the absolute path needs to be provided to ensure
.Nm
-can re-open the file after a SIGHUP.
-.It Fl m Ar output_mask
-Redirect output from the child process stdout (1), stderr (2), or both (3).
-This value specifies what is sent to syslog and the log file.
-The default is 3.
-.It Fl p Ar child_pidfile
-Write the ID of the created process into the
-.Ar child_pidfile
+can re-open the file after a
+.Dv SIGHUP .
+.It Fl P , Fl -supervisor-pidfile Ar supervisor_pidfile
+Write the ID of the
+.Nm
+process into the
+.Ar supervisor_pidfile
using the
.Xr pidfile 3
functionality.
The program is executed in a spawned child process while the
.Nm
waits until it terminates to keep the
-.Ar child_pidfile
+.Ar supervisor_pidfile
locked and removes it after the process exits.
The
-.Ar child_pidfile
+.Ar supervisor_pidfile
owner is the user who runs the
.Nm
regardless of whether the
-.Fl u
+.Fl -user
option is used or not.
-.It Fl P Ar supervisor_pidfile
-Write the ID of the
-.Nm
-process into the
-.Ar supervisor_pidfile
+.It Fl p , Fl -child-pidfile Ar child_pidfile
+Write the ID of the created process into the
+.Ar child_pidfile
using the
.Xr pidfile 3
functionality.
The program is executed in a spawned child process while the
.Nm
waits until it terminates to keep the
-.Ar supervisor_pidfile
+.Ar child_pidfile
locked and removes it after the process exits.
The
-.Ar supervisor_pidfile
+.Ar child_pidfile
owner is the user who runs the
.Nm
regardless of whether the
-.Fl u
+.Fl -user
option is used or not.
-.It Fl r
-Supervise and restart the program after a one-second delay if it has
-been terminated.
-.It Fl R Ar restart_delay_seconds
+.It Fl R , Fl -restart-delay Ar restart_delay_seconds
Supervise and restart the program after the specified delay
if it has been terminated.
-.It Fl t Ar title
+Valid values are 1-31536000 (up to 1 year).
+.It Fl r , Fl -restart
+Supervise and restart the program after a one-second delay if it has
+been terminated.
+.It Fl S , Fl -syslog
+Enable syslog output.
+This is implicitly applied if other syslog parameters are provided.
+The default values are daemon, notice, and daemon for facility, priority, and
+tag, respectively.
+.It Fl s , Fl -syslog-priority Ar syslog_priority
+These priorities are accepted:
+.Cm emerg , alert , crit , err , warning ,
+.Cm notice , info ,
+and
+.Cm debug .
+The default is
+.Cm notice .
+.It Fl T , Fl -syslog-tag Ar syslog_tag
+Set the tag which is appended to all syslog messages.
+The default is
+.Cm daemon .
+.It Fl t , Fl -title Ar title
Set the title for the daemon process.
The default is the daemonized invocation.
-.It Fl u Ar user
+.It Fl u , Fl -user Ar user
Login name of the user to execute the program under.
+Environment variables
+.Ev HOME , USER ,
+and
+.Ev SHELL
+are set accordingly.
Requires adequate superuser privileges.
-.It Fl s Ar syslog_priority
-These priorities are accepted: emerg, alert, crit, err, warning,
-notice, info, and debug.
-The default is notice.
-.It Fl l Ar syslog_facility
-These facilities are accepted: auth, authpriv, console, cron, daemon,
-ftp, kern, lpr, mail, news, ntp, security, syslog, user, uucp, and
-local0, ..., local7.
-The default is daemon.
-.It Fl T Ar syslog_tag
-Set the tag which is appended to all syslog messages.
-The default is daemon.
.El
.Pp
If any of the options
-.Fl p ,
-.Fl P ,
-.Fl r ,
-.Fl o ,
-.Fl s ,
-.Fl T ,
-.Fl m ,
-.Fl S ,
+.Fl -child-pidfile ,
+.Fl -output-mask ,
+.Fl -restart ,
+.Fl -restart-delay ,
+.Fl -supervisor-pidfile ,
+.Fl -syslog ,
+.Fl -syslog-facility
+.Fl -syslog-priority ,
+.Fl -syslog-tag ,
or
-.Fl l
+.Fl -output ,
are specified, the program is executed in a spawned child process.
The
.Nm
@@ -178,7 +204,9 @@ waits until it terminates to keep the pid file(s) locked and removes them
after the process exits or restarts the program.
In this case if the monitoring
.Nm
-receives software termination signal (SIGTERM) it forwards it to the
+receives software termination signal
+.Pq Dv SIGTERM
+it forwards it to the
spawned process.
Normally it will cause the child to exit, remove the pidfile(s)
and then terminate.
@@ -187,21 +215,21 @@ If neither file or syslog output are selected, all output is redirected to the
.Nm
process and written to stdout.
The
-.Fl f
+.Fl -close-fds
option may be used to suppress the stdout output completely.
.Pp
The
-.Fl P
+.Fl -supervisor-pidfile
option is useful combined with the
-.Fl r
+.Fl -restart
option as
.Ar supervisor_pidfile
contains the ID of the supervisor
not the child.
This is especially important if you use
-.Fl r
+.Fl -restart
in an rc script as the
-.Fl p
+.Fl -child-pidfile
option will give you the child's ID to signal when you attempt to
stop the service, causing
.Nm
@@ -229,7 +257,7 @@ cannot be opened for appending, and otherwise 0.
If the command cannot be executed, an error message is printed to
standard error.
The exact behavior depends on the logging parameters and the
-.Fl f
+.Fl -close-fds
flag.
.Sh SEE ALSO
.Xr nohup 1 ,
diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c
index d8a26132223b..26e34d1d2e2b 100644
--- a/usr.sbin/daemon/daemon.c
+++ b/usr.sbin/daemon/daemon.c
@@ -30,416 +30,526 @@
* From BSDI: daemon.c,v 1.2 1996/08/15 01:11:09 jch Exp
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
+#include <sys/event.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <err.h>
#include <errno.h>
+#include <getopt.h>
#include <libutil.h>
#include <login_cap.h>
+#include <paths.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <strings.h>
#define SYSLOG_NAMES
#include <syslog.h>
#include <time.h>
#include <assert.h>
+/* 1 year in seconds */
+#define MAX_RESTART_DELAY 60*60*24*365
+
#define LBUF_SIZE 4096
-struct log_params {
- int dosyslog;
- int logpri;
- int noclose;
- int outfd;
- const char *outfn;
+enum daemon_mode {
+ MODE_DAEMON = 0, /* simply daemonize, no supervision */
+ MODE_SUPERVISE, /* initial supervision state */
+ MODE_TERMINATING, /* user requested termination */
+ MODE_NOCHILD, /* child is terminated, final state of the event loop */
+};
+
+
+struct daemon_state {
+ unsigned char buf[LBUF_SIZE];
+ size_t pos;
+ char **argv;
+ const char *child_pidfile;
+ const char *parent_pidfile;
+ const char *output_filename;
+ const char *syslog_tag;
+ const char *title;
+ const char *user;
+ struct pidfh *parent_pidfh;
+ struct pidfh *child_pidfh;
+ enum daemon_mode mode;
+ int pid;
+ int pipe_rd;
+ int pipe_wr;
+ int keep_cur_workdir;
+ int restart_delay;
+ int stdmask;
+ int syslog_priority;
+ int syslog_facility;
+ int keep_fds_open;
+ int output_fd;
+ bool restart_enabled;
+ bool syslog_enabled;
+ bool log_reopen;
};
static void restrict_process(const char *);
-static void handle_term(int);
-static void handle_chld(int);
-static void handle_hup(int);
-static int open_log(const char *);
-static void reopen_log(struct log_params *);
-static int listen_child(int, struct log_params *);
+static int open_log(const char *);
+static void reopen_log(struct daemon_state *);
+static bool listen_child(struct daemon_state *);
static int get_log_mapping(const char *, const CODE *);
-static void open_pid_files(const char *, const char *, struct pidfh **,
- struct pidfh **);
-static void do_output(const unsigned char *, size_t, struct log_params *);
-static void daemon_sleep(time_t, long);
-static void usage(void);
+static void open_pid_files(struct daemon_state *);
+static void do_output(const unsigned char *, size_t, struct daemon_state *);
+static void daemon_sleep(struct daemon_state *);
+static void daemon_state_init(struct daemon_state *);
+static void daemon_eventloop(struct daemon_state *);
+static void daemon_terminate(struct daemon_state *);
+static void daemon_exec(struct daemon_state *);
+static bool daemon_is_child_dead(struct daemon_state *);
+static void daemon_set_child_pipe(struct daemon_state *);
+
+static const char shortopts[] = "+cfHSp:P:ru:o:s:l:t:m:R:T:h";
+
+static const struct option longopts[] = {
+ { "change-dir", no_argument, NULL, 'c' },
+ { "close-fds", no_argument, NULL, 'f' },
+ { "sighup", no_argument, NULL, 'H' },
+ { "syslog", no_argument, NULL, 'S' },
+ { "output-file", required_argument, NULL, 'o' },
+ { "output-mask", required_argument, NULL, 'm' },
+ { "child-pidfile", required_argument, NULL, 'p' },
+ { "supervisor-pidfile", required_argument, NULL, 'P' },
+ { "restart", no_argument, NULL, 'r' },
+ { "restart-delay", required_argument, NULL, 'R' },
+ { "title", required_argument, NULL, 't' },
+ { "user", required_argument, NULL, 'u' },
+ { "syslog-priority", required_argument, NULL, 's' },
+ { "syslog-facility", required_argument, NULL, 'l' },
+ { "syslog-tag", required_argument, NULL, 'T' },
+ { "help", no_argument, NULL, 'h' },
+ { NULL, 0, NULL, 0 }
+};
-static volatile sig_atomic_t terminate = 0, child_gone = 0, pid = 0,
- do_log_reopen = 0;
+static _Noreturn void
+usage(int exitcode)
+{
+ (void)fprintf(stderr,
+ "usage: daemon [-cfHrS] [-p child_pidfile] [-P supervisor_pidfile]\n"
+ " [-u user] [-o output_file] [-t title]\n"
+ " [-l syslog_facility] [-s syslog_priority]\n"
+ " [-T syslog_tag] [-m output_mask] [-R restart_delay_secs]\n"
+ "command arguments ...\n");
+
+ (void)fprintf(stderr,
+ " --change-dir -c Change the current working directory to root\n"
+ " --close-fds -f Set stdin, stdout, stderr to /dev/null\n"
+ " --sighup -H Close and re-open output file on SIGHUP\n"
+ " --syslog -S Send output to syslog\n"
+ " --output-file -o <file> Append output of the child process to file\n"
+ " --output-mask -m <mask> What to send to syslog/file\n"
+ " 1=stdout, 2=stderr, 3=both\n"
+ " --child-pidfile -p <file> Write PID of the child process to file\n"
+ " --supervisor-pidfile -P <file> Write PID of the supervisor process to file\n"
+ " --restart -r Restart child if it terminates (1 sec delay)\n"
+ " --restart-delay -R <N> Restart child if it terminates after N sec\n"
+ " --title -t <title> Set the title of the supervisor process\n"
+ " --user -u <user> Drop privileges, run as given user\n"
+ " --syslog-priority -s <prio> Set syslog priority\n"
+ " --syslog-facility -l <flty> Set syslog facility\n"
+ " --syslog-tag -T <tag> Set syslog tag\n"
+ " --help -h Show this help\n");
+
+ exit(exitcode);
+}
int
main(int argc, char *argv[])
{
- const char *pidfile, *ppidfile, *title, *user, *outfn, *logtag;
- int ch, nochdir, noclose, restart, dosyslog, child_eof;
- sigset_t mask_susp, mask_orig, mask_read, mask_term;
- struct log_params logpar;
- int pfd[2] = { -1, -1 }, outfd = -1;
- int stdmask, logpri, logfac, log_reopen;
- struct pidfh *ppfh, *pfh;
- char *p;
-
- memset(&logpar, 0, sizeof(logpar));
- stdmask = STDOUT_FILENO | STDERR_FILENO;
- ppidfile = pidfile = user = NULL;
- nochdir = noclose = 1;
- logpri = LOG_NOTICE;
- logfac = LOG_DAEMON;
- logtag = "daemon";
- restart = 0;
- dosyslog = 0;
- log_reopen = 0;
- outfn = NULL;
- title = NULL;
- while ((ch = getopt(argc, argv, "cfHSp:P:ru:o:s:l:t:l:m:R:T:")) != -1) {
+ const char *e = NULL;
+ int ch = 0;
+ struct daemon_state state;
+
+ daemon_state_init(&state);
+
+ /* Signals are processed via kqueue */
+ signal(SIGHUP, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+
+ /*
+ * Supervision mode is enabled if one of the following options are used:
+ * --child-pidfile -p
+ * --supervisor-pidfile -P
+ * --restart -r / --restart-delay -R
+ * --syslog -S
+ * --syslog-facility -l
+ * --syslog-priority -s
+ * --syslog-tag -T
+ *
+ * In supervision mode daemon executes the command in a forked process
+ * and observes the child by waiting for SIGCHILD. In supervision mode
+ * daemon must never exit before the child, this is necessary to prevent
+ * orphaning the child and leaving a stale pid file.
+ * To achieve this daemon catches SIGTERM and
+ * forwards it to the child, expecting to get SIGCHLD eventually.
+ */
+ while ((ch = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
switch (ch) {
case 'c':
- nochdir = 0;
+ state.keep_cur_workdir = 0;
break;
case 'f':
- noclose = 0;
+ state.keep_fds_open = 0;
break;
case 'H':
- log_reopen = 1;
+ state.log_reopen = true;
break;
case 'l':
- logfac = get_log_mapping(optarg, facilitynames);
- if (logfac == -1)
+ state.syslog_facility = get_log_mapping(optarg,
+ facilitynames);
+ if (state.syslog_facility == -1) {
errx(5, "unrecognized syslog facility");
- dosyslog = 1;
+ }
+ state.syslog_enabled = true;
+ state.mode = MODE_SUPERVISE;
break;
case 'm':
- stdmask = strtol(optarg, &p, 10);
- if (p == optarg || stdmask < 0 || stdmask > 3)
- errx(6, "unrecognized listening mask");
+ state.stdmask = (int)strtonum(optarg, 0, 3, &e);
+ if (e != NULL) {
+ errx(6, "unrecognized listening mask: %s", e);
+ }
break;
case 'o':
- outfn = optarg;
+ state.output_filename = optarg;
+ /*
+ * TODO: setting output filename doesn't have to turn
+ * the supervision mode on. For non-supervised mode
+ * daemon could open the specified file and set it's
+ * descriptor as both stderr and stout before execve()
+ */
+ state.mode = MODE_SUPERVISE;
break;
case 'p':
- pidfile = optarg;
+ state.child_pidfile = optarg;
+ state.mode = MODE_SUPERVISE;
break;
case 'P':
- ppidfile = optarg;
+ state.parent_pidfile = optarg;
+ state.mode = MODE_SUPERVISE;
break;
case 'r':
- restart = 1;
+ state.restart_enabled = true;
+ state.mode = MODE_SUPERVISE;
break;
case 'R':
- restart = strtol(optarg, &p, 0);
- if (p == optarg || restart < 1)
- errx(6, "invalid restart delay");
+ state.restart_enabled = true;
+ state.restart_delay = (int)strtonum(optarg, 1,
+ MAX_RESTART_DELAY, &e);
+ if (e != NULL) {
+ errx(6, "invalid restart delay: %s", e);
+ }
+ state.mode = MODE_SUPERVISE;
break;
case 's':
- logpri = get_log_mapping(optarg, prioritynames);
- if (logpri == -1)
+ state.syslog_priority = get_log_mapping(optarg,
+ prioritynames);
+ if (state.syslog_priority == -1) {
errx(4, "unrecognized syslog priority");
- dosyslog = 1;
+ }
+ state.syslog_enabled = true;
+ state.mode = MODE_SUPERVISE;
break;
case 'S':
- dosyslog = 1;
+ state.syslog_enabled = true;
+ state.mode = MODE_SUPERVISE;
break;
case 't':
- title = optarg;
+ state.title = optarg;
break;
case 'T':
- logtag = optarg;
- dosyslog = 1;
+ state.syslog_tag = optarg;
+ state.syslog_enabled = true;
+ state.mode = MODE_SUPERVISE;
break;
case 'u':
- user = optarg;
+ state.user = optarg;
break;
+ case 'h':
+ usage(0);
+ __unreachable();
default:
- usage();
+ usage(1);
}
}
argc -= optind;
argv += optind;
+ state.argv = argv;
- if (argc == 0)
- usage();
+ if (argc == 0) {
+ usage(1);
+ }
- if (!title)
- title = argv[0];
+ if (!state.title) {
+ state.title = argv[0];
+ }
- if (outfn) {
- outfd = open_log(outfn);
- if (outfd == -1)
+ if (state.output_filename) {
+ state.output_fd = open_log(state.output_filename);
+ if (state.output_fd == -1) {
err(7, "open");
+ }
+ }
+
+ if (state.syslog_enabled) {
+ openlog(state.syslog_tag, LOG_PID | LOG_NDELAY,
+ state.syslog_facility);
}
-
- if (dosyslog)
- openlog(logtag, LOG_PID | LOG_NDELAY, logfac);
- ppfh = pfh = NULL;
/*
* Try to open the pidfile before calling daemon(3),
* to be able to report the error intelligently
*/
- open_pid_files(pidfile, ppidfile, &pfh, &ppfh);
- if (daemon(nochdir, noclose) == -1) {
+ open_pid_files(&state);
+
+ /*
+ * TODO: add feature to avoid backgrounding
+ * i.e. --foreground, -f
+ */
+ if (daemon(state.keep_cur_workdir, state.keep_fds_open) == -1) {
warn("daemon");
- goto exit;
+ daemon_terminate(&state);
+ }
+
+ if (state.mode == MODE_DAEMON) {
+ daemon_exec(&state);
}
+
/* Write out parent pidfile if needed. */
- pidfile_write(ppfh);
+ pidfile_write(state.parent_pidfh);
+
+ do {
+ state.mode = MODE_SUPERVISE;
+ daemon_eventloop(&state);
+ daemon_sleep(&state);
+ } while (state.restart_enabled);
+
+ daemon_terminate(&state);
+}
+
+static void
+daemon_exec(struct daemon_state *state)
+{
+ pidfile_write(state->child_pidfh);
+
+ if (state->user != NULL) {
+ restrict_process(state->user);
+ }
+
+ /* Ignored signals remain ignored after execve, unignore them */
+ signal(SIGHUP, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
+ execvp(state->argv[0], state->argv);
+ /* execvp() failed - report error and exit this process */
+ err(1, "%s", state->argv[0]);
+}
+
+/* Main event loop: fork the child and watch for events.
+ * After SIGTERM is received and propagated to the child there are
+ * several options on what to do next:
+ * - read until EOF
+ * - read until EOF but only for a while
+ * - bail immediately
+ * Currently the third option is used, because otherwise there is no
+ * guarantee that read() won't block indefinitely if the child refuses
+ * to depart. To handle the second option, a different approach
+ * would be needed (procctl()?).
+ */
+static void
+daemon_eventloop(struct daemon_state *state)
+{
+ struct kevent event;
+ int kq;
+ int ret;
+ int pipe_fd[2];
+
/*
- * If the pidfile or restart option is specified the daemon
- * executes the command in a forked process and wait on child
- * exit to remove the pidfile or restart the command. Normally
- * we don't want the monitoring daemon to be terminated
- * leaving the running process and the stale pidfile, so we
- * catch SIGTERM and forward it to the children expecting to
- * get SIGCHLD eventually. We also must fork() to obtain a
- * readable pipe with the child for writing to a log file
- * and syslog.
+ * Try to protect against pageout kill. Ignore the
+ * error, madvise(2) will fail only if a process does
+ * not have superuser privileges.
*/
- pid = -1;
- if (pidfile || ppidfile || restart || outfd != -1 || dosyslog) {
- struct sigaction act_term, act_chld, act_hup;
-
- /* Avoid PID racing with SIGCHLD and SIGTERM. */
- memset(&act_term, 0, sizeof(act_term));
- act_term.sa_handler = handle_term;
- sigemptyset(&act_term.sa_mask);
- sigaddset(&act_term.sa_mask, SIGCHLD);
-
- memset(&act_chld, 0, sizeof(act_chld));
- act_chld.sa_handler = handle_chld;
- sigemptyset(&act_chld.sa_mask);
- sigaddset(&act_chld.sa_mask, SIGTERM);
-
- memset(&act_hup, 0, sizeof(act_hup));
- act_hup.sa_handler = handle_hup;
- sigemptyset(&act_hup.sa_mask);
-
- /* Block these when avoiding racing before sigsuspend(). */
- sigemptyset(&mask_susp);
- sigaddset(&mask_susp, SIGTERM);
- sigaddset(&mask_susp, SIGCHLD);
- /* Block SIGTERM when we lack a valid child PID. */
- sigemptyset(&mask_term);
- sigaddset(&mask_term, SIGTERM);
- /*
- * When reading, we wish to avoid SIGCHLD. SIGTERM
- * has to be caught, otherwise we'll be stuck until
- * the read() returns - if it returns.
- */
- sigemptyset(&mask_read);
- sigaddset(&mask_read, SIGCHLD);
- /* Block SIGTERM to avoid racing until we have forked. */
- if (sigprocmask(SIG_BLOCK, &mask_term, &mask_orig)) {
- warn("sigprocmask");
- goto exit;
- }
- if (sigaction(SIGTERM, &act_term, NULL) == -1) {
- warn("sigaction");
- goto exit;
- }
- if (sigaction(SIGCHLD, &act_chld, NULL) == -1) {
- warn("sigaction");
- goto exit;
- }
- /*
- * Try to protect against pageout kill. Ignore the
- * error, madvise(2) will fail only if a process does
- * not have superuser privileges.
- */
- (void)madvise(NULL, 0, MADV_PROTECT);
- logpar.outfd = outfd;
- logpar.dosyslog = dosyslog;
- logpar.logpri = logpri;
- logpar.noclose = noclose;
- logpar.outfn = outfn;
- if (log_reopen && outfd >= 0 &&
- sigaction(SIGHUP, &act_hup, NULL) == -1) {
- warn("sigaction");
- goto exit;
+ (void)madvise(NULL, 0, MADV_PROTECT);
+
+ if (pipe(pipe_fd)) {
+ err(1, "pipe");
+ }
+ state->pipe_rd = pipe_fd[0];
+ state->pipe_wr = pipe_fd[1];
+
+ kq = kqueuex(KQUEUE_CLOEXEC);
+ EV_SET(&event, state->pipe_rd, EVFILT_READ, EV_ADD|EV_CLEAR, 0, 0,
+ NULL);
+ if (kevent(kq, &event, 1, NULL, 0, NULL) == -1) {
+ err(EXIT_FAILURE, "failed to register kevent");
+ }
+
+ EV_SET(&event, SIGHUP, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL);
+ if (kevent(kq, &event, 1, NULL, 0, NULL) == -1) {
+ err(EXIT_FAILURE, "failed to register kevent");
+ }
+
+ EV_SET(&event, SIGTERM, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL);
+ if (kevent(kq, &event, 1, NULL, 0, NULL) == -1) {
+ err(EXIT_FAILURE, "failed to register kevent");
+ }
+
+ EV_SET(&event, SIGCHLD, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL);
+ if (kevent(kq, &event, 1, NULL, 0, NULL) == -1) {
+ err(EXIT_FAILURE, "failed to register kevent");
+ }
+ memset(&event, 0, sizeof(struct kevent));
+
+ /* Spawn a child to exec the command. */
+ state->pid = fork();
+
+ /* fork failed, this can only happen when supervision is enabled */
+ switch (state->pid) {
+ case -1:
+ warn("fork");
+ state->mode = MODE_NOCHILD;
+ return;
+ /* fork succeeded, this is child's branch */
+ case 0:
+ close(kq);
+ daemon_set_child_pipe(state);
+ daemon_exec(state);
+ break;
+ }
+
+ /* case: pid > 0; fork succeeded */
+ close(state->pipe_wr);
+ state->pipe_wr = -1;
+ setproctitle("%s[%d]", state->title, (int)state->pid);
+ setbuf(stdout, NULL);
+
+ while (state->mode != MODE_NOCHILD) {
+ ret = kevent(kq, NULL, 0, &event, 1, NULL);
+ switch (ret) {
+ case -1:
+ if (errno == EINTR)
+ continue;
+ err(EXIT_FAILURE, "kevent wait");
+ case 0:
+ continue;
}
-restart:
- if (pipe(pfd))
- err(1, "pipe");
- /*
- * Spawn a child to exec the command.
- */
- child_gone = 0;
- pid = fork();
- if (pid == -1) {
- warn("fork");
- goto exit;
- } else if (pid > 0) {
- /*
- * Unblock SIGTERM after we know we have a valid
- * child PID to signal.
- */
- if (sigprocmask(SIG_UNBLOCK, &mask_term, NULL)) {
- warn("sigprocmask");
- goto exit;
- }
- close(pfd[1]);
- pfd[1] = -1;
+
+ if (event.flags & EV_ERROR) {
+ errx(EXIT_FAILURE, "Event error: %s",
+ strerror((int)event.data));
}
- }
- if (pid <= 0) {
- /* Now that we are the child, write out the pid. */
- pidfile_write(pfh);
- if (user != NULL)
- restrict_process(user);
- /*
- * When forking, the child gets the original sigmask,
- * and dup'd pipes.
- */
- if (pid == 0) {
- close(pfd[0]);
- if (sigprocmask(SIG_SETMASK, &mask_orig, NULL))
- err(1, "sigprogmask");
- if (stdmask & STDERR_FILENO) {
- if (dup2(pfd[1], STDERR_FILENO) == -1)
- err(1, "dup2");
+ switch (event.filter) {
+ case EVFILT_SIGNAL:
+
+ switch (event.ident) {
+ case SIGCHLD:
+ if (daemon_is_child_dead(state)) {
+ /* child is dead, read all until EOF */
+ state->pid = -1;
+ state->mode = MODE_NOCHILD;
+ while (listen_child(state)) {
+ continue;
+ }
+ }
+ continue;
+ case SIGTERM:
+ if (state->mode != MODE_SUPERVISE) {
+ /* user is impatient */
+ /* TODO: warn about repeated SIGTERM? */
+ continue;
+ }
+
+ state->mode = MODE_TERMINATING;
+ state->restart_enabled = false;
+ if (state->pid > 0) {
+ kill(state->pid, SIGTERM);
+ }
+ /*
+ * TODO set kevent timer to exit
+ * unconditionally after some time
+ */
+ continue;
+ case SIGHUP:
+ if (state->log_reopen && state->output_fd >= 0) {
+ reopen_log(state);
+ }
+ continue;
}
- if (stdmask & STDOUT_FILENO) {
- if (dup2(pfd[1], STDOUT_FILENO) == -1)
- err(1, "dup2");
- }
- if (pfd[1] != STDERR_FILENO &&
- pfd[1] != STDOUT_FILENO)
- close(pfd[1]);
- }
- execvp(argv[0], argv);
- /*
- * execvp() failed -- report the error. The child is
- * now running, so the exit status doesn't matter.
- */
- err(1, "%s", argv[0]);
- }
- setproctitle("%s[%d]", title, (int)pid);
- /*
- * As we have closed the write end of pipe for parent process,
- * we might detect the child's exit by reading EOF. The child
- * might have closed its stdout and stderr, so we must wait for
- * the SIGCHLD to ensure that the process is actually gone.
- */
- child_eof = 0;
- for (;;) {
- /*
- * We block SIGCHLD when listening, but SIGTERM we accept
- * so the read() won't block if we wish to depart.
- *
- * Upon receiving SIGTERM, we have several options after
- * sending the SIGTERM to our child:
- * - read until EOF
- * - read until EOF but only for a while
- * - bail immediately
- *
- * We go for the third, as otherwise we have no guarantee
- * that we won't block indefinitely if the child refuses
- * to depart. To handle the second option, a different
- * approach would be needed (procctl()?)
- */
- if (child_gone && child_eof) {
break;
- } else if (terminate) {
- goto exit;
- } else if (!child_eof) {
- if (sigprocmask(SIG_BLOCK, &mask_read, NULL)) {
- warn("sigprocmask");
- goto exit;
- }
- child_eof = !listen_child(pfd[0], &logpar);
- if (sigprocmask(SIG_UNBLOCK, &mask_read, NULL)) {
- warn("sigprocmask");
- goto exit;
- }
- } else {
- if (sigprocmask(SIG_BLOCK, &mask_susp, NULL)) {
- warn("sigprocmask");
- goto exit;
- }
- while (!terminate && !child_gone)
- sigsuspend(&mask_orig);
- if (sigprocmask(SIG_UNBLOCK, &mask_susp, NULL)) {
- warn("sigprocmask");
- goto exit;
+
+ case EVFILT_READ:
+ /*
+ * detecting EOF is no longer necessary
+ * if child closes the pipe daemon will stop getting
+ * EVFILT_READ events
+ */
+
+ if (event.data > 0) {
+ (void)listen_child(state);
}
+ continue;
+ default:
+ continue;
}
}
- if (restart && !terminate)
- daemon_sleep(restart, 0);
- if (sigprocmask(SIG_BLOCK, &mask_term, NULL)) {
- warn("sigprocmask");
- goto exit;
- }
- if (restart && !terminate) {
- close(pfd[0]);
- pfd[0] = -1;
- goto restart;
- }
-exit:
- close(outfd);
- close(pfd[0]);
- close(pfd[1]);
- if (dosyslog)
- closelog();
- pidfile_remove(pfh);
- pidfile_remove(ppfh);
- exit(1); /* If daemon(3) succeeded exit status does not matter. */
+
+ close(kq);
+ close(state->pipe_rd);
+ state->pipe_rd = -1;
}
static void
-daemon_sleep(time_t secs, long nsecs)
+daemon_sleep(struct daemon_state *state)
{
- struct timespec ts = { secs, nsecs };
+ struct timespec ts = { state->restart_delay, 0 };
- while (!terminate && nanosleep(&ts, &ts) == -1) {
- if (errno != EINTR)
+ if (!state->restart_enabled) {
+ return;
+ }
+ while (nanosleep(&ts, &ts) == -1) {
+ if (errno != EINTR) {
err(1, "nanosleep");
+ }
}
}
static void
-open_pid_files(const char *pidfile, const char *ppidfile,
- struct pidfh **pfh, struct pidfh **ppfh)
+open_pid_files(struct daemon_state *state)
{
pid_t fpid;
int serrno;
- if (pidfile) {
- *pfh = pidfile_open(pidfile, 0600, &fpid);
- if (*pfh == NULL) {
+ if (state->child_pidfile) {
+ state->child_pidfh = pidfile_open(state->child_pidfile, 0600, &fpid);
+ if (state->child_pidfh == NULL) {
if (errno == EEXIST) {
errx(3, "process already running, pid: %d",
fpid);
}
- err(2, "pidfile ``%s''", pidfile);
+ err(2, "pidfile ``%s''", state->child_pidfile);
}
}
/* Do the same for the actual daemon process. */
- if (ppidfile) {
- *ppfh = pidfile_open(ppidfile, 0600, &fpid);
- if (*ppfh == NULL) {
+ if (state->parent_pidfile) {
+ state->parent_pidfh= pidfile_open(state->parent_pidfile, 0600, &fpid);
+ if (state->parent_pidfh == NULL) {
serrno = errno;
- pidfile_remove(*pfh);
+ pidfile_remove(state->child_pidfh);
errno = serrno;
if (errno == EEXIST) {
errx(3, "process already running, pid: %d",
fpid);
}
- err(2, "ppidfile ``%s''", ppidfile);
+ err(2, "ppidfile ``%s''", state->parent_pidfile);
}
}
}
@@ -449,8 +559,9 @@ get_log_mapping(const char *str, const CODE *c)
{
const CODE *cp;
for (cp = c; cp->c_name; cp++)
- if (strcmp(cp->c_name, str) == 0)
+ if (strcmp(cp->c_name, str) == 0) {
return cp->c_val;
+ }
return -1;
}
@@ -460,72 +571,80 @@ restrict_process(const char *user)
struct passwd *pw = NULL;
pw = getpwnam(user);
- if (pw == NULL)
+ if (pw == NULL) {
errx(1, "unknown user: %s", user);
+ }
- if (setusercontext(NULL, pw, pw->pw_uid, LOGIN_SETALL) != 0)
+ if (setusercontext(NULL, pw, pw->pw_uid, LOGIN_SETALL) != 0) {
errx(1, "failed to set user environment");
+ }
+
+ setenv("USER", pw->pw_name, 1);
+ setenv("HOME", pw->pw_dir, 1);
+ setenv("SHELL", *pw->pw_shell ? pw->pw_shell : _PATH_BSHELL, 1);
}
/*
* We try to collect whole lines terminated by '\n'. Otherwise we collect a
* full buffer, and then output it.
*
- * Return value of 0 is assumed to mean EOF or error, and 1 indicates to
+ * Return value of false is assumed to mean EOF or error, and true indicates to
* continue reading.
*/
-static int
-listen_child(int fd, struct log_params *logpar)
+static bool
+listen_child(struct daemon_state *state)
{
- static unsigned char buf[LBUF_SIZE];
- static size_t bytes_read = 0;
- int rv;
+ ssize_t rv;
+ unsigned char *cp;
- assert(logpar);
- assert(bytes_read < LBUF_SIZE - 1);
+ assert(state != NULL);
+ assert(state->pos < LBUF_SIZE - 1);
- if (do_log_reopen)
- reopen_log(logpar);
- rv = read(fd, buf + bytes_read, LBUF_SIZE - bytes_read - 1);
+ rv = read(state->pipe_rd, state->buf + state->pos,
+ LBUF_SIZE - state->pos - 1);
if (rv > 0) {
- unsigned char *cp;
-
- bytes_read += rv;
- assert(bytes_read <= LBUF_SIZE - 1);
+ state->pos += rv;
+ assert(state->pos <= LBUF_SIZE - 1);
/* Always NUL-terminate just in case. */
- buf[LBUF_SIZE - 1] = '\0';
+ state->buf[LBUF_SIZE - 1] = '\0';
+
/*
- * Chomp line by line until we run out of buffer.
+ * Find position of the last newline in the buffer.
+ * The buffer is guaranteed to have one or more complete lines
+ * if at least one newline was found when searching in reverse.
+ * All complete lines are flushed.
* This does not take NUL characters into account.
*/
- while ((cp = memchr(buf, '\n', bytes_read)) != NULL) {
- size_t bytes_line = cp - buf + 1;
- assert(bytes_line <= bytes_read);
- do_output(buf, bytes_line, logpar);
- bytes_read -= bytes_line;
- memmove(buf, cp + 1, bytes_read);
+ cp = memrchr(state->buf, '\n', state->pos);
+ if (cp != NULL) {
+ size_t bytes_line = cp - state->buf + 1;
+ assert(bytes_line <= state->pos);
+ do_output(state->buf, bytes_line, state);
+ state->pos -= bytes_line;
+ memmove(state->buf, cp + 1, state->pos);
}
/* Wait until the buffer is full. */
- if (bytes_read < LBUF_SIZE - 1)
- return 1;
- do_output(buf, bytes_read, logpar);
- bytes_read = 0;
- return 1;
+ if (state->pos < LBUF_SIZE - 1) {
+ return true;
+ }
+ do_output(state->buf, state->pos, state);
+ state->pos = 0;
+ return true;
} else if (rv == -1) {
/* EINTR should trigger another read. */
if (errno == EINTR) {
- return 1;
+ return true;
} else {
warn("read");
- return 0;
+ return false;
}
}
/* Upon EOF, we have to flush what's left of the buffer. */
- if (bytes_read > 0) {
- do_output(buf, bytes_read, logpar);
- bytes_read = 0;
+ if (state->pos > 0) {
+ do_output(state->buf, state->pos, state);
+ state->pos = 0;
}
- return 0;
+ return false;
}
/*
@@ -534,85 +653,150 @@ listen_child(int fd, struct log_params *logpar)
* everything back to parent's stdout.
*/
static void
-do_output(const unsigned char *buf, size_t len, struct log_params *logpar)
+do_output(const unsigned char *buf, size_t len, struct daemon_state *state)
{
assert(len <= LBUF_SIZE);
- assert(logpar);
+ assert(state != NULL);
- if (len < 1)
+ if (len < 1) {
return;
- if (logpar->dosyslog)
- syslog(logpar->logpri, "%.*s", (int)len, buf);
- if (logpar->outfd != -1) {
- if (write(logpar->outfd, buf, len) == -1)
+ }
+ if (state->syslog_enabled) {
+ syslog(state->syslog_priority, "%.*s", (int)len, buf);
+ }
+ if (state->output_fd != -1) {
+ if (write(state->output_fd, buf, len) == -1)
warn("write");
}
- if (logpar->noclose && !logpar->dosyslog && logpar->outfd == -1)
+ if (state->keep_fds_open &&
+ !state->syslog_enabled &&
+ state->output_fd == -1) {
printf("%.*s", (int)len, buf);
+ }
}
-/*
- * We use the global PID acquired directly from fork. If there is no valid
- * child pid, the handler should be blocked and/or child_gone == 1.
- */
-static void
-handle_term(int signo)
+static int
+open_log(const char *outfn)
{
- if (pid > 0 && !child_gone)
- kill(pid, signo);
- terminate = 1;
+
+ return open(outfn, O_CREAT | O_WRONLY | O_APPEND | O_CLOEXEC, 0600);
}
static void
-handle_chld(int signo __unused)
+reopen_log(struct daemon_state *state)
{
+ int outfd;
- for (;;) {
- int rv = waitpid(-1, NULL, WNOHANG);
- if (pid == rv) {
- child_gone = 1;
- break;
- } else if (rv == -1 && errno != EINTR) {
- warn("waitpid");
- return;
- }
+ outfd = open_log(state->output_filename);
+ if (state->output_fd >= 0) {
+ close(state->output_fd);
}
+ state->output_fd = outfd;
}
static void
-handle_hup(int signo __unused)
+daemon_state_init(struct daemon_state *state)
{
-
- do_log_reopen = 1;
+ *state = (struct daemon_state) {
+ .buf = {0},
+ .pos = 0,
+ .argv = NULL,
+ .parent_pidfh = NULL,
+ .child_pidfh = NULL,
+ .child_pidfile = NULL,
+ .parent_pidfile = NULL,
+ .title = NULL,
+ .user = NULL,
+ .mode = MODE_DAEMON,
+ .restart_enabled = false,
+ .pid = 0,
+ .pipe_rd = -1,
+ .pipe_wr = -1,
+ .keep_cur_workdir = 1,
+ .restart_delay = 1,
+ .stdmask = STDOUT_FILENO | STDERR_FILENO,
+ .syslog_enabled = false,
+ .log_reopen = false,
+ .syslog_priority = LOG_NOTICE,
+ .syslog_tag = "daemon",
+ .syslog_facility = LOG_DAEMON,
+ .keep_fds_open = 1,
+ .output_fd = -1,
+ .output_filename = NULL,
+ };
}
-static int
-open_log(const char *outfn)
+static _Noreturn void
+daemon_terminate(struct daemon_state *state)
{
+ assert(state != NULL);
- return open(outfn, O_CREAT | O_WRONLY | O_APPEND | O_CLOEXEC, 0600);
+ if (state->output_fd >= 0) {
+ close(state->output_fd);
+ }
+ if (state->pipe_rd >= 0) {
+ close(state->pipe_rd);
+ }
+
+ if (state->pipe_wr >= 0) {
+ close(state->pipe_wr);
+ }
+ if (state->syslog_enabled) {
+ closelog();
+ }
+ pidfile_remove(state->child_pidfh);
+ pidfile_remove(state->parent_pidfh);
+
+ /*
+ * Note that the exit value here doesn't matter in the case of a clean
+ * exit; daemon(3) already detached us from the caller, nothing is left
+ * to care about this one.
+ */
+ exit(1);
}
-static void
-reopen_log(struct log_params *lpp)
+/*
+ * Returns true if SIGCHILD came from state->pid due to its exit.
+ */
+static bool
+daemon_is_child_dead(struct daemon_state *state)
{
- int outfd;
+ int status;
- do_log_reopen = 0;
- outfd = open_log(lpp->outfn);
- if (lpp->outfd >= 0)
- close(lpp->outfd);
- lpp->outfd = outfd;
+ for (;;) {
+ int who = waitpid(-1, &status, WNOHANG);
+ if (state->pid == who && (WIFEXITED(status) ||
+ WIFSIGNALED(status))) {
+ return true;
+ }
+ if (who == 0) {
+ return false;
+ }
+ if (who == -1 && errno != EINTR) {
+ warn("waitpid");
+ return false;
+ }
+ }
}
static void
-usage(void)
+daemon_set_child_pipe(struct daemon_state *state)
{
- (void)fprintf(stderr,
- "usage: daemon [-cfHrS] [-p child_pidfile] [-P supervisor_pidfile]\n"
- " [-u user] [-o output_file] [-t title]\n"
- " [-l syslog_facility] [-s syslog_priority]\n"
- " [-T syslog_tag] [-m output_mask] [-R restart_delay_secs]\n"
- "command arguments ...\n");
- exit(1);
+ if (state->stdmask & STDERR_FILENO) {
+ if (dup2(state->pipe_wr, STDERR_FILENO) == -1) {
+ err(1, "dup2");
+ }
+ }
+ if (state->stdmask & STDOUT_FILENO) {
+ if (dup2(state->pipe_wr, STDOUT_FILENO) == -1) {
+ err(1, "dup2");
+ }
+ }
+ if (state->pipe_wr != STDERR_FILENO &&
+ state->pipe_wr != STDOUT_FILENO) {
+ close(state->pipe_wr);
+ }
+
+ /* The child gets dup'd pipes. */
+ close(state->pipe_rd);
}
diff --git a/usr.sbin/daemon/tests/Makefile b/usr.sbin/daemon/tests/Makefile
index c687361ec4e7..c5c6470416db 100644
--- a/usr.sbin/daemon/tests/Makefile
+++ b/usr.sbin/daemon/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/usr.sbin/daemon/tests/daemon_test.sh b/usr.sbin/daemon/tests/daemon_test.sh
index ab5d86e0e71b..948a9f6a8a57 100644
--- a/usr.sbin/daemon/tests/daemon_test.sh
+++ b/usr.sbin/daemon/tests/daemon_test.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2021 Axcient
#
@@ -25,8 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-# $FreeBSD$
-
atf_test_case both_pidfile cleanup
both_pidfile_head() {
atf_set "descr" "daemon should write pid files for itself and its child"
diff --git a/usr.sbin/dconschat/Makefile b/usr.sbin/dconschat/Makefile
index c0bc058c22e6..f5f7795f284b 100644
--- a/usr.sbin/dconschat/Makefile
+++ b/usr.sbin/dconschat/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= dconschat
MAN= dconschat.8
diff --git a/usr.sbin/dconschat/Makefile.depend b/usr.sbin/dconschat/Makefile.depend
index daaa39c06eaf..0d74e2b83f8e 100644
--- a/usr.sbin/dconschat/Makefile.depend
+++ b/usr.sbin/dconschat/Makefile.depend
@@ -1,15 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libelf \
lib/libkvm \
diff --git a/usr.sbin/dconschat/dconschat.8 b/usr.sbin/dconschat/dconschat.8
index 330f44c530c5..1f93e6d5a235 100644
--- a/usr.sbin/dconschat/dconschat.8
+++ b/usr.sbin/dconschat/dconschat.8
@@ -22,10 +22,8 @@
.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
.\"
-.\"
-.Dd February 11, 2003
+.Dd September 29, 2022
.Dt DCONSCHAT 8
.Os
.Sh NAME
@@ -79,16 +77,16 @@ utility and the
.Xr dcons 4
driver communicate using 2 ports, one for the console port and another
for remote
-.Xr gdb 1
+.Xr gdb 1 Pq Pa ports/devel/gdb
port.
Users are supposed to access
.Nm
using TTY,
.Xr telnet 1
and
-.Xr gdb 1 .
+.Xr gdb 1 Pq Pa ports/devel/gdb .
You can specify listen ports for console and
-.Xr gdb 1
+.Xr gdb 1 Pq Pa ports/devel/gdb
port using the
.Fl C
and
@@ -104,7 +102,7 @@ device, the
acts as a slave device and
.Nm
acts as a master device with
-.Xr telnetd 8 .
+.Nm telnetd .
.Pp
Typed characters are normally transmitted directly to
.Xr dcons 4 .
@@ -129,7 +127,7 @@ The following options are supported.
Translate Ctrl-C to ALT_BREAK (CR +
.Ql ~
+ Ctrl-B) on
-.Xr gdb 1
+.Xr gdb 1 Pq Pa ports/devel/gdb
port.
.It Fl r
Replay old buffer on connection.
@@ -169,7 +167,7 @@ Specify the console port.
The default value is 0 (stdin/stdout).
.It Fl G Ar gdb_port
Specify
-.Xr gdb 1
+.Xr gdb 1 Pq Pa ports/devel/gdb
port.
The default value is \-1 (disabled).
.It Fl M Ar core
@@ -252,9 +250,9 @@ To quit the session, type CR +
in the console port.
.Pp
Using
-.Xr gdb 1
+.Xr gdb 1 Pq Pa ports/devel/gdb
port is almost the same as remote
-.Xr gdb 1
+.Xr gdb 1 Pq Pa ports/devel/gdb
over serial line except
using TCP/IP instead of
.Pa /dev/cu* .
@@ -271,13 +269,13 @@ for details.
.Ed
.Pp
Once
-.Xr gdb 1
+.Xr gdb 1 Pq Pa ports/devel/gdb
is attached and you specified the
.Fl b
option to
.Nm ,
typing Ctrl-C in
-.Xr gdb 1
+.Xr gdb 1 Pq Pa ports/devel/gdb
causes a break to debugger.
.Pp
The following command gets the console log from the crash dump:
@@ -311,7 +309,7 @@ console remote {
}
.Ed
.Sh SEE ALSO
-.Xr gdb 1 ,
+.Xr gdb 1 Pq Pa ports/devel/gdb ,
.Xr telnet 1 ,
.Xr kvm 3 ,
.Xr dcons 4 ,
diff --git a/usr.sbin/dconschat/dconschat.c b/usr.sbin/dconschat/dconschat.c
index c7e21460226c..72d1aa276bd3 100644
--- a/usr.sbin/dconschat/dconschat.c
+++ b/usr.sbin/dconschat/dconschat.c
@@ -34,7 +34,6 @@
* SUCH DAMAGE.
*
* $Id: dconschat.c,v 1.76 2003/10/23 06:21:13 simokawa Exp $
- * $FreeBSD$
*/
#include <sys/param.h>
@@ -281,7 +280,7 @@ dconschat_get_crom(struct dcons_state *dc)
for (i = 20; i < 0x400; i += 4) {
if (dread(dc, &buf, 4, addr + i) < 0) {
if (verbose)
- warn("crom read faild");
+ warn("crom read failed");
goto out;
}
buf = ntohl(buf);
@@ -681,7 +680,6 @@ dconschat_init_socket(struct dcons_state *dc, int port, char *host, int sport)
error = kevent(dc->kq, &kev, 1, NULL, 0, &dc->to);
if (error < 0)
err(1, "kevent");
- return;
}
static int
diff --git a/usr.sbin/devctl/Makefile b/usr.sbin/devctl/Makefile
index a7deb3793181..cf52a8632292 100644
--- a/usr.sbin/devctl/Makefile
+++ b/usr.sbin/devctl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= devctl
MAN= devctl.8
diff --git a/usr.sbin/devctl/Makefile.depend b/usr.sbin/devctl/Makefile.depend
index 74130daab290..fed1efaf7831 100644
--- a/usr.sbin/devctl/Makefile.depend
+++ b/usr.sbin/devctl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/devctl/devctl.8 b/usr.sbin/devctl/devctl.8
index 533ecac4c23a..41f2dd915708 100644
--- a/usr.sbin/devctl/devctl.8
+++ b/usr.sbin/devctl/devctl.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 31, 2021
.Dt DEVCTL 8
.Os
diff --git a/usr.sbin/devctl/devctl.c b/usr.sbin/devctl/devctl.c
index 1417b087b535..66bfb7dc6ed1 100644
--- a/usr.sbin/devctl/devctl.c
+++ b/usr.sbin/devctl/devctl.c
@@ -24,8 +24,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/linker_set.h>
#include <devctl.h>
#include <err.h>
diff --git a/usr.sbin/devinfo/Makefile b/usr.sbin/devinfo/Makefile
index 681c8197f5de..35444d5d5e68 100644
--- a/usr.sbin/devinfo/Makefile
+++ b/usr.sbin/devinfo/Makefile
@@ -1,5 +1,5 @@
-# $FreeBSD$
+PACKAGE= devmatch
PROG= devinfo
MAN= devinfo.8
diff --git a/usr.sbin/devinfo/Makefile.depend b/usr.sbin/devinfo/Makefile.depend
index 2c68d7ccef0d..a4d91ccfc657 100644
--- a/usr.sbin/devinfo/Makefile.depend
+++ b/usr.sbin/devinfo/Makefile.depend
@@ -1,9 +1,8 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
+ include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
diff --git a/usr.sbin/devinfo/devinfo.8 b/usr.sbin/devinfo/devinfo.8
index 091248250830..f2b9a5d5cbaf 100644
--- a/usr.sbin/devinfo/devinfo.8
+++ b/usr.sbin/devinfo/devinfo.8
@@ -25,9 +25,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 1, 2021
+.Dd July 5, 2022
.Dt DEVINFO 8
.Os
.Sh NAME
@@ -73,6 +71,7 @@ back to the root of the device tree.
.Sh SEE ALSO
.Xr systat 1 ,
.Xr devinfo 3 ,
+.Xr devctl 8 ,
.Xr iostat 8 ,
.Xr pciconf 8 ,
.Xr vmstat 8 ,
diff --git a/usr.sbin/devinfo/devinfo.c b/usr.sbin/devinfo/devinfo.c
index ee5ac0a1f7eb..a035d958ab80 100644
--- a/usr.sbin/devinfo/devinfo.c
+++ b/usr.sbin/devinfo/devinfo.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2000, 2001 Michael Smith
* Copyright (c) 2000 BSDi
@@ -31,9 +31,6 @@
* Print information about system device configuration.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <err.h>
#include <errno.h>
diff --git a/usr.sbin/diskinfo/Makefile b/usr.sbin/diskinfo/Makefile
index 41c52da551be..d6e2b3c3a94a 100644
--- a/usr.sbin/diskinfo/Makefile
+++ b/usr.sbin/diskinfo/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= diskinfo
MAN= diskinfo.8
diff --git a/usr.sbin/diskinfo/Makefile.depend b/usr.sbin/diskinfo/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/diskinfo/Makefile.depend
+++ b/usr.sbin/diskinfo/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/diskinfo/diskinfo.8 b/usr.sbin/diskinfo/diskinfo.8
index 753850d4ca5c..970bafd4f8e5 100644
--- a/usr.sbin/diskinfo/diskinfo.8
+++ b/usr.sbin/diskinfo/diskinfo.8
@@ -27,9 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd July 4, 2017
+.Dd March 5, 2024
.Dt DISKINFO 8
.Os
.Sh NAME
@@ -40,10 +38,12 @@
.Op Fl citSvw
.Ar disk ...
.Nm
-.Op Fl p
+.Op Fl l
+.Fl p
.Ar disk ...
.Nm
-.Op Fl s
+.Op Fl l
+.Fl s
.Ar disk ...
.Sh DESCRIPTION
The
@@ -59,6 +59,13 @@ Print fields one per line with a descriptive comment.
Perform a simple measurement of the I/O read command overhead.
.It Fl i
Perform a simple IOPS benchmark.
+.It Fl l
+In case of
+.Fl p
+or
+.Fl s
+modes prepend each line of an output with a device name using a tab
+character as a separator.
.It Fl p
Return the physical path of the disk.
This is a string that identifies the physical path to the disk in the
@@ -82,6 +89,14 @@ with the following fields: device name, sectorsize, media size in bytes,
media size in sectors, stripe size, stripe offset, firmware cylinders,
firmware heads, and firmware sectors.
The last three fields are only present if the information is available.
+.Sh EXAMPLES
+List first ten (at most)
+.Xr da 4
+devices with corresponding serial numbers:
+.Pp
+.Dl diskinfo -ls /dev/da?
+.Sh SEE ALSO
+.Xr da 4
.Sh HISTORY
The
.Nm
diff --git a/usr.sbin/diskinfo/diskinfo.c b/usr.sbin/diskinfo/diskinfo.c
index fa95a3b92148..f091d0ccfbea 100644
--- a/usr.sbin/diskinfo/diskinfo.c
+++ b/usr.sbin/diskinfo/diskinfo.c
@@ -29,8 +29,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 <stdbool.h>
@@ -60,11 +58,14 @@
static void
usage(void)
{
- fprintf(stderr, "usage: diskinfo [-cipsStvw] disk ...\n");
+ fprintf(stderr, "usage: diskinfo [-ciStvw] disk ...\n"
+ " diskinfo [-l] -p disk ...\n"
+ " diskinfo [-l] -s disk ...\n"
+ );
exit (1);
}
-static int opt_c, opt_i, opt_p, opt_s, opt_S, opt_t, opt_v, opt_w;
+static int opt_c, opt_i, opt_l, opt_p, opt_s, opt_S, opt_t, opt_v, opt_w;
static bool candelete(int fd);
static void speeddisk(int fd, off_t mediasize, u_int sectorsize);
@@ -90,7 +91,7 @@ main(int argc, char **argv)
u_int sectorsize, fwsectors, fwheads, zoned = 0, isreg;
uint32_t zone_mode;
- while ((ch = getopt(argc, argv, "cipsStvw")) != -1) {
+ while ((ch = getopt(argc, argv, "cilpsStvw")) != -1) {
switch (ch) {
case 'c':
opt_c = 1;
@@ -100,6 +101,9 @@ main(int argc, char **argv)
opt_i = 1;
opt_v = 1;
break;
+ case 'l':
+ opt_l = 1;
+ break;
case 'p':
opt_p = 1;
break;
@@ -171,6 +175,9 @@ main(int argc, char **argv)
goto out;
}
} else {
+ if (opt_l && (opt_p || opt_s)) {
+ printf("%s\t", argv[i]);
+ }
if (opt_p) {
if (ioctl(fd, DIOCGPHYSPATH, physpath) == 0) {
printf("%s\n", physpath);
@@ -527,7 +534,6 @@ speeddisk(int fd, off_t mediasize, u_int sectorsize)
TR(bulk * 1024);
printf("\n");
- return;
}
static void
@@ -559,7 +565,6 @@ commandtime(int fd, off_t mediasize, u_int sectorsize)
(dtsector - dtmega)*100/2048);
printf("\n");
- return;
}
static void
@@ -621,8 +626,6 @@ iops(int fd, off_t mediasize, u_int sectorsize)
}
TI(completed);
-
- return;
}
static void
diff --git a/usr.sbin/dumpcis/Makefile b/usr.sbin/dumpcis/Makefile
index 7a5a590090da..790b4a5a18e7 100644
--- a/usr.sbin/dumpcis/Makefile
+++ b/usr.sbin/dumpcis/Makefile
@@ -1,6 +1,5 @@
# pccardc Makefile
#
-# $FreeBSD$
PROG= dumpcis
MAN= dumpcis.8
diff --git a/usr.sbin/dumpcis/Makefile.depend b/usr.sbin/dumpcis/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/dumpcis/Makefile.depend
+++ b/usr.sbin/dumpcis/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/dumpcis/cardinfo.h b/usr.sbin/dumpcis/cardinfo.h
index 5cd810dabbd9..d58199158c4d 100644
--- a/usr.sbin/dumpcis/cardinfo.h
+++ b/usr.sbin/dumpcis/cardinfo.h
@@ -31,7 +31,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $FreeBSD$ */
#ifndef _PCCARD_CARDINFO_H_
#define _PCCARD_CARDINFO_H_
diff --git a/usr.sbin/dumpcis/cis.h b/usr.sbin/dumpcis/cis.h
index e511a85c7d8c..e0af86f58baa 100644
--- a/usr.sbin/dumpcis/cis.h
+++ b/usr.sbin/dumpcis/cis.h
@@ -32,8 +32,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$
- *
*/
/*
diff --git a/usr.sbin/dumpcis/dumpcis.8 b/usr.sbin/dumpcis/dumpcis.8
index 3f49807f205f..c40e5fe75d40 100644
--- a/usr.sbin/dumpcis/dumpcis.8
+++ b/usr.sbin/dumpcis/dumpcis.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 October 18, 2006
.Dt DUMPCIS 8
.Os
diff --git a/usr.sbin/dumpcis/main.c b/usr.sbin/dumpcis/main.c
index 28ae2dae49c4..50d87bcfeb4b 100644
--- a/usr.sbin/dumpcis/main.c
+++ b/usr.sbin/dumpcis/main.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 M. Warner Losh <imp@FreeBSD.org>
*
@@ -25,8 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
diff --git a/usr.sbin/dumpcis/printcis.c b/usr.sbin/dumpcis/printcis.c
index c6ec2beb3787..641fd19944d4 100644
--- a/usr.sbin/dumpcis/printcis.c
+++ b/usr.sbin/dumpcis/printcis.c
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Code cleanup, bug-fix and extension
* by Tatsumi Hosokawa <hosokawa@mt.cs.keio.ac.jp>
diff --git a/usr.sbin/dumpcis/readcis.c b/usr.sbin/dumpcis/readcis.c
index ce072d017cf4..9afdb6f2ba24 100644
--- a/usr.sbin/dumpcis/readcis.c
+++ b/usr.sbin/dumpcis/readcis.c
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Code cleanup, bug-fix and extension
* by Tatsumi Hosokawa <hosokawa@mt.cs.keio.ac.jp>
diff --git a/usr.sbin/dumpcis/readcis.h b/usr.sbin/dumpcis/readcis.h
index 14d9803eebc4..d89758dfcfe9 100644
--- a/usr.sbin/dumpcis/readcis.h
+++ b/usr.sbin/dumpcis/readcis.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 tuple {
diff --git a/usr.sbin/editmap/Makefile b/usr.sbin/editmap/Makefile
index 04ce398f2d51..0935595fd2c9 100644
--- a/usr.sbin/editmap/Makefile
+++ b/usr.sbin/editmap/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SENDMAIL_DIR=${SRCTOP}/contrib/sendmail
.PATH: ${SENDMAIL_DIR}/editmap
@@ -27,3 +26,5 @@ sm_os.h: ${SENDMAIL_DIR}/include/sm/os/sm_os_freebsd.h .NOMETA
ln -sf ${.ALLSRC} ${.TARGET}
.include <bsd.prog.mk>
+
+CWARNFLAGS+= ${NO_WDEPRECATED_NON_PROTOTYPE}
diff --git a/usr.sbin/editmap/Makefile.depend b/usr.sbin/editmap/Makefile.depend
index 0feabbf167e0..ec81c06f90f1 100644
--- a/usr.sbin/editmap/Makefile.depend
+++ b/usr.sbin/editmap/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/edquota/Makefile b/usr.sbin/edquota/Makefile
index 38d6eb3a55ce..3e9d0ede6721 100644
--- a/usr.sbin/edquota/Makefile
+++ b/usr.sbin/edquota/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= edquota
MAN= edquota.8
diff --git a/usr.sbin/edquota/Makefile.depend b/usr.sbin/edquota/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/edquota/Makefile.depend
+++ b/usr.sbin/edquota/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/edquota/edquota.8 b/usr.sbin/edquota/edquota.8
index fe50913d22c1..926576abf0d9 100644
--- a/usr.sbin/edquota/edquota.8
+++ b/usr.sbin/edquota/edquota.8
@@ -28,9 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)edquota.8 8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
-.\"
.Dd June 6, 1993
.Dt EDQUOTA 8
.Os
diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c
index de2083506864..6c209cd23716 100644
--- a/usr.sbin/edquota/edquota.c
+++ b/usr.sbin/edquota/edquota.c
@@ -32,21 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1990, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)edquota.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Disk quota editor.
*/
@@ -110,7 +95,7 @@ struct quotause *getprivs(long, int, char *);
void putprivs(long, struct quotause *);
int readprivs(struct quotause *, char *);
int readtimes(struct quotause *, char *);
-static void usage(void);
+static void usage(void) __dead2;
int writetimes(struct quotause *, int, int);
int writeprivs(struct quotause *, int, char *, int);
diff --git a/usr.sbin/edquota/pathnames.h b/usr.sbin/edquota/pathnames.h
index e5be2d24c518..3a9758a2abd3 100644
--- a/usr.sbin/edquota/pathnames.h
+++ b/usr.sbin/edquota/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/6/93
- * $FreeBSD$
*/
#include <paths.h>
diff --git a/usr.sbin/efibootmgr/Makefile b/usr.sbin/efibootmgr/Makefile
index 9e98412f6f74..d976656a99c9 100644
--- a/usr.sbin/efibootmgr/Makefile
+++ b/usr.sbin/efibootmgr/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
EFIBOOT=${SRCTOP}/stand/efi
EFIINCL=${SRCTOP}/stand/efi/include
EFIVAR=${SRCTOP}/usr.sbin/efivar
diff --git a/usr.sbin/efibootmgr/efibootmgr.8 b/usr.sbin/efibootmgr/efibootmgr.8
index 6b53de33db56..f74ee8a2e634 100644
--- a/usr.sbin/efibootmgr/efibootmgr.8
+++ b/usr.sbin/efibootmgr/efibootmgr.8
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd April 3, 2022
+.Dd December 17, 2023
.Dt EFIBOOTMGR 8
.Os
.Sh NAME
@@ -69,6 +67,7 @@
.Fl t Ar timeout
.Nm
.Fl T
+.Nm Fl u Ar unix-path
.Sh "DESCRIPTION"
The
.Nm
@@ -116,6 +115,11 @@ When creating or modifying an entry, use
.Ar bootnum
as the index.
When creating a new entry, fail if it already exists.
+For convenience, if
+.Ar bootnum
+is prefixed with
+.Dq boot ,
+that prefix is ignored.
.It Fl B -delete
Delete the given
.Ar bootnum
@@ -126,6 +130,21 @@ Create a new
variable (aka method or entry).
.It Fl D -dry-run
Process but do not change any variables.
+.It Fl e -env
+When creating a
+.Cm Boot
+variable, include a set of environment variables for the loader to set after
+parsing the command line.
+Variables are of the form
+.Dq a=b
+and separated by spaces.
+The argument should be quoted.
+.Nm appends these to the end of the
+.Cm Boot
+environment variable.
+Before processing anything else,
+.Xr loader.efi 8
+will parse this area and set all variables found there.
.It Fl E -esp
Print the
.Fx
@@ -174,6 +193,9 @@ Set the bootmenu timeout value.
Delete the
.Cm BootTimeout
variable.
+.It Fl u -efidev Ar unix-path
+Displays the UEFI device path of
+.Ar unix-path .
.It Fl v -verbose
Display the device path of boot entries in the output.
.El
@@ -209,16 +231,16 @@ the EFI partition mounted under
.Pa /boot/efi ,
mark the method active, using
the given loader and label the method
-.Qq FreeBSD-11 :
+.Qq FreeBSD-15 :
.Pp
-.Dl efibootmgr -a -c -l /boot/efi/EFI/freebsd/loader.efi -L FreeBSD-11
+.Dl efibootmgr -a -c -l /boot/efi/EFI/freebsd/loader.efi -L FreeBSD-15
.Pp
This will result in the next available bootnum being assigned to a
new UEFI boot variable, and given the label
-.Qq FreeBSD-11
+.Qq FreeBSD-15
such as:
.Pp
-.Dl Boot0009 FreeBSD-11
+.Dl Boot0009 FreeBSD-15
.Pp
Note newly created boot entries are, by default, created inactive, hence
the reason
diff --git a/usr.sbin/efibootmgr/efibootmgr.c b/usr.sbin/efibootmgr/efibootmgr.c
index 53bc417c4e07..b919130d9c11 100644
--- a/usr.sbin/efibootmgr/efibootmgr.c
+++ b/usr.sbin/efibootmgr/efibootmgr.c
@@ -24,10 +24,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/stat.h>
-#include <sys/vtoc.h>
#include <sys/param.h>
#include <assert.h>
#include <ctype.h>
@@ -70,6 +67,7 @@ __FBSDID("$FreeBSD$");
#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001
typedef struct _bmgr_opts {
+ char *dev;
char *env;
char *loader;
char *label;
@@ -85,6 +83,7 @@ typedef struct _bmgr_opts {
bool dry_run;
bool device_path;
bool esp_device;
+ bool find_dev;
bool fw_ui;
bool no_fw_ui;
bool has_bootnum;
@@ -114,6 +113,7 @@ static struct option lopts[] = {
{"dry-run", no_argument, NULL, 'D'},
{"env", required_argument, NULL, 'e'},
{"esp", no_argument, NULL, 'E'},
+ {"efidev", required_argument, NULL, 'u'},
{"fw-ui", no_argument, NULL, 'f'},
{"no-fw-ui", no_argument, NULL, 'F'},
{"help", no_argument, NULL, 'h'},
@@ -202,9 +202,10 @@ static void
parse_args(int argc, char *argv[])
{
int ch;
+ const char *arg;
- while ((ch = getopt_long(argc, argv, "AaBb:C:cdDe:EFfhk:L:l:NnOo:pTt:v",
- lopts, NULL)) != -1) {
+ while ((ch = getopt_long(argc, argv,
+ "AaBb:C:cdDe:EFfhk:L:l:NnOo:pTt:u:v", lopts, NULL)) != -1) {
switch (ch) {
case 'A':
opts.set_inactive = true;
@@ -214,7 +215,10 @@ parse_args(int argc, char *argv[])
break;
case 'b':
opts.has_bootnum = true;
- opts.bootnum = strtoul(optarg, NULL, 16);
+ arg = optarg;
+ if (strncasecmp(arg, "boot", 4) == 0)
+ arg += 4;
+ opts.bootnum = strtoul(arg, NULL, 16);
break;
case 'B':
opts.delete = true;
@@ -222,6 +226,8 @@ parse_args(int argc, char *argv[])
case 'C':
opts.copy = true;
opts.cp_src = strtoul(optarg, NULL, 16);
+ errx(1, "Copy not implemented");
+ break;
case 'c':
opts.create = true;
break;
@@ -284,6 +290,10 @@ parse_args(int argc, char *argv[])
opts.set_timeout = true;
opts.timeout = strtoul(optarg, NULL, 10);
break;
+ case 'u':
+ opts.find_dev = true;
+ opts.dev = strdup(optarg);
+ break;
case 'v':
opts.verbose = true;
break;
@@ -551,7 +561,7 @@ static char *
make_next_boot_var_name(void)
{
struct entry *v;
- uint16_t *vals, next_free = 0;
+ uint16_t *vals;
char *name;
int cnt = 0;
int i;
@@ -569,21 +579,14 @@ make_next_boot_var_name(void)
vals[i++] = v->idx;
}
qsort(vals, cnt, sizeof(uint16_t), compare);
- /* if the hole is at the beginning, just return zero */
- if (vals[0] > 0) {
- next_free = 0;
- } else {
- /* now just run the list looking for the first hole */
- for (i = 0; i < cnt - 1 && next_free == 0; i++)
- if (vals[i] + 1 != vals[i + 1])
- next_free = vals[i] + 1;
- if (next_free == 0)
- next_free = vals[cnt - 1] + 1;
- /* In theory we could have used all 65k slots -- what to do? */
- }
+ /* Find the first hole (could be at start or end) */
+ for (i = 0; i < cnt; ++i)
+ if (vals[i] != i)
+ break;
free(vals);
+ /* In theory we could have used all 65k slots -- what to do? */
- asprintf(&name, "%s%04X", "Boot", next_free);
+ asprintf(&name, "%s%04X", "Boot", i);
if (name == NULL)
err(1, "asprintf");
return name;
@@ -780,6 +783,8 @@ print_loadopt_str(uint8_t *data, size_t datalen)
*/
indent = 1;
while (dp < edp) {
+ if (efidp_size(dp) == 0)
+ break;
efidp_format_device_path(buf, sizeof(buf), dp,
(intptr_t)(void *)edp - (intptr_t)(void *)dp);
printf("%*s%s\n", indent, "", buf);
@@ -996,7 +1001,7 @@ report_esp_device(bool do_dp, bool do_unix)
char *name, *dev, *relpath, *abspath;
uint8_t *walker, *ep;
efi_char *descr;
- efidp dp, edp;
+ efidp dp;
char buf[PATH_MAX];
if (do_dp && do_unix)
@@ -1026,7 +1031,6 @@ report_esp_device(bool do_dp, bool do_unix)
// Now we have fplen bytes worth of file path stuff
dp = (efidp)walker;
walker += fplen;
- edp = (efidp)walker;
if (walker > ep)
errx(1, "malformed boot variable %s", name);
if (do_dp) {
@@ -1043,7 +1047,7 @@ report_esp_device(bool do_dp, bool do_unix)
abspath[strlen(abspath) - strlen(relpath) - 1] = '\0';
printf("%s\n", abspath);
} else {
- printf("%s\n", dev);
+ printf("/dev/%s\n", dev);
}
free(dev);
free(relpath);
@@ -1068,6 +1072,26 @@ set_boot_to_fw_ui(bool to_fw)
errx(1, "failed to set boot to fw ui");
}
+static void
+find_efi_device(const char *path)
+{
+ efidp dp = NULL;
+ size_t len;
+ int ret;
+ char buf[1024];
+
+ ret = efivar_unix_path_to_device_path(path, &dp);
+ if (ret != 0)
+ errc(1, ret,
+ "Cannot translate path '%s' to UEFI", path);
+ len = efidp_size(dp);
+ if (len > MAX_DP_LEN)
+ errx(1, "Resulting device path too long.");
+ efidp_format_device_path(buf, sizeof(buf), dp, len);
+ printf("%s -> %s\n", path, buf);
+ exit (0);
+}
+
int
main(int argc, char *argv[])
{
@@ -1075,8 +1099,14 @@ main(int argc, char *argv[])
memset(&opts, 0, sizeof (bmgr_opts_t));
parse_args(argc, argv);
- if (!efi_variables_supported())
- errx(1, "efi variables not supported on this system. root? kldload efirt?");
+ /*
+ * find_dev can operate without any efi variables
+ */
+ if (!efi_variables_supported() && !opts.find_dev) {
+ if (errno == EACCES && geteuid() != 0)
+ errx(1, "must be run as root");
+ errx(1, "efi variables not supported on this system. kldload efirt?");
+ }
read_vars();
@@ -1107,6 +1137,8 @@ main(int argc, char *argv[])
set_boot_to_fw_ui(true);
else if (opts.no_fw_ui)
set_boot_to_fw_ui(false);
+ else if (opts.find_dev)
+ find_efi_device(opts.dev);
print_boot_vars(opts.verbose);
}
diff --git a/usr.sbin/efidp/Makefile b/usr.sbin/efidp/Makefile
index 7b8bf2d1d556..a1edd8ac5e51 100644
--- a/usr.sbin/efidp/Makefile
+++ b/usr.sbin/efidp/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= efi-tools
diff --git a/usr.sbin/efidp/Makefile.depend b/usr.sbin/efidp/Makefile.depend
index 204b8d257e53..43c8da8637b0 100644
--- a/usr.sbin/efidp/Makefile.depend
+++ b/usr.sbin/efidp/Makefile.depend
@@ -1,14 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libefivar \
+ lib/libgeom \
.include <dirdeps.mk>
diff --git a/usr.sbin/efidp/efidp.8 b/usr.sbin/efidp/efidp.8
index ad98428a97a5..77629c590313 100644
--- a/usr.sbin/efidp/efidp.8
+++ b/usr.sbin/efidp/efidp.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 1, 2017
.Dt EFIDP 8
.Os
diff --git a/usr.sbin/efidp/efidp.c b/usr.sbin/efidp/efidp.c
index aef154112d66..513aa259e99a 100644
--- a/usr.sbin/efidp/efidp.c
+++ b/usr.sbin/efidp/efidp.c
@@ -24,8 +24,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <efivar.h>
#include <efivar-dp.h>
@@ -38,7 +36,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-#define MAXSIZE 65536 /* Everyting will be smaller than this, most 1000x smaller */
+#define MAXSIZE 65536 /* Everything will be smaller than this, most 1000x smaller */
/* options descriptor */
static struct option longopts[] = {
@@ -169,14 +167,13 @@ efi_to_unix(void)
char buffer[MAXSIZE];
char dpbuf[MAXSIZE];
efidp dp;
- size_t dplen;
char *walker, *dev, *relpath, *abspath;
int rv;
dp = (efidp)dpbuf;
while (fgets(buffer, sizeof(buffer), stdin)) {
walker= trim(buffer);
- dplen = efidp_parse_device_path(walker, dp, sizeof(dpbuf));
+ efidp_parse_device_path(walker, dp, sizeof(dpbuf));
rv = efivar_device_path_to_unix_path(dp, &dev, &relpath, &abspath);
if (rv == 0)
printf("%s:%s %s\n", dev, relpath, abspath);
diff --git a/usr.sbin/efitable/Makefile b/usr.sbin/efitable/Makefile
index d318a5818da9..81777bf73885 100644
--- a/usr.sbin/efitable/Makefile
+++ b/usr.sbin/efitable/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= efi-tools
diff --git a/usr.sbin/efitable/efitable.8 b/usr.sbin/efitable/efitable.8
index 9bc897e66ff4..d1f4cedcdea8 100644
--- a/usr.sbin/efitable/efitable.8
+++ b/usr.sbin/efitable/efitable.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 10, 2021
.Dt EFITABLE 8
.Os
diff --git a/usr.sbin/efitable/efitable.c b/usr.sbin/efitable/efitable.c
index 6bd4d96ffd2a..81d8bb999c58 100644
--- a/usr.sbin/efitable/efitable.c
+++ b/usr.sbin/efitable/efitable.c
@@ -23,15 +23,11 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/efi.h>
#include <sys/efiio.h>
#include <sys/param.h>
#include <sys/stat.h>
-#include <err.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdbool.h>
@@ -48,7 +44,7 @@ __FBSDID("$FreeBSD$");
static void efi_table_print_esrt(const void *data);
static void efi_table_print_prop(const void *data);
-static void usage(void);
+static void usage(void) __dead2;
struct efi_table_op {
char name[TABLE_MAX_LEN];
@@ -211,7 +207,8 @@ efi_table_print_esrt(const void *data)
xo_close_list("entries");
xo_close_container("esrt");
- xo_finish();
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
}
static void
@@ -229,7 +226,8 @@ efi_table_print_prop(const void *data)
"{:memory_protection_attribute/%#lx}\n",
prop->memory_protection_attribute);
xo_close_container("prop");
- xo_finish();
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
}
static void usage(void)
diff --git a/usr.sbin/efivar/Makefile b/usr.sbin/efivar/Makefile
index aa00f4b79502..2e794e13968f 100644
--- a/usr.sbin/efivar/Makefile
+++ b/usr.sbin/efivar/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= efi-tools
diff --git a/usr.sbin/efivar/Makefile.depend b/usr.sbin/efivar/Makefile.depend
index 204b8d257e53..43c8da8637b0 100644
--- a/usr.sbin/efivar/Makefile.depend
+++ b/usr.sbin/efivar/Makefile.depend
@@ -1,14 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libefivar \
+ lib/libgeom \
.include <dirdeps.mk>
diff --git a/usr.sbin/efivar/efiutil.c b/usr.sbin/efivar/efiutil.c
index 838e56334066..fc2a309a81ef 100644
--- a/usr.sbin/efivar/efiutil.c
+++ b/usr.sbin/efivar/efiutil.c
@@ -24,8 +24,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <efivar.h>
#include <efivar-dp.h>
diff --git a/usr.sbin/efivar/efiutil.h b/usr.sbin/efivar/efiutil.h
index 19e80b89ecf9..c9fcb99ec1eb 100644
--- a/usr.sbin/efivar/efiutil.h
+++ b/usr.sbin/efivar/efiutil.h
@@ -21,8 +21,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$
*/
/*
diff --git a/usr.sbin/efivar/efivar.8 b/usr.sbin/efivar/efivar.8
index 74c93e2793cb..a0b2b243aeba 100644
--- a/usr.sbin/efivar/efivar.8
+++ b/usr.sbin/efivar/efivar.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 7, 2021
.Dt EFIVAR 8
.Os
diff --git a/usr.sbin/efivar/efivar.c b/usr.sbin/efivar/efivar.c
index 5bdf0c11a488..a87c73abef36 100644
--- a/usr.sbin/efivar/efivar.c
+++ b/usr.sbin/efivar/efivar.c
@@ -24,8 +24,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <efivar.h>
#include <efivar-dp.h>
diff --git a/usr.sbin/efiwake/Makefile b/usr.sbin/efiwake/Makefile
new file mode 100644
index 000000000000..0e6da2802055
--- /dev/null
+++ b/usr.sbin/efiwake/Makefile
@@ -0,0 +1,12 @@
+
+PACKAGE= efi-tools
+
+PROG= efiwake
+MAN= efiwake.8
+
+SRCS= efiwake.c
+
+EFIBOOT=${SRCTOP}/stand/efi
+CFLAGS+=-I${EFIBOOT}/include
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/efiwake/efiwake.8 b/usr.sbin/efiwake/efiwake.8
new file mode 100644
index 000000000000..13d422d8ecf7
--- /dev/null
+++ b/usr.sbin/efiwake/efiwake.8
@@ -0,0 +1,99 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2023 Johannes Totz
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd May 9, 2023
+.Dt EFIWAKE 8
+.Os
+.Sh NAME
+.Nm efiwake
+.Nd manipulate the EFI wake timer
+.Sh SYNOPSIS
+.Nm
+.Nm
+.Fl d
+.Nm
+.Fl e Ar yyyy-mm-ddThh:mm:ss
+.Sh DESCRIPTION
+.Nm
+reports the current value of, disables or enables the EFI wake timer that can
+wake your machine from S3 sleep at a given time.
+.Pp
+If invoked without arguments, the current EFI time and the current value of the
+wake timer will be printed, followed by an
+.Em enabled
+status and a
+.Em pending
+status.
+EFI time is supposed to be in UTC.
+Note that it can be out of sync with kernel time.
+The pending status tells whether the wake timer fired recently; it is cleared
+upon reading.
+.Pp
+If invoked with the
+.Sy -d
+option, the wake timer is reset and disabled.
+.Pp
+If invoked with the
+.Sy -e
+option, the wake timer is set to the given time and date.
+If the date or time is invalid, an error is returned.
+.Pp
+The current EFI time is always printed.
+.Sh EXAMPLES
+Without arguments:
+.Bd -literal -offset indent
+# efiwake
+Current EFI time: 2023-05-04T15:30:45
+EFI wake time: 2023-05-04T10:00:00; enabled=0, pending=1
+.Ed
+.Pp
+Disabling and resetting the wake timer:
+.Bd -literal -offset indent
+# efiwake -d
+Current EFI time: 2023-05-04T15:32:16
+EFI wake time: 2023-05-04T15:32:16; enabled=0, pending=0
+.Ed
+.Pp
+Enabling the wake timer with a valid date:
+.Bd -literal -offset indent
+# efiwake -e 2023-05-04T15:35:00
+Current EFI time: 2023-05-04T15:34:05
+EFI wake time: 2023-05-04T15:35:00; enabled=1, pending=0
+.Ed
+.Pp
+Trying to enable with an invalid date (there is no 31st of April):
+.Bd -literal -offset indent
+# efiwake -e 2023-04-31T15:35:00
+Current EFI time: 2023-05-04T15:35:25
+efiwake: cannot enable EFI wake time: Invalid argument
+.Ed
+.Sh AUTHORS
+.An -nosplit
+The tool and manual page were written by
+.An Johannes Totz Aq Mt jo@bruelltuete.com .
+.Sh BUGS
+The quality of EFI implementations differs widely.
+Corruption of the wake-up date has been observed on real hardware.
diff --git a/usr.sbin/efiwake/efiwake.c b/usr.sbin/efiwake/efiwake.c
new file mode 100644
index 000000000000..41ffdea60068
--- /dev/null
+++ b/usr.sbin/efiwake/efiwake.c
@@ -0,0 +1,140 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Johannes Totz
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/efiio.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+static void
+usage(void)
+{
+ fprintf(stderr, "Usage:\n"
+ " efiwake -- print out current "
+ "EFI time and wake time\n"
+ " efiwake -d -- disable wake time\n"
+ " efiwake -e yyyy-mm-ddThh:mm:ss -- enable wake time\n"
+ );
+ exit(EX_USAGE);
+}
+
+int
+main(int argc, char **argv)
+{
+ struct efi_tm now;
+ struct efi_waketime_ioc waketime;
+ int ch, error, efi_fd;
+ bool disable = false, enable = false;
+
+ memset(&waketime, 0, sizeof(waketime));
+
+ while ((ch = getopt(argc, argv, "de:")) != -1) {
+ switch (ch) {
+ case 'd':
+ disable = true;
+ break;
+ case 'e':
+ if (sscanf(optarg,
+ "%hu-%02hhu-%02hhuT%02hhu:%02hhu:%02hhu",
+ &waketime.waketime.tm_year,
+ &waketime.waketime.tm_mon,
+ &waketime.waketime.tm_mday,
+ &waketime.waketime.tm_hour,
+ &waketime.waketime.tm_min,
+ &waketime.waketime.tm_sec) != 6) {
+ usage();
+ }
+ enable = true;
+ break;
+ case '?':
+ default:
+ usage();
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 0)
+ usage();
+ if (disable && enable)
+ usage();
+
+ efi_fd = open("/dev/efi", O_RDWR);
+ if (efi_fd < 0)
+ err(EX_OSERR, "cannot open /dev/efi");
+
+ error = ioctl(efi_fd, EFIIOC_GET_TIME, &now);
+ if (error != 0)
+ err(EX_OSERR, "cannot get EFI time");
+
+ /* EFI's time can be different from kernel's time. */
+ printf("Current EFI time: %u-%02u-%02uT%02u:%02u:%02u\n",
+ now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min,
+ now.tm_sec);
+
+ if (disable) {
+ /*
+ * It's tempting to preserve the current timer value.
+ * However, wonky EFI implementations sometimes return bogus
+ * dates for the wake timer and would then fail disabling it
+ * here.
+ * A safe timer value is the current EFI time.
+ */
+ waketime.waketime = now;
+ waketime.enabled = 0;
+ error = ioctl(efi_fd, EFIIOC_SET_WAKETIME, &waketime);
+ if (error != 0)
+ err(EX_OSERR, "cannot disable EFI wake time");
+ }
+ if (enable) {
+ waketime.enabled = 1;
+ error = ioctl(efi_fd, EFIIOC_SET_WAKETIME, &waketime);
+ if (error != 0)
+ err(EX_OSERR, "cannot enable EFI wake time");
+ }
+
+ /* Confirm to user what the wake time has been set to. */
+ error = ioctl(efi_fd, EFIIOC_GET_WAKETIME, &waketime);
+ if (error != 0)
+ err(EX_OSERR, "cannot get EFI wake time");
+
+ printf("EFI wake time: %u-%02u-%02uT%02u:%02u:%02u; "
+ "enabled=%i, pending=%i\n",
+ waketime.waketime.tm_year, waketime.waketime.tm_mon,
+ waketime.waketime.tm_mday, waketime.waketime.tm_hour,
+ waketime.waketime.tm_min, waketime.waketime.tm_sec,
+ waketime.enabled, waketime.pending);
+
+ close(efi_fd);
+ return (0);
+}
diff --git a/usr.sbin/etcupdate/Makefile b/usr.sbin/etcupdate/Makefile
index 46edaf03baf1..f2b6bd9ab374 100644
--- a/usr.sbin/etcupdate/Makefile
+++ b/usr.sbin/etcupdate/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/etcupdate/Makefile.depend b/usr.sbin/etcupdate/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/etcupdate/Makefile.depend
+++ b/usr.sbin/etcupdate/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/etcupdate/etcupdate.8 b/usr.sbin/etcupdate/etcupdate.8
index 3d48e218494c..82c36fc9cb68 100644
--- a/usr.sbin/etcupdate/etcupdate.8
+++ b/usr.sbin/etcupdate/etcupdate.8
@@ -23,9 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd April 20, 2021
+.Dd August 9, 2022
.Dt ETCUPDATE 8
.Os
.Sh NAME
@@ -33,7 +31,7 @@
.Nd "manage updates to system files not updated by installworld"
.Sh SYNOPSIS
.Nm
-.Op Fl npBF
+.Op Fl npBFN
.Op Fl d Ar workdir
.Op Fl r | Fl s Ar source | Fl t Ar tarball
.Op Fl A Ar patterns
@@ -41,13 +39,15 @@
.Op Fl I Ar patterns
.Op Fl L Ar logfile
.Op Fl M Ar options
+.Op Fl m Ar make
.Nm
.Cm build
-.Op Fl B
+.Op Fl BN
.Op Fl d Ar workdir
.Op Fl s Ar source
.Op Fl L Ar logfile
.Op Fl M Ar options
+.Op Fl m Ar make
.Ar tarball
.Nm
.Cm diff
@@ -57,12 +57,13 @@
.Op Fl L Ar logfile
.Nm
.Cm extract
-.Op Fl B
+.Op Fl BN
.Op Fl d Ar workdir
.Op Fl s Ar source | Fl t Ar tarball
.Op Fl D Ar destdir
.Op Fl L Ar logfile
.Op Fl M Ar options
+.Op Fl m Ar make
.Nm
.Cm resolve
.Op Fl p
@@ -489,6 +490,14 @@ This can be used for to set the
or
.Dv TARGET_ARCH
variables for a cross-build.
+.It Fl m Ar make
+Use
+.Ar make
+as the
+.Xr make 1
+binary when building a
+.Dq current
+tree.
.It Fl n
Enable
.Dq dry-run
@@ -507,6 +516,15 @@ option is not specified,
then a temporary
.Dq current
tree will be extracted to perform the comparison.
+.It Fl N
+Perform a
+.Dv NO_ROOT
+build when building a
+.Dq current
+tree.
+The resulting tree will include a corresponding
+.Pa METALOG
+file at its root.
.It Fl p
Enable
.Dq pre-world
@@ -593,6 +611,14 @@ option.
Specify an alternate path for the log file similar to the
.Fl L
option.
+.It Ev MAKE_CMD
+Specify the
+.Xr make 1
+binary when building a
+.Dq current
+tree similar to the
+.Fl m
+option.
.It Ev MAKE_OPTIONS
Pass additional options to
.Xr make 1
diff --git a/usr.sbin/etcupdate/etcupdate.sh b/usr.sbin/etcupdate/etcupdate.sh
index 40868fe6586e..39d1f9e56a54 100755
--- a/usr.sbin/etcupdate/etcupdate.sh
+++ b/usr.sbin/etcupdate/etcupdate.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2010-2013 Hudson River Trading LLC
# Written by: John H. Baldwin <jhb@FreeBSD.org>
@@ -27,7 +27,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
# This is a tool to manage updating files that are not updated as part
# of 'make installworld' such as files in /etc. Unlike other tools,
@@ -62,14 +61,14 @@
usage()
{
cat <<EOF
-usage: etcupdate [-npBF] [-d workdir] [-r | -s source | -t tarball]
+usage: etcupdate [-npBFN] [-d workdir] [-r | -s source | -t tarball]
[-A patterns] [-D destdir] [-I patterns] [-L logfile]
- [-M options]
- etcupdate build [-B] [-d workdir] [-s source] [-L logfile] [-M options]
- <tarball>
+ [-M options] [-m make]
+ etcupdate build [-BN] [-d workdir] [-s source] [-L logfile] [-M options]
+ [-m make] <tarball>
etcupdate diff [-d workdir] [-D destdir] [-I patterns] [-L logfile]
- etcupdate extract [-B] [-d workdir] [-s source | -t tarball]
- [-D destdir] [-L logfile] [-M options]
+ etcupdate extract [-BN] [-d workdir] [-s source | -t tarball]
+ [-D destdir] [-L logfile] [-M options] [-m make]
etcupdate resolve [-p] [-d workdir] [-D destdir] [-L logfile]
etcupdate revert [-d workdir] [-D destdir] [-L logfile] file ...
etcupdate status [-d workdir] [-D destdir]
@@ -184,14 +183,24 @@ always_install()
# $1 - directory to store new tree in
build_tree()
(
- local destdir dir file make
+ local destdir dir file make autogenfiles metatmp
- make="make $MAKE_OPTIONS -DNO_FILEMON"
+ make="$MAKE_CMD $MAKE_OPTIONS -DNO_FILEMON"
+
+ if [ -n "$noroot" ]; then
+ make="$make -DNO_ROOT"
+ metatmp=`mktemp $WORKDIR/etcupdate-XXXXXXX`
+ : > $metatmp
+ trap "rm -f $metatmp; trap '' EXIT; return 1" INT
+ trap "rm -f $metatmp" EXIT
+ else
+ metatmp="/dev/null"
+ trap "return 1" INT
+ fi
log "Building tree at $1 with $make"
exec >&3 2>&1
- trap 'return 1' INT
mkdir -p $1/usr/obj
destdir=`realpath $1`
@@ -204,28 +213,63 @@ build_tree()
mkdir -p $1/etc || return 1
cp -p $SRCDIR/$file $1/etc/$name || return 1
done
- elif ! [ -n "$nobuild" ]; then
- (cd $SRCDIR; $make DESTDIR=$destdir distrib-dirs &&
- MAKEOBJDIRPREFIX=$destdir/usr/obj $make _obj SUBDIR_OVERRIDE=etc &&
- MAKEOBJDIRPREFIX=$destdir/usr/obj $make everything SUBDIR_OVERRIDE=etc &&
- MAKEOBJDIRPREFIX=$destdir/usr/obj $make DESTDIR=$destdir distribution) || \
- return 1
else
- (cd $SRCDIR; $make DESTDIR=$destdir distrib-dirs &&
- $make DESTDIR=$destdir distribution) || return 1
+ (
+ cd $SRCDIR || exit 1
+ if ! [ -n "$nobuild" ]; then
+ export MAKEOBJDIRPREFIX=$destdir/usr/obj
+ if [ -n "$($make -V.ALLTARGETS:Mbuildetc)" ]; then
+ $make buildetc || exit 1
+ else
+ $make _obj SUBDIR_OVERRIDE=etc || exit 1
+ $make everything SUBDIR_OVERRIDE=etc || exit 1
+ fi
+ fi
+ if [ -n "$($make -V.ALLTARGETS:Minstalletc)" ]; then
+ $make DESTDIR=$destdir installetc || exit 1
+ else
+ $make DESTDIR=$destdir distrib-dirs || exit 1
+ $make DESTDIR=$destdir distribution || exit 1
+ fi
+ ) || return 1
fi
chflags -R noschg $1 || return 1
rm -rf $1/usr/obj || return 1
# Purge auto-generated files. Only the source files need to
# be updated after which these files are regenerated.
- rm -f $1/etc/*.db $1/etc/passwd $1/var/db/services.db || return 1
+ autogenfiles="./etc/*.db ./etc/passwd ./var/db/services.db"
+ (cd $1 && printf '%s\n' $autogenfiles >> $metatmp && \
+ rm -f $autogenfiles) || return 1
# Remove empty files. These just clutter the output of 'diff'.
- find $1 -type f -size 0 -delete || return 1
+ (cd $1 && find . -type f -size 0 -delete -print >> $metatmp) || \
+ return 1
# Trim empty directories.
- find -d $1 -type d -empty -delete || return 1
+ (cd $1 && find . -depth -type d -empty -delete -print >> $metatmp) || \
+ return 1
+
+ if [ -n "$noroot" ]; then
+ # Rewrite the METALOG to exclude the files (and directories)
+ # removed above. $metatmp contains the list of files to delete,
+ # and we append #METALOG# as a delimiter followed by the
+ # original METALOG. This lets us scan through $metatmp in awk
+ # building up a table of names to delete until we reach the
+ # delimiter, then emit all the entries of the original METALOG
+ # after it that aren't in that table. We also exclude ./usr/obj
+ # and its children explicitly for simplicity rather than
+ # building up that list (and in practice only ./usr/obj itself
+ # will be in the METALOG since nothing is installed there).
+ echo '#METALOG#' >> $metatmp || return 1
+ cat $1/METALOG >> $metatmp || return 1
+ awk '/^#METALOG#$/ { metalog = 1; next }
+ { f=$1; gsub(/\/\/+/, "/", f) }
+ !metalog { rm[f] = 1; next }
+ !rm[f] && f !~ /^\.\/usr\/obj(\/|$)/ { print }' \
+ $metatmp > $1/METALOG || return 1
+ fi
+
return 0
)
@@ -673,8 +717,9 @@ install_resolved()
return 1
fi
- log "cp -Rp ${CONFLICTS}$1 ${DESTDIR}$1"
- cp -Rp ${CONFLICTS}$1 ${DESTDIR}$1 >&3 2>&1
+ # Use cat rather than cp to preserve metadata
+ log "cat ${CONFLICTS}$1 > ${DESTDIR}$1"
+ cat ${CONFLICTS}$1 > ${DESTDIR}$1 2>&3
post_install_file $1
return 0
}
@@ -1285,7 +1330,7 @@ handle_added_file()
# Build a new tree and save it in a tarball.
build_cmd()
{
- local dir
+ local dir tartree
if [ $# -ne 1 ]; then
echo "Missing required tarball."
@@ -1306,7 +1351,12 @@ build_cmd()
remove_tree $dir
exit 1
fi
- if ! tar cfj $1 -C $dir . >&3 2>&1; then
+ if [ -n "$noroot" ]; then
+ tartree=@METALOG
+ else
+ tartree=.
+ fi
+ if ! tar cfj $1 -C $dir $tartree >&3 2>&1; then
echo "Failed to create tarball."
remove_tree $dir
exit 1
@@ -1612,6 +1662,18 @@ EOF
cat $WARNINGS
fi
+ # If this was a dryrun, remove the temporary tree if we built
+ # a new one.
+ if [ -n "$dryrun" ]; then
+ if [ -n "$dir" ]; then
+ if [ -n "$rerun" ]; then
+ panic "Should not have a temporary directory"
+ fi
+ remove_tree $dir
+ fi
+ return
+ fi
+
# Finally, rotate any needed trees.
if [ "$new" != "$NEWTREE" ]; then
if [ -n "$rerun" ]; then
@@ -1694,6 +1756,9 @@ ALWAYS_INSTALL=
# Files to ignore and never update during a merge.
IGNORE_FILES=
+# The path to the make binary
+MAKE_CMD=make
+
# Flags to pass to 'make' when building a tree.
MAKE_OPTIONS=
@@ -1706,6 +1771,7 @@ MAKE_OPTIONS=
# - FREEBSD_ID
# - IGNORE_FILES
# - LOGFILE
+# - MAKE_CMD
# - MAKE_OPTIONS
# - SRCDIR
# - WORKDIR
@@ -1721,11 +1787,15 @@ dryrun=
ignore=
nobuild=
preworld=
-while getopts "d:nprs:t:A:BD:FI:L:M:" option; do
+noroot=
+while getopts "d:m:nprs:t:A:BD:FI:L:M:N" option; do
case "$option" in
d)
WORKDIR=$OPTARG
;;
+ m)
+ MAKE_CMD=$OPTARG
+ ;;
n)
dryrun=YES
;;
@@ -1778,6 +1848,9 @@ while getopts "d:nprs:t:A:BD:FI:L:M:" option; do
M)
MAKE_OPTIONS="$OPTARG"
;;
+ N)
+ noroot=YES
+ ;;
*)
echo
usage
diff --git a/usr.sbin/etcupdate/tests/Makefile b/usr.sbin/etcupdate/tests/Makefile
index 45b12b7bb75d..77cd0b87a21c 100644
--- a/usr.sbin/etcupdate/tests/Makefile
+++ b/usr.sbin/etcupdate/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PLAIN_TESTS_SH=
.for test in always_test \
diff --git a/usr.sbin/etcupdate/tests/Makefile.depend b/usr.sbin/etcupdate/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/etcupdate/tests/Makefile.depend
+++ b/usr.sbin/etcupdate/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/etcupdate/tests/always_test.sh b/usr.sbin/etcupdate/tests/always_test.sh
index 2055bb6347a1..321f7beb2a67 100644
--- a/usr.sbin/etcupdate/tests/always_test.sh
+++ b/usr.sbin/etcupdate/tests/always_test.sh
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
# Various regression tests to test the -A flag to the 'update' command.
diff --git a/usr.sbin/etcupdate/tests/conflicts_test.sh b/usr.sbin/etcupdate/tests/conflicts_test.sh
index 71f16fabf35b..87857e7cd0a9 100644
--- a/usr.sbin/etcupdate/tests/conflicts_test.sh
+++ b/usr.sbin/etcupdate/tests/conflicts_test.sh
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
# Various regression tests to run for the 'resolve' command.
diff --git a/usr.sbin/etcupdate/tests/fbsdid_test.sh b/usr.sbin/etcupdate/tests/fbsdid_test.sh
index d8d5cce993c6..b93c2ff1793e 100644
--- a/usr.sbin/etcupdate/tests/fbsdid_test.sh
+++ b/usr.sbin/etcupdate/tests/fbsdid_test.sh
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
# Various regression tests to test the -F flag to the 'update' command.
diff --git a/usr.sbin/etcupdate/tests/ignore_test.sh b/usr.sbin/etcupdate/tests/ignore_test.sh
index 571dd247150c..20d1f9abcd54 100644
--- a/usr.sbin/etcupdate/tests/ignore_test.sh
+++ b/usr.sbin/etcupdate/tests/ignore_test.sh
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
# Various regression tests to test the -I flag to the 'update' command.
diff --git a/usr.sbin/etcupdate/tests/preworld_test.sh b/usr.sbin/etcupdate/tests/preworld_test.sh
index b7241542784f..e9a7544197a9 100644
--- a/usr.sbin/etcupdate/tests/preworld_test.sh
+++ b/usr.sbin/etcupdate/tests/preworld_test.sh
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
# Regression tests for the pre-world (-p) mode
@@ -214,7 +213,7 @@ check_trees()
missing /etc/inetd.conf
# These should be auto-generated by pwd_mkdb
- file /etc/passwd "" 9831537874bdc99adccaa2b0293248a1
+ file /etc/passwd "" e4650d2727044b22d513e6a02d86bcfa
file /etc/pwd.db
file /etc/spwd.db
}
diff --git a/usr.sbin/etcupdate/tests/tests_test.sh b/usr.sbin/etcupdate/tests/tests_test.sh
index 5382de30da00..794be8065a96 100644
--- a/usr.sbin/etcupdate/tests/tests_test.sh
+++ b/usr.sbin/etcupdate/tests/tests_test.sh
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
# Various regression tests to run for the 'update' command.
diff --git a/usr.sbin/etcupdate/tests/tzsetup_test.sh b/usr.sbin/etcupdate/tests/tzsetup_test.sh
index 5d3fe89d7a24..155830bddae7 100644
--- a/usr.sbin/etcupdate/tests/tzsetup_test.sh
+++ b/usr.sbin/etcupdate/tests/tzsetup_test.sh
@@ -25,7 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
# Various regression tests for the tzsetup handling in the 'update' command.
@@ -233,7 +232,8 @@ echo "Differences for real update:"
diff -u -L "correct" $WORKDIR/correct.out -L "test" $WORKDIR/test.out \
|| FAILED=yes
-file /etc/localtime "foo"
-file /var/db/zoneinfo "foo"
+# XXX tzsetup installs a symlink as of 5e16809c953f
+#file /etc/localtime "foo"
+#file /var/db/zoneinfo "foo"
[ "${FAILED}" = no ]
diff --git a/usr.sbin/extattr/Makefile b/usr.sbin/extattr/Makefile
index 253b61b5a9ac..61171ef385d7 100644
--- a/usr.sbin/extattr/Makefile
+++ b/usr.sbin/extattr/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= rmextattr
MAN= rmextattr.8
diff --git a/usr.sbin/extattr/Makefile.depend b/usr.sbin/extattr/Makefile.depend
index c3cca03a0705..3c711d830978 100644
--- a/usr.sbin/extattr/Makefile.depend
+++ b/usr.sbin/extattr/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/extattr/rmextattr.8 b/usr.sbin/extattr/rmextattr.8
index 3b0988fd0bab..dee62ed73872 100644
--- a/usr.sbin/extattr/rmextattr.8
+++ b/usr.sbin/extattr/rmextattr.8
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 27, 2016
.Dt RMEXTATTR 8
.Os
diff --git a/usr.sbin/extattr/rmextattr.c b/usr.sbin/extattr/rmextattr.c
index 0daf15cec940..305feb2b8f21 100644
--- a/usr.sbin/extattr/rmextattr.c
+++ b/usr.sbin/extattr/rmextattr.c
@@ -34,8 +34,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/types.h>
@@ -98,7 +96,6 @@ mkbuf(char **buf, int *oldlen, int newlen)
if (*buf == NULL)
err(1, "malloc");
*oldlen = newlen;
- return;
}
int
diff --git a/usr.sbin/extattr/tests/Makefile b/usr.sbin/extattr/tests/Makefile
index 7dec010fe009..3e3218032d07 100644
--- a/usr.sbin/extattr/tests/Makefile
+++ b/usr.sbin/extattr/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
ATF_TESTS_SH= extattr_test
diff --git a/usr.sbin/extattr/tests/Makefile.depend b/usr.sbin/extattr/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/extattr/tests/Makefile.depend
+++ b/usr.sbin/extattr/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/extattr/tests/extattr_test.sh b/usr.sbin/extattr/tests/extattr_test.sh
index c2d96cfcb0bf..0b16350a958a 100755
--- a/usr.sbin/extattr/tests/extattr_test.sh
+++ b/usr.sbin/extattr/tests/extattr_test.sh
@@ -23,7 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
atf_test_case bad_namespace
bad_namespace_head() {
diff --git a/usr.sbin/extattrctl/Makefile b/usr.sbin/extattrctl/Makefile
index 496a8aa8c7c1..9365aff89230 100644
--- a/usr.sbin/extattrctl/Makefile
+++ b/usr.sbin/extattrctl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= extattrctl
MAN= extattrctl.8
diff --git a/usr.sbin/extattrctl/Makefile.depend b/usr.sbin/extattrctl/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/extattrctl/Makefile.depend
+++ b/usr.sbin/extattrctl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/extattrctl/extattrctl.8 b/usr.sbin/extattrctl/extattrctl.8
index 9492f7abb549..845929ac9ed2 100644
--- a/usr.sbin/extattrctl/extattrctl.8
+++ b/usr.sbin/extattrctl/extattrctl.8
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.\" Developed by the TrustedBSD Project.
.\" Support for file system extended attribute.
.\"
diff --git a/usr.sbin/extattrctl/extattrctl.c b/usr.sbin/extattrctl/extattrctl.c
index a8ac064bddf7..3243f1ad3f45 100644
--- a/usr.sbin/extattrctl/extattrctl.c
+++ b/usr.sbin/extattrctl/extattrctl.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999-2002 Robert N. M. Watson
* 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$
*/
/*
* Developed by the TrustedBSD Project.
diff --git a/usr.sbin/fdcontrol/Makefile b/usr.sbin/fdcontrol/Makefile
index a11c6f1292e0..f3d7cc2af36b 100644
--- a/usr.sbin/fdcontrol/Makefile
+++ b/usr.sbin/fdcontrol/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${.CURDIR:H}/fdread
diff --git a/usr.sbin/fdcontrol/Makefile.depend b/usr.sbin/fdcontrol/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/fdcontrol/Makefile.depend
+++ b/usr.sbin/fdcontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/fdcontrol/fdcontrol.8 b/usr.sbin/fdcontrol/fdcontrol.8
index 210bf52c5820..23c3a2ee20de 100644
--- a/usr.sbin/fdcontrol/fdcontrol.8
+++ b/usr.sbin/fdcontrol/fdcontrol.8
@@ -23,8 +23,6 @@
.\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
.\" DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 7, 2017
.Dt FDCONTROL 8
.Os
diff --git a/usr.sbin/fdcontrol/fdcontrol.c b/usr.sbin/fdcontrol/fdcontrol.c
index fc975eb87b3e..ebe9a90c8472 100644
--- a/usr.sbin/fdcontrol/fdcontrol.c
+++ b/usr.sbin/fdcontrol/fdcontrol.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1994, 2001 by Joerg Wunsch, Dresden
* All rights reserved.
@@ -28,8 +28,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/fdcio.h>
#include <sys/file.h>
@@ -47,7 +45,7 @@ static int format, verbose, show = 1, showfmt;
static char *fmtstring;
static void showdev(enum fd_drivetype, const char *);
-static void usage(void);
+static void usage(void) __dead2;
static void
usage(void)
diff --git a/usr.sbin/fdformat/Makefile b/usr.sbin/fdformat/Makefile
index 9acde9482c78..f2cd4e4841e9 100644
--- a/usr.sbin/fdformat/Makefile
+++ b/usr.sbin/fdformat/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${.CURDIR:H}/fdread
diff --git a/usr.sbin/fdformat/Makefile.depend b/usr.sbin/fdformat/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/fdformat/Makefile.depend
+++ b/usr.sbin/fdformat/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/fdformat/fdformat.8 b/usr.sbin/fdformat/fdformat.8
index 317aa6d23a1d..bf18f93f5e87 100644
--- a/usr.sbin/fdformat/fdformat.8
+++ b/usr.sbin/fdformat/fdformat.8
@@ -22,8 +22,6 @@
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 23, 2020
.Dt FDFORMAT 8
.Os
diff --git a/usr.sbin/fdformat/fdformat.c b/usr.sbin/fdformat/fdformat.c
index 383609dc810c..1e6e50d2c43a 100644
--- a/usr.sbin/fdformat/fdformat.c
+++ b/usr.sbin/fdformat/fdformat.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1992-1994,2001 by Joerg Wunsch, Dresden
* All rights reserved.
@@ -24,8 +24,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$
*/
#include <sys/types.h>
diff --git a/usr.sbin/fdread/Makefile b/usr.sbin/fdread/Makefile
index 05e588de00e1..4b7570868ccb 100644
--- a/usr.sbin/fdread/Makefile
+++ b/usr.sbin/fdread/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= fdread
SRCS= fdread.c fdutil.c
diff --git a/usr.sbin/fdread/Makefile.depend b/usr.sbin/fdread/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/fdread/Makefile.depend
+++ b/usr.sbin/fdread/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/fdread/fdread.1 b/usr.sbin/fdread/fdread.1
index d29a4a44dd64..c0036906bee6 100644
--- a/usr.sbin/fdread/fdread.1
+++ b/usr.sbin/fdread/fdread.1
@@ -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 May 14, 2001
.Dt FDREAD 1
diff --git a/usr.sbin/fdread/fdread.c b/usr.sbin/fdread/fdread.c
index 58d8e670ee26..ee8548699783 100644
--- a/usr.sbin/fdread/fdread.c
+++ b/usr.sbin/fdread/fdread.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Joerg Wunsch
*
@@ -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$
*/
#include <sys/types.h>
diff --git a/usr.sbin/fdread/fdutil.c b/usr.sbin/fdread/fdutil.c
index 46cf3541e058..eb5e7a642f2f 100644
--- a/usr.sbin/fdread/fdutil.c
+++ b/usr.sbin/fdread/fdutil.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Joerg Wunsch
*
@@ -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$
*/
#include <dev/ic/nec765.h>
diff --git a/usr.sbin/fdread/fdutil.h b/usr.sbin/fdread/fdutil.h
index bb65748ec1d9..a0c53424824e 100644
--- a/usr.sbin/fdread/fdutil.h
+++ b/usr.sbin/fdread/fdutil.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Joerg Wunsch
*
@@ -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$
*/
diff --git a/usr.sbin/fdwrite/Makefile b/usr.sbin/fdwrite/Makefile
index b97bdd444821..810ae058c7b0 100644
--- a/usr.sbin/fdwrite/Makefile
+++ b/usr.sbin/fdwrite/Makefile
@@ -5,7 +5,6 @@
# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
# ----------------------------------------------------------------------------
#
-# $FreeBSD$
PROG= fdwrite
diff --git a/usr.sbin/fdwrite/Makefile.depend b/usr.sbin/fdwrite/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/fdwrite/Makefile.depend
+++ b/usr.sbin/fdwrite/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/fdwrite/fdwrite.1 b/usr.sbin/fdwrite/fdwrite.1
index 9f1270f72f03..9d188de02d83 100644
--- a/usr.sbin/fdwrite/fdwrite.1
+++ b/usr.sbin/fdwrite/fdwrite.1
@@ -6,8 +6,6 @@
.\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
.\" ----------------------------------------------------------------------------
.\"
-.\" $FreeBSD$
-.\"
.\"
.Dd September 16, 1993
.Dt FDWRITE 1
@@ -78,7 +76,7 @@ The parameters returned from
.Ar device
are used for formatting.
If custom formatting is needed, please use
-.Xr fdformat 1
+.Xr fdformat 8
instead.
.Sh EXAMPLES
The
@@ -95,13 +93,13 @@ multivolume facility is of course the formatting of the floppies, which
here is done on the fly,
thus reducing the amount of work for the floppy-jockey.
.Sh SEE ALSO
-.Xr fdformat 1
+.Xr fdformat 8
.Sh HISTORY
The
.Nm
utility was written while waiting for ``make world'' to complete.
Some of the code was taken from
-.Xr fdformat 1 .
+.Xr fdformat 8 .
.Sh AUTHORS
The program has been contributed by
.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org .
diff --git a/usr.sbin/fdwrite/fdwrite.c b/usr.sbin/fdwrite/fdwrite.c
index d2f8de340b51..94052028c6dc 100644
--- a/usr.sbin/fdwrite/fdwrite.c
+++ b/usr.sbin/fdwrite/fdwrite.c
@@ -8,11 +8,8 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $FreeBSD$
- *
*/
-#include <ctype.h>
#include <err.h>
#include <fcntl.h>
#include <paths.h>
@@ -28,7 +25,7 @@ format_track(int fd, int cyl, int secs, int head, int rate,
int gaplen, int secsize, int fill, int interleave)
{
struct fd_formb f;
- register int i,j;
+ int i, j;
int il[100];
memset(il,0,sizeof il);
@@ -70,7 +67,7 @@ main(int argc, char **argv)
int bpt, verbose=1, nbytes=0, track;
int interactive = 1;
const char *device= "/dev/fd0";
- char *trackbuf = 0,*vrfybuf = 0;
+ char *trackbuf = NULL, *vrfybuf = NULL;
struct fd_type fdt;
FILE *tty;
@@ -194,5 +191,8 @@ main(int argc, char **argv)
}
if(verbose)
printf("%d bytes on %d flopp%s\n",nbytes,fdn,fdn==1?"y":"ies");
+
+ free(trackbuf);
+ free(vrfybuf);
exit(0);
}
diff --git a/usr.sbin/fifolog/Makefile b/usr.sbin/fifolog/Makefile
index fbaaa894d2c7..779fec1860de 100644
--- a/usr.sbin/fifolog/Makefile
+++ b/usr.sbin/fifolog/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= lib .WAIT \
fifolog_create fifolog_writer fifolog_reader
diff --git a/usr.sbin/fifolog/Makefile.inc b/usr.sbin/fifolog/Makefile.inc
index 265f86d1ed55..d3b5cbd3a79b 100644
--- a/usr.sbin/fifolog/Makefile.inc
+++ b/usr.sbin/fifolog/Makefile.inc
@@ -1,3 +1,2 @@
-# $FreeBSD$
.include "../Makefile.inc"
diff --git a/usr.sbin/fifolog/fifolog_create/Makefile b/usr.sbin/fifolog/fifolog_create/Makefile
index 04370e6e358c..79dfedbcb83a 100644
--- a/usr.sbin/fifolog/fifolog_create/Makefile
+++ b/usr.sbin/fifolog/fifolog_create/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= fifolog_create
diff --git a/usr.sbin/fifolog/fifolog_create/Makefile.depend b/usr.sbin/fifolog/fifolog_create/Makefile.depend
index ce13a0df74aa..4fbab540293d 100644
--- a/usr.sbin/fifolog/fifolog_create/Makefile.depend
+++ b/usr.sbin/fifolog/fifolog_create/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
lib/${CSU_DIR} \
lib/libc \
diff --git a/usr.sbin/fifolog/fifolog_create/fifolog.1 b/usr.sbin/fifolog/fifolog_create/fifolog.1
index 69e8fbeebc2e..4cf3be114ab6 100644
--- a/usr.sbin/fifolog/fifolog_create/fifolog.1
+++ b/usr.sbin/fifolog/fifolog_create/fifolog.1
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd February 9, 2008
.Dt FIFOLOG 1
.Os
diff --git a/usr.sbin/fifolog/fifolog_create/fifolog_create.c b/usr.sbin/fifolog/fifolog_create/fifolog_create.c
index 5bb4fe783e21..2b62787f99c0 100644
--- a/usr.sbin/fifolog/fifolog_create/fifolog_create.c
+++ b/usr.sbin/fifolog/fifolog_create/fifolog_create.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008 Poul-Henning Kamp
* 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 <stdio.h>
diff --git a/usr.sbin/fifolog/fifolog_reader/Makefile b/usr.sbin/fifolog/fifolog_reader/Makefile
index 2dd103f91f2c..fd3e09aed919 100644
--- a/usr.sbin/fifolog/fifolog_reader/Makefile
+++ b/usr.sbin/fifolog/fifolog_reader/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= fifolog_reader
diff --git a/usr.sbin/fifolog/fifolog_reader/Makefile.depend b/usr.sbin/fifolog/fifolog_reader/Makefile.depend
index d223e22c5c58..84b8efcd8205 100644
--- a/usr.sbin/fifolog/fifolog_reader/Makefile.depend
+++ b/usr.sbin/fifolog/fifolog_reader/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c b/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c
index 7d6fdbff2143..0738d0fde8b7 100644
--- a/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c
+++ b/usr.sbin/fifolog/fifolog_reader/fifolog_reader.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008 Poul-Henning Kamp
* 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 <stdio.h>
diff --git a/usr.sbin/fifolog/fifolog_writer/Makefile b/usr.sbin/fifolog/fifolog_writer/Makefile
index d5b888dd5bc6..ade8308db418 100644
--- a/usr.sbin/fifolog/fifolog_writer/Makefile
+++ b/usr.sbin/fifolog/fifolog_writer/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= fifolog_writer
diff --git a/usr.sbin/fifolog/fifolog_writer/Makefile.depend b/usr.sbin/fifolog/fifolog_writer/Makefile.depend
index d223e22c5c58..84b8efcd8205 100644
--- a/usr.sbin/fifolog/fifolog_writer/Makefile.depend
+++ b/usr.sbin/fifolog/fifolog_writer/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c b/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c
index 1b6702d2ff43..27ee55971ab3 100644
--- a/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c
+++ b/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008 Poul-Henning Kamp
* 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 <stdio.h>
diff --git a/usr.sbin/fifolog/lib/Makefile b/usr.sbin/fifolog/lib/Makefile
index f60529fa9ef0..831285df8fac 100644
--- a/usr.sbin/fifolog/lib/Makefile
+++ b/usr.sbin/fifolog/lib/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
LIB= fifolog
INTERNALLIB= # API not published or supported.
diff --git a/usr.sbin/fifolog/lib/Makefile.depend b/usr.sbin/fifolog/lib/Makefile.depend
index 5deb34f4f4f5..37782773d8ea 100644
--- a/usr.sbin/fifolog/lib/Makefile.depend
+++ b/usr.sbin/fifolog/lib/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/fifolog/lib/fifolog.h b/usr.sbin/fifolog/lib/fifolog.h
index c8a10fd49dc7..9a673db89f06 100644
--- a/usr.sbin/fifolog/lib/fifolog.h
+++ b/usr.sbin/fifolog/lib/fifolog.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008 Poul-Henning Kamp
* 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 __LOCAL_FIFOLOG_H_
diff --git a/usr.sbin/fifolog/lib/fifolog_create.c b/usr.sbin/fifolog/lib/fifolog_create.c
index d3d1e4487f35..5737cba15db6 100644
--- a/usr.sbin/fifolog/lib/fifolog_create.c
+++ b/usr.sbin/fifolog/lib/fifolog_create.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008 Poul-Henning Kamp
* 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 <assert.h>
diff --git a/usr.sbin/fifolog/lib/fifolog_int.c b/usr.sbin/fifolog/lib/fifolog_int.c
index d22bd4745e4f..2cbc430993be 100644
--- a/usr.sbin/fifolog/lib/fifolog_int.c
+++ b/usr.sbin/fifolog/lib/fifolog_int.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008 Poul-Henning Kamp
* 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 <assert.h>
diff --git a/usr.sbin/fifolog/lib/fifolog_reader.c b/usr.sbin/fifolog/lib/fifolog_reader.c
index 1ef6a4e2048f..092d630d5b3f 100644
--- a/usr.sbin/fifolog/lib/fifolog_reader.c
+++ b/usr.sbin/fifolog/lib/fifolog_reader.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008 Poul-Henning Kamp
* 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 <stdio.h>
diff --git a/usr.sbin/fifolog/lib/fifolog_write.h b/usr.sbin/fifolog/lib/fifolog_write.h
index 841ec4a386bb..36186be45a15 100644
--- a/usr.sbin/fifolog/lib/fifolog_write.h
+++ b/usr.sbin/fifolog/lib/fifolog_write.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008 Poul-Henning Kamp
* 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$
*/
#define FIFOLOG_PT_BYTES_PRE 0
diff --git a/usr.sbin/fifolog/lib/fifolog_write_poll.c b/usr.sbin/fifolog/lib/fifolog_write_poll.c
index cffe095d4d7b..f64a21e2b619 100644
--- a/usr.sbin/fifolog/lib/fifolog_write_poll.c
+++ b/usr.sbin/fifolog/lib/fifolog_write_poll.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008 Poul-Henning Kamp
* 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 <assert.h>
diff --git a/usr.sbin/fifolog/lib/getdate.y b/usr.sbin/fifolog/lib/getdate.y
index 8e63e8112993..dfbfad9a9fda 100644
--- a/usr.sbin/fifolog/lib/getdate.y
+++ b/usr.sbin/fifolog/lib/getdate.y
@@ -12,7 +12,6 @@
** Picked up from CVS and slightly cleaned up by to WARNS=5 level by
** Poul-Henning Kamp <phk@FreeBSD.org>
**
-** $FreeBSD$
*/
#include <stdio.h>
@@ -818,30 +817,18 @@ yylex(void)
time_t
get_date(char *p)
{
- struct tm *tm, gmt;
+ struct tm *tm;
time_t Start;
time_t tod;
time_t nowtime;
- struct tm *gmt_ptr;
yyInput = p;
(void)time (&nowtime);
- gmt_ptr = gmtime (&nowtime);
- if (gmt_ptr != NULL)
- {
- /* Make a copy, in case localtime modifies *tm (I think
- that comment now applies to *gmt_ptr, but I am too
- lazy to dig into how gmtime and locatime allocate the
- structures they return pointers to). */
- gmt = *gmt_ptr;
- }
-
if (! (tm = localtime (&nowtime)))
return -1;
- tm = localtime(&nowtime);
yyYear = tm->tm_year + 1900;
yyMonth = tm->tm_mon + 1;
yyDay = tm->tm_mday;
diff --git a/usr.sbin/fifolog/lib/libfifolog.h b/usr.sbin/fifolog/lib/libfifolog.h
index 46d20af46808..239ad4974f1e 100644
--- a/usr.sbin/fifolog/lib/libfifolog.h
+++ b/usr.sbin/fifolog/lib/libfifolog.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008 Poul-Henning Kamp
* 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 <sys/stdint.h>
diff --git a/usr.sbin/fifolog/lib/libfifolog_int.h b/usr.sbin/fifolog/lib/libfifolog_int.h
index 69cd73433195..42dac35aaaf2 100644
--- a/usr.sbin/fifolog/lib/libfifolog_int.h
+++ b/usr.sbin/fifolog/lib/libfifolog_int.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008
* 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$
*/
struct fifolog_file {
diff --git a/usr.sbin/fifolog/lib/miniobj.h b/usr.sbin/fifolog/lib/miniobj.h
index 3edc42c8ff5e..f643b207e7c8 100644
--- a/usr.sbin/fifolog/lib/miniobj.h
+++ b/usr.sbin/fifolog/lib/miniobj.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2008 Poul-Henning Kamp
* 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$
*/
#define ALLOC_OBJ(to, type_magic) \
diff --git a/usr.sbin/flowctl/Makefile b/usr.sbin/flowctl/Makefile
index 8bd63893cc6a..dfc4a8947d08 100644
--- a/usr.sbin/flowctl/Makefile
+++ b/usr.sbin/flowctl/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
.include <src.opts.mk>
@@ -17,4 +16,6 @@ CFLAGS+= -DINET6
CFLAGS+= -DINET
.endif
+CFLAGS+= -Wno-error=unused-but-set-variable
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/flowctl/Makefile.depend b/usr.sbin/flowctl/Makefile.depend
index d64c9ccbda7b..29f4fca87a58 100644
--- a/usr.sbin/flowctl/Makefile.depend
+++ b/usr.sbin/flowctl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/flowctl/flowctl.8 b/usr.sbin/flowctl/flowctl.8
index a8a1ce1c0bd2..b0d9bdeef2b5 100644
--- a/usr.sbin/flowctl/flowctl.8
+++ b/usr.sbin/flowctl/flowctl.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 8, 2012
.Dt FLOWCTL 8
.Os
diff --git a/usr.sbin/flowctl/flowctl.c b/usr.sbin/flowctl/flowctl.c
index 66c6431d00bc..e7684a68a35b 100644
--- a/usr.sbin/flowctl/flowctl.c
+++ b/usr.sbin/flowctl/flowctl.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004-2005 Gleb Smirnoff <glebius@FreeBSD.org>
* Copyright (c) 2001-2003 Roman V. Palagin <romanp@unshadow.net>
@@ -29,11 +29,6 @@
* $SourceForge: flowctl.c,v 1.15 2004/08/31 20:24:58 glebius Exp $
*/
-#ifndef lint
-static const char rcs_id[] =
- "@(#) $FreeBSD$";
-#endif
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
diff --git a/usr.sbin/freebsd-update/Makefile b/usr.sbin/freebsd-update/Makefile
index b64d5c78a88d..14e522adb1a0 100644
--- a/usr.sbin/freebsd-update/Makefile
+++ b/usr.sbin/freebsd-update/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
CONFS= freebsd-update.conf
SCRIPTS=freebsd-update.sh
diff --git a/usr.sbin/freebsd-update/Makefile.depend b/usr.sbin/freebsd-update/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/freebsd-update/Makefile.depend
+++ b/usr.sbin/freebsd-update/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/freebsd-update/freebsd-update.8 b/usr.sbin/freebsd-update/freebsd-update.8
index 6d7fc792c6f1..7524087cb95b 100644
--- a/usr.sbin/freebsd-update/freebsd-update.8
+++ b/usr.sbin/freebsd-update/freebsd-update.8
@@ -23,9 +23,7 @@
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd April 22, 2022
+.Dd February 2, 2024
.Dt FREEBSD-UPDATE 8
.Os
.Sh NAME
@@ -84,8 +82,7 @@ e.g.:
.Pp
In particular, the
.Fx
-Security Team only builds updates for releases shipped in binary form
-by the
+Security Team only builds updates for releases shipped in binary form by the
.Fx
Release Engineering Team.
.Sh OPTIONS
@@ -151,8 +148,8 @@ from
or similar using this flag, see:
.Nm Cm cron
.It Fl -currently-running Ar release
-Do not detect the currently-running release; instead, assume that the
-system is running the specified
+Do not detect the currently-running release; instead, assume that the system is
+running the specified
.Ar release .
This is most likely to be useful when upgrading jails.
.El
@@ -162,28 +159,26 @@ The
can be any one of the following:
.Bl -tag -width "rollback"
.It Cm fetch
-Based on the currently installed world and the configuration
-options set, fetch all available binary updates.
+Based on the currently installed world and the configuration options set, fetch
+all available binary updates.
.It Cm cron
-Sleep a random amount of time between 1 and 3600 seconds,
-then download updates as if the
+Sleep a random amount of time between 1 and 3600 seconds, then download updates
+as if the
.Cm fetch
command was used.
-If updates are downloaded, an email will be sent
-(to root or a different address if specified via the
+If updates are downloaded, an email will be sent (to root or a different
+address if specified via the
.Fl t
option or in the configuration file).
-As the name suggests, this command is designed for running
-from
+As the name suggests, this command is designed for running from
.Xr cron 8 ;
-the random delay serves to minimize the probability that
-a large number of machines will simultaneously attempt to
-fetch updates.
+the random delay serves to minimize the probability that a large number of
+machines will simultaneously attempt to fetch updates.
.It Cm upgrade
Fetch files necessary for upgrading to a new release.
-Before using this command, make sure that you read the
-announcement and release notes for the new release in
-case there are any special steps needed for upgrading.
+Before using this command, make sure that you read the announcement and release
+notes for the new release in case there are any special steps needed for
+upgrading.
Note that this command may require up to 500 MB of space in
.Ar workdir
depending on which components of the
@@ -194,19 +189,15 @@ Check if there are fetched updates ready to install.
Returns exit code 2 if there are no updates to install.
.It Cm install
Install the most recently fetched updates or upgrade.
-Returns exit code 2 if there are no updates to install
-and the
+Returns exit code 2 if there are no updates to install and the
.Cm fetch
-command wasn't passed as an earlier argument in the same
-invocation.
+command wasn't passed as an earlier argument in the same invocation.
.It Cm rollback
Uninstall the most recently installed updates.
.It Cm IDS
-Compare the system against a "known good" index of the
-installed release.
+Compare the system against a "known good" index of the installed release.
.It Cm showconfig
-Show configuration options after parsing conffile and command
-line options.
+Show configuration options after parsing conffile and command line options.
.El
.Sh TIPS
.Bl -bullet
@@ -218,17 +209,15 @@ If your clock is set to local time, adding the line
to
.Pa /etc/crontab
will check for updates every night.
-If your clock is set to UTC, please pick a random time
-other than 3AM, to avoid overly imposing an uneven load
-on the server(s) hosting the updates.
+If your clock is set to UTC, please pick a random time other than 3AM, to avoid
+overly imposing an uneven load on the server(s) hosting the updates.
.It
In spite of its name,
.Nm
-IDS should not be relied upon as an "Intrusion Detection
-System", since if the system has been tampered with
-it cannot be trusted to operate correctly.
-If you intend to use this command for intrusion-detection
-purposes, make sure you boot from a secure disk (e.g., a CD).
+IDS should not be relied upon as an "Intrusion Detection System", since if the
+system has been tampered with it cannot be trusted to operate correctly.
+If you intend to use this command for intrusion-detection purposes, make sure
+you boot from a secure disk (e.g., a CD).
.El
.Sh ENVIRONMENT
.Bl -tag -width "PAGER"
@@ -253,10 +242,26 @@ configuration file.
.It Pa /var/db/freebsd-update/
Default location where
.Nm
-stores temporary files and downloaded updates.
+stores temporary files, downloaded updates, and files required for rollback.
+All files under
+.Pa /var/db/freebsd-update/
+may be deleted if an upgrade is not in progress and rollback will not be
+required.
.El
.Sh SEE ALSO
+.Xr freebsd-version 1 ,
+.Xr uname 1 ,
.Xr freebsd-update.conf 5 ,
.Xr nextboot 8
.Sh AUTHORS
.An Colin Percival Aq Mt cperciva@FreeBSD.org
+.Sh BUGS
+In patch level situations – for example, 13.2-RELEASE-p1 up to
+13.2-RELEASE-p2: if any previous modification to a file in
+.Pa /etc/
+will conflict with an available update, then
+.Nm
+will make no attempt to merge.
+Instead:
+.Nm
+will print a list of affected locally-modified files.
diff --git a/usr.sbin/freebsd-update/freebsd-update.conf b/usr.sbin/freebsd-update/freebsd-update.conf
index 62e6acf96cc8..08cf512ce144 100644
--- a/usr.sbin/freebsd-update/freebsd-update.conf
+++ b/usr.sbin/freebsd-update/freebsd-update.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Trusted keyprint. Changing this is a Bad Idea unless you've received
# a PGP-signed email from <security-officer@FreeBSD.org> telling you to
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh
index 078043326115..d1cd46963a6c 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#-
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright 2004-2007 Colin Percival
# All rights reserved
@@ -27,8 +27,6 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-# $FreeBSD$
-
#### Usage function -- called from command-line handling code.
# Usage instructions. Options not listed:
@@ -49,7 +47,7 @@ Options:
case of an unfinished upgrade
-j jail -- Operate on the given jail specified by jid or name
-k KEY -- Trust an RSA key with SHA256 hash of KEY
- -r release -- Target for upgrade (e.g., 11.1-RELEASE)
+ -r release -- Target for upgrade (e.g., 13.2-RELEASE)
-s server -- Server from which to fetch updates
(default: update.FreeBSD.org)
-t address -- Mail output of cron command, if any, to address
@@ -657,6 +655,63 @@ fetch_setup_verboselevel () {
esac
}
+# Check if there are any kernel modules installed from ports.
+# In that case warn the user that a rebuild from ports (i.e. not from
+# packages) might need necessary for the modules to work in the new release.
+upgrade_check_kmod_ports() {
+ local mod_name
+ local modules
+ local pattern
+ local pkg_name
+ local port_name
+ local report
+ local w
+
+ if ! command -v pkg >/dev/null; then
+ echo "Skipping kernel modules check. pkg(8) not present."
+ return
+ fi
+
+ # Most modules are in /boot/modules but we should actually look
+ # in every path configured in module_path
+ search_files="/boot/defaults/loader.conf /boot/loader.conf"
+ pattern=$(grep -shE '^module_path=' ${search_files} |
+ tail -1 |
+ cut -f2 -d\" |
+ tr ";" "|")
+
+ if [ -z "${pattern}" ]; then
+ # Not having module_path in loader.conf is probably an error.
+ # Check at least the most common path
+ pattern="/boot/modules"
+ fi
+
+ # Check the pkg database for modules installed in those directories
+ modules=$(pkg query '%Fp' | grep -E "${pattern}")
+
+ if [ -z "${modules}" ]; then
+ return
+ fi
+
+ echo -e "\n"
+ echo "The following modules have been installed from packages."
+ echo "As a consequence they might not work when performing a major or minor upgrade."
+ echo -e "It is advised to rebuild these ports:\n"
+
+
+ report="Module Package Port\n------ ------- ----\n"
+ for module in ${modules}; do
+ w=$(pkg which "${module}")
+ mod_name=$(echo "${w}" | awk '{print $1;}')
+ pkg_name=$(echo "${w}" | awk '{print $6;}')
+ port_name=$(pkg info -o "${pkg_name}" | awk '{print $2;}')
+ report="${report}${mod_name} ${pkg_name} ${port_name}\n"
+ done
+
+ echo -e "${report}" | column -t
+ echo -e "\n"
+}
+
# Perform sanity checks and set some final parameters
# in preparation for fetching files. Figure out which
# set of updates should be downloaded: If the user is
@@ -778,7 +833,7 @@ fetch_check_params () {
if ! [ -z "${TARGETRELEASE}" ]; then
echo -n "`basename $0`: "
- echo -n "-r option is meaningless with 'fetch' command. "
+ echo -n "'-r' option is meaningless with 'fetch' command. "
echo "(Did you mean 'upgrade' instead?)"
exit 1
fi
@@ -786,8 +841,8 @@ fetch_check_params () {
# Check that we have updates ready to install
if [ -f ${BDHASH}-install/kerneldone -a $FORCEFETCH -eq 0 ]; then
echo "You have a partially completed upgrade pending"
- echo "Run '$0 install' first."
- echo "Run '$0 fetch -F' to proceed anyway."
+ echo "Run '`basename $0` [options] install' first."
+ echo "Run '`basename $0` [options] fetch -F' to proceed anyway."
exit 1
fi
}
@@ -800,7 +855,7 @@ upgrade_check_params () {
NKERNCONF=${KERNCONF}
# We need TARGETRELEASE set
- _TARGETRELEASE_z="Release target must be specified via -r option."
+ _TARGETRELEASE_z="Release target must be specified via '-r' option."
if [ -z "${TARGETRELEASE}" ]; then
echo -n "`basename $0`: "
echo "${_TARGETRELEASE_z}"
@@ -865,7 +920,7 @@ install_check_params () {
if ! [ -L ${BDHASH}-install ]; then
echo "No updates are available to install."
if [ $ISFETCHED -eq 0 ]; then
- echo "Run '$0 fetch' first."
+ echo "Run '`basename $0` [options] fetch' first."
exit 2
fi
exit 0
@@ -873,7 +928,7 @@ install_check_params () {
if ! [ -f ${BDHASH}-install/INDEX-OLD ] ||
! [ -f ${BDHASH}-install/INDEX-NEW ]; then
echo "Update manifest is corrupt -- this should never happen."
- echo "Re-run '$0 fetch'."
+ echo "Re-run '`basename $0` [options] fetch'."
exit 1
fi
@@ -918,7 +973,7 @@ install_create_be () {
echo -n "Creating snapshot of existing boot environment... "
VERSION=`freebsd-version -ku | sort -V | tail -n 1`
TIMESTAMP=`date +"%Y-%m-%d_%H%M%S"`
- bectl create ${VERSION}_${TIMESTAMP}
+ bectl create -r ${VERSION}_${TIMESTAMP}
if [ $? -eq 0 ]; then
echo "done.";
else
@@ -975,7 +1030,7 @@ IDS_check_params () {
_SERVERNAME_z=\
"SERVERNAME must be given via command line or configuration file."
- _KEYPRINT_z="Key must be given via -k option or configuration file."
+ _KEYPRINT_z="Key must be given via '-k' option or configuration file."
_KEYPRINT_bad="Invalid key fingerprint: "
_WORKDIR_bad="Directory does not exist or is not writable: "
@@ -1204,10 +1259,10 @@ fetch_progress () {
continuep () {
while read -p "Does this look reasonable (y/n)? " CONTINUE; do
case "${CONTINUE}" in
- y*)
+ [yY]*)
return 0
;;
- n*)
+ [nN]*)
return 1
;;
esac
@@ -1677,11 +1732,12 @@ fetch_inspect_system () {
echo "done."
}
-# For any paths matching ${MERGECHANGES}, compare $1 and $2 and find any
-# files which differ; generate $3 containing these paths and the old hashes.
+# For any paths matching ${MERGECHANGES}, compare $2 against $1 and $3 and
+# find any files with values unique to $2; generate $4 containing these paths
+# and their corresponding hashes from $1.
fetch_filter_mergechanges () {
# Pull out the paths and hashes of the files matching ${MERGECHANGES}.
- for F in $1 $2; do
+ for F in $1 $2 $3; do
for X in ${MERGECHANGES}; do
grep -E "^${X}" ${F}
done |
@@ -1689,9 +1745,10 @@ fetch_filter_mergechanges () {
sort > ${F}-values
done
- # Any line in $2-values which doesn't appear in $1-values and is a
- # file means that we should list the path in $3.
- comm -13 $1-values $2-values |
+ # Any line in $2-values which doesn't appear in $1-values or $3-values
+ # and is a file means that we should list the path in $3.
+ sort $1-values $3-values |
+ comm -13 - $2-values |
fgrep '|f|' |
cut -f 1 -d '|' > $2-paths
@@ -1703,10 +1760,10 @@ fetch_filter_mergechanges () {
while read X; do
look "${X}|" $1-values |
head -1
- done < $2-paths > $3
+ done < $2-paths > $4
# Clean up
- rm $1-values $2-values $2-paths
+ rm $1-values $2-values $3-values $2-paths
}
# For any paths matching ${UPDATEIFUNMODIFIED}, remove lines from $[123]
@@ -2326,7 +2383,7 @@ upgrade_guess_components () {
WARNING: This system is running a "${KCOMP}" kernel, which is not a
kernel configuration distributed as part of FreeBSD ${RELNUM}.
This kernel will not be updated: you MUST update the kernel manually
-before running "$0 install".
+before running '`basename $0` [options] install'.
EOF
fi
@@ -2543,8 +2600,26 @@ The following file could not be merged automatically: ${F}
Press Enter to edit this file in ${EDITOR} and resolve the conflicts
manually...
EOF
- read dummy </dev/tty
- ${EDITOR} `pwd`/merge/new/${F} < /dev/tty
+ while true; do
+ read response </dev/tty
+ if expr "${response}" : '[Aa][Cc][Cc][Ee][Pp][Tt]' > /dev/null; then
+ echo
+ break
+ fi
+ ${EDITOR} `pwd`/merge/new/${F} < /dev/tty
+
+ if ! grep -qE '^(<<<<<<<|=======|>>>>>>>)([[:space:]].*)?$' $(pwd)/merge/new/${F} ; then
+ break
+ fi
+ cat <<-EOF
+
+Merge conflict markers remain in: ${F}
+These must be resolved for the system to be functional.
+
+Press Enter to return to editing this file, or type "ACCEPT" to carry on with
+these lines remaining in the file.
+ EOF
+ done
done < failed.merges
rm failed.merges
@@ -2698,7 +2773,7 @@ upgrade_run () {
# Based on ${MERGECHANGES}, generate a file tomerge-old with the
# paths and hashes of old versions of files to merge.
- fetch_filter_mergechanges INDEX-OLD INDEX-PRESENT tomerge-old
+ fetch_filter_mergechanges INDEX-OLD INDEX-PRESENT INDEX-NEW tomerge-old
# Based on ${UPDATEIFUNMODIFIED}, remove lines from INDEX-* which
# correspond to lines in INDEX-PRESENT with hashes not appearing
@@ -2752,7 +2827,7 @@ upgrade_run () {
# Remind the user that they need to run "freebsd-update install"
# to install the downloaded bits, in case they didn't RTFM.
- echo "To install the downloaded upgrades, run \"$0 install\"."
+ echo "To install the downloaded upgrades, run '`basename $0` [options] install'."
}
# Make sure that all the file hashes mentioned in $@ have corresponding
@@ -2770,7 +2845,7 @@ install_verify () {
if ! [ -f files/${HASH}.gz ]; then
echo -n "Update files missing -- "
echo "this should never happen."
- echo "Re-run '$0 fetch'."
+ echo "Re-run '`basename $0` [options] fetch'."
return 1
fi
done < filelist
@@ -2877,10 +2952,19 @@ backup_kernel () {
(cd ${BASEDIR}/${KERNELDIR} && find . -type f $FINDFILTER -exec \
cp -pl '{}' ${BASEDIR}/${BACKUPKERNELDIR}/'{}' \;)
- # Re-enable patchname expansion.
+ # Re-enable pathname expansion.
set +f
}
+# Check for and remove an existing directory that conflicts with the file or
+# symlink that we are going to install.
+dir_conflict () {
+ if [ -d "$1" ]; then
+ echo "Removing conflicting directory $1"
+ rm -rf -- "$1"
+ fi
+}
+
# Install new files
install_from_index () {
# First pass: Do everything apart from setting file flags. We
@@ -2890,11 +2974,18 @@ install_from_index () {
while read FPATH TYPE OWNER GROUP PERM FLAGS HASH LINK; do
case ${TYPE} in
d)
- # Create a directory
+ # Create a directory. A file may change to a directory
+ # on upgrade (PR273661). If that happens, remove the
+ # file first.
+ if [ -e "${BASEDIR}/${FPATH}" ] && \
+ ! [ -d "${BASEDIR}/${FPATH}" ]; then
+ rm -f -- "${BASEDIR}/${FPATH}"
+ fi
install -d -o ${OWNER} -g ${GROUP} \
-m ${PERM} ${BASEDIR}/${FPATH}
;;
f)
+ dir_conflict "${BASEDIR}/${FPATH}"
if [ -z "${LINK}" ]; then
# Create a file, without setting flags.
gunzip < files/${HASH}.gz > ${HASH}
@@ -2907,6 +2998,7 @@ install_from_index () {
fi
;;
L)
+ dir_conflict "${BASEDIR}/${FPATH}"
# Create a symlink
ln -sfh ${HASH} ${BASEDIR}/${FPATH}
;;
@@ -2943,10 +3035,14 @@ install_delete () {
rmdir ${BASEDIR}/${FPATH}
;;
f)
- rm ${BASEDIR}/${FPATH}
+ if [ -f "${BASEDIR}/${FPATH}" ]; then
+ rm "${BASEDIR}/${FPATH}"
+ fi
;;
L)
- rm ${BASEDIR}/${FPATH}
+ if [ -L "${BASEDIR}/${FPATH}" ]; then
+ rm "${BASEDIR}/${FPATH}"
+ fi
;;
esac
done < killfiles
@@ -2985,7 +3081,7 @@ install_files () {
cat <<-EOF
Kernel updates have been installed. Please reboot and run
-"$0 install" again to finish installing updates.
+'`basename $0` [options] install' again to finish installing updates.
EOF
exit 0
fi
@@ -3023,9 +3119,10 @@ Kernel updates have been installed. Please reboot and run
install_from_index INDEX-NEW || return 1
install_delete INDEX-OLD INDEX-NEW || return 1
- # Restart sshd if running (PR263489). Note that this does not
- # affect child sshd processes handling existing sessions.
- if service sshd status >/dev/null 2>/dev/null; then
+ # Restart host sshd if running (PR263489). Note that this does
+ # not affect child sshd processes handling existing sessions.
+ if [ "$BASEDIR" = / ] && \
+ service sshd status >/dev/null 2>/dev/null; then
echo
echo "Restarting sshd after upgrade"
service sshd restart
@@ -3071,8 +3168,8 @@ Kernel updates have been installed. Please reboot and run
Completing this upgrade requires removing old shared object files.
Please rebuild all installed 3rd party software (e.g., programs
-installed from the ports tree) and then run "$0 install"
-again to finish installing updates.
+installed from the ports tree) and then run
+'`basename $0` [options] install' again to finish installing updates.
EOF
rm newfiles
exit 0
@@ -3156,6 +3253,11 @@ rollback_setup_rollback () {
# Install old files, delete new files, and update linker.hints
rollback_files () {
+ # Create directories first. They may be needed by files we will
+ # install in subsequent steps (PR273950).
+ awk -F \| '{if ($2 == "d") print }' $1/INDEX-OLD > INDEX-OLD
+ install_from_index INDEX-OLD || return 1
+
# Install old shared library files which don't have the same path as
# a new shared library file.
grep -vE '^/boot/' $1/INDEX-NEW |
@@ -3412,6 +3514,7 @@ cmd_cron () {
[ ${VERBOSELEVEL} = "debug" ]; then
mail -s "`hostname` security updates" ${MAILTO} < ${TMPFILE}
fi
+ ISFETCHED=1
rm ${TMPFILE}
}
@@ -3420,6 +3523,7 @@ cmd_cron () {
cmd_upgrade () {
finalize_components_config ${COMPONENTS}
upgrade_check_params
+ upgrade_check_kmod_ports
upgrade_run || exit 1
}
@@ -3446,7 +3550,7 @@ cmd_updatesready () {
fi
echo "There are updates available to install."
- echo "Run '$0 install' to proceed."
+ echo "Run '`basename $0` [options] install' to proceed."
}
# Install downloaded updates.
@@ -3492,6 +3596,9 @@ fi
# Set LC_ALL in order to avoid problems with character ranges like [A-Z].
export LC_ALL=C
+# Clear environment variables that may affect operation of tools that we use.
+unset GREP_OPTIONS
+
get_params $@
for COMMAND in ${COMMANDS}; do
cmd_${COMMAND}
diff --git a/usr.sbin/fstyp/Makefile b/usr.sbin/fstyp/Makefile
index e2758de95519..0ec14daeb773 100644
--- a/usr.sbin/fstyp/Makefile
+++ b/usr.sbin/fstyp/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/fstyp/Makefile.depend b/usr.sbin/fstyp/Makefile.depend
index 9371e83a7830..07af642591f5 100644
--- a/usr.sbin/fstyp/Makefile.depend
+++ b/usr.sbin/fstyp/Makefile.depend
@@ -1,10 +1,7 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- cddl/lib/libavl \
- cddl/lib/libumem \
- cddl/lib/libuutil \
+ cddl/lib/libspl \
include \
include/xlocale \
lib/${CSU_DIR} \
@@ -12,15 +9,9 @@ DIRDEPS = \
lib/libcapsicum \
lib/libcasper/libcasper \
lib/libcompiler_rt \
- lib/libexpat \
lib/libgeom \
lib/libmd \
- lib/libsbuf \
- lib/libthr \
lib/libufs \
- lib/libutil \
- lib/libz \
- lib/msun \
.include <dirdeps.mk>
diff --git a/usr.sbin/fstyp/Makefile.depend.options b/usr.sbin/fstyp/Makefile.depend.options
index d51fe0e13561..3bc806c5cc59 100644
--- a/usr.sbin/fstyp/Makefile.depend.options
+++ b/usr.sbin/fstyp/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= ZFS
diff --git a/usr.sbin/fstyp/apfs.c b/usr.sbin/fstyp/apfs.c
index 7f8543a5a108..aeb459a1c3af 100644
--- a/usr.sbin/fstyp/apfs.c
+++ b/usr.sbin/fstyp/apfs.c
@@ -24,8 +24,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <err.h>
#include <errno.h>
diff --git a/usr.sbin/fstyp/befs.c b/usr.sbin/fstyp/befs.c
index 352fe7d4c296..6c204f7eb381 100644
--- a/usr.sbin/fstyp/befs.c
+++ b/usr.sbin/fstyp/befs.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021 Miguel Gocobachi
*
@@ -28,8 +28,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.sbin/fstyp/cd9660.c b/usr.sbin/fstyp/cd9660.c
index 658af338d4dd..e981a5978dd4 100644
--- a/usr.sbin/fstyp/cd9660.c
+++ b/usr.sbin/fstyp/cd9660.c
@@ -29,8 +29,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/fstyp/exfat.c b/usr.sbin/fstyp/exfat.c
index 80cef5cbf822..8f8393b861fb 100644
--- a/usr.sbin/fstyp/exfat.c
+++ b/usr.sbin/fstyp/exfat.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/endian.h>
diff --git a/usr.sbin/fstyp/ext2fs.c b/usr.sbin/fstyp/ext2fs.c
index 79a4e3ad4172..d7110f6896ce 100644
--- a/usr.sbin/fstyp/ext2fs.c
+++ b/usr.sbin/fstyp/ext2fs.c
@@ -29,8 +29,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
diff --git a/usr.sbin/fstyp/fstyp.8 b/usr.sbin/fstyp/fstyp.8
index 22d41628d8d5..8471bc207e3c 100644
--- a/usr.sbin/fstyp/fstyp.8
+++ b/usr.sbin/fstyp/fstyp.8
@@ -24,8 +24,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 24, 2019
.Dt FSTYP 8
.Os
diff --git a/usr.sbin/fstyp/fstyp.c b/usr.sbin/fstyp/fstyp.c
index 91c36d9d9191..578210116ae5 100644
--- a/usr.sbin/fstyp/fstyp.c
+++ b/usr.sbin/fstyp/fstyp.c
@@ -27,9 +27,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/capsicum.h>
#include <sys/disk.h>
#include <sys/ioctl.h>
diff --git a/usr.sbin/fstyp/fstyp.h b/usr.sbin/fstyp/fstyp.h
index f11d66f5ffc2..d87cac456379 100644
--- a/usr.sbin/fstyp/fstyp.h
+++ b/usr.sbin/fstyp/fstyp.h
@@ -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 FSTYP_H
diff --git a/usr.sbin/fstyp/geli.c b/usr.sbin/fstyp/geli.c
index 59e8653bf195..17d1faf8407f 100644
--- a/usr.sbin/fstyp/geli.c
+++ b/usr.sbin/fstyp/geli.c
@@ -25,8 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/disk.h>
#include <sys/types.h>
#include <stdio.h>
diff --git a/usr.sbin/fstyp/hammer.c b/usr.sbin/fstyp/hammer.c
index 777f5d312371..45aee42fb53a 100644
--- a/usr.sbin/fstyp/hammer.c
+++ b/usr.sbin/fstyp/hammer.c
@@ -29,8 +29,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/fstyp/hammer2.c b/usr.sbin/fstyp/hammer2.c
index dfd026649fdb..e0c036c7442a 100644
--- a/usr.sbin/fstyp/hammer2.c
+++ b/usr.sbin/fstyp/hammer2.c
@@ -29,8 +29,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
diff --git a/usr.sbin/fstyp/hammer2_disk.h b/usr.sbin/fstyp/hammer2_disk.h
index c975cbd8309b..6efefe9a2495 100644
--- a/usr.sbin/fstyp/hammer2_disk.h
+++ b/usr.sbin/fstyp/hammer2_disk.h
@@ -31,8 +31,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$
*/
#ifndef _HAMMER2_DISK_H_
@@ -55,8 +53,8 @@ struct dmsg_hdr {
uint64_t reserved18; /* 18 */
uint32_t cmd; /* 20 flags | cmd | hdr_size / ALIGN */
- uint32_t aux_crc; /* 24 auxillary data crc */
- uint32_t aux_bytes; /* 28 auxillary data length (bytes) */
+ uint32_t aux_crc; /* 24 auxiliary data crc */
+ uint32_t aux_bytes; /* 28 auxiliary data length (bytes) */
uint32_t error; /* 2C error code or 0 */
uint64_t aux_descr; /* 30 negotiated OOB data descr */
uint32_t reserved38; /* 38 */
@@ -621,7 +619,7 @@ typedef struct hammer2_dirent_head hammer2_dirent_head_t;
*
* Simple check codes are not sufficient for unverified dedup. Even with
* a maximally-sized check code unverified dedup should only be used in
- * in subdirectory trees where you do not need 100% data integrity.
+ * subdirectory trees where you do not need 100% data integrity.
*
* Unverified dedup is deduping based on meta-data only without verifying
* that the data blocks are actually identical. Verified dedup guarantees
diff --git a/usr.sbin/fstyp/hammer_disk.h b/usr.sbin/fstyp/hammer_disk.h
index 205c9fb64fd4..4b5182d7e868 100644
--- a/usr.sbin/fstyp/hammer_disk.h
+++ b/usr.sbin/fstyp/hammer_disk.h
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*
* $DragonFly: src/sys/vfs/hammer/hammer_disk.h,v 1.55 2008/11/13 02:18:43 dillon Exp $
- * $FreeBSD$
*/
#ifndef VFS_HAMMER_DISK_H_
@@ -910,7 +909,7 @@ typedef struct hammer_inode_data {
} *hammer_inode_data_t;
/*
- * Neither mtime nor atime upates are CRCd by the B-Tree element.
+ * Neither mtime nor atime updates are CRCd by the B-Tree element.
* mtime updates have UNDO, atime updates do not.
*/
#define HAMMER_INODE_CRCSIZE \
@@ -1038,7 +1037,7 @@ typedef struct hammer_pseudofs_data *hammer_pseudofs_data_t;
* Snapshot meta-data { Objid = HAMMER_OBJID_ROOT, Key = tid, rectype = SNAPSHOT }.
*
* Snapshot records replace the old <fs>/snapshots/<softlink> methodology. Snapshot
- * records are mirrored but may be independantly managed once they are laid down on
+ * records are mirrored but may be independently managed once they are laid down on
* a slave.
*
* NOTE: The b-tree key is signed, the tid is not, so callers must still sort the
diff --git a/usr.sbin/fstyp/hfsplus.c b/usr.sbin/fstyp/hfsplus.c
index 3a94faf7766f..bdeaaa3b397c 100644
--- a/usr.sbin/fstyp/hfsplus.c
+++ b/usr.sbin/fstyp/hfsplus.c
@@ -24,8 +24,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <err.h>
#include <errno.h>
diff --git a/usr.sbin/fstyp/msdosfs.c b/usr.sbin/fstyp/msdosfs.c
index 473180d9c644..cd0a67243a15 100644
--- a/usr.sbin/fstyp/msdosfs.c
+++ b/usr.sbin/fstyp/msdosfs.c
@@ -30,8 +30,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/fstyp/msdosfs.h b/usr.sbin/fstyp/msdosfs.h
index a04b87fe9706..91fe5967cd03 100644
--- a/usr.sbin/fstyp/msdosfs.h
+++ b/usr.sbin/fstyp/msdosfs.h
@@ -22,8 +22,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/types.h>
diff --git a/usr.sbin/fstyp/ntfs.c b/usr.sbin/fstyp/ntfs.c
index c286d950dc2b..a3457c285edc 100644
--- a/usr.sbin/fstyp/ntfs.c
+++ b/usr.sbin/fstyp/ntfs.c
@@ -29,8 +29,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#ifdef WITH_ICONV
#include <iconv.h>
diff --git a/usr.sbin/fstyp/tests/Makefile b/usr.sbin/fstyp/tests/Makefile
index c821bc9b45eb..99e7d4e2c51f 100644
--- a/usr.sbin/fstyp/tests/Makefile
+++ b/usr.sbin/fstyp/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/usr.sbin/fstyp/tests/Makefile.depend b/usr.sbin/fstyp/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/fstyp/tests/Makefile.depend
+++ b/usr.sbin/fstyp/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/fstyp/tests/fstyp_test.sh b/usr.sbin/fstyp/tests/fstyp_test.sh
index 81a549629dd7..af3516e02de1 100755
--- a/usr.sbin/fstyp/tests/fstyp_test.sh
+++ b/usr.sbin/fstyp/tests/fstyp_test.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2015 Alan Somers
#
@@ -25,8 +25,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-# $FreeBSD$
-
atf_test_case befs
befs_head() {
atf_set "descr" "fstyp(8) can detect BeFS and label filesystem"
diff --git a/usr.sbin/fstyp/ufs.c b/usr.sbin/fstyp/ufs.c
index e4de1283e769..5133febbf065 100644
--- a/usr.sbin/fstyp/ufs.c
+++ b/usr.sbin/fstyp/ufs.c
@@ -29,9 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@@ -50,11 +47,9 @@ fstyp_ufs(FILE *fp, char *label, size_t labelsize)
{
struct fs *fs;
- switch (sbget(fileno(fp), &fs, STDSB)) {
+ switch (sbget(fileno(fp), &fs, UFS_STDSB, UFS_NOCSUM)) {
case 0:
strlcpy(label, fs->fs_volname, labelsize);
- free(fs->fs_csp);
- free(fs->fs_si);
free(fs);
return (0);
case ENOENT:
diff --git a/usr.sbin/fstyp/zfs.c b/usr.sbin/fstyp/zfs.c
index 96ff0485d71e..6fde88c79524 100644
--- a/usr.sbin/fstyp/zfs.c
+++ b/usr.sbin/fstyp/zfs.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <stdint.h>
@@ -45,7 +42,7 @@ fstyp_zfs(FILE *fp, char *label, size_t labelsize)
{
vdev_label_t *vdev_label = NULL;
vdev_phys_t *vdev_phys;
- char *zpool_name = NULL;
+ const char *zpool_name = NULL;
nvlist_t *config = NULL;
int err = 0;
diff --git a/usr.sbin/ftp-proxy/Makefile b/usr.sbin/ftp-proxy/Makefile
index 768901f99131..dc7ad7096448 100644
--- a/usr.sbin/ftp-proxy/Makefile
+++ b/usr.sbin/ftp-proxy/Makefile
@@ -1,7 +1,7 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/contrib/pf/ftp-proxy
+PACKAGE= pf
PROG= ftp-proxy
MAN= ftp-proxy.8
diff --git a/usr.sbin/ftp-proxy/Makefile.depend b/usr.sbin/ftp-proxy/Makefile.depend
index 34af16caac3e..cc544b2b390c 100644
--- a/usr.sbin/ftp-proxy/Makefile.depend
+++ b/usr.sbin/ftp-proxy/Makefile.depend
@@ -1,15 +1,15 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libevent \
+ lib/libevent1 \
+ lib/libnv \
+ lib/libpfctl \
.include <dirdeps.mk>
diff --git a/usr.sbin/fwcontrol/Makefile b/usr.sbin/fwcontrol/Makefile
index ec0e67f67d20..ae87135af919 100644
--- a/usr.sbin/fwcontrol/Makefile
+++ b/usr.sbin/fwcontrol/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= fwcontrol
SRCS= fwcontrol.c fwcrom.c fwdv.c fwmpegts.c
@@ -9,5 +8,6 @@ WARNS?= 3
SDIR= ${SRCTOP}/sys
CFLAGS+=-I${.CURDIR} -I${SDIR}
+CWARNFLAGS+= ${NO_WZERO_LENGTH_BOUNDS}
.include <bsd.prog.mk>
diff --git a/usr.sbin/fwcontrol/Makefile.depend b/usr.sbin/fwcontrol/Makefile.depend
index d5ed563ecfc8..344a5d0e9310 100644
--- a/usr.sbin/fwcontrol/Makefile.depend
+++ b/usr.sbin/fwcontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/fwcontrol/fwcontrol.8 b/usr.sbin/fwcontrol/fwcontrol.8
index 4e9b61b77c39..7f461162eae1 100644
--- a/usr.sbin/fwcontrol/fwcontrol.8
+++ b/usr.sbin/fwcontrol/fwcontrol.8
@@ -22,8 +22,6 @@
.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd September 12, 2008
.Dt FWCONTROL 8
.Os
diff --git a/usr.sbin/fwcontrol/fwcontrol.c b/usr.sbin/fwcontrol/fwcontrol.c
index 4554ab9a8fbb..94478259606d 100644
--- a/usr.sbin/fwcontrol/fwcontrol.c
+++ b/usr.sbin/fwcontrol/fwcontrol.c
@@ -36,7 +36,6 @@
#if defined(__FreeBSD__)
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#endif
#include <sys/param.h>
diff --git a/usr.sbin/fwcontrol/fwdv.c b/usr.sbin/fwcontrol/fwdv.c
index 8c14e1ad8ed8..140549f2a490 100644
--- a/usr.sbin/fwcontrol/fwdv.c
+++ b/usr.sbin/fwcontrol/fwdv.c
@@ -32,8 +32,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/param.h>
#include <sys/ioctl.h>
diff --git a/usr.sbin/fwcontrol/fwmethods.h b/usr.sbin/fwcontrol/fwmethods.h
index 9ac82e6fab8d..484e2044e8c6 100644
--- a/usr.sbin/fwcontrol/fwmethods.h
+++ b/usr.sbin/fwcontrol/fwmethods.h
@@ -1,7 +1,5 @@
/*-
* This file is in the public domain.
- *
- * $FreeBSD$
*/
typedef void (fwmethod)(int dev_fd, const char *filename, char ich, int count);
diff --git a/usr.sbin/fwcontrol/fwmpegts.c b/usr.sbin/fwcontrol/fwmpegts.c
index c744b53a7d46..5a6551c62a8d 100644
--- a/usr.sbin/fwcontrol/fwmpegts.c
+++ b/usr.sbin/fwcontrol/fwmpegts.c
@@ -33,7 +33,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
*/
#include <sys/param.h>
#include <sys/ioctl.h>
diff --git a/usr.sbin/fwget/Makefile b/usr.sbin/fwget/Makefile
new file mode 100644
index 000000000000..1cdf0f18230d
--- /dev/null
+++ b/usr.sbin/fwget/Makefile
@@ -0,0 +1,7 @@
+PACKAGE= fwget
+
+SCRIPTS= fwget
+MAN= fwget.8
+SUBDIR= pci
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/fwget/fwget.8 b/usr.sbin/fwget/fwget.8
new file mode 100644
index 000000000000..71cee817b7e6
--- /dev/null
+++ b/usr.sbin/fwget/fwget.8
@@ -0,0 +1,64 @@
+.\" Copyright (c) 2023 Beckhoff Automation GmbH & Co. KG
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd Apr 26, 2023
+.Dt FWGET 8
+.Os
+.Sh NAME
+.Nm fwget
+.Nd Install firmwares for the running system
+.Sh SYNOPSIS
+.Nm
+.Op Fl v
+.Op Fl n
+.Ar subsystem
+.Sh DESCRIPTION
+The
+.Nm
+utility can be used to install firmwares packaged needed for the running
+system
+.Pp
+If not specified the
+.Ar subsystem
+argument will default to pci cards.
+.Pp
+The options are as follows:
+.Bl -tag -width
+.It Fl n
+Dry run, only show needed packages
+.It Fl v
+Be more verbose
+.El
+.Sh SEE ALSO
+.Xr firmware 9
+.Sh HISTORY
+The
+.Nm
+utility appeared in
+.Fx 14.0 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+utility and this manual page were written by
+.An Emmanuel Vadot Aq Mt manu@FreeBSD.org
+for Beckhoff Automation GmbH & Co. KG .
diff --git a/usr.sbin/fwget/fwget.sh b/usr.sbin/fwget/fwget.sh
new file mode 100644
index 000000000000..154fb7dc92e1
--- /dev/null
+++ b/usr.sbin/fwget/fwget.sh
@@ -0,0 +1,125 @@
+#!/bin/sh
+
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright 2023 Beckhoff Automation GmbH & Co. KG
+# Copyright 2023 Bjoern A. Zeeb
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted providing that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+: ${LIBEXEC_PATH:="/usr/libexec/fwget"}
+
+usage()
+{
+ cat <<EOF
+Usage: $(basename "$0") [options] [subsystem]
+
+Supported subsystems
+ pci
+
+Options:
+ -n -- Do not install package, only print the results
+ -v -- More verbose
+EOF
+ exit 1
+}
+
+log()
+{
+ echo "$@"
+}
+
+log_verbose()
+{
+ if [ "${VERBOSE}" = "n" ]; then
+ return
+ fi
+
+ echo "$@"
+}
+
+addpkg()
+{
+ local _p
+
+ _p=$1
+
+ case "${packages}" in
+ "") packages="${_p}" ;;
+ *) # Avoid duplicates.
+ case " ${packages} " in
+ *\ ${_p}\ *) ;; # duplicate
+ *) packages="${packages} ${_p}" ;;
+ esac
+ esac
+}
+
+DRY_RUN=n
+VERBOSE=n
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -n)
+ DRY_RUN=y
+ ;;
+ -v)
+ VERBOSE=y
+ ;;
+ *)
+ subsystems="${subsystems} $1"
+ ;;
+ esac
+ shift
+done
+
+# Default searching PCI subsystem
+if [ -z "${subsystems}" ]; then
+ subsystems="pci"
+fi
+
+# Fail early on unsupported subsystem
+for subsystem in ${subsystems}; do
+ if [ ! -f "${LIBEXEC_PATH}"/"${subsystem}" ]; then
+ usage
+ fi
+ . "${LIBEXEC_PATH}"/"${subsystem}"
+done
+
+packages=""
+for subsystem in ${subsystems}; do
+ "${subsystem}"_search_packages
+done
+
+case "${packages}" in
+""|^[[:space:]]*$)
+ echo "No firmware packages to install."
+ exit 0
+ ;;
+esac
+
+echo "Needed firmware packages: '${packages}'"
+if [ "${DRY_RUN}" = "y" ]; then
+ exit 0
+fi
+
+pkg install -qy ${packages}
diff --git a/usr.sbin/fwget/pci/Makefile b/usr.sbin/fwget/pci/Makefile
new file mode 100644
index 000000000000..66b3901e4a91
--- /dev/null
+++ b/usr.sbin/fwget/pci/Makefile
@@ -0,0 +1,14 @@
+PACKAGE= fwget
+
+SCRIPTS=pci \
+ pci_network_mediatek \
+ pci_network_qca \
+ pci_network_realtek \
+ pci_video_amd \
+ pci_video_intel
+
+BINDIR= ${LIBEXECDIR}/fwget
+
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/fwget/pci/pci b/usr.sbin/fwget/pci/pci
new file mode 100644
index 000000000000..6a66049842e2
--- /dev/null
+++ b/usr.sbin/fwget/pci/pci
@@ -0,0 +1,113 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright 2023 Beckhoff Automation GmbH & Co. KG
+# Copyright 2023 Bjoern A. Zeeb
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted providing that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+pci_get_class()
+{
+ local hexclass=$(echo $1 | sed 's/.*class=\(0x[0-9a-z]\{2\}\).*/\1/')
+ case "${hexclass}" in
+ 0x00) echo "old" ;; # built before class codes were finalized
+ 0x02) echo "network" ;;
+ 0x03) echo "video" ;;
+ 0xff) echo "misc" ;; # does not fit in other defined classes
+ esac
+}
+
+pci_get_vendor()
+{
+ local hexvendor=$(echo $1 | sed 's/.*\ vendor=\(0x[0-9a-z]*\).*/\1/')
+
+ case "${hexvendor}" in
+ 0x1002) echo "amd" ;;
+ 0x10ec) echo "realtek" ;;
+ 0x14c3) echo "mediatek" ;;
+ 0x168c) echo "qca" ;; # Qualcomm Atheros
+ 0x17cb) echo "qca" ;; # Qualcomm Technologies
+ 0x8086) echo "intel" ;;
+ esac
+}
+
+pci_get_device()
+{
+ local hexdevice=$(echo $1 | sed 's/.*\ device=\(0x[0-9a-z]*\).*/\1/')
+
+ echo ${hexdevice}
+}
+
+pci_fixup_class()
+{
+ local _c _v
+ _c=$1
+ _v=$2
+
+ case ${_c} in
+ "old")
+ case ${_v} in
+ "mediatek") echo "network" ;;
+ esac
+ ;;
+ "misc")
+ case ${_v} in
+ "qca") echo "network" ;;
+ esac
+ ;;
+ esac
+}
+
+pci_search_packages()
+{
+ local IFS
+
+ oldifs=$IFS
+ IFS=$'\n'
+ for fulldevice in $(pciconf -l); do
+ class=$(pci_get_class "${fulldevice}")
+ if [ -z "${class}" ]; then
+ continue
+ fi
+ vendor=$(pci_get_vendor "${fulldevice}")
+ if [ -z "${vendor}" ]; then
+ continue
+ fi
+ device=$(pci_get_device "${fulldevice}")
+
+ log_verbose "Trying to match device ${device} in class ${class} and vendor ${vendor} with pci_${class}_${vendor}"
+ if [ ! -f ${LIBEXEC_PATH}/pci_${class}_${vendor} ]; then
+ class=$(pci_fixup_class ${class} ${vendor})
+ if [ -z "${class}" ]; then
+ continue
+ fi
+ log_verbose "Trying to match device ${device} in fixed up class ${class} and vendor ${vendor} with pci_${class}_${vendor}"
+ if [ ! -f ${LIBEXEC_PATH}/pci_${class}_${vendor} ]; then
+ continue
+ fi
+ fi
+ . ${LIBEXEC_PATH}/pci_${class}_${vendor}
+
+ pci_${class}_${vendor} ${device}
+ done
+ IFS=${oldifs}
+}
diff --git a/usr.sbin/fwget/pci/pci_network_mediatek b/usr.sbin/fwget/pci/pci_network_mediatek
new file mode 100644
index 000000000000..5e4d2af9eb26
--- /dev/null
+++ b/usr.sbin/fwget/pci/pci_network_mediatek
@@ -0,0 +1,72 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright 2023 Bjoern A. Zeeb
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+# mt7915
+pci_network_mediatek_mt7915()
+{
+
+ # awk 'BEGIN { x = 0; } { if (/mt7915_pci_device_table/) { x=1 }; if (/^\};/) { x=0 }; if (x==1 && /PCI_DEVICE\(PCI_VENDOR_ID_MEDIATEK,/) { gsub(").*", "", $3); printf "%s)\taddpkg \"wifi-firmware-mt76-kmod\"; return 1 ;;\n", tolower($3) } }' *.c
+
+ case "$1" in
+ 0x7915) addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
+ 0x7906) addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
+ esac
+}
+
+# mt7921
+pci_network_mediatek_mt7921()
+{
+
+ # awk 'BEGIN { x = 0; } { if (/mt7921_pci_device_table/) { x=1 }; if (/^\};/) { x=0 }; if (x==1 && /PCI_DEVICE\(PCI_VENDOR_ID_MEDIATEK,/) { gsub(").*", "", $3); printf "%s)\taddpkg \"wifi-firmware-mt76-kmod\"; return 1 ;;\n", tolower($3) } }' *.c
+ case "$1" in
+ 0x7961) addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
+ 0x7922) addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
+ 0x0608) addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
+ 0x0616) addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
+ esac
+}
+
+# mt7996
+pci_network_mediatek_mt7996()
+{
+
+ # awk 'BEGIN { x = 0; } { if (/mt7996_pci_device_table/) { x=1 }; if (/^\};/) { x=0 }; if (x==1 && /PCI_DEVICE\(PCI_VENDOR_ID_MEDIATEK,/) { gsub(").*", "", $3); printf "%s)\taddpkg \"wifi-firmware-mt76-kmod\"; return 1 ;;\n", tolower($3) } }' *.c
+ case "$1" in
+ 0x7990) addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
+ esac
+}
+
+pci_network_mediatek()
+{
+
+ for _drv in mt7915 mt7921 mt7996; do
+ pci_network_mediatek_${_drv} "$1"
+ case $? in
+ 1) break ;;
+ esac
+ done
+}
diff --git a/usr.sbin/fwget/pci/pci_network_qca b/usr.sbin/fwget/pci/pci_network_qca
new file mode 100644
index 000000000000..cf33e0d87239
--- /dev/null
+++ b/usr.sbin/fwget/pci/pci_network_qca
@@ -0,0 +1,81 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright 2023 Bjoern A. Zeeb
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+# ath10k
+pci_network_qca_ath10k()
+{
+
+ # awk '/DEVICE_ID[[:space:]]/ { gsub("[()]", "", $3); printf "%s)\taddpkg \"wifi-firmware-ath10k-kmod\"; return 1 ;;\n", tolower($3) }' hw.h
+ # We ignore the ubiquity entry for now.
+ case "$1" in
+ 0x003c) addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
+ 0x0041) addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
+ 0x003e) addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
+ 0x0042) addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
+ 0x0040) addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
+ 0x0056) addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
+ 0x0046) addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
+ 0x0042) addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
+ 0x0050) addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
+ esac
+}
+
+# ath11k
+pci_network_qca_ath11k()
+{
+
+ # awk '/DEVICE_ID[[:space:]]/ { gsub("[()]", "", $3); printf "%s)\taddpkg \"wifi-firmware-ath11k-kmod\"; return 1 ;;\n", tolower($3) }' pci.c
+ case "$1" in
+ 0x1101) addpkg "wifi-firmware-ath11k-kmod"; return 1 ;;
+ 0x1104) addpkg "wifi-firmware-ath11k-kmod"; return 1 ;;
+ 0x1103) addpkg "wifi-firmware-ath11k-kmod"; return 1 ;;
+ esac
+}
+
+# ath12k
+pci_network_qca_ath12k()
+{
+ # No ath12k firmware package yet
+ return 0
+
+ # awk '/DEVICE_ID[[:space:]]/ { gsub("[()]", "", $3); printf "%s)\taddpkg \"wifi-firmware-ath12k-kmod\"; return 1 ;;\n", tolower($3) }' pci.c
+ case "$1" in
+ 0x1109) addpkg "wifi-firmware-ath12k-kmod"; return 1 ;;
+ 0x1107) addpkg "wifi-firmware-ath12k-kmod"; return 1 ;;
+ esac
+}
+
+pci_network_qca()
+{
+
+ for _drv in ath10k ath11k; do
+ pci_network_qca_${_drv} "$1"
+ case $? in
+ 1) break ;;
+ esac
+ done
+}
diff --git a/usr.sbin/fwget/pci/pci_network_realtek b/usr.sbin/fwget/pci/pci_network_realtek
new file mode 100644
index 000000000000..795d9d4a6e0a
--- /dev/null
+++ b/usr.sbin/fwget/pci/pci_network_realtek
@@ -0,0 +1,65 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright 2023 Bjoern A. Zeeb
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+# rtw88
+pci_network_realtek_rtw88()
+{
+
+ # awk '/PCI_DEVICE\(PCI_VENDOR_ID_REALTEK,/ { gsub(").*", "", $2); printf "%s)\taddpkg \"wifi-firmware-rtw88-kmod\"; return 1 ;;\n", tolower($2) }' *.c
+ case "$1" in
+ 0xd723) addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
+ 0xb821) addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
+ 0xc821) addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
+ 0xb822) addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
+ 0xc822) addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
+ 0xc82f) addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
+ esac
+}
+
+# rtw89
+pci_network_realtek_rtw89()
+{
+
+ # awk '/PCI_DEVICE\(PCI_VENDOR_ID_REALTEK,/ { gsub(").*", "", $2); printf "%s)\taddpkg \"wifi-firmware-rtw89-kmod\"; return 1 ;;\n", tolower($2) }' *.c
+ case "$1" in
+ 0x8852) addpkg "wifi-firmware-rtw89-kmod"; return 1 ;;
+ 0xa85a) addpkg "wifi-firmware-rtw89-kmod"; return 1 ;;
+ 0xc852) addpkg "wifi-firmware-rtw89-kmod"; return 1 ;;
+ esac
+}
+
+
+pci_network_realtek()
+{
+
+ for _drv in rtw88 rtw89; do
+ pci_network_realtek_${_drv} "$1"
+ case $? in
+ 1) break ;;
+ esac
+ done
+}
diff --git a/usr.sbin/fwget/pci/pci_video_amd b/usr.sbin/fwget/pci/pci_video_amd
new file mode 100644
index 000000000000..5f89b12dce7c
--- /dev/null
+++ b/usr.sbin/fwget/pci/pci_video_amd
@@ -0,0 +1,154 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright 2023 Beckhoff Automation GmbH & Co. KG
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted providing that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+pci_video_amd()
+{
+ case "$1" in
+ 0x678*|0x679*)
+ addpkg "gpu-firmware-amd-kmod-tahiti"
+ ;;
+ 0x680*|0x681*)
+ addpkg "gpu-firmware-amd-kmod-pitcairn"
+ ;;
+ 0x660*|0x661*|0x662*|0x663*)
+ addpkg "gpu-firmware-amd-kmod-oland"
+ ;;
+ 0x682*|0x683*)
+ addpkg "gpu-firmware-amd-kmod-verde gpu-firmware-amd-kmod-si58"
+ ;;
+ 0x666*)
+ addpkg "gpu-firmware-amd-kmod-hainan"
+ ;;
+ 0x13*)
+ addpkg "gpu-firmware-amd-kmod-kaveri"
+ ;;
+ 0x664*|0x664*)
+ addpkg "gpu-firmware-amd-kmod-bonaire"
+ ;;
+ 0x67a*|0x67b*)
+ addpkg "gpu-firmware-amd-kmod-hawaii"
+ ;;
+ 0x983*)
+ addpkg "gpu-firmware-amd-kmod-kabini"
+ ;;
+ 0x985*)
+ addpkg "gpu-firmware-amd-kmod-mullins"
+ ;;
+ 0x690*)
+ addpkg "gpu-firmware-amd-kmod-topaz"
+ ;;
+ 0x692*|0x693*)
+ addpkg "gpu-firmware-amd-kmod-tonga"
+ ;;
+ 0x730*)
+ addpkg "gpu-firmware-amd-kmod-fiji"
+ ;;
+ 0x987*)
+ addpkg "gpu-firmware-amd-kmod-carrizo"
+ ;;
+ 0x98e4*)
+ addpkg "gpu-firmware-amd-kmod-stoney"
+ ;;
+ 0x67e*|0x67ff)
+ addpkg "gpu-firmware-amd-kmod-polaris11"
+ ;;
+ 0x67c*|0x67d*|0x6fdf)
+ addpkg "gpu-firmware-amd-kmod-polaris10"
+ ;;
+ 0x698*|0x699*)
+ addpkg "gpu-firmware-amd-kmod-polaris12"
+ ;;
+ 0x694*)
+ addpkg "gpu-firmware-amd-kmod-vegam"
+ ;;
+ 0x686*|0x687*)
+ addpkg "gpu-firmware-amd-kmod-vega10"
+ ;;
+ 0x69a*)
+ addpkg "gpu-firmware-amd-kmod-vega12"
+ ;;
+ 0x66a*)
+ addpkg "gpu-firmware-amd-kmod-vega20"
+ ;;
+ 0x15d*)
+ addpkg "gpu-firmware-amd-kmod-raven"
+ ;;
+ 0x738*|0x739*)
+ addpkg "gpu-firmware-amd-kmod-arcturus"
+ ;;
+ 0x731*)
+ addpkg "gpu-firmware-amd-kmod-navi10"
+ ;;
+ 0x734*)
+ addpkg "gpu-firmware-amd-kmod-navi14"
+ ;;
+ 0x15e7|0x1636|0x1638|0x164c)
+ addpkg "gpu-firmware-amd-kmod-renoir"
+ ;;
+ 0x736*)
+ addpkg "gpu-firmware-amd-kmod-navi12"
+ ;;
+ 0x73a*|0x73b*)
+ addpkg "gpu-firmware-amd-kmod-sienna-cichlid"
+ ;;
+ 0x163f)
+ addpkg "gpu-firmware-amd-kmod-vangogh"
+ ;;
+ 0x164d|0x1681)
+ addpkg "gpu-firmware-amd-kmod-yellow-carp"
+ ;;
+ 0x73c*|0x73d*)
+ addpkg "gpu-firmware-amd-kmod-navy-flounder"
+ ;;
+ 0x73e*|0x73f*)
+ addpkg "gpu-firmware-amd-kmod-dimgrey-cavefish"
+ ;;
+ 0x740*|0x741*)
+ addpkg "gpu-firmware-amd-kmod-aldebaran"
+ ;;
+ 0x13fe)
+ addpkg "gpu-firmware-amd-kmod-cyan-skillfish2"
+ ;;
+ 0x742*|0x743*)
+ addpkg "gpu-firmware-amd-kmod-beige-goby"
+ ;;
+ 0x744c)
+ addpkg "gpu-firmware-amd-kmod-dcn-3-2-0"
+ addpkg "gpu-firmware-amd-kmod-gc-11-0-0"
+ addpkg "gpu-firmware-amd-kmod-psp-13-0-0"
+ addpkg "gpu-firmware-amd-kmod-sdma-6-0-0"
+ addpkg "gpu-firmware-amd-kmod-smu-13-0-0"
+ addpkg "gpu-firmware-amd-kmod-vcn-4-0-0"
+ ;;
+ 0x15bf)
+ addpkg "gpu-firmware-amd-kmod-gc-11-0-1"
+ addpkg "gpu-firmware-amd-kmod-psp-13-0-4"
+ addpkg "gpu-firmware-amd-kmod-dcn-3-1-4"
+ addpkg "gpu-firmware-amd-kmod-sdma-6-0-1"
+ addpkg "gpu-firmware-amd-kmod-vcn-4-0-2"
+ ;;
+ esac
+}
diff --git a/usr.sbin/fwget/pci/pci_video_intel b/usr.sbin/fwget/pci/pci_video_intel
new file mode 100644
index 000000000000..3824c4a49ffb
--- /dev/null
+++ b/usr.sbin/fwget/pci/pci_video_intel
@@ -0,0 +1,78 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright 2023 Beckhoff Automation GmbH & Co. KG
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted providing that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+pci_video_intel()
+{
+ case "$1" in
+ # Skylake
+ 0x19*)
+ addpkg "gpu-firmware-intel-kmod-skylake"
+ ;;
+ # Broxton
+ 0x0a*|0x1a*|0x5a84|0x5a85)
+ addpkg "gpu-firmware-intel-kmod-broxton"
+ ;;
+ # Geminilake
+ 0x318*)
+ addpkg "gpu-firmware-intel-kmod-geminilake"
+ ;;
+ # Kabylake, Coffeelake and Cometlake
+ 0x59*|0x87*|0x9b*|0x3e*)
+ addpkg "gpu-firmware-intel-kmod-kabylake"
+ ;;
+ # Cannonlake
+ 0x5a*)
+ addpkg "gpu-firmware-intel-kmod-cannonlake"
+ ;;
+ # Icelake
+ 0x8a*)
+ addpkg "gpu-firmware-intel-kmod-icelake"
+ ;;
+ # Elkhartlake/Jasperlake
+ 0x45*|0x4e*)
+ addpkg "gpu-firmware-intel-kmod-elkhartlake"
+ ;;
+ # Tigerlake
+ 0x9a*)
+ addpkg "gpu-firmware-intel-kmod-tigerlake"
+ ;;
+ # Rocketlake (Uses tigerlake GuC/HuC firmware)
+ 0x4c*)
+ addpkg "gpu-firmware-intel-kmod-rocketlake gpu-firmware-intel-kmod-tigerlake"
+ ;;
+ # DG1
+ 0x49*)
+ addpkg "gpu-firmware-intel-kmod-dg1"
+ ;;
+ # Alderlake (Uses tigerlake GuC/HuC firmware)
+ 0x46*)
+ addpkg "gpu-firmware-intel-kmod-alderlake gpu-firmware-intel-kmod-tigerlake"
+ ;;
+ *)
+ log "No package found for device $1"
+ ;;
+ esac
+}
diff --git a/usr.sbin/getfmac/Makefile b/usr.sbin/getfmac/Makefile
index f9fa1b2e4462..d01845caf2ff 100644
--- a/usr.sbin/getfmac/Makefile
+++ b/usr.sbin/getfmac/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= getfmac
MAN= getfmac.8
diff --git a/usr.sbin/getfmac/Makefile.depend b/usr.sbin/getfmac/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/getfmac/Makefile.depend
+++ b/usr.sbin/getfmac/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/getfmac/getfmac.8 b/usr.sbin/getfmac/getfmac.8
index f8ebb314c3db..eb930e0044f9 100644
--- a/usr.sbin/getfmac/getfmac.8
+++ b/usr.sbin/getfmac/getfmac.8
@@ -31,8 +31,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 27, 2002
.Dt GETFMAC 8
.Os
diff --git a/usr.sbin/getfmac/getfmac.c b/usr.sbin/getfmac/getfmac.c
index cf6d042047a0..2d2addab66a9 100644
--- a/usr.sbin/getfmac/getfmac.c
+++ b/usr.sbin/getfmac/getfmac.c
@@ -32,8 +32,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/types.h>
#include <sys/mac.h>
diff --git a/usr.sbin/getpmac/Makefile b/usr.sbin/getpmac/Makefile
index 597472866526..b8da866b212e 100644
--- a/usr.sbin/getpmac/Makefile
+++ b/usr.sbin/getpmac/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= getpmac
MAN= getpmac.8
diff --git a/usr.sbin/getpmac/Makefile.depend b/usr.sbin/getpmac/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/getpmac/Makefile.depend
+++ b/usr.sbin/getpmac/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/getpmac/getpmac.8 b/usr.sbin/getpmac/getpmac.8
index 307c9628f890..263771a72a1f 100644
--- a/usr.sbin/getpmac/getpmac.8
+++ b/usr.sbin/getpmac/getpmac.8
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 14, 2003
.Dt GETPMAC 8
.Os
diff --git a/usr.sbin/getpmac/getpmac.c b/usr.sbin/getpmac/getpmac.c
index aef1341f92e4..d3a65a00fb30 100644
--- a/usr.sbin/getpmac/getpmac.c
+++ b/usr.sbin/getpmac/getpmac.c
@@ -32,8 +32,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/types.h>
#include <sys/mac.h>
diff --git a/usr.sbin/gpioctl/Makefile b/usr.sbin/gpioctl/Makefile
index 3c86c9909091..dead7a46e202 100644
--- a/usr.sbin/gpioctl/Makefile
+++ b/usr.sbin/gpioctl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= gpioctl
MAN= gpioctl.8
diff --git a/usr.sbin/gpioctl/Makefile.depend b/usr.sbin/gpioctl/Makefile.depend
index fd3b3da66347..bfb71b3132e7 100644
--- a/usr.sbin/gpioctl/Makefile.depend
+++ b/usr.sbin/gpioctl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/gpioctl/gpioctl.8 b/usr.sbin/gpioctl/gpioctl.8
index 1649df2e15d2..cf9292e4c6e6 100644
--- a/usr.sbin/gpioctl/gpioctl.8
+++ b/usr.sbin/gpioctl/gpioctl.8
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 6, 2018
.Dt GPIOCTL 8
.Os
diff --git a/usr.sbin/gpioctl/gpioctl.c b/usr.sbin/gpioctl/gpioctl.c
index 7adca26bbf28..86cbabb24f5c 100644
--- a/usr.sbin/gpioctl/gpioctl.c
+++ b/usr.sbin/gpioctl/gpioctl.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org>
* Copyright (c) 2014, Rui Paulo <rpaulo@FreeBSD.org>
@@ -30,8 +30,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <fcntl.h>
#include <getopt.h>
#include <paths.h>
diff --git a/usr.sbin/gssd/Makefile b/usr.sbin/gssd/Makefile
index d22a01597ced..9621363296b5 100644
--- a/usr.sbin/gssd/Makefile
+++ b/usr.sbin/gssd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/gssd/Makefile.depend b/usr.sbin/gssd/Makefile.depend
index 8b377d145a7a..b9cbaf33a636 100644
--- a/usr.sbin/gssd/Makefile.depend
+++ b/usr.sbin/gssd/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
@@ -8,12 +7,8 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
- lib/libcom_err \
lib/libcompiler_rt \
- lib/libcrypt \
lib/libgssapi \
- lib/libthr \
- secure/lib/libcrypto \
.include <dirdeps.mk>
diff --git a/usr.sbin/gssd/Makefile.depend.options b/usr.sbin/gssd/Makefile.depend.options
index 098025149aec..fa9c85522a73 100644
--- a/usr.sbin/gssd/Makefile.depend.options
+++ b/usr.sbin/gssd/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= KERBEROS_SUPPORT
diff --git a/usr.sbin/gssd/gssd.8 b/usr.sbin/gssd/gssd.8
index 10f5287ca0ed..4240bf28867d 100644
--- a/usr.sbin/gssd/gssd.8
+++ b/usr.sbin/gssd/gssd.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 10 2020
.Dt GSSD 8
.Os
diff --git a/usr.sbin/gssd/gssd.c b/usr.sbin/gssd/gssd.c
index 5589da37c195..1d543719b11c 100644
--- a/usr.sbin/gssd/gssd.c
+++ b/usr.sbin/gssd/gssd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Isilon Inc http://www.isilon.com/
* Authors: Doug Rabson <dfr@rabson.org>
@@ -27,14 +27,13 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/linker.h>
#include <sys/module.h>
#include <sys/queue.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <ctype.h>
#include <dirent.h>
@@ -43,6 +42,7 @@ __FBSDID("$FreeBSD$");
#ifndef WITHOUT_KERBEROS
#include <krb5.h>
#endif
+#include <netdb.h>
#include <pwd.h>
#include <signal.h>
#include <stdarg.h>
@@ -50,6 +50,8 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
#include <gssapi/gssapi.h>
#include <rpc/rpc.h>
#include <rpc/rpc_com.h>
@@ -112,8 +114,9 @@ main(int argc, char **argv)
* directly to us.
*/
struct sockaddr_un sun;
- int fd, oldmask, ch, debug;
+ int fd, oldmask, ch, debug, jailed;
SVCXPRT *xprt;
+ size_t jailed_size;
/*
* Initialize the credential cache file name substring and the
@@ -243,7 +246,27 @@ main(int argc, char **argv)
gss_next_id = 1;
gss_start_time = time(0);
- gssd_syscall(_PATH_GSSDSOCK);
+ if (gssd_syscall(_PATH_GSSDSOCK) < 0) {
+ jailed = 0;
+ if (errno == EPERM) {
+ jailed_size = sizeof(jailed);
+ sysctlbyname("security.jail.jailed", &jailed,
+ &jailed_size, NULL, 0);
+ }
+ if (debug_level == 0) {
+ if (jailed != 0)
+ syslog(LOG_ERR, "Cannot start gssd."
+ " allow.nfsd must be configured");
+ else
+ syslog(LOG_ERR, "Cannot start gssd");
+ exit(1);
+ }
+ if (jailed != 0)
+ err(1, "Cannot start gssd."
+ " allow.nfsd must be configured");
+ else
+ err(1, "Cannot start gssd");
+ }
svc_run();
gssd_syscall("");
@@ -604,6 +627,51 @@ gssd_import_name_1_svc(import_name_args *argp, import_name_res *result, struct s
return (TRUE);
}
+/*
+ * If the name is a numeric IP host address, do a DNS lookup on it and
+ * return the DNS name in a malloc'd string.
+ */
+static char *
+gssd_conv_ip_to_dns(int len, char *name)
+{
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
+ char *retcp;
+
+ retcp = NULL;
+ if (len > 0) {
+ retcp = mem_alloc(NI_MAXHOST);
+ memcpy(retcp, name, len);
+ retcp[len] = '\0';
+ if (inet_pton(AF_INET, retcp, &sin.sin_addr) != 0) {
+ sin.sin_family = AF_INET;
+ sin.sin_len = sizeof(sin);
+ sin.sin_port = 0;
+ if (getnameinfo((struct sockaddr *)&sin,
+ sizeof(sin), retcp, NI_MAXHOST,
+ NULL, 0, NI_NAMEREQD) != 0) {
+ mem_free(retcp, NI_MAXHOST);
+ return (NULL);
+ }
+ } else if (inet_pton(AF_INET6, retcp, &sin6.sin6_addr) != 0) {
+ sin6.sin6_family = AF_INET6;
+ sin6.sin6_len = sizeof(sin6);
+ sin6.sin6_port = 0;
+ if (getnameinfo((struct sockaddr *)&sin6,
+ sizeof(sin6), retcp, NI_MAXHOST,
+ NULL, 0, NI_NAMEREQD) != 0) {
+ mem_free(retcp, NI_MAXHOST);
+ return (NULL);
+ }
+ } else {
+ mem_free(retcp, NI_MAXHOST);
+ return (NULL);
+ }
+ gssd_verbose_out("gssd_conv_ip_to_dns: %s\n", retcp);
+ }
+ return (retcp);
+}
+
bool_t
gssd_canonicalize_name_1_svc(canonicalize_name_args *argp, canonicalize_name_res *result, struct svc_req *rqstp)
{
@@ -913,6 +981,25 @@ gssd_display_status_1_svc(display_status_args *argp, display_status_res *result,
return (TRUE);
}
+bool_t
+gssd_ip_to_dns_1_svc(ip_to_dns_args *argp, ip_to_dns_res *result, struct svc_req *rqstp)
+{
+ char *host;
+
+ memset(result, 0, sizeof(*result));
+ /* Check to see if the name is actually an IP address. */
+ host = gssd_conv_ip_to_dns(argp->ip_addr.ip_addr_len,
+ argp->ip_addr.ip_addr_val);
+ if (host != NULL) {
+ result->major_status = GSS_S_COMPLETE;
+ result->dns_name.dns_name_len = strlen(host);
+ result->dns_name.dns_name_val = host;
+ return (TRUE);
+ }
+ result->major_status = GSS_S_FAILURE;
+ return (TRUE);
+}
+
int
gssd_1_freeresult(SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)
{
diff --git a/usr.sbin/gstat/Makefile b/usr.sbin/gstat/Makefile
index fcf90fa3b130..033ebb157f61 100644
--- a/usr.sbin/gstat/Makefile
+++ b/usr.sbin/gstat/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= gstat
MAN= gstat.8
diff --git a/usr.sbin/gstat/Makefile.depend b/usr.sbin/gstat/Makefile.depend
index 7a3e02950915..dbff07bc2e7a 100644
--- a/usr.sbin/gstat/Makefile.depend
+++ b/usr.sbin/gstat/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
@@ -10,12 +8,10 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libdevstat \
lib/libedit \
- lib/libelf \
- lib/libexpat \
lib/libgeom \
lib/libkvm \
- lib/libsbuf \
- lib/ncurses/ncursesw \
+ lib/ncurses/ncurses \
+ lib/ncurses/tinfo \
.include <dirdeps.mk>
diff --git a/usr.sbin/gstat/gstat.8 b/usr.sbin/gstat/gstat.8
index de1a2b21bc88..d328d26be23c 100644
--- a/usr.sbin/gstat/gstat.8
+++ b/usr.sbin/gstat/gstat.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 1, 2021
.Dt GSTAT 8
.Os
diff --git a/usr.sbin/gstat/gstat.c b/usr.sbin/gstat/gstat.c
index 65388c3002ff..b99b750eb253 100644
--- a/usr.sbin/gstat/gstat.c
+++ b/usr.sbin/gstat/gstat.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-3-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 2003 Poul-Henning Kamp
* All rights reserved.
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
@@ -66,7 +64,7 @@ static int flag_I = 1000000;
printw(__VA_ARGS__); \
} while(0)
-static void usage(void);
+static void usage(void) __dead2;
static const char*
el_prompt(void)
diff --git a/usr.sbin/hyperv/Makefile b/usr.sbin/hyperv/Makefile
index d42817f4a747..f5a4cbd4810a 100644
--- a/usr.sbin/hyperv/Makefile
+++ b/usr.sbin/hyperv/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <bsd.own.mk>
diff --git a/usr.sbin/hyperv/Makefile.inc b/usr.sbin/hyperv/Makefile.inc
index edb012926dd1..ceaf3870d9bd 100644
--- a/usr.sbin/hyperv/Makefile.inc
+++ b/usr.sbin/hyperv/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
CFLAGS.gcc+= -Wno-uninitialized
.include "../Makefile.inc"
diff --git a/usr.sbin/hyperv/tools/Makefile.inc b/usr.sbin/hyperv/tools/Makefile.inc
index 7e09f324e3e4..1dc11073a2f3 100644
--- a/usr.sbin/hyperv/tools/Makefile.inc
+++ b/usr.sbin/hyperv/tools/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
CFLAGS.gcc+= -Wno-uninitialized
.include "../../Makefile.inc"
diff --git a/usr.sbin/hyperv/tools/kvp/Makefile b/usr.sbin/hyperv/tools/kvp/Makefile
index ca87371881fb..4fb5f68ce2b1 100644
--- a/usr.sbin/hyperv/tools/kvp/Makefile
+++ b/usr.sbin/hyperv/tools/kvp/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <bsd.own.mk>
diff --git a/usr.sbin/hyperv/tools/kvp/Makefile.depend b/usr.sbin/hyperv/tools/kvp/Makefile.depend
index d5ed563ecfc8..344a5d0e9310 100644
--- a/usr.sbin/hyperv/tools/kvp/Makefile.depend
+++ b/usr.sbin/hyperv/tools/kvp/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/hyperv/tools/vss/Makefile b/usr.sbin/hyperv/tools/vss/Makefile
index d6fb6a3ef482..03bd6eccd54f 100644
--- a/usr.sbin/hyperv/tools/vss/Makefile
+++ b/usr.sbin/hyperv/tools/vss/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
DIRDEPS = lib/libc
.include <bsd.own.mk>
diff --git a/usr.sbin/hyperv/tools/vss/Makefile.depend b/usr.sbin/hyperv/tools/vss/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/hyperv/tools/vss/Makefile.depend
+++ b/usr.sbin/hyperv/tools/vss/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/i2c/Makefile b/usr.sbin/i2c/Makefile
index 681f4b7b89d2..37bff6c42314 100644
--- a/usr.sbin/i2c/Makefile
+++ b/usr.sbin/i2c/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= i2c
MAN= i2c.8
diff --git a/usr.sbin/i2c/Makefile.depend b/usr.sbin/i2c/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/i2c/Makefile.depend
+++ b/usr.sbin/i2c/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/i2c/i2c.8 b/usr.sbin/i2c/i2c.8
index 7c995f5743a4..95aba8e5d105 100644
--- a/usr.sbin/i2c/i2c.8
+++ b/usr.sbin/i2c/i2c.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 22, 2019
.Dt I2C 8
.Os
@@ -130,7 +128,7 @@ specified with
.Fl o
to the slave.
Zero means that the offset is ignored and not passed to the slave at all.
-The endianess defaults to little-endian.
+The endianness defaults to little-endian.
.El
.Sh INTERPRETED MODE
When started with
diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c
index 2ab7c55772de..12155f1a0663 100644
--- a/usr.sbin/i2c/i2c.c
+++ b/usr.sbin/i2c/i2c.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2008-2009 Semihalf, Michal Hajduk and Bartlomiej Sieka
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <ctype.h>
#include <err.h>
diff --git a/usr.sbin/ifmcstat/Makefile b/usr.sbin/ifmcstat/Makefile
index adf1304f3dda..faf6908e9204 100644
--- a/usr.sbin/ifmcstat/Makefile
+++ b/usr.sbin/ifmcstat/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ifmcstat/Makefile.depend b/usr.sbin/ifmcstat/Makefile.depend
index d5ed563ecfc8..344a5d0e9310 100644
--- a/usr.sbin/ifmcstat/Makefile.depend
+++ b/usr.sbin/ifmcstat/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/ifmcstat/ifmcstat.8 b/usr.sbin/ifmcstat/ifmcstat.8
index 70b9791b8a6b..aa148e802ea7 100644
--- a/usr.sbin/ifmcstat/ifmcstat.8
+++ b/usr.sbin/ifmcstat/ifmcstat.8
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 27, 2009
.Dt IFMCSTAT 8
.Os
diff --git a/usr.sbin/ifmcstat/ifmcstat.c b/usr.sbin/ifmcstat/ifmcstat.c
index 81befd3d6af1..503c1000d82d 100644
--- a/usr.sbin/ifmcstat/ifmcstat.c
+++ b/usr.sbin/ifmcstat/ifmcstat.c
@@ -32,9 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/usr.sbin/ifmcstat/printb.c b/usr.sbin/ifmcstat/printb.c
index 9481a0dc1bff..6054be88a2be 100644
--- a/usr.sbin/ifmcstat/printb.c
+++ b/usr.sbin/ifmcstat/printb.c
@@ -30,8 +30,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <stdio.h>
diff --git a/usr.sbin/inetd/Makefile b/usr.sbin/inetd/Makefile
index b8f216970d7f..c62efc8dabb0 100644
--- a/usr.sbin/inetd/Makefile
+++ b/usr.sbin/inetd/Makefile
@@ -1,10 +1,9 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
.include <src.opts.mk>
CONFS= inetd.conf
PROG= inetd
+PACKAGE= inetd
MAN= inetd.8
MLINKS= inetd.8 inetd.conf.5
SRCS= inetd.c builtins.c
diff --git a/usr.sbin/inetd/Makefile.depend b/usr.sbin/inetd/Makefile.depend
index 69c4141352e1..3cbe5b8b5fd4 100644
--- a/usr.sbin/inetd/Makefile.depend
+++ b/usr.sbin/inetd/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/inetd/Makefile.depend.options b/usr.sbin/inetd/Makefile.depend.options
index a62a5692d70a..fbc21670804e 100644
--- a/usr.sbin/inetd/Makefile.depend.options
+++ b/usr.sbin/inetd/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= TCP_WRAPPERS
diff --git a/usr.sbin/inetd/builtins.c b/usr.sbin/inetd/builtins.c
index a2302ee62eef..9609faf0b104 100644
--- a/usr.sbin/inetd/builtins.c
+++ b/usr.sbin/inetd/builtins.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1983, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/filio.h>
#include <sys/ioccom.h>
#include <sys/param.h>
@@ -315,8 +313,8 @@ echo_stream(int s, struct servtab *sep)
/* RFC 1413 says the following are the only errors you can return. */
#define ID_INVALID "INVALID-PORT" /* Port number improperly specified. */
-#define ID_NOUSER "NO-USER" /* Port not in use/not identifable. */
-#define ID_HIDDEN "HIDDEN-USER" /* Hiden at user's request. */
+#define ID_NOUSER "NO-USER" /* Port not in use/not identifiable. */
+#define ID_HIDDEN "HIDDEN-USER" /* Hidden at user's request. */
#define ID_UNKNOWN "UNKNOWN-ERROR" /* Everything else. */
/* Generic ident_stream error-sending func */
@@ -407,7 +405,7 @@ ident_stream(int s, struct servtab *sep)
* random number only when necessary.
*
* 32 bits from arc4random corresponds to
- * about 6 base-36 digits, so we reseed evey 6.
+ * about 6 base-36 digits, so we reseed every 6.
*/
for (i = 0; i < sizeof(idbuf) - 1; i++) {
static const char *const base36 =
diff --git a/usr.sbin/inetd/inetd.8 b/usr.sbin/inetd/inetd.8
index 6e6af3ec68cb..86feb0ba466e 100644
--- a/usr.sbin/inetd/inetd.8
+++ b/usr.sbin/inetd/inetd.8
@@ -25,10 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)inetd.8 8.3 (Berkeley) 4/13/94
-.\" $FreeBSD$
-.\"
-.Dd December 6, 2021
+.Dd September 29, 2022
.Dt INETD 8
.Os
.Sh NAME
@@ -964,7 +961,7 @@ database.
.Xr prometheus_sysctl_exporter 8 ,
.Xr smbd 8 Pq Pa ports/net/samba412 ,
.Xr talkd 8 ,
-.Xr telnetd 8 ,
+.Xr telnetd 8 Pq Pa ports/net/freebsd-telnetd ,
.Xr tftpd 8 ,
.Xr uucpd 8 Pq Pa ports/net/freebsd-uucp
.Rs
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c
index 848714bd395a..2ebc9fe02a81 100644
--- a/usr.sbin/inetd/inetd.c
+++ b/usr.sbin/inetd/inetd.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1983, 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[] = "@(#)from: inetd.c 8.4 (Berkeley) 4/13/94";
-#endif
-#endif /* not lint */
-
/*
* Inetd - Internet super-server
*
diff --git a/usr.sbin/inetd/inetd.conf b/usr.sbin/inetd/inetd.conf
index 09dfbab66496..14e5fec5d1bf 100644
--- a/usr.sbin/inetd/inetd.conf
+++ b/usr.sbin/inetd/inetd.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Internet server configuration database
#
@@ -10,8 +9,8 @@
#ftp stream tcp6 nowait root /usr/libexec/ftpd ftpd -l
#ssh stream tcp nowait root /usr/sbin/sshd sshd -i -4
#ssh stream tcp6 nowait root /usr/sbin/sshd sshd -i -6
-#telnet stream tcp nowait root /usr/libexec/telnetd telnetd
-#telnet stream tcp6 nowait root /usr/libexec/telnetd telnetd
+#telnet stream tcp nowait root /usr/local/libexec/telnetd telnetd
+#telnet stream tcp6 nowait root /usr/local/libexec/telnetd telnetd
#shell stream tcp nowait root /usr/local/sbin/rshd rshd
#shell stream tcp6 nowait root /usr/local/sbin/rshd rshd
#login stream tcp nowait root /usr/local/sbin/rlogind rlogind
diff --git a/usr.sbin/inetd/inetd.h b/usr.sbin/inetd/inetd.h
index a7dc89ad7015..685becf8a7f0 100644
--- a/usr.sbin/inetd/inetd.h
+++ b/usr.sbin/inetd/inetd.h
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <sys/time.h>
diff --git a/usr.sbin/inetd/pathnames.h b/usr.sbin/inetd/pathnames.h
index d725cad4c624..0c103c24fa6e 100644
--- a/usr.sbin/inetd/pathnames.h
+++ b/usr.sbin/inetd/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/6/93
- * $FreeBSD$
*/
#include <paths.h>
diff --git a/usr.sbin/iostat/Makefile b/usr.sbin/iostat/Makefile
index 4d74fe163d0b..fa9640267d3d 100644
--- a/usr.sbin/iostat/Makefile
+++ b/usr.sbin/iostat/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= iostat
MAN= iostat.8
diff --git a/usr.sbin/iostat/Makefile.depend b/usr.sbin/iostat/Makefile.depend
index 70e72f3ef71d..3b8b50f9f6bf 100644
--- a/usr.sbin/iostat/Makefile.depend
+++ b/usr.sbin/iostat/Makefile.depend
@@ -1,15 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libdevstat \
- lib/libelf \
lib/libkvm \
lib/msun \
diff --git a/usr.sbin/iostat/iostat.8 b/usr.sbin/iostat/iostat.8
index 323e77ef6447..11f0ef6fbeb6 100644
--- a/usr.sbin/iostat/iostat.8
+++ b/usr.sbin/iostat/iostat.8
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -54,9 +52,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)iostat.8 8.1 (Berkeley) 6/6/93
-.\"
-.Dd May 22, 2015
+.Dd November 26, 2023
.Dt IOSTAT 8
.Os
.Sh NAME
@@ -66,7 +62,7 @@
statistics
.Sh SYNOPSIS
.Nm
-.Op Fl CdhIKoTxz?\&
+.Op Fl CdhIKoTxz
.Op Fl c Ar count
.Op Fl M Ar core
.Op Fl n Ar devs
@@ -85,25 +81,18 @@ The
utility displays kernel
.Tn I/O
statistics on terminal, device and cpu operations.
-The first statistics that are printed are averaged over the system uptime.
+The first statistics that are printed are averaged over the system uptime
+(unless
+.Fl I
+is specified).
+Any references to repetitions in this man page implicitly include the first
+statistics output.
To get information about the current activity, a suitable wait time should
be specified, so that the subsequent sets of printed statistics will be
averaged over that time.
.Pp
The options are as follows:
.Bl -tag -width flag
-.It Fl c
-Repeat the display
-.Ar count
-times.
-If no repeat
-.Ar count
-is specified, the default depends on whether
-.Fl w
-is specified.
-With
-.Fl w
-the default repeat count is infinity, otherwise it is 1.
.It Fl C
Display CPU statistics.
This is on by default, unless
@@ -111,6 +100,15 @@ This is on by default, unless
or
.Fl x
is specified.
+.It Fl c
+Repeat the display
+.Ar count
+times.
+If
+.Fl c
+is not specified and a wait interval is specified,
+the default repeat count is infinity.
+If no wait interval is specified, the default repeat count is 1.
.It Fl d
Display only device statistics.
If this flag is turned on, only device statistics will be displayed, unless
@@ -132,24 +130,27 @@ per measurement cycle.
Display total statistics for a given time period, rather than average
statistics for each second during that time period.
.It Fl K
-In the blocks transferred display (-o), display block count in kilobytes rather
-then the device native block size.
+In the old-style blocks transferred display
+.Po Fl I
+and
+.Fl o Pc ,
+display block count in kilobytes rather than the device native block size.
.It Fl M
Extract values associated with the name list from the specified core
instead of the default
.Dq Pa /dev/kmem .
+.It Fl N
+Extract the name list from the specified system instead of the default
+.Dq Pa /boot/kernel/kernel .
.It Fl n
Display up to
.Ar devs
number of devices.
The
.Nm
-utility will display fewer devices if there are not
+utility will display fewer devices if there are less than
.Ar devs
devices present.
-.It Fl N
-Extract the name list from the specified system instead of the default
-.Dq Pa /boot/kernel/kernel .
.It Fl o
Display old-style
.Nm
@@ -160,6 +161,13 @@ If
.Fl I
is specified, total blocks/sectors, total transfers, and
milliseconds per seek are displayed.
+.It Fl T
+Display TTY statistics.
+This is on by default, unless
+.Fl d
+or
+.Fl x
+is specified.
.It Fl t
Specify which types of devices to display.
There are three different categories of devices:
@@ -201,6 +209,8 @@ Floppy devices
Integrated Drive Electronics devices
.It SCSI
Small Computer System Interface devices
+.It NVME
+NVM Express Interface devices
.It other
Any other device interface
.El
@@ -215,7 +225,7 @@ Passthrough devices
The user must specify at least one device type, and may specify at most
one device type from each category.
Multiple device types in a single device type statement must be separated by
-commas.
+commas and are ANDed together.
.Pp
Any number of
.Fl t
@@ -229,21 +239,16 @@ Any device that fully matches any
argument will be included in the
.Nm
output, up to the number of devices that can be displayed in
-80 columns, or the maximum number of devices specified by the user.
-.It Fl T
-Display TTY statistics.
-This is on by default, unless
-.Fl d
-or
-.Fl x
-is specified.
+80 columns, or the maximum number of devices
+.Pq Fl n
+specified by the user.
.It Fl w
Pause
.Ar wait
seconds between each display.
-If no
-.Ar wait
-interval is specified, the default is 1 second.
+If
+.Fl w
+is not specified, the default interval is 1 second.
.Pp
The
.Nm
@@ -269,8 +274,6 @@ is also specified to enable the display of CPU or TTY statistics.
If
.Fl x
is specified, omit lines for devices with no activity.
-.It Fl ?\&
-Display a usage statement and exit.
.El
.Pp
The
@@ -520,3 +523,24 @@ The use of
as a debugging tool for crash dumps is probably limited because there is
currently no way to get statistics that only cover the time immediately before
the crash.
+.Pp
+Each
+.Ar drives
+argument is passed to
+.Fn isdigit .
+If
+.Fn isdigit
+returns true,
+.Nm
+switches into an undocumented traditional syntax and subsequent arguments,
+if any, will not be interpreted as drive names.
+This behavior collides with the one documented in this man page and prevents
+specifying drive names starting with a number.
+E.g., the following
+.Bd -literal -offset indent
+iostat ada0 ada1 2 3 cd0
+.Ed
+.Pp
+This document's use of
+.Dq device type
+is misleading.
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index 9140bf10ef07..ec18f4fd35b3 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -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$
*/
/*
* Parts of this program are derived from the original FreeBSD iostat
@@ -149,7 +147,7 @@ static int dflag = 0, Iflag = 0, Cflag = 0, Tflag = 0, oflag = 0, Kflag = 0;
static int xflag = 0, zflag = 0;
/* local function declarations */
-static void usage(void);
+static void usage(void) __dead2;
static void needhdr(int signo);
static void needresize(int signo);
static void needreturn(int signo);
@@ -170,16 +168,17 @@ usage(void)
* This isn't mentioned in the man page, or the usage statement,
* but it is supported.
*/
- fprintf(stderr, "usage: iostat [-CdhIKoTxz?] [-c count] [-M core]"
+ fprintf(stderr, "usage: iostat [-CdhIKoTxz] [-c count] [-M core]"
" [-n devs] [-N system]\n"
"\t [-t type,if,pass] [-w wait] [drives]\n");
+ exit(1);
}
int
main(int argc, char **argv)
{
int c, i;
- int tflag = 0, hflag = 0, cflag = 0, wflag = 0, nflag = 0;
+ int hflag = 0, cflag = 0, wflag = 0, nflag = 0;
int count = 0, waittime = 0;
char *memf = NULL, *nlistf = NULL;
struct devstat_match *matches;
@@ -199,17 +198,17 @@ main(int argc, char **argv)
matches = NULL;
maxshowdevs = 3;
- while ((c = getopt(argc, argv, "c:CdhIKM:n:N:ot:Tw:xz?")) != -1) {
- switch(c) {
+ while ((c = getopt(argc, argv, "Cc:dhIKM:N:n:oTt:w:xz")) != -1) {
+ switch (c) {
+ case 'C':
+ Cflag++;
+ break;
case 'c':
cflag++;
count = atoi(optarg);
if (count < 1)
errx(1, "count %d is < 1", count);
break;
- case 'C':
- Cflag++;
- break;
case 'd':
dflag++;
break;
@@ -225,6 +224,9 @@ main(int argc, char **argv)
case 'M':
memf = optarg;
break;
+ case 'N':
+ nlistf = optarg;
+ break;
case 'n':
nflag++;
maxshowdevs = atoi(optarg);
@@ -232,21 +234,17 @@ main(int argc, char **argv)
errx(1, "number of devices %d is < 0",
maxshowdevs);
break;
- case 'N':
- nlistf = optarg;
- break;
case 'o':
oflag++;
break;
+ case 'T':
+ Tflag++;
+ break;
case 't':
- tflag++;
if (devstat_buildmatch(optarg, &matches,
&num_matches) != 0)
errx(1, "%s", devstat_errbuf);
break;
- case 'T':
- Tflag++;
- break;
case 'w':
wflag++;
f = atof(optarg);
@@ -262,8 +260,6 @@ main(int argc, char **argv)
break;
default:
usage();
- exit(1);
- break;
}
}
@@ -616,7 +612,7 @@ main(int argc, char **argv)
}
if (xflag == 0 && Tflag > 0)
- printf("%4.0Lf %5.0Lf", cur.tk_nin / etime,
+ printf("%4.0Lf %5.0Lf ", cur.tk_nin / etime,
cur.tk_nout / etime);
devstats(hflag, etime, havelast);
@@ -735,7 +731,7 @@ phdr(void)
return;
if (Tflag > 0)
- (void)printf(" tty");
+ (void)printf(" tty ");
for (i = 0, printed=0;(i < num_devices) && (printed < maxshowdevs);i++){
int di;
if ((dev_select[i].selected != 0)
@@ -757,7 +753,7 @@ phdr(void)
(void)printf("\n");
if (Tflag > 0)
- (void)printf(" tin tout");
+ (void)printf(" tin tout ");
for (i=0, printed = 0;(i < num_devices) && (printed < maxshowdevs);i++){
if ((dev_select[i].selected != 0)
@@ -769,9 +765,9 @@ phdr(void)
(void)printf(" blk xfr msps ");
} else {
if (Iflag == 0)
- printf(" KB/t tps MB/s ");
+ printf("KB/t tps MB/s ");
else
- printf(" KB/t xfrs MB ");
+ printf("KB/t xfrs MB ");
}
printed++;
}
@@ -938,26 +934,30 @@ devstats(int perf_select, long double etime, int havelast)
msdig,
ms_per_transaction);
else
- printf("%4.1" PRIu64 "%4.1" PRIu64 "%5.*Lf ",
+ printf("%4" PRIu64 "%4" PRIu64 "%5.*Lf ",
total_blocks,
total_transfers,
msdig,
ms_per_transaction);
} else {
if (Iflag == 0)
- printf(" %4.*Lf %4.0Lf %5.*Lf ",
+ printf("%4.*Lf %5.0Lf %5.*Lf ",
kb_per_transfer >= 100 ? 0 : 1,
kb_per_transfer,
transfers_per_second,
- mb_per_second >= 1000 ? 0 : 1,
+ mb_per_second >= 1000 ? 0 :
+ (total_mb >= 100 ? 1 : 2),
mb_per_second);
else {
total_mb = total_bytes;
total_mb /= 1024 * 1024;
- printf(" %4.1Lf %4.1" PRIu64 " %5.2Lf ",
+ printf("%4.*Lf %5" PRIu64 " %5.*Lf ",
+ kb_per_transfer >= 100 ? 0 : 1,
kb_per_transfer,
total_transfers,
+ total_mb >= 1000 ? 0 :
+ (total_mb >= 100 ? 1 : 2),
total_mb);
}
}
diff --git a/usr.sbin/iovctl/Makefile b/usr.sbin/iovctl/Makefile
index 42fca7dab71c..599fc41785e0 100644
--- a/usr.sbin/iovctl/Makefile
+++ b/usr.sbin/iovctl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= iovctl
SRCS= iovctl.c parse.c validate.c
diff --git a/usr.sbin/iovctl/Makefile.depend b/usr.sbin/iovctl/Makefile.depend
index 2082bfb7951c..552b40d7838b 100644
--- a/usr.sbin/iovctl/Makefile.depend
+++ b/usr.sbin/iovctl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/iovctl/iovctl.8 b/usr.sbin/iovctl/iovctl.8
index f22fdab61464..5c7b01c249a0 100644
--- a/usr.sbin/iovctl/iovctl.8
+++ b/usr.sbin/iovctl/iovctl.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 31, 2020
.Dt IOVCTL 8
.Os
diff --git a/usr.sbin/iovctl/iovctl.c b/usr.sbin/iovctl/iovctl.c
index 0350c732f671..0110751082ec 100644
--- a/usr.sbin/iovctl/iovctl.c
+++ b/usr.sbin/iovctl/iovctl.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/iov.h>
#include <sys/dnv.h>
diff --git a/usr.sbin/iovctl/iovctl.conf.5 b/usr.sbin/iovctl/iovctl.conf.5
index a9630f3b3b13..a7eb6c2077ee 100644
--- a/usr.sbin/iovctl/iovctl.conf.5
+++ b/usr.sbin/iovctl/iovctl.conf.5
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 29, 2020
.Dt IOVCTL.CONF 5
.Os
diff --git a/usr.sbin/iovctl/iovctl.h b/usr.sbin/iovctl/iovctl.h
index 20b2da011c91..5a39092395ca 100644
--- a/usr.sbin/iovctl/iovctl.h
+++ b/usr.sbin/iovctl/iovctl.h
@@ -22,8 +22,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 IOVCTL_H
diff --git a/usr.sbin/iovctl/parse.c b/usr.sbin/iovctl/parse.c
index 347b35fb417a..b1aad7d7ddd6 100644
--- a/usr.sbin/iovctl/parse.c
+++ b/usr.sbin/iovctl/parse.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/iov.h>
#include <sys/nv.h>
@@ -164,8 +161,8 @@ add_unicast_mac_config(const char *key, const ucl_object_t *obj, nvlist_t *confi
}
/*
- * Validates that the given configuation value has the right type as specified
- * in the schema, and then adds the value to the configuation node.
+ * Validates that the given configuration value has the right type as specified
+ * in the schema, and then adds the value to the configuration node.
*/
static void
add_config(const char *key, const ucl_object_t *obj, nvlist_t *config,
diff --git a/usr.sbin/iovctl/validate.c b/usr.sbin/iovctl/validate.c
index 6658a8c0c281..cd187291c9c7 100644
--- a/usr.sbin/iovctl/validate.c
+++ b/usr.sbin/iovctl/validate.c
@@ -24,9 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/iov.h>
#include <sys/dnv.h>
diff --git a/usr.sbin/ip6addrctl/Makefile b/usr.sbin/ip6addrctl/Makefile
index f484461b3ccb..6fc277d39e63 100644
--- a/usr.sbin/ip6addrctl/Makefile
+++ b/usr.sbin/ip6addrctl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= runtime
PROG= ip6addrctl
diff --git a/usr.sbin/ip6addrctl/Makefile.depend b/usr.sbin/ip6addrctl/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/ip6addrctl/Makefile.depend
+++ b/usr.sbin/ip6addrctl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/ip6addrctl/ip6addrctl.8 b/usr.sbin/ip6addrctl/ip6addrctl.8
index 59154d447b1e..f50da59aa2bb 100644
--- a/usr.sbin/ip6addrctl/ip6addrctl.8
+++ b/usr.sbin/ip6addrctl/ip6addrctl.8
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd September 25, 2001
.Dt IP6ADDRCTL 8
.Os
diff --git a/usr.sbin/ip6addrctl/ip6addrctl.c b/usr.sbin/ip6addrctl/ip6addrctl.c
index 06d527dac2ce..13413fefa8ce 100644
--- a/usr.sbin/ip6addrctl/ip6addrctl.c
+++ b/usr.sbin/ip6addrctl/ip6addrctl.c
@@ -29,8 +29,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/types.h>
@@ -62,7 +60,7 @@ struct policyqueue {
TAILQ_HEAD(policyhead, policyqueue);
static struct policyhead policyhead;
-static void usage(void);
+static void usage(void) __dead2;
static void get_policy(void);
static void dump_policy(void);
static int mask2plen(struct sockaddr_in6 *);
diff --git a/usr.sbin/ip6addrctl/ip6addrctl.conf.sample b/usr.sbin/ip6addrctl/ip6addrctl.conf.sample
index a2b3759de5f7..edcf77553f14 100644
--- a/usr.sbin/ip6addrctl/ip6addrctl.conf.sample
+++ b/usr.sbin/ip6addrctl/ip6addrctl.conf.sample
@@ -1,7 +1,6 @@
# default policy table based on RFC 3484.
# usage: ip6addrctl install path_to_this_file
#
-# $FreeBSD$
#
#Format:
#Prefix Precedence Label
diff --git a/usr.sbin/ipfwpcap/Makefile b/usr.sbin/ipfwpcap/Makefile
index dbdd0cae2a56..e5a59fc951de 100644
--- a/usr.sbin/ipfwpcap/Makefile
+++ b/usr.sbin/ipfwpcap/Makefile
@@ -1,7 +1,6 @@
#
# From: Id: Makefile,v 1.2 2004/01/15 16:20:56 pkern Exp
#
-# $FreeBSD$
#
PROG= ipfwpcap
diff --git a/usr.sbin/ipfwpcap/Makefile.depend b/usr.sbin/ipfwpcap/Makefile.depend
index 893e74eb908c..cf48f0c1690f 100644
--- a/usr.sbin/ipfwpcap/Makefile.depend
+++ b/usr.sbin/ipfwpcap/Makefile.depend
@@ -1,9 +1,8 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
+ include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
diff --git a/usr.sbin/ipfwpcap/ipfwpcap.8 b/usr.sbin/ipfwpcap/ipfwpcap.8
index a426ee084824..30a98af5aa66 100644
--- a/usr.sbin/ipfwpcap/ipfwpcap.8
+++ b/usr.sbin/ipfwpcap/ipfwpcap.8
@@ -21,8 +21,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 22, 2006
.Dt IPFWPCAP 8
.Os
diff --git a/usr.sbin/ipfwpcap/ipfwpcap.c b/usr.sbin/ipfwpcap/ipfwpcap.c
index 96ee47e836a6..a9cead99bd07 100644
--- a/usr.sbin/ipfwpcap/ipfwpcap.c
+++ b/usr.sbin/ipfwpcap/ipfwpcap.c
@@ -20,8 +20,6 @@
* accept no liability for this software.
*
* From: Header: /local/src/local.lib/SRC/ipfwpcap/RCS/ipfwpcap.c,v 1.4 2004/01/15 16:19:07 pkern Exp
- *
- * $FreeBSD$
*/
#include <stdio.h>
@@ -202,7 +200,7 @@ main(int ac, char *av[])
if (debug) fprintf(stderr, "bind to %d.\ndump to '%s'.\n", portnum, dumpf);
- if ((r = socket(PF_INET, SOCK_RAW, IPPROTO_DIVERT)) == -1) {
+ if ((r = socket(PF_DIVERT, SOCK_RAW, 0)) == -1) {
perror("socket(DIVERT)");
exit(2);
}
diff --git a/usr.sbin/iscsid/Makefile b/usr.sbin/iscsid/Makefile
index f9694866b7f6..a4fbcb368650 100644
--- a/usr.sbin/iscsid/Makefile
+++ b/usr.sbin/iscsid/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= iscsi
PROG= iscsid
diff --git a/usr.sbin/iscsid/Makefile.depend b/usr.sbin/iscsid/Makefile.depend
index aa7d77115eb0..905e1b1ff555 100644
--- a/usr.sbin/iscsid/Makefile.depend
+++ b/usr.sbin/iscsid/Makefile.depend
@@ -1,14 +1,14 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
- include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
+ lib/libcasper/libcasper \
lib/libcompiler_rt \
+ lib/libiscsiutil \
lib/libmd \
lib/libutil \
diff --git a/usr.sbin/iscsid/discovery.c b/usr.sbin/iscsid/discovery.c
index 942d4a4bc408..c9bbf5504554 100644
--- a/usr.sbin/iscsid/discovery.c
+++ b/usr.sbin/iscsid/discovery.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 The FreeBSD Foundation
*
@@ -29,9 +29,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdbool.h>
diff --git a/usr.sbin/iscsid/iscsid.8 b/usr.sbin/iscsid/iscsid.8
index 793e05e91bf1..af355b57c8f4 100644
--- a/usr.sbin/iscsid/iscsid.8
+++ b/usr.sbin/iscsid/iscsid.8
@@ -24,8 +24,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 28, 2017
.Dt ISCSID 8
.Os
diff --git a/usr.sbin/iscsid/iscsid.c b/usr.sbin/iscsid/iscsid.c
index c81692948c1a..7230a8bda6fe 100644
--- a/usr.sbin/iscsid/iscsid.c
+++ b/usr.sbin/iscsid/iscsid.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 The FreeBSD Foundation
*
@@ -29,9 +29,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
diff --git a/usr.sbin/iscsid/iscsid.h b/usr.sbin/iscsid/iscsid.h
index 42343c0556ae..0ff0b0ccb300 100644
--- a/usr.sbin/iscsid/iscsid.h
+++ b/usr.sbin/iscsid/iscsid.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 The FreeBSD Foundation
*
@@ -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 ISCSID_H
diff --git a/usr.sbin/iscsid/login.c b/usr.sbin/iscsid/login.c
index 264bcb48104b..06d6ac072d21 100644
--- a/usr.sbin/iscsid/login.c
+++ b/usr.sbin/iscsid/login.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 The FreeBSD Foundation
*
@@ -29,9 +29,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/ioctl.h>
#include <assert.h>
diff --git a/usr.sbin/jail/Makefile b/usr.sbin/jail/Makefile
index de1e89e708f0..60234c8255d9 100644
--- a/usr.sbin/jail/Makefile
+++ b/usr.sbin/jail/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
@@ -11,6 +10,7 @@ LIBADD= jail kvm util
PACKAGE=jail
NO_WMISSING_VARIABLE_DECLARATIONS=
+CWARNFLAGS.jailparse.c= ${NO_WUNUSED_BUT_SET_VARIABLE}
YFLAGS+=-v
CFLAGS+=-I. -I${.CURDIR}
diff --git a/usr.sbin/jail/Makefile.depend b/usr.sbin/jail/Makefile.depend
index 7f608aab0712..ef2f6c1424ca 100644
--- a/usr.sbin/jail/Makefile.depend
+++ b/usr.sbin/jail/Makefile.depend
@@ -1,19 +1,15 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libelf \
lib/libjail \
lib/libkvm \
lib/libutil \
- usr.bin/lex/lib \
usr.bin/yacc.host \
diff --git a/usr.sbin/jail/command.c b/usr.sbin/jail/command.c
index c1d418d6cc69..60893444e9de 100644
--- a/usr.sbin/jail/command.c
+++ b/usr.sbin/jail/command.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 James Gritton
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/cpuset.h>
#include <sys/event.h>
@@ -294,9 +291,9 @@ run_command(struct cfjail *j)
login_cap_t *lcap;
const char **argv;
char *acs, *cs, *comcs, *devpath;
- const char *jidstr, *conslog, *path, *ruleset, *term, *username;
+ const char *jidstr, *conslog, *fmt, *path, *ruleset, *term, *username;
enum intparam comparam;
- size_t comlen;
+ size_t comlen, ret;
pid_t pid;
cpusetid_t setid;
int argc, bg, clean, consfd, down, fib, i, injail, sjuser, timeout;
@@ -440,7 +437,7 @@ run_command(struct cfjail *j)
} else
argc = 4;
- if (!down) {
+ if (!down && extrap != NULL) {
for (cs = strtok(extrap, " "); cs;
cs = strtok(NULL, " ")) {
size_t len = strlen(cs) + 1;
@@ -593,6 +590,31 @@ run_command(struct cfjail *j)
}
break;
+ case IP_ZFS_DATASET:
+ argv = alloca(4 * sizeof(char *));
+ jidstr = string_param(j->intparams[KP_JID]) ?
+ string_param(j->intparams[KP_JID]) :
+ string_param(j->intparams[KP_NAME]);
+ fmt = "if [ $(/sbin/zfs get -H -o value jailed %s) = on ]; then /sbin/zfs jail %s %s || echo error, attaching %s to jail %s failed; else echo error, you need to set jailed=on for dataset %s; fi";
+ comlen = strlen(fmt)
+ + 2 * strlen(jidstr)
+ + 4 * comstring->len
+ - 6 * 2 /* 6 * "%s" */
+ + 1;
+ comcs = alloca(comlen);
+ ret = snprintf(comcs, comlen, fmt, comstring->s,
+ jidstr, comstring->s, comstring->s, jidstr,
+ comstring->s);
+ if (ret >= comlen) {
+ jail_warnx(j, "internal error in ZFS dataset handling");
+ exit(1);
+ }
+ argv[0] = _PATH_BSHELL;
+ argv[1] = "-c";
+ argv[2] = comcs;
+ argv[3] = NULL;
+ break;
+
case IP_COMMAND:
if (j->name != NULL)
goto default_command;
diff --git a/usr.sbin/jail/config.c b/usr.sbin/jail/config.c
index 4cf28820452a..3af0088626c9 100644
--- a/usr.sbin/jail/config.c
+++ b/usr.sbin/jail/config.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 James Gritton
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/socket.h>
@@ -38,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/in.h>
#include <err.h>
+#include <glob.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
@@ -46,20 +44,22 @@ __FBSDID("$FreeBSD$");
#include "jailp.h"
+#define MAX_INCLUDE_DEPTH 32
+
struct ipspec {
const char *name;
unsigned flags;
};
-extern FILE *yyin;
-extern int yynerrs;
-
-extern int yyparse(void);
+extern int yylex_init_extra(struct cflex *extra, void *scanner);
+extern int yylex_destroy(void *scanner);
+extern int yyparse(void *scanner);
+extern int yyset_in(FILE *fp, void *scanner);
struct cfjails cfjails = TAILQ_HEAD_INITIALIZER(cfjails);
+static void parse_config(const char *fname, int is_stdin);
static void free_param(struct cfparams *pp, struct cfparam *p);
-static void free_param_strings(struct cfparam *p);
static const struct ipspec intparams[] = {
[IP_ALLOW_DYING] = {"allow.dying", PF_INTERNAL | PF_BOOL},
@@ -93,6 +93,7 @@ static const struct ipspec intparams[] = {
[IP_MOUNT_FSTAB] = {"mount.fstab", PF_INTERNAL},
[IP_STOP_TIMEOUT] = {"stop.timeout", PF_INTERNAL | PF_INT},
[IP_VNET_INTERFACE] = {"vnet.interface", PF_INTERNAL},
+ [IP_ZFS_DATASET] = {"zfs.dataset", PF_INTERNAL},
#ifdef INET
[IP__IP4_IFADDR] = {"ip4.addr", PF_INTERNAL | PF_CONV | PF_REV},
#endif
@@ -127,7 +128,7 @@ static const struct ipspec intparams[] = {
* Parse the jail configuration file.
*/
void
-load_config(void)
+load_config(const char *cfname)
{
struct cfjails wild;
struct cfparams opp;
@@ -138,16 +139,7 @@ load_config(void)
char *ep;
int did_self, jseq, pgen;
- if (!strcmp(cfname, "-")) {
- cfname = "STDIN";
- yyin = stdin;
- } else {
- yyin = fopen(cfname, "r");
- if (!yyin)
- err(1, "%s", cfname);
- }
- if (yyparse() || yynerrs)
- exit(1);
+ parse_config(cfname, !strcmp(cfname, "-"));
/* Separate the wildcard jails out from the actual jails. */
jseq = 0;
@@ -274,6 +266,67 @@ load_config(void)
}
}
+void
+include_config(void *scanner, const char *cfname)
+{
+ static unsigned int depth;
+ glob_t g = {0};
+ const char *slash;
+ char *fullpath = NULL;
+
+ /* Simple sanity check for include loops. */
+ if (++depth > MAX_INCLUDE_DEPTH)
+ errx(1, "maximum include depth exceeded");
+ /* Base relative pathnames on the current config file. */
+ if (yyget_in(scanner) != stdin && cfname[0] != '/') {
+ const char *outer_cfname = yyget_extra(scanner)->cfname;
+ if ((slash = strrchr(outer_cfname, '/')) != NULL) {
+ size_t dirlen = (slash - outer_cfname) + 1;
+
+ fullpath = emalloc(dirlen + strlen(cfname) + 1);
+ strncpy(fullpath, outer_cfname, dirlen);
+ strcpy(fullpath + dirlen, cfname);
+ cfname = fullpath;
+ }
+ }
+ /*
+ * Check if the include statement had a filename glob.
+ * Globbing doesn't need to catch any files, but a non-glob
+ * file needs to exist (enforced by parse_config).
+ */
+ if (glob(cfname, GLOB_NOCHECK, NULL, &g) != 0)
+ errx(1, "%s: filename glob failed", cfname);
+ if (g.gl_flags & GLOB_MAGCHAR) {
+ for (size_t gi = 0; gi < g.gl_matchc; gi++)
+ parse_config(g.gl_pathv[gi], 0);
+ } else
+ parse_config(cfname, 0);
+ if (fullpath)
+ free(fullpath);
+ --depth;
+}
+
+static void
+parse_config(const char *cfname, int is_stdin)
+{
+ struct cflex cflex = {.cfname = cfname, .error = 0};
+ void *scanner;
+
+ yylex_init_extra(&cflex, &scanner);
+ if (is_stdin) {
+ cflex.cfname = "STDIN";
+ yyset_in(stdin, scanner);
+ } else {
+ FILE *yfp = fopen(cfname, "r");
+ if (!yfp)
+ err(1, "%s", cfname);
+ yyset_in(yfp, scanner);
+ }
+ if (yyparse(scanner) || cflex.error)
+ exit(1);
+ yylex_destroy(scanner);
+}
+
/*
* Create a new jail record.
*/
@@ -836,7 +889,7 @@ free_param(struct cfparams *pp, struct cfparam *p)
free(p);
}
-static void
+void
free_param_strings(struct cfparam *p)
{
struct cfstring *s;
diff --git a/usr.sbin/jail/jail.8 b/usr.sbin/jail/jail.8
index 61fe91cf973e..d58192623952 100644
--- a/usr.sbin/jail/jail.8
+++ b/usr.sbin/jail/jail.8
@@ -23,34 +23,45 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 2021
+.Dd March 16, 2024
.Dt JAIL 8
.Os
.Sh NAME
.Nm jail
.Nd "manage system jails"
.Sh SYNOPSIS
+.Ss From Configuration File
+.Nm
+.Op Fl cm
+.Op Fl Cdqv
+.Op Fl f Ar conf_file
+.Op Fl p Ar limit
+.Op Ar jail
.Nm
+.Op Fl r
+.Op Fl Cqv
+.Op Fl f Ar conf_file
+.Op Fl p Ar limit
+.Op Cm * | Ar jail ...
+.Ss Without Configuration File
+.Nm
+.Op Fl cm
.Op Fl dhilqv
.Op Fl J Ar jid_file
.Op Fl u Ar username
.Op Fl U Ar username
-.Op Fl cmr
.Ar param Ns = Ns Ar value ...
.Op Cm command Ns = Ns Ar command ...
.Nm
-.Op Fl dqv
-.Op Fl f Ar conf_file
-.Op Fl p Ar limit
-.Op Fl cmr
-.Op Ar jail
-.Nm
-.Op Fl qv
-.Op Fl f Ar conf_file
.Op Fl rR
+.Op Fl qv
.Op Cm * | Ar jail ...
+.Ss Show Parameters
+.Nm
+.Op Fl f Ar conf_file
+.Fl e
+.Ar separator
+.Ss Backward Compatibility
.Nm
.Op Fl dhilqv
.Op Fl J Ar jid_file
@@ -58,11 +69,8 @@
.Op Fl U Ar username
.Op Fl n Ar jailname
.Op Fl s Ar securelevel
-.Ar path hostname ip Ns [ Ns Ar ,... Ns ] Ar command ...
-.Nm
-.Op Fl f Ar conf_file
-.Fl e
-.Ar separator
+.Ar path hostname ip Ns Op Cm \&, Ns Ar ...
+.Ar command ...
.Sh DESCRIPTION
The
.Nm
@@ -136,10 +144,9 @@ jail if it does exist.
.Pp
Other available options are:
.Bl -tag -width indent
-.It Fl d
-Allow making changes to a dying jail, equivalent to the
-.Va allow.dying
-parameter.
+.It Fl C
+Clean up after an already-removed jail, running commands and operations
+that are typically run following jail removal.
.It Fl f Ar conf_file
Use configuration file
.Ar conf_file
@@ -207,6 +214,17 @@ parameter.
.It Fl v
Print a message on every operation, such as running commands and
mounting filesystems.
+.It Fl d
+This is deprecated and is equivalent to the
+.Va allow.dying
+parameter, which is also deprecated.
+It used to allow making changes to a
+.Va dying
+jail.
+Now such jails are always replaced when a new jail is created with the same
+.Va jid
+or
+.Va name .
.El
.Pp
If no arguments are given after the options, the operation (except
@@ -239,10 +257,10 @@ would apply to jails with names like
and
.Dq foo.bar.baz .
.Pp
-A jail may be specified with parameters directly on the command line.
-In this case, the
-.Xr jail.conf 5
-file will not be used.
+A jail may also be specified via parameters directly on the command line in
+.Dq name=value
+form, ignoring the contents of
+.Xr jail.conf 5 .
For backward compatibility, the command line may also have four fixed
parameters, without names:
.Ar path ,
@@ -250,11 +268,6 @@ parameters, without names:
.Ar ip ,
and
.Ar command .
-This mode will always create a new jail, and the
-.Fl c
-and
-.Fl m
-options do not apply (and must not be present).
.Ss Jail Parameters
Parameters in the
.Xr jail.conf 5
@@ -571,8 +584,9 @@ If the
MIB entry is zero, this will be restricted to the root user.
.It Va allow.socket_af
Sockets within a jail are normally restricted to IPv4, IPv6, local
-(UNIX), and route. This allows access to other protocol stacks that
-have not had jail functionality added to them.
+(UNIX), and route.
+This allows access to other protocol stacks that have not had jail
+functionality added to them.
.It Va allow.mlock
Locking or unlocking physical pages in memory are normally not available
within a jail.
@@ -583,6 +597,51 @@ or
memory subject to
.Va security.bsd.unprivileged_mlock
and resource limits.
+.It Va allow.nfsd
+The
+.Xr mountd 8 ,
+.Xr nfsd 8 ,
+.Xr nfsuserd 8 ,
+.Xr gssd 8
+and
+.Xr rpc.tlsservd 8
+daemons are permitted to run inside a properly configured vnet-enabled jail.
+The jail's root must be a file system mount point and
+.Va enforce_statfs
+must not be set to 0, so that
+.Xr mountd 8
+can export file systems visible within the jail.
+.Va enforce_statfs
+must be set to 1 if file systems mounted under the
+jail's file system need to be exported by
+.Xr mount 8 .
+For exporting only the jail's file system, a setting of 2
+is sufficient.
+If the kernel configuration does not include the
+.Sy NFSD
+option,
+.Pa nfsd.ko
+must be loaded outside of the jails.
+This is normally done by adding
+.Dq nfsd
+to
+.Va kld_list
+in the
+.Xr rc.conf 5
+file outside of the jails.
+Similarily, if the
+.Xr gssd 8
+is to be run in a jail, either the kernel
+.Sy KGSSAPI
+option needs to be specified or
+.Dq kgssapi
+and
+.Dq kgssapi_krb5
+need to be in
+.Va kld_list
+in the
+.Xr rc.conf 5
+file outside of the jails.
.It Va allow.reserved_ports
The jail root may bind to ports lower than 1024.
.It Va allow.unprivileged_proc_debug
@@ -594,6 +653,9 @@ sysctl.
The super-user will be disabled automatically if its parent system has it
disabled.
The super-user is enabled by default.
+.It Va allow.extattr
+Allow privileged process in the jail to manipulate filesystem extended
+attributes in the system namespace.
.El
.El
.Pp
@@ -620,7 +682,7 @@ and only when
.Va enforce_statfs
is set to a value lower than 2.
.It Va allow.mount.fusefs
-privileged users inside the jail will be able to mount and unmount
+privileged users inside the jail will be able to mount and unmount
fuse-based file systems.
This permission is effective only together with
.Va allow.mount
@@ -713,7 +775,7 @@ the jail cannot perform any sysvmsg-related system calls.
.It Va sysvsem, sysvshm
Allow access to SYSV IPC semaphore and shared memory primitives, in the
same manner as
-.Va sysvmsg.
+.Va sysvmsg .
.El
.Pp
There are pseudo-parameters that are not passed to the kernel, but are
@@ -859,6 +921,15 @@ may also be specified, in the form
.It Va vnet.interface
A network interface to give to a vnet-enabled jail after is it created.
The interface will automatically be released when the jail is removed.
+.It Va zfs.dataset
+A list of ZFS datasets to be attached to the jail.
+This requires
+.Va allow.mount.zfs
+to be set.
+See
+.Xr zfs-jail 8
+for information on how to configure a ZFS dataset to be operated from
+within a jail.
.It Va ip_hostname
Resolve the
.Va host.hostname
@@ -903,9 +974,14 @@ filesystem on the chrooted
.Pa /proc
directory.
.It Va allow.dying
-Allow making changes to a
+This is deprecated and has no effect.
+It used to allow making changes to a
.Va dying
jail.
+Now such jails are always replaced when a new jail is created with the same
+.Va jid
+or
+.Va name .
.It Va depend
Specify a jail (or jails) that this jail depends on.
When this jail is to be created, any jail(s) it depends on must already exist.
@@ -941,7 +1017,7 @@ To set up a jail directory tree containing an entire
distribution, the following
.Xr sh 1
command script can be used:
-.Bd -literal
+.Bd -literal -offset indent
D=/here/is/the/jail
cd /usr/src
mkdir -p $D
@@ -1021,11 +1097,6 @@ To configure
it is necessary to modify
.Pa /etc/mail/sendmail.cf .
.Pp
-For
-.Xr named 8 ,
-it is necessary to modify
-.Pa /etc/namedb/named.conf .
-.Pp
In addition, a number of services must be recompiled in order to run
them in the host environment.
This includes most applications providing services using
@@ -1200,9 +1271,11 @@ the intended use of the jail, you may also want to run
.Pa /etc/rc.shutdown
from within the jail.
.Pp
-To shut down the jail from the outside, simply remove it with
-.Nm
-.Ar -r ,
+To shut down the jail from the outside, simply remove it with:
+.Bd -literal -offset indent
+jail -r
+.Ed
+.Pp
which will run any commands specified by
.Va exec.stop ,
and then send
@@ -1265,7 +1338,7 @@ can be used to determine if a process is running inside a jail (value
is one) or not (value is zero).
.Pp
The variable
-.Va security.jail.max_af_ips
+.Va security.jail.jail_max_af_ips
determines how may address per address family a jail may have.
The default is 255.
.Pp
@@ -1361,14 +1434,17 @@ environment of the first jail.
.Xr jexec 8 ,
.Xr jls 8 ,
.Xr mount 8 ,
-.Xr named 8 ,
+.Xr mountd 8 ,
+.Xr nfsd 8 ,
.Xr reboot 8 ,
.Xr rpcbind 8 ,
.Xr sendmail 8 ,
.Xr shutdown 8 ,
.Xr sysctl 8 ,
.Xr syslogd 8 ,
-.Xr umount 8
+.Xr umount 8 ,
+.Xr zfs-jail 8 ,
+.Xr extattr 9
.Sh HISTORY
The
.Nm
diff --git a/usr.sbin/jail/jail.c b/usr.sbin/jail/jail.c
index 63096146f176..53e05870ff26 100644
--- a/usr.sbin/jail/jail.c
+++ b/usr.sbin/jail/jail.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Poul-Henning Kamp.
* Copyright (c) 2009-2012 James Gritton
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
@@ -56,7 +53,6 @@ struct permspec {
int rev;
};
-const char *cfname;
int iflag;
int note_remove;
int verbose;
@@ -65,7 +61,7 @@ const char *separator = "\t";
static void clear_persist(struct cfjail *j);
static int update_jail(struct cfjail *j);
static int rdtun_params(struct cfjail *j, int dofail);
-static void running_jid(struct cfjail *j, int dflag);
+static void running_jid(struct cfjail *j);
static void jail_quoted_warnx(const struct cfjail *j, const char *name_msg,
const char *noname_msg);
static int jailparam_set_note(const struct cfjail *j, struct jailparam *jp,
@@ -74,7 +70,7 @@ static void print_jail(FILE *fp, struct cfjail *j, int oldcl, int running);
static void print_param(FILE *fp, const struct cfparam *p, int sep, int doname);
static void show_jails(void);
static void quoted_print(FILE *fp, char *str);
-static void usage(void);
+static void usage(void) __dead2;
static struct permspec perm_sysctl[] = {
{ "security.jail.set_hostname_allowed", KP_ALLOW_SET_HOSTNAME, 0 },
@@ -102,6 +98,7 @@ static const enum intparam startcommands[] = {
IP_EXEC_PRESTART,
IP__OP,
IP_EXEC_CREATED,
+ IP_ZFS_DATASET,
IP_VNET_INTERFACE,
IP_EXEC_START,
IP_COMMAND,
@@ -131,6 +128,24 @@ static const enum intparam stopcommands[] = {
IP__NULL
};
+static const enum intparam cleancommands[] = {
+ IP__NULL,
+ IP_EXEC_POSTSTOP,
+ IP_MOUNT_PROCFS,
+ IP_MOUNT_FDESCFS,
+ IP_MOUNT_DEVFS,
+ IP__MOUNT_FROM_FSTAB,
+ IP_MOUNT,
+#ifdef INET6
+ IP__IP6_IFADDR,
+#endif
+#ifdef INET
+ IP__IP4_IFADDR,
+#endif
+ IP_EXEC_RELEASE,
+ IP__NULL
+};
+
int
main(int argc, char **argv)
{
@@ -138,10 +153,11 @@ main(int argc, char **argv)
FILE *jfp;
struct cfjail *j;
char *JidFile;
+ const char *cfname;
size_t sysvallen;
unsigned op, pi;
- int ch, docf, error, i, oldcl, sysval;
- int dflag, Rflag;
+ int ch, docf, dying_warned, error, i, oldcl, sysval;
+ int dflag, eflag, Rflag;
#if defined(INET) || defined(INET6)
char *cs, *ncs;
#endif
@@ -150,21 +166,24 @@ main(int argc, char **argv)
#endif
op = 0;
- dflag = Rflag = 0;
+ dflag = eflag = Rflag = 0;
docf = 1;
cfname = CONF_FILE;
JidFile = NULL;
- while ((ch = getopt(argc, argv, "cde:f:hiJ:lmn:p:qrRs:u:U:v")) != -1) {
+ while ((ch = getopt(argc, argv, "cCde:f:hiJ:lmn:p:qrRs:u:U:v")) != -1) {
switch (ch) {
case 'c':
op |= JF_START;
break;
+ case 'C':
+ op |= JF_CLEANUP;
+ break;
case 'd':
dflag = 1;
break;
case 'e':
- op |= JF_SHOW;
+ eflag = 1;
separator = optarg;
break;
case 'f':
@@ -234,7 +253,16 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
- /* Find out which of the four command line styles this is. */
+ if (eflag) {
+ /* Just print list of all configured non-wildcard jails */
+ if (op || argc > 0)
+ usage();
+ load_config(cfname);
+ show_jails();
+ exit(0);
+ }
+
+ /* Find out which of the command line styles this is. */
oldcl = 0;
if (!op) {
/* Old-style command line with four fixed parameters */
@@ -284,13 +312,7 @@ main(int argc, char **argv)
? NULL : "false");
}
}
- } else if (op == JF_STOP || op == JF_SHOW) {
- /* Just print list of all configured non-wildcard jails */
- if (op == JF_SHOW) {
- load_config();
- show_jails();
- exit(0);
- }
+ } else if (op == JF_STOP) {
/* Jail remove, perhaps using the config file */
if (!docf || argc == 0)
usage();
@@ -300,11 +322,11 @@ main(int argc, char **argv)
usage();
if ((docf = !Rflag &&
(!strcmp(cfname, "-") || stat(cfname, &st) == 0)))
- load_config();
+ load_config(cfname);
note_remove = docf || argc > 1 || wild_jail_name(argv[0]);
} else if (argc > 1 || (argc == 1 && strchr(argv[0], '='))) {
/* Single jail specified on the command line */
- if (Rflag)
+ if (Rflag || (op & JF_CLEANUP))
usage();
docf = 0;
for (i = 0; i < argc; i++) {
@@ -348,13 +370,13 @@ main(int argc, char **argv)
/* From the config file, perhaps with a specified jail */
if (Rflag || !docf)
usage();
- load_config();
+ load_config(cfname);
}
/* Find out which jails will be run. */
dep_setup(docf);
error = 0;
- if (op == JF_STOP) {
+ if ((op & JF_OP_MASK) == JF_STOP) {
for (i = 0; i < argc; i++)
if (start_state(argv[i], docf, op, Rflag) < 0)
error = 1;
@@ -377,6 +399,7 @@ main(int argc, char **argv)
* operation on it. When that is done, the jail may be finished,
* or it may go back for the next step.
*/
+ dying_warned = 0;
while ((j = next_jail()))
{
if (j->flags & JF_FAILED) {
@@ -397,11 +420,13 @@ main(int argc, char **argv)
import_params(j) < 0)
continue;
}
+ if (j->intparams[IP_ALLOW_DYING] && !dying_warned) {
+ warnx("%s", "the 'allow.dying' parameter and '-d' flag "
+ "are deprecated and have no effect.");
+ dying_warned = 1;
+ }
if (!j->jid)
- running_jid(j,
- (j->flags & (JF_SET | JF_DEPEND)) == JF_SET
- ? dflag || bool_param(j->intparams[IP_ALLOW_DYING])
- : 0);
+ running_jid(j);
if (finish_command(j))
continue;
@@ -411,22 +436,24 @@ main(int argc, char **argv)
* depending on the jail's current status.
*/
case JF_START_SET:
- j->flags = j->jid < 0 ? JF_START : JF_SET;
+ j->flags = j->jid < 0
+ ? (j->flags & JF_CLEANUP) | JF_START : JF_SET;
break;
case JF_SET_RESTART:
- if (j->jid < 0) {
+ if (j->jid < 0 && !(j->flags & JF_CLEANUP)) {
jail_quoted_warnx(j, "not found",
"no jail specified");
failed(j);
continue;
}
- j->flags = rdtun_params(j, 0) ? JF_RESTART : JF_SET;
+ j->flags = rdtun_params(j, 0)
+ ? (j->flags & JF_CLEANUP) | JF_RESTART : JF_SET;
if (j->flags == JF_RESTART)
dep_reset(j);
break;
case JF_START_SET_RESTART:
- j->flags = j->jid < 0 ? JF_START
- : rdtun_params(j, 0) ? JF_RESTART : JF_SET;
+ j->flags = j->jid < 0 ? JF_START : rdtun_params(j, 0)
+ ? (j->flags & JF_CLEANUP) | JF_RESTART : JF_SET;
if (j->flags == JF_RESTART)
dep_reset(j);
}
@@ -445,11 +472,18 @@ main(int argc, char **argv)
continue;
if (j->jid > 0)
goto jail_create_done;
+ if (j->flags & JF_CLEANUP) {
+ j->flags |= JF_STOP;
+ j->comparam = cleancommands;
+ } else
+ j->comparam = startcommands;
j->comparam = startcommands;
j->comstring = NULL;
}
if (next_command(j))
continue;
+ if (j->flags & JF_STOP)
+ goto jail_remove_done;
jail_create_done:
clear_persist(j);
if (jfp != NULL)
@@ -481,7 +515,10 @@ main(int argc, char **argv)
if (j->comparam == NULL) {
if (dep_check(j))
continue;
- if (j->jid < 0) {
+ if (j->flags & JF_CLEANUP) {
+ j->comparam = j->jid < 0
+ ? cleancommands : stopcommands;
+ } else if (j->jid < 0) {
if (!(j->flags & (JF_DEPEND|JF_WILD))) {
if (verbose >= 0)
jail_quoted_warnx(j,
@@ -490,7 +527,8 @@ main(int argc, char **argv)
}
goto jail_remove_done;
}
- j->comparam = stopcommands;
+ else
+ j->comparam = stopcommands;
j->comstring = NULL;
} else if ((j->flags & JF_FAILED) && j->jid > 0)
goto jail_remove_done;
@@ -500,7 +538,7 @@ main(int argc, char **argv)
dep_done(j, 0);
if ((j->flags & (JF_START | JF_FAILED)) == JF_START) {
j->comparam = NULL;
- j->flags &= ~JF_STOP;
+ j->flags &= ~(JF_STOP | JF_CLEANUP);
dep_reset(j);
requeue(j, j->ndeps ? &depend : &ready);
}
@@ -613,11 +651,10 @@ jail_warnx(const struct cfjail *j, const char *fmt, ...)
int
create_jail(struct cfjail *j)
{
- struct iovec jiov[4];
struct stat st;
- struct jailparam *jp, *setparams, *setparams2, *sjp;
+ struct jailparam *jp, *setparams, *sjp;
const char *path;
- int dopersist, ns, jid, dying, didfail;
+ int dopersist, ns;
/*
* Check the jail's path, with a better error message than jail_set
@@ -657,57 +694,8 @@ create_jail(struct cfjail *j)
*sjp++ = *jp;
ns = sjp - setparams;
- didfail = 0;
j->jid = jailparam_set_note(j, setparams, ns, JAIL_CREATE);
- if (j->jid < 0 && errno == EEXIST &&
- bool_param(j->intparams[IP_ALLOW_DYING]) &&
- int_param(j->intparams[KP_JID], &jid) && jid != 0) {
- /*
- * The jail already exists, but may be dying.
- * Make sure it is, in which case an update is appropriate.
- */
- jiov[0].iov_base = __DECONST(char *, "jid");
- jiov[0].iov_len = sizeof("jid");
- jiov[1].iov_base = &jid;
- jiov[1].iov_len = sizeof(jid);
- jiov[2].iov_base = __DECONST(char *, "dying");
- jiov[2].iov_len = sizeof("dying");
- jiov[3].iov_base = &dying;
- jiov[3].iov_len = sizeof(dying);
- if (jail_get(jiov, 4, JAIL_DYING) < 0) {
- /*
- * It could be that the jail just barely finished
- * dying, or it could be that the jid never existed
- * but the name does. In either case, another try
- * at creating the jail should do the right thing.
- */
- if (errno == ENOENT)
- j->jid = jailparam_set_note(j, setparams, ns,
- JAIL_CREATE);
- } else if (dying) {
- j->jid = jid;
- if (rdtun_params(j, 1) < 0) {
- j->jid = -1;
- didfail = 1;
- } else {
- sjp = setparams2 = alloca((j->njp + dopersist) *
- sizeof(struct jailparam));
- for (jp = setparams; jp < setparams + ns; jp++)
- if (!JP_RDTUN(jp) ||
- !strcmp(jp->jp_name, "jid"))
- *sjp++ = *jp;
- j->jid = jailparam_set_note(j, setparams2,
- sjp - setparams2, JAIL_UPDATE | JAIL_DYING);
- /*
- * Again, perhaps the jail just finished dying.
- */
- if (j->jid < 0 && errno == ENOENT)
- j->jid = jailparam_set_note(j,
- setparams, ns, JAIL_CREATE);
- }
- }
- }
- if (j->jid < 0 && !didfail) {
+ if (j->jid < 0) {
jail_warnx(j, "%s", jail_errmsg);
failed(j);
}
@@ -772,9 +760,7 @@ update_jail(struct cfjail *j)
if (!JP_RDTUN(jp))
*++sjp = *jp;
- jid = jailparam_set_note(j, setparams, ns,
- bool_param(j->intparams[IP_ALLOW_DYING])
- ? JAIL_UPDATE | JAIL_DYING : JAIL_UPDATE);
+ jid = jailparam_set_note(j, setparams, ns, JAIL_UPDATE);
if (jid < 0) {
jail_warnx(j, "%s", jail_errmsg);
failed(j);
@@ -815,8 +801,7 @@ rdtun_params(struct cfjail *j, int dofail)
rtjp->jp_value = NULL;
}
rval = 0;
- if (jailparam_get(rtparams, nrt,
- bool_param(j->intparams[IP_ALLOW_DYING]) ? JAIL_DYING : 0) > 0) {
+ if (jailparam_get(rtparams, nrt, 0) > 0) {
rtjp = rtparams + 1;
for (jp = j->jp; rtjp < rtparams + nrt; jp++) {
if (JP_RDTUN(jp) && strcmp(jp->jp_name, "jid")) {
@@ -863,7 +848,7 @@ rdtun_params(struct cfjail *j, int dofail)
* Get the jail's jid if it is running.
*/
static void
-running_jid(struct cfjail *j, int dflag)
+running_jid(struct cfjail *j)
{
struct iovec jiov[2];
const char *pval;
@@ -889,7 +874,7 @@ running_jid(struct cfjail *j, int dflag)
j->jid = -1;
return;
}
- j->jid = jail_get(jiov, 2, dflag ? JAIL_DYING : 0);
+ j->jid = jail_get(jiov, 2, 0);
}
static void
@@ -918,10 +903,9 @@ jailparam_set_note(const struct cfjail *j, struct jailparam *jp, unsigned njp,
jid = jailparam_set(jp, njp, flags);
if (verbose > 0) {
- jail_note(j, "jail_set(%s%s)",
+ jail_note(j, "jail_set(%s)",
(flags & (JAIL_CREATE | JAIL_UPDATE)) == JAIL_CREATE
- ? "JAIL_CREATE" : "JAIL_UPDATE",
- (flags & JAIL_DYING) ? " | JAIL_DYING" : "");
+ ? "JAIL_CREATE" : "JAIL_UPDATE");
for (i = 0; i < njp; i++) {
printf(" %s", jp[i].jp_name);
if (jp[i].jp_value == NULL)
diff --git a/usr.sbin/jail/jail.conf.5 b/usr.sbin/jail/jail.conf.5
index ce414b96463e..0b82a972020c 100644
--- a/usr.sbin/jail/jail.conf.5
+++ b/usr.sbin/jail/jail.conf.5
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd April 18, 2021
+.Dd September 5, 2023
.Dt JAIL.CONF 5
.Os
.Sh NAME
@@ -163,6 +161,25 @@ would apply to jails with names like
.Dq foo.bar
and
.Dq foo.bar.baz .
+.Ss Includes
+A line of the form
+.Bd -literal -offset ident
+\&.include "filename";
+.Ed
+.Pp
+will include another file (or files) in the configuration.
+The filename should be either absolute, or relative to the
+configuration file's directory. It cannot contain variable
+expansions, but may contain
+.Xr glob 3
+patterns.
+.Pp
+The included file must exist, though a filename glob may match zero or
+more files. This allows inclusion of any/all files in a directory,
+such as
+.Dq /etc/jail.conf.d/*.conf ,
+or conditional inclusion of a single file, such as
+.Dq jail.foo[.]conf .
.Ss Comments
The configuration file may contain comments in the common C, C++, and
shell formats:
@@ -178,6 +195,13 @@ shell formats:
.Pp
Comments are legal wherever whitespace is allowed, i.e. anywhere except
in the middle of a string or a token.
+.Sh FILES
+.Bl -tag -width "indent" -compact
+.It Pa /etc/jail.conf
+.It Pa /etc/jail.*.conf
+.It Pa /etc/jail.conf.d/*.conf
+.It Pa /usr/share/examples/jails/
+.El
.Sh EXAMPLES
.Bd -literal
# Typical static defaults:
@@ -205,6 +229,13 @@ bar {
mount.nodevfs;
persist; // Required because there are no processes
}
+
+# Include configurations from standard locations.
+\[char46]include "/etc/jail.conf.d/*.conf";
+\[char46]include "/etc/jail.*.conf";
+\[char46]include "/usr/local/etc/jail[.]conf";
+\[char46]include "/usr/local/etc/jail.conf.d/*.conf";
+\[char46]include "/usr/local/etc/jail.*.conf";
.Ed
.Sh SEE ALSO
.Xr jail_set 2 ,
diff --git a/usr.sbin/jail/jaillex.l b/usr.sbin/jail/jaillex.l
index cb758b237b46..1dc61c1e9ab0 100644
--- a/usr.sbin/jail/jaillex.l
+++ b/usr.sbin/jail/jaillex.l
@@ -1,6 +1,6 @@
%{
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 James Gritton
* All rights reserved.
@@ -28,8 +28,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <stddef.h>
#include <stdlib.h>
@@ -38,40 +36,32 @@ __FBSDID("$FreeBSD$");
#include "jailp.h"
#include "y.tab.h"
-extern int yynerrs;
+#define YY_DECL int yylex(YYSTYPE *yylval, yyscan_t yyscanner)
+#define YY_EXTRA_TYPE struct cflex*
-static ssize_t text2lval(size_t triml, size_t trimr, int tovar);
+extern YY_DECL;
-static int instr;
-static int lineno = 1;
+static ssize_t text2lval(size_t triml, size_t trimr, int tovar,
+ YYSTYPE *yylval, yyscan_t scanner);
-#define YY_DECL int yylex(void)
+static int instr;
%}
%option noyywrap
%option noinput
%option nounput
+%option reentrant
+%option yylineno
%start _ DQ
%%
/* Whitespace or equivalent */
-<_>[ \t]+ instr = 0;
-<_>#.* ;
-<_>\/\/.* ;
-<_>\/\*([^*]|(\*+([^*\/])))*\*+\/ {
- const char *s;
-
- for (s = yytext; s < yytext + yyleng; s++)
- if (*s == '\n')
- lineno++;
- instr = 0;
- }
-<_>\n {
- lineno++;
- instr = 0;
- }
+<_>[ \t\r\n]+ instr = 0;
+<_>#.* instr = 0;
+<_>\/\/.* instr = 0;
+<_>\/\*([^*]|(\*+([^*\/])))*\*+\/ instr = 0;
/* Reserved tokens */
<_>\+= {
@@ -87,13 +77,13 @@ static int lineno = 1;
<_,DQ>[A-Za-z0-9_!%&()\-.:<>?@\[\]^`|~]+ |
<_,DQ>\\(.|\n|[0-7]{1,3}|x[0-9A-Fa-f]{1,2}) |
<_,DQ>[$*+/\\] {
- (void)text2lval(0, 0, 0);
+ (void)text2lval(0, 0, 0, yylval, yyscanner);
return instr ? STR1 : (instr = 1, STR);
}
/* Single and double quoted strings */
<_>'([^\'\\]|\\(.|\n))*' {
- (void)text2lval(1, 1, 0);
+ (void)text2lval(1, 1, 0, yylval, yyscanner);
return instr ? STR1 : (instr = 1, STR);
}
<_>\"([^"\\]|\\(.|\n))*\" |
@@ -102,7 +92,8 @@ static int lineno = 1;
ssize_t atvar;
skip = yytext[0] == '"' ? 1 : 0;
- atvar = text2lval(skip, 1, 1);
+ atvar = text2lval(skip, 1, 1, yylval,
+ yyscanner);
if (atvar < 0)
BEGIN _;
else {
@@ -120,32 +111,32 @@ static int lineno = 1;
/* Variables, single-word or bracketed */
<_,DQ>$[A-Za-z_][A-Za-z_0-9]* {
- (void)text2lval(1, 0, 0);
+ (void)text2lval(1, 0, 0, yylval, yyscanner);
return instr ? VAR1 : (instr = 1, VAR);
}
<_>$\{([^\n{}]|\\(.|\n))*\} |
<DQ>$\{([^\n\"{}]|\\(.|\n))*\} {
- (void)text2lval(2, 1, 0);
+ (void)text2lval(2, 1, 0, yylval, yyscanner);
return instr ? VAR1 : (instr = 1, VAR);
}
/* Partially formed bits worth complaining about */
<_>\/\*([^*]|(\*+([^*\/])))*\** {
warnx("%s line %d: unterminated comment",
- cfname, lineno);
- yynerrs++;
+ yyextra->cfname, yylineno);
+ yyextra->error = 1;
}
<_>'([^\n'\\]|\\.)* |
<_>\"([^\n\"\\]|\\.)* {
warnx("%s line %d: unterminated string",
- cfname, lineno);
- yynerrs++;
+ yyextra->cfname, yylineno);
+ yyextra->error = 1;
}
<_>$\{([^\n{}]|\\.)* |
<DQ>$\{([^\n\"{}]|\\.)* {
warnx("%s line %d: unterminated variable",
- cfname, lineno);
- yynerrs++;
+ yyextra->cfname, yylineno);
+ yyextra->error = 1;
}
/* A hack because "<0>" rules aren't allowed */
@@ -157,28 +148,19 @@ static int lineno = 1;
%%
-void
-yyerror(const char *s)
-{
- if (!yytext)
- warnx("%s line %d: %s", cfname, lineno, s);
- else if (!yytext[0])
- warnx("%s: unexpected EOF", cfname);
- else
- warnx("%s line %d: %s: %s", cfname, lineno, yytext, s);
-}
-
/*
* Copy string from yytext to yylval, handling backslash escapes,
* and optionally stopping at the beginning of a variable.
*/
static ssize_t
-text2lval(size_t triml, size_t trimr, int tovar)
+text2lval(size_t triml, size_t trimr, int tovar, YYSTYPE *yylval,
+ yyscan_t scanner)
{
char *d;
const char *s, *se;
- yylval.cs = d = emalloc(yyleng - trimr - triml + 1);
+ struct yyguts_t *yyg = scanner;
+ yylval->cs = d = emalloc(yyleng - trimr - triml + 1);
se = yytext + (yyleng - trimr);
for (s = yytext + triml; s < se; s++, d++) {
if (*s != '\\') {
@@ -186,8 +168,6 @@ text2lval(size_t triml, size_t trimr, int tovar)
*d = '\0';
return s - yytext;
}
- if (*s == '\n')
- lineno++;
*d = *s;
continue;
}
@@ -209,8 +189,8 @@ text2lval(size_t triml, size_t trimr, int tovar)
case 'r': *d = '\r'; break;
case 't': *d = '\t'; break;
case 'v': *d = '\v'; break;
- case '\n': d--; lineno++; break;
default: *d = *s; break;
+ case '\n': d--; break;
case 'x':
*d = 0;
if (s + 1 >= se)
diff --git a/usr.sbin/jail/jailp.h b/usr.sbin/jail/jailp.h
index 0ed0755f74b6..ccd96f5f247e 100644
--- a/usr.sbin/jail/jailp.h
+++ b/usr.sbin/jail/jailp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 James Gritton.
* 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 <sys/param.h>
@@ -35,6 +33,7 @@
#include <sys/time.h>
#include <jail.h>
+#include <stdio.h>
#define CONF_FILE "/etc/jail.conf"
@@ -45,15 +44,16 @@
#define DF_LIGHT 0x02 /* Implied dependency on jail existence only */
#define DF_NOFAIL 0x04 /* Don't propagate failed jails */
-#define PF_VAR 0x01 /* This is a variable, not a true parameter */
-#define PF_APPEND 0x02 /* Append to existing parameter list */
-#define PF_BAD 0x04 /* Unable to resolve parameter value */
-#define PF_INTERNAL 0x08 /* Internal parameter, not passed to kernel */
-#define PF_BOOL 0x10 /* Boolean parameter */
-#define PF_INT 0x20 /* Integer parameter */
-#define PF_CONV 0x40 /* Parameter duplicated in converted form */
-#define PF_REV 0x80 /* Run commands in reverse order on stopping */
-#define PF_IMMUTABLE 0x100 /* Immutable parameter */
+#define PF_VAR 0x0001 /* This is a variable, not a true parameter */
+#define PF_APPEND 0x0002 /* Append to existing parameter list */
+#define PF_BAD 0x0004 /* Unable to resolve parameter value */
+#define PF_INTERNAL 0x0008 /* Internal parameter, not passed to kernel */
+#define PF_BOOL 0x0010 /* Boolean parameter */
+#define PF_INT 0x0020 /* Integer parameter */
+#define PF_CONV 0x0040 /* Parameter duplicated in converted form */
+#define PF_REV 0x0080 /* Run commands in reverse order on stopping */
+#define PF_IMMUTABLE 0x0100 /* Immutable parameter */
+#define PF_NAMEVAL 0x0200 /* Parameter is in "name value" form */
#define JF_START 0x0001 /* -c */
#define JF_SET 0x0002 /* -m */
@@ -67,7 +67,7 @@
#define JF_TIMEOUT 0x0200 /* A command (or process kill) timed out */
#define JF_SLEEPQ 0x0400 /* Waiting on a command and/or timeout */
#define JF_FROM_RUNQ 0x0800 /* Has already been on the run queue */
-#define JF_SHOW 0x1000 /* -e Exhibit list of configured jails */
+#define JF_CLEANUP 0x1000 /* -C Run post-removal commands */
#define JF_OP_MASK (JF_START | JF_SET | JF_STOP)
#define JF_RESTART (JF_START | JF_STOP)
@@ -108,6 +108,7 @@ enum intparam {
IP_MOUNT_FSTAB, /* A standard fstab(5) file */
IP_STOP_TIMEOUT, /* Time to wait after sending SIGTERM */
IP_VNET_INTERFACE, /* Assign interface(s) to vnet jail */
+ IP_ZFS_DATASET, /* Jail ZFS datasets */
#ifdef INET
IP__IP4_IFADDR, /* Copy of ip4.addr with interface/netmask */
#endif
@@ -176,6 +177,7 @@ struct cfjail {
struct cfparams params;
struct cfdepends dep[2];
struct cfjails *queue;
+ struct cfjail *cfparent;
struct cfparam *intparams[IP_NPARAM];
struct cfstring *comstring;
struct jailparam *jp;
@@ -196,6 +198,11 @@ struct cfdepend {
unsigned flags;
};
+struct cflex {
+ const char *cfname;
+ int error;
+};
+
extern void *emalloc(size_t);
extern void *erealloc(void *, size_t);
extern char *estrdup(const char *);
@@ -208,7 +215,8 @@ extern int next_command(struct cfjail *j);
extern int finish_command(struct cfjail *j);
extern struct cfjail *next_proc(int nonblock);
-extern void load_config(void);
+extern void load_config(const char *cfname);
+extern void include_config(void *scanner, const char *cfname);
extern struct cfjail *add_jail(void);
extern void add_param(struct cfjail *j, const struct cfparam *p,
enum intparam ipnum, const char *value);
@@ -220,6 +228,7 @@ extern int import_params(struct cfjail *j);
extern int equalopts(const char *opt1, const char *opt2);
extern int wild_jail_name(const char *wname);
extern int wild_jail_match(const char *jname, const char *wname);
+extern void free_param_strings(struct cfparam *p);
extern void dep_setup(int docf);
extern int dep_check(struct cfjail *j);
@@ -231,13 +240,14 @@ extern int start_state(const char *target, int docf, unsigned state,
extern void requeue(struct cfjail *j, struct cfjails *queue);
extern void requeue_head(struct cfjail *j, struct cfjails *queue);
-extern void yyerror(const char *);
-extern int yylex(void);
+extern struct cflex *yyget_extra(void *scanner);
+extern FILE *yyget_in(void *scanner);
+extern int yyget_lineno(void *scanner);
+extern char *yyget_text(void *scanner);
extern struct cfjails cfjails;
extern struct cfjails ready;
extern struct cfjails depend;
-extern const char *cfname;
extern int iflag;
extern int note_remove;
extern int paralimit;
diff --git a/usr.sbin/jail/jailparse.y b/usr.sbin/jail/jailparse.y
index ff673c72695a..048cfcf11c2b 100644
--- a/usr.sbin/jail/jailparse.y
+++ b/usr.sbin/jail/jailparse.y
@@ -1,6 +1,6 @@
%{
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 James Gritton
* All rights reserved.
@@ -28,8 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
+#include <err.h>
#include <stdlib.h>
#include <string.h>
@@ -38,11 +37,12 @@ __FBSDID("$FreeBSD$");
#ifdef DEBUG
#define YYDEBUG 1
#endif
+
+static struct cfjail *current_jail;
+static struct cfjail *global_jail;
%}
%union {
- struct cfjail *j;
- struct cfparams *pp;
struct cfparam *p;
struct cfstrings *ss;
struct cfstring *s;
@@ -52,55 +52,68 @@ __FBSDID("$FreeBSD$");
%token PLEQ
%token <cs> STR STR1 VAR VAR1
-%type <j> jail
-%type <pp> param_l
%type <p> param name
%type <ss> value
%type <s> string
+%pure-parser
+
+%lex-param { void *scanner }
+%parse-param { void *scanner }
+
%%
/*
- * A config file is a series of jails (containing parameters) and jail-less
- * parameters which really belong to a global pseudo-jail.
+ * A config file is a list of jails and parameters. Parameters are
+ * added to the current jail, otherwise to a global pesudo-jail.
*/
conf :
- ;
| conf jail
- ;
| conf param ';'
{
- struct cfjail *j;
+ if (!special_param($2, scanner)) {
+ struct cfjail *j = current_jail;
- j = TAILQ_LAST(&cfjails, cfjails);
- if (!j || strcmp(j->name, "*")) {
- j = add_jail();
- j->name = estrdup("*");
+ if (j == NULL) {
+ if (global_jail == NULL) {
+ global_jail = add_jail();
+ global_jail->name = estrdup("*");
+ }
+ j = global_jail;
+ }
+ TAILQ_INSERT_TAIL(&j->params, $2, tq);
}
- TAILQ_INSERT_TAIL(&j->params, $2, tq);
}
| conf ';'
+ ;
-jail : STR '{' param_l '}'
+jail : jail_name '{' conf '}'
{
- $$ = add_jail();
- $$->name = $1;
- TAILQ_CONCAT(&$$->params, $3, tq);
- free($3);
+ current_jail = current_jail->cfparent;
}
;
-param_l :
- {
- $$ = emalloc(sizeof(struct cfparams));
- TAILQ_INIT($$);
- }
- | param_l param ';'
+jail_name : STR
{
- $$ = $1;
- TAILQ_INSERT_TAIL($$, $2, tq);
+ struct cfjail *j = add_jail();
+
+ if (current_jail == NULL)
+ j->name = $1;
+ else {
+ /*
+ * A nested jail definition becomes
+ * a hierarchically-named sub-jail.
+ */
+ size_t parentlen = strlen(current_jail->name);
+ j->name = emalloc(parentlen + strlen($1) + 2);
+ strcpy(j->name, current_jail->name);
+ j->name[parentlen++] = '.';
+ strcpy(j->name + parentlen, $1);
+ free($1);
+ }
+ j->cfparent = current_jail;
+ current_jail = j;
}
- | param_l ';'
;
/*
@@ -128,11 +141,10 @@ param : name
{
$$ = $1;
TAILQ_CONCAT(&$$->val, $2, tq);
+ $$->flags |= PF_NAMEVAL;
free($2);
}
| error
- {
- }
;
/*
@@ -216,3 +228,49 @@ string : STR
;
%%
+
+extern int YYLEX_DECL();
+
+static void
+YYERROR_DECL()
+{
+ struct cflex *cflex = yyget_extra(scanner);
+
+ if (!yyget_text(scanner))
+ warnx("%s line %d: %s",
+ cflex->cfname, yyget_lineno(scanner), s);
+ else if (!yyget_text(scanner)[0])
+ warnx("%s: unexpected EOF",
+ cflex->cfname);
+ else
+ warnx("%s line %d: %s: %s",
+ cflex->cfname, yyget_lineno(scanner),
+ yyget_text(scanner), s);
+ cflex->error = 1;
+}
+
+/* Handle special parameters (i.e. the include directive).
+ * Return true if the parameter was specially handled.
+ */
+static int
+special_param(struct cfparam *p, void *scanner)
+{
+ if ((p->flags & (PF_VAR | PF_APPEND | PF_NAMEVAL)) != PF_NAMEVAL
+ || strcmp(p->name, ".include"))
+ return 0;
+ struct cfstring *s;
+ TAILQ_FOREACH(s, &p->val, tq) {
+ if (STAILQ_EMPTY(&s->vars))
+ include_config(scanner, s->s);
+ else {
+ warnx("%s line %d: "
+ "variables not permitted in '.include' filename",
+ yyget_extra(scanner)->cfname,
+ yyget_lineno(scanner));
+ yyget_extra(scanner)->error = 1;
+ }
+ }
+ free_param_strings(p);
+ free(p);
+ return 1;
+}
diff --git a/usr.sbin/jail/state.c b/usr.sbin/jail/state.c
index 2bb93d8054b2..1d200beacef9 100644
--- a/usr.sbin/jail/state.c
+++ b/usr.sbin/jail/state.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 James Gritton
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/uio.h>
#include <err.h>
@@ -308,7 +306,7 @@ start_state(const char *target, int docf, unsigned state, int running)
int jid;
char namebuf[MAXHOSTNAMELEN];
- if (!target || (!docf && state != JF_STOP) ||
+ if (!target || (!docf && (state & JF_OP_MASK) != JF_STOP) ||
(!running && !strcmp(target, "*"))) {
/*
* For a global wildcard (including no target specified),
@@ -367,7 +365,7 @@ start_state(const char *target, int docf, unsigned state, int running)
}
} else {
j = find_jail(target);
- if (j == NULL && state == JF_STOP) {
+ if (j == NULL && (state & JF_OP_MASK) == JF_STOP) {
/* Allow -[rR] to specify a currently running jail. */
j = running_jail(target, JAIL_DYING);
}
diff --git a/usr.sbin/jail/tests/Makefile b/usr.sbin/jail/tests/Makefile
index 216a5a581980..66f52faebaa9 100644
--- a/usr.sbin/jail/tests/Makefile
+++ b/usr.sbin/jail/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/usr.sbin/jail/tests/commands.jail.conf b/usr.sbin/jail/tests/commands.jail.conf
index 8787af49eba0..4ea24ec6b058 100644
--- a/usr.sbin/jail/tests/commands.jail.conf
+++ b/usr.sbin/jail/tests/commands.jail.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
exec.prestop = "echo STOP";
exec.prestart = "echo START";
diff --git a/usr.sbin/jail/tests/jail_basic_test.sh b/usr.sbin/jail/tests/jail_basic_test.sh
index ba691cb9b05a..a907e713ab9a 100755
--- a/usr.sbin/jail/tests/jail_basic_test.sh
+++ b/usr.sbin/jail/tests/jail_basic_test.sh
@@ -1,5 +1,5 @@
#
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2019 Michael Zhilin
#
@@ -24,8 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-# $FreeBSD$
-
atf_test_case "basic" "cleanup"
atf_test_case "nested" "cleanup"
atf_test_case "commands" "cleanup"
diff --git a/usr.sbin/jexec/Makefile b/usr.sbin/jexec/Makefile
index 3ecf5676dc55..89445c600a8a 100644
--- a/usr.sbin/jexec/Makefile
+++ b/usr.sbin/jexec/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= jexec
MAN= jexec.8
diff --git a/usr.sbin/jexec/Makefile.depend b/usr.sbin/jexec/Makefile.depend
index 98929049af54..a6495919e286 100644
--- a/usr.sbin/jexec/Makefile.depend
+++ b/usr.sbin/jexec/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/jexec/jexec.8 b/usr.sbin/jexec/jexec.8
index 8b28061c7037..4400cbbe56a3 100644
--- a/usr.sbin/jexec/jexec.8
+++ b/usr.sbin/jexec/jexec.8
@@ -23,9 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd April 24, 2016
+.Dd October 7, 2023
.Dt JEXEC 8
.Os
.Sh NAME
@@ -67,6 +65,44 @@ The user name from jailed environment as whom the
.Ar command
should run.
.El
+.Sh EXAMPLES
+.Ss Example 1 : Open a shell in a jail
+The following command specifies a jail by its name and utilizes the current
+user's shell:
+.Pp
+.Dl # jexec name
+.Pp
+It is also possible to specify a jail by its jid:
+.Pp
+.Dl # jexec JID
+.Ss Example 2 : Run a single command without opening a shell
+The following command runs
+.Ql uname -a
+in a jail called
+.Dq name .
+Since a command is specified explicitly,
+.Nm
+does not spawn an interactive shell.
+Instead,
+.Nm
+executes the specified command directly.
+.Pp
+.Dl # jexec name uname -a
+.Ss Example 3 : Open a shell in a jail with a clean environment
+The following command opens a
+.Xr sh 1
+shell in a jail with a clean environment:
+.Pp
+.Dl # jexec -l name sh
+.Ss Example 4 : Open a shell in a jail with the login command
+The following command utilizes
+.Xr login 1
+to access the jail, submitting an audit record, and displaying the
+user's last login, system copyright, and
+.Xr motd 5
+message:
+.Pp
+.Dl # jexec -l name login -f root
.Sh SEE ALSO
.Xr jail_attach 2 ,
.Xr jail 8 ,
diff --git a/usr.sbin/jexec/jexec.c b/usr.sbin/jexec/jexec.c
index 83a60816afd3..7a32efa34031 100644
--- a/usr.sbin/jexec/jexec.c
+++ b/usr.sbin/jexec/jexec.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
* Copyright (c) 2008 Bjoern A. Zeeb <bz@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$
*/
#include <sys/param.h>
diff --git a/usr.sbin/jls/Makefile b/usr.sbin/jls/Makefile
index 34a5023516cb..ffe5704859eb 100644
--- a/usr.sbin/jls/Makefile
+++ b/usr.sbin/jls/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/jls/Makefile.depend b/usr.sbin/jls/Makefile.depend
index d4d0b05e7f43..845d2b50241d 100644
--- a/usr.sbin/jls/Makefile.depend
+++ b/usr.sbin/jls/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -10,8 +8,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libjail \
- lib/libutil \
- lib/libxo \
+ lib/libxo/libxo \
.include <dirdeps.mk>
diff --git a/usr.sbin/jls/jls.8 b/usr.sbin/jls/jls.8
index fff1051c0114..1361d70b654b 100644
--- a/usr.sbin/jls/jls.8
+++ b/usr.sbin/jls/jls.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd July 20, 2012
.Dt JLS 8
.Os
diff --git a/usr.sbin/jls/jls.c b/usr.sbin/jls/jls.c
index 374ee14bf080..5c26965b045b 100644
--- a/usr.sbin/jls/jls.c
+++ b/usr.sbin/jls/jls.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
* Copyright (c) 2008 Bjoern A. Zeeb <bz@FreeBSD.org>
@@ -29,9 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/jail.h>
#include <sys/socket.h>
@@ -384,7 +381,10 @@ print_jail(int pflags, int jflags)
{
char *nname, *xo_nname;
char **param_values;
- int i, jid, n, spc;
+ int i, jid, spc;
+#if (defined INET || defined INET6)
+ int n;
+#endif
jid = jailparam_get(params, nparams, jflags);
if (jid < 0)
@@ -402,7 +402,9 @@ print_jail(int pflags, int jflags)
(char *)params[3].jp_value,
*(int *)params[4].jp_value ? "DYING" : "ACTIVE");
xo_emit("{P: }{:cpusetid/%d}\n", *(int *)params[5].jp_value);
+#if (defined INET || defined INET6)
n = 6;
+#endif
#ifdef INET
if (ip4_ok && !strcmp(params[n].jp_name, "ip4.addr")) {
emit_ip_addr_list(AF_INET, "ipv4_addrs", params + n);
diff --git a/usr.sbin/kbdcontrol/Makefile b/usr.sbin/kbdcontrol/Makefile
index 5a15ef3c9da6..982fa42e1564 100644
--- a/usr.sbin/kbdcontrol/Makefile
+++ b/usr.sbin/kbdcontrol/Makefile
@@ -1,5 +1,5 @@
-# $FreeBSD$
+PACKAGE= console-tools
PROG= kbdcontrol
MAN= kbdcontrol.1 kbdmap.5
MLINKS= kbdmap.5 keymap.5
@@ -8,4 +8,12 @@ SRCS= kbdcontrol.c lex.l
WARNS?= 4
CFLAGS+= -I${.CURDIR}
+.ifdef BOOTSTRAPPING
+# Provide minimal load and dump functionality
+CFLAGS+= -DBOOTSTRAP_KBDCONTROL
+.else
+# temporarily added for pre-Unicode accent key API/ABI compatibility
+CFLAGS+= -DCOMPAT_FREEBSD13
+.endif
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/kbdcontrol/Makefile.depend b/usr.sbin/kbdcontrol/Makefile.depend
index b3c7e9af13c7..6ef78fac5cbf 100644
--- a/usr.sbin/kbdcontrol/Makefile.depend
+++ b/usr.sbin/kbdcontrol/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 \
- usr.bin/lex/lib \
.include <dirdeps.mk>
diff --git a/usr.sbin/kbdcontrol/kbdcontrol.1 b/usr.sbin/kbdcontrol/kbdcontrol.1
index 17e9d118ea94..dcadf1b7414d 100644
--- a/usr.sbin/kbdcontrol/kbdcontrol.1
+++ b/usr.sbin/kbdcontrol/kbdcontrol.1
@@ -10,9 +10,6 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" @(#)kbdcontrol.1
-.\" $FreeBSD$
-.\"
.Dd March 16, 2016
.Dt KBDCONTROL 1
.Os
diff --git a/usr.sbin/kbdcontrol/kbdcontrol.c b/usr.sbin/kbdcontrol/kbdcontrol.c
index f4651acea840..e55165fd0888 100644
--- a/usr.sbin/kbdcontrol/kbdcontrol.c
+++ b/usr.sbin/kbdcontrol/kbdcontrol.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1994-1995 Søren Schmidt
* All rights reserved.
@@ -29,8 +29,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <err.h>
#include <stdio.h>
@@ -40,46 +38,36 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <sys/kbio.h>
#include <sys/consio.h>
+#include <sys/param.h>
#include <sys/queue.h>
#include <sys/sysctl.h>
#include "path.h"
#include "lex.h"
-/*
- * HALT, PDWN, and PASTE aren't defined in 4.x, but we need them to bridge
- * to 5.0-current so define them here as a stop gap transition measure.
- */
-#ifndef HALT
-#define HALT 0xa1 /* halt machine */
-#endif
-#ifndef PDWN
-#define PDWN 0xa2 /* halt machine and power down */
-#endif
-#ifndef PASTE
-#define PASTE 0xa3 /* paste from cut-paste buffer */
-#endif
-
#define SPECIAL 0x80000000
+#ifndef BOOTSTRAP_KBDCONTROL
static const char ctrl_names[32][4] = {
"nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
"bs ", "ht ", "nl ", "vt ", "ff ", "cr ", "so ", "si ",
"dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb",
"can", "em ", "sub", "esc", "fs ", "gs ", "rs ", "us "
};
+#endif
static const char acc_names[15][5] = {
"dgra", "dacu", "dcir", "dtil", "dmac", "dbre", "ddot",
- "duml", "dsla", "drin", "dced", "dapo", "ddac", "dogo",
+ "duml", "dsla", "drin", "dced", "dapo", "ddac", "dogo",
"dcar",
};
static const char acc_names_u[15][5] = {
"DGRA", "DACU", "DCIR", "DTIL", "DMAC", "DBRE", "DDOT",
- "DUML", "DSLA", "DRIN", "DCED", "DAPO", "DDAC", "DOGO",
+ "DUML", "DSLA", "DRIN", "DCED", "DAPO", "DDAC", "DOGO",
"DCAR",
};
+#ifndef BOOTSTRAP_KBDCONTROL
static const char fkey_table[96][MAXFK] = {
/* 01-04 */ "\033[M", "\033[N", "\033[O", "\033[P",
/* 05-08 */ "\033[Q", "\033[R", "\033[S", "\033[T",
@@ -106,15 +94,13 @@ static const char fkey_table[96][MAXFK] = {
/* 89-92 */ "" , "" , "" , "" ,
/* 93-96 */ "" , "" , "" , "" ,
};
+#endif
-static const int delays[] = {250, 500, 750, 1000};
-static const int repeats[] = { 34, 38, 42, 46, 50, 55, 59, 63,
- 68, 76, 84, 92, 100, 110, 118, 126,
- 136, 152, 168, 184, 200, 220, 236, 252,
- 272, 304, 336, 368, 400, 440, 472, 504};
-static const int ndelays = (sizeof(delays) / sizeof(int));
-static const int nrepeats = (sizeof(repeats) / sizeof(int));
+#ifndef BOOTSTRAP_KBDCONTROL
+static const int ndelays = nitems(kbdelays);
+static const int nrepeats = nitems(kbrates);
static int hex = 0;
+#endif
static int paths_configured = 0;
static int token;
@@ -129,9 +115,12 @@ static int get_accent_definition_line(accentmap_t *);
static int get_entry(void);
static int get_key_definition_line(keymap_t *);
static void load_keymap(char *opt, int dumponly);
+#ifndef BOOTSTRAP_KBDCONTROL
static void load_default_functionkeys(void);
+#endif
static char * nextarg(int ac, char **av, int *indp, int oc);
static char * mkfullname(const char *s1, const char *s2, const char *s3);
+#ifndef BOOTSTRAP_KBDCONTROL
static void print_accent_definition_line(FILE *fp, int accent,
struct acc_t *key);
static void print_entry(FILE *fp, int value);
@@ -145,6 +134,7 @@ static void set_functionkey(char *keynumstr, char *string);
static void set_keyboard(char *device);
static void set_keyrates(char *opt);
static void show_kbd_info(void);
+#endif
static void usage(void) __dead2;
struct pathent {
@@ -153,6 +143,7 @@ struct pathent {
};
static STAILQ_HEAD(, pathent) pathlist = STAILQ_HEAD_INITIALIZER(pathlist);
+#ifndef BOOTSTRAP_KBDCONTROL
/* Detect presence of vt(4). */
static int
is_vt4(void)
@@ -164,6 +155,7 @@ is_vt4(void)
return (0);
return (strcmp(vty_name, "vt") == 0);
}
+#endif
static char *
nextarg(int ac, char **av, int *indp, int oc)
@@ -298,7 +290,7 @@ get_definition_line(FILE *file, keymap_t *keymap, accentmap_t *accentmap)
if (token < 0)
token = yylex();
- switch (token) {
+ switch (token) {
case TNUM:
c = get_key_definition_line(keymap);
if (c < 0)
@@ -410,6 +402,7 @@ get_accent_definition_line(accentmap_t *map)
return (accent + 1);
}
+#ifndef BOOTSTRAP_KBDCONTROL
static void
print_entry(FILE *fp, int value)
{
@@ -610,6 +603,7 @@ print_accent_definition_line(FILE *fp, int accent, struct acc_t *key)
}
fprintf(fp, "\n");
}
+#endif
static void
dump_entry(int value)
@@ -751,7 +745,7 @@ dump_key_definition(char *name, keymap_t *keymap)
dump_entry(keymap->key[i].map[j]);
}
printf("}, 0x%02X,0x%02X },\n",
- (unsigned)keymap->key[i].spcl,
+ (unsigned)keymap->key[i].spcl,
(unsigned)keymap->key[i].flgs);
}
printf("} };\n\n");
@@ -764,7 +758,7 @@ dump_accent_definition(char *name, accentmap_t *accentmap)
int c;
printf("static accentmap_t accentmap_%s = { %d",
- name, accentmap->n_accs);
+ name, accentmap->n_accs);
if (accentmap->n_accs <= 0) {
printf(" };\n\n");
return;
@@ -785,7 +779,7 @@ dump_accent_definition(char *name, accentmap_t *accentmap)
} else
printf(" 0x%02x, {", c);
for (j = 0; j < NUM_ACCENTCHARS; j++) {
- c = accentmap->acc[i].map[j][0];
+ c = accentmap->acc[i].map[j][0];
if (c == 0)
break;
if ((j > 0) && ((j % 4) == 0))
@@ -793,7 +787,7 @@ dump_accent_definition(char *name, accentmap_t *accentmap)
if (isascii(c) && isprint(c))
printf(" { '%c',", c);
else
- printf(" { 0x%02x,", c);
+ printf(" { 0x%02x,", c);
printf("0x%02x },", accentmap->acc[i].map[j][1]);
}
printf(" }, },\n");
@@ -818,11 +812,31 @@ add_keymap_path(const char *path)
STAILQ_INSERT_TAIL(&pathlist, pe, next);
}
+#ifdef OPIO_DEADKEYMAP
+static void
+to_old_accentmap(accentmap_t *from, oaccentmap_t *to)
+{
+ int i, j;
+
+ to->n_accs = from->n_accs;
+ for (i = 0; i < NUM_DEADKEYS; i++) {
+ for (j = 0; j < NUM_ACCENTCHARS; j++) {
+ to->acc[i].map[j][0] = from->acc[i].map[j][0];
+ to->acc[i].map[j][1] = from->acc[i].map[j][1];
+ to->acc[i].accchar = from->acc[i].accchar;
+ }
+ }
+}
+#endif /* OPIO_DEADKEYMAP */
+
static void
load_keymap(char *opt, int dumponly)
{
keymap_t keymap;
accentmap_t accentmap;
+#ifdef OPIO_DEADKEYMAP
+ oaccentmap_t oaccentmap;
+#endif /* OPIO_DEADKEYMAP */
struct pathent *pe;
FILE *file;
int j;
@@ -836,10 +850,12 @@ load_keymap(char *opt, int dumponly)
if (cp != NULL)
add_keymap_path(cp);
add_keymap_path("");
+#ifndef BOOTSTRAP_KBDCONTROL
if (is_vt4())
add_keymap_path(vt_keymap_path);
else
add_keymap_path(keymap_path);
+#endif
paths_configured = 1;
}
@@ -875,30 +891,65 @@ load_keymap(char *opt, int dumponly)
dump_accent_definition(opt, &accentmap);
return;
}
+#ifndef BOOTSTRAP_KBDCONTROL
if ((keymap.n_keys > 0) && (ioctl(0, PIO_KEYMAP, &keymap) < 0)) {
warn("setting keymap");
fclose(file);
return;
}
- if ((accentmap.n_accs > 0)
- && (ioctl(0, PIO_DEADKEYMAP, &accentmap) < 0)) {
- warn("setting accentmap");
- fclose(file);
- return;
+ if ((accentmap.n_accs > 0)
+ && (ioctl(0, PIO_DEADKEYMAP, &accentmap) < 0)) {
+#ifdef OPIO_DEADKEYMAP
+ to_old_accentmap(&accentmap, &oaccentmap);
+ if (ioctl(0, OPIO_DEADKEYMAP, &oaccentmap) < 0)
+#endif /* OGIO_DEADKEYMAP */
+ {
+ warn("setting accentmap");
+ fclose(file);
+ return;
+ }
}
+#endif
}
+#ifdef OPIO_DEADKEYMAP
+static void
+to_new_accentmap(oaccentmap_t *from, accentmap_t *to)
+{
+ int i, j;
+
+ to->n_accs = from->n_accs;
+ for (i = 0; i < NUM_DEADKEYS; i++) {
+ for (j = 0; j < NUM_ACCENTCHARS; j++) {
+ to->acc[i].map[j][0] = from->acc[i].map[j][0];
+ to->acc[i].map[j][1] = from->acc[i].map[j][1];
+ to->acc[i].accchar = from->acc[i].accchar;
+ }
+ }
+}
+#endif /* OPIO_DEADKEYMAP */
+
+#ifndef BOOTSTRAP_KBDCONTROL
static void
print_keymap(void)
{
keymap_t keymap;
accentmap_t accentmap;
+#ifdef OGIO_DEADKEYMAP
+ oaccentmap_t oaccentmap;
+#endif /* OPIO_DEADKEYMAP */
int i;
if (ioctl(0, GIO_KEYMAP, &keymap) < 0)
err(1, "getting keymap");
- if (ioctl(0, GIO_DEADKEYMAP, &accentmap) < 0)
- memset(&accentmap, 0, sizeof(accentmap));
+ if (ioctl(0, GIO_DEADKEYMAP, &accentmap) < 0) {
+#ifdef OGIO_DEADKEYMAP
+ if (ioctl(0, OGIO_DEADKEYMAP, &oaccentmap) == 0)
+ to_new_accentmap(&oaccentmap, &accentmap);
+ else
+#endif /* OGIO_DEADKEYMAP */
+ memset(&accentmap, 0, sizeof(accentmap));
+ }
printf(
"# alt\n"
"# scan cntrl alt alt cntrl lock\n"
@@ -1006,14 +1057,20 @@ set_keyrates(char *opt)
int r, d;
if (!strcmp(opt, "slow")) {
- delay = 1000, repeat = 500;
- d = 3, r = 31;
+ delay = 1000;
+ repeat = 504;
+ d = 3;
+ r = 31;
} else if (!strcmp(opt, "normal")) {
- delay = 500, repeat = 125;
- d = 1, r = 15;
+ delay = 500;
+ repeat = 126;
+ d = 1;
+ r = 15;
} else if (!strcmp(opt, "fast")) {
- delay = repeat = 0;
- d = r = 0;
+ delay = 0;
+ repeat = 0;
+ d = 0;
+ r = 0;
} else {
int n;
char *v1;
@@ -1029,11 +1086,11 @@ badopt:
return;
}
for (n = 0; n < ndelays - 1; n++)
- if (delay <= delays[n])
+ if (delay <= kbdelays[n])
break;
d = n;
for (n = 0; n < nrepeats - 1; n++)
- if (repeat <= repeats[n])
+ if (repeat <= kbrates[n])
break;
r = n;
}
@@ -1041,6 +1098,7 @@ badopt:
arg[0] = delay;
arg[1] = repeat;
if (ioctl(0, KDSETREPEAT, arg)) {
+ warn("fallback, setting keyboard rate via legacy interface (KDSETRAD), will be removed soon");
if (ioctl(0, KDSETRAD, (d << 5) | r))
warn("setting keyboard rate");
}
@@ -1099,7 +1157,7 @@ set_keyboard(char *device)
}
/*
* The keyboard device driver won't release the keyboard by
- * the following ioctl, but it automatically will, when the device
+ * the following ioctl, but it automatically will, when the device
* is closed. So, we don't check error here.
*/
ioctl(fd, CONS_RELKBD, 0);
@@ -1201,14 +1259,20 @@ mux_keyboard(u_int op, char *kbd)
if (ioctl(0, op, &info) == -1)
warn("unable to (un)mux the keyboard");
}
+#endif
static void
usage(void)
{
+#ifdef BOOTSTRAP_KBDCONTROL
+ fprintf(stderr, "%s\n",
+"usage: kbdcontrol [-L mapfile] [-P path]");
+#else
fprintf(stderr, "%s\n%s\n%s\n",
"usage: kbdcontrol [-dFKix] [-A name] [-a name] [-b duration.pitch | [quiet.]belltype]",
" [-r delay.repeat | speed] [-l mapfile] [-f # string]",
" [-k device] [-L mapfile] [-P path]");
+#endif
exit(1);
}
@@ -1216,7 +1280,11 @@ usage(void)
int
main(int argc, char **argv)
{
+#ifdef BOOTSTRAP_KBDCONTROL
+ const char *optstring = "L:P:";
+#else
const char *optstring = "A:a:b:df:iKk:Fl:L:P:r:x";
+#endif
int opt;
/* Collect any -P arguments, regardless of where they appear. */
@@ -1230,6 +1298,7 @@ main(int argc, char **argv)
optind = optreset = 1;
while ((opt = getopt(argc, argv, optstring)) != -1)
switch(opt) {
+#ifndef BOOTSTRAP_KBDCONTROL
case 'A':
case 'a':
mux_keyboard((opt == 'A')? KBRELKBD : KBADDKBD, optarg);
@@ -1243,11 +1312,13 @@ main(int argc, char **argv)
case 'l':
load_keymap(optarg, 0);
break;
+#endif
case 'L':
load_keymap(optarg, 1);
break;
case 'P':
break;
+#ifndef BOOTSTRAP_KBDCONTROL
case 'f':
set_functionkey(optarg,
nextarg(argc, argv, &optind, 'f'));
@@ -1270,6 +1341,7 @@ main(int argc, char **argv)
case 'x':
hex = 1;
break;
+#endif
default:
usage();
}
diff --git a/usr.sbin/kbdcontrol/kbdmap.5 b/usr.sbin/kbdcontrol/kbdmap.5
index fda2ada5a4f4..abd91ce87995 100644
--- a/usr.sbin/kbdcontrol/kbdmap.5
+++ b/usr.sbin/kbdcontrol/kbdmap.5
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 2, 2016
.Dt KBDMAP 5
.Os
diff --git a/usr.sbin/kbdcontrol/lex.h b/usr.sbin/kbdcontrol/lex.h
index a852a30bd3c0..3c28b8622979 100644
--- a/usr.sbin/kbdcontrol/lex.h
+++ b/usr.sbin/kbdcontrol/lex.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1994-1995 Søren Schmidt
* All rights reserved.
@@ -26,8 +26,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$
*/
#define TNOP 256
diff --git a/usr.sbin/kbdcontrol/lex.l b/usr.sbin/kbdcontrol/lex.l
index 0568758d3708..6ce1007bd622 100644
--- a/usr.sbin/kbdcontrol/lex.l
+++ b/usr.sbin/kbdcontrol/lex.l
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1994-1995 Søren Schmidt
* All rights reserved.
@@ -26,8 +26,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$
*/
%{
diff --git a/usr.sbin/kbdcontrol/path.h b/usr.sbin/kbdcontrol/path.h
index e1fa341e0c78..12ea4a5b3f66 100644
--- a/usr.sbin/kbdcontrol/path.h
+++ b/usr.sbin/kbdcontrol/path.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#define KEYMAP_PATH "/usr/share/syscons/keymaps/"
#define FONT_PATH "/usr/share/syscons/fonts/"
diff --git a/usr.sbin/kbdmap/Makefile b/usr.sbin/kbdmap/Makefile
index 22747e70720c..d1957485830d 100644
--- a/usr.sbin/kbdmap/Makefile
+++ b/usr.sbin/kbdmap/Makefile
@@ -1,5 +1,5 @@
-# $FreeBSD$
+PACKAGE= console-tools
PROG= kbdmap
CFLAGS+= -I${SRCTOP}/contrib/bsddialog/lib
LIBADD= bsddialog
diff --git a/usr.sbin/kbdmap/Makefile.depend b/usr.sbin/kbdmap/Makefile.depend
index 6cfaab1c3644..63fe0b5e1069 100644
--- a/usr.sbin/kbdmap/Makefile.depend
+++ b/usr.sbin/kbdmap/Makefile.depend
@@ -1,11 +1,10 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
+ lib/libbsddialog \
lib/libc \
lib/libcompiler_rt \
diff --git a/usr.sbin/kbdmap/TODO b/usr.sbin/kbdmap/TODO
index cef30f79ba1b..039e92fb0250 100644
--- a/usr.sbin/kbdmap/TODO
+++ b/usr.sbin/kbdmap/TODO
@@ -1,4 +1,3 @@
-$FreeBSD$
o remember some hackers to translate Languages.phrases into
Norwegian, Russian, Danish, Swedish
diff --git a/usr.sbin/kbdmap/kbdmap.1 b/usr.sbin/kbdmap/kbdmap.1
index 5d4cf0ed4aa0..4c7f01d84745 100644
--- a/usr.sbin/kbdmap/kbdmap.1
+++ b/usr.sbin/kbdmap/kbdmap.1
@@ -21,8 +21,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$
.Dd July 3, 2002
.Dt KBDMAP 1
.Os
diff --git a/usr.sbin/kbdmap/kbdmap.c b/usr.sbin/kbdmap/kbdmap.c
index 0702c1e66e94..75663ad87ff3 100644
--- a/usr.sbin/kbdmap/kbdmap.c
+++ b/usr.sbin/kbdmap/kbdmap.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002 Jonathan Belson <jon@witchspace.com>
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/sysctl.h>
@@ -401,8 +398,7 @@ show_dialog(struct keymap **km_sorted, int num_keymaps)
case BSDDIALOG_OK:
for (i = 0; i < num_keymaps; i++) {
if (listitems[i].on) {
- printf("ici\n");
- if (!strcmp(program, "kdbmap"))
+ if (!strcmp(program, "kbdmap"))
do_kbdcontrol(km_sorted[i]);
else
do_vidfont(km_sorted[i]);
@@ -411,7 +407,6 @@ show_dialog(struct keymap **km_sorted, int num_keymaps)
}
break;
default:
- printf("la\n");
if (font != NULL && strcmp(font, font_current))
/* Cancelled, restore old font */
vidcontrol(font_current);
diff --git a/usr.sbin/kbdmap/kbdmap.h b/usr.sbin/kbdmap/kbdmap.h
index 1d33b9ab9d50..932cc4b6aaab 100644
--- a/usr.sbin/kbdmap/kbdmap.h
+++ b/usr.sbin/kbdmap/kbdmap.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002 Jonathan Belson <jon@witchspace.com>
* 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$
*/
diff --git a/usr.sbin/keyserv/Makefile b/usr.sbin/keyserv/Makefile
index 367919271ee8..18eee0701606 100644
--- a/usr.sbin/keyserv/Makefile
+++ b/usr.sbin/keyserv/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= keyserv
MAN= keyserv.8
diff --git a/usr.sbin/keyserv/Makefile.depend b/usr.sbin/keyserv/Makefile.depend
index 97ec617dcc81..67fb1e963614 100644
--- a/usr.sbin/keyserv/Makefile.depend
+++ b/usr.sbin/keyserv/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/rpc \
include/rpcsvc \
diff --git a/usr.sbin/keyserv/crypt_server.c b/usr.sbin/keyserv/crypt_server.c
index a97c2e1904b3..99ce8b8bf1af 100644
--- a/usr.sbin/keyserv/crypt_server.c
+++ b/usr.sbin/keyserv/crypt_server.c
@@ -42,11 +42,6 @@
#include <rpc/des.h>
#include "crypt.h"
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
/*
* The U.S. government stupidly believes that a) it can keep strong
* crypto code a secret and b) that doing so somehow protects national
@@ -143,10 +138,7 @@ static void swap_byte(unsigned char *a, unsigned char *b)
}
/* Dummy _des_crypt function that uses ARCFOUR with a 40 bit key */
-int _arcfour_crypt(buf, len, desp)
- char *buf;
- int len;
- struct desparams *desp;
+int _arcfour_crypt(char *buf, int len, struct desparams *desp)
{
struct arcfour_key arcfourk;
@@ -174,9 +166,7 @@ static void *dlhandle;
#define LIBCRYPTO "libcrypto.so.2"
#endif
-void load_des(warn, libpath)
- int warn;
- char *libpath;
+void load_des(int warn, char *libpath)
{
char dlpath[MAXPATHLEN];
@@ -206,8 +196,6 @@ void load_des(warn, libpath)
printf ("Using %s shared object.\n", dlpath);
}
}
-
- return;
}
desresp *
diff --git a/usr.sbin/keyserv/keyserv.8 b/usr.sbin/keyserv/keyserv.8
index 726f91cc00c4..f067c421a333 100644
--- a/usr.sbin/keyserv/keyserv.8
+++ b/usr.sbin/keyserv/keyserv.8
@@ -1,8 +1,5 @@
-.\" @(#)keyserv.1m 1.21 93/07/14 SMI; from SVr4
.\"macro stdmacro
.\" Copyright 1989 AT&T
-.\" @(#)keyserv.8c 1.8 89/03/29 SMI;
-.\" $FreeBSD$
.\".TH KEYSERV 8C "9 September 1987"
.Dd September 14, 1992
.Dt KEYSERV 8
@@ -17,6 +14,10 @@
.Op Fl n
.Op Fl p Ar path
.Op Fl v
+.Sh DEPRECATION NOTICE
+.Nm
+is deprecated and is not available as of
+.Fx 15.0.
.Sh DESCRIPTION
The
.Nm
diff --git a/usr.sbin/keyserv/keyserv.c b/usr.sbin/keyserv/keyserv.c
index 051521636ce7..080798ad84bd 100644
--- a/usr.sbin/keyserv/keyserv.c
+++ b/usr.sbin/keyserv/keyserv.c
@@ -27,14 +27,6 @@
* Mountain View, California 94043
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)keyserv.c 1.15 94/04/25 SMI";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
/*
* Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
*/
@@ -83,9 +75,8 @@ static int debugging = 1;
static int debugging = 0;
#endif
-static void keyprogram();
+static void keyprogram(struct svc_req *rqstp, SVCXPRT *transp);
static des_block masterkey;
-char *getenv();
static char ROOTKEY[] = "/etc/.rootkey";
/*
@@ -107,9 +98,7 @@ cryptkeyres *key_decrypt_pk_2_svc_prog( uid_t, cryptkeyarg2 * );
des_block *key_gen_1_svc_prog( void *, struct svc_req * );
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int nflag = 0;
int c;
@@ -221,8 +210,7 @@ main(argc, argv)
* randomize the master key the best we can
*/
static void
-randomize(master)
- des_block *master;
+randomize(des_block *master)
{
master->key.low = arc4random();
master->key.high = arc4random();
@@ -234,9 +222,7 @@ randomize(master)
* Returns 1 on success.
*/
static int
-getrootkey(master, prompt)
- des_block *master;
- int prompt;
+getrootkey(des_block *master, int prompt)
{
char *passwd;
char name[MAXNETNAMELEN + 1];
@@ -306,8 +292,7 @@ getrootkey(master, prompt)
* Procedures to implement RPC service
*/
char *
-strstatus(status)
- keystatus status;
+strstatus(keystatus status)
{
switch (status) {
case KEY_SUCCESS:
@@ -324,9 +309,7 @@ strstatus(status)
}
keystatus *
-key_set_1_svc_prog(uid, key)
- uid_t uid;
- keybuf key;
+key_set_1_svc_prog(uid_t uid, keybuf key)
{
static keystatus status;
@@ -343,9 +326,7 @@ key_set_1_svc_prog(uid, key)
}
cryptkeyres *
-key_encrypt_pk_2_svc_prog(uid, arg)
- uid_t uid;
- cryptkeyarg2 *arg;
+key_encrypt_pk_2_svc_prog(uid_t uid, cryptkeyarg2 *arg)
{
static cryptkeyres res;
@@ -371,9 +352,7 @@ key_encrypt_pk_2_svc_prog(uid, arg)
}
cryptkeyres *
-key_decrypt_pk_2_svc_prog(uid, arg)
- uid_t uid;
- cryptkeyarg2 *arg;
+key_decrypt_pk_2_svc_prog(uid_t uid, cryptkeyarg2 *arg)
{
static cryptkeyres res;
@@ -399,9 +378,7 @@ key_decrypt_pk_2_svc_prog(uid, arg)
}
keystatus *
-key_net_put_2_svc_prog(uid, arg)
- uid_t uid;
- key_netstarg *arg;
+key_net_put_2_svc_prog(uid_t uid, key_netstarg *arg)
{
static keystatus status;
@@ -423,9 +400,7 @@ key_net_put_2_svc_prog(uid, arg)
}
key_netstres *
-key_net_get_2_svc_prog(uid, arg)
- uid_t uid;
- void *arg;
+key_net_get_2_svc_prog(uid_t uid, void *arg)
{
static key_netstres keynetname;
@@ -452,9 +427,7 @@ key_net_get_2_svc_prog(uid, arg)
}
cryptkeyres *
-key_get_conv_2_svc_prog(uid, arg)
- uid_t uid;
- keybuf arg;
+key_get_conv_2_svc_prog(uid_t uid, keybuf arg)
{
static cryptkeyres res;
@@ -480,9 +453,7 @@ key_get_conv_2_svc_prog(uid, arg)
cryptkeyres *
-key_encrypt_1_svc_prog(uid, arg)
- uid_t uid;
- cryptkeyarg *arg;
+key_encrypt_1_svc_prog(uid_t uid, cryptkeyarg *arg)
{
static cryptkeyres res;
@@ -508,9 +479,7 @@ key_encrypt_1_svc_prog(uid, arg)
}
cryptkeyres *
-key_decrypt_1_svc_prog(uid, arg)
- uid_t uid;
- cryptkeyarg *arg;
+key_decrypt_1_svc_prog(uid_t uid, cryptkeyarg *arg)
{
static cryptkeyres res;
@@ -537,9 +506,7 @@ key_decrypt_1_svc_prog(uid, arg)
/* ARGSUSED */
des_block *
-key_gen_1_svc_prog(v, s)
- void *v;
- struct svc_req *s;
+key_gen_1_svc_prog(void *v, struct svc_req *s)
{
struct timeval time;
static des_block keygen;
@@ -561,9 +528,7 @@ key_gen_1_svc_prog(v, s)
}
getcredres *
-key_getcred_1_svc_prog(uid, name)
- uid_t uid;
- netnamestr *name;
+key_getcred_1_svc_prog(uid_t uid, netnamestr *name)
{
static getcredres res;
static u_int gids[NGROUPS];
@@ -594,9 +559,7 @@ key_getcred_1_svc_prog(uid, name)
* RPC boilerplate
*/
static void
-keyprogram(rqstp, transp)
- struct svc_req *rqstp;
- SVCXPRT *transp;
+keyprogram(struct svc_req *rqstp, SVCXPRT *transp)
{
union {
keybuf key_set_1_arg;
@@ -613,7 +576,8 @@ keyprogram(rqstp, transp)
} argument;
char *result;
xdrproc_t xdr_argument, xdr_result;
- char *(*local) ();
+ typedef void *(svc_cb)(uid_t uid, void *arg);
+ svc_cb *local;
uid_t uid = -1;
int check_auth;
@@ -625,49 +589,49 @@ keyprogram(rqstp, transp)
case KEY_SET:
xdr_argument = (xdrproc_t)xdr_keybuf;
xdr_result = (xdrproc_t)xdr_int;
- local = (char *(*)()) key_set_1_svc_prog;
+ local = (svc_cb *)key_set_1_svc_prog;
check_auth = 1;
break;
case KEY_ENCRYPT:
xdr_argument = (xdrproc_t)xdr_cryptkeyarg;
xdr_result = (xdrproc_t)xdr_cryptkeyres;
- local = (char *(*)()) key_encrypt_1_svc_prog;
+ local = (svc_cb *)key_encrypt_1_svc_prog;
check_auth = 1;
break;
case KEY_DECRYPT:
xdr_argument = (xdrproc_t)xdr_cryptkeyarg;
xdr_result = (xdrproc_t)xdr_cryptkeyres;
- local = (char *(*)()) key_decrypt_1_svc_prog;
+ local = (svc_cb *)key_decrypt_1_svc_prog;
check_auth = 1;
break;
case KEY_GEN:
xdr_argument = (xdrproc_t)xdr_void;
xdr_result = (xdrproc_t)xdr_des_block;
- local = (char *(*)()) key_gen_1_svc_prog;
+ local = (svc_cb *)key_gen_1_svc_prog;
check_auth = 0;
break;
case KEY_GETCRED:
xdr_argument = (xdrproc_t)xdr_netnamestr;
xdr_result = (xdrproc_t)xdr_getcredres;
- local = (char *(*)()) key_getcred_1_svc_prog;
+ local = (svc_cb *)key_getcred_1_svc_prog;
check_auth = 0;
break;
case KEY_ENCRYPT_PK:
xdr_argument = (xdrproc_t)xdr_cryptkeyarg2;
xdr_result = (xdrproc_t)xdr_cryptkeyres;
- local = (char *(*)()) key_encrypt_pk_2_svc_prog;
+ local = (svc_cb *)key_encrypt_pk_2_svc_prog;
check_auth = 1;
break;
case KEY_DECRYPT_PK:
xdr_argument = (xdrproc_t)xdr_cryptkeyarg2;
xdr_result = (xdrproc_t)xdr_cryptkeyres;
- local = (char *(*)()) key_decrypt_pk_2_svc_prog;
+ local = (svc_cb *)key_decrypt_pk_2_svc_prog;
check_auth = 1;
break;
@@ -675,21 +639,21 @@ keyprogram(rqstp, transp)
case KEY_NET_PUT:
xdr_argument = (xdrproc_t)xdr_key_netstarg;
xdr_result = (xdrproc_t)xdr_keystatus;
- local = (char *(*)()) key_net_put_2_svc_prog;
+ local = (svc_cb *)key_net_put_2_svc_prog;
check_auth = 1;
break;
case KEY_NET_GET:
xdr_argument = (xdrproc_t) xdr_void;
xdr_result = (xdrproc_t)xdr_key_netstres;
- local = (char *(*)()) key_net_get_2_svc_prog;
+ local = (svc_cb *)key_net_get_2_svc_prog;
check_auth = 1;
break;
case KEY_GET_CONV:
xdr_argument = (xdrproc_t) xdr_keybuf;
xdr_result = (xdrproc_t)xdr_cryptkeyres;
- local = (char *(*)()) key_get_conv_2_svc_prog;
+ local = (svc_cb *)key_get_conv_2_svc_prog;
check_auth = 1;
break;
@@ -734,13 +698,10 @@ keyprogram(rqstp, transp)
"unable to free arguments\n");
exit(1);
}
- return;
}
static int
-root_auth(trans, rqstp)
- SVCXPRT *trans;
- struct svc_req *rqstp;
+root_auth(SVCXPRT *trans, struct svc_req *rqstp)
{
uid_t uid;
struct sockaddr *remote;
@@ -782,7 +743,7 @@ root_auth(trans, rqstp)
}
static void
-usage()
+usage(void)
{
(void) fprintf(stderr,
"usage: keyserv [-n] [-D] [-d] [-v] [-p path]\n");
diff --git a/usr.sbin/keyserv/keyserv.h b/usr.sbin/keyserv/keyserv.h
index 07e4ab6efa8e..7eb5b4bae29f 100644
--- a/usr.sbin/keyserv/keyserv.h
+++ b/usr.sbin/keyserv/keyserv.h
@@ -1,5 +1,4 @@
/*
- * $FreeBSD$
*/
extern void setmodulus(char *modx);
diff --git a/usr.sbin/keyserv/setkey.c b/usr.sbin/keyserv/setkey.c
index a11d04d4babe..ec263ebf5321 100644
--- a/usr.sbin/keyserv/setkey.c
+++ b/usr.sbin/keyserv/setkey.c
@@ -27,14 +27,6 @@
* Mountain View, California 94043
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)setkey.c 1.11 94/04/25 SMI";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
/*
* Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
*/
@@ -72,7 +64,7 @@ static int nodefaultkeys = 0;
* prohibit the nobody key on this machine k (the -d flag)
*/
void
-pk_nodefaultkeys()
+pk_nodefaultkeys(void)
{
nodefaultkeys = 1;
}
@@ -81,8 +73,7 @@ pk_nodefaultkeys()
* Set the modulus for all our Diffie-Hellman operations
*/
void
-setmodulus(modx)
- char *modx;
+setmodulus(char *modx)
{
MODULUS = mp_xtom(modx);
}
@@ -91,9 +82,7 @@ setmodulus(modx)
* Set the secretkey key for this uid
*/
keystatus
-pk_setkey(uid, skey)
- uid_t uid;
- keybuf skey;
+pk_setkey(uid_t uid, keybuf skey)
{
if (!storesecretkey(uid, skey)) {
return (KEY_SYSTEMERR);
@@ -106,11 +95,7 @@ pk_setkey(uid, skey)
* secret key associated with uid.
*/
keystatus
-pk_encrypt(uid, remote_name, remote_key, key)
- uid_t uid;
- char *remote_name;
- netobj *remote_key;
- des_block *key;
+pk_encrypt(uid_t uid, char *remote_name, netobj *remote_key, des_block *key)
{
return (pk_crypt(uid, remote_name, remote_key, key, DES_ENCRYPT));
}
@@ -120,11 +105,7 @@ pk_encrypt(uid, remote_name, remote_key, key)
* secret key associated with uid.
*/
keystatus
-pk_decrypt(uid, remote_name, remote_key, key)
- uid_t uid;
- char *remote_name;
- netobj *remote_key;
- des_block *key;
+pk_decrypt(uid_t uid, char *remote_name, netobj *remote_key, des_block *key)
{
return (pk_crypt(uid, remote_name, remote_key, key, DES_DECRYPT));
}
@@ -133,9 +114,7 @@ static int store_netname( uid_t, key_netstarg * );
static int fetch_netname( uid_t, key_netstarg * );
keystatus
-pk_netput(uid, netstore)
- uid_t uid;
- key_netstarg *netstore;
+pk_netput(uid_t uid, key_netstarg *netstore)
{
if (!store_netname(uid, netstore)) {
return (KEY_SYSTEMERR);
@@ -144,9 +123,7 @@ pk_netput(uid, netstore)
}
keystatus
-pk_netget(uid, netstore)
- uid_t uid;
- key_netstarg *netstore;
+pk_netget(uid_t uid, key_netstarg *netstore)
{
if (!fetch_netname(uid, netstore)) {
return (KEY_SYSTEMERR);
@@ -159,12 +136,8 @@ pk_netget(uid, netstore)
* Do the work of pk_encrypt && pk_decrypt
*/
static keystatus
-pk_crypt(uid, remote_name, remote_key, key, mode)
- uid_t uid;
- char *remote_name;
- netobj *remote_key;
- des_block *key;
- int mode;
+pk_crypt(uid_t uid, char *remote_name, netobj *remote_key, des_block *key,
+ int mode)
{
char *xsecret;
char xpublic[1024];
@@ -221,10 +194,7 @@ pk_crypt(uid, remote_name, remote_key, key, mode)
}
keystatus
-pk_get_conv_key(uid, xpublic, result)
- uid_t uid;
- keybuf xpublic;
- cryptkeyres *result;
+pk_get_conv_key(uid_t uid, keybuf xpublic, cryptkeyres *result)
{
char *xsecret;
char xsecret_hold[1024];
@@ -271,9 +241,7 @@ pk_get_conv_key(uid, xpublic, result)
* overwriting the lower order bits by setting parity.
*/
static void
-extractdeskey(ck, deskey)
- MINT *ck;
- des_block *deskey;
+extractdeskey(MINT *ck, des_block *deskey)
{
MINT *a;
short r;
@@ -320,9 +288,7 @@ static struct secretkey_netname_list *g_secretkey_netname;
* Store the keys and netname for this uid
*/
static int
-store_netname(uid, netstore)
- uid_t uid;
- key_netstarg *netstore;
+store_netname(uid_t uid, key_netstarg *netstore)
{
struct secretkey_netname_list *new;
struct secretkey_netname_list **l;
@@ -361,9 +327,7 @@ store_netname(uid, netstore)
*/
static int
-fetch_netname(uid, key_netst)
- uid_t uid;
- struct key_netstarg *key_netst;
+fetch_netname(uid_t uid, struct key_netstarg *key_netst)
{
struct secretkey_netname_list *l;
@@ -389,8 +353,7 @@ fetch_netname(uid, key_netst)
}
static char *
-fetchsecretkey(uid)
- uid_t uid;
+fetchsecretkey(uid_t uid)
{
struct secretkey_netname_list *l;
@@ -406,9 +369,7 @@ fetchsecretkey(uid)
* Store the secretkey for this uid
*/
static int
-storesecretkey(uid, key)
- uid_t uid;
- keybuf key;
+storesecretkey(uid_t uid, keybuf key)
{
struct secretkey_netname_list *new;
struct secretkey_netname_list **l;
@@ -437,17 +398,13 @@ storesecretkey(uid, key)
}
static int
-hexdigit(val)
- int val;
+hexdigit(int val)
{
return ("0123456789abcdef"[val]);
}
void
-bin2hex(bin, hex, size)
- unsigned char *bin;
- unsigned char *hex;
- int size;
+bin2hex(unsigned char *bin, unsigned char *hex, int size)
{
int i;
@@ -458,8 +415,7 @@ bin2hex(bin, hex, size)
}
static int
-hexval(dig)
- char dig;
+hexval(char dig)
{
if ('0' <= dig && dig <= '9') {
return (dig - '0');
@@ -473,10 +429,7 @@ hexval(dig)
}
void
-hex2bin(hex, bin, size)
- unsigned char *hex;
- unsigned char *bin;
- int size;
+hex2bin(unsigned char *hex, unsigned char *bin, int size)
{
int i;
@@ -501,10 +454,7 @@ static struct cachekey_list *g_cachedkeys;
* cache result of expensive multiple precision exponential operation
*/
static void
-writecache(pub, sec, deskey)
- char *pub;
- char *sec;
- des_block *deskey;
+writecache(char *pub, char *sec, des_block *deskey)
{
struct cachekey_list *new;
@@ -523,10 +473,7 @@ writecache(pub, sec, deskey)
* Try to find the common key in the cache
*/
static int
-readcache(pub, sec, deskey)
- char *pub;
- char *sec;
- des_block *deskey;
+readcache(char *pub, char *sec, des_block *deskey)
{
struct cachekey_list *found;
register struct cachekey_list **l;
diff --git a/usr.sbin/kldxref/Makefile b/usr.sbin/kldxref/Makefile
index c22960c54e3a..7b392e020939 100644
--- a/usr.sbin/kldxref/Makefile
+++ b/usr.sbin/kldxref/Makefile
@@ -1,16 +1,18 @@
-# $FreeBSD$
PACKAGE= runtime
PROG= kldxref
MAN= kldxref.8
-SRCS= kldxref.c ef.c ef_obj.c
+SRCS= kldxref.c ef.c ef_obj.c elf.c
+SRCS+= ef_aarch64.c \
+ ef_arm.c \
+ ef_amd64.c \
+ ef_i386.c \
+ ef_mips.c \
+ ef_powerpc.c \
+ ef_riscv.c
WARNS?= 2
-.if exists(ef_${MACHINE_CPUARCH}.c)
-SRCS+= ef_${MACHINE_CPUARCH}.c
-.else
-SRCS+= ef_nop.c
-.endif
+LIBADD= elf
.include <bsd.prog.mk>
diff --git a/usr.sbin/kldxref/Makefile.depend b/usr.sbin/kldxref/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/kldxref/Makefile.depend
+++ b/usr.sbin/kldxref/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/kldxref/ef.c b/usr.sbin/kldxref/ef.c
index 736b7cab9279..77ddada946f2 100644
--- a/usr.sbin/kldxref/ef.c
+++ b/usr.sbin/kldxref/ef.c
@@ -30,22 +30,16 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <sys/param.h>
-#include <sys/linker.h>
#include <err.h>
#include <errno.h>
-#include <fcntl.h>
+#include <gelf.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <machine/elf.h>
-#define FREEBSD_ELF
#include "ef.h"
@@ -53,76 +47,52 @@
struct ef_file {
char *ef_name;
struct elf_file *ef_efile;
- Elf_Phdr *ef_ph;
- int ef_fd;
- int ef_type;
- Elf_Ehdr ef_hdr;
+ GElf_Phdr *ef_ph;
void *ef_fpage; /* First block of the file */
int ef_fplen; /* length of first block */
- Elf_Dyn *ef_dyn; /* Symbol table etc. */
- Elf_Hashelt ef_nbuckets;
- Elf_Hashelt ef_nchains;
- Elf_Hashelt *ef_buckets;
- Elf_Hashelt *ef_chains;
- Elf_Hashelt *ef_hashtab;
- Elf_Off ef_stroff;
+ GElf_Hashelt ef_nbuckets;
+ GElf_Hashelt ef_nchains;
+ GElf_Hashelt *ef_buckets;
+ GElf_Hashelt *ef_chains;
+ GElf_Hashelt *ef_hashtab;
caddr_t ef_strtab;
- int ef_strsz;
- Elf_Off ef_symoff;
- Elf_Sym *ef_symtab;
+ long ef_strsz;
+ GElf_Sym *ef_symtab;
int ef_nsegs;
- Elf_Phdr *ef_segs[MAXSEGS];
+ GElf_Phdr *ef_segs[MAXSEGS];
int ef_verbose;
- Elf_Rel *ef_rel; /* relocation table */
- int ef_relsz; /* number of entries */
- Elf_Rela *ef_rela; /* relocation table */
- int ef_relasz; /* number of entries */
+ GElf_Rel *ef_rel; /* relocation table */
+ long ef_relsz; /* number of entries */
+ GElf_Rela *ef_rela; /* relocation table */
+ long ef_relasz; /* number of entries */
};
-static void ef_print_phdr(Elf_Phdr *);
-static Elf_Off ef_get_offset(elf_file_t, Elf_Off);
-static int ef_parse_dynamic(elf_file_t);
+static void ef_print_phdr(GElf_Phdr *);
+static GElf_Off ef_get_offset(elf_file_t, GElf_Addr);
-static int ef_get_type(elf_file_t ef);
-static int ef_close(elf_file_t ef);
-static int ef_read(elf_file_t ef, Elf_Off offset, size_t len, void *dest);
-static int ef_read_entry(elf_file_t ef, Elf_Off offset, size_t len,
- void **ptr);
+static void ef_close(elf_file_t ef);
-static int ef_seg_read(elf_file_t ef, Elf_Off offset, size_t len,
- void *dest);
-static int ef_seg_read_rel(elf_file_t ef, Elf_Off offset, size_t len,
+static int ef_seg_read_rel(elf_file_t ef, GElf_Addr address, size_t len,
void *dest);
-static int ef_seg_read_string(elf_file_t ef, Elf_Off offset, size_t len,
+static int ef_seg_read_string(elf_file_t ef, GElf_Addr address, size_t len,
char *dest);
-static int ef_seg_read_entry(elf_file_t ef, Elf_Off offset, size_t len,
- void **ptr);
-static int ef_seg_read_entry_rel(elf_file_t ef, Elf_Off offset, size_t len,
- void **ptr);
-
-static Elf_Addr ef_symaddr(elf_file_t ef, Elf_Size symidx);
-static int ef_lookup_set(elf_file_t ef, const char *name, long *startp,
- long *stopp, long *countp);
+
+static GElf_Addr ef_symaddr(elf_file_t ef, GElf_Size symidx);
+static int ef_lookup_set(elf_file_t ef, const char *name,
+ GElf_Addr *startp, GElf_Addr *stopp, long *countp);
static int ef_lookup_symbol(elf_file_t ef, const char *name,
- Elf_Sym **sym);
+ GElf_Sym **sym);
static struct elf_file_ops ef_file_ops = {
- .get_type = ef_get_type,
.close = ef_close,
- .read = ef_read,
- .read_entry = ef_read_entry,
- .seg_read = ef_seg_read,
.seg_read_rel = ef_seg_read_rel,
.seg_read_string = ef_seg_read_string,
- .seg_read_entry = ef_seg_read_entry,
- .seg_read_entry_rel = ef_seg_read_entry_rel,
.symaddr = ef_symaddr,
.lookup_set = ef_lookup_set,
- .lookup_symbol = ef_lookup_symbol
};
static void
-ef_print_phdr(Elf_Phdr *phdr)
+ef_print_phdr(GElf_Phdr *phdr)
{
if ((phdr->p_flags & PF_W) == 0) {
@@ -136,53 +106,29 @@ ef_print_phdr(Elf_Phdr *phdr)
}
}
-static Elf_Off
-ef_get_offset(elf_file_t ef, Elf_Off off)
+static GElf_Off
+ef_get_offset(elf_file_t ef, GElf_Addr addr)
{
- Elf_Phdr *ph;
+ GElf_Phdr *ph;
int i;
for (i = 0; i < ef->ef_nsegs; i++) {
ph = ef->ef_segs[i];
- if (off >= ph->p_vaddr && off < ph->p_vaddr + ph->p_memsz) {
- return (ph->p_offset + (off - ph->p_vaddr));
+ if (addr >= ph->p_vaddr && addr < ph->p_vaddr + ph->p_memsz) {
+ return (ph->p_offset + (addr - ph->p_vaddr));
}
}
return (0);
}
-static int
-ef_get_type(elf_file_t ef)
-{
-
- return (ef->ef_type);
-}
-
/*
- * next three functions copied from link_elf.c
+ * next two functions copied from link_elf.c
*/
-static unsigned long
-elf_hash(const char *name)
-{
- unsigned long h, g;
- const unsigned char *p;
-
- h = 0;
- p = (const unsigned char *)name;
- while (*p != '\0') {
- h = (h << 4) + *p++;
- if ((g = h & 0xf0000000) != 0)
- h ^= g >> 24;
- h &= ~g;
- }
- return (h);
-}
-
static int
-ef_lookup_symbol(elf_file_t ef, const char *name, Elf_Sym **sym)
+ef_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym)
{
unsigned long hash, symnum;
- Elf_Sym *symp;
+ GElf_Sym *symp;
char *strp;
/* First, search hashed global symbols */
@@ -208,7 +154,7 @@ ef_lookup_symbol(elf_file_t ef, const char *name, Elf_Sym **sym)
if (strcmp(name, strp) == 0) {
if (symp->st_shndx != SHN_UNDEF ||
(symp->st_value != 0 &&
- ELF_ST_TYPE(symp->st_info) == STT_FUNC)) {
+ GELF_ST_TYPE(symp->st_info) == STT_FUNC)) {
*sym = symp;
return (0);
} else
@@ -222,10 +168,10 @@ ef_lookup_symbol(elf_file_t ef, const char *name, Elf_Sym **sym)
}
static int
-ef_lookup_set(elf_file_t ef, const char *name, long *startp, long *stopp,
- long *countp)
+ef_lookup_set(elf_file_t ef, const char *name, GElf_Addr *startp,
+ GElf_Addr *stopp, long *countp)
{
- Elf_Sym *sym;
+ GElf_Sym *sym;
char *setsym;
int error, len;
@@ -249,258 +195,350 @@ ef_lookup_set(elf_file_t ef, const char *name, long *startp, long *stopp,
*stopp = sym->st_value;
/* and the number of entries */
- *countp = (*stopp - *startp) / sizeof(void *);
+ *countp = (*stopp - *startp) / elf_pointer_size(ef->ef_efile);
out:
free(setsym);
return (error);
}
-static Elf_Addr
-ef_symaddr(elf_file_t ef, Elf_Size symidx)
+static GElf_Addr
+ef_symaddr(elf_file_t ef, GElf_Size symidx)
{
- const Elf_Sym *sym;
+ const GElf_Sym *sym;
if (symidx >= ef->ef_nchains)
return (0);
sym = ef->ef_symtab + symidx;
- if (ELF_ST_BIND(sym->st_info) == STB_LOCAL &&
+ if (GELF_ST_BIND(sym->st_info) == STB_LOCAL &&
sym->st_shndx != SHN_UNDEF && sym->st_value != 0)
return (sym->st_value);
return (0);
}
static int
-ef_parse_dynamic(elf_file_t ef)
+ef_parse_dynamic(elf_file_t ef, const GElf_Phdr *phdyn)
{
- Elf_Dyn *dp;
- Elf_Hashelt hashhdr[2];
+ GElf_Shdr *shdr;
+ GElf_Dyn *dyn, *dp;
+ size_t i, ndyn, nshdr, nsym;
int error;
- Elf_Off rel_off;
- Elf_Off rela_off;
+ GElf_Off hash_off, sym_off, str_off;
+ GElf_Off rel_off;
+ GElf_Off rela_off;
int rel_sz;
int rela_sz;
- int rel_entry;
- int rela_entry;
+ int dynamic_idx;
+
+ /*
+ * The kernel linker parses the PT_DYNAMIC segment to find
+ * various important tables. The gelf API of libelf is
+ * section-oriented and requires extracting data from sections
+ * instead of segments (program headers). As a result,
+ * iterate over section headers to read various tables after
+ * parsing values from PT_DYNAMIC.
+ */
+ error = elf_read_shdrs(ef->ef_efile, &nshdr, &shdr);
+ if (error != 0)
+ return (EFTYPE);
+ dyn = NULL;
+
+ /* Find section for .dynamic. */
+ dynamic_idx = -1;
+ for (i = 0; i < nshdr; i++) {
+ if (shdr[i].sh_type == SHT_DYNAMIC) {
+ /*
+ * PowerPC kernels contain additional sections
+ * beyond .dynamic in PT_DYNAMIC due to a linker
+ * script bug. Permit a section with a smaller
+ * size as a workaround.
+ */
+ if (shdr[i].sh_offset != phdyn->p_offset ||
+ ((elf_machine(ef->ef_efile) == EM_PPC ||
+ elf_machine(ef->ef_efile) == EM_PPC64) ?
+ shdr[i].sh_size > phdyn->p_filesz :
+ shdr[i].sh_size != phdyn->p_filesz)) {
+ warnx(".dynamic section doesn't match phdr");
+ error = EFTYPE;
+ goto out;
+ }
+ if (dynamic_idx != -1) {
+ warnx("multiple SHT_DYNAMIC sections");
+ error = EFTYPE;
+ goto out;
+ }
+ dynamic_idx = i;
+ }
+ }
- rel_off = rela_off = 0;
+ error = elf_read_dynamic(ef->ef_efile, dynamic_idx, &ndyn, &dyn);
+ if (error != 0)
+ goto out;
+
+ hash_off = rel_off = rela_off = sym_off = str_off = 0;
rel_sz = rela_sz = 0;
- rel_entry = rela_entry = 0;
- for (dp = ef->ef_dyn; dp->d_tag != DT_NULL; dp++) {
+ for (i = 0; i < ndyn; i++) {
+ dp = &dyn[i];
+ if (dp->d_tag == DT_NULL)
+ break;
+
switch (dp->d_tag) {
case DT_HASH:
- error = ef_read(ef, ef_get_offset(ef, dp->d_un.d_ptr),
- sizeof(hashhdr), hashhdr);
- if (error != 0) {
- warnx("can't read hash header (%jx)",
- (uintmax_t)ef_get_offset(ef, dp->d_un.d_ptr));
- return (error);
- }
- ef->ef_nbuckets = hashhdr[0];
- ef->ef_nchains = hashhdr[1];
- error = ef_read_entry(ef, -1,
- (hashhdr[0] + hashhdr[1]) * sizeof(Elf_Hashelt),
- (void **)&ef->ef_hashtab);
- if (error != 0) {
- warnx("can't read hash table");
- return (error);
- }
- ef->ef_buckets = ef->ef_hashtab;
- ef->ef_chains = ef->ef_buckets + ef->ef_nbuckets;
+ if (hash_off != 0)
+ warnx("second DT_HASH entry ignored");
+ else
+ hash_off = ef_get_offset(ef, dp->d_un.d_ptr);
break;
case DT_STRTAB:
- ef->ef_stroff = dp->d_un.d_ptr;
- break;
- case DT_STRSZ:
- ef->ef_strsz = dp->d_un.d_val;
+ if (str_off != 0)
+ warnx("second DT_STRTAB entry ignored");
+ else
+ str_off = ef_get_offset(ef, dp->d_un.d_ptr);
break;
case DT_SYMTAB:
- ef->ef_symoff = dp->d_un.d_ptr;
+ if (sym_off != 0)
+ warnx("second DT_SYMTAB entry ignored");
+ else
+ sym_off = ef_get_offset(ef, dp->d_un.d_ptr);
break;
case DT_SYMENT:
- if (dp->d_un.d_val != sizeof(Elf_Sym))
- return (EFTYPE);
+ if (dp->d_un.d_val != elf_object_size(ef->ef_efile,
+ ELF_T_SYM)) {
+ error = EFTYPE;
+ goto out;
+ }
break;
case DT_REL:
if (rel_off != 0)
warnx("second DT_REL entry ignored");
- rel_off = dp->d_un.d_ptr;
+ else
+ rel_off = ef_get_offset(ef, dp->d_un.d_ptr);
break;
case DT_RELSZ:
if (rel_sz != 0)
warnx("second DT_RELSZ entry ignored");
- rel_sz = dp->d_un.d_val;
+ else
+ rel_sz = dp->d_un.d_val;
break;
case DT_RELENT:
- if (rel_entry != 0)
- warnx("second DT_RELENT entry ignored");
- rel_entry = dp->d_un.d_val;
+ if (dp->d_un.d_val != elf_object_size(ef->ef_efile,
+ ELF_T_REL)) {
+ error = EFTYPE;
+ goto out;
+ }
break;
case DT_RELA:
if (rela_off != 0)
warnx("second DT_RELA entry ignored");
- rela_off = dp->d_un.d_ptr;
+ else
+ rela_off = ef_get_offset(ef, dp->d_un.d_ptr);
break;
case DT_RELASZ:
if (rela_sz != 0)
- warnx("second DT_RELASZ entry ignored");
- rela_sz = dp->d_un.d_val;
+ warnx("second DT_RELSZ entry ignored");
+ else
+ rela_sz = dp->d_un.d_val;
break;
case DT_RELAENT:
- if (rela_entry != 0)
- warnx("second DT_RELAENT entry ignored");
- rela_entry = dp->d_un.d_val;
+ if (dp->d_un.d_val != elf_object_size(ef->ef_efile,
+ ELF_T_RELA)) {
+ error = EFTYPE;
+ goto out;
+ }
break;
}
}
- if (ef->ef_symoff == 0) {
+ if (hash_off == 0) {
+ warnx("%s: no .hash section found\n", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (sym_off == 0) {
warnx("%s: no .dynsym section found\n", ef->ef_name);
- return (EFTYPE);
+ error = EFTYPE;
+ goto out;
}
- if (ef->ef_stroff == 0) {
+ if (str_off == 0) {
warnx("%s: no .dynstr section found\n", ef->ef_name);
- return (EFTYPE);
- }
- if (ef_read_entry(ef, ef_get_offset(ef, ef->ef_symoff),
- ef->ef_nchains * sizeof(Elf_Sym),
- (void **)&ef->ef_symtab) != 0) {
- if (ef->ef_verbose)
- warnx("%s: can't load .dynsym section (0x%jx)",
- ef->ef_name, (uintmax_t)ef->ef_symoff);
- return (EIO);
- }
- if (ef_read_entry(ef, ef_get_offset(ef, ef->ef_stroff), ef->ef_strsz,
- (void **)&ef->ef_strtab) != 0) {
- warnx("can't load .dynstr section");
- return (EIO);
- }
- if (rel_off != 0) {
- if (rel_entry == 0) {
- warnx("%s: no DT_RELENT for DT_REL", ef->ef_name);
- return (EFTYPE);
- }
- if (rel_entry != sizeof(Elf_Rel)) {
- warnx("%s: inconsistent DT_RELENT value",
- ef->ef_name);
- return (EFTYPE);
- }
- if (rel_sz % rel_entry != 0) {
- warnx("%s: inconsistent values for DT_RELSZ and "
- "DT_RELENT", ef->ef_name);
- return (EFTYPE);
- }
- if (ef_read_entry(ef, ef_get_offset(ef, rel_off), rel_sz,
- (void **)&ef->ef_rel) != 0) {
- warnx("%s: cannot load DT_REL section", ef->ef_name);
- return (EIO);
- }
- ef->ef_relsz = rel_sz / rel_entry;
- if (ef->ef_verbose)
- warnx("%s: %d REL entries", ef->ef_name,
- ef->ef_relsz);
+ error = EFTYPE;
+ goto out;
}
- if (rela_off != 0) {
- if (rela_entry == 0) {
- warnx("%s: no DT_RELAENT for DT_RELA", ef->ef_name);
- return (EFTYPE);
- }
- if (rela_entry != sizeof(Elf_Rela)) {
- warnx("%s: inconsistent DT_RELAENT value",
- ef->ef_name);
- return (EFTYPE);
- }
- if (rela_sz % rela_entry != 0) {
- warnx("%s: inconsistent values for DT_RELASZ and "
- "DT_RELAENT", ef->ef_name);
- return (EFTYPE);
- }
- if (ef_read_entry(ef, ef_get_offset(ef, rela_off), rela_sz,
- (void **)&ef->ef_rela) != 0) {
- warnx("%s: cannot load DT_RELA section", ef->ef_name);
- return (EIO);
- }
- ef->ef_relasz = rela_sz / rela_entry;
- if (ef->ef_verbose)
- warnx("%s: %d RELA entries", ef->ef_name,
- ef->ef_relasz);
+ if (rel_off == 0 && rela_off == 0) {
+ warnx("%s: no ELF relocation table found\n", ef->ef_name);
+ error = EFTYPE;
+ goto out;
}
- return (0);
-}
-static int
-ef_read(elf_file_t ef, Elf_Off offset, size_t len, void *dest)
-{
- ssize_t r;
+ nsym = 0;
+ for (i = 0; i < nshdr; i++) {
+ switch (shdr[i].sh_type) {
+ case SHT_HASH:
+ if (shdr[i].sh_offset != hash_off) {
+ warnx("%s: ignoring SHT_HASH at different offset from DT_HASH",
+ ef->ef_name);
+ break;
+ }
- if (offset != (Elf_Off)-1) {
- if (lseek(ef->ef_fd, offset, SEEK_SET) == -1)
- return (EIO);
- }
+ /*
+ * libelf(3) mentions ELF_T_HASH, but it is
+ * not defined.
+ */
+ if (shdr[i].sh_size < sizeof(*ef->ef_hashtab) * 2) {
+ warnx("hash section too small");
+ error = EFTYPE;
+ goto out;
+ }
+ error = elf_read_data(ef->ef_efile, ELF_T_WORD,
+ shdr[i].sh_offset, shdr[i].sh_size,
+ (void **)&ef->ef_hashtab);
+ if (error != 0) {
+ warnc(error, "can't read hash table");
+ goto out;
+ }
+ ef->ef_nbuckets = ef->ef_hashtab[0];
+ ef->ef_nchains = ef->ef_hashtab[1];
+ if ((2 + ef->ef_nbuckets + ef->ef_nchains) *
+ sizeof(*ef->ef_hashtab) != shdr[i].sh_size) {
+ warnx("inconsistent hash section size");
+ error = EFTYPE;
+ goto out;
+ }
- r = read(ef->ef_fd, dest, len);
- if (r != -1 && (size_t)r == len)
- return (0);
- else
- return (EIO);
-}
+ ef->ef_buckets = ef->ef_hashtab + 2;
+ ef->ef_chains = ef->ef_buckets + ef->ef_nbuckets;
+ break;
+ case SHT_DYNSYM:
+ if (shdr[i].sh_offset != sym_off) {
+ warnx("%s: ignoring SHT_DYNSYM at different offset from DT_SYMTAB",
+ ef->ef_name);
+ break;
+ }
+ error = elf_read_symbols(ef->ef_efile, i, &nsym,
+ &ef->ef_symtab);
+ if (error != 0) {
+ if (ef->ef_verbose)
+ warnx("%s: can't load .dynsym section (0x%jx)",
+ ef->ef_name, (uintmax_t)sym_off);
+ goto out;
+ }
+ break;
+ case SHT_STRTAB:
+ if (shdr[i].sh_offset != str_off)
+ break;
+ error = elf_read_string_table(ef->ef_efile,
+ &shdr[i], &ef->ef_strsz, &ef->ef_strtab);
+ if (error != 0) {
+ warnx("can't load .dynstr section");
+ error = EIO;
+ goto out;
+ }
+ break;
+ case SHT_REL:
+ if (shdr[i].sh_offset != rel_off)
+ break;
+ if (shdr[i].sh_size != rel_sz) {
+ warnx("%s: size mismatch for DT_REL section",
+ ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ error = elf_read_rel(ef->ef_efile, i, &ef->ef_relsz,
+ &ef->ef_rel);
+ if (error != 0) {
+ warnx("%s: cannot load DT_REL section",
+ ef->ef_name);
+ goto out;
+ }
+ break;
+ case SHT_RELA:
+ if (shdr[i].sh_offset != rela_off)
+ break;
+ if (shdr[i].sh_size != rela_sz) {
+ warnx("%s: size mismatch for DT_RELA section",
+ ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ error = elf_read_rela(ef->ef_efile, i, &ef->ef_relasz,
+ &ef->ef_rela);
+ if (error != 0) {
+ warnx("%s: cannot load DT_RELA section",
+ ef->ef_name);
+ goto out;
+ }
+ break;
+ }
+ }
-static int
-ef_read_entry(elf_file_t ef, Elf_Off offset, size_t len, void **ptr)
-{
- int error;
+ if (ef->ef_hashtab == NULL) {
+ warnx("%s: did not find a symbol hash table", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (ef->ef_symtab == NULL) {
+ warnx("%s: did not find a dynamic symbol table", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (nsym != ef->ef_nchains) {
+ warnx("%s: symbol count mismatch", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (ef->ef_strtab == NULL) {
+ warnx("%s: did not find a dynamic string table", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (rel_off != 0 && ef->ef_rel == NULL) {
+ warnx("%s: did not find a DT_REL relocation table",
+ ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (rela_off != 0 && ef->ef_rela == NULL) {
+ warnx("%s: did not find a DT_RELA relocation table",
+ ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
- *ptr = malloc(len);
- if (*ptr == NULL)
- return (errno);
- error = ef_read(ef, offset, len, *ptr);
- if (error != 0)
- free(*ptr);
+ error = 0;
+out:
+ free(dyn);
+ free(shdr);
return (error);
}
static int
-ef_seg_read(elf_file_t ef, Elf_Off offset, size_t len, void *dest)
+ef_seg_read_rel(elf_file_t ef, GElf_Addr address, size_t len, void *dest)
{
- Elf_Off ofs;
-
- ofs = ef_get_offset(ef, offset);
- if (ofs == 0) {
- if (ef->ef_verbose)
- warnx("ef_seg_read(%s): zero offset (%jx:%ju)",
- ef->ef_name, (uintmax_t)offset, (uintmax_t)ofs);
- return (EFAULT);
- }
- return (ef_read(ef, ofs, len, dest));
-}
-
-static int
-ef_seg_read_rel(elf_file_t ef, Elf_Off offset, size_t len, void *dest)
-{
- Elf_Off ofs;
- const Elf_Rela *a;
- const Elf_Rel *r;
+ GElf_Off ofs;
+ const GElf_Rela *a;
+ const GElf_Rel *r;
int error;
- ofs = ef_get_offset(ef, offset);
+ ofs = ef_get_offset(ef, address);
if (ofs == 0) {
if (ef->ef_verbose)
- warnx("ef_seg_read_rel(%s): zero offset (%jx:%ju)",
- ef->ef_name, (uintmax_t)offset, (uintmax_t)ofs);
+ warnx("ef_seg_read_rel(%s): bad address (%jx)",
+ ef->ef_name, (uintmax_t)address);
return (EFAULT);
}
- if ((error = ef_read(ef, ofs, len, dest)) != 0)
+ error = elf_read_raw_data(ef->ef_efile, ofs, dest, len);
+ if (error != 0)
return (error);
for (r = ef->ef_rel; r < &ef->ef_rel[ef->ef_relsz]; r++) {
- error = ef_reloc(ef->ef_efile, r, EF_RELOC_REL, 0, offset, len,
- dest);
+ error = elf_reloc(ef->ef_efile, r, ELF_T_REL, 0, address,
+ len, dest);
if (error != 0)
return (error);
}
for (a = ef->ef_rela; a < &ef->ef_rela[ef->ef_relasz]; a++) {
- error = ef_reloc(ef->ef_efile, a, EF_RELOC_RELA, 0, offset, len,
- dest);
+ error = elf_reloc(ef->ef_efile, a, ELF_T_RELA, 0, address,
+ len, dest);
if (error != 0)
return (error);
}
@@ -508,168 +546,108 @@ ef_seg_read_rel(elf_file_t ef, Elf_Off offset, size_t len, void *dest)
}
static int
-ef_seg_read_string(elf_file_t ef, Elf_Off offset, size_t len, char *dest)
+ef_seg_read_string(elf_file_t ef, GElf_Addr address, size_t len, char *dest)
{
- Elf_Off ofs;
- ssize_t r;
+ GElf_Off ofs;
- ofs = ef_get_offset(ef, offset);
- if (ofs == 0 || ofs == (Elf_Off)-1) {
+ ofs = ef_get_offset(ef, address);
+ if (ofs == 0) {
if (ef->ef_verbose)
warnx("ef_seg_read_string(%s): bad offset (%jx:%ju)",
- ef->ef_name, (uintmax_t)offset, (uintmax_t)ofs);
+ ef->ef_name, (uintmax_t)address, (uintmax_t)ofs);
return (EFAULT);
}
- r = pread(ef->ef_fd, dest, len, ofs);
- if (r < 0)
- return (errno);
- if (strnlen(dest, len) == len)
- return (EFAULT);
-
- return (0);
-}
-
-static int
-ef_seg_read_entry(elf_file_t ef, Elf_Off offset, size_t len, void **ptr)
-{
- int error;
-
- *ptr = malloc(len);
- if (*ptr == NULL)
- return (errno);
- error = ef_seg_read(ef, offset, len, *ptr);
- if (error != 0)
- free(*ptr);
- return (error);
-}
-
-static int
-ef_seg_read_entry_rel(elf_file_t ef, Elf_Off offset, size_t len, void **ptr)
-{
- int error;
-
- *ptr = malloc(len);
- if (*ptr == NULL)
- return (errno);
- error = ef_seg_read_rel(ef, offset, len, *ptr);
- if (error != 0)
- free(*ptr);
- return (error);
+ return (elf_read_raw_string(ef->ef_efile, ofs, dest, len));
}
int
-ef_open(const char *filename, struct elf_file *efile, int verbose)
+ef_open(struct elf_file *efile, int verbose)
{
elf_file_t ef;
- Elf_Ehdr *hdr;
- int fd;
+ GElf_Ehdr *hdr;
+ size_t i, nphdr, nsegs;
int error;
- int phlen, res;
- int nsegs;
- Elf_Phdr *phdr, *phdyn, *phlimit;
+ GElf_Phdr *phdr, *phdyn;
- if (filename == NULL)
- return (EINVAL);
- if ((fd = open(filename, O_RDONLY)) == -1)
- return (errno);
+ hdr = &efile->ef_hdr;
+ if (hdr->e_phnum == 0 ||
+ hdr->e_phentsize != elf_object_size(efile, ELF_T_PHDR) ||
+ hdr->e_shnum == 0 || hdr->e_shoff == 0 ||
+ hdr->e_shentsize != elf_object_size(efile, ELF_T_SHDR))
+ return (EFTYPE);
ef = malloc(sizeof(*ef));
- if (ef == NULL) {
- close(fd);
+ if (ef == NULL)
return (errno);
- }
efile->ef_ef = ef;
efile->ef_ops = &ef_file_ops;
bzero(ef, sizeof(*ef));
ef->ef_verbose = verbose;
- ef->ef_fd = fd;
- ef->ef_name = strdup(filename);
+ ef->ef_name = strdup(efile->ef_filename);
ef->ef_efile = efile;
- hdr = (Elf_Ehdr *)&ef->ef_hdr;
- do {
- res = read(fd, hdr, sizeof(*hdr));
- error = EFTYPE;
- if (res != sizeof(*hdr))
- break;
- if (!IS_ELF(*hdr))
- break;
- if (hdr->e_ident[EI_CLASS] != ELF_TARG_CLASS ||
- hdr->e_ident[EI_DATA] != ELF_TARG_DATA ||
- hdr->e_ident[EI_VERSION] != EV_CURRENT ||
- hdr->e_version != EV_CURRENT ||
- hdr->e_machine != ELF_TARG_MACH ||
- hdr->e_phentsize != sizeof(Elf_Phdr))
- break;
- phlen = hdr->e_phnum * sizeof(Elf_Phdr);
- if (ef_read_entry(ef, hdr->e_phoff, phlen,
- (void **)&ef->ef_ph) != 0)
- break;
- phdr = ef->ef_ph;
- phlimit = phdr + hdr->e_phnum;
- nsegs = 0;
- phdyn = NULL;
- while (phdr < phlimit) {
- if (verbose > 1)
- ef_print_phdr(phdr);
- switch (phdr->p_type) {
- case PT_LOAD:
- if (nsegs < MAXSEGS)
- ef->ef_segs[nsegs] = phdr;
- nsegs++;
- break;
- case PT_PHDR:
- break;
- case PT_DYNAMIC:
- phdyn = phdr;
- break;
- }
- phdr++;
- }
+
+ error = elf_read_phdrs(efile, &nphdr, &ef->ef_ph);
+ if (error != 0) {
+ phdr = NULL;
+ goto out;
+ }
+
+ error = EFTYPE;
+ nsegs = 0;
+ phdyn = NULL;
+ phdr = ef->ef_ph;
+ for (i = 0; i < nphdr; i++, phdr++) {
if (verbose > 1)
- printf("\n");
- if (phdyn == NULL) {
- warnx("Skipping %s: not dynamically-linked",
- filename);
+ ef_print_phdr(phdr);
+ switch (phdr->p_type) {
+ case PT_LOAD:
+ if (nsegs < MAXSEGS)
+ ef->ef_segs[nsegs] = phdr;
+ nsegs++;
break;
- } else if (nsegs > MAXSEGS) {
- warnx("%s: too many segments", filename);
+ case PT_PHDR:
break;
- }
- ef->ef_nsegs = nsegs;
- if (ef_read_entry(ef, phdyn->p_offset,
- phdyn->p_filesz, (void **)&ef->ef_dyn) != 0) {
- printf("ef_read_entry failed\n");
+ case PT_DYNAMIC:
+ phdyn = phdr;
break;
}
- error = ef_parse_dynamic(ef);
- if (error != 0)
- break;
- if (hdr->e_type == ET_DYN) {
- ef->ef_type = EFT_KLD;
- error = 0;
- } else if (hdr->e_type == ET_EXEC) {
- ef->ef_type = EFT_KERNEL;
- error = 0;
- } else
- break;
- } while(0);
+ }
+ if (verbose > 1)
+ printf("\n");
+ if (phdyn == NULL) {
+ warnx("Skipping %s: not dynamically-linked",
+ ef->ef_name);
+ goto out;
+ }
+
+ if (nsegs > MAXSEGS) {
+ warnx("%s: too many segments", ef->ef_name);
+ goto out;
+ }
+ ef->ef_nsegs = nsegs;
+
+ error = ef_parse_dynamic(ef, phdyn);
+out:
if (error != 0)
ef_close(ef);
return (error);
}
-static int
+static void
ef_close(elf_file_t ef)
{
-
- close(ef->ef_fd);
+ free(ef->ef_rela);
+ free(ef->ef_rel);
+ free(ef->ef_strtab);
+ free(ef->ef_symtab);
+ free(ef->ef_hashtab);
+ free(ef->ef_ph);
if (ef->ef_name)
free(ef->ef_name);
ef->ef_efile->ef_ops = NULL;
ef->ef_efile->ef_ef = NULL;
free(ef);
- return (0);
}
diff --git a/usr.sbin/kldxref/ef.h b/usr.sbin/kldxref/ef.h
index 0b13b5570f9f..9d3dc1b1b435 100644
--- a/usr.sbin/kldxref/ef.h
+++ b/usr.sbin/kldxref/ef.h
@@ -1,73 +1,315 @@
-/* $FreeBSD$ */
+/*-
+ * SPDX-License-Identifier: BSD-4-Clause
+ *
+ * Copyright (c) 2000, Boris Popov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Boris Popov.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
#ifndef _EF_H_
#define _EF_H_
-#define EFT_KLD 1
-#define EFT_KERNEL 2
+#include <sys/linker_set.h>
+#include <stdbool.h>
-#define EF_RELOC_REL 1
-#define EF_RELOC_RELA 2
-
-#define EF_GET_TYPE(ef) \
- (ef)->ef_ops->get_type((ef)->ef_ef)
#define EF_CLOSE(ef) \
(ef)->ef_ops->close((ef)->ef_ef)
-#define EF_READ(ef, offset, len, dest) \
- (ef)->ef_ops->read((ef)->ef_ef, offset, len, dest)
-#define EF_READ_ENTRY(ef, offset, len, ptr) \
- (ef)->ef_ops->read_entry((ef)->ef_ef, offset, len, ptr)
-#define EF_SEG_READ(ef, offset, len, dest) \
- (ef)->ef_ops->seg_read((ef)->ef_ef, offset, len, dest)
-#define EF_SEG_READ_REL(ef, offset, len, dest) \
- (ef)->ef_ops->seg_read_rel((ef)->ef_ef, offset, len, dest)
-#define EF_SEG_READ_STRING(ef, offset, len, dest) \
- (ef)->ef_ops->seg_read_string((ef)->ef_ef, offset, len, dest)
-#define EF_SEG_READ_ENTRY(ef, offset, len, ptr) \
- (ef)->ef_ops->seg_read_entry((ef)->kf_ef, offset, len, ptr)
-#define EF_SEG_READ_ENTRY_REL(ef, offset, len, ptr) \
- (ef)->ef_ops->seg_read_entry_rel((ef)->ef_ef, offset, len, ptr)
+#define EF_SEG_READ_REL(ef, address, len, dest) \
+ (ef)->ef_ops->seg_read_rel((ef)->ef_ef, address, len, dest)
+#define EF_SEG_READ_STRING(ef, address, len, dest) \
+ (ef)->ef_ops->seg_read_string((ef)->ef_ef, address, len, dest)
#define EF_SYMADDR(ef, symidx) \
(ef)->ef_ops->symaddr((ef)->ef_ef, symidx)
#define EF_LOOKUP_SET(ef, name, startp, stopp, countp) \
(ef)->ef_ops->lookup_set((ef)->ef_ef, name, startp, stopp, countp)
-#define EF_LOOKUP_SYMBOL(ef, name, sym) \
- (ef)->ef_ops->lookup_symbol((ef)->ef_ef, name, sym)
/* XXX, should have a different name. */
typedef struct ef_file *elf_file_t;
+/* FreeBSD's headers define additional typedef's for ELF structures. */
+typedef Elf64_Size GElf_Size;
+typedef Elf64_Hashelt GElf_Hashelt;
+
+struct elf_file;
+
struct elf_file_ops {
- int (*get_type)(elf_file_t ef);
- int (*close)(elf_file_t ef);
- int (*read)(elf_file_t ef, Elf_Off offset, size_t len, void* dest);
- int (*read_entry)(elf_file_t ef, Elf_Off offset, size_t len,
- void **ptr);
- int (*seg_read)(elf_file_t ef, Elf_Off offset, size_t len, void *dest);
- int (*seg_read_rel)(elf_file_t ef, Elf_Off offset, size_t len,
+ void (*close)(elf_file_t ef);
+ int (*seg_read_rel)(elf_file_t ef, GElf_Addr address, size_t len,
void *dest);
- int (*seg_read_string)(elf_file_t, Elf_Off offset, size_t len,
+ int (*seg_read_string)(elf_file_t ef, GElf_Addr address, size_t len,
char *dest);
- int (*seg_read_entry)(elf_file_t ef, Elf_Off offset, size_t len,
- void**ptr);
- int (*seg_read_entry_rel)(elf_file_t ef, Elf_Off offset, size_t len,
- void**ptr);
- Elf_Addr (*symaddr)(elf_file_t ef, Elf_Size symidx);
- int (*lookup_set)(elf_file_t ef, const char *name, long *startp,
- long *stopp, long *countp);
- int (*lookup_symbol)(elf_file_t ef, const char* name, Elf_Sym** sym);
+ GElf_Addr (*symaddr)(elf_file_t ef, GElf_Size symidx);
+ int (*lookup_set)(elf_file_t ef, const char *name, GElf_Addr *startp,
+ GElf_Addr *stopp, long *countp);
+};
+
+typedef int (elf_reloc_t)(struct elf_file *ef, const void *reldata,
+ Elf_Type reltype, GElf_Addr relbase, GElf_Addr dataoff, size_t len,
+ void *dest);
+
+struct elf_reloc_data {
+ unsigned char class;
+ unsigned char data;
+ GElf_Half machine;
+ elf_reloc_t *reloc;
};
+#define ELF_RELOC(_class, _data, _machine, _reloc) \
+ static struct elf_reloc_data __CONCAT(elf_reloc_data_, __LINE__) = { \
+ .class = (_class), \
+ .data = (_data), \
+ .machine = (_machine), \
+ .reloc = (_reloc) \
+ }; \
+ DATA_SET(elf_reloc, __CONCAT(elf_reloc_data_, __LINE__))
+
struct elf_file {
elf_file_t ef_ef;
struct elf_file_ops *ef_ops;
+ const char *ef_filename;
+ Elf *ef_elf;
+ elf_reloc_t *ef_reloc;
+ GElf_Ehdr ef_hdr;
+ size_t ef_pointer_size;
+ int ef_fd;
+};
+
+#define elf_machine(ef) ((ef)->ef_hdr.e_machine)
+#define elf_class(ef) ((ef)->ef_hdr.e_ident[EI_CLASS])
+#define elf_encoding(ef) ((ef)->ef_hdr.e_ident[EI_DATA])
+
+/*
+ * "Generic" versions of module metadata structures.
+ */
+struct Gmod_depend {
+ int md_ver_minimum;
+ int md_ver_preferred;
+ int md_ver_maximum;
+};
+
+struct Gmod_version {
+ int mv_version;
+};
+
+struct Gmod_metadata {
+ int md_version; /* structure version MDTV_* */
+ int md_type; /* type of entry MDT_* */
+ GElf_Addr md_data; /* specific data */
+ GElf_Addr md_cval; /* common string label */
+};
+
+struct Gmod_pnp_match_info
+{
+ GElf_Addr descr; /* Description of the table */
+ GElf_Addr bus; /* Name of the bus for this table */
+ GElf_Addr table; /* Pointer to pnp table */
+ int entry_len; /* Length of each entry in the table (may be */
+ /* longer than descr describes). */
+ int num_entry; /* Number of entries in the table */
};
__BEGIN_DECLS
-int ef_open(const char *filename, struct elf_file *ef, int verbose);
-int ef_obj_open(const char *filename, struct elf_file *ef, int verbose);
-int ef_reloc(struct elf_file *ef, const void *reldata, int reltype,
- Elf_Off relbase, Elf_Off dataoff, size_t len, void *dest);
+
+/*
+ * Attempt to parse an open ELF file as either an executable or DSO
+ * (ef_open) or an object file (ef_obj_open). On success, these
+ * routines initialize the 'ef_ef' and 'ef_ops' members of 'ef'.
+ */
+int ef_open(struct elf_file *ef, int verbose);
+int ef_obj_open(struct elf_file *ef, int verbose);
+
+/*
+ * Direct operations on an ELF file regardless of type. Many of these
+ * use libelf.
+ */
+
+/*
+ * Open an ELF file with libelf. Populates fields other than ef_ef
+ * and ef_ops in '*efile'.
+ */
+int elf_open_file(struct elf_file *efile, const char *filename,
+ int verbose);
+
+/* Close an ELF file. */
+void elf_close_file(struct elf_file *efile);
+
+/* Is an ELF file the same architecture as hdr? */
+bool elf_compatible(struct elf_file *efile, const GElf_Ehdr *hdr);
+
+/* The size of a single object of 'type'. */
+size_t elf_object_size(struct elf_file *efile, Elf_Type type);
+
+/* The size of a pointer in architecture of 'efile'. */
+size_t elf_pointer_size(struct elf_file *efile);
+
+/*
+ * Read and convert an array of a data type from an ELF file. This is
+ * a wrapper around gelf_xlatetom() which reads an array of raw ELF
+ * objects from the file and converts them into host structures using
+ * native endianness. The data is returned in a dynamically-allocated
+ * buffer.
+ */
+int elf_read_data(struct elf_file *efile, Elf_Type type, off_t offset,
+ size_t len, void **out);
+
+/* Reads "raw" data from an ELF file without any translation. */
+int elf_read_raw_data(struct elf_file *efile, off_t offset, void *dst,
+ size_t len);
+
+/*
+ * A wrapper around elf_read_raw_data which returns the data in a
+ * dynamically-allocated buffer.
+ */
+int elf_read_raw_data_alloc(struct elf_file *efile, off_t offset,
+ size_t len, void **out);
+
+/* Reads a single string at the given offset from an ELF file. */
+int elf_read_raw_string(struct elf_file *efile, off_t offset, char *dst,
+ size_t len);
+
+/*
+ * Read relocated data from an ELF file and return it in a
+ * dynamically-allocated buffer. Note that no translation
+ * (byte-swapping for endianness, 32-vs-64) is performed on the
+ * returned data, but any ELF relocations which affect the contents
+ * are applied to the returned data. The address parameter gives the
+ * address of the data buffer if the ELF file were loaded into memory
+ * rather than a direct file offset.
+ */
+int elf_read_relocated_data(struct elf_file *efile, GElf_Addr address,
+ size_t len, void **buf);
+
+/*
+ * Read the program headers from an ELF file and return them in a
+ * dynamically-allocated array of GElf_Phdr objects.
+ */
+int elf_read_phdrs(struct elf_file *efile, size_t *nphdrp,
+ GElf_Phdr **phdrp);
+
+/*
+ * Read the section headers from an ELF file and return them in a
+ * dynamically-allocated array of GElf_Shdr objects.
+ */
+int elf_read_shdrs(struct elf_file *efile, size_t *nshdrp,
+ GElf_Shdr **shdrp);
+
+/*
+ * Read the dynamic table from a section of an ELF file into a
+ * dynamically-allocated array of GElf_Dyn objects.
+ */
+int elf_read_dynamic(struct elf_file *efile, int section_index, size_t *ndynp,
+ GElf_Dyn **dynp);
+
+/*
+ * Read a symbol table from a section of an ELF file into a
+ * dynamically-allocated array of GElf_Sym objects.
+ */
+int elf_read_symbols(struct elf_file *efile, int section_index,
+ size_t *nsymp, GElf_Sym **symp);
+
+/*
+ * Read a string table described by a section header of an ELF file
+ * into a dynamically-allocated buffer.
+ */
+int elf_read_string_table(struct elf_file *efile, const GElf_Shdr *shdr,
+ long *strcnt, char **strtab);
+
+/*
+ * Read a table of relocation objects from a section of an ELF file
+ * into a dynamically-allocated array of GElf_Rel objects.
+ */
+int elf_read_rel(struct elf_file *efile, int section_index, long *nrelp,
+ GElf_Rel **relp);
+
+/*
+ * Read a table of relocation-with-addend objects from a section of an
+ * ELF file into a dynamically-allocated array of GElf_Rela objects.
+ */
+int elf_read_rela(struct elf_file *efile, int section_index, long *nrelap,
+ GElf_Rela **relap);
+
+/*
+ * Read a string from an ELF file and return it in the provided
+ * buffer. If the string is longer than the buffer, this fails with
+ * EFAULT. The address parameter gives the address of the data buffer
+ * if the ELF file were loaded into memory rather than a direct file
+ * offset.
+ */
+int elf_read_string(struct elf_file *efile, GElf_Addr address, void *dst,
+ size_t len);
+
+/* Return the address extracted from a target pointer stored at 'p'. */
+GElf_Addr elf_address_from_pointer(struct elf_file *efile, const void *p);
+
+/*
+ * Read a linker set and return an array of addresses extracted from the
+ * relocated pointers in the linker set.
+ */
+int elf_read_linker_set(struct elf_file *efile, const char *name,
+ GElf_Addr **buf, long *countp);
+
+/*
+ * Read and convert a target 'struct mod_depend' into a host
+ * 'struct Gmod_depend'.
+ */
+int elf_read_mod_depend(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_depend *mdp);
+
+/*
+ * Read and convert a target 'struct mod_version' into a host
+ * 'struct Gmod_version'.
+ */
+int elf_read_mod_version(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_version *mdv);
+
+/*
+ * Read and convert a target 'struct mod_metadata' into a host
+ * 'struct Gmod_metadata'.
+ */
+int elf_read_mod_metadata(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_metadata *md);
+
+/*
+ * Read and convert a target 'struct mod_pnp_match_info' into a host
+ * 'struct Gmod_pnp_match_info'.
+ */
+int elf_read_mod_pnp_match_info(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_pnp_match_info *pnp);
+
+/*
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
+ */
+int elf_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest);
+
__END_DECLS
#endif /* _EF_H_*/
diff --git a/usr.sbin/kldxref/ef_aarch64.c b/usr.sbin/kldxref/ef_aarch64.c
index 17a9274e27a3..b61de3b032ab 100644
--- a/usr.sbin/kldxref/ef_aarch64.c
+++ b/usr.sbin/kldxref/ef_aarch64.c
@@ -23,16 +23,13 @@
* 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/types.h>
-#include <machine/elf.h>
+#include <sys/endian.h>
#include <err.h>
#include <errno.h>
-#include <string.h>
+#include <gelf.h>
#include "ef.h"
@@ -41,34 +38,44 @@
* target relocation address of the section, and `dataoff/len' is the region
* that is to be relocated, and has been copied to *dest
*/
-int
-ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase,
- Elf_Off dataoff, size_t len, void *dest)
+static int
+ef_aarch64_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
{
- Elf_Addr *where, addend;
- Elf_Size rtype;
- const Elf_Rela *rela;
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rela *rela;
- if (reltype != EF_RELOC_RELA)
+ switch (reltype) {
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
+ addend = rela->r_addend;
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
+ break;
+ default:
return (EINVAL);
+ }
- rela = (const Elf_Rela *)reldata;
- where = (Elf_Addr *) ((Elf_Off)dest - dataoff + rela->r_offset);
- addend = rela->r_addend;
- rtype = ELF_R_TYPE(rela->r_info);
-
- if ((char *)where < (char *)dest || (char *)where >= (char *)dest + len)
+ if (where < (char *)dest || where >= (char *)dest + len)
return (0);
- switch(rtype) {
+ switch (rtype) {
case R_AARCH64_RELATIVE:
- *where = relbase + addend;
+ addr = relbase + addend;
+ le64enc(where, addr);
break;
case R_AARCH64_ABS64:
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le64enc(where, addr);
break;
default:
- warnx("unhandled relocation type %lu", rtype);
+ warnx("unhandled relocation type %d", (int)rtype);
break;
}
return (0);
}
+
+ELF_RELOC(ELFCLASS64, ELFDATA2LSB, EM_AARCH64, ef_aarch64_reloc);
diff --git a/usr.sbin/kldxref/ef_amd64.c b/usr.sbin/kldxref/ef_amd64.c
index 270f27ad8bfa..fde032dcabc2 100644
--- a/usr.sbin/kldxref/ef_amd64.c
+++ b/usr.sbin/kldxref/ef_amd64.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003 Jake Burkholder.
* Copyright 1996-1998 John D. Polstra.
@@ -25,65 +25,62 @@
* 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/types.h>
-#include <machine/elf.h>
+#include <sys/endian.h>
#include <err.h>
#include <errno.h>
+#include <gelf.h>
#include "ef.h"
/*
- * Apply relocations to the values we got from the file. `relbase' is the
- * target relocation address of the section, and `dataoff' is the target
- * relocation address of the data in `dest'.
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
*/
-int
-ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase,
- Elf_Off dataoff, size_t len, void *dest)
+static int
+ef_amd64_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
{
- Elf64_Addr *where, val;
- Elf32_Addr *where32, val32;
- Elf_Addr addend, addr;
- Elf_Size rtype, symidx;
- const Elf_Rel *rel;
- const Elf_Rela *rela;
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rel *rel;
+ const GElf_Rela *rela;
switch (reltype) {
- case EF_RELOC_REL:
- rel = (const Elf_Rel *)reldata;
- where = (Elf_Addr *)(dest + relbase + rel->r_offset - dataoff);
+ case ELF_T_REL:
+ rel = (const GElf_Rel *)reldata;
+ where = (char *)dest + (relbase + rel->r_offset - dataoff);
addend = 0;
- rtype = ELF_R_TYPE(rel->r_info);
- symidx = ELF_R_SYM(rel->r_info);
+ rtype = GELF_R_TYPE(rel->r_info);
+ symidx = GELF_R_SYM(rel->r_info);
break;
- case EF_RELOC_RELA:
- rela = (const Elf_Rela *)reldata;
- where = (Elf_Addr *)(dest + relbase + rela->r_offset - dataoff);
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
addend = rela->r_addend;
- rtype = ELF_R_TYPE(rela->r_info);
- symidx = ELF_R_SYM(rela->r_info);
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
break;
default:
return (EINVAL);
}
- if ((char *)where < (char *)dest || (char *)where >= (char *)dest + len)
+ if (where < (char *)dest || where >= (char *)dest + len)
return (0);
- if (reltype == EF_RELOC_REL) {
+ if (reltype == ELF_T_REL) {
/* Addend is 32 bit on 32 bit relocs */
switch (rtype) {
case R_X86_64_PC32:
case R_X86_64_32S:
- addend = *(Elf32_Addr *)where;
+ addend = le32dec(where);
break;
default:
- addend = *where;
+ addend = le64dec(where);
break;
}
}
@@ -92,27 +89,25 @@ ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase,
case R_X86_64_NONE: /* none */
break;
case R_X86_64_64: /* S + A */
- addr = EF_SYMADDR(ef, symidx);
- val = addr + addend;
- *where = val;
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le64enc(where, addr);
break;
case R_X86_64_32S: /* S + A sign extend */
- addr = EF_SYMADDR(ef, symidx);
- val32 = (Elf32_Addr)(addr + addend);
- where32 = (Elf32_Addr *)where;
- *where32 = val32;
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le32enc(where, addr);
break;
case R_X86_64_GLOB_DAT: /* S */
addr = EF_SYMADDR(ef, symidx);
- *where = addr;
+ le64enc(where, addr);
break;
case R_X86_64_RELATIVE: /* B + A */
- addr = (Elf_Addr)addend + relbase;
- val = addr;
- *where = val;
+ addr = relbase + addend;
+ le64enc(where, addr);
break;
default:
warnx("unhandled relocation type %d", (int)rtype);
}
return (0);
}
+
+ELF_RELOC(ELFCLASS64, ELFDATA2LSB, EM_X86_64, ef_amd64_reloc);
diff --git a/usr.sbin/kldxref/ef_arm.c b/usr.sbin/kldxref/ef_arm.c
new file mode 100644
index 000000000000..cc5e265f821e
--- /dev/null
+++ b/usr.sbin/kldxref/ef_arm.c
@@ -0,0 +1,94 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2003 Jake Burkholder.
+ * Copyright 1996-1998 John D. Polstra.
+ * All rights reserved.
+ * Copyright (c) 2023 Jessica Clarke <jrtc27@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/endian.h>
+
+#include <err.h>
+#include <errno.h>
+#include <gelf.h>
+
+#include "ef.h"
+
+/*
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
+ */
+static int
+ef_arm_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
+{
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rel *rel;
+ const GElf_Rela *rela;
+
+ switch (reltype) {
+ case ELF_T_REL:
+ rel = (const GElf_Rel *)reldata;
+ where = (char *)dest + (relbase + rel->r_offset - dataoff);
+ addend = 0;
+ rtype = GELF_R_TYPE(rel->r_info);
+ symidx = GELF_R_SYM(rel->r_info);
+ break;
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
+ addend = rela->r_addend;
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ if (where < (char *)dest || where >= (char *)dest + len)
+ return (0);
+
+ if (reltype == ELF_T_REL)
+ addend = le32dec(where);
+
+ switch (rtype) {
+ case R_ARM_ABS32: /* S + A */
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le32enc(where, addr);
+ break;
+ case R_ARM_RELATIVE: /* B + A */
+ addr = relbase + addend;
+ le32enc(where, addr);
+ break;
+ default:
+ warnx("unhandled relocation type %d", (int)rtype);
+ }
+ return (0);
+}
+
+ELF_RELOC(ELFCLASS32, ELFDATA2LSB, EM_ARM, ef_arm_reloc);
diff --git a/usr.sbin/kldxref/ef_i386.c b/usr.sbin/kldxref/ef_i386.c
index 34bc9ad59c47..962ed2bc0664 100644
--- a/usr.sbin/kldxref/ef_i386.c
+++ b/usr.sbin/kldxref/ef_i386.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003 Jake Burkholder.
* Copyright 1996-1998 John D. Polstra.
@@ -25,74 +25,73 @@
* 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/types.h>
-#include <machine/elf.h>
+#include <sys/endian.h>
#include <err.h>
#include <errno.h>
+#include <gelf.h>
#include "ef.h"
/*
- * Apply relocations to the values we got from the file. `relbase' is the
- * target relocation address of the section, and `dataoff' is the target
- * relocation address of the data in `dest'.
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
*/
-int
-ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase,
- Elf_Off dataoff, size_t len, void *_dest)
+static int
+ef_i386_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
{
- Elf_Addr *where, addr, addend;
- Elf_Size rtype, symidx;
- const Elf_Rel *rel;
- const Elf_Rela *rela;
- char *dest = _dest;
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rel *rel;
+ const GElf_Rela *rela;
switch (reltype) {
- case EF_RELOC_REL:
- rel = (const Elf_Rel *)reldata;
- where = (Elf_Addr *)(dest + relbase + rel->r_offset - dataoff);
+ case ELF_T_REL:
+ rel = (const GElf_Rel *)reldata;
+ where = (char *)dest + (relbase + rel->r_offset - dataoff);
addend = 0;
- rtype = ELF_R_TYPE(rel->r_info);
- symidx = ELF_R_SYM(rel->r_info);
+ rtype = GELF_R_TYPE(rel->r_info);
+ symidx = GELF_R_SYM(rel->r_info);
break;
- case EF_RELOC_RELA:
- rela = (const Elf_Rela *)reldata;
- where = (Elf_Addr *)(dest + relbase + rela->r_offset - dataoff);
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
addend = rela->r_addend;
- rtype = ELF_R_TYPE(rela->r_info);
- symidx = ELF_R_SYM(rela->r_info);
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
break;
default:
return (EINVAL);
}
- if ((char *)where < (char *)dest || (char *)where >= (char *)dest + len)
+ if (where < (char *)dest || where >= (char *)dest + len)
return (0);
- if (reltype == EF_RELOC_REL)
- addend = *where;
+ if (reltype == ELF_T_REL)
+ addend = le32dec(where);
switch (rtype) {
- case R_386_RELATIVE: /* A + B */
- addr = (Elf_Addr)addend + relbase;
- *where = addr;
+ case R_386_RELATIVE: /* B + A */
+ addr = relbase + addend;
+ le32enc(where, addr);
break;
case R_386_32: /* S + A - P */
- addr = EF_SYMADDR(ef, symidx);
- addr += addend;
- *where = addr;
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le32enc(where, addr);
break;
case R_386_GLOB_DAT: /* S */
addr = EF_SYMADDR(ef, symidx);
- *where = addr;
+ le32enc(where, addr);
break;
default:
warnx("unhandled relocation type %d", (int)rtype);
}
return (0);
}
+
+ELF_RELOC(ELFCLASS32, ELFDATA2LSB, EM_386, ef_i386_reloc);
diff --git a/usr.sbin/kldxref/ef_mips.c b/usr.sbin/kldxref/ef_mips.c
index cf02eb203518..e4aeedb5c08b 100644
--- a/usr.sbin/kldxref/ef_mips.c
+++ b/usr.sbin/kldxref/ef_mips.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 John Baldwin <jhb@FreeBSD.org>
*
@@ -28,72 +28,89 @@
* 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/types.h>
-#include <machine/elf.h>
+#include <sys/endian.h>
#include <err.h>
#include <errno.h>
+#include <gelf.h>
#include "ef.h"
/*
- * Apply relocations to the values we got from the file. `relbase' is the
- * target relocation address of the section, and `dataoff' is the target
- * relocation address of the data in `dest'.
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
*/
-int
-ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase,
- Elf_Off dataoff, size_t len, void *dest)
+static int
+ef_mips_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
{
- Elf_Addr *where, val;
- const Elf_Rel *rel;
- const Elf_Rela *rela;
- Elf_Addr addend, addr;
- Elf_Size rtype, symidx;
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rel *rel;
+ const GElf_Rela *rela;
switch (reltype) {
- case EF_RELOC_REL:
- rel = (const Elf_Rel *)reldata;
- where = (Elf_Addr *)((char *)dest + relbase + rel->r_offset -
- dataoff);
+ case ELF_T_REL:
+ rel = (const GElf_Rel *)reldata;
+ where = (char *)dest + (relbase + rel->r_offset - dataoff);
addend = 0;
- rtype = ELF_R_TYPE(rel->r_info);
- symidx = ELF_R_SYM(rel->r_info);
+ rtype = GELF_R_TYPE(rel->r_info);
+ symidx = GELF_R_SYM(rel->r_info);
break;
- case EF_RELOC_RELA:
- rela = (const Elf_Rela *)reldata;
- where = (Elf_Addr *)((char *)dest + relbase + rela->r_offset -
- dataoff);
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
addend = rela->r_addend;
- rtype = ELF_R_TYPE(rela->r_info);
- symidx = ELF_R_SYM(rela->r_info);
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
break;
default:
return (EINVAL);
}
- if ((char *)where < (char *)dest || (char *)where >= (char *)dest + len)
+ if (where < (char *)dest || where >= (char *)dest + len)
return (0);
- if (reltype == EF_RELOC_REL)
- addend = *where;
+ if (reltype == ELF_T_REL) {
+ if (elf_class(ef) == ELFCLASS64) {
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ addend = le64dec(where);
+ else
+ addend = be64dec(where);
+ } else {
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ addend = le32dec(where);
+ else
+ addend = be32dec(where);
+ }
+ }
switch (rtype) {
-#ifdef __LP64__
case R_MIPS_64: /* S + A */
-#else
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ le64enc(where, addr);
+ else
+ be64enc(where, addr);
+ break;
case R_MIPS_32: /* S + A */
-#endif
- addr = EF_SYMADDR(ef, symidx);
- val = addr + addend;
- *where = val;
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ le32enc(where, addr);
+ else
+ be32enc(where, addr);
break;
default:
warnx("unhandled relocation type %d", (int)rtype);
}
return (0);
}
+
+ELF_RELOC(ELFCLASS32, ELFDATA2LSB, EM_MIPS, ef_mips_reloc);
+ELF_RELOC(ELFCLASS32, ELFDATA2MSB, EM_MIPS, ef_mips_reloc);
+ELF_RELOC(ELFCLASS64, ELFDATA2LSB, EM_MIPS, ef_mips_reloc);
+ELF_RELOC(ELFCLASS64, ELFDATA2MSB, EM_MIPS, ef_mips_reloc);
diff --git a/usr.sbin/kldxref/ef_obj.c b/usr.sbin/kldxref/ef_obj.c
index e1684bf810d9..ac83137cd394 100644
--- a/usr.sbin/kldxref/ef_obj.c
+++ b/usr.sbin/kldxref/ef_obj.c
@@ -32,55 +32,44 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <sys/param.h>
-#include <sys/linker.h>
#include <err.h>
#include <errno.h>
-#include <fcntl.h>
+#include <gelf.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <machine/elf.h>
-#define FREEBSD_ELF
#include "ef.h"
typedef struct {
- void *addr;
- Elf_Off size;
+ GElf_Addr addr;
+ GElf_Off offset;
+ GElf_Off size;
int flags;
int sec; /* Original section */
char *name;
} Elf_progent;
typedef struct {
- Elf_Rel *rel;
- int nrel;
+ GElf_Rel *rel;
+ long nrel;
int sec;
} Elf_relent;
typedef struct {
- Elf_Rela *rela;
- int nrela;
+ GElf_Rela *rela;
+ long nrela;
int sec;
} Elf_relaent;
struct ef_file {
char *ef_name;
- int ef_fd;
- Elf_Ehdr ef_hdr;
struct elf_file *ef_efile;
- caddr_t address;
- Elf_Off size;
- Elf_Shdr *e_shdr;
-
Elf_progent *progtab;
int nprogtab;
@@ -90,8 +79,8 @@ struct ef_file {
Elf_relent *reltab;
int nrel;
- Elf_Sym *ddbsymtab; /* The symbol table we are using */
- long ddbsymcnt; /* Number of symbols */
+ GElf_Sym *ddbsymtab; /* The symbol table we are using */
+ size_t ddbsymcnt; /* Number of symbols */
caddr_t ddbstrtab; /* String table */
long ddbstrcnt; /* number of bytes in string table */
@@ -101,54 +90,47 @@ struct ef_file {
int ef_verbose;
};
-static int ef_obj_get_type(elf_file_t ef);
-static int ef_obj_close(elf_file_t ef);
-static int ef_obj_read(elf_file_t ef, Elf_Off offset, size_t len,
- void* dest);
-static int ef_obj_read_entry(elf_file_t ef, Elf_Off offset, size_t len,
- void **ptr);
-static int ef_obj_seg_read(elf_file_t ef, Elf_Off offset, size_t len,
- void *dest);
-static int ef_obj_seg_read_rel(elf_file_t ef, Elf_Off offset, size_t len,
- void *dest);
-static int ef_obj_seg_read_string(elf_file_t ef, Elf_Off offset,
+static void ef_obj_close(elf_file_t ef);
+
+static int ef_obj_seg_read_rel(elf_file_t ef, GElf_Addr address,
+ size_t len, void *dest);
+static int ef_obj_seg_read_string(elf_file_t ef, GElf_Addr address,
size_t len, char *dest);
-static int ef_obj_seg_read_entry(elf_file_t ef, Elf_Off offset, size_t len,
- void **ptr);
-static int ef_obj_seg_read_entry_rel(elf_file_t ef, Elf_Off offset,
- size_t len, void **ptr);
-static Elf_Addr ef_obj_symaddr(elf_file_t ef, Elf_Size symidx);
-static int ef_obj_lookup_set(elf_file_t ef, const char *name, long *startp,
- long *stopp, long *countp);
-static int ef_obj_lookup_symbol(elf_file_t ef, const char* name,
- Elf_Sym** sym);
+
+static GElf_Addr ef_obj_symaddr(elf_file_t ef, GElf_Size symidx);
+static int ef_obj_lookup_set(elf_file_t ef, const char *name,
+ GElf_Addr *startp, GElf_Addr *stopp, long *countp);
+static int ef_obj_lookup_symbol(elf_file_t ef, const char *name,
+ GElf_Sym **sym);
static struct elf_file_ops ef_obj_file_ops = {
- .get_type = ef_obj_get_type,
.close = ef_obj_close,
- .read = ef_obj_read,
- .read_entry = ef_obj_read_entry,
- .seg_read = ef_obj_seg_read,
.seg_read_rel = ef_obj_seg_read_rel,
.seg_read_string = ef_obj_seg_read_string,
- .seg_read_entry = ef_obj_seg_read_entry,
- .seg_read_entry_rel = ef_obj_seg_read_entry_rel,
.symaddr = ef_obj_symaddr,
.lookup_set = ef_obj_lookup_set,
- .lookup_symbol = ef_obj_lookup_symbol
};
-static int
-ef_obj_get_type(elf_file_t __unused ef)
+static GElf_Off
+ef_obj_get_offset(elf_file_t ef, GElf_Addr addr)
{
+ Elf_progent *pt;
+ int i;
- return (EFT_KLD);
+ for (i = 0; i < ef->nprogtab; i++) {
+ pt = &ef->progtab[i];
+ if (pt->offset == (GElf_Off)-1)
+ continue;
+ if (addr >= pt->addr && addr < pt->addr + pt->size)
+ return (pt->offset + (addr - pt->addr));
+ }
+ return (0);
}
static int
-ef_obj_lookup_symbol(elf_file_t ef, const char* name, Elf_Sym** sym)
+ef_obj_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym)
{
- Elf_Sym *symp;
+ GElf_Sym *symp;
const char *strp;
int i;
@@ -163,119 +145,78 @@ ef_obj_lookup_symbol(elf_file_t ef, const char* name, Elf_Sym** sym)
}
static int
-ef_obj_lookup_set(elf_file_t ef, const char *name, long *startp, long *stopp,
- long *countp)
+ef_obj_lookup_set(elf_file_t ef, const char *name, GElf_Addr *startp,
+ GElf_Addr *stopp, long *countp)
{
int i;
for (i = 0; i < ef->nprogtab; i++) {
if ((strncmp(ef->progtab[i].name, "set_", 4) == 0) &&
strcmp(ef->progtab[i].name + 4, name) == 0) {
- *startp = (char *)ef->progtab[i].addr - ef->address;
- *stopp = (char *)ef->progtab[i].addr +
- ef->progtab[i].size - ef->address;
- *countp = (*stopp - *startp) / sizeof(void *);
+ *startp = ef->progtab[i].addr;
+ *stopp = ef->progtab[i].addr + ef->progtab[i].size;
+ *countp = (*stopp - *startp) /
+ elf_pointer_size(ef->ef_efile);
return (0);
}
}
return (ESRCH);
}
-static Elf_Addr
-ef_obj_symaddr(elf_file_t ef, Elf_Size symidx)
+static GElf_Addr
+ef_obj_symaddr(elf_file_t ef, GElf_Size symidx)
{
- const Elf_Sym *sym;
+ const GElf_Sym *sym;
- if (symidx >= (size_t) ef->ddbsymcnt)
+ if (symidx >= ef->ddbsymcnt)
return (0);
sym = ef->ddbsymtab + symidx;
if (sym->st_shndx != SHN_UNDEF)
- return (sym->st_value - (Elf_Addr)ef->address);
- return (0);
-}
-
-static int
-ef_obj_read(elf_file_t ef, Elf_Off offset, size_t len, void *dest)
-{
- ssize_t r;
-
- if (offset != (Elf_Off)-1) {
- if (lseek(ef->ef_fd, offset, SEEK_SET) == -1)
- return (EIO);
- }
-
- r = read(ef->ef_fd, dest, len);
- if (r != -1 && (size_t)r == len)
- return (0);
- else
- return (EIO);
-}
-
-static int
-ef_obj_read_entry(elf_file_t ef, Elf_Off offset, size_t len, void **ptr)
-{
- int error;
-
- *ptr = malloc(len);
- if (*ptr == NULL)
- return (errno);
- error = ef_obj_read(ef, offset, len, *ptr);
- if (error != 0)
- free(*ptr);
- return (error);
-}
-
-static int
-ef_obj_seg_read(elf_file_t ef, Elf_Off offset, size_t len, void *dest)
-{
-
- if (offset + len > ef->size) {
- if (ef->ef_verbose)
- warnx("ef_obj_seg_read(%s): bad offset/len (%lx:%ld)",
- ef->ef_name, (long)offset, (long)len);
- return (EFAULT);
- }
- bcopy(ef->address + offset, dest, len);
+ return (sym->st_value);
return (0);
}
static int
-ef_obj_seg_read_rel(elf_file_t ef, Elf_Off offset, size_t len, void *dest)
+ef_obj_seg_read_rel(elf_file_t ef, GElf_Addr address, size_t len, void *dest)
{
- char *memaddr;
- Elf_Rel *r;
- Elf_Rela *a;
- Elf_Off secbase, dataoff;
+ GElf_Off secofs;
+ GElf_Rel *r;
+ GElf_Rela *a;
+ GElf_Addr secbase, dataoff;
int error, i, sec;
- if (offset + len > ef->size) {
- if (ef->ef_verbose)
- warnx("ef_obj_seg_read_rel(%s): bad offset/len (%lx:%ld)",
- ef->ef_name, (long)offset, (long)len);
- return (EFAULT);
- }
- bcopy(ef->address + offset, dest, len);
-
/* Find out which section contains the data. */
- memaddr = ef->address + offset;
sec = -1;
- secbase = dataoff = 0;
for (i = 0; i < ef->nprogtab; i++) {
- if (ef->progtab[i].addr == NULL)
+ if (address < ef->progtab[i].addr)
continue;
- if (memaddr < (char *)ef->progtab[i].addr || memaddr + len >
- (char *)ef->progtab[i].addr + ef->progtab[i].size)
+
+ dataoff = address - ef->progtab[i].addr;
+ if (dataoff + len > ef->progtab[i].size)
continue;
+
sec = ef->progtab[i].sec;
- /* We relocate to address 0. */
- secbase = (char *)ef->progtab[i].addr - ef->address;
- dataoff = memaddr - ef->address;
+ secbase = ef->progtab[i].addr;
+ secofs = ef->progtab[i].offset;
break;
}
- if (sec == -1)
+ if (sec == -1) {
+ if (ef->ef_verbose)
+ warnx("ef_obj_seg_read_rel(%s): bad address (%jx)",
+ ef->ef_name, (uintmax_t)address);
return (EFAULT);
+ }
+
+ if (secofs == (GElf_Off)-1) {
+ memset(dest, 0, len);
+ } else {
+ error = elf_read_raw_data(ef->ef_efile, secofs + dataoff, dest,
+ len);
+ if (error != 0)
+ return (error);
+ }
/* Now do the relocations. */
for (i = 0; i < ef->nrel; i++) {
@@ -283,8 +224,8 @@ ef_obj_seg_read_rel(elf_file_t ef, Elf_Off offset, size_t len, void *dest)
continue;
for (r = ef->reltab[i].rel;
r < &ef->reltab[i].rel[ef->reltab[i].nrel]; r++) {
- error = ef_reloc(ef->ef_efile, r, EF_RELOC_REL, secbase,
- dataoff, len, dest);
+ error = elf_reloc(ef->ef_efile, r, ELF_T_REL, secbase,
+ address, len, dest);
if (error != 0)
return (error);
}
@@ -294,8 +235,8 @@ ef_obj_seg_read_rel(elf_file_t ef, Elf_Off offset, size_t len, void *dest)
continue;
for (a = ef->relatab[i].rela;
a < &ef->relatab[i].rela[ef->relatab[i].nrela]; a++) {
- error = ef_reloc(ef->ef_efile, a, EF_RELOC_RELA,
- secbase, dataoff, len, dest);
+ error = elf_reloc(ef->ef_efile, a, ELF_T_RELA, secbase,
+ address, len, dest);
if (error != 0)
return (error);
}
@@ -304,117 +245,60 @@ ef_obj_seg_read_rel(elf_file_t ef, Elf_Off offset, size_t len, void *dest)
}
static int
-ef_obj_seg_read_string(elf_file_t ef, Elf_Off offset, size_t len, char *dest)
+ef_obj_seg_read_string(elf_file_t ef, GElf_Addr address, size_t len, char *dest)
{
+ GElf_Off ofs;
- if (offset >= ef->size) {
+ ofs = ef_obj_get_offset(ef, address);
+ if (ofs == 0) {
if (ef->ef_verbose)
- warnx("ef_obj_seg_read_string(%s): bad offset (%lx)",
- ef->ef_name, (long)offset);
+ warnx("ef_obj_seg_read_string(%s): bad address (%jx)",
+ ef->ef_name, (uintmax_t)address);
return (EFAULT);
}
- if (ef->size - offset < len)
- len = ef->size - offset;
-
- if (strnlen(ef->address + offset, len) == len)
- return (EFAULT);
-
- memcpy(dest, ef->address + offset, len);
- return (0);
-}
-
-static int
-ef_obj_seg_read_entry(elf_file_t ef, Elf_Off offset, size_t len, void **ptr)
-{
- int error;
-
- *ptr = malloc(len);
- if (*ptr == NULL)
- return (errno);
- error = ef_obj_seg_read(ef, offset, len, *ptr);
- if (error != 0)
- free(*ptr);
- return (error);
-}
-
-static int
-ef_obj_seg_read_entry_rel(elf_file_t ef, Elf_Off offset, size_t len,
- void **ptr)
-{
- int error;
-
- *ptr = malloc(len);
- if (*ptr == NULL)
- return (errno);
- error = ef_obj_seg_read_rel(ef, offset, len, *ptr);
- if (error != 0)
- free(*ptr);
- return (error);
+ return (elf_read_raw_string(ef->ef_efile, ofs, dest, len));
}
int
-ef_obj_open(const char *filename, struct elf_file *efile, int verbose)
+ef_obj_open(struct elf_file *efile, int verbose)
{
elf_file_t ef;
- Elf_Ehdr *hdr;
- Elf_Shdr *shdr;
- Elf_Sym *es;
- char *mapbase;
- void *vtmp;
- size_t mapsize, alignmask, max_addralign;
- int error, fd, pb, ra, res, rl;
- int i, j, nbytes, nsym, shstrindex, symstrindex, symtabindex;
-
- if (filename == NULL)
- return (EINVAL);
- if ((fd = open(filename, O_RDONLY)) == -1)
- return (errno);
+ GElf_Ehdr *hdr;
+ GElf_Shdr *shdr;
+ GElf_Sym *es;
+ GElf_Addr mapbase;
+ size_t i, nshdr;
+ int error, pb, ra, rl;
+ int j, nsym, symstrindex, symtabindex;
+
+ hdr = &efile->ef_hdr;
+ if (hdr->e_type != ET_REL || hdr->e_shnum == 0 || hdr->e_shoff == 0 ||
+ hdr->e_shentsize != elf_object_size(efile, ELF_T_SHDR))
+ return (EFTYPE);
ef = calloc(1, sizeof(*ef));
- if (ef == NULL) {
- close(fd);
+ if (ef == NULL)
return (errno);
- }
efile->ef_ef = ef;
efile->ef_ops = &ef_obj_file_ops;
ef->ef_verbose = verbose;
- ef->ef_fd = fd;
- ef->ef_name = strdup(filename);
+ ef->ef_name = strdup(efile->ef_filename);
ef->ef_efile = efile;
- hdr = (Elf_Ehdr *)&ef->ef_hdr;
- res = read(fd, hdr, sizeof(*hdr));
- error = EFTYPE;
- if (res != sizeof(*hdr))
- goto out;
- if (!IS_ELF(*hdr))
- goto out;
- if (hdr->e_ident[EI_CLASS] != ELF_TARG_CLASS ||
- hdr->e_ident[EI_DATA] != ELF_TARG_DATA ||
- hdr->e_ident[EI_VERSION] != EV_CURRENT ||
- hdr->e_version != EV_CURRENT || hdr->e_machine != ELF_TARG_MACH ||
- hdr->e_type != ET_REL)
- goto out;
-
- nbytes = hdr->e_shnum * hdr->e_shentsize;
- if (nbytes == 0 || hdr->e_shoff == 0 ||
- hdr->e_shentsize != sizeof(Elf_Shdr))
- goto out;
-
- if (ef_obj_read_entry(ef, hdr->e_shoff, nbytes, &vtmp) != 0) {
- printf("ef_read_entry failed\n");
+ error = elf_read_shdrs(efile, &nshdr, &shdr);
+ if (error != 0) {
+ shdr = NULL;
goto out;
}
- ef->e_shdr = shdr = vtmp;
- /* Scan the section header for information and table sizing. */
+ /* Scan the section headers for information and table sizing. */
nsym = 0;
symtabindex = -1;
symstrindex = -1;
- for (i = 0; i < hdr->e_shnum; i++) {
+ for (i = 0; i < nshdr; i++) {
switch (shdr[i].sh_type) {
case SHT_PROGBITS:
case SHT_NOBITS:
@@ -437,16 +321,16 @@ ef_obj_open(const char *filename, struct elf_file *efile, int verbose)
}
if (ef->nprogtab == 0) {
- warnx("%s: file has no contents", filename);
+ warnx("%s: file has no contents", ef->ef_name);
goto out;
}
if (nsym != 1) {
- warnx("%s: file has no valid symbol table", filename);
+ warnx("%s: file has no valid symbol table", ef->ef_name);
goto out;
}
- if (symstrindex < 0 || symstrindex > hdr->e_shnum ||
+ if (symstrindex < 0 || symstrindex > nshdr ||
shdr[symstrindex].sh_type != SHT_STRTAB) {
- warnx("%s: file has invalid symbol strings", filename);
+ warnx("%s: file has invalid symbol strings", ef->ef_name);
goto out;
}
@@ -465,86 +349,48 @@ ef_obj_open(const char *filename, struct elf_file *efile, int verbose)
goto out;
}
- ef->ddbsymcnt = shdr[symtabindex].sh_size / sizeof(Elf_Sym);
- if (ef_obj_read_entry(ef, shdr[symtabindex].sh_offset,
- shdr[symtabindex].sh_size, (void**)&ef->ddbsymtab) != 0) {
- printf("ef_read_entry failed\n");
+ if (elf_read_symbols(efile, symtabindex, &ef->ddbsymcnt,
+ &ef->ddbsymtab) != 0) {
+ printf("elf_read_symbols failed\n");
goto out;
}
- ef->ddbstrcnt = shdr[symstrindex].sh_size;
- if (ef_obj_read_entry(ef, shdr[symstrindex].sh_offset,
- shdr[symstrindex].sh_size, (void**)&ef->ddbstrtab) != 0) {
- printf("ef_read_entry failed\n");
+ if (elf_read_string_table(efile, &shdr[symstrindex], &ef->ddbstrcnt,
+ &ef->ddbstrtab) != 0) {
+ printf("elf_read_string_table failed\n");
goto out;
}
/* Do we have a string table for the section names? */
- shstrindex = -1;
if (hdr->e_shstrndx != 0 &&
shdr[hdr->e_shstrndx].sh_type == SHT_STRTAB) {
- shstrindex = hdr->e_shstrndx;
- ef->shstrcnt = shdr[shstrindex].sh_size;
- if (ef_obj_read_entry(ef, shdr[shstrindex].sh_offset,
- shdr[shstrindex].sh_size, (void**)&ef->shstrtab) != 0) {
- printf("ef_read_entry failed\n");
+ if (elf_read_string_table(efile, &shdr[hdr->e_shstrndx],
+ &ef->shstrcnt, &ef->shstrtab) != 0) {
+ printf("elf_read_string_table failed\n");
goto out;
}
}
- /* Size up code/data(progbits) and bss(nobits). */
- alignmask = 0;
- max_addralign = 0;
- mapsize = 0;
- for (i = 0; i < hdr->e_shnum; i++) {
- switch (shdr[i].sh_type) {
- case SHT_PROGBITS:
- case SHT_NOBITS:
- alignmask = shdr[i].sh_addralign - 1;
- if (shdr[i].sh_addralign > max_addralign)
- max_addralign = shdr[i].sh_addralign;
- mapsize += alignmask;
- mapsize &= ~alignmask;
- mapsize += shdr[i].sh_size;
- break;
- }
- }
-
- /* We know how much space we need for the text/data/bss/etc. */
- ef->size = mapsize;
- if (posix_memalign((void **)&ef->address, max_addralign, mapsize)) {
- printf("posix_memalign failed\n");
- goto out;
- }
- mapbase = ef->address;
-
/*
- * Now load code/data(progbits), zero bss(nobits), allocate
- * space for and load relocs
+ * Now allocate address space for code/data(progbits) and
+ * bss(nobits) and allocate space for and load relocs.
*/
pb = 0;
rl = 0;
ra = 0;
- alignmask = 0;
- for (i = 0; i < hdr->e_shnum; i++) {
+ mapbase = 0;
+ for (i = 0; i < nshdr; i++) {
switch (shdr[i].sh_type) {
case SHT_PROGBITS:
case SHT_NOBITS:
- alignmask = shdr[i].sh_addralign - 1;
- mapbase += alignmask;
- mapbase = (char *)((uintptr_t)mapbase & ~alignmask);
- ef->progtab[pb].addr = (void *)(uintptr_t)mapbase;
+ mapbase = roundup2(mapbase, shdr[i].sh_addralign);
+ ef->progtab[pb].addr = mapbase;
if (shdr[i].sh_type == SHT_PROGBITS) {
ef->progtab[pb].name = "<<PROGBITS>>";
- if (ef_obj_read(ef, shdr[i].sh_offset,
- shdr[i].sh_size,
- ef->progtab[pb].addr) != 0) {
- printf("failed to read progbits\n");
- goto out;
- }
+ ef->progtab[pb].offset = shdr[i].sh_offset;
} else {
ef->progtab[pb].name = "<<NOBITS>>";
- bzero(ef->progtab[pb].addr, shdr[i].sh_size);
+ ef->progtab[pb].offset = (GElf_Off)-1;
}
ef->progtab[pb].size = shdr[i].sh_size;
ef->progtab[pb].sec = i;
@@ -557,30 +403,25 @@ ef_obj_open(const char *filename, struct elf_file *efile, int verbose)
es = &ef->ddbsymtab[j];
if (es->st_shndx != i)
continue;
- es->st_value += (Elf_Addr)ef->progtab[pb].addr;
+ es->st_value += ef->progtab[pb].addr;
}
mapbase += shdr[i].sh_size;
pb++;
break;
case SHT_REL:
- ef->reltab[rl].nrel = shdr[i].sh_size / sizeof(Elf_Rel);
ef->reltab[rl].sec = shdr[i].sh_info;
- if (ef_obj_read_entry(ef, shdr[i].sh_offset,
- shdr[i].sh_size, (void**)&ef->reltab[rl].rel) !=
- 0) {
- printf("ef_read_entry failed\n");
+ if (elf_read_rel(efile, i, &ef->reltab[rl].nrel,
+ &ef->reltab[rl].rel) != 0) {
+ printf("elf_read_rel failed\n");
goto out;
}
rl++;
break;
case SHT_RELA:
- ef->relatab[ra].nrela =
- shdr[i].sh_size / sizeof(Elf_Rela);
ef->relatab[ra].sec = shdr[i].sh_info;
- if (ef_obj_read_entry(ef, shdr[i].sh_offset,
- shdr[i].sh_size, (void**)&ef->relatab[ra].rela) !=
- 0) {
- printf("ef_read_entry failed\n");
+ if (elf_read_rela(efile, i, &ef->relatab[ra].nrela,
+ &ef->relatab[ra].rela) != 0) {
+ printf("elf_read_rela failed\n");
goto out;
}
ra++;
@@ -589,23 +430,19 @@ ef_obj_open(const char *filename, struct elf_file *efile, int verbose)
}
error = 0;
out:
+ free(shdr);
if (error != 0)
ef_obj_close(ef);
return (error);
}
-static int
+static void
ef_obj_close(elf_file_t ef)
{
int i;
- close(ef->ef_fd);
if (ef->ef_name)
free(ef->ef_name);
- if (ef->e_shdr != NULL)
- free(ef->e_shdr);
- if (ef->size != 0)
- free(ef->address);
if (ef->nprogtab != 0)
free(ef->progtab);
if (ef->nrel != 0) {
@@ -629,6 +466,4 @@ ef_obj_close(elf_file_t ef)
ef->ef_efile->ef_ops = NULL;
ef->ef_efile->ef_ef = NULL;
free(ef);
-
- return (0);
}
diff --git a/usr.sbin/kldxref/ef_powerpc.c b/usr.sbin/kldxref/ef_powerpc.c
index 45eca477abcd..f72cc1d85e20 100644
--- a/usr.sbin/kldxref/ef_powerpc.c
+++ b/usr.sbin/kldxref/ef_powerpc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Peter Grehan.
* Copyright 1996-1998 John D. Polstra.
@@ -25,67 +25,73 @@
* 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/types.h>
-#include <machine/elf.h>
+#include <sys/endian.h>
#include <err.h>
#include <errno.h>
-#include <inttypes.h>
-#include <string.h>
+#include <gelf.h>
#include "ef.h"
-#ifdef __powerpc64__
-#define PRI_ELF_SIZE PRIu64
-#else
-#define PRI_ELF_SIZE PRIu32
-#endif
-
/*
* Apply relocations to the values obtained from the file. `relbase' is the
* target relocation address of the section, and `dataoff/len' is the region
* that is to be relocated, and has been copied to *dest
*/
-int
-ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase,
- Elf_Off dataoff, size_t len, void *dest)
+static int
+ef_ppc_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
{
- Elf_Addr *where, addend;
- Elf32_Addr *where32;
- Elf_Size rtype, symidx;
- const Elf_Rela *rela;
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rela *rela;
- if (reltype != EF_RELOC_RELA)
+ switch (reltype) {
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
+ addend = rela->r_addend;
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
+ break;
+ default:
return (EINVAL);
+ }
- rela = (const Elf_Rela *)reldata;
- where = (Elf_Addr *) ((Elf_Off)dest - dataoff + rela->r_offset);
- where32 = (Elf32_Addr *) ((Elf_Off)dest - dataoff + rela->r_offset);
- addend = rela->r_addend;
- rtype = ELF_R_TYPE(rela->r_info);
- symidx = ELF_R_SYM(rela->r_info);
-
- if ((char *)where < (char *)dest || (char *)where >= (char *)dest + len)
+ if (where < (char *)dest || where >= (char *)dest + len)
return (0);
switch (rtype) {
case R_PPC_RELATIVE: /* word32|doubleword64 B + A */
- *where = relbase + addend;
+ addr = relbase + addend;
+ if (elf_class(ef) == ELFCLASS64) {
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ le64enc(where, addr);
+ else
+ be64enc(where, addr);
+ } else
+ be32enc(where, addr);
break;
case R_PPC_ADDR32: /* word32 S + A */
- *where32 = EF_SYMADDR(ef, symidx) + addend;
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ be32enc(where, addr);
break;
-#ifdef __powerpc64__
case R_PPC64_ADDR64: /* doubleword64 S + A */
- *where = EF_SYMADDR(ef, symidx) + addend;
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ le64enc(where, addr);
+ else
+ be64enc(where, addr);
break;
-#endif
default:
- warnx("unhandled relocation type %" PRI_ELF_SIZE, rtype);
+ warnx("unhandled relocation type %d", (int)rtype);
}
return (0);
}
+
+ELF_RELOC(ELFCLASS32, ELFDATA2MSB, EM_PPC, ef_ppc_reloc);
+ELF_RELOC(ELFCLASS64, ELFDATA2LSB, EM_PPC64, ef_ppc_reloc);
+ELF_RELOC(ELFCLASS64, ELFDATA2MSB, EM_PPC64, ef_ppc_reloc);
diff --git a/usr.sbin/kldxref/ef_riscv.c b/usr.sbin/kldxref/ef_riscv.c
index e0caae3bd286..46b9b66bee58 100644
--- a/usr.sbin/kldxref/ef_riscv.c
+++ b/usr.sbin/kldxref/ef_riscv.c
@@ -30,49 +30,56 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <machine/elf.h>
+#include <sys/endian.h>
#include <err.h>
#include <errno.h>
+#include <gelf.h>
#include "ef.h"
-int
-ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase,
- Elf_Off dataoff, size_t len, void *dest)
+/*
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
+ */
+static int
+ef_riscv_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
{
- Elf_Addr *where, val;
- const Elf_Rela *rela;
- Elf_Addr addend, addr;
- Elf_Size rtype;
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rela *rela;
switch (reltype) {
- case EF_RELOC_RELA:
- rela = (const Elf_Rela *)reldata;
- where = (Elf_Addr *)((char *)dest + relbase + rela->r_offset -
- dataoff);
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
addend = rela->r_addend;
- rtype = ELF_R_TYPE(rela->r_info);
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
break;
default:
return (EINVAL);
}
- if ((char *)where < (char *)dest || (char *)where >= (char *)dest + len)
+ if (where < (char *)dest || where >= (char *)dest + len)
return (0);
switch (rtype) {
+ case R_RISCV_64: /* S + A */
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le64enc(where, addr);
+ break;
case R_RISCV_RELATIVE: /* B + A */
- addr = addend + relbase;
- val = addr;
- *where = val;
+ addr = relbase + addend;
+ le64enc(where, addr);
break;
default:
warnx("unhandled relocation type %d", (int)rtype);
}
return (0);
}
+
+ELF_RELOC(ELFCLASS64, ELFDATA2LSB, EM_RISCV, ef_riscv_reloc);
diff --git a/usr.sbin/kldxref/elf.c b/usr.sbin/kldxref/elf.c
new file mode 100644
index 000000000000..f98c39b69c0b
--- /dev/null
+++ b/usr.sbin/kldxref/elf.c
@@ -0,0 +1,688 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2021-2023 John Baldwin <jhb@FreeBSD.org>
+ *
+ * This software was developed by SRI International and the University
+ * of Cambridge Computer Laboratory (Department of Computer Science
+ * and Technology) under Defense Advanced Research Projects Agency
+ * (DARPA) contract HR0011-18-C-0016 ("ECATS"), as part of the DARPA
+ * SSITH research programme and under DARPA Contract No. HR001123C0031
+ * ("MTSS").
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/endian.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <gelf.h>
+#include <libelf.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "ef.h"
+
+SET_DECLARE(elf_reloc, struct elf_reloc_data);
+
+static elf_reloc_t *
+elf_find_reloc(const GElf_Ehdr *hdr)
+{
+ struct elf_reloc_data **erd;
+
+ SET_FOREACH(erd, elf_reloc) {
+ if (hdr->e_ident[EI_CLASS] == (*erd)->class &&
+ hdr->e_ident[EI_DATA] == (*erd)->data &&
+ hdr->e_machine == (*erd)->machine)
+ return ((*erd)->reloc);
+ }
+ return (NULL);
+}
+
+int
+elf_open_file(struct elf_file *efile, const char *filename, int verbose)
+{
+ int error;
+
+ memset(efile, 0, sizeof(*efile));
+ efile->ef_filename = filename;
+ efile->ef_fd = open(filename, O_RDONLY);
+ if (efile->ef_fd == -1) {
+ if (verbose)
+ warn("open(%s)", filename);
+ return (errno);
+ }
+
+ efile->ef_elf = elf_begin(efile->ef_fd, ELF_C_READ, NULL);
+ if (efile->ef_elf == NULL) {
+ if (verbose)
+ warnx("elf_begin(%s): %s", filename, elf_errmsg(0));
+ elf_close_file(efile);
+ return (EINVAL);
+ }
+
+ if (elf_kind(efile->ef_elf) != ELF_K_ELF) {
+ if (verbose)
+ warnx("%s: not an ELF file", filename);
+ elf_close_file(efile);
+ return (EINVAL);
+ }
+
+ if (gelf_getehdr(efile->ef_elf, &efile->ef_hdr) == NULL) {
+ if (verbose)
+ warnx("gelf_getehdr(%s): %s", filename, elf_errmsg(0));
+ elf_close_file(efile);
+ return (EINVAL);
+ }
+
+ efile->ef_reloc = elf_find_reloc(&efile->ef_hdr);
+ if (efile->ef_reloc == NULL) {
+ if (verbose)
+ warnx("%s: unsupported architecture", filename);
+ elf_close_file(efile);
+ return (EFTYPE);
+ }
+
+ error = ef_open(efile, verbose);
+ if (error != 0) {
+ error = ef_obj_open(efile, verbose);
+ if (error != 0) {
+ if (verbose)
+ warnc(error, "%s: not a valid DSO or object file",
+ filename);
+ elf_close_file(efile);
+ return (error);
+ }
+ }
+
+ efile->ef_pointer_size = elf_object_size(efile, ELF_T_ADDR);
+
+ return (0);
+}
+
+void
+elf_close_file(struct elf_file *efile)
+{
+ if (efile->ef_ops != NULL) {
+ EF_CLOSE(efile);
+ }
+ if (efile->ef_elf != NULL) {
+ elf_end(efile->ef_elf);
+ efile->ef_elf = NULL;
+ }
+ if (efile->ef_fd > 0) {
+ close(efile->ef_fd);
+ efile->ef_fd = -1;
+ }
+}
+
+bool
+elf_compatible(struct elf_file *efile, const GElf_Ehdr *hdr)
+{
+ if (efile->ef_hdr.e_ident[EI_CLASS] != hdr->e_ident[EI_CLASS] ||
+ efile->ef_hdr.e_ident[EI_DATA] != hdr->e_ident[EI_DATA] ||
+ efile->ef_hdr.e_machine != hdr->e_machine)
+ return (false);
+ return (true);
+}
+
+size_t
+elf_object_size(struct elf_file *efile, Elf_Type type)
+{
+ return (gelf_fsize(efile->ef_elf, type, 1, efile->ef_hdr.e_version));
+}
+
+/*
+ * The number of objects of 'type' in region of the file of size
+ * 'file_size'.
+ */
+static size_t
+elf_object_count(struct elf_file *efile, Elf_Type type, size_t file_size)
+{
+ return (file_size / elf_object_size(efile, type));
+}
+
+int
+elf_read_raw_data(struct elf_file *efile, off_t offset, void *dst, size_t len)
+{
+ ssize_t nread;
+
+ nread = pread(efile->ef_fd, dst, len, offset);
+ if (nread == -1)
+ return (errno);
+ if (nread != len)
+ return (EIO);
+ return (0);
+}
+
+int
+elf_read_raw_data_alloc(struct elf_file *efile, off_t offset, size_t len,
+ void **out)
+{
+ void *buf;
+ int error;
+
+ buf = malloc(len);
+ if (buf == NULL)
+ return (ENOMEM);
+ error = elf_read_raw_data(efile, offset, buf, len);
+ if (error != 0) {
+ free(buf);
+ return (error);
+ }
+ *out = buf;
+ return (0);
+}
+
+int
+elf_read_raw_string(struct elf_file *efile, off_t offset, char *dst, size_t len)
+{
+ ssize_t nread;
+
+ nread = pread(efile->ef_fd, dst, len, offset);
+ if (nread == -1)
+ return (errno);
+ if (nread == 0)
+ return (EIO);
+
+ /* A short read is ok so long as the data contains a terminator. */
+ if (strnlen(dst, nread) == nread)
+ return (EFAULT);
+
+ return (0);
+}
+
+int
+elf_read_data(struct elf_file *efile, Elf_Type type, off_t offset, size_t len,
+ void **out)
+{
+ Elf_Data dst, src;
+ void *buf;
+ int error;
+
+ buf = malloc(len);
+ if (buf == NULL)
+ return (ENOMEM);
+
+ error = elf_read_raw_data(efile, offset, buf, len);
+ if (error != 0) {
+ free(buf);
+ return (error);
+ }
+
+ memset(&dst, 0, sizeof(dst));
+ memset(&src, 0, sizeof(src));
+
+ src.d_buf = buf;
+ src.d_size = len;
+ src.d_type = type;
+ src.d_version = efile->ef_hdr.e_version;
+
+ dst.d_buf = buf;
+ dst.d_size = len;
+ dst.d_version = EV_CURRENT;
+
+ if (gelf_xlatetom(efile->ef_elf, &dst, &src, elf_encoding(efile)) ==
+ NULL) {
+ free(buf);
+ return (ENXIO);
+ }
+
+ if (dst.d_size != len)
+ warnx("elf_read_data: translation of type %u size mismatch",
+ type);
+
+ *out = buf;
+ return (0);
+}
+
+int
+elf_read_relocated_data(struct elf_file *efile, GElf_Addr address, size_t len,
+ void **buf)
+{
+ int error;
+ void *p;
+
+ p = malloc(len);
+ if (p == NULL)
+ return (ENOMEM);
+ error = EF_SEG_READ_REL(efile, address, len, p);
+ if (error != 0) {
+ free(p);
+ return (error);
+ }
+ *buf = p;
+ return (0);
+}
+
+int
+elf_read_phdrs(struct elf_file *efile, size_t *nphdrp, GElf_Phdr **phdrp)
+{
+ GElf_Phdr *phdr;
+ size_t nphdr, i;
+ int error;
+
+ if (elf_getphdrnum(efile->ef_elf, &nphdr) == -1)
+ return (EFTYPE);
+
+ phdr = calloc(nphdr, sizeof(*phdr));
+ if (phdr == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < nphdr; i++) {
+ if (gelf_getphdr(efile->ef_elf, i, &phdr[i]) == NULL) {
+ error = EFTYPE;
+ goto out;
+ }
+ }
+
+ *nphdrp = nphdr;
+ *phdrp = phdr;
+ return (0);
+out:
+ free(phdr);
+ return (error);
+}
+
+int
+elf_read_shdrs(struct elf_file *efile, size_t *nshdrp, GElf_Shdr **shdrp)
+{
+ GElf_Shdr *shdr;
+ Elf_Scn *scn;
+ size_t nshdr, i;
+ int error;
+
+ if (elf_getshdrnum(efile->ef_elf, &nshdr) == -1)
+ return (EFTYPE);
+
+ shdr = calloc(nshdr, sizeof(*shdr));
+ if (shdr == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < nshdr; i++) {
+ scn = elf_getscn(efile->ef_elf, i);
+ if (scn == NULL) {
+ error = EFTYPE;
+ goto out;
+ }
+ if (gelf_getshdr(scn, &shdr[i]) == NULL) {
+ error = EFTYPE;
+ goto out;
+ }
+ }
+
+ *nshdrp = nshdr;
+ *shdrp = shdr;
+ return (0);
+out:
+ free(shdr);
+ return (error);
+}
+
+int
+elf_read_dynamic(struct elf_file *efile, int section_index, size_t *ndynp,
+ GElf_Dyn **dynp)
+{
+ GElf_Shdr shdr;
+ Elf_Scn *scn;
+ Elf_Data *data;
+ GElf_Dyn *dyn;
+ long i, ndyn;
+
+ scn = elf_getscn(efile->ef_elf, section_index);
+ if (scn == NULL)
+ return (EINVAL);
+ if (gelf_getshdr(scn, &shdr) == NULL)
+ return (EINVAL);
+ data = elf_getdata(scn, NULL);
+ if (data == NULL)
+ return (EINVAL);
+
+ ndyn = elf_object_count(efile, ELF_T_DYN, shdr.sh_size);
+ dyn = calloc(ndyn, sizeof(*dyn));
+ if (dyn == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < ndyn; i++) {
+ if (gelf_getdyn(data, i, &dyn[i]) == NULL) {
+ free(dyn);
+ return (EINVAL);
+ }
+ }
+
+ *ndynp = ndyn;
+ *dynp = dyn;
+ return (0);
+}
+
+int
+elf_read_symbols(struct elf_file *efile, int section_index, size_t *nsymp,
+ GElf_Sym **symp)
+{
+ GElf_Shdr shdr;
+ Elf_Scn *scn;
+ Elf_Data *data;
+ GElf_Sym *sym;
+ size_t i, nsym;
+
+ scn = elf_getscn(efile->ef_elf, section_index);
+ if (scn == NULL)
+ return (EINVAL);
+ if (gelf_getshdr(scn, &shdr) == NULL)
+ return (EINVAL);
+ data = elf_getdata(scn, NULL);
+ if (data == NULL)
+ return (EINVAL);
+
+ nsym = elf_object_count(efile, ELF_T_SYM, shdr.sh_size);
+ sym = calloc(nsym, sizeof(*sym));
+ if (sym == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < nsym; i++) {
+ if (gelf_getsym(data, i, &sym[i]) == NULL) {
+ free(sym);
+ return (EINVAL);
+ }
+ }
+
+ *nsymp = nsym;
+ *symp = sym;
+ return (0);
+}
+
+int
+elf_read_string_table(struct elf_file *efile, const GElf_Shdr *shdr,
+ long *strcnt, char **strtab)
+{
+ int error;
+
+ if (shdr->sh_type != SHT_STRTAB)
+ return (EINVAL);
+ error = elf_read_raw_data_alloc(efile, shdr->sh_offset, shdr->sh_size,
+ (void **)strtab);
+ if (error != 0)
+ return (error);
+ *strcnt = shdr->sh_size;
+ return (0);
+}
+
+int
+elf_read_rel(struct elf_file *efile, int section_index, long *nrelp,
+ GElf_Rel **relp)
+{
+ GElf_Shdr shdr;
+ Elf_Scn *scn;
+ Elf_Data *data;
+ GElf_Rel *rel;
+ long i, nrel;
+
+ scn = elf_getscn(efile->ef_elf, section_index);
+ if (scn == NULL)
+ return (EINVAL);
+ if (gelf_getshdr(scn, &shdr) == NULL)
+ return (EINVAL);
+ data = elf_getdata(scn, NULL);
+ if (data == NULL)
+ return (EINVAL);
+
+ nrel = elf_object_count(efile, ELF_T_REL, shdr.sh_size);
+ rel = calloc(nrel, sizeof(*rel));
+ if (rel == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < nrel; i++) {
+ if (gelf_getrel(data, i, &rel[i]) == NULL) {
+ free(rel);
+ return (EINVAL);
+ }
+ }
+
+ *nrelp = nrel;
+ *relp = rel;
+ return (0);
+}
+
+int
+elf_read_rela(struct elf_file *efile, int section_index, long *nrelap,
+ GElf_Rela **relap)
+{
+ GElf_Shdr shdr;
+ Elf_Scn *scn;
+ Elf_Data *data;
+ GElf_Rela *rela;
+ long i, nrela;
+
+ scn = elf_getscn(efile->ef_elf, section_index);
+ if (scn == NULL)
+ return (EINVAL);
+ if (gelf_getshdr(scn, &shdr) == NULL)
+ return (EINVAL);
+ data = elf_getdata(scn, NULL);
+ if (data == NULL)
+ return (EINVAL);
+
+ nrela = elf_object_count(efile, ELF_T_RELA, shdr.sh_size);
+ rela = calloc(nrela, sizeof(*rela));
+ if (rela == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < nrela; i++) {
+ if (gelf_getrela(data, i, &rela[i]) == NULL) {
+ free(rela);
+ return (EINVAL);
+ }
+ }
+
+ *nrelap = nrela;
+ *relap = rela;
+ return (0);
+}
+
+size_t
+elf_pointer_size(struct elf_file *efile)
+{
+ return (efile->ef_pointer_size);
+}
+
+int
+elf_int(struct elf_file *efile, const void *p)
+{
+ if (elf_encoding(efile) == ELFDATA2LSB)
+ return (le32dec(p));
+ else
+ return (be32dec(p));
+}
+
+GElf_Addr
+elf_address_from_pointer(struct elf_file *efile, const void *p)
+{
+ switch (elf_class(efile)) {
+ case ELFCLASS32:
+ if (elf_encoding(efile) == ELFDATA2LSB)
+ return (le32dec(p));
+ else
+ return (be32dec(p));
+ case ELFCLASS64:
+ if (elf_encoding(efile) == ELFDATA2LSB)
+ return (le64dec(p));
+ else
+ return (be64dec(p));
+ default:
+ __unreachable();
+ }
+}
+
+int
+elf_read_string(struct elf_file *efile, GElf_Addr address, void *dst,
+ size_t len)
+{
+ return (EF_SEG_READ_STRING(efile, address, len, dst));
+}
+
+int
+elf_read_linker_set(struct elf_file *efile, const char *name, GElf_Addr **bufp,
+ long *countp)
+{
+ GElf_Addr *buf, start, stop;
+ char *p;
+ void *raw;
+ long i, count;
+ int error;
+
+ error = EF_LOOKUP_SET(efile, name, &start, &stop, &count);
+ if (error != 0)
+ return (error);
+
+ error = elf_read_relocated_data(efile, start,
+ count * elf_pointer_size(efile), &raw);
+ if (error != 0)
+ return (error);
+
+ buf = calloc(count, sizeof(*buf));
+ if (buf == NULL) {
+ free(raw);
+ return (ENOMEM);
+ }
+
+ p = raw;
+ for (i = 0; i < count; i++) {
+ buf[i] = elf_address_from_pointer(efile, p);
+ p += elf_pointer_size(efile);
+ }
+ free(raw);
+
+ *bufp = buf;
+ *countp = count;
+ return (0);
+}
+
+int
+elf_read_mod_depend(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_depend *mdp)
+{
+ int *p;
+ int error;
+
+ error = elf_read_relocated_data(efile, addr, sizeof(int) * 3,
+ (void **)&p);
+ if (error != 0)
+ return (error);
+
+ memset(mdp, 0, sizeof(*mdp));
+ mdp->md_ver_minimum = elf_int(efile, p);
+ mdp->md_ver_preferred = elf_int(efile, p + 1);
+ mdp->md_ver_maximum = elf_int(efile, p + 2);
+ free(p);
+ return (0);
+}
+
+int
+elf_read_mod_version(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_version *mdv)
+{
+ int error, value;
+
+ error = EF_SEG_READ_REL(efile, addr, sizeof(int), &value);
+ if (error != 0)
+ return (error);
+
+ memset(mdv, 0, sizeof(*mdv));
+ mdv->mv_version = elf_int(efile, &value);
+ return (0);
+}
+
+int
+elf_read_mod_metadata(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_metadata *md)
+{
+ char *p;
+ size_t len, offset, pointer_size;
+ int error;
+
+ pointer_size = elf_pointer_size(efile);
+ len = 2 * sizeof(int);
+ len = roundup(len, pointer_size);
+ len += 2 * pointer_size;
+
+ error = elf_read_relocated_data(efile, addr, len, (void **)&p);
+ if (error != 0)
+ return (error);
+
+ memset(md, 0, sizeof(*md));
+ offset = 0;
+ md->md_version = elf_int(efile, p + offset);
+ offset += sizeof(int);
+ md->md_type = elf_int(efile, p + offset);
+ offset += sizeof(int);
+ offset = roundup(offset, pointer_size);
+ md->md_data = elf_address_from_pointer(efile, p + offset);
+ offset += pointer_size;
+ md->md_cval = elf_address_from_pointer(efile, p + offset);
+ free(p);
+ return (0);
+}
+
+int
+elf_read_mod_pnp_match_info(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_pnp_match_info *pnp)
+{
+ char *p;
+ size_t len, offset, pointer_size;
+ int error;
+
+ pointer_size = elf_pointer_size(efile);
+ len = 3 * pointer_size;
+ len = roundup(len, pointer_size);
+ len += 2 * sizeof(int);
+
+ error = elf_read_relocated_data(efile, addr, len, (void **)&p);
+ if (error != 0)
+ return (error);
+
+ memset(pnp, 0, sizeof(*pnp));
+ offset = 0;
+ pnp->descr = elf_address_from_pointer(efile, p + offset);
+ offset += pointer_size;
+ pnp->bus = elf_address_from_pointer(efile, p + offset);
+ offset += pointer_size;
+ pnp->table = elf_address_from_pointer(efile, p + offset);
+ offset += pointer_size;
+ offset = roundup(offset, pointer_size);
+ pnp->entry_len = elf_int(efile, p + offset);
+ offset += sizeof(int);
+ pnp->num_entry = elf_int(efile, p + offset);
+ free(p);
+ return (0);
+}
+
+int
+elf_reloc(struct elf_file *efile, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
+{
+ return (efile->ef_reloc(efile, reldata, reltype, relbase, dataoff, len,
+ dest));
+}
diff --git a/usr.sbin/kldxref/fileformat b/usr.sbin/kldxref/fileformat
index 81d115c73bb6..701b56aa1554 100644
--- a/usr.sbin/kldxref/fileformat
+++ b/usr.sbin/kldxref/fileformat
@@ -1,4 +1,3 @@
-$FreeBSD$
linker.hints file consists from the one or more records,
and is processed by sys/kern/kern_linker.c::linker_hints_lookup()
diff --git a/usr.sbin/kldxref/kldxref.8 b/usr.sbin/kldxref/kldxref.8
index 1a3b9118dd5c..1704847592cd 100644
--- a/usr.sbin/kldxref/kldxref.8
+++ b/usr.sbin/kldxref/kldxref.8
@@ -1,6 +1,6 @@
.\"-
.\" Copyright (c) 2001 Boris Popov
-.\" Copyright (c) 2001 Dag-Erling Coïdan Smørgrav
+.\" Copyright (c) 2001 Dag-Erling Smørgrav
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,9 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd October 9, 2001
+.Dd February 25, 2023
.Dt KLDXREF 8
.Os
.Sh NAME
@@ -51,6 +49,14 @@ If no hint records are generated for a particular directory, no hint
file is created, and the preexisting hint file (if there was one in
that directory) is removed.
.Pp
+.Nm
+only processes files that either have no dots in their name like
+.Pa kernel
+or that end in
+.Dq .ko
+like
+.Pa foo.ko .
+.Pp
The following options are available:
.Bl -tag -width indent
.It Fl R
diff --git a/usr.sbin/kldxref/kldxref.c b/usr.sbin/kldxref/kldxref.c
index 7a4d704356b8..c88769ce1824 100644
--- a/usr.sbin/kldxref/kldxref.c
+++ b/usr.sbin/kldxref/kldxref.c
@@ -30,32 +30,26 @@
* 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/types.h>
#include <sys/param.h>
#include <sys/endian.h>
-#include <sys/exec.h>
#include <sys/queue.h>
-#include <sys/kernel.h>
-#include <sys/reboot.h>
-#include <sys/linker.h>
#include <sys/stat.h>
#include <sys/module.h>
-#define FREEBSD_ELF
+#include <assert.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fts.h>
+#include <gelf.h>
+#include <libelf.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <machine/elf.h>
#include "ef.h"
@@ -66,6 +60,9 @@ static bool dflag; /* do not create a hint file, only write on stdout */
static int verbose;
static FILE *fxref; /* current hints file */
+static int byte_order;
+static GElf_Ehdr ehdr;
+static char *ehdr_filename;
static const char *xref_file = "linker.hints";
@@ -84,6 +81,19 @@ intalign(void)
}
static void
+write_int(int val)
+{
+ char buf[4];
+
+ assert(byte_order != ELFDATANONE);
+ if (byte_order == ELFDATA2LSB)
+ le32enc(buf, val);
+ else
+ be32enc(buf, val);
+ fwrite(buf, sizeof(buf), 1, fxref);
+}
+
+static void
record_start(void)
{
@@ -95,11 +105,24 @@ static int
record_end(void)
{
- if (recpos == 0)
+ if (recpos == 0) {
+ /*
+ * Pretend to have written a record in debug mode so
+ * the architecture check works.
+ */
+ if (dflag)
+ reccnt++;
return (0);
+ }
+
+ if (reccnt == 0) {
+ /* File version record. */
+ write_int(1);
+ }
+
reccnt++;
intalign();
- fwrite(&recpos, sizeof(recpos), 1, fxref);
+ write_int(recpos);
return (fwrite(recbuf, recpos, 1, fxref) != 1 ? errno : 0);
}
@@ -115,14 +138,21 @@ record_buf(const void *buf, size_t size)
}
/*
- * An int is stored in host order and aligned
+ * An int is stored in target byte order and aligned
*/
static int
record_int(int val)
{
+ char buf[4];
+
+ assert(byte_order != ELFDATANONE);
+ if (byte_order == ELFDATA2LSB)
+ le32enc(buf, val);
+ else
+ be32enc(buf, val);
intalign();
- return (record_buf(&val, sizeof(val)));
+ return (record_buf(buf, sizeof(buf)));
}
/*
@@ -200,7 +230,7 @@ typedef TAILQ_HEAD(pnp_head, pnp_elt) pnp_list;
/*
* this function finds the data from the pnp table, as described by the
- * the description and creates a new output (new_desc). This output table
+ * description and creates a new output (new_desc). This output table
* is a form that's easier for the agent that's automatically loading the
* modules.
*
@@ -230,7 +260,8 @@ typedef TAILQ_HEAD(pnp_head, pnp_elt) pnp_list;
* sign extension to uint32_t to simplify parsing downstream.
*/
static int
-parse_pnp_list(const char *desc, char **new_desc, pnp_list *list)
+parse_pnp_list(struct elf_file *ef, const char *desc, char **new_desc,
+ pnp_list *list)
{
const char *walker, *ep;
const char *colon, *semi;
@@ -240,6 +271,7 @@ parse_pnp_list(const char *desc, char **new_desc, pnp_list *list)
size_t new_desc_size;
FILE *fp;
+ TAILQ_INIT(list);
walker = desc;
ep = desc + strlen(desc);
off = 0;
@@ -276,7 +308,7 @@ parse_pnp_list(const char *desc, char **new_desc, pnp_list *list)
printf("Found type %s for name %s\n", type, key);
/* Skip pointer place holders */
if (strcmp(type, "P") == 0) {
- off += sizeof(void *);
+ off += elf_pointer_size(ef);
continue;
}
@@ -335,8 +367,8 @@ parse_pnp_list(const char *desc, char **new_desc, pnp_list *list)
/* doesn't actually consume space in the table */
off = elt->pe_offset;
} else {
- elt->pe_offset = roundup2(elt->pe_offset, sizeof(void *));
- off = elt->pe_offset + sizeof(void *);
+ elt->pe_offset = roundup2(elt->pe_offset, elf_pointer_size(ef));
+ off = elt->pe_offset + elf_pointer_size(ef);
}
if (elt->pe_kind & TYPE_PAIRED) {
char *word, *ctx, newtype;
@@ -382,33 +414,183 @@ err:
errx(1, "Parse error of description string %s", desc);
}
+static void
+free_pnp_list(char *new_desc, pnp_list *list)
+{
+ struct pnp_elt *elt, *elt_tmp;
+
+ TAILQ_FOREACH_SAFE(elt, list, next, elt_tmp) {
+ TAILQ_REMOVE(list, elt, next);
+ free(elt);
+ }
+ free(new_desc);
+}
+
+static uint16_t
+parse_16(const void *p)
+{
+ if (byte_order == ELFDATA2LSB)
+ return (le16dec(p));
+ else
+ return (be16dec(p));
+}
+
+static uint32_t
+parse_32(const void *p)
+{
+ if (byte_order == ELFDATA2LSB)
+ return (le32dec(p));
+ else
+ return (be32dec(p));
+}
+
+static void
+parse_pnp_entry(struct elf_file *ef, struct pnp_elt *elt, const char *walker)
+{
+ uint8_t v1;
+ uint16_t v2;
+ uint32_t v4;
+ int value;
+ char buffer[1024];
+
+ if (elt->pe_kind == TYPE_W32) {
+ v4 = parse_32(walker + elt->pe_offset);
+ value = v4 & 0xffff;
+ record_int(value);
+ if (verbose > 1)
+ printf("W32:%#x", value);
+ value = (v4 >> 16) & 0xffff;
+ record_int(value);
+ if (verbose > 1)
+ printf(":%#x;", value);
+ } else if (elt->pe_kind & TYPE_INT) {
+ switch (elt->pe_kind & TYPE_SZ_MASK) {
+ case 1:
+ memcpy(&v1, walker + elt->pe_offset, sizeof(v1));
+ if ((elt->pe_kind & TYPE_FLAGGED) && v1 == 0xff)
+ value = -1;
+ else
+ value = v1;
+ break;
+ case 2:
+ v2 = parse_16(walker + elt->pe_offset);
+ if ((elt->pe_kind & TYPE_FLAGGED) && v2 == 0xffff)
+ value = -1;
+ else
+ value = v2;
+ break;
+ case 4:
+ v4 = parse_32(walker + elt->pe_offset);
+ if ((elt->pe_kind & TYPE_FLAGGED) && v4 == 0xffffffff)
+ value = -1;
+ else
+ value = v4;
+ break;
+ default:
+ errx(1, "Invalid size somehow %#x", elt->pe_kind);
+ }
+ if (verbose > 1)
+ printf("I:%#x;", value);
+ record_int(value);
+ } else if (elt->pe_kind == TYPE_T) {
+ /* Do nothing */
+ } else { /* E, Z or D -- P already filtered */
+ if (elt->pe_kind == TYPE_E) {
+ v4 = parse_32(walker + elt->pe_offset);
+ strcpy(buffer, pnp_eisaformat(v4));
+ } else {
+ GElf_Addr address;
+
+ address = elf_address_from_pointer(ef, walker +
+ elt->pe_offset);
+ buffer[0] = '\0';
+ if (address != 0) {
+ elf_read_string(ef, address, buffer,
+ sizeof(buffer));
+ buffer[sizeof(buffer) - 1] = '\0';
+ }
+ }
+ if (verbose > 1)
+ printf("%c:%s;", elt->pe_kind == TYPE_E ? 'E' :
+ (elt->pe_kind == TYPE_Z ? 'Z' : 'D'), buffer);
+ record_string(buffer);
+ }
+}
+
+static void
+record_pnp_info(struct elf_file *ef, const char *cval,
+ struct Gmod_pnp_match_info *pnp, const char *descr)
+{
+ pnp_list list;
+ struct pnp_elt *elt;
+ char *new_descr, *walker;
+ void *table;
+ size_t len;
+ int error, i;
+
+ if (verbose > 1)
+ printf(" pnp info for bus %s format %s %d entries of %d bytes\n",
+ cval, descr, pnp->num_entry, pnp->entry_len);
+
+ /*
+ * Parse descr to weed out the chaff and to create a list
+ * of offsets to output.
+ */
+ parse_pnp_list(ef, descr, &new_descr, &list);
+ record_int(MDT_PNP_INFO);
+ record_string(cval);
+ record_string(new_descr);
+ record_int(pnp->num_entry);
+ len = pnp->num_entry * pnp->entry_len;
+ error = elf_read_relocated_data(ef, pnp->table, len, &table);
+ if (error != 0) {
+ free_pnp_list(new_descr, &list);
+ return;
+ }
+
+ /*
+ * Walk the list and output things. We've collapsed all the
+ * variant forms of the table down to just ints and strings.
+ */
+ walker = table;
+ for (i = 0; i < pnp->num_entry; i++) {
+ TAILQ_FOREACH(elt, &list, next) {
+ parse_pnp_entry(ef, elt, walker);
+ }
+ if (verbose > 1)
+ printf("\n");
+ walker += pnp->entry_len;
+ }
+
+ /* Now free it */
+ free_pnp_list(new_descr, &list);
+ free(table);
+}
+
static int
-parse_entry(struct mod_metadata *md, const char *cval,
+parse_entry(struct Gmod_metadata *md, const char *cval,
struct elf_file *ef, const char *kldname)
{
- struct mod_depend mdp;
- struct mod_version mdv;
- struct mod_pnp_match_info pnp;
+ struct Gmod_depend mdp;
+ struct Gmod_version mdv;
+ struct Gmod_pnp_match_info pnp;
char descr[1024];
- Elf_Off data;
- int error, i;
- size_t len;
- char *walker;
- void *table;
+ GElf_Addr data;
+ int error;
- data = (Elf_Off)md->md_data;
+ data = md->md_data;
error = 0;
record_start();
switch (md->md_type) {
case MDT_DEPEND:
if (!dflag)
break;
- check(EF_SEG_READ(ef, data, sizeof(mdp), &mdp));
+ check(elf_read_mod_depend(ef, data, &mdp));
printf(" depends on %s.%d (%d,%d)\n", cval,
mdp.md_ver_preferred, mdp.md_ver_minimum, mdp.md_ver_maximum);
break;
case MDT_VERSION:
- check(EF_SEG_READ(ef, data, sizeof(mdv), &mdv));
+ check(elf_read_mod_version(ef, data, &mdv));
if (dflag) {
printf(" interface %s.%d\n", cval, mdv.mv_version);
} else {
@@ -428,117 +610,13 @@ parse_entry(struct mod_metadata *md, const char *cval,
}
break;
case MDT_PNP_INFO:
- check(EF_SEG_READ_REL(ef, data, sizeof(pnp), &pnp));
- check(EF_SEG_READ_STRING(ef, (Elf_Off)pnp.descr, sizeof(descr), descr));
- descr[sizeof(descr) - 1] = '\0';
+ check(elf_read_mod_pnp_match_info(ef, data, &pnp));
+ check(elf_read_string(ef, pnp.descr, descr, sizeof(descr)));
if (dflag) {
printf(" pnp info for bus %s format %s %d entries of %d bytes\n",
cval, descr, pnp.num_entry, pnp.entry_len);
} else {
- pnp_list list;
- struct pnp_elt *elt, *elt_tmp;
- char *new_descr;
-
- if (verbose > 1)
- printf(" pnp info for bus %s format %s %d entries of %d bytes\n",
- cval, descr, pnp.num_entry, pnp.entry_len);
- /*
- * Parse descr to weed out the chaff and to create a list
- * of offsets to output.
- */
- TAILQ_INIT(&list);
- parse_pnp_list(descr, &new_descr, &list);
- record_int(MDT_PNP_INFO);
- record_string(cval);
- record_string(new_descr);
- record_int(pnp.num_entry);
- len = pnp.num_entry * pnp.entry_len;
- walker = table = malloc(len);
- check(EF_SEG_READ_REL(ef, (Elf_Off)pnp.table, len, table));
-
- /*
- * Walk the list and output things. We've collapsed all the
- * variant forms of the table down to just ints and strings.
- */
- for (i = 0; i < pnp.num_entry; i++) {
- TAILQ_FOREACH(elt, &list, next) {
- uint8_t v1;
- uint16_t v2;
- uint32_t v4;
- int value;
- char buffer[1024];
-
- if (elt->pe_kind == TYPE_W32) {
- memcpy(&v4, walker + elt->pe_offset, sizeof(v4));
- value = v4 & 0xffff;
- record_int(value);
- if (verbose > 1)
- printf("W32:%#x", value);
- value = (v4 >> 16) & 0xffff;
- record_int(value);
- if (verbose > 1)
- printf(":%#x;", value);
- } else if (elt->pe_kind & TYPE_INT) {
- switch (elt->pe_kind & TYPE_SZ_MASK) {
- case 1:
- memcpy(&v1, walker + elt->pe_offset, sizeof(v1));
- if ((elt->pe_kind & TYPE_FLAGGED) && v1 == 0xff)
- value = -1;
- else
- value = v1;
- break;
- case 2:
- memcpy(&v2, walker + elt->pe_offset, sizeof(v2));
- if ((elt->pe_kind & TYPE_FLAGGED) && v2 == 0xffff)
- value = -1;
- else
- value = v2;
- break;
- case 4:
- memcpy(&v4, walker + elt->pe_offset, sizeof(v4));
- if ((elt->pe_kind & TYPE_FLAGGED) && v4 == 0xffffffff)
- value = -1;
- else
- value = v4;
- break;
- default:
- errx(1, "Invalid size somehow %#x", elt->pe_kind);
- }
- if (verbose > 1)
- printf("I:%#x;", value);
- record_int(value);
- } else if (elt->pe_kind == TYPE_T) {
- /* Do nothing */
- } else { /* E, Z or D -- P already filtered */
- if (elt->pe_kind == TYPE_E) {
- memcpy(&v4, walker + elt->pe_offset, sizeof(v4));
- strcpy(buffer, pnp_eisaformat(v4));
- } else {
- char *ptr;
-
- ptr = *(char **)(walker + elt->pe_offset);
- buffer[0] = '\0';
- if (ptr != NULL) {
- EF_SEG_READ_STRING(ef, (Elf_Off)ptr,
- sizeof(buffer), buffer);
- buffer[sizeof(buffer) - 1] = '\0';
- }
- }
- if (verbose > 1)
- printf("%c:%s;", elt->pe_kind == TYPE_E ? 'E' : (elt->pe_kind == TYPE_Z ? 'Z' : 'D'), buffer);
- record_string(buffer);
- }
- }
- if (verbose > 1)
- printf("\n");
- walker += pnp.entry_len;
- }
- /* Now free it */
- TAILQ_FOREACH_SAFE(elt, &list, next, elt_tmp) {
- TAILQ_REMOVE(&list, elt, next);
- free(elt);
- }
- free(table);
+ record_pnp_info(ef, cval, &pnp, descr);
}
break;
default:
@@ -552,34 +630,35 @@ parse_entry(struct mod_metadata *md, const char *cval,
static int
read_kld(char *filename, char *kldname)
{
- struct mod_metadata md;
+ struct Gmod_metadata md;
struct elf_file ef;
- void **p;
- int error, eftype;
- long start, finish, entries, i;
+ GElf_Addr *p;
+ int error;
+ long entries, i;
char cval[MAXMODNAME + 1];
if (verbose || dflag)
printf("%s\n", filename);
- error = ef_open(filename, &ef, verbose);
- if (error != 0) {
- error = ef_obj_open(filename, &ef, verbose);
- if (error != 0) {
- if (verbose)
- warnc(error, "elf_open(%s)", filename);
- return (error);
- }
- }
- eftype = EF_GET_TYPE(&ef);
- if (eftype != EFT_KLD && eftype != EFT_KERNEL) {
- EF_CLOSE(&ef);
- return (0);
+
+ error = elf_open_file(&ef, filename, verbose);
+ if (error != 0)
+ return (error);
+
+ if (reccnt == 0) {
+ ehdr = ef.ef_hdr;
+ byte_order = elf_encoding(&ef);
+ free(ehdr_filename);
+ ehdr_filename = strdup(filename);
+ } else if (!elf_compatible(&ef, &ehdr)) {
+ warnx("%s does not match architecture of %s",
+ filename, ehdr_filename);
+ elf_close_file(&ef);
+ return (EINVAL);
}
+
do {
- check(EF_LOOKUP_SET(&ef, MDT_SETNAME, &start, &finish,
- &entries));
- check(EF_SEG_READ_ENTRY_REL(&ef, start, sizeof(*p) * entries,
- (void *)&p));
+ check(elf_read_linker_set(&ef, MDT_SETNAME, &p, &entries));
+
/*
* Do a first pass to find MDT_MODULE. It is required to be
* ordered first in the output linker.hints stream because it
@@ -599,16 +678,16 @@ read_kld(char *filename, char *kldname)
* in the same kld.
*/
for (i = 0; i < entries; i++) {
- check(EF_SEG_READ_REL(&ef, (Elf_Off)p[i], sizeof(md),
- &md));
- check(EF_SEG_READ_STRING(&ef, (Elf_Off)md.md_cval,
- sizeof(cval), cval));
+ check(elf_read_mod_metadata(&ef, p[i], &md));
+ check(elf_read_string(&ef, md.md_cval, cval,
+ sizeof(cval)));
if (md.md_type == MDT_MODULE) {
parse_entry(&md, cval, &ef, kldname);
break;
}
}
if (error != 0) {
+ free(p);
warnc(error, "error while reading %s", filename);
break;
}
@@ -617,10 +696,9 @@ read_kld(char *filename, char *kldname)
* Second pass for all !MDT_MODULE entries.
*/
for (i = 0; i < entries; i++) {
- check(EF_SEG_READ_REL(&ef, (Elf_Off)p[i], sizeof(md),
- &md));
- check(EF_SEG_READ_STRING(&ef, (Elf_Off)md.md_cval,
- sizeof(cval), cval));
+ check(elf_read_mod_metadata(&ef, p[i], &md));
+ check(elf_read_string(&ef, md.md_cval, cval,
+ sizeof(cval)));
if (md.md_type != MDT_MODULE)
parse_entry(&md, cval, &ef, kldname);
}
@@ -628,7 +706,7 @@ read_kld(char *filename, char *kldname)
warnc(error, "error while reading %s", filename);
free(p);
} while(0);
- EF_CLOSE(&ef);
+ elf_close_file(&ef);
return (error);
}
@@ -639,12 +717,9 @@ read_kld(char *filename, char *kldname)
static FILE *
maketempfile(char *dest, const char *root)
{
- char *p;
- int n, fd;
+ int fd;
- p = strrchr(root, '/');
- n = p != NULL ? p - root + 1 : 0;
- if (snprintf(dest, MAXPATHLEN, "%.*slhint.XXXXXX", n, root) >=
+ if (snprintf(dest, MAXPATHLEN, "%s/lhint.XXXXXX", root) >=
MAXPATHLEN) {
errno = ENAMETOOLONG;
return (NULL);
@@ -670,7 +745,11 @@ usage(void)
}
static int
+#if defined(__GLIBC__) || defined(__APPLE__)
+compare(const FTSENT **a, const FTSENT **b)
+#else
compare(const FTSENT *const *a, const FTSENT *const *b)
+#endif
{
if ((*a)->fts_info == FTS_D && (*b)->fts_info != FTS_D)
@@ -685,7 +764,8 @@ main(int argc, char *argv[])
{
FTS *ftsp;
FTSENT *p;
- int opt, fts_options, ival;
+ char *dot = NULL;
+ int opt, fts_options;
struct stat sb;
fts_options = FTS_PHYSICAL;
@@ -721,6 +801,9 @@ main(int argc, char *argv[])
err(1, "%s", argv[0]);
}
+ if (elf_version(EV_CURRENT) == EV_NONE)
+ errx(1, "unsupported libelf");
+
ftsp = fts_open(argv, fts_options, compare);
if (ftsp == NULL)
exit(1);
@@ -748,18 +831,19 @@ main(int argc, char *argv[])
fxref = maketempfile(tempname, ftsp->fts_path);
if (fxref == NULL)
err(1, "can't create %s", tempname);
- ival = 1;
- fwrite(&ival, sizeof(ival), 1, fxref);
+ byte_order = ELFDATANONE;
reccnt = 0;
}
- /* skip non-files and separate debug files */
+ /* skip non-files.. */
if (p->fts_info != FTS_F)
continue;
- if (p->fts_namelen >= 6 &&
- strcmp(p->fts_name + p->fts_namelen - 6, ".debug") == 0)
- continue;
- if (p->fts_namelen >= 8 &&
- strcmp(p->fts_name + p->fts_namelen - 8, ".symbols") == 0)
+ /*
+ * Skip files that generate errors like .debug, .symbol and .pkgsave
+ * by generally skipping all files not ending with ".ko" or that have
+ * no dots in the name (like kernel).
+ */
+ dot = strrchr(p->fts_name, '.');
+ if (dot != NULL && strcmp(dot, ".ko") != 0)
continue;
read_kld(p->fts_path, p->fts_name);
}
diff --git a/usr.sbin/lastlogin/Makefile b/usr.sbin/lastlogin/Makefile
index 7fe146ffd492..b595837075ee 100644
--- a/usr.sbin/lastlogin/Makefile
+++ b/usr.sbin/lastlogin/Makefile
@@ -1,6 +1,6 @@
-# $FreeBSD$
PROG= lastlogin
+PACKAGE= acct
MAN= lastlogin.8
LIBADD= xo
diff --git a/usr.sbin/lastlogin/Makefile.depend b/usr.sbin/lastlogin/Makefile.depend
index 6cfaab1c3644..b95024e29443 100644
--- a/usr.sbin/lastlogin/Makefile.depend
+++ b/usr.sbin/lastlogin/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/libxo/libxo \
.include <dirdeps.mk>
diff --git a/usr.sbin/lastlogin/lastlogin.8 b/usr.sbin/lastlogin/lastlogin.8
index 2ee0ff035d7d..0e18724a8707 100644
--- a/usr.sbin/lastlogin/lastlogin.8
+++ b/usr.sbin/lastlogin/lastlogin.8
@@ -1,4 +1,3 @@
-.\" $FreeBSD$
.\" $NetBSD: lastlogin.8,v 1.3 1998/02/06 06:20:39 perry Exp $
.\"
.\" Copyright (c) 1996 John M. Vinopal
diff --git a/usr.sbin/lastlogin/lastlogin.c b/usr.sbin/lastlogin/lastlogin.c
index 35aee1dcb2c5..a1dcde3f60bf 100644
--- a/usr.sbin/lastlogin/lastlogin.c
+++ b/usr.sbin/lastlogin/lastlogin.c
@@ -35,7 +35,6 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$FreeBSD$");
__RCSID("$NetBSD: lastlogin.c,v 1.4 1998/02/03 04:45:35 perry Exp $");
#endif
diff --git a/usr.sbin/lpr/Makefile b/usr.sbin/lpr/Makefile
index 5873c0758a9a..a36ad649501d 100644
--- a/usr.sbin/lpr/Makefile
+++ b/usr.sbin/lpr/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= common_source .WAIT \
chkprintcap lp lpc lpd lpq lpr lprm lptest pac \
diff --git a/usr.sbin/lpr/Makefile.inc b/usr.sbin/lpr/Makefile.inc
index 59f8ceb1ed55..20800c3bb080 100644
--- a/usr.sbin/lpr/Makefile.inc
+++ b/usr.sbin/lpr/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/lpr/chkprintcap/Makefile b/usr.sbin/lpr/chkprintcap/Makefile
index c8378dc97a41..4895305ba9bb 100644
--- a/usr.sbin/lpr/chkprintcap/Makefile
+++ b/usr.sbin/lpr/chkprintcap/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${.CURDIR:H}/common_source
diff --git a/usr.sbin/lpr/chkprintcap/Makefile.depend b/usr.sbin/lpr/chkprintcap/Makefile.depend
index 5ca32400912b..52597b984452 100644
--- a/usr.sbin/lpr/chkprintcap/Makefile.depend
+++ b/usr.sbin/lpr/chkprintcap/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/lpr/chkprintcap/chkprintcap.8 b/usr.sbin/lpr/chkprintcap/chkprintcap.8
index b41546242b15..7aecf9fbb1b7 100644
--- a/usr.sbin/lpr/chkprintcap/chkprintcap.8
+++ b/usr.sbin/lpr/chkprintcap/chkprintcap.8
@@ -24,8 +24,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$
.Dd November 30, 1997
.Dt CHKPRINTCAP 8
.Os
diff --git a/usr.sbin/lpr/chkprintcap/chkprintcap.c b/usr.sbin/lpr/chkprintcap/chkprintcap.c
index fab2239adbd2..5e9179b03f21 100644
--- a/usr.sbin/lpr/chkprintcap/chkprintcap.c
+++ b/usr.sbin/lpr/chkprintcap/chkprintcap.c
@@ -31,8 +31,6 @@ static const char copyright[] =
"Copyright (C) 1997, Massachusetts Institute of Technology\r\n";
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
diff --git a/usr.sbin/lpr/chkprintcap/skimprintcap.c b/usr.sbin/lpr/chkprintcap/skimprintcap.c
index 25a5eb5941bf..f6e74bc6df03 100644
--- a/usr.sbin/lpr/chkprintcap/skimprintcap.c
+++ b/usr.sbin/lpr/chkprintcap/skimprintcap.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* ------+---------+---------+---------+---------+---------+---------+---------*
* Copyright (c) 2001 - Garance Alistair Drosehn <gad@FreeBSD.org>.
@@ -34,8 +34,6 @@
*/
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <ctype.h>
diff --git a/usr.sbin/lpr/chkprintcap/skimprintcap.h b/usr.sbin/lpr/chkprintcap/skimprintcap.h
index 29b5627458a9..d7250ff6fff5 100644
--- a/usr.sbin/lpr/chkprintcap/skimprintcap.h
+++ b/usr.sbin/lpr/chkprintcap/skimprintcap.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* ------+---------+---------+---------+---------+---------+---------+---------*
* Copyright (c) 2001 - Garance Alistair Drosehn <gad@FreeBSD.org>.
@@ -31,7 +31,6 @@
* official policies, either expressed or implied, of the FreeBSD Project.
*
* ------+---------+---------+---------+---------+---------+---------+---------*
- * $FreeBSD$
* ------+---------+---------+---------+---------+---------+---------+---------*
*/
diff --git a/usr.sbin/lpr/common_source/Makefile b/usr.sbin/lpr/common_source/Makefile
index 4f148f9d4c46..1d3a10a60ae3 100644
--- a/usr.sbin/lpr/common_source/Makefile
+++ b/usr.sbin/lpr/common_source/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Library of internal routines for the print spooler suite.
diff --git a/usr.sbin/lpr/common_source/Makefile.depend b/usr.sbin/lpr/common_source/Makefile.depend
index 56ba32964b9d..f2b0559818dd 100644
--- a/usr.sbin/lpr/common_source/Makefile.depend
+++ b/usr.sbin/lpr/common_source/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c
index b20855515adb..9b73667d3058 100644
--- a/usr.sbin/lpr/common_source/common.c
+++ b/usr.sbin/lpr/common_source/common.c
@@ -38,15 +38,7 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)common.c 8.5 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -554,8 +546,6 @@ trstat_init(struct printer *pp, const char *fname, int filenum)
* save those away along with the file-number */
pp->jobdfnum = filenum;
lpd_gettime(&pp->tr_start, pp->tr_timestr, (size_t)TIMESTR_SIZE);
-
- return;
}
void
diff --git a/usr.sbin/lpr/common_source/ctlinfo.c b/usr.sbin/lpr/common_source/ctlinfo.c
index 15fed7bc32ef..5f5351b613c2 100644
--- a/usr.sbin/lpr/common_source/ctlinfo.c
+++ b/usr.sbin/lpr/common_source/ctlinfo.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* ------+---------+---------+---------+---------+---------+---------+---------*
* Copyright (c) 2001,2011 - Garance Alistair Drosehn <gad@FreeBSD.org>.
@@ -34,8 +34,6 @@
*/
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* ctlinfo - This collection of routines will know everything there is to
* know about the information inside a control file ('cf*') which is used
diff --git a/usr.sbin/lpr/common_source/ctlinfo.h b/usr.sbin/lpr/common_source/ctlinfo.h
index 5966485cb365..82d0c92df458 100644
--- a/usr.sbin/lpr/common_source/ctlinfo.h
+++ b/usr.sbin/lpr/common_source/ctlinfo.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* ------+---------+---------+---------+---------+---------+---------+---------*
* Copyright (c) 2001,2011 - Garance Alistair Drosehn <gad@FreeBSD.org>.
@@ -31,7 +31,6 @@
* official policies, either expressed or implied, of the FreeBSD Project.
*
* ------+---------+---------+---------+---------+---------+---------+---------*
- * $FreeBSD$
* ------+---------+---------+---------+---------+---------+---------+---------*
*/
@@ -56,7 +55,7 @@ struct cjobinfo {
* did the original 'lpr') */
char *cji_class; /* class-name */
char *cji_curqueue; /* printer-queue that this cf-file is
- * curently sitting in (mainly used
+ * currently sitting in (mainly used
* in syslog error messages) */
char *cji_fname; /* filename of the control file */
char *cji_jobname; /* job-name (for banner) */
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index f21852cdc5b4..e9ef544f0399 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -29,15 +29,7 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)displayq.c 8.4 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
diff --git a/usr.sbin/lpr/common_source/lp.cdefs.h b/usr.sbin/lpr/common_source/lp.cdefs.h
index cadef37f0c3e..f5adf6e0ba5d 100644
--- a/usr.sbin/lpr/common_source/lp.cdefs.h
+++ b/usr.sbin/lpr/common_source/lp.cdefs.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* ------+---------+---------+---------+---------+---------+---------+---------*
* Copyright (c) 2003,2013 - Garance Alistair Drosehn <gad@FreeBSD.org>.
@@ -31,7 +31,6 @@
* official policies, either expressed or implied, of the FreeBSD Project.
*
* ------+---------+---------+---------+---------+---------+---------+---------*
- * $FreeBSD$
* ------+---------+---------+---------+---------+---------+---------+---------*
*/
@@ -83,20 +82,6 @@
#endif
/*
- * All the lpr source files will want to reference __FBSDID() to
- * handle rcs id's.
- */
-#if !defined(__FBSDID)
-# if defined(lint) || defined(STRIP_FBSDID)
-# define __FBSDID(s) struct skip_rcsid_struct
-# elif defined(__IDSTRING) /* NetBSD */
-# define __FBSDID(s) __IDSTRING(rcsid,s)
-# else
-# define __FBSDID(s) static const char rcsid[] __unused = s
-# endif
-#endif /* __FBSDID */
-
-/*
* Some lpr include files use __BEGIN_DECLS and __END_DECLS.
*/
#if !defined(__BEGIN_DECLS)
diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h
index bf9262db02a0..b8c02e26b710 100644
--- a/usr.sbin/lpr/common_source/lp.h
+++ b/usr.sbin/lpr/common_source/lp.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.
- *
- * From: @(#)lp.h 8.2 (Berkeley) 4/28/95
- * $FreeBSD$
*/
#include <sys/queue.h>
diff --git a/usr.sbin/lpr/common_source/lp.local.h b/usr.sbin/lpr/common_source/lp.local.h
index c0e3f308f75d..c4ccef0c2597 100644
--- a/usr.sbin/lpr/common_source/lp.local.h
+++ b/usr.sbin/lpr/common_source/lp.local.h
@@ -25,9 +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.
- *
- * @(#)lp.local.h 8.1 (Berkeley) 6/6/93
- * $FreeBSD$
*/
/*
@@ -67,7 +64,7 @@
#define DROP 3 /* offset to drop characters with descenders */
/*
- * Define TERMCAP if the terminal capabilites are to be used for lpq.
+ * Define TERMCAP if the terminal capabilities are to be used for lpq.
*/
#define TERMCAP
diff --git a/usr.sbin/lpr/common_source/matchjobs.c b/usr.sbin/lpr/common_source/matchjobs.c
index 6d7379e24fa8..47309cf25702 100644
--- a/usr.sbin/lpr/common_source/matchjobs.c
+++ b/usr.sbin/lpr/common_source/matchjobs.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* ------+---------+---------+---------+---------+---------+---------+---------*
* Copyright (c) 2002,2011 - Garance Alistair Drosehn <gad@FreeBSD.org>.
@@ -35,8 +35,6 @@
*/
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* movejobs.c - The lpc commands which move jobs around.
*/
diff --git a/usr.sbin/lpr/common_source/matchjobs.h b/usr.sbin/lpr/common_source/matchjobs.h
index 98de13bdb7bf..a3c28623e216 100644
--- a/usr.sbin/lpr/common_source/matchjobs.h
+++ b/usr.sbin/lpr/common_source/matchjobs.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* ------+---------+---------+---------+---------+---------+---------+---------*
* Copyright (c) 2002 - Garance Alistair Drosehn <gad@FreeBSD.org>.
@@ -32,7 +32,6 @@
* or FreeBSD, Inc.
*
* ------+---------+---------+---------+---------+---------+---------+---------*
- * $FreeBSD$
* ------+---------+---------+---------+---------+---------+---------+---------*
*/
diff --git a/usr.sbin/lpr/common_source/net.c b/usr.sbin/lpr/common_source/net.c
index 3954b2286dc6..86af21601f7f 100644
--- a/usr.sbin/lpr/common_source/net.c
+++ b/usr.sbin/lpr/common_source/net.c
@@ -36,13 +36,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.
- *
- * From: @(#)common.c 8.5 (Berkeley) 4/28/95
*/
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
diff --git a/usr.sbin/lpr/common_source/pathnames.h b/usr.sbin/lpr/common_source/pathnames.h
index f987b393848d..2704c2245b53 100644
--- a/usr.sbin/lpr/common_source/pathnames.h
+++ b/usr.sbin/lpr/common_source/pathnames.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.
- *
- * $FreeBSD$
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/6/93
*/
#include <paths.h>
diff --git a/usr.sbin/lpr/common_source/printcap.c b/usr.sbin/lpr/common_source/printcap.c
index 96b3e9dfdbac..35fcab4c16eb 100644
--- a/usr.sbin/lpr/common_source/printcap.c
+++ b/usr.sbin/lpr/common_source/printcap.c
@@ -38,15 +38,7 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)printcap.c 8.2 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.sbin/lpr/common_source/request.c b/usr.sbin/lpr/common_source/request.c
index 0c68fe92674a..e0a41a1161e0 100644
--- a/usr.sbin/lpr/common_source/request.c
+++ b/usr.sbin/lpr/common_source/request.c
@@ -31,8 +31,6 @@ static const char copyright[] =
"Copyright (C) 1997, Massachusetts Institute of Technology\r\n";
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c
index f3502000ee08..b3af8bf5ad3f 100644
--- a/usr.sbin/lpr/common_source/rmjob.c
+++ b/usr.sbin/lpr/common_source/rmjob.c
@@ -29,15 +29,7 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)rmjob.c 8.2 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/uio.h>
diff --git a/usr.sbin/lpr/common_source/startdaemon.c b/usr.sbin/lpr/common_source/startdaemon.c
index 112846ebc0c9..d37dd0817043 100644
--- a/usr.sbin/lpr/common_source/startdaemon.c
+++ b/usr.sbin/lpr/common_source/startdaemon.c
@@ -29,15 +29,7 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)startdaemon.c 8.2 (Berkeley) 4/17/94";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/uio.h>
diff --git a/usr.sbin/lpr/filters.ru/Makefile b/usr.sbin/lpr/filters.ru/Makefile
index ee15541fae74..c3f7e6162369 100644
--- a/usr.sbin/lpr/filters.ru/Makefile
+++ b/usr.sbin/lpr/filters.ru/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= koi2alt koi2855
diff --git a/usr.sbin/lpr/filters.ru/Makefile.depend b/usr.sbin/lpr/filters.ru/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/lpr/filters.ru/Makefile.depend
+++ b/usr.sbin/lpr/filters.ru/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/lpr/filters.ru/Makefile.inc b/usr.sbin/lpr/filters.ru/Makefile.inc
index 36a6f4641306..ee7dbae5aef7 100644
--- a/usr.sbin/lpr/filters.ru/Makefile.inc
+++ b/usr.sbin/lpr/filters.ru/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
BINDIR= /usr/libexec/lpr/ru
diff --git a/usr.sbin/lpr/filters.ru/koi2855/Makefile b/usr.sbin/lpr/filters.ru/koi2855/Makefile
index 564867d2be7c..ec6d8cb2c198 100644
--- a/usr.sbin/lpr/filters.ru/koi2855/Makefile
+++ b/usr.sbin/lpr/filters.ru/koi2855/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= koi2855
MAN=
diff --git a/usr.sbin/lpr/filters.ru/koi2855/Makefile.depend b/usr.sbin/lpr/filters.ru/koi2855/Makefile.depend
index cae7e645ef6a..93249906da4f 100644
--- a/usr.sbin/lpr/filters.ru/koi2855/Makefile.depend
+++ b/usr.sbin/lpr/filters.ru/koi2855/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
lib/${CSU_DIR} \
lib/libc \
diff --git a/usr.sbin/lpr/filters.ru/koi2855/koi2855.c b/usr.sbin/lpr/filters.ru/koi2855/koi2855.c
index 2baee03ccb64..595ea375a266 100644
--- a/usr.sbin/lpr/filters.ru/koi2855/koi2855.c
+++ b/usr.sbin/lpr/filters.ru/koi2855/koi2855.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1999 by Andrey A. Chernov, Moscow, Russia.
* (C) 18 Sep 1999, Alex G. Bulushev (bag@demos.su)
@@ -28,8 +28,6 @@
*/
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* KOI8-R -> CP855 conversion filter (Russian character sets)
*/
diff --git a/usr.sbin/lpr/filters.ru/koi2alt/Makefile b/usr.sbin/lpr/filters.ru/koi2alt/Makefile
index 4e2f7853ddab..84a1e1eb4b00 100644
--- a/usr.sbin/lpr/filters.ru/koi2alt/Makefile
+++ b/usr.sbin/lpr/filters.ru/koi2alt/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= koi2alt
MAN=
diff --git a/usr.sbin/lpr/filters.ru/koi2alt/Makefile.depend b/usr.sbin/lpr/filters.ru/koi2alt/Makefile.depend
index cae7e645ef6a..93249906da4f 100644
--- a/usr.sbin/lpr/filters.ru/koi2alt/Makefile.depend
+++ b/usr.sbin/lpr/filters.ru/koi2alt/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
lib/${CSU_DIR} \
lib/libc \
diff --git a/usr.sbin/lpr/filters.ru/koi2alt/koi2alt.c b/usr.sbin/lpr/filters.ru/koi2alt/koi2alt.c
index 9bbeb81ac5e1..25cf23e3a513 100644
--- a/usr.sbin/lpr/filters.ru/koi2alt/koi2alt.c
+++ b/usr.sbin/lpr/filters.ru/koi2alt/koi2alt.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1993-98 by Andrey A. Chernov, Moscow, Russia.
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* KOI8-R -> CP866 conversion filter (Russian character sets)
*/
diff --git a/usr.sbin/lpr/filters/Makefile b/usr.sbin/lpr/filters/Makefile
index a984e78980d0..024fb738f0fb 100644
--- a/usr.sbin/lpr/filters/Makefile
+++ b/usr.sbin/lpr/filters/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
BINDIR= ${LIBEXECDIR}/lpr
diff --git a/usr.sbin/lpr/filters/Makefile.depend b/usr.sbin/lpr/filters/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/lpr/filters/Makefile.depend
+++ b/usr.sbin/lpr/filters/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/lpr/filters/lpf.c b/usr.sbin/lpr/filters/lpf.c
index 2f2f88f02089..5a036de4fb6d 100644
--- a/usr.sbin/lpr/filters/lpf.c
+++ b/usr.sbin/lpr/filters/lpf.c
@@ -29,21 +29,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)lpf.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* filter which reads the output of nroff and converts lines
* with ^H's to overwritten lines. Thus this works like 'ul'
diff --git a/usr.sbin/lpr/lp/Makefile b/usr.sbin/lpr/lp/Makefile
index 2fcec43ec80b..c726c0bb25ee 100644
--- a/usr.sbin/lpr/lp/Makefile
+++ b/usr.sbin/lpr/lp/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
BINDIR= /usr/bin
diff --git a/usr.sbin/lpr/lp/Makefile.depend b/usr.sbin/lpr/lp/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/lpr/lp/Makefile.depend
+++ b/usr.sbin/lpr/lp/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/lpr/lp/lp.1 b/usr.sbin/lpr/lp/lp.1
index 903bb031f560..907ce867279e 100644
--- a/usr.sbin/lpr/lp/lp.1
+++ b/usr.sbin/lpr/lp/lp.1
@@ -31,8 +31,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 22, 1995
.Dt LP 1
.Os
diff --git a/usr.sbin/lpr/lp/lp.sh b/usr.sbin/lpr/lp/lp.sh
index af6b9d16880b..114b8e579ebc 100644
--- a/usr.sbin/lpr/lp/lp.sh
+++ b/usr.sbin/lpr/lp/lp.sh
@@ -38,7 +38,6 @@
#
# Posix 1003.2 compliant print spooler interface.
#
-# $FreeBSD$
#
ncopies=""
diff --git a/usr.sbin/lpr/lpc/Makefile b/usr.sbin/lpr/lpc/Makefile
index ab972a5c888b..545f0f7ed121 100644
--- a/usr.sbin/lpr/lpc/Makefile
+++ b/usr.sbin/lpr/lpc/Makefile
@@ -1,5 +1,3 @@
-# From: @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
.PATH: ${.CURDIR:H}/common_source
diff --git a/usr.sbin/lpr/lpc/Makefile.depend b/usr.sbin/lpr/lpc/Makefile.depend
index e59ad46a72f3..50679f3178f8 100644
--- a/usr.sbin/lpr/lpc/Makefile.depend
+++ b/usr.sbin/lpr/lpc/Makefile.depend
@@ -1,15 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libedit \
- lib/ncurses/ncursesw \
usr.sbin/lpr/common_source \
diff --git a/usr.sbin/lpr/lpc/cmds.c b/usr.sbin/lpr/lpc/cmds.c
index c0debb1fcbcd..30e091577732 100644
--- a/usr.sbin/lpr/lpc/cmds.c
+++ b/usr.sbin/lpr/lpc/cmds.c
@@ -30,21 +30,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* lpc -- line printer control program -- commands:
*/
@@ -644,8 +630,6 @@ clean_gi(int argc, char *argv[])
generic_initerr = 1;
}
}
-
- return;
}
void
@@ -656,8 +640,6 @@ tclean_gi(int argc, char *argv[])
/* (...and the fact that 'clean' is priv and 'tclean' is not) */
clean_gi(argc, argv);
cln_testonly = 1;
-
- return;
}
void
diff --git a/usr.sbin/lpr/lpc/cmdtab.c b/usr.sbin/lpr/lpc/cmdtab.c
index 8e8b2b634991..0c91c083a9b2 100644
--- a/usr.sbin/lpr/lpc/cmdtab.c
+++ b/usr.sbin/lpr/lpc/cmdtab.c
@@ -29,15 +29,7 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include "lpc.h"
#include "extern.h"
diff --git a/usr.sbin/lpr/lpc/extern.h b/usr.sbin/lpr/lpc/extern.h
index e34451dbb18e..c1cca9978d06 100644
--- a/usr.sbin/lpr/lpc/extern.h
+++ b/usr.sbin/lpr/lpc/extern.h
@@ -28,10 +28,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.
- *
- * @(#)extern.h 8.1 (Berkeley) 6/6/93
- *
- * $FreeBSD$
*/
diff --git a/usr.sbin/lpr/lpc/lpc.8 b/usr.sbin/lpr/lpc/lpc.8
index abaff662639c..089be4ab3bfc 100644
--- a/usr.sbin/lpr/lpc/lpc.8
+++ b/usr.sbin/lpr/lpc/lpc.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)lpc.8 8.5 (Berkeley) 4/28/95
-.\" $FreeBSD$
-.\"
.Dd July 16, 2002
.Dt LPC 8
.Os
diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c
index 3155a7cc7714..a3da852de46e 100644
--- a/usr.sbin/lpr/lpc/lpc.c
+++ b/usr.sbin/lpr/lpc/lpc.c
@@ -30,21 +30,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)lpc.c 8.3 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <ctype.h>
diff --git a/usr.sbin/lpr/lpc/lpc.h b/usr.sbin/lpr/lpc/lpc.h
index a2350d865564..958956fa33ff 100644
--- a/usr.sbin/lpr/lpc/lpc.h
+++ b/usr.sbin/lpr/lpc/lpc.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.
- *
- * @(#)lpc.h 8.1 (Berkeley) 6/6/93
- *
- * $FreeBSD$
*/
/*
diff --git a/usr.sbin/lpr/lpc/movejobs.c b/usr.sbin/lpr/lpc/movejobs.c
index 26c4d4fb5bcf..35fdcaec3b0c 100644
--- a/usr.sbin/lpr/lpc/movejobs.c
+++ b/usr.sbin/lpr/lpc/movejobs.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* ------+---------+---------+---------+---------+---------+---------+---------*
* Copyright (c) 2002 - Garance Alistair Drosehn <gad@FreeBSD.org>.
@@ -35,8 +35,6 @@
*/
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* movejobs.c - The lpc commands which move jobs around.
*/
diff --git a/usr.sbin/lpr/lpd/Makefile b/usr.sbin/lpr/lpd/Makefile
index 6a152c46268f..944a3e1a83ab 100644
--- a/usr.sbin/lpr/lpd/Makefile
+++ b/usr.sbin/lpr/lpd/Makefile
@@ -1,5 +1,3 @@
-# From: @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
CONFS= hosts.lpd printcap
PROG= lpd
diff --git a/usr.sbin/lpr/lpd/Makefile.depend b/usr.sbin/lpr/lpd/Makefile.depend
index 288e8eec083e..f72fd2df5270 100644
--- a/usr.sbin/lpr/lpd/Makefile.depend
+++ b/usr.sbin/lpr/lpd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/lpr/lpd/extern.h b/usr.sbin/lpr/lpd/extern.h
index 5b3d50d26903..71b02ea904f4 100644
--- a/usr.sbin/lpr/lpd/extern.h
+++ b/usr.sbin/lpr/lpd/extern.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.
- *
- * From: @(#)extern.h 8.1 (Berkeley) 6/6/93
- * $FreeBSD$
*/
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
diff --git a/usr.sbin/lpr/lpd/hosts.lpd b/usr.sbin/lpr/lpd/hosts.lpd
index b53202ab18e5..c440bdec992e 100644
--- a/usr.sbin/lpr/lpd/hosts.lpd
+++ b/usr.sbin/lpr/lpd/hosts.lpd
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# See lpd(8)
#machine.domain
diff --git a/usr.sbin/lpr/lpd/lpd.8 b/usr.sbin/lpr/lpd/lpd.8
index 23c839086571..eed37ea1d6f4 100644
--- a/usr.sbin/lpr/lpd/lpd.8
+++ b/usr.sbin/lpr/lpd/lpd.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)lpd.8 8.3 (Berkeley) 4/19/94
-.\" $FreeBSD$
-.\"
.Dd April 15, 2021
.Dt LPD 8
.Os
@@ -222,7 +219,7 @@ as a filter.
.It t
Troff File.
The file contains
-.Xr troff 1
+.Xr troff 1 Pq Pa ports/textproc/groff
output (cat phototypesetter commands).
.It n
Ditroff File.
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index 56821d114268..b78077dfa225 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -30,21 +30,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* lpd -- line printer daemon.
*
diff --git a/usr.sbin/lpr/lpd/lpdchar.c b/usr.sbin/lpr/lpd/lpdchar.c
index acdb3a4f7411..a9d06fe7f600 100644
--- a/usr.sbin/lpr/lpd/lpdchar.c
+++ b/usr.sbin/lpr/lpd/lpdchar.c
@@ -29,15 +29,7 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)lpdchar.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* Character set for line printer daemon
*/
diff --git a/usr.sbin/lpr/lpd/modes.c b/usr.sbin/lpr/lpd/modes.c
index 653a2cefce7e..c1f61d5be069 100644
--- a/usr.sbin/lpr/lpd/modes.c
+++ b/usr.sbin/lpr/lpd/modes.c
@@ -29,15 +29,7 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)modes.c 8.3 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <stddef.h>
#include <string.h>
#include <termios.h>
diff --git a/usr.sbin/lpr/lpd/printcap b/usr.sbin/lpr/lpd/printcap
index 1bfa1abb4c20..ace92b2bf955 100644
--- a/usr.sbin/lpr/lpd/printcap
+++ b/usr.sbin/lpr/lpd/printcap
@@ -1,5 +1,3 @@
-# @(#)printcap 5.3 (Berkeley) 6/30/90
-# $FreeBSD$
#
# This enables a simple local "raw" printer, hooked up to the first
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index ff16f8f298c1..1c6736097492 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -30,21 +30,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)printjob.c 8.7 (Berkeley) 5/10/95";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* printjob -- print jobs in the queue.
*
diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c
index 890ede4bcbf8..f103829b19e8 100644
--- a/usr.sbin/lpr/lpd/recvjob.c
+++ b/usr.sbin/lpr/lpd/recvjob.c
@@ -30,21 +30,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)recvjob.c 8.2 (Berkeley) 4/27/95";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* Receive printer jobs from the network, queue them and
* start the printer daemon.
@@ -68,7 +54,7 @@ __FBSDID("$FreeBSD$");
#include "extern.h"
#include "pathnames.h"
-#define ack() (void) write(STDOUT_FILENO, sp, (size_t)1);
+#define ack() (void) write(STDOUT_FILENO, sp, (size_t)1)
/*
* The buffer size to use when reading/writing spool files.
diff --git a/usr.sbin/lpr/lpq/Makefile b/usr.sbin/lpr/lpq/Makefile
index 3ce7182480f0..0010eb05e968 100644
--- a/usr.sbin/lpr/lpq/Makefile
+++ b/usr.sbin/lpr/lpq/Makefile
@@ -1,5 +1,3 @@
-# From: @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
BINDIR= /usr/bin
diff --git a/usr.sbin/lpr/lpq/Makefile.depend b/usr.sbin/lpr/lpq/Makefile.depend
index 5ca32400912b..52597b984452 100644
--- a/usr.sbin/lpr/lpq/Makefile.depend
+++ b/usr.sbin/lpr/lpq/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/lpr/lpq/lpq.1 b/usr.sbin/lpr/lpq/lpq.1
index 4d876d2caa96..c87bcbbaa94d 100644
--- a/usr.sbin/lpr/lpq/lpq.1
+++ b/usr.sbin/lpr/lpq/lpq.1
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)lpq.1 8.2 (Berkeley) 4/28/95
-.\" $FreeBSD$
-.\"
.Dd April 28, 1995
.Dt LPQ 1
.Os
diff --git a/usr.sbin/lpr/lpq/lpq.c b/usr.sbin/lpr/lpq/lpq.c
index 7a492950253f..6899b691ee3a 100644
--- a/usr.sbin/lpr/lpq/lpq.c
+++ b/usr.sbin/lpr/lpq/lpq.c
@@ -30,21 +30,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)lpq.c 8.3 (Berkeley) 5/10/95";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* Spool Queue examination program
*
diff --git a/usr.sbin/lpr/lpr/Makefile b/usr.sbin/lpr/lpr/Makefile
index a25bb87f2f44..7f7fa6d1fd71 100644
--- a/usr.sbin/lpr/lpr/Makefile
+++ b/usr.sbin/lpr/lpr/Makefile
@@ -1,5 +1,3 @@
-# From: @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
.PATH: ${.CURDIR:H}/common_source
diff --git a/usr.sbin/lpr/lpr/Makefile.depend b/usr.sbin/lpr/lpr/Makefile.depend
index 5ca32400912b..52597b984452 100644
--- a/usr.sbin/lpr/lpr/Makefile.depend
+++ b/usr.sbin/lpr/lpr/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/lpr/lpr/lpr.1 b/usr.sbin/lpr/lpr/lpr.1
index b63d480d6e0b..8acb9d23d9da 100644
--- a/usr.sbin/lpr/lpr/lpr.1
+++ b/usr.sbin/lpr/lpr/lpr.1
@@ -24,9 +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.
-.\"
-.\" From @(#)lpr.1 8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
.\" "
.Dd June 6, 1993
.Dt LPR 1
@@ -105,7 +102,7 @@ The files are assumed to contain
.Tn C/A/T
phototypesetter commands from ancient versions of
.Ux
-.Xr troff 1 .
+.Xr troff 1 Pq Pa ports/textproc/groff .
.It Fl v
The files are assumed to contain a raster image for devices like the
Benson Varian.
@@ -292,7 +289,7 @@ command appeared in
.Bx 3 .
.Sh BUGS
Fonts for
-.Xr troff 1
+.Xr troff 1 Pq Pa ports/textproc/groff
and
.Tn TeX
reside on the host with the printer.
diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c
index 9845a3774fbe..7d71bb2fa45c 100644
--- a/usr.sbin/lpr/lpr/lpr.c
+++ b/usr.sbin/lpr/lpr/lpr.c
@@ -39,21 +39,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)lpr.c 8.4 (Berkeley) 4/28/95";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* lpr -- off line print
*
@@ -190,7 +176,7 @@ main(int argc, char *argv[])
jobname = optarg;
break;
- case 'P': /* specifiy printer name */
+ case 'P': /* specify printer name */
printer = optarg;
break;
diff --git a/usr.sbin/lpr/lpr/printcap.5 b/usr.sbin/lpr/lpr/printcap.5
index d46b97a73408..e745fafc7b27 100644
--- a/usr.sbin/lpr/lpr/printcap.5
+++ b/usr.sbin/lpr/lpr/printcap.5
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)printcap.5 8.2 (Berkeley) 12/11/93
-.\" $FreeBSD$
-.\"
.Dd October 11, 2000
.Dt PRINTCAP 5
.Os
diff --git a/usr.sbin/lpr/lprm/Makefile b/usr.sbin/lpr/lprm/Makefile
index 8e882c3f8c1b..11c5a7a5a7ac 100644
--- a/usr.sbin/lpr/lprm/Makefile
+++ b/usr.sbin/lpr/lprm/Makefile
@@ -1,5 +1,3 @@
-# From: @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
.PATH: ${.CURDIR:H}/common_source
diff --git a/usr.sbin/lpr/lprm/Makefile.depend b/usr.sbin/lpr/lprm/Makefile.depend
index 5ca32400912b..52597b984452 100644
--- a/usr.sbin/lpr/lprm/Makefile.depend
+++ b/usr.sbin/lpr/lprm/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/lpr/lprm/lprm.1 b/usr.sbin/lpr/lprm/lprm.1
index 3ecf9a5bc2ee..8d35a3434969 100644
--- a/usr.sbin/lpr/lprm/lprm.1
+++ b/usr.sbin/lpr/lprm/lprm.1
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)lprm.1 8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
-.\"
.Dd June 6, 1993
.Dt LPRM 1
.Os
diff --git a/usr.sbin/lpr/lprm/lprm.c b/usr.sbin/lpr/lprm/lprm.c
index 17aac1adc798..fd7b5ccec365 100644
--- a/usr.sbin/lpr/lprm/lprm.c
+++ b/usr.sbin/lpr/lprm/lprm.c
@@ -30,21 +30,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)lprm.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* lprm - remove the current user's spool entry
*
diff --git a/usr.sbin/lpr/lptest/Makefile b/usr.sbin/lpr/lptest/Makefile
index 18083e529d3b..2f44f09acd89 100644
--- a/usr.sbin/lpr/lptest/Makefile
+++ b/usr.sbin/lpr/lptest/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= lptest
diff --git a/usr.sbin/lpr/lptest/Makefile.depend b/usr.sbin/lpr/lptest/Makefile.depend
index cae7e645ef6a..93249906da4f 100644
--- a/usr.sbin/lpr/lptest/Makefile.depend
+++ b/usr.sbin/lpr/lptest/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
lib/${CSU_DIR} \
lib/libc \
diff --git a/usr.sbin/lpr/lptest/lptest.1 b/usr.sbin/lpr/lptest/lptest.1
index 86c11a3e1469..76f9c2418ce8 100644
--- a/usr.sbin/lpr/lptest/lptest.1
+++ b/usr.sbin/lpr/lptest/lptest.1
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)lptest.1 8.2 (Berkeley) 12/30/93
-.\" $FreeBSD$
-.\"
.Dd December 30, 1993
.Dt LPTEST 1
.Os
diff --git a/usr.sbin/lpr/lptest/lptest.c b/usr.sbin/lpr/lptest/lptest.c
index f064e3333628..771652de4892 100644
--- a/usr.sbin/lpr/lptest/lptest.c
+++ b/usr.sbin/lpr/lptest/lptest.c
@@ -30,21 +30,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)lptest.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
diff --git a/usr.sbin/lpr/pac/Makefile b/usr.sbin/lpr/pac/Makefile
index 81ffc5c96c21..c3b6f5078fca 100644
--- a/usr.sbin/lpr/pac/Makefile
+++ b/usr.sbin/lpr/pac/Makefile
@@ -1,5 +1,3 @@
-# From: @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
.PATH: ${.CURDIR:H}/common_source
diff --git a/usr.sbin/lpr/pac/Makefile.depend b/usr.sbin/lpr/pac/Makefile.depend
index 5ca32400912b..52597b984452 100644
--- a/usr.sbin/lpr/pac/Makefile.depend
+++ b/usr.sbin/lpr/pac/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/lpr/pac/pac.8 b/usr.sbin/lpr/pac/pac.8
index 3f1baf875aa2..145d54ad4562 100644
--- a/usr.sbin/lpr/pac/pac.8
+++ b/usr.sbin/lpr/pac/pac.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)pac.8 8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
-.\"
.Dd June 6, 1993
.Dt PAC 8
.Os
diff --git a/usr.sbin/lpr/pac/pac.c b/usr.sbin/lpr/pac/pac.c
index 7713096da641..1cc0e050a99e 100644
--- a/usr.sbin/lpr/pac/pac.c
+++ b/usr.sbin/lpr/pac/pac.c
@@ -30,21 +30,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)pac.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
-__FBSDID("$FreeBSD$");
-
/*
* Do Printer accounting summary.
* Currently, usage is
diff --git a/usr.sbin/lptcontrol/Makefile b/usr.sbin/lptcontrol/Makefile
index 0cff6202fafa..2a34ba9d6382 100644
--- a/usr.sbin/lptcontrol/Makefile
+++ b/usr.sbin/lptcontrol/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= lptcontrol
MAN= lptcontrol.8
diff --git a/usr.sbin/lptcontrol/Makefile.depend b/usr.sbin/lptcontrol/Makefile.depend
index cae7e645ef6a..93249906da4f 100644
--- a/usr.sbin/lptcontrol/Makefile.depend
+++ b/usr.sbin/lptcontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
lib/${CSU_DIR} \
lib/libc \
diff --git a/usr.sbin/lptcontrol/lptcontrol.8 b/usr.sbin/lptcontrol/lptcontrol.8
index 772307884d8b..bcc1e263fe47 100644
--- a/usr.sbin/lptcontrol/lptcontrol.8
+++ b/usr.sbin/lptcontrol/lptcontrol.8
@@ -9,8 +9,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" $FreeBSD$
.Dd October 1, 2004
.Dt LPTCONTROL 8
.Os
diff --git a/usr.sbin/lptcontrol/lptcontrol.c b/usr.sbin/lptcontrol/lptcontrol.c
index 834f62456b54..9381722a6d0c 100644
--- a/usr.sbin/lptcontrol/lptcontrol.c
+++ b/usr.sbin/lptcontrol/lptcontrol.c
@@ -31,8 +31,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <dev/ppbus/lptio.h>
#include <err.h>
diff --git a/usr.sbin/mailstats/Makefile b/usr.sbin/mailstats/Makefile
index b8dd89225551..2da9169090fd 100644
--- a/usr.sbin/mailstats/Makefile
+++ b/usr.sbin/mailstats/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.2 (Berkeley) 9/21/96
-# $FreeBSD$
SENDMAIL_DIR= ${SRCTOP}/contrib/sendmail
.PATH: ${SENDMAIL_DIR}/mailstats
@@ -28,3 +26,5 @@ sm_os.h: ${SENDMAIL_DIR}/include/sm/os/sm_os_freebsd.h .NOMETA
ln -sf ${.ALLSRC} ${.TARGET}
.include <bsd.prog.mk>
+
+CWARNFLAGS+= ${NO_WDEPRECATED_NON_PROTOTYPE}
diff --git a/usr.sbin/mailstats/Makefile.depend b/usr.sbin/mailstats/Makefile.depend
index d1b41fcc8417..caeac562fb7b 100644
--- a/usr.sbin/mailstats/Makefile.depend
+++ b/usr.sbin/mailstats/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/mailwrapper/Makefile b/usr.sbin/mailwrapper/Makefile
index 28e0c3c1ce6d..237be9d6e1b6 100644
--- a/usr.sbin/mailwrapper/Makefile
+++ b/usr.sbin/mailwrapper/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
@@ -9,14 +8,16 @@ MAN= mailwrapper.8
LIBADD= util
.endif
-.if ${MK_MAILWRAPPER} != "no" || ${MK_SENDMAIL} != "no"
+.if ${MK_MAILWRAPPER} != "no" || ${MK_SENDMAIL} != "no" || ${MK_DMAGENT} != "no"
SYMLINKS= ../sbin/mailwrapper /usr/bin/mailq \
../sbin/mailwrapper /usr/bin/newaliases \
mailwrapper /usr/sbin/hoststat \
mailwrapper /usr/sbin/purgestat \
mailwrapper /usr/sbin/sendmail
-.if ${MK_MAILWRAPPER} == "no" && ${MK_SENDMAIL} != "no"
+.if ${MK_MAILWRAPPER} == "no" && ${MK_DMAGENT} != "no"
+SYMLINKS+= ../libexec/dma ${BINDIR}/mailwrapper
+.elif ${MK_MAILWRAPPER} == "no" && ${MK_DMAGENT} == "no" && ${MK_SENDMAIL} != "no"
SYMLINKS+= ../libexec/sendmail/sendmail ${BINDIR}/mailwrapper
.endif
.endif
@@ -25,16 +26,24 @@ SYMLINKS+= ../libexec/sendmail/sendmail ${BINDIR}/mailwrapper
SYMLINKS+= ..${BINDIR}/mailwrapper /bin/rmail
.endif
+.if ${MK_SENDMAIL} != "no"
+FILES= ${SRCTOP}/etc/mail/mailer.conf
+FILESDIR= ${SHAREDIR}/examples/sendmail
+FILESPACKAGE= sendmail
+.endif
+
.if ${MK_MAILWRAPPER} != "no"
-# We install here if either sendmail(8) is enabled, or dma(8) isn't. In the
+# We install here if either dma(8) is enabled, or sendmail(8) isn't. In the
# latter scenario, we take care of the possibility that neither sendmail(8) nor
# dma(8) are installed and simply provide a default that can be changed for an
# alternative in ports.
-.if ${MK_SENDMAIL} != "no" || ${MK_DMAGENT} == "no"
+.if ${MK_DMAGENT} != "no" || ${MK_SENDMAIL} == "no"
+CONFS= ${SRCTOP}/libexec/dma/dmagent/mailer.conf
+.else
CONFS= ${SRCTOP}/etc/mail/mailer.conf
+.endif
CONFSDIR= /etc/mail
CONFSMODE= 644
.endif
-.endif
.include <bsd.prog.mk>
diff --git a/usr.sbin/mailwrapper/Makefile.depend b/usr.sbin/mailwrapper/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/mailwrapper/Makefile.depend
+++ b/usr.sbin/mailwrapper/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/mailwrapper/mailwrapper.8 b/usr.sbin/mailwrapper/mailwrapper.8
index 2da92494b662..8480c939904c 100644
--- a/usr.sbin/mailwrapper/mailwrapper.8
+++ b/usr.sbin/mailwrapper/mailwrapper.8
@@ -1,6 +1,5 @@
.\" $OpenBSD: mailwrapper.8,v 1.12 2014/03/27 22:34:42 jmc Exp $
.\" $NetBSD: mailwrapper.8,v 1.16 2014/09/19 16:05:55 wiz Exp $
-.\" $FreeBSD$
.\"
.\" Copyright (c) 1998
.\" Perry E. Metzger. All rights reserved.
diff --git a/usr.sbin/mailwrapper/mailwrapper.c b/usr.sbin/mailwrapper/mailwrapper.c
index ef9c3b4d55c2..f11361f10daa 100644
--- a/usr.sbin/mailwrapper/mailwrapper.c
+++ b/usr.sbin/mailwrapper/mailwrapper.c
@@ -34,9 +34,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <err.h>
diff --git a/usr.sbin/mailwrapper/pathnames.h b/usr.sbin/mailwrapper/pathnames.h
index 5511d1eccff9..442503af8dd4 100644
--- a/usr.sbin/mailwrapper/pathnames.h
+++ b/usr.sbin/mailwrapper/pathnames.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -34,4 +33,4 @@
*/
#define _PATH_MAILERCONF "/etc/mail/mailer.conf"
-#define _PATH_DEFAULTMTA "/usr/libexec/sendmail/sendmail"
+#define _PATH_DEFAULTMTA "/usr/libexec/dma"
diff --git a/usr.sbin/makefs/Makefile b/usr.sbin/makefs/Makefile
index 3fea648f9383..c0f4469d29f1 100644
--- a/usr.sbin/makefs/Makefile
+++ b/usr.sbin/makefs/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SRCDIR:=${.PARSEDIR:tA}
@@ -19,6 +18,17 @@ MAN= makefs.8
NO_WCAST_ALIGN=
CSTD= c11
+.if ${MK_ZFS} != "no"
+SRCS+= zfs.c
+CFLAGS+=-I${SRCDIR}/zfs \
+ -I${SRCTOP}/stand/libsa \
+ -I${SRCTOP}/sys/cddl/boot
+
+CFLAGS+= -DHAVE_ZFS
+
+.include "${SRCDIR}/zfs/Makefile.inc"
+.endif
+
.include "${SRCDIR}/cd9660/Makefile.inc"
.include "${SRCDIR}/ffs/Makefile.inc"
.include "${SRCDIR}/msdos/Makefile.inc"
@@ -39,4 +49,9 @@ LIBADD= netbsd util sbuf
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
+# cd9660_generate_path_table adds a global variable to an on-stack
+# TAILQ which temporarily stores a pointer to the on-stack TAILQ head
+# in the global
+CWARNFLAGS.cd9660.c+= ${NO_WDANGLING_POINTER}
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/makefs/Makefile.depend b/usr.sbin/makefs/Makefile.depend
index 00df4e89c233..b5ea35e70f2e 100644
--- a/usr.sbin/makefs/Makefile.depend
+++ b/usr.sbin/makefs/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/makefs/Makefile.depend.host b/usr.sbin/makefs/Makefile.depend.host
new file mode 100644
index 000000000000..525b90abb269
--- /dev/null
+++ b/usr.sbin/makefs/Makefile.depend.host
@@ -0,0 +1,11 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ lib/libnetbsd \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/makefs/Makefile.depend.options b/usr.sbin/makefs/Makefile.depend.options
new file mode 100644
index 000000000000..4dcc6c412671
--- /dev/null
+++ b/usr.sbin/makefs/Makefile.depend.options
@@ -0,0 +1,6 @@
+DIRDEPS_OPTIONS = host_egacy
+
+DIRDEPS.host_egacy.yes = tools/build
+
+.include <dirdeps-options.mk>
+
diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index a83ff753b069..500e3c08c7af 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -1,7 +1,7 @@
-/* $NetBSD: cd9660.c,v 1.32 2011/08/23 17:09:11 christos Exp $ */
+/* $NetBSD: cd9660.c,v 1.56 2019/10/18 04:09:02 msaitoh Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD AND BSD-4-Clause
+ * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause
*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
* Perez-Rathke and Ram Vedam. All rights reserved.
@@ -97,9 +97,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/queue.h>
#include <ctype.h>
@@ -110,12 +107,11 @@ __FBSDID("$FreeBSD$");
#include "makefs.h"
#include "cd9660.h"
#include "cd9660/iso9660_rrip.h"
-#include "cd9660/cd9660_archimedes.h"
static void cd9660_finalize_PVD(iso9660_disk *);
static cd9660node *cd9660_allocate_cd9660node(void);
static void cd9660_set_defaults(iso9660_disk *);
-static int cd9660_arguments_set_string(const char *, const char *, int,
+static int cd9660_arguments_set_string(const char *, const char *, size_t,
char, char *);
static void cd9660_populate_iso_dir_record(
struct _iso_directory_record_cd9660 *, u_char, u_char, u_char,
@@ -147,10 +143,6 @@ static int cd9660_level1_convert_filename(iso9660_disk *, const char *, char *,
int);
static int cd9660_level2_convert_filename(iso9660_disk *, const char *, char *,
int);
-#if 0
-static int cd9660_joliet_convert_filename(iso9660_disk *, const char *, char *,
- int);
-#endif
static int cd9660_convert_filename(iso9660_disk *, const char *, char *, int);
static void cd9660_populate_dot_records(iso9660_disk *, cd9660node *);
static int64_t cd9660_compute_offsets(iso9660_disk *, cd9660node *, int64_t);
@@ -200,7 +192,6 @@ cd9660_set_defaults(iso9660_disk *diskStructure)
/* Set up defaults in our own structure */
diskStructure->verbose_level = 0;
diskStructure->keep_bad_images = 0;
- diskStructure->follow_sym_links = 0;
diskStructure->isoLevel = 2;
diskStructure->rock_ridge_enabled = 0;
@@ -208,7 +199,6 @@ cd9660_set_defaults(iso9660_disk *diskStructure)
diskStructure->rock_ridge_move_count = 0;
diskStructure->rr_moved_dir = 0;
- diskStructure->archimedes_enabled = 0;
diskStructure->chrp_boot = 0;
diskStructure->include_padding_areas = 1;
@@ -270,10 +260,6 @@ cd9660_prep_opts(fsinfo_t *fsopts)
OPT_NUM('v', "verbose", verbose_level,
0, 2, "Turns on verbose output"),
- OPT_BOOL('h', "help", displayHelp,
- "Show help message"),
- OPT_BOOL('S', "follow-symlinks", follow_sym_links,
- "Resolve symlinks in pathnames"),
OPT_BOOL('R', "rockridge", rock_ridge_enabled,
"Enable Rock-Ridge extensions"),
OPT_BOOL('C', "chrp-boot", chrp_boot,
@@ -292,8 +278,6 @@ cd9660_prep_opts(fsinfo_t *fsopts)
"Omit trailing periods in filenames"),
OPT_BOOL('\0', "allow-lowercase", allow_lowercase,
"Allow lowercase characters in filenames"),
- OPT_BOOL('\0', "archimedes", archimedes_enabled,
- "Enable Archimedes structure"),
OPT_BOOL('\0', "no-trailing-padding", include_padding_areas,
"Include padding areas"),
@@ -328,13 +312,14 @@ cd9660_cleanup_opts(fsinfo_t *fsopts)
}
static int
-cd9660_arguments_set_string(const char *val, const char *fieldtitle, int length,
- char testmode, char * dest)
+cd9660_arguments_set_string(const char *val, const char *fieldtitle,
+ size_t length, char testmode, char *dest)
{
- int len, test;
+ size_t len;
+ int test;
if (val == NULL)
- warnx("error: The %s requires a string argument", fieldtitle);
+ warnx("error: '%s' requires a string argument", fieldtitle);
else if ((len = strlen(val)) <= length) {
if (testmode == 'd')
test = cd9660_valid_d_chars(val);
@@ -346,10 +331,10 @@ cd9660_arguments_set_string(const char *val, const char *fieldtitle, int length,
cd9660_uppercase_characters(dest, len);
return 1;
} else
- warnx("error: The %s must be composed of "
- "%c-characters", fieldtitle, testmode);
+ warnx("error: '%s' must be composed of %c-characters",
+ fieldtitle, testmode);
} else
- warnx("error: The %s must be at most 32 characters long",
+ warnx("error: '%s' must be at most 32 characters long",
fieldtitle);
return 0;
}
@@ -494,14 +479,6 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
assert(dir != NULL);
assert(root != NULL);
- if (diskStructure->displayHelp) {
- /*
- * Display help here - probably want to put it in
- * a separate function
- */
- return;
- }
-
if (diskStructure->verbose_level > 0)
printf("%s: image %s directory %s root %p\n", __func__,
image, dir, root);
@@ -546,10 +523,6 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
if (diskStructure->verbose_level > 0)
printf("%s: done converting tree\n", __func__);
- /* non-SUSP extensions */
- if (diskStructure->archimedes_enabled)
- archimedes_convert_tree(diskStructure->rootNode);
-
/* Rock ridge / SUSP init pass */
if (diskStructure->rock_ridge_enabled) {
cd9660_susp_initialize(diskStructure, diskStructure->rootNode,
@@ -727,7 +700,10 @@ cd9660_populate_iso_dir_record(struct _iso_directory_record_cd9660 *record,
u_char ext_attr_length, u_char flags,
u_char name_len, const char * name)
{
+ time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL);
+
record->ext_attr_length[0] = ext_attr_length;
+ cd9660_time_915(record->date, tstamp);
record->flags[0] = ISO_FLAG_CLEAR | flags;
record->file_unit_size[0] = 0;
record->interleave[0] = 0;
@@ -814,7 +790,6 @@ cd9660_fill_extended_attribute_record(cd9660node *node)
static int
cd9660_translate_node_common(iso9660_disk *diskStructure, cd9660node *newnode)
{
- time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL);
u_char flag;
char temp[ISO_FILENAME_MAXLENGTH_WITH_PADDING];
@@ -831,12 +806,6 @@ cd9660_translate_node_common(iso9660_disk *diskStructure, cd9660node *newnode)
cd9660_populate_iso_dir_record(newnode->isoDirRecord, 0,
flag, strlen(temp), temp);
- /* Set the various dates */
-
- /* If we want to use the current date and time */
-
- cd9660_time_915(newnode->isoDirRecord->date, tstamp);
-
cd9660_bothendian_dword(newnode->fileDataLength,
newnode->isoDirRecord->size);
/* If the file is a link, we want to set the size to 0 */
@@ -886,7 +855,7 @@ cd9660_translate_node(iso9660_disk *diskStructure, fsnode *node,
* @param const char * The first file name
* @param const char * The second file name
* @returns : -1 if first is less than second, 0 if they are the same, 1 if
- * the second is greater than the first
+ * the second is greater than the first
*/
static int
cd9660_compare_filename(const char *first, const char *second)
@@ -1001,7 +970,7 @@ cd9660_sorted_child_insert(cd9660node *parent, cd9660node *cn_new)
/*
* Called After cd9660_sorted_child_insert
- * handles file collisions by suffixing each filname with ~n
+ * handles file collisions by suffixing each filename with ~n
* where n represents the files respective place in the ordering
*/
static int
@@ -1275,7 +1244,7 @@ cd9660_rrip_move_directory(iso9660_disk *diskStructure, cd9660node *dir)
return NULL;
diskStructure->rock_ridge_move_count++;
- snprintf(newname, sizeof(newname), "%08i",
+ snprintf(newname, sizeof(newname), "%08u",
diskStructure->rock_ridge_move_count);
/* Point to old parent */
@@ -1538,10 +1507,10 @@ cd9660_generate_path_table(iso9660_disk *diskStructure)
TAILQ_INSERT_HEAD(&pt_head, n, ptq);
/* Breadth-first traversal of file structure */
- while (pt_head.tqh_first != 0) {
- n = pt_head.tqh_first;
+ while (!TAILQ_EMPTY(&pt_head)) {
+ n = TAILQ_FIRST(&pt_head);
dirNode = n->node;
- TAILQ_REMOVE(&pt_head, pt_head.tqh_first, ptq);
+ TAILQ_REMOVE(&pt_head, n, ptq);
free(n);
/* Update the size */
@@ -1582,18 +1551,13 @@ cd9660_compute_full_filename(cd9660node *node, char *buf)
{
int len;
- len = CD9660MAXPATH + 1;
+ len = PATH_MAX;
len = snprintf(buf, len, "%s/%s/%s", node->node->root,
node->node->path, node->node->name);
- if (len > CD9660MAXPATH)
+ if (len >= PATH_MAX)
errx(EXIT_FAILURE, "Pathname too long.");
}
-/* NEW filename conversion method */
-typedef int(*cd9660_filename_conversion_functor)(iso9660_disk *, const char *,
- char *, int);
-
-
/*
* TODO: These two functions are almost identical.
* Some code cleanup is possible here
@@ -1626,11 +1590,6 @@ cd9660_level1_convert_filename(iso9660_disk *diskStructure, const char *oldname,
found_ext = 1;
}
} else {
- /* cut RISC OS file type off ISO name */
- if (diskStructure->archimedes_enabled &&
- *oldname == ',' && strlen(oldname) == 4)
- break;
-
/* Enforce 12.3 / 8 */
if (namelen == 8 && !found_ext)
break;
@@ -1693,19 +1652,14 @@ cd9660_level2_convert_filename(iso9660_disk *diskStructure, const char *oldname,
found_ext = 1;
}
} else {
- /* cut RISC OS file type off ISO name */
- if (diskStructure->archimedes_enabled &&
- *oldname == ',' && strlen(oldname) == 4)
- break;
-
- if (islower((unsigned char)*oldname))
+ if (islower((unsigned char)*oldname))
*newname++ = toupper((unsigned char)*oldname);
else if (isupper((unsigned char)*oldname) ||
isdigit((unsigned char)*oldname))
*newname++ = *oldname;
else if (diskStructure->allow_multidot &&
*oldname == '.') {
- *newname++ = '.';
+ *newname++ = '.';
} else {
*newname++ = '_';
}
@@ -1726,16 +1680,6 @@ cd9660_level2_convert_filename(iso9660_disk *diskStructure, const char *oldname,
return namelen + extlen + found_ext;
}
-#if 0
-static int
-cd9660_joliet_convert_filename(iso9660_disk *diskStructure, const char *oldname,
- char *newname, int is_file)
-{
- /* TODO: implement later, move to cd9660_joliet.c ?? */
-}
-#endif
-
-
/*
* Convert a file name to ISO compliant file name
* @param char * oldname The original filename
@@ -1749,13 +1693,13 @@ cd9660_convert_filename(iso9660_disk *diskStructure, const char *oldname,
char *newname, int is_file)
{
assert(1 <= diskStructure->isoLevel && diskStructure->isoLevel <= 2);
- /* NEW */
- cd9660_filename_conversion_functor conversion_function = NULL;
if (diskStructure->isoLevel == 1)
- conversion_function = &cd9660_level1_convert_filename;
+ return(cd9660_level1_convert_filename(diskStructure,
+ oldname, newname, is_file));
else if (diskStructure->isoLevel == 2)
- conversion_function = &cd9660_level2_convert_filename;
- return (*conversion_function)(diskStructure, oldname, newname, is_file);
+ return (cd9660_level2_convert_filename(diskStructure,
+ oldname, newname, is_file));
+ abort();
}
int
@@ -1852,7 +1796,7 @@ cd9660_compute_offsets(iso9660_disk *diskStructure, cd9660node *node,
cd9660_compute_record_size(diskStructure, child);
if ((cd9660_compute_record_size(diskStructure, child) +
current_sector_usage) >=
- diskStructure->sectorSize) {
+ diskStructure->sectorSize) {
current_sector_usage = 0;
node->fileSectorsUsed++;
}
diff --git a/usr.sbin/makefs/cd9660.h b/usr.sbin/makefs/cd9660.h
index 5f6525d3e94f..bc826a414a6d 100644
--- a/usr.sbin/makefs/cd9660.h
+++ b/usr.sbin/makefs/cd9660.h
@@ -1,7 +1,7 @@
-/* $NetBSD: cd9660.h,v 1.17 2011/06/23 02:35:56 enami Exp $ */
+/* $NetBSD: cd9660.h,v 1.21 2015/12/24 15:52:37 christos Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
* Perez-Rathke and Ram Vedam. All rights reserved.
@@ -32,8 +32,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$
*/
#ifndef _MAKEFS_CD9660_H
@@ -65,33 +63,8 @@
#define INODE_WARNX(__x)
#endif /* DEBUG */
-#define CD9660MAXPATH 4096
-
-#define ISO_STRING_FILTER_NONE = 0x00
-#define ISO_STRING_FILTER_DCHARS = 0x01
-#define ISO_STRING_FILTER_ACHARS = 0x02
-
-/*
-Extended preferences type, in the spirit of what makefs gives us (only ints)
-*/
-typedef struct {
- const char *shortName; /* Short option */
- const char *name; /* option name */
- char *value; /* where to stuff the value */
- int minLength; /* minimum for value */
- int maxLength; /* maximum for value */
- const char *desc; /* option description */
- int filterFlags;
-} string_option_t;
-
/******** STRUCTURES **********/
-/*Defaults*/
-#define ISO_DEFAULT_VOLUMEID "MAKEFS_CD9660_IMAGE"
-#define ISO_DEFAULT_APPID "MAKEFS"
-#define ISO_DEFAULT_PUBLISHER "MAKEFS"
-#define ISO_DEFAULT_PREPARER "MAKEFS"
-
#define ISO_VOLUME_DESCRIPTOR_STANDARD_ID "CD001"
#define ISO_VOLUME_DESCRIPTOR_BOOT 0
#define ISO_VOLUME_DESCRIPTOR_PVD 1
@@ -263,9 +236,7 @@ typedef struct _iso9660_disk {
int include_padding_areas;
- int follow_sym_links;
int verbose_level;
- int displayHelp;
int keep_bad_images;
/* SUSP options and variables */
@@ -276,10 +247,9 @@ typedef struct _iso9660_disk {
int rock_ridge_enabled;
/* Other Rock Ridge Variables */
char *rock_ridge_renamed_dir_name;
- int rock_ridge_move_count;
+ unsigned rock_ridge_move_count;
cd9660node *rr_moved_dir;
- int archimedes_enabled;
int chrp_boot;
/* Spec breaking options */
@@ -309,15 +279,15 @@ typedef struct _iso9660_disk {
/************ FUNCTIONS **************/
int cd9660_valid_a_chars(const char *);
int cd9660_valid_d_chars(const char *);
-void cd9660_uppercase_characters(char *, int);
+void cd9660_uppercase_characters(char *, size_t);
/* ISO Data Types */
void cd9660_721(uint16_t, unsigned char *);
void cd9660_731(uint32_t, unsigned char *);
void cd9660_722(uint16_t, unsigned char *);
void cd9660_732(uint32_t, unsigned char *);
-void cd9660_bothendian_dword(uint32_t dw, unsigned char *);
-void cd9660_bothendian_word(uint16_t dw, unsigned char *);
+void cd9660_bothendian_dword(uint32_t dw, unsigned char *);
+void cd9660_bothendian_word(uint16_t dw, unsigned char *);
void cd9660_set_date(char *, time_t);
void cd9660_time_8426(unsigned char *, time_t);
void cd9660_time_915(unsigned char *, time_t);
diff --git a/usr.sbin/makefs/cd9660/Makefile.inc b/usr.sbin/makefs/cd9660/Makefile.inc
index b5012a323699..ec949f1413dc 100644
--- a/usr.sbin/makefs/cd9660/Makefile.inc
+++ b/usr.sbin/makefs/cd9660/Makefile.inc
@@ -1,9 +1,6 @@
-# $FreeBSD$
-#
-
.PATH: ${SRCDIR}/cd9660
CFLAGS+=-I${SRCTOP}/sys/fs/cd9660/
SRCS+= cd9660_strings.c cd9660_debug.c cd9660_eltorito.c \
- cd9660_write.c cd9660_conversion.c iso9660_rrip.c cd9660_archimedes.c
+ cd9660_write.c cd9660_conversion.c iso9660_rrip.c
diff --git a/usr.sbin/makefs/cd9660/cd9660_archimedes.c b/usr.sbin/makefs/cd9660/cd9660_archimedes.c
deleted file mode 100644
index cf53e0123d24..000000000000
--- a/usr.sbin/makefs/cd9660/cd9660_archimedes.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* $NetBSD: cd9660_archimedes.c,v 1.1 2009/01/10 22:06:29 bjh21 Exp $ */
-
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1998, 2009 Ben Harris
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/*
- * cd9660_archimedes.c - support for RISC OS "ARCHIMEDES" extension
- *
- * RISC OS CDFS looks for a special block at the end of the System Use
- * Field for each file. If present, this contains the RISC OS load
- * and exec address (used to hold the file timestamp and type), the
- * file attributes, and a flag indicating whether the first character
- * of the filename should be replaced with '!' (since many special
- * RISC OS filenames do).
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <assert.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <util.h>
-
-#include "makefs.h"
-#include "cd9660.h"
-#include "cd9660_archimedes.h"
-
-/*
- * Convert a Unix time_t (non-leap seconds since 1970-01-01) to a RISC
- * OS time (non-leap(?) centiseconds since 1900-01-01(?)).
- */
-
-static u_int64_t
-riscos_date(time_t unixtime)
-{
- u_int64_t base;
-
- base = 31536000ULL * 70 + 86400 * 17;
- return (((u_int64_t)unixtime) + base)*100;
-}
-
-/*
- * Add "ARCHIMEDES" metadata to a node if that seems appropriate.
- *
- * We touch regular files with names matching /,[0-9a-f]{3}$/ and
- * directories matching /^!/.
- */
-static void
-archimedes_convert_node(cd9660node *node)
-{
- struct ISO_ARCHIMEDES *arc;
- size_t len;
- int type = -1;
- uint64_t stamp;
-
- if (node->su_tail_data != NULL)
- /* Something else already has the tail. */
- return;
-
- len = strlen(node->node->name);
- if (len < 1) return;
-
- if (len >= 4 && node->node->name[len-4] == ',')
- /* XXX should support ,xxx and ,lxa */
- type = strtoul(node->node->name + len - 3, NULL, 16);
- if (type == -1 && node->node->name[0] != '!')
- return;
- if (type == -1) type = 0;
-
- assert(sizeof(*arc) == 32);
- arc = ecalloc(1, sizeof(*arc));
-
- stamp = riscos_date(node->node->inode->st.st_mtime);
-
- memcpy(arc->magic, "ARCHIMEDES", 10);
- cd9660_731(0xfff00000 | (type << 8) | (stamp >> 32), arc->loadaddr);
- cd9660_731(stamp & 0x00ffffffffULL, arc->execaddr);
- arc->ro_attr = RO_ACCESS_UR | RO_ACCESS_OR;
- arc->cdfs_attr = node->node->name[0] == '!' ? CDFS_PLING : 0;
- node->su_tail_data = (void *)arc;
- node->su_tail_size = sizeof(*arc);
-}
-
-/*
- * Add "ARCHIMEDES" metadata to an entire tree recursively.
- */
-void
-archimedes_convert_tree(cd9660node *node)
-{
- cd9660node *cn;
-
- assert(node != NULL);
-
- archimedes_convert_node(node);
-
- /* Recurse on children. */
- TAILQ_FOREACH(cn, &node->cn_children, cn_next_child)
- archimedes_convert_tree(cn);
-}
diff --git a/usr.sbin/makefs/cd9660/cd9660_archimedes.h b/usr.sbin/makefs/cd9660/cd9660_archimedes.h
deleted file mode 100644
index 96e30336310b..000000000000
--- a/usr.sbin/makefs/cd9660/cd9660_archimedes.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* $NetBSD: cd9660_archimedes.h,v 1.1 2009/01/10 22:06:29 bjh21 Exp $ */
-
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1998, 2009 Ben Harris
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/*
- * cd9660_archimedes.c - support for RISC OS "ARCHIMEDES" extension
- *
- * $FreeBSD$
- */
-
-struct ISO_ARCHIMEDES {
- char magic[10]; /* "ARCHIMEDES" */
- unsigned char loadaddr[4]; /* Load address, little-endian */
- unsigned char execaddr[4]; /* Exec address, little-endian */
- unsigned char ro_attr; /* RISC OS attributes */
-#define RO_ACCESS_UR 0x01 /* Owner read */
-#define RO_ACCESS_UW 0x02 /* Owner write */
-#define RO_ACCESS_L 0x04 /* Locked */
-#define RO_ACCESS_OR 0x10 /* Public read */
-#define RO_ACCESS_OW 0x20 /* Public write */
- unsigned char cdfs_attr; /* Extra attributes for CDFS */
-#define CDFS_PLING 0x01 /* Filename begins with '!' */
- char reserved[12];
-};
-
-extern void archimedes_convert_tree(cd9660node *);
diff --git a/usr.sbin/makefs/cd9660/cd9660_conversion.c b/usr.sbin/makefs/cd9660/cd9660_conversion.c
index 57a1c62a25b7..4ccc87e22661 100644
--- a/usr.sbin/makefs/cd9660/cd9660_conversion.c
+++ b/usr.sbin/makefs/cd9660/cd9660_conversion.c
@@ -1,7 +1,7 @@
/* $NetBSD: cd9660_conversion.c,v 1.4 2007/03/14 14:11:17 christos Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
* Perez-Rathke and Ram Vedam. All rights reserved.
@@ -36,8 +36,6 @@
#include "cd9660.h"
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
static char cd9660_compute_gm_offset(time_t);
#if 0
diff --git a/usr.sbin/makefs/cd9660/cd9660_debug.c b/usr.sbin/makefs/cd9660/cd9660_debug.c
index b1e07fb85f0f..f49c5108f4c2 100644
--- a/usr.sbin/makefs/cd9660/cd9660_debug.c
+++ b/usr.sbin/makefs/cd9660/cd9660_debug.c
@@ -1,7 +1,7 @@
/* $NetBSD: cd9660_debug.c,v 1.11 2010/10/27 18:51:35 christos Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
* Perez-Rathke and Ram Vedam. All rights reserved.
@@ -34,8 +34,6 @@
* OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/mount.h>
diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.c b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
index 3628a798db4c..dd5bf67b2b09 100644
--- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c
+++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
@@ -1,7 +1,7 @@
/* $NetBSD: cd9660_eltorito.c,v 1.23 2018/03/28 06:48:55 nonaka Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
* Perez-Rathke and Ram Vedam. All rights reserved.
@@ -39,7 +39,13 @@
#include <util.h>
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+/*
+ * Partition Status Information from Apple Tech Note 1189
+ */
+#define APPLE_PS_VALID 0x00000001 /* Entry is valid */
+#define APPLE_PS_ALLOCATED 0x00000002 /* Entry is allocated */
+#define APPLE_PS_READABLE 0x00000010 /* Entry is readable */
+#define APPLE_PS_WRITABLE 0x00000020 /* Entry is writable */
#ifdef DEBUG
#define ELTORITO_DPRINTF(__x) printf __x
@@ -366,6 +372,7 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int first_sector)
struct boot_catalog_entry *x86_head, *mac_head, *ppc_head, *efi_head,
*valid_entry, *default_entry, *temp, *head, **headp, *next;
struct cd9660_boot_image *tmp_disk;
+ uint8_t system;
headp = NULL;
x86_head = mac_head = ppc_head = efi_head = NULL;
@@ -377,12 +384,19 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int first_sector)
/* Point to catalog: For now assume it consumes one sector */
ELTORITO_DPRINTF(("Boot catalog will go in sector %d\n", first_sector));
diskStructure->boot_catalog_sector = first_sector;
- cd9660_bothendian_dword(first_sector,
- diskStructure->boot_descriptor->boot_catalog_pointer);
+ cd9660_731(first_sector,
+ diskStructure->boot_descriptor->boot_catalog_pointer);
+
+ /*
+ * Use system type of default image for validation entry. Fallback to
+ * X86 system type if not found.
+ */
+ system = default_boot_image != NULL ? default_boot_image->system :
+ ET_SYS_X86;
/* Step 1: Generate boot catalog */
/* Step 1a: Validation entry */
- valid_entry = cd9660_boot_setup_validation_entry(ET_SYS_X86);
+ valid_entry = cd9660_boot_setup_validation_entry(system);
if (valid_entry == NULL)
return -1;
@@ -540,7 +554,7 @@ cd9660_write_mbr_partition_entry(FILE *fd, int idx, off_t sector_start,
if (fseeko(fd, (off_t)(idx) * 16 + 0x1be, SEEK_SET) == -1)
err(1, "fseeko");
-
+
val = 0x80; /* Bootable */
fwrite(&val, sizeof(val), 1, fd);
@@ -574,15 +588,8 @@ cd9660_write_apm_partition_entry(FILE *fd, int idx, int total_partitions,
uint32_t apm32, part_status;
uint16_t apm16;
- /* See Apple Tech Note 1189 for the details about the pmPartStatus
- * flags.
- * Below the flags which are default:
- * - IsValid 0x01
- * - IsAllocated 0x02
- * - IsReadable 0x10
- * - IsWritable 0x20
- */
- part_status = 0x01 | 0x02 | 0x10 | 0x20;
+ part_status = APPLE_PS_VALID | APPLE_PS_ALLOCATED | APPLE_PS_READABLE |
+ APPLE_PS_WRITABLE;
if (fseeko(fd, (off_t)(idx + 1) * sector_size, SEEK_SET) == -1)
err(1, "fseeko");
@@ -610,7 +617,7 @@ cd9660_write_apm_partition_entry(FILE *fd, int idx, int total_partitions,
apm32 = 0;
/* pmLgDataStart */
fwrite(&apm32, sizeof(apm32), 1, fd);
- /* pmDataCnt */
+ /* pmDataCnt */
apm32 = htobe32(nsectors);
fwrite(&apm32, sizeof(apm32), 1, fd);
/* pmPartStatus */
@@ -659,9 +666,9 @@ cd9660_write_boot(iso9660_disk *diskStructure, FILE *fd)
}
cd9660_copy_file(diskStructure, fd, t->sector, t->filename);
- if (t->system == ET_SYS_MAC)
+ if (t->system == ET_SYS_MAC)
apm_partitions++;
- if (t->system == ET_SYS_PPC)
+ if (t->system == ET_SYS_PPC)
mbr_partitions++;
}
diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.h b/usr.sbin/makefs/cd9660/cd9660_eltorito.h
index cbc3f8419e31..a9ad0901e1a7 100644
--- a/usr.sbin/makefs/cd9660/cd9660_eltorito.h
+++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.h
@@ -1,7 +1,7 @@
/* $NetBSD: cd9660_eltorito.h,v 1.6 2017/01/24 11:22:43 nonaka Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
* Perez-Rathke and Ram Vedam. All rights reserved.
@@ -32,8 +32,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$
*/
#ifndef _CD9660_ELTORITO_H_
@@ -131,7 +129,7 @@ struct boot_catalog_entry {
char entry_type;
union {
boot_catalog_validation_entry VE;
- boot_catalog_initial_entry IE;
+ boot_catalog_initial_entry IE;
boot_catalog_section_header SH;
boot_catalog_section_entry SE;
boot_catalog_section_entry_extension EX;
@@ -144,7 +142,7 @@ struct boot_catalog_entry {
struct cd9660_boot_image {
char *filename;
int size;
- int sector; /* copied to LoadRBA */
+ int sector; /* copied to LoadRBA */
int num_sectors;
unsigned int loadSegment;
u_char targetMode;
diff --git a/usr.sbin/makefs/cd9660/cd9660_strings.c b/usr.sbin/makefs/cd9660/cd9660_strings.c
index 12d7566e463d..b3111fca6cd1 100644
--- a/usr.sbin/makefs/cd9660/cd9660_strings.c
+++ b/usr.sbin/makefs/cd9660/cd9660_strings.c
@@ -1,7 +1,7 @@
/* $NetBSD: cd9660_strings.c,v 1.4 2007/01/16 17:32:05 hubertf Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
* Perez-Rathke and Ram Vedam. All rights reserved.
@@ -36,8 +36,6 @@
#include <sys/mount.h>
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <ctype.h>
@@ -46,9 +44,9 @@ __FBSDID("$FreeBSD$");
void
-cd9660_uppercase_characters(char *str, int len)
+cd9660_uppercase_characters(char *str, size_t len)
{
- int p;
+ size_t p;
for (p = 0; p < len; p++) {
if (islower((unsigned char)str[p]) )
diff --git a/usr.sbin/makefs/cd9660/cd9660_write.c b/usr.sbin/makefs/cd9660/cd9660_write.c
index 71e884f792d9..828af11669c1 100644
--- a/usr.sbin/makefs/cd9660/cd9660_write.c
+++ b/usr.sbin/makefs/cd9660/cd9660_write.c
@@ -1,7 +1,7 @@
/* $NetBSD: cd9660_write.c,v 1.14 2011/01/04 09:48:21 wiz Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
* Perez-Rathke and Ram Vedam. All rights reserved.
@@ -38,8 +38,6 @@
#include "iso9660_rrip.h"
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <util.h>
static int cd9660_write_volume_descriptors(iso9660_disk *, FILE *);
@@ -273,7 +271,7 @@ cd9660_write_file(iso9660_disk *diskStructure, FILE *fd, cd9660node *writenode)
/* Todo : clean up variables */
- temp_file_name = ecalloc(CD9660MAXPATH + 1, 1);
+ temp_file_name = ecalloc(PATH_MAX, 1);
buf = emalloc(diskStructure->sectorSize);
if ((writenode->level != 0) &&
!(writenode->node->type & S_IFDIR)) {
@@ -316,7 +314,7 @@ cd9660_write_file(iso9660_disk *diskStructure, FILE *fd, cd9660node *writenode)
/*
* Now loop over children, writing out their directory
* records - beware of sector boundaries
- */
+ */
TAILQ_FOREACH(temp, &writenode->cn_children, cn_next_child) {
/*
* Copy the temporary record and adjust its size
@@ -429,7 +427,6 @@ cd9660_copy_file(iso9660_disk *diskStructure, FILE *fd, off_t start_sector,
{
FILE *rf;
int bytes_read;
- off_t sector = start_sector;
int buf_size = diskStructure->sectorSize;
char *buf;
@@ -462,7 +459,6 @@ cd9660_copy_file(iso9660_disk *diskStructure, FILE *fd, off_t start_sector,
(void)fclose(rf);
return 0;
}
- sector++;
}
fclose(rf);
diff --git a/usr.sbin/makefs/cd9660/iso9660_rrip.c b/usr.sbin/makefs/cd9660/iso9660_rrip.c
index c5ef88d59de6..a4ce5c09b24b 100644
--- a/usr.sbin/makefs/cd9660/iso9660_rrip.c
+++ b/usr.sbin/makefs/cd9660/iso9660_rrip.c
@@ -1,7 +1,7 @@
/* $NetBSD: iso9660_rrip.c,v 1.14 2014/05/30 13:14:47 martin Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
* Perez-Rathke and Ram Vedam. All rights reserved.
@@ -38,8 +38,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/queue.h>
#include <sys/types.h>
#include <stdio.h>
@@ -394,6 +392,12 @@ cd9660_rrip_initialize_node(iso9660_disk *diskStructure, cd9660node *node,
SUSP_ENTRY_RRIP_PX, "PX", SUSP_LOC_ENTRY);
cd9660node_rrip_px(current, parent->node);
TAILQ_INSERT_TAIL(&node->head, current, rr_ll);
+
+ /* TF - timestamp */
+ current = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
+ SUSP_ENTRY_RRIP_TF, "TF", SUSP_LOC_ENTRY);
+ cd9660node_rrip_tf(current, parent->node);
+ TAILQ_INSERT_TAIL(&node->head, current, rr_ll);
}
} else if (node->type & CD9660_TYPE_DOTDOT) {
if (grandparent != NULL && grandparent->node != NULL &&
@@ -403,6 +407,12 @@ cd9660_rrip_initialize_node(iso9660_disk *diskStructure, cd9660node *node,
SUSP_ENTRY_RRIP_PX, "PX", SUSP_LOC_ENTRY);
cd9660node_rrip_px(current, grandparent->node);
TAILQ_INSERT_TAIL(&node->head, current, rr_ll);
+
+ /* TF - timestamp */
+ current = cd9660node_susp_create_node(SUSP_TYPE_RRIP,
+ SUSP_ENTRY_RRIP_TF, "TF", SUSP_LOC_ENTRY);
+ cd9660node_rrip_tf(current, grandparent->node);
+ TAILQ_INSERT_TAIL(&node->head, current, rr_ll);
}
/* Handle PL */
if (parent != NULL && parent->rr_real_parent != NULL) {
@@ -414,26 +424,12 @@ cd9660_rrip_initialize_node(iso9660_disk *diskStructure, cd9660node *node,
} else {
cd9660_rrip_initialize_inode(node);
- /*
- * Not every node needs a NM set - only if the name is
- * actually different. IE: If a file is TEST -> TEST,
- * no NM. test -> TEST, need a NM
- *
- * The rr_moved_dir needs to be assigned a NM record as well.
- */
if (node == diskStructure->rr_moved_dir) {
cd9660_rrip_add_NM(node, RRIP_DEFAULT_MOVE_DIR_NAME);
- }
- else if ((node->node != NULL) &&
- ((strlen(node->node->name) !=
- (uint8_t)node->isoDirRecord->name_len[0]) ||
- (memcmp(node->node->name,node->isoDirRecord->name,
- (uint8_t)node->isoDirRecord->name_len[0]) != 0))) {
+ } else if (node->node != NULL) {
cd9660_rrip_NM(node);
}
-
-
/* Rock ridge directory relocation code here. */
/* First handle the CL for the placeholder file. */
@@ -699,11 +695,11 @@ cd9660node_rrip_tf(struct ISO_SUSP_ATTRIBUTES *p, fsnode *_node)
*/
cd9660_time_915(p->attr.rr_entry.TF.timestamp,
- _node->inode->st.st_atime);
+ _node->inode->st.st_mtime);
p->attr.rr_entry.TF.h.length[0] += 7;
cd9660_time_915(p->attr.rr_entry.TF.timestamp + 7,
- _node->inode->st.st_mtime);
+ _node->inode->st.st_atime);
p->attr.rr_entry.TF.h.length[0] += 7;
cd9660_time_915(p->attr.rr_entry.TF.timestamp + 14,
@@ -756,7 +752,7 @@ cd9660_rrip_add_NM(cd9660node *node, const char *name)
struct ISO_SUSP_ATTRIBUTES *r;
/*
- * Each NM record has 254 byes to work with. This means that
+ * Each NM record has 254 bytes to work with. This means that
* the name data itself only has 249 bytes to work with. So, a
* name with 251 characters would require two nm records.
*/
diff --git a/usr.sbin/makefs/cd9660/iso9660_rrip.h b/usr.sbin/makefs/cd9660/iso9660_rrip.h
index 0c7b89ec860b..5e1e8b5130f0 100644
--- a/usr.sbin/makefs/cd9660/iso9660_rrip.h
+++ b/usr.sbin/makefs/cd9660/iso9660_rrip.h
@@ -1,7 +1,7 @@
/* $NetBSD: iso9660_rrip.h,v 1.5 2009/01/10 22:06:29 bjh21 Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
* Perez-Rathke and Ram Vedam. All rights reserved.
@@ -32,8 +32,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$
*/
#ifndef __ISO9660_RRIP_H__
#define __ISO9660_RRIP_H__
@@ -52,17 +50,17 @@
#define PX_LENGTH 0x2C
#define PN_LENGTH 0x14
-#define TF_CREATION 0x00
-#define TF_MODIFY 0x01
-#define TF_ACCESS 0x02
-#define TF_ATTRIBUTES 0x04
-#define TF_BACKUP 0x08
-#define TF_EXPIRATION 0x10
-#define TF_EFFECTIVE 0x20
-#define TF_LONGFORM 0x40
-#define NM_CONTINUE 0x80
-#define NM_CURRENT 0x100
-#define NM_PARENT 0x200
+#define TF_CREATION 0x01
+#define TF_MODIFY 0x02
+#define TF_ACCESS 0x04
+#define TF_ATTRIBUTES 0x08
+#define TF_BACKUP 0x10
+#define TF_EXPIRATION 0x20
+#define TF_EFFECTIVE 0x40
+#define TF_LONG_FORM 0x80
+#define NM_CONTINUE 0x01
+#define NM_CURRENT 0x02
+#define NM_PARENT 0x04
#define SUSP_LOC_ENTRY 0x01
@@ -209,7 +207,7 @@ struct ISO_SUSP_ATTRIBUTES {
char type_of[2];
char last_in_suf; /* last entry in the System Use Field? */
/* Dan's addons - will merge later. This allows use of a switch */
- char susp_type; /* SUSP or RRIP */
+ char susp_type; /* SUSP or RRIP */
char entry_type; /* Record type */
char write_location;
TAILQ_ENTRY(ISO_SUSP_ATTRIBUTES) rr_ll;
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c
index 81101b6aa6bf..ebfda7f929e4 100644
--- a/usr.sbin/makefs/ffs.c
+++ b/usr.sbin/makefs/ffs.c
@@ -63,13 +63,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.
- *
- * @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
@@ -342,6 +338,9 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts)
/* set FFS defaults */
if (fsopts->sectorsize == -1)
fsopts->sectorsize = DFL_SECSIZE;
+ if (fsopts->sectorsize != DFL_SECSIZE)
+ warnx("sectorsize %d may produce nonfunctional image",
+ fsopts->sectorsize);
if (ffs_opts->fsize == -1)
ffs_opts->fsize = MAX(DFL_FRAGSIZE, fsopts->sectorsize);
if (ffs_opts->bsize == -1)
@@ -907,7 +906,7 @@ ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts)
static void
ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts)
{
- int isfile, ffd;
+ int isfile, ffd;
char *fbuf, *p;
off_t bufleft, chunk, offset;
ssize_t nread;
@@ -954,7 +953,7 @@ ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts)
if (isfile) {
fbuf = emalloc(ffs_opts->bsize);
- if ((ffd = open((char *)buf, O_RDONLY, 0444)) == -1) {
+ if ((ffd = open((char *)buf, O_RDONLY)) == -1) {
err(EXIT_FAILURE, "Can't open `%s' for reading", (char *)buf);
}
} else {
@@ -1002,7 +1001,6 @@ ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts)
errno = bwrite(bp);
if (errno != 0)
goto bad_ffs_write_file;
- brelse(bp);
if (!isfile)
p += chunk;
}
@@ -1097,7 +1095,7 @@ ffs_make_dirbuf(dirbuf_t *dbuf, const char *name, fsnode *node, int needswap)
static void
ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts)
{
- char *buf;
+ char *buf;
struct ufs1_dinode *dp1;
struct ufs2_dinode *dp2, *dip;
struct cg *cgp;
diff --git a/usr.sbin/makefs/ffs.h b/usr.sbin/makefs/ffs.h
index e1dda429ff26..834c5f4424f2 100644
--- a/usr.sbin/makefs/ffs.h
+++ b/usr.sbin/makefs/ffs.h
@@ -35,8 +35,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 _FFS_H
diff --git a/usr.sbin/makefs/ffs/Makefile.inc b/usr.sbin/makefs/ffs/Makefile.inc
index a1e839fd7ab6..0db1750ab282 100644
--- a/usr.sbin/makefs/ffs/Makefile.inc
+++ b/usr.sbin/makefs/ffs/Makefile.inc
@@ -1,9 +1,8 @@
-# $FreeBSD$
-#
-
.PATH: ${SRCDIR}/ffs ${SRCTOP}/sys/ufs/ffs
SRCS+= ffs_alloc.c ffs_balloc.c ffs_bswap.c ffs_subr.c ufs_bmap.c
SRCS+= buf.c mkfs.c
# Reach-over source from sys/ufs/ffs
SRCS+= ffs_tables.c
+
+CWARNFLAGS.ffs_balloc.c+= -Wno-sign-compare
diff --git a/usr.sbin/makefs/ffs/buf.c b/usr.sbin/makefs/ffs/buf.c
index 13f3099c4491..5fdb517208f9 100644
--- a/usr.sbin/makefs/ffs/buf.c
+++ b/usr.sbin/makefs/ffs/buf.c
@@ -37,9 +37,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
@@ -78,7 +75,7 @@ bread(struct m_vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused,
if (lseek((*bpp)->b_fs->fd, offset, SEEK_SET) == -1)
err(1, "%s: lseek %lld (%lld)", __func__,
(long long)(*bpp)->b_blkno, (long long)offset);
- rv = read((*bpp)->b_fs->fd, (*bpp)->b_data, (*bpp)->b_bcount);
+ rv = read((*bpp)->b_fs->fd, (*bpp)->b_data, (size_t)(*bpp)->b_bcount);
if (debug & DEBUG_BUF_BREAD)
printf("%s: read %ld (%lld) returned %d\n", __func__,
(*bpp)->b_bcount, (long long)offset, (int)rv);
@@ -127,26 +124,31 @@ bwrite(struct m_buf *bp)
{
off_t offset;
ssize_t rv;
+ size_t bytes;
+ int e;
fsinfo_t *fs = bp->b_fs;
assert (bp != NULL);
offset = (off_t)bp->b_blkno * fs->sectorsize + fs->offset;
+ bytes = (size_t)bp->b_bcount;
if (debug & DEBUG_BUF_BWRITE)
- printf("bwrite: blkno %lld offset %lld bcount %ld\n",
- (long long)bp->b_blkno, (long long) offset,
- bp->b_bcount);
- if (lseek(bp->b_fs->fd, offset, SEEK_SET) == -1)
+ printf("%s: blkno %lld offset %lld bcount %zu\n", __func__,
+ (long long)bp->b_blkno, (long long) offset, bytes);
+ if (lseek(bp->b_fs->fd, offset, SEEK_SET) == -1) {
+ brelse(bp);
return (errno);
- rv = write(bp->b_fs->fd, bp->b_data, bp->b_bcount);
+ }
+ rv = write(bp->b_fs->fd, bp->b_data, bytes);
+ e = errno;
if (debug & DEBUG_BUF_BWRITE)
- printf("bwrite: write %ld (offset %lld) returned %lld\n",
+ printf("%s: write %ld (offset %lld) returned %lld\n", __func__,
bp->b_bcount, (long long)offset, (long long)rv);
- if (rv == bp->b_bcount)
+ brelse(bp);
+ if (rv == (ssize_t)bytes)
return (0);
- else if (rv == -1) /* write error */
- return (errno);
- else /* short write ? */
- return (EAGAIN);
+ if (rv == -1) /* write error */
+ return (e);
+ return (EAGAIN);
}
void
@@ -163,13 +165,13 @@ bcleanup(void)
if (TAILQ_EMPTY(&buftail))
return;
- printf("bcleanup: unflushed buffers:\n");
+ printf("%s: unflushed buffers:\n", __func__);
TAILQ_FOREACH(bp, &buftail, b_tailq) {
printf("\tlblkno %10lld blkno %10lld count %6ld bufsize %6ld\n",
(long long)bp->b_lblkno, (long long)bp->b_blkno,
bp->b_bcount, bp->b_bufsize);
}
- printf("bcleanup: done\n");
+ printf("%s: done\n", __func__);
}
struct m_buf *
@@ -181,12 +183,13 @@ getblk(struct m_vnode *vp, daddr_t blkno, int size, int u1 __unused,
void *n;
if (debug & DEBUG_BUF_GETBLK)
- printf("getblk: blkno %lld size %d\n", (long long)blkno, size);
+ printf("%s: blkno %lld size %d\n", __func__, (long long)blkno,
+ size);
bp = NULL;
if (!buftailinitted) {
if (debug & DEBUG_BUF_GETBLK)
- printf("getblk: initialising tailq\n");
+ printf("%s: initialising tailq\n", __func__);
TAILQ_INIT(&buftail);
buftailinitted = 1;
} else {
@@ -206,8 +209,8 @@ getblk(struct m_vnode *vp, daddr_t blkno, int size, int u1 __unused,
}
bp->b_bcount = size;
if (bp->b_data == NULL || bp->b_bcount > bp->b_bufsize) {
- n = erealloc(bp->b_data, size);
- memset(n, 0, size);
+ n = erealloc(bp->b_data, (size_t)size);
+ memset(n, 0, (size_t)size);
bp->b_data = n;
bp->b_bufsize = size;
}
diff --git a/usr.sbin/makefs/ffs/buf.h b/usr.sbin/makefs/ffs/buf.h
index 31196b8b2fbe..dfe7edb3e784 100644
--- a/usr.sbin/makefs/ffs/buf.h
+++ b/usr.sbin/makefs/ffs/buf.h
@@ -35,8 +35,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 _FFS_BUF_H
diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c
index ff0e72c56af0..c5aae97928b5 100644
--- a/usr.sbin/makefs/ffs/ffs_alloc.c
+++ b/usr.sbin/makefs/ffs/ffs_alloc.c
@@ -39,13 +39,8 @@
* 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.
- *
- * @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
@@ -305,7 +300,6 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size)
error = bread((void *)ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
(int)fs->fs_cgsize, NULL, &bp);
if (error) {
- brelse(bp);
return (0);
}
cgp = (struct cg *)bp->b_data;
@@ -449,7 +443,6 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size)
error = bread((void *)ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
(int)fs->fs_cgsize, NULL, &bp);
if (error) {
- brelse(bp);
return;
}
cgp = (struct cg *)bp->b_data;
diff --git a/usr.sbin/makefs/ffs/ffs_balloc.c b/usr.sbin/makefs/ffs/ffs_balloc.c
index 275ec4c04471..969a779d0ae8 100644
--- a/usr.sbin/makefs/ffs/ffs_balloc.c
+++ b/usr.sbin/makefs/ffs/ffs_balloc.c
@@ -30,13 +30,8 @@
* 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.
- *
- * @(#)ffs_balloc.c 8.8 (Berkeley) 6/16/95
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
diff --git a/usr.sbin/makefs/ffs/ffs_bswap.c b/usr.sbin/makefs/ffs/ffs_bswap.c
index 43fa60cb0373..50498cb4f259 100644
--- a/usr.sbin/makefs/ffs/ffs_bswap.c
+++ b/usr.sbin/makefs/ffs/ffs_bswap.c
@@ -1,7 +1,7 @@
/* $NetBSD: ffs_bswap.c,v 1.28 2004/05/25 14:54:59 hannken Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Manuel Bouyer.
*
@@ -27,9 +27,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#if defined(_KERNEL)
#include <sys/systm.h>
diff --git a/usr.sbin/makefs/ffs/ffs_extern.h b/usr.sbin/makefs/ffs/ffs_extern.h
index 12ba0b77989c..ac0dafaff860 100644
--- a/usr.sbin/makefs/ffs/ffs_extern.h
+++ b/usr.sbin/makefs/ffs/ffs_extern.h
@@ -30,9 +30,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.
- *
- * @(#)ffs_extern.h 8.6 (Berkeley) 3/30/95
- * $FreeBSD$
*/
#include "ffs/buf.h"
diff --git a/usr.sbin/makefs/ffs/ffs_subr.c b/usr.sbin/makefs/ffs/ffs_subr.c
index 53e5b97ada48..3f5b2297389b 100644
--- a/usr.sbin/makefs/ffs/ffs_subr.c
+++ b/usr.sbin/makefs/ffs/ffs_subr.c
@@ -29,13 +29,8 @@
* 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.
- *
- * @(#)ffs_subr.c 8.5 (Berkeley) 3/21/95
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/types.h>
diff --git a/usr.sbin/makefs/ffs/mkfs.c b/usr.sbin/makefs/ffs/mkfs.c
index 0f8b040d6997..b2f752102a69 100644
--- a/usr.sbin/makefs/ffs/mkfs.c
+++ b/usr.sbin/makefs/ffs/mkfs.c
@@ -40,9 +40,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -80,6 +77,23 @@ static int count_digits(int);
#define UMASK 0755
#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
+/*
+ * The definition of "struct cg" used to contain an extra field at the end
+ * to represent the variable-length data that followed the fixed structure.
+ * This had the effect of artificially limiting the number of blocks that
+ * newfs would put in a CG, since newfs thought that the fixed-size header
+ * was bigger than it really was. When we started validating that the CG
+ * header data actually fit into one fs block, the placeholder field caused
+ * a problem because it caused struct cg to be a different size depending on
+ * platform. The placeholder field was later removed, but this caused a
+ * backward compatibility problem with older binaries that still thought
+ * struct cg was larger, and a new file system could fail validation if
+ * viewed by the older binaries. To avoid this compatibility problem, we
+ * now artificially reduce the amount of space that the variable-length data
+ * can use such that new file systems will pass validation by older binaries.
+ */
+#define CGSIZEFUDGE 8
+
static union {
struct fs fs;
char pad[SBLOCKSIZE];
@@ -347,7 +361,8 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
sblock.fs_fpg = minfpg;
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
INOPB(&sblock));
- if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize)
+ if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize -
+ CGSIZEFUDGE)
break;
density -= sblock.fs_fsize;
}
@@ -366,9 +381,11 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
INOPB(&sblock));
if (sblock.fs_size / sblock.fs_fpg < 1)
break;
- if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize)
+ if (CGSIZE(&sblock) < (unsigned long)sblock.fs_bsize -
+ CGSIZEFUDGE)
continue;
- if (CGSIZE(&sblock) == (unsigned long)sblock.fs_bsize)
+ if (CGSIZE(&sblock) == (unsigned long)sblock.fs_bsize -
+ CGSIZEFUDGE)
break;
sblock.fs_fpg -= sblock.fs_frag;
sblock.fs_ipg = roundup(howmany(sblock.fs_fpg, fragsperinode),
@@ -529,8 +546,9 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
initcg(cylno, tstamp, fsopts);
if (cylno % nprintcols == 0)
printf("\n");
- printf(" %*lld,", printcolwidth,
- (long long)fsbtodb(&sblock, cgsblock(&sblock, cylno)));
+ printf(" %*lld%s", printcolwidth,
+ (long long)fsbtodb(&sblock, cgsblock(&sblock, cylno)),
+ cylno == sblock.fs_ncg - 1 ? "" : ",");
fflush(stdout);
}
printf("\n");
@@ -633,7 +651,7 @@ initcg(uint32_t cylno, time_t utime, const fsinfo_t *fsopts)
acg.cg_ndblk = dmax - cbase;
if (sblock.fs_contigsumsize > 0)
acg.cg_nclusterblks = acg.cg_ndblk >> sblock.fs_fragshift;
- start = &acg.cg_space[0] - (u_char *)(&acg.cg_firstfield);
+ start = sizeof(acg);
if (Oflag == 2) {
acg.cg_iusedoff = start;
} else {
diff --git a/usr.sbin/makefs/ffs/newfs_extern.h b/usr.sbin/makefs/ffs/newfs_extern.h
index 636c86b356f5..82a6337a720a 100644
--- a/usr.sbin/makefs/ffs/newfs_extern.h
+++ b/usr.sbin/makefs/ffs/newfs_extern.h
@@ -2,7 +2,7 @@
/* From: NetBSD: extern.h,v 1.3 2000/12/01 12:03:27 simonb Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
*
@@ -25,8 +25,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$
*/
/* prototypes */
diff --git a/usr.sbin/makefs/ffs/ufs_bmap.c b/usr.sbin/makefs/ffs/ufs_bmap.c
index 196693587da0..1dc644349d3a 100644
--- a/usr.sbin/makefs/ffs/ufs_bmap.c
+++ b/usr.sbin/makefs/ffs/ufs_bmap.c
@@ -35,13 +35,8 @@
* 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.
- *
- * @(#)ufs_bmap.c 8.8 (Berkeley) 8/11/95
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
diff --git a/usr.sbin/makefs/ffs/ufs_bswap.h b/usr.sbin/makefs/ffs/ufs_bswap.h
index 49b96990ccb2..36f9b88a5686 100644
--- a/usr.sbin/makefs/ffs/ufs_bswap.h
+++ b/usr.sbin/makefs/ffs/ufs_bswap.h
@@ -1,7 +1,7 @@
/* $NetBSD: ufs_bswap.h,v 1.13 2003/10/05 17:48:50 bouyer Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Manuel Bouyer.
*
@@ -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$
*/
#ifndef _UFS_UFS_BSWAP_H_
diff --git a/usr.sbin/makefs/ffs/ufs_inode.h b/usr.sbin/makefs/ffs/ufs_inode.h
index 2b30b801b36e..050392624739 100644
--- a/usr.sbin/makefs/ffs/ufs_inode.h
+++ b/usr.sbin/makefs/ffs/ufs_inode.h
@@ -35,9 +35,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.
- *
- * @(#)inode.h 8.9 (Berkeley) 5/14/95
- * $FreeBSD$
*/
union dinode {
@@ -46,7 +43,7 @@ union dinode {
};
struct inode {
- ino_t i_number; /* The identity of the inode. */
+ ino_t i_number; /* The identity of the inode. */
struct vnode *i_devvp; /* vnode pointer (contains fsopts) */
struct fs *i_fs; /* File system */
union dinode i_din;
diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8
index fdf8d532b69f..4601e6278046 100644
--- a/usr.sbin/makefs/makefs.8
+++ b/usr.sbin/makefs/makefs.8
@@ -33,9 +33,8 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd September 17, 2020
+.Dd January 19, 2024
+
.Dt MAKEFS 8
.Os
.Sh NAME
@@ -111,11 +110,18 @@ suffix may be provided to indicate that
indicates a percentage of the calculated image size.
.It Fl D
Treat duplicate paths in an mtree manifest as warnings not error.
+If this flag is specified more than once, warnings about duplicate paths
+are not printed at all.
.It Fl d Ar debug-mask
Enable various levels of debugging, depending upon which bits are
set in
.Ar debug-mask .
-XXX: document these
+This option is intended for source debugging.
+.Ar debug-mask
+is a bit map defined in the header file
+.Ar makefs.h .
+See the source for usage, and look for defines starting with
+.Ar DEBUG_ .
.It Fl F Ar mtree-specfile
.Em This is almost certainly not the option you are looking for.
To create an image from a list of files in an mtree format manifest,
@@ -266,6 +272,8 @@ BSD fast file system (default).
ISO 9660 file system.
.It Sy msdos
FAT12, FAT16, or FAT32 file system.
+.It Sy zfs
+ZFS pool containing one or more file systems.
.El
.It Fl x
Exclude file system nodes not explicitly listed in the specfile.
@@ -365,12 +373,6 @@ version id.
Allow multiple dots in a filename.
.It Sy applicationid
Application ID of the image.
-.It Sy archimedes
-Use the
-.Ql ARCHIMEDES
-extension to encode
-.Tn RISC OS
-metadata.
.It Sy bootimagedir
Boot image directory.
This option is not implemented.
@@ -494,8 +496,95 @@ Volume ID.
.It Cm volume_label
Volume Label.
.El
+.Ss zfs-specific options
+Note: ZFS support is currently considered experimental.
+Do not use it for anything critical.
+.Pp
+The image created by
+.Nm
+contains a ZFS pool with a single vdev of type
+.Ql disk .
+The root dataset is always created implicitly and contains the entire input
+directory tree unless additional datasets are specified using the options
+described below.
+.Pp
+The arguments consist of a keyword, an equal sign
+.Pq Ql = ,
+and a value.
+The following keywords are supported:
+.Pp
+.Bl -tag -width omit-trailing-period -offset indent -compact
+.It ashift
+The base-2 logarithm of the minimum block size.
+Typical values are 9 (512B blocks) and 12 (4KB blocks).
+The default value is 12.
+.It bootfs
+The name of the bootable dataset for the pool.
+Specifying this option causes the
+.Ql bootfs
+property to be set in the created pool.
+.It mssize
+The size of metaslabs in the created pool.
+By default,
+.Nm
+allocates large (up to 512MB) metaslabs with the expectation that
+the image will be auto-expanded upon first use.
+This option allows the default heuristic to be overridden.
+.It poolname
+The name of the ZFS pool.
+This option must be specified.
+.It rootpath
+An implicit path prefix added to dataset mountpoints.
+By default it is
+.Pa /<poolname> .
+For creating bootable pools, the
+.Va rootpath
+should be set to
+.Pa / .
+At least one dataset must have a mountpoint equal to
+.Va rootpath .
+.It fs
+Create an additional dataset.
+This option may be specified multiple times.
+The argument value must be of the form
+.Ar <dataset>[;<prop1=v1>[;<prop2=v2>[;...]]] ,
+where
+.Ar dataset
+is the name of the dataset and must belong to the pool's namespace.
+For example, with a pool name of
+.Ql test
+all dataset names must be prefixed by
+.Ql test/ .
+A dataset must exist at each level of the pool's namespace.
+For example, to create
+.Ql test/foo/bar ,
+.Ql test/foo
+must be created as well.
+.Pp
+The dataset mountpoints determine how the datasets are populated with
+files from the staged directory tree.
+Conceptually, all datasets are mounted before any are populated with files.
+The root of the staged directory tree is mapped to
+.Va rootpath .
+.Pp
+Dataset properties, as described in
+.Xr zfsprops 7 ,
+may be specified following the dataset name.
+The following properties may be set for a dataset:
+.Pp
+.Bl -tag -compact -offset indent
+.It atime
+.It canmount
+.It exec
+.It mountpoint
+.It setuid
+.El
+.El
.Sh SEE ALSO
.Xr mtree 5 ,
+.Xr zfsconcepts 7 ,
+.Xr zfsprops 7 ,
+.Xr zpoolprops 7 ,
.Xr mtree 8 ,
.Xr newfs 8
.Sh HISTORY
@@ -518,4 +607,6 @@ and first appeared in
.An Ram Vedam
(cd9660 support),
.An Christos Zoulas
-(msdos support).
+(msdos support),
+.An Mark Johnston
+(zfs support).
diff --git a/usr.sbin/makefs/makefs.c b/usr.sbin/makefs/makefs.c
index 888a2b3edea7..dbd8f3a4d39e 100644
--- a/usr.sbin/makefs/makefs.c
+++ b/usr.sbin/makefs/makefs.c
@@ -37,9 +37,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -77,6 +74,9 @@ static fstype_t fstypes[] = {
ENTRY(cd9660),
ENTRY(ffs),
ENTRY(msdos),
+#ifdef HAVE_ZFS
+ ENTRY(zfs),
+#endif
{ .type = NULL },
};
@@ -97,7 +97,7 @@ main(int argc, char *argv[])
fstype_t *fstype;
fsinfo_t fsoptions;
fsnode *root;
- int ch, i, len;
+ int ch, i, len;
const char *subtree;
const char *specfile;
@@ -164,7 +164,7 @@ main(int argc, char *argv[])
break;
case 'D':
- dupsok = 1;
+ dupsok++;
break;
case 'd':
@@ -270,7 +270,6 @@ main(int argc, char *argv[])
fsoptions.sparse = 1;
break;
- case '?':
default:
usage(fstype, &fsoptions);
/* NOTREACHED */
diff --git a/usr.sbin/makefs/makefs.h b/usr.sbin/makefs/makefs.h
index 68dc0362dd21..db0addc4bc94 100644
--- a/usr.sbin/makefs/makefs.h
+++ b/usr.sbin/makefs/makefs.h
@@ -35,8 +35,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 _MAKEFS_H
@@ -58,7 +56,7 @@
*
* name "." "bin" "netbsd"
* type S_IFDIR S_IFDIR S_IFREG
- * next > > NULL
+ * next > > NULL
* parent NULL NULL NULL
* child NULL v
*
@@ -78,12 +76,14 @@ enum fi_flags {
FI_SIZED = 1<<0, /* inode sized */
FI_ALLOCATED = 1<<1, /* fsinode->ino allocated */
FI_WRITTEN = 1<<2, /* inode written */
+ FI_ROOT = 1<<3, /* root of a ZFS dataset */
};
typedef struct {
uint32_t ino; /* inode number used on target fs */
uint32_t nlink; /* number of links to this entry */
enum fi_flags flags; /* flags used by fs specific code */
+ void *param; /* for use by individual fs impls */
struct stat st; /* stat entry */
} fsinode;
@@ -186,6 +186,9 @@ void fs ## _makefs(const char *, const char *, fsnode *, fsinfo_t *)
DECLARE_FUN(cd9660);
DECLARE_FUN(ffs);
DECLARE_FUN(msdos);
+#ifdef HAVE_ZFS
+DECLARE_FUN(zfs);
+#endif
extern u_int debug;
extern int dupsok;
diff --git a/usr.sbin/makefs/msdos.c b/usr.sbin/makefs/msdos.c
index ec38c1d207dd..3707481a1c47 100644
--- a/usr.sbin/makefs/msdos.c
+++ b/usr.sbin/makefs/msdos.c
@@ -32,11 +32,6 @@
#include "nbtool_config.h"
#endif
-#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(__lint)
-__FBSDID("$FreeBSD$");
-#endif /* !__lint */
-
#include <sys/param.h>
#if !HAVE_NBTOOL_CONFIG_H
diff --git a/usr.sbin/makefs/msdos.h b/usr.sbin/makefs/msdos.h
index ea78e49648a3..376713051d52 100644
--- a/usr.sbin/makefs/msdos.h
+++ b/usr.sbin/makefs/msdos.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $NetBSD: msdos.h,v 1.3 2015/10/16 16:40:02 christos Exp $ */
/*-
diff --git a/usr.sbin/makefs/msdos/Makefile.inc b/usr.sbin/makefs/msdos/Makefile.inc
index fa3890d8393b..78ddc7804b31 100644
--- a/usr.sbin/makefs/msdos/Makefile.inc
+++ b/usr.sbin/makefs/msdos/Makefile.inc
@@ -1,6 +1,3 @@
-# $FreeBSD$
-#
-
MSDOS= ${SRCTOP}/sys/fs/msdosfs
MSDOS_NEWFS= ${SRCTOP}/sbin/newfs_msdos
diff --git a/usr.sbin/makefs/msdos/direntry.h b/usr.sbin/makefs/msdos/direntry.h
index 9cc601d5e96c..9d6c65dfcc7d 100644
--- a/usr.sbin/makefs/msdos/direntry.h
+++ b/usr.sbin/makefs/msdos/direntry.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $NetBSD: direntry.h,v 1.14 1997/11/17 15:36:32 ws Exp $ */
/*-
diff --git a/usr.sbin/makefs/msdos/msdosfs_conv.c b/usr.sbin/makefs/msdos/msdosfs_conv.c
index b53656d3b439..cacaa4a49a2c 100644
--- a/usr.sbin/makefs/msdos/msdosfs_conv.c
+++ b/usr.sbin/makefs/msdos/msdosfs_conv.c
@@ -47,9 +47,6 @@
* October 1992
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/endian.h>
diff --git a/usr.sbin/makefs/msdos/msdosfs_denode.c b/usr.sbin/makefs/msdos/msdosfs_denode.c
index ff706ad99563..88e90ab87c7e 100644
--- a/usr.sbin/makefs/msdos/msdosfs_denode.c
+++ b/usr.sbin/makefs/msdos/msdosfs_denode.c
@@ -49,9 +49,6 @@
* October 1992
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
diff --git a/usr.sbin/makefs/msdos/msdosfs_fat.c b/usr.sbin/makefs/msdos/msdosfs_fat.c
index 0081e2d2d38c..e00ce9ef7b97 100644
--- a/usr.sbin/makefs/msdos/msdosfs_fat.c
+++ b/usr.sbin/makefs/msdos/msdosfs_fat.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $NetBSD: msdosfs_fat.c,v 1.28 1997/11/17 15:36:49 ws Exp $ */
/*-
@@ -135,7 +134,7 @@ pcbmap(struct denode *dep, u_long findcn, daddr_t *bnp, u_long *cnp, int *sp)
int error;
u_long i;
u_long cn;
- u_long prevcn = 0; /* XXX: prevcn could be used unititialized */
+ u_long prevcn = 0; /* XXX: prevcn could be used uninitialized */
u_long byteoffset;
u_long bn;
u_long bo;
@@ -668,7 +667,7 @@ chainlength(struct msdosfsmount *pmp, u_long start, u_long count)
}
/*
- * Allocate contigous free clusters.
+ * Allocate contiguous free clusters.
*
* pmp - mount point.
* start - start of cluster chain.
@@ -737,7 +736,7 @@ clusteralloc1(struct msdosfsmount *pmp, u_long start, u_long count,
{
u_long idx;
u_long len, newst, foundl, cn, l;
- u_long foundcn = 0; /* XXX: foundcn could be used unititialized */
+ u_long foundcn = 0; /* XXX: foundcn could be used uninitialized */
u_int map;
MSDOSFS_DPRINTF(("clusteralloc(): find %lu clusters\n", count));
diff --git a/usr.sbin/makefs/msdos/msdosfs_lookup.c b/usr.sbin/makefs/msdos/msdosfs_lookup.c
index fb2f4deceaf2..80bab768959d 100644
--- a/usr.sbin/makefs/msdos/msdosfs_lookup.c
+++ b/usr.sbin/makefs/msdos/msdosfs_lookup.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $NetBSD: msdosfs_lookup.c,v 1.37 1997/11/17 15:36:54 ws Exp $ */
/*-
@@ -125,7 +124,6 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp,
diroffset &= pmp->pm_crbomask;
if ((error = bread((void *)pmp->pm_devvp, bn, blsize, NOCRED,
&bp)) != 0) {
- brelse(bp);
return error;
}
ndep = bptoep(pmp, bp, ddep->de_fndoffset);
@@ -157,7 +155,6 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp,
error = bread((void *)pmp->pm_devvp, bn, blsize,
NOCRED, &bp);
if (error) {
- brelse(bp);
return error;
}
ndep = bptoep(pmp, bp, ddep->de_fndoffset);
@@ -213,7 +210,6 @@ m_readep(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset,
bn = detobn(pmp, dirclust, diroffset);
if ((error = bread((void *)pmp->pm_devvp, bn, blsize, NOCRED,
bpp)) != 0) {
- brelse(*bpp);
*bpp = NULL;
return (error);
}
@@ -274,7 +270,6 @@ uniqdosname(struct denode *dep, struct componentname *cnp, u_char *cp)
error = bread((void *)pmp->pm_devvp, bn, blsize,
NOCRED, &bp);
if (error) {
- brelse(bp);
return error;
}
for (dentp = (struct direntry *)bp->b_data;
diff --git a/usr.sbin/makefs/msdos/msdosfs_vfsops.c b/usr.sbin/makefs/msdos/msdosfs_vfsops.c
index d543adc2bbcd..8b5eac4a4b66 100644
--- a/usr.sbin/makefs/msdos/msdosfs_vfsops.c
+++ b/usr.sbin/makefs/msdos/msdosfs_vfsops.c
@@ -49,8 +49,6 @@
#include <sys/cdefs.h>
/* $NetBSD: msdosfs_vfsops.c,v 1.10 2016/01/30 09:59:27 mlelstv Exp $ */
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/mount.h>
diff --git a/usr.sbin/makefs/msdos/msdosfs_vnops.c b/usr.sbin/makefs/msdos/msdosfs_vnops.c
index 5bc9b495c586..ae1fa3f7bf75 100644
--- a/usr.sbin/makefs/msdos/msdosfs_vnops.c
+++ b/usr.sbin/makefs/msdos/msdosfs_vnops.c
@@ -49,9 +49,6 @@
* October 1992
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/mman.h>
diff --git a/usr.sbin/makefs/mtree.c b/usr.sbin/makefs/mtree.c
index 4272299ce135..fddc32b85322 100644
--- a/usr.sbin/makefs/mtree.c
+++ b/usr.sbin/makefs/mtree.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 Marcel Moolenaar
* All rights reserved.
@@ -29,9 +29,6 @@
#include "nbtool_config.h"
#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/sbuf.h>
@@ -742,7 +739,10 @@ read_mtree_keywords(FILE *fp, fsnode *node)
type = S_IFREG;
} else if (node->type != 0) {
type = node->type;
- if (type == S_IFREG) {
+ if (type == S_IFLNK && node->symlink == NULL) {
+ mtree_error("%s: link type requires link keyword", node->name);
+ return (0);
+ } else if (type == S_IFREG) {
/* the named path is the default contents */
node->contents = mtree_file_path(node);
}
@@ -836,7 +836,7 @@ read_mtree_spec1(FILE *fp, bool def, const char *name)
* not the '.' node of the parent directory, but the directory
* node within the parent to which the child relates. However,
* going up a directory means we need to find the '.' node to
- * which the directoy node is linked. This we can do via the
+ * which the directory node is linked. This we can do via the
* first * pointer, because '.' is always the first entry in a
* directory.
*/
@@ -894,11 +894,11 @@ read_mtree_spec1(FILE *fp, bool def, const char *name)
if (strcmp(name, node->name) == 0) {
if (def == true) {
- if (!dupsok)
+ if (dupsok == 0)
mtree_error(
"duplicate definition of %s",
name);
- else
+ else if (dupsok == 1)
mtree_warning(
"duplicate definition of %s",
name);
@@ -1016,7 +1016,7 @@ read_mtree_spec(FILE *fp)
}
}
- /* Ignore absolute specfications that end with a slash. */
+ /* Ignore absolute specifications that end with a slash. */
if (!error && pathspec[0] != '\0')
error = read_mtree_spec1(fp, true, pathspec);
diff --git a/usr.sbin/makefs/tests/Makefile b/usr.sbin/makefs/tests/Makefile
index 85e4b233aea7..98cc89031c64 100644
--- a/usr.sbin/makefs/tests/Makefile
+++ b/usr.sbin/makefs/tests/Makefile
@@ -1,7 +1,16 @@
-# $FreeBSD$
+
+.include <src.opts.mk>
ATF_TESTS_SH+= makefs_cd9660_tests
+TEST_METADATA.makefs_cd9660_tests+= required_files="/sbin/mount_cd9660"
ATF_TESTS_SH+= makefs_ffs_tests
+.if ${MK_ZFS} != "no"
+ATF_TESTS_SH+= makefs_zfs_tests
+# ZFS pools created by makefs always have the same GUID, so OpenZFS
+# refuses to import more than one at a time. Thus the ZFS tests cannot
+# be run in parallel for now.
+TEST_METADATA.makefs_zfs_tests+= is_exclusive="true"
+.endif
BINDIR= ${TESTSDIR}
@@ -9,8 +18,6 @@ BINDIR= ${TESTSDIR}
SCRIPTS+= makefs_tests_common.sh
SCRIPTSNAME_makefs_tests_common.sh= makefs_tests_common.sh
-TEST_METADATA.makefs_cd9660_tests+= required_files="/sbin/mount_cd9660"
-
.for t in ${ATF_TESTS_SH}
TEST_METADATA.$t+= required_user="root"
.endfor
diff --git a/usr.sbin/makefs/tests/Makefile.depend b/usr.sbin/makefs/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/makefs/tests/Makefile.depend
+++ b/usr.sbin/makefs/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/makefs/tests/makefs_cd9660_tests.sh b/usr.sbin/makefs/tests/makefs_cd9660_tests.sh
index 8a3ac1684032..2fdf47f76a4c 100644
--- a/usr.sbin/makefs/tests/makefs_cd9660_tests.sh
+++ b/usr.sbin/makefs/tests/makefs_cd9660_tests.sh
@@ -23,9 +23,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$
-#
# A note on specs:
# - A copy of the ISO-9660 spec can be found here:
diff --git a/usr.sbin/makefs/tests/makefs_ffs_tests.sh b/usr.sbin/makefs/tests/makefs_ffs_tests.sh
index 1a415cb5f518..2505b2e24d72 100644
--- a/usr.sbin/makefs/tests/makefs_ffs_tests.sh
+++ b/usr.sbin/makefs/tests/makefs_ffs_tests.sh
@@ -23,9 +23,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$
-#
MAKEFS="makefs -t ffs"
MOUNT="mount"
diff --git a/usr.sbin/makefs/tests/makefs_tests_common.sh b/usr.sbin/makefs/tests/makefs_tests_common.sh
index 5eb4ee5bf9f5..12c7c7c84fb7 100644
--- a/usr.sbin/makefs/tests/makefs_tests_common.sh
+++ b/usr.sbin/makefs/tests/makefs_tests_common.sh
@@ -23,9 +23,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$
-#
KB=1024
: ${TMPDIR=/tmp}
diff --git a/usr.sbin/makefs/tests/makefs_zfs_tests.sh b/usr.sbin/makefs/tests/makefs_zfs_tests.sh
new file mode 100644
index 000000000000..6e20ae33b354
--- /dev/null
+++ b/usr.sbin/makefs/tests/makefs_zfs_tests.sh
@@ -0,0 +1,868 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2022-2023 The FreeBSD Foundation
+#
+# This software was developed by Mark Johnston under sponsorship from
+# the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+MAKEFS="makefs -t zfs -o nowarn=true"
+ZFS_POOL_NAME="makefstest$$"
+TEST_ZFS_POOL_NAME="$TMPDIR/poolname"
+
+. "$(dirname "$0")/makefs_tests_common.sh"
+
+common_cleanup()
+{
+ local pool md
+
+ # Try to force a TXG, this can help catch bugs by triggering a panic.
+ sync
+
+ pool=$(cat $TEST_ZFS_POOL_NAME)
+ if zpool list "$pool" >/dev/null; then
+ zpool destroy "$pool"
+ fi
+
+ md=$(cat $TEST_MD_DEVICE_FILE)
+ if [ -c /dev/"$md" ]; then
+ mdconfig -d -u "$md"
+ fi
+}
+
+import_image()
+{
+ atf_check -e empty -o save:$TEST_MD_DEVICE_FILE -s exit:0 \
+ mdconfig -a -f $TEST_IMAGE
+ atf_check -o ignore -e empty -s exit:0 \
+ zdb -e -p /dev/$(cat $TEST_MD_DEVICE_FILE) -mmm -ddddd $ZFS_POOL_NAME
+ atf_check zpool import -R $TEST_MOUNT_DIR $ZFS_POOL_NAME
+ echo "$ZFS_POOL_NAME" > $TEST_ZFS_POOL_NAME
+}
+
+#
+# Test autoexpansion of the vdev.
+#
+# The pool is initially 10GB, so we get 10GB minus one metaslab's worth of
+# usable space for data. Then the pool is expanded to 50GB, and the amount of
+# usable space is 50GB minus one metaslab.
+#
+atf_test_case autoexpand cleanup
+autoexpand_body()
+{
+ local mssize poolsize poolsize1 newpoolsize
+
+ create_test_inputs
+
+ mssize=$((128 * 1024 * 1024))
+ poolsize=$((10 * 1024 * 1024 * 1024))
+ atf_check $MAKEFS -s $poolsize -o mssize=$mssize -o rootpath=/ \
+ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ newpoolsize=$((50 * 1024 * 1024 * 1024))
+ truncate -s $newpoolsize $TEST_IMAGE
+
+ import_image
+
+ check_image_contents
+
+ poolsize1=$(zpool list -Hp -o size $ZFS_POOL_NAME)
+ atf_check [ $((poolsize1 + $mssize)) -eq $poolsize ]
+
+ atf_check zpool online -e $ZFS_POOL_NAME /dev/$(cat $TEST_MD_DEVICE_FILE)
+
+ check_image_contents
+
+ poolsize1=$(zpool list -Hp -o size $ZFS_POOL_NAME)
+ atf_check [ $((poolsize1 + $mssize)) -eq $newpoolsize ]
+}
+autoexpand_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Test with some default layout defined by the common code.
+#
+atf_test_case basic cleanup
+basic_body()
+{
+ create_test_inputs
+
+ atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+}
+basic_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case dataset_removal cleanup
+dataset_removal_body()
+{
+ create_test_dirs
+
+ cd $TEST_INPUTS_DIR
+ mkdir dir
+ cd -
+
+ atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ -o fs=${ZFS_POOL_NAME}/dir \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+
+ atf_check zfs destroy ${ZFS_POOL_NAME}/dir
+}
+dataset_removal_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Make sure that we can create and remove an empty directory.
+#
+atf_test_case empty_dir cleanup
+empty_dir_body()
+{
+ create_test_dirs
+
+ cd $TEST_INPUTS_DIR
+ mkdir dir
+ cd -
+
+ atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+
+ atf_check rmdir ${TEST_MOUNT_DIR}/dir
+}
+empty_dir_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case empty_fs cleanup
+empty_fs_body()
+{
+ create_test_dirs
+
+ atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+}
+empty_fs_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case file_extend cleanup
+file_extend_body()
+{
+ local i start
+
+ create_test_dirs
+
+ # Create a file slightly longer than the maximum block size.
+ start=132
+ dd if=/dev/random of=${TEST_INPUTS_DIR}/foo bs=1k count=$start
+ md5 -q ${TEST_INPUTS_DIR}/foo > foo.md5
+
+ atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+
+ i=0
+ while [ $i -lt 1000 ]; do
+ dd if=/dev/random of=${TEST_MOUNT_DIR}/foo bs=1k count=1 \
+ seek=$(($i + $start)) conv=notrunc
+ # Make sure that the first $start blocks are unmodified.
+ dd if=${TEST_MOUNT_DIR}/foo bs=1k count=$start of=foo.copy
+ atf_check -o file:foo.md5 md5 -q foo.copy
+ i=$(($i + 1))
+ done
+}
+file_extend_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case file_sizes cleanup
+file_sizes_body()
+{
+ local i
+
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ i=1
+ while [ $i -lt $((1 << 20)) ]; do
+ truncate -s $i ${i}.1
+ truncate -s $(($i - 1)) ${i}.2
+ truncate -s $(($i + 1)) ${i}.3
+ i=$(($i << 1))
+ done
+
+ cd -
+
+ # XXXMJ this creates sparse files, make sure makefs doesn't
+ # preserve the sparseness.
+ # XXXMJ need to test with larger files (at least 128MB for L2 indirs)
+ atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+}
+file_sizes_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case hard_links cleanup
+hard_links_body()
+{
+ local f
+
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ mkdir dir
+ echo "hello" > 1
+ ln 1 2
+ ln 1 dir/1
+
+ echo "goodbye" > dir/a
+ ln dir/a dir/b
+ ln dir/a a
+
+ cd -
+
+ atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+
+ stat -f '%i' ${TEST_MOUNT_DIR}/1 > ./ino
+ stat -f '%l' ${TEST_MOUNT_DIR}/1 > ./nlink
+ for f in 1 2 dir/1; do
+ atf_check -o file:./nlink -e empty -s exit:0 \
+ stat -f '%l' ${TEST_MOUNT_DIR}/${f}
+ atf_check -o file:./ino -e empty -s exit:0 \
+ stat -f '%i' ${TEST_MOUNT_DIR}/${f}
+ atf_check cmp -s ${TEST_INPUTS_DIR}/1 ${TEST_MOUNT_DIR}/${f}
+ done
+
+ stat -f '%i' ${TEST_MOUNT_DIR}/dir/a > ./ino
+ stat -f '%l' ${TEST_MOUNT_DIR}/dir/a > ./nlink
+ for f in dir/a dir/b a; do
+ atf_check -o file:./nlink -e empty -s exit:0 \
+ stat -f '%l' ${TEST_MOUNT_DIR}/${f}
+ atf_check -o file:./ino -e empty -s exit:0 \
+ stat -f '%i' ${TEST_MOUNT_DIR}/${f}
+ atf_check cmp -s ${TEST_INPUTS_DIR}/dir/a ${TEST_MOUNT_DIR}/${f}
+ done
+}
+hard_links_cleanup()
+{
+ common_cleanup
+}
+
+# Allocate enough dnodes from an object set that the meta dnode needs to use
+# indirect blocks.
+atf_test_case indirect_dnode_array cleanup
+indirect_dnode_array_body()
+{
+ local count i
+
+ # How many dnodes do we need to allocate? Well, the data block size
+ # for meta dnodes is always 16KB, so with a dnode size of 512B we get
+ # 32 dnodes per direct block. The maximum indirect block size is 128KB
+ # and that can fit 1024 block pointers, so we need at least 32 * 1024
+ # files to force the use of two levels of indirection.
+ #
+ # Unfortunately that number of files makes the test run quite slowly,
+ # so we settle for a single indirect block for now...
+ count=$(jot -r 1 32 1024)
+
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+ for i in $(seq 1 $count); do
+ touch $i
+ done
+ cd -
+
+ atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+}
+indirect_dnode_array_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Create some files with long names, so as to test fat ZAP handling.
+#
+atf_test_case long_file_name cleanup
+long_file_name_body()
+{
+ local dir i
+
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ # micro ZAP keys can be at most 50 bytes.
+ for i in $(seq 1 60); do
+ touch $(jot -s '' $i 1 1)
+ done
+ dir=$(jot -s '' 61 1 1)
+ mkdir $dir
+ for i in $(seq 1 60); do
+ touch ${dir}/$(jot -s '' $i 1 1)
+ done
+
+ cd -
+
+ atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+
+ # Add a directory entry in the hope that OpenZFS might catch a bug
+ # in makefs' fat ZAP encoding.
+ touch ${TEST_MOUNT_DIR}/foo
+}
+long_file_name_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Exercise handling of multiple datasets.
+#
+atf_test_case multi_dataset_1 cleanup
+multi_dataset_1_body()
+{
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ mkdir dir1
+ echo a > dir1/a
+ mkdir dir2
+ echo b > dir2/b
+
+ cd -
+
+ atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ -o fs=${ZFS_POOL_NAME}/dir1 -o fs=${ZFS_POOL_NAME}/dir2 \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+
+ # Make sure that we have three datasets with the expected mount points.
+ atf_check -o inline:${ZFS_POOL_NAME}\\n -e empty -s exit:0 \
+ zfs list -H -o name ${ZFS_POOL_NAME}
+ atf_check -o inline:${TEST_MOUNT_DIR}\\n -e empty -s exit:0 \
+ zfs list -H -o mountpoint ${ZFS_POOL_NAME}
+
+ atf_check -o inline:${ZFS_POOL_NAME}/dir1\\n -e empty -s exit:0 \
+ zfs list -H -o name ${ZFS_POOL_NAME}/dir1
+ atf_check -o inline:${TEST_MOUNT_DIR}/dir1\\n -e empty -s exit:0 \
+ zfs list -H -o mountpoint ${ZFS_POOL_NAME}/dir1
+
+ atf_check -o inline:${ZFS_POOL_NAME}/dir2\\n -e empty -s exit:0 \
+ zfs list -H -o name ${ZFS_POOL_NAME}/dir2
+ atf_check -o inline:${TEST_MOUNT_DIR}/dir2\\n -e empty -s exit:0 \
+ zfs list -H -o mountpoint ${ZFS_POOL_NAME}/dir2
+}
+multi_dataset_1_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Create a pool with two datasets, where the root dataset is mounted below
+# the child dataset.
+#
+atf_test_case multi_dataset_2 cleanup
+multi_dataset_2_body()
+{
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ mkdir dir1
+ echo a > dir1/a
+ mkdir dir2
+ echo b > dir2/b
+
+ cd -
+
+ atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ -o fs=${ZFS_POOL_NAME}/dir1\;mountpoint=/ \
+ -o fs=${ZFS_POOL_NAME}\;mountpoint=/dir1 \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+}
+multi_dataset_2_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Create a dataset with a non-existent mount point.
+#
+atf_test_case multi_dataset_3 cleanup
+multi_dataset_3_body()
+{
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ mkdir dir1
+ echo a > dir1/a
+
+ cd -
+
+ atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ -o fs=${ZFS_POOL_NAME}/dir1 \
+ -o fs=${ZFS_POOL_NAME}/dir2 \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ atf_check -o inline:${TEST_MOUNT_DIR}/dir2\\n -e empty -s exit:0 \
+ zfs list -H -o mountpoint ${ZFS_POOL_NAME}/dir2
+
+ # Mounting dir2 should have created a directory called dir2. Go
+ # back and create it in the staging tree before comparing.
+ atf_check mkdir ${TEST_INPUTS_DIR}/dir2
+
+ check_image_contents
+}
+multi_dataset_3_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Create an unmounted dataset.
+#
+atf_test_case multi_dataset_4 cleanup
+multi_dataset_4_body()
+{
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ mkdir dir1
+ echo a > dir1/a
+
+ cd -
+
+ atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ -o fs=${ZFS_POOL_NAME}/dir1\;canmount=noauto\;mountpoint=none \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ atf_check -o inline:none\\n -e empty -s exit:0 \
+ zfs list -H -o mountpoint ${ZFS_POOL_NAME}/dir1
+
+ check_image_contents
+
+ atf_check zfs set mountpoint=/dir1 ${ZFS_POOL_NAME}/dir1
+ atf_check zfs mount ${ZFS_POOL_NAME}/dir1
+ atf_check -o inline:${TEST_MOUNT_DIR}/dir1\\n -e empty -s exit:0 \
+ zfs list -H -o mountpoint ${ZFS_POOL_NAME}/dir1
+
+ # dir1/a should be part of the root dataset, not dir1.
+ atf_check -s not-exit:0 -e not-empty stat ${TEST_MOUNT_DIR}dir1/a
+}
+multi_dataset_4_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Validate handling of multiple staging directories.
+#
+atf_test_case multi_staging_1 cleanup
+multi_staging_1_body()
+{
+ local tmpdir
+
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ mkdir dir1
+ echo a > a
+ echo a > dir1/a
+ echo z > z
+
+ cd -
+
+ tmpdir=$(mktemp -d)
+ cd $tmpdir
+
+ mkdir dir2 dir2/dir3
+ echo b > dir2/b
+ echo c > dir2/dir3/c
+ ln -s dir2/dir3c s
+
+ cd -
+
+ atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE ${TEST_INPUTS_DIR} $tmpdir
+
+ import_image
+
+ check_image_contents -d $tmpdir
+}
+multi_staging_1_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case multi_staging_2 cleanup
+multi_staging_2_body()
+{
+ local tmpdir
+
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ mkdir dir
+ echo a > dir/foo
+ echo b > dir/bar
+
+ cd -
+
+ tmpdir=$(mktemp -d)
+ cd $tmpdir
+
+ mkdir dir
+ echo c > dir/baz
+
+ cd -
+
+ atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE ${TEST_INPUTS_DIR} $tmpdir
+
+ import_image
+
+ # check_image_contents can't easily handle merged directories, so
+ # just check that the merged directory contains the files we expect.
+ atf_check -o not-empty stat ${TEST_MOUNT_DIR}/dir/foo
+ atf_check -o not-empty stat ${TEST_MOUNT_DIR}/dir/bar
+ atf_check -o not-empty stat ${TEST_MOUNT_DIR}/dir/baz
+
+ if [ "$(ls ${TEST_MOUNT_DIR}/dir | wc -l)" -ne 3 ]; then
+ atf_fail "Expected 3 files in ${TEST_MOUNT_DIR}/dir"
+ fi
+}
+multi_staging_2_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Rudimentary test to verify that two ZFS images created using the same
+# parameters and input hierarchy are byte-identical. In particular, makefs(1)
+# does not preserve file access times.
+#
+atf_test_case reproducible cleanup
+reproducible_body()
+{
+ create_test_inputs
+
+ atf_check $MAKEFS -s 512m -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ ${TEST_IMAGE}.1 $TEST_INPUTS_DIR
+
+ atf_check $MAKEFS -s 512m -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ ${TEST_IMAGE}.2 $TEST_INPUTS_DIR
+
+ # XXX-MJ cmp(1) is really slow
+ atf_check cmp ${TEST_IMAGE}.1 ${TEST_IMAGE}.2
+}
+reproducible_cleanup()
+{
+}
+
+#
+# Verify that we can take a snapshot of a generated dataset.
+#
+atf_test_case snapshot cleanup
+snapshot_body()
+{
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ mkdir dir
+ echo "hello" > dir/hello
+ echo "goodbye" > goodbye
+
+ cd -
+
+ atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ atf_check zfs snapshot ${ZFS_POOL_NAME}@1
+}
+snapshot_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Check handling of symbolic links.
+#
+atf_test_case soft_links cleanup
+soft_links_body()
+{
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ mkdir dir
+ ln -s a a
+ ln -s dir/../a a
+ ln -s dir/b b
+ echo 'c' > dir
+ ln -s dir/c c
+ # XXX-MJ overflows bonus buffer ln -s $(jot -s '' 320 1 1) 1
+
+ cd -
+
+ atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+}
+soft_links_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Verify that we can set properties on the root dataset.
+#
+atf_test_case root_props cleanup
+root_props_body()
+{
+ create_test_inputs
+
+ atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ -o fs=${ZFS_POOL_NAME}\;atime=off\;setuid=off \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+
+ atf_check -o inline:off\\n -e empty -s exit:0 \
+ zfs get -H -o value atime $ZFS_POOL_NAME
+ atf_check -o inline:local\\n -e empty -s exit:0 \
+ zfs get -H -o source atime $ZFS_POOL_NAME
+ atf_check -o inline:off\\n -e empty -s exit:0 \
+ zfs get -H -o value setuid $ZFS_POOL_NAME
+ atf_check -o inline:local\\n -e empty -s exit:0 \
+ zfs get -H -o source setuid $ZFS_POOL_NAME
+}
+root_props_cleanup()
+{
+ common_cleanup
+}
+
+#
+# Verify that usedds and usedchild props are set properly.
+#
+atf_test_case used_space_props cleanup
+used_space_props_body()
+{
+ local used usedds usedchild
+ local rootmb childmb totalmb fudge
+ local status
+
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+ mkdir dir
+
+ rootmb=17
+ childmb=39
+ totalmb=$(($rootmb + $childmb))
+ fudge=$((2 * 1024 * 1024))
+
+ atf_check -e ignore dd if=/dev/random of=foo bs=1M count=$rootmb
+ atf_check -e ignore dd if=/dev/random of=dir/bar bs=1M count=$childmb
+
+ cd -
+
+ atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ -o fs=${ZFS_POOL_NAME}/dir \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ # Make sure that each dataset's space usage is no more than 2MB larger
+ # than their files. This number is magic and might need to change
+ # someday.
+ usedds=$(zfs list -o usedds -Hp ${ZFS_POOL_NAME})
+ atf_check test $usedds -gt $(($rootmb * 1024 * 1024)) -a \
+ $usedds -le $(($rootmb * 1024 * 1024 + $fudge))
+ usedds=$(zfs list -o usedds -Hp ${ZFS_POOL_NAME}/dir)
+ atf_check test $usedds -gt $(($childmb * 1024 * 1024)) -a \
+ $usedds -le $(($childmb * 1024 * 1024 + $fudge))
+
+ # Make sure that the usedchild property value makes sense: the parent's
+ # value corresponds to the size of the child, and the child has no
+ # children.
+ usedchild=$(zfs list -o usedchild -Hp ${ZFS_POOL_NAME})
+ atf_check test $usedchild -gt $(($childmb * 1024 * 1024)) -a \
+ $usedchild -le $(($childmb * 1024 * 1024 + $fudge))
+ atf_check -o inline:'0\n' \
+ zfs list -Hp -o usedchild ${ZFS_POOL_NAME}/dir
+
+ # Make sure that the used property value makes sense: the parent's
+ # value is the sum of the two sizes, and the child's value is the
+ # same as its usedds value, which has already been checked.
+ used=$(zfs list -o used -Hp ${ZFS_POOL_NAME})
+ atf_check test $used -gt $(($totalmb * 1024 * 1024)) -a \
+ $used -le $(($totalmb * 1024 * 1024 + 2 * $fudge))
+ used=$(zfs list -o used -Hp ${ZFS_POOL_NAME}/dir)
+ atf_check -o inline:$used'\n' \
+ zfs list -Hp -o usedds ${ZFS_POOL_NAME}/dir
+
+ # Both datasets do not have snapshots.
+ atf_check -o inline:'0\n' zfs list -Hp -o usedsnap ${ZFS_POOL_NAME}
+ atf_check -o inline:'0\n' zfs list -Hp -o usedsnap ${ZFS_POOL_NAME}/dir
+}
+used_space_props_cleanup()
+{
+ common_cleanup
+}
+
+# Verify that file permissions are set properly. Make sure that non-executable
+# files can't be executed.
+atf_test_case perms cleanup
+perms_body()
+{
+ local mode
+
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ for mode in $(seq 0 511); do
+ mode=$(printf "%04o\n" $mode)
+ echo 'echo a' > $mode
+ atf_check chmod $mode $mode
+ done
+
+ cd -
+
+ atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+
+ for mode in $(seq 0 511); do
+ mode=$(printf "%04o\n" $mode)
+ if [ $(($mode & 0111)) -eq 0 ]; then
+ atf_check -s not-exit:0 -e match:"Permission denied" \
+ ${TEST_INPUTS_DIR}/$mode
+ fi
+ if [ $(($mode & 0001)) -eq 0 ]; then
+ atf_check -s not-exit:0 -e match:"Permission denied" \
+ su -m tests -c ${TEST_INPUTS_DIR}/$mode
+ fi
+ done
+
+}
+perms_cleanup()
+{
+ common_cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case autoexpand
+ atf_add_test_case basic
+ atf_add_test_case dataset_removal
+ atf_add_test_case empty_dir
+ atf_add_test_case empty_fs
+ atf_add_test_case file_extend
+ atf_add_test_case file_sizes
+ atf_add_test_case hard_links
+ atf_add_test_case indirect_dnode_array
+ atf_add_test_case long_file_name
+ atf_add_test_case multi_dataset_1
+ atf_add_test_case multi_dataset_2
+ atf_add_test_case multi_dataset_3
+ atf_add_test_case multi_dataset_4
+ atf_add_test_case multi_staging_1
+ atf_add_test_case multi_staging_2
+ atf_add_test_case reproducible
+ atf_add_test_case snapshot
+ atf_add_test_case soft_links
+ atf_add_test_case root_props
+ atf_add_test_case used_space_props
+ atf_add_test_case perms
+
+ # XXXMJ tests:
+ # - test with different ashifts (at least, 9 and 12), different image sizes
+ # - create datasets in imported pool
+}
diff --git a/usr.sbin/makefs/walk.c b/usr.sbin/makefs/walk.c
index 79b68d1d3e19..401865229957 100644
--- a/usr.sbin/makefs/walk.c
+++ b/usr.sbin/makefs/walk.c
@@ -37,10 +37,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
diff --git a/usr.sbin/makefs/zfs.c b/usr.sbin/makefs/zfs.c
new file mode 100644
index 000000000000..b16a48564f04
--- /dev/null
+++ b/usr.sbin/makefs/zfs.c
@@ -0,0 +1,797 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 The FreeBSD Foundation
+ *
+ * This software was developed by Mark Johnston under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/errno.h>
+#include <sys/queue.h>
+
+#include <assert.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <stdalign.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <util.h>
+
+#include "makefs.h"
+#include "zfs.h"
+
+#define VDEV_LABEL_SPACE \
+ ((off_t)(VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE))
+_Static_assert(VDEV_LABEL_SPACE <= MINDEVSIZE, "");
+
+#define MINMSSIZE ((off_t)1 << 24) /* 16MB */
+#define DFLTMSSIZE ((off_t)1 << 29) /* 512MB */
+#define MAXMSSIZE ((off_t)1 << 34) /* 16GB */
+
+#define INDIR_LEVELS 6
+/* Indirect blocks are always 128KB. */
+#define BLKPTR_PER_INDIR (MAXBLOCKSIZE / sizeof(blkptr_t))
+
+struct dnode_cursor {
+ char inddir[INDIR_LEVELS][MAXBLOCKSIZE];
+ off_t indloc;
+ off_t indspace;
+ dnode_phys_t *dnode;
+ off_t dataoff;
+ off_t datablksz;
+};
+
+void
+zfs_prep_opts(fsinfo_t *fsopts)
+{
+ zfs_opt_t *zfs;
+ size_t align;
+
+ align = alignof(uint64_t);
+ zfs = aligned_alloc(align, roundup2(sizeof(*zfs), align));
+ if (zfs == NULL)
+ err(1, "aligned_alloc");
+ memset(zfs, 0, sizeof(*zfs));
+
+ const option_t zfs_options[] = {
+ { '\0', "bootfs", &zfs->bootfs, OPT_STRPTR,
+ 0, 0, "Bootable dataset" },
+ { '\0', "mssize", &zfs->mssize, OPT_INT64,
+ MINMSSIZE, MAXMSSIZE, "Metaslab size" },
+ { '\0', "poolname", &zfs->poolname, OPT_STRPTR,
+ 0, 0, "ZFS pool name" },
+ { '\0', "rootpath", &zfs->rootpath, OPT_STRPTR,
+ 0, 0, "Prefix for all dataset mount points" },
+ { '\0', "ashift", &zfs->ashift, OPT_INT32,
+ MINBLOCKSHIFT, MAXBLOCKSHIFT, "ZFS pool ashift" },
+ { '\0', "nowarn", &zfs->nowarn, OPT_BOOL,
+ 0, 0, "Suppress warning about experimental ZFS support" },
+ { .name = NULL }
+ };
+
+ STAILQ_INIT(&zfs->datasetdescs);
+
+ fsopts->fs_specific = zfs;
+ fsopts->fs_options = copy_opts(zfs_options);
+}
+
+int
+zfs_parse_opts(const char *option, fsinfo_t *fsopts)
+{
+ zfs_opt_t *zfs;
+ struct dataset_desc *dsdesc;
+ char buf[BUFSIZ], *opt, *val;
+ int rv;
+
+ zfs = fsopts->fs_specific;
+
+ opt = val = estrdup(option);
+ opt = strsep(&val, "=");
+ if (strcmp(opt, "fs") == 0) {
+ if (val == NULL)
+ errx(1, "invalid filesystem parameters `%s'", option);
+
+ /*
+ * Dataset descriptions will be parsed later, in dsl_init().
+ * Just stash them away for now.
+ */
+ dsdesc = ecalloc(1, sizeof(*dsdesc));
+ dsdesc->params = estrdup(val);
+ free(opt);
+ STAILQ_INSERT_TAIL(&zfs->datasetdescs, dsdesc, next);
+ return (1);
+ }
+ free(opt);
+
+ rv = set_option(fsopts->fs_options, option, buf, sizeof(buf));
+ return (rv == -1 ? 0 : 1);
+}
+
+static void
+zfs_size_vdev(fsinfo_t *fsopts)
+{
+ zfs_opt_t *zfs;
+ off_t asize, mssize, vdevsize, vdevsize1;
+
+ zfs = fsopts->fs_specific;
+
+ assert(fsopts->maxsize != 0);
+ assert(zfs->ashift != 0);
+
+ /*
+ * Figure out how big the vdev should be.
+ */
+ vdevsize = rounddown2(fsopts->maxsize, 1 << zfs->ashift);
+ if (vdevsize < MINDEVSIZE)
+ errx(1, "maximum image size is too small");
+ if (vdevsize < fsopts->minsize || vdevsize > fsopts->maxsize) {
+ errx(1, "image size bounds must be multiples of %d",
+ 1 << zfs->ashift);
+ }
+ asize = vdevsize - VDEV_LABEL_SPACE;
+
+ /*
+ * Size metaslabs according to the following heuristic:
+ * - provide at least 8 metaslabs,
+ * - without using a metaslab size larger than 512MB.
+ * This approximates what OpenZFS does without being complicated. In
+ * practice we expect pools to be expanded upon first use, and OpenZFS
+ * does not resize metaslabs in that case, so there is no right answer
+ * here. In general we want to provide large metaslabs even if the
+ * image size is small, and 512MB is a reasonable size for pools up to
+ * several hundred gigabytes.
+ *
+ * The user may override this heuristic using the "-o mssize" option.
+ */
+ mssize = zfs->mssize;
+ if (mssize == 0) {
+ mssize = MAX(MIN(asize / 8, DFLTMSSIZE), MINMSSIZE);
+ if (!powerof2(mssize))
+ mssize = 1l << (flsll(mssize) - 1);
+ }
+ if (!powerof2(mssize))
+ errx(1, "metaslab size must be a power of 2");
+
+ /*
+ * If we have some slop left over, try to cover it by resizing the vdev,
+ * subject to the maxsize and minsize parameters.
+ */
+ if (asize % mssize != 0) {
+ vdevsize1 = rounddown2(asize, mssize) + VDEV_LABEL_SPACE;
+ if (vdevsize1 < fsopts->minsize)
+ vdevsize1 = roundup2(asize, mssize) + VDEV_LABEL_SPACE;
+ if (vdevsize1 <= fsopts->maxsize)
+ vdevsize = vdevsize1;
+ }
+ asize = vdevsize - VDEV_LABEL_SPACE;
+
+ zfs->asize = asize;
+ zfs->vdevsize = vdevsize;
+ zfs->mssize = mssize;
+ zfs->msshift = flsll(mssize) - 1;
+ zfs->mscount = asize / mssize;
+}
+
+/*
+ * Validate options and set some default values.
+ */
+static void
+zfs_check_opts(fsinfo_t *fsopts)
+{
+ zfs_opt_t *zfs;
+
+ zfs = fsopts->fs_specific;
+
+ if (fsopts->offset != 0)
+ errx(1, "unhandled offset option");
+ if (fsopts->maxsize == 0)
+ errx(1, "an image size must be specified");
+
+ if (zfs->poolname == NULL)
+ errx(1, "a pool name must be specified");
+ if (!isalpha(zfs->poolname[0]))
+ errx(1, "the pool name must begin with a letter");
+ for (size_t i = 0, len = strlen(zfs->poolname); i < len; i++) {
+ if (!isalnum(zfs->poolname[i]) && zfs->poolname[i] != '_')
+ errx(1, "invalid character '%c' in pool name",
+ zfs->poolname[i]);
+ }
+ if (strcmp(zfs->poolname, "mirror") == 0 ||
+ strcmp(zfs->poolname, "raidz") == 0 ||
+ strcmp(zfs->poolname, "draid") == 0) {
+ errx(1, "pool name '%s' is reserved and cannot be used",
+ zfs->poolname);
+ }
+
+ if (zfs->rootpath == NULL)
+ easprintf(&zfs->rootpath, "/%s", zfs->poolname);
+ if (zfs->rootpath[0] != '/')
+ errx(1, "mountpoint `%s' must be absolute", zfs->rootpath);
+
+ if (zfs->ashift == 0)
+ zfs->ashift = 12;
+
+ zfs_size_vdev(fsopts);
+}
+
+void
+zfs_cleanup_opts(fsinfo_t *fsopts)
+{
+ struct dataset_desc *d, *tmp;
+ zfs_opt_t *zfs;
+
+ zfs = fsopts->fs_specific;
+ free(zfs->rootpath);
+ free(zfs->bootfs);
+ free(__DECONST(void *, zfs->poolname));
+ STAILQ_FOREACH_SAFE(d, &zfs->datasetdescs, next, tmp) {
+ free(d->params);
+ free(d);
+ }
+ free(zfs);
+ free(fsopts->fs_options);
+}
+
+static size_t
+nvlist_size(const nvlist_t *nvl)
+{
+ return (sizeof(nvl->nv_header) + nvl->nv_size);
+}
+
+static void
+nvlist_copy(const nvlist_t *nvl, char *buf, size_t sz)
+{
+ assert(sz >= nvlist_size(nvl));
+
+ memcpy(buf, &nvl->nv_header, sizeof(nvl->nv_header));
+ memcpy(buf + sizeof(nvl->nv_header), nvl->nv_data, nvl->nv_size);
+}
+
+/*
+ * Avoid returning a GUID of 0, just to avoid the possibility that something
+ * will interpret that as meaning that the GUID is uninitialized.
+ */
+uint64_t
+randomguid(void)
+{
+ uint64_t ret;
+
+ do {
+ ret = ((uint64_t)random() << 32) | random();
+ } while (ret == 0);
+
+ return (ret);
+}
+
+static nvlist_t *
+pool_config_nvcreate(zfs_opt_t *zfs)
+{
+ nvlist_t *featuresnv, *poolnv;
+
+ poolnv = nvlist_create(NV_UNIQUE_NAME);
+ nvlist_add_uint64(poolnv, ZPOOL_CONFIG_POOL_TXG, TXG);
+ nvlist_add_uint64(poolnv, ZPOOL_CONFIG_VERSION, SPA_VERSION);
+ nvlist_add_uint64(poolnv, ZPOOL_CONFIG_POOL_STATE, POOL_STATE_EXPORTED);
+ nvlist_add_string(poolnv, ZPOOL_CONFIG_POOL_NAME, zfs->poolname);
+ nvlist_add_uint64(poolnv, ZPOOL_CONFIG_POOL_GUID, zfs->poolguid);
+ nvlist_add_uint64(poolnv, ZPOOL_CONFIG_TOP_GUID, zfs->vdevguid);
+ nvlist_add_uint64(poolnv, ZPOOL_CONFIG_GUID, zfs->vdevguid);
+ nvlist_add_uint64(poolnv, ZPOOL_CONFIG_VDEV_CHILDREN, 1);
+
+ featuresnv = nvlist_create(NV_UNIQUE_NAME);
+ nvlist_add_nvlist(poolnv, ZPOOL_CONFIG_FEATURES_FOR_READ, featuresnv);
+ nvlist_destroy(featuresnv);
+
+ return (poolnv);
+}
+
+static nvlist_t *
+pool_disk_vdev_config_nvcreate(zfs_opt_t *zfs)
+{
+ nvlist_t *diskvdevnv;
+
+ assert(zfs->objarrid != 0);
+
+ diskvdevnv = nvlist_create(NV_UNIQUE_NAME);
+ nvlist_add_string(diskvdevnv, ZPOOL_CONFIG_TYPE, VDEV_TYPE_DISK);
+ nvlist_add_uint64(diskvdevnv, ZPOOL_CONFIG_ASHIFT, zfs->ashift);
+ nvlist_add_uint64(diskvdevnv, ZPOOL_CONFIG_ASIZE, zfs->asize);
+ nvlist_add_uint64(diskvdevnv, ZPOOL_CONFIG_GUID, zfs->vdevguid);
+ nvlist_add_uint64(diskvdevnv, ZPOOL_CONFIG_ID, 0);
+ nvlist_add_string(diskvdevnv, ZPOOL_CONFIG_PATH, "/dev/null");
+ nvlist_add_uint64(diskvdevnv, ZPOOL_CONFIG_WHOLE_DISK, 1);
+ nvlist_add_uint64(diskvdevnv, ZPOOL_CONFIG_CREATE_TXG, TXG);
+ nvlist_add_uint64(diskvdevnv, ZPOOL_CONFIG_METASLAB_ARRAY,
+ zfs->objarrid);
+ nvlist_add_uint64(diskvdevnv, ZPOOL_CONFIG_METASLAB_SHIFT,
+ zfs->msshift);
+
+ return (diskvdevnv);
+}
+
+static nvlist_t *
+pool_root_vdev_config_nvcreate(zfs_opt_t *zfs)
+{
+ nvlist_t *diskvdevnv, *rootvdevnv;
+
+ diskvdevnv = pool_disk_vdev_config_nvcreate(zfs);
+ rootvdevnv = nvlist_create(NV_UNIQUE_NAME);
+
+ nvlist_add_uint64(rootvdevnv, ZPOOL_CONFIG_ID, 0);
+ nvlist_add_uint64(rootvdevnv, ZPOOL_CONFIG_GUID, zfs->poolguid);
+ nvlist_add_string(rootvdevnv, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT);
+ nvlist_add_uint64(rootvdevnv, ZPOOL_CONFIG_CREATE_TXG, TXG);
+ nvlist_add_nvlist_array(rootvdevnv, ZPOOL_CONFIG_CHILDREN, &diskvdevnv,
+ 1);
+ nvlist_destroy(diskvdevnv);
+
+ return (rootvdevnv);
+}
+
+/*
+ * Create the pool's "config" object, which contains an nvlist describing pool
+ * parameters and the vdev topology. It is similar but not identical to the
+ * nvlist stored in vdev labels. The main difference is that vdev labels do not
+ * describe the full vdev tree and in particular do not contain the "root"
+ * meta-vdev.
+ */
+static void
+pool_init_objdir_config(zfs_opt_t *zfs, zfs_zap_t *objdir)
+{
+ dnode_phys_t *dnode;
+ nvlist_t *poolconfig, *vdevconfig;
+ void *configbuf;
+ uint64_t dnid;
+ off_t configloc, configblksz;
+ int error;
+
+ dnode = objset_dnode_bonus_alloc(zfs->mos, DMU_OT_PACKED_NVLIST,
+ DMU_OT_PACKED_NVLIST_SIZE, sizeof(uint64_t), &dnid);
+
+ poolconfig = pool_config_nvcreate(zfs);
+
+ vdevconfig = pool_root_vdev_config_nvcreate(zfs);
+ nvlist_add_nvlist(poolconfig, ZPOOL_CONFIG_VDEV_TREE, vdevconfig);
+ nvlist_destroy(vdevconfig);
+
+ error = nvlist_export(poolconfig);
+ if (error != 0)
+ errc(1, error, "nvlist_export");
+
+ configblksz = nvlist_size(poolconfig);
+ configloc = objset_space_alloc(zfs, zfs->mos, &configblksz);
+ configbuf = ecalloc(1, configblksz);
+ nvlist_copy(poolconfig, configbuf, configblksz);
+
+ vdev_pwrite_dnode_data(zfs, dnode, configbuf, configblksz, configloc);
+
+ dnode->dn_datablkszsec = configblksz >> MINBLOCKSHIFT;
+ dnode->dn_flags = DNODE_FLAG_USED_BYTES;
+ *(uint64_t *)DN_BONUS(dnode) = nvlist_size(poolconfig);
+
+ zap_add_uint64(objdir, DMU_POOL_CONFIG, dnid);
+
+ nvlist_destroy(poolconfig);
+ free(configbuf);
+}
+
+/*
+ * Add objects block pointer list objects, used for deferred frees. We don't do
+ * anything with them, but they need to be present or OpenZFS will refuse to
+ * import the pool.
+ */
+static void
+pool_init_objdir_bplists(zfs_opt_t *zfs __unused, zfs_zap_t *objdir)
+{
+ uint64_t dnid;
+
+ (void)objset_dnode_bonus_alloc(zfs->mos, DMU_OT_BPOBJ, DMU_OT_BPOBJ_HDR,
+ BPOBJ_SIZE_V2, &dnid);
+ zap_add_uint64(objdir, DMU_POOL_FREE_BPOBJ, dnid);
+
+ (void)objset_dnode_bonus_alloc(zfs->mos, DMU_OT_BPOBJ, DMU_OT_BPOBJ_HDR,
+ BPOBJ_SIZE_V2, &dnid);
+ zap_add_uint64(objdir, DMU_POOL_SYNC_BPLIST, dnid);
+}
+
+/*
+ * Add required feature metadata objects. We don't know anything about ZFS
+ * features, so the objects are just empty ZAPs.
+ */
+static void
+pool_init_objdir_feature_maps(zfs_opt_t *zfs, zfs_zap_t *objdir)
+{
+ dnode_phys_t *dnode;
+ uint64_t dnid;
+
+ dnode = objset_dnode_alloc(zfs->mos, DMU_OTN_ZAP_METADATA, &dnid);
+ zap_add_uint64(objdir, DMU_POOL_FEATURES_FOR_READ, dnid);
+ zap_write(zfs, zap_alloc(zfs->mos, dnode));
+
+ dnode = objset_dnode_alloc(zfs->mos, DMU_OTN_ZAP_METADATA, &dnid);
+ zap_add_uint64(objdir, DMU_POOL_FEATURES_FOR_WRITE, dnid);
+ zap_write(zfs, zap_alloc(zfs->mos, dnode));
+
+ dnode = objset_dnode_alloc(zfs->mos, DMU_OTN_ZAP_METADATA, &dnid);
+ zap_add_uint64(objdir, DMU_POOL_FEATURE_DESCRIPTIONS, dnid);
+ zap_write(zfs, zap_alloc(zfs->mos, dnode));
+}
+
+static void
+pool_init_objdir_dsl(zfs_opt_t *zfs, zfs_zap_t *objdir)
+{
+ zap_add_uint64(objdir, DMU_POOL_ROOT_DATASET,
+ dsl_dir_id(zfs->rootdsldir));
+}
+
+static void
+pool_init_objdir_poolprops(zfs_opt_t *zfs, zfs_zap_t *objdir)
+{
+ dnode_phys_t *dnode;
+ uint64_t id;
+
+ dnode = objset_dnode_alloc(zfs->mos, DMU_OT_POOL_PROPS, &id);
+ zap_add_uint64(objdir, DMU_POOL_PROPS, id);
+
+ zfs->poolprops = zap_alloc(zfs->mos, dnode);
+}
+
+/*
+ * Initialize the MOS object directory, the root of virtually all of the pool's
+ * data and metadata.
+ */
+static void
+pool_init_objdir(zfs_opt_t *zfs)
+{
+ zfs_zap_t *zap;
+ dnode_phys_t *objdir;
+
+ objdir = objset_dnode_lookup(zfs->mos, DMU_POOL_DIRECTORY_OBJECT);
+
+ zap = zap_alloc(zfs->mos, objdir);
+ pool_init_objdir_config(zfs, zap);
+ pool_init_objdir_bplists(zfs, zap);
+ pool_init_objdir_feature_maps(zfs, zap);
+ pool_init_objdir_dsl(zfs, zap);
+ pool_init_objdir_poolprops(zfs, zap);
+ zap_write(zfs, zap);
+}
+
+/*
+ * Initialize the meta-object set (MOS) and immediately write out several
+ * special objects whose contents are already finalized, including the object
+ * directory.
+ *
+ * Once the MOS is finalized, it'll look roughly like this:
+ *
+ * object directory (ZAP)
+ * |-> vdev config object (nvlist)
+ * |-> features for read
+ * |-> features for write
+ * |-> feature descriptions
+ * |-> sync bplist
+ * |-> free bplist
+ * |-> pool properties
+ * L-> root DSL directory
+ * |-> DSL child directory (ZAP)
+ * | |-> $MOS (DSL dir)
+ * | | |-> child map
+ * | | L-> props (ZAP)
+ * | |-> $FREE (DSL dir)
+ * | | |-> child map
+ * | | L-> props (ZAP)
+ * | |-> $ORIGIN (DSL dir)
+ * | | |-> child map
+ * | | |-> dataset
+ * | | | L-> deadlist
+ * | | |-> snapshot
+ * | | | |-> deadlist
+ * | | | L-> snapshot names
+ * | | |-> props (ZAP)
+ * | | L-> clones (ZAP)
+ * | |-> dataset 1 (DSL dir)
+ * | | |-> DSL dataset
+ * | | | |-> snapshot names
+ * | | | L-> deadlist
+ * | | |-> child map
+ * | | | L-> ...
+ * | | L-> props
+ * | |-> dataset 2
+ * | | L-> ...
+ * | |-> ...
+ * | L-> dataset n
+ * |-> DSL root dataset
+ * | |-> snapshot names
+ * | L-> deadlist
+ * L-> props (ZAP)
+ * space map object array
+ * |-> space map 1
+ * |-> space map 2
+ * |-> ...
+ * L-> space map n (zfs->mscount)
+ *
+ * The space map object array is pointed to by the "msarray" property in the
+ * pool configuration.
+ */
+static void
+pool_init(zfs_opt_t *zfs)
+{
+ uint64_t dnid;
+
+ zfs->poolguid = randomguid();
+ zfs->vdevguid = randomguid();
+
+ zfs->mos = objset_alloc(zfs, DMU_OST_META);
+
+ (void)objset_dnode_alloc(zfs->mos, DMU_OT_OBJECT_DIRECTORY, &dnid);
+ assert(dnid == DMU_POOL_DIRECTORY_OBJECT);
+
+ (void)objset_dnode_alloc(zfs->mos, DMU_OT_OBJECT_ARRAY, &zfs->objarrid);
+
+ dsl_init(zfs);
+
+ pool_init_objdir(zfs);
+}
+
+static void
+pool_labels_write(zfs_opt_t *zfs)
+{
+ uberblock_t *ub;
+ vdev_label_t *label;
+ nvlist_t *poolconfig, *vdevconfig;
+ int error;
+
+ label = ecalloc(1, sizeof(*label));
+
+ /*
+ * Assemble the vdev configuration and store it in the label.
+ */
+ poolconfig = pool_config_nvcreate(zfs);
+ vdevconfig = pool_disk_vdev_config_nvcreate(zfs);
+ nvlist_add_nvlist(poolconfig, ZPOOL_CONFIG_VDEV_TREE, vdevconfig);
+ nvlist_destroy(vdevconfig);
+
+ error = nvlist_export(poolconfig);
+ if (error != 0)
+ errc(1, error, "nvlist_export");
+ nvlist_copy(poolconfig, label->vl_vdev_phys.vp_nvlist,
+ sizeof(label->vl_vdev_phys.vp_nvlist));
+ nvlist_destroy(poolconfig);
+
+ /*
+ * Fill out the uberblock. Just make each one the same. The embedded
+ * checksum is calculated in vdev_label_write().
+ */
+ for (size_t uoff = 0; uoff < sizeof(label->vl_uberblock);
+ uoff += (1 << zfs->ashift)) {
+ ub = (uberblock_t *)(&label->vl_uberblock[0] + uoff);
+ ub->ub_magic = UBERBLOCK_MAGIC;
+ ub->ub_version = SPA_VERSION;
+ ub->ub_txg = TXG;
+ ub->ub_guid_sum = zfs->poolguid + zfs->vdevguid;
+ ub->ub_timestamp = 0;
+
+ ub->ub_software_version = SPA_VERSION;
+ ub->ub_mmp_magic = MMP_MAGIC;
+ ub->ub_mmp_delay = 0;
+ ub->ub_mmp_config = 0;
+ ub->ub_checkpoint_txg = 0;
+ objset_root_blkptr_copy(zfs->mos, &ub->ub_rootbp);
+ }
+
+ /*
+ * Write out four copies of the label: two at the beginning of the vdev
+ * and two at the end.
+ */
+ for (int i = 0; i < VDEV_LABELS; i++)
+ vdev_label_write(zfs, i, label);
+
+ free(label);
+}
+
+static void
+pool_fini(zfs_opt_t *zfs)
+{
+ zap_write(zfs, zfs->poolprops);
+ dsl_write(zfs);
+ objset_write(zfs, zfs->mos);
+ pool_labels_write(zfs);
+}
+
+struct dnode_cursor *
+dnode_cursor_init(zfs_opt_t *zfs, zfs_objset_t *os, dnode_phys_t *dnode,
+ off_t size, off_t blksz)
+{
+ struct dnode_cursor *c;
+ uint64_t nbppindir, indlevel, ndatablks, nindblks;
+
+ assert(dnode->dn_nblkptr == 1);
+ assert(blksz <= MAXBLOCKSIZE);
+
+ if (blksz == 0) {
+ /* Must be between 1<<ashift and 128KB. */
+ blksz = MIN(MAXBLOCKSIZE, MAX(1 << zfs->ashift,
+ powerof2(size) ? size : (1l << flsll(size))));
+ }
+ assert(powerof2(blksz));
+
+ /*
+ * Do we need indirect blocks? Figure out how many levels are needed
+ * (indlevel == 1 means no indirect blocks) and how much space is needed
+ * (it has to be allocated up-front to break the dependency cycle
+ * described in objset_write()).
+ */
+ ndatablks = size == 0 ? 0 : howmany(size, blksz);
+ nindblks = 0;
+ for (indlevel = 1, nbppindir = 1; ndatablks > nbppindir; indlevel++) {
+ nbppindir *= BLKPTR_PER_INDIR;
+ nindblks += howmany(ndatablks, indlevel * nbppindir);
+ }
+ assert(indlevel < INDIR_LEVELS);
+
+ dnode->dn_nlevels = (uint8_t)indlevel;
+ dnode->dn_maxblkid = ndatablks > 0 ? ndatablks - 1 : 0;
+ dnode->dn_datablkszsec = blksz >> MINBLOCKSHIFT;
+
+ c = ecalloc(1, sizeof(*c));
+ if (nindblks > 0) {
+ c->indspace = nindblks * MAXBLOCKSIZE;
+ c->indloc = objset_space_alloc(zfs, os, &c->indspace);
+ }
+ c->dnode = dnode;
+ c->dataoff = 0;
+ c->datablksz = blksz;
+
+ return (c);
+}
+
+static void
+_dnode_cursor_flush(zfs_opt_t *zfs, struct dnode_cursor *c, unsigned int levels)
+{
+ blkptr_t *bp, *pbp;
+ void *buf;
+ uint64_t fill;
+ off_t blkid, blksz, loc;
+
+ assert(levels > 0);
+ assert(levels <= c->dnode->dn_nlevels - 1U);
+
+ blksz = MAXBLOCKSIZE;
+ blkid = (c->dataoff / c->datablksz) / BLKPTR_PER_INDIR;
+ for (unsigned int level = 1; level <= levels; level++) {
+ buf = c->inddir[level - 1];
+
+ if (level == c->dnode->dn_nlevels - 1U) {
+ pbp = &c->dnode->dn_blkptr[0];
+ } else {
+ uint64_t iblkid;
+
+ iblkid = blkid & (BLKPTR_PER_INDIR - 1);
+ pbp = (blkptr_t *)
+ &c->inddir[level][iblkid * sizeof(blkptr_t)];
+ }
+
+ /*
+ * Space for indirect blocks is allocated up-front; see the
+ * comment in objset_write().
+ */
+ loc = c->indloc;
+ c->indloc += blksz;
+ assert(c->indspace >= blksz);
+ c->indspace -= blksz;
+
+ bp = buf;
+ fill = 0;
+ for (size_t i = 0; i < BLKPTR_PER_INDIR; i++)
+ fill += BP_GET_FILL(&bp[i]);
+
+ vdev_pwrite_dnode_indir(zfs, c->dnode, level, fill, buf, blksz,
+ loc, pbp);
+ memset(buf, 0, MAXBLOCKSIZE);
+
+ blkid /= BLKPTR_PER_INDIR;
+ }
+}
+
+blkptr_t *
+dnode_cursor_next(zfs_opt_t *zfs, struct dnode_cursor *c, off_t off)
+{
+ off_t blkid, l1id;
+ unsigned int levels;
+
+ if (c->dnode->dn_nlevels == 1) {
+ assert(off < MAXBLOCKSIZE);
+ return (&c->dnode->dn_blkptr[0]);
+ }
+
+ assert(off % c->datablksz == 0);
+
+ /* Do we need to flush any full indirect blocks? */
+ if (off > 0) {
+ blkid = off / c->datablksz;
+ for (levels = 0; levels < c->dnode->dn_nlevels - 1U; levels++) {
+ if (blkid % BLKPTR_PER_INDIR != 0)
+ break;
+ blkid /= BLKPTR_PER_INDIR;
+ }
+ if (levels > 0)
+ _dnode_cursor_flush(zfs, c, levels);
+ }
+
+ c->dataoff = off;
+ l1id = (off / c->datablksz) & (BLKPTR_PER_INDIR - 1);
+ return ((blkptr_t *)&c->inddir[0][l1id * sizeof(blkptr_t)]);
+}
+
+void
+dnode_cursor_finish(zfs_opt_t *zfs, struct dnode_cursor *c)
+{
+ unsigned int levels;
+
+ assert(c->dnode->dn_nlevels > 0);
+ levels = c->dnode->dn_nlevels - 1;
+ if (levels > 0)
+ _dnode_cursor_flush(zfs, c, levels);
+ assert(c->indspace == 0);
+ free(c);
+}
+
+void
+zfs_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts)
+{
+ zfs_opt_t *zfs;
+ int dirfd;
+
+ zfs = fsopts->fs_specific;
+
+ /*
+ * Use a fixed seed to provide reproducible pseudo-random numbers for
+ * on-disk structures when needed (e.g., GUIDs, ZAP hash salts).
+ */
+ srandom(1729);
+
+ zfs_check_opts(fsopts);
+
+ if (!zfs->nowarn) {
+ fprintf(stderr,
+ "ZFS support is currently considered experimental. "
+ "Do not use it for anything critical.\n");
+ }
+
+ dirfd = open(dir, O_DIRECTORY | O_RDONLY);
+ if (dirfd < 0)
+ err(1, "open(%s)", dir);
+
+ vdev_init(zfs, image);
+ pool_init(zfs);
+ fs_build(zfs, dirfd, root);
+ pool_fini(zfs);
+ vdev_fini(zfs);
+}
diff --git a/usr.sbin/makefs/zfs/Makefile.inc b/usr.sbin/makefs/zfs/Makefile.inc
new file mode 100644
index 000000000000..78561813e229
--- /dev/null
+++ b/usr.sbin/makefs/zfs/Makefile.inc
@@ -0,0 +1,13 @@
+.PATH: ${SRCDIR}/zfs
+.PATH: ${SRCTOP}/stand/libsa/zfs
+
+SRCS+= dsl.c \
+ fs.c \
+ objset.c \
+ vdev.c \
+ zap.c
+
+SRCS+= nvlist.c
+
+CFLAGS.nvlist.c+= -I${SRCTOP}/stand/libsa -Wno-cast-qual
+CWARNFLAGS.zap.c+= -Wno-sign-compare
diff --git a/usr.sbin/makefs/zfs/dsl.c b/usr.sbin/makefs/zfs/dsl.c
new file mode 100644
index 000000000000..93083f286e81
--- /dev/null
+++ b/usr.sbin/makefs/zfs/dsl.c
@@ -0,0 +1,628 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 The FreeBSD Foundation
+ *
+ * This software was developed by Mark Johnston under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <util.h>
+
+#include "makefs.h"
+#include "zfs.h"
+
+typedef struct zfs_dsl_dataset {
+ zfs_objset_t *os; /* referenced objset, may be null */
+ dsl_dataset_phys_t *phys; /* on-disk representation */
+ uint64_t dsid; /* DSL dataset dnode */
+
+ struct zfs_dsl_dir *dir; /* containing parent */
+} zfs_dsl_dataset_t;
+
+typedef STAILQ_HEAD(zfs_dsl_dir_list, zfs_dsl_dir) zfs_dsl_dir_list_t;
+
+typedef struct zfs_dsl_dir {
+ char *fullname; /* full dataset name */
+ char *name; /* basename(fullname) */
+ dsl_dir_phys_t *phys; /* on-disk representation */
+ nvlist_t *propsnv; /* properties saved in propszap */
+
+ zfs_dsl_dataset_t *headds; /* principal dataset, may be null */
+
+ uint64_t dirid; /* DSL directory dnode */
+ zfs_zap_t *propszap; /* dataset properties */
+ zfs_zap_t *childzap; /* child directories */
+
+ /* DSL directory tree linkage. */
+ struct zfs_dsl_dir *parent;
+ zfs_dsl_dir_list_t children;
+ STAILQ_ENTRY(zfs_dsl_dir) next;
+} zfs_dsl_dir_t;
+
+static zfs_dsl_dir_t *dsl_dir_alloc(zfs_opt_t *zfs, const char *name);
+static zfs_dsl_dataset_t *dsl_dataset_alloc(zfs_opt_t *zfs, zfs_dsl_dir_t *dir);
+
+static int
+nvlist_find_string(nvlist_t *nvl, const char *key, char **retp)
+{
+ char *str;
+ int error, len;
+
+ error = nvlist_find(nvl, key, DATA_TYPE_STRING, NULL, &str, &len);
+ if (error == 0) {
+ *retp = ecalloc(1, len + 1);
+ memcpy(*retp, str, len);
+ }
+ return (error);
+}
+
+static int
+nvlist_find_uint64(nvlist_t *nvl, const char *key, uint64_t *retp)
+{
+ return (nvlist_find(nvl, key, DATA_TYPE_UINT64, NULL, retp, NULL));
+}
+
+/*
+ * Return an allocated string containing the head dataset's mountpoint,
+ * including the root path prefix.
+ *
+ * If the dataset has a mountpoint property, it is returned. Otherwise we have
+ * to follow ZFS' inheritance rules.
+ */
+char *
+dsl_dir_get_mountpoint(zfs_opt_t *zfs, zfs_dsl_dir_t *dir)
+{
+ zfs_dsl_dir_t *pdir;
+ char *mountpoint;
+
+ if (nvlist_find_string(dir->propsnv, "mountpoint", &mountpoint) == 0) {
+ if (strcmp(mountpoint, "none") == 0)
+ return (NULL);
+ } else {
+ /*
+ * If we don't have a mountpoint, it's inherited from one of our
+ * ancestors. Walk up the hierarchy until we find it, building
+ * up our mountpoint along the way. The mountpoint property is
+ * always set for the root dataset.
+ */
+ for (pdir = dir->parent, mountpoint = estrdup(dir->name);;
+ pdir = pdir->parent) {
+ char *origmountpoint, *tmp;
+
+ origmountpoint = mountpoint;
+
+ if (nvlist_find_string(pdir->propsnv, "mountpoint",
+ &tmp) == 0) {
+ easprintf(&mountpoint, "%s%s%s", tmp,
+ tmp[strlen(tmp) - 1] == '/' ? "" : "/",
+ origmountpoint);
+ free(tmp);
+ free(origmountpoint);
+ break;
+ }
+
+ easprintf(&mountpoint, "%s/%s", pdir->name,
+ origmountpoint);
+ free(origmountpoint);
+ }
+ }
+ assert(mountpoint[0] == '/');
+ assert(strstr(mountpoint, zfs->rootpath) == mountpoint);
+
+ return (mountpoint);
+}
+
+int
+dsl_dir_get_canmount(zfs_dsl_dir_t *dir, uint64_t *canmountp)
+{
+ return (nvlist_find_uint64(dir->propsnv, "canmount", canmountp));
+}
+
+/*
+ * Handle dataset properties that we know about; stash them into an nvlist to be
+ * written later to the properties ZAP object.
+ *
+ * If the set of properties we handle grows too much, we should probably explore
+ * using libzfs to manage them.
+ */
+static void
+dsl_dir_set_prop(zfs_opt_t *zfs, zfs_dsl_dir_t *dir, const char *key,
+ const char *val)
+{
+ nvlist_t *nvl;
+
+ nvl = dir->propsnv;
+ if (val == NULL || val[0] == '\0')
+ errx(1, "missing value for property `%s'", key);
+ if (nvpair_find(nvl, key) != NULL)
+ errx(1, "property `%s' already set", key);
+
+ if (strcmp(key, "mountpoint") == 0) {
+ if (strcmp(val, "none") != 0) {
+ if (val[0] != '/')
+ errx(1, "mountpoint `%s' is not absolute", val);
+ if (strcmp(val, zfs->rootpath) != 0 &&
+ strcmp(zfs->rootpath, "/") != 0 &&
+ (strstr(val, zfs->rootpath) != val ||
+ val[strlen(zfs->rootpath)] != '/')) {
+ errx(1, "mountpoint `%s' is not prefixed by "
+ "the root path `%s'", val, zfs->rootpath);
+ }
+ }
+ nvlist_add_string(nvl, key, val);
+ } else if (strcmp(key, "atime") == 0 || strcmp(key, "exec") == 0 ||
+ strcmp(key, "setuid") == 0) {
+ if (strcmp(val, "on") == 0)
+ nvlist_add_uint64(nvl, key, 1);
+ else if (strcmp(val, "off") == 0)
+ nvlist_add_uint64(nvl, key, 0);
+ else
+ errx(1, "invalid value `%s' for %s", val, key);
+ } else if (strcmp(key, "canmount") == 0) {
+ if (strcmp(val, "noauto") == 0)
+ nvlist_add_uint64(nvl, key, 2);
+ else if (strcmp(val, "on") == 0)
+ nvlist_add_uint64(nvl, key, 1);
+ else if (strcmp(val, "off") == 0)
+ nvlist_add_uint64(nvl, key, 0);
+ else
+ errx(1, "invalid value `%s' for %s", val, key);
+ } else {
+ errx(1, "unknown property `%s'", key);
+ }
+}
+
+static zfs_dsl_dir_t *
+dsl_metadir_alloc(zfs_opt_t *zfs, const char *name)
+{
+ zfs_dsl_dir_t *dir;
+ char *path;
+
+ easprintf(&path, "%s/%s", zfs->poolname, name);
+ dir = dsl_dir_alloc(zfs, path);
+ free(path);
+ return (dir);
+}
+
+static void
+dsl_origindir_init(zfs_opt_t *zfs)
+{
+ dnode_phys_t *clones;
+ uint64_t clonesid;
+
+ zfs->origindsldir = dsl_metadir_alloc(zfs, "$ORIGIN");
+ zfs->originds = dsl_dataset_alloc(zfs, zfs->origindsldir);
+ zfs->snapds = dsl_dataset_alloc(zfs, zfs->origindsldir);
+
+ clones = objset_dnode_alloc(zfs->mos, DMU_OT_DSL_CLONES, &clonesid);
+ zfs->cloneszap = zap_alloc(zfs->mos, clones);
+ zfs->origindsldir->phys->dd_clones = clonesid;
+}
+
+void
+dsl_init(zfs_opt_t *zfs)
+{
+ zfs_dsl_dir_t *dir;
+ struct dataset_desc *d;
+ const char *dspropdelim;
+
+ dspropdelim = ";";
+
+ zfs->rootdsldir = dsl_dir_alloc(zfs, NULL);
+
+ nvlist_add_uint64(zfs->rootdsldir->propsnv, "compression",
+ ZIO_COMPRESS_OFF);
+
+ zfs->rootds = dsl_dataset_alloc(zfs, zfs->rootdsldir);
+ zfs->rootdsldir->headds = zfs->rootds;
+
+ zfs->mosdsldir = dsl_metadir_alloc(zfs, "$MOS");
+ zfs->freedsldir = dsl_metadir_alloc(zfs, "$FREE");
+ dsl_origindir_init(zfs);
+
+ /*
+ * Go through the list of user-specified datasets and create DSL objects
+ * for them.
+ */
+ STAILQ_FOREACH(d, &zfs->datasetdescs, next) {
+ char *dsname, *next, *params, *param, *nextparam;
+
+ params = d->params;
+ dsname = strsep(&params, dspropdelim);
+
+ if (strcmp(dsname, zfs->poolname) == 0) {
+ /*
+ * This is the root dataset; it's already created, so
+ * we're just setting options.
+ */
+ dir = zfs->rootdsldir;
+ } else {
+ /*
+ * This dataset must be a child of the root dataset.
+ */
+ if (strstr(dsname, zfs->poolname) != dsname ||
+ (next = strchr(dsname, '/')) == NULL ||
+ (size_t)(next - dsname) != strlen(zfs->poolname)) {
+ errx(1, "dataset `%s' must be a child of `%s'",
+ dsname, zfs->poolname);
+ }
+ dir = dsl_dir_alloc(zfs, dsname);
+ dir->headds = dsl_dataset_alloc(zfs, dir);
+ }
+
+ for (nextparam = param = params; nextparam != NULL;) {
+ char *key, *val;
+
+ param = strsep(&nextparam, dspropdelim);
+
+ key = val = param;
+ key = strsep(&val, "=");
+ dsl_dir_set_prop(zfs, dir, key, val);
+ }
+ }
+
+ /*
+ * Set the root dataset's mount point if the user didn't override the
+ * default.
+ */
+ if (nvpair_find(zfs->rootdsldir->propsnv, "mountpoint") == NULL) {
+ nvlist_add_string(zfs->rootdsldir->propsnv, "mountpoint",
+ zfs->rootpath);
+ }
+}
+
+uint64_t
+dsl_dir_id(zfs_dsl_dir_t *dir)
+{
+ return (dir->dirid);
+}
+
+uint64_t
+dsl_dir_dataset_id(zfs_dsl_dir_t *dir)
+{
+ return (dir->headds->dsid);
+}
+
+static void
+dsl_dir_foreach_post(zfs_opt_t *zfs, zfs_dsl_dir_t *dsldir,
+ void (*cb)(zfs_opt_t *, zfs_dsl_dir_t *, void *), void *arg)
+{
+ zfs_dsl_dir_t *cdsldir;
+
+ STAILQ_FOREACH(cdsldir, &dsldir->children, next) {
+ dsl_dir_foreach_post(zfs, cdsldir, cb, arg);
+ }
+ cb(zfs, dsldir, arg);
+}
+
+/*
+ * Used when the caller doesn't care about the order one way or another.
+ */
+void
+dsl_dir_foreach(zfs_opt_t *zfs, zfs_dsl_dir_t *dsldir,
+ void (*cb)(zfs_opt_t *, zfs_dsl_dir_t *, void *), void *arg)
+{
+ dsl_dir_foreach_post(zfs, dsldir, cb, arg);
+}
+
+const char *
+dsl_dir_fullname(const zfs_dsl_dir_t *dir)
+{
+ return (dir->fullname);
+}
+
+/*
+ * Create a DSL directory, which is effectively an entry in the ZFS namespace.
+ * We always create a root DSL directory, whose name is the pool's name, and
+ * several metadata directories.
+ *
+ * Each directory has two ZAP objects, one pointing to child directories, and
+ * one for properties (which are inherited by children unless overridden).
+ * Directories typically reference a DSL dataset, the "head dataset", which
+ * points to an object set.
+ */
+static zfs_dsl_dir_t *
+dsl_dir_alloc(zfs_opt_t *zfs, const char *name)
+{
+ zfs_dsl_dir_list_t l, *lp;
+ zfs_dsl_dir_t *dir, *parent;
+ dnode_phys_t *dnode;
+ char *dirname, *nextdir, *origname;
+ uint64_t childid, propsid;
+
+ dir = ecalloc(1, sizeof(*dir));
+
+ dnode = objset_dnode_bonus_alloc(zfs->mos, DMU_OT_DSL_DIR,
+ DMU_OT_DSL_DIR, sizeof(dsl_dir_phys_t), &dir->dirid);
+ dir->phys = (dsl_dir_phys_t *)DN_BONUS(dnode);
+
+ dnode = objset_dnode_alloc(zfs->mos, DMU_OT_DSL_PROPS, &propsid);
+ dir->propszap = zap_alloc(zfs->mos, dnode);
+
+ dnode = objset_dnode_alloc(zfs->mos, DMU_OT_DSL_DIR_CHILD_MAP,
+ &childid);
+ dir->childzap = zap_alloc(zfs->mos, dnode);
+
+ dir->propsnv = nvlist_create(NV_UNIQUE_NAME);
+ STAILQ_INIT(&dir->children);
+
+ dir->phys->dd_child_dir_zapobj = childid;
+ dir->phys->dd_props_zapobj = propsid;
+
+ if (name == NULL) {
+ /*
+ * This is the root DSL directory.
+ */
+ dir->name = estrdup(zfs->poolname);
+ dir->fullname = estrdup(zfs->poolname);
+ dir->parent = NULL;
+ dir->phys->dd_parent_obj = 0;
+
+ assert(zfs->rootdsldir == NULL);
+ zfs->rootdsldir = dir;
+ return (dir);
+ }
+
+ /*
+ * Insert the new directory into the hierarchy. Currently this must be
+ * done in order, e.g., when creating pool/a/b, pool/a must already
+ * exist.
+ */
+ STAILQ_INIT(&l);
+ STAILQ_INSERT_HEAD(&l, zfs->rootdsldir, next);
+ origname = dirname = nextdir = estrdup(name);
+ for (lp = &l;; lp = &parent->children) {
+ dirname = strsep(&nextdir, "/");
+ if (nextdir == NULL)
+ break;
+
+ STAILQ_FOREACH(parent, lp, next) {
+ if (strcmp(parent->name, dirname) == 0)
+ break;
+ }
+ if (parent == NULL) {
+ errx(1, "no parent at `%s' for filesystem `%s'",
+ dirname, name);
+ }
+ }
+
+ dir->fullname = estrdup(name);
+ dir->name = estrdup(dirname);
+ free(origname);
+ STAILQ_INSERT_TAIL(lp, dir, next);
+ zap_add_uint64(parent->childzap, dir->name, dir->dirid);
+
+ dir->parent = parent;
+ dir->phys->dd_parent_obj = parent->dirid;
+ return (dir);
+}
+
+static void
+dsl_dir_size_add(zfs_dsl_dir_t *dir, uint64_t bytes)
+{
+ dir->phys->dd_used_bytes += bytes;
+ dir->phys->dd_compressed_bytes += bytes;
+ dir->phys->dd_uncompressed_bytes += bytes;
+}
+
+/*
+ * See dsl_dir_root_finalize().
+ */
+void
+dsl_dir_root_finalize(zfs_opt_t *zfs, uint64_t bytes)
+{
+ dsl_dir_size_add(zfs->mosdsldir, bytes);
+ zfs->mosdsldir->phys->dd_used_breakdown[DD_USED_HEAD] += bytes;
+
+ dsl_dir_size_add(zfs->rootdsldir, bytes);
+ zfs->rootdsldir->phys->dd_used_breakdown[DD_USED_CHILD] += bytes;
+}
+
+/*
+ * Convert dataset properties into entries in the DSL directory's properties
+ * ZAP.
+ */
+static void
+dsl_dir_finalize_props(zfs_dsl_dir_t *dir)
+{
+ for (nvp_header_t *nvh = NULL;
+ (nvh = nvlist_next_nvpair(dir->propsnv, nvh)) != NULL;) {
+ nv_string_t *nvname;
+ nv_pair_data_t *nvdata;
+ char *name;
+
+ nvname = (nv_string_t *)(nvh + 1);
+ nvdata = (nv_pair_data_t *)(&nvname->nv_data[0] +
+ NV_ALIGN4(nvname->nv_size));
+
+ name = nvstring_get(nvname);
+ switch (nvdata->nv_type) {
+ case DATA_TYPE_UINT64: {
+ uint64_t val;
+
+ memcpy(&val, &nvdata->nv_data[0], sizeof(uint64_t));
+ zap_add_uint64(dir->propszap, name, val);
+ break;
+ }
+ case DATA_TYPE_STRING: {
+ nv_string_t *nvstr;
+ char *val;
+
+ nvstr = (nv_string_t *)&nvdata->nv_data[0];
+ val = nvstring_get(nvstr);
+ zap_add_string(dir->propszap, name, val);
+ free(val);
+ break;
+ }
+ default:
+ assert(0);
+ }
+ free(name);
+ }
+}
+
+static void
+dsl_dir_finalize(zfs_opt_t *zfs, zfs_dsl_dir_t *dir, void *arg __unused)
+{
+ char key[32];
+ zfs_dsl_dir_t *cdir;
+ dnode_phys_t *snapnames;
+ zfs_dsl_dataset_t *headds;
+ zfs_objset_t *os;
+ uint64_t bytes, childbytes, snapnamesid;
+
+ dsl_dir_finalize_props(dir);
+ zap_write(zfs, dir->propszap);
+ zap_write(zfs, dir->childzap);
+
+ headds = dir->headds;
+ if (headds == NULL)
+ return;
+ os = headds->os;
+ if (os == NULL)
+ return;
+
+ snapnames = objset_dnode_alloc(zfs->mos, DMU_OT_DSL_DS_SNAP_MAP,
+ &snapnamesid);
+ zap_write(zfs, zap_alloc(zfs->mos, snapnames));
+
+ dir->phys->dd_head_dataset_obj = headds->dsid;
+ dir->phys->dd_clone_parent_obj = zfs->snapds->dsid;
+ headds->phys->ds_prev_snap_obj = zfs->snapds->dsid;
+ headds->phys->ds_snapnames_zapobj = snapnamesid;
+ objset_root_blkptr_copy(os, &headds->phys->ds_bp);
+
+ zfs->snapds->phys->ds_num_children++;
+ snprintf(key, sizeof(key), "%jx", (uintmax_t)headds->dsid);
+ zap_add_uint64(zfs->cloneszap, key, headds->dsid);
+
+ bytes = objset_space(os);
+ headds->phys->ds_used_bytes = bytes;
+ headds->phys->ds_uncompressed_bytes = bytes;
+ headds->phys->ds_compressed_bytes = bytes;
+
+ childbytes = 0;
+ STAILQ_FOREACH(cdir, &dir->children, next) {
+ /*
+ * The root directory needs a special case: the amount of
+ * space used for the MOS isn't known until everything else is
+ * finalized, so it can't be accounted in the MOS directory's
+ * parent until then, at which point dsl_dir_root_finalize() is
+ * called.
+ */
+ if (dir == zfs->rootdsldir && cdir == zfs->mosdsldir)
+ continue;
+ childbytes += cdir->phys->dd_used_bytes;
+ }
+ dsl_dir_size_add(dir, bytes + childbytes);
+
+ dir->phys->dd_flags |= DD_FLAG_USED_BREAKDOWN;
+ dir->phys->dd_used_breakdown[DD_USED_HEAD] = bytes;
+ dir->phys->dd_used_breakdown[DD_USED_CHILD] = childbytes;
+}
+
+void
+dsl_write(zfs_opt_t *zfs)
+{
+ zfs_zap_t *snapnameszap;
+ dnode_phys_t *snapnames;
+ uint64_t snapmapid;
+
+ /*
+ * Perform accounting, starting from the leaves of the DSL directory
+ * tree. Accounting for $MOS is done later, once we've finished
+ * allocating space.
+ */
+ dsl_dir_foreach_post(zfs, zfs->rootdsldir, dsl_dir_finalize, NULL);
+
+ snapnames = objset_dnode_alloc(zfs->mos, DMU_OT_DSL_DS_SNAP_MAP,
+ &snapmapid);
+ snapnameszap = zap_alloc(zfs->mos, snapnames);
+ zap_add_uint64(snapnameszap, "$ORIGIN", zfs->snapds->dsid);
+ zap_write(zfs, snapnameszap);
+
+ zfs->origindsldir->phys->dd_head_dataset_obj = zfs->originds->dsid;
+ zfs->originds->phys->ds_prev_snap_obj = zfs->snapds->dsid;
+ zfs->originds->phys->ds_snapnames_zapobj = snapmapid;
+
+ zfs->snapds->phys->ds_next_snap_obj = zfs->originds->dsid;
+ assert(zfs->snapds->phys->ds_num_children > 0);
+ zfs->snapds->phys->ds_num_children++;
+
+ zap_write(zfs, zfs->cloneszap);
+
+ /* XXX-MJ dirs and datasets are leaked */
+}
+
+void
+dsl_dir_dataset_write(zfs_opt_t *zfs, zfs_objset_t *os, zfs_dsl_dir_t *dir)
+{
+ dir->headds->os = os;
+ objset_write(zfs, os);
+}
+
+bool
+dsl_dir_has_dataset(zfs_dsl_dir_t *dir)
+{
+ return (dir->headds != NULL);
+}
+
+bool
+dsl_dir_dataset_has_objset(zfs_dsl_dir_t *dir)
+{
+ return (dsl_dir_has_dataset(dir) && dir->headds->os != NULL);
+}
+
+static zfs_dsl_dataset_t *
+dsl_dataset_alloc(zfs_opt_t *zfs, zfs_dsl_dir_t *dir)
+{
+ zfs_dsl_dataset_t *ds;
+ dnode_phys_t *dnode;
+ uint64_t deadlistid;
+
+ ds = ecalloc(1, sizeof(*ds));
+
+ dnode = objset_dnode_bonus_alloc(zfs->mos, DMU_OT_DSL_DATASET,
+ DMU_OT_DSL_DATASET, sizeof(dsl_dataset_phys_t), &ds->dsid);
+ ds->phys = (dsl_dataset_phys_t *)DN_BONUS(dnode);
+
+ dnode = objset_dnode_bonus_alloc(zfs->mos, DMU_OT_DEADLIST,
+ DMU_OT_DEADLIST_HDR, sizeof(dsl_deadlist_phys_t), &deadlistid);
+ zap_write(zfs, zap_alloc(zfs->mos, dnode));
+
+ ds->phys->ds_dir_obj = dir->dirid;
+ ds->phys->ds_deadlist_obj = deadlistid;
+ ds->phys->ds_creation_txg = TXG - 1;
+ if (ds != zfs->snapds)
+ ds->phys->ds_prev_snap_txg = TXG - 1;
+ ds->phys->ds_guid = randomguid();
+ ds->dir = dir;
+
+ return (ds);
+}
diff --git a/usr.sbin/makefs/zfs/fs.c b/usr.sbin/makefs/zfs/fs.c
new file mode 100644
index 000000000000..9413241da0c7
--- /dev/null
+++ b/usr.sbin/makefs/zfs/fs.c
@@ -0,0 +1,1082 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 The FreeBSD Foundation
+ *
+ * This software was developed by Mark Johnston under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/stat.h>
+
+#include <assert.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <util.h>
+
+#include "makefs.h"
+#include "zfs.h"
+
+typedef struct {
+ const char *name;
+ unsigned int id;
+ uint16_t size;
+ sa_bswap_type_t bs;
+} zfs_sattr_t;
+
+typedef struct zfs_fs {
+ zfs_objset_t *os;
+
+ /* Offset table for system attributes, indexed by a zpl_attr_t. */
+ uint16_t *saoffs;
+ size_t sacnt;
+ const zfs_sattr_t *satab;
+} zfs_fs_t;
+
+/*
+ * The order of the attributes doesn't matter, this is simply the one hard-coded
+ * by OpenZFS, based on a zdb dump of the SA_REGISTRY table.
+ */
+typedef enum zpl_attr {
+ ZPL_ATIME,
+ ZPL_MTIME,
+ ZPL_CTIME,
+ ZPL_CRTIME,
+ ZPL_GEN,
+ ZPL_MODE,
+ ZPL_SIZE,
+ ZPL_PARENT,
+ ZPL_LINKS,
+ ZPL_XATTR,
+ ZPL_RDEV,
+ ZPL_FLAGS,
+ ZPL_UID,
+ ZPL_GID,
+ ZPL_PAD,
+ ZPL_ZNODE_ACL,
+ ZPL_DACL_COUNT,
+ ZPL_SYMLINK,
+ ZPL_SCANSTAMP,
+ ZPL_DACL_ACES,
+ ZPL_DXATTR,
+ ZPL_PROJID,
+} zpl_attr_t;
+
+/*
+ * This table must be kept in sync with zpl_attr_layout[] and zpl_attr_t.
+ */
+static const zfs_sattr_t zpl_attrs[] = {
+#define _ZPL_ATTR(n, s, b) { .name = #n, .id = n, .size = s, .bs = b }
+ _ZPL_ATTR(ZPL_ATIME, sizeof(uint64_t) * 2, SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_MTIME, sizeof(uint64_t) * 2, SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_CTIME, sizeof(uint64_t) * 2, SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_CRTIME, sizeof(uint64_t) * 2, SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_GEN, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_MODE, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_SIZE, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_PARENT, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_LINKS, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_XATTR, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_RDEV, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_FLAGS, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_UID, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_GID, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_PAD, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_ZNODE_ACL, 88, SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_DACL_COUNT, sizeof(uint64_t), SA_UINT64_ARRAY),
+ _ZPL_ATTR(ZPL_SYMLINK, 0, SA_UINT8_ARRAY),
+ _ZPL_ATTR(ZPL_SCANSTAMP, sizeof(uint64_t) * 4, SA_UINT8_ARRAY),
+ _ZPL_ATTR(ZPL_DACL_ACES, 0, SA_ACL),
+ _ZPL_ATTR(ZPL_DXATTR, 0, SA_UINT8_ARRAY),
+ _ZPL_ATTR(ZPL_PROJID, sizeof(uint64_t), SA_UINT64_ARRAY),
+#undef ZPL_ATTR
+};
+
+/*
+ * This layout matches that of a filesystem created using OpenZFS on FreeBSD.
+ * It need not match in general, but FreeBSD's loader doesn't bother parsing the
+ * layout and just hard-codes attribute offsets.
+ */
+static const sa_attr_type_t zpl_attr_layout[] = {
+ ZPL_MODE,
+ ZPL_SIZE,
+ ZPL_GEN,
+ ZPL_UID,
+ ZPL_GID,
+ ZPL_PARENT,
+ ZPL_FLAGS,
+ ZPL_ATIME,
+ ZPL_MTIME,
+ ZPL_CTIME,
+ ZPL_CRTIME,
+ ZPL_LINKS,
+ ZPL_DACL_COUNT,
+ ZPL_DACL_ACES,
+ ZPL_SYMLINK,
+};
+
+/*
+ * Keys for the ZPL attribute tables in the SA layout ZAP. The first two
+ * indices are reserved for legacy attribute encoding.
+ */
+#define SA_LAYOUT_INDEX_DEFAULT 2
+#define SA_LAYOUT_INDEX_SYMLINK 3
+
+struct fs_populate_dir {
+ SLIST_ENTRY(fs_populate_dir) next;
+ int dirfd;
+ uint64_t objid;
+ zfs_zap_t *zap;
+};
+
+struct fs_populate_arg {
+ zfs_opt_t *zfs;
+ zfs_fs_t *fs; /* owning filesystem */
+ uint64_t rootdirid; /* root directory dnode ID */
+ int rootdirfd; /* root directory fd */
+ SLIST_HEAD(, fs_populate_dir) dirs; /* stack of directories */
+};
+
+static void fs_build_one(zfs_opt_t *, zfs_dsl_dir_t *, fsnode *, int);
+
+static void
+eclose(int fd)
+{
+ if (close(fd) != 0)
+ err(1, "close");
+}
+
+static bool
+fsnode_isroot(const fsnode *cur)
+{
+ return (strcmp(cur->name, ".") == 0);
+}
+
+/*
+ * Visit each node in a directory hierarchy, in pre-order depth-first order.
+ */
+static void
+fsnode_foreach(fsnode *root, int (*cb)(fsnode *, void *), void *arg)
+{
+ assert(root->type == S_IFDIR);
+
+ for (fsnode *cur = root; cur != NULL; cur = cur->next) {
+ assert(cur->type == S_IFREG || cur->type == S_IFDIR ||
+ cur->type == S_IFLNK);
+
+ if (cb(cur, arg) == 0)
+ continue;
+ if (cur->type == S_IFDIR && cur->child != NULL)
+ fsnode_foreach(cur->child, cb, arg);
+ }
+}
+
+static void
+fs_populate_dirent(struct fs_populate_arg *arg, fsnode *cur, uint64_t dnid)
+{
+ struct fs_populate_dir *dir;
+ uint64_t type;
+
+ switch (cur->type) {
+ case S_IFREG:
+ type = DT_REG;
+ break;
+ case S_IFDIR:
+ type = DT_DIR;
+ break;
+ case S_IFLNK:
+ type = DT_LNK;
+ break;
+ default:
+ assert(0);
+ }
+
+ dir = SLIST_FIRST(&arg->dirs);
+ zap_add_uint64(dir->zap, cur->name, ZFS_DIRENT_MAKE(type, dnid));
+}
+
+static void
+fs_populate_attr(zfs_fs_t *fs, char *attrbuf, const void *val, uint16_t ind,
+ size_t *szp)
+{
+ assert(ind < fs->sacnt);
+ assert(fs->saoffs[ind] != 0xffff);
+
+ memcpy(attrbuf + fs->saoffs[ind], val, fs->satab[ind].size);
+ *szp += fs->satab[ind].size;
+}
+
+static void
+fs_populate_varszattr(zfs_fs_t *fs, char *attrbuf, const void *val,
+ size_t valsz, size_t varoff, uint16_t ind, size_t *szp)
+{
+ assert(ind < fs->sacnt);
+ assert(fs->saoffs[ind] != 0xffff);
+ assert(fs->satab[ind].size == 0);
+
+ memcpy(attrbuf + fs->saoffs[ind] + varoff, val, valsz);
+ *szp += valsz;
+}
+
+/*
+ * Derive the relative fd/path combo needed to access a file. Ideally we'd
+ * always be able to use relative lookups (i.e., use the *at() system calls),
+ * since they require less path translation and are more amenable to sandboxing,
+ * but the handling of multiple staging directories makes that difficult. To
+ * make matters worse, we have no choice but to use relative lookups when
+ * dealing with an mtree manifest, so both mechanisms are implemented.
+ */
+static void
+fs_populate_path(const fsnode *cur, struct fs_populate_arg *arg,
+ char *path, size_t sz, int *dirfdp)
+{
+ if (cur->contents != NULL) {
+ size_t n;
+
+ *dirfdp = AT_FDCWD;
+ n = strlcpy(path, cur->contents, sz);
+ assert(n < sz);
+ } else if (cur->root == NULL) {
+ size_t n;
+
+ *dirfdp = SLIST_FIRST(&arg->dirs)->dirfd;
+ n = strlcpy(path, cur->name, sz);
+ assert(n < sz);
+ } else {
+ int n;
+
+ *dirfdp = AT_FDCWD;
+ n = snprintf(path, sz, "%s/%s/%s",
+ cur->root, cur->path, cur->name);
+ assert(n >= 0);
+ assert((size_t)n < sz);
+ }
+}
+
+static int
+fs_open(const fsnode *cur, struct fs_populate_arg *arg, int flags)
+{
+ char path[PATH_MAX];
+ int fd;
+
+ fs_populate_path(cur, arg, path, sizeof(path), &fd);
+
+ fd = openat(fd, path, flags);
+ if (fd < 0)
+ err(1, "openat(%s)", path);
+ return (fd);
+}
+
+static int
+fs_open_can_fail(const fsnode *cur, struct fs_populate_arg *arg, int flags)
+{
+ int fd;
+ char path[PATH_MAX];
+
+ fs_populate_path(cur, arg, path, sizeof(path), &fd);
+
+ return (openat(fd, path, flags));
+}
+
+static void
+fs_readlink(const fsnode *cur, struct fs_populate_arg *arg,
+ char *buf, size_t bufsz)
+{
+ char path[PATH_MAX];
+ int fd;
+
+ if (cur->symlink != NULL) {
+ size_t n;
+
+ n = strlcpy(buf, cur->symlink, bufsz);
+ assert(n < bufsz);
+ } else {
+ ssize_t n;
+
+ fs_populate_path(cur, arg, path, sizeof(path), &fd);
+
+ n = readlinkat(fd, path, buf, bufsz - 1);
+ if (n == -1)
+ err(1, "readlinkat(%s)", cur->name);
+ buf[n] = '\0';
+ }
+}
+
+static void
+fs_populate_time(zfs_fs_t *fs, char *attrbuf, struct timespec *ts,
+ uint16_t ind, size_t *szp)
+{
+ uint64_t timebuf[2];
+
+ assert(ind < fs->sacnt);
+ assert(fs->saoffs[ind] != 0xffff);
+ assert(fs->satab[ind].size == sizeof(timebuf));
+
+ timebuf[0] = ts->tv_sec;
+ timebuf[1] = ts->tv_nsec;
+ fs_populate_attr(fs, attrbuf, timebuf, ind, szp);
+}
+
+static void
+fs_populate_sattrs(struct fs_populate_arg *arg, const fsnode *cur,
+ dnode_phys_t *dnode)
+{
+ char target[PATH_MAX];
+ zfs_fs_t *fs;
+ zfs_ace_hdr_t aces[3];
+ struct stat *sb;
+ sa_hdr_phys_t *sahdr;
+ uint64_t daclcount, flags, gen, gid, links, mode, parent, objsize, uid;
+ char *attrbuf;
+ size_t bonussz, hdrsz;
+ int layout;
+
+ assert(dnode->dn_bonustype == DMU_OT_SA);
+ assert(dnode->dn_nblkptr == 1);
+
+ fs = arg->fs;
+ sb = &cur->inode->st;
+
+ switch (cur->type) {
+ case S_IFREG:
+ layout = SA_LAYOUT_INDEX_DEFAULT;
+ links = cur->inode->nlink;
+ objsize = sb->st_size;
+ parent = SLIST_FIRST(&arg->dirs)->objid;
+ break;
+ case S_IFDIR:
+ layout = SA_LAYOUT_INDEX_DEFAULT;
+ links = 1; /* .. */
+ objsize = 1; /* .. */
+
+ /*
+ * The size of a ZPL directory is the number of entries
+ * (including "." and ".."), and the link count is the number of
+ * entries which are directories (including "." and "..").
+ */
+ for (fsnode *c = fsnode_isroot(cur) ? cur->next : cur->child;
+ c != NULL; c = c->next) {
+ if (c->type == S_IFDIR)
+ links++;
+ objsize++;
+ }
+
+ /* The root directory is its own parent. */
+ parent = SLIST_EMPTY(&arg->dirs) ?
+ arg->rootdirid : SLIST_FIRST(&arg->dirs)->objid;
+ break;
+ case S_IFLNK:
+ fs_readlink(cur, arg, target, sizeof(target));
+
+ layout = SA_LAYOUT_INDEX_SYMLINK;
+ links = 1;
+ objsize = strlen(target);
+ parent = SLIST_FIRST(&arg->dirs)->objid;
+ break;
+ default:
+ assert(0);
+ }
+
+ daclcount = nitems(aces);
+ flags = ZFS_ACL_TRIVIAL | ZFS_ACL_AUTO_INHERIT | ZFS_ARCHIVE |
+ ZFS_AV_MODIFIED;
+ gen = 1;
+ gid = sb->st_gid;
+ mode = sb->st_mode;
+ uid = sb->st_uid;
+
+ memset(aces, 0, sizeof(aces));
+ aces[0].z_flags = ACE_OWNER;
+ aces[0].z_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ aces[0].z_access_mask = ACE_WRITE_ATTRIBUTES | ACE_WRITE_OWNER |
+ ACE_WRITE_ACL | ACE_WRITE_NAMED_ATTRS | ACE_READ_ACL |
+ ACE_READ_ATTRIBUTES | ACE_READ_NAMED_ATTRS | ACE_SYNCHRONIZE;
+ if ((mode & S_IRUSR) != 0)
+ aces[0].z_access_mask |= ACE_READ_DATA;
+ if ((mode & S_IWUSR) != 0)
+ aces[0].z_access_mask |= ACE_WRITE_DATA | ACE_APPEND_DATA;
+ if ((mode & S_IXUSR) != 0)
+ aces[0].z_access_mask |= ACE_EXECUTE;
+
+ aces[1].z_flags = ACE_GROUP | ACE_IDENTIFIER_GROUP;
+ aces[1].z_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ aces[1].z_access_mask = ACE_READ_ACL | ACE_READ_ATTRIBUTES |
+ ACE_READ_NAMED_ATTRS | ACE_SYNCHRONIZE;
+ if ((mode & S_IRGRP) != 0)
+ aces[1].z_access_mask |= ACE_READ_DATA;
+ if ((mode & S_IWGRP) != 0)
+ aces[1].z_access_mask |= ACE_WRITE_DATA | ACE_APPEND_DATA;
+ if ((mode & S_IXGRP) != 0)
+ aces[1].z_access_mask |= ACE_EXECUTE;
+
+ aces[2].z_flags = ACE_EVERYONE;
+ aces[2].z_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ aces[2].z_access_mask = ACE_READ_ACL | ACE_READ_ATTRIBUTES |
+ ACE_READ_NAMED_ATTRS | ACE_SYNCHRONIZE;
+ if ((mode & S_IROTH) != 0)
+ aces[2].z_access_mask |= ACE_READ_DATA;
+ if ((mode & S_IWOTH) != 0)
+ aces[2].z_access_mask |= ACE_WRITE_DATA | ACE_APPEND_DATA;
+ if ((mode & S_IXOTH) != 0)
+ aces[2].z_access_mask |= ACE_EXECUTE;
+
+ switch (layout) {
+ case SA_LAYOUT_INDEX_DEFAULT:
+ /* At most one variable-length attribute. */
+ hdrsz = sizeof(uint64_t);
+ break;
+ case SA_LAYOUT_INDEX_SYMLINK:
+ /* At most five variable-length attributes. */
+ hdrsz = sizeof(uint64_t) * 2;
+ break;
+ default:
+ assert(0);
+ }
+
+ sahdr = (sa_hdr_phys_t *)DN_BONUS(dnode);
+ sahdr->sa_magic = SA_MAGIC;
+ SA_HDR_LAYOUT_INFO_ENCODE(sahdr->sa_layout_info, layout, hdrsz);
+
+ bonussz = SA_HDR_SIZE(sahdr);
+ attrbuf = (char *)sahdr + SA_HDR_SIZE(sahdr);
+
+ fs_populate_attr(fs, attrbuf, &daclcount, ZPL_DACL_COUNT, &bonussz);
+ fs_populate_attr(fs, attrbuf, &flags, ZPL_FLAGS, &bonussz);
+ fs_populate_attr(fs, attrbuf, &gen, ZPL_GEN, &bonussz);
+ fs_populate_attr(fs, attrbuf, &gid, ZPL_GID, &bonussz);
+ fs_populate_attr(fs, attrbuf, &links, ZPL_LINKS, &bonussz);
+ fs_populate_attr(fs, attrbuf, &mode, ZPL_MODE, &bonussz);
+ fs_populate_attr(fs, attrbuf, &parent, ZPL_PARENT, &bonussz);
+ fs_populate_attr(fs, attrbuf, &objsize, ZPL_SIZE, &bonussz);
+ fs_populate_attr(fs, attrbuf, &uid, ZPL_UID, &bonussz);
+
+ /*
+ * We deliberately set atime = mtime here to ensure that images are
+ * reproducible.
+ */
+ fs_populate_time(fs, attrbuf, &sb->st_mtim, ZPL_ATIME, &bonussz);
+ fs_populate_time(fs, attrbuf, &sb->st_ctim, ZPL_CTIME, &bonussz);
+ fs_populate_time(fs, attrbuf, &sb->st_mtim, ZPL_MTIME, &bonussz);
+#ifdef __linux__
+ /* Linux has no st_birthtim; approximate with st_ctim */
+ fs_populate_time(fs, attrbuf, &sb->st_ctim, ZPL_CRTIME, &bonussz);
+#else
+ fs_populate_time(fs, attrbuf, &sb->st_birthtim, ZPL_CRTIME, &bonussz);
+#endif
+
+ fs_populate_varszattr(fs, attrbuf, aces, sizeof(aces), 0,
+ ZPL_DACL_ACES, &bonussz);
+ sahdr->sa_lengths[0] = sizeof(aces);
+
+ if (cur->type == S_IFLNK) {
+ assert(layout == SA_LAYOUT_INDEX_SYMLINK);
+ /* Need to use a spill block pointer if the target is long. */
+ assert(bonussz + objsize <= DN_OLD_MAX_BONUSLEN);
+ fs_populate_varszattr(fs, attrbuf, target, objsize,
+ sahdr->sa_lengths[0], ZPL_SYMLINK, &bonussz);
+ sahdr->sa_lengths[1] = (uint16_t)objsize;
+ }
+
+ dnode->dn_bonuslen = bonussz;
+}
+
+static void
+fs_populate_file(fsnode *cur, struct fs_populate_arg *arg)
+{
+ struct dnode_cursor *c;
+ dnode_phys_t *dnode;
+ zfs_opt_t *zfs;
+ char *buf;
+ uint64_t dnid;
+ ssize_t n;
+ size_t bufsz;
+ off_t nbytes, reqbytes, size;
+ int fd;
+
+ assert(cur->type == S_IFREG);
+ assert((cur->inode->flags & FI_ROOT) == 0);
+
+ zfs = arg->zfs;
+
+ assert(cur->inode->ino != 0);
+ if ((cur->inode->flags & FI_ALLOCATED) != 0) {
+ /*
+ * This is a hard link of an existing file.
+ *
+ * XXX-MJ need to check whether it crosses datasets, add a test
+ * case for that
+ */
+ fs_populate_dirent(arg, cur, cur->inode->ino);
+ return;
+ }
+
+ dnode = objset_dnode_bonus_alloc(arg->fs->os,
+ DMU_OT_PLAIN_FILE_CONTENTS, DMU_OT_SA, 0, &dnid);
+ cur->inode->ino = dnid;
+ cur->inode->flags |= FI_ALLOCATED;
+
+ fd = fs_open(cur, arg, O_RDONLY);
+
+ buf = zfs->filebuf;
+ bufsz = sizeof(zfs->filebuf);
+ size = cur->inode->st.st_size;
+ c = dnode_cursor_init(zfs, arg->fs->os, dnode, size, 0);
+ for (off_t foff = 0; foff < size; foff += nbytes) {
+ off_t loc, sofar;
+
+ /*
+ * Fill up our buffer, handling partial reads.
+ */
+ sofar = 0;
+ nbytes = MIN(size - foff, (off_t)bufsz);
+ do {
+ n = read(fd, buf + sofar, nbytes);
+ if (n < 0)
+ err(1, "reading from '%s'", cur->name);
+ if (n == 0)
+ errx(1, "unexpected EOF reading '%s'",
+ cur->name);
+ sofar += n;
+ } while (sofar < nbytes);
+
+ if (nbytes < (off_t)bufsz)
+ memset(buf + nbytes, 0, bufsz - nbytes);
+
+ reqbytes = foff == 0 ? nbytes : MAXBLOCKSIZE;
+ loc = objset_space_alloc(zfs, arg->fs->os, &reqbytes);
+ vdev_pwrite_dnode_indir(zfs, dnode, 0, 1, buf, reqbytes, loc,
+ dnode_cursor_next(zfs, c, foff));
+ }
+ eclose(fd);
+ dnode_cursor_finish(zfs, c);
+
+ fs_populate_sattrs(arg, cur, dnode);
+ fs_populate_dirent(arg, cur, dnid);
+}
+
+static void
+fs_populate_dir(fsnode *cur, struct fs_populate_arg *arg)
+{
+ dnode_phys_t *dnode;
+ zfs_objset_t *os;
+ uint64_t dnid;
+ int dirfd;
+
+ assert(cur->type == S_IFDIR);
+ assert((cur->inode->flags & FI_ALLOCATED) == 0);
+
+ os = arg->fs->os;
+
+ dnode = objset_dnode_bonus_alloc(os, DMU_OT_DIRECTORY_CONTENTS,
+ DMU_OT_SA, 0, &dnid);
+
+ /*
+ * Add an entry to the parent directory and open this directory.
+ */
+ if (!SLIST_EMPTY(&arg->dirs)) {
+ fs_populate_dirent(arg, cur, dnid);
+ /*
+ * We only need the directory fd if we're finding files in
+ * it. If it's just there for other directories or
+ * files using contents= we don't need to succeed here.
+ */
+ dirfd = fs_open_can_fail(cur, arg, O_DIRECTORY | O_RDONLY);
+ } else {
+ arg->rootdirid = dnid;
+ dirfd = arg->rootdirfd;
+ arg->rootdirfd = -1;
+ }
+
+ /*
+ * Set ZPL attributes.
+ */
+ fs_populate_sattrs(arg, cur, dnode);
+
+ /*
+ * If this is a root directory, then its children belong to a different
+ * dataset and this directory remains empty in the current objset.
+ */
+ if ((cur->inode->flags & FI_ROOT) == 0) {
+ struct fs_populate_dir *dir;
+
+ dir = ecalloc(1, sizeof(*dir));
+ dir->dirfd = dirfd;
+ dir->objid = dnid;
+ dir->zap = zap_alloc(os, dnode);
+ SLIST_INSERT_HEAD(&arg->dirs, dir, next);
+ } else {
+ zap_write(arg->zfs, zap_alloc(os, dnode));
+ fs_build_one(arg->zfs, cur->inode->param, cur->child, dirfd);
+ }
+}
+
+static void
+fs_populate_symlink(fsnode *cur, struct fs_populate_arg *arg)
+{
+ dnode_phys_t *dnode;
+ uint64_t dnid;
+
+ assert(cur->type == S_IFLNK);
+ assert((cur->inode->flags & (FI_ALLOCATED | FI_ROOT)) == 0);
+
+ dnode = objset_dnode_bonus_alloc(arg->fs->os,
+ DMU_OT_PLAIN_FILE_CONTENTS, DMU_OT_SA, 0, &dnid);
+
+ fs_populate_dirent(arg, cur, dnid);
+
+ fs_populate_sattrs(arg, cur, dnode);
+}
+
+static int
+fs_foreach_populate(fsnode *cur, void *_arg)
+{
+ struct fs_populate_arg *arg;
+ struct fs_populate_dir *dir;
+ int ret;
+
+ arg = _arg;
+ switch (cur->type) {
+ case S_IFREG:
+ fs_populate_file(cur, arg);
+ break;
+ case S_IFDIR:
+ if (fsnode_isroot(cur))
+ break;
+ fs_populate_dir(cur, arg);
+ break;
+ case S_IFLNK:
+ fs_populate_symlink(cur, arg);
+ break;
+ default:
+ assert(0);
+ }
+
+ ret = (cur->inode->flags & FI_ROOT) != 0 ? 0 : 1;
+
+ if (cur->next == NULL &&
+ (cur->child == NULL || (cur->inode->flags & FI_ROOT) != 0)) {
+ /*
+ * We reached a terminal node in a subtree. Walk back up and
+ * write out directories. We're done once we hit the root of a
+ * dataset or find a level where we're not on the edge of the
+ * tree.
+ */
+ do {
+ dir = SLIST_FIRST(&arg->dirs);
+ SLIST_REMOVE_HEAD(&arg->dirs, next);
+ zap_write(arg->zfs, dir->zap);
+ if (dir->dirfd != -1)
+ eclose(dir->dirfd);
+ free(dir);
+ cur = cur->parent;
+ } while (cur != NULL && cur->next == NULL &&
+ (cur->inode->flags & FI_ROOT) == 0);
+ }
+
+ return (ret);
+}
+
+static void
+fs_add_zpl_attr_layout(zfs_zap_t *zap, unsigned int index,
+ const sa_attr_type_t layout[], size_t sacnt)
+{
+ char ti[16];
+
+ assert(sizeof(layout[0]) == 2);
+
+ snprintf(ti, sizeof(ti), "%u", index);
+ zap_add(zap, ti, sizeof(sa_attr_type_t), sacnt,
+ (const uint8_t *)layout);
+}
+
+/*
+ * Initialize system attribute tables.
+ *
+ * There are two elements to this. First, we write the zpl_attrs[] and
+ * zpl_attr_layout[] tables to disk. Then we create a lookup table which
+ * allows us to set file attributes quickly.
+ */
+static uint64_t
+fs_set_zpl_attrs(zfs_opt_t *zfs, zfs_fs_t *fs)
+{
+ zfs_zap_t *sazap, *salzap, *sarzap;
+ zfs_objset_t *os;
+ dnode_phys_t *saobj, *salobj, *sarobj;
+ uint64_t saobjid, salobjid, sarobjid;
+ uint16_t offset;
+
+ os = fs->os;
+
+ /*
+ * The on-disk tables are stored in two ZAP objects, the registry object
+ * and the layout object. Individual attributes are described by
+ * entries in the registry object; for example, the value for the
+ * "ZPL_SIZE" key gives the size and encoding of the ZPL_SIZE attribute.
+ * The attributes of a file are ordered according to one of the layouts
+ * defined in the layout object. The master node object is simply used
+ * to locate the registry and layout objects.
+ */
+ saobj = objset_dnode_alloc(os, DMU_OT_SA_MASTER_NODE, &saobjid);
+ salobj = objset_dnode_alloc(os, DMU_OT_SA_ATTR_LAYOUTS, &salobjid);
+ sarobj = objset_dnode_alloc(os, DMU_OT_SA_ATTR_REGISTRATION, &sarobjid);
+
+ sarzap = zap_alloc(os, sarobj);
+ for (size_t i = 0; i < nitems(zpl_attrs); i++) {
+ const zfs_sattr_t *sa;
+ uint64_t attr;
+
+ attr = 0;
+ sa = &zpl_attrs[i];
+ SA_ATTR_ENCODE(attr, (uint64_t)i, sa->size, sa->bs);
+ zap_add_uint64(sarzap, sa->name, attr);
+ }
+ zap_write(zfs, sarzap);
+
+ /*
+ * Layouts are arrays of indices into the registry. We define two
+ * layouts for use by the ZPL, one for non-symlinks and one for
+ * symlinks. They are identical except that the symlink layout includes
+ * ZPL_SYMLINK as its final attribute.
+ */
+ salzap = zap_alloc(os, salobj);
+ assert(zpl_attr_layout[nitems(zpl_attr_layout) - 1] == ZPL_SYMLINK);
+ fs_add_zpl_attr_layout(salzap, SA_LAYOUT_INDEX_DEFAULT,
+ zpl_attr_layout, nitems(zpl_attr_layout) - 1);
+ fs_add_zpl_attr_layout(salzap, SA_LAYOUT_INDEX_SYMLINK,
+ zpl_attr_layout, nitems(zpl_attr_layout));
+ zap_write(zfs, salzap);
+
+ sazap = zap_alloc(os, saobj);
+ zap_add_uint64(sazap, SA_LAYOUTS, salobjid);
+ zap_add_uint64(sazap, SA_REGISTRY, sarobjid);
+ zap_write(zfs, sazap);
+
+ /* Sanity check. */
+ for (size_t i = 0; i < nitems(zpl_attrs); i++)
+ assert(i == zpl_attrs[i].id);
+
+ /*
+ * Build the offset table used when setting file attributes. File
+ * attributes are stored in the object's bonus buffer; this table
+ * provides the buffer offset of attributes referenced by the layout
+ * table.
+ */
+ fs->sacnt = nitems(zpl_attrs);
+ fs->saoffs = ecalloc(fs->sacnt, sizeof(*fs->saoffs));
+ for (size_t i = 0; i < fs->sacnt; i++)
+ fs->saoffs[i] = 0xffff;
+ offset = 0;
+ for (size_t i = 0; i < nitems(zpl_attr_layout); i++) {
+ uint16_t size;
+
+ assert(zpl_attr_layout[i] < fs->sacnt);
+
+ fs->saoffs[zpl_attr_layout[i]] = offset;
+ size = zpl_attrs[zpl_attr_layout[i]].size;
+ offset += size;
+ }
+ fs->satab = zpl_attrs;
+
+ return (saobjid);
+}
+
+static void
+fs_layout_one(zfs_opt_t *zfs, zfs_dsl_dir_t *dsldir, void *arg)
+{
+ char *mountpoint, *origmountpoint, *name, *next;
+ fsnode *cur, *root;
+ uint64_t canmount;
+
+ if (!dsl_dir_has_dataset(dsldir))
+ return;
+
+ if (dsl_dir_get_canmount(dsldir, &canmount) == 0 && canmount == 0)
+ return;
+ mountpoint = dsl_dir_get_mountpoint(zfs, dsldir);
+ if (mountpoint == NULL)
+ return;
+
+ /*
+ * If we were asked to specify a bootfs, set it here.
+ */
+ if (zfs->bootfs != NULL && strcmp(zfs->bootfs,
+ dsl_dir_fullname(dsldir)) == 0) {
+ zap_add_uint64(zfs->poolprops, "bootfs",
+ dsl_dir_dataset_id(dsldir));
+ }
+
+ origmountpoint = mountpoint;
+
+ /*
+ * Figure out which fsnode corresponds to our mountpoint.
+ */
+ root = arg;
+ cur = root;
+ if (strcmp(mountpoint, zfs->rootpath) != 0) {
+ mountpoint += strlen(zfs->rootpath);
+
+ /*
+ * Look up the directory in the staged tree. For example, if
+ * the dataset's mount point is /foo/bar/baz, we'll search the
+ * root directory for "foo", search "foo" for "baz", and so on.
+ * Each intermediate name must refer to a directory; the final
+ * component need not exist.
+ */
+ cur = root;
+ for (next = name = mountpoint; next != NULL;) {
+ for (; *next == '/'; next++)
+ ;
+ name = strsep(&next, "/");
+
+ for (; cur != NULL && strcmp(cur->name, name) != 0;
+ cur = cur->next)
+ ;
+ if (cur == NULL) {
+ if (next == NULL)
+ break;
+ errx(1, "missing mountpoint directory for `%s'",
+ dsl_dir_fullname(dsldir));
+ }
+ if (cur->type != S_IFDIR) {
+ errx(1,
+ "mountpoint for `%s' is not a directory",
+ dsl_dir_fullname(dsldir));
+ }
+ if (next != NULL)
+ cur = cur->child;
+ }
+ }
+
+ if (cur != NULL) {
+ assert(cur->type == S_IFDIR);
+
+ /*
+ * Multiple datasets shouldn't share a mountpoint. It's
+ * technically allowed, but it's not clear what makefs should do
+ * in that case.
+ */
+ assert((cur->inode->flags & FI_ROOT) == 0);
+ if (cur != root)
+ cur->inode->flags |= FI_ROOT;
+ assert(cur->inode->param == NULL);
+ cur->inode->param = dsldir;
+ }
+
+ free(origmountpoint);
+}
+
+static int
+fs_foreach_mark(fsnode *cur, void *arg)
+{
+ uint64_t *countp;
+
+ countp = arg;
+ if (cur->type == S_IFDIR && fsnode_isroot(cur))
+ return (1);
+
+ if (cur->inode->ino == 0) {
+ cur->inode->ino = ++(*countp);
+ cur->inode->nlink = 1;
+ } else {
+ cur->inode->nlink++;
+ }
+
+ return ((cur->inode->flags & FI_ROOT) != 0 ? 0 : 1);
+}
+
+/*
+ * Create a filesystem dataset. More specifically:
+ * - create an object set for the dataset,
+ * - add required metadata (SA tables, property definitions, etc.) to that
+ * object set,
+ * - optionally populate the object set with file objects, using "root" as the
+ * root directory.
+ *
+ * "dirfd" is a directory descriptor for the directory referenced by "root". It
+ * is closed before returning.
+ */
+static void
+fs_build_one(zfs_opt_t *zfs, zfs_dsl_dir_t *dsldir, fsnode *root, int dirfd)
+{
+ struct fs_populate_arg arg;
+ zfs_fs_t fs;
+ zfs_zap_t *masterzap;
+ zfs_objset_t *os;
+ dnode_phys_t *deleteq, *masterobj;
+ uint64_t deleteqid, dnodecount, moid, rootdirid, saobjid;
+ bool fakedroot;
+
+ /*
+ * This dataset's mountpoint doesn't exist in the staging tree, or the
+ * dataset doesn't have a mountpoint at all. In either case we still
+ * need a root directory. Fake up a root fsnode to handle this case.
+ */
+ fakedroot = root == NULL;
+ if (fakedroot) {
+ struct stat *stp;
+
+ assert(dirfd == -1);
+
+ root = ecalloc(1, sizeof(*root));
+ root->inode = ecalloc(1, sizeof(*root->inode));
+ root->name = estrdup(".");
+ root->type = S_IFDIR;
+
+ stp = &root->inode->st;
+ stp->st_uid = 0;
+ stp->st_gid = 0;
+ stp->st_mode = S_IFDIR | 0755;
+ }
+ assert(root->type == S_IFDIR);
+ assert(fsnode_isroot(root));
+
+ /*
+ * Initialize the object set for this dataset.
+ */
+ os = objset_alloc(zfs, DMU_OST_ZFS);
+ masterobj = objset_dnode_alloc(os, DMU_OT_MASTER_NODE, &moid);
+ assert(moid == MASTER_NODE_OBJ);
+
+ memset(&fs, 0, sizeof(fs));
+ fs.os = os;
+
+ /*
+ * Create the ZAP SA layout now since filesystem object dnodes will
+ * refer to those attributes.
+ */
+ saobjid = fs_set_zpl_attrs(zfs, &fs);
+
+ /*
+ * Make a pass over the staged directory to detect hard links and assign
+ * virtual dnode numbers.
+ */
+ dnodecount = 1; /* root directory */
+ fsnode_foreach(root, fs_foreach_mark, &dnodecount);
+
+ /*
+ * Make a second pass to populate the dataset with files from the
+ * staged directory. Most of our runtime is spent here.
+ */
+ arg.rootdirfd = dirfd;
+ arg.zfs = zfs;
+ arg.fs = &fs;
+ SLIST_INIT(&arg.dirs);
+ fs_populate_dir(root, &arg);
+ assert(!SLIST_EMPTY(&arg.dirs));
+ fsnode_foreach(root, fs_foreach_populate, &arg);
+ assert(SLIST_EMPTY(&arg.dirs));
+ rootdirid = arg.rootdirid;
+
+ /*
+ * Create an empty delete queue. We don't do anything with it, but
+ * OpenZFS will refuse to mount filesystems that don't have one.
+ */
+ deleteq = objset_dnode_alloc(os, DMU_OT_UNLINKED_SET, &deleteqid);
+ zap_write(zfs, zap_alloc(os, deleteq));
+
+ /*
+ * Populate and write the master node object. This is a ZAP object
+ * containing various dataset properties and the object IDs of the root
+ * directory and delete queue.
+ */
+ masterzap = zap_alloc(os, masterobj);
+ zap_add_uint64(masterzap, ZFS_ROOT_OBJ, rootdirid);
+ zap_add_uint64(masterzap, ZFS_UNLINKED_SET, deleteqid);
+ zap_add_uint64(masterzap, ZFS_SA_ATTRS, saobjid);
+ zap_add_uint64(masterzap, ZPL_VERSION_OBJ, 5 /* ZPL_VERSION_SA */);
+ zap_add_uint64(masterzap, "normalization", 0 /* off */);
+ zap_add_uint64(masterzap, "utf8only", 0 /* off */);
+ zap_add_uint64(masterzap, "casesensitivity", 0 /* case sensitive */);
+ zap_add_uint64(masterzap, "acltype", 2 /* NFSv4 */);
+ zap_write(zfs, masterzap);
+
+ /*
+ * All finished with this object set, we may as well write it now.
+ * The DSL layer will sum up the bytes consumed by each dataset using
+ * information stored in the object set, so it can't be freed just yet.
+ */
+ dsl_dir_dataset_write(zfs, os, dsldir);
+
+ if (fakedroot) {
+ free(root->inode);
+ free(root->name);
+ free(root);
+ }
+ free(fs.saoffs);
+}
+
+/*
+ * Create an object set for each DSL directory which has a dataset and doesn't
+ * already have an object set.
+ */
+static void
+fs_build_unmounted(zfs_opt_t *zfs, zfs_dsl_dir_t *dsldir, void *arg __unused)
+{
+ if (dsl_dir_has_dataset(dsldir) && !dsl_dir_dataset_has_objset(dsldir))
+ fs_build_one(zfs, dsldir, NULL, -1);
+}
+
+/*
+ * Create our datasets and populate them with files.
+ */
+void
+fs_build(zfs_opt_t *zfs, int dirfd, fsnode *root)
+{
+ /*
+ * Run through our datasets and find the root fsnode for each one. Each
+ * root fsnode is flagged so that we can figure out which dataset it
+ * belongs to.
+ */
+ dsl_dir_foreach(zfs, zfs->rootdsldir, fs_layout_one, root);
+
+ /*
+ * Did we find our boot filesystem?
+ */
+ if (zfs->bootfs != NULL && !zap_entry_exists(zfs->poolprops, "bootfs"))
+ errx(1, "no mounted dataset matches bootfs property `%s'",
+ zfs->bootfs);
+
+ /*
+ * Traverse the file hierarchy starting from the root fsnode. One
+ * dataset, not necessarily the root dataset, must "own" the root
+ * directory by having its mountpoint be equal to the root path.
+ *
+ * As roots of other datasets are encountered during the traversal,
+ * fs_build_one() recursively creates the corresponding object sets and
+ * populates them. Once this function has returned, all datasets will
+ * have been fully populated.
+ */
+ fs_build_one(zfs, root->inode->param, root, dirfd);
+
+ /*
+ * Now create object sets for datasets whose mountpoints weren't found
+ * in the staging directory, either because there is no mountpoint, or
+ * because the mountpoint doesn't correspond to an existing directory.
+ */
+ dsl_dir_foreach(zfs, zfs->rootdsldir, fs_build_unmounted, NULL);
+}
diff --git a/usr.sbin/makefs/zfs/objset.c b/usr.sbin/makefs/zfs/objset.c
new file mode 100644
index 000000000000..6be732db477a
--- /dev/null
+++ b/usr.sbin/makefs/zfs/objset.c
@@ -0,0 +1,262 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 The FreeBSD Foundation
+ *
+ * This software was developed by Mark Johnston under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <util.h>
+
+#include "zfs.h"
+
+#define DNODES_PER_CHUNK (MAXBLOCKSIZE / sizeof(dnode_phys_t))
+
+struct objset_dnode_chunk {
+ dnode_phys_t buf[DNODES_PER_CHUNK];
+ unsigned int nextfree;
+ STAILQ_ENTRY(objset_dnode_chunk) next;
+};
+
+typedef struct zfs_objset {
+ /* Physical object set. */
+ objset_phys_t *phys;
+ off_t osloc;
+ off_t osblksz;
+ blkptr_t osbp; /* set in objset_write() */
+
+ /* Accounting. */
+ off_t space; /* bytes allocated to this objset */
+
+ /* dnode allocator. */
+ uint64_t dnodecount;
+ STAILQ_HEAD(, objset_dnode_chunk) dnodechunks;
+} zfs_objset_t;
+
+static void
+dnode_init(dnode_phys_t *dnode, uint8_t type, uint8_t bonustype,
+ uint16_t bonuslen)
+{
+ dnode->dn_indblkshift = MAXBLOCKSHIFT;
+ dnode->dn_type = type;
+ dnode->dn_bonustype = bonustype;
+ dnode->dn_bonuslen = bonuslen;
+ dnode->dn_checksum = ZIO_CHECKSUM_FLETCHER_4;
+ dnode->dn_nlevels = 1;
+ dnode->dn_nblkptr = 1;
+ dnode->dn_flags = DNODE_FLAG_USED_BYTES;
+}
+
+zfs_objset_t *
+objset_alloc(zfs_opt_t *zfs, uint64_t type)
+{
+ struct objset_dnode_chunk *chunk;
+ zfs_objset_t *os;
+
+ os = ecalloc(1, sizeof(*os));
+ os->osblksz = sizeof(objset_phys_t);
+ os->osloc = objset_space_alloc(zfs, os, &os->osblksz);
+
+ /*
+ * Object ID zero is always reserved for the meta dnode, which is
+ * embedded in the objset itself.
+ */
+ STAILQ_INIT(&os->dnodechunks);
+ chunk = ecalloc(1, sizeof(*chunk));
+ chunk->nextfree = 1;
+ STAILQ_INSERT_HEAD(&os->dnodechunks, chunk, next);
+ os->dnodecount = 1;
+
+ os->phys = ecalloc(1, os->osblksz);
+ os->phys->os_type = type;
+
+ dnode_init(&os->phys->os_meta_dnode, DMU_OT_DNODE, DMU_OT_NONE, 0);
+ os->phys->os_meta_dnode.dn_datablkszsec =
+ DNODE_BLOCK_SIZE >> MINBLOCKSHIFT;
+
+ return (os);
+}
+
+/*
+ * Write the dnode array and physical object set to disk.
+ */
+static void
+_objset_write(zfs_opt_t *zfs, zfs_objset_t *os, struct dnode_cursor *c,
+ off_t loc)
+{
+ struct objset_dnode_chunk *chunk, *tmp;
+ unsigned int total;
+
+ /*
+ * Write out the dnode array, i.e., the meta-dnode. For some reason its
+ * data blocks must be 16KB in size no matter how large the array is.
+ */
+ total = 0;
+ STAILQ_FOREACH_SAFE(chunk, &os->dnodechunks, next, tmp) {
+ unsigned int i;
+
+ assert(chunk->nextfree > 0);
+ assert(chunk->nextfree <= os->dnodecount);
+ assert(chunk->nextfree <= DNODES_PER_CHUNK);
+
+ for (i = 0; i < chunk->nextfree; i += DNODES_PER_BLOCK) {
+ blkptr_t *bp;
+ uint64_t fill;
+
+ if (chunk->nextfree - i < DNODES_PER_BLOCK)
+ fill = DNODES_PER_BLOCK - (chunk->nextfree - i);
+ else
+ fill = 0;
+ bp = dnode_cursor_next(zfs, c,
+ (total + i) * sizeof(dnode_phys_t));
+ vdev_pwrite_dnode_indir(zfs, &os->phys->os_meta_dnode,
+ 0, fill, chunk->buf + i, DNODE_BLOCK_SIZE, loc, bp);
+ loc += DNODE_BLOCK_SIZE;
+ }
+ total += i;
+
+ free(chunk);
+ }
+ dnode_cursor_finish(zfs, c);
+ STAILQ_INIT(&os->dnodechunks);
+
+ /*
+ * Write the object set itself. The saved block pointer will be copied
+ * into the referencing DSL dataset or the uberblocks.
+ */
+ vdev_pwrite_data(zfs, DMU_OT_OBJSET, ZIO_CHECKSUM_FLETCHER_4, 0,
+ os->dnodecount - 1, os->phys, os->osblksz, os->osloc, &os->osbp);
+}
+
+void
+objset_write(zfs_opt_t *zfs, zfs_objset_t *os)
+{
+ struct dnode_cursor *c;
+ off_t dnodeloc, dnodesz;
+ uint64_t dnodecount;
+
+ /*
+ * There is a chicken-and-egg problem here when writing the MOS: we
+ * cannot write space maps before we're finished allocating space from
+ * the vdev, and we can't write the MOS without having allocated space
+ * for indirect dnode blocks. Thus, rather than lazily allocating
+ * indirect blocks for the meta-dnode (which would be simpler), they are
+ * allocated up-front and before writing space maps.
+ */
+ dnodecount = os->dnodecount;
+ if (os == zfs->mos)
+ dnodecount += zfs->mscount;
+ dnodesz = dnodecount * sizeof(dnode_phys_t);
+ c = dnode_cursor_init(zfs, os, &os->phys->os_meta_dnode, dnodesz,
+ DNODE_BLOCK_SIZE);
+ dnodesz = roundup2(dnodesz, DNODE_BLOCK_SIZE);
+ dnodeloc = objset_space_alloc(zfs, os, &dnodesz);
+
+ if (os == zfs->mos) {
+ vdev_spacemap_write(zfs);
+
+ /*
+ * We've finished allocating space, account for it in $MOS and
+ * in the parent directory.
+ */
+ dsl_dir_root_finalize(zfs, os->space);
+ }
+ _objset_write(zfs, os, c, dnodeloc);
+}
+
+dnode_phys_t *
+objset_dnode_bonus_alloc(zfs_objset_t *os, uint8_t type, uint8_t bonustype,
+ uint16_t bonuslen, uint64_t *idp)
+{
+ struct objset_dnode_chunk *chunk;
+ dnode_phys_t *dnode;
+
+ assert(bonuslen <= DN_OLD_MAX_BONUSLEN);
+ assert(!STAILQ_EMPTY(&os->dnodechunks));
+
+ chunk = STAILQ_LAST(&os->dnodechunks, objset_dnode_chunk, next);
+ if (chunk->nextfree == DNODES_PER_CHUNK) {
+ chunk = ecalloc(1, sizeof(*chunk));
+ STAILQ_INSERT_TAIL(&os->dnodechunks, chunk, next);
+ }
+ *idp = os->dnodecount++;
+ dnode = &chunk->buf[chunk->nextfree++];
+ dnode_init(dnode, type, bonustype, bonuslen);
+ dnode->dn_datablkszsec = os->osblksz >> MINBLOCKSHIFT;
+ return (dnode);
+}
+
+dnode_phys_t *
+objset_dnode_alloc(zfs_objset_t *os, uint8_t type, uint64_t *idp)
+{
+ return (objset_dnode_bonus_alloc(os, type, DMU_OT_NONE, 0, idp));
+}
+
+/*
+ * Look up a physical dnode by ID. This is not used often so a linear search is
+ * fine.
+ */
+dnode_phys_t *
+objset_dnode_lookup(zfs_objset_t *os, uint64_t id)
+{
+ struct objset_dnode_chunk *chunk;
+
+ assert(id > 0);
+ assert(id < os->dnodecount);
+
+ STAILQ_FOREACH(chunk, &os->dnodechunks, next) {
+ if (id < DNODES_PER_CHUNK)
+ return (&chunk->buf[id]);
+ id -= DNODES_PER_CHUNK;
+ }
+ assert(0);
+ return (NULL);
+}
+
+off_t
+objset_space_alloc(zfs_opt_t *zfs, zfs_objset_t *os, off_t *lenp)
+{
+ off_t loc;
+
+ loc = vdev_space_alloc(zfs, lenp);
+ os->space += *lenp;
+ return (loc);
+}
+
+uint64_t
+objset_space(const zfs_objset_t *os)
+{
+ return (os->space);
+}
+
+void
+objset_root_blkptr_copy(const zfs_objset_t *os, blkptr_t *bp)
+{
+ memcpy(bp, &os->osbp, sizeof(blkptr_t));
+}
diff --git a/usr.sbin/makefs/zfs/vdev.c b/usr.sbin/makefs/zfs/vdev.c
new file mode 100644
index 000000000000..ef9e681af2da
--- /dev/null
+++ b/usr.sbin/makefs/zfs/vdev.c
@@ -0,0 +1,436 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 The FreeBSD Foundation
+ *
+ * This software was developed by Mark Johnston under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <assert.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <util.h>
+
+#include "zfs.h"
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+#include "zfs/fletcher.c"
+#include "zfs/sha256.c"
+#pragma GCC diagnostic pop
+
+static void
+blkptr_set(blkptr_t *bp, off_t off, off_t size, uint8_t dntype, uint8_t level,
+ uint64_t fill, enum zio_checksum cksumt, zio_cksum_t *cksum)
+{
+ dva_t *dva;
+
+ assert(powerof2(size));
+
+ BP_ZERO(bp);
+ BP_SET_LSIZE(bp, size);
+ BP_SET_PSIZE(bp, size);
+ BP_SET_CHECKSUM(bp, cksumt);
+ BP_SET_COMPRESS(bp, ZIO_COMPRESS_OFF);
+ BP_SET_BYTEORDER(bp, ZFS_HOST_BYTEORDER);
+ BP_SET_BIRTH(bp, TXG, TXG);
+ BP_SET_LEVEL(bp, level);
+ BP_SET_FILL(bp, fill);
+ BP_SET_TYPE(bp, dntype);
+
+ dva = BP_IDENTITY(bp);
+ DVA_SET_VDEV(dva, 0);
+ DVA_SET_OFFSET(dva, off);
+ DVA_SET_ASIZE(dva, size);
+ memcpy(&bp->blk_cksum, cksum, sizeof(*cksum));
+}
+
+/*
+ * Write a block of data to the vdev. The offset is always relative to the end
+ * of the second leading vdev label.
+ *
+ * Consumers should generally use the helpers below, which provide block
+ * pointers and update dnode accounting, rather than calling this function
+ * directly.
+ */
+static void
+vdev_pwrite(const zfs_opt_t *zfs, const void *buf, size_t len, off_t off)
+{
+ ssize_t n;
+
+ assert(off >= 0 && off < zfs->asize);
+ assert(powerof2(len));
+ assert((off_t)len > 0 && off + (off_t)len > off &&
+ off + (off_t)len < zfs->asize);
+ if (zfs->spacemap != NULL) {
+ /*
+ * Verify that the blocks being written were in fact allocated.
+ *
+ * The space map isn't available once the on-disk space map is
+ * finalized, so this check doesn't quite catch everything.
+ */
+ assert(bit_ntest(zfs->spacemap, off >> zfs->ashift,
+ (off + len - 1) >> zfs->ashift, 1));
+ }
+
+ off += VDEV_LABEL_START_SIZE;
+ for (size_t sofar = 0; sofar < len; sofar += n) {
+ n = pwrite(zfs->fd, (const char *)buf + sofar, len - sofar,
+ off + sofar);
+ if (n < 0)
+ err(1, "pwrite");
+ assert(n > 0);
+ }
+}
+
+void
+vdev_pwrite_data(zfs_opt_t *zfs, uint8_t datatype, uint8_t cksumtype,
+ uint8_t level, uint64_t fill, const void *data, off_t sz, off_t loc,
+ blkptr_t *bp)
+{
+ zio_cksum_t cksum;
+
+ assert(cksumtype == ZIO_CHECKSUM_FLETCHER_4);
+
+ fletcher_4_native(data, sz, NULL, &cksum);
+ blkptr_set(bp, loc, sz, datatype, level, fill, cksumtype, &cksum);
+ vdev_pwrite(zfs, data, sz, loc);
+}
+
+void
+vdev_pwrite_dnode_indir(zfs_opt_t *zfs, dnode_phys_t *dnode, uint8_t level,
+ uint64_t fill, const void *data, off_t sz, off_t loc, blkptr_t *bp)
+{
+ vdev_pwrite_data(zfs, dnode->dn_type, dnode->dn_checksum, level, fill,
+ data, sz, loc, bp);
+
+ assert((dnode->dn_flags & DNODE_FLAG_USED_BYTES) != 0);
+ dnode->dn_used += sz;
+}
+
+void
+vdev_pwrite_dnode_data(zfs_opt_t *zfs, dnode_phys_t *dnode, const void *data,
+ off_t sz, off_t loc)
+{
+ vdev_pwrite_dnode_indir(zfs, dnode, 0, 1, data, sz, loc,
+ &dnode->dn_blkptr[0]);
+}
+
+static void
+vdev_label_set_checksum(void *buf, off_t off, off_t size)
+{
+ zio_cksum_t cksum;
+ zio_eck_t *eck;
+
+ assert(size > 0 && (size_t)size >= sizeof(zio_eck_t));
+
+ eck = (zio_eck_t *)((char *)buf + size) - 1;
+ eck->zec_magic = ZEC_MAGIC;
+ ZIO_SET_CHECKSUM(&eck->zec_cksum, off, 0, 0, 0);
+ zio_checksum_SHA256(buf, size, NULL, &cksum);
+ eck->zec_cksum = cksum;
+}
+
+/*
+ * Set embedded checksums and write the label at the specified index.
+ */
+void
+vdev_label_write(zfs_opt_t *zfs, int ind, const vdev_label_t *labelp)
+{
+ vdev_label_t *label;
+ ssize_t n;
+ off_t blksz, loff;
+
+ assert(ind >= 0 && ind < VDEV_LABELS);
+
+ /*
+ * Make a copy since we have to modify the label to set checksums.
+ */
+ label = ecalloc(1, sizeof(*label));
+ memcpy(label, labelp, sizeof(*label));
+
+ if (ind < 2)
+ loff = ind * sizeof(*label);
+ else
+ loff = zfs->vdevsize - (VDEV_LABELS - ind) * sizeof(*label);
+
+ /*
+ * Set the verifier checksum for the boot block. We don't use it, but
+ * the FreeBSD loader reads it and will complain if the checksum isn't
+ * valid.
+ */
+ vdev_label_set_checksum(&label->vl_be,
+ loff + __offsetof(vdev_label_t, vl_be), sizeof(label->vl_be));
+
+ /*
+ * Set the verifier checksum for the label.
+ */
+ vdev_label_set_checksum(&label->vl_vdev_phys,
+ loff + __offsetof(vdev_label_t, vl_vdev_phys),
+ sizeof(label->vl_vdev_phys));
+
+ /*
+ * Set the verifier checksum for the uberblocks. There is one uberblock
+ * per sector; for example, with an ashift of 12 we end up with
+ * 128KB/4KB=32 copies of the uberblock in the ring.
+ */
+ blksz = 1 << zfs->ashift;
+ assert(sizeof(label->vl_uberblock) % blksz == 0);
+ for (size_t roff = 0; roff < sizeof(label->vl_uberblock);
+ roff += blksz) {
+ vdev_label_set_checksum(&label->vl_uberblock[0] + roff,
+ loff + __offsetof(vdev_label_t, vl_uberblock) + roff,
+ blksz);
+ }
+
+ n = pwrite(zfs->fd, label, sizeof(*label), loff);
+ if (n < 0)
+ err(1, "writing vdev label");
+ assert(n == sizeof(*label));
+
+ free(label);
+}
+
+/*
+ * Find a chunk of contiguous free space of length *lenp, according to the
+ * following rules:
+ * 1. If the length is less than or equal to 128KB, the returned run's length
+ * will be the smallest power of 2 equal to or larger than the length.
+ * 2. If the length is larger than 128KB, the returned run's length will be
+ * the smallest multiple of 128KB that is larger than the length.
+ * 3. The returned run's length will be size-aligned up to 128KB.
+ *
+ * XXX-MJ the third rule isn't actually required, so this can just be a dumb
+ * bump allocator. Maybe there's some benefit to keeping large blocks aligned,
+ * so let's keep it for now and hope we don't get too much fragmentation.
+ * Alternately we could try to allocate all blocks of a certain size from the
+ * same metaslab.
+ */
+off_t
+vdev_space_alloc(zfs_opt_t *zfs, off_t *lenp)
+{
+ off_t len;
+ int align, loc, minblksz, nbits;
+
+ minblksz = 1 << zfs->ashift;
+ len = roundup2(*lenp, minblksz);
+
+ assert(len != 0);
+ assert(len / minblksz <= INT_MAX);
+
+ if (len < MAXBLOCKSIZE) {
+ if ((len & (len - 1)) != 0)
+ len = (off_t)1 << flsll(len);
+ align = len / minblksz;
+ } else {
+ len = roundup2(len, MAXBLOCKSIZE);
+ align = MAXBLOCKSIZE / minblksz;
+ }
+
+ for (loc = 0, nbits = len / minblksz;; loc = roundup2(loc, align)) {
+ bit_ffc_area_at(zfs->spacemap, loc, zfs->spacemapbits, nbits,
+ &loc);
+ if (loc == -1) {
+ errx(1, "failed to find %ju bytes of space",
+ (uintmax_t)len);
+ }
+ if ((loc & (align - 1)) == 0)
+ break;
+ }
+ assert(loc + nbits > loc);
+ bit_nset(zfs->spacemap, loc, loc + nbits - 1);
+ *lenp = len;
+
+ return ((off_t)loc << zfs->ashift);
+}
+
+static void
+vdev_spacemap_init(zfs_opt_t *zfs)
+{
+ uint64_t nbits;
+
+ assert(powerof2(zfs->mssize));
+
+ nbits = rounddown2(zfs->asize, zfs->mssize) >> zfs->ashift;
+ if (nbits > INT_MAX) {
+ /*
+ * With the smallest block size of 512B, the limit on the image
+ * size is 2TB. That should be enough for anyone.
+ */
+ errx(1, "image size is too large");
+ }
+ zfs->spacemapbits = (int)nbits;
+ zfs->spacemap = bit_alloc(zfs->spacemapbits);
+ if (zfs->spacemap == NULL)
+ err(1, "bitstring allocation failed");
+}
+
+void
+vdev_spacemap_write(zfs_opt_t *zfs)
+{
+ dnode_phys_t *objarr;
+ bitstr_t *spacemap;
+ uint64_t *objarrblk;
+ off_t smblksz, objarrblksz, objarrloc;
+
+ struct {
+ dnode_phys_t *dnode;
+ uint64_t dnid;
+ off_t loc;
+ } *sma;
+
+ objarrblksz = sizeof(uint64_t) * zfs->mscount;
+ assert(objarrblksz <= MAXBLOCKSIZE);
+ objarrloc = objset_space_alloc(zfs, zfs->mos, &objarrblksz);
+ objarrblk = ecalloc(1, objarrblksz);
+
+ objarr = objset_dnode_lookup(zfs->mos, zfs->objarrid);
+ objarr->dn_datablkszsec = objarrblksz >> MINBLOCKSHIFT;
+
+ /*
+ * Use the smallest block size for space maps. The space allocation
+ * algorithm should aim to minimize the number of holes.
+ */
+ smblksz = 1 << zfs->ashift;
+
+ /*
+ * First allocate dnodes and space for all of our space maps. No more
+ * space can be allocated from the vdev after this point.
+ */
+ sma = ecalloc(zfs->mscount, sizeof(*sma));
+ for (uint64_t i = 0; i < zfs->mscount; i++) {
+ sma[i].dnode = objset_dnode_bonus_alloc(zfs->mos,
+ DMU_OT_SPACE_MAP, DMU_OT_SPACE_MAP_HEADER,
+ sizeof(space_map_phys_t), &sma[i].dnid);
+ sma[i].loc = objset_space_alloc(zfs, zfs->mos, &smblksz);
+ }
+ spacemap = zfs->spacemap;
+ zfs->spacemap = NULL;
+
+ /*
+ * Now that the set of allocated space is finalized, populate each space
+ * map and write it to the vdev.
+ */
+ for (uint64_t i = 0; i < zfs->mscount; i++) {
+ space_map_phys_t *sm;
+ uint64_t alloc, length, *smblk;
+ int shift, startb, endb, srunb, erunb;
+
+ /*
+ * We only allocate a single block for this space map, but
+ * OpenZFS assumes that a space map object with sufficient bonus
+ * space supports histograms.
+ */
+ sma[i].dnode->dn_nblkptr = 3;
+ sma[i].dnode->dn_datablkszsec = smblksz >> MINBLOCKSHIFT;
+
+ smblk = ecalloc(1, smblksz);
+
+ alloc = length = 0;
+ shift = zfs->msshift - zfs->ashift;
+ for (srunb = startb = i * (1 << shift),
+ endb = (i + 1) * (1 << shift);
+ srunb < endb; srunb = erunb) {
+ uint64_t runlen, runoff;
+
+ /* Find a run of allocated space. */
+ bit_ffs_at(spacemap, srunb, zfs->spacemapbits, &srunb);
+ if (srunb == -1 || srunb >= endb)
+ break;
+
+ bit_ffc_at(spacemap, srunb, zfs->spacemapbits, &erunb);
+ if (erunb == -1 || erunb > endb)
+ erunb = endb;
+
+ /*
+ * The space represented by [srunb, erunb) has been
+ * allocated. Add a record to the space map to indicate
+ * this. Run offsets are relative to the beginning of
+ * the metaslab.
+ */
+ runlen = erunb - srunb;
+ runoff = srunb - startb;
+
+ assert(length * sizeof(uint64_t) < (uint64_t)smblksz);
+ smblk[length] = SM_PREFIX_ENCODE(SM2_PREFIX) |
+ SM2_RUN_ENCODE(runlen) | SM2_VDEV_ENCODE(0);
+ smblk[length + 1] = SM2_TYPE_ENCODE(SM_ALLOC) |
+ SM2_OFFSET_ENCODE(runoff);
+
+ alloc += runlen << zfs->ashift;
+ length += 2;
+ }
+
+ sm = DN_BONUS(sma[i].dnode);
+ sm->smp_length = length * sizeof(uint64_t);
+ sm->smp_alloc = alloc;
+
+ vdev_pwrite_dnode_data(zfs, sma[i].dnode, smblk, smblksz,
+ sma[i].loc);
+ free(smblk);
+
+ /* Record this space map in the space map object array. */
+ objarrblk[i] = sma[i].dnid;
+ }
+
+ /*
+ * All of the space maps are written, now write the object array.
+ */
+ vdev_pwrite_dnode_data(zfs, objarr, objarrblk, objarrblksz, objarrloc);
+ free(objarrblk);
+
+ assert(zfs->spacemap == NULL);
+ free(spacemap);
+ free(sma);
+}
+
+void
+vdev_init(zfs_opt_t *zfs, const char *image)
+{
+ assert(zfs->ashift >= MINBLOCKSHIFT);
+
+ zfs->fd = open(image, O_RDWR | O_CREAT | O_TRUNC, 0644);
+ if (zfs->fd == -1)
+ err(1, "Can't open `%s' for writing", image);
+ if (ftruncate(zfs->fd, zfs->vdevsize) != 0)
+ err(1, "Failed to extend image file `%s'", image);
+
+ vdev_spacemap_init(zfs);
+}
+
+void
+vdev_fini(zfs_opt_t *zfs)
+{
+ assert(zfs->spacemap == NULL);
+
+ if (zfs->fd != -1) {
+ if (close(zfs->fd) != 0)
+ err(1, "close");
+ zfs->fd = -1;
+ }
+}
diff --git a/usr.sbin/makefs/zfs/zap.c b/usr.sbin/makefs/zfs/zap.c
new file mode 100644
index 000000000000..2437ee3bfd1e
--- /dev/null
+++ b/usr.sbin/makefs/zfs/zap.c
@@ -0,0 +1,549 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 The FreeBSD Foundation
+ *
+ * This software was developed by Mark Johnston under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/endian.h>
+
+#include <assert.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <util.h>
+
+#include "makefs.h"
+#include "zfs.h"
+
+typedef struct zfs_zap_entry {
+ char *name; /* entry key, private copy */
+ uint64_t hash; /* key hash */
+ union {
+ uint8_t *valp;
+ uint16_t *val16p;
+ uint32_t *val32p;
+ uint64_t *val64p;
+ }; /* entry value, an integer array */
+ uint64_t val64; /* embedded value for a common case */
+ size_t intsz; /* array element size; 1, 2, 4 or 8 */
+ size_t intcnt; /* array size */
+ STAILQ_ENTRY(zfs_zap_entry) next;
+} zfs_zap_entry_t;
+
+struct zfs_zap {
+ STAILQ_HEAD(, zfs_zap_entry) kvps;
+ uint64_t hashsalt; /* key hash input */
+ unsigned long kvpcnt; /* number of key-value pairs */
+ unsigned long chunks; /* count of chunks needed for fat ZAP */
+ bool micro; /* can this be a micro ZAP? */
+
+ dnode_phys_t *dnode; /* backpointer */
+ zfs_objset_t *os; /* backpointer */
+};
+
+static uint16_t
+zap_entry_chunks(zfs_zap_entry_t *ent)
+{
+ return (1 + howmany(strlen(ent->name) + 1, ZAP_LEAF_ARRAY_BYTES) +
+ howmany(ent->intsz * ent->intcnt, ZAP_LEAF_ARRAY_BYTES));
+}
+
+static uint64_t
+zap_hash(uint64_t salt, const char *name)
+{
+ static uint64_t crc64_table[256];
+ const uint64_t crc64_poly = 0xC96C5795D7870F42UL;
+ const uint8_t *cp;
+ uint64_t crc;
+ uint8_t c;
+
+ assert(salt != 0);
+ if (crc64_table[128] == 0) {
+ for (int i = 0; i < 256; i++) {
+ uint64_t *t;
+
+ t = crc64_table + i;
+ *t = i;
+ for (int j = 8; j > 0; j--)
+ *t = (*t >> 1) ^ (-(*t & 1) & crc64_poly);
+ }
+ }
+ assert(crc64_table[128] == crc64_poly);
+
+ for (cp = (const uint8_t *)name, crc = salt; (c = *cp) != '\0'; cp++)
+ crc = (crc >> 8) ^ crc64_table[(crc ^ c) & 0xFF];
+
+ /*
+ * Only use 28 bits, since we need 4 bits in the cookie for the
+ * collision differentiator. We MUST use the high bits, since
+ * those are the ones that we first pay attention to when
+ * choosing the bucket.
+ */
+ crc &= ~((1ULL << (64 - ZAP_HASHBITS)) - 1);
+
+ return (crc);
+}
+
+zfs_zap_t *
+zap_alloc(zfs_objset_t *os, dnode_phys_t *dnode)
+{
+ zfs_zap_t *zap;
+
+ zap = ecalloc(1, sizeof(*zap));
+ STAILQ_INIT(&zap->kvps);
+ zap->hashsalt = ((uint64_t)random() << 32) | random();
+ zap->micro = true;
+ zap->kvpcnt = 0;
+ zap->chunks = 0;
+ zap->dnode = dnode;
+ zap->os = os;
+ return (zap);
+}
+
+void
+zap_add(zfs_zap_t *zap, const char *name, size_t intsz, size_t intcnt,
+ const uint8_t *val)
+{
+ zfs_zap_entry_t *ent;
+
+ assert(intsz == 1 || intsz == 2 || intsz == 4 || intsz == 8);
+ assert(strlen(name) + 1 <= ZAP_MAXNAMELEN);
+ assert(intcnt <= ZAP_MAXVALUELEN && intcnt * intsz <= ZAP_MAXVALUELEN);
+
+ ent = ecalloc(1, sizeof(*ent));
+ ent->name = estrdup(name);
+ ent->hash = zap_hash(zap->hashsalt, ent->name);
+ ent->intsz = intsz;
+ ent->intcnt = intcnt;
+ if (intsz == sizeof(uint64_t) && intcnt == 1) {
+ /*
+ * Micro-optimization to elide a memory allocation in that most
+ * common case where this is a directory entry.
+ */
+ ent->val64p = &ent->val64;
+ } else {
+ ent->valp = ecalloc(intcnt, intsz);
+ }
+ memcpy(ent->valp, val, intcnt * intsz);
+ zap->kvpcnt++;
+ zap->chunks += zap_entry_chunks(ent);
+ STAILQ_INSERT_TAIL(&zap->kvps, ent, next);
+
+ if (zap->micro && (intcnt != 1 || intsz != sizeof(uint64_t) ||
+ strlen(name) + 1 > MZAP_NAME_LEN || zap->kvpcnt > MZAP_ENT_MAX))
+ zap->micro = false;
+}
+
+void
+zap_add_uint64(zfs_zap_t *zap, const char *name, uint64_t val)
+{
+ zap_add(zap, name, sizeof(uint64_t), 1, (uint8_t *)&val);
+}
+
+void
+zap_add_string(zfs_zap_t *zap, const char *name, const char *val)
+{
+ zap_add(zap, name, 1, strlen(val) + 1, val);
+}
+
+bool
+zap_entry_exists(zfs_zap_t *zap, const char *name)
+{
+ zfs_zap_entry_t *ent;
+
+ STAILQ_FOREACH(ent, &zap->kvps, next) {
+ if (strcmp(ent->name, name) == 0)
+ return (true);
+ }
+ return (false);
+}
+
+static void
+zap_micro_write(zfs_opt_t *zfs, zfs_zap_t *zap)
+{
+ dnode_phys_t *dnode;
+ zfs_zap_entry_t *ent;
+ mzap_phys_t *mzap;
+ mzap_ent_phys_t *ment;
+ off_t bytes, loc;
+
+ memset(zfs->filebuf, 0, sizeof(zfs->filebuf));
+ mzap = (mzap_phys_t *)&zfs->filebuf[0];
+ mzap->mz_block_type = ZBT_MICRO;
+ mzap->mz_salt = zap->hashsalt;
+ mzap->mz_normflags = 0;
+
+ bytes = sizeof(*mzap) + (zap->kvpcnt - 1) * sizeof(*ment);
+ assert(bytes <= (off_t)MZAP_MAX_BLKSZ);
+
+ ment = &mzap->mz_chunk[0];
+ STAILQ_FOREACH(ent, &zap->kvps, next) {
+ memcpy(&ment->mze_value, ent->valp, ent->intsz * ent->intcnt);
+ ment->mze_cd = 0; /* XXX-MJ */
+ strlcpy(ment->mze_name, ent->name, sizeof(ment->mze_name));
+ ment++;
+ }
+
+ loc = objset_space_alloc(zfs, zap->os, &bytes);
+
+ dnode = zap->dnode;
+ dnode->dn_maxblkid = 0;
+ dnode->dn_datablkszsec = bytes >> MINBLOCKSHIFT;
+
+ vdev_pwrite_dnode_data(zfs, dnode, zfs->filebuf, bytes, loc);
+}
+
+/*
+ * Write some data to the fat ZAP leaf chunk starting at index "li".
+ *
+ * Note that individual integers in the value may be split among consecutive
+ * leaves.
+ */
+static void
+zap_fat_write_array_chunk(zap_leaf_t *l, uint16_t li, size_t sz,
+ const uint8_t *val)
+{
+ struct zap_leaf_array *la;
+
+ assert(sz <= ZAP_MAXVALUELEN);
+
+ for (uint16_t n, resid = sz; resid > 0; resid -= n, val += n, li++) {
+ n = MIN(resid, ZAP_LEAF_ARRAY_BYTES);
+
+ la = &ZAP_LEAF_CHUNK(l, li).l_array;
+ assert(la->la_type == ZAP_CHUNK_FREE);
+ la->la_type = ZAP_CHUNK_ARRAY;
+ memcpy(la->la_array, val, n);
+ la->la_next = li + 1;
+ }
+ la->la_next = 0xffff;
+}
+
+/*
+ * Find the shortest hash prefix length which lets us distribute keys without
+ * overflowing a leaf block. This is not (space) optimal, but is simple, and
+ * directories large enough to overflow a single 128KB leaf block are uncommon.
+ */
+static unsigned int
+zap_fat_write_prefixlen(zfs_zap_t *zap, zap_leaf_t *l)
+{
+ zfs_zap_entry_t *ent;
+ unsigned int prefixlen;
+
+ if (zap->chunks <= ZAP_LEAF_NUMCHUNKS(l)) {
+ /*
+ * All chunks will fit in a single leaf block.
+ */
+ return (0);
+ }
+
+ for (prefixlen = 1; prefixlen < (unsigned int)l->l_bs; prefixlen++) {
+ uint32_t *leafchunks;
+
+ leafchunks = ecalloc(1u << prefixlen, sizeof(*leafchunks));
+ STAILQ_FOREACH(ent, &zap->kvps, next) {
+ uint64_t li;
+ uint16_t chunks;
+
+ li = ZAP_HASH_IDX(ent->hash, prefixlen);
+
+ chunks = zap_entry_chunks(ent);
+ if (ZAP_LEAF_NUMCHUNKS(l) - leafchunks[li] < chunks) {
+ /*
+ * Not enough space, grow the prefix and retry.
+ */
+ break;
+ }
+ leafchunks[li] += chunks;
+ }
+ free(leafchunks);
+
+ if (ent == NULL) {
+ /*
+ * Everything fits, we're done.
+ */
+ break;
+ }
+ }
+
+ /*
+ * If this fails, then we need to expand the pointer table. For now
+ * this situation is unhandled since it is hard to trigger.
+ */
+ assert(prefixlen < (unsigned int)l->l_bs);
+
+ return (prefixlen);
+}
+
+/*
+ * Initialize a fat ZAP leaf block.
+ */
+static void
+zap_fat_write_leaf_init(zap_leaf_t *l, uint64_t prefix, int prefixlen)
+{
+ zap_leaf_phys_t *leaf;
+
+ leaf = l->l_phys;
+
+ leaf->l_hdr.lh_block_type = ZBT_LEAF;
+ leaf->l_hdr.lh_magic = ZAP_LEAF_MAGIC;
+ leaf->l_hdr.lh_nfree = ZAP_LEAF_NUMCHUNKS(l);
+ leaf->l_hdr.lh_prefix = prefix;
+ leaf->l_hdr.lh_prefix_len = prefixlen;
+
+ /* Initialize the leaf hash table. */
+ assert(leaf->l_hdr.lh_nfree < 0xffff);
+ memset(leaf->l_hash, 0xff,
+ ZAP_LEAF_HASH_NUMENTRIES(l) * sizeof(*leaf->l_hash));
+
+ /* Initialize the leaf chunks. */
+ for (uint16_t i = 0; i < ZAP_LEAF_NUMCHUNKS(l); i++) {
+ struct zap_leaf_free *lf;
+
+ lf = &ZAP_LEAF_CHUNK(l, i).l_free;
+ lf->lf_type = ZAP_CHUNK_FREE;
+ if (i + 1 == ZAP_LEAF_NUMCHUNKS(l))
+ lf->lf_next = 0xffff;
+ else
+ lf->lf_next = i + 1;
+ }
+}
+
+static void
+zap_fat_write(zfs_opt_t *zfs, zfs_zap_t *zap)
+{
+ struct dnode_cursor *c;
+ zap_leaf_t l;
+ zap_phys_t *zaphdr;
+ struct zap_table_phys *zt;
+ zfs_zap_entry_t *ent;
+ dnode_phys_t *dnode;
+ uint8_t *leafblks;
+ uint64_t lblkcnt, *ptrhasht;
+ off_t loc, blksz;
+ size_t blkshift;
+ unsigned int prefixlen;
+ int ptrcnt;
+
+ /*
+ * For simplicity, always use the largest block size. This should be ok
+ * since most directories will be micro ZAPs, but it's space inefficient
+ * for small ZAPs and might need to be revisited.
+ */
+ blkshift = MAXBLOCKSHIFT;
+ blksz = (off_t)1 << blkshift;
+
+ /*
+ * Embedded pointer tables give up to 8192 entries. This ought to be
+ * enough for anything except massive directories.
+ */
+ ptrcnt = (blksz / 2) / sizeof(uint64_t);
+
+ memset(zfs->filebuf, 0, sizeof(zfs->filebuf));
+ zaphdr = (zap_phys_t *)&zfs->filebuf[0];
+ zaphdr->zap_block_type = ZBT_HEADER;
+ zaphdr->zap_magic = ZAP_MAGIC;
+ zaphdr->zap_num_entries = zap->kvpcnt;
+ zaphdr->zap_salt = zap->hashsalt;
+
+ l.l_bs = blkshift;
+ l.l_phys = NULL;
+
+ zt = &zaphdr->zap_ptrtbl;
+ zt->zt_blk = 0;
+ zt->zt_numblks = 0;
+ zt->zt_shift = flsll(ptrcnt) - 1;
+ zt->zt_nextblk = 0;
+ zt->zt_blks_copied = 0;
+
+ /*
+ * How many leaf blocks do we need? Initialize them and update the
+ * header.
+ */
+ prefixlen = zap_fat_write_prefixlen(zap, &l);
+ lblkcnt = (uint64_t)1 << prefixlen;
+ leafblks = ecalloc(lblkcnt, blksz);
+ for (unsigned int li = 0; li < lblkcnt; li++) {
+ l.l_phys = (zap_leaf_phys_t *)(leafblks + li * blksz);
+ zap_fat_write_leaf_init(&l, li, prefixlen);
+ }
+ zaphdr->zap_num_leafs = lblkcnt;
+ zaphdr->zap_freeblk = lblkcnt + 1;
+
+ /*
+ * For each entry, figure out which leaf block it belongs to based on
+ * the upper bits of its hash, allocate chunks from that leaf, and fill
+ * them out.
+ */
+ ptrhasht = (uint64_t *)(&zfs->filebuf[0] + blksz / 2);
+ STAILQ_FOREACH(ent, &zap->kvps, next) {
+ struct zap_leaf_entry *le;
+ uint16_t *lptr;
+ uint64_t hi, li;
+ uint16_t namelen, nchunks, nnamechunks, nvalchunks;
+
+ hi = ZAP_HASH_IDX(ent->hash, zt->zt_shift);
+ li = ZAP_HASH_IDX(ent->hash, prefixlen);
+ assert(ptrhasht[hi] == 0 || ptrhasht[hi] == li + 1);
+ ptrhasht[hi] = li + 1;
+ l.l_phys = (zap_leaf_phys_t *)(leafblks + li * blksz);
+
+ namelen = strlen(ent->name) + 1;
+
+ /*
+ * How many leaf chunks do we need for this entry?
+ */
+ nnamechunks = howmany(namelen, ZAP_LEAF_ARRAY_BYTES);
+ nvalchunks = howmany(ent->intcnt,
+ ZAP_LEAF_ARRAY_BYTES / ent->intsz);
+ nchunks = 1 + nnamechunks + nvalchunks;
+
+ /*
+ * Allocate a run of free leaf chunks for this entry,
+ * potentially extending a hash chain.
+ */
+ assert(l.l_phys->l_hdr.lh_nfree >= nchunks);
+ l.l_phys->l_hdr.lh_nfree -= nchunks;
+ l.l_phys->l_hdr.lh_nentries++;
+ lptr = ZAP_LEAF_HASH_ENTPTR(&l, ent->hash);
+ while (*lptr != 0xffff) {
+ assert(*lptr < ZAP_LEAF_NUMCHUNKS(&l));
+ le = ZAP_LEAF_ENTRY(&l, *lptr);
+ assert(le->le_type == ZAP_CHUNK_ENTRY);
+ le->le_cd++;
+ lptr = &le->le_next;
+ }
+ *lptr = l.l_phys->l_hdr.lh_freelist;
+ l.l_phys->l_hdr.lh_freelist += nchunks;
+ assert(l.l_phys->l_hdr.lh_freelist <=
+ ZAP_LEAF_NUMCHUNKS(&l));
+ if (l.l_phys->l_hdr.lh_freelist ==
+ ZAP_LEAF_NUMCHUNKS(&l))
+ l.l_phys->l_hdr.lh_freelist = 0xffff;
+
+ /*
+ * Integer values must be stored in big-endian format.
+ */
+ switch (ent->intsz) {
+ case 1:
+ break;
+ case 2:
+ for (uint16_t *v = ent->val16p;
+ v - ent->val16p < (ptrdiff_t)ent->intcnt;
+ v++)
+ *v = htobe16(*v);
+ break;
+ case 4:
+ for (uint32_t *v = ent->val32p;
+ v - ent->val32p < (ptrdiff_t)ent->intcnt;
+ v++)
+ *v = htobe32(*v);
+ break;
+ case 8:
+ for (uint64_t *v = ent->val64p;
+ v - ent->val64p < (ptrdiff_t)ent->intcnt;
+ v++)
+ *v = htobe64(*v);
+ break;
+ default:
+ assert(0);
+ }
+
+ /*
+ * Finally, write out the leaf chunks for this entry.
+ */
+ le = ZAP_LEAF_ENTRY(&l, *lptr);
+ assert(le->le_type == ZAP_CHUNK_FREE);
+ le->le_type = ZAP_CHUNK_ENTRY;
+ le->le_next = 0xffff;
+ le->le_name_chunk = *lptr + 1;
+ le->le_name_numints = namelen;
+ le->le_value_chunk = *lptr + 1 + nnamechunks;
+ le->le_value_intlen = ent->intsz;
+ le->le_value_numints = ent->intcnt;
+ le->le_hash = ent->hash;
+ zap_fat_write_array_chunk(&l, *lptr + 1, namelen, ent->name);
+ zap_fat_write_array_chunk(&l, *lptr + 1 + nnamechunks,
+ ent->intcnt * ent->intsz, ent->valp);
+ }
+
+ /*
+ * Initialize unused slots of the pointer table.
+ */
+ for (int i = 0; i < ptrcnt; i++)
+ if (ptrhasht[i] == 0)
+ ptrhasht[i] = (i >> (zt->zt_shift - prefixlen)) + 1;
+
+ /*
+ * Write the whole thing to disk.
+ */
+ dnode = zap->dnode;
+ dnode->dn_datablkszsec = blksz >> MINBLOCKSHIFT;
+ dnode->dn_maxblkid = lblkcnt + 1;
+
+ c = dnode_cursor_init(zfs, zap->os, zap->dnode,
+ (lblkcnt + 1) * blksz, blksz);
+
+ loc = objset_space_alloc(zfs, zap->os, &blksz);
+ vdev_pwrite_dnode_indir(zfs, dnode, 0, 1, zfs->filebuf, blksz, loc,
+ dnode_cursor_next(zfs, c, 0));
+
+ for (uint64_t i = 0; i < lblkcnt; i++) {
+ loc = objset_space_alloc(zfs, zap->os, &blksz);
+ vdev_pwrite_dnode_indir(zfs, dnode, 0, 1, leafblks + i * blksz,
+ blksz, loc, dnode_cursor_next(zfs, c, (i + 1) * blksz));
+ }
+
+ dnode_cursor_finish(zfs, c);
+
+ free(leafblks);
+}
+
+void
+zap_write(zfs_opt_t *zfs, zfs_zap_t *zap)
+{
+ zfs_zap_entry_t *ent;
+
+ if (zap->micro) {
+ zap_micro_write(zfs, zap);
+ } else {
+ assert(!STAILQ_EMPTY(&zap->kvps));
+ assert(zap->kvpcnt > 0);
+ zap_fat_write(zfs, zap);
+ }
+
+ while ((ent = STAILQ_FIRST(&zap->kvps)) != NULL) {
+ STAILQ_REMOVE_HEAD(&zap->kvps, next);
+ if (ent->val64p != &ent->val64)
+ free(ent->valp);
+ free(ent->name);
+ free(ent);
+ }
+ free(zap);
+}
diff --git a/usr.sbin/makefs/zfs/zfs.h b/usr.sbin/makefs/zfs/zfs.h
new file mode 100644
index 000000000000..9af090b14912
--- /dev/null
+++ b/usr.sbin/makefs/zfs/zfs.h
@@ -0,0 +1,173 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 The FreeBSD Foundation
+ *
+ * This software was developed by Mark Johnston under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _MAKEFS_ZFS_H_
+#define _MAKEFS_ZFS_H_
+
+#include <sys/types.h>
+#include <sys/endian.h>
+#include <sys/queue.h>
+
+#include <bitstring.h>
+#include <stdalign.h>
+#include <stdbool.h>
+
+#include "makefs.h"
+
+#include "zfs/nvlist.h"
+#define ASSERT assert
+#include "zfs/zfsimpl.h"
+
+#define MAXBLOCKSHIFT 17 /* 128KB */
+#define MAXBLOCKSIZE ((off_t)(1 << MAXBLOCKSHIFT))
+_Static_assert(MAXBLOCKSIZE == SPA_OLDMAXBLOCKSIZE, "");
+#define MINBLOCKSHIFT 9 /* 512B */
+#define MINBLOCKSIZE ((off_t)(1 << MINBLOCKSHIFT))
+_Static_assert(MINBLOCKSIZE == SPA_MINBLOCKSIZE, "");
+#define MINDEVSIZE ((off_t)SPA_MINDEVSIZE)
+
+/* All data was written in this transaction group. */
+#define TXG 4
+
+typedef struct zfs_dsl_dataset zfs_dsl_dataset_t;
+typedef struct zfs_dsl_dir zfs_dsl_dir_t;
+typedef struct zfs_objset zfs_objset_t;
+typedef struct zfs_zap zfs_zap_t;
+
+struct dataset_desc {
+ char *params;
+ STAILQ_ENTRY(dataset_desc) next;
+};
+
+typedef struct {
+ /*
+ * Block buffer, needs to be aligned for various on-disk structures,
+ * ZAPs, etc..
+ */
+ char filebuf[MAXBLOCKSIZE] __aligned(alignof(uint64_t));
+
+ bool nowarn;
+
+ /* Pool parameters. */
+ const char *poolname;
+ char *rootpath; /* implicit mount point prefix */
+ char *bootfs; /* bootable dataset, pool property */
+ int ashift; /* vdev block size */
+ uint64_t mssize; /* metaslab size */
+ STAILQ_HEAD(, dataset_desc) datasetdescs; /* non-root dataset descrs */
+
+ /* Pool state. */
+ uint64_t poolguid; /* pool and root vdev GUID */
+ zfs_zap_t *poolprops;
+
+ /* MOS state. */
+ zfs_objset_t *mos; /* meta object set */
+ uint64_t objarrid; /* space map object array */
+
+ /* DSL state. */
+ zfs_dsl_dir_t *rootdsldir; /* root DSL directory */
+ zfs_dsl_dataset_t *rootds;
+ zfs_dsl_dir_t *origindsldir; /* $ORIGIN */
+ zfs_dsl_dataset_t *originds;
+ zfs_dsl_dataset_t *snapds;
+ zfs_zap_t *cloneszap;
+ zfs_dsl_dir_t *freedsldir; /* $FREE */
+ zfs_dsl_dir_t *mosdsldir; /* $MOS */
+
+ /* vdev state. */
+ int fd; /* vdev disk fd */
+ uint64_t vdevguid; /* disk vdev GUID */
+ off_t vdevsize; /* vdev size, including labels */
+ off_t asize; /* vdev size, excluding labels */
+ bitstr_t *spacemap; /* space allocation tracking */
+ int spacemapbits; /* one bit per ashift-sized block */
+ uint64_t msshift; /* log2(metaslab size) */
+ uint64_t mscount; /* number of metaslabs for this vdev */
+} zfs_opt_t;
+
+/* dsl.c */
+void dsl_init(zfs_opt_t *);
+const char *dsl_dir_fullname(const zfs_dsl_dir_t *);
+uint64_t dsl_dir_id(zfs_dsl_dir_t *);
+uint64_t dsl_dir_dataset_id(zfs_dsl_dir_t *);
+void dsl_dir_foreach(zfs_opt_t *, zfs_dsl_dir_t *,
+ void (*)(zfs_opt_t *, zfs_dsl_dir_t *, void *), void *);
+int dsl_dir_get_canmount(zfs_dsl_dir_t *, uint64_t *);
+char *dsl_dir_get_mountpoint(zfs_opt_t *, zfs_dsl_dir_t *);
+bool dsl_dir_has_dataset(zfs_dsl_dir_t *);
+bool dsl_dir_dataset_has_objset(zfs_dsl_dir_t *);
+void dsl_dir_dataset_write(zfs_opt_t *, zfs_objset_t *, zfs_dsl_dir_t *);
+void dsl_dir_root_finalize(zfs_opt_t *, uint64_t);
+void dsl_write(zfs_opt_t *);
+
+/* fs.c */
+void fs_build(zfs_opt_t *, int, fsnode *);
+
+/* objset.c */
+zfs_objset_t *objset_alloc(zfs_opt_t *zfs, uint64_t type);
+off_t objset_space_alloc(zfs_opt_t *, zfs_objset_t *, off_t *);
+dnode_phys_t *objset_dnode_alloc(zfs_objset_t *, uint8_t, uint64_t *);
+dnode_phys_t *objset_dnode_bonus_alloc(zfs_objset_t *, uint8_t, uint8_t,
+ uint16_t, uint64_t *);
+dnode_phys_t *objset_dnode_lookup(zfs_objset_t *, uint64_t);
+void objset_root_blkptr_copy(const zfs_objset_t *, blkptr_t *);
+uint64_t objset_space(const zfs_objset_t *);
+void objset_write(zfs_opt_t *zfs, zfs_objset_t *os);
+
+/* vdev.c */
+void vdev_init(zfs_opt_t *, const char *);
+off_t vdev_space_alloc(zfs_opt_t *zfs, off_t *lenp);
+void vdev_pwrite_data(zfs_opt_t *zfs, uint8_t datatype, uint8_t cksumtype,
+ uint8_t level, uint64_t fill, const void *data, off_t sz, off_t loc,
+ blkptr_t *bp);
+void vdev_pwrite_dnode_indir(zfs_opt_t *zfs, dnode_phys_t *dnode, uint8_t level,
+ uint64_t fill, const void *data, off_t sz, off_t loc, blkptr_t *bp);
+void vdev_pwrite_dnode_data(zfs_opt_t *zfs, dnode_phys_t *dnode, const void *data,
+ off_t sz, off_t loc);
+void vdev_label_write(zfs_opt_t *zfs, int ind, const vdev_label_t *labelp);
+void vdev_spacemap_write(zfs_opt_t *);
+void vdev_fini(zfs_opt_t *zfs);
+
+/* zap.c */
+zfs_zap_t *zap_alloc(zfs_objset_t *, dnode_phys_t *);
+void zap_add(zfs_zap_t *, const char *, size_t, size_t, const uint8_t *);
+void zap_add_uint64(zfs_zap_t *, const char *, uint64_t);
+void zap_add_string(zfs_zap_t *, const char *, const char *);
+bool zap_entry_exists(zfs_zap_t *, const char *);
+void zap_write(zfs_opt_t *, zfs_zap_t *);
+
+/* zfs.c */
+struct dnode_cursor *dnode_cursor_init(zfs_opt_t *, zfs_objset_t *,
+ dnode_phys_t *, off_t, off_t);
+blkptr_t *dnode_cursor_next(zfs_opt_t *, struct dnode_cursor *, off_t);
+void dnode_cursor_finish(zfs_opt_t *, struct dnode_cursor *);
+uint64_t randomguid(void);
+
+#endif /* !_MAKEFS_ZFS_H_ */
diff --git a/usr.sbin/makemap/Makefile b/usr.sbin/makemap/Makefile
index 2477060b7937..8d558a7b6795 100644
--- a/usr.sbin/makemap/Makefile
+++ b/usr.sbin/makemap/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.4 (Berkeley) 6/10/97
-# $FreeBSD$
SENDMAIL_DIR=${SRCTOP}/contrib/sendmail
.PATH: ${SENDMAIL_DIR}/makemap
@@ -28,3 +26,5 @@ sm_os.h: ${SENDMAIL_DIR}/include/sm/os/sm_os_freebsd.h .NOMETA
ln -sf ${.ALLSRC} ${.TARGET}
.include <bsd.prog.mk>
+
+CWARNFLAGS+= ${NO_WDEPRECATED_NON_PROTOTYPE}
diff --git a/usr.sbin/makemap/Makefile.depend b/usr.sbin/makemap/Makefile.depend
index 0feabbf167e0..ec81c06f90f1 100644
--- a/usr.sbin/makemap/Makefile.depend
+++ b/usr.sbin/makemap/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/manctl/Makefile b/usr.sbin/manctl/Makefile
index 9e0c12ecb9a9..e550b78644d8 100644
--- a/usr.sbin/manctl/Makefile
+++ b/usr.sbin/manctl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SCRIPTS=manctl.sh
MAN= manctl.8
diff --git a/usr.sbin/manctl/Makefile.depend b/usr.sbin/manctl/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/manctl/Makefile.depend
+++ b/usr.sbin/manctl/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/manctl/manctl.8 b/usr.sbin/manctl/manctl.8
index 01006d6738d3..c29654e3aca7 100644
--- a/usr.sbin/manctl/manctl.8
+++ b/usr.sbin/manctl/manctl.8
@@ -21,8 +21,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$
.Dd January 1, 1996
.Dt MANCTL 8
.Os
diff --git a/usr.sbin/manctl/manctl.sh b/usr.sbin/manctl/manctl.sh
index e79da64868a9..1b23d7901a2e 100644
--- a/usr.sbin/manctl/manctl.sh
+++ b/usr.sbin/manctl/manctl.sh
@@ -32,12 +32,11 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# manctl:
# a utility for manipulating manual pages
# functions:
-# compress uncompressed man pages (elliminating .so's)
+# compress uncompressed man pages (eliminating .so's)
# this is now two-pass. If possible, .so's
# are replaced with hard links
# uncompress compressed man pages
diff --git a/usr.sbin/memcontrol/Makefile b/usr.sbin/memcontrol/Makefile
index d465d531a3e9..6010a24ad082 100644
--- a/usr.sbin/memcontrol/Makefile
+++ b/usr.sbin/memcontrol/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= memcontrol
MAN= memcontrol.8
diff --git a/usr.sbin/memcontrol/Makefile.depend b/usr.sbin/memcontrol/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/memcontrol/Makefile.depend
+++ b/usr.sbin/memcontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/memcontrol/memcontrol.8 b/usr.sbin/memcontrol/memcontrol.8
index ad0e5330671b..5cc504f340bc 100644
--- a/usr.sbin/memcontrol/memcontrol.8
+++ b/usr.sbin/memcontrol/memcontrol.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd September 15, 2002
.Dt MEMCONTROL 8
.Os
diff --git a/usr.sbin/memcontrol/memcontrol.c b/usr.sbin/memcontrol/memcontrol.c
index 0b345b9c65e9..5f8fca7e66ef 100644
--- a/usr.sbin/memcontrol/memcontrol.c
+++ b/usr.sbin/memcontrol/memcontrol.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* 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 <sys/types.h>
diff --git a/usr.sbin/mergemaster/Makefile b/usr.sbin/mergemaster/Makefile
index 257fbeba4ca4..9dd7e2193db3 100644
--- a/usr.sbin/mergemaster/Makefile
+++ b/usr.sbin/mergemaster/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SCRIPTS=mergemaster.sh
MAN= mergemaster.8
diff --git a/usr.sbin/mergemaster/Makefile.depend b/usr.sbin/mergemaster/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/mergemaster/Makefile.depend
+++ b/usr.sbin/mergemaster/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/mergemaster/mergemaster.8 b/usr.sbin/mergemaster/mergemaster.8
index 2f5b85f30b4c..695f1bba3474 100644
--- a/usr.sbin/mergemaster/mergemaster.8
+++ b/usr.sbin/mergemaster/mergemaster.8
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd May 20, 2021
+.Dd March 2, 2023
.Dt MERGEMASTER 8
.Os
.Sh NAME
@@ -43,6 +41,17 @@
.Op Fl A Ar Target architecture
.Op Fl D Ar /destdir/path
.Sh DESCRIPTION
+.Bf -symbolic
+The
+.Nm
+utility is deprecated and may not be available in
+.Fx 14.0
+or later.
+Users are advised to use
+.Xr etcupdate 8
+instead.
+.Ef
+.Pp
The
.Nm
utility is a Bourne shell script which is designed to aid you
diff --git a/usr.sbin/mergemaster/mergemaster.sh b/usr.sbin/mergemaster/mergemaster.sh
index edbf07d743ee..572415164101 100755
--- a/usr.sbin/mergemaster/mergemaster.sh
+++ b/usr.sbin/mergemaster/mergemaster.sh
@@ -8,8 +8,6 @@
# Copyright (c) 1998-2012 Douglas Barton, All rights reserved
# Please see detailed copyright below
-# $FreeBSD$
-
PATH=/bin:/usr/bin:/usr/sbin
display_usage () {
@@ -782,7 +780,7 @@ CONFIRMED_UMASK=${NEW_UMASK:-0022}
# Warn users who still have old rc files
#
for file in atm devfs diskless1 diskless2 network network6 pccard \
- serial syscons sysctl alpha amd64 i386 sparc64; do
+ serial syscons sysctl alpha amd64 i386; do
if [ -f "${DESTDIR}/etc/rc.${file}" ]; then
OLD_RC_PRESENT=1
break
@@ -808,7 +806,7 @@ case "${OLD_RC_PRESENT}" in
*)
mkdir -p /var/tmp/mergemaster/old_rc
for file in atm devfs diskless1 diskless2 network network6 pccard \
- serial syscons sysctl alpha amd64 i386 sparc64; do
+ serial syscons sysctl alpha amd64 i386; do
if [ -f "${DESTDIR}/etc/rc.${file}" ]; then
mv ${DESTDIR}/etc/rc.${file} /var/tmp/mergemaster/old_rc/
fi
@@ -1248,7 +1246,7 @@ handle_symbolic_link () {
esac
}
-# Compare symblic links
+# Compare symbolic links
for COMPSYMLINK in `find . -type l | sort`; do
if [ ! -L "${DESTDIR}${COMPSYMLINK#.}" ]; then
if [ -n "${AUTO_RUN}" -a -z "${AUTO_INSTALL}" ]; then
diff --git a/usr.sbin/mfiutil/Makefile b/usr.sbin/mfiutil/Makefile
index dc6f3e481593..da1c9249f8cd 100644
--- a/usr.sbin/mfiutil/Makefile
+++ b/usr.sbin/mfiutil/Makefile
@@ -1,10 +1,11 @@
-# $FreeBSD$
PROG= mfiutil
+LINKS= ${BINDIR}/mfiutil ${BINDIR}/mrsasutil
SRCS= mfiutil.c mfi_bbu.c mfi_cmd.c mfi_config.c mfi_drive.c mfi_evt.c \
mfi_flash.c mfi_patrol.c mfi_show.c mfi_volume.c mfi_foreign.c \
mfi_properties.c
MAN8= mfiutil.8
+MLINKS= mfiutil.8 mrsasutil.8
CFLAGS.gcc+= -fno-builtin-strftime
diff --git a/usr.sbin/mfiutil/Makefile.depend b/usr.sbin/mfiutil/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/mfiutil/Makefile.depend
+++ b/usr.sbin/mfiutil/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/mfiutil/mfi_bbu.c b/usr.sbin/mfiutil/mfi_bbu.c
index 343d101661da..9075c4d0ddd0 100644
--- a/usr.sbin/mfiutil/mfi_bbu.c
+++ b/usr.sbin/mfiutil/mfi_bbu.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Sandvine Inc.
* 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 <sys/param.h>
@@ -134,7 +132,7 @@ start_bbu_learn(int ac, char **av __unused)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -171,7 +169,7 @@ update_bbu_props(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_cmd.c b/usr.sbin/mfiutil/mfi_cmd.c
index 094c9017348b..8e0a0aca32c4 100644
--- a/usr.sbin/mfiutil/mfi_cmd.c
+++ b/usr.sbin/mfiutil/mfi_cmd.c
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <sys/param.h>
@@ -44,6 +42,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <paths.h>
#include "mfiutil.h"
#include <dev/mfi/mfi_ioctl.h>
@@ -209,15 +208,23 @@ mfi_volume_busy(int fd, uint8_t target_id)
* configuration of the mfi controller.
*/
int
-mfi_reconfig_supported(void)
+mfi_reconfig_supported(const char *dev)
{
char mibname[64];
+ const char *cp;
size_t len;
- int dummy;
+ int dummy, mfi_unit;
+
+ cp = dev + strlen(_PATH_DEV);
+ if (strncmp(cp, MRSAS_TYPE, strlen(MRSAS_TYPE)) == 0)
+ return (1);
+
+ cp += strlen(MFI_TYPE);
+ mfi_unit = strtol(cp, NULL, 10);
len = sizeof(dummy);
- snprintf(mibname, sizeof(mibname), "dev.mfi.%d.delete_busy_volumes",
- mfi_unit);
+ snprintf(mibname, sizeof(mibname),
+ "dev.mfi.%d.delete_busy_volumes", mfi_unit);
return (sysctlbyname(mibname, &dummy, &len, NULL, 0) == 0);
}
@@ -239,7 +246,7 @@ mfi_lookup_volume(int fd, const char *name, uint8_t *target_id)
if (mfi_dcmd_command(fd, MFI_DCMD_LD_GET_LIST, &list, sizeof(list),
NULL, 0, NULL) < 0)
- return (-1);
+ return (-1);
for (i = 0; i < list.ld_count; i++) {
if (mfi_query_disk(fd, list.ld_list[i].ld.v.target_id,
@@ -304,12 +311,14 @@ mfi_ctrl_get_info(int fd, struct mfi_ctrl_info *info, uint8_t *statusp)
}
int
-mfi_open(int unit, int acs)
+mfi_open(char *dev, int acs)
{
- char path[MAXPATHLEN];
+ int ret;
- snprintf(path, sizeof(path), "/dev/mfi%d", unit);
- return (open(path, acs));
+ ret = open(dev, acs);
+ if (ret < 0)
+ warn("Couldn't open %s", dev);
+ return (ret);
}
static void
diff --git a/usr.sbin/mfiutil/mfi_config.c b/usr.sbin/mfiutil/mfi_config.c
index 0ee78fca0613..49c7fea16d31 100644
--- a/usr.sbin/mfiutil/mfi_config.c
+++ b/usr.sbin/mfiutil/mfi_config.c
@@ -27,14 +27,13 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <sys/param.h>
#ifdef DEBUG
#include <sys/sysctl.h>
#endif
+#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
@@ -52,30 +51,30 @@ static int remove_spare(int ac, char **av);
static long
dehumanize(const char *value)
{
- char *vtp;
- long iv;
-
- if (value == NULL)
- return (0);
- iv = strtoq(value, &vtp, 0);
- if (vtp == value || (vtp[0] != '\0' && vtp[1] != '\0')) {
- return (0);
- }
- switch (vtp[0]) {
- case 't': case 'T':
- iv *= 1024;
- case 'g': case 'G':
- iv *= 1024;
- case 'm': case 'M':
- iv *= 1024;
- case 'k': case 'K':
- iv *= 1024;
- case '\0':
- break;
- default:
- return (0);
- }
- return (iv);
+ char *vtp;
+ long iv;
+
+ if (value == NULL)
+ return (0);
+ iv = strtoq(value, &vtp, 0);
+ if (vtp == value || (vtp[0] != '\0' && vtp[1] != '\0')) {
+ return (0);
+ }
+ switch (vtp[0]) {
+ case 't': case 'T':
+ iv *= 1024;
+ case 'g': case 'G':
+ iv *= 1024;
+ case 'm': case 'M':
+ iv *= 1024;
+ case 'k': case 'K':
+ iv *= 1024;
+ case '\0':
+ break;
+ default:
+ return (0);
+ }
+ return (iv);
}
int
@@ -162,16 +161,16 @@ clear_config(int ac __unused, char **av __unused)
int ch, error, fd;
u_int i;
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
return (error);
}
- if (!mfi_reconfig_supported()) {
- warnx("The current mfi(4) driver does not support "
- "configuration changes.");
+ if (!mfi_reconfig_supported(mfi_device)) {
+ warnx("The current %s driver does not support "
+ "configuration changes.", mfi_device);
close(fd);
return (EOPNOTSUPP);
}
@@ -193,8 +192,8 @@ clear_config(int ac __unused, char **av __unused)
}
printf(
- "Are you sure you wish to clear the configuration on mfi%u? [y/N] ",
- mfi_unit);
+ "Are you sure you wish to clear the configuration on %s? [y/N] ",
+ mfi_device);
ch = getchar();
if (ch != 'y' && ch != 'Y') {
printf("\nAborting\n");
@@ -209,7 +208,7 @@ clear_config(int ac __unused, char **av __unused)
return (error);
}
- printf("mfi%d: Configuration cleared\n", mfi_unit);
+ printf("%s: Configuration cleared\n", mfi_device);
close(fd);
return (0);
@@ -587,16 +586,16 @@ create_volume(int ac, char **av)
narrays = 0;
error = 0;
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
return (error);
}
- if (!mfi_reconfig_supported()) {
- warnx("The current mfi(4) driver does not support "
- "configuration changes.");
+ if (!mfi_reconfig_supported(mfi_device)) {
+ warnx("The current %s(4) driver does not support "
+ "configuration changes.", mfi_device);
error = EOPNOTSUPP;
goto error;
}
@@ -869,16 +868,16 @@ delete_volume(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
return (error);
}
- if (!mfi_reconfig_supported()) {
- warnx("The current mfi(4) driver does not support "
- "configuration changes.");
+ if (!mfi_reconfig_supported(mfi_device)) {
+ warnx("The current %s(4) driver does not support "
+ "configuration changes.", mfi_device);
close(fd);
return (EOPNOTSUPP);
}
@@ -937,7 +936,7 @@ add_spare(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -1027,7 +1026,7 @@ add_spare(int ac, char **av)
ar->array_ref);
error = EINVAL;
goto error;
- }
+ }
spare->array_ref[i] = ar->array_ref;
}
}
@@ -1062,7 +1061,7 @@ remove_spare(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -1120,7 +1119,7 @@ dump_config(int fd, struct mfi_config_data *config, const char *msg_prefix)
msg_prefix = "Configuration (Debug)";
printf(
- "mfi%d %s: %d arrays, %d volumes, %d spares\n", mfi_unit,
+ "%s %s: %d arrays, %d volumes, %d spares\n", mfi_device,
msg_prefix, config->array_count, config->log_drv_count,
config->spares_count);
printf(" array size: %u\n", config->array_size);
@@ -1211,7 +1210,7 @@ debug_config(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -1248,7 +1247,7 @@ dump(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_drive.c b/usr.sbin/mfiutil/mfi_drive.c
index 4fd8fb93dd4c..e8e945c566c4 100644
--- a/usr.sbin/mfiutil/mfi_drive.c
+++ b/usr.sbin/mfiutil/mfi_drive.c
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <sys/types.h>
@@ -74,7 +72,7 @@ mfi_drive_name(struct mfi_pd_info *pinfo, uint16_t device_id, uint32_t def)
else
snprintf(buf, sizeof(buf), "%2u", device_id);
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
warn("mfi_open");
return (buf);
@@ -388,7 +386,7 @@ drive_set_state(char *drive, uint16_t new_state)
uint8_t mbox[6];
int error, fd;
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -503,7 +501,7 @@ start_rebuild(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -560,7 +558,7 @@ abort_rebuild(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -616,7 +614,7 @@ drive_progress(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -682,7 +680,7 @@ drive_clear(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -742,7 +740,7 @@ drive_locate(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_evt.c b/usr.sbin/mfiutil/mfi_evt.c
index 915fbb7125bf..9f6c0c2246ca 100644
--- a/usr.sbin/mfiutil/mfi_evt.c
+++ b/usr.sbin/mfiutil/mfi_evt.c
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <sys/types.h>
@@ -77,7 +75,7 @@ show_logstate(int ac, char **av __unused)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -91,13 +89,13 @@ show_logstate(int ac, char **av __unused)
return (error);
}
- printf("mfi%d Event Log Sequence Numbers:\n", mfi_unit);
+ printf("%s Event Log Sequence Numbers:\n", mfi_device);
printf(" Newest Seq #: %u\n", info.newest_seq_num);
printf(" Oldest Seq #: %u\n", info.oldest_seq_num);
printf(" Clear Seq #: %u\n", info.clear_seq_num);
printf("Shutdown Seq #: %u\n", info.shutdown_seq_num);
printf(" Boot Seq #: %u\n", info.boot_seq_num);
-
+
close(fd);
return (0);
@@ -547,7 +545,7 @@ show_events(int ac, char **av)
int ch, error, fd, num_events, verbose;
u_int i;
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -691,7 +689,7 @@ show_events(int ac, char **av)
* need to know the size of the buffer somehow.
*/
seq = list->event[list->count - 1].seq + 1;
-
+
}
finish:
if (first)
diff --git a/usr.sbin/mfiutil/mfi_flash.c b/usr.sbin/mfiutil/mfi_flash.c
index 239390acf7b5..2fbfc978edac 100644
--- a/usr.sbin/mfiutil/mfi_flash.c
+++ b/usr.sbin/mfiutil/mfi_flash.c
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <sys/param.h>
@@ -58,7 +56,7 @@ display_pending_firmware(int fd)
return (error);
}
- printf("mfi%d Pending Firmware Images:\n", mfi_unit);
+ printf("%s Pending Firmware Images:\n", mfi_device);
strcpy(header.name, "Name");
strcpy(header.version, "Version");
strcpy(header.build_date, "Date");
@@ -122,7 +120,7 @@ flash_adapter(int ac, char **av)
goto error;
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_foreign.c b/usr.sbin/mfiutil/mfi_foreign.c
index ce4b8a704bea..81b9933937c6 100644
--- a/usr.sbin/mfiutil/mfi_foreign.c
+++ b/usr.sbin/mfiutil/mfi_foreign.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 smh@freebsd.org
* All rights reserved.
@@ -25,8 +25,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- *
- * $FreeBSD$
*/
#include <sys/param.h>
@@ -48,7 +46,7 @@ foreign_clear(__unused int ac, __unused char **av)
{
int ch, error, fd;
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -57,7 +55,7 @@ foreign_clear(__unused int ac, __unused char **av)
printf(
"Are you sure you wish to clear ALL foreign configurations"
- " on mfi%u? [y/N] ", mfi_unit);
+ " on %s? [y/N] ", mfi_device);
ch = getchar();
if (ch != 'y' && ch != 'Y') {
@@ -74,7 +72,7 @@ foreign_clear(__unused int ac, __unused char **av)
return (error);
}
- printf("mfi%d: Foreign configuration cleared\n", mfi_unit);
+ printf("%s: Foreign configuration cleared\n", mfi_device);
close(fd);
return (0);
}
@@ -86,7 +84,7 @@ foreign_scan(__unused int ac, __unused char **av)
struct mfi_foreign_scan_info info;
int error, fd;
- fd = mfi_open(mfi_unit, O_RDONLY);
+ fd = mfi_open(mfi_device, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -101,7 +99,7 @@ foreign_scan(__unused int ac, __unused char **av)
return (error);
}
- printf("mfi%d: Found %d foreign configurations\n", mfi_unit,
+ printf("%s: Found %d foreign configurations\n", mfi_device,
info.count);
close(fd);
return (0);
@@ -143,7 +141,7 @@ foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic)
ld_list = (char *)(config->array);
- printf("%s: %d arrays, %d volumes, %d spares\n", prefix,
+ printf("%s: %d arrays, %d volumes, %d spares\n", prefix,
config->array_count, config->log_drv_count,
config->spares_count);
@@ -152,28 +150,28 @@ foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic)
ld_list += config->array_size;
for (i = 0; i < config->log_drv_count; i++) {
- const char *level;
- char size[6], stripe[5];
+ const char *level;
+ char size[6], stripe[5];
struct mfi_ld_config *ld;
ld = (struct mfi_ld_config *)ld_list;
- format_stripe(stripe, sizeof(stripe),
- ld->params.stripe_size);
+ format_stripe(stripe, sizeof(stripe),
+ ld->params.stripe_size);
/*
* foreign configs don't seem to have a secondary raid level
* but, we can use span depth here as if a LD spans multiple
* arrays of disks (2 raid 1 sets for example), we will have an
* indication based on the spam depth. swb
- */
- level = mfi_raid_level(ld->params.primary_raid_level,
- (ld->params.span_depth - 1));
+ */
+ level = mfi_raid_level(ld->params.primary_raid_level,
+ (ld->params.span_depth - 1));
- humanize_number(size, sizeof(size), ld->span[0].num_blocks * 512,
- "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
+ humanize_number(size, sizeof(size), ld->span[0].num_blocks * 512,
+ "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
printf(" ID%d ", i);
- printf("(%6s) %-8s |",
+ printf("(%6s) %-8s |",
size, level);
printf("volume spans %d %s\n", ld->params.span_depth,
(ld->params.span_depth > 1) ? "arrays" : "array");
@@ -183,9 +181,9 @@ foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic)
uint16_t device_id;
printf(" array %u @ ", ld->span[j].array_ref);
- humanize_number(size, sizeof(size), ld->span[j].num_blocks * 512,
- "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
-
+ humanize_number(size, sizeof(size), ld->span[j].num_blocks * 512,
+ "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
+
printf("(%6s)\n",size);
ar_list = (char *)config->array + (ld->span[j].array_ref * config->array_size);
@@ -196,7 +194,7 @@ foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic)
printf(" drive MISSING\n");
else {
printf(" drive %u %s\n", device_id,
- mfi_pdstate(ar->pd[k].fw_state));
+ mfi_pdstate(ar->pd[k].fw_state));
}
}
@@ -222,7 +220,7 @@ display_format(int ac, char **av, int diagnostic, mfi_dcmd_t display_cmd)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDONLY);
+ fd = mfi_open(mfi_device, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -262,7 +260,7 @@ display_format(int ac, char **av, int diagnostic, mfi_dcmd_t display_cmd)
return (error);
}
}
-
+
close(fd);
return (0);
}
@@ -294,7 +292,7 @@ foreign_import(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -318,7 +316,7 @@ foreign_import(int ac, char **av)
if (ac == 1) {
cfgidx = 0xff;
printf("Are you sure you wish to import ALL foreign "
- "configurations on mfi%u? [y/N] ", mfi_unit);
+ "configurations on %s? [y/N] ", mfi_device);
} else {
/*
* While this is docmmented for MegaCli this failed with
@@ -334,7 +332,7 @@ foreign_import(int ac, char **av)
return (EINVAL);
}
printf("Are you sure you wish to import the foreign "
- "configuration %d on mfi%u? [y/N] ", cfgidx, mfi_unit);
+ "configuration %d on %s? [y/N] ", cfgidx, mfi_device);
}
ch = getchar();
@@ -355,11 +353,11 @@ foreign_import(int ac, char **av)
}
if (ac == 1)
- printf("mfi%d: All foreign configurations imported\n",
- mfi_unit);
+ printf("%s: All foreign configurations imported\n",
+ mfi_device);
else
- printf("mfi%d: Foreign configuration %d imported\n", mfi_unit,
- cfgidx);
+ printf("%s: Foreign configuration %d imported\n",
+ mfi_device, cfgidx);
close(fd);
return (0);
}
diff --git a/usr.sbin/mfiutil/mfi_patrol.c b/usr.sbin/mfiutil/mfi_patrol.c
index a1dbb1336f1b..bbaea57ea020 100644
--- a/usr.sbin/mfiutil/mfi_patrol.c
+++ b/usr.sbin/mfiutil/mfi_patrol.c
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <sys/types.h>
@@ -89,7 +87,7 @@ show_patrol(int ac __unused, char **av __unused)
int error, fd;
u_int i;
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -199,7 +197,7 @@ start_patrol(int ac __unused, char **av __unused)
{
int error, fd;
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -225,7 +223,7 @@ stop_patrol(int ac __unused, char **av __unused)
{
int error, fd;
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -295,7 +293,7 @@ patrol_config(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_properties.c b/usr.sbin/mfiutil/mfi_properties.c
index f5affe14bd50..3b2eeca079f1 100644
--- a/usr.sbin/mfiutil/mfi_properties.c
+++ b/usr.sbin/mfiutil/mfi_properties.c
@@ -1,9 +1,9 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Yahoo!, Inc.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -25,8 +25,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- *
- * $FreeBSD$
*/
#include <sys/errno.h>
@@ -64,8 +62,8 @@ mfi_ctrl_set_properties(int fd, struct mfi_ctrl_props *info)
}
/*
- * aquite the controller properties data structure modify the
- * rebuild rate if requested and then retun
+ * Acquire the controller properties data structure, modify the
+ * rebuild rate if requested and then return
*/
static int
mfi_ctrl_rebuild_rate(int ac, char **av)
@@ -77,8 +75,8 @@ mfi_ctrl_rebuild_rate(int ac, char **av)
warn("mfi_ctrl_set_rebuild_rate");
return(-1);
}
-
- fd = mfi_open(mfi_unit, O_RDWR);
+
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -129,8 +127,8 @@ mfi_ctrl_alarm_enable(int ac, char **av)
warn("mfi_ctrl_alarm_enable");
return(-1);
}
-
- fd = mfi_open(mfi_unit, O_RDWR);
+
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_show.c b/usr.sbin/mfiutil/mfi_show.c
index 17c967762963..bf85c8b82d69 100644
--- a/usr.sbin/mfiutil/mfi_show.c
+++ b/usr.sbin/mfiutil/mfi_show.c
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <sys/types.h>
@@ -50,7 +48,7 @@ void
format_stripe(char *buf, size_t buflen, uint8_t stripe)
{
- humanize_number(buf, buflen, (1 << stripe) * 512, "", HN_AUTOSCALE,
+ humanize_number(buf, buflen, (1 << stripe) * 512, "", HN_AUTOSCALE,
HN_B | HN_NOSPACE);
}
@@ -66,7 +64,7 @@ show_adapter(int ac, char **av __unused)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDONLY);
+ fd = mfi_open(mfi_device, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -79,7 +77,7 @@ show_adapter(int ac, char **av __unused)
close(fd);
return (error);
}
- printf("mfi%d Adapter:\n", mfi_unit);
+ printf("%s Adapter:\n", mfi_device);
printf(" Product Name: %.80s\n", info.product_name);
printf(" Serial Number: %.32s\n", info.serial_number);
if (info.package_version[0] != '\0')
@@ -155,7 +153,7 @@ show_battery(int ac, char **av __unused)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDONLY);
+ fd = mfi_open(mfi_device, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -170,7 +168,7 @@ show_battery(int ac, char **av __unused)
return (error);
}
if (status == MFI_STAT_NO_HW_PRESENT) {
- printf("mfi%d: No battery present\n", mfi_unit);
+ printf("%s: No battery present\n", mfi_device);
close(fd);
return (0);
}
@@ -200,7 +198,7 @@ show_battery(int ac, char **av __unused)
}
show_props = (status == MFI_STAT_OK);
- printf("mfi%d: Battery State:\n", mfi_unit);
+ printf("%s: Battery State:\n", mfi_device);
printf(" Manufacture Date: %d/%d/%d\n", design.mfg_date >> 5 & 0x0f,
design.mfg_date & 0x1f, design.mfg_date >> 9 & 0xffff);
printf(" Serial Number: %d\n", design.serial_number);
@@ -357,7 +355,7 @@ show_config(int ac, char **av __unused)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDONLY);
+ fd = mfi_open(mfi_device, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -373,8 +371,8 @@ show_config(int ac, char **av __unused)
}
/* Dump out the configuration. */
- printf("mfi%d Configuration: %d arrays, %d volumes, %d spares\n",
- mfi_unit, config->array_count, config->log_drv_count,
+ printf("%s Configuration: %d arrays, %d volumes, %d spares\n",
+ mfi_device, config->array_count, config->log_drv_count,
config->spares_count);
p = (char *)config->array;
@@ -458,7 +456,7 @@ show_volumes(int ac, char **av __unused)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDONLY);
+ fd = mfi_open(mfi_device, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -474,7 +472,7 @@ show_volumes(int ac, char **av __unused)
}
/* List the volumes. */
- printf("mfi%d Volumes:\n", mfi_unit);
+ printf("%s Volumes:\n", mfi_device);
state_len = strlen("State");
for (i = 0; i < list.ld_count; i++) {
len = strlen(mfi_ldstate(list.ld_list[i].state));
@@ -541,7 +539,7 @@ show_drives(int ac, char **av __unused)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDONLY);
+ fd = mfi_open(mfi_device, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -576,7 +574,7 @@ show_drives(int ac, char **av __unused)
}
/* List the drives. */
- printf("mfi%d Physical Drives:\n", mfi_unit);
+ printf("%s Physical Drives:\n", mfi_device);
for (i = 0; i < list->count; i++) {
/* Skip non-hard disks. */
@@ -621,7 +619,7 @@ show_firmware(int ac, char **av __unused)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDONLY);
+ fd = mfi_open(mfi_device, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -636,9 +634,9 @@ show_firmware(int ac, char **av __unused)
}
if (info.package_version[0] != '\0')
- printf("mfi%d Firmware Package Version: %s\n", mfi_unit,
+ printf("%s Firmware Package Version: %s\n", mfi_device,
info.package_version);
- printf("mfi%d Firmware Images:\n", mfi_unit);
+ printf("%s Firmware Images:\n", mfi_device);
strcpy(header.name, "Name");
strcpy(header.version, "Version");
strcpy(header.build_date, "Date");
@@ -681,7 +679,7 @@ show_progress(int ac, char **av __unused)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDONLY);
+ fd = mfi_open(mfi_device, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -776,7 +774,8 @@ show_progress(int ac, char **av __unused)
close(fd);
if (!busy)
- printf("No activity in progress for adapter mfi%d\n", mfi_unit);
+ printf("No activity in progress for adapter %s\n",
+ mfi_device);
return (0);
}
diff --git a/usr.sbin/mfiutil/mfi_volume.c b/usr.sbin/mfiutil/mfi_volume.c
index 2bc913374b86..8cf2c95b5927 100644
--- a/usr.sbin/mfiutil/mfi_volume.c
+++ b/usr.sbin/mfiutil/mfi_volume.c
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <sys/types.h>
@@ -297,7 +295,7 @@ volume_cache(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -319,7 +317,7 @@ volume_cache(int ac, char **av)
}
if (ac == 2) {
- printf("mfi%u volume %s cache settings:\n", mfi_unit,
+ printf("%s volume %s cache settings:\n", mfi_device,
mfi_volume_name(fd, target_id));
printf(" I/O caching: ");
switch (props.default_cache_policy &
@@ -406,7 +404,7 @@ volume_name(int ac, char **av)
return (ENOSPC);
}
- fd = mfi_open(mfi_unit, O_RDWR);
+ fd = mfi_open(mfi_device, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -427,7 +425,7 @@ volume_name(int ac, char **av)
return (error);
}
- printf("mfi%u volume %s name changed from \"%s\" to \"%s\"\n", mfi_unit,
+ printf("%s volume %s name changed from \"%s\" to \"%s\"\n", mfi_device,
mfi_volume_name(fd, target_id), props.name, av[2]);
bzero(props.name, sizeof(props.name));
strcpy(props.name, av[2]);
@@ -457,7 +455,7 @@ volume_progress(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit, O_RDONLY);
+ fd = mfi_open(mfi_device, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfiutil.8 b/usr.sbin/mfiutil/mfiutil.8
index e3adc0b65698..86dc6b6ee122 100644
--- a/usr.sbin/mfiutil/mfiutil.8
+++ b/usr.sbin/mfiutil/mfiutil.8
@@ -25,32 +25,41 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd September 2, 2011
.Dt MFIUTIL 8
.Os
.Sh NAME
-.Nm mfiutil
+.Nm mfiutil ,
+.Nm mrsasutil
.Nd Utility for managing LSI MegaRAID SAS controllers
.Sh SYNOPSIS
.Nm
.Cm version
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm show adapter
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm show battery
.Nm
.Op Fl d
.Op Fl e
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm show config
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm show drives
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm show events
.Op Fl c Ar class
@@ -59,67 +68,107 @@
.Op Fl v
.Op Ar start Op Ar stop
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm show firmware
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm show foreign Op Ar volume
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm show logstate
.Nm
.Op Fl d
.Op Fl e
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm show patrol
.Nm
.Op Fl d
.Op Fl e
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm show progress
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm show volumes
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm fail Ar drive
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm good Ar drive
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm rebuild Ar drive
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm syspd Ar drive
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm drive progress Ar drive
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm drive clear Ar drive Brq "start | stop"
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm start rebuild Ar drive
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm abort rebuild Ar drive
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm locate Ar drive Brq "on | off"
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm cache Ar volume Op Ar setting Oo Ar value Oc Op ...
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm name Ar volume Ar name
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm volume progress Ar volume
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm clear
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm create Ar type
.Op Fl v
@@ -127,51 +176,83 @@
.Ar drive Ns Op \&, Ns Ar drive Ns Op ",..."
.Op Ar drive Ns Op \&, Ns Ar drive Ns Op ",..."
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm delete Ar volume
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm add Ar drive Op Ar volume
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm remove Ar drive
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm start patrol
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm stop patrol
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm patrol Ar command Op Ar interval Op Ar start
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm foreign scan
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm foreign clear Op Ar config
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm foreign diag Op Ar config
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm foreign preview Op Ar config
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm foreign import Op Ar config
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm flash Ar file
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm start learn
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm bbu Ar setting Ar value
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm ctrlprop Ar rebuild Op Ar rate
.Nm
+.Op Fl D Ar device
+.Op Fl t Ar type
.Op Fl u Ar unit
.Cm ctrlprop Ar alarm Op Ar 0/1
.Sh DESCRIPTION
@@ -185,8 +266,22 @@ consists of zero or more global options followed by a command.
Commands may support additional optional or required arguments after the
command.
.Pp
-Currently one global option is supported:
+Currently three global options are supported:
.Bl -tag -width indent
+.It Fl D Ar device
+.Ar device
+specifies the device node of the controller to use.
+'/dev/' will be added to the device node if needed.
+If no device node is specified,
+then device will be made of the type and device.
+.It Fl t Ar type
+.Ar type
+specifies the type of the controller to work with either
+.Xr mfi 4
+or
+.Xr mrsas 4 .
+If no type is specified,
+then the name of the invoked tool used to derive the type.
.It Fl u Ar unit
.Ar unit
specifies the unit of the controller to work with.
@@ -326,7 +421,8 @@ the controller for each low-level request.
The default is 15 events.
.Pp
By default, matching event log entries from the previous shutdown up to the
-present are displayed. This range can be adjusted via the
+present are displayed.
+This range can be adjusted via the
.Ar start
and
.Ar stop
@@ -383,7 +479,8 @@ The firmware should kick off an array rebuild on its own if a failed drive
is marked as a rebuild drive.
.It Cm syspd Ar drive
Present the drive to the host operating system as a disk SYSPD block device in
-the format /dev/mfisyspdX. Clear this flag with
+the format /dev/mfisyspdX.
+Clear this flag with
.Cm good
.Ar drive
.It Cm drive progress Ar drive
@@ -524,7 +621,7 @@ Creates a single volume by concatenating all of the drives in the single drive
list.
.El
.Pp
-.Sy Note:
+.Sy Note :
Not all volume types are supported by all controllers.
.Pp
If the
@@ -602,7 +699,8 @@ Start a patrol read operation.
.It Cm stop patrol
Stop a currently running patrol read operation.
.It Cm foreign scan
-Scan for foreign configurations and display the number found. The
+Scan for foreign configurations and display the number found.
+The
.Ar config
argument for the commands below takes the form of a number from 0 to the total
configurations found.
@@ -645,8 +743,8 @@ Update battery backup unit (BBU) properties related to battery relearning.
The following settings are configurable:
.Bl -tag -width indent
.It Cm learn-delay
-Add a delay to the next scheduled battery relearn event. This setting is
-given in hours and must lie in the range of 0 to 255.
+Add a delay to the next scheduled battery relearn event.
+This setting is given in hours and must lie in the range of 0 to 255.
.It Cm autolearn-mode
Enable or disable automatic periodic battery relearning.
The setting may be set to
@@ -659,7 +757,8 @@ Mode 0 enables periodic relearning, mode 1 disables it, and mode 2 disables
it and logs a warning to the event log when it detects that a battery relearn
should be performed.
.It Cm bbu-mode
-Set the BBU's mode of operation. This setting is not supported by all BBUs.
+Set the BBU's mode of operation.
+This setting is not supported by all BBUs.
Where it is supported, the possible values are the integers between 1 and 5
inclusive.
Modes 1, 2 and 3 enable a transparent learn cycle, whereas modes 4 and 5 do not.
@@ -670,7 +769,8 @@ With no arguments display the rate of rebuild (percentage)a for volumes.
With an integer argument (0-100), set that value as the new rebuild rate for volumes.
.It Cm ctrlprop Ar alarm Op Ar 0/1
With no arguments display the current alarm enable/disable status.
-With a 0, disable alarms. With a 1, enable alarms.
+With a 0, disable alarms.
+With a 1, enable alarms.
.El
.Sh EXAMPLES
Configure the cache for volume mfid0 to cache only writes:
@@ -715,7 +815,8 @@ Display the second detected foreign configuration:
Set the current rebuild rate for volumes to 40%:
.Dl Nm Cm ctrlprop rebuild 40
.Sh SEE ALSO
-.Xr mfi 4
+.Xr mfi 4 ,
+.Xr mrsas 4
.Sh HISTORY
The
.Nm
diff --git a/usr.sbin/mfiutil/mfiutil.c b/usr.sbin/mfiutil/mfiutil.c
index 8d4dffc0c918..c6df9908b634 100644
--- a/usr.sbin/mfiutil/mfiutil.c
+++ b/usr.sbin/mfiutil/mfiutil.c
@@ -27,16 +27,17 @@
* 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/errno.h>
+#include <sys/param.h>
+
#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <paths.h>
#include "mfiutil.h"
SET_DECLARE(MFI_DATASET(top), struct mfiutil_command);
@@ -45,7 +46,7 @@ MFI_TABLE(top, start);
MFI_TABLE(top, stop);
MFI_TABLE(top, abort);
-int mfi_unit;
+char *mfi_device = NULL;
u_int mfi_opts;
static int fw_name_width, fw_version_width, fw_date_width, fw_time_width;
@@ -53,7 +54,7 @@ static void
usage(void)
{
- fprintf(stderr, "usage: mfiutil [-de] [-u unit] <command> ...\n\n");
+ fprintf(stderr, "usage: %s [-de] [-D device] [-u unit] [-t type] <command> ...\n\n", getprogname());
fprintf(stderr, "Commands include:\n");
fprintf(stderr, " version\n");
fprintf(stderr, " show adapter - display controller information\n");
@@ -121,10 +122,24 @@ int
main(int ac, char **av)
{
struct mfiutil_command **cmd;
- int ch;
+ int ch, mfi_unit;
+ const char *pn, *mfi_type;
+ char *temp;
+
+ mfi_unit = 0;
+
+ pn = getprogname();
+
+ if (strcmp(pn, "mrsasutil") == 0)
+ mfi_type = MRSAS_TYPE;
+ else
+ mfi_type = MFI_TYPE;
- while ((ch = getopt(ac, av, "deu:")) != -1) {
+ while ((ch = getopt(ac, av, "D:det:u:")) != -1) {
switch (ch) {
+ case 'D':
+ mfi_device = optarg;
+ break;
case 'd':
mfi_opts |= MFI_DNAME_DEVICE_ID;
break;
@@ -134,11 +149,27 @@ main(int ac, char **av)
case 'u':
mfi_unit = atoi(optarg);
break;
+ case 't':
+ mfi_type = optarg;
+ break;
case '?':
usage();
}
}
+ if (mfi_device == NULL) {
+ if (asprintf(&mfi_device, "%s%s%d", _PATH_DEV, mfi_type,
+ mfi_unit) < 0)
+ errx(1, "Can't allocate memory for device name\n");
+ } else {
+ if (strncmp(mfi_device, _PATH_DEV, strlen(_PATH_DEV)) != 0) {
+ if (asprintf(&temp, "%s%s%d", _PATH_DEV, mfi_type,
+ mfi_unit) < 0)
+ errx(1, "Can't allocate memory for device name\n");
+ mfi_device = temp;
+ }
+ }
+
av += optind;
ac -= optind;
diff --git a/usr.sbin/mfiutil/mfiutil.h b/usr.sbin/mfiutil/mfiutil.h
index cedac5ac1dd5..34b423098862 100644
--- a/usr.sbin/mfiutil/mfiutil.h
+++ b/usr.sbin/mfiutil/mfiutil.h
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#ifndef __MFIUTIL_H__
@@ -39,6 +37,9 @@
#include <dev/mfi/mfireg.h>
+#define MRSAS_TYPE "mrsas"
+#define MFI_TYPE "mfi"
+
/* 4.x compat */
#ifndef SET_DECLARE
@@ -122,7 +123,7 @@ struct mfiutil_command {
#define MFI_DNAME_DEVICE_ID 0x0002 /* %u */
#define MFI_DNAME_HONOR_OPTS 0x8000 /* Allow cmd line to override default */
-extern int mfi_unit;
+extern char *mfi_device;
extern u_int mfi_opts;
@@ -154,7 +155,7 @@ int mfi_lookup_drive(int fd, char *drive, uint16_t *device_id);
int mfi_lookup_volume(int fd, const char *name, uint8_t *target_id);
int mfi_dcmd_command(int fd, uint32_t opcode, void *buf, size_t bufsize,
uint8_t *mbox, size_t mboxlen, uint8_t *statusp);
-int mfi_open(int unit, int acs);
+int mfi_open(char *dev, int acs);
int mfi_ctrl_get_info(int fd, struct mfi_ctrl_info *info, uint8_t *statusp);
int mfi_ld_get_info(int fd, uint8_t target_id, struct mfi_ld_info *info,
uint8_t *statusp);
@@ -162,7 +163,7 @@ int mfi_ld_get_list(int fd, struct mfi_ld_list *list, uint8_t *statusp);
int mfi_pd_get_info(int fd, uint16_t device_id, struct mfi_pd_info *info,
uint8_t *statusp);
int mfi_pd_get_list(int fd, struct mfi_pd_list **listp, uint8_t *statusp);
-int mfi_reconfig_supported(void);
+int mfi_reconfig_supported(const char *mfi_device);
const char *mfi_status(u_int status_code);
const char *mfi_drive_name(struct mfi_pd_info *pinfo, uint16_t device_id,
uint32_t def);
@@ -177,6 +178,8 @@ int mfi_bbu_set_props(int fd, struct mfi_bbu_properties *props,
void mfi_autolearn_period(uint32_t, char *, size_t);
void mfi_next_learn_time(uint32_t, char *, size_t);
void mfi_autolearn_mode(uint8_t, char *, size_t);
+int get_mfi_unit(const char *dev);
+char *get_mfi_type(const char *dev);
void scan_firmware(struct mfi_info_component *comp);
void display_firmware(struct mfi_info_component *comp, const char *tag);
diff --git a/usr.sbin/mixer/Makefile b/usr.sbin/mixer/Makefile
index 6bbc6f07c7e1..0dab386e0873 100644
--- a/usr.sbin/mixer/Makefile
+++ b/usr.sbin/mixer/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/mixer/Makefile.depend b/usr.sbin/mixer/Makefile.depend
index 6cfaab1c3644..40aed37205a9 100644
--- a/usr.sbin/mixer/Makefile.depend
+++ b/usr.sbin/mixer/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/libmixer \
.include <dirdeps.mk>
diff --git a/usr.sbin/mixer/mixer.8 b/usr.sbin/mixer/mixer.8
index 284750538f7e..75c6a81e3a55 100644
--- a/usr.sbin/mixer/mixer.8
+++ b/usr.sbin/mixer/mixer.8
@@ -19,9 +19,7 @@
.\" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
.\" THE SOFTWARE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd March 20, 2022
+.Dd February 8, 2024
.Dt MIXER 8
.Os
.Sh NAME
@@ -30,12 +28,11 @@
.Sh SYNOPSIS
.Nm
.Op Fl f Ar device
-.Op Fl d Ar unit
+.Op Fl d Ar pcmN | N
.Op Fl os
.Op Ar dev Ns Op Cm \&. Ns Ar control Ns Op Cm \&= Ns Ar value
.Ar ...
.Nm
-.Op Fl d Ar unit
.Op Fl os
.Fl a
.Nm
@@ -46,16 +43,17 @@ The
utility is used to set and display soundcard mixer device controls.
.Pp
The options are as follows:
-.Bl -tag -width "-f device"
+.Bl -tag -width "-d pcmN | N"
.It Fl a
Print the values for all mixer devices available in the system
.Pq see Sx FILES .
-.It Fl d Ar unit
+.It Fl d Ar pcmN | N
Change the default audio card to
-.Ar unit .
-The unit has to be an integer value.
-To see what unit values are available, look at the number each mixer device has by running
-.Nm .
+.Ar pcmN ,
+where N is the unit number (e.g for pcm0, the unit number is 0).
+See
+.Sx EXAMPLES
+on how to list all available audio devices in the system.
.It Fl f Ar device
Open
.Ar device
@@ -112,11 +110,13 @@ with one of the available devices):
.It Sy Name Ta Sy Value
.It Ar dev Cm .volume Ta Xo
.Ar vol |
-.Oo Cm \&+ | Cm \&- Oc Ar lvol
-.Oo Cm \&: Oo Cm \&+ | Cm \&- Oc Ar rvol Oc
+.Oo Cm \&+ | Cm \&- Oc Ar lvol Oo % Oc
+.Oo Cm \&: Oo Cm \&+ | Cm \&- Oc Ar rvol Oo % Oc Oc
.Xc
.It Ar dev Cm .mute Ta Cm 0 | 1 | ^
+.It Ar dev Cm .mute Ta Cm off | on | toggle
.It Ar dev Cm .recsrc Ta Cm ^ | + | - | =
+.It Ar dev Cm .recsrc Ta Cm toggle | add | remove | set
.El
.Sm on
.Pp
@@ -128,16 +128,21 @@ The optional
and/or
.Ar rvol
values have to be specified.
-The values have to be normalized 32-bit floats, from 0.0 to 1.0 inclusively.
-If no
-.Ql \&.
-character is present, the value is treated like a percentage, for backwards compatibility.
+The values should typically be decimal numbers between 0 and 1 with at most 2
+digits after the decimal point.
+A trailing percent sign indicates that the value should be treated as a
+percentage of 1.0, rather than an absolute value.
+Thus, 70% means the same as 0.7.
If the left or right volume values are prefixed with
.Cm +
or
.Cm - ,
the value following will be used as a relative adjustment, modifying the
current settings by the amount specified.
+Note that relative percentages are still relative to 1.0, not to the current
+value.
+If the volume is currently 0.40 and an adjustment of +20% is specified, then
+thet final volume will be set to 0.60.
.Pp
Volume can also be set using the shorthand
.Ar dev Ns Cm =value .
@@ -147,14 +152,14 @@ The
.Ar dev Ns Cm .mute
control (un)mutes a device.
The following values are available:
-.Bl -tag -width = -offset indent
-.It Cm 0
+.Bl -tag -width "xxxxxxxxxx" -offset indent
+.It Cm 0 | off
unmutes
.Ar dev
-.It Cm 1
+.It Cm 1 | on
mutes
.Ar dev
-.It Cm ^
+.It Cm ^ | toggle
toggles the mute of
.Ar dev
.El
@@ -171,22 +176,23 @@ To modify the recording source you can use one of the following modifiers
on a
.Sy rec
device:
-.Bl -tag -width = -offset indent
-.It Cm ^
+.Bl -tag -width "xxxxxxxxxx" -offset indent
+.It Cm ^ | toggle
toggles
.Ar dev
of possible recording devices
-.It Cm +
+.It Cm + | add
adds
.Ar dev
to possible recording devices
-.It Cm -
+.It Cm - | remove
removes
.Ar dev
from possible recording devices
-.It Cm =
-sets the recording device to
+.It Cm = | set
+makes
.Ar dev
+the only recording device.
.El
.Sh FILES
.Bl -tag -width /dev/mixerN -compact
@@ -215,6 +221,18 @@ opens when the
option has not been specified.
.El
.Sh EXAMPLES
+List all available audio devices in the system:
+.Bd -literal -offset indent
+$ mixer -a | grep ^pcm
+.Ed
+.Pp
+Increase the
+.Cm vol
+device's volume by 5%:
+.Bd -literal -offset indent
+$ mixer vol=+5%
+.Ed
+.Pp
Change the volume for the
.Cm vol
device of the
@@ -235,16 +253,16 @@ $ mixer mic.volume=+0.10:-0.05
Toggle the mute for
.Cm vol :
.Bd -literal -offset indent
-$ mixer vol.mute=^
+$ mixer vol.mute=toggle
.Ed
.Pp
-Set
+Add
.Cm mic
-and toggle
+and remove
.Cm line
-recording sources:
+from the recording devices:
.Bd -literal -offset indent
-$ mixer mic.recsrc=+ line.recsrc=^
+$ mixer mic.recsrc=add line.recsrc=remove
.Ed
.Pp
Dump
diff --git a/usr.sbin/mixer/mixer.c b/usr.sbin/mixer/mixer.c
index c0a9ec25c6fa..47d8e6359b73 100644
--- a/usr.sbin/mixer/mixer.c
+++ b/usr.sbin/mixer/mixer.c
@@ -18,8 +18,6 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
- *
- * $FreeBSD$
*/
#include <err.h>
@@ -42,8 +40,8 @@ static void printall(struct mixer *, int);
static void printminfo(struct mixer *, int);
static void printdev(struct mixer *, int);
static void printrecsrc(struct mixer *, int); /* XXX: change name */
+static int set_dunit(struct mixer *, int);
/* Control handlers */
-static int mod_dunit(struct mix_dev *, void *);
static int mod_volume(struct mix_dev *, void *);
static int mod_mute(struct mix_dev *, void *);
static int mod_recsrc(struct mix_dev *, void *);
@@ -51,14 +49,6 @@ static int print_volume(struct mix_dev *, void *);
static int print_mute(struct mix_dev *, void *);
static int print_recsrc(struct mix_dev *, void *);
-static const mix_ctl_t ctl_dunit = {
- .parent_dev = NULL,
- .id = -1,
- .name = "default_unit",
- .mod = mod_dunit,
- .print = NULL
-};
-
int
main(int argc, char *argv[])
{
@@ -76,9 +66,12 @@ main(int argc, char *argv[])
aflag = 1;
break;
case 'd':
+ if (strncmp(optarg, "pcm", 3) == 0)
+ optarg += 3;
+ errno = 0;
dunit = strtol(optarg, NULL, 10);
if (errno == EINVAL || errno == ERANGE)
- err(1, "strtol");
+ err(1, "strtol(%s)", optarg);
dflag = 1;
break;
case 'f':
@@ -102,11 +95,11 @@ main(int argc, char *argv[])
/* Print all mixers and exit. */
if (aflag) {
if ((n = mixer_get_nmixers()) < 0)
- err(1, "mixer_get_nmixers");
+ errx(1, "no mixers present in the system");
for (i = 0; i < n; i++) {
(void)snprintf(buf, sizeof(buf), "/dev/mixer%d", i);
if ((m = mixer_open(buf)) == NULL)
- err(1, "mixer_open: %s", buf);
+ errx(1, "%s: no such mixer", buf);
initctls(m);
if (sflag)
printrecsrc(m, oflag);
@@ -121,12 +114,25 @@ main(int argc, char *argv[])
}
if ((m = mixer_open(name)) == NULL)
- err(1, "mixer_open: %s", name);
+ errx(1, "%s: no such mixer", name);
initctls(m);
- if (dflag && ctl_dunit.mod(m->dev, &dunit) < 0)
- goto parse;
+ if (dflag) {
+ if (set_dunit(m, dunit) < 0)
+ goto parse;
+ else {
+ /*
+ * Open current mixer since we changed the default
+ * unit, otherwise we'll print and apply changes to the
+ * old one.
+ */
+ (void)mixer_close(m);
+ if ((m = mixer_open(NULL)) == NULL)
+ errx(1, "cannot open default mixer");
+ initctls(m);
+ }
+ }
if (sflag) {
printrecsrc(m, oflag);
(void)mixer_close(m);
@@ -203,8 +209,8 @@ next:
static void __dead2
usage(void)
{
- fprintf(stderr, "usage: %1$s [-f device] [-d unit] [-os] [dev[.control[=value]]] ...\n"
- " %1$s [-d unit] [-os] -a\n"
+ fprintf(stderr, "usage: %1$s [-f device] [-d pcmN | N] [-os] [dev[.control[=value]]] ...\n"
+ " %1$s [-os] -a\n"
" %1$s -h\n", getprogname());
exit(1);
}
@@ -222,7 +228,7 @@ initctls(struct mixer *m)
}
if (rc) {
(void)mixer_close(m);
- err(1, "cannot make controls");
+ errx(1, "cannot make mixer controls");
}
}
@@ -316,20 +322,19 @@ printrecsrc(struct mixer *m, int oflag)
}
static int
-mod_dunit(struct mix_dev *d, void *p)
+set_dunit(struct mixer *m, int dunit)
{
- int dunit = *((int *)p);
int n;
if ((n = mixer_get_dunit()) < 0) {
warn("cannot get default unit");
return (-1);
}
- if (mixer_set_dunit(d->parent_mixer, dunit) < 0) {
- warn("cannot set default unit to: %d", dunit);
+ if (mixer_set_dunit(m, dunit) < 0) {
+ warn("cannot set default unit to %d", dunit);
return (-1);
}
- printf("%s: %d -> %d\n", ctl_dunit.name, n, dunit);
+ printf("default_unit: %d -> %d\n", n, dunit);
return (0);
}
@@ -341,7 +346,7 @@ mod_volume(struct mix_dev *d, void *p)
mix_ctl_t *cp;
mix_volume_t v;
const char *val;
- char lstr[8], rstr[8];
+ char *endp, lstr[8], rstr[8];
float lprev, rprev, lrel, rrel;
int n;
@@ -356,25 +361,32 @@ mod_volume(struct mix_dev *d, void *p)
lrel = rrel = 0;
if (n > 0) {
if (*lstr == '+' || *lstr == '-')
- lrel = rrel = 1;
- v.left = strtof(lstr, NULL);
+ lrel = 1;
+ v.left = strtof(lstr, &endp);
+ if (*endp != '\0' && (*endp != '%' || *(endp + 1) != '\0')) {
+ warnx("invalid volume value: %s", lstr);
+ return (-1);
+ }
- /* be backwards compatible */
- if (strstr(lstr, ".") == NULL)
+ if (*endp == '%')
v.left /= 100.0f;
}
if (n > 1) {
if (*rstr == '+' || *rstr == '-')
rrel = 1;
- v.right = strtof(rstr, NULL);
+ v.right = strtof(rstr, &endp);
+ if (*endp != '\0' && (*endp != '%' || *(endp + 1) != '\0')) {
+ warnx("invalid volume value: %s", rstr);
+ return (-1);
+ }
- /* be backwards compatible */
- if (strstr(rstr, ".") == NULL)
+ if (*endp == '%')
v.right /= 100.0f;
}
switch (n) {
case 1:
v.right = v.left; /* FALLTHROUGH */
+ rrel = lrel;
case 2:
if (lrel)
v.left += m->dev->vol.left;
@@ -414,26 +426,24 @@ mod_mute(struct mix_dev *d, void *p)
m = d->parent_mixer;
cp = mixer_get_ctl(m->dev, C_MUT);
val = p;
- switch (*val) {
- case '0':
+ if (strncmp(val, "off", strlen(val)) == 0 || *val == '0')
opt = MIX_UNMUTE;
- break;
- case '1':
+ else if (strncmp(val, "on", strlen(val)) == 0 || *val == '1')
opt = MIX_MUTE;
- break;
- case '^':
+ else if (strncmp(val, "toggle", strlen(val)) == 0 || *val == '^')
opt = MIX_TOGGLEMUTE;
- break;
- default:
- warnx("%c: no such modifier", *val);
+ else {
+ warnx("%s: no such modifier", val);
return (-1);
}
n = MIX_ISMUTE(m, m->dev->devno);
if (mixer_set_mute(m, opt) < 0)
- warn("%s.%s=%c", m->dev->name, cp->name, *val);
+ warn("%s.%s=%s", m->dev->name, cp->name, val);
else
- printf("%s.%s: %d -> %d\n",
- m->dev->name, cp->name, n, MIX_ISMUTE(m, m->dev->devno));
+ printf("%s.%s: %s -> %s\n",
+ m->dev->name, cp->name,
+ n ? "on" : "off",
+ MIX_ISMUTE(m, m->dev->devno) ? "on" : "off");
return (0);
}
@@ -449,29 +459,26 @@ mod_recsrc(struct mix_dev *d, void *p)
m = d->parent_mixer;
cp = mixer_get_ctl(m->dev, C_SRC);
val = p;
- switch (*val) {
- case '+':
+ if (strncmp(val, "add", strlen(val)) == 0 || *val == '+')
opt = MIX_ADDRECSRC;
- break;
- case '-':
+ else if (strncmp(val, "remove", strlen(val)) == 0 || *val == '-')
opt = MIX_REMOVERECSRC;
- break;
- case '=':
+ else if (strncmp(val, "set", strlen(val)) == 0 || *val == '=')
opt = MIX_SETRECSRC;
- break;
- case '^':
+ else if (strncmp(val, "toggle", strlen(val)) == 0 || *val == '^')
opt = MIX_TOGGLERECSRC;
- break;
- default:
- warnx("%c: no such modifier", *val);
+ else {
+ warnx("%s: no such modifier", val);
return (-1);
}
n = MIX_ISRECSRC(m, m->dev->devno);
if (mixer_mod_recsrc(m, opt) < 0)
- warn("%s.%s=%c", m->dev->name, cp->name, *val);
+ warn("%s.%s=%s", m->dev->name, cp->name, val);
else
- printf("%s.%s: %d -> %d\n",
- m->dev->name, cp->name, n, MIX_ISRECSRC(m, m->dev->devno));
+ printf("%s.%s: %s -> %s\n",
+ m->dev->name, cp->name,
+ n ? "add" : "remove",
+ MIX_ISRECSRC(m, m->dev->devno) ? "add" : "remove");
return (0);
}
@@ -494,7 +501,8 @@ print_mute(struct mix_dev *d, void *p)
struct mixer *m = d->parent_mixer;
const char *ctl_name = p;
- printf("%s.%s=%d\n", m->dev->name, ctl_name, MIX_ISMUTE(m, m->dev->devno));
+ printf("%s.%s=%s\n", m->dev->name, ctl_name,
+ MIX_ISMUTE(m, m->dev->devno) ? "on" : "off");
return (0);
}
@@ -507,7 +515,7 @@ print_recsrc(struct mix_dev *d, void *p)
if (!MIX_ISRECSRC(m, m->dev->devno))
return (-1);
- printf("%s.%s=+\n", m->dev->name, ctl_name);
+ printf("%s.%s=add\n", m->dev->name, ctl_name);
return (0);
}
diff --git a/usr.sbin/mld6query/Makefile b/usr.sbin/mld6query/Makefile
index 33503600d164..270acdc9ede6 100644
--- a/usr.sbin/mld6query/Makefile
+++ b/usr.sbin/mld6query/Makefile
@@ -12,7 +12,6 @@
# LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE.
#
-# $FreeBSD$
PROG= mld6query
MAN= mld6query.8
diff --git a/usr.sbin/mld6query/Makefile.depend b/usr.sbin/mld6query/Makefile.depend
index d5ed563ecfc8..344a5d0e9310 100644
--- a/usr.sbin/mld6query/Makefile.depend
+++ b/usr.sbin/mld6query/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/mld6query/mld6.c b/usr.sbin/mld6query/mld6.c
index 2506308702d4..7a8bc8c05446 100644
--- a/usr.sbin/mld6query/mld6.c
+++ b/usr.sbin/mld6query/mld6.c
@@ -31,9 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/uio.h>
#include <sys/socket.h>
@@ -107,7 +104,7 @@ main(int argc, char *argv[])
switch (ch) {
case 'd':
if (type != MLD_LISTENER_QUERY) {
- printf("Can not specifiy -d with -r\n");
+ printf("Can not specify -d with -r\n");
return 1;
}
type = MLD_LISTENER_DONE;
@@ -117,7 +114,7 @@ main(int argc, char *argv[])
break;
case 'r':
if (type != MLD_LISTENER_QUERY) {
- printf("Can not specifiy -r with -d\n");
+ printf("Can not specify -r with -d\n");
return 1;
}
type = MLD_LISTENER_REPORT;
@@ -140,7 +137,7 @@ main(int argc, char *argv[])
if (argc == 2 && inet_pton(AF_INET6, argv[1], &maddr) != 1)
usage();
if (type != MLD_LISTENER_QUERY && qaddr != &maddr) {
- printf("Can not specifiy -g with -d or -r\n");
+ printf("Can not specify -g with -d or -r\n");
return 1;
}
@@ -270,7 +267,7 @@ make_msg(int index, struct in6_addr *addr, u_int type, struct in6_addr *qaddr)
pi = (struct in6_pktinfo *)CMSG_DATA(cmsgp);
pi->ipi6_ifindex = index;
memcpy(&pi->ipi6_addr, &src, sizeof(pi->ipi6_addr));
- /* specifiy to insert router alert option in a hop-by-hop opt hdr. */
+ /* specify to insert router alert option in a hop-by-hop opt hdr. */
cmsgp = CMSG_NXTHDR(&m, cmsgp);
cmsgp->cmsg_len = CMSG_LEN(hbhlen);
cmsgp->cmsg_level = IPPROTO_IPV6;
diff --git a/usr.sbin/mld6query/mld6query.8 b/usr.sbin/mld6query/mld6query.8
index 1f75e0e60518..289c48108906 100644
--- a/usr.sbin/mld6query/mld6query.8
+++ b/usr.sbin/mld6query/mld6query.8
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 17, 1998
.Dt MLD6QUERY 8
.Os
diff --git a/usr.sbin/mlx5tool/Makefile b/usr.sbin/mlx5tool/Makefile
index c8d0277c541d..b6896b270b89 100644
--- a/usr.sbin/mlx5tool/Makefile
+++ b/usr.sbin/mlx5tool/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= mlx-tools
diff --git a/usr.sbin/trpt/Makefile.depend b/usr.sbin/mlx5tool/Makefile.depend
index d5ed563ecfc8..6ef78fac5cbf 100644
--- a/usr.sbin/trpt/Makefile.depend
+++ b/usr.sbin/mlx5tool/Makefile.depend
@@ -1,10 +1,7 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
- include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
diff --git a/usr.sbin/mlx5tool/mlx5tool.8 b/usr.sbin/mlx5tool/mlx5tool.8
index 6e0eee0eac4f..17f0fd515a50 100644
--- a/usr.sbin/mlx5tool/mlx5tool.8
+++ b/usr.sbin/mlx5tool/mlx5tool.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 7, 2019
.Dt mlx5tool 8
.Os
diff --git a/usr.sbin/mlx5tool/mlx5tool.c b/usr.sbin/mlx5tool/mlx5tool.c
index 4d2cbe51cffa..f58434c91740 100644
--- a/usr.sbin/mlx5tool/mlx5tool.c
+++ b/usr.sbin/mlx5tool/mlx5tool.c
@@ -23,9 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
diff --git a/usr.sbin/mlxcontrol/Makefile b/usr.sbin/mlxcontrol/Makefile
index 5a425fd003da..d18ed4ac77a5 100644
--- a/usr.sbin/mlxcontrol/Makefile
+++ b/usr.sbin/mlxcontrol/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= mlxcontrol
MAN= mlxcontrol.8
diff --git a/usr.sbin/mlxcontrol/Makefile.depend b/usr.sbin/mlxcontrol/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/mlxcontrol/Makefile.depend
+++ b/usr.sbin/mlxcontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/mlxcontrol/command.c b/usr.sbin/mlxcontrol/command.c
index 9e2f5dd2a643..23663d7d1983 100644
--- a/usr.sbin/mlxcontrol/command.c
+++ b/usr.sbin/mlxcontrol/command.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Michael Smith
* 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 <fcntl.h>
diff --git a/usr.sbin/mlxcontrol/config.c b/usr.sbin/mlxcontrol/config.c
index d236e5d585de..471720c6a251 100644
--- a/usr.sbin/mlxcontrol/config.c
+++ b/usr.sbin/mlxcontrol/config.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Michael Smith
* 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 <fcntl.h>
diff --git a/usr.sbin/mlxcontrol/interface.c b/usr.sbin/mlxcontrol/interface.c
index 41ec08dd94ea..7e83ae8f0abd 100644
--- a/usr.sbin/mlxcontrol/interface.c
+++ b/usr.sbin/mlxcontrol/interface.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Michael Smith
* 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 <fcntl.h>
diff --git a/usr.sbin/mlxcontrol/mlxcontrol.8 b/usr.sbin/mlxcontrol/mlxcontrol.8
index 33788b94b070..0d8c546d1833 100644
--- a/usr.sbin/mlxcontrol/mlxcontrol.8
+++ b/usr.sbin/mlxcontrol/mlxcontrol.8
@@ -21,8 +21,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 April 10, 2000
.Dt MLXCONTROL 8
.Os
diff --git a/usr.sbin/mlxcontrol/mlxcontrol.h b/usr.sbin/mlxcontrol/mlxcontrol.h
index 79f7a1938de9..e204faefd183 100644
--- a/usr.sbin/mlxcontrol/mlxcontrol.h
+++ b/usr.sbin/mlxcontrol/mlxcontrol.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Michael Smith
* 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 <sys/queue.h>
diff --git a/usr.sbin/mlxcontrol/util.c b/usr.sbin/mlxcontrol/util.c
index 137c9e461954..2b472266fb2d 100644
--- a/usr.sbin/mlxcontrol/util.c
+++ b/usr.sbin/mlxcontrol/util.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Michael Smith
* 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 <sys/types.h>
diff --git a/usr.sbin/mount_smbfs/Makefile b/usr.sbin/mount_smbfs/Makefile
index 64f428035700..1ba3430551dd 100644
--- a/usr.sbin/mount_smbfs/Makefile
+++ b/usr.sbin/mount_smbfs/Makefile
@@ -1,6 +1,6 @@
-# $FreeBSD$
PROG= mount_smbfs
+PACKAGE= smbutils
SRCS= mount_smbfs.c getmntopts.c
MAN= mount_smbfs.8
diff --git a/usr.sbin/mount_smbfs/Makefile.depend b/usr.sbin/mount_smbfs/Makefile.depend
index 6d0625c20465..bd0ab591e5b1 100644
--- a/usr.sbin/mount_smbfs/Makefile.depend
+++ b/usr.sbin/mount_smbfs/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/libkiconv \
lib/libsmb \
diff --git a/usr.sbin/mountd/Makefile b/usr.sbin/mountd/Makefile
index bc16512c5a26..980842b93b19 100644
--- a/usr.sbin/mountd/Makefile
+++ b/usr.sbin/mountd/Makefile
@@ -1,5 +1,3 @@
-# From: @(#)Makefile 8.3 (Berkeley) 1/25/94
-# $FreeBSD$
PROG= mountd
SRCS= mountd.c getmntopts.c
diff --git a/usr.sbin/mountd/Makefile.depend b/usr.sbin/mountd/Makefile.depend
index 741d5bc5bd59..7e5c47e39608 100644
--- a/usr.sbin/mountd/Makefile.depend
+++ b/usr.sbin/mountd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
diff --git a/usr.sbin/mountd/exports.5 b/usr.sbin/mountd/exports.5
index d5aa49a1f428..33ab4f693978 100644
--- a/usr.sbin/mountd/exports.5
+++ b/usr.sbin/mountd/exports.5
@@ -25,10 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)exports.5 8.3 (Berkeley) 3/29/95
-.\" $FreeBSD$
-.\"
-.Dd November 9, 2021
+.Dd April 7, 2024
.Dt EXPORTS 5
.Os
.Sh NAME
@@ -109,6 +106,17 @@ any
or
.Dq Pa ..
components.
+Pathnames are decoded by
+.Xr strunvis 3
+allowing special characters to be included in the directory name(s).
+In particular, whitespace, such as embedded blanks in directory names
+can be handled.
+For example, a blank can be encoded as \(rs040.
+.Xr vis 1
+with the
+.Fl M
+option may be used to encode directory name(s) with embedded special
+characters.
Mount points for a file system may appear on multiple lines each with
different sets of hosts and export options.
.Pp
@@ -251,7 +259,7 @@ The
and
.Fl tlscertuser
export options are used to require the client to use TLS for the mount(s)
-per RFC NNNN.
+per RFC 9289.
For NFS mounts using TLS to work,
.Xr rpc.tlsservd 8
must be running on the server.
@@ -412,6 +420,13 @@ file.
the default remote mount-point file
.El
.Sh EXAMPLES
+Given that
+.Pa /usr , /u , /a
+and
+.Pa /u2
+are
+local file system mount points, let's consider the following example:
+.Pp
.Bd -literal -offset indent
/usr /usr/local -maproot=0:10 friends
/usr -maproot=daemon grumpy.cis.uoguelph.ca 131.104.48.16
@@ -428,27 +443,21 @@ V4: / -sec=krb5:krb5i:krb5p -network 131.104.48 -mask 255.255.255.0
V4: / -sec=sys:krb5:krb5i:krb5p grumpy.cis.uoguelph.ca
.Ed
.Pp
-Given that
-.Pa /usr , /u , /a
-and
-.Pa /u2
-are
-local file system mount points, the above example specifies the following:
-.Pp
-The file system rooted at
+The file systems rooted at
.Pa /usr
-is exported to hosts
-.Em friends
-where friends is specified in the netgroup file
+and
+.Pa /usr/local
+are exported to hosts within the
+.Dq friends
+network group
with users mapped to their remote credentials and
root mapped to UID 0 and group 10.
-It is exported read-write and the hosts in
-.Dq friends
-can mount either
+They are exported read-write and the hosts in
+.Dq friends .
+.Pp
+The file system rooted at
.Pa /usr
-or
-.Pa /usr/local .
-It is exported to
+is exported to
.Em 131.104.48.16
and
.Em grumpy.cis.uoguelph.ca
@@ -584,6 +593,8 @@ NFSv4 mount request for a directory that the client does not have
permission for will succeed and read/write access will fail
afterwards, whereas NFSv3 rejects the mount request.
.Sh SEE ALSO
+.Xr vis 1 ,
+.Xr strunvis 3 ,
.Xr nfsv4 4 ,
.Xr netgroup 5 ,
.Xr mountd 8 ,
@@ -591,12 +602,21 @@ afterwards, whereas NFSv3 rejects the mount request.
.Xr rpc.tlsservd 8 ,
.Xr showmount 8
.Sh STANDARDS
-The implementation is based on the specification in
+The implementation is based on the following documents:
+.Bl -dash
+.It
.Rs
.%T "Network File System Protocol Specification, Appendix A, RFC 1094"
+.Re
+.It
+.Rs
.%T "NFS: Network File System Version 3, Appendix I, RFC 1813"
-.%T "Towards Remote Procedure Call Encryption By Default, RFC nnnn"
.Re
+.It
+.Rs
+.%T "Towards Remote Procedure Call Encryption by Default, RFC 9289"
+.Re
+.El
.Sh BUGS
The export options are tied to the local mount points in the kernel and
must be non-contradictory for any exported subdirectory of the local
diff --git a/usr.sbin/mountd/mountd.8 b/usr.sbin/mountd/mountd.8
index 128b305cb5d9..6528aa3c94a1 100644
--- a/usr.sbin/mountd/mountd.8
+++ b/usr.sbin/mountd/mountd.8
@@ -25,10 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)mountd.8 8.4 (Berkeley) 4/28/95
-.\" $FreeBSD$
-.\"
-.Dd October 11, 2020
+.Dd April 8, 2024
.Dt MOUNTD 8
.Os
.Sh NAME
@@ -38,7 +35,7 @@
mount requests
.Sh SYNOPSIS
.Nm
-.Op Fl 2delnRrS
+.Op Fl 2AdelnRrS
.Op Fl h Ar bindip
.Op Fl p Ar port
.Op Ar exportsfile ...
@@ -63,6 +60,16 @@ Allow the administrator to force clients to use only the
version 2
.Tn NFS
protocol to mount file systems from this server.
+.It Fl A
+Silence the warnings related to
+.Dq administrative controls .
+These warnings remind users that an exported
+.Dq administrative control
+directory that is not a local server file system mount point
+actually exports the entire local file system and not just
+the subtree below the directory exported.
+(See
+.Xr exports 5 )
.It Fl d
Output debugging information.
.Nm
@@ -158,7 +165,7 @@ When
is started,
it loads the export host addresses and options into the kernel
using the
-.Xr mount 2
+.Xr nmount 2
system call.
After changing the exports file,
a hangup signal should be sent to the
@@ -172,6 +179,20 @@ check the syslog output to see if
logged any parsing
errors in the exports file.
.Pp
+If multiple instances of
+.Nm
+are being run, either in multiple jails or both within
+and outside of a jail, care must be taken to export
+any given file system in only one of the instances.
+Note that the
+.Va allow.nfsd
+jail parameter is required to allow
+.Nm
+to run in a jail.
+See
+.Xr jail 8
+for more information.
+.Pp
If
.Nm
detects that the running kernel does not include
@@ -185,6 +206,15 @@ If this fails, or no
KLD was available,
.Nm
exits with an error.
+When run in a jail, the
+.Xr kldload 2
+must be done outside the jail, typically by adding
+.Dq nfsd
+to
+.Va kld_list
+in the
+.Xr rc.conf 5
+file on the jail host.
.Sh FILES
.Bl -tag -width /var/run/mountd.pid -compact
.It Pa /etc/exports
@@ -199,6 +229,8 @@ the current list of remote mounted file systems
.Xr kldload 2 ,
.Xr nfsv4 4 ,
.Xr exports 5 ,
+.Xr rc.conf 5 ,
+.Xr jail 8 ,
.Xr nfsd 8 ,
.Xr rpcbind 8 ,
.Xr showmount 8
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 569ea0fbf707..14693a922186 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -32,21 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /*not lint*/
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95";
-#endif /*not lint*/
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
@@ -85,6 +70,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <vis.h>
#include "pathnames.h"
#include "mntopts.h"
@@ -144,10 +130,11 @@ struct exportlist {
SLIST_ENTRY(exportlist) entries;
};
/* ex_flag bits */
-#define EX_LINKED 0x1
-#define EX_DONE 0x2
-#define EX_DEFSET 0x4
-#define EX_PUBLICFH 0x8
+#define EX_LINKED 0x01
+#define EX_DONE 0x02
+#define EX_DEFSET 0x04
+#define EX_PUBLICFH 0x08
+#define EX_ADMINWARN 0x10
SLIST_HEAD(exportlisthead, exportlist);
@@ -210,7 +197,9 @@ static void add_dlist(struct dirlist **, struct dirlist *,
struct grouplist *, int, struct exportlist *,
struct expcred *, uint64_t);
static void add_mlist(char *, char *);
-static int check_dirpath(char *);
+static int check_path_component(const char *, char **);
+static int check_dirpath(char *, char **);
+static int check_statfs(const char *, struct statfs *, char **);
static int check_options(struct dirlist *);
static int checkmask(struct sockaddr *sa);
static int chk_host(struct dirlist *, struct sockaddr *, int *, int *,
@@ -284,11 +273,12 @@ static char *exnames_default[2] = { _PATH_EXPORTS, NULL };
static char **exnames;
static char **hosts = NULL;
static int force_v2 = 0;
+static int warn_admin = 1;
static int resvport_only = 1;
static int nhosts = 0;
static int dir_only = 1;
static int dolog = 0;
-static int got_sighup = 0;
+static _Atomic(int) got_sighup = 0;
static int xcreated = 0;
static char *svcport_str = NULL;
@@ -319,6 +309,7 @@ static struct pidfh *pfh = NULL;
#define OP_QUIET 0x100
#define OP_MASKLEN 0x200
#define OP_SEC 0x400
+#define OP_CLASSMASK 0x800 /* mask not specified, is Class A/B/C default */
#ifdef DEBUG
static int debug = 1;
@@ -445,11 +436,14 @@ main(int argc, char **argv)
else
close(s);
- while ((c = getopt(argc, argv, "2deh:lnp:RrS")) != -1)
+ while ((c = getopt(argc, argv, "2Adeh:lnp:RrS")) != -1)
switch (c) {
case '2':
force_v2 = 1;
break;
+ case 'A':
+ warn_admin = 0;
+ break;
case 'e':
/* now a no-op, since this is the default */
break;
@@ -779,7 +773,7 @@ main(int argc, char **argv)
/*
* This routine creates and binds sockets on the appropriate
* addresses. It gets called one time for each transport.
- * It returns 0 upon success, 1 for ingore the call and -1 to indicate
+ * It returns 0 upon success, 1 for ignore the call and -1 to indicate
* bind failed with EADDRINUSE.
* Any file descriptors that have been created are stored in sock_fd and
* the total count of them is maintained in sock_fdcnt.
@@ -1557,12 +1551,16 @@ get_exportlist_one(int passno)
struct statfs fsb;
struct expcred anon;
char *cp, *endcp, *dirp, *hst, *usr, *dom, savedc;
+ char *err_msg = NULL;
int len, has_host, got_nondir, dirplen, netgrp;
uint64_t exflags;
+ char unvis_dir[PATH_MAX + 1];
+ int unvis_len;
v4root_phase = 0;
anon.cr_groups = NULL;
dirhead = (struct dirlist *)NULL;
+ unvis_dir[0] = '\0';
while (get_line()) {
if (debug)
warnx("got line %s", line);
@@ -1629,17 +1627,25 @@ get_exportlist_one(int passno)
} else if (*cp == '/') {
savedc = *endcp;
*endcp = '\0';
+ unvis_len = strnunvis(unvis_dir, sizeof(unvis_dir),
+ cp);
+ if (unvis_len <= 0) {
+ getexp_err(ep, tgrp, "Cannot strunvis "
+ "decode dir");
+ goto nextline;
+ }
if (v4root_phase > 1) {
if (dirp != NULL) {
getexp_err(ep, tgrp, "Multiple V4 dirs");
goto nextline;
}
}
- if (check_dirpath(cp) &&
- statfs(cp, &fsb) >= 0) {
+ if (check_dirpath(unvis_dir, &err_msg) &&
+ check_statfs(unvis_dir, &fsb, &err_msg)) {
if ((fsb.f_flags & MNT_AUTOMOUNTED) != 0)
syslog(LOG_ERR, "Warning: exporting of "
- "automounted fs %s not supported", cp);
+ "automounted fs %s not supported",
+ unvis_dir);
if (got_nondir) {
getexp_err(ep, tgrp, "dirs must be first");
goto nextline;
@@ -1650,16 +1656,17 @@ get_exportlist_one(int passno)
goto nextline;
}
if (strlen(v4root_dirpath) == 0) {
- strlcpy(v4root_dirpath, cp,
+ strlcpy(v4root_dirpath, unvis_dir,
sizeof (v4root_dirpath));
- } else if (strcmp(v4root_dirpath, cp)
+ } else if (strcmp(v4root_dirpath, unvis_dir)
!= 0) {
syslog(LOG_ERR,
- "different V4 dirpath %s", cp);
+ "different V4 dirpath %s",
+ unvis_dir);
getexp_err(ep, tgrp, NULL);
goto nextline;
}
- dirp = cp;
+ dirp = unvis_dir;
v4root_phase = 2;
got_nondir = 1;
ep = get_exp();
@@ -1694,15 +1701,37 @@ get_exportlist_one(int passno)
fsb.f_fsid.val[1]);
}
+ if (warn_admin != 0 &&
+ (ep->ex_flag & EX_ADMINWARN) == 0 &&
+ strcmp(unvis_dir, fsb.f_mntonname) !=
+ 0) {
+ if (debug)
+ warnx("exporting %s exports entire "
+ "%s file system", unvis_dir,
+ fsb.f_mntonname);
+ syslog(LOG_ERR, "Warning: exporting %s "
+ "exports entire %s file system",
+ unvis_dir, fsb.f_mntonname);
+ ep->ex_flag |= EX_ADMINWARN;
+ }
+
/*
* Add dirpath to export mount point.
*/
- dirp = add_expdir(&dirhead, cp, len);
- dirplen = len;
+ dirp = add_expdir(&dirhead, unvis_dir,
+ unvis_len);
+ dirplen = unvis_len;
}
} else {
- getexp_err(ep, tgrp,
- "symbolic link in export path or statfs failed");
+ if (err_msg != NULL) {
+ getexp_err(ep, tgrp, err_msg);
+ free(err_msg);
+ err_msg = NULL;
+ } else {
+ getexp_err(ep, tgrp,
+ "symbolic link in export path or "
+ "statfs failed");
+ }
goto nextline;
}
*endcp = savedc;
@@ -1749,6 +1778,11 @@ get_exportlist_one(int passno)
nextfield(&cp, &endcp);
len = endcp - cp;
}
+ if (opt_flags & OP_CLASSMASK)
+ syslog(LOG_WARNING,
+ "WARNING: No mask specified for %s, "
+ "using out-of-date default",
+ (&grp->gr_ptr.gt_net)->nt_name);
if (check_options(dirhead)) {
getexp_err(ep, tgrp, NULL);
goto nextline;
@@ -2300,7 +2334,7 @@ compare_export(struct exportlist *ep, struct exportlist *oep)
* "same" refers to having the same set of values in the two arrays.
* The arrays are in no particular order and duplicates (multiple entries
* in an array with the same value) is allowed.
- * The algorithm is inefficient, but the common case of indentical arrays is
+ * The algorithm is inefficient, but the common case of identical arrays is
* handled first and "n" is normally fairly small.
* Since the two functions need the same algorithm but for arrays of
* different types (gid_t vs int), this is done as a macro.
@@ -3385,6 +3419,7 @@ get_net(char *cp, struct netmsk *net, int maskflg)
goto fail;
bcopy(sa, &net->nt_mask, sa->sa_len);
opt_flags |= OP_HAVEMASK;
+ opt_flags &= ~OP_CLASSMASK;
} else {
/* The specified sockaddr is a network address. */
bcopy(sa, &net->nt_net, sa->sa_len);
@@ -3418,9 +3453,6 @@ get_net(char *cp, struct netmsk *net, int maskflg)
(opt_flags & OP_MASK) == 0) {
in_addr_t addr;
- syslog(LOG_WARNING,
- "WARNING: No mask specified for %s, "
- "using out-of-date default", name);
addr = ((struct sockaddr_in *)sa)->sin_addr.s_addr;
if (IN_CLASSA(addr))
preflen = 8;
@@ -3435,7 +3467,7 @@ get_net(char *cp, struct netmsk *net, int maskflg)
bcopy(sa, &net->nt_mask, sa->sa_len);
makemask(&net->nt_mask, (int)preflen);
- opt_flags |= OP_HAVEMASK;
+ opt_flags |= OP_HAVEMASK | OP_CLASSMASK;
}
}
@@ -3786,29 +3818,76 @@ check_options(struct dirlist *dp)
return (0);
}
+static int
+check_path_component(const char *path, char **err)
+{
+ struct stat sb;
+
+ if (lstat(path, &sb)) {
+ asprintf(err, "%s: lstat() failed: %s.\n",
+ path, strerror(errno));
+ return (0);
+ }
+
+ switch (sb.st_mode & S_IFMT) {
+ case S_IFDIR:
+ return (1);
+ case S_IFLNK:
+ asprintf(err, "%s: path is a symbolic link.\n", path);
+ break;
+ case S_IFREG:
+ asprintf(err, "%s: path is a file rather than a directory.\n",
+ path);
+ break;
+ default:
+ asprintf(err, "%s: path is not a directory.\n", path);
+ }
+
+ return (0);
+}
+
/*
- * Check an absolute directory path for any symbolic links. Return true
+ * Check each path component for the presence of symbolic links. Return true
*/
static int
-check_dirpath(char *dirp)
+check_dirpath(char *dirp, char **err)
{
char *cp;
- int ret = 1;
- struct stat sb;
cp = dirp + 1;
- while (*cp && ret) {
+ while (*cp) {
if (*cp == '/') {
*cp = '\0';
- if (lstat(dirp, &sb) < 0 || !S_ISDIR(sb.st_mode))
- ret = 0;
+
+ if (!check_path_component(dirp, err)) {
+ *cp = '/';
+ return (0);
+ }
+
*cp = '/';
}
cp++;
}
- if (lstat(dirp, &sb) < 0 || !S_ISDIR(sb.st_mode))
- ret = 0;
- return (ret);
+
+ if (!check_path_component(dirp, err))
+ return (0);
+
+ return (1);
+}
+
+/*
+ * Populate statfs information. Return true on success.
+ */
+static int
+check_statfs(const char *dirp, struct statfs *fsb, char **err)
+{
+ if (statfs(dirp, fsb)) {
+ asprintf(err, "%s: statfs() failed: %s\n", dirp,
+ strerror(errno));
+ return (0);
+ }
+
+ return (1);
}
/*
diff --git a/usr.sbin/mountd/netgroup.5 b/usr.sbin/mountd/netgroup.5
index 80d78f47cc83..85e3d2f72da0 100644
--- a/usr.sbin/mountd/netgroup.5
+++ b/usr.sbin/mountd/netgroup.5
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)netgroup.5 8.2 (Berkeley) 12/11/93
-.\" $FreeBSD$
-.\"
.Dd December 11, 1993
.Dt NETGROUP 5
.Os
diff --git a/usr.sbin/mountd/pathnames.h b/usr.sbin/mountd/pathnames.h
index 0a0c74644cb1..a97961419cc8 100644
--- a/usr.sbin/mountd/pathnames.h
+++ b/usr.sbin/mountd/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/usr.sbin/moused/Makefile b/usr.sbin/moused/Makefile
index 0f9eac5b2417..030fefbaa313 100644
--- a/usr.sbin/moused/Makefile
+++ b/usr.sbin/moused/Makefile
@@ -1,5 +1,5 @@
-# $FreeBSD$
+PACKAGE= console-tools
PROG= moused
MAN= moused.8
diff --git a/usr.sbin/moused/Makefile.depend b/usr.sbin/moused/Makefile.depend
index a015e205da56..af3b7054df7a 100644
--- a/usr.sbin/moused/Makefile.depend
+++ b/usr.sbin/moused/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/moused/moused.8 b/usr.sbin/moused/moused.8
index d3b98a5d135a..9eeb48547866 100644
--- a/usr.sbin/moused/moused.8
+++ b/usr.sbin/moused/moused.8
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 15, 2008
.Dt MOUSED 8
.Os
diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c
index 08aa16f6103b..201e0b6ce0f6 100644
--- a/usr.sbin/moused/moused.c
+++ b/usr.sbin/moused/moused.c
@@ -46,9 +46,6 @@
**
**/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/consio.h>
#include <sys/mouse.h>
@@ -3013,7 +3010,7 @@ pnpparse(pnpid_t *id, char *buf, int len)
id->revision = ((buf[1] & 0x3f) << 6) | (buf[2] & 0x3f);
debug("PnP rev %d.%02d", id->revision / 100, id->revision % 100);
- /* EISA vender and product ID */
+ /* EISA vendor and product ID */
id->eisaid = &buf[3];
id->neisaid = 7;
@@ -3053,7 +3050,7 @@ pnpparse(pnpid_t *id, char *buf, int len)
}
/*
* PnP COM spec prior to v0.96 allowed '*' in this field,
- * it's not allowed now; just igore it.
+ * it's not allowed now; just ignore it.
*/
if (buf[j] == '*')
++j;
diff --git a/usr.sbin/mpsutil/Makefile b/usr.sbin/mpsutil/Makefile
index 0bc981366650..aa59d8cddf76 100644
--- a/usr.sbin/mpsutil/Makefile
+++ b/usr.sbin/mpsutil/Makefile
@@ -1,18 +1,13 @@
-# $FreeBSD$
-
PROG= mpsutil
SRCS= mps_cmd.c mps_debug.c mps_flash.c mps_set.c mps_show.c mps_slot.c mpsutil.c
MAN= mpsutil.8
WARNS?= 3
-#LIBADD= cam util
LINKS= ${BINDIR}/mpsutil ${BINDIR}/mprutil
MLINKS= mpsutil.8 mprutil.8
CFLAGS+= -I${SRCTOP}/sys -I. -DUSE_MPT_IOCTLS
-# Avoid dirdep dependency on libutil
-CFLAGS+= -I${SRCTOP}/lib/libutil
# Here be dragons
.ifdef DEBUG
diff --git a/usr.sbin/mpsutil/Makefile.depend b/usr.sbin/mpsutil/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/mpsutil/Makefile.depend
+++ b/usr.sbin/mpsutil/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/mpsutil/mps_cmd.c b/usr.sbin/mpsutil/mps_cmd.c
index a9cb269abc5f..e8828ce0509c 100644
--- a/usr.sbin/mpsutil/mps_cmd.c
+++ b/usr.sbin/mpsutil/mps_cmd.c
@@ -33,9 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
@@ -723,25 +720,39 @@ mps_pass_command(int fd, void *req, uint32_t req_len, void *reply,
return (0);
}
+/* Return the length in bytes of the device's MPI2_IOC_FACTS reply */
+static size_t
+mps_get_ioc_factslen(int fd)
+{
+ MPI2_IOC_FACTS_REQUEST req;
+ const size_t factslen = 4;
+ char factsbuf[4] = {0};
+ MPI2_IOC_FACTS_REPLY *facts = (MPI2_IOC_FACTS_REPLY*)factsbuf;
+ int error;
+
+ bzero(&req, sizeof(req));
+ req.Function = MPI2_FUNCTION_IOC_FACTS;
+ error = mps_pass_command(fd, &req, sizeof(MPI2_IOC_FACTS_REQUEST),
+ factsbuf, factslen, NULL, 0, NULL, 0, 10);
+
+ if (error)
+ return (0);
+
+ /* The card's response is measured in dwords */
+ return (facts->MsgLength * 4);
+}
+
MPI2_IOC_FACTS_REPLY *
mps_get_iocfacts(int fd)
{
MPI2_IOC_FACTS_REPLY *facts;
MPI2_IOC_FACTS_REQUEST req;
- char msgver[8], sysctlname[128];
- size_t len, factslen;
+ size_t factslen;
int error;
- snprintf(sysctlname, sizeof(sysctlname), "dev.%s.%d.msg_version",
- is_mps ? "mps" : "mpr", mps_unit);
-
- factslen = sizeof(MPI2_IOC_FACTS_REPLY);
- len = sizeof(msgver);
- error = sysctlbyname(sysctlname, msgver, &len, NULL, 0);
- if (error == 0) {
- if (strncmp(msgver, "2.6", sizeof(msgver)) == 0)
- factslen += 4;
- }
+ factslen = mps_get_ioc_factslen(fd);
+ if (factslen == 0)
+ return (NULL);
facts = malloc(factslen);
if (facts == NULL) {
@@ -749,7 +760,7 @@ mps_get_iocfacts(int fd)
return (NULL);
}
- bzero(&req, factslen);
+ bzero(&req, sizeof(req));
req.Function = MPI2_FUNCTION_IOC_FACTS;
#if 1
diff --git a/usr.sbin/mpsutil/mps_debug.c b/usr.sbin/mpsutil/mps_debug.c
index 83315090d730..68394de50143 100644
--- a/usr.sbin/mpsutil/mps_debug.c
+++ b/usr.sbin/mpsutil/mps_debug.c
@@ -27,15 +27,11 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <err.h>
-#include <libutil.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/mpsutil/mps_flash.c b/usr.sbin/mpsutil/mps_flash.c
index a0cc4a877b7d..98f476e3e234 100644
--- a/usr.sbin/mpsutil/mps_flash.c
+++ b/usr.sbin/mpsutil/mps_flash.c
@@ -24,8 +24,6 @@
*/
#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/mman.h>
diff --git a/usr.sbin/mpsutil/mps_set.c b/usr.sbin/mpsutil/mps_set.c
index 91e4d23ab78d..a1b61356e4ec 100644
--- a/usr.sbin/mpsutil/mps_set.c
+++ b/usr.sbin/mpsutil/mps_set.c
@@ -25,13 +25,9 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <err.h>
-#include <libutil.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/mpsutil/mps_show.c b/usr.sbin/mpsutil/mps_show.c
index ef20cd942d86..378d5380aa76 100644
--- a/usr.sbin/mpsutil/mps_show.c
+++ b/usr.sbin/mpsutil/mps_show.c
@@ -31,14 +31,10 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/endian.h>
#include <err.h>
-#include <libutil.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -59,7 +55,7 @@ MPS_TABLE(top, show);
static int
show_adapter(int ac, char **av)
{
- const char* pcie_speed[] = { "2.5", "5.0", "8.0" };
+ const char* pcie_speed[] = { "2.5", "5.0", "8.0", "16.0", "32.0" };
const char* temp_units[] = { "", "F", "C" };
const char* ioc_speeds[] = { "", "Full", "Half", "Quarter", "Eighth" };
diff --git a/usr.sbin/mpsutil/mps_slot.c b/usr.sbin/mpsutil/mps_slot.c
index 396d5706cd5f..2c90668ec808 100644
--- a/usr.sbin/mpsutil/mps_slot.c
+++ b/usr.sbin/mpsutil/mps_slot.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/mman.h>
diff --git a/usr.sbin/mpsutil/mpsutil.8 b/usr.sbin/mpsutil/mpsutil.8
index e7c2fda8f84e..6bfcdf5f9dd7 100644
--- a/usr.sbin/mpsutil/mpsutil.8
+++ b/usr.sbin/mpsutil/mpsutil.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 7, 2021
.Dt MPSUTIL 8
.Os
@@ -85,11 +83,11 @@ The
utility can be used to display or modify various parameters on LSI
Fusion-MPS 3 controllers.
.Pp
-The
+Both the
.Nm mprutil
-utility behave identically to
-.Nm .
-(same program)
+and
+.Nm
+commands behave identically.
.Pp
Each invocation of
.Nm
@@ -171,4 +169,3 @@ utility first appeared in
.Fx 11.0 .
.Sh TODO
Flash operations (save/update) are not supported on big-endian architectures.
-.Pp
diff --git a/usr.sbin/mpsutil/mpsutil.c b/usr.sbin/mpsutil/mpsutil.c
index cb9563cefa60..51e88ed17a2e 100644
--- a/usr.sbin/mpsutil/mpsutil.c
+++ b/usr.sbin/mpsutil/mpsutil.c
@@ -31,9 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <err.h>
diff --git a/usr.sbin/mpsutil/mpsutil.h b/usr.sbin/mpsutil/mpsutil.h
index b826cdef2763..52562717f484 100644
--- a/usr.sbin/mpsutil/mpsutil.h
+++ b/usr.sbin/mpsutil/mpsutil.h
@@ -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 __MPSUTIL_H__
diff --git a/usr.sbin/mptable/Makefile b/usr.sbin/mptable/Makefile
index cff7602f1e66..08a0bc1024e3 100644
--- a/usr.sbin/mptable/Makefile
+++ b/usr.sbin/mptable/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= mptable
diff --git a/usr.sbin/mptable/Makefile.depend b/usr.sbin/mptable/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/mptable/Makefile.depend
+++ b/usr.sbin/mptable/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/mptable/mptable.1 b/usr.sbin/mptable/mptable.1
index 83e4cea1908e..fda72eeb1159 100644
--- a/usr.sbin/mptable/mptable.1
+++ b/usr.sbin/mptable/mptable.1
@@ -21,8 +21,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 28, 1997
.Dt MPTABLE 1
.Os
diff --git a/usr.sbin/mptable/mptable.c b/usr.sbin/mptable/mptable.c
index 6c5efee766bf..a879279a2d4e 100644
--- a/usr.sbin/mptable/mptable.c
+++ b/usr.sbin/mptable/mptable.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996, by Steve Passe
* All rights reserved.
@@ -29,11 +29,6 @@
* mptable.c
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
/*
* this will cause the raw mp table to be dumped to /tmp/mpdump
*
@@ -188,19 +183,21 @@ main( int argc, char *argv[] )
if ( strcmp( optarg, "mesg") == 0 )
dmesg = 1;
else
- dmesg = 0;
+ usage();
break;
case 'h':
- if ( strcmp( optarg, "elp") == 0 )
- usage();
- break;
+ usage();
case 'g':
if ( strcmp( optarg, "rope") == 0 )
grope = 1;
+ else
+ usage();
break;
case 'v':
if ( strcmp( optarg, "erbose") == 0 )
verbose = 1;
+ else
+ usage();
break;
default:
usage();
@@ -530,7 +527,6 @@ MPConfigTableHeader( u_int32_t pap )
{
mpcth_t cth;
int x;
- int totalSize;
int c;
int oldtype, entrytype;
u_int8_t *entry;
@@ -574,8 +570,6 @@ MPConfigTableHeader( u_int32_t pap )
printf( " extended table length:\t%d\n", cth->extended_table_length );
printf( " extended table checksum:\t%d\n", cth->extended_table_checksum );
- totalSize = cth->base_table_length - sizeof( struct MPCTH );
-
puts( SEP_LINE );
printf( "MP Config Base Table Entries:\n\n" );
diff --git a/usr.sbin/mptutil/Makefile b/usr.sbin/mptutil/Makefile
index 2054c26c5649..6d7e79338f6a 100644
--- a/usr.sbin/mptutil/Makefile
+++ b/usr.sbin/mptutil/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= mptutil
SRCS= mptutil.c mpt_cam.c mpt_cmd.c mpt_config.c mpt_drive.c mpt_evt.c \
diff --git a/usr.sbin/mptutil/Makefile.depend b/usr.sbin/mptutil/Makefile.depend
index ee06e1c20939..3c2b5b10ac32 100644
--- a/usr.sbin/mptutil/Makefile.depend
+++ b/usr.sbin/mptutil/Makefile.depend
@@ -1,15 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcam \
lib/libcompiler_rt \
- lib/libsbuf \
lib/libutil \
diff --git a/usr.sbin/mptutil/mpt_cam.c b/usr.sbin/mptutil/mpt_cam.c
index 04c13f0c25fe..87aebc8819a1 100644
--- a/usr.sbin/mptutil/mpt_cam.c
+++ b/usr.sbin/mptutil/mpt_cam.c
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <err.h>
#include <errno.h>
diff --git a/usr.sbin/mptutil/mpt_cmd.c b/usr.sbin/mptutil/mpt_cmd.c
index 79422c12dd89..8e091e2ed19b 100644
--- a/usr.sbin/mptutil/mpt_cmd.c
+++ b/usr.sbin/mptutil/mpt_cmd.c
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
diff --git a/usr.sbin/mptutil/mpt_config.c b/usr.sbin/mptutil/mpt_config.c
index 58894fb5ecc9..88fb619c7eba 100644
--- a/usr.sbin/mptutil/mpt_config.c
+++ b/usr.sbin/mptutil/mpt_config.c
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <err.h>
diff --git a/usr.sbin/mptutil/mpt_drive.c b/usr.sbin/mptutil/mpt_drive.c
index 96004c7a3e74..82d5aefe8795 100644
--- a/usr.sbin/mptutil/mpt_drive.c
+++ b/usr.sbin/mptutil/mpt_drive.c
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <ctype.h>
diff --git a/usr.sbin/mptutil/mpt_evt.c b/usr.sbin/mptutil/mpt_evt.c
index b1c423f71031..a3fbf4cf7aec 100644
--- a/usr.sbin/mptutil/mpt_evt.c
+++ b/usr.sbin/mptutil/mpt_evt.c
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <ctype.h>
diff --git a/usr.sbin/mptutil/mpt_show.c b/usr.sbin/mptutil/mpt_show.c
index 4bc2c7569f53..f9191aa6921e 100644
--- a/usr.sbin/mptutil/mpt_show.c
+++ b/usr.sbin/mptutil/mpt_show.c
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <err.h>
diff --git a/usr.sbin/mptutil/mpt_volume.c b/usr.sbin/mptutil/mpt_volume.c
index 9c160542f51c..4a7c55f9f6c6 100644
--- a/usr.sbin/mptutil/mpt_volume.c
+++ b/usr.sbin/mptutil/mpt_volume.c
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <err.h>
@@ -219,7 +216,8 @@ volume_cache(int ac, char **av)
*s1 = tolower(*s1);
if ((strcmp(av[2], "enable")) && (strcmp(av[2], "enabled")) &&
(strcmp(av[2], "disable")) && (strcmp(av[2], "disabled"))) {
- warnx("volume cache: invalid flag, must be 'enable' or 'disable'\n");
+ warnx("volume cache: invalid flag; "
+ "must be 'enable', 'enabled', 'disable', or 'disabled'");
return (EINVAL);
}
@@ -246,9 +244,9 @@ volume_cache(int ac, char **av)
Settings = volume->VolumeSettings.Settings;
NewSettings = Settings;
- if (strncmp(av[2], "enable", sizeof("enable")) == 0)
+ if (strncmp(av[2], "enable", strlen("enable")) == 0)
NewSettings |= 0x01;
- if (strncmp(av[2], "disable", sizeof("disable")) == 0)
+ else if (strncmp(av[2], "disable", strlen("disable")) == 0)
NewSettings &= ~0x01;
if (NewSettings == Settings) {
diff --git a/usr.sbin/mptutil/mptutil.8 b/usr.sbin/mptutil/mptutil.8
index e8b617ffbcaf..47eb9e43d2b9 100644
--- a/usr.sbin/mptutil/mptutil.8
+++ b/usr.sbin/mptutil/mptutil.8
@@ -27,9 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd August 16, 2009
+.Dd May 24, 2024
.Dt MPTUTIL 8
.Os
.Sh NAME
@@ -71,7 +69,7 @@
.Nm
.Op Fl u Ar unit
.Cm volume cache Ar volume
-.Ar enable|disable
+.Ar enable|enabled|disable|disabled
.Nm
.Op Fl u Ar unit
.Cm clear
@@ -239,7 +237,7 @@ Sets the name of
.Ar volume
to
.Ar name .
-.It Cm volume cache Ar volume Ar enable|disable
+.It Cm volume cache Ar volume Ar enable|enabled|disable|disabled
Enables or disables the drive write cache for the member drives of
.Ar volume .
.It Cm volume status Ar volume
diff --git a/usr.sbin/mptutil/mptutil.c b/usr.sbin/mptutil/mptutil.c
index 0ec6620c8688..ed414931339c 100644
--- a/usr.sbin/mptutil/mptutil.c
+++ b/usr.sbin/mptutil/mptutil.c
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <err.h>
diff --git a/usr.sbin/mptutil/mptutil.h b/usr.sbin/mptutil/mptutil.h
index 191c8d2dfda2..6148d5405ab1 100644
--- a/usr.sbin/mptutil/mptutil.h
+++ b/usr.sbin/mptutil/mptutil.h
@@ -28,8 +28,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 __MPTUTIL_H__
diff --git a/usr.sbin/mtest/Makefile b/usr.sbin/mtest/Makefile
index 8afee2a87435..9efd1e8d716f 100644
--- a/usr.sbin/mtest/Makefile
+++ b/usr.sbin/mtest/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/mtest/Makefile.depend b/usr.sbin/mtest/Makefile.depend
index d5ed563ecfc8..344a5d0e9310 100644
--- a/usr.sbin/mtest/Makefile.depend
+++ b/usr.sbin/mtest/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/mtest/mtest.8 b/usr.sbin/mtest/mtest.8
index 5ccfa941e184..dfad4a657e2e 100644
--- a/usr.sbin/mtest/mtest.8
+++ b/usr.sbin/mtest/mtest.8
@@ -24,8 +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.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 29, 2009
.Dt MTEST 8
.Os
diff --git a/usr.sbin/mtest/mtest.c b/usr.sbin/mtest/mtest.c
index f50c1a631a0a..941379b01bc9 100644
--- a/usr.sbin/mtest/mtest.c
+++ b/usr.sbin/mtest/mtest.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2007-2009 Bruce Simpson.
* Copyright (c) 2000 Wilbert De Graaf.
@@ -38,9 +38,6 @@
* is implemented; use MCAST_JOIN_SOURCE for IPv4.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/param.h>
#include <sys/errno.h>
diff --git a/usr.sbin/ndp/Makefile b/usr.sbin/ndp/Makefile
index 52d8304a436a..998860d00a69 100644
--- a/usr.sbin/ndp/Makefile
+++ b/usr.sbin/ndp/Makefile
@@ -11,17 +11,16 @@
# AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
# LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE.
-# $FreeBSD$
.include <src.opts.mk>
-.PATH: ${SRCTOP}/contrib/tcpdump
-
PROG= ndp
MAN= ndp.8
-SRCS= ndp.c gmt2local.c
+SRCS= ndp.c
+
+LIBADD= xo
-CFLAGS+= -I. -I${.CURDIR} -I${SRCTOP}/contrib/tcpdump
+CFLAGS+= -I. -I${.CURDIR}
CFLAGS+= -D_U_=""
.if ${MK_EXPERIMENTAL} != "no"
@@ -29,6 +28,13 @@ CFLAGS+= -DEXPERIMENTAL
CFLAGS+= -DDRAFT_IETF_6MAN_IPV6ONLY_FLAG
.endif
+.if ${MK_NETLINK_SUPPORT} != "no"
+SRCS+= ndp_netlink.c
+.else
+CFLAGS+=-DWITHOUT_NETLINK
+.endif
+
+
WARNS?= 3
.include <bsd.prog.mk>
diff --git a/usr.sbin/ndp/Makefile.depend b/usr.sbin/ndp/Makefile.depend
index d5ed563ecfc8..11a91dcad4b2 100644
--- a/usr.sbin/ndp/Makefile.depend
+++ b/usr.sbin/ndp/Makefile.depend
@@ -1,14 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libxo/libxo \
.include <dirdeps.mk>
diff --git a/usr.sbin/ndp/ndp.8 b/usr.sbin/ndp/ndp.8
index c2a4c1de3e22..7ad1cd0fc883 100644
--- a/usr.sbin/ndp/ndp.8
+++ b/usr.sbin/ndp/ndp.8
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 9, 2014
.Dt NDP 8
.Os
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index ce21e34417c3..9d9ae02dc1e2 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: ndp.c,v 1.104 2003/06/27 07:48:39 itojun Exp $ */
/*-
@@ -65,10 +64,7 @@
/*
* Based on:
- * "@(#) Copyright (c) 1984, 1993\n\
* The Regents of the University of California. All rights reserved.\n";
- *
- * "@(#)arp.c 8.2 (Berkeley) 1/2/94";
*/
/*
@@ -98,18 +94,24 @@
#include <arpa/inet.h>
+#include <assert.h>
#include <ctype.h>
#include <netdb.h>
#include <errno.h>
#include <nlist.h>
+#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <paths.h>
#include <err.h>
+#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
-#include "gmt2local.h"
+#include <libxo/xo.h>
+#include <time.h>
+
+#include "ndp.h"
#define NEXTADDR(w, s) \
if (rtm->rtm_addrs & (w)) { \
@@ -118,8 +120,6 @@
}
static pid_t pid;
-static int nflag;
-static int tflag;
static int32_t thiszone; /* time difference with gmt */
static int s = -1;
static int repeat = 0;
@@ -128,16 +128,13 @@ static char host_buf[NI_MAXHOST]; /* getnameinfo() */
static char ifix_buf[IFNAMSIZ]; /* if_indextoname() */
static int file(char *);
-static void getsocket(void);
static int set(int, char **);
static void get(char *);
static int delete(char *);
-static void dump(struct sockaddr_in6 *, int);
+static int dump(struct sockaddr_in6 *, int);
static struct in6_nbrinfo *getnbrinfo(struct in6_addr *, int, int);
-static char *ether_str(struct sockaddr_dl *);
static int ndp_ether_aton(char *, u_char *);
-static void usage(void);
-static int rtmsg(int);
+static void usage(void) __dead2;
static void ifinfo(char *, int, char **);
static void rtrlist(void);
static void plist(void);
@@ -148,8 +145,11 @@ static void harmonize_rtr(void);
static void getdefif(void);
static void setdefif(char *);
#endif
-static char *sec2str(time_t);
-static void ts_print(const struct timeval *);
+
+#ifdef WITHOUT_NETLINK
+static void getsocket(void);
+static int rtmsg(int);
+#endif
static const char *rtpref_str[] = {
"medium", /* 00 */
@@ -158,14 +158,57 @@ static const char *rtpref_str[] = {
"low" /* 11 */
};
+struct ndp_opts opts = {};
+
+#define NDP_XO_VERSION "1"
+
+bool
+valid_type(int if_type)
+{
+ switch (if_type) {
+ case IFT_ETHER:
+ case IFT_FDDI:
+ case IFT_ISO88023:
+ case IFT_ISO88024:
+ case IFT_ISO88025:
+ case IFT_L2VLAN:
+ case IFT_BRIDGE:
+ return (true);
+ break;
+ }
+ return (false);
+}
+
+static int32_t
+utc_offset(void)
+{
+ time_t t;
+ struct tm *tm;
+
+ t = time(NULL);
+ tm = localtime(&t);
+
+ assert(tm->tm_gmtoff > INT32_MIN && tm->tm_gmtoff < INT32_MAX);
+
+ return (tm->tm_gmtoff);
+}
+
int
main(int argc, char **argv)
{
int ch, mode = 0;
char *arg = NULL;
+ int ret = 0;
pid = getpid();
- thiszone = gmt2local(0);
+ thiszone = utc_offset();
+
+ argc = xo_parse_args(argc, argv);
+ if (argc < 0)
+ exit(1);
+ xo_set_version(NDP_XO_VERSION);
+ xo_open_container("ndp");
+
while ((ch = getopt(argc, argv, "acd:f:Ii:nprstA:HPR")) != -1)
switch (ch) {
case 'a':
@@ -196,10 +239,10 @@ main(int argc, char **argv)
arg = optarg;
break;
case 'n':
- nflag = 1;
+ opts.nflag = true;
break;
case 't':
- tflag = 1;
+ opts.tflag = true;
break;
case 'A':
if (mode) {
@@ -234,7 +277,9 @@ main(int argc, char **argv)
usage();
/*NOTREACHED*/
}
- delete(arg);
+ xo_open_list("neighbor-cache");
+ ret = delete(arg);
+ xo_close_list("neighbor-cache");
break;
case 'I':
#ifdef SIOCSDEFIFACE_IN6 /* XXX: check SIOCGDEFIFACE_IN6 as well? */
@@ -246,12 +291,12 @@ main(int argc, char **argv)
if_nametoindex(*argv))
setdefif(*argv);
else
- errx(1, "invalid interface %s", *argv);
+ xo_errx(1, "invalid interface %s", *argv);
}
getdefif(); /* always call it to print the result */
break;
#else
- errx(1, "not supported yet");
+ xo_errx(1, "not supported yet");
/*NOTREACHED*/
#endif
case 'p':
@@ -304,7 +349,10 @@ main(int argc, char **argv)
get(argv[0]);
break;
}
- exit(0);
+ xo_close_container("ndp");
+ xo_finish();
+
+ return (ret);
}
/*
@@ -318,7 +366,7 @@ file(char *name)
char line[100], arg[5][50], *args[5], *p;
if ((fp = fopen(name, "r")) == NULL)
- err(1, "cannot open %s", name);
+ xo_err(1, "cannot open %s", name);
args[0] = &arg[0][0];
args[1] = &arg[1][0];
args[2] = &arg[2][0];
@@ -334,7 +382,7 @@ file(char *name)
i = sscanf(line, "%49s %49s %49s %49s %49s",
arg[0], arg[1], arg[2], arg[3], arg[4]);
if (i < 2) {
- warnx("bad line: %s", line);
+ xo_warnx("bad line: %s", line);
retval = 1;
continue;
}
@@ -346,12 +394,12 @@ file(char *name)
}
static void
-getsocket()
+getsocket(void)
{
if (s < 0) {
s = socket(PF_ROUTE, SOCK_RAW, 0);
if (s < 0) {
- err(1, "socket");
+ xo_err(1, "socket");
/* NOTREACHED */
}
}
@@ -371,12 +419,12 @@ static struct sockaddr_dl blank_sdl = {
.sdl_family = AF_LINK
};
static struct sockaddr_dl sdl_m;
-static time_t expire_time;
-static int flags, found_entry;
+#ifdef WITHOUT_NETLINK
static struct {
struct rt_msghdr m_rtm;
char m_space[512];
} m_rtmsg;
+#endif
/*
* Set an individual neighbor cache entry
@@ -384,47 +432,46 @@ static struct {
static int
set(int argc, char **argv)
{
- register struct sockaddr_in6 *sin = &sin_m;
- register struct sockaddr_dl *sdl;
- register struct rt_msghdr *rtm = &(m_rtmsg.m_rtm);
- struct addrinfo hints, *res;
+ struct sockaddr_in6 *sin = &sin_m;
int gai_error;
u_char *ea;
char *host = argv[0], *eaddr = argv[1];
- getsocket();
argc -= 2;
argv += 2;
sdl_m = blank_sdl;
sin_m = blank_sin;
- bzero(&hints, sizeof(hints));
- hints.ai_family = AF_INET6;
- gai_error = getaddrinfo(host, NULL, &hints, &res);
+ gai_error = getaddr(host, sin);
if (gai_error) {
- fprintf(stderr, "ndp: %s: %s\n", host,
- gai_strerror(gai_error));
+ xo_warnx("%s: %s", host, gai_strerror(gai_error));
return 1;
}
- sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
- sin->sin6_scope_id =
- ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id;
+
ea = (u_char *)LLADDR(&sdl_m);
if (ndp_ether_aton(eaddr, ea) == 0)
sdl_m.sdl_alen = 6;
- flags = expire_time = 0;
while (argc-- > 0) {
if (strncmp(argv[0], "temp", 4) == 0) {
struct timeval now;
gettimeofday(&now, 0);
- expire_time = now.tv_sec + 20 * 60;
+ opts.expire_time = now.tv_sec + 20 * 60;
} else if (strncmp(argv[0], "proxy", 5) == 0)
- flags |= RTF_ANNOUNCE;
+ opts.flags |= RTF_ANNOUNCE;
argv++;
}
+
+#ifndef WITHOUT_NETLINK
+ return (set_nl(0, sin, &sdl_m, host));
+#else
+ struct rt_msghdr *rtm = &(m_rtmsg.m_rtm);
+ struct sockaddr_dl *sdl;
+
+ getsocket();
+
if (rtmsg(RTM_GET) < 0) {
- errx(1, "RTM_GET(%s) failed", host);
+ xo_errx(1, "RTM_GET(%s) failed", host);
/* NOTREACHED */
}
sin = (struct sockaddr_in6 *)(rtm + 1);
@@ -432,25 +479,39 @@ set(int argc, char **argv)
if (IN6_ARE_ADDR_EQUAL(&sin->sin6_addr, &sin_m.sin6_addr)) {
if (sdl->sdl_family == AF_LINK &&
!(rtm->rtm_flags & RTF_GATEWAY)) {
- switch (sdl->sdl_type) {
- case IFT_ETHER: case IFT_FDDI: case IFT_ISO88023:
- case IFT_ISO88024: case IFT_ISO88025:
- case IFT_L2VLAN: case IFT_BRIDGE:
+ if (valid_type(sdl->sdl_type))
goto overwrite;
- }
}
- fprintf(stderr, "set: cannot configure a new entry\n");
+ xo_warnx("cannot configure a new entry");
return 1;
}
overwrite:
if (sdl->sdl_family != AF_LINK) {
- printf("cannot intuit interface index and type for %s\n", host);
+ xo_warnx("cannot intuit interface index and type for %s", host);
return (1);
}
sdl_m.sdl_type = sdl->sdl_type;
sdl_m.sdl_index = sdl->sdl_index;
return (rtmsg(RTM_ADD));
+#endif
+}
+
+int
+getaddr(char *host, struct sockaddr_in6 *sin6)
+{
+ struct addrinfo hints = { .ai_family = AF_INET6 };
+ struct addrinfo *res;
+
+ int gai_error = getaddrinfo(host, NULL, &hints, &res);
+ if (gai_error != 0)
+ return (gai_error);
+ sin6->sin6_family = AF_INET6;
+ sin6->sin6_len = sizeof(*sin6);
+ sin6->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
+ sin6->sin6_scope_id =
+ ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id;
+ return (0);
}
/*
@@ -460,60 +521,47 @@ static void
get(char *host)
{
struct sockaddr_in6 *sin = &sin_m;
- struct addrinfo hints, *res;
int gai_error;
sin_m = blank_sin;
- bzero(&hints, sizeof(hints));
- hints.ai_family = AF_INET6;
- gai_error = getaddrinfo(host, NULL, &hints, &res);
+
+ gai_error = getaddr(host, sin);
if (gai_error) {
- fprintf(stderr, "ndp: %s: %s\n", host,
- gai_strerror(gai_error));
+ xo_warnx("%s: %s", host, gai_strerror(gai_error));
return;
}
- sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
- sin->sin6_scope_id =
- ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id;
- dump(sin, 0);
- if (found_entry == 0) {
+ if (dump(sin, 0) == 0) {
getnameinfo((struct sockaddr *)sin, sin->sin6_len, host_buf,
sizeof(host_buf), NULL ,0,
- (nflag ? NI_NUMERICHOST : 0));
- printf("%s (%s) -- no entry\n", host, host_buf);
- exit(1);
+ (opts.nflag ? NI_NUMERICHOST : 0));
+ xo_errx(1, "%s (%s) -- no entry", host, host_buf);
}
}
+#ifdef WITHOUT_NETLINK
/*
* Delete a neighbor cache entry
*/
static int
-delete(char *host)
+delete_rtsock(char *host)
{
struct sockaddr_in6 *sin = &sin_m;
register struct rt_msghdr *rtm = &m_rtmsg.m_rtm;
register char *cp = m_rtmsg.m_space;
struct sockaddr_dl *sdl;
- struct addrinfo hints, *res;
int gai_error;
getsocket();
sin_m = blank_sin;
- bzero(&hints, sizeof(hints));
- hints.ai_family = AF_INET6;
- gai_error = getaddrinfo(host, NULL, &hints, &res);
+ gai_error = getaddr(host, sin);
if (gai_error) {
- fprintf(stderr, "ndp: %s: %s\n", host,
- gai_strerror(gai_error));
+ xo_warnx("%s: %s", host, gai_strerror(gai_error));
return 1;
}
- sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
- sin->sin6_scope_id =
- ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id;
+
if (rtmsg(RTM_GET) < 0) {
- errx(1, "RTM_GET(%s) failed", host);
+ xo_errx(1, "RTM_GET(%s) failed", host);
/* NOTREACHED */
}
sin = (struct sockaddr_in6 *)(rtm + 1);
@@ -523,13 +571,13 @@ delete(char *host)
!(rtm->rtm_flags & RTF_GATEWAY)) {
goto delete;
}
- fprintf(stderr, "delete: cannot delete non-NDP entry\n");
+ xo_warnx("delete: cannot delete non-NDP entry");
return 1;
}
delete:
if (sdl->sdl_family != AF_LINK) {
- printf("cannot locate %s\n", host);
+ xo_warnx("cannot locate %s", host);
return (1);
}
/*
@@ -542,22 +590,30 @@ delete:
getnameinfo((struct sockaddr *)sin,
sin->sin6_len, host_buf,
sizeof(host_buf), NULL, 0,
- (nflag ? NI_NUMERICHOST : 0));
- printf("%s (%s) deleted\n", host, host_buf);
+ (opts.nflag ? NI_NUMERICHOST : 0));
+ xo_open_instance("neighbor-cache");
+
+ char *ifname = if_indextoname(sdl->sdl_index, ifix_buf);
+ if (ifname == NULL) {
+ strlcpy(ifix_buf, "?", sizeof(ifix_buf));
+ ifname = ifix_buf;
+ }
+ char abuf[INET6_ADDRSTRLEN];
+ inet_ntop(AF_INET6, &sin->sin6_addr, abuf, sizeof(abuf));
+
+ xo_emit("{:hostname/%s}{d:/ (%s) deleted\n}", host, host_buf);
+ xo_emit("{e:address/%s}{e:interface/%s}", abuf, ifname);
+ xo_close_instance("neighbor-cache");
}
return 0;
}
-#define W_ADDR 36
-#define W_LL 17
-#define W_IF 6
-
/*
* Dump the entire neighbor cache
*/
-static void
-dump(struct sockaddr_in6 *addr, int cflag)
+static int
+dump_rtsock(struct sockaddr_in6 *addr, int cflag)
{
int mib[6];
size_t needed;
@@ -574,11 +630,14 @@ dump(struct sockaddr_in6 *addr, int cflag)
char *ifname;
/* Print header */
- if (!tflag && !cflag)
- printf("%-*.*s %-*.*s %*.*s %-9.9s %1s %5s\n",
- W_ADDR, W_ADDR, "Neighbor", W_LL, W_LL, "Linklayer Address",
- W_IF, W_IF, "Netif", "Expire", "S", "Flags");
-
+ if (!opts.tflag && !cflag) {
+ char xobuf[200];
+ snprintf(xobuf, sizeof(xobuf),
+ "{T:/%%-%d.%ds} {T:/%%-%d.%ds} {T:/%%%d.%ds} {T:/%%-9.9s} {T:%%1s} {T:%%5s}\n",
+ W_ADDR, W_ADDR, W_LL, W_LL, W_IF, W_IF);
+ xo_emit(xobuf, "Neighbor", "Linklayer Address", "Netif", "Expire", "S", "Flags");
+ }
+ xo_open_list("neighbor-cache");
again:;
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
@@ -591,16 +650,23 @@ again:;
mib[5] = 0;
#endif
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
- err(1, "sysctl(PF_ROUTE estimate)");
+ xo_err(1, "sysctl(PF_ROUTE estimate)");
if (needed > 0) {
+ /*
+ * Add ~2% additional space in case some records
+ * will appear between sysctl() calls.
+ * Round it up so it can fit 4 additional messages at least.
+ */
+ needed += ((needed >> 6) | (sizeof(m_rtmsg) * 4));
if ((buf = malloc(needed)) == NULL)
- err(1, "malloc");
+ xo_err(1, "malloc");
if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
- err(1, "sysctl(PF_ROUTE, NET_RT_FLAGS)");
+ xo_err(1, "sysctl(PF_ROUTE, NET_RT_FLAGS)");
lim = buf + needed;
} else
buf = lim = NULL;
+ int count = 0;
for (next = buf; next && next < lim; next += rtm->rtm_msglen) {
int isrouter = 0, prbs = 0;
@@ -633,9 +699,9 @@ again:;
&sin->sin6_addr) == 0 ||
addr->sin6_scope_id != sin->sin6_scope_id)
continue;
- found_entry = 1;
} else if (IN6_IS_ADDR_MULTICAST(&sin->sin6_addr))
continue;
+ count++;
if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr) ||
IN6_IS_ADDR_MC_LINKLOCAL(&sin->sin6_addr)) {
/* XXX: should scope id be filled in the kernel? */
@@ -643,7 +709,7 @@ again:;
sin->sin6_scope_id = sdl->sdl_index;
}
getnameinfo((struct sockaddr *)sin, sin->sin6_len, host_buf,
- sizeof(host_buf), NULL, 0, (nflag ? NI_NUMERICHOST : 0));
+ sizeof(host_buf), NULL, 0, (opts.nflag ? NI_NUMERICHOST : 0));
if (cflag) {
#ifdef RTF_WASCLONED
if (rtm->rtm_flags & RTF_WASCLONED)
@@ -659,7 +725,7 @@ again:;
continue;
}
gettimeofday(&now, 0);
- if (tflag)
+ if (opts.tflag)
ts_print(&now);
addrwidth = strlen(host_buf);
@@ -677,46 +743,54 @@ again:;
if (W_ADDR + W_LL + W_IF - addrwidth - llwidth > ifwidth)
ifwidth = W_ADDR + W_LL + W_IF - addrwidth - llwidth;
- printf("%-*.*s %-*.*s %*.*s", addrwidth, addrwidth, host_buf,
- llwidth, llwidth, ether_str(sdl), ifwidth, ifwidth, ifname);
+ xo_open_instance("neighbor-cache");
+ /* Compose format string for libxo, as it doesn't support *.* */
+ char xobuf[200];
+ snprintf(xobuf, sizeof(xobuf),
+ "{:address/%%-%d.%ds/%%s} {:mac-address/%%-%d.%ds/%%s} {:interface/%%%d.%ds/%%s}",
+ addrwidth, addrwidth, llwidth, llwidth, ifwidth, ifwidth);
+ xo_emit(xobuf, host_buf, ether_str(sdl), ifname);
/* Print neighbor discovery specific information */
expire = rtm->rtm_rmx.rmx_expire;
+ int expire_in = expire - now.tv_sec;
if (expire > now.tv_sec)
- printf(" %-9.9s", sec2str(expire - now.tv_sec));
+ xo_emit("{d:/ %-9.9s}{e:expires_sec/%d}", sec2str(expire_in), expire_in);
else if (expire == 0)
- printf(" %-9.9s", "permanent");
+ xo_emit("{d:/ %-9.9s}{en:permanent/true}", "permanent");
else
- printf(" %-9.9s", "expired");
+ xo_emit("{d:/ %-9.9s}{e:expires_sec/%d}", "expired", expire_in);
+ char *lle_state = "";
switch (rtm->rtm_rmx.rmx_state) {
case ND6_LLINFO_NOSTATE:
- printf(" N");
+ lle_state = "N";
break;
#ifdef ND6_LLINFO_WAITDELETE
case ND6_LLINFO_WAITDELETE:
- printf(" W");
+ lle_state = "W";
break;
#endif
case ND6_LLINFO_INCOMPLETE:
- printf(" I");
+ lle_state = "I";
break;
case ND6_LLINFO_REACHABLE:
- printf(" R");
+ lle_state = "R";
break;
case ND6_LLINFO_STALE:
- printf(" S");
+ lle_state = "S";
break;
case ND6_LLINFO_DELAY:
- printf(" D");
+ lle_state = "D";
break;
case ND6_LLINFO_PROBE:
- printf(" P");
+ lle_state = "P";
break;
default:
- printf(" ?");
+ lle_state = "?";
break;
}
+ xo_emit(" {:neighbor-state/%s}", lle_state);
isrouter = rtm->rtm_flags & RTF_GATEWAY;
prbs = rtm->rtm_rmx.rmx_pksent;
@@ -743,22 +817,49 @@ again:;
(rtm->rtm_flags & RTF_ANNOUNCE) ? "p" : "");
#endif
}
- printf(" %s", flgbuf);
+ xo_emit(" {:nd-flags/%s}", flgbuf);
if (prbs)
- printf(" %d", prbs);
+ xo_emit("{d:/ %d}", prbs);
- printf("\n");
+ xo_emit("\n");
+ xo_close_instance("neighbor-cache");
}
if (buf != NULL)
free(buf);
if (repeat) {
- printf("\n");
- fflush(stdout);
+ xo_emit("\n");
+ xo_flush();
sleep(repeat);
goto again;
}
+
+ xo_close_list("neighbor-cache");
+
+ return (count);
+}
+#endif
+
+
+static int
+delete(char *host)
+{
+#ifndef WITHOUT_NETLINK
+ return (delete_nl(0, host, true)); /* do warn */
+#else
+ return (delete_rtsock(host));
+#endif
+}
+
+static int
+dump(struct sockaddr_in6 *addr, int cflag)
+{
+#ifndef WITHOUT_NETLINK
+ return (print_entries_nl(0, addr, cflag));
+#else
+ return (dump_rtsock(addr, cflag));
+#endif
}
static struct in6_nbrinfo *
@@ -768,14 +869,14 @@ getnbrinfo(struct in6_addr *addr, int ifindex, int warning)
int sock;
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
- err(1, "socket");
+ xo_err(1, "socket");
bzero(&nbi, sizeof(nbi));
if_indextoname(ifindex, nbi.ifname);
nbi.addr = *addr;
if (ioctl(sock, SIOCGNBRINFO_IN6, (caddr_t)&nbi) < 0) {
if (warning)
- warn("ioctl(SIOCGNBRINFO_IN6)");
+ xo_warn("ioctl(SIOCGNBRINFO_IN6)");
close(sock);
return(NULL);
}
@@ -784,7 +885,7 @@ getnbrinfo(struct in6_addr *addr, int ifindex, int warning)
return(&nbi);
}
-static char *
+char *
ether_str(struct sockaddr_dl *sdl)
{
static char hbuf[NI_MAXHOST];
@@ -809,7 +910,7 @@ ndp_ether_aton(char *a, u_char *n)
i = sscanf(a, "%x:%x:%x:%x:%x:%x", &o[0], &o[1], &o[2],
&o[3], &o[4], &o[5]);
if (i != 6) {
- fprintf(stderr, "ndp: invalid Ethernet address '%s'\n", a);
+ xo_warnx("invalid Ethernet address '%s'", a);
return (1);
}
for (i = 0; i < 6; i++)
@@ -818,7 +919,7 @@ ndp_ether_aton(char *a, u_char *n)
}
static void
-usage()
+usage(void)
{
printf("usage: ndp [-nt] hostname\n");
printf(" ndp [-nt] -a | -c | -p | -r | -H | -P | -R\n");
@@ -833,6 +934,7 @@ usage()
exit(1);
}
+#ifdef WITHOUT_NETLINK
static int
rtmsg(int cmd)
{
@@ -846,17 +948,16 @@ rtmsg(int cmd)
if (cmd == RTM_DELETE)
goto doit;
bzero((char *)&m_rtmsg, sizeof(m_rtmsg));
- rtm->rtm_flags = flags;
+ rtm->rtm_flags = opts.flags;
rtm->rtm_version = RTM_VERSION;
switch (cmd) {
default:
- fprintf(stderr, "ndp: internal wrong cmd\n");
- exit(1);
+ xo_errx(1, "internal wrong cmd");
case RTM_ADD:
rtm->rtm_addrs |= RTA_GATEWAY;
- if (expire_time) {
- rtm->rtm_rmx.rmx_expire = expire_time;
+ if (opts.expire_time) {
+ rtm->rtm_rmx.rmx_expire = opts.expire_time;
rtm->rtm_inits = RTV_EXPIRE;
}
rtm->rtm_flags |= (RTF_HOST | RTF_STATIC | RTF_LLDATA);
@@ -875,7 +976,7 @@ doit:
rtm->rtm_type = cmd;
if ((rlen = write(s, (char *)&m_rtmsg, l)) < 0) {
if (errno != ESRCH || cmd != RTM_DELETE) {
- err(1, "writing to routing socket");
+ xo_err(1, "writing to routing socket");
/* NOTREACHED */
}
}
@@ -884,10 +985,10 @@ doit:
} while (l > 0 && (rtm->rtm_type != cmd || rtm->rtm_seq != seq ||
rtm->rtm_pid != pid));
if (l < 0)
- (void) fprintf(stderr, "ndp: read from routing socket: %s\n",
- strerror(errno));
+ xo_warn("read from routing socket");
return (0);
}
+#endif
static void
ifinfo(char *ifname, int argc, char **argv)
@@ -900,13 +1001,13 @@ ifinfo(char *ifname, int argc, char **argv)
#endif
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
- err(1, "socket");
+ xo_err(1, "socket");
/* NOTREACHED */
}
bzero(&nd, sizeof(nd));
strlcpy(nd.ifname, ifname, sizeof(nd.ifname));
if (ioctl(sock, SIOCGIFINFO_IN6, (caddr_t)&nd) < 0) {
- err(1, "ioctl(SIOCGIFINFO_IN6)");
+ xo_err(1, "ioctl(SIOCGIFINFO_IN6)");
/* NOTREACHED */
}
#define ND nd.ndi
@@ -939,11 +1040,11 @@ ifinfo(char *ifname, int argc, char **argv)
if (strncmp(cp, f, strlen(f)) == 0) { \
valptr = strchr(cp, '='); \
if (valptr == NULL) \
- err(1, "syntax error in %s field", (f)); \
+ xo_err(1, "syntax error in %s field", (f)); \
errno = 0; \
newval = strtoul(++valptr, NULL, 0); \
if (errno) \
- err(1, "syntax error in %s's value", (f)); \
+ xo_err(1, "syntax error in %s's value", (f)); \
v = newval; \
} \
} while (0)
@@ -965,7 +1066,7 @@ ifinfo(char *ifname, int argc, char **argv)
ND.flags = newflags;
if (ioctl(sock, SIOCSIFINFO_IN6, (caddr_t)&nd) < 0) {
- err(1, "ioctl(SIOCSIFINFO_IN6)");
+ xo_err(1, "ioctl(SIOCSIFINFO_IN6)");
/* NOTREACHED */
}
#undef SETFLAG
@@ -973,21 +1074,25 @@ ifinfo(char *ifname, int argc, char **argv)
}
if (!ND.initialized) {
- errx(1, "%s: not initialized yet", ifname);
+ xo_errx(1, "%s: not initialized yet", ifname);
/* NOTREACHED */
}
if (ioctl(sock, SIOCGIFINFO_IN6, (caddr_t)&nd) < 0) {
- err(1, "ioctl(SIOCGIFINFO_IN6)");
+ xo_err(1, "ioctl(SIOCGIFINFO_IN6)");
/* NOTREACHED */
}
- printf("linkmtu=%d", ND.linkmtu);
- printf(", maxmtu=%d", ND.maxmtu);
- printf(", curhlim=%d", ND.chlim);
- printf(", basereachable=%ds%dms",
- ND.basereachable / 1000, ND.basereachable % 1000);
- printf(", reachable=%ds", ND.reachable);
- printf(", retrans=%ds%dms", ND.retrans / 1000, ND.retrans % 1000);
+ xo_open_container("ifinfo");
+
+ xo_emit("{e:interface/%s}", ifname);
+ xo_emit("linkmtu={:linkmtu/%d}", ND.linkmtu);
+ xo_emit(", maxmtu={:maxmtu/%d}", ND.maxmtu);
+ xo_emit(", curhlim={:curhlim/%d}", ND.chlim);
+ xo_emit("{d:/, basereachable=%ds%dms}{e:basereachable_ms/%u}",
+ ND.basereachable / 1000, ND.basereachable % 1000, ND.basereachable);
+ xo_emit("{d:/, reachable=%ds}{e:reachable_ms/%u}", ND.reachable, ND.reachable * 1000);
+ xo_emit("{d:/, retrans=%ds%dms}{e:retrans_ms/%u}", ND.retrans / 1000, ND.retrans % 1000,
+ ND.retrans);
#ifdef IPV6CTL_USETEMPADDR
memset(nullbuf, 0, sizeof(nullbuf));
if (memcmp(nullbuf, ND.randomid, sizeof(nullbuf)) != 0) {
@@ -995,50 +1100,60 @@ ifinfo(char *ifname, int argc, char **argv)
u_int8_t *rbuf;
for (i = 0; i < 3; i++) {
+ const char *txt, *field;
switch (i) {
case 0:
- printf("\nRandom seed(0): ");
+ txt = "\nRandom seed(0): ";
+ field = "seed_0";
rbuf = ND.randomseed0;
break;
case 1:
- printf("\nRandom seed(1): ");
+ txt = "\nRandom seed(1): ";
+ field = "seed_1";
rbuf = ND.randomseed1;
break;
case 2:
- printf("\nRandom ID: ");
+ txt = "\nRandom ID: ";
+ field = "random_id";
rbuf = ND.randomid;
break;
default:
- errx(1, "impossible case for tempaddr display");
+ xo_errx(1, "impossible case for tempaddr display");
}
+ char abuf[20], xobuf[200];
for (j = 0; j < 8; j++)
- printf("%02x", rbuf[j]);
+ snprintf(&abuf[j * 2], sizeof(abuf), "%02X", rbuf[j]);
+ snprintf(xobuf, sizeof(xobuf), "%s{:%s/%%s}", txt, field);
+ xo_emit(xobuf, abuf);
}
}
#endif /* IPV6CTL_USETEMPADDR */
if (ND.flags) {
- printf("\nFlags: ");
+ xo_emit("\nFlags: {e:flags/%u}", ND.flags);
+ xo_open_list("flags_pretty");
#ifdef ND6_IFF_IFDISABLED
if ((ND.flags & ND6_IFF_IFDISABLED))
- printf("disabled ");
+ xo_emit("{l:%s} ", "disabled");
#endif
if ((ND.flags & ND6_IFF_PERFORMNUD))
- printf("nud ");
+ xo_emit("{l:%s} ", "nud");
#ifdef ND6_IFF_ACCEPT_RTADV
if ((ND.flags & ND6_IFF_ACCEPT_RTADV))
- printf("accept_rtadv ");
+ xo_emit("{l:%s} ", "accept_rtadv");
#endif
#ifdef ND6_IFF_AUTO_LINKLOCAL
if ((ND.flags & ND6_IFF_AUTO_LINKLOCAL))
- printf("auto_linklocal ");
+ xo_emit("{l:%s} ", "auto_linklocal");
#endif
#ifdef ND6_IFF_NO_PREFER_IFACE
if ((ND.flags & ND6_IFF_NO_PREFER_IFACE))
- printf("no_prefer_iface ");
+ xo_emit("{l:%s} ", "no_prefer_iface");
#endif
+ xo_close_list("flags");
}
- putc('\n', stdout);
+ xo_emit("\n");
#undef ND
+ xo_close_container("ifinfo");
close(sock);
}
@@ -1048,7 +1163,7 @@ ifinfo(char *ifname, int argc, char **argv)
#endif
static void
-rtrlist()
+rtrlist(void)
{
int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_DRLIST };
char *buf;
@@ -1057,53 +1172,80 @@ rtrlist()
struct timeval now;
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
- err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
+ xo_err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
/*NOTREACHED*/
}
if (l == 0)
return;
buf = malloc(l);
if (!buf) {
- err(1, "malloc");
+ xo_err(1, "malloc");
/*NOTREACHED*/
}
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
- err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
+ xo_err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
/*NOTREACHED*/
}
+ xo_open_list("router-list");
+
ep = (struct in6_defrouter *)(buf + l);
for (p = (struct in6_defrouter *)buf; p < ep; p++) {
int rtpref;
+ char abuf[INET6_ADDRSTRLEN], *paddr;
if (getnameinfo((struct sockaddr *)&p->rtaddr,
p->rtaddr.sin6_len, host_buf, sizeof(host_buf), NULL, 0,
- (nflag ? NI_NUMERICHOST : 0)) != 0)
+ (opts.nflag ? NI_NUMERICHOST : 0)) != 0)
strlcpy(host_buf, "?", sizeof(host_buf));
+ if (opts.nflag)
+ paddr = host_buf;
+ else {
+ inet_ntop(AF_INET6, &p->rtaddr.sin6_addr, abuf, sizeof(abuf));
+ paddr = abuf;
+ }
- printf("%s if=%s", host_buf,
+ xo_open_instance("router-list");
+ xo_emit("{:hostname/%s}{e:address/%s} if={:interface/%s}",
+ host_buf, paddr,
if_indextoname(p->if_index, ifix_buf));
- printf(", flags=%s%s",
- p->flags & ND_RA_FLAG_MANAGED ? "M" : "",
- p->flags & ND_RA_FLAG_OTHER ? "O" : "");
+ xo_open_list("flags_pretty");
+ char rflags[6] = {}, *pflags = rflags;
+ if (p->flags & ND_RA_FLAG_MANAGED) {
+ *pflags++ = 'M';
+ xo_emit("{el:%s}", "managed");
+ }
+ if (p->flags & ND_RA_FLAG_OTHER) {
+ *pflags++ = 'O';
+ xo_emit("{el:%s}", "other");
+ }
#ifdef DRAFT_IETF_6MAN_IPV6ONLY_FLAG
- printf("%s", p->flags & ND_RA_FLAG_IPV6_ONLY ? "S" : "");
+ if (p->flags & ND_RA_FLAG_IPV6_ONLY) {
+ *pflags++ = 'S';
+ xo_emit("{el:%s}", "ipv6only");
+ }
#endif
+ xo_close_list("flags_pretty");
+ xo_emit(", flags={:flags/%s}", rflags);
+
rtpref = ((p->flags & ND_RA_FLAG_RTPREF_MASK) >> 3) & 0xff;
- printf(", pref=%s", rtpref_str[rtpref]);
+ xo_emit(", pref={:preference/%s}", rtpref_str[rtpref]);
gettimeofday(&now, 0);
if (p->expire == 0)
- printf(", expire=Never\n");
+ xo_emit(", expire=Never\n{en:permanent/true}");
else
- printf(", expire=%s\n",
- sec2str(p->expire - now.tv_sec));
+ xo_emit("{d:/, expire=%s\n}{e:expires_sec/%ld}",
+ sec2str(p->expire - now.tv_sec),
+ (long)p->expire - now.tv_sec);
+ xo_close_instance("router-list");
}
free(buf);
+ xo_close_list("router-list");
}
static void
-plist()
+plist(void)
{
int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_PRLIST };
char *buf;
@@ -1112,68 +1254,92 @@ plist()
size_t l;
struct timeval now;
const int niflags = NI_NUMERICHOST;
- int ninflags = nflag ? NI_NUMERICHOST : 0;
+ int ninflags = opts.nflag ? NI_NUMERICHOST : 0;
char namebuf[NI_MAXHOST];
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
- err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
+ xo_err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
/*NOTREACHED*/
}
buf = malloc(l);
if (!buf) {
- err(1, "malloc");
+ xo_err(1, "malloc");
/*NOTREACHED*/
}
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
- err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
+ xo_err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
/*NOTREACHED*/
}
+ xo_open_list("prefix-list");
+
ep = (struct in6_prefix *)(buf + l);
for (p = (struct in6_prefix *)buf; p < ep; p = n) {
advrtr = (struct sockaddr_in6 *)(p + 1);
n = (struct in6_prefix *)&advrtr[p->advrtrs];
+ xo_open_instance("prefix-list");
if (getnameinfo((struct sockaddr *)&p->prefix,
p->prefix.sin6_len, namebuf, sizeof(namebuf),
NULL, 0, niflags) != 0)
strlcpy(namebuf, "?", sizeof(namebuf));
- printf("%s/%d if=%s\n", namebuf, p->prefixlen,
- if_indextoname(p->if_index, ifix_buf));
+ xo_emit("{:prefix/%s%s%d} if={:interface/%s}\n", namebuf, "/",
+ p->prefixlen, if_indextoname(p->if_index, ifix_buf));
gettimeofday(&now, 0);
/*
* meaning of fields, especially flags, is very different
* by origin. notify the difference to the users.
*/
- printf("flags=%s%s%s%s%s",
- p->raflags.onlink ? "L" : "",
- p->raflags.autonomous ? "A" : "",
- (p->flags & NDPRF_ONLINK) != 0 ? "O" : "",
- (p->flags & NDPRF_DETACHED) != 0 ? "D" : "",
+ char flags[10] = {}, *pflags = flags;
+ xo_open_list("flags_pretty");
+ if (p->raflags.onlink) {
+ *pflags++ = 'L';
+ xo_emit("{el:%s}", "ra_onlink");
+ }
+ if (p->raflags.autonomous) {
+ *pflags++ = 'A';
+ xo_emit("{el:%s}", "ra_autonomous");
+ }
+ if (p->flags & NDPRF_ONLINK) {
+ *pflags++ = 'O';
+ xo_emit("{el:%s}", "is_onlink");
+ }
+ if (p->flags & NDPRF_DETACHED) {
+ *pflags++ = 'D';
+ xo_emit("{el:%s}", "is_detached");
+ }
#ifdef NDPRF_HOME
- (p->flags & NDPRF_HOME) != 0 ? "H" : ""
-#else
- ""
+ if (p->flags & NDPRF_HOME) {
+ *pflags++ = 'H';
+ xo_emit("{el:%s}", "is_home");
+ }
#endif
- );
+ xo_close_list("flags_pretty");
+ xo_emit("flags={:flags/%s}", flags);
+ int expire_in = p->expire - now.tv_sec;
+
if (p->vltime == ND6_INFINITE_LIFETIME)
- printf(" vltime=infinity");
+ xo_emit(" vltime=infinity{e:valid-lifetime/%lu}",
+ (unsigned long)p->vltime);
else
- printf(" vltime=%lu", (unsigned long)p->vltime);
+ xo_emit(" vltime={:valid-lifetime/%lu}",
+ (unsigned long)p->vltime);
if (p->pltime == ND6_INFINITE_LIFETIME)
- printf(", pltime=infinity");
+ xo_emit(", pltime=infinity{e:preferred-lifetime/%lu}",
+ (unsigned long)p->pltime);
else
- printf(", pltime=%lu", (unsigned long)p->pltime);
+ xo_emit(", pltime={:preferred-lifetime/%lu}",
+ (unsigned long)p->pltime);
if (p->expire == 0)
- printf(", expire=Never");
+ xo_emit(", expire=Never{en:permanent/true}");
else if (p->expire >= now.tv_sec)
- printf(", expire=%s",
- sec2str(p->expire - now.tv_sec));
+ xo_emit(", expire=%s{e:expires_sec/%d}",
+ sec2str(expire_in), expire_in);
else
- printf(", expired");
- printf(", ref=%d", p->refcnt);
- printf("\n");
+ xo_emit(", expired{e:expires_sec/%d}", expire_in);
+ xo_emit(", ref={:refcount/%d}", p->refcnt);
+ xo_emit("\n");
/*
* "advertising router" list is meaningful only if the prefix
* information is from RA.
@@ -1183,80 +1349,94 @@ plist()
struct sockaddr_in6 *sin6;
sin6 = advrtr;
- printf(" advertised by\n");
+ xo_emit(" advertised by\n");
+ xo_open_list("advertising-routers");
for (j = 0; j < p->advrtrs; j++) {
struct in6_nbrinfo *nbi;
+ xo_open_instance("advertising-routers");
if (getnameinfo((struct sockaddr *)sin6,
sin6->sin6_len, namebuf, sizeof(namebuf),
NULL, 0, ninflags) != 0)
strlcpy(namebuf, "?", sizeof(namebuf));
- printf(" %s", namebuf);
+ char abuf[INET6_ADDRSTRLEN];
+ inet_ntop(AF_INET6, &sin6->sin6_addr, abuf,
+ sizeof(abuf));
+
+ xo_emit(" {:hostname/%s}{e:address/%s}",
+ namebuf, abuf);
nbi = getnbrinfo(&sin6->sin6_addr,
p->if_index, 0);
+ const char *state = "";
if (nbi) {
switch (nbi->state) {
case ND6_LLINFO_REACHABLE:
case ND6_LLINFO_STALE:
case ND6_LLINFO_DELAY:
case ND6_LLINFO_PROBE:
- printf(" (reachable)\n");
+ state = "reachable";
break;
default:
- printf(" (unreachable)\n");
+ state = "unreachable";
}
} else
- printf(" (no neighbor state)\n");
+ state = "no neighbor state";
+ xo_emit(" ({:state/%s})\n", state);
sin6++;
+ xo_close_instance("advertising-routers");
}
+ xo_close_list("advertising-routers");
} else
- printf(" No advertising router\n");
+ xo_emit(" No advertising router\n");
+ xo_close_instance("prefix-list");
}
free(buf);
+
+ xo_close_list("prefix-list");
}
static void
-pfx_flush()
+pfx_flush(void)
{
char dummyif[IFNAMSIZ+8];
int sock;
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
- err(1, "socket");
+ xo_err(1, "socket");
strlcpy(dummyif, "lo0", sizeof(dummyif)); /* dummy */
if (ioctl(sock, SIOCSPFXFLUSH_IN6, (caddr_t)&dummyif) < 0)
- err(1, "ioctl(SIOCSPFXFLUSH_IN6)");
+ xo_err(1, "ioctl(SIOCSPFXFLUSH_IN6)");
close(sock);
}
static void
-rtr_flush()
+rtr_flush(void)
{
char dummyif[IFNAMSIZ+8];
int sock;
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
- err(1, "socket");
+ xo_err(1, "socket");
strlcpy(dummyif, "lo0", sizeof(dummyif)); /* dummy */
if (ioctl(sock, SIOCSRTRFLUSH_IN6, (caddr_t)&dummyif) < 0)
- err(1, "ioctl(SIOCSRTRFLUSH_IN6)");
+ xo_err(1, "ioctl(SIOCSRTRFLUSH_IN6)");
close(sock);
}
static void
-harmonize_rtr()
+harmonize_rtr(void)
{
char dummyif[IFNAMSIZ+8];
int sock;
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
- err(1, "socket");
+ xo_err(1, "socket");
strlcpy(dummyif, "lo0", sizeof(dummyif)); /* dummy */
if (ioctl(sock, SIOCSNDFLUSH_IN6, (caddr_t)&dummyif) < 0)
- err(1, "ioctl(SIOCSNDFLUSH_IN6)");
+ xo_err(1, "ioctl(SIOCSNDFLUSH_IN6)");
close(sock);
}
@@ -1273,51 +1453,51 @@ setdefif(char *ifname)
ifindex = 0;
else {
if ((ifindex = if_nametoindex(ifname)) == 0)
- err(1, "failed to resolve i/f index for %s", ifname);
+ xo_err(1, "failed to resolve i/f index for %s", ifname);
}
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
- err(1, "socket");
+ xo_err(1, "socket");
strlcpy(ndifreq.ifname, "lo0", sizeof(ndifreq.ifname)); /* dummy */
ndifreq.ifindex = ifindex;
if (ioctl(sock, SIOCSDEFIFACE_IN6, (caddr_t)&ndifreq) < 0)
- err(1, "ioctl(SIOCSDEFIFACE_IN6)");
+ xo_err(1, "ioctl(SIOCSDEFIFACE_IN6)");
close(sock);
}
static void
-getdefif()
+getdefif(void)
{
struct in6_ndifreq ndifreq;
char ifname[IFNAMSIZ+8];
int sock;
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
- err(1, "socket");
+ xo_err(1, "socket");
memset(&ndifreq, 0, sizeof(ndifreq));
strlcpy(ndifreq.ifname, "lo0", sizeof(ndifreq.ifname)); /* dummy */
if (ioctl(sock, SIOCGDEFIFACE_IN6, (caddr_t)&ndifreq) < 0)
- err(1, "ioctl(SIOCGDEFIFACE_IN6)");
+ xo_err(1, "ioctl(SIOCGDEFIFACE_IN6)");
if (ndifreq.ifindex == 0)
- printf("No default interface.\n");
+ xo_emit("No default interface.\n");
else {
if ((if_indextoname(ndifreq.ifindex, ifname)) == NULL)
- err(1, "failed to resolve ifname for index %lu",
+ xo_err(1, "failed to resolve ifname for index %lu",
ndifreq.ifindex);
- printf("ND default interface = %s\n", ifname);
+ xo_emit("ND default interface = {:default-interface/%s}\n", ifname);
}
close(sock);
}
#endif /* SIOCSDEFIFACE_IN6 */
-static char *
+char *
sec2str(time_t total)
{
static char result[256];
@@ -1362,14 +1542,15 @@ sec2str(time_t total)
* Print the timestamp
* from tcpdump/util.c
*/
-static void
+void
ts_print(const struct timeval *tvp)
{
int sec;
/* Default */
sec = (tvp->tv_sec + thiszone) % 86400;
- (void)printf("%02d:%02d:%02d.%06u ",
+ xo_emit("{e:tv_sec/%lld}{e:tv_usec/%lld}{d:/%02d:%02d:%02d.%06u} ",
+ tvp->tv_sec, tvp->tv_usec,
sec / 3600, (sec % 3600) / 60, sec % 60, (u_int32_t)tvp->tv_usec);
}
diff --git a/usr.sbin/ndp/ndp.h b/usr.sbin/ndp/ndp.h
new file mode 100644
index 000000000000..f89ab19a9d3f
--- /dev/null
+++ b/usr.sbin/ndp/ndp.h
@@ -0,0 +1,27 @@
+#ifndef _USR_SBIN_NDP_NDP_H_
+#define _USR_SBIN_NDP_NDP_H_
+
+#define W_ADDR 36
+#define W_LL 17
+#define W_IF 6
+
+struct ndp_opts {
+ bool nflag;
+ bool tflag;
+ int flags;
+ time_t expire_time;
+};
+
+extern struct ndp_opts opts;
+
+bool valid_type(int if_type);
+void ts_print(const struct timeval *tvp);
+char *ether_str(struct sockaddr_dl *sdl);
+char *sec2str(time_t total);
+int getaddr(char *host, struct sockaddr_in6 *sin6);
+int print_entries_nl(uint32_t ifindex, struct sockaddr_in6 *addr, bool cflag);
+int delete_nl(uint32_t ifindex, char *host, bool warn);
+int set_nl(uint32_t ifindex, struct sockaddr_in6 *dst, struct sockaddr_dl *sdl,
+ char *host);
+
+#endif
diff --git a/usr.sbin/ndp/ndp_netlink.c b/usr.sbin/ndp/ndp_netlink.c
new file mode 100644
index 000000000000..e18d64175619
--- /dev/null
+++ b/usr.sbin/ndp/ndp_netlink.c
@@ -0,0 +1,516 @@
+#include <sys/param.h>
+#include <sys/module.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sys/linker.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+#include <sys/time.h>
+#include <sys/queue.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+
+#include <netinet/icmp6.h>
+#include <netinet6/in6_var.h>
+#include <netinet6/nd6.h>
+
+#include <arpa/inet.h>
+
+#include <ctype.h>
+#include <netdb.h>
+#include <errno.h>
+#include <nlist.h>
+#include <stdio.h>
+#include <string.h>
+#include <paths.h>
+#include <err.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <libxo/xo.h>
+
+
+#include <netlink/netlink.h>
+#include <netlink/netlink_route.h>
+#include <netlink/netlink_snl.h>
+#include <netlink/netlink_snl_route.h>
+#include <netlink/netlink_snl_route_compat.h>
+#include <netlink/netlink_snl_route_parsers.h>
+
+#include <libxo/xo.h>
+#include "ndp.h"
+
+#define RTF_ANNOUNCE RTF_PROTO2
+
+static void
+nl_init_socket(struct snl_state *ss)
+{
+ if (snl_init(ss, NETLINK_ROUTE))
+ return;
+
+ if (modfind("netlink") == -1 && errno == ENOENT) {
+ /* Try to load */
+ if (kldload("netlink") == -1)
+ err(1, "netlink is not loaded and load attempt failed");
+ if (snl_init(ss, NETLINK_ROUTE))
+ return;
+ }
+
+ err(1, "unable to open netlink socket");
+}
+
+static bool
+get_link_info(struct snl_state *ss, uint32_t ifindex,
+ struct snl_parsed_link_simple *link)
+{
+ struct snl_writer nw;
+
+ snl_init_writer(ss, &nw);
+
+ struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_GETLINK);
+ struct ifinfomsg *ifmsg = snl_reserve_msg_object(&nw, struct ifinfomsg);
+ if (ifmsg != NULL)
+ ifmsg->ifi_index = ifindex;
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(ss, hdr))
+ return (false);
+
+ hdr = snl_read_reply(ss, hdr->nlmsg_seq);
+
+ if (hdr == NULL || hdr->nlmsg_type != RTM_NEWLINK)
+ return (false);
+
+ if (!snl_parse_nlmsg(ss, hdr, &snl_rtm_link_parser_simple, link))
+ return (false);
+
+ return (true);
+}
+
+
+
+static bool
+has_l2(struct snl_state *ss, uint32_t ifindex)
+{
+ struct snl_parsed_link_simple link = {};
+
+ if (!get_link_info(ss, ifindex, &link))
+ return (false);
+
+ return (valid_type(link.ifi_type) != 0);
+}
+
+static uint32_t
+get_myfib(void)
+{
+ uint32_t fibnum = 0;
+ size_t len = sizeof(fibnum);
+
+ sysctlbyname("net.my_fibnum", (void *)&fibnum, &len, NULL, 0);
+
+ return (fibnum);
+}
+
+static void
+ip6_writemask(struct in6_addr *addr6, uint8_t mask)
+{
+ uint32_t *cp;
+
+ for (cp = (uint32_t *)addr6; mask >= 32; mask -= 32)
+ *cp++ = 0xFFFFFFFF;
+ if (mask > 0)
+ *cp = htonl(mask ? ~((1 << (32 - mask)) - 1) : 0);
+}
+#define s6_addr32 __u6_addr.__u6_addr32
+#define IN6_MASK_ADDR(a, m) do { \
+ (a)->s6_addr32[0] &= (m)->s6_addr32[0]; \
+ (a)->s6_addr32[1] &= (m)->s6_addr32[1]; \
+ (a)->s6_addr32[2] &= (m)->s6_addr32[2]; \
+ (a)->s6_addr32[3] &= (m)->s6_addr32[3]; \
+} while (0)
+
+static int
+guess_ifindex(struct snl_state *ss, uint32_t fibnum, const struct sockaddr_in6 *dst)
+{
+ struct snl_writer nw;
+
+ if (IN6_IS_ADDR_LINKLOCAL(&dst->sin6_addr))
+ return (dst->sin6_scope_id);
+ else if (IN6_IS_ADDR_MULTICAST(&dst->sin6_addr))
+ return (0);
+
+
+ snl_init_writer(ss, &nw);
+
+ struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_GETROUTE);
+ struct rtmsg *rtm = snl_reserve_msg_object(&nw, struct rtmsg);
+ rtm->rtm_family = AF_INET6;
+
+ snl_add_msg_attr_ip(&nw, RTA_DST, (struct sockaddr *)dst);
+ snl_add_msg_attr_u32(&nw, RTA_TABLE, fibnum);
+
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(ss, hdr))
+ return (0);
+
+ hdr = snl_read_reply(ss, hdr->nlmsg_seq);
+
+ if (hdr->nlmsg_type != NL_RTM_NEWROUTE) {
+ /* No route found, unable to guess ifindex */
+ return (0);
+ }
+
+ struct snl_parsed_route r = {};
+ if (!snl_parse_nlmsg(ss, hdr, &snl_rtm_route_parser, &r))
+ return (0);
+
+ if (r.rta_multipath.num_nhops > 0 || (r.rta_rtflags & RTF_GATEWAY))
+ return (0);
+
+ /* Check if the interface is of supported type */
+ if (has_l2(ss, r.rta_oif))
+ return (r.rta_oif);
+
+ /* Check the case when we matched the loopback route for P2P */
+ snl_init_writer(ss, &nw);
+ hdr = snl_create_msg_request(&nw, RTM_GETNEXTHOP);
+ snl_reserve_msg_object(&nw, struct nhmsg);
+
+ int off = snl_add_msg_attr_nested(&nw, NHA_FREEBSD);
+ snl_add_msg_attr_u32(&nw, NHAF_KID, r.rta_knh_id);
+ snl_add_msg_attr_u8(&nw, NHAF_FAMILY, AF_INET6);
+ snl_add_msg_attr_u32(&nw, NHAF_TABLE, fibnum);
+ snl_end_attr_nested(&nw, off);
+
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(ss, hdr))
+ return (0);
+
+ hdr = snl_read_reply(ss, hdr->nlmsg_seq);
+
+ if (hdr->nlmsg_type != NL_RTM_NEWNEXTHOP) {
+ /* No nexthop found, unable to guess ifindex */
+ return (0);
+ }
+
+ struct snl_parsed_nhop nh = {};
+ if (!snl_parse_nlmsg(ss, hdr, &snl_nhmsg_parser, &nh))
+ return (0);
+
+ return (nh.nhaf_aif);
+}
+
+static uint32_t
+fix_ifindex(struct snl_state *ss, uint32_t ifindex, const struct sockaddr_in6 *sa)
+{
+ if (ifindex == 0)
+ ifindex = guess_ifindex(ss, get_myfib(), sa);
+ return (ifindex);
+}
+
+static void
+print_entry(struct snl_parsed_neigh *neigh, struct snl_parsed_link_simple *link)
+{
+ struct timeval now;
+ char host_buf[NI_MAXHOST];
+ int addrwidth;
+ int llwidth;
+ int ifwidth;
+ char *ifname;
+
+ getnameinfo(neigh->nda_dst, sizeof(struct sockaddr_in6), host_buf,
+ sizeof(host_buf), NULL, 0, (opts.nflag ? NI_NUMERICHOST : 0));
+
+ gettimeofday(&now, 0);
+ if (opts.tflag)
+ ts_print(&now);
+
+ struct sockaddr_dl sdl = {
+ .sdl_family = AF_LINK,
+ .sdl_type = link->ifi_type,
+ .sdl_len = sizeof(struct sockaddr_dl),
+ };
+
+ if (neigh->nda_lladdr) {
+ sdl.sdl_alen = NLA_DATA_LEN(neigh->nda_lladdr),
+ memcpy(sdl.sdl_data, NLA_DATA(neigh->nda_lladdr), sdl.sdl_alen);
+ }
+
+ addrwidth = strlen(host_buf);
+ if (addrwidth < W_ADDR)
+ addrwidth = W_ADDR;
+ llwidth = strlen(ether_str(&sdl));
+ if (W_ADDR + W_LL - addrwidth > llwidth)
+ llwidth = W_ADDR + W_LL - addrwidth;
+ ifname = link->ifla_ifname;
+ ifwidth = strlen(ifname);
+ if (W_ADDR + W_LL + W_IF - addrwidth - llwidth > ifwidth)
+ ifwidth = W_ADDR + W_LL + W_IF - addrwidth - llwidth;
+
+ xo_open_instance("neighbor-cache");
+ /* Compose format string for libxo, as it doesn't support *.* */
+ char xobuf[200];
+ snprintf(xobuf, sizeof(xobuf),
+ "{:address/%%-%d.%ds/%%s} {:mac-address/%%-%d.%ds/%%s} {:interface/%%%d.%ds/%%s}",
+ addrwidth, addrwidth, llwidth, llwidth, ifwidth, ifwidth);
+ xo_emit(xobuf, host_buf, ether_str(&sdl), ifname);
+
+ /* Print neighbor discovery specific information */
+ time_t expire = (time_t)neigh->ndaf_next_ts;
+ int expire_in = expire - now.tv_sec;
+ if (expire > now.tv_sec)
+ xo_emit("{d:/ %-9.9s}{e:expires_sec/%d}", sec2str(expire_in), expire_in);
+ else if (expire == 0)
+ xo_emit("{d:/ %-9.9s}{en:permanent/true}", "permanent");
+ else
+ xo_emit("{d:/ %-9.9s}{e:expires_sec/%d}", "expired", expire_in);
+
+ const char *lle_state = "";
+ switch (neigh->ndm_state) {
+ case NUD_INCOMPLETE:
+ lle_state = "I";
+ break;
+ case NUD_REACHABLE:
+ lle_state = "R";
+ break;
+ case NUD_STALE:
+ lle_state = "S";
+ break;
+ case NUD_DELAY:
+ lle_state = "D";
+ break;
+ case NUD_PROBE:
+ lle_state = "P";
+ break;
+ case NUD_FAILED:
+ lle_state = "F";
+ break;
+ default:
+ lle_state = "N";
+ break;
+ }
+ xo_emit(" {:neighbor-state/%s}", lle_state);
+
+ bool isrouter = neigh->ndm_flags & NTF_ROUTER;
+
+ /*
+ * other flags. R: router, P: proxy, W: ??
+ */
+ char flgbuf[8];
+ snprintf(flgbuf, sizeof(flgbuf), "%s%s",
+ isrouter ? "R" : "",
+ (neigh->ndm_flags & NTF_PROXY) ? "p" : "");
+ xo_emit(" {:nd-flags/%s}", flgbuf);
+
+ if (neigh->nda_probes != 0)
+ xo_emit("{u:/ %d}", neigh->nda_probes);
+
+ xo_emit("\n");
+ xo_close_instance("neighbor-cache");
+}
+
+int
+print_entries_nl(uint32_t ifindex, struct sockaddr_in6 *addr, bool cflag)
+{
+ struct snl_state ss_req = {}, ss_cmd = {};
+ struct snl_parsed_link_simple link = {};
+ struct snl_writer nw;
+
+ nl_init_socket(&ss_req);
+ snl_init_writer(&ss_req, &nw);
+
+ struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_GETNEIGH);
+ struct ndmsg *ndmsg = snl_reserve_msg_object(&nw, struct ndmsg);
+ if (ndmsg != NULL) {
+ ndmsg->ndm_family = AF_INET6;
+ ndmsg->ndm_ifindex = ifindex;
+ }
+
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(&ss_req, hdr)) {
+ snl_free(&ss_req);
+ return (0);
+ }
+
+ uint32_t nlmsg_seq = hdr->nlmsg_seq;
+ struct snl_errmsg_data e = {};
+ int count = 0;
+ nl_init_socket(&ss_cmd);
+
+ /* Print header */
+ if (!opts.tflag && !cflag) {
+ char xobuf[200];
+ snprintf(xobuf, sizeof(xobuf),
+ "{T:/%%-%d.%ds} {T:/%%-%d.%ds} {T:/%%%d.%ds} {T:/%%-9.9s} {T:%%1s} {T:%%5s}\n",
+ W_ADDR, W_ADDR, W_LL, W_LL, W_IF, W_IF);
+ xo_emit(xobuf, "Neighbor", "Linklayer Address", "Netif", "Expire", "S", "Flags");
+ }
+ xo_open_list("neighbor-cache");
+
+ while ((hdr = snl_read_reply_multi(&ss_req, nlmsg_seq, &e)) != NULL) {
+ struct snl_parsed_neigh neigh = {};
+
+ if (!snl_parse_nlmsg(&ss_req, hdr, &snl_rtm_neigh_parser, &neigh))
+ continue;
+
+ if (neigh.nda_ifindex != link.ifi_index) {
+ snl_clear_lb(&ss_cmd);
+ memset(&link, 0, sizeof(link));
+ if (!get_link_info(&ss_cmd, neigh.nda_ifindex, &link))
+ continue;
+ }
+
+ /* TODO: embed LL in the parser */
+ struct sockaddr_in6 *dst = (struct sockaddr_in6 *)neigh.nda_dst;
+ if (IN6_IS_ADDR_LINKLOCAL(&dst->sin6_addr))
+ dst->sin6_scope_id = neigh.nda_ifindex;
+
+ if (addr != NULL) {
+ if (IN6_ARE_ADDR_EQUAL(&addr->sin6_addr,
+ &dst->sin6_addr) == 0 ||
+ addr->sin6_scope_id != dst->sin6_scope_id)
+ continue;
+ }
+
+ if (cflag) {
+ char dst_str[INET6_ADDRSTRLEN];
+
+ inet_ntop(AF_INET6, &dst->sin6_addr, dst_str, sizeof(dst_str));
+ delete_nl(neigh.nda_ifindex, dst_str, false); /* no warn */
+ } else
+ print_entry(&neigh, &link);
+
+ count++;
+ snl_clear_lb(&ss_req);
+ }
+ xo_close_list("neighbor-cache");
+
+ snl_free(&ss_req);
+ snl_free(&ss_cmd);
+
+ return (count);
+}
+
+int
+delete_nl(uint32_t ifindex, char *host, bool warn)
+{
+#define xo_warnx(...) do { if (warn) { xo_warnx(__VA_ARGS__); } } while(0)
+ struct snl_state ss = {};
+ struct snl_writer nw;
+ struct sockaddr_in6 dst;
+
+ int gai_error = getaddr(host, &dst);
+ if (gai_error) {
+ xo_warnx("%s: %s", host, gai_strerror(gai_error));
+ return 1;
+ }
+
+ nl_init_socket(&ss);
+
+ ifindex = fix_ifindex(&ss, ifindex, &dst);
+ if (ifindex == 0) {
+ xo_warnx("delete: cannot locate %s", host);
+ snl_free(&ss);
+ return (0);
+ }
+
+ snl_init_writer(&ss, &nw);
+ struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_DELNEIGH);
+ struct ndmsg *ndmsg = snl_reserve_msg_object(&nw, struct ndmsg);
+ if (ndmsg != NULL) {
+ ndmsg->ndm_family = AF_INET6;
+ ndmsg->ndm_ifindex = ifindex;
+ }
+ snl_add_msg_attr_ip(&nw, NDA_DST, (struct sockaddr *)&dst);
+
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(&ss, hdr)) {
+ snl_free(&ss);
+ return (1);
+ }
+
+ struct snl_errmsg_data e = {};
+ snl_read_reply_code(&ss, hdr->nlmsg_seq, &e);
+ if (e.error != 0) {
+ if (e.error_str != NULL)
+ xo_warnx("delete %s: %s (%s)", host, strerror(e.error), e.error_str);
+ else
+ xo_warnx("delete %s: %s", host, strerror(e.error));
+ } else {
+ char host_buf[NI_MAXHOST];
+ char ifix_buf[IFNAMSIZ];
+
+ getnameinfo((struct sockaddr *)&dst,
+ dst.sin6_len, host_buf,
+ sizeof(host_buf), NULL, 0,
+ (opts.nflag ? NI_NUMERICHOST : 0));
+
+ char *ifname = if_indextoname(ifindex, ifix_buf);
+ if (ifname == NULL) {
+ strlcpy(ifix_buf, "?", sizeof(ifix_buf));
+ ifname = ifix_buf;
+ }
+ char abuf[INET6_ADDRSTRLEN];
+ inet_ntop(AF_INET6, &dst.sin6_addr, abuf, sizeof(abuf));
+
+ xo_open_instance("neighbor-cache");
+ xo_emit("{:hostname/%s}{d:/ (%s) deleted\n}", host, host_buf);
+ xo_emit("{e:address/%s}{e:interface/%s}", abuf, ifname);
+ xo_close_instance("neighbor-cache");
+ }
+ snl_free(&ss);
+
+ return (e.error != 0);
+#undef xo_warnx /* see above */
+}
+
+int
+set_nl(uint32_t ifindex, struct sockaddr_in6 *dst, struct sockaddr_dl *sdl, char *host)
+{
+ struct snl_state ss = {};
+ struct snl_writer nw;
+
+ nl_init_socket(&ss);
+
+ ifindex = fix_ifindex(&ss, ifindex, dst);
+ if (ifindex == 0) {
+ xo_warnx("delete: cannot locate %s", host);
+ snl_free(&ss);
+ return (0);
+ }
+
+ snl_init_writer(&ss, &nw);
+ struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_NEWNEIGH);
+ hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE;
+ struct ndmsg *ndmsg = snl_reserve_msg_object(&nw, struct ndmsg);
+ if (ndmsg != NULL) {
+ uint8_t nl_flags = NTF_STICKY;
+
+ ndmsg->ndm_family = AF_INET6;
+ ndmsg->ndm_ifindex = ifindex;
+ ndmsg->ndm_state = NUD_PERMANENT;
+
+ if (opts.flags & RTF_ANNOUNCE)
+ nl_flags |= NTF_PROXY;
+ ndmsg->ndm_flags = nl_flags;
+ }
+ snl_add_msg_attr_ip(&nw, NDA_DST, (struct sockaddr *)dst);
+ snl_add_msg_attr(&nw, NDA_LLADDR, sdl->sdl_alen, LLADDR(sdl));
+
+ if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(&ss, hdr)) {
+ snl_free(&ss);
+ return (1);
+ }
+
+ struct snl_errmsg_data e = {};
+ snl_read_reply_code(&ss, hdr->nlmsg_seq, &e);
+ if (e.error != 0) {
+ if (e.error_str != NULL)
+ xo_warnx("set: %s: %s (%s)", host, strerror(e.error), e.error_str);
+ else
+ xo_warnx("set %s: %s", host, strerror(e.error));
+ }
+ snl_free(&ss);
+
+ return (e.error != 0);
+}
+
diff --git a/usr.sbin/newsyslog/Makefile b/usr.sbin/newsyslog/Makefile
index a0f933333320..b2e945b6215a 100644
--- a/usr.sbin/newsyslog/Makefile
+++ b/usr.sbin/newsyslog/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/newsyslog/Makefile.depend b/usr.sbin/newsyslog/Makefile.depend
index 6cfaab1c3644..cde253fc72ce 100644
--- a/usr.sbin/newsyslog/Makefile.depend
+++ b/usr.sbin/newsyslog/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/libsbuf \
.include <dirdeps.mk>
diff --git a/usr.sbin/newsyslog/extern.h b/usr.sbin/newsyslog/extern.h
index 909da2ca7341..8337b314508e 100644
--- a/usr.sbin/newsyslog/extern.h
+++ b/usr.sbin/newsyslog/extern.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* ------+---------+---------+---------+---------+---------+---------+---------*
* Copyright (c) 2003 - Garance Alistair Drosehn <gad@FreeBSD.org>.
@@ -31,7 +31,6 @@
* official policies, either expressed or implied, of the FreeBSD Project.
*
* ------+---------+---------+---------+---------+---------+---------+---------*
- * $FreeBSD$
* ------+---------+---------+---------+---------+---------+---------+---------*
*/
diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8
index a85f8ac7054a..6d4fc378e790 100644
--- a/usr.sbin/newsyslog/newsyslog.8
+++ b/usr.sbin/newsyslog/newsyslog.8
@@ -1,8 +1,5 @@
.\" This file contains changes from the Open Software Foundation.
.\"
-.\" from: @(#)newsyslog.8
-.\" $FreeBSD$
-.\"
.\" Copyright 1988, 1989 by the Massachusetts Institute of Technology
.\"
.\" Permission to use, copy, modify, and distribute this software
@@ -17,7 +14,7 @@
.\" the suitability of this software for any purpose. It is
.\" provided "as is" without express or implied warranty.
.\"
-.Dd November 10, 2018
+.Dd December 22, 2023
.Dt NEWSYSLOG 8
.Os
.Sh NAME
@@ -27,6 +24,7 @@
.Nm
.Op Fl CFNPnrsv
.Op Fl a Ar directory
+.Op Fl c Ar none Ns | Ns Ar legacy Ns | Ns Ar bzip2 Ns | Ns Ar gzip Ns | Ns Ar xz Ns | Ns Ar zstd
.Op Fl d Ar directory
.Op Fl f Ar config_file
.Op Fl S Ar pidfile
@@ -81,6 +79,25 @@ and mode three (above) assumes that this is so.
The following options can be used with
.Nm :
.Bl -tag -width indent
+.It Fl c Ar none Ns | Ns Ar legacy Ns | Ns Ar bzip2 Ns | Ns Ar gzip Ns | Ns Ar xz Ns | Ns Ar zstd
+Instructs
+.Nm
+to use the specified compression method when a file is flagged for compression.
+The default method is
+.Dq legacy ,
+which interprets the
+.Sy J, X, Y, Z
+flags in the configuration file according to their historical meanings.
+This default setting can be overridden by specifying
+.Fl c Ar none ,
+which causes
+.Nm
+to ignore all compression flags.
+Alternatively, specifying one of the compression methods:
+.Sy bzip2 , gzip , xz ,
+or
+.Sy zstd ,
+will apply the chosen method to all files flagged for compression.
.It Fl f Ar config_file
Instruct
.Nm
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index 8f8bb54e9b46..e9b84bae342d 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -54,8 +54,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define OSF
#include <sys/param.h>
@@ -76,6 +74,7 @@ __FBSDID("$FreeBSD$");
#include <paths.h>
#include <pwd.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <libgen.h>
#include <stdlib.h>
@@ -90,13 +89,15 @@ __FBSDID("$FreeBSD$");
/*
* Compression types
*/
-#define COMPRESS_TYPES 5 /* Number of supported compression types */
-
-#define COMPRESS_NONE 0
-#define COMPRESS_GZIP 1
-#define COMPRESS_BZIP2 2
-#define COMPRESS_XZ 3
-#define COMPRESS_ZSTD 4
+enum compress_types_enum {
+ COMPRESS_NONE = 0,
+ COMPRESS_GZIP = 1,
+ COMPRESS_BZIP2 = 2,
+ COMPRESS_XZ = 3,
+ COMPRESS_ZSTD = 4,
+ COMPRESS_LEGACY = 5, /* Special: use legacy type */
+ COMPRESS_TYPES = COMPRESS_LEGACY /* Number of supported compression types */
+};
/*
* Bit-values for the 'flags' parsed from a config-file entry.
@@ -124,11 +125,13 @@ __FBSDID("$FreeBSD$");
#define DEFAULT_MARKER "<default>"
#define DEBUG_MARKER "<debug>"
#define INCLUDE_MARKER "<include>"
+#define COMPRESS_MARKER "<compress>"
#define DEFAULT_TIMEFNAME_FMT "%Y%m%dT%H%M%S"
#define MAX_OLDLOGS 65536 /* Default maximum number of old logfiles */
struct compress_types {
+ const char *name; /* Name of compression type */
const char *flag; /* Flag in configuration file */
const char *suffix; /* Compression suffix */
const char *path; /* Path to compression program */
@@ -139,14 +142,29 @@ struct compress_types {
static const char *gzip_flags[] = { "-f" };
#define bzip2_flags gzip_flags
#define xz_flags gzip_flags
-static const char *zstd_flags[] = { "-q", "--rm" };
-
-static const struct compress_types compress_type[COMPRESS_TYPES] = {
- { "", "", "", NULL, 0 },
- { "Z", ".gz", _PATH_GZIP, gzip_flags, nitems(gzip_flags) },
- { "J", ".bz2", _PATH_BZIP2, bzip2_flags, nitems(bzip2_flags) },
- { "X", ".xz", _PATH_XZ, xz_flags, nitems(xz_flags) },
- { "Y", ".zst", _PATH_ZSTD, zstd_flags, nitems(zstd_flags) }
+static const char *zstd_flags[] = { "-q", "-T0", "--adapt", "--long", "--rm" };
+
+static struct compress_types compress_type[COMPRESS_TYPES] = {
+ [COMPRESS_NONE] = {
+ .name = "none", .flag = "", .suffix = "",
+ .path = "", .flags = NULL, .nflags = 0
+ },
+ [COMPRESS_GZIP] = {
+ .name = "gzip", .flag = "Z", .suffix = ".gz",
+ .path = _PATH_GZIP, .flags = gzip_flags, .nflags = nitems(gzip_flags)
+ },
+ [COMPRESS_BZIP2] = {
+ .name = "bzip2", .flag = "J", .suffix = ".bz2",
+ .path = _PATH_BZIP2, .flags = bzip2_flags, .nflags = nitems(bzip2_flags)
+ },
+ [COMPRESS_XZ] = {
+ .name = "xz", .flag = "X", .suffix = ".xz",
+ .path = _PATH_XZ, .flags = xz_flags, .nflags = nitems(xz_flags)
+ },
+ [COMPRESS_ZSTD] = {
+ .name = "zstd", .flag = "Y", .suffix = ".zst",
+ .path = _PATH_ZSTD, .flags = zstd_flags, .nflags = nitems(zstd_flags)
+ },
};
struct conf_entry {
@@ -231,6 +249,9 @@ static char *timefnamefmt = NULL;/* Use time based filenames instead of .0 */
static char *archdirname; /* Directory path to old logfiles archive */
static char *destdir = NULL; /* Directory to treat at root for logs */
static const char *conf; /* Configuration file to use */
+static enum compress_types_enum compress_type_override = COMPRESS_LEGACY; /* Compression type */
+static bool compress_type_set = false;
+static bool compress_type_seen = false;
struct ptime_data *dbg_timenow; /* A "timenow" value set via -D option */
static struct ptime_data *timenow; /* The time to use for checking at-fields */
@@ -281,7 +302,7 @@ static struct conf_entry *init_entry(const char *fname,
struct conf_entry *src_entry);
static void parse_args(int argc, char **argv);
static int parse_doption(const char *doption);
-static void usage(void);
+static void usage(void) __dead2;
static int log_trim(const char *logname, const struct conf_entry *log_ent);
static int age_old_log(const char *file);
static void savelog(char *from, char *to);
@@ -488,6 +509,37 @@ free_clist(struct cflist *list)
list = NULL;
}
+static bool
+parse_compression_type(const char *str, enum compress_types_enum *type)
+{
+ int i;
+
+ for (i = 0; i < COMPRESS_TYPES; i++) {
+ if (strcasecmp(str, compress_type[i].name) == 0) {
+ *type = i;
+ break;
+ }
+ }
+ if (i == COMPRESS_TYPES) {
+ if (strcasecmp(str, "legacy") == 0)
+ compress_type_override = COMPRESS_LEGACY;
+ else {
+ return (false);
+ }
+ }
+ return (true);
+}
+
+static const char *
+compression_type_name(enum compress_types_enum type)
+{
+
+ if (type == COMPRESS_LEGACY)
+ return ("legacy");
+ else
+ return (compress_type[type].name);
+}
+
static fk_entry
do_entry(struct conf_entry * ent)
{
@@ -611,8 +663,13 @@ do_entry(struct conf_entry * ent)
if (ent->rotate && !norotate) {
if (temp_reason[0] != '\0')
ent->r_reason = strdup(temp_reason);
- if (verbose)
- printf("--> trimming log....\n");
+ if (verbose) {
+ if (ent->compress == COMPRESS_NONE)
+ printf("--> trimming log....\n");
+ else
+ printf("--> trimming log and compressing with %s....\n",
+ compression_type_name(ent->compress));
+ }
if (noaction && !verbose)
printf("%s <%d%s>: trimming\n", ent->log,
ent->numlogs,
@@ -643,12 +700,19 @@ parse_args(int argc, char **argv)
hostname_shortlen = strcspn(hostname, ".");
/* Parse command line options. */
- while ((ch = getopt(argc, argv, "a:d:f:nrst:vCD:FNPR:S:")) != -1)
+ while ((ch = getopt(argc, argv, "a:c:d:f:nrst:vCD:FNPR:S:")) != -1)
switch (ch) {
case 'a':
archtodir++;
archdirname = optarg;
break;
+ case 'c':
+ if (!parse_compression_type(optarg, &compress_type_override)) {
+ warnx("Unrecognized compression method '%s'.", optarg);
+ usage();
+ }
+ compress_type_set = true;
+ break;
case 'd':
destdir = optarg;
break;
@@ -793,10 +857,26 @@ parse_doption(const char *doption)
static void
usage(void)
{
+ int i;
+ char *alltypes = NULL, *tmp = NULL;
+
+ for (i = 0; i < COMPRESS_TYPES; i++) {
+ if (i == COMPRESS_NONE) {
+ (void)asprintf(&tmp, "%s|legacy", compress_type[i].name);
+ } else {
+ (void)asprintf(&tmp, "%s|%s", alltypes, compress_type[i].name);
+ }
+ if (alltypes)
+ free(alltypes);
+ alltypes = tmp;
+ tmp = NULL;
+ }
fprintf(stderr,
- "usage: newsyslog [-CFNPnrsv] [-a directory] [-d directory] [-f config_file]\n"
- " [-S pidfile] [-t timefmt] [[-R tagname] file ...]\n");
+ "usage: newsyslog [-CFNPnrsv] [-a directory] [-c %s]\n"
+ " [-d directory] [-f config_file]\n"
+ " [-S pidfile] [-t timefmt] [[-R tagname] file ...]\n",
+ alltypes);
exit(1);
}
@@ -1138,6 +1218,36 @@ parse_file(FILE *cf, struct cflist *work_p, struct cflist *glob_p,
} else
add_to_queue(q, inclist);
continue;
+ } else if (strcasecmp(COMPRESS_MARKER, q) == 0) {
+ enum compress_types_enum result;
+
+ if (verbose)
+ printf("Found: %s", errline);
+ q = parse = missing_field(sob(parse + 1), errline);
+ parse = son(parse);
+ if (!*parse)
+ warnx("compress line specifies no option:\n%s",
+ errline);
+ else {
+ *parse = '\0';
+ if (parse_compression_type(q, &result)) {
+ if (compress_type_set) {
+ warnx("Ignoring compress line "
+ "option '%s', using '%s' instead",
+ q,
+ compression_type_name(compress_type_override));
+ } else {
+ if (compress_type_seen)
+ warnx("Compress type should appear before all log files:\n%s",
+ errline);
+ compress_type_override = result;
+ compress_type_set = true;
+ }
+ } else {
+ warnx("Bad compress option '%s'", q);
+ };
+ }
+ continue;
}
#define badline(msg, ...) do { \
@@ -1304,7 +1414,11 @@ no_trimat:
working->flags |= CE_GLOB;
break;
case 'j':
- working->compress = COMPRESS_BZIP2;
+ if (compress_type_override == COMPRESS_LEGACY)
+ working->compress = COMPRESS_BZIP2;
+ else
+ working->compress = compress_type_override;
+ compress_type_seen = true;
break;
case 'n':
working->flags |= CE_NOSIGNAL;
@@ -1325,13 +1439,25 @@ no_trimat:
/* Deprecated flag - keep for compatibility purposes */
break;
case 'x':
- working->compress = COMPRESS_XZ;
+ if (compress_type_override == COMPRESS_LEGACY)
+ working->compress = COMPRESS_XZ;
+ else
+ working->compress = compress_type_override;
+ compress_type_seen = true;
break;
case 'y':
- working->compress = COMPRESS_ZSTD;
+ if (compress_type_override == COMPRESS_LEGACY)
+ working->compress = COMPRESS_ZSTD;
+ else
+ working->compress = compress_type_override;
+ compress_type_seen = true;
break;
case 'z':
- working->compress = COMPRESS_GZIP;
+ if (compress_type_override == COMPRESS_LEGACY)
+ working->compress = COMPRESS_GZIP;
+ else
+ working->compress = compress_type_override;
+ compress_type_seen = true;
break;
case '-':
break;
@@ -2037,6 +2163,7 @@ do_zipwork(struct zipwork_entry *zwork)
assert(zwork->zw_conf != NULL);
assert(zwork->zw_conf->compress > COMPRESS_NONE);
assert(zwork->zw_conf->compress < COMPRESS_TYPES);
+ assert(zwork->zw_conf->compress != COMPRESS_LEGACY);
if (zwork->zw_swork != NULL && zwork->zw_swork->sw_runcmd == 0 &&
zwork->zw_swork->sw_pidok <= 0) {
@@ -2284,7 +2411,7 @@ set_swpid(struct sigwork_entry *swork, const struct conf_entry *ent)
/*
* Warn if the PID file is empty, but do not consider
* it an error. Most likely it means the process has
- * has terminated, so it should be safe to rotate any
+ * terminated, so it should be safe to rotate any
* log files that the process would have been using.
*/
if (feof(f) && enforcepid == 0) {
diff --git a/usr.sbin/newsyslog/newsyslog.conf b/usr.sbin/newsyslog/newsyslog.conf
index 80e8270935a1..d907e08fd747 100644
--- a/usr.sbin/newsyslog/newsyslog.conf
+++ b/usr.sbin/newsyslog/newsyslog.conf
@@ -1,5 +1,4 @@
# configuration file for newsyslog
-# $FreeBSD$
#
# Entries which do not specify the '/pid_file' field will cause the
# syslogd process to be signalled when that log file is rotated. This
@@ -16,21 +15,21 @@
#
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/all.log 600 7 * @T00 J
-/var/log/auth.log 600 7 1000 @0101T JC
+/var/log/auth.log 600 7 1000 @0101T JC
/var/log/console.log 600 5 1000 * J
/var/log/cron 600 3 1000 * JC
+/var/log/daemon.log 644 5 1000 @0101T JC
/var/log/daily.log 640 7 * @T00 JN
-/var/log/debug.log 600 7 1000 * JC
+/var/log/debug.log 600 7 1000 * JC
+/var/log/devd.log 644 3 1000 * JC
/var/log/init.log 644 3 1000 * J
/var/log/kerberos.log 600 7 1000 * J
/var/log/maillog 640 7 * @T00 JC
/var/log/messages 644 5 1000 @0101T JC
/var/log/monthly.log 640 12 * $M1D0 JN
-/var/log/devd.log 644 3 1000 * JC
/var/log/security 600 10 1000 * JC
/var/log/utx.log 644 3 * @01T05 B
/var/log/weekly.log 640 5 * $W6D0 JN
-/var/log/daemon.log 644 5 1000 @0101T JC
<include> /etc/newsyslog.conf.d/[!.]*.conf
<include> /usr/local/etc/newsyslog.conf.d/[!.]*.conf
diff --git a/usr.sbin/newsyslog/newsyslog.conf.5 b/usr.sbin/newsyslog/newsyslog.conf.5
index cf1a36305b00..120c5a0cb7cc 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.5
+++ b/usr.sbin/newsyslog/newsyslog.conf.5
@@ -4,9 +4,6 @@
.\"
.\" This file contains changes from the Open Software Foundation.
.\"
-.\" from: @(#)newsyslog.8
-.\" $FreeBSD$
-.\"
.\" Copyright 1988, 1989 by the Massachusetts Institute of Technology
.\"
.\" Permission to use, copy, modify, and distribute this software
@@ -21,7 +18,7 @@
.\" the suitability of this software for any purpose. It is
.\" provided "as is" without express or implied warranty.
.\"
-.Dd February 26, 2021
+.Dd December 25, 2023
.Dt NEWSYSLOG.CONF 5
.Os
.Sh NAME
@@ -70,11 +67,24 @@ The fields of the configuration file are as follows:
.Bl -tag -width indent
.It Ar logfile_name
Name of the system log file to be archived,
-or one of the literal strings
-.Dq Aq Li default ,
+or one of the special strings
+.Dq Li <compress> ,
+.Dq Li <default> ,
or
-.Dq Aq Li include .
-The special default entry will only be used if a log file
+.Dq Li <include> .
+The <compress> entry,
+which should be placed at the beginning of the
+.Nm
+configuration file,
+sets the global compress method.
+This method is applied when a log file is flagged as
+compressible,
+which has the same effect of passing a compress method to the
+.Fl c
+option on the
+.Xr newsyslog 8
+command line.
+The special <default> entry will only be used if a log file
name is given as a command line argument to
.Xr newsyslog 8 ,
and if that log file name is not matched by any other
@@ -311,8 +321,11 @@ for details on syntax and matching rules.
.It Cm J
indicates that
.Xr newsyslog 8
-should attempt to save disk space by compressing the rotated
-log file using
+should consider the rotated log file as compressible.
+In legacy mode,
+this also tells
+.Xr newsyslog 8
+to use
.Xr bzip2 1 .
.It Cm N
indicates that there is no process which needs to be signaled
@@ -340,20 +353,29 @@ be a negative value to distinguish it from a process ID.
.It Cm X
indicates that
.Xr newsyslog 8
-should attempt to save disk space by compressing the rotated
-log file using
+should consider the rotated log file as compressible.
+In legacy mode,
+this also tells
+.Xr newsyslog 8
+to use
.Xr xz 1 .
.It Cm Y
indicates that
.Xr newsyslog 8
-should attempt to save disk space by compressing the rotated
-log file using
+should consider the rotated log file as compressible.
+In legacy mode,
+this also tells
+.Xr newsyslog 8
+to use
.Xr zstd 1 .
.It Cm Z
indicates that
.Xr newsyslog 8
-should attempt to save disk space by compressing the rotated
-log file using
+should consider the rotated log file as compressible.
+In legacy mode,
+this also tells
+.Xr newsyslog 8
+to use
.Xr gzip 1 .
.It Fl
a minus sign will not cause any special processing, but it
diff --git a/usr.sbin/newsyslog/newsyslog.conf.d/Makefile b/usr.sbin/newsyslog/newsyslog.conf.d/Makefile
index 1c8980c2e383..4b2dff13723b 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.d/Makefile
+++ b/usr.sbin/newsyslog/newsyslog.conf.d/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/newsyslog/newsyslog.conf.d/Makefile.depend b/usr.sbin/newsyslog/newsyslog.conf.d/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.d/Makefile.depend
+++ b/usr.sbin/newsyslog/newsyslog.conf.d/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/newsyslog/newsyslog.conf.d/amd.conf b/usr.sbin/newsyslog/newsyslog.conf.d/amd.conf
index 329652dd5135..6b1abc706b4a 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.d/amd.conf
+++ b/usr.sbin/newsyslog/newsyslog.conf.d/amd.conf
@@ -1,2 +1 @@
-# $FreeBSD$
/var/log/amd.log 644 7 1000 * J
diff --git a/usr.sbin/newsyslog/newsyslog.conf.d/ftp.conf b/usr.sbin/newsyslog/newsyslog.conf.d/ftp.conf
index c12e24d7066f..f935a9a20f6c 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.d/ftp.conf
+++ b/usr.sbin/newsyslog/newsyslog.conf.d/ftp.conf
@@ -1,2 +1 @@
-# $FreeBSD$
/var/log/xferlog 600 7 1000 * JC
diff --git a/usr.sbin/newsyslog/newsyslog.conf.d/lpr.conf b/usr.sbin/newsyslog/newsyslog.conf.d/lpr.conf
index 5febb309c6ec..a797cd6b7a66 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.d/lpr.conf
+++ b/usr.sbin/newsyslog/newsyslog.conf.d/lpr.conf
@@ -1,2 +1 @@
-# $FreeBSD$
/var/log/lpd-errs 644 7 1000 * JC
diff --git a/usr.sbin/newsyslog/newsyslog.conf.d/opensm.conf b/usr.sbin/newsyslog/newsyslog.conf.d/opensm.conf
index db7113f25afd..5c7d1c74fdbf 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.d/opensm.conf
+++ b/usr.sbin/newsyslog/newsyslog.conf.d/opensm.conf
@@ -1,3 +1,2 @@
-# $FreeBSD$
/var/log/opensm.log 600 7 1000 * J /var/run/opensm.pid 30
diff --git a/usr.sbin/newsyslog/newsyslog.conf.d/pf.conf b/usr.sbin/newsyslog/newsyslog.conf.d/pf.conf
index 7c41c816c1ff..0fe6186f24a7 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.d/pf.conf
+++ b/usr.sbin/newsyslog/newsyslog.conf.d/pf.conf
@@ -1,2 +1 @@
-# $FreeBSD$
/var/log/pflog 600 3 1000 * JB /var/run/pflogd.pid
diff --git a/usr.sbin/newsyslog/newsyslog.conf.d/ppp.conf b/usr.sbin/newsyslog/newsyslog.conf.d/ppp.conf
index 198579dae27a..02eaeccfec67 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.d/ppp.conf
+++ b/usr.sbin/newsyslog/newsyslog.conf.d/ppp.conf
@@ -1,2 +1 @@
-# $FreeBSD$
/var/log/ppp.log root:network 640 3 1000 * JC
diff --git a/usr.sbin/newsyslog/newsyslog.conf.d/sendmail.conf b/usr.sbin/newsyslog/newsyslog.conf.d/sendmail.conf
index 5cb59c4e8c18..9553cd02eafb 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.d/sendmail.conf
+++ b/usr.sbin/newsyslog/newsyslog.conf.d/sendmail.conf
@@ -1,2 +1 @@
-# $FreeBSD$
/var/log/sendmail.st 640 10 * 168 BN
diff --git a/usr.sbin/newsyslog/pathnames.h b/usr.sbin/newsyslog/pathnames.h
index 04c3086a48ef..9a833e091dbd 100644
--- a/usr.sbin/newsyslog/pathnames.h
+++ b/usr.sbin/newsyslog/pathnames.h
@@ -18,8 +18,6 @@ M.I.T. and the M.I.T. S.I.P.B. make no representations about
the suitability of this software for any purpose. It is
provided "as is" without express or implied warranty.
- $FreeBSD$
-
*/
#define _PATH_CONF "/etc/newsyslog.conf"
diff --git a/usr.sbin/newsyslog/ptimes.c b/usr.sbin/newsyslog/ptimes.c
index d54ca1d40050..792ad3e1727d 100644
--- a/usr.sbin/newsyslog/ptimes.c
+++ b/usr.sbin/newsyslog/ptimes.c
@@ -41,8 +41,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
diff --git a/usr.sbin/newsyslog/tests/Makefile b/usr.sbin/newsyslog/tests/Makefile
index 802a44c01012..3adc1eec5d42 100644
--- a/usr.sbin/newsyslog/tests/Makefile
+++ b/usr.sbin/newsyslog/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
TAP_TESTS_SH= legacy_test
diff --git a/usr.sbin/newsyslog/tests/Makefile.depend b/usr.sbin/newsyslog/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/newsyslog/tests/Makefile.depend
+++ b/usr.sbin/newsyslog/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/newsyslog/tests/legacy_test.sh b/usr.sbin/newsyslog/tests/legacy_test.sh
index a16059b6fa9c..5aecdeacd10a 100644
--- a/usr.sbin/newsyslog/tests/legacy_test.sh
+++ b/usr.sbin/newsyslog/tests/legacy_test.sh
@@ -1,7 +1,5 @@
#!/bin/sh
-# $FreeBSD$
-
# A regular expression matching the format of an RFC-5424 log line header,
# including the timestamp up through the seconds indicator; it does not include
# the (optional) timezone offset.
diff --git a/usr.sbin/nfscbd/Makefile b/usr.sbin/nfscbd/Makefile
index 668914a88154..5703601b9ac3 100644
--- a/usr.sbin/nfscbd/Makefile
+++ b/usr.sbin/nfscbd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= nfs
diff --git a/usr.sbin/nfscbd/Makefile.depend b/usr.sbin/nfscbd/Makefile.depend
index 74a3ee19f459..e27add9121d0 100644
--- a/usr.sbin/nfscbd/Makefile.depend
+++ b/usr.sbin/nfscbd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/rpc \
include/xlocale \
diff --git a/usr.sbin/nfscbd/nfscbd.8 b/usr.sbin/nfscbd/nfscbd.8
index 958e53466b99..64bf32fc6f23 100644
--- a/usr.sbin/nfscbd/nfscbd.8
+++ b/usr.sbin/nfscbd/nfscbd.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 25, 2009
.Dt NFSCBD 8
.Os
diff --git a/usr.sbin/nfscbd/nfscbd.c b/usr.sbin/nfscbd/nfscbd.c
index 3731575b4822..6b0b938973f2 100644
--- a/usr.sbin/nfscbd/nfscbd.c
+++ b/usr.sbin/nfscbd/nfscbd.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/linker.h>
diff --git a/usr.sbin/nfsd/Makefile b/usr.sbin/nfsd/Makefile
index e9d9b31fd168..424d35872dad 100644
--- a/usr.sbin/nfsd/Makefile
+++ b/usr.sbin/nfsd/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
PACKAGE= nfs
diff --git a/usr.sbin/nfsd/Makefile.depend b/usr.sbin/nfsd/Makefile.depend
index faed4b4cc2aa..732a025c9552 100644
--- a/usr.sbin/nfsd/Makefile.depend
+++ b/usr.sbin/nfsd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
diff --git a/usr.sbin/nfsd/nfsd.8 b/usr.sbin/nfsd/nfsd.8
index c8a5fea4e6a2..9051df4bcb31 100644
--- a/usr.sbin/nfsd/nfsd.8
+++ b/usr.sbin/nfsd/nfsd.8
@@ -25,10 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)nfsd.8 8.4 (Berkeley) 3/29/95
-.\" $FreeBSD$
-.\"
-.Dd December 20, 2019
+.Dd March 16, 2024
.Dt NFSD 8
.Os
.Sh NAME
@@ -56,6 +53,22 @@ must be running for a machine to operate as a server.
Unless otherwise specified, eight servers per CPU for UDP transport are
started.
.Pp
+When
+.Nm
+is run in an appropriately configured vnet jail, the server is restricted
+to TCP transport and no pNFS service.
+Therefore, the
+.Fl t
+option must be specified and none of the
+.Fl u ,
+.Fl p
+and
+.Fl m
+options can be specified when run in a vnet jail.
+See
+.Xr jail 8
+for more information.
+.Pp
The following options are available:
.Bl -tag -width Ds
.It Fl r
@@ -307,6 +320,7 @@ just do a
.Xr stablerestart 5 ,
.Xr gssd 8 ,
.Xr ipfw 8 ,
+.Xr jail 8 ,
.Xr mountd 8 ,
.Xr nfsiod 8 ,
.Xr nfsrevoke 8 ,
@@ -339,3 +353,25 @@ to be set to one on the MDS as a workaround.
Linux 5.n kernels appear to have been patched such that this
.Xr sysctl 8
does not need to be set.
+.Pp
+For NFSv4.2, a Copy operation can take a long time to complete.
+If there is a concurrent ExchangeID or DelegReturn operation
+which requires the exclusive lock on all NFSv4 state, this can
+result in a
+.Dq stall
+of the
+.Nm
+server.
+If your storage is on ZFS without block cloning enabled,
+setting the
+.Xr sysctl 8
+.Va vfs.zfs.dmu_offset_next_sync
+to 0 can often avoid this problem.
+It is also possible to set the
+.Xr sysctl 8
+.Va vfs.nfsd.maxcopyrange
+to 10-100 megabytes to try and reduce Copy operation times.
+As a last resort, setting
+.Xr sysctl 8
+.Va vfs.nfsd.maxcopyrange
+to 0 disables the Copy operation.
diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c
index 0222d23f2312..563a36983547 100644
--- a/usr.sbin/nfsd/nfsd.c
+++ b/usr.sbin/nfsd/nfsd.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)nfsd.c 8.9 (Berkeley) 3/29/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/syslog.h>
#include <sys/wait.h>
@@ -170,8 +156,8 @@ main(int argc, char **argv)
int udpflag, ecode, error, s;
int bindhostc, bindanyflag, rpcbreg, rpcbregcnt;
int nfssvc_addsock;
- int longindex = 0;
- size_t nfs_minvers_size;
+ int jailed, longindex = 0;
+ size_t jailed_size, nfs_minvers_size;
const char *lopt;
char **bindhost = NULL;
pid_t pid;
@@ -465,7 +451,21 @@ main(int argc, char **argv)
/* This system call will fail for old kernels, but that's ok. */
nfssvc(NFSSVC_BACKUPSTABLE, NULL);
if (nfssvc(NFSSVC_STABLERESTART, (caddr_t)&stablefd) < 0) {
- syslog(LOG_ERR, "Can't read stable storage file: %m\n");
+ if (errno == EPERM) {
+ jailed = 0;
+ jailed_size = sizeof(jailed);
+ sysctlbyname("security.jail.jailed", &jailed,
+ &jailed_size, NULL, 0);
+ if (jailed != 0)
+ syslog(LOG_ERR, "nfssvc stablerestart failed: "
+ "allow.nfsd might not be configured");
+ else
+ syslog(LOG_ERR, "nfssvc stablerestart failed");
+ } else if (errno == ENXIO)
+ syslog(LOG_ERR, "nfssvc stablerestart failed: is nfsd "
+ "already running?");
+ else
+ syslog(LOG_ERR, "Can't read stable storage file: %m\n");
exit(1);
}
nfssvc_addsock = NFSSVC_NFSDADDSOCK;
diff --git a/usr.sbin/nfsd/nfsv4.4 b/usr.sbin/nfsd/nfsv4.4
index 8460ed174ea6..e96e507e23ad 100644
--- a/usr.sbin/nfsd/nfsv4.4
+++ b/usr.sbin/nfsd/nfsv4.4
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd December 20, 2019
+.Dd January 8, 2024
.Dt NFSV4 4
.Os
.Sh NAME
@@ -156,8 +154,8 @@ either client or server, this daemon must be running.
The form where the numbers are in the strings can only be used for AUTH_SYS.
To configure your systems this way, the
.Xr nfsuserd 8
-daemon does not need to be running on the server, but the following sysctls need to be
-set to 1 on the server.
+daemon does not need to be running on the server, but the following sysctls
+need to be set to 1 on the server.
.sp
.Bd -literal -offset indent -compact
vfs.nfs.enable_uidtostring
@@ -179,8 +177,8 @@ report a lot of ``nobody'' and ``nogroup'' ownerships.
.Pp
Although uid/gid numbers are no longer used in the
.Nm
-protocol except optionally in the above strings, they will still be in the RPC authentication fields when
-using AUTH_SYS (sec=sys), which is the default.
+protocol except optionally in the above strings, they will still be in the RPC
+authentication fields when using AUTH_SYS (sec=sys), which is the default.
As such, in this case both the user/group name and number spaces must
be consistent between the client and server.
.Pp
@@ -210,6 +208,14 @@ if the server is using the ``<user>@<domain>'' form of user/group strings or
is using the ``-manage-gids'' option for
.Xr nfsuserd 8 .
.Pp
+In addition, you can set:
+.sp
+.Bd -literal -offset indent -compact
+nfsv4_server_only="YES"
+.Ed
+.sp
+to disable support for NFSv2 and NFSv3.
+.Pp
You will also need to add at least one ``V4:'' line to the
.Xr exports 5
file for
@@ -300,7 +306,8 @@ are set in
Without a functioning callback path, a server will never issue Delegations
to a client.
.sp
-For NFSv4.0, by default, the callback address will be set to the IP address acquired via
+For NFSv4.0, by default, the callback address will be set to the IP address
+acquired via
.Fn rtalloc
in the kernel and port# 7745.
To override the default port#, a command line option for
@@ -318,9 +325,9 @@ N.N.N.N.N.N
where the first 4 Ns are the host IP address and the last two are the
port# in network byte order (all decimal #s in the range 0-255).
.Pp
-For NFSv4.1 and NFSv4.2, the callback path (called a backchannel) uses the same TCP connection as the mount,
-so none of the above applies and should work through gateways without
-any issues.
+For NFSv4.1 and NFSv4.2, the callback path (called a backchannel) uses the
+same TCP connection as the mount, so none of the above applies and should
+work through gateways without any issues.
.Pp
To build a kernel with the client that supports
.Nm
@@ -348,7 +355,7 @@ It occurs when an nfsd thread tries to do an NFSv4
.Fn VOP_RECLAIM
/ Close RPC as part of acquiring a new vnode.
If all other nfsd threads are blocked waiting for lock(s) held by this nfsd
-thread, then there isn't an nfsd thread to service the Close RPC.
+thread, then there is no nfsd thread to service the Close RPC.
.Sh FILES
.Bl -tag -width /var/db/nfs-stablerestart.bak -compact
.It Pa /var/db/nfs-stablerestart
diff --git a/usr.sbin/nfsd/pnfs.4 b/usr.sbin/nfsd/pnfs.4
index 94fe02536ba1..babd221a6d5a 100644
--- a/usr.sbin/nfsd/pnfs.4
+++ b/usr.sbin/nfsd/pnfs.4
@@ -21,8 +21,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 20, 2019
.Dt PNFS 4
.Os
@@ -117,7 +115,7 @@ For a non-mirrored configuration, the
server will issue File Layout
layouts by default.
However that default can be set to the Flexible File Layout by setting the
-.Xr sysctl 1
+.Xr sysctl 8
sysctl
.Dq vfs.nfsd.default_flexfile
to one.
@@ -142,7 +140,7 @@ on the MDS server (not via an NFS mount), the files will all be of size zero.
Each of these files will also have two extended attributes in the system
attribute name space:
.Bd -literal -offset indent
-pnfsd.dsfile - This extended attrbute stores the information that the
+pnfsd.dsfile - This extended attribute stores the information that the
MDS needs to find the data file on a DS(s) for this file.
pnfsd.dsattr - This extended attribute stores the Size, AccessTime,
ModifyTime, Change and SpaceUsed attributes for the file.
diff --git a/usr.sbin/nfsd/pnfsserver.4 b/usr.sbin/nfsd/pnfsserver.4
index 67a138099c37..7a2ddc4e85c0 100644
--- a/usr.sbin/nfsd/pnfsserver.4
+++ b/usr.sbin/nfsd/pnfsserver.4
@@ -21,8 +21,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 20, 2019
.Dt PNFSSERVER 4
.Os
diff --git a/usr.sbin/nfsd/stablerestart.5 b/usr.sbin/nfsd/stablerestart.5
index 0f921a07ca49..0d93b0487f09 100644
--- a/usr.sbin/nfsd/stablerestart.5
+++ b/usr.sbin/nfsd/stablerestart.5
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 10, 2011
.Dt STABLERESTART 5
.Os
diff --git a/usr.sbin/nfsdumpstate/Makefile b/usr.sbin/nfsdumpstate/Makefile
index 49f14d7ba4ab..c55425965630 100644
--- a/usr.sbin/nfsdumpstate/Makefile
+++ b/usr.sbin/nfsdumpstate/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/nfsdumpstate/Makefile.depend b/usr.sbin/nfsdumpstate/Makefile.depend
index d5ed563ecfc8..344a5d0e9310 100644
--- a/usr.sbin/nfsdumpstate/Makefile.depend
+++ b/usr.sbin/nfsdumpstate/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/nfsdumpstate/nfsdumpstate.8 b/usr.sbin/nfsdumpstate/nfsdumpstate.8
index 1a9f11014e17..a9f4e814be81 100644
--- a/usr.sbin/nfsdumpstate/nfsdumpstate.8
+++ b/usr.sbin/nfsdumpstate/nfsdumpstate.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 25, 2009
.Dt NFSDUMPSTATE 8
.Os
diff --git a/usr.sbin/nfsdumpstate/nfsdumpstate.c b/usr.sbin/nfsdumpstate/nfsdumpstate.c
index c7e086655f79..70cfa4ac5420 100644
--- a/usr.sbin/nfsdumpstate/nfsdumpstate.c
+++ b/usr.sbin/nfsdumpstate/nfsdumpstate.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/linker.h>
#include <sys/module.h>
@@ -56,7 +53,7 @@ __FBSDID("$FreeBSD$");
static void dump_lockstate(char *);
static void dump_openstate(void);
-static void usage(void);
+static void usage(void) __dead2;
static char *open_flags(uint32_t);
static char *deleg_flags(uint32_t);
static char *lock_flags(uint32_t);
diff --git a/usr.sbin/nfsrevoke/Makefile b/usr.sbin/nfsrevoke/Makefile
index 3583d5e8a67a..f4c1146e2084 100644
--- a/usr.sbin/nfsrevoke/Makefile
+++ b/usr.sbin/nfsrevoke/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= nfs
diff --git a/usr.sbin/nfsrevoke/Makefile.depend b/usr.sbin/nfsrevoke/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/nfsrevoke/Makefile.depend
+++ b/usr.sbin/nfsrevoke/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/nfsrevoke/nfsrevoke.8 b/usr.sbin/nfsrevoke/nfsrevoke.8
index 00a8915e361b..811d4ba828a8 100644
--- a/usr.sbin/nfsrevoke/nfsrevoke.8
+++ b/usr.sbin/nfsrevoke/nfsrevoke.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 25, 2009
.Dt NFSREVOKE 8
.Os
diff --git a/usr.sbin/nfsrevoke/nfsrevoke.c b/usr.sbin/nfsrevoke/nfsrevoke.c
index 85eb48bfa8fb..a914555e4ec1 100644
--- a/usr.sbin/nfsrevoke/nfsrevoke.c
+++ b/usr.sbin/nfsrevoke/nfsrevoke.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/linker.h>
#include <sys/module.h>
@@ -57,7 +54,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char **argv)
diff --git a/usr.sbin/nfsuserd/Makefile b/usr.sbin/nfsuserd/Makefile
index c8a3553191a7..be27b4d044c1 100644
--- a/usr.sbin/nfsuserd/Makefile
+++ b/usr.sbin/nfsuserd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/nfsuserd/Makefile.depend b/usr.sbin/nfsuserd/Makefile.depend
index 74a3ee19f459..90cdaad976de 100644
--- a/usr.sbin/nfsuserd/Makefile.depend
+++ b/usr.sbin/nfsuserd/Makefile.depend
@@ -1,9 +1,8 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
+ include/arpa \
include/rpc \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/nfsuserd/nfsuserd.8 b/usr.sbin/nfsuserd/nfsuserd.8
index 06b116a45387..61384a39b641 100644
--- a/usr.sbin/nfsuserd/nfsuserd.8
+++ b/usr.sbin/nfsuserd/nfsuserd.8
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd April 6, 2019
+.Dd April 22, 2023
.Dt NFSUSERD 8
.Os
.Sh NAME
@@ -53,13 +51,17 @@ owner and owner_group strings.
It also provides support for manage-gids and must be running on the server if
this is being used for any version of NFS.
.Pp
-Upon startup, it loads the machines DNS domain name, plus timeout and cache size
+Upon startup, it loads the machine's DNS domain name, plus timeout and cache size
limit into the kernel.
It then preloads the cache with group and user information, up to the cache size
-limit and forks off N children (default 4), that service requests from the kernel
+limit and forks off
+.Ar num_servers
+(default 4) children which are the servers
+that service requests from the kernel
for cache misses.
-The master server is there for the sole purpose of killing off the slaves.
-To stop the nfsuserd, send a SIGUSR1 to the master server.
+The master is there for the sole purpose of terminating the
+servers.
+To stop the nfsuserd, send a SIGUSR1 to the master.
.Pp
The following options are available:
.Bl -tag -width Ds
@@ -103,7 +105,7 @@ Specifies how many servers to create (max 20).
The default of 4 may be sufficient.
You should run enough servers, so that
.Xr ps 1
-shows almost no running time for one or two of the slaves after the system
+shows almost no running time for one or two of the servers after the system
has been running for a long period.
Running too few will have a major performance impact, whereas running too many
will only tie up some resources, such as a process table entry and swap space.
diff --git a/usr.sbin/nfsuserd/nfsuserd.c b/usr.sbin/nfsuserd/nfsuserd.c
index 1e99f806637d..29d816934600 100644
--- a/usr.sbin/nfsuserd/nfsuserd.c
+++ b/usr.sbin/nfsuserd/nfsuserd.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/linker.h>
@@ -35,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/ucred.h>
#include <sys/vnode.h>
@@ -96,9 +94,9 @@ u_char *defaultuser = "nobody";
uid_t defaultuid = 65534;
u_char *defaultgroup = "nogroup";
gid_t defaultgid = 65533;
-int verbose = 0, im_a_slave = 0, nfsuserdcnt = -1, forcestart = 0;
+int verbose = 0, im_a_server = 0, nfsuserdcnt = -1, forcestart = 0;
int defusertimeout = DEFUSERTIMEOUT, manage_gids = 0;
-pid_t slaves[MAXNFSUSERD];
+pid_t servers[MAXNFSUSERD];
static struct sockaddr_storage fromip;
#ifdef INET6
static struct in6_addr in6loopback = IN6ADDR_LOOPBACK_INIT;
@@ -127,7 +125,8 @@ main(int argc, char *argv[])
#ifdef INET6
struct sockaddr_in6 *sin6;
#endif
- int s;
+ int jailed, s;
+ size_t jailed_size;
if (modfind("nfscommon") < 0) {
/* Not present in kernel, try loading it */
@@ -290,7 +289,7 @@ main(int argc, char *argv[])
dnsname, nid.nid_usermax, nid.nid_usertimeout);
for (i = 0; i < nfsuserdcnt; i++)
- slaves[i] = (pid_t)-1;
+ servers[i] = (pid_t)-1;
nargs.nuserd_family = fromip.ss_family;
/*
@@ -326,10 +325,19 @@ main(int argc, char *argv[])
#else
if (nfssvc(NFSSVC_NFSUSERDPORT | NFSSVC_NEWSTRUCT, &nargs) < 0) {
if (errno == EPERM) {
- fprintf(stderr,
- "Can't start nfsuserd when already running");
- fprintf(stderr,
- " If not running, use the -force option.\n");
+ jailed = 0;
+ jailed_size = sizeof(jailed);
+ sysctlbyname("security.jail.jailed", &jailed,
+ &jailed_size, NULL, 0);
+ if (jailed != 0) {
+ fprintf(stderr, "Cannot start nfsuserd. "
+ "allow.nfsd might not be configured\n");
+ } else {
+ fprintf(stderr, "Cannot start nfsuserd "
+ "when already running.");
+ fprintf(stderr, " If not running, "
+ "use the -force option.\n");
+ }
} else {
fprintf(stderr, "Can't do nfssvc() to add port\n");
}
@@ -444,7 +452,7 @@ main(int argc, char *argv[])
exit(0);
#endif
/*
- * Temporarily block SIGUSR1 and SIGCHLD, so slaves[] can't
+ * Temporarily block SIGUSR1 and SIGCHLD, so servers[] can't
* end up bogus.
*/
sigemptyset(&signew);
@@ -463,14 +471,14 @@ main(int argc, char *argv[])
openlog("nfsuserd:", LOG_PID, LOG_DAEMON);
/*
- * Fork off the slave daemons that do the work. All the master
- * does is kill them off and cleanup.
+ * Fork off the server daemons that do the work. All the master
+ * does is terminate them and cleanup.
*/
for (i = 0; i < nfsuserdcnt; i++) {
- slaves[i] = fork();
- if (slaves[i] == 0) {
- im_a_slave = 1;
- setproctitle("slave");
+ servers[i] = fork();
+ if (servers[i] == 0) {
+ im_a_server = 1;
+ setproctitle("server");
sigemptyset(&signew);
sigaddset(&signew, SIGUSR1);
sigprocmask(SIG_UNBLOCK, &signew, NULL);
@@ -481,7 +489,7 @@ main(int argc, char *argv[])
svc_run();
syslog(LOG_ERR, "nfsuserd died: %m");
exit(1);
- } else if (slaves[i] < 0) {
+ } else if (servers[i] < 0) {
syslog(LOG_ERR, "fork: %m");
}
}
@@ -800,7 +808,7 @@ cleanup_term(int signo __unused)
{
int i, cnt;
- if (im_a_slave)
+ if (im_a_server)
exit(0);
/*
@@ -809,9 +817,9 @@ cleanup_term(int signo __unused)
*/
cnt = 0;
for (i = 0; i < nfsuserdcnt; i++) {
- if (slaves[i] != (pid_t)-1) {
+ if (servers[i] != (pid_t)-1) {
cnt++;
- kill(slaves[i], SIGUSR1);
+ kill(servers[i], SIGUSR1);
}
}
diff --git a/usr.sbin/ngctl/Makefile b/usr.sbin/ngctl/Makefile
index a4831523c3fc..72a5ccaa96d7 100644
--- a/usr.sbin/ngctl/Makefile
+++ b/usr.sbin/ngctl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
# $Whistle: Makefile,v 1.3 1999/01/16 00:10:11 archie Exp $
.include <src.opts.mk>
diff --git a/usr.sbin/ngctl/Makefile.depend b/usr.sbin/ngctl/Makefile.depend
index 6f7dfbccc4f0..5ac03b898d36 100644
--- a/usr.sbin/ngctl/Makefile.depend
+++ b/usr.sbin/ngctl/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
@@ -9,7 +8,6 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libnetgraph \
lib/libthr \
- lib/ncurses/ncursesw \
.include <dirdeps.mk>
diff --git a/usr.sbin/ngctl/Makefile.depend.options b/usr.sbin/ngctl/Makefile.depend.options
index 67c3a5d932ef..7ed4c9792550 100644
--- a/usr.sbin/ngctl/Makefile.depend.options
+++ b/usr.sbin/ngctl/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= LIBTHR
diff --git a/usr.sbin/ngctl/config.c b/usr.sbin/ngctl/config.c
index 9b1a2751d136..261bc950f570 100644
--- a/usr.sbin/ngctl/config.c
+++ b/usr.sbin/ngctl/config.c
@@ -32,8 +32,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/ngctl/connect.c b/usr.sbin/ngctl/connect.c
index cd5307e499c2..7f538e0a442d 100644
--- a/usr.sbin/ngctl/connect.c
+++ b/usr.sbin/ngctl/connect.c
@@ -33,8 +33,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/ngctl/debug.c b/usr.sbin/ngctl/debug.c
index d64e32d7f4cf..bbc329acdcd2 100644
--- a/usr.sbin/ngctl/debug.c
+++ b/usr.sbin/ngctl/debug.c
@@ -33,8 +33,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <netgraph.h>
diff --git a/usr.sbin/ngctl/dot.c b/usr.sbin/ngctl/dot.c
index c9d4b75f7c92..95132a5d0785 100644
--- a/usr.sbin/ngctl/dot.c
+++ b/usr.sbin/ngctl/dot.c
@@ -35,8 +35,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/ngctl/list.c b/usr.sbin/ngctl/list.c
index ae64dea88000..d13de1c4c57f 100644
--- a/usr.sbin/ngctl/list.c
+++ b/usr.sbin/ngctl/list.c
@@ -33,8 +33,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/ngctl/main.c b/usr.sbin/ngctl/main.c
index 4b1cdabdb8e9..7c79e67d8275 100644
--- a/usr.sbin/ngctl/main.c
+++ b/usr.sbin/ngctl/main.c
@@ -37,9 +37,6 @@
* $Whistle: main.c,v 1.12 1999/11/29 19:17:46 archie Exp $
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/select.h>
diff --git a/usr.sbin/ngctl/mkpeer.c b/usr.sbin/ngctl/mkpeer.c
index 1c6896b1d18c..b16260a7cce1 100644
--- a/usr.sbin/ngctl/mkpeer.c
+++ b/usr.sbin/ngctl/mkpeer.c
@@ -33,8 +33,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/ngctl/msg.c b/usr.sbin/ngctl/msg.c
index 38f0db704927..2cc733408380 100644
--- a/usr.sbin/ngctl/msg.c
+++ b/usr.sbin/ngctl/msg.c
@@ -38,8 +38,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <netgraph.h>
#include <stdio.h>
diff --git a/usr.sbin/ngctl/name.c b/usr.sbin/ngctl/name.c
index 7149d35dbc88..79ddcad2f0c7 100644
--- a/usr.sbin/ngctl/name.c
+++ b/usr.sbin/ngctl/name.c
@@ -33,8 +33,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/ngctl/ngctl.8 b/usr.sbin/ngctl/ngctl.8
index 8ba9f5d2854d..2225c836674a 100644
--- a/usr.sbin/ngctl/ngctl.8
+++ b/usr.sbin/ngctl/ngctl.8
@@ -29,8 +29,6 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
.\" OF SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
.\" $Whistle: ngctl.8,v 1.6 1999/01/20 03:19:44 archie Exp $
.\"
.Dd January 19, 1999
diff --git a/usr.sbin/ngctl/ngctl.h b/usr.sbin/ngctl/ngctl.h
index 4d8c2adb7691..782e77e36b85 100644
--- a/usr.sbin/ngctl/ngctl.h
+++ b/usr.sbin/ngctl/ngctl.h
@@ -33,8 +33,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#define MAX_CMD_ALIAS 8
diff --git a/usr.sbin/ngctl/rmhook.c b/usr.sbin/ngctl/rmhook.c
index 9a47a9d66fdf..5591d39cb078 100644
--- a/usr.sbin/ngctl/rmhook.c
+++ b/usr.sbin/ngctl/rmhook.c
@@ -33,8 +33,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/ngctl/show.c b/usr.sbin/ngctl/show.c
index 26eea0468273..35d1aa2e5192 100644
--- a/usr.sbin/ngctl/show.c
+++ b/usr.sbin/ngctl/show.c
@@ -33,8 +33,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/ngctl/shutdown.c b/usr.sbin/ngctl/shutdown.c
index b06beb5ca0ff..fd38b9dc152b 100644
--- a/usr.sbin/ngctl/shutdown.c
+++ b/usr.sbin/ngctl/shutdown.c
@@ -33,8 +33,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/ngctl/status.c b/usr.sbin/ngctl/status.c
index 7827c631513d..10007255d551 100644
--- a/usr.sbin/ngctl/status.c
+++ b/usr.sbin/ngctl/status.c
@@ -33,8 +33,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/ngctl/types.c b/usr.sbin/ngctl/types.c
index 5ed4b53d00ea..555960a59c02 100644
--- a/usr.sbin/ngctl/types.c
+++ b/usr.sbin/ngctl/types.c
@@ -33,8 +33,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/ngctl/write.c b/usr.sbin/ngctl/write.c
index 4114211705c6..1e86963fb39c 100644
--- a/usr.sbin/ngctl/write.c
+++ b/usr.sbin/ngctl/write.c
@@ -29,8 +29,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ARCHIE L. COBBS IS ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.sbin/nghook/Makefile b/usr.sbin/nghook/Makefile
index 8a63d8238e17..ea3db8641298 100644
--- a/usr.sbin/nghook/Makefile
+++ b/usr.sbin/nghook/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
# $Whistle: Makefile,v 1.4 1999/01/16 04:44:33 archie Exp $
PROG= nghook
diff --git a/usr.sbin/nghook/Makefile.depend b/usr.sbin/nghook/Makefile.depend
index 3f4cb50e1709..208c47654297 100644
--- a/usr.sbin/nghook/Makefile.depend
+++ b/usr.sbin/nghook/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/nghook/main.c b/usr.sbin/nghook/main.c
index 700ca5e1a59d..cee8bf481df4 100644
--- a/usr.sbin/nghook/main.c
+++ b/usr.sbin/nghook/main.c
@@ -37,8 +37,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/nghook/nghook.8 b/usr.sbin/nghook/nghook.8
index 651a6fad1bc0..f51e8ef84044 100644
--- a/usr.sbin/nghook/nghook.8
+++ b/usr.sbin/nghook/nghook.8
@@ -29,8 +29,6 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
.\" OF SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
.\" $Whistle: nghook.8,v 1.4 1999/01/20 03:19:45 archie Exp $
.\"
.Dd October 24, 2003
diff --git a/usr.sbin/nmtree/Makefile b/usr.sbin/nmtree/Makefile
index 19a4bd9a1516..45610b0b2965 100644
--- a/usr.sbin/nmtree/Makefile
+++ b/usr.sbin/nmtree/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/nmtree/Makefile.depend b/usr.sbin/nmtree/Makefile.depend
index 4e01fee15c05..7b46d62ef663 100644
--- a/usr.sbin/nmtree/Makefile.depend
+++ b/usr.sbin/nmtree/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/nmtree/Makefile.depend.host b/usr.sbin/nmtree/Makefile.depend.host
new file mode 100644
index 000000000000..0c28ef988613
--- /dev/null
+++ b/usr.sbin/nmtree/Makefile.depend.host
@@ -0,0 +1,12 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ lib/libmd \
+ lib/libnetbsd \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/nmtree/mtree.5 b/usr.sbin/nmtree/mtree.5
index 597c984ab8e3..a4157c1d7af7 100644
--- a/usr.sbin/nmtree/mtree.5
+++ b/usr.sbin/nmtree/mtree.5
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)mtree.8 8.2 (Berkeley) 12/11/93
-.\" $FreeBSD$
-.\"
.Dd December 31, 2007
.Dt MTREE 5
.Os
diff --git a/usr.sbin/nmtree/tests/Makefile b/usr.sbin/nmtree/tests/Makefile
index f88b4db110fc..2a5e2e2d92a4 100644
--- a/usr.sbin/nmtree/tests/Makefile
+++ b/usr.sbin/nmtree/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/usr.sbin/nmtree/tests/Makefile.depend b/usr.sbin/nmtree/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/nmtree/tests/Makefile.depend
+++ b/usr.sbin/nmtree/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/nologin/Makefile b/usr.sbin/nologin/Makefile
index d743f60c6a7c..79fa75d34a73 100644
--- a/usr.sbin/nologin/Makefile
+++ b/usr.sbin/nologin/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.2 (Berkeley) 4/22/94
-# $FreeBSD$
PROG= nologin
MAN= nologin.5 nologin.8
diff --git a/usr.sbin/nologin/Makefile.depend b/usr.sbin/nologin/Makefile.depend
index cae7e645ef6a..93249906da4f 100644
--- a/usr.sbin/nologin/Makefile.depend
+++ b/usr.sbin/nologin/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
lib/${CSU_DIR} \
lib/libc \
diff --git a/usr.sbin/nologin/nologin.5 b/usr.sbin/nologin/nologin.5
index 97f3f26be512..b85046fff6da 100644
--- a/usr.sbin/nologin/nologin.5
+++ b/usr.sbin/nologin/nologin.5
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)nologin.8 8.1 (Berkeley) 6/19/93
-.\" $FreeBSD$
-.\"
.Dd May 10, 2007
.Dt NOLOGIN 5
.Os
diff --git a/usr.sbin/nologin/nologin.8 b/usr.sbin/nologin/nologin.8
index a6be6ac249fd..75a6738284fd 100644
--- a/usr.sbin/nologin/nologin.8
+++ b/usr.sbin/nologin/nologin.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)nologin.8 8.1 (Berkeley) 6/19/93
-.\" $FreeBSD$
-.\"
.Dd April 15, 2020
.Dt NOLOGIN 8
.Os
diff --git a/usr.sbin/nologin/nologin.c b/usr.sbin/nologin/nologin.c
index 658637ef2ae8..9535ed64390e 100644
--- a/usr.sbin/nologin/nologin.c
+++ b/usr.sbin/nologin/nologin.c
@@ -25,8 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <syslog.h>
#include <unistd.h>
diff --git a/usr.sbin/nscd/Makefile b/usr.sbin/nscd/Makefile
index 0a3af09ac2ac..105801a7b9ac 100644
--- a/usr.sbin/nscd/Makefile
+++ b/usr.sbin/nscd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
CONFS= nscd.conf
PROG= nscd
diff --git a/usr.sbin/nscd/Makefile.depend b/usr.sbin/nscd/Makefile.depend
index b208e1c5f44c..669cd46e0c72 100644
--- a/usr.sbin/nscd/Makefile.depend
+++ b/usr.sbin/nscd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/nscd/agent.c b/usr.sbin/nscd/agent.c
index 55b1565a1195..f44cc1071bd5 100644
--- a/usr.sbin/nscd/agent.c
+++ b/usr.sbin/nscd/agent.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/nscd/agent.h b/usr.sbin/nscd/agent.h
index 57078c6f853a..2c937a4dd6be 100644
--- a/usr.sbin/nscd/agent.h
+++ b/usr.sbin/nscd/agent.h
@@ -22,8 +22,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 __NSCD_AGENT_H__
diff --git a/usr.sbin/nscd/agents/Makefile.inc b/usr.sbin/nscd/agents/Makefile.inc
index 1be32e1d986f..243f00c5b994 100644
--- a/usr.sbin/nscd/agents/Makefile.inc
+++ b/usr.sbin/nscd/agents/Makefile.inc
@@ -1,3 +1,2 @@
-# $FreeBSD$
SRCS += passwd.c group.c services.c
diff --git a/usr.sbin/nscd/agents/group.c b/usr.sbin/nscd/agents/group.c
index 92be7ed0ae48..b64a4886f712 100644
--- a/usr.sbin/nscd/agents/group.c
+++ b/usr.sbin/nscd/agents/group.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <assert.h>
diff --git a/usr.sbin/nscd/agents/group.h b/usr.sbin/nscd/agents/group.h
index 15e1097092ed..140e90cd07cc 100644
--- a/usr.sbin/nscd/agents/group.h
+++ b/usr.sbin/nscd/agents/group.h
@@ -22,8 +22,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 "../agent.h"
diff --git a/usr.sbin/nscd/agents/passwd.c b/usr.sbin/nscd/agents/passwd.c
index 247444f5c4ba..1401a1b95246 100644
--- a/usr.sbin/nscd/agents/passwd.c
+++ b/usr.sbin/nscd/agents/passwd.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <assert.h>
diff --git a/usr.sbin/nscd/agents/passwd.h b/usr.sbin/nscd/agents/passwd.h
index 112423a6f35a..e6b4c8f4de6f 100644
--- a/usr.sbin/nscd/agents/passwd.h
+++ b/usr.sbin/nscd/agents/passwd.h
@@ -22,8 +22,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 "../agent.h"
diff --git a/usr.sbin/nscd/agents/services.c b/usr.sbin/nscd/agents/services.c
index 7b02e50cebd8..b1cff4352349 100644
--- a/usr.sbin/nscd/agents/services.c
+++ b/usr.sbin/nscd/agents/services.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <assert.h>
diff --git a/usr.sbin/nscd/agents/services.h b/usr.sbin/nscd/agents/services.h
index 728fe99b24f8..70b5f2faece0 100644
--- a/usr.sbin/nscd/agents/services.h
+++ b/usr.sbin/nscd/agents/services.h
@@ -22,8 +22,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 "../agent.h"
diff --git a/usr.sbin/nscd/cachelib.c b/usr.sbin/nscd/cachelib.c
index ff3e8cb730aa..3a2d58300f31 100644
--- a/usr.sbin/nscd/cachelib.c
+++ b/usr.sbin/nscd/cachelib.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/time.h>
#include <assert.h>
diff --git a/usr.sbin/nscd/cachelib.h b/usr.sbin/nscd/cachelib.h
index 9df50e786d2c..ad9fcabf2a10 100644
--- a/usr.sbin/nscd/cachelib.h
+++ b/usr.sbin/nscd/cachelib.h
@@ -22,8 +22,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 __NSCD_CACHELIB_H__
diff --git a/usr.sbin/nscd/cacheplcs.c b/usr.sbin/nscd/cacheplcs.c
index 37cf765459a0..534f757c22fc 100644
--- a/usr.sbin/nscd/cacheplcs.c
+++ b/usr.sbin/nscd/cacheplcs.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/time.h>
#include <assert.h>
@@ -159,11 +157,9 @@ static struct cache_policy_item_ *
cache_queue_policy_get_next_item(struct cache_policy_ *policy,
struct cache_policy_item_ *item)
{
- struct cache_queue_policy_ *queue_policy;
struct cache_queue_policy_item_ *queue_item;
TRACE_IN(cache_queue_policy_get_next_item);
- queue_policy = (struct cache_queue_policy_ *)policy;
queue_item = (struct cache_queue_policy_item_ *)item;
TRACE_OUT(cache_queue_policy_get_next_item);
@@ -174,11 +170,9 @@ static struct cache_policy_item_ *
cache_queue_policy_get_prev_item(struct cache_policy_ *policy,
struct cache_policy_item_ *item)
{
- struct cache_queue_policy_ *queue_policy;
struct cache_queue_policy_item_ *queue_item;
TRACE_IN(cache_queue_policy_get_prev_item);
- queue_policy = (struct cache_queue_policy_ *)policy;
queue_item = (struct cache_queue_policy_item_ *)item;
TRACE_OUT(cache_queue_policy_get_prev_item);
diff --git a/usr.sbin/nscd/cacheplcs.h b/usr.sbin/nscd/cacheplcs.h
index 7d7e1dab6aa0..1fe60aa6672e 100644
--- a/usr.sbin/nscd/cacheplcs.h
+++ b/usr.sbin/nscd/cacheplcs.h
@@ -22,8 +22,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 __NSCD_CACHEPLCS_H__
diff --git a/usr.sbin/nscd/config.c b/usr.sbin/nscd/config.c
index 74a5cddc1436..f8d33625b520 100644
--- a/usr.sbin/nscd/config.c
+++ b/usr.sbin/nscd/config.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/stat.h>
#include <sys/time.h>
diff --git a/usr.sbin/nscd/config.h b/usr.sbin/nscd/config.h
index 29770e64caaf..f7baf46fff90 100644
--- a/usr.sbin/nscd/config.h
+++ b/usr.sbin/nscd/config.h
@@ -22,8 +22,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 __NSCD_CONFIG_H__
@@ -70,7 +68,7 @@ struct configuration_entry {
/*
* configuration_entry holds pointers for all actual cache_entries,
* which are used for it. There is one for positive caching, one for
- * for negative caching, and several (one per each euid/egid) for
+ * negative caching, and several (one per each euid/egid) for
* multipart caching.
*/
cache_entry positive_cache_entry;
diff --git a/usr.sbin/nscd/debug.c b/usr.sbin/nscd/debug.c
index 2d2ea5b2ca44..6485cb19f221 100644
--- a/usr.sbin/nscd/debug.c
+++ b/usr.sbin/nscd/debug.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include "debug.h"
diff --git a/usr.sbin/nscd/debug.h b/usr.sbin/nscd/debug.h
index 862b902447c7..af81529faacf 100644
--- a/usr.sbin/nscd/debug.h
+++ b/usr.sbin/nscd/debug.h
@@ -22,8 +22,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 __NSCD_DEBUG_H__
diff --git a/usr.sbin/nscd/hashtable.h b/usr.sbin/nscd/hashtable.h
index cbbf6bbc2df1..a68eb2b61c6c 100644
--- a/usr.sbin/nscd/hashtable.h
+++ b/usr.sbin/nscd/hashtable.h
@@ -22,8 +22,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 __CACHELIB_HASHTABLE_H__
diff --git a/usr.sbin/nscd/log.c b/usr.sbin/nscd/log.c
index 5f4c578f1130..d76b2b380b35 100644
--- a/usr.sbin/nscd/log.c
+++ b/usr.sbin/nscd/log.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
diff --git a/usr.sbin/nscd/log.h b/usr.sbin/nscd/log.h
index 296c98f3e18a..8b24b268aa66 100644
--- a/usr.sbin/nscd/log.h
+++ b/usr.sbin/nscd/log.h
@@ -22,8 +22,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 __NSCD_LOG_H__
diff --git a/usr.sbin/nscd/mp_rs_query.c b/usr.sbin/nscd/mp_rs_query.c
index 4bec5174a635..225eec91d2a3 100644
--- a/usr.sbin/nscd/mp_rs_query.c
+++ b/usr.sbin/nscd/mp_rs_query.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/event.h>
#include <sys/socket.h>
diff --git a/usr.sbin/nscd/mp_rs_query.h b/usr.sbin/nscd/mp_rs_query.h
index f74200ac3544..23cb92bb0b9c 100644
--- a/usr.sbin/nscd/mp_rs_query.h
+++ b/usr.sbin/nscd/mp_rs_query.h
@@ -22,8 +22,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 __NSCD_MP_RS_QUERY_H__
diff --git a/usr.sbin/nscd/mp_ws_query.c b/usr.sbin/nscd/mp_ws_query.c
index 5e29748529ed..a2416655b991 100644
--- a/usr.sbin/nscd/mp_ws_query.c
+++ b/usr.sbin/nscd/mp_ws_query.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/event.h>
#include <sys/socket.h>
diff --git a/usr.sbin/nscd/mp_ws_query.h b/usr.sbin/nscd/mp_ws_query.h
index 3337ef63c25b..4a779e654a88 100644
--- a/usr.sbin/nscd/mp_ws_query.h
+++ b/usr.sbin/nscd/mp_ws_query.h
@@ -22,8 +22,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 __NSCD_MP_WS_QUERY_H__
diff --git a/usr.sbin/nscd/nscd.8 b/usr.sbin/nscd/nscd.8
index 7858a30af04f..e34d0920fcb1 100644
--- a/usr.sbin/nscd/nscd.8
+++ b/usr.sbin/nscd/nscd.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 5, 2018
.Dt NSCD 8
.Os
diff --git a/usr.sbin/nscd/nscd.c b/usr.sbin/nscd/nscd.c
index 3c3ebda565f6..0314e99675f3 100644
--- a/usr.sbin/nscd/nscd.c
+++ b/usr.sbin/nscd/nscd.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/event.h>
#include <sys/socket.h>
@@ -85,7 +82,7 @@ static void process_socket_event(struct kevent *, struct runtime_env *,
static void process_timer_event(struct kevent *, struct runtime_env *,
struct configuration *);
static void *processing_thread(void *);
-static void usage(void);
+static void usage(void) __dead2;
void get_time_func(struct timeval *);
@@ -105,7 +102,6 @@ init_cache_(struct configuration *config)
struct configuration_entry *config_entry;
size_t size, i;
- int res;
TRACE_IN(init_cache_);
@@ -120,14 +116,14 @@ init_cache_(struct configuration *config)
* We should register common entries now - multipart entries
* would be registered automatically during the queries.
*/
- res = register_cache_entry(retval, (struct cache_entry_params *)
+ register_cache_entry(retval, (struct cache_entry_params *)
&config_entry->positive_cache_params);
config_entry->positive_cache_entry = find_cache_entry(retval,
config_entry->positive_cache_params.cep.entry_name);
assert(config_entry->positive_cache_entry !=
INVALID_CACHE_ENTRY);
- res = register_cache_entry(retval, (struct cache_entry_params *)
+ register_cache_entry(retval, (struct cache_entry_params *)
&config_entry->negative_cache_params);
config_entry->negative_cache_entry = find_cache_entry(retval,
config_entry->negative_cache_params.cep.entry_name);
diff --git a/usr.sbin/nscd/nscd.conf b/usr.sbin/nscd/nscd.conf
index 19a8b5b95452..0d9025221504 100644
--- a/usr.sbin/nscd/nscd.conf
+++ b/usr.sbin/nscd/nscd.conf
@@ -1,6 +1,5 @@
#
# Default caching daemon configuration file
-# $FreeBSD$
#
enable-cache passwd yes
diff --git a/usr.sbin/nscd/nscd.conf.5 b/usr.sbin/nscd/nscd.conf.5
index a29e31a4f27f..259709894e47 100644
--- a/usr.sbin/nscd/nscd.conf.5
+++ b/usr.sbin/nscd/nscd.conf.5
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 6, 2018
.Dt NSCD.CONF 5
.Os
diff --git a/usr.sbin/nscd/nscdcli.c b/usr.sbin/nscd/nscdcli.c
index 326acfae7dea..1a7a86532343 100644
--- a/usr.sbin/nscd/nscdcli.c
+++ b/usr.sbin/nscd/nscdcli.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/event.h>
@@ -139,7 +136,6 @@ send_credentials(struct nscd_connection_ *connection, int type)
struct kevent eventlist;
int nevents;
ssize_t result;
- int res;
TRACE_IN(send_credentials);
memset(&cmsg, 0, sizeof(cmsg));
@@ -158,7 +154,7 @@ send_credentials(struct nscd_connection_ *connection, int type)
EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD,
NOTE_LOWAT, sizeof(int), NULL);
- res = kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL);
+ kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL);
nevents = kevent(connection->write_queue, NULL, 0, &eventlist, 1, NULL);
if ((nevents == 1) && (eventlist.filter == EVFILT_WRITE)) {
diff --git a/usr.sbin/nscd/nscdcli.h b/usr.sbin/nscd/nscdcli.h
index 1eae4efc0146..7042d79aca80 100644
--- a/usr.sbin/nscd/nscdcli.h
+++ b/usr.sbin/nscd/nscdcli.h
@@ -22,8 +22,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 __NSCD_NSCDCLI_H__
diff --git a/usr.sbin/nscd/parser.c b/usr.sbin/nscd/parser.c
index 1c1523a031a3..dc8ad809e8a8 100644
--- a/usr.sbin/nscd/parser.c
+++ b/usr.sbin/nscd/parser.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/time.h>
#include <assert.h>
@@ -364,7 +362,7 @@ set_threads_num(struct configuration *config, int value)
/*
* The main configuration routine. Its implementation is hugely inspired by the
- * the same routine implementation in Solaris NSCD.
+ * same routine implementation in Solaris NSCD.
*/
int
parse_config_file(struct configuration *config,
diff --git a/usr.sbin/nscd/parser.h b/usr.sbin/nscd/parser.h
index d4f3b227279f..5566d0138378 100644
--- a/usr.sbin/nscd/parser.h
+++ b/usr.sbin/nscd/parser.h
@@ -22,8 +22,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 __NSCD_PARSER_H__
diff --git a/usr.sbin/nscd/protocol.c b/usr.sbin/nscd/protocol.c
index 3e40739600a6..528fec1c7554 100644
--- a/usr.sbin/nscd/protocol.c
+++ b/usr.sbin/nscd/protocol.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/nscd/protocol.h b/usr.sbin/nscd/protocol.h
index 270335cb6e05..3e521f2d1313 100644
--- a/usr.sbin/nscd/protocol.h
+++ b/usr.sbin/nscd/protocol.h
@@ -22,8 +22,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 __NSCD_PROTOCOL_H__
diff --git a/usr.sbin/nscd/query.c b/usr.sbin/nscd/query.c
index a7737c0ea9aa..aa048f029aa6 100644
--- a/usr.sbin/nscd/query.c
+++ b/usr.sbin/nscd/query.c
@@ -25,9 +25,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/event.h>
#include <sys/socket.h>
@@ -81,7 +78,7 @@ static int on_write_response_write1(struct query_state *);
/*
* Clears the specified configuration entry (clears the cache for positive and
- * and negative entries) and also for all multipart entries.
+ * negative entries) and also for all multipart entries.
*/
static void
clear_config_entry(struct configuration_entry *config_entry)
diff --git a/usr.sbin/nscd/query.h b/usr.sbin/nscd/query.h
index f3df9068221f..f43b6d4c9c6e 100644
--- a/usr.sbin/nscd/query.h
+++ b/usr.sbin/nscd/query.h
@@ -22,8 +22,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 __NSCD_QUERY_H__
diff --git a/usr.sbin/nscd/singletons.c b/usr.sbin/nscd/singletons.c
index e557c20cfc1c..a6c3d1337b33 100644
--- a/usr.sbin/nscd/singletons.c
+++ b/usr.sbin/nscd/singletons.c
@@ -26,8 +26,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/time.h>
#include "singletons.h"
diff --git a/usr.sbin/nscd/singletons.h b/usr.sbin/nscd/singletons.h
index dfd891fe10c6..6acb1a83bca0 100644
--- a/usr.sbin/nscd/singletons.h
+++ b/usr.sbin/nscd/singletons.h
@@ -22,8 +22,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 __NSCD_SINGLETONS_H__
diff --git a/usr.sbin/ntp/Makefile b/usr.sbin/ntp/Makefile
index ad5b5234035a..3701fd297c1a 100644
--- a/usr.sbin/ntp/Makefile
+++ b/usr.sbin/ntp/Makefile
@@ -1,5 +1,4 @@
# Makefile for ntpd.
-# $FreeBSD$
SUBDIR= libopts libntp libntpevent libparse ntpd ntpdc ntpq ntpdate \
ntptime ntp-keygen sntp
diff --git a/usr.sbin/ntp/Makefile.inc b/usr.sbin/ntp/Makefile.inc
index 2b3b5983dc23..a4174bb99393 100644
--- a/usr.sbin/ntp/Makefile.inc
+++ b/usr.sbin/ntp/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ntp/config.h b/usr.sbin/ntp/config.h
index 7446d199e16f..97c46aaf1dab 100644
--- a/usr.sbin/ntp/config.h
+++ b/usr.sbin/ntp/config.h
@@ -1,6 +1,5 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
-/* $FreeBSD$ */
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
@@ -1468,7 +1467,7 @@
#define PACKAGE_NAME "ntp"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "ntp 4.2.8p15"
+#define PACKAGE_STRING "ntp 4.2.8p17"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "ntp"
@@ -1477,7 +1476,7 @@
#define PACKAGE_URL "http://www.ntp.org./"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "4.2.8p15"
+#define PACKAGE_VERSION "4.2.8p17"
/* data dir */
#define PERLLIBDIR "/usr/share/ntp/lib"
@@ -1586,10 +1585,6 @@
#define STR_SYSTEM "powerpc64-undermydesk-freebsd"
#elif defined(__powerpc__)
#define STR_SYSTEM "powerpc-undermydesk-freebsd"
-#elif defined(__mips64)
-#define STR_SYSTEM "mips64-undermydesk-freebsd"
-#elif defined(__mips__)
-#define STR_SYSTEM "mips-undermydesk-freebsd"
#elif defined(__aarch64__)
#define STR_SYSTEM "arm64-undermydesk-freebsd"
#elif defined(__arm__)
@@ -1652,7 +1647,7 @@ typedef unsigned int uintptr_t;
/* #undef USE_UDP_SIGPOLL */
/* Version number of package */
-#define VERSION "4.2.8p15"
+#define VERSION "4.2.8p17"
/* vsnprintf expands "%m" to strerror(errno) */
#define VSNPRINTF_PERCENT_M 1
diff --git a/usr.sbin/ntp/doc/Makefile b/usr.sbin/ntp/doc/Makefile
index 2ec8d324db3b..345e75d54679 100644
--- a/usr.sbin/ntp/doc/Makefile
+++ b/usr.sbin/ntp/doc/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ntp/doc/Makefile.depend b/usr.sbin/ntp/doc/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/ntp/doc/Makefile.depend
+++ b/usr.sbin/ntp/doc/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/doc/drivers/Makefile b/usr.sbin/ntp/doc/drivers/Makefile
index d1c42bd1eb98..580a62a7a9ed 100644
--- a/usr.sbin/ntp/doc/drivers/Makefile
+++ b/usr.sbin/ntp/doc/drivers/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ntp/doc/drivers/Makefile.depend b/usr.sbin/ntp/doc/drivers/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/ntp/doc/drivers/Makefile.depend
+++ b/usr.sbin/ntp/doc/drivers/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/doc/drivers/icons/Makefile b/usr.sbin/ntp/doc/drivers/icons/Makefile
index 55746bedb7ea..eda2a743078d 100644
--- a/usr.sbin/ntp/doc/drivers/icons/Makefile
+++ b/usr.sbin/ntp/doc/drivers/icons/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ntp/doc/drivers/icons/Makefile.depend b/usr.sbin/ntp/doc/drivers/icons/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/ntp/doc/drivers/icons/Makefile.depend
+++ b/usr.sbin/ntp/doc/drivers/icons/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/doc/drivers/scripts/Makefile b/usr.sbin/ntp/doc/drivers/scripts/Makefile
index 64a2ef8079e8..16b896553114 100644
--- a/usr.sbin/ntp/doc/drivers/scripts/Makefile
+++ b/usr.sbin/ntp/doc/drivers/scripts/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ntp/doc/drivers/scripts/Makefile.depend b/usr.sbin/ntp/doc/drivers/scripts/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/ntp/doc/drivers/scripts/Makefile.depend
+++ b/usr.sbin/ntp/doc/drivers/scripts/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/doc/hints/Makefile b/usr.sbin/ntp/doc/hints/Makefile
index f7571f02df09..899e8adaea0f 100644
--- a/usr.sbin/ntp/doc/hints/Makefile
+++ b/usr.sbin/ntp/doc/hints/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ntp/doc/hints/Makefile.depend b/usr.sbin/ntp/doc/hints/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/ntp/doc/hints/Makefile.depend
+++ b/usr.sbin/ntp/doc/hints/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/doc/icons/Makefile b/usr.sbin/ntp/doc/icons/Makefile
index 2faf147bb7ff..b9608cc2f82e 100644
--- a/usr.sbin/ntp/doc/icons/Makefile
+++ b/usr.sbin/ntp/doc/icons/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ntp/doc/icons/Makefile.depend b/usr.sbin/ntp/doc/icons/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/ntp/doc/icons/Makefile.depend
+++ b/usr.sbin/ntp/doc/icons/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/doc/ntp-keygen.8 b/usr.sbin/ntp/doc/ntp-keygen.8
index f17666d650c6..ad7b844d27de 100644
--- a/usr.sbin/ntp/doc/ntp-keygen.8
+++ b/usr.sbin/ntp/doc/ntp-keygen.8
@@ -3,8 +3,6 @@
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.mdoc)
.\"
-.\" $FreeBSD$
-.\"
.\" It has been AutoGen-ed August 14, 2018 at 08:30:38 AM by AutoGen 5.18.5
.\" From the definitions ntp-keygen-opts.def
.\" and the template file agmdoc-cmd.tpl
diff --git a/usr.sbin/ntp/doc/ntp.conf.5 b/usr.sbin/ntp/doc/ntp.conf.5
index 3494a09c2bc7..9e23a2294c48 100644
--- a/usr.sbin/ntp/doc/ntp.conf.5
+++ b/usr.sbin/ntp/doc/ntp.conf.5
@@ -3,8 +3,6 @@
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
-.\" $FreeBSD$
-.\"
.\" It has been AutoGen-ed August 14, 2018 at 08:29:15 AM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agmdoc-cmd.tpl
diff --git a/usr.sbin/ntp/doc/ntp.keys.5 b/usr.sbin/ntp/doc/ntp.keys.5
index 5c3785a73e36..d235f3b5f7dd 100644
--- a/usr.sbin/ntp/doc/ntp.keys.5
+++ b/usr.sbin/ntp/doc/ntp.keys.5
@@ -3,8 +3,6 @@
.Os SunOS 5.10
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
-.\" $FreeBSD$
-.\"
.\" It has been AutoGen-ed August 14, 2018 at 08:29:18 AM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agmdoc-file.tpl
diff --git a/usr.sbin/ntp/doc/ntpd.8 b/usr.sbin/ntp/doc/ntpd.8
index 07cb6d5578c6..74bc07793048 100644
--- a/usr.sbin/ntp/doc/ntpd.8
+++ b/usr.sbin/ntp/doc/ntpd.8
@@ -3,8 +3,6 @@
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc)
.\"
-.\" $FreeBSD$
-.\"
.\" It has been AutoGen-ed August 14, 2018 at 08:29:20 AM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agmdoc-cmd.tpl
diff --git a/usr.sbin/ntp/doc/ntpdate.8 b/usr.sbin/ntp/doc/ntpdate.8
index e5aaecd4329e..fb10cc94089d 100644
--- a/usr.sbin/ntp/doc/ntpdate.8
+++ b/usr.sbin/ntp/doc/ntpdate.8
@@ -1,6 +1,4 @@
.\"
-.\" $FreeBSD$
-.\"
.Dd May 17, 2006
.Dt NTPDATE 8
.Os
diff --git a/usr.sbin/ntp/doc/ntpdc.8 b/usr.sbin/ntp/doc/ntpdc.8
index c0ffef117613..af4190f31553 100644
--- a/usr.sbin/ntp/doc/ntpdc.8
+++ b/usr.sbin/ntp/doc/ntpdc.8
@@ -3,8 +3,6 @@
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpdc-opts.mdoc)
.\"
-.\" $FreeBSD$
-.\"
.\" It has been AutoGen-ed August 14, 2018 at 08:29:43 AM by AutoGen 5.18.5
.\" From the definitions ntpdc-opts.def
.\" and the template file agmdoc-cmd.tpl
diff --git a/usr.sbin/ntp/doc/ntpq.8 b/usr.sbin/ntp/doc/ntpq.8
index 04f1d70133a0..e6c66ed71d97 100644
--- a/usr.sbin/ntp/doc/ntpq.8
+++ b/usr.sbin/ntp/doc/ntpq.8
@@ -3,8 +3,6 @@
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpq-opts.mdoc)
.\"
-.\" $FreeBSD$
-.\"
.\" It has been AutoGen-ed August 14, 2018 at 08:30:05 AM by AutoGen 5.18.5
.\" From the definitions ntpq-opts.def
.\" and the template file agmdoc-cmd.tpl
diff --git a/usr.sbin/ntp/doc/ntptime.8 b/usr.sbin/ntp/doc/ntptime.8
index bb3b41aeea26..c9a3aebaae68 100644
--- a/usr.sbin/ntp/doc/ntptime.8
+++ b/usr.sbin/ntp/doc/ntptime.8
@@ -1,6 +1,4 @@
.\"
-.\" $FreeBSD$
-.\"
.Dd April 27, 2015
.Dt NTPTIME 8
.Os
diff --git a/usr.sbin/ntp/doc/ntptrace.8 b/usr.sbin/ntp/doc/ntptrace.8
index 40cb7191d42c..20fad744819a 100644
--- a/usr.sbin/ntp/doc/ntptrace.8
+++ b/usr.sbin/ntp/doc/ntptrace.8
@@ -3,8 +3,6 @@
.Os
.\" EDIT THIS FILE WITH CAUTION (ntptrace-opts.mdoc)
.\"
-.\" $FreeBSD$
-.\"
.\" It has been AutoGen-ed February 4, 2015 at 02:37:48 AM by AutoGen 5.18.5pre4
.\" From the definitions ntptrace-opts.def
.\" and the template file agmdoc-cmd.tpl
diff --git a/usr.sbin/ntp/doc/pic/Makefile b/usr.sbin/ntp/doc/pic/Makefile
index cce1fbcc927b..23cf769892da 100644
--- a/usr.sbin/ntp/doc/pic/Makefile
+++ b/usr.sbin/ntp/doc/pic/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ntp/doc/pic/Makefile.depend b/usr.sbin/ntp/doc/pic/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/ntp/doc/pic/Makefile.depend
+++ b/usr.sbin/ntp/doc/pic/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/doc/scripts/Makefile b/usr.sbin/ntp/doc/scripts/Makefile
index 5cc430b1afae..7b8255a02423 100644
--- a/usr.sbin/ntp/doc/scripts/Makefile
+++ b/usr.sbin/ntp/doc/scripts/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ntp/doc/scripts/Makefile.depend b/usr.sbin/ntp/doc/scripts/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/ntp/doc/scripts/Makefile.depend
+++ b/usr.sbin/ntp/doc/scripts/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/doc/sntp.8 b/usr.sbin/ntp/doc/sntp.8
index 2cf625ff2d5e..94c3c2816035 100644
--- a/usr.sbin/ntp/doc/sntp.8
+++ b/usr.sbin/ntp/doc/sntp.8
@@ -3,8 +3,6 @@
.Os
.\" EDIT THIS FILE WITH CAUTION (sntp-opts.mdoc)
.\"
-.\" $FreeBSD$
-.\"
.\" It has been AutoGen-ed August 14, 2018 at 08:27:40 AM by AutoGen 5.18.5
.\" From the definitions sntp-opts.def
.\" and the template file agmdoc-cmd.tpl
diff --git a/usr.sbin/ntp/libntp/Makefile b/usr.sbin/ntp/libntp/Makefile
index 8ac370cae693..7cf4a33b8c6d 100644
--- a/usr.sbin/ntp/libntp/Makefile
+++ b/usr.sbin/ntp/libntp/Makefile
@@ -1,10 +1,9 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/contrib/ntp/libntp \
- ${SRCTOP}/contrib/ntp/lib/isc \
- ${SRCTOP}/contrib/ntp/lib/isc/nls \
- ${SRCTOP}/contrib/ntp/lib/isc/pthreads \
- ${SRCTOP}/contrib/ntp/lib/isc/unix \
+ ${SRCTOP}/contrib/ntp/libntp/lib/isc \
+ ${SRCTOP}/contrib/ntp/libntp/lib/isc/nls \
+ ${SRCTOP}/contrib/ntp/libntp/lib/isc/pthreads \
+ ${SRCTOP}/contrib/ntp/libntp/lib/isc/unix \
LIB= ntp
INTERNALLIB=
@@ -23,7 +22,8 @@ NTP_SRCS= systime.c a_md5encrypt.c adjtime.c atoint.c \
mstolfp.c msyslog.c netof.c ntp_calendar.c \
ntp_calgps.c \
ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c \
- ntp_lineedit.c ntp_random.c ntp_rfc2553.c ntp_worker.c \
+ ntp_lineedit.c ntp_random.c ntp_rfc2553.c ntp_realpath.c \
+ ntp_worker.c \
numtoa.c numtohost.c octtoint.c prettydate.c \
recvbuff.c refidsmear.c \
refnumtoa.c snprintf.c socket.c \
@@ -77,9 +77,9 @@ ISC_SRCS= assertions.c \
SRCS= ${NTP_SRCS} ${ISC_SRCS} version.c
CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/unix/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/pthreads/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/unix/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/pthreads/include \
-I${SRCTOP}/contrib/ntp/sntp/libopts \
-I${SRCTOP}/lib/libc/${MACHINE_ARCH} \
-I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/edit \
diff --git a/usr.sbin/ntp/libntp/Makefile.depend b/usr.sbin/ntp/libntp/Makefile.depend
index 1fd58260f7dd..cd4ecd009905 100644
--- a/usr.sbin/ntp/libntp/Makefile.depend
+++ b/usr.sbin/ntp/libntp/Makefile.depend
@@ -1,7 +1,7 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
+ bin/sh.host \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/ntp/libntpevent/Makefile b/usr.sbin/ntp/libntpevent/Makefile
index 487faedc00a3..0c04dae95d47 100644
--- a/usr.sbin/ntp/libntpevent/Makefile
+++ b/usr.sbin/ntp/libntpevent/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ntp/libntpevent/Makefile.depend b/usr.sbin/ntp/libntpevent/Makefile.depend
index 9493af9c2323..f527c2585bed 100644
--- a/usr.sbin/ntp/libntpevent/Makefile.depend
+++ b/usr.sbin/ntp/libntpevent/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/libntpevent/event2/event-config.h b/usr.sbin/ntp/libntpevent/event2/event-config.h
index 920b7bada257..e636a9fba1d5 100644
--- a/usr.sbin/ntp/libntpevent/event2/event-config.h
+++ b/usr.sbin/ntp/libntpevent/event2/event-config.h
@@ -1,5 +1,4 @@
/* event2/event-config.h
-* $FreeBSD$
*
* This file was generated by autoconf when libevent was built, and post-
* processed by Libevent so that its macros would have a uniform prefix.
diff --git a/usr.sbin/ntp/libopts/Makefile b/usr.sbin/ntp/libopts/Makefile
index 17fe6783b3cb..170ff6db61da 100644
--- a/usr.sbin/ntp/libopts/Makefile
+++ b/usr.sbin/ntp/libopts/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/contrib/ntp/sntp/libopts
diff --git a/usr.sbin/ntp/libopts/Makefile.depend b/usr.sbin/ntp/libopts/Makefile.depend
index 18be76b0cb6f..15a1f9c07f7c 100644
--- a/usr.sbin/ntp/libopts/Makefile.depend
+++ b/usr.sbin/ntp/libopts/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/libparse/Makefile b/usr.sbin/ntp/libparse/Makefile
index a5530ac473c1..e6c0bbb269cc 100644
--- a/usr.sbin/ntp/libparse/Makefile
+++ b/usr.sbin/ntp/libparse/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/contrib/ntp/libparse
@@ -13,7 +12,7 @@ SRCS= binio.c clk_computime.c clk_dcf7000.c clk_hopf6021.c \
trim_info.c
CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/unix/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/include -I${.CURDIR:H}
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/unix/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/include -I${.CURDIR:H}
.include <bsd.lib.mk>
diff --git a/usr.sbin/ntp/libparse/Makefile.depend b/usr.sbin/ntp/libparse/Makefile.depend
index 4bf31bdca104..469861b9c400 100644
--- a/usr.sbin/ntp/libparse/Makefile.depend
+++ b/usr.sbin/ntp/libparse/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/ntp-keygen/Makefile b/usr.sbin/ntp/ntp-keygen/Makefile
index 923ff42bdd43..71df31a475a7 100644
--- a/usr.sbin/ntp/ntp-keygen/Makefile
+++ b/usr.sbin/ntp/ntp-keygen/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
MAN=
@@ -12,10 +11,10 @@ SRCS= ntp-keygen.c ntp-keygen-opts.c
CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
-I${SRCTOP}/contrib/ntp/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/unix/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/pthreads/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/${NTP_ATOMIC}/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/unix/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/pthreads/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/${NTP_ATOMIC}/include \
-I${SRCTOP}/contrib/ntp/sntp/libopts \
-I${.CURDIR}/lib/libc/${MACHINE_ARCH} \
-I${.CURDIR:H}
diff --git a/usr.sbin/ntp/ntp-keygen/Makefile.depend b/usr.sbin/ntp/ntp-keygen/Makefile.depend
index 434e203392a3..9284c867f078 100644
--- a/usr.sbin/ntp/ntp-keygen/Makefile.depend
+++ b/usr.sbin/ntp/ntp-keygen/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/ntp-keygen/Makefile.depend.options b/usr.sbin/ntp/ntp-keygen/Makefile.depend.options
index fa96b2506b2c..b374d7a1fd52 100644
--- a/usr.sbin/ntp/ntp-keygen/Makefile.depend.options
+++ b/usr.sbin/ntp/ntp-keygen/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= OPENSSL
diff --git a/usr.sbin/ntp/ntpd/Makefile b/usr.sbin/ntp/ntpd/Makefile
index 2d8a8b9d2a2d..d7b5010227f5 100644
--- a/usr.sbin/ntp/ntpd/Makefile
+++ b/usr.sbin/ntp/ntpd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
MAN=
@@ -16,9 +15,12 @@ FILESDIR= ETC_NTP
FILESMODE= 644
PROG= ntpd
-SRCS= cmd_args.c ntp_config.c ntp_control.c ntp_crypto.c ntp_filegen.c \
+SRCS= cmd_args.c \
+ ntp_clockdev.c \
+ ntp_config.c ntp_control.c ntp_crypto.c ntp_filegen.c \
ntp_io.c ntp_leapsec.c ntp_loopfilter.c ntp_monitor.c ntp_parser.c \
ntp_peer.c ntp_proto.c ntp_refclock.c ntp_request.c ntp_restrict.c \
+ ntp_ppsdev.c \
ntp_scanner.c ntp_signd.c ntp_timer.c ntp_util.c ntpd-opts.c ntpd.c \
rc_cmdlength.c \
refclock_acts.c refclock_arbiter.c refclock_arc.c refclock_as2201.c \
@@ -36,9 +38,9 @@ SRCS= cmd_args.c ntp_config.c ntp_control.c ntp_crypto.c ntp_filegen.c \
CFLAGS+= -I${SRCTOP}/contrib/ntp/ntpd \
-I${SRCTOP}/contrib/ntp/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/pthreads/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/unix/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/pthreads/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/unix/include \
-I${SRCTOP}/contrib/ntp/sntp/libopts \
-I${.CURDIR:H} \
-I${.CURDIR}
diff --git a/usr.sbin/ntp/ntpd/Makefile.depend b/usr.sbin/ntp/ntpd/Makefile.depend
index 2d2229dcbd62..c2747ffc19c6 100644
--- a/usr.sbin/ntp/ntpd/Makefile.depend
+++ b/usr.sbin/ntp/ntpd/Makefile.depend
@@ -1,7 +1,7 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
+ bin/sh.host \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/ntp/ntpd/Makefile.depend.options b/usr.sbin/ntp/ntpd/Makefile.depend.options
index fa96b2506b2c..b374d7a1fd52 100644
--- a/usr.sbin/ntp/ntpd/Makefile.depend.options
+++ b/usr.sbin/ntp/ntpd/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= OPENSSL
diff --git a/usr.sbin/ntp/ntpd/leap-seconds b/usr.sbin/ntp/ntpd/leap-seconds
index 0f43115c8e53..3fe9a1210e3c 100644
--- a/usr.sbin/ntp/ntpd/leap-seconds
+++ b/usr.sbin/ntp/ntpd/leap-seconds
@@ -204,10 +204,10 @@
# current -- the update time stamp, the data and the name of the file
# will not change.
#
-# Updated through IERS Bulletin C63
-# File expires on: 28 December 2022
+# Updated through IERS Bulletin C66
+# File expires on: 28 June 2024
#
-#@ 3881174400
+#@ 3928521600
#
2272060800 10 # 1 Jan 1972
2287785600 11 # 1 Jul 1972
@@ -252,4 +252,4 @@
# the hash line is also ignored in the
# computation.
#
-#h 732b2044 5863a938 b7e43179 1339c710 ded63837
+#h 16edd0f0 3666784f 37db6bdd e74ced87 59af48f1
diff --git a/usr.sbin/ntp/ntpd/ntp.conf b/usr.sbin/ntp/ntpd/ntp.conf
index ae0a3d0e6cad..726729f30f93 100644
--- a/usr.sbin/ntp/ntpd/ntp.conf
+++ b/usr.sbin/ntp/ntpd/ntp.conf
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
# Default NTP servers for the FreeBSD operating system.
#
@@ -20,24 +19,27 @@
tos minclock 3 maxclock 6
#
-# The following pool statement will give you a random set of NTP servers
-# geographically close to you. A single pool statement adds multiple
-# servers from the pool, according to the tos minclock/maxclock targets.
+# The following pool statements will give you a random set of IPv4 and IPv6
+# NTP servers geographically close to you. A single pool statement adds
+# multiple servers from the pool, according to the tos minclock/maxclock
+# targets.
# See http://www.pool.ntp.org/ for details. Note, pool.ntp.org encourages
# users with a static IP and good upstream NTP servers to add a server
-# to the pool. See http://www.pool.ntp.org/join.html if you are interested.
+# to the pool. See http://www.pool.ntp.org/join.html if you are interested.
#
# The option `iburst' is used for faster initial synchronization.
#
pool 0.freebsd.pool.ntp.org iburst
+pool 2.freebsd.pool.ntp.org iburst
#
# If you want to pick yourself which country's public NTP server
-# you want to sync against, comment out the above pool, uncomment
-# the next one, and replace CC with the country's abbreviation.
-# Make sure that the hostname resolves to a proper IP address!
+# you want to sync against, comment out the above pool statements,
+# uncomment the next ones, and replace CC with the country's abbreviation.
+# Make sure that the hostnames resolves to a proper IP address!
#
# pool 0.CC.pool.ntp.org iburst
+# pool 2.CC.pool.ntp.org iburst
#
# To configure a specific server, such as an organization-wide local
diff --git a/usr.sbin/ntp/ntpdate/Makefile b/usr.sbin/ntp/ntpdate/Makefile
index afd544d020da..03afbb5d708b 100644
--- a/usr.sbin/ntp/ntpdate/Makefile
+++ b/usr.sbin/ntp/ntpdate/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
@@ -9,9 +8,9 @@ MAN=
SRCS= ntpdate.c version.c
CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/include/ \
- -I${SRCTOP}/contrib/ntp/lib/isc/unix/include/ \
- -I${SRCTOP}/contrib/ntp/lib/isc/pthreads/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/include/ \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/unix/include/ \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/pthreads/include \
-I${.CURDIR:H}
LIBADD= ntp m pthread
diff --git a/usr.sbin/ntp/ntpdate/Makefile.depend b/usr.sbin/ntp/ntpdate/Makefile.depend
index dccc5fcb536f..361bd50df87f 100644
--- a/usr.sbin/ntp/ntpdate/Makefile.depend
+++ b/usr.sbin/ntp/ntpdate/Makefile.depend
@@ -1,7 +1,7 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
+ bin/sh.host \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/ntp/ntpdate/Makefile.depend.options b/usr.sbin/ntp/ntpdate/Makefile.depend.options
index fa96b2506b2c..b374d7a1fd52 100644
--- a/usr.sbin/ntp/ntpdate/Makefile.depend.options
+++ b/usr.sbin/ntp/ntpdate/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= OPENSSL
diff --git a/usr.sbin/ntp/ntpdc/Makefile b/usr.sbin/ntp/ntpdc/Makefile
index 1e363a3e2a83..8502b7c1b503 100644
--- a/usr.sbin/ntp/ntpdc/Makefile
+++ b/usr.sbin/ntp/ntpdc/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
MAN=
@@ -10,9 +9,9 @@ PROG= ntpdc
SRCS= ntpdc.c ntpdc_ops.c ntpdc-opts.c version.c
CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/unix/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/pthreads/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/unix/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/pthreads/include \
-I${SRCTOP}/contrib/ntp/sntp/libopts \
-I${.CURDIR}/lib/libc/${MACHINE_ARCH} \
-I${.CURDIR:H} -I${.CURDIR}
diff --git a/usr.sbin/ntp/ntpdc/Makefile.depend b/usr.sbin/ntp/ntpdc/Makefile.depend
index b41e2855ad23..675855e8f3ed 100644
--- a/usr.sbin/ntp/ntpdc/Makefile.depend
+++ b/usr.sbin/ntp/ntpdc/Makefile.depend
@@ -1,7 +1,7 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
+ bin/sh.host \
include \
include/arpa \
include/xlocale \
@@ -11,7 +11,6 @@ DIRDEPS = \
lib/libedit \
lib/libthr \
lib/msun \
- lib/ncurses/ncursesw \
usr.sbin/ntp/libntp \
usr.sbin/ntp/libopts \
diff --git a/usr.sbin/ntp/ntpdc/Makefile.depend.options b/usr.sbin/ntp/ntpdc/Makefile.depend.options
index fa96b2506b2c..b374d7a1fd52 100644
--- a/usr.sbin/ntp/ntpdc/Makefile.depend.options
+++ b/usr.sbin/ntp/ntpdc/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= OPENSSL
diff --git a/usr.sbin/ntp/ntpdc/nl.c b/usr.sbin/ntp/ntpdc/nl.c
index 045d000fe252..6ad05f368742 100644
--- a/usr.sbin/ntp/ntpdc/nl.c
+++ b/usr.sbin/ntp/ntpdc/nl.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
printf("sizeof(union req_data_u_tag) = %d\n",
(int) sizeof(union req_data_u_tag));
printf("offsetof(u32) = %d\n",
diff --git a/usr.sbin/ntp/ntpq/Makefile b/usr.sbin/ntp/ntpq/Makefile
index 3efa1e149a5d..be1e9c9034ff 100644
--- a/usr.sbin/ntp/ntpq/Makefile
+++ b/usr.sbin/ntp/ntpq/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
MAN=
@@ -13,10 +12,10 @@ SRCS= ntpq.c ntpq-opts.c ntpq-subs.c version.c
CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
-I${SRCTOP}/contrib/ntp/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/unix/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/pthreads/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/${NTP_ATOMIC}/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/unix/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/pthreads/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/${NTP_ATOMIC}/include \
-I${SRCTOP}/contrib/ntp/sntp/libopts \
-I${.CURDIR:H}
diff --git a/usr.sbin/ntp/ntpq/Makefile.depend b/usr.sbin/ntp/ntpq/Makefile.depend
index b41e2855ad23..675855e8f3ed 100644
--- a/usr.sbin/ntp/ntpq/Makefile.depend
+++ b/usr.sbin/ntp/ntpq/Makefile.depend
@@ -1,7 +1,7 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
+ bin/sh.host \
include \
include/arpa \
include/xlocale \
@@ -11,7 +11,6 @@ DIRDEPS = \
lib/libedit \
lib/libthr \
lib/msun \
- lib/ncurses/ncursesw \
usr.sbin/ntp/libntp \
usr.sbin/ntp/libopts \
diff --git a/usr.sbin/ntp/ntpq/Makefile.depend.options b/usr.sbin/ntp/ntpq/Makefile.depend.options
index fa96b2506b2c..b374d7a1fd52 100644
--- a/usr.sbin/ntp/ntpq/Makefile.depend.options
+++ b/usr.sbin/ntp/ntpq/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= OPENSSL
diff --git a/usr.sbin/ntp/ntptime/Makefile b/usr.sbin/ntp/ntptime/Makefile
index 1111434541ce..027021aa1b16 100644
--- a/usr.sbin/ntp/ntptime/Makefile
+++ b/usr.sbin/ntp/ntptime/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/contrib/ntp/util
@@ -6,9 +5,9 @@ PROG= ntptime
MAN=
CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/include/ \
- -I${SRCTOP}/contrib/ntp/lib/isc/unix/include/ \
- -I${SRCTOP}/contrib/ntp/lib/isc/pthreads/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/include/ \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/unix/include/ \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/pthreads/include \
-I${.CURDIR:H}
LIBADD= m ntp pthread
diff --git a/usr.sbin/ntp/ntptime/Makefile.depend b/usr.sbin/ntp/ntptime/Makefile.depend
index c7f2a7c3eff4..159bb4bc52a6 100644
--- a/usr.sbin/ntp/ntptime/Makefile.depend
+++ b/usr.sbin/ntp/ntptime/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/ntp/scripts/mkver b/usr.sbin/ntp/scripts/mkver
index f193db55f1b4..279468a1af1c 100755
--- a/usr.sbin/ntp/scripts/mkver
+++ b/usr.sbin/ntp/scripts/mkver
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
PROG=${1-UNKNOWN}
@@ -8,7 +7,7 @@ PROG=${1-UNKNOWN}
ConfStr="$PROG"
-ConfStr="$ConfStr 4.2.8p15"
+ConfStr="$ConfStr 4.2.8p16"
case "$CSET" in
'') ;;
diff --git a/usr.sbin/ntp/scripts/ntptrace b/usr.sbin/ntp/scripts/ntptrace
index 8a895c4ba0be..994a008cd7e8 100644
--- a/usr.sbin/ntp/scripts/ntptrace
+++ b/usr.sbin/ntp/scripts/ntptrace
@@ -1,6 +1,5 @@
#! /usr/local/bin/perl -w
#
-# $FreeBSD$
# John Hay -- John.Hay@icomtek.csir.co.za / jhay@FreeBSD.org
diff --git a/usr.sbin/ntp/scripts/ntpver b/usr.sbin/ntp/scripts/ntpver
index 6dbc510db8c2..cb216e8a636c 100755
--- a/usr.sbin/ntp/scripts/ntpver
+++ b/usr.sbin/ntp/scripts/ntpver
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
# print version string of NTP daemon
# Copyright (c) 1997 by Ulrich Windl
# Modified 970318: Harlan Stenn: rewritten...
diff --git a/usr.sbin/ntp/sntp/Makefile b/usr.sbin/ntp/sntp/Makefile
index 11a9a5af8e9d..ebbfb77b4fab 100644
--- a/usr.sbin/ntp/sntp/Makefile
+++ b/usr.sbin/ntp/sntp/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
@@ -11,9 +10,9 @@ SRCS= crypto.c kod_management.c log.c main.c networking.c \
CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
-I${SRCTOP}/contrib/ntp/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/unix/include \
- -I${SRCTOP}/contrib/ntp/lib/isc/pthreads/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/unix/include \
+ -I${SRCTOP}/contrib/ntp/libntp/lib/isc/pthreads/include \
-I${SRCTOP}/contrib/ntp/sntp \
-I${SRCTOP}/contrib/ntp/sntp/libopts \
-I${SRCTOP}/contrib/ntp/sntp/libevent/include \
diff --git a/usr.sbin/ntp/sntp/Makefile.depend b/usr.sbin/ntp/sntp/Makefile.depend
index c859ede595b8..fdd3beeaa837 100644
--- a/usr.sbin/ntp/sntp/Makefile.depend
+++ b/usr.sbin/ntp/sntp/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ntp/sntp/Makefile.depend.options b/usr.sbin/ntp/sntp/Makefile.depend.options
index fa96b2506b2c..b374d7a1fd52 100644
--- a/usr.sbin/ntp/sntp/Makefile.depend.options
+++ b/usr.sbin/ntp/sntp/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= OPENSSL
diff --git a/usr.sbin/nvram/Makefile b/usr.sbin/nvram/Makefile
index 2c6e43c8fcb4..66ae05294526 100644
--- a/usr.sbin/nvram/Makefile
+++ b/usr.sbin/nvram/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= nvram
MAN= nvram.8
diff --git a/usr.sbin/nvram/nvram.8 b/usr.sbin/nvram/nvram.8
index 7a8794c53814..f0b63cdbc731 100644
--- a/usr.sbin/nvram/nvram.8
+++ b/usr.sbin/nvram/nvram.8
@@ -23,8 +23,6 @@
.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 19, 2020
.Dt NVRAM 8 powerpc
.Os
diff --git a/usr.sbin/nvram/nvram.c b/usr.sbin/nvram/nvram.c
index 52c1e809ae71..bc0b55fed844 100644
--- a/usr.sbin/nvram/nvram.c
+++ b/usr.sbin/nvram/nvram.c
@@ -22,8 +22,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$
*/
#include <sys/types.h>
@@ -41,7 +39,7 @@
#define DEVICE_NAME (_PATH_DEV "powermac_nvram")
-static void usage(void);
+static void usage(void) __dead2;
static int remove_var(uint8_t *, int, const char *);
static int append_var(uint8_t *, int, const char *, const char *);
diff --git a/usr.sbin/ofwdump/Makefile b/usr.sbin/ofwdump/Makefile
index ca4f4868db53..cd867da9d0fa 100644
--- a/usr.sbin/ofwdump/Makefile
+++ b/usr.sbin/ofwdump/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= ofwdump
MAN= ofwdump.8
diff --git a/usr.sbin/ofwdump/Makefile.depend b/usr.sbin/ofwdump/Makefile.depend
index 2ff61520f354..ee629ba230bb 100644
--- a/usr.sbin/ofwdump/Makefile.depend
+++ b/usr.sbin/ofwdump/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ofwdump/ofw_util.c b/usr.sbin/ofwdump/ofw_util.c
index 71361d452511..0e825a4e5430 100644
--- a/usr.sbin/ofwdump/ofw_util.c
+++ b/usr.sbin/ofwdump/ofw_util.c
@@ -23,9 +23,6 @@
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/ioctl.h>
diff --git a/usr.sbin/ofwdump/ofw_util.h b/usr.sbin/ofwdump/ofw_util.h
index af8f01f233b2..f843496e537c 100644
--- a/usr.sbin/ofwdump/ofw_util.h
+++ b/usr.sbin/ofwdump/ofw_util.h
@@ -21,8 +21,6 @@
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef OFW_UTIL_H
diff --git a/usr.sbin/ofwdump/ofwdump.8 b/usr.sbin/ofwdump/ofwdump.8
index ecd98bf34c69..2e9b280d4ab5 100644
--- a/usr.sbin/ofwdump/ofwdump.8
+++ b/usr.sbin/ofwdump/ofwdump.8
@@ -21,9 +21,7 @@
.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
.\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd February 26, 2022
+.Dd October 23, 2023
.Dt OFWDUMP 8
.Os
.Sh NAME
@@ -92,6 +90,8 @@ property of the
node as plain string:
.Pp
.Dl "ofwdump -P compatible -S /pci"
+.Sh SEE ALSO
+.Xr openfirm 4
.Sh HISTORY
The
.Nm
diff --git a/usr.sbin/ofwdump/ofwdump.c b/usr.sbin/ofwdump/ofwdump.c
index 6bca1ac839ab..335ae38afa5d 100644
--- a/usr.sbin/ofwdump/ofwdump.c
+++ b/usr.sbin/ofwdump/ofwdump.c
@@ -24,13 +24,12 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <dev/ofw/openfirm.h>
#include <dev/ofw/openfirmio.h>
#include <err.h>
#include <fcntl.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -49,10 +48,10 @@ __FBSDID("$FreeBSD$");
static void usage(void);
static void ofw_indent(int);
-static void ofw_dump_properties(int, phandle_t, int, int, int);
+static void ofw_dump_properties(int, phandle_t, int, bool, bool);
static void ofw_dump_property(int fd, phandle_t n, int level,
- const char *prop, int raw, int str);
-static void ofw_dump(int, const char *, int, int, const char *, int, int);
+ const char *prop, bool raw, bool str);
+static void ofw_dump(int, const char *, bool, bool, const char *, bool, bool);
static void
usage(void)
@@ -68,42 +67,42 @@ int
main(int argc, char *argv[])
{
int opt, i, fd;
- int aflag, pflag, rflag, Rflag, Sflag;
+ bool aflag, pflag, rflag, Rflag, Sflag;
char *Parg;
- aflag = pflag = rflag = Rflag = Sflag = 0;
+ aflag = pflag = rflag = Rflag = Sflag = false;
Parg = NULL;
while ((opt = getopt(argc, argv, "-aprP:RS")) != -1) {
if (opt == '-')
break;
switch (opt) {
case 'a':
- aflag = 1;
- rflag = 1;
+ aflag = true;
+ rflag = true;
break;
case 'p':
if (Parg != NULL)
usage();
- pflag = 1;
+ pflag = true;
break;
case 'r':
- rflag = 1;
+ rflag = true;
break;
case 'P':
if (pflag)
usage();
- pflag = 1;
+ pflag = true;
Parg = optarg;
break;
case 'R':
if (Sflag)
usage();
- Rflag = 1;
+ Rflag = true;
break;
case 'S':
if (Rflag)
usage();
- Sflag = 1;
+ Sflag = true;
break;
case '?':
default:
@@ -141,7 +140,7 @@ ofw_indent(int level)
}
static void
-ofw_dump_properties(int fd, phandle_t n, int level, int raw, int str)
+ofw_dump_properties(int fd, phandle_t n, int level, bool raw, bool str)
{
int nlen;
char prop[OFIOCSUGGPROPNAMELEN];
@@ -152,8 +151,8 @@ ofw_dump_properties(int fd, phandle_t n, int level, int raw, int str)
}
static void
-ofw_dump_property(int fd, phandle_t n, int level, const char *prop, int raw,
- int str)
+ofw_dump_property(int fd, phandle_t n, int level, const char *prop, bool raw,
+ bool str)
{
static void *pbuf = NULL;
static char *visbuf = NULL;
@@ -209,7 +208,7 @@ ofw_dump_property(int fd, phandle_t n, int level, const char *prop, int raw,
static void
ofw_dump_node(int fd, phandle_t n, int level, int rec, int prop,
- const char *pmatch, int raw, int str)
+ const char *pmatch, bool raw, bool str)
{
static void *nbuf = NULL;
static int nblen = 0;
@@ -240,8 +239,8 @@ ofw_dump_node(int fd, phandle_t n, int level, int rec, int prop,
}
static void
-ofw_dump(int fd, const char *start, int rec, int prop, const char *pmatch,
- int raw, int str)
+ofw_dump(int fd, const char *start, bool rec, bool prop, const char *pmatch,
+ bool raw, bool str)
{
phandle_t n;
diff --git a/usr.sbin/ofwdump/pathnames.h b/usr.sbin/ofwdump/pathnames.h
index 32f5fe624db6..86d45dfcfe15 100644
--- a/usr.sbin/ofwdump/pathnames.h
+++ b/usr.sbin/ofwdump/pathnames.h
@@ -21,8 +21,6 @@
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <paths.h>
diff --git a/usr.sbin/pciconf/Makefile b/usr.sbin/pciconf/Makefile
index e288654a4d85..77d2679b4c75 100644
--- a/usr.sbin/pciconf/Makefile
+++ b/usr.sbin/pciconf/Makefile
@@ -1,5 +1,4 @@
# $ANA: Makefile,v 1.1.1.1 1996/09/25 21:12:57 wollman Exp $
-# $FreeBSD$
PROG= pciconf
SRCS= pciconf.c cap.c err.c
diff --git a/usr.sbin/pciconf/Makefile.depend b/usr.sbin/pciconf/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/pciconf/Makefile.depend
+++ b/usr.sbin/pciconf/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/pciconf/cap.c b/usr.sbin/pciconf/cap.c
index eae53acbd250..e252926ab9be 100644
--- a/usr.sbin/pciconf/cap.c
+++ b/usr.sbin/pciconf/cap.c
@@ -30,11 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/types.h>
#include <err.h>
@@ -381,6 +376,118 @@ cap_subvendor(int fd, struct pci_conf *p, uint8_t ptr)
printf("PCI Bridge subvendor=0x%04x subdevice=0x%04x", ssvid, ssid);
}
+static const char *
+cap_secdev_amdiommu_decode_vasize(uint32_t misc0)
+{
+ switch (misc0 & PCIM_AMDIOMMU_MISC0_VASIZE_MASK) {
+ case PCIM_AMDIOMMU_MISC0_VASIZE_32:
+ return ("32bit");
+ case PCIM_AMDIOMMU_MISC0_VASIZE_40:
+ return ("40bit");
+ case PCIM_AMDIOMMU_MISC0_VASIZE_48:
+ return ("48bit");
+ case PCIM_AMDIOMMU_MISC0_VASIZE_64:
+ return ("64bit");
+ default:
+ return ("unknown");
+ }
+}
+
+static const char *
+cap_secdev_amdiommu_decode_pasize(uint32_t misc0)
+{
+ switch (misc0 & PCIM_AMDIOMMU_MISC0_PASIZE_MASK) {
+ case PCIM_AMDIOMMU_MISC0_PASIZE_40:
+ return ("40bit");
+ case PCIM_AMDIOMMU_MISC0_PASIZE_48:
+ return ("48bit");
+ case PCIM_AMDIOMMU_MISC0_PASIZE_52:
+ return ("52bit");
+ default:
+ return ("unknown");
+ }
+}
+
+static const char *
+cap_secdev_amdiommu_decode_gvasize(uint32_t misc0)
+{
+ switch (misc0 & PCIM_AMDIOMMU_MISC0_GVASIZE_MASK) {
+ case PCIM_AMDIOMMU_MISC0_GVASIZE_48:
+ return ("48bit");
+ case PCIM_AMDIOMMU_MISC0_GVASIZE_57:
+ return ("57bit");
+ default:
+ return ("unknown");
+ }
+}
+
+static void
+cap_secdev(int fd, struct pci_conf *p, uint8_t ptr)
+{
+ uint32_t cap_h;
+ uint32_t cap_type, cap_rev;
+ uint32_t base_low, base_high;
+ uint32_t range;
+ uint32_t misc0, misc1;
+ const char *delim;
+
+ cap_h = read_config(fd, &p->pc_sel, ptr + PCIR_AMDIOMMU_CAP_HEADER, 4);
+ cap_type = cap_h & PCIM_AMDIOMMU_CAP_TYPE_MASK;
+ cap_rev = cap_h & PCIM_AMDIOMMU_CAP_REV_MASK;
+ if (cap_type != PCIM_AMDIOMMU_CAP_TYPE_VAL ||
+ cap_rev != PCIM_AMDIOMMU_CAP_REV_VAL) {
+ printf("Secure Device Type=0x%1x Rev=0x%02x\n",
+ cap_type >> 16, cap_rev >> 19);
+ return;
+ }
+ base_low = read_config(fd, &p->pc_sel, ptr + PCIR_AMDIOMMU_BASE_LOW,
+ 4);
+ base_high = read_config(fd, &p->pc_sel, ptr + PCIR_AMDIOMMU_BASE_HIGH,
+ 4);
+ printf("AMD IOMMU Base Capability Base=%#018jx/%sabled",
+ (uintmax_t)(base_low & PCIM_AMDIOMMU_BASE_LOW_ADDRM) +
+ ((uintmax_t)base_high << 32),
+ (base_low & PCIM_AMDIOMMU_BASE_LOW_EN) != 0 ? "En" : "Dis");
+
+ delim = "\n\t\t";
+#define PRINTCAP(bit, name) \
+ if ((cap_h & PCIM_AMDIOMMU_CAP_ ##bit) != 0) { \
+ printf("%s%s", delim, #name); \
+ delim = ","; \
+ }
+ PRINTCAP(CAPEXT, CapExt);
+ PRINTCAP(EFR, EFRSup);
+ PRINTCAP(NPCACHE, NpCache);
+ PRINTCAP(HTTUN, HtTunnel);
+ PRINTCAP(IOTLB, IotlbSup);
+#undef PRINTCAP
+
+ range = read_config(fd, &p->pc_sel, ptr + PCIR_AMDIOMMU_RANGE, 4);
+ printf("\n\t\tUnitId=%d", range & PCIM_AMDIOMMU_RANGE_UNITID_MASK);
+ if ((range & PCIM_AMDIOMMU_RANGE_RNGVALID) != 0) {
+ printf(" BusNum=%#06x FirstDev=%#06x LastDev=%#06x",
+ (range & PCIM_AMDIOMMU_RANGE_BUSNUM_MASK) >> 8,
+ (range & PCIM_AMDIOMMU_RANGE_FIRSTDEV_MASK) >> 16,
+ (range & PCIM_AMDIOMMU_RANGE_LASTDEV_MASK) >> 24);
+ }
+
+ misc0 = read_config(fd, &p->pc_sel, ptr + PCIR_AMDIOMMU_MISC0, 4);
+ printf("\n\t\tMsiNum=%d MsiNumPPR=%d HtAtsResv=%d",
+ misc0 & PCIM_AMDIOMMU_MISC0_MSINUM_MASK,
+ (misc0 & PCIM_AMDIOMMU_MISC0_MSINUMPPR_MASK) >> 27,
+ (misc0 & PCIM_AMDIOMMU_MISC0_HTATSRESV) != 0);
+ if ((cap_h & PCIM_AMDIOMMU_CAP_CAPEXT) != 0) {
+ misc1 = read_config(fd, &p->pc_sel,
+ ptr + PCIR_AMDIOMMU_MISC1, 4);
+ printf(" MsiNumGA=%d",
+ misc1 & PCIM_AMDIOMMU_MISC1_MSINUMGA_MASK);
+ }
+ printf("\n\t\tVAsize=%s PAsize=%s GVAsize=%s",
+ cap_secdev_amdiommu_decode_vasize(misc0),
+ cap_secdev_amdiommu_decode_pasize(misc0),
+ cap_secdev_amdiommu_decode_gvasize(misc0));
+}
+
#define MAX_PAYLOAD(field) (128 << (field))
static const char *
@@ -396,6 +503,10 @@ link_speed_string(uint8_t speed)
return ("8.0");
case 4:
return ("16.0");
+ case 5:
+ return ("32.0");
+ case 6:
+ return ("64.0");
default:
return ("undef");
}
@@ -814,6 +925,9 @@ list_caps(int fd, struct pci_conf *p, int level)
case PCIY_SUBVENDOR:
cap_subvendor(fd, p, ptr);
break;
+ case PCIY_SECDEV:
+ cap_secdev(fd, p, ptr);
+ break;
case PCIY_EXPRESS:
express = 1;
cap_express(fd, p, ptr);
@@ -1016,6 +1130,64 @@ ecap_sriov(int fd, struct pci_conf *p, uint16_t ptr, uint8_t ver)
print_bar(fd, p, "iov bar ", ptr + PCIR_SRIOV_BAR(i));
}
+static const char *
+check_avail_and_state(u_int cap, u_int capbit, u_int ctl, u_int ctlbit)
+{
+
+ if (cap & capbit)
+ return (ctl & ctlbit ? "enabled" : "disabled");
+ else
+ return "unavailable";
+}
+
+static void
+ecap_acs(int fd, struct pci_conf *p, uint16_t ptr, uint8_t ver)
+{
+ uint16_t acs_cap, acs_ctl;
+ static const char *const acc[] = { "access enabled", "blocking enabled",
+ "redirect enabled", "reserved" };
+
+ printf("ACS %d ", ver);
+ if (ver != 1) {
+ printf("\n");
+ return;
+ }
+
+#define CHECK_AVAIL_STATE(bit) \
+ check_avail_and_state(acs_cap, bit, acs_ctl, bit##_ENABLE)
+
+ acs_cap = read_config(fd, &p->pc_sel, ptr + PCIR_ACS_CAP, 2);
+ acs_ctl = read_config(fd, &p->pc_sel, ptr + PCIR_ACS_CTL, 2);
+ printf("Source Validation %s, Translation Blocking %s\n",
+ CHECK_AVAIL_STATE(PCIM_ACS_SOURCE_VALIDATION),
+ CHECK_AVAIL_STATE(PCIM_ACS_TRANSLATION_BLOCKING));
+
+ printf(" ");
+ printf("P2P Req Redirect %s, P2P Cmpl Redirect %s\n",
+ CHECK_AVAIL_STATE(PCIM_ACS_P2P_REQ_REDIRECT),
+ CHECK_AVAIL_STATE(PCIM_ACS_P2P_CMP_REDIRECT));
+ printf(" ");
+ printf("P2P Upstream Forwarding %s, P2P Egress Control %s\n",
+ CHECK_AVAIL_STATE(PCIM_ACS_P2P_UPSTREAM_FORWARDING),
+ CHECK_AVAIL_STATE(PCIM_ACS_P2P_EGRESS_CTL));
+ printf(" ");
+ printf("P2P Direct Translated %s, Enhanced Capability %s\n",
+ CHECK_AVAIL_STATE(PCIM_ACS_P2P_DIRECT_TRANSLATED),
+ acs_ctl & PCIM_ACS_ENHANCED_CAP ? "available" : "unavailable");
+#undef CHECK_AVAIL_STATE
+
+ if (acs_cap & PCIM_ACS_ENHANCED_CAP) {
+ printf(" ");
+ printf("I/O Req Blocking %s, Unclaimed Req Redirect Control %s\n",
+ check_enabled(acs_ctl & PCIM_ACS_IO_REQ_BLOCKING_ENABLE),
+ check_enabled(acs_ctl & PCIM_ACS_UNCLAIMED_REQ_REDIRECT_CTL));
+ printf(" ");
+ printf("DSP BAR %s, USP BAR %s\n",
+ acc[(acs_cap & PCIM_ACS_DSP_MEM_TGT_ACC_CTL) >> 8],
+ acc[(acs_cap & PCIM_ACS_USP_MEM_TGT_ACC_CTL) >> 10]);
+ }
+}
+
static struct {
uint16_t id;
const char *name;
@@ -1099,6 +1271,9 @@ list_ecaps(int fd, struct pci_conf *p)
case PCIZ_SRIOV:
ecap_sriov(fd, p, ptr, PCI_EXTCAP_VER(ecap));
break;
+ case PCIZ_ACS:
+ ecap_acs(fd, p, ptr, PCI_EXTCAP_VER(ecap));
+ break;
default:
name = "unknown";
for (i = 0; ecap_names[i].name != NULL; i++)
diff --git a/usr.sbin/pciconf/err.c b/usr.sbin/pciconf/err.c
index 9092b62ef021..dca0ca1cea87 100644
--- a/usr.sbin/pciconf/err.c
+++ b/usr.sbin/pciconf/err.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 Hudson River Trading LLC
* Written by: John H. Baldwin <jhb@FreeBSD.org>
@@ -27,11 +27,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/pciio.h>
diff --git a/usr.sbin/pciconf/pathnames.h b/usr.sbin/pciconf/pathnames.h
index c35c721aa838..7e8e562b94a1 100644
--- a/usr.sbin/pciconf/pathnames.h
+++ b/usr.sbin/pciconf/pathnames.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#include <paths.h>
#define _PATH_DEVPCI "/dev/pci"
diff --git a/usr.sbin/pciconf/pciconf.8 b/usr.sbin/pciconf/pciconf.8
index 24dccb1aa321..4e46d502887a 100644
--- a/usr.sbin/pciconf/pciconf.8
+++ b/usr.sbin/pciconf/pciconf.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 14, 2018
.Dt PCICONF 8
.Os
diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c
index 946adc080720..83ea50efb183 100644
--- a/usr.sbin/pciconf/pciconf.c
+++ b/usr.sbin/pciconf/pciconf.c
@@ -27,11 +27,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/mman.h>
diff --git a/usr.sbin/pciconf/pciconf.h b/usr.sbin/pciconf/pciconf.h
index 353c361f302a..bdb8d44cbb3f 100644
--- a/usr.sbin/pciconf/pciconf.h
+++ b/usr.sbin/pciconf/pciconf.h
@@ -28,8 +28,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 __PCICONF_H__
diff --git a/usr.sbin/periodic/Makefile b/usr.sbin/periodic/Makefile
index 62a1cff105a2..f991bbd6ae1e 100644
--- a/usr.sbin/periodic/Makefile
+++ b/usr.sbin/periodic/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= periodic
diff --git a/usr.sbin/periodic/Makefile.depend b/usr.sbin/periodic/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/periodic/Makefile.depend
+++ b/usr.sbin/periodic/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/periodic/etc/Makefile b/usr.sbin/periodic/etc/Makefile
index a2d99020fd10..6678f16a49d4 100644
--- a/usr.sbin/periodic/etc/Makefile
+++ b/usr.sbin/periodic/etc/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= daily security weekly monthly
SUBDIR_PARALLEL=
diff --git a/usr.sbin/periodic/etc/Makefile.inc b/usr.sbin/periodic/etc/Makefile.inc
index a1fed7ac7afb..dcd34a07dee9 100644
--- a/usr.sbin/periodic/etc/Makefile.inc
+++ b/usr.sbin/periodic/etc/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
CONFMODE= 755
CONFDIR= ETC_PERIODIC_${.CURDIR:T:U}
diff --git a/usr.sbin/periodic/etc/daily/100.clean-disks b/usr.sbin/periodic/etc/daily/100.clean-disks
index b4ebf3083bc5..7eedcfce6f96 100755
--- a/usr.sbin/periodic/etc/daily/100.clean-disks
+++ b/usr.sbin/periodic/etc/daily/100.clean-disks
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# Remove garbage files more than $daily_clean_disks_days days old
#
diff --git a/usr.sbin/periodic/etc/daily/110.clean-tmps b/usr.sbin/periodic/etc/daily/110.clean-tmps
index 67bcec6f00d3..4780aa72aa42 100755
--- a/usr.sbin/periodic/etc/daily/110.clean-tmps
+++ b/usr.sbin/periodic/etc/daily/110.clean-tmps
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# Perform temporary directory cleaning so that long-lived systems
# don't end up with excessively old files there.
diff --git a/usr.sbin/periodic/etc/daily/120.clean-preserve b/usr.sbin/periodic/etc/daily/120.clean-preserve
index d5b34a12c385..9c2bc86ae48a 100755
--- a/usr.sbin/periodic/etc/daily/120.clean-preserve
+++ b/usr.sbin/periodic/etc/daily/120.clean-preserve
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# Remove stale files in /var/preserve
#
diff --git a/usr.sbin/periodic/etc/daily/130.clean-msgs b/usr.sbin/periodic/etc/daily/130.clean-msgs
index b7890db6d954..df9f6ef2c1e1 100755
--- a/usr.sbin/periodic/etc/daily/130.clean-msgs
+++ b/usr.sbin/periodic/etc/daily/130.clean-msgs
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# Remove system messages
#
diff --git a/usr.sbin/periodic/etc/daily/140.clean-rwho b/usr.sbin/periodic/etc/daily/140.clean-rwho
index 9645d7e60bf7..b34fa80c58f7 100755
--- a/usr.sbin/periodic/etc/daily/140.clean-rwho
+++ b/usr.sbin/periodic/etc/daily/140.clean-rwho
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# Remove stale files in /var/rwho
#
diff --git a/usr.sbin/periodic/etc/daily/150.clean-hoststat b/usr.sbin/periodic/etc/daily/150.clean-hoststat
index 460d1a267908..5d2ba42831ee 100755
--- a/usr.sbin/periodic/etc/daily/150.clean-hoststat
+++ b/usr.sbin/periodic/etc/daily/150.clean-hoststat
@@ -1,8 +1,7 @@
#!/bin/sh
#
-# $FreeBSD$
#
-# Remove stale persistent host status files
+# Remove stale persistent host status files if the mailer supports it.
#
# If there is a global system configuration file, suck it in.
@@ -14,7 +13,9 @@ fi
case "$daily_clean_hoststat_enable" in
[Yy][Ee][Ss])
- if [ -z "$(hoststat 2>&1)" ]; then
+ if ! grep -q '^purgestat' /etc/mail/mailer.conf; then
+ rc=3
+ elif [ -z "$(hoststat 2>&1)" ]; then
rc=2
else
echo ""
diff --git a/usr.sbin/periodic/etc/daily/200.backup-passwd b/usr.sbin/periodic/etc/daily/200.backup-passwd
index 1e9bb8964047..7cd52fc7be4b 100755
--- a/usr.sbin/periodic/etc/daily/200.backup-passwd
+++ b/usr.sbin/periodic/etc/daily/200.backup-passwd
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
@@ -41,7 +40,7 @@ case "$daily_backup_passwd_enable" in
then
[ $rc -lt 1 ] && rc=1
echo "$host passwd diffs:"
- diff -uI '^#' $bak/master.passwd.bak /etc/master.passwd |\
+ diff ${daily_diff_flags} -I '^#' $bak/master.passwd.bak /etc/master.passwd |\
sed 's/^\([-+ ][^:]*\):[^:]*:/\1:(password):/'
mv $bak/master.passwd.bak $bak/master.passwd.bak2
cp -p /etc/master.passwd $bak/master.passwd.bak || rc=3
@@ -58,7 +57,7 @@ case "$daily_backup_passwd_enable" in
then
[ $rc -lt 1 ] && rc=1
echo "$host group diffs:"
- diff -u $bak/group.bak /etc/group
+ diff ${daily_diff_flags} $bak/group.bak /etc/group
mv $bak/group.bak $bak/group.bak2
cp -p /etc/group $bak/group.bak || rc=3
fi
diff --git a/usr.sbin/periodic/etc/daily/210.backup-aliases b/usr.sbin/periodic/etc/daily/210.backup-aliases
index fe170389ef03..d236d9615dba 100755
--- a/usr.sbin/periodic/etc/daily/210.backup-aliases
+++ b/usr.sbin/periodic/etc/daily/210.backup-aliases
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
@@ -35,7 +34,7 @@ case "$daily_backup_aliases_enable" in
then
[ $rc -lt 1 ] && rc=1
echo "$host aliases diffs:"
- diff -u $bak/aliases.bak /etc/mail/aliases
+ diff ${daily_diff_flags} $bak/aliases.bak /etc/mail/aliases
mv $bak/aliases.bak $bak/aliases.bak2
cp -p /etc/mail/aliases $bak/aliases.bak || rc=3
fi
diff --git a/usr.sbin/periodic/etc/daily/221.backup-gpart b/usr.sbin/periodic/etc/daily/221.backup-gpart
index b2bfde820272..50096e38f118 100755
--- a/usr.sbin/periodic/etc/daily/221.backup-gpart
+++ b/usr.sbin/periodic/etc/daily/221.backup-gpart
@@ -1,6 +1,4 @@
#!/bin/sh
-
-## $FreeBSD$
## Created by: Miroslav Lachman <000.fbsd@quip.cz>
## Backup of disk partitions layout, useful for gpart restore.
@@ -29,7 +27,7 @@ rotate() {
rm "${file}.tmp"
else
rc=1
- [ -n "$show_diff" ] && diff "${file}.bak" "${file}.tmp"
+ [ -n "$show_diff" ] && diff ${daily_diff_flags} "${file}.bak" "${file}.tmp"
mv "${file}.bak" "${file}.bak2" || rc=3
mv "${file}.tmp" "${file}.bak" || rc=3
fi
diff --git a/usr.sbin/periodic/etc/daily/222.backup-gmirror b/usr.sbin/periodic/etc/daily/222.backup-gmirror
index 2b14a2d4d5c6..45c656dc4f41 100755
--- a/usr.sbin/periodic/etc/daily/222.backup-gmirror
+++ b/usr.sbin/periodic/etc/daily/222.backup-gmirror
@@ -1,6 +1,4 @@
#!/bin/sh
-
-# $FreeBSD$
# Created by: Miroslav Lachman <000.fbsd@quip.cz>
# Backup output from `gmirror list`, which provides detailed information
@@ -27,7 +25,7 @@ rotate() {
rm "${file}.tmp"
else
rc=1
- [ -n "$show_diff" ] && diff "${file}.bak" "${file}.tmp"
+ [ -n "$show_diff" ] && diff ${daily_diff_flags} "${file}.bak" "${file}.tmp"
mv "${file}.bak" "${file}.bak2" || rc=3
mv "${file}.tmp" "${file}.bak" || rc=3
fi
diff --git a/usr.sbin/periodic/etc/daily/223.backup-zfs b/usr.sbin/periodic/etc/daily/223.backup-zfs
index e263775fb53f..e76421220a0b 100755
--- a/usr.sbin/periodic/etc/daily/223.backup-zfs
+++ b/usr.sbin/periodic/etc/daily/223.backup-zfs
@@ -1,6 +1,4 @@
#!/bin/sh
-
-# $FreeBSD$
# Created by: Miroslav Lachman <000.fbsd@quip.cz>
# Backup of zpool list, zfs list, zpool properties and zfs properties
@@ -15,6 +13,7 @@ then
fi
bak_dir=/var/backups
+rc=0
rotate() {
base_name=$1
@@ -22,12 +21,13 @@ rotate() {
file="$bak_dir/$base_name"
if [ -f "${file}.bak" ] ; then
- rc=0
if cmp -s "${file}.bak" "${file}.tmp"; then
rm "${file}.tmp"
else
- rc=1
- [ -n "$show_diff" ] && diff "${file}.bak" "${file}.tmp"
+ if [ -n "$show_diff" ]; then
+ rc=1
+ diff ${daily_diff_flags} "${file}.bak" "${file}.tmp"
+ fi
mv "${file}.bak" "${file}.bak2" || rc=3
mv "${file}.tmp" "${file}.bak" || rc=3
fi
@@ -38,6 +38,7 @@ rotate() {
fi
}
+show=""
case "$daily_backup_zfs_verbose" in
[Yy][Ee][Ss]) show="YES"
esac
@@ -45,9 +46,9 @@ esac
case "$daily_backup_zfs_enable" in
[Yy][Ee][Ss])
- zpools=$(zpool list $daily_backup_zpool_list_flags)
+ zpools=$(zpool list $daily_backup_zpool_list_flags)
- if [ -z "$zpools" ]; then
+ if [ -z "$zpools" ]; then
echo 'daily_backup_zfs_enable is set to YES but no zpools found.'
rc=2
else
@@ -61,18 +62,17 @@ case "$daily_backup_zfs_enable" in
rotate "zfs_list" $show
fi
;;
- *) rc=0;;
esac
case "$daily_backup_zfs_props_enable" in
- [Yy][Ee][Ss])
+ [Yy][Ee][Ss])
- zfs get $daily_backup_zfs_get_flags > "$bak_dir/zfs_props.tmp"
- rotate "zfs_props"
+ zfs get $daily_backup_zfs_get_flags > "$bak_dir/zfs_props.tmp"
+ rotate "zfs_props" $show
- zpool get $daily_backup_zpool_get_flags > "$bak_dir/zpool_props.tmp"
- rotate "zpool_props"
- ;;
+ zpool get $daily_backup_zpool_get_flags > "$bak_dir/zpool_props.tmp"
+ rotate "zpool_props" $show
+ ;;
esac
exit $rc
diff --git a/usr.sbin/periodic/etc/daily/300.calendar b/usr.sbin/periodic/etc/daily/300.calendar
index cc12097162e5..3be90a8c4754 100755
--- a/usr.sbin/periodic/etc/daily/300.calendar
+++ b/usr.sbin/periodic/etc/daily/300.calendar
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# `calendar -a' needs to die. Why? Because it's a bad idea, particular
# with networked home directories, but also in general. If you want the
diff --git a/usr.sbin/periodic/etc/daily/310.accounting b/usr.sbin/periodic/etc/daily/310.accounting
index b0dd786447eb..861a22720236 100755
--- a/usr.sbin/periodic/etc/daily/310.accounting
+++ b/usr.sbin/periodic/etc/daily/310.accounting
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
@@ -18,6 +17,11 @@ case "$daily_accounting_enable" in
echo '$daily_accounting_enable is set but /var/account/acct' \
"doesn't exist"
rc=2
+ elif [ $(sysctl -n kern.acct_configured) -eq 0 ]
+ then
+ echo '$daily_accounting_enable is set but' \
+ 'process accounting is not active'
+ rc=2
elif [ -z "$daily_accounting_save" ]
then
echo '$daily_accounting_enable is set but ' \
diff --git a/usr.sbin/periodic/etc/daily/400.status-disks b/usr.sbin/periodic/etc/daily/400.status-disks
index bab281097dbd..cc1fe8dc0ab3 100755
--- a/usr.sbin/periodic/etc/daily/400.status-disks
+++ b/usr.sbin/periodic/etc/daily/400.status-disks
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/401.status-graid b/usr.sbin/periodic/etc/daily/401.status-graid
index a28fc5bbe569..259722a94a0c 100755
--- a/usr.sbin/periodic/etc/daily/401.status-graid
+++ b/usr.sbin/periodic/etc/daily/401.status-graid
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/404.status-zfs b/usr.sbin/periodic/etc/daily/404.status-zfs
index df23bae7a37e..052f794c0bbc 100755
--- a/usr.sbin/periodic/etc/daily/404.status-zfs
+++ b/usr.sbin/periodic/etc/daily/404.status-zfs
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/406.status-gmirror b/usr.sbin/periodic/etc/daily/406.status-gmirror
index 8fc698c804d2..06fbb9491576 100755
--- a/usr.sbin/periodic/etc/daily/406.status-gmirror
+++ b/usr.sbin/periodic/etc/daily/406.status-gmirror
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/407.status-graid3 b/usr.sbin/periodic/etc/daily/407.status-graid3
index 52750f7d88e5..af73ca4dd754 100755
--- a/usr.sbin/periodic/etc/daily/407.status-graid3
+++ b/usr.sbin/periodic/etc/daily/407.status-graid3
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/408.status-gstripe b/usr.sbin/periodic/etc/daily/408.status-gstripe
index ff74f76e3c7c..1a4c9f053747 100755
--- a/usr.sbin/periodic/etc/daily/408.status-gstripe
+++ b/usr.sbin/periodic/etc/daily/408.status-gstripe
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/409.status-gconcat b/usr.sbin/periodic/etc/daily/409.status-gconcat
index 7dfa91812f68..2fabac1caeed 100755
--- a/usr.sbin/periodic/etc/daily/409.status-gconcat
+++ b/usr.sbin/periodic/etc/daily/409.status-gconcat
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/410.status-mfi b/usr.sbin/periodic/etc/daily/410.status-mfi
index 6e13fbb5a74f..141cd777380c 100644
--- a/usr.sbin/periodic/etc/daily/410.status-mfi
+++ b/usr.sbin/periodic/etc/daily/410.status-mfi
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/420.status-network b/usr.sbin/periodic/etc/daily/420.status-network
index 03166a915a1a..955d6b0e9146 100755
--- a/usr.sbin/periodic/etc/daily/420.status-network
+++ b/usr.sbin/periodic/etc/daily/420.status-network
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/430.status-uptime b/usr.sbin/periodic/etc/daily/430.status-uptime
index 0c8c591a5973..19c4bcd0b0d0 100755
--- a/usr.sbin/periodic/etc/daily/430.status-uptime
+++ b/usr.sbin/periodic/etc/daily/430.status-uptime
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/440.status-mailq b/usr.sbin/periodic/etc/daily/440.status-mailq
index 515f9f42ead9..ad2c7f6af293 100755
--- a/usr.sbin/periodic/etc/daily/440.status-mailq
+++ b/usr.sbin/periodic/etc/daily/440.status-mailq
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
@@ -38,7 +37,7 @@ case "$daily_status_mailq_enable" in
case "$daily_status_include_submit_mailq" in
[Yy][Ee][Ss])
- if [ -f /etc/mail/submit.cf ]
+ if [ -f /etc/mail/submit.cf ] && mailq -Ac >/dev/null 2>&1
then
echo ""
echo "Mail in submit queue:"
diff --git a/usr.sbin/periodic/etc/daily/450.status-security b/usr.sbin/periodic/etc/daily/450.status-security
index 31b6d4cf524e..c004e0ae98ac 100755
--- a/usr.sbin/periodic/etc/daily/450.status-security
+++ b/usr.sbin/periodic/etc/daily/450.status-security
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/460.status-mail-rejects b/usr.sbin/periodic/etc/daily/460.status-mail-rejects
index 6161a5525cc1..b33e0062f3d7 100755
--- a/usr.sbin/periodic/etc/daily/460.status-mail-rejects
+++ b/usr.sbin/periodic/etc/daily/460.status-mail-rejects
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/480.leapfile-ntpd b/usr.sbin/periodic/etc/daily/480.leapfile-ntpd
index a693986e0dd1..c7de845ea87d 100755
--- a/usr.sbin/periodic/etc/daily/480.leapfile-ntpd
+++ b/usr.sbin/periodic/etc/daily/480.leapfile-ntpd
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
@@ -13,9 +12,9 @@ fi
case "$daily_ntpd_leapfile_enable" in
[Yy][Ee][Ss])
- if service ntpd oneneedfetch; then
+ if service ntpd enabled && service ntpd needfetch; then
anticongestion
- service ntpd onefetch
+ service ntpd fetch
fi
;;
esac
diff --git a/usr.sbin/periodic/etc/daily/480.status-ntpd b/usr.sbin/periodic/etc/daily/480.status-ntpd
index 1ff5cc516f5a..f77910befea8 100755
--- a/usr.sbin/periodic/etc/daily/480.status-ntpd
+++ b/usr.sbin/periodic/etc/daily/480.status-ntpd
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/500.queuerun b/usr.sbin/periodic/etc/daily/500.queuerun
index f46c24614b2c..cdc4e979b5a8 100755
--- a/usr.sbin/periodic/etc/daily/500.queuerun
+++ b/usr.sbin/periodic/etc/daily/500.queuerun
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/510.status-world-kernel b/usr.sbin/periodic/etc/daily/510.status-world-kernel
index 4e08a04d2a25..e9ebc0a830a9 100755
--- a/usr.sbin/periodic/etc/daily/510.status-world-kernel
+++ b/usr.sbin/periodic/etc/daily/510.status-world-kernel
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# Check that the running userland and kernel versions are in sync.
diff --git a/usr.sbin/periodic/etc/daily/800.scrub-zfs b/usr.sbin/periodic/etc/daily/800.scrub-zfs
index 8cca1ea4d949..3a19c09b4698 100755
--- a/usr.sbin/periodic/etc/daily/800.scrub-zfs
+++ b/usr.sbin/periodic/etc/daily/800.scrub-zfs
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/daily/801.trim-zfs b/usr.sbin/periodic/etc/daily/801.trim-zfs
new file mode 100755
index 000000000000..17d2ce217c10
--- /dev/null
+++ b/usr.sbin/periodic/etc/daily/801.trim-zfs
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+#
+
+# If there is a global system configuration file, suck it in.
+#
+
+if [ -r /etc/defaults/periodic.conf ]
+then
+ . /etc/defaults/periodic.conf
+ source_periodic_confs
+fi
+
+case "$daily_trim_zfs_enable" in
+ [Yy][Ee][Ss])
+ echo
+ echo 'Trimming of zfs pools:'
+
+ if [ -z "${daily_trim_zfs_pools}" ]; then
+ daily_trim_zfs_pools="$(zpool list -H -o name)"
+ fi
+
+ rc=0
+ for pool in ${daily_trim_zfs_pools}; do
+ # sanity check
+ _status=$(zpool list -Hohealth "${pool}" 2> /dev/null)
+ if [ $? -ne 0 ]; then
+ rc=2
+ echo " WARNING: pool '${pool}' specified in"
+ echo " '/etc/periodic.conf:daily_trim_zfs_pools'"
+ echo " does not exist"
+ continue
+ fi
+ case ${_status} in
+ FAULTED)
+ rc=3
+ echo "Skipping faulted pool: ${pool}"
+ continue ;;
+ UNAVAIL)
+ rc=4
+ echo "Skipping unavailable pool: ${pool}"
+ continue ;;
+ esac
+
+ if ! zpool status "${pool}" | grep -q '(trimming)'; then
+ echo " starting trim of pool '${pool}'"
+ zpool trim ${daily_zfs_trim_flags} "${pool}"
+ else
+ echo " trim of pool '${pool}' already in progress, skipping"
+ fi
+ done
+ ;;
+
+ *)
+ rc=0
+ ;;
+esac
+
+exit $rc
diff --git a/usr.sbin/periodic/etc/daily/999.local b/usr.sbin/periodic/etc/daily/999.local
index eca04e5771b8..29c410f416b3 100755
--- a/usr.sbin/periodic/etc/daily/999.local
+++ b/usr.sbin/periodic/etc/daily/999.local
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# Run the old /etc/daily.local script. This is really for backwards
# compatibility more than anything else.
diff --git a/usr.sbin/periodic/etc/daily/Makefile b/usr.sbin/periodic/etc/daily/Makefile
index fefe35eebe18..3bf4601f5145 100644
--- a/usr.sbin/periodic/etc/daily/Makefile
+++ b/usr.sbin/periodic/etc/daily/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
@@ -61,7 +60,8 @@ SENDMAILPACKAGE= sendmail
.if ${MK_ZFS} != "no"
CONFS+= 223.backup-zfs \
404.status-zfs \
- 800.scrub-zfs
+ 800.scrub-zfs \
+ 801.trim-zfs
.endif
.include <bsd.prog.mk>
diff --git a/usr.sbin/periodic/etc/monthly/200.accounting b/usr.sbin/periodic/etc/monthly/200.accounting
index 9d50ba182777..0571bebeabf0 100755
--- a/usr.sbin/periodic/etc/monthly/200.accounting
+++ b/usr.sbin/periodic/etc/monthly/200.accounting
@@ -1,6 +1,5 @@
#!/bin/sh -
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/monthly/450.status-security b/usr.sbin/periodic/etc/monthly/450.status-security
index 61e6b92387bd..ad6312c3cb20 100755
--- a/usr.sbin/periodic/etc/monthly/450.status-security
+++ b/usr.sbin/periodic/etc/monthly/450.status-security
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/monthly/999.local b/usr.sbin/periodic/etc/monthly/999.local
index a017a69540e5..154d8dfe090c 100755
--- a/usr.sbin/periodic/etc/monthly/999.local
+++ b/usr.sbin/periodic/etc/monthly/999.local
@@ -1,6 +1,5 @@
#!/bin/sh -
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/monthly/Makefile b/usr.sbin/periodic/etc/monthly/Makefile
index b4aaf6967891..8de5d5d81c03 100644
--- a/usr.sbin/periodic/etc/monthly/Makefile
+++ b/usr.sbin/periodic/etc/monthly/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/periodic/etc/security/100.chksetuid b/usr.sbin/periodic/etc/security/100.chksetuid
index 670ae9792021..071d296cdaff 100755
--- a/usr.sbin/periodic/etc/security/100.chksetuid
+++ b/usr.sbin/periodic/etc/security/100.chksetuid
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
@@ -54,7 +53,7 @@ then
}'`
find -sx $MP /dev/null \( ! -fstype local \) -prune -o -type f \
\( -perm -u+x -or -perm -g+x -or -perm -o+x \) \
- \( -perm -u+s -or -perm -g+s \) -exec ls -liTd \{\} \+ |
+ \( -perm -u+s -or -perm -g+s \) -exec ls -lid -D "%FT%T" \{\} \+ |
check_diff setuid - "${host} setuid diffs:"
rc=$?
fi
diff --git a/usr.sbin/periodic/etc/security/110.neggrpperm b/usr.sbin/periodic/etc/security/110.neggrpperm
index 55974eae6345..6def25fc6a0e 100755
--- a/usr.sbin/periodic/etc/security/110.neggrpperm
+++ b/usr.sbin/periodic/etc/security/110.neggrpperm
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
@@ -54,7 +53,7 @@ then
\( \( ! -perm +010 -and -perm +001 \) -or \
\( ! -perm +020 -and -perm +002 \) -or \
\( ! -perm +040 -and -perm +004 \) \) \
- -exec ls -liTd \{\} \+ | tee /dev/stderr | wc -l)
+ -exec ls -lid -D "%FT%T" \{\} \+ | tee /dev/stderr | wc -l)
[ $n -gt 0 ] && rc=1 || rc=0
fi
diff --git a/usr.sbin/periodic/etc/security/200.chkmounts b/usr.sbin/periodic/etc/security/200.chkmounts
index 7b14866869bb..c6405bb86467 100755
--- a/usr.sbin/periodic/etc/security/200.chkmounts
+++ b/usr.sbin/periodic/etc/security/200.chkmounts
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Show changes in the way filesystems are mounted
diff --git a/usr.sbin/periodic/etc/security/300.chkuid0 b/usr.sbin/periodic/etc/security/300.chkuid0
index 73578e241553..121734357d06 100755
--- a/usr.sbin/periodic/etc/security/300.chkuid0
+++ b/usr.sbin/periodic/etc/security/300.chkuid0
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
diff --git a/usr.sbin/periodic/etc/security/400.passwdless b/usr.sbin/periodic/etc/security/400.passwdless
index 5e851ac847c7..10a80ce43370 100755
--- a/usr.sbin/periodic/etc/security/400.passwdless
+++ b/usr.sbin/periodic/etc/security/400.passwdless
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/security/410.logincheck b/usr.sbin/periodic/etc/security/410.logincheck
index 41e7f65ebf1b..7e1ac5ec1b67 100755
--- a/usr.sbin/periodic/etc/security/410.logincheck
+++ b/usr.sbin/periodic/etc/security/410.logincheck
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/security/500.ipfwdenied b/usr.sbin/periodic/etc/security/500.ipfwdenied
index f39ca0ed9531..f2a435711805 100755
--- a/usr.sbin/periodic/etc/security/500.ipfwdenied
+++ b/usr.sbin/periodic/etc/security/500.ipfwdenied
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/security/510.ipfdenied b/usr.sbin/periodic/etc/security/510.ipfdenied
index bed75e645c2a..3350bfd40fcf 100755
--- a/usr.sbin/periodic/etc/security/510.ipfdenied
+++ b/usr.sbin/periodic/etc/security/510.ipfdenied
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/security/520.pfdenied b/usr.sbin/periodic/etc/security/520.pfdenied
index 31e80cf3acab..6af474712d6f 100755
--- a/usr.sbin/periodic/etc/security/520.pfdenied
+++ b/usr.sbin/periodic/etc/security/520.pfdenied
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/security/550.ipfwlimit b/usr.sbin/periodic/etc/security/550.ipfwlimit
index 86932c676c7a..7b6f915a1ac5 100755
--- a/usr.sbin/periodic/etc/security/550.ipfwlimit
+++ b/usr.sbin/periodic/etc/security/550.ipfwlimit
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Show ipfw rules which have reached the log limit
diff --git a/usr.sbin/periodic/etc/security/610.ipf6denied b/usr.sbin/periodic/etc/security/610.ipf6denied
index 7e02cfc583f3..a7902e504baa 100755
--- a/usr.sbin/periodic/etc/security/610.ipf6denied
+++ b/usr.sbin/periodic/etc/security/610.ipf6denied
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/security/700.kernelmsg b/usr.sbin/periodic/etc/security/700.kernelmsg
index 8bf6491901ed..cd4391aad98d 100755
--- a/usr.sbin/periodic/etc/security/700.kernelmsg
+++ b/usr.sbin/periodic/etc/security/700.kernelmsg
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Show kernel log messages
diff --git a/usr.sbin/periodic/etc/security/800.loginfail b/usr.sbin/periodic/etc/security/800.loginfail
index ef169482001c..c5a3a972aaa1 100755
--- a/usr.sbin/periodic/etc/security/800.loginfail
+++ b/usr.sbin/periodic/etc/security/800.loginfail
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Show login failures
@@ -50,12 +49,7 @@ catmsgs() {
sort -t. -r -n -k 2,2 |
while read f
do
- case $f in
- *.gz) zcat -f $f;;
- *.bz2) bzcat -f $f;;
- *.xz) xzcat -f $f;;
- *.zst) zstdcat -f $f;;
- esac
+ zcat -f $f
done
[ -f ${LOG}/auth.log ] && cat $LOG/auth.log
}
diff --git a/usr.sbin/periodic/etc/security/900.tcpwrap b/usr.sbin/periodic/etc/security/900.tcpwrap
index b6c44126bc1c..55fa58f4df39 100755
--- a/usr.sbin/periodic/etc/security/900.tcpwrap
+++ b/usr.sbin/periodic/etc/security/900.tcpwrap
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# Show tcp_wrapper warning messages
@@ -50,12 +49,7 @@ catmsgs() {
sort -t. -r -n -k 2,2 |
while read f
do
- case $f in
- *.gz) zcat -f $f;;
- *.bz2) bzcat -f $f;;
- *.xz) xzcat -f $f;;
- *.zst) zstdcat -f $f;;
- esac
+ zcat -f $f
done
[ -f ${LOG}/messages ] && cat $LOG/messages
}
diff --git a/usr.sbin/periodic/etc/security/Makefile b/usr.sbin/periodic/etc/security/Makefile
index 02d2264be15a..f70aa23a1445 100644
--- a/usr.sbin/periodic/etc/security/Makefile
+++ b/usr.sbin/periodic/etc/security/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
@@ -25,7 +24,7 @@ DATAPACKAGE= periodic
CONFGROUPS+= IPFILTER
IPFILTER+= 510.ipfdenied
IPFILTER+= 610.ipf6denied
-IPFILTERPACKAGE= ipfilter
+IPFILTERPACKAGE= ipf
.endif
.if ${MK_IPFW} != "no"
diff --git a/usr.sbin/periodic/etc/security/security.functions b/usr.sbin/periodic/etc/security/security.functions
index 00a89075dbfd..aa19a99ebf87 100644
--- a/usr.sbin/periodic/etc/security/security.functions
+++ b/usr.sbin/periodic/etc/security/security.functions
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
# This is a library file, so we only try to do something when sourced.
diff --git a/usr.sbin/periodic/etc/weekly/310.locate b/usr.sbin/periodic/etc/weekly/310.locate
index b7481965444a..84c0d69610e1 100755
--- a/usr.sbin/periodic/etc/weekly/310.locate
+++ b/usr.sbin/periodic/etc/weekly/310.locate
@@ -1,34 +1,32 @@
#!/bin/sh -
#
-# $FreeBSD$
#
-# If there is a global system configuration file, suck it in.
+# If there is a global system configuration file, read it.
#
-if [ -r /etc/defaults/periodic.conf ]
-then
- . /etc/defaults/periodic.conf
- source_periodic_confs
+if [ -r /etc/defaults/periodic.conf ]; then
+ . /etc/defaults/periodic.conf
+ source_periodic_confs
fi
case "$weekly_locate_enable" in
- [Yy][Ee][Ss])
+ [Yy][Ee][Ss])
echo ""
echo "Rebuilding locate database:"
- . /etc/locate.rc
- : ${FCODES:="/var/db/locate.database"}
- locdb="$FCODES"
+ . /etc/locate.rc
+ : "${FCODES:=/var/db/locate.database}"
+ locdb="$FCODES"
- touch $locdb && rc=0 || rc=3
- chown nobody $locdb || rc=3
- chmod 644 $locdb || rc=3
+ touch "$locdb" && rc=0 || rc=3
+ chown nobody "$locdb" || rc=3
+ chmod 644 "$locdb" || rc=3
cd /
echo /usr/libexec/locate.updatedb | nice -n 5 su -fm nobody || rc=3
- chmod 444 $locdb || rc=3;;
+ chmod 444 "$locdb" || rc=3;;
- *) rc=0;;
+ *) rc=0;;
esac
-exit $rc
+exit "$rc"
diff --git a/usr.sbin/periodic/etc/weekly/320.whatis b/usr.sbin/periodic/etc/weekly/320.whatis
index dfc218ae008c..22d9070a4dbb 100755
--- a/usr.sbin/periodic/etc/weekly/320.whatis
+++ b/usr.sbin/periodic/etc/weekly/320.whatis
@@ -1,6 +1,5 @@
#!/bin/sh -
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/weekly/340.noid b/usr.sbin/periodic/etc/weekly/340.noid
index 06ac3df31ffc..6151840ea3c2 100755
--- a/usr.sbin/periodic/etc/weekly/340.noid
+++ b/usr.sbin/periodic/etc/weekly/340.noid
@@ -1,6 +1,5 @@
#!/bin/sh -
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/weekly/450.status-security b/usr.sbin/periodic/etc/weekly/450.status-security
index d224e44a58a1..8bb0c02859c4 100755
--- a/usr.sbin/periodic/etc/weekly/450.status-security
+++ b/usr.sbin/periodic/etc/weekly/450.status-security
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/weekly/999.local b/usr.sbin/periodic/etc/weekly/999.local
index cc40c07c8840..c53e9113cbd2 100755
--- a/usr.sbin/periodic/etc/weekly/999.local
+++ b/usr.sbin/periodic/etc/weekly/999.local
@@ -1,6 +1,5 @@
#!/bin/sh -
#
-# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
diff --git a/usr.sbin/periodic/etc/weekly/Makefile b/usr.sbin/periodic/etc/weekly/Makefile
index 74ab84f3684e..4d21c098dd10 100644
--- a/usr.sbin/periodic/etc/weekly/Makefile
+++ b/usr.sbin/periodic/etc/weekly/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/periodic/periodic.8 b/usr.sbin/periodic/periodic.8
index 2fda1db157f5..0cd57bab27e2 100644
--- a/usr.sbin/periodic/periodic.8
+++ b/usr.sbin/periodic/periodic.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 18, 2020
.Dt PERIODIC 8
.Os
@@ -183,7 +181,7 @@ and the standard
and
.Pa security
scripts
-.It Pa /etc/periodic.conf
+.It Pa /etc/periodic.conf , ${LOCALBASE}/etc/periodic.conf
this file contains local overrides for the default
.Nm
configuration
@@ -207,7 +205,12 @@ system registry will typically have a
.Va local_periodic
variable reading:
.Pp
-.Dl local_periodic="/usr/local/etc/periodic"
+.Dl local_periodic="${_localbase}/etc/periodic"
+.Pp
+where
+.Pa ${_localbase}
+is being set from within
+.Pa /usr/sbin/periodic .
.Pp
To log
.Nm
diff --git a/usr.sbin/periodic/periodic.conf b/usr.sbin/periodic/periodic.conf
index 61cebe858372..608a199b3cc9 100644
--- a/usr.sbin/periodic/periodic.conf
+++ b/usr.sbin/periodic/periodic.conf
@@ -13,14 +13,13 @@
# For a more detailed explanation of all the periodic.conf variables, please
# refer to the periodic.conf(5) manual page.
#
-# $FreeBSD$
#
# What files override these defaults ?
-periodic_conf_files="/etc/periodic.conf /etc/periodic.conf.local"
+periodic_conf_files="/etc/periodic.conf /etc/periodic.conf.local ${_localbase}/etc/periodic.conf"
-# periodic script dirs
-local_periodic="/usr/local/etc/periodic"
+# periodic script dirs. _localbase is being set in /usr/sbin/periodic
+local_periodic="${_localbase}/etc/periodic"
# Max time to sleep to avoid causing congestion on download servers
anticongestion_sleeptime=3600
@@ -32,6 +31,7 @@ anticongestion_sleeptime=3600
# that output. $daily_output might be set to /var/log/daily.log if you
# wish to log the daily output and have the files rotated by newsyslog(8)
#
+daily_diff_flags="-b -U 0" # flags for diff output
daily_output="root" # user or /file
daily_show_success="YES" # scripts returning 0
daily_show_info="YES" # scripts returning 1
@@ -179,6 +179,11 @@ daily_scrub_zfs_pools="" # empty string selects all pools
daily_scrub_zfs_default_threshold="35" # days between scrubs
#daily_scrub_zfs_${poolname}_threshold="35" # pool specific threshold
+# 801.trim-zfs
+daily_trim_zfs_enable="NO"
+daily_trim_zfs_pools="" # empty string selects all pools
+daily_trim_zfs_flags="" # zpool-trim(8) flags
+
# 999.local
daily_local="/etc/daily.local" # Local scripts
@@ -249,7 +254,7 @@ security_show_badconfig="NO" # scripts returning 2
# These options are used by the security periodic(8) scripts spawned in
# daily and weekly 450.status-security.
security_status_logdir="/var/log" # Directory for logs
-security_status_diff_flags="-b -u" # flags for diff output
+security_status_diff_flags="-b -U 0" # flags for diff output
# Each of the security_status_*_period options below can have one of the
# following values:
diff --git a/usr.sbin/periodic/periodic.sh b/usr.sbin/periodic/periodic.sh
index 26413c4ab51e..09727a840eff 100644
--- a/usr.sbin/periodic/periodic.sh
+++ b/usr.sbin/periodic/periodic.sh
@@ -1,6 +1,5 @@
#!/bin/sh -
#
-# $FreeBSD$
#
# Run nightly periodic scripts
#
@@ -30,9 +29,13 @@ if [ $# -lt 1 ] ; then
usage
fi
+_localbase=`/sbin/sysctl -n user.localbase 2> /dev/null`
+# Set default value of _localbase if not previously set
+: ${_localbase:="/usr/local"}
+
# Use a deterministic path to match the preset from /etc/crontab in case
# periodic is run interactively.
-export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin:${_localbase}/sbin:${_localbase}/bin
# If possible, check the global system configuration file,
# to see if there are additional dirs to check
@@ -47,13 +50,13 @@ export host
# If we were called normally, then create a lock file for each argument
# in turn and reinvoke ourselves with the LOCKED argument. This prevents
# very long running jobs from being overlapped by another run as this is
-# will lead the system running progressivly slower and more and more jobs
+# will lead the system running progressively slower and more and more jobs
# are run at once.
if [ $1 != "LOCKED" ]; then
ret=0
for arg; do
lockfile=/var/run/periodic.${arg##*/}.lock
- lockf -t 0 "${lockfile}" /bin/sh $0 LOCKED "$arg"
+ lockf -s -t 0 "${lockfile}" /bin/sh $0 LOCKED "$arg"
case $? in
0) ;;
73) #EX_CANTCREATE
diff --git a/usr.sbin/pkg/FreeBSD.conf.latest b/usr.sbin/pkg/FreeBSD.conf.latest
index e4eec8f11451..a75b0703386f 100644
--- a/usr.sbin/pkg/FreeBSD.conf.latest
+++ b/usr.sbin/pkg/FreeBSD.conf.latest
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# To disable this repository, instead of modifying or removing this file,
# create a /usr/local/etc/pkg/repos/FreeBSD.conf file:
@@ -8,7 +7,7 @@
#
FreeBSD: {
- url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
+ url: "pkg+https://pkg.FreeBSD.org/${ABI}/latest",
mirror_type: "srv",
signature_type: "fingerprints",
fingerprints: "/usr/share/keys/pkg",
diff --git a/usr.sbin/pkg/FreeBSD.conf.quarterly b/usr.sbin/pkg/FreeBSD.conf.quarterly
index 68e1d32ac680..645053820dda 100644
--- a/usr.sbin/pkg/FreeBSD.conf.quarterly
+++ b/usr.sbin/pkg/FreeBSD.conf.quarterly
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# To disable this repository, instead of modifying or removing this file,
# create a /usr/local/etc/pkg/repos/FreeBSD.conf file:
@@ -8,7 +7,7 @@
#
FreeBSD: {
- url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly",
+ url: "pkg+https://pkg.FreeBSD.org/${ABI}/quarterly",
mirror_type: "srv",
signature_type: "fingerprints",
fingerprints: "/usr/share/keys/pkg",
diff --git a/usr.sbin/pkg/Makefile b/usr.sbin/pkg/Makefile
index 29bd6ea5e1af..3e0e047382ca 100644
--- a/usr.sbin/pkg/Makefile
+++ b/usr.sbin/pkg/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= pkg-bootstrap
@@ -10,7 +9,7 @@ PKGCONFBRANCH?= latest
. if ${BRANCH:MBETA*} || ${BRANCH:MRC*} || ${BRANCH:MRELEASE*}
PKGCONFBRANCH?= quarterly
. else
-. if ${MACHINE} != "amd64" && ${MACHINE} != "i386"
+. if ${MACHINE} != "amd64" && ${MACHINE} != "i386" && ${MACHINE} != "arm64"
PKGCONFBRANCH?= quarterly
. else
PKGCONFBRANCH?= latest
@@ -23,11 +22,11 @@ CONFSNAME_${PKGCONF}= ${PKGCONF:C/\.conf.+$/.conf/}
CONFSDIR= /etc/pkg
CONFSMODE= 644
PROG= pkg
-SRCS= pkg.c dns_utils.c config.c
+SRCS= pkg.c dns_utils.c config.c hash.c
MAN= pkg.7
CFLAGS+=-I${SRCTOP}/contrib/libucl/include
.PATH: ${SRCTOP}/contrib/libucl/include
-LIBADD= archive fetch ucl crypto ssl util
+LIBADD= archive fetch ucl crypto ssl util md
.include <bsd.prog.mk>
diff --git a/usr.sbin/pkg/Makefile.depend b/usr.sbin/pkg/Makefile.depend
index 0d93f91b60de..5b6639f85f7f 100644
--- a/usr.sbin/pkg/Makefile.depend
+++ b/usr.sbin/pkg/Makefile.depend
@@ -1,24 +1,17 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libarchive \
- lib/libbz2 \
lib/libc \
lib/libcompiler_rt \
- lib/libexpat \
lib/libfetch \
- lib/liblzma \
- lib/libsbuf \
- lib/libthr \
+ lib/libmd \
lib/libucl \
- lib/libz \
- lib/msun \
+ lib/libutil \
secure/lib/libcrypto \
secure/lib/libssl \
diff --git a/usr.sbin/pkg/config.c b/usr.sbin/pkg/config.c
index 08e206b93511..d8e15d44da3d 100644
--- a/usr.sbin/pkg/config.c
+++ b/usr.sbin/pkg/config.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 Baptiste Daroussin <bapt@FreeBSD.org>
* Copyright (c) 2013 Bryan Drewery <bdrewery@FreeBSD.org>
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/utsname.h>
@@ -146,32 +143,35 @@ static struct config_entry c[] = {
}
};
-static int
-pkg_get_myabi(char *dest, size_t sz)
+static char *
+pkg_get_myabi(void)
{
struct utsname uts;
char machine_arch[255];
+ char *abi;
size_t len;
int error;
error = uname(&uts);
if (error)
- return (errno);
+ return (NULL);
len = sizeof(machine_arch);
error = sysctlbyname("hw.machine_arch", machine_arch, &len, NULL, 0);
if (error)
- return (errno);
+ return (NULL);
machine_arch[len] = '\0';
/*
* Use __FreeBSD_version rather than kernel version (uts.release) for
* use in jails. This is equivalent to the value of uname -U.
*/
- snprintf(dest, sz, "%s:%d:%s", uts.sysname, __FreeBSD_version/100000,
+ error = asprintf(&abi, "%s:%d:%s", uts.sysname, __FreeBSD_version/100000,
machine_arch);
+ if (error < 0)
+ return (NULL);
- return (error);
+ return (abi);
}
static void
@@ -455,10 +455,9 @@ config_init(const char *requested_repo)
char *val;
int i;
const char *localbase;
- char *env_list_item;
+ char *abi, *env_list_item;
char confpath[MAXPATHLEN];
struct config_value *cv;
- char abi[BUFSIZ];
for (i = 0; i < CONFIG_SIZE; i++) {
val = getenv(c[i].key);
@@ -514,7 +513,8 @@ config_init(const char *requested_repo)
finalize:
if (c[ABI].val == NULL && c[ABI].value == NULL) {
- if (pkg_get_myabi(abi, BUFSIZ) != 0)
+ abi = pkg_get_myabi();
+ if (abi == NULL)
errx(EXIT_FAILURE, "Failed to determine the system "
"ABI");
c[ABI].val = abi;
diff --git a/usr.sbin/pkg/config.h b/usr.sbin/pkg/config.h
index 87efd3c29e94..21d115e41db2 100644
--- a/usr.sbin/pkg/config.h
+++ b/usr.sbin/pkg/config.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 Baptiste Daroussin <bapt@FreeBSD.org>
* 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 _PKG_CONFIG_H
diff --git a/usr.sbin/pkg/dns_utils.c b/usr.sbin/pkg/dns_utils.c
index f3bde529daca..dcf4b5599532 100644
--- a/usr.sbin/pkg/dns_utils.c
+++ b/usr.sbin/pkg/dns_utils.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012-2013 Baptiste Daroussin <bapt@FreeBSD.org>
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
diff --git a/usr.sbin/pkg/dns_utils.h b/usr.sbin/pkg/dns_utils.h
index da1482577fe7..23b8a30140ab 100644
--- a/usr.sbin/pkg/dns_utils.h
+++ b/usr.sbin/pkg/dns_utils.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012 Baptiste Daroussin <bapt@FreeBSD.org>
* 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 DNS_UTILS_H
diff --git a/usr.sbin/pkg/hash.c b/usr.sbin/pkg/hash.c
new file mode 100644
index 000000000000..b3e6334da6a2
--- /dev/null
+++ b/usr.sbin/pkg/hash.c
@@ -0,0 +1,47 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2012-2014 Baptiste Daroussin <bapt@FreeBSD.org>
+ * Copyright (c) 2013 Bryan Drewery <bdrewery@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sha256.h>
+#include <unistd.h>
+
+#include "hash.h"
+
+char *
+sha256_buf(char *buf, size_t len)
+{
+
+ return (SHA256_Data(buf, len, NULL));
+}
+
+char *
+sha256_fd(int fd)
+{
+
+ return (SHA256_Fd(fd, NULL));
+}
diff --git a/usr.sbin/kldxref/ef_nop.c b/usr.sbin/pkg/hash.h
index 420dba5ccdc3..2ade4b7e7a1f 100644
--- a/usr.sbin/kldxref/ef_nop.c
+++ b/usr.sbin/pkg/hash.h
@@ -1,8 +1,7 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2003 Jake Burkholder.
- * All rights reserved.
+ * Copyright (c) 2023 Baptiste Daroussin <bapt@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -12,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -25,18 +24,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
*/
-#include <sys/types.h>
-#include <machine/elf.h>
-
-#include "ef.h"
-
-int
-ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase,
- Elf_Off dataoff, size_t len, void *dest)
-{
+#pragma once
- return (0);
-}
+char *sha256_buf(char *buf, size_t len);
+char *sha256_fd(int fd);
diff --git a/usr.sbin/pkg/pkg.7 b/usr.sbin/pkg/pkg.7
index b92f5c9820cd..605653bbd8c6 100644
--- a/usr.sbin/pkg/pkg.7
+++ b/usr.sbin/pkg/pkg.7
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd February 7, 2021
+.Dd August 24, 2022
.Dt PKG 7
.Os
.Sh NAME
@@ -32,21 +30,20 @@
.Nd a utility for manipulating packages
.Sh SYNOPSIS
.Nm
-.Ao Ar command Ac
+.Op Fl d
+.Ar command ...
.Nm
-add
-.Op Fl f
+.Cm add
+.Op Fl dfy
.Op Fl r Ar reponame
-.Op Fl y
-.Ao Pa pkg.txz Ac
+.Ar pkg.txz
.Nm
.Fl N
.Nm
-.Op Fl 4 | Fl 6
-bootstrap
-.Op Fl f
+.Op Fl 46d
+.Cm bootstrap
+.Op Fl fy
.Op Fl r Ar reponame
-.Op Fl y
.Sh DESCRIPTION
.Nm
is the package management tool.
@@ -62,15 +59,15 @@ The first time invoked,
will bootstrap the real
.Xr pkg 8
from a remote repository.
-.Bl -tag -width "pkg bootstrap"
-.It Nm Ao Ar command Ac
+.Bl -tag
+.It Nm Ar command ...
If
.Xr pkg 8
is not installed yet, it will be fetched, have its signature verified,
installed, and then have the original command forwarded to it.
If already installed, the command requested will be forwarded to the real
.Xr pkg 8 .
-.It Nm Li add Oo Fl f Oc Oo Fl r Ar reponame Oc Oo Fl y Oc Ao Pa pkg.txz Ac
+.It Nm Cm add Oo Fl fy Oc Oo Fl r Ar reponame Oc Ar pkg.txz
Install
.Xr pkg 8
from a local package instead of fetching from remote.
@@ -96,8 +93,8 @@ Do not bootstrap, just determine if
is actually installed or not.
Returns 0 and the number of packages installed
if it is, otherwise 1.
-.It Nm Oo Fl 4 | Fl 6 Oc Li bootstrap Oo Fl f Oc \
-Oo Fl r Ar reponame Oc Oo Fl y Oc
+.It Nm Oo Fl 46 Oc Cm bootstrap Oo Fl fy Oc \
+Oo Fl r Ar reponame Oc
Attempt to bootstrap and do not forward anything to
.Xr pkg 8
after it is installed.
@@ -123,6 +120,17 @@ If a
.Ar reponame
has been specified, then the configuration for that repository will be used.
.El
+.Sh OPTIONS
+The following options are supported by
+.Nm :
+.Bl -tag -width indent
+.It Fl d, Fl -debug
+Show debug information.
+May be specified more than once to increase the level of detail.
+When specified twice,
+.Xr fetch 3
+debug output is enabled.
+.El
.Sh CONFIGURATION
Configuration varies in whether it is in a repository configuration file
or the global configuration file.
@@ -243,7 +251,7 @@ configuration files.
.Sh FILES
Configuration is read from the files in the listed order.
This path can be changed by setting
-.Sy REPOS_DIR .
+.Ev REPOS_DIR .
The last enabled repository is the one used for bootstrapping
.Xr pkg 8 .
.Bl -tag -width "/usr/local/etc/pkg/repos/*.conf"
@@ -282,12 +290,12 @@ Remove unneeded dependencies:
.Dl % pkg autoremove
.Pp
Change a package from automatic to non-automatic, which will prevent
-.Ic autoremove
+.Xr pkg-autoremove 8
from removing it:
.Dl % pkg set -A 0 perl
.Pp
Change a package from non-automatic to automatic, which will make
-.Ic autoremove
+.Xr pkg-autoremove 8
allow it be removed once nothing depends on it:
.Dl % pkg set -A 1 perl
.Pp
diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c
index 292f4a68b824..70086886fbc5 100644
--- a/usr.sbin/pkg/pkg.c
+++ b/usr.sbin/pkg/pkg.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012-2014 Baptiste Daroussin <bapt@FreeBSD.org>
* Copyright (c) 2013 Bryan Drewery <bdrewery@FreeBSD.org>
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
@@ -56,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include "dns_utils.h"
#include "config.h"
+#include "hash.h"
struct sig_cert {
char *name;
@@ -91,6 +89,8 @@ static const char *bootstrap_names [] = {
STAILQ_HEAD(fingerprint_list, fingerprint);
+static int debug;
+
static int
extract_pkg_static(int fd, char *p, int sz)
{
@@ -236,9 +236,7 @@ fetch_to_fd(const char *url, char *path, const char *fetchOpts)
--retry;
if (retry <= 0)
goto fetchfail;
- if (mirrors == NULL) {
- sleep(1);
- } else {
+ if (mirrors != NULL) {
current = current->next;
if (current == NULL)
current = mirrors;
@@ -402,83 +400,6 @@ load_fingerprints(const char *path, int *count)
return (fingerprints);
}
-static void
-sha256_hash(unsigned char hash[SHA256_DIGEST_LENGTH],
- char out[SHA256_DIGEST_LENGTH * 2 + 1])
-{
- int i;
-
- for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
- sprintf(out + (i * 2), "%02x", hash[i]);
-
- out[SHA256_DIGEST_LENGTH * 2] = '\0';
-}
-
-static void
-sha256_buf(char *buf, size_t len, char out[SHA256_DIGEST_LENGTH * 2 + 1])
-{
- unsigned char hash[SHA256_DIGEST_LENGTH];
- SHA256_CTX sha256;
-
- out[0] = '\0';
-
- SHA256_Init(&sha256);
- SHA256_Update(&sha256, buf, len);
- SHA256_Final(hash, &sha256);
- sha256_hash(hash, out);
-}
-
-static int
-sha256_fd(int fd, char out[SHA256_DIGEST_LENGTH * 2 + 1])
-{
- int my_fd;
- FILE *fp;
- char buffer[BUFSIZ];
- unsigned char hash[SHA256_DIGEST_LENGTH];
- size_t r;
- int ret;
- SHA256_CTX sha256;
-
- fp = NULL;
- ret = 1;
-
- out[0] = '\0';
-
- /* Duplicate the fd so that fclose(3) does not close it. */
- if ((my_fd = dup(fd)) == -1) {
- warnx("dup");
- goto cleanup;
- }
-
- if ((fp = fdopen(my_fd, "rb")) == NULL) {
- warnx("fdopen");
- goto cleanup;
- }
-
- SHA256_Init(&sha256);
-
- while ((r = fread(buffer, 1, BUFSIZ, fp)) > 0)
- SHA256_Update(&sha256, buffer, r);
-
- if (ferror(fp) != 0) {
- warnx("fread");
- goto cleanup;
- }
-
- SHA256_Final(hash, &sha256);
- sha256_hash(hash, out);
- ret = 0;
-
-cleanup:
- if (fp != NULL)
- fclose(fp);
- else if (my_fd != -1)
- close(my_fd);
- (void)lseek(fd, 0, SEEK_SET);
-
- return (ret);
-}
-
static EVP_PKEY *
load_public_key_file(const char *file)
{
@@ -521,10 +442,11 @@ rsa_verify_cert(int fd, const char *sigfile, const unsigned char *key,
{
EVP_MD_CTX *mdctx;
EVP_PKEY *pkey;
- char sha256[(SHA256_DIGEST_LENGTH * 2) + 2];
+ char *sha256;
char errbuf[1024];
bool ret;
+ sha256 = NULL;
pkey = NULL;
mdctx = NULL;
ret = false;
@@ -536,7 +458,7 @@ rsa_verify_cert(int fd, const char *sigfile, const unsigned char *key,
warn("lseek");
goto cleanup;
}
- if ((sha256_fd(fd, sha256)) == -1) {
+ if ((sha256 = sha256_fd(fd)) == NULL) {
warnx("Error creating SHA256 hash for package");
goto cleanup;
}
@@ -581,6 +503,7 @@ error:
printf("failed\n");
cleanup:
+ free(sha256);
if (pkey)
EVP_PKEY_free(pkey);
if (mdctx)
@@ -743,8 +666,9 @@ verify_signature(int fd_pkg, int fd_sig)
int trusted_count, revoked_count;
const char *fingerprints;
char path[MAXPATHLEN];
- char hash[SHA256_DIGEST_LENGTH * 2 + 1];
+ char *hash;
+ hash = NULL;
sc = NULL;
trusted = revoked = NULL;
ret = false;
@@ -781,7 +705,7 @@ verify_signature(int fd_pkg, int fd_sig)
sc->trusted = false;
/* Parse signature and pubkey out of the certificate */
- sha256_buf(sc->cert, sc->certlen, hash);
+ hash = sha256_buf(sc->cert, sc->certlen);
/* Check if this hash is revoked */
if (revoked != NULL) {
@@ -820,6 +744,7 @@ verify_signature(int fd_pkg, int fd_sig)
ret = true;
cleanup:
+ free(hash);
if (trusted)
free_fingerprint_list(trusted);
if (revoked)
@@ -1115,6 +1040,7 @@ main(int argc, char *argv[])
yes = false;
struct option longopts[] = {
+ { "debug", no_argument, NULL, 'd' },
{ "force", no_argument, NULL, 'f' },
{ "only-ipv4", no_argument, NULL, '4' },
{ "only-ipv6", no_argument, NULL, '6' },
@@ -1124,8 +1050,11 @@ main(int argc, char *argv[])
snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", getlocalbase());
- while ((ch = getopt_long(argc, argv, "-:fr::yN46", longopts, NULL)) != -1) {
+ while ((ch = getopt_long(argc, argv, "-:dfr::yN46", longopts, NULL)) != -1) {
switch (ch) {
+ case 'd':
+ debug++;
+ break;
case 'f':
force = true;
break;
@@ -1222,12 +1151,14 @@ main(int argc, char *argv[])
break;
}
}
+ if (debug > 1)
+ fetchDebug = 1;
if ((bootstrap_only && force) || access(pkgpath, X_OK) == -1) {
- /*
+ /*
* To allow 'pkg -N' to be used as a reliable test for whether
* a system is configured to use pkg, don't bootstrap pkg
- * when that that option is passed.
+ * when that option is passed.
*/
if (activation_test)
errx(EXIT_FAILURE, "pkg is not installed");
diff --git a/usr.sbin/pmc/Makefile b/usr.sbin/pmc/Makefile
index 8f026f131a8b..3f73dd398958 100644
--- a/usr.sbin/pmc/Makefile
+++ b/usr.sbin/pmc/Makefile
@@ -1,19 +1,11 @@
-#
-# $FreeBSD$
-#
-
.include <src.opts.mk>
+
PROG_CXX= pmc
MAN=
-WARNS?= 3
-CXXFLAGS+= -O0
CXXSTD= c++14
CWARNFLAGS.gcc+= -Wno-redundant-decls
CFLAGS+= -I${SRCTOP}/lib/libpmcstat
-# Does not link when built position-independent.
-MK_PIE=no
-
LIBADD= pmc m pmcstat elf
SRCS= pmc.c pmc_util.c cmd_pmc_stat.c \
diff --git a/usr.sbin/pmc/cmd_pmc.h b/usr.sbin/pmc/cmd_pmc.h
index cdec055a2036..83c279c4e8b7 100644
--- a/usr.sbin/pmc/cmd_pmc.h
+++ b/usr.sbin/pmc/cmd_pmc.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018, Matthew Macy
*
@@ -24,8 +24,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#ifndef _CMD_PMC_H_
#define _CMD_PMC_H_
diff --git a/usr.sbin/pmc/cmd_pmc_filter.cc b/usr.sbin/pmc/cmd_pmc_filter.cc
index 07027cb272f9..11ab2dc3c964 100644
--- a/usr.sbin/pmc/cmd_pmc_filter.cc
+++ b/usr.sbin/pmc/cmd_pmc_filter.cc
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018, Matthew Macy
*
@@ -26,9 +26,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/cpuset.h>
#include <sys/event.h>
@@ -208,7 +205,7 @@ pmc_filter_handler(uint32_t *lwplist, int lwpcount, uint32_t *pidlist, int pidco
char cpuid[PMC_CPUID_LEN];
char *proclist[LIST_MAX];
char *threadlist[LIST_MAX];
- int i, pmccount, copies, eventcount;
+ int i, pmccount, eventcount;
int proccount, threadcount;
uint32_t idx;
idmap pidmap, tidmap;
@@ -247,7 +244,6 @@ pmc_filter_handler(uint32_t *lwplist, int lwpcount, uint32_t *pidlist, int pidco
pmclog_close(ps);
if ((ps = static_cast < struct pmclog_parse_state *>(pmclog_open(infd)))== NULL)
errx(EX_OSERR, "ERROR: Cannot allocate pmclog parse state: %s\n", strerror(errno));
- copies = 0;
while (pmclog_read(ps, &ev) == 0) {
if (ev.pl_type == PMCLOG_TYPE_THR_CREATE)
tidmap[ev.pl_u.pl_tc.pl_tid] = ev.pl_u.pl_tc.pl_tdname;
diff --git a/usr.sbin/pmc/cmd_pmc_list.c b/usr.sbin/pmc/cmd_pmc_list.c
index 2e1117e326e6..a1da6a8e732d 100644
--- a/usr.sbin/pmc/cmd_pmc_list.c
+++ b/usr.sbin/pmc/cmd_pmc_list.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018, Matthew Macy
*
@@ -26,9 +26,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/cpuset.h>
#include <sys/event.h>
diff --git a/usr.sbin/pmc/cmd_pmc_stat.c b/usr.sbin/pmc/cmd_pmc_stat.c
index 55d1f1ca7a3b..1e5c14e61857 100644
--- a/usr.sbin/pmc/cmd_pmc_stat.c
+++ b/usr.sbin/pmc/cmd_pmc_stat.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018, Matthew Macy
*
@@ -26,9 +26,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/cpuset.h>
#include <sys/event.h>
diff --git a/usr.sbin/pmc/cmd_pmc_summary.cc b/usr.sbin/pmc/cmd_pmc_summary.cc
index 16edc5c7c30e..610c1fee7f0d 100644
--- a/usr.sbin/pmc/cmd_pmc_summary.cc
+++ b/usr.sbin/pmc/cmd_pmc_summary.cc
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018, Matthew Macy
*
@@ -26,9 +26,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/cpuset.h>
#include <sys/event.h>
diff --git a/usr.sbin/pmc/pmc.c b/usr.sbin/pmc/pmc.c
index a923e5c0c2a4..4b4d113e2bd4 100644
--- a/usr.sbin/pmc/pmc.c
+++ b/usr.sbin/pmc/pmc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018, Matthew Macy
*
@@ -24,8 +24,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#include <sys/types.h>
diff --git a/usr.sbin/pmc/pmc_util.c b/usr.sbin/pmc/pmc_util.c
index 94f82a49ef36..40f2b9caeef3 100644
--- a/usr.sbin/pmc/pmc_util.c
+++ b/usr.sbin/pmc/pmc_util.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003-2008, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -31,9 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/cpuset.h>
#include <sys/event.h>
diff --git a/usr.sbin/pmcannotate/Makefile b/usr.sbin/pmcannotate/Makefile
index cff1efb5ccfa..8f408590a743 100644
--- a/usr.sbin/pmcannotate/Makefile
+++ b/usr.sbin/pmcannotate/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
PROG= pmcannotate
diff --git a/usr.sbin/pmcannotate/Makefile.depend b/usr.sbin/pmcannotate/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/pmcannotate/Makefile.depend
+++ b/usr.sbin/pmcannotate/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/pmcannotate/pmcannotate.8 b/usr.sbin/pmcannotate/pmcannotate.8
index 08967d9d7bf9..9a89c40db1e7 100644
--- a/usr.sbin/pmcannotate/pmcannotate.8
+++ b/usr.sbin/pmcannotate/pmcannotate.8
@@ -25,8 +25,6 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
-.\"
.Dd November 20, 2008
.Dt PMCANNOTATE 8
.Os
diff --git a/usr.sbin/pmcannotate/pmcannotate.c b/usr.sbin/pmcannotate/pmcannotate.c
index 03f384d3f531..01af75090793 100644
--- a/usr.sbin/pmcannotate/pmcannotate.c
+++ b/usr.sbin/pmcannotate/pmcannotate.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Nokia Corporation
* All rights reserved.
@@ -30,9 +30,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/queue.h>
@@ -434,11 +431,6 @@ fqueue_getall(const char *bin, char *temp, int asmf)
start = agg->ag_ostart;
end = agg->ag_oend;
- /*
- * Fix-up the end address in order to show it in the objdump's
- * trace.
- */
- end++;
if (asmf)
snprintf(tmpf, sizeof(tmpf),
"objdump --start-address=%p "
diff --git a/usr.sbin/pmccontrol/Makefile b/usr.sbin/pmccontrol/Makefile
index 340c12811a4c..de6224979a60 100644
--- a/usr.sbin/pmccontrol/Makefile
+++ b/usr.sbin/pmccontrol/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
PROG_CXX= pmccontrol
diff --git a/usr.sbin/pmccontrol/Makefile.depend b/usr.sbin/pmccontrol/Makefile.depend
index a52f7b8c67dc..0349c74b7779 100644
--- a/usr.sbin/pmccontrol/Makefile.depend
+++ b/usr.sbin/pmccontrol/Makefile.depend
@@ -1,14 +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/libpmc \
+ lib/msun \
.include <dirdeps.mk>
diff --git a/usr.sbin/pmccontrol/pmccontrol.8 b/usr.sbin/pmccontrol/pmccontrol.8
index a5b6baa2874f..26f6800c66ed 100644
--- a/usr.sbin/pmccontrol/pmccontrol.8
+++ b/usr.sbin/pmccontrol/pmccontrol.8
@@ -21,8 +21,6 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
-.\"
.Dd November 9, 2008
.Dt PMCCONTROL 8
.Os
diff --git a/usr.sbin/pmccontrol/pmccontrol.c b/usr.sbin/pmccontrol/pmccontrol.c
index 9d57a2923784..c90b4994e0e8 100644
--- a/usr.sbin/pmccontrol/pmccontrol.c
+++ b/usr.sbin/pmccontrol/pmccontrol.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003,2004 Joseph Koshy
* All rights reserved.
@@ -27,9 +27,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/cpuset.h>
@@ -101,7 +98,7 @@ static FILE *debug_stream = NULL;
#if DEBUG
#define DEBUG_MSG(...) \
- (void) fprintf(debug_stream, "[pmccontrol] " __VA_ARGS__);
+ (void) fprintf(debug_stream, "[pmccontrol] " __VA_ARGS__)
#else
#define DEBUG_MSG(m) /* */
#endif /* !DEBUG */
@@ -241,11 +238,6 @@ pmcc_do_list_state(void)
ncpu = pc->pm_ncpu;
for (c = cpu = 0; cpu < ncpu; cpu++) {
-#if defined(__i386__) || defined(__amd64__)
- if (pc->pm_cputype == PMC_CPU_INTEL_PIV &&
- CPU_ISSET(cpu, &logical_cpus_mask))
- continue; /* skip P4-style 'logical' cpus */
-#endif
if (pmc_pmcinfo(cpu, &pi) < 0) {
if (errno == ENXIO)
continue;
diff --git a/usr.sbin/pmcstat/Makefile b/usr.sbin/pmcstat/Makefile
index 5d938677306c..7e0c671e38ac 100644
--- a/usr.sbin/pmcstat/Makefile
+++ b/usr.sbin/pmcstat/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
PROG_CXX= pmcstat
diff --git a/usr.sbin/pmcstat/Makefile.depend b/usr.sbin/pmcstat/Makefile.depend
index 6d010477ce76..c35a6a067529 100644
--- a/usr.sbin/pmcstat/Makefile.depend
+++ b/usr.sbin/pmcstat/Makefile.depend
@@ -1,19 +1,20 @@
-# $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/libelf \
lib/libkvm \
lib/libpmc \
lib/libpmcstat \
lib/msun \
- lib/ncurses/ncursesw \
+ lib/ncurses/ncurses \
+ lib/ncurses/tinfo \
.include <dirdeps.mk>
diff --git a/usr.sbin/pmcstat/pmcpl_annotate.c b/usr.sbin/pmcstat/pmcpl_annotate.c
index 18d37c06e6c5..cdc0d5705597 100644
--- a/usr.sbin/pmcstat/pmcpl_annotate.c
+++ b/usr.sbin/pmcstat/pmcpl_annotate.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2007, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -35,9 +35,6 @@
* gprof(1) compatible profiles.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/gmon.h>
diff --git a/usr.sbin/pmcstat/pmcpl_annotate.h b/usr.sbin/pmcstat/pmcpl_annotate.h
index 35b6412b7165..469bf111611e 100644
--- a/usr.sbin/pmcstat/pmcpl_annotate.h
+++ b/usr.sbin/pmcstat/pmcpl_annotate.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2007, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -28,8 +28,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 _PMCSTAT_PL_ANNOTATE_H_
diff --git a/usr.sbin/pmcstat/pmcpl_annotate_cg.c b/usr.sbin/pmcstat/pmcpl_annotate_cg.c
index d6274e1f2b73..68d718e30821 100644
--- a/usr.sbin/pmcstat/pmcpl_annotate_cg.c
+++ b/usr.sbin/pmcstat/pmcpl_annotate_cg.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2007, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -38,9 +38,6 @@
* gprof(1) compatible profiles.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/gmon.h>
diff --git a/usr.sbin/pmcstat/pmcpl_annotate_cg.h b/usr.sbin/pmcstat/pmcpl_annotate_cg.h
index afd5209ee756..6483636f47e8 100644
--- a/usr.sbin/pmcstat/pmcpl_annotate_cg.h
+++ b/usr.sbin/pmcstat/pmcpl_annotate_cg.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2007, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -31,8 +31,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 _PMCSTAT_PL_ANNOTATE_CG_H_
diff --git a/usr.sbin/pmcstat/pmcpl_callgraph.c b/usr.sbin/pmcstat/pmcpl_callgraph.c
index f6b662fdeb14..ade99464a4a3 100644
--- a/usr.sbin/pmcstat/pmcpl_callgraph.c
+++ b/usr.sbin/pmcstat/pmcpl_callgraph.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2007, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -35,9 +35,6 @@
* gprof(1) compatible profiles.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/gmon.h>
@@ -361,7 +358,7 @@ pmcpl_cg_process(struct pmcstat_process *pp, struct pmcstat_pmcrecord *pmcr,
* For each return address in the call chain record, subject
* to the maximum depth desired.
* - Find the image associated with the sample. Stop if there
- * there is no valid image at that address.
+ * is no valid image at that address.
* - Find the function that overlaps the return address.
* - If found: use the start address of the function.
* If not found (say an object's symbol table is not present or
diff --git a/usr.sbin/pmcstat/pmcpl_callgraph.h b/usr.sbin/pmcstat/pmcpl_callgraph.h
index c3da2a8f93fc..75673c2afb28 100644
--- a/usr.sbin/pmcstat/pmcpl_callgraph.h
+++ b/usr.sbin/pmcstat/pmcpl_callgraph.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2007, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -28,8 +28,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 _PMCSTAT_PL_CALLGRAPH_H_
diff --git a/usr.sbin/pmcstat/pmcpl_calltree.c b/usr.sbin/pmcstat/pmcpl_calltree.c
index b0ce18aae76e..209297a41885 100644
--- a/usr.sbin/pmcstat/pmcpl_calltree.c
+++ b/usr.sbin/pmcstat/pmcpl_calltree.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012, Fabien Thomas
* All rights reserved.
@@ -33,9 +33,6 @@
* Handle top mode with a sorted tree display.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/queue.h>
diff --git a/usr.sbin/pmcstat/pmcpl_calltree.h b/usr.sbin/pmcstat/pmcpl_calltree.h
index bb73b6b6f3c0..16feca85cbb7 100644
--- a/usr.sbin/pmcstat/pmcpl_calltree.h
+++ b/usr.sbin/pmcstat/pmcpl_calltree.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2009, Fabien Thomas
* 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 _PMCSTAT_PL_CALLTREE_H_
diff --git a/usr.sbin/pmcstat/pmcpl_gprof.c b/usr.sbin/pmcstat/pmcpl_gprof.c
index 535c94746959..acc8c0b56a2b 100644
--- a/usr.sbin/pmcstat/pmcpl_gprof.c
+++ b/usr.sbin/pmcstat/pmcpl_gprof.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2007, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -36,9 +36,6 @@
* gprof(1) compatible profiles.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/gmon.h>
diff --git a/usr.sbin/pmcstat/pmcpl_gprof.h b/usr.sbin/pmcstat/pmcpl_gprof.h
index 4ce59ddacc57..b4e587651794 100644
--- a/usr.sbin/pmcstat/pmcpl_gprof.h
+++ b/usr.sbin/pmcstat/pmcpl_gprof.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2007, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -29,8 +29,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 _PMCSTAT_PL_GPROF_H_
diff --git a/usr.sbin/pmcstat/pmcstat.8 b/usr.sbin/pmcstat/pmcstat.8
index b0dae2449cfe..02218a5cfa22 100644
--- a/usr.sbin/pmcstat/pmcstat.8
+++ b/usr.sbin/pmcstat/pmcstat.8
@@ -23,9 +23,7 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
-.\"
-.Dd August 17, 2020
+.Dd May 31, 2023
.Dt PMCSTAT 8
.Os
.Sh NAME
@@ -57,7 +55,6 @@
.Op Fl f Ar pluginopt
.Op Fl g
.Op Fl i Ar lwp
-.Op Fl k Ar kerneldir
.Op Fl l Ar secs
.Op Fl m Ar pathname
.Op Fl n Ar rate
@@ -107,6 +104,10 @@ counting and sampling flavors.
The values of all counting PMCs are printed in human readable form
at regular intervals by
.Nm .
+The format of
+.Nm Ns 's
+human-readable textual output is not stable, and could change
+in the future.
The output of sampling PMCs may be configured to go to a log file for
subsequent offline analysis, or, at the expense of greater
overhead, may be configured to be printed in text form on the fly.
@@ -226,8 +227,8 @@ specified in
.It Fl T
Use a
.Xr top 1 Ns -like
-mode for sampling PMCs. The following hotkeys
-can be used:
+mode for sampling PMCs.
+The following hotkeys can be used:
.Pp
.Bl -tag -compact -width "Ctrl+a" -offset 4n
.It Ic A
@@ -332,17 +333,6 @@ which you can get from
.Xr ps 1
.Fl o
.Li lwp .
-.It Fl k Ar kerneldir
-Set the pathname of the kernel directory to argument
-.Ar kerneldir .
-This directory specifies where
-.Nm
-should look for the kernel and its modules.
-The default is to use the path of the running kernel obtained from the
-.Va kern.bootfile
-sysctl.
-Modules will also be searched for in /boot/modules if not found in
-.Ar kerneldir .
.It Fl l Ar secs
Set system-wide performance measurement duration for
.Ar secs
@@ -544,8 +534,6 @@ The
.Nm
utility first appeared in
.Fx 6.0 .
-It is
-.Ud
.Sh AUTHORS
.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org
.Sh BUGS
diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c
index 3e2d101ab113..98e14dfb9113 100644
--- a/usr.sbin/pmcstat/pmcstat.c
+++ b/usr.sbin/pmcstat/pmcstat.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003-2008, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/cpuset.h>
#include <sys/event.h>
@@ -59,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <regex.h>
#include <signal.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -95,7 +93,7 @@ __FBSDID("$FreeBSD$");
*
* /Parent/ /Child/
*
- * - Wait for childs token.
+ * - Wait for child's token.
* - Sends token.
* - Awaits signal to start.
* - Attaches PMCs to the child's pid
@@ -116,6 +114,7 @@ static int pmcstat_kq;
static kvm_t *pmcstat_kvm;
static struct kinfo_proc *pmcstat_plist;
struct pmcstat_args args;
+static bool libpmc_initialized = false;
static void
pmcstat_get_cpumask(const char *cpuspec, cpuset_t *cpumask)
@@ -347,8 +346,6 @@ pmcstat_print_pmcs(void)
(void) fprintf(args.pa_printfile, "\n");
pmcstat_print_counters();
-
- return;
}
void
@@ -383,7 +380,6 @@ pmcstat_show_usage(void)
"\t -f spec\t pass \"spec\" to as plugin option\n"
"\t -g\t\t produce gprof(1) compatible profiles\n"
"\t -i lwp\t\t filter on thread id \"lwp\" in post-processing\n"
- "\t -k dir\t\t set the path to the kernel\n"
"\t -l secs\t set duration time\n"
"\t -m file\t print sampled PCs to \"file\"\n"
"\t -n rate\t set sampling rate\n"
@@ -419,6 +415,22 @@ pmcstat_topexit(void)
endwin();
}
+static inline void
+libpmc_initialize(int *npmc)
+{
+
+ if (libpmc_initialized)
+ return;
+ if (pmc_init() < 0)
+ err(EX_UNAVAILABLE, "ERROR: Initialization of the pmc(3)"
+ " library failed");
+
+ /* assume all CPUs are identical */
+ if ((*npmc = pmc_npmc(0)) < 0)
+ err(EX_OSERR, "ERROR: Cannot determine the number of PMCs on "
+ "CPU %d", 0);
+ libpmc_initialized = true;
+}
/*
* Main
*/
@@ -426,21 +438,21 @@ pmcstat_topexit(void)
int
main(int argc, char **argv)
{
- cpuset_t cpumask, rootmask;
+ cpuset_t cpumask, dommask, rootmask;
double interval;
double duration;
int option, npmc;
int c, check_driver_stats;
int do_callchain, do_descendants, do_logproccsw, do_logprocexit;
- int do_print, do_read, do_listcounters, do_descr;
- int do_userspace;
+ int do_print, do_read, do_listcounters, do_descr, domains;
+ int do_userspace, i;
size_t len;
int graphdepth;
int pipefd[2], rfd;
int use_cumulative_counts;
short cf, cb;
uint64_t current_sampling_count;
- char *end, *tmp, *event;
+ char *end, *event;
const char *errmsg, *graphfilename;
enum pmcstat_state runstate;
struct pmc_driverstats ds_start, ds_end;
@@ -449,7 +461,7 @@ main(int argc, char **argv)
struct kevent kev;
struct winsize ws;
struct stat sb;
- char buffer[PATH_MAX];
+ uint32_t caps;
check_driver_stats = 0;
current_sampling_count = 0;
@@ -460,6 +472,7 @@ main(int argc, char **argv)
do_logproccsw = 0;
do_logprocexit = 0;
do_listcounters = 0;
+ domains = 0;
use_cumulative_counts = 0;
graphfilename = "-";
args.pa_required = 0;
@@ -489,17 +502,12 @@ main(int argc, char **argv)
bzero(&ds_end, sizeof(ds_end));
ev = NULL;
event = NULL;
+ caps = 0;
CPU_ZERO(&cpumask);
- /* Default to using the running system kernel. */
- len = 0;
- if (sysctlbyname("kern.bootfile", NULL, &len, NULL, 0) == -1)
- err(EX_OSERR, "ERROR: Cannot determine path of running kernel");
- args.pa_kernel = malloc(len);
- if (args.pa_kernel == NULL)
- errx(EX_SOFTWARE, "ERROR: Out of memory.");
- if (sysctlbyname("kern.bootfile", args.pa_kernel, &len, NULL, 0) == -1)
- err(EX_OSERR, "ERROR: Cannot determine path of running kernel");
+ len = sizeof(domains);
+ if (sysctlbyname("vm.ndomains", &domains, &len, NULL, 0) == -1)
+ err(EX_OSERR, "ERROR: Cannot get number of domains");
/*
* The initial CPU mask specifies the root mask of this process
@@ -600,12 +608,8 @@ main(int argc, char **argv)
break;
case 'k': /* pathname to the kernel */
- free(args.pa_kernel);
- args.pa_kernel = strdup(optarg);
- if (args.pa_kernel == NULL)
- errx(EX_SOFTWARE, "ERROR: Out of memory");
- args.pa_required |= FLAG_DO_ANALYSIS;
- args.pa_flags |= FLAG_HAS_KERNELPATH;
+ warnx("WARNING: -k is obsolete, has no effect "
+ "and will be removed in FreeBSD 15.");
break;
case 'L':
@@ -640,6 +644,7 @@ main(int argc, char **argv)
case 's': /* system-wide counting PMC */
case 'P': /* process virtual sampling PMC */
case 'S': /* system-wide sampling PMC */
+ caps = 0;
if ((ev = malloc(sizeof(*ev))) == NULL)
errx(EX_SOFTWARE, "ERROR: Out of memory.");
@@ -708,8 +713,55 @@ main(int argc, char **argv)
(void) strncpy(ev->ev_name, optarg, c);
*(ev->ev_name + c) = '\0';
+ libpmc_initialize(&npmc);
+
+ if (args.pa_flags & FLAG_HAS_SYSTEM_PMCS) {
+ /*
+ * We need to check the capabilities of the
+ * desired event to determine if it should be
+ * allocated on every CPU, or only a subset of
+ * them. This requires allocating a PMC now.
+ */
+ if (pmc_allocate(ev->ev_spec, ev->ev_mode,
+ ev->ev_flags, ev->ev_cpu, &ev->ev_pmcid,
+ ev->ev_count) < 0)
+ err(EX_OSERR, "ERROR: Cannot allocate "
+ "system-mode pmc with specification"
+ " \"%s\"", ev->ev_spec);
+ if (pmc_capabilities(ev->ev_pmcid, &caps)) {
+ pmc_release(ev->ev_pmcid);
+ err(EX_OSERR, "ERROR: Cannot get pmc "
+ "capabilities");
+ }
+
+ /*
+ * Release the PMC now that we have caps; we
+ * will reallocate shortly.
+ */
+ pmc_release(ev->ev_pmcid);
+ ev->ev_pmcid = PMC_ID_INVALID;
+ }
+
STAILQ_INSERT_TAIL(&args.pa_events, ev, ev_next);
+ if ((caps & PMC_CAP_SYSWIDE) == PMC_CAP_SYSWIDE)
+ break;
+ if ((caps & PMC_CAP_DOMWIDE) == PMC_CAP_DOMWIDE) {
+ CPU_ZERO(&cpumask);
+ /*
+ * Get number of domains and allocate one
+ * counter in each.
+ * First already allocated.
+ */
+ for (i = 1; i < domains; i++) {
+ CPU_ZERO(&dommask);
+ cpuset_getaffinity(CPU_LEVEL_WHICH,
+ CPU_WHICH_DOMAIN, i, sizeof(dommask),
+ &dommask);
+ CPU_SET(CPU_FFS(&dommask) - 1, &cpumask);
+ }
+ args.pa_flags |= FLAGS_HAS_CPUMASK;
+ }
if (option == 's' || option == 'S') {
CPU_CLR(ev->ev_cpu, &cpumask);
pmcstat_clone_event_descriptor(ev, &cpumask, &args);
@@ -923,7 +975,7 @@ main(int argc, char **argv)
if ((args.pa_required & FLAG_HAS_PROCESS_PMCS) &&
(args.pa_flags & FLAG_HAS_PROCESS_PMCS) == 0)
errx(EX_USAGE,
-"ERROR: options -d, -E, and -W require a process mode PMC to be specified."
+"ERROR: options -d, -E, -t, and -W require a process mode PMC to be specified."
);
/* check for -c cpu with no system mode PMCs or logfile. */
@@ -969,12 +1021,6 @@ main(int argc, char **argv)
"ERROR: option -O is used only with options -E, -P, -S and -W."
);
- /* -k kernel path require -g/-G/-m/-T or -R */
- if ((args.pa_flags & FLAG_HAS_KERNELPATH) &&
- (args.pa_flags & FLAG_DO_ANALYSIS) == 0 &&
- (args.pa_flags & FLAG_READ_LOGFILE) == 0)
- errx(EX_USAGE, "ERROR: option -k is only used with -g/-R/-m/-T.");
-
/* -D only applies to gprof output mode (-g) */
if ((args.pa_flags & FLAG_HAS_SAMPLESDIR) &&
(args.pa_flags & FLAG_DO_GPROF) == 0)
@@ -999,36 +1045,6 @@ main(int argc, char **argv)
);
/*
- * Check if 'kerneldir' refers to a file rather than a
- * directory. If so, use `dirname path` to determine the
- * kernel directory.
- */
- (void) snprintf(buffer, sizeof(buffer), "%s%s", args.pa_fsroot,
- args.pa_kernel);
- if (stat(buffer, &sb) < 0)
- err(EX_OSERR, "ERROR: Cannot locate kernel \"%s\"",
- buffer);
- if (!S_ISREG(sb.st_mode) && !S_ISDIR(sb.st_mode))
- errx(EX_USAGE, "ERROR: \"%s\": Unsupported file type.",
- buffer);
- if (!S_ISDIR(sb.st_mode)) {
- tmp = args.pa_kernel;
- args.pa_kernel = strdup(dirname(args.pa_kernel));
- if (args.pa_kernel == NULL)
- errx(EX_SOFTWARE, "ERROR: Out of memory");
- free(tmp);
- (void) snprintf(buffer, sizeof(buffer), "%s%s",
- args.pa_fsroot, args.pa_kernel);
- if (stat(buffer, &sb) < 0)
- err(EX_OSERR, "ERROR: Cannot stat \"%s\"",
- buffer);
- if (!S_ISDIR(sb.st_mode))
- errx(EX_USAGE,
- "ERROR: \"%s\" is not a directory.",
- buffer);
- }
-
- /*
* If we have a callgraph be created, select the outputfile.
*/
if (args.pa_flags & FLAG_DO_CALLGRAPHS) {
@@ -1050,17 +1066,8 @@ main(int argc, char **argv)
}
/* if we've been asked to process a log file, skip init */
- if ((args.pa_flags & FLAG_READ_LOGFILE) == 0) {
- if (pmc_init() < 0)
- err(EX_UNAVAILABLE,
- "ERROR: Initialization of the pmc(3) library failed"
- );
-
- if ((npmc = pmc_npmc(0)) < 0) /* assume all CPUs are identical */
- err(EX_OSERR,
-"ERROR: Cannot determine the number of PMCs on CPU %d",
- 0);
- }
+ if ((args.pa_flags & FLAG_READ_LOGFILE) == 0)
+ libpmc_initialize(&npmc);
/* Allocate a kqueue */
if ((pmcstat_kq = kqueue()) < 0)
diff --git a/usr.sbin/pmcstat/pmcstat.h b/usr.sbin/pmcstat/pmcstat.h
index 4e15ab90367a..67571ce4b2ee 100644
--- a/usr.sbin/pmcstat/pmcstat.h
+++ b/usr.sbin/pmcstat/pmcstat.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2007, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -28,8 +28,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 _PMCSTAT_H_
diff --git a/usr.sbin/pmcstat/pmcstat_log.c b/usr.sbin/pmcstat/pmcstat_log.c
index 71f3b6b9b14e..c8fc414f6214 100644
--- a/usr.sbin/pmcstat/pmcstat_log.c
+++ b/usr.sbin/pmcstat/pmcstat_log.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2007, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -35,9 +35,6 @@
* gprof(1) compatible profiles.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/cpuset.h>
@@ -459,10 +456,11 @@ pmcstat_print_log(void)
ev.pl_u.pl_pc.pl_pcomm);
break;
case PMCLOG_TYPE_PROCEXEC:
- PMCSTAT_PRINT_ENTRY("exec","0x%x %d %p \"%s\"",
+ PMCSTAT_PRINT_ENTRY("exec","0x%x %d %p %p \"%s\"",
ev.pl_u.pl_x.pl_pmcid,
ev.pl_u.pl_x.pl_pid,
- (void *) ev.pl_u.pl_x.pl_entryaddr,
+ (void *)ev.pl_u.pl_x.pl_baseaddr,
+ (void *)ev.pl_u.pl_x.pl_dynaddr,
ev.pl_u.pl_x.pl_pathname);
break;
case PMCLOG_TYPE_PROCEXIT:
@@ -726,7 +724,7 @@ pmcstat_display_log(void)
pmcstat_refresh_top();
- /* Reset everythings if delta mode. */
+ /* Reset everything if delta mode. */
if (args.pa_topmode == PMCSTAT_TOP_DELTA) {
if (plugins[args.pa_plugin].pl_shutdown != NULL)
plugins[args.pa_plugin].pl_shutdown(NULL);
diff --git a/usr.sbin/pmcstat/pmcstat_log.h b/usr.sbin/pmcstat/pmcstat_log.h
index 20e64fcf9b9f..e4186734e702 100644
--- a/usr.sbin/pmcstat/pmcstat_log.h
+++ b/usr.sbin/pmcstat/pmcstat_log.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005-2007, Joseph Koshy
* Copyright (c) 2007 The FreeBSD Foundation
@@ -29,8 +29,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 _PMCSTAT_LOG_H_
diff --git a/usr.sbin/pmcstat/pmcstat_top.h b/usr.sbin/pmcstat/pmcstat_top.h
index f9173a4256c1..3d4ea89b75b6 100644
--- a/usr.sbin/pmcstat/pmcstat_top.h
+++ b/usr.sbin/pmcstat/pmcstat_top.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2009, Fabien Thomas
* 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 _PMCSTAT_TOP_H_
diff --git a/usr.sbin/pmcstudy/Makefile b/usr.sbin/pmcstudy/Makefile
index 18fd151b6599..af3fab50b95a 100644
--- a/usr.sbin/pmcstudy/Makefile
+++ b/usr.sbin/pmcstudy/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/9/93
-# $FreeBSD$
PROG= pmcstudy
MAN= pmcstudy.8
diff --git a/usr.sbin/pmcstudy/Makefile.depend b/usr.sbin/pmcstudy/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/pmcstudy/Makefile.depend
+++ b/usr.sbin/pmcstudy/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/pmcstudy/eval_expr.c b/usr.sbin/pmcstudy/eval_expr.c
index 984e5ea72176..32369f046177 100644
--- a/usr.sbin/pmcstudy/eval_expr.c
+++ b/usr.sbin/pmcstudy/eval_expr.c
@@ -32,8 +32,6 @@
#include <strings.h>
#include <ctype.h>
#include "eval_expr.h"
-__FBSDID("$FreeBSD$");
-
static struct expression *
alloc_and_hook_expr(struct expression **exp_p, struct expression **last_p)
{
diff --git a/usr.sbin/pmcstudy/eval_expr.h b/usr.sbin/pmcstudy/eval_expr.h
index 2c264ff711b2..de61e54b8c96 100644
--- a/usr.sbin/pmcstudy/eval_expr.h
+++ b/usr.sbin/pmcstudy/eval_expr.h
@@ -26,8 +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.
*/
-__FBSDID("$FreeBSD$");
-
enum exptype {
TYPE_OP_PLUS,
TYPE_OP_MINUS,
diff --git a/usr.sbin/pmcstudy/pmcstudy.8 b/usr.sbin/pmcstudy/pmcstudy.8
index 1e7d8c44cf9b..eacee1dc28bd 100644
--- a/usr.sbin/pmcstudy/pmcstudy.8
+++ b/usr.sbin/pmcstudy/pmcstudy.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd March 26, 2015
.Dt PMCSTUDY 8
.Os
diff --git a/usr.sbin/pmcstudy/pmcstudy.c b/usr.sbin/pmcstudy/pmcstudy.c
index c72822ccccf5..653ae7c53b44 100644
--- a/usr.sbin/pmcstudy/pmcstudy.c
+++ b/usr.sbin/pmcstudy/pmcstudy.c
@@ -35,8 +35,6 @@
#include <sys/wait.h>
#include <getopt.h>
#include "eval_expr.h"
-__FBSDID("$FreeBSD$");
-
static int max_pmc_counters = 1;
static int run_all = 0;
diff --git a/usr.sbin/pnfsdscopymr/Makefile b/usr.sbin/pnfsdscopymr/Makefile
index 4cefca6af690..dcce66b0b6ac 100644
--- a/usr.sbin/pnfsdscopymr/Makefile
+++ b/usr.sbin/pnfsdscopymr/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= nfs
diff --git a/usr.sbin/pnfsdscopymr/pnfsdscopymr.8 b/usr.sbin/pnfsdscopymr/pnfsdscopymr.8
index 4f540fe19cd9..607f902a585e 100644
--- a/usr.sbin/pnfsdscopymr/pnfsdscopymr.8
+++ b/usr.sbin/pnfsdscopymr/pnfsdscopymr.8
@@ -21,8 +21,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 2, 2018
.Dt PNFSDSCOPYMR 8
.Os
@@ -64,7 +62,7 @@ in order to recover the data
storage files onto a repaired DS.
.It Fl m Ar source-mounted-on-DS-dir destination-mounted-on-DS-dir
This option indicates that the data storage file is to be migrated from
-the source DS mounted on the diectory
+the source DS mounted on the directory
.Dq source-mounted-on-DS-dir
to the DS mounted on the directory
.Dq destination-mounted-on-DS-dir .
diff --git a/usr.sbin/pnfsdscopymr/pnfsdscopymr.c b/usr.sbin/pnfsdscopymr/pnfsdscopymr.c
index 9526d04eabab..2f155ed354c0 100644
--- a/usr.sbin/pnfsdscopymr/pnfsdscopymr.c
+++ b/usr.sbin/pnfsdscopymr/pnfsdscopymr.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2017 Rick Macklem
*
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <errno.h>
#include <getopt.h>
@@ -53,7 +51,7 @@ __FBSDID("$FreeBSD$");
#include <fs/nfs/nfs.h>
#include <fs/nfs/nfsrvstate.h>
-static void usage(void);
+static void usage(void) __dead2;
static struct option longopts[] = {
{ "migrate", required_argument, NULL, 'm' },
@@ -173,7 +171,7 @@ main(int argc, char *argv[])
pnfsdarg.dspath);
/*
- * Check the IP address of the NFS server against the entrie(s)
+ * Check the IP address of the NFS server against the entry(ies)
* in the extended attribute.
*/
strlcpy(host, sf.f_mntfromname, sizeof(host));
@@ -235,7 +233,7 @@ main(int argc, char *argv[])
pnfsdarg.curdspath);
/*
- * Check the IP address of the NFS server against the entrie(s)
+ * Check the IP address of the NFS server against the entry(ies)
* in the extended attribute.
*/
strlcpy(host, sf.f_mntfromname, sizeof(host));
diff --git a/usr.sbin/pnfsdsfile/Makefile b/usr.sbin/pnfsdsfile/Makefile
index 2a85baf33fc1..55af5d58816e 100644
--- a/usr.sbin/pnfsdsfile/Makefile
+++ b/usr.sbin/pnfsdsfile/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= nfs
diff --git a/usr.sbin/pnfsdsfile/pnfsdsfile.8 b/usr.sbin/pnfsdsfile/pnfsdsfile.8
index c6fb2e2f48f5..996026fc7b01 100644
--- a/usr.sbin/pnfsdsfile/pnfsdsfile.8
+++ b/usr.sbin/pnfsdsfile/pnfsdsfile.8
@@ -21,8 +21,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 30, 2018
.Dt PNFSDSFILE 8
.Os
diff --git a/usr.sbin/pnfsdsfile/pnfsdsfile.c b/usr.sbin/pnfsdsfile/pnfsdsfile.c
index 944903c807e4..37b2bc79d46a 100644
--- a/usr.sbin/pnfsdsfile/pnfsdsfile.c
+++ b/usr.sbin/pnfsdsfile/pnfsdsfile.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2017 Rick Macklem
*
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <getopt.h>
#include <netdb.h>
@@ -46,7 +44,7 @@ __FBSDID("$FreeBSD$");
#include <fs/nfs/nfs.h>
#include <fs/nfs/nfsrvstate.h>
-static void usage(void);
+static void usage(void) __dead2;
static struct option longopts[] = {
{ "changeds", required_argument, NULL, 'c' },
diff --git a/usr.sbin/pnfsdskill/Makefile b/usr.sbin/pnfsdskill/Makefile
index 49b1c3b00d67..c7f74773f9e1 100644
--- a/usr.sbin/pnfsdskill/Makefile
+++ b/usr.sbin/pnfsdskill/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= nfs
diff --git a/usr.sbin/pnfsdskill/pnfsdskill.8 b/usr.sbin/pnfsdskill/pnfsdskill.8
index ce654aa94965..a08492fdb966 100644
--- a/usr.sbin/pnfsdskill/pnfsdskill.8
+++ b/usr.sbin/pnfsdskill/pnfsdskill.8
@@ -21,8 +21,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd July 9, 2018
.Dt PNFSDSKILL 8
.Os
diff --git a/usr.sbin/pnfsdskill/pnfsdskill.c b/usr.sbin/pnfsdskill/pnfsdskill.c
index 55bbde687553..06b0dee6d361 100644
--- a/usr.sbin/pnfsdskill/pnfsdskill.c
+++ b/usr.sbin/pnfsdskill/pnfsdskill.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2017 Rick Macklem
*
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <getopt.h>
#include <stdio.h>
@@ -43,7 +41,7 @@ __FBSDID("$FreeBSD$");
#include <fs/nfs/nfskpiport.h>
#include <fs/nfs/nfs.h>
-static void usage(void);
+static void usage(void) __dead2;
static struct option longopts[] = {
{ "force", no_argument, NULL, 'f' },
diff --git a/usr.sbin/pnpinfo/Makefile b/usr.sbin/pnpinfo/Makefile
index 450fe740f89d..3a8579835499 100644
--- a/usr.sbin/pnpinfo/Makefile
+++ b/usr.sbin/pnpinfo/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/contrib/pnpinfo
diff --git a/usr.sbin/pnpinfo/Makefile.depend b/usr.sbin/pnpinfo/Makefile.depend
index c729e17c52db..77f8f90c31c3 100644
--- a/usr.sbin/pnpinfo/Makefile.depend
+++ b/usr.sbin/pnpinfo/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/portsnap/Makefile b/usr.sbin/portsnap/Makefile
deleted file mode 100644
index 169befd6e726..000000000000
--- a/usr.sbin/portsnap/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# $FreeBSD$
-
-SUBDIR= portsnap make_index
-
-.include <bsd.subdir.mk>
diff --git a/usr.sbin/portsnap/Makefile.inc b/usr.sbin/portsnap/Makefile.inc
deleted file mode 100644
index 5f6527edb373..000000000000
--- a/usr.sbin/portsnap/Makefile.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-# $FreeBSD$
-
-LIBEXECDIR?= /usr/libexec
-
-.include "../Makefile.inc"
diff --git a/usr.sbin/portsnap/make_index/Makefile b/usr.sbin/portsnap/make_index/Makefile
deleted file mode 100644
index 92e91450e4fd..000000000000
--- a/usr.sbin/portsnap/make_index/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# $FreeBSD$
-
-PROG= make_index
-MAN=
-
-BINDIR= ${LIBEXECDIR}
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/portsnap/make_index/make_index.c b/usr.sbin/portsnap/make_index/make_index.c
deleted file mode 100644
index 642404b63605..000000000000
--- a/usr.sbin/portsnap/make_index/make_index.c
+++ /dev/null
@@ -1,515 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright 2005 Colin Percival
- * All rights reserved
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted providing that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-struct port;
-
-typedef union {
- char * name;
- struct port * p;
-} DEP;
-
-typedef struct port {
- char * pkgname;
- char * portdir;
- char * prefix;
- char * comment;
- char * pkgdescr;
- char * maintainer;
- char * categories;
- size_t n_edep;
- DEP * edep;
- size_t n_pdep;
- DEP * pdep;
- size_t n_fdep;
- DEP * fdep;
- size_t n_bdep;
- DEP * bdep;
- size_t n_rdep;
- DEP * rdep;
- char * www;
- int recursed;
-} PORT;
-
-static void usage(void);
-static char * strdup2(const char *str);
-static DEP * makelist(char * str, size_t * n);
-static PORT * portify(char * line);
-static int portcompare(char * a, char * b);
-static void heapifyports(PORT **pp, size_t size, size_t pos);
-static PORT * findport(PORT ** pp, size_t st, size_t en, char * name, char * from);
-static void translateport(PORT ** pp, size_t pplen, PORT * p);
-static DEP * recurse_one(DEP * d, size_t * nd);
-static void recurse(PORT * p);
-static void heapifypkgs(DEP * d, size_t size, size_t pos);
-static void sortpkgs(DEP * d, size_t nd);
-static void printport(PORT * p);
-
-static void
-usage(void)
-{
-
- fprintf(stderr, "usage: make_index file\n");
- exit(1);
- /* NOTREACHED */
-}
-
-static char *
-strdup2(const char *str)
-{
- char * r;
-
- r = strdup(str);
- if (r == NULL)
- err(1, "strdup");
- return r;
-}
-
-/* Take a space-separated list and return an array of (char *) */
-static DEP *
-makelist(char * str, size_t * n)
-{
- DEP * d;
- size_t i;
-
- /* No depends at all? */
- if (str[0] == 0) {
- *n = 0;
- return NULL;
- }
-
- /* Count the number of fields */
- *n = 1;
- for (i = 0; str[i] != 0; i++)
- if (str[i] == ' ')
- (*n)++;
-
- /* Allocate and fill an array */
- d = malloc(*n * sizeof(DEP));
- if (d == NULL)
- err(1, "malloc(DEP)");
- for (i = 0; i < *n; i++) {
- d[i].name = strdup2(strsep(&str, " "));
-
- /* Strip trailing slashes */
- if (d[i].name[strlen(d[i].name) - 1] == '/')
- d[i].name[strlen(d[i].name) - 1] = 0;
- }
-
- return d;
-}
-
-/* Take a port's describe line and split it into fields */
-static PORT *
-portify(char * line)
-{
- PORT * p;
- size_t i, n;
-
- /* Verify that line has the right number of fields */
- for (n = i = 0; line[i] != 0; i++)
- if (line[i] == '|')
- n++;
- if (n != 12)
- errx(1, "Port describe line is corrupt:\n%s\n", line);
-
- p = malloc(sizeof(PORT));
- if (p == NULL)
- err(1, "malloc(PORT)");
-
- p->pkgname = strdup2(strsep(&line, "|"));
- p->portdir = strdup2(strsep(&line, "|"));
- p->prefix = strdup2(strsep(&line, "|"));
- p->comment = strdup2(strsep(&line, "|"));
- p->pkgdescr = strdup2(strsep(&line, "|"));
- p->maintainer = strdup2(strsep(&line, "|"));
- p->categories = strdup2(strsep(&line, "|"));
- p->edep = makelist(strsep(&line, "|"), &p->n_edep);
- p->pdep = makelist(strsep(&line, "|"), &p->n_pdep);
- p->fdep = makelist(strsep(&line, "|"), &p->n_fdep);
- p->bdep = makelist(strsep(&line, "|"), &p->n_bdep);
- p->rdep = makelist(strsep(&line, "|"), &p->n_rdep);
- p->www = strdup2(strsep(&line, "|"));
-
- p->recursed = 0;
-
- /*
- * line will now be equal to NULL -- we counted the field
- * separators at the top of the function.
- */
-
- return p;
-}
-
-/* Returns -1, 0, or 1 based on a comparison of the portdir strings */
-static int
-portcompare(char * a, char * b)
-{
- size_t i;
-
- /* Find first non-matching position */
- for (i = 0; ; i++) {
- if (a[i] != b[i])
- break;
- if (a[i] == 0) /* End of strings */
- return 0;
- }
-
- /* One string is a prefix of the other */
- if (a[i] == 0)
- return -1;
- if (b[i] == 0)
- return 1;
-
- /* One string has a category which is a prefix of the other */
- if (a[i] == '/')
- return -1;
- if (b[i] == '/')
- return 1;
-
- /* The two strings are simply different */
- if (a[i] < b[i])
- return -1;
- else
- return 1;
-}
-
-/* Heapify (PORT *) number pos in a pseudo-heap pp[0]..pp[size - 1] */
-static void
-heapifyports(PORT **pp, size_t size, size_t pos)
-{
- size_t i = pos;
- PORT * tmp;
-
-top:
- /* Find the largest value out of {pos, 2*pos+1, 2*pos+2} */
- if ((2 * pos + 1 < size) &&
- (portcompare(pp[i]->portdir, pp[2 * pos + 1]->portdir) < 0))
- i = 2 * pos + 1;
- if ((2 * pos + 2 < size) &&
- (portcompare(pp[i]->portdir, pp[2 * pos + 2]->portdir) < 0))
- i = 2 * pos + 2;
-
- /* If necessary, swap elements and iterate down the tree. */
- if (i != pos) {
- tmp = pp[pos];
- pp[pos] = pp[i];
- pp[i] = tmp;
- pos = i;
- goto top;
- }
-}
-
-/* Translate a port directory name into a (PORT *), and free the name */
-static PORT *
-findport(PORT ** pp, size_t st, size_t en, char * name, char * from)
-{
- size_t mid;
- int r;
-
- if (st == en)
- errx(1, "%s: no entry for %s", from, name);
-
- mid = (st + en) / 2;
- r = portcompare(pp[mid]->portdir, name);
-
- if (r == 0) {
- free(name);
- return pp[mid];
- } else if (r < 0)
- return findport(pp, mid + 1, en, name, from);
- else
- return findport(pp, st, mid, name, from);
-}
-
-/* Translate all depends from names into PORT *s */
-static void
-translateport(PORT ** pp, size_t pplen, PORT * p)
-{
- size_t i;
-
- for (i = 0; i < p->n_edep; i++)
- p->edep[i].p = findport(pp, 0, pplen, p->edep[i].name, p->portdir);
- for (i = 0; i < p->n_pdep; i++)
- p->pdep[i].p = findport(pp, 0, pplen, p->pdep[i].name, p->portdir);
- for (i = 0; i < p->n_fdep; i++)
- p->fdep[i].p = findport(pp, 0, pplen, p->fdep[i].name, p->portdir);
- for (i = 0; i < p->n_bdep; i++)
- p->bdep[i].p = findport(pp, 0, pplen, p->bdep[i].name, p->portdir);
- for (i = 0; i < p->n_rdep; i++)
- p->rdep[i].p = findport(pp, 0, pplen, p->rdep[i].name, p->portdir);
-}
-
-/* Recurse on one specific depends list */
-static DEP *
-recurse_one(DEP * d, size_t * nd)
-{
- size_t i, j, k, n, N;
-
- N = n = *nd;
- for (i = 0; i < n; i++) {
- recurse(d[i].p);
- for (j = 0; j < d[i].p->n_rdep; j++) {
- for (k = 0; k < N; k++) {
- if (d[i].p->rdep[j].p == d[k].p)
- break;
- }
- if (k == N) {
- N++;
- if (N >= *nd) {
- *nd += *nd;
- d = realloc(d, *nd * sizeof(DEP));
- if (d == NULL)
- err(1, "realloc(d)");
- }
- d[k].p = d[i].p->rdep[j].p;
- }
- }
- }
- *nd = N;
-
- return d;
-}
-
-/* Recurse on the depends lists */
-static void
-recurse(PORT * p)
-{
- switch (p->recursed) {
- case 0:
- /* First time we've seen this port */
- p->recursed = 1;
- break;
- case 1:
- /* We're in the middle of recursing this port */
- errx(1, "Circular dependency loop found: %s"
- " depends upon itself.\n", p->pkgname);
- case 2:
- /* This port has already been recursed */
- return;
- }
-
- p->edep = recurse_one(p->edep, &p->n_edep);
- p->pdep = recurse_one(p->pdep, &p->n_pdep);
- p->fdep = recurse_one(p->fdep, &p->n_fdep);
- p->bdep = recurse_one(p->bdep, &p->n_bdep);
- p->rdep = recurse_one(p->rdep, &p->n_rdep);
-
- /* Finished recursing on this port */
- p->recursed = 2;
-}
-
-/* Heapify an element in a package list */
-static void
-heapifypkgs(DEP * d, size_t size, size_t pos)
-{
- size_t i = pos;
- PORT * tmp;
-
-top:
- /* Find the largest value out of {pos, 2*pos+1, 2*pos+2} */
- if ((2 * pos + 1 < size) &&
- (strcmp(d[i].p->pkgname, d[2 * pos + 1].p->pkgname) < 0))
- i = 2 * pos + 1;
- if ((2 * pos + 2 < size) &&
- (strcmp(d[i].p->pkgname, d[2 * pos + 2].p->pkgname) < 0))
- i = 2 * pos + 2;
-
- /* If necessary, swap elements and iterate down the tree. */
- if (i != pos) {
- tmp = d[pos].p;
- d[pos].p = d[i].p;
- d[i].p = tmp;
- pos = i;
- goto top;
- }
-}
-
-/* Sort a list of dependent packages in alphabetical order */
-static void
-sortpkgs(DEP * d, size_t nd)
-{
- size_t i;
- PORT * tmp;
-
- if (nd == 0)
- return;
-
- for (i = nd; i > 0; i--)
- heapifypkgs(d, nd, i - 1); /* Build a heap */
- for (i = nd - 1; i > 0; i--) {
- tmp = d[0].p; /* Extract elements */
- d[0].p = d[i].p;
- d[i].p = tmp;
- heapifypkgs(d, i, 0); /* And re-heapify */
- }
-}
-
-/* Output an index line for the given port. */
-static void
-printport(PORT * p)
-{
- size_t i;
-
- sortpkgs(p->edep, p->n_edep);
- sortpkgs(p->pdep, p->n_pdep);
- sortpkgs(p->fdep, p->n_fdep);
- sortpkgs(p->bdep, p->n_bdep);
- sortpkgs(p->rdep, p->n_rdep);
-
- printf("%s|%s|%s|%s|%s|%s|%s|",
- p->pkgname, p->portdir, p->prefix, p->comment, p->pkgdescr,
- p->maintainer, p->categories);
- for (i = 0; i < p->n_bdep; i++)
- printf("%s%s", i ? " " : "", p->bdep[i].p->pkgname);
- printf("|");
- for (i = 0; i < p->n_rdep; i++)
- printf("%s%s", i ? " " : "", p->rdep[i].p->pkgname);
- printf("|");
- printf("%s|", p->www);
- for (i = 0; i < p->n_edep; i++)
- printf("%s%s", i ? " " : "", p->edep[i].p->pkgname);
- printf("|");
- for (i = 0; i < p->n_pdep; i++)
- printf("%s%s", i ? " " : "", p->pdep[i].p->pkgname);
- printf("|");
- for (i = 0; i < p->n_fdep; i++)
- printf("%s%s", i ? " " : "", p->fdep[i].p->pkgname);
- printf("\n");
-}
-
-/*
- * Algorithm:
- * 1. Suck in all the data, splitting into fields.
- * 1a. If there are no ports, there is no INDEX.
- * 2. Sort the ports according to port directory.
- * 3. Using a binary search, translate each dependency from a
- * port directory name into a pointer to a port.
- * 4. Recursively follow dependencies, expanding the lists of
- * pointers as needed (using realloc).
- * 5. Iterate through the ports, printing them out (remembering
- * to list the dependent ports in alphabetical order).
- */
-
-int
-main(int argc, char *argv[])
-{
- FILE * f;
- char * line;
- size_t linelen;
- PORT ** pp; /* Array of pointers to PORTs */
- PORT * tmp;
- size_t pplen; /* Allocated size of array */
- size_t i;
-
- if (argc != 2)
- usage();
- if ((f = fopen(argv[1], "r")) == NULL)
- err(1, "fopen(%s)", argv[1]);
-
- pplen = 1024;
- if ((pp = malloc(pplen * sizeof(PORT *))) == NULL)
- err(1, "malloc(pp)");
-
- /*
- * 1. Suck in all the data, splitting into fields.
- */
- for(i = 0; (line = fgetln(f, &linelen)) != NULL; i++) {
- if (line[linelen - 1] != '\n')
- errx(1, "Unterminated line encountered");
- line[linelen - 1] = 0;
-
- /* Enlarge array if needed */
- if (i >= pplen) {
- pplen *= 2;
- if ((pp = realloc(pp, pplen * sizeof(PORT *))) == NULL)
- err(1, "realloc(pp)");
- }
-
- pp[i] = portify(line);
- }
- /* Reallocate to the correct size */
- pplen = i;
- if ((pp = realloc(pp, pplen * sizeof(PORT *))) == NULL)
- err(1, "realloc(pp)");
-
- /* Make sure we actually reached the EOF */
- if (!feof(f))
- err(1, "fgetln(%s)", argv[1]);
- /* Close the describes file */
- if (fclose(f) != 0)
- err(1, "fclose(%s)", argv[1]);
-
- /*
- * 1a. If there are no ports, there is no INDEX.
- */
- if (pplen == 0)
- return 0;
-
- /*
- * 2. Sort the ports according to port directory.
- */
- for (i = pplen; i > 0; i--)
- heapifyports(pp, pplen, i - 1); /* Build a heap */
- for (i = pplen - 1; i > 0; i--) {
- tmp = pp[0]; /* Extract elements */
- pp[0] = pp[i];
- pp[i] = tmp;
- heapifyports(pp, i, 0); /* And re-heapify */
- }
-
- /*
- * 3. Using a binary search, translate each dependency from a
- * port directory name into a pointer to a port.
- */
- for (i = 0; i < pplen; i++)
- translateport(pp, pplen, pp[i]);
-
- /*
- * 4. Recursively follow dependencies, expanding the lists of
- * pointers as needed (using realloc).
- */
- for (i = 0; i < pplen; i++)
- recurse(pp[i]);
-
- /*
- * 5. Iterate through the ports, printing them out (remembering
- * to list the dependent ports in alphabetical order).
- */
- for (i = 0; i < pplen; i++)
- printport(pp[i]);
-
- return 0;
-}
diff --git a/usr.sbin/portsnap/portsnap/Makefile b/usr.sbin/portsnap/portsnap/Makefile
deleted file mode 100644
index 6acd3f523751..000000000000
--- a/usr.sbin/portsnap/portsnap/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# $FreeBSD$
-
-CONFS= portsnap.conf
-SCRIPTS=portsnap.sh
-MAN= portsnap.8
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/portsnap/portsnap/portsnap.8 b/usr.sbin/portsnap/portsnap/portsnap.8
deleted file mode 100644
index 6357fe0f9e8b..000000000000
--- a/usr.sbin/portsnap/portsnap/portsnap.8
+++ /dev/null
@@ -1,288 +0,0 @@
-.\"-
-.\" Copyright 2004-2005 Colin Percival
-.\" All rights reserved
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted providing that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-.\" POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 1, 2018
-.Dt PORTSNAP 8
-.Os FreeBSD
-.Sh NAME
-.Nm portsnap
-.Nd fetch and extract compressed snapshots of the ports tree
-.Sh SYNOPSIS
-.Nm
-.Op Fl I
-.Op Fl d Ar workdir
-.Op Fl f Ar conffile
-.Op Fl k Ar KEY
-.Op Fl l Ar descfile
-.Op Fl p Ar portsdir
-.Op Fl s Ar server
-.Cm command ...
-.Op Ar path
-.Sh DESCRIPTION
-The
-.Nm
-tool is used to fetch and update compressed snapshots
-of the
-.Fx
-ports tree, and extract and update an
-uncompressed ports tree.
-.Pp
-In a normal update operation,
-.Nm
-will routinely restore modified files to their unmodified state and
-delete unrecognized local files.
-.Sh OPTIONS
-The following options are supported:
-.Bl -tag -width "-f conffile"
-.It Fl d Ar workdir
-Store working files (e.g.\& downloaded updates) in
-.Ar workdir .
-(default:
-.Pa /var/db/portsnap ,
-or as given in the configuration file.)
-.It Fl f Ar conffile
-Read the configuration from
-.Ar conffile .
-(default:
-.Pa /etc/portsnap.conf )
-.It Fl I
-For the
-.Cm update
-command, update INDEX files, but not the rest of the ports tree.
-.It Fl k Ar KEY
-Expect a public key with given SHA256 hash.
-(default: read value from configuration file.)
-.It Fl l Ar descfile
-Merge the specified local describes file into the INDEX files being
-built.
-The
-.Ar descfile
-should be generated by running
-.Cm make describe
-in each of the local port directories.
-.It Fl p Ar portsdir
-When extracting or updating an uncompressed snapshot,
-operate on the directory
-.Ar portsdir .
-(default:
-.Pa /usr/ports/ ,
-or as given in the configuration file.)
-.It Fl s Ar server
-Fetch files from the specified server or server pool.
-(default: portsnap.FreeBSD.org, or as given in the
-configuration file.)
-.It path
-For
-.Cm extract
-command only, operate only on parts of the ports tree starting with
-.Ar path .
-(e.g.\&
-.Nm
-.Cm extract
-.Ar sysutils/port
-would extract sysutils/portsman, sysutils/portsnap,
-sysutils/portupgrade, etc.)
-.It Fl Fl interactive
-override auto-detection of calling process.
-Only use this when calling portsnap from an
-.Sy interactive, non-terminal application.
-(Cron jobs are particularly bad since they cause
-load spikes on the Portsnap mirrors.)
-.El
-.Sh COMMANDS
-The
-.Cm command
-can be any one of the following:
-.Bl -tag -width "-f conffile"
-.It fetch
-Fetch a compressed snapshot of the ports tree, or update
-the existing snapshot.
-This command should only be used interactively; for
-non-interactive use, you should use the
-.Cm cron
-command.
-.It cron
-Sleep a random amount of time between 1 and 3600 seconds,
-then operate as if the
-.Cm fetch
-command was specified.
-As the name suggests, this command is designed for running
-from
-.Xr cron 8 ;
-the random delay serves to minimize the probability that
-a large number of machines will simultaneously attempt to
-fetch updates.
-.It extract
-Extract a ports tree, replacing existing files and directories.
-NOTE: This will remove anything occupying the location where
-files or directories are being extracted; in particular, any
-changes made locally to the ports tree (for example, adding new
-patches) will be silently obliterated.
-.Pp
-Only run this command to initialize your portsnap-maintained
-ports tree for the first time, if you wish to start over with
-a clean, completely unmodified tree, or if you wish to extract
-a specific part of the tree (using the
-.Ar path
-option).
-.It update
-Update a ports tree extracted using the
-.Cm extract
-command.
-You must run this command to apply changes to your ports tree
-after downloading updates via the
-.Cm fetch
-or
-.Cm cron
-commands.
-Again, note that in the parts of the ports tree which are being
-updated, any local changes or additions will be removed.
-.It auto
-Run
-.Cm fetch
-or
-.Cm cron
-depending on whether stdin is a terminal; then run
-.Cm update
-or
-.Cm extract
-depending on whether
-.Ar portsdir
-exists.
-.El
-.Sh TIPS
-.Bl -bullet
-.It
-If your clock is set to local time, adding the line
-.Pp
-.Dl 0 3 * * * root /usr/sbin/portsnap cron
-.Pp
-to
-.Pa /etc/crontab
-is a good way to make sure you always have
-an up-to-date snapshot of the ports tree available which
-can quickly be extracted into
-.Pa /usr/ports .
-If your clock is set to UTC, please pick a random time other
-than 3AM, to avoid overly imposing an uneven load on the
-server(s) hosting the snapshots.
-.Pp
-Note that running
-.Nm
-.Cm cron
-or
-.Nm
-.Cm fetch
-does not apply the changes that were received: they only download
-them.
-To apply the changes, you must follow these commands with
-.Nm
-.Cm update .
-The
-.Nm
-.Cm update
-command is normally run by hand at a time when you are sure that
-no one is manually working in the ports tree.
-.It
-Running
-.Nm
-.Cm update
-from
-.Xr cron 8
-is a bad idea -- if you are ever installing or updating a
-port at the time the cron job runs, you will probably end up
-in a mess when
-.Nm
-updates or removes files which are being used by the port
-build.
-However, running
-.Nm
-.Fl I
-.Cm update
-is probably safe, and can be used together with
-.Xr pkg-version 8
-to identify installed software which is out of date.
-.It
-If you wish to use
-.Nm
-to keep a large number of machines up to date, you may wish
-to set up a caching HTTP proxy.
-Since
-.Nm
-uses
-.Xr fetch 1
-to download updates, setting the
-.Ev HTTP_PROXY
-environment variable will direct it to fetch updates from
-the given proxy.
-This is much more efficient than
-.Em mirroring
-the files on the portsnap server, since the vast majority
-of files are not needed by any particular client.
-.El
-.Sh PRIVACY NOTICE
-As an unavoidable part of its operation, a machine running
-.Nm
-will make its public IP address and the list of files it fetches
-available to the server from which it fetches updates.
-Using these it may be possible to recognize a machine over an extended
-period of time, determine when it is updated, and identify which
-portions of the FreeBSD ports tree, if any, are being ignored using
-"REFUSE" directives in
-.Pa portsnap.conf .
-In addition, the FreeBSD release level is transmitted to the server.
-.Pp
-Statistical data generated from information collected in this manner
-may be published, but only in aggregate and after anonymizing the
-individual systems.
-.Sh FILES
-.Bl -tag -width "/etc/portsnap.conf"
-.It Pa /etc/portsnap.conf
-Default location of the portsnap configuration file.
-.It Pa /var/db/portsnap
-Default location where compressed snapshots are stored.
-.It Pa /usr/ports
-Default location where the ports tree is extracted.
-.El
-.Sh EXAMPLES
-Fetch the snapshots and create the
-.Xr ports 7
-tree under
-.Pa /usr/ports :
-.Dl Nm Ar fetch Ar extract
-.Pp
-Update the ports tree:
-.Dl Nm Ar fetch Ar update
-.Sh SEE ALSO
-.Xr fetch 1 ,
-.Xr sha256 1 ,
-.Xr fetch 3 ,
-.Xr portsnap.conf 5 ,
-.Xr pkg 7 ,
-.Xr pkg-version 8
-.Sh AUTHORS
-.An Colin Percival Aq Mt cperciva@FreeBSD.org
diff --git a/usr.sbin/portsnap/portsnap/portsnap.conf b/usr.sbin/portsnap/portsnap/portsnap.conf
deleted file mode 100644
index ab1d93c9b653..000000000000
--- a/usr.sbin/portsnap/portsnap/portsnap.conf
+++ /dev/null
@@ -1,36 +0,0 @@
-# $FreeBSD$
-
-# Default directory where compressed snapshots are stored.
-# WORKDIR=/var/db/portsnap
-
-# Default location of the ports tree (target for "update" and "extract").
-# PORTSDIR=/usr/ports
-
-# Server or server pool from which to fetch updates. You can change
-# this to point at a specific server if you want, but in most cases
-# using a "nearby" server won't provide a measurable improvement in
-# performance.
-SERVERNAME=portsnap.FreeBSD.org
-
-# Trusted keyprint. Changing this is a Bad Idea unless you've received
-# a PGP-signed email from <security-officer@FreeBSD.org> telling you to
-# change it and explaining why.
-KEYPRINT=9b5feee6d69f170e3dd0a2c8e469ddbd64f13f978f2f3aede40c98633216c330
-
-# Example of ignoring parts of the ports tree. If you know that you
-# absolutely will not need certain parts of the tree, this will save
-# some bandwidth and disk space. See the manual page for more details.
-#
-# WARNING: Working with an incomplete ports tree is not supported and
-# can cause problems due to missing dependencies. If you have REFUSE
-# directives and experience problems, remove them and update your tree
-# before asking for help on the mailing lists.
-#
-# REFUSE arabic chinese french german hebrew hungarian japanese
-# REFUSE korean polish portuguese russian ukrainian vietnamese
-
-# List of INDEX files to build and the DESCRIBE file to use for each
-#INDEX INDEX-11 DESCRIBE.11
-#INDEX INDEX-12 DESCRIBE.12
-#INDEX INDEX-13 DESCRIBE.13
-INDEX INDEX-14 DESCRIBE.14
diff --git a/usr.sbin/portsnap/portsnap/portsnap.sh b/usr.sbin/portsnap/portsnap/portsnap.sh
deleted file mode 100644
index ad40e3c9c95c..000000000000
--- a/usr.sbin/portsnap/portsnap/portsnap.sh
+++ /dev/null
@@ -1,1156 +0,0 @@
-#!/bin/sh
-
-#-
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
-#
-# Copyright 2004-2005 Colin Percival
-# All rights reserved
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted providing that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-# $FreeBSD$
-
-#### Usage function -- called from command-line handling code.
-
-# Usage instructions. Options not listed:
-# --debug -- don't filter output from utilities
-# --no-stats -- don't show progress statistics while fetching files
-usage() {
- cat <<EOF
-usage: `basename $0` [options] command ... [path]
-
-Options:
- -d workdir -- Store working files in workdir
- (default: /var/db/portsnap/)
- -f conffile -- Read configuration options from conffile
- (default: /etc/portsnap.conf)
- -I -- Update INDEX only. (update command only)
- -k KEY -- Trust an RSA key with SHA256 hash of KEY
- -l descfile -- Merge the specified local describes file into the INDEX.
- -p portsdir -- Location of uncompressed ports tree
- (default: /usr/ports/)
- -s server -- Server from which to fetch updates.
- (default: portsnap.FreeBSD.org)
- --interactive -- interactive: override auto-detection of calling process
- (use this when calling portsnap from an interactive, non-
- terminal application AND NEVER ELSE).
- path -- Extract only parts of the tree starting with the given
- string. (extract command only)
-Commands:
- fetch -- Fetch a compressed snapshot of the ports tree,
- or update an existing snapshot.
- cron -- Sleep rand(3600) seconds, and then fetch updates.
- extract -- Extract snapshot of ports tree, replacing existing
- files and directories.
- update -- Update ports tree to match current snapshot, replacing
- files and directories which have changed.
- auto -- Fetch updates, and either extract a new ports tree or
- update an existing tree.
-EOF
- exit 0
-}
-
-#### Parameter handling functions.
-
-# Initialize parameters to null, just in case they're
-# set in the environment.
-init_params() {
- KEYPRINT=""
- EXTRACTPATH=""
- WORKDIR=""
- PORTSDIR=""
- CONFFILE=""
- COMMAND=""
- COMMANDS=""
- QUIETREDIR=""
- QUIETFLAG=""
- STATSREDIR=""
- XARGST=""
- NDEBUG=""
- DDSTATS=""
- INDEXONLY=""
- SERVERNAME=""
- REFUSE=""
- LOCALDESC=""
- INTERACTIVE=""
-}
-
-# Parse the command line
-parse_cmdline() {
- while [ $# -gt 0 ]; do
- case "$1" in
- -d)
- if [ $# -eq 1 ]; then usage; fi
- if [ ! -z "${WORKDIR}" ]; then usage; fi
- shift; WORKDIR="$1"
- ;;
- --debug)
- QUIETREDIR="/dev/stderr"
- STATSREDIR="/dev/stderr"
- QUIETFLAG=" "
- NDEBUG=" "
- XARGST="-t"
- DDSTATS=".."
- ;;
- --interactive)
- INTERACTIVE="YES"
- ;;
- -f)
- if [ $# -eq 1 ]; then usage; fi
- if [ ! -z "${CONFFILE}" ]; then usage; fi
- shift; CONFFILE="$1"
- ;;
- -h | --help | help)
- usage
- ;;
- -I)
- INDEXONLY="YES"
- ;;
- -k)
- if [ $# -eq 1 ]; then usage; fi
- if [ ! -z "${KEYPRINT}" ]; then usage; fi
- shift; KEYPRINT="$1"
- ;;
- -l)
- if [ $# -eq 1 ]; then usage; fi
- if [ ! -z "${LOCALDESC}" ]; then usage; fi
- shift; LOCALDESC="$1"
- ;;
- --no-stats)
- if [ -z "${STATSREDIR}" ]; then
- STATSREDIR="/dev/null"
- DDSTATS=".. "
- fi
- ;;
- -p)
- if [ $# -eq 1 ]; then usage; fi
- if [ ! -z "${PORTSDIR}" ]; then usage; fi
- shift; PORTSDIR="$1"
- ;;
- -s)
- if [ $# -eq 1 ]; then usage; fi
- if [ ! -z "${SERVERNAME}" ]; then usage; fi
- shift; SERVERNAME="$1"
- ;;
- cron | extract | fetch | update | auto)
- COMMANDS="${COMMANDS} $1"
- ;;
- up)
- COMMANDS="${COMMANDS} update"
- ;;
- alfred)
- COMMANDS="${COMMANDS} auto"
- ;;
- *)
- if [ $# -gt 1 ]; then usage; fi
- if echo ${COMMANDS} | grep -vq extract; then
- usage
- fi
- EXTRACTPATH="$1"
- ;;
- esac
- shift
- done
-
- if [ -z "${COMMANDS}" ]; then
- usage
- fi
-}
-
-# If CONFFILE was specified at the command-line, make
-# sure that it exists and is readable.
-sanity_conffile() {
- if [ ! -z "${CONFFILE}" ] && [ ! -r "${CONFFILE}" ]; then
- echo -n "File does not exist "
- echo -n "or is not readable: "
- echo ${CONFFILE}
- exit 1
- fi
-}
-
-# If a configuration file hasn't been specified, use
-# the default value (/etc/portsnap.conf)
-default_conffile() {
- if [ -z "${CONFFILE}" ]; then
- CONFFILE="/etc/portsnap.conf"
- fi
-}
-
-# Read {KEYPRINT, SERVERNAME, WORKDIR, PORTSDIR} from the configuration
-# file if they haven't already been set. If the configuration
-# file doesn't exist, do nothing.
-# Also read REFUSE (which cannot be set via the command line) if it is
-# present in the configuration file.
-parse_conffile() {
- if [ -r "${CONFFILE}" ]; then
- for X in KEYPRINT WORKDIR PORTSDIR SERVERNAME; do
- eval _=\$${X}
- if [ -z "${_}" ]; then
- eval ${X}=`grep "^${X}=" "${CONFFILE}" |
- cut -f 2- -d '=' | tail -1`
- fi
- done
-
- if grep -qE "^REFUSE[[:space:]]" ${CONFFILE}; then
- REFUSE="^(`
- grep -E "^REFUSE[[:space:]]" "${CONFFILE}" |
- cut -c 7- | xargs echo | tr ' ' '|'
- `)"
- fi
-
- if grep -qE "^INDEX[[:space:]]" ${CONFFILE}; then
- INDEXPAIRS="`
- grep -E "^INDEX[[:space:]]" "${CONFFILE}" |
- cut -c 7- | tr ' ' '|' | xargs echo`"
- fi
- fi
-}
-
-# If parameters have not been set, use default values
-default_params() {
- _QUIETREDIR="/dev/null"
- _QUIETFLAG="-q"
- _STATSREDIR="/dev/stdout"
- _WORKDIR="/var/db/portsnap"
- _PORTSDIR="/usr/ports"
- _NDEBUG="-n"
- _LOCALDESC="/dev/null"
- for X in QUIETREDIR QUIETFLAG STATSREDIR WORKDIR PORTSDIR \
- NDEBUG LOCALDESC; do
- eval _=\$${X}
- eval __=\$_${X}
- if [ -z "${_}" ]; then
- eval ${X}=${__}
- fi
- done
- if [ -z "${INTERACTIVE}" ]; then
- if [ -t 0 ]; then
- INTERACTIVE="YES"
- else
- INTERACTIVE="NO"
- fi
- fi
-}
-
-# Perform sanity checks and set some final parameters
-# in preparation for fetching files. Also chdir into
-# the working directory.
-fetch_check_params() {
- export HTTP_USER_AGENT="portsnap (${COMMAND}, `uname -r`)"
-
- _SERVERNAME_z=\
-"SERVERNAME must be given via command line or configuration file."
- _KEYPRINT_z="Key must be given via -k option or configuration file."
- _KEYPRINT_bad="Invalid key fingerprint: "
- _WORKDIR_bad="Directory does not exist or is not writable: "
-
- if [ -z "${SERVERNAME}" ]; then
- echo -n "`basename $0`: "
- echo "${_SERVERNAME_z}"
- exit 1
- fi
- if [ -z "${KEYPRINT}" ]; then
- echo -n "`basename $0`: "
- echo "${_KEYPRINT_z}"
- exit 1
- fi
- if ! echo "${KEYPRINT}" | grep -qE "^[0-9a-f]{64}$"; then
- echo -n "`basename $0`: "
- echo -n "${_KEYPRINT_bad}"
- echo ${KEYPRINT}
- exit 1
- fi
- if ! [ -d "${WORKDIR}" -a -w "${WORKDIR}" ]; then
- echo -n "`basename $0`: "
- echo -n "${_WORKDIR_bad}"
- echo ${WORKDIR}
- exit 1
- fi
- cd ${WORKDIR} || exit 1
-
- BSPATCH=/usr/bin/bspatch
- SHA256=/sbin/sha256
- PHTTPGET=/usr/libexec/phttpget
-}
-
-# Perform sanity checks and set some final parameters
-# in preparation for extracting or updating ${PORTSDIR}
-# Complain if ${PORTSDIR} exists but is not writable,
-# but don't complain if ${PORTSDIR} doesn't exist.
-extract_check_params() {
- _WORKDIR_bad="Directory does not exist: "
- _PORTSDIR_bad="Directory is not writable: "
-
- if ! [ -d "${WORKDIR}" ]; then
- echo -n "`basename $0`: "
- echo -n "${_WORKDIR_bad}"
- echo ${WORKDIR}
- exit 1
- fi
- if [ -d "${PORTSDIR}" ] && ! [ -w "${PORTSDIR}" ]; then
- echo -n "`basename $0`: "
- echo -n "${_PORTSDIR_bad}"
- echo ${PORTSDIR}
- exit 1
- fi
-
- if ! [ -d "${WORKDIR}/files" -a -r "${WORKDIR}/tag" \
- -a -r "${WORKDIR}/INDEX" -a -r "${WORKDIR}/tINDEX" ]; then
- echo "No snapshot available. Try running"
- echo "# `basename $0` fetch"
- exit 1
- fi
-
- MKINDEX=/usr/libexec/make_index
-}
-
-# Perform sanity checks and set some final parameters
-# in preparation for updating ${PORTSDIR}
-update_check_params() {
- extract_check_params
-
- if ! [ -r ${PORTSDIR}/.portsnap.INDEX ]; then
- echo "${PORTSDIR} was not created by portsnap."
- echo -n "You must run '`basename $0` extract' before "
- echo "running '`basename $0` update'."
- exit 1
- fi
-
-}
-
-#### Core functionality -- the actual work gets done here
-
-# Use an SRV query to pick a server. If the SRV query doesn't provide
-# a useful answer, use the server name specified by the user.
-# Put another way... look up _http._tcp.${SERVERNAME} and pick a server
-# from that; or if no servers are returned, use ${SERVERNAME}.
-# This allows a user to specify "portsnap.freebsd.org" (in which case
-# portsnap will select one of the mirrors) or "portsnap5.tld.freebsd.org"
-# (in which case portsnap will use that particular server, since there
-# won't be an SRV entry for that name).
-#
-# We ignore the Port field, since we are always going to use port 80.
-
-# Fetch the mirror list, but do not pick a mirror yet. Returns 1 if
-# no mirrors are available for any reason.
-fetch_pick_server_init() {
- : > serverlist_tried
-
-# Check that host(1) exists (i.e., that the system wasn't built with the
-# WITHOUT_BIND set) and don't try to find a mirror if it doesn't exist.
- if ! which -s host; then
- : > serverlist_full
- return 1
- fi
-
- echo -n "Looking up ${SERVERNAME} mirrors... "
-
-# Issue the SRV query and pull out the Priority, Weight, and Target fields.
-# BIND 9 prints "$name has SRV record ..." while BIND 8 prints
-# "$name server selection ..."; we allow either format.
- MLIST="_http._tcp.${SERVERNAME}"
- host -t srv "${MLIST}" |
- sed -nE "s/${MLIST} (has SRV record|server selection) //Ip" |
- cut -f 1,2,4 -d ' ' |
- sed -e 's/\.$//' |
- sort > serverlist_full
-
-# If no records, give up -- we'll just use the server name we were given.
- if [ `wc -l < serverlist_full` -eq 0 ]; then
- echo "none found."
- return 1
- fi
-
-# Report how many mirrors we found.
- echo `wc -l < serverlist_full` "mirrors found."
-
-# Generate a random seed for use in picking mirrors. If HTTP_PROXY
-# is set, this will be used to generate the seed; otherwise, the seed
-# will be random.
- if [ -n "${HTTP_PROXY}${http_proxy}" ]; then
- RANDVALUE=`sha256 -qs "${HTTP_PROXY}${http_proxy}" |
- tr -d 'a-f' |
- cut -c 1-9`
- else
- RANDVALUE=`jot -r 1 0 999999999`
- fi
-}
-
-# Pick a mirror. Returns 1 if we have run out of mirrors to try.
-fetch_pick_server() {
-# Generate a list of not-yet-tried mirrors
- sort serverlist_tried |
- comm -23 serverlist_full - > serverlist
-
-# Have we run out of mirrors?
- if [ `wc -l < serverlist` -eq 0 ]; then
- echo "No mirrors remaining, giving up."
- return 1
- fi
-
-# Find the highest priority level (lowest numeric value).
- SRV_PRIORITY=`cut -f 1 -d ' ' serverlist | sort -n | head -1`
-
-# Add up the weights of the response lines at that priority level.
- SRV_WSUM=0
- while read X; do
- case "$X" in
- ${SRV_PRIORITY}\ *)
- SRV_W=`echo $X | cut -f 2 -d ' '`
- SRV_WSUM=$(($SRV_WSUM + $SRV_W))
- ;;
- esac
- done < serverlist
-
-# If all the weights are 0, pretend that they are all 1 instead.
- if [ ${SRV_WSUM} -eq 0 ]; then
- SRV_WSUM=`grep -E "^${SRV_PRIORITY} " serverlist | wc -l`
- SRV_W_ADD=1
- else
- SRV_W_ADD=0
- fi
-
-# Pick a value between 0 and the sum of the weights - 1
- SRV_RND=`expr ${RANDVALUE} % ${SRV_WSUM}`
-
-# Read through the list of mirrors and set SERVERNAME. Write the line
-# corresponding to the mirror we selected into serverlist_tried so that
-# we won't try it again.
- while read X; do
- case "$X" in
- ${SRV_PRIORITY}\ *)
- SRV_W=`echo $X | cut -f 2 -d ' '`
- SRV_W=$(($SRV_W + $SRV_W_ADD))
- if [ $SRV_RND -lt $SRV_W ]; then
- SERVERNAME=`echo $X | cut -f 3 -d ' '`
- echo "$X" >> serverlist_tried
- break
- else
- SRV_RND=$(($SRV_RND - $SRV_W))
- fi
- ;;
- esac
- done < serverlist
-}
-
-# Check that we have a public key with an appropriate hash, or
-# fetch the key if it doesn't exist. Returns 1 if the key has
-# not yet been fetched.
-fetch_key() {
- if [ -r pub.ssl ] && [ `${SHA256} -q pub.ssl` = ${KEYPRINT} ]; then
- return 0
- fi
-
- echo -n "Fetching public key from ${SERVERNAME}... "
- rm -f pub.ssl
- fetch ${QUIETFLAG} http://${SERVERNAME}/pub.ssl \
- 2>${QUIETREDIR} || true
- if ! [ -r pub.ssl ]; then
- echo "failed."
- return 1
- fi
- if ! [ `${SHA256} -q pub.ssl` = ${KEYPRINT} ]; then
- echo "key has incorrect hash."
- rm -f pub.ssl
- return 1
- fi
- echo "done."
-}
-
-# Fetch a snapshot tag
-fetch_tag() {
- rm -f snapshot.ssl tag.new
-
- echo ${NDEBUG} "Fetching snapshot tag from ${SERVERNAME}... "
- fetch ${QUIETFLAG} http://${SERVERNAME}/$1.ssl \
- 2>${QUIETREDIR} || true
- if ! [ -r $1.ssl ]; then
- echo "failed."
- return 1
- fi
-
- openssl rsautl -pubin -inkey pub.ssl -verify \
- < $1.ssl > tag.new 2>${QUIETREDIR} || true
- rm $1.ssl
-
- if ! [ `wc -l < tag.new` = 1 ] ||
- ! grep -qE "^portsnap\|[0-9]{10}\|[0-9a-f]{64}" tag.new; then
- echo "invalid snapshot tag."
- return 1
- fi
-
- echo "done."
-
- SNAPSHOTDATE=`cut -f 2 -d '|' < tag.new`
- SNAPSHOTHASH=`cut -f 3 -d '|' < tag.new`
-}
-
-# Sanity-check the date on a snapshot tag
-fetch_snapshot_tagsanity() {
- if [ `date "+%s"` -gt `expr ${SNAPSHOTDATE} + 31536000` ]; then
- echo "Snapshot appears to be more than a year old!"
- echo "(Is the system clock correct?)"
- echo "Cowardly refusing to proceed any further."
- return 1
- fi
- if [ `date "+%s"` -lt `expr ${SNAPSHOTDATE} - 86400` ]; then
- echo -n "Snapshot appears to have been created more than "
- echo "one day into the future!"
- echo "(Is the system clock correct?)"
- echo "Cowardly refusing to proceed any further."
- return 1
- fi
-}
-
-# Sanity-check the date on a snapshot update tag
-fetch_update_tagsanity() {
- fetch_snapshot_tagsanity || return 1
-
- if [ ${OLDSNAPSHOTDATE} -gt ${SNAPSHOTDATE} ]; then
- echo -n "Latest snapshot on server is "
- echo "older than what we already have!"
- echo -n "Cowardly refusing to downgrade from "
- date -r ${OLDSNAPSHOTDATE}
- echo "to `date -r ${SNAPSHOTDATE}`."
- return 1
- fi
-}
-
-# Compare old and new tags; return 1 if update is unnecessary
-fetch_update_neededp() {
- if [ ${OLDSNAPSHOTDATE} -eq ${SNAPSHOTDATE} ]; then
- echo -n "Latest snapshot on server matches "
- echo "what we already have."
- echo "No updates needed."
- rm tag.new
- return 1
- fi
- if [ ${OLDSNAPSHOTHASH} = ${SNAPSHOTHASH} ]; then
- echo -n "Ports tree hasn't changed since "
- echo "last snapshot."
- echo "No updates needed."
- rm tag.new
- return 1
- fi
-
- return 0
-}
-
-# Fetch snapshot metadata file
-fetch_metadata() {
- rm -f ${SNAPSHOTHASH} tINDEX.new
-
- echo ${NDEBUG} "Fetching snapshot metadata... "
- fetch ${QUIETFLAG} http://${SERVERNAME}/t/${SNAPSHOTHASH} \
- 2>${QUIETREDIR} || return
- if [ "`${SHA256} -q ${SNAPSHOTHASH}`" != ${SNAPSHOTHASH} ]; then
- echo "snapshot metadata corrupt."
- return 1
- fi
- mv ${SNAPSHOTHASH} tINDEX.new
- echo "done."
-}
-
-# Warn user about bogus metadata
-fetch_metadata_freakout() {
- echo
- echo "Portsnap metadata is correctly signed, but contains"
- echo "at least one line which appears bogus."
- echo "Cowardly refusing to proceed any further."
-}
-
-# Sanity-check a snapshot metadata file
-fetch_metadata_sanity() {
- if grep -qvE "^[0-9A-Z.]+\|[0-9a-f]{64}$" tINDEX.new; then
- fetch_metadata_freakout
- return 1
- fi
- if [ `look INDEX tINDEX.new | wc -l` != 1 ]; then
- echo
- echo "Portsnap metadata appears bogus."
- echo "Cowardly refusing to proceed any further."
- return 1
- fi
-}
-
-# Take a list of ${oldhash}|${newhash} and output a list of needed patches
-fetch_make_patchlist() {
- local IFS='|'
- echo "" 1>${QUIETREDIR}
- grep -vE "^([0-9a-f]{64})\|\1$" |
- while read X Y; do
- printf "Processing: $X $Y ...\r" 1>${QUIETREDIR}
- if [ -f "files/${Y}.gz" -o ! -f "files/${X}.gz" ]; then continue; fi
- echo "${X}|${Y}"
- done
- echo "" 1>${QUIETREDIR}
-}
-
-# Print user-friendly progress statistics
-fetch_progress() {
- LNC=0
- while read x; do
- LNC=$(($LNC + 1))
- if [ $(($LNC % 10)) = 0 ]; then
- echo -n $LNC
- elif [ $(($LNC % 2)) = 0 ]; then
- echo -n .
- fi
- done
- echo -n " "
-}
-
-pct_fmt()
-{
- if [ $TOTAL -gt 0 ]; then
- printf " \r"
- printf "($1/$2) %02.2f%% " `echo "scale=4;$LNC / $TOTAL * 100"|bc`
- fi
-}
-
-fetch_progress_percent() {
- TOTAL=$1
- LNC=0
- pct_fmt $LNC $TOTAL
- while read x; do
- LNC=$(($LNC + 1))
- if [ $(($LNC % 100)) = 0 ]; then
- pct_fmt $LNC $TOTAL
- elif [ $(($LNC % 10)) = 0 ]; then
- echo -n .
- fi
- done
- pct_fmt $LNC $TOTAL
- echo " done. "
-}
-
-# Sanity-check an index file
-fetch_index_sanity() {
- if grep -qvE "^[-_+./@0-9A-Za-z]+\|[0-9a-f]{64}$" INDEX.new ||
- fgrep -q "./" INDEX.new; then
- fetch_metadata_freakout
- return 1
- fi
-}
-
-# Verify a list of files
-fetch_snapshot_verify() {
- while read F; do
- if [ "`gunzip -c < snap/${F}.gz | ${SHA256} -q`" != ${F} ]; then
- echo "snapshot corrupt."
- return 1
- fi
- done
- return 0
-}
-
-# Fetch a snapshot tarball, extract, and verify.
-fetch_snapshot() {
- while ! fetch_tag snapshot; do
- fetch_pick_server || return 1
- done
- fetch_snapshot_tagsanity || return 1
- fetch_metadata || return 1
- fetch_metadata_sanity || return 1
-
- rm -rf snap/
-
-# Don't ask fetch(1) to be quiet -- downloading a snapshot of ~ 35MB will
-# probably take a while, so the progrees reports that fetch(1) generates
-# will be useful for keeping the users' attention from drifting.
- echo "Fetching snapshot generated at `date -r ${SNAPSHOTDATE}`:"
- fetch -r http://${SERVERNAME}/s/${SNAPSHOTHASH}.tgz || return 1
-
- echo -n "Extracting snapshot... "
- tar -xz --numeric-owner -f ${SNAPSHOTHASH}.tgz snap/ || return 1
- rm ${SNAPSHOTHASH}.tgz
- echo "done."
-
- echo -n "Verifying snapshot integrity... "
-# Verify the metadata files
- cut -f 2 -d '|' tINDEX.new | fetch_snapshot_verify || return 1
-# Extract the index
- rm -f INDEX.new
- gunzip -c < snap/`look INDEX tINDEX.new |
- cut -f 2 -d '|'`.gz > INDEX.new
- fetch_index_sanity || return 1
-# Verify the snapshot contents
- cut -f 2 -d '|' INDEX.new | fetch_snapshot_verify || return 1
- cut -f 2 -d '|' tINDEX.new INDEX.new | sort -u |
- lam -s 'snap/' - -s '.gz' > files.expected
- find snap -mindepth 1 | sort > files.snap
- if ! cmp -s files.expected files.snap; then
- echo "unexpected files in snapshot."
- return 1
- fi
- rm files.expected files.snap
- echo "done."
-
-# Move files into their proper locations
- rm -f tag INDEX tINDEX
- rm -rf files
- mv tag.new tag
- mv tINDEX.new tINDEX
- mv INDEX.new INDEX
- mv snap/ files/
-
- return 0
-}
-
-# Update a compressed snapshot
-fetch_update() {
- rm -f patchlist diff OLD NEW filelist INDEX.new
-
- OLDSNAPSHOTDATE=`cut -f 2 -d '|' < tag`
- OLDSNAPSHOTHASH=`cut -f 3 -d '|' < tag`
-
- while ! fetch_tag latest; do
- fetch_pick_server || return 1
- done
- fetch_update_tagsanity || return 1
- fetch_update_neededp || return 0
- fetch_metadata || return 1
- fetch_metadata_sanity || return 1
-
- echo -n "Updating from `date -r ${OLDSNAPSHOTDATE}` "
- echo "to `date -r ${SNAPSHOTDATE}`."
-
-# Generate a list of wanted metadata patches
- join -t '|' -o 1.2,2.2 tINDEX tINDEX.new |
- fetch_make_patchlist > patchlist
-
-# Attempt to fetch metadata patches
- echo -n "Fetching `wc -l < patchlist | tr -d ' '` "
- echo ${NDEBUG} "metadata patches.${DDSTATS}"
- tr '|' '-' < patchlist |
- lam -s "tp/" - -s ".gz" |
- xargs ${XARGST} ${PHTTPGET} ${SERVERNAME} \
- 2>${STATSREDIR} | fetch_progress
- echo "done."
-
-# Attempt to apply metadata patches
- echo -n "Applying metadata patches... "
- local oldifs="$IFS" IFS='|'
- while read X Y; do
- if [ ! -f "${X}-${Y}.gz" ]; then continue; fi
- gunzip -c < ${X}-${Y}.gz > diff
- gunzip -c < files/${X}.gz > OLD
- cut -c 2- diff | join -t '|' -v 2 - OLD > ptmp
- grep '^\+' diff | cut -c 2- |
- sort -k 1,1 -t '|' -m - ptmp > NEW
- if [ `${SHA256} -q NEW` = ${Y} ]; then
- mv NEW files/${Y}
- gzip -n files/${Y}
- fi
- rm -f diff OLD NEW ${X}-${Y}.gz ptmp
- done < patchlist 2>${QUIETREDIR}
- IFS="$oldifs"
- echo "done."
-
-# Update metadata without patches
- join -t '|' -v 2 tINDEX tINDEX.new |
- cut -f 2 -d '|' /dev/stdin patchlist |
- while read Y; do
- if [ ! -f "files/${Y}.gz" ]; then
- echo ${Y}
- fi
- done > filelist
- echo -n "Fetching `wc -l < filelist | tr -d ' '` "
- echo ${NDEBUG} "metadata files... "
- lam -s "f/" - -s ".gz" < filelist |
- xargs ${XARGST} ${PHTTPGET} ${SERVERNAME} \
- 2>${QUIETREDIR}
-
- while read Y; do
- echo -n "Verifying ${Y}... " 1>${QUIETREDIR}
- if [ `gunzip -c < ${Y}.gz | ${SHA256} -q` = ${Y} ]; then
- mv ${Y}.gz files/${Y}.gz
- else
- echo "metadata is corrupt."
- return 1
- fi
- echo "ok." 1>${QUIETREDIR}
- done < filelist
- echo "done."
-
-# Extract the index
- echo -n "Extracting index... " 1>${QUIETREDIR}
- gunzip -c < files/`look INDEX tINDEX.new |
- cut -f 2 -d '|'`.gz > INDEX.new
- fetch_index_sanity || return 1
-
-# If we have decided to refuse certain updates, construct a hybrid index which
-# is equal to the old index for parts of the tree which we don't want to
-# update, and equal to the new index for parts of the tree which gets updates.
-# This means that we should always have a "complete snapshot" of the ports
-# tree -- with the caveat that it isn't actually a snapshot.
- if [ ! -z "${REFUSE}" ]; then
- echo "Refusing to download updates for ${REFUSE}" \
- >${QUIETREDIR}
-
- grep -Ev "${REFUSE}" INDEX.new > INDEX.tmp
- grep -E "${REFUSE}" INDEX |
- sort -m -k 1,1 -t '|' - INDEX.tmp > INDEX.new
- rm -f INDEX.tmp
- fi
-
-# Generate a list of wanted ports patches
- echo -n "Generating list of wanted patches..." 1>${QUIETREDIR}
- join -t '|' -o 1.2,2.2 INDEX INDEX.new |
- fetch_make_patchlist > patchlist
- echo " done." 1>${QUIETREDIR}
-
-# Attempt to fetch ports patches
- patchcnt=`wc -l < patchlist | tr -d ' '`
- echo -n "Fetching $patchcnt "
- echo ${NDEBUG} "patches.${DDSTATS}"
- echo " "
- tr '|' '-' < patchlist | lam -s "bp/" - |
- xargs ${XARGST} ${PHTTPGET} ${SERVERNAME} \
- 2>${STATSREDIR} | fetch_progress_percent $patchcnt
- echo "done."
-
-# Attempt to apply ports patches
- PATCHCNT=`wc -l patchlist`
- echo "Applying patches... "
- local oldifs="$IFS" IFS='|'
- I=0
- while read X Y; do
- I=$(($I + 1))
- F="${X}-${Y}"
- if [ ! -f "${F}" ]; then
- XS=${X%[0-9a-f][0-9a-f][0-9a-f][0-9a-f]}
- XE=${X#[0-9a-f][0-9a-f][0-9a-f][0-9a-f]}
- YS=${Y%[0-9a-f][0-9a-f][0-9a-f][0-9a-f]}
- YE=${Y#[0-9a-f][0-9a-f][0-9a-f][0-9a-f]}
- F="${X%${XE}}...${X#${XS}}-${Y%${YE}}...${Y#${YS}}"
- printf " Skipping ${F} (${I} of ${PATCHCNT}).\r"
- continue
- fi
- echo " Processing ${F}..." 1>${QUIETREDIR}
- gunzip -c < files/${X}.gz > OLD
- ${BSPATCH} OLD NEW ${X}-${Y}
- if [ `${SHA256} -q NEW` = ${Y} ]; then
- mv NEW files/${Y}
- gzip -n files/${Y}
- fi
- rm -f diff OLD NEW ${X}-${Y}
- done < patchlist 2>${QUIETREDIR}
- IFS="$oldifs"
- echo "done."
-
-# Update ports without patches
- join -t '|' -v 2 INDEX INDEX.new |
- cut -f 2 -d '|' /dev/stdin patchlist |
- while read Y; do
- if [ ! -f "files/${Y}.gz" ]; then
- echo ${Y}
- fi
- done > filelist
- echo -n "Fetching `wc -l < filelist | tr -d ' '` "
- echo ${NDEBUG} "new ports or files... "
- lam -s "f/" - -s ".gz" < filelist |
- xargs ${XARGST} ${PHTTPGET} ${SERVERNAME} \
- 2>${QUIETREDIR}
-
- I=0
- while read Y; do
- I=$(($I + 1))
- printf " Processing ${Y} (${I} of ${PATCHCNT}).\r" 1>${QUIETREDIR}
- if [ `gunzip -c < ${Y}.gz | ${SHA256} -q` = ${Y} ]; then
- mv ${Y}.gz files/${Y}.gz
- else
- echo "snapshot is corrupt."
- return 1
- fi
- done < filelist
- echo "done."
-
-# Remove files which are no longer needed
- cut -f 2 -d '|' tINDEX INDEX | sort -u > oldfiles
- cut -f 2 -d '|' tINDEX.new INDEX.new | sort -u | comm -13 - oldfiles |
- lam -s "files/" - -s ".gz" | xargs rm -f
- rm patchlist filelist oldfiles
-
-# We're done!
- mv INDEX.new INDEX
- mv tINDEX.new tINDEX
- mv tag.new tag
-
- return 0
-}
-
-# Do the actual work involved in "fetch" / "cron".
-fetch_run() {
- fetch_pick_server_init && fetch_pick_server
-
- while ! fetch_key; do
- fetch_pick_server || return 1
- done
-
- if ! [ -d files -a -r tag -a -r INDEX -a -r tINDEX ]; then
- fetch_snapshot || return 1
- fi
- fetch_update || return 1
-}
-
-# Build a ports INDEX file
-extract_make_index() {
- if ! look $1 ${WORKDIR}/tINDEX > /dev/null; then
- echo -n "$1 not provided by portsnap server; "
- echo "$2 not being generated."
- else
- gunzip -c < "${WORKDIR}/files/`look $1 ${WORKDIR}/tINDEX |
- cut -f 2 -d '|'`.gz" |
- cat - ${LOCALDESC} |
- ${MKINDEX} /dev/stdin > ${PORTSDIR}/$2
- fi
-}
-
-# Create INDEX, INDEX-5, INDEX-6
-extract_indices() {
- echo -n "Building new INDEX files... "
- for PAIR in ${INDEXPAIRS}; do
- INDEXFILE=`echo ${PAIR} | cut -f 1 -d '|'`
- DESCRIBEFILE=`echo ${PAIR} | cut -f 2 -d '|'`
- extract_make_index ${DESCRIBEFILE} ${INDEXFILE} || return 1
- done
- echo "done."
-}
-
-# Create .portsnap.INDEX; if we are REFUSEing to touch certain directories,
-# merge the values from any exiting .portsnap.INDEX file.
-extract_metadata() {
- if [ -z "${REFUSE}" ]; then
- sort ${WORKDIR}/INDEX > ${PORTSDIR}/.portsnap.INDEX
- elif [ -f ${PORTSDIR}/.portsnap.INDEX ]; then
- grep -E "${REFUSE}" ${PORTSDIR}/.portsnap.INDEX \
- > ${PORTSDIR}/.portsnap.INDEX.tmp
- grep -vE "${REFUSE}" ${WORKDIR}/INDEX | sort |
- sort -m - ${PORTSDIR}/.portsnap.INDEX.tmp \
- > ${PORTSDIR}/.portsnap.INDEX
- rm -f ${PORTSDIR}/.portsnap.INDEX.tmp
- else
- grep -vE "${REFUSE}" ${WORKDIR}/INDEX | sort \
- > ${PORTSDIR}/.portsnap.INDEX
- fi
-}
-
-# Do the actual work involved in "extract"
-extract_run() {
- local oldifs="$IFS" IFS='|'
- mkdir -p ${PORTSDIR} || return 1
-
- if !
- if ! [ -z "${EXTRACTPATH}" ]; then
- grep "^${EXTRACTPATH}" ${WORKDIR}/INDEX
- elif ! [ -z "${REFUSE}" ]; then
- grep -vE "${REFUSE}" ${WORKDIR}/INDEX
- else
- cat ${WORKDIR}/INDEX
- fi | while read FILE HASH; do
- echo ${PORTSDIR}/${FILE}
- if ! [ -s "${WORKDIR}/files/${HASH}.gz" ]; then
- echo "files/${HASH}.gz not found -- snapshot corrupt."
- return 1
- fi
- case ${FILE} in
- */)
- rm -rf ${PORTSDIR}/${FILE%/}
- mkdir -p ${PORTSDIR}/${FILE}
- tar -xz --numeric-owner -f ${WORKDIR}/files/${HASH}.gz \
- -C ${PORTSDIR}/${FILE}
- ;;
- *)
- rm -f ${PORTSDIR}/${FILE}
- tar -xz --numeric-owner -f ${WORKDIR}/files/${HASH}.gz \
- -C ${PORTSDIR} ${FILE}
- ;;
- esac
- done; then
- return 1
- fi
- if [ ! -z "${EXTRACTPATH}" ]; then
- return 0
- fi
-
- IFS="$oldifs"
-
- extract_metadata
- extract_indices
-}
-
-update_run_extract() {
- local IFS='|'
-
-# Install new files
- echo "Extracting new files:"
- if !
- if ! [ -z "${REFUSE}" ]; then
- grep -vE "${REFUSE}" ${WORKDIR}/INDEX | sort
- else
- sort ${WORKDIR}/INDEX
- fi |
- comm -13 ${PORTSDIR}/.portsnap.INDEX - |
- while read FILE HASH; do
- echo ${PORTSDIR}/${FILE}
- if ! [ -s "${WORKDIR}/files/${HASH}.gz" ]; then
- echo "files/${HASH}.gz not found -- snapshot corrupt."
- return 1
- fi
- case ${FILE} in
- */)
- mkdir -p ${PORTSDIR}/${FILE}
- tar -xz --numeric-owner -f ${WORKDIR}/files/${HASH}.gz \
- -C ${PORTSDIR}/${FILE}
- ;;
- *)
- tar -xz --numeric-owner -f ${WORKDIR}/files/${HASH}.gz \
- -C ${PORTSDIR} ${FILE}
- ;;
- esac
- done; then
- return 1
- fi
-}
-
-# Do the actual work involved in "update"
-update_run() {
- if ! [ -z "${INDEXONLY}" ]; then
- extract_indices >/dev/null || return 1
- return 0
- fi
-
- if sort ${WORKDIR}/INDEX |
- cmp -s ${PORTSDIR}/.portsnap.INDEX -; then
- echo "Ports tree is already up to date."
- return 0
- fi
-
-# If we are REFUSEing to touch certain directories, don't remove files
-# from those directories (even if they are out of date)
- echo -n "Removing old files and directories... "
- if ! [ -z "${REFUSE}" ]; then
- sort ${WORKDIR}/INDEX |
- comm -23 ${PORTSDIR}/.portsnap.INDEX - | cut -f 1 -d '|' |
- grep -vE "${REFUSE}" |
- lam -s "${PORTSDIR}/" - |
- sed -e 's|/$||' | xargs rm -rf
- else
- sort ${WORKDIR}/INDEX |
- comm -23 ${PORTSDIR}/.portsnap.INDEX - | cut -f 1 -d '|' |
- lam -s "${PORTSDIR}/" - |
- sed -e 's|/$||' | xargs rm -rf
- fi
- echo "done."
-
- update_run_extract || return 1
- extract_metadata
- extract_indices
-}
-
-#### Main functions -- call parameter-handling and core functions
-
-# Using the command line, configuration file, and defaults,
-# set all the parameters which are needed later.
-get_params() {
- init_params
- parse_cmdline $@
- sanity_conffile
- default_conffile
- parse_conffile
- default_params
-}
-
-# Fetch command. Make sure that we're being called
-# interactively, then run fetch_check_params and fetch_run
-cmd_fetch() {
- if [ "${INTERACTIVE}" != "YES" ]; then
- echo -n "`basename $0` fetch should not "
- echo "be run non-interactively."
- echo "Run `basename $0` cron instead"
- exit 1
- fi
- fetch_check_params
- fetch_run || exit 1
-}
-
-# Cron command. Make sure the parameters are sensible; wait
-# rand(3600) seconds; then fetch updates. While fetching updates,
-# send output to a temporary file; only print that file if the
-# fetching failed.
-cmd_cron() {
- fetch_check_params
- sleep `jot -r 1 0 3600`
-
- TMPFILE=`mktemp /tmp/portsnap.XXXXXX` || exit 1
- if ! fetch_run >> ${TMPFILE}; then
- cat ${TMPFILE}
- rm ${TMPFILE}
- exit 1
- fi
-
- rm ${TMPFILE}
-}
-
-# Extract command. Make sure the parameters are sensible,
-# then extract the ports tree (or part thereof).
-cmd_extract() {
- extract_check_params
- extract_run || exit 1
-}
-
-# Update command. Make sure the parameters are sensible,
-# then update the ports tree.
-cmd_update() {
- update_check_params
- update_run || exit 1
-}
-
-# Auto command. Run 'fetch' or 'cron' depending on
-# whether stdin is a terminal; then run 'update' or
-# 'extract' depending on whether ${PORTSDIR} exists.
-cmd_auto() {
- if [ "${INTERACTIVE}" = "YES" ]; then
- cmd_fetch
- else
- cmd_cron
- fi
- if [ -r ${PORTSDIR}/.portsnap.INDEX ]; then
- cmd_update
- else
- cmd_extract
- fi
-}
-
-#### Entry point
-
-# Make sure we find utilities from the base system
-export PATH=/sbin:/bin:/usr/sbin:/usr/bin:${PATH}
-
-# Set LC_ALL in order to avoid problems with character ranges like [A-Z].
-export LC_ALL=C
-
-get_params $@
-for COMMAND in ${COMMANDS}; do
- cmd_${COMMAND}
-done
diff --git a/usr.sbin/powerd/Makefile b/usr.sbin/powerd/Makefile
index 4434dcf69318..323a85e821ad 100644
--- a/usr.sbin/powerd/Makefile
+++ b/usr.sbin/powerd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= powerd
MAN= powerd.8
diff --git a/usr.sbin/powerd/Makefile.depend b/usr.sbin/powerd/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/powerd/Makefile.depend
+++ b/usr.sbin/powerd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/powerd/powerd.8 b/usr.sbin/powerd/powerd.8
index 9c5133f536d7..43442a38b97f 100644
--- a/usr.sbin/powerd/powerd.8
+++ b/usr.sbin/powerd/powerd.8
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd November 6, 2021
+.Dd February 25, 2023
.Dt POWERD 8
.Os
.Sh NAME
@@ -170,7 +168,7 @@ utility should also power down idle disks and other components besides the CPU.
If
.Nm
is used with
-.Pa power_profile ,
+.Pa /etc/rc.d/power_profile ,
they may override each other.
.Pp
The
diff --git a/usr.sbin/powerd/powerd.c b/usr.sbin/powerd/powerd.c
index 2acb14503685..8517b4f2bf0b 100644
--- a/usr.sbin/powerd/powerd.c
+++ b/usr.sbin/powerd/powerd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2004 Colin Percival
* Copyright (c) 2005 Nate Lawson
@@ -27,9 +27,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/sysctl.h>
diff --git a/usr.sbin/ppp/Makefile b/usr.sbin/ppp/Makefile
index a7a35d49295e..d729d8adc748 100644
--- a/usr.sbin/ppp/Makefile
+++ b/usr.sbin/ppp/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
@@ -66,6 +65,7 @@ SRCS+= id.c
CFLAGS+=-DNODES
.else
SRCS+= chap_ms.c mppe.c
+CFLAGS+= -DOPENSSL_API_COMPAT=0x10100000L
LIBADD+= crypto
.endif
diff --git a/usr.sbin/ppp/Makefile.depend b/usr.sbin/ppp/Makefile.depend
index 92ea9e3b6910..7dbe27fe4499 100644
--- a/usr.sbin/ppp/Makefile.depend
+++ b/usr.sbin/ppp/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/ppp/README.changes b/usr.sbin/ppp/README.changes
index 4ed3da6cd0d5..66928b90f13f 100644
--- a/usr.sbin/ppp/README.changes
+++ b/usr.sbin/ppp/README.changes
@@ -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$
-
This file summarises changes made to ppp that effect
its configuration.
diff --git a/usr.sbin/ppp/README.nat b/usr.sbin/ppp/README.nat
index 9ff240a9f37c..7616fd6dc045 100644
--- a/usr.sbin/ppp/README.nat
+++ b/usr.sbin/ppp/README.nat
@@ -22,8 +22,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$
-
User PPP NAT (Packet Aliasing)
diff --git a/usr.sbin/ppp/acf.c b/usr.sbin/ppp/acf.c
index dd5d5c0c91a4..5ff27358eff4 100644
--- a/usr.sbin/ppp/acf.c
+++ b/usr.sbin/ppp/acf.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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 <sys/types.h>
diff --git a/usr.sbin/ppp/acf.h b/usr.sbin/ppp/acf.h
index 0ef231e34bf7..a14eb39dad7b 100644
--- a/usr.sbin/ppp/acf.h
+++ b/usr.sbin/ppp/acf.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct lcp;
diff --git a/usr.sbin/ppp/arp.c b/usr.sbin/ppp/arp.c
index f88fc1d1d97e..ad623525ad4c 100644
--- a/usr.sbin/ppp/arp.c
+++ b/usr.sbin/ppp/arp.c
@@ -19,8 +19,6 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $FreeBSD$
- *
*/
/*
@@ -223,7 +221,7 @@ arp_ClearProxy(struct bundle *bundle, struct in_addr addr, int s)
/*
* arp_EtherAddr - get the hardware address of an interface on the
- * the same subnet as ipaddr.
+ * same subnet as ipaddr.
*/
int
diff --git a/usr.sbin/ppp/arp.h b/usr.sbin/ppp/arp.h
index c835e2049ec7..32f209aadc57 100644
--- a/usr.sbin/ppp/arp.h
+++ b/usr.sbin/ppp/arp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
struct sockaddr_dl;
diff --git a/usr.sbin/ppp/async.c b/usr.sbin/ppp/async.c
index 1ed8d953b87f..d6cb89df23b8 100644
--- a/usr.sbin/ppp/async.c
+++ b/usr.sbin/ppp/async.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -29,9 +29,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <string.h>
diff --git a/usr.sbin/ppp/async.h b/usr.sbin/ppp/async.h
index 5413e80d62a1..9be23b819b7c 100644
--- a/usr.sbin/ppp/async.h
+++ b/usr.sbin/ppp/async.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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$
*/
#define HDLCSIZE (MAX_MRU*2+6)
diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c
index 1fa4b7f194a6..b027f74be2d8 100644
--- a/usr.sbin/ppp/auth.c
+++ b/usr.sbin/ppp/auth.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/auth.h b/usr.sbin/ppp/auth.h
index 12638c79d010..6371ce396af5 100644
--- a/usr.sbin/ppp/auth.h
+++ b/usr.sbin/ppp/auth.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
struct physical;
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c
index 1af2924b8d56..28da36d0f987 100644
--- a/usr.sbin/ppp/bundle.c
+++ b/usr.sbin/ppp/bundle.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
@@ -1354,7 +1352,7 @@ bundle_GetLabel(struct bundle *bundle)
}
int
-bundle_LinkSize()
+bundle_LinkSize(void)
{
struct iovec iov[SCATTER_SEGMENTS];
int niov, expect, f;
diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h
index 6658c5616fa4..aa909bdb4686 100644
--- a/usr.sbin/ppp/bundle.h
+++ b/usr.sbin/ppp/bundle.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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$
*/
#define PHASE_DEAD 0 /* Link is dead */
diff --git a/usr.sbin/ppp/cbcp.c b/usr.sbin/ppp/cbcp.c
index 76d2e1d9bbf9..bc92ca40efd5 100644
--- a/usr.sbin/ppp/cbcp.c
+++ b/usr.sbin/ppp/cbcp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/cbcp.h b/usr.sbin/ppp/cbcp.h
index 30c417b7ddfb..7fb827579b12 100644
--- a/usr.sbin/ppp/cbcp.h
+++ b/usr.sbin/ppp/cbcp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct mbuf;
diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c
index be9a2479e675..8c8d111721f6 100644
--- a/usr.sbin/ppp/ccp.c
+++ b/usr.sbin/ppp/ccp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/ccp.h b/usr.sbin/ppp/ccp.h
index ca072de7a842..2e329657ab7c 100644
--- a/usr.sbin/ppp/ccp.h
+++ b/usr.sbin/ppp/ccp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
#define CCP_MAXCODE CODE_RESETACK
diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c
index 61ba177b79e3..9cefa6db71ce 100644
--- a/usr.sbin/ppp/chap.c
+++ b/usr.sbin/ppp/chap.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/chap.h b/usr.sbin/ppp/chap.h
index c7d145bd4c2f..f697167ab165 100644
--- a/usr.sbin/ppp/chap.h
+++ b/usr.sbin/ppp/chap.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
struct mbuf;
diff --git a/usr.sbin/ppp/chap_ms.c b/usr.sbin/ppp/chap_ms.c
index 37d143d12dc2..67c373af34d6 100644
--- a/usr.sbin/ppp/chap_ms.c
+++ b/usr.sbin/ppp/chap_ms.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Gabor Kincses <gabor@acm.org>
* 1997 - 2001 Brian Somers <brian@Awfulhak.org>
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <ctype.h>
diff --git a/usr.sbin/ppp/chap_ms.h b/usr.sbin/ppp/chap_ms.h
index 014a2849f137..eae38f81974e 100644
--- a/usr.sbin/ppp/chap_ms.h
+++ b/usr.sbin/ppp/chap_ms.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Gabor Kincses <gabor@acm.org>
* 1997 - 2001 Brian Somers <brian@Awfulhak.org>
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
/* Max # of (Unicode) chars in an NT password */
diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c
index b7eebb387a94..1e1d8e21f293 100644
--- a/usr.sbin/ppp/chat.c
+++ b/usr.sbin/ppp/chat.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/chat.h b/usr.sbin/ppp/chat.h
index 984f9bf04192..54e86834be60 100644
--- a/usr.sbin/ppp/chat.h
+++ b/usr.sbin/ppp/chat.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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$
*/
#define CHAT_EXPECT 0
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index e126c31529d4..e94c18ae3fd2 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/command.h b/usr.sbin/ppp/command.h
index 7a61fd655517..9f7add2e1e79 100644
--- a/usr.sbin/ppp/command.h
+++ b/usr.sbin/ppp/command.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
struct cmdtab;
diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c
index ff81a0dc0288..6346f9e2960b 100644
--- a/usr.sbin/ppp/datalink.c
+++ b/usr.sbin/ppp/datalink.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/datalink.h b/usr.sbin/ppp/datalink.h
index 69116036b933..7a1c0691e930 100644
--- a/usr.sbin/ppp/datalink.h
+++ b/usr.sbin/ppp/datalink.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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$
*/
#define DATALINK_CLOSED (0)
diff --git a/usr.sbin/ppp/deflate.c b/usr.sbin/ppp/deflate.c
index a2095dbe397d..b4359287d377 100644
--- a/usr.sbin/ppp/deflate.c
+++ b/usr.sbin/ppp/deflate.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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 <sys/types.h>
diff --git a/usr.sbin/ppp/deflate.h b/usr.sbin/ppp/deflate.h
index 474c2228d5be..a875fd4af237 100644
--- a/usr.sbin/ppp/deflate.h
+++ b/usr.sbin/ppp/deflate.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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$
*/
extern const struct ccp_algorithm PppdDeflateAlgorithm;
diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c
index 7f89ef8b9f9e..3e2fcbfc0da1 100644
--- a/usr.sbin/ppp/defs.c
+++ b/usr.sbin/ppp/defs.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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$
*/
@@ -384,7 +382,7 @@ SetTitle(const char *title)
}
fd_set *
-mkfdset()
+mkfdset(void)
{
return (fd_set *)malloc(howmany(getdtablesize(), NFDBITS) * sizeof (fd_mask));
}
diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h
index 9efdaca3563c..c76cbd8ad9cb 100644
--- a/usr.sbin/ppp/defs.h
+++ b/usr.sbin/ppp/defs.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
/* Check the following definitions for your machine environment */
diff --git a/usr.sbin/ppp/descriptor.h b/usr.sbin/ppp/descriptor.h
index 506c12af2722..d34c7a5cab4e 100644
--- a/usr.sbin/ppp/descriptor.h
+++ b/usr.sbin/ppp/descriptor.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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$
*/
#define PHYSICAL_DESCRIPTOR (1)
diff --git a/usr.sbin/ppp/ether.c b/usr.sbin/ppp/ether.c
index 2256a83636a5..b33da1f0048a 100644
--- a/usr.sbin/ppp/ether.c
+++ b/usr.sbin/ppp/ether.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/ether.h b/usr.sbin/ppp/ether.h
index c0c8c30a1d47..c100a950cc50 100644
--- a/usr.sbin/ppp/ether.h
+++ b/usr.sbin/ppp/ether.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct physical;
diff --git a/usr.sbin/ppp/exec.c b/usr.sbin/ppp/exec.c
index 2520532aec5b..45f68e81fc50 100644
--- a/usr.sbin/ppp/exec.c
+++ b/usr.sbin/ppp/exec.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/exec.h b/usr.sbin/ppp/exec.h
index 0bc5b41a302e..3b6c32eae09a 100644
--- a/usr.sbin/ppp/exec.h
+++ b/usr.sbin/ppp/exec.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct physical;
diff --git a/usr.sbin/ppp/filter.c b/usr.sbin/ppp/filter.c
index 8dc894ab3618..66c72324a5ce 100644
--- a/usr.sbin/ppp/filter.c
+++ b/usr.sbin/ppp/filter.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/filter.h b/usr.sbin/ppp/filter.h
index 74af3f994952..aad8deaa6f69 100644
--- a/usr.sbin/ppp/filter.h
+++ b/usr.sbin/ppp/filter.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
/* Operations - f_srcop, f_dstop */
diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c
index 1d35bafa8bd4..5c011bef7f4f 100644
--- a/usr.sbin/ppp/fsm.c
+++ b/usr.sbin/ppp/fsm.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/fsm.h b/usr.sbin/ppp/fsm.h
index 361f483e34c2..250518320f5e 100644
--- a/usr.sbin/ppp/fsm.h
+++ b/usr.sbin/ppp/fsm.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
/*
diff --git a/usr.sbin/ppp/hdlc.c b/usr.sbin/ppp/hdlc.c
index 57d1486d0312..2c6a03d7e0ba 100644
--- a/usr.sbin/ppp/hdlc.c
+++ b/usr.sbin/ppp/hdlc.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/hdlc.h b/usr.sbin/ppp/hdlc.h
index 9f51d090d68e..2e29ed021bab 100644
--- a/usr.sbin/ppp/hdlc.h
+++ b/usr.sbin/ppp/hdlc.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
/*
diff --git a/usr.sbin/ppp/i4b.h b/usr.sbin/ppp/i4b.h
index a19658319382..70d97149f790 100644
--- a/usr.sbin/ppp/i4b.h
+++ b/usr.sbin/ppp/i4b.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct physical;
diff --git a/usr.sbin/ppp/id.c b/usr.sbin/ppp/id.c
index 48ea7ce4a7f0..c7d512380afa 100644
--- a/usr.sbin/ppp/id.c
+++ b/usr.sbin/ppp/id.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
@@ -61,7 +59,7 @@ static int uid;
static int euid;
void
-ID0init()
+ID0init(void)
{
uid = getuid();
euid = geteuid();
@@ -77,7 +75,7 @@ ID0setuser(void)
}
uid_t
-ID0realuid()
+ID0realuid(void)
{
return uid;
}
diff --git a/usr.sbin/ppp/id.h b/usr.sbin/ppp/id.h
index 83b34a80c88c..5c724177ad57 100644
--- a/usr.sbin/ppp/id.h
+++ b/usr.sbin/ppp/id.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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 NOSUID
diff --git a/usr.sbin/ppp/iface.c b/usr.sbin/ppp/iface.c
index 858fb1502d27..ad9f81b062f7 100644
--- a/usr.sbin/ppp/iface.c
+++ b/usr.sbin/ppp/iface.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/iface.h b/usr.sbin/ppp/iface.h
index 04bb2c5a8f8a..4f84481f0fbb 100644
--- a/usr.sbin/ppp/iface.h
+++ b/usr.sbin/ppp/iface.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct ifa_msghdr;
diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c
index 8e5f7bcb4dda..386b167db0cf 100644
--- a/usr.sbin/ppp/ip.c
+++ b/usr.sbin/ppp/ip.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/ip.h b/usr.sbin/ppp/ip.h
index db9e7b279521..c160de755224 100644
--- a/usr.sbin/ppp/ip.h
+++ b/usr.sbin/ppp/ip.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
struct mbuf;
diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c
index e4426952c4dc..23f68ad0f7c6 100644
--- a/usr.sbin/ppp/ipcp.c
+++ b/usr.sbin/ppp/ipcp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/ipcp.h b/usr.sbin/ppp/ipcp.h
index a6864d815781..0ad52909f835 100644
--- a/usr.sbin/ppp/ipcp.h
+++ b/usr.sbin/ppp/ipcp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
#define IPCP_MAXCODE CODE_CODEREJ
diff --git a/usr.sbin/ppp/iplist.c b/usr.sbin/ppp/iplist.c
index c96353054b2a..51324752448a 100644
--- a/usr.sbin/ppp/iplist.c
+++ b/usr.sbin/ppp/iplist.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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 <sys/types.h>
diff --git a/usr.sbin/ppp/iplist.h b/usr.sbin/ppp/iplist.h
index e4bcea43ce4d..147583f3c77d 100644
--- a/usr.sbin/ppp/iplist.h
+++ b/usr.sbin/ppp/iplist.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct iplist_cur {
diff --git a/usr.sbin/ppp/ipv6cp.c b/usr.sbin/ppp/ipv6cp.c
index 7f4c0c9277aa..bebbe029b304 100644
--- a/usr.sbin/ppp/ipv6cp.c
+++ b/usr.sbin/ppp/ipv6cp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/ipv6cp.h b/usr.sbin/ppp/ipv6cp.h
index 390b2afc7bba..e645ad27f411 100644
--- a/usr.sbin/ppp/ipv6cp.h
+++ b/usr.sbin/ppp/ipv6cp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
* 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 NOINET6
diff --git a/usr.sbin/ppp/layer.h b/usr.sbin/ppp/layer.h
index 8d7382c35cc3..3aa9cb64c1be 100644
--- a/usr.sbin/ppp/layer.h
+++ b/usr.sbin/ppp/layer.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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$
*/
#define LAYER_ASYNC 2
diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c
index d447c9ef8737..462f3c4281bb 100644
--- a/usr.sbin/ppp/lcp.c
+++ b/usr.sbin/ppp/lcp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/lcp.h b/usr.sbin/ppp/lcp.h
index 05c66de2ee5f..81ac068600a0 100644
--- a/usr.sbin/ppp/lcp.h
+++ b/usr.sbin/ppp/lcp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
/* callback::opmask values */
diff --git a/usr.sbin/ppp/link.c b/usr.sbin/ppp/link.c
index 0cc32f040802..3dd5fa91aec8 100644
--- a/usr.sbin/ppp/link.c
+++ b/usr.sbin/ppp/link.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* All rights reserved.
@@ -25,8 +25,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#include <sys/types.h>
diff --git a/usr.sbin/ppp/link.h b/usr.sbin/ppp/link.h
index 72e4dd405ead..d2fd65e31798 100644
--- a/usr.sbin/ppp/link.h
+++ b/usr.sbin/ppp/link.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* All rights reserved.
@@ -25,8 +25,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
diff --git a/usr.sbin/ppp/log.c b/usr.sbin/ppp/log.c
index 72f1ca9a9a91..aec05772e850 100644
--- a/usr.sbin/ppp/log.c
+++ b/usr.sbin/ppp/log.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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 <sys/types.h>
@@ -83,7 +81,7 @@ struct prompt *log_PromptContext;
int log_PromptListChanged;
struct prompt *
-log_PromptList()
+log_PromptList(void)
{
return promptlist;
}
@@ -163,7 +161,7 @@ log_DestroyPrompts(struct server *s)
}
void
-log_DisplayPrompts()
+log_DisplayPrompts(void)
{
struct prompt *p;
@@ -254,7 +252,7 @@ log_DiscardLocal(int id, u_long *mask)
}
void
-log_DiscardAll()
+log_DiscardAll(void)
{
LogMask = 0;
}
@@ -306,7 +304,7 @@ log_SetTun(int tunno, const char *ifaceName)
}
void
-log_Close()
+log_Close(void)
{
closelog();
LogTunno = -1;
diff --git a/usr.sbin/ppp/log.h b/usr.sbin/ppp/log.h
index f5bbacefba94..9333b41e8ee5 100644
--- a/usr.sbin/ppp/log.h
+++ b/usr.sbin/ppp/log.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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$
*/
#define LogLOG (0)
diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c
index 787faeab880f..c7156e4bca21 100644
--- a/usr.sbin/ppp/lqr.c
+++ b/usr.sbin/ppp/lqr.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/lqr.h b/usr.sbin/ppp/lqr.h
index 522f0abf35f7..7f780841455f 100644
--- a/usr.sbin/ppp/lqr.h
+++ b/usr.sbin/ppp/lqr.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
/*
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index 3545d4753fcb..76a145b2e551 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
@@ -112,7 +110,7 @@ static struct prompt *SignalPrompt;
struct libalias *la;
void
-Cleanup()
+Cleanup(void)
{
SignalBundle->CleaningUp = 1;
bundle_Close(SignalBundle, NULL, CLOSE_STAYDOWN);
diff --git a/usr.sbin/ppp/main.h b/usr.sbin/ppp/main.h
index e94c1f3c3f26..8d4919ee9b0e 100644
--- a/usr.sbin/ppp/main.h
+++ b/usr.sbin/ppp/main.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
extern void Cleanup(void);
diff --git a/usr.sbin/ppp/mbuf.c b/usr.sbin/ppp/mbuf.c
index 5d0d27d123e3..12a6647fe0fc 100644
--- a/usr.sbin/ppp/mbuf.c
+++ b/usr.sbin/ppp/mbuf.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/types.h>
diff --git a/usr.sbin/ppp/mbuf.h b/usr.sbin/ppp/mbuf.h
index 81d1116132ef..9e0624f750ca 100644
--- a/usr.sbin/ppp/mbuf.h
+++ b/usr.sbin/ppp/mbuf.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
struct mbuf {
diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c
index 91fdaf09a936..84ddb6e053e3 100644
--- a/usr.sbin/ppp/mp.c
+++ b/usr.sbin/ppp/mp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/mp.h b/usr.sbin/ppp/mp.h
index 7020275c3c0d..0625b8cdae77 100644
--- a/usr.sbin/ppp/mp.h
+++ b/usr.sbin/ppp/mp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct mbuf;
diff --git a/usr.sbin/ppp/mppe.c b/usr.sbin/ppp/mppe.c
index 2589141625ab..152963f73056 100644
--- a/usr.sbin/ppp/mppe.c
+++ b/usr.sbin/ppp/mppe.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2000 Semen Ustimenko <semenu@FreeBSD.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/mppe.h b/usr.sbin/ppp/mppe.h
index c9566e333d3d..bbd7778c3a2b 100644
--- a/usr.sbin/ppp/mppe.h
+++ b/usr.sbin/ppp/mppe.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2000 Semen Ustimenko <semenu@FreeBSD.org>
* 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$
*/
#define MPPE_KEY_LEN 16
diff --git a/usr.sbin/ppp/nat_cmd.c b/usr.sbin/ppp/nat_cmd.c
index a413fbb878fa..f6be935099e6 100644
--- a/usr.sbin/ppp/nat_cmd.c
+++ b/usr.sbin/ppp/nat_cmd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Charles Mott <cm@linktel.net>
* Brian Somers <brian@Awfulhak.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$
*/
#include <sys/param.h>
diff --git a/usr.sbin/ppp/nat_cmd.h b/usr.sbin/ppp/nat_cmd.h
index 40f4bc7ea71d..61059a338c83 100644
--- a/usr.sbin/ppp/nat_cmd.h
+++ b/usr.sbin/ppp/nat_cmd.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Charles Mott <cm@linktel.net>
* Brian Somers <brian@Awfulhak.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$
*/
struct cmdargs;
diff --git a/usr.sbin/ppp/ncp.c b/usr.sbin/ppp/ncp.c
index d9aaf2bc71bf..701f47e9ff4a 100644
--- a/usr.sbin/ppp/ncp.c
+++ b/usr.sbin/ppp/ncp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/ncp.h b/usr.sbin/ppp/ncp.h
index 70b00a422310..95cc2f899bbf 100644
--- a/usr.sbin/ppp/ncp.h
+++ b/usr.sbin/ppp/ncp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct port_range {
@@ -96,8 +94,8 @@ extern void ncp2initial(struct ncp *);
ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.tcp)
#define ncp_ClearUrgentUdpPorts(ncp) \
ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.udp)
-#define ncp_ClearUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 0;
-#define ncp_SetUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 1;
+#define ncp_ClearUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 0
+#define ncp_SetUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 1
#ifndef NOINET6
#define isncp(proto) ((proto) == PROTO_IPCP || (proto) == PROTO_IPV6CP)
diff --git a/usr.sbin/ppp/ncpaddr.c b/usr.sbin/ppp/ncpaddr.c
index 4e086eb5e377..4cf36e2a23e6 100644
--- a/usr.sbin/ppp/ncpaddr.c
+++ b/usr.sbin/ppp/ncpaddr.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
* 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 <sys/types.h>
diff --git a/usr.sbin/ppp/ncpaddr.h b/usr.sbin/ppp/ncpaddr.h
index 72b9596c73fd..2c3dc527a6db 100644
--- a/usr.sbin/ppp/ncpaddr.h
+++ b/usr.sbin/ppp/ncpaddr.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
* 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$
*/
/*
diff --git a/usr.sbin/ppp/netgraph.c b/usr.sbin/ppp/netgraph.c
index 1a96ccc856e1..bc98dd2472a9 100644
--- a/usr.sbin/ppp/netgraph.c
+++ b/usr.sbin/ppp/netgraph.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2000 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/netgraph.h b/usr.sbin/ppp/netgraph.h
index 007c16d6c7a0..124d301e4bc5 100644
--- a/usr.sbin/ppp/netgraph.h
+++ b/usr.sbin/ppp/netgraph.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2000 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct physical;
diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c
index 01b2cb34db12..c0ad77e26108 100644
--- a/usr.sbin/ppp/pap.c
+++ b/usr.sbin/ppp/pap.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/pap.h b/usr.sbin/ppp/pap.h
index f9f685c913c9..a8e1f47d7dd7 100644
--- a/usr.sbin/ppp/pap.h
+++ b/usr.sbin/ppp/pap.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
#define PAP_REQUEST 1
diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c
index 5612c1194e9d..d4232240434a 100644
--- a/usr.sbin/ppp/physical.c
+++ b/usr.sbin/ppp/physical.c
@@ -16,8 +16,6 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $FreeBSD$
- *
*/
#include <sys/param.h>
@@ -646,7 +644,7 @@ iov2physical(struct datalink *dl, struct iovec *iov, int *niov, int maxiov,
}
unsigned
-physical_MaxDeviceSize()
+physical_MaxDeviceSize(void)
{
unsigned biggest, sz, n;
diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h
index cf3408e783eb..cb09c80bbae5 100644
--- a/usr.sbin/ppp/physical.h
+++ b/usr.sbin/ppp/physical.h
@@ -16,8 +16,6 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $FreeBSD$
- *
*/
struct datalink;
diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8
index 00470f6e5273..95b833c73c5c 100644
--- a/usr.sbin/ppp/ppp.8
+++ b/usr.sbin/ppp/ppp.8
@@ -23,9 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd May 20, 2021
+.Dd June 27, 2022
.Dt PPP 8
.Os
.Sh NAME
@@ -500,10 +498,7 @@ after altering
Although not strictly relevant to
.Nm Ns No 's
operation, you should configure your resolver so that it works correctly.
-This can be done by configuring a local DNS
-(using
-.Xr named 8 )
-or by adding the correct
+This can be done by configuring a local DNS resolver or by adding the correct
.Sq nameserver
lines to the file
.Pa /etc/resolv.conf .
@@ -6064,7 +6059,6 @@ This socket is used to pass links between different instances of
.Xr getty 8 ,
.Xr inetd 8 ,
.Xr init 8 ,
-.Xr named 8 ,
.Xr ping 8 ,
.Xr pppctl 8 ,
.Xr pppoed 8 ,
diff --git a/usr.sbin/ppp/ppp.conf b/usr.sbin/ppp/ppp.conf
index 576c11cde90a..9838023ea3e2 100644
--- a/usr.sbin/ppp/ppp.conf
+++ b/usr.sbin/ppp/ppp.conf
@@ -5,7 +5,6 @@
#
# See /usr/share/examples/ppp/ for some examples
#
-# $FreeBSD$
#################################################################
default:
diff --git a/usr.sbin/ppp/pred.c b/usr.sbin/ppp/pred.c
index 270cfa29b93b..04bfaebe9392 100644
--- a/usr.sbin/ppp/pred.c
+++ b/usr.sbin/ppp/pred.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* Ian Donaldson <iand@labtam.labtam.oz.au>
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <sys/types.h>
diff --git a/usr.sbin/ppp/pred.h b/usr.sbin/ppp/pred.h
index 395c57d4603b..81d8aaca19bd 100644
--- a/usr.sbin/ppp/pred.h
+++ b/usr.sbin/ppp/pred.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
extern const struct ccp_algorithm Pred1Algorithm;
diff --git a/usr.sbin/ppp/probe.c b/usr.sbin/ppp/probe.c
index 34e65d03b1ed..600a77601108 100644
--- a/usr.sbin/ppp/probe.c
+++ b/usr.sbin/ppp/probe.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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 <sys/time.h>
@@ -67,7 +65,7 @@ ipv6_available(void)
#endif
void
-probe_Init()
+probe_Init(void)
{
probe.select_changes_time = select_changes_time() ? 1 : 0;
log_Printf(LogDEBUG, "Select changes time: %s\n",
diff --git a/usr.sbin/ppp/probe.h b/usr.sbin/ppp/probe.h
index de838a6d9e0b..8d9766f23796 100644
--- a/usr.sbin/ppp/probe.h
+++ b/usr.sbin/ppp/probe.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct probe {
diff --git a/usr.sbin/ppp/prompt.c b/usr.sbin/ppp/prompt.c
index 48c264ce4b8d..478a2190a17a 100644
--- a/usr.sbin/ppp/prompt.c
+++ b/usr.sbin/ppp/prompt.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/prompt.h b/usr.sbin/ppp/prompt.h
index dbc1425dc74a..49c64e5bf9bb 100644
--- a/usr.sbin/ppp/prompt.h
+++ b/usr.sbin/ppp/prompt.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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$
*/
#define LOCAL_AUTH 0x01
diff --git a/usr.sbin/ppp/proto.c b/usr.sbin/ppp/proto.c
index 45c57b12c5bc..a737568acc68 100644
--- a/usr.sbin/ppp/proto.c
+++ b/usr.sbin/ppp/proto.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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 <sys/types.h>
diff --git a/usr.sbin/ppp/proto.h b/usr.sbin/ppp/proto.h
index e49cc91ab0e4..3937e1e1c819 100644
--- a/usr.sbin/ppp/proto.h
+++ b/usr.sbin/ppp/proto.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
/*
diff --git a/usr.sbin/ppp/radius.c b/usr.sbin/ppp/radius.c
index 92735e777ce1..77a38dead19e 100644
--- a/usr.sbin/ppp/radius.c
+++ b/usr.sbin/ppp/radius.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright 1999 Internet Business Solutions Ltd., Switzerland
* All rights reserved.
@@ -25,8 +25,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#include <stdint.h>
diff --git a/usr.sbin/ppp/radius.h b/usr.sbin/ppp/radius.h
index 5ffbbefefaee..ada086c1f56c 100644
--- a/usr.sbin/ppp/radius.h
+++ b/usr.sbin/ppp/radius.h
@@ -1,5 +1,5 @@
/*
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright 1999 Internet Business Solutions Ltd., Switzerland
* 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$
*/
#define MPPE_POLICY_ALLOWED 1
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c
index 72dbf65fef2b..8ec12f9ff9a3 100644
--- a/usr.sbin/ppp/route.c
+++ b/usr.sbin/ppp/route.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/route.h b/usr.sbin/ppp/route.h
index c088752fe02e..b117a11c818b 100644
--- a/usr.sbin/ppp/route.h
+++ b/usr.sbin/ppp/route.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
struct bundle;
diff --git a/usr.sbin/ppp/server.c b/usr.sbin/ppp/server.c
index 162eb445f07b..e7936f4ef88c 100644
--- a/usr.sbin/ppp/server.c
+++ b/usr.sbin/ppp/server.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/server.h b/usr.sbin/ppp/server.h
index b053ae253e60..71ca1cb3c96c 100644
--- a/usr.sbin/ppp/server.h
+++ b/usr.sbin/ppp/server.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct bundle;
diff --git a/usr.sbin/ppp/sig.c b/usr.sbin/ppp/sig.c
index c7b2f469826c..77fed9ffe0d8 100644
--- a/usr.sbin/ppp/sig.c
+++ b/usr.sbin/ppp/sig.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 - 1999, 2001 Brian Somers <brian@Awfulhak.org>
* 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 <sys/types.h>
@@ -94,7 +92,7 @@ sig_signal(int sig, sig_type fn)
* select() returned due to a signal being recorded by signal_recorder().
*/
int
-sig_Handle()
+sig_Handle(void)
{
int sig;
int got;
diff --git a/usr.sbin/ppp/sig.h b/usr.sbin/ppp/sig.h
index 277584544a5b..fefd4d071e52 100644
--- a/usr.sbin/ppp/sig.h
+++ b/usr.sbin/ppp/sig.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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$
*/
typedef void (*sig_type)(int);
diff --git a/usr.sbin/ppp/slcompress.c b/usr.sbin/ppp/slcompress.c
index adfdcd6da796..d79651a34195 100644
--- a/usr.sbin/ppp/slcompress.c
+++ b/usr.sbin/ppp/slcompress.c
@@ -27,8 +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.
- *
- * @(#)slcompress.c 8.2 (Berkeley) 4/16/94
*/
/*
@@ -37,8 +35,6 @@
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
- *
- * $FreeBSD$
*/
#include <sys/param.h>
diff --git a/usr.sbin/ppp/slcompress.h b/usr.sbin/ppp/slcompress.h
index 9694d3ace21d..5bb854be5533 100644
--- a/usr.sbin/ppp/slcompress.h
+++ b/usr.sbin/ppp/slcompress.h
@@ -32,8 +32,6 @@
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
- *
- * $FreeBSD$
*/
#define MIN_VJ_STATES 3
diff --git a/usr.sbin/ppp/sync.c b/usr.sbin/ppp/sync.c
index a9703f8c7bdc..22c50aff9bc5 100644
--- a/usr.sbin/ppp/sync.c
+++ b/usr.sbin/ppp/sync.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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 <sys/types.h>
diff --git a/usr.sbin/ppp/sync.h b/usr.sbin/ppp/sync.h
index acf7a837e6a4..d26d76d95962 100644
--- a/usr.sbin/ppp/sync.h
+++ b/usr.sbin/ppp/sync.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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$
*/
extern struct layer synclayer;
diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c
index f7f871eef514..b10072d093db 100644
--- a/usr.sbin/ppp/systems.c
+++ b/usr.sbin/ppp/systems.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/systems.h b/usr.sbin/ppp/systems.h
index 857f069d62c2..d8f328269628 100644
--- a/usr.sbin/ppp/systems.h
+++ b/usr.sbin/ppp/systems.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
struct prompt;
diff --git a/usr.sbin/ppp/tcp.c b/usr.sbin/ppp/tcp.c
index 13dbd22b5967..6306a7620c2a 100644
--- a/usr.sbin/ppp/tcp.c
+++ b/usr.sbin/ppp/tcp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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 <sys/types.h>
diff --git a/usr.sbin/ppp/tcp.h b/usr.sbin/ppp/tcp.h
index ad7a95441d44..da3329edf943 100644
--- a/usr.sbin/ppp/tcp.h
+++ b/usr.sbin/ppp/tcp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct physical;
diff --git a/usr.sbin/ppp/tcpmss.c b/usr.sbin/ppp/tcpmss.c
index 765668e9d137..a11b0104d99a 100644
--- a/usr.sbin/ppp/tcpmss.c
+++ b/usr.sbin/ppp/tcpmss.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2000 Ruslan Ermilov and Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
@@ -35,6 +33,9 @@
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
+#ifndef NOINET6
+#include <netinet/ip6.h>
+#endif
#include <netinet/tcp.h>
#include <sys/un.h>
@@ -69,10 +70,12 @@
/*-
- * We are in a liberal position about MSS
- * (RFC 879, section 7).
+ * Compute the MSS as described in RFC 6691.
*/
-#define MAXMSS(mtu) ((mtu) - sizeof(struct ip) - sizeof(struct tcphdr) - 12)
+#define MAXMSS4(mtu) ((mtu) - sizeof(struct ip) - sizeof(struct tcphdr))
+#ifndef NOINET6
+#define MAXMSS6(mtu) ((mtu) - sizeof(struct ip6_hdr) - sizeof(struct tcphdr))
+#endif
/*-
@@ -146,6 +149,10 @@ static struct mbuf *
tcpmss_Check(struct bundle *bundle, struct mbuf *bp)
{
struct ip *pip;
+#ifndef NOINET6
+ struct ip6_hdr *pip6;
+ struct ip6_frag *pfrag;
+#endif
size_t hlen, plen;
if (!Enabled(bundle, OPT_TCPMSSFIXUP))
@@ -153,19 +160,58 @@ tcpmss_Check(struct bundle *bundle, struct mbuf *bp)
bp = m_pullup(bp);
plen = m_length(bp);
+ if (plen < sizeof(struct ip))
+ return bp;
pip = (struct ip *)MBUF_CTOP(bp);
- hlen = pip->ip_hl << 2;
-
- /*
- * Check for MSS option only for TCP packets with zero fragment offsets
- * and correct total and header lengths.
- */
- if (pip->ip_p == IPPROTO_TCP && (ntohs(pip->ip_off) & IP_OFFMASK) == 0 &&
- ntohs(pip->ip_len) == plen && hlen <= plen &&
- plen >= sizeof(struct tcphdr) + hlen)
- MSSFixup((struct tcphdr *)(MBUF_CTOP(bp) + hlen), plen - hlen,
- MAXMSS(bundle->iface->mtu));
+ switch (pip->ip_v) {
+ case IPVERSION:
+ /*
+ * Check for MSS option only for TCP packets with zero fragment offsets
+ * and correct total and header lengths.
+ */
+ hlen = pip->ip_hl << 2;
+ if (pip->ip_p == IPPROTO_TCP && (ntohs(pip->ip_off) & IP_OFFMASK) == 0 &&
+ ntohs(pip->ip_len) == plen && hlen <= plen &&
+ plen >= sizeof(struct tcphdr) + hlen)
+ MSSFixup((struct tcphdr *)(MBUF_CTOP(bp) + hlen), plen - hlen,
+ MAXMSS4(bundle->iface->mtu));
+ break;
+#ifndef NOINET6
+ case IPV6_VERSION >> 4:
+ /*
+ * Check for MSS option only for TCP packets with no extension headers
+ * or a single extension header which is a fragmentation header with
+ * offset 0. Furthermore require that the length field is correct.
+ */
+ if (plen < sizeof(struct ip6_hdr))
+ break;
+ pip6 = (struct ip6_hdr *)MBUF_CTOP(bp);
+ if (ntohs(pip6->ip6_plen) + sizeof(struct ip6_hdr) != plen)
+ break;
+ hlen = 0;
+ switch (pip6->ip6_nxt) {
+ case IPPROTO_TCP:
+ hlen = sizeof(struct ip6_hdr);
+ break;
+ case IPPROTO_FRAGMENT:
+ if (plen >= sizeof(struct ip6_frag) + sizeof(struct ip6_hdr)) {
+ pfrag = (struct ip6_frag *)(MBUF_CTOP(bp) + sizeof(struct ip6_hdr));
+ if (pfrag->ip6f_nxt == IPPROTO_TCP &&
+ ntohs(pfrag->ip6f_offlg & IP6F_OFF_MASK) == 0)
+ hlen = sizeof(struct ip6_hdr)+ sizeof(struct ip6_frag);
+ }
+ break;
+ }
+ if (hlen > 0 && plen >= sizeof(struct tcphdr) + hlen)
+ MSSFixup((struct tcphdr *)(MBUF_CTOP(bp) + hlen), plen - hlen,
+ MAXMSS6(bundle->iface->mtu));
+ break;
+#endif
+ default:
+ log_Printf(LogDEBUG, "tcpmss_Check: Unknown IP family %u\n", pip->ip_v);
+ break;
+ }
return bp;
}
diff --git a/usr.sbin/ppp/tcpmss.h b/usr.sbin/ppp/tcpmss.h
index 1b84e28f61dd..02f4a0156418 100644
--- a/usr.sbin/ppp/tcpmss.h
+++ b/usr.sbin/ppp/tcpmss.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2000 Brian Somers <brian@Awfulhak.org>
* 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$
*/
extern struct layer tcpmsslayer;
diff --git a/usr.sbin/ppp/throughput.c b/usr.sbin/ppp/throughput.c
index 697223f1c85e..321c61719317 100644
--- a/usr.sbin/ppp/throughput.c
+++ b/usr.sbin/ppp/throughput.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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 <sys/types.h>
diff --git a/usr.sbin/ppp/throughput.h b/usr.sbin/ppp/throughput.h
index 8ece5adaa804..0511329cab3c 100644
--- a/usr.sbin/ppp/throughput.h
+++ b/usr.sbin/ppp/throughput.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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$
*/
#define SAMPLE_PERIOD 5 /* Default sample period */
diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c
index 581e2979f0d2..469f68c715de 100644
--- a/usr.sbin/ppp/timer.c
+++ b/usr.sbin/ppp/timer.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001, 2009 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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 <errno.h>
diff --git a/usr.sbin/ppp/timer.h b/usr.sbin/ppp/timer.h
index c68733f9438f..1c66d0e1cd1e 100644
--- a/usr.sbin/ppp/timer.h
+++ b/usr.sbin/ppp/timer.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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$
*/
#define TICKUNIT 100000 /* usec's per Unit */
diff --git a/usr.sbin/ppp/tty.c b/usr.sbin/ppp/tty.c
index 66b8b576c685..f0a76d648faf 100644
--- a/usr.sbin/ppp/tty.c
+++ b/usr.sbin/ppp/tty.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/tty.h b/usr.sbin/ppp/tty.h
index 8115b68ef6ec..79ff734b38f4 100644
--- a/usr.sbin/ppp/tty.h
+++ b/usr.sbin/ppp/tty.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct physical;
diff --git a/usr.sbin/ppp/tun.c b/usr.sbin/ppp/tun.c
index 66d7254aca71..1d08acbb6a2c 100644
--- a/usr.sbin/ppp/tun.c
+++ b/usr.sbin/ppp/tun.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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 <sys/param.h>
diff --git a/usr.sbin/ppp/tun.h b/usr.sbin/ppp/tun.h
index 720e538197dd..c02c1ddd3874 100644
--- a/usr.sbin/ppp/tun.h
+++ b/usr.sbin/ppp/tun.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct tun_data {
diff --git a/usr.sbin/ppp/ua.h b/usr.sbin/ppp/ua.h
index 9c13aabe6914..17e134a6a113 100644
--- a/usr.sbin/ppp/ua.h
+++ b/usr.sbin/ppp/ua.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
* 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$
*/
#ifdef __i386__ /* Do any other archs not care about alignment ? */
diff --git a/usr.sbin/ppp/udp.c b/usr.sbin/ppp/udp.c
index 3990b679b0a2..407adfe9fff2 100644
--- a/usr.sbin/ppp/udp.c
+++ b/usr.sbin/ppp/udp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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 <sys/types.h>
diff --git a/usr.sbin/ppp/udp.h b/usr.sbin/ppp/udp.h
index 5c251879a738..42b9950360f3 100644
--- a/usr.sbin/ppp/udp.h
+++ b/usr.sbin/ppp/udp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct physical;
diff --git a/usr.sbin/ppp/vjcomp.c b/usr.sbin/ppp/vjcomp.c
index 1b2ff64f474e..aabacffac0cb 100644
--- a/usr.sbin/ppp/vjcomp.c
+++ b/usr.sbin/ppp/vjcomp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
@@ -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/param.h>
diff --git a/usr.sbin/ppp/vjcomp.h b/usr.sbin/ppp/vjcomp.h
index 20465c4c8395..9afe305cb3ec 100644
--- a/usr.sbin/ppp/vjcomp.h
+++ b/usr.sbin/ppp/vjcomp.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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$
*/
struct mbuf;
diff --git a/usr.sbin/pppctl/Makefile b/usr.sbin/pppctl/Makefile
index 064f12dd7763..2c0204c26630 100644
--- a/usr.sbin/pppctl/Makefile
+++ b/usr.sbin/pppctl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= ppp
PROG= pppctl
diff --git a/usr.sbin/pppctl/Makefile.depend b/usr.sbin/pppctl/Makefile.depend
index 199e18875437..252e432e0ecb 100644
--- a/usr.sbin/pppctl/Makefile.depend
+++ b/usr.sbin/pppctl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -11,7 +9,6 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libedit \
lib/libthr \
- lib/ncurses/ncursesw \
.include <dirdeps.mk>
diff --git a/usr.sbin/pppctl/pppctl.8 b/usr.sbin/pppctl/pppctl.8
index 431b7d76c17e..3c4fde52b352 100644
--- a/usr.sbin/pppctl/pppctl.8
+++ b/usr.sbin/pppctl/pppctl.8
@@ -1,4 +1,3 @@
-.\" $FreeBSD$
.Dd June 26, 1997
.Dt PPPCTL 8
.Os
diff --git a/usr.sbin/pppctl/pppctl.c b/usr.sbin/pppctl/pppctl.c
index 129dc4fdf3c6..d5f7a81eac75 100644
--- a/usr.sbin/pppctl/pppctl.c
+++ b/usr.sbin/pppctl/pppctl.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* All rights reserved.
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/usr.sbin/praliases/Makefile b/usr.sbin/praliases/Makefile
index fbef36565bda..ef2682a8729f 100644
--- a/usr.sbin/praliases/Makefile
+++ b/usr.sbin/praliases/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.2 (Berkeley) 9/21/96
-# $FreeBSD$
SENDMAIL_DIR= ${SRCTOP}/contrib/sendmail
.PATH: ${SENDMAIL_DIR}/praliases
@@ -28,3 +26,5 @@ sm_os.h: ${SENDMAIL_DIR}/include/sm/os/sm_os_freebsd.h .NOMETA
ln -sf ${.ALLSRC} ${.TARGET}
.include <bsd.prog.mk>
+
+CWARNFLAGS+= ${NO_WDEPRECATED_NON_PROTOTYPE}
diff --git a/usr.sbin/praliases/Makefile.depend b/usr.sbin/praliases/Makefile.depend
index 0feabbf167e0..ec81c06f90f1 100644
--- a/usr.sbin/praliases/Makefile.depend
+++ b/usr.sbin/praliases/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/praudit/Makefile b/usr.sbin/praudit/Makefile
index 4d0cf2742e56..2eb78dddf292 100644
--- a/usr.sbin/praudit/Makefile
+++ b/usr.sbin/praudit/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
.include <src.opts.mk>
diff --git a/usr.sbin/praudit/Makefile.depend b/usr.sbin/praudit/Makefile.depend
index 2511c90c76b0..9ec2c1a7a215 100644
--- a/usr.sbin/praudit/Makefile.depend
+++ b/usr.sbin/praudit/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/praudit/tests/Makefile b/usr.sbin/praudit/tests/Makefile
index 628ed695f940..89cd1e462be8 100644
--- a/usr.sbin/praudit/tests/Makefile
+++ b/usr.sbin/praudit/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/usr.sbin/praudit/tests/praudit_test.sh b/usr.sbin/praudit/tests/praudit_test.sh
index eeaee25eef71..4aa98f0aa138 100644
--- a/usr.sbin/praudit/tests/praudit_test.sh
+++ b/usr.sbin/praudit/tests/praudit_test.sh
@@ -22,7 +22,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
diff --git a/usr.sbin/prometheus_sysctl_exporter/Makefile b/usr.sbin/prometheus_sysctl_exporter/Makefile
index 7d9b68b2cdc6..20eabbb7dbc4 100644
--- a/usr.sbin/prometheus_sysctl_exporter/Makefile
+++ b/usr.sbin/prometheus_sysctl_exporter/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= prometheus_sysctl_exporter
MAN= prometheus_sysctl_exporter.8
diff --git a/usr.sbin/prometheus_sysctl_exporter/Makefile.depend b/usr.sbin/prometheus_sysctl_exporter/Makefile.depend
index 5ed09d7880db..1361d23a34b2 100644
--- a/usr.sbin/prometheus_sysctl_exporter/Makefile.depend
+++ b/usr.sbin/prometheus_sysctl_exporter/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.8 b/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.8
index 7d73e3cab8cd..da09f43c1cf9 100644
--- a/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.8
+++ b/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.8
@@ -20,8 +20,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$
.Dd October 7, 2021
.Dt PROMETHEUS_SYSCTL_EXPORTER 8
.Os
diff --git a/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c b/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c
index e452e305d2bf..e3182467beab 100644
--- a/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c
+++ b/usr.sbin/prometheus_sysctl_exporter/prometheus_sysctl_exporter.c
@@ -23,9 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/resource.h>
#include <sys/socket.h>
@@ -62,18 +59,17 @@ static void
oid_get_root(struct oid *o)
{
- o->id[0] = 1;
+ o->id[0] = CTL_KERN;
o->len = 1;
}
/* Obtains the OID for a sysctl by name. */
-static void
+static bool
oid_get_by_name(struct oid *o, const char *name)
{
o->len = nitems(o->id);
- if (sysctlnametomib(name, o->id, &o->len) != 0)
- err(1, "sysctl(%s)", name);
+ return (sysctlnametomib(name, o->id, &o->len) == 0);
}
/* Returns whether an OID is placed below another OID. */
@@ -92,8 +88,8 @@ oid_get_next(const struct oid *cur, struct oid *next)
int lookup[CTL_MAXNAME + 2];
size_t nextsize;
- lookup[0] = 0;
- lookup[1] = 2;
+ lookup[0] = CTL_SYSCTL;
+ lookup[1] = CTL_SYSCTL_NEXT;
memcpy(lookup + 2, cur->id, cur->len * sizeof(lookup[0]));
nextsize = sizeof(next->id);
if (sysctl(lookup, 2 + cur->len, &next->id, &nextsize, 0, 0) != 0) {
@@ -136,8 +132,8 @@ oid_get_format(const struct oid *o, struct oidformat *of)
int lookup[CTL_MAXNAME + 2];
size_t oflen;
- lookup[0] = 0;
- lookup[1] = 4;
+ lookup[0] = CTL_SYSCTL;
+ lookup[1] = CTL_SYSCTL_OIDFMT;
memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0]));
oflen = sizeof(*of);
if (sysctl(lookup, 2 + o->len, of, &oflen, 0, 0) != 0) {
@@ -345,8 +341,8 @@ oid_get_name(const struct oid *o, struct oidname *on)
size_t i, len;
/* Fetch the name and split it up in separate components. */
- lookup[0] = 0;
- lookup[1] = 1;
+ lookup[0] = CTL_SYSCTL;
+ lookup[1] = CTL_SYSCTL_NAME;
memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0]));
len = sizeof(on->names);
if (sysctl(lookup, 2 + o->len, on->names, &len, 0, 0) != 0)
@@ -465,8 +461,8 @@ oid_get_description(const struct oid *o, struct oiddescription *od)
char *newline;
size_t odlen;
- lookup[0] = 0;
- lookup[1] = 5;
+ lookup[0] = CTL_SYSCTL;
+ lookup[1] = CTL_SYSCTL_OIDDESCR;
memcpy(lookup + 2, o->id, o->len * sizeof(lookup[0]));
odlen = sizeof(od->description);
if (sysctl(lookup, 2 + o->len, &od->description, &odlen, 0, 0) != 0) {
@@ -644,7 +640,15 @@ main(int argc, char *argv[])
for (i = 0; i < argc; ++i) {
struct oid o, root;
- oid_get_by_name(&root, argv[i]);
+ if (!oid_get_by_name(&root, argv[i])) {
+ /*
+ * Ignore trees provided as arguments that
+ * can't be found. They might belong, for
+ * example, to kernel modules not currently
+ * loaded.
+ */
+ continue;
+ }
o = root;
do {
oid_print(&o, &on, print_descriptions, exclude, include, fp);
diff --git a/usr.sbin/pstat/Makefile b/usr.sbin/pstat/Makefile
index e3b053308282..62d07c92a3c3 100644
--- a/usr.sbin/pstat/Makefile
+++ b/usr.sbin/pstat/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= pstat
LINKS= ${BINDIR}/pstat ${BINDIR}/swapinfo
diff --git a/usr.sbin/pstat/Makefile.depend b/usr.sbin/pstat/Makefile.depend
index 1487255a4257..41acc51d886d 100644
--- a/usr.sbin/pstat/Makefile.depend
+++ b/usr.sbin/pstat/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 \
lib/libutil \
diff --git a/usr.sbin/pstat/pstat.8 b/usr.sbin/pstat/pstat.8
index c6cc99e5571b..5d81a8d269da 100644
--- a/usr.sbin/pstat/pstat.8
+++ b/usr.sbin/pstat/pstat.8
@@ -32,10 +32,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)pstat.8 8.5 (Berkeley) 5/13/94
-.\" $FreeBSD$
-.\"
-.Dd October 11, 2014
+.Dd July 8, 2022
.Dt PSTAT 8
.Os
.Sh NAME
@@ -229,6 +226,26 @@ is also specified,
extract the name list from the specified system instead of the default,
which is the kernel image the system has booted from.
.El
+.Sh ENVIRONMENT
+.Bl -tag -width BLOCKSIZE
+.It Ev BLOCKSIZE
+If the environment variable
+.Ev BLOCKSIZE
+is set, and the
+.Fl h , k ,
+or
+.Fl m
+options are not specified, the block counts will be displayed in units of
+that block size.
+If
+.Ev BLOCKSIZE
+is not set, and the
+.Fl h , k ,
+or
+.Fl m
+options are not specified, the block counts will be displayed in 512-byte
+blocks.
+.El
.Sh SEE ALSO
.Xr ps 1 ,
.Xr systat 1 ,
diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c
index bcb3df20b8bd..aab7e902cc4c 100644
--- a/usr.sbin/pstat/pstat.c
+++ b/usr.sbin/pstat/pstat.c
@@ -36,20 +36,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#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
-static char sccsid[] = "@(#)pstat.c 8.16 (Berkeley) 5/9/95";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/time.h>
#include <sys/file.h>
diff --git a/usr.sbin/pw/Makefile b/usr.sbin/pw/Makefile
index 353eac132c7d..a1e0167e04d7 100644
--- a/usr.sbin/pw/Makefile
+++ b/usr.sbin/pw/Makefile
@@ -1,5 +1,5 @@
-# $FreeBSD$
+PACKAGE= runtime
PROG= pw
MAN= pw.conf.5 pw.8
SRCS= pw.c pw_conf.c pw_user.c pw_group.c pw_log.c pw_nis.c pw_vpw.c \
diff --git a/usr.sbin/pw/Makefile.depend b/usr.sbin/pw/Makefile.depend
index f746d7af1b21..1a673c53cbc6 100644
--- a/usr.sbin/pw/Makefile.depend
+++ b/usr.sbin/pw/Makefile.depend
@@ -1,15 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libcrypt \
- lib/libsbuf \
lib/libutil \
diff --git a/usr.sbin/pw/README b/usr.sbin/pw/README
index bbb153988366..b437df6b510f 100644
--- a/usr.sbin/pw/README
+++ b/usr.sbin/pw/README
@@ -16,7 +16,5 @@ is fully supported.
This program may be FreeBSD specific, but should be trivial to port to
other bsd4.4 variants.
-Author and maintainer: David L. Nugent, <davidn@blaze.net.au>
-
-$FreeBSD$
+Author: David L. Nugent, <davidn@blaze.net.au>
diff --git a/usr.sbin/pw/bitmap.c b/usr.sbin/pw/bitmap.c
index be82b2c792dd..f176fe571a36 100644
--- a/usr.sbin/pw/bitmap.c
+++ b/usr.sbin/pw/bitmap.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/pw/bitmap.h b/usr.sbin/pw/bitmap.h
index 570c678237d5..5bb436630055 100644
--- a/usr.sbin/pw/bitmap.h
+++ b/usr.sbin/pw/bitmap.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. 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 _BITMAP_H_
diff --git a/usr.sbin/pw/cpdir.c b/usr.sbin/pw/cpdir.c
index 4e6ca8828b91..504933ab88af 100644
--- a/usr.sbin/pw/cpdir.c
+++ b/usr.sbin/pw/cpdir.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <dirent.h>
#include <err.h>
#include <errno.h>
diff --git a/usr.sbin/pw/grupd.c b/usr.sbin/pw/grupd.c
index e98dd295183f..392e32b3ee7a 100644
--- a/usr.sbin/pw/grupd.c
+++ b/usr.sbin/pw/grupd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <err.h>
#include <grp.h>
#include <libutil.h>
diff --git a/usr.sbin/pw/psdate.c b/usr.sbin/pw/psdate.c
index 8c833b5c69c7..7d37e6b4aa1b 100644
--- a/usr.sbin/pw/psdate.c
+++ b/usr.sbin/pw/psdate.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <ctype.h>
#include <err.h>
#include <stdlib.h>
@@ -128,8 +123,8 @@ parse_datesub(char const * str, struct tm *t)
l = newlocale(LC_ALL_MASK, "C", NULL);
- memset(&tm, 0, sizeof(tm));
for (i=0; valid_formats[i] != NULL; i++) {
+ memset(&tm, 0, sizeof(tm));
ret = strptime_l(str, valid_formats[i], &tm, l);
if (ret && *ret == '\0') {
t->tm_mday = tm.tm_mday;
diff --git a/usr.sbin/pw/psdate.h b/usr.sbin/pw/psdate.h
index 29bfb3397f37..00744baafb43 100644
--- a/usr.sbin/pw/psdate.h
+++ b/usr.sbin/pw/psdate.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. 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 _PSDATE_H_
diff --git a/usr.sbin/pw/pw.8 b/usr.sbin/pw/pw.8
index d9072872bc2b..5d461fc6464e 100644
--- a/usr.sbin/pw/pw.8
+++ b/usr.sbin/pw/pw.8
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd April 3, 2022
+.Dd November 28, 2022
.Dt PW 8
.Os
.Sh NAME
@@ -541,6 +539,11 @@ This is like
.Fl h ,
but the password should be supplied already encrypted in a form
suitable for writing directly to the password database.
+See
+.Xr openssl-passwd 1
+and
+.Xr crypt 3
+for more details about generating an encrypted password hash.
.El
.Pp
It is possible to use
@@ -988,6 +991,12 @@ in addition to the other groups jsmith is already a member of.
.Bd -literal -offset indent
pw groupmod wheel -m jsmith
.Ed
+.Pp
+Generate random password and show it in both plain text and
+encrypted form not modifying any database.
+.Bd -literal -offset indent
+pw usermod nobody -Nw random
+.Ed
.Sh EXIT STATUS
The
.Nm
diff --git a/usr.sbin/pw/pw.c b/usr.sbin/pw/pw.c
index 4f92034a5d20..063553dd084f 100644
--- a/usr.sbin/pw/pw.c
+++ b/usr.sbin/pw/pw.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <err.h>
#include <fcntl.h>
#include <locale.h>
diff --git a/usr.sbin/pw/pw.conf.5 b/usr.sbin/pw/pw.conf.5
index 61c40e87c11a..2a4aab25c328 100644
--- a/usr.sbin/pw/pw.conf.5
+++ b/usr.sbin/pw/pw.conf.5
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd March 30, 2007
.Dt PW.CONF 5
.Os
diff --git a/usr.sbin/pw/pw.h b/usr.sbin/pw/pw.h
index 1e09722a907c..5de333ce5e71 100644
--- a/usr.sbin/pw/pw.h
+++ b/usr.sbin/pw/pw.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. 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 <sys/stat.h>
@@ -114,3 +112,5 @@ extern const char *Which[];
uintmax_t strtounum(const char * __restrict, uintmax_t, uintmax_t,
const char ** __restrict);
+
+bool grp_has_member(struct group *grp, const char *name);
diff --git a/usr.sbin/pw/pw_conf.c b/usr.sbin/pw/pw_conf.c
index b9b80f85cd48..e9042b15b321 100644
--- a/usr.sbin/pw/pw_conf.c
+++ b/usr.sbin/pw/pw_conf.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <err.h>
#include <fcntl.h>
#include <string.h>
diff --git a/usr.sbin/pw/pw_group.c b/usr.sbin/pw/pw_group.c
index a294d4ecbb5c..32dec769fb1a 100644
--- a/usr.sbin/pw/pw_group.c
+++ b/usr.sbin/pw/pw_group.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <ctype.h>
#include <err.h>
#include <grp.h>
@@ -55,7 +50,8 @@ grp_set_passwd(struct group *grp, bool update, int fd, bool precrypted)
int b;
int istty;
struct termios t, n;
- char *p, line[256];
+ static char line[256];
+ char *p;
if (fd == -1)
return;
@@ -276,6 +272,8 @@ pw_group_next(int argc, char **argv, char *arg1 __unused)
case 'q':
quiet = true;
break;
+ default:
+ exit(EX_USAGE);
}
}
@@ -333,6 +331,8 @@ pw_group_show(int argc, char **argv, char *arg1)
case 'a':
all = true;
break;
+ default:
+ exit(EX_USAGE);
}
}
@@ -390,6 +390,8 @@ pw_group_del(int argc, char **argv, char *arg1)
case 'Y':
nis = true;
break;
+ default:
+ exit(EX_USAGE);
}
}
@@ -411,7 +413,7 @@ pw_group_del(int argc, char **argv, char *arg1)
return (EXIT_SUCCESS);
}
-static bool
+bool
grp_has_member(struct group *grp, const char *name)
{
int j;
@@ -548,6 +550,8 @@ pw_group_add(int argc, char **argv, char *arg1)
case 'Y':
nis = true;
break;
+ default:
+ exit(EX_USAGE);
}
}
@@ -640,6 +644,8 @@ pw_group_mod(int argc, char **argv, char *arg1)
case 'Y':
nis = true;
break;
+ default:
+ exit(EX_USAGE);
}
}
if (quiet)
diff --git a/usr.sbin/pw/pw_log.c b/usr.sbin/pw/pw_log.c
index 17e14d1e44ed..43dd4207ba29 100644
--- a/usr.sbin/pw/pw_log.c
+++ b/usr.sbin/pw/pw_log.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <ctype.h>
#include <err.h>
#include <fcntl.h>
diff --git a/usr.sbin/pw/pw_nis.c b/usr.sbin/pw/pw_nis.c
index 4b70bc1de1f6..23e82239379f 100644
--- a/usr.sbin/pw/pw_nis.c
+++ b/usr.sbin/pw/pw_nis.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/types.h>
#include <err.h>
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 2eec317b5e5b..6875d931a1d2 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -27,11 +27,6 @@
*
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/types.h>
@@ -50,6 +45,7 @@ static const char rcsid[] =
#include <sysexits.h>
#include <termios.h>
#include <unistd.h>
+#include <spawn.h>
#include "pw.h"
#include "bitmap.h"
@@ -57,6 +53,7 @@ static const char rcsid[] =
#define LOGNAMESIZE (MAXLOGNAME-1)
+extern char **environ;
static char locked_str[] = "*LOCKED*";
static struct passwd fakeuser = {
@@ -80,11 +77,9 @@ static uid_t pw_gidpolicy(struct userconf *cnf, char *grname, char *nam,
static char *pw_homepolicy(struct userconf * cnf, char *homedir,
const char *user);
static char *pw_shellpolicy(struct userconf * cnf);
-static char *pw_password(struct userconf * cnf, char const * user,
- bool dryrun);
+static char *pw_password(struct userconf * cnf, char const * user);
static char *shell_path(char const * path, char *shells[], char *sh);
static void rmat(uid_t uid);
-static void rmopie(char const * name);
static void
mkdir_home_parents(int dfd, const char *dir)
@@ -114,36 +109,20 @@ mkdir_home_parents(int dfd, const char *dir)
}
tmp[0] = '\0';
- /*
- * This is a kludge especially for Joerg :)
- * If the home directory would be created in the root partition, then
- * we really create it under /usr which is likely to have more space.
- * But we create a symlink from cnf->home -> "/usr" -> cnf->home
- */
- if (strchr(dirs, '/') == NULL) {
- asprintf(&tmp, "usr/%s", dirs);
- if (tmp == NULL)
- errx(EX_UNAVAILABLE, "out of memory");
- if (mkdirat(dfd, tmp, _DEF_DIRMODE) != -1 || errno == EEXIST) {
- fchownat(dfd, tmp, 0, 0, 0);
- symlinkat(tmp, dfd, dirs);
- }
- free(tmp);
- }
tmp = dirs;
if (fstatat(dfd, dirs, &st, 0) == -1) {
while ((tmp = strchr(tmp + 1, '/')) != NULL) {
*tmp = '\0';
if (fstatat(dfd, dirs, &st, 0) == -1) {
if (mkdirat(dfd, dirs, _DEF_DIRMODE) == -1)
- err(EX_OSFILE, "'%s' (root home parent) is not a directory", dirs);
+ err(EX_OSFILE, "'%s' (home parent) is not a directory", dirs);
}
*tmp = '/';
}
}
if (fstatat(dfd, dirs, &st, 0) == -1) {
if (mkdirat(dfd, dirs, _DEF_DIRMODE) == -1)
- err(EX_OSFILE, "'%s' (root home parent) is not a directory", dirs);
+ err(EX_OSFILE, "'%s' (home parent) is not a directory", dirs);
fchownat(dfd, dirs, 0, 0, 0);
}
@@ -394,8 +373,7 @@ pw_gidpolicy(struct userconf *cnf, char *grname, char *nam, gid_t prefer, bool d
grp = GETGRGID(gid);
}
gid = grp->gr_gid;
- } else if ((grp = GETGRNAM(nam)) != NULL &&
- (grp->gr_mem == NULL || grp->gr_mem[0] == NULL)) {
+ } else if ((grp = GETGRNAM(nam)) != NULL) {
gid = grp->gr_gid; /* Already created? Use it anyway... */
} else {
intmax_t grid = -1;
@@ -511,7 +489,7 @@ pw_pwcrypt(char *password)
}
static char *
-pw_password(struct userconf * cnf, char const * user, bool dryrun)
+pw_password(struct userconf * cnf, char const * user)
{
int i, l;
char pwbuf[32];
@@ -528,7 +506,7 @@ pw_password(struct userconf * cnf, char const * user, bool dryrun)
/*
* We give this information back to the user
*/
- if (conf.fd == -1 && !dryrun) {
+ if (conf.fd == -1) {
if (isatty(STDOUT_FILENO))
printf("Password for '%s' is: ", user);
printf("%s\n", pwbuf);
@@ -636,7 +614,7 @@ pw_checkname(char *name, int gecos)
showtype = "gecos field";
} else {
/* See if the name is valid as a userid or group. */
- badchars = " ,\t:+&#%$^()!@~*?<>=|\\/\"";
+ badchars = " ,\t:+&#%$^()!@~*?<>=|\\/\";";
showtype = "userid/group name";
/* Userids and groups can not have a leading '-'. */
if (*ch == '-')
@@ -696,47 +674,22 @@ rmat(uid_t uid)
stat(e->d_name, &st) == 0 &&
!S_ISDIR(st.st_mode) &&
st.st_uid == uid) {
- char tmp[MAXPATHLEN];
-
- snprintf(tmp, sizeof(tmp), "/usr/bin/atrm %s",
- e->d_name);
- system(tmp);
+ const char *argv[] = {
+ "/usr/sbin/atrm",
+ e->d_name,
+ NULL
+ };
+ if (posix_spawn(NULL, argv[0], NULL, NULL,
+ (char *const *) argv, environ)) {
+ warn("Failed to execute '%s %s'",
+ argv[0], argv[1]);
+ }
}
}
closedir(d);
}
}
-static void
-rmopie(char const * name)
-{
- char tmp[1014];
- FILE *fp;
- size_t len;
- long atofs;
- int fd;
-
- if ((fd = openat(conf.rootfd, "etc/opiekeys", O_RDWR)) == -1)
- return;
-
- fp = fdopen(fd, "r+");
- len = strlen(name);
-
- for (atofs = 0; fgets(tmp, sizeof(tmp), fp) != NULL && atofs >= 0;
- atofs = ftell(fp)) {
- if (strncmp(name, tmp, len) == 0 && tmp[len]==' ') {
- /* Comment username out */
- if (fseek(fp, atofs, SEEK_SET) == 0)
- fwrite("#", 1, 1, fp);
- break;
- }
- }
- /*
- * If we got an error of any sort, don't update!
- */
- fclose(fp);
-}
-
int
pw_user_next(int argc, char **argv, char *name __unused)
{
@@ -754,6 +707,8 @@ pw_user_next(int argc, char **argv, char *name __unused)
case 'q':
quiet = true;
break;
+ default:
+ exit(EX_USAGE);
}
}
@@ -816,6 +771,8 @@ pw_user_show(int argc, char **argv, char *arg1)
case '7':
v7 = true;
break;
+ default:
+ exit(EX_USAGE);
}
}
@@ -897,6 +854,8 @@ pw_user_del(int argc, char **argv, char *arg1)
case 'Y':
nis = true;
break;
+ default:
+ exit(EX_USAGE);
}
}
@@ -937,17 +896,22 @@ pw_user_del(int argc, char **argv, char *arg1)
if (strcmp(pwd->pw_name, "root") == 0)
errx(EX_DATAERR, "cannot remove user 'root'");
- /* Remove opie record from /etc/opiekeys */
- if (PWALTDIR() != PWF_ALT)
- rmopie(pwd->pw_name);
-
if (!PWALTDIR()) {
/* Remove crontabs */
snprintf(file, sizeof(file), "/var/cron/tabs/%s", pwd->pw_name);
if (access(file, F_OK) == 0) {
- snprintf(file, sizeof(file), "crontab -u %s -r",
- pwd->pw_name);
- system(file);
+ const char *argv[] = {
+ "crontab",
+ "-u",
+ pwd->pw_name,
+ "-r",
+ NULL
+ };
+ if (posix_spawnp(NULL, argv[0], NULL, NULL,
+ (char *const *) argv, environ)) {
+ warn("Failed to execute '%s %s'",
+ argv[0], argv[1]);
+ }
}
}
@@ -1038,6 +1002,8 @@ pw_user_lock(int argc, char **argv, char *arg1)
case 'q':
/* compatibility */
break;
+ default:
+ exit(EX_USAGE);
}
}
@@ -1055,6 +1021,8 @@ pw_user_unlock(int argc, char **argv, char *arg1)
case 'q':
/* compatibility */
break;
+ default:
+ exit(EX_USAGE);
}
}
@@ -1322,6 +1290,8 @@ pw_user_add(int argc, char **argv, char *arg1)
case 'Y':
nis = true;
break;
+ default:
+ exit(EX_USAGE);
}
}
@@ -1398,7 +1368,7 @@ pw_user_add(int argc, char **argv, char *arg1)
if (lc == NULL || login_setcryptfmt(lc, "sha512", NULL) == NULL)
warn("setting crypt(3) format");
login_close(lc);
- pwd->pw_passwd = pw_password(cmdcnf, pwd->pw_name, dryrun);
+ pwd->pw_passwd = pw_password(cmdcnf, pwd->pw_name);
if (pwd->pw_uid == 0 && strcmp(pwd->pw_name, "root") != 0)
warnx("WARNING: new account `%s' has a uid of 0 "
"(superuser access!)", pwd->pw_name);
@@ -1432,6 +1402,9 @@ pw_user_add(int argc, char **argv, char *arg1)
if (cmdcnf->groups != NULL) {
for (i = 0; i < cmdcnf->groups->sl_cur; i++) {
grp = GETGRNAM(cmdcnf->groups->sl_str[i]);
+ /* gr_add doesn't check if new member is already in group */
+ if (grp_has_member(grp, pwd->pw_name))
+ continue;
grp = gr_add(grp, pwd->pw_name);
/*
* grp can only be NULL in 2 cases:
@@ -1630,6 +1603,8 @@ pw_user_mod(int argc, char **argv, char *arg1)
case 'Y':
nis = true;
break;
+ default:
+ exit(EX_USAGE);
}
}
@@ -1745,7 +1720,7 @@ pw_user_mod(int argc, char **argv, char *arg1)
login_close(lc);
cnf->default_password = passwd_val(passwd,
cnf->default_password);
- pwd->pw_passwd = pw_password(cnf, pwd->pw_name, dryrun);
+ pwd->pw_passwd = pw_password(cnf, pwd->pw_name);
edited = true;
}
diff --git a/usr.sbin/pw/pw_utils.c b/usr.sbin/pw/pw_utils.c
index fbf4a3f5f560..9be1656bcfe1 100644
--- a/usr.sbin/pw/pw_utils.c
+++ b/usr.sbin/pw/pw_utils.c
@@ -25,8 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/wait.h>
#include <err.h>
diff --git a/usr.sbin/pw/pw_vpw.c b/usr.sbin/pw/pw_vpw.c
index 192d588ab0cf..4814ec2076d6 100644
--- a/usr.sbin/pw/pw_vpw.c
+++ b/usr.sbin/pw/pw_vpw.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -27,11 +27,6 @@
*
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <pwd.h>
#include <grp.h>
#include <libutil.h>
diff --git a/usr.sbin/pw/pwupd.c b/usr.sbin/pw/pwupd.c
index ac91c9e4c1bb..89c1553c8c92 100644
--- a/usr.sbin/pw/pwupd.c
+++ b/usr.sbin/pw/pwupd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/wait.h>
#include <err.h>
diff --git a/usr.sbin/pw/pwupd.h b/usr.sbin/pw/pwupd.h
index b6f268baae5c..d174a4a20200 100644
--- a/usr.sbin/pw/pwupd.h
+++ b/usr.sbin/pw/pwupd.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -24,14 +24,11 @@
* 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 _PWUPD_H_
#define _PWUPD_H_
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/types.h>
diff --git a/usr.sbin/pw/rm_r.c b/usr.sbin/pw/rm_r.c
index 66ec3f21423f..14218d68215b 100644
--- a/usr.sbin/pw/rm_r.c
+++ b/usr.sbin/pw/rm_r.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
@@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/stat.h>
#include <dirent.h>
diff --git a/usr.sbin/pw/strtounum.c b/usr.sbin/pw/strtounum.c
index ae578bdeaeba..b138e7f130b7 100644
--- a/usr.sbin/pw/strtounum.c
+++ b/usr.sbin/pw/strtounum.c
@@ -25,8 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
diff --git a/usr.sbin/pw/tests/Makefile b/usr.sbin/pw/tests/Makefile
index ecdb0fe1665d..4704adbf995f 100644
--- a/usr.sbin/pw/tests/Makefile
+++ b/usr.sbin/pw/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/usr.sbin/pw/tests/Makefile.depend b/usr.sbin/pw/tests/Makefile.depend
index 9124664318e7..6424d36707cd 100644
--- a/usr.sbin/pw/tests/Makefile.depend
+++ b/usr.sbin/pw/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/pw/tests/crypt.c b/usr.sbin/pw/tests/crypt.c
index 586fccdfec78..2a2023e47393 100644
--- a/usr.sbin/pw/tests/crypt.c
+++ b/usr.sbin/pw/tests/crypt.c
@@ -22,8 +22,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 <err.h>
diff --git a/usr.sbin/pw/tests/group b/usr.sbin/pw/tests/group
index 620c588faa38..2812f56cfa98 100644
--- a/usr.sbin/pw/tests/group
+++ b/usr.sbin/pw/tests/group
@@ -1,3 +1,2 @@
-# $FreeBSD$
#
wheel:*:0:root
diff --git a/usr.sbin/pw/tests/helper_functions.shin b/usr.sbin/pw/tests/helper_functions.shin
index 1ee731a786ef..c03ca98d8709 100755
--- a/usr.sbin/pw/tests/helper_functions.shin
+++ b/usr.sbin/pw/tests/helper_functions.shin
@@ -1,4 +1,3 @@
-# $FreeBSD$
# The pw command
PW="pw -V ${HOME}"
diff --git a/usr.sbin/pw/tests/master.passwd b/usr.sbin/pw/tests/master.passwd
index f7dc837dabca..46728369eb17 100644
--- a/usr.sbin/pw/tests/master.passwd
+++ b/usr.sbin/pw/tests/master.passwd
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
root:*:0:0::0:0:Charlie &:/root:/bin/csh
toor:*:0:0::0:0:Bourne-again Superuser:/root:
diff --git a/usr.sbin/pw/tests/pw_config_test.sh b/usr.sbin/pw/tests/pw_config_test.sh
index fb6489a0b31c..e9209190dc5e 100755
--- a/usr.sbin/pw/tests/pw_config_test.sh
+++ b/usr.sbin/pw/tests/pw_config_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_etcdir_test.sh b/usr.sbin/pw/tests/pw_etcdir_test.sh
index b237789ed457..db6f0f30eaf3 100755
--- a/usr.sbin/pw/tests/pw_etcdir_test.sh
+++ b/usr.sbin/pw/tests/pw_etcdir_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# When the '-V directory' option is provided, the directory must exist
atf_test_case etcdir_must_exist
diff --git a/usr.sbin/pw/tests/pw_groupadd_test.sh b/usr.sbin/pw/tests/pw_groupadd_test.sh
index 5fa7bef0fdf1..cf3c401a361c 100755
--- a/usr.sbin/pw/tests/pw_groupadd_test.sh
+++ b/usr.sbin/pw/tests/pw_groupadd_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_groupdel_test.sh b/usr.sbin/pw/tests/pw_groupdel_test.sh
index 88cc0e08b8bf..fa51b3814205 100755
--- a/usr.sbin/pw/tests/pw_groupdel_test.sh
+++ b/usr.sbin/pw/tests/pw_groupdel_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_groupmod_test.sh b/usr.sbin/pw/tests/pw_groupmod_test.sh
index 580692553847..ce7106d885d2 100755
--- a/usr.sbin/pw/tests/pw_groupmod_test.sh
+++ b/usr.sbin/pw/tests/pw_groupmod_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_groupshow_test.sh b/usr.sbin/pw/tests/pw_groupshow_test.sh
index f348d0ab1f70..06631e912c0f 100755
--- a/usr.sbin/pw/tests/pw_groupshow_test.sh
+++ b/usr.sbin/pw/tests/pw_groupshow_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_lock_test.sh b/usr.sbin/pw/tests/pw_lock_test.sh
index 5ec1b09a6956..f8fe03a4d147 100755
--- a/usr.sbin/pw/tests/pw_lock_test.sh
+++ b/usr.sbin/pw/tests/pw_lock_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_useradd_test.sh b/usr.sbin/pw/tests/pw_useradd_test.sh
index a50f018ab99d..3b495482eb05 100755
--- a/usr.sbin/pw/tests/pw_useradd_test.sh
+++ b/usr.sbin/pw/tests/pw_useradd_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
@@ -295,15 +294,23 @@ user_add_R_body() {
[ ! -d ${HOME}/home/bar ] || atf_fail "Directory not removed"
}
-atf_test_case user_add_R_symlink
-user_add_R_symlink_body() {
+atf_test_case user_add_R_no_symlink
+user_add_R_no_symlink_body() {
populate_root_etc_skel
mkdir ${HOME}/usr
atf_check -s exit:0 ${RPW} useradd foo -m
- test -d ${HOME}/usr/home || atf_fail "Home parent directory not created"
- test -h ${HOME}/home || atf_fail "/home directory is not a symlink"
- atf_check -s exit:0 -o inline:"usr/home\n" readlink ${HOME}/home
+ [ ! -d ${HOME}/usr/home ] || atf_fail "/usr/home created"
+ test -d ${HOME}/home || atf_fail "/home directory not created"
+}
+
+atf_test_case user_add_R_intermed
+user_add_R_intermed_body() {
+ populate_root_etc_skel
+
+ atf_check -s exit:0 ${RPW} useradd foo -m -d /a/b/c/foo
+ test -d ${HOME}/a/b/c || atf_fail "intermediate directories not created"
+ test -d ${HOME}/a/b/c/foo || atf_fail "user directory not created"
}
atf_test_case user_add_skel
@@ -455,6 +462,29 @@ user_add_conf_defaultpasswd_body()
grep defaultpasswd ${HOME}/pw.conf
}
+atf_test_case user_add_existing_login_group
+user_add_existing_login_group_body()
+{
+ populate_etc_skel
+
+ atf_check -s exit:0 ${PW} groupadd testuser
+ atf_check -s exit:0 ${PW} useradd user1 -G testuser
+ atf_check -s exit:0 ${PW} useradd testuser
+ atf_check -o match:"1" \
+ sh -c "grep testuser ${HOME}/group | wc -l"
+}
+
+atf_test_case user_add_already_in_group
+user_add_already_in_group_body()
+{
+ populate_etc_skel
+
+ echo "testgroup:*:4242:testuser" >> ${HOME}/group
+ atf_check -s exit:0 ${PW} useradd testuser -G testgroup
+ atf_check -o not-match:"testuser,testuser" \
+ grep testuser ${HOME}/group
+}
+
atf_init_test_cases() {
atf_add_test_case user_add
atf_add_test_case user_add_noupdate
@@ -479,7 +509,8 @@ atf_init_test_cases() {
atf_add_test_case user_add_invalid_group_entry
atf_add_test_case user_add_password_from_h
atf_add_test_case user_add_R
- atf_add_test_case user_add_R_symlink
+ atf_add_test_case user_add_R_no_symlink
+ atf_add_test_case user_add_R_intermed
atf_add_test_case user_add_skel
atf_add_test_case user_add_uid0
atf_add_test_case user_add_uid_too_large
@@ -494,4 +525,6 @@ atf_init_test_cases() {
atf_add_test_case user_add_defaultgroup
atf_add_test_case user_add_conf_defaultpasswd
+ atf_add_test_case user_add_existing_login_group
+ atf_add_test_case user_add_already_in_group
}
diff --git a/usr.sbin/pw/tests/pw_userdel_test.sh b/usr.sbin/pw/tests/pw_userdel_test.sh
index 694d7bbae6cc..2e11c3534d58 100755
--- a/usr.sbin/pw/tests/pw_userdel_test.sh
+++ b/usr.sbin/pw/tests/pw_userdel_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
@@ -39,12 +38,10 @@ delete_files_body() {
touch ${HOME}/skel/a
mkdir -p ${HOME}/home
mkdir -p ${HOME}/var/mail
- echo "foo wedontcare" > ${HOME}/etc/opiekeys
atf_check -s exit:0 ${RPW} useradd foo -k /skel -m
test -d ${HOME}/home || atf_fail "Fail to create home directory"
test -f ${HOME}/var/mail/foo || atf_fail "Mail file not created"
atf_check -s exit:0 ${RPW} userdel foo -r
- atf_check -s exit:0 -o inline:"#oo wedontcare\n" cat ${HOME}/etc/opiekeys
if test -f ${HOME}/var/mail/foo; then
atf_fail "Mail file not removed"
fi
diff --git a/usr.sbin/pw/tests/pw_usermod_test.sh b/usr.sbin/pw/tests/pw_usermod_test.sh
index cf3622f3b222..f8cb66a45b70 100755
--- a/usr.sbin/pw/tests/pw_usermod_test.sh
+++ b/usr.sbin/pw/tests/pw_usermod_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_usernext_test.sh b/usr.sbin/pw/tests/pw_usernext_test.sh
index 89f938ec8c33..63a688f573d8 100755
--- a/usr.sbin/pw/tests/pw_usernext_test.sh
+++ b/usr.sbin/pw/tests/pw_usernext_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_usershow_test.sh b/usr.sbin/pw/tests/pw_usershow_test.sh
index 530597948e4a..06f7f610936a 100755
--- a/usr.sbin/pw/tests/pw_usershow_test.sh
+++ b/usr.sbin/pw/tests/pw_usershow_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pwd_mkdb/Makefile b/usr.sbin/pwd_mkdb/Makefile
index f8a2b20ef10b..e9a4aa09d911 100644
--- a/usr.sbin/pwd_mkdb/Makefile
+++ b/usr.sbin/pwd_mkdb/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
.PATH: ${SRCTOP}/lib/libc/gen # for pw_scan.c
diff --git a/usr.sbin/pwd_mkdb/Makefile.depend b/usr.sbin/pwd_mkdb/Makefile.depend
index d5ed563ecfc8..344a5d0e9310 100644
--- a/usr.sbin/pwd_mkdb/Makefile.depend
+++ b/usr.sbin/pwd_mkdb/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/pwd_mkdb/bootstrap/pwd.h b/usr.sbin/pwd_mkdb/bootstrap/pwd.h
index bc196e2c0fd0..90f5b6fd7a68 100644
--- a/usr.sbin/pwd_mkdb/bootstrap/pwd.h
+++ b/usr.sbin/pwd_mkdb/bootstrap/pwd.h
@@ -32,8 +32,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$
*/
/*
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.8 b/usr.sbin/pwd_mkdb/pwd_mkdb.8
index 0a8b0143569c..d28d5dc0ab2c 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.8
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.8
@@ -25,10 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)pwd_mkdb.8 8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
-.\"
-.Dd October 20, 2018
+.Dd March 25, 2023
.Dt PWD_MKDB 8
.Os
.Sh NAME
@@ -65,6 +62,19 @@ The options are as follows:
Check if the password file is in the correct format.
Do not
change, add, or remove any files.
+.It Fl d Ar directory
+Store databases into specified destination directory instead of
+.Pa /etc .
+.It Fl i
+Ignore locking failure of the
+.Pa master.passwd
+file.
+This option is intended to be used to build password files in
+the release process over NFS where no contention can happen.
+A non-default directory must also be specified with the
+.Fl d
+option for locking to be ignored.
+Other use of this option is strongly discouraged.
.It Fl N
Tell
.Nm
@@ -76,24 +86,6 @@ the rebuilding of the database.
.It Fl p
Create a Version 7 style password file and install it into
.Pa /etc/passwd .
-.It Fl i
-Ignore locking failure of the
-.Pa master.passwd
-file.
-This option is intended to be used to build password files in
-the release process over NFS where no contention can happen.
-A non-default directory must also be specified with the
-.Fl d
-option for locking to be ignored.
-Other use of this option is strongly discouraged.
-.It Fl d Ar directory
-Store databases into specified destination directory instead of
-.Pa /etc .
-.It Fl u Ar username
-Only update the record for the specified user.
-Utilities that
-operate on a single user can use this option to avoid the
-overhead of rebuilding the entire database.
.It Fl s Ar cachesize
Specify in megabytes the size of the memory cache used by the
hashing library.
@@ -104,6 +96,11 @@ As a rough guide, the memory usage of
in megabytes will be a little bit more than twice the figure
specified here.
The default is 2 megabytes.
+.It Fl u Ar username
+Only update the record for the specified user.
+Utilities that
+operate on a single user can use this option to avoid the
+overhead of rebuilding the entire database.
.El
.Pp
The two databases differ in that the secure version contains the user's
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c
index 6297bcb461db..3c27b40044e3 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.c
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c
@@ -29,21 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1991, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)pwd_mkdb.c 8.5 (Berkeley) 4/20/94";
-#endif /* not lint */
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/stat.h>
@@ -109,10 +94,11 @@ main(int argc, char *argv[])
uint32_t store;
const char *t;
char *p;
- char buf[MAX(MAXPATHLEN, LINE_MAX * 2)], tbuf[1024];
+ char buf[MAX(MAXPATHLEN, LINE_MAX * 2)];
char sbuf[MAX(MAXPATHLEN, LINE_MAX * 2)];
char buf2[MAXPATHLEN];
char sbuf2[MAXPATHLEN];
+ char tbuf[1024];
char *username;
u_int method, methoduid;
int Cflag, dflag, iflag;
@@ -123,14 +109,11 @@ main(int argc, char *argv[])
makeold = 0;
username = NULL;
oldfp = NULL;
- while ((ch = getopt(argc, argv, "CNd:ips:u:v")) != -1)
+ while ((ch = getopt(argc, argv, "Cd:iNps:u:v")) != -1)
switch(ch) {
case 'C': /* verify only */
Cflag = 1;
break;
- case 'N': /* do not wait for lock */
- nblock = LOCK_NB; /* will fail if locked */
- break;
case 'd':
dflag++;
strlcpy(prefix, optarg, sizeof(prefix));
@@ -138,6 +121,9 @@ main(int argc, char *argv[])
case 'i':
iflag++;
break;
+ case 'N': /* do not wait for lock */
+ nblock = LOCK_NB; /* will fail if locked */
+ break;
case 'p': /* create V7 "file.orig" */
makeold = 1;
break;
@@ -462,11 +448,14 @@ main(int argc, char *argv[])
error("put");
}
}
- /* Create original format password file entry */
- if (is_comment && makeold){ /* copy comments */
- if (fprintf(oldfp, "%s\n", line) < 0)
- error("write old");
- } else if (makeold) {
+ /*
+ * Create original style password file entry.
+ *
+ * Don't copy comments since this could reveal encrypted
+ * passwords if entries have been simply commented out
+ * in master.passwd.
+ */
+ if (makeold && !is_comment) {
char uidstr[20];
char gidstr[20];
@@ -672,6 +661,6 @@ usage(void)
{
(void)fprintf(stderr,
-"usage: pwd_mkdb [-BCiLNp] [-d directory] [-s cachesize] [-u username] file\n");
+"usage: pwd_mkdb [-CiNp] [-d directory] [-s cachesize] [-u username] file\n");
exit(1);
}
diff --git a/usr.sbin/pwm/Makefile b/usr.sbin/pwm/Makefile
index 732995fc6018..044b1b1b72f1 100644
--- a/usr.sbin/pwm/Makefile
+++ b/usr.sbin/pwm/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= pwm
MAN= pwm.8
diff --git a/usr.sbin/pwm/pwm.8 b/usr.sbin/pwm/pwm.8
index 94be5af7f703..359cdac52822 100644
--- a/usr.sbin/pwm/pwm.8
+++ b/usr.sbin/pwm/pwm.8
@@ -20,8 +20,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 June 17, 2019
.Dt PWM 8
.Os
diff --git a/usr.sbin/pwm/pwm.c b/usr.sbin/pwm/pwm.c
index 441181917afd..d7bbbad6c173 100644
--- a/usr.sbin/pwm/pwm.c
+++ b/usr.sbin/pwm/pwm.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Emmanuel Vadot <manu@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$
*/
#include <sys/types.h>
diff --git a/usr.sbin/quot/Makefile b/usr.sbin/quot/Makefile
index 3ec74b02ce5c..b18c37126448 100644
--- a/usr.sbin/quot/Makefile
+++ b/usr.sbin/quot/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= quot
MAN= quot.8
diff --git a/usr.sbin/quot/Makefile.depend b/usr.sbin/quot/Makefile.depend
index 6cfaab1c3644..910688a678fa 100644
--- a/usr.sbin/quot/Makefile.depend
+++ b/usr.sbin/quot/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/usr.sbin/quot/quot.8 b/usr.sbin/quot/quot.8
index 5451f63e15c5..81abe28b41d5 100644
--- a/usr.sbin/quot/quot.8
+++ b/usr.sbin/quot/quot.8
@@ -27,8 +27,6 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd February 8, 1994
.Dt QUOT 8
.Os
@@ -37,8 +35,8 @@
.Nd display disk space occupied by each user
.Sh SYNOPSIS
.Nm
-.Op Fl acfhknv
-.Op Ar filesystem ...
+.Op Fl cfhknv
+.Op Fl a | Ar filesystem ...
.Sh DESCRIPTION
The
.Nm
diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c
index fa1ee1c65fe7..7ca8110bef76 100644
--- a/usr.sbin/quot/quot.c
+++ b/usr.sbin/quot/quot.c
@@ -31,9 +31,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stdint.h>
#include <sys/mount.h>
@@ -529,9 +526,9 @@ static void
usage(void)
{
#ifdef COMPAT
- fprintf(stderr,"usage: quot [-nfcvha] [filesystem ...]\n");
+ fprintf(stderr, "usage: quot [-cfhnv] [-a | filesystem ...]\n");
#else /* COMPAT */
- fprintf(stderr,"usage: quot [-acfhknv] [filesystem ...]\n");
+ fprintf(stderr, "usage: quot [-cfhknv] [-a | filesystem ...]\n");
#endif /* COMPAT */
exit(1);
}
@@ -550,7 +547,7 @@ quot(char *name, char *mp)
close(fd);
return;
}
- switch (sbget(fd, &fs, STDSB)) {
+ switch (errno = sbget(fd, &fs, UFS_STDSB, UFS_NOCSUM)) {
case 0:
break;
case ENOENT:
@@ -567,8 +564,6 @@ quot(char *name, char *mp)
printf(" (%s)",mp);
putchar('\n');
(*func)(fd, fs, name);
- free(fs->fs_csp);
- free(fs->fs_si);
free(fs);
close(fd);
}
@@ -580,42 +575,47 @@ main(int argc, char *argv[])
struct statfs *mp;
struct fstab *fs;
int cnt;
+ int ch;
func = douser;
#ifndef COMPAT
header = getbsize(&headerlen,&blocksize);
#endif
- while (--argc > 0 && **++argv == '-') {
- while (*++*argv) {
- switch (**argv) {
- case 'n':
- func = donames;
- break;
- case 'c':
- func = dofsizes;
- break;
- case 'a':
- all = 1;
- break;
- case 'f':
- count = 1;
- break;
- case 'h':
- estimate = 1;
- break;
+ while ((ch = getopt(argc, argv, "acfhknv")) != -1) {
+ switch (ch) {
+ case 'a':
+ all = 1;
+ break;
+ case 'c':
+ func = dofsizes;
+ break;
+ case 'f':
+ count = 1;
+ break;
+ case 'h':
+ estimate = 1;
+ break;
#ifndef COMPAT
- case 'k':
- blocksize = 1024;
- break;
+ case 'k':
+ blocksize = 1024;
+ break;
#endif /* COMPAT */
- case 'v':
- unused = 1;
- break;
- default:
- usage();
- }
+ case 'n':
+ func = donames;
+ break;
+ case 'v':
+ unused = 1;
+ break;
+ default:
+ usage();
}
}
+ argc -= optind;
+ argv += optind;
+
+ if ((argc == 0 && !all) || (all && argc))
+ usage();
+
if (all) {
cnt = getmntinfo(&mp,MNT_NOWAIT);
for (; --cnt >= 0; mp++) {
diff --git a/usr.sbin/quotaon/Makefile b/usr.sbin/quotaon/Makefile
index ec3dc1ab7e15..41464cbf071b 100644
--- a/usr.sbin/quotaon/Makefile
+++ b/usr.sbin/quotaon/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= quotaon
LINKS= ${BINDIR}/quotaon ${BINDIR}/quotaoff
diff --git a/usr.sbin/quotaon/Makefile.depend b/usr.sbin/quotaon/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/quotaon/Makefile.depend
+++ b/usr.sbin/quotaon/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/quotaon/quotaon.8 b/usr.sbin/quotaon/quotaon.8
index 02c55e31f1c3..b2660690c017 100644
--- a/usr.sbin/quotaon/quotaon.8
+++ b/usr.sbin/quotaon/quotaon.8
@@ -27,9 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)quotaon.8 8.2 (Berkeley) 12/11/93
-.\" $FreeBSD$
-.\"
.Dd December 11, 1993
.Dt QUOTAON 8
.Os
diff --git a/usr.sbin/quotaon/quotaon.c b/usr.sbin/quotaon/quotaon.c
index f5340c6b44c5..724eb42fc358 100644
--- a/usr.sbin/quotaon/quotaon.c
+++ b/usr.sbin/quotaon/quotaon.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1990, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)quotaon.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Turn quota on/off for a filesystem.
*/
@@ -70,7 +56,7 @@ static int vflag; /* verbose */
static int oneof(char *, char *[], int);
static int quotaonoff(struct fstab *fs, int, int);
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char **argv)
diff --git a/usr.sbin/rarpd/Makefile b/usr.sbin/rarpd/Makefile
index b7816cddedd3..93974cd11613 100644
--- a/usr.sbin/rarpd/Makefile
+++ b/usr.sbin/rarpd/Makefile
@@ -1,5 +1,3 @@
-# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
-# $FreeBSD$
PROG= rarpd
MAN= rarpd.8
diff --git a/usr.sbin/rarpd/Makefile.depend b/usr.sbin/rarpd/Makefile.depend
index 4fc5be2a35f0..bbd6b7071809 100644
--- a/usr.sbin/rarpd/Makefile.depend
+++ b/usr.sbin/rarpd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/rarpd/rarpd.8 b/usr.sbin/rarpd/rarpd.8
index 4b00c9e7b83a..91326cb95927 100644
--- a/usr.sbin/rarpd/rarpd.8
+++ b/usr.sbin/rarpd/rarpd.8
@@ -14,8 +14,6 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.\" $FreeBSD$
-.\"
.Dd July 9, 2012
.Dt RARPD 8
.Os
diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c
index 441164dd2bd2..6281fbfd0c6b 100644
--- a/usr.sbin/rarpd/rarpd.c
+++ b/usr.sbin/rarpd/rarpd.c
@@ -16,16 +16,6 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1990, 1991, 1992, 1993, 1996\n\
-The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* rarpd - Reverse ARP Daemon
*
@@ -692,7 +682,7 @@ rarp_process(struct if_info *ii, u_char *pkt, u_int len)
}
/*
- * Poke the kernel arp tables with the ethernet/ip address combinataion
+ * Poke the kernel arp tables with the ethernet/ip address combination
* given. When processing a reply, we must do this so that the booting
* host (i.e. the guy running rarpd), won't try to ARP for the hardware
* address of the guy being booted (he cannot answer the ARP).
diff --git a/usr.sbin/repquota/Makefile b/usr.sbin/repquota/Makefile
index 78fd39832cf8..feb2a13410e2 100644
--- a/usr.sbin/repquota/Makefile
+++ b/usr.sbin/repquota/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= repquota
MAN= repquota.8
diff --git a/usr.sbin/repquota/Makefile.depend b/usr.sbin/repquota/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/repquota/Makefile.depend
+++ b/usr.sbin/repquota/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/repquota/repquota.8 b/usr.sbin/repquota/repquota.8
index 16a8417c1310..f999eeaa9385 100644
--- a/usr.sbin/repquota/repquota.8
+++ b/usr.sbin/repquota/repquota.8
@@ -28,9 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)repquota.8 8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
-.\"
.Dd June 6, 1993
.Dt REPQUOTA 8
.Os
diff --git a/usr.sbin/repquota/repquota.c b/usr.sbin/repquota/repquota.c
index 23abcca93752..e5ae7832f0a6 100644
--- a/usr.sbin/repquota/repquota.c
+++ b/usr.sbin/repquota/repquota.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1990, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)repquota.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Quota report
*/
@@ -104,7 +90,7 @@ int oneof(char *, char *[], int);
int repquota(struct fstab *, int);
char *timeprt(time_t);
static void prthumanval(int64_t bytes);
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char *argv[])
diff --git a/usr.sbin/rip6query/Makefile b/usr.sbin/rip6query/Makefile
index d33621dae174..7f954ca55674 100644
--- a/usr.sbin/rip6query/Makefile
+++ b/usr.sbin/rip6query/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
PROG= rip6query
MAN= rip6query.8
diff --git a/usr.sbin/rip6query/Makefile.depend b/usr.sbin/rip6query/Makefile.depend
index d5ed563ecfc8..344a5d0e9310 100644
--- a/usr.sbin/rip6query/Makefile.depend
+++ b/usr.sbin/rip6query/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/rip6query/rip6query.8 b/usr.sbin/rip6query/rip6query.8
index 9bcd4a508e38..856a59138bc1 100644
--- a/usr.sbin/rip6query/rip6query.8
+++ b/usr.sbin/rip6query/rip6query.8
@@ -28,7 +28,6 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: rip6query.8,v 1.2 2000/01/19 06:24:55 itojun Exp $
-.\" $FreeBSD$
.\"
.Dd October 7, 1999
.Dt RIP6QUERY 8
diff --git a/usr.sbin/rip6query/rip6query.c b/usr.sbin/rip6query/rip6query.c
index b3d745965965..7d0f788ed7ef 100644
--- a/usr.sbin/rip6query/rip6query.c
+++ b/usr.sbin/rip6query/rip6query.c
@@ -29,8 +29,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 <stdio.h>
@@ -62,7 +60,7 @@ static struct rip6 *ripbuf;
#define RIPSIZE(n) (sizeof(struct rip6) + (n-1) * sizeof(struct netinfo6))
int main(int, char **);
-static void usage(void);
+static void usage(void) __dead2;
static const char *sa_n2a(struct sockaddr *);
static const char *inet6_n2a(struct in6_addr *);
@@ -90,7 +88,6 @@ main(int argc, char *argv[])
break;
default:
usage();
- exit(1);
/*NOTREACHED*/
}
}
@@ -99,7 +96,6 @@ main(int argc, char *argv[])
if (argc != 1) {
usage();
- exit(1);
}
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
@@ -168,13 +164,14 @@ main(int argc, char *argv[])
}
} while (len == RIPSIZE(24));
- exit(0);
+ return 0;
}
static void
usage(void)
{
fprintf(stderr, "usage: rip6query [-I iface] address\n");
+ exit(1);
}
/* getnameinfo() is preferred as we may be able to show ifindex as ifname */
diff --git a/usr.sbin/rmt/Makefile b/usr.sbin/rmt/Makefile
index 0cbc67c70880..6bd58fae3afd 100644
--- a/usr.sbin/rmt/Makefile
+++ b/usr.sbin/rmt/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= rmt
MAN= rmt.8
diff --git a/usr.sbin/rmt/Makefile.depend b/usr.sbin/rmt/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/rmt/Makefile.depend
+++ b/usr.sbin/rmt/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/rmt/rmt.8 b/usr.sbin/rmt/rmt.8
index 0baa453141b8..11bc7187889b 100644
--- a/usr.sbin/rmt/rmt.8
+++ b/usr.sbin/rmt/rmt.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)rmt.8 8.3 (Berkeley) 6/1/94
-.\" $FreeBSD$
-.\"
.Dd June 1, 1994
.Dt RMT 8
.Os
diff --git a/usr.sbin/rmt/rmt.c b/usr.sbin/rmt/rmt.c
index 308d41b14c64..3746a63810eb 100644
--- a/usr.sbin/rmt/rmt.c
+++ b/usr.sbin/rmt/rmt.c
@@ -29,20 +29,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)rmt.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* rmt
*/
diff --git a/usr.sbin/route6d/Makefile b/usr.sbin/route6d/Makefile
index df23d33aea57..03e54ad34e80 100644
--- a/usr.sbin/route6d/Makefile
+++ b/usr.sbin/route6d/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
PROG= route6d
MAN= route6d.8
diff --git a/usr.sbin/route6d/Makefile.depend b/usr.sbin/route6d/Makefile.depend
index d5ed563ecfc8..344a5d0e9310 100644
--- a/usr.sbin/route6d/Makefile.depend
+++ b/usr.sbin/route6d/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/route6d/misc/chkrt b/usr.sbin/route6d/misc/chkrt
index 6ae01f37be04..86e61b281140 100755
--- a/usr.sbin/route6d/misc/chkrt
+++ b/usr.sbin/route6d/misc/chkrt
@@ -1,6 +1,5 @@
#!/usr/bin/perl
#
-# $FreeBSD$
#
$dump="/var/tmp/route6d_dump";
$pidfile="/var/run/route6d.pid";
diff --git a/usr.sbin/route6d/misc/cksum.c b/usr.sbin/route6d/misc/cksum.c
index 200eecceef7d..b943018f851b 100644
--- a/usr.sbin/route6d/misc/cksum.c
+++ b/usr.sbin/route6d/misc/cksum.c
@@ -27,8 +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.
- *
- * $FreeBSD$
*/
#include <stdio.h>
diff --git a/usr.sbin/route6d/route6d.8 b/usr.sbin/route6d/route6d.8
index 2dfd91c53d4b..3a7bc8721923 100644
--- a/usr.sbin/route6d/route6d.8
+++ b/usr.sbin/route6d/route6d.8
@@ -14,8 +14,6 @@
.\" LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
.\" A PARTICULAR PURPOSE.
.\"
-.\" $FreeBSD$
-.\"
.Dd November 18, 2012
.Dt ROUTE6D 8
.Os
diff --git a/usr.sbin/route6d/route6d.c b/usr.sbin/route6d/route6d.c
index 7d873d4dfa40..17b985fac2c0 100644
--- a/usr.sbin/route6d/route6d.c
+++ b/usr.sbin/route6d/route6d.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: route6d.c,v 1.104 2003/10/31 00:30:20 itojun Exp $ */
/*-
@@ -32,9 +31,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char _rcsid[] = "$KAME: route6d.c,v 1.104 2003/10/31 00:30:20 itojun Exp $";
-#endif
#include <sys/param.h>
#include <sys/file.h>
@@ -101,7 +97,7 @@ struct ifc { /* Configuration of an interface */
};
static TAILQ_HEAD(, ifc) ifc_head = TAILQ_HEAD_INITIALIZER(ifc_head);
-struct ifac { /* Adddress associated to an interface */
+struct ifac { /* Address associated to an interface */
TAILQ_ENTRY(ifac) ifac_next;
struct ifc *ifac_ifc; /* back pointer */
@@ -1690,7 +1686,7 @@ ifremove(int ifindex)
/*
* Receive and process routing messages.
- * Update interface information as necesssary.
+ * Update interface information as necessary.
*/
static void
rtrecv(void)
diff --git a/usr.sbin/route6d/route6d.h b/usr.sbin/route6d/route6d.h
index d556799c7177..3193514ddeb3 100644
--- a/usr.sbin/route6d/route6d.h
+++ b/usr.sbin/route6d/route6d.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: route6d.h,v 1.8 2003/05/28 09:11:13 itojun Exp $ */
/*-
diff --git a/usr.sbin/rpc.lockd/Makefile b/usr.sbin/rpc.lockd/Makefile
index 71c68a2d0ced..2efb5eb4bc76 100644
--- a/usr.sbin/rpc.lockd/Makefile
+++ b/usr.sbin/rpc.lockd/Makefile
@@ -1,5 +1,4 @@
# $NetBSD: Makefile,v 1.12 2000/08/07 16:23:31 thorpej Exp $
-# $FreeBSD$
PACKAGE= nfs
diff --git a/usr.sbin/rpc.lockd/Makefile.depend b/usr.sbin/rpc.lockd/Makefile.depend
index 8939901b94fd..9e6ba57ca2bf 100644
--- a/usr.sbin/rpc.lockd/Makefile.depend
+++ b/usr.sbin/rpc.lockd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
diff --git a/usr.sbin/rpc.lockd/kern.c b/usr.sbin/rpc.lockd/kern.c
index 08566a5b4658..c24b81159ea5 100644
--- a/usr.sbin/rpc.lockd/kern.c
+++ b/usr.sbin/rpc.lockd/kern.c
@@ -30,9 +30,6 @@
* from BSDI kern.c,v 1.2 1998/11/25 22:38:27 don Exp
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/queue.h>
@@ -572,16 +569,11 @@ void
show(LOCKD_MSG *mp)
{
static char hex[] = "0123456789abcdef";
- struct fid *fidp;
- fsid_t *fsidp;
size_t len;
u_int8_t *p, *t, buf[NFS_SMALLFH*3+1];
syslog(LOG_DEBUG, "process ID: %lu\n", (long)mp->lm_msg_ident.pid);
- fsidp = (fsid_t *)&mp->lm_fh;
- fidp = (struct fid *)((u_int8_t *)&mp->lm_fh + sizeof(fsid_t));
-
for (t = buf, p = (u_int8_t *)mp->lm_fh,
len = mp->lm_fh_len;
len > 0; ++p, --len) {
diff --git a/usr.sbin/rpc.lockd/lock_proc.c b/usr.sbin/rpc.lockd/lock_proc.c
index 160e1844e5a8..b720be7dba69 100644
--- a/usr.sbin/rpc.lockd/lock_proc.c
+++ b/usr.sbin/rpc.lockd/lock_proc.c
@@ -1,5 +1,4 @@
/* $NetBSD: lock_proc.c,v 1.7 2000/10/11 20:23:56 is Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
*
@@ -999,7 +998,7 @@ nlm4_lock_4_svc(nlm4_lockargs *arg, struct svc_req *rqstp)
/* copy cookie from arg to result. See comment in nlm_test_4() */
res.cookie = arg->cookie;
- res.stat.stat = getlock(arg, rqstp, LOCK_MON | LOCK_V4);
+ res.stat.stat = (enum nlm4_stats)getlock(arg, rqstp, LOCK_MON | LOCK_V4);
return (&res);
}
@@ -1012,7 +1011,7 @@ nlm4_lock_msg_4_svc(nlm4_lockargs *arg, struct svc_req *rqstp)
log_from_addr("nlm4_lock_msg", rqstp);
res.cookie = arg->cookie;
- res.stat.stat = getlock(arg, rqstp, LOCK_MON | LOCK_ASYNC | LOCK_V4);
+ res.stat.stat = (enum nlm4_stats)getlock(arg, rqstp, LOCK_MON | LOCK_ASYNC | LOCK_V4);
transmit4_result(NLM4_LOCK_RES, &res, getrpcaddr(rqstp));
return (NULL);
@@ -1039,7 +1038,7 @@ nlm4_cancel_4_svc(nlm4_cancargs *arg, struct svc_req *rqstp)
* Since at present we never return 'nlm_blocked', there can never be
* a lock to cancel, so this call always fails.
*/
- res.stat.stat = unlock(&arg->alock, LOCK_CANCEL);
+ res.stat.stat = (enum nlm4_stats)unlock(&arg->alock, LOCK_CANCEL);
return (&res);
}
@@ -1056,7 +1055,7 @@ nlm4_cancel_msg_4_svc(nlm4_cancargs *arg, struct svc_req *rqstp)
* Since at present we never return 'nlm_blocked', there can never be
* a lock to cancel, so this call always fails.
*/
- res.stat.stat = unlock(&arg->alock, LOCK_CANCEL | LOCK_V4);
+ res.stat.stat = (enum nlm4_stats)unlock(&arg->alock, LOCK_CANCEL | LOCK_V4);
transmit4_result(NLM4_CANCEL_RES, &res, getrpcaddr(rqstp));
return (NULL);
}
@@ -1077,7 +1076,7 @@ nlm4_unlock_4_svc(nlm4_unlockargs *arg, struct svc_req *rqstp)
if (debug_level)
log_from_addr("nlm4_unlock", rqstp);
- res.stat.stat = unlock(&arg->alock, LOCK_V4);
+ res.stat.stat = (enum nlm4_stats)unlock(&arg->alock, LOCK_V4);
res.cookie = arg->cookie;
return (&res);
@@ -1091,7 +1090,7 @@ nlm4_unlock_msg_4_svc(nlm4_unlockargs *arg, struct svc_req *rqstp)
if (debug_level)
log_from_addr("nlm4_unlock_msg", rqstp);
- res.stat.stat = unlock(&arg->alock, LOCK_V4);
+ res.stat.stat = (enum nlm4_stats)unlock(&arg->alock, LOCK_V4);
res.cookie = arg->cookie;
transmit4_result(NLM4_UNLOCK_RES, &res, getrpcaddr(rqstp));
diff --git a/usr.sbin/rpc.lockd/lockd.c b/usr.sbin/rpc.lockd/lockd.c
index e25cef9993bb..7e0652d26533 100644
--- a/usr.sbin/rpc.lockd/lockd.c
+++ b/usr.sbin/rpc.lockd/lockd.c
@@ -1,5 +1,4 @@
/* $NetBSD: lockd.c,v 1.7 2000/08/12 18:08:44 thorpej Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -489,7 +488,7 @@ main(int argc, char **argv)
*
* It gets called one time for each transport.
*
- * It returns 0 upon success, 1 for ingore the call and -1 to indicate
+ * It returns 0 upon success, 1 for ignore the call and -1 to indicate
* bind failed with EADDRINUSE.
*
* Any file descriptors that have been created are stored in sock_fd and
@@ -845,7 +844,7 @@ sigalarm_handler(void)
}
void
-usage()
+usage(void)
{
errx(1, "usage: rpc.lockd [-d <debuglevel>]"
" [-F] [-g <grace period>] [-h <bindip>] [-p <port>]");
@@ -904,7 +903,8 @@ init_nsm(void)
/*
* Out of memory, fatal
*/
-void out_of_mem()
+void
+out_of_mem(void)
{
syslog(LOG_ERR, "out of memory");
exit(2);
diff --git a/usr.sbin/rpc.lockd/lockd.h b/usr.sbin/rpc.lockd/lockd.h
index 23cb19fd79c6..ae73c075e4bb 100644
--- a/usr.sbin/rpc.lockd/lockd.h
+++ b/usr.sbin/rpc.lockd/lockd.h
@@ -1,5 +1,4 @@
/* $NetBSD: lockd.h,v 1.2 2000/06/07 14:34:40 bouyer Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
diff --git a/usr.sbin/rpc.lockd/lockd_lock.c b/usr.sbin/rpc.lockd/lockd_lock.c
index 1fc4ce23597a..7ba948c5ca8e 100644
--- a/usr.sbin/rpc.lockd/lockd_lock.c
+++ b/usr.sbin/rpc.lockd/lockd_lock.c
@@ -37,8 +37,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define LOCKD_DEBUG
#include <stdio.h>
@@ -235,13 +233,9 @@ debuglog(char const *fmt, ...)
}
void
-dump_static_object(object, size_object, hbuff, size_hbuff, cbuff, size_cbuff)
- const unsigned char *object;
- const int size_object;
- unsigned char *hbuff;
- const int size_hbuff;
- unsigned char *cbuff;
- const int size_cbuff;
+dump_static_object(const unsigned char *object, const int size_object,
+ unsigned char *hbuff, const int size_hbuff, unsigned char *cbuff,
+ const int size_cbuff)
{
int i, objectsize;
@@ -358,10 +352,8 @@ dump_filelock(const struct file_lock *fl)
}
void
-copy_nlm4_lock_to_nlm4_holder(src, exclusive, dest)
- const struct nlm4_lock *src;
- const bool_t exclusive;
- struct nlm4_holder *dest;
+copy_nlm4_lock_to_nlm4_holder(const struct nlm4_lock *src,
+ const bool_t exclusive, struct nlm4_holder *dest)
{
dest->exclusive = exclusive;
@@ -465,8 +457,8 @@ deallocate_file_lock(struct file_lock *fl)
* overlap.
*/
int
-regions_overlap(start1, len1, start2, len2)
- const u_int64_t start1, len1, start2, len2;
+regions_overlap(const u_int64_t start1, const u_int64_t len1,
+ const u_int64_t start2, const u_int64_t len2)
{
u_int64_t d1,d2,d3,d4;
enum split_status result;
@@ -494,10 +486,9 @@ regions_overlap(start1, len1, start2, len2)
* XXX: This DESPERATELY needs a regression test.
*/
enum split_status
-region_compare(starte, lene, startu, lenu,
- start1, len1, start2, len2)
- const u_int64_t starte, lene, startu, lenu;
- u_int64_t *start1, *len1, *start2, *len2;
+region_compare(const u_int64_t starte, const u_int64_t lene,
+ const u_int64_t startu, const u_int64_t lenu, u_int64_t *start1,
+ u_int64_t *len1, u_int64_t *start2, u_int64_t *len2)
{
/*
* Please pay attention to the sequential exclusions
@@ -680,8 +671,7 @@ same_netobj(const netobj *n0, const netobj *n1)
* same_filelock_identity: Compares the appropriate bits of a file_lock
*/
int
-same_filelock_identity(fl0, fl1)
- const struct file_lock *fl0, *fl1;
+same_filelock_identity(const struct file_lock *fl0, const struct file_lock *fl1)
{
int retval;
@@ -767,7 +757,7 @@ get_lock_matching_unlock(const struct file_lock *fl)
* This routine makes the following assumptions:
* 1) Nothing will adjust the lock list during a lookup
*
- * This routine has an intersting quirk which bit me hard.
+ * This routine has an interesting quirk which bit me hard.
* The conflicting_fl is the pointer to the conflicting lock.
* However, to modify the "*pointer* to the conflicting lock" rather
* that the "conflicting lock itself" one must pass in a "pointer to
@@ -919,9 +909,9 @@ delete_nfslock(struct file_lock *fl)
}
enum split_status
-split_nfslock(exist_lock, unlock_lock, left_lock, right_lock)
- const struct file_lock *exist_lock, *unlock_lock;
- struct file_lock **left_lock, **right_lock;
+split_nfslock(const struct file_lock *exist_lock,
+ const struct file_lock *unlock_lock, struct file_lock **left_lock,
+ struct file_lock **right_lock)
{
u_int64_t start1, len1, start2, len2;
enum split_status spstatus;
@@ -965,11 +955,8 @@ split_nfslock(exist_lock, unlock_lock, left_lock, right_lock)
}
enum nfslock_status
-unlock_nfslock(fl, released_lock, left_lock, right_lock)
- const struct file_lock *fl;
- struct file_lock **released_lock;
- struct file_lock **left_lock;
- struct file_lock **right_lock;
+unlock_nfslock(const struct file_lock *fl, struct file_lock **released_lock,
+ struct file_lock **left_lock, struct file_lock **right_lock)
{
struct file_lock *mfl; /* Matching file lock */
enum nfslock_status retval;
@@ -1164,9 +1151,8 @@ unlock_hwlock(const struct file_lock *fl)
}
enum hwlock_status
-test_hwlock(fl, conflicting_fl)
- const struct file_lock *fl __unused;
- struct file_lock **conflicting_fl __unused;
+test_hwlock(const struct file_lock *fl __unused,
+ struct file_lock **conflicting_fl __unused)
{
/*
@@ -2176,9 +2162,7 @@ notify(const char *hostname, const int state)
}
void
-send_granted(fl, opcode)
- struct file_lock *fl;
- int opcode __unused;
+send_granted(struct file_lock *fl, int opcode __unused)
{
CLIENT *cli;
static char dummy;
diff --git a/usr.sbin/rpc.lockd/lockd_lock.h b/usr.sbin/rpc.lockd/lockd_lock.h
index 62f6981151ed..31f0913fd067 100644
--- a/usr.sbin/rpc.lockd/lockd_lock.h
+++ b/usr.sbin/rpc.lockd/lockd_lock.h
@@ -1,5 +1,4 @@
/* $NetBSD: lockd_lock.h,v 1.2 2000/06/09 14:00:54 fvdl Exp $ */
-/* $FreeBSD$ */
/* Headers and function declarations for file-locking utilities */
diff --git a/usr.sbin/rpc.lockd/rpc.lockd.8 b/usr.sbin/rpc.lockd/rpc.lockd.8
index 52d3675c5424..89f55087901d 100644
--- a/usr.sbin/rpc.lockd/rpc.lockd.8
+++ b/usr.sbin/rpc.lockd/rpc.lockd.8
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd November 21, 2019
.Dt RPC.LOCKD 8
.Os
diff --git a/usr.sbin/rpc.lockd/test.c b/usr.sbin/rpc.lockd/test.c
index a751e5c6f4e4..9a772cfefb2d 100644
--- a/usr.sbin/rpc.lockd/test.c
+++ b/usr.sbin/rpc.lockd/test.c
@@ -3,15 +3,6 @@
#include <sys/cdefs.h>
#include <rpc/rpc.h>
#include <rpcsvc/nlm_prot.h>
-#ifndef lint
-#if 0
-static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";
-static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";
-#else
-__RCSID("$NetBSD: test.c,v 1.2 1997/10/18 04:01:21 lukem Exp $");
-static const char rcsid[] = "$FreeBSD$";
-#endif
-#endif /* not lint */
/* Default timeout can be changed using clnt_control() */
static struct timeval TIMEOUT = { 0, 0 };
diff --git a/usr.sbin/rpc.statd/Makefile b/usr.sbin/rpc.statd/Makefile
index c857f62790dc..161eebe9dc78 100644
--- a/usr.sbin/rpc.statd/Makefile
+++ b/usr.sbin/rpc.statd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= rpc.statd
MAN= rpc.statd.8
diff --git a/usr.sbin/rpc.statd/Makefile.depend b/usr.sbin/rpc.statd/Makefile.depend
index 572fc8dbf41a..210baeaabfd6 100644
--- a/usr.sbin/rpc.statd/Makefile.depend
+++ b/usr.sbin/rpc.statd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
diff --git a/usr.sbin/rpc.statd/file.c b/usr.sbin/rpc.statd/file.c
index d4fd3eda8882..cdfd46d718ff 100644
--- a/usr.sbin/rpc.statd/file.c
+++ b/usr.sbin/rpc.statd/file.c
@@ -31,8 +31,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#include <err.h>
diff --git a/usr.sbin/rpc.statd/procs.c b/usr.sbin/rpc.statd/procs.c
index 3f1b60bd3f22..70fb52e32452 100644
--- a/usr.sbin/rpc.statd/procs.c
+++ b/usr.sbin/rpc.statd/procs.c
@@ -34,8 +34,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.sbin/rpc.statd/rpc.statd.8 b/usr.sbin/rpc.statd/rpc.statd.8
index a4a143f19e2a..6c1a421e31de 100644
--- a/usr.sbin/rpc.statd/rpc.statd.8
+++ b/usr.sbin/rpc.statd/rpc.statd.8
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd November 21, 2019
.Dt RPC.STATD 8
.Os
diff --git a/usr.sbin/rpc.statd/statd.c b/usr.sbin/rpc.statd/statd.c
index ecd31b8ddf68..c71270181999 100644
--- a/usr.sbin/rpc.statd/statd.c
+++ b/usr.sbin/rpc.statd/statd.c
@@ -38,8 +38,6 @@
/* The actual program logic is in the file procs.c */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <errno.h>
#include <stdio.h>
@@ -319,7 +317,7 @@ main(int argc, char **argv)
/*
* This routine creates and binds sockets on the appropriate
* addresses. It gets called one time for each transport.
- * It returns 0 upon success, 1 for ingore the call and -1 to indicate
+ * It returns 0 upon success, 1 for ignore the call and -1 to indicate
* bind failed with EADDRINUSE.
* Any file descriptors that have been created are stored in sock_fd and
* the total count of them is maintained in sock_fdcnt.
diff --git a/usr.sbin/rpc.statd/statd.h b/usr.sbin/rpc.statd/statd.h
index ede159039ada..b61e27123396 100644
--- a/usr.sbin/rpc.statd/statd.h
+++ b/usr.sbin/rpc.statd/statd.h
@@ -30,8 +30,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$
*/
diff --git a/usr.sbin/rpc.statd/test.c b/usr.sbin/rpc.statd/test.c
index c3b342441781..2f18a159ba2d 100644
--- a/usr.sbin/rpc.statd/test.c
+++ b/usr.sbin/rpc.statd/test.c
@@ -1,8 +1,3 @@
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/rpc.tlsclntd/Makefile b/usr.sbin/rpc.tlsclntd/Makefile
index 1c8481a7889c..2dbde13463ca 100644
--- a/usr.sbin/rpc.tlsclntd/Makefile
+++ b/usr.sbin/rpc.tlsclntd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.8 b/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.8
index d8e2d1cd140b..5e6f93318ec2 100644
--- a/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.8
+++ b/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.8
@@ -23,10 +23,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.\" Modified from gssd.8 for rpc.tlsclntd.8 by Rick Macklem.
-.Dd May 22, 2022
+.Dd September 23, 2022
.Dt RPC.TLSCLNTD 8
.Os
.Sh NAME
@@ -203,7 +201,7 @@ option has also been specified.
.Sh STANDARDS
The implementation is based on the specification in
.Rs
-.%B "RFC NNNN"
+.%B "RFC 9289"
.%T "Towards Remote Procedure Call Encryption By Default"
.Re
.Sh HISTORY
diff --git a/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c b/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c
index 841c0b4e3114..9c50e4b48cb7 100644
--- a/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c
+++ b/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Isilon Inc http://www.isilon.com/
* Authors: Doug Rabson <dfr@rabson.org>
@@ -32,9 +32,6 @@
* the client side of kernel RPC-over-TLS by Rick Macklem.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/types.h>
#include <sys/queue.h>
@@ -285,14 +282,20 @@ main(int argc, char **argv)
err(1, "Can't register service for local rpctlscd socket");
}
- rpctls_syscall(RPCTLS_SYSC_CLSETPATH, _PATH_RPCTLSCDSOCK);
+ if (rpctls_syscall(RPCTLS_SYSC_CLSETPATH, _PATH_RPCTLSCDSOCK) < 0) {
+ if (rpctls_debug_level == 0) {
+ syslog(LOG_ERR,
+ "Can't set upcall socket path errno=%d", errno);
+ exit(1);
+ }
+ err(1, "Can't set upcall socket path");
+ }
rpctls_svc_run();
rpctls_syscall(RPCTLS_SYSC_CLSHUTDOWN, "");
SSL_CTX_free(rpctls_ctx);
- EVP_cleanup();
return (0);
}
@@ -473,17 +476,12 @@ rpctls_setupcl_ssl(void)
size_t len, rlen;
int ret;
- SSL_library_init();
- SSL_load_error_strings();
- OpenSSL_add_all_algorithms();
-
ctx = SSL_CTX_new(TLS_client_method());
if (ctx == NULL) {
rpctls_verbose_out("rpctls_setupcl_ssl: SSL_CTX_new "
"failed\n");
return (NULL);
}
- SSL_CTX_set_ecdh_auto(ctx, 1);
if (rpctls_ciphers != NULL) {
/*
@@ -673,13 +671,17 @@ rpctls_connect(SSL_CTX *ctx, int s, char *certname, u_int certlen, X509 **certp)
ret = SSL_connect(ssl);
if (ret != 1) {
rpctls_verbose_out("rpctls_connect: "
- "SSL_connect failed %d\n",
- ret);
+ "SSL_connect failed %d: %s\n",
+ ret, ERR_error_string(ERR_get_error(), NULL));
SSL_free(ssl);
return (NULL);
}
+#if OPENSSL_VERSION_NUMBER >= 0x30000000
+ cert = SSL_get1_peer_certificate(ssl);
+#else
cert = SSL_get_peer_certificate(ssl);
+#endif
if (cert == NULL) {
rpctls_verbose_out("rpctls_connect: get peer"
" certificate failed\n");
diff --git a/usr.sbin/rpc.tlsservd/Makefile b/usr.sbin/rpc.tlsservd/Makefile
index 4424c38a8502..fb73d2edf7a0 100644
--- a/usr.sbin/rpc.tlsservd/Makefile
+++ b/usr.sbin/rpc.tlsservd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/rpc.tlsservd/rpc.tlscommon.c b/usr.sbin/rpc.tlsservd/rpc.tlscommon.c
index f5b88ffd0166..5bf7f86fba23 100644
--- a/usr.sbin/rpc.tlsservd/rpc.tlscommon.c
+++ b/usr.sbin/rpc.tlsservd/rpc.tlscommon.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021 Rick Macklem
*
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/queue.h>
#include <sys/syslog.h>
#include <sys/select.h>
diff --git a/usr.sbin/rpc.tlsservd/rpc.tlscommon.h b/usr.sbin/rpc.tlsservd/rpc.tlscommon.h
index ad7147339d51..8ca9f45c2428 100644
--- a/usr.sbin/rpc.tlsservd/rpc.tlscommon.h
+++ b/usr.sbin/rpc.tlsservd/rpc.tlscommon.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021 Rick Macklem
*
@@ -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$
*/
/*
diff --git a/usr.sbin/rpc.tlsservd/rpc.tlsservd.8 b/usr.sbin/rpc.tlsservd/rpc.tlsservd.8
index cfba53536b7d..6b604c9136b9 100644
--- a/usr.sbin/rpc.tlsservd/rpc.tlsservd.8
+++ b/usr.sbin/rpc.tlsservd/rpc.tlsservd.8
@@ -23,10 +23,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.\" Modified from gssd.8 for rpc.tlsservd.8 by Rick Macklem.
-.Dd May 22, 2022
+.Dd November 10, 2022
.Dt RPC.TLSSERVD 8
.Os
.Sh NAME
@@ -41,6 +39,7 @@
.Op Fl h
.Op Fl l Ar CAfile
.Op Fl m
+.Op Fl N Ar num_servers
.Op Fl n Ar domain
.Op Fl p Ar CApath
.Op Fl r Ar CRLfile
@@ -237,6 +236,16 @@ may be used to require a client to provide a certificate
that verifies.
See
.Xr exports 5 .
+.It Fl N Ar num_servers , Fl Fl numdaemons= Ns Ar num_servers
+For a server with a large number of NFS-over-TLS client mounts,
+this daemon might get overloaded after a reboot, when many
+clients attempt to do a TLS handshake at the same time.
+This option may be used to specify that
+.Dq num_servers
+daemons are to be run instead of a single daemon.
+When this is done, the TLS handshakes are spread across the
+.Dq num_servers
+daemons in a round robin fashion to spread out the load.
.It Fl n Ar domain , Fl Fl domain= Ns Ar domain
This option specifies what the
.Dq domain
@@ -303,7 +312,7 @@ and either the
or
.Fl p
options.
-Use of this option might not conform to RFC-NNNN, which does
+Use of this option might not conform to RFC-9289, which does
not allow certificates to be used for user authentication.
.It Fl v , Fl Fl verbose
Run in verbose mode.
@@ -361,7 +370,7 @@ options is allowed.
.Sh STANDARDS
The implementation is based on the specification in
.Rs
-.%B "RFC NNNN"
+.%B "RFC 9289"
.%T "Towards Remote Procedure Call Encryption By Default"
.Re
.Sh HISTORY
diff --git a/usr.sbin/rpc.tlsservd/rpc.tlsservd.c b/usr.sbin/rpc.tlsservd/rpc.tlsservd.c
index 8c364584a76c..00ea407551f5 100644
--- a/usr.sbin/rpc.tlsservd/rpc.tlsservd.c
+++ b/usr.sbin/rpc.tlsservd/rpc.tlsservd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Isilon Inc http://www.isilon.com/
* Authors: Doug Rabson <dfr@rabson.org>
@@ -32,9 +32,6 @@
* the server side of kernel RPC-over-TLS by Rick Macklem.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/types.h>
#include <sys/linker.h>
@@ -44,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/time.h>
+#include <sys/wait.h>
#include <err.h>
#include <getopt.h>
#include <libutil.h>
@@ -106,8 +104,12 @@ static char *rpctls_dnsname;
static const char *rpctls_cnuseroid = "1.3.6.1.4.1.2238.1.1.1";
static const char *rpctls_ciphers = NULL;
static int rpctls_mintls = TLS1_3_VERSION;
+static int rpctls_procs = 1;
+static char *rpctls_sockname[RPCTLS_SRV_MAXNPROCS];
+static pid_t rpctls_workers[RPCTLS_SRV_MAXNPROCS - 1];
+static bool rpctls_im_a_worker = false;
-static void rpctlssd_terminate(int);
+static void rpctls_cleanup_term(int sig);
static SSL_CTX *rpctls_setup_ssl(const char *certdir);
static SSL *rpctls_server(SSL_CTX *ctx, int s,
uint32_t *flags, uint32_t *uidp,
@@ -127,6 +129,7 @@ static struct option longopts[] = {
{ "checkhost", no_argument, NULL, 'h' },
{ "verifylocs", required_argument, NULL, 'l' },
{ "mutualverf", no_argument, NULL, 'm' },
+ { "numdaemons", required_argument, NULL, 'N' },
{ "domain", required_argument, NULL, 'n' },
{ "verifydir", required_argument, NULL, 'p' },
{ "crl", required_argument, NULL, 'r' },
@@ -146,7 +149,7 @@ main(int argc, char **argv)
* TLS handshake.
*/
struct sockaddr_un sun;
- int ch, fd, oldmask;
+ int ch, fd, i, mypos, oldmask;
SVCXPRT *xprt;
struct timeval tm;
struct timezone tz;
@@ -154,6 +157,7 @@ main(int argc, char **argv)
pid_t otherpid;
bool tls_enable;
size_t tls_enable_len;
+ sigset_t signew;
/* Check that another rpctlssd isn't already running. */
rpctls_pfh = pidfile_open(_PATH_RPCTLSSDPID, 0600, &otherpid);
@@ -181,8 +185,15 @@ main(int argc, char **argv)
rpctls_dnsname = hostname;
}
+ /* Initialize socket names. */
+ for (i = 0; i < RPCTLS_SRV_MAXNPROCS; i++) {
+ asprintf(&rpctls_sockname[i], "%s.%d", _PATH_RPCTLSSDSOCK, i);
+ if (rpctls_sockname[i] == NULL)
+ errx(1, "Cannot malloc socknames");
+ }
+
rpctls_verbose = false;
- while ((ch = getopt_long(argc, argv, "2C:D:dhl:n:mp:r:uvWw", longopts,
+ while ((ch = getopt_long(argc, argv, "2C:D:dhl:N:n:mp:r:uvWw", longopts,
NULL)) != -1) {
switch (ch) {
case '2':
@@ -206,6 +217,13 @@ main(int argc, char **argv)
case 'm':
rpctls_do_mutual = true;
break;
+ case 'N':
+ rpctls_procs = atoi(optarg);
+ if (rpctls_procs < 1 ||
+ rpctls_procs > RPCTLS_SRV_MAXNPROCS)
+ errx(1, "numdaemons/-N must be between 1 and "
+ "%d", RPCTLS_SRV_MAXNPROCS);
+ break;
case 'n':
hostname[0] = '@';
strlcpy(&hostname[1], optarg, MAXHOSTNAMELEN + 1);
@@ -242,6 +260,7 @@ main(int argc, char **argv)
"[-D/--certdir certdir] [-d/--debuglevel] "
"[-h/--checkhost] "
"[-l/--verifylocs CAfile] [-m/--mutualverf] "
+ "[-N/--numdaemons num] "
"[-n/--domain domain_name] "
"[-p/--verifydir CApath] [-r/--crl CRLfile] "
"[-u/--certuser] [-v/--verbose] [-W/--multiwild] "
@@ -271,23 +290,60 @@ main(int argc, char **argv)
errx(1, "Kernel RPC is not available");
}
+ for (i = 0; i < rpctls_procs - 1; i++)
+ rpctls_workers[i] = -1;
+ mypos = 0;
+
if (rpctls_debug_level == 0) {
+ /*
+ * Temporarily block SIGTERM and SIGCHLD, so workers[] can't
+ * end up bogus.
+ */
+ sigemptyset(&signew);
+ sigaddset(&signew, SIGTERM);
+ sigaddset(&signew, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &signew, NULL);
+
if (daemon(0, 0) != 0)
err(1, "Can't daemonize");
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
- signal(SIGHUP, SIG_IGN);
}
- signal(SIGTERM, rpctlssd_terminate);
signal(SIGPIPE, SIG_IGN);
signal(SIGHUP, rpctls_huphandler);
+ signal(SIGTERM, rpctls_cleanup_term);
+ signal(SIGCHLD, rpctls_cleanup_term);
pidfile_write(rpctls_pfh);
+ rpctls_syscall(RPCTLS_SYSC_SRVSTARTUP, "");
+
+ if (rpctls_debug_level == 0) {
+ /* Fork off the worker daemons. */
+ for (i = 0; i < rpctls_procs - 1; i++) {
+ rpctls_workers[i] = fork();
+ if (rpctls_workers[i] == 0) {
+ rpctls_im_a_worker = true;
+ mypos = i + 1;
+ setproctitle("server");
+ break;
+ } else if (rpctls_workers[i] < 0) {
+ syslog(LOG_ERR, "fork: %m");
+ }
+ }
+
+ if (!rpctls_im_a_worker && rpctls_procs > 1)
+ setproctitle("master");
+ }
+ sigemptyset(&signew);
+ sigaddset(&signew, SIGTERM);
+ sigaddset(&signew, SIGCHLD);
+ sigprocmask(SIG_UNBLOCK, &signew, NULL);
+
memset(&sun, 0, sizeof sun);
sun.sun_family = AF_LOCAL;
- unlink(_PATH_RPCTLSSDSOCK);
- strcpy(sun.sun_path, _PATH_RPCTLSSDSOCK);
+ unlink(rpctls_sockname[mypos]);
+ strcpy(sun.sun_path, rpctls_sockname[mypos]);
sun.sun_len = SUN_LEN(&sun);
fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (fd < 0) {
@@ -343,14 +399,20 @@ main(int argc, char **argv)
rpctls_gothup = false;
LIST_INIT(&rpctls_ssllist);
- rpctls_syscall(RPCTLS_SYSC_SRVSETPATH, _PATH_RPCTLSSDSOCK);
+ if (rpctls_syscall(RPCTLS_SYSC_SRVSETPATH, rpctls_sockname[mypos]) < 0){
+ if (rpctls_debug_level == 0) {
+ syslog(LOG_ERR,
+ "Can't set upcall socket path=%s errno=%d",
+ rpctls_sockname[mypos], errno);
+ exit(1);
+ }
+ err(1, "Can't set upcall socket path=%s",
+ rpctls_sockname[mypos]);
+ }
rpctls_svc_run();
- rpctls_syscall(RPCTLS_SYSC_SRVSHUTDOWN, "");
-
SSL_CTX_free(rpctls_ctx);
- EVP_cleanup();
return (0);
}
@@ -529,16 +591,43 @@ rpctlssd_1_freeresult(__unused SVCXPRT *transp, xdrproc_t xdr_result,
return (TRUE);
}
+/*
+ * cleanup_term() called via SIGTERM (or SIGCHLD if a child dies).
+ */
static void
-rpctlssd_terminate(int sig __unused)
+rpctls_cleanup_term(int sig)
{
struct ssl_entry *slp;
+ int i, cnt;
+
+ if (rpctls_im_a_worker && sig == SIGCHLD)
+ return;
+ LIST_FOREACH(slp, &rpctls_ssllist, next)
+ shutdown(slp->s, SHUT_RD);
+ SSL_CTX_free(rpctls_ctx);
+ EVP_cleanup();
+
+ if (rpctls_im_a_worker)
+ exit(0);
+
+ /* I'm the server, so terminate the workers. */
+ cnt = 0;
+ for (i = 0; i < rpctls_procs - 1; i++) {
+ if (rpctls_workers[i] != -1) {
+ cnt++;
+ kill(rpctls_workers[i], SIGTERM);
+ }
+ }
+
+ /*
+ * Wait for them to die.
+ */
+ for (i = 0; i < cnt; i++)
+ wait3(NULL, 0, NULL);
rpctls_syscall(RPCTLS_SYSC_SRVSHUTDOWN, "");
pidfile_remove(rpctls_pfh);
- LIST_FOREACH(slp, &rpctls_ssllist, next)
- shutdown(slp->s, SHUT_RD);
exit(0);
}
@@ -559,16 +648,11 @@ rpctls_setup_ssl(const char *certdir)
size_t len, rlen;
int ret;
- SSL_library_init();
- SSL_load_error_strings();
- OpenSSL_add_all_algorithms();
-
ctx = SSL_CTX_new(TLS_server_method());
if (ctx == NULL) {
rpctls_verbose_out("rpctls_setup_ssl: SSL_CTX_new failed\n");
return (NULL);
}
- SSL_CTX_set_ecdh_auto(ctx, 1);
if (rpctls_ciphers != NULL) {
/*
@@ -718,7 +802,11 @@ rpctls_server(SSL_CTX *ctx, int s, uint32_t *flags, uint32_t *uidp,
SSL_get_cipher(ssl));
}
if (rpctls_do_mutual) {
+#if OPENSSL_VERSION_NUMBER >= 0x30000000
+ cert = SSL_get1_peer_certificate(ssl);
+#else
cert = SSL_get_peer_certificate(ssl);
+#endif
if (cert != NULL) {
if (!rpctls_verbose) {
gethostret = rpctls_gethost(s, sad, hostnam,
diff --git a/usr.sbin/rpc.umntall/Makefile b/usr.sbin/rpc.umntall/Makefile
index c44441a6de1a..a8cd0b478729 100644
--- a/usr.sbin/rpc.umntall/Makefile
+++ b/usr.sbin/rpc.umntall/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.4 (Berkeley) 6/22/95
-# $FreeBSD$
PACKAGE= nfs
diff --git a/usr.sbin/rpc.umntall/Makefile.depend b/usr.sbin/rpc.umntall/Makefile.depend
index 85338ebe3beb..a2d89550fa2b 100644
--- a/usr.sbin/rpc.umntall/Makefile.depend
+++ b/usr.sbin/rpc.umntall/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/rpc \
include/rpcsvc \
diff --git a/usr.sbin/rpc.umntall/mounttab.c b/usr.sbin/rpc.umntall/mounttab.c
index a0e0d7fb81e6..0043d4302e59 100644
--- a/usr.sbin/rpc.umntall/mounttab.c
+++ b/usr.sbin/rpc.umntall/mounttab.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Martin Blapp
* All rights reserved.
@@ -28,8 +28,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/syslog.h>
#include <rpc/rpc.h>
diff --git a/usr.sbin/rpc.umntall/mounttab.h b/usr.sbin/rpc.umntall/mounttab.h
index 904f2ec79b28..e576978ba7bd 100644
--- a/usr.sbin/rpc.umntall/mounttab.h
+++ b/usr.sbin/rpc.umntall/mounttab.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Martin Blapp
* 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$
*/
#define STRSIZ (MNTNAMLEN+MNTPATHLEN+100)
diff --git a/usr.sbin/rpc.umntall/rpc.umntall.8 b/usr.sbin/rpc.umntall/rpc.umntall.8
index 1f7607f9b7f6..73b4e9094e3f 100644
--- a/usr.sbin/rpc.umntall/rpc.umntall.8
+++ b/usr.sbin/rpc.umntall/rpc.umntall.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd November 17, 1999
.Dt RPC.UMNTALL 8
.Os
diff --git a/usr.sbin/rpc.umntall/rpc.umntall.c b/usr.sbin/rpc.umntall/rpc.umntall.c
index 74df093e6d18..b5f0413c0857 100644
--- a/usr.sbin/rpc.umntall/rpc.umntall.c
+++ b/usr.sbin/rpc.umntall/rpc.umntall.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 Martin Blapp
* All rights reserved.
@@ -27,11 +27,6 @@
*
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
@@ -261,7 +256,8 @@ xdr_dir(XDR *xdrsp, char *dirp) {
}
static void
-usage() {
+usage(void)
+{
(void)fprintf(stderr, "%s\n",
"usage: rpc.umntall [-kv] [-e expire] [-h host] [-p path]");
exit(1);
diff --git a/usr.sbin/rpc.yppasswdd/Makefile b/usr.sbin/rpc.yppasswdd/Makefile
index b31b34f4db3a..4b539f66fa81 100644
--- a/usr.sbin/rpc.yppasswdd/Makefile
+++ b/usr.sbin/rpc.yppasswdd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
RPCDIR= ${DESTDIR}/usr/include/rpcsvc
diff --git a/usr.sbin/rpc.yppasswdd/Makefile.depend b/usr.sbin/rpc.yppasswdd/Makefile.depend
index f4474e3dffda..4cca22d28d6c 100644
--- a/usr.sbin/rpc.yppasswdd/Makefile.depend
+++ b/usr.sbin/rpc.yppasswdd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
diff --git a/usr.sbin/rpc.yppasswdd/rpc.yppasswdd.8 b/usr.sbin/rpc.yppasswdd/rpc.yppasswdd.8
index 3d0b48664ba6..dca48b41ebaf 100644
--- a/usr.sbin/rpc.yppasswdd/rpc.yppasswdd.8
+++ b/usr.sbin/rpc.yppasswdd/rpc.yppasswdd.8
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd February 8, 1996
.Dt RPC.YPPASSWDD 8
.Os
diff --git a/usr.sbin/rpc.yppasswdd/yppasswd_private.x b/usr.sbin/rpc.yppasswdd/yppasswd_private.x
index a1d6be51f369..d1e32f8819b5 100644
--- a/usr.sbin/rpc.yppasswdd/yppasswd_private.x
+++ b/usr.sbin/rpc.yppasswdd/yppasswd_private.x
@@ -32,7 +32,6 @@
#ifndef RPC_HDR
%#include <sys/cdefs.h>
-%__FBSDID("$FreeBSD$");
#endif
#ifdef RPC_HDR
diff --git a/usr.sbin/rpc.yppasswdd/yppasswdd_extern.h b/usr.sbin/rpc.yppasswdd/yppasswdd_extern.h
index 563d47c2205f..37df03067a5e 100644
--- a/usr.sbin/rpc.yppasswdd/yppasswdd_extern.h
+++ b/usr.sbin/rpc.yppasswdd/yppasswdd_extern.h
@@ -30,8 +30,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 _YPPASSWDD_EXTERN_H
diff --git a/usr.sbin/rpc.yppasswdd/yppasswdd_main.c b/usr.sbin/rpc.yppasswdd/yppasswdd_main.c
index b48ba40aeeca..54e5cbd060cf 100644
--- a/usr.sbin/rpc.yppasswdd/yppasswdd_main.c
+++ b/usr.sbin/rpc.yppasswdd/yppasswdd_main.c
@@ -32,9 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
diff --git a/usr.sbin/rpc.yppasswdd/yppasswdd_server.c b/usr.sbin/rpc.yppasswdd/yppasswdd_server.c
index 56c8defc3ba7..e42c941b7bff 100644
--- a/usr.sbin/rpc.yppasswdd/yppasswdd_server.c
+++ b/usr.sbin/rpc.yppasswdd/yppasswdd_server.c
@@ -32,9 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/fcntl.h>
#include <sys/socket.h>
@@ -135,8 +132,6 @@ copy_yp_pass(char *p, int x, int m)
yp_password.pw_fields |= _PWF_DIR;
EXPAND(yp_password.pw_shell);
yp_password.pw_fields |= _PWF_SHELL;
-
- return;
}
static int
diff --git a/usr.sbin/rpc.yppasswdd/yppwupdate b/usr.sbin/rpc.yppasswdd/yppwupdate
index a9db8f7e5b6c..c0587ada7f1d 100644
--- a/usr.sbin/rpc.yppasswdd/yppwupdate
+++ b/usr.sbin/rpc.yppasswdd/yppwupdate
@@ -8,7 +8,6 @@
#
# Comment out the LOG=yes line to disable logging.
#
-# $FreeBSD$
#
PATH=/bin:/usr/bin; export PATH
diff --git a/usr.sbin/rpc.ypupdated/Makefile b/usr.sbin/rpc.ypupdated/Makefile
index 1f34a28914d7..1c35f377002b 100644
--- a/usr.sbin/rpc.ypupdated/Makefile
+++ b/usr.sbin/rpc.ypupdated/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/usr.sbin/ypserv ${SRCTOP}/libexec/ypxfr
diff --git a/usr.sbin/rpc.ypupdated/Makefile.depend b/usr.sbin/rpc.ypupdated/Makefile.depend
index 5b0587ae477a..352a225b19c6 100644
--- a/usr.sbin/rpc.ypupdated/Makefile.depend
+++ b/usr.sbin/rpc.ypupdated/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/rpc \
include/rpcsvc \
diff --git a/usr.sbin/rpc.ypupdated/update.c b/usr.sbin/rpc.ypupdated/update.c
index f3d54b833d2f..332ed752acc4 100644
--- a/usr.sbin/rpc.ypupdated/update.c
+++ b/usr.sbin/rpc.ypupdated/update.c
@@ -28,14 +28,6 @@
* Mountain View, California 94043
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)update.c 1.2 91/03/11 Copyr 1986 Sun Micro";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
/*
* Copyright (C) 1986, 1989, Sun Microsystems, Inc.
*/
diff --git a/usr.sbin/rpc.ypupdated/yp_dbdelete.c b/usr.sbin/rpc.ypupdated/yp_dbdelete.c
index 7ef145867391..d07a8fcd2ff9 100644
--- a/usr.sbin/rpc.ypupdated/yp_dbdelete.c
+++ b/usr.sbin/rpc.ypupdated/yp_dbdelete.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
diff --git a/usr.sbin/rpc.ypupdated/yp_dbupdate.c b/usr.sbin/rpc.ypupdated/yp_dbupdate.c
index d4cfc7ac0353..af17bf5244ef 100644
--- a/usr.sbin/rpc.ypupdated/yp_dbupdate.c
+++ b/usr.sbin/rpc.ypupdated/yp_dbupdate.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/fcntl.h>
#include <stdint.h>
diff --git a/usr.sbin/rpc.ypupdated/ypupdate b/usr.sbin/rpc.ypupdated/ypupdate
index 4a26f4b6d72b..8795ef3baf80 100755
--- a/usr.sbin/rpc.ypupdated/ypupdate
+++ b/usr.sbin/rpc.ypupdated/ypupdate
@@ -8,7 +8,6 @@
#
# Comment out the LOG=yes line to disable logging.
#
-# $FreeBSD$
#
LOG=yes
diff --git a/usr.sbin/rpc.ypupdated/ypupdated_extern.h b/usr.sbin/rpc.ypupdated/ypupdated_extern.h
index 2cacb9511e1f..90968df36748 100644
--- a/usr.sbin/rpc.ypupdated/ypupdated_extern.h
+++ b/usr.sbin/rpc.ypupdated/ypupdated_extern.h
@@ -1,5 +1,4 @@
/*
- * $FreeBSD$
*/
#include <db.h>
diff --git a/usr.sbin/rpc.ypupdated/ypupdated_main.c b/usr.sbin/rpc.ypupdated/ypupdated_main.c
index 4d826afa4e63..dae956594da0 100644
--- a/usr.sbin/rpc.ypupdated/ypupdated_main.c
+++ b/usr.sbin/rpc.ypupdated/ypupdated_main.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "ypupdate_prot.h"
#include <stdio.h>
#include <stdlib.h> /* getenv, exit */
diff --git a/usr.sbin/rpc.ypupdated/ypupdated_server.c b/usr.sbin/rpc.ypupdated/ypupdated_server.c
index 67fa05eceee5..47e52401cd6e 100644
--- a/usr.sbin/rpc.ypupdated/ypupdated_server.c
+++ b/usr.sbin/rpc.ypupdated/ypupdated_server.c
@@ -39,8 +39,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <rpc/rpc.h>
#include <rpc/key_prot.h>
diff --git a/usr.sbin/rpc.ypxfrd/Makefile b/usr.sbin/rpc.ypxfrd/Makefile
index d07ee6d5c70c..a761275b6377 100644
--- a/usr.sbin/rpc.ypxfrd/Makefile
+++ b/usr.sbin/rpc.ypxfrd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/usr.sbin/ypserv
diff --git a/usr.sbin/rpc.ypxfrd/Makefile.depend b/usr.sbin/rpc.ypxfrd/Makefile.depend
index 572fc8dbf41a..210baeaabfd6 100644
--- a/usr.sbin/rpc.ypxfrd/Makefile.depend
+++ b/usr.sbin/rpc.ypxfrd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
diff --git a/usr.sbin/rpc.ypxfrd/rpc.ypxfrd.8 b/usr.sbin/rpc.ypxfrd/rpc.ypxfrd.8
index 5a7f8dab24b9..7b2573421159 100644
--- a/usr.sbin/rpc.ypxfrd/rpc.ypxfrd.8
+++ b/usr.sbin/rpc.ypxfrd/rpc.ypxfrd.8
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 2, 1996
.Dt RPC.YPXFRD 8
.Os
diff --git a/usr.sbin/rpc.ypxfrd/ypxfrd_extern.h b/usr.sbin/rpc.ypxfrd/ypxfrd_extern.h
index 165b144f2c45..efe5b3ff2cec 100644
--- a/usr.sbin/rpc.ypxfrd/ypxfrd_extern.h
+++ b/usr.sbin/rpc.ypxfrd/ypxfrd_extern.h
@@ -30,8 +30,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 MAX_CHILDREN
diff --git a/usr.sbin/rpc.ypxfrd/ypxfrd_main.c b/usr.sbin/rpc.ypxfrd/ypxfrd_main.c
index 412190c9ebe9..5498535930f1 100644
--- a/usr.sbin/rpc.ypxfrd/ypxfrd_main.c
+++ b/usr.sbin/rpc.ypxfrd/ypxfrd_main.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "ypxfrd.h"
#include <err.h>
#include <fcntl.h>
@@ -184,7 +182,6 @@ static void reaper(int sig)
}
errno = saved_errno;
- return;
}
void
diff --git a/usr.sbin/rpc.ypxfrd/ypxfrd_server.c b/usr.sbin/rpc.ypxfrd/ypxfrd_server.c
index ca8a2a3c4fe4..f012fbaf50d3 100644
--- a/usr.sbin/rpc.ypxfrd/ypxfrd_server.c
+++ b/usr.sbin/rpc.ypxfrd/ypxfrd_server.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "ypxfrd.h"
#include <stdio.h>
diff --git a/usr.sbin/rpcbind/Makefile b/usr.sbin/rpcbind/Makefile
index eb7baa7fbcfc..1bb2d7584ed2 100644
--- a/usr.sbin/rpcbind/Makefile
+++ b/usr.sbin/rpcbind/Makefile
@@ -1,5 +1,4 @@
# $NetBSD: Makefile,v 1.3 2000/06/20 13:56:43 fvdl Exp $
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/rpcbind/Makefile.depend b/usr.sbin/rpcbind/Makefile.depend
index 722af65039b3..732a025c9552 100644
--- a/usr.sbin/rpcbind/Makefile.depend
+++ b/usr.sbin/rpcbind/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/rpcbind/Makefile.depend.options b/usr.sbin/rpcbind/Makefile.depend.options
index a62a5692d70a..fbc21670804e 100644
--- a/usr.sbin/rpcbind/Makefile.depend.options
+++ b/usr.sbin/rpcbind/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= TCP_WRAPPERS
diff --git a/usr.sbin/rpcbind/check_bound.c b/usr.sbin/rpcbind/check_bound.c
index cf0a029dad72..446dceb3502f 100644
--- a/usr.sbin/rpcbind/check_bound.c
+++ b/usr.sbin/rpcbind/check_bound.c
@@ -1,5 +1,4 @@
/* $NetBSD: check_bound.c,v 1.2 2000/06/22 08:09:26 fvdl Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-3-Clause
@@ -34,14 +33,6 @@
* Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
*/
-/* #ident "@(#)check_bound.c 1.15 93/07/05 SMI" */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)check_bound.c 1.11 89/04/21 Copyr 1989 Sun Micro";
-#endif
-#endif
-
/*
* check_bound.c
* Checks to see whether the program is still bound to the
@@ -161,7 +152,7 @@ char *
mergeaddr(SVCXPRT *xprt, char *netid, char *uaddr, char *saddr)
{
struct fdlist *fdl;
- struct svc_dg_data *dg_data;
+ struct netbuf *callee;
char *c_uaddr, *s_uaddr, *m_uaddr, *allocated_uaddr = NULL;
for (fdl = fdhead; fdl; fdl = fdl->next)
@@ -182,12 +173,11 @@ mergeaddr(SVCXPRT *xprt, char *netid, char *uaddr, char *saddr)
* address by which it contacted us. Use that for the "client" uaddr,
* otherwise use the info from the SVCXPRT.
*/
- dg_data = (struct svc_dg_data*)xprt->xp_p2;
- if (dg_data != NULL && dg_data->su_srcaddr.buf != NULL) {
- c_uaddr = taddr2uaddr(fdl->nconf, &dg_data->su_srcaddr);
+ callee = svc_getrpccallee(xprt);
+ if (callee != NULL && callee->buf != NULL) {
+ c_uaddr = taddr2uaddr(fdl->nconf, callee);
allocated_uaddr = c_uaddr;
- }
- else if (saddr != NULL) {
+ } else if (saddr != NULL) {
c_uaddr = saddr;
} else {
c_uaddr = taddr2uaddr(fdl->nconf, svc_getrpccaller(xprt));
diff --git a/usr.sbin/rpcbind/pmap_svc.c b/usr.sbin/rpcbind/pmap_svc.c
index 991a28d680fb..cea1606258ae 100644
--- a/usr.sbin/rpcbind/pmap_svc.c
+++ b/usr.sbin/rpcbind/pmap_svc.c
@@ -1,5 +1,4 @@
/* $NetBSD: pmap_svc.c,v 1.2 2000/10/20 11:49:40 fvdl Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-3-Clause
@@ -34,14 +33,6 @@
* Copyright (c) 1984 - 1991 by Sun Microsystems, Inc.
*/
-/* #ident "@(#)pmap_svc.c 1.14 93/07/05 SMI" */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)pmap_svc.c 1.23 89/04/05 Copyr 1984 Sun Micro";
-#endif
-#endif
-
/*
* pmap_svc.c
* The server procedure for the version 2 portmaper.
diff --git a/usr.sbin/rpcbind/rpcb_stat.c b/usr.sbin/rpcbind/rpcb_stat.c
index 361ae4c7f2bb..9c03ce368293 100644
--- a/usr.sbin/rpcbind/rpcb_stat.c
+++ b/usr.sbin/rpcbind/rpcb_stat.c
@@ -1,6 +1,5 @@
/*
* $NetBSD: rpcb_stat.c,v 1.2 2000/07/04 20:27:40 matt Exp $
- * $FreeBSD$
*/
/*-
* SPDX-License-Identifier: BSD-3-Clause
@@ -31,8 +30,6 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-/* #pragma ident "@(#)rpcb_stat.c 1.7 94/04/25 SMI" */
-
/*
* rpcb_stat.c
* Allows for gathering of statistics
@@ -80,7 +77,6 @@ rpcbs_procinfo(rpcvers_t rtype, rpcproc_t proc)
default: return;
}
inf[rtype].info[proc]++;
- return;
}
void
@@ -89,7 +85,6 @@ rpcbs_set(rpcvers_t rtype, bool_t success)
if ((rtype >= RPCBVERS_STAT) || (success == FALSE))
return;
inf[rtype].setinfo++;
- return;
}
void
@@ -98,7 +93,6 @@ rpcbs_unset(rpcvers_t rtype, bool_t success)
if ((rtype >= RPCBVERS_STAT) || (success == FALSE))
return;
inf[rtype].unsetinfo++;
- return;
}
void
@@ -195,7 +189,6 @@ rpcbs_rmtcall(rpcvers_t rtype, rpcproc_t rpcbproc, rpcprog_t prog,
rl->indirect = 1;
rl->next = inf[rtype].rmtinfo;
inf[rtype].rmtinfo = rl;
- return;
}
void *
diff --git a/usr.sbin/rpcbind/rpcb_svc.c b/usr.sbin/rpcbind/rpcb_svc.c
index 474f8ec77d17..94323ab992aa 100644
--- a/usr.sbin/rpcbind/rpcb_svc.c
+++ b/usr.sbin/rpcbind/rpcb_svc.c
@@ -1,5 +1,4 @@
/* $NetBSD: rpcb_svc.c,v 1.1 2000/06/02 23:15:41 fvdl Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-3-Clause
@@ -34,8 +33,6 @@
* Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
*/
-/* #ident "@(#)rpcb_svc.c 1.16 93/07/05 SMI" */
-
/*
* rpcb_svc.c
* The server procedure for the version 3 rpcbind (TLI).
diff --git a/usr.sbin/rpcbind/rpcb_svc_4.c b/usr.sbin/rpcbind/rpcb_svc_4.c
index b6ee61771edf..77240e4d3ef5 100644
--- a/usr.sbin/rpcbind/rpcb_svc_4.c
+++ b/usr.sbin/rpcbind/rpcb_svc_4.c
@@ -1,6 +1,5 @@
/*
* $NetBSD: rpcb_svc_4.c,v 1.1 2000/06/02 23:15:41 fvdl Exp $
- * $FreeBSD$
*/
/*-
@@ -36,8 +35,6 @@
* Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
*/
-/* #ident "@(#)rpcb_svc_4.c 1.8 93/07/05 SMI" */
-
/*
* rpcb_svc_4.c
* The server procedure for the version 4 rpcbind.
@@ -245,7 +242,6 @@ done:
}
}
}
- return;
}
/*
diff --git a/usr.sbin/rpcbind/rpcb_svc_com.c b/usr.sbin/rpcbind/rpcb_svc_com.c
index 31cdaf96f074..15ecda213abc 100644
--- a/usr.sbin/rpcbind/rpcb_svc_com.c
+++ b/usr.sbin/rpcbind/rpcb_svc_com.c
@@ -1,5 +1,4 @@
/* $NetBSD: rpcb_svc_com.c,v 1.9 2002/11/08 00:16:39 fvdl Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-3-Clause
@@ -34,8 +33,6 @@
* Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
*/
-/* #ident "@(#)rpcb_svc_com.c 1.18 94/05/02 SMI" */
-
/*
* rpcb_svc_com.c
* The commom server procedure for the rpcbind.
@@ -1225,7 +1222,6 @@ send_svcsyserr(SVCXPRT *xprt, struct finfo *fi)
xprt_set_caller(xprt, fi);
svcerr_systemerr(xprt);
}
- return;
}
static void
@@ -1318,7 +1314,6 @@ done:
#endif
} else
(void) free_slot_by_xid(reply_msg.rm_xid);
- return;
}
static void
@@ -1344,7 +1339,6 @@ find_versions(rpcprog_t prog, char *netid, rpcvers_t *lowvp, rpcvers_t *highvp)
}
*lowvp = lowv;
*highvp = highv;
- return;
}
/*
diff --git a/usr.sbin/rpcbind/rpcbind.8 b/usr.sbin/rpcbind/rpcbind.8
index 0e05405d9279..814e95c46722 100644
--- a/usr.sbin/rpcbind/rpcbind.8
+++ b/usr.sbin/rpcbind/rpcbind.8
@@ -1,8 +1,6 @@
-.\" @(#)rpcbind.1m 1.19 92/09/14 SMI; from SVr4
.\" Copyright 1989 AT&T
.\" Copyright 1991 Sun Microsystems, Inc.
-.\" $FreeBSD$
-.Dd April 19, 2017
+.Dd August 31, 2023
.Dt RPCBIND 8
.Os
.Sh NAME
@@ -10,7 +8,7 @@
.Nd universal addresses to RPC program number mapper
.Sh SYNOPSIS
.Nm
-.Op Fl 6adiLlswW
+.Op Fl 6adiLlNswW
.Op Fl h Ar bindip
.Sh DESCRIPTION
The
@@ -123,6 +121,11 @@ Without this flag, local connections are only allowed over a local socket,
.Pa /var/run/rpcbind.sock .
.It Fl l
Turn on libwrap connection logging.
+.It Fl N
+Run in foreground mode.
+In this mode,
+.Nm
+will not fork when it starts.
.It Fl s
Cause
.Nm
diff --git a/usr.sbin/rpcbind/rpcbind.c b/usr.sbin/rpcbind/rpcbind.c
index b0d79df20b16..de05330d0ca5 100644
--- a/usr.sbin/rpcbind/rpcbind.c
+++ b/usr.sbin/rpcbind/rpcbind.c
@@ -1,5 +1,4 @@
/* $NetBSD: rpcbind.c,v 1.3 2002/11/08 00:16:40 fvdl Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-3-Clause
@@ -34,14 +33,6 @@
* Copyright (c) 1984 - 1991 by Sun Microsystems, Inc.
*/
-/* #ident "@(#)rpcbind.c 1.19 94/04/25 SMI" */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)rpcbind.c 1.35 89/04/21 Copyr 1984 Sun Micro";
-#endif
-#endif
-
/*
* rpcbind.c
* Implements the program, version to address mapping for rpc.
@@ -95,6 +86,7 @@ int oldstyle_local = 0;
#ifdef LIBWRAP
int libwrap = 0;
#endif
+int nofork = 0;
int verboselog = 0;
static char **hosts = NULL;
@@ -227,7 +219,7 @@ main(int argc, char *argv[])
} else {
printf("\n");
}
- } else {
+ } else if (!nofork) {
if (daemon(0, 0))
err(1, "fork failed");
}
@@ -810,7 +802,7 @@ parseargs(int argc, char *argv[])
#else
#define WRAPOP ""
#endif
- while ((c = getopt(argc, argv, "6adh:iLls" WRAPOP WSOP)) != -1) {
+ while ((c = getopt(argc, argv, "6adh:iLlNs" WRAPOP WSOP)) != -1) {
switch (c) {
case '6':
ipv6_only = 1;
@@ -840,6 +832,9 @@ parseargs(int argc, char *argv[])
case 'l':
verboselog = 1;
break;
+ case 'N':
+ nofork = 1;
+ break;
case 's':
runasdaemon = 1;
break;
diff --git a/usr.sbin/rpcbind/rpcbind.h b/usr.sbin/rpcbind/rpcbind.h
index a4bb3d274066..28addac494ce 100644
--- a/usr.sbin/rpcbind/rpcbind.h
+++ b/usr.sbin/rpcbind/rpcbind.h
@@ -1,5 +1,4 @@
/* $NetBSD: rpcbind.h,v 1.1 2000/06/03 00:47:21 fvdl Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-3-Clause
@@ -34,8 +33,6 @@
* Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
*/
-/* #ident "@(#)rpcbind.h 1.4 90/04/12 SMI" */
-
/*
* rpcbind.h
* The common header declarations
diff --git a/usr.sbin/rpcbind/security.c b/usr.sbin/rpcbind/security.c
index 22cf0b26fa9c..6d899f0a9269 100644
--- a/usr.sbin/rpcbind/security.c
+++ b/usr.sbin/rpcbind/security.c
@@ -1,5 +1,4 @@
/* $NetBSD: security.c,v 1.5 2000/06/08 09:01:05 fvdl Exp $ */
-/* $FreeBSD$ */
#include <sys/types.h>
#include <sys/time.h>
diff --git a/usr.sbin/rpcbind/tests/Makefile b/usr.sbin/rpcbind/tests/Makefile
index dae57a29fda7..f5647c997480 100644
--- a/usr.sbin/rpcbind/tests/Makefile
+++ b/usr.sbin/rpcbind/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/rpcbind/tests/Makefile.depend b/usr.sbin/rpcbind/tests/Makefile.depend
index d313b17d4486..f17dae18048f 100644
--- a/usr.sbin/rpcbind/tests/Makefile.depend
+++ b/usr.sbin/rpcbind/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/rpcbind/tests/addrmerge_test.c b/usr.sbin/rpcbind/tests/addrmerge_test.c
index a29dc30fdde8..e0830bc2401b 100644
--- a/usr.sbin/rpcbind/tests/addrmerge_test.c
+++ b/usr.sbin/rpcbind/tests/addrmerge_test.c
@@ -26,8 +26,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 DAMAGES.
- *
- * $FreeBSD$
*/
#include <rpc/rpc.h>
diff --git a/usr.sbin/rpcbind/util.c b/usr.sbin/rpcbind/util.c
index e497e9227690..491c3e53b9e5 100644
--- a/usr.sbin/rpcbind/util.c
+++ b/usr.sbin/rpcbind/util.c
@@ -1,10 +1,9 @@
/*
* $NetBSD: util.c,v 1.4 2000/08/03 00:04:30 fvdl Exp $
- * $FreeBSD$
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -101,7 +100,7 @@ bitmaskcmp(struct sockaddr *dst, struct sockaddr *src, struct sockaddr *mask)
/*
* Find a server address that can be used by `caller' to contact
- * the local service specified by `serv_uaddr'. If `clnt_uaddr' is
+ * the local service specified by `serv_uaddr'. If `contct_uaddr' is
* non-NULL, it is used instead of `caller' as a hint suggesting
* the best address (e.g. the `r_addr' field of an rpc, which
* contains the rpcbind server address that the caller used).
@@ -110,8 +109,8 @@ bitmaskcmp(struct sockaddr *dst, struct sockaddr *src, struct sockaddr *mask)
* string which should be freed by the caller. On error, returns NULL.
*/
char *
-addrmerge(struct netbuf *caller, const char *serv_uaddr, const char *clnt_uaddr,
- const char *netid)
+addrmerge(struct netbuf *caller, const char *serv_uaddr,
+ const char *contct_uaddr, const char *netid)
{
struct ifaddrs *ifap, *ifp = NULL, *bestif;
struct netbuf *serv_nbp = NULL, *hint_nbp = NULL, tbuf;
@@ -128,7 +127,7 @@ addrmerge(struct netbuf *caller, const char *serv_uaddr, const char *clnt_uaddr,
#ifdef ND_DEBUG
if (debugging)
fprintf(stderr, "addrmerge(caller, %s, %s, %s\n", serv_uaddr,
- clnt_uaddr == NULL ? "NULL" : clnt_uaddr, netid);
+ contct_uaddr == NULL ? "NULL" : contct_uaddr, netid);
#endif
caller_sa = caller->buf;
if ((nconf = rpcbind_get_conf(netid)) == NULL)
@@ -137,15 +136,15 @@ addrmerge(struct netbuf *caller, const char *serv_uaddr, const char *clnt_uaddr,
goto freeit;
/*
- * Use `clnt_uaddr' as the hint if non-NULL, but ignore it if its
+ * Use `contct_uaddr' as the hint if non-NULL, but ignore it if its
* address family is different from that of the caller.
*/
hint_sa = NULL;
- if (clnt_uaddr != NULL) {
+ if (contct_uaddr != NULL) {
#ifdef ND_DEBUG
- hint_uaddr = clnt_uaddr;
+ hint_uaddr = contct_uaddr;
#endif
- if ((hint_nbp = uaddr2taddr(nconf, clnt_uaddr)) == NULL)
+ if ((hint_nbp = uaddr2taddr(nconf, contct_uaddr)) == NULL)
goto freeit;
hint_sa = hint_nbp->buf;
}
diff --git a/usr.sbin/rpcbind/warmstart.c b/usr.sbin/rpcbind/warmstart.c
index 74ad91231e3d..075aebf421f1 100644
--- a/usr.sbin/rpcbind/warmstart.c
+++ b/usr.sbin/rpcbind/warmstart.c
@@ -35,8 +35,6 @@
*/
/*
- * #ident "@(#)warmstart.c 1.7 93/07/05 SMI"
- * $FreeBSD$/
*/
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/usr.sbin/rrenumd/Makefile b/usr.sbin/rrenumd/Makefile
index ba6c4ad8f5cd..f2a0415b8607 100644
--- a/usr.sbin/rrenumd/Makefile
+++ b/usr.sbin/rrenumd/Makefile
@@ -12,7 +12,6 @@
# LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE.
#
-# $FreeBSD$
PROG= rrenumd
MAN= rrenumd.conf.5 rrenumd.8
diff --git a/usr.sbin/rrenumd/Makefile.depend b/usr.sbin/rrenumd/Makefile.depend
index ca3301c271b9..48f9c6dc2589 100644
--- a/usr.sbin/rrenumd/Makefile.depend
+++ b/usr.sbin/rrenumd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -10,8 +8,6 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libipsec \
- lib/liby \
- usr.bin/lex/lib \
usr.bin/yacc.host \
diff --git a/usr.sbin/rrenumd/lexer.l b/usr.sbin/rrenumd/lexer.l
index 315d75a2fb13..f94a1afea128 100644
--- a/usr.sbin/rrenumd/lexer.l
+++ b/usr.sbin/rrenumd/lexer.l
@@ -29,8 +29,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$
*/
%{
diff --git a/usr.sbin/rrenumd/parser.y b/usr.sbin/rrenumd/parser.y
index c75dde23df3d..94f6b15555c5 100644
--- a/usr.sbin/rrenumd/parser.y
+++ b/usr.sbin/rrenumd/parser.y
@@ -29,8 +29,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$
*/
%{
diff --git a/usr.sbin/rrenumd/rrenumd.8 b/usr.sbin/rrenumd/rrenumd.8
index cc13a018fd2a..418e4eeb68e8 100644
--- a/usr.sbin/rrenumd/rrenumd.8
+++ b/usr.sbin/rrenumd/rrenumd.8
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd September 7, 1998
.Dt RRENUMD 8
.Os
diff --git a/usr.sbin/rrenumd/rrenumd.c b/usr.sbin/rrenumd/rrenumd.c
index dd08396b6421..152cf6346fd9 100644
--- a/usr.sbin/rrenumd/rrenumd.c
+++ b/usr.sbin/rrenumd/rrenumd.c
@@ -29,8 +29,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/param.h>
@@ -348,8 +346,6 @@ sock6_open(struct flags *flags
}
#endif /* IPSEC_POLICY_IPSEC */
#endif /* IPSEC */
-
- return;
}
static void
@@ -414,8 +410,6 @@ sock4_open(struct flags *flags
}
#endif /* IPSEC_POLICY_IPSEC */
#endif /* IPSEC */
-
- return;
}
static void
diff --git a/usr.sbin/rrenumd/rrenumd.conf.5 b/usr.sbin/rrenumd/rrenumd.conf.5
index 9ce2306cc51f..f12d6d900c88 100644
--- a/usr.sbin/rrenumd/rrenumd.conf.5
+++ b/usr.sbin/rrenumd/rrenumd.conf.5
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd November 5, 1998
.Dt RRENUMD.CONF 5
.Os
diff --git a/usr.sbin/rrenumd/rrenumd.h b/usr.sbin/rrenumd/rrenumd.h
index 2e9390d023fd..521d3e48fada 100644
--- a/usr.sbin/rrenumd/rrenumd.h
+++ b/usr.sbin/rrenumd/rrenumd.h
@@ -33,8 +33,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$
*/
struct dst_list {
diff --git a/usr.sbin/rtadvctl/Makefile b/usr.sbin/rtadvctl/Makefile
index a8dcad163651..f45ab4f0d25a 100644
--- a/usr.sbin/rtadvctl/Makefile
+++ b/usr.sbin/rtadvctl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
.PATH: ${.CURDIR:H}/rtadvd
diff --git a/usr.sbin/rtadvctl/Makefile.depend b/usr.sbin/rtadvctl/Makefile.depend
index d5ed563ecfc8..344a5d0e9310 100644
--- a/usr.sbin/rtadvctl/Makefile.depend
+++ b/usr.sbin/rtadvctl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/rtadvctl/rtadvctl.8 b/usr.sbin/rtadvctl/rtadvctl.8
index be1586daf9bb..b138056875af 100644
--- a/usr.sbin/rtadvctl/rtadvctl.8
+++ b/usr.sbin/rtadvctl/rtadvctl.8
@@ -23,8 +23,6 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd July 16, 2011
.Dt RTADVCTL 8
.Os
diff --git a/usr.sbin/rtadvctl/rtadvctl.c b/usr.sbin/rtadvctl/rtadvctl.c
index 8bbd7afb6dd5..727fa6ee1a52 100644
--- a/usr.sbin/rtadvctl/rtadvctl.c
+++ b/usr.sbin/rtadvctl/rtadvctl.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org>
* All rights reserved.
@@ -25,8 +25,6 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#include <sys/queue.h>
diff --git a/usr.sbin/rtadvd/Makefile b/usr.sbin/rtadvd/Makefile
index 920c6d966aff..583f9db88ceb 100644
--- a/usr.sbin/rtadvd/Makefile
+++ b/usr.sbin/rtadvd/Makefile
@@ -12,7 +12,6 @@
# LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE.
#
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/rtadvd/Makefile.depend b/usr.sbin/rtadvd/Makefile.depend
index 4fc5be2a35f0..bbd6b7071809 100644
--- a/usr.sbin/rtadvd/Makefile.depend
+++ b/usr.sbin/rtadvd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/rtadvd/advcap.c b/usr.sbin/rtadvd/advcap.c
index 5efa5ce2dd9c..7e7c1ad4fe0b 100644
--- a/usr.sbin/rtadvd/advcap.c
+++ b/usr.sbin/rtadvd/advcap.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: advcap.c,v 1.11 2003/05/19 09:46:50 keiichi Exp $ */
/*-
diff --git a/usr.sbin/rtadvd/advcap.h b/usr.sbin/rtadvd/advcap.h
index 3414e209cecd..75c8e5c1976a 100644
--- a/usr.sbin/rtadvd/advcap.h
+++ b/usr.sbin/rtadvd/advcap.h
@@ -1,8 +1,7 @@
-/* $FreeBSD$ */
/* $KAME: advcap.h,v 1.5 2003/06/09 05:40:54 t-momose Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 1994,1995 by Andrey A. Chernov, Moscow, Russia.
* All rights reserved.
diff --git a/usr.sbin/rtadvd/config.c b/usr.sbin/rtadvd/config.c
index f857889332a4..bd990c58b36a 100644
--- a/usr.sbin/rtadvd/config.c
+++ b/usr.sbin/rtadvd/config.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: config.c,v 1.84 2003/08/05 12:34:23 itojun Exp $ */
/*-
@@ -1549,5 +1548,4 @@ make_packet(struct rainfo *rai)
syslog(LOG_DEBUG, "<%s>: nd_opt_dnssl_len = %d", __func__,
ndopt_dnssl->nd_opt_dnssl_len);
}
- return;
}
diff --git a/usr.sbin/rtadvd/config.h b/usr.sbin/rtadvd/config.h
index 24e6f493bdbc..cfea1821ca5e 100644
--- a/usr.sbin/rtadvd/config.h
+++ b/usr.sbin/rtadvd/config.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: config.h,v 1.8 2003/06/17 08:26:22 itojun Exp $ */
/*-
diff --git a/usr.sbin/rtadvd/control.c b/usr.sbin/rtadvd/control.c
index 4ef2e8383450..80af6371a269 100644
--- a/usr.sbin/rtadvd/control.c
+++ b/usr.sbin/rtadvd/control.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org>
* All rights reserved.
@@ -25,8 +25,6 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#include <sys/queue.h>
diff --git a/usr.sbin/rtadvd/control.h b/usr.sbin/rtadvd/control.h
index 1086519948dc..d87887df7bd5 100644
--- a/usr.sbin/rtadvd/control.h
+++ b/usr.sbin/rtadvd/control.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org>
* All rights reserved.
@@ -25,8 +25,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#define SOCK_BACKLOG 5
diff --git a/usr.sbin/rtadvd/control_client.c b/usr.sbin/rtadvd/control_client.c
index 64d7d68a89fa..03107c6bd944 100644
--- a/usr.sbin/rtadvd/control_client.c
+++ b/usr.sbin/rtadvd/control_client.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org>
* All rights reserved.
@@ -25,8 +25,6 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#include <sys/queue.h>
diff --git a/usr.sbin/rtadvd/control_client.h b/usr.sbin/rtadvd/control_client.h
index d1af84dc7456..f0bba527bc26 100644
--- a/usr.sbin/rtadvd/control_client.h
+++ b/usr.sbin/rtadvd/control_client.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org>
* All rights reserved.
@@ -25,8 +25,6 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
int cm_handler_client(int, int, char *);
diff --git a/usr.sbin/rtadvd/control_server.c b/usr.sbin/rtadvd/control_server.c
index c6cf695ac36f..e96a1958dd10 100644
--- a/usr.sbin/rtadvd/control_server.c
+++ b/usr.sbin/rtadvd/control_server.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org>
* All rights reserved.
@@ -25,8 +25,6 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#include <sys/queue.h>
diff --git a/usr.sbin/rtadvd/control_server.h b/usr.sbin/rtadvd/control_server.h
index 072caa10a290..a3dc19474dc6 100644
--- a/usr.sbin/rtadvd/control_server.h
+++ b/usr.sbin/rtadvd/control_server.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org>
* All rights reserved.
@@ -25,8 +25,6 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
int cm_getprop(struct ctrl_msg_pl *);
diff --git a/usr.sbin/rtadvd/if.c b/usr.sbin/rtadvd/if.c
index 34fe7ad49dc2..6212639ba028 100644
--- a/usr.sbin/rtadvd/if.c
+++ b/usr.sbin/rtadvd/if.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: if.c,v 1.17 2001/01/21 15:27:30 itojun Exp $ */
/*-
@@ -144,8 +143,6 @@ lladdropt_fill(struct sockaddr_dl *sdl, struct nd_opt_hdr *ndopt)
__func__, sdl->sdl_type);
exit(1);
}
-
- return;
}
int
diff --git a/usr.sbin/rtadvd/if.h b/usr.sbin/rtadvd/if.h
index 42b4be795859..c477a836e251 100644
--- a/usr.sbin/rtadvd/if.h
+++ b/usr.sbin/rtadvd/if.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: if.h,v 1.10 2003/02/24 11:29:10 ono Exp $ */
/*-
diff --git a/usr.sbin/rtadvd/pathnames.h b/usr.sbin/rtadvd/pathnames.h
index 248ee19f66e0..154feab97f07 100644
--- a/usr.sbin/rtadvd/pathnames.h
+++ b/usr.sbin/rtadvd/pathnames.h
@@ -1,5 +1,4 @@
/* $KAME: pathnames.h,v 1.2 2000/05/16 13:34:13 itojun Exp $ */
-/* $FreeBSD$ */
#define _PATH_RTADVDCONF "/etc/rtadvd.conf"
#define _PATH_RTADVDPID "/var/run/rtadvd.pid"
diff --git a/usr.sbin/rtadvd/rrenum.c b/usr.sbin/rtadvd/rrenum.c
index f12fcaaed8c7..d148d5d20885 100644
--- a/usr.sbin/rtadvd/rrenum.c
+++ b/usr.sbin/rtadvd/rrenum.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: rrenum.c,v 1.12 2002/06/10 19:59:47 itojun Exp $ */
/*-
@@ -432,7 +431,6 @@ rr_command_input(int len, struct icmp6_router_renum *rr,
failed:
syslog(LOG_ERR, "<%s> received RR was invalid", __func__);
- return;
}
void
@@ -500,6 +498,4 @@ rr_input(int len, struct icmp6_router_renum *rr, struct in6_pktinfo *pi,
break;
}
-
- return;
}
diff --git a/usr.sbin/rtadvd/rrenum.h b/usr.sbin/rtadvd/rrenum.h
index 93cd96b6d189..c4bc3e1af376 100644
--- a/usr.sbin/rtadvd/rrenum.h
+++ b/usr.sbin/rtadvd/rrenum.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: rrenum.h,v 1.3 2001/01/21 15:37:14 itojun Exp $ */
/*-
diff --git a/usr.sbin/rtadvd/rtadvd.8 b/usr.sbin/rtadvd/rtadvd.8
index fcb46feebef6..52db425f03b7 100644
--- a/usr.sbin/rtadvd/rtadvd.8
+++ b/usr.sbin/rtadvd/rtadvd.8
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd February 25, 2013
.Dt RTADVD 8
.Os
diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c
index 391c95c9bd48..aa9038b65e63 100644
--- a/usr.sbin/rtadvd/rtadvd.c
+++ b/usr.sbin/rtadvd/rtadvd.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: rtadvd.c,v 1.82 2003/08/05 12:34:23 itojun Exp $ */
/*-
@@ -705,8 +704,6 @@ rtmsg_input(struct sockinfo *s)
set_short_delay(ifi);
}
}
-
- return;
}
void
@@ -898,8 +895,6 @@ rtadvd_input(struct sockinfo *s)
syslog(LOG_ERR, "invalid icmp type(%d)", icp->icmp6_type);
return;
}
-
- return;
}
static void
@@ -991,7 +986,6 @@ rs_input(int len, struct nd_router_solicit *rs,
done:
free_ndopts(&ndopts);
- return;
}
static void
@@ -1221,7 +1215,6 @@ ra_input(int len, struct nd_router_advert *nra,
done:
free_ndopts(&ndopts);
- return;
}
static uint32_t
@@ -1613,8 +1606,6 @@ sock_open(struct sockinfo *s)
sndmhdr.msg_iovlen = 1;
sndmhdr.msg_control = (caddr_t)sndcmsgbuf;
sndmhdr.msg_controllen = sndcmsgbuflen;
-
- return;
}
/* open a routing socket to watch the routing table */
@@ -1916,6 +1907,4 @@ ra_timer_update(void *arg, struct timespec *tm)
"<%s> RA timer on %s is set to %ld:%ld",
__func__, ifi->ifi_ifname,
(long int)tm->tv_sec, (long int)tm->tv_nsec / 1000);
-
- return;
}
diff --git a/usr.sbin/rtadvd/rtadvd.conf b/usr.sbin/rtadvd/rtadvd.conf
index 1e42c75b75be..cb97bec97bde 100644
--- a/usr.sbin/rtadvd/rtadvd.conf
+++ b/usr.sbin/rtadvd/rtadvd.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
# $KAME: rtadvd.conf,v 1.13 2003/06/25 03:45:21 itojun Exp $
#
# Note: All of the following parameters have default values defined
diff --git a/usr.sbin/rtadvd/rtadvd.conf.5 b/usr.sbin/rtadvd/rtadvd.conf.5
index d4a0c0258915..6824d2a5578b 100644
--- a/usr.sbin/rtadvd/rtadvd.conf.5
+++ b/usr.sbin/rtadvd/rtadvd.conf.5
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 4, 2011
.Dt RTADVD.CONF 5
.Os
diff --git a/usr.sbin/rtadvd/rtadvd.h b/usr.sbin/rtadvd/rtadvd.h
index 885d2fbb3c80..eb7746733c6e 100644
--- a/usr.sbin/rtadvd/rtadvd.h
+++ b/usr.sbin/rtadvd/rtadvd.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: rtadvd.h,v 1.26 2003/08/05 12:34:23 itojun Exp $ */
/*-
diff --git a/usr.sbin/rtadvd/timer.c b/usr.sbin/rtadvd/timer.c
index 94c5dcd91f70..a73bf6f94d29 100644
--- a/usr.sbin/rtadvd/timer.c
+++ b/usr.sbin/rtadvd/timer.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: timer.c,v 1.9 2002/06/10 19:59:47 itojun Exp $ */
/*-
@@ -100,8 +99,6 @@ rtadvd_update_timeout_handler(void)
break;
}
}
-
- return;
}
struct rtadvd_timer *
@@ -196,6 +193,4 @@ rtadvd_set_timer(struct timespec *tm, struct rtadvd_timer *rat)
/* update the next expiration time */
if (TS_CMP(&rat->rat_tm, &tm_max, <))
tm_max = rat->rat_tm;
-
- return;
}
diff --git a/usr.sbin/rtadvd/timer.h b/usr.sbin/rtadvd/timer.h
index 74ac7d41d8fe..49364bf19c9f 100644
--- a/usr.sbin/rtadvd/timer.h
+++ b/usr.sbin/rtadvd/timer.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: timer.h,v 1.5 2002/05/31 13:30:38 jinmei Exp $ */
/*-
diff --git a/usr.sbin/rtadvd/timer_subr.c b/usr.sbin/rtadvd/timer_subr.c
index 7a7a23cd98f7..9bd91753dd23 100644
--- a/usr.sbin/rtadvd/timer_subr.c
+++ b/usr.sbin/rtadvd/timer_subr.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: timer.c,v 1.9 2002/06/10 19:59:47 itojun Exp $ */
/*-
diff --git a/usr.sbin/rtadvd/timer_subr.h b/usr.sbin/rtadvd/timer_subr.h
index 36e8b3bdc192..ccf1b3b7f8c7 100644
--- a/usr.sbin/rtadvd/timer_subr.h
+++ b/usr.sbin/rtadvd/timer_subr.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $KAME: timer.h,v 1.5 2002/05/31 13:30:38 jinmei Exp $ */
/*-
diff --git a/usr.sbin/rtprio/Makefile b/usr.sbin/rtprio/Makefile
index b612f2bc974b..c9c72a9b4e0c 100644
--- a/usr.sbin/rtprio/Makefile
+++ b/usr.sbin/rtprio/Makefile
@@ -1,5 +1,3 @@
-# from: @(#)Makefile 5.5 (Berkeley) 5/11/90
-# $FreeBSD$
PROG= rtprio
LINKS= ${BINDIR}/rtprio ${BINDIR}/idprio
diff --git a/usr.sbin/rtprio/Makefile.depend b/usr.sbin/rtprio/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/rtprio/Makefile.depend
+++ b/usr.sbin/rtprio/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/rtprio/rtprio.1 b/usr.sbin/rtprio/rtprio.1
index 3f29e87d44f8..5a86934bdcda 100644
--- a/usr.sbin/rtprio/rtprio.1
+++ b/usr.sbin/rtprio/rtprio.1
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 8, 2021
.Dt RTPRIO 1
.Os
diff --git a/usr.sbin/rtprio/rtprio.c b/usr.sbin/rtprio/rtprio.c
index 9ce74b5547ad..b5ded9308828 100644
--- a/usr.sbin/rtprio/rtprio.c
+++ b/usr.sbin/rtprio/rtprio.c
@@ -34,9 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/rtprio.h>
@@ -49,7 +46,7 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
static int parseint(const char *, const char *);
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char *argv[])
diff --git a/usr.sbin/rtsold/Makefile b/usr.sbin/rtsold/Makefile
index 34da996b0f79..99a01f236e1b 100644
--- a/usr.sbin/rtsold/Makefile
+++ b/usr.sbin/rtsold/Makefile
@@ -12,7 +12,6 @@
# LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE.
#
-# $FreeBSD$
PROG= rtsold
MAN= rtsold.8
diff --git a/usr.sbin/rtsold/Makefile.depend b/usr.sbin/rtsold/Makefile.depend
index d897c480ee77..2326fec704fd 100644
--- a/usr.sbin/rtsold/Makefile.depend
+++ b/usr.sbin/rtsold/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/rtsold/Makefile.depend.options b/usr.sbin/rtsold/Makefile.depend.options
index c20f954f5bc4..a0449df3a893 100644
--- a/usr.sbin/rtsold/Makefile.depend.options
+++ b/usr.sbin/rtsold/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= CASPER
diff --git a/usr.sbin/rtsold/cap_llflags.c b/usr.sbin/rtsold/cap_llflags.c
index aea45d9fb8a0..29b7bd2d4b5c 100644
--- a/usr.sbin/rtsold/cap_llflags.c
+++ b/usr.sbin/rtsold/cap_llflags.c
@@ -28,9 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/dnv.h>
#include <sys/ioctl.h>
diff --git a/usr.sbin/rtsold/cap_script.c b/usr.sbin/rtsold/cap_script.c
index 971d0bae4172..97b7f947532c 100644
--- a/usr.sbin/rtsold/cap_script.c
+++ b/usr.sbin/rtsold/cap_script.c
@@ -28,9 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/capsicum.h>
#include <sys/dnv.h>
diff --git a/usr.sbin/rtsold/cap_sendmsg.c b/usr.sbin/rtsold/cap_sendmsg.c
index b81993514eaf..6e7f156fbe62 100644
--- a/usr.sbin/rtsold/cap_sendmsg.c
+++ b/usr.sbin/rtsold/cap_sendmsg.c
@@ -29,8 +29,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/param.h>
diff --git a/usr.sbin/rtsold/dump.c b/usr.sbin/rtsold/dump.c
index 803a6c0d95d3..3c4c78799dcc 100644
--- a/usr.sbin/rtsold/dump.c
+++ b/usr.sbin/rtsold/dump.c
@@ -29,8 +29,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/types.h>
diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c
index 0f7f2ce7cba5..a0f61b991e8a 100644
--- a/usr.sbin/rtsold/if.c
+++ b/usr.sbin/rtsold/if.c
@@ -29,8 +29,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/param.h>
diff --git a/usr.sbin/rtsold/rtsock.c b/usr.sbin/rtsold/rtsock.c
index 4dfbf61f47db..1dfdea0f5c3d 100644
--- a/usr.sbin/rtsold/rtsock.c
+++ b/usr.sbin/rtsold/rtsock.c
@@ -1,5 +1,4 @@
/* $KAME: rtsock.c,v 1.3 2000/10/10 08:46:45 itojun Exp $ */
-/* $FreeBSD$ */
/*-
* SPDX-License-Identifier: BSD-3-Clause
diff --git a/usr.sbin/rtsold/rtsol.c b/usr.sbin/rtsold/rtsol.c
index 646dd092cb0c..79928932ca5c 100644
--- a/usr.sbin/rtsold/rtsol.c
+++ b/usr.sbin/rtsold/rtsol.c
@@ -30,8 +30,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/param.h>
@@ -81,6 +79,7 @@ static char *make_rsid(const char *, const char *, struct rainfo *);
#define _ARGS_MANAGED managedconf_script, ifi->ifname, rasender
#define _ARGS_OTHER otherconf_script, ifi->ifname, rasender
+#define _ARGS_ALWAYS alwaysconf_script, ifi->ifname, rasender
#define _ARGS_RESADD resolvconf_script, "-a", rsid
#define _ARGS_RESDEL resolvconf_script, "-d", rsid
@@ -327,6 +326,17 @@ rtsol_input(int sock)
if (!ifi->managedconfig)
CALL_SCRIPT(OTHER, NULL);
}
+
+ /*
+ * "Always" script.
+ */
+ if (!ifi->alwaysconfig) {
+ const char *rasender = inet_ntop(AF_INET6, &from.sin6_addr,
+ ntopbuf, sizeof(ntopbuf));
+ ifi->alwaysconfig = 1;
+ CALL_SCRIPT(ALWAYS, NULL);
+ }
+
clock_gettime(CLOCK_MONOTONIC_FAST, &now);
newent_rai = 0;
rai = find_rainfo(ifi, &from);
diff --git a/usr.sbin/rtsold/rtsold.8 b/usr.sbin/rtsold/rtsold.8
index 992d3a0f784d..cc29ae5a8738 100644
--- a/usr.sbin/rtsold/rtsold.8
+++ b/usr.sbin/rtsold/rtsold.8
@@ -27,9 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd December 15, 2021
+.Dd May 2, 2023
.Dt RTSOLD 8
.Os
.\"
@@ -42,6 +40,7 @@
.Op Fl dDfFimu1
.Op Fl M Ar script-name
.Op Fl O Ar script-name
+.Op Fl A Ar script-name
.Op Fl p Ar pidfile
.Op Fl R Ar script-name
.Ar interface ...
@@ -49,6 +48,7 @@
.Op Fl dDfFimu1
.Op Fl M Ar script-name
.Op Fl O Ar script-name
+.Op Fl A Ar script-name
.Op Fl p Ar pidfile
.Op Fl R Ar script-name
.Fl a
@@ -56,12 +56,14 @@
.Op Fl dDiu
.Op Fl M Ar script-name
.Op Fl O Ar script-name
+.Op Fl A Ar script-name
.Op Fl R Ar script-name
.Ar interface ...
.Nm rtsol
.Op Fl dDiu
.Op Fl M Ar script-name
.Op Fl O Ar script-name
+.Op Fl A Ar script-name
.Op Fl R Ar script-name
.Fl a
.\"
@@ -250,6 +252,18 @@ router advertisement is also TRUE.
must be the absolute path from root to the script file, be a regular
file, and be created by the same owner who runs
.Nm .
+.It Fl A Ar script-name
+Specifies a supplement script file to always be called for the router
+advertisement.
+.Nm
+will invoke
+.Ar script-name
+with a first argument of the receiving interface name
+and a second argument of the sending router address.
+.Ar script-name
+must be the absolute path from root to the script file, be a regular
+file, and be created by the same owner who runs
+.Nm .
.It Fl p Ar pidfile
Writes the process ID of
.Nm
diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c
index f1ba3b07c879..91c80d178bc7 100644
--- a/usr.sbin/rtsold/rtsold.c
+++ b/usr.sbin/rtsold/rtsold.c
@@ -29,8 +29,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/param.h>
@@ -82,6 +80,7 @@ int uflag = 0;
const char *managedconf_script;
const char *otherconf_script;
+const char *alwaysconf_script;
const char *resolvconf_script = "/sbin/resolvconf";
cap_channel_t *capllflags, *capscript, *capsendmsg, *capsyslog;
@@ -126,11 +125,11 @@ main(int argc, char **argv)
progname = basename(argv[0]);
if (strcmp(progname, "rtsold") == 0) {
- opts = "adDfFim1M:O:p:R:u";
+ opts = "adDfFim1M:O:A:p:R:u";
once = 0;
pidfilepath = NULL;
} else {
- opts = "adDFiM:O:R:u";
+ opts = "adDFiM:O:A:R:u";
fflag = 1;
once = 1;
}
@@ -167,6 +166,9 @@ main(int argc, char **argv)
case 'O':
otherconf_script = optarg;
break;
+ case 'A':
+ alwaysconf_script = optarg;
+ break;
case 'p':
pidfilepath = optarg;
break;
@@ -204,6 +206,9 @@ main(int argc, char **argv)
if (otherconf_script != NULL && *otherconf_script != '/')
errx(1, "configuration script (%s) must be an absolute path",
otherconf_script);
+ if (alwaysconf_script != NULL && *alwaysconf_script != '/')
+ errx(1, "configuration script (%s) must be an absolute path",
+ alwaysconf_script);
if (*resolvconf_script != '/')
errx(1, "configuration script (%s) must be an absolute path",
resolvconf_script);
@@ -336,7 +341,8 @@ init_capabilities(void)
{
#ifdef WITH_CASPER
const char *const scripts[] =
- { resolvconf_script, managedconf_script, otherconf_script };
+ { resolvconf_script, managedconf_script, otherconf_script,
+ alwaysconf_script };
cap_channel_t *capcasper;
nvlist_t *limits;
@@ -616,6 +622,7 @@ rtsol_check_timer(void)
if (probe) {
ifi->managedconfig = 0;
ifi->otherconfig = 0;
+ ifi->alwaysconfig = 0;
}
if (probe && mobile_node) {
error = cap_probe_defrouters(capsendmsg,
@@ -786,13 +793,17 @@ usage(const char *progname)
if (strcmp(progname, "rtsold") == 0) {
fprintf(stderr, "usage: rtsold [-dDfFm1] [-O script-name] "
+ "[-M script-name ] [-A script-name ] "
"[-p pidfile] [-R script-name] interface ...\n");
fprintf(stderr, "usage: rtsold [-dDfFm1] [-O script-name] "
+ "[-M script-name ] [-A script-name ] "
"[-p pidfile] [-R script-name] -a\n");
} else {
fprintf(stderr, "usage: rtsol [-dDF] [-O script-name] "
+ "[-M script-name ] [-A script-name ] "
"[-p pidfile] [-R script-name] interface ...\n");
fprintf(stderr, "usage: rtsol [-dDF] [-O script-name] "
+ "[-M script-name ] [-A script-name ] "
"[-p pidfile] [-R script-name] -a\n");
}
exit(1);
diff --git a/usr.sbin/rtsold/rtsold.h b/usr.sbin/rtsold/rtsold.h
index 1342ad87703b..e8df6b8c61df 100644
--- a/usr.sbin/rtsold/rtsold.h
+++ b/usr.sbin/rtsold/rtsold.h
@@ -29,8 +29,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$
*/
struct script_msg {
@@ -75,6 +73,7 @@ struct ifinfo {
* configuration */
int otherconfig; /* need a separate protocol for the "other"
* configuration */
+ int alwaysconfig; /* Have we called the 'always' script? */
int state;
int probes;
int dadcount;
@@ -160,6 +159,7 @@ extern int Fflag;
extern int uflag;
extern const char *managedconf_script;
extern const char *otherconf_script;
+extern const char *alwaysconf_script;
extern const char *resolvconf_script;
extern struct cap_channel *capllflags, *capscript, *capsendmsg, *capsyslog;
diff --git a/usr.sbin/rwhod/Makefile b/usr.sbin/rwhod/Makefile
index 554f6bec1c3c..3196179da14f 100644
--- a/usr.sbin/rwhod/Makefile
+++ b/usr.sbin/rwhod/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= rwhod
MAN= rwhod.8
diff --git a/usr.sbin/rwhod/Makefile.depend b/usr.sbin/rwhod/Makefile.depend
index 782b0d5c171e..2b2c07c4987d 100644
--- a/usr.sbin/rwhod/Makefile.depend
+++ b/usr.sbin/rwhod/Makefile.depend
@@ -1,14 +1,14 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/protocols \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
+ lib/libcasper/libcasper \
lib/libcompiler_rt \
diff --git a/usr.sbin/rwhod/rwhod.8 b/usr.sbin/rwhod/rwhod.8
index c4f60a371645..db96833841f9 100644
--- a/usr.sbin/rwhod/rwhod.8
+++ b/usr.sbin/rwhod/rwhod.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)rwhod.8 8.2 (Berkeley) 12/11/93
-.\" $FreeBSD$
-.\"
.Dd August 8, 2017
.Dt RWHOD 8
.Os
diff --git a/usr.sbin/rwhod/rwhod.c b/usr.sbin/rwhod/rwhod.c
index 23c307e33829..2f589e2492e3 100644
--- a/usr.sbin/rwhod/rwhod.c
+++ b/usr.sbin/rwhod/rwhod.c
@@ -30,21 +30,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)rwhod.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/capsicum.h>
#include <sys/ioctl.h>
@@ -137,7 +122,7 @@ void run_as(uid_t *uid, gid_t *gid);
void quit(const char *msg);
void sender_process(void);
int verify(char *name, int maxlen);
-static void usage(void);
+static void usage(void) __dead2;
#ifdef DEBUG
char *interval(int time, char *updown);
diff --git a/usr.sbin/sa/Makefile b/usr.sbin/sa/Makefile
index 375b8045e81f..2b7aa79154d0 100644
--- a/usr.sbin/sa/Makefile
+++ b/usr.sbin/sa/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/sa/Makefile.depend b/usr.sbin/sa/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/sa/Makefile.depend
+++ b/usr.sbin/sa/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/sa/db.c b/usr.sbin/sa/db.c
index b0c9656d980a..8776ed7cd9ed 100644
--- a/usr.sbin/sa/db.c
+++ b/usr.sbin/sa/db.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2007 Diomidis Spinellis
* All rights reserved.
@@ -27,9 +27,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/acct.h>
diff --git a/usr.sbin/sa/extern.h b/usr.sbin/sa/extern.h
index 17c77e1b2371..aa15d208c8dd 100644
--- a/usr.sbin/sa/extern.h
+++ b/usr.sbin/sa/extern.h
@@ -28,8 +28,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$
*/
#include <sys/types.h>
diff --git a/usr.sbin/sa/main.c b/usr.sbin/sa/main.c
index b6c9708de74f..e36f082e0e6c 100644
--- a/usr.sbin/sa/main.c
+++ b/usr.sbin/sa/main.c
@@ -30,16 +30,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1994 Christopher G. Demetriou\n\
- All rights reserved.\n";
-#endif
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* sa: system accounting
*/
diff --git a/usr.sbin/sa/pathnames.h b/usr.sbin/sa/pathnames.h
index 7352818addad..6bc01bd4cf1f 100644
--- a/usr.sbin/sa/pathnames.h
+++ b/usr.sbin/sa/pathnames.h
@@ -28,8 +28,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$
*/
#define _PATH_ACCT "/var/account/acct"
diff --git a/usr.sbin/sa/pdb.c b/usr.sbin/sa/pdb.c
index eb3f4a40c983..958b2c966d74 100644
--- a/usr.sbin/sa/pdb.c
+++ b/usr.sbin/sa/pdb.c
@@ -30,9 +30,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/acct.h>
#include <err.h>
diff --git a/usr.sbin/sa/sa.8 b/usr.sbin/sa/sa.8
index dc50fc441c16..597e44fccd15 100644
--- a/usr.sbin/sa/sa.8
+++ b/usr.sbin/sa/sa.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 February 14, 2020
.Dt SA 8
.Os
diff --git a/usr.sbin/sa/tests/Makefile b/usr.sbin/sa/tests/Makefile
index ed2318417842..c049ae25368f 100644
--- a/usr.sbin/sa/tests/Makefile
+++ b/usr.sbin/sa/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= tests
diff --git a/usr.sbin/sa/tests/Makefile.depend b/usr.sbin/sa/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/sa/tests/Makefile.depend
+++ b/usr.sbin/sa/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/sa/tests/legacy_test.sh b/usr.sbin/sa/tests/legacy_test.sh
index d0d8f429366a..718135c8b1ae 100644
--- a/usr.sbin/sa/tests/legacy_test.sh
+++ b/usr.sbin/sa/tests/legacy_test.sh
@@ -1,6 +1,5 @@
#!/bin/sh
#
-# $FreeBSD$
#
DIR=`dirname $0`
diff --git a/usr.sbin/sa/tests/prime.sh b/usr.sbin/sa/tests/prime.sh
index 6992f45bce28..cafdc9e58f26 100755
--- a/usr.sbin/sa/tests/prime.sh
+++ b/usr.sbin/sa/tests/prime.sh
@@ -3,7 +3,6 @@
# Configure and run this script to create the files for regression testing
# for a new architecture/configuration.
#
-# $FreeBSD$
#
TZ=UTC; export TZ
diff --git a/usr.sbin/sa/usrdb.c b/usr.sbin/sa/usrdb.c
index 50a33e1a91ae..9e01d59a3693 100644
--- a/usr.sbin/sa/usrdb.c
+++ b/usr.sbin/sa/usrdb.c
@@ -30,9 +30,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/types.h>
#include <sys/acct.h>
diff --git a/usr.sbin/sendmail/Makefile b/usr.sbin/sendmail/Makefile
index 3a74a200f2ed..b062d417a042 100644
--- a/usr.sbin/sendmail/Makefile
+++ b/usr.sbin/sendmail/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.8 (Berkeley) 3/28/97
-# $FreeBSD$
.include <src.opts.mk>
@@ -17,7 +15,7 @@ MLINKS+=sendmail.8 purgestat.8
SRCS= alias.c arpadate.c bf.c collect.c conf.c control.c \
convtime.c daemon.c deliver.c domain.c envelope.c err.c headers.c \
macro.c main.c map.c mci.c milter.c mime.c parseaddr.c queue.c \
- ratectrl.c readcf.c recipient.c savemail.c sasl.c sfsasl.c \
+ ratectrl.c readcf.c recipient.c savemail.c sasl.c sched.c sfsasl.c \
shmticklib.c sm_resolve.c srvrsmtp.c stab.c stats.c sysexits.c \
timers.c tlsh.c tls.c trace.c udb.c usersmtp.c util.c version.c
BINOWN= root
@@ -62,6 +60,8 @@ CFLAGS+= -DTCPWRAPPERS
LIBADD+= wrap
.endif
+CFLAGS+= ${NO_WDEPRECATED_NON_PROTOTYPE}
+
# User customizations to the sendmail build environment
CFLAGS+=${SENDMAIL_CFLAGS}
DPADD+=${SENDMAIL_DPADD}
diff --git a/usr.sbin/sendmail/Makefile.depend b/usr.sbin/sendmail/Makefile.depend
index 4a376e6292e9..236c896d87e1 100644
--- a/usr.sbin/sendmail/Makefile.depend
+++ b/usr.sbin/sendmail/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
@@ -11,7 +10,6 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libsm \
lib/libsmutil \
- lib/libthr \
lib/libutil \
diff --git a/usr.sbin/sendmail/Makefile.depend.options b/usr.sbin/sendmail/Makefile.depend.options
index 1feb80a343bb..c0a29e52552f 100644
--- a/usr.sbin/sendmail/Makefile.depend.options
+++ b/usr.sbin/sendmail/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= OPENSSL TCP_WRAPPERS
diff --git a/usr.sbin/service/Makefile b/usr.sbin/service/Makefile
index e8432f5aabf8..95244ab69685 100644
--- a/usr.sbin/service/Makefile
+++ b/usr.sbin/service/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= runtime
SCRIPTS=service.sh
diff --git a/usr.sbin/service/Makefile.depend b/usr.sbin/service/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/service/Makefile.depend
+++ b/usr.sbin/service/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/service/service.8 b/usr.sbin/service/service.8
index 9902ae3c8574..2c5dfa3f3a66 100644
--- a/usr.sbin/service/service.8
+++ b/usr.sbin/service/service.8
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd November 9, 2021
+.Dd January 29, 2024
.Dt SERVICE 8
.Os
.Sh NAME
@@ -48,6 +46,7 @@
.Nm
.Op Fl j Ar jail
.Op Fl v
+.Op Fl E Ar var=value
.Ar script
.Ar command
.Sh DESCRIPTION
@@ -65,8 +64,22 @@ see
It can also be used to list
the scripts using various criteria.
.Pp
+The set of permissible values for
+.Ar command
+depends on the particular rc.d script being invoked.
+For a list of standard commands which are supported by most rc.d
+scripts, see
+.Xr rc 8 .
+.Pp
The options are as follows:
.Bl -tag -width F1
+.It Fl E Ar var=value
+Set the environment variable
+.Ar var
+to the specified
+.Ar value
+before starting the script.
+This option can be used multiple times.
.It Fl e
List services that are enabled.
The list of scripts to check is compiled using
@@ -117,15 +130,50 @@ to
which is how they are set in
.Pa /etc/rc
at boot time.
+If the
+.Fl E
+option is used, the corresponding variable is set accordingly.
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
-The following are examples of typical usage of the
-.Nm
-command:
+These are some examples of the most common service commands.
+For a full list of commands available in most rc.d scripts, see
+.Xr rc 8 .
+.Pp
+Enable a service, then start it:
+.Bd -literal -offset -indent
+service sshd enable
+service sshd start
+.Ed
+.Pp
+Stop a service, then disable it:
+.Bd -literal -offset -indent
+service sshd stop
+service sshd disable
+.Ed
+.Pp
+Start a service which is not enabled:
+.Bd -literal -offset -indent
+service sshd onestart
+.Ed
+.Pp
+Report the status of a service:
.Bd -literal -offset -ident
service named status
-service -j dns named status
+.Ed
+.Pp
+Restart a service running in a jail:
+.Bd -literal -offset -indent
+service -j dns named restart
+.Ed
+.Pp
+Start a service with a specific environment variable set:
+.Bd -literal -offset -indent
+service -E LC_ALL=C.UTF-8 named start
+.Ed
+.Pp
+Report a verbose listing of all available services:
+.Bd -literal -offset -indent
service -rv
.Ed
.Pp
@@ -154,7 +202,8 @@ complete -F _service service
.Xr bash 1 Pq Pa ports/shells/bash ,
.Xr rc.conf 5 ,
.Xr rc 8 ,
-.Xr rcorder 8
+.Xr rcorder 8 ,
+.Xr sysrc 8
.Sh HISTORY
The
.Nm
diff --git a/usr.sbin/service/service.sh b/usr.sbin/service/service.sh
index 76cce580c5b4..65aa18181101 100755
--- a/usr.sbin/service/service.sh
+++ b/usr.sbin/service/service.sh
@@ -1,8 +1,6 @@
#!/bin/sh
-# $FreeBSD$
-
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2009 Douglas Barton
# All rights reserved.
@@ -37,21 +35,23 @@ usage () {
echo "${0##*/} [-j <jail name or id>] -e"
echo "${0##*/} [-j <jail name or id>] -R"
echo "${0##*/} [-j <jail name or id>] [-v] -l | -r"
- echo "${0##*/} [-j <jail name or id>] [-v] <rc.d script> start|stop|etc."
+ echo "${0##*/} [-j <jail name or id>] [-v] [-E var=value] <rc.d script> start|stop|etc."
echo "${0##*/} -h"
echo ''
- echo "-j Perform actions within the named jail"
- echo '-e Show services that are enabled'
- echo "-R Stop and start enabled $local_startup services"
- echo "-l List all scripts in /etc/rc.d and $local_startup"
- echo '-r Show the results of boot time rcorder'
- echo '-v Verbose'
+ echo "-j Perform actions within the named jail"
+ echo "-E n=val Set variable n to val before executing the rc.d script"
+ echo '-e Show services that are enabled'
+ echo "-R Stop and start enabled $local_startup services"
+ echo "-l List all scripts in /etc/rc.d and $local_startup"
+ echo '-r Show the results of boot time rcorder'
+ echo '-v Verbose'
echo ''
}
-while getopts 'j:ehlrRv' COMMAND_LINE_ARGUMENT ; do
+while getopts 'j:E:ehlrRv' COMMAND_LINE_ARGUMENT ; do
case "${COMMAND_LINE_ARGUMENT}" in
j) JAIL="${OPTARG}" ;;
+ E) VARS="${VARS} ${OPTARG}" ;;
e) ENABLED=eopt ;;
h) usage ; exit 0 ;;
l) LIST=lopt ;;
@@ -72,6 +72,9 @@ if [ -n "${JAIL}" ]; then
[ -n "${RCORDER}" ] && args="${args} -r"
[ -n "${RESTART}" ] && args="${args} -R"
[ -n "${VERBOSE}" ] && args="${args} -v"
+ for var in ${VARS}; do
+ args="${args} -E ${var}"
+ done
# Call jexec(8) with the rebuild args and any positional args that
# were left in $@
@@ -171,7 +174,7 @@ cd /
for dir in /etc/rc.d $local_startup; do
if [ -x "$dir/$script" ]; then
[ -n "$VERBOSE" ] && echo "$script is located in $dir"
- exec env -i -L -/daemon HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin "$dir/$script" "$@"
+ exec env -i -L -/daemon HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ${VARS} "$dir/$script" "$@"
fi
done
diff --git a/usr.sbin/services_mkdb/Makefile b/usr.sbin/services_mkdb/Makefile
index c1edc37452ab..8d8e0f1c0626 100644
--- a/usr.sbin/services_mkdb/Makefile
+++ b/usr.sbin/services_mkdb/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PACKAGE= runtime
diff --git a/usr.sbin/services_mkdb/Makefile.depend b/usr.sbin/services_mkdb/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/services_mkdb/Makefile.depend
+++ b/usr.sbin/services_mkdb/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/services_mkdb/extern.h b/usr.sbin/services_mkdb/extern.h
index 07c2f227b426..3fba548ab5e9 100644
--- a/usr.sbin/services_mkdb/extern.h
+++ b/usr.sbin/services_mkdb/extern.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -27,8 +27,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$
*/
extern HASHINFO hinfo;
diff --git a/usr.sbin/services_mkdb/services b/usr.sbin/services_mkdb/services
index 71dda5b8d80f..aa5421366ae6 100644
--- a/usr.sbin/services_mkdb/services
+++ b/usr.sbin/services_mkdb/services
@@ -16,10 +16,6 @@
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
-#
-# $FreeBSD$
-# From: @(#)services 5.8 (Berkeley) 5/9/91
-#
# WELL KNOWN PORT NUMBERS
#
tcpmux 1/tcp #TCP Port Service Multiplexer
diff --git a/usr.sbin/services_mkdb/services_mkdb.8 b/usr.sbin/services_mkdb/services_mkdb.8
index 08cdbe7ac5a2..0e0fac9e5280 100644
--- a/usr.sbin/services_mkdb/services_mkdb.8
+++ b/usr.sbin/services_mkdb/services_mkdb.8
@@ -27,8 +27,6 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 4, 2010
.Dt SERVICES_MKDB 8
.Os
diff --git a/usr.sbin/services_mkdb/services_mkdb.c b/usr.sbin/services_mkdb/services_mkdb.c
index 60d5783977d6..5c6de31ba5e1 100644
--- a/usr.sbin/services_mkdb/services_mkdb.c
+++ b/usr.sbin/services_mkdb/services_mkdb.c
@@ -1,7 +1,7 @@
/* $NetBSD: services_mkdb.c,v 1.14 2008/04/28 20:24:17 martin Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -31,9 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
diff --git a/usr.sbin/services_mkdb/uniq.c b/usr.sbin/services_mkdb/uniq.c
index c78b01ef27c5..e18d0e462c90 100644
--- a/usr.sbin/services_mkdb/uniq.c
+++ b/usr.sbin/services_mkdb/uniq.c
@@ -1,7 +1,7 @@
/* $NetBSD: uniq.c,v 1.4 2008/04/28 20:24:17 martin Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -31,8 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
diff --git a/usr.sbin/sesutil/Makefile b/usr.sbin/sesutil/Makefile
index fc39434a3704..4e8e08eabd15 100644
--- a/usr.sbin/sesutil/Makefile
+++ b/usr.sbin/sesutil/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= sesutil
SRCS= sesutil.c eltsub.c
diff --git a/usr.sbin/sesutil/Makefile.depend b/usr.sbin/sesutil/Makefile.depend
index 5770a091f2a6..b95024e29443 100644
--- a/usr.sbin/sesutil/Makefile.depend
+++ b/usr.sbin/sesutil/Makefile.depend
@@ -1,15 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libutil \
- lib/libxo \
+ lib/libxo/libxo \
.include <dirdeps.mk>
diff --git a/usr.sbin/sesutil/eltsub.c b/usr.sbin/sesutil/eltsub.c
index 740182e91211..d18fad5cb784 100644
--- a/usr.sbin/sesutil/eltsub.c
+++ b/usr.sbin/sesutil/eltsub.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*
* Copyright (c) 2000 by Matthew Jacob
* All rights reserved.
diff --git a/usr.sbin/sesutil/eltsub.h b/usr.sbin/sesutil/eltsub.h
index d1818ef3ee8b..d7feb461368e 100644
--- a/usr.sbin/sesutil/eltsub.h
+++ b/usr.sbin/sesutil/eltsub.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*
* Copyright (c) 2000 by Matthew Jacob
* All rights reserved.
@@ -13,7 +12,7 @@
* derived from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
- * the GNU Public License ("GPL").
+ * GNU Public License ("GPL").
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
diff --git a/usr.sbin/sesutil/sesutil.8 b/usr.sbin/sesutil/sesutil.8
index 101c93ae40ee..664dcab593e9 100644
--- a/usr.sbin/sesutil/sesutil.8
+++ b/usr.sbin/sesutil/sesutil.8
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd December 12, 2019
+.Dd July 5, 2022
.Dt SESUTIL 8
.Os
.Sh NAME
@@ -34,13 +32,25 @@
.Nm
.Cm fault
.Op Fl u Ar /dev/sesN
-.Aq Ar disk | Ar sesid | Li all
-.Op on | off
+.Ar disk Ns | Ns Cm all
+.Cm on Ns | Ns Cm off
+.Nm
+.Cm fault
+.Fl u Ar /dev/sesN
+.Sm off
+.Ar sesid
+.Sm on
+.Cm on Ns | Ns Cm off
.Nm
.Cm locate
.Op Fl u Ar /dev/sesN
-.Aq Ar disk | Ar sesid | Li all
-.Op on | off
+.Ar disk Ns | Ns Cm all
+.Cm on Ns | Ns Cm off
+.Nm
+.Cm locate
+.Fl u Ar /dev/sesN
+.Ar sesid
+.Cm on Ns | Ns Cm off
.Nm
.Cm map
.Op Fl -libxo Ar options
@@ -61,22 +71,16 @@ Services (SES) devices.
.Pp
List of supported commands:
.Bl -tag -width indent
-.It Fl -libxo
-Generate output via
-.Xr libxo 3
-in a selection of different human and machine readable formats.
-See
-.Xr xo_parse_args 3
-.It Cm fault Oo Fl u Ar /dev/sesN Oc Ao Ar disk | Li all Ac Op on | off
+.It Cm fault Oo Fl u Ar /dev/sesN Oc Ar disk Ns | Ns Cm all Cm on Ns | Ns Cm off
Change the state of the external fault LED associated with
.Ar disk .
.Ar disk
can be the device name of the disk, like
-.Cm da12 ,
+.Ql da12 ,
or
-.Ql all .
+.Cm all
to indicate all disks attached to SES controllers.
-.It Cm fault Fl u Ar /dev/sesN Ar sesid Op on | off
+.It Cm fault Fl u Ar /dev/sesN Ar sesid Cm on Ns | Ns Cm off
Change the state of the external fault LED associated with an element
connected to the SES controller.
.Ar sesid
@@ -84,16 +88,16 @@ must be the element ID of a valid item attached to the controller.
Use the
.Cm map
command to list the elements attached to a controller.
-.It Cm locate Oo Fl u Ar /dev/sesN Oc Ao Ar disk | Li all Ac Op on | off
+.It Cm locate Oo Fl u Ar /dev/sesN Oc Ar disk Ns | Ns Cm all Cm on Ns | Ns Cm off
Change the state of the external locate LED associated with
.Ar disk .
.Ar disk
can be the device name of the disk, like
-.Cm da12 ,
+.Ql da12 ,
or
-.Ql all .
+.Cm all
to indicate all disks attached to SES controllers.
-.It Cm locate Fl u Ar /dev/sesN Ar sesid Op on | off
+.It Cm locate Fl u Ar /dev/sesN Ar sesid Cm on Ns | Ns Cm off
Change the state of the external locate LED associated with an element
connected to the SES controller.
.Ar sesid
@@ -101,22 +105,32 @@ must be the element ID of a valid item attached to the controller.
Use the
.Cm map
command to list the elements attached to a controller.
-.It Cm show Op Fl u Ar /dev/sesN
-Display user-friendly summary of specified
+.It Cm map Oo Fl -libxo Ar options Oc Op Fl u Ar /dev/sesN
+Display a map of all elements connected to the specified
.Xr ses 4
controller.
If no controller is specified, all controllers are mapped.
-.It Cm map Op Fl u Ar /dev/sesN
-Display a map of all elements connected to the specified
+.It Cm show Oo Fl -libxo Ar options Oc Op Fl u Ar /dev/sesN
+Display user-friendly summary of specified
.Xr ses 4
controller.
If no controller is specified, all controllers are mapped.
-.It Cm status Op Fl u Ar /dev/sesN
+.It Cm status Oo Fl -libxo Ar options Oc Op Fl u Ar /dev/sesN
Display the status of the specified
.Xr ses 4
controller.
If no controller is specified, the status of each controller is returned.
.El
+.Pp
+Common options:
+.Bl -tag -width indent
+.It Fl -libxo Ar options
+Generate output via
+.Xr libxo 3
+in a selection of different human and machine readable formats.
+See
+.Xr xo_parse_args 3
+.El
.Sh EXAMPLES
Turn off all locate LEDs:
.Pp
diff --git a/usr.sbin/sesutil/sesutil.c b/usr.sbin/sesutil/sesutil.c
index b11f02177c62..b6cdd2cf3314 100644
--- a/usr.sbin/sesutil/sesutil.c
+++ b/usr.sbin/sesutil/sesutil.c
@@ -31,8 +31,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/endian.h>
#include <sys/param.h>
#include <sys/disk.h>
@@ -281,6 +279,16 @@ sesled(int argc, char **argv, bool setfault)
char devnames[devnames_size];
if (all) {
+ encioc_elm_status_t es;
+ memset(&es, 0, sizeof(es));
+ es.elm_idx = objp[j].elm_idx;
+ if (ioctl(fd, ENCIOC_GETELMSTAT, &es) < 0) {
+ close(fd);
+ xo_err(EXIT_FAILURE,
+ "ENCIOC_GETELMSTAT");
+ }
+ if ((es.cstat[0] & 0xf) == SES_OBJSTAT_NOACCESS)
+ continue;
do_led(fd, objp[j].elm_idx, objp[j].elm_type,
onoff, setfault);
continue;
@@ -417,6 +425,17 @@ objmap(int argc, char **argv __unused)
usage(stderr, "map");
}
+ memset(&e_desc, 0, sizeof(e_desc));
+ /* SES4r02 allows element descriptors of up to 65536 characters */
+ e_desc.elm_desc_str = calloc(UINT16_MAX, sizeof(char));
+ if (e_desc.elm_desc_str == NULL)
+ xo_err(EXIT_FAILURE, "calloc()");
+
+ e_devname.elm_devnames = calloc(128, sizeof(char));
+ if (e_devname.elm_devnames == NULL)
+ xo_err(EXIT_FAILURE, "calloc()");
+ e_devname.elm_names_size = 128;
+
/* Get the list of ses devices */
if (glob(uflag, 0, NULL, &g) == GLOB_NOMATCH) {
globfree(&g);
@@ -481,29 +500,16 @@ objmap(int argc, char **argv __unused)
xo_err(EXIT_FAILURE, "ENCIOC_GETELMSTAT");
}
/* Get the description of the element */
- memset(&e_desc, 0, sizeof(e_desc));
e_desc.elm_idx = e_ptr[j].elm_idx;
e_desc.elm_desc_len = UINT16_MAX;
- /* XXX memory leak! */
- e_desc.elm_desc_str = calloc(UINT16_MAX, sizeof(char));
- if (e_desc.elm_desc_str == NULL) {
- close(fd);
- xo_err(EXIT_FAILURE, "calloc()");
- }
if (ioctl(fd, ENCIOC_GETELMDESC,
(caddr_t) &e_desc) < 0) {
close(fd);
xo_err(EXIT_FAILURE, "ENCIOC_GETELMDESC");
}
+ e_desc.elm_desc_str[e_desc.elm_desc_len] = '\0';
/* Get the device name(s) of the element */
- memset(&e_devname, 0, sizeof(e_devname));
e_devname.elm_idx = e_ptr[j].elm_idx;
- e_devname.elm_names_size = 128;
- e_devname.elm_devnames = calloc(128, sizeof(char));
- if (e_devname.elm_devnames == NULL) {
- close(fd);
- xo_err(EXIT_FAILURE, "calloc()");
- }
if (ioctl(fd, ENCIOC_GETELMDEVNAMES,
(caddr_t) &e_devname) <0) {
/* Continue even if we can't look up devnames */
@@ -526,13 +532,14 @@ objmap(int argc, char **argv __unused)
}
print_extra_status(e_ptr[j].elm_type, e_status.cstat, PRINT_STYLE_DASHED);
xo_close_instance("elements");
- free(e_devname.elm_devnames);
}
xo_close_list("elements");
free(e_ptr);
close(fd);
}
globfree(&g);
+ free(e_devname.elm_devnames);
+ free(e_desc.elm_desc_str);
xo_close_list("enclosures");
xo_close_container("sesutil");
xo_finish();
@@ -618,7 +625,7 @@ static void
show_device(int fd, int elm_idx, encioc_elm_status_t e_status, encioc_elm_desc_t e_desc)
{
encioc_elm_devnames_t e_devname;
- char *model, *serial;
+ char *model = NULL, *serial = NULL;
off_t size;
/* Get the device name(s) of the element */
@@ -635,8 +642,6 @@ show_device(int fd, int elm_idx, encioc_elm_status_t e_status, encioc_elm_desc_t
(caddr_t) &e_devname) < 0) {
/* We don't care if this fails */
e_devname.elm_devnames[0] = '\0';
- model = NULL;
- serial = NULL;
size = -1;
} else {
skip_pass_devices(e_devname.elm_devnames, 128);
@@ -661,6 +666,8 @@ show_device(int fd, int elm_idx, encioc_elm_status_t e_status, encioc_elm_desc_t
print_extra_status(ELMTYP_ARRAY_DEV, e_status.cstat, PRINT_STYLE_CSV);
xo_emit("\n");
xo_close_instance("elements");
+ free(serial);
+ free(model);
free(e_devname.elm_devnames);
}
@@ -727,6 +734,10 @@ show(int argc, char **argv __unused)
first_ses = true;
+ e_desc.elm_desc_str = calloc(UINT16_MAX, sizeof(char));
+ if (e_desc.elm_desc_str == NULL)
+ xo_err(EXIT_FAILURE, "calloc()");
+
/* Get the list of ses devices */
if (glob(uflag, 0, NULL, &g) == GLOB_NOMATCH) {
globfree(&g);
@@ -808,19 +819,14 @@ show(int argc, char **argv __unused)
continue;
/* Get the description of the element */
- memset(&e_desc, 0, sizeof(e_desc));
e_desc.elm_idx = e_ptr[j].elm_idx;
e_desc.elm_desc_len = UINT16_MAX;
- e_desc.elm_desc_str = calloc(UINT16_MAX, sizeof(char));
- if (e_desc.elm_desc_str == NULL) {
- close(fd);
- xo_err(EXIT_FAILURE, "calloc()");
- }
if (ioctl(fd, ENCIOC_GETELMDESC,
(caddr_t) &e_desc) < 0) {
close(fd);
xo_err(EXIT_FAILURE, "ENCIOC_GETELMDESC");
}
+ e_desc.elm_desc_str[e_desc.elm_desc_len] = '\0';
switch (e_ptr[j].elm_type) {
case ELMTYP_DEVICE:
@@ -862,6 +868,7 @@ show(int argc, char **argv __unused)
close(fd);
}
globfree(&g);
+ free(e_desc.elm_desc_str);
xo_close_list("enclosures");
xo_close_container("sesutil");
xo_finish();
diff --git a/usr.sbin/setfib/Makefile b/usr.sbin/setfib/Makefile
index 8508ed14ffc6..45d4667e6a94 100644
--- a/usr.sbin/setfib/Makefile
+++ b/usr.sbin/setfib/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= setfib
diff --git a/usr.sbin/setfib/Makefile.depend b/usr.sbin/setfib/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/setfib/Makefile.depend
+++ b/usr.sbin/setfib/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/setfib/setfib.1 b/usr.sbin/setfib/setfib.1
index 5c36748343fe..ecf92f05a831 100644
--- a/usr.sbin/setfib/setfib.1
+++ b/usr.sbin/setfib/setfib.1
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 20, 2008
.Dt SETFIB 1
.Os
diff --git a/usr.sbin/setfib/setfib.c b/usr.sbin/setfib/setfib.c
index 0783a07f4597..aa998a0f6e77 100644
--- a/usr.sbin/setfib/setfib.c
+++ b/usr.sbin/setfib/setfib.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <err.h>
#include <errno.h>
@@ -45,7 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/sysctl.h>
-static void usage(void);
+static void usage(void) __dead2;
int
main(int argc, char *argv[])
diff --git a/usr.sbin/setfmac/Makefile b/usr.sbin/setfmac/Makefile
index bcbd85fe275e..fc2d9fc9917f 100644
--- a/usr.sbin/setfmac/Makefile
+++ b/usr.sbin/setfmac/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= setfmac
LINKS= ${BINDIR}/setfmac ${BINDIR}/setfsmac
diff --git a/usr.sbin/setfmac/Makefile.depend b/usr.sbin/setfmac/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/setfmac/Makefile.depend
+++ b/usr.sbin/setfmac/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/setfmac/setfmac.8 b/usr.sbin/setfmac/setfmac.8
index b541a4afe9e3..f9424f32a9ca 100644
--- a/usr.sbin/setfmac/setfmac.8
+++ b/usr.sbin/setfmac/setfmac.8
@@ -27,8 +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.
-.\"
-.\" $FreeBSD$
.Dd February 17, 2004
.Dt SETFMAC 8
.Os
diff --git a/usr.sbin/setfmac/setfmac.c b/usr.sbin/setfmac/setfmac.c
index 15dc7ffc4dde..411eb886c22b 100644
--- a/usr.sbin/setfmac/setfmac.c
+++ b/usr.sbin/setfmac/setfmac.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002, 2004 Networks Associates Technology, Inc.
* All rights reserved.
@@ -29,8 +29,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/types.h>
diff --git a/usr.sbin/setfmac/setfsmac.8 b/usr.sbin/setfmac/setfsmac.8
index 9bdb0e8f7ec9..18fa408d7b63 100644
--- a/usr.sbin/setfmac/setfsmac.8
+++ b/usr.sbin/setfmac/setfsmac.8
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd February 17, 2004
.Dt SETFSMAC 8
.Os
diff --git a/usr.sbin/setpmac/Makefile b/usr.sbin/setpmac/Makefile
index a8bc1acca26b..4f134b8e23cb 100644
--- a/usr.sbin/setpmac/Makefile
+++ b/usr.sbin/setpmac/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= setpmac
MAN= setpmac.8
diff --git a/usr.sbin/setpmac/Makefile.depend b/usr.sbin/setpmac/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/setpmac/Makefile.depend
+++ b/usr.sbin/setpmac/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/setpmac/setpmac.8 b/usr.sbin/setpmac/setpmac.8
index c5c2963c5570..a63089c4f8d3 100644
--- a/usr.sbin/setpmac/setpmac.8
+++ b/usr.sbin/setpmac/setpmac.8
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 14, 2003
.Dt SETPMAC 8
.Os
diff --git a/usr.sbin/setpmac/setpmac.c b/usr.sbin/setpmac/setpmac.c
index 386d76589d90..72c6acbc99db 100644
--- a/usr.sbin/setpmac/setpmac.c
+++ b/usr.sbin/setpmac/setpmac.c
@@ -32,8 +32,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/types.h>
#include <sys/mac.h>
diff --git a/usr.sbin/smbmsg/Makefile b/usr.sbin/smbmsg/Makefile
index 2ae640442808..4d3a498b6d3b 100644
--- a/usr.sbin/smbmsg/Makefile
+++ b/usr.sbin/smbmsg/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
PROG= smbmsg
MAN= smbmsg.8
diff --git a/usr.sbin/smbmsg/Makefile.depend b/usr.sbin/smbmsg/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/smbmsg/Makefile.depend
+++ b/usr.sbin/smbmsg/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/smbmsg/pathnames.h b/usr.sbin/smbmsg/pathnames.h
index d5a0a24fe755..4eb1a1d37053 100644
--- a/usr.sbin/smbmsg/pathnames.h
+++ b/usr.sbin/smbmsg/pathnames.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2004 Joerg Wunsch
* 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$
*/
#define PATH_DEFAULTSMBDEV "/dev/smb0"
diff --git a/usr.sbin/smbmsg/smbmsg.8 b/usr.sbin/smbmsg/smbmsg.8
index faa5bb099349..107da7819d2c 100644
--- a/usr.sbin/smbmsg/smbmsg.8
+++ b/usr.sbin/smbmsg/smbmsg.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 16, 2004
.Dt SMBMSG 8
.Os
diff --git a/usr.sbin/smbmsg/smbmsg.c b/usr.sbin/smbmsg/smbmsg.c
index bd552bee3659..eaf2d345e452 100644
--- a/usr.sbin/smbmsg/smbmsg.c
+++ b/usr.sbin/smbmsg/smbmsg.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2004 Joerg Wunsch
* 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$
*/
/*
diff --git a/usr.sbin/snapinfo/Makefile b/usr.sbin/snapinfo/Makefile
index 76013744e988..12c2881ca6ca 100644
--- a/usr.sbin/snapinfo/Makefile
+++ b/usr.sbin/snapinfo/Makefile
@@ -1,6 +1,6 @@
-# $FreeBSD$
#
+PACKAGE= ufs
PROG= snapinfo
MAN= snapinfo.8
diff --git a/usr.sbin/snapinfo/Makefile.depend b/usr.sbin/snapinfo/Makefile.depend
index 735bf03b75b6..910688a678fa 100644
--- a/usr.sbin/snapinfo/Makefile.depend
+++ b/usr.sbin/snapinfo/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/snapinfo/snapinfo.8 b/usr.sbin/snapinfo/snapinfo.8
index 010291ecb2c7..07e6bf2b4d4a 100644
--- a/usr.sbin/snapinfo/snapinfo.8
+++ b/usr.sbin/snapinfo/snapinfo.8
@@ -22,8 +22,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 July 20, 2005
.Dt SNAPINFO 8
.Os
diff --git a/usr.sbin/snapinfo/snapinfo.c b/usr.sbin/snapinfo/snapinfo.c
index 9758979bc7e9..28f42ebdbe34 100644
--- a/usr.sbin/snapinfo/snapinfo.c
+++ b/usr.sbin/snapinfo/snapinfo.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2005 Mark Santcroos <marks@freebsd.org>
*
@@ -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$
- *
*/
#include <sys/param.h>
diff --git a/usr.sbin/spi/Makefile b/usr.sbin/spi/Makefile
index 5676e4193064..17d651ce80eb 100644
--- a/usr.sbin/spi/Makefile
+++ b/usr.sbin/spi/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
#.include <src.opts.mk>
diff --git a/usr.sbin/spi/spi.8 b/usr.sbin/spi/spi.8
index ed012be64fe5..c3c041fe8e93 100644
--- a/usr.sbin/spi/spi.8
+++ b/usr.sbin/spi/spi.8
@@ -21,8 +21,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd August 21, 2020
.Dt SPI 8
.Os
diff --git a/usr.sbin/spi/spi.c b/usr.sbin/spi/spi.c
index 0407f40a3521..351474dde0ba 100644
--- a/usr.sbin/spi/spi.c
+++ b/usr.sbin/spi/spi.c
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/ioccom.h>
#include <sys/spigenio.h>
diff --git a/usr.sbin/spkrtest/Makefile b/usr.sbin/spkrtest/Makefile
index 8e9245aa753a..1a67586a360c 100644
--- a/usr.sbin/spkrtest/Makefile
+++ b/usr.sbin/spkrtest/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SCRIPTS=spkrtest.sh
MAN= spkrtest.8
diff --git a/usr.sbin/spkrtest/Makefile.depend b/usr.sbin/spkrtest/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/spkrtest/Makefile.depend
+++ b/usr.sbin/spkrtest/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/spkrtest/spkrtest.8 b/usr.sbin/spkrtest/spkrtest.8
index a7266c7e7be1..b30b9b11e444 100644
--- a/usr.sbin/spkrtest/spkrtest.8
+++ b/usr.sbin/spkrtest/spkrtest.8
@@ -21,9 +21,7 @@
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.Dd March 6, 2022
+.Dd October 11, 2023
.Dt SPKRTEST 8
.Os
.Sh NAME
@@ -35,6 +33,16 @@
The
.Nm
utility is an easy to use test script for the speaker driver.
+.Pp
+.Nm
+requires the
+.Xr spkr 4
+driver.
+To load the driver as a module at boot time, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+speaker_load="YES"
+.Ed
.Sh FILES
.Bl -tag -width /dev/speakerxx
.It Pa /dev/speaker
diff --git a/usr.sbin/spkrtest/spkrtest.sh b/usr.sbin/spkrtest/spkrtest.sh
index 417d38350233..af0ef4b7ca4b 100644
--- a/usr.sbin/spkrtest/spkrtest.sh
+++ b/usr.sbin/spkrtest/spkrtest.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2002 The FreeBSD Project
# All rights reserved.
@@ -31,7 +31,6 @@
#
# Inspired on spkrtest.pl, rewritten from scratch to remove perl dependency
# $VER: spkrtest 0.3 (9.5.2002) Riccardo "VIC" Torrini <riccardo@torrini.org>
-# $FreeBSD$
#
cleanExit() {
diff --git a/usr.sbin/spray/Makefile b/usr.sbin/spray/Makefile
index f0070726c820..4342c9658f9b 100644
--- a/usr.sbin/spray/Makefile
+++ b/usr.sbin/spray/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= spray
MAN= spray.8
diff --git a/usr.sbin/spray/Makefile.depend b/usr.sbin/spray/Makefile.depend
index 5b0587ae477a..352a225b19c6 100644
--- a/usr.sbin/spray/Makefile.depend
+++ b/usr.sbin/spray/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/rpc \
include/rpcsvc \
diff --git a/usr.sbin/spray/spray.8 b/usr.sbin/spray/spray.8
index e10704886771..2e76d341ee87 100644
--- a/usr.sbin/spray/spray.8
+++ b/usr.sbin/spray/spray.8
@@ -21,8 +21,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 July 10, 1995
.Dt SPRAY 8
.Os
diff --git a/usr.sbin/spray/spray.c b/usr.sbin/spray/spray.c
index d8d25ef8a33c..436b28d32fba 100644
--- a/usr.sbin/spray/spray.c
+++ b/usr.sbin/spray/spray.c
@@ -30,11 +30,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
@@ -47,7 +42,7 @@ static const char rcsid[] =
#define SPRAYOVERHEAD 86
#endif
-static void usage(void);
+static void usage(void) __dead2;
static void print_xferstats(unsigned int, int, double);
/* spray buffer */
diff --git a/usr.sbin/syslogd/Makefile b/usr.sbin/syslogd/Makefile
index f96a72274d60..d612b5a0a6af 100644
--- a/usr.sbin/syslogd/Makefile
+++ b/usr.sbin/syslogd/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
.include <src.opts.mk>
@@ -45,4 +43,7 @@ PPPPACKAGE= ppp
CFLAGS+= -I${SRCTOP}/usr.bin/wall
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/syslogd/Makefile.depend b/usr.sbin/syslogd/Makefile.depend
index 4fc5be2a35f0..bbd6b7071809 100644
--- a/usr.sbin/syslogd/Makefile.depend
+++ b/usr.sbin/syslogd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/syslogd/ftp.conf b/usr.sbin/syslogd/ftp.conf
index d4d11cfb7a65..b70c91570567 100644
--- a/usr.sbin/syslogd/ftp.conf
+++ b/usr.sbin/syslogd/ftp.conf
@@ -1,2 +1 @@
-# $FreeBSD$
ftp.info /var/log/xferlog
diff --git a/usr.sbin/syslogd/lpr.conf b/usr.sbin/syslogd/lpr.conf
index 0eb6eb06db2a..b8a5a6c0f71b 100644
--- a/usr.sbin/syslogd/lpr.conf
+++ b/usr.sbin/syslogd/lpr.conf
@@ -1,2 +1 @@
-# $FreeBSD$
lpr.info /var/log/lpd-errs
diff --git a/usr.sbin/syslogd/pathnames.h b/usr.sbin/syslogd/pathnames.h
index 7297ba5b95d7..b70acfb07f62 100644
--- a/usr.sbin/syslogd/pathnames.h
+++ b/usr.sbin/syslogd/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/6/93
- * $FreeBSD$
*/
#define _PATH_KLOG "/dev/klog"
diff --git a/usr.sbin/syslogd/ppp.conf b/usr.sbin/syslogd/ppp.conf
index 57ee868bd142..f23f11fc3989 100644
--- a/usr.sbin/syslogd/ppp.conf
+++ b/usr.sbin/syslogd/ppp.conf
@@ -1,3 +1,2 @@
-# $FreeBSD$
!ppp
*.* /var/log/ppp.log
diff --git a/usr.sbin/syslogd/syslog.conf b/usr.sbin/syslogd/syslog.conf
index a556f309d943..d06d58a1d200 100644
--- a/usr.sbin/syslogd/syslog.conf
+++ b/usr.sbin/syslogd/syslog.conf
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
# Spaces ARE valid field separators in this file. However,
# other *nix-like systems still insist on using tabs as field
diff --git a/usr.sbin/syslogd/syslog.conf.5 b/usr.sbin/syslogd/syslog.conf.5
index 7afd6b94cdf7..691f2cdd7062 100644
--- a/usr.sbin/syslogd/syslog.conf.5
+++ b/usr.sbin/syslogd/syslog.conf.5
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)syslog.conf.5 8.1 (Berkeley) 6/9/93
-.\" $FreeBSD$
-.\"
.Dd December 10, 2020
.Dt SYSLOG.CONF 5
.Os
diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8
index c908e130f114..b23d0327b76c 100644
--- a/usr.sbin/syslogd/syslogd.8
+++ b/usr.sbin/syslogd/syslogd.8
@@ -25,9 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)syslogd.8 8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
-.\"
.Dd July 2, 2018
.Dt SYSLOGD 8
.Os
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 5c2555480d3f..7770e97e7a2d 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018 Prodrive Technologies, https://prodrive-technologies.com/
* Author: Ed Schouten <ed@FreeBSD.org>
@@ -56,21 +56,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1988, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94";
-#endif
-#endif /* not lint */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* syslogd -- log system messages
*
@@ -106,8 +91,10 @@ __FBSDID("$FreeBSD$");
#define RCVBUF_MINSIZE (80 * 1024) /* minimum size of dgram rcv buffer */
#include <sys/param.h>
+#include <sys/event.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
+#include <sys/procdesc.h>
#include <sys/queue.h>
#include <sys/resource.h>
#include <sys/socket.h>
@@ -130,10 +117,13 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
+#include <libgen.h>
#include <libutil.h>
#include <limits.h>
#include <netdb.h>
#include <paths.h>
+#include <poll.h>
+#include <regex.h>
#include <signal.h>
#include <stdbool.h>
#include <stddef.h>
@@ -143,7 +133,6 @@ __FBSDID("$FreeBSD$");
#include <sysexits.h>
#include <unistd.h>
#include <utmpx.h>
-#include <regex.h>
#include "pathnames.h"
#include "ttymsg.h"
@@ -153,7 +142,6 @@ __FBSDID("$FreeBSD$");
static const char *ConfFile = _PATH_LOGCONF;
static const char *PidFile = _PATH_LOGPID;
-static const char ctty[] = _PATH_CONSOLE;
static const char include_str[] = "include";
static const char include_ext[] = ".conf";
@@ -176,8 +164,10 @@ static const char include_ext[] = ".conf";
(((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
(((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
#endif
+
/*
- * List of peers and sockets for binding.
+ * List of peers and sockets that can't be bound until
+ * flags have been parsed.
*/
struct peer {
const char *pe_name;
@@ -187,13 +177,17 @@ struct peer {
};
static STAILQ_HEAD(, peer) pqueue = STAILQ_HEAD_INITIALIZER(pqueue);
+/*
+ * Sockets used for logging; monitored by kevent().
+ */
struct socklist {
struct addrinfo sl_ai;
#define sl_sa sl_ai.ai_addr
#define sl_salen sl_ai.ai_addrlen
#define sl_family sl_ai.ai_family
int sl_socket;
- struct peer *sl_peer;
+ char *sl_name;
+ int sl_dirfd;
int (*sl_recv)(struct socklist *);
STAILQ_ENTRY(socklist) next;
};
@@ -218,92 +212,112 @@ struct logtime {
#define RFC3164_DATELEN 15
#define RFC3164_DATEFMT "%b %e %H:%M:%S"
+enum filt_proptype {
+ FILT_PROP_NOOP,
+ FILT_PROP_MSG,
+ FILT_PROP_HOSTNAME,
+ FILT_PROP_PROGNAME,
+};
+
+enum filt_cmptype {
+ FILT_CMP_CONTAINS,
+ FILT_CMP_EQUAL,
+ FILT_CMP_STARTS,
+ FILT_CMP_REGEX,
+};
+
/*
* This structure holds a property-based filter
*/
-
struct prop_filter {
- uint8_t prop_type;
-#define PROP_TYPE_NOOP 0
-#define PROP_TYPE_MSG 1
-#define PROP_TYPE_HOSTNAME 2
-#define PROP_TYPE_PROGNAME 3
-
- uint8_t cmp_type;
-#define PROP_CMP_CONTAINS 1
-#define PROP_CMP_EQUAL 2
-#define PROP_CMP_STARTS 3
-#define PROP_CMP_REGEX 4
-
- uint16_t cmp_flags;
-#define PROP_FLAG_EXCLUDE (1 << 0)
-#define PROP_FLAG_ICASE (1 << 1)
-
+ enum filt_proptype prop_type;
+ enum filt_cmptype cmp_type;
+ uint8_t cmp_flags;
+#define FILT_FLAG_EXCLUDE (1 << 0)
+#define FILT_FLAG_ICASE (1 << 1)
union {
char *p_strval;
regex_t *p_re;
} pflt_uniptr;
#define pflt_strval pflt_uniptr.p_strval
#define pflt_re pflt_uniptr.p_re
-
size_t pflt_strlen;
};
+enum f_type {
+ F_UNUSED, /* unused entry */
+ F_FILE, /* regular file */
+ F_TTY, /* terminal */
+ F_CONSOLE, /* console terminal */
+ F_FORW, /* remote machine */
+ F_USERS, /* list of users */
+ F_WALL, /* everyone logged on */
+ F_PIPE, /* pipe to program */
+};
+
/*
* This structure represents the files that will have log
* copies printed.
* We require f_file to be valid if f_type is F_FILE, F_CONSOLE, F_TTY
* or if f_type is F_PIPE and f_pid > 0.
*/
-
struct filed {
- STAILQ_ENTRY(filed) next; /* next in linked list */
- short f_type; /* entry type, see below */
- short f_file; /* file descriptor */
- time_t f_time; /* time this was last written */
- char *f_host; /* host from which to recd. */
+ enum f_type f_type;
+
+ /* Used for filtering. */
+ char *f_host; /* host from which to recd. */
+ char *f_program; /* program this applies to */
+ struct prop_filter *f_prop_filter; /* property-based filter */
u_char f_pmask[LOG_NFACILITIES+1]; /* priority mask */
u_char f_pcmp[LOG_NFACILITIES+1]; /* compare priority */
#define PRI_LT 0x1
#define PRI_EQ 0x2
#define PRI_GT 0x4
- char *f_program; /* program this applies to */
- struct prop_filter *f_prop_filter; /* property-based filter */
+
+ /* Logging destinations. */
+ int f_file; /* file descriptor */
+ int f_flags; /* file-specific flags */
+#define FFLAG_SYNC 0x01
+#define FFLAG_NEEDSYNC 0x02
union {
- char f_uname[MAXUNAMES][MAXLOGNAME];
+ char f_uname[MAXUNAMES][MAXLOGNAME]; /* F_WALL, F_USERS */
+ char f_fname[MAXPATHLEN]; /* F_FILE, F_CONSOLE, F_TTY */
struct {
char f_hname[MAXHOSTNAMELEN];
struct addrinfo *f_addr;
-
- } f_forw; /* forwarding address */
- char f_fname[MAXPATHLEN];
+ } f_forw; /* F_FORW */
struct {
char f_pname[MAXPATHLEN];
- pid_t f_pid;
- } f_pipe;
+ int f_procdesc;
+ } f_pipe; /* F_PIPE */
} f_un;
#define fu_uname f_un.f_uname
+#define fu_fname f_un.f_fname
#define fu_forw_hname f_un.f_forw.f_hname
#define fu_forw_addr f_un.f_forw.f_addr
-#define fu_fname f_un.f_fname
#define fu_pipe_pname f_un.f_pipe.f_pname
-#define fu_pipe_pid f_un.f_pipe.f_pid
+#define fu_pipe_pd f_un.f_pipe.f_procdesc
+
+ /* Book-keeping. */
char f_prevline[MAXSVLINE]; /* last message logged */
+ time_t f_time; /* time this was last written */
struct logtime f_lasttime; /* time of last occurrence */
int f_prevpri; /* pri of f_prevline */
size_t f_prevlen; /* length of f_prevline */
int f_prevcount; /* repetition cnt of prevline */
u_int f_repeatcount; /* number of "repeated" msgs */
- int f_flags; /* file-specific flags */
-#define FFLAG_SYNC 0x01
-#define FFLAG_NEEDSYNC 0x02
+ STAILQ_ENTRY(filed) next; /* next in linked list */
};
+static STAILQ_HEAD(, filed) fhead =
+ STAILQ_HEAD_INITIALIZER(fhead); /* Log files that we write to */
+static struct filed consfile; /* Console */
+
/*
* Queue of about-to-be dead processes we should watch out for.
*/
struct deadq_entry {
- pid_t dq_pid;
+ int dq_procdesc;
int dq_timeout;
TAILQ_ENTRY(deadq_entry) dq_entries;
};
@@ -319,11 +333,10 @@ static TAILQ_HEAD(, deadq_entry) deadq_head =
#define DQ_TIMO_INIT 2
/*
- * Struct to hold records of network addresses that are allowed to log
- * to us.
+ * Network addresses that are allowed to log to us.
*/
struct allowedpeer {
- int isnumeric;
+ bool isnumeric;
u_short port;
union {
struct {
@@ -339,7 +352,6 @@ struct allowedpeer {
};
static STAILQ_HEAD(, allowedpeer) aphead = STAILQ_HEAD_INITIALIZER(aphead);
-
/*
* Intervals at which we flush out "message repeated" messages,
* in seconds after previous message is logged. After each flush,
@@ -353,34 +365,37 @@ static int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */
(f)->f_repeatcount = MAXREPEAT; \
} while (0)
-/* values for f_type */
-#define F_UNUSED 0 /* unused entry */
-#define F_FILE 1 /* regular file */
-#define F_TTY 2 /* terminal */
-#define F_CONSOLE 3 /* console terminal */
-#define F_FORW 4 /* remote machine */
-#define F_USERS 5 /* list of users */
-#define F_WALL 6 /* everyone logged on */
-#define F_PIPE 7 /* pipe to program */
-
static const char *TypeNames[] = {
- "UNUSED", "FILE", "TTY", "CONSOLE",
- "FORW", "USERS", "WALL", "PIPE"
+ "UNUSED",
+ "FILE",
+ "TTY",
+ "CONSOLE",
+ "FORW",
+ "USERS",
+ "WALL",
+ "PIPE",
};
-static STAILQ_HEAD(, filed) fhead =
- STAILQ_HEAD_INITIALIZER(fhead); /* Log files that we write to */
-static struct filed consfile; /* Console */
+static const int sigcatch[] = {
+ SIGHUP,
+ SIGINT,
+ SIGQUIT,
+ SIGPIPE,
+ SIGALRM,
+ SIGTERM,
+ SIGCHLD,
+};
-static int Debug; /* debug flag */
-static int Foreground = 0; /* Run in foreground, instead of daemonizing */
-static int resolve = 1; /* resolve hostname */
+static int nulldesc; /* /dev/null descriptor */
+static bool Debug; /* debug flag */
+static bool Foreground = false; /* Run in foreground, instead of daemonizing */
+static bool resolve = true; /* resolve hostname */
static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */
static const char *LocalDomain; /* our local domain name */
-static int Initialized; /* set when we have initialized ourselves */
+static bool Initialized; /* set when we have initialized ourselves */
static int MarkInterval = 20 * 60; /* interval between marks in seconds */
static int MarkSeq; /* mark sequence number */
-static int NoBind; /* don't bind() as suggested by RFC 3164 */
+static bool NoBind; /* don't bind() as suggested by RFC 3164 */
static int SecureMode; /* when true, receive only unix domain socks */
static int MaxForwardLen = 1024; /* max length of forwared message */
#ifdef INET6
@@ -396,68 +411,54 @@ static int logflags = O_WRONLY|O_APPEND; /* flags used to open log files */
static char bootfile[MAXPATHLEN]; /* booted kernel file */
-static int RemoteAddDate; /* Always set the date on remote messages */
-static int RemoteHostname; /* Log remote hostname from the message */
+static bool RemoteAddDate; /* Always set the date on remote messages */
+static bool RemoteHostname; /* Log remote hostname from the message */
-static int UniquePriority; /* Only log specified priority? */
+static bool UniquePriority; /* Only log specified priority? */
static int LogFacPri; /* Put facility and priority in log message: */
/* 0=no, 1=numeric, 2=names */
-static int KeepKernFac; /* Keep remotely logged kernel facility */
-static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */
+static bool KeepKernFac; /* Keep remotely logged kernel facility */
+static bool needdofsync = true; /* Are any file(s) waiting to be fsynced? */
static struct pidfh *pfh;
-static int sigpipe[2]; /* Pipe to catch a signal during select(). */
static bool RFC3164OutputFormat = true; /* Use legacy format by default. */
-static volatile sig_atomic_t MarkSet, WantDie, WantInitialize, WantReapchild;
-
struct iovlist;
-static int allowaddr(char *);
-static int addfile(struct filed *);
-static int addpeer(struct peer *);
-static int addsock(struct addrinfo *, struct socklist *);
-static struct filed *cfline(const char *, const char *, const char *,
- const char *);
+static bool allowaddr(char *);
+static void addpeer(const char *, const char *, mode_t);
+static void addsock(const char *, const char *, mode_t);
+static void cfline(const char *, const char *, const char *, const char *);
static const char *cvthname(struct sockaddr *);
-static void deadq_enter(pid_t, const char *);
-static int deadq_remove(struct deadq_entry *);
-static int deadq_removebypid(pid_t);
+static void deadq_enter(int);
+static void deadq_remove(struct deadq_entry *);
static int decode(const char *, const CODE *);
static void die(int) __dead2;
-static void dodie(int);
static void dofsync(void);
-static void domark(int);
static void fprintlog_first(struct filed *, const char *, const char *,
const char *, const char *, const char *, const char *, int);
static void fprintlog_write(struct filed *, struct iovlist *, int);
static void fprintlog_successive(struct filed *, int);
-static void init(int);
+static void init(bool);
static void logerror(const char *);
static void logmsg(int, const struct logtime *, const char *, const char *,
const char *, const char *, const char *, const char *, int);
-static void log_deadchild(pid_t, int, const char *);
static void markit(void);
-static int socksetup(struct peer *);
+static struct socklist *socksetup(struct addrinfo *, const char *, mode_t);
static int socklist_recv_file(struct socklist *);
static int socklist_recv_sock(struct socklist *);
-static int socklist_recv_signal(struct socklist *);
-static void sighandler(int);
static int skip_message(const char *, const char *, int);
static int evaluate_prop_filter(const struct prop_filter *filter,
const char *value);
-static int prop_filter_compile(struct prop_filter *pfilter,
- char *filterstr);
+static struct prop_filter *prop_filter_compile(const char *);
static void parsemsg(const char *, char *);
static void printsys(char *);
static int p_open(const char *, pid_t *);
-static void reapchild(int);
static const char *ttymsg_check(struct iovec *, int, char *, int);
static void usage(void);
-static int validate(struct sockaddr *, const char *);
+static bool validate(struct sockaddr *, const char *);
static void unmapped(struct sockaddr *);
static void wallmsg(struct filed *, struct iovec *, const int iovlen);
static int waitdaemon(int);
-static void timedout(int);
static void increase_rcvbuf(int);
static void
@@ -474,81 +475,121 @@ close_filed(struct filed *f)
f->fu_forw_addr = NULL;
}
/* FALLTHROUGH */
-
case F_FILE:
case F_TTY:
case F_CONSOLE:
f->f_type = F_UNUSED;
break;
case F_PIPE:
- f->fu_pipe_pid = 0;
+ if (f->fu_pipe_pd >= 0) {
+ deadq_enter(f->fu_pipe_pd);
+ f->fu_pipe_pd = -1;
+ }
+ break;
+ default:
break;
}
(void)close(f->f_file);
f->f_file = -1;
}
-static int
-addfile(struct filed *f0)
-{
- struct filed *f;
-
- f = calloc(1, sizeof(*f));
- if (f == NULL)
- err(1, "malloc failed");
- *f = *f0;
- STAILQ_INSERT_TAIL(&fhead, f, next);
-
- return (0);
-}
-
-static int
-addpeer(struct peer *pe0)
+static void
+addpeer(const char *name, const char *serv, mode_t mode)
{
- struct peer *pe;
-
- pe = calloc(1, sizeof(*pe));
+ struct peer *pe = calloc(1, sizeof(*pe));
if (pe == NULL)
err(1, "malloc failed");
- *pe = *pe0;
+ pe->pe_name = name;
+ pe->pe_serv = serv;
+ pe->pe_mode = mode;
STAILQ_INSERT_TAIL(&pqueue, pe, next);
-
- return (0);
}
-static int
-addsock(struct addrinfo *ai, struct socklist *sl0)
+static void
+addsock(const char *name, const char *serv, mode_t mode)
{
+ struct addrinfo hints = { }, *res, *res0;
struct socklist *sl;
+ int error;
+ char *cp, *msgbuf;
- /* Copy *ai->ai_addr to the tail of struct socklist if any. */
- sl = calloc(1, sizeof(*sl) + ((ai != NULL) ? ai->ai_addrlen : 0));
+ /*
+ * We have to handle this case for backwards compatibility:
+ * If there are two (or more) colons but no '[' and ']',
+ * assume this is an inet6 address without a service.
+ */
+ if (name != NULL) {
+#ifdef INET6
+ if (name[0] == '[' &&
+ (cp = strchr(name + 1, ']')) != NULL) {
+ name = &name[1];
+ *cp = '\0';
+ if (cp[1] == ':' && cp[2] != '\0')
+ serv = cp + 2;
+ } else {
+#endif
+ cp = strchr(name, ':');
+ if (cp != NULL && strchr(cp + 1, ':') == NULL) {
+ *cp = '\0';
+ if (cp[1] != '\0')
+ serv = cp + 1;
+ if (cp == name)
+ name = NULL;
+ }
+#ifdef INET6
+ }
+#endif
+ }
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_flags = AI_PASSIVE;
+ if (name != NULL)
+ dprintf("Trying peer: %s\n", name);
+ if (serv == NULL)
+ serv = "syslog";
+ error = getaddrinfo(name, serv, &hints, &res0);
+ if (error) {
+ asprintf(&msgbuf, "getaddrinfo failed for %s%s: %s",
+ name == NULL ? "" : name, serv,
+ gai_strerror(error));
+ errno = 0;
+ if (msgbuf == NULL)
+ logerror(gai_strerror(error));
+ else
+ logerror(msgbuf);
+ free(msgbuf);
+ die(0);
+ }
+ for (res = res0; res != NULL; res = res->ai_next) {
+ sl = socksetup(res, name, mode);
+ if (sl == NULL)
+ continue;
+ STAILQ_INSERT_TAIL(&shead, sl, next);
+ }
+ freeaddrinfo(res0);
+}
+
+static void
+addfile(int fd)
+{
+ struct socklist *sl = calloc(1, sizeof(*sl));
if (sl == NULL)
err(1, "malloc failed");
- *sl = *sl0;
- if (ai != NULL) {
- memcpy(&sl->sl_ai, ai, sizeof(*ai));
- if (ai->ai_addrlen > 0) {
- memcpy((sl + 1), ai->ai_addr, ai->ai_addrlen);
- sl->sl_sa = (struct sockaddr *)(sl + 1);
- } else
- sl->sl_sa = NULL;
- }
+ sl->sl_socket = fd;
+ sl->sl_recv = socklist_recv_file;
STAILQ_INSERT_TAIL(&shead, sl, next);
-
- return (0);
}
int
main(int argc, char *argv[])
{
- int ch, i, s, fdsrmax = 0, bflag = 0, pflag = 0, Sflag = 0;
- fd_set *fdsr = NULL;
- struct timeval tv, *tvp;
- struct peer *pe;
+ struct sigaction act = { };
+ struct kevent ev;
struct socklist *sl;
- pid_t ppid = 1, spid;
+ pid_t spid;
+ int ch, kq, ppipe_w = -1, s;
char *p;
+ bool bflag = false, pflag = false, Sflag = false;
if (madvise(NULL, 0, MADV_PROTECT) != 0)
dprintf("madvise() failed: %s\n", strerror(errno));
@@ -570,14 +611,14 @@ main(int argc, char *argv[])
mask_C1 = 0;
break;
case 'A':
- send_to_all++;
+ send_to_all = true;
break;
case 'a': /* allow specific network addresses only */
- if (allowaddr(optarg) == -1)
+ if (!allowaddr(optarg))
usage();
break;
case 'b':
- bflag = 1;
+ bflag = true;
p = strchr(optarg, ']');
if (p != NULL)
p = strchr(p + 1, ':');
@@ -588,18 +629,12 @@ main(int argc, char *argv[])
}
if (p == NULL) {
/* A hostname or filename only. */
- addpeer(&(struct peer){
- .pe_name = optarg,
- .pe_serv = "syslog"
- });
+ addpeer(optarg, "syslog", 0);
} else {
/* The case of "name:service". */
*p++ = '\0';
- addpeer(&(struct peer){
- .pe_serv = p,
- .pe_name = (strlen(optarg) == 0) ?
- NULL : optarg,
- });
+ addpeer(strlen(optarg) == 0 ? NULL : optarg,
+ p, 0);
}
break;
case 'c':
@@ -609,19 +644,19 @@ main(int argc, char *argv[])
logflags |= O_CREAT;
break;
case 'd': /* debug */
- Debug++;
+ Debug = true;
break;
case 'f': /* configuration file */
ConfFile = optarg;
break;
case 'F': /* run in foreground instead of daemon */
- Foreground++;
+ Foreground = true;
break;
case 'H':
- RemoteHostname = 1;
+ RemoteHostname = true;
break;
case 'k': /* keep remote kern fac */
- KeepKernFac = 1;
+ KeepKernFac = true;
break;
case 'l':
case 'p':
@@ -635,10 +670,10 @@ main(int argc, char *argv[])
mode = DEFFILEMODE;
else if (ch == 'p') {
mode = DEFFILEMODE;
- pflag = 1;
+ pflag = true;
} else {
mode = S_IRUSR | S_IWUSR;
- Sflag = 1;
+ Sflag = true;
}
if (optarg[0] == '/')
name = optarg;
@@ -660,10 +695,7 @@ main(int argc, char *argv[])
} else
errx(1, "invalid filename %s, exiting",
optarg);
- addpeer(&(struct peer){
- .pe_name = name,
- .pe_mode = mode
- });
+ addpeer(name, NULL, mode);
break;
}
case 'M': /* max length of forwarded message */
@@ -676,12 +708,12 @@ main(int argc, char *argv[])
MarkInterval = atoi(optarg) * 60;
break;
case 'N':
- NoBind = 1;
+ NoBind = true;
if (!SecureMode)
SecureMode = 1;
break;
case 'n':
- resolve = 0;
+ resolve = false;
break;
case 'O':
if (strcmp(optarg, "bsd") == 0 ||
@@ -694,7 +726,7 @@ main(int argc, char *argv[])
usage();
break;
case 'o':
- use_bootfile = 1;
+ use_bootfile = true;
break;
case 'P': /* path for alt. PID */
PidFile = optarg;
@@ -703,10 +735,10 @@ main(int argc, char *argv[])
SecureMode++;
break;
case 'T':
- RemoteAddDate = 1;
+ RemoteAddDate = true;
break;
case 'u': /* only log specified priority */
- UniquePriority++;
+ UniquePriority = true;
break;
case 'v': /* log facility and priority */
LogFacPri++;
@@ -720,170 +752,145 @@ main(int argc, char *argv[])
if (RFC3164OutputFormat && MaxForwardLen > 1024)
errx(1, "RFC 3164 messages may not exceed 1024 bytes");
- /* Pipe to catch a signal during select(). */
- s = pipe2(sigpipe, O_CLOEXEC);
- if (s < 0) {
- err(1, "cannot open a pipe for signals");
- } else {
- addsock(NULL, &(struct socklist){
- .sl_socket = sigpipe[0],
- .sl_recv = socklist_recv_signal
- });
+ pfh = pidfile_open(PidFile, 0600, &spid);
+ if (pfh == NULL) {
+ if (errno == EEXIST)
+ errx(1, "syslogd already running, pid: %d", spid);
+ warn("cannot open pid file");
}
+ /*
+ * Now that flags have been parsed, we know if we're in
+ * secure mode. Add peers to the socklist, if allowed.
+ */
+ while (!STAILQ_EMPTY(&pqueue)) {
+ struct peer *pe = STAILQ_FIRST(&pqueue);
+ STAILQ_REMOVE_HEAD(&pqueue, next);
+ addsock(pe->pe_name, pe->pe_serv, pe->pe_mode);
+ free(pe);
+ }
/* Listen by default: /dev/klog. */
s = open(_PATH_KLOG, O_RDONLY | O_NONBLOCK | O_CLOEXEC, 0);
if (s < 0) {
dprintf("can't open %s (%d)\n", _PATH_KLOG, errno);
} else {
- addsock(NULL, &(struct socklist){
- .sl_socket = s,
- .sl_recv = socklist_recv_file,
- });
+ addfile(s);
}
/* Listen by default: *:514 if no -b flag. */
if (bflag == 0)
- addpeer(&(struct peer){
- .pe_serv = "syslog"
- });
+ addsock(NULL, "syslog", 0);
/* Listen by default: /var/run/log if no -p flag. */
if (pflag == 0)
- addpeer(&(struct peer){
- .pe_name = _PATH_LOG,
- .pe_mode = DEFFILEMODE,
- });
+ addsock(_PATH_LOG, NULL, DEFFILEMODE);
/* Listen by default: /var/run/logpriv if no -S flag. */
if (Sflag == 0)
- addpeer(&(struct peer){
- .pe_name = _PATH_LOG_PRIV,
- .pe_mode = S_IRUSR | S_IWUSR,
- });
- STAILQ_FOREACH(pe, &pqueue, next)
- socksetup(pe);
+ addsock(_PATH_LOG_PRIV, NULL, S_IRUSR | S_IWUSR);
- pfh = pidfile_open(PidFile, 0600, &spid);
- if (pfh == NULL) {
- if (errno == EEXIST)
- errx(1, "syslogd already running, pid: %d", spid);
- warn("cannot open pid file");
+ consfile.f_type = F_CONSOLE;
+ consfile.f_file = -1;
+ (void)strlcpy(consfile.fu_fname, _PATH_CONSOLE + sizeof(_PATH_DEV) - 1,
+ sizeof(consfile.fu_fname));
+
+ nulldesc = open(_PATH_DEVNULL, O_RDWR);
+ if (nulldesc == -1) {
+ warn("cannot open %s", _PATH_DEVNULL);
+ pidfile_remove(pfh);
+ exit(1);
}
- if ((!Foreground) && (!Debug)) {
- ppid = waitdaemon(30);
- if (ppid < 0) {
- warn("could not become daemon");
+ (void)strlcpy(bootfile, getbootfile(), sizeof(bootfile));
+
+ if (!Foreground && !Debug)
+ ppipe_w = waitdaemon(30);
+ else if (Debug)
+ setlinebuf(stdout);
+
+ kq = kqueue();
+ if (kq == -1) {
+ warn("failed to initialize kqueue");
+ pidfile_remove(pfh);
+ exit(1);
+ }
+ STAILQ_FOREACH(sl, &shead, next) {
+ if (sl->sl_recv == NULL)
+ continue;
+ EV_SET(&ev, sl->sl_socket, EVFILT_READ, EV_ADD, 0, 0, sl);
+ if (kevent(kq, &ev, 1, NULL, 0, NULL) == -1) {
+ warn("failed to add kevent to kqueue");
pidfile_remove(pfh);
exit(1);
}
- } else if (Debug)
- setlinebuf(stdout);
+ }
- consfile.f_type = F_CONSOLE;
- (void)strlcpy(consfile.fu_fname, ctty + sizeof _PATH_DEV - 1,
- sizeof(consfile.fu_fname));
- (void)strlcpy(bootfile, getbootfile(), sizeof(bootfile));
- (void)signal(SIGTERM, dodie);
- (void)signal(SIGINT, Debug ? dodie : SIG_IGN);
- (void)signal(SIGQUIT, Debug ? dodie : SIG_IGN);
- (void)signal(SIGHUP, sighandler);
- (void)signal(SIGCHLD, sighandler);
- (void)signal(SIGALRM, domark);
- (void)signal(SIGPIPE, SIG_IGN); /* We'll catch EPIPE instead. */
+ /*
+ * Syslogd will not reap its children via wait().
+ * When SIGCHLD is ignored, zombie processes are
+ * not created. A child's PID will be recycled
+ * upon its exit.
+ */
+ act.sa_handler = SIG_IGN;
+ for (size_t i = 0; i < nitems(sigcatch); ++i) {
+ EV_SET(&ev, sigcatch[i], EVFILT_SIGNAL, EV_ADD, 0, 0, NULL);
+ if (kevent(kq, &ev, 1, NULL, 0, NULL) == -1) {
+ warn("failed to add kevent to kqueue");
+ pidfile_remove(pfh);
+ exit(1);
+ }
+ if (sigaction(sigcatch[i], &act, NULL) == -1) {
+ warn("failed to apply signal handler");
+ pidfile_remove(pfh);
+ exit(1);
+ }
+ }
(void)alarm(TIMERINTVL);
/* tuck my process id away */
pidfile_write(pfh);
dprintf("off & running....\n");
-
- tvp = &tv;
- tv.tv_sec = tv.tv_usec = 0;
-
- STAILQ_FOREACH(sl, &shead, next) {
- if (sl->sl_socket > fdsrmax)
- fdsrmax = sl->sl_socket;
- }
- fdsr = (fd_set *)calloc(howmany(fdsrmax+1, NFDBITS),
- sizeof(*fdsr));
- if (fdsr == NULL)
- errx(1, "calloc fd_set");
-
+ init(false);
for (;;) {
- if (Initialized == 0)
- init(0);
- else if (WantInitialize)
- init(WantInitialize);
- if (WantReapchild)
- reapchild(WantReapchild);
- if (MarkSet)
- markit();
- if (WantDie) {
- free(fdsr);
- die(WantDie);
- }
-
- bzero(fdsr, howmany(fdsrmax+1, NFDBITS) *
- sizeof(*fdsr));
-
- STAILQ_FOREACH(sl, &shead, next) {
- if (sl->sl_socket != -1 && sl->sl_recv != NULL)
- FD_SET(sl->sl_socket, fdsr);
- }
- i = select(fdsrmax + 1, fdsr, NULL, NULL,
- needdofsync ? &tv : tvp);
- switch (i) {
- case 0:
+ if (needdofsync) {
dofsync();
- needdofsync = 0;
- if (tvp) {
- tvp = NULL;
- if (ppid != 1)
- kill(ppid, SIGALRM);
+ if (ppipe_w != -1) {
+ /*
+ * Close our end of the pipe so our
+ * parent knows that we have finished
+ * initialization.
+ */
+ (void)close(ppipe_w);
+ ppipe_w = -1;
}
- continue;
- case -1:
+ }
+ if (kevent(kq, NULL, 0, &ev, 1, NULL) == -1) {
if (errno != EINTR)
- logerror("select");
+ logerror("kevent");
continue;
}
- STAILQ_FOREACH(sl, &shead, next) {
- if (FD_ISSET(sl->sl_socket, fdsr))
- (*sl->sl_recv)(sl);
- }
- }
- free(fdsr);
-}
-
-static int
-socklist_recv_signal(struct socklist *sl __unused)
-{
- ssize_t len;
- int i, nsig, signo;
-
- if (ioctl(sigpipe[0], FIONREAD, &i) != 0) {
- logerror("ioctl(FIONREAD)");
- err(1, "signal pipe read failed");
- }
- nsig = i / sizeof(signo);
- dprintf("# of received signals = %d\n", nsig);
- for (i = 0; i < nsig; i++) {
- len = read(sigpipe[0], &signo, sizeof(signo));
- if (len != sizeof(signo)) {
- logerror("signal pipe read failed");
- err(1, "signal pipe read failed");
- }
- dprintf("Received signal: %d from fd=%d\n", signo,
- sigpipe[0]);
- switch (signo) {
- case SIGHUP:
- WantInitialize = 1;
+ switch (ev.filter) {
+ case EVFILT_READ:
+ sl = ev.udata;
+ if (sl->sl_socket != -1 && sl->sl_recv != NULL)
+ sl->sl_recv(sl);
break;
- case SIGCHLD:
- WantReapchild = 1;
+ case EVFILT_SIGNAL:
+ switch (ev.ident) {
+ case SIGHUP:
+ init(true);
+ break;
+ case SIGINT:
+ case SIGQUIT:
+ case SIGTERM:
+ if (ev.ident == SIGTERM || Debug)
+ die(ev.ident);
+ break;
+ case SIGALRM:
+ markit();
+ break;
+ }
break;
}
}
- return (0);
}
static int
@@ -1123,6 +1130,7 @@ parsemsg_rfc5424(const char *from, int pri, char *msg)
FAIL_IF("STRUCTURED-NAME", start == msg); \
} while (0)
IF_NOT_NILVALUE(structured_data) {
+ structured_data = msg;
/* SD-ELEMENT. */
while (*msg == '[') {
++msg;
@@ -1486,7 +1494,7 @@ skip_message(const char *name, const char *spec, int checkcase)
/* Behaviour on explicit match */
if (spec == NULL)
- return 0;
+ return (0);
switch (*spec) {
case '-':
exclude = 1;
@@ -1509,12 +1517,12 @@ skip_message(const char *name, const char *spec, int checkcase)
if (prev == ',' && (next == '\0' || next == ','))
/* Explicit match: skip iff the spec is an
exclusive one. */
- return exclude;
+ return (exclude);
}
/* No explicit match for this name: skip the message iff
the spec is an inclusive one. */
- return !exclude;
+ return (!exclude);
}
/*
@@ -1526,13 +1534,13 @@ static int
evaluate_prop_filter(const struct prop_filter *filter, const char *value)
{
const char *s = NULL;
- const int exclude = ((filter->cmp_flags & PROP_FLAG_EXCLUDE) > 0);
+ const int exclude = ((filter->cmp_flags & FILT_FLAG_EXCLUDE) > 0);
size_t valuelen;
if (value == NULL)
return (-1);
- if (filter->cmp_type == PROP_CMP_REGEX) {
+ if (filter->cmp_type == FILT_CMP_REGEX) {
if (regexec(filter->pflt_re, value, 0, NULL, 0) == 0)
return (exclude);
else
@@ -1542,31 +1550,31 @@ evaluate_prop_filter(const struct prop_filter *filter, const char *value)
valuelen = strlen(value);
/* a shortcut for equal with different length is always false */
- if (filter->cmp_type == PROP_CMP_EQUAL &&
+ if (filter->cmp_type == FILT_CMP_EQUAL &&
valuelen != filter->pflt_strlen)
return (!exclude);
- if (filter->cmp_flags & PROP_FLAG_ICASE)
+ if (filter->cmp_flags & FILT_FLAG_ICASE)
s = strcasestr(value, filter->pflt_strval);
else
s = strstr(value, filter->pflt_strval);
/*
- * PROP_CMP_CONTAINS true if s
- * PROP_CMP_STARTS true if s && s == value
- * PROP_CMP_EQUAL true if s && s == value &&
+ * FILT_CMP_CONTAINS true if s
+ * FILT_CMP_STARTS true if s && s == value
+ * FILT_CMP_EQUAL true if s && s == value &&
* valuelen == filter->pflt_strlen
* (and length match is checked
* already)
*/
switch (filter->cmp_type) {
- case PROP_CMP_STARTS:
- case PROP_CMP_EQUAL:
+ case FILT_CMP_STARTS:
+ case FILT_CMP_EQUAL:
if (s != value)
return (!exclude);
/* FALLTHROUGH */
- case PROP_CMP_CONTAINS:
+ case FILT_CMP_CONTAINS:
if (s)
return (exclude);
else
@@ -1582,9 +1590,8 @@ evaluate_prop_filter(const struct prop_filter *filter, const char *value)
/*
* Logs a message to the appropriate log files, users, etc. based on the
- * priority. Log messages are always formatted according to RFC 3164,
- * even if they were in RFC 5424 format originally, The MSGID and
- * STRUCTURED-DATA fields are thus discarded for the time being.
+ * priority. Log messages are formatted according to RFC 3164 or
+ * RFC 5424 in subsequent fprintlog_*() functions.
*/
static void
logmsg(int pri, const struct logtime *timestamp, const char *hostname,
@@ -1640,20 +1647,9 @@ logmsg(int pri, const struct logtime *timestamp, const char *hostname,
/* log the message to the particular outputs */
if (!Initialized) {
- f = &consfile;
- /*
- * Open in non-blocking mode to avoid hangs during open
- * and close(waiting for the port to drain).
- */
- f->f_file = open(ctty, O_WRONLY | O_NONBLOCK, 0);
-
- if (f->f_file >= 0) {
- f->f_lasttime = *timestamp;
- fprintlog_first(f, hostname, app_name, procid, msgid,
- structured_data, msg, flags);
- close(f->f_file);
- f->f_file = -1;
- }
+ consfile.f_lasttime = *timestamp;
+ fprintlog_first(&consfile, hostname, app_name, procid,
+ msgid, structured_data, msg, flags);
return;
}
@@ -1693,19 +1689,19 @@ logmsg(int pri, const struct logtime *timestamp, const char *hostname,
/* skip messages if a property does not match filter */
if (f->f_prop_filter != NULL &&
- f->f_prop_filter->prop_type != PROP_TYPE_NOOP) {
+ f->f_prop_filter->prop_type != FILT_PROP_NOOP) {
switch (f->f_prop_filter->prop_type) {
- case PROP_TYPE_MSG:
+ case FILT_PROP_MSG:
if (evaluate_prop_filter(f->f_prop_filter,
msg))
continue;
break;
- case PROP_TYPE_HOSTNAME:
+ case FILT_PROP_HOSTNAME:
if (evaluate_prop_filter(f->f_prop_filter,
hostname))
continue;
break;
- case PROP_TYPE_PROGNAME:
+ case FILT_PROP_PROGNAME:
if (evaluate_prop_filter(f->f_prop_filter,
app_name == NULL ? "" : app_name))
continue;
@@ -1767,12 +1763,13 @@ dofsync(void)
struct filed *f;
STAILQ_FOREACH(f, &fhead, next) {
- if ((f->f_type == F_FILE) &&
- (f->f_flags & FFLAG_NEEDSYNC)) {
+ if (f->f_type == F_FILE &&
+ (f->f_flags & FFLAG_NEEDSYNC) != 0) {
f->f_flags &= ~FFLAG_NEEDSYNC;
(void)fsync(f->f_file);
}
}
+ needdofsync = false;
}
/*
@@ -1933,27 +1930,23 @@ fprintlog_write(struct filed *f, struct iovlist *il, int flags)
}
} else if ((flags & SYNC_FILE) && (f->f_flags & FFLAG_SYNC)) {
f->f_flags |= FFLAG_NEEDSYNC;
- needdofsync = 1;
+ needdofsync = true;
}
break;
case F_PIPE:
dprintf(" %s\n", f->fu_pipe_pname);
iovlist_append(il, "\n");
- if (f->fu_pipe_pid == 0) {
+ if (f->fu_pipe_pd == -1) {
if ((f->f_file = p_open(f->fu_pipe_pname,
- &f->fu_pipe_pid)) < 0) {
+ &f->fu_pipe_pd)) < 0) {
logerror(f->fu_pipe_pname);
break;
}
}
if (writev(f->f_file, il->iov, il->iovcnt) < 0) {
- int e = errno;
-
- deadq_enter(f->fu_pipe_pid, f->fu_pipe_pname);
- close_filed(f);
- errno = e;
logerror(f->fu_pipe_pname);
+ close_filed(f);
}
break;
@@ -1980,6 +1973,8 @@ fprintlog_write(struct filed *f, struct iovlist *il, int flags)
iovlist_append(il, "\r\n");
wallmsg(f, il->iov, il->iovcnt);
break;
+ default:
+ break;
}
}
@@ -2247,32 +2242,7 @@ ttymsg_check(struct iovec *iov, int iovcnt, char *line, int tmout)
if ((sb.st_mode & S_IWGRP) == 0)
/* Messages disabled. */
return (NULL);
- return ttymsg(iov, iovcnt, line, tmout);
-}
-
-static void
-reapchild(int signo __unused)
-{
- int status;
- pid_t pid;
- struct filed *f;
-
- while ((pid = wait3(&status, WNOHANG, (struct rusage *)NULL)) > 0) {
- /* First, look if it's a process from the dead queue. */
- if (deadq_removebypid(pid))
- continue;
-
- /* Now, look in list of active processes. */
- STAILQ_FOREACH(f, &fhead, next) {
- if (f->f_type == F_PIPE &&
- f->fu_pipe_pid == pid) {
- close_filed(f);
- log_deadchild(pid, status, f->fu_pipe_pname);
- break;
- }
- }
- }
- WantReapchild = 0;
+ return (ttymsg(iov, iovcnt, line, tmout));
}
/*
@@ -2311,20 +2281,6 @@ cvthname(struct sockaddr *f)
return (hname);
}
-static void
-dodie(int signo)
-{
-
- WantDie = signo;
-}
-
-static void
-domark(int signo __unused)
-{
-
- MarkSet = 1;
-}
-
/*
* Print syslogd errors some place.
*/
@@ -2344,7 +2300,7 @@ logerror(const char *msg)
msg = buf;
}
errno = 0;
- dprintf("%s\n", buf);
+ dprintf("%s\n", msg);
logmsg(LOG_SYSLOG|LOG_ERR, NULL, LocalHostName, "syslogd", NULL, NULL,
NULL, msg, 0);
recursed--;
@@ -2361,7 +2317,8 @@ die(int signo)
/* flush any pending output */
if (f->f_prevcount)
fprintlog_successive(f, 0);
- if (f->f_type == F_PIPE && f->fu_pipe_pid > 0)
+ /* close our end of the pipe */
+ if (f->f_type == F_PIPE)
close_filed(f);
}
if (signo) {
@@ -2371,8 +2328,12 @@ die(int signo)
logerror(buf);
}
STAILQ_FOREACH(sl, &shead, next) {
- if (sl->sl_sa != NULL && sl->sl_family == AF_LOCAL)
- unlink(sl->sl_peer->pe_name);
+ if (sl->sl_sa != NULL && sl->sl_family == AF_LOCAL) {
+ if (unlinkat(sl->sl_dirfd, sl->sl_name, 0) == -1) {
+ dprintf("Failed to unlink %s: %s", sl->sl_name,
+ strerror(errno));
+ }
+ }
}
pidfile_remove(pfh);
@@ -2401,10 +2362,9 @@ configfiles(const struct dirent *dp)
}
static void
-readconfigfile(FILE *cf, int allow_includes)
+parseconfigfile(FILE *cf, bool allow_includes)
{
FILE *cf2;
- struct filed *f;
struct dirent **ent;
char cline[LINE_MAX];
char host[MAXHOSTNAMELEN];
@@ -2418,7 +2378,7 @@ readconfigfile(FILE *cf, int allow_includes)
/*
* Foreach line in the conf table, open that file.
*/
- include_len = sizeof(include_str) -1;
+ include_len = sizeof(include_str) - 1;
(void)strlcpy(host, "*", sizeof(host));
(void)strlcpy(prog, "*", sizeof(prog));
(void)strlcpy(pfilter, "*", sizeof(pfilter));
@@ -2430,7 +2390,7 @@ readconfigfile(FILE *cf, int allow_includes)
*/
for (p = cline; isspace(*p); ++p)
continue;
- if (*p == 0)
+ if (*p == '\0')
continue;
if (allow_includes &&
strncmp(p, include_str, include_len) == 0 &&
@@ -2462,7 +2422,7 @@ readconfigfile(FILE *cf, int allow_includes)
if (cf2 == NULL)
continue;
dprintf("reading %s\n", file);
- readconfigfile(cf2, 0);
+ parseconfigfile(cf2, false);
fclose(cf2);
}
free(ent);
@@ -2477,7 +2437,7 @@ readconfigfile(FILE *cf, int allow_includes)
host[0] = *p++;
while (isspace(*p))
p++;
- if ((!*p) || (*p == '*')) {
+ if (*p == '\0' || *p == '*') {
(void)strlcpy(host, "*", sizeof(host));
continue;
}
@@ -2494,8 +2454,9 @@ readconfigfile(FILE *cf, int allow_includes)
}
if (*p == '!') {
p++;
- while (isspace(*p)) p++;
- if ((!*p) || (*p == '*')) {
+ while (isspace(*p))
+ p++;
+ if (*p == '\0' || *p == '*') {
(void)strlcpy(prog, "*", sizeof(prog));
continue;
}
@@ -2504,14 +2465,14 @@ readconfigfile(FILE *cf, int allow_includes)
break;
prog[i] = p[i];
}
- prog[i] = 0;
+ prog[i] = '\0';
continue;
}
if (*p == ':') {
p++;
while (isspace(*p))
p++;
- if ((!*p) || (*p == '*')) {
+ if (*p == '\0' || *p == '*') {
(void)strlcpy(pfilter, "*", sizeof(pfilter));
continue;
}
@@ -2531,42 +2492,91 @@ readconfigfile(FILE *cf, int allow_includes)
}
for (i = strlen(cline) - 1; i >= 0 && isspace(cline[i]); i--)
cline[i] = '\0';
- f = cfline(cline, prog, host, pfilter);
- if (f != NULL)
- addfile(f);
- free(f);
+ cfline(cline, prog, host, pfilter);
}
}
static void
-sighandler(int signo)
+readconfigfile(const char *path)
{
+ FILE *cf;
- /* Send an wake-up signal to the select() loop. */
- write(sigpipe[1], &signo, sizeof(signo));
+ if ((cf = fopen(path, "r")) != NULL) {
+ parseconfigfile(cf, true);
+ (void)fclose(cf);
+ } else {
+ dprintf("cannot open %s\n", ConfFile);
+ cfline("*.ERR\t/dev/console", "*", "*", "*");
+ cfline("*.PANIC\t*", "*", "*", "*");
+ }
+}
+
+/*
+ * Close all open log files.
+ */
+static void
+closelogfiles(void)
+{
+ struct filed *f;
+
+ while (!STAILQ_EMPTY(&fhead)) {
+ f = STAILQ_FIRST(&fhead);
+ STAILQ_REMOVE_HEAD(&fhead, next);
+
+ /* flush any pending output */
+ if (f->f_prevcount)
+ fprintlog_successive(f, 0);
+
+ switch (f->f_type) {
+ case F_FILE:
+ case F_FORW:
+ case F_CONSOLE:
+ case F_TTY:
+ case F_PIPE:
+ close_filed(f);
+ break;
+ default:
+ break;
+ }
+
+ free(f->f_program);
+ free(f->f_host);
+ if (f->f_prop_filter) {
+ switch (f->f_prop_filter->cmp_type) {
+ case FILT_CMP_REGEX:
+ regfree(f->f_prop_filter->pflt_re);
+ free(f->f_prop_filter->pflt_re);
+ break;
+ case FILT_CMP_CONTAINS:
+ case FILT_CMP_EQUAL:
+ case FILT_CMP_STARTS:
+ free(f->f_prop_filter->pflt_strval);
+ break;
+ }
+ free(f->f_prop_filter);
+ }
+ free(f);
+ }
}
/*
* INIT -- Initialize syslogd from configuration table
*/
static void
-init(int signo)
+init(bool reload)
{
int i;
- FILE *cf;
- struct filed *f;
char *p;
char oldLocalHostName[MAXHOSTNAMELEN];
char hostMsg[2*MAXHOSTNAMELEN+40];
char bootfileMsg[MAXLINE + 1];
dprintf("init\n");
- WantInitialize = 0;
/*
* Load hostname (may have changed).
*/
- if (signo != 0)
+ if (reload)
(void)strlcpy(oldLocalHostName, LocalHostName,
sizeof(oldLocalHostName));
if (gethostname(LocalHostName, sizeof(LocalHostName)))
@@ -2598,75 +2608,15 @@ init(int signo)
unsetenv("TZ");
}
- /*
- * Close all open log files.
- */
- Initialized = 0;
- STAILQ_FOREACH(f, &fhead, next) {
- /* flush any pending output */
- if (f->f_prevcount)
- fprintlog_successive(f, 0);
-
- switch (f->f_type) {
- case F_FILE:
- case F_FORW:
- case F_CONSOLE:
- case F_TTY:
- close_filed(f);
- break;
- case F_PIPE:
- deadq_enter(f->fu_pipe_pid, f->fu_pipe_pname);
- close_filed(f);
- break;
- }
- }
- while(!STAILQ_EMPTY(&fhead)) {
- f = STAILQ_FIRST(&fhead);
- STAILQ_REMOVE_HEAD(&fhead, next);
- free(f->f_program);
- free(f->f_host);
- if (f->f_prop_filter) {
- switch (f->f_prop_filter->cmp_type) {
- case PROP_CMP_REGEX:
- regfree(f->f_prop_filter->pflt_re);
- free(f->f_prop_filter->pflt_re);
- break;
- case PROP_CMP_CONTAINS:
- case PROP_CMP_EQUAL:
- case PROP_CMP_STARTS:
- free(f->f_prop_filter->pflt_strval);
- break;
- }
- free(f->f_prop_filter);
- }
- free(f);
- }
-
- /* open the configuration file */
- if ((cf = fopen(ConfFile, "r")) == NULL) {
- dprintf("cannot open %s\n", ConfFile);
- f = cfline("*.ERR\t/dev/console", "*", "*", "*");
- if (f != NULL)
- addfile(f);
- free(f);
- f = cfline("*.PANIC\t*", "*", "*", "*");
- if (f != NULL)
- addfile(f);
- free(f);
- Initialized = 1;
-
- return;
- }
-
- readconfigfile(cf, 1);
-
- /* close the configuration file */
- (void)fclose(cf);
-
- Initialized = 1;
+ Initialized = false;
+ closelogfiles();
+ readconfigfile(ConfFile);
+ Initialized = true;
if (Debug) {
+ struct filed *f;
int port;
+
STAILQ_FOREACH(f, &fhead, next) {
for (i = 0; i <= LOG_NFACILITIES; i++)
if (f->f_pmask[i] == INTERNAL_NOPRI)
@@ -2715,6 +2665,8 @@ init(int signo)
for (i = 0; i < MAXUNAMES && *f->fu_uname[i]; i++)
printf("%s, ", f->fu_uname[i]);
break;
+ default:
+ break;
}
if (f->f_program)
printf(" (%s)", f->f_program);
@@ -2726,9 +2678,9 @@ init(int signo)
NULL, NULL, "restart", 0);
dprintf("syslogd: restarted\n");
/*
- * Log a change in hostname, but only on a restart.
+ * Log a change in hostname, but only on reload.
*/
- if (signo != 0 && strcmp(oldLocalHostName, LocalHostName) != 0) {
+ if (reload && strcmp(oldLocalHostName, LocalHostName) != 0) {
(void)snprintf(hostMsg, sizeof(hostMsg),
"hostname changed, \"%s\" to \"%s\"",
oldLocalHostName, LocalHostName);
@@ -2738,9 +2690,9 @@ init(int signo)
}
/*
* Log the kernel boot file if we aren't going to use it as
- * the prefix, and if this is *not* a restart.
+ * the prefix, and if this is *not* a reload.
*/
- if (signo == 0 && !use_bootfile) {
+ if (!reload && !use_bootfile) {
(void)snprintf(bootfileMsg, sizeof(bootfileMsg),
"kernel boot file is %s", bootfile);
logmsg(LOG_KERN | LOG_INFO, NULL, LocalHostName, "syslogd",
@@ -2751,17 +2703,31 @@ init(int signo)
/*
* Compile property-based filter.
- * Returns 0 on success, -1 otherwise.
*/
-static int
-prop_filter_compile(struct prop_filter *pfilter, char *filter)
+static struct prop_filter *
+prop_filter_compile(const char *cfilter)
{
- char *filter_endpos, *p;
+ struct prop_filter *pfilter;
+ char *filter, *filter_endpos, *filter_begpos, *p;
char **ap, *argv[2] = {NULL, NULL};
int re_flags = REG_NOSUB;
int escaped;
- bzero(pfilter, sizeof(struct prop_filter));
+ pfilter = calloc(1, sizeof(*pfilter));
+ if (pfilter == NULL) {
+ logerror("pfilter calloc");
+ exit(1);
+ }
+ if (*cfilter == '*') {
+ pfilter->prop_type = FILT_PROP_NOOP;
+ return (pfilter);
+ }
+ filter = strdup(cfilter);
+ if (filter == NULL) {
+ logerror("strdup");
+ exit(1);
+ }
+ filter_begpos = filter;
/*
* Here's some filter examples mentioned in syslog.conf(5)
@@ -2782,48 +2748,48 @@ prop_filter_compile(struct prop_filter *pfilter, char *filter)
if (argv[0] == NULL || argv[1] == NULL) {
logerror("filter parse error");
- return (-1);
+ goto error;
}
/* fill in prop_type */
if (strcasecmp(argv[0], "msg") == 0)
- pfilter->prop_type = PROP_TYPE_MSG;
- else if(strcasecmp(argv[0], "hostname") == 0)
- pfilter->prop_type = PROP_TYPE_HOSTNAME;
- else if(strcasecmp(argv[0], "source") == 0)
- pfilter->prop_type = PROP_TYPE_HOSTNAME;
- else if(strcasecmp(argv[0], "programname") == 0)
- pfilter->prop_type = PROP_TYPE_PROGNAME;
+ pfilter->prop_type = FILT_PROP_MSG;
+ else if (strcasecmp(argv[0], "hostname") == 0)
+ pfilter->prop_type = FILT_PROP_HOSTNAME;
+ else if (strcasecmp(argv[0], "source") == 0)
+ pfilter->prop_type = FILT_PROP_HOSTNAME;
+ else if (strcasecmp(argv[0], "programname") == 0)
+ pfilter->prop_type = FILT_PROP_PROGNAME;
else {
logerror("unknown property");
- return (-1);
+ goto error;
}
/* full in cmp_flags (i.e. !contains, icase_regex, etc.) */
if (*argv[1] == '!') {
- pfilter->cmp_flags |= PROP_FLAG_EXCLUDE;
+ pfilter->cmp_flags |= FILT_FLAG_EXCLUDE;
argv[1]++;
}
if (strncasecmp(argv[1], "icase_", (sizeof("icase_") - 1)) == 0) {
- pfilter->cmp_flags |= PROP_FLAG_ICASE;
+ pfilter->cmp_flags |= FILT_FLAG_ICASE;
argv[1] += sizeof("icase_") - 1;
}
/* fill in cmp_type */
if (strcasecmp(argv[1], "contains") == 0)
- pfilter->cmp_type = PROP_CMP_CONTAINS;
+ pfilter->cmp_type = FILT_CMP_CONTAINS;
else if (strcasecmp(argv[1], "isequal") == 0)
- pfilter->cmp_type = PROP_CMP_EQUAL;
+ pfilter->cmp_type = FILT_CMP_EQUAL;
else if (strcasecmp(argv[1], "startswith") == 0)
- pfilter->cmp_type = PROP_CMP_STARTS;
+ pfilter->cmp_type = FILT_CMP_STARTS;
else if (strcasecmp(argv[1], "regex") == 0)
- pfilter->cmp_type = PROP_CMP_REGEX;
+ pfilter->cmp_type = FILT_CMP_REGEX;
else if (strcasecmp(argv[1], "ereregex") == 0) {
- pfilter->cmp_type = PROP_CMP_REGEX;
+ pfilter->cmp_type = FILT_CMP_REGEX;
re_flags |= REG_EXTENDED;
} else {
logerror("unknown cmp function");
- return (-1);
+ goto error;
}
/*
@@ -2835,7 +2801,7 @@ prop_filter_compile(struct prop_filter *pfilter, char *filter)
filter += strspn(filter, ", \t\n");
if (*filter != '"' || strlen(filter) < 3) {
logerror("property value parse error");
- return (-1);
+ goto error;
}
filter++;
@@ -2867,130 +2833,54 @@ prop_filter_compile(struct prop_filter *pfilter, char *filter)
/* We should not have anything but whitespace left after closing '"' */
if (*p != '\0' && strspn(p, " \t\n") != strlen(p)) {
logerror("property value parse error");
- return (-1);
+ goto error;
}
- if (pfilter->cmp_type == PROP_CMP_REGEX) {
+ if (pfilter->cmp_type == FILT_CMP_REGEX) {
pfilter->pflt_re = calloc(1, sizeof(*pfilter->pflt_re));
if (pfilter->pflt_re == NULL) {
logerror("RE calloc() error");
- free(pfilter->pflt_re);
- return (-1);
+ goto error;
}
- if (pfilter->cmp_flags & PROP_FLAG_ICASE)
+ if (pfilter->cmp_flags & FILT_FLAG_ICASE)
re_flags |= REG_ICASE;
if (regcomp(pfilter->pflt_re, filter, re_flags) != 0) {
logerror("RE compilation error");
- free(pfilter->pflt_re);
- return (-1);
+ goto error;
}
} else {
pfilter->pflt_strval = strdup(filter);
pfilter->pflt_strlen = strlen(filter);
}
- return (0);
-
+ free(filter_begpos);
+ return (pfilter);
+error:
+ free(filter_begpos);
+ free(pfilter->pflt_re);
+ free(pfilter);
+ return (NULL);
}
-/*
- * Crack a configuration file line
- */
-static struct filed *
-cfline(const char *line, const char *prog, const char *host,
- const char *pfilter)
+static const char *
+parse_selector(const char *p, struct filed *f)
{
- struct filed *f;
- struct addrinfo hints, *res;
- int error, i, pri, syncfile;
- const char *p, *q;
- char *bp, *pfilter_dup;
- char buf[LINE_MAX], ebuf[100];
-
- dprintf("cfline(\"%s\", f, \"%s\", \"%s\", \"%s\")\n", line, prog,
- host, pfilter);
-
- f = calloc(1, sizeof(*f));
- if (f == NULL) {
- logerror("malloc");
- exit(1);
- }
- errno = 0; /* keep strerror() stuff out of logerror messages */
-
- for (i = 0; i <= LOG_NFACILITIES; i++)
- f->f_pmask[i] = INTERNAL_NOPRI;
-
- /* save hostname if any */
- if (host && *host == '*')
- host = NULL;
- if (host) {
- int hl;
-
- f->f_host = strdup(host);
- if (f->f_host == NULL) {
- logerror("strdup");
- exit(1);
- }
- hl = strlen(f->f_host);
- if (hl > 0 && f->f_host[hl-1] == '.')
- f->f_host[--hl] = '\0';
- /* RFC 5424 prefers logging FQDNs. */
- if (RFC3164OutputFormat)
- trimdomain(f->f_host, hl);
- }
-
- /* save program name if any */
- if (prog && *prog == '*')
- prog = NULL;
- if (prog) {
- f->f_program = strdup(prog);
- if (f->f_program == NULL) {
- logerror("strdup");
- exit(1);
- }
- }
-
- if (pfilter) {
- f->f_prop_filter = calloc(1, sizeof(*(f->f_prop_filter)));
- if (f->f_prop_filter == NULL) {
- logerror("pfilter calloc");
- exit(1);
- }
- if (*pfilter == '*')
- f->f_prop_filter->prop_type = PROP_TYPE_NOOP;
- else {
- pfilter_dup = strdup(pfilter);
- if (pfilter_dup == NULL) {
- logerror("strdup");
- exit(1);
- }
- if (prop_filter_compile(f->f_prop_filter, pfilter_dup)) {
- logerror("filter compile error");
- exit(1);
- }
- }
- }
-
- /* scan through the list of selectors */
- for (p = line; *p && *p != '\t' && *p != ' ';) {
- int pri_done;
- int pri_cmp;
- int pri_invert;
-
- /* find the end of this facility name list */
- for (q = p; *q && *q != '\t' && *q != ' ' && *q++ != '.'; )
- continue;
-
- /* get the priority comparison */
- pri_cmp = 0;
- pri_done = 0;
- pri_invert = 0;
- if (*q == '!') {
- pri_invert = 1;
- q++;
- }
- while (!pri_done) {
- switch (*q) {
+ int i, pri;
+ int pri_done = 0, pri_cmp = 0, pri_invert = 0;
+ char *bp, buf[LINE_MAX], ebuf[100];
+ const char *q;
+
+ /* find the end of this facility name list */
+ for (q = p; *q && *q != '\t' && *q != ' ' && *q++ != '.';)
+ continue;
+
+ /* get the priority comparison */
+ if (*q == '!') {
+ pri_invert = 1;
+ q++;
+ }
+ while (!pri_done) {
+ switch (*q) {
case '<':
pri_cmp |= PRI_LT;
q++;
@@ -3006,86 +2896,86 @@ cfline(const char *line, const char *prog, const char *host,
default:
pri_done++;
break;
- }
}
+ }
- /* collect priority name */
- for (bp = buf; *q && !strchr("\t,; ", *q); )
- *bp++ = *q++;
- *bp = '\0';
+ /* collect priority name */
+ for (bp = buf; *q != '\0' && !strchr("\t,; ", *q); )
+ *bp++ = *q++;
+ *bp = '\0';
- /* skip cruft */
- while (strchr(",;", *q))
- q++;
+ /* skip cruft */
+ while (strchr(",;", *q))
+ q++;
+
+ /* decode priority name */
+ if (*buf == '*') {
+ pri = LOG_PRIMASK;
+ pri_cmp = PRI_LT | PRI_EQ | PRI_GT;
+ } else {
+ /* Ignore trailing spaces. */
+ for (i = strlen(buf) - 1; i >= 0 && buf[i] == ' '; i--)
+ buf[i] = '\0';
+
+ pri = decode(buf, prioritynames);
+ if (pri < 0) {
+ errno = 0;
+ (void)snprintf(ebuf, sizeof(ebuf),
+ "unknown priority name \"%s\"", buf);
+ logerror(ebuf);
+ free(f);
+ return (NULL);
+ }
+ }
+ if (!pri_cmp)
+ pri_cmp = UniquePriority ? PRI_EQ : (PRI_EQ | PRI_GT);
+ if (pri_invert)
+ pri_cmp ^= PRI_LT | PRI_EQ | PRI_GT;
+
+ /* scan facilities */
+ while (*p != '\0' && !strchr("\t.; ", *p)) {
+ for (bp = buf; *p != '\0' && !strchr("\t,;. ", *p); )
+ *bp++ = *p++;
+ *bp = '\0';
- /* decode priority name */
if (*buf == '*') {
- pri = LOG_PRIMASK;
- pri_cmp = PRI_LT | PRI_EQ | PRI_GT;
+ for (i = 0; i < LOG_NFACILITIES; i++) {
+ f->f_pmask[i] = pri;
+ f->f_pcmp[i] = pri_cmp;
+ }
} else {
- /* Ignore trailing spaces. */
- for (i = strlen(buf) - 1; i >= 0 && buf[i] == ' '; i--)
- buf[i] = '\0';
-
- pri = decode(buf, prioritynames);
- if (pri < 0) {
+ i = decode(buf, facilitynames);
+ if (i < 0) {
errno = 0;
- (void)snprintf(ebuf, sizeof ebuf,
- "unknown priority name \"%s\"", buf);
+ (void)snprintf(ebuf, sizeof(ebuf),
+ "unknown facility name \"%s\"",
+ buf);
logerror(ebuf);
free(f);
return (NULL);
}
+ f->f_pmask[i >> 3] = pri;
+ f->f_pcmp[i >> 3] = pri_cmp;
}
- if (!pri_cmp)
- pri_cmp = (UniquePriority)
- ? (PRI_EQ)
- : (PRI_EQ | PRI_GT)
- ;
- if (pri_invert)
- pri_cmp ^= PRI_LT | PRI_EQ | PRI_GT;
-
- /* scan facilities */
- while (*p && !strchr("\t.; ", *p)) {
- for (bp = buf; *p && !strchr("\t,;. ", *p); )
- *bp++ = *p++;
- *bp = '\0';
-
- if (*buf == '*') {
- for (i = 0; i < LOG_NFACILITIES; i++) {
- f->f_pmask[i] = pri;
- f->f_pcmp[i] = pri_cmp;
- }
- } else {
- i = decode(buf, facilitynames);
- if (i < 0) {
- errno = 0;
- (void)snprintf(ebuf, sizeof ebuf,
- "unknown facility name \"%s\"",
- buf);
- logerror(ebuf);
- free(f);
- return (NULL);
- }
- f->f_pmask[i >> 3] = pri;
- f->f_pcmp[i >> 3] = pri_cmp;
- }
- while (*p == ',' || *p == ' ')
- p++;
- }
-
- p = q;
+ while (*p == ',' || *p == ' ')
+ p++;
}
+ return (q);
+}
- /* skip to action part */
- while (*p == '\t' || *p == ' ')
- p++;
+static void
+parse_action(const char *p, struct filed *f)
+{
+ struct addrinfo hints, *res;
+ int error, i;
+ const char *q;
+ bool syncfile;
if (*p == '-') {
- syncfile = 0;
+ syncfile = false;
p++;
} else
- syncfile = 1;
+ syncfile = true;
switch (*p) {
case '@':
@@ -3144,7 +3034,7 @@ cfline(const char *line, const char *prog, const char *host,
if (syncfile)
f->f_flags |= FFLAG_SYNC;
if (isatty(f->f_file)) {
- if (strcmp(p, ctty) == 0)
+ if (strcmp(p, _PATH_CONSOLE) == 0)
f->f_type = F_CONSOLE;
else
f->f_type = F_TTY;
@@ -3157,7 +3047,7 @@ cfline(const char *line, const char *prog, const char *host,
break;
case '|':
- f->fu_pipe_pid = 0;
+ f->fu_pipe_pd = -1;
(void)strlcpy(f->fu_pipe_pname, p + 1,
sizeof(f->fu_pipe_pname));
f->f_type = F_PIPE;
@@ -3183,9 +3073,80 @@ cfline(const char *line, const char *prog, const char *host,
f->f_type = F_USERS;
break;
}
- return (f);
}
+/*
+ * Crack a configuration file line
+ */
+static void
+cfline(const char *line, const char *prog, const char *host,
+ const char *pfilter)
+{
+ struct filed *f;
+ const char *p;
+
+ dprintf("cfline(\"%s\", f, \"%s\", \"%s\", \"%s\")\n", line, prog,
+ host, pfilter);
+
+ f = calloc(1, sizeof(*f));
+ if (f == NULL) {
+ logerror("malloc");
+ exit(1);
+ }
+ errno = 0; /* keep strerror() stuff out of logerror messages */
+
+ for (int i = 0; i <= LOG_NFACILITIES; i++)
+ f->f_pmask[i] = INTERNAL_NOPRI;
+
+ /* save hostname if any */
+ if (host && *host == '*')
+ host = NULL;
+ if (host) {
+ int hl;
+
+ f->f_host = strdup(host);
+ if (f->f_host == NULL) {
+ logerror("strdup");
+ exit(1);
+ }
+ hl = strlen(f->f_host);
+ if (hl > 0 && f->f_host[hl-1] == '.')
+ f->f_host[--hl] = '\0';
+ /* RFC 5424 prefers logging FQDNs. */
+ if (RFC3164OutputFormat)
+ trimdomain(f->f_host, hl);
+ }
+
+ /* save program name if any */
+ if (prog && *prog == '*')
+ prog = NULL;
+ if (prog) {
+ f->f_program = strdup(prog);
+ if (f->f_program == NULL) {
+ logerror("strdup");
+ exit(1);
+ }
+ }
+
+ if (pfilter) {
+ f->f_prop_filter = prop_filter_compile(pfilter);
+ if (f->f_prop_filter == NULL) {
+ logerror("filter compile error");
+ exit(1);
+ }
+ }
+
+ /* scan through the list of selectors */
+ for (p = line; *p != '\0' && *p != '\t' && *p != ' ';)
+ p = parse_selector(p, f);
+
+ /* skip to action part */
+ while (*p == '\t' || *p == ' ')
+ p++;
+ parse_action(p, f);
+
+ STAILQ_INSERT_TAIL(&fhead, f, next);
+}
/*
* Decode a symbolic name to a numeric value
@@ -3242,20 +3203,12 @@ markit(void)
switch (dq->dq_timeout) {
case 0:
/* Already signalled once, try harder now. */
- if (kill(dq->dq_pid, SIGKILL) != 0)
- (void)deadq_remove(dq);
+ (void)pdkill(dq->dq_procdesc, SIGKILL);
+ (void)deadq_remove(dq);
break;
case 1:
- /*
- * Timed out on dead queue, send terminate
- * signal. Note that we leave the removal
- * from the dead queue to reapchild(), which
- * will also log the event (unless the process
- * didn't even really exist, in case we simply
- * drop it from the dead queue).
- */
- if (kill(dq->dq_pid, SIGTERM) != 0)
+ if (pdkill(dq->dq_procdesc, SIGTERM) != 0)
(void)deadq_remove(dq);
else
dq->dq_timeout--;
@@ -3264,76 +3217,58 @@ markit(void)
dq->dq_timeout--;
}
}
- MarkSet = 0;
(void)alarm(TIMERINTVL);
}
/*
* fork off and become a daemon, but wait for the child to come online
* before returning to the parent, or we get disk thrashing at boot etc.
- * Set a timer so we don't hang forever if it wedges.
*/
static int
waitdaemon(int maxwait)
{
- int fd;
- int status;
- pid_t pid, childpid;
+ struct pollfd pollfd;
+ int events, pipefd[2], status;
+ pid_t pid;
- switch (childpid = fork()) {
- case -1:
- return (-1);
- case 0:
- break;
- default:
- signal(SIGALRM, timedout);
- alarm(maxwait);
- while ((pid = wait3(&status, 0, NULL)) != -1) {
+ if (pipe(pipefd) == -1) {
+ warn("failed to daemonize, pipe");
+ die(0);
+ }
+ pid = fork();
+ if (pid == -1) {
+ warn("failed to daemonize, fork");
+ die(0);
+ } else if (pid > 0) {
+ close(pipefd[1]);
+ pollfd.fd = pipefd[0];
+ pollfd.events = POLLHUP;
+ events = poll(&pollfd, 1, maxwait * 1000);
+ if (events == -1)
+ err(1, "failed to daemonize, poll");
+ else if (events == 0)
+ errx(1, "timed out waiting for child");
+ if (waitpid(pid, &status, WNOHANG) > 0) {
if (WIFEXITED(status))
errx(1, "child pid %d exited with return code %d",
- pid, WEXITSTATUS(status));
+ pid, WEXITSTATUS(status));
if (WIFSIGNALED(status))
errx(1, "child pid %d exited on signal %d%s",
- pid, WTERMSIG(status),
- WCOREDUMP(status) ? " (core dumped)" :
- "");
- if (pid == childpid) /* it's gone... */
- break;
+ pid, WTERMSIG(status),
+ WCOREDUMP(status) ? " (core dumped)" : "");
}
exit(0);
}
-
- if (setsid() == -1)
- return (-1);
-
+ close(pipefd[0]);
+ if (setsid() == -1) {
+ warn("failed to daemonize, setsid");
+ die(0);
+ }
(void)chdir("/");
- if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
- (void)dup2(fd, STDIN_FILENO);
- (void)dup2(fd, STDOUT_FILENO);
- (void)dup2(fd, STDERR_FILENO);
- if (fd > STDERR_FILENO)
- (void)close(fd);
- }
- return (getppid());
-}
-
-/*
- * We get a SIGALRM from the child when it's running and finished doing it's
- * fsync()'s or O_SYNC writes for all the boot messages.
- *
- * We also get a signal from the kernel if the timer expires, so check to
- * see what happened.
- */
-static void
-timedout(int sig __unused)
-{
- int left;
- left = alarm(0);
- signal(SIGALRM, SIG_DFL);
- if (left == 0)
- errx(1, "timed out waiting for child");
- else
- _exit(0);
+ (void)dup2(nulldesc, STDIN_FILENO);
+ (void)dup2(nulldesc, STDOUT_FILENO);
+ (void)dup2(nulldesc, STDERR_FILENO);
+ return (pipefd[1]);
}
/*
@@ -3348,9 +3283,9 @@ timedout(int sig __unused)
*
* netaddr/maskbits[:{servicename|portnumber|*}]
*
- * Returns -1 on error, 0 if the argument was valid.
+ * Returns false on error, true if the argument was valid.
*/
-static int
+static bool
#if defined(INET) || defined(INET6)
allowaddr(char *s)
#else
@@ -3426,7 +3361,7 @@ allowaddr(char *s __unused)
.ai_flags = AI_PASSIVE | AI_NUMERICHOST
};
if (getaddrinfo(s, NULL, &hints, &res) == 0) {
- ap->isnumeric = 1;
+ ap->isnumeric = true;
memcpy(&ap->a_addr, res->ai_addr, res->ai_addrlen);
ap->a_mask = (struct sockaddr_storage){
.ss_family = res->ai_family,
@@ -3487,7 +3422,7 @@ allowaddr(char *s __unused)
freeaddrinfo(res);
} else {
/* arg `s' is domain name */
- ap->isnumeric = 0;
+ ap->isnumeric = false;
ap->a_name = s;
if (cp1)
*cp1 = '/';
@@ -3506,11 +3441,11 @@ allowaddr(char *s __unused)
printf("numeric, ");
getnameinfo(sstosa(&ap->a_addr),
(sstosa(&ap->a_addr))->sa_len,
- ip, sizeof ip, NULL, 0, NI_NUMERICHOST);
+ ip, sizeof(ip), NULL, 0, NI_NUMERICHOST);
printf("addr = %s, ", ip);
getnameinfo(sstosa(&ap->a_mask),
(sstosa(&ap->a_mask))->sa_len,
- ip, sizeof ip, NULL, 0, NI_NUMERICHOST);
+ ip, sizeof(ip), NULL, 0, NI_NUMERICHOST);
printf("mask = %s; ", ip);
} else {
printf("domainname = %s; ", ap->a_name);
@@ -3518,19 +3453,19 @@ allowaddr(char *s __unused)
printf("port = %d\n", ap->port);
}
- return (0);
+ return (true);
err:
if (res != NULL)
freeaddrinfo(res);
free(ap);
#endif
- return (-1);
+ return (false);
}
/*
* Validate that the remote peer has permission to log to us.
*/
-static int
+static bool
validate(struct sockaddr *sa, const char *hname)
{
int i;
@@ -3544,15 +3479,10 @@ validate(struct sockaddr *sa, const char *hname)
#endif
struct addrinfo hints, *res;
u_short sport;
- int num = 0;
- STAILQ_FOREACH(ap, &aphead, next) {
- num++;
- }
- dprintf("# of validation rule: %d\n", num);
- if (num == 0)
- /* traditional behaviour, allow everything */
- return (1);
+ /* traditional behaviour, allow everything */
+ if (STAILQ_EMPTY(&aphead))
+ return (true);
(void)strlcpy(name, hname, sizeof(name));
hints = (struct addrinfo){
@@ -3563,12 +3493,12 @@ validate(struct sockaddr *sa, const char *hname)
if (getaddrinfo(name, NULL, &hints, &res) == 0)
freeaddrinfo(res);
else if (strchr(name, '.') == NULL) {
- strlcat(name, ".", sizeof name);
- strlcat(name, LocalDomain, sizeof name);
+ strlcat(name, ".", sizeof(name));
+ strlcat(name, LocalDomain, sizeof(name));
}
if (getnameinfo(sa, sa->sa_len, ip, sizeof(ip), port, sizeof(port),
NI_NUMERICHOST | NI_NUMERICSERV) != 0)
- return (0); /* for safety, should not occur */
+ return (false); /* for safety, should not occur */
dprintf("validate: dgram from IP %s, port %s, name %s;\n",
ip, port, name);
sport = atoi(port);
@@ -3628,9 +3558,9 @@ validate(struct sockaddr *sa, const char *hname)
}
}
dprintf("accepted in rule %d.\n", i);
- return (1); /* hooray! */
+ return (true); /* hooray! */
}
- return (0);
+ return (false);
}
/*
@@ -3638,22 +3568,19 @@ validate(struct sockaddr *sa, const char *hname)
* opposed to a FILE *.
*/
static int
-p_open(const char *prog, pid_t *rpid)
+p_open(const char *prog, int *rpd)
{
- int pfd[2], nulldesc;
+ struct sigaction act = { };
+ int pfd[2], pd;
pid_t pid;
char *argv[4]; /* sh -c cmd NULL */
char errmsg[200];
if (pipe(pfd) == -1)
return (-1);
- if ((nulldesc = open(_PATH_DEVNULL, O_RDWR)) == -1)
- /* we are royally screwed anyway */
- return (-1);
- switch ((pid = fork())) {
+ switch ((pid = pdfork(&pd, PD_CLOEXEC))) {
case -1:
- close(nulldesc);
return (-1);
case 0:
@@ -3668,11 +3595,13 @@ p_open(const char *prog, pid_t *rpid)
}
alarm(0);
-
- /* Restore signals marked as SIG_IGN. */
- (void)signal(SIGINT, SIG_DFL);
- (void)signal(SIGQUIT, SIG_DFL);
- (void)signal(SIGPIPE, SIG_DFL);
+ act.sa_handler = SIG_DFL;
+ for (size_t i = 0; i < nitems(sigcatch); ++i) {
+ if (sigaction(sigcatch[i], &act, NULL) == -1) {
+ logerror("sigaction");
+ exit(1);
+ }
+ }
dup2(pfd[0], STDIN_FILENO);
dup2(nulldesc, STDOUT_FILENO);
@@ -3682,7 +3611,6 @@ p_open(const char *prog, pid_t *rpid)
(void)execvp(_PATH_BSHELL, argv);
_exit(255);
}
- close(nulldesc);
close(pfd[0]);
/*
* Avoid blocking on a hung pipe. With O_NONBLOCK, we are
@@ -3695,255 +3623,150 @@ p_open(const char *prog, pid_t *rpid)
*/
if (fcntl(pfd[1], F_SETFL, O_NONBLOCK) == -1) {
/* This is bad. */
- (void)snprintf(errmsg, sizeof errmsg,
+ (void)snprintf(errmsg, sizeof(errmsg),
"Warning: cannot change pipe to PID %d to "
"non-blocking behaviour.",
(int)pid);
logerror(errmsg);
}
- *rpid = pid;
+ *rpd = pd;
return (pfd[1]);
}
static void
-deadq_enter(pid_t pid, const char *name)
+deadq_enter(int pd)
{
struct deadq_entry *dq;
- int status;
- if (pid == 0)
- return;
- /*
- * Be paranoid, if we can't signal the process, don't enter it
- * into the dead queue (perhaps it's already dead). If possible,
- * we try to fetch and log the child's status.
- */
- if (kill(pid, 0) != 0) {
- if (waitpid(pid, &status, WNOHANG) > 0)
- log_deadchild(pid, status, name);
+ if (pd == -1)
return;
- }
dq = malloc(sizeof(*dq));
if (dq == NULL) {
logerror("malloc");
exit(1);
}
- *dq = (struct deadq_entry){
- .dq_pid = pid,
- .dq_timeout = DQ_TIMO_INIT
- };
+
+ dq->dq_procdesc = pd;
+ dq->dq_timeout = DQ_TIMO_INIT;
TAILQ_INSERT_TAIL(&deadq_head, dq, dq_entries);
}
-static int
+static void
deadq_remove(struct deadq_entry *dq)
{
- if (dq != NULL) {
- TAILQ_REMOVE(&deadq_head, dq, dq_entries);
- free(dq);
- return (1);
- }
-
- return (0);
+ TAILQ_REMOVE(&deadq_head, dq, dq_entries);
+ close(dq->dq_procdesc);
+ free(dq);
}
-static int
-deadq_removebypid(pid_t pid)
+static struct socklist *
+socksetup(struct addrinfo *ai, const char *name, mode_t mode)
{
- struct deadq_entry *dq;
+ struct socklist *sl;
+ int (*sl_recv)(struct socklist *);
+ int s, optval = 1;
- TAILQ_FOREACH(dq, &deadq_head, dq_entries) {
- if (dq->dq_pid == pid)
- break;
+ if (ai->ai_family != AF_LOCAL && SecureMode > 1) {
+ /* Only AF_LOCAL in secure mode. */
+ return (NULL);
}
- return (deadq_remove(dq));
-}
+ if (family != AF_UNSPEC && ai->ai_family != AF_LOCAL &&
+ ai->ai_family != family)
+ return (NULL);
-static void
-log_deadchild(pid_t pid, int status, const char *name)
-{
- int code;
- char buf[256];
- const char *reason;
-
- errno = 0; /* Keep strerror() stuff out of logerror messages. */
- if (WIFSIGNALED(status)) {
- reason = "due to signal";
- code = WTERMSIG(status);
- } else {
- reason = "with status";
- code = WEXITSTATUS(status);
- if (code == 0)
- return;
+ s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ if (s < 0) {
+ logerror("socket");
+ return (NULL);
}
- (void)snprintf(buf, sizeof buf,
- "Logging subprocess %d (%s) exited %s %d.",
- pid, name, reason, code);
- logerror(buf);
-}
-
-static int
-socksetup(struct peer *pe)
-{
- struct addrinfo hints, *res, *res0;
- int error;
- char *cp;
- int (*sl_recv)(struct socklist *);
- /*
- * We have to handle this case for backwards compatibility:
- * If there are two (or more) colons but no '[' and ']',
- * assume this is an inet6 address without a service.
- */
- if (pe->pe_name != NULL) {
-#ifdef INET6
- if (pe->pe_name[0] == '[' &&
- (cp = strchr(pe->pe_name + 1, ']')) != NULL) {
- pe->pe_name = &pe->pe_name[1];
- *cp = '\0';
- if (cp[1] == ':' && cp[2] != '\0')
- pe->pe_serv = cp + 2;
- } else {
-#endif
- cp = strchr(pe->pe_name, ':');
- if (cp != NULL && strchr(cp + 1, ':') == NULL) {
- *cp = '\0';
- if (cp[1] != '\0')
- pe->pe_serv = cp + 1;
- if (cp == pe->pe_name)
- pe->pe_name = NULL;
- }
#ifdef INET6
+ if (ai->ai_family == AF_INET6) {
+ if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &optval,
+ sizeof(int)) < 0) {
+ logerror("setsockopt(IPV6_V6ONLY)");
+ close(s);
+ return (NULL);
}
-#endif
}
- hints = (struct addrinfo){
- .ai_family = AF_UNSPEC,
- .ai_socktype = SOCK_DGRAM,
- .ai_flags = AI_PASSIVE
- };
- if (pe->pe_name != NULL)
- dprintf("Trying peer: %s\n", pe->pe_name);
- if (pe->pe_serv == NULL)
- pe->pe_serv = "syslog";
- error = getaddrinfo(pe->pe_name, pe->pe_serv, &hints, &res0);
- if (error) {
- char *msgbuf;
-
- asprintf(&msgbuf, "getaddrinfo failed for %s%s: %s",
- pe->pe_name == NULL ? "" : pe->pe_name, pe->pe_serv,
- gai_strerror(error));
- errno = 0;
- if (msgbuf == NULL)
- logerror(gai_strerror(error));
- else
- logerror(msgbuf);
- free(msgbuf);
- die(0);
- }
- for (res = res0; res != NULL; res = res->ai_next) {
- int s;
-
- if (res->ai_family != AF_LOCAL &&
- SecureMode > 1) {
- /* Only AF_LOCAL in secure mode. */
- continue;
- }
- if (family != AF_UNSPEC &&
- res->ai_family != AF_LOCAL && res->ai_family != family)
- continue;
-
- s = socket(res->ai_family, res->ai_socktype,
- res->ai_protocol);
- if (s < 0) {
- logerror("socket");
- error++;
- continue;
- }
-#ifdef INET6
- if (res->ai_family == AF_INET6) {
- if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
- &(int){1}, sizeof(int)) < 0) {
- logerror("setsockopt(IPV6_V6ONLY)");
- close(s);
- error++;
- continue;
- }
- }
#endif
- if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
- &(int){1}, sizeof(int)) < 0) {
- logerror("setsockopt(SO_REUSEADDR)");
- close(s);
- error++;
- continue;
- }
+ if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &optval,
+ sizeof(int)) < 0) {
+ logerror("setsockopt(SO_REUSEADDR)");
+ close(s);
+ return (NULL);
+ }
- /*
- * Bind INET and UNIX-domain sockets.
- *
- * A UNIX-domain socket is always bound to a pathname
- * regardless of -N flag.
- *
- * For INET sockets, RFC 3164 recommends that client
- * side message should come from the privileged syslogd port.
- *
- * If the system administrator chooses not to obey
- * this, we can skip the bind() step so that the
- * system will choose a port for us.
- */
- if (res->ai_family == AF_LOCAL)
- unlink(pe->pe_name);
- if (res->ai_family == AF_LOCAL ||
- NoBind == 0 || pe->pe_name != NULL) {
- if (bind(s, res->ai_addr, res->ai_addrlen) < 0) {
- logerror("bind");
- close(s);
- error++;
- continue;
- }
- if (res->ai_family == AF_LOCAL ||
- SecureMode == 0)
- increase_rcvbuf(s);
- }
- if (res->ai_family == AF_LOCAL &&
- chmod(pe->pe_name, pe->pe_mode) < 0) {
- dprintf("chmod %s: %s\n", pe->pe_name,
- strerror(errno));
+ /*
+ * Bind INET and UNIX-domain sockets.
+ *
+ * A UNIX-domain socket is always bound to a pathname
+ * regardless of -N flag.
+ *
+ * For INET sockets, RFC 3164 recommends that client
+ * side message should come from the privileged syslogd port.
+ *
+ * If the system administrator chooses not to obey
+ * this, we can skip the bind() step so that the
+ * system will choose a port for us.
+ */
+ if (ai->ai_family == AF_LOCAL)
+ unlink(name);
+ if (ai->ai_family == AF_LOCAL || NoBind == 0 || name != NULL) {
+ if (bind(s, ai->ai_addr, ai->ai_addrlen) < 0) {
+ logerror("bind");
close(s);
- error++;
- continue;
- }
- dprintf("new socket fd is %d\n", s);
- if (res->ai_socktype != SOCK_DGRAM) {
- listen(s, 5);
+ return (NULL);
}
- sl_recv = socklist_recv_sock;
+ if (ai->ai_family == AF_LOCAL || SecureMode == 0)
+ increase_rcvbuf(s);
+ }
+ if (ai->ai_family == AF_LOCAL && chmod(name, mode) < 0) {
+ dprintf("chmod %s: %s\n", name, strerror(errno));
+ close(s);
+ return (NULL);
+ }
+ dprintf("new socket fd is %d\n", s);
+ sl_recv = socklist_recv_sock;
#if defined(INET) || defined(INET6)
- if (SecureMode && (res->ai_family == AF_INET ||
- res->ai_family == AF_INET6)) {
- dprintf("shutdown\n");
- /* Forbid communication in secure mode. */
- if (shutdown(s, SHUT_RD) < 0 &&
- errno != ENOTCONN) {
- logerror("shutdown");
- if (!Debug)
- die(0);
- }
- sl_recv = NULL;
- } else
+ if (SecureMode && (ai->ai_family == AF_INET ||
+ ai->ai_family == AF_INET6)) {
+ dprintf("shutdown\n");
+ /* Forbid communication in secure mode. */
+ if (shutdown(s, SHUT_RD) < 0 && errno != ENOTCONN) {
+ logerror("shutdown");
+ if (!Debug)
+ die(0);
+ }
+ sl_recv = NULL;
+ } else
#endif
- dprintf("listening on socket\n");
- dprintf("sending on socket\n");
- addsock(res, &(struct socklist){
- .sl_socket = s,
- .sl_peer = pe,
- .sl_recv = sl_recv
- });
+ dprintf("listening on socket\n");
+ dprintf("sending on socket\n");
+ /* Copy *ai->ai_addr to the tail of struct socklist if any. */
+ sl = calloc(1, sizeof(*sl) + ai->ai_addrlen);
+ if (sl == NULL)
+ err(1, "malloc failed");
+ sl->sl_socket = s;
+ if (ai->ai_family == AF_LOCAL) {
+ char *name2 = strdup(name);
+ if (name2 == NULL)
+ err(1, "strdup failed");
+ sl->sl_name = strdup(basename(name2));
+ sl->sl_dirfd = open(dirname(name2), O_DIRECTORY);
+ if (sl->sl_name == NULL || sl->sl_dirfd == -1)
+ err(1, "failed to save dir info for %s", name);
+ free(name2);
+ }
+ sl->sl_recv = sl_recv;
+ (void)memcpy(&sl->sl_ai, ai, sizeof(*ai));
+ if (ai->ai_addrlen > 0) {
+ (void)memcpy((sl + 1), ai->ai_addr, ai->ai_addrlen);
+ sl->sl_sa = (struct sockaddr *)(sl + 1);
+ } else {
+ sl->sl_sa = NULL;
}
- freeaddrinfo(res0);
-
- return(error);
+ return (sl);
}
static void
diff --git a/usr.sbin/syslogd/tests/Makefile b/usr.sbin/syslogd/tests/Makefile
new file mode 100644
index 000000000000..781730a1102a
--- /dev/null
+++ b/usr.sbin/syslogd/tests/Makefile
@@ -0,0 +1,5 @@
+ATF_TESTS_SH+= syslogd_test
+# Several syslogd listening on the same port prevent parallel operation
+TEST_METADATA+= is_exclusive="true"
+
+.include <bsd.test.mk>
diff --git a/usr.sbin/syslogd/tests/syslogd_test.sh b/usr.sbin/syslogd/tests/syslogd_test.sh
new file mode 100644
index 000000000000..e4927868e47f
--- /dev/null
+++ b/usr.sbin/syslogd/tests/syslogd_test.sh
@@ -0,0 +1,299 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2021, 2023 The FreeBSD Foundation
+#
+# This software was developed by Mark Johnston under sponsorship from
+# the FreeBSD Foundation.
+#
+# This software was developed by Jake Freeland under sponsorship from
+# the FreeBSD Foundation.
+#
+
+# Tests to-do:
+# actions: hostname, users
+
+readonly SYSLOGD_UDP_PORT="5140"
+readonly SYSLOGD_CONFIG="${PWD}/syslog.conf"
+readonly SYSLOGD_LOCAL_SOCKET="${PWD}/log.sock"
+readonly SYSLOGD_PIDFILE="${PWD}/syslogd.pid"
+readonly SYSLOGD_LOCAL_PRIVSOCKET="${PWD}/logpriv.sock"
+
+# Start a private syslogd instance.
+syslogd_start()
+{
+ syslogd \
+ -b ":${SYSLOGD_UDP_PORT}" \
+ -C \
+ -d \
+ -f "${SYSLOGD_CONFIG}" \
+ -H \
+ -p "${SYSLOGD_LOCAL_SOCKET}" \
+ -P "${SYSLOGD_PIDFILE}" \
+ -S "${SYSLOGD_LOCAL_PRIVSOCKET}" \
+ $@ \
+ &
+
+ # Give syslogd a bit of time to spin up.
+ while [ "$((i+=1))" -le 20 ]; do
+ [ -S "${SYSLOGD_LOCAL_SOCKET}" ] && return
+ sleep 0.1
+ done
+ atf_fail "timed out waiting for syslogd to start"
+}
+
+# Simple logger(1) wrapper.
+syslogd_log()
+{
+ atf_check -s exit:0 -o empty -e empty logger $*
+}
+
+# Make syslogd reload its configuration file.
+syslogd_reload()
+{
+ pkill -HUP -F "${SYSLOGD_PIDFILE}"
+}
+
+# Stop a private syslogd instance.
+syslogd_stop()
+{
+ pid=$(cat "${SYSLOGD_PIDFILE}")
+ if pkill -F "${SYSLOGD_PIDFILE}"; then
+ wait "${pid}"
+ rm -f "${SYSLOGD_PIDFILE}" "${SYSLOGD_LOCAL_SOCKET}" \
+ "${SYSLOGD_LOCAL_PRIVSOCKET}"
+ fi
+}
+
+atf_test_case "basic" "cleanup"
+basic_head()
+{
+ atf_set descr "Messages are logged via supported transports"
+}
+basic_body()
+{
+ logfile="${PWD}/basic.log"
+ printf "user.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}"
+ syslogd_start
+
+ syslogd_log -p user.debug -t basic -h "${SYSLOGD_LOCAL_SOCKET}" \
+ "hello, world (unix)"
+ atf_check -s exit:0 -o match:"basic: hello, world \(unix\)" \
+ tail -n 1 "${logfile}"
+
+ # Grab kernel configuration file.
+ sysctl kern.conftxt > conf.txt
+
+ # We have INET transport; make sure we can use it.
+ if grep -qw "INET" conf.txt; then
+ syslogd_log -4 -p user.debug -t basic -h 127.0.0.1 -P "${SYSLOGD_UDP_PORT}" \
+ "hello, world (v4)"
+ atf_check -s exit:0 -o match:"basic: hello, world \(v4\)" \
+ tail -n 1 "${logfile}"
+ fi
+ # We have INET6 transport; make sure we can use it.
+ if grep -qw "INET6" conf.txt; then
+ syslogd_log -6 -p user.debug -t basic -h ::1 -P "${SYSLOGD_UDP_PORT}" \
+ "hello, world (v6)"
+ atf_check -s exit:0 -o match:"basic: hello, world \(v6\)" \
+ tail -n 1 "${logfile}"
+ fi
+}
+basic_cleanup()
+{
+ syslogd_stop
+}
+
+atf_test_case "reload" "cleanup"
+reload_head()
+{
+ atf_set descr "SIGHUP correctly refreshes configuration"
+}
+reload_body()
+{
+ logfile="${PWD}/reload.log"
+ printf "user.debug\t/${logfile}\n" > "${SYSLOGD_CONFIG}"
+ syslogd_start
+
+ syslogd_log -p user.debug -t reload -h "${SYSLOGD_LOCAL_SOCKET}" \
+ "pre-reload"
+ atf_check -s exit:0 -o match:"reload: pre-reload" tail -n 1 "${logfile}"
+
+ # Override the old rule.
+ truncate -s 0 "${logfile}"
+ printf "news.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}"
+ syslogd_reload
+
+ syslogd_log -p user.debug -t reload -h "${SYSLOGD_LOCAL_SOCKET}" \
+ "post-reload user"
+ syslogd_log -p news.debug -t reload -h "${SYSLOGD_LOCAL_SOCKET}" \
+ "post-reload news"
+ atf_check -s exit:0 -o not-match:"reload: post-reload user" cat ${logfile}
+ atf_check -s exit:0 -o match:"reload: post-reload news" cat ${logfile}
+}
+reload_cleanup()
+{
+ syslogd_stop
+}
+
+atf_test_case "prog_filter" "cleanup"
+prog_filter_head()
+{
+ atf_set descr "Messages are only received from programs in the filter"
+}
+prog_filter_body()
+{
+ logfile="${PWD}/prog_filter.log"
+ printf "!prog1,prog2\nuser.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}"
+ syslogd_start
+
+ for i in 1 2 3; do
+ syslogd_log -p user.debug -t "prog${i}" -h "${SYSLOGD_LOCAL_SOCKET}" \
+ "hello this is prog${i}"
+ done
+ atf_check -s exit:0 -o match:"prog1: hello this is prog1" cat "${logfile}"
+ atf_check -s exit:0 -o match:"prog2: hello this is prog2" cat "${logfile}"
+ atf_check -s exit:0 -o not-match:"prog3: hello this is prog3" cat "${logfile}"
+
+ # Override the old rule.
+ truncate -s 0 ${logfile}
+ printf "!-prog1,prog2\nuser.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}"
+ syslogd_reload
+
+ for i in 1 2 3; do
+ syslogd_log -p user.debug -t "prog${i}" -h "${SYSLOGD_LOCAL_SOCKET}" \
+ "hello this is prog${i}"
+ done
+ atf_check -s exit:0 -o not-match:"prog1: hello this is prog1" cat "${logfile}"
+ atf_check -s exit:0 -o not-match:"prog2: hello this is prog2" cat "${logfile}"
+ atf_check -s exit:0 -o match:"prog3: hello this is prog3" cat "${logfile}"
+}
+prog_filter_cleanup()
+{
+ syslogd_stop
+}
+
+atf_test_case "host_filter" "cleanup"
+host_filter_head()
+{
+ atf_set descr "Messages are only received from hostnames in the filter"
+}
+host_filter_body()
+{
+ logfile="${PWD}/host_filter.log"
+ printf "+host1,host2\nuser.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}"
+ syslogd_start
+
+ for i in 1 2 3; do
+ syslogd_log -p user.debug -t "host${i}" -H "host${i}" \
+ -h "${SYSLOGD_LOCAL_SOCKET}" "hello this is host${i}"
+ done
+ atf_check -s exit:0 -o match:"host1: hello this is host1" cat "${logfile}"
+ atf_check -s exit:0 -o match:"host2: hello this is host2" cat "${logfile}"
+ atf_check -s exit:0 -o not-match:"host3: hello this is host3" cat "${logfile}"
+
+ # Override the old rule.
+ truncate -s 0 ${logfile}
+ printf "\-host1,host2\nuser.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}"
+ syslogd_reload
+
+ for i in 1 2 3; do
+ syslogd_log -p user.debug -t "host${i}" -H "host${i}" \
+ -h "${SYSLOGD_LOCAL_SOCKET}" "hello this is host${i}"
+ done
+ atf_check -s exit:0 -o not-match:"host1: hello this is host1" cat "${logfile}"
+ atf_check -s exit:0 -o not-match:"host2: hello this is host2" cat "${logfile}"
+ atf_check -s exit:0 -o match:"host3: hello this is host3" cat "${logfile}"
+}
+host_filter_cleanup()
+{
+ syslogd_stop
+}
+
+atf_test_case "prop_filter" "cleanup"
+prop_filter_head()
+{
+ atf_set descr "Messages are received based on conditions in the propery based filter"
+}
+prop_filter_body()
+{
+ logfile="${PWD}/prop_filter.log"
+ printf ":msg,contains,\"FreeBSD\"\nuser.debug\t${logfile}\n" \
+ > "${SYSLOGD_CONFIG}"
+ syslogd_start
+
+ syslogd_log -p user.debug -t "prop1" -h "${SYSLOGD_LOCAL_SOCKET}" "FreeBSD"
+ syslogd_log -p user.debug -t "prop2" -h "${SYSLOGD_LOCAL_SOCKET}" "freebsd"
+ atf_check -s exit:0 -o match:"prop1: FreeBSD" cat "${logfile}"
+ atf_check -s exit:0 -o not-match:"prop2: freebsd" cat "${logfile}"
+
+ truncate -s 0 ${logfile}
+ printf ":msg,!contains,\"FreeBSD\"\nuser.debug\t${logfile}\n" \
+ > "${SYSLOGD_CONFIG}"
+ syslogd_reload
+
+ syslogd_log -p user.debug -t "prop1" -h "${SYSLOGD_LOCAL_SOCKET}" "FreeBSD"
+ syslogd_log -p user.debug -t "prop2" -h "${SYSLOGD_LOCAL_SOCKET}" "freebsd"
+ atf_check -s exit:0 -o not-match:"prop1: FreeBSD" cat "${logfile}"
+ atf_check -s exit:0 -o match:"prop2: freebsd" cat "${logfile}"
+
+ truncate -s 0 ${logfile}
+ printf ":msg,icase_contains,\"FreeBSD\"\nuser.debug\t${logfile}\n" \
+ > "${SYSLOGD_CONFIG}"
+ syslogd_reload
+
+ syslogd_log -p user.debug -t "prop1" -h "${SYSLOGD_LOCAL_SOCKET}" "FreeBSD"
+ syslogd_log -p user.debug -t "prop2" -h "${SYSLOGD_LOCAL_SOCKET}" "freebsd"
+ atf_check -s exit:0 -o match:"prop1: FreeBSD" cat "${logfile}"
+ atf_check -s exit:0 -o match:"prop2: freebsd" cat "${logfile}"
+
+ truncate -s 0 ${logfile}
+ printf ":msg,!icase_contains,\"FreeBSD\"\nuser.debug\t${logfile}\n" \
+ > "${SYSLOGD_CONFIG}"
+ syslogd_reload
+
+ syslogd_log -p user.debug -t "prop1" -h "${SYSLOGD_LOCAL_SOCKET}" "FreeBSD"
+ syslogd_log -p user.debug -t "prop2" -h "${SYSLOGD_LOCAL_SOCKET}" "freebsd"
+ syslogd_log -p user.debug -t "prop3" -h "${SYSLOGD_LOCAL_SOCKET}" "Solaris"
+ atf_check -s exit:0 -o not-match:"prop1: FreeBSD" cat "${logfile}"
+ atf_check -s exit:0 -o not-match:"prop2: freebsd" cat "${logfile}"
+ atf_check -s exit:0 -o match:"prop3: Solaris" cat "${logfile}"
+}
+prop_filter_cleanup()
+{
+ syslogd_stop
+}
+
+atf_test_case "pipe_action" "cleanup"
+pipe_action_head()
+{
+ atf_set descr "The pipe action evaluates provided command in sh(1)"
+}
+pipe_action_body()
+{
+ logfile="${PWD}/pipe_action.log"
+ printf "\"While I'm digging in the tunnel, the elves will often come to me \
+ with solutions to my problem.\"\n-Saymore Crey" > ${logfile}
+
+ printf "!pipe\nuser.debug\t| sed -i '' -e 's/Saymore Crey/Seymour Cray/g' \
+ ${logfile}\n" > "${SYSLOGD_CONFIG}"
+ syslogd_start
+
+ syslogd_log -p user.debug -t "pipe" -h "${SYSLOGD_LOCAL_SOCKET}" \
+ "fix spelling error"
+ atf_check -s exit:0 -o match:"Seymour Cray" cat "${logfile}"
+}
+pipe_action_cleanup()
+{
+ syslogd_stop
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case "basic"
+ atf_add_test_case "reload"
+ atf_add_test_case "prog_filter"
+ atf_add_test_case "host_filter"
+ atf_add_test_case "prop_filter"
+ atf_add_test_case "pipe_action"
+}
diff --git a/usr.sbin/sysrc/Makefile b/usr.sbin/sysrc/Makefile
index 1ace38af4867..831ce5d135bd 100644
--- a/usr.sbin/sysrc/Makefile
+++ b/usr.sbin/sysrc/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SCRIPTS= sysrc
diff --git a/usr.sbin/sysrc/Makefile.depend b/usr.sbin/sysrc/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/sysrc/Makefile.depend
+++ b/usr.sbin/sysrc/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc
index 5c24d1d4f831..1766cf7ab835 100644
--- a/usr.sbin/sysrc/sysrc
+++ b/usr.sbin/sysrc/sysrc
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
############################################################ INCLUDES
diff --git a/usr.sbin/sysrc/sysrc.8 b/usr.sbin/sysrc/sysrc.8
index 6d5bd0e91f53..bdf3353c2cf9 100644
--- a/usr.sbin/sysrc/sysrc.8
+++ b/usr.sbin/sysrc/sysrc.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 3, 2022
.Dt SYSRC 8
.Os
diff --git a/usr.sbin/tcpdchk/Makefile b/usr.sbin/tcpdchk/Makefile
index 2cbadf29f655..93fc23169ea0 100644
--- a/usr.sbin/tcpdchk/Makefile
+++ b/usr.sbin/tcpdchk/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/tcpdchk/Makefile.depend b/usr.sbin/tcpdchk/Makefile.depend
index 8af4779ea996..0f04a84483b2 100644
--- a/usr.sbin/tcpdchk/Makefile.depend
+++ b/usr.sbin/tcpdchk/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/tcpdmatch/Makefile b/usr.sbin/tcpdmatch/Makefile
index 81e04e758225..e12bde64c493 100644
--- a/usr.sbin/tcpdmatch/Makefile
+++ b/usr.sbin/tcpdmatch/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/tcpdmatch/Makefile.depend b/usr.sbin/tcpdmatch/Makefile.depend
index 8af4779ea996..0f04a84483b2 100644
--- a/usr.sbin/tcpdmatch/Makefile.depend
+++ b/usr.sbin/tcpdmatch/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/tcpdrop/Makefile b/usr.sbin/tcpdrop/Makefile
index 2fc606a26392..58a9e05d46a5 100644
--- a/usr.sbin/tcpdrop/Makefile
+++ b/usr.sbin/tcpdrop/Makefile
@@ -1,5 +1,4 @@
# $OpenBSD: Makefile,v 1.1 2004/04/26 19:51:20 markus Exp $
-# $FreeBSD$
PROG= tcpdrop
MAN= tcpdrop.8
diff --git a/usr.sbin/tcpdrop/Makefile.depend b/usr.sbin/tcpdrop/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/tcpdrop/Makefile.depend
+++ b/usr.sbin/tcpdrop/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/tcpdrop/tcpdrop.8 b/usr.sbin/tcpdrop/tcpdrop.8
index 2549a2ec0ad7..4b9c654ffb6f 100644
--- a/usr.sbin/tcpdrop/tcpdrop.8
+++ b/usr.sbin/tcpdrop/tcpdrop.8
@@ -15,8 +15,6 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 4, 2021
.Dt TCPDROP 8
.Os
diff --git a/usr.sbin/tcpdrop/tcpdrop.c b/usr.sbin/tcpdrop/tcpdrop.c
index 135f1b52c403..6f6b94789df1 100644
--- a/usr.sbin/tcpdrop/tcpdrop.c
+++ b/usr.sbin/tcpdrop/tcpdrop.c
@@ -17,9 +17,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -58,7 +55,7 @@ static bool tcpdropall(const char *, const char *, int);
static bool tcpdropbyname(const char *, const char *, const char *,
const char *);
static bool tcpdropconn(const struct in_conninfo *);
-static void usage(void);
+static void usage(void) __dead2;
/*
* Drop a tcp connection.
diff --git a/usr.sbin/tcpdump/Makefile b/usr.sbin/tcpdump/Makefile
index d183febb134b..dd899258ebae 100644
--- a/usr.sbin/tcpdump/Makefile
+++ b/usr.sbin/tcpdump/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 0.1 (RGrimes) 4/4/93
-# $FreeBSD$
SUBDIR= tcpdump
diff --git a/usr.sbin/tcpdump/Makefile.inc b/usr.sbin/tcpdump/Makefile.inc
index 6c4b6e22ba1c..c5de27435b82 100644
--- a/usr.sbin/tcpdump/Makefile.inc
+++ b/usr.sbin/tcpdump/Makefile.inc
@@ -1,5 +1,3 @@
-# @(#)Makefile.inc 5.1 (Berkeley) 5/11/90
-# $FreeBSD$
BINDIR?= /usr/sbin
diff --git a/usr.sbin/tcpdump/tcpdump/Makefile b/usr.sbin/tcpdump/tcpdump/Makefile
index 1133a0a150d5..ff0106d29336 100644
--- a/usr.sbin/tcpdump/tcpdump/Makefile
+++ b/usr.sbin/tcpdump/tcpdump/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
@@ -13,14 +12,16 @@ SRCS= addrtoname.c \
ascii_strcasecmp.c \
checksum.c \
cpack.c \
+ fptype.c \
gmpls.c \
- gmt2local.c \
in_cksum.c \
ipproto.c \
l2vpn.c \
machdep.c \
netdissect.c \
+ netdissect-alloc.c \
nlpid.c \
+ ntp.c \
oui.c \
parsenfsfh.c \
print.c \
@@ -99,7 +100,6 @@ SRCS= addrtoname.c \
print-lwapp.c \
print-lwres.c \
print-m3ua.c \
- print-medsa.c \
print-mobile.c \
print-mobility.c \
print-mpcp.c \
@@ -107,6 +107,7 @@ SRCS= addrtoname.c \
print-mptcp.c \
print-msdp.c \
print-msnlb.c \
+ print-nflog.c \
print-nfs.c \
print-nsh.c \
print-ntp.c \
@@ -130,7 +131,6 @@ SRCS= addrtoname.c \
print-rip.c \
print-ripng.c \
print-rpki-rtr.c \
- print-rrcp.c \
print-rsvp.c \
print-rt6.c \
print-rtsp.c \
@@ -157,6 +157,7 @@ SRCS= addrtoname.c \
print-token.c \
print-udld.c \
print-udp.c \
+ print-usb.c \
print-vjc.c \
print-vqp.c \
print-vrrp.c \
@@ -166,12 +167,27 @@ SRCS= addrtoname.c \
print-wb.c \
print-zephyr.c \
print-zeromq.c \
- setsignal.c \
signature.c \
smbutil.c \
strtoaddr.c \
tcpdump.c \
util-print.c \
+ print-arista.c \
+ print-bcm-li.c \
+ print-brcmtag.c \
+ print-dsa.c \
+ print-ip-demux.c \
+ print-ipoib.c \
+ print-macsec.c \
+ print-openflow-1.3.c \
+ print-ptp.c \
+ print-realtek.c \
+ print-someip.c \
+ print-ssh.c \
+ print-unsupported.c \
+ print-vsock.c \
+ print-whois.c \
+ print-zep.c \
version.c
CLEANFILES+= version.c ${MAN}
@@ -196,6 +212,7 @@ CFLAGS+=-DHAVE_CASPER
LIBADD+= crypto
CFLAGS+= -I${SYSROOT:U${DESTDIR}}/usr/include/openssl
CFLAGS+= -DHAVE_LIBCRYPTO -DHAVE_OPENSSL_EVP_H
+CFLAGS+= -DOPENSSL_API_COMPAT=0x10100000L
.endif
.if ${MK_PF} != "no"
diff --git a/usr.sbin/tcpdump/tcpdump/Makefile.depend b/usr.sbin/tcpdump/tcpdump/Makefile.depend
index 45d244118e6d..30a449014390 100644
--- a/usr.sbin/tcpdump/tcpdump/Makefile.depend
+++ b/usr.sbin/tcpdump/tcpdump/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
@@ -9,12 +8,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libnv \
lib/libpcap \
- lib/libthr \
- lib/ofed/libibverbs \
- lib/ofed/libmlx5 \
- usr.bin/lex/lib \
.include <dirdeps.mk>
diff --git a/usr.sbin/tcpdump/tcpdump/Makefile.depend.options b/usr.sbin/tcpdump/tcpdump/Makefile.depend.options
index e5807369dda2..e111e9fc3536 100644
--- a/usr.sbin/tcpdump/tcpdump/Makefile.depend.options
+++ b/usr.sbin/tcpdump/tcpdump/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= CASPER OPENSSL
diff --git a/usr.sbin/tcpdump/tcpdump/config.h b/usr.sbin/tcpdump/tcpdump/config.h
index 8980b31c8591..8fc7d8c2523f 100644
--- a/usr.sbin/tcpdump/tcpdump/config.h
+++ b/usr.sbin/tcpdump/tcpdump/config.h
@@ -1,25 +1,20 @@
-/* $FreeBSD$ */
/* This is an edited copy of the config.h generated by configure. */
/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.in by autoheader. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if arpa/inet.h declares `ether_ntohost' */
+/* #undef ARPA_INET_H_DECLARES_ETHER_NTOHOST */
/* define if you want to build the possibly-buggy SMB printer */
#define ENABLE_SMB 1
-/* Define to 1 if you have the `alarm' function. */
-#define HAVE_ALARM 1
-
/* Define to 1 if you have the `bpf_dump' function. */
#define HAVE_BPF_DUMP 1
/* capsicum support available */
#define HAVE_CAPSICUM 1
-/* Casper library support available */
-/* See Makefile */
-/* #undef HAVE_CASPER */
-
/* Define to 1 if you have the `cap_enter' function. */
#define HAVE_CAP_ENTER 1
@@ -32,12 +27,12 @@
/* Define to 1 if you have the `cap_rights_limit' function. */
#define HAVE_CAP_RIGHTS_LIMIT 1
-/* Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
- don't. */
-#define HAVE_DECL_ETHER_NTOHOST 1
+/* Casper library support available */
+/* See Makefile */
+/* #undef HAVE_CASPER */
-/* define if you have the dnet_htoa function */
-/* #undef HAVE_DNET_HTOA */
+/* Define to 1 if you have the declaration of `ether_ntohost' */
+/* #undef HAVE_DECL_ETHER_NTOHOST */
/* Define to 1 if you have the `ether_ntohost' function. */
#define HAVE_ETHER_NTOHOST 1
@@ -45,6 +40,9 @@
/* Define to 1 if you have the `EVP_CIPHER_CTX_new' function. */
#define HAVE_EVP_CIPHER_CTX_NEW 1
+/* Define to 1 if you have the `EVP_DecryptInit_ex' function. */
+#define HAVE_EVP_DECRYPTINIT_EX 1
+
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
@@ -57,6 +55,9 @@
/* define if you have getrpcbynumber() */
#define HAVE_GETRPCBYNUMBER 1
+/* Define to 1 if you have the `getservent' function. */
+#define HAVE_GETSERVENT 1
+
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
@@ -73,43 +74,24 @@
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
-/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */
-/* #undef HAVE_NETDNET_DNETDB_H */
-
-/* define if you have a dnet_htoa declaration in <netdnet/dnetdb.h> */
-/* #undef HAVE_NETDNET_DNETDB_H_DNET_HTOA */
-
-/* Define to 1 if you have the <netinet/ether.h> header file. */
-/* #undef HAVE_NETINET_ETHER_H */
-
-/* Define to 1 if you have the <netinet/if_ether.h> header file. */
-#define HAVE_NETINET_IF_ETHER_H 1
+/* Define to 1 if you have the <net/if.h> header file. */
+#define HAVE_NET_IF_H 1
-/* Define to 1 if you have the <net/if_pflog.h> header file. */
-/* See Makefile */
-/* #undef HAVE_NET_IF_PFLOG_H */
-
-/* Define to 1 if you have the <net/pfvar.h> header file. */
-/* See Makefile */
-/* #undef HAVE_NET_PFVAR_H */
+/* Define to 1 if printf(3) does not support the z length modifier. */
+/* #undef HAVE_NO_PRINTF_Z */
/* Define to 1 if you have the `openat' function. */
#define HAVE_OPENAT 1
/* Define to 1 if you have the <openssl/evp.h> header file. */
-/* See Makefile */
-/* #undef HAVE_OPENSSL_EVP_H 1 */
+#define HAVE_OPENSSL_EVP_H 1
/* define if the OS provides AF_INET6 and struct in6_addr */
-/* See Makefile */
-/* #undef HAVE_OS_IPV6_SUPPORT */
-
+#define HAVE_OS_IPV6_SUPPORT 1
+
/* if there's an os_proto.h for this platform, to use additional prototypes */
/* #undef HAVE_OS_PROTO_H */
-/* Define to 1 if you have the <pcap/bluetooth.h> header file. */
-/* #undef HAVE_PCAP_BLUETOOTH_H */
-
/* Define to 1 if you have the `pcap_breakloop' function. */
#define HAVE_PCAP_BREAKLOOP 1
@@ -128,12 +110,18 @@
/* Define to 1 if you have the `pcap_dump_flush' function. */
#define HAVE_PCAP_DUMP_FLUSH 1
-/* define if libpcap has pcap_dump_ftell() */
+/* Define to 1 if you have the `pcap_dump_ftell' function. */
#define HAVE_PCAP_DUMP_FTELL 1
+/* Define to 1 if you have the `pcap_dump_ftell64' function. */
+#define HAVE_PCAP_DUMP_FTELL64 1
+
/* Define to 1 if you have the `pcap_findalldevs' function. */
#define HAVE_PCAP_FINDALLDEVS 1
+/* Define to 1 if you have the `pcap_findalldevs_ex' function. */
+/* #undef HAVE_PCAP_FINDALLDEVS_EX */
+
/* Define to 1 if you have the `pcap_free_datalinks' function. */
#define HAVE_PCAP_FREE_DATALINKS 1
@@ -146,8 +134,11 @@
/* define if libpcap has pcap_list_datalinks() */
#define HAVE_PCAP_LIST_DATALINKS 1
-/* Define to 1 if you have the <pcap/nflog.h> header file. */
-/* #undef HAVE_PCAP_NFLOG_H */
+/* Define to 1 if you have the `pcap_open' function. */
+/* #undef HAVE_PCAP_OPEN */
+
+/* Define to 1 if you have the <pcap/pcap-inttypes.h> header file. */
+#define HAVE_PCAP_PCAP_INTTYPES_H 1
/* Define to 1 if you have the `pcap_setdirection' function. */
#define HAVE_PCAP_SETDIRECTION 1
@@ -170,9 +161,6 @@
/* Define to 1 if you have the `pcap_set_tstamp_type' function. */
#define HAVE_PCAP_SET_TSTAMP_TYPE 1
-/* Define to 1 if you have the <pcap/usb.h> header file. */
-/* #undef HAVE_PCAP_USB_H */
-
/* define if libpcap has pcap_version */
/* #undef HAVE_PCAP_VERSION */
@@ -188,18 +176,6 @@
/* Define to 1 if you have the `setlinebuf' function. */
#define HAVE_SETLINEBUF 1
-/* Define to 1 if you have the `sigaction' function. */
-#define HAVE_SIGACTION 1
-
-/* Define to 1 if you have the `sigset' function. */
-/* #undef HAVE_SIGSET */
-
-/* Define to 1 if you have the `snprintf' function. */
-#define HAVE_SNPRINTF 1
-
-/* if struct sockaddr has the sa_len member */
-#define HAVE_SOCKADDR_SA_LEN 1
-
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
@@ -209,9 +185,6 @@
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
-/* Define to 1 if you have the `strftime' function. */
-#define HAVE_STRFTIME 1
-
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
@@ -245,71 +218,47 @@
/* Define to 1 if you have the `vfork' function. */
#define HAVE_VFORK 1
-/* Define to 1 if you have the `vfprintf' function. */
-#define HAVE_VFPRINTF 1
-
-/* Define to 1 if you have the `vsnprintf' function. */
-#define HAVE_VSNPRINTF 1
-
/* define if libpcap has yydebug */
/* #undef HAVE_YYDEBUG */
-/* define if your compiler has __attribute__ */
-#define HAVE___ATTRIBUTE__ 1
-
-/* if unaligned access fails */
-/* #undef LBL_ALIGN */
-
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
/* #undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */
/* Define to 1 if netinet/if_ether.h declares `ether_ntohost' */
-#define NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST /**/
+/* #undef NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST */
+
+/* Define to 1 if net/ethernet.h declares `ether_ntohost' */
+/* #undef NET_ETHERNET_H_DECLARES_ETHER_NTOHOST */
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
-#define PACKAGE_NAME ""
+#define PACKAGE_NAME "tcpdump"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING ""
+#define PACKAGE_STRING "tcpdump 4.99.4"
/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME ""
+#define PACKAGE_TARNAME "tcpdump"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION ""
+#define PACKAGE_VERSION "4.99.4"
-/* define if the platform doesn't define PRId64 */
-/* #undef PRId64 */
-
-/* define if the platform doesn't define PRIo64 */
-/* #undef PRIo64 */
-
-/* define if the platform doesn't define PRIx64 */
-/* #undef PRIu64 */
-
-/* define if the platform doesn't define PRIu64 */
-/* #undef PRIx64 */
-
-/* Define as the return type of signal handlers (`int' or `void'). */
-#define RETSIGTYPE void
-
-/* return value of signal handlers */
-#define RETSIGVAL /**/
+/* The size of `void *', as computed by sizeof. */
+/* #undef SIZEOF_VOID_P */
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-#define TIME_WITH_SYS_TIME 1
+/* Define to 1 if sys/ethernet.h declares `ether_ntohost' */
+/* #undef SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST */
/* define if you have ether_ntohost() and it works */
-#define USE_ETHER_NTOHOST 1
+/* #undef USE_ETHER_NTOHOST */
/* Define if you enable support for libsmi */
/* #undef USE_LIBSMI */
@@ -320,60 +269,15 @@
/* define if should drop privileges by default */
/* #undef WITH_USER */
-/* get BSD semantics on Irix */
-/* #undef _BSD_SIGNALS */
-
/* define on AIX to get certain functions */
/* #undef _SUN */
-/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
- <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
- #define below would cause a syntax error. */
-/* #undef _UINT32_T */
-
-/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
- <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
- #define below would cause a syntax error. */
-/* #undef _UINT64_T */
-
-/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
- <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
- #define below would cause a syntax error. */
-/* #undef _UINT8_T */
-
-/* define if your compiler allows __attribute__((format)) without a warning */
-#define __ATTRIBUTE___FORMAT_OK 1
-
-/* define if your compiler allows __attribute__((format)) to be applied to
- function pointers */
-#define __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS 1
-
-/* define if your compiler allows __attribute__((noreturn)) to be applied to
- function pointers */
-#define __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS 1
-
/* to handle Ultrix compilers that don't support const in prototypes */
/* #undef const */
/* Define as token for inline if inlining supported */
#define inline inline
-/* Define to the type of a signed integer type of width exactly 16 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef int16_t */
-
-/* Define to the type of a signed integer type of width exactly 32 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef int32_t */
-
-/* Define to the type of a signed integer type of width exactly 64 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef int64_t */
-
-/* Define to the type of a signed integer type of width exactly 8 bits if such
- a type exists and the standard includes do not define it. */
-/* #undef int8_t */
-
/* Define to `uint16_t' if u_int16_t not defined. */
/* #undef u_int16_t */
@@ -386,22 +290,6 @@
/* Define to `uint8_t' if u_int8_t not defined. */
/* #undef u_int8_t */
-/* Define to the type of an unsigned integer type of width exactly 16 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef uint16_t */
-
-/* Define to the type of an unsigned integer type of width exactly 32 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef uint32_t */
-
-/* Define to the type of an unsigned integer type of width exactly 64 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef uint64_t */
-
-/* Define to the type of an unsigned integer type of width exactly 8 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef uint8_t */
-
/* Define to the type of an unsigned integer type wide enough to hold a
pointer, if such a type exists, and if the system does not define it. */
/* #undef uintptr_t */
diff --git a/usr.sbin/tcpsso/tcpsso.8 b/usr.sbin/tcpsso/tcpsso.8
index b3aee93ae5da..37968c8afa54 100644
--- a/usr.sbin/tcpsso/tcpsso.8
+++ b/usr.sbin/tcpsso/tcpsso.8
@@ -1,5 +1,5 @@
.\"
-.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2022 Michael Tuexen <tuexen@FreeBSD.org>
.\"
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd February 10, 2022
+.Dd January 14, 2024
.Dt TCPSSO 8
.Os
.Sh NAME
@@ -73,8 +73,15 @@ and value
.Ar optval
on a TCP endpoint from the command line.
.Pp
+TCP endpoints in the
+.Dv SYN_RCVD
+state can only be handled by
+.Nm
+if their prior state was
+.Dv SYN_SENT .
+.Pp
.Op Ar level
-can be specified as a non negative number or a symbolic name like
+can be specified as a non-negative number or a symbolic name like
.Dv SOL_SOCKET ,
.Dv IPPROTO_IP ,
.Dv IPPROTO_IPV6 ,
@@ -90,7 +97,7 @@ If that is not the case,
is used.
.Pp
.Ar optname
-can be specified as a non negative number or a symbolic name like
+can be specified as a non-negative number or a symbolic name like
.Dv SO_DEBUG ,
.Dv IP_TOS ,
.Dv IPV6_TCLASS ,
@@ -100,7 +107,7 @@ or
.Dv TCP_FUNCTION_BLK .
.Pp
.Ar optval
-can be in integer value, which will be converted to a binary value and
+can be an integer value, which will be converted to a binary value and
passed as an int value.
If it cannot be parsed as an integer value, it will be processed as a string.
If the
@@ -129,8 +136,8 @@ If
.Fl a
is specified then
.Nm
-will apply the socket option to all TCP endpoints not being in the state
-.Dv TIME_WAIT .
+will apply the socket option to all TCP endpoints subject to the above state
+restrictions.
.Pp
If
.Fl C Ar cc-algo
@@ -139,8 +146,7 @@ is specified then
will apply the socket option to all TCP endpoints using the TCP
congestion control algorithm
.Ar cc-algo
-and not being in the state
-.Dv TIME_WAIT .
+and subject to the above state restrictions.
.Pp
If
.Fl S Ar stack
@@ -149,8 +155,7 @@ is specified then
will apply the socket option to all TCP endpoints using the TCP
stack
.Ar stack
-and not being in the state
-.Dv TIME_WAIT .
+and subject to the above state restrictions.
.Pp
If
.Fl s Ar state
@@ -169,7 +174,15 @@ is one of
.Dv FIN_WAIT_1 ,
.Dv CLOSING ,
.Dv LAST_ACK ,
-.Dv FIN_WAIT_2 .
+.Dv FIN_WAIT_2,
+or
+.Dv TIME_WAIT .
+Using
+.Dv SYN_RCVD
+only applies to TCP endpoints in the state
+.Dv SYN_RCVD
+if their prior state was
+.Dv SYN_SENT .
.Pp
If multiple of
.Fl C Ar cc-algo ,
@@ -178,10 +191,8 @@ and
.Fl s Ar state
are specified,
.Nm
-will apply the socket option to all TCP endpoints not being in the
-state
-.Dv TIME_WAIT
-and using the congestion control algorithm
+will apply the socket option to all TCP endpoints using the congestion
+control algorithm
.Ar cc-algo ,
being in the state
.Ar state ,
diff --git a/usr.sbin/tcpsso/tcpsso.c b/usr.sbin/tcpsso/tcpsso.c
index 2ac4d0c57d1d..7e7e25246d80 100644
--- a/usr.sbin/tcpsso/tcpsso.c
+++ b/usr.sbin/tcpsso/tcpsso.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 Michael Tuexen <tuexen@FreeBSD.org>
* Copyright (c) 2009 Juli Mallett <jmallett@FreeBSD.org>
@@ -115,10 +115,6 @@ tcpssoall(const char *ca_name, const char *stack, int state,
continue;
- /* Skip endpoints in TIME WAIT. */
- if (xtp->t_state == TCPS_TIME_WAIT)
- continue;
-
/* If requested, skip sockets not having the requested state. */
if ((state != -1) && (xtp->t_state != state))
continue;
@@ -192,6 +188,7 @@ static struct so_name so_names[] = {
tcp_entry(TCP_REMOTE_UDP_ENCAPS_PORT), /* int */
tcp_entry(TCP_MAXSEG), /* int */
tcp_entry(TCP_TXTLS_MODE), /* unsigned int */
+ tcp_entry(TCP_MAXUNACKTIME), /* unsigned int */
tcp_entry(TCP_KEEPIDLE), /* unsigned int */
tcp_entry(TCP_KEEPINTVL), /* unsigned int */
tcp_entry(TCP_KEEPINIT), /* unsigned int */
@@ -452,7 +449,6 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
if ((state == TCP_NSTATES) ||
- (state == TCPS_TIME_WAIT) ||
(argc < 2) || (argc > 3) ||
(apply_all && apply_subset) ||
(apply_all && apply_specific) ||
diff --git a/usr.sbin/tests/Makefile b/usr.sbin/tests/Makefile
index 3b3078f8612a..b8996030aafc 100644
--- a/usr.sbin/tests/Makefile
+++ b/usr.sbin/tests/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/usr.sbin/tests/Makefile.depend b/usr.sbin/tests/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/tests/Makefile.depend
+++ b/usr.sbin/tests/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/traceroute/Makefile b/usr.sbin/traceroute/Makefile
index e90019fedb5d..45a80174f5ab 100644
--- a/usr.sbin/traceroute/Makefile
+++ b/usr.sbin/traceroute/Makefile
@@ -1,24 +1,13 @@
-# $FreeBSD$
.include <src.opts.mk>
-TRACEROUTE_DISTDIR?= ${SRCTOP}/contrib/traceroute
-.PATH: ${TRACEROUTE_DISTDIR}
-
PACKAGE= runtime
PROG= traceroute
MAN= traceroute.8
-SRCS= as.c version.c traceroute.c ifaddrlist.c findsaddr-udp.c
+SRCS= as.c traceroute.c ifaddrlist.c findsaddr-udp.c
BINOWN= root
BINMODE=4555
-CLEANFILES= version.c
-CFLAGS+= -DHAVE_SYS_SELECT_H=1 -DHAVE_SYS_SOCKIO_H=1 \
- -DHAVE_NET_ROUTE_H=1 -DHAVE_NET_IF_DL_H=1 \
- -DHAVE_STRERROR=1 -DHAVE_USLEEP=1 \
- -DHAVE_SYS_SYSCTL_H=1 -DBYTESWAP_IP_HDR=1 \
- -DHAVE_SETLINEBUF=1 -DHAVE_RAW_OPTIONS=1 \
- -DHAVE_SOCKADDR_SA_LEN=1 -DHAVE_ICMP_NEXTMTU=1
.if !defined(TRACEROUTE_NO_IPSEC)
CFLAGS+= -DIPSEC
.endif
@@ -37,14 +26,6 @@ LIBADD+= cap_dns
CFLAGS+=-DWITH_CASPER
.endif
-CFLAGS+= -I${TRACEROUTE_DISTDIR}
-
WARNS?= 3
-version.c: ${TRACEROUTE_DISTDIR}/VERSION
- @rm -f ${.TARGET}
- head -1 ${TRACEROUTE_DISTDIR}/VERSION | \
- sed -e 's/.*/char version[] = "&";/' \
- > ${.TARGET}
-
.include <bsd.prog.mk>
diff --git a/usr.sbin/traceroute/Makefile.depend b/usr.sbin/traceroute/Makefile.depend
index 12fc57a4aaf9..8be8495a06ee 100644
--- a/usr.sbin/traceroute/Makefile.depend
+++ b/usr.sbin/traceroute/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
@@ -10,7 +9,6 @@ DIRDEPS = \
lib/libcapsicum \
lib/libcompiler_rt \
lib/libipsec \
- lib/libnv \
.include <dirdeps.mk>
diff --git a/usr.sbin/traceroute/Makefile.depend.options b/usr.sbin/traceroute/Makefile.depend.options
index a1c8f6278e92..5d5af2276e30 100644
--- a/usr.sbin/traceroute/Makefile.depend.options
+++ b/usr.sbin/traceroute/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= CASPER
diff --git a/usr.sbin/traceroute/as.c b/usr.sbin/traceroute/as.c
new file mode 100644
index 000000000000..7fb952ed3da1
--- /dev/null
+++ b/usr.sbin/traceroute/as.c
@@ -0,0 +1,221 @@
+/* $NetBSD: as.c,v 1.1 2001/11/04 23:14:36 atatat Exp $ */
+
+/*
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Brown.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <err.h>
+#include <stdio.h>
+
+#include "as.h"
+
+#define DEFAULT_AS_SERVER "whois.radb.net"
+#undef AS_DEBUG_FILE
+
+struct aslookup {
+ FILE *as_f;
+#ifdef AS_DEBUG_FILE
+ FILE *as_debug;
+#endif /* AS_DEBUG_FILE */
+};
+
+void *
+as_setup(const char *server)
+{
+ struct aslookup *asn;
+ struct addrinfo hints, *res0, *res;
+ FILE *f;
+ int s, error;
+
+ s = -1;
+ if (server == NULL)
+ server = getenv("RA_SERVER");
+ if (server == NULL)
+ server = DEFAULT_AS_SERVER;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = PF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ error = getaddrinfo(server, "whois", &hints, &res0);
+ if (error == EAI_SERVICE) {
+ warnx("warning: whois/tcp service not found");
+ error = getaddrinfo(server, "43", &hints, &res0);
+ }
+ if (error != 0) {
+ warnx("%s: %s", server, gai_strerror(error));
+ return (NULL);
+ }
+
+ for (res = res0; res; res = res->ai_next) {
+ s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (s < 0)
+ continue;
+ if (connect(s, res->ai_addr, res->ai_addrlen) >= 0)
+ break;
+ close(s);
+ s = -1;
+ }
+ freeaddrinfo(res0);
+ if (s < 0) {
+ warn("connect");
+ return (NULL);
+ }
+
+ f = fdopen(s, "r+");
+ (void)fprintf(f, "!!\n");
+ (void)fflush(f);
+
+ asn = malloc(sizeof(struct aslookup));
+ if (asn == NULL)
+ (void)fclose(f);
+ else
+ asn->as_f = f;
+
+#ifdef AS_DEBUG_FILE
+ asn->as_debug = fopen(AS_DEBUG_FILE, "w");
+ if (asn->as_debug) {
+ (void)fprintf(asn->as_debug, ">> !!\n");
+ (void)fflush(asn->as_debug);
+ }
+#endif /* AS_DEBUG_FILE */
+
+ return (asn);
+}
+
+unsigned int
+as_lookup(void *_asn, char *addr, sa_family_t family)
+{
+ struct aslookup *asn = _asn;
+ char buf[1024];
+ unsigned int as;
+ int rc, dlen, plen;
+
+ as = 0;
+ rc = dlen = 0;
+ plen = (family == AF_INET6) ? 128 : 32;
+ (void)fprintf(asn->as_f, "!r%s/%d,l\n", addr, plen);
+ (void)fflush(asn->as_f);
+
+#ifdef AS_DEBUG_FILE
+ if (asn->as_debug) {
+ (void)fprintf(asn->as_debug, ">> !r%s/%d,l\n", addr, plen);
+ (void)fflush(asn->as_debug);
+ }
+#endif /* AS_DEBUG_FILE */
+
+ while (fgets(buf, sizeof(buf), asn->as_f) != NULL) {
+ buf[sizeof(buf) - 1] = '\0';
+
+#ifdef AS_DEBUG_FILE
+ if (asn->as_debug) {
+ (void)fprintf(asn->as_debug, "<< %s", buf);
+ (void)fflush(asn->as_debug);
+ }
+#endif /* AS_DEBUG_FILE */
+
+ if (rc == 0) {
+ rc = buf[0];
+ switch (rc) {
+ case 'A':
+ /* A - followed by # bytes of answer */
+ sscanf(buf, "A%d\n", &dlen);
+#ifdef AS_DEBUG_FILE
+ if (asn->as_debug) {
+ (void)fprintf(asn->as_debug,
+ "dlen: %d\n", dlen);
+ (void)fflush(asn->as_debug);
+ }
+#endif /* AS_DEBUG_FILE */
+ break;
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ /* C - no data returned */
+ /* D - key not found */
+ /* E - multiple copies of key */
+ /* F - some other error */
+ break;
+ }
+ if (rc == 'A')
+ /* skip to next input line */
+ continue;
+ }
+
+ if (dlen == 0)
+ /* out of data, next char read is end code */
+ rc = buf[0];
+ if (rc != 'A')
+ /* either an error off the bat, or a done code */
+ break;
+
+ /* data received, thank you */
+ dlen -= strlen(buf);
+
+ /* origin line is the interesting bit */
+ if (as == 0 && strncasecmp(buf, "origin:", 7) == 0) {
+ sscanf(buf + 7, " AS%u", &as);
+#ifdef AS_DEBUG_FILE
+ if (asn->as_debug) {
+ (void)fprintf(asn->as_debug, "as: %d\n", as);
+ (void)fflush(asn->as_debug);
+ }
+#endif /* AS_DEBUG_FILE */
+ }
+ }
+
+ return (as);
+}
+
+void
+as_shutdown(void *_asn)
+{
+ struct aslookup *asn = _asn;
+
+ (void)fprintf(asn->as_f, "!q\n");
+ (void)fclose(asn->as_f);
+
+#ifdef AS_DEBUG_FILE
+ if (asn->as_debug) {
+ (void)fprintf(asn->as_debug, ">> !q\n");
+ (void)fclose(asn->as_debug);
+ }
+#endif /* AS_DEBUG_FILE */
+
+ free(asn);
+}
diff --git a/usr.sbin/traceroute/as.h b/usr.sbin/traceroute/as.h
new file mode 100644
index 000000000000..f5a5dae2acec
--- /dev/null
+++ b/usr.sbin/traceroute/as.h
@@ -0,0 +1,34 @@
+/* $NetBSD: as.h,v 1.1 2001/11/04 23:14:36 atatat Exp $ */
+
+/*
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Brown.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+void *as_setup(const char *);
+unsigned int as_lookup(void *, char *, sa_family_t);
+void as_shutdown(void *);
diff --git a/usr.sbin/traceroute/findsaddr-socket.c b/usr.sbin/traceroute/findsaddr-socket.c
new file mode 100644
index 000000000000..48b0289f8e06
--- /dev/null
+++ b/usr.sbin/traceroute/findsaddr-socket.c
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2000
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the Computer Systems
+ * Engineering Group at Lawrence Berkeley Laboratory.
+ * 4. Neither the name of the University nor of the Laboratory may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* XXX Yes this is WAY too complicated */
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/time.h> /* concession to AIX */
+
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/route.h>
+#include <netinet/in.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "gnuc.h"
+#include "os-proto.h"
+
+#include "findsaddr.h"
+
+#define SALEN(sa) ((sa)->sa_len)
+
+#ifndef roundup
+#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
+#endif
+
+struct rtmsg {
+ struct rt_msghdr rtmsg;
+ u_char data[512];
+};
+
+static struct rtmsg rtmsg = {
+ { 0, RTM_VERSION, RTM_GET, 0,
+ RTF_UP | RTF_GATEWAY | RTF_HOST | RTF_STATIC,
+ RTA_DST | RTA_IFA, 0, 0, 0, 0, 0, { 0 } },
+ { 0 }
+};
+
+/*
+ * Return the source address for the given destination address
+ */
+const char *
+findsaddr(register const struct sockaddr_in *to,
+ register struct sockaddr_in *from)
+{
+ register struct rt_msghdr *rp;
+ register u_char *cp;
+
+ register struct sockaddr_in *sp, *ifa;
+ register struct sockaddr *sa;
+ register int s, size, cc, seq, i;
+ register pid_t pid;
+ static char errbuf[512];
+
+ s = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC);
+ if (s < 0) {
+ sprintf(errbuf, "socket: %.128s", strerror(errno));
+ return (errbuf);
+ }
+
+ seq = 0;
+ pid = getpid();
+
+ rp = &rtmsg.rtmsg;
+ rp->rtm_seq = ++seq;
+ cp = (u_char *)(rp + 1);
+
+ sp = (struct sockaddr_in *)cp;
+ *sp = *to;
+ cp += roundup(SALEN((struct sockaddr *)sp), sizeof(u_int32_t));
+
+ size = cp - (u_char *)rp;
+ rp->rtm_msglen = size;
+
+ cc = write(s, (char *)rp, size);
+ if (cc < 0) {
+ sprintf(errbuf, "write: %.128s", strerror(errno));
+ close(s);
+ return (errbuf);
+ }
+ if (cc != size) {
+ sprintf(errbuf, "short write (%d != %d)", cc, size);
+ close(s);
+ return (errbuf);
+ }
+
+ size = sizeof(rtmsg);
+ do {
+ memset(rp, 0, size);
+ cc = read(s, (char *)rp, size);
+ if (cc < 0) {
+ sprintf(errbuf, "read: %.128s", strerror(errno));
+ close(s);
+ return (errbuf);
+ }
+
+ } while (rp->rtm_type != RTM_GET || rp->rtm_seq != seq ||
+ rp->rtm_pid != pid);
+ close(s);
+
+
+ if (rp->rtm_version != RTM_VERSION) {
+ sprintf(errbuf, "bad version %d", rp->rtm_version);
+ return (errbuf);
+ }
+ if (rp->rtm_msglen > cc) {
+ sprintf(errbuf, "bad msglen %d > %d", rp->rtm_msglen, cc);
+ return (errbuf);
+ }
+ if (rp->rtm_errno != 0) {
+ sprintf(errbuf, "rtm_errno: %.128s", strerror(rp->rtm_errno));
+ return (errbuf);
+ }
+
+ /* Find the interface sockaddr */
+ cp = (u_char *)(rp + 1);
+ for (i = 1; i != 0; i <<= 1)
+ if ((i & rp->rtm_addrs) != 0) {
+ sa = (struct sockaddr *)cp;
+ switch (i) {
+
+ case RTA_IFA:
+ if (sa->sa_family == AF_INET) {
+ ifa = (struct sockaddr_in *)cp;
+ if (ifa->sin_addr.s_addr != 0) {
+ *from = *ifa;
+ return (NULL);
+ }
+ }
+ break;
+
+ }
+
+ if (SALEN(sa) == 0)
+ cp += sizeof(long);
+ else
+ cp += roundup(SALEN(sa), sizeof(long));
+ }
+
+ return ("failed!");
+}
diff --git a/usr.sbin/traceroute/findsaddr-udp.c b/usr.sbin/traceroute/findsaddr-udp.c
index 57ecc27ce9cd..be193290afde 100644
--- a/usr.sbin/traceroute/findsaddr-udp.c
+++ b/usr.sbin/traceroute/findsaddr-udp.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2010 Bjoern A. Zeeb <bz@FreeBSD.org>
* 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 <string.h>
diff --git a/usr.sbin/traceroute/findsaddr.h b/usr.sbin/traceroute/findsaddr.h
new file mode 100644
index 000000000000..c63d8d55b342
--- /dev/null
+++ b/usr.sbin/traceroute/findsaddr.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2000
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#) $Id: findsaddr.h,v 1.1 2000/11/19 23:13:38 leres Exp $ (LBL)
+ */
+const char *findsaddr(const struct sockaddr_in *, struct sockaddr_in *);
diff --git a/usr.sbin/traceroute/ifaddrlist.c b/usr.sbin/traceroute/ifaddrlist.c
new file mode 100644
index 000000000000..e2b49292fbe7
--- /dev/null
+++ b/usr.sbin/traceroute/ifaddrlist.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 1997, 1998, 1999, 2000
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the Computer Systems
+ * Engineering Group at Lawrence Berkeley Laboratory.
+ * 4. Neither the name of the University nor of the Laboratory may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/time.h> /* concession to AIX */
+
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+
+#include <net/if.h>
+#include <netinet/in.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <memory.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "ifaddrlist.h"
+
+/*
+ * Return the interface list
+ */
+int
+ifaddrlist(register struct ifaddrlist **ipaddrp, register char *errbuf)
+{
+ register int fd, nipaddr;
+ size_t n;
+ register struct ifreq *ifrp, *ifend, *ifnext;
+ register struct sockaddr_in *sin;
+ register struct ifaddrlist *al;
+ struct ifconf ifc;
+ struct ifreq ibuf[(32 * 1024) / sizeof(struct ifreq)], ifr;
+#define MAX_IPADDR ((int)(sizeof(ibuf) / sizeof(ibuf[0])))
+ static struct ifaddrlist ifaddrlist[MAX_IPADDR];
+ char device[sizeof(ifr.ifr_name) + 1];
+
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd < 0) {
+ (void)sprintf(errbuf, "socket: %s", strerror(errno));
+ return (-1);
+ }
+ ifc.ifc_len = sizeof(ibuf);
+ ifc.ifc_buf = (caddr_t)ibuf;
+
+ if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0 ||
+ ifc.ifc_len < (int)sizeof(struct ifreq)) {
+ if (errno == EINVAL)
+ (void)sprintf(errbuf,
+ "SIOCGIFCONF: ifreq struct too small (%zu bytes)",
+ sizeof(ibuf));
+ else
+ (void)sprintf(errbuf, "SIOCGIFCONF: %s",
+ strerror(errno));
+ (void)close(fd);
+ return (-1);
+ }
+ ifrp = ibuf;
+ ifend = (struct ifreq *)((char *)ibuf + ifc.ifc_len);
+
+ al = ifaddrlist;
+ nipaddr = 0;
+ for (; ifrp < ifend; ifrp = ifnext) {
+ n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name);
+ if (n < sizeof(*ifrp))
+ ifnext = ifrp + 1;
+ else
+ ifnext = (struct ifreq *)((char *)ifrp + n);
+ if (ifrp->ifr_addr.sa_family != AF_INET)
+ continue;
+ /*
+ * Need a template to preserve address info that is
+ * used below to locate the next entry. (Otherwise,
+ * SIOCGIFFLAGS stomps over it because the requests
+ * are returned in a union.)
+ */
+ strncpy(ifr.ifr_name, ifrp->ifr_name, sizeof(ifr.ifr_name));
+ if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) {
+ if (errno == ENXIO)
+ continue;
+ (void)sprintf(errbuf, "SIOCGIFFLAGS: %.*s: %s",
+ (int)sizeof(ifr.ifr_name), ifr.ifr_name,
+ strerror(errno));
+ (void)close(fd);
+ return (-1);
+ }
+
+ /* Must be up */
+ if ((ifr.ifr_flags & IFF_UP) == 0)
+ continue;
+
+
+ (void)strlcpy(device, ifr.ifr_name, sizeof(device));
+#ifdef sun
+ /* Ignore sun virtual interfaces */
+ if (strchr(device, ':') != NULL)
+ continue;
+#endif
+ if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) {
+ (void)sprintf(errbuf, "SIOCGIFADDR: %s: %s",
+ device, strerror(errno));
+ (void)close(fd);
+ return (-1);
+ }
+
+ if (nipaddr >= MAX_IPADDR) {
+ (void)sprintf(errbuf, "Too many interfaces (%d)",
+ MAX_IPADDR);
+ (void)close(fd);
+ return (-1);
+ }
+ sin = (struct sockaddr_in *)&ifr.ifr_addr;
+ al->addr = sin->sin_addr.s_addr;
+ al->device = strdup(device);
+ ++al;
+ ++nipaddr;
+ }
+ (void)close(fd);
+
+ *ipaddrp = ifaddrlist;
+ return (nipaddr);
+}
diff --git a/usr.sbin/traceroute/ifaddrlist.h b/usr.sbin/traceroute/ifaddrlist.h
new file mode 100644
index 000000000000..1352e01af4d7
--- /dev/null
+++ b/usr.sbin/traceroute/ifaddrlist.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#) $Header: traceroute.h,v 1.1 97/01/04 19:33:33 leres Locked $ (LBL)
+ */
+
+struct ifaddrlist {
+ u_int32_t addr;
+ char *device;
+};
+
+int ifaddrlist(struct ifaddrlist **, char *);
diff --git a/usr.sbin/traceroute/traceroute.8 b/usr.sbin/traceroute/traceroute.8
new file mode 100644
index 000000000000..203b743fb408
--- /dev/null
+++ b/usr.sbin/traceroute/traceroute.8
@@ -0,0 +1,403 @@
+.\" Copyright (c) 1989, 1995, 1996, 1997, 1999, 2000
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms are permitted
+.\" provided that the above copyright notice and this paragraph are
+.\" duplicated in all such forms and that any documentation,
+.\" advertising materials, and other materials related to such
+.\" distribution and use acknowledge that the software was developed
+.\" by the University of California, Berkeley. The name of the
+.\" University may not be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
+.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+.\"
+.\" $Id: traceroute.8,v 1.19 2000/09/21 08:44:19 leres Exp $
+.\"
+.Dd November 17, 2023
+.Dt TRACEROUTE 8
+.Os
+.Sh NAME
+.Nm traceroute
+.Nd "print the route packets take to network host"
+.Sh SYNOPSIS
+.Nm
+.Bk -words
+.Op Fl adDeEFISnrvx
+.Op Fl A Ar as_server
+.Op Fl f Ar first_ttl
+.Op Fl g Ar gateway
+.Op Fl i Ar iface
+.Op Fl m Ar max_ttl
+.Op Fl M Ar first_ttl
+.Op Fl p Ar port
+.Op Fl P Ar proto
+.Op Fl q Ar nprobes
+.Op Fl s Ar src_addr
+.Op Fl t Ar tos
+.Op Fl w Ar waittime
+.Op Fl z Ar pausemsecs
+.Ar host
+.Op Ar packetlen
+.Ek
+.Sh DESCRIPTION
+The Internet is a large and complex aggregation of network hardware, connected
+together by gateways.
+Tracking the route one's packets follow (or finding the miscreant gateway
+that's discarding your packets) can be difficult.
+.Nm
+utilizes the IP protocol `time to live' field and attempts to elicit an ICMP
+TIME_EXCEEDED response from each gateway along the path to some host.
+.Pp
+The only mandatory parameter is the destination host name or IP number.
+The default probe datagram length is 40 bytes, but this may be increased by
+specifying a packet length (in bytes) after the destination host name.
+.Pp
+Other options are:
+.Bl -tag -width Ds
+.It Fl a
+Turn on AS# lookups for each hop encountered.
+.It Fl A Ar as_server
+Turn on AS# lookups and use the given server instead of the default.
+.It Fl d
+Enable socket level debugging.
+.It Fl D
+When an ICMP response to our probe datagram is received, print the differences
+between the transmitted packet and the packet quoted by the ICMP response.
+A key showing the location of fields within the transmitted packet is printed,
+followed by the original packet in hex, followed by the quoted packet in hex.
+Bytes that are unchanged in the quoted packet are shown as underscores.
+Note, the IP checksum and the TTL of the quoted packet are not expected to
+match.
+By default, only one probe per hop is sent with this option.
+.It Fl e
+Firewall evasion mode.
+Use fixed destination ports for UDP, UDP-Lite, TCP and SCTP probes.
+The destination port does NOT increment with each packet sent.
+.It Fl E
+Detect ECN bleaching.
+Set the
+.Em IPTOS_ECN_ECT1
+Explicit Congestion Notification (ECN) bits
+.Pq Dv 01 ,
+and report if the hop has bleached
+.Pq Dv 00
+or mangled
+.Pq Dv 10
+them, or if it is experiencing congestion
+.Pq Dv 11 .
+Otherwise, report that it passed the bits appropriately.
+If
+.Fl t
+is also specified, the corresponding ECN bits will be replaced.
+.It Fl f Ar first_ttl
+Set the initial time-to-live used in the first outgoing probe packet.
+.It Fl F
+Set the "don't fragment" bit.
+.It Fl g Ar gateway
+Specify a loose source route gateway (8 maximum).
+.It Fl i Ar iface
+Specify a network interface to obtain the source IP address for outgoing probe
+packets.
+This is normally only useful on a multi-homed host.
+(See the
+.Fl s
+flag for another way to do this).
+.It Fl I
+Use ICMP ECHO instead of UDP datagrams.
+(A synonym for "-P icmp").
+.It Fl m Ar max_ttl
+Set the max time-to-live (max number of hops) used in outgoing probe packets.
+The default is the value of the
+.Va net.inet.ip.ttl
+.Xr sysctl 8
+(the same default used for TCP connections).
+.It Fl M Ar first_ttl
+Set the initial time-to-live value used in outgoing probe packets.
+The default is 1, i.e., start with the first hop.
+.It Fl n
+Print hop addresses numerically rather than symbolically and numerically
+(saves a nameserver address-to-name lookup for each gateway found on the path).
+.It Fl p Ar port
+Protocol specific.
+For UDP, UDP-Lite, TCP and SCTP, sets the base
+.Ar port
+number used in probes (default is 33434).
+Traceroute hopes that nothing is listening on UDP ports (or UDP-Lite ports
+if used by
+.Nm
+and supported by the peer)
+.Em port + 1
+to
+.Em port + (max_ttl - first_ttl + 1) * nprobes
+at the destination host (so an ICMP PORT_UNREACHABLE message will be returned
+to terminate the route tracing).
+If something is listening on a port in the default range, this option can be
+used to pick an unused port range.
+.It Fl P Ar proto
+Send packets of specified IP protocol.
+The currently supported protocols
+are: UDP, UDP-Lite, TCP, SCTP, GRE and ICMP.
+Other protocols may also be specified (either by name or by number), though
+.Nm
+does not implement any special knowledge of their packet formats.
+This option is useful for determining which router along a path may be blocking
+packets based on IP protocol number.
+But see BUGS below.
+.It Fl q Ar nprobes
+Set the number of probes per hop (default is 3, unless
+.Fl D
+is specified,
+when it is 1).
+.It Fl r
+Bypass the normal routing tables and send directly to a host on an attached
+network.
+If the host is not on a directly-attached network, an error is returned.
+This option can be used to ping a local host through an interface that has no
+route through it (e.g., after the interface was dropped by
+.Xr routed 8 .
+.It Fl s Ar src_addr
+Use the following IP address (which usually is given as an IP number, not a
+hostname) as the source address in outgoing probe packets.
+On multi-homed hosts (those with more than one IP address), this option can be
+used to force the source address to be something other than the IP address of
+the interface the probe packet is sent on.
+If the IP address is not one of this machine's interface addresses, an error is
+returned and nothing is sent.
+(See the
+.Fl i
+flag for another way to do this).
+.It Fl S
+Print a summary of how many probes were not answered for each hop.
+.It Fl t Ar tos
+Set the
+.Em type-of-service
+in probe packets to the following value (default zero).
+The value must be a decimal integer in the range 0 to 255.
+This option can be used to see if different types-of-service result in
+different paths.
+The upper six bits are the Differentiated Services Codepoint (RFC4594).
+The lower two bits are the Explicit Congestion Notification field (RFC3168).
+.It Fl v
+Verbose output.
+Received ICMP packets other than
+.Dv TIME_EXCEEDED
+and
+.Dv UNREACHABLE Ns s
+are listed.
+.It Fl w Ar waittime
+Set the time (in seconds) to wait for a response to a probe (default 5 sec.).
+.It Fl x
+Toggle ip checksums.
+Normally, this prevents traceroute from calculating ip checksums.
+In some cases, the operating system can overwrite parts of the outgoing packet
+but not recalculate the checksum (so in some cases the default is to not
+calculate checksums and using
+.Fl x
+causes them to be calculated).
+Note that checksums are usually required for the last hop when using ICMP ECHO
+probes
+.Pq Fl I .
+So they are always calculated when using ICMP.
+.It Fl z Ar pausemsecs
+Set the time (in milliseconds) to pause between probes (default 0).
+Some systems such as Solaris and routers such as Ciscos rate limit ICMP
+messages.
+A good value to use with this is 500 (e.g., 1/2 second).
+.El
+.Pp
+This program attempts to trace the route an IP packet would follow to some
+internet host by launching UDP probe packets with a small TTL (time to live)
+then listening for an ICMP "time exceeded" reply from a gateway.
+We start our probes with a TTL of one and increase by one until we get an ICMP
+"port unreachable" (which means we got to "host") or hit a max (which defaults
+to the amount of hops specified by the
+.Va net.inet.ip.ttl
+.Xr sysctl 8
+and can be changed with the
+.Fl m
+flag).
+Three probes (change with
+.Fl q
+flag) are sent at each TTL setting and a line is printed showing the TTL,
+address of the gateway and round trip time of each probe.
+If the probe answers come from different gateways, the address of each
+responding system will be printed.
+If there is no response within a 5 sec. timeout interval (changed with the
+.Fl w
+flag), a "*" is printed for that probe.
+.Pp
+We don't want the destination host to process the UDP probe packets so the
+destination port is set to an unlikely value (if some clod on the destination
+is using that value, it can be changed with the
+.Fl p
+flag).
+.Pp
+A sample use and output might be:
+.Bd -literal -offset 4n
+% traceroute nis.nsf.net.
+traceroute to nis.nsf.net (35.1.1.48), 64 hops max, 40 byte packets
+ 1 helios.ee.lbl.gov (128.3.112.1) 19 ms 19 ms 0 ms
+ 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
+ 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
+ 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 39 ms
+ 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 39 ms 39 ms 39 ms
+ 6 128.32.197.4 (128.32.197.4) 40 ms 59 ms 59 ms
+ 7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 59 ms
+ 8 129.140.70.13 (129.140.70.13) 99 ms 99 ms 80 ms
+ 9 129.140.71.6 (129.140.71.6) 139 ms 239 ms 319 ms
+10 129.140.81.7 (129.140.81.7) 220 ms 199 ms 199 ms
+11 nic.merit.edu (35.1.1.48) 239 ms 239 ms 239 ms
+.Ed
+.Pp
+Note that lines 2 & 3 are the same.
+This is due to a buggy kernel on the 2nd hop system \- lilac-dmc.Berkeley.EDU \-
+that forwards packets with a zero TTL (a bug in the distributed version of
+4.3BSD).
+Note that you have to guess what path the packets are taking cross-country
+since the NSFNet (129.140) doesn't supply address-to-name translations for its
+NSSes.
+.Pp
+A more interesting example is:
+.Bd -literal -offset 4n
+% traceroute allspice.lcs.mit.edu.
+traceroute to allspice.lcs.mit.edu (18.26.0.115), 64 hops max, 40 byte packets
+ 1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
+ 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 19 ms 19 ms
+ 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 19 ms
+ 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 19 ms 39 ms 39 ms
+ 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 20 ms 39 ms 39 ms
+ 6 128.32.197.4 (128.32.197.4) 59 ms 119 ms 39 ms
+ 7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 39 ms
+ 8 129.140.70.13 (129.140.70.13) 80 ms 79 ms 99 ms
+ 9 129.140.71.6 (129.140.71.6) 139 ms 139 ms 159 ms
+10 129.140.81.7 (129.140.81.7) 199 ms 180 ms 300 ms
+11 129.140.72.17 (129.140.72.17) 300 ms 239 ms 239 ms
+12 * * *
+13 128.121.54.72 (128.121.54.72) 259 ms 499 ms 279 ms
+14 * * *
+15 * * *
+16 * * *
+17 * * *
+18 ALLSPICE.LCS.MIT.EDU (18.26.0.115) 339 ms 279 ms 279 ms
+.Ed
+.Pp
+Note that the gateways 12, 14, 15, 16 & 17 hops away either don't send ICMP
+"time exceeded" messages or send them with a TTL too small to reach us.
+14 \- 17 are running the MIT C Gateway code that doesn't send "time exceeded"s.
+God only knows what's going on with 12.
+.Pp
+The silent gateway 12 in the above may be the result of a bug in the 4.[23]BSD
+network code (and its derivatives): 4.x (x <= 3) sends an unreachable message
+using whatever TTL remains in the original datagram.
+Since, for gateways, the remaining TTL is zero, the ICMP "time exceeded" is
+guaranteed to not make it back to us.
+The behavior of this bug is slightly more interesting when it appears on the
+destination system:
+.Bd -literal -offset 4n
+ 1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
+ 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 39 ms
+ 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 39 ms 19 ms
+ 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 19 ms
+ 5 ccn-nerif35.Berkeley.EDU (128.32.168.35) 39 ms 39 ms 39 ms
+ 6 csgw.Berkeley.EDU (128.32.133.254) 39 ms 59 ms 39 ms
+ 7 * * *
+ 8 * * *
+ 9 * * *
+10 * * *
+11 * * *
+12 * * *
+13 rip.Berkeley.EDU (128.32.131.22) 59 ms ! 39 ms ! 39 ms !
+.Ed
+.Pp
+Notice that there are 12 "gateways" (13 is the final destination) and exactly
+the last half of them are "missing".
+What's really happening is that rip (a Sun-3 running Sun OS3.5) is using the
+TTL from our arriving datagram as the TTL in its ICMP reply.
+So, the reply will time out on the return path (with no notice sent to anyone
+since ICMP's aren't sent for ICMP's) until we probe with a TTL that's at least
+twice the path length.
+I.e., rip is really only 7 hops away.
+A reply that returns with a TTL of 1 is a clue this problem exists.
+.Nm
+prints a "!" after the time if the TTL is <= 1.
+Since vendors ship a lot of obsolete
+.Pf ( DEC Ns \'s
+Ultrix, Sun 3.x) or
+non-standard
+.Pq HP-UX
+software, expect to see this problem frequently and/or take care picking the
+target host of your probes.
+.Pp
+Other possible annotations after the time are:
+.Bl -hang -offset indent -width 12n
+.It Sy !H
+Host unreachable.
+.It Sy !N
+Network unreachable.
+.It Sy !P
+Protocol unreachable.
+.It Sy !S
+Source route failed.
+.It Sy !F\-<pmtu>
+Fragmentation needed.
+The RFC1191 Path MTU Discovery value is displayed.
+.It Sy !U
+Destination network unknown.
+.It Sy !W
+Destination host unknown.
+.It Sy !I
+Source host is isolated.
+.It Sy !A
+Communication with destination network administratively prohibited.
+.It Sy !Z
+Communication with destination host administratively prohibited.
+.It Sy !Q
+For this ToS the destination network is unreachable.
+.It Sy !T
+For this ToS the destination host is unreachable.
+.It Sy !X
+Communication administratively prohibited.
+.It Sy !V
+Host precedence violation.
+.It Sy !C
+Precedence cutoff in effect.
+.It Sy !<num>
+ICMP unreachable code <num>.
+.El
+.Pp
+These are defined by RFC1812 (which supersedes RFC1716).
+If almost all the probes result in some kind of unreachable,
+.Nm
+will give up and exit.
+.Pp
+This program is intended for use in network testing, measurement and
+management.
+It should be used primarily for manual fault isolation.
+Because of the load it could impose on the network, it is unwise to use
+.Nm
+during normal operations or from automated scripts.
+.Sh SEE ALSO
+.Xr netstat 1 ,
+.Xr ping 8 ,
+.Xr traceroute6 8
+.Sh AUTHORS
+Implemented by
+.An Van Jacobson
+from a suggestion by Steve Deering.
+Debugged by a cast of thousands with particularly cogent suggestions or fixes
+from C. Philip Wood, Tim Seaver and Ken Adelman.
+.Sh BUGS
+When using protocols other than UDP, functionality is reduced.
+In particular, the last packet will often appear to be lost, because even
+though it reaches the destination host, there's no way to know that because no
+ICMP message is sent back.
+In the TCP case,
+.Nm
+should listen for a RST from the destination host (or an intermediate router
+that's filtering packets), but this is not implemented yet.
+.Pp
+The AS number capability reports information that may sometimes be inaccurate
+due to discrepancies between the contents of the routing database server and
+the current state of the Internet.
diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c
new file mode 100644
index 000000000000..ec7a479afb7b
--- /dev/null
+++ b/usr.sbin/traceroute/traceroute.c
@@ -0,0 +1,2078 @@
+/*
+ * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ * traceroute host - trace the route ip packets follow going to "host".
+ *
+ * Attempt to trace the route an ip packet would follow to some
+ * internet host. We find out intermediate hops by launching probe
+ * packets with a small ttl (time to live) then listening for an
+ * icmp "time exceeded" reply from a gateway. We start our probes
+ * with a ttl of one and increase by one until we get an icmp "port
+ * unreachable" (which means we got to "host") or hit a max (which
+ * defaults to net.inet.ip.ttl hops & can be changed with the -m flag).
+ * Three probes (change with -q flag) are sent at each ttl setting and
+ * a line is printed showing the ttl, address of the gateway and
+ * round trip time of each probe. If the probe answers come from
+ * different gateways, the address of each responding system will
+ * be printed. If there is no response within a 5 sec. timeout
+ * interval (changed with the -w flag), a "*" is printed for that
+ * probe.
+ *
+ * Probe packets are UDP format. We don't want the destination
+ * host to process them so the destination port is set to an
+ * unlikely value (if some clod on the destination is using that
+ * value, it can be changed with the -p flag).
+ *
+ * A sample use might be:
+ *
+ * [yak 71]% traceroute nis.nsf.net.
+ * traceroute to nis.nsf.net (35.1.1.48), 64 hops max, 40 byte packets
+ * 1 helios.ee.lbl.gov (128.3.112.1) 19 ms 19 ms 0 ms
+ * 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
+ * 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
+ * 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 39 ms
+ * 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 39 ms 39 ms 39 ms
+ * 6 128.32.197.4 (128.32.197.4) 40 ms 59 ms 59 ms
+ * 7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 59 ms
+ * 8 129.140.70.13 (129.140.70.13) 99 ms 99 ms 80 ms
+ * 9 129.140.71.6 (129.140.71.6) 139 ms 239 ms 319 ms
+ * 10 129.140.81.7 (129.140.81.7) 220 ms 199 ms 199 ms
+ * 11 nic.merit.edu (35.1.1.48) 239 ms 239 ms 239 ms
+ *
+ * Note that lines 2 & 3 are the same. This is due to a buggy
+ * kernel on the 2nd hop system -- lbl-csam.arpa -- that forwards
+ * packets with a zero ttl.
+ *
+ * A more interesting example is:
+ *
+ * [yak 72]% traceroute allspice.lcs.mit.edu.
+ * traceroute to allspice.lcs.mit.edu (18.26.0.115), 64 hops max, 40 byte packets
+ * 1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
+ * 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 19 ms 19 ms
+ * 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 19 ms
+ * 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 19 ms 39 ms 39 ms
+ * 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 20 ms 39 ms 39 ms
+ * 6 128.32.197.4 (128.32.197.4) 59 ms 119 ms 39 ms
+ * 7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 39 ms
+ * 8 129.140.70.13 (129.140.70.13) 80 ms 79 ms 99 ms
+ * 9 129.140.71.6 (129.140.71.6) 139 ms 139 ms 159 ms
+ * 10 129.140.81.7 (129.140.81.7) 199 ms 180 ms 300 ms
+ * 11 129.140.72.17 (129.140.72.17) 300 ms 239 ms 239 ms
+ * 12 * * *
+ * 13 128.121.54.72 (128.121.54.72) 259 ms 499 ms 279 ms
+ * 14 * * *
+ * 15 * * *
+ * 16 * * *
+ * 17 * * *
+ * 18 ALLSPICE.LCS.MIT.EDU (18.26.0.115) 339 ms 279 ms 279 ms
+ *
+ * (I start to see why I'm having so much trouble with mail to
+ * MIT.) Note that the gateways 12, 14, 15, 16 & 17 hops away
+ * either don't send ICMP "time exceeded" messages or send them
+ * with a ttl too small to reach us. 14 - 17 are running the
+ * MIT C Gateway code that doesn't send "time exceeded"s. God
+ * only knows what's going on with 12.
+ *
+ * The silent gateway 12 in the above may be the result of a bug in
+ * the 4.[23]BSD network code (and its derivatives): 4.x (x <= 3)
+ * sends an unreachable message using whatever ttl remains in the
+ * original datagram. Since, for gateways, the remaining ttl is
+ * zero, the icmp "time exceeded" is guaranteed to not make it back
+ * to us. The behavior of this bug is slightly more interesting
+ * when it appears on the destination system:
+ *
+ * 1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
+ * 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 39 ms
+ * 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 39 ms 19 ms
+ * 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 19 ms
+ * 5 ccn-nerif35.Berkeley.EDU (128.32.168.35) 39 ms 39 ms 39 ms
+ * 6 csgw.Berkeley.EDU (128.32.133.254) 39 ms 59 ms 39 ms
+ * 7 * * *
+ * 8 * * *
+ * 9 * * *
+ * 10 * * *
+ * 11 * * *
+ * 12 * * *
+ * 13 rip.Berkeley.EDU (128.32.131.22) 59 ms ! 39 ms ! 39 ms !
+ *
+ * Notice that there are 12 "gateways" (13 is the final
+ * destination) and exactly the last half of them are "missing".
+ * What's really happening is that rip (a Sun-3 running Sun OS3.5)
+ * is using the ttl from our arriving datagram as the ttl in its
+ * icmp reply. So, the reply will time out on the return path
+ * (with no notice sent to anyone since icmp's aren't sent for
+ * icmp's) until we probe with a ttl that's at least twice the path
+ * length. I.e., rip is really only 7 hops away. A reply that
+ * returns with a ttl of 1 is a clue this problem exists.
+ * Traceroute prints a "!" after the time if the ttl is <= 1.
+ * Since vendors ship a lot of obsolete (DEC's Ultrix, Sun 3.x) or
+ * non-standard (HPUX) software, expect to see this problem
+ * frequently and/or take care picking the target host of your
+ * probes.
+ *
+ * Other possible annotations after the time are !H, !N, !P (got a host,
+ * network or protocol unreachable, respectively), !S or !F (source
+ * route failed or fragmentation needed -- neither of these should
+ * ever occur and the associated gateway is busted if you see one). If
+ * almost all the probes result in some kind of unreachable, traceroute
+ * will give up and exit.
+ *
+ * Notes
+ * -----
+ * This program must be run by root or be setuid. (I suggest that
+ * you *don't* make it setuid -- casual use could result in a lot
+ * of unnecessary traffic on our poor, congested nets.)
+ *
+ * This program requires a kernel mod that does not appear in any
+ * system available from Berkeley: A raw ip socket using proto
+ * IPPROTO_RAW must interpret the data sent as an ip datagram (as
+ * opposed to data to be wrapped in an ip datagram). See the README
+ * file that came with the source to this program for a description
+ * of the mods I made to /sys/netinet/raw_ip.c. Your mileage may
+ * vary. But, again, ANY 4.x (x < 4) BSD KERNEL WILL HAVE TO BE
+ * MODIFIED TO RUN THIS PROGRAM.
+ *
+ * The udp port usage may appear bizarre (well, ok, it is bizarre).
+ * The problem is that an icmp message only contains 8 bytes of
+ * data from the original datagram. 8 bytes is the size of a udp
+ * header so, if we want to associate replies with the original
+ * datagram, the necessary information must be encoded into the
+ * udp header (the ip id could be used but there's no way to
+ * interlock with the kernel's assignment of ip id's and, anyway,
+ * it would have taken a lot more kernel hacking to allow this
+ * code to set the ip id). So, to allow two or more users to
+ * use traceroute simultaneously, we use this task's pid as the
+ * source port (the high bit is set to move the port number out
+ * of the "likely" range). To keep track of which probe is being
+ * replied to (so times and/or hop counts don't get confused by a
+ * reply that was delayed in transit), we increment the destination
+ * port number before each probe.
+ *
+ * Don't use this as a coding example. I was trying to find a
+ * routing problem and this code sort-of popped out after 48 hours
+ * without sleep. I was amazed it ever compiled, much less ran.
+ *
+ * I stole the idea for this program from Steve Deering. Since
+ * the first release, I've learned that had I attended the right
+ * IETF working group meetings, I also could have stolen it from Guy
+ * Almes or Matt Mathis. I don't know (or care) who came up with
+ * the idea first. I envy the originators' perspicacity and I'm
+ * glad they didn't keep the idea a secret.
+ *
+ * Tim Seaver, Ken Adelman and C. Philip Wood provided bug fixes and/or
+ * enhancements to the original distribution.
+ *
+ * I've hacked up a round-trip-route version of this that works by
+ * sending a loose-source-routed udp datagram through the destination
+ * back to yourself. Unfortunately, SO many gateways botch source
+ * routing, the thing is almost worthless. Maybe one day...
+ *
+ * -- Van Jacobson (van@ee.lbl.gov)
+ * Tue Dec 20 03:50:13 PST 1988
+ */
+
+#include <sys/param.h>
+#include <sys/capsicum.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+#include <sys/time.h>
+
+#include <netinet/in_systm.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/sctp.h>
+#include <netinet/sctp_header.h>
+#include <netinet/udp.h>
+#include <netinet/tcp.h>
+#include <netinet/tcpip.h>
+
+#include <arpa/inet.h>
+
+#ifdef WITH_CASPER
+#include <libcasper.h>
+#include <casper/cap_dns.h>
+#endif
+
+#ifdef IPSEC
+#include <net/route.h>
+#include <netipsec/ipsec.h> /* XXX */
+#endif /* IPSEC */
+
+#include <ctype.h>
+#include <capsicum_helpers.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <malloc.h>
+#include <memory.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* rfc1716 */
+#ifndef ICMP_UNREACH_FILTER_PROHIB
+#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohibited filter */
+#endif
+#ifndef ICMP_UNREACH_HOST_PRECEDENCE
+#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host precedence violation */
+#endif
+#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
+#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */
+#endif
+
+#include "findsaddr.h"
+#include "ifaddrlist.h"
+#include "as.h"
+#include "traceroute.h"
+
+/* Maximum number of gateways (include room for one noop) */
+#define NGATEWAYS ((int)((MAX_IPOPTLEN - IPOPT_MINOFF - 1) / sizeof(u_int32_t)))
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 64
+#endif
+
+#define Fprintf (void)fprintf
+#define Printf (void)printf
+
+/* What a GRE packet header looks like */
+struct grehdr {
+ u_int16_t flags;
+ u_int16_t proto;
+ u_int16_t length; /* PPTP version of these fields */
+ u_int16_t callId;
+};
+#ifndef IPPROTO_GRE
+#define IPPROTO_GRE 47
+#endif
+
+/* For GRE, we prepare what looks like a PPTP packet */
+#define GRE_PPTP_PROTO 0x880b
+
+/* Host name and address list */
+struct hostinfo {
+ char *name;
+ int n;
+ u_int32_t *addrs;
+};
+
+/* Data section of the probe packet */
+struct outdata {
+ u_char seq; /* sequence number of this packet */
+ u_char ttl; /* ttl packet left with */
+ struct timeval tv; /* time packet left */
+};
+
+u_char packet[512]; /* last inbound (icmp) packet */
+
+struct ip *outip; /* last output ip packet */
+u_char *outp; /* last output inner protocol packet */
+
+struct ip *hip = NULL; /* Quoted IP header */
+int hiplen = 0;
+
+/* loose source route gateway list (including room for final destination) */
+u_int32_t gwlist[NGATEWAYS + 1];
+
+int s; /* receive (icmp) socket file descriptor */
+int sndsock; /* send (udp) socket file descriptor */
+
+struct sockaddr whereto; /* Who to try to reach */
+struct sockaddr wherefrom; /* Who we are */
+int packlen; /* total length of packet */
+int protlen; /* length of protocol part of packet */
+int minpacket; /* min ip packet size */
+int maxpacket = 32 * 1024; /* max ip packet size */
+int pmtu; /* Path MTU Discovery (RFC1191) */
+u_int pausemsecs;
+
+char *prog;
+char *source;
+char *hostname;
+char *device;
+static const char devnull[] = "/dev/null";
+
+int nprobes = -1;
+int max_ttl;
+int first_ttl = 1;
+u_short ident;
+u_short port; /* protocol specific base "port" */
+
+int options; /* socket options */
+int verbose;
+int waittime = 5; /* time to wait for response (in seconds) */
+int nflag; /* print addresses numerically */
+int as_path; /* print as numbers for each hop */
+char *as_server = NULL;
+void *asn;
+#ifdef CANT_HACK_IPCKSUM
+int doipcksum = 0; /* don't calculate ip checksums by default */
+#else
+int doipcksum = 1; /* calculate ip checksums by default */
+#endif
+int optlen; /* length of ip options */
+int fixedPort = 0; /* Use fixed destination port for TCP and UDP */
+int printdiff = 0; /* Print the difference between sent and quoted */
+int ecnflag = 0; /* ECN bleaching detection flag */
+
+extern int optind;
+extern int opterr;
+extern char *optarg;
+
+#ifdef WITH_CASPER
+static cap_channel_t *capdns;
+#endif
+
+/* Forwards */
+double deltaT(struct timeval *, struct timeval *);
+void freehostinfo(struct hostinfo *);
+void getaddr(u_int32_t *, char *);
+struct hostinfo *gethostinfo(char *);
+u_short in_cksum(u_short *, int);
+u_int32_t sctp_crc32c(const void *, u_int32_t);
+char *inetname(struct in_addr);
+int main(int, char **);
+u_short p_cksum(struct ip *, u_short *, int, int);
+int packet_ok(u_char *, int, struct sockaddr_in *, int);
+char *pr_type(u_char);
+void print(u_char *, int, struct sockaddr_in *);
+#ifdef IPSEC
+int setpolicy(int so, char *policy);
+#endif
+void send_probe(int, int);
+struct outproto *setproto(char *);
+int str2val(const char *, const char *, int, int);
+void tvsub(struct timeval *, struct timeval *);
+void usage(void);
+int wait_for_reply(int, struct sockaddr_in *, const struct timeval *);
+void pkt_compare(const u_char *, int, const u_char *, int);
+
+void udp_prep(struct outdata *);
+int udp_check(const u_char *, int);
+void udplite_prep(struct outdata *);
+int udplite_check(const u_char *, int);
+void tcp_prep(struct outdata *);
+int tcp_check(const u_char *, int);
+void sctp_prep(struct outdata *);
+int sctp_check(const u_char *, int);
+void gre_prep(struct outdata *);
+int gre_check(const u_char *, int);
+void gen_prep(struct outdata *);
+int gen_check(const u_char *, int);
+void icmp_prep(struct outdata *);
+int icmp_check(const u_char *, int);
+
+/* Descriptor structure for each outgoing protocol we support */
+struct outproto {
+ char *name; /* name of protocol */
+ const char *key; /* An ascii key for the bytes of the header */
+ u_char num; /* IP protocol number */
+ u_short hdrlen; /* max size of protocol header */
+ u_short port; /* default base protocol-specific "port" */
+ void (*prepare)(struct outdata *);
+ /* finish preparing an outgoing packet */
+ int (*check)(const u_char *, int);
+ /* check an incoming packet */
+};
+
+/* List of supported protocols. The first one is the default. The last
+ one is the handler for generic protocols not explicitly listed. */
+struct outproto protos[] = {
+ {
+ "udp",
+ "spt dpt len sum",
+ IPPROTO_UDP,
+ sizeof(struct udphdr),
+ 32768 + 666,
+ udp_prep,
+ udp_check
+ },
+ {
+ "udplite",
+ "spt dpt cov sum",
+ IPPROTO_UDPLITE,
+ sizeof(struct udphdr),
+ 32768 + 666,
+ udplite_prep,
+ udplite_check
+ },
+ {
+ "tcp",
+ "spt dpt seq ack xxflwin sum urp",
+ IPPROTO_TCP,
+ sizeof(struct tcphdr),
+ 32768 + 666,
+ tcp_prep,
+ tcp_check
+ },
+ {
+ "sctp",
+ "spt dpt vtag crc tyfllen tyfllen ",
+ IPPROTO_SCTP,
+ sizeof(struct sctphdr),
+ 32768 + 666,
+ sctp_prep,
+ sctp_check
+ },
+ {
+ "gre",
+ "flg pro len clid",
+ IPPROTO_GRE,
+ sizeof(struct grehdr),
+ GRE_PPTP_PROTO,
+ gre_prep,
+ gre_check
+ },
+ {
+ "icmp",
+ "typ cod sum ",
+ IPPROTO_ICMP,
+ sizeof(struct icmp),
+ 0,
+ icmp_prep,
+ icmp_check
+ },
+ {
+ NULL,
+ "",
+ 0,
+ 2 * sizeof(u_short),
+ 0,
+ gen_prep,
+ gen_check
+ },
+};
+struct outproto *proto = &protos[0];
+
+const char *ip_hdr_key = "vhtslen id off tlprsum srcip dstip opts";
+
+int
+main(int argc, char **argv)
+{
+ register int op, code, n;
+ register char *cp;
+ register const char *err;
+ register u_int32_t *ap;
+ register struct sockaddr_in *from = (struct sockaddr_in *)&wherefrom;
+ register struct sockaddr_in *to = (struct sockaddr_in *)&whereto;
+ register struct hostinfo *hi;
+ int on = 1;
+ register struct protoent *pe;
+ register int ttl, probe, i;
+ register int seq = 0;
+ int tos = 0, settos = 0;
+ register int lsrr = 0;
+ register u_short off = 0;
+ struct ifaddrlist *al;
+ char errbuf[132];
+ int requestPort = -1;
+ int sump = 0;
+ int sockerrno;
+#ifdef WITH_CASPER
+ const char *types[] = { "NAME2ADDR", "ADDR2NAME" };
+ int families[1];
+ cap_channel_t *casper;
+#endif
+ cap_rights_t rights;
+ bool cansandbox;
+
+ /* Insure the socket fds won't be 0, 1 or 2 */
+ if (open(devnull, O_RDONLY) < 0 ||
+ open(devnull, O_RDONLY) < 0 ||
+ open(devnull, O_RDONLY) < 0) {
+ Fprintf(stderr, "%s: open \"%s\": %s\n",
+ prog, devnull, strerror(errno));
+ exit(1);
+ }
+ /*
+ * Do the setuid-required stuff first, then lose privileges ASAP.
+ * Do error checking for these two calls where they appeared in
+ * the original code.
+ */
+ cp = "icmp";
+ pe = getprotobyname(cp);
+ if (pe) {
+ if ((s = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0)
+ sockerrno = errno;
+ else if ((sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
+ sockerrno = errno;
+ }
+
+ if (setuid(getuid()) != 0) {
+ perror("setuid()");
+ exit(1);
+ }
+
+#ifdef WITH_CASPER
+ casper = cap_init();
+ if (casper == NULL)
+ errx(1, "unable to create casper process");
+ capdns = cap_service_open(casper, "system.dns");
+ if (capdns == NULL)
+ errx(1, "unable to open system.dns service");
+ if (cap_dns_type_limit(capdns, types, 2) < 0)
+ errx(1, "unable to limit access to system.dns service");
+ families[0] = AF_INET;
+ if (cap_dns_family_limit(capdns, families, 1) < 0)
+ errx(1, "unable to limit access to system.dns service");
+#endif /* WITH_CASPER */
+
+#ifdef IPCTL_DEFTTL
+ {
+ int mib[4] = { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_DEFTTL };
+ size_t sz = sizeof(max_ttl);
+
+ if (sysctl(mib, 4, &max_ttl, &sz, NULL, 0) == -1) {
+ perror("sysctl(net.inet.ip.ttl)");
+ exit(1);
+ }
+ }
+#else /* !IPCTL_DEFTTL */
+ max_ttl = 30;
+#endif
+
+#ifdef WITH_CASPER
+ cap_close(casper);
+#endif
+
+ if (argv[0] == NULL)
+ prog = "traceroute";
+ else if ((cp = strrchr(argv[0], '/')) != NULL)
+ prog = cp + 1;
+ else
+ prog = argv[0];
+
+ opterr = 0;
+ while ((op = getopt(argc, argv, "aA:eEdDFInrSvxf:g:i:M:m:P:p:q:s:t:w:z:")) != EOF)
+ switch (op) {
+ case 'a':
+ as_path = 1;
+ break;
+
+ case 'A':
+ as_path = 1;
+ as_server = optarg;
+ break;
+
+ case 'd':
+ options |= SO_DEBUG;
+ break;
+
+ case 'D':
+ printdiff = 1;
+ break;
+
+ case 'e':
+ fixedPort = 1;
+ break;
+
+ case 'E':
+ ecnflag = 1;
+ break;
+
+ case 'f':
+ case 'M': /* FreeBSD compat. */
+ first_ttl = str2val(optarg, "first ttl", 1, 255);
+ break;
+
+ case 'F':
+ off = IP_DF;
+ break;
+
+ case 'g':
+ if (lsrr >= NGATEWAYS) {
+ Fprintf(stderr,
+ "%s: No more than %d gateways\n",
+ prog, NGATEWAYS);
+ exit(1);
+ }
+ getaddr(gwlist + lsrr, optarg);
+ ++lsrr;
+ break;
+
+ case 'i':
+ device = optarg;
+ break;
+
+ case 'I':
+ proto = setproto("icmp");
+ break;
+
+ case 'm':
+ max_ttl = str2val(optarg, "max ttl", 1, 255);
+ break;
+
+ case 'n':
+ ++nflag;
+ break;
+
+ case 'P':
+ proto = setproto(optarg);
+ break;
+
+ case 'p':
+ requestPort = (u_short)str2val(optarg, "port",
+ 1, (1 << 16) - 1);
+ break;
+
+ case 'q':
+ nprobes = str2val(optarg, "nprobes", 1, -1);
+ break;
+
+ case 'r':
+ options |= SO_DONTROUTE;
+ break;
+
+ case 's':
+ /*
+ * set the ip source address of the outbound
+ * probe (e.g., on a multi-homed host).
+ */
+ source = optarg;
+ break;
+
+ case 'S':
+ sump = 1;
+ break;
+
+ case 't':
+ tos = str2val(optarg, "tos", 0, 255);
+ ++settos;
+ break;
+
+ case 'v':
+ ++verbose;
+ break;
+
+ case 'x':
+ doipcksum = (doipcksum == 0);
+ break;
+
+ case 'w':
+ waittime = str2val(optarg, "wait time",
+ 1, 24 * 60 * 60);
+ break;
+
+ case 'z':
+ pausemsecs = str2val(optarg, "pause msecs",
+ 0, 60 * 60 * 1000);
+ break;
+
+ default:
+ usage();
+ }
+
+ /* Set requested port, if any, else default for this protocol */
+ port = (requestPort != -1) ? requestPort : proto->port;
+
+ if (nprobes == -1)
+ nprobes = printdiff ? 1 : 3;
+
+ if (first_ttl > max_ttl) {
+ Fprintf(stderr,
+ "%s: first ttl (%d) may not be greater than max ttl (%d)\n",
+ prog, first_ttl, max_ttl);
+ exit(1);
+ }
+
+ if (!doipcksum)
+ Fprintf(stderr, "%s: Warning: ip checksums disabled\n", prog);
+
+ if (lsrr > 0)
+ optlen = (lsrr + 1) * sizeof(gwlist[0]);
+ minpacket = sizeof(*outip) + proto->hdrlen + optlen;
+ if (minpacket > 40)
+ packlen = minpacket;
+ else
+ packlen = 40;
+
+ /* Process destination and optional packet size */
+ switch (argc - optind) {
+
+ case 2:
+ packlen = str2val(argv[optind + 1],
+ "packet length", minpacket, maxpacket);
+ /* Fall through */
+
+ case 1:
+ hostname = argv[optind];
+ hi = gethostinfo(hostname);
+ setsin(to, hi->addrs[0]);
+ if (hi->n > 1)
+ Fprintf(stderr,
+ "%s: Warning: %s has multiple addresses; using %s\n",
+ prog, hostname, inet_ntoa(to->sin_addr));
+ hostname = hi->name;
+ hi->name = NULL;
+ freehostinfo(hi);
+ break;
+
+ default:
+ usage();
+ }
+
+ setlinebuf(stdout);
+
+ protlen = packlen - sizeof(*outip) - optlen;
+ if ((proto->num == IPPROTO_SCTP) && (packlen & 3)) {
+ Fprintf(stderr, "%s: packet length must be a multiple of 4\n",
+ prog);
+ exit(1);
+ }
+
+ outip = (struct ip *)malloc((unsigned)packlen);
+ if (outip == NULL) {
+ Fprintf(stderr, "%s: malloc: %s\n", prog, strerror(errno));
+ exit(1);
+ }
+ memset((char *)outip, 0, packlen);
+
+ outip->ip_v = IPVERSION;
+ if (settos)
+ outip->ip_tos = tos;
+ if (ecnflag) {
+ outip->ip_tos &= ~IPTOS_ECN_MASK;
+ outip->ip_tos |= IPTOS_ECN_ECT1;
+ }
+ outip->ip_len = htons(packlen);
+ outip->ip_off = htons(off);
+ outip->ip_p = proto->num;
+ outp = (u_char *)(outip + 1);
+ if (lsrr > 0) {
+ register u_char *optlist;
+
+ optlist = outp;
+ outp += optlen;
+
+ /* final hop */
+ gwlist[lsrr] = to->sin_addr.s_addr;
+
+ outip->ip_dst.s_addr = gwlist[0];
+
+ /* force 4 byte alignment */
+ optlist[0] = IPOPT_NOP;
+ /* loose source route option */
+ optlist[1] = IPOPT_LSRR;
+ i = lsrr * sizeof(gwlist[0]);
+ optlist[2] = i + 3;
+ /* Pointer to LSRR addresses */
+ optlist[3] = IPOPT_MINOFF;
+ memcpy(optlist + 4, gwlist + 1, i);
+ } else
+ outip->ip_dst = to->sin_addr;
+
+ outip->ip_hl = (outp - (u_char *)outip) >> 2;
+ ident = (getpid() & 0xffff) | 0x8000;
+
+ if (pe == NULL) {
+ Fprintf(stderr, "%s: unknown protocol %s\n", prog, cp);
+ exit(1);
+ }
+ if (s < 0) {
+ errno = sockerrno;
+ Fprintf(stderr, "%s: icmp socket: %s\n", prog, strerror(errno));
+ exit(1);
+ }
+ if (options & SO_DEBUG)
+ (void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&on,
+ sizeof(on));
+ if (options & SO_DONTROUTE)
+ (void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&on,
+ sizeof(on));
+
+#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
+ if (setpolicy(s, "in bypass") < 0)
+ errx(1, "%s", ipsec_strerror());
+
+ if (setpolicy(s, "out bypass") < 0)
+ errx(1, "%s", ipsec_strerror());
+#endif /* defined(IPSEC) && defined(IPSEC_POLICY_IPSEC) */
+
+ if (sndsock < 0) {
+ errno = sockerrno;
+ Fprintf(stderr, "%s: raw socket: %s\n", prog, strerror(errno));
+ exit(1);
+ }
+
+#ifdef SO_SNDBUF
+ if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&packlen,
+ sizeof(packlen)) < 0) {
+ Fprintf(stderr, "%s: SO_SNDBUF: %s\n", prog, strerror(errno));
+ exit(1);
+ }
+#endif
+#ifdef IP_HDRINCL
+ if (setsockopt(sndsock, IPPROTO_IP, IP_HDRINCL, (char *)&on,
+ sizeof(on)) < 0) {
+ Fprintf(stderr, "%s: IP_HDRINCL: %s\n", prog, strerror(errno));
+ exit(1);
+ }
+#else
+#ifdef IP_TOS
+ if (settos && setsockopt(sndsock, IPPROTO_IP, IP_TOS,
+ (char *)&tos, sizeof(tos)) < 0) {
+ Fprintf(stderr, "%s: setsockopt tos %d: %s\n",
+ prog, tos, strerror(errno));
+ exit(1);
+ }
+#endif
+#endif
+ if (options & SO_DEBUG)
+ (void)setsockopt(sndsock, SOL_SOCKET, SO_DEBUG, (char *)&on,
+ sizeof(on));
+ if (options & SO_DONTROUTE)
+ (void)setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE, (char *)&on,
+ sizeof(on));
+
+ /* Get the interface address list */
+ n = ifaddrlist(&al, errbuf);
+ if (n < 0) {
+ Fprintf(stderr, "%s: ifaddrlist: %s\n", prog, errbuf);
+ exit(1);
+ }
+ if (n == 0) {
+ Fprintf(stderr,
+ "%s: Can't find any network interfaces\n", prog);
+ exit(1);
+ }
+
+ /* Look for a specific device */
+ if (device != NULL) {
+ for (i = n; i > 0; --i, ++al)
+ if (strcmp(device, al->device) == 0)
+ break;
+ if (i <= 0) {
+ Fprintf(stderr, "%s: Can't find interface %.32s\n",
+ prog, device);
+ exit(1);
+ }
+ }
+
+ /* Determine our source address */
+ if (source == NULL) {
+ /*
+ * If a device was specified, use the interface address.
+ * Otherwise, try to determine our source address.
+ */
+ if (device != NULL)
+ setsin(from, al->addr);
+ else if ((err = findsaddr(to, from)) != NULL) {
+ Fprintf(stderr, "%s: findsaddr: %s\n",
+ prog, err);
+ exit(1);
+ }
+ } else {
+ hi = gethostinfo(source);
+ source = hi->name;
+ hi->name = NULL;
+ /*
+ * If the device was specified make sure it
+ * corresponds to the source address specified.
+ * Otherwise, use the first address (and warn if
+ * there are more than one).
+ */
+ if (device != NULL) {
+ for (i = hi->n, ap = hi->addrs; i > 0; --i, ++ap)
+ if (*ap == al->addr)
+ break;
+ if (i <= 0) {
+ Fprintf(stderr,
+ "%s: %s is not on interface %.32s\n",
+ prog, source, device);
+ exit(1);
+ }
+ setsin(from, *ap);
+ } else {
+ setsin(from, hi->addrs[0]);
+ if (hi->n > 1)
+ Fprintf(stderr,
+ "%s: Warning: %s has multiple addresses; using %s\n",
+ prog, source, inet_ntoa(from->sin_addr));
+ }
+ freehostinfo(hi);
+ }
+
+ outip->ip_src = from->sin_addr;
+
+ /* Check the source address (-s), if any, is valid */
+ if (bind(sndsock, (struct sockaddr *)from, sizeof(*from)) < 0) {
+ Fprintf(stderr, "%s: bind: %s\n",
+ prog, strerror(errno));
+ exit(1);
+ }
+
+ if (as_path) {
+ asn = as_setup(as_server);
+ if (asn == NULL) {
+ Fprintf(stderr, "%s: as_setup failed, AS# lookups"
+ " disabled\n", prog);
+ (void)fflush(stderr);
+ as_path = 0;
+ }
+ }
+
+ if (connect(sndsock, (struct sockaddr *)&whereto,
+ sizeof(whereto)) != 0) {
+ Fprintf(stderr, "%s: connect: %s\n", prog, strerror(errno));
+ exit(1);
+ }
+
+#ifdef WITH_CASPER
+ cansandbox = true;
+#else
+ if (nflag)
+ cansandbox = true;
+ else
+ cansandbox = false;
+#endif
+
+ caph_cache_catpages();
+
+ /*
+ * Here we enter capability mode. Further down access to global
+ * namespaces (e.g filesystem) is restricted (see capsicum(4)).
+ * We must connect(2) our socket before this point.
+ */
+ if (cansandbox && cap_enter() < 0) {
+ if (errno != ENOSYS) {
+ Fprintf(stderr, "%s: cap_enter: %s\n", prog,
+ strerror(errno));
+ exit(1);
+ } else {
+ cansandbox = false;
+ }
+ }
+
+ cap_rights_init(&rights, CAP_SEND, CAP_SETSOCKOPT);
+ if (cansandbox && cap_rights_limit(sndsock, &rights) < 0) {
+ Fprintf(stderr, "%s: cap_rights_limit sndsock: %s\n", prog,
+ strerror(errno));
+ exit(1);
+ }
+
+ cap_rights_init(&rights, CAP_RECV, CAP_EVENT);
+ if (cansandbox && cap_rights_limit(s, &rights) < 0) {
+ Fprintf(stderr, "%s: cap_rights_limit s: %s\n", prog,
+ strerror(errno));
+ exit(1);
+ }
+
+#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
+ if (setpolicy(sndsock, "in bypass") < 0)
+ errx(1, "%s", ipsec_strerror());
+
+ if (setpolicy(sndsock, "out bypass") < 0)
+ errx(1, "%s", ipsec_strerror());
+#endif /* defined(IPSEC) && defined(IPSEC_POLICY_IPSEC) */
+
+ Fprintf(stderr, "%s to %s (%s)",
+ prog, hostname, inet_ntoa(to->sin_addr));
+ if (source)
+ Fprintf(stderr, " from %s", source);
+ Fprintf(stderr, ", %d hops max, %d byte packets\n", max_ttl, packlen);
+ (void)fflush(stderr);
+
+ for (ttl = first_ttl; ttl <= max_ttl; ++ttl) {
+ u_int32_t lastaddr = 0;
+ int gotlastaddr = 0;
+ int got_there = 0;
+ int unreachable = 0;
+ int sentfirst = 0;
+ int loss;
+
+ Printf("%2d ", ttl);
+ for (probe = 0, loss = 0; probe < nprobes; ++probe) {
+ register int cc;
+ struct timeval t1, t2;
+ register struct ip *ip;
+ struct outdata outdata;
+
+ if (sentfirst && pausemsecs > 0)
+ usleep(pausemsecs * 1000);
+ /* Prepare outgoing data */
+ outdata.seq = ++seq;
+ outdata.ttl = ttl;
+
+ /* Avoid alignment problems by copying bytewise: */
+ (void)gettimeofday(&t1, NULL);
+ memcpy(&outdata.tv, &t1, sizeof(outdata.tv));
+
+ /* Finalize and send packet */
+ (*proto->prepare)(&outdata);
+ send_probe(seq, ttl);
+ ++sentfirst;
+
+ /* Wait for a reply */
+ while ((cc = wait_for_reply(s, from, &t1)) != 0) {
+ double T;
+ int precis;
+
+ (void)gettimeofday(&t2, NULL);
+ i = packet_ok(packet, cc, from, seq);
+ /* Skip short packet */
+ if (i == 0)
+ continue;
+ if (!gotlastaddr ||
+ from->sin_addr.s_addr != lastaddr) {
+ if (gotlastaddr)
+ printf("\n ");
+ print(packet, cc, from);
+ lastaddr = from->sin_addr.s_addr;
+ ++gotlastaddr;
+ }
+ T = deltaT(&t1, &t2);
+#ifdef SANE_PRECISION
+ if (T >= 1000.0)
+ precis = 0;
+ else if (T >= 100.0)
+ precis = 1;
+ else if (T >= 10.0)
+ precis = 2;
+ else
+#endif
+ precis = 3;
+ Printf(" %.*f ms", precis, T);
+ if (ecnflag) {
+ u_char ecn = hip->ip_tos & IPTOS_ECN_MASK;
+ switch (ecn) {
+ case IPTOS_ECN_ECT1:
+ Printf(" (ecn=passed)");
+ break;
+ case IPTOS_ECN_NOTECT:
+ Printf(" (ecn=bleached)");
+ break;
+ case IPTOS_ECN_CE:
+ Printf(" (ecn=congested)");
+ break;
+ default:
+ Printf(" (ecn=mangled)");
+ break;
+ }
+ }
+ if (printdiff) {
+ Printf("\n");
+ Printf("%*.*s%s\n",
+ -(outip->ip_hl << 3),
+ outip->ip_hl << 3,
+ ip_hdr_key,
+ proto->key);
+ pkt_compare((void *)outip, packlen,
+ (void *)hip, hiplen);
+ }
+ if (i == -2) {
+#ifndef ARCHAIC
+ ip = (struct ip *)packet;
+ if (ip->ip_ttl <= 1)
+ Printf(" !");
+#endif
+ ++got_there;
+ break;
+ }
+ /* time exceeded in transit */
+ if (i == -1)
+ break;
+ code = i - 1;
+ switch (code) {
+
+ case ICMP_UNREACH_PORT:
+#ifndef ARCHAIC
+ ip = (struct ip *)packet;
+ if (ip->ip_ttl <= 1)
+ Printf(" !");
+#endif
+ ++got_there;
+ break;
+
+ case ICMP_UNREACH_NET:
+ ++unreachable;
+ Printf(" !N");
+ break;
+
+ case ICMP_UNREACH_HOST:
+ ++unreachable;
+ Printf(" !H");
+ break;
+
+ case ICMP_UNREACH_PROTOCOL:
+ ++got_there;
+ Printf(" !P");
+ break;
+
+ case ICMP_UNREACH_NEEDFRAG:
+ ++unreachable;
+ Printf(" !F-%d", pmtu);
+ break;
+
+ case ICMP_UNREACH_SRCFAIL:
+ ++unreachable;
+ Printf(" !S");
+ break;
+
+ case ICMP_UNREACH_NET_UNKNOWN:
+ ++unreachable;
+ Printf(" !U");
+ break;
+
+ case ICMP_UNREACH_HOST_UNKNOWN:
+ ++unreachable;
+ Printf(" !W");
+ break;
+
+ case ICMP_UNREACH_ISOLATED:
+ ++unreachable;
+ Printf(" !I");
+ break;
+
+ case ICMP_UNREACH_NET_PROHIB:
+ ++unreachable;
+ Printf(" !A");
+ break;
+
+ case ICMP_UNREACH_HOST_PROHIB:
+ ++unreachable;
+ Printf(" !Z");
+ break;
+
+ case ICMP_UNREACH_TOSNET:
+ ++unreachable;
+ Printf(" !Q");
+ break;
+
+ case ICMP_UNREACH_TOSHOST:
+ ++unreachable;
+ Printf(" !T");
+ break;
+
+ case ICMP_UNREACH_FILTER_PROHIB:
+ ++unreachable;
+ Printf(" !X");
+ break;
+
+ case ICMP_UNREACH_HOST_PRECEDENCE:
+ ++unreachable;
+ Printf(" !V");
+ break;
+
+ case ICMP_UNREACH_PRECEDENCE_CUTOFF:
+ ++unreachable;
+ Printf(" !C");
+ break;
+
+ default:
+ ++unreachable;
+ Printf(" !<%d>", code);
+ break;
+ }
+ break;
+ }
+ if (cc == 0) {
+ loss++;
+ Printf(" *");
+ }
+ (void)fflush(stdout);
+ }
+ if (sump) {
+ Printf(" (%d%% loss)", (loss * 100) / nprobes);
+ }
+ putchar('\n');
+ if (got_there ||
+ (unreachable > 0 && unreachable >= nprobes - 1))
+ break;
+ }
+ if (as_path)
+ as_shutdown(asn);
+ exit(0);
+}
+
+int
+wait_for_reply(register int sock, register struct sockaddr_in *fromp,
+ register const struct timeval *tp)
+{
+ fd_set *fdsp;
+ size_t nfds;
+ struct timeval now, wait;
+ register int cc = 0;
+ register int error;
+ int fromlen = sizeof(*fromp);
+
+ nfds = howmany(sock + 1, NFDBITS);
+ if ((fdsp = malloc(nfds * sizeof(fd_mask))) == NULL)
+ err(1, "malloc");
+ memset(fdsp, 0, nfds * sizeof(fd_mask));
+ FD_SET(sock, fdsp);
+
+ wait.tv_sec = tp->tv_sec + waittime;
+ wait.tv_usec = tp->tv_usec;
+ (void)gettimeofday(&now, NULL);
+ tvsub(&wait, &now);
+ if (wait.tv_sec < 0) {
+ wait.tv_sec = 0;
+ wait.tv_usec = 1;
+ }
+
+ error = select(sock + 1, fdsp, NULL, NULL, &wait);
+ if (error == -1 && errno == EINVAL) {
+ Fprintf(stderr, "%s: botched select() args\n", prog);
+ exit(1);
+ }
+ if (error > 0)
+ cc = recvfrom(sock, (char *)packet, sizeof(packet), 0,
+ (struct sockaddr *)fromp, &fromlen);
+
+ free(fdsp);
+ return (cc);
+}
+
+void
+send_probe(int seq, int ttl)
+{
+ register int cc;
+
+ outip->ip_ttl = ttl;
+ outip->ip_id = htons(ident + seq);
+
+ /* XXX undocumented debugging hack */
+ if (verbose > 1) {
+ register const u_short *sp;
+ register int nshorts, i;
+
+ sp = (u_short *)outip;
+ nshorts = (u_int)packlen / sizeof(u_short);
+ i = 0;
+ Printf("[ %d bytes", packlen);
+ while (--nshorts >= 0) {
+ if ((i++ % 8) == 0)
+ Printf("\n\t");
+ Printf(" %04x", ntohs(*sp++));
+ }
+ if (packlen & 1) {
+ if ((i % 8) == 0)
+ Printf("\n\t");
+ Printf(" %02x", *(u_char *)sp);
+ }
+ Printf("]\n");
+ }
+
+#if !defined(IP_HDRINCL) && defined(IP_TTL)
+ if (setsockopt(sndsock, IPPROTO_IP, IP_TTL,
+ (char *)&ttl, sizeof(ttl)) < 0) {
+ Fprintf(stderr, "%s: setsockopt ttl %d: %s\n",
+ prog, ttl, strerror(errno));
+ exit(1);
+ }
+#endif
+
+ cc = send(sndsock, (char *)outip, packlen, 0);
+ if (cc < 0 || cc != packlen) {
+ if (cc < 0)
+ Fprintf(stderr, "%s: sendto: %s\n",
+ prog, strerror(errno));
+ Printf("%s: wrote %s %d chars, ret=%d\n",
+ prog, hostname, packlen, cc);
+ (void)fflush(stdout);
+ }
+}
+
+#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
+int
+setpolicy(int so, char *policy)
+{
+ char *buf;
+
+ buf = ipsec_set_policy(policy, strlen(policy));
+ if (buf == NULL) {
+ warnx("%s", ipsec_strerror());
+ return (-1);
+ }
+ (void)setsockopt(so, IPPROTO_IP, IP_IPSEC_POLICY,
+ buf, ipsec_get_policylen(buf));
+
+ free(buf);
+
+ return (0);
+}
+#endif
+
+double
+deltaT(struct timeval *t1p, struct timeval *t2p)
+{
+ register double dt;
+
+ dt = (double)(t2p->tv_sec - t1p->tv_sec) * 1000.0 +
+ (double)(t2p->tv_usec - t1p->tv_usec) / 1000.0;
+ return (dt);
+}
+
+/*
+ * Convert an ICMP "type" field to a printable string.
+ */
+char *
+pr_type(register u_char t)
+{
+ static char *ttab[] = {
+ "Echo Reply", "ICMP 1", "ICMP 2", "Dest Unreachable",
+ "Source Quench", "Redirect", "ICMP 6", "ICMP 7",
+ "Echo", "ICMP 9", "ICMP 10", "Time Exceeded",
+ "Param Problem", "Timestamp", "Timestamp Reply", "Info Request",
+ "Info Reply"
+ };
+
+ if (t > 16)
+ return ("OUT-OF-RANGE");
+
+ return (ttab[t]);
+}
+
+int
+packet_ok(register u_char *buf, int cc, register struct sockaddr_in *from,
+ register int seq)
+{
+ register struct icmp *icp;
+ register u_char type, code;
+ register int hlen;
+#ifndef ARCHAIC
+ register struct ip *ip;
+
+ ip = (struct ip *) buf;
+ hlen = ip->ip_hl << 2;
+ if (cc < hlen + ICMP_MINLEN) {
+ if (verbose)
+ Printf("packet too short (%d bytes) from %s\n", cc,
+ inet_ntoa(from->sin_addr));
+ return (0);
+ }
+ cc -= hlen;
+ icp = (struct icmp *)(buf + hlen);
+#else
+ icp = (struct icmp *)buf;
+#endif
+ type = icp->icmp_type;
+ code = icp->icmp_code;
+ /* Path MTU Discovery (RFC1191) */
+ if (code != ICMP_UNREACH_NEEDFRAG)
+ pmtu = 0;
+ else {
+ pmtu = ntohs(icp->icmp_nextmtu);
+ }
+ if (type == ICMP_ECHOREPLY
+ && proto->num == IPPROTO_ICMP
+ && (*proto->check)((u_char *)icp, (u_char)seq))
+ return (-2);
+ if ((type == ICMP_TIMXCEED && code == ICMP_TIMXCEED_INTRANS) ||
+ type == ICMP_UNREACH) {
+ u_char *inner;
+
+ hip = &icp->icmp_ip;
+ hiplen = ((u_char *)icp + cc) - (u_char *)hip;
+ hlen = hip->ip_hl << 2;
+ inner = (u_char *)((u_char *)hip + hlen);
+ if (hlen + 16 <= cc
+ && hip->ip_p == proto->num
+ && (*proto->check)(inner, (u_char)seq))
+ return (type == ICMP_TIMXCEED ? -1 : code + 1);
+ }
+#ifndef ARCHAIC
+ if (verbose) {
+ register int i;
+ u_int32_t *lp = (u_int32_t *)&icp->icmp_ip;
+
+ Printf("\n%d bytes from %s to ", cc, inet_ntoa(from->sin_addr));
+ Printf("%s: icmp type %d (%s) code %d\n",
+ inet_ntoa(ip->ip_dst), type, pr_type(type), icp->icmp_code);
+ for (i = 4; i <= cc - ICMP_MINLEN; i += sizeof(*lp))
+ Printf("%2d: %8.8x\n", i, ntohl(*lp++));
+ }
+#endif
+ return (0);
+}
+
+void
+icmp_prep(struct outdata *outdata)
+{
+ struct icmp *const icmpheader = (struct icmp *) outp;
+
+ icmpheader->icmp_type = ICMP_ECHO;
+ icmpheader->icmp_id = htons(ident);
+ icmpheader->icmp_seq = htons(outdata->seq);
+ icmpheader->icmp_cksum = 0;
+ icmpheader->icmp_cksum = in_cksum((u_short *)icmpheader, protlen);
+ if (icmpheader->icmp_cksum == 0)
+ icmpheader->icmp_cksum = 0xffff;
+}
+
+int
+icmp_check(const u_char *data, int seq)
+{
+ struct icmp *const icmpheader = (struct icmp *) data;
+
+ return (icmpheader->icmp_id == htons(ident)
+ && icmpheader->icmp_seq == htons(seq));
+}
+
+void
+udp_prep(struct outdata *outdata)
+{
+ struct udphdr *const outudp = (struct udphdr *) outp;
+
+ outudp->uh_sport = htons(ident + (fixedPort ? outdata->seq : 0));
+ outudp->uh_dport = htons(port + (fixedPort ? 0 : outdata->seq));
+ outudp->uh_ulen = htons((u_short)protlen);
+ outudp->uh_sum = 0;
+ if (doipcksum) {
+ u_short sum = p_cksum(outip, (u_short *)outudp, protlen, protlen);
+ outudp->uh_sum = (sum) ? sum : 0xffff;
+ }
+
+ return;
+}
+
+int
+udp_check(const u_char *data, int seq)
+{
+ struct udphdr *const udp = (struct udphdr *) data;
+
+ return (ntohs(udp->uh_sport) == ident + (fixedPort ? seq : 0) &&
+ ntohs(udp->uh_dport) == port + (fixedPort ? 0 : seq));
+}
+
+void
+udplite_prep(struct outdata *outdata)
+{
+ struct udphdr *const outudp = (struct udphdr *) outp;
+
+ outudp->uh_sport = htons(ident + (fixedPort ? outdata->seq : 0));
+ outudp->uh_dport = htons(port + (fixedPort ? 0 : outdata->seq));
+ outudp->uh_ulen = htons(8);
+ outudp->uh_sum = 0;
+ if (doipcksum) {
+ u_short sum = p_cksum(outip, (u_short *)outudp, protlen, 8);
+ outudp->uh_sum = (sum) ? sum : 0xffff;
+ }
+
+ return;
+}
+
+int
+udplite_check(const u_char *data, int seq)
+{
+ struct udphdr *const udp = (struct udphdr *) data;
+
+ return (ntohs(udp->uh_sport) == ident + (fixedPort ? seq : 0) &&
+ ntohs(udp->uh_dport) == port + (fixedPort ? 0 : seq));
+}
+
+void
+tcp_prep(struct outdata *outdata)
+{
+ struct tcphdr *const tcp = (struct tcphdr *) outp;
+
+ tcp->th_sport = htons(ident);
+ tcp->th_dport = htons(port + (fixedPort ? 0 : outdata->seq));
+ tcp->th_seq = (tcp->th_sport << 16) | tcp->th_dport;
+ tcp->th_ack = 0;
+ tcp->th_off = 5;
+ tcp->th_flags = TH_SYN;
+ tcp->th_sum = 0;
+
+ if (doipcksum)
+ tcp->th_sum = p_cksum(outip, (u_short *)tcp, protlen, protlen);
+}
+
+int
+tcp_check(const u_char *data, int seq)
+{
+ struct tcphdr *const tcp = (struct tcphdr *) data;
+
+ return (ntohs(tcp->th_sport) == ident
+ && ntohs(tcp->th_dport) == port + (fixedPort ? 0 : seq)
+ && tcp->th_seq == (tcp_seq)((tcp->th_sport << 16) | tcp->th_dport));
+}
+
+void
+sctp_prep(struct outdata *outdata)
+{
+ struct sctphdr *const sctp = (struct sctphdr *) outp;
+ struct sctp_chunkhdr *chk;
+ struct sctp_init_chunk *init;
+ struct sctp_paramhdr *param;
+
+ sctp->src_port = htons(ident);
+ sctp->dest_port = htons(port + (fixedPort ? 0 : outdata->seq));
+ if (protlen >= (int)(sizeof(struct sctphdr) +
+ sizeof(struct sctp_init_chunk))) {
+ sctp->v_tag = 0;
+ } else {
+ sctp->v_tag = (sctp->src_port << 16) | sctp->dest_port;
+ }
+ sctp->checksum = htonl(0);
+ if (protlen >= (int)(sizeof(struct sctphdr) +
+ sizeof(struct sctp_init_chunk))) {
+ /*
+ * Send a packet containing an INIT chunk. This works
+ * better in case of firewalls on the path, but
+ * results in a probe packet containing at least
+ * 32 bytes of payload. For shorter payloads, use
+ * SHUTDOWN-ACK chunks.
+ */
+ init = (struct sctp_init_chunk *)(sctp + 1);
+ init->ch.chunk_type = SCTP_INITIATION;
+ init->ch.chunk_flags = 0;
+ init->ch.chunk_length = htons((u_int16_t)(protlen -
+ sizeof(struct sctphdr)));
+ init->init.initiate_tag = (sctp->src_port << 16) |
+ sctp->dest_port;
+ init->init.a_rwnd = htonl(1500);
+ init->init.num_outbound_streams = htons(1);
+ init->init.num_inbound_streams = htons(1);
+ init->init.initial_tsn = htonl(0);
+ if (protlen >= (int)(sizeof(struct sctphdr) +
+ sizeof(struct sctp_init_chunk) +
+ sizeof(struct sctp_paramhdr))) {
+ param = (struct sctp_paramhdr *)(init + 1);
+ param->param_type = htons(SCTP_PAD);
+ param->param_length =
+ htons((u_int16_t)(protlen -
+ sizeof(struct sctphdr) -
+ sizeof(struct sctp_init_chunk)));
+ }
+ } else {
+ /*
+ * Send a packet containing a SHUTDOWN-ACK chunk,
+ * possibly followed by a PAD chunk.
+ */
+ if (protlen >=
+ (int)(sizeof(struct sctphdr) +
+ sizeof(struct sctp_chunkhdr))) {
+ chk = (struct sctp_chunkhdr *)(sctp + 1);
+ chk->chunk_type = SCTP_SHUTDOWN_ACK;
+ chk->chunk_flags = 0;
+ chk->chunk_length = htons(4);
+ }
+ if (protlen >=
+ (int)(sizeof(struct sctphdr) +
+ 2 * sizeof(struct sctp_chunkhdr))) {
+ chk = chk + 1;
+ chk->chunk_type = SCTP_PAD_CHUNK;
+ chk->chunk_flags = 0;
+ chk->chunk_length = htons(protlen -
+ (sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr)));
+ }
+ }
+ if (doipcksum) {
+ sctp->checksum = sctp_crc32c(sctp, protlen);
+ }
+}
+
+int
+sctp_check(const u_char *data, int seq)
+{
+ struct sctphdr *const sctp = (struct sctphdr *) data;
+
+ if (ntohs(sctp->src_port) != ident ||
+ ntohs(sctp->dest_port) != port + (fixedPort ? 0 : seq))
+ return (0);
+ if (protlen < (int)(sizeof(struct sctphdr) +
+ sizeof(struct sctp_init_chunk))) {
+ return (sctp->v_tag ==
+ (u_int32_t)((sctp->src_port << 16) | sctp->dest_port));
+ } else {
+ /*
+ * Don't verify the initiate_tag, since it is not available,
+ * most of the time.
+ */
+ return (sctp->v_tag == 0);
+ }
+}
+
+void
+gre_prep(struct outdata *outdata)
+{
+ struct grehdr *const gre = (struct grehdr *) outp;
+
+ gre->flags = htons(0x2001);
+ gre->proto = htons(port);
+ gre->length = 0;
+ gre->callId = htons(ident + outdata->seq);
+}
+
+int
+gre_check(const u_char *data, int seq)
+{
+ struct grehdr *const gre = (struct grehdr *) data;
+
+ return (ntohs(gre->proto) == port
+ && ntohs(gre->callId) == ident + seq);
+}
+
+void
+gen_prep(struct outdata *outdata)
+{
+ u_int16_t *const ptr = (u_int16_t *) outp;
+
+ ptr[0] = htons(ident);
+ ptr[1] = htons(port + outdata->seq);
+}
+
+int
+gen_check(const u_char *data, int seq)
+{
+ u_int16_t *const ptr = (u_int16_t *) data;
+
+ return (ntohs(ptr[0]) == ident
+ && ntohs(ptr[1]) == port + seq);
+}
+
+void
+print(register u_char *buf, register int cc, register struct sockaddr_in *from)
+{
+ register struct ip *ip;
+ register int hlen;
+ char addr[INET_ADDRSTRLEN];
+
+ ip = (struct ip *) buf;
+ hlen = ip->ip_hl << 2;
+ cc -= hlen;
+
+ strlcpy(addr, inet_ntoa(from->sin_addr), sizeof(addr));
+
+ if (as_path)
+ Printf(" [AS%u]", as_lookup(asn, addr, AF_INET));
+
+ if (nflag)
+ Printf(" %s", addr);
+ else
+ Printf(" %s (%s)", inetname(from->sin_addr), addr);
+
+ if (verbose)
+ Printf(" %d bytes to %s", cc, inet_ntoa(ip->ip_dst));
+}
+
+/*
+ * Checksum routine for UDP and TCP headers.
+ */
+u_short
+p_cksum(struct ip *ip, u_short *data, int len, int cov)
+{
+ static struct ipovly ipo;
+ u_short sum[2];
+
+ ipo.ih_pr = ip->ip_p;
+ ipo.ih_len = htons(len);
+ ipo.ih_src = ip->ip_src;
+ ipo.ih_dst = ip->ip_dst;
+
+ sum[1] = in_cksum((u_short *)&ipo, sizeof(ipo)); /* pseudo ip hdr cksum */
+ sum[0] = in_cksum(data, cov); /* payload data cksum */
+
+ return (~in_cksum(sum, sizeof(sum)));
+}
+
+/*
+ * Checksum routine for Internet Protocol family headers (C Version)
+ */
+u_short
+in_cksum(register u_short *addr, register int len)
+{
+ register int nleft = len;
+ register u_short *w = addr;
+ register u_short answer;
+ register int sum = 0;
+
+ /*
+ * Our algorithm is simple, using a 32 bit accumulator (sum),
+ * we add sequential 16 bit words to it, and at the end, fold
+ * back all the carry bits from the top 16 bits into the lower
+ * 16 bits.
+ */
+ while (nleft > 1) {
+ sum += *w++;
+ nleft -= 2;
+ }
+
+ /* mop up an odd byte, if necessary */
+ if (nleft == 1)
+ sum += *(u_char *)w;
+
+ /*
+ * add back carry outs from top 16 bits to low 16 bits
+ */
+ sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
+ sum += (sum >> 16); /* add carry */
+ answer = ~sum; /* truncate to 16 bits */
+ return (answer);
+}
+
+/*
+ * CRC32C routine for the Stream Control Transmission Protocol
+ */
+
+#define CRC32C(c, d) (c = (c >> 8) ^ crc_c[(c ^ (d)) & 0xFF])
+
+static u_int32_t crc_c[256] = {
+ 0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4,
+ 0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB,
+ 0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B,
+ 0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24,
+ 0x105EC76F, 0xE235446C, 0xF165B798, 0x030E349B,
+ 0xD7C45070, 0x25AFD373, 0x36FF2087, 0xC494A384,
+ 0x9A879FA0, 0x68EC1CA3, 0x7BBCEF57, 0x89D76C54,
+ 0x5D1D08BF, 0xAF768BBC, 0xBC267848, 0x4E4DFB4B,
+ 0x20BD8EDE, 0xD2D60DDD, 0xC186FE29, 0x33ED7D2A,
+ 0xE72719C1, 0x154C9AC2, 0x061C6936, 0xF477EA35,
+ 0xAA64D611, 0x580F5512, 0x4B5FA6E6, 0xB93425E5,
+ 0x6DFE410E, 0x9F95C20D, 0x8CC531F9, 0x7EAEB2FA,
+ 0x30E349B1, 0xC288CAB2, 0xD1D83946, 0x23B3BA45,
+ 0xF779DEAE, 0x05125DAD, 0x1642AE59, 0xE4292D5A,
+ 0xBA3A117E, 0x4851927D, 0x5B016189, 0xA96AE28A,
+ 0x7DA08661, 0x8FCB0562, 0x9C9BF696, 0x6EF07595,
+ 0x417B1DBC, 0xB3109EBF, 0xA0406D4B, 0x522BEE48,
+ 0x86E18AA3, 0x748A09A0, 0x67DAFA54, 0x95B17957,
+ 0xCBA24573, 0x39C9C670, 0x2A993584, 0xD8F2B687,
+ 0x0C38D26C, 0xFE53516F, 0xED03A29B, 0x1F682198,
+ 0x5125DAD3, 0xA34E59D0, 0xB01EAA24, 0x42752927,
+ 0x96BF4DCC, 0x64D4CECF, 0x77843D3B, 0x85EFBE38,
+ 0xDBFC821C, 0x2997011F, 0x3AC7F2EB, 0xC8AC71E8,
+ 0x1C661503, 0xEE0D9600, 0xFD5D65F4, 0x0F36E6F7,
+ 0x61C69362, 0x93AD1061, 0x80FDE395, 0x72966096,
+ 0xA65C047D, 0x5437877E, 0x4767748A, 0xB50CF789,
+ 0xEB1FCBAD, 0x197448AE, 0x0A24BB5A, 0xF84F3859,
+ 0x2C855CB2, 0xDEEEDFB1, 0xCDBE2C45, 0x3FD5AF46,
+ 0x7198540D, 0x83F3D70E, 0x90A324FA, 0x62C8A7F9,
+ 0xB602C312, 0x44694011, 0x5739B3E5, 0xA55230E6,
+ 0xFB410CC2, 0x092A8FC1, 0x1A7A7C35, 0xE811FF36,
+ 0x3CDB9BDD, 0xCEB018DE, 0xDDE0EB2A, 0x2F8B6829,
+ 0x82F63B78, 0x709DB87B, 0x63CD4B8F, 0x91A6C88C,
+ 0x456CAC67, 0xB7072F64, 0xA457DC90, 0x563C5F93,
+ 0x082F63B7, 0xFA44E0B4, 0xE9141340, 0x1B7F9043,
+ 0xCFB5F4A8, 0x3DDE77AB, 0x2E8E845F, 0xDCE5075C,
+ 0x92A8FC17, 0x60C37F14, 0x73938CE0, 0x81F80FE3,
+ 0x55326B08, 0xA759E80B, 0xB4091BFF, 0x466298FC,
+ 0x1871A4D8, 0xEA1A27DB, 0xF94AD42F, 0x0B21572C,
+ 0xDFEB33C7, 0x2D80B0C4, 0x3ED04330, 0xCCBBC033,
+ 0xA24BB5A6, 0x502036A5, 0x4370C551, 0xB11B4652,
+ 0x65D122B9, 0x97BAA1BA, 0x84EA524E, 0x7681D14D,
+ 0x2892ED69, 0xDAF96E6A, 0xC9A99D9E, 0x3BC21E9D,
+ 0xEF087A76, 0x1D63F975, 0x0E330A81, 0xFC588982,
+ 0xB21572C9, 0x407EF1CA, 0x532E023E, 0xA145813D,
+ 0x758FE5D6, 0x87E466D5, 0x94B49521, 0x66DF1622,
+ 0x38CC2A06, 0xCAA7A905, 0xD9F75AF1, 0x2B9CD9F2,
+ 0xFF56BD19, 0x0D3D3E1A, 0x1E6DCDEE, 0xEC064EED,
+ 0xC38D26C4, 0x31E6A5C7, 0x22B65633, 0xD0DDD530,
+ 0x0417B1DB, 0xF67C32D8, 0xE52CC12C, 0x1747422F,
+ 0x49547E0B, 0xBB3FFD08, 0xA86F0EFC, 0x5A048DFF,
+ 0x8ECEE914, 0x7CA56A17, 0x6FF599E3, 0x9D9E1AE0,
+ 0xD3D3E1AB, 0x21B862A8, 0x32E8915C, 0xC083125F,
+ 0x144976B4, 0xE622F5B7, 0xF5720643, 0x07198540,
+ 0x590AB964, 0xAB613A67, 0xB831C993, 0x4A5A4A90,
+ 0x9E902E7B, 0x6CFBAD78, 0x7FAB5E8C, 0x8DC0DD8F,
+ 0xE330A81A, 0x115B2B19, 0x020BD8ED, 0xF0605BEE,
+ 0x24AA3F05, 0xD6C1BC06, 0xC5914FF2, 0x37FACCF1,
+ 0x69E9F0D5, 0x9B8273D6, 0x88D28022, 0x7AB90321,
+ 0xAE7367CA, 0x5C18E4C9, 0x4F48173D, 0xBD23943E,
+ 0xF36E6F75, 0x0105EC76, 0x12551F82, 0xE03E9C81,
+ 0x34F4F86A, 0xC69F7B69, 0xD5CF889D, 0x27A40B9E,
+ 0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E,
+ 0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351
+};
+
+u_int32_t
+sctp_crc32c(const void *packet, u_int32_t len)
+{
+ u_int32_t i, crc32c;
+ u_int8_t byte0, byte1, byte2, byte3;
+ const u_int8_t *buf = (const u_int8_t *)packet;
+
+ crc32c = ~0;
+ for (i = 0; i < len; i++)
+ CRC32C(crc32c, buf[i]);
+ crc32c = ~crc32c;
+ byte0 = crc32c & 0xff;
+ byte1 = (crc32c >> 8) & 0xff;
+ byte2 = (crc32c >> 16) & 0xff;
+ byte3 = (crc32c >> 24) & 0xff;
+ crc32c = ((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3);
+ return (htonl(crc32c));
+}
+
+/*
+ * Subtract 2 timeval structs: out = out - in.
+ * Out is assumed to be within about LONG_MAX seconds of in.
+ */
+void
+tvsub(register struct timeval *out, register struct timeval *in)
+{
+
+ if ((out->tv_usec -= in->tv_usec) < 0) {
+ --out->tv_sec;
+ out->tv_usec += 1000000;
+ }
+ out->tv_sec -= in->tv_sec;
+}
+
+/*
+ * Construct an Internet address representation.
+ * If the nflag has been supplied, give
+ * numeric value, otherwise try for symbolic name.
+ */
+char *
+inetname(struct in_addr in)
+{
+ register char *cp;
+ register struct hostent *hp;
+ static int first = 1;
+ static char domain[MAXHOSTNAMELEN + 1], line[MAXHOSTNAMELEN + 1];
+
+ if (first && !nflag) {
+ first = 0;
+ if (gethostname(domain, sizeof(domain) - 1) < 0)
+ domain[0] = '\0';
+ else {
+ cp = strchr(domain, '.');
+ if (cp == NULL) {
+#ifdef WITH_CASPER
+ if (capdns != NULL)
+ hp = cap_gethostbyname(capdns, domain);
+ else
+#endif
+ hp = gethostbyname(domain);
+ if (hp != NULL)
+ cp = strchr(hp->h_name, '.');
+ }
+ if (cp == NULL)
+ domain[0] = '\0';
+ else {
+ ++cp;
+ (void)strncpy(domain, cp, sizeof(domain) - 1);
+ domain[sizeof(domain) - 1] = '\0';
+ }
+ }
+ }
+ if (!nflag && in.s_addr != INADDR_ANY) {
+#ifdef WITH_CASPER
+ if (capdns != NULL)
+ hp = cap_gethostbyaddr(capdns, (char *)&in, sizeof(in),
+ AF_INET);
+ else
+#endif
+ hp = gethostbyaddr((char *)&in, sizeof(in), AF_INET);
+ if (hp != NULL) {
+ if ((cp = strchr(hp->h_name, '.')) != NULL &&
+ strcmp(cp + 1, domain) == 0)
+ *cp = '\0';
+ (void)strncpy(line, hp->h_name, sizeof(line) - 1);
+ line[sizeof(line) - 1] = '\0';
+ return (line);
+ }
+ }
+ return (inet_ntoa(in));
+}
+
+struct hostinfo *
+gethostinfo(register char *hostname)
+{
+ register int n;
+ register struct hostent *hp;
+ register struct hostinfo *hi;
+ register char **p;
+ register u_int32_t addr, *ap;
+
+ if (strlen(hostname) >= MAXHOSTNAMELEN) {
+ Fprintf(stderr, "%s: hostname \"%.32s...\" is too long\n",
+ prog, hostname);
+ exit(1);
+ }
+ hi = calloc(1, sizeof(*hi));
+ if (hi == NULL) {
+ Fprintf(stderr, "%s: calloc %s\n", prog, strerror(errno));
+ exit(1);
+ }
+ addr = inet_addr(hostname);
+ if ((int32_t)addr != -1) {
+ hi->name = strdup(hostname);
+ hi->n = 1;
+ hi->addrs = calloc(1, sizeof(hi->addrs[0]));
+ if (hi->addrs == NULL) {
+ Fprintf(stderr, "%s: calloc %s\n",
+ prog, strerror(errno));
+ exit(1);
+ }
+ hi->addrs[0] = addr;
+ return (hi);
+ }
+
+#ifdef WITH_CASPER
+ if (capdns != NULL)
+ hp = cap_gethostbyname(capdns, hostname);
+ else
+#endif
+ hp = gethostbyname(hostname);
+ if (hp == NULL) {
+ Fprintf(stderr, "%s: unknown host %s\n", prog, hostname);
+ exit(1);
+ }
+ if (hp->h_addrtype != AF_INET || hp->h_length != 4) {
+ Fprintf(stderr, "%s: bad host %s\n", prog, hostname);
+ exit(1);
+ }
+ hi->name = strdup(hp->h_name);
+ for (n = 0, p = hp->h_addr_list; *p != NULL; ++n, ++p)
+ continue;
+ hi->n = n;
+ hi->addrs = calloc(n, sizeof(hi->addrs[0]));
+ if (hi->addrs == NULL) {
+ Fprintf(stderr, "%s: calloc %s\n", prog, strerror(errno));
+ exit(1);
+ }
+ for (ap = hi->addrs, p = hp->h_addr_list; *p != NULL; ++ap, ++p)
+ memcpy(ap, *p, sizeof(*ap));
+ return (hi);
+}
+
+void
+freehostinfo(register struct hostinfo *hi)
+{
+ if (hi->name != NULL) {
+ free(hi->name);
+ hi->name = NULL;
+ }
+ free((char *)hi->addrs);
+ free((char *)hi);
+}
+
+void
+getaddr(register u_int32_t *ap, register char *hostname)
+{
+ register struct hostinfo *hi;
+
+ hi = gethostinfo(hostname);
+ *ap = hi->addrs[0];
+ freehostinfo(hi);
+}
+
+void
+setsin(register struct sockaddr_in *sin, register u_int32_t addr)
+{
+
+ memset(sin, 0, sizeof(*sin));
+ sin->sin_len = sizeof(*sin);
+ sin->sin_family = AF_INET;
+ sin->sin_addr.s_addr = addr;
+}
+
+/* String to value with optional min and max. Handles decimal and hex. */
+int
+str2val(register const char *str, register const char *what,
+ register int mi, register int ma)
+{
+ register const char *cp;
+ register int val;
+ char *ep;
+
+ if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) {
+ cp = str + 2;
+ val = (int)strtol(cp, &ep, 16);
+ } else
+ val = (int)strtol(str, &ep, 10);
+ if (*ep != '\0') {
+ Fprintf(stderr, "%s: \"%s\" bad value for %s\n",
+ prog, str, what);
+ exit(1);
+ }
+ if (val < mi && mi >= 0) {
+ if (mi == 0)
+ Fprintf(stderr, "%s: %s must be >= %d\n",
+ prog, what, mi);
+ else
+ Fprintf(stderr, "%s: %s must be > %d\n",
+ prog, what, mi - 1);
+ exit(1);
+ }
+ if (val > ma && ma >= 0) {
+ Fprintf(stderr, "%s: %s must be <= %d\n", prog, what, ma);
+ exit(1);
+ }
+ return (val);
+}
+
+struct outproto *
+setproto(char *pname)
+{
+ struct outproto *proto;
+ int i;
+
+ for (i = 0; protos[i].name != NULL; i++) {
+ if (strcasecmp(protos[i].name, pname) == 0) {
+ break;
+ }
+ }
+ proto = &protos[i];
+ if (proto->name == NULL) { /* generic handler */
+ struct protoent *pe;
+ u_long pnum;
+
+ /* Determine the IP protocol number */
+ if ((pe = getprotobyname(pname)) != NULL)
+ pnum = pe->p_proto;
+ else
+ pnum = str2val(optarg, "proto number", 1, 255);
+ proto->num = pnum;
+ }
+ return (proto);
+}
+
+void
+pkt_compare(const u_char *a, int la, const u_char *b, int lb) {
+ int l;
+ int i;
+
+ for (i = 0; i < la; i++)
+ Printf("%02x", (unsigned int)a[i]);
+ Printf("\n");
+ l = (la <= lb) ? la : lb;
+ for (i = 0; i < l; i++)
+ if (a[i] == b[i])
+ Printf("__");
+ else
+ Printf("%02x", (unsigned int)b[i]);
+ for (; i < lb; i++)
+ Printf("%02x", (unsigned int)b[i]);
+ Printf("\n");
+}
+
+
+void
+usage(void)
+{
+ Fprintf(stderr,
+ "Usage: %s [-adDeEFInrSvx] [-A as_server] [-f first_ttl] [-g gateway]\n"
+ "\t[-i iface] [-m max_ttl] [-M first_ttl] [-p port] [-P proto]\n"
+ "\t[-q nprobes] [-s src_addr] [-t tos] [-w waittime]\n"
+ "\t[-z pausemsecs] host [packetlen]\n", prog);
+ exit(1);
+}
diff --git a/usr.sbin/traceroute/traceroute.h b/usr.sbin/traceroute/traceroute.h
new file mode 100644
index 000000000000..7ddf087f9fb6
--- /dev/null
+++ b/usr.sbin/traceroute/traceroute.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2000
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#) $Id: traceroute.h,v 1.1 2000/11/23 20:06:54 leres Exp $ (LBL)
+ */
+
+extern char *prog;
+
+void setsin(struct sockaddr_in *, u_int32_t);
diff --git a/usr.sbin/traceroute6/Makefile b/usr.sbin/traceroute6/Makefile
index 4d28d8f3c347..d2b84296fe97 100644
--- a/usr.sbin/traceroute6/Makefile
+++ b/usr.sbin/traceroute6/Makefile
@@ -11,11 +11,10 @@
# AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
# LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE.
-# $FreeBSD$
.include <src.opts.mk>
-TRACEROUTE_DISTDIR?= ${SRCTOP}/contrib/traceroute
+TRACEROUTE_DISTDIR?= ${SRCTOP}/usr.sbin/traceroute
.PATH: ${TRACEROUTE_DISTDIR}
PACKAGE= runtime
diff --git a/usr.sbin/traceroute6/Makefile.depend b/usr.sbin/traceroute6/Makefile.depend
index b78c121a5f29..fe5482dd4b09 100644
--- a/usr.sbin/traceroute6/Makefile.depend
+++ b/usr.sbin/traceroute6/Makefile.depend
@@ -1,13 +1,14 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
+ lib/libcasper/libcasper \
+ lib/libcasper/services/cap_dns \
lib/libcompiler_rt \
lib/libipsec \
diff --git a/usr.sbin/traceroute6/traceroute6.8 b/usr.sbin/traceroute6/traceroute6.8
index afa201d19c24..f185b8087411 100644
--- a/usr.sbin/traceroute6/traceroute6.8
+++ b/usr.sbin/traceroute6/traceroute6.8
@@ -27,9 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd November 25, 2020
+.Dd February 2, 2024
.Dt TRACEROUTE6 8
.Os
.\"
@@ -40,7 +38,10 @@
.Sh SYNOPSIS
.Nm
.Bk -words
-.Op Fl adIlnNrSTUv
+.Op Fl adEIlnNrSTUv
+.Ek
+.Bk -words
+.Op Fl A Ar as_server
.Ek
.Bk -words
.Op Fl f Ar firsthop
@@ -67,9 +68,6 @@
.Op Fl w Ar waittime
.Ek
.Bk -words
-.Op Fl A Ar as_server
-.Ek
-.Bk -words
.Ar target
.Op Ar datalen
.Ek
@@ -77,16 +75,14 @@
.Sh DESCRIPTION
The
.Nm
-utility
-uses the IPv6 protocol hop limit field to elicit an ICMPv6 TIME_EXCEEDED
-response from each gateway along the path to some host.
+utility uses the IPv6 protocol hop limit field to elicit an ICMPv6
+TIME_EXCEEDED response from each gateway along the path to some host.
.Pp
The only mandatory parameter is the destination host name or IPv6 address.
-The default probe datagram carries 20 bytes of payload,
-in addition to the IPv6 header.
-The size of the payload can be specified by giving a length
-(in bytes)
-after the destination host name.
+The default probe datagram carries 20 bytes of payload, in addition to the IPv6
+header.
+The size of the payload can be specified by giving a length (in bytes) after
+the destination host name.
.Pp
Other options are:
.Bl -tag -width Ds
@@ -96,6 +92,22 @@ Turn on AS# lookups for each hop encountered.
Turn on AS# lookups and use the given server instead of the default.
.It Fl d
Debug mode.
+.It Fl E
+Detect ECN bleaching.
+Set the
+.Em IPTOS_ECN_ECT1
+Explicit Congestion Notification (ECN) bits
+.Pq Dv 01 ,
+and report if the hop has bleached
+.Pq Dv 00
+or mangled
+.Pq Dv 10
+them, or if it is experiencing congestion
+.Pq Dv 11 .
+Otherwise, report that it passed the bits appropriately.
+If
+.Fl t
+is also specified, the corresponding ECN bits will be replaced.
.It Fl f Ar firsthop
Specify how many hops to skip in trace.
.It Fl g Ar gateway
@@ -106,14 +118,7 @@ tries to use routing headers.
.It Fl I
Use ICMP6 ECHO instead of UDP datagrams.
.It Fl l
-Print both host hostnames and numeric addresses.
-Normally
-.Nm
-prints only hostnames if
-.Fl n
-is not specified, and only numeric addresses if
-.Fl n
-is specified.
+Ignored for backward compatibility.
.It Fl m Ar hoplimit
Specify maximum hoplimit, up to 255.
The default is the value of the
@@ -123,8 +128,8 @@ The default is the value of the
.It Fl n
Do not resolve numeric address to hostname.
.It Fl N
-Use a packet with no upper layer header for the probes,
-instead of UDP datagrams.
+Use a packet with no upper layer header for the probes, instead of UDP
+datagrams.
.It Fl p Ar port
Set SCTP/TCP/UDP port number to
.Ar port .
@@ -132,16 +137,15 @@ Set SCTP/TCP/UDP port number to
Set the number of probe per hop count to
.Ar probes .
.It Fl r
-Bypass the normal routing tables and send directly to a host
-on an attached network.
+Bypass the normal routing tables and send directly to a host on an attached
+network.
If the host is not on a directly-connected network,
an error is returned.
This option corresponds to the
.Dv SO_DONTROUTE
-socket option;
-it can be used to ping a local host through an interface
-that has no route through it
-(e.g., after the interface was dropped by a routing daemon).
+socket option; it can be used to ping a local host through an interface that
+has no route through it (e.g., after the interface was dropped by a routing
+daemon).
.It Fl s Ar src
.Ar Src
specifies the source IPv6 address to be used.
@@ -171,10 +175,11 @@ Be verbose.
Specify the delay time between probes.
.El
.Pp
-This program prints the route to the given destination and the round-trip
-time to each gateway, in the same manner as traceroute.
+This program prints the route to the given destination and the round-trip time
+to each gateway, in the same manner as traceroute.
.Pp
-Here is a list of possible annotations after the round-trip time for each gateway:
+Here is a list of possible annotations after the round-trip time for each
+gateway:
.Bl -hang -offset indent
.It !N
Destination Unreachable - No Route to Host.
@@ -188,11 +193,11 @@ Destination Unreachable - Address Unreachable.
Parameter Problem - Unrecognized Next Header Type.
.It !\&
This is printed if the hop limit is <= 1 on a port unreachable message.
-This means that the packet got to the destination,
-but that the reply had a hop limit that was just large enough to
-allow it to get back to the source of the traceroute6.
-This was more interesting in the IPv4 case,
-where some IP stack bugs could be identified by this behaviour.
+This means that the packet got to the destination, but that the reply had a hop
+limit that was just large enough to allow it to get back to the source of the
+traceroute6.
+This was more interesting in the IPv4 case, where some IP stack bugs could be
+identified by this behaviour.
.El
.\"
.Sh EXIT STATUS
diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c
index a071c084ad07..dfe1d9565b94 100644
--- a/usr.sbin/traceroute6/traceroute6.c
+++ b/usr.sbin/traceroute6/traceroute6.c
@@ -63,20 +63,6 @@
* SUCH DAMAGE.
*/
-#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
-#if 0
-static char sccsid[] = "@(#)traceroute.c 8.1 (Berkeley) 6/6/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
/*
* traceroute host - trace the route ip packets follow going to "host".
*
@@ -86,9 +72,9 @@ static const char rcsid[] =
* icmp "time exceeded" reply from a gateway. We start our probes
* with a ttl of one and increase by one until we get an icmp "port
* unreachable" (which means we got to "host") or hit a max (which
- * defaults to 30 hops & can be changed with the -m flag). Three
- * probes (change with -q flag) are sent at each ttl setting and a
- * line is printed showing the ttl, address of the gateway and
+ * defaults to net.inet.ip.ttl hops & can be changed with the -m flag).
+ * Three probes (change with -q flag) are sent at each ttl setting and
+ * a line is printed showing the ttl, address of the gateway and
* round trip time of each probe. If the probe answers come from
* different gateways, the address of each responding system will
* be printed. If there is no response within a 5 sec. timeout
@@ -103,7 +89,7 @@ static const char rcsid[] =
* A sample use might be:
*
* [yak 71]% traceroute nis.nsf.net.
- * traceroute to nis.nsf.net (35.1.1.48), 30 hops max, 56 byte packet
+ * traceroute to nis.nsf.net (35.1.1.48), 64 hops max, 40 byte packets
* 1 helios.ee.lbl.gov (128.3.112.1) 19 ms 19 ms 0 ms
* 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
* 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
@@ -123,7 +109,7 @@ static const char rcsid[] =
* A more interesting example is:
*
* [yak 72]% traceroute allspice.lcs.mit.edu.
- * traceroute to allspice.lcs.mit.edu (18.26.0.115), 30 hops max
+ * traceroute to allspice.lcs.mit.edu (18.26.0.115), 64 hops max, 40 byte packets
* 1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
* 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 19 ms 19 ms
* 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 19 ms
@@ -244,7 +230,7 @@ static const char rcsid[] =
* back to yourself. Unfortunately, SO many gateways botch source
* routing, the thing is almost worthless. Maybe one day...
*
- * -- Van Jacobson (van@helios.ee.lbl.gov)
+ * -- Van Jacobson (van@ee.lbl.gov)
* Tue Dec 20 03:50:13 PST 1988
*/
@@ -276,6 +262,7 @@ static const char rcsid[] =
#include <string.h>
#include <unistd.h>
+#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#include <netinet/sctp.h>
@@ -308,7 +295,7 @@ void capdns_open(void);
int get_hoplim(struct msghdr *);
double deltaT(struct timeval *, struct timeval *);
const char *pr_type(int);
-int packet_ok(struct msghdr *, int, int, u_char *, u_char *);
+int packet_ok(struct msghdr *, int, int, u_char *, u_char *, u_char *);
void print(struct msghdr *, int);
const char *inetname(struct sockaddr *);
u_int32_t sctp_crc32c(void *, u_int32_t);
@@ -344,7 +331,7 @@ static u_long nprobes = 3;
static u_long first_hop = 1;
static u_long max_hops = 30;
static u_int16_t srcport;
-static u_int16_t port = 32768+666; /* start udp dest port # for probe packets */
+static u_int16_t port = 32768 + 666; /* start udp dest port # for probe packets */
static u_int16_t ident;
static int tclass = -1;
static int options; /* socket options */
@@ -352,8 +339,8 @@ static int verbose;
static int waittime = 5; /* time to wait for response (in seconds) */
static int nflag; /* print addresses numerically */
static int useproto = IPPROTO_UDP; /* protocol to use to send packet */
-static int lflag; /* print both numerical address & hostname */
static int as_path; /* print as numbers for each hop */
+static int ecnflag; /* ECN bleaching detection flag */
static char *as_server = NULL;
static void *asn;
@@ -369,7 +356,7 @@ main(int argc, char *argv[])
struct hostent *hp;
size_t size, minlen;
uid_t uid;
- u_char type, code;
+ u_char type, code, ecn;
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
char ipsec_inpolicy[] = "in bypass";
char ipsec_outpolicy[] = "out bypass";
@@ -387,7 +374,7 @@ main(int argc, char *argv[])
}
size = sizeof(i);
- (void) sysctl(mib, sizeof(mib)/sizeof(mib[0]), &i, &size, NULL, 0);
+ (void) sysctl(mib, sizeof(mib) / sizeof(mib[0]), &i, &size, NULL, 0);
max_hops = i;
/* specify to tell receiving interface */
@@ -415,7 +402,7 @@ main(int argc, char *argv[])
seq = 0;
ident = htons(getpid() & 0xffff); /* same as ping6 */
- while ((ch = getopt(argc, argv, "aA:df:g:Ilm:nNp:q:rs:St:TUvw:")) != -1)
+ while ((ch = getopt(argc, argv, "aA:dEf:g:Ilm:nNp:q:rs:St:TUvw:")) != -1)
switch (ch) {
case 'a':
as_path = 1;
@@ -427,6 +414,9 @@ main(int argc, char *argv[])
case 'd':
options |= SO_DEBUG;
break;
+ case 'E':
+ ecnflag = 1;
+ break;
case 'f':
ep = NULL;
errno = 0;
@@ -471,7 +461,6 @@ main(int argc, char *argv[])
useproto = IPPROTO_ICMPV6;
break;
case 'l':
- lflag++;
break;
case 'm':
ep = NULL;
@@ -598,6 +587,15 @@ main(int argc, char *argv[])
exit(1);
}
+ if (ecnflag) {
+ if (tclass != -1) {
+ tclass &= ~IPTOS_ECN_MASK;
+ } else {
+ tclass = 0;
+ }
+ tclass |= IPTOS_ECN_ECT1;
+ }
+
/* revoke privs */
uid = getuid();
if (setresuid(uid, uid, uid) == -1) {
@@ -695,7 +693,7 @@ main(int argc, char *argv[])
exit(1);
}
if ((useproto == IPPROTO_SCTP) && (datalen & 3)) {
- fprintf(stderr,
+ fprintf(stderr,
"traceroute6: packet size must be a multiple of 4.\n");
exit(1);
}
@@ -937,7 +935,7 @@ main(int argc, char *argv[])
strerror(errno));
exit(1);
}
- cap_rights_init(&rights, CAP_RECV);
+ cap_rights_init(&rights, CAP_RECV, CAP_EVENT);
if (caph_rights_limit(rcvsock, &rights) < 0) {
fprintf(stderr, "caph_rights_limit rcvsock: %s\n",
strerror(errno));
@@ -962,7 +960,7 @@ main(int argc, char *argv[])
send_probe(++seq, hops);
while ((cc = wait_for_reply(rcvsock, &rcvmhdr))) {
(void) gettimeofday(&t2, NULL);
- if (packet_ok(&rcvmhdr, cc, seq, &type, &code)) {
+ if (packet_ok(&rcvmhdr, cc, seq, &type, &code, &ecn)) {
if (!IN6_ARE_ADDR_EQUAL(&Rcv.sin6_addr,
&lastaddr)) {
if (probe > 0)
@@ -971,6 +969,22 @@ main(int argc, char *argv[])
lastaddr = Rcv.sin6_addr;
}
printf(" %.3f ms", deltaT(&t1, &t2));
+ if (ecnflag) {
+ switch (ecn) {
+ case IPTOS_ECN_ECT1:
+ printf(" (ecn=passed)");
+ break;
+ case IPTOS_ECN_NOTECT:
+ printf(" (ecn=bleached)");
+ break;
+ case IPTOS_ECN_CE:
+ printf(" (ecn=congested)");
+ break;
+ default:
+ printf(" (ecn=mangled)");
+ break;
+ }
+ }
if (type == ICMP6_DST_UNREACH) {
switch (code) {
case ICMP6_DST_UNREACH_NOROUTE:
@@ -1039,7 +1053,8 @@ wait_for_reply(int sock, struct msghdr *mhdr)
pfd[0].events = POLLIN;
pfd[0].revents = 0;
- if (poll(pfd, 1, waittime * 1000) > 0)
+ if (poll(pfd, 1, waittime * 1000) > 0 &&
+ pfd[0].revents & POLLIN)
cc = recvmsg(rcvsock, mhdr, 0);
return (cc);
@@ -1055,7 +1070,7 @@ wait_for_reply(int sock, struct msghdr *mhdr)
FD_SET(sock, fdsp);
wait.tv_sec = waittime; wait.tv_usec = 0;
- if (select(sock+1, fdsp, (fd_set *)0, (fd_set *)0, &wait) > 0)
+ if (select(sock + 1, fdsp, (fd_set *)0, (fd_set *)0, &wait) > 0)
cc = recvmsg(rcvsock, mhdr, 0);
free(fdsp);
@@ -1072,14 +1087,14 @@ setpolicy(int so, char *policy)
buf = ipsec_set_policy(policy, strlen(policy));
if (buf == NULL) {
warnx("%s", ipsec_strerror());
- return -1;
+ return (-1);
}
(void)setsockopt(so, IPPROTO_IPV6, IPV6_IPSEC_POLICY,
buf, ipsec_get_policylen(buf));
free(buf);
- return 0;
+ return (0);
}
#endif
@@ -1116,7 +1131,7 @@ send_probe(int seq, u_long hops)
case IPPROTO_UDP:
outudp = (struct udphdr *) outpacket;
outudp->uh_sport = htons(ident);
- outudp->uh_dport = htons(port+seq);
+ outudp->uh_dport = htons(port + seq);
outudp->uh_ulen = htons(datalen);
outudp->uh_sum = 0;
outudp->uh_sum = udp_cksum(&Src, &Dst, outpacket, datalen);
@@ -1206,7 +1221,7 @@ send_probe(int seq, u_long hops)
fprintf(stderr, "Unknown probe protocol %d.\n", useproto);
exit(1);
}
-
+
i = send(sndsock, (char *)outpacket, datalen, 0);
if (i < 0 || (u_long)i != datalen) {
if (i < 0)
@@ -1299,11 +1314,12 @@ pr_type(int t0)
cp = "Unknown";
break;
}
- return cp;
+ return (cp);
}
int
-packet_ok(struct msghdr *mhdr, int cc, int seq, u_char *type, u_char *code)
+packet_ok(struct msghdr *mhdr, int cc, int seq, u_char *type, u_char *code,
+ u_char *ecn)
{
struct icmp6_hdr *icp;
struct sockaddr_in6 *from = (struct sockaddr_in6 *)mhdr->msg_name;
@@ -1367,8 +1383,7 @@ packet_ok(struct msghdr *mhdr, int cc, int seq, u_char *type, u_char *code)
#else
rcvhlim = 0; /*XXX*/
#endif
- }
- else
+ } else
rcvhlim = *hlimp;
*type = icp->icmp6_type;
@@ -1387,6 +1402,7 @@ packet_ok(struct msghdr *mhdr, int cc, int seq, u_char *type, u_char *code)
void *up;
hip = (struct ip6_hdr *)(icp + 1);
+ *ecn = ntohl(hip->ip6_flow & IPV6_ECN_MASK) >> 20;
if ((up = get_uphdr(hip, (u_char *)(buf + cc))) == NULL) {
if (verbose)
warnx("failed to get upper layer header");
@@ -1453,7 +1469,7 @@ packet_ok(struct msghdr *mhdr, int cc, int seq, u_char *type, u_char *code)
return (1);
}
if (verbose) {
- char sbuf[NI_MAXHOST+1], dbuf[INET6_ADDRSTRLEN];
+ char sbuf[NI_MAXHOST + 1], dbuf[INET6_ADDRSTRLEN];
u_int8_t *p;
int i;
@@ -1566,10 +1582,8 @@ print(struct msghdr *mhdr, int cc)
printf(" [AS%u]", as_lookup(asn, hbuf, AF_INET6));
if (nflag)
printf(" %s", hbuf);
- else if (lflag)
- printf(" %s (%s)", inetname((struct sockaddr *)from), hbuf);
else
- printf(" %s", inetname((struct sockaddr *)from));
+ printf(" %s (%s)", inetname((struct sockaddr *)from), hbuf);
if (verbose) {
#ifdef OLDRAWSOCKET
@@ -1615,19 +1629,19 @@ inetname(struct sockaddr *sa)
}
}
if (cp)
- return cp;
+ return (cp);
if (cap_getnameinfo(capdns, sa, sa->sa_len, line, sizeof(line), NULL, 0,
NI_NUMERICHOST) != 0)
strlcpy(line, "invalid", sizeof(line));
- return line;
+ return (line);
}
/*
* CRC32C routine for the Stream Control Transmission Protocol
*/
-#define CRC32C(c, d) (c = (c>>8) ^ crc_c[(c^(d))&0xFF])
+#define CRC32C(c, d) (c = (c >> 8) ^ crc_c[(c ^ (d)) & 0xFF])
static u_int32_t crc_c[256] = {
0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4,
@@ -1708,11 +1722,11 @@ sctp_crc32c(void *pack, u_int32_t len)
CRC32C(crc32c, buf[i]);
crc32c = ~crc32c;
byte0 = crc32c & 0xff;
- byte1 = (crc32c>>8) & 0xff;
- byte2 = (crc32c>>16) & 0xff;
- byte3 = (crc32c>>24) & 0xff;
+ byte1 = (crc32c >> 8) & 0xff;
+ byte2 = (crc32c >> 16) & 0xff;
+ byte3 = (crc32c >> 24) & 0xff;
crc32c = ((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3);
- return htonl(crc32c);
+ return (htonl(crc32c));
}
u_int16_t
@@ -1804,10 +1818,9 @@ tcp_chksum(struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
void
usage(void)
{
-
fprintf(stderr,
-"usage: traceroute6 [-adIlnNrSTUv] [-A as_server] [-f firsthop] [-g gateway]\n"
-" [-m hoplimit] [-p port] [-q probes] [-s src] [-w waittime] target\n"
-" [datalen]\n");
+"Usage: traceroute6 [-adEIlnNrSTUv] [-A as_server] [-f firsthop] [-g gateway]\n"
+"\t[-m hoplimit] [-p port] [-q probes] [-s src] [-t tclass]\n"
+"\t[-w waittime] target [datalen]\n");
exit(1);
}
diff --git a/usr.sbin/trim/Makefile b/usr.sbin/trim/Makefile
index 6126ef35503a..cb609121be7b 100644
--- a/usr.sbin/trim/Makefile
+++ b/usr.sbin/trim/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= trim
MAN= trim.8
diff --git a/usr.sbin/trim/trim.8 b/usr.sbin/trim/trim.8
index abd306ab70af..1ac10d7e3d46 100644
--- a/usr.sbin/trim/trim.8
+++ b/usr.sbin/trim/trim.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 18, 2019
.Dt TRIM 8
.Os
diff --git a/usr.sbin/trim/trim.c b/usr.sbin/trim/trim.c
index a368f3ac799c..3e187faa0fb3 100644
--- a/usr.sbin/trim/trim.c
+++ b/usr.sbin/trim/trim.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 Eugene Grosbein <eugen@FreeBSD.org>.
* Contains code written by Alan Somers <asomers@FreeBSD.org>.
@@ -45,8 +45,6 @@
#include <unistd.h>
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
static bool candelete(int fd);
static off_t getsize(const char *path);
static int opendev(const char *path, int flags);
diff --git a/usr.sbin/trpt/Makefile b/usr.sbin/trpt/Makefile
deleted file mode 100644
index 33a3d1f81a7f..000000000000
--- a/usr.sbin/trpt/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
-
-.include <src.opts.mk>
-
-PROG= trpt
-MAN= trpt.8
-BINGRP= kmem
-BINMODE= 2555
-
-.if ${MK_INET6_SUPPORT} != "no"
-CFLAGS+= -DINET6
-.endif
-
-.include <bsd.prog.mk>
-
-# Several included system headers tickle this warning in ways that are
-# difficult to work around in this program.
-CFLAGS+= -Wno-missing-variable-declarations
diff --git a/usr.sbin/trpt/trpt.8 b/usr.sbin/trpt/trpt.8
deleted file mode 100644
index 3c66f5afe761..000000000000
--- a/usr.sbin/trpt/trpt.8
+++ /dev/null
@@ -1,144 +0,0 @@
-.\" Copyright (c) 1983, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)trpt.8 8.2 (Berkeley) 12/11/93
-.\" $FreeBSD$
-.\"
-.Dd February 15, 2018
-.Dt TRPT 8
-.Os
-.Sh NAME
-.Nm trpt
-.Nd transliterate protocol trace
-.Sh SYNOPSIS
-.Nm
-.Op Fl a
-.Op Fl f
-.Op Fl j
-.Op Fl p Ar hex-address
-.Op Fl s
-.Oo
-.Ar system Op Ar core
-.Oc
-.Sh DESCRIPTION
-The
-.Nm
-utility interrogates the buffer of
-.Tn TCP
-trace records created
-when a socket is marked for
-.Dq debugging
-(see
-.Xr setsockopt 2 ) ,
-and prints a readable description of these records.
-When no options are supplied,
-.Nm
-prints all the trace records found in the system
-grouped according to
-.Tn TCP
-connection protocol control
-block
-.Pq Tn PCB .
-.Pp
-The following options may be used to
-alter this behavior:
-.Bl -tag -width indent
-.It Fl a
-In addition to the normal output,
-print the values of the source and destination
-addresses for each packet recorded.
-.It Fl f
-Follow the trace as it occurs, waiting a short time for additional records
-each time the end of the log is reached.
-.It Fl j
-Just give a list of the protocol control block
-addresses for which there are trace records.
-.It Fl p
-Show only trace records associated with the protocol
-control block at the given address
-.Ar hex-address .
-.It Fl s
-In addition to the normal output,
-print a detailed description of the packet
-sequencing information.
-.El
-.Pp
-The recommended use of
-.Nm
-is as follows.
-Isolate the problem and enable debugging on the
-socket(s) involved in the connection.
-Find the address of the protocol control blocks
-associated with the sockets using the
-.Fl A
-option to
-.Xr netstat 1 .
-Then run
-.Nm
-with the
-.Fl p
-option, supplying the associated
-protocol control block addresses.
-The
-.Fl f
-option can be used to follow the trace log once the trace is located.
-If there are
-many sockets using the debugging option, the
-.Fl j
-option may be useful in checking to see if
-any trace records are present for the socket in
-question.
-.Pp
-If debugging is being performed on a system or
-core file other than the default, the last two
-arguments may be used to supplant the defaults.
-.Sh FILES
-.Bl -tag -width /boot/kernel/kernel -compact
-.It Pa /boot/kernel/kernel
-.It Pa /dev/kmem
-.El
-.Sh DIAGNOSTICS
-.Bl -diag
-.It no namelist
-When the system image does not
-contain the proper symbols to find the trace buffer;
-others which should be self explanatory.
-.El
-.Sh SEE ALSO
-.Xr netstat 1 ,
-.Xr setsockopt 2
-.Sh HISTORY
-The
-.Nm
-utility appeared in
-.Bx 4.2 .
-.Sh BUGS
-Should also print the data for each input or output,
-but this is not saved in the trace record.
-.Pp
-The output format is inscrutable and should be described
-here.
diff --git a/usr.sbin/trpt/trpt.c b/usr.sbin/trpt/trpt.c
deleted file mode 100644
index 59727cadaaba..000000000000
--- a/usr.sbin/trpt/trpt.c
+++ /dev/null
@@ -1,446 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1983, 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1983, 1988, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)trpt.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#define PRUREQUESTS
-#include <sys/protosw.h>
-#include <sys/file.h>
-#include <sys/time.h>
-
-#include <net/route.h>
-#include <net/if.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
-#include <netinet/ip_var.h>
-#include <netinet/tcp.h>
-#define TCPSTATES
-#include <netinet/tcp_fsm.h>
-#include <netinet/tcp_seq.h>
-#define TCPTIMERS
-#include <netinet/tcp_timer.h>
-#define _WANT_TCPCB
-#include <netinet/tcp_var.h>
-#include <netinet/tcpip.h>
-#define TANAMES
-#include <netinet/tcp_debug.h>
-
-#include <arpa/inet.h>
-
-#include <err.h>
-#include <nlist.h>
-#include <paths.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-static struct tcp_debug tcp_debug[TCP_NDEBUG];
-static int tcp_debx;
-
-static struct nlist nl[3];
-#define N_TCP_DEBUG 0
-#define N_TCP_DEBX 1
-
-static caddr_t tcp_pcbs[TCP_NDEBUG];
-static n_time ntime;
-static int aflag, kflag, memf, follow, sflag;
-
-static void dotrace(caddr_t);
-static void klseek(int, off_t, int);
-static int numeric(const void *, const void *);
-static void tcp_trace(short, short, struct tcpcb *, int, void *, struct tcphdr *, int);
-static void usage(void);
-
-int
-main(int argc, char **argv)
-{
- int ch, i, jflag, npcbs;
- const char *core, *syst;
-
- nl[0].n_name = strdup("_tcp_debug");
- nl[1].n_name = strdup("_tcp_debx");
-
- jflag = npcbs = 0;
- while ((ch = getopt(argc, argv, "afjp:s")) != -1)
- switch (ch) {
- case 'a':
- ++aflag;
- break;
- case 'f':
- ++follow;
- setlinebuf(stdout);
- break;
- case 'j':
- ++jflag;
- break;
- case 'p':
- if (npcbs >= TCP_NDEBUG)
- errx(1, "too many pcb's specified");
- (void)sscanf(optarg, "%x", (int *)&tcp_pcbs[npcbs++]);
- break;
- case 's':
- ++sflag;
- break;
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- core = _PATH_KMEM;
- if (argc > 0) {
- syst = *argv;
- argc--, argv++;
- if (argc > 0) {
- core = *argv;
- argc--, argv++;
- ++kflag;
- }
- /*
- * Discard setgid privileges if not the running kernel so that
- * bad guys can't print interesting stuff from kernel memory.
- */
- if (setgid(getgid()) != 0)
- err(1, "setgid");
- } else
- syst = getbootfile();
-
- if (nlist(syst, nl) < 0 || !nl[0].n_value)
- errx(1, "%s: no namelist", syst);
- if ((memf = open(core, O_RDONLY)) < 0)
- err(2, "%s", core);
- if (setgid(getgid()) != 0)
- err(1, "setgid");
- if (kflag)
- errx(1, "can't do core files yet");
- (void)klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET);
- if (read(memf, (char *)&tcp_debx, sizeof(tcp_debx)) !=
- sizeof(tcp_debx))
- err(3, "tcp_debx");
- (void)klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET);
- if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) !=
- sizeof(tcp_debug))
- err(3, "tcp_debug");
- /*
- * If no control blocks have been specified, figure
- * out how many distinct one we have and summarize
- * them in tcp_pcbs for sorting the trace records
- * below.
- */
- if (!npcbs) {
- for (i = 0; i < TCP_NDEBUG; i++) {
- struct tcp_debug *td = &tcp_debug[i];
- int j;
-
- if (td->td_tcb == 0)
- continue;
- for (j = 0; j < npcbs; j++)
- if (tcp_pcbs[j] == td->td_tcb)
- break;
- if (j >= npcbs)
- tcp_pcbs[npcbs++] = td->td_tcb;
- }
- if (!npcbs)
- exit(0);
- }
- qsort(tcp_pcbs, npcbs, sizeof(caddr_t), numeric);
- if (jflag) {
- for (i = 0;;) {
- printf("%p", (void *)tcp_pcbs[i]);
- if (++i == npcbs)
- break;
- fputs(", ", stdout);
- }
- putchar('\n');
- } else
- for (i = 0; i < npcbs; i++) {
- printf("\n%p:\n", tcp_pcbs[i]);
- dotrace(tcp_pcbs[i]);
- }
- exit(0);
-}
-
-static void
-usage(void)
-{
- (void)fprintf(stderr,
- "usage: trpt [-afjs] [-p hex-address] [system [core]]\n");
- exit(1);
-}
-
-static void
-dotrace(caddr_t tcpcb)
-{
- struct tcp_debug *td;
- int i;
- int prev_debx = tcp_debx, family;
-
-again:
- if (--tcp_debx < 0)
- tcp_debx = TCP_NDEBUG - 1;
- for (i = prev_debx % TCP_NDEBUG; i < TCP_NDEBUG; i++) {
- td = &tcp_debug[i];
- if (tcpcb && td->td_tcb != tcpcb)
- continue;
- ntime = ntohl(td->td_time);
-#ifdef INET6
- family = td->td_family;
-#else
- family = AF_INET;
-#endif
- switch (family) {
- case AF_INET:
- tcp_trace(td->td_act, td->td_ostate, &td->td_cb,
- td->td_family, &td->td_ti.ti_i, &td->td_ti.ti_t,
- td->td_req);
- break;
-#ifdef INET6
- case AF_INET6:
- tcp_trace(td->td_act, td->td_ostate, &td->td_cb,
- td->td_family, &td->td_ti6.ip6, &td->td_ti6.th,
- td->td_req);
- break;
-#endif
- }
- if (i == tcp_debx)
- goto done;
- }
- for (i = 0; i <= tcp_debx % TCP_NDEBUG; i++) {
- td = &tcp_debug[i];
- if (tcpcb && td->td_tcb != tcpcb)
- continue;
- ntime = ntohl(td->td_time);
-#ifdef INET6
- family = td->td_family;
-#else
- family = AF_INET;
-#endif
- switch (family) {
- case AF_INET:
- tcp_trace(td->td_act, td->td_ostate, &td->td_cb,
- td->td_family, &td->td_ti.ti_i, &td->td_ti.ti_t,
- td->td_req);
- break;
-#ifdef INET6
- case AF_INET6:
- tcp_trace(td->td_act, td->td_ostate, &td->td_cb,
- td->td_family, &td->td_ti6.ip6, &td->td_ti6.th,
- td->td_req);
- break;
-#endif
- }
- }
-done:
- if (follow) {
- prev_debx = tcp_debx + 1;
- if (prev_debx >= TCP_NDEBUG)
- prev_debx = 0;
- do {
- sleep(1);
- (void)klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET);
- if (read(memf, (char *)&tcp_debx, sizeof(tcp_debx)) !=
- sizeof(tcp_debx))
- err(3, "tcp_debx");
- } while (tcp_debx == prev_debx);
- (void)klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET);
- if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) !=
- sizeof(tcp_debug))
- err(3, "tcp_debug");
- goto again;
- }
-}
-
-/*
- * Tcp debug routines
- */
-/*ARGSUSED*/
-static void
-tcp_trace(short act, short ostate, struct tcpcb *tp, int family __unused,
- void *ip, struct tcphdr *th, int req)
-{
- tcp_seq seq, ack;
- int flags, len, win, timer;
- struct ip *ip4;
-#ifdef INET6
- bool isipv6, nopkt = true;
- struct ip6_hdr *ip6;
- char ntop_buf[INET6_ADDRSTRLEN];
-#endif
-
-#ifdef INET6
- /* Appease GCC -Wmaybe-uninitialized */
- ip4 = NULL;
- ip6 = NULL;
- isipv6 = false;
-
- switch (family) {
- case AF_INET:
- nopkt = false;
- isipv6 = false;
- ip4 = (struct ip *)ip;
- break;
- case AF_INET6:
- nopkt = false;
- isipv6 = true;
- ip6 = (struct ip6_hdr *)ip;
- case 0:
- default:
- break;
- }
-#else
- ip4 = (struct ip *)ip;
-#endif
- printf("%03ld %s:%s ", (long)((ntime / 10) % 1000), tcpstates[ostate],
- tanames[act]);
- switch (act) {
- case TA_INPUT:
- case TA_OUTPUT:
- case TA_DROP:
-#ifdef INET6
- if (nopkt)
- break;
-#endif
- if (aflag) {
- printf("(src=%s,%u, ",
-
-#ifdef INET6
- isipv6 ? inet_ntop(AF_INET6, &ip6->ip6_src,
- ntop_buf, sizeof(ntop_buf)) :
-#endif
- inet_ntoa(ip4->ip_src), ntohs(th->th_sport));
- printf("dst=%s,%u)",
-#ifdef INET6
- isipv6 ? inet_ntop(AF_INET6, &ip6->ip6_dst,
- ntop_buf, sizeof(ntop_buf)) :
-#endif
- inet_ntoa(ip4->ip_dst), ntohs(th->th_dport));
- }
- seq = th->th_seq;
- ack = th->th_ack;
-
- len =
-#ifdef INET6
- isipv6 ? ip6->ip6_plen :
-#endif
- ip4->ip_len;
- win = th->th_win;
- if (act == TA_OUTPUT) {
- seq = ntohl(seq);
- ack = ntohl(ack);
- len = ntohs(len);
- win = ntohs(win);
- }
- if (act == TA_OUTPUT)
- len -= sizeof(struct tcphdr);
- if (len)
- printf("[%lx..%lx)", (u_long)seq, (u_long)(seq + len));
- else
- printf("%lx", (u_long)seq);
- printf("@%lx", (u_long)ack);
- if (win)
- printf("(win=%x)", win);
- flags = th->th_flags;
- if (flags) {
- const char *cp = "<";
-#define pf(flag, string) { \
- if (th->th_flags&flag) { \
- (void)printf("%s%s", cp, string); \
- cp = ","; \
- } \
-}
- pf(TH_SYN, "SYN");
- pf(TH_ACK, "ACK");
- pf(TH_FIN, "FIN");
- pf(TH_RST, "RST");
- pf(TH_PUSH, "PUSH");
- pf(TH_URG, "URG");
- printf(">");
- }
- break;
- case TA_USER:
- timer = req >> 8;
- req &= 0xff;
- printf("%s", prurequests[req]);
- if (req == PRU_SLOWTIMO || req == PRU_FASTTIMO)
- printf("<%s>", tcptimers[timer]);
- break;
- }
- printf(" -> %s", tcpstates[tp->t_state]);
- /* print out internal state of tp !?! */
- printf("\n");
- if (sflag) {
- printf("\trcv_nxt %lx rcv_wnd %lx snd_una %lx snd_nxt %lx snd_max %lx\n",
- (u_long)tp->rcv_nxt, (u_long)tp->rcv_wnd,
- (u_long)tp->snd_una, (u_long)tp->snd_nxt,
- (u_long)tp->snd_max);
- printf("\tsnd_wl1 %lx snd_wl2 %lx snd_wnd %lx\n",
- (u_long)tp->snd_wl1, (u_long)tp->snd_wl2,
- (u_long)tp->snd_wnd);
- }
-}
-
-static int
-numeric(const void *v1, const void *v2)
-{
- const caddr_t *c1 = v1, *c2 = v2;
-
- return (*c1 - *c2);
-}
-
-static void
-klseek(int fd, off_t base, int off)
-{
- (void)lseek(fd, base, off);
-}
diff --git a/usr.sbin/tzsetup/Makefile b/usr.sbin/tzsetup/Makefile
index adef619b6596..2522fb06c22a 100644
--- a/usr.sbin/tzsetup/Makefile
+++ b/usr.sbin/tzsetup/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
@@ -13,4 +12,10 @@ CFLAGS+= -I${SRCTOP}/contrib/bsddialog/lib -DHAVE_BSDDIALOG
LIBADD= bsddialog
.endif
+ZONETAB= ${SRCTOP}/contrib/tzdata/zone1970.tab
+baseline: ${PROG} ${ZONETAB}
+ ${.OBJDIR}/${PROG} -d ${ZONETAB} > ${.CURDIR}/baseline
+
+.PHONY: baseline
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/tzsetup/Makefile.depend b/usr.sbin/tzsetup/Makefile.depend
index 5f1a802404d8..63fe0b5e1069 100644
--- a/usr.sbin/tzsetup/Makefile.depend
+++ b/usr.sbin/tzsetup/Makefile.depend
@@ -1,13 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
include \
include/xlocale \
lib/${CSU_DIR} \
+ lib/libbsddialog \
lib/libc \
lib/libcompiler_rt \
- lib/msun \
.include <dirdeps.mk>
diff --git a/usr.sbin/tzsetup/Makefile.depend.options b/usr.sbin/tzsetup/Makefile.depend.options
deleted file mode 100644
index 4425320ea3be..000000000000
--- a/usr.sbin/tzsetup/Makefile.depend.options
+++ /dev/null
@@ -1,10 +0,0 @@
-# $FreeBSD$
-# This file is not autogenerated - take care!
-
-DIRDEPS_OPTIONS= DIALOG
-
-DIRDEPS.DIALOG.yes= \
- gnu/lib/libdialog \
- lib/ncurses/ncursesw \
-
-.include <dirdeps-options.mk>
diff --git a/usr.sbin/tzsetup/baseline b/usr.sbin/tzsetup/baseline
new file mode 100644
index 000000000000..de9b5f638d09
--- /dev/null
+++ b/usr.sbin/tzsetup/baseline
@@ -0,0 +1,670 @@
+AF:Afghanistan
+ Asia:Asia/Kabul
+AL:Albania
+ Europe:Europe/Tirane
+DZ:Algeria
+ Africa:Africa/Algiers
+AS:American Samoa
+ Pacific:Pacific/Pago_Pago
+AD:Andorra
+ Europe:Europe/Andorra
+AO:Angola
+ Africa:Africa/Lagos
+AI:Anguilla
+ America:America/Puerto_Rico
+AQ:Antarctica
+ Antarctica:Antarctica/Casey
+ Antarctica:Antarctica/Davis
+ Antarctica:Antarctica/Mawson
+ Antarctica:Antarctica/Palmer
+ Antarctica:Antarctica/Rothera
+ Antarctica:Antarctica/Troll
+ Antarctica:Asia/Urumqi
+ Antarctica:Pacific/Auckland
+ Antarctica:Pacific/Port_Moresby
+ Antarctica:Asia/Riyadh
+AG:Antigua and Barbuda
+ America:America/Puerto_Rico
+AR:Argentina
+ America:America/Argentina/Buenos_Aires
+ America:America/Argentina/Cordoba
+ America:America/Argentina/Salta
+ America:America/Argentina/Jujuy
+ America:America/Argentina/Tucuman
+ America:America/Argentina/Catamarca
+ America:America/Argentina/La_Rioja
+ America:America/Argentina/San_Juan
+ America:America/Argentina/Mendoza
+ America:America/Argentina/San_Luis
+ America:America/Argentina/Rio_Gallegos
+ America:America/Argentina/Ushuaia
+AM:Armenia
+ Asia:Asia/Yerevan
+AW:Aruba
+ America:America/Puerto_Rico
+AU:Australia
+ Australia:Australia/Lord_Howe
+ Antarctica:Antarctica/Macquarie
+ Australia:Australia/Hobart
+ Australia:Australia/Melbourne
+ Australia:Australia/Sydney
+ Australia:Australia/Broken_Hill
+ Australia:Australia/Brisbane
+ Australia:Australia/Lindeman
+ Australia:Australia/Adelaide
+ Australia:Australia/Darwin
+ Australia:Australia/Perth
+ Australia:Australia/Eucla
+AT:Austria
+ Europe:Europe/Vienna
+AZ:Azerbaijan
+ Asia:Asia/Baku
+BS:Bahamas
+ America:America/Toronto
+BH:Bahrain
+ Asia:Asia/Qatar
+BD:Bangladesh
+ Asia:Asia/Dhaka
+BB:Barbados
+ America:America/Barbados
+BY:Belarus
+ Europe:Europe/Minsk
+BE:Belgium
+ Europe:Europe/Brussels
+BZ:Belize
+ America:America/Belize
+BJ:Benin
+ Africa:Africa/Lagos
+BM:Bermuda
+ Atlantic:Atlantic/Bermuda
+BT:Bhutan
+ Asia:Asia/Thimphu
+BO:Bolivia, Plurinational State of
+ America:America/La_Paz
+BQ:Bonaire, Sint Eustatius and Saba
+ America:America/Puerto_Rico
+BA:Bosnia and Herzegovina
+ Europe:Europe/Belgrade
+BW:Botswana
+ Africa:Africa/Maputo
+BV:Bouvet Island
+BR:Brazil
+ America:America/Noronha
+ America:America/Belem
+ America:America/Fortaleza
+ America:America/Recife
+ America:America/Araguaina
+ America:America/Maceio
+ America:America/Bahia
+ America:America/Sao_Paulo
+ America:America/Campo_Grande
+ America:America/Cuiaba
+ America:America/Santarem
+ America:America/Porto_Velho
+ America:America/Boa_Vista
+ America:America/Manaus
+ America:America/Eirunepe
+ America:America/Rio_Branco
+IO:British Indian Ocean Territory
+ Indian:Indian/Chagos
+BN:Brunei Darussalam
+ Asia:Asia/Kuching
+BG:Bulgaria
+ Europe:Europe/Sofia
+BF:Burkina Faso
+ Africa:Africa/Abidjan
+BI:Burundi
+ Africa:Africa/Maputo
+CV:Cabo Verde
+ Atlantic:Atlantic/Cape_Verde
+KH:Cambodia
+ Asia:Asia/Bangkok
+CM:Cameroon
+ Africa:Africa/Lagos
+CA:Canada
+ America:America/St_Johns
+ America:America/Halifax
+ America:America/Glace_Bay
+ America:America/Moncton
+ America:America/Goose_Bay
+ America:America/Toronto
+ America:America/Iqaluit
+ America:America/Winnipeg
+ America:America/Resolute
+ America:America/Rankin_Inlet
+ America:America/Regina
+ America:America/Swift_Current
+ America:America/Edmonton
+ America:America/Cambridge_Bay
+ America:America/Inuvik
+ America:America/Dawson_Creek
+ America:America/Fort_Nelson
+ America:America/Whitehorse
+ America:America/Dawson
+ America:America/Vancouver
+ America:America/Panama
+ America:America/Puerto_Rico
+ America:America/Phoenix
+KY:Cayman Islands
+ America:America/Panama
+CF:Central African Republic
+ Africa:Africa/Lagos
+TD:Chad
+ Africa:Africa/Ndjamena
+CL:Chile
+ America:America/Santiago
+ America:America/Punta_Arenas
+ Pacific:Pacific/Easter
+CN:China
+ Asia:Asia/Shanghai
+ Asia:Asia/Urumqi
+CX:Christmas Island
+ Indian:Asia/Bangkok
+CC:Cocos (Keeling) Islands
+ Indian:Asia/Yangon
+CO:Colombia
+ America:America/Bogota
+KM:Comoros
+ Indian:Africa/Nairobi
+CG:Congo
+ Africa:Africa/Lagos
+CD:Congo, Democratic Republic of the
+ Africa:Africa/Maputo
+ Africa:Africa/Lagos
+CK:Cook Islands
+ Pacific:Pacific/Rarotonga
+CR:Costa Rica
+ America:America/Costa_Rica
+HR:Croatia
+ Europe:Europe/Belgrade
+CU:Cuba
+ America:America/Havana
+CW:Curaçao
+ America:America/Puerto_Rico
+CY:Cyprus
+ Asia:Asia/Nicosia
+ Asia:Asia/Famagusta
+CZ:Czech Republic
+ Europe:Europe/Prague
+CI:Côte d'Ivoire
+ Africa:Africa/Abidjan
+DK:Denmark
+ Europe:Europe/Berlin
+DJ:Djibouti
+ Africa:Africa/Nairobi
+DM:Dominica
+ America:America/Puerto_Rico
+DO:Dominican Republic
+ America:America/Santo_Domingo
+EC:Ecuador
+ America:America/Guayaquil
+ Pacific:Pacific/Galapagos
+EG:Egypt
+ Africa:Africa/Cairo
+SV:El Salvador
+ America:America/El_Salvador
+GQ:Equatorial Guinea
+ Africa:Africa/Lagos
+ER:Eritrea
+ Africa:Africa/Nairobi
+EE:Estonia
+ Europe:Europe/Tallinn
+SZ:Eswatini
+ Africa:Africa/Johannesburg
+ET:Ethiopia
+ Africa:Africa/Nairobi
+FK:Falkland Islands (Malvinas)
+ Atlantic:Atlantic/Stanley
+FO:Faroe Islands
+ Atlantic:Atlantic/Faroe
+FJ:Fiji
+ Pacific:Pacific/Fiji
+FI:Finland
+ Europe:Europe/Helsinki
+FR:France
+ Europe:Europe/Paris
+GF:French Guiana
+ America:America/Cayenne
+PF:French Polynesia
+ Pacific:Pacific/Tahiti
+ Pacific:Pacific/Marquesas
+ Pacific:Pacific/Gambier
+TF:French Southern Territories
+ Asia:Asia/Dubai
+ Indian:Indian/Maldives
+GA:Gabon
+ Africa:Africa/Lagos
+GM:Gambia
+ Africa:Africa/Abidjan
+GE:Georgia
+ Asia:Asia/Tbilisi
+DE:Germany
+ Europe:Europe/Zurich
+ Europe:Europe/Berlin
+GH:Ghana
+ Africa:Africa/Abidjan
+GI:Gibraltar
+ Europe:Europe/Gibraltar
+GR:Greece
+ Europe:Europe/Athens
+GL:Greenland
+ America:America/Nuuk
+ America:America/Danmarkshavn
+ America:America/Scoresbysund
+ America:America/Thule
+GD:Grenada
+ America:America/Puerto_Rico
+GP:Guadeloupe
+ America:America/Puerto_Rico
+GU:Guam
+ Pacific:Pacific/Guam
+GT:Guatemala
+ America:America/Guatemala
+GG:Guernsey
+ Europe:Europe/London
+GN:Guinea
+ Africa:Africa/Abidjan
+GW:Guinea-Bissau
+ Africa:Africa/Bissau
+GY:Guyana
+ America:America/Guyana
+HT:Haiti
+ America:America/Port-au-Prince
+HM:Heard Island and McDonald Islands
+VA:Holy See
+ Europe:Europe/Rome
+HN:Honduras
+ America:America/Tegucigalpa
+HK:Hong Kong
+ Asia:Asia/Hong_Kong
+HU:Hungary
+ Europe:Europe/Budapest
+IS:Iceland
+ Atlantic:Africa/Abidjan
+IN:India
+ Asia:Asia/Kolkata
+ID:Indonesia
+ Asia:Asia/Jakarta
+ Asia:Asia/Pontianak
+ Asia:Asia/Makassar
+ Asia:Asia/Jayapura
+IR:Iran (Islamic Republic of)
+ Asia:Asia/Tehran
+IQ:Iraq
+ Asia:Asia/Baghdad
+IE:Ireland
+ Europe:Europe/Dublin
+IM:Isle of Man
+ Europe:Europe/London
+IL:Israel
+ Asia:Asia/Jerusalem
+IT:Italy
+ Europe:Europe/Rome
+JM:Jamaica
+ America:America/Jamaica
+JP:Japan
+ Asia:Asia/Tokyo
+JE:Jersey
+ Europe:Europe/London
+JO:Jordan
+ Asia:Asia/Amman
+KZ:Kazakhstan
+ Asia:Asia/Almaty
+ Asia:Asia/Qyzylorda
+ Asia:Asia/Qostanay
+ Asia:Asia/Aqtobe
+ Asia:Asia/Aqtau
+ Asia:Asia/Atyrau
+ Asia:Asia/Oral
+KE:Kenya
+ Africa:Africa/Nairobi
+KI:Kiribati
+ Pacific:Pacific/Tarawa
+ Pacific:Pacific/Kanton
+ Pacific:Pacific/Kiritimati
+KP:Korea (Democratic People's Republic of)
+ Asia:Asia/Pyongyang
+KR:Korea (Republic of)
+ Asia:Asia/Seoul
+KW:Kuwait
+ Asia:Asia/Riyadh
+KG:Kyrgyzstan
+ Asia:Asia/Bishkek
+LA:Lao People's Democratic Republic
+ Asia:Asia/Bangkok
+LV:Latvia
+ Europe:Europe/Riga
+LB:Lebanon
+ Asia:Asia/Beirut
+LS:Lesotho
+ Africa:Africa/Johannesburg
+LR:Liberia
+ Africa:Africa/Monrovia
+LY:Libya
+ Africa:Africa/Tripoli
+LI:Liechtenstein
+ Europe:Europe/Zurich
+LT:Lithuania
+ Europe:Europe/Vilnius
+LU:Luxembourg
+ Europe:Europe/Brussels
+MO:Macao
+ Asia:Asia/Macau
+MK:Macedonia (the former Yugoslav Republic of)
+ Europe:Europe/Belgrade
+MG:Madagascar
+ Indian:Africa/Nairobi
+MW:Malawi
+ Africa:Africa/Maputo
+MY:Malaysia
+ Asia:Asia/Kuching
+ Asia:Asia/Singapore
+MV:Maldives
+ Indian:Indian/Maldives
+ML:Mali
+ Africa:Africa/Abidjan
+MT:Malta
+ Europe:Europe/Malta
+MH:Marshall Islands
+ Pacific:Pacific/Tarawa
+ Pacific:Pacific/Kwajalein
+MQ:Martinique
+ America:America/Martinique
+MR:Mauritania
+ Africa:Africa/Abidjan
+MU:Mauritius
+ Indian:Indian/Mauritius
+YT:Mayotte
+ Indian:Africa/Nairobi
+MX:Mexico
+ America:America/Mexico_City
+ America:America/Cancun
+ America:America/Merida
+ America:America/Monterrey
+ America:America/Matamoros
+ America:America/Chihuahua
+ America:America/Ciudad_Juarez
+ America:America/Ojinaga
+ America:America/Mazatlan
+ America:America/Bahia_Banderas
+ America:America/Hermosillo
+ America:America/Tijuana
+FM:Micronesia (Federated States of)
+ Pacific:Pacific/Kosrae
+ Pacific:Pacific/Port_Moresby
+ Pacific:Pacific/Guadalcanal
+MD:Moldova (Republic of)
+ Europe:Europe/Chisinau
+MC:Monaco
+ Europe:Europe/Paris
+MN:Mongolia
+ Asia:Asia/Ulaanbaatar
+ Asia:Asia/Hovd
+ Asia:Asia/Choibalsan
+ME:Montenegro
+ Europe:Europe/Belgrade
+MS:Montserrat
+ America:America/Puerto_Rico
+MA:Morocco
+ Africa:Africa/Casablanca
+MZ:Mozambique
+ Africa:Africa/Maputo
+MM:Myanmar
+ Asia:Asia/Yangon
+NA:Namibia
+ Africa:Africa/Windhoek
+NR:Nauru
+ Pacific:Pacific/Nauru
+NP:Nepal
+ Asia:Asia/Kathmandu
+NL:Netherlands
+ Europe:Europe/Brussels
+NC:New Caledonia
+ Pacific:Pacific/Noumea
+NZ:New Zealand
+ Pacific:Pacific/Auckland
+ Pacific:Pacific/Chatham
+NI:Nicaragua
+ America:America/Managua
+NE:Niger
+ Africa:Africa/Lagos
+NG:Nigeria
+ Africa:Africa/Lagos
+NU:Niue
+ Pacific:Pacific/Niue
+NF:Norfolk Island
+ Pacific:Pacific/Norfolk
+MP:Northern Mariana Islands
+ Pacific:Pacific/Guam
+NO:Norway
+ Europe:Europe/Berlin
+OM:Oman
+ Asia:Asia/Dubai
+PK:Pakistan
+ Asia:Asia/Karachi
+PW:Palau
+ Pacific:Pacific/Palau
+PS:Palestine, State of
+ Asia:Asia/Gaza
+ Asia:Asia/Hebron
+PA:Panama
+ America:America/Panama
+PG:Papua New Guinea
+ Pacific:Pacific/Port_Moresby
+ Pacific:Pacific/Bougainville
+PY:Paraguay
+ America:America/Asuncion
+PE:Peru
+ America:America/Lima
+PH:Philippines
+ Asia:Asia/Manila
+PN:Pitcairn
+ Pacific:Pacific/Pitcairn
+PL:Poland
+ Europe:Europe/Warsaw
+PT:Portugal
+ Europe:Europe/Lisbon
+ Atlantic:Atlantic/Madeira
+ Atlantic:Atlantic/Azores
+PR:Puerto Rico
+ America:America/Puerto_Rico
+QA:Qatar
+ Asia:Asia/Qatar
+RO:Romania
+ Europe:Europe/Bucharest
+RU:Russian Federation
+ Europe:Europe/Kaliningrad
+ Europe:Europe/Moscow
+ Europe:Europe/Simferopol
+ Europe:Europe/Kirov
+ Europe:Europe/Volgograd
+ Europe:Europe/Astrakhan
+ Europe:Europe/Saratov
+ Europe:Europe/Ulyanovsk
+ Europe:Europe/Samara
+ Asia:Asia/Yekaterinburg
+ Asia:Asia/Omsk
+ Asia:Asia/Novosibirsk
+ Asia:Asia/Barnaul
+ Asia:Asia/Tomsk
+ Asia:Asia/Novokuznetsk
+ Asia:Asia/Krasnoyarsk
+ Asia:Asia/Irkutsk
+ Asia:Asia/Chita
+ Asia:Asia/Yakutsk
+ Asia:Asia/Khandyga
+ Asia:Asia/Vladivostok
+ Asia:Asia/Ust-Nera
+ Asia:Asia/Magadan
+ Asia:Asia/Sakhalin
+ Asia:Asia/Srednekolymsk
+ Asia:Asia/Kamchatka
+ Asia:Asia/Anadyr
+RW:Rwanda
+ Africa:Africa/Maputo
+RE:Réunion
+ Asia:Asia/Dubai
+BL:Saint Barthélemy
+ America:America/Puerto_Rico
+SH:Saint Helena Ascension and Tristan da Cunha
+ Atlantic:Africa/Abidjan
+KN:Saint Kitts and Nevis
+ America:America/Puerto_Rico
+LC:Saint Lucia
+ America:America/Puerto_Rico
+MF:Saint Martin (French part)
+ America:America/Puerto_Rico
+PM:Saint Pierre and Miquelon
+ America:America/Miquelon
+VC:Saint Vincent and the Grenadines
+ America:America/Puerto_Rico
+WS:Samoa
+ Pacific:Pacific/Apia
+SM:San Marino
+ Europe:Europe/Rome
+ST:Sao Tome and Principe
+ Africa:Africa/Sao_Tome
+SA:Saudi Arabia
+ Asia:Asia/Riyadh
+SN:Senegal
+ Africa:Africa/Abidjan
+RS:Serbia
+ Europe:Europe/Belgrade
+SC:Seychelles
+ Asia:Asia/Dubai
+SL:Sierra Leone
+ Africa:Africa/Abidjan
+SG:Singapore
+ Asia:Asia/Singapore
+SX:Sint Maarten (Dutch part)
+ America:America/Puerto_Rico
+SK:Slovakia
+ Europe:Europe/Prague
+SI:Slovenia
+ Europe:Europe/Belgrade
+SB:Solomon Islands
+ Pacific:Pacific/Guadalcanal
+SO:Somalia
+ Africa:Africa/Nairobi
+ZA:South Africa
+ Africa:Africa/Johannesburg
+GS:South Georgia and the South Sandwich Islands
+ Atlantic:Atlantic/South_Georgia
+SS:South Sudan
+ Africa:Africa/Juba
+ES:Spain
+ Europe:Europe/Madrid
+ Africa:Africa/Ceuta
+ Atlantic:Atlantic/Canary
+LK:Sri Lanka
+ Asia:Asia/Colombo
+SD:Sudan
+ Africa:Africa/Khartoum
+SR:Suriname
+ America:America/Paramaribo
+SJ:Svalbard and Jan Mayen
+ Arctic:Europe/Berlin
+SE:Sweden
+ Europe:Europe/Berlin
+CH:Switzerland
+ Europe:Europe/Zurich
+SY:Syrian Arab Republic
+ Asia:Asia/Damascus
+TW:Taiwan
+ Asia:Asia/Taipei
+TJ:Tajikistan
+ Asia:Asia/Dushanbe
+TZ:Tanzania United Republic of
+ Africa:Africa/Nairobi
+TH:Thailand
+ Asia:Asia/Bangkok
+TL:Timor-Leste
+ Asia:Asia/Dili
+TG:Togo
+ Africa:Africa/Abidjan
+TK:Tokelau
+ Pacific:Pacific/Fakaofo
+TO:Tonga
+ Pacific:Pacific/Tongatapu
+TT:Trinidad and Tobago
+ America:America/Puerto_Rico
+TN:Tunisia
+ Africa:Africa/Tunis
+TR:Turkey
+ Europe:Europe/Istanbul
+TM:Turkmenistan
+ Asia:Asia/Ashgabat
+TC:Turks and Caicos Islands
+ America:America/Grand_Turk
+TV:Tuvalu
+ Pacific:Pacific/Tarawa
+UG:Uganda
+ Africa:Africa/Nairobi
+UA:Ukraine
+ Europe:Europe/Simferopol
+ Europe:Europe/Kyiv
+AE:United Arab Emirates
+ Asia:Asia/Dubai
+GB:United Kingdom of Great Britain and Northern Ireland
+ Europe:Europe/London
+UM:United States Minor Outlying Islands
+ Pacific:Pacific/Pago_Pago
+ Pacific:Pacific/Tarawa
+US:United States of America
+ America:America/New_York
+ America:America/Detroit
+ America:America/Kentucky/Louisville
+ America:America/Kentucky/Monticello
+ America:America/Indiana/Indianapolis
+ America:America/Indiana/Vincennes
+ America:America/Indiana/Winamac
+ America:America/Indiana/Marengo
+ America:America/Indiana/Petersburg
+ America:America/Indiana/Vevay
+ America:America/Chicago
+ America:America/Indiana/Tell_City
+ America:America/Indiana/Knox
+ America:America/Menominee
+ America:America/North_Dakota/Center
+ America:America/North_Dakota/New_Salem
+ America:America/North_Dakota/Beulah
+ America:America/Denver
+ America:America/Boise
+ America:America/Phoenix
+ America:America/Los_Angeles
+ America:America/Anchorage
+ America:America/Juneau
+ America:America/Sitka
+ America:America/Metlakatla
+ America:America/Yakutat
+ America:America/Nome
+ America:America/Adak
+ Pacific:Pacific/Honolulu
+UY:Uruguay
+ America:America/Montevideo
+UZ:Uzbekistan
+ Asia:Asia/Samarkand
+ Asia:Asia/Tashkent
+VU:Vanuatu
+ Pacific:Pacific/Efate
+VE:Venezuela, Bolivarian Republic of
+ America:America/Caracas
+VN:Viet Nam
+ Asia:Asia/Bangkok
+ Asia:Asia/Ho_Chi_Minh
+VG:Virgin Islands (British)
+ America:America/Puerto_Rico
+VI:Virgin Islands (U.S.)
+ America:America/Puerto_Rico
+WF:Wallis and Futuna
+ Pacific:Pacific/Tarawa
+EH:Western Sahara
+ Africa:Africa/El_Aaiun
+YE:Yemen
+ Asia:Asia/Riyadh
+ZM:Zambia
+ Africa:Africa/Maputo
+ZW:Zimbabwe
+ Africa:Africa/Maputo
+AX:Ã…land Islands
+ Europe:Europe/Helsinki
diff --git a/usr.sbin/tzsetup/tzsetup.8 b/usr.sbin/tzsetup/tzsetup.8
index 6ac5749e0aa4..60461363da9a 100644
--- a/usr.sbin/tzsetup/tzsetup.8
+++ b/usr.sbin/tzsetup/tzsetup.8
@@ -22,9 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
-.Dd October 21, 2009
+.Dd April 18, 2023
.Dt TZSETUP 8
.Os
.Sh NAME
@@ -46,8 +44,7 @@ default zone.
The
.Nm
utility also determines whether any adjustment is necessary for systems where
-the hardware clock does not keep
-.Tn UTC .
+the hardware clock does not keep UTC.
.Pp
The following options are available:
.Bl -tag -offset indent -width Fl
@@ -55,14 +52,13 @@ The following options are available:
Open all files and directories relative to
.Ar chroot_directory .
.It Fl n
-Do not create or copy files.
+Do not create or symlink files.
.It Fl r
Reinstall the zoneinfo file installed last time.
The name is obtained from
.Pa /var/db/zoneinfo .
.It Fl s
-Skip the initial question about adjusting the clock if not set to
-.Tn UTC .
+Skip the initial question about adjusting the clock if not set to UTC.
.El
.Pp
It is possible to short-circuit the menu system by specifying the
@@ -74,13 +70,9 @@ on the command line; this is intended mainly for pre-configured installation
scripts or people who know which zoneinfo they want to install.
.Sh TIMEZONE DATABASE
The contents of the timezone database are indexed by
-.Pa /usr/share/zoneinfo/zone.tab .
-This file lists, for each timezone data file, the
-.Tn ISO
-3166 territory code, approximate geographical coordinates
-(in
-.Tn ISO
-6709 format),
+.Pa /usr/share/zoneinfo/zone1970.tab .
+This file lists, for each timezone data file, the ISO 3166 territory code,
+approximate geographical coordinates (in ISO 6709 format),
and location within the territory.
.Pp
The maintainers of the database maintain the following policies:
@@ -91,31 +83,29 @@ At least one zone for every country or inhabited geographical territory.
One zone for every distinct, documented timezone history since the
beginning of the
.Ux
-epoch (January 1, 1970,
-.Tn GMT ) .
+epoch (January 1, 1970, GMT).
.It
Each zone is named for the most populous city therein.
(Where possible,
the database includes pre-1970 history for its city.)
.El
+.Pp
The source code to the database
-.Pq Pa /usr/src/share/zoneinfo/[a-z]*
+.Pq Pa /usr/src/contrib/tzdata/[a-z]*
contains many additional comments and documentation references for the
historically minded.
.Sh FILES
-.Bl -tag -width ".Pa /usr/share/zoneinfo/zone.tab" -compact
+.Bl -tag -width ".Pa /usr/share/zoneinfo/zone1970.tab" -compact
.It Pa /etc/localtime
current time zone file
.It Pa /etc/wall_cmos_clock
see
.Xr adjkerntz 8
.It Pa /usr/share/misc/iso3166
-mapping of
-.Tn ISO
-3166 territory codes to names
+mapping of ISO 3166 territory codes to names
.It Pa /usr/share/zoneinfo
directory for zoneinfo files
-.It Pa /usr/share/zoneinfo/zone.tab
+.It Pa /usr/share/zoneinfo/zone1970.tab
mapping of timezone file to country and location
.It Pa /var/db/zoneinfo
saved name of the timezone file installed last
@@ -123,21 +113,24 @@ saved name of the timezone file installed last
.Sh EXAMPLES
Normal usage, to select the right zoneinfo file via the dialog-based
user interface:
-.Dl tzsetup
+.Pp
+.Dl # tzsetup
.Pp
Install the file
.Pa /usr/share/zoneinfo/Australia/Sydney :
-.Dl "tzsetup /usr/share/zoneinfo/Australia/Sydney"
.Pp
-Install the zoneinfo file for Australia/Sydney, assumed to be located
-in
+.Dl "# tzsetup /usr/share/zoneinfo/Australia/Sydney"
+.Pp
+Install the zoneinfo file for Australia/Sydney, assumed to be located in
.Pa /usr/share/zoneinfo :
-.Dl "tzsetup Australia/Sydney"
+.Pp
+.Dl "# tzsetup Australia/Sydney"
.Pp
After a reinstall of the zoneinfo files, you can reinstall the
latest installed zoneinfo file (as specified in
.Pa /var/db/zoneinfo ) :
-.Dl "tzsetup -r"
+.Pp
+.Dl "# tzsetup -r"
.Sh SEE ALSO
.Xr date 1 ,
.Xr adjtime 2 ,
@@ -159,8 +152,7 @@ Programs which are already running when
creates or updates
.Pa /etc/localtime
will not reflect the updated timezone.
-When the system is first configured for a
-.Pf non- Tn UTC
+When the system is first configured for a non-UTC
hardware clock, it is necessary to run
.Xr adjkerntz 8
(which normally happens as a part of system startup) in order to update
diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c
index 310414e69975..9610023ec3ea 100644
--- a/usr.sbin/tzsetup/tzsetup.c
+++ b/usr.sbin/tzsetup/tzsetup.c
@@ -32,9 +32,12 @@
* files provided in newer tzdata releases.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+/*
+ * When making changes to parser code, run baseline target, check that there are
+ * no unintended changes and commit updated file.
+ */
+#include <sys/cdefs.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
@@ -62,7 +65,7 @@ __FBSDID("$FreeBSD$");
#define _PATH_WALL_CMOS_CLOCK "/etc/wall_cmos_clock"
#ifdef PATH_MAX
-#define SILLY_BUFFER_SIZE 2*PATH_MAX
+#define SILLY_BUFFER_SIZE (2 * PATH_MAX)
#else
#warning "Somebody needs to fix this to dynamically size this buffer."
#define SILLY_BUFFER_SIZE 2048
@@ -152,8 +155,7 @@ static int usedialog = 1;
static int confirm_zone(const char *filename);
static int continent_country_menu(dialogMenuItem *);
-static int set_zone_multi(dialogMenuItem *);
-static int set_zone_whole_country(dialogMenuItem *);
+static int set_zone(dialogMenuItem *);
static int set_zone_menu(dialogMenuItem *);
static int set_zone_utc(void);
@@ -162,46 +164,48 @@ struct continent {
int nitems;
};
-static struct continent africa, america, antarctica, asia, atlantic;
+static struct continent africa, america, antarctica, arctic, asia, atlantic;
static struct continent australia, europe, indian, pacific, utc;
static struct continent_names {
const char *name;
struct continent *continent;
} continent_names[] = {
+ { "UTC", &utc },
{ "Africa", &africa },
{ "America", &america },
{ "Antarctica", &antarctica },
+ { "Arctic", &arctic },
{ "Asia", &asia },
{ "Atlantic", &atlantic },
{ "Australia", &australia },
{ "Europe", &europe },
{ "Indian", &indian },
{ "Pacific", &pacific },
- { "UTC", &utc }
};
static struct continent_items {
- char prompt[2];
+ char prompt[3];
char title[30];
} continent_items[] = {
+ { "0", "UTC" },
{ "1", "Africa" },
{ "2", "America -- North and South" },
{ "3", "Antarctica" },
- { "4", "Asia" },
- { "5", "Atlantic Ocean" },
- { "6", "Australia" },
- { "7", "Europe" },
- { "8", "Indian Ocean" },
- { "9", "Pacific Ocean" },
- { "0", "UTC" }
+ { "4", "Arctic Ocean" },
+ { "5", "Asia" },
+ { "6", "Atlantic Ocean" },
+ { "7", "Australia" },
+ { "8", "Europe" },
+ { "9", "Indian Ocean" },
+ { "10", "Pacific Ocean" },
};
#define NCONTINENTS \
(int)((sizeof(continent_items)) / (sizeof(continent_items[0])))
static dialogMenuItem continents[NCONTINENTS];
-#define OCEANP(x) ((x) == 4 || (x) == 7 || (x) == 8)
+#define OCEANP(x) ((x) == 4 || (x) == 6 || (x) == 9 || (x) == 10)
static int
continent_country_menu(dialogMenuItem *continent)
@@ -214,10 +218,6 @@ continent_country_menu(dialogMenuItem *continent)
if (strcmp(continent->title, "UTC") == 0)
return (set_zone_utc());
- /* Short cut -- if there's only one country, don't post a menu. */
- if (contp->nitems == 1)
- return (contp->menu[0].fire(&contp->menu[0]));
-
/* It's amazing how much good grammar really matters... */
if (!isocean) {
snprintf(title, sizeof(title), "Countries in %s",
@@ -234,24 +234,51 @@ continent_country_menu(dialogMenuItem *continent)
}
static struct continent *
-find_continent(const char *name)
+find_continent(int lineno, const char *name)
{
+ char *cname, *cp;
int i;
+ /*
+ * Both normal (the ones in zone filename, e.g. Europe/Andorra) and
+ * override (e.g. Atlantic/) entries should contain '/'.
+ */
+ cp = strdup(name);
+ if (cp == NULL)
+ err(1, "strdup");
+ cname = strsep(&cp, "/");
+ if (cp == NULL)
+ errx(1, "%s:%d: invalid entry `%s'", path_zonetab, lineno,
+ cname);
+
for (i = 0; i < NCONTINENTS; i++)
- if (strcmp(name, continent_names[i].name) == 0)
+ if (strcmp(cname, continent_names[i].name) == 0) {
+ free(cname);
return (continent_names[i].continent);
- return (0);
+ }
+
+ errx(1, "%s:%d: continent `%s' unknown", path_zonetab, lineno, cname);
+}
+
+static const char *
+find_continent_name(struct continent *cont)
+{
+ int i;
+
+ for (i = 0; i < NCONTINENTS; i++)
+ if (cont == continent_names[i].continent)
+ return (continent_names[i].name);
+ return ("Unknown");
}
struct country {
char *name;
char *tlc;
int nzones;
- char *filename; /* use iff nzones < 0 */
- struct continent *continent; /* use iff nzones < 0 */
- TAILQ_HEAD(, zone) zones; /* use iff nzones > 0 */
- dialogMenuItem *submenu; /* use iff nzones > 0 */
+ struct continent *override; /* continent override */
+ struct continent *alternate; /* extra continent */
+ TAILQ_HEAD(, zone) zones;
+ dialogMenuItem *submenu;
};
struct zone {
@@ -330,56 +357,62 @@ read_iso3166_table(void)
fclose(fp);
}
-static void
-add_zone_to_country(int lineno, const char *tlc, const char *descr,
- const char *file, struct continent *cont)
+static struct country *
+find_country(int lineno, const char *tlc)
{
- struct zone *zp;
struct country *cp;
- if (tlc[0] < 'A' || tlc[0] > 'Z' || tlc[1] < 'A' || tlc[1] > 'Z')
+ if (strlen(tlc) != 2 ||
+ tlc[0] < 'A' || tlc[0] > 'Z' || tlc[1] < 'A' || tlc[1] > 'Z')
errx(1, "%s:%d: country code `%s' invalid", path_zonetab,
lineno, tlc);
cp = &countries[CODE2INT(tlc)];
- if (cp->name == 0)
+ if (cp->name == NULL)
errx(1, "%s:%d: country code `%s' unknown", path_zonetab,
lineno, tlc);
- if (descr) {
- if (cp->nzones < 0)
- errx(1, "%s:%d: conflicting zone definition",
- path_zonetab, lineno);
+ return (cp);
+}
- zp = malloc(sizeof(*zp));
- if (zp == NULL)
- errx(1, "malloc(%zu)", sizeof(*zp));
+static void
+add_cont_to_country(struct country *cp, struct continent *cont)
+{
+ struct zone *zp;
- if (cp->nzones == 0)
- TAILQ_INIT(&cp->zones);
+ TAILQ_FOREACH(zp, &cp->zones, link) {
+ if (zp->continent == cont)
+ return;
+ }
+ cp->alternate = cont;
+}
+static void
+add_zone_to_country(int lineno, struct country *cp, const char *descr,
+ const char *file, struct continent *cont)
+{
+ struct zone *zp;
+
+ zp = malloc(sizeof(*zp));
+ if (zp == NULL)
+ errx(1, "malloc(%zu)", sizeof(*zp));
+
+ if (cp->nzones == 0)
+ TAILQ_INIT(&cp->zones);
+
+ if (descr != NULL) {
zp->descr = strdup(descr);
if (zp->descr == NULL)
errx(1, "malloc failed");
- zp->filename = strdup(file);
- if (zp->filename == NULL)
- errx(1, "malloc failed");
- zp->continent = cont;
- TAILQ_INSERT_TAIL(&cp->zones, zp, link);
- cp->nzones++;
} else {
- if (cp->nzones > 0)
- errx(1, "%s:%d: zone must have description",
- path_zonetab, lineno);
- if (cp->nzones < 0)
- errx(1, "%s:%d: zone multiply defined",
- path_zonetab, lineno);
- cp->nzones = -1;
- cp->filename = strdup(file);
- if (cp->filename == NULL)
- errx(1, "malloc failed");
- cp->continent = cont;
+ zp->descr = NULL;
}
+ zp->filename = strdup(file);
+ if (zp->filename == NULL)
+ errx(1, "malloc failed");
+ zp->continent = cp->override != NULL ? cp->override : cont;
+ TAILQ_INSERT_TAIL(&cp->zones, zp, link);
+ cp->nzones++;
}
/*
@@ -416,58 +449,125 @@ sort_countries(void)
static void
read_zones(void)
{
- char contbuf[16];
FILE *fp;
struct continent *cont;
- size_t len, contlen;
- char *line, *country_list, *tlc, *file, *descr, *p;
+ struct country *cp;
+ size_t len;
+ char *line, *country_list, *tlc, *file, *descr;
+ char *p, *q;
int lineno;
+ int pass = 1;
fp = fopen(path_zonetab, "r");
if (!fp)
err(1, "%s", path_zonetab);
- lineno = 0;
+again:
+ lineno = 0;
while ((line = fgetln(fp, &len)) != NULL) {
lineno++;
if (line[len - 1] != '\n')
errx(1, "%s:%d: invalid format", path_zonetab, lineno);
line[len - 1] = '\0';
- if (line[0] == '#')
- continue;
- country_list = strsep(&line, "\t");
- /* coord = */ strsep(&line, "\t"); /* Unused */
- file = strsep(&line, "\t");
- /* get continent portion from continent/country */
- p = strchr(file, '/');
- if (p == NULL)
- errx(1, "%s:%d: invalid zone name `%s'", path_zonetab,
- lineno, file);
- contlen = p - file + 1; /* trailing nul */
- if (contlen > sizeof(contbuf))
- errx(1, "%s:%d: continent name in zone name `%s' too long",
- path_zonetab, lineno, file);
- strlcpy(contbuf, file, contlen);
- cont = find_continent(contbuf);
- if (!cont)
- errx(1, "%s:%d: invalid region `%s'", path_zonetab,
- lineno, contbuf);
-
- descr = (line != NULL && *line != '\0') ? line : NULL;
-
- while (country_list != NULL) {
- tlc = strsep(&country_list, ",");
- if (strlen(tlc) != 2)
- errx(1, "%s:%d: invalid country code `%s'",
- path_zonetab, lineno, tlc);
- add_zone_to_country(lineno, tlc, descr, file, cont);
+ switch (pass)
+ {
+ case 1:
+ /*
+ * First pass: collect overrides, only looking for
+ * single continent ones for the moment.
+ *
+ * zone1970.tab introduced continent overrides in the
+ * following format:
+ *
+ * #@TLC[,TLC...]<tab>CONTINENT/[,CONTINENT/...]
+ */
+ if (strncmp(line, "#@", strlen("#@")) != 0)
+ continue;
+ line += 2;
+ country_list = strsep(&line, "\t");
+ /* Skip multi-continent overrides */
+ if (strchr(line, ',') != NULL)
+ continue;
+ cont = find_continent(lineno, line);
+ /* Parse and store overrides */
+ while (country_list != NULL) {
+ tlc = strsep(&country_list, ",");
+ cp = find_country(lineno, tlc);
+ cp->override = cont;
+ }
+ break;
+ case 2:
+ /* Second pass: parse actual data */
+ if (line[0] == '#')
+ continue;
+
+ country_list = strsep(&line, "\t");
+ /* coord = */ strsep(&line, "\t"); /* Unused */
+ file = strsep(&line, "\t");
+ cont = find_continent(lineno, file);
+ descr = (line != NULL && *line != '\0') ? line : NULL;
+
+ while (country_list != NULL) {
+ tlc = strsep(&country_list, ",");
+ cp = find_country(lineno, tlc);
+ add_zone_to_country(lineno, cp, descr, file,
+ cont);
+ }
+ break;
+ case 3:
+ /* Third pass: collect multi-continent overrides */
+ if (strncmp(line, "#@", strlen("#@")) != 0)
+ continue;
+ line += 2;
+ country_list = strsep(&line, "\t");
+ /* Skip single-continent overrides */
+ if (strchr(line, ',') == NULL)
+ continue;
+ while (line != NULL) {
+ cont = find_continent(lineno, line);
+ p = q = strdup(country_list);
+ if (p == NULL)
+ errx(1, "malloc failed");
+ while (q != NULL) {
+ tlc = strsep(&q, ",");
+ cp = find_country(lineno, tlc);
+ add_cont_to_country(cp, cont);
+ }
+ free(p);
+ strsep(&line, ",");
+ }
+ break;
}
}
+
+ if (pass++ < 3) {
+ errno = 0;
+ rewind(fp);
+ if (errno != 0)
+ err(1, "failed to rewind %s", path_zonetab);
+ goto again;
+ }
fclose(fp);
}
static void
+dump_zonetab(void)
+{
+ struct country *cp;
+ struct zone *zp;
+ const char *cont;
+
+ for (cp = countries; cp->name != NULL; cp++) {
+ printf("%s:%s\n", cp->tlc, cp->name);
+ TAILQ_FOREACH(zp, &cp->zones, link) {
+ cont = find_continent_name(zp->continent);
+ printf(" %s:%s\n", cont, zp->filename);
+ }
+ }
+}
+
+static void
make_menus(void)
{
struct country *cp;
@@ -485,17 +585,19 @@ make_menus(void)
for (cp = countries; cp->name; cp++) {
if (cp->nzones == 0)
continue;
- if (cp->nzones < 0) {
- cp->continent->nitems++;
- } else {
- TAILQ_FOREACH(zp, &cp->zones, link) {
- cont = zp->continent;
- for (zp2 = TAILQ_FIRST(&cp->zones);
- zp2->continent != cont;
- zp2 = TAILQ_NEXT(zp2, link))
- ;
- if (zp2 == zp)
- zp->continent->nitems++;
+ TAILQ_FOREACH(zp, &cp->zones, link) {
+ cont = zp->continent;
+ for (zp2 = TAILQ_FIRST(&cp->zones);
+ zp2->continent != cont;
+ zp2 = TAILQ_NEXT(zp2, link))
+ ;
+ if (zp2 == zp)
+ zp->continent->nitems++;
+ }
+
+ for (i = 0; i < NCONTINENTS; i++) {
+ if (cp->alternate == continent_names[i].continent) {
+ continent_names[i].continent->nitems++;
}
}
}
@@ -527,41 +629,42 @@ make_menus(void)
for (cp = countries; cp->name; cp++) {
if (cp->nzones == 0)
continue;
- if (cp->nzones < 0) {
- dmi = &cp->continent->menu[cp->continent->nitems];
+ cp->submenu = malloc(cp->nzones * sizeof(*dmi));
+ if (cp->submenu == 0)
+ errx(1, "malloc for submenu");
+ cp->nzones = 0;
+ TAILQ_FOREACH(zp, &cp->zones, link) {
+ cont = zp->continent;
+ dmi = &cp->submenu[cp->nzones];
memset(dmi, 0, sizeof(*dmi));
- asprintf(&dmi->prompt, "%d", ++cp->continent->nitems);
+ asprintf(&dmi->prompt, "%d", ++cp->nzones);
+ dmi->title = zp->descr;
+ dmi->fire = set_zone;
+ dmi->data = zp;
+
+ for (zp2 = TAILQ_FIRST(&cp->zones);
+ zp2->continent != cont;
+ zp2 = TAILQ_NEXT(zp2, link))
+ ;
+ if (zp2 != zp)
+ continue;
+
+ dmi = &cont->menu[cont->nitems];
+ memset(dmi, 0, sizeof(*dmi));
+ asprintf(&dmi->prompt, "%d", ++cont->nitems);
dmi->title = cp->name;
- dmi->fire = set_zone_whole_country;
+ dmi->fire = set_zone_menu;
+ dmi->data = cp;
+ }
+
+ if (cp->alternate != NULL) {
+ cont = cp->alternate;
+ dmi = &cont->menu[cont->nitems];
+ memset(dmi, 0, sizeof(*dmi));
+ asprintf(&dmi->prompt, "%d", ++cont->nitems);
+ dmi->title = cp->name;
+ dmi->fire = set_zone_menu;
dmi->data = cp;
- } else {
- cp->submenu = malloc(cp->nzones * sizeof(*dmi));
- if (cp->submenu == 0)
- errx(1, "malloc for submenu");
- cp->nzones = 0;
- TAILQ_FOREACH(zp, &cp->zones, link) {
- cont = zp->continent;
- dmi = &cp->submenu[cp->nzones];
- memset(dmi, 0, sizeof(*dmi));
- asprintf(&dmi->prompt, "%d", ++cp->nzones);
- dmi->title = zp->descr;
- dmi->fire = set_zone_multi;
- dmi->data = zp;
-
- for (zp2 = TAILQ_FIRST(&cp->zones);
- zp2->continent != cont;
- zp2 = TAILQ_NEXT(zp2, link))
- ;
- if (zp2 != zp)
- continue;
-
- dmi = &cont->menu[cont->nitems];
- memset(dmi, 0, sizeof(*dmi));
- asprintf(&dmi->prompt, "%d", ++cont->nitems);
- dmi->title = cp->name;
- dmi->fire = set_zone_menu;
- dmi->data = cp;
- }
}
}
}
@@ -573,6 +676,10 @@ set_zone_menu(dialogMenuItem *dmi)
struct country *cp = dmi->data;
int rv;
+ /* Short cut -- if there's only one zone, don't post a menu. */
+ if (cp->nzones == 1)
+ return (cp->submenu[0].fire(&cp->submenu[0]));
+
snprintf(title, sizeof(title), "%s Time Zones", cp->name);
snprintf(prompt, sizeof(prompt),
"Select a zone which observes the same time as your locality.");
@@ -609,7 +716,7 @@ confirm_zone(const char *filename)
}
static int
-set_zone_multi(dialogMenuItem *dmi)
+set_zone(dialogMenuItem *dmi)
{
struct zone *zp = dmi->data;
int rv;
@@ -621,19 +728,6 @@ set_zone_multi(dialogMenuItem *dmi)
return (rv);
}
-static int
-set_zone_whole_country(dialogMenuItem *dmi)
-{
- struct country *cp = dmi->data;
- int rv;
-
- if (!confirm_zone(cp->filename))
- return (DITEM_FAILURE | DITEM_RECREATE);
-
- rv = install_zoneinfo(cp->filename);
- return (rv);
-}
-
#endif
static void message_zoneinfo_file(const char *title, char *prompt)
@@ -650,109 +744,42 @@ static void message_zoneinfo_file(const char *title, char *prompt)
static int
install_zoneinfo_file(const char *zoneinfo_file)
{
- char buf[1024];
char prompt[SILLY_BUFFER_SIZE];
- struct stat sb;
- ssize_t len;
- int fd1, fd2, copymode;
-
- if (lstat(path_localtime, &sb) < 0) {
- /* Nothing there yet... */
- copymode = 1;
- } else if (S_ISLNK(sb.st_mode))
- copymode = 0;
- else
- copymode = 1;
#ifdef VERBOSE
- if (copymode)
- snprintf(prompt, sizeof(prompt),
- "Copying %s to %s", zoneinfo_file, path_localtime);
- else
- snprintf(prompt, sizeof(prompt),
- "Creating symbolic link %s to %s",
- path_localtime, zoneinfo_file);
- message_zoneinfo_file("Info", prompt);
+ snprintf(prompt, sizeof(prompt), "Creating symbolic link %s to %s",
+ path_localtime, zoneinfo_file);
+ message_zoneinfo_file("Info", prompt);
#endif
if (reallydoit) {
- if (copymode) {
- fd1 = open(zoneinfo_file, O_RDONLY, 0);
- if (fd1 < 0) {
- snprintf(prompt, sizeof(prompt),
- "Could not open %s: %s", zoneinfo_file,
- strerror(errno));
- message_zoneinfo_file("Error", prompt);
- return (DITEM_FAILURE | DITEM_RECREATE);
- }
-
- if (unlink(path_localtime) < 0 && errno != ENOENT) {
- snprintf(prompt, sizeof(prompt),
- "Could not delete %s: %s",
- path_localtime, strerror(errno));
- message_zoneinfo_file("Error", prompt);
- return (DITEM_FAILURE | DITEM_RECREATE);
- }
-
- fd2 = open(path_localtime, O_CREAT | O_EXCL | O_WRONLY,
- S_IRUSR | S_IRGRP | S_IROTH);
- if (fd2 < 0) {
- snprintf(prompt, sizeof(prompt),
- "Could not open %s: %s",
- path_localtime, strerror(errno));
- message_zoneinfo_file("Error", prompt);
- return (DITEM_FAILURE | DITEM_RECREATE);
- }
-
- while ((len = read(fd1, buf, sizeof(buf))) > 0)
- if ((len = write(fd2, buf, len)) < 0)
- break;
-
- if (len == -1) {
- snprintf(prompt, sizeof(prompt),
- "Error copying %s to %s %s", zoneinfo_file,
- path_localtime, strerror(errno));
- message_zoneinfo_file("Error", prompt);
- /* Better to leave none than a corrupt one. */
- unlink(path_localtime);
- return (DITEM_FAILURE | DITEM_RECREATE);
- }
- close(fd1);
- close(fd2);
- } else {
- if (access(zoneinfo_file, R_OK) != 0) {
- snprintf(prompt, sizeof(prompt),
- "Cannot access %s: %s", zoneinfo_file,
- strerror(errno));
- message_zoneinfo_file("Error", prompt);
- return (DITEM_FAILURE | DITEM_RECREATE);
- }
- if (unlink(path_localtime) < 0 && errno != ENOENT) {
- snprintf(prompt, sizeof(prompt),
- "Could not delete %s: %s",
- path_localtime, strerror(errno));
- message_zoneinfo_file("Error", prompt);
- return (DITEM_FAILURE | DITEM_RECREATE);
- }
- if (symlink(zoneinfo_file, path_localtime) < 0) {
- snprintf(prompt, sizeof(prompt),
- "Cannot create symbolic link %s to %s: %s",
- path_localtime, zoneinfo_file,
- strerror(errno));
- message_zoneinfo_file("Error", prompt);
- return (DITEM_FAILURE | DITEM_RECREATE);
- }
+ if (access(zoneinfo_file, R_OK) != 0) {
+ snprintf(prompt, sizeof(prompt),
+ "Cannot access %s: %s", zoneinfo_file,
+ strerror(errno));
+ message_zoneinfo_file("Error", prompt);
+ return (DITEM_FAILURE | DITEM_RECREATE);
}
-
-#ifdef VERBOSE
- if (copymode)
+ if (unlink(path_localtime) < 0 && errno != ENOENT) {
snprintf(prompt, sizeof(prompt),
- "Copied timezone file from %s to %s",
- zoneinfo_file, path_localtime);
- else
+ "Could not delete %s: %s",
+ path_localtime, strerror(errno));
+ message_zoneinfo_file("Error", prompt);
+ return (DITEM_FAILURE | DITEM_RECREATE);
+ }
+ if (symlink(zoneinfo_file, path_localtime) < 0) {
snprintf(prompt, sizeof(prompt),
- "Created symbolic link from %s to %s",
- zoneinfo_file, path_localtime);
+ "Cannot create symbolic link %s to %s: %s",
+ path_localtime, zoneinfo_file,
+ strerror(errno));
+ message_zoneinfo_file("Error", prompt);
+ return (DITEM_FAILURE | DITEM_RECREATE);
+ }
+
+#ifdef VERBOSE
+ snprintf(prompt, sizeof(prompt),
+ "Created symbolic link from %s to %s", zoneinfo_file,
+ path_localtime);
message_zoneinfo_file("Done", prompt);
#endif
} /* reallydoit */
@@ -802,7 +829,9 @@ main(int argc, char **argv)
int c, rv, skiputc;
char vm_guest[16] = "";
size_t len = sizeof(vm_guest);
+ char *dztpath;
+ dztpath = NULL;
skiputc = 0;
#ifdef HAVE_BSDDIALOG
@@ -814,11 +843,14 @@ main(int argc, char **argv)
strcmp(vm_guest, "none") != 0)
skiputc = 1;
- while ((c = getopt(argc, argv, "C:nrs")) != -1) {
- switch(c) {
+ while ((c = getopt(argc, argv, "C:d:nrs")) != -1) {
+ switch (c) {
case 'C':
chrootenv = optarg;
break;
+ case 'd':
+ dztpath = optarg;
+ break;
case 'n':
reallydoit = 0;
break;
@@ -840,7 +872,10 @@ main(int argc, char **argv)
usage();
if (chrootenv == NULL) {
- strcpy(path_zonetab, _PATH_ZONETAB);
+ if (dztpath == NULL)
+ strcpy(path_zonetab, _PATH_ZONETAB);
+ else
+ strlcpy(path_zonetab, dztpath, sizeof(path_zonetab));
strcpy(path_iso3166, _PATH_ISO3166);
strcpy(path_zoneinfo, _PATH_ZONEINFO);
strcpy(path_localtime, _PATH_LOCALTIME);
@@ -902,6 +937,10 @@ main(int argc, char **argv)
read_iso3166_table();
read_zones();
sort_countries();
+ if (dztpath != NULL) {
+ dump_zonetab();
+ return (0);
+ }
make_menus();
bsddialog_initconf(&conf);
diff --git a/usr.sbin/uathload/Makefile b/usr.sbin/uathload/Makefile
index 10a7cf472747..a3895d2019c4 100644
--- a/usr.sbin/uathload/Makefile
+++ b/usr.sbin/uathload/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= uathload
MAN= uathload.8
diff --git a/usr.sbin/uathload/Makefile.depend b/usr.sbin/uathload/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/uathload/Makefile.depend
+++ b/usr.sbin/uathload/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/uathload/uathload.8 b/usr.sbin/uathload/uathload.8
index 49c261252bfa..41cb2b4c1da7 100644
--- a/usr.sbin/uathload/uathload.8
+++ b/usr.sbin/uathload/uathload.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 11, 2010
.Dt UATHLOAD 8
.Os
diff --git a/usr.sbin/uathload/uathload.c b/usr.sbin/uathload/uathload.c
index 459dd31f1d74..6a1069943012 100644
--- a/usr.sbin/uathload/uathload.c
+++ b/usr.sbin/uathload/uathload.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2006 Sam Leffler, Errno Consulting
* All rights reserved.
@@ -27,8 +27,6 @@
* 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 DAMAGES.
- *
- * $FreeBSD$
*/
/*
diff --git a/usr.sbin/uefisign/Makefile b/usr.sbin/uefisign/Makefile
index d404a4c2363a..8c6314fe0f3e 100644
--- a/usr.sbin/uefisign/Makefile
+++ b/usr.sbin/uefisign/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= uefisign
SRCS= uefisign.c child.c pe.c
diff --git a/usr.sbin/uefisign/Makefile.depend b/usr.sbin/uefisign/Makefile.depend
index cdd96948933d..30ac5d62651c 100644
--- a/usr.sbin/uefisign/Makefile.depend
+++ b/usr.sbin/uefisign/Makefile.depend
@@ -1,12 +1,12 @@
-# $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 \
secure/lib/libcrypto \
diff --git a/usr.sbin/uefisign/child.c b/usr.sbin/uefisign/child.c
index 2eda8a66fd04..7d2349aec7d7 100644
--- a/usr.sbin/uefisign/child.c
+++ b/usr.sbin/uefisign/child.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -29,9 +29,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/capsicum.h>
#include <sys/types.h>
diff --git a/usr.sbin/uefisign/magic.h b/usr.sbin/uefisign/magic.h
index a20aa6fb06fd..1533d0ad347c 100644
--- a/usr.sbin/uefisign/magic.h
+++ b/usr.sbin/uefisign/magic.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -27,8 +27,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
/*
diff --git a/usr.sbin/uefisign/pe.c b/usr.sbin/uefisign/pe.c
index 09b5edd56ab7..7c194cc134a7 100644
--- a/usr.sbin/uefisign/pe.c
+++ b/usr.sbin/uefisign/pe.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -35,8 +35,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <assert.h>
#include <err.h>
#include <errno.h>
diff --git a/usr.sbin/uefisign/uefisign.8 b/usr.sbin/uefisign/uefisign.8
index e64c3249aca5..753751ce5c75 100644
--- a/usr.sbin/uefisign/uefisign.8
+++ b/usr.sbin/uefisign/uefisign.8
@@ -24,8 +24,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd July 11, 2015
.Dt UEFISIGN 8
.Os
diff --git a/usr.sbin/uefisign/uefisign.c b/usr.sbin/uefisign/uefisign.c
index 7eab934c3394..bf6a2c0d0e42 100644
--- a/usr.sbin/uefisign/uefisign.c
+++ b/usr.sbin/uefisign/uefisign.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -30,8 +30,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/wait.h>
#include <assert.h>
#include <err.h>
diff --git a/usr.sbin/uefisign/uefisign.h b/usr.sbin/uefisign/uefisign.h
index 0eb6adb84b9f..9ec41184aa11 100644
--- a/usr.sbin/uefisign/uefisign.h
+++ b/usr.sbin/uefisign/uefisign.h
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2014 The FreeBSD Foundation
*
@@ -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 EFISIGN_H
diff --git a/usr.sbin/ugidfw/Makefile b/usr.sbin/ugidfw/Makefile
index 7a5453e49d68..959e4d4c1aa2 100644
--- a/usr.sbin/ugidfw/Makefile
+++ b/usr.sbin/ugidfw/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= ugidfw
MAN= ugidfw.8
diff --git a/usr.sbin/ugidfw/Makefile.depend b/usr.sbin/ugidfw/Makefile.depend
index 65c3644dbf39..475c2951bb86 100644
--- a/usr.sbin/ugidfw/Makefile.depend
+++ b/usr.sbin/ugidfw/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/ugidfw/ugidfw.8 b/usr.sbin/ugidfw/ugidfw.8
index a639d43c49fe..e96b63128e16 100644
--- a/usr.sbin/ugidfw/ugidfw.8
+++ b/usr.sbin/ugidfw/ugidfw.8
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd February 24, 2004
.Dt UGIDFW 8
.Os
diff --git a/usr.sbin/ugidfw/ugidfw.c b/usr.sbin/ugidfw/ugidfw.c
index f748b4da77a3..1cba74e4bab7 100644
--- a/usr.sbin/ugidfw/ugidfw.c
+++ b/usr.sbin/ugidfw/ugidfw.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002, 2004 Networks Associates Technology, Inc.
* All rights reserved.
@@ -31,9 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/mount.h>
diff --git a/usr.sbin/uhsoctl/Makefile b/usr.sbin/uhsoctl/Makefile
index 264384b755c1..9d731bbf09dc 100644
--- a/usr.sbin/uhsoctl/Makefile
+++ b/usr.sbin/uhsoctl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= uhsoctl
MAN= uhsoctl.1
diff --git a/usr.sbin/uhsoctl/Makefile.depend b/usr.sbin/uhsoctl/Makefile.depend
index 4fc5be2a35f0..bbd6b7071809 100644
--- a/usr.sbin/uhsoctl/Makefile.depend
+++ b/usr.sbin/uhsoctl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/uhsoctl/uhsoctl.1 b/usr.sbin/uhsoctl/uhsoctl.1
index 826a1ec94c74..c6dd0debe703 100644
--- a/usr.sbin/uhsoctl/uhsoctl.1
+++ b/usr.sbin/uhsoctl/uhsoctl.1
@@ -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 Aug 12, 2009
+.Dd August 12, 2009
.Dt UHSOCTL 1
.Os
.Sh NAME
diff --git a/usr.sbin/uhsoctl/uhsoctl.c b/usr.sbin/uhsoctl/uhsoctl.c
index 8e5f88da2b36..992858eb45ca 100644
--- a/usr.sbin/uhsoctl/uhsoctl.c
+++ b/usr.sbin/uhsoctl/uhsoctl.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008-2009 Fredrik Lindberg
* All rights reserved.
@@ -23,8 +23,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$
*/
#include <sys/types.h>
diff --git a/usr.sbin/unbound/Makefile b/usr.sbin/unbound/Makefile
index 5e747ebb6952..a4fbd0b4a67b 100644
--- a/usr.sbin/unbound/Makefile
+++ b/usr.sbin/unbound/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= daemon anchor checkconf control
SUBDIR+= setup
diff --git a/usr.sbin/unbound/Makefile.inc b/usr.sbin/unbound/Makefile.inc
index 7cdeaa592d2a..8e4e8818522b 100644
--- a/usr.sbin/unbound/Makefile.inc
+++ b/usr.sbin/unbound/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
MK_WERROR= no
NO_WTHREAD_SAFETY= true
diff --git a/usr.sbin/unbound/anchor/Makefile b/usr.sbin/unbound/anchor/Makefile
index 986c77b02dbc..91ae1090415a 100644
--- a/usr.sbin/unbound/anchor/Makefile
+++ b/usr.sbin/unbound/anchor/Makefile
@@ -1,8 +1,8 @@
-# $FreeBSD$
# Vendor sources and generated files
LDNSDIR= ${SRCTOP}/contrib/ldns
UNBOUNDDIR= ${SRCTOP}/contrib/unbound
+LIBUNBOUNDDIR=${SRCTOP}/lib/libunbound
EXPATDIR= ${SRCTOP}/contrib/expat
.PATH: ${UNBOUNDDIR} ${UNBOUNDDIR}/smallapp ${UNBOUNDDIR}/doc
@@ -10,7 +10,7 @@ EXPATDIR= ${SRCTOP}/contrib/expat
PROG= local-unbound-anchor
SRCS= unbound-anchor.c
CFLAGS+= -I${UNBOUNDDIR} -I${LDNSDIR} -I${EXPATDIR}/lib
-CFLAGS+= -I${.CURDIR:H} -I${.CURDIR}
+CFLAGS+= -I${LIBUNBOUNDDIR} -I${.CURDIR}
LIBADD= unbound bsdxml ssl crypto pthread
MAN= local-unbound-anchor.8
diff --git a/usr.sbin/unbound/anchor/Makefile.depend b/usr.sbin/unbound/anchor/Makefile.depend
index 75cb691c1c91..178471a79ddf 100644
--- a/usr.sbin/unbound/anchor/Makefile.depend
+++ b/usr.sbin/unbound/anchor/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/unbound/checkconf/Makefile b/usr.sbin/unbound/checkconf/Makefile
index c10f7eb90959..c8d8397225b0 100644
--- a/usr.sbin/unbound/checkconf/Makefile
+++ b/usr.sbin/unbound/checkconf/Makefile
@@ -1,15 +1,15 @@
-# $FreeBSD$
# Vendor sources and generated files
LDNSDIR= ${SRCTOP}/contrib/ldns
UNBOUNDDIR= ${SRCTOP}/contrib/unbound
+LIBUNBOUNDDIR=${SRCTOP}/lib/libunbound
.PATH: ${UNBOUNDDIR} ${UNBOUNDDIR}/smallapp ${UNBOUNDDIR}/util ${UNBOUNDDIR}/doc
PROG= local-unbound-checkconf
SRCS= ub_event.c unbound-checkconf.c worker_cb.c
CFLAGS+= -I${UNBOUNDDIR} -I${LDNSDIR}
-CFLAGS+= -I${.CURDIR:H} -I${.CURDIR}
+CFLAGS+= -I${LIBUNBOUNDDIR} -I${.CURDIR}
LIBADD= unbound pthread
MAN= local-unbound-checkconf.8
diff --git a/usr.sbin/unbound/checkconf/Makefile.depend b/usr.sbin/unbound/checkconf/Makefile.depend
index 37b991b9f24c..bfc61c9e999b 100644
--- a/usr.sbin/unbound/checkconf/Makefile.depend
+++ b/usr.sbin/unbound/checkconf/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -11,8 +9,6 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libthr \
lib/libunbound \
- secure/lib/libcrypto \
- secure/lib/libssl \
.include <dirdeps.mk>
diff --git a/usr.sbin/unbound/config.h b/usr.sbin/unbound/config.h
deleted file mode 100644
index 4cc2dcfeb511..000000000000
--- a/usr.sbin/unbound/config.h
+++ /dev/null
@@ -1,1404 +0,0 @@
-/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-/* $FreeBSD$ */
-
-/* apply the noreturn attribute to a function that exits the program */
-#define ATTR_NORETURN __attribute__((__noreturn__))
-
-/* apply the weak attribute to a symbol */
-#define ATTR_WEAK __attribute__((weak))
-
-/* Directory to chroot to */
-#define CHROOT_DIR "/var/unbound"
-
-/* Define this to enable client subnet option. */
-/* #undef CLIENT_SUBNET */
-
-/* Do sha512 definitions in config.h */
-/* #undef COMPAT_SHA512 */
-
-/* Command line arguments used with configure */
-#define CONFCMDLINE "--with-ssl=/usr --with-libexpat=/usr --disable-dnscrypt --disable-dnstap --enable-ecdsa --disable-event-api --enable-gost --with-libevent --disable-subnet --disable-tfo-client --disable-tfo-server --with-pthreads--prefix=/usr --localstatedir=/var/unbound --mandir=/usr/share/man --build=freebsd"
-
-/* Pathname to the Unbound configuration file */
-#define CONFIGFILE "/var/unbound/unbound.conf"
-
-/* Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work
- */
-/* #undef DARWIN_BROKEN_SETREUID */
-
-/* Whether daemon is deprecated */
-/* #undef DEPRECATED_DAEMON */
-
-/* Define this to enable kernel based UDP source port randomization. */
-/* #undef DISABLE_EXPLICIT_PORT_RANDOMISATION */
-
-/* default dnstap socket path */
-/* #undef DNSTAP_SOCKET_PATH */
-
-/* Define if you want to use debug lock checking (slow). */
-/* #undef ENABLE_LOCK_CHECKS */
-
-/* Define this if you enabled-allsymbols from libunbound to link binaries to
- it for smaller install size, but the libunbound export table is polluted by
- internal symbols */
-/* #undef EXPORT_ALL_SYMBOLS */
-
-/* Define to 1 if you have the `accept4' function. */
-#define HAVE_ACCEPT4 1
-
-/* Define to 1 if you have the `arc4random' function. */
-#define HAVE_ARC4RANDOM 1
-
-/* Define to 1 if you have the `arc4random_uniform' function. */
-#define HAVE_ARC4RANDOM_UNIFORM 1
-
-/* Define to 1 if you have the <arpa/inet.h> header file. */
-#define HAVE_ARPA_INET_H 1
-
-/* Whether the C compiler accepts the "format" attribute */
-#define HAVE_ATTR_FORMAT 1
-
-/* Whether the C compiler accepts the "noreturn" attribute */
-#define HAVE_ATTR_NORETURN 1
-
-/* Whether the C compiler accepts the "unused" attribute */
-#define HAVE_ATTR_UNUSED 1
-
-/* Whether the C compiler accepts the "weak" attribute */
-#define HAVE_ATTR_WEAK 1
-
-/* If we have be64toh */
-/* #undef HAVE_BE64TOH */
-
-/* Define to 1 if you have the <bsd/stdlib.h> header file. */
-/* #undef HAVE_BSD_STDLIB_H */
-
-/* Define to 1 if you have the <bsd/string.h> header file. */
-/* #undef HAVE_BSD_STRING_H */
-
-/* Define to 1 if you have the `chown' function. */
-#define HAVE_CHOWN 1
-
-/* Define to 1 if you have the `chroot' function. */
-#define HAVE_CHROOT 1
-
-/* Define to 1 if you have the `CRYPTO_cleanup_all_ex_data' function. */
-/* #undef HAVE_CRYPTO_CLEANUP_ALL_EX_DATA */
-
-/* Define to 1 if you have the `CRYPTO_THREADID_set_callback' function. */
-/* #undef HAVE_CRYPTO_THREADID_SET_CALLBACK */
-
-/* Define to 1 if you have the `ctime_r' function. */
-#define HAVE_CTIME_R 1
-
-/* Define to 1 if you have the `daemon' function. */
-#define HAVE_DAEMON 1
-
-/* Define to 1 if you have the declaration of `arc4random', and to 0 if you
- don't. */
-/* #undef HAVE_DECL_ARC4RANDOM */
-
-/* Define to 1 if you have the declaration of `arc4random_uniform', and to 0
- if you don't. */
-/* #undef HAVE_DECL_ARC4RANDOM_UNIFORM */
-
-/* Define to 1 if you have the declaration of `evsignal_assign', and to 0 if
- you don't. */
-/* #undef HAVE_DECL_EVSIGNAL_ASSIGN */
-
-/* Define to 1 if you have the declaration of `inet_ntop', and to 0 if you
- don't. */
-#define HAVE_DECL_INET_NTOP 1
-
-/* Define to 1 if you have the declaration of `inet_pton', and to 0 if you
- don't. */
-#define HAVE_DECL_INET_PTON 1
-
-/* Define to 1 if you have the declaration of `nghttp2_session_server_new',
- and to 0 if you don't. */
-/* #undef HAVE_DECL_NGHTTP2_SESSION_SERVER_NEW */
-
-/* Define to 1 if you have the declaration of `NID_ED25519', and to 0 if you
- don't. */
-#define HAVE_DECL_NID_ED25519 1
-
-/* Define to 1 if you have the declaration of `NID_ED448', and to 0 if you
- don't. */
-#define HAVE_DECL_NID_ED448 1
-
-/* Define to 1 if you have the declaration of `NID_secp384r1', and to 0 if you
- don't. */
-#define HAVE_DECL_NID_SECP384R1 1
-
-/* Define to 1 if you have the declaration of `NID_X9_62_prime256v1', and to 0
- if you don't. */
-#define HAVE_DECL_NID_X9_62_PRIME256V1 1
-
-/* Define to 1 if you have the declaration of `reallocarray', and to 0 if you
- don't. */
-#define HAVE_DECL_REALLOCARRAY 1
-
-/* Define to 1 if you have the declaration of `redisConnect', and to 0 if you
- don't. */
-/* #undef HAVE_DECL_REDISCONNECT */
-
-/* Define to 1 if you have the declaration of `sk_SSL_COMP_pop_free', and to 0
- if you don't. */
-#define HAVE_DECL_SK_SSL_COMP_POP_FREE 1
-
-/* Define to 1 if you have the declaration of
- `SSL_COMP_get_compression_methods', and to 0 if you don't. */
-#define HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS 1
-
-/* Define to 1 if you have the declaration of `SSL_CTX_set_ecdh_auto', and to
- 0 if you don't. */
-#define HAVE_DECL_SSL_CTX_SET_ECDH_AUTO 1
-
-/* Define to 1 if you have the declaration of `strlcat', and to 0 if you
- don't. */
-/* #undef HAVE_DECL_STRLCAT */
-
-/* Define to 1 if you have the declaration of `strlcpy', and to 0 if you
- don't. */
-/* #undef HAVE_DECL_STRLCPY */
-
-/* Define to 1 if you have the declaration of `XML_StopParser', and to 0 if
- you don't. */
-#define HAVE_DECL_XML_STOPPARSER 1
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the `DSA_SIG_set0' function. */
-#define HAVE_DSA_SIG_SET0 1
-
-/* Define to 1 if you have the <endian.h> header file. */
-/* #undef HAVE_ENDIAN_H */
-
-/* Define to 1 if you have the `endprotoent' function. */
-#define HAVE_ENDPROTOENT 1
-
-/* Define to 1 if you have the `endpwent' function. */
-#define HAVE_ENDPWENT 1
-
-/* Define to 1 if you have the `endservent' function. */
-#define HAVE_ENDSERVENT 1
-
-/* Define to 1 if you have the `ENGINE_cleanup' function. */
-/* #undef HAVE_ENGINE_CLEANUP */
-
-/* Define to 1 if you have the `ERR_free_strings' function. */
-/* #undef HAVE_ERR_FREE_STRINGS */
-
-/* Define to 1 if you have the `ERR_load_crypto_strings' function. */
-/* #undef HAVE_ERR_LOAD_CRYPTO_STRINGS */
-
-/* Define to 1 if you have the `event_assign' function. */
-/* #undef HAVE_EVENT_ASSIGN */
-
-/* Define to 1 if you have the `event_base_free' function. */
-/* #undef HAVE_EVENT_BASE_FREE */
-
-/* Define to 1 if you have the `event_base_get_method' function. */
-/* #undef HAVE_EVENT_BASE_GET_METHOD */
-
-/* Define to 1 if you have the `event_base_new' function. */
-/* #undef HAVE_EVENT_BASE_NEW */
-
-/* Define to 1 if you have the `event_base_once' function. */
-/* #undef HAVE_EVENT_BASE_ONCE */
-
-/* Define to 1 if you have the <event.h> header file. */
-/* #undef HAVE_EVENT_H */
-
-/* Define to 1 if you have the `EVP_aes_256_cbc' function. */
-#define HAVE_EVP_AES_256_CBC 1
-
-/* Define to 1 if you have the `EVP_cleanup' function. */
-/* #undef HAVE_EVP_CLEANUP */
-
-/* Define to 1 if you have the `EVP_DigestVerify' function. */
-#define HAVE_EVP_DIGESTVERIFY 1
-
-/* Define to 1 if you have the `EVP_dss1' function. */
-/* #undef HAVE_EVP_DSS1 */
-
-/* Define to 1 if you have the `EVP_EncryptInit_ex' function. */
-#define HAVE_EVP_ENCRYPTINIT_EX 1
-
-/* Define to 1 if you have the `EVP_MAC_CTX_set_params' function. */
-/* #undef HAVE_EVP_MAC_CTX_SET_PARAMS */
-
-/* Define to 1 if you have the `EVP_MD_CTX_new' function. */
-#define HAVE_EVP_MD_CTX_NEW 1
-
-/* Define to 1 if you have the `EVP_sha1' function. */
-#define HAVE_EVP_SHA1 1
-
-/* Define to 1 if you have the `EVP_sha256' function. */
-#define HAVE_EVP_SHA256 1
-
-/* Define to 1 if you have the `EVP_sha512' function. */
-#define HAVE_EVP_SHA512 1
-
-/* Define to 1 if you have the `ev_default_loop' function. */
-/* #undef HAVE_EV_DEFAULT_LOOP */
-
-/* Define to 1 if you have the `ev_loop' function. */
-/* #undef HAVE_EV_LOOP */
-
-/* Define to 1 if you have the <expat.h> header file. */
-#define HAVE_EXPAT_H 1
-
-/* Define to 1 if you have the `explicit_bzero' function. */
-#define HAVE_EXPLICIT_BZERO 1
-
-/* Define to 1 if you have the `fcntl' function. */
-#define HAVE_FCNTL 1
-
-/* Define to 1 if you have the `FIPS_mode' function. */
-#define HAVE_FIPS_MODE 1
-
-/* Define to 1 if you have the `fork' function. */
-#define HAVE_FORK 1
-
-/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
-#define HAVE_FSEEKO 1
-
-/* Define to 1 if you have the `fsync' function. */
-#define HAVE_FSYNC 1
-
-/* Whether getaddrinfo is available */
-#define HAVE_GETADDRINFO 1
-
-/* Define to 1 if you have the `getauxval' function. */
-/* #undef HAVE_GETAUXVAL */
-
-/* Define to 1 if you have the `getentropy' function. */
-/* #undef HAVE_GETENTROPY */
-
-/* Define to 1 if you have the `getifaddrs' function. */
-#define HAVE_GETIFADDRS 1
-
-/* Define to 1 if you have the <getopt.h> header file. */
-#define HAVE_GETOPT_H 1
-
-/* Define to 1 if you have the `getpwnam' function. */
-#define HAVE_GETPWNAM 1
-
-/* Define to 1 if you have the `getrlimit' function. */
-#define HAVE_GETRLIMIT 1
-
-/* Define to 1 if you have the `glob' function. */
-#define HAVE_GLOB 1
-
-/* Define to 1 if you have the <glob.h> header file. */
-#define HAVE_GLOB_H 1
-
-/* Define to 1 if you have the `gmtime_r' function. */
-#define HAVE_GMTIME_R 1
-
-/* Define to 1 if you have the <grp.h> header file. */
-#define HAVE_GRP_H 1
-
-/* Define to 1 if you have the <hiredis/hiredis.h> header file. */
-/* #undef HAVE_HIREDIS_HIREDIS_H */
-
-/* Define to 1 if you have the `HMAC_Init_ex' function. */
-#define HAVE_HMAC_INIT_EX 1
-
-/* If we have htobe64 */
-/* #undef HAVE_HTOBE64 */
-
-/* Define to 1 if you have the <ifaddrs.h> header file. */
-#define HAVE_IFADDRS_H 1
-
-/* Define to 1 if you have the `inet_aton' function. */
-#define HAVE_INET_ATON 1
-
-/* Define to 1 if you have the `inet_ntop' function. */
-#define HAVE_INET_NTOP 1
-
-/* Define to 1 if you have the `inet_pton' function. */
-#define HAVE_INET_PTON 1
-
-/* Define to 1 if you have the `initgroups' function. */
-#define HAVE_INITGROUPS 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* if the function 'ioctlsocket' is available */
-/* #undef HAVE_IOCTLSOCKET */
-
-/* Define to 1 if you have the <iphlpapi.h> header file. */
-/* #undef HAVE_IPHLPAPI_H */
-
-/* Define to 1 if you have the `isblank' function. */
-#define HAVE_ISBLANK 1
-
-/* Define to 1 if you have the `kill' function. */
-#define HAVE_KILL 1
-
-/* Use portable libbsd functions */
-/* #undef HAVE_LIBBSD */
-
-/* Define to 1 if you have the <libkern/OSByteOrder.h> header file. */
-/* #undef HAVE_LIBKERN_OSBYTEORDER_H */
-
-/* Define if we have LibreSSL */
-/* #undef HAVE_LIBRESSL */
-
-/* Define to 1 if you have the `localtime_r' function. */
-#define HAVE_LOCALTIME_R 1
-
-/* Define to 1 if you have the <login_cap.h> header file. */
-#define HAVE_LOGIN_CAP_H 1
-
-/* If have GNU libc compatible malloc */
-#define HAVE_MALLOC 1
-
-/* Define to 1 if you have the `memmove' function. */
-#define HAVE_MEMMOVE 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the <netdb.h> header file. */
-#define HAVE_NETDB_H 1
-
-/* Define to 1 if you have the <netinet/in.h> header file. */
-#define HAVE_NETINET_IN_H 1
-
-/* Define to 1 if you have the <netinet/tcp.h> header file. */
-#define HAVE_NETINET_TCP_H 1
-
-/* Use libnettle for crypto */
-/* #undef HAVE_NETTLE */
-
-/* Define to 1 if you have the <nettle/dsa-compat.h> header file. */
-/* #undef HAVE_NETTLE_DSA_COMPAT_H */
-
-/* Define to 1 if you have the <nettle/eddsa.h> header file. */
-/* #undef HAVE_NETTLE_EDDSA_H */
-
-/* Define to 1 if you have the <net/if.h> header file. */
-#define HAVE_NET_IF_H 1
-
-/* Define this to use nghttp2 client. */
-/* #undef HAVE_NGHTTP2 */
-
-/* Define to 1 if you have the <nghttp2/nghttp2.h> header file. */
-/* #undef HAVE_NGHTTP2_NGHTTP2_H */
-
-/* Use libnss for crypto */
-/* #undef HAVE_NSS */
-
-/* Define to 1 if you have the `OpenSSL_add_all_digests' function. */
-/* #undef HAVE_OPENSSL_ADD_ALL_DIGESTS */
-
-/* Define to 1 if you have the <openssl/bn.h> header file. */
-#define HAVE_OPENSSL_BN_H 1
-
-/* Define to 1 if you have the `OPENSSL_config' function. */
-#define HAVE_OPENSSL_CONFIG 1
-
-/* Define to 1 if you have the <openssl/conf.h> header file. */
-#define HAVE_OPENSSL_CONF_H 1
-
-/* Define to 1 if you have the <openssl/core_names.h> header file. */
-/* #undef HAVE_OPENSSL_CORE_NAMES_H */
-
-/* Define to 1 if you have the <openssl/dh.h> header file. */
-#define HAVE_OPENSSL_DH_H 1
-
-/* Define to 1 if you have the <openssl/dsa.h> header file. */
-#define HAVE_OPENSSL_DSA_H 1
-
-/* Define to 1 if you have the <openssl/engine.h> header file. */
-#define HAVE_OPENSSL_ENGINE_H 1
-
-/* Define to 1 if you have the <openssl/err.h> header file. */
-#define HAVE_OPENSSL_ERR_H 1
-
-/* Define to 1 if you have the `OPENSSL_init_crypto' function. */
-#define HAVE_OPENSSL_INIT_CRYPTO 1
-
-/* Define to 1 if you have the `OPENSSL_init_ssl' function. */
-#define HAVE_OPENSSL_INIT_SSL 1
-
-/* Define to 1 if you have the <openssl/rand.h> header file. */
-#define HAVE_OPENSSL_RAND_H 1
-
-/* Define to 1 if you have the <openssl/rsa.h> header file. */
-#define HAVE_OPENSSL_RSA_H 1
-
-/* Define to 1 if you have the <openssl/ssl.h> header file. */
-#define HAVE_OPENSSL_SSL_H 1
-
-/* Define if you have POSIX threads libraries and header files. */
-#define HAVE_PTHREAD 1
-
-/* Have PTHREAD_PRIO_INHERIT. */
-#define HAVE_PTHREAD_PRIO_INHERIT 1
-
-/* Define to 1 if the system has the type `pthread_rwlock_t'. */
-#define HAVE_PTHREAD_RWLOCK_T 1
-
-/* Define to 1 if the system has the type `pthread_spinlock_t'. */
-#define HAVE_PTHREAD_SPINLOCK_T 1
-
-/* Define to 1 if you have the <pwd.h> header file. */
-#define HAVE_PWD_H 1
-
-/* Define if you have Python libraries and header files. */
-/* #undef HAVE_PYTHON */
-
-/* Define to 1 if you have the `random' function. */
-#define HAVE_RANDOM 1
-
-/* Define to 1 if you have the `RAND_cleanup' function. */
-/* #undef HAVE_RAND_CLEANUP */
-
-/* If we have reallocarray(3) */
-#define HAVE_REALLOCARRAY 1
-
-/* Define to 1 if you have the `recvmsg' function. */
-#define HAVE_RECVMSG 1
-
-/* Define to 1 if you have the `sendmsg' function. */
-#define HAVE_SENDMSG 1
-
-/* Define to 1 if you have the `setregid' function. */
-/* #undef HAVE_SETREGID */
-
-/* Define to 1 if you have the `setresgid' function. */
-#define HAVE_SETRESGID 1
-
-/* Define to 1 if you have the `setresuid' function. */
-#define HAVE_SETRESUID 1
-
-/* Define to 1 if you have the `setreuid' function. */
-/* #undef HAVE_SETREUID */
-
-/* Define to 1 if you have the `setrlimit' function. */
-#define HAVE_SETRLIMIT 1
-
-/* Define to 1 if you have the `setsid' function. */
-#define HAVE_SETSID 1
-
-/* Define to 1 if you have the `setusercontext' function. */
-#define HAVE_SETUSERCONTEXT 1
-
-/* Define to 1 if you have the `SHA512_Update' function. */
-/* #undef HAVE_SHA512_UPDATE */
-
-/* Define to 1 if you have the `shmget' function. */
-#define HAVE_SHMGET 1
-
-/* Define to 1 if you have the `sigprocmask' function. */
-#define HAVE_SIGPROCMASK 1
-
-/* Define to 1 if you have the `sleep' function. */
-#define HAVE_SLEEP 1
-
-/* Define to 1 if you have the `snprintf' function. */
-#define HAVE_SNPRINTF 1
-
-/* Define to 1 if you have the `socketpair' function. */
-#define HAVE_SOCKETPAIR 1
-
-/* Using Solaris threads */
-/* #undef HAVE_SOLARIS_THREADS */
-
-/* Define to 1 if you have the `srandom' function. */
-#define HAVE_SRANDOM 1
-
-/* Define if you have the SSL libraries installed. */
-#define HAVE_SSL /**/
-
-/* Define to 1 if you have the `SSL_CTX_set_alpn_select_cb' function. */
-#define HAVE_SSL_CTX_SET_ALPN_SELECT_CB 1
-
-/* Define to 1 if you have the `SSL_CTX_set_ciphersuites' function. */
-#define HAVE_SSL_CTX_SET_CIPHERSUITES 1
-
-/* Define to 1 if you have the `SSL_CTX_set_security_level' function. */
-#define HAVE_SSL_CTX_SET_SECURITY_LEVEL 1
-
-/* Define to 1 if you have the `SSL_CTX_set_tlsext_ticket_key_evp_cb'
- function. */
-/* #undef HAVE_SSL_CTX_SET_TLSEXT_TICKET_KEY_EVP_CB */
-
-/* Define to 1 if you have the `SSL_get0_peername' function. */
-#define HAVE_SSL_GET0_PEERNAME 1
-
-/* Define to 1 if you have the `SSL_set1_host' function. */
-#define HAVE_SSL_SET1_HOST 1
-
-/* Define to 1 if you have the <stdarg.h> header file. */
-#define HAVE_STDARG_H 1
-
-/* Define to 1 if you have the <stdbool.h> header file. */
-#define HAVE_STDBOOL_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `strftime' function. */
-#define HAVE_STRFTIME 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `strlcat' function. */
-#define HAVE_STRLCAT 1
-
-/* Define to 1 if you have the `strlcpy' function. */
-#define HAVE_STRLCPY 1
-
-/* Define to 1 if you have the `strptime' function. */
-#define HAVE_STRPTIME 1
-
-/* Define to 1 if you have the `strsep' function. */
-#define HAVE_STRSEP 1
-
-/* Define to 1 if `ipi_spec_dst' is a member of `struct in_pktinfo'. */
-/* #undef HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST */
-
-/* Define to 1 if `sun_len' is a member of `struct sockaddr_un'. */
-#define HAVE_STRUCT_SOCKADDR_UN_SUN_LEN 1
-
-/* Define if you have Swig libraries and header files. */
-/* #undef HAVE_SWIG */
-
-/* Define to 1 if you have the <syslog.h> header file. */
-#define HAVE_SYSLOG_H 1
-
-/* Define to 1 if systemd should be used */
-/* #undef HAVE_SYSTEMD */
-
-/* Define to 1 if you have the <sys/endian.h> header file. */
-#define HAVE_SYS_ENDIAN_H 1
-
-/* Define to 1 if you have the <sys/ipc.h> header file. */
-#define HAVE_SYS_IPC_H 1
-
-/* Define to 1 if you have the <sys/param.h> header file. */
-#define HAVE_SYS_PARAM_H 1
-
-/* Define to 1 if you have the <sys/resource.h> header file. */
-#define HAVE_SYS_RESOURCE_H 1
-
-/* Define to 1 if you have the <sys/select.h> header file. */
-#define HAVE_SYS_SELECT_H 1
-
-/* Define to 1 if you have the <sys/sha2.h> header file. */
-/* #undef HAVE_SYS_SHA2_H */
-
-/* Define to 1 if you have the <sys/shm.h> header file. */
-#define HAVE_SYS_SHM_H 1
-
-/* Define to 1 if you have the <sys/socket.h> header file. */
-#define HAVE_SYS_SOCKET_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/sysctl.h> header file. */
-/* #undef HAVE_SYS_SYSCTL_H */
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <sys/uio.h> header file. */
-#define HAVE_SYS_UIO_H 1
-
-/* Define to 1 if you have the <sys/un.h> header file. */
-#define HAVE_SYS_UN_H 1
-
-/* Define to 1 if you have the <sys/wait.h> header file. */
-#define HAVE_SYS_WAIT_H 1
-
-/* Define to 1 if you have the <TargetConditionals.h> header file. */
-/* #undef HAVE_TARGETCONDITIONALS_H */
-
-/* Define to 1 if you have the <time.h> header file. */
-#define HAVE_TIME_H 1
-
-/* Define to 1 if you have the `tzset' function. */
-#define HAVE_TZSET 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if you have the `usleep' function. */
-#define HAVE_USLEEP 1
-
-/* Define to 1 if you have the `vfork' function. */
-#define HAVE_VFORK 1
-
-/* Define to 1 if you have the <vfork.h> header file. */
-/* #undef HAVE_VFORK_H */
-
-/* Define to 1 if you have the <windows.h> header file. */
-/* #undef HAVE_WINDOWS_H */
-
-/* Using Windows threads */
-/* #undef HAVE_WINDOWS_THREADS */
-
-/* Define to 1 if you have the <winsock2.h> header file. */
-/* #undef HAVE_WINSOCK2_H */
-
-/* Define to 1 if `fork' works. */
-#define HAVE_WORKING_FORK 1
-
-/* Define to 1 if `vfork' works. */
-#define HAVE_WORKING_VFORK 1
-
-/* Define to 1 if you have the `writev' function. */
-#define HAVE_WRITEV 1
-
-/* Define to 1 if you have the <ws2tcpip.h> header file. */
-/* #undef HAVE_WS2TCPIP_H */
-
-/* Define to 1 if you have the `X509_VERIFY_PARAM_set1_host' function. */
-#define HAVE_X509_VERIFY_PARAM_SET1_HOST 1
-
-/* Define to 1 if you have the `_beginthreadex' function. */
-/* #undef HAVE__BEGINTHREADEX */
-
-/* If HMAC_Init_ex() returns void */
-/* #undef HMAC_INIT_EX_RETURNS_VOID */
-
-/* if lex has yylex_destroy */
-#define LEX_HAS_YYLEX_DESTROY 1
-
-/* Define to the sub-directory where libtool stores uninstalled libraries. */
-#define LT_OBJDIR ".libs/"
-
-/* Define to the maximum message length to pass to syslog. */
-#define MAXSYSLOGMSGLEN 10240
-
-/* Define if memcmp() does not compare unsigned bytes */
-/* #undef MEMCMP_IS_BROKEN */
-
-/* Define if mkdir has one argument. */
-/* #undef MKDIR_HAS_ONE_ARG */
-
-/* Define if the network stack does not fully support nonblocking io (causes
- lower performance). */
-/* #undef NONBLOCKING_IS_BROKEN */
-
-/* Put -D_ALL_SOURCE define in config.h */
-/* #undef OMITTED__D_ALL_SOURCE */
-
-/* Put -D_BSD_SOURCE define in config.h */
-/* #undef OMITTED__D_BSD_SOURCE */
-
-/* Put -D_DEFAULT_SOURCE define in config.h */
-/* #undef OMITTED__D_DEFAULT_SOURCE */
-
-/* Put -D_GNU_SOURCE define in config.h */
-/* #undef OMITTED__D_GNU_SOURCE */
-
-/* Put -D_LARGEFILE_SOURCE=1 define in config.h */
-/* #undef OMITTED__D_LARGEFILE_SOURCE_1 */
-
-/* Put -D_POSIX_C_SOURCE=200112 define in config.h */
-/* #undef OMITTED__D_POSIX_C_SOURCE_200112 */
-
-/* Put -D_XOPEN_SOURCE=600 define in config.h */
-/* #undef OMITTED__D_XOPEN_SOURCE_600 */
-
-/* Put -D_XOPEN_SOURCE_EXTENDED=1 define in config.h */
-/* #undef OMITTED__D_XOPEN_SOURCE_EXTENDED_1 */
-
-/* Put -D__EXTENSIONS__ define in config.h */
-/* #undef OMITTED__D__EXTENSIONS__ */
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "unbound-bugs@nlnetlabs.nl or https://github.com/NLnetLabs/unbound/issues"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "unbound"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "unbound 1.13.1"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "unbound"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.13.1"
-
-/* default pidfile location */
-#define PIDFILE "/var/unbound/unbound.pid"
-
-/* Define to necessary symbol if this constant uses a non-standard name on
- your system. */
-/* #undef PTHREAD_CREATE_JOINABLE */
-
-/* Define as the return type of signal handlers (`int' or `void'). */
-#define RETSIGTYPE void
-
-/* if REUSEPORT is enabled by default */
-#define REUSEPORT_DEFAULT 0
-
-/* default rootkey location */
-#define ROOT_ANCHOR_FILE "/var/unbound/root.key"
-
-/* default rootcert location */
-#define ROOT_CERT_FILE "/var/unbound/icannbundle.pem"
-
-/* version number for resource files */
-#define RSRC_PACKAGE_VERSION 1,13,1,0
-
-/* Directory to chdir to */
-#define RUN_DIR "/var/unbound"
-
-/* Shared data */
-#define SHARE_DIR "/var/unbound"
-
-/* The size of `size_t'. */
-#ifdef __LP64__
-#define SIZEOF_SIZE_T 8
-#else
-#define SIZEOF_SIZE_T 4
-#endif
-
-/* The size of `time_t', as computed by sizeof. */
-#ifdef __i386__
-#define SIZEOF_TIME_T 4
-#else
-#define SIZEOF_TIME_T 8
-#endif
-
-/* define if (v)snprintf does not return length needed, (but length used) */
-/* #undef SNPRINTF_RET_BROKEN */
-
-/* Define to 1 if libsodium supports sodium_set_misuse_handler */
-/* #undef SODIUM_MISUSE_HANDLER */
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* use default strptime. */
-#define STRPTIME_WORKS 1
-
-/* Use win32 resources and API */
-/* #undef UB_ON_WINDOWS */
-
-/* the SYSLOG_FACILITY to use, default LOG_DAEMON */
-#define UB_SYSLOG_FACILITY LOG_DAEMON
-
-/* default username */
-#define UB_USERNAME "unbound"
-
-/* use to enable lightweight alloc assertions, for debug use */
-/* #undef UNBOUND_ALLOC_LITE */
-
-/* use malloc not regions, for debug use */
-/* #undef UNBOUND_ALLOC_NONREGIONAL */
-
-/* use statistics for allocs and frees, for debug use */
-/* #undef UNBOUND_ALLOC_STATS */
-
-/* define this to enable debug checks. */
-/* #undef UNBOUND_DEBUG */
-
-/* Define to 1 to use cachedb support */
-/* #undef USE_CACHEDB */
-
-/* Define to 1 to enable dnscrypt support */
-/* #undef USE_DNSCRYPT */
-
-/* Define to 1 to enable dnscrypt with xchacha20 support */
-/* #undef USE_DNSCRYPT_XCHACHA20 */
-
-/* Define to 1 to enable dnstap support */
-/* #undef USE_DNSTAP */
-
-/* Define this to enable DSA support. */
-#define USE_DSA 1
-
-/* Define this to enable ECDSA support. */
-#define USE_ECDSA 1
-
-/* Define this to enable an EVP workaround for older openssl */
-/* #undef USE_ECDSA_EVP_WORKAROUND */
-
-/* Define this to enable ED25519 support. */
-#define USE_ED25519 1
-
-/* Define this to enable ED448 support. */
-#define USE_ED448 1
-
-/* Define this to enable GOST support. */
-/* #undef USE_GOST */
-
-/* Define to 1 to use ipsecmod support. */
-/* #undef USE_IPSECMOD */
-
-/* Define to 1 to use ipset support */
-/* #undef USE_IPSET */
-
-/* Define if you enable libevent */
-#define USE_LIBEVENT 1
-
-/* Define if you want to use internal select based events */
-#define USE_MINI_EVENT 1
-
-/* Define this to enable client TCP Fast Open. */
-/* #undef USE_MSG_FASTOPEN */
-
-/* Define this to enable client TCP Fast Open. */
-/* #undef USE_OSX_MSG_FASTOPEN */
-
-/* Define this to use hiredis client. */
-/* #undef USE_REDIS */
-
-/* Define this to enable SHA1 support. */
-#define USE_SHA1 1
-
-/* Define this to enable SHA256 and SHA512 support. */
-#define USE_SHA2 1
-
-/* Enable extensions on AIX 3, Interix. */
-#ifndef _ALL_SOURCE
-# define _ALL_SOURCE 1
-#endif
-/* Enable GNU extensions on systems that have them. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-/* Enable threading extensions on Solaris. */
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# define _POSIX_PTHREAD_SEMANTICS 1
-#endif
-/* Enable extensions on HP NonStop. */
-#ifndef _TANDEM_SOURCE
-# define _TANDEM_SOURCE 1
-#endif
-/* Enable general extensions on Solaris. */
-#ifndef __EXTENSIONS__
-# define __EXTENSIONS__ 1
-#endif
-
-
-/* Define this to enable server TCP Fast Open. */
-/* #undef USE_TCP_FASTOPEN */
-
-/* Whether the windows socket API is used */
-/* #undef USE_WINSOCK */
-
-/* the version of the windows API enabled */
-#define WINVER 0x0502
-
-/* Define if you want dynlib module. */
-/* #undef WITH_DYNLIBMODULE */
-
-/* Define if you want Python module. */
-/* #undef WITH_PYTHONMODULE */
-
-/* Define if you want PyUnbound. */
-/* #undef WITH_PYUNBOUND */
-
-/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
- `char[]'. */
-#define YYTEXT_POINTER 1
-
-/* Enable large inode numbers on Mac OS X 10.5. */
-#ifndef _DARWIN_USE_64_BIT_INODE
-# define _DARWIN_USE_64_BIT_INODE 1
-#endif
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-/* #undef _FILE_OFFSET_BITS */
-
-/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
-/* #undef _LARGEFILE_SOURCE */
-
-/* Define for large files, on AIX-style hosts. */
-/* #undef _LARGE_FILES */
-
-/* Define to 1 if on MINIX. */
-/* #undef _MINIX */
-
-/* Enable for compile on Minix */
-/* #undef _NETBSD_SOURCE */
-
-/* Define to 2 if the system does not provide POSIX.1 features except with
- this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define to 1 if you need to in order for `stat' and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef gid_t */
-
-/* in_addr_t */
-/* #undef in_addr_t */
-
-/* in_port_t */
-/* #undef in_port_t */
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler
- calls it, or to nothing if 'inline' is not supported under any name. */
-#ifndef __cplusplus
-/* #undef inline */
-#endif
-
-/* Define to `short' if <sys/types.h> does not define. */
-/* #undef int16_t */
-
-/* Define to `int' if <sys/types.h> does not define. */
-/* #undef int32_t */
-
-/* Define to `long long' if <sys/types.h> does not define. */
-/* #undef int64_t */
-
-/* Define to `signed char' if <sys/types.h> does not define. */
-/* #undef int8_t */
-
-/* Define if replacement function should be used. */
-/* #undef malloc */
-
-/* Define to `long int' if <sys/types.h> does not define. */
-/* #undef off_t */
-
-/* Define to `int' if <sys/types.h> does not define. */
-/* #undef pid_t */
-
-/* Define to 'int' if not defined */
-/* #undef rlim_t */
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-/* #undef size_t */
-
-/* Define to 'int' if not defined */
-/* #undef socklen_t */
-
-/* Define to `int' if <sys/types.h> does not define. */
-/* #undef ssize_t */
-
-/* Define to 'unsigned char if not defined */
-/* #undef u_char */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef uid_t */
-
-/* Define to `unsigned short' if <sys/types.h> does not define. */
-/* #undef uint16_t */
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-/* #undef uint32_t */
-
-/* Define to `unsigned long long' if <sys/types.h> does not define. */
-/* #undef uint64_t */
-
-/* Define to `unsigned char' if <sys/types.h> does not define. */
-/* #undef uint8_t */
-
-/* Define as `fork' if `vfork' does not work. */
-/* #undef vfork */
-
-#if defined(OMITTED__D_GNU_SOURCE) && !defined(_GNU_SOURCE)
-#define _GNU_SOURCE 1
-#endif
-
-#if defined(OMITTED__D_BSD_SOURCE) && !defined(_BSD_SOURCE)
-#define _BSD_SOURCE 1
-#endif
-
-#if defined(OMITTED__D_DEFAULT_SOURCE) && !defined(_DEFAULT_SOURCE)
-#define _DEFAULT_SOURCE 1
-#endif
-
-#if defined(OMITTED__D__EXTENSIONS__) && !defined(__EXTENSIONS__)
-#define __EXTENSIONS__ 1
-#endif
-
-#if defined(OMITTED__D_POSIX_C_SOURCE_200112) && !defined(_POSIX_C_SOURCE)
-#define _POSIX_C_SOURCE 200112
-#endif
-
-#if defined(OMITTED__D_XOPEN_SOURCE_600) && !defined(_XOPEN_SOURCE)
-#define _XOPEN_SOURCE 600
-#endif
-
-#if defined(OMITTED__D_XOPEN_SOURCE_EXTENDED_1) && !defined(_XOPEN_SOURCE_EXTENDED)
-#define _XOPEN_SOURCE_EXTENDED 1
-#endif
-
-#if defined(OMITTED__D_ALL_SOURCE) && !defined(_ALL_SOURCE)
-#define _ALL_SOURCE 1
-#endif
-
-#if defined(OMITTED__D_LARGEFILE_SOURCE_1) && !defined(_LARGEFILE_SOURCE)
-#define _LARGEFILE_SOURCE 1
-#endif
-
-
-
-
-#ifndef _OPENBSD_SOURCE
-#define _OPENBSD_SOURCE 1
-#endif
-
-#ifndef UNBOUND_DEBUG
-# ifndef NDEBUG
-# define NDEBUG
-# endif
-#endif
-
-/** Use small-ldns codebase */
-#define USE_SLDNS 1
-#ifdef HAVE_SSL
-# define LDNS_BUILD_CONFIG_HAVE_SSL 1
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <assert.h>
-
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-
-#ifdef HAVE_STDARG_H
-#include <stdarg.h>
-#endif
-
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
-
-#include <errno.h>
-
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#ifdef HAVE_SYS_UIO_H
-#include <sys/uio.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-
-#ifdef HAVE_NETINET_TCP_H
-#include <netinet/tcp.h>
-#endif
-
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-
-#ifdef HAVE_WS2TCPIP_H
-#include <ws2tcpip.h>
-#endif
-
-#ifndef USE_WINSOCK
-#define ARG_LL "%ll"
-#else
-#define ARG_LL "%I64"
-#endif
-
-#ifndef AF_LOCAL
-#define AF_LOCAL AF_UNIX
-#endif
-
-
-
-#ifdef HAVE_ATTR_FORMAT
-# define ATTR_FORMAT(archetype, string_index, first_to_check) \
- __attribute__ ((format (archetype, string_index, first_to_check)))
-#else /* !HAVE_ATTR_FORMAT */
-# define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
-#endif /* !HAVE_ATTR_FORMAT */
-
-
-#if defined(DOXYGEN)
-# define ATTR_UNUSED(x) x
-#elif defined(__cplusplus)
-# define ATTR_UNUSED(x)
-#elif defined(HAVE_ATTR_UNUSED)
-# define ATTR_UNUSED(x) x __attribute__((unused))
-#else /* !HAVE_ATTR_UNUSED */
-# define ATTR_UNUSED(x) x
-#endif /* !HAVE_ATTR_UNUSED */
-
-
-#ifndef HAVE_FSEEKO
-#define fseeko fseek
-#define ftello ftell
-#endif /* HAVE_FSEEKO */
-
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif
-
-#if !defined(HAVE_SNPRINTF) || defined(SNPRINTF_RET_BROKEN)
-#define snprintf snprintf_unbound
-#define vsnprintf vsnprintf_unbound
-#include <stdarg.h>
-int snprintf (char *str, size_t count, const char *fmt, ...);
-int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
-#endif /* HAVE_SNPRINTF or SNPRINTF_RET_BROKEN */
-
-#ifndef HAVE_INET_PTON
-#define inet_pton inet_pton_unbound
-int inet_pton(int af, const char* src, void* dst);
-#endif /* HAVE_INET_PTON */
-
-
-#ifndef HAVE_INET_NTOP
-#define inet_ntop inet_ntop_unbound
-const char *inet_ntop(int af, const void *src, char *dst, size_t size);
-#endif
-
-
-#ifndef HAVE_INET_ATON
-#define inet_aton inet_aton_unbound
-int inet_aton(const char *cp, struct in_addr *addr);
-#endif
-
-
-#ifndef HAVE_MEMMOVE
-#define memmove memmove_unbound
-void *memmove(void *dest, const void *src, size_t n);
-#endif
-
-
-#ifndef HAVE_STRLCAT
-#define strlcat strlcat_unbound
-size_t strlcat(char *dst, const char *src, size_t siz);
-#endif
-
-
-#ifndef HAVE_STRLCPY
-#define strlcpy strlcpy_unbound
-size_t strlcpy(char *dst, const char *src, size_t siz);
-#endif
-
-
-#ifndef HAVE_GMTIME_R
-#define gmtime_r gmtime_r_unbound
-struct tm *gmtime_r(const time_t *timep, struct tm *result);
-#endif
-
-
-#ifndef HAVE_REALLOCARRAY
-#define reallocarray reallocarrayunbound
-void* reallocarray(void *ptr, size_t nmemb, size_t size);
-#endif
-
-
-#if !defined(HAVE_SLEEP) || defined(HAVE_WINDOWS_H)
-#define sleep(x) Sleep((x)*1000) /* on win32 */
-#endif /* HAVE_SLEEP */
-
-
-#ifndef HAVE_USLEEP
-#define usleep(x) Sleep((x)/1000 + 1) /* on win32 */
-#endif /* HAVE_USLEEP */
-
-
-#ifndef HAVE_RANDOM
-#define random rand /* on win32, for tests only (bad random) */
-#endif /* HAVE_RANDOM */
-
-
-#ifndef HAVE_SRANDOM
-#define srandom(x) srand(x) /* on win32, for tests only (bad random) */
-#endif /* HAVE_SRANDOM */
-
-
-/* detect if we need to cast to unsigned int for FD_SET to avoid warnings */
-#ifdef HAVE_WINSOCK2_H
-#define FD_SET_T (u_int)
-#else
-#define FD_SET_T
-#endif
-
-
-#ifndef IPV6_MIN_MTU
-#define IPV6_MIN_MTU 1280
-#endif /* IPV6_MIN_MTU */
-
-
-#ifdef MEMCMP_IS_BROKEN
-#include "compat/memcmp.h"
-#define memcmp memcmp_unbound
-int memcmp(const void *x, const void *y, size_t n);
-#endif
-
-
-
-#ifndef HAVE_CTIME_R
-#define ctime_r unbound_ctime_r
-char *ctime_r(const time_t *timep, char *buf);
-#endif
-
-#ifndef HAVE_STRSEP
-#define strsep unbound_strsep
-char *strsep(char **stringp, const char *delim);
-#endif
-
-#ifndef HAVE_ISBLANK
-#define isblank unbound_isblank
-int isblank(int c);
-#endif
-
-#ifndef HAVE_EXPLICIT_BZERO
-#define explicit_bzero unbound_explicit_bzero
-void explicit_bzero(void* buf, size_t len);
-#endif
-
-#if defined(HAVE_INET_NTOP) && !HAVE_DECL_INET_NTOP
-const char *inet_ntop(int af, const void *src, char *dst, size_t size);
-#endif
-
-#if defined(HAVE_INET_PTON) && !HAVE_DECL_INET_PTON
-int inet_pton(int af, const char* src, void* dst);
-#endif
-
-#if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS)
-#define strptime unbound_strptime
-struct tm;
-char *strptime(const char *s, const char *format, struct tm *tm);
-#endif
-
-#if !HAVE_DECL_REALLOCARRAY
-void *reallocarray(void *ptr, size_t nmemb, size_t size);
-#endif
-
-#ifdef HAVE_LIBBSD
-#include <bsd/string.h>
-#include <bsd/stdlib.h>
-#endif
-
-#ifdef HAVE_LIBRESSL
-# if !HAVE_DECL_STRLCPY
-size_t strlcpy(char *dst, const char *src, size_t siz);
-# endif
-# if !HAVE_DECL_STRLCAT
-size_t strlcat(char *dst, const char *src, size_t siz);
-# endif
-# if !HAVE_DECL_ARC4RANDOM && defined(HAVE_ARC4RANDOM)
-uint32_t arc4random(void);
-# endif
-# if !HAVE_DECL_ARC4RANDOM_UNIFORM && defined(HAVE_ARC4RANDOM_UNIFORM)
-uint32_t arc4random_uniform(uint32_t upper_bound);
-# endif
-#endif /* HAVE_LIBRESSL */
-#ifndef HAVE_ARC4RANDOM
-int getentropy(void* buf, size_t len);
-uint32_t arc4random(void);
-void arc4random_buf(void* buf, size_t n);
-void _ARC4_LOCK(void);
-void _ARC4_UNLOCK(void);
-void _ARC4_LOCK_DESTROY(void);
-#endif
-#ifndef HAVE_ARC4RANDOM_UNIFORM
-uint32_t arc4random_uniform(uint32_t upper_bound);
-#endif
-#ifdef COMPAT_SHA512
-#ifndef SHA512_DIGEST_LENGTH
-#define SHA512_BLOCK_LENGTH 128
-#define SHA512_DIGEST_LENGTH 64
-#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
-typedef struct _SHA512_CTX {
- uint64_t state[8];
- uint64_t bitcount[2];
- uint8_t buffer[SHA512_BLOCK_LENGTH];
-} SHA512_CTX;
-#endif /* SHA512_DIGEST_LENGTH */
-void SHA512_Init(SHA512_CTX*);
-void SHA512_Update(SHA512_CTX*, void*, size_t);
-void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
-unsigned char *SHA512(void* data, unsigned int data_len, unsigned char *digest);
-#endif /* COMPAT_SHA512 */
-
-
-
-#if defined(HAVE_EVENT_H) && !defined(HAVE_EVENT_BASE_ONCE) && !(defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)) && (defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS))
- /* using version of libevent that is not threadsafe. */
-# define LIBEVENT_SIGNAL_PROBLEM 1
-#endif
-
-#ifndef CHECKED_INET6
-# define CHECKED_INET6
-# ifdef AF_INET6
-# define INET6
-# else
-# define AF_INET6 28
-# endif
-#endif /* CHECKED_INET6 */
-
-#ifndef HAVE_GETADDRINFO
-struct sockaddr_storage;
-#include "compat/fake-rfc2553.h"
-#endif
-
-#ifdef UNBOUND_ALLOC_STATS
-# define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__)
-# define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__)
-# define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__)
-# define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__)
-void *unbound_stat_malloc(size_t size);
-void *unbound_stat_calloc(size_t nmemb, size_t size);
-void unbound_stat_free(void *ptr);
-void *unbound_stat_realloc(void *ptr, size_t size);
-void *unbound_stat_malloc_log(size_t size, const char* file, int line,
- const char* func);
-void *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file,
- int line, const char* func);
-void unbound_stat_free_log(void *ptr, const char* file, int line,
- const char* func);
-void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file,
- int line, const char* func);
-#elif defined(UNBOUND_ALLOC_LITE)
-# include "util/alloc.h"
-#endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */
-
-/** default port for DNS traffic. */
-#define UNBOUND_DNS_PORT 53
-/** default port for DNS over TLS traffic. */
-#define UNBOUND_DNS_OVER_TLS_PORT 853
-/** default port for DNS over HTTPS traffic. */
-#define UNBOUND_DNS_OVER_HTTPS_PORT 443
-/** default port for unbound control traffic, registered port with IANA,
- ub-dns-control 8953/tcp unbound dns nameserver control */
-#define UNBOUND_CONTROL_PORT 8953
-/** the version of unbound-control that this software implements */
-#define UNBOUND_CONTROL_VERSION 1
-
-
diff --git a/usr.sbin/unbound/control/Makefile b/usr.sbin/unbound/control/Makefile
index eeadc753f5dd..ad5f7eb21f09 100644
--- a/usr.sbin/unbound/control/Makefile
+++ b/usr.sbin/unbound/control/Makefile
@@ -1,15 +1,15 @@
-# $FreeBSD$
# Vendor sources and generated files
LDNSDIR= ${SRCTOP}/contrib/ldns
UNBOUNDDIR= ${SRCTOP}/contrib/unbound
+LIBUNBOUNDDIR=${SRCTOP}/lib/libunbound
.PATH: ${UNBOUNDDIR} ${UNBOUNDDIR}/smallapp ${UNBOUNDDIR}/util ${UNBOUNDDIR}/doc
PROG= local-unbound-control
SRCS= ub_event.c unbound-control.c worker_cb.c
CFLAGS+= -I${UNBOUNDDIR} -I${LDNSDIR}
-CFLAGS+= -I${.CURDIR:H} -I${.CURDIR}
+CFLAGS+= -I${LIBUNBOUNDDIR} -I${.CURDIR}
LIBADD= unbound crypto ssl pthread
MAN= local-unbound-control.8
diff --git a/usr.sbin/unbound/control/Makefile.depend b/usr.sbin/unbound/control/Makefile.depend
index 37b991b9f24c..cba3180a2127 100644
--- a/usr.sbin/unbound/control/Makefile.depend
+++ b/usr.sbin/unbound/control/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/unbound/daemon/Makefile b/usr.sbin/unbound/daemon/Makefile
index ee251acee85f..28b451aa5061 100644
--- a/usr.sbin/unbound/daemon/Makefile
+++ b/usr.sbin/unbound/daemon/Makefile
@@ -1,8 +1,8 @@
-# $FreeBSD$
# Vendor sources and generated files
LDNSDIR= ${SRCTOP}/contrib/ldns
UNBOUNDDIR= ${SRCTOP}/contrib/unbound
+LIBUNBOUNDDIR=${SRCTOP}/lib/libunbound
.PATH: ${UNBOUNDDIR} ${UNBOUNDDIR}/daemon ${UNBOUNDDIR}/util ${UNBOUNDDIR}/util/shm_side ${UNBOUNDDIR}/doc
@@ -10,7 +10,7 @@ PROG= local-unbound
SRCS= acl_list.c cachedump.c daemon.c remote.c shm_main.c stats.c \
ub_event.c unbound.c worker.c
CFLAGS+= -I${UNBOUNDDIR} -I${LDNSDIR}
-CFLAGS+= -I${.CURDIR:H} -I${.CURDIR}
+CFLAGS+= -I${LIBUNBOUNDDIR} -I${.CURDIR}
LIBADD= unbound util ssl crypto pthread
MAN= local-unbound.8 local-unbound.conf.5
diff --git a/usr.sbin/unbound/daemon/Makefile.depend b/usr.sbin/unbound/daemon/Makefile.depend
index fb63d6473d7b..a2b6d15f808f 100644
--- a/usr.sbin/unbound/daemon/Makefile.depend
+++ b/usr.sbin/unbound/daemon/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/unbound/setup/Makefile b/usr.sbin/unbound/setup/Makefile
index 7a1bc0441939..b7b811238b9c 100644
--- a/usr.sbin/unbound/setup/Makefile
+++ b/usr.sbin/unbound/setup/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SCRIPTS= local-unbound-setup.sh
MAN= #
diff --git a/usr.sbin/unbound/setup/Makefile.depend b/usr.sbin/unbound/setup/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/unbound/setup/Makefile.depend
+++ b/usr.sbin/unbound/setup/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/unbound/setup/local-unbound-setup.sh b/usr.sbin/unbound/setup/local-unbound-setup.sh
index 3be78339b0ba..d52534b46fa3 100755
--- a/usr.sbin/unbound/setup/local-unbound-setup.sh
+++ b/usr.sbin/unbound/setup/local-unbound-setup.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#-
-# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2013 Dag-Erling Smørgrav
# All rights reserved.
@@ -26,7 +26,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
D="${DESTDIR}"
@@ -195,7 +194,7 @@ do_not_edit() {
gen_resolvconf_conf() {
local style="$1"
do_not_edit
- echo "resolv_conf=\"/dev/null\" # prevent updating ${resolv_conf}"
+ echo "libc=\"NO\""
if [ "${style}" = "dynamic" ] ; then
echo "unbound_conf=\"${forward_conf}\""
echo "unbound_pid=\"${pidfile}\""
@@ -260,7 +259,7 @@ gen_unbound_conf() {
echo " pidfile: ${pidfile}"
echo " auto-trust-anchor-file: ${anchor}"
if [ "${use_tls}" = "yes" ] ; then
- echo " tls-cert-bundle: /etc/ssl/cert.pem"
+ echo " tls-system-cert: yes"
fi
echo ""
if [ -f "${forward_conf}" ] ; then
diff --git a/usr.sbin/usbconfig/Makefile b/usr.sbin/usbconfig/Makefile
index bfc4b6354d2a..55a222d7ee4a 100644
--- a/usr.sbin/usbconfig/Makefile
+++ b/usr.sbin/usbconfig/Makefile
@@ -1,5 +1,4 @@
#
-# $FreeBSD$
#
PROG= usbconfig
MAN= usbconfig.8
diff --git a/usr.sbin/usbconfig/Makefile.depend b/usr.sbin/usbconfig/Makefile.depend
index a93901938c4b..34fbfadfcfb6 100644
--- a/usr.sbin/usbconfig/Makefile.depend
+++ b/usr.sbin/usbconfig/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/libthr \
lib/libusb \
diff --git a/usr.sbin/usbconfig/dump.c b/usr.sbin/usbconfig/dump.c
index 4a52ab9fd85e..36f026bfc2fb 100644
--- a/usr.sbin/usbconfig/dump.c
+++ b/usr.sbin/usbconfig/dump.c
@@ -1,8 +1,8 @@
-/* $FreeBSD$ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2024 Baptiste Daroussin <bapt@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,6 +26,8 @@
* SUCH DAMAGE.
*/
+#include <sys/queue.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -39,12 +41,28 @@
#include <libusb20_desc.h>
#include "dump.h"
+#include "pathnames.h"
#define DUMP0(n,type,field,...) dump_field(pdev, " ", #field, n->field);
#define DUMP1(n,type,field,...) dump_field(pdev, " ", #field, n->field);
#define DUMP2(n,type,field,...) dump_field(pdev, " ", #field, n->field);
#define DUMP3(n,type,field,...) dump_field(pdev, " ", #field, n->field);
+struct usb_product_info {
+ STAILQ_ENTRY(usb_product_info) link;
+ int id;
+ char *desc;
+};
+
+struct usb_vendor_info {
+ STAILQ_ENTRY(usb_vendor_info) link;
+ STAILQ_HEAD(,usb_product_info) devs;
+ int id;
+ char *desc;
+};
+
+STAILQ_HEAD(usb_vendors, usb_vendor_info);
+
const char *
dump_mode(uint8_t value)
{
@@ -264,7 +282,6 @@ dump_extra(struct libusb20_me_struct *str, const char *plevel)
}
printf("\n");
}
- return;
}
static void
@@ -276,7 +293,6 @@ dump_endpoint(struct libusb20_device *pdev,
edesc = &ep->desc;
LIBUSB20_ENDPOINT_DESC(DUMP3, edesc);
dump_extra(&ep->extra, " " " " " ");
- return;
}
static void
@@ -294,7 +310,131 @@ dump_iface(struct libusb20_device *pdev,
printf("\n Endpoint %u\n", z);
dump_endpoint(pdev, iface->endpoints + z);
}
- return;
+}
+
+static struct usb_vendors *
+load_vendors(void)
+{
+ const char *dbf;
+ FILE *db = NULL;
+ struct usb_vendor_info *cv;
+ struct usb_product_info *cd;
+ struct usb_vendors *usb_vendors;
+ char buf[1024], str[1024];
+ char *ch;
+ int id;
+
+ usb_vendors = malloc(sizeof(*usb_vendors));
+ if (usb_vendors == NULL)
+ err(1, "out of memory");
+ STAILQ_INIT(usb_vendors);
+ if ((dbf = getenv("USB_VENDOR_DATABASE")) != NULL)
+ db = fopen(dbf, "r");
+ if (db == NULL) {
+ dbf = _PATH_LUSBVDB;
+ if ((db = fopen(dbf, "r")) == NULL) {
+ dbf = _PATH_USBVDB;
+ if ((db = fopen(dbf, "r")) == NULL)
+ return (usb_vendors);
+ }
+ }
+ cv = NULL;
+ cd = NULL;
+
+ for (;;) {
+ if (fgets(buf, sizeof(buf), db) == NULL)
+ break;
+
+ if ((ch = strchr(buf, '#')) != NULL)
+ *ch = '\0';
+ if (ch == buf)
+ continue;
+ ch = strchr(buf, '\0') - 1;
+ while (ch > buf && isspace(*ch))
+ *ch-- = '\0';
+ if (ch <= buf)
+ continue;
+
+ /* Can't handle subvendor / subdevice entries yet */
+ if (buf[0] == '\t' && buf[1] == '\t')
+ continue;
+
+ /* Check for vendor entry */
+ if (buf[0] != '\t' && sscanf(buf, "%04x %[^\n]", &id, str) == 2) {
+ if ((id == 0) || (strlen(str) < 1))
+ continue;
+ if ((cv = malloc(sizeof(struct usb_vendor_info))) == NULL)
+ err(1, "out of memory");
+ if ((cv->desc = strdup(str)) == NULL)
+ err(1, "out of memory");
+ cv->id = id;
+ STAILQ_INIT(&cv->devs);
+ STAILQ_INSERT_TAIL(usb_vendors, cv, link);
+ continue;
+ }
+
+ /* Check for device entry */
+ if (buf[0] == '\t' && sscanf(buf + 1, "%04x %[^\n]", &id, str) == 2) {
+ if ((id == 0) || (strlen(str) < 1))
+ continue;
+ if (cv == NULL)
+ continue;
+ if ((cd = malloc(sizeof(struct usb_product_info))) == NULL)
+ err(1, "out of memory");
+ if ((cd->desc = strdup(str)) == NULL)
+ err(1, "out of memory");
+ cd->id = id;
+ STAILQ_INSERT_TAIL(&cv->devs, cd, link);
+ continue;
+ }
+ }
+ if (ferror(db))
+ err(1, "error reading the usb id db");
+
+ fclose(db);
+ /* cleanup */
+ return (usb_vendors);
+}
+
+static char *
+_device_desc(struct libusb20_device *pdev)
+{
+ static struct usb_vendors *usb_vendors = NULL;
+ char *desc = NULL;
+ const char *vendor = NULL, *product = NULL;
+ uint16_t vid = libusb20_dev_get_device_desc(pdev)->idVendor;
+ uint16_t pid = libusb20_dev_get_device_desc(pdev)->idProduct;
+ struct usb_vendor_info *vi;
+ struct usb_product_info *pi;
+
+ if (usb_vendors == NULL)
+ usb_vendors = load_vendors();
+
+ STAILQ_FOREACH(vi, usb_vendors, link) {
+ if (vi->id == vid) {
+ vendor = vi->desc;
+ break;
+ }
+ }
+ if (vi != NULL) {
+ STAILQ_FOREACH(pi, &vi->devs, link) {
+ if (pi->id == pid) {
+ product = pi->desc;
+ break;
+ }
+ }
+ }
+ if (vendor == NULL || product == NULL)
+ return (NULL);
+
+ asprintf(&desc, "ugen%u.%u: <%s %s> at usbus%u",
+ libusb20_dev_get_bus_number(pdev),
+ libusb20_dev_get_address(pdev),
+ product, vendor,
+ libusb20_dev_get_bus_number(pdev));
+
+
+ return (desc);
}
void
@@ -303,16 +443,20 @@ dump_device_info(struct libusb20_device *pdev, uint8_t show_ifdrv)
char buf[128];
uint8_t n;
unsigned int usage;
+ char *desc;
usage = libusb20_dev_get_power_usage(pdev);
+ desc = _device_desc(pdev);
+
printf("%s, cfg=%u md=%s spd=%s pwr=%s (%umA)\n",
- libusb20_dev_get_desc(pdev),
+ desc ? desc : libusb20_dev_get_desc(pdev),
libusb20_dev_get_config_index(pdev),
dump_mode(libusb20_dev_get_mode(pdev)),
dump_speed(libusb20_dev_get_speed(pdev)),
dump_power_mode(libusb20_dev_get_power_mode(pdev)),
usage);
+ free(desc);
if (!show_ifdrv)
return;
@@ -353,7 +497,6 @@ dump_be_quirk_names(struct libusb20_backend *pbe)
printf("%s\n", q.quirkname);
}
printf("\n");
- return;
}
void
@@ -385,7 +528,6 @@ dump_be_dev_quirks(struct libusb20_backend *pbe)
}
}
printf("\n");
- return;
}
void
@@ -395,7 +537,6 @@ dump_device_desc(struct libusb20_device *pdev)
ddesc = libusb20_dev_get_device_desc(pdev);
LIBUSB20_DEVICE_DESC(DUMP0, ddesc);
- return;
}
void
@@ -444,7 +585,6 @@ dump_config(struct libusb20_device *pdev, uint8_t all_cfg)
printf("\n");
free(pcfg);
}
- return;
}
void
diff --git a/usr.sbin/usbconfig/dump.h b/usr.sbin/usbconfig/dump.h
index d7fe12866282..71adb47262ea 100644
--- a/usr.sbin/usbconfig/dump.h
+++ b/usr.sbin/usbconfig/dump.h
@@ -1,6 +1,5 @@
-/* $FreeBSD$ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
*
diff --git a/usr.sbin/usbconfig/pathnames.h b/usr.sbin/usbconfig/pathnames.h
new file mode 100644
index 000000000000..66053a9a87c5
--- /dev/null
+++ b/usr.sbin/usbconfig/pathnames.h
@@ -0,0 +1,4 @@
+#include <paths.h>
+
+#define _PATH_USBVDB "/usr/share/misc/usb_vendors"
+#define _PATH_LUSBVDB _PATH_LOCALBASE "/share/usbids/usb.ids"
diff --git a/usr.sbin/usbconfig/usbconfig.8 b/usr.sbin/usbconfig/usbconfig.8
index 0cc2f25d9bf8..3926b03747e5 100644
--- a/usr.sbin/usbconfig/usbconfig.8
+++ b/usr.sbin/usbconfig/usbconfig.8
@@ -1,4 +1,3 @@
-.\" $FreeBSD$
.\"
.\" Copyright (c) 2008-2019 Hans Petter Selasky. All rights reserved.
.\"
diff --git a/usr.sbin/usbconfig/usbconfig.c b/usr.sbin/usbconfig/usbconfig.c
index 81112d957bbb..7d257fea52cd 100644
--- a/usr.sbin/usbconfig/usbconfig.c
+++ b/usr.sbin/usbconfig/usbconfig.c
@@ -1,6 +1,5 @@
-/* $FreeBSD$ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008-2009 Hans Petter Selasky. All rights reserved.
*
@@ -182,7 +181,6 @@ be_dev_remove_quirk(struct libusb20_backend *pbe,
if (error) {
fprintf(stderr, "Removing quirk '%s' failed, continuing.\n", str);
}
- return;
}
static void
@@ -205,7 +203,6 @@ be_dev_add_quirk(struct libusb20_backend *pbe,
if (error) {
fprintf(stderr, "Adding quirk '%s' failed, continuing.\n", str);
}
- return;
}
static uint8_t
@@ -312,7 +309,6 @@ reset_options(struct options *opt)
if (opt->buffer)
free(opt->buffer);
memset(opt, 0, sizeof(*opt));
- return;
}
static void
@@ -542,8 +538,6 @@ flush_command(struct libusb20_backend *pbe, struct options *opt)
}
done:
reset_options(opt);
-
- return;
}
int
diff --git a/usr.sbin/usbdump/Makefile b/usr.sbin/usbdump/Makefile
index d42c9b6326cb..fd57c087c998 100644
--- a/usr.sbin/usbdump/Makefile
+++ b/usr.sbin/usbdump/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= usbdump
SRCS= usbdump.c
diff --git a/usr.sbin/usbdump/Makefile.depend b/usr.sbin/usbdump/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/usbdump/Makefile.depend
+++ b/usr.sbin/usbdump/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/usbdump/usbdump.8 b/usr.sbin/usbdump/usbdump.8
index 6b5ad1920e94..33b759e3406d 100644
--- a/usr.sbin/usbdump/usbdump.8
+++ b/usr.sbin/usbdump/usbdump.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 14, 2021
.Dt USBDUMP 8
.Os
diff --git a/usr.sbin/usbdump/usbdump.c b/usr.sbin/usbdump/usbdump.c
index 3c4f93f80c72..9c4b6c67c07d 100644
--- a/usr.sbin/usbdump/usbdump.c
+++ b/usr.sbin/usbdump/usbdump.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2010 Weongyo Jeong <weongyo@freebsd.org>
* All rights reserved.
@@ -27,8 +27,6 @@
* 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 DAMAGES.
- *
- * $FreeBSD$
*/
#include <sys/param.h>
diff --git a/usr.sbin/utx/Makefile b/usr.sbin/utx/Makefile
index 8177d3fe7832..98ba06acb92e 100644
--- a/usr.sbin/utx/Makefile
+++ b/usr.sbin/utx/Makefile
@@ -1,6 +1,5 @@
-# $FreeBSD$
-PACKAGE= runtime
+PACKAGE= acct
PROG= utx
MAN= utx.8
diff --git a/usr.sbin/utx/Makefile.depend b/usr.sbin/utx/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/utx/Makefile.depend
+++ b/usr.sbin/utx/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/utx/utx.8 b/usr.sbin/utx/utx.8
index 21794964add3..ddcdcc08b2d2 100644
--- a/usr.sbin/utx/utx.8
+++ b/usr.sbin/utx/utx.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd November 3, 2013
.Dt UTX 8
.Os
diff --git a/usr.sbin/utx/utx.c b/usr.sbin/utx/utx.c
index 75a3e00ef7e3..ab40668a0926 100644
--- a/usr.sbin/utx/utx.c
+++ b/usr.sbin/utx/utx.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011-2012 Ed Schouten <ed@FreeBSD.org>
* All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/time.h>
#include <errno.h>
#include <ctype.h>
diff --git a/usr.sbin/valectl/Makefile b/usr.sbin/valectl/Makefile
index f9322fa05047..5ecc5fac7ca8 100644
--- a/usr.sbin/valectl/Makefile
+++ b/usr.sbin/valectl/Makefile
@@ -1,5 +1,5 @@
-# $FreeBSD$
+PACKAGE= netmap
PROG= valectl
MAN= valectl.8
diff --git a/usr.sbin/valectl/valectl.8 b/usr.sbin/valectl/valectl.8
index 83bddea9207f..deb660bb0e4a 100644
--- a/usr.sbin/valectl/valectl.8
+++ b/usr.sbin/valectl/valectl.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 2, 2021
.Dt VALECTL 8
.Os
diff --git a/usr.sbin/valectl/valectl.c b/usr.sbin/valectl/valectl.c
index bf1bc6229fb8..0e4dffd34290 100644
--- a/usr.sbin/valectl/valectl.c
+++ b/usr.sbin/valectl/valectl.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-/* $FreeBSD$ */
#define LIBNETMAP_NOTHREADSAFE
#include <libnetmap.h>
diff --git a/usr.sbin/vidcontrol/Makefile b/usr.sbin/vidcontrol/Makefile
index 8c8f6bb804b2..47a8e01362fe 100644
--- a/usr.sbin/vidcontrol/Makefile
+++ b/usr.sbin/vidcontrol/Makefile
@@ -1,5 +1,5 @@
-# $FreeBSD$
+PACKAGE= console-tools
PROG= vidcontrol
SRCS= vidcontrol.c decode.c
diff --git a/usr.sbin/vidcontrol/Makefile.depend b/usr.sbin/vidcontrol/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/vidcontrol/Makefile.depend
+++ b/usr.sbin/vidcontrol/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/vidcontrol/decode.c b/usr.sbin/vidcontrol/decode.c
index 160a6ca92e98..9db7c537a19f 100644
--- a/usr.sbin/vidcontrol/decode.c
+++ b/usr.sbin/vidcontrol/decode.c
@@ -28,11 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <stdio.h>
#include <string.h>
#include "decode.h"
diff --git a/usr.sbin/vidcontrol/decode.h b/usr.sbin/vidcontrol/decode.h
index 1f1cba4a4720..b4dba1ba391e 100644
--- a/usr.sbin/vidcontrol/decode.h
+++ b/usr.sbin/vidcontrol/decode.h
@@ -1,3 +1,2 @@
-/* $FreeBSD$ */
int decode(FILE *fd, char *buffer, int len);
diff --git a/usr.sbin/vidcontrol/path.h b/usr.sbin/vidcontrol/path.h
index e1fa341e0c78..12ea4a5b3f66 100644
--- a/usr.sbin/vidcontrol/path.h
+++ b/usr.sbin/vidcontrol/path.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#define KEYMAP_PATH "/usr/share/syscons/keymaps/"
#define FONT_PATH "/usr/share/syscons/fonts/"
diff --git a/usr.sbin/vidcontrol/vidcontrol.1 b/usr.sbin/vidcontrol/vidcontrol.1
index 6eee089c1972..44e0950294cb 100644
--- a/usr.sbin/vidcontrol/vidcontrol.1
+++ b/usr.sbin/vidcontrol/vidcontrol.1
@@ -10,9 +10,6 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" @(#)vidcontrol.1
-.\" $FreeBSD$
-.\"
.Dd April 6, 2022
.Dt VIDCONTROL 1
.Os
diff --git a/usr.sbin/vidcontrol/vidcontrol.c b/usr.sbin/vidcontrol/vidcontrol.c
index 3e0ab102ae8c..e4cf1e8efc53 100644
--- a/usr.sbin/vidcontrol/vidcontrol.c
+++ b/usr.sbin/vidcontrol/vidcontrol.c
@@ -33,11 +33,6 @@
* $DragonFly: src/usr.sbin/vidcontrol/vidcontrol.c,v 1.10 2005/03/02 06:08:29 joerg Exp $
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <ctype.h>
#include <err.h>
#include <limits.h>
diff --git a/usr.sbin/vigr/Makefile b/usr.sbin/vigr/Makefile
index 52b548e57ca1..575b2aa5e39b 100644
--- a/usr.sbin/vigr/Makefile
+++ b/usr.sbin/vigr/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SCRIPTS= vigr
MAN= vigr.8
diff --git a/usr.sbin/vigr/Makefile.depend b/usr.sbin/vigr/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/vigr/Makefile.depend
+++ b/usr.sbin/vigr/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/vigr/vigr.8 b/usr.sbin/vigr/vigr.8
index 3fd582b2cd98..3a8e9c92b83f 100644
--- a/usr.sbin/vigr/vigr.8
+++ b/usr.sbin/vigr/vigr.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 14, 2014
.Dt VIGR 8
.Os
diff --git a/usr.sbin/vigr/vigr.sh b/usr.sbin/vigr/vigr.sh
index c5dc65d8be18..ed84cfbb277e 100644
--- a/usr.sbin/vigr/vigr.sh
+++ b/usr.sbin/vigr/vigr.sh
@@ -24,7 +24,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD$
#
error() {
diff --git a/usr.sbin/vipw/Makefile b/usr.sbin/vipw/Makefile
index f36825de6df9..17ffd4859bf6 100644
--- a/usr.sbin/vipw/Makefile
+++ b/usr.sbin/vipw/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
PROG= vipw
MAN= vipw.8
diff --git a/usr.sbin/vipw/Makefile.depend b/usr.sbin/vipw/Makefile.depend
index 991757ecadc0..678747db6f2c 100644
--- a/usr.sbin/vipw/Makefile.depend
+++ b/usr.sbin/vipw/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/vipw/vipw.8 b/usr.sbin/vipw/vipw.8
index 85d09b41efda..836c49b87291 100644
--- a/usr.sbin/vipw/vipw.8
+++ b/usr.sbin/vipw/vipw.8
@@ -25,10 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)vipw.8 8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
-.\"
-.Dd February 14, 2012
+.Dd November 12, 2022
.Dt VIPW 8
.Os
.Sh NAME
@@ -98,6 +95,19 @@ password file.
See
.Xr pwd_mkdb 8 .
.El
+.Sh FILES
+.Bl -tag -width "/etc/master.passwdXXX" -compact
+.It Pa /etc/master.passwd
+Current password file.
+.It Pa /etc/passwd
+Legacy password file.
+.It Pa /etc/ptmp
+Password lock file.
+.It Pa /etc/pwd.db
+Insecure password database file.
+.It Pa /etc/spwd.db
+Secure password database file.
+.El
.Sh SEE ALSO
.Xr chpass 1 ,
.Xr passwd 1 ,
diff --git a/usr.sbin/vipw/vipw.c b/usr.sbin/vipw/vipw.c
index 09d37ea440d0..7e5e760bf3c5 100644
--- a/usr.sbin/vipw/vipw.c
+++ b/usr.sbin/vipw/vipw.c
@@ -36,20 +36,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1987, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)vipw.c 8.3 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/usr.sbin/wake/Makefile b/usr.sbin/wake/Makefile
index f75d4693d1b5..5da46d9880f4 100644
--- a/usr.sbin/wake/Makefile
+++ b/usr.sbin/wake/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= wake
MAN= wake.8
diff --git a/usr.sbin/wake/Makefile.depend b/usr.sbin/wake/Makefile.depend
index 6cfaab1c3644..6ef78fac5cbf 100644
--- a/usr.sbin/wake/Makefile.depend
+++ b/usr.sbin/wake/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/wake/wake.8 b/usr.sbin/wake/wake.8
index e08acbc8d15b..ee9a0cc9a8e9 100644
--- a/usr.sbin/wake/wake.8
+++ b/usr.sbin/wake/wake.8
@@ -1,6 +1,4 @@
.\"
-.\" $FreeBSD$
-.\"
.\" Copyright (c) 2009, 2010 Marc Balmer <marc@msys.ch>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
diff --git a/usr.sbin/wake/wake.c b/usr.sbin/wake/wake.c
index ca600e1d9884..7b3a87c01033 100644
--- a/usr.sbin/wake/wake.c
+++ b/usr.sbin/wake/wake.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (C) 2006, 2007, 2008, 2009, 2010 Marc Balmer <marc@msys.ch>
* Copyright (C) 2000 Eugene M. Kim. All rights reserved.
@@ -27,8 +27,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
diff --git a/usr.sbin/watch/Makefile b/usr.sbin/watch/Makefile
index 215ff61e9004..9bf1f6857128 100644
--- a/usr.sbin/watch/Makefile
+++ b/usr.sbin/watch/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= watch
MAN= watch.8
diff --git a/usr.sbin/watch/Makefile.depend b/usr.sbin/watch/Makefile.depend
index 9b2a343de2dc..dd06faaab7bf 100644
--- a/usr.sbin/watch/Makefile.depend
+++ b/usr.sbin/watch/Makefile.depend
@@ -1,14 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/ncurses/ncursesw \
+ lib/ncurses/tinfo \
.include <dirdeps.mk>
diff --git a/usr.sbin/watch/watch.8 b/usr.sbin/watch/watch.8
index 9a5485fcf61f..7acd79df8710 100644
--- a/usr.sbin/watch/watch.8
+++ b/usr.sbin/watch/watch.8
@@ -1,6 +1,4 @@
.\"
-.\" $FreeBSD$
-.\"
.Dd November 24, 2001
.Dt WATCH 8
.Os
diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c
index 85583882ea4e..fd1b98d8f4a3 100644
--- a/usr.sbin/watch/watch.c
+++ b/usr.sbin/watch/watch.c
@@ -13,9 +13,6 @@
* Snoop stuff.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/fcntl.h>
#include <sys/filio.h>
diff --git a/usr.sbin/watchdogd/Makefile b/usr.sbin/watchdogd/Makefile
index bce983f6a92c..1ba414f79846 100644
--- a/usr.sbin/watchdogd/Makefile
+++ b/usr.sbin/watchdogd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= watchdogd
LINKS= ${BINDIR}/watchdogd ${BINDIR}/watchdog
diff --git a/usr.sbin/watchdogd/Makefile.depend b/usr.sbin/watchdogd/Makefile.depend
index a015e205da56..af3b7054df7a 100644
--- a/usr.sbin/watchdogd/Makefile.depend
+++ b/usr.sbin/watchdogd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/watchdogd/watchdog.8 b/usr.sbin/watchdogd/watchdog.8
index 9d041f539e16..4695054e52dd 100644
--- a/usr.sbin/watchdogd/watchdog.8
+++ b/usr.sbin/watchdogd/watchdog.8
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd October 18, 2014
.Dt WATCHDOG 8
.Os
diff --git a/usr.sbin/watchdogd/watchdogd.8 b/usr.sbin/watchdogd/watchdogd.8
index fe5bba6ff610..debc03b8bbba 100644
--- a/usr.sbin/watchdogd/watchdogd.8
+++ b/usr.sbin/watchdogd/watchdogd.8
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 11, 2015
.Dt WATCHDOGD 8
.Os
diff --git a/usr.sbin/watchdogd/watchdogd.c b/usr.sbin/watchdogd/watchdogd.c
index a926c0d25388..88b467486da1 100644
--- a/usr.sbin/watchdogd/watchdogd.c
+++ b/usr.sbin/watchdogd/watchdogd.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2003-2004 Sean M. Kelly <smkelly@FreeBSD.org>
* Copyright (c) 2013 iXsystems.com,
@@ -34,8 +34,6 @@
*/
#include <sys/types.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/rtprio.h>
diff --git a/usr.sbin/wlandebug/Makefile b/usr.sbin/wlandebug/Makefile
index d03fa4a07f82..fe694847cf72 100644
--- a/usr.sbin/wlandebug/Makefile
+++ b/usr.sbin/wlandebug/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= wlandebug
MAN= wlandebug.8
diff --git a/usr.sbin/wlandebug/Makefile.depend b/usr.sbin/wlandebug/Makefile.depend
index 37b288fd73d8..b4ac94747265 100644
--- a/usr.sbin/wlandebug/Makefile.depend
+++ b/usr.sbin/wlandebug/Makefile.depend
@@ -1,14 +1,13 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libifconfig \
+ lib/msun \
.include <dirdeps.mk>
diff --git a/usr.sbin/wlandebug/wlandebug.8 b/usr.sbin/wlandebug/wlandebug.8
index 28fb904306e9..6a857306108b 100644
--- a/usr.sbin/wlandebug/wlandebug.8
+++ b/usr.sbin/wlandebug/wlandebug.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd August 17, 2015
.Dt WLANDEBUG 8
.Os
diff --git a/usr.sbin/wlandebug/wlandebug.c b/usr.sbin/wlandebug/wlandebug.c
index cc8698824880..b44d82d8dd1d 100644
--- a/usr.sbin/wlandebug/wlandebug.c
+++ b/usr.sbin/wlandebug/wlandebug.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
* All rights reserved.
@@ -27,8 +27,6 @@
* 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 DAMAGES.
- *
- * $FreeBSD$
*/
/*
@@ -55,7 +53,7 @@ const char *progname;
#define IEEE80211_MSG_11N 0x80000000 /* 11n mode debug */
#define IEEE80211_MSG_DEBUG 0x40000000 /* IFF_DEBUG equivalent */
-#define IEEE80211_MSG_DUMPPKTS 0x20000000 /* IFF_LINK2 equivalant */
+#define IEEE80211_MSG_DUMPPKTS 0x20000000 /* IFF_LINK2 equivalent */
#define IEEE80211_MSG_CRYPTO 0x10000000 /* crypto work */
#define IEEE80211_MSG_INPUT 0x08000000 /* input handling */
#define IEEE80211_MSG_XRATE 0x04000000 /* rate set handling */
diff --git a/usr.sbin/wpa/Makefile b/usr.sbin/wpa/Makefile
index be01cf7efdac..426c6aabab20 100644
--- a/usr.sbin/wpa/Makefile
+++ b/usr.sbin/wpa/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SUBDIR= src .WAIT \
wpa_supplicant \
diff --git a/usr.sbin/wpa/Makefile.crypto b/usr.sbin/wpa/Makefile.crypto
index 2046c32d76ac..7208a4b4fabf 100644
--- a/usr.sbin/wpa/Makefile.crypto
+++ b/usr.sbin/wpa/Makefile.crypto
@@ -1,4 +1,3 @@
-# $FreeBSD$
.if ${MK_OPENSSL} != "no"
LIBADD+= ssl crypto
diff --git a/usr.sbin/wpa/Makefile.depend b/usr.sbin/wpa/Makefile.depend
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/usr.sbin/wpa/Makefile.depend
diff --git a/usr.sbin/wpa/Makefile.depend.options b/usr.sbin/wpa/Makefile.depend.options
index fa96b2506b2c..b374d7a1fd52 100644
--- a/usr.sbin/wpa/Makefile.depend.options
+++ b/usr.sbin/wpa/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= OPENSSL
diff --git a/usr.sbin/wpa/Makefile.inc b/usr.sbin/wpa/Makefile.inc
index 5ce7dee4d2c5..ce4f1ec38b4b 100644
--- a/usr.sbin/wpa/Makefile.inc
+++ b/usr.sbin/wpa/Makefile.inc
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
@@ -6,7 +5,7 @@ BINDIR?= /usr/sbin
WARNS?= 0
-WPA_DISTDIR?= ${SRCTOP}/contrib/wpa/
+WPA_DISTDIR?= ${SRCTOP}/contrib/wpa
WPA_SUPPLICANT_DISTDIR?=${WPA_DISTDIR}/wpa_supplicant
HOSTAPD_DISTDIR?= ${WPA_DISTDIR}/hostapd
@@ -66,6 +65,7 @@ CFLAGS+=-DCONFIG_WNM
CFLAGS+=-DCONFIG_WNM_AP
CFLAGS+=-DCONFIG_MBO
CFLAGS+=-DCONFIG_RSN_PREAUTH
+CFLAGS+=-DCONFIG_WEP
.if ${MK_WPA_SUPPLICANT_EAPOL} != "no"
CFLAGS+=-DCONFIG_HS20 \
diff --git a/usr.sbin/wpa/hostapd/Makefile b/usr.sbin/wpa/hostapd/Makefile
index ce3b7d82fd69..04176419084f 100644
--- a/usr.sbin/wpa/hostapd/Makefile
+++ b/usr.sbin/wpa/hostapd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
.include "../Makefile.inc"
diff --git a/usr.sbin/wpa/hostapd/Makefile.depend b/usr.sbin/wpa/hostapd/Makefile.depend
index 59c29ce26572..422856c1631a 100644
--- a/usr.sbin/wpa/hostapd/Makefile.depend
+++ b/usr.sbin/wpa/hostapd/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -13,6 +11,18 @@ DIRDEPS = \
lib/libutil \
secure/lib/libcrypto \
secure/lib/libssl \
+ usr.sbin/wpa/src/ap \
+ usr.sbin/wpa/src/common \
+ usr.sbin/wpa/src/crypto \
+ usr.sbin/wpa/src/drivers \
+ usr.sbin/wpa/src/eap_common \
+ usr.sbin/wpa/src/eap_server \
+ usr.sbin/wpa/src/eapol_auth \
+ usr.sbin/wpa/src/l2_packet \
+ usr.sbin/wpa/src/radius \
+ usr.sbin/wpa/src/tls \
+ usr.sbin/wpa/src/utils \
+ usr.sbin/wpa/src/wps \
.include <dirdeps.mk>
diff --git a/usr.sbin/wpa/hostapd/hostapd.8 b/usr.sbin/wpa/hostapd/hostapd.8
index 9edbd65438c3..b60900249da1 100644
--- a/usr.sbin/wpa/hostapd/hostapd.8
+++ b/usr.sbin/wpa/hostapd/hostapd.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd July 18, 2012
.Dt HOSTAPD 8
.Os
@@ -116,7 +114,6 @@ Store PID in
.Xr rum 4 ,
.Xr run 4 ,
.Xr ural 4 ,
-.Xr wi 4 ,
.Xr hostapd.conf 5 ,
.Xr hostapd_cli 8 ,
.Xr ifconfig 8
diff --git a/usr.sbin/wpa/hostapd/hostapd.conf.5 b/usr.sbin/wpa/hostapd/hostapd.conf.5
index 217810713f53..d1f64e7487d5 100644
--- a/usr.sbin/wpa/hostapd/hostapd.conf.5
+++ b/usr.sbin/wpa/hostapd/hostapd.conf.5
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd September 2, 2006
.Dt HOSTAPD.CONF 5
.Os
diff --git a/usr.sbin/wpa/hostapd_cli/Makefile b/usr.sbin/wpa/hostapd_cli/Makefile
index fef18dab7b32..4c66c2078f4b 100644
--- a/usr.sbin/wpa/hostapd_cli/Makefile
+++ b/usr.sbin/wpa/hostapd_cli/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include "../Makefile.inc"
diff --git a/usr.sbin/wpa/hostapd_cli/Makefile.depend b/usr.sbin/wpa/hostapd_cli/Makefile.depend
index 4fc5be2a35f0..6f6eb0fd070e 100644
--- a/usr.sbin/wpa/hostapd_cli/Makefile.depend
+++ b/usr.sbin/wpa/hostapd_cli/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -10,6 +8,10 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libutil \
+ secure/lib/libcrypto \
+ secure/lib/libssl \
+ usr.sbin/wpa/src/common \
+ usr.sbin/wpa/src/utils \
.include <dirdeps.mk>
diff --git a/usr.sbin/wpa/hostapd_cli/hostapd_cli.8 b/usr.sbin/wpa/hostapd_cli/hostapd_cli.8
index 605a7f5d2a94..9b97e512f1e2 100644
--- a/usr.sbin/wpa/hostapd_cli/hostapd_cli.8
+++ b/usr.sbin/wpa/hostapd_cli/hostapd_cli.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd June 16, 2005
.Dt HOSTAPD_CLI 8
.Os
diff --git a/usr.sbin/wpa/src/ap/Makefile.depend b/usr.sbin/wpa/src/ap/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/ap/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/common/Makefile.depend b/usr.sbin/wpa/src/common/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/common/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/crypto/Makefile.depend b/usr.sbin/wpa/src/crypto/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/crypto/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/drivers/Makefile.depend b/usr.sbin/wpa/src/drivers/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/drivers/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/eap_common/Makefile.depend b/usr.sbin/wpa/src/eap_common/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/eap_common/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/eap_peer/Makefile.depend b/usr.sbin/wpa/src/eap_peer/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/eap_peer/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/eap_server/Makefile.depend b/usr.sbin/wpa/src/eap_server/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/eap_server/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/eapol_auth/Makefile.depend b/usr.sbin/wpa/src/eapol_auth/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/eapol_auth/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/eapol_supp/Makefile.depend b/usr.sbin/wpa/src/eapol_supp/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/eapol_supp/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/l2_packet/Makefile.depend b/usr.sbin/wpa/src/l2_packet/Makefile.depend
new file mode 100644
index 000000000000..31ec0d76c4b0
--- /dev/null
+++ b/usr.sbin/wpa/src/l2_packet/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/libpcap \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/radius/Makefile.depend b/usr.sbin/wpa/src/radius/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/radius/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/rsn_supp/Makefile.depend b/usr.sbin/wpa/src/rsn_supp/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/rsn_supp/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/tls/Makefile.depend b/usr.sbin/wpa/src/tls/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/tls/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/utils/Makefile.depend b/usr.sbin/wpa/src/utils/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/utils/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/src/wps/Makefile b/usr.sbin/wpa/src/wps/Makefile
index 5f5485d69bce..8890c34fb0a3 100644
--- a/usr.sbin/wpa/src/wps/Makefile
+++ b/usr.sbin/wpa/src/wps/Makefile
@@ -27,8 +27,6 @@ SRCS= http_client.c \
wps_upnp_ssdp.c \
wps_upnp_web.c
-CFLAGS+=-DCONFIG_P2P
-
.if ${MK_INET6} != "no"
CFLAGS+= -DCONFIG_IPV6
.endif
diff --git a/usr.sbin/wpa/src/wps/Makefile.depend b/usr.sbin/wpa/src/wps/Makefile.depend
new file mode 100644
index 000000000000..f2b0559818dd
--- /dev/null
+++ b/usr.sbin/wpa/src/wps/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/wpa_cli/Makefile b/usr.sbin/wpa/wpa_cli/Makefile
index 2aad727a6785..be5896e74d6d 100644
--- a/usr.sbin/wpa/wpa_cli/Makefile
+++ b/usr.sbin/wpa/wpa_cli/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/wpa/wpa_cli/Makefile.depend b/usr.sbin/wpa/wpa_cli/Makefile.depend
index 4fc5be2a35f0..99363d6b54b8 100644
--- a/usr.sbin/wpa/wpa_cli/Makefile.depend
+++ b/usr.sbin/wpa/wpa_cli/Makefile.depend
@@ -1,15 +1,28 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libpcap \
lib/libutil \
+ secure/lib/libcrypto \
+ secure/lib/libssl \
+ usr.sbin/wpa/src/common \
+ usr.sbin/wpa/src/crypto \
+ usr.sbin/wpa/src/eap_common \
+ usr.sbin/wpa/src/eap_peer \
+ usr.sbin/wpa/src/eap_server \
+ usr.sbin/wpa/src/eapol_auth \
+ usr.sbin/wpa/src/eapol_supp \
+ usr.sbin/wpa/src/l2_packet \
+ usr.sbin/wpa/src/radius \
+ usr.sbin/wpa/src/rsn_supp \
+ usr.sbin/wpa/src/tls \
+ usr.sbin/wpa/src/utils \
.include <dirdeps.mk>
diff --git a/usr.sbin/wpa/wpa_cli/wpa_cli.8 b/usr.sbin/wpa/wpa_cli/wpa_cli.8
index 68108c9a55ee..c484434f0b0c 100644
--- a/usr.sbin/wpa/wpa_cli/wpa_cli.8
+++ b/usr.sbin/wpa/wpa_cli/wpa_cli.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd January 24, 2017
.Dt WPA_CLI 8
.Os
diff --git a/usr.sbin/wpa/wpa_passphrase/Makefile b/usr.sbin/wpa/wpa_passphrase/Makefile
index 4cd540696d67..eeb71a31ec9d 100644
--- a/usr.sbin/wpa/wpa_passphrase/Makefile
+++ b/usr.sbin/wpa/wpa_passphrase/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include "../Makefile.inc"
diff --git a/usr.sbin/wpa/wpa_passphrase/Makefile.depend b/usr.sbin/wpa/wpa_passphrase/Makefile.depend
index 4fc5be2a35f0..98764f95ccff 100644
--- a/usr.sbin/wpa/wpa_passphrase/Makefile.depend
+++ b/usr.sbin/wpa/wpa_passphrase/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -10,6 +8,10 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libutil \
+ secure/lib/libcrypto \
+ secure/lib/libssl \
+ usr.sbin/wpa/src/crypto \
+ usr.sbin/wpa/src/utils \
.include <dirdeps.mk>
diff --git a/usr.sbin/wpa/wpa_passphrase/wpa_passphrase.8 b/usr.sbin/wpa/wpa_passphrase/wpa_passphrase.8
index b661a792dd73..56b1cc2eb15b 100644
--- a/usr.sbin/wpa/wpa_passphrase/wpa_passphrase.8
+++ b/usr.sbin/wpa/wpa_passphrase/wpa_passphrase.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd July 17, 2007
.Dt WPA_PASSPHRASE 8
.Os
diff --git a/usr.sbin/wpa/wpa_priv/Makefile b/usr.sbin/wpa/wpa_priv/Makefile
index d3b693341276..4ed75bd22511 100644
--- a/usr.sbin/wpa/wpa_priv/Makefile
+++ b/usr.sbin/wpa/wpa_priv/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include "../Makefile.inc"
diff --git a/usr.sbin/wpa/wpa_supplicant/Makefile b/usr.sbin/wpa/wpa_supplicant/Makefile
index fb045f804977..d82d18ac025e 100644
--- a/usr.sbin/wpa/wpa_supplicant/Makefile
+++ b/usr.sbin/wpa/wpa_supplicant/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/wpa/wpa_supplicant/Makefile.depend b/usr.sbin/wpa/wpa_supplicant/Makefile.depend
index 59c29ce26572..a7a98b651269 100644
--- a/usr.sbin/wpa/wpa_supplicant/Makefile.depend
+++ b/usr.sbin/wpa/wpa_supplicant/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -13,6 +11,18 @@ DIRDEPS = \
lib/libutil \
secure/lib/libcrypto \
secure/lib/libssl \
+ usr.sbin/wpa/src/common \
+ usr.sbin/wpa/src/crypto \
+ usr.sbin/wpa/src/drivers \
+ usr.sbin/wpa/src/eap_common \
+ usr.sbin/wpa/src/eap_peer \
+ usr.sbin/wpa/src/eap_server \
+ usr.sbin/wpa/src/eapol_supp \
+ usr.sbin/wpa/src/l2_packet \
+ usr.sbin/wpa/src/rsn_supp \
+ usr.sbin/wpa/src/tls \
+ usr.sbin/wpa/src/utils \
+ usr.sbin/wpa/src/wps \
.include <dirdeps.mk>
diff --git a/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.8 b/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.8
index 7ba6e4c2f8aa..9b51c3d8688c 100644
--- a/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.8
+++ b/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd July 28, 2018
.Dt WPA_SUPPLICANT 8
.Os
@@ -150,14 +148,12 @@ Display version information on the terminal and exit.
Wait for a control interface monitor before starting.
.El
.Sh SEE ALSO
-.Xr an 4 ,
.Xr ath 4 ,
.Xr ipw 4 ,
.Xr iwi 4 ,
.Xr ral 4 ,
.Xr rum 4 ,
.Xr ural 4 ,
-.Xr wi 4 ,
.Xr wlan 4 ,
.Xr wpi 4 ,
.Xr zyd 4 ,
diff --git a/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.5 b/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.5
index c22d3aa5da68..852d83f463ce 100644
--- a/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.5
+++ b/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.5
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd March 16, 2022
.Dt WPA_SUPPLICANT.CONF 5
.Os
diff --git a/usr.sbin/yp_mkdb/Makefile b/usr.sbin/yp_mkdb/Makefile
index 6ddbfdfd9b09..a556510b8b40 100644
--- a/usr.sbin/yp_mkdb/Makefile
+++ b/usr.sbin/yp_mkdb/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.PATH: ${SRCTOP}/libexec/ypxfr ${SRCTOP}/usr.sbin/ypserv
diff --git a/usr.sbin/yp_mkdb/Makefile.depend b/usr.sbin/yp_mkdb/Makefile.depend
index 85338ebe3beb..a2d89550fa2b 100644
--- a/usr.sbin/yp_mkdb/Makefile.depend
+++ b/usr.sbin/yp_mkdb/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/rpc \
include/rpcsvc \
diff --git a/usr.sbin/yp_mkdb/yp_mkdb.8 b/usr.sbin/yp_mkdb/yp_mkdb.8
index 2689f292332c..a5457f1cef4e 100644
--- a/usr.sbin/yp_mkdb/yp_mkdb.8
+++ b/usr.sbin/yp_mkdb/yp_mkdb.8
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd March 12, 1996
.Dt YP_MKDB 8
.Os
diff --git a/usr.sbin/yp_mkdb/yp_mkdb.c b/usr.sbin/yp_mkdb/yp_mkdb.c
index 19139c3dc61e..4e733325141a 100644
--- a/usr.sbin/yp_mkdb/yp_mkdb.c
+++ b/usr.sbin/yp_mkdb/yp_mkdb.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <err.h>
#include <fcntl.h>
#include <limits.h>
@@ -92,7 +90,6 @@ unwind(char *map)
(int)data.size, (char *)data.data);
(void)(dbp->close)(dbp);
- return;
}
int
diff --git a/usr.sbin/ypbind/Makefile b/usr.sbin/ypbind/Makefile
index 1a5844390810..27e041ebce5d 100644
--- a/usr.sbin/ypbind/Makefile
+++ b/usr.sbin/ypbind/Makefile
@@ -1,5 +1,3 @@
-# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
-# $FreeBSD$
PACKAGE= yp
PROG= ypbind
diff --git a/usr.sbin/ypbind/Makefile.depend b/usr.sbin/ypbind/Makefile.depend
index faed4b4cc2aa..732a025c9552 100644
--- a/usr.sbin/ypbind/Makefile.depend
+++ b/usr.sbin/ypbind/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
diff --git a/usr.sbin/ypbind/yp_ping.c b/usr.sbin/ypbind/yp_ping.c
index d65c5eb695e2..38fbd403245c 100644
--- a/usr.sbin/ypbind/yp_ping.c
+++ b/usr.sbin/ypbind/yp_ping.c
@@ -59,15 +59,6 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if 0
-#ifndef lint
-static char *sccsid = "@(#)from: clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)from: clnt_udp.c 2.2 88/08/01 4.0 RPCSRC";
-#endif
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* clnt_udp.c, Implements a UDP/IP based, client side RPC.
*
diff --git a/usr.sbin/ypbind/yp_ping.h b/usr.sbin/ypbind/yp_ping.h
index 80e6a7873011..09f88b9442ce 100644
--- a/usr.sbin/ypbind/yp_ping.h
+++ b/usr.sbin/ypbind/yp_ping.h
@@ -1,5 +1,4 @@
/*
- * $FreeBSD$
*/
extern int __yp_ping(struct in_addr *, int, char *, short *);
diff --git a/usr.sbin/ypbind/ypbind.8 b/usr.sbin/ypbind/ypbind.8
index 9b38ffcb3744..1089f79c5b39 100644
--- a/usr.sbin/ypbind/ypbind.8
+++ b/usr.sbin/ypbind/ypbind.8
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd April 9, 1995
.Dt YPBIND 8
.Os
diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c
index 60d439d32f09..2aacfa5c87d6 100644
--- a/usr.sbin/ypbind/ypbind.c
+++ b/usr.sbin/ypbind/ypbind.c
@@ -29,9 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -91,10 +88,6 @@ struct _dom_binding {
#define WRITEFD ypdb->dom_pipe_fds[1]
#define BROADFD broad_domain->dom_pipe_fds[1]
-extern bool_t xdr_domainname(), xdr_ypbind_resp();
-extern bool_t xdr_ypreq_key(), xdr_ypresp_val();
-extern bool_t xdr_ypbind_setdom();
-
void checkwork(void);
void *ypbindproc_null_2_yp(SVCXPRT *, void *, CLIENT *);
void *ypbindproc_setdom_2_yp(SVCXPRT *, struct ypbind_setdom *, CLIENT *);
@@ -301,21 +294,23 @@ ypbindprog_2(struct svc_req *rqstp, register SVCXPRT *transp)
struct ypbind_setdom ypbindproc_setdom_2_arg;
} argument;
struct authunix_parms *creds;
- char *result;
- bool_t (*xdr_argument)(), (*xdr_result)();
- char *(*local)();
+ void *result;
+ xdrproc_t xdr_argument, xdr_result;
+ typedef void *(svc_cb)(SVCXPRT *transp, void *arg,
+ struct svc_req *rqstp);
+ svc_cb *local;
switch (rqstp->rq_proc) {
case YPBINDPROC_NULL:
- xdr_argument = xdr_void;
- xdr_result = xdr_void;
- local = (char *(*)()) ypbindproc_null_2_yp;
+ xdr_argument = (xdrproc_t)xdr_void;
+ xdr_result = (xdrproc_t)xdr_void;
+ local = (svc_cb *)ypbindproc_null_2_yp;
break;
case YPBINDPROC_DOMAIN:
- xdr_argument = xdr_domainname;
- xdr_result = xdr_ypbind_resp;
- local = (char *(*)()) ypbindproc_domain_2_yp;
+ xdr_argument = (xdrproc_t)xdr_domainname;
+ xdr_result = (xdrproc_t)xdr_ypbind_resp;
+ local = (svc_cb *)ypbindproc_domain_2_yp;
break;
case YPBINDPROC_SETDOM:
@@ -332,9 +327,9 @@ ypbindprog_2(struct svc_req *rqstp, register SVCXPRT *transp)
return;
}
- xdr_argument = xdr_ypbind_setdom;
- xdr_result = xdr_void;
- local = (char *(*)()) ypbindproc_setdom_2_yp;
+ xdr_argument = (xdrproc_t)xdr_ypbind_setdom;
+ xdr_result = (xdrproc_t)xdr_void;
+ local = (svc_cb *)ypbindproc_setdom_2_yp;
break;
default:
@@ -342,13 +337,13 @@ ypbindprog_2(struct svc_req *rqstp, register SVCXPRT *transp)
return;
}
bzero(&argument, sizeof(argument));
- if (!svc_getargs(transp, (xdrproc_t)xdr_argument, &argument)) {
+ if (!svc_getargs(transp, xdr_argument, &argument)) {
svcerr_decode(transp);
return;
}
result = (*local)(transp, &argument, rqstp);
if (result != NULL &&
- !svc_sendreply(transp, (xdrproc_t)xdr_result, result)) {
+ !svc_sendreply(transp, xdr_result, result)) {
svcerr_systemerr(transp);
}
return;
diff --git a/usr.sbin/ypldap/Makefile b/usr.sbin/ypldap/Makefile
index 1fcaf238ca2a..fe2416027b75 100644
--- a/usr.sbin/ypldap/Makefile
+++ b/usr.sbin/ypldap/Makefile
@@ -1,5 +1,4 @@
# $OpenBSD: Makefile,v 1.8 2015/09/09 15:33:18 deraadt Exp $
-# $FreeBSD$
PACKAGE= yp
PROG= ypldap
diff --git a/usr.sbin/ypldap/Makefile.depend b/usr.sbin/ypldap/Makefile.depend
index 2a162b74233c..12a7f62f9149 100644
--- a/usr.sbin/ypldap/Makefile.depend
+++ b/usr.sbin/ypldap/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
@@ -11,7 +9,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libevent \
+ lib/libevent1 \
lib/libopenbsd \
lib/librpcsvc \
lib/libutil \
diff --git a/usr.sbin/ypldap/aldap.c b/usr.sbin/ypldap/aldap.c
index 4fb6608ec3f0..5a84068b9520 100644
--- a/usr.sbin/ypldap/aldap.c
+++ b/usr.sbin/ypldap/aldap.c
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* $Id: aldap.c,v 1.32 2016/04/27 10:53:27 schwarze Exp $ */
/* $OpenBSD: aldap.c,v 1.32 2016/04/27 10:53:27 schwarze Exp $ */
diff --git a/usr.sbin/ypldap/aldap.h b/usr.sbin/ypldap/aldap.h
index cdf5316e8328..8e3a7d8088c7 100644
--- a/usr.sbin/ypldap/aldap.h
+++ b/usr.sbin/ypldap/aldap.h
@@ -1,6 +1,5 @@
/* $Id: aldap.h,v 1.9 2012/04/30 21:40:03 jmatthew Exp $ */
/* $OpenBSD: aldap.h,v 1.9 2012/04/30 21:40:03 jmatthew Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org>
diff --git a/usr.sbin/ypldap/ber.c b/usr.sbin/ypldap/ber.c
index 62ba8f0f0d3b..b7d4d5e2939b 100644
--- a/usr.sbin/ypldap/ber.c
+++ b/usr.sbin/ypldap/ber.c
@@ -1,5 +1,4 @@
/* $OpenBSD: ber.c,v 1.9 2015/02/12 00:30:38 pelikan Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net>
diff --git a/usr.sbin/ypldap/ber.h b/usr.sbin/ypldap/ber.h
index eec02d4ac1b4..8498fd02be38 100644
--- a/usr.sbin/ypldap/ber.h
+++ b/usr.sbin/ypldap/ber.h
@@ -1,5 +1,4 @@
/* $OpenBSD: ber.h,v 1.2 2008/12/29 15:48:13 aschrijver Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net>
diff --git a/usr.sbin/ypldap/entries.c b/usr.sbin/ypldap/entries.c
index 1d57d5cd7b05..aa1341199d54 100644
--- a/usr.sbin/ypldap/entries.c
+++ b/usr.sbin/ypldap/entries.c
@@ -1,5 +1,4 @@
/* $OpenBSD: entries.c,v 1.3 2015/01/16 06:40:22 deraadt Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
*
@@ -40,7 +39,6 @@
void
flatten_entries(struct env *env)
{
- size_t wrlen;
size_t len;
char *linep;
char *endp;
@@ -56,7 +54,6 @@ flatten_entries(struct env *env)
*
* An extra octet is alloced to make space for an additional NUL.
*/
- wrlen = env->sc_user_line_len;
if ((linep = calloc(1, env->sc_user_line_len + 1)) == NULL) {
/*
* XXX: try allocating a smaller chunk of memory
@@ -78,7 +75,6 @@ flatten_entries(struct env *env)
free(ue->ue_line);
ue->ue_line = endp;
endp += len;
- wrlen -= len;
/*
* To save memory strdup(3) the netid_line which originally used
@@ -94,7 +90,6 @@ flatten_entries(struct env *env)
env->sc_user_lines = linep;
log_debug("done pushing users");
- wrlen = env->sc_group_line_len;
if ((linep = calloc(1, env->sc_group_line_len + 1)) == NULL) {
/*
* XXX: try allocating a smaller chunk of memory
@@ -115,7 +110,6 @@ flatten_entries(struct env *env)
free(ge->ge_line);
ge->ge_line = endp;
endp += len;
- wrlen -= len;
}
env->sc_group_lines = linep;
log_debug("done pushing groups");
diff --git a/usr.sbin/ypldap/ldapclient.c b/usr.sbin/ypldap/ldapclient.c
index 5f446a6f847e..acd4410d939f 100644
--- a/usr.sbin/ypldap/ldapclient.c
+++ b/usr.sbin/ypldap/ldapclient.c
@@ -1,5 +1,4 @@
/* $OpenBSD: ldapclient.c,v 1.31 2014/11/16 23:24:44 tedu Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org>
@@ -346,7 +345,7 @@ client_shutdown(void)
pid_t
ldapclient(int pipe_main2client[2])
{
- pid_t pid, dns_pid;
+ pid_t pid;
int pipe_dns[2];
struct passwd *pw;
struct event ev_sigint;
@@ -371,7 +370,7 @@ ldapclient(int pipe_main2client[2])
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_dns) == -1)
fatal("socketpair");
- dns_pid = ypldap_dns(pipe_dns, pw);
+ ypldap_dns(pipe_dns, pw);
close(pipe_dns[1]);
#ifndef DEBUG
diff --git a/usr.sbin/ypldap/log.c b/usr.sbin/ypldap/log.c
index 7fec6f7427b7..0df690e27f55 100644
--- a/usr.sbin/ypldap/log.c
+++ b/usr.sbin/ypldap/log.c
@@ -1,5 +1,4 @@
/* $OpenBSD: log.c,v 1.1 2008/06/26 15:10:01 pyr Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
diff --git a/usr.sbin/ypldap/parse.y b/usr.sbin/ypldap/parse.y
index b97af1dfa801..2a3bb8cf5c35 100644
--- a/usr.sbin/ypldap/parse.y
+++ b/usr.sbin/ypldap/parse.y
@@ -1,5 +1,4 @@
/* $OpenBSD: parse.y,v 1.18 2015/01/16 06:40:22 deraadt Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
diff --git a/usr.sbin/ypldap/yp.c b/usr.sbin/ypldap/yp.c
index 0cbadc371c5e..0d3d189ef1d7 100644
--- a/usr.sbin/ypldap/yp.c
+++ b/usr.sbin/ypldap/yp.c
@@ -1,5 +1,4 @@
/* $OpenBSD: yp.c,v 1.14 2015/02/11 01:26:00 pelikan Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
*
@@ -268,9 +267,6 @@ yp_dispatch(struct svc_req *req, SVCXPRT *trans)
int
yp_check(struct svc_req *req)
{
- struct sockaddr_in *caller;
-
- caller = svc_getcaller(req->rq_xprt);
/*
* We might want to know who we allow here.
*/
diff --git a/usr.sbin/ypldap/ypldap.8 b/usr.sbin/ypldap/ypldap.8
index 0ef75a257f79..35d28bc99696 100644
--- a/usr.sbin/ypldap/ypldap.8
+++ b/usr.sbin/ypldap/ypldap.8
@@ -1,5 +1,4 @@
.\" $OpenBSD: ypldap.8,v 1.10 2015/07/27 17:28:40 sobrado Exp $
-.\" $FreeBSD$
.\"
.\" Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
.\"
diff --git a/usr.sbin/ypldap/ypldap.c b/usr.sbin/ypldap/ypldap.c
index 9a6dc303dd9d..01b5955aa822 100644
--- a/usr.sbin/ypldap/ypldap.c
+++ b/usr.sbin/ypldap/ypldap.c
@@ -1,5 +1,4 @@
/* $OpenBSD: ypldap.c,v 1.16 2015/11/02 10:06:06 jmatthew Exp $ */
-/* $FreeBSD */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -143,7 +142,7 @@ main_start_update(struct env *env)
/*
* XXX: Currently this function should only be called when updating is
- * finished. A notification should be send to ldapclient that it should stop
+ * finished. A notification should be sent to ldapclient that it should stop
* sending new pwd/grp entries before it can be called from different places.
*/
void
diff --git a/usr.sbin/ypldap/ypldap.conf.5 b/usr.sbin/ypldap/ypldap.conf.5
index a5135dddd417..87518c5a7e3b 100644
--- a/usr.sbin/ypldap/ypldap.conf.5
+++ b/usr.sbin/ypldap/ypldap.conf.5
@@ -1,5 +1,4 @@
.\" $OpenBSD: ypldap.conf.5,v 1.19 2012/04/30 11:28:25 jmatthew Exp $
-.\" $FreeBSD$
.\"
.\" Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
.\"
diff --git a/usr.sbin/ypldap/ypldap.h b/usr.sbin/ypldap/ypldap.h
index 07e633fdeca5..e1a08d9e5cf8 100644
--- a/usr.sbin/ypldap/ypldap.h
+++ b/usr.sbin/ypldap/ypldap.h
@@ -1,5 +1,4 @@
/* $OpenBSD: ypldap.h,v 1.16 2015/01/16 06:40:22 deraadt Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -197,7 +196,7 @@ int parse_config(struct env *, const char *, int);
int cmdline_symset(char *);
/* ldapclient.c */
-pid_t ldapclient(int []);
+pid_t ldapclient(int [2]);
/* ypldap.c */
void purge_config(struct env *);
diff --git a/usr.sbin/ypldap/ypldap_dns.c b/usr.sbin/ypldap/ypldap_dns.c
index 5cb0390c8603..09ce636ebdc8 100644
--- a/usr.sbin/ypldap/ypldap_dns.c
+++ b/usr.sbin/ypldap/ypldap_dns.c
@@ -1,5 +1,4 @@
/* $OpenBSD: ypldap_dns.c,v 1.8 2015/01/16 06:40:22 deraadt Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org>
diff --git a/usr.sbin/yppoll/Makefile b/usr.sbin/yppoll/Makefile
index b865632fb82f..aa8879d777f9 100644
--- a/usr.sbin/yppoll/Makefile
+++ b/usr.sbin/yppoll/Makefile
@@ -1,5 +1,3 @@
-# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
-# $FreeBSD$
PACKAGE= yp
PROG= yppoll
diff --git a/usr.sbin/yppoll/Makefile.depend b/usr.sbin/yppoll/Makefile.depend
index faed4b4cc2aa..732a025c9552 100644
--- a/usr.sbin/yppoll/Makefile.depend
+++ b/usr.sbin/yppoll/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
diff --git a/usr.sbin/yppoll/yppoll.8 b/usr.sbin/yppoll/yppoll.8
index cc49393569f6..d1a1f802caad 100644
--- a/usr.sbin/yppoll/yppoll.8
+++ b/usr.sbin/yppoll/yppoll.8
@@ -27,7 +27,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$
.\"
.Dd September 3, 2015
.Dt YPPOLL 8
diff --git a/usr.sbin/yppoll/yppoll.c b/usr.sbin/yppoll/yppoll.c
index 03828238f67a..e6cde29d221a 100644
--- a/usr.sbin/yppoll/yppoll.c
+++ b/usr.sbin/yppoll/yppoll.c
@@ -33,9 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/usr.sbin/yppush/Makefile b/usr.sbin/yppush/Makefile
index 897e308c351c..9dfdd6d7ab65 100644
--- a/usr.sbin/yppush/Makefile
+++ b/usr.sbin/yppush/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
RPCDIR= ${SRCTOP}/include/rpcsvc
.PATH: ${RPCDIR} ${SRCTOP}/usr.sbin/ypserv ${SRCTOP}/libexec/ypxfr
diff --git a/usr.sbin/yppush/Makefile.depend b/usr.sbin/yppush/Makefile.depend
index 85338ebe3beb..a2d89550fa2b 100644
--- a/usr.sbin/yppush/Makefile.depend
+++ b/usr.sbin/yppush/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/rpc \
include/rpcsvc \
diff --git a/usr.sbin/yppush/yppush.8 b/usr.sbin/yppush/yppush.8
index 5e423570eab2..e3c91188c40c 100644
--- a/usr.sbin/yppush/yppush.8
+++ b/usr.sbin/yppush/yppush.8
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd February 5, 1995
.Dt YPPUSH 8
.Os
diff --git a/usr.sbin/yppush/yppush_extern.h b/usr.sbin/yppush/yppush_extern.h
index 2a4fbccee2c6..9220f0de05a8 100644
--- a/usr.sbin/yppush/yppush_extern.h
+++ b/usr.sbin/yppush/yppush_extern.h
@@ -28,8 +28,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$
*/
/* Privately defined error codes. */
diff --git a/usr.sbin/yppush/yppush_main.c b/usr.sbin/yppush/yppush_main.c
index bfcdeb7f4f22..2b167846d1b6 100644
--- a/usr.sbin/yppush/yppush_main.c
+++ b/usr.sbin/yppush/yppush_main.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <errno.h>
#include <signal.h>
#include <stdio.h>
@@ -217,7 +215,6 @@ static void
handler(int sig)
{
yppush_exit (1);
- return;
}
/*
diff --git a/usr.sbin/ypserv/Makefile b/usr.sbin/ypserv/Makefile
index 6d5948554ec8..18869d5c3345 100644
--- a/usr.sbin/ypserv/Makefile
+++ b/usr.sbin/ypserv/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
.include <src.opts.mk>
diff --git a/usr.sbin/ypserv/Makefile.depend b/usr.sbin/ypserv/Makefile.depend
index 722af65039b3..732a025c9552 100644
--- a/usr.sbin/ypserv/Makefile.depend
+++ b/usr.sbin/ypserv/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/ypserv/Makefile.depend.options b/usr.sbin/ypserv/Makefile.depend.options
index a62a5692d70a..fbc21670804e 100644
--- a/usr.sbin/ypserv/Makefile.depend.options
+++ b/usr.sbin/ypserv/Makefile.depend.options
@@ -1,4 +1,3 @@
-# $FreeBSD$
# This file is not autogenerated - take care!
DIRDEPS_OPTIONS= TCP_WRAPPERS
diff --git a/usr.sbin/ypserv/Makefile.yp b/usr.sbin/ypserv/Makefile.yp
index 17eabe5f42f4..18d6509a9fa7 100644
--- a/usr.sbin/ypserv/Makefile.yp
+++ b/usr.sbin/ypserv/Makefile.yp
@@ -1,7 +1,6 @@
#
# Makefile for the NIS databases
#
-# $FreeBSD$
#
# This Makefile should only be run on the NIS master server of a domain.
# All updated maps will be pushed to all NIS slave servers listed in the
diff --git a/usr.sbin/ypserv/common/yplib_host.c b/usr.sbin/ypserv/common/yplib_host.c
index 05b6e961314a..2751c5950d87 100644
--- a/usr.sbin/ypserv/common/yplib_host.c
+++ b/usr.sbin/ypserv/common/yplib_host.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/types.h>
@@ -54,10 +51,10 @@ __FBSDID("$FreeBSD$");
#include "yplib_host.h"
+extern bool_t xdr_ypresp_all_seq(XDR *, unsigned long *);
+
extern int (*ypresp_allfn)(u_long, char *, int, char *, int, void *);
extern void *ypresp_data;
-extern bool_t xdr_ypreq_key(), xdr_ypresp_val();
-extern bool_t xdr_ypresp_all_seq();
static int _yplib_host_timeout = 10;
diff --git a/usr.sbin/ypserv/common/yplib_host.h b/usr.sbin/ypserv/common/yplib_host.h
index 08b9e30066ee..eabafae9c1b9 100644
--- a/usr.sbin/ypserv/common/yplib_host.h
+++ b/usr.sbin/ypserv/common/yplib_host.h
@@ -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 _YPLIB_HOST_H_
diff --git a/usr.sbin/ypserv/yp_access.c b/usr.sbin/ypserv/yp_access.c
index 50c8d3dbd532..fefe96076092 100644
--- a/usr.sbin/ypserv/yp_access.c
+++ b/usr.sbin/ypserv/yp_access.c
@@ -34,8 +34,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <stdlib.h>
#include <rpc/rpc.h>
#include <rpcsvc/yp.h>
diff --git a/usr.sbin/ypserv/yp_dblookup.c b/usr.sbin/ypserv/yp_dblookup.c
index 291daba0da09..c0aefb048cb9 100644
--- a/usr.sbin/ypserv/yp_dblookup.c
+++ b/usr.sbin/ypserv/yp_dblookup.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <db.h>
#include <errno.h>
#include <fcntl.h>
@@ -93,7 +91,6 @@ void
yp_init_dbs(void)
{
TAILQ_INIT(&qhead);
- return;
}
/*
@@ -155,8 +152,6 @@ yp_free_qent(struct circleq_entry *q)
*/
free(q);
q = NULL;
-
- return;
}
/*
@@ -173,8 +168,6 @@ yp_flush(void)
TAILQ_REMOVE(&qhead, qptr, links);
yp_free_qent(qptr);
numdbs--;
-
- return;
}
/*
@@ -192,7 +185,6 @@ yp_flush_all(void)
}
numdbs = 0;
- return;
}
static char *inter_string = "YP_INTERDOMAIN";
diff --git a/usr.sbin/ypserv/yp_dnslookup.c b/usr.sbin/ypserv/yp_dnslookup.c
index b33b80c2e82c..699c4d7e8018 100644
--- a/usr.sbin/ypserv/yp_dnslookup.c
+++ b/usr.sbin/ypserv/yp_dnslookup.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Do standard and reverse DNS lookups using the resolver library.
* Take care of all the dirty work here so the main program only has to
@@ -308,8 +306,6 @@ yp_send_dns_reply(struct circleq_dnsentry *q, char *buf)
if (q->prot_type == SOCK_DGRAM)
svcudp_set_xid(q->xprt, xid);
q->xprt->xp_raddr = client_addr;
-
- return;
}
/*
@@ -336,8 +332,6 @@ yp_prune_dnsq(void)
if (pending < 0)
pending = 0;
-
- return;
}
/*
@@ -405,8 +399,6 @@ yp_run_dnsq(void)
/* Decrement TTLs on other entries while we're here. */
yp_prune_dnsq();
-
- return;
}
/*
diff --git a/usr.sbin/ypserv/yp_error.c b/usr.sbin/ypserv/yp_error.c
index c22375f859ac..314c11d2514d 100644
--- a/usr.sbin/ypserv/yp_error.c
+++ b/usr.sbin/ypserv/yp_error.c
@@ -34,8 +34,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* error logging/reporting facilities
* stolen from /usr/libexec/mail.local via ypserv
diff --git a/usr.sbin/ypserv/yp_extern.h b/usr.sbin/ypserv/yp_extern.h
index 4a1c6b3528dc..3fe03df71b88 100644
--- a/usr.sbin/ypserv/yp_extern.h
+++ b/usr.sbin/ypserv/yp_extern.h
@@ -30,8 +30,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 <db.h>
@@ -39,7 +37,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <sys/cdefs.h>
+
#include <sys/types.h>
#include <rpc/rpc.h>
#include <rpcsvc/yp.h>
diff --git a/usr.sbin/ypserv/yp_main.c b/usr.sbin/ypserv/yp_main.c
index 452bee79d2ca..d326603a9229 100644
--- a/usr.sbin/ypserv/yp_main.c
+++ b/usr.sbin/ypserv/yp_main.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* ypserv startup function.
* We need out own main() since we have to do some additional work
@@ -211,7 +209,6 @@ reaper(int sig)
exit(0);
}
errno = saved_errno;
- return;
}
static void
diff --git a/usr.sbin/ypserv/yp_server.c b/usr.sbin/ypserv/yp_server.c
index 7acb5d7f2b5c..62e45e35cbe1 100644
--- a/usr.sbin/ypserv/yp_server.c
+++ b/usr.sbin/ypserv/yp_server.c
@@ -34,8 +34,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "yp.h"
#include "yp_extern.h"
#include <dirent.h>
@@ -307,7 +305,6 @@ ypxfr_callback(ypxfrstat rval, struct sockaddr_in *addr, unsigned int transid,
}
clnt_destroy(clnt);
- return;
}
#define YPXFR_RETURN(CODE) \
@@ -675,7 +672,6 @@ static void yp_maplist_free(struct ypmaplist *yp_maplist)
free(yp_maplist);
yp_maplist = next;
}
- return;
}
static struct ypmaplist *
diff --git a/usr.sbin/ypserv/yp_svc_udp.c b/usr.sbin/ypserv/yp_svc_udp.c
index 288bd28423b1..9cb904db01b1 100644
--- a/usr.sbin/ypserv/yp_svc_udp.c
+++ b/usr.sbin/ypserv/yp_svc_udp.c
@@ -33,8 +33,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <rpc/rpc.h>
#include <rpc/svc_dg.h>
#include "yp_extern.h"
diff --git a/usr.sbin/ypserv/ypinit.8 b/usr.sbin/ypserv/ypinit.8
index c843a665e2e2..6e09a64aa86e 100644
--- a/usr.sbin/ypserv/ypinit.8
+++ b/usr.sbin/ypserv/ypinit.8
@@ -28,8 +28,6 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
.\" THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd August 18, 2015
.Dt YPINIT 8
.Os
diff --git a/usr.sbin/ypserv/ypinit.sh b/usr.sbin/ypserv/ypinit.sh
index 5008bcfe5093..63f4e0706b92 100644
--- a/usr.sbin/ypserv/ypinit.sh
+++ b/usr.sbin/ypserv/ypinit.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
#
# ypinit.sh - setup a master or slave server.
# (Taken from OpenBSD and modified for FreeBSD.)
diff --git a/usr.sbin/ypserv/ypserv.8 b/usr.sbin/ypserv/ypserv.8
index f255118179e3..9c33b4b95ddc 100644
--- a/usr.sbin/ypserv/ypserv.8
+++ b/usr.sbin/ypserv/ypserv.8
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd December 13, 2009
.Dt YPSERV 8
.Os
diff --git a/usr.sbin/ypset/Makefile b/usr.sbin/ypset/Makefile
index 4c6c86df556e..38f645516433 100644
--- a/usr.sbin/ypset/Makefile
+++ b/usr.sbin/ypset/Makefile
@@ -1,5 +1,3 @@
-# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
-# $FreeBSD$
PACKAGE= yp
PROG= ypset
diff --git a/usr.sbin/ypset/Makefile.depend b/usr.sbin/ypset/Makefile.depend
index faed4b4cc2aa..732a025c9552 100644
--- a/usr.sbin/ypset/Makefile.depend
+++ b/usr.sbin/ypset/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/rpc \
diff --git a/usr.sbin/ypset/ypset.8 b/usr.sbin/ypset/ypset.8
index 25900952615c..8b4b7b7397f2 100644
--- a/usr.sbin/ypset/ypset.8
+++ b/usr.sbin/ypset/ypset.8
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd September 3, 2015
.Dt YPSET 8
.Os
diff --git a/usr.sbin/ypset/ypset.c b/usr.sbin/ypset/ypset.c
index 95153ca48a9a..2a22b54b9350 100644
--- a/usr.sbin/ypset/ypset.c
+++ b/usr.sbin/ypset/ypset.c
@@ -2,7 +2,7 @@
/* $NetBSD: ypset.c,v 1.8 1996/05/13 02:46:33 thorpej Exp $ */
/*-
- * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
* All rights reserved.
@@ -29,9 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/usr.sbin/zdump/Makefile b/usr.sbin/zdump/Makefile
new file mode 100644
index 000000000000..6b18107c2f75
--- /dev/null
+++ b/usr.sbin/zdump/Makefile
@@ -0,0 +1,10 @@
+
+.PATH: ${SRCTOP}/contrib/tzcode
+
+PROG= zdump
+MAN= zdump.8
+SRCS= zdump.c
+
+CFLAGS+= -I${SRCTOP}/contrib/tzcode -include tzconfig.h
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/portsnap/make_index/Makefile.depend b/usr.sbin/zdump/Makefile.depend
index 6cfaab1c3644..84b8ddd67e34 100644
--- a/usr.sbin/portsnap/make_index/Makefile.depend
+++ b/usr.sbin/zdump/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/zic/Makefile b/usr.sbin/zic/Makefile
index 9d699a891449..fdfe6870583a 100644
--- a/usr.sbin/zic/Makefile
+++ b/usr.sbin/zic/Makefile
@@ -1,7 +1,10 @@
-# $FreeBSD$
-# Vendor contact: tz@elsie.nci.nih.gov
+.PATH: ${SRCTOP}/contrib/tzcode
-SUBDIR= zic zdump
+PROG= zic
+MAN= zic.8
+SRCS= zic.c
-.include <bsd.subdir.mk>
+CFLAGS+= -I${SRCTOP}/contrib/tzcode -include tzconfig.h
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/zic/zic/Makefile.depend b/usr.sbin/zic/Makefile.depend
index 6cfaab1c3644..84b8ddd67e34 100644
--- a/usr.sbin/zic/zic/Makefile.depend
+++ b/usr.sbin/zic/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/zic/Makefile.inc b/usr.sbin/zic/Makefile.inc
deleted file mode 100644
index 19a7ea422c5b..000000000000
--- a/usr.sbin/zic/Makefile.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-# $FreeBSD$
-
-.include "${SRCTOP}/usr.sbin/Makefile.inc"
diff --git a/usr.sbin/zic/README b/usr.sbin/zic/README
deleted file mode 100644
index 5cb701eca276..000000000000
--- a/usr.sbin/zic/README
+++ /dev/null
@@ -1,88 +0,0 @@
-@(#)README 8.3
-This file is in the public domain, so clarified as of
-2009-05-17 by Arthur David Olson.
-
-$FreeBSD$
-
-"What time is it?" -- Richard Deacon as The King
-"Any time you want it to be." -- Frank Baxter as The Scientist
- (from the Bell System film "About Time")
-
-The 1989 update of the time zone package featured
-
-* POSIXization (including interpretation of POSIX-style TZ environment
- variables, provided by Guy Harris),
-* ANSIfication (including versions of "mktime" and "difftime"),
-* SVIDulation (an "altzone" variable)
-* MACHination (the "gtime" function)
-* corrections to some time zone data (including corrections to the rules
- for Great Britain and New Zealand)
-* reference data from the United States Naval Observatory for folks who
- want to do additional time zones
-* and the 1989 data for Saudi Arabia.
-
-(Since this code will be treated as "part of the implementation" in some places
-and as "part of the application" in others, there's no good way to name
-functions, such as timegm, that are not part of the proposed ANSI C standard;
-such functions have kept their old, underscore-free names in this update.)
-
-And the "dysize" function has disappeared; it was present to allow compilation
-of the "date" command on old BSD systems, and a version of "date" is now
-provided in the package. The "date" command is not created when you "make all"
-since it may lack options provided by the version distributed with your
-operating system, or may not interact with the system in the same way the
-native version does.
-
-Since POSIX frowns on correct leap second handling, the default behavior of
-the "zic" command (in the absence of a "-L" option) has been changed to omit
-leap second information from its output files.
-
-Here is a recipe for acquiring, building, installing, and testing the
-tz distribution on a GNU/Linux or similar host.
-
- mkdir tz
- cd tz
- wget 'ftp://elsie.nci.nih.gov/pub/tz*.tar.gz'
- gzip -dc tzcode*.tar.gz | tar -xf -
- gzip -dc tzdata*.tar.gz | tar -xf -
-
-Be sure to read the comments in "Makefile" and make any changes needed
-to make things right for your system, especially if you are using some
-platform other than GNU/Linux. Then run the following commands,
-substituting your desired installation directory for "$HOME/tzdir":
-
- make TOPDIR=$HOME/tzdir install
- $HOME/tzdir/etc/zdump -v America/Los_Angeles
-
-To use the new functions, use a "-ltz" option when compiling or linking.
-
-Historical local time information has been included here to:
-
-* provide a compendium of data about the history of civil time
- that is useful even if the data are not 100% accurate;
-
-* give an idea of the variety of local time rules that have
- existed in the past and thus an idea of the variety that may be
- expected in the future;
-
-* provide a test of the generality of the local time rule description
- system.
-
-The information in the time zone data files is by no means authoritative;
-the files currently do not even attempt to cover all time stamps before
-1970, and there are undoubtedly errors even for time stamps since 1970.
-If you know that the rules are different from those in a file, by all means
-feel free to change file (and please send the changed version to
-tz@elsie.nci.nih.gov for use in the future). Europeans take note!
-
-Thanks to these Timezone Caballeros who've made major contributions to the
-time conversion package: Keith Bostic; Bob Devine; Paul Eggert; Robert Elz;
-Guy Harris; Mark Horton; John Mackin; and Bradley White. Thanks also to
-Michael Bloom, Art Neilson, Stephen Prince, John Sovereign, and Frank Wales
-for testing work, and to Gwillim Law for checking local mean time data.
-None of them are responsible for remaining errors.
-
-Look in the ~ftp/pub directory of elsie.nci.nih.gov
-for updated versions of these files.
-
-Please send comments or information to tz@elsie.nci.nih.gov.
diff --git a/usr.sbin/zic/zdump/Makefile b/usr.sbin/zic/zdump/Makefile
deleted file mode 100644
index 9671e7bf5298..000000000000
--- a/usr.sbin/zic/zdump/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${SRCTOP}/contrib/tzcode/zic
-
-PROG= zdump
-MAN= zdump.8
-SRCS= zdump.c ialloc.c scheck.c
-
-CFLAGS+= -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DSTD_INSPIRED -DPCTS
-CFLAGS+= -DHAVE_LONG_DOUBLE -DTZDIR=\"${SHAREDIR}/zoneinfo\" -Demkdir=mkdir
-CFLAGS+= -I${.CURDIR:H} -I${SRCTOP}/contrib/tzcode/stdtime
-
-WARNS?= 2
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/zic/zic/Makefile b/usr.sbin/zic/zic/Makefile
deleted file mode 100644
index 17ffb33a57e7..000000000000
--- a/usr.sbin/zic/zic/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-# $FreeBSD$
-
-.include <src.opts.mk>
-
-.PATH: ${SRCTOP}/contrib/tzcode/zic
-
-PROG= zic
-MAN= zic.8
-SRCS= zic.c ialloc.c scheck.c
-
-CFLAGS+= -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DSTD_INSPIRED -DPCTS
-CFLAGS+= -DHAVE_LONG_DOUBLE -DTZDIR=\"${SHAREDIR}/zoneinfo\" -Demkdir=mkdir
-CFLAGS+= -DHAVE_STRERROR -DHAVE_UNISTD_H
-CFLAGS+= -I${.CURDIR:H} -I${SRCTOP}/contrib/tzcode/stdtime
-
-WARNS?= 2
-
-.if ${COMPILER_TYPE} == "gcc"
-CWARNFLAGS+= -Wno-error=strict-overflow
-.endif
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/zonectl/Makefile b/usr.sbin/zonectl/Makefile
index 5dac60ddf3f7..9c86470f785e 100644
--- a/usr.sbin/zonectl/Makefile
+++ b/usr.sbin/zonectl/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
PROG= zonectl
SRCS= zonectl.c
diff --git a/usr.sbin/zonectl/Makefile.depend b/usr.sbin/zonectl/Makefile.depend
index ee06e1c20939..0ef6390836dd 100644
--- a/usr.sbin/zonectl/Makefile.depend
+++ b/usr.sbin/zonectl/Makefile.depend
@@ -1,8 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.sbin/zonectl/zonectl.8 b/usr.sbin/zonectl/zonectl.8
index 1338bf197eb2..72cebfaf1ff0 100644
--- a/usr.sbin/zonectl/zonectl.8
+++ b/usr.sbin/zonectl/zonectl.8
@@ -29,8 +29,6 @@
.\"
.\" Authors: Ken Merry (Spectra Logic Corporation)
.\"
-.\" $FreeBSD$
-.\"
.Dd May 18, 2016
.Dt ZONECTL 8
.Os
@@ -149,7 +147,7 @@ For the Report Zones command, specify a subset of zones to report.
.It all
Report all zones.
This is the default.
-.It emtpy
+.It empty
Report only empty zones.
.It imp_open
Report zones that are implicitly open.
diff --git a/usr.sbin/zonectl/zonectl.c b/usr.sbin/zonectl/zonectl.c
index dac773974deb..56cd3c436d10 100644
--- a/usr.sbin/zonectl/zonectl.c
+++ b/usr.sbin/zonectl/zonectl.c
@@ -31,8 +31,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/ioctl.h>
#include <sys/stdint.h>
#include <sys/types.h>
diff --git a/usr.sbin/zzz/Makefile b/usr.sbin/zzz/Makefile
index 8c4a9beb763a..85191008a0b3 100644
--- a/usr.sbin/zzz/Makefile
+++ b/usr.sbin/zzz/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SCRIPTS=zzz.sh
MAN= zzz.8
diff --git a/usr.sbin/zzz/Makefile.depend b/usr.sbin/zzz/Makefile.depend
index f80275d86ab1..11aba52f82cf 100644
--- a/usr.sbin/zzz/Makefile.depend
+++ b/usr.sbin/zzz/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/usr.sbin/zzz/zzz.8 b/usr.sbin/zzz/zzz.8
index 365950f64389..c2799c28e177 100644
--- a/usr.sbin/zzz/zzz.8
+++ b/usr.sbin/zzz/zzz.8
@@ -22,8 +22,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd July 13, 2003
.Dt ZZZ 8
.Os
diff --git a/usr.sbin/zzz/zzz.sh b/usr.sbin/zzz/zzz.sh
index ef9527bb76b3..0e0ceebe70b9 100644
--- a/usr.sbin/zzz/zzz.sh
+++ b/usr.sbin/zzz/zzz.sh
@@ -7,7 +7,6 @@
#
# Mark Santcroos <marks@ripe.net>
#
-# $FreeBSD$
PATH=/sbin:/usr/sbin:/usr/bin:/bin
@@ -18,18 +17,18 @@ APM_SUSPEND_DELAY=machdep.apm_suspend_delay
# Check for ACPI support
if sysctl $ACPI_SUSPEND_STATE >/dev/null 2>&1; then
# Get configured suspend state
- SUSPEND_STATE=`sysctl -n $ACPI_SUSPEND_STATE `
+ SUSPEND_STATE=$(sysctl -n $ACPI_SUSPEND_STATE)
# Get list of supported suspend states
- SUPPORTED_STATES=`sysctl -n $ACPI_SUPPORTED_STATES `
+ SUPPORTED_STATES=$(sysctl -n $ACPI_SUPPORTED_STATES)
# Check if the configured suspend state is supported by the system
- if echo $SUPPORTED_STATES | grep $SUSPEND_STATE >/dev/null; then
+ if echo "$SUPPORTED_STATES" | grep "$SUSPEND_STATE" >/dev/null; then
# execute ACPI style suspend command
- exec acpiconf -s $SUSPEND_STATE
+ exec acpiconf -s "$SUSPEND_STATE"
else
echo -n "Requested suspend state $SUSPEND_STATE "
- echo -n "is not supported. "
+ echo -n "is not supported."
echo "Supported states: $SUPPORTED_STATES"
fi
# Check for APM support