diff options
| -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) | 
