diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2019-03-03 13:18:58 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2019-03-03 13:18:58 +0100 |
commit | 66c875209a9b85fd80875f44a3ae5b92548639ba (patch) | |
tree | 1614c381adc4e2f8bd74b1a1713d2164d3003ac5 | |
parent | 2788bf237014af5c6eece0190c7f73e4a1968290 (diff) | |
download | eumel-tools-66c875209a9b85fd80875f44a3ae5b92548639ba.tar.gz eumel-tools-66c875209a9b85fd80875f44a3ae5b92548639ba.tar.bz2 eumel-tools-66c875209a9b85fd80875f44a3ae5b92548639ba.zip |
The script added a bogus/empty page at offset 0x600, since only three
instead of four entries of the first page table were skipped.
To make sure offsets are correct, add the first page (not stored on
Hintergrund) to the output as well. FILE dataspace conversion can skip
this page with `--skip 1`.
-rwxr-xr-x | convertFileDs.py | 7 | ||||
-rwxr-xr-x | extractHintergrund.py | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/convertFileDs.py b/convertFileDs.py index 89e0cab..d5c234b 100755 --- a/convertFileDs.py +++ b/convertFileDs.py @@ -9,7 +9,7 @@ datastructure here. See EUMEL packet “file handling”. import struct, copy from collections import namedtuple -from eumel import Dataspace, DataspaceTypeMismatch, HeapReferenceUnresolved +from eumel import Dataspace, DataspaceTypeMismatch, HeapReferenceUnresolved, pagesize Segment = namedtuple ('Segment', ['succ', 'pred', 'end']) Sequence = namedtuple ('Sequence', ['index', 'segmentbegin', 'segmentend', 'lineno', 'lines']) @@ -77,12 +77,13 @@ class FileDataspace (Dataspace): Dataspace.__init__ (self, fd) # header of the BOUND LIST (aka TYPE FILE) + start = fd.tell () self.used = self.parseSequence () self.parseInt (2) self.parseSequence () self.parseSequence () self.parseInt (7) - assert self.fd.tell () == 0x38 + assert self.fd.tell ()-start == 0x30 rows = self.parseRows () @@ -150,6 +151,7 @@ if __name__ == '__main__': parser = argparse.ArgumentParser(description='Convert EUMEL FILE dataspace into plain text file.') parser.add_argument ('-v', '--verbose', help='Enable debugging messages', action='store_true') + parser.add_argument ('-s', '--skip', metavar='PAGES', type=int, default=0, help='Skip pages at the beginning of the file') parser.add_argument ('file', help='Input file') args = parser.parse_args () @@ -160,6 +162,7 @@ if __name__ == '__main__': with open (args.file, 'rb') as fd: try: + fd.seek (args.skip*pagesize) ds = FileDataspace (fd) linecount = len (ds.text.splitlines ()) if linecount != ds.used.lines: diff --git a/extractHintergrund.py b/extractHintergrund.py index 8f178a0..5795d8d 100755 --- a/extractHintergrund.py +++ b/extractHintergrund.py @@ -44,6 +44,7 @@ anchor = Struct( Const(b"\xff"*4), ) * "System anchor block" +assert pagesize//blockref.sizeof() == 128 blockTable = Array(pagesize//blockref.sizeof(), blockref) # XXX: skip const @@ -212,6 +213,10 @@ if __name__ == '__main__': with open (f'{taskid:04d}_{dsid:04d}.ds', 'wb') as outfd: os.ftruncate (outfd.fileno(), 0) + # the first page of a dataspace is used by the OS + # and not stored to the Hintergrund + outfd.seek (pagesize) + # get the first three pages for ref in d.blocks: copyblock (ref.value, fd, outfd) @@ -219,7 +224,7 @@ if __name__ == '__main__': # indirect block refs (level 4a) assert len (d.blockTables) == 2 # first four entries of first table are empty and must not be written! - copyBlockTable (d.blockTables[0].value, fd, outfd, 3) + copyBlockTable (d.blockTables[0].value, fd, outfd, 4) copyBlockTable (d.blockTables[1].value, fd, outfd) # segment tables (level 4b) |