#4458 file stat fails on locked files on win32

obsolete: 8.6b1
closed-fixed
Jan Nijtmans
6
2013-03-19
2009-11-07
Pat Thoyts
No

On Windows the page file c:\pagefile.sys is always open and locked. In NativeAccess we try using GetFileAttributes but this will return ERROR_SHARING_VIOLATION and -1, leading Tcl to believe the file does not exist. Similar code is in NativeStat fails for the same reason. So we cannot currently test for the existence or size or mtime for this file. However if we then try FindFirstFile for the pathname we can get this information even though the file is in use.
The attached patch tries FindFirstFile when GetFIleAttributes fails. GFA is a bit faster on my system than FFF so I prefer to only try this when necessary. I've not checked for the GetLastError() code as well as I don't know if other error codes might still be appropriate for continuing to check using FFF.

Discussion

  • Pat Thoyts
    Pat Thoyts
    2009-11-07

    patch file

     
    Attachments
  • Pat Thoyts
    Pat Thoyts
    2009-11-24

    • status: open --> closed-fixed
     
  • Pat Thoyts
    Pat Thoyts
    2009-11-24

    I have applied this patch with a new test to the HEAD 8.6 code.

     
  • Jan Nijtmans
    Jan Nijtmans
    2013-03-19

    • assigned_to: vincentdarley --> nijtmans
    • status: closed-fixed --> open
     
  • Jan Nijtmans
    Jan Nijtmans
    2013-03-19

    Had to back out this patch, because of bug [3608360]: Incompatible behaviour of "file exists".

     
  • Jan Nijtmans
    Jan Nijtmans
    2013-03-19

    I would prefer another solution for this problem. If GetFileAttributes() returns
    ERROR_SHARING_VIOLATION, then we know that the file exists but
    is not readable and not writable. Let's thread that as a special case.

     
  • Jan Nijtmans
    Jan Nijtmans
    2013-03-19

    • status: open --> closed-fixed
     
  • Jan Nijtmans
    Jan Nijtmans
    2013-03-19

    Fixed now on all branches.