README revision 1.2 1 1.2 lukem $NetBSD: README,v 1.2 2004/05/31 22:21:12 lukem Exp $
2 1.1 lukem
3 1.1 lukem makefs - build a file system image from a directory tree
4 1.1 lukem
5 1.1 lukem NOTES:
6 1.1 lukem
7 1.1 lukem * This tool uses modified local copies of source found in other
8 1.1 lukem parts of the tree. This is intentional.
9 1.1 lukem
10 1.1 lukem * makefs is a work in progress, and subject to change.
11 1.1 lukem
12 1.1 lukem
13 1.1 lukem user overview:
14 1.1 lukem --------------
15 1.1 lukem
16 1.1 lukem makefs creates a file system image from a given directory tree.
17 1.1 lukem the following file system types can be built:
18 1.1 lukem ffs BSD fast file system
19 1.1 lukem
20 1.1 lukem Support for the following file systems maybe be added in the future
21 1.1 lukem ext2fs Linux EXT2 file system
22 1.1 lukem fat MS-DOS `FAT' file system (FAT12, FAT16, FAT32)
23 1.1 lukem cd9660 ISO 9660 file system
24 1.1 lukem
25 1.1 lukem Various file system independent parameters and contraints can be
26 1.1 lukem specified, such as:
27 1.1 lukem - minimum file system size (in KB)
28 1.1 lukem - maximum file system size (in KB)
29 1.1 lukem - free inodes
30 1.1 lukem - free blocks (in KB)
31 1.1 lukem - mtree(8) specification file containing permissions and ownership
32 1.1 lukem to use in image, overridding the settings in the directory tree
33 1.1 lukem - file containing list of files to specifically exclude or include
34 1.1 lukem - fnmatch(3) pattern of filenames to exclude or include
35 1.1 lukem - endianness of target file system
36 1.1 lukem
37 1.1 lukem File system specific parameters can be given as well, with a command
38 1.1 lukem line option such as "-o fsspeccific-options,comma-separated".
39 1.1 lukem For example, ffs would allow tuning of:
40 1.2 lukem - block & fragment size
41 1.1 lukem - cylinder groups
42 1.1 lukem - number of blocks per inode
43 1.1 lukem - minimum free space
44 1.1 lukem
45 1.1 lukem Other file systems might have controls on how to "munge" file names to
46 1.1 lukem fit within the constraints of the target file system.
47 1.1 lukem
48 1.1 lukem Exit codes:
49 1.1 lukem 0 all ok
50 1.1 lukem 1 fatal error
51 1.1 lukem 2 some files couldn't be added during image creation
52 1.1 lukem (bad perms, missing file, etc). image will continue
53 1.1 lukem to be made
54 1.1 lukem
55 1.1 lukem
56 1.1 lukem Implementation overview:
57 1.1 lukem ------------------------
58 1.1 lukem
59 1.1 lukem The implementation must allow for easy addition of extra file systems
60 1.1 lukem with minimal changes to the file system independent sections.
61 1.1 lukem
62 1.1 lukem The main program will:
63 1.1 lukem - parse the options, including calling fs-specific routines to
64 1.1 lukem validate fs-specific options
65 1.1 lukem - walk the tree, building up a data structure which represents
66 1.1 lukem the tree to stuff into the image. The structure will
67 1.1 lukem probably be a similar tree to what mtree(8) uses internally;
68 1.1 lukem a linked list of entries per directory with a child pointer
69 1.1 lukem to children of directories. ".." won't be stored in the list;
70 1.1 lukem the fs-specific tree walker should add this if required by the fs.
71 1.1 lukem this builder have the smarts to handle hard links correctly.
72 1.1 lukem - (optionally) Change the permissions in the tree according to
73 1.1 lukem the mtree(8) specfile
74 1.1 lukem - Call an fs-specific routine to build the image based on the
75 1.1 lukem data structures.
76 1.1 lukem
77 1.1 lukem Each fs-specific module should have the following external interfaces:
78 1.1 lukem
79 1.1 lukem parse_options parse the string for fs-specific options, feeding
80 1.1 lukem errors back to the user as appropriate
81 1.1 lukem
82 1.1 lukem make_fs take the data structures representing the
83 1.1 lukem directory tree and fs parameters,
84 1.1 lukem validate that the parameters are valid
85 1.1 lukem (e.g, the requested image will be large enough),
86 1.1 lukem create the image, and
87 1.1 lukem populate the image
88 1.1 lukem
89 1.1 lukem
90 1.1 lukem ffs implementation
91 1.1 lukem ------------------
92 1.1 lukem
93 1.1 lukem In the ffs case, we can leverage off sbin/newfs/mkfs.c to actually build
94 1.1 lukem the image. When building and populating the image, the implementation
95 1.1 lukem can be greatly simplified if some assumptions are made:
96 1.1 lukem - the total required size (in blocks and inodes) is determined
97 1.1 lukem as part of the validation phase
98 1.1 lukem - a "file" (including a directory) has a known size, so
99 1.1 lukem support for growing a file is not necessary
100 1.1 lukem
101 1.1 lukem Two underlying primitives are provided:
102 1.1 lukem make_inode create an inode, returning the inode number
103 1.1 lukem
104 1.1 lukem write_file write file (from memory if DIR, file descriptor
105 1.1 lukem if FILE or SYMLINK), referencing given inode.
106 1.1 lukem it is smart enough to know if a short symlink
107 1.1 lukem can be stuffed into the inode, etc.
108 1.1 lukem
109 1.1 lukem When creating a directory, the directory entries in the previously
110 1.1 lukem built tree data structure is scanned and built in memory so it can
111 1.1 lukem be written entirely as a single write_file() operation.
112