4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-19 04:49:25 +08:00

* 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.
This commit is contained in:
Corinna Vinschen 2007-08-16 15:07:42 +00:00
parent 29fec364c0
commit 29992bf3da
9 changed files with 54 additions and 38 deletions

View File

@ -1,3 +1,17 @@
2007-08-16 Corinna Vinschen <corinna@vinschen.de>
* 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 <corinna@vinschen.de> 2007-08-16 Corinna Vinschen <corinna@vinschen.de>
* dir.cc (readdir_worker): Convert w32name to PUNICODE_STRING. * dir.cc (readdir_worker): Convert w32name to PUNICODE_STRING.

View File

@ -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 */ real_filename.check (name, PC_SYM_FOLLOW | PC_NOFULL | PC_NULLEMPTY); /* Convert */
if (!real_filename.error) if (!real_filename.error)
ret = strcpy (name, real_filename); ret = strcpy (name, real_filename.get_win32 ());
else else
{ {
set_errno (real_filename.error); set_errno (real_filename.error);

View File

@ -708,7 +708,9 @@ fhandler_socket::fchmod (mode_t mode)
fhandler_disk_file fh (pc); fhandler_disk_file fh (pc);
fh.get_device () = FH_FS; fh.get_device () = FH_FS;
int ret = fh.fchmod (adjust_socket_file_mode (mode)); 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; return ret;
} }
set_errno (EBADF); set_errno (EBADF);

View File

@ -219,7 +219,7 @@ ld_preload ()
for (p = strtok_r (s, ":\t\n", &here); p; p = strtok_r (NULL, ":\t\n", &here)) for (p = strtok_r (s, ":\t\n", &here); p; p = strtok_r (NULL, ":\t\n", &here))
{ {
path_conv lib (p); path_conv lib (p);
if (!LoadLibrary (lib)) if (!LoadLibrary (lib.get_win32 ()))
{ {
__seterrno (); __seterrno ();
api_fatal ("error while loading shared libraries: %s: " api_fatal ("error while loading shared libraries: %s: "

View File

@ -2929,7 +2929,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
{ {
strcpy (w32oldpath, oldpath); strcpy (w32oldpath, oldpath);
create_how = CREATE_ALWAYS; create_how = CREATE_ALWAYS;
SetFileAttributes (win32_path, FILE_ATTRIBUTE_NORMAL); SetFileAttributes (win32_path.get_win32 (), FILE_ATTRIBUTE_NORMAL);
} }
else else
{ {
@ -2952,7 +2952,8 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW, win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW,
transparent_exe ? stat_suffixes : NULL); transparent_exe ? stat_suffixes : NULL);
if (win32_oldpath.error != ENOENT) 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) else if (!use_winsym)
strcpy (w32oldpath, reloldpath); 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, win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW,
transparent_exe ? stat_suffixes : NULL); transparent_exe ? stat_suffixes : NULL);
strcpy (w32oldpath, win32_oldpath); strcpy (w32oldpath, win32_oldpath.get_win32 ());
} }
if (cp) if (cp)
{ {
@ -2972,7 +2973,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
{ {
win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW, win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW,
transparent_exe ? stat_suffixes : NULL); transparent_exe ? stat_suffixes : NULL);
strcpy (w32oldpath, win32_oldpath); strcpy (w32oldpath, win32_oldpath.get_win32 ());
} }
create_how = CREATE_NEW; 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, set_security_attribute (S_IFLNK | STD_RBITS | STD_WBITS,
&sa, sd); &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); FILE_ATTRIBUTE_NORMAL, 0);
if (h == INVALID_HANDLE_VALUE) if (h == INVALID_HANDLE_VALUE)
__seterrno (); __seterrno ();
@ -3066,7 +3067,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
CloseHandle (h); CloseHandle (h);
DWORD attr = use_winsym ? FILE_ATTRIBUTE_READONLY DWORD attr = use_winsym ? FILE_ATTRIBUTE_READONLY
: FILE_ATTRIBUTE_SYSTEM; : FILE_ATTRIBUTE_SYSTEM;
SetFileAttributes (win32_path, attr); SetFileAttributes (win32_path.get_win32 (), attr);
res = 0; res = 0;
} }
@ -3759,7 +3760,6 @@ hash_path_name (__ino64_t hash, PUNICODE_STRING name)
hash = L'\\' + (hash << 6) + (hash << 16) - hash; hash = L'\\' + (hash << 6) + (hash << 16) - hash;
} }
hashit:
/* Build up hash. Name is already normalized */ /* Build up hash. Name is already normalized */
USHORT len = name->Length / sizeof (WCHAR); USHORT len = name->Length / sizeof (WCHAR);
for (USHORT idx = 0; idx < len; ++idx) for (USHORT idx = 0; idx < len; ++idx)
@ -3834,7 +3834,7 @@ chdir (const char *in_dir)
int res = -1; int res = -1;
bool doit = false; 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 (); int devn = path.get_devn ();
if (!isvirtual_dev (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; return 0;
} }
@ -3933,7 +3934,7 @@ cygwin_conv_to_full_win32_path (const char *path, char *win32_path)
return -1; return -1;
} }
strcpy (win32_path, p); strcpy (win32_path, p.get_win32 ());
return 0; return 0;
} }
@ -4506,7 +4507,7 @@ etc::dir_changed (int n)
if (!changed_h) if (!changed_h)
{ {
path_conv pwd ("/etc"); path_conv pwd ("/etc");
changed_h = FindFirstChangeNotification (pwd, FALSE, changed_h = FindFirstChangeNotification (pwd.get_win32 (), FALSE,
FILE_NOTIFY_CHANGE_LAST_WRITE FILE_NOTIFY_CHANGE_LAST_WRITE
| FILE_NOTIFY_CHANGE_FILE_NAME); | FILE_NOTIFY_CHANGE_FILE_NAME);
#ifdef DEBUGGING #ifdef DEBUGGING

View File

@ -252,8 +252,6 @@ class path_conv
POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr, POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr,
SECURITY_ATTRIBUTES &sa); SECURITY_ATTRIBUTES &sa);
PWCHAR get_wide_win32_path (PWCHAR wc); PWCHAR get_wide_win32_path (PWCHAR wc);
operator char *() {return path;}
operator const char *() {return path;}
operator DWORD &() {return fileattr;} operator DWORD &() {return fileattr;}
operator int () {return fileattr; } operator int () {return fileattr; }
path_conv &operator =(path_conv &pc) path_conv &operator =(path_conv &pc)

View File

@ -82,11 +82,11 @@ perhaps_suffix (const char *prog, path_conv& buf, int& err, unsigned opt)
ext = NULL; ext = NULL;
} }
else if (buf.known_suffix) 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 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; return ext;
} }
@ -104,7 +104,7 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv,
{ {
const char *suffix = ""; const char *suffix = "";
debug_printf ("find_exec (%s)", name); debug_printf ("find_exec (%s)", name);
const char *retval = buf; const char *retval = buf.get_win32 ();
char tmp[CYG_MAX_PATH]; char tmp[CYG_MAX_PATH];
const char *posix = (opt & FE_NATIVE) ? NULL : name; const char *posix = (opt & FE_NATIVE) ? NULL : name;
bool has_slash = strchr (name, '/'); bool has_slash = strchr (name, '/');
@ -200,9 +200,9 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv,
out: out:
if (posix) if (posix)
buf.set_path (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) if (known_suffix)
*known_suffix = suffix ?: strchr (buf, '\0'); *known_suffix = suffix ?: strchr (buf.get_win32 (), '\0');
if (!retval && err) if (!retval && err)
set_errno (err); set_errno (err);
return retval; return retval;
@ -367,7 +367,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
real_path.check (prog_arg); real_path.check (prog_arg);
one_line.add ("\""); one_line.add ("\"");
if (!real_path.error) if (!real_path.error)
one_line.add (real_path); one_line.add (real_path.get_win32 ());
else else
one_line.add (argv[0]); one_line.add (argv[0]);
one_line.add ("\""); 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 (argv[1]);
one_line.add (" "); one_line.add (" ");
one_line.add (argv[2]); one_line.add (argv[2]);
strcpy (real_path, argv[0]); strcpy (real_path.get_win32 (), argv[0]);
null_app_name = true; null_app_name = true;
} }
else else
{ {
if (wascygexec) if (wascygexec)
newargv.dup_all (); 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; res = -1;
goto out; 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 ())) && (!ch.iscygwin () || mode != _P_OVERLAY || cygheap->fdtab.need_fixup_before ()))
c_flags |= CREATE_SUSPENDED; 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); syscall_printf ("null_app_name %d (%s, %.9500s)", null_app_name, runpath, one_line.buf);
@ -597,7 +597,7 @@ loop:
myself->dwProcessId = pi.dwProcessId; myself->dwProcessId = pi.dwProcessId;
strace.execing = 1; strace.execing = 1;
myself.hProcess = hExeced = pi.hProcess; 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); sigproc_printf ("new process name %s", myself->progname);
/* If wr_proc_pipe doesn't exist then this process was not started by a cygwin /* 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" process. So, we need to wait around until the process we've just "execed"
@ -638,7 +638,7 @@ loop:
child->dwProcessId = pi.dwProcessId; child->dwProcessId = pi.dwProcessId;
child.hProcess = pi.hProcess; 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. /* 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 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 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"); bool exeext = strcasematch (ext, ".exe");
if (exeext && real_path.iscygexec () || strcasematch (ext, ".bat")) if (exeext && real_path.iscygexec () || strcasematch (ext, ".bat"))
return 0; 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, ".bat") || strcasematch (p, ".cmd")
|| strcasematch (p, ".btm"))) || strcasematch (p, ".btm")))
return 0; return 0;
@ -920,7 +920,7 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext)
char *arg1 = NULL; char *arg1 = NULL;
char *ptr, *buf; 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, FILE_SHARE_READ | FILE_SHARE_WRITE,
&sec_none_nih, OPEN_EXISTING, &sec_none_nih, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0); 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; ptr = buf;
if (*ptr++ == '#' && *ptr++ == '!') if (*ptr++ == '#' && *ptr++ == '!')
@ -1019,7 +1019,7 @@ just_shell:
/* FIXME: This should not be using FE_NATIVE. It should be putting /* FIXME: This should not be using FE_NATIVE. It should be putting
the posix path on the argv list. */ the posix path on the argv list. */
find_exec (pgm, real_path, "PATH=", FE_NATIVE, &ext); find_exec (pgm, real_path, "PATH=", FE_NATIVE, &ext);
unshift (real_path, 1); unshift (real_path.get_win32 (), 1);
} }
return 0; return 0;

View File

@ -1125,7 +1125,7 @@ umask (mode_t mask)
int int
chmod_device (path_conv& pc, mode_t mode) 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 */ /* chmod: POSIX 5.6.4.1 */
@ -2395,7 +2395,7 @@ mknod32 (const char *path, mode_t mode, __dev32_t dev)
return -1; return -1;
} }
return mknod_worker (w32path, type, mode, major, minor); return mknod_worker (w32path.get_win32 (), type, mode, major, minor);
} }
extern "C" int extern "C" int
@ -2702,7 +2702,7 @@ chroot (const char *newroot)
else else
{ {
getwinenv("PATH="); /* Save the native PATH */ getwinenv("PATH="); /* Save the native PATH */
cygheap->root.set (path.normalized_path, path); cygheap->root.set (path.normalized_path, path.get_win32 ());
ret = 0; ret = 0;
} }

View File

@ -518,7 +518,7 @@ pwdgrp::load (const char *posix_fname)
curr_lines = 0; curr_lines = 0;
pc.check (posix_fname); 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); paranoid_printf ("%s", posix_fname);
@ -529,8 +529,9 @@ pwdgrp::load (const char *posix_fname)
} }
else else
{ {
HANDLE fh = CreateFile (pc, GENERIC_READ, FILE_SHARE_VALID_FLAGS, NULL, HANDLE fh = CreateFile (pc.get_win32 (), GENERIC_READ,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); FILE_SHARE_VALID_FLAGS, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
if (fh == INVALID_HANDLE_VALUE) if (fh == INVALID_HANDLE_VALUE)
{ {
paranoid_printf ("%s CreateFile failed, %E"); paranoid_printf ("%s CreateFile failed, %E");