Module Name:    src
Committed By:   perseant
Date:           Mon Jul  1 22:15:22 UTC 2024

Modified Files:
        src/sys/fs/exfatfs [perseant-exfatfs]: exfatfs.h exfatfs_cksum.c
            exfatfs_cksum.h exfatfs_conv.c exfatfs_conv.h exfatfs_dirent.h
            exfatfs_extern.c exfatfs_extern.h exfatfs_inode.h exfatfs_mount.h
            exfatfs_rename.c exfatfs_rename.h exfatfs_tables.c exfatfs_tables.h
            exfatfs_trie.c exfatfs_trie.h exfatfs_trie_basic.c
            exfatfs_trie_basic.h exfatfs_vfsops.c exfatfs_vfsops.h
            exfatfs_vnops.c exfatfs_vnops.h

Log Message:
Update to match the NetBSD style guide.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/fs/exfatfs/exfatfs.h \
    src/sys/fs/exfatfs/exfatfs_cksum.c src/sys/fs/exfatfs/exfatfs_cksum.h \
    src/sys/fs/exfatfs/exfatfs_conv.c src/sys/fs/exfatfs/exfatfs_conv.h \
    src/sys/fs/exfatfs/exfatfs_dirent.h src/sys/fs/exfatfs/exfatfs_extern.c \
    src/sys/fs/exfatfs/exfatfs_extern.h src/sys/fs/exfatfs/exfatfs_inode.h \
    src/sys/fs/exfatfs/exfatfs_mount.h src/sys/fs/exfatfs/exfatfs_rename.c \
    src/sys/fs/exfatfs/exfatfs_rename.h src/sys/fs/exfatfs/exfatfs_tables.c \
    src/sys/fs/exfatfs/exfatfs_tables.h src/sys/fs/exfatfs/exfatfs_trie.c \
    src/sys/fs/exfatfs/exfatfs_trie.h src/sys/fs/exfatfs/exfatfs_trie_basic.c \
    src/sys/fs/exfatfs/exfatfs_trie_basic.h \
    src/sys/fs/exfatfs/exfatfs_vfsops.c src/sys/fs/exfatfs/exfatfs_vfsops.h \
    src/sys/fs/exfatfs/exfatfs_vnops.c src/sys/fs/exfatfs/exfatfs_vnops.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/exfatfs/exfatfs.h
diff -u src/sys/fs/exfatfs/exfatfs.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs.h	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,31 @@
-/* $NetBSD: exfatfs.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $ */
+/* $NetBSD: exfatfs.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $ */
+
+/*-
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef FS_EXFATFS_EXFATFS_H_
 #define FS_EXFATFS_EXFATFS_H_
 
@@ -63,7 +90,8 @@ struct exfatfs {
 #define xf_FatLength xf_exfatdfs.xdf_FatLength
 #define xf_ClusterHeapOffset xf_exfatdfs.xdf_ClusterHeapOffset
 #define xf_ClusterCount xf_exfatdfs.xdf_ClusterCount
-#define xf_FirstClusterOfRootDirectory xf_exfatdfs.xdf_FirstClusterOfRootDirectory
+#define xf_FirstClusterOfRootDirectory \
+		xf_exfatdfs.xdf_FirstClusterOfRootDirectory
 #define xf_VolumeSerialNumber xf_exfatdfs.xdf_VolumeSerialNumber
 #define xf_FileSystemRevision xf_exfatdfs.xdf_FileSystemRevision
 #define EXFATFS_MAJOR(fs) (((fs)->xf_FileSystemRevision & 0xFF00) >> 8)
@@ -108,7 +136,8 @@ struct exfatfs {
  * DEV_BSIZE is 512 bytes and cluster numbers are 4 bytes,
  * so there are 128 = 2**7 entries per DEV_BSIZE.
  */
-#define EXFATFS_FATBLK(fs, clust) (((fs)->xf_FatOffset >> ((fs)->xf_BytesPerSectorShift - DEV_BSHIFT)) + ((clust) >> 7))
+#define EXFATFS_FATBLK(fs, clust) (((fs)->xf_FatOffset >> 		\
+	((fs)->xf_BytesPerSectorShift - DEV_BSHIFT)) + ((clust) >> 7))
 #define EXFATFS_FATOFF(clust) ((clust) & 0x7F)
 
 #if 0
@@ -144,18 +173,26 @@ struct exfatfs_args {
 #define EXFATFS_DIRENT2BYTES(fs, e) ((e) << EXFATFS_DIRENT_BASESHIFT)
 
 /* Convert from sizeof(dirent) to cluster */
-#define EXFATFS_DIRENT_SHIFT(fs) ((fs)->xf_BytesPerSectorShift + (fs)->xf_SectorsPerClusterShift - EXFATFS_DIRENT_BASESHIFT)
+#define EXFATFS_DIRENT_SHIFT(fs) ((fs)->xf_BytesPerSectorShift + \
+	(fs)->xf_SectorsPerClusterShift - EXFATFS_DIRENT_BASESHIFT)
 
-#define EXFATFS_DIRENT2DEVBSIZE(fs, e) ((e) >> (DEV_BSHIFT - EXFATFS_DIRENT_BASESHIFT))
-#define EXFATFS_DEVBSIZE2DIRENT(fs, e) ((e) << (DEV_BSHIFT - EXFATFS_DIRENT_BASESHIFT))
-#define EXFATFS_DIRENT2FSSEC(fs, e) ((e) >> (fs->xf_BytesPerSectorShift - EXFATFS_DIRENT_BASESHIFT))
-#define EXFATFS_FSSEC2DIRENT(fs, sec) ((sec) << (fs->xf_BytesPerSectorShift - EXFATFS_DIRENT_BASESHIFT))
+#define EXFATFS_DIRENT2DEVBSIZE(fs, e) ((e) >> (DEV_BSHIFT - \
+					EXFATFS_DIRENT_BASESHIFT))
+#define EXFATFS_DEVBSIZE2DIRENT(fs, e) ((e) << (DEV_BSHIFT \
+						- EXFATFS_DIRENT_BASESHIFT))
+#define EXFATFS_DIRENT2FSSEC(fs, e) ((e) >> (fs->xf_BytesPerSectorShift \
+						- EXFATFS_DIRENT_BASESHIFT))
+#define EXFATFS_FSSEC2DIRENT(fs, sec) ((sec) << (fs->xf_BytesPerSectorShift \
+						- EXFATFS_DIRENT_BASESHIFT))
 
 /* If we have an entry number we may need to convert it to lbn and offset */
-#define EXFATFS_DIRENT2ENTRY(fs, e) EXFATFS_BYTES2DIRENT((fs), (EXFATFS_DIRENT2BYTES((fs), (e)) & SECMASK(fs)))
+#define EXFATFS_DIRENT2ENTRY(fs, e) EXFATFS_BYTES2DIRENT((fs), \
+			(EXFATFS_DIRENT2BYTES((fs), (e)) & SECMASK(fs)))
 
-#define EXFATFS_CLUST_ENTRY2INO(fs, clust, entry) ((((uint64_t)clust) << EXFATFS_DIRENT_SHIFT(fs)) | (entry))
-#define EXFATFS_HWADDR_ENTRY2INO(fs, bn, entry) ((EXFATFS_HWADDR2CLUSTER((fs), (bn)) << EXFATFS_DIRENT_SHIFT(fs)) | (entry))
+#define EXFATFS_CLUST_ENTRY2INO(fs, clust, entry) ((((uint64_t)clust) \
+				<< EXFATFS_DIRENT_SHIFT(fs)) | (entry))
+#define EXFATFS_HWADDR_ENTRY2INO(fs, bn, entry) ((EXFATFS_HWADDR2CLUSTER((fs),\
+			 (bn)) << EXFATFS_DIRENT_SHIFT(fs)) | (entry))
 #define INO2CLUST(ino) ((ino) >> EXFATFS_DIRENT_SHIFT(fs))
 #define INO2ENTRY(ino) ((ino) & ((1 << EXFATFS_DIRENT_SHIFT(fs)) - 1))
 #define ROOTDIRCLUST 1
@@ -165,24 +202,40 @@ struct exfatfs_args {
 /*
  * Units conversions between clusters, filesystem sectors and DEV_BSIZE.
  */
-#define EXFATFS_FSSEC2DEVBSIZE(fs, bn) ((bn) << ((fs)->xf_BytesPerSectorShift - DEV_BSHIFT))
-#define EXFATFS_DEVBSIZE2FSSEC(fs, bn) ((bn) >> ((fs)->xf_BytesPerSectorShift - DEV_BSHIFT))
-#define EXFATFS_BYTES2CLUSTER(fs, n) ((n) >> ((fs)->xf_BytesPerSectorShift + (fs)->xf_SectorsPerClusterShift))
+#define EXFATFS_FSSEC2DEVBSIZE(fs, bn) ((bn) << ((fs)->xf_BytesPerSectorShift \
+							- DEV_BSHIFT))
+#define EXFATFS_DEVBSIZE2FSSEC(fs, bn) ((bn) >> ((fs)->xf_BytesPerSectorShift \
+							- DEV_BSHIFT))
+#define EXFATFS_BYTES2CLUSTER(fs, n) ((n) >> ((fs)->xf_BytesPerSectorShift \
+					+ (fs)->xf_SectorsPerClusterShift))
 #define EXFATFS_BYTES2FSSEC(fs, n) ((n) >> ((fs)->xf_BytesPerSectorShift))
 #define EXFATFS_FSSEC2BYTES(fs, n) ((n) << ((fs)->xf_BytesPerSectorShift))
-#define EXFATFS_CLUSTER2BYTES(fs, cn) ((cn) << ((fs)->xf_BytesPerSectorShift + (fs)->xf_SectorsPerClusterShift))
-#define EXFATFS_CLUSTER2DEVBSIZE(fs, cn) ((cn) << ((fs)->xf_BytesPerSectorShift + (fs)->xf_SectorsPerClusterShift - DEV_BSHIFT))
-#define EXFATFS_DEVBSIZE2CLUSTER(fs, bn) ((bn) >> ((fs)->xf_BytesPerSectorShift + (fs)->xf_SectorsPerClusterShift - DEV_BSHIFT))
-#define EXFATFS_CLUSTER2FSSEC(fs, clust) ((clust) << (fs)->xf_SectorsPerClusterShift)
-#define EXFATFS_FSSEC2CLUSTER(fs, lbn)   ((lbn) >> (fs)->xf_SectorsPerClusterShift)
+#define EXFATFS_CLUSTER2BYTES(fs, cn) ((cn) << ((fs)->xf_BytesPerSectorShift \
+					+ (fs)->xf_SectorsPerClusterShift))
+#define EXFATFS_CLUSTER2DEVBSIZE(fs, cn) ((cn) << ((fs)->xf_BytesPerSectorShift\
+			 + (fs)->xf_SectorsPerClusterShift - DEV_BSHIFT))
+#define EXFATFS_DEVBSIZE2CLUSTER(fs, bn) ((bn) >> ((fs)->xf_BytesPerSectorShift\
+			 + (fs)->xf_SectorsPerClusterShift - DEV_BSHIFT))
+#define EXFATFS_CLUSTER2FSSEC(fs, clust) ((clust) << 			\
+			(fs)->xf_SectorsPerClusterShift)
+#define EXFATFS_FSSEC2CLUSTER(fs, lbn)   ((lbn) >> 			\
+			(fs)->xf_SectorsPerClusterShift)
 #define SECSIZE(fs) (1 << (fs)->xf_BytesPerSectorShift)
 #define SECMASK(fs) (SECSIZE(fs) - 1)
-#define CLUSTERSIZE(fs) (1 << ((fs)->xf_BytesPerSectorShift + (fs)->xf_SectorsPerClusterShift))
+#define CLUSTERSIZE(fs) (1 << ((fs)->xf_BytesPerSectorShift + 		\
+				(fs)->xf_SectorsPerClusterShift))
 #define CLUSTERMASK(fs) (CLUSTERSIZE(fs) - 1)
-
-#define EXFATFS_CLUSTER2HWADDR(fs, clust) (EXFATFS_CLUSTER2FSSEC((fs), (clust) - 2) + (fs)->xf_ClusterHeapOffset)
-#define EXFATFS_HWADDR2CLUSTER(fs, bn) (EXFATFS_FSSEC2CLUSTER((fs), (bn) - (fs)->xf_ClusterHeapOffset) + 2)
+/* The unit in which I/O is performed */
+#define IOSIZE(fs) MIN(CLUSTERSIZE(fs), MAXPHYS)
+#define IOMASK(fs) (IOSIZE(fs) - 1)
+
+#define EXFATFS_CLUSTER2HWADDR(fs, clust) (EXFATFS_CLUSTER2FSSEC((fs),	\
+				(clust) - 2) + (fs)->xf_ClusterHeapOffset)
+#define EXFATFS_HWADDR2CLUSTER(fs, bn) (EXFATFS_FSSEC2CLUSTER((fs), (bn) \
+				- (fs)->xf_ClusterHeapOffset) + 2)
 /* The offset of this block relative to start of cluster, in dirent units */
-#define EXFATFS_HWADDR2DIRENT(fs, bn) EXFATFS_DEVBSIZE2DIRENT((fs), ((bn) - EXFATFS_CLUSTER2HWADDR((fs), EXFATFS_HWADDR2CLUSTER((fs), (bn)))))
+#define EXFATFS_HWADDR2DIRENT(fs, bn) EXFATFS_DEVBSIZE2DIRENT((fs),	\
+	((bn) - EXFATFS_CLUSTER2HWADDR((fs), 				\
+		EXFATFS_HWADDR2CLUSTER((fs), (bn)))))
 
 #endif /* FS_EXFATFS_EXFATFS_H_ */
Index: src/sys/fs/exfatfs/exfatfs_cksum.c
diff -u src/sys/fs/exfatfs/exfatfs_cksum.c:1.1.2.1 src/sys/fs/exfatfs/exfatfs_cksum.c:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_cksum.c:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_cksum.c	Mon Jul  1 22:15:21 2024
@@ -1,7 +1,7 @@
-/*	$NetBSD: exfatfs_cksum.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $	*/
+/*	$NetBSD: exfatfs_cksum.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $	*/
 
 /*-
- * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exfatfs_cksum.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exfatfs_cksum.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $");
 
 #include <sys/types.h>
 #ifdef _KERNEL
@@ -48,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: exfatfs_cksu
 #ifdef EXFATFS_CKSUM_DEBUG
 # define DPRINTF(x) printf x
 #else
-# define DPRINTF(x)
+# define DPRINTF(x) __nothing
 #endif
 
 /*
@@ -135,78 +135,6 @@ uint16_t exfatfs_cksum16(uint16_t seed, 
 	return cksum;
 }
 
-/*
-uint32_t BootChecksum(uint8_t *sectors, uint16_t BytesPerSector)
-{
-    uint32_t NumberOfBytes = (uint32_t)BytesPerSector * 11;
-    uint32_t Checksum = 0;
-    uint32_t Index;
-
-    for (Index = 0; Index < NumberOfBytes; Index++)
-    {
-        if ((Index == 106) || (Index == 107) || (Index == 112))
-        {
-            continue;
-        }
-        Checksum = ((Checksum&1) ? 0x80000000 : 0) + (Checksum>>1) + (uint32_t)Sectors[Index];
-    }
-
-    return Checksum;
-}
-*/
-
-/*
-uint16_t EntrySetChecksum(uint8_t * Entries, uint8_t SecondaryCount)
-{
-    uint16_t NumberOfBytes = ((uint16_t)SecondaryCount + 1) * 32;
-    uint16_t Checksum = 0;
-    uint16_t Index;
-
-    for (Index = 0; Index < NumberOfBytes; Index++)
-    {
-        if ((Index == 2) || (Index == 3))
-        {
-            continue;
-        }
-        Checksum = ((Checksum&1) ? 0x8000 : 0) + (Checksum>>1) +  (uint16_t)Entries[Index];
-    }
-    return Checksum;
-}
-
-uint32_t TableChecksum
-(
-    uint8_t  * Table,    // points to an in-memory copy of the up-case table
-    uint64_t   DataLength
-)
-{
-    uint32_t Checksum = 0;
-    uint64_t Index;
-
-    for (Index = 0; Index < DataLength; Index++)
-    {
-        Checksum = ((Checksum&1) ? 0x80000000 : 0) + (Checksum>>1) + (uint32_t)Table[Index];
-    }
-
-    return Checksum;
-}
-*/
-
-/*
-uint16_t NameHash (uint16_t *FileName, uint8_t NameLength)
-{
-    uint8_t  * Buffer = (uint8_t *)FileName;
-    uint16_t   NumberOfBytes = (uint16_t)NameLength * 2;
-    uint16_t   Hash = 0;
-    uint16_t   Index;
-
-    for (Index = 0; Index < NumberOfBytes; Index++)
-    {
-        Hash = ((Hash&1) ? 0x8000 : 0) + (Hash>>1) + (uint16_t)Buffer[Index];
-    }
-    return Hash;
-}
-*/
-
 void htole_bootblock(struct exfatfs *out, struct exfatfs *in)
 {
 	memcpy(out, in, sizeof(in->xf_JumpBoot)
Index: src/sys/fs/exfatfs/exfatfs_cksum.h
diff -u src/sys/fs/exfatfs/exfatfs_cksum.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_cksum.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_cksum.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_cksum.h	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,31 @@
-/* $NetBSD: exfatfs_cksum.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $ */
+/* $NetBSD: exfatfs_cksum.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $ */
+
+/*-
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef EXFATFS_CKSUM_H_
 #define EXFATFS_CKSUM_H_
 
@@ -8,17 +35,12 @@
 #include <fs/exfatfs/exfatfs.h>
 #include <fs/exfatfs/exfatfs_dirent.h>
 
-uint32_t exfatfs_cksum32(uint32_t seed, uint8_t *data, uint64_t datalen,
-			uint8_t *ignore, uint8_t ignorelen);
-uint16_t exfatfs_namehash(struct exfatfs *fs,
-			   uint16_t seed, uint16_t *name, int namelen);
-uint16_t exfatfs_cksum16(uint16_t seed, uint8_t *data, uint64_t datalen,
-			uint8_t *ignore, uint8_t ignorelen);
-void htole_bootblock(struct exfatfs *out, struct exfatfs *in);
-void letoh_bootblock(struct exfatfs *out, struct exfatfs *in);
-void htole_dfe(struct exfatfs_dfe *out,
-		       struct exfatfs_dfe *in);
-void letoh_dfe(struct exfatfs_dfe *out,
-		       struct exfatfs_dfe *in);
+uint32_t exfatfs_cksum32(uint32_t, uint8_t *, uint64_t, uint8_t *, uint8_t);
+uint16_t exfatfs_namehash(struct exfatfs *, uint16_t, uint16_t *, int);
+uint16_t exfatfs_cksum16(uint16_t, uint8_t *, uint64_t, uint8_t *, uint8_t);
+void htole_bootblock(struct exfatfs *, struct exfatfs *);
+void letoh_bootblock(struct exfatfs *, struct exfatfs *);
+void htole_dfe(struct exfatfs_dfe *, struct exfatfs_dfe *);
+void letoh_dfe(struct exfatfs_dfe *, struct exfatfs_dfe *);
 
 #endif /* EXFATFS_CKSUM_H_ */
Index: src/sys/fs/exfatfs/exfatfs_conv.c
diff -u src/sys/fs/exfatfs/exfatfs_conv.c:1.1.2.1 src/sys/fs/exfatfs/exfatfs_conv.c:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_conv.c:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_conv.c	Mon Jul  1 22:15:21 2024
@@ -1,7 +1,7 @@
-/*	$NetBSD: exfatfs_conv.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $	*/
+/*	$NetBSD: exfatfs_conv.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $	*/
 
 /*-
- * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,10 +25,6 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exfatfs_conv.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $");
-
 /*-
  * Copyright (C) 1995, 1997 Wolfgang Solfrank.
  * Copyright (C) 1995, 1997 TooLs GmbH.
@@ -77,6 +73,9 @@ __KERNEL_RCSID(0, "$NetBSD: exfatfs_conv
  *
  */
 
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: exfatfs_conv.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $");
+
 #if HAVE_NBTOOL_CONFIG_H
 #include "nbtool_config.h"
 #endif
@@ -86,9 +85,6 @@ __KERNEL_RCSID(0, "$NetBSD: exfatfs_conv
 #define KASSERT(x)     assert(x)
 #endif
 
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exfatfs_conv.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $");
-
 /*
  * System include files.
  */
@@ -158,7 +154,8 @@ static int utf8ucs2(const u_int8_t *, in
  * file timestamps. The passed in unix time is assumed to be in GMT.
  */
 void
-exfatfs_unix2dostime(const struct timespec *tsp, int gmtoff, uint32_t *dtp, uint8_t *dhp)
+exfatfs_unix2dostime(const struct timespec *tsp, int gmtoff, uint32_t *dtp,
+	uint8_t *dhp)
 {
 	u_long t;
 	struct clock_ymdhms ymd;
@@ -210,7 +207,8 @@ invalid_dos_date:
  * not be too efficient.
  */
 struct timespec *
-exfatfs_dos2unixtime(uint32_t dt, u_int8_t dh, int gmtoff, struct timespec *tsp)
+exfatfs_dos2unixtime(uint32_t dt, u_int8_t dh, int gmtoff,
+	struct timespec *tsp)
 {
 	time_t seconds;
 	struct clock_ymdhms ymd;
@@ -245,7 +243,8 @@ exfatfs_dos2unixtime(uint32_t dt, u_int8
  * User-space versions of the above.
  */
 void
-exfatfs_unix2dostime(const struct timespec *tsp, int gmtoff, uint32_t *dtp, uint8_t *dhp)
+exfatfs_unix2dostime(const struct timespec *tsp, int gmtoff, uint32_t *dtp,
+	uint8_t *dhp)
 {
 	time_t t;
 	struct tm *tm;
@@ -292,12 +291,14 @@ invalid_dos_date:
 }
 
 struct timespec *
-exfatfs_dos2unixtime(uint32_t dt, uint8_t dh, int gmtoff, struct timespec *tsp) {
+exfatfs_dos2unixtime(uint32_t dt, uint8_t dh, int gmtoff, struct timespec *tsp)
+{
 	struct tm tm;
 	time_t seconds;
 
 	memset(&tm, 0, sizeof(tm));
-	tm.tm_year = ((dt & DT_YEAR_MASK)       >> DT_YEAR_SHIFT) + DOSBIASYEAR - 1900;
+	tm.tm_year = ((dt & DT_YEAR_MASK)       >> DT_YEAR_SHIFT)
+							+ DOSBIASYEAR - 1900;
 	tm.tm_mon =  ((dt & DT_MONTH_MASK) - 1) >> DT_MONTH_SHIFT;
 	tm.tm_mday = (dt & DT_DAY_MASK)         >> DT_DAY_SHIFT;
 	tm.tm_hour = (dt & DT_HOURS_MASK)       >> DT_HOURS_SHIFT;
@@ -380,7 +381,9 @@ utf8ucs2(const u_int8_t *in, int n, u_in
 		return 2;
 	} else if (in[0] <= 0xef) {
 		if (n < 3) return 0;
-		outch = (in[0] & 0x1f) << 12 | (in[1] & 0x3f) << 6 | (in[2] & 0x3f);
+		outch = (in[0] & 0x1f) << 12
+			| (in[1] & 0x3f) << 6
+			| (in[2] & 0x3f);
 		if (out)
 			*out = htole16(outch);
 		return 3;
@@ -438,5 +441,3 @@ exfatfs_utf8ucs2str(const u_int8_t *in, 
 
 	return p - out;
 }
-
-
Index: src/sys/fs/exfatfs/exfatfs_conv.h
diff -u src/sys/fs/exfatfs/exfatfs_conv.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_conv.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_conv.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_conv.h	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,31 @@
-/* $NetBSD: exfatfs_conv.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $ */
+/* $NetBSD: exfatfs_conv.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $ */
+
+/*-
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef EXFATFS_CONV_H_
 #define EXFATFS_CONV_H_
 
@@ -12,6 +39,8 @@ struct timespec;
 
 int exfatfs_ucs2utf8str(const uint16_t *, int, uint8_t *, int);
 int exfatfs_utf8ucs2str(const uint8_t *, int, uint16_t *, int);
-void exfatfs_unix2dostime(const struct timespec *tsp, int gmtoff, uint32_t *, uint8_t *);
-struct timespec *exfatfs_dos2unixtime(uint32_t dt, uint8_t dh, int gmtoff, struct timespec *tsp);
+void exfatfs_unix2dostime(const struct timespec *, int, uint32_t *, uint8_t *);
+struct timespec *exfatfs_dos2unixtime(uint32_t, uint8_t, int,
+	struct timespec *);
+
 #endif /* EXFATFS_CONV_H_ */
Index: src/sys/fs/exfatfs/exfatfs_dirent.h
diff -u src/sys/fs/exfatfs/exfatfs_dirent.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_dirent.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_dirent.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_dirent.h	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,31 @@
-/* $NetBSD: exfatfs_dirent.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $ */
+/* $NetBSD: exfatfs_dirent.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $ */
+
+/*-
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef EXFATFS_DIRENT_H_
 #define EXFATFS_DIRENT_H_
 
@@ -11,7 +38,8 @@ struct exfatfs_dirent {
 #define XD_ENTRYTYPE_TYPECODE_MASK       0x1f /* All values valid */
 #define XD_ENTRYTYPE_TYPEIMPORTANCE_MASK 0x20 /* 0 = critical, 1 = benign */
 #define XD_ENTRYTYPE_TYPECATEGORY_MASK   0x40 /* 0 = primary, 1 = secondary */
-#define ISPRIMARY(dp) (((dp)->xd_entryType & XD_ENTRYTYPE_TYPECATEGORY_MASK) == 0)
+#define ISPRIMARY(dp) (((dp)->xd_entryType & XD_ENTRYTYPE_TYPECATEGORY_MASK) \
+			== 0)
 #define XD_ENTRYTYPE_INUSE_MASK          0x80 /* 0 = not in use, 1 = in use */
 #define ISINUSE(dp) (((dp)->xd_entryType & XD_ENTRYTYPE_INUSE_MASK) > 0)
 
@@ -43,8 +71,10 @@ struct exfatfs_dirent_plus {
 
 struct exfatfs_dirent_primary {
 	uint8_t  xd_entryType;          /* Byte 0 */
-	uint8_t  xd_secondaryCount;     /* Byte 1 */ /* # of secondary entries after this one */
-	uint16_t xd_setChecksum;        /* Bytes 2-3 */ /* Checksum of all dirents, excluding this field */
+	/* # of secondary entries after this one */
+	uint8_t  xd_secondaryCount;     /* Byte 1 */
+	/* Checksum of all dirents, excluding this field */
+	uint16_t xd_setChecksum;        /* Bytes 2-3 */
 	uint16_t xd_generalPrimaryFlags; /* Bytes 4-5 */
 #define XD_GENERALPRIMARYFLAGS_ALLOCATIONPOSSIBLE_MASK 0x0001
 #define XD_GENERALPRIMARYFLAGS_NOFATCHAIN              0x0002
@@ -112,7 +142,8 @@ struct exfatfs_dfe {
 #define XD_FILEATTR_RESERVED1 0x0008
 #define XD_FILEATTR_DIRECTORY 0x0010
 #define XD_FILEATTR_ARCHIVE   0x0020
-#define XD_FILEATTR_SYMLINK   0x0040 /* Non-standard, from dorimanx/exfat-nofuse */
+/* Non-standard, from dorimanx/exfat-nofuse */
+#define XD_FILEATTR_SYMLINK   0x0040
 	uint8_t xd_reserved1[2];
 	uint32_t xd_createTimestamp;
 	uint32_t xd_lastModifiedTimestamp;
Index: src/sys/fs/exfatfs/exfatfs_extern.c
diff -u src/sys/fs/exfatfs/exfatfs_extern.c:1.1.2.1 src/sys/fs/exfatfs/exfatfs_extern.c:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_extern.c:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_extern.c	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exfatfs_extern.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $	*/
+/*	$NetBSD: exfatfs_extern.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $	*/
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@ typedef struct uvvnode uvnode_t;
 #  include <stdio.h>
 # endif /* !_KERNEL */
 #else
-# define DPRINTF(x)
+# define DPRINTF(x) __nothing
 #endif
 
 #ifdef _KERNEL
@@ -204,7 +204,8 @@ exfatfs_bmap_shared(struct vnode *vp, da
 		}
 		assert(pcn >= 2 && pcn < fs->xf_ClusterCount + 2);
 		/* Read the FAT to find the next cluster */
-		if ((error = bread(fs->xf_devvp, EXFATFS_FATBLK(fs, pcn), SECSIZE(fs), 0, &bp)) != 0) {
+		if ((error = bread(fs->xf_devvp, EXFATFS_FATBLK(fs, pcn),
+					SECSIZE(fs), 0, &bp)) != 0) {
 			printf("failed to read FAT pcn %u block 0x%x\n",
 			       (unsigned)pcn, (unsigned)EXFATFS_FATBLK(fs, pcn));
 			goto errout;
@@ -238,7 +239,7 @@ exfatfs_bmap_shared(struct vnode *vp, da
 	xip->xi_fatcache_pc = pcn;
 	*bnp = EXFATFS_CLUSTER2HWADDR(fs, pcn)
 		+ EXFATFS_FSSEC2DEVBSIZE(fs, (targetlbn
-					      & ((1 << fs->xf_SectorsPerClusterShift) - 1)));
+			      & ((1 << fs->xf_SectorsPerClusterShift) - 1)));
 
 	/* If we found it, hint the rest of the cluster. */
 	run = EXFATFS_CLUSTER2FSSEC(fs, targetcn + 1) - targetlbn - 1;
@@ -246,7 +247,7 @@ exfatfs_bmap_shared(struct vnode *vp, da
 		*runp = run;
 	}
 
-	DPRINTF(("BMAP return lcn %d at pcn 0x%lx -> lbn %d..%d at bn 0x%lx..0x%lx\n",
+	DPRINTF(("BMAP lcn %d at pcn 0x%lx -> lbn %d..%d at bn 0x%lx..0x%lx\n",
 		 (int)lcn, (unsigned long)pcn,
 		 (int)targetlbn, (int)(targetlbn + run),
 		 (unsigned long)*bnp,
@@ -256,7 +257,8 @@ errout:
 	return error;
 }
 
-int exfatfs_mountfs_shared(struct vnode *devvp, struct exfatfs_mount *xmp, unsigned secsize, struct exfatfs **fsp)
+int exfatfs_mountfs_shared(struct vnode *devvp, struct exfatfs_mount *xmp,
+	unsigned secsize, struct exfatfs **fsp)
 {
 	struct exfatfs *fs = NULL;
 	struct buf *bp;
@@ -304,7 +306,7 @@ int exfatfs_mountfs_shared(struct vnode 
 					   secsize, 0, &bp)) < 0) {
 				DPRINTF(("bread (., %lu, %lu, ., .) errno %d\n",
 					 (unsigned long)((bn + boot_offset)
-							 << (secshift - DEV_BSHIFT)),
+						<< (secshift - DEV_BSHIFT)),
 					 (unsigned long)secsize, error));
 				continue;
 			}
@@ -917,10 +919,16 @@ exfatfs_scandir(struct vnode *dvp,
 					uint16_t ucs2[NAME_MAX];
 					uint8_t utf8[NAME_MAX];
 					int namlen;
-					exfatfs_get_file_name(xip, ucs2, &namlen, sizeof(ucs2));
-					namlen = exfatfs_ucs2utf8str(ucs2, namlen, utf8, sizeof(utf8));
-					printf("trace process inum 0x%lx primary 0x%hhx valid %d len %d name %.*s\n",
-					       INUM(xip), xip->xi_direntp[0]->xd_entryType, valid, namlen, namlen, utf8);
+					exfatfs_get_file_name(xip, ucs2,
+						&namlen, sizeof(ucs2));
+					namlen = exfatfs_ucs2utf8str(ucs2,
+						namlen, utf8, sizeof(utf8));
+					printf("trace process inum 0x%lx"
+					       " primary 0x%hhx valid %d"
+					       " len %d name %.*s\n",
+					       INUM(xip),
+					       xip->xi_direntp[0]->xd_entryType,
+					       valid, namlen, namlen, utf8);
 				}
 #endif /* TRACE_INUM */
 					       
@@ -930,8 +938,10 @@ exfatfs_scandir(struct vnode *dvp,
 					assert(xip->xi_direntp[1] != NULL);
 					assert(dxip->xi_serial == dserial);
 					if (validfunc != NULL) {
-						flags = (*validfunc)(arg, xip, EXFATFS_DIRENT2BYTES(fs, off));
-						assert(dxip->xi_serial == dserial);
+						flags = (*validfunc)(arg, xip,
+						 EXFATFS_DIRENT2BYTES(fs, off));
+						assert(dxip->xi_serial
+							== dserial);
 						if (flags & SCANDIR_DONTFREE) {
 							/*
 							 * Caller will free
@@ -939,11 +949,14 @@ exfatfs_scandir(struct vnode *dvp,
 							 * Get ourselves a
 							 * new one.
 							 */
-							xip = exfatfs_newxfinode(fs, 0, 0);
+							xip = exfatfs_newxfinode
+								(fs, 0, 0);
 						}
-						assert(dxip->xi_serial == dserial);
+						assert(dxip->xi_serial
+							== dserial);
 						if (flags & SCANDIR_STOP) {
-							DPRINTF(("  SCANDIR_STOP\n"));
+							DPRINTF(("  SCANDIR"
+								 "_STOP\n"));
 							goto out;
 						}
 					}
Index: src/sys/fs/exfatfs/exfatfs_extern.h
diff -u src/sys/fs/exfatfs/exfatfs_extern.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_extern.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_extern.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_extern.h	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exfatfs_extern.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $	*/
+/*	$NetBSD: exfatfs_extern.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $	*/
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -25,24 +25,31 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+
+#ifndef EXFATFS_EXTERN_H_
+#define EXFATFS_EXTERN_H_
+
 #include <sys/types.h>
 #include <sys/vnode.h>
 #include <fs/exfatfs/exfatfs.h>
 #include <fs/exfatfs/exfatfs_inode.h>
 #include <fs/exfatfs/exfatfs_mount.h>
 
-int exfatfs_bmap_shared(struct vnode *vp, daddr_t bn, struct vnode **vpp,
-			daddr_t *bnp, int *runp);
-int exfatfs_mountfs_shared(struct vnode *devvp, struct exfatfs_mount *, unsigned secsize, struct exfatfs **fsp);
+int exfatfs_bmap_shared(struct vnode *, daddr_t, struct vnode **, daddr_t *,
+	int *);
+int exfatfs_mountfs_shared(struct vnode *, struct exfatfs_mount *, unsigned,
+	struct exfatfs **);
 struct xfinode *exfatfs_newxfinode(struct exfatfs *, uint32_t, uint32_t);
 struct exfatfs_dirent *exfatfs_newdirent(void);
 int exfatfs_get_file_name(struct xfinode *, uint16_t *, int *, int);
 int exfatfs_set_file_name(struct xfinode *, uint16_t *, int);
 void exfatfs_freexfinode(struct xfinode *);
 void exfatfs_freedirent(struct exfatfs_dirent *);
-int exfatfs_scandir(struct vnode *dvp, off_t startoff, off_t *endoff,
-		    unsigned (*emptyfunc)(void *, off_t, off_t),
-		    unsigned (*validfunc)(void *, struct xfinode *, off_t),
+int exfatfs_scandir(struct vnode *, off_t, off_t *,
+		    unsigned (*)(void *, off_t, off_t),
+		    unsigned (*)(void *, struct xfinode *, off_t),
 		    void *arg);
 #define SCANDIR_STOP     0x00000001
 #define SCANDIR_DONTFREE 0x00000002
+
+#endif /* EXFATFS_EXTERN_H_ */
Index: src/sys/fs/exfatfs/exfatfs_inode.h
diff -u src/sys/fs/exfatfs/exfatfs_inode.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_inode.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_inode.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_inode.h	Mon Jul  1 22:15:21 2024
@@ -1,6 +1,35 @@
-/*	$NetBSD: exfatfs_inode.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $	*/
+/*	$NetBSD: exfatfs_inode.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $	*/
 
 /*-
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Some of this code is derived from msdosfs, which bore the following
+ * copyright notice:
+ */
+/*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
  * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
  * All rights reserved.
@@ -63,13 +92,20 @@ struct exfatfs_lookup_results {
 
 /* Vnode key; taken from msdosfs */
 struct exfatfs_dirent_key {
-        uint32_t dk_dirclust;     /* cluster of the (primary) directory file containing this entry */
-        uint32_t dk_diroffset;    /* offset of this entry in the directory cluster, in dirent units */
-        void *dk_dirgen;          /* non zero and unique for unlinked nodes */
+	/* cluster of the (primary) directory file containing this entry */
+        uint32_t dk_dirclust;
+	/* offset of this entry in the directory cluster, in dirent units */
+        uint32_t dk_diroffset;
+	/* non zero and unique for unlinked nodes */
+        void *dk_dirgen;
 };
 
 #define EXFATFS_FENCE 2
 #define EXFATFS_MAXDIRENT 19 /* File + Stream + 17 * File Name */
+
+/*
+ * The in-memory structure representing an exFAT file.
+ */
 struct xfinode {
 	struct genfs_node i_gnode; /* Must be first */
 #ifdef EXFATFS_FENCE
@@ -103,7 +139,7 @@ struct xfinode {
 	 * Sections held on disk
 	 */
 	struct exfatfs_dirent *xi_direntp[EXFATFS_MAXDIRENT];
-	daddr_t xi_dirent_blk[EXFATFS_MAXDIRENT]; /* Location on disk, or NULL */
+	daddr_t xi_dirent_blk[EXFATFS_MAXDIRENT]; /* Location on disk */
 	int xi_dirent_off[EXFATFS_MAXDIRENT]; /* Offset within block */
 	
 	/* File Entry, one of the above pointers */
@@ -121,17 +157,60 @@ struct xfinode {
 #define GET_DFE_CREATE10MS(xip) DFE(xip)->xd_create10msIncrement
 #define GET_DFE_CREATE_UTCOFF(xip) DFE(xip)->xd_createUtcOffset
 
-#define SET_DFE_SET_CHECKSUM(xip, v) do { DFE(xip)->xd_setChecksum = (v); } while(0)
-#define SET_DFE_SECONDARY_COUNT(xip, v) do { DFE(xip)->xd_secondaryCount = (v); } while(0)
-#define SET_DFE_FILE_ATTRIBUTES(xip, v) do { DFE(xip)->xd_fileAttributes = (v); } while(0)
-#define SET_DFE_LAST_MODIFIED(xip, v) do { DFE(xip)->xd_lastModifiedTimestamp = (v); } while(0)
-#define SET_DFE_LAST_MODIFIED10MS(xip, v) do { DFE(xip)->xd_lastModified10msIncrement = (v); } while(0)
-#define SET_DFE_LAST_MODIFIED_UTCOFF(xip, v) do { DFE(xip)->xd_lastModifiedUtcOffset = (v); } while(0)
-#define SET_DFE_LAST_ACCESSED(xip, v) do { DFE(xip)->xd_lastAccessedTimestamp = (v); } while(0)
-#define SET_DFE_LAST_ACCESSED_UTCOFF(xip, v) do { DFE(xip)->xd_lastAccessedUtcOffset = (v); } while(0)
-#define SET_DFE_CREATE(xip, v) do { DFE(xip)->xd_createTimestamp = (v); } while(0)
-#define SET_DFE_CREATE10MS(xip, v) do { DFE(xip)->xd_create10msIncrement = (v); } while(0)
-#define SET_DFE_CREATE_UTCOFF(xip, v) do { DFE(xip)->xd_createUtcOffset = (v); } while(0)
+#define SET_DFE_SET_CHECKSUM(xip, v) 					\
+do {									\
+	DFE(xip)->xd_setChecksum = (v); 				\
+} while(0)
+
+#define SET_DFE_SECONDARY_COUNT(xip, v)					\
+do {									\
+	DFE(xip)->xd_secondaryCount = (v);				\
+} while(0)
+
+#define SET_DFE_FILE_ATTRIBUTES(xip, v)					\
+do {									\
+	DFE(xip)->xd_fileAttributes = (v);				\
+} while(0)
+
+#define SET_DFE_LAST_MODIFIED(xip, v)					\
+do {									\
+	DFE(xip)->xd_lastModifiedTimestamp = (v);			\
+} while(0)
+
+#define SET_DFE_LAST_MODIFIED10MS(xip, v)				\
+do {									\
+	DFE(xip)->xd_lastModified10msIncrement = (v);			\
+} while(0)
+
+#define SET_DFE_LAST_MODIFIED_UTCOFF(xip, v)				\
+do {									\
+	DFE(xip)->xd_lastModifiedUtcOffset = (v);			\
+} while(0)
+
+#define SET_DFE_LAST_ACCESSED(xip, v)					\
+do {									\
+	DFE(xip)->xd_lastAccessedTimestamp = (v);			\
+} while(0)
+
+#define SET_DFE_LAST_ACCESSED_UTCOFF(xip, v)				\
+do {									\
+	DFE(xip)->xd_lastAccessedUtcOffset = (v);			\
+} while(0)
+
+#define SET_DFE_CREATE(xip, v)						\
+do {									\
+	DFE(xip)->xd_createTimestamp = (v);				\
+} while(0)
+
+#define SET_DFE_CREATE10MS(xip, v)					\
+do {									\
+	DFE(xip)->xd_create10msIncrement = (v);				\
+} while(0)
+
+#define SET_DFE_CREATE_UTCOFF(xip, v)					\
+do {									\
+	DFE(xip)->xd_createUtcOffset = (v);				\
+} while(0)
 
 #define ISDIRECTORY(xip) (DFE(xip)->xd_fileAttributes & XD_FILEATTR_DIRECTORY)
 #define ISREADONLY(xip)  (DFE(xip)->xd_fileAttributes & XD_FILEATTR_READONLY)
@@ -147,19 +226,54 @@ struct xfinode {
 #define GET_DSE_FIRSTCLUSTER(xip)    DSE(xip)->xd_firstCluster
 #define GET_DSE_DATALENGTH(xip)      DSE(xip)->xd_dataLength
 
-#define SET_DSE_NAMELENGTH(xip, v)      do { DSE(xip)->xd_nameLength = (v); } while(0)
-#define SET_DSE_NAMEHASH(xip, v)        do { DSE(xip)->xd_nameHash = (v); } while(0)
-#define SET_DSE_VALIDDATALENGTH(xip, v) do { DSE(xip)->xd_validDataLength = (v); } while(0)
-#define SET_DSE_FIRSTCLUSTER(xip, v)    do { DSE(xip)->xd_firstCluster = (v); } while(0)
-#define SET_DSE_DATALENGTH(xip, v)      do { DSE(xip)->xd_dataLength = (v); } while(0)
-
-#define IS_DSE_ALLOCPOSSIBLE(xip) (DSE(xip)->xd_generalSecondaryFlags & XD_FLAG_ALLOCPOSSIBLE)
-#define SET_DSE_ALLOCPOSSIBLE(xip) do { DSE(xip)->xd_generalSecondaryFlags |= XD_FLAG_ALLOCPOSSIBLE; } while (0)
-#define CLR_DSE_ALLOCPOSSIBLE(xip) do { DSE(xip)->xd_generalSecondaryFlags &= ~XD_FLAG_ALLOCPOSSIBLE; } while (0)
-
-#define IS_DSE_NOFATCHAIN(xip) (DSE(xip)->xd_generalSecondaryFlags & XD_FLAG_NOFATCHAIN)
-#define SET_DSE_NOFATCHAIN(xip) do { DSE(xip)->xd_generalSecondaryFlags |= XD_FLAG_NOFATCHAIN; } while (0)
-#define CLR_DSE_NOFATCHAIN(xip) do { DSE(xip)->xd_generalSecondaryFlags &= ~XD_FLAG_NOFATCHAIN; } while (0)
+#define SET_DSE_NAMELENGTH(xip, v)					\
+do {									\
+	DSE(xip)->xd_nameLength = (v);					\
+} while(0)
+
+#define SET_DSE_NAMEHASH(xip, v)					\
+do {									\
+	DSE(xip)->xd_nameHash = (v);					\
+} while(0)
+
+#define SET_DSE_VALIDDATALENGTH(xip, v)					\
+do {									\
+	DSE(xip)->xd_validDataLength = (v);				\
+} while(0)
+
+#define SET_DSE_FIRSTCLUSTER(xip, v)					\
+do {									\
+	DSE(xip)->xd_firstCluster = (v);				\
+} while(0)
+
+#define SET_DSE_DATALENGTH(xip, v)					\
+do {									\
+	DSE(xip)->xd_dataLength = (v);					\
+} while(0)
+
+#define IS_DSE_ALLOCPOSSIBLE(xip)					\
+	(DSE(xip)->xd_generalSecondaryFlags & XD_FLAG_ALLOCPOSSIBLE)
+#define SET_DSE_ALLOCPOSSIBLE(xip)					\
+do {									\
+	DSE(xip)->xd_generalSecondaryFlags |= XD_FLAG_ALLOCPOSSIBLE;	\
+} while (0)
+
+#define CLR_DSE_ALLOCPOSSIBLE(xip)					\
+do {									\
+	DSE(xip)->xd_generalSecondaryFlags &= ~XD_FLAG_ALLOCPOSSIBLE;	\
+} while (0)
+
+#define IS_DSE_NOFATCHAIN(xip)						\
+	(DSE(xip)->xd_generalSecondaryFlags & XD_FLAG_NOFATCHAIN)
+#define SET_DSE_NOFATCHAIN(xip)						\
+do {									\
+	DSE(xip)->xd_generalSecondaryFlags |= XD_FLAG_NOFATCHAIN;	\
+} while (0)
+
+#define CLR_DSE_NOFATCHAIN(xip)						\
+do {									\
+	DSE(xip)->xd_generalSecondaryFlags &= ~XD_FLAG_NOFATCHAIN;	\
+} while (0)
 
 	unsigned long xi_serial; /* Serial number, for debugging */
 	
@@ -170,30 +284,34 @@ struct xfinode {
 
 #ifdef _KERNEL
 #define GETPARENT(xip, dvp) do {					\
-		KASSERT(dvp != NULL);					\
-		if (xip->xi_parentvp == NULL && dvp != NULL) {		\
-			KASSERT(dvp->v_data != xip);			\
-			++xip->xi_fs->xf_nparent;			\
-			DPRINTF(("getparent %s:%d ino 0x%lx parent 0x%lx now %d\n", \
-				 __FILE__, __LINE__, (unsigned long)INUM(xip), \
-				 (unsigned long)INUM(VTOXI(dvp)),	\
-				 xip->xi_fs->xf_nparent));		\
-			xip->xi_parentvp = dvp;				\
-			vref(dvp);					\
-		}							\
-	} while (0)
+	KASSERT(dvp != NULL);						\
+	if (xip->xi_parentvp == NULL && dvp != NULL) {			\
+		KASSERT(dvp->v_data != xip);				\
+		++xip->xi_fs->xf_nparent;				\
+		DPRINTF(("getparent %s:%d ino 0x%lx "			\
+			 "parent 0x%lx now %d\n",			\
+			 __FILE__, __LINE__,				\
+			 (unsigned long)INUM(xip),			\
+			 (unsigned long)INUM(VTOXI(dvp)),		\
+			 xip->xi_fs->xf_nparent));			\
+		xip->xi_parentvp = dvp;					\
+		vref(dvp);						\
+	}								\
+} while (0)
 
 #define PUTPARENT(xip) do {						\
-		if (xip->xi_parentvp != NULL) {				\
-			--xip->xi_fs->xf_nparent;			\
-			DPRINTF(("putparent %s:%d ino 0x%lx parent 0x%lx now %d\n", \
-				 __FILE__, __LINE__, (unsigned long)INUM(xip), \
-				 (unsigned long)INUM(VTOXI(xip->xi_parentvp)), \
-				 xip->xi_fs->xf_nparent));		\
-			vrele(xip->xi_parentvp);			\
-			xip->xi_parentvp = NULL;			\
-		}						    \
-	} while (0)
+	if (xip->xi_parentvp != NULL) {					\
+		--xip->xi_fs->xf_nparent;				\
+		DPRINTF(("putparent %s:%d ino 0x%lx "			\
+			 "parent 0x%lx now %d\n",			\
+			 __FILE__, __LINE__,				\
+			 (unsigned long)INUM(xip),			\
+			 (unsigned long)INUM(VTOXI(xip->xi_parentvp)),	\
+			 xip->xi_fs->xf_nparent));			\
+		vrele(xip->xi_parentvp);				\
+		xip->xi_parentvp = NULL;				\
+	}								\
+} while (0)
 #else
 #define GETPARENT(xip, dvp)
 #define PUTPARENT(xip)
@@ -205,7 +323,8 @@ void exfatfs_check_fence(struct exfatfs 
 # define exfatfs_check_fence(fs)
 #endif
 
-#define INUM(xip) EXFATFS_CLUST_ENTRY2INO((xip)->xi_fs, (xip)->xi_dirclust, (xip)->xi_diroffset)
+#define INUM(xip) EXFATFS_CLUST_ENTRY2INO((xip)->xi_fs, (xip)->xi_dirclust, \
+					(xip)->xi_diroffset)
 
 /*
  * Values for the xi_flag field of the xfinode.
@@ -214,7 +333,7 @@ void exfatfs_check_fence(struct exfatfs 
 #define	XI_CREATE	0x0002	/* Creation time update */
 #define	XI_ACCESS	0x0004	/* Access time update */
 #define	XI_MODIFIED	0x0008	/* Xfinode has been modified. */
-#define	XI_RENAME	0x0010	/* Xfinode is in the process of being renamed */
+#define	XI_RENAME	0x0010	/* Xfinode is being renamed */
 
 #define	EXFATFS_MAXNAMELEN	255
 
Index: src/sys/fs/exfatfs/exfatfs_mount.h
diff -u src/sys/fs/exfatfs/exfatfs_mount.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_mount.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_mount.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_mount.h	Mon Jul  1 22:15:21 2024
@@ -1,3 +1,31 @@
+/* $NetBSD: exfatfs_mount.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $ */
+
+/*-
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef EXFATFS_MOUNT_H_
 #define EXFATFS_MOUNT_H_
 
Index: src/sys/fs/exfatfs/exfatfs_rename.c
diff -u src/sys/fs/exfatfs/exfatfs_rename.c:1.1.2.1 src/sys/fs/exfatfs/exfatfs_rename.c:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_rename.c:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_rename.c	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exfatfs_rename.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $	*/
+/*	$NetBSD: exfatfs_rename.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $	*/
 
 /*-
  * Copyright (c) 2011, 2022 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exfatfs_rename.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exfatfs_rename.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -57,7 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: exfatfs_rena
 #ifdef EXFATFS_RENAME_DEBUG
 # define DPRINTF(x) printf x
 #else
-# define DPRINTF(x)
+# define DPRINTF(x) __nothing
 #endif
 
 /*
@@ -365,8 +365,8 @@ exfatfs_gro_rename(struct mount *mp, kau
 	KASSERT(fxip != NULL);
 	KASSERT(fs != NULL);
 
-	DPRINTF(("exfatfs_gro_rename(mp=%p, cred=%p, fdvp=%p, fcnp=%p, fde=%p, fvp=%p,\n",
-		 mp, cred, fdvp, fcnp, fde, fvp));
+	DPRINTF(("exfatfs_gro_rename(mp=%p, cred=%p, fdvp=%p, fcnp=%p, fde=%p,"
+		 " fvp=%p,\n", mp, cred, fdvp, fcnp, fde, fvp));
 	DPRINTF(("    tdvp=%p, tcnp=%p, tde=%p, tvp=%p, tvp_nlinkp=%p)\n",
 		 tdvp, tcnp, tde, tvp, tvp_nlinkp));
 
Index: src/sys/fs/exfatfs/exfatfs_rename.h
diff -u src/sys/fs/exfatfs/exfatfs_rename.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_rename.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_rename.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_rename.h	Mon Jul  1 22:15:21 2024
@@ -1,7 +1,7 @@
-/*	$NetBSD: exfatfs_rename.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $	*/
+/*	$NetBSD: exfatfs_rename.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $	*/
 
 /*-
- * Copyright (c) 2011, 2022 The NetBSD Foundation, Inc.
+ * Copyright (c) 2011, 2022, 2024 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -31,6 +31,6 @@
 #ifndef EXFATFS_RENAME_H_
 #define EXFATFS_RENAME_H_
 
-int exfatfs_rename(void *v);
+int exfatfs_rename(void *);
 
 #endif /* EXFATFS_RENAME_H_ */
Index: src/sys/fs/exfatfs/exfatfs_tables.c
diff -u src/sys/fs/exfatfs/exfatfs_tables.c:1.1.2.1 src/sys/fs/exfatfs/exfatfs_tables.c:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_tables.c:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_tables.c	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exfatfs_tables.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $	*/
+/*	$NetBSD: exfatfs_tables.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $	*/
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exfatfs_tables.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exfatfs_tables.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $");
 
 #include <sys/types.h>
 #include <sys/queue.h>
@@ -469,7 +469,8 @@ exfatfs_check_filename_ucs2(uint16_t *na
 	return 0;
 }
 
-MALLOC_JUSTDEFINE(M_EURO, "Exfatfs upcase table", "Exfatfs upcase table list entry");
+MALLOC_JUSTDEFINE(M_EURO, "Exfatfs upcase table",			\
+		"Exfatfs upcase table list entry");
 	
 void
 exfatfs_load_uctable(struct exfatfs *fs, uint16_t *table, int len)
@@ -566,7 +567,9 @@ exfatfs_upcase_str(struct exfatfs *fs, u
  * Implement strcasecmp() using this particular upcase table.
  * We don't care *how* the file names differ, only *whether* they differ.
  */
-int exfatfs_upcase_cmp(struct exfatfs *fs, uint16_t *s1, int len1, uint16_t *s2, int len2) {
+int exfatfs_upcase_cmp(struct exfatfs *fs, uint16_t *s1, int len1,
+	uint16_t *s2, int len2)
+{
 	int i, r;
 
 	for (i = 0; i < len1 && i < len2; i++) {
Index: src/sys/fs/exfatfs/exfatfs_tables.h
diff -u src/sys/fs/exfatfs/exfatfs_tables.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_tables.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_tables.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_tables.h	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,31 @@
-/* $NetBSD: exfatfs_tables.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $ */
+/* $NetBSD: exfatfs_tables.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $ */
+
+/*-
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef EXFATFS_TABLES_H_
 #define EXFATFS_TABLES_H_
 
Index: src/sys/fs/exfatfs/exfatfs_trie.c
diff -u src/sys/fs/exfatfs/exfatfs_trie.c:1.1.2.1 src/sys/fs/exfatfs/exfatfs_trie.c:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_trie.c:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_trie.c	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exfatfs_trie.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $	*/
+/*	$NetBSD: exfatfs_trie.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $	*/
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exfatfs_trie.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exfatfs_trie.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $");
 
 #include <sys/types.h>
 #include <sys/buf.h>
@@ -55,7 +55,8 @@ typedef struct uvnode uvnode_t;
 # include <stdlib.h>
 # include <string.h>
 # include <errno.h>
-# define pool_get(a, b) (struct xf_bitmap_node *)malloc(sizeof(struct xf_bitmap_node))
+# define pool_get(a, b) (struct xf_bitmap_node *)			\
+			malloc(sizeof(struct xf_bitmap_node))
 # define pool_put(a, b) free((b))
 #endif
 
@@ -67,7 +68,7 @@ typedef struct uvnode uvnode_t;
 #ifdef EXFATFS_TRIE_DEBUG
 # define DPRINTF(x) printf x
 #else
-# define DPRINTF(x)
+# define DPRINTF(x) __nothing
 #endif
 
 /*
@@ -76,9 +77,11 @@ typedef struct uvnode uvnode_t;
 
 extern struct pool exfatfs_bitmap_pool;
 
-static int exfatfs_bitmap_alloc_basic(struct exfatfs *fs, uint32_t start, uint32_t end, uint32_t *cp, int alloc);
+static int exfatfs_bitmap_alloc_basic(struct exfatfs *fs, uint32_t start,
+					uint32_t end, uint32_t *cp, int alloc);
 #ifndef USE_BASIC
-static int exfatfs_bitmap_isalloc_basic(struct exfatfs *fs, uint32_t cno, int *tfp);
+static int exfatfs_bitmap_isalloc_basic(struct exfatfs *fs, uint32_t cno,
+					int *tfp);
 #endif /* USE_BASIC */
 
 
@@ -209,7 +212,8 @@ exfatfs_bitmap_scan(struct exfatfs *fs,
 		if (bnp->children[i] == NULL) {
 			/* We must be empty */
 			if (bnp->count == 0) {
-				bnp->children[i] = pool_get(&exfatfs_bitmap_pool, PR_WAITOK);
+				bnp->children[i] = pool_get(
+					&exfatfs_bitmap_pool, PR_WAITOK);
 				memset(bnp->children[i], 0, sizeof(*bnp));
 			} else
 				continue;
@@ -342,8 +346,9 @@ exfatfs_init_trie(struct exfatfs *fs, in
 	/* Discover which is the top level */
 	for (i = BOTTOM_LEVEL; ; i++) {
 		DPRINTF(("TRIE: level %d gives %llu vs %llu\n", i,
-		       (unsigned long long)fs->xf_ClusterCount,
-			 (unsigned long long)(1 << (i * TBN_CHILDREN_SHIFT)) - 1));
+			(unsigned long long)fs->xf_ClusterCount,
+			(unsigned long long)
+				(1 << (i * TBN_CHILDREN_SHIFT)) - 1));
 		if (fs->xf_ClusterCount < (1 << (i * TBN_CHILDREN_SHIFT)) - 1) {
 			fs->xf_bitmap_toplevel = i;
 			break;
@@ -359,8 +364,9 @@ exfatfs_init_trie(struct exfatfs *fs, in
 	/* Populate from disk */
 	for (i = 0; i < GET_DSE_VALIDDATALENGTH(VTOXI(fs->xf_bitmapvp));
 	     i += SECSIZE(fs)) {
-		if ((error = bread(fs->xf_bitmapvp, i >> fs->xf_BytesPerSectorShift,
-				   SECSIZE(fs), 0, &bp)) != 0)
+		if ((error = bread(fs->xf_bitmapvp,
+				i >> fs->xf_BytesPerSectorShift,
+				SECSIZE(fs), 0, &bp)) != 0)
 			return error;
 		DPRINTF(("TRIE: read lblkno %lu blkno 0x%lx\n",
 		       (unsigned long)bp->b_lblkno,
@@ -371,7 +377,8 @@ exfatfs_init_trie(struct exfatfs *fs, in
 				break;
 			byte = ((char *)bp->b_data)[j];
 			if (cno + NBBY > fs->xf_ClusterCount)
-				byte &= ((1 << (fs->xf_ClusterCount & (NBBY - 1))) - 1);
+				byte &= ((1 << (fs->xf_ClusterCount
+						& (NBBY - 1))) - 1);
 			bitcount = byte2bitcount[byte];
 			DPRINTF(("TRIE: cluster %lu..%lu, %d busy\n",
 			       (unsigned long)(cno),
@@ -451,7 +458,8 @@ exfatfs_bitmap_destroy_trie(struct exfat
  */
 
 static int
-exfatfs_bitmap_alloc_basic(struct exfatfs *fs, uint32_t start, uint32_t end, uint32_t *cp, int alloc)
+exfatfs_bitmap_alloc_basic(struct exfatfs *fs, uint32_t start, uint32_t end,
+	uint32_t *cp, int alloc)
 {
 	daddr_t lbn, blkno;
 	uint32_t r, ostart, c;
@@ -476,13 +484,16 @@ exfatfs_bitmap_alloc_basic(struct exfatf
 			 (unsigned)LBNOFF2CLUSTER(fs, lbn, off),
 			 (unsigned)end));
 		while (LBNOFF2CLUSTER(fs, lbn, off) < end) {
-			exfatfs_bmap_shared(fs->xf_bitmapvp, lbn, NULL, &blkno, NULL);
+			exfatfs_bmap_shared(fs->xf_bitmapvp, lbn, NULL, &blkno,
+					    NULL);
 			DPRINTF((" lbn %u -> bn 0x%x\n",
 				 (unsigned)lbn, (unsigned)blkno));
-			if ((error = bread(fs->xf_devvp, blkno, SECSIZE(fs), 0, &bp)) != 0)
+			if ((error = bread(fs->xf_devvp, blkno, SECSIZE(fs), 0,
+					   &bp)) != 0)
 				return error;
 			DPRINTF((" search %u..%u\n",
-				 (unsigned)off, (unsigned)(1 << BITMAPSHIFT(fs))));
+				(unsigned)off,
+				(unsigned)(1 << BITMAPSHIFT(fs))));
 			while (off < (1 << BITMAPSHIFT(fs))
 			       && LBNOFF2CLUSTER(fs, lbn, off) < end) {
 				data = (uint8_t *)bp->b_data;
@@ -494,8 +505,10 @@ exfatfs_bitmap_alloc_basic(struct exfatf
 			}
 			if (r != INVALID) {
 				assert(r >= 2 && r < fs->xf_ClusterCount - 2);
-				DPRINTF(("basic allocate cluster %u/%u at lbn %u bit %d\n",
-					 (unsigned)r, (unsigned)end, (unsigned)lbn, (int)off));
+				DPRINTF(("basic allocate cluster %u/%u"
+					 " at lbn %u bit %d\n",
+					 (unsigned)r, (unsigned)end,
+					 (unsigned)lbn, (int)off));
 				setbit(data, off);
 				bdwrite(bp);
 				--fs->xf_FreeClusterCount;
@@ -596,7 +609,8 @@ exfatfs_bitmap_init_basic(struct exfatfs
 					++cn;
 				}
 			} else {
-				fs->xf_FreeClusterCount -= byte2bitcount[data[off]];
+				fs->xf_FreeClusterCount
+					-= byte2bitcount[data[off]];
 				cn += NBBY;
 			}
 		}
@@ -764,4 +778,3 @@ int exfatfs_bitmap_dealloc(struct exfatf
 	return exfatfs_bitmap_dealloc_trie(fs, cno);
 }
 #endif /* ! TEST_TRIE */
-
Index: src/sys/fs/exfatfs/exfatfs_trie.h
diff -u src/sys/fs/exfatfs/exfatfs_trie.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_trie.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_trie.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_trie.h	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,31 @@
-/* $NetBSD: exfatfs_trie.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $ */
+/* $NetBSD: exfatfs_trie.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $ */
+
+/*-
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef EXFATFS_TRIE_H_
 #define EXFATFS_TRIE_H_
 
Index: src/sys/fs/exfatfs/exfatfs_trie_basic.c
diff -u src/sys/fs/exfatfs/exfatfs_trie_basic.c:1.1.2.1 src/sys/fs/exfatfs/exfatfs_trie_basic.c:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_trie_basic.c:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_trie_basic.c	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exfatfs_trie_basic.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $	*/
+/*	$NetBSD: exfatfs_trie_basic.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $	*/
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exfatfs_trie_basic.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exfatfs_trie_basic.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $");
 
 #include <sys/types.h>
 #include <sys/buf.h>
@@ -55,7 +55,8 @@ typedef struct uvnode uvnode_t;
 # include <stdlib.h>
 # include <string.h>
 # include <errno.h>
-# define pool_get(a, b) (struct xf_bitmap_node *)malloc(sizeof(struct xf_bitmap_node))
+# define pool_get(a, b) (struct xf_bitmap_node *)			\
+			malloc(sizeof(struct xf_bitmap_node))
 # define pool_put(a, b) free((b))
 #endif
 
@@ -64,7 +65,7 @@ typedef struct uvnode uvnode_t;
 #ifdef EXFATFS_TRIE_DEBUG
 # define DPRINTF(x) printf x
 #else
-# define DPRINTF(x)
+# define DPRINTF(x) __nothing
 #endif
 
 /*
@@ -73,7 +74,8 @@ typedef struct uvnode uvnode_t;
 
 extern struct pool exfatfs_bitmap_pool;
 
-#define BN_FULL(bp, level) ((bp)->count == (1 << (level * BN_CHILDREN_SHIFT)) - 1)
+#define BN_FULL(bp, level) ((bp)->count == (1 << (level * BN_CHILDREN_SHIFT)) \
+									- 1)
 
 /* Convert cluster number to disk address and offset */
 #define NBBYSHIFT 3 /* 1 << NBBYSHIFT == NBBY == 8 */
@@ -142,7 +144,8 @@ exfatfs_bitmap_adj(struct exfatfs *fs,
 			return 0;
 		secno = cno >> (fs->xf_SectorsPerClusterShift
 				+ fs->xf_BytesPerSectorShift + NBBY);
-		if ((error = bread(fs->xf_bitmapvp, secno, BN_BLOCK_SIZE, 0, &bp)) != 0)
+		if ((error = bread(fs->xf_bitmapvp, secno, BN_BLOCK_SIZE, 0,
+				   &bp)) != 0)
 			return error;
 		data = (uint8_t *)bp->b_data;
 		if (dir > 0)
@@ -159,7 +162,8 @@ exfatfs_bitmap_adj(struct exfatfs *fs,
 	if (bnp->count == 0 || BN_FULL(bnp, level)) {
 		for (i = 0; i < BN_CHILDREN_COUNT; i++)
 			if (bnp->children[i] != NULL)
-				pool_put(&exfatfs_bitmap_pool, bnp->children[i]);
+				pool_put(&exfatfs_bitmap_pool,
+					 bnp->children[i]);
 		exfatfs_check_fence(fs);
 		return 0;
 	}
@@ -169,7 +173,8 @@ exfatfs_bitmap_adj(struct exfatfs *fs,
 		bnp->children[rcno] = pool_get(&exfatfs_bitmap_pool, PR_WAITOK);
 		memset(bnp->children[rcno], 0, sizeof(*bnp));
 	}
-	return exfatfs_bitmap_adj(fs, bnp->children[rcno], cno, --level, dir, alloc);
+	return exfatfs_bitmap_adj(fs, bnp->children[rcno], cno, --level, dir,
+				  alloc);
 }
 
 /*
@@ -201,7 +206,8 @@ exfatfs_bitmap_scan(struct exfatfs *fs,
 	if (level == BOTTOM_LEVEL) {
 		secno = start >> (fs->xf_SectorsPerClusterShift
 				  + fs->xf_BytesPerSectorShift + NBBY);
-		if ((error = bread(fs->xf_bitmapvp, secno, BN_BLOCK_SIZE, 0, &bp)) != 0)
+		if ((error = bread(fs->xf_bitmapvp, secno, BN_BLOCK_SIZE, 0,
+				   &bp)) != 0)
 			return error;
 		data = (uint8_t *)bp->b_data;
 		r = INVALID;
@@ -220,8 +226,9 @@ exfatfs_bitmap_scan(struct exfatfs *fs,
 				break;
 		}
 		if (alloc && r != INVALID) {
-			DPRINTF(("TRIE: allocate cluster %u at lbn %u byte %d bit %d\n",
-				 (unsigned)r, (unsigned)bp->b_lblkno, (int)i, (int)j));
+			DPRINTF(("TRIE: allocate cluster %u at lbn %u byte %d"
+				 " bit %d\n", (unsigned)r,
+				 (unsigned)bp->b_lblkno, (int)i, (int)j));
 			data[i] |= (1 << j);
 			bdwrite(bp);
 		} else
@@ -240,7 +247,8 @@ exfatfs_bitmap_scan(struct exfatfs *fs,
 		if (bnp->children[i] == NULL) /* Empty (or full) section */
 			return (i << (BN_CHILDREN_SHIFT * level));
 
-		error = exfatfs_bitmap_scan(fs, bnp->children[i], start, --level, &r, alloc);
+		error = exfatfs_bitmap_scan(fs, bnp->children[i], start,
+					    --level, &r, alloc);
 		if (error == 0 && r != INVALID) {
 			*cp = (i << (BN_CHILDREN_SHIFT * level)) | r;
 			exfatfs_check_fence(fs);
@@ -272,8 +280,9 @@ exfatfs_init_trie(struct exfatfs *fs, in
 	/* Discover which is the top level */
 	for (i = BOTTOM_LEVEL; ; i++) {
 		DPRINTF(("TRIE: level %d gives %llu vs %llu\n", i,
-		       (unsigned long long)fs->xf_ClusterCount,
-			 (unsigned long long)(1 << (i * BN_CHILDREN_SHIFT)) - 1));
+		         (unsigned long long)fs->xf_ClusterCount,
+			 (unsigned long long)
+				(1 << (i * BN_CHILDREN_SHIFT)) - 1));
 		if (fs->xf_ClusterCount < (1 << (i * BN_CHILDREN_SHIFT)) - 1) {
 			fs->xf_bitmap_toplevel = i;
 			break;
@@ -287,8 +296,10 @@ exfatfs_init_trie(struct exfatfs *fs, in
 	}
 
 	/* Populate from disk */
-	for (i = 0; i < VTOXI(fs->xf_bitmapvp)->xi_validDataLength; i += SECSIZE(fs)) {
-		if ((error = bread(fs->xf_bitmapvp, i >> fs->xf_BytesPerSectorShift,
+	for (i = 0; i < VTOXI(fs->xf_bitmapvp)->xi_validDataLength;
+	     i += SECSIZE(fs)) {
+		if ((error = bread(fs->xf_bitmapvp,
+				   i >> fs->xf_BytesPerSectorShift,
 				   SECSIZE(fs), 0, &bp)) != 0)
 			return error;
 		DPRINTF(("TRIE: read lblkno %lu blkno 0x%lx\n",
@@ -300,7 +311,8 @@ exfatfs_init_trie(struct exfatfs *fs, in
 				break;
 			byte = ((char *)bp->b_data)[j];
 			if (cno + NBBY > fs->xf_ClusterCount)
-				byte &= ((1 << (fs->xf_ClusterCount & (NBBY - 1))) - 1);
+				byte &= ((1 << (fs->xf_ClusterCount
+						& (NBBY - 1))) - 1);
 			bitcount = byte2bitcount[byte];
 			DPRINTF(("TRIE: cluster %lu..%lu, %d busy\n",
 			       (unsigned long)(cno),
@@ -377,13 +389,16 @@ exfatfs_bitmap_alloc(struct exfatfs *fs,
 			 (unsigned)LBNOFF2CLUSTER(fs, lbn, off),
 			 (unsigned)end));
 		while (LBNOFF2CLUSTER(fs, lbn, off) < end) {
-			exfatfs_bmap_shared(fs->xf_bitmapvp, lbn, NULL, &blkno, NULL);
+			exfatfs_bmap_shared(fs->xf_bitmapvp, lbn, NULL, &blkno,
+					    NULL);
 			DPRINTF((" lbn %u -> bn 0x%x\n",
 				 (unsigned)lbn, (unsigned)blkno));
-			if ((error = bread(fs->xf_devvp, blkno, SECSIZE(fs), 0, &bp)) != 0)
+			if ((error = bread(fs->xf_devvp, blkno, SECSIZE(fs), 0,
+					   &bp)) != 0)
 				return error;
 			DPRINTF((" search %u..%u\n",
-				 (unsigned)off, (unsigned)(1 << BITMAPSHIFT(fs))));
+				 (unsigned)off,
+				 (unsigned)(1 << BITMAPSHIFT(fs))));
 			while (off < (1 << BITMAPSHIFT(fs))
 			       && LBNOFF2CLUSTER(fs, lbn, off) < end) {
 				data = (uint8_t *)bp->b_data;
@@ -395,8 +410,10 @@ exfatfs_bitmap_alloc(struct exfatfs *fs,
 			}
 			if (r != INVALID) {
 				assert(r >= 2 && r < fs->xf_ClusterCount - 2);
-				DPRINTF(("basic allocate cluster %u/%u at lbn %u bit %d\n",
-					 (unsigned)r, (unsigned)end, (unsigned)lbn, (int)off));
+				DPRINTF(("basic allocate cluster %u/%u at lbn"
+					 " %u bit %d\n", (unsigned)r,
+					 (unsigned)end, (unsigned)lbn,
+					 (int)off));
 				setbit(data, off);
 				bdwrite(bp);
 #ifdef _KERNEL
@@ -483,14 +500,17 @@ exfatfs_bitmap_init(struct exfatfs *fs, 
 		exfatfs_bmap_shared(fs->xf_bitmapvp, lbn, NULL, &blkno, NULL);
 		DPRINTF((" lbn %u -> bn 0x%x\n",
 			 (unsigned)lbn, (unsigned)blkno));
-		if ((error = bread(fs->xf_devvp, blkno, SECSIZE(fs), 0, &bp)) != 0) {
+		if ((error = bread(fs->xf_devvp, blkno, SECSIZE(fs), 0, &bp))
+			     != 0) {
 			printf("bread(%p, %u, %u) returned %d\n",
-			       fs->xf_devvp, (unsigned)blkno, (unsigned)SECSIZE(fs), error);
+			       fs->xf_devvp, (unsigned)blkno,
+			       (unsigned)SECSIZE(fs), error);
 			return error;
 		}
 #if 1
 		for (data = (uint8_t *)bp->b_data;
-		     data - (uint8_t *)bp->b_data < SECSIZE(fs) && LBNOFF2CLUSTER(fs, lbn, off + NBBY) < end;
+		     data - (uint8_t *)bp->b_data < SECSIZE(fs)
+			&& LBNOFF2CLUSTER(fs, lbn, off + NBBY) < end;
 		     ++data) {
 			fs->xf_FreeClusterCount -= byte2bitcount[*data];
 			off += NBBY;
@@ -518,4 +538,3 @@ exfatfs_bitmap_destroy(struct exfatfs *f
 {
 }
 #endif /* ! EXFATFS_USE_TRIE */
-
Index: src/sys/fs/exfatfs/exfatfs_trie_basic.h
diff -u src/sys/fs/exfatfs/exfatfs_trie_basic.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_trie_basic.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_trie_basic.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_trie_basic.h	Mon Jul  1 22:15:21 2024
@@ -1,6 +1,33 @@
-/* $NetBSD: exfatfs_trie_basic.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $ */
-#ifndef EXFATFS_TRIE_H_
-#define EXFATFS_TRIE_H_
+/* $NetBSD: exfatfs_trie_basic.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $ */
+
+/*-
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EXFATFS_TRIE_BASIC_H_
+#define EXFATFS_TRIE_BASIC_H_
 
 #define BN_CHILDREN_SHIFT 8
 #define BN_CHILDREN_COUNT (1 << BN_CHILDREN_SHIFT)
@@ -13,10 +40,10 @@ struct xf_bitmap_node {
 	uint32_t count;
 };
 
-int exfatfs_bitmap_init(struct exfatfs *fs, int);
-void exfatfs_bitmap_destroy(struct exfatfs *fs);
+int exfatfs_bitmap_init(struct exfatfs *, int);
+void exfatfs_bitmap_destroy(struct exfatfs *);
 
-int exfatfs_bitmap_alloc(struct exfatfs *fs, uint32_t start, uint32_t *cp);
-int exfatfs_bitmap_dealloc(struct exfatfs *fs, uint32_t cno);
+int exfatfs_bitmap_alloc(struct exfatfs *, uint32_t, uint32_t *);
+int exfatfs_bitmap_dealloc(struct exfatfs *, uint32_t);
 
-#endif /* EXFATFS_TRIE_H_ */
+#endif /* EXFATFS_TRIE_BASIC_H_ */
Index: src/sys/fs/exfatfs/exfatfs_vfsops.c
diff -u src/sys/fs/exfatfs/exfatfs_vfsops.c:1.1.2.1 src/sys/fs/exfatfs/exfatfs_vfsops.c:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_vfsops.c:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_vfsops.c	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: exfatfs_vfsops.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $ */
+/* $NetBSD: exfatfs_vfsops.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $ */
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exfatfs_vfsops.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exfatfs_vfsops.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $");
 
 struct vm_page;
 
@@ -66,7 +66,7 @@ struct vm_page;
 #ifdef EXFATFS_VFSOPS_DEBUG
 # define DPRINTF(x) printf x
 #else
-# define DPRINTF(x)
+# define DPRINTF(x) __nothing
 #endif
 
 static int update_mp(struct mount *, struct exfatfs_args *);
Index: src/sys/fs/exfatfs/exfatfs_vfsops.h
diff -u src/sys/fs/exfatfs/exfatfs_vfsops.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_vfsops.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_vfsops.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_vfsops.h	Mon Jul  1 22:15:21 2024
@@ -1,24 +1,54 @@
-/* $NetBSD: exfatfs_vfsops.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $ */
+/* $NetBSD: exfatfs_vfsops.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $ */
+
+/*-
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef EXFATFS_VFSOPS_H_
 #define EXFATFS_VFSOPS_H_
 
-int exfatfs_getnewvnode(struct exfatfs *fs, struct vnode *dvp,
-			uint32_t clust, uint32_t off, unsigned type,
-			void *xip, struct vnode **vpp);
+int exfatfs_getnewvnode(struct exfatfs *, struct vnode *,
+			uint32_t, uint32_t, unsigned,
+			void *, struct vnode **);
+
 #ifdef _KERNEL
 void exfatfs_init(void);
-int exfatfs_loadvnode(struct mount *mp, struct vnode *vp, const void *key, size_t key_len, const void **new_key);
-int exfatfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len);
-int exfatfs_mountfs(struct vnode *, struct mount *, struct lwp *, struct exfatfs_args *);
-int exfatfs_finish_mountfs(struct exfatfs *fs);
+int exfatfs_loadvnode(struct mount *, struct vnode *, const void *, size_t,
+	const void **);
+int exfatfs_mount(struct mount *, const char *, void *, size_t *);
+int exfatfs_mountfs(struct vnode *, struct mount *, struct lwp *,
+	struct exfatfs_args *);
+int exfatfs_finish_mountfs(struct exfatfs *);
 int exfatfs_mountroot(void);
 /* void exfatfs_reinit(void); */
-int exfatfs_root(struct mount *mp, int unused, struct vnode **vpp);
-int exfatfs_start(struct mount *mp, int flags);
-int exfatfs_statvfs(struct mount *mp, struct statvfs *sbp);
-int exfatfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred);
-int exfatfs_unmount(struct mount *mp, int mntflags);
-int exfatfs_vget(struct mount *mp, ino_t ino, int unused, struct vnode **vpp);
+int exfatfs_root(struct mount *, int, struct vnode **);
+int exfatfs_start(struct mount *, int);
+int exfatfs_statvfs(struct mount *, struct statvfs *);
+int exfatfs_sync(struct mount *, int, kauth_cred_t);
+int exfatfs_unmount(struct mount *, int);
+int exfatfs_vget(struct mount *, ino_t, int, struct vnode **);
 #endif /* _KERNEL */
 
 #endif /* EXFATFS_VFSOPS_H_ */
Index: src/sys/fs/exfatfs/exfatfs_vnops.c
diff -u src/sys/fs/exfatfs/exfatfs_vnops.c:1.1.2.1 src/sys/fs/exfatfs/exfatfs_vnops.c:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_vnops.c:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_vnops.c	Mon Jul  1 22:15:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exfatfs_vnops.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $	*/
+/*	$NetBSD: exfatfs_vnops.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $	*/
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exfatfs_vnops.c,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exfatfs_vnops.c,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $");
 
 #include <sys/buf.h>
 #include <sys/dirent.h>
@@ -89,7 +89,7 @@ static uint8_t PRIMARY_IGNORE_LEN = 2;
 #ifdef EXFATFS_VNOPS_DEBUG
 # define DPRINTF(x) printf x
 #else
-# define DPRINTF(x)
+# define DPRINTF(x) __nothing
 #endif
 
 /*
@@ -293,9 +293,12 @@ exfatfs_setattr(void *v)
 		if (error)
 			goto bad;
 		if (vap->va_atime.tv_sec != VNOVAL)
-			exfatfs_unix2dostime(&vap->va_atime, fs->xf_gmtoff, &DFE(xip)->xd_lastAccessedTimestamp, NULL);
+			exfatfs_unix2dostime(&vap->va_atime, fs->xf_gmtoff,
+				&DFE(xip)->xd_lastAccessedTimestamp, NULL);
 		if (vap->va_mtime.tv_sec != VNOVAL)
-			exfatfs_unix2dostime(&vap->va_mtime, fs->xf_gmtoff, &DFE(xip)->xd_lastModifiedTimestamp, &DFE(xip)->xd_lastModified10msIncrement);
+			exfatfs_unix2dostime(&vap->va_mtime, fs->xf_gmtoff,
+				&DFE(xip)->xd_lastModifiedTimestamp,
+				&DFE(xip)->xd_lastModified10msIncrement);
 		DFE(xip)->xd_fileAttributes |= XD_FILEATTR_ARCHIVE;
 		xip->xi_flag |= XI_MODIFIED;
 		de_changed = 1;
@@ -415,8 +418,10 @@ exfatfs_read(void *v)
 
 		off = uio->uio_offset & (SECSIZE(fs) - 1);
 		n = uio->uio_resid - uio->uio_offset;
-		if (uio->uio_offset + uio->uio_resid > GET_DSE_VALIDDATALENGTH(xip))
-			n -= uio->uio_offset + uio->uio_resid - GET_DSE_VALIDDATALENGTH(xip);
+		if (uio->uio_offset + uio->uio_resid >
+		    GET_DSE_VALIDDATALENGTH(xip))
+			n -= uio->uio_offset + uio->uio_resid
+			     - GET_DSE_VALIDDATALENGTH(xip);
 		n = MIN(n, bp->b_resid - off);
 		if (n > 0)
 			error = uiomove((char *)bp->b_data + off, n, uio);
@@ -517,10 +522,12 @@ exfatfs_write(void *v)
 		/* DPRINTF(("write past valid data length\n")); */
 		if (uio->uio_offset + resid > GET_DSE_DATALENGTH(xip)) {
 			DPRINTF(("write past allocation\n"));
-			if ((error = deextend(xip, uio->uio_offset + resid, ioflag, cred)) != 0)
+			if ((error = deextend(xip, uio->uio_offset + resid,
+					      ioflag, cred)) != 0)
 				goto errexit;
 			DPRINTF(("now vdl=%llu dl=%llu\n",
-				 (unsigned long long)GET_DSE_VALIDDATALENGTH(xip),
+				 (unsigned long long)
+					GET_DSE_VALIDDATALENGTH(xip),
 				 (unsigned long long)GET_DSE_DATALENGTH(xip)));
 		}
 
@@ -531,7 +538,8 @@ exfatfs_write(void *v)
 		rem = round_page(GET_DSE_VALIDDATALENGTH(xip))
 			- GET_DSE_VALIDDATALENGTH(xip);
 		if (rem > 0)
-			ubc_zerorange(&vp->v_uobj, (off_t)GET_DSE_VALIDDATALENGTH(xip),
+			ubc_zerorange(&vp->v_uobj,
+				      (off_t)GET_DSE_VALIDDATALENGTH(xip),
 			    rem, UBC_VNODE_FLAGS(vp));
 		extended = 1;
 	}
@@ -625,7 +633,8 @@ exfatfs_writeback(struct xfinode *xip)
 	for (i = 0; i < EXFATFS_MAXDIRENT
 		     && xip->xi_direntp[i]
 		     && xip->xi_dirent_blk[i]; i++) {
-		DPRINTF((" write inum 0x%lx i=%d type 0x%x bn %lx off %d = cn 0x%lx off 0x%lx\n",
+		DPRINTF((" write inum 0x%lx i=%d type 0x%x bn %lx off %d"
+			 " = cn 0x%lx off 0x%lx\n",
 			 (unsigned long)INUM(xip), i,
 			 xip->xi_direntp[i]->xd_entryType,
 			 xip->xi_dirent_blk[i],
@@ -675,7 +684,8 @@ exfatfs_update(struct vnode *vp, const s
 	struct xfinode *xip;
 	
 	DPRINTF(("exfatfs_update %p (0x%lx) flags 0x%x xiflags 0x%lx\n",
-		 vp, (unsigned long)INUM(VTOXI(vp)), flags, VTOXI(vp)->xi_flag));
+		 vp, (unsigned long)INUM(VTOXI(vp)), flags,
+		 VTOXI(vp)->xi_flag));
 	
 	if (vp->v_mount->mnt_flag & MNT_RDONLY) {
 		DPRINTF(("exfatfs_update: ro\n"));
@@ -839,7 +849,7 @@ exfatfs_findempty(struct vnode *dvp, str
 	KASSERT(len > 2);
 	KASSERT(len <= EXFATFS_MAXDIRENT);
 	
-	DPRINTF(("exfatfs_findempty searching dir 0x%lx bytes 0..%llu of %llu\n",
+	DPRINTF(("exfatfs_findempty search dir 0x%lx bytes 0..%llu of %llu\n",
 		 (unsigned long)INUM(dxip),
 		 (unsigned long long)GET_DSE_VALIDDATALENGTH(dxip),
 		 (unsigned long long)GET_DSE_DATALENGTH(dxip)));
@@ -852,7 +862,8 @@ exfatfs_findempty(struct vnode *dvp, str
 	for (off = 0; off < GET_DSE_VALIDDATALENGTH(dxip); off += SECSIZE(fs)) {
 		lbn = EXFATFS_BYTES2FSSEC(fs, off);
 		VOP_BMAP(dvp, lbn, NULL, &blkno, NULL);
-		if ((error = bread(fs->xf_devvp, blkno, SECSIZE(fs), 0, &bp)) != 0)
+		if ((error = bread(fs->xf_devvp, blkno, SECSIZE(fs), 0, &bp))
+		    != 0)
 			return error;
 		for (so = 0; so < SECSIZE(fs); so += sizeof(*dirent)) {
 			dirent = (struct exfatfs_dirent *)
@@ -868,11 +879,15 @@ exfatfs_findempty(struct vnode *dvp, str
 				++contig;
 				if (contig >= len) {
 					brelse(bp, 0);
-					DPRINTF(("dir 0x%lx has %d empty entries at byte %lld (entry %u) bn 0x%lx..0x%lx\n",
+					DPRINTF(("dir 0x%lx has %d empty"
+						 " entries at byte %lld"
+						 " (entry %u) bn 0x%lx..0x%lx"
+						 "\n",
 						 (unsigned long)INUM(dxip),
 						 contig,
 						 (long long)r,
-						 (unsigned)EXFATFS_BYTES2DIRENT(fs, r),
+						 (unsigned)
+						  EXFATFS_BYTES2DIRENT(fs, r),
 						 rblkno, blkno));
 					goto havespace;
 				}
@@ -892,7 +907,8 @@ exfatfs_findempty(struct vnode *dvp, str
 	newsize = r + len * sizeof(*dirent);
 	if (GET_DSE_DATALENGTH(dxip) < newsize) {
 		/* We need to allocate blocks before extending */
-		if ((error = deextend(dxip, roundup2(newsize, CLUSTERSIZE(fs)), 0, NOCRED)) != 0)
+		if ((error = deextend(dxip, roundup2(newsize, CLUSTERSIZE(fs)),
+				      0, NOCRED)) != 0)
 			return error;
 		DPRINTF((" allocated dir 0x%lx to %llu\n",
 			 (unsigned long)INUM(dxip),
@@ -1095,7 +1111,8 @@ exfatfs_alloc(struct vnode *dvp, struct 
 		    cnp->cn_flags);
 
 	VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
-	DPRINTF(("exfatfs_alloc: new entry is 0x%lx\n", (unsigned long)INUM(xip)));
+	DPRINTF(("exfatfs_alloc: new entry is 0x%lx\n",
+		 (unsigned long)INUM(xip)));
 	return (0);
 
 errout:
@@ -1320,7 +1337,8 @@ exfatfs_lookup(void *v)
 
 	*vpp = NULL;
 	
-	DPRINTF(("exfatfs_lookup(%p, %p, {%x, %x, %d:\"%*s\"=%hhx,%hhx,%hhx})\n",
+	DPRINTF(("exfatfs_lookup(%p, %p, {%x, %x, %d:\"%*s\"=%hhx,%hhx,%hhx})"
+		 "\n",
 		 dvp, vpp,
 		 (unsigned)cnp->cn_nameiop,
 		 (unsigned)cnp->cn_flags,
@@ -1362,11 +1380,13 @@ exfatfs_lookup(void *v)
 #ifdef TRACE_INUM
 		if (INUM(dxip) == TRACE_INUM) {
 			if (*vpp == NULLVP) {
-				printf("cache_lookup returned ENOENT for name %.*s\n",
+				printf("cache_lookup returned ENOENT for name"
+				       " %.*s\n",
 				       (int)cnp->cn_namelen, cnp->cn_nameptr);
 			} else {
 				KASSERT(VTOXI(*vpp) != NULL);
-				printf("cache_lookup returned ino 0x%lx for name %.*s\n",
+				printf("cache_lookup returned ino 0x%lx for"
+				       " name %.*s\n",
 				       INUM(VTOXI(*vpp)), (int)cnp->cn_namelen,
 				       cnp->cn_nameptr);
 			}
@@ -1425,8 +1445,9 @@ exfatfs_lookup(void *v)
 	if (fx.xip != NULL) {
 #ifdef TRACE_INUM
 		if (INUM(dxip) == TRACE_INUM || INUM(fx.xip) == TRACE_INUM)
-			printf("lookup dino 0x%lx found ino 0x%lx with xip=%p gen %p\n",
-			       INUM(dxip), INUM(fx.xip), fx.xip, fx.xip->xi_dirgen);
+			printf("lookup dino 0x%lx found ino 0x%lx with xip=%p"
+			       " gen %p\n", INUM(dxip), INUM(fx.xip), fx.xip,
+			       fx.xip->xi_dirgen);
 #endif /* TRACE_INUM */
 		nvp = NULL;
 		/* Store xip where loadvnode can find it */
@@ -1636,9 +1657,10 @@ exfatfs_readdir(void *v)
 			}
 			dirbuf.d_type = DT_DIR;
 			dirbuf.d_reclen = _DIRENT_SIZE(&dirbuf);
-			DPRINTF(("dirbuf fileno=0x%lx type=%d namlen=%d name=%.*s\n",
-			       dirbuf.d_fileno, dirbuf.d_type,
-			       dirbuf.d_namlen,
+			DPRINTF(("dirbuf fileno=0x%lx type=%d namlen=%d"
+				 " name=%.*s\n",
+			         dirbuf.d_fileno, dirbuf.d_type,
+			         dirbuf.d_namlen,
 				 dirbuf.d_namlen, dirbuf.d_name));
 			if (uio->uio_resid < dirbuf.d_reclen)
 				goto out;
@@ -1680,9 +1702,10 @@ out:
 			*ap->a_ncookies = fo.ncookies;
 	}
 
-	DPRINTF(("readdir: returning %d with resid=%u, offset-BIAS=%llu, eof=%d\n",
-	       error, (unsigned)uio->uio_resid,
-	       (unsigned long long)(offset - BIAS),
+	DPRINTF(("readdir: returning %d with resid=%u, offset-BIAS=%llu,"
+		 " eof=%d\n",
+	         error, (unsigned)uio->uio_resid,
+	         (unsigned long long)(offset - BIAS),
 		 *ap->a_eofflag));
 	exfatfs_check_fence(fs);
 	return (error);
@@ -1939,10 +1962,12 @@ exfatfs_inactive(void *v)
 	 * it from the directory earlier.
          */
 	if (xip->xi_refcnt > 0) {
-	  DPRINTF(("exfatfs_inactive: ino 0x%lx no recycle\n", (unsigned long)INUM(xip)));
+		DPRINTF(("exfatfs_inactive: ino 0x%lx no recycle\n",
+			 (unsigned long)INUM(xip)));
 		*ap->a_recycle = 0;
 	} else {
-	  DPRINTF(("exfatfs_inactive: ino 0x%lx yes recycle\n", (unsigned long)INUM(xip)));
+		DPRINTF(("exfatfs_inactive: ino 0x%lx yes recycle\n",
+			 (unsigned long)INUM(xip)));
 		*ap->a_recycle = 1;
 #ifdef USE_INACTIVE
 		if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0 &&
@@ -2145,7 +2170,8 @@ exfatfs_readlink(void *v)
 		{
 			daddr_t blkno;
 			VOP_BMAP(vp, lbn, NULL, &blkno, NULL);
-			error = bread(xip->xi_devvp, blkno, SECSIZE(fs), 0, &bp);
+			error = bread(xip->xi_devvp, blkno, SECSIZE(fs), 0,
+				      &bp);
 		}
 #endif /* !SYMLINK_SELF */
 		if (error)
@@ -2208,7 +2234,7 @@ const struct vnodeopv_entry_desc exfatfs
 	{ &vop_inactive_desc, exfatfs_inactive },	/* inactive */
 	{ &vop_reclaim_desc, exfatfs_reclaim },		/* reclaim */
 #ifdef EXFATFS_LOCKDEBUG
-	{ &vop_lock_desc, exfatfs_lock },			/* lock */
+	{ &vop_lock_desc, exfatfs_lock },		/* lock */
 #else
 	{ &vop_lock_desc, genfs_lock },			/* lock */
 #endif
@@ -2269,8 +2295,9 @@ detrunc(struct xfinode *xip, off_t bytes
 	}
 #endif /* USE_FATCACHE */
 
-	DPRINTF(("inum 0x%lx trunc bytes=%lx lcn=0x%x pcn=0x%x oldcount=0x%x newcount=0x%x\n",
-		 (unsigned long)INUM(xip), (unsigned long)bytes, (unsigned)lcn, (unsigned)pcn,
+	DPRINTF(("inum 0x%lx trunc bytes=%lx lcn=0x%x pcn=0x%x oldcount=0x%x"
+		 " newcount=0x%x\n", (unsigned long)INUM(xip),
+		 (unsigned long)bytes, (unsigned)lcn, (unsigned)pcn,
 		 (unsigned)oldcount, (unsigned)newcount));
 	
 	while (lcn < oldcount) {
@@ -2278,17 +2305,21 @@ detrunc(struct xfinode *xip, off_t bytes
 		assert(pcn >= 2 && pcn < fs->xf_ClusterCount + 2);
 
 		/* Read the FAT to find the next cluster */
-		bread(fs->xf_devvp, EXFATFS_FATBLK(fs, pcn), SECSIZE(fs), 0, &bp);
+		bread(fs->xf_devvp, EXFATFS_FATBLK(fs, pcn), SECSIZE(fs), 0,
+		      &bp);
 		opcn = pcn;
 		pcn = ((uint32_t *)bp->b_data)[EXFATFS_FATOFF(pcn)];
 		if (lcn >= newcount) {
 			/* Deallocate cluster */
-			DPRINTF(("dealloc cluster 0x%x from ino 0x%x coff %u/%u\n",
+			DPRINTF(("dealloc cluster 0x%x from ino 0x%x coff"
+				 " %u/%u\n",
 				 (unsigned)opcn, (unsigned)INUM(xip),
 				 (unsigned)lcn,
-				 (unsigned)EXFATFS_BYTES2CLUSTER(fs, GET_DSE_DATALENGTH(xip))));
+				 (unsigned)EXFATFS_BYTES2CLUSTER(fs,
+					GET_DSE_DATALENGTH(xip))));
 			exfatfs_bitmap_dealloc(fs, opcn);
-			((uint32_t *)bp->b_data)[EXFATFS_FATOFF(opcn)] = 0xFFFFFFFF;
+			((uint32_t *)bp->b_data)[EXFATFS_FATOFF(opcn)]
+				= 0xFFFFFFFF;
 			if (ioflags)
 				bwrite(bp);
 			else
@@ -2297,9 +2328,13 @@ detrunc(struct xfinode *xip, off_t bytes
 			/* Invalidate the pages, if any, in the buffer cache */
 #if 0 /* use vtruncbuf instead */
 			if (ISDIRECTORY(xip) || ISSYMLINK(xip)) {
-				for (lbn = 0; lbn < EXFATFS_CLUSTER2FSSEC(fs, 1); ++lbn) {
+				for (lbn = 0;
+				     lbn < EXFATFS_CLUSTER2FSSEC(fs, 1); ++lbn) {
 					binvalbuf(xip->xi_devvp,
-						  EXFATFS_CLUSTER2HWADDR(fs, pcn) + EXFATFS_FSSEC2DEVBSIZE(fs, lbn));
+						  EXFATFS_CLUSTER2HWADDR(fs,
+							pcn)
+						  + EXFATFS_FSSEC2DEVBSIZE(fs,
+							lbn));
 				}
 			}
 #endif /* 0 */
@@ -2336,7 +2371,9 @@ detrunc(struct xfinode *xip, off_t bytes
 /*
  * Allocate clusters from the free map.
  */
-static int deextend(struct xfinode *xip, off_t bytes, int ioflags, kauth_cred_t cred) {
+static int deextend(struct xfinode *xip, off_t bytes, int ioflags,
+	kauth_cred_t cred)
+{
 	struct exfatfs *fs = xip->xi_fs;
 	uint32_t newcount = EXFATFS_BYTES2CLUSTER(fs, bytes) +
 		((bytes & CLUSTERMASK(fs)) ? 1 : 0);
@@ -2380,7 +2417,8 @@ static int deextend(struct xfinode *xip,
 #endif /* USE_FATCACHE */
 
 	if (lcn >= newcount) {
-		printf("impossible: bytes=%ld datalength=%lu lcn=%u old=%u new=%u\n",
+		printf("impossible: bytes=%ld datalength=%lu lcn=%u old=%u"
+		       " new=%u\n",
 		       (long)bytes, (unsigned long)GET_DSE_DATALENGTH(xip),
 		       lcn, oldcount, newcount);
 	}
@@ -2412,7 +2450,8 @@ static int deextend(struct xfinode *xip,
 			mutex_exit(&fs->xf_lock);
 #endif /* !ALLOC_SEQUENTIAL */
 			allocated = 1;
-			DPRINTF(("         allocated lclust %u = pclust 0x%x (following 0x%x)\n", lcn, pcn, opcn));
+			DPRINTF(("  allocated lclust %u = pclust 0x%x"
+				 " (following 0x%x)\n", lcn, pcn, opcn));
 			/* Store the allocation */
 			if (lcn == 0) {
 				/* Store it in the directory entry */
@@ -2420,11 +2459,14 @@ static int deextend(struct xfinode *xip,
 				SET_DSE_NOFATCHAIN(xip);
 			} else {
 				/* Store it in the FAT, just after opcn */
-				if ((error = bread(fs->xf_devvp, EXFATFS_FATBLK(fs, opcn),
+				if ((error = bread(fs->xf_devvp,
+						   EXFATFS_FATBLK(fs, opcn),
 						   SECSIZE(fs), 0, &bp)) != 0)
 					return error;
-				((uint32_t *)bp->b_data)[EXFATFS_FATOFF(opcn)] = pcn;
-				DPRINTF(("FAT %lu -> %lu\n", (unsigned long)opcn,
+				((uint32_t *)bp->b_data)[EXFATFS_FATOFF(opcn)]
+					= pcn;
+				DPRINTF(("FAT %lu -> %lu\n",
+					 (unsigned long)opcn,
 					 (unsigned long)pcn));
 				/*
 				 * If the clusters are not adjacent,
@@ -2432,7 +2474,8 @@ static int deextend(struct xfinode *xip,
 				 * reckoning for bmap.
 				 */
 				if (pcn != opcn + 1 && IS_DSE_NOFATCHAIN(xip)) {
-					DPRINTF(("inum 0x%lx not consecutive with 0x%x != 0x%x+1\n",
+					DPRINTF(("inum 0x%lx not consecutive"
+						 " with 0x%x != 0x%x+1\n",
 						 INUM(xip), pcn, opcn));
 					CLR_DSE_NOFATCHAIN(xip);
 				}
@@ -2447,7 +2490,8 @@ static int deextend(struct xfinode *xip,
 				for (bn = EXFATFS_CLUSTER2HWADDR(fs, pcn);
 				     EXFATFS_HWADDR2CLUSTER(fs, bn) == pcn;
 				     bn += EXFATFS_FSSEC2DEVBSIZE(fs, 1)) {
-					bp = getblk(fs->xf_devvp, bn, SECSIZE(fs), 0, 0);
+					bp = getblk(fs->xf_devvp, bn,
+						    SECSIZE(fs), 0, 0);
 					memset(bp->b_data, 0, SECSIZE(fs));
 					bdwrite(bp);
 					bp = NULL;
@@ -2468,7 +2512,8 @@ static int deextend(struct xfinode *xip,
 		if (allocated) {
 			pcn = 0;
 		} else {
-			if ((error = bread(fs->xf_devvp, EXFATFS_FATBLK(fs, pcn),
+			if ((error = bread(fs->xf_devvp,
+					   EXFATFS_FATBLK(fs, pcn),
 					   SECSIZE(fs), 0, &bp)) != 0)
 				return error;
 			pcn = ((uint32_t *)bp->b_data)[EXFATFS_FATOFF(pcn)];
Index: src/sys/fs/exfatfs/exfatfs_vnops.h
diff -u src/sys/fs/exfatfs/exfatfs_vnops.h:1.1.2.1 src/sys/fs/exfatfs/exfatfs_vnops.h:1.1.2.2
--- src/sys/fs/exfatfs/exfatfs_vnops.h:1.1.2.1	Sat Jun 29 19:43:26 2024
+++ src/sys/fs/exfatfs/exfatfs_vnops.h	Mon Jul  1 22:15:21 2024
@@ -1,39 +1,66 @@
-/* $NetBSD: exfatfs_vnops.h,v 1.1.2.1 2024/06/29 19:43:26 perseant Exp $ */
+/* $NetBSD: exfatfs_vnops.h,v 1.1.2.2 2024/07/01 22:15:21 perseant Exp $ */
+
+/*-
+ * Copyright (c) 2022, 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef EXFATFS_VNOPS_H_
 #define EXFATFS_VNOPS_H_
 
-int exfatfs_access(void *v);
-int exfatfs_activate(struct xfinode *xip, bool rekey);
-int exfatfs_advlock(void *v);
-int exfatfs_bmap(void *v);
-int exfatfs_close(void *v);
-int exfatfs_create(void *v);
-int exfatfs_deactivate(struct xfinode *xip, bool rekey);
+int exfatfs_access(void *);
+int exfatfs_activate(struct xfinode *, bool);
+int exfatfs_advlock(void *);
+int exfatfs_bmap(void *);
+int exfatfs_close(void *);
+int exfatfs_create(void *);
+int exfatfs_deactivate(struct xfinode *, bool);
 int exfatfs_findempty(struct vnode *, struct xfinode *);
-int exfatfs_fsync(void *v);
-int exfatfs_getattr(void *v);
-int exfatfs_inactive(void *v);
-void exfatfs_itimes(struct xfinode *dep, const struct timespec *acc,
-		    const struct timespec *mod, const struct timespec *cre);
+int exfatfs_fsync(void *);
+int exfatfs_getattr(void *);
+int exfatfs_inactive(void *);
+void exfatfs_itimes(struct xfinode *, const struct timespec *,
+		    const struct timespec *, const struct timespec *);
 int exfatfs_lookup(void *);
-int exfatfs_mkdir(void *v);
-int exfatfs_pathconf(void *v);
-int exfatfs_print(void *v);
-int exfatfs_read(void *v);
-int exfatfs_readdir(void *v);
-int exfatfs_readlink(void *v);
-int exfatfs_reclaim(void *v);
-int exfatfs_rekey(struct vnode *vp, struct exfatfs_dirent_key *nkeyp);
-int exfatfs_remove(void *v);
-int exfatfs_rename(void *v);
-int exfatfs_rmdir(void *v);
-int exfatfs_setattr(void *v);
-int exfatfs_strategy(void *v);
-int exfatfs_symlink(void *v);
-int exfatfs_update(struct vnode *vp, const struct timespec *acc,
-		   const struct timespec *mod, int flags);
-int exfatfs_write(void *v);
-int exfatfs_writeback(struct xfinode *xip);
-int exfatfs_writeback2(struct xfinode *xip, struct xfinode *rxip);
+int exfatfs_mkdir(void *);
+int exfatfs_pathconf(void *);
+int exfatfs_print(void *);
+int exfatfs_read(void *);
+int exfatfs_readdir(void *);
+int exfatfs_readlink(void *);
+int exfatfs_reclaim(void *);
+int exfatfs_rekey(struct vnode *, struct exfatfs_dirent_key *);
+int exfatfs_remove(void *);
+int exfatfs_rename(void *);
+int exfatfs_rmdir(void *);
+int exfatfs_setattr(void *);
+int exfatfs_strategy(void *);
+int exfatfs_symlink(void *);
+int exfatfs_update(struct vnode *, const struct timespec *,
+		   const struct timespec *, int);
+int exfatfs_write(void *);
+int exfatfs_writeback(struct xfinode *);
+int exfatfs_writeback2(struct xfinode *, struct xfinode *);
 
 #endif /* EXFATFS_VNOPS_H_ */

Reply via email to