comparison python/iso9660.py @ 283:c9781c73e7e2

Added first kernel files
author Windel Bouwman
date Fri, 15 Nov 2013 12:26:50 +0100
parents
children 1c7c1e619be8
comparison
equal deleted inserted replaced
282:c137f1fe3e65 283:c9781c73e7e2
1
2 import argparse
3
4 """
5 ISO 9660 filesystem utility.
6 """
7
8 def read_vol_desc(f):
9 s = f.read(2048)
10 ty = s[0]
11 Id = s[1:6]
12 assert Id == 'CD001'.encode('ascii')
13 ver = s[6]
14 assert ver == 1
15 data = s[7:]
16 assert len(data) == 2041
17 return ty, Id, s
18
19 def parse_boot_record(sec):
20 boot_sys_id = sec[7:39]
21 boot_id = sec[39:71]
22 print(boot_sys_id)
23 print(boot_id)
24
25 def parse_primary_volume(sec):
26 sys_id = sec[8:40]
27 vol_id = sec[40:72]
28 print(sys_id)
29 print(vol_id)
30
31 def read_iso(f):
32 # System area
33 system = f.read(16 * 2048)
34 while True:
35 ty, Id, dat = read_vol_desc(f)
36 print(ty, Id)
37 if ty == 255:
38 break
39 elif ty == 0:
40 parse_boot_record(dat)
41 elif ty == 1:
42 parse_primary_volume(dat)
43
44
45 if __name__ == '__main__':
46 with open('mikeos.iso', 'rb') as f:
47 read_iso(f)
48
49