README revision 1.6 1 1.6 snj $NetBSD: README,v 1.6 2014/10/18 08:33:31 snj 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.4 lukem cd9660 ISO 9660 file system
20 1.5 uch v7fs 7th edition(V7) file system
21 1.1 lukem
22 1.1 lukem Support for the following file systems maybe be added in the future
23 1.1 lukem ext2fs Linux EXT2 file system
24 1.1 lukem fat MS-DOS `FAT' file system (FAT12, FAT16, FAT32)
25 1.1 lukem
26 1.1 lukem Various file system independent parameters and contraints can be
27 1.1 lukem specified, such as:
28 1.1 lukem - minimum file system size (in KB)
29 1.1 lukem - maximum file system size (in KB)
30 1.1 lukem - free inodes
31 1.1 lukem - free blocks (in KB)
32 1.1 lukem - mtree(8) specification file containing permissions and ownership
33 1.1 lukem to use in image, overridding the settings in the directory tree
34 1.1 lukem - file containing list of files to specifically exclude or include
35 1.1 lukem - fnmatch(3) pattern of filenames to exclude or include
36 1.1 lukem - endianness of target file system
37 1.1 lukem
38 1.1 lukem File system specific parameters can be given as well, with a command
39 1.1 lukem line option such as "-o fsspeccific-options,comma-separated".
40 1.1 lukem For example, ffs would allow tuning of:
41 1.2 lukem - block & fragment size
42 1.1 lukem - cylinder groups
43 1.1 lukem - number of blocks per inode
44 1.1 lukem - minimum free space
45 1.1 lukem
46 1.1 lukem Other file systems might have controls on how to "munge" file names to
47 1.1 lukem fit within the constraints of the target file system.
48 1.1 lukem
49 1.1 lukem Exit codes:
50 1.1 lukem 0 all ok
51 1.1 lukem 1 fatal error
52 1.1 lukem 2 some files couldn't be added during image creation
53 1.1 lukem (bad perms, missing file, etc). image will continue
54 1.1 lukem to be made
55 1.1 lukem
56 1.1 lukem
57 1.1 lukem Implementation overview:
58 1.1 lukem ------------------------
59 1.1 lukem
60 1.1 lukem The implementation must allow for easy addition of extra file systems
61 1.1 lukem with minimal changes to the file system independent sections.
62 1.1 lukem
63 1.1 lukem The main program will:
64 1.1 lukem - parse the options, including calling fs-specific routines to
65 1.1 lukem validate fs-specific options
66 1.1 lukem - walk the tree, building up a data structure which represents
67 1.1 lukem the tree to stuff into the image. The structure will
68 1.1 lukem probably be a similar tree to what mtree(8) uses internally;
69 1.1 lukem a linked list of entries per directory with a child pointer
70 1.1 lukem to children of directories. ".." won't be stored in the list;
71 1.1 lukem the fs-specific tree walker should add this if required by the fs.
72 1.1 lukem this builder have the smarts to handle hard links correctly.
73 1.1 lukem - (optionally) Change the permissions in the tree according to
74 1.1 lukem the mtree(8) specfile
75 1.1 lukem - Call an fs-specific routine to build the image based on the
76 1.1 lukem data structures.
77 1.1 lukem
78 1.1 lukem Each fs-specific module should have the following external interfaces:
79 1.1 lukem
80 1.3 jmc prepare_options optional file system specific defaults that need to be
81 1.3 jmc setup before parsing fs-specific options.
82 1.3 jmc
83 1.1 lukem parse_options parse the string for fs-specific options, feeding
84 1.1 lukem errors back to the user as appropriate
85 1.1 lukem
86 1.3 jmc cleanup_options optional file system specific data that need to be
87 1.3 jmc cleaned up when done with this filesystem.
88 1.3 jmc
89 1.1 lukem make_fs take the data structures representing the
90 1.1 lukem directory tree and fs parameters,
91 1.1 lukem validate that the parameters are valid
92 1.1 lukem (e.g, the requested image will be large enough),
93 1.1 lukem create the image, and
94 1.1 lukem populate the image
95 1.1 lukem
96 1.3 jmc prepare_options and cleanup_options are optional and can be NULL.
97 1.3 jmc
98 1.3 jmc NOTE: All file system specific options are referenced via the fs_specific
99 1.3 jmc pointer from the fsinfo_t strucutre. It is up to the filesystem to allocate
100 1.3 jmc and free any data needed for this via the prepare and cleanup callbacks.
101 1.3 jmc
102 1.6 snj Each fs-specific module will need to add its routines to the dispatch array
103 1.3 jmc in makefs.c and add prototypes for these to makefs.h
104 1.3 jmc
105 1.3 jmc All other implementation details should not need to change any of the
106 1.3 jmc generic code.
107 1.1 lukem
108 1.1 lukem ffs implementation
109 1.1 lukem ------------------
110 1.1 lukem
111 1.1 lukem In the ffs case, we can leverage off sbin/newfs/mkfs.c to actually build
112 1.1 lukem the image. When building and populating the image, the implementation
113 1.1 lukem can be greatly simplified if some assumptions are made:
114 1.1 lukem - the total required size (in blocks and inodes) is determined
115 1.1 lukem as part of the validation phase
116 1.1 lukem - a "file" (including a directory) has a known size, so
117 1.1 lukem support for growing a file is not necessary
118 1.1 lukem
119 1.1 lukem Two underlying primitives are provided:
120 1.1 lukem make_inode create an inode, returning the inode number
121 1.1 lukem
122 1.1 lukem write_file write file (from memory if DIR, file descriptor
123 1.1 lukem if FILE or SYMLINK), referencing given inode.
124 1.1 lukem it is smart enough to know if a short symlink
125 1.1 lukem can be stuffed into the inode, etc.
126 1.1 lukem
127 1.1 lukem When creating a directory, the directory entries in the previously
128 1.1 lukem built tree data structure is scanned and built in memory so it can
129 1.1 lukem be written entirely as a single write_file() operation.
130