From 8ba0913684cbc967db95fef050ae93cdae98670a Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Thu, 21 Nov 2024 16:11:21 +0100 Subject: [PATCH] refs #1166 add ogIsWritable() --- client/lib/engine/bin/FileSystemLib.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/client/lib/engine/bin/FileSystemLib.py b/client/lib/engine/bin/FileSystemLib.py index a843cce..80859e0 100755 --- a/client/lib/engine/bin/FileSystemLib.py +++ b/client/lib/engine/bin/FileSystemLib.py @@ -552,22 +552,18 @@ def ogIsReadonly(disk, par): options = result.stdout.strip().split(",") return "ro" in options -def ogIsWritable(int_ndisk, int_nfilesys): - if len(sys.argv) != 3: - SystemLib.ogRaiseError( - "session", - ogGlobals.OG_ERR_FORMAT, - f"Not enough arguments" - ) - return +#/** +# ogIsWritable int_ndisk int_nfilesys +#@brief Comprueba si un sistema de archivos está montado de lectura y escritura. +#@param int_ndisk nº de orden del disco +#@param int_nfilesys nº de orden del sistema de archivos +#@return Código de salida: 0 - lectura y escritura, 1 - solo lectura o no montado. +#*/ ## +def ogIsWritable (disk, par): + PART = DiskLib.ogDiskToDev (disk, par) + if not PART: return - # Obtener partición. - PART = DiskLib.ogDiskToDev(int_ndisk, int_nfilesys) - if not PART: - return - - # Comprobar si la partición está montada en modo de escritura. result = subprocess.run(["findmnt", "-n", "-o", "OPTIONS", PART], capture_output=True, text=True) options = result.stdout.strip().split(",") return "rw" in options