aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-03-17 10:21:12 +0000
committerRon Yorston <rmy@pobox.com>2018-03-17 10:21:12 +0000
commit2cbc61ac77a4e661ad97143c3f53db55506d8349 (patch)
treec798fc22e4ed0e4a2f274e58100ab8cbb87dfaca
parent701cea96c43d185ebe433df9ecca39ecc9742ef3 (diff)
downloadbusybox-w32-2cbc61ac77a4e661ad97143c3f53db55506d8349.tar.gz
busybox-w32-2cbc61ac77a4e661ad97143c3f53db55506d8349.tar.bz2
busybox-w32-2cbc61ac77a4e661ad97143c3f53db55506d8349.zip
win32: try harder to get file attributes
Reading the attributes of files like c:/pagefile.sys fails with error code ERROR_SHARING_VIOLATION, which breaks 'ls'. If this happens try an alternative API call to get the attributes. See GitHub issue #101.
-rw-r--r--win32/mingw.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/win32/mingw.c b/win32/mingw.c
index 7fe5a6f05..ee549c311 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -286,6 +286,22 @@ static inline int get_file_attr(const char *fname, WIN32_FILE_ATTRIBUTE_DATA *fd
286 if (GetFileAttributesExA(fname, GetFileExInfoStandard, fdata)) 286 if (GetFileAttributesExA(fname, GetFileExInfoStandard, fdata))
287 return 0; 287 return 0;
288 288
289 if (GetLastError() == ERROR_SHARING_VIOLATION) {
290 HANDLE hnd;
291 WIN32_FIND_DATA fd;
292
293 if ((hnd=FindFirstFile(fname, &fd)) != INVALID_HANDLE_VALUE) {
294 fdata->dwFileAttributes = fd.dwFileAttributes;
295 fdata->ftCreationTime = fd.ftCreationTime;
296 fdata->ftLastAccessTime = fd.ftLastAccessTime;
297 fdata->ftLastWriteTime = fd.ftLastWriteTime;
298 fdata->nFileSizeHigh = fd.nFileSizeHigh;
299 fdata->nFileSizeLow = fd.nFileSizeLow;
300 FindClose(hnd);
301 return 0;
302 }
303 }
304
289 switch (GetLastError()) { 305 switch (GetLastError()) {
290 case ERROR_ACCESS_DENIED: 306 case ERROR_ACCESS_DENIED:
291 case ERROR_SHARING_VIOLATION: 307 case ERROR_SHARING_VIOLATION: