FATFileSystem

Dependents:   SDFileSystem IPS SDFileSystem SDFileSystem ... more

Fork of FATFileSystem by mbed official

Revision:
6:a5fcdbf92056
Parent:
5:b3b3370574cf
--- a/ChaN/ff.cpp	Thu Aug 13 10:15:39 2015 +0100
+++ b/ChaN/ff.cpp	Thu Nov 26 13:30:57 2015 +0000
@@ -1,5 +1,5 @@
 /*----------------------------------------------------------------------------/
-/  FatFs - FAT file system module  R0.11                 (C)ChaN, 2015
+/  FatFs - FAT file system module  R0.11a                (C)ChaN, 2015        /
 /-----------------------------------------------------------------------------/
 / FatFs module is a free software that opened under license policy of
 / following conditions.
@@ -26,7 +26,7 @@
 
 ---------------------------------------------------------------------------*/
 
-#if _FATFS != 32020	/* Revision ID */
+#if _FATFS != 64180	/* Revision ID */
 #error Wrong include file (ff.h).
 #endif
 
@@ -83,7 +83,7 @@
 
 
 
-/* DBCS code ranges and SBCS extend character conversion table */
+/* DBCS code ranges and SBCS upper conversion tables */
 
 #if _CODE_PAGE == 932	/* Japanese Shift-JIS */
 #define _DF1S	0x81	/* DBC 1st byte range 1 start */
@@ -121,152 +121,192 @@
 #define _DS2S	0xA1
 #define _DS2E	0xFE
 
-#elif _CODE_PAGE == 437	/* U.S. (OEM) */
+#elif _CODE_PAGE == 437	/* U.S. */
 #define _DF1S	0
-#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 720	/* Arabic (OEM) */
+#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
+				0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
+				0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
+				0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
+				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \
+				0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
+				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \
+				0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 720	/* Arabic */
 #define _DF1S	0
-#define _EXCVT {0x80,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C8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \
+				0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
+				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \
+				0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 737	/* Greek */
 #define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \
-				0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 775	/* Baltic (OEM) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \
-				0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 850	/* Multilingual Latin 1 (OEM) */
+#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
+				0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \
+				0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96, \
+				0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
+				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,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x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
+				0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
+				0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
+				0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
+				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \
+				0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDC,0xDE,0xDE, \
+				0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
+				0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFE,0xFF}
+
+#elif _CODE_PAGE == 775	/* Baltic */
 #define _DF1S	0
-#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \
-				0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC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C4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 858	/* Multilingual Latin 1 + Euro (OEM) */
+#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x41,0x43,0x45,0x45,0x45,0x49,0x49,0x49,0x41,0x41, \
+				0x45,0x92,0x92,0x4F,0x4F,0x4F,0x55,0x55,0x59,0x4F,0x55,0x4F,0x9C,0x4F,0x9E,0x9F, \
+				0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
+				0xB0,0xB1,0xB2,0xB3,0xB4,0x41,0x41,0x41,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
+				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0x41,0x41,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \
+				0xD1,0xD1,0x45,0x45,0x45,0x49,0x49,0x49,0x49,0xD9,0xDA,0xDB,0xDC,0xDD,0x49,0xDF, \
+				0x4F,0xE1,0x4F,0x4F,0x4F,0x4F,0xE6,0xE8,0xE8,0x55,0x55,0x55,0x59,0x59,0xEE,0xEF, \
+				0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 852	/* Latin 2 */
 #define _DF1S	0
-#define _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OEM) */
+#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F, \
+				0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \
+				0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF, \
+				0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \
+				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \
+				0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \
+				0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF, \
+				0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 857	/* Turkish */
 #define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC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/* Portuguese */
 #define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */
+#define _EXCVT {0x80,0x9A,0x90,0x8F,0x8E,0x91,0x86,0x80,0x89,0x89,0x92,0x8B,0x8C,0x98,0x8E,0x8F, \
+				0x90,0x91,0x92,0x8C,0x99,0xA9,0x96,0x9D,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
+				0x86,0x8B,0x9F,0x96,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
+				0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
+				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_PAGE == 1251 /* Cyrillic (Windows) */
+#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x8B,0x8B,0x8D,0x8E,0x8F, \
+				0x90,0x92,0x92,0x4F,0x99,0x8D,0x55,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \
+				0xA4,0xA5,0xA6,0xA7,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
+				0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
+				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \
+				0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
+				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \
+				0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 862	/* Hebrew */
 #define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \
-				0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3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DE,0x9F}
-
-#elif _CODE_PAGE == 1253 /* Greek (Windows) */
+#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
+				0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
+				0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
+				0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
+				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \
+				0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
+				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \
+				0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 863	/* Canadian-French */
 #define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA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xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 864	/* Arabic */
 #define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \
-				0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F}
-
-#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */
+#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
+				0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
+				0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
+				0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,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0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 1256 /* Arabic (Windows) */
+#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
+				0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
+				0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
+				0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
+				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \
+				0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
+				0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \
+				0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 866	/* Russian */
 #define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \
-				0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF}
-
-#elif _CODE_PAGE == 1257 /* Baltic (Windows) */
+#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
+				0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
+				0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
+				0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
+				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \
+				0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
+				0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
+				0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 869	/* Greek 2 */
 #define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
-				0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
-				0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF}
-
-#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */
-#define _DF1S	0
-#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \
-				0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0x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only non-LFN cfg) */
 #if _USE_LFN
@@ -318,12 +358,12 @@
 
 
 /* FAT sub-type boundaries (Differ from specs but correct for real DOS/Windows) */
-#define MIN_FAT16	4086U	/* Minimum number of clusters as FAT16 */
-#define	MIN_FAT32	65526U	/* Minimum number of clusters as FAT32 */
+#define MIN_FAT16	4086U	/* Minimum number of clusters of FAT16 */
+#define	MIN_FAT32	65526U	/* Minimum number of clusters of FAT32 */
 
 
 /* FatFs refers the members in the FAT structures as byte array instead of
-/ structure member because the structure is not binary compatible between
+/ structure members because the structure is not binary compatible between
 / different platforms */
 
 #define BS_jmpBoot			0		/* x86 jump instruction (3) */
@@ -340,7 +380,8 @@
 #define BPB_NumHeads		26		/* Number of heads (2) */
 #define BPB_HiddSec			28		/* Number of special hidden sectors (4) */
 #define BPB_TotSec32		32		/* Volume size [sector] (4) */
-#define BS_DrvNum			36		/* Physical drive number (2) */
+#define BS_DrvNum			36		/* Physical drive number (1) */
+#define BS_NTres			37		/* Error flag (1) */
 #define BS_BootSig			38		/* Extended boot signature (1) */
 #define BS_VolID			39		/* Volume serial number (4) */
 #define BS_VolLab			43		/* Volume label (8) */
@@ -351,7 +392,8 @@
 #define BPB_RootClus		44		/* Root directory first cluster (4) */
 #define BPB_FSInfo			48		/* Offset of FSINFO sector (2) */
 #define BPB_BkBootSec		50		/* Offset of backup boot sector (2) */
-#define BS_DrvNum32			64		/* Physical drive number (2) */
+#define BS_DrvNum32			64		/* Physical drive number (1) */
+#define BS_NTres32			65		/* Error flag (1) */
 #define BS_BootSig32		66		/* Extended boot signature (1) */
 #define BS_VolID32			67		/* Volume serial number (4) */
 #define BS_VolLab32			71		/* Volume label (8) */
@@ -379,7 +421,7 @@
 #define	LDIR_Ord			0		/* LFN entry order and LLE flag (1) */
 #define	LDIR_Attr			11		/* LFN attribute (1) */
 #define	LDIR_Type			12		/* LFN type (1) */
-#define	LDIR_Chksum			13		/* Sum of corresponding SFN entry */
+#define	LDIR_Chksum			13		/* Checksum of corresponding SFN entry */
 #define	LDIR_FstClusLO		26		/* Must be zero (0) */
 #define	SZ_DIRE				32		/* Size of a directory entry */
 #define	LLEF				0x40	/* Last long entry flag in LDIR_Ord */
@@ -389,12 +431,15 @@
 
 
 
-/*------------------------------------------------------------*/
-/* Module private work area                                   */
-/*------------------------------------------------------------*/
-/* Remark: Uninitialized variables with static duration are
-/  guaranteed zero/null at start-up. If not, either the linker
-/  or start-up routine being used is out of ANSI-C standard.
+/*--------------------------------------------------------------------------
+
+   Module Private Work Area
+
+---------------------------------------------------------------------------*/
+
+/* Remark: Uninitialized variables with static duration are guaranteed
+/  zero/null at start-up. If not, either the linker or start-up routine
+/  being used is not compliance with ANSI-C standard.
 */
 
 #if _VOLUMES < 1 || _VOLUMES > 9
@@ -438,7 +483,7 @@
 #endif
 
 #ifdef _EXCVT
-static const BYTE ExCvt[] = _EXCVT;	/* Upper conversion table for extended characters */
+static const BYTE ExCvt[] = _EXCVT;	/* Upper conversion table for SBCS extended characters */
 #endif
 
 
@@ -652,7 +697,7 @@
 /*-----------------------------------------------------------------------*/
 #if !_FS_READONLY
 static
-FRESULT sync_window (
+FRESULT sync_window (	/* FR_OK:succeeded, !=0:error */
 	FATFS* fs		/* File system object */
 )
 {
@@ -681,7 +726,7 @@
 
 
 static
-FRESULT move_window (
+FRESULT move_window (	/* FR_OK(0):succeeded, !=0:error */
 	FATFS* fs,		/* File system object */
 	DWORD sector	/* Sector number to make appearance in the fs->win[] */
 )
@@ -712,7 +757,7 @@
 /*-----------------------------------------------------------------------*/
 #if !_FS_READONLY
 static
-FRESULT sync_fs (	/* FR_OK: successful, FR_DISK_ERR: failed */
+FRESULT sync_fs (	/* FR_OK:succeeded, !=0:error */
 	FATFS* fs		/* File system object */
 )
 {
@@ -721,16 +766,16 @@
 
 	res = sync_window(fs);
 	if (res == FR_OK) {
-		/* Update FSINFO sector if needed */
+		/* Update FSInfo sector if needed */
 		if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) {
-			/* Create FSINFO structure */
+			/* Create FSInfo structure */
 			mem_set(fs->win, 0, SS(fs));
 			ST_WORD(fs->win + BS_55AA, 0xAA55);
 			ST_DWORD(fs->win + FSI_LeadSig, 0x41615252);
 			ST_DWORD(fs->win + FSI_StrucSig, 0x61417272);
 			ST_DWORD(fs->win + FSI_Free_Count, fs->free_clust);
 			ST_DWORD(fs->win + FSI_Nxt_Free, fs->last_clust);
-			/* Write it into the FSINFO sector */
+			/* Write it into the FSInfo sector */
 			fs->winsect = fs->volbase + 1;
 			disk_write(fs->drv, fs->win, fs->winsect, 1);
 			fs->fsi_flag = 0;
@@ -752,7 +797,7 @@
 /*-----------------------------------------------------------------------*/
 /* Hidden API for hacks and disk tools */
 
-DWORD clust2sect (	/* !=0: Sector number, 0: Failed - invalid cluster# */
+DWORD clust2sect (	/* !=0:Sector number, 0:Failed (invalid cluster#) */
 	FATFS* fs,		/* File system object */
 	DWORD clst		/* Cluster# to be converted */
 )
@@ -780,7 +825,7 @@
 	DWORD val;
 
 
-	if (clst < 2 || clst >= fs->n_fatent) {	/* Check range */
+	if (clst < 2 || clst >= fs->n_fatent) {	/* Check if in valid range */
 		val = 1;	/* Internal error */
 
 	} else {
@@ -825,10 +870,10 @@
 /* Hidden API for hacks and disk tools */
 
 #if !_FS_READONLY
-FRESULT put_fat (
-	FATFS* fs,	/* File system object */
-	DWORD clst,	/* FAT index number (cluster number) to be changed */
-	DWORD val	/* New value to be set to the entry */
+FRESULT put_fat (	/* FR_OK(0):succeeded, !=0:error */
+	FATFS* fs,		/* File system object */
+	DWORD clst,		/* FAT index number (cluster number) to be changed */
+	DWORD val		/* New value to be set to the entry */
 )
 {
 	UINT bc;
@@ -836,7 +881,7 @@
 	FRESULT res;
 
 
-	if (clst < 2 || clst >= fs->n_fatent) {	/* Check range */
+	if (clst < 2 || clst >= fs->n_fatent) {	/* Check if in valid range */
 		res = FR_INT_ERR;
 
 	} else {
@@ -889,7 +934,7 @@
 /*-----------------------------------------------------------------------*/
 #if !_FS_READONLY
 static
-FRESULT remove_chain (
+FRESULT remove_chain (	/* FR_OK(0):succeeded, !=0:error */
 	FATFS* fs,			/* File system object */
 	DWORD clst			/* Cluster# to remove a chain from */
 )
@@ -900,7 +945,7 @@
 	DWORD scl = clst, ecl = clst, rt[2];
 #endif
 
-	if (clst < 2 || clst >= fs->n_fatent) {	/* Check range */
+	if (clst < 2 || clst >= fs->n_fatent) {	/* Check if in valid range */
 		res = FR_INT_ERR;
 
 	} else {
@@ -944,7 +989,7 @@
 static
 DWORD create_chain (	/* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */
 	FATFS* fs,			/* File system object */
-	DWORD clst			/* Cluster# to stretch. 0 means create a new chain. */
+	DWORD clst			/* Cluster# to stretch, 0:Create a new chain */
 )
 {
 	DWORD cs, ncl, scl;
@@ -1032,7 +1077,7 @@
 /*-----------------------------------------------------------------------*/
 
 static
-FRESULT dir_sdi (
+FRESULT dir_sdi (	/* FR_OK(0):succeeded, !=0:error */
 	FATFS_DIR* dp,		/* Pointer to directory object */
 	UINT idx		/* Index of directory table */
 )
@@ -1067,7 +1112,7 @@
 	dp->clust = clst;	/* Current cluster# */
 	if (!sect) return FR_INT_ERR;
 	dp->sect = sect + idx / (SS(dp->fs) / SZ_DIRE);					/* Sector# of the directory entry */
-	dp->FATFS_DIR = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE;	/* Ptr to the entry in the sector */
+	dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE;	/* Ptr to the entry in the sector */
 
 	return FR_OK;
 }
@@ -1080,7 +1125,7 @@
 /*-----------------------------------------------------------------------*/
 
 static
-FRESULT dir_next (	/* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */
+FRESULT dir_next (	/* FR_OK(0):succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */
 	FATFS_DIR* dp,		/* Pointer to the directory object */
 	int stretch		/* 0: Do not stretch table, 1: Stretch table if needed */
 )
@@ -1137,7 +1182,7 @@
 	}
 
 	dp->index = (WORD)i;	/* Current index */
-	dp->FATFS_DIR = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE;	/* Current entry in the window */
+	dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIRE)) * SZ_DIRE;	/* Current entry in the window */
 
 	return FR_OK;
 }
@@ -1151,9 +1196,9 @@
 
 #if !_FS_READONLY
 static
-FRESULT dir_alloc (
-	FATFS_DIR* dp,	/* Pointer to the directory object */
-	UINT nent	/* Number of contiguous entries to allocate (1-21) */
+FRESULT dir_alloc (	/* FR_OK(0):succeeded, !=0:error */
+	FATFS_DIR* dp,		/* Pointer to the directory object */
+	UINT nent		/* Number of contiguous entries to allocate (1-21) */
 )
 {
 	FRESULT res;
@@ -1166,7 +1211,7 @@
 		do {
 			res = move_window(dp->fs, dp->sect);
 			if (res != FR_OK) break;
-			if (dp->FATFS_DIR[0] == DDEM || dp->FATFS_DIR[0] == 0) {	/* Is it a free entry? */
+			if (dp->dir[0] == DDEM || dp->dir[0] == 0) {	/* Is it a free entry? */
 				if (++n == nent) break;	/* A block of contiguous free entries is found */
 			} else {
 				n = 0;					/* Not a blank entry. Restart to search */
@@ -1187,16 +1232,16 @@
 /*-----------------------------------------------------------------------*/
 
 static
-DWORD ld_clust (
-	FATFS* fs,	/* Pointer to the fs object */
-	BYTE* FATFS_DIR	/* Pointer to the directory entry */
+DWORD ld_clust (	/* Returns the top cluster value of the SFN entry */
+	FATFS* fs,		/* Pointer to the fs object */
+	const BYTE* dir	/* Pointer to the SFN entry */
 )
 {
 	DWORD cl;
 
-	cl = LD_WORD(FATFS_DIR + DIR_FstClusLO);
+	cl = LD_WORD(dir + DIR_FstClusLO);
 	if (fs->fs_type == FS_FAT32)
-		cl |= (DWORD)LD_WORD(FATFS_DIR + DIR_FstClusHI) << 16;
+		cl |= (DWORD)LD_WORD(dir + DIR_FstClusHI) << 16;
 
 	return cl;
 }
@@ -1205,12 +1250,12 @@
 #if !_FS_READONLY
 static
 void st_clust (
-	BYTE* FATFS_DIR,	/* Pointer to the directory entry */
+	BYTE* dir,	/* Pointer to the SFN entry */
 	DWORD cl	/* Value to be set */
 )
 {
-	ST_WORD(FATFS_DIR + DIR_FstClusLO, cl);
-	ST_WORD(FATFS_DIR + DIR_FstClusHI, cl >> 16);
+	ST_WORD(dir + DIR_FstClusLO, cl);
+	ST_WORD(dir + DIR_FstClusHI, cl >> 16);
 }
 #endif
 
@@ -1226,95 +1271,98 @@
 
 
 static
-int cmp_lfn (			/* 1:Matched, 0:Not matched */
-	WCHAR* lfnbuf,		/* Pointer to the LFN to be compared */
-	BYTE* FATFS_DIR			/* Pointer to the directory entry containing a part of LFN */
+int cmp_lfn (			/* 1:matched, 0:not matched */
+	WCHAR* lfnbuf,		/* Pointer to the LFN working buffer to be compared */
+	BYTE* dir			/* Pointer to the directory entry containing the part of LFN */
 )
 {
 	UINT i, s;
 	WCHAR wc, uc;
 
 
-	i = ((FATFS_DIR[LDIR_Ord] & ~LLEF) - 1) * 13;	/* Get offset in the LFN buffer */
-	s = 0; wc = 1;
-	do {
-		uc = LD_WORD(FATFS_DIR + LfnOfs[s]);	/* Pick an LFN character from the entry */
-		if (wc) {	/* Last character has not been processed */
-			wc = ff_wtoupper(uc);		/* Convert it to upper case */
-			if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++]))	/* Compare it */
-				return 0;				/* Not matched */
+	if (LD_WORD(dir + LDIR_FstClusLO) != 0) return 0;	/* Check LDIR_FstClusLO */
+
+	i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13;	/* Offset in the LFN buffer */
+
+	for (wc = 1, s = 0; s < 13; s++) {		/* Process all characters in the entry */
+		uc = LD_WORD(dir + LfnOfs[s]);		/* Pick an LFN character */
+		if (wc) {
+			if (i >= _MAX_LFN || ff_wtoupper(uc) != ff_wtoupper(lfnbuf[i++]))	/* Compare it */
+				return 0;					/* Not matched */
+			wc = uc;
 		} else {
-			if (uc != 0xFFFF) return 0;	/* Check filler */
+			if (uc != 0xFFFF) return 0;		/* Check filler */
 		}
-	} while (++s < 13);				/* Repeat until all characters in the entry are checked */
-
-	if ((FATFS_DIR[LDIR_Ord] & LLEF) && wc && lfnbuf[i])	/* Last segment matched but different length */
+	}
+
+	if ((dir[LDIR_Ord] & LLEF) && wc && lfnbuf[i])	/* Last segment matched but different length */
 		return 0;
 
-	return 1;						/* The part of LFN matched */
+	return 1;		/* The part of LFN matched */
 }
 
 
 
 static
-int pick_lfn (			/* 1:Succeeded, 0:Buffer overflow */
-	WCHAR* lfnbuf,		/* Pointer to the Unicode-LFN buffer */
-	BYTE* FATFS_DIR			/* Pointer to the directory entry */
+int pick_lfn (			/* 1:succeeded, 0:buffer overflow or invalid LFN entry */
+	WCHAR* lfnbuf,		/* Pointer to the LFN working buffer */
+	BYTE* dir			/* Pointer to the LFN entry */
 )
 {
 	UINT i, s;
 	WCHAR wc, uc;
 
 
-	i = ((FATFS_DIR[LDIR_Ord] & 0x3F) - 1) * 13;	/* Offset in the LFN buffer */
-
-	s = 0; wc = 1;
-	do {
-		uc = LD_WORD(FATFS_DIR + LfnOfs[s]);		/* Pick an LFN character from the entry */
-		if (wc) {	/* Last character has not been processed */
+	if (LD_WORD(dir + LDIR_FstClusLO) != 0) return 0;	/* Check LDIR_FstClusLO */
+
+	i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13;	/* Offset in the LFN buffer */
+
+	for (wc = 1, s = 0; s < 13; s++) {		/* Process all characters in the entry */
+		uc = LD_WORD(dir + LfnOfs[s]);		/* Pick an LFN character */
+		if (wc) {
 			if (i >= _MAX_LFN) return 0;	/* Buffer overflow? */
 			lfnbuf[i++] = wc = uc;			/* Store it */
 		} else {
 			if (uc != 0xFFFF) return 0;		/* Check filler */
 		}
-	} while (++s < 13);						/* Read all character in the entry */
-
-	if (FATFS_DIR[LDIR_Ord] & LLEF) {				/* Put terminator if it is the last LFN part */
+	}
+
+	if (dir[LDIR_Ord] & LLEF) {				/* Put terminator if it is the last LFN part */
 		if (i >= _MAX_LFN) return 0;		/* Buffer overflow? */
 		lfnbuf[i] = 0;
 	}
 
-	return 1;
+	return 1;		/* The part of LFN is valid */
 }
 
 
 #if !_FS_READONLY
 static
 void fit_lfn (
-	const WCHAR* lfnbuf,	/* Pointer to the LFN buffer */
-	BYTE* FATFS_DIR,				/* Pointer to the directory entry */
+	const WCHAR* lfnbuf,	/* Pointer to the LFN working buffer */
+	BYTE* dir,				/* Pointer to the LFN entry to be processed */
 	BYTE ord,				/* LFN order (1-20) */
-	BYTE sum				/* SFN sum */
+	BYTE sum				/* Checksum of the corresponding SFN */
 )
 {
 	UINT i, s;
 	WCHAR wc;
 
 
-	FATFS_DIR[LDIR_Chksum] = sum;			/* Set check sum */
-	FATFS_DIR[LDIR_Attr] = AM_LFN;		/* Set attribute. LFN entry */
-	FATFS_DIR[LDIR_Type] = 0;
-	ST_WORD(FATFS_DIR + LDIR_FstClusLO, 0);
-
-	i = (ord - 1) * 13;				/* Get offset in the LFN buffer */
+	dir[LDIR_Chksum] = sum;			/* Set checksum */
+	dir[LDIR_Attr] = AM_LFN;		/* Set attribute. LFN entry */
+	dir[LDIR_Type] = 0;
+	ST_WORD(dir + LDIR_FstClusLO, 0);
+
+	i = (ord - 1) * 13;				/* Get offset in the LFN working buffer */
 	s = wc = 0;
 	do {
 		if (wc != 0xFFFF) wc = lfnbuf[i++];	/* Get an effective character */
-		ST_WORD(FATFS_DIR+LfnOfs[s], wc);	/* Put it */
+		ST_WORD(dir+LfnOfs[s], wc);	/* Put it */
 		if (!wc) wc = 0xFFFF;		/* Padding characters following last character */
 	} while (++s < 13);
 	if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLEF;	/* Bottom LFN part is the start of LFN sequence */
-	FATFS_DIR[LDIR_Ord] = ord;			/* Set the LFN order */
+	dir[LDIR_Ord] = ord;			/* Set the LFN order */
 }
 
 #endif
@@ -1383,18 +1431,18 @@
 
 
 /*-----------------------------------------------------------------------*/
-/* Calculate sum of an SFN                                               */
+/* Calculate checksum of an SFN entry                                    */
 /*-----------------------------------------------------------------------*/
 #if _USE_LFN
 static
 BYTE sum_sfn (
-	const BYTE* FATFS_DIR		/* Pointer to the SFN entry */
+	const BYTE* dir		/* Pointer to the SFN entry */
 )
 {
 	BYTE sum = 0;
 	UINT n = 11;
 
-	do sum = (sum >> 1) + (sum << 7) + *FATFS_DIR++; while (--n);
+	do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n);
 	return sum;
 }
 #endif
@@ -1407,12 +1455,12 @@
 /*-----------------------------------------------------------------------*/
 
 static
-FRESULT dir_find (
+FRESULT dir_find (	/* FR_OK(0):succeeded, !=0:error */
 	FATFS_DIR* dp			/* Pointer to the directory object linked to the file name */
 )
 {
 	FRESULT res;
-	BYTE c, *FATFS_DIR;
+	BYTE c, *dir;
 #if _USE_LFN
 	BYTE a, ord, sum;
 #endif
@@ -1426,32 +1474,32 @@
 	do {
 		res = move_window(dp->fs, dp->sect);
 		if (res != FR_OK) break;
-		FATFS_DIR = dp->FATFS_DIR;					/* Ptr to the directory entry of current index */
-		c = FATFS_DIR[DIR_Name];
+		dir = dp->dir;					/* Ptr to the directory entry of current index */
+		c = dir[DIR_Name];
 		if (c == 0) { res = FR_NO_FILE; break; }	/* Reached to end of table */
 #if _USE_LFN	/* LFN configuration */
-		a = FATFS_DIR[DIR_Attr] & AM_MASK;
+		a = dir[DIR_Attr] & AM_MASK;
 		if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) {	/* An entry without valid data */
 			ord = 0xFF; dp->lfn_idx = 0xFFFF;	/* Reset LFN sequence */
 		} else {
 			if (a == AM_LFN) {			/* An LFN entry is found */
 				if (dp->lfn) {
 					if (c & LLEF) {		/* Is it start of LFN sequence? */
-						sum = FATFS_DIR[LDIR_Chksum];
+						sum = dir[LDIR_Chksum];
 						c &= ~LLEF; ord = c;	/* LFN start order */
 						dp->lfn_idx = dp->index;	/* Start index of LFN */
 					}
 					/* Check validity of the LFN entry and compare it with given name */
-					ord = (c == ord && sum == FATFS_DIR[LDIR_Chksum] && cmp_lfn(dp->lfn, FATFS_DIR)) ? ord - 1 : 0xFF;
+					ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF;
 				}
 			} else {					/* An SFN entry is found */
-				if (!ord && sum == sum_sfn(FATFS_DIR)) break;	/* LFN matched? */
-				if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(FATFS_DIR, dp->fn, 11)) break;	/* SFN matched? */
+				if (!ord && sum == sum_sfn(dir)) break;	/* LFN matched? */
+				if (!(dp->fn[NSFLAG] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break;	/* SFN matched? */
 				ord = 0xFF; dp->lfn_idx = 0xFFFF;	/* Reset LFN sequence */
 			}
 		}
 #else		/* Non LFN configuration */
-		if (!(FATFS_DIR[DIR_Attr] & AM_VOL) && !mem_cmp(FATFS_DIR, dp->fn, 11)) /* Is it a valid entry? */
+		if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */
 			break;
 #endif
 		res = dir_next(dp, 0);		/* Next entry */
@@ -1474,7 +1522,7 @@
 )
 {
 	FRESULT res;
-	BYTE a, c, *FATFS_DIR;
+	BYTE a, c, *dir;
 #if _USE_LFN
 	BYTE ord = 0xFF, sum = 0xFF;
 #endif
@@ -1483,24 +1531,24 @@
 	while (dp->sect) {
 		res = move_window(dp->fs, dp->sect);
 		if (res != FR_OK) break;
-		FATFS_DIR = dp->FATFS_DIR;					/* Ptr to the directory entry of current index */
-		c = FATFS_DIR[DIR_Name];
+		dir = dp->dir;					/* Ptr to the directory entry of current index */
+		c = dir[DIR_Name];
 		if (c == 0) { res = FR_NO_FILE; break; }	/* Reached to end of table */
-		a = FATFS_DIR[DIR_Attr] & AM_MASK;
+		a = dir[DIR_Attr] & AM_MASK;
 #if _USE_LFN	/* LFN configuration */
 		if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) {	/* An entry without valid data */
 			ord = 0xFF;
 		} else {
 			if (a == AM_LFN) {			/* An LFN entry is found */
 				if (c & LLEF) {			/* Is it start of LFN sequence? */
-					sum = FATFS_DIR[LDIR_Chksum];
+					sum = dir[LDIR_Chksum];
 					c &= ~LLEF; ord = c;
 					dp->lfn_idx = dp->index;
 				}
 				/* Check LFN validity and capture it */
-				ord = (c == ord && sum == FATFS_DIR[LDIR_Chksum] && pick_lfn(dp->lfn, FATFS_DIR)) ? ord - 1 : 0xFF;
+				ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF;
 			} else {					/* An SFN entry is found */
-				if (ord || sum != sum_sfn(FATFS_DIR))	/* Is there a valid LFN? */
+				if (ord || sum != sum_sfn(dir))	/* Is there a valid LFN? */
 					dp->lfn_idx = 0xFFFF;		/* It has no LFN. */
 				break;
 			}
@@ -1527,7 +1575,7 @@
 /*-----------------------------------------------------------------------*/
 #if !_FS_READONLY
 static
-FRESULT dir_register (	/* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */
+FRESULT dir_register (	/* FR_OK:succeeded, FR_DENIED:no free entry or too many SFN collision, FR_DISK_ERR:disk error */
 	FATFS_DIR* dp				/* Target directory with object name to be created */
 )
 {
@@ -1567,11 +1615,11 @@
 	if (res == FR_OK && --nent) {	/* Set LFN entry if needed */
 		res = dir_sdi(dp, dp->index - nent);
 		if (res == FR_OK) {
-			sum = sum_sfn(dp->fn);	/* Sum value of the SFN tied to the LFN */
+			sum = sum_sfn(dp->fn);	/* Checksum value of the SFN tied to the LFN */
 			do {					/* Store LFN entries in bottom first */
 				res = move_window(dp->fs, dp->sect);
 				if (res != FR_OK) break;
-				fit_lfn(dp->lfn, dp->FATFS_DIR, (BYTE)nent, sum);
+				fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum);
 				dp->fs->wflag = 1;
 				res = dir_next(dp, 0);	/* Next entry */
 			} while (res == FR_OK && --nent);
@@ -1584,10 +1632,10 @@
 	if (res == FR_OK) {				/* Set SFN entry */
 		res = move_window(dp->fs, dp->sect);
 		if (res == FR_OK) {
-			mem_set(dp->FATFS_DIR, 0, SZ_DIRE);	/* Clean the entry */
-			mem_cpy(dp->FATFS_DIR, dp->fn, 11);	/* Put SFN */
+			mem_set(dp->dir, 0, SZ_DIRE);	/* Clean the entry */
+			mem_cpy(dp->dir, dp->fn, 11);	/* Put SFN */
 #if _USE_LFN
-			dp->FATFS_DIR[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT);	/* Put NT flag */
+			dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT);	/* Put NT flag */
 #endif
 			dp->fs->wflag = 1;
 		}
@@ -1605,7 +1653,7 @@
 /*-----------------------------------------------------------------------*/
 #if !_FS_READONLY && !_FS_MINIMIZE
 static
-FRESULT dir_remove (	/* FR_OK: Successful, FR_DISK_ERR: A disk error */
+FRESULT dir_remove (	/* FR_OK:Succeeded, FR_DISK_ERR:A disk error */
 	FATFS_DIR* dp				/* Directory object pointing the entry to be removed */
 )
 {
@@ -1619,8 +1667,8 @@
 		do {
 			res = move_window(dp->fs, dp->sect);
 			if (res != FR_OK) break;
-			mem_set(dp->FATFS_DIR, 0, SZ_DIRE);	/* Clear and mark the entry "deleted" */
-			*dp->FATFS_DIR = DDEM;
+			mem_set(dp->dir, 0, SZ_DIRE);	/* Clear and mark the entry "deleted" */
+			*dp->dir = DDEM;
 			dp->fs->wflag = 1;
 			if (dp->index >= i) break;	/* When reached SFN, all entries of the object has been deleted. */
 			res = dir_next(dp, 0);		/* Next entry */
@@ -1633,8 +1681,8 @@
 	if (res == FR_OK) {
 		res = move_window(dp->fs, dp->sect);
 		if (res == FR_OK) {
-			mem_set(dp->FATFS_DIR, 0, SZ_DIRE);	/* Clear and mark the entry "deleted" */
-			*dp->FATFS_DIR = DDEM;
+			mem_set(dp->dir, 0, SZ_DIRE);	/* Clear and mark the entry "deleted" */
+			*dp->dir = DDEM;
 			dp->fs->wflag = 1;
 		}
 	}
@@ -1659,36 +1707,36 @@
 {
 	UINT i;
 	TCHAR *p, c;
-	BYTE *FATFS_DIR;
+	BYTE *dir;
 #if _USE_LFN
 	WCHAR w, *lfn;
 #endif
 
 	p = fno->fname;
 	if (dp->sect) {		/* Get SFN */
-		FATFS_DIR = dp->FATFS_DIR;
+		dir = dp->dir;
 		i = 0;
 		while (i < 11) {		/* Copy name body and extension */
-			c = (TCHAR)FATFS_DIR[i++];
+			c = (TCHAR)dir[i++];
 			if (c == ' ') continue;				/* Skip padding spaces */
 			if (c == RDDEM) c = (TCHAR)DDEM;	/* Restore replaced DDEM character */
 			if (i == 9) *p++ = '.';				/* Insert a . if extension is exist */
 #if _USE_LFN
-			if (IsUpper(c) && (FATFS_DIR[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY)))
+			if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY)))
 				c += 0x20;			/* To lower */
 #if _LFN_UNICODE
-			if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(FATFS_DIR[i]))
-				c = c << 8 | FATFS_DIR[i++];
+			if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i]))
+				c = c << 8 | dir[i++];
 			c = ff_convert(c, 1);	/* OEM -> Unicode */
 			if (!c) c = '?';
 #endif
 #endif
 			*p++ = c;
 		}
-		fno->fattrib = FATFS_DIR[DIR_Attr];				/* Attribute */
-		fno->fsize = LD_DWORD(FATFS_DIR + DIR_FileSize);	/* Size */
-		fno->fdate = LD_WORD(FATFS_DIR + DIR_WrtDate);	/* Date */
-		fno->ftime = LD_WORD(FATFS_DIR + DIR_WrtTime);	/* Time */
+		fno->fattrib = dir[DIR_Attr];				/* Attribute */
+		fno->fsize = LD_DWORD(dir + DIR_FileSize);	/* Size */
+		fno->fdate = LD_WORD(dir + DIR_WrtDate);	/* Date */
+		fno->ftime = LD_WORD(dir + DIR_WrtTime);	/* Time */
 	}
 	*p = 0;		/* Terminate SFN string by a \0 */
 
@@ -1744,7 +1792,7 @@
 
 
 static
-int pattern_matching (	/* Return value: 0:mismatched, 1:matched */
+int pattern_matching (	/* 0:mismatched, 1:matched */
 	const TCHAR* pat,	/* Matching pattern */
 	const TCHAR* nam,	/* String to be tested */
 	int skip,			/* Number of pre-skip chars (number of ?s) */
@@ -1788,11 +1836,11 @@
 
 
 /*-----------------------------------------------------------------------*/
-/* Pick a segment and create the object name in directory form           */
+/* Pick a top segment and create the object name in directory form       */
 /*-----------------------------------------------------------------------*/
 
 static
-FRESULT create_name (
+FRESULT create_name (	/* FR_OK: successful, FR_INVALID_NAME: could not create */
 	FATFS_DIR* dp,			/* Pointer to the directory object */
 	const TCHAR** path	/* Pointer to pointer to the segment in the path string */
 )
@@ -1830,22 +1878,21 @@
 	*path = &p[si];						/* Return pointer to the next segment */
 	cf = (w < ' ') ? NS_LAST : 0;		/* Set last segment flag if end of path */
 #if _FS_RPATH
-	if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */
-		(di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) {
+	if ((di == 1 && lfn[di - 1] == '.') ||
+		(di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) {	/* Is this segment a dot entry? */
 		lfn[di] = 0;
-		for (i = 0; i < 11; i++)
+		for (i = 0; i < 11; i++)		/* Create dot name for SFN entry */
 			dp->fn[i] = (i < di) ? '.' : ' ';
 		dp->fn[i] = cf | NS_DOT;		/* This is a dot entry */
 		return FR_OK;
 	}
 #endif
-	while (di) {						/* Strip trailing spaces and dots */
+	while (di) {						/* Snip off trailing spaces and dots if exist */
 		w = lfn[di - 1];
 		if (w != ' ' && w != '.') break;
 		di--;
 	}
 	if (!di) return FR_INVALID_NAME;	/* Reject nul string */
-
 	lfn[di] = 0;						/* LFN is created */
 
 	/* Create SFN in directory form */
@@ -1882,7 +1929,7 @@
 			cf |= NS_LFN;				/* Force create LFN entry */
 		}
 
-		if (_DF1S && w >= 0x100) {		/* DBC (always false at SBCS cfg) */
+		if (_DF1S && w >= 0x100) {		/* Is this DBC? (always false at SBCS cfg) */
 			if (i >= ni - 1) {
 				cf |= NS_LOSS | NS_LFN; i = ni; continue;
 			}
@@ -1903,7 +1950,7 @@
 		dp->fn[i++] = (BYTE)w;
 	}
 
-	if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM;	/* If the first character collides with deleted mark, replace it with RDDEM */
+	if (dp->fn[0] == DDEM) dp->fn[0] = RDDEM;	/* If the first character collides with DDEM, replace it with RDDEM */
 
 	if (ni == 8) b <<= 2;
 	if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03)	/* Create LFN entry when there are composite capitals */
@@ -1924,7 +1971,7 @@
 	const char *p;
 
 	/* Create file name in directory form */
-	for (p = *path; *p == '/' || *p == '\\'; p++) ;	/* Strip duplicated separator */
+	for (p = *path; *p == '/' || *p == '\\'; p++) ;	/* Skip duplicated separator */
 	sfn = dp->fn;
 	mem_set(sfn, ' ', 11);
 	si = i = b = 0; ni = 8;
@@ -1959,7 +2006,7 @@
 #endif
 #endif
 		}
-		if (IsDBCS1(c)) {				/* Check if it is a DBC 1st byte (always false on SBCS cfg) */
+		if (IsDBCS1(c)) {				/* Check if it is a DBC 1st byte (always false at SBCS cfg.) */
 			d = (BYTE)p[si++];			/* Get 2nd byte */
 			if (!IsDBCS2(d) || i >= ni - 1)	/* Reject invalid DBC */
 				return FR_INVALID_NAME;
@@ -2008,7 +2055,7 @@
 )
 {
 	FRESULT res;
-	BYTE *FATFS_DIR, ns;
+	BYTE *dir, ns;
 
 
 #if _FS_RPATH
@@ -2025,7 +2072,7 @@
 
 	if ((UINT)*path < ' ') {				/* Null path name is the origin directory itself */
 		res = dir_sdi(dp, 0);
-		dp->FATFS_DIR = 0;
+		dp->dir = 0;
 	} else {								/* Follow path */
 		for (;;) {
 			res = create_name(dp, &path);	/* Get a segment name of the path */
@@ -2035,7 +2082,7 @@
 			if (res != FR_OK) {				/* Failed to find the object */
 				if (res == FR_NO_FILE) {	/* Object is not found */
 					if (_FS_RPATH && (ns & NS_DOT)) {	/* If dot entry is not exist, */
-						dp->sclust = 0; dp->FATFS_DIR = 0;	/* it is the root directory and stay there */
+						dp->sclust = 0; dp->dir = 0;	/* it is the root directory and stay there */
 						if (!(ns & NS_LAST)) continue;	/* Continue to follow if not last segment */
 						res = FR_OK;					/* Ended at the root directroy. Function completed. */
 					} else {							/* Could not find the object */
@@ -2045,11 +2092,11 @@
 				break;
 			}
 			if (ns & NS_LAST) break;			/* Last segment matched. Function completed. */
-			FATFS_DIR = dp->FATFS_DIR;						/* Follow the sub-directory */
-			if (!(FATFS_DIR[DIR_Attr] & AM_DIR)) {	/* It is not a sub-directory and cannot follow */
+			dir = dp->dir;						/* Follow the sub-directory */
+			if (!(dir[DIR_Attr] & AM_DIR)) {	/* It is not a sub-directory and cannot follow */
 				res = FR_NO_PATH; break;
 			}
-			dp->sclust = ld_clust(dp->fs, FATFS_DIR);
+			dp->sclust = ld_clust(dp->fs, dir);
 		}
 	}
 
@@ -2125,7 +2172,7 @@
 /*-----------------------------------------------------------------------*/
 
 static
-BYTE check_fs (	/* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */
+BYTE check_fs (	/* 0:Valid FAT-BS, 1:Valid BS but not FAT, 2:Not a BS, 3:Disk error */
 	FATFS* fs,	/* File system object */
 	DWORD sect	/* Sector# (lba) to check if it is an FAT boot record or not */
 )
@@ -2283,7 +2330,7 @@
 	/* Get fsinfo if available */
 	fs->fsi_flag = 0x80;
 #if (_FS_NOFSINFO & 3) != 3
-	if (fmt == FS_FAT32				/* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */
+	if (fmt == FS_FAT32				/* Enable FSINFO only if FAT32 and BPB_FSInfo == 1 */
 		&& LD_WORD(fs->win + BPB_FSInfo) == 1
 		&& move_window(fs, bsect + 1) == FR_OK)
 	{
@@ -2329,14 +2376,11 @@
 	FIL *fil = (FIL*)obj;	/* Assuming offset of .fs and .id in the FIL/FATFS_DIR structure is identical */
 
 
-	if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id)
+	if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id || (disk_status(fil->fs->drv) & STA_NOINIT))
 		return FR_INVALID_OBJECT;
 
 	ENTER_FF(fil->fs);		/* Lock file system */
 
-	if (disk_status(fil->fs->drv) & STA_NOINIT)
-		return FR_NOT_READY;
-
 	return FR_OK;
 }
 
@@ -2347,7 +2391,7 @@
 
    Public Functions
 
---------------------------------------------------------------------------*/
+---------------------------------------------------------------------------*/
 
 
 
@@ -2410,7 +2454,7 @@
 {
 	FRESULT res;
 	FATFS_DIR dj;
-	BYTE *FATFS_DIR;
+	BYTE *dir;
 	DEFINE_NAMEBUF;
 #if !_FS_READONLY
 	DWORD dw, cl;
@@ -2431,10 +2475,10 @@
 	if (res == FR_OK) {
 		INIT_BUF(dj);
 		res = follow_path(&dj, path);	/* Follow the file path */
-		FATFS_DIR = dj.FATFS_DIR;
+		dir = dj.dir;
 #if !_FS_READONLY	/* R/W configuration */
 		if (res == FR_OK) {
-			if (!FATFS_DIR)	/* Default directory itself */
+			if (!dir)	/* Default directory itself */
 				res = FR_INVALID_NAME;
 #if _FS_LOCK
 			else
@@ -2451,10 +2495,10 @@
 					res = dir_register(&dj);
 #endif
 				mode |= FA_CREATE_ALWAYS;		/* File is created */
-				FATFS_DIR = dj.FATFS_DIR;					/* New entry */
+				dir = dj.dir;					/* New entry */
 			}
 			else {								/* Any object is already existing */
-				if (FATFS_DIR[DIR_Attr] & (AM_RDO | AM_DIR)) {	/* Cannot overwrite it (R/O or FATFS_DIR) */
+				if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) {	/* Cannot overwrite it (R/O or FATFS_DIR) */
 					res = FR_DENIED;
 				} else {
 					if (mode & FA_CREATE_NEW)	/* Cannot create as new file */
@@ -2462,12 +2506,13 @@
 				}
 			}
 			if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) {	/* Truncate it if overwrite mode */
-				dw = GET_FATTIME();				/* Created time */
-				ST_DWORD(FATFS_DIR + DIR_CrtTime, dw);
-				FATFS_DIR[DIR_Attr] = 0;				/* Reset attribute */
-				ST_DWORD(FATFS_DIR + DIR_FileSize, 0);/* size = 0 */
-				cl = ld_clust(dj.fs, FATFS_DIR);		/* Get start cluster */
-				st_clust(FATFS_DIR, 0);				/* cluster = 0 */
+				dw = GET_FATTIME();
+				ST_DWORD(dir + DIR_CrtTime, dw);/* Set created time */
+				ST_DWORD(dir + DIR_WrtTime, dw);/* Set modified time */
+				dir[DIR_Attr] = 0;				/* Reset attribute */
+				ST_DWORD(dir + DIR_FileSize, 0);/* Reset file size */
+				cl = ld_clust(dj.fs, dir);		/* Get cluster chain */
+				st_clust(dir, 0);				/* Reset cluster */
 				dj.fs->wflag = 1;
 				if (cl) {						/* Remove the cluster chain if exist */
 					dw = dj.fs->winsect;
@@ -2480,11 +2525,11 @@
 			}
 		}
 		else {	/* Open an existing file */
-			if (res == FR_OK) {					/* Follow succeeded */
-				if (FATFS_DIR[DIR_Attr] & AM_DIR) {	/* It is a directory */
+			if (res == FR_OK) {					/* Following succeeded */
+				if (dir[DIR_Attr] & AM_DIR) {	/* It is a directory */
 					res = FR_NO_FILE;
 				} else {
-					if ((mode & FA_WRITE) && (FATFS_DIR[DIR_Attr] & AM_RDO)) /* R/O violation */
+					if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */
 						res = FR_DENIED;
 				}
 			}
@@ -2493,7 +2538,7 @@
 			if (mode & FA_CREATE_ALWAYS)		/* Set file change flag if created or overwritten */
 				mode |= FA__WRITTEN;
 			fp->dir_sect = dj.fs->winsect;		/* Pointer to the directory entry */
-			fp->dir_ptr = FATFS_DIR;
+			fp->dir_ptr = dir;
 #if _FS_LOCK
 			fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0);
 			if (!fp->lockid) res = FR_INT_ERR;
@@ -2502,11 +2547,11 @@
 
 #else				/* R/O configuration */
 		if (res == FR_OK) {					/* Follow succeeded */
-			FATFS_DIR = dj.FATFS_DIR;
-			if (!FATFS_DIR) {						/* Current directory itself */
+			dir = dj.dir;
+			if (!dir) {						/* Current directory itself */
 				res = FR_INVALID_NAME;
 			} else {
-				if (FATFS_DIR[DIR_Attr] & AM_DIR)	/* It is a directory */
+				if (dir[DIR_Attr] & AM_DIR)	/* It is a directory */
 					res = FR_NO_FILE;
 			}
 		}
@@ -2516,8 +2561,8 @@
 		if (res == FR_OK) {
 			fp->flag = mode;					/* File access mode */
 			fp->err = 0;						/* Clear error flag */
-			fp->sclust = ld_clust(dj.fs, FATFS_DIR);	/* File start cluster */
-			fp->fsize = LD_DWORD(FATFS_DIR + DIR_FileSize);	/* File size */
+			fp->sclust = ld_clust(dj.fs, dir);	/* File start cluster */
+			fp->fsize = LD_DWORD(dir + DIR_FileSize);	/* File size */
 			fp->fptr = 0;						/* File pointer */
 			fp->dsect = 0;
 #if _USE_FASTSEEK
@@ -2686,7 +2731,7 @@
 				fp->clust = clst;			/* Update current cluster */
 				if (fp->sclust == 0) fp->sclust = clst;	/* Set start cluster if the first write */
 				
-#ifdef FLUSH_ON_NEW_CLUSTER
+#if FLUSH_ON_NEW_CLUSTER
                 // We do not need to flush for the first cluster
                 if (fp->fptr != 0) {
                     need_sync = true;
@@ -2726,7 +2771,7 @@
 #endif
 #endif
 				wcnt = SS(fp->fs) * cc;		/* Number of bytes transferred */
-#ifdef FLUSH_ON_NEW_SECTOR
+#if FLUSH_ON_NEW_SECTOR
                 need_sync = true;
 #endif
 				continue;
@@ -2764,7 +2809,7 @@
 	if (need_sync) {
         f_sync (fp);
     }
-	
+
 	LEAVE_FF(fp->fs, FR_OK);
 }
 
@@ -2781,15 +2826,14 @@
 {
 	FRESULT res;
 	DWORD tm;
-	BYTE *FATFS_DIR;
+	BYTE *dir;
 
 
 	res = validate(fp);					/* Check validity of the object */
 	if (res == FR_OK) {
-		if (fp->flag & FA__WRITTEN) {	/* Has the file been written? */
-			/* Write-back dirty buffer */
+		if (fp->flag & FA__WRITTEN) {	/* Is there any change to the file? */
 #if !_FS_TINY
-			if (fp->flag & FA__DIRTY) {
+			if (fp->flag & FA__DIRTY) {	/* Write-back cached data if needed */
 				if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK)
 					LEAVE_FF(fp->fs, FR_DISK_ERR);
 				fp->flag &= ~FA__DIRTY;
@@ -2798,13 +2842,13 @@
 			/* Update the directory entry */
 			res = move_window(fp->fs, fp->dir_sect);
 			if (res == FR_OK) {
-				FATFS_DIR = fp->dir_ptr;
-				FATFS_DIR[DIR_Attr] |= AM_ARC;					/* Set archive bit */
-				ST_DWORD(FATFS_DIR + DIR_FileSize, fp->fsize);	/* Update file size */
-				st_clust(FATFS_DIR, fp->sclust);					/* Update start cluster */
-				tm = GET_FATTIME();							/* Update updated time */
-				ST_DWORD(FATFS_DIR + DIR_WrtTime, tm);
-				ST_WORD(FATFS_DIR + DIR_LstAccDate, 0);
+				dir = fp->dir_ptr;
+				dir[DIR_Attr] |= AM_ARC;					/* Set archive bit */
+				ST_DWORD(dir + DIR_FileSize, fp->fsize);	/* Update file size */
+				st_clust(dir, fp->sclust);					/* Update start cluster */
+				tm = GET_FATTIME();							/* Update modified time */
+				ST_DWORD(dir + DIR_WrtTime, tm);
+				ST_WORD(dir + DIR_LstAccDate, 0);
 				fp->flag &= ~FA__WRITTEN;
 				fp->fs->wflag = 1;
 				res = sync_fs(fp->fs);
@@ -2896,11 +2940,11 @@
 		res = follow_path(&dj, path);		/* Follow the path */
 		FREE_BUF();
 		if (res == FR_OK) {					/* Follow completed */
-			if (!dj.FATFS_DIR) {
+			if (!dj.dir) {
 				dj.fs->cdir = dj.sclust;	/* Start directory itself */
 			} else {
-				if (dj.FATFS_DIR[DIR_Attr] & AM_DIR)	/* Reached to the directory */
-					dj.fs->cdir = ld_clust(dj.fs, dj.FATFS_DIR);
+				if (dj.dir[DIR_Attr] & AM_DIR)	/* Reached to the directory */
+					dj.fs->cdir = ld_clust(dj.fs, dj.dir);
 				else
 					res = FR_NO_PATH;		/* Reached but a file */
 			}
@@ -2939,13 +2983,13 @@
 			if (res != FR_OK) break;
 			res = dir_read(&dj, 0);
 			if (res != FR_OK) break;
-			dj.sclust = ld_clust(dj.fs, dj.FATFS_DIR);	/* Goto parent directory */
+			dj.sclust = ld_clust(dj.fs, dj.dir);	/* Goto parent directory */
 			res = dir_sdi(&dj, 0);
 			if (res != FR_OK) break;
 			do {							/* Find the entry links to the child directory */
 				res = dir_read(&dj, 0);
 				if (res != FR_OK) break;
-				if (ccl == ld_clust(dj.fs, dj.FATFS_DIR)) break;	/* Found the entry */
+				if (ccl == ld_clust(dj.fs, dj.dir)) break;	/* Found the entry */
 				res = dir_next(&dj, 0);	
 			} while (res == FR_OK);
 			if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */
@@ -3174,9 +3218,9 @@
 		res = follow_path(dp, path);			/* Follow the path to the directory */
 		FREE_BUF();
 		if (res == FR_OK) {						/* Follow completed */
-			if (dp->FATFS_DIR) {						/* It is not the origin directory itself */
-				if (dp->FATFS_DIR[DIR_Attr] & AM_DIR)	/* The object is a sub directory */
-					dp->sclust = ld_clust(fs, dp->FATFS_DIR);
+			if (dp->dir) {						/* It is not the origin directory itself */
+				if (dp->dir[DIR_Attr] & AM_DIR)	/* The object is a sub directory */
+					dp->sclust = ld_clust(fs, dp->dir);
 				else							/* The object is a file */
 					res = FR_NO_PATH;
 			}
@@ -3352,7 +3396,7 @@
 		INIT_BUF(dj);
 		res = follow_path(&dj, path);	/* Follow the file path */
 		if (res == FR_OK) {				/* Follow completed */
-			if (dj.FATFS_DIR) {		/* Found an object */
+			if (dj.dir) {		/* Found an object */
 				if (fno) get_fileinfo(&dj, fno);
 			} else {			/* It is root directory */
 				res = FR_INVALID_NAME;
@@ -3379,7 +3423,7 @@
 {
 	FRESULT res;
 	FATFS *fs;
-	DWORD n, clst, sect, stat;
+	DWORD nfree, clst, sect, stat;
 	UINT i;
 	BYTE fat, *p;
 
@@ -3394,18 +3438,17 @@
 		} else {
 			/* Get number of free clusters */
 			fat = fs->fs_type;
-			n = 0;
-			if (fat == FS_FAT12) {
+			nfree = 0;
+			if (fat == FS_FAT12) {	/* Sector unalighed entries: Search FAT via regular routine. */
 				clst = 2;
 				do {
 					stat = get_fat(fs, clst);
 					if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; }
 					if (stat == 1) { res = FR_INT_ERR; break; }
-					if (stat == 0) n++;
+					if (stat == 0) nfree++;
 				} while (++clst < fs->n_fatent);
-			} else {
-				clst = fs->n_fatent;
-				sect = fs->fatbase;
+			} else {				/* Sector alighed entries: Accelerate the FAT search. */
+				clst = fs->n_fatent; sect = fs->fatbase;
 				i = 0; p = 0;
 				do {
 					if (!i) {
@@ -3415,17 +3458,17 @@
 						i = SS(fs);
 					}
 					if (fat == FS_FAT16) {
-						if (LD_WORD(p) == 0) n++;
+						if (LD_WORD(p) == 0) nfree++;
 						p += 2; i -= 2;
 					} else {
-						if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++;
+						if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) nfree++;
 						p += 4; i -= 4;
 					}
 				} while (--clst);
 			}
-			fs->free_clust = n;
-			fs->fsi_flag |= 1;
-			*nclst = n;
+			fs->free_clust = nfree;	/* free_clust is valid */
+			fs->fsi_flag |= 1;		/* FSInfo is to be updated */
+			*nclst = nfree;			/* Return the free clusters */
 		}
 	}
 	LEAVE_FF(fs, res);
@@ -3500,7 +3543,7 @@
 {
 	FRESULT res;
 	FATFS_DIR dj, sdj;
-	BYTE *FATFS_DIR;
+	BYTE *dir;
 	DWORD dclst = 0;
 	DEFINE_NAMEBUF;
 
@@ -3516,16 +3559,16 @@
 		if (res == FR_OK) res = chk_lock(&dj, 2);	/* Cannot remove open object */
 #endif
 		if (res == FR_OK) {					/* The object is accessible */
-			FATFS_DIR = dj.FATFS_DIR;
-			if (!FATFS_DIR) {
+			dir = dj.dir;
+			if (!dir) {
 				res = FR_INVALID_NAME;		/* Cannot remove the origin directory */
 			} else {
-				if (FATFS_DIR[DIR_Attr] & AM_RDO)
+				if (dir[DIR_Attr] & AM_RDO)
 					res = FR_DENIED;		/* Cannot remove R/O object */
 			}
 			if (res == FR_OK) {
-				dclst = ld_clust(dj.fs, FATFS_DIR);
-				if (dclst && (FATFS_DIR[DIR_Attr] & AM_DIR)) {	/* Is it a sub-directory ? */
+				dclst = ld_clust(dj.fs, dir);
+				if (dclst && (dir[DIR_Attr] & AM_DIR)) {	/* Is it a sub-directory ? */
 #if _FS_RPATH
 					if (dclst == dj.fs->cdir) {		 		/* Is it the current directory? */
 						res = FR_DENIED;
@@ -3569,7 +3612,7 @@
 {
 	FRESULT res;
 	FATFS_DIR dj;
-	BYTE *FATFS_DIR, n;
+	BYTE *dir, n;
 	DWORD dsc, dcl, pcl, tm = GET_FATTIME();
 	DEFINE_NAMEBUF;
 
@@ -3592,34 +3635,34 @@
 				res = sync_window(dj.fs);
 			if (res == FR_OK) {					/* Initialize the new directory table */
 				dsc = clust2sect(dj.fs, dcl);
-				FATFS_DIR = dj.fs->win;
-				mem_set(FATFS_DIR, 0, SS(dj.fs));
-				mem_set(FATFS_DIR + DIR_Name, ' ', 11);	/* Create "." entry */
-				FATFS_DIR[DIR_Name] = '.';
-				FATFS_DIR[DIR_Attr] = AM_DIR;
-				ST_DWORD(FATFS_DIR + DIR_WrtTime, tm);
-				st_clust(FATFS_DIR, dcl);
-				mem_cpy(FATFS_DIR + SZ_DIRE, FATFS_DIR, SZ_DIRE); 	/* Create ".." entry */
-				FATFS_DIR[SZ_DIRE + 1] = '.'; pcl = dj.sclust;
+				dir = dj.fs->win;
+				mem_set(dir, 0, SS(dj.fs));
+				mem_set(dir + DIR_Name, ' ', 11);	/* Create "." entry */
+				dir[DIR_Name] = '.';
+				dir[DIR_Attr] = AM_DIR;
+				ST_DWORD(dir + DIR_WrtTime, tm);
+				st_clust(dir, dcl);
+				mem_cpy(dir + SZ_DIRE, dir, SZ_DIRE); 	/* Create ".." entry */
+				dir[SZ_DIRE + 1] = '.'; pcl = dj.sclust;
 				if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase)
 					pcl = 0;
-				st_clust(FATFS_DIR + SZ_DIRE, pcl);
+				st_clust(dir + SZ_DIRE, pcl);
 				for (n = dj.fs->csize; n; n--) {	/* Write dot entries and clear following sectors */
 					dj.fs->winsect = dsc++;
 					dj.fs->wflag = 1;
 					res = sync_window(dj.fs);
 					if (res != FR_OK) break;
-					mem_set(FATFS_DIR, 0, SS(dj.fs));
+					mem_set(dir, 0, SS(dj.fs));
 				}
 			}
 			if (res == FR_OK) res = dir_register(&dj);	/* Register the object to the directoy */
 			if (res != FR_OK) {
 				remove_chain(dj.fs, dcl);			/* Could not register, remove cluster chain */
 			} else {
-				FATFS_DIR = dj.FATFS_DIR;
-				FATFS_DIR[DIR_Attr] = AM_DIR;				/* Attribute */
-				ST_DWORD(FATFS_DIR + DIR_WrtTime, tm);	/* Created time */
-				st_clust(FATFS_DIR, dcl);					/* Table start cluster */
+				dir = dj.dir;
+				dir[DIR_Attr] = AM_DIR;				/* Attribute */
+				ST_DWORD(dir + DIR_WrtTime, tm);	/* Created time */
+				st_clust(dir, dcl);					/* Table start cluster */
 				dj.fs->wflag = 1;
 				res = sync_fs(dj.fs);
 			}
@@ -3645,12 +3688,11 @@
 {
 	FRESULT res;
 	FATFS_DIR dj;
-	BYTE *FATFS_DIR;
+	BYTE *dir;
 	DEFINE_NAMEBUF;
 
 
-	/* Get logical drive number */
-	res = find_volume(&dj.fs, &path, 1);
+	res = find_volume(&dj.fs, &path, 1);	/* Get logical drive number */
 	if (res == FR_OK) {
 		INIT_BUF(dj);
 		res = follow_path(&dj, path);		/* Follow the file path */
@@ -3658,12 +3700,12 @@
 		if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT))
 			res = FR_INVALID_NAME;
 		if (res == FR_OK) {
-			FATFS_DIR = dj.FATFS_DIR;
-			if (!FATFS_DIR) {						/* Is it a root directory? */
+			dir = dj.dir;
+			if (!dir) {						/* Is it a root directory? */
 				res = FR_INVALID_NAME;
 			} else {						/* File or sub directory */
 				mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC;	/* Valid attribute mask */
-				FATFS_DIR[DIR_Attr] = (attr & mask) | (FATFS_DIR[DIR_Attr] & (BYTE)~mask);	/* Apply attribute change */
+				dir[DIR_Attr] = (attr & mask) | (dir[DIR_Attr] & (BYTE)~mask);	/* Apply attribute change */
 				dj.fs->wflag = 1;
 				res = sync_fs(dj.fs);
 			}
@@ -3687,7 +3729,7 @@
 {
 	FRESULT res;
 	FATFS_DIR djo, djn;
-	BYTE buf[21], *FATFS_DIR;
+	BYTE buf[21], *dir;
 	DWORD dw;
 	DEFINE_NAMEBUF;
 
@@ -3704,10 +3746,10 @@
 		if (res == FR_OK) res = chk_lock(&djo, 2);
 #endif
 		if (res == FR_OK) {						/* Old object is found */
-			if (!djo.FATFS_DIR) {						/* Is root FATFS_DIR? */
+			if (!djo.dir) {						/* Is root dir? */
 				res = FR_NO_FILE;
 			} else {
-				mem_cpy(buf, djo.FATFS_DIR + DIR_Attr, 21);	/* Save information about object except name */
+				mem_cpy(buf, djo.dir + DIR_Attr, 21);	/* Save information about object except name */
 				mem_cpy(&djn, &djo, sizeof (FATFS_DIR));		/* Duplicate the directory object */
 				if (get_ldnumber(&path_new) >= 0)		/* Snip drive number off and ignore it */
 					res = follow_path(&djn, path_new);	/* and make sure if new object name is not conflicting */
@@ -3718,19 +3760,19 @@
 					res = dir_register(&djn);			/* Register the new entry */
 					if (res == FR_OK) {
 /* Start of critical section where any interruption can cause a cross-link */
-						FATFS_DIR = djn.FATFS_DIR;					/* Copy information about object except name */
-						mem_cpy(FATFS_DIR + 13, buf + 2, 19);
-						FATFS_DIR[DIR_Attr] = buf[0] | AM_ARC;
+						dir = djn.dir;					/* Copy information about object except name */
+						mem_cpy(dir + 13, buf + 2, 19);
+						dir[DIR_Attr] = buf[0] | AM_ARC;
 						djo.fs->wflag = 1;
-						if ((FATFS_DIR[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) {	/* Update .. entry in the sub-directory if needed */
-							dw = clust2sect(djo.fs, ld_clust(djo.fs, FATFS_DIR));
+						if ((dir[DIR_Attr] & AM_DIR) && djo.sclust != djn.sclust) {	/* Update .. entry in the sub-directory if needed */
+							dw = clust2sect(djo.fs, ld_clust(djo.fs, dir));
 							if (!dw) {
 								res = FR_INT_ERR;
 							} else {
 								res = move_window(djo.fs, dw);
-								FATFS_DIR = djo.fs->win + SZ_DIRE * 1;	/* Ptr to .. entry */
-								if (res == FR_OK && FATFS_DIR[1] == '.') {
-									st_clust(FATFS_DIR, djn.sclust);
+								dir = djo.fs->win + SZ_DIRE * 1;	/* Ptr to .. entry */
+								if (res == FR_OK && dir[1] == '.') {
+									st_clust(dir, djn.sclust);
 									djo.fs->wflag = 1;
 								}
 							}
@@ -3765,7 +3807,7 @@
 {
 	FRESULT res;
 	FATFS_DIR dj;
-	BYTE *FATFS_DIR;
+	BYTE *dir;
 	DEFINE_NAMEBUF;
 
 
@@ -3778,12 +3820,12 @@
 		if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT))
 			res = FR_INVALID_NAME;
 		if (res == FR_OK) {
-			FATFS_DIR = dj.FATFS_DIR;
-			if (!FATFS_DIR) {					/* Root directory */
+			dir = dj.dir;
+			if (!dir) {					/* Root directory */
 				res = FR_INVALID_NAME;
 			} else {					/* File or sub-directory */
-				ST_WORD(FATFS_DIR + DIR_WrtTime, fno->ftime);
-				ST_WORD(FATFS_DIR + DIR_WrtDate, fno->fdate);
+				ST_WORD(dir + DIR_WrtTime, fno->ftime);
+				ST_WORD(dir + DIR_WrtDate, fno->fdate);
 				dj.fs->wflag = 1;
 				res = sync_fs(dj.fs);
 			}
@@ -3833,13 +3875,13 @@
 #if _USE_LFN && _LFN_UNICODE
 				i = j = 0;
 				do {
-					w = (i < 11) ? dj.FATFS_DIR[i++] : ' ';
-					if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.FATFS_DIR[i]))
-						w = w << 8 | dj.FATFS_DIR[i++];
+					w = (i < 11) ? dj.dir[i++] : ' ';
+					if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i]))
+						w = w << 8 | dj.dir[i++];
 					label[j++] = ff_convert(w, 1);	/* OEM -> Unicode */
 				} while (j < 11);
 #else
-				mem_cpy(label, dj.FATFS_DIR, 11);
+				mem_cpy(label, dj.dir, 11);
 #endif
 				j = 11;
 				do {
@@ -3929,11 +3971,11 @@
 		res = dir_read(&dj, 1);		/* Get an entry with AM_VOL */
 		if (res == FR_OK) {			/* A volume label is found */
 			if (vn[0]) {
-				mem_cpy(dj.FATFS_DIR, vn, 11);	/* Change the volume label name */
+				mem_cpy(dj.dir, vn, 11);	/* Change the volume label name */
 				tm = GET_FATTIME();
-				ST_DWORD(dj.FATFS_DIR + DIR_WrtTime, tm);
+				ST_DWORD(dj.dir + DIR_WrtTime, tm);
 			} else {
-				dj.FATFS_DIR[0] = DDEM;			/* Remove the volume label */
+				dj.dir[0] = DDEM;			/* Remove the volume label */
 			}
 			dj.fs->wflag = 1;
 			res = sync_fs(dj.fs);
@@ -3943,11 +3985,11 @@
 				if (vn[0]) {				/* Create volume label as new */
 					res = dir_alloc(&dj, 1);	/* Allocate an entry for volume label */
 					if (res == FR_OK) {
-						mem_set(dj.FATFS_DIR, 0, SZ_DIRE);	/* Set volume label */
-						mem_cpy(dj.FATFS_DIR, vn, 11);
-						dj.FATFS_DIR[DIR_Attr] = AM_VOL;
+						mem_set(dj.dir, 0, SZ_DIRE);	/* Set volume label */
+						mem_cpy(dj.dir, vn, 11);
+						dj.dir[DIR_Attr] = AM_VOL;
 						tm = GET_FATTIME();
-						ST_DWORD(dj.FATFS_DIR + DIR_WrtTime, tm);
+						ST_DWORD(dj.dir + DIR_WrtTime, tm);
 						dj.fs->wflag = 1;
 						res = sync_fs(dj.fs);
 					}
@@ -4217,7 +4259,7 @@
 	ST_WORD(tbl + BS_55AA, 0xAA55);			/* Signature (Offset is fixed here regardless of sector size) */
 	if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK)	/* Write it to the VBR sector */
 		return FR_DISK_ERR;
-	if (fmt == FS_FAT32)					/* Write backup VBR if needed (VBR + 6) */
+	if (fmt == FS_FAT32)					/* Write it to the backup VBR if needed (VBR + 6) */
 		disk_write(pdrv, tbl, b_vol + 6, 1);
 
 	/* Initialize FAT area */
@@ -4647,4 +4689,3 @@
 
 #endif /* !_FS_READONLY */
 #endif /* _USE_STRFUNC */
-