From: Tomohiro Kusumi Date: Sat, 7 Sep 2019 17:33:01 +0000 (+0900) Subject: sys/vfs/msdosfs: Sync with FreeBSD (non functional diffs) X-Git-Tag: v5.8.0rc1~1017 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/8b2578454d6b1896b41203d8736ffdd19b8a8559 sys/vfs/msdosfs: Sync with FreeBSD (non functional diffs) --- diff --git a/sys/vfs/msdosfs/bootsect.h b/sys/vfs/msdosfs/bootsect.h index b85b9ad9ba..5a3ff56b85 100644 --- a/sys/vfs/msdosfs/bootsect.h +++ b/sys/vfs/msdosfs/bootsect.h @@ -1,7 +1,7 @@ -/* $FreeBSD: src/sys/msdosfs/bootsect.h,v 1.7 1999/08/28 00:48:06 peter Exp $ */ +/* $FreeBSD$ */ /* $NetBSD: bootsect.h,v 1.9 1997/11/17 15:36:17 ws Exp $ */ -/* +/*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote @@ -16,9 +16,8 @@ * * October 1992 */ - -#ifndef _VFS_MSDOSFS_BOOTSECT_H_ -#define _VFS_MSDOSFS_BOOTSECT_H_ +#ifndef _FS_MSDOSFS_BOOTSECT_H_ +#define _FS_MSDOSFS_BOOTSECT_H_ /* * Format of a boot sector. This is the first sector on a DOS floppy disk @@ -42,7 +41,6 @@ struct extboot { int8_t exReserved1; /* reserved */ int8_t exBootSignature; /* ext. boot signature (0x29) */ #define EXBOOTSIG 0x29 -#define EXBOOTSIG2 0x28 int8_t exVolumeID[4]; /* volume ID number */ int8_t exVolumeLabel[11]; /* volume label */ int8_t exFileSysType[8]; /* fs type (FAT12 or FAT16) */ @@ -63,35 +61,14 @@ struct bootsector50 { struct bootsector710 { uint8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */ int8_t bsOEMName[8]; /* OEM name and version */ - int8_t bsPBP[53]; /* BIOS parameter block */ + int8_t bsBPB[53]; /* BIOS parameter block */ int8_t bsExt[26]; /* Bootsector Extension */ - int8_t bsBootCode[418]; /* pad so structure is 512b */ - uint8_t bsBootSectSig2; /* 2 & 3 are only defined for FAT32? */ - uint8_t bsBootSectSig3; + int8_t bsBootCode[420]; /* pad so structure is 512b */ uint8_t bsBootSectSig0; uint8_t bsBootSectSig1; #define BOOTSIG0 0x55 #define BOOTSIG1 0xaa -#define BOOTSIG2 0 -#define BOOTSIG3 0 -}; - -#ifdef atari -/* - * The boot sector on a gemdos fs is a little bit different from the msdos fs - * format. Currently there is no need to declare a separate structure, the - * bootsector33 struct will do. - */ -#if 0 -struct bootsec_atari { - uint8_t bsBranch[2]; /* branch inst if auto-boot */ - int8_t bsFiller[6]; /* anything or nothing */ - int8_t bsSerial[3]; /* serial no. for mediachange */ - int8_t bsBPB[19]; /* BIOS parameter block */ - int8_t bsBootCode[482]; /* pad so struct is 512b */ }; -#endif -#endif /* atari */ union bootsector { struct bootsector33 bs33; @@ -117,4 +94,4 @@ union bootsector { #define bsHugeSectors bsBPB.bpbHugeSectors #endif -#endif /* !_VFS_MSDOSFS_BOOTSECT_H_ */ +#endif /* !_FS_MSDOSFS_BOOTSECT_H_ */ diff --git a/sys/vfs/msdosfs/bpb.h b/sys/vfs/msdosfs/bpb.h index 3a97961e4a..aeca6e997c 100644 --- a/sys/vfs/msdosfs/bpb.h +++ b/sys/vfs/msdosfs/bpb.h @@ -1,4 +1,4 @@ -/* $FreeBSD: head/sys/fs/msdosfs/bpb.h 203827 2010-02-13 12:41:07Z kib $ */ +/* $FreeBSD$ */ /* $NetBSD: bpb.h,v 1.7 1997/11/17 15:36:24 ws Exp $ */ /*- @@ -17,8 +17,8 @@ * October 1992 */ -#ifndef _VFS_MSDOSFS_BPB_H_ -#define _VFS_MSDOSFS_BPB_H_ +#ifndef _FS_MSDOSFS_BPB_H_ +#define _FS_MSDOSFS_BPB_H_ /* * BIOS Parameter Block (BPB) for DOS 3.3 @@ -84,28 +84,6 @@ struct bpb710 { uint8_t bpbReserved[12]; /* reserved for future expansion */ }; -#ifdef atari -/* - * BPB for gemdos filesystems. Atari leaves the obsolete stuff undefined. - * Currently there is no need for a separate BPB structure. - */ -#if 0 -struct bpb_a { - uint16_t bpbBytesPerSec; /* bytes per sector */ - uint8_t bpbSecPerClust; /* sectors per cluster */ - uint16_t bpbResSectors; /* number of reserved sectors */ - uint8_t bpbFATs; /* number of FATs */ - uint16_t bpbRootDirEnts; /* number of root directory entries */ - uint16_t bpbSectors; /* total number of sectors */ - uint8_t bpbUseless1; /* meaningless on gemdos fs */ - uint16_t bpbFATsecs; /* number of sectors per FAT */ - uint16_t bpbUseless2; /* meaningless for harddisk fs */ - uint16_t bpbUseless3; /* meaningless for harddisk fs */ - uint16_t bpbHiddenSecs; /* the TOS-BIOS ignores this */ -}; -#endif -#endif /* atari */ - /* * The following structures represent how the bpb's look on disk. shorts * and longs are just character arrays of the appropriate length. This is @@ -195,5 +173,4 @@ struct fsinfo { uint8_t fsifill3[508]; uint8_t fsisig4[4]; }; - -#endif /* !_VFS_MSDOSFS_BPB_H_ */ +#endif /* !_FS_MSDOSFS_BPB_H_ */ diff --git a/sys/vfs/msdosfs/denode.h b/sys/vfs/msdosfs/denode.h index aab75e9bed..c36988d64d 100644 --- a/sys/vfs/msdosfs/denode.h +++ b/sys/vfs/msdosfs/denode.h @@ -1,8 +1,9 @@ -/* $FreeBSD: src/sys/msdosfs/denode.h,v 1.20 1999/12/29 04:54:52 peter Exp $ */ -/* $DragonFly: src/sys/vfs/msdosfs/denode.h,v 1.12 2006/09/10 01:26:41 dillon Exp $ */ +/* $FreeBSD$ */ /* $NetBSD: denode.h,v 1.25 1997/11/17 15:36:28 ws Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. * Copyright (C) 1994, 1995, 1997 TooLs GmbH. * All rights reserved. @@ -33,7 +34,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote @@ -48,6 +49,8 @@ * * October 1992 */ +#ifndef _FS_MSDOSFS_DENODE_H_ +#define _FS_MSDOSFS_DENODE_H_ /* * This is the pc filesystem specific portion of the vnode structure. @@ -99,7 +102,7 @@ #define MSDOSFSROOT_OFS 0x1fffffff /* - * The fat cache structure. fc_fsrcn is the filesystem relative cluster + * The FAT cache structure. fc_fsrcn is the filesystem relative cluster * number that corresponds to the file relative cluster number in this * structure (fc_frcn). */ @@ -109,11 +112,11 @@ struct fatcache { }; /* - * The fat entry cache as it stands helps make extending files a "quick" - * operation by avoiding having to scan the fat to discover the last + * The FAT entry cache as it stands helps make extending files a "quick" + * operation by avoiding having to scan the FAT to discover the last * cluster of the file. The cache also helps sequential reads by * remembering the last cluster read from the file. This also prevents us - * from having to rescan the fat to find the next cluster to read. This + * from having to rescan the FAT to find the next cluster to read. This * cache is probably pretty worthless if a file is opened by multiple * processes. */ @@ -125,11 +128,11 @@ struct fatcache { #define FCE_EMPTY 0xffffffff /* doesn't represent an actual cluster # */ /* - * Set a slot in the fat cache. + * Set a slot in the FAT cache. */ #define fc_setcache(dep, slot, frcn, fsrcn) \ - (dep)->de_fc[slot].fc_frcn = frcn; \ - (dep)->de_fc[slot].fc_fsrcn = fsrcn; + (dep)->de_fc[(slot)].fc_frcn = (frcn); \ + (dep)->de_fc[(slot)].fc_fsrcn = (fsrcn); /* * This is the in memory variant of a dos directory entry. It is usually @@ -158,7 +161,7 @@ struct denode { u_short de_MDate; /* modification date */ u_long de_StartCluster; /* starting cluster of file */ u_long de_FileSize; /* size of file in bytes */ - struct fatcache de_fc[FC_SIZE]; /* fat cache */ + struct fatcache de_fc[FC_SIZE]; /* FAT cache */ u_quad_t de_modrev; /* Revision level for lease. */ }; @@ -180,7 +183,7 @@ struct denode { #define DE_INTERNALIZE32(dep, dp) \ ((dep)->de_StartCluster |= getushort((dp)->deHighClust) << 16) #define DE_INTERNALIZE(dep, dp) \ - (bcopy((dp)->deName, (dep)->de_Name, 11), \ + (memcpy((dep)->de_Name, (dp)->deName, 11), \ (dep)->de_Attributes = (dp)->deAttributes, \ (dep)->de_LowerCase = (dp)->deLowerCase, \ (dep)->de_CHun = (dp)->deCHundredth, \ @@ -194,7 +197,7 @@ struct denode { (FAT32((dep)->de_pmp) ? DE_INTERNALIZE32((dep), (dp)) : 0)) #define DE_EXTERNALIZE(dp, dep) \ - (bcopy((dep)->de_Name, (dp)->deName, 11), \ + (memcpy((dp)->deName, (dep)->de_Name, 11), \ (dp)->deAttributes = (dep)->de_Attributes, \ (dp)->deLowerCase = (dep)->de_LowerCase, \ (dp)->deCHundredth = (dep)->de_CHun, \ @@ -209,9 +212,6 @@ struct denode { 0 : (dep)->de_FileSize), \ putushort((dp)->deHighClust, (dep)->de_StartCluster >> 16)) -#define de_forw de_chain[0] -#define de_back de_chain[1] - #ifdef _KERNEL #define VTODE(vp) ((struct denode *)(vp)->v_data) @@ -243,7 +243,7 @@ struct denode { (dep)->de_flag |= DE_MODIFIED; \ } \ (dep)->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS); \ -} while (0); +} while (0) /* * This overlays the fid structure (see mount.h) @@ -285,3 +285,5 @@ int removede(struct denode *pdep, struct denode *dep); int detrunc(struct denode *dep, u_long length, int flags); int doscheckpath( struct denode *source, struct denode *target); #endif /* _KERNEL */ + +#endif /* !_FS_MSDOSFS_DENODE_H_ */ diff --git a/sys/vfs/msdosfs/direntry.h b/sys/vfs/msdosfs/direntry.h index 44a174529b..ba32b0cdbe 100644 --- a/sys/vfs/msdosfs/direntry.h +++ b/sys/vfs/msdosfs/direntry.h @@ -1,7 +1,9 @@ -/* $FreeBSD: src/sys/msdosfs/direntry.h,v 1.15 1999/12/29 04:54:52 peter Exp $ */ +/* $FreeBSD$ */ /* $NetBSD: direntry.h,v 1.14 1997/11/17 15:36:32 ws Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. * Copyright (C) 1994, 1995, 1997 TooLs GmbH. * All rights reserved. @@ -32,7 +34,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote @@ -47,19 +49,18 @@ * * October 1992 */ - -#ifndef _VFS_MSDOSFS_DIRENTRY_H_ -#define _VFS_MSDOSFS_DIRENTRY_H_ +#ifndef _FS_MSDOSFS_DIRENTRY_H_ +#define _FS_MSDOSFS_DIRENTRY_H_ /* * Structure of a dos directory entry. */ struct direntry { - uint8_t deName[11]; /* filename, blank filled */ + uint8_t deName[11]; /* filename, blank filled */ #define SLOT_EMPTY 0x00 /* slot has never been used */ #define SLOT_E5 0x05 /* the real value is 0xe5 */ #define SLOT_DELETED 0xe5 /* file in this slot deleted */ - uint8_t deAttributes; /* file attributes */ + uint8_t deAttributes; /* file attributes */ #define ATTR_NORMAL 0x00 /* normal file */ #define ATTR_READONLY 0x01 /* file is readonly */ #define ATTR_HIDDEN 0x02 /* file is hidden */ @@ -67,18 +68,18 @@ struct direntry { #define ATTR_VOLUME 0x08 /* entry is a volume label */ #define ATTR_DIRECTORY 0x10 /* entry is a directory name */ #define ATTR_ARCHIVE 0x20 /* file is new or modified */ - uint8_t deLowerCase; /* NT VFAT lower case flags */ + uint8_t deLowerCase; /* NT VFAT lower case flags */ #define LCASE_BASE 0x08 /* filename base in lower case */ #define LCASE_EXT 0x10 /* filename extension in lower case */ - uint8_t deCHundredth; /* hundredth of seconds in CTime */ - uint8_t deCTime[2]; /* create time */ - uint8_t deCDate[2]; /* create date */ - uint8_t deADate[2]; /* access date */ - uint8_t deHighClust[2]; /* high bytes of cluster number */ - uint8_t deMTime[2]; /* last update time */ - uint8_t deMDate[2]; /* last update date */ - uint8_t deStartCluster[2]; /* starting cluster of file */ - uint8_t deFileSize[4]; /* size of file in bytes */ + uint8_t deCHundredth; /* hundredth of seconds in CTime */ + uint8_t deCTime[2]; /* create time */ + uint8_t deCDate[2]; /* create date */ + uint8_t deADate[2]; /* access date */ + uint8_t deHighClust[2]; /* high bytes of cluster number */ + uint8_t deMTime[2]; /* last update time */ + uint8_t deMDate[2]; /* last update date */ + uint8_t deStartCluster[2]; /* starting cluster of file */ + uint8_t deFileSize[4]; /* size of file in bytes */ }; /* @@ -131,10 +132,11 @@ struct winentry { #ifdef _KERNEL struct mbnambuf { - size_t nb_len; - int nb_last_id; - char nb_buf[WIN_MAXLEN + 1]; + size_t nb_len; + int nb_last_id; + char nb_buf[WIN_MAXLEN + 1]; }; + struct dirent; struct msdosfsmount; @@ -157,5 +159,4 @@ uint8_t winChksum(uint8_t *name); int winSlotCnt(const u_char *un, size_t unlen, struct msdosfsmount *pmp); size_t winLenFixup(const u_char *un, size_t unlen); #endif /* _KERNEL */ - -#endif /* !_VFS_MSDOSFS_DIRENTRY_H_ */ +#endif /* !_FS_MSDOSFS_DIRENTRY_H_ */ diff --git a/sys/vfs/msdosfs/fat.h b/sys/vfs/msdosfs/fat.h index 08e9509d88..5f7937552d 100644 --- a/sys/vfs/msdosfs/fat.h +++ b/sys/vfs/msdosfs/fat.h @@ -1,8 +1,9 @@ -/* $FreeBSD: src/sys/msdosfs/fat.h,v 1.9 1999/12/29 04:54:53 peter Exp $ */ -/* $DragonFly: src/sys/vfs/msdosfs/fat.h,v 1.3 2003/08/20 09:56:32 rob Exp $ */ +/* $FreeBSD$ */ /* $NetBSD: fat.h,v 1.12 1997/11/17 15:36:36 ws Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1994, 1997 Wolfgang Solfrank. * Copyright (C) 1994, 1997 TooLs GmbH. * All rights reserved. @@ -33,7 +34,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote @@ -49,6 +50,8 @@ * October 1992 */ +#ifndef _FS_MSDOSFS_FAT_H_ +#define _FS_MSDOSFS_FAT_H_ /* * Some useful cluster numbers. */ @@ -67,16 +70,11 @@ /* * MSDOSFS: - * Return true if filesystem uses 12 bit fats. Microsoft Programmer's + * Return true if filesystem uses 12 bit FATs. Microsoft Programmer's * Reference says if the maximum cluster number in a filesystem is greater - * than 4078 ((CLUST_RSRVS - CLUST_FIRST) & FAT12_MASK) then we've got a - * 16 bit fat filesystem. While mounting, the result of this test is stored + * than 4084 ((CLUST_RSRVD - CLUST_FIRST) & FAT12_MASK) then we've got a + * 16 bit FAT filesystem. While mounting, the result of this test is stored * in pm_fatentrysize. - * GEMDOS-flavour (atari): - * If the filesystem is on floppy we've got a 12 bit fat filesystem, otherwise - * 16 bit. We check the d_type field in the disklabel struct while mounting - * and store the result in the pm_fatentrysize. Note that this kind of - * detection gets flakey when mounting a vnd-device. */ #define FAT12(pmp) (pmp->pm_fatmask == FAT12_MASK) #define FAT16(pmp) (pmp->pm_fatmask == FAT16_MASK) @@ -90,8 +88,8 @@ * These are the values for the function argument to the function * fatentry(). */ -#define FAT_GET 0x0001 /* get a fat entry */ -#define FAT_SET 0x0002 /* set a fat entry */ +#define FAT_GET 0x0001 /* get a FAT entry */ +#define FAT_SET 0x0002 /* set a FAT entry */ #define FAT_GET_AND_SET (FAT_GET | FAT_SET) /* @@ -112,3 +110,4 @@ int extendfile(struct denode *dep, u_long count, struct buf **bpp, u_long *ncp, void fc_purge(struct denode *dep, u_int frcn); #endif /* _KERNEL */ +#endif /* !_FS_MSDOSFS_FAT_H_ */ diff --git a/sys/vfs/msdosfs/msdosfs_conv.c b/sys/vfs/msdosfs/msdosfs_conv.c index 81af9a6f3c..db607f4e73 100644 --- a/sys/vfs/msdosfs/msdosfs_conv.c +++ b/sys/vfs/msdosfs/msdosfs_conv.c @@ -1,7 +1,9 @@ -/* $FreeBSD: src/sys/msdosfs/msdosfs_conv.c,v 1.29.2.1 2002/11/08 22:01:22 semenu Exp $ */ +/* $FreeBSD$ */ /* $NetBSD: msdosfs_conv.c,v 1.25 1997/11/17 15:36:40 ws Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1995, 1997 Wolfgang Solfrank. * Copyright (C) 1995, 1997 TooLs GmbH. * All rights reserved. @@ -32,7 +34,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote @@ -48,20 +50,15 @@ * October 1992 */ -/* - * System include files. - */ #include #include #include /* defines tz */ #include -#include #include #include +#include #include -/* - * MSDOSFS include files. - */ + #include "bpb.h" #include "msdosfsmount.h" #include "direntry.h" @@ -304,8 +301,9 @@ dos2unixtime(u_int dd, u_int dt, u_int dh, struct timespec *tsp) * 2 - character ('.' and ' ') should be skipped in DOS file name, * and generation number inserted. */ -static u_char +static const u_char unix2dos[256] = { +/* iso8859-1 -> cp850 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 00-07 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 08-0f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 10-17 */ @@ -340,8 +338,9 @@ unix2dos[256] = { 0x9d, 0xeb, 0xe9, 0xea, 0x9a, 0xed, 0xe8, 0x98, /* f8-ff */ }; -static u_char +static const u_char dos2unix[256] = { +/* cp850 -> iso8859-1 */ 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, /* 00-07 */ 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, /* 08-0f */ 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, /* 10-17 */ @@ -376,8 +375,9 @@ dos2unix[256] = { 0xb0, 0xa8, 0xb7, 0xb9, 0xb3, 0xb2, 0x3f, 0x3f, /* f8-ff */ }; -static u_char +static const u_char u2l[256] = { +/* tolower */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 00-07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 08-0f */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 10-17 */ @@ -412,8 +412,9 @@ u2l[256] = { 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* f8-ff */ }; -static u_char +static const u_char l2u[256] = { +/* toupper */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 00-07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 08-0f */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 10-17 */ @@ -519,6 +520,7 @@ dos2unixfn(u_char dn[11], u_char *un, int lower, struct msdosfsmount *pmp) */ if (*dn == SLOT_E5) *dn = 0xe5; + /* * Copy the name portion into the unix filename string. */ @@ -538,7 +540,7 @@ dos2unixfn(u_char dn[11], u_char *un, int lower, struct msdosfsmount *pmp) * Now, if there is an extension then put in a period and copy in * the extension. */ - if (*dn != ' ') { + if (*dn != ' ') { *un++ = '.'; thislong++; for (i = 3; i > 0 && *dn != ' ';) { @@ -662,7 +664,6 @@ unix2doschr(const u_char **instr, size_t *ilen, struct msdosfsmount *pmp) * 2 if conversion was successful * 3 if conversion was successful and generation number was inserted */ - int unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen, struct msdosfsmount *pmp) @@ -681,6 +682,7 @@ unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen, for (i = 0; i < 11; i++) dn[i] = ' '; dn[11] = 0; + /* * The filenames "." and ".." are handled specially, since they * don't follow dos filename rules. @@ -694,6 +696,7 @@ unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen, dn[1] = '.'; return gen <= 1; } + /* * Filenames with only blanks and dots are not allowed! */ @@ -702,20 +705,22 @@ unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen, break; if (i < 0) return 0; + /* * Filenames with some characters are not allowed! */ for (cp = un, i = unlen; i > 0;) if (unix2doschr(&cp, (size_t *)&i, pmp) == 0) return 0; + /* * Now find the extension * Note: dot as first char doesn't start extension - * and trailing dots and blanks are ignored + * and trailing dots and blanks are ignored * Note(2003/7): It seems recent Windows has - * defferent rule than this code, that Windows - * ignores all dots before extension, and use all - * chars as filename except for dots. + * defferent rule than this code, that Windows + * ignores all dots before extension, and use all + * chars as filename except for dots. */ dp = dp1 = NULL; for (cp = un + 1, i = unlen - 1; --i >= 0;) { @@ -733,6 +738,7 @@ unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen, break; } } + /* * Now convert it (this part is for extension). * As Windows XP do, if it's not ascii char, @@ -778,6 +784,7 @@ unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen, for (dp = cp; *--dp == ' ' || *dp == '.';); dp++; } + /* * Now convert the rest of the name */ @@ -817,6 +824,7 @@ unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen, */ if (!j) dn[0] = '_'; + /* * If there wasn't any char dropped, * there is no place for generation numbers @@ -826,6 +834,7 @@ unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen, conv = 0; goto done; } + /* * Now insert the generation number into the filename part */ @@ -850,12 +859,14 @@ unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen, dn[i++] = '~'; while (wcp < gentext + sizeof(gentext)) dn[i++] = *wcp++; + /* * Tail of the filename should be space */ while (i < 8) dn[i++] = ' '; conv = 3; + done: /* * The first character cannot be E5, @@ -863,6 +874,7 @@ done: */ if (dn[0] == 0xe5) dn[0] = SLOT_E5; + return conv; } @@ -944,24 +956,21 @@ unix2winfn(const u_char *un, size_t unlen, struct winentry *wep, int cnt, * Now convert the filename parts */ end = 0; - for (wcp = wep->wePart1, i = sizeof(wep->wePart1)/2; --i >= 0 && !end;) - { + for (wcp = wep->wePart1, i = sizeof(wep->wePart1)/2; --i >= 0 && !end;) { code = unix2winchr(&un, &unlen, 0, pmp); *wcp++ = code; *wcp++ = code >> 8; if (!code) end = WIN_LAST; } - for (wcp = wep->wePart2, i = sizeof(wep->wePart2)/2; --i >= 0 && !end;) - { + for (wcp = wep->wePart2, i = sizeof(wep->wePart2)/2; --i >= 0 && !end;) { code = unix2winchr(&un, &unlen, 0, pmp); *wcp++ = code; *wcp++ = code >> 8; if (!code) end = WIN_LAST; } - for (wcp = wep->wePart3, i = sizeof(wep->wePart3)/2; --i >= 0 && !end;) - { + for (wcp = wep->wePart3, i = sizeof(wep->wePart3)/2; --i >= 0 && !end;) { code = unix2winchr(&un, &unlen, 0, pmp); *wcp++ = code; *wcp++ = code >> 8; @@ -1013,6 +1022,7 @@ winChkName(struct mbnambuf *nbp, const u_char *un, size_t unlen, int chksum, len = d_namlen; if (unlen != len) return -2; + for (np = d_name; unlen > 0 && len > 0;) { /* * Comparison must be case insensitive, because FAT disallows @@ -1083,6 +1093,7 @@ win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum, if ((wep->weCnt&WIN_CNT) > howmany(WIN_MAXLEN, WIN_CHARS) || !(wep->weCnt&WIN_CNT)) return -1; + /* * First compare checksums */ @@ -1092,6 +1103,7 @@ win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum, chksum = -1; if (chksum == -1) return -1; + /* * Convert the name parts */ @@ -1159,7 +1171,7 @@ win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum, } /* - * Compute the checksum of a DOS filename for Win95 use + * Compute the unrolled checksum of a DOS filename for Win95 LFN use. */ uint8_t winChksum(uint8_t *name) @@ -1169,7 +1181,7 @@ winChksum(uint8_t *name) for (s = 0, i = 11; --i >= 0; s += *name++) s = (s << 7)|(s >> 1); - return s; + return (s); } /* @@ -1182,6 +1194,7 @@ winSlotCnt(const u_char *un, size_t unlen, struct msdosfsmount *pmp) char wn[WIN_MAXLEN * 2 + 1], *wnp; unlen = winLenFixup(un, unlen); + if (pmp->pm_flags & MSDOSFSMNT_KICONV && msdos_iconv) { wlen = WIN_MAXLEN * 2; wnp = wn; @@ -1191,13 +1204,14 @@ winSlotCnt(const u_char *un, size_t unlen, struct msdosfsmount *pmp) return 0; return howmany(WIN_MAXLEN - wlen/2, WIN_CHARS); } + if (unlen > WIN_MAXLEN) return 0; return howmany(unlen, WIN_CHARS); } /* - * Determine the number of bytes neccesary for Win95 names + * Determine the number of bytes necessary for Win95 names */ size_t winLenFixup(const u_char *un, size_t unlen) diff --git a/sys/vfs/msdosfs/msdosfs_denode.c b/sys/vfs/msdosfs/msdosfs_denode.c index 65692e5917..0616eb17cb 100644 --- a/sys/vfs/msdosfs/msdosfs_denode.c +++ b/sys/vfs/msdosfs/msdosfs_denode.c @@ -1,7 +1,9 @@ -/* $FreeBSD: src/sys/msdosfs/msdosfs_denode.c,v 1.47.2.3 2002/08/22 16:20:15 trhodes Exp $ */ +/* $FreeBSD$ */ /* $NetBSD: msdosfs_denode.c,v 1.28 1998/02/10 14:10:00 mrg Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. * Copyright (C) 1994, 1995, 1997 TooLs GmbH. * All rights reserved. @@ -32,7 +34,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote @@ -50,11 +52,11 @@ #include #include +#include #include -#include #include #include -#include +#include #include #include diff --git a/sys/vfs/msdosfs/msdosfs_fat.c b/sys/vfs/msdosfs/msdosfs_fat.c index 22b29eda2f..194bcbbfa6 100644 --- a/sys/vfs/msdosfs/msdosfs_fat.c +++ b/sys/vfs/msdosfs/msdosfs_fat.c @@ -1,7 +1,9 @@ -/* $FreeBSD: src/sys/msdosfs/msdosfs_fat.c,v 1.23 2000/01/27 14:43:06 nyan Exp $ */ +/* $FreeBSD$ */ /* $NetBSD: msdosfs_fat.c,v 1.28 1997/11/17 15:36:49 ws Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. * Copyright (C) 1994, 1995, 1997 TooLs GmbH. * All rights reserved. @@ -32,7 +34,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote @@ -48,9 +50,6 @@ * October 1992 */ -/* - * kernel include files. - */ #include #include #include @@ -59,9 +58,6 @@ #include -/* - * msdosfs include files. - */ #include "bpb.h" #include "msdosfsmount.h" #include "direntry.h" @@ -90,7 +86,7 @@ static void fc_lookup(struct denode *dep, u_long findcn, u_long *frcnp, */ static void fatblock(struct msdosfsmount *pmp, u_long ofs, u_long *bnp, u_long *sizep, - u_long *bop) + u_long *bop) { u_long bn, size; @@ -113,10 +109,11 @@ fatblock(struct msdosfsmount *pmp, u_long ofs, u_long *bnp, u_long *sizep, * dep - address of denode representing the file of interest * findcn - file relative cluster whose filesystem relative cluster number * and/or block number are/is to be found - * bnp - address of where to place the file system relative block number. + * bnp - address of where to place the filesystem relative block number. * If this pointer is null then don't return this quantity. - * cnp - address of where to place the file system relative cluster number. + * cnp - address of where to place the filesystem relative cluster number. * If this pointer is null then don't return this quantity. + * sp - pointer to returned block size * * NOTE: Either bnp or cnp must be non-null. * This function has one side effect. If the requested file relative cluster @@ -190,8 +187,8 @@ pcbmap(struct denode *dep, *sp = pmp->pm_bpcluster; /* - * Rummage around in the fat cache, maybe we can avoid tromping - * thru every fat entry for the file. And, keep track of how far + * Rummage around in the FAT cache, maybe we can avoid tromping + * through every FAT entry for the file. And, keep track of how far * off the cache was from where we wanted to be. */ i = 0; @@ -225,9 +222,9 @@ pcbmap(struct denode *dep, } prevcn = cn; if (FAT32(pmp)) - cn = getulong(&bp->b_data[bo]); + cn = getulong(bp->b_data + bo); else - cn = getushort(&bp->b_data[bo]); + cn = getushort(bp->b_data + bo); if (FAT12(pmp) && (prevcn & 1)) cn >>= 4; cn &= pmp->pm_fatmask; @@ -258,13 +255,13 @@ hiteof: *cnp = i; if (bp) brelse(bp); - /* update last file cluster entry in the fat cache */ + /* update last file cluster entry in the FAT cache */ fc_setcache(dep, FC_LASTFC, i - 1, prevcn); return (E2BIG); } /* - * Find the closest entry in the fat cache to the cluster we are looking + * Find the closest entry in the FAT cache to the cluster we are looking * for. */ static void @@ -288,7 +285,7 @@ fc_lookup(struct denode *dep, u_long findcn, u_long *frcnp, u_long *fsrcnp) } /* - * Purge the fat cache in denode dep of all entries relating to file + * Purge the FAT cache in denode dep of all entries relating to file * relative cluster frcn and beyond. */ void @@ -305,13 +302,13 @@ fc_purge(struct denode *dep, u_int frcn) } /* - * Update the fat. - * If mirroring the fat, update all copies, with the first copy as last. - * Else update only the current fat (ignoring the others). + * Update the FAT. + * If mirroring the FAT, update all copies, with the first copy as last. + * Else update only the current FAT (ignoring the others). * * pmp - msdosfsmount structure for filesystem to update - * bp - addr of modified fat block - * fatbn - block number relative to begin of filesystem of the modified fat block. + * bp - addr of modified FAT block + * fatbn - block number relative to begin of filesystem of the modified FAT block. */ static void updatefats(struct msdosfsmount *pmp, struct buf *bp, u_long fatbn) @@ -362,12 +359,12 @@ updatefats(struct msdosfsmount *pmp, struct buf *bp, u_long fatbn) if (pmp->pm_flags & MSDOSFS_FATMIRROR) { /* - * Now copy the block(s) of the modified fat to the other copies of - * the fat and write them out. This is faster than reading in the - * other fats and then writing them back out. This could tie up - * the fat for quite a while. Preventing others from accessing it. - * To prevent us from going after the fat quite so much we use - * delayed writes, unless they specfied "synchronous" when the + * Now copy the block(s) of the modified FAT to the other copies of + * the FAT and write them out. This is faster than reading in the + * other FATs and then writing them back out. This could tie up + * the FAT for quite a while. Preventing others from accessing it. + * To prevent us from going after the FAT quite so much we use + * delayed writes, unless they specified "synchronous" when the * filesystem was mounted. If synch is asked for then use * bwrite()'s and really slow things down. */ @@ -385,19 +382,16 @@ updatefats(struct msdosfsmount *pmp, struct buf *bp, u_long fatbn) } /* - * Write out the first (or current) fat last. + * Write out the first (or current) FAT last. */ if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT) bwrite(bp); else bdwrite(bp); - /* - * Maybe update fsinfo sector here? - */ } /* - * Updating entries in 12 bit fats is a pain in the butt. + * Updating entries in 12 bit FATs is a pain in the butt. * * The following picture shows where nibbles go when moving from a 12 bit * cluster number into the appropriate bytes in the FAT. @@ -452,27 +446,27 @@ clusterfree(struct msdosfsmount *pmp, u_long cluster, u_long *oldcnp) } /* - * Get or Set or 'Get and Set' the cluster'th entry in the fat. + * Get or Set or 'Get and Set' the cluster'th entry in the FAT. * - * function - whether to get or set a fat entry + * function - whether to get or set a FAT entry * pmp - address of the msdosfsmount structure for the filesystem - * whose fat is to be manipulated. + * whose FAT is to be manipulated. * cn - which cluster is of interest * oldcontents - address of a word that is to receive the contents of the * cluster'th entry if this is a get function * newcontents - the new value to be written into the cluster'th element of - * the fat if this is a set function. + * the FAT if this is a set function. * - * This function can also be used to free a cluster by setting the fat entry + * This function can also be used to free a cluster by setting the FAT entry * for a cluster to 0. * - * All copies of the fat are updated if this is a set function. NOTE: If + * All copies of the FAT are updated if this is a set function. NOTE: If * fatentry() marks a cluster as free it does not update the inusemap in * the msdosfsmount structure. This is left to the caller. */ int fatentry(int function, struct msdosfsmount *pmp, u_long cn, u_long *oldcontents, - u_long newcontents) + u_long newcontents) { int error; u_long readcn; @@ -517,13 +511,13 @@ fatentry(int function, struct msdosfsmount *pmp, u_long cn, u_long *oldcontents, if (function & FAT_GET) { if (FAT32(pmp)) - readcn = getulong(&bp->b_data[bo]); + readcn = getulong(bp->b_data + bo); else - readcn = getushort(&bp->b_data[bo]); + readcn = getushort(bp->b_data + bo); if (FAT12(pmp) & (cn & 1)) readcn >>= 4; readcn &= pmp->pm_fatmask; - /* map reserved fat entries to same values for all fats */ + /* map reserved FAT entries to same values for all FATs */ if ((readcn | ~pmp->pm_fatmask) >= CLUST_RSRVD) readcn |= ~pmp->pm_fatmask; *oldcontents = readcn; @@ -531,7 +525,7 @@ fatentry(int function, struct msdosfsmount *pmp, u_long cn, u_long *oldcontents, if (function & FAT_SET) { switch (pmp->pm_fatmask) { case FAT12_MASK: - readcn = getushort(&bp->b_data[bo]); + readcn = getushort(bp->b_data + bo); if (cn & 1) { readcn &= 0x000f; readcn |= newcontents << 4; @@ -539,20 +533,20 @@ fatentry(int function, struct msdosfsmount *pmp, u_long cn, u_long *oldcontents, readcn &= 0xf000; readcn |= newcontents & 0xfff; } - putushort(&bp->b_data[bo], readcn); + putushort(bp->b_data + bo, readcn); break; case FAT16_MASK: - putushort(&bp->b_data[bo], newcontents); + putushort(bp->b_data + bo, newcontents); break; case FAT32_MASK: /* * According to spec we have to retain the - * high order bits of the fat entry. + * high order bits of the FAT entry. */ - readcn = getulong(&bp->b_data[bo]); + readcn = getulong(bp->b_data + bo); readcn &= ~FAT32_MASK; readcn |= newcontents & FAT32_MASK; - putulong(&bp->b_data[bo], readcn); + putulong(bp->b_data + bo, readcn); break; } updatefats(pmp, bp, bn); @@ -570,7 +564,7 @@ fatentry(int function, struct msdosfsmount *pmp, u_long cn, u_long *oldcontents, * pmp - mount point * start - first cluster of chain * count - number of clusters in chain - * fillwith - what to write into fat entry of last cluster + * fillwith - what to write into FAT entry of last cluster */ static int fatchain(struct msdosfsmount *pmp, u_long start, u_long count, u_long fillwith) @@ -601,7 +595,7 @@ fatchain(struct msdosfsmount *pmp, u_long start, u_long count, u_long fillwith) newc = --count > 0 ? start : fillwith; switch (pmp->pm_fatmask) { case FAT12_MASK: - readcn = getushort(&bp->b_data[bo]); + readcn = getushort(bp->b_data + bo); if (start & 1) { readcn &= 0xf000; readcn |= newc & 0xfff; @@ -609,20 +603,20 @@ fatchain(struct msdosfsmount *pmp, u_long start, u_long count, u_long fillwith) readcn &= 0x000f; readcn |= newc << 4; } - putushort(&bp->b_data[bo], readcn); + putushort(bp->b_data + bo, readcn); bo++; if (!(start & 1)) bo++; break; case FAT16_MASK: - putushort(&bp->b_data[bo], newc); + putushort(bp->b_data + bo, newc); bo += 2; break; case FAT32_MASK: - readcn = getulong(&bp->b_data[bo]); + readcn = getulong(bp->b_data + bo); readcn &= ~pmp->pm_fatmask; readcn |= newc & pmp->pm_fatmask; - putulong(&bp->b_data[bo], readcn); + putulong(bp->b_data + bo, readcn); bo += 4; break; } @@ -666,7 +660,7 @@ chainlength(struct msdosfsmount *pmp, u_long start, u_long count) break; map = pmp->pm_inusemap[idx]; if (map) { - len += ffs(map) - 1; + len += ffs(map) - 1; break; } len += N_INUSEBITS; @@ -680,14 +674,14 @@ chainlength(struct msdosfsmount *pmp, u_long start, u_long count) * pmp - mount point. * start - start of cluster chain. * count - number of clusters to allocate. - * fillwith - put this value into the fat entry for the + * fillwith - put this value into the FAT entry for the * last allocated cluster. * retcluster - put the first allocated cluster's number here. * got - how many clusters were actually allocated. */ static int chainalloc(struct msdosfsmount *pmp, u_long start, u_long count, - u_long fillwith, u_long *retcluster, u_long *got) + u_long fillwith, u_long *retcluster, u_long *got) { int error; u_long cl, n; @@ -713,14 +707,14 @@ chainalloc(struct msdosfsmount *pmp, u_long start, u_long count, * pmp - mount point. * start - preferred start of cluster chain. * count - number of clusters requested. - * fillwith - put this value into the fat entry for the + * fillwith - put this value into the FAT entry for the * last allocated cluster. * retcluster - put the first allocated cluster's number here. * got - how many clusters were actually allocated. */ int clusteralloc(struct msdosfsmount *pmp, u_long start, u_long count, - u_long fillwith, u_long *retcluster, u_long *got) + u_long fillwith, u_long *retcluster, u_long *got) { u_long idx; u_long len, newst, foundl, cn, l; @@ -823,7 +817,7 @@ freeclusterchain(struct msdosfsmount *pmp, u_long cluster) usemap_free(pmp, cluster); switch (pmp->pm_fatmask) { case FAT12_MASK: - readcn = getushort(&bp->b_data[bo]); + readcn = getushort(bp->b_data + bo); if (cluster & 1) { cluster = readcn >> 4; readcn &= 0x000f; @@ -833,15 +827,15 @@ freeclusterchain(struct msdosfsmount *pmp, u_long cluster) readcn &= 0xf000; readcn |= MSDOSFSFREE & 0xfff; } - putushort(&bp->b_data[bo], readcn); + putushort(bp->b_data + bo, readcn); break; case FAT16_MASK: - cluster = getushort(&bp->b_data[bo]); - putushort(&bp->b_data[bo], MSDOSFSFREE); + cluster = getushort(bp->b_data + bo); + putushort(bp->b_data + bo, MSDOSFSFREE); break; case FAT32_MASK: - cluster = getulong(&bp->b_data[bo]); - putulong(&bp->b_data[bo], + cluster = getulong(bp->b_data + bo); + putulong(bp->b_data + bo, (MSDOSFSFREE & FAT32_MASK) | (cluster & ~FAT32_MASK)); break; @@ -856,7 +850,7 @@ freeclusterchain(struct msdosfsmount *pmp, u_long cluster) } /* - * Read in fat blocks looking for free clusters. For every free cluster + * Read in FAT blocks looking for free clusters. For every free cluster * found turn off its corresponding bit in the pm_inusemap. */ int @@ -868,7 +862,7 @@ fillinusemap(struct msdosfsmount *pmp) u_long bn, bo, bsize, byteoffset; /* - * Mark all clusters in use, we mark the free ones in the fat scan + * Mark all clusters in use, we mark the free ones in the FAT scan * loop further down. */ for (cn = 0; cn < (pmp->pm_maxcluster + N_INUSEBITS) / N_INUSEBITS; cn++) @@ -876,7 +870,7 @@ fillinusemap(struct msdosfsmount *pmp) /* * Figure how many free clusters are in the filesystem by ripping - * through the fat counting the number of entries whose content is + * through the FAT counting the number of entries whose content is * zero. These represent free clusters. */ pmp->pm_freeclustercount = 0; @@ -896,9 +890,9 @@ fillinusemap(struct msdosfsmount *pmp) } } if (FAT32(pmp)) - readcn = getulong(&bp->b_data[bo]); + readcn = getulong(bp->b_data + bo); else - readcn = getushort(&bp->b_data[bo]); + readcn = getushort(bp->b_data + bo); if (FAT12(pmp) && (cn & 1)) readcn >>= 4; readcn &= pmp->pm_fatmask; @@ -927,7 +921,7 @@ fillinusemap(struct msdosfsmount *pmp) */ int extendfile(struct denode *dep, u_long count, struct buf **bpp, u_long *ncp, - int flags) + int flags) { int error; u_long frcn; @@ -961,7 +955,7 @@ extendfile(struct denode *dep, u_long count, struct buf **bpp, u_long *ncp, while (count > 0) { /* * Allocate a new cluster chain and cat onto the end of the - * file. * If the file is empty we make de_StartCluster point + * file. If the file is empty we make de_StartCluster point * to the new block. Note that de_StartCluster being 0 is * sufficient to be sure the file is empty since we exclude * attempts to extend the root directory above, and the root @@ -1003,7 +997,7 @@ extendfile(struct denode *dep, u_long count, struct buf **bpp, u_long *ncp, /* * Update the "last cluster of the file" entry in the - * denode's fat cache. + * denode's FAT cache. */ fc_setcache(dep, FC_LASTFC, frcn + got - 1, cn + got - 1); @@ -1042,8 +1036,9 @@ extendfile(struct denode *dep, u_long count, struct buf **bpp, u_long *ncp, if (bpp) { *bpp = bp; bpp = NULL; - } else + } else { bdwrite(bp); + } } } } diff --git a/sys/vfs/msdosfs/msdosfs_lookup.c b/sys/vfs/msdosfs/msdosfs_lookup.c index b00268e0d9..374c91f8bb 100644 --- a/sys/vfs/msdosfs/msdosfs_lookup.c +++ b/sys/vfs/msdosfs/msdosfs_lookup.c @@ -1,7 +1,9 @@ -/* $FreeBSD: src/sys/msdosfs/msdosfs_lookup.c,v 1.30.2.1 2000/11/03 15:55:39 bp Exp $ */ +/* $FreeBSD$ */ /* $NetBSD: msdosfs_lookup.c,v 1.37 1997/11/17 15:36:54 ws Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. * Copyright (C) 1994, 1995, 1997 TooLs GmbH. * All rights reserved. @@ -32,7 +34,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote @@ -51,10 +53,10 @@ #include #include #include -#include #include -#include #include +#include +#include #include @@ -81,9 +83,6 @@ * Then update the disk block and the denode, and then write the disk block * out to disk. This way disk blocks containing directory entries and in * memory denode's will be in synch. - * - * msdosfs_lookup(struct vnode *a_dvp, struct vnode **a_vpp, - * struct componentname *a_cnp) */ int msdosfs_lookup(struct vop_old_lookup_args *ap) @@ -145,6 +144,7 @@ msdosfs_lookup(struct vop_old_lookup_args *ap) blkoff = MSDOSFSROOT_OFS; goto foundroot; } + switch (unix2dosfn((const u_char *)cnp->cn_nameptr, dosfilename, cnp->cn_namelen, 0, pmp)) { case 0: @@ -250,18 +250,18 @@ msdosfs_lookup(struct vop_old_lookup_args *ap) MSDOSFSMNT_SHORTNAME) continue; chksum = win2unixfn(&nb, - (struct winentry *)dep, chksum, - pmp); + (struct winentry *)dep, chksum, + pmp); continue; } - chksum = winChkName(&nb, - (const u_char *)cnp->cn_nameptr, unlen, - chksum, pmp); + chksum = winChkName(&nb, + (const u_char *)cnp->cn_nameptr, unlen, + chksum, pmp); if (chksum == -2) { - chksum = -1; - continue; - } + chksum = -1; + continue; + } /* * Ignore volume labels (anywhere, not just @@ -542,7 +542,7 @@ foundroot: */ int createde(struct denode *dep, struct denode *ddep, struct denode **depp, - struct componentname *cnp) + struct componentname *cnp) { int error; u_long dirclust, diroffset; @@ -763,7 +763,7 @@ doscheckpath(struct denode *source, struct denode *target) if (dep->de_StartCluster == MSDOSFSROOT) goto out; pmp = dep->de_pmp; -#ifdef DIAGNOSTIC +#ifdef DIAGNOSTIC if (pmp != source->de_pmp) panic("doscheckpath: source and target on different filesystems"); #endif @@ -829,7 +829,7 @@ out: */ int readep(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, - struct buf **bpp, struct direntry **epp) + struct buf **bpp, struct direntry **epp) { int error; daddr_t bn; @@ -865,15 +865,17 @@ readde(struct denode *dep, struct buf **bpp, struct direntry **epp) /* * Remove a directory entry. At this point the file represented by the - * directory entry to be removed is still full length until noone has it + * directory entry to be removed is still full length until no one has it * open. When the file no longer being used msdosfs_inactive() is called * and will truncate the file to 0 length. When the vnode containing the * denode is needed for some other purpose by VFS it will call * msdosfs_reclaim() which will remove the denode from the denode cache. + * + * pdep directory where the entry is removed + * dep file to be removed */ int -removede(struct denode *pdep, /* directory where the entry is removed */ - struct denode *dep) /* file to be removed */ +removede(struct denode *pdep, struct denode *dep) { int error; struct direntry *ep; diff --git a/sys/vfs/msdosfs/msdosfs_vfsops.c b/sys/vfs/msdosfs/msdosfs_vfsops.c index 75322374f4..07edb553c5 100644 --- a/sys/vfs/msdosfs/msdosfs_vfsops.c +++ b/sys/vfs/msdosfs/msdosfs_vfsops.c @@ -1,7 +1,9 @@ -/* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/msdosfs/Attic/msdosfs_vfsops.c,v 1.60.2.8 2004/03/02 09:43:04 tjr Exp $ */ +/* $FreeBSD$ */ /* $NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. * Copyright (C) 1994, 1995, 1997 TooLs GmbH. * All rights reserved. @@ -32,7 +34,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote @@ -237,7 +239,7 @@ msdosfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) } /* * Not an update, or updating the name: look up the name - * and verify that it refers to a sensible block device. + * and verify that it refers to a sensible disk device. */ devvp = NULL; error = nlookup_init(&nd, args.fspec, UIO_USERSPACE, NLC_FOLLOW); @@ -354,7 +356,7 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp, struct msdosfs_args *argp) bsp = (union bootsector *)bp->b_data; b33 = (struct byte_bpb33 *)bsp->bs33.bsBPB; b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB; - b710 = (struct byte_bpb710 *)bsp->bs710.bsPBP; + b710 = (struct byte_bpb710 *)bsp->bs710.bsBPB; #ifndef MSDOSFS_NOCHECKSIG if (bsp->bs50.bsBootSectSig0 != BOOTSIG0 @@ -447,7 +449,7 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp, struct msdosfs_args *argp) } pmp->pm_HugeSectors *= pmp->pm_BlkPerSec; - pmp->pm_HiddenSects *= pmp->pm_BlkPerSec; /* XXX not used? */ + pmp->pm_HiddenSects *= pmp->pm_BlkPerSec; /* XXX not used? */ pmp->pm_FATsecs *= pmp->pm_BlkPerSec; SecPerClust *= pmp->pm_BlkPerSec; @@ -475,7 +477,7 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp, struct msdosfs_args *argp) <= ((CLUST_RSRVD - CLUST_FIRST) & FAT12_MASK)) { /* * This will usually be a floppy disk. This size makes - * sure that one fat entry will not be split across + * sure that one FAT entry will not be split across * multiple blocks. */ pmp->pm_fatmask = FAT12_MASK; @@ -580,8 +582,8 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp, struct msdosfs_args *argp) /* * fillinusemap() needs pm_devvp. */ - pmp->pm_dev = dev; pmp->pm_devvp = devvp; + pmp->pm_dev = dev; /* * Have the inuse map filled in. @@ -590,9 +592,9 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp, struct msdosfs_args *argp) goto error_exit; /* - * If they want fat updates to be synchronous then let them suffer + * If they want FAT updates to be synchronous then let them suffer * the performance degradation in exchange for the on disk copy of - * the fat being correct just about all the time. I suppose this + * the FAT being correct just about all the time. I suppose this * would be a good thing to turn on if the kernel is still flakey. */ if (mp->mnt_flag & MNT_SYNCHRONOUS) @@ -612,7 +614,7 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp, struct msdosfs_args *argp) vfs_add_vnodeops(mp, &msdosfs_vnode_vops, &mp->mnt_vn_norm_ops); dev->si_mountpoint = mp; - return 0; + return (0); error_exit: if (bp) { @@ -717,7 +719,7 @@ msdosfs_statfs(struct mount *mp, struct statfs *sbp, struct ucred *cred) sbp->f_blocks = pmp->pm_maxcluster + 1; sbp->f_bfree = pmp->pm_freeclustercount; sbp->f_bavail = pmp->pm_freeclustercount; - sbp->f_files = pmp->pm_RootDirEnts; /* XXX */ + sbp->f_files = pmp->pm_RootDirEnts; /* XXX */ sbp->f_ffree = 0; /* what to put in here? */ if (sbp != &mp->mnt_stat) { sbp->f_type = mp->mnt_vfc->vfc_typenum; @@ -743,14 +745,14 @@ msdosfs_sync(struct mount *mp, int waitfor) int error; /* - * If we ever switch to not updating all of the fats all the time, + * If we ever switch to not updating all of the FATs all the time, * this would be the place to update them from the first one. */ if (pmp->pm_fmod != 0) { if (pmp->pm_flags & MSDOSFSMNT_RONLY) { panic("msdosfs_sync: rofs mod"); } else { - /* update fats here */ + /* update FATs here */ } } /* diff --git a/sys/vfs/msdosfs/msdosfs_vnops.c b/sys/vfs/msdosfs/msdosfs_vnops.c index 09190c1a42..9b1e2b60b3 100644 --- a/sys/vfs/msdosfs/msdosfs_vnops.c +++ b/sys/vfs/msdosfs/msdosfs_vnops.c @@ -1,7 +1,9 @@ -/* $FreeBSD: src/sys/msdosfs/msdosfs_vnops.c,v 1.95.2.4 2003/06/13 15:05:47 trhodes Exp $ */ +/* $FreeBSD$ */ /* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. * Copyright (C) 1994, 1995, 1997 TooLs GmbH. * All rights reserved. @@ -32,7 +34,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote @@ -95,16 +97,15 @@ * that when a directory is actually read/written (via read, write, or * readdir, or seek) we must use the vnode for the filesystem instead of * the vnode for the directory as would happen in ufs. This is to insure we - * retreive the correct block from the buffer cache since the hash value is + * retrieve the correct block from the buffer cache since the hash value is * based upon the vnode address and the desired block number. */ /* * Create a regular file. On entry the directory to contain the file being - * created is locked. We must release before we return. - * - * msdosfs_create(struct vnode *a_dvp, struct vnode **a_vpp, - * struct componentname *a_cnp, struct vattr *a_vap) + * created is locked. We must release before we return. We must also free + * the pathname buffer pointed at by cnp->cn_pnbuf, always on error, or + * only if the SAVESTART bit in cn_flags is clear on success. */ static int msdosfs_create(struct vop_old_create_args *ap) @@ -163,10 +164,6 @@ bad: static int msdosfs_mkdir(struct vop_old_mkdir_args *); -/* - * msdosfs_mknod(struct vnode *a_dvp, struct vnode **a_vpp, - * struct componentname *a_cnp, struct vattr *a_vap) - */ static int msdosfs_mknod(struct vop_old_mknod_args *ap) { @@ -181,19 +178,12 @@ msdosfs_mknod(struct vop_old_mknod_args *ap) /* NOTREACHED */ } -/* - * msdosfs_open(struct vnode *a_vp, int a_mode, struct ucred *a_cred, - * struct file *a_fp) - */ static int msdosfs_open(struct vop_open_args *ap) { return(vop_stdopen(ap)); } -/* - * msdosfs_close(struct vnode *a_vp, int a_fflag) - */ static int msdosfs_close(struct vop_close_args *ap) { @@ -208,9 +198,6 @@ msdosfs_close(struct vop_close_args *ap) return (vop_stdclose(ap)); } -/* - * msdosfs_access(struct vnode *a_vp, int a_mode, struct ucred *a_cred) - */ static int msdosfs_access(struct vop_access_args *ap) { @@ -226,9 +213,6 @@ msdosfs_access(struct vop_access_args *ap) return (vop_helper_access(ap, pmp->pm_uid, pmp->pm_gid, file_mode, 0)); } -/* - * msdosfs_getattr(struct vnode *a_vp, struct vattr *a_vap) - */ static int msdosfs_getattr(struct vop_getattr_args *ap) { @@ -291,10 +275,6 @@ msdosfs_getattr(struct vop_getattr_args *ap) return (0); } -/* - * msdosfs_setattr(struct vnode *a_vp, struct vattr *a_vap, - * struct ucred *a_cred) - */ static int msdosfs_setattr(struct vop_setattr_args *ap) { @@ -445,10 +425,6 @@ msdosfs_setattr(struct vop_setattr_args *ap) return (deupdat(dep, 1)); } -/* - * msdosfs_read(struct vnode *a_vp, struct uio *a_uio, int a_ioflag, - * struct ucred *a_cred) - */ static int msdosfs_read(struct vop_read_args *ap) { @@ -552,9 +528,6 @@ msdosfs_read(struct vop_read_args *ap) /* * Write data to a file or directory. - * - * msdosfs_write(struct vnode *a_vp, struct uio *a_uio, int a_ioflag, - * struct ucred *a_cred) */ static int msdosfs_write(struct vop_write_args *ap) @@ -681,7 +654,7 @@ msdosfs_write(struct vop_write_args *ap) clrbuf(bp); /* * Do the bmap now, since pcbmap needs buffers - * for the fat table. (see msdosfs_strategy) + * for the FAT table. (see msdosfs_strategy) */ if (bp->b_bio2.bio_offset == NOOFFSET) { daddr_t lblkno = de_off2cn(pmp, bp->b_loffset); @@ -770,8 +743,6 @@ errexit: * * This function is worthless for vnodes that represent directories. Maybe we * could just do a sync if they try an fsync on a directory file. - * - * msdosfs_fsync(struct vnode *a_vp, int a_waitfor) */ static int msdosfs_fsync(struct vop_fsync_args *ap) @@ -794,10 +765,6 @@ loop: return (deupdat(VTODE(vp), ap->a_waitfor == MNT_WAIT)); } -/* - * msdosfs_remove(struct vnode *a_dvp, struct vnode *a_vp, - * struct componentname *a_cnp) - */ static int msdosfs_remove(struct vop_old_remove_args *ap) { @@ -818,9 +785,6 @@ msdosfs_remove(struct vop_old_remove_args *ap) * DOS filesystems don't know what links are. But since we already called * msdosfs_lookup() with create and lockparent, the parent is locked so we * have to free it before we return the error. - * - * msdosfs_link(struct vnode *a_tdvp, struct vnode *a_vp, - * struct componentname *a_cnp) */ static int msdosfs_link(struct vop_old_link_args *ap) @@ -878,10 +842,6 @@ msdosfs_link(struct vop_old_link_args *ap) * I'm not sure how the memory containing the pathnames pointed at by the * componentname structures is freed, there may be some memory bleeding * for each rename done. - * - * msdosfs_rename(struct vnode *a_fdvp, struct vnode *a_fvp, - * struct componentname *a_fcnp, struct vnode *a_tdvp, - * struct vnode *a_tvp, struct componentname *a_tcnp) */ static int msdosfs_rename(struct vop_old_rename_args *ap) @@ -983,7 +943,7 @@ abortit: /* * If ".." must be changed (ie the directory gets a new * parent) then the source directory must not be in the - * directory heirarchy above the target, as this would + * directory hierarchy above the target, as this would * orphan everything below the source directory. Also * the user must have write permission in the source so * as to be able to change "..". We must repeat the call @@ -1275,10 +1235,6 @@ static struct { } }; -/* - * msdosfs_mkdir(struct vnode *a_dvp, struct vnode **a_vpp, - * struct componentname *a_cnp, struct vattr *a_vap) - */ static int msdosfs_mkdir(struct vop_old_mkdir_args *ap) { @@ -1383,10 +1339,6 @@ bad2: return (error); } -/* - * msdosfs_rmdir(struct vnode *a_dvp, struct vnode *a_vp, - * struct componentname *a_cnp) - */ static int msdosfs_rmdir(struct vop_old_rmdir_args *ap) { @@ -1439,10 +1391,6 @@ out: /* * DOS filesystems don't know what symlinks are. - * - * msdosfs_symlink(struct vnode *a_dvp, struct vnode **a_vpp, - * struct componentname *a_cnp, struct vattr *a_vap, - * char *a_target) */ static int msdosfs_symlink(struct vop_old_symlink_args *ap) @@ -1450,11 +1398,6 @@ msdosfs_symlink(struct vop_old_symlink_args *ap) return (EOPNOTSUPP); } -/* - * msdosfs_readdir(struct vnode *a_vp, struct uio *a_uio, - * struct ucred *a_cred, int *a_eofflag, int *a_ncookies, - * off_t **a_cookies) - */ static int msdosfs_readdir(struct vop_readdir_args *ap) { @@ -1721,9 +1664,6 @@ done: * vpp - returns the vnode for the block special file holding the filesystem * containing the file of interest * bnp - address of where to return the filesystem relative block number - * - * msdosfs_bmap(struct vnode *a_vp, off_t a_loffset, - * off_t *a_doffsetp, int *a_runp, int *a_runb) */ static int msdosfs_bmap(struct vop_bmap_args *ap) @@ -1756,9 +1696,6 @@ msdosfs_bmap(struct vop_bmap_args *ap) return (error); } -/* - * msdosfs_strategy(struct vnode *a_vp, struct bio *a_bio) - */ static int msdosfs_strategy(struct vop_strategy_args *ap) { @@ -1810,9 +1747,6 @@ msdosfs_strategy(struct vop_strategy_args *ap) return (0); } -/* - * msdosfs_print(struct vnode *vp) - */ static int msdosfs_print(struct vop_print_args *ap) { @@ -1826,9 +1760,6 @@ msdosfs_print(struct vop_print_args *ap) return (0); } -/* - * msdosfs_pathconf(struct vnode *a_vp, int a_name, int *a_retval) - */ static int msdosfs_pathconf(struct vop_pathconf_args *ap) { diff --git a/sys/vfs/msdosfs/msdosfsmount.h b/sys/vfs/msdosfs/msdosfsmount.h index e892b13498..849cb87123 100644 --- a/sys/vfs/msdosfs/msdosfsmount.h +++ b/sys/vfs/msdosfs/msdosfsmount.h @@ -1,8 +1,9 @@ -/* $FreeBSD: src/sys/msdosfs/msdosfsmount.h,v 1.20.2.2 2000/10/27 09:45:07 bde Exp $ */ -/* $DragonFly: src/sys/vfs/msdosfs/msdosfsmount.h,v 1.9 2007/08/08 00:23:40 swildner Exp $ */ +/* $FreeBSD$ */ /* $NetBSD: msdosfsmount.h,v 1.17 1997/11/17 15:37:07 ws Exp $ */ /*- + * SPDX-License-Identifier: BSD-4-Clause + * * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. * Copyright (C) 1994, 1995, 1997 TooLs GmbH. * All rights reserved. @@ -33,7 +34,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote @@ -60,19 +61,21 @@ MALLOC_DECLARE(M_MSDOSFSMNT); #endif #include #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) + /* - * Layout of the mount control block for a msdos file system. + * Layout of the mount control block for a MSDOSFS filesystem. */ struct msdosfsmount { struct mount *pm_mountp;/* vfs mount struct for this fs */ - cdev_t pm_dev; /* block special device mounted */ uid_t pm_uid; /* uid to set as owner of the files */ gid_t pm_gid; /* gid to set as owner of the files */ - mode_t pm_mask; /* mask to and with file protection bits */ - struct vnode *pm_devvp; /* vnode for block device mntd */ + mode_t pm_mask; /* mask to and with file protection bits + for files */ + struct vnode *pm_devvp; /* vnode for character device mounted */ + cdev_t pm_dev; /* character device mounted */ struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */ u_long pm_BlkPerSec; /* How many DEV_BSIZE blocks fit inside a physical sector */ - u_long pm_FATsecs; /* actual number of fat sectors */ + u_long pm_FATsecs; /* actual number of FAT sectors */ u_long pm_fatblk; /* block # of first FAT */ u_long pm_rootdirblk; /* block # (cluster # for FAT32) of root directory number */ u_long pm_rootdirsize; /* size in blocks (not clusters) */ @@ -84,21 +87,21 @@ struct msdosfsmount { u_long pm_bnshift; /* shift file offset right this amount to get a block number */ u_long pm_bpcluster; /* bytes per cluster */ u_long pm_fmod; /* ~0 if fs is modified, this can rollover to 0 */ - u_long pm_fatblocksize; /* size of fat blocks in bytes */ - u_long pm_fatblocksec; /* size of fat blocks in sectors */ - uint32_t pm_fatmask; /* mask to use for fat numbers */ + u_long pm_fatblocksize; /* size of FAT blocks in bytes */ + u_long pm_fatblocksec; /* size of FAT blocks in sectors */ + uint32_t pm_fatmask; /* mask to use for FAT numbers */ u_long pm_fsinfo; /* fsinfo block number */ - u_long pm_nxtfree; /* next free cluster in fsinfo block */ - u_int pm_fatmult; /* these 2 values are used in fat */ + u_long pm_nxtfree; /* next place to search for a free cluster */ + u_int pm_fatmult; /* these 2 values are used in FAT */ u_int pm_fatdiv; /* offset computation */ - u_int pm_curfat; /* current fat for FAT32 (0 otherwise) */ + u_int pm_curfat; /* current FAT for FAT32 (0 otherwise) */ u_int *pm_inusemap; /* ptr to bitmap of in-use clusters */ u_int pm_flags; /* see below */ struct netexport pm_export; /* export information */ - void *pm_u2w; /* Local->Unicode handle */ - void *pm_w2u; /* Unicode->Local handle */ - void *pm_d2u; /* DOS->local handle */ - void *pm_u2d; /* Local->DOS handle */ + void *pm_u2w; /* Local->Unicode iconv handle */ + void *pm_w2u; /* Unicode->Local iconv handle */ + void *pm_u2d; /* Unicode->DOS iconv handle */ + void *pm_d2u; /* DOS->Local iconv handle */ }; /* Byte offset in FAT on filesystem pmp, cluster cn */ #define FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv) @@ -202,7 +205,6 @@ struct msdosfsmount { #define xcntobn(pmp, cn) \ (de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster) - /* * Calculate block number for directory entry in root dir, offset dirofs */ @@ -242,7 +244,7 @@ struct msdosfs_args { struct export_args export; /* network export information */ uid_t uid; /* uid that owns msdosfs files */ gid_t gid; /* gid that owns msdosfs files */ - mode_t mask; /* mask to be applied for msdosfs perms */ + mode_t mask; /* file mask to be applied for msdosfs perms */ int flags; /* see below */ int magic; /* version number */ char cs_local[ICONV_CSNMAXLEN]; @@ -255,12 +257,11 @@ struct msdosfs_args { #define MSDOSFSMNT_SHORTNAME 1 /* Force old DOS short names only */ #define MSDOSFSMNT_LONGNAME 2 /* Force Win'95 long names */ #define MSDOSFSMNT_NOWIN95 4 /* Completely ignore Win95 entries */ -#define MSDOSFSMNT_KICONV 0x10 /* Local->Unicode and local<->DOS */ - /* tables loaded */ +#define MSDOSFSMNT_KICONV 0x10 /* Use libiconv to convert chars */ /* All flags above: */ #define MSDOSFSMNT_MNTOPT \ (MSDOSFSMNT_SHORTNAME|MSDOSFSMNT_LONGNAME|MSDOSFSMNT_NOWIN95 \ - /*|MSDOSFSMNT_GEMDOSFS*/|MSDOSFSMNT_KICONV) + |MSDOSFSMNT_KICONV) #define MSDOSFSMNT_RONLY 0x80000000 /* mounted read-only */ #define MSDOSFSMNT_WAITONFAT 0x40000000 /* mounted synchronous */ #define MSDOSFS_FATMIRROR 0x20000000 /* FAT is mirrored */