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-10 12:06:02 +0400
committerCorinna Vinschen <corinna@vinschen.de>2010-09-10 12:06:02 +0400
commit28e19bafa0e3398a3e346effd4917db6ec8b5c85 (patch)
tree6c48d8483e1650d72259a2e309f3c0cb0cf44209 /winsup/cygwin/fhandler_procsys.cc
parentb88e4203a993ce37f0812ee325a0a8c09aefd644 (diff)
* fhandler_procsys.cc (fhandler_procsys::exists): Rearrange to handle
dangling symlinks correctly. Fix comments. (fhandler_procsys::fill_filebuf): Remove useless comment.
Diffstat (limited to 'winsup/cygwin/fhandler_procsys.cc')
-rw-r--r--winsup/cygwin/fhandler_procsys.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/winsup/cygwin/fhandler_procsys.cc b/winsup/cygwin/fhandler_procsys.cc
index 317e6f76f..54218156f 100644
--- a/winsup/cygwin/fhandler_procsys.cc
+++ b/winsup/cygwin/fhandler_procsys.cc
@@ -52,6 +52,7 @@ fhandler_procsys::exists (struct __stat64 *buf)
NTSTATUS status;
HANDLE h;
FILE_BASIC_INFORMATION fbi;
+ /* Default device type is character device. */
virtual_ftype_t file_type = virt_chr;
if (strlen (get_name ()) == procsys_len)
@@ -61,16 +62,17 @@ fhandler_procsys::exists (struct __stat64 *buf)
InitializeObjectAttributes (&attr, &path, OBJ_CASE_INSENSITIVE, NULL, NULL);
status = NtOpenFile (&h, READ_CONTROL | FILE_READ_ATTRIBUTES, &attr, &io,
FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT);
- if (status == STATUS_OBJECT_PATH_NOT_FOUND)
- return virt_none;
- /* If the name isn't found, or we get this dreaded sharing violation, let
- the caller try again as normal file. */
- if (status == STATUS_OBJECT_NAME_NOT_FOUND
- || status == STATUS_NO_MEDIA_IN_DEVICE
+ /* If no media is found, or we get this dreaded sharing violation, let
+ the caller immediately try again as normal file. */
+ if (status == STATUS_NO_MEDIA_IN_DEVICE
|| status == STATUS_SHARING_VIOLATION)
return virt_fsfile; /* Just try again as normal file. */
+ /* If file or path can't be found, let caller try again as normal file. */
+ if (status == STATUS_OBJECT_PATH_NOT_FOUND
+ || status == STATUS_OBJECT_NAME_NOT_FOUND)
+ file_type = virt_fsfile;
/* Check for pipe errors, which make a good hint... */
- if (status >= STATUS_PIPE_NOT_AVAILABLE && status <= STATUS_PIPE_BUSY)
+ else if (status >= STATUS_PIPE_NOT_AVAILABLE && status <= STATUS_PIPE_BUSY)
file_type = virt_pipe;
else if (status == STATUS_ACCESS_DENIED)
{
@@ -134,7 +136,7 @@ fhandler_procsys::exists (struct __stat64 *buf)
}
else if (status == STATUS_ACCESS_DENIED)
return virt_directory;
- /* Give up. Just treat as character device. */
+ /* That's it. Return type we found above. */
return file_type;
}
@@ -152,7 +154,6 @@ fhandler_procsys::fhandler_procsys ():
bool
fhandler_procsys::fill_filebuf ()
{
- /* The NT device namespace is ASCII only. */
char *fnamep;
UNICODE_STRING path, target;
OBJECT_ATTRIBUTES attr;