diff python/iso9660.py @ 283:c9781c73e7e2

Added first kernel files
author Windel Bouwman
date Fri, 15 Nov 2013 12:26:50 +0100
parents
children 1c7c1e619be8
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/iso9660.py	Fri Nov 15 12:26:50 2013 +0100
@@ -0,0 +1,49 @@
+
+import argparse
+
+"""
+  ISO 9660 filesystem utility.
+"""
+
+def read_vol_desc(f):
+    s = f.read(2048)
+    ty = s[0]
+    Id = s[1:6]
+    assert Id == 'CD001'.encode('ascii')
+    ver = s[6]
+    assert ver == 1
+    data = s[7:]
+    assert len(data) == 2041
+    return ty, Id, s
+
+def parse_boot_record(sec):
+    boot_sys_id = sec[7:39]
+    boot_id = sec[39:71]
+    print(boot_sys_id)
+    print(boot_id)
+
+def parse_primary_volume(sec):
+    sys_id = sec[8:40]
+    vol_id = sec[40:72]
+    print(sys_id)
+    print(vol_id)
+
+def read_iso(f):
+    # System area
+    system = f.read(16 * 2048)
+    while True:
+        ty, Id, dat = read_vol_desc(f)
+        print(ty, Id)
+        if ty == 255:
+            break
+        elif ty == 0:
+            parse_boot_record(dat)
+        elif ty == 1:
+            parse_primary_volume(dat)
+
+
+if __name__ == '__main__':
+    with open('mikeos.iso', 'rb') as f:
+        read_iso(f)
+
+