sys.exit(1)
return [self.binaries.get(binary, None)]
+ def get_raw_binary_sector(self, binary):
+ for entry in self.raw_binary_table:
+ if entry['binaries'] == binary:
+ return entry['start_sector'];
+ return None
+
def ensure_parttable(self):
logging.notice(f"Verifying that partition table on {Device} matches target specification")
for partnum, part in enumerate(self.part_table, 1):
logging.error("kname entry not found")
sys.exit(1)
+def do_fuse_raw(f, name, target, sector):
+ argv = ['dd', 'bs=512',
+ 'oflag=direct',
+ f'seek={sector}',
+ 'conv=nocreat',
+ 'status=progress',
+ f"of={Device}"]
+ logging.debug(" ".join(argv))
+ proc_dd = subprocess.Popen(argv,
+ bufsize=(1 << 9),
+ stdin=subprocess.PIPE,
+ stdout=None, stderr=None)
+ logging.notice(f"Writing {name} to {Device} at sector {sector}")
+ f.seek(0)
+ buf = f.read(1 << 9)
+ while len(buf) > 0:
+ proc_dd.stdin.write(buf)
+ buf = f.read(1 << 9)
+ proc_dd.communicate()
+ logging.info("Done")
+ #TODO: verification
+
def do_fuse_file(f, name, target):
+ sector = target.get_raw_binary_sector(name)
+ if sector is not None:
+ do_fuse_raw(f, name, target, sector)
+ return
indexes = target.get_partition_index_list(name)
if len(indexes) == 0:
logging.info(f"No partition defined for {name}, skipping.")