[PATCH] V12 of experiment for a simpler path encoding for hashed paths (for "fncache2")

Adrian Buehlmann adrian at cadifra.com
Fri Sep 28 16:26:23 CDT 2012


On 2012-09-28 22:37, Bryan O'Sullivan wrote:
> On Fri, Sep 28, 2012 at 1:08 PM, Adrian Buehlmann <adrian at cadifra.com
> <mailto:adrian at cadifra.com>> wrote:
> 
>     +               if (src[i] == '/' || src[i] == '\0') {
>     +                       if (seglen != 0) {
>     +                               if (seglen == 3) {
>     +                                       cmp = seg[0] << 16 | seg[1]
>     << 8 | seg[2];
>     +                                       if (   cmp == 0x617578 /* aux */
> 
> 
> I believe that this no longer correctly handles name components that
> start with a reserved name, e.g. nul.txt?

Thanks for looking. I think V12 is correct.

V12 replaces periods and spaces with ~ *everywhere*. These are dangerous
characters.

The period in "nul.txt" is thus replaced with a tilde, so you get
"nul~txt", which is not a reserved name anymore.

The code decides it by len("nul~txt") is 7, which is != 3 and != 4.


I just tried on Windows 7 here: I can create and delete files named
"nul~txt" and "aux~txt" using explorer without any problems.

http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
says:

"Do not use the following reserved device names for the name of a file:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8,
COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also
avoid these names followed immediately by an extension; for example,
NUL.txt is not recommended."

"~txt" is not an extension.

HOWEVER:

I just noticed that *explorer* of Windows 7 aborts the operation with an
error message box reading "The specified name is invalid" when I try to
create a new file named "com0.txt" - even though "com0" is *not*
reserved according to that MS document. I can create a file with that
name using the command line (cmd.exe) just fine and explorer can then
delete, move and rename it. I can also copy a directory containing such
a file using explorer. But I cannot copy-drag that file in explorer
(just does nothing, no error). I can move-drag such a file though.

I think we should escape com0..com9 and lpt0..lpt9 (despite what the MS
document says).


More information about the Mercurial-devel mailing list