From 1da77c2678b3f69f2bc212e79df6432a9fffb61c Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sat, 2 Oct 2010 19:03:44 +0000 Subject: [PATCH] * fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Simplify. Just call nfs_fetch_fattr3 if called via fstat. * nfs.cc (nfs_fetch_fattr3): New function to fetch NFS fattr3 info from file handle. * nfs.h (nfs_fetch_fattr3): Declare. * path.cc (symlink_info::check): Simplify NFS case. Just call nfs_fetch_fattr3. --- winsup/cygwin/ChangeLog | 10 ++++++++++ winsup/cygwin/fhandler_disk_file.cc | 21 +------------------ winsup/cygwin/nfs.cc | 31 ++++++++++++++++++++++++++++- winsup/cygwin/nfs.h | 4 +++- winsup/cygwin/path.cc | 25 +++-------------------- 5 files changed, 47 insertions(+), 44 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c8648c192..a0b5bbe38 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2010-09-02 Corinna Vinschen + + * fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Simplify. + Just call nfs_fetch_fattr3 if called via fstat. + * nfs.cc (nfs_fetch_fattr3): New function to fetch NFS fattr3 info from + file handle. + * nfs.h (nfs_fetch_fattr3): Declare. + * path.cc (symlink_info::check): Simplify NFS case. Just call + nfs_fetch_fattr3. + 2010-09-02 Corinna Vinschen * fhandler_procsys.cc (fhandler_procsys::exists): Return virt_none diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 7f314ed19..13ed5ed5e 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -293,16 +293,6 @@ path_conv::ndisk_links (DWORD nNumberOfLinks) int __stdcall fhandler_base::fstat_by_nfs_ea (struct __stat64 *buf) { - NTSTATUS status; - IO_STATUS_BLOCK io; - struct { - FILE_FULL_EA_INFORMATION ffei; - char buf[sizeof (NFS_V3_ATTR) + sizeof (fattr3)]; - } ffei_buf; - struct { - FILE_GET_EA_INFORMATION fgei; - char buf[sizeof (NFS_V3_ATTR)]; - } fgei_buf; fattr3 *nfs_attr = pc.nfsattr (); if (get_io_handle ()) @@ -314,16 +304,7 @@ fhandler_base::fstat_by_nfs_ea (struct __stat64 *buf) NFS client. */ if (get_access () & GENERIC_WRITE) FlushFileBuffers (get_io_handle ()); - - fgei_buf.fgei.NextEntryOffset = 0; - fgei_buf.fgei.EaNameLength = sizeof (NFS_V3_ATTR) - 1; - stpcpy (fgei_buf.fgei.EaName, NFS_V3_ATTR); - status = NtQueryEaFile (get_io_handle (), &io, - &ffei_buf.ffei, sizeof ffei_buf, TRUE, - &fgei_buf.fgei, sizeof fgei_buf, NULL, TRUE); - if (NT_SUCCESS (status)) - nfs_attr = (fattr3 *) (ffei_buf.ffei.EaName - + ffei_buf.ffei.EaNameLength + 1); + nfs_fetch_fattr3 (get_io_handle (), nfs_attr); } buf->st_dev = nfs_attr->fsid; buf->st_ino = nfs_attr->fileid; diff --git a/winsup/cygwin/nfs.cc b/winsup/cygwin/nfs.cc index 46face17e..32d9ad2bf 100644 --- a/winsup/cygwin/nfs.cc +++ b/winsup/cygwin/nfs.cc @@ -1,6 +1,6 @@ /* nfs.cc - Copyright 2008 Red Hat, Inc. + Copyright 2008, 2010 Red Hat, Inc. This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for @@ -9,6 +9,7 @@ details. */ #include "winsup.h" #include "sys/fcntl.h" #include "nfs.h" +#include "ntdll.h" struct nfs_aol_ffei_t nfs_aol_ffei = { 0, 0, sizeof (NFS_ACT_ON_LINK) - 1, 0, NFS_ACT_ON_LINK }; @@ -16,3 +17,31 @@ struct nfs_aol_ffei_t nfs_aol_ffei = { 0, 0, sizeof (NFS_ACT_ON_LINK) - 1, 0, uint32_t nfs_type_mapping[] = { 0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, S_IFSOCK, S_IFIFO }; +NTSTATUS +nfs_fetch_fattr3 (HANDLE h, fattr3 *fattr_buf) +{ + struct { + FILE_FULL_EA_INFORMATION ffei; + char buf[sizeof (NFS_V3_ATTR) + sizeof (fattr3)]; + } ffei_buf; + struct { + FILE_GET_EA_INFORMATION fgei; + char buf[sizeof (NFS_V3_ATTR)]; + } fgei_buf; + NTSTATUS status; + IO_STATUS_BLOCK io; + + fgei_buf.fgei.NextEntryOffset = 0; + fgei_buf.fgei.EaNameLength = sizeof (NFS_V3_ATTR) - 1; + stpcpy (fgei_buf.fgei.EaName, NFS_V3_ATTR); + status = NtQueryEaFile (h, &io, &ffei_buf.ffei, sizeof ffei_buf, TRUE, + &fgei_buf.fgei, sizeof fgei_buf, NULL, TRUE); + if (NT_SUCCESS (status)) + { + fattr3 *nfs_attr = (fattr3 *) (ffei_buf.ffei.EaName + + ffei_buf.ffei.EaNameLength + 1); + if (fattr_buf) + memcpy (fattr_buf, nfs_attr, sizeof (fattr3)); + } + return status; +} diff --git a/winsup/cygwin/nfs.h b/winsup/cygwin/nfs.h index 657126f78..f185fe0b1 100644 --- a/winsup/cygwin/nfs.h +++ b/winsup/cygwin/nfs.h @@ -1,6 +1,6 @@ /* nfs.h - Copyright 2008 Red Hat, Inc. + Copyright 2008, 2010 Red Hat, Inc. This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for @@ -53,3 +53,5 @@ struct nfs_aol_ffei_t { extern struct nfs_aol_ffei_t nfs_aol_ffei; extern uint32_t nfs_type_mapping[]; + +extern NTSTATUS nfs_fetch_fattr3 (HANDLE h, fattr3 *fattr_buf); diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 8c98e4dab..bc655c84f 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2404,29 +2404,10 @@ restart: { if (fs.is_nfs ()) { - struct { - FILE_FULL_EA_INFORMATION ffei; - char buf[sizeof (NFS_V3_ATTR) + sizeof (fattr3)]; - } ffei_buf; - struct { - FILE_GET_EA_INFORMATION fgei; - char buf[sizeof (NFS_V3_ATTR)]; - } fgei_buf; - - fgei_buf.fgei.NextEntryOffset = 0; - fgei_buf.fgei.EaNameLength = sizeof (NFS_V3_ATTR) - 1; - stpcpy (fgei_buf.fgei.EaName, NFS_V3_ATTR); - status = NtQueryEaFile (h, &io, &ffei_buf.ffei, sizeof ffei_buf, - TRUE, &fgei_buf.fgei, sizeof fgei_buf, - NULL, TRUE); + status = nfs_fetch_fattr3 (h, conv_hdl.nfsattr ()); if (NT_SUCCESS (status)) - { - fattr3 *nfs_attr = (fattr3 *) - (ffei_buf.ffei.EaName + ffei_buf.ffei.EaNameLength + 1); - memcpy (conv_hdl.nfsattr (), nfs_attr, sizeof (fattr3)); - fileattr = ((nfs_attr->type & 7) == NF3DIR) - ? FILE_ATTRIBUTE_DIRECTORY : 0; - } + fileattr = ((conv_hdl.nfsattr ()->type & 7) == NF3DIR) + ? FILE_ATTRIBUTE_DIRECTORY : 0; } else {