Optimized get_resume_offset()
This commit is contained in:
12
main.py
12
main.py
@@ -70,10 +70,14 @@ def get_swap_uuid():
|
|||||||
def get_resume_offset():
|
def get_resume_offset():
|
||||||
print("[+] Calculating resume_offset...")
|
print("[+] Calculating resume_offset...")
|
||||||
out = run(f"filefrag -v {SWAPFILE}", capture=True)
|
out = run(f"filefrag -v {SWAPFILE}", capture=True)
|
||||||
match = re.search(r"^\s*0:\s+(\d+)", out, re.MULTILINE)
|
for line in out.splitlines():
|
||||||
if match:
|
match = re.search(r"^\s*\d+:\s+\d+\.\.\s*\d+:\s+(\d+)", line)
|
||||||
return match.group(1)
|
if match:
|
||||||
raise RuntimeError("Couldn't find resume offset.")
|
offset = match.group(1)
|
||||||
|
if offset != "0":
|
||||||
|
print(f"[✓] Found resume_offset: {offset}")
|
||||||
|
return offset
|
||||||
|
raise RuntimeError("Couldn't find valid resume offset.")
|
||||||
|
|
||||||
def update_grub(uuid, offset):
|
def update_grub(uuid, offset):
|
||||||
print("[+] Updating GRUB_CMDLINE_LINUX_DEFAULT...")
|
print("[+] Updating GRUB_CMDLINE_LINUX_DEFAULT...")
|
||||||
|
|||||||
Reference in New Issue
Block a user