summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/utils/fs.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils/fs.py b/src/utils/fs.py
index 7b0e1c3..a7058a7 100644
--- a/src/utils/fs.py
+++ b/src/utils/fs.py
@@ -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()