diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_procsys.cc | 19 |
2 files changed, 16 insertions, 9 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 65c0f037f..1b5da688d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2010-09-10 Corinna Vinschen <corinna@vinschen.de> + + * fhandler_procsys.cc (fhandler_procsys::exists): Rearrange to handle + dangling symlinks correctly. Fix comments. + (fhandler_procsys::fill_filebuf): Remove useless comment. + 2010-09-08 Corinna Vinschen <corinna@vinschen.de> * fhandler_procsys.cc (fhandler_procsys::open): Simplify by just 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; |