Module Name: src
Committed By: martin
Date: Wed Jan 22 06:11:28 UTC 2020
Modified Files:
src/sys/lib/libsa: dosfs.c
Log Message:
To support big partitions we need to make sure all byte offsets are calculated
in 64 bit arithmetic. Pointed out by Rob Newberry.
Unfortunately this causes a code size increase breaking some boot blocks,
so conditionalize it and use 32 bit arithmetic if SA_DOSFS_NO_BIG_PART_SUPPORT
is defined.
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/lib/libsa/dosfs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/lib/libsa/dosfs.c
diff -u src/sys/lib/libsa/dosfs.c:1.22 src/sys/lib/libsa/dosfs.c:1.23
--- src/sys/lib/libsa/dosfs.c:1.22 Sun Mar 31 20:08:45 2019
+++ src/sys/lib/libsa/dosfs.c Wed Jan 22 06:11:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: dosfs.c,v 1.22 2019/03/31 20:08:45 christos Exp $ */
+/* $NetBSD: dosfs.c,v 1.23 2020/01/22 06:11:28 martin Exp $ */
/*
* Copyright (c) 1996, 1998 Robert Nordier
@@ -108,12 +108,18 @@ static const struct direntry dot[2] = {
{0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}}
};
+#ifdef SA_DOSFS_NO_BIG_PART_SUPPORT
+#define BYTE_OFF_T u_int
+#else
+#define BYTE_OFF_T uint64_t
+#endif
+
/* The usual conversion macros to avoid multiplication and division */
#define bytsec(n) ((n) >> SSHIFT)
-#define secbyt(s) ((s) << SSHIFT)
+#define secbyt(s) ((BYTE_OFF_T)(s) << SSHIFT)
#define entsec(e) ((e) >> DSHIFT)
#define bytblk(fs, n) ((n) >> (fs)->bshift)
-#define blkbyt(fs, b) ((b) << (fs)->bshift)
+#define blkbyt(fs, b) ((BYTE_OFF_T)(b) << (fs)->bshift)
#define secblk(fs, s) ((s) >> ((fs)->bshift - SSHIFT))
#define blksec(fs, b) ((b) << ((fs)->bshift - SSHIFT))
@@ -146,7 +152,7 @@ static off_t fsize(DOS_FS *, struct dire
static int fatcnt(DOS_FS *, u_int);
static int fatget(DOS_FS *, u_int *);
static int fatend(u_int, u_int);
-static int ioread(DOS_FS *, u_int, void *, u_int);
+static int ioread(DOS_FS *, BYTE_OFF_T, void *, u_int);
static int iobuf(DOS_FS *, u_int);
static int ioget(struct open_file *, u_int, void *, u_int);
@@ -733,7 +739,7 @@ fatend(u_int sz, u_int c)
* Offset-based I/O primitive
*/
static int
-ioread(DOS_FS *fs, u_int offset, void *buf, u_int nbyte)
+ioread(DOS_FS *fs, BYTE_OFF_T offset, void *buf, u_int nbyte)
{
char *s;
u_int off, n;