summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/path.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2007-07-26 17:30:54 +0000
committerCorinna Vinschen <corinna@vinschen.de>2007-07-26 17:30:54 +0000
commit214c3a1167c25b0696b118e347a78adf813151a9 (patch)
tree412d926fc8b2185246eac004b59b990e65a24e63 /winsup/cygwin/path.cc
parent4b62a570de173dd5adecbac8bf9ae9039d0bdef5 (diff)
downloadcygnal-214c3a1167c25b0696b118e347a78adf813151a9.tar.gz
cygnal-214c3a1167c25b0696b118e347a78adf813151a9.tar.bz2
cygnal-214c3a1167c25b0696b118e347a78adf813151a9.zip
* dir.cc (readdir_worker): Drop dir parameter from call to
readdir_get_ino. * fhandler.h (fhandler_disk_file::readdir_helper): Switch file name parameter to PUNICODE_STRING. * fhandler_disk_file.cc: Drop including ntdef.h. (class __DIR_mounts): Store mount points in UNICODE. Additionally store cygdrive prefix in unicode here. Change methods accordingly. (__DIR_mounts::eval_ino): Call new stat_worker instead of lstat64. (__DIR_mounts::~__DIR_mounts): New destructor to free UNICODE buffers. (path_conv::ndisk_links): Rewrite using native NT functions. (fhandler_base::fstat_by_handle): Use NAME_MAX instead of CYG_MAX_PATH. Always set pfvi->VolumeSerialNumber to non-0. Remove last resort code. (fhandler_base::fstat_by_name): Rewrite using native NT functions. (fhandler_base::fstat_fs): Always call fstat_by_name if fstat_by_handle fails. (fhandler_base::fstat_helper): Rely on dwVolumeSerialNumber. (fhandler_disk_file::facl): Call fstat_by_name if fstat_by_handle fails. (DIR_BUF_SIZE): Define using NAME_MAX instead of CYG_MAX_PATH. (__DIR_cache): Remove __name. (d_dirname): Remove. (fhandler_disk_file::opendir): Drop pathname length check. Remove outdated comment. Use get_name method instead of accessing pc.normalized_path directly. (readdir_get_ino): Drop unused dir parameter. Accomodate throughout. Allocate fname dynamically. Call new stat_worker instead of lstat64. Call NtOpenFile instead of CreateFile. Call NtClose instead of CloseHandle. (fhandler_disk_file::readdir_helper): Use native NT functions. Check for volume mount points and use correct inode number. (fhandler_disk_file::readdir): Simplify slightly. Use get_name instead of pc.normalized_path. (fhandler_disk_file::rewinddir): Use RtlInitUnicodeString. (fhandler_cygdrive::fstat): Ignore floppy drives. Set st_nlink correctly. (fhandler_cygdrive::readdir): Ignore floppy drives. * fhandler_netdrive.cc (fhandler_netdrive::readdir): Accommodate change to readdir_get_ino. * fhandler_proc.cc (PROC_DIR_COUNT): Define. (fhandler_proc::fstat): Evaluate correct link count for /proc. * ntdll.h (struct _FILE_DIRECTORY_INFORMATION): Define. (NtFsControlFile): Declare. (RtlAppendUnicodeToString): Declare. (RtlAppendUnicodeStringToString): Declare. (RtlCompareUnicodeString): Declare. (RtlCopyUnicodeString): Declare. (RtlCreateUnicodeStringFromAsciiz): Declare. (RtlEqualUnicodeString): Declare. (RtlFreeUnicodeString): Declare. (RtlInitEmptyUnicodeString): Declare. (RtlSecondsSince1970ToTime): Declare. (RtlInitEmptyUnicodeString): Define as inline function. (RtlInitCountedUnicodeString): Define as inline function. * path.cc (path_conv::check): New method with PUNICODE_STRING as path, preliminary implementation. (mount_info::get_mounts_here): Change to create UNICODE_STRINGs. Also copy cygpath prefix into UNICODE_STRING. (is_floppy): Drop 9x consideration. * path.h: Drop including ntdef.h. (path_conv::check): Add declaration. (path_conv::path_conv): Add constructor for UNICODE_STRING paths. * shared_info.h (mount_info::get_mounts_here): Change declaration. * syscalls.cc: Drop forward declaration of stat_worker. (stat_worke): Take path_conv as parameter. Drop nofollow flag. (stat64): Create matching path_conv and call stat_worker with it. (lstat64): Ditto. * winsup.h: Include ntdef.h. (stat_worker): Declare. (readdir_get_ino): Change declaration.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc31
1 files changed, 26 insertions, 5 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 6e345588e..062f5ab7e 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -637,6 +637,23 @@ warn_msdos (const char *src)
SYMLINK_CONTENTS - just return symlink contents
*/
+/* TODO: This implementation is only preliminary. For internal
+ purposes it's necessary to have a path_conv::check function which
+ takes a UNICODE_STRING src path, otherwise we waste a lot of time
+ for converting back and forth. The below implementation does
+ realy nothing but converting to char *, until path_conv handles
+ wide-char paths directly. */
+void
+path_conv::check (PUNICODE_STRING src, unsigned opt,
+ const suffix_info *suffixes)
+{
+ char path[CYG_MAX_PATH];
+
+ user_shared->warned_msdos = true;
+ sys_wcstombs (path, CYG_MAX_PATH, src->Buffer, src->Length / 2);
+ path_conv::check (path, opt, suffixes);
+}
+
void
path_conv::check (const char *src, unsigned opt,
const suffix_info *suffixes)
@@ -1840,7 +1857,8 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev,
int
mount_info::get_mounts_here (const char *parent_dir, int parent_dir_len,
- char **mount_points)
+ PUNICODE_STRING mount_points,
+ PUNICODE_STRING cygd)
{
int n_mounts = 0;
@@ -1853,12 +1871,16 @@ mount_info::get_mounts_here (const char *parent_dir, int parent_dir_len,
if (last_slash == mi->posix_path)
{
if (parent_dir_len == 1 && mi->posix_pathlen > 1)
- mount_points[n_mounts++] = last_slash + 1;
+ RtlCreateUnicodeStringFromAsciiz (&mount_points[n_mounts++],
+ last_slash + 1);
}
else if (parent_dir_len == last_slash - mi->posix_path
&& strncasematch (parent_dir, mi->posix_path, parent_dir_len))
- mount_points[n_mounts++] = last_slash + 1;
+ RtlCreateUnicodeStringFromAsciiz (&mount_points[n_mounts++],
+ last_slash + 1);
}
+ RtlCreateUnicodeStringFromAsciiz (cygd, cygdrive + 1);
+ cygd->Length -= 2; // Strip trailing slash
return n_mounts;
}
@@ -2794,8 +2816,7 @@ is_floppy (const char *dos)
char dev[256];
if (!QueryDosDevice (dos, dev, 256))
return false;
- return strncasematch (dev, "\\Device\\Floppy", 14)
- || strcasematch (dev, "A:");
+ return strncasematch (dev, "\\Device\\Floppy", 14);
}
extern "C" FILE *