summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-05-07 11:58:05 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-05-07 12:20:26 +0200
commitde17bb6812f9127eaef4d8b4b357822b1367e9a3 (patch)
tree7578b8a44b7db7a7c27a2b153214d1b0213bebb6 /src/utils
parent9ffe1c81bf611c9321e0c093229fb19eaa5c12d2 (diff)
utils:fs: add mkfs logs when return code is not 0
Report mkfs failure for every partition. This does not raise an exception as that would skip partprobe operations and the mkfs operations in the next potentially well formated partitions.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/fs.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/utils/fs.py b/src/utils/fs.py
index a4a9ae5..1fd13f1 100644
--- a/src/utils/fs.py
+++ b/src/utils/fs.py
@@ -170,9 +170,12 @@ def mkfs_ext4(partdev, label=None):
else:
cmd = shlex.split(f'mkfs.ext4 -F {partdev}')
with open('/tmp/command.log', 'wb', 0) as logfile:
- subprocess.run(cmd,
- stdout=logfile,
- stderr=STDOUT)
+ ret = subprocess.run(cmd,
+ stdout=logfile,
+ stderr=STDOUT)
+
+ if ret.returncode != 0:
+ logging.error(f'mkfs.ext4 reports return code {ret.returncode} for {partdev}')
def mkfs_ntfs(partdev, label=None):
@@ -181,9 +184,12 @@ def mkfs_ntfs(partdev, label=None):
else:
cmd = shlex.split(f'mkfs.ntfs -f {partdev}')
with open('/tmp/command.log', 'wb', 0) as logfile:
- subprocess.run(cmd,
- stdout=logfile,
- stderr=STDOUT)
+ ret = subprocess.run(cmd,
+ stdout=logfile,
+ stderr=STDOUT)
+
+ if ret.returncode != 0:
+ logging.error(f'mkfs.ntfs reports return code {ret.returncode} for {partdev}')
def mkfs_fat32(partdev, label=None):
@@ -192,9 +198,12 @@ def mkfs_fat32(partdev, label=None):
else:
cmd = shlex.split(f'mkfs.vfat -F32 {partdev}')
with open('/tmp/command.log', 'wb', 0) as logfile:
- subprocess.run(cmd,
- stdout=logfile,
- stderr=STDOUT)
+ ret = subprocess.run(cmd,
+ stdout=logfile,
+ stderr=STDOUT)
+
+ if ret.returncode != 0:
+ logging.error(f'mkfs.vfat reports return code {ret.returncode} for {partdev}')
def mkfs_swap(partdev, label=None):
@@ -203,9 +212,12 @@ def mkfs_swap(partdev, label=None):
else:
cmd = shlex.split(f'mkswap -f {partdev}')
with open('/tmp/command.log', 'wb', 0) as logfile:
- subprocess.run(cmd,
- stdout=logfile,
- stderr=STDOUT)
+ ret = subprocess.run(cmd,
+ stdout=logfile,
+ stderr=STDOUT)
+
+ if ret.returncode != 0:
+ logging.error(f'mkswap reports return code {ret.returncode} for {partdev}')
def get_filesystem_type(partdev):