Page MenuHomeFreeBSD

dumpon: accept "dump" type in fstab
Needs ReviewPublic

Authored by emaste on Mar 10 2022, 5:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jun 23, 2:57 AM
Unknown Object (File)
Tue, Jun 23, 12:13 AM
Unknown Object (File)
Thu, Jun 11, 10:39 AM
Unknown Object (File)
Tue, Jun 9, 2:13 AM
Unknown Object (File)
May 2 2026, 10:29 PM
Unknown Object (File)
Apr 27 2026, 12:18 PM
Unknown Object (File)
Apr 19 2026, 6:19 PM
Unknown Object (File)
Mar 23 2026, 6:16 AM
Subscribers

Details

Reviewers
jilles
kevans

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

emaste created this revision.

PR: 175311

In contrast to the approach in the PR I went with a loop looking for dump first then swap, as dump should take precedence over swap, in e.g.

# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/nvd0p3             none    swap    sw              0       0
/dev/nvd0p4             none    dump    sw              0       0

or if we want to avoid reading /etc/fstab twice something like

dump_try=
swap_try=
while read dev mp type more ; do
        [ "${type}" = dump -o "${type}" = swap ] || continue
        case ${dev} in
        *.bde|*.eli)
                dumpon_warn_unencrypted
                dev=${dev%.*}
                ;;
        esac
        [ -c "${dev}" ] || continue
        eval ${type}_try=\"\${${type}_try} ${dev}\"
done </etc/fstab
for dev in ${dump_try} ${swap_try}; do
        dumpon_try "${dev}" 2>/dev/null && return 0
done

or if we want to avoid reading /etc/fstab twice something like

I'm not sure it's worth the added complexity, especially in a zfs world where fstab is typically very short.

The commit message needs some work, it should mention that we prefer dump to swap if both are encountered.

libexec/rc/rc.d/dumpon
65

We should skip lines where ${dev} begins with #, otherwise commenting out the first dump or swap line will result in some strange console errors:

unable to specify #/dev/da0p2 as a dump device
66

The patch in the PR has it right here (except for a missing newline); case is faster than test for string comparisons. Although arguably we should fix that by giving sh a built-in [.

I agree that comment lines in /etc/fstab should be skipped.

libexec/rc/rc.d/dumpon
66

Our sh has had a built-in [ since 2001, but case is still somewhat faster because it avoids the overhead associated with simple commands and built-in utilities. I don't think this is sufficient reason to replace [ with case even where it looks unnatural, though.