This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH v2 3/5] Cygwin: AF_LOCAL::fstatvfs: use our handle if O_PATH is set
- From: Ken Brown <kbrown at cornell dot edu>
- To: "cygwin-patches at cygwin dot com" <cygwin-patches at cygwin dot com>
- Date: Wed, 29 Jan 2020 17:22:12 +0000
- Subject: [PATCH v2 3/5] Cygwin: AF_LOCAL::fstatvfs: use our handle if O_PATH is set
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kGjM4usv95dg+ADzv6Sk7I4nZyBD5O4eX/6DmjhgH3k=; b=dA9A2Ji0vJIALyIAxiNk7jy289akMkBP1CYdE0dzfVQtfGUgBdCIrVMOH+U/uKZNw1mNlQht0JxTP0Fm4a4uQLDXSPi2bAKDt0hadq07YmxHNdyKN4JJxz56T1WAkued00dd7f96bG6xGDm0JRUV9jhF+HvmfwyUhA8/zUThvuNMWXPocrUt55WsuB6cvoFgeG20w1nyYHoRHfTh6r/8FUWGlyq4dR+pX0ottI6lVtcgMt6m3lkMrvtJOExZN8UJEm6qRm79J8/zfRLffJt7vZQqL74RhtHouUImwIDHE37YRvFl4NdEADUXzRasBEISEWHXiGkG5FXbUYbXdEOI7g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HcaAkDswSw1K92fegguAgE9IavDZhG9ePyDKZmY6NabyGpnCrQnyhA/BW9KnZJSuJf4P0dVt5DHHQ42S3C2gAdcfOUS5erREuaZ9yGdE/q06+NIOXnywfNQkkGX/zWowjPalpTaojCvfImy70ruQYR7ZvXmdNZur0r6nlwGAGUjyGRbieyIwNwHe78mSR4w4pkIMhh6AnT3k+RTagKb96CB0n/l2OZSS76qJ41hKrYNZXXaIYLoLcTKT4iDKrFGdWkR25rhZNlxdoBqLiJY7KMWXpqndbJR1+YX7i4AqRxAo9JhEDKkrdlWx24KYVjvGXe3YgfUHcfoQl9GSUcotug==
- References: <20200129172147.1566-1-kbrown@cornell.edu>
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