diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2015-12-06 17:25:48 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2015-12-06 17:25:48 +0100 |
commit | 5aa8817e3a56da2b4177329e2d523f54eae7e142 (patch) | |
tree | 9cb862606b1d946f85cdc441d9131929ffcd4acf /winsup/utils | |
parent | 3ff65caea58441cecf65a53f01a7e566be01c51c (diff) | |
download | cygnal-5aa8817e3a56da2b4177329e2d523f54eae7e142.tar.gz cygnal-5aa8817e3a56da2b4177329e2d523f54eae7e142.tar.bz2 cygnal-5aa8817e3a56da2b4177329e2d523f54eae7e142.zip |
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>
Diffstat (limited to 'winsup/utils')
-rw-r--r-- | winsup/utils/ChangeLog | 15 | ||||
-rw-r--r-- | winsup/utils/cygpath.cc | 22 |
2 files changed, 31 insertions, 6 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index de00ef71b..77572209d 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,18 @@ +2015-12-06 Corinna Vinschen <corinna@vinschen.de> + + * 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. + 2015-11-26 Michael Kwasigroch <mkwasigr@web.de> * kill.cc (strsigno): Don't call sys_sigabbrev for signal 0. diff --git a/winsup/utils/cygpath.cc b/winsup/utils/cygpath.cc index 6094eb7eb..0fbb2e90e 100644 --- a/winsup/utils/cygpath.cc +++ b/winsup/utils/cygpath.cc @@ -1,6 +1,6 @@ /* cygpath.cc -- convert pathnames between Windows and Unix format Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010, 2011, 2012, 2013 Red Hat, Inc. + 2009, 2010, 2011, 2012, 2013, 2015 Red Hat, Inc. This file is part of Cygwin. @@ -36,7 +36,7 @@ details. */ static char *prog_name; static char *file_arg, *output_arg; -static int path_flag, unix_flag, windows_flag, absolute_flag; +static int path_flag, unix_flag, windows_flag, absolute_flag, cygdrive_flag; static int shortname_flag, longname_flag; static int ignore_flag, allusers_flag, output_flag; static int mixed_flag, options_from_file_flag, mode_flag; @@ -56,6 +56,7 @@ static struct option long_options[] = { {(char *) "mode", no_argument, NULL, 'M'}, {(char *) "option", no_argument, NULL, 'o'}, {(char *) "path", no_argument, NULL, 'p'}, + {(char *) "proc-cygdrive", no_argument, NULL, 'U'}, {(char *) "short-name", no_argument, NULL, 's'}, {(char *) "type", required_argument, NULL, 't'}, {(char *) "unix", no_argument, NULL, 'u'}, @@ -73,7 +74,7 @@ static struct option long_options[] = { {0, no_argument, 0, 0} }; -static char options[] = "ac:df:hilmMopst:uVwAC:DHOPSWF:"; +static char options[] = "ac:df:hilmMopst:uUVwAC:DHOPSWF:"; static void usage (FILE * stream, int status) @@ -101,6 +102,8 @@ Path conversion options:\n\ -a, --absolute output absolute path\n\ -l, --long-name print Windows long form of NAMEs (with -w, -m only)\n\ -p, --path NAME is a PATH list (i.e., '/bin:/usr/bin')\n\ + -U, --proc-cygdrive Emit /proc/cygdrive path instead of cygdrive prefix\n\ + when converting Windows path to UNIX path.\n\ -s, --short-name print DOS (short) form of NAMEs (with -w, -m only)\n\ -C, --codepage CP print DOS, Windows, or mixed pathname in Windows\n\ codepage CP. CP can be a numeric codepage identifier,\n\ @@ -607,7 +610,8 @@ do_sysfolders (char option) } else if (!windows_flag) { - if (cygwin_conv_path (CCP_WIN_W_TO_POSIX, wbuf, buf, PATH_MAX)) + if (cygwin_conv_path (CCP_WIN_W_TO_POSIX | cygdrive_flag, + wbuf, buf, PATH_MAX)) fprintf (stderr, "%s: error converting \"%ls\" - %s\n", prog_name, wbuf, strerror (errno)); } @@ -652,7 +656,7 @@ do_pathconv (char *filename) bool print_tmp = false; cygwin_conv_path_t conv_func = (unix_flag ? CCP_WIN_W_TO_POSIX : CCP_POSIX_TO_WIN_W) - | (absolute_flag ? CCP_ABSOLUTE : CCP_RELATIVE); + | absolute_flag | cygdrive_flag; if (!filename || !filename[0]) { @@ -792,6 +796,8 @@ do_options (int argc, char **argv, int from_file) output_flag = 0; mode_flag = 0; codepage = 0; + cygdrive_flag = 0; + absolute_flag = CCP_RELATIVE; if (!from_file) options_from_file_flag = 0; optind = 0; @@ -801,7 +807,7 @@ do_options (int argc, char **argv, int from_file) switch (c) { case 'a': - absolute_flag = 1; + absolute_flag = CCP_ABSOLUTE; break; case 'c': @@ -883,6 +889,10 @@ do_options (int argc, char **argv, int from_file) allusers_flag = 1; break; + case 'U': + cygdrive_flag = CCP_PROC_CYGDRIVE; + break; + case 'C': if (!optarg) usage (stderr, 1); |