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:
Diffstat (limited to 'winsup/cygwin/mount.cc')
-rw-r--r--winsup/cygwin/mount.cc56
1 files changed, 35 insertions, 21 deletions
diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc
index c04805bfc..68977fd58 100644
--- a/winsup/cygwin/mount.cc
+++ b/winsup/cygwin/mount.cc
@@ -791,14 +791,28 @@ mount_info::get_mounts_here (const char *parent_dir, int parent_dir_len,
/* cygdrive_posix_path: Build POSIX path used as the
mount point for cygdrives created when there is no other way to
- obtain a POSIX path from a Win32 one. */
+ obtain a POSIX path from a Win32 one.
+
+ Recognized flag values:
+ - 0x001: Add trailing slash.
+ - 0x200 == CCP_PROC_CYGDRIVE: Return /proc/cygdrive rather than actual
+ cygdrive prefix. */
void
-mount_info::cygdrive_posix_path (const char *src, char *dst, int trailing_slash_p)
+mount_info::cygdrive_posix_path (const char *src, char *dst, int flags)
{
- int len = cygdrive_len;
+ int len;
- memcpy (dst, cygdrive, len + 1);
+ if (flags & CCP_PROC_CYGDRIVE)
+ {
+ len = sizeof ("/proc/cygdrive/") - 1;
+ memcpy (dst, "/proc/cygdrive/", len + 1);
+ }
+ else
+ {
+ len = cygdrive_len;
+ memcpy (dst, cygdrive, len + 1);
+ }
/* Now finish the path off with the drive letter to be used.
The cygdrive prefix always ends with a trailing slash so
@@ -816,7 +830,7 @@ mount_info::cygdrive_posix_path (const char *src, char *dst, int trailing_slash_
n = 2;
strcpy (dst + len, src + n);
}
- slashify (dst, dst, trailing_slash_p);
+ slashify (dst, dst, !!(flags & 0x1));
}
int
@@ -855,7 +869,7 @@ mount_info::cygdrive_win32_path (const char *src, char *dst, int& unit)
/* src_path is a wide Win32 path. */
int
mount_info::conv_to_posix_path (PWCHAR src_path, char *posix_path,
- int keep_rel_p)
+ int ccp_flags)
{
bool changed = false;
if (!wcsncmp (src_path, L"\\\\?\\", 4))
@@ -870,7 +884,7 @@ mount_info::conv_to_posix_path (PWCHAR src_path, char *posix_path,
tmp_pathbuf tp;
char *buf = tp.c_get ();
sys_wcstombs (buf, NT_MAX_PATH, src_path);
- int ret = conv_to_posix_path (buf, posix_path, keep_rel_p);
+ int ret = conv_to_posix_path (buf, posix_path, ccp_flags);
if (changed)
src_path[0] = L'C';
return ret;
@@ -878,23 +892,22 @@ mount_info::conv_to_posix_path (PWCHAR src_path, char *posix_path,
int
mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
- int keep_rel_p)
+ int ccp_flags)
{
int src_path_len = strlen (src_path);
- int relative_path_p = !isabspath (src_path);
- int trailing_slash_p;
+ int relative = !isabspath (src_path);
+ int append_slash;
if (src_path_len <= 1)
- trailing_slash_p = 0;
+ append_slash = 0;
else
{
const char *lastchar = src_path + src_path_len - 1;
- trailing_slash_p = isdirsep (*lastchar) && lastchar[-1] != ':';
+ append_slash = isdirsep (*lastchar) && lastchar[-1] != ':';
}
- debug_printf ("conv_to_posix_path (%s, %s, %s)", src_path,
- keep_rel_p ? "keep-rel" : "no-keep-rel",
- trailing_slash_p ? "add-slash" : "no-add-slash");
+ debug_printf ("conv_to_posix_path (%s, 0x%x, %s)", src_path, ccp_flags,
+ append_slash ? "add-slash" : "no-add-slash");
MALLOC_CHECK;
if (src_path_len >= NT_MAX_PATH)
@@ -906,7 +919,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
/* FIXME: For now, if the path is relative and it's supposed to stay
that way, skip mount table processing. */
- if (keep_rel_p && relative_path_p)
+ if ((ccp_flags & CCP_RELATIVE) && relative)
{
slashify (src_path, posix_path, 0);
debug_printf ("%s = conv_to_posix_path (%s)", posix_path, src_path);
@@ -953,8 +966,9 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
strcat (posix_path, "/");
if (nextchar)
slashify (p,
- posix_path + addslash + (mi.posix_pathlen == 1 ? 0 : mi.posix_pathlen),
- trailing_slash_p);
+ posix_path + addslash + (mi.posix_pathlen == 1
+ ? 0 : mi.posix_pathlen),
+ append_slash);
if (cygheap->root.exists ())
{
@@ -972,7 +986,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
{
const char *p = pathbuf + cygheap->root.native_length ();
if (*p)
- slashify (p, posix_path, trailing_slash_p);
+ slashify (p, posix_path, append_slash);
else
{
posix_path[0] = '/';
@@ -987,12 +1001,12 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
caller must want an absolute path (otherwise we would have returned
above). So we always return an absolute path at this point. */
if (isdrive (pathbuf))
- cygdrive_posix_path (pathbuf, posix_path, trailing_slash_p);
+ cygdrive_posix_path (pathbuf, posix_path, append_slash | ccp_flags);
else
{
/* The use of src_path and not pathbuf here is intentional.
We couldn't translate the path, so just ensure no \'s are present. */
- slashify (src_path, posix_path, trailing_slash_p);
+ slashify (src_path, posix_path, append_slash);
}
out: