* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Fetch number

of links and inode number only if path has good inodes.
	(fhandler_base::fstat_by_name): Fetch inode number only if path has
	good inodes.
This commit is contained in:
Corinna Vinschen 2010-09-15 11:26:10 +00:00
parent f859880a5b
commit 421ff3ff77
2 changed files with 27 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2010-09-15 Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Fetch number
of links and inode number only if path has good inodes.
(fhandler_base::fstat_by_name): Fetch inode number only if path has
good inodes.
2010-09-14 Corinna Vinschen <corinna@vinschen.de>
* path.cc (symlink_info::check): Make sure AllocationSize and EndOfFile

View File

@ -356,25 +356,30 @@ fhandler_base::fstat_by_handle (struct __stat64 *buf)
NTSTATUS status = 0;
IO_STATUS_BLOCK io;
status = NtQueryInformationFile (h, &io, &fsi, sizeof fsi,
FileStandardInformation);
if (!NT_SUCCESS (status))
if (!pc.hasgood_inode ())
fsi.NumberOfLinks = 1;
else
{
debug_printf ("%p = NtQueryInformationFile(%S, FileStandardInformation)",
status, pc.get_nt_native_path ());
return -1;
}
if (!ino && pc.hasgood_inode ())
{
status = NtQueryInformationFile (h, &io, &fii, sizeof fii,
FileInternalInformation);
status = NtQueryInformationFile (h, &io, &fsi, sizeof fsi,
FileStandardInformation);
if (!NT_SUCCESS (status))
{
debug_printf ("%p = NtQueryInformationFile(%S, FileInternalInformation)",
debug_printf ("%p = NtQueryInformationFile(%S, FileStandardInformation)",
status, pc.get_nt_native_path ());
return -1;
}
ino = fii.FileId.QuadPart;
if (!ino)
{
status = NtQueryInformationFile (h, &io, &fii, sizeof fii,
FileInternalInformation);
if (!NT_SUCCESS (status))
{
debug_printf ("%p = NtQueryInformationFile(%S, FileInternalInformation)",
status, pc.get_nt_native_path ());
return -1;
}
ino = fii.FileId.QuadPart;
}
}
return fstat_helper (buf, fsi.NumberOfLinks);
}
@ -393,7 +398,8 @@ fhandler_base::fstat_by_name (struct __stat64 *buf)
WCHAR buf[NAME_MAX + 1];
} fdi_buf;
if (!ino && wincap.has_fileid_dirinfo () && !pc.has_buggy_fileid_dirinfo ())
if (!ino && pc.hasgood_inode ()
&& wincap.has_fileid_dirinfo () && !pc.has_buggy_fileid_dirinfo ())
{
RtlSplitUnicodePath (pc.get_nt_native_path (), &dirname, &basename);
InitializeObjectAttributes (&attr, &dirname, pc.objcaseinsensitive (),