aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Innes1998-11-03 22:39:04 +0000
committerAndrew Innes1998-11-03 22:39:04 +0000
commit01f31dfb5ff5a47079541350fb62adfc97f10838 (patch)
treec3e4f345dd84ad8e92035618390482cea91b0a2b /src
parent8cd2ac8d1a48b76dff855f969234a9071854bf5a (diff)
downloademacs-01f31dfb5ff5a47079541350fb62adfc97f10838.tar.gz
emacs-01f31dfb5ff5a47079541350fb62adfc97f10838.zip
(stat): GetFileInformationByHandle can legitimately fail, so don't
rely on it succeeding.
Diffstat (limited to 'src')
-rw-r--r--src/w32.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/w32.c b/src/w32.c
index 8ec2670a2bf..1a4f632ad3f 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1960,19 +1960,6 @@ stat (const char * path, struct stat * buf)
1960 1960
1961 if (GetFileInformationByHandle (fh, &info)) 1961 if (GetFileInformationByHandle (fh, &info))
1962 { 1962 {
1963 switch (GetFileType (fh))
1964 {
1965 case FILE_TYPE_DISK:
1966 buf->st_mode = _S_IFREG;
1967 break;
1968 case FILE_TYPE_PIPE:
1969 buf->st_mode = _S_IFIFO;
1970 break;
1971 case FILE_TYPE_CHAR:
1972 case FILE_TYPE_UNKNOWN:
1973 default:
1974 buf->st_mode = _S_IFCHR;
1975 }
1976 buf->st_nlink = info.nNumberOfLinks; 1963 buf->st_nlink = info.nNumberOfLinks;
1977 /* Might as well use file index to fake inode values, but this 1964 /* Might as well use file index to fake inode values, but this
1978 is not guaranteed to be unique unless we keep a handle open 1965 is not guaranteed to be unique unless we keep a handle open
@@ -1980,13 +1967,27 @@ stat (const char * path, struct stat * buf)
1980 not unique). Reputedly, there are at most 48 bits of info 1967 not unique). Reputedly, there are at most 48 bits of info
1981 (on NTFS, presumably less on FAT). */ 1968 (on NTFS, presumably less on FAT). */
1982 fake_inode = info.nFileIndexLow ^ info.nFileIndexHigh; 1969 fake_inode = info.nFileIndexLow ^ info.nFileIndexHigh;
1983 CloseHandle (fh);
1984 } 1970 }
1985 else 1971 else
1986 { 1972 {
1987 errno = EACCES; 1973 buf->st_nlink = 1;
1988 return -1; 1974 fake_inode = 0;
1989 } 1975 }
1976
1977 switch (GetFileType (fh))
1978 {
1979 case FILE_TYPE_DISK:
1980 buf->st_mode = _S_IFREG;
1981 break;
1982 case FILE_TYPE_PIPE:
1983 buf->st_mode = _S_IFIFO;
1984 break;
1985 case FILE_TYPE_CHAR:
1986 case FILE_TYPE_UNKNOWN:
1987 default:
1988 buf->st_mode = _S_IFCHR;
1989 }
1990 CloseHandle (fh);
1990 } 1991 }
1991 else 1992 else
1992 { 1993 {