Pages

Sunday, July 23, 2006

windows folder creation surprise from kerneltrap_org

Posted by venkatesh on Monday, October 10, 2005 - 04:53
It was dicovered that nobody can create a folder named as "con" in windows.
This is something pretty cool...and unbelievable...
Note : This should be through & in windows only.
If any one have solution or reason why it happens , let me also know please.

MS-DOS that's the problem!
Comment posted by Anonymous (not verified) on Monday, October 10, 2005 - 12:18
hmm, have you tried to create a folder named "com1" "lpt1" "com2" ... it shouldn't work either!

"con" is a _old_ MS-DOS stuff!

I found how to create a folde
Comment posted by Venkat (not verified) on Wednesday, October 12, 2005 - 14:52
I found how to create a folder or file named CON , LPT1 , COM1 etc...

STEP1: goto command prompt

STEP2: type in prompt e:\> "mkdir \\.\e:\con"

STEP3: verify by typing "dir \\.\e:\con"

STEP4: delete the file or folder "rmdir \\.\e:\con"

it will work like this md Comment posted by yash (not verified) on Wednesday, March 8, 2006 - 21:44
it will work like this
md \\.\\c:\con
dir c:
rd \\.\\c:\con

Please explain
Comment posted by Anonymous (not verified) on Monday, October 17, 2005 - 03:52
Yes, it is working, but I would very thankful to you if you could tell me HOW?
I don't understand anything in it
what \\. means in DOS?
thanks,
sam

UNC
Comment posted by strcmp on Monday, October 17, 2005 - 05:16
This is a UNC path (see http://en.wikipedia.org/wiki/Universal_Naming_Convention). Because these didn't exist under pure DOS, they don't have to be backward compatible (and \\remotehost\drive:\con doesn't make sense anyway, because without having a process on the remote host, there is no current 'console'). It would be a security hazard as well, having the serial and parallel ports accessible for everyone who is allowed to read or write in any single directory.

http://forums.whirlpool.net.a
Comment posted by ruza on Tuesday, October 11, 2005 - 03:10
http://forums.whirlpool.net.au/forum-replies-archive.cfm/409278.html

The following reserved device names cannot be used as the name of a file:

CON, PRN, AUX, CLOCK$, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.

You must avoid using these names as a file name suffix or file name body, so you have to avoid names such as aux.c, file.aux or NUL.txt.

This actually is a unix-like feature. DOS device drivers are accessible like normal files, i.e. the everything-is-a-file philosophy. CON is the equivalent of /dev/tty, NUL of /dev/null, COM# of /dev/ttyS#, LPT# of /dev/lp# and CLOCK$ corresponds to /dev/rtc (PRN is an alias to LPT1, AUX is COM1). Every character device can be opened this way, block devices (which are assumed to be FAT formatted...) are named A: to Z:, as you will know. Many pseudo character devices (drivers which had to be loaded as drivers but were no character devices, like EMM386, HIMEM.SYS, ..) had forbidden characters like '*' in their device names to be hidden from the user.

The only problem is: DOS 1, which introduced CON, NUL, PRN and AUX had no directories, i.e. no /dev/, so for compatibility with old DOS1-executables (which don't know that they live in a directory) the character devices have to exist in every directory. Don't know why this feature was not limited to FCB (CP/M like) file access, unix like file numbers were introduced together with directories in DOS 2 (actually the MS programmers had Xenix machines on their desks, I heard)..
For a period of time, DOS allowed referencing these files through the directory \DEV, even if \DEV didn't exist. I think they may've intended to deprecate the "available in every directory" behavior, but in the end it got too much inertia behind it.


I'm surprised at the level of comments in this thread. There are other, more appropriate sites for "M$ IS TEH SUX0R" debates.

If you want to learn a few details on why CON, AUX, et al are considered reserved filenames, then continue reading.

Start with the MSDN documentation on file naming. It provides the list of reserved file names. It also explains the "\\?\D:\foo" syntax, with focus on overcoming the MAX_PATH length limitations in the ANSI APIs.

What it doesn't do is tie these ideas together. (It also doesn't mention the "\\.\" prefix, but it basically works like "\\?\".)

In NT-based versions of Windows (NT 3.1-4.0, Win2K, WinXP, Vista, etc) Win32 is implemented as a subsystem on top of the NT OS. One function of this subsystem is to translate filenames and pathnames from the Win32 object namespace to the NT object namespace. It is in this translation layer that the reserved names are handled. (This is also where concepts like "current directory" and "relative paths" are implemented.)

The "\\?\d:\foo" syntax provides a way to bypass the translation mechanism. This is why relative paths are not permitted using this syntax. This is also why you can create files with "Win32 reserved names" using this syntax.

The reserved names "feature" is done for backwards compability with Win16 and DOS applications. Modern versions of Windows and still run 16-bit applications via the included Virtual DOS Machine (VDM). Also, the initial Win32 APIs were, whenever possible, a simple 32-bit "widening" of the 16-bit APIs. I suspect 32-bit support for these reserved names was included to ease the porting of 16-bit apps.

The connection between reserved names and "\\?\d:\foo" may be subtle and not documented very clearly, but there's no magic, no conspiracy, no "MS FORGOT TO REMOVE SOME DOS CODE" mistakes. It may seem unnecessary now, but the industry was very different 16 years ago when Win32 was designed.

I now return you to kerneltrap, and (hopefully) something more relevant to OSS.

Watch out for long path names on an NTFS volume From MarkWilson_co_uk

Watch out for long path names on an NTFS volume

I came across an interesting issue earlier today. Somehow, on my NTFS-formatted external hard disk I had managed to create a file system structure which was too deep.

Whenever I tried to delete a particular folder tree, I received strange errors about files which couldn't be deleted:

Error Deleting File or Folder

Cannot delete foldername: The file name you specified is not valid or too long. Specify a different file name.

I thought that was strange - after all, I'd managed to create the files in the first place, then I found that if I drilled down to the files that would not delete, there was no right-click option to delete the file. Finally, I found that some folders displayed the following error when I tried to access them:

Can't access this folder.

Path is too long.

It turned out that the problem folders/files had path names in excess of 255 characters. By renaming some of the top level folders to single character folder names (thus reducing the length of the path), I was able to access the problem files and folders, including deleting the files that I wanted to remove.

Posted @ 22:28 (Permanent link)
View/add comments (15 comments added previously) | Backlinks | E-mail this post to someone

Comments
Posted by jstratton @ 22 November, 2005 21:47:
Damn good thinking! I never thought to rename the folders (my first inclination was to use DSL (Damn Small Linux), but your solution keeps me in Gate's reach.

Thanks!


Posted by Sean Duncan @ 23 November, 2005 05:50:
Thanks, I never thought of renaming the folders either.


Posted by Anonymous @ 25 November, 2005 08:32:
There should be some shareware somewhere that will seek this out and let you fix it in advance. As said, maddening because you could create the path in the first place. I'd love to know all the paths on my hard drive which are 'too long' in advance. I think modern Windows conventions where "My Documents" is buried deep within other folders (c:\files and documents\users\admin\etc\etc\my documents) contributes to this.


Posted by Allen Garcia @ 10 January, 2006 19:57:
Brillant Many Thanks Problem Fixed Grate Soultion


Posted by doug @ 14 January, 2006 21:46:
Brilliant, I had the same problem, eventually reformatted the external ntfs hard drive!! ... and then read your solution after :~(


Posted by Mark @ 23 January, 2006 16:36:
Don Thompson e-mailed me to let me know that the maximum path length depends on the method of access. It seems that UNC paths can be significantly longer than mapped drive paths.


Posted by Sarath Chandra K @ 17 February, 2006 10:13:
Can only repeat. Damn good thinking.
Too cool. Thanks for the solution, saved a huge effort for me.


Posted by Anonymous @ 27 February, 2006 12:14:
Maybe robocopy could be used to generate an error report using the /256 switch, and presumably /ndl /nfl and nocopy switches? You can send the results to a file.

- worth a try, got the idea here:

http://www.windowsitpro.com/Windows/Articles/ArticleID/44324/pg/2/2.html


Posted by Anonymous @ 27 February, 2006 12:17:
that link should be

http://www.windowsitpro.com/Windows/Articles
/ArticleID/44324/pg/2/2.html

you can paste it in the browser bar in bits!

helpful


Posted by Anonymous @ 28 February, 2006 11:21:
furthermore http://www.langa.com/newsletters
/2005/2005-08-25.htm

has an item, and links to

http://www.herve-thouzard.com/modules
/wfsection/article.php?articleid=1

helpful


Posted by Anonymous @ 28 February, 2006 12:36:
There is a downloadable perl solution here,

http://www.windowsitpro.com/
WindowsScripting/Article/
ArticleID/7828/7828.html

you can specify the threshold of pathname length above which you want a report

the zip file contains a small readme file but no massive explanantions

perl can be downloaded www.activestate.com (incl msi package)

helpful


Posted by Anonymous @ 28 February, 2006 14:42:
I just used the 7828.pl file zipped in the download mentioned above:
works fine. I just opened the .pl file with a text editor and put my own paths in - it's explained by the author anyway inside th .pl file.

My longest path was 231 characters and likely to expand (you know how it happens, someone creates a folder "fotherington-smythe's archive sent by e-mail to Thomas, Thomas and Thomas on 30 February 2006").
Now every path is back under 200 characters, and users have been alerted to what I only estimated previously.


Posted by Anonymous @ 28 February, 2006 14:59:
p.s. Won't robocopy copy everything anyway? Or move it with the /mov switch, or delete it by copying an empty folder to the top location of the part of the tree you want to erase and you using the /purge switch - you will then get a list of "extra" files and folders deleted below that location. or use the /mov switch to the NUL directory to delete stuff (I never got that one to work yet, but I have seen claims it does - i have no idea about syntax).

This is my lunchtime backup
AT 13:00 /every:M,T,W,Th,F C:\WINDOWS\system32\robocopy.exe \\server\share\ c:\backup\ /xf *.tmp /xf ~$*.* /s /e /zb /purge /nfl /ndl /log:c:\Logs\lunchtime.txt

it synchs a day's work in minutes - I run it to a different network hard-drive each day to keep a weeks backups "right there", uses hardly any bandwidth. I probably don't need the /zb switch.

Helpful?


Posted by Anonymous @ 20 May, 2006 03:56:
I had this exact problem while trying to back up files onto my Maxtor External hard drive. I was puzzled until today. I found a great app on Download.com called File and MP3 Renamer 2005
http://www.download.com/File-and-MP3-Renamer-2005/3000-2248_4-10482097.html?tag=lst-4-3

It lets you trim file names by a certain # of characters, or to a maximum length. And it can do them from the left or right side of the file name. It has many more ways of changing file names than that but I just went for the basic right-side file name trim.

The only thing it can't do is find all files whose path names exceeds a certain length. Also, while the app can do hundreds or thousands of files at a time by trimming all files in a folder and its sub-folders, it does tend to crash if you do too many. So I couldn't do my entire MyDocuments folder and all subfolders at once.

The only other quibble I would have is the interface is a bit unclear, namely that the buttons might say "Do this folder" and you might think that pressing it will choose that option, when in fact it then selects the OTHER option, that is, "Do this and all sub-folders at once".

But it's free for a 10-day trial and works great. I'm backing up my files right now with Retrospect without getting that uber-annoying "path name too long" message!


Posted by Dus10 D @ 21 June, 2006 15:09:
Thanks for that advise. Somehow, a seemingly endless nested directory structure was created of directories named "2003". I am unsure how it even allows them to be created in the first place. My guess is that when files/directories are created, their blocks are allocated first, and then their name is placed in the file header, and then it is placed in its path within the filesystem. That seems like a possibility, at least.

Tuesday, July 04, 2006

Everybody Hurts :: by R.E.M.

When your day is long and the night, the night is yours alone,


when you're sure you've had enough of this life, well hang on.


Don't let yourself go, everybody cries and everybody hurts sometimes.





Sometimes everything is wrong. Now it's time to sing along.


When your day is night alone, (hold on, hold on)


if you feel like letting go, (hold on)


when you think you've had too much of this life, well hang on.





Everybody hurts. Take comfort in your friends.


Everybody hurts. Don't throw your hand. Oh, no. Don't throw your


hand.


If you feel like you're alone, no, no, no, you are not alone





If you're on your own in this life, the days and nights are long,


when you think you've had too much of this life to hang on.





Well, everybody hurts sometimes,


everybody cries. And everybody hurts sometimes.


And everybody hurts sometimes. So, hold on, hold on.


Hold on, hold on. Hold on, hold on. Hold on, hold on. (repeat & fade)


(Everybody hurts. You are not alone.)