diff --git a/client/lib/engine/bin/BootLib.py b/client/lib/engine/bin/BootLib.py index a8ce397..c9e5e7d 100644 --- a/client/lib/engine/bin/BootLib.py +++ b/client/lib/engine/bin/BootLib.py @@ -135,6 +135,27 @@ def ogSetWindowsName (disk, par, name): #@exception OG_ERR_FORMAT Formato incorrecto. #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. #*/ ## +def ogFixBootSector (disk, par): + partype = DiskLib.ogGetPartitionId (disk, par) + if partype not in [ '1', '4', '6', '7', 'b', 'c', 'e', 'f', '17', '700', 'EF00' ]: + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, '') + return + + if not FileSystemLib.ogUnmount (disk, par): + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, '') + return + + disk0 = str (int (disk) - 1) + + tmpfile = tempfile.NamedTemporaryFile (prefix='ogFBS-', mode='w').name + with open (tmpfile, 'w') as fd: + fd.write (f"""disk={disk0} +main_part={par} +fix_first_sector=yes +""") + subprocess.run (['timeout', '--foreground', '--signal=SIGKILL', '5s', 'spartlnx.run', '-cui', '-nm', '-w', '-f', tmpfile], stdin=subprocess.DEVNULL) + + os.remove (tmpfile) #/** @@ -317,7 +338,7 @@ boot_entry=Herramienta de diagnstico de memoria de Windows #ogWindowsRegisterPartition ("1", "1", "c:", "1", "1") def ogWindowsRegisterPartition (registered_disk, registered_par, registered_vol, disk, par): registered_vol = registered_vol[0].upper() - tmpfile = tempfile.NamedTemporaryFile (prefix='ogWBP-', mode='w').name + tmpfile = tempfile.NamedTemporaryFile (prefix='ogWRP-', mode='w').name if not DiskLib.ogDiskToDev (registered_disk, registered_par): SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, 'particion a registrar')