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>
This commit is contained in:
Corinna Vinschen 2019-01-05 21:49:16 +01:00
parent 97d2fe2694
commit c208ecd540
1 changed files with 6 additions and 1 deletions

View File

@ -552,7 +552,12 @@ fhandler_base::open (int flags, mode_t mode)
syscall_printf ("(%S, %y)", pc.get_nt_native_path (), flags); 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; options = FILE_OPEN_FOR_BACKUP_INTENT;
switch (query_open ()) switch (query_open ())