Date: Sun, 17 Jan 2010 12:39:41 -0800 (PST) From: "Pedro F. Giffuni" <giffunip@tutopia.com> To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org Subject: Re: kern/142558: Minor updates to fs/msdosfs headers (from NetBSD) Message-ID: <372327.30275.qm@web113510.mail.gq1.yahoo.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Updated patch:
- In direntry.h remove deExtension, this was always part of the deName
and some of the code still abuses it. This basically undoes CVS Rev.
1.46 but fixes the issues more practically.
- As a consequence to the above winChksum is now exactly as
in NetBSD.
[-- Attachment #2 --]
diff -ru msdosfs.orig/bootsect.h msdosfs/bootsect.h
--- msdosfs.orig/bootsect.h 2010-01-09 19:29:45.000000000 +0000
+++ msdosfs/bootsect.h 2010-01-17 14:16:20.000000000 +0000
@@ -16,6 +16,8 @@
*
* October 1992
*/
+#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
@@ -91,3 +93,5 @@
#define bsHiddenSecs bsBPB.bpbHiddenSecs
#define bsHugeSectors bsBPB.bpbHugeSectors
#endif
+
+#endif /* !_FS_MSDOSFS_BOOTSECT_H_ */
diff -ru msdosfs.orig/bpb.h msdosfs/bpb.h
--- msdosfs.orig/bpb.h 2010-01-09 19:29:45.000000000 +0000
+++ msdosfs/bpb.h 2010-01-17 14:16:27.000000000 +0000
@@ -17,6 +17,9 @@
* October 1992
*/
+#ifndef _FS_MSDOSFS_BPB_H_
+#define _FS_MSDOSFS_BPB_H_
+
/*
* BIOS Parameter Block (BPB) for DOS 3.3
*/
@@ -78,7 +81,7 @@
u_int32_t bpbRootClust; /* start cluster for root directory */
u_int16_t bpbFSInfo; /* filesystem info structure sector */
u_int16_t bpbBackup; /* backup boot sector */
- /* There is a 12 byte filler here, but we ignore it */
+ u_int8_t bpbReserved[12]; /* reserved for future expansion */
};
/*
@@ -153,7 +156,7 @@
u_int8_t bpbRootClust[4]; /* start cluster for root directory */
u_int8_t bpbFSInfo[2]; /* filesystem info structure sector */
u_int8_t bpbBackup[2]; /* backup boot sector */
- /* There is a 12 byte filler here, but we ignore it */
+ u_int8_t bpbReserved[12]; /* reserved for future expansion */
};
/*
@@ -168,3 +171,4 @@
u_int8_t fsifill2[12];
u_int8_t fsisig3[4];
};
+#endif /* !_FS_MSDOSFS_BPB_H_ */
diff -ru msdosfs.orig/direntry.h msdosfs/direntry.h
--- msdosfs.orig/direntry.h 2010-01-09 19:29:45.000000000 +0000
+++ msdosfs/direntry.h 2010-01-17 15:02:41.000000000 +0000
@@ -47,16 +47,17 @@
*
* October 1992
*/
+#ifndef _FS_MSDOSFS_DIRENTRY_H_
+#define _FS_MSDOSFS_DIRENTRY_H_
/*
* Structure of a dos directory entry.
*/
struct direntry {
- u_int8_t deName[8]; /* filename, blank filled */
+ u_int8_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 */
- u_int8_t deExtension[3]; /* extension, blank filled */
u_int8_t deAttributes; /* file attributes */
#define ATTR_NORMAL 0x00 /* normal file */
#define ATTR_READONLY 0x01 /* file is readonly */
@@ -155,7 +156,8 @@
int chksum, struct msdosfsmount *pmp);
int win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum,
struct msdosfsmount *pmp);
-u_int8_t winChksum(struct direntry *dep);
+u_int8_t winChksum(u_int8_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 /* !_FS_MSDOSFS_DIRENTRY_H_ */
diff -ru msdosfs.orig/msdosfs_conv.c msdosfs/msdosfs_conv.c
--- msdosfs.orig/msdosfs_conv.c 2010-01-09 19:29:45.000000000 +0000
+++ msdosfs/msdosfs_conv.c 2010-01-17 15:25:10.000000000 +0000
@@ -741,22 +741,13 @@
* Compute the unrolled checksum of a DOS filename for Win95 LFN use.
*/
u_int8_t
-winChksum(struct direntry *dep)
+winChksum(u_int8_t *name)
{
+ int i;
u_int8_t s;
- s = dep->deName[0];
- s = ((s << 7) | (s >> 1)) + dep->deName[1];
- s = ((s << 7) | (s >> 1)) + dep->deName[2];
- s = ((s << 7) | (s >> 1)) + dep->deName[3];
- s = ((s << 7) | (s >> 1)) + dep->deName[4];
- s = ((s << 7) | (s >> 1)) + dep->deName[5];
- s = ((s << 7) | (s >> 1)) + dep->deName[6];
- s = ((s << 7) | (s >> 1)) + dep->deName[7];
- s = ((s << 7) | (s >> 1)) + dep->deExtension[0];
- s = ((s << 7) | (s >> 1)) + dep->deExtension[1];
- s = ((s << 7) | (s >> 1)) + dep->deExtension[2];
-
+ for (s = 0, i = 11; --i >= 0; s += *name++)
+ s = (s << 7)|(s >> 1);
return (s);
}
diff -ru msdosfs.orig/msdosfs_lookup.c msdosfs/msdosfs_lookup.c
--- msdosfs.orig/msdosfs_lookup.c 2010-01-09 19:29:45.000000000 +0000
+++ msdosfs/msdosfs_lookup.c 2010-01-17 15:06:01.000000000 +0000
@@ -276,7 +276,7 @@
/*
* Check for a checksum or name match
*/
- chksum_ok = (chksum == winChksum(dep));
+ chksum_ok = (chksum == winChksum(dep->deName));
if (!chksum_ok
&& (!olddos || bcmp(dosfilename, dep->deName, 11))) {
chksum = -1;
@@ -617,7 +617,7 @@
* Now write the Win95 long name
*/
if (ddep->de_fndcnt > 0) {
- u_int8_t chksum = winChksum(ndep);
+ u_int8_t chksum = winChksum(ndep->deName);
const u_char *un = (const u_char *)cnp->cn_nameptr;
int unlen = cnp->cn_namelen;
int cnt = 1;
diff -ru msdosfs.orig/msdosfs_vnops.c msdosfs/msdosfs_vnops.c
--- msdosfs.orig/msdosfs_vnops.c 2010-01-09 19:29:45.000000000 +0000
+++ msdosfs/msdosfs_vnops.c 2010-01-17 15:07:20.000000000 +0000
@@ -1287,7 +1287,7 @@
struct direntry dot;
struct direntry dotdot;
} dosdirtemplate = {
- { ". ", " ", /* the . entry */
+ { ". ", /* the . entry */
ATTR_DIRECTORY, /* file attribute */
0, /* reserved */
0, { 0, 0 }, { 0, 0 }, /* create time & date */
@@ -1297,7 +1297,7 @@
{ 0, 0 }, /* startcluster */
{ 0, 0, 0, 0 } /* filesize */
},
- { ".. ", " ", /* the .. entry */
+ { ".. ", /* the .. entry */
ATTR_DIRECTORY, /* file attribute */
0, /* reserved */
0, { 0, 0 }, { 0, 0 }, /* create time & date */
@@ -1729,7 +1729,7 @@
} else
dirbuf.d_fileno = (uint32_t)fileno;
- if (chksum != winChksum(dentp)) {
+ if (chksum != winChksum(dentp->deName)) {
dirbuf.d_namlen = dos2unixfn(dentp->deName,
(u_char *)dirbuf.d_name,
dentp->deLowerCase |
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?372327.30275.qm>
