summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_dev.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/fhandler_dev.cc')
-rw-r--r--winsup/cygwin/fhandler_dev.cc96
1 files changed, 13 insertions, 83 deletions
diff --git a/winsup/cygwin/fhandler_dev.cc b/winsup/cygwin/fhandler_dev.cc
index 713e8c0fb..82bd2fa82 100644
--- a/winsup/cygwin/fhandler_dev.cc
+++ b/winsup/cygwin/fhandler_dev.cc
@@ -12,8 +12,6 @@ details. */
#include <stdlib.h>
#include "path.h"
#include "fhandler.h"
-#include "shared_info.h"
-#include "ntdll.h"
#include "dtable.h"
#include "cygheap.h"
#include "devices.h"
@@ -121,79 +119,8 @@ fhandler_dev::readdir (DIR *dir, dirent *de)
while (devidx < dev_storage_end)
{
const device& thisdev = *devidx++;
- if (!thisdev.expose ())
+ if (!thisdev.exists ())
continue;
- int devn = *const_cast<device *> (&thisdev);
- /* Exclude devices which are only available for internal purposes
- and devices which are not really existing at this time. */
- switch (thisdev.get_major ())
- {
- case DEV_PTYS_MAJOR:
- /* Show only existing slave ptys. */
- if (cygwin_shared->tty.connect (thisdev.get_minor ()) == -1)
- continue;
- break;
- case DEV_CONS_MAJOR:
- /* Show only the one console which is our controlling tty
- right now. */
- if (!iscons_dev (myself->ctty)
- || myself->ctty != devn)
- continue;
- break;
- case DEV_TTY_MAJOR:
- /* Show con{in,out,sole} only if we're running in a console. */
- switch (devn)
- {
- case FH_CONIN:
- case FH_CONOUT:
- case FH_CONSOLE:
- if (!iscons_dev (myself->ctty))
- continue;
- }
- break;
- case DEV_SERIAL_MAJOR:
- case DEV_FLOPPY_MAJOR:
- case DEV_TAPE_MAJOR:
- case DEV_CDROM_MAJOR:
- case DEV_SD_MAJOR:
- case DEV_SD1_MAJOR:
- case DEV_SD2_MAJOR:
- case DEV_SD3_MAJOR:
- case DEV_SD4_MAJOR:
- case DEV_SD5_MAJOR:
- case DEV_SD6_MAJOR:
- case DEV_SD7_MAJOR:
- /* Check existence of POSIX devices backed by real NT devices. */
- {
- WCHAR wpath[MAX_PATH];
- UNICODE_STRING upath;
- OBJECT_ATTRIBUTES attr;
- HANDLE h;
- NTSTATUS status;
-
- sys_mbstowcs (wpath, MAX_PATH, thisdev.native);
- RtlInitUnicodeString (&upath, wpath);
- InitializeObjectAttributes (&attr, &upath,
- OBJ_CASE_INSENSITIVE, NULL, NULL);
- /* Except for the serial IO devices, the native paths are
- direct device paths, not symlinks, so every status code
- except for "NOT_FOUND" means the device exists. */
- status = NtOpenSymbolicLinkObject (&h, SYMBOLIC_LINK_QUERY,
- &attr);
- switch (status)
- {
- case STATUS_OBJECT_NAME_NOT_FOUND:
- case STATUS_OBJECT_PATH_NOT_FOUND:
- continue;
- case STATUS_SUCCESS:
- NtClose (h);
- break;
- default:
- break;
- }
- }
- break;
- }
++dir->__d_position;
strcpy (de->d_name, thisdev.name + dev_prefix_len);
de->d_ino = hash_path_name (0, thisdev.native);
@@ -213,15 +140,18 @@ fhandler_dev::readdir (DIR *dir, dirent *de)
de->d_type = DT_BLK;
break;
case DEV_TTY_MAJOR:
- switch (devn)
- {
- case FH_CONIN:
- case FH_CONOUT:
- case FH_CONSOLE:
- dev.parse (myself->ctty);
- de->d_ino = hash_path_name (0, dev.native);
- break;
- }
+ {
+ int devn = *const_cast<device *> (&thisdev);
+ switch (devn)
+ {
+ case FH_CONIN:
+ case FH_CONOUT:
+ case FH_CONSOLE:
+ dev.parse (myself->ctty);
+ de->d_ino = hash_path_name (0, dev.native);
+ break;
+ }
+ }
/*FALLTHRU*/
default:
de->d_type = DT_CHR;