diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/live/ogOperations.py | 7 | ||||
-rw-r--r-- | src/utils/fs.py | 22 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index 44d8f1b..15e563f 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -429,9 +429,12 @@ class OgLiveOperations: partition = int(part["partition"]) if fs == 'cache': - mkfs('ext4', int(disk), partition, label='CACHE') + err = mkfs('ext4', int(disk), partition, label='CACHE') else: - mkfs(fs, int(disk), partition) + err = mkfs(fs, int(disk), partition) + + if err == -1: + raise OgError(f'Failed to format {part["partition"]} with filesystem {part["filesystem"]}') ret = subprocess.run(['partprobe', f'/dev/{diskname}']) logging.info(f'second partprobe /dev/{diskname} reports {ret.returncode}') diff --git a/src/utils/fs.py b/src/utils/fs.py index fc326ab..8f45ad5 100644 --- a/src/utils/fs.py +++ b/src/utils/fs.py @@ -165,10 +165,11 @@ def mkfs(fs, disk, partition, label=None): except ValueError as e: raise OgError(f'mkfs aborted: {e}') from e - fsdict[fs](partdev, label) + return fsdict[fs](partdev, label) def mkfs_ext4(partdev, label=None): + err = -1 if label: cmd = shlex.split(f'mkfs.ext4 -L {label} -F {partdev}') else: @@ -177,12 +178,15 @@ def mkfs_ext4(partdev, label=None): ret = subprocess.run(cmd, stdout=logfile, stderr=STDOUT) - + err = ret.returncode if ret.returncode != 0: logging.error(f'mkfs.ext4 reports return code {ret.returncode} for {partdev}') + return err + def mkfs_ntfs(partdev, label=None): + err = -1 if label: cmd = shlex.split(f'mkfs.ntfs -f -L {label} {partdev}') else: @@ -191,12 +195,15 @@ def mkfs_ntfs(partdev, label=None): ret = subprocess.run(cmd, stdout=logfile, stderr=STDOUT) - + err = ret.returncode if ret.returncode != 0: logging.error(f'mkfs.ntfs reports return code {ret.returncode} for {partdev}') + return err + def mkfs_fat32(partdev, label=None): + err = -1 if label: cmd = shlex.split(f'mkfs.vfat -n {label} -F32 {partdev}') else: @@ -205,12 +212,15 @@ def mkfs_fat32(partdev, label=None): ret = subprocess.run(cmd, stdout=logfile, stderr=STDOUT) - + err = ret.returncode if ret.returncode != 0: logging.error(f'mkfs.vfat reports return code {ret.returncode} for {partdev}') + return err + def mkfs_swap(partdev, label=None): + err = -1 if label: cmd = shlex.split(f'mkswap -f -L {label} {partdev}') else: @@ -219,10 +229,12 @@ def mkfs_swap(partdev, label=None): ret = subprocess.run(cmd, stdout=logfile, stderr=STDOUT) - + err = ret.returncode if ret.returncode != 0: logging.error(f'mkswap reports return code {ret.returncode} for {partdev}') + return err + def get_filesystem_type(partdev): """ |