summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-02-15 10:37:54 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-02-15 16:58:46 +0100
commitd6c32bba5d3d91f6917b2c856f571964fb725323 (patch)
tree3995f21feb4ec8a7e02f351f9cf105a1d2c383cc
parent0f30b1349d430bcb564e9bf736f98de6bc511e65 (diff)
fs: check if ntfsresize actually succeded to shrink filesystem
According to ntfsresize.c, this retuns 0 in case nothing needs to be done. It should be safe to check for non-zero error and bail out in that case.
-rw-r--r--src/utils/fs.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/utils/fs.py b/src/utils/fs.py
index 651801c..4fd431e 100644
--- a/src/utils/fs.py
+++ b/src/utils/fs.py
@@ -260,7 +260,10 @@ def _reduce_ntfsresize(partdev):
if new_size < size:
cmd_resize = shlex.split(f'ntfsresize -fs {new_size:.0f} {partdev}')
with open('/tmp/command.log', 'ab', 0) as logfile:
- subprocess.run(cmd_resize, input='y', stderr=STDOUT, encoding='utf-8')
+ proc_resize = subprocess.run(cmd_resize, input='y', stderr=STDOUT, encoding='utf-8')
+ if proc_resize.returncode != 0:
+ logging.error(f'ntfsresize on {partdev} with {new_size:.0f} failed with {proc_resize.returncode}')
+ return -1
return 0