Skip to contentSkip to conversation

fat: kill reserved names

PATCH In review OGAWA Hirofumi 3 participants 5 messages Mar 29, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fat: kill reserved names

Since these names on old MSDOS is used as device, so, current fat driver doesn't allow a user to create those names. But many OSes and even Windows can create those names actually, now.

This patch removes the reserved name check.

---

 fs/msdos/namei.c |   15 +--------------
 fs/vfat/namei.c  |   18 ------------------
 2 files changed, 1 insertion(+), 32 deletions(-)
fs/msdos/namei.c renamed from fs/msdos/namei.c~fat-kill-reserved-names +1 -14
diff -puN fs/msdos/namei.c~fat-kill-reserved-names fs/msdos/namei.c
@@ -12,14 +12,6 @@
 #include <linux/msdos_fs.h>
 #include <linux/smp_lock.h>
 
-/* MS-DOS "device special files" */
-static const unsigned char *reserved_names[] = {
-	"CON     ", "PRN     ", "NUL     ", "AUX     ",
-	"LPT1    ", "LPT2    ", "LPT3    ", "LPT4    ",
-	"COM1    ", "COM2    ", "COM3    ", "COM4    ",
-	NULL
-};
-
 /* Characters that are undesirable in an MS-DOS file name */
 static unsigned char bad_chars[] = "*?<>|\"";
 static unsigned char bad_if_strict_pc[] = "+=,; ";
@@ -40,7 +32,6 @@ static int msdos_format_name(const unsig
 	 */
 {
 	unsigned char *walk;
-	const unsigned char **reserved;
 	unsigned char c;
 	int space;
 
@@ -127,11 +118,7 @@ static int msdos_format_name(const unsig
 	}
 	while (walk - res < MSDOS_NAME)
 		*walk++ = ' ';
-	if (!opts->atari)
-		/* GEMDOS is less stupid and has no reserved names */
-		for (reserved = reserved_names; *reserved; reserved++)
-			if (!strncmp(res, *reserved, 8))
-				return -EINVAL;
+
 	return 0;
 }
 
fs/vfat/namei.c renamed from fs/vfat/namei.c~fat-kill-reserved-names +0 -18
diff -puN fs/vfat/namei.c~fat-kill-reserved-names fs/vfat/namei.c
@@ -185,24 +185,6 @@ static int vfat_valid_longname(const uns
 		return -EINVAL;
 	if (len >= 256)
 		return -ENAMETOOLONG;
-
-	/* MS-DOS "device special files" */
-	if (len == 3 || (len > 3 && name[3] == '.')) {	/* basename == 3 */
-		if (!strnicmp(name, "aux", 3) ||
-		    !strnicmp(name, "con", 3) ||
-		    !strnicmp(name, "nul", 3) ||
-		    !strnicmp(name, "prn", 3))
-			return -EINVAL;
-	}
-	if (len == 4 || (len > 4 && name[4] == '.')) {	/* basename == 4 */
-		/* "com1", "com2", ... */
-		if ('1' <= name[3] && name[3] <= '9') {
-			if (!strnicmp(name, "com", 3) ||
-			    !strnicmp(name, "lpt", 3))
-				return -EINVAL;
-		}
-	}
-
 	return 0;
 }
 

_

#1 lore raw

Hello,

fs/msdos/namei.c line 20

Quoted 12 lines

Since these names on old MSDOS is used as device, so, current fat driver doesn't allow a user to create those names. But many OSes and even Windows can create those names actually, now.

This patch removes the reserved name check.

fs/msdos/namei.c renamed from fs/msdos/namei.c~fat-kill-reserved-names +0 -6
-/* MS-DOS "device special files" */
-static const unsigned char *reserved_names[] = {
-	"CON     ", "PRN     ", "NUL     ", "AUX     ",
-	"LPT1    ", "LPT2    ", "LPT3    ", "LPT4    ",
-	"COM1    ", "COM2    ", "COM3    ", "COM4    ",
-	NULL

Please don't :

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\>mkdir LPT1
The directory name is invalid.

Windows doesn't want these !!!

Regards,
Paul

#2 lore raw
Quoted 20 lines · Paul Rolland

Hello,

fs/msdos/namei.c line 20

Quoted 12 lines

Since these names on old MSDOS is used as device, so, current fat driver doesn't allow a user to create those names. But many OSes and even Windows can create those names actually, now.

This patch removes the reserved name check.

fs/msdos/namei.c renamed from fs/msdos/namei.c~fat-kill-reserved-names +0 -6
-/* MS-DOS "device special files" */
-static const unsigned char *reserved_names[] = {
-	"CON     ", "PRN     ", "NUL     ", "AUX     ",
-	"LPT1    ", "LPT2    ", "LPT3    ", "LPT4    ",
-	"COM1    ", "COM2    ", "COM3    ", "COM4    ",
-	NULL

Please don't :

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

Quoted 7 lines

D:\>mkdir LPT1
The directory name is invalid.

Windows doesn't want these !!!

Regards,
Paul

Well somebody else showed that it's the API that doesn't want those, not the file-system. So, if you have a file called AUX and you click on it, it will hang the machine until you Ctrl-Alr-Del to the Task manager and kill the task. This is supposed to be okay.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.15.4 on an i686 machine (5589.42 BogoMips). Warning : 98.36% of all statistics are fiction, book release in April. _


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

#3 lore raw

Hello,

Quoted 5 lines

Well somebody else showed that it's the API that doesn't want those, not the file-system. So, if you have a file called AUX and you click on it, it will hang the machine until you Ctrl-Alr-Del to the Task manager and kill the task. This is supposed to be okay.

Gasp, yes, I missed the thread Hirofumi mentionned to me... Must have been busy somewhere else at that time.

Sorry for the noise,
Regards,
Paul