Changeset cc1a727 in mainline
- Timestamp:
- 2011-07-24T21:18:16Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 78eb2dc
- Parents:
- c028b22
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
rc028b22 rcc1a727 88 88 @ "tmpfs" TMPFS image 89 89 @ "fat" FAT16 image 90 @ "ext2fs" EXT2 image 90 91 ! RDFMT (choice) 91 92 -
boot/Makefile
rc028b22 rcc1a727 50 50 $(MKFAT) 1048576 $(DIST_PATH) $@ 51 51 endif 52 ifeq ($(RDFMT),ext2fs) 53 $(MKEXT2) 1048576 $(DIST_PATH) $@ 54 endif 52 55 53 56 build_dist: clean_dist -
boot/Makefile.common
rc028b22 rcc1a727 56 56 MKTMPFS = $(TOOLS_PATH)/mktmpfs.py 57 57 MKFAT = $(TOOLS_PATH)/mkfat.py 58 MKEXT2 = $(TOOLS_PATH)/mkext2.py 58 59 MKUIMAGE = $(TOOLS_PATH)/mkuimage.py 59 60 … … 82 83 ifeq ($(RDFMT),fat) 83 84 INIT_TASKS += $(USPACE_PATH)/srv/fs/fat/fat 85 endif 86 87 ifeq ($(RDFMT),ext2fs) 88 INIT_TASKS += $(USPACE_PATH)/srv/fs/ext2fs/ext2fs 84 89 endif 85 90 -
tools/mkfat.py
rc028b22 rcc1a727 37 37 import xstruct 38 38 import array 39 40 exclude_names = set(['.svn', '.bzr']) 41 42 def align_up(size, alignment): 43 "Return size aligned up to alignment" 44 45 if (size % alignment == 0): 46 return size 47 48 return ((size // alignment) + 1) * alignment 39 from imgutil import * 49 40 50 41 def subtree_size(root, cluster_size, dirent_size): … … 54 45 files = 2 55 46 56 for name in os.listdir(root): 57 canon = os.path.join(root, name) 58 59 if (os.path.isfile(canon) and (not name in exclude_names)): 60 size += align_up(os.path.getsize(canon), cluster_size) 47 for item in listdir_items(root): 48 if item.is_file: 49 size += align_up(item.size, cluster_size) 61 50 files += 1 62 63 if (os.path.isdir(canon) and (not name in exclude_names)): 64 size += subtree_size(canon, cluster_size, dirent_size) 51 elif item.is_dir: 52 size += subtree_size(item.path, cluster_size, dirent_size) 65 53 files += 1 66 54 … … 72 60 return len(os.listdir(root)) 73 61 74 def write_file( path, outf, cluster_size, data_start, fat, reserved_clusters):62 def write_file(item, outf, cluster_size, data_start, fat, reserved_clusters): 75 63 "Store the contents of a file" 76 64 77 size = os.path.getsize(path)78 65 prev = -1 79 66 first = 0 80 67 81 inf = open(path, "rb") 82 rd = 0; 83 while (rd < size): 68 for data in chunks(item, cluster_size): 84 69 empty_cluster = fat.index(0) 85 70 fat[empty_cluster] = 0xffff … … 92 77 prev = empty_cluster 93 78 94 data = bytes(inf.read(cluster_size));95 79 outf.seek(data_start + (empty_cluster - reserved_clusters) * cluster_size) 96 80 outf.write(data) 97 rd += len(data) 98 inf.close() 99 100 return first, size 81 82 return first, item.size 101 83 102 84 def write_directory(directory, outf, cluster_size, data_start, fat, reserved_clusters, dirent_size, empty_cluster): … … 303 285 empty_cluster = 0 304 286 305 for name in os.listdir(root): 306 canon = os.path.join(root, name) 307 308 if (os.path.isfile(canon) and (not name in exclude_names)): 309 rv = write_file(canon, outf, cluster_size, data_start, fat, reserved_clusters) 310 directory.append(create_dirent(name, False, rv[0], rv[1])) 311 312 if (os.path.isdir(canon) and (not name in exclude_names)): 313 rv = recursion(False, canon, outf, cluster_size, root_start, data_start, fat, reserved_clusters, dirent_size, empty_cluster) 314 directory.append(create_dirent(name, True, rv[0], rv[1])) 287 for item in listdir_items(root): 288 if item.is_file: 289 rv = write_file(item, outf, cluster_size, data_start, fat, reserved_clusters) 290 directory.append(create_dirent(item.name, False, rv[0], rv[1])) 291 elif item.is_dir: 292 rv = recursion(False, item.path, outf, cluster_size, root_start, data_start, fat, reserved_clusters, dirent_size, empty_cluster) 293 directory.append(create_dirent(item.name, True, rv[0], rv[1])) 315 294 316 295 if (head): -
tools/xstruct.py
rc028b22 rcc1a727 1 1 # 2 2 # Copyright (c) 2008 Martin Decky 3 # Copyright (c) 2011 Martin Sucha 3 4 # All rights reserved. 4 5 # … … 31 32 32 33 import struct 34 import types 35 36 ranges = { 37 'B': ((int, long), 0x00, 0xff), 38 'H': ((int, long), 0x0000, 0xffff), 39 'L': ((int, long), 0x00000000, 0xffffffff), 40 'Q': ((int, long), 0x0000000000000000, 0xffffffffffffffff), 41 'b': ((int, long), -0x80, 0x7f), 42 'h': ((int, long), -0x8000, 0x7fff), 43 'l': ((int, long), -0x80000000, 0x7fffffff) , 44 'q': ((int, long), -0x8000000000000000, 0x7fffffffffffffff), 45 } 46 47 def check_range(varname, fmt, value): 48 if value == None: 49 raise ValueError('Variable "%s" not set' % varname) 50 if not fmt in ranges: 51 return 52 vartype, varmin, varmax = ranges[fmt] 53 if not isinstance(value, vartype): 54 raise ValueError('Variable "%s" is %s but should be %s' % 55 (varname, str(type(value)), str(vartype))) 56 if value < varmin or value > varmax: 57 raise ValueError('Variable "%s" value %s out of range %s..%s' % 58 (varname, repr(value), repr(varmin), repr(varmax))) 33 59 34 60 class Struct: … … 38 64 def pack(self): 39 65 args = [] 40 for variable in self._args_: 41 if (isinstance(self.__dict__[variable], list)): 42 for item in self.__dict__[variable]: 66 for variable, fmt, length in self._args_: 67 value = self.__dict__[variable] 68 if isinstance(value, list): 69 if length != None and length != len(value): 70 raise ValueError('Variable "%s" length %u does not match %u' % 71 (variable, len(value), length)) 72 for index, item in enumerate(value): 73 check_range(variable + '[' + repr(index) + ']', fmt, item) 43 74 args.append(item) 44 75 else: 45 args.append(self.__dict__[variable])46 76 check_range(variable, fmt, value) 77 args.append(value) 47 78 return struct.pack(self._format_, *args) 79 80 def unpack(self, data): 81 values = struct.unpack(self._format_, data) 82 i = 0 83 for variable, fmt, length in self._args_: 84 self.__dict__[variable] = values[i] 85 i += 1 48 86 49 87 def create(definition): … … 77 115 subtokens = token.split("[") 78 116 117 length = None 79 118 if (len(subtokens) > 1): 80 format += "%d" % int(subtokens[1].split("]")[0]) 119 length = int(subtokens[1].split("]")[0]) 120 format += "%d" % length 81 121 82 122 format += variable 83 123 84 124 inst.__dict__[subtokens[0]] = None 85 args.append( subtokens[0])125 args.append((subtokens[0], variable, length)) 86 126 87 127 variable = None
Note:
See TracChangeset
for help on using the changeset viewer.