# HG changeset patch # User Andrew Innes # Date 910132744 0 # Node ID 0dc79ede9c531912440ecae863cdbd3151b7b658 # Parent 82325b2dbb5ef956b1040594ebb852f87af42f2b (stat): GetFileInformationByHandle can legitimately fail, so don't rely on it succeeding. diff -r 82325b2dbb5e -r 0dc79ede9c53 src/w32.c --- a/src/w32.c Tue Nov 03 22:26:56 1998 +0000 +++ b/src/w32.c Tue Nov 03 22:39:04 1998 +0000 @@ -1960,19 +1960,6 @@ if (GetFileInformationByHandle (fh, &info)) { - switch (GetFileType (fh)) - { - case FILE_TYPE_DISK: - buf->st_mode = _S_IFREG; - break; - case FILE_TYPE_PIPE: - buf->st_mode = _S_IFIFO; - break; - case FILE_TYPE_CHAR: - case FILE_TYPE_UNKNOWN: - default: - buf->st_mode = _S_IFCHR; - } buf->st_nlink = info.nNumberOfLinks; /* Might as well use file index to fake inode values, but this is not guaranteed to be unique unless we keep a handle open @@ -1980,13 +1967,27 @@ not unique). Reputedly, there are at most 48 bits of info (on NTFS, presumably less on FAT). */ fake_inode = info.nFileIndexLow ^ info.nFileIndexHigh; - CloseHandle (fh); } else { - errno = EACCES; - return -1; + buf->st_nlink = 1; + fake_inode = 0; } + + switch (GetFileType (fh)) + { + case FILE_TYPE_DISK: + buf->st_mode = _S_IFREG; + break; + case FILE_TYPE_PIPE: + buf->st_mode = _S_IFIFO; + break; + case FILE_TYPE_CHAR: + case FILE_TYPE_UNKNOWN: + default: + buf->st_mode = _S_IFCHR; + } + CloseHandle (fh); } else {