[newlib-cygwin] Cygwin: fhandler_base::open: allow to reopen file from handle
Corinna Vinschen
corinna@sourceware.org
Sun Jan 6 19:41:00 GMT 2019
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c208ecd540c02773b0d25246e0fbaadcd416600a
commit c208ecd540c02773b0d25246e0fbaadcd416600a
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Sat Jan 5 21:49:16 2019 +0100
Cygwin: fhandler_base::open: allow to reopen file from handle
So far io_handle is NULL when calling fhandler_base::open to
open or create a file. Add a check for io_handle to allow
priming the fhandler with a HANDLE value so we can reopen a
file from a HANDLE on file systems supporting it. This allows
to open already deleted files for further action. This will
be used by open("/proc/PID/fd/DESCRIPTOR") scenarios.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/fhandler.cc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index f7e34c7..01afdb2 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -552,7 +552,12 @@ fhandler_base::open (int flags, mode_t mode)
syscall_printf ("(%S, %y)", pc.get_nt_native_path (), flags);
- pc.get_object_attr (attr, *sec_none_cloexec (flags));
+ /* Allow to reopen from handle. This is utilized by
+ open ("/proc/PID/fd/DESCRIPTOR", ...); */
+ if (get_handle ())
+ pc.init_reopen_attr (attr, get_handle ());
+ else
+ pc.get_object_attr (attr, *sec_none_cloexec (flags));
options = FILE_OPEN_FOR_BACKUP_INTENT;
switch (query_open ())
More information about the Cygwin-cvs
mailing list