summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/path.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-01-22 13:46:12 +0000
committerCorinna Vinschen <corinna@vinschen.de>2015-01-22 13:46:12 +0000
commit185784962a8f35695800dfeaa49da4a4209df6ad (patch)
tree41554d436b87eabad0d4194fd1058355014eb085 /winsup/cygwin/path.cc
parent638dd243f28e693471630152345777c21d5a00c6 (diff)
downloadcygnal-185784962a8f35695800dfeaa49da4a4209df6ad.tar.gz
cygnal-185784962a8f35695800dfeaa49da4a4209df6ad.tar.bz2
cygnal-185784962a8f35695800dfeaa49da4a4209df6ad.zip
* fhandler.h (class fhandler_process): Add fd_type member.
* fhandler_process.cc (process_tab): Fix indentation. (fhandler_process::exists): Rely on format_process_fd returning file type in fd_type. (struct process_fd_t): Add fd_type member. (fhandler_process::fill_filebuf): Allow format_process_fd to set this->fd_type member. (format_process_fd): Fix path evaluation to allow recognizing trailing path components. Fix check for file descriptor path component. Return virt_symlink in fd_type if no trailing path compenents exist, return virt_fsdir otherwise and copy full resulting path into destbuf. * path.cc (path_conv::check): If /proc/$PID/fd symlink has trailing path components, reparse resulting path as if it's the incoming path. Add comment to wail over the outdated and hackish check method, and to explain what we do here.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index dc8b97fc3..ff6751583 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -1,7 +1,7 @@
/* path.cc: path support.
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
+ 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Red Hat, Inc.
This file is part of Cygwin.
@@ -747,6 +747,8 @@ path_conv::check (const char *src, unsigned opt,
full_path = THIS_path;
}
+ retry_fs_via_processfd:
+
/* Convert to native path spec sans symbolic link info. */
error = mount_table->conv_to_win32_path (path_copy, full_path,
dev, &sym.pflags);
@@ -796,6 +798,29 @@ 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)
+ {
+ /* FIXME: This is YA bad hack to workaround that
+ we're checking for isvirtual_dev at this point.
+ This should only happen if the file is actually
+ a virtual file, and NOT already if the preceeding
+ path components constitute a virtual file.
+
+ Anyway, what we do here is this: If the descriptor
+ symlink points to a dir, and if there are trailing
+ path components, it's actually pointing somewhere
+ else. The format_process_fd function returns the
+ full path, resolved symlink plus trailing path
+ components, in its filebuf. This is a POSIX path
+ we know nothing about, so we have to convert it to
+ native again, calling conv_to_win32_path. Since
+ basically nothing happened yet, just copy it over
+ into full_path and jump back to the
+ conv_to_win32_path call. What a mess. */
+ stpcpy (path_copy, fh->get_filebuf ());
+ delete fh;
+ goto retry_fs_via_processfd;
+ }
delete fh;
}
switch (file_type)