Mercurial > lcfOS
comparison cos/utils/makeinitrd.py @ 41:35cc54e078dd
Added memory functions
author | windel |
---|---|
date | Fri, 03 Feb 2012 17:56:41 +0100 |
parents | cos/makeinitrd.py@3a6a9b929db0 |
children |
comparison
equal
deleted
inserted
replaced
40:24ce177e01e8 | 41:35cc54e078dd |
---|---|
1 #!/usr/bin/python | |
2 | |
3 # Script for generation of an initial ramdisk that contains | |
4 # the first programs to run. | |
5 | |
6 import struct | |
7 import sys | |
8 | |
9 if len(sys.argv) < 3: | |
10 print('Usage: {0} output file1 [file2] ...'.format(sys.argv[0])) | |
11 sys.exit(1) | |
12 | |
13 outputfilename = sys.argv[1] | |
14 inputFileNames = sys.argv[2:] | |
15 | |
16 with open(outputfilename, 'wb') as outputFile: | |
17 # Amount of files: | |
18 outputFile.write(struct.pack('<I', 0x1337babe)) | |
19 outputFile.write(struct.pack('<I', len(inputFileNames))) | |
20 for inputFileName in inputFileNames: | |
21 # Magic: | |
22 outputFile.write(struct.pack('<I', 0xcafebabe)) | |
23 | |
24 # Filename: | |
25 fn = inputFileName.encode('ascii') | |
26 outputFile.write(struct.pack('<I', len(fn))) | |
27 outputFile.write(fn) | |
28 | |
29 # Data: | |
30 with open(inputFileName, 'rb') as inputFile: | |
31 data = inputFile.read() | |
32 outputFile.write(struct.pack('<I', len(data))) | |
33 outputFile.write(data) | |
34 |