* fhandler_proc.cc (proc_listing): Add entry for "self".

(proc_fhandlers): Add entry for "self".
* fhandler_process.cc (fhandler_process::fstate): Handle "self".
(fhandler_process::open): Handle "self".
This commit is contained in:
Christopher Faylor 2004-12-18 16:37:44 +00:00
parent a9c42bde0b
commit b25e8b65c2
6 changed files with 139 additions and 106 deletions

View File

@ -1,3 +1,10 @@
2004-12-18 Chris January <chris@atomice.net>
* fhandler_proc.cc (proc_listing): Add entry for "self".
(proc_fhandlers): Add entry for "self".
* fhandler_process.cc (fhandler_process::fstate): Handle "self".
(fhandler_process::open): Handle "self".
2004-12-17 Christopher Faylor <cgf@timesys.com> 2004-12-17 Christopher Faylor <cgf@timesys.com>
* sigproc.cc (proc_subproc): Fix long-standing problem. Only wait for * sigproc.cc (proc_subproc): Fix long-standing problem. Only wait for

View File

@ -29,7 +29,7 @@ enum child_info_types
#define EXEC_MAGIC_SIZE sizeof(child_info) #define EXEC_MAGIC_SIZE sizeof(child_info)
#define CURR_CHILD_INFO_MAGIC 0x694cd4b8U #define CURR_CHILD_INFO_MAGIC 0x17ad771aU
/* NOTE: Do not make gratuitous changes to the names or organization of the /* NOTE: Do not make gratuitous changes to the names or organization of the
below class. The layout is checksummed to determine compatibility between below class. The layout is checksummed to determine compatibility between

View File

@ -54,6 +54,7 @@ static const char *proc_listing[] = {
"uptime", "uptime",
"cpuinfo", "cpuinfo",
"partitions", "partitions",
"self",
NULL NULL
}; };
@ -73,6 +74,7 @@ static const DWORD proc_fhandlers[PROC_LINK_COUNT] = {
FH_PROC, FH_PROC,
FH_PROC, FH_PROC,
FH_PROC, FH_PROC,
FH_PROCESS,
}; };
/* name of the /proc filesystem */ /* name of the /proc filesystem */

View File

@ -107,6 +107,9 @@ fhandler_process::fstat (struct __stat64 *buf)
int file_type = exists (); int file_type = exists ();
(void) fhandler_base::fstat (buf); (void) fhandler_base::fstat (buf);
path += proc_len + 1; path += proc_len + 1;
if (path_prefix_p ("self", path, 4))
pid = getpid ();
else
pid = atoi (path); pid = atoi (path);
pinfo p (pid); pinfo p (pid);
if (!p) if (!p)
@ -167,6 +170,9 @@ fhandler_process::open (int flags, mode_t mode)
const char *path; const char *path;
path = get_name () + proc_len + 1; path = get_name () + proc_len + 1;
if (path_prefix_p ("self", path, 4))
pid = getpid ();
else
pid = atoi (path); pid = atoi (path);
while (*path != 0 && !isdirsep (*path)) while (*path != 0 && !isdirsep (*path))
path++; path++;
@ -313,7 +319,8 @@ fhandler_process::fill_filebuf ()
strcpy (filebuf, "<defunct>"); strcpy (filebuf, "<defunct>");
else else
{ {
mount_table->conv_to_posix_path (p->progname, filebuf, 1); charplus x (p->progname);
mount_table->conv_to_posix_path (x, filebuf, 1);
int len = strlen (filebuf); int len = strlen (filebuf);
if (len > 4) if (len > 4)
{ {

View File

@ -75,7 +75,7 @@ details. */
#include "cygtls.h" #include "cygtls.h"
#include <assert.h> #include <assert.h>
static int normalize_win32_path (const char *src, char *dst, char ** tail); static int normalize_win32_path (const char *, charplus&);
static void slashify (const char *src, char *dst, int trailing_slash_p); static void slashify (const char *src, char *dst, int trailing_slash_p);
static void backslashify (const char *src, char *dst, int trailing_slash_p); static void backslashify (const char *src, char *dst, int trailing_slash_p);
@ -190,38 +190,37 @@ pathmatch (const char *path1, const char *path2)
The result is 0 for success, or an errno error value. */ The result is 0 for success, or an errno error value. */
static int static int
normalize_posix_path (const char *src, char *dst, char **tail) normalize_posix_path (const char *src, charplus& dst)
{ {
const char *src_start = src; const char *src_start = src;
char *dst_start = dst;
syscall_printf ("src %s", src); syscall_printf ("src %s", src);
const char *in_src = src; const char *in_src = src;
char *in_dst = dst;
if (isdrive (src) || *src == '\\') if (isdrive (src) || *src == '\\')
goto win32_path; goto win32_path;
dst.tail = dst;
if (!isslash (src[0])) if (!isslash (src[0]))
{ {
if (!cygheap->cwd.get (dst)) if (!cygheap->cwd.get (dst))
return get_errno (); return get_errno ();
dst = strchr (dst, '\0'); dst.tail = strchr (dst.tail, '\0');
if (*src == '.') if (*src == '.')
{ {
if (dst == dst_start + 1 && *dst_start == '/') if (dst.tail == dst + 1 && *dst == '/')
--dst; dst.tail--;
goto sawdot; goto sawdot;
} }
if (dst > dst_start && !isslash (dst[-1])) if (dst.tail > dst && !isslash (dst.tail[-1]))
*dst++ = '/'; *dst.tail++ = '/';
} }
/* Two leading /'s? If so, preserve them. */ /* Two leading /'s? If so, preserve them. */
else if (isslash (src[1]) && !isslash (src[2])) else if (isslash (src[1]) && !isslash (src[2]))
{ {
*dst++ = '/'; *dst.tail++ = '/';
*dst++ = '/'; *dst.tail++ = '/';
src += 2; src += 2;
} }
@ -231,7 +230,7 @@ normalize_posix_path (const char *src, char *dst, char **tail)
goto win32_path; goto win32_path;
/* Strip runs of /'s. */ /* Strip runs of /'s. */
if (!isslash (*src)) if (!isslash (*src))
*dst++ = *src++; *dst.tail++ = *src++;
else else
{ {
while (*++src) while (*++src)
@ -247,7 +246,7 @@ normalize_posix_path (const char *src, char *dst, char **tail)
{ {
if (!src[1]) if (!src[1])
{ {
*dst++ = '/'; *dst.tail++ = '/';
goto done; goto done;
} }
if (!isslash (src[1])) if (!isslash (src[1]))
@ -268,15 +267,15 @@ normalize_posix_path (const char *src, char *dst, char **tail)
} }
else else
{ {
while (dst > dst_start && !isslash (*--dst)) while (dst.tail > dst && !isslash (*--dst.tail))
continue; continue;
src++; src++;
} }
} }
*dst++ = '/'; *dst.tail++ = '/';
} }
if ((dst - dst_start) >= CYG_MAX_PATH) if ((dst.tail - dst) >= CYG_MAX_PATH)
{ {
debug_printf ("ENAMETOOLONG = normalize_posix_path (%s)", src); debug_printf ("ENAMETOOLONG = normalize_posix_path (%s)", src);
return ENAMETOOLONG; return ENAMETOOLONG;
@ -284,16 +283,15 @@ normalize_posix_path (const char *src, char *dst, char **tail)
} }
done: done:
*dst = '\0'; *dst.tail = '\0';
*tail = dst;
debug_printf ("%s = normalize_posix_path (%s)", dst_start, src_start); debug_printf ("%s = normalize_posix_path (%s)", (char *) dst, src_start);
return 0; return 0;
win32_path: win32_path:
int err = normalize_win32_path (in_src, in_dst, tail); int err = normalize_win32_path (in_src, dst);
if (!err) if (!err)
for (char *p = in_dst; (p = strchr (p, '\\')); p++) for (char *p = dst; (p = strchr (p, '\\')); p++)
*p = '/'; *p = '/';
return err; return err;
} }
@ -500,13 +498,13 @@ path_conv::check (const char *src, unsigned opt,
/* This array is used when expanding symlinks. It is CYG_MAX_PATH * 2 /* This array is used when expanding symlinks. It is CYG_MAX_PATH * 2
in length so that we can hold the expanded symlink plus a in length so that we can hold the expanded symlink plus a
trailer. */ trailer. */
char path_copy[CYG_MAX_PATH + 3]; charplus path_copy;
char tmp_buf[2 * CYG_MAX_PATH + 3]; char tmp_buf[2 * CYG_MAX_PATH + 3];
symlink_info sym; symlink_info sym;
bool need_directory = 0; bool need_directory = 0;
bool saw_symlinks = 0; bool saw_symlinks = 0;
int is_relpath; int is_relpath;
char *tail, *path_end; char *path_end;
#if 0 #if 0
static path_conv last_path_conv; static path_conv last_path_conv;
@ -537,34 +535,34 @@ path_conv::check (const char *src, unsigned opt,
{ {
MALLOC_CHECK; MALLOC_CHECK;
assert (src); assert (src);
is_relpath = !isabspath (src); is_relpath = !isabspath (src);
error = normalize_posix_path (src, path_copy, &tail); error = normalize_posix_path (src, path_copy);
if (error) if (error)
return; return;
/* Detect if the user was looking for a directory. We have to strip the /* Detect if the user was looking for a directory. We have to strip the
trailing slash initially while trying to add extensions but take it trailing slash initially while trying to add extensions but take it
into account during processing */ into account during processing */
if (tail > path_copy + 1) if (path_copy.tail > path_copy + 1)
{ {
if (isslash (tail[-1])) if (isslash (path_copy.tail[-1]))
{ {
need_directory = 1; need_directory = 1;
tail--; *--path_copy.tail = '\0';
} }
/* Remove trailing dots and spaces which are ignored by Win32 functions but /* Remove trailing dots and spaces which are ignored by Win32 functions but
not by native NT functions. */ not by native NT functions. */
while (tail[-1] == '.' || tail[-1] == ' ') while (path_copy.tail[-1] == '.' || path_copy.tail[-1] == ' ')
tail--; path_copy.tail--;
if (tail > path_copy + 1 && isslash (tail[-1])) if (path_copy.tail > path_copy + 1 && isslash (path_copy.tail[-1]))
{ {
error = ENOENT; error = ENOENT;
return; return;
} }
} }
path_end = tail; path_end = path_copy.tail;
*tail = '\0'; path_copy.tailch = *path_copy.tail;
*path_copy.tail = '\0';
/* Scan path_copy from right to left looking either for a symlink /* Scan path_copy from right to left looking either for a symlink
or an actual existing file. If an existing file is found, just or an actual existing file. If an existing file is found, just
@ -601,6 +599,7 @@ path_conv::check (const char *src, unsigned opt,
error = mount_table->conv_to_win32_path (path_copy, full_path, dev, error = mount_table->conv_to_win32_path (path_copy, full_path, dev,
&sym.pflags); &sym.pflags);
path_copy.tailch = '\0';
if (error) if (error)
return; return;
@ -747,17 +746,17 @@ path_conv::check (const char *src, unsigned opt,
/* Find the new "tail" of the path, e.g. in '/for/bar/baz', /* Find the new "tail" of the path, e.g. in '/for/bar/baz',
/baz is the tail. */ /baz is the tail. */
if (tail != path_end) if (path_copy.tail != path_end)
*tail = '/'; *path_copy.tail = '/';
while (--tail > path_copy + 1 && *tail != '/') {} while (--path_copy.tail > path_copy + 1 && *path_copy.tail != '/') {}
/* Exit loop if there is no tail or we are at the /* Exit loop if there is no tail or we are at the
beginning of a UNC path */ beginning of a UNC path */
if (tail <= path_copy + 1) if (path_copy.tail <= path_copy + 1)
goto out; // all done goto out; // all done
/* Haven't found an existing pathname component yet. /* Haven't found an existing pathname component yet.
Pinch off the tail and try again. */ Pinch off the tail and try again. */
*tail = '\0'; *path_copy.tail = '\0';
component++; component++;
} }
@ -779,7 +778,7 @@ path_conv::check (const char *src, unsigned opt,
else else
{ {
/* Copy the first part of the path (with ending /) and point to the end. */ /* Copy the first part of the path (with ending /) and point to the end. */
char *prevtail = tail; char *prevtail = path_copy.tail;
while (--prevtail > path_copy && *prevtail != '/') {} while (--prevtail > path_copy && *prevtail != '/') {}
int headlen = prevtail - path_copy + 1;; int headlen = prevtail - path_copy + 1;;
memcpy (tmp_buf, path_copy, headlen); memcpy (tmp_buf, path_copy, headlen);
@ -802,15 +801,15 @@ path_conv::check (const char *src, unsigned opt,
*headptr = '\0'; *headptr = '\0';
/* Copy any tail component (with the 0) */ /* Copy any tail component (with the 0) */
if (tail++ < path_end) if (path_copy.tail++ < path_end)
{ {
/* Add a slash if needed. There is space. */ /* Add a slash if needed. There is space. */
if (*(headptr - 1) != '/') if (*(headptr - 1) != '/')
*headptr++ = '/'; *headptr++ = '/';
int taillen = path_end - tail + 1; int taillen = path_end - path_copy.tail + 1;
if (headptr + taillen > tmp_buf + sizeof (tmp_buf)) if (headptr + taillen > tmp_buf + sizeof (tmp_buf))
goto too_long; goto too_long;
memcpy (headptr, tail, taillen); memcpy (headptr, path_copy.tail, taillen);
} }
/* Evaluate everything all over again. */ /* Evaluate everything all over again. */
@ -891,8 +890,8 @@ out:
normalized_path_size = 0; normalized_path_size = 0;
else else
{ {
if (tail < path_end && tail > path_copy + 1) if (path_copy.tail < path_end && path_copy.tail > path_copy + 1)
*tail = '/'; *path_copy.tail = '/';
set_normalized_path (path_copy); set_normalized_path (path_copy);
} }
@ -957,34 +956,33 @@ is_unc_share (const char *path)
The result is 0 for success, or an errno error value. The result is 0 for success, or an errno error value.
FIXME: A lot of this should be mergeable with the POSIX critter. */ FIXME: A lot of this should be mergeable with the POSIX critter. */
static int static int
normalize_win32_path (const char *src, char *dst, char **tail) normalize_win32_path (const char *src, charplus& dst)
{ {
const char *src_start = src; const char *src_start = src;
char *dst_start = dst;
char *dst_root_start = dst;
bool beg_src_slash = isdirsep (src[0]); bool beg_src_slash = isdirsep (src[0]);
dst.tail = dst;
if (beg_src_slash && isdirsep (src[1])) if (beg_src_slash && isdirsep (src[1]))
{ {
*dst++ = '\\'; *dst.tail++ = '\\';
src++; src++;
if (src[1] == '.' && isdirsep (src[2])) if (src[1] == '.' && isdirsep (src[2]))
{ {
*dst++ = '\\'; *dst.tail++ = '\\';
*dst++ = '.'; *dst.tail++ = '.';
src += 2; src += 2;
} }
} }
else if (!isdrive(src) && *src != '/') else if (!isdrive(src) && *src != '/')
{ {
if (beg_src_slash) if (beg_src_slash)
dst += cygheap->cwd.get_drive (dst); dst.tail += cygheap->cwd.get_drive (dst);
else if (!cygheap->cwd.get (dst, 0)) else if (!cygheap->cwd.get (dst, 0))
return get_errno (); return get_errno ();
else else
{ {
dst += strlen (dst); dst.tail = strchr (dst.tail, '\0');
*dst++ = '\\'; *dst.tail++ = '\\';
} }
} }
@ -1001,16 +999,16 @@ normalize_win32_path (const char *src, char *dst, char **tail)
/* Backup if "..". */ /* Backup if "..". */
else if (src[0] == '.' && src[1] == '.' else if (src[0] == '.' && src[1] == '.'
/* dst must be greater than dst_start */ /* dst must be greater than dst_start */
&& dst[-1] == '\\') && dst.tail[-1] == '\\')
{ {
if (isdirsep (src[2]) || src[2] == 0) if (isdirsep (src[2]) || src[2] == 0)
{ {
/* Back up over /, but not if it's the first one. */ /* Back up over /, but not if it's the first one. */
if (dst > dst_root_start + 1) if (dst.tail > dst + 1)
dst--; dst.tail--;
/* Now back up to the next /. */ /* Now back up to the next /. */
while (dst > dst_root_start + 1 && dst[-1] != '\\' && dst[-2] != ':') while (dst.tail > dst + 1 && dst.tail[-1] != '\\' && dst.tail[-2] != ':')
dst--; dst.tail--;
src += 2; src += 2;
if (isdirsep (*src)) if (isdirsep (*src))
src++; src++;
@ -1020,26 +1018,25 @@ normalize_win32_path (const char *src, char *dst, char **tail)
int n = strspn (src, "."); int n = strspn (src, ".");
if (!src[n] || isdirsep (src[n])) /* just dots... */ if (!src[n] || isdirsep (src[n])) /* just dots... */
return ENOENT; return ENOENT;
*dst++ = *src++; *dst.tail++ = *src++;
} }
} }
/* Otherwise, add char to result. */ /* Otherwise, add char to result. */
else else
{ {
if (*src == '/') if (*src == '/')
*dst++ = '\\'; *dst.tail++ = '\\';
else else
*dst++ = *src; *dst.tail++ = *src;
++src; src++;
} }
if ((dst - dst_start) >= CYG_MAX_PATH) if ((dst.tail - dst) >= CYG_MAX_PATH)
return ENAMETOOLONG; return ENAMETOOLONG;
} }
if (dst > dst_start + 1 && dst[-1] == '.' && dst[-2] == '\\') if (dst.tail > dst + 1 && dst.tail[-1] == '.' && dst.tail[-2] == '\\')
dst--; dst.tail--;
*dst = '\0'; *dst.tail = '\0';
*tail = dst; debug_printf ("%s = normalize_win32_path (%s)", (char *) dst, src_start);
debug_printf ("%s = normalize_win32_path (%s)", dst_start, src_start);
return 0; return 0;
} }
@ -1324,7 +1321,7 @@ mount_item::fnmunge (char *dst, const char *src, int& left)
} }
int int
mount_item::build_win32 (char *dst, const char *src, unsigned *outflags, unsigned chroot_pathlen) mount_item::build_win32 (char *dst, const charplus& src, unsigned *outflags, unsigned chroot_pathlen)
{ {
int n, err = 0; int n, err = 0;
const char *real_native_path; const char *real_native_path;
@ -1357,6 +1354,16 @@ mount_item::build_win32 (char *dst, const char *src, unsigned *outflags, unsigne
} }
else else
{ {
char buf[CYG_MAX_PATH];
if (src.tailch)
{
strcpy (buf, p);
char *endp = strchr (buf, '\0');
*endp = src.tailch;
strcpy (endp + 1, src.tail + 1);
p = buf;
}
int left = CYG_MAX_PATH - n; int left = CYG_MAX_PATH - n;
while (*p) while (*p)
{ {
@ -1392,8 +1399,8 @@ mount_item::build_win32 (char *dst, const char *src, unsigned *outflags, unsigne
{,full_}win32_path must have sufficient space (i.e. CYG_MAX_PATH bytes). */ {,full_}win32_path must have sufficient space (i.e. CYG_MAX_PATH bytes). */
int int
mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev, mount_info::conv_to_win32_path (const charplus& src_path, char *dst,
unsigned *flags) device& dev, unsigned *flags)
{ {
bool chroot_ok = !cygheap->root.exists (); bool chroot_ok = !cygheap->root.exists ();
while (sys_mount_table_counter < cygwin_shared->sys_mount_table_counter) while (sys_mount_table_counter < cygwin_shared->sys_mount_table_counter)
@ -1407,7 +1414,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev,
dev.devn = FH_FS; dev.devn = FH_FS;
*flags = 0; *flags = 0;
debug_printf ("conv_to_win32_path (%s)", src_path); debug_printf ("conv_to_win32_path (%s)", (const char *) src_path);
int i, rc; int i, rc;
mount_item *mi = NULL; /* initialized to avoid compiler warning */ mount_item *mi = NULL; /* initialized to avoid compiler warning */
@ -1525,7 +1532,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev,
} }
out_no_chroot_check: out_no_chroot_check:
debug_printf ("src_path %s, dst %s, flags %p, rc %d", src_path, dst, *flags, rc); debug_printf ("src_path %s, dst %s, flags %p, rc %d", (const char *) src_path, dst, *flags, rc);
return rc; return rc;
} }
@ -1590,7 +1597,7 @@ mount_info::cygdrive_win32_path (const char *src, char *dst, int& unit)
If keep_rel_p is non-zero, relative paths stay that way. */ If keep_rel_p is non-zero, relative paths stay that way. */
int int
mount_info::conv_to_posix_path (const char *src_path, char *posix_path, mount_info::conv_to_posix_path (const charplus& src_path, char *posix_path,
int keep_rel_p) int keep_rel_p)
{ {
int src_path_len = strlen (src_path); int src_path_len = strlen (src_path);
@ -1605,7 +1612,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
trailing_slash_p = isdirsep (*lastchar) && lastchar[-1] != ':'; trailing_slash_p = isdirsep (*lastchar) && lastchar[-1] != ':';
} }
debug_printf ("conv_to_posix_path (%s, %s, %s)", src_path, debug_printf ("conv_to_posix_path (%s, %s, %s)", (const char *) src_path,
keep_rel_p ? "keep-rel" : "no-keep-rel", keep_rel_p ? "keep-rel" : "no-keep-rel",
trailing_slash_p ? "add-slash" : "no-add-slash"); trailing_slash_p ? "add-slash" : "no-add-slash");
MALLOC_CHECK; MALLOC_CHECK;
@ -1622,20 +1629,19 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
if (keep_rel_p && relative_path_p) if (keep_rel_p && relative_path_p)
{ {
slashify (src_path, posix_path, 0); slashify (src_path, posix_path, 0);
debug_printf ("%s = conv_to_posix_path (%s)", posix_path, src_path); debug_printf ("%s = conv_to_posix_path (%s)", posix_path, (const char *) src_path);
return 0; return 0;
} }
char pathbuf[CYG_MAX_PATH]; charplus pathbuf;
char * tail; int rc = normalize_win32_path (src_path, pathbuf);
int rc = normalize_win32_path (src_path, pathbuf, &tail);
if (rc != 0) if (rc != 0)
{ {
debug_printf ("%d = conv_to_posix_path (%s)", rc, src_path); debug_printf ("%d = conv_to_posix_path (%s)", rc, (const char *) src_path);
return rc; return rc;
} }
int pathbuflen = tail - pathbuf; int pathbuflen = pathbuf.tail - pathbuf;
for (int i = 0; i < nmounts; ++i) for (int i = 0; i < nmounts; ++i)
{ {
mount_item &mi = mount[native_sorted[i]]; mount_item &mi = mount[native_sorted[i]];
@ -1713,7 +1719,7 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
} }
out: out:
debug_printf ("%s = conv_to_posix_path (%s)", posix_path, src_path); debug_printf ("%s = conv_to_posix_path (%s)", posix_path, (const char *) src_path);
MALLOC_CHECK; MALLOC_CHECK;
return 0; return 0;
} }
@ -2109,9 +2115,9 @@ mount_info::sort ()
int int
mount_info::add_item (const char *native, const char *posix, unsigned mountflags, int reg_p) mount_info::add_item (const char *native, const char *posix, unsigned mountflags, int reg_p)
{ {
char nativetmp[CYG_MAX_PATH]; charplus nativetmp;
char posixtmp[CYG_MAX_PATH]; charplus posixtmp;
char *nativetail, *posixtail, error[] = "error"; char error[] = "error";
int nativeerr, posixerr; int nativeerr, posixerr;
/* Something's wrong if either path is NULL or empty, or if it's /* Something's wrong if either path is NULL or empty, or if it's
@ -2121,17 +2127,17 @@ mount_info::add_item (const char *native, const char *posix, unsigned mountflags
!(is_unc_share (native) || isdrive (native))) !(is_unc_share (native) || isdrive (native)))
nativeerr = EINVAL; nativeerr = EINVAL;
else else
nativeerr = normalize_win32_path (native, nativetmp, &nativetail); nativeerr = normalize_win32_path (native, nativetmp);
if (posix == NULL || !isabspath (posix) || if (posix == NULL || !isabspath (posix) ||
is_unc_share (posix) || isdrive (posix)) is_unc_share (posix) || isdrive (posix))
posixerr = EINVAL; posixerr = EINVAL;
else else
posixerr = normalize_posix_path (posix, posixtmp, &posixtail); posixerr = normalize_posix_path (posix, posixtmp);
debug_printf ("%s[%s], %s[%s], %p", debug_printf ("%s[%s], %s[%s], %p",
native, nativeerr ? error : nativetmp, native, nativeerr ? error : (const char *) nativetmp,
posix, posixerr ? error : posixtmp, mountflags); posix, posixerr ? error : (const char *) posixtmp, mountflags);
if (nativeerr || posixerr) if (nativeerr || posixerr)
{ {
@ -2140,10 +2146,10 @@ mount_info::add_item (const char *native, const char *posix, unsigned mountflags
} }
/* Make sure both paths do not end in /. */ /* Make sure both paths do not end in /. */
if (nativetail > nativetmp + 1 && nativetail[-1] == '\\') if (nativetmp.tail > nativetmp + 1 && nativetmp.tail[-1] == '\\')
nativetail[-1] = '\0'; nativetmp.tail[-1] = '\0';
if (posixtail > posixtmp + 1 && posixtail[-1] == '/') if (posixtmp.tail > posixtmp + 1 && posixtmp.tail[-1] == '/')
posixtail[-1] = '\0'; posixtmp.tail[-1] = '\0';
/* Write over an existing mount item with the same POSIX path if /* Write over an existing mount item with the same POSIX path if
it exists and is from the same registry area. */ it exists and is from the same registry area. */

View File

@ -11,6 +11,17 @@ details. */
#include "tty.h" #include "tty.h"
#include "security.h" #include "security.h"
struct charplus
{
char buf[CYG_MAX_PATH];
char tailch;
char *tail;
operator char * () { return buf; }
operator const char * () const { return buf; }
charplus (const char *s) : tailch (0), tail (0) {strcpy (buf, s);}
charplus () : tailch (0), tail (0) {*buf = '\0';}
};
/* Mount table entry */ /* Mount table entry */
class mount_item class mount_item
@ -33,7 +44,7 @@ class mount_item
struct mntent *getmntent (); struct mntent *getmntent ();
int fnmunge (char *, const char *, int&); int fnmunge (char *, const char *, int&);
int build_win32 (char *, const char *, unsigned *, unsigned); int build_win32 (char *, const charplus&, unsigned *, unsigned);
}; };
/* Warning: Decreasing this value will cause cygwin.dll to ignore existing /* Warning: Decreasing this value will cause cygwin.dll to ignore existing
@ -80,9 +91,9 @@ class mount_info
int del_reg_mount (const char * posix_path, unsigned mountflags); int del_reg_mount (const char * posix_path, unsigned mountflags);
unsigned set_flags_from_win32_path (const char *path); unsigned set_flags_from_win32_path (const char *path);
int conv_to_win32_path (const char *src_path, char *dst, device&, int conv_to_win32_path (const charplus& src_path, char *dst, device&,
unsigned *flags = NULL); unsigned *flags = NULL);
int conv_to_posix_path (const char *src_path, char *posix_path, int conv_to_posix_path (const charplus& src_path, char *posix_path,
int keep_rel_p); int keep_rel_p);
struct mntent *getmntent (int x); struct mntent *getmntent (int x);