Page MenuHomeFreeBSD

swapon: parse md.eli device for encrypted swapfile from fstab
Needs ReviewPublic

Authored by ronald_klop.ws on Thu, Feb 6, 10:15 PM.

Details

Summary

Although fstab(5) suggests usage of md(4) and an .eli suffix in the same
paragraph, the combination did not work.
This patch adds a bit of parsing, creates the md device and then passes
that device to the *_geli function.

PR: 186252
MFC after: 2 weeks
Relnotes: yes

Test Plan
# truncate -s 1m /tmp/swapfile
# echo "md0.eli    none    swap    sw,file=/tmp/swapfile  0       0" > /tmp/fstab
# /sbin/swapon -F /tmp/fstab -a
swapon: Bad device unit: md0.eli: Invalid argument

# /usr/obj/usr/src/arm64.aarch64/sbin/swapon/swapon -F /tmp/fstab -a
swapon: adding /dev/md0.eli as swap device

# swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/gpt/ssdswap0   8388608        0  8388608     0%
/dev/md0.eli         1024        0     1024     0%
Total             8389632        0  8389632     0%

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 62286
Build 59170: arc lint + arc unit

Event Timeline

Could you add a short test plan to follow?

ronald_klop.ws edited the test plan for this revision. (Show Details)
In D48874#1114805, @dsl wrote:

Could you add a short test plan to follow?

I hope the test plan is as expected. Otherwise please let me know.

allanjude added inline comments.
sbin/swapon/swapon.c
234

Wouldn't we end up calling swap_on_off_md() for a .eli that is NOT an md now?

Is _PATH_DEV missing here as well?

In D48874#1114805, @dsl wrote:

Could you add a short test plan to follow?

I hope the test plan is as expected. Otherwise please let me know.

I think the test plan needs to test other cases (a .eli that is not a md(4), and md without eli, etc)