summaryrefslogtreecommitdiffstats
path: root/src/live/ogOperations.py
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-10-01 16:58:02 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-10-01 17:02:49 +0200
commitcf9e1c96fd63d8893f4ddd58501123235c2d2728 (patch)
treee2aa536c3158a4420d761f7dd6f7bd013cb7b40f /src/live/ogOperations.py
parentf0953c969a0719438530c12ab2d84ce0993be6dd (diff)
live: fix EBUSY error in newer kernels with mkfs
python-libfdisk does not close file descriptor to /dev/sda after completing partitioning. This results EBUSY errors when formatting partitions with mkfs in newer kernels. Encapsulate code to partition in method so python garbage collection knows ctx objects can be release then close file descritor to /dev/sda. ogRest is not accessible from _partition(), remove check to ogRest.terminated, actually no need to terminate inmediately when formatting is ongoing, better leave things in consistent state when stop command is received.
Diffstat (limited to 'src/live/ogOperations.py')
-rw-r--r--src/live/ogOperations.py40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index 4b3ec13..2451c9b 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -454,23 +454,7 @@ class OgLiveOperations:
logging.info('Successful hardware inventory command execution')
return result
- def setup(self, request, ogRest):
- table_type = request.getType()
- disk = int(request.getDisk())
- cache = request.getCache()
- cache_size = request.getCacheSize()
- partlist = request.getPartitionSetup()
-
- self._ogbrowser_clear_logs()
- self._restartBrowser(self._url_log)
-
- umount_all()
- umount_cache()
-
- if disk < 0 or disk > len(get_disks()):
- raise OgError(f'Invalid disk number {disk}, {len(get_disks())} disks available.')
-
- diskname = get_disks()[disk-1]
+ def _partition(self, diskname, table_type, partlist):
cxt = fdisk.Context(f'/dev/{diskname}',
details=True)
@@ -487,8 +471,6 @@ class OgLiveOperations:
logging.info(f'Creating partition {part["partition"]} with {part["code"]} of {int(part["size"])//1024} MiB')
if part["code"] == 'EMPTY':
continue
- if ogRest.terminated:
- break
pa = fdisk.Partition(start_follow_default=True,
end_follow_default=False,
@@ -503,6 +485,26 @@ class OgLiveOperations:
cxt.write_disklabel()
os.sync()
+
+ def setup(self, request, ogRest):
+ table_type = request.getType()
+ disk = int(request.getDisk())
+ cache = request.getCache()
+ cache_size = request.getCacheSize()
+ partlist = request.getPartitionSetup()
+
+ self._ogbrowser_clear_logs()
+ self._restartBrowser(self._url_log)
+
+ umount_all()
+ umount_cache()
+
+ if disk < 0 or disk > len(get_disks()):
+ raise OgError(f'Invalid disk number {disk}, {len(get_disks())} disks available.')
+
+ diskname = get_disks()[disk-1]
+ self._partition(diskname, table_type, partlist)
+
ret = subprocess.run(['partprobe', f'/dev/{diskname}'])
logging.info(f'first partprobe /dev/{diskname} reports {ret.returncode}')