* fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Use handle

returned by get_stat_handle.
	(fhandler_base::fstat_helper): Reinstatiate code to re-open the file
	when checking for executability if called via fstat.  Explain why.
This commit is contained in:
Corinna Vinschen 2010-06-15 15:10:42 +00:00
parent 5a0d1edba4
commit 342814df29
2 changed files with 36 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2010-06-15 Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Use handle
returned by get_stat_handle.
(fhandler_base::fstat_helper): Reinstatiate code to re-open the file
when checking for executability if called via fstat. Explain why.
2010-06-15 Corinna Vinschen <corinna@vinschen.de> 2010-06-15 Corinna Vinschen <corinna@vinschen.de>
* dtable.cc (dtable::dup_worker): Reset path_conv handle in duplicated * dtable.cc (dtable::dup_worker): Reset path_conv handle in duplicated

View File

@ -294,7 +294,7 @@ fhandler_base::fstat_by_nfs_ea (struct __stat64 *buf)
fgei_buf.fgei.NextEntryOffset = 0; fgei_buf.fgei.NextEntryOffset = 0;
fgei_buf.fgei.EaNameLength = sizeof (NFS_V3_ATTR) - 1; fgei_buf.fgei.EaNameLength = sizeof (NFS_V3_ATTR) - 1;
stpcpy (fgei_buf.fgei.EaName, NFS_V3_ATTR); stpcpy (fgei_buf.fgei.EaName, NFS_V3_ATTR);
status = NtQueryEaFile (get_handle (), &io, status = NtQueryEaFile (get_stat_handle (), &io,
&ffei_buf.ffei, sizeof ffei_buf, TRUE, &ffei_buf.ffei, sizeof ffei_buf, TRUE,
&fgei_buf.fgei, sizeof fgei_buf, NULL, TRUE); &fgei_buf.fgei, sizeof fgei_buf, NULL, TRUE);
if (NT_SUCCESS (status)) if (NT_SUCCESS (status))
@ -674,10 +674,34 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
{ {
LARGE_INTEGER off = { QuadPart:0LL }; LARGE_INTEGER off = { QuadPart:0LL };
char magic[3]; char magic[3];
NTSTATUS status; NTSTATUS status = 0;
IO_STATUS_BLOCK io; IO_STATUS_BLOCK io;
bool opened = false;
if (get_stat_access () & (GENERIC_READ | FILE_READ_DATA)) if (h == get_handle ())
{
/* We have been opened via fstat. We have to re-open the
file. Either the file is not opened for reading, or the
read will change the file position. */
OBJECT_ATTRIBUTES attr;
if (pc.fs_is_nwfs ())
InitializeObjectAttributes (&attr, pc.get_nt_native_path (),
OBJ_CASE_INSENSITIVE,
NULL, NULL)
else
InitializeObjectAttributes (&attr, &ro_u_empty, 0,
get_handle (), NULL);
status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA,
&attr, &io, FILE_SHARE_VALID_FLAGS,
FILE_OPEN_FOR_BACKUP_INTENT
| FILE_OPEN_REPARSE_POINT);
if (!NT_SUCCESS (status))
debug_printf ("%p = NtOpenFile(%S)", status,
pc.get_nt_native_path ());
else
opened = true;
}
if (NT_SUCCESS (status))
{ {
status = NtReadFile (h, NULL, NULL, NULL, status = NtReadFile (h, NULL, NULL, NULL,
&io, magic, 3, &off, NULL); &io, magic, 3, &off, NULL);
@ -692,6 +716,8 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
buf->st_mode |= STD_XBITS; buf->st_mode |= STD_XBITS;
} }
} }
if (opened)
NtClose (h);
} }
} }
if (pc.exec_state () == is_executable) if (pc.exec_state () == is_executable)