From f207699a539ac11f2966631e0f1b107849b34ef4 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 5 Sep 2014 19:11:01 +0000 Subject: [PATCH] * fhandler_proc.cc (proc_tab): Add entry for cygdrive symlink. (format_proc_cygdrive): New function to implement /proc/cygdrive. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/fhandler_proc.cc | 12 ++++++++++++ winsup/cygwin/release/1.7.33 | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 2d682a9ac..3d7c077f8 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2014-09-05 Corinna Vinschen + + * fhandler_proc.cc (proc_tab): Add entry for cygdrive symlink. + (format_proc_cygdrive): New function to implement /proc/cygdrive. + 2014-09-05 Corinna Vinschen * exception.h (class exception): Remove unnecessary #ifdef. diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 5db8ea2c5..0ae6ab0c9 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -17,6 +17,7 @@ details. */ #include "cygerrno.h" #include "security.h" #include "path.h" +#include "shared_info.h" #include "fhandler.h" #include "fhandler_virtual.h" #include "pinfo.h" @@ -44,6 +45,7 @@ static off_t format_proc_uptime (void *, char *&); static off_t format_proc_cpuinfo (void *, char *&); static off_t format_proc_partitions (void *, char *&); static off_t format_proc_self (void *, char *&); +static off_t format_proc_cygdrive (void *, char *&); static off_t format_proc_mounts (void *, char *&); static off_t format_proc_filesystems (void *, char *&); static off_t format_proc_swaps (void *, char *&); @@ -55,6 +57,7 @@ static const virt_tab_t proc_tab[] = { { _VN ("."), FH_PROC, virt_directory, NULL }, { _VN (".."), FH_PROC, virt_directory, NULL }, { _VN ("cpuinfo"), FH_PROC, virt_file, format_proc_cpuinfo }, + { _VN ("cygdrive"), FH_PROC, virt_symlink, format_proc_cygdrive }, { _VN ("devices"), FH_PROC, virt_file, format_proc_devices }, { _VN ("filesystems"), FH_PROC, virt_file, format_proc_filesystems }, { _VN ("loadavg"), FH_PROC, virt_file, format_proc_loadavg }, @@ -1328,6 +1331,15 @@ format_proc_self (void *, char *&destbuf) return __small_sprintf (destbuf, "%d", getpid ()); } +static off_t +format_proc_cygdrive (void *, char *&destbuf) +{ + destbuf = (char *) crealloc_abort (destbuf, mount_table->cygdrive_len + 1); + char *dend = stpcpy (destbuf, mount_table->cygdrive); + *--dend = '\0'; + return dend - destbuf; +} + static off_t format_proc_mounts (void *, char *&destbuf) { diff --git a/winsup/cygwin/release/1.7.33 b/winsup/cygwin/release/1.7.33 index 1f4342e7c..a6b590735 100644 --- a/winsup/cygwin/release/1.7.33 +++ b/winsup/cygwin/release/1.7.33 @@ -5,6 +5,10 @@ What's new: to do without /etc/passwd and /etc/group files. Introduce /etc/nsswitch.conf file to configure passwd/group handling. +- /proc/cygdrive as a symlink pointing to the current cygdrive prefix. This + can be utilized in scripts to access paths via cygdrive prefix, even if the + cygdrive prefix has been changed by the user. + What changed: -------------