Commit Graph

8 Commits

Author SHA1 Message Date
Sebastian Huber 103b055035 Add generic implementation of fdopendir()
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11 08:29:17 +02:00
Sebastian Huber 61fc64ed97 Open a directory with the usual flags
Use O_RDONLY since you are not supposed to write to a directory.

Use O_DIRECTORY as mandated by POSIX (The Open Group Base Specifications
Issue 7, 2018 edition IEEE Std 1003.1-2017):

"If the type DIR is implemented using a file descriptor, the descriptor
shall be obtained as if the O_DIRECTORY flag was passed to open()."

Use O_CLOEXEC as mandated by POSIX:

"When a file descriptor is used to implement the directory stream, it
behaves as if the FD_CLOEXEC had been set for the file descriptor."

Drop the fcntl() call in favour of O_CLOEXEC.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11 08:29:16 +02:00
Yaakov Selkowitz 9087163804 ansification: remove _DEFUN
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:26 -06:00
Corinna Vinschen 04c82a9ba0 * libc/posix/opendir.c (opendir): Fix potential memory leak. 2010-08-25 10:44:47 +00:00
Jeff Johnston 729d1ff9d8 2003-06-06 Jeff Johnston <jjohnstn@redhat.com>
* libc/argz/argz_add.c: Change to use _DEFUN macro for function
        definition.
        * libc/argz/argz_add_sep.c: Ditto.
        * libc/argz/argz_append.c libc/argz/argz_count.c: Ditto.
        * libc/argz/argz_create.c libc/argz/argz_create_sep.c: Ditto.
        * libc/argz/argz_delete.c libc/argz/argz_extract.c: Ditto.
        * libc/argz/argz_insert.c libc/argz/argz_next.c: Ditto.
        * libc/argz/argz_replace.c libc/argz/argz_stringify.c: Ditto.
        * libc/argz/envz_add.c libc/argz/envz_entry.c: Ditto.
        * libc/argz/envz_get.c libc/argz/envz_merge.c: Ditto.
        * libc/argz/envz_remove.c libc/argz/envz_strip.c: Ditto.
        * libc/locale/nl_langinfo.c libc/misc/ffs.c: Ditto.
        * libc/posix/closedir.c libc/posix/creat.c: Ditto.
        * libc/posix/execl.c libc/posix/execle.c: Ditto.
        * libc/posix/execlp.c libc/posix/execve.c: Ditto.
        * libc/posix/isatty.c libc/posix/opendir.c: Ditto.
        * libc/posix/popen.c libc/posix/readdir.c: Ditto.
        * libc/posix/readdir_r.c libc/posix/rewinddir.c: Ditto.
        * libc/posix/scandir.c libc/posix/seekdir.c: Ditto.
        * libc/posix/telldir.c libc/search/hcreate.c: Ditto.
        * libc/search/tdelete.c libc/search/tdestroy.c: Ditto.
        * libc/search/tfind.c libc/search/tsearch.c: Ditto.
        * libc/search/twalk.c libc/signal/signal.c: Ditto.
2003-06-06 19:57:51 +00:00
Jeff Johnston 50558bf3bd 2002-09-19 Jeff Johnston <jjohnstn@redhat.com>
* libc/posix/opendir.c (opendir): Change code to check
        for HAVE_FCNTL before calling fcntl.
        * libc/search/hash.c (hash_open): Ditto.
        * libc/search/hash_page.c (open_tmp): Ditto.
        * libc/reent/Makefile.am: Add fcntlr.c.
        * libc/reent/Makefile.in: Regenerated.
        * libc/reent/fcntlr.c: New file.
        * libc/stdio/fdopen.c (_fdopen_r): Change to call _fcntl_r
        instead of _fcntl when HAVE_FCNTL flag is set.
        * libc/syscalls/sysfcntl.c (fcntl): Check for HAVE_FCNTL flag
        to see if _fcntl or _fcntl_r should be called.  If flag is not
        set, default to ENOSYS stub.
2002-09-19 21:28:52 +00:00
Jeff Johnston 39e65e0113 2002-06-05 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/string.h[__linux__]: Add strsignal prototype.
        * libc/include/sys/lock.h: New file with default locking support.
        * libc/include/sys/reent.h: Add signal buffer support for strsignal
        and psignal.
        * libc/posix/Makefile.am: Add support for readdir_r.c.
        * libc/posix/Makefile.in: Regenerated.
        * libc/posix/closedir.c: Add locking support and hash table cleanup.
        * libc/posix/opendir.c: Add lock support.
        * libc/posix/readdir.c: Ditto.
        * libc/posix/rewinddir.c: Ditto.
        * libc/posix/scandir.c: Ditto.
        * libc/posix/seekdir.c: Ditto.
        * libc/posix/telldir.c: Ditto plus add _cleanupdir routine to
        clean up leftover hash table entries.
        * libc/posix/readdir_r.c: New file.
        * libc/sys/linux/Makefile.am: Add psignal.c and strsignal.c support.
        * libc/sys/linux/Makefile.in: Regenerated.
        * libc/sys/linux/sys/dirent.h: Add dd_lock to DIR structure.
        * libc/sys/linux/sys/signal.h: Add psignal prototype.
        * libc/sys/linux/psignal.c: New file.
        * libc/sys/linux/strsignal.c: Ditto.
2002-06-05 20:58:59 +00:00
Christopher Faylor 8a0efa53e4 import newlib-2000-02-17 snapshot 2000-02-17 19:39:52 +00:00