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>2010-09-06 13:47:01 +0400
committerCorinna Vinschen <corinna@vinschen.de>2010-09-06 13:47:01 +0400
commit43f65cdd7dae0bbeb5b5f26b008c8645d524869d (patch)
treeccc368e556e96032ec5ee254bf881842a08842c9 /winsup/cygwin/fhandler_registry.cc
parent0de488378f3bb2b881436a9e0781b66a0eda815f (diff)
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o.
* devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
Diffstat (limited to 'winsup/cygwin/fhandler_registry.cc')
-rw-r--r--winsup/cygwin/fhandler_registry.cc44
1 files changed, 23 insertions, 21 deletions
diff --git a/winsup/cygwin/fhandler_registry.cc b/winsup/cygwin/fhandler_registry.cc
index 478b9cca4..b9c9a8ea5 100644
--- a/winsup/cygwin/fhandler_registry.cc
+++ b/winsup/cygwin/fhandler_registry.cc
@@ -268,10 +268,11 @@ multi_wcstombs (char *dst, size_t len, const wchar_t *src, size_t nwc)
* final component is there. This gets round the problem of not having security access
* to the final key in the path.
*/
-int
+virtual_ftype_t
fhandler_registry::exists ()
{
- int file_type = 0, index = 0, pathlen;
+ virtual_ftype_t file_type = virt_none;
+ int index = 0, pathlen;
DWORD buf_size = NAME_MAX + 1;
LONG error;
wchar_t buf[buf_size];
@@ -285,7 +286,7 @@ fhandler_registry::exists ()
path++;
else
{
- file_type = 2;
+ file_type = virt_rootdir;
goto out;
}
pathlen = strlen (path);
@@ -302,7 +303,7 @@ fhandler_registry::exists ()
if (path_prefix_p (registry_listing[i], path,
strlen (registry_listing[i]), true))
{
- file_type = 1;
+ file_type = virt_directory;
break;
}
}
@@ -317,12 +318,12 @@ fhandler_registry::exists ()
if (!val_only)
hKey = open_key (path, KEY_READ, wow64, false);
if (hKey != (HKEY) INVALID_HANDLE_VALUE || get_errno () == EACCES)
- file_type = 1;
+ file_type = virt_directory;
else
{
hKey = open_key (path, KEY_READ, wow64, true);
if (hKey == (HKEY) INVALID_HANDLE_VALUE)
- return 0;
+ return virt_none;
if (hKey == HKEY_PERFORMANCE_DATA)
{
@@ -332,13 +333,14 @@ fhandler_registry::exists ()
So allow access to the generic names and to
(blank separated) lists of counter numbers.
Never allow access to "Add", see above comment. */
- for (int i = 0; i < PERF_DATA_FILE_COUNT && file_type == 0; i++)
+ for (int i = 0; i < PERF_DATA_FILE_COUNT
+ && file_type == virt_none; i++)
{
if (strcasematch (perf_data_files[i], file))
- file_type = -1;
+ file_type = virt_file;
}
- if (file_type == 0 && !file[strspn (file, " 0123456789")])
- file_type = -1;
+ if (file_type == virt_none && !file[strspn (file, " 0123456789")])
+ file_type = virt_file;
goto out;
}
@@ -351,7 +353,7 @@ fhandler_registry::exists ()
{
if (!wcscasecmp (buf, dec_file))
{
- file_type = 1;
+ file_type = virt_directory;
goto out;
}
buf_size = NAME_MAX + 1;
@@ -372,7 +374,7 @@ fhandler_registry::exists ()
{
if (!wcscasecmp (buf, dec_file))
{
- file_type = -1;
+ file_type = virt_file;
goto out;
}
buf_size = NAME_MAX + 1;
@@ -418,32 +420,32 @@ fhandler_registry::fstat (struct __stat64 *buf)
{
fhandler_base::fstat (buf);
buf->st_mode &= ~_IFMT & NO_W;
- int file_type = exists ();
+ virtual_ftype_t file_type = exists ();
switch (file_type)
{
- case 0:
+ case virt_none:
set_errno (ENOENT);
return -1;
- case 1:
+ case virt_directory:
buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
break;
- case 2:
+ case virt_rootdir:
buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
buf->st_nlink = ROOT_KEY_COUNT;
break;
default:
- case -1:
+ case virt_file:
buf->st_mode |= S_IFREG;
buf->st_mode &= NO_X;
break;
}
- if (file_type != 0 && file_type != 2)
+ if (file_type != virt_none && file_type != virt_rootdir)
{
HKEY hKey;
const char *path = get_name () + proc_len + prefix_len + 2;
hKey =
open_key (path, STANDARD_RIGHTS_READ | KEY_QUERY_VALUE, wow64,
- (file_type < 0) ? true : false);
+ (file_type < virt_none) ? true : false);
if (hKey == HKEY_PERFORMANCE_DATA)
/* RegQueryInfoKey () always returns write time 0,
@@ -461,7 +463,7 @@ fhandler_registry::fstat (struct __stat64 *buf)
to_timestruc_t (&ftLastWriteTime, &buf->st_mtim);
buf->st_ctim = buf->st_birthtim = buf->st_mtim;
time_as_timestruc_t (&buf->st_atim);
- if (file_type > 0)
+ if (file_type > virt_none)
buf->st_nlink = subkey_count + 2;
else
{
@@ -508,7 +510,7 @@ fhandler_registry::fstat (struct __stat64 *buf)
buf->st_uid = uid;
buf->st_gid = gid;
buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
- if (file_type > 0)
+ if (file_type > virt_none)
buf->st_mode |= S_IFDIR;
else
buf->st_mode &= NO_X;