diff --git a/client/lib/engine/bin/FileSystemLib.py b/client/lib/engine/bin/FileSystemLib.py index bb4fc61..42c422e 100755 --- a/client/lib/engine/bin/FileSystemLib.py +++ b/client/lib/engine/bin/FileSystemLib.py @@ -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]) #/** diff --git a/client/shared/functions/ogUnsetDirtyBit b/client/shared/functions/ogUnsetDirtyBit new file mode 100755 index 0000000..c7314f2 --- /dev/null +++ b/client/shared/functions/ogUnsetDirtyBit @@ -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)