1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-04 23:35:36 -08:00
Commit Graph

35 Commits

Author SHA1 Message Date
florian
b5a3756551 Add scandirat(3); from freebsd
To be used in httpd(8) shortly to prevent toctu issues.

This makes __fdopendir internally accessible to avoid unnecessary
syscalls in scandirat(3). Suggested & diff by guenther

suggested by & OK millert
tweak & OK guenther
OK tb, jca

This rides the libc crank.
2024-04-15 15:47:58 +00:00
millert
6ecde746de Move the 10 (!) defintions of NULL to their own mini header file and
update the NULL definition for C++11.  OK deraadt@ guenther@ kettenis@
2016-09-09 18:12:37 +00:00
zhuk
d33565a9ed Zap some getdirentries() leftovers.
okay guenther@
2013-12-13 18:09:27 +00:00
guenther
e3635453c2 Tweak the getdents() kernel prototype to use "void *"
Provide a declaration for userspace
Fix the kernel's sanity check on the buflen argument

lack of prototype pointed out by sthen@ and landry@
ok kettenis@ otto@
2013-08-16 08:33:20 +00:00
guenther
cc0a63afba XPG 4 apparently exposed d_ino and ino_t. Also, always pull in
<sys/_types.h> for the internal types

ok matthew@
2013-06-02 16:14:59 +00:00
deraadt
d7fe39fbb4 I can see no reason for #ifndef _KERNEL check in a /usr/include
(ie. non-kernel) .h file
2013-03-24 17:46:58 +00:00
guenther
a737da7824 Change scandir()'s 'select' argument from
int (*)(struct dirent *)
to
	int (*)(const struct dirent *)
to match POSIX.

ok millert@, ports check by naddy@
2012-11-29 02:15:44 +00:00
guenther
d4dd0b48f8 Provide the old prototypes for scandir() and alphasort() for code that
requests the pre-standardized version

requested by millert@
2012-03-24 01:53:51 +00:00
matthew
e55576ca58 Make DIR a private type within libc, give it the same underlying
typedef regardless of __BSD_VISIBLE, and eliminate the dirfd() macro.

ok guenther@
2012-03-22 04:11:53 +00:00
guenther
9142ec076e Update alphasort() and scandir()'s argument types to match POSIX:
use "const struct dirent **" instead of "const void *".  Also, add
__restrict to readdir_r().

ok matthew@
2012-03-22 01:44:19 +00:00
matthew
94e5217d08 Add dirfd() as a function to libc per POSIX requirement; dirfd() macro
to be pruned later when DIR is made an opaque type.

ok guenther@; prodding by brad@ for VLC and other ports
2012-03-22 01:13:40 +00:00
matthew
f02fac78d1 Expose a bunch of new functionality from POSIX 2008: openat(2),
fchmodat(2), fstatat(2), mkdirat(2), mkfifoat(2), mknodat(2),
faccessat(2), fchownat(2), linkat(2), readlinkat(2), renameat(2),
symlinkat(2), unlinkat(2), utimensat(2), futimens(2), and
fdopendir(3).

"Minor" libc bump.

Tested in a bulk build by naddy@
Much help from guenther@, thib@, tedu@, oga@, and others.
ok deraadt@, naddy@
2011-07-18 17:29:49 +00:00
deraadt
8cf2685156 __opendir2, DTF_NODUP, and __DTF_READALL can die. struct dirent
dd_flags is renamed to the placeholder position dd_unused so that
we can spot "broken software" which assumes we have Jan Simon Pendry's
union mounts (we don't have them, and won't have them ever again).
__opendir2 question spotted by matthew
verified to not break ports by sthen
2011-07-14 02:16:00 +00:00
jsg
c4ff7bee63 As pointed out by Richard Guenther our definition
of NULL was incorrect for c++ compilers that aren't
gcc (or pretend to be gcc like clang).

ok miod@
2011-07-03 18:51:01 +00:00
miod
0c2a5da7f0 Define NULL as a void * instead of a long integer, as required by Single Unix.
Kernel and bootblocks still use the old 0L value until all the NULL abuses
in the code are fixed.
2011-04-06 11:39:42 +00:00
guenther
3e110e7bec Standards compliance: expose dirfd with XPG7 and scandir and alphasort
with POSIX 2008

ok millert@
2010-12-31 19:54:05 +00:00
millert
3f3251d07e Change basep parameter of getdirentries() to be off_t *, not long *
so it works correctly with large offsets (and matches other systems).
This requires adding a new getdirentries syscall, with the old one
renamed to ogetdirentries.  All in-tree consumers of getdirentries()
have been updated.  Bump libc and libpthread major numbers.
OK and with deraadt@
2010-10-28 15:02:41 +00:00
kurt
45e14c3813 _FD_LOCK/UNLOCK() is libpthread specific and not needed for librthread, so
isolate its usage to libpthread only and replace with generic non-static
mutex support in the one place it is needed:
 - remove _FD_LOCK/UNLOCK from lseek and ftruncate in libc and make the
   functions weak so that libpthread can override with its own new
   versions that do the locking.
 - remove _thread_fd_lock/unlock() weak functions from libc and adjust
   libpthread for the change.
 - add generic _thread_mutex_lock/unlock/destroy() weak functions in libc
   to support non-static mutexes in libc and add libpthread and librthread
   implementations for them. libc can utilize non-static mutexes via the
   new _MUTEX_LOCK/UNLOCK/DESTROY() macros. Actually these new macros can
   support both static and non-static mutexes but currently only using
   them for non-static.
 - make opendir/closedir/readdir/readdir_r/seekdir/telldir() thread-safe
   for both thread libraries by using a non-static mutex in the struct
   _dirdesc (typedef DIR), utilizing it in the *dir functions and remove
   remaining and incorrect _FD_LOCK/UNLOCK() use in libc.
 - add comments to both thread libraries to indicate libc depends on the
   current implementation of static mutex initialization. suggested by
   marc@
 - major bump libc and libpthread due to function removal, structure
   change and weak symbol conversions.
okay marc@, tedu@
2007-06-05 18:11:48 +00:00
millert
9dad84be6d g/c __DTF_READALL. It was a flag to the internal __opendir2() but
is never set now that the unionfs support has been removed from
readdir().  OK pedro@
2007-02-08 16:34:38 +00:00
otto
3e18185e19 - Plug huge mem leak; mostly samba was suffering.
- Fix semantics: seekdir(pos); telldir() shoud return pos. The code
that implements this will be made faster in a later commit.
- We loose documented behaviour (after closedir() the telldir()
positions are not valid anymore). This was never in Posix, and most
other systems have nothing like it.

Diff originally from Paul Thorn, rewritten by me using some FreeBSD
code.  "slap it in" deraadt@
2006-04-01 18:06:59 +00:00
millert
52a0e6034e First step in include files overhaul. Use __FOO_VISIBLE (as defined
in sys/cdefs.h) instead of _FOO_SOURCE.  Also fix several namespace
pollution issues, including the byte order defines.  OK deraadt@
2005-12-13 00:35:22 +00:00
millert
8ec6394d04 Remove remaining whiteout tentacles; OK deraadt@ miod@ weingart@ 2005-06-18 18:09:42 +00:00
avsm
89b95c1c6c add __bounded__ attributes for userland headers; enabled with -Wbounded
ok deraadt@
2003-08-01 17:38:33 +00:00
avsm
3e87668a71 backout the __bounded__ attributes for a while; requested by deraadt@ 2003-06-26 19:34:17 +00:00
avsm
585be00bb5 Mark various standard library functions with the __bounded__ attribute.
You must have an up-to-date gcc for this!
deraadt@ ok
2003-06-26 18:35:13 +00:00
millert
e33d3bd3b8 Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999.  Proofed by myself and Theo.
2003-06-02 19:34:12 +00:00
millert
8248c2b451 NULL is now 0L so it is the same size as a pointer.
OK mickey@ and discussed with deraadt@
2002-10-25 21:55:28 +00:00
millert
f3c3a9c6df Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree) 2002-02-17 19:42:18 +00:00
millert
c72b5b24e1 Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically. 2002-02-16 21:27:05 +00:00
espie
ad7ac144d1 Be thorough about NULL as __null for C++. 1999-09-17 13:13:46 +00:00
espie
6689767d41 Define NULL to be __null for C++: better quality of implementation.
__null is a magic constant of integral type that converts to a null pointer
as should be, but warns for ambiguity when used to resolved an overload
between an integral type and a pointer type.
1999-06-11 22:47:47 +00:00
d
92efb73507 Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
  (more md stuff is needed for other libc/arch/*)
  (setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO
1998-11-20 11:18:22 +00:00
niklas
5ea2d675e0 Well, as we are heading for a release people are encouraged to rebuild their
entire trees for testing anyway, I might as well do this intrusive touching
of include files now.  Added openBSD tags.
1997-09-21 10:45:23 +00:00
deraadt
3ab9281929 include sys/types.h as mandated by X/Open XPG 4.2; from agc@sde.uts.amdahl.com; netbsd pr#1785 1995-11-23 17:12:11 +00:00
deraadt
df930be708 initial import of NetBSD tree 1995-10-18 08:37:01 +00:00