Sat May 7 08:54:02 2022 UTC ()
When creating disc images, keep the proposed size a multiple of the blockingnr
for good measure; this prevents possible burning/copying issues on packet
media.


(reinoud)
diff -r1.38 -r1.39 src/usr.sbin/makefs/makefs.h
diff -r1.29 -r1.30 src/usr.sbin/makefs/udf.c

cvs diff -r1.38 -r1.39 src/usr.sbin/makefs/makefs.h (expand / switch to unified diff)

--- src/usr.sbin/makefs/makefs.h 2022/04/09 10:05:35 1.38
+++ src/usr.sbin/makefs/makefs.h 2022/05/07 08:54:02 1.39
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: makefs.h,v 1.38 2022/04/09 10:05:35 riastradh Exp $ */ 1/* $nEtBSD: makefs.h,v 1.38 2022/04/09 10:05:35 riastradh 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
@@ -34,27 +34,27 @@ @@ -34,27 +34,27 @@
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#ifndef _MAKEFS_H 38#ifndef _MAKEFS_H
39#define _MAKEFS_H 39#define _MAKEFS_H
40 40
41#if HAVE_NBTOOL_CONFIG_H 41#if HAVE_NBTOOL_CONFIG_H
42#include "nbtool_config.h" 42#include "nbtool_config.h"
43#else 43#else
44#define HAVE_STRUCT_STAT_ST_FLAGS 1 44#define HAVE_STRUCT_STAT_ST_FLAGS 1
45#define HAVE_STRUCT_STAT_ST_GEN 1 45#define HAVE_STRUCT_STAT_ST_GEN 1
46#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1 46#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
47#define HAVE_STRUCT_STATVFS_F_IOSIZE 1 47//#define HAVE_STRUCT_STATVFS_F_IOSIZE 1
48#define HAVE_STRUCT_STAT_BIRTHTIME 1 48#define HAVE_STRUCT_STAT_BIRTHTIME 1
49#define HAVE_FSTATVFS 1 49#define HAVE_FSTATVFS 1
50#endif 50#endif
51 51
52#include <sys/stat.h> 52#include <sys/stat.h>
53#include <err.h> 53#include <err.h>
54 54
55/* 55/*
56 * fsnode - 56 * fsnode -
57 * a component of the tree; contains a filename, a pointer to 57 * a component of the tree; contains a filename, a pointer to
58 * fsinode, optional symlink name, and tree pointers 58 * fsinode, optional symlink name, and tree pointers
59 * 59 *
60 * fsinode - 60 * fsinode -

cvs diff -r1.29 -r1.30 src/usr.sbin/makefs/udf.c (expand / switch to unified diff)

--- src/usr.sbin/makefs/udf.c 2022/04/26 15:18:08 1.29
+++ src/usr.sbin/makefs/udf.c 2022/05/07 08:54:02 1.30
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: udf.c,v 1.29 2022/04/26 15:18:08 reinoud Exp $ */ 1/* $NetBSD: udf.c,v 1.30 2022/05/07 08:54:02 reinoud Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006, 2008, 2013, 2021, 2022 Reinoud Zandijk 4 * Copyright (c) 2006, 2008, 2013, 2021, 2022 Reinoud Zandijk
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * 26 *
27 */ 27 */
28#if HAVE_NBTOOL_CONFIG_H 28#if HAVE_NBTOOL_CONFIG_H
29#include "nbtool_config.h" 29#include "nbtool_config.h"
30#endif 30#endif
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__RCSID("$NetBSD: udf.c,v 1.29 2022/04/26 15:18:08 reinoud Exp $"); 33__RCSID("$NetBSD: udf.c,v 1.30 2022/05/07 08:54:02 reinoud Exp $");
34 34
35#include <stdio.h> 35#include <stdio.h>
36#include <stdlib.h> 36#include <stdlib.h>
37#include <string.h> 37#include <string.h>
38#include <errno.h> 38#include <errno.h>
39#include <time.h> 39#include <time.h>
40#include <assert.h> 40#include <assert.h>
41#include <err.h> 41#include <err.h>
42#include <unistd.h> 42#include <unistd.h>
43#include <fcntl.h> 43#include <fcntl.h>
44#include <math.h> 44#include <math.h>
45#include <sys/types.h> 45#include <sys/types.h>
46#include <sys/param.h> 46#include <sys/param.h>
@@ -1120,27 +1120,44 @@ udf_enumerate_and_estimate(const char *d @@ -1120,27 +1120,44 @@ udf_enumerate_and_estimate(const char *d
1120 nblk += spareable_blockingnr; /* slack */ 1120 nblk += spareable_blockingnr; /* slack */
1121 } 1121 }
1122 1122
1123 nblk += 256; /* pre-volume space */ 1123 nblk += 256; /* pre-volume space */
1124 nblk += 256; /* post-volume space */ 1124 nblk += 256; /* post-volume space */
1125 nblk += 1024; /* safeguard */ 1125 nblk += 1024; /* safeguard */
1126 1126
1127 /* try to honour minimum size */ 1127 /* try to honour minimum size */
1128 n = fsopts->minsize / fsopts->sectorsize; 1128 n = fsopts->minsize / fsopts->sectorsize;
1129 if (nblk < n) { 1129 if (nblk < n) {
1130 stats->ndatablocks += (n - nblk); 1130 stats->ndatablocks += (n - nblk);
1131 nblk += n - nblk; 1131 nblk += n - nblk;
1132 } 1132 }
 1133
 1134 /* keep proposed size a multiple of blockingnr for image creation */
 1135 if (S_ISREG(dev_fd_stat.st_mode)) {
 1136 struct mmc_trackinfo ti;
 1137 int blockingnr;
 1138 int error;
 1139
 1140 /* adjust proposed size to be a multiple of the blockingnr */
 1141 udf_update_discinfo();
 1142 ti.tracknr = mmc_discinfo.first_track_last_session;
 1143 error = udf_update_trackinfo(&ti);
 1144 assert(!error);
 1145 blockingnr = udf_get_blockingnr(&ti);
 1146 nblk = UDF_ROUNDUP(nblk, blockingnr);
 1147 }
 1148
1133 proposed_size = (off_t) nblk * fsopts->sectorsize; 1149 proposed_size = (off_t) nblk * fsopts->sectorsize;
 1150
1134 /* sanity size */ 1151 /* sanity size */
1135 if (proposed_size < 512*1024) 1152 if (proposed_size < 512*1024)
1136 proposed_size = 512*1024; 1153 proposed_size = 512*1024;
1137 1154
1138 if (fsopts->size) { 1155 if (fsopts->size) {
1139 if (fsopts->size < proposed_size) 1156 if (fsopts->size < proposed_size)
1140 errx(1, "makefs_udf: won't fit on disc!"); 1157 errx(1, "makefs_udf: won't fit on disc!");
1141 } else { 1158 } else {
1142 fsopts->size = proposed_size; 1159 fsopts->size = proposed_size;
1143 } 1160 }
1144 1161
1145 fsopts->inodes = stats->nfiles + stats->ndirs; 1162 fsopts->inodes = stats->nfiles + stats->ndirs;
1146} 1163}