Invalid FilenamesinvalidFilenames
OverviewExploring some of the filenames you can't use in Windows and all the Unix variants (Linux, Mac OS X, etc). Windows has arbitrary restrictions (Old legacy device files that don't actually exist), whereas the Unix ones deal with introducing invalid characters. WindowsRecently Chris sent me a link to a paper describing Zombie OS Files in Windows. The short story is some seemingly straightforward names can not be used for a Windows file. The full list of names is: con, com, lpt, aux, prn, nul. This also includes some permutations like con1 and any extension like lpt.mp3 Experiment SetupTo test this I created a directory with 3 files called aux.txt, con.mp3, and goodFile.txt under Linux and placed it on a flash drive The following oddities occured:
DOS SessionOutput of a DOS session: Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\gblack>E: E:\>cd nameTest E:\nameTest>dir
Volume in drive E has no label.
Volume Serial Number is 7851-F135
Directory of E:\nameTest
07/16/2009 03:44 AM <DIR> .
07/16/2009 03:44 AM <DIR> ..
07/16/2009 03:21 AM 15 aux.txt
07/16/2009 03:21 AM 9,647,072 con.mp3
07/16/2009 03:45 AM 159,084 goodFile.txt
3 File(s) 9,806,171 bytes
2 Dir(s) 1,431,011,328 bytes free
E:\nameTest>dir aux.txt Directory of \\. File Not Found E:\nameTest>dir con.mp3 Directory of \\. File Not Found E:\nameTest>dir goodFilename.txt
Volume in drive E has no label.
Volume Serial Number is 7851-F135
Directory of E:\nameTest
07/16/2009 03:45 AM 159,084 goodFile.txt
1 File(s) 159,084 bytes
0 Dir(s) 1,431,011,328 bytes free
E:\nameTest>del aux.txt The filename, directory name, or volume label syntax is incorrect. E:\nameTest>del goodFile.txt E:\nameTest> Windows ConclusionThis is a silly bug, it was introduced to maintain backwards compatible with MS-DOS 2.0 over 20 years ago, and you'd think after the NT baseline was adopted it would be gone. At least there is always 0xDEADDEAD to reboot the thing :) UnixThere are only a couple of illegal characters for filenames, namely \0 (null character) and / for directories. Which is fine, since you can't do this, unless you write directly to the block devices. Experiment Setup
Linux Results(ext2 fs, 2.6 kernel)
Unix ConclusionThere are reasons you can't use / and \0 in filenames :) Doing preliminary testing in an OpenBSD VM completely crashed it, and I've spent too much time on this to explore it much more. Still interesting to see what fsck does and does not handle. Last Edited: 2010-10-24 18:50:38
+ Add a comment 7ecde511dded58151c674a1a910ea9622012-02-22 23:38:31.870064 UTC |
Posts
Source Code