makefs.c (217769) | makefs.c (223306) |
---|---|
1/* $NetBSD: makefs.c,v 1.26 2006/10/22 21:11:56 christos Exp $ */ 2 3/* 4 * Copyright (c) 2001-2003 Wasabi Systems, Inc. 5 * All rights reserved. 6 * 7 * Written by Luke Mewburn for Wasabi Systems, Inc. 8 * --- 22 unchanged lines hidden (view full) --- 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38#include <sys/cdefs.h> | 1/* $NetBSD: makefs.c,v 1.26 2006/10/22 21:11:56 christos Exp $ */ 2 3/* 4 * Copyright (c) 2001-2003 Wasabi Systems, Inc. 5 * All rights reserved. 6 * 7 * Written by Luke Mewburn for Wasabi Systems, Inc. 8 * --- 22 unchanged lines hidden (view full) --- 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/usr.sbin/makefs/makefs.c 217769 2011-01-24 06:17:05Z mckusick $"); | 39__FBSDID("$FreeBSD: head/usr.sbin/makefs/makefs.c 223306 2011-06-19 18:34:49Z marcel $"); |
40 | 40 |
41#include <sys/types.h> 42#include <sys/stat.h> |
|
41#include <assert.h> 42#include <ctype.h> 43#include <errno.h> 44#include <limits.h> 45#include <stdio.h> 46#include <stdlib.h> 47#include <string.h> 48#include <time.h> --- 26 unchanged lines hidden (view full) --- 75 76static fstype_t *get_fstype(const char *); 77static void usage(void); 78int main(int, char *[]); 79 80int 81main(int argc, char *argv[]) 82{ | 43#include <assert.h> 44#include <ctype.h> 45#include <errno.h> 46#include <limits.h> 47#include <stdio.h> 48#include <stdlib.h> 49#include <string.h> 50#include <time.h> --- 26 unchanged lines hidden (view full) --- 77 78static fstype_t *get_fstype(const char *); 79static void usage(void); 80int main(int, char *[]); 81 82int 83main(int argc, char *argv[]) 84{ |
85 struct stat sb; |
|
83 struct timeval start; 84 fstype_t *fstype; 85 fsinfo_t fsoptions; 86 fsnode *root; 87 int ch, len; | 86 struct timeval start; 87 fstype_t *fstype; 88 fsinfo_t fsoptions; 89 fsnode *root; 90 int ch, len; |
91 char *subtree; |
|
88 char *specfile; 89 90 setprogname(argv[0]); 91 92 debug = 0; 93 if ((fstype = get_fstype(DEFAULT_FSTYPE)) == NULL) 94 errx(1, "Unknown default fs type `%s'.", DEFAULT_FSTYPE); 95 --- 143 unchanged lines hidden (view full) --- 239 240 if (argc != 2) 241 usage(); 242 243 /* -x must be accompanied by -F */ 244 if (fsoptions.onlyspec != 0 && specfile == NULL) 245 errx(1, "-x requires -F mtree-specfile."); 246 | 92 char *specfile; 93 94 setprogname(argv[0]); 95 96 debug = 0; 97 if ((fstype = get_fstype(DEFAULT_FSTYPE)) == NULL) 98 errx(1, "Unknown default fs type `%s'.", DEFAULT_FSTYPE); 99 --- 143 unchanged lines hidden (view full) --- 243 244 if (argc != 2) 245 usage(); 246 247 /* -x must be accompanied by -F */ 248 if (fsoptions.onlyspec != 0 && specfile == NULL) 249 errx(1, "-x requires -F mtree-specfile."); 250 |
247 /* walk the tree */ 248 TIMER_START(start); 249 root = walk_dir(argv[1], NULL); 250 TIMER_RESULTS(start, "walk_dir"); | 251 /* Accept '-' as meaning "read from standard input". */ 252 if (strcmp(argv[1], "-") == 0) 253 sb.st_mode = S_IFREG; 254 else { 255 if (stat(argv[1], &sb) == -1) 256 err(1, "Can't stat `%s'", argv[1]); 257 } |
251 | 258 |
259 switch (sb.st_mode & S_IFMT) { 260 case S_IFDIR: /* walk the tree */ 261 subtree = argv[1]; 262 TIMER_START(start); 263 root = walk_dir(subtree, NULL); 264 TIMER_RESULTS(start, "walk_dir"); 265 break; 266 case S_IFREG: /* read the manifest file */ 267 subtree = "."; 268 TIMER_START(start); 269 root = read_mtree(argv[1], NULL); 270 TIMER_RESULTS(start, "manifest"); 271 break; 272 default: 273 errx(1, "%s: not a file or directory", argv[1]); 274 /* NOTREACHED */ 275 } 276 |
|
252 if (specfile) { /* apply a specfile */ 253 TIMER_START(start); | 277 if (specfile) { /* apply a specfile */ 278 TIMER_START(start); |
254 apply_specfile(specfile, argv[1], root, fsoptions.onlyspec); | 279 apply_specfile(specfile, subtree, root, fsoptions.onlyspec); |
255 TIMER_RESULTS(start, "apply_specfile"); 256 } 257 258 if (debug & DEBUG_DUMP_FSNODES) { | 280 TIMER_RESULTS(start, "apply_specfile"); 281 } 282 283 if (debug & DEBUG_DUMP_FSNODES) { |
259 printf("\nparent: %s\n", argv[1]); | 284 printf("\nparent: %s\n", subtree); |
260 dump_fsnodes(".", root); 261 putchar('\n'); 262 } 263 264 /* build the file system */ 265 TIMER_START(start); | 285 dump_fsnodes(".", root); 286 putchar('\n'); 287 } 288 289 /* build the file system */ 290 TIMER_START(start); |
266 fstype->make_fs(argv[0], argv[1], root, &fsoptions); | 291 fstype->make_fs(argv[0], subtree, root, &fsoptions); |
267 TIMER_RESULTS(start, "make_fs"); 268 269 free_fsnodes(root); 270 271 exit(0); 272 /* NOTREACHED */ 273} 274 --- 31 unchanged lines hidden (view full) --- 306{ 307 const char *prog; 308 309 prog = getprogname(); 310 fprintf(stderr, 311"usage: %s [-t fs-type] [-o fs-options] [-d debug-mask] [-B endian]\n" 312"\t[-S sector-size] [-M minimum-size] [-m maximum-size] [-s image-size]\n" 313"\t[-b free-blocks] [-f free-files] [-F mtree-specfile] [-x]\n" | 292 TIMER_RESULTS(start, "make_fs"); 293 294 free_fsnodes(root); 295 296 exit(0); 297 /* NOTREACHED */ 298} 299 --- 31 unchanged lines hidden (view full) --- 331{ 332 const char *prog; 333 334 prog = getprogname(); 335 fprintf(stderr, 336"usage: %s [-t fs-type] [-o fs-options] [-d debug-mask] [-B endian]\n" 337"\t[-S sector-size] [-M minimum-size] [-m maximum-size] [-s image-size]\n" 338"\t[-b free-blocks] [-f free-files] [-F mtree-specfile] [-x]\n" |
314"\t[-N userdb-dir] image-file directory\n", | 339"\t[-N userdb-dir] image-file directory | manifest\n", |
315 prog); 316 exit(1); 317} | 340 prog); 341 exit(1); 342} |