simplePerson43
simplePerson43

Reputation: 3873

in BY_HANDLE_FILE_INFORMATION structure what is nNumberOfLinks

in the doc, they have mentioned that nNumberOfLinks is "The number of links to this file. For the FAT file system, this member is always 1. For the NTFS file system, it can be more than 1."

The number of links to the file means what ? if that file used as the destination of 3 symlinks then nNumberOfLinks is 3 . or it has some other meaning.

Upvotes: 2

Views: 349

Answers (1)

Make that 4
Make that 4

Reputation: 256

Looking into the implementation of GetFileInformationByHandle in the ReactOS source code, https://doxygen.reactos.org/da/d02/dll_2win32_2kernel32_2client_2file_2fileinfo_8c_source.html We can see the field nNumberOfLinks gets populated as follows (error checking removed).

errCode = NtQueryInformationFile(hFile,
                &IoStatusBlock,
                &FileStandard,
                sizeof(FILE_STANDARD_INFORMATION),
                FileStandardInformation);
lpFileInformation->nNumberOfLinks = FileStandard.NumberOfLinks;

As per the documentation of FILE_STANDARD_INFORMATION https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_file_standard_information.

NumberOfLinks

The number of hard links to the file.

So nNumberOfLinks will be the number of hard links, as mentioned by dxiv in the comments.

Upvotes: 1

Related Questions