diff options
author | Ron Yorston <rmy@pobox.com> | 2019-02-19 10:59:45 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-02-19 10:59:45 +0000 |
commit | 8c47a98c9166ff23c3bcbb3e1ef8430b349cf71e (patch) | |
tree | aebfe98490659a3882dc2d391a15ea2d95c7e8b4 /win32 | |
parent | 4d47580175918882dd827183569d6a50f460f00a (diff) | |
download | busybox-w32-8c47a98c9166ff23c3bcbb3e1ef8430b349cf71e.tar.gz busybox-w32-8c47a98c9166ff23c3bcbb3e1ef8430b349cf71e.tar.bz2 busybox-w32-8c47a98c9166ff23c3bcbb3e1ef8430b349cf71e.zip |
win32: stat(2) succeeds if fetching extra metadata fails
Some files can't be opened to fetch additional metadata. When
that happens allow stat(2) to successfully return what data it
has.
In a few cases where the inode number is used to determine if
files are identical ignore invalid inode numbers.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 3713fea95..84522d3ea 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -441,22 +441,14 @@ static int do_lstat(int follow, const char *file_name, struct mingw_stat *buf) | |||
441 | #if ENABLE_FEATURE_EXTRA_FILE_DATA | 441 | #if ENABLE_FEATURE_EXTRA_FILE_DATA |
442 | fh = CreateFile(file_name, 0, 0, NULL, OPEN_EXISTING, | 442 | fh = CreateFile(file_name, 0, 0, NULL, OPEN_EXISTING, |
443 | FILE_FLAG_BACKUP_SEMANTICS, NULL); | 443 | FILE_FLAG_BACKUP_SEMANTICS, NULL); |
444 | if (fh == INVALID_HANDLE_VALUE) | 444 | if (fh != INVALID_HANDLE_VALUE && |
445 | goto error; | 445 | GetFileInformationByHandle(fh, &hdata)) { |
446 | |||
447 | if (GetFileInformationByHandle(fh, &hdata)) { | ||
448 | buf->st_dev = hdata.dwVolumeSerialNumber; | 446 | buf->st_dev = hdata.dwVolumeSerialNumber; |
449 | buf->st_ino = hdata.nFileIndexLow | | 447 | buf->st_ino = hdata.nFileIndexLow | |
450 | (((ino_t)hdata.nFileIndexHigh)<<32); | 448 | (((ino_t)hdata.nFileIndexHigh)<<32); |
451 | buf->st_nlink = S_ISDIR(buf->st_mode) ? 2 : hdata.nNumberOfLinks; | 449 | buf->st_nlink = S_ISDIR(buf->st_mode) ? 2 : hdata.nNumberOfLinks; |
452 | CloseHandle(fh); | ||
453 | } | ||
454 | else { | ||
455 | error: | ||
456 | errno = err_win_to_posix(GetLastError()); | ||
457 | CloseHandle(fh); | ||
458 | return -1; | ||
459 | } | 450 | } |
451 | CloseHandle(fh); | ||
460 | #endif | 452 | #endif |
461 | 453 | ||
462 | /* | 454 | /* |