diff --git a/ogclient/lib/python3/CacheLib.py b/ogclient/lib/python3/CacheLib.py index 8edde91..28ad37b 100644 --- a/ogclient/lib/python3/CacheLib.py +++ b/ogclient/lib/python3/CacheLib.py @@ -37,6 +37,9 @@ def ogCreateCache (ndsk=1, part=4, sizecache=0): NVME_PREFIX = 'p' END = DiskLib.ogGetLastSector (ndsk) + if not END: + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, 'Failed to get last sector of disk') + return None SIZE = 2 * sizecache # Inicio partición cache según el disco tenga sectores de 4k o menores IOSIZE = 0 @@ -70,7 +73,7 @@ def ogCreateCache (ndsk=1, part=4, sizecache=0): MINSIZE = 25000 MAXSIZE = END if SIZE < MINSIZE or SIZE > MAXSIZE or START < ENDPREVPART: - SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_GENERIC, f'size ({SIZE}) < minsize ({MINSIZE}) or size > maxsize ({MAXSIZE}) or start ({START}) < endprevpart ({ENDPREVPART})') + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f'size ({SIZE}) < minsize ({MINSIZE}) or size ({SIZE}) > maxsize ({MAXSIZE}) or start ({START}) < endprevpart ({ENDPREVPART})') return None # Desmontar todos los sistemas de archivos del disco. @@ -111,6 +114,9 @@ def ogCreateCache (ndsk=1, part=4, sizecache=0): # Guardamos nueva configuración en el disco. i = '\n'.join(tmp) subprocess.run (['sfdisk', '--no-reread', DISK], input=i, text=True) + else: + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, 'No hay tabla de particiones en el disco') + return False # Actualiza la tabla de particiones en el kernel. DiskLib.ogUpdatePartitionTable() return True