refs #1101 add ogUnmount() and its dependency
parent
d49e01f9e2
commit
79c1ab34c0
|
@ -750,45 +750,62 @@ def ogUnlockPartition(int_ndisk, int_npartition):
|
|||
LOCKFILE = f"/var/lock/lock{PART.replace('/', '-')}"
|
||||
os.remove(LOCKFILE)
|
||||
|
||||
def ogUnmount():
|
||||
ogUnmountFs(*sys.argv[2:])
|
||||
|
||||
def ogUnmountFs(int_ndisk, int_npartition):
|
||||
FUNCNAME = ogUnmountFs.__name__
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if len(sys.argv) == 3 and sys.argv[2] == "help":
|
||||
ogHelp("ogUnmountFs", "ogUnmountFs int_ndisk int_npartition", "ogUnmountFs 1 1")
|
||||
return
|
||||
#/**
|
||||
# ogUnmount int_ndisk int_npartition
|
||||
#@see ogUnmountFs
|
||||
#*/ ##
|
||||
def ogUnmount (disk, par):
|
||||
ogUnmountFs (disk, par)
|
||||
|
||||
# Error si no se reciben 2 parámetros.
|
||||
if len(sys.argv) != 3:
|
||||
ogRaiseError(OG_ERR_FORMAT)
|
||||
return
|
||||
#/**
|
||||
# ogUnmountFs int_ndisk int_nfilesys
|
||||
#@brief Desmonta un sistema de archivos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@return Nada
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@warning La partición no está previamente montada o no se puede desmontar.
|
||||
#*/ ##
|
||||
|
||||
# Obtener partición y punto de montaje.
|
||||
PART = ogDiskToDev(int_ndisk, int_npartition)
|
||||
MNTDIR = ogGetMountPoint(int_ndisk, int_npartition)
|
||||
def ogUnmountFs(disk, par):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return
|
||||
MNTDIR = ogGetMountPoint (disk, par)
|
||||
|
||||
# Si está montada, desmontarla.
|
||||
if MNTDIR:
|
||||
# Error si la particion está bloqueada.
|
||||
if ogIsPartitionLocked(int_ndisk, int_npartition):
|
||||
ogRaiseError(OG_ERR_LOCKED, f"{MSG_PARTITION}, {int_ndisk} {int_npartition}")
|
||||
if ogIsLocked (disk, par):
|
||||
ogRaiseError ([], ogGlobals.OG_ERR_LOCKED, f"{ogGlobals.lang.MSG_PARTITION}, {disk} {par}")
|
||||
return
|
||||
|
||||
# Desmontar y borrar punto de montaje.
|
||||
try:
|
||||
subprocess.run(["umount", PART], check=True, stderr=subprocess.DEVNULL)
|
||||
subprocess.run(["umount", PART], check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
ogEcho("warning", f"{FUNCNAME}: {MSG_DONTUNMOUNT}: \"{int_ndisk}, {int_npartition}\"")
|
||||
SystemLib.ogEcho("warning", f'ogUnmountFs: {ogGlobals.lang.MSG_DONTUNMOUNT}: "{disk}, {par}"')
|
||||
try:
|
||||
os.rmdir(MNTDIR)
|
||||
except OSError:
|
||||
os.remove(MNTDIR)
|
||||
except:
|
||||
try:
|
||||
os.remove(MNTDIR)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
ogEcho("warning", f"{MSG_DONTMOUNT}: \"{int_ndisk},{int_npartition}\"")
|
||||
ogUnmountFs(int_ndisk, int_npartition)
|
||||
SystemLib.ogEcho ([], "warning", f'{ogGlobals.lang.MSG_DONTMOUNT}: "{disk},{par}"')
|
||||
|
||||
|
||||
#/**
|
||||
# ogUnmountAll int_ndisk
|
||||
#@brief Desmonta todos los sistema de archivos de un disco, excepto el caché local.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return Nada
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@warning No se desmonta la partición marcada como caché local.
|
||||
#*/ ##
|
||||
def ogUnmountAll(int_ndisk):
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if len(sys.argv) == 3 and sys.argv[2] == "help":
|
||||
|
|
Loading…
Reference in New Issue