Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lib/libsa To support big partitions we need to make sure...



details:   https://anonhg.NetBSD.org/src/rev/1c665cb046b6
branches:  trunk
changeset: 1006643:1c665cb046b6
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Jan 22 06:11:28 2020 +0000

description:
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.

diffstat:

 sys/lib/libsa/dosfs.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (48 lines):

diff -r 4273ad586574 -r 1c665cb046b6 sys/lib/libsa/dosfs.c
--- a/sys/lib/libsa/dosfs.c     Wed Jan 22 03:48:10 2020 +0000
+++ b/sys/lib/libsa/dosfs.c     Wed Jan 22 06:11:28 2020 +0000
@@ -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 @@
                {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 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 @@
  * 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;



Home | Main Index | Thread Index | Old Index