2004-06-17 Pierre Humblet <pierre.humblet@ieee.org>
* fhandler.cc (fhandler_base::open_9x): Do not check for null name. Move debug_printf to common code line. (fhandler_base::open): Ditto. Initialize upath. Remove second argument of pc.get_nt_native_path. * path.h (path_conv::get_nt_native_path): Remove second argument. * path.cc (path_conv::get_nt_native_path): Ditto. Call str2uni_cat. * security.h (str2buf2uni_cat): Delete declaration. (str2uni_cat): New declaration. * security.cc (str2buf2uni): Get length from sys_mbstowcs call. (str2buf2uni_cat): Delete function. (str2uni_cat): New function. * miscfuncs.cc (sys_mbstowcs): Add debug_printf.
This commit is contained in:
parent
9f35b46456
commit
bd0e9c7aa6
|
@ -1,3 +1,18 @@
|
|||
2004-06-17 Pierre Humblet <pierre.humblet@ieee.org>
|
||||
|
||||
* fhandler.cc (fhandler_base::open_9x): Do not check for null name.
|
||||
Move debug_printf to common code line.
|
||||
(fhandler_base::open): Ditto. Initialize upath. Remove second argument
|
||||
of pc.get_nt_native_path.
|
||||
* path.h (path_conv::get_nt_native_path): Remove second argument.
|
||||
* path.cc (path_conv::get_nt_native_path): Ditto. Call str2uni_cat.
|
||||
* security.h (str2buf2uni_cat): Delete declaration.
|
||||
(str2uni_cat): New declaration.
|
||||
* security.cc (str2buf2uni): Get length from sys_mbstowcs call.
|
||||
(str2buf2uni_cat): Delete function.
|
||||
(str2uni_cat): New function.
|
||||
* miscfuncs.cc (sys_mbstowcs): Add debug_printf.
|
||||
|
||||
2004-06-17 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* fhandler.cc (fhandler_base::open): Substitute FILE_SUPERSEDE with
|
||||
|
|
|
@ -437,12 +437,6 @@ fhandler_base::open_9x (int flags, mode_t mode)
|
|||
|
||||
syscall_printf ("(%s, %p)", get_win32_name (), flags);
|
||||
|
||||
if (get_win32_name () == NULL)
|
||||
{
|
||||
set_errno (ENOENT);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDONLY)
|
||||
access = GENERIC_READ;
|
||||
else if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY)
|
||||
|
@ -512,16 +506,16 @@ fhandler_base::open_9x (int flags, mode_t mode)
|
|||
goto done;
|
||||
}
|
||||
|
||||
syscall_printf ("%p = CreateFile (%s, %p, %p, %p, %p, %p, 0)",
|
||||
x, get_win32_name (), access, shared, &sa,
|
||||
creation_distribution, file_attributes);
|
||||
|
||||
set_io_handle (x);
|
||||
set_flags (flags, pc.binmode ());
|
||||
|
||||
res = 1;
|
||||
set_open_status ();
|
||||
done:
|
||||
debug_printf ("%p = CreateFile (%s, %p, %p, %p, %p, %p, 0)",
|
||||
x, get_win32_name (), access, shared, &sa,
|
||||
creation_distribution, file_attributes);
|
||||
|
||||
syscall_printf ("%d = fhandler_base::open (%s, %p)", res, get_win32_name (),
|
||||
flags);
|
||||
return res;
|
||||
|
@ -534,11 +528,11 @@ fhandler_base::open (int flags, mode_t mode)
|
|||
if (!wincap.is_winnt ())
|
||||
return fhandler_base::open_9x (flags, mode);
|
||||
|
||||
UNICODE_STRING upath;
|
||||
WCHAR wpath[CYG_MAX_PATH + 10];
|
||||
pc.get_nt_native_path (upath, wpath);
|
||||
UNICODE_STRING upath = {0, sizeof (wpath), wpath};
|
||||
pc.get_nt_native_path (upath);
|
||||
|
||||
if (RtlIsDosDeviceName_U (wpath))
|
||||
if (RtlIsDosDeviceName_U (upath.Buffer))
|
||||
return fhandler_base::open_9x (flags, mode);
|
||||
|
||||
int res = 0;
|
||||
|
@ -554,11 +548,6 @@ fhandler_base::open (int flags, mode_t mode)
|
|||
NTSTATUS status;
|
||||
|
||||
syscall_printf ("(%s, %p)", get_win32_name (), flags);
|
||||
if (get_win32_name () == NULL)
|
||||
{
|
||||
set_errno (ENOENT);
|
||||
goto done;
|
||||
}
|
||||
|
||||
InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
|
||||
sa.lpSecurityDescriptor, NULL);
|
||||
|
@ -657,17 +646,17 @@ fhandler_base::open (int flags, mode_t mode)
|
|||
goto done;
|
||||
}
|
||||
|
||||
syscall_printf ("%x = NtCreateFile "
|
||||
"(%p, %x, %s, io, NULL, %x, %x, %x, %x, NULL, 0)",
|
||||
status, x, access, get_win32_name (), file_attributes, shared,
|
||||
create_disposition, create_options);
|
||||
|
||||
set_io_handle (x);
|
||||
set_flags (flags, pc.binmode ());
|
||||
|
||||
res = 1;
|
||||
set_open_status ();
|
||||
done:
|
||||
debug_printf ("%x = NtCreateFile "
|
||||
"(%p, %x, %s, io, NULL, %x, %x, %x, %x, NULL, 0)",
|
||||
status, x, access, get_win32_name (), file_attributes, shared,
|
||||
create_disposition, create_options);
|
||||
|
||||
syscall_printf ("%d = fhandler_base::open (%s, %p)", res, get_win32_name (),
|
||||
flags);
|
||||
return res;
|
||||
|
|
|
@ -312,7 +312,10 @@ sys_wcstombs (char *tgt, const WCHAR *src, int len)
|
|||
int __stdcall
|
||||
sys_mbstowcs (WCHAR *tgt, const char *src, int len)
|
||||
{
|
||||
return MultiByteToWideChar (get_cp (), 0, src, -1, tgt, len);
|
||||
int res = MultiByteToWideChar (get_cp (), 0, src, -1, tgt, len);
|
||||
if (!res)
|
||||
debug_printf ("MultiByteToWideChar %E");
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
|
|
|
@ -459,25 +459,25 @@ path_conv::set_normalized_path (const char *path_copy)
|
|||
}
|
||||
|
||||
PUNICODE_STRING
|
||||
path_conv::get_nt_native_path (UNICODE_STRING &upath, WCHAR *wpath)
|
||||
path_conv::get_nt_native_path (UNICODE_STRING &upath)
|
||||
{
|
||||
if (path[0] != '\\') /* X:\... or NUL, etc. */
|
||||
{
|
||||
str2buf2uni (upath, wpath, "\\??\\");
|
||||
str2buf2uni_cat (upath, path);
|
||||
str2uni_cat (upath, "\\??\\");
|
||||
str2uni_cat (upath, path);
|
||||
}
|
||||
else if (path[1] != '\\') /* \Device\... */
|
||||
str2buf2uni (upath, wpath, path);
|
||||
str2uni_cat (upath, path);
|
||||
else if (path[2] != '.'
|
||||
|| path[3] != '\\') /* \\server\share\... */
|
||||
{
|
||||
str2buf2uni (upath, wpath, "\\??\\UNC\\");
|
||||
str2buf2uni_cat (upath, path + 2);
|
||||
str2uni_cat (upath, "\\??\\UNC\\");
|
||||
str2uni_cat (upath, path + 2);
|
||||
}
|
||||
else /* \\.\device */
|
||||
{
|
||||
str2buf2uni (upath, wpath, "\\??\\");
|
||||
str2buf2uni_cat (upath, path + 4);
|
||||
str2uni_cat (upath, "\\??\\");
|
||||
str2uni_cat (upath, path + 4);
|
||||
}
|
||||
return &upath;
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ class path_conv
|
|||
|
||||
~path_conv ();
|
||||
inline char *get_win32 () { return path; }
|
||||
PUNICODE_STRING get_nt_native_path (UNICODE_STRING &upath, WCHAR *wpath);
|
||||
PUNICODE_STRING get_nt_native_path (UNICODE_STRING &upath);
|
||||
operator char *() {return path;}
|
||||
operator const char *() {return path;}
|
||||
operator DWORD &() {return fileattr;}
|
||||
|
|
|
@ -156,23 +156,28 @@ str2buf2lsa (LSA_STRING &tgt, char *buf, const char *srcstr)
|
|||
memcpy (buf, srcstr, tgt.MaximumLength);
|
||||
}
|
||||
|
||||
/* The dimension of buf is assumed to be at least strlen(srcstr) + 1,
|
||||
The result will be shorter if the input has multibyte chars */
|
||||
void
|
||||
str2buf2uni (UNICODE_STRING &tgt, WCHAR *buf, const char *srcstr)
|
||||
{
|
||||
tgt.Length = strlen (srcstr) * sizeof (WCHAR);
|
||||
tgt.MaximumLength = tgt.Length + sizeof (WCHAR);
|
||||
tgt.Buffer = (PWCHAR) buf;
|
||||
sys_mbstowcs (buf, srcstr, tgt.MaximumLength);
|
||||
tgt.MaximumLength = (strlen (srcstr) + 1) * sizeof (WCHAR);
|
||||
tgt.Length = sys_mbstowcs (buf, srcstr, tgt.MaximumLength / sizeof (WCHAR))
|
||||
* sizeof (WCHAR);
|
||||
if (tgt.Length)
|
||||
tgt.Length -= sizeof (WCHAR);
|
||||
}
|
||||
|
||||
void
|
||||
str2buf2uni_cat (UNICODE_STRING &tgt, const char *srcstr)
|
||||
str2uni_cat (UNICODE_STRING &tgt, const char *srcstr)
|
||||
{
|
||||
DWORD len = strlen (srcstr) * sizeof (WCHAR);
|
||||
sys_mbstowcs (tgt.Buffer + tgt.Length / sizeof (WCHAR), srcstr,
|
||||
len + tgt.MaximumLength);
|
||||
tgt.Length += len;
|
||||
tgt.MaximumLength += len;
|
||||
int len = sys_mbstowcs (tgt.Buffer + tgt.Length / sizeof (WCHAR), srcstr,
|
||||
(tgt.MaximumLength - tgt.Length) / sizeof (WCHAR));
|
||||
if (len)
|
||||
tgt.Length += (len - 1) * sizeof (WCHAR);
|
||||
else
|
||||
tgt.Length = tgt.MaximumLength = 0;
|
||||
}
|
||||
|
||||
#if 0 /* unused */
|
||||
|
|
|
@ -276,7 +276,7 @@ int setacl (HANDLE, const char *, int, __acl32 *);
|
|||
|
||||
struct _UNICODE_STRING;
|
||||
void __stdcall str2buf2uni (_UNICODE_STRING &, WCHAR *, const char *) __attribute__ ((regparm (3)));
|
||||
void __stdcall str2buf2uni_cat (_UNICODE_STRING &, const char *) __attribute__ ((regparm (2)));
|
||||
void __stdcall str2uni_cat (_UNICODE_STRING &, const char *) __attribute__ ((regparm (2)));
|
||||
|
||||
/* Try a subauthentication. */
|
||||
HANDLE subauth (struct passwd *pw);
|
||||
|
|
Loading…
Reference in New Issue