aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2019-01-05 21:36:34 +0100
committerCorinna Vinschen <corinna@vinschen.de>2019-01-05 21:36:34 +0100
commitf72191ac0177883bb395d8d5f0ddc3f45b5dd29d (patch)
treef823afcff836fb7b6ce89f6d2eccc7614d6175f3
parent36ff506ddccb20c7a2c8ca35433b774d477dd694 (diff)
downloadnewlib-f72191ac0177883bb395d8d5f0ddc3f45b5dd29d.zip
newlib-f72191ac0177883bb395d8d5f0ddc3f45b5dd29d.tar.gz
newlib-f72191ac0177883bb395d8d5f0ddc3f45b5dd29d.tar.bz2
Cygwin: return correct FH_PROCESSFD for files under /proc/PID/fd subdir
This allows easier handling of fd symlinks. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/fhandler_proc.cc12
-rw-r--r--winsup/cygwin/path.cc2
2 files changed, 11 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
index c9761b5..cda2f72 100644
--- a/winsup/cygwin/fhandler_proc.cc
+++ b/winsup/cygwin/fhandler_proc.cc
@@ -134,14 +134,22 @@ fhandler_proc::get_proc_fhandler (const char *path)
if (entry)
return entry->fhandler;
- int pid = atoi (path);
+ char *e;
+ pid_t pid = strtoul (path, &e, 10);
+ if (*e != '/' && *e != '\0')
+ return FH_NADA;
pinfo p (pid);
/* If p->pid != pid, then pid is actually the Windows PID for an execed
Cygwin process, and the pinfo entry is the additional entry created
at exec time. We don't want to enable the user to access a process
entry by using the Win32 PID, though. */
if (p && p->pid == pid)
- return FH_PROCESS;
+ {
+ /* Check for entry in fd subdir */
+ if (!strncmp (++e, "fd/", 3) && e[3] != '\0')
+ return FH_PROCESSFD;
+ return FH_PROCESS;
+ }
bool has_subdir = false;
while (*path)
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index ee15dec..3324395 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -806,7 +806,7 @@ path_conv::check (const char *src, unsigned opt,
fh->fill_filebuf ();
symlen = sym.set (fh->get_filebuf ());
}
- else if (file_type == virt_fsdir && dev == FH_PROCESS)
+ else if (file_type == virt_fsdir && dev == FH_PROCESSFD)
{
/* FIXME: This is YA bad hack to workaround that
we're checking for isvirtual_dev at this point.