mirror of https://git.48k.eu/ogclient
utils: add get_filesystem_type function
Retrieve filesystem type from a partition using get_filesystem_type. Encapsulates a subprocess call to blkid.more_events
parent
2ddea6d514
commit
22dce48d3e
|
@ -165,3 +165,15 @@ def mkfs_fat32(partdev, label=None):
|
|||
subprocess.run(cmd,
|
||||
stdout=logfile,
|
||||
stderr=STDOUT)
|
||||
|
||||
|
||||
def get_filesystem_type(partdev):
|
||||
"""
|
||||
Get filesystem type from a partition device path.
|
||||
Raises RuntimeError when blkid exits with non-zero return code.
|
||||
"""
|
||||
cmd = shlex.split(f'blkid -o value -s TYPE {partdev}')
|
||||
proc = subprocess.run(cmd, stdout=PIPE, encoding='utf-8')
|
||||
if proc.returncode != 0:
|
||||
raise RuntimeError(f'Error getting filesystem from {partdev}')
|
||||
return proc.stdout.strip()
|
||||
|
|
Loading…
Reference in New Issue