refs #1098 add ogIsFormated()
parent
a5d3d8088d
commit
844ae53c05
|
@ -414,29 +414,28 @@ def ogGetMountPoint(int_ndisk, int_nfilesys):
|
||||||
result = subprocess.run(["findmnt", "-n", "-o", "TARGET", PART], capture_output=True, text=True)
|
result = subprocess.run(["findmnt", "-n", "-o", "TARGET", PART], capture_output=True, text=True)
|
||||||
return result.stdout.strip()
|
return result.stdout.strip()
|
||||||
|
|
||||||
def ogIsFormated(int_ndisk, int_nfilesys):
|
|
||||||
# Si se solicita, mostrar ayuda.
|
|
||||||
if len(sys.argv) == 3 and sys.argv[2] == "help":
|
|
||||||
ogHelp("ogIsFormated", "ogIsFormated int_ndisk int_nfilesys", "ogIsFormated 1 1")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Error si no se reciben 2 parámetros.
|
#/**
|
||||||
if len(sys.argv) != 3:
|
# ogIsFormated int_ndisk int_nfilesys
|
||||||
ogRaiseError(OG_ERR_FORMAT)
|
#@brief Comprueba si un sistema de archivos está formateado.
|
||||||
return
|
#@param int_ndisk nº de orden del disco o volumen.
|
||||||
|
#@param int_nfilesys nº de orden del sistema de archivos
|
||||||
# Obtener partición.
|
#@return Código de salida: True - formateado, False - sin formato o error.
|
||||||
PART = ogDiskToDev(int_ndisk, int_nfilesys)
|
#*/ ##
|
||||||
|
def ogIsFormated(disk, part):
|
||||||
|
PART = ogDiskToDev(disk, part)
|
||||||
if not PART:
|
if not PART:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Revisar tipo de sistema de archivos.
|
# Revisar tipo de sistema de archivos.
|
||||||
if PART.startswith("/"):
|
if PART.startswith("/"):
|
||||||
result = subprocess.run(["blkid", "-s", "TYPE", PART], capture_output=True, text=True)
|
out = subprocess.run(["blkid", "-s", "TYPE", PART], capture_output=True, text=True).stdout.strip()
|
||||||
return bool(result.stdout.strip())
|
if 'swap' in out: return False
|
||||||
|
if '_member' in out: return False
|
||||||
|
return bool(out)
|
||||||
else:
|
else:
|
||||||
result = subprocess.run(["zfs", "list", "-Hp", "-o", "canmount", PART], capture_output=True, text=True)
|
out = subprocess.run(["zfs", "list", "-Hp", "-o", "canmount", PART], capture_output=True, text=True).stdout.strip()
|
||||||
return result.stdout.strip() == "on"
|
return out == "on"
|
||||||
|
|
||||||
def ogIsLocked(int_ndisk, int_nfilesys):
|
def ogIsLocked(int_ndisk, int_nfilesys):
|
||||||
return ogIsPartitionLocked(int_ndisk, int_nfilesys)
|
return ogIsPartitionLocked(int_ndisk, int_nfilesys)
|
||||||
|
|
Loading…
Reference in New Issue