README revision 1.2
11.2Slukem$NetBSD: README,v 1.2 2004/05/31 22:21:12 lukem Exp $ 21.1Slukem 31.1Slukemmakefs - build a file system image from a directory tree 41.1Slukem 51.1SlukemNOTES: 61.1Slukem 71.1Slukem * This tool uses modified local copies of source found in other 81.1Slukem parts of the tree. This is intentional. 91.1Slukem 101.1Slukem * makefs is a work in progress, and subject to change. 111.1Slukem 121.1Slukem 131.1Slukemuser overview: 141.1Slukem-------------- 151.1Slukem 161.1Slukemmakefs creates a file system image from a given directory tree. 171.1Slukemthe following file system types can be built: 181.1Slukem ffs BSD fast file system 191.1Slukem 201.1SlukemSupport for the following file systems maybe be added in the future 211.1Slukem ext2fs Linux EXT2 file system 221.1Slukem fat MS-DOS `FAT' file system (FAT12, FAT16, FAT32) 231.1Slukem cd9660 ISO 9660 file system 241.1Slukem 251.1SlukemVarious file system independent parameters and contraints can be 261.1Slukemspecified, such as: 271.1Slukem - minimum file system size (in KB) 281.1Slukem - maximum file system size (in KB) 291.1Slukem - free inodes 301.1Slukem - free blocks (in KB) 311.1Slukem - mtree(8) specification file containing permissions and ownership 321.1Slukem to use in image, overridding the settings in the directory tree 331.1Slukem - file containing list of files to specifically exclude or include 341.1Slukem - fnmatch(3) pattern of filenames to exclude or include 351.1Slukem - endianness of target file system 361.1Slukem 371.1SlukemFile system specific parameters can be given as well, with a command 381.1Slukemline option such as "-o fsspeccific-options,comma-separated". 391.1SlukemFor example, ffs would allow tuning of: 401.2Slukem - block & fragment size 411.1Slukem - cylinder groups 421.1Slukem - number of blocks per inode 431.1Slukem - minimum free space 441.1Slukem 451.1SlukemOther file systems might have controls on how to "munge" file names to 461.1Slukemfit within the constraints of the target file system. 471.1Slukem 481.1SlukemExit codes: 491.1Slukem 0 all ok 501.1Slukem 1 fatal error 511.1Slukem 2 some files couldn't be added during image creation 521.1Slukem (bad perms, missing file, etc). image will continue 531.1Slukem to be made 541.1Slukem 551.1Slukem 561.1SlukemImplementation overview: 571.1Slukem------------------------ 581.1Slukem 591.1SlukemThe implementation must allow for easy addition of extra file systems 601.1Slukemwith minimal changes to the file system independent sections. 611.1Slukem 621.1SlukemThe main program will: 631.1Slukem - parse the options, including calling fs-specific routines to 641.1Slukem validate fs-specific options 651.1Slukem - walk the tree, building up a data structure which represents 661.1Slukem the tree to stuff into the image. The structure will 671.1Slukem probably be a similar tree to what mtree(8) uses internally; 681.1Slukem a linked list of entries per directory with a child pointer 691.1Slukem to children of directories. ".." won't be stored in the list; 701.1Slukem the fs-specific tree walker should add this if required by the fs. 711.1Slukem this builder have the smarts to handle hard links correctly. 721.1Slukem - (optionally) Change the permissions in the tree according to 731.1Slukem the mtree(8) specfile 741.1Slukem - Call an fs-specific routine to build the image based on the 751.1Slukem data structures. 761.1Slukem 771.1SlukemEach fs-specific module should have the following external interfaces: 781.1Slukem 791.1Slukem parse_options parse the string for fs-specific options, feeding 801.1Slukem errors back to the user as appropriate 811.1Slukem 821.1Slukem make_fs take the data structures representing the 831.1Slukem directory tree and fs parameters, 841.1Slukem validate that the parameters are valid 851.1Slukem (e.g, the requested image will be large enough), 861.1Slukem create the image, and 871.1Slukem populate the image 881.1Slukem 891.1Slukem 901.1Slukemffs implementation 911.1Slukem------------------ 921.1Slukem 931.1SlukemIn the ffs case, we can leverage off sbin/newfs/mkfs.c to actually build 941.1Slukemthe image. When building and populating the image, the implementation 951.1Slukemcan be greatly simplified if some assumptions are made: 961.1Slukem - the total required size (in blocks and inodes) is determined 971.1Slukem as part of the validation phase 981.1Slukem - a "file" (including a directory) has a known size, so 991.1Slukem support for growing a file is not necessary 1001.1Slukem 1011.1SlukemTwo underlying primitives are provided: 1021.1Slukem make_inode create an inode, returning the inode number 1031.1Slukem 1041.1Slukem write_file write file (from memory if DIR, file descriptor 1051.1Slukem if FILE or SYMLINK), referencing given inode. 1061.1Slukem it is smart enough to know if a short symlink 1071.1Slukem can be stuffed into the inode, etc. 1081.1Slukem 1091.1SlukemWhen creating a directory, the directory entries in the previously 1101.1Slukembuilt tree data structure is scanned and built in memory so it can 1111.1Slukembe written entirely as a single write_file() operation. 112