Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2007-07-28 20:00:35 +0400
committerCorinna Vinschen <corinna@vinschen.de>2007-07-28 20:00:35 +0400
commit74c5e8c73ace5043a1a78b479d7b701be3f5966d (patch)
tree4f92cc9c959df3543a3a6637d6c2526721799831
parent745c29fe7b54844aad20e62891624ea9a0063d9a (diff)
* ntdll.h (RtlInitCountedUnicodeString): Swap order of string and length
parameters to be the same as for RtlInitEmptyUnicodeString. (RtlEqualPathPrefix): New inline function. (RtlEqualPathSuffix): New inline function. * fhandler_disk_file.cc: Accommodate parameter order change of RtlInitEmptyUnicodeString throughout. (fhandler_disk_file::link): Do path checking in unicode. Call CopyFileW instead of CopyFileA.
-rw-r--r--winsup/cygwin/ChangeLog11
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc35
-rw-r--r--winsup/cygwin/ntdll.h37
3 files changed, 61 insertions, 22 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 0ddebd52d..c54330ca2 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,16 @@
2007-07-27 Corinna Vinschen <corinna@vinschen.de>
+ * ntdll.h (RtlInitCountedUnicodeString): Swap order of string and length
+ parameters to be the same as for RtlInitEmptyUnicodeString.
+ (RtlEqualPathPrefix): New inline function.
+ (RtlEqualPathSuffix): New inline function.
+ * fhandler_disk_file.cc: Accommodate parameter order change of
+ RtlInitEmptyUnicodeString throughout.
+ (fhandler_disk_file::link): Do path checking in unicode. Call
+ CopyFileW instead of CopyFileA.
+
+2007-07-27 Corinna Vinschen <corinna@vinschen.de>
+
* autoload.cc (CreateHardLinkA): Remove.
* fhandler_disk_file.cc (fhandler_disk_file::link): Drop GetBinaryType
test. Just check exe suffix instead. Tune creating new file name.
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index dcbc137e9..ef46beeaf 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -223,8 +223,8 @@ path_conv::ndisk_links (DWORD nNumberOfLinks)
{
UNICODE_STRING fname;
- RtlInitCountedUnicodeString (&fname, pfdi->FileNameLength,
- pfdi->FileName);
+ RtlInitCountedUnicodeString (&fname, pfdi->FileName,
+ pfdi->FileNameLength);
InitializeObjectAttributes (&attr, &fname,
OBJ_CASE_INSENSITIVE, fh, NULL);
if (is_volume_mountpoint (&attr))
@@ -235,8 +235,8 @@ path_conv::ndisk_links (DWORD nNumberOfLinks)
break;
}
UNICODE_STRING fname;
- RtlInitCountedUnicodeString (&fname, pfdi->FileNameLength,
- pfdi->FileName);
+ RtlInitCountedUnicodeString (&fname, pfdi->FileName,
+ pfdi->FileNameLength);
dir->check_mount (&fname, 0, false);
}
}
@@ -1043,8 +1043,6 @@ fhandler_disk_file::link (const char *newpath)
char new_buf[strlen (newpath) + 5];
if (!newpc.error && !newpc.case_clash)
{
- int len;
-
if (allow_winsymlinks && pc.is_lnk_special ())
{
/* Shortcut hack. */
@@ -1053,10 +1051,9 @@ fhandler_disk_file::link (const char *newpath)
newpc.check (newpath, PC_SYM_NOFOLLOW);
}
else if (!pc.isdir ()
- && (len = strlen (pc.get_win32 ())) > 4
- && strcasematch (pc.get_win32 () + len - 4, ".exe")
- && (len = strlen (newpc.get_win32 ())) > 4
- && !strcasematch (newpc.get_win32 () + len - 4, ".exe"))
+ && RtlEqualPathSuffix (pc.get_nt_native_path (), L".exe", TRUE)
+ && !RtlEqualPathSuffix (newpc.get_nt_native_path (), L".exe",
+ TRUE))
{
/* Executable hack. */
stpcpy (stpcpy (new_buf, newpath), ".exe");
@@ -1091,7 +1088,10 @@ fhandler_disk_file::link (const char *newpath)
if (status == STATUS_INVALID_DEVICE_REQUEST)
{
/* FS doesn't support hard links. Try to copy file. */
- if (!CopyFileA (pc, newpc, TRUE))
+ WCHAR pcw[pc.get_nt_native_path ()->Length + 1];
+ WCHAR newpcw[newpc.get_nt_native_path ()->Length + 1];
+ if (!CopyFileW (pc.get_wide_win32_path (pcw),
+ newpc.get_wide_win32_path (newpcw), TRUE))
{
__seterrno ();
return -1;
@@ -1732,11 +1732,12 @@ fhandler_disk_file::readdir_helper (DIR *dir, dirent *de, DWORD w32_err,
UNICODE_STRING uname;
UNICODE_STRING lname;
- RtlInitCountedUnicodeString (&uname, 4 * sizeof (WCHAR),
- fname->Buffer +
- fname->Length / sizeof (WCHAR) - 4);
- RtlInitCountedUnicodeString (&lname, 4 * sizeof (WCHAR),
- (PWCHAR) L".lnk");
+ RtlInitCountedUnicodeString (&uname,
+ fname->Buffer
+ + fname->Length / sizeof (WCHAR) - 4,
+ 4 * sizeof (WCHAR));
+ RtlInitCountedUnicodeString (&lname, (PWCHAR) L".lnk",
+ 4 * sizeof (WCHAR));
if (RtlEqualUnicodeString (&uname, &lname, TRUE))
{
@@ -1872,7 +1873,7 @@ go_ahead:
}
else
FileName = ((PFILE_BOTH_DIR_INFORMATION) buf)->FileName;
- RtlInitCountedUnicodeString (&fname, buf->FileNameLength, FileName);
+ RtlInitCountedUnicodeString (&fname, FileName, buf->FileNameLength);
de->d_ino = d_mounts (dir)->check_mount (&fname, de->d_ino);
if (de->d_ino == 0 && (dir->__flags & dirent_set_d_ino))
{
diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h
index aca672533..c30aed15c 100644
--- a/winsup/cygwin/ntdll.h
+++ b/winsup/cygwin/ntdll.h
@@ -807,8 +807,8 @@ extern "C"
dest->Buffer = (PWSTR) buf;
}
inline
- VOID NTAPI RtlInitCountedUnicodeString (PUNICODE_STRING dest, USHORT len,
- PCWSTR buf)
+ VOID NTAPI RtlInitCountedUnicodeString (PUNICODE_STRING dest, PCWSTR buf,
+ USHORT len)
{
dest->Length = dest->MaximumLength = len;
dest->Buffer = (PWSTR) buf;
@@ -822,9 +822,36 @@ extern "C"
;
++len;
if (dir)
- RtlInitCountedUnicodeString (dir, len * sizeof (WCHAR), path->Buffer);
+ RtlInitCountedUnicodeString (dir, path->Buffer, len * sizeof (WCHAR));
if (file)
- RtlInitCountedUnicodeString (file, path->Length - len * sizeof (WCHAR),
- &path->Buffer[len]);
+ RtlInitCountedUnicodeString (file, &path->Buffer[len],
+ path->Length - len * sizeof (WCHAR));
+ }
+ inline
+ BOOLEAN NTAPI RtlEqualPathPrefix (PUNICODE_STRING path, PCWSTR prefix,
+ BOOLEAN caseinsensitive)
+ {
+ UNICODE_STRING p, pref;
+
+ RtlInitUnicodeString (&pref, prefix);
+ RtlInitCountedUnicodeString (&p, path->Buffer,
+ pref.Length < path->Length
+ ? pref.Length : path->Length);
+ return RtlEqualUnicodeString (&p, &pref, caseinsensitive);
+ }
+ inline
+ BOOL NTAPI RtlEqualPathSuffix (PUNICODE_STRING path, PCWSTR suffix,
+ BOOLEAN caseinsensitive)
+ {
+ UNICODE_STRING p, suf;
+
+ RtlInitUnicodeString (&suf, suffix);
+ if (suf.Length < path->Length)
+ RtlInitCountedUnicodeString (&p, (PWCHAR) ((PBYTE) path->Buffer
+ + path->Length - suf.Length),
+ suf.Length);
+ else
+ RtlInitCountedUnicodeString (&p, path->Buffer, path->Length);
+ return RtlEqualUnicodeString (&p, &suf, caseinsensitive);
}
}