diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2019-01-05 21:49:16 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2019-01-06 20:30:14 +0100 |
commit | c208ecd540c02773b0d25246e0fbaadcd416600a (patch) | |
tree | bc0d8430612cd3358fa58da0e0748ed1e465f708 | |
parent | 97d2fe2694ce935bc295ad6107ce9c7de55285b8 (diff) | |
download | cygnal-c208ecd540c02773b0d25246e0fbaadcd416600a.tar.gz cygnal-c208ecd540c02773b0d25246e0fbaadcd416600a.tar.bz2 cygnal-c208ecd540c02773b0d25246e0fbaadcd416600a.zip |
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>
-rw-r--r-- | winsup/cygwin/fhandler.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index f7e34c746..01afdb29b 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 ()) |