Each file is identified by an unique ID in the file system. On linux, this ID "inode number" can be obtained with ls command. To obtain inode number of "foobar.txt" (that reside at NTFS storage), type as follows:

$ ls -i /media/32C0C7B1C0C77A1D/foobar.txt
35 foobar.txt
$ 

You can see "35" is this file's inode number.

On NTFS, the ID is called File reference number (FileRef#). To obtain FileRef# of "foobar.txt", type as follows:

> fsutil usn readdata f:\foobar.txt
Major Version    : 0x2
Minor Version    : 0x0
FileRef#         : 0x0001000000000023
Parent FileRef#  : 0x0005000000000005
Usn              : 0x0000000000000000
Time Stamp       : 0x0000000000000000 0:00:00 1601/01/01
Reason           : 0x0
Source Info      : 0x0
Security Id      : 0x0
File Attributes  : 0x20
File Name Length : 0x14
File Name Offset : 0x3c
FileName         : foobar.txt

You can see "0x0001000000000023" is this file's FileRef#. Same FileRef# value was obtained by using GetFileInformationByHandle() function:


BY_HANDLE_FILE_INFORMATION fileInfo;
HANDLE hFile;

hFile = CreateFile(TEXT("f:\\foobar.txt"),
                   GENERIC_READ,
                   FILE_SHARE_READ,
                   NULL,
                   OPEN_EXISTING,
                   FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_READONLY,
                   NULL);
GetFileInformationByHandle(hFile, &fileInfo);
fileID = (ULONGLONG)((fileInfo.nFileIndexLow) | (((ULONGLONG)fileInfo.nFileIndexHigh) << 32));

In addition, I obtained inode number with MSYS's ls command.

> c:\msys\1.0\bin\ls.exe -i f:\foobar.txt
65571 f:\foobar.txt
> 

I was surprised the inode number obtained by MSYS's ls is different from one obtained by Linux's ls. The above results were summarized as follows:

inode# & FileRef# of "foobar.txt" on NTFS storage
Type of File IDDecimal formatHex format
inode# obtained by linux's ls350x00000023
inode# obtained by MSYS's ls655710x00010023
FileRef# obtained by fsutil command2814749767106910x0001000000000023

See also