Skip to content

Commit a64f6c7

Browse files
committed
mountpoints: OpenBSD: mount(8) -v for more options and disklabel(8) UID
"Verbose mode" yields makes some options always appear, e.g. `rw` rather than lack of `read-only` or informational timestamps, as well as a disk's unique identifier, iff available. Example `mount` and `facter mountpoints` output changes due to `-v`: ``` -/dev/sd1a on / type ffs (local, noatime) +/dev/sd1a (2b22b08ec9273d80.a) on / type ffs (rw, local, ctime=Sat Feb 21 13:52:57 2026) ``` ``` { available => "663.01 MiB", available_bytes => 695216128, capacity => "27.91%", device => "/dev/sd1a", + duid => "2b22b08ec9273d80.a", filesystem => "ffs", options => [ + "rw", "local", "noatime", + "ctime=Sun Mar 1 16:49:49 2026" ], size => "988.19 MiB", size_bytes => 1036187648, used => "275.77 MiB", used_bytes => 289163264 } ``` With DUID not available, e.g. after remounting in certain ways: ``` -/dev/sd1a on / type ffs (local, noatime) +/dev/sd1a on / type ffs (rw, local, noatime, ctime=Sun Mar 1 16:31:04 2026) ``` ``` { available => "663.01 MiB", available_bytes => 695216128, capacity => "27.91%", device => "/dev/sd1a", filesystem => "ffs", options => [ + "rw", "local", "noatime", + "ctime=Sun Mar 1 16:49:49 2026" ], size => "988.19 MiB", size_bytes => 1036187648, used => "275.77 MiB", used_bytes => 289163264 } ``` This makes it easier to: - compare and ensure options - manage fstab(5) using stable DUIDs (device numbers roam due to attach order, softraid(4)/vnd(4), etc.)
1 parent 02f7440 commit a64f6c7

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

lib/facter/resolvers/openbsd/mountpoints.rb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def post_resolve(fact_name, _options)
1717

1818
def read_mount(fact_name)
1919
@fact_list[:mountpoints] = {}
20-
output = Facter::Core::Execution.execute('mount', logger: log)
20+
output = Facter::Core::Execution.execute('mount -v', logger: log)
2121
output.split("\n").map do |line|
2222
add_mount_points_fact(line)
2323
end
@@ -27,11 +27,21 @@ def read_mount(fact_name)
2727
end
2828

2929
def add_mount_points_fact(line)
30-
(elem, _, options) = line.partition("\s(")
31-
elem = elem.split("\s")
32-
options = options.chop!.split(",\s")
33-
@fact_list[:mountpoints][elem[2]] = { device: elem[0], filesystem: elem[4],
34-
options: options }
30+
(*tokens, options) = line.split(/\s*\(|\)\s*/, 0)
31+
32+
if tokens.length == 3
33+
(device, duid, tokens) = tokens
34+
else
35+
(device, tokens) = tokens[0].split("\s", 2)
36+
end
37+
(_on, path, _type, filesystem) = tokens.split("\s")
38+
39+
@fact_list[:mountpoints][path] = {
40+
device: device,
41+
duid: duid,
42+
filesystem: filesystem,
43+
options: options.split(",\s")
44+
}.compact
3545
end
3646

3747
def retrieve_sizes_for_mounts

spec/facter/resolvers/openbsd/mountpoints_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
before do
1818
allow(Facter::Core::Execution).to receive(:execute)
19-
.with('mount', logger: an_instance_of(Facter::Log))
19+
.with('mount -v', logger: an_instance_of(Facter::Log))
2020
.and_return(load_fixture('openbsd_filesystems').read)
2121
allow(Facter::Core::Execution).to receive(:execute)
2222
.with('df -P', logger: an_instance_of(Facter::Log))

0 commit comments

Comments
 (0)