1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-07-01 16:18:55 +00:00

[PR #12235/33ae6c10 backport][stable-12] filesystem: handle BusyBox blkid output when detecting existing filesystem (#12272)

filesystem: handle BusyBox `blkid` output when detecting existing filesystem (#12235)

* fix(filesystem): handle BusyBox blkid output when detecting existing filesystem

BusyBox blkid ignores util-linux -o/-s flags and outputs the full device
info line instead of just the filesystem type. Parse the TYPE= field from
the raw output when it does not look like a plain type name.

Fixes #7283

* changelog: add fragment for PR 12235

(cherry picked from commit 33ae6c1018)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2026-06-14 20:55:48 +02:00 committed by GitHub
parent 7b00d2c445
commit 56e3de349e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -683,6 +683,11 @@ def main():
cmd = module.get_bin_path("blkid", required=True)
rc, raw_fs, err = module.run_command([cmd, "-c", os.devnull, "-o", "value", "-s", "TYPE", str(dev)])
fs = raw_fs.strip()
# BusyBox blkid may ignore -o/-s flags and output the full device info line,
# e.g. '/dev/sda2: UUID="..." TYPE="btrfs"' instead of just 'btrfs'
if fs and " " in fs:
type_match = re.search(r'\bTYPE="?([^"\s]+)"?', raw_fs)
fs = type_match.group(1) if type_match else ""
if not fs and platform.system() == "FreeBSD":
cmd = module.get_bin_path("fstyp", required=True)
rc, raw_fs, err = module.run_command([cmd, str(dev)])