annotate ffstools/tiffs-mkfs/main.c @ 833:625bee54ed34

CHANGES: document lunadrv init-kwh addition
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 22 Jun 2021 02:28:18 +0000
parents 178ed445021d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
705
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <sys/param.h>
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <stdio.h>
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 #include <stdint.h>
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdlib.h>
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <string.h>
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <strings.h>
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "struct.h"
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "globals.h"
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 void
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 process_cmdline(argc, argv)
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 char **argv;
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 {
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern int optind;
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern char *optarg;
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 int c;
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
717
178ed445021d tiffs-mkfs: journal creation implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 705
diff changeset
19 while ((c = getopt(argc, argv, "c:f:j:Jm:")) != EOF)
705
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 switch (c) {
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 case 'c':
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 chunk_size_max = strtoul(optarg, 0, 0);
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 continue;
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 case 'f':
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (*optarg != '/') {
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 fprintf(stderr,
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 "error: format name must begin with \'/\'\n");
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 exit(1);
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 format_name = optarg;
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 continue;
717
178ed445021d tiffs-mkfs: journal creation implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 705
diff changeset
32 case 'j':
178ed445021d tiffs-mkfs: journal creation implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 705
diff changeset
33 journal_size = strtoul(optarg, 0, 0);
178ed445021d tiffs-mkfs: journal creation implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 705
diff changeset
34 continue;
178ed445021d tiffs-mkfs: journal creation implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 705
diff changeset
35 case 'J':
178ed445021d tiffs-mkfs: journal creation implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 705
diff changeset
36 no_journal = 1;
178ed445021d tiffs-mkfs: journal creation implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 705
diff changeset
37 continue;
705
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 case 'm':
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 block_files_max = strtoul(optarg, 0, 0);
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 continue;
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 default:
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 usage: fprintf(stderr,
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 "usage: %s [options] <org> <srcdir> <outfile>\n",
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 argv[0]);
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 exit(1);
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 if (argc - optind != 3)
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 goto usage;
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 parse_org_arg(argv[optind]);
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 input_host_dir = argv[optind+1];
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 output_filename = argv[optind+2];
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 main(argc, argv)
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 char **argv;
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 {
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 process_cmdline(argc, argv);
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 if (!format_name)
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 format_name = "/";
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 preen_chunk_size_max();
717
178ed445021d tiffs-mkfs: journal creation implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 705
diff changeset
61 preen_journal_size();
705
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 preen_block_files_max();
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 /* input phase */
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 read_dir_level(&root, input_host_dir, 0);
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 sort_dir_level(&root);
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 /* output phase */
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 prepare_output_buffers();
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 open_output_file();
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 create_root_dir();
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 process_dir_level(&root);
717
178ed445021d tiffs-mkfs: journal creation implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 705
diff changeset
71 if (!no_journal)
178ed445021d tiffs-mkfs: journal creation implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 705
diff changeset
72 create_journal();
705
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 finish_output();
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 close(output_fd);
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 exit(0);
12ae93940467 tiffs-mkfs program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }