Allow cygwin_conv_path(3) and cygpath(1) to emit /proc/cygdrive prefixed path
* include/sys/cygwin.h (CCP_PROC_CYGDRIVE): New flag. * mount.cc (mount_info::cygdrive_posix_path): Take flag values rather than just a trailing_slash_p bool. Emit /proc/cygdrive path if CCP_PROC_CYGDRIVE flag is given. (mount_info::conv_to_posix_path): Take flag values rather than just a keep_rel_p bool. Rename _p variables. Print flag value as hex in debug_printf. Call cygdrive_posix_path with flag values. * mount.h (mount_info::cygdrive_posix_path): Accommodate above change in declaration. (mount_info::conv_to_posix_path): Ditto. * fhandler_process.cc (format_process_exename): Accommodate change to mount_info::conv_to_posix_path. * path.cc (cygwin_conv_path): Ditto. * cygpath.cc (absolute_flag): Initialize to CCP_RELATIVE to simplify expressions. (cygdrive_flag): New global flag. (long_options): Add --proc-cygdrive option. (options): Add -U option. (usage): Add description for -U option. (do_sysfolders): Or cygdrive_flag to cygwin_conv_path call. (do_pathconv): Simply or absolute_flag to conv_func. Or cygdrive_flag to conv_func. (do_options): Initalize absolute_flag to CCP_RELATIVE. Initialize new cygdrive_flag. Set absolute_flag to CCP_ABSOLUTE on -a. Set cygdrive_flag to CCP_PROC_CYGDRIVE on -U. * new-features.xml (ov-new2.4): Document cygpath -U option. * utils.xml (cygpath): Ditto. * path.xml (func-cygwin-path): Add CCP_PROC_CYGDRIVE description. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
@@ -3342,7 +3342,7 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
|
||||
char *buf = NULL;
|
||||
PWCHAR path = NULL;
|
||||
int error = 0;
|
||||
bool relative = !!(what & CCP_RELATIVE);
|
||||
int how = what & ~CCP_CONVTYPE_MASK;
|
||||
what &= CCP_CONVTYPE_MASK;
|
||||
int ret = -1;
|
||||
|
||||
@@ -3360,7 +3360,8 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
|
||||
{
|
||||
p.check ((const char *) from,
|
||||
PC_POSIX | PC_SYM_FOLLOW | PC_SYM_NOFOLLOW_REP
|
||||
| PC_NO_ACCESS_CHECK | PC_NOWARN | (relative ? PC_NOFULL : 0));
|
||||
| PC_NO_ACCESS_CHECK | PC_NOWARN
|
||||
| ((how & CCP_RELATIVE) ? PC_NOFULL : 0));
|
||||
if (p.error)
|
||||
{
|
||||
set_errno (p.error);
|
||||
@@ -3393,7 +3394,7 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
|
||||
backslash ".\\" in the Win32 path. That's a result of the
|
||||
conversion in normalize_posix_path. This should not occur
|
||||
so the below code is just a band-aid. */
|
||||
if (relative && !strcmp ((const char *) from, ".")
|
||||
if ((how & CCP_RELATIVE) && !strcmp ((const char *) from, ".")
|
||||
&& !strcmp (buf, ".\\"))
|
||||
{
|
||||
lsiz = 2;
|
||||
@@ -3404,14 +3405,15 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
|
||||
case CCP_POSIX_TO_WIN_W:
|
||||
p.check ((const char *) from,
|
||||
PC_POSIX | PC_SYM_FOLLOW | PC_SYM_NOFOLLOW_REP
|
||||
| PC_NO_ACCESS_CHECK | PC_NOWARN | (relative ? PC_NOFULL : 0));
|
||||
| PC_NO_ACCESS_CHECK | PC_NOWARN
|
||||
| ((how & CCP_RELATIVE) ? PC_NOFULL : 0));
|
||||
if (p.error)
|
||||
{
|
||||
set_errno (p.error);
|
||||
__leave;
|
||||
}
|
||||
/* Relative Windows paths are always restricted to MAX_PATH chars. */
|
||||
if (relative && !isabspath (p.get_win32 ())
|
||||
if ((how & CCP_RELATIVE) && !isabspath (p.get_win32 ())
|
||||
&& sys_mbstowcs (NULL, 0, p.get_win32 ()) > MAX_PATH)
|
||||
{
|
||||
/* Recreate as absolute path. */
|
||||
@@ -3455,7 +3457,7 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
|
||||
lsiz += ro_u_globalroot.Length / sizeof (WCHAR);
|
||||
}
|
||||
/* TODO: Same ".\\" band-aid as in CCP_POSIX_TO_WIN_A case. */
|
||||
if (relative && !strcmp ((const char *) from, ".")
|
||||
if ((how & CCP_RELATIVE) && !strcmp ((const char *) from, ".")
|
||||
&& !wcscmp (path, L".\\"))
|
||||
{
|
||||
lsiz = 2;
|
||||
@@ -3466,7 +3468,7 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
|
||||
case CCP_WIN_A_TO_POSIX:
|
||||
buf = tp.c_get ();
|
||||
error = mount_table->conv_to_posix_path ((const char *) from, buf,
|
||||
relative);
|
||||
how);
|
||||
if (error)
|
||||
{
|
||||
set_errno (p.error);
|
||||
@@ -3477,7 +3479,7 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
|
||||
case CCP_WIN_W_TO_POSIX:
|
||||
buf = tp.c_get ();
|
||||
error = mount_table->conv_to_posix_path ((const PWCHAR) from, buf,
|
||||
relative);
|
||||
how);
|
||||
if (error)
|
||||
{
|
||||
set_errno (error);
|
||||
|
Reference in New Issue
Block a user