Sat Dec 30 19:17:07 2023 UTC (155d)
Pull up following revision(s) (requested by tsutsui in ticket #1783):

	usr.sbin/makefs/msdos.c: revision 1.22

Return a proper exit status on failure on creating msdosfs.

No particular comment in PR bin/57752.


(martin)
diff -r1.20 -r1.20.14.1 src/usr.sbin/makefs/msdos.c

cvs diff -r1.20 -r1.20.14.1 src/usr.sbin/makefs/msdos.c (expand / switch to unified diff)

--- src/usr.sbin/makefs/msdos.c 2017/04/14 15:40:35 1.20
+++ src/usr.sbin/makefs/msdos.c 2023/12/30 19:17:06 1.20.14.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: msdos.c,v 1.20 2017/04/14 15:40:35 christos Exp $ */ 1/* $NetBSD: msdos.c,v 1.20.14.1 2023/12/30 19:17:06 martin 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.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31#if HAVE_NBTOOL_CONFIG_H 31#if HAVE_NBTOOL_CONFIG_H
32#include "nbtool_config.h" 32#include "nbtool_config.h"
33#endif 33#endif
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36#if defined(__RCSID) && !defined(__lint) 36#if defined(__RCSID) && !defined(__lint)
37__RCSID("$NetBSD: msdos.c,v 1.20 2017/04/14 15:40:35 christos Exp $"); 37__RCSID("$NetBSD: msdos.c,v 1.20.14.1 2023/12/30 19:17:06 martin Exp $");
38#endif /* !__lint */ 38#endif /* !__lint */
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41 41
42#if !HAVE_NBTOOL_CONFIG_H 42#if !HAVE_NBTOOL_CONFIG_H
43#include <sys/mount.h> 43#include <sys/mount.h>
44#endif 44#endif
45 45
46#include <assert.h> 46#include <assert.h>
47#include <errno.h> 47#include <errno.h>
48#include <fcntl.h> 48#include <fcntl.h>
49#include <stdarg.h> 49#include <stdarg.h>
50#include <stdio.h> 50#include <stdio.h>
@@ -167,51 +167,51 @@ msdos_makefs(const char *image, const ch @@ -167,51 +167,51 @@ msdos_makefs(const char *image, const ch
167 msdos_opt->options.bytes_per_sector = fsopts->sectorsize; 167 msdos_opt->options.bytes_per_sector = fsopts->sectorsize;
168 } else if (fsopts->sectorsize == -1) { 168 } else if (fsopts->sectorsize == -1) {
169 fsopts->sectorsize = msdos_opt->options.bytes_per_sector; 169 fsopts->sectorsize = msdos_opt->options.bytes_per_sector;
170 } else if (fsopts->sectorsize != msdos_opt->options.bytes_per_sector) { 170 } else if (fsopts->sectorsize != msdos_opt->options.bytes_per_sector) {
171 err(1, "inconsistent sectorsize -S %u" 171 err(1, "inconsistent sectorsize -S %u"
172 "!= -o bytes_per_sector %u",  172 "!= -o bytes_per_sector %u",
173 fsopts->sectorsize, msdos_opt->options.bytes_per_sector); 173 fsopts->sectorsize, msdos_opt->options.bytes_per_sector);
174 } 174 }
175 175
176 /* create image */ 176 /* create image */
177 printf("Creating `%s'\n", image); 177 printf("Creating `%s'\n", image);
178 TIMER_START(start); 178 TIMER_START(start);
179 if (mkfs_msdos(image, NULL, &msdos_opt->options) == -1) 179 if (mkfs_msdos(image, NULL, &msdos_opt->options) == -1)
180 return; 180 errx(1, "Image file `%s' not created.", image);
181 TIMER_RESULTS(start, "mkfs_msdos"); 181 TIMER_RESULTS(start, "mkfs_msdos");
182 182
183 fsopts->fd = open(image, O_RDWR); 183 fsopts->fd = open(image, O_RDWR);
184 vp.fs = fsopts; 184 vp.fs = fsopts;
185 185
186 flags = 0; 186 flags = 0;
187 if (msdos_opt->utf8) 187 if (msdos_opt->utf8)
188 flags |= MSDOSFSMNT_UTF8; 188 flags |= MSDOSFSMNT_UTF8;
189 189
190 if ((pmp = msdosfs_mount(&vp, flags)) == NULL) 190 if ((pmp = msdosfs_mount(&vp, flags)) == NULL)
191 err(1, "msdosfs_mount"); 191 err(1, "msdosfs_mount");
192 192
193 if (msdosfs_root(pmp, &rootvp) != 0) 193 if (msdosfs_root(pmp, &rootvp) != 0)
194 err(1, "msdosfs_root"); 194 err(1, "msdosfs_root");
195 195
196 if (debug & DEBUG_FS_MAKEFS) 196 if (debug & DEBUG_FS_MAKEFS)
197 printf("msdos_makefs: image %s directory %s root %p\n", 197 printf("msdos_makefs: image %s directory %s root %p\n",
198 image, dir, root); 198 image, dir, root);
199 199
200 /* populate image */ 200 /* populate image */
201 printf("Populating `%s'\n", image); 201 printf("Populating `%s'\n", image);
202 TIMER_START(start); 202 TIMER_START(start);
203 if (msdos_populate_dir(dir, VTODE(&rootvp), root, root, fsopts) == -1) 203 if (msdos_populate_dir(dir, VTODE(&rootvp), root, root, fsopts) == -1)
204 errx(1, "Image file `%s' not created.", image); 204 errx(1, "Image file `%s' not populated.", image);
205 TIMER_RESULTS(start, "msdos_populate_dir"); 205 TIMER_RESULTS(start, "msdos_populate_dir");
206 206
207 if (debug & DEBUG_FS_MAKEFS) 207 if (debug & DEBUG_FS_MAKEFS)
208 putchar('\n'); 208 putchar('\n');
209 209
210 /* ensure no outstanding buffers remain */ 210 /* ensure no outstanding buffers remain */
211 if (debug & DEBUG_FS_MAKEFS) 211 if (debug & DEBUG_FS_MAKEFS)
212 bcleanup(); 212 bcleanup();
213 213
214 printf("Image `%s' complete\n", image); 214 printf("Image `%s' complete\n", image);
215} 215}
216 216
217static int 217static int