refs #2412 add and improve error messages

particionador
Natalia Serrano 2025-07-09 13:43:33 +02:00
parent 588ed96098
commit a7f4d767f5
1 changed files with 7 additions and 1 deletions

View File

@ -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