return the bit of the option set, so that others can act on it.diff -r1.51 -r1.52 src/usr.sbin/makefs/ffs.c
(christos)
--- src/usr.sbin/makefs/ffs.c 2013/01/23 21:32:32 1.51
+++ src/usr.sbin/makefs/ffs.c 2013/01/23 21:42:22 1.52
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ffs.c,v 1.51 2013/01/23 21:32:32 christos Exp $ */ | 1 | /* $NetBSD: ffs.c,v 1.52 2013/01/23 21:42:22 christos Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001 Wasabi Systems, Inc. | 4 | * Copyright (c) 2001 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Luke Mewburn for Wasabi Systems, Inc. | 7 | * Written by Luke Mewburn for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -61,27 +61,27 @@ | @@ -61,27 +61,27 @@ | |||
61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
63 | * SUCH DAMAGE. | 63 | * SUCH DAMAGE. | |
64 | * | 64 | * | |
65 | * @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95 | 65 | * @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95 | |
66 | */ | 66 | */ | |
67 | 67 | |||
68 | #if HAVE_NBTOOL_CONFIG_H | 68 | #if HAVE_NBTOOL_CONFIG_H | |
69 | #include "nbtool_config.h" | 69 | #include "nbtool_config.h" | |
70 | #endif | 70 | #endif | |
71 | 71 | |||
72 | #include <sys/cdefs.h> | 72 | #include <sys/cdefs.h> | |
73 | #if defined(__RCSID) && !defined(__lint) | 73 | #if defined(__RCSID) && !defined(__lint) | |
74 | __RCSID("$NetBSD: ffs.c,v 1.51 2013/01/23 21:32:32 christos Exp $"); | 74 | __RCSID("$NetBSD: ffs.c,v 1.52 2013/01/23 21:42:22 christos Exp $"); | |
75 | #endif /* !__lint */ | 75 | #endif /* !__lint */ | |
76 | 76 | |||
77 | #include <sys/param.h> | 77 | #include <sys/param.h> | |
78 | 78 | |||
79 | #if !HAVE_NBTOOL_CONFIG_H | 79 | #if !HAVE_NBTOOL_CONFIG_H | |
80 | #include <sys/mount.h> | 80 | #include <sys/mount.h> | |
81 | #endif | 81 | #endif | |
82 | 82 | |||
83 | #include <assert.h> | 83 | #include <assert.h> | |
84 | #include <errno.h> | 84 | #include <errno.h> | |
85 | #include <fcntl.h> | 85 | #include <fcntl.h> | |
86 | #include <stdarg.h> | 86 | #include <stdarg.h> | |
87 | #include <stdio.h> | 87 | #include <stdio.h> | |
@@ -222,26 +222,29 @@ ffs_parse_opts(const char *option, fsinf | @@ -222,26 +222,29 @@ ffs_parse_opts(const char *option, fsinf | |||
222 | assert(fsopts != NULL); | 222 | assert(fsopts != NULL); | |
223 | assert(ffs_opts != NULL); | 223 | assert(ffs_opts != NULL); | |
224 | 224 | |||
225 | if (debug & DEBUG_FS_PARSE_OPTS) | 225 | if (debug & DEBUG_FS_PARSE_OPTS) | |
226 | printf("ffs_parse_opts: got `%s'\n", option); | 226 | printf("ffs_parse_opts: got `%s'\n", option); | |
227 | 227 | |||
228 | rv = set_option(ffs_options, option); | 228 | rv = set_option(ffs_options, option); | |
229 | if (rv == 0) | 229 | if (rv == 0) | |
230 | return 0; | 230 | return 0; | |
231 | 231 | |||
232 | for (i = 0; ffs_options[i].name && (1 << i) != rv; i++) | 232 | for (i = 0; ffs_options[i].name && (1 << i) != rv; i++) | |
233 | continue; | 233 | continue; | |
234 | 234 | |||
235 | if (ffs_options[i].name == NULL) | |||
236 | abort(); | |||
237 | ||||
235 | if (strcmp(ffs_options[i].name, "optimization") == 0) { | 238 | if (strcmp(ffs_options[i].name, "optimization") == 0) { | |
236 | if (strcmp(optimization, "time") == 0) { | 239 | if (strcmp(optimization, "time") == 0) { | |
237 | ffs_opts->optimization = FS_OPTTIME; | 240 | ffs_opts->optimization = FS_OPTTIME; | |
238 | } else if (strcmp(optimization, "space") == 0) { | 241 | } else if (strcmp(optimization, "space") == 0) { | |
239 | ffs_opts->optimization = FS_OPTSPACE; | 242 | ffs_opts->optimization = FS_OPTSPACE; | |
240 | } else { | 243 | } else { | |
241 | warnx("Invalid optimization `%s'", optimization); | 244 | warnx("Invalid optimization `%s'", optimization); | |
242 | return 0; | 245 | return 0; | |
243 | } | 246 | } | |
244 | } | 247 | } | |
245 | return rv; | 248 | return rv; | |
246 | } | 249 | } | |
247 | 250 |
--- src/usr.sbin/makefs/makefs.c 2013/01/23 21:32:32 1.37
+++ src/usr.sbin/makefs/makefs.c 2013/01/23 21:42:22 1.38
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: makefs.c,v 1.37 2013/01/23 21:32:32 christos Exp $ */ | 1 | /* $NetBSD: makefs.c,v 1.38 2013/01/23 21:42:22 christos Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001-2003 Wasabi Systems, Inc. | 4 | * Copyright (c) 2001-2003 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Luke Mewburn for Wasabi Systems, Inc. | 7 | * Written by Luke Mewburn for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -31,27 +31,27 @@ | @@ -31,27 +31,27 @@ | |||
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 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 | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 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 | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | 35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | #if HAVE_NBTOOL_CONFIG_H | 38 | #if HAVE_NBTOOL_CONFIG_H | |
39 | #include "nbtool_config.h" | 39 | #include "nbtool_config.h" | |
40 | #endif | 40 | #endif | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | #if defined(__RCSID) && !defined(__lint) | 43 | #if defined(__RCSID) && !defined(__lint) | |
44 | __RCSID("$NetBSD: makefs.c,v 1.37 2013/01/23 21:32:32 christos Exp $"); | 44 | __RCSID("$NetBSD: makefs.c,v 1.38 2013/01/23 21:42:22 christos Exp $"); | |
45 | #endif /* !__lint */ | 45 | #endif /* !__lint */ | |
46 | 46 | |||
47 | #include <assert.h> | 47 | #include <assert.h> | |
48 | #include <ctype.h> | 48 | #include <ctype.h> | |
49 | #include <errno.h> | 49 | #include <errno.h> | |
50 | #include <limits.h> | 50 | #include <limits.h> | |
51 | #include <stdio.h> | 51 | #include <stdio.h> | |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> | |
53 | #include <string.h> | 53 | #include <string.h> | |
54 | #include <unistd.h> | 54 | #include <unistd.h> | |
55 | #include <stdbool.h> | 55 | #include <stdbool.h> | |
56 | 56 | |||
57 | #include "makefs.h" | 57 | #include "makefs.h" | |
@@ -357,27 +357,27 @@ set_option_var(const option_t *options, | @@ -357,27 +357,27 @@ set_option_var(const option_t *options, | |||
357 | case OPT_INT64: | 357 | case OPT_INT64: | |
358 | NUM(64); | 358 | NUM(64); | |
359 | case OPT_INT32: | 359 | case OPT_INT32: | |
360 | NUM(32); | 360 | NUM(32); | |
361 | case OPT_INT16: | 361 | case OPT_INT16: | |
362 | NUM(16); | 362 | NUM(16); | |
363 | case OPT_INT8: | 363 | case OPT_INT8: | |
364 | NUM(8); | 364 | NUM(8); | |
365 | default: | 365 | default: | |
366 | warnx("Unknown type %d in option %s", options[i].type, | 366 | warnx("Unknown type %d in option %s", options[i].type, | |
367 | val); | 367 | val); | |
368 | return 0; | 368 | return 0; | |
369 | } | 369 | } | |
370 | return 1; | 370 | return 1 << i; | |
371 | } | 371 | } | |
372 | warnx("Unknown option `%s'", var); | 372 | warnx("Unknown option `%s'", var); | |
373 | return (0); | 373 | return (0); | |
374 | } | 374 | } | |
375 | 375 | |||
376 | 376 | |||
377 | static fstype_t * | 377 | static fstype_t * | |
378 | get_fstype(const char *type) | 378 | get_fstype(const char *type) | |
379 | { | 379 | { | |
380 | int i; | 380 | int i; | |
381 | 381 | |||
382 | for (i = 0; fstypes[i].type != NULL; i++) | 382 | for (i = 0; fstypes[i].type != NULL; i++) | |
383 | if (strcmp(fstypes[i].type, type) == 0) | 383 | if (strcmp(fstypes[i].type, type) == 0) |
--- src/usr.sbin/makefs/msdos.c 2013/01/23 21:32:32 1.2
+++ src/usr.sbin/makefs/msdos.c 2013/01/23 21:42:22 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: msdos.c,v 1.2 2013/01/23 21:32:32 christos Exp $ */ | 1 | /* $NetBSD: msdos.c,v 1.3 2013/01/23 21:42:22 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Christos Zoulas. | 8 | * by Christos Zoulas. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
32 | * POSSIBILITY OF SUCH DAMAGE. | 32 | * POSSIBILITY OF SUCH DAMAGE. | |
33 | */ | 33 | */ | |
34 | #if HAVE_NBTOOL_CONFIG_H | 34 | #if HAVE_NBTOOL_CONFIG_H | |
35 | #include "nbtool_config.h" | 35 | #include "nbtool_config.h" | |
36 | #endif | 36 | #endif | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | #if defined(__RCSID) && !defined(__lint) | 39 | #if defined(__RCSID) && !defined(__lint) | |
40 | __RCSID("$NetBSD: msdos.c,v 1.2 2013/01/23 21:32:32 christos Exp $"); | 40 | __RCSID("$NetBSD: msdos.c,v 1.3 2013/01/23 21:42:22 christos Exp $"); | |
41 | #endif /* !__lint */ | 41 | #endif /* !__lint */ | |
42 | 42 | |||
43 | #include <sys/param.h> | 43 | #include <sys/param.h> | |
44 | 44 | |||
45 | #if !HAVE_NBTOOL_CONFIG_H | 45 | #if !HAVE_NBTOOL_CONFIG_H | |
46 | #include <sys/mount.h> | 46 | #include <sys/mount.h> | |
47 | #endif | 47 | #endif | |
48 | 48 | |||
49 | #include <assert.h> | 49 | #include <assert.h> | |
50 | #include <errno.h> | 50 | #include <errno.h> | |
51 | #include <fcntl.h> | 51 | #include <fcntl.h> | |
52 | #include <stdarg.h> | 52 | #include <stdarg.h> | |
53 | #include <stdio.h> | 53 | #include <stdio.h> | |
@@ -91,35 +91,51 @@ msdos_parse_opts(const char *option, fsi | @@ -91,35 +91,51 @@ msdos_parse_opts(const char *option, fsi | |||
91 | (sizeof(_type) == 2 ? OPT_INT16 : \ | 91 | (sizeof(_type) == 2 ? OPT_INT16 : \ | |
92 | (sizeof(_type) == 4 ? OPT_INT32 : OPT_INT64)))), \ | 92 | (sizeof(_type) == 4 ? OPT_INT32 : OPT_INT64)))), \ | |
93 | .value = &msdos_opt->_name, \ | 93 | .value = &msdos_opt->_name, \ | |
94 | .minimum = _min, \ | 94 | .minimum = _min, \ | |
95 | .maximum = sizeof(_type) == 1 ? 0xff : \ | 95 | .maximum = sizeof(_type) == 1 ? 0xff : \ | |
96 | (sizeof(_type) == 2 ? 0xffff : \ | 96 | (sizeof(_type) == 2 ? 0xffff : \ | |
97 | (sizeof(_type) == 4 ? 0xffffffff : 0xffffffffffffffffLL)), \ | 97 | (sizeof(_type) == 4 ? 0xffffffff : 0xffffffffffffffffLL)), \ | |
98 | .desc = _desc, \ | 98 | .desc = _desc, \ | |
99 | }, | 99 | }, | |
100 | ALLOPTS | 100 | ALLOPTS | |
101 | #undef AOPT | 101 | #undef AOPT | |
102 | { .name = NULL } | 102 | { .name = NULL } | |
103 | }; | 103 | }; | |
104 | int i, rv; | |||
104 | 105 | |||
105 | assert(option != NULL); | 106 | assert(option != NULL); | |
106 | assert(fsopts != NULL); | 107 | assert(fsopts != NULL); | |
107 | assert(msdos_opt != NULL); | 108 | assert(msdos_opt != NULL); | |
108 | 109 | |||
109 | if (debug & DEBUG_FS_PARSE_OPTS) | 110 | if (debug & DEBUG_FS_PARSE_OPTS) | |
110 | printf("msdos_parse_opts: got `%s'\n", option); | 111 | printf("msdos_parse_opts: got `%s'\n", option); | |
111 | 112 | |||
112 | return set_option(msdos_options, option); | 113 | rv = set_option(msdos_options, option); | |
114 | if (rv == 0) | |||
115 | return rv; | |||
116 | ||||
117 | for (i = 0; msdos_options[i].name != NULL && (1 << i) != rv; i++) | |||
118 | break; | |||
119 | if (msdos_options[i].name == NULL) | |||
120 | abort(); | |||
121 | ||||
122 | if (strcmp(msdos_options[i].name, "volume_id") == 0) | |||
123 | msdos_opt->volume_id_set = 1; | |||
124 | else if (strcmp(msdos_options[i].name, "media_descriptor") == 0) | |||
125 | msdos_opt->media_descriptor_set = 1; | |||
126 | else if (strcmp(msdos_options[i].name, "hidden_sectors") == 0) | |||
127 | msdos_opt->hidden_sectors_set = 1; | |||
128 | return rv; | |||
113 | } | 129 | } | |
114 | 130 | |||
115 | 131 | |||
116 | void | 132 | void | |
117 | msdos_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts) | 133 | msdos_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts) | |
118 | { | 134 | { | |
119 | #ifdef notyet | 135 | #ifdef notyet | |
120 | struct fs *superblock; | 136 | struct fs *superblock; | |
121 | struct timeval start; | 137 | struct timeval start; | |
122 | 138 | |||
123 | assert(image != NULL); | 139 | assert(image != NULL); | |
124 | assert(dir != NULL); | 140 | assert(dir != NULL); | |
125 | assert(root != NULL); | 141 | assert(root != NULL); |