Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2018-12-26 23:22:40 +0300
committerCorinna Vinschen <corinna@vinschen.de>2018-12-27 00:16:24 +0300
commit7148fbc49688986b3648ba6ce3f2afd527d8baa0 (patch)
tree2fe4734294dbc58d49773cf403c1eb7221830280
parent4cd209e921ceab5cf5a5cc5abc3ff62ecc462d33 (diff)
Cygwin: Change /proc/$PID/fd/<fd> symlink target for deleted files
- As on Linux, print the file name with an attached " (deleted)" Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/fhandler.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 22dbdb05d..f7e34c746 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -137,11 +137,23 @@ fhandler_base::set_name (path_conv &in_pc)
char *fhandler_base::get_proc_fd_name (char *buf)
{
+ IO_STATUS_BLOCK io;
+ FILE_STANDARD_INFORMATION fsi;
+
/* If the file had been opened with O_TMPFILE | O_EXCL, don't
expose the filename. linkat is supposed to return ENOENT in this
- case. See man 2 open on Linux. */
- if ((get_flags () & (O_TMPFILE | O_EXCL)) == (O_TMPFILE | O_EXCL))
- return strcpy (buf, "");
+ case. FIXME: As soon as we open by handle from /proc/<PID>/fd,
+ the O_EXCL test has to be moved to open. */
+ if ((get_flags () & (O_TMPFILE | O_EXCL)) == (O_TMPFILE | O_EXCL)
+ || (get_device () == FH_FS
+ && NT_SUCCESS (NtQueryInformationFile (get_handle (), &io,
+ &fsi, sizeof fsi,
+ FileStandardInformation))
+ && fsi.DeletePending))
+ {
+ stpcpy (stpcpy (buf, get_name ()), " (deleted)");
+ return buf;
+ }
if (get_name ())
return strcpy (buf, get_name ());
if (dev ().name ())