refs #1164 ogRaiseError function call correction
parent
18339f947c
commit
bb0805e237
|
@ -9,18 +9,17 @@ import CacheLib
|
||||||
import FileSystemLib
|
import FileSystemLib
|
||||||
|
|
||||||
def ogCheckFs(int_ndisk, int_nfilesys):
|
def ogCheckFs(int_ndisk, int_nfilesys):
|
||||||
# Si se solicita, mostrar ayuda.
|
|
||||||
if int_ndisk == "help":
|
|
||||||
ogHelp("ogCheckFs", "ogCheckFs int_ndisk int_nfilesys", "ogCheckFs 1 1")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Error si no se reciben 2 parámetros.
|
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
ogRaiseError(OG_ERR_FORMAT)
|
SystemLib.ogRaiseError(
|
||||||
|
"session",
|
||||||
|
ogGlobals.OG_ERR_FORMAT,
|
||||||
|
"Not enough arguments"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Obtener partición.
|
# Obtener partición.
|
||||||
PART = ogDiskToDev(int_ndisk, int_nfilesys)
|
PART = DiskLib.ogDiskToDev(int_ndisk, int_nfilesys)
|
||||||
if not PART:
|
if not PART:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -73,16 +72,28 @@ def ogCheckFs(int_ndisk, int_nfilesys):
|
||||||
elif TYPE == "ZFS":
|
elif TYPE == "ZFS":
|
||||||
PROG = "fsck.zfs"
|
PROG = "fsck.zfs"
|
||||||
else:
|
else:
|
||||||
ogRaiseError(OG_ERR_PARTITION, f"{int_ndisk}, {int_nfilesys}")
|
SystemLib.ogRaiseError(
|
||||||
|
"session",
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{int_ndisk}, {int_nfilesys}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Error si el sistema de archivos esta montado o bloqueado.
|
# Error si el sistema de archivos esta montado o bloqueado.
|
||||||
ogUnmount(int_ndisk, int_nfilesys)
|
ogUnmount(int_ndisk, int_nfilesys)
|
||||||
if ogIsMounted(int_ndisk, int_nfilesys):
|
if ogIsMounted(int_ndisk, int_nfilesys):
|
||||||
ogRaiseError(OG_ERR_PARTITION, f"{int_ndisk} {int_nfilesys}")
|
SystemLib.ogRaiseError(
|
||||||
|
"session",
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{int_ndisk} {int_nfilesys}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
if ogIsLocked(int_ndisk, int_nfilesys):
|
if ogIsLocked(int_ndisk, int_nfilesys):
|
||||||
ogRaiseError(OG_ERR_LOCKED, f"{int_ndisk} {int_nfilesys}")
|
SystemLib.ogRaiseError(
|
||||||
|
"session",
|
||||||
|
ogGlobals.OG_ERR_LOCKED,
|
||||||
|
f"{int_ndisk} {int_nfilesys}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Comprobar en modo uso exclusivo.
|
# Comprobar en modo uso exclusivo.
|
||||||
|
@ -91,28 +102,36 @@ def ogCheckFs(int_ndisk, int_nfilesys):
|
||||||
result = subprocess.run([PROG, PARAMS, PART], capture_output=True)
|
result = subprocess.run([PROG, PARAMS, PART], capture_output=True)
|
||||||
ERRCODE = result.returncode
|
ERRCODE = result.returncode
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
ogRaiseError(OG_ERR_NOTEXEC, PROG)
|
SystemLib.ogRaiseError(
|
||||||
ERRCODE = OG_ERR_NOTEXEC
|
"session",
|
||||||
|
ogGlobals.OG_ERR_NOTEXEC,
|
||||||
|
PROG
|
||||||
|
)
|
||||||
|
ERRCODE = ogGlobals.OG_ERR_NOTEXEC
|
||||||
except:
|
except:
|
||||||
ogRaiseError(OG_ERR_PARTITION, f"{int_ndisk} {int_nfilesys}")
|
SystemLib.ogRaiseError(
|
||||||
ERRCODE = OG_ERR_PARTITION
|
"session",
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{int_ndisk} {int_nfilesys}"
|
||||||
|
)
|
||||||
|
ERRCODE = ogGlobals.OG_ERR_PARTITION
|
||||||
|
|
||||||
ogUnlock(int_ndisk, int_nfilesys)
|
ogUnlock(int_ndisk, int_nfilesys)
|
||||||
return ERRCODE
|
return ERRCODE
|
||||||
|
|
||||||
def ogExtendFs():
|
def ogExtendFs():
|
||||||
# Si se solicita, mostrar ayuda.
|
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == "help":
|
|
||||||
ogHelp("ogExtendFs", "ogExtendFs int_ndisk int_nfilesys", "ogExtendFs 1 1")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Error si no se reciben 2 parámetros.
|
# Error si no se reciben 2 parámetros.
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
ogRaiseError(OG_ERR_FORMAT)
|
SystemLib.ogRaiseError(
|
||||||
|
"session",
|
||||||
|
ogGlobals.OG_ERR_FORMAT,
|
||||||
|
f"Not enough arguments"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Obtener partición.
|
# Obtener partición.
|
||||||
PART = ogDiskToDev(int(sys.argv[1]), int(sys.argv[2]))
|
PART = DiskLib.ogDiskToDev(int(sys.argv[1]), int(sys.argv[2]))
|
||||||
if not PART:
|
if not PART:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -134,7 +153,11 @@ def ogExtendFs():
|
||||||
PROG = "ntfsresize"
|
PROG = "ntfsresize"
|
||||||
PARAMS = "<<<\"y\" -f"
|
PARAMS = "<<<\"y\" -f"
|
||||||
else:
|
else:
|
||||||
ogRaiseError(OG_ERR_PARTITION, f"{int(sys.argv[1])} {int(sys.argv[2])} {TYPE}")
|
SystemLib.ogRaiseError(
|
||||||
|
"session",
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{int(sys.argv[1])} {int(sys.argv[2])} {TYPE}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Salida normal si no se va a aplicar la operación.
|
# Salida normal si no se va a aplicar la operación.
|
||||||
|
@ -149,12 +172,20 @@ def ogExtendFs():
|
||||||
else:
|
else:
|
||||||
ogUnmount(int(sys.argv[1]), int(sys.argv[2]))
|
ogUnmount(int(sys.argv[1]), int(sys.argv[2]))
|
||||||
if ogIsMounted(int(sys.argv[1]), int(sys.argv[2])):
|
if ogIsMounted(int(sys.argv[1]), int(sys.argv[2])):
|
||||||
ogRaiseError(OG_ERR_PARTITION, f"{int(sys.argv[1])} {int(sys.argv[2])}")
|
SystemLib.ogRaiseError(
|
||||||
|
"session",
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{int(sys.argv[1])} {int(sys.argv[2])}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Error si el sistema de archivos está bloqueado.
|
# Error si el sistema de archivos está bloqueado.
|
||||||
if ogIsLocked(int(sys.argv[1]), int(sys.argv[2])):
|
if ogIsLocked(int(sys.argv[1]), int(sys.argv[2])):
|
||||||
ogRaiseError(OG_ERR_LOCKED, f"{int(sys.argv[1])} {int(sys.argv[2])}")
|
SystemLib.ogRaiseError(
|
||||||
|
"session",
|
||||||
|
ogGlobals.OG_ERR_LOCKED,
|
||||||
|
f"{int(sys.argv[1])} {int(sys.argv[2])}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Redimensionar en modo uso exclusivo.
|
# Redimensionar en modo uso exclusivo.
|
||||||
|
@ -163,11 +194,19 @@ def ogExtendFs():
|
||||||
subprocess.run([PROG, PARAMS, PART], capture_output=True)
|
subprocess.run([PROG, PARAMS, PART], capture_output=True)
|
||||||
ERRCODE = 0
|
ERRCODE = 0
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
ogRaiseError(OG_ERR_NOTEXEC, PROG)
|
SystemLib.ogRaiseError(
|
||||||
ERRCODE = OG_ERR_NOTEXEC
|
"session",
|
||||||
|
ogGlobals.OG_ERR_NOTEXEC,
|
||||||
|
PROG
|
||||||
|
)
|
||||||
|
ERRCODE = ogGlobals.OG_ERR_NOTEXEC
|
||||||
except:
|
except:
|
||||||
ogRaiseError(OG_ERR_PARTITION, f"{int(sys.argv[1])} {int(sys.argv[2])}")
|
SystemLib.ogRaiseError(
|
||||||
ERRCODE = OG_ERR_PARTITION
|
"session",
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{int(sys.argv[1])} {int(sys.argv[2])}"
|
||||||
|
)
|
||||||
|
ERRCODE = ogGlobals.OG_ERR_PARTITION
|
||||||
|
|
||||||
ogUnlock(int(sys.argv[1]), int(sys.argv[2]))
|
ogUnlock(int(sys.argv[1]), int(sys.argv[2]))
|
||||||
return ERRCODE
|
return ERRCODE
|
||||||
|
@ -205,17 +244,29 @@ def ogFormatFs (disk, par, type=None, label=None):
|
||||||
if not PART: return
|
if not PART: return
|
||||||
|
|
||||||
if ogIsMounted (disk, par):
|
if ogIsMounted (disk, par):
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_DONTFORMAT, f'{ogGlobals.lang.MSG_MOUNT}: {disk} {par}')
|
SystemLib.ogRaiseError(
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_DONTFORMAT,
|
||||||
|
f'{ogGlobals.lang.MSG_MOUNT}: {disk} {par}'
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
if ogIsLocked (disk, par):
|
if ogIsLocked (disk, par):
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_LOCKED, f"{disk} {par}")
|
SystemLib.ogRaiseError(
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_LOCKED,
|
||||||
|
f"{disk} {par}"
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not type:
|
if not type:
|
||||||
type = ogGetFsType (disk, par)
|
type = ogGetFsType (disk, par)
|
||||||
|
|
||||||
if not type:
|
if not type:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f"{disk} {par} ...")
|
SystemLib.ogRaiseError(
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_FORMAT,
|
||||||
|
f"{disk} {par} ..."
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
|
@ -240,7 +291,11 @@ def ogFormatFs (disk, par, type=None, label=None):
|
||||||
'UFS': { 'PROG': 'mkfs.ufs', 'PARAMS': '-O 2' },
|
'UFS': { 'PROG': 'mkfs.ufs', 'PARAMS': '-O 2' },
|
||||||
}
|
}
|
||||||
if type not in data:
|
if type not in data:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f"{disk} {par} {type}")
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{disk} {par} {type}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
d = data[type]
|
d = data[type]
|
||||||
|
@ -250,7 +305,11 @@ def ogFormatFs (disk, par, type=None, label=None):
|
||||||
input = d['INPUT'] if 'INPUT' in d else ''
|
input = d['INPUT'] if 'INPUT' in d else ''
|
||||||
|
|
||||||
if label == "CACHE":
|
if label == "CACHE":
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f"{ogGlobals.lang.MSG_RESERVEDVALUE}: CACHE")
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_FORMAT,
|
||||||
|
f"{ogGlobals.lang.MSG_RESERVEDVALUE}: CACHE"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
if label:
|
if label:
|
||||||
params = f"{params} {labelparam or '-L'} {label}"
|
params = f"{params} {labelparam or '-L'} {label}"
|
||||||
|
@ -263,10 +322,18 @@ def ogFormatFs (disk, par, type=None, label=None):
|
||||||
else:
|
else:
|
||||||
errcode = subprocess.run ([prog, params, PART], input=input, text=True)
|
errcode = subprocess.run ([prog, params, PART], input=input, text=True)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTEXEC, prog)
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_NOTEXEC,
|
||||||
|
prog
|
||||||
|
)
|
||||||
errcode = ogGlobals.OG_ERR_NOTEXEC
|
errcode = ogGlobals.OG_ERR_NOTEXEC
|
||||||
except:
|
except:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f"{disk} {par}")
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{disk} {par}"
|
||||||
|
)
|
||||||
errcode = ogGlobals.OG_ERR_PARTITION
|
errcode = ogGlobals.OG_ERR_PARTITION
|
||||||
|
|
||||||
ogUnlock (disk, par)
|
ogUnlock (disk, par)
|
||||||
|
@ -293,7 +360,11 @@ def ogGetFsSize (disk, par, unit='KB'):
|
||||||
elif unit.upper() == "TB":
|
elif unit.upper() == "TB":
|
||||||
factor = 1024 * 1024 * 1024
|
factor = 1024 * 1024 * 1024
|
||||||
elif unit.upper() != "KB":
|
elif unit.upper() != "KB":
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f"{unit} != {{ KB, MB, GB, TB }}")
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_FORMAT,
|
||||||
|
f"{unit} != {{ KB, MB, GB, TB }}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Obtener el tamaño del sistema de archivo (si no está formateado; tamaño = 0).
|
# Obtener el tamaño del sistema de archivo (si no está formateado; tamaño = 0).
|
||||||
|
@ -334,7 +405,11 @@ def ogGetFsType(disk, part):
|
||||||
try:
|
try:
|
||||||
subprocess.run(["zfs", "mount", PART])
|
subprocess.run(["zfs", "mount", PART])
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTEXEC, 'zfs')
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_NOTEXEC,
|
||||||
|
'zfs'
|
||||||
|
)
|
||||||
return
|
return
|
||||||
out = subprocess.run(["mount"], capture_output=True, text=True).stdout.splitlines()
|
out = subprocess.run(["mount"], capture_output=True, text=True).stdout.splitlines()
|
||||||
for line in out:
|
for line in out:
|
||||||
|
@ -343,7 +418,11 @@ def ogGetFsType(disk, part):
|
||||||
break
|
break
|
||||||
|
|
||||||
if not TYPE:
|
if not TYPE:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f'{disk} {part}')
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_NOTFOUND,
|
||||||
|
f'{disk} {part}'
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Componer valores correctos.
|
# Componer valores correctos.
|
||||||
|
@ -474,18 +553,17 @@ def ogIsReadonly(disk, par):
|
||||||
return "ro" in options
|
return "ro" in options
|
||||||
|
|
||||||
def ogIsWritable(int_ndisk, int_nfilesys):
|
def ogIsWritable(int_ndisk, int_nfilesys):
|
||||||
# Si se solicita, mostrar ayuda.
|
|
||||||
if len(sys.argv) == 3 and sys.argv[2] == "help":
|
|
||||||
ogHelp("ogIsWritable", "ogIsWritable int_ndisk int_nfilesys", "ogIsWritable 1 1")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Error si no se reciben 2 parámetros.
|
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
ogRaiseError(OG_ERR_FORMAT)
|
SystemLib.ogRaiseError(
|
||||||
|
"session",
|
||||||
|
ogGlobals.OG_ERR_FORMAT,
|
||||||
|
f"Not enough arguments"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Obtener partición.
|
# Obtener partición.
|
||||||
PART = ogDiskToDev(int_ndisk, int_nfilesys)
|
PART = DiskLib.ogDiskToDev(int_ndisk, int_nfilesys)
|
||||||
if not PART:
|
if not PART:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -528,7 +606,7 @@ def ogLockPartition (disk, par):
|
||||||
def ogMount(*args):
|
def ogMount(*args):
|
||||||
if 1 == len (args):
|
if 1 == len (args):
|
||||||
if 'cache' == args[0].lower():
|
if 'cache' == args[0].lower():
|
||||||
return ogMountCache()
|
return DiskLib.ogMountCache()
|
||||||
elif 'cdrom' == args[0].lower():
|
elif 'cdrom' == args[0].lower():
|
||||||
return ogMountCdrom()
|
return ogMountCdrom()
|
||||||
elif 2 == len (args):
|
elif 2 == len (args):
|
||||||
|
@ -536,13 +614,17 @@ def ogMount(*args):
|
||||||
|
|
||||||
def ogMountFirstFs(int_ndisk):
|
def ogMountFirstFs(int_ndisk):
|
||||||
# Obtener número de particiones del disco.
|
# Obtener número de particiones del disco.
|
||||||
NPARTS = ogGetPartitionsNumber(int_ndisk)
|
NPARTS = DiskLib.ogGetPartitionsNumber(int_ndisk)
|
||||||
for PART in range(1, NPARTS + 1):
|
for PART in range(1, NPARTS + 1):
|
||||||
MNTDIR = ogMount(int_ndisk, PART)
|
MNTDIR = ogMount(int_ndisk, PART)
|
||||||
if MNTDIR:
|
if MNTDIR:
|
||||||
return MNTDIR
|
return MNTDIR
|
||||||
ogRaiseError(OG_ERR_NOTFOUND, int_ndisk)
|
SystemLib.ogRaiseError(
|
||||||
return OG_ERR_NOTFOUND
|
"session",
|
||||||
|
ogGlobals.OG_ERR_NOTFOUND,
|
||||||
|
f"{int_ndisk}"
|
||||||
|
)
|
||||||
|
return ogGlobals.OG_ERR_NOTFOUND
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
# ogMountFs int_ndisk int_nfilesys
|
# ogMountFs int_ndisk int_nfilesys
|
||||||
|
@ -563,7 +645,11 @@ def ogMountFs (disk, par):
|
||||||
|
|
||||||
if ogIsLocked (disk, par):
|
if ogIsLocked (disk, par):
|
||||||
print (f'nati: ogMountFs: is locked disk ({disk}) par ({par})')
|
print (f'nati: ogMountFs: is locked disk ({disk}) par ({par})')
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_LOCKED, f"{ogGlobals.lang.MSG_PARTITION}, {disk} {par}")
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_LOCKED,
|
||||||
|
f"{ogGlobals.lang.MSG_PARTITION}, {disk} {par}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# El camino de un dispositivo normal comienza por el carácter "/".
|
# El camino de un dispositivo normal comienza por el carácter "/".
|
||||||
|
@ -586,7 +672,11 @@ def ogMountFs (disk, par):
|
||||||
try:
|
try:
|
||||||
rc = subprocess.run(['mount', dev, mntdir, '-o', 'force,remove_hiberfile'], check=True).returncode
|
rc = subprocess.run(['mount', dev, mntdir, '-o', 'force,remove_hiberfile'], check=True).returncode
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f"{disk}, {par}")
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{disk}, {par}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
if 0 == rc:
|
if 0 == rc:
|
||||||
|
@ -595,13 +685,21 @@ def ogMountFs (disk, par):
|
||||||
try:
|
try:
|
||||||
subprocess.run (['ntfsfix', '-d', par], check=True)
|
subprocess.run (['ntfsfix', '-d', par], check=True)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f"{disk, par}")
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{disk, par}"
|
||||||
|
)
|
||||||
#return
|
#return
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
subprocess.run (['mount', par, mntdir, '-o', 'ro'], check=True)
|
subprocess.run (['mount', par, mntdir, '-o', 'ro'], check=True)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f"{disk, par}")
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{disk, par}"
|
||||||
|
)
|
||||||
#return
|
#return
|
||||||
|
|
||||||
# Aviso de montaje de solo lectura.
|
# Aviso de montaje de solo lectura.
|
||||||
|
@ -635,23 +733,27 @@ def ogMountCdrom():
|
||||||
try:
|
try:
|
||||||
subprocess.run(["mount", "-t", "iso9660", DEV, MNTDIR], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(["mount", "-t", "iso9660", DEV, MNTDIR], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, "cdrom")
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
"cdrom"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
return MNTDIR
|
return MNTDIR
|
||||||
|
|
||||||
def ogReduceFs(int_ndisk, int_nfilesys):
|
def ogReduceFs(int_ndisk, int_nfilesys):
|
||||||
# Si se solicita, mostrar ayuda.
|
|
||||||
if len(sys.argv) == 3 and sys.argv[2] == "help":
|
|
||||||
ogHelp("ogReduceFs", "ogReduceFs int_ndisk int_nfilesys", "ogReduceFs 1 1")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Error si no se reciben 2 parámetros.
|
# Error si no se reciben 2 parámetros.
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
ogRaiseError(OG_ERR_FORMAT)
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_FORMAT,
|
||||||
|
"Not enough arguments"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Obtener partición.
|
# Obtener partición.
|
||||||
PART = ogDiskToDev(int_ndisk, int_nfilesys)
|
PART = DiskLib.ogDiskToDev(int_ndisk, int_nfilesys)
|
||||||
if not PART:
|
if not PART:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -696,7 +798,11 @@ def ogReduceFs(int_ndisk, int_nfilesys):
|
||||||
# No se reduce (por el momento).
|
# No se reduce (por el momento).
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
ogRaiseError(OG_ERR_PARTITION, f"{int_ndisk}, {int_nfilesys}")
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_PARTITION,
|
||||||
|
f"{int_ndisk}, {int_nfilesys}"
|
||||||
|
)
|
||||||
|
|
||||||
# Devuelve tamaño del sistema de ficheros.
|
# Devuelve tamaño del sistema de ficheros.
|
||||||
return ogGetFsSize(int_ndisk, int_nfilesys)
|
return ogGetFsSize(int_ndisk, int_nfilesys)
|
||||||
|
@ -754,7 +860,11 @@ def ogUnmountFs(disk, par):
|
||||||
if MNTDIR:
|
if MNTDIR:
|
||||||
# Error si la particion está bloqueada.
|
# Error si la particion está bloqueada.
|
||||||
if ogIsLocked (disk, par):
|
if ogIsLocked (disk, par):
|
||||||
ogRaiseError ([], ogGlobals.OG_ERR_LOCKED, f"{ogGlobals.lang.MSG_PARTITION}, {disk} {par}")
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_LOCKED,
|
||||||
|
f"{ogGlobals.lang.MSG_PARTITION}, {disk} {par}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Desmontar y borrar punto de montaje.
|
# Desmontar y borrar punto de montaje.
|
||||||
|
@ -785,35 +895,34 @@ def ogUnmountFs(disk, par):
|
||||||
#@warning No se desmonta la partición marcada como caché local.
|
#@warning No se desmonta la partición marcada como caché local.
|
||||||
#*/ ##
|
#*/ ##
|
||||||
def ogUnmountAll(int_ndisk):
|
def ogUnmountAll(int_ndisk):
|
||||||
# Si se solicita, mostrar ayuda.
|
|
||||||
if len(sys.argv) == 3 and sys.argv[2] == "help":
|
|
||||||
ogHelp("ogUnmountAll", "ogUnmountAll int_ndisk", "ogUnmountAll 1")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Error si no se recibe 1 parámetro.
|
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
ogRaiseError(OG_ERR_FORMAT)
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_FORMAT,
|
||||||
|
"Not enough arguments"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Obtener partición y punto de montaje.
|
# Obtener partición y punto de montaje.
|
||||||
DISK = ogDiskToDev(int_ndisk)
|
DISK = DiskLib.ogDiskToDev(int_ndisk)
|
||||||
for PART in range(1, ogGetPartitionsNumber(int_ndisk) + 1):
|
for PART in range(1, DiskLib.ogGetPartitionsNumber(int_ndisk) + 1):
|
||||||
if ogGetFsType(int_ndisk, PART) != "CACHE":
|
if ogGetFsType(int_ndisk, PART) != "CACHE":
|
||||||
ogUnmount(int_ndisk, PART)
|
ogUnmount(int_ndisk, PART)
|
||||||
|
|
||||||
def ogUnsetDirtyBit(int_ndisk, int_nfilesys):
|
def ogUnsetDirtyBit(int_ndisk, int_nfilesys):
|
||||||
# Si se solicita, mostrar ayuda.
|
|
||||||
if len(sys.argv) == 3 and sys.argv[2] == "help":
|
|
||||||
ogHelp("ogUnsetDirtyBit", "ogUnsetDirtyBit int_ndisk int_nfilesys", "ogUnsetDirtyBit 1 1")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Error si no se reciben 2 parámetros.
|
# Error si no se reciben 2 parámetros.
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
ogRaiseError(OG_ERR_FORMAT)
|
SystemLib.ogRaiseError (
|
||||||
|
[],
|
||||||
|
ogGlobals.OG_ERR_FORMAT,
|
||||||
|
"Not enough arguments"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Obtener partición y punto de montaje.
|
# Obtener partición y punto de montaje.
|
||||||
PART = ogDiskToDev(int_ndisk, int_nfilesys)
|
PART = DiskLib.ogDiskToDev(int_ndisk, int_nfilesys)
|
||||||
if not PART:
|
if not PART:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue