diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7f95f16fd..aa244343f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,17 @@ +2007-08-16 Corinna Vinschen + + * path.h (path_conv::operator char *): Delete. + (path_conv::operator const char *): Delete. + * dlfcn.cc: Throughout, replace path_conv::operator char * and + path_conv::operator const char * by call to path_conv::get_win32 + for easier transition to UNICODE_PATHs. + * fhandler_socket.cc: Ditto. + * hookapi.cc: Ditto. + * path.cc: Ditto. + * spawn.cc: Ditto. + * syscalls.cc: Ditto. + * uinfo.cc: Ditto. + 2007-08-16 Corinna Vinschen * dir.cc (readdir_worker): Convert w32name to PUNICODE_STRING. diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc index 3893045b3..bcdc452ef 100644 --- a/winsup/cygwin/dlfcn.cc +++ b/winsup/cygwin/dlfcn.cc @@ -72,7 +72,7 @@ get_full_path_of_dll (const char* str, char *name) real_filename.check (name, PC_SYM_FOLLOW | PC_NOFULL | PC_NULLEMPTY); /* Convert */ if (!real_filename.error) - ret = strcpy (name, real_filename); + ret = strcpy (name, real_filename.get_win32 ()); else { set_errno (real_filename.error); diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 44002c5eb..a5a13d064 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -708,7 +708,9 @@ fhandler_socket::fchmod (mode_t mode) fhandler_disk_file fh (pc); fh.get_device () = FH_FS; int ret = fh.fchmod (adjust_socket_file_mode (mode)); - SetFileAttributes (pc, GetFileAttributes (pc) | FILE_ATTRIBUTE_SYSTEM); + SetFileAttributesA (pc.get_win32 (), + GetFileAttributesA (pc.get_win32 ()) + | FILE_ATTRIBUTE_SYSTEM); return ret; } set_errno (EBADF); diff --git a/winsup/cygwin/hookapi.cc b/winsup/cygwin/hookapi.cc index 39ba6de88..552b8bb86 100644 --- a/winsup/cygwin/hookapi.cc +++ b/winsup/cygwin/hookapi.cc @@ -219,7 +219,7 @@ ld_preload () for (p = strtok_r (s, ":\t\n", &here); p; p = strtok_r (NULL, ":\t\n", &here)) { path_conv lib (p); - if (!LoadLibrary (lib)) + if (!LoadLibrary (lib.get_win32 ())) { __seterrno (); api_fatal ("error while loading shared libraries: %s: " diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index a8b64da98..953efce42 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2929,7 +2929,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym, { strcpy (w32oldpath, oldpath); create_how = CREATE_ALWAYS; - SetFileAttributes (win32_path, FILE_ATTRIBUTE_NORMAL); + SetFileAttributes (win32_path.get_win32 (), FILE_ATTRIBUTE_NORMAL); } else { @@ -2952,7 +2952,8 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym, win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW, transparent_exe ? stat_suffixes : NULL); if (win32_oldpath.error != ENOENT) - strcpy (use_winsym ? reloldpath : w32oldpath, win32_oldpath); + strcpy (use_winsym ? reloldpath : w32oldpath, + win32_oldpath.get_win32 ()); } else if (!use_winsym) strcpy (w32oldpath, reloldpath); @@ -2960,7 +2961,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym, { win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW, transparent_exe ? stat_suffixes : NULL); - strcpy (w32oldpath, win32_oldpath); + strcpy (w32oldpath, win32_oldpath.get_win32 ()); } if (cp) { @@ -2972,7 +2973,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym, { win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW, transparent_exe ? stat_suffixes : NULL); - strcpy (w32oldpath, win32_oldpath); + strcpy (w32oldpath, win32_oldpath.get_win32 ()); } create_how = CREATE_NEW; } @@ -2981,7 +2982,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym, set_security_attribute (S_IFLNK | STD_RBITS | STD_WBITS, &sa, sd); - h = CreateFile (win32_path, GENERIC_WRITE, 0, &sa, create_how, + h = CreateFile (win32_path.get_win32 (), GENERIC_WRITE, 0, &sa, create_how, FILE_ATTRIBUTE_NORMAL, 0); if (h == INVALID_HANDLE_VALUE) __seterrno (); @@ -3066,7 +3067,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym, CloseHandle (h); DWORD attr = use_winsym ? FILE_ATTRIBUTE_READONLY : FILE_ATTRIBUTE_SYSTEM; - SetFileAttributes (win32_path, attr); + SetFileAttributes (win32_path.get_win32 (), attr); res = 0; } @@ -3759,7 +3760,6 @@ hash_path_name (__ino64_t hash, PUNICODE_STRING name) hash = L'\\' + (hash << 6) + (hash << 16) - hash; } -hashit: /* Build up hash. Name is already normalized */ USHORT len = name->Length / sizeof (WCHAR); for (USHORT idx = 0; idx < len; ++idx) @@ -3834,7 +3834,7 @@ chdir (const char *in_dir) int res = -1; bool doit = false; - const char *native_dir = path, *posix_cwd = NULL; + const char *native_dir = path.get_win32 (), *posix_cwd = NULL; int devn = path.get_devn (); if (!isvirtual_dev (devn)) { @@ -3918,7 +3918,8 @@ cygwin_conv_to_win32_path (const char *path, char *win32_path) } - strcpy (win32_path, strcmp ((char *) p, ".\\") == 0 ? "." : (char *) p); + strcpy (win32_path, + strcmp (p.get_win32 (), ".\\") == 0 ? "." : p.get_win32 ()); return 0; } @@ -3933,7 +3934,7 @@ cygwin_conv_to_full_win32_path (const char *path, char *win32_path) return -1; } - strcpy (win32_path, p); + strcpy (win32_path, p.get_win32 ()); return 0; } @@ -4506,7 +4507,7 @@ etc::dir_changed (int n) if (!changed_h) { path_conv pwd ("/etc"); - changed_h = FindFirstChangeNotification (pwd, FALSE, + changed_h = FindFirstChangeNotification (pwd.get_win32 (), FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_FILE_NAME); #ifdef DEBUGGING diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 32634af82..eb3fb5d74 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -252,8 +252,6 @@ class path_conv POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr, SECURITY_ATTRIBUTES &sa); PWCHAR get_wide_win32_path (PWCHAR wc); - operator char *() {return path;} - operator const char *() {return path;} operator DWORD &() {return fileattr;} operator int () {return fileattr; } path_conv &operator =(path_conv &pc) diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 604376880..6a658e92e 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -82,11 +82,11 @@ perhaps_suffix (const char *prog, path_conv& buf, int& err, unsigned opt) ext = NULL; } else if (buf.known_suffix) - ext = (char *) buf + (buf.known_suffix - buf.get_win32 ()); + ext = buf.get_win32 () + (buf.known_suffix - buf.get_win32 ()); else - ext = strchr (buf, '\0'); + ext = strchr (buf.get_win32 (), '\0'); - debug_printf ("buf %s, suffix found '%s'", (char *) buf, ext); + debug_printf ("buf %s, suffix found '%s'", (char *) buf.get_win32 (), ext); return ext; } @@ -104,7 +104,7 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv, { const char *suffix = ""; debug_printf ("find_exec (%s)", name); - const char *retval = buf; + const char *retval = buf.get_win32 (); char tmp[CYG_MAX_PATH]; const char *posix = (opt & FE_NATIVE) ? NULL : name; bool has_slash = strchr (name, '/'); @@ -200,9 +200,9 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv, out: if (posix) buf.set_path (posix); - debug_printf ("%s = find_exec (%s)", (char *) buf, name); + debug_printf ("%s = find_exec (%s)", (char *) buf.get_win32 (), name); if (known_suffix) - *known_suffix = suffix ?: strchr (buf, '\0'); + *known_suffix = suffix ?: strchr (buf.get_win32 (), '\0'); if (!retval && err) set_errno (err); return retval; @@ -367,7 +367,7 @@ spawn_guts (const char * prog_arg, const char *const *argv, real_path.check (prog_arg); one_line.add ("\""); if (!real_path.error) - one_line.add (real_path); + one_line.add (real_path.get_win32 ()); else one_line.add (argv[0]); one_line.add ("\""); @@ -375,14 +375,14 @@ spawn_guts (const char * prog_arg, const char *const *argv, one_line.add (argv[1]); one_line.add (" "); one_line.add (argv[2]); - strcpy (real_path, argv[0]); + strcpy (real_path.get_win32 (), argv[0]); null_app_name = true; } else { if (wascygexec) newargv.dup_all (); - else if (!one_line.fromargv (newargv, real_path, real_path.iscygexec ())) + else if (!one_line.fromargv (newargv, real_path.get_win32 (), real_path.iscygexec ())) { res = -1; goto out; @@ -459,7 +459,7 @@ spawn_guts (const char * prog_arg, const char *const *argv, && (!ch.iscygwin () || mode != _P_OVERLAY || cygheap->fdtab.need_fixup_before ())) c_flags |= CREATE_SUSPENDED; - runpath = null_app_name ? NULL : (const char *) real_path; + runpath = null_app_name ? NULL : real_path.get_win32 (); syscall_printf ("null_app_name %d (%s, %.9500s)", null_app_name, runpath, one_line.buf); @@ -597,7 +597,7 @@ loop: myself->dwProcessId = pi.dwProcessId; strace.execing = 1; myself.hProcess = hExeced = pi.hProcess; - strcpy (myself->progname, real_path); // FIXME: race? + strcpy (myself->progname, real_path.get_win32 ()); // FIXME: race? sigproc_printf ("new process name %s", myself->progname); /* If wr_proc_pipe doesn't exist then this process was not started by a cygwin process. So, we need to wait around until the process we've just "execed" @@ -638,7 +638,7 @@ loop: child->dwProcessId = pi.dwProcessId; child.hProcess = pi.hProcess; - strcpy (child->progname, real_path); + strcpy (child->progname, real_path.get_win32 ()); /* FIXME: This introduces an unreferenced, open handle into the child. The purpose is to keep the pid shared memory open so that all of the fields filled out by child.remember do not disappear and so there @@ -910,7 +910,7 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext) bool exeext = strcasematch (ext, ".exe"); if (exeext && real_path.iscygexec () || strcasematch (ext, ".bat")) return 0; - if (!*ext && ((p = ext - 4) > (char *) real_path) + if (!*ext && ((p = ext - 4) > real_path.get_win32 ()) && (strcasematch (p, ".bat") || strcasematch (p, ".cmd") || strcasematch (p, ".btm"))) return 0; @@ -920,7 +920,7 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext) char *arg1 = NULL; char *ptr, *buf; - HANDLE h = CreateFile (real_path, GENERIC_READ, + HANDLE h = CreateFile (real_path.get_win32 (), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none_nih, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); @@ -966,7 +966,7 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext) } } - debug_printf ("%s is possibly a script", (char *) real_path); + debug_printf ("%s is possibly a script", real_path.get_win32 ()); ptr = buf; if (*ptr++ == '#' && *ptr++ == '!') @@ -1019,7 +1019,7 @@ just_shell: /* FIXME: This should not be using FE_NATIVE. It should be putting the posix path on the argv list. */ find_exec (pgm, real_path, "PATH=", FE_NATIVE, &ext); - unshift (real_path, 1); + unshift (real_path.get_win32 (), 1); } return 0; diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 63df37e2c..905f77425 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1125,7 +1125,7 @@ umask (mode_t mask) int chmod_device (path_conv& pc, mode_t mode) { - return mknod_worker (pc, pc.dev.mode & S_IFMT, mode, pc.dev.major, pc.dev.minor); + return mknod_worker (pc.get_win32 (), pc.dev.mode & S_IFMT, mode, pc.dev.major, pc.dev.minor); } /* chmod: POSIX 5.6.4.1 */ @@ -2395,7 +2395,7 @@ mknod32 (const char *path, mode_t mode, __dev32_t dev) return -1; } - return mknod_worker (w32path, type, mode, major, minor); + return mknod_worker (w32path.get_win32 (), type, mode, major, minor); } extern "C" int @@ -2702,7 +2702,7 @@ chroot (const char *newroot) else { getwinenv("PATH="); /* Save the native PATH */ - cygheap->root.set (path.normalized_path, path); + cygheap->root.set (path.normalized_path, path.get_win32 ()); ret = 0; } diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index a6d8c41b3..4ebe7245c 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -518,7 +518,7 @@ pwdgrp::load (const char *posix_fname) curr_lines = 0; pc.check (posix_fname); - etc_ix = etc::init (etc_ix, pc); + etc_ix = etc::init (etc_ix, pc.get_win32 ()); paranoid_printf ("%s", posix_fname); @@ -529,8 +529,9 @@ pwdgrp::load (const char *posix_fname) } else { - HANDLE fh = CreateFile (pc, GENERIC_READ, FILE_SHARE_VALID_FLAGS, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + HANDLE fh = CreateFile (pc.get_win32 (), GENERIC_READ, + FILE_SHARE_VALID_FLAGS, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, 0); if (fh == INVALID_HANDLE_VALUE) { paranoid_printf ("%s CreateFile failed, %E");