Skip to content

Commit

Permalink
Prefer lsblk over blkid
Browse files Browse the repository at this point in the history
Prior to this commit, the partitions resolver only used lsblk as a
fallback if blkid did not return any information.

However, there are many advantages to lsblk. lsblk does not necessarily
require root (while blkid does), it returns more information (like
partition type GUIDs), and blkid specifically recommends using lsblk in
its manpage.

This commit updates the partitions resolver to prefer lsblk and use
blkid as a fallback.
  • Loading branch information
mhashizume committed Aug 5, 2024
1 parent 62119d1 commit 57a281e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/facter/resolvers/partitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ def populate_partitions(partition_name, block_path, blkid_and_lsblk, backing_fil
end

def populate_from_syscalls(partition_name, blkid_and_lsblk)
part_info = populate_from_blkid(partition_name, blkid_and_lsblk)
# Prefer lsblk over blkid since lsblk does not require root, returns more information, and is recommended by blkid
part_info = populate_from_lsblk(partition_name, blkid_and_lsblk)

return populate_from_lsblk(partition_name, blkid_and_lsblk) if part_info.empty?
return populate_from_blkid(partition_name, blkid_and_lsblk) if part_info.empty?

part_info
end
Expand Down

0 comments on commit 57a281e

Please sign in to comment.