diff options
author | Christopher Faylor <me@cgf.cx> | 2006-08-01 22:00:44 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2006-08-01 22:00:44 +0400 |
commit | 01bbb24d1514058a6373236712cea3334315c9c0 (patch) | |
tree | fb7b50fd6ff14beff107fb56b6d19d8ababc47af | |
parent | a121349405f9daf1464042cb50995d8d0e7a7818 (diff) |
* environ.cc (dos_file_warning): Declare.
(parse_thing): Add "dosfilewarning". Alphabetize.
* path.cc (normalize_posix_path): Return -1 when MS-DOS path detected.
(warn_msdos): New function.
(path_conv::check): Call if !PC_NOWARN and MS-DOS path detected.
(cygwin_conv_to_win32_path): Set PC_NOWARN when calling path_conv.
(cygwin_conv_to_full_win32_path): Ditto.
* path.h (pathconv_arg::PC_NOWARN): Define.
* shared_info.h (user_info::warned_msdos): New field.
(CURR_USER_MAGIC): Reset.
-rw-r--r-- | winsup/cygwin/ChangeLog | 13 | ||||
-rw-r--r-- | winsup/cygwin/environ.cc | 6 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 41 | ||||
-rw-r--r-- | winsup/cygwin/path.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/shared_info.h | 4 |
5 files changed, 55 insertions, 10 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e55394f79..f2f42c7b4 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,16 @@ +2006-08-01 Christopher Faylor <cgf@timesys.com> + + * environ.cc (dos_file_warning): Declare. + (parse_thing): Add "dosfilewarning". Alphabetize. + * path.cc (normalize_posix_path): Return -1 when MS-DOS path detected. + (warn_msdos): New function. + (path_conv::check): Call if !PC_NOWARN and MS-DOS path detected. + (cygwin_conv_to_win32_path): Set PC_NOWARN when calling path_conv. + (cygwin_conv_to_full_win32_path): Ditto. + * path.h (pathconv_arg::PC_NOWARN): Define. + * shared_info.h (user_info::warned_msdos): New field. + (CURR_USER_MAGIC): Reset. + 2006-07-31 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::recv_internal): Fix a problem diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 4d6ae3e4a..2e8acddcb 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -28,6 +28,7 @@ details. */ #include "environ.h" #include "child_info.h" +extern bool dos_file_warning; extern bool allow_glob; extern bool ignore_case_with_glob; extern bool allow_winsymlinks; @@ -593,6 +594,7 @@ static struct parse_thing {"binmode", {x: &binmode}, justset, NULL, {{O_TEXT}, {O_BINARY}}}, {"check_case", {func: &check_case_init}, isfunc, NULL, {{0}, {0}}}, {"codepage", {func: &codepage_init}, isfunc, NULL, {{0}, {0}}}, + {"dosfilewarning", {&dos_file_warning}, justset, NULL, {{false}, {true}}}, {"envcache", {&envcache}, justset, NULL, {{true}, {false}}}, {"error_start", {func: &error_start_init}, isfunc, NULL, {{0}, {0}}}, {"export", {&export_settings}, justset, NULL, {{false}, {true}}}, @@ -600,7 +602,7 @@ static struct parse_thing {"glob", {func: &glob_init}, isfunc, NULL, {{0}, {s: "normal"}}}, {"ntea", {func: set_ntea}, isfunc, NULL, {{0}, {s: "yes"}}}, {"ntsec", {func: set_ntsec}, isfunc, NULL, {{0}, {s: "yes"}}}, - {"traverse", {func: set_traverse}, isfunc, NULL, {{0}, {s: "yes"}}}, + {"proc_retry", {func: set_proc_retry}, isfunc, NULL, {{0}, {5}}}, {"reset_com", {&reset_com}, justset, NULL, {{false}, {true}}}, #ifdef USE_SERVER {"server", {&allow_server}, justset, NULL, {{false}, {true}}}, @@ -609,10 +611,10 @@ static struct parse_thing {"strip_title", {&strip_title_path}, justset, NULL, {{false}, {true}}}, {"subauth_id", {func: &subauth_id_init}, isfunc, NULL, {{0}, {0}}}, {"title", {&display_title}, justset, NULL, {{false}, {true}}}, + {"traverse", {func: set_traverse}, isfunc, NULL, {{0}, {s: "yes"}}}, {"tty", {NULL}, set_process_state, NULL, {{0}, {PID_USETTY}}}, {"winsymlinks", {&allow_winsymlinks}, justset, NULL, {{false}, {true}}}, {"transparent_exe", {&transparent_exe}, justset, NULL, {{false}, {true}}}, - {"proc_retry", {func: set_proc_retry}, isfunc, NULL, {{0}, {5}}}, {NULL, {0}, justset, 0, {{0}, {0}}} }; diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index f857f168e..9a91aceb9 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -77,6 +77,7 @@ details. */ #include "cygtls.h" #include <assert.h> +bool dos_file_warning = true; static int normalize_win32_path (const char *, char *, char *&); static void slashify (const char *, char *, int); static void backslashify (const char *, char *, int); @@ -208,8 +209,7 @@ pathmatch (const char *path1, const char *path2) /* TODO: This function is used in mkdir and rmdir to generate correct error messages in case of paths ending in /. or /.. components. - This test should eventually end up in path_conv::check in one way - or another. Right now, normalize_posix_path will just normalize + Right now, normalize_posix_path will just normalize those components away, which changes the semantics. */ bool has_dot_last_component (const char *dir) @@ -322,7 +322,7 @@ win32_path: if (!err) for (char *p = dst; (p = strchr (p, '\\')); p++) *p = '/'; - return err; + return err ?: -1; } inline void @@ -539,6 +539,26 @@ path_conv::get_nt_native_path (UNICODE_STRING &upath) return &upath; } +void +warn_msdos (const char *src) +{ + if (user_shared->warned_msdos || !dos_file_warning) + return; + char posix_path[CYG_MAX_PATH]; + small_printf ("cygwin warning:\n"); + if (cygwin_conv_to_full_posix_path (src, posix_path)) + small_printf (" MS-DOS style path detected: %s\n POSIX equivalent preferred.\n", + src); + else + small_printf (" MS-DOS style path detected: %s\n Preferred POSIX equivalent is: %s\n", + src, posix_path); + small_printf (" CYGWIN environment variable option \"nodosfilewarning\" turns off this warning.\n" + " Consult the user's guide for more details about POSIX paths:\n" + " http://cygwin.com/cygwin-ug-net/using.html#using-pathnames\n"); + + user_shared->warned_msdos = true; +} + /* Convert an arbitrary path SRC to a pure Win32 path, suitable for passing to Win32 API routines. @@ -602,6 +622,7 @@ path_conv::check (const char *src, unsigned opt, return; } + bool is_msdos = false; /* This loop handles symlink expansion. */ for (;;) { @@ -610,8 +631,14 @@ path_conv::check (const char *src, unsigned opt, is_relpath = !isabspath (src); error = normalize_posix_path (src, path_copy, tail); - if (error) + if (error > 0) return; + if (error < 0) + { + if (component == 0) + is_msdos = true; + error = 0; + } /* 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 @@ -1059,6 +1086,8 @@ out: if (tail < path_end && tail > path_copy + 1) *tail = '/'; set_normalized_path (path_copy, strip_tail); + if (is_msdos && !(opt & PC_NOWARN)) + warn_msdos (src); } #if 0 @@ -3646,7 +3675,7 @@ fchdir (int fd) extern "C" int cygwin_conv_to_win32_path (const char *path, char *win32_path) { - path_conv p (path, PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK | PC_NOFULL); + path_conv p (path, PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK | PC_NOFULL | PC_NOWARN); if (p.error) { win32_path[0] = '\0'; @@ -3662,7 +3691,7 @@ cygwin_conv_to_win32_path (const char *path, char *win32_path) extern "C" int cygwin_conv_to_full_win32_path (const char *path, char *win32_path) { - path_conv p (path, PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK); + path_conv p (path, PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK | PC_NOWARN); if (p.error) { win32_path[0] = '\0'; diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index d432e70d3..038ed0cf2 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -47,6 +47,7 @@ enum pathconv_arg PC_NULLEMPTY = 0x0020, PC_CHECK_EA = 0x0040, PC_POSIX = 0x0080, + PC_NOWARN = 0x0100, PC_NO_ACCESS_CHECK = 0x00800000 }; diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index 17a21b4cc..ff9361605 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -44,7 +44,7 @@ class mount_item #define USER_VERSION 1 // increment when mount table changes and #define USER_VERSION_MAGIC CYGWIN_VERSION_MAGIC (USER_MAGIC, USER_VERSION) -#define CURR_USER_MAGIC 0x8dc7b1d5U +#define CURR_USER_MAGIC 0x38edd704U class reg_key; struct device; @@ -133,6 +133,7 @@ public: DWORD version; DWORD cb; delqueue_list delqueue; + bool warned_msdos; mount_info mountinfo; }; /******** Shared Info ********/ @@ -197,4 +198,3 @@ void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD si shared_locations&, PSECURITY_ATTRIBUTES psa = &sec_all, DWORD access = FILE_MAP_READ | FILE_MAP_WRITE); extern void user_shared_initialize (bool reinit); - |