[PATCH v2 3/5] Cygwin: AF_LOCAL::fstatvfs: use our handle if O_PATH is set

Ken Brown kbrown@cornell.edu
Wed Jan 29 17:22:00 GMT 2020


If O_PATH is set, then the fhandler_socket_local object has a handle
that can be used for getting the statvfs information.  Use it by
calling fhandler_base::fstatvfs_by_handle.  Without this change,
fhandler_disk_file::fstatfvs would called on a new fhandler_disk
object, which would then have to be opened.
---
 winsup/cygwin/fhandler_socket_local.cc | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/winsup/cygwin/fhandler_socket_local.cc b/winsup/cygwin/fhandler_socket_local.cc
index e7f4fe603..76815a611 100644
--- a/winsup/cygwin/fhandler_socket_local.cc
+++ b/winsup/cygwin/fhandler_socket_local.cc
@@ -675,6 +675,13 @@ fhandler_socket_local::fstatvfs (struct statvfs *sfs)
 {
   if (get_sun_path () && get_sun_path ()[0] == '\0')
     return fhandler_socket_wsock::fstatvfs (sfs);
+  if (get_flags () & O_PATH)
+    /* We already have a handle. */
+    {
+      HANDLE h = get_handle ();
+      if (h)
+	return fstatvfs_by_handle (h, sfs);
+    }
   fhandler_disk_file fh (pc);
   fh.get_device () = FH_FS;
   return fh.fstatvfs (sfs);
-- 
2.21.0



More information about the Cygwin-patches mailing list