Changeset 677f620 in mainline for tools/mktmpfs.py


Ignore:
Timestamp:
2008-08-05T21:52:14Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
30b3ddb
Parents:
0928526
Message:

Split mktmpfs.py to a TMPFS specific part and a HORD specific part. The latter
is moved to mkhord.py and can be reused for FAT16 images as well. mktmpfs.py and
mkfat.sh define the same interface now. Modify makefiles to use the modified
interface (e.g. do not pass alignment to either mktmpfs.py or mkfat.sh). FAT16
initrd image can be now loaded as initrd on amd64 and gets recognized as a
ramdisk image.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/mktmpfs.py

    r0928526 r677f620  
    3434import os
    3535import struct
    36 
    37 def align_up(size, alignment):
    38         "Align upwards to a given alignment"
    39         return (((size) + ((alignment) - 1)) & ~((alignment) - 1))
    4036
    4137def usage(prname):
     
    7773
    7874def main():
    79         if (len(sys.argv) < 4):
     75        if (len(sys.argv) < 3):
    8076                usage(sys.argv[0])
    8177                return
    8278       
    83         if (not sys.argv[1].isdigit()):
    84                 print "<ALIGNMENT> must be a number"
    85                 return
    86        
    87         align = int(sys.argv[1], 0)
    88         path = os.path.abspath(sys.argv[2])
     79        path = os.path.abspath(sys.argv[1])
    8980        if (not os.path.isdir(path)):
    9081                print "<PATH> must be a directory"
    9182                return
    9283       
    93         header_size = align_up(18, align)
    94         outf = file(sys.argv[3], "w")
    95         outf.write(struct.pack("<" + ("%d" % header_size) + "x"))
     84        outf = file(sys.argv[2], "w")
    9685       
    9786        outf.write(struct.pack("<5s", "TMPFS"))
    98         payload_size = 5
    99        
    100         payload_size += recursion(path, outf)
     87        recursion(path, outf)
     88        outf.write(struct.pack("<BL", 0, 0))
     89
     90        outf.close()
    10191               
    102         outf.write(struct.pack("<BL", 0, 0))
    103         payload_size += 5
    104        
    105         aligned_size = align_up(payload_size, align)
    106        
    107         if (aligned_size - payload_size > 0):
    108                 outf.write(struct.pack("<" + ("%d" % (aligned_size - payload_size)) + "x"))
    109                
    110         outf.seek(0)
    111         outf.write(struct.pack("<4sBBLQ", "HORD", 1, 1, header_size, aligned_size))
    112         outf.close()
    113 
    11492if __name__ == '__main__':
    11593        main()
Note: See TracChangeset for help on using the changeset viewer.