mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-03 13:20:28 -05:00
Fix incorrect st_nlink inheritance from directory in Windows stream scanner
This commit is contained in:
parent
c9fbc058ef
commit
b113accaad
3 changed files with 18 additions and 8 deletions
|
|
@ -547,7 +547,12 @@ static int windows_stream2stat(const BY_HANDLE_FILE_INFORMATION* info, const FIL
|
|||
|
||||
st->st_ino = stream->FileId.QuadPart;
|
||||
|
||||
st->st_nlink = info->nNumberOfLinks;
|
||||
/*
|
||||
* FILE_ID_BOTH_DIR_INFO doesn't provide the hardlink count of the entry.
|
||||
* The BY_HANDLE_FILE_INFORMATION refers to the directory itself, so its
|
||||
* nNumberOfLinks cannot be used for the child.
|
||||
*/
|
||||
st->st_nlink = 0;
|
||||
|
||||
st->st_dev = info->dwVolumeSerialNumber;
|
||||
|
||||
|
|
|
|||
10
os/mingw.h
10
os/mingw.h
|
|
@ -409,11 +409,13 @@ int windows_closedir(windows_dir* dirstream);
|
|||
* Specifically this happens if we are using GetFileInformationByHandleEx()
|
||||
* to read the directory stream.
|
||||
*
|
||||
* The st_ino field may be 0 if it's not possible to read it in a fast way.
|
||||
* Specifically this happens if we are using FindFirst/FindNext to enumerate
|
||||
* the directory.
|
||||
* The st_ino and st_nlink fields may be 0 if the fast directory enumeration
|
||||
* API does not provide them. Specifically, st_ino is 0 with FindFirst/FindNext,
|
||||
* while st_nlink is 0 with both directory streams and FindFirst/FindNext.
|
||||
*
|
||||
* In such cases, call lstat_sync() to fill the missing fields.
|
||||
* If a missing field is actually needed by the caller, call lstat_sync()
|
||||
* to retrieve it from the file handle. Otherwise, avoid calling lstat_sync()
|
||||
* to preserve fast directory scanning performance.
|
||||
*/
|
||||
void windows_dirent_lstat(const struct windows_dirent* dd, struct windows_stat* st);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue