refs #1487 add ogUnsetDirtyBit
parent
04d0b2208b
commit
3a886c8579
|
@ -866,29 +866,14 @@ def ogUnmountAll (disk):
|
|||
#@return Nada
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#*/ ##
|
||||
def ogUnsetDirtyBit(int_ndisk, int_nfilesys):
|
||||
def ogUnsetDirtyBit (disk, par):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return None
|
||||
|
||||
# Error si no se reciben 2 parámetros.
|
||||
if len(sys.argv) != 3:
|
||||
SystemLib.ogRaiseError (
|
||||
[],
|
||||
ogGlobals.OG_ERR_FORMAT,
|
||||
"Not enough arguments"
|
||||
)
|
||||
return
|
||||
|
||||
# Obtener partición y punto de montaje.
|
||||
PART = DiskLib.ogDiskToDev(int_ndisk, int_nfilesys)
|
||||
if not PART:
|
||||
return
|
||||
|
||||
# Realizar acciones específicas según el tipo de sistema de archivos.
|
||||
TYPE = ogGetFsType(int_ndisk, int_nfilesys)
|
||||
if TYPE == "NTFS":
|
||||
ogUnmount(int_ndisk, int_nfilesys)
|
||||
subprocess.run(["ntfsfix", "-d", PART], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
else:
|
||||
pass # Add more specific actions for other file systems if needed.
|
||||
TYPE = ogGetFsType (disk, par)
|
||||
if 'NTFS' == TYPE:
|
||||
ogUnmount (disk, par)
|
||||
subprocess.run (['ntfsfix', '--clear-dirty', PART])
|
||||
|
||||
|
||||
#/**
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from FileSystemLib import ogUnsetDirtyBit
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogUnsetDirtyBit', 'ogUnsetDirtyBit int_ndisk int_nfilesys', ['ogUnsetDirtyBit 1 1'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogUnsetDirtyBit (args.disk, args.par)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
Loading…
Reference in New Issue