diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-08-12 12:31:08 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-08-12 12:31:08 +0000 |
commit | 1f08558f14e45382f5f5b137c45aae3bb79b067c (patch) | |
tree | 2770d3ea3f7fb2e3566fd85800fdb62a980b71cd | |
parent | 6e2c582323d667fec9b1859757515f932c6f8db2 (diff) | |
download | cygnal-1f08558f14e45382f5f5b137c45aae3bb79b067c.tar.gz cygnal-1f08558f14e45382f5f5b137c45aae3bb79b067c.tar.bz2 cygnal-1f08558f14e45382f5f5b137c45aae3bb79b067c.zip |
* fhandler.h (fhandler_proc::opendir): Declare.
(fhandler_proc::closedir): Declare.
* fhandler_proc.cc (fhandler_proc::opendir): New method. Fetch list
of active processes here once to avoid potential duplicates.
(fhandler_proc::closedir): New method.
-rw-r--r-- | winsup/cygwin/ChangeLog | 8 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_proc.cc | 22 |
3 files changed, 31 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8dc5248db..933769a48 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2011-08-12 Corinna Vinschen <corinna@vinschen.de> + + * fhandler.h (fhandler_proc::opendir): Declare. + (fhandler_proc::closedir): Declare. + * fhandler_proc.cc (fhandler_proc::opendir): New method. Fetch list + of active processes here once to avoid potential duplicates. + (fhandler_proc::closedir): New method. + 2011-08-11 Corinna Vinschen <corinna@vinschen.de> * fhandler_proc.cc (fhandler_proc::get_proc_fhandler): Don't allow to diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index b8c3f20bb..3cbcba91d 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -1440,6 +1440,8 @@ class fhandler_proc: public fhandler_virtual public: fhandler_proc (); virtual_ftype_t exists(); + DIR *opendir (int fd) __attribute__ ((regparm (2))); + int closedir (DIR *); int readdir (DIR *, dirent *) __attribute__ ((regparm (3))); static fh_devices get_proc_fhandler (const char *path); diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 63178a003..94007cae1 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -220,6 +220,26 @@ fhandler_proc::fstat (struct __stat64 *buf) return -1; } +DIR * +fhandler_proc::opendir (int fd) +{ + DIR *dir = fhandler_virtual::opendir (fd); + if (dir && !(dir->__handle = (void *) new winpids ((DWORD) 0))) + { + free (dir); + dir = NULL; + set_errno (ENOMEM); + } + return dir; +} + +int +fhandler_proc::closedir (DIR *dir) +{ + free (dir->__handle); + return fhandler_virtual::closedir (dir); +} + int fhandler_proc::readdir (DIR *dir, dirent *de) { @@ -232,7 +252,7 @@ fhandler_proc::readdir (DIR *dir, dirent *de) } else { - winpids pids ((DWORD) 0); + winpids &pids = *(winpids *) dir->__handle; int found = 0; res = ENMFILE; for (unsigned i = 0; i < pids.npids; i++) |