Skip to contentSkip to conversation

FAT: Add FAT_NO_83NAME flag

PATCH New [email protected] 1 participant 2 messages Jul 21, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 FAT: Add FAT_NO_83NAME flag

This is the first of two patches which attempt to address the technical concerns raised by the previous round of VFAT patent workaround patches.

This patch adds a new flag field 'FAT_NO_83NAME' for FAT files. When this flag is set on an 8.3 FAT entry, both the MSDOS and VFAT filesystems will skip the entry. For MSDOS this makes the file inaccessible. For VFAT it makes the file only accessible by the long filename.

The justification for this patch is to provide a clean way to distinguish files created on VFAT filesystems with long filenames but without a 8.3 short name. It uses a unused bit in the FAT directory entry to store the FAT_NO_83NAME flag.

This patch, combined with the following VFAT_FS_NO_DUALNAMES patch, address the following technical issues found with the last series of patches:

- Fixed problems with Win98, although some cosmetic issues remain
- Fixed problems with all tested MP3 players and similar devices
- Lowers the probability of a WinXP bluescreen by a factor of about 80x
- Fixed problems with mtools, although some cosmetic issues remain that require a small mtools patch to fix

More details and testing tools are available at

http://kernel.org/pub/linux/kernel/people/tridge/VFAT/

---
 fs/fat/dir.c             |   14 ++++++++++++++
 include/linux/msdos_fs.h |    1 +
 2 files changed, 15 insertions(+), 0 deletions(-)
fs/fat/dir.c +14 -0
index 38ff75a..902e84c 100644
@@ -385,6 +385,13 @@ parse_record:
 				goto end_of_dir;
 		}
 
+		/*
+		 * The FAT_NO_83NAME flag is used to mark files
+		 * created with no 8.3 short name
+		 */
+		if (de->lcase & FAT_NO_83NAME)
+			goto compare_longname;
+
 		memcpy(work, de->name, sizeof(de->name));
 		/* see namei.c, msdos_format_name */
 		if (work[0] == 0x05)
@@ -429,6 +436,7 @@ parse_record:
 		if (fat_name_match(sbi, name, name_len, bufname, len))
 			goto found;
 
+compare_longname:
 		if (nr_slots) {
 			void *longname = unicode + FAT_MAX_UNI_CHARS;
 			int size = PATH_MAX - FAT_MAX_UNI_SIZE;
@@ -530,6 +538,8 @@ parse_record:
 		if (de->attr != ATTR_EXT && IS_FREE(de->name))
 			goto record_end;
 	} else {
+		if (de->lcase & FAT_NO_83NAME)
+			goto record_end;
 		if ((de->attr & ATTR_VOLUME) || IS_FREE(de->name))
 			goto record_end;
 	}
@@ -935,6 +945,10 @@ int fat_scan(struct inode *dir, const unsigned char *name,
 	sinfo->bh = NULL;
 	while (fat_get_short_entry(dir, &sinfo->slot_off, &sinfo->bh,
 				   &sinfo->de) >= 0) {
+		/* skip files marked as having no 8.3 short name  */
+		if (sinfo->de->lcase & FAT_NO_83NAME)
+			continue;
+
 		if (!strncmp(sinfo->de->name, name, MSDOS_NAME)) {
 			sinfo->slot_off -= sizeof(*sinfo->de);
 			sinfo->nr_slots = 1;
include/linux/msdos_fs.h +1 -0
index ce38f1c..639e6a4 100644
@@ -43,6 +43,7 @@
 
 #define CASE_LOWER_BASE	8	/* base is lower case */
 #define CASE_LOWER_EXT	16	/* extension is lower case */
+#define FAT_NO_83NAME	32	/* no 8.3 short filename for this file */
 
 #define DELETED_FLAG	0xe5	/* marks file as deleted when in name[0] */
 #define IS_FREE(n)	(!*(n) || *(n) == DELETED_FLAG)
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 2/2 FAT: Add CONFIG_VFAT_FS_NO_DUALNAMES option

This is the second of two patches which attempt to address the technical concerns raised by the previous round of VFAT patent workaround patches.

This patch adds a new config option VFAT_FS_NO_DUALNAMES. When VFAT_FS_NO_DUALNAMES is enabled, VFAT will never create a file with both a long and a short filename. If a long filename is needed, then dummy bytes are stored in the 8.3 entry, and the 8.3 entry is marked as having no short name using the FAT_NO_83NAME flag.

This patch is similar in concept to the previously posted dualnames patch, but changes the bytes put in the 8.3 directory entry when long filenames are created. The new values work with Win98, MP3 players and other devices that have been tested.

This patch depends on the FAT_NO_83NAME flag added in the first patch in this series.

More details and testing tools are available at

http://kernel.org/pub/linux/kernel/people/tridge/VFAT/

---
 fs/fat/Kconfig      |   21 +++++++++++++
 fs/fat/namei_vfat.c |   83 +++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 102 insertions(+), 2 deletions(-)
fs/fat/Kconfig +21 -0
index 182f9ff..d1c10a1 100644
@@ -74,6 +74,27 @@ config VFAT_FS
 	  To compile this as a module, choose M here: the module will be called
 	  vfat.
 
+config VFAT_FS_NO_DUALNAMES
+	bool "disable VFAT dual names support (patent workaround)"
+	depends on VFAT_FS
+	help
+	  This option disables support for dual filenames on VFAT filesystems.
+	  If this option is enabled then file creation will either put
+	  a short (8.3) name or a long name on the file, but never both.
+	  The field where a shortname would normally go is filled with
+	  invalid characters such that it cannot be considered a valid
+	  short filename.
+
+	  That means that long filenames created with this option
+	  disabled will not be accessible at all to operating systems
+	  that do not understand the FAT long filename extensions.
+
+	  Users considering disabling this option should consider the
+	  implications of any patents that may exist on dual filenames
+	  in VFAT.
+
+	  If unsure, say N
+
 config FAT_DEFAULT_CODEPAGE
 	int "Default codepage for FAT"
 	depends on MSDOS_FS || VFAT_FS
fs/fat/namei_vfat.c +81 -2

114 lines not on this page · raw message

Signature · 1 line
1.6.0.4