Skip to contentSkip to conversation

vfat on bigendian

DISCUSSION Stefan Wanner 3 participants 5 messages Oct 11, 2001 VFAT/FAT/msdos filesystem

lore
Share & tools
lore
#1 lore raw
Quoted 11 lines · Stefan Wanner

hi

i tried the patch you posted today:
http://lists.linuxppc.org/linuxppc-dev/200110/msg00075.html

now, i can read files with long names created on windows. but it's no more possible to create files on the linux system (also 8.3 names). they apear on linux as ????.

any idea?

Alan has the patch. /mirror/SuSE/ftp.suse.com/pub/suse/ppc/kernel/BETA/patches/70__2.4.5-pre1_vfat_direntry_endianfix.diff.gz

Gruss Olaf

--

 $ man clone

BUGS
Main feature not yet implemented...

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#2 lore raw

thanks a lot!!!

now it works fine.

stefan

Quoted 20 lines · Olaf Hering
Quoted 11 lines · Stefan Wanner

hi

i tried the patch you posted today:
http://lists.linuxppc.org/linuxppc-dev/200110/msg00075.html

now, i can read files with long names created on windows. but it's no more possible to create files on the linux system (also 8.3 names). they apear on linux as ????.

any idea?

Alan has the patch. /mirror/SuSE/ftp.suse.com/pub/suse/ppc/kernel/BETA/patches/70__2.4.5-pre1_vfat_direntry_endianfix.diff.gz

Quoted 11 lines

Gruss Olaf

--

 $ man clone

BUGS
Main feature not yet implemented...

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#3 lore raw
In reply to Olaf Hering
Quoted 2 lines · Olaf Hering

Alan has the patch. /mirror/SuSE/ftp.suse.com/pub/suse/ppc/kernel/BETA/patches/70__2.4.5-pre1_vfat_direntry_endianfix.diff.gz

Yeah, except it looks like that patch will generate trashed short names. I did fix my patch (I had to add stuff in fs/vfat/namei.c to translate the long name in Unicode for into little-endian, and to allow "proper" comparisons and conversions of its wide-char form so that the short name will be generated correctly. The corrected patch is attached.

/me procceds to put a paper bag over his head and sit in the corner. :)

Derrik Pates      |   Sysadmin, Douglas School   |    #linuxOS on EFnet
[email protected] |     District (dsdk12.net)    |    #linuxOS on OPN
fs/fat/dir.c renamed from linux-2.4-benh.dist/fs/fat/dir.c +8 -0
@@ -232,6 +232,10 @@
 				memcpy(&unicode[offset], ds->name0_4, 10);
 				memcpy(&unicode[offset+10], ds->name5_10, 12);
 				memcpy(&unicode[offset+22], ds->name11_12, 4);
+
+				for(i = offset; i < offset + 26; i += 2)
+					__le16_to_cpus((wchar_t *)&unicode[i]);
+
 				offset += 26;
 
 				if (ds->id & 0x40) {
@@ -430,6 +435,10 @@
 			memcpy(&unicode[offset], ds->name0_4, 10);
 			memcpy(&unicode[offset+10], ds->name5_10, 12);
 			memcpy(&unicode[offset+22], ds->name11_12, 4);
+
+			for(i = offset; i < offset + 26; i += 2)
+				__le16_to_cpus((wchar_t *)&unicode[i]);
+
 			offset += 26;
 
 			if (ds->id & 0x40) {
fs/vfat/namei.c renamed from linux-2.4-benh.dist/fs/vfat/namei.c +12 -5
@@ -519,7 +519,8 @@
 	/*  `['     `]'    `;'     `,'     `+'      `=' */
 	0x005B, 0x005D, 0x003B, 0x002C, 0x002B, 0x003D, 0,
 };
-#define IS_REPLACECHAR(uni)	(vfat_unistrchr(replace_chars, (uni)) != NULL)
+#define IS_REPLACECHAR(uni)	(vfat_unistrchr(replace_chars, \
+					__cpu_to_le16(uni)) != NULL)
 
 static inline wchar_t *vfat_unistrchr(const wchar_t *s, const wchar_t c)
 {
@@ -587,7 +588,8 @@
 	0x002E, 0x0020, 0,
 };
 #define IS_SKIPCHAR(uni) \
-	((wchar_t)(uni) == skip_chars[0] || (wchar_t)(uni) == skip_chars[1])
+	(__cpu_to_le16((wchar_t)(uni)) == skip_chars[0] || \
+	 __cpu_to_le16((wchar_t)(uni)) == skip_chars[1])
 
 /* Given a valid longname, create a unique shortname.  Make sure the
  * shortname does not exist
@@ -627,7 +629,7 @@
 	/* Now, we need to create a shortname from the long name */
 	ext_start = end = &uname[ulen];
 	while (--ext_start >= uname) {
-		if (*ext_start == 0x002E) { /* is `.' */
+		if (*ext_start == __cpu_to_le16(0x002E)) { /* is `.' */
 			if (ext_start == end - 1) {
 				sz = ulen;
 				ext_start = NULL;
@@ -673,7 +675,8 @@
 			charbuf[0] = '_';
 			chl = 1;
 		} else {
-			chl = nls->uni2char(*ip, charbuf, sizeof(charbuf));
+			chl = nls->uni2char(__cpu_to_le16(*ip), charbuf,
+					sizeof(charbuf));
 			if (chl <= 0) {
 				is_shortname = 0;
 				charbuf[0]  = '_';
@@ -720,7 +723,8 @@
 				charbuf[0] = '_';
 				chl = 1;
 			} else {
-				chl = nls->uni2char(*ip, charbuf, sizeof(charbuf));
+				chl = nls->uni2char(__cpu_to_le16(*ip), charbuf,
+						sizeof(charbuf));
 				if (chl <= 0) {
 					is_shortname = 0;
 					charbuf[0] = '_';
@@ -883,6 +887,9 @@
 	}
 	if (*outlen > 260)
 		return -ENAMETOOLONG;
+
+	for(i = 0; i < *outlen; i++)
+		__cpu_to_le16s(&((wchar_t *)outname)[i]);
 
 	*longlen = *outlen;
 	if (*outlen % 13) {
#4 lore raw
In reply to Stefan Wanner
Quoted 6 lines · Stefan Wanner

i tried the patch you posted today:
http://lists.linuxppc.org/linuxppc-dev/200110/msg00075.html

now, i can read files with long names created on windows. but it's no more possible to create files on the linux system (also 8.3 names). they apear on linux as ????.

*self-baps* Doh. I see where I need to add another translation, and I'm doing so now.

/me == idiot...

Derrik Pates      |   Sysadmin, Douglas School   |    #linuxOS on EFnet
[email protected] |     District (dsdk12.net)    |    #linuxOS on OPN

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/