Changes in / [b0d309f:a2271a3] in mainline
- Files:
-
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
rb0d309f ra2271a3 88 88 @ "tmpfs" TMPFS image 89 89 @ "fat" FAT16 image 90 @ "ext2fs" EXT2 image91 90 ! RDFMT (choice) 92 91 -
boot/Makefile
rb0d309f ra2271a3 50 50 $(MKFAT) 1048576 $(DIST_PATH) $@ 51 51 endif 52 ifeq ($(RDFMT),ext2fs)53 $(MKEXT2) 1048576 $(DIST_PATH) $@54 endif55 52 56 53 build_dist: clean_dist -
boot/Makefile.common
rb0d309f ra2271a3 56 56 MKTMPFS = $(TOOLS_PATH)/mktmpfs.py 57 57 MKFAT = $(TOOLS_PATH)/mkfat.py 58 MKEXT2 = $(TOOLS_PATH)/mkext2.py59 58 MKUIMAGE = $(TOOLS_PATH)/mkuimage.py 60 59 … … 83 82 ifeq ($(RDFMT),fat) 84 83 INIT_TASKS += $(USPACE_PATH)/srv/fs/fat/fat 85 endif86 87 ifeq ($(RDFMT),ext2fs)88 INIT_TASKS += $(USPACE_PATH)/srv/fs/ext2fs/ext2fs89 84 endif 90 85 -
tools/mkfat.py
rb0d309f ra2271a3 37 37 import xstruct 38 38 import array 39 from imgutil import * 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 40 49 41 50 def subtree_size(root, cluster_size, dirent_size): … … 45 54 files = 2 46 55 47 for item in listdir_items(root): 48 if item.is_file: 49 size += align_up(item.size, cluster_size) 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) 50 61 files += 1 51 elif item.is_dir: 52 size += subtree_size(item.path, cluster_size, dirent_size) 62 63 if (os.path.isdir(canon) and (not name in exclude_names)): 64 size += subtree_size(canon, cluster_size, dirent_size) 53 65 files += 1 54 66 … … 60 72 return len(os.listdir(root)) 61 73 62 def write_file( item, outf, cluster_size, data_start, fat, reserved_clusters):74 def write_file(path, outf, cluster_size, data_start, fat, reserved_clusters): 63 75 "Store the contents of a file" 64 76 77 size = os.path.getsize(path) 65 78 prev = -1 66 79 first = 0 67 80 68 for data in chunks(item, cluster_size): 81 inf = open(path, "rb") 82 rd = 0; 83 while (rd < size): 69 84 empty_cluster = fat.index(0) 70 85 fat[empty_cluster] = 0xffff … … 77 92 prev = empty_cluster 78 93 94 data = bytes(inf.read(cluster_size)); 79 95 outf.seek(data_start + (empty_cluster - reserved_clusters) * cluster_size) 80 96 outf.write(data) 81 82 return first, item.size 97 rd += len(data) 98 inf.close() 99 100 return first, size 83 101 84 102 def write_directory(directory, outf, cluster_size, data_start, fat, reserved_clusters, dirent_size, empty_cluster): … … 285 303 empty_cluster = 0 286 304 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])) 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])) 294 315 295 316 if (head): -
tools/mktmpfs.py
rb0d309f ra2271a3 35 35 import os 36 36 import xstruct 37 from imgutil import listdir_items, chunks 37 38 exclude_names = set(['.svn', '.bzr']) 38 39 39 40 HEADER = """little: … … 70 71 "Recursive directory walk" 71 72 72 for item in listdir_items(root): 73 if item.is_file: 74 dentry = xstruct.create(DENTRY_FILE % len(item.name)) 73 for name in os.listdir(root): 74 canon = os.path.join(root, name) 75 76 if (os.path.isfile(canon) and (not name in exclude_names)): 77 size = os.path.getsize(canon) 78 79 dentry = xstruct.create(DENTRY_FILE % len(name)) 75 80 dentry.kind = TMPFS_FILE 76 dentry.fname_len = len( item.name)77 dentry.fname = item.name.encode('ascii')78 dentry.flen = item.size81 dentry.fname_len = len(name) 82 dentry.fname = name.encode('ascii') 83 dentry.flen = size 79 84 80 85 outf.write(dentry.pack()) 81 86 82 for data in chunks(item, 4096): 87 inf = open(canon, "rb") 88 rd = 0; 89 while (rd < size): 90 data = inf.read(4096); 83 91 outf.write(data) 92 rd += len(data) 93 inf.close() 84 94 85 elif item.is_dir:86 dentry = xstruct.create(DENTRY_DIRECTORY % len( item.name))95 if (os.path.isdir(canon) and (not name in exclude_names)): 96 dentry = xstruct.create(DENTRY_DIRECTORY % len(name)) 87 97 dentry.kind = TMPFS_DIRECTORY 88 dentry.fname_len = len( item.name)89 dentry.fname = item.name.encode('ascii')98 dentry.fname_len = len(name) 99 dentry.fname = name.encode('ascii') 90 100 91 101 outf.write(dentry.pack()) 92 102 93 recursion( item.path, outf)103 recursion(canon, outf) 94 104 95 105 dentry = xstruct.create(DENTRY_NONE) -
tools/xstruct.py
rb0d309f ra2271a3 1 1 # 2 2 # Copyright (c) 2008 Martin Decky 3 # Copyright (c) 2011 Martin Sucha4 3 # All rights reserved. 5 4 # … … 32 31 33 32 import struct 34 import types35 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 return52 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)))59 33 60 34 class Struct: … … 64 38 def pack(self): 65 39 args = [] 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) 40 for variable in self._args_: 41 if (isinstance(self.__dict__[variable], list)): 42 for item in self.__dict__[variable]: 74 43 args.append(item) 75 44 else: 76 check_range(variable, fmt, value)77 args.append(value)45 args.append(self.__dict__[variable]) 46 78 47 return struct.pack(self._format_, *args) 79 80 def unpack(self, data):81 values = struct.unpack(self._format_, data)82 i = 083 for variable, fmt, length in self._args_:84 self.__dict__[variable] = values[i]85 i += 186 48 87 49 def create(definition): … … 115 77 subtokens = token.split("[") 116 78 117 length = None118 79 if (len(subtokens) > 1): 119 length = int(subtokens[1].split("]")[0]) 120 format += "%d" % length 80 format += "%d" % int(subtokens[1].split("]")[0]) 121 81 122 82 format += variable 123 83 124 84 inst.__dict__[subtokens[0]] = None 125 args.append( (subtokens[0], variable, length))85 args.append(subtokens[0]) 126 86 127 87 variable = None
Note:
See TracChangeset
for help on using the changeset viewer.