Changeset 33c058d3 in mainline
- Timestamp:
- 2008-05-29T00:20:06Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e19d667
- Parents:
- ff48a15
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/mktmpfs.py
rff48a15 r33c058d3 35 35 import struct 36 36 37 def align_up(size, alignment): 38 return (((size) + ((alignment) - 1)) & ~((alignment) - 1)) 39 37 40 def usage(prname): 38 41 "Print usage syntax" 39 print prname + " < PATH> <IMAGE>"42 print prname + " <ALIGNMENT> <PATH> <IMAGE>" 40 43 41 44 def main(): 42 if (len(sys.argv) < 3):45 if (len(sys.argv) < 4): 43 46 usage(sys.argv[0]) 44 47 return 45 48 46 path = os.path.abspath(sys.argv[1]); 49 if (not sys.argv[1].isdigit()): 50 print "<ALIGNMENT> must be a number" 51 return 52 53 align = int(sys.argv[1], 0) 54 path = os.path.abspath(sys.argv[2]) 47 55 if (not os.path.isdir(path)): 48 56 print "<PATH> must be a directory" 49 57 return 50 58 51 header_size = 1859 header_size = align_up(18, align) 52 60 payload_size = 0 53 outf = file(sys.argv[ 2], "w")61 outf = file(sys.argv[3], "w") 54 62 outf.write(struct.pack("<" + ("%d" % header_size) + "x")) 55 63 … … 80 88 payload_size += 5 + len(canon) 81 89 90 aligned_size = align_up(payload_size, align) 91 92 if (aligned_size - payload_size > 0): 93 outf.write(struct.pack("<" + ("%d" % (aligned_size - payload_size)) + "x")) 94 82 95 outf.seek(0) 83 outf.write(struct.pack("<4sBBLQ", "HORD", 1, 1, header_size, payload_size))96 outf.write(struct.pack("<4sBBLQ", "HORD", 1, 1, header_size, aligned_size)) 84 97 outf.close() 85 98
Note:
See TracChangeset
for help on using the changeset viewer.