Subversion Repositories HelenOS

Rev

Rev 3245 | Rev 3260 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3245 Rev 3259
Line 36... Line 36...
36
 
36
 
37
def align_up(size, alignment):
37
def align_up(size, alignment):
38
    "Align upwards to a given alignment"
38
    "Align upwards to a given alignment"
39
    return (((size) + ((alignment) - 1)) & ~((alignment) - 1))
39
    return (((size) + ((alignment) - 1)) & ~((alignment) - 1))
40
 
40
 
41
 
-
 
42
def usage(prname):
41
def usage(prname):
43
    "Print usage syntax"
42
    "Print usage syntax"
44
    print prname + " <ALIGNMENT> <FS_IMAGE> <HORD_IMAGE>"
43
    print prname + " <ALIGNMENT> <FS_IMAGE> <HORD_IMAGE>"
45
 
44
 
46
def main():
45
def main():
Line 58... Line 57...
58
        print "<FS_IMAGE> must be a file"
57
        print "<FS_IMAGE> must be a file"
59
        return
58
        return
60
   
59
   
61
    inf = file(fs_image, "rb")
60
    inf = file(fs_image, "rb")
62
    outf = file(sys.argv[3], "wb")
61
    outf = file(sys.argv[3], "wb")
63
 
62
   
64
    header_size = align_up(18, align)
63
    header_size = align_up(18, align)
65
    aligned_size = align_up(os.path.getsize(fs_image), align)
64
    aligned_size = align_up(os.path.getsize(fs_image), align)
66
 
-
 
67
   
65
   
68
    outf.write(struct.pack("<4sBBLQ", "HORD", 1, 1, header_size, aligned_size))
66
    outf.write(struct.pack("<4sBBLQ", "HORD", 1, 1, header_size, aligned_size))
69
    outf.write(struct.pack("<" + ("%d" % (header_size - 18)) + "x"))
67
    outf.write(struct.pack("<" + ("%d" % (header_size - 18)) + "x"))
70
   
68
   
71
    outf.write(inf.read())
69
    outf.write(inf.read())