Commit Graph

154 Commits

Author SHA1 Message Date
Mark Johnston
68ca8363c7 libc: Use secure_getenv(3) where appropriate
No functional change intended.

Reviewed by:	mjg, imp, kib
Differential Revision:	https://reviews.freebsd.org/D39278
2023-03-27 08:56:22 -04:00
Gordon Bergling
4b7f35db44 libc: Add HISTORY sections to the manual pages
There are some sections which could be improved
and work to do so is on going. The work will be
covered via 'X-MFC-WITH' commits.

Obtained from:	OpenBSD
MFC after:	1 month
Differential Revision: https://reviews.freebsd.org/D34759
2022-05-05 18:46:32 +02:00
Alex Richardson
5f6c8ce245 tools/build: Don't redefine open() for the linux bootstrap
This is needed to bootstrap llvm-tblgen on Linux since LLVM calls
`::open(...)` which does not work if open is a statement macro.
Also stop defining O_SHLOCK/O_EXLOCK and update the only bootstrap tools
user of those flags to deal with missing definitions.

Reviewed By:	jrtc27
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D31226
2021-08-02 14:33:23 +01:00
John Baldwin
371f3da616 Remove the SYMVER build option.
This option was added as a transition aide when symbol versioning was
first added.  It was enabled by default in 2007 and is supported even
by the old GPLv2 binutils.  Trying to disable it currently fails to
build in libc and at this point it isn't worth fixing the build.

Reported by:	Michael Dexter
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D24637
2020-04-30 22:08:40 +00:00
Xin LI
b6f7731dba Remove "All rights reserved" from my files.
See r333391 for the rationale.

MFC after:	1 week
2018-05-10 06:41:08 +00:00
Pedro F. Giffuni
d915a14ef0 libc: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-25 17:12:48 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Pedro F. Giffuni
70e7268bd5 hash(3): protect in-memory page when using cross-endianness.
When writing out pages in the "other endian" format, make a copy
instead of trashing the in-memory one.

Obtained from:	NetBSD (CVS rev. 1.29)
2016-09-26 16:06:50 +00:00
Pedro F. Giffuni
d191be26c0 btree(3): don't shortcut closing if the metadata is dirty.
Obtained from:	NetBSD (from krb5 tree)

MFC after:	3 weeks
2016-09-26 02:29:28 +00:00
Ed Schouten
de1d269583 Fix prototype of dbm_open().
The last argument of dbm_open() should be a mode_t according to POSIX;
not an int.

Reviewed by:	pfg, kib
Differential Revision:	https://reviews.freebsd.org/D6650
2016-05-31 18:32:57 +00:00
Ed Schouten
2fed5061db Let dbm's datum::dptr use the right type.
According to POSIX, it should use void *, not char *. Unfortunately, the
dsize field also has the wrong type. It should be size_t. I'm not going
to change that, as that will break the ABI.

Reviewed by:	pfg
Differential Revision:	https://reviews.freebsd.org/D6647
2016-05-30 16:52:23 +00:00
Pedro F. Giffuni
968c0b406d libc: make more use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.
2016-04-26 01:17:05 +00:00
Pedro F. Giffuni
75a5de5a40 libc: use our roundup2/rounddown2() macros when param.h is available.
rounddown2 tends to produce longer lines than the original code but
still it makes the code more readable.
2016-04-20 01:21:39 +00:00
Andriy Voskoboinyk
2cf5e9365d libc: do not include <sys/types.h> where <sys/param.h> was already included
According to style(9):
> normally, include <sys/types.h> OR <sys/param.h>, but not both.
(<sys/param.h> already includes <sys/types.h> when LOCORE is not defined).
2016-04-18 21:05:15 +00:00
Pedro F. Giffuni
513004a23d libc: replace 0 with NULL for pointers.
While here also cleanup some surrounding code; particularly
drop some malloc() casts.

Found with devel/coccinelle.

Reviewed by:	bde (previous version - all new bugs are mine)
2016-04-10 19:33:58 +00:00
Bryan Drewery
15719ec499 Follow-up r295924: Only sync hash-based db files open for writing when closing.
This fixes a major performance regression when reading db files such as
the pw database during a 'pkg install'.

MFC after:	1 week
Tested by:	bapt
Reviewed by:	bapt
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D5868
2016-04-06 22:38:50 +00:00
Ed Maste
c38dac681d libc: don't build compat functions if building WITHOUT_SYMVER
WITHOUT_SYMVER necessarily implies building a system without symver
backwards compatability.

Sponsored by:	The FreeBSD Foundation
2016-03-15 19:26:32 +00:00
Kurt Lidl
06feb971e7 Allow O_CLOEXEC to be used in dbopen() flags
There is also a small portability crutch, also present in NetBSD,
to allow compiling on a system that doesn't define O_CLOEXEC.

Approved by:	rpaulo (mentor)
Obtained from:	NetBSD (r1.17, r1.18)
Differential Revision:	https://reviews.freebsd.org/D5549
2016-03-06 04:38:08 +00:00
Pedro F. Giffuni
e1ea782729 db(3): Fix aliasing warnings from modern GCC.
While here also drop a malloc cast.

Obtained from:	NetBSD (CVS Rev. 1.18 - 1.20)
2016-02-24 17:14:11 +00:00
Pedro F. Giffuni
3579f3d9ea db(3): Fix aliasing warnings from modern GCC.
Obtained from:	NetBSD (CVS Rev. 1.20)
2016-02-24 16:52:03 +00:00
David Malone
efb7dae251 If we close or sync a hash-based db file, make sure to call fsync to
make sure the changes are on disk. The people at pfSense noticed that
it didn't always make it to the disk soon enough with soft updates.

Differential Revision:	https://reviews.freebsd.org/D5186
Reviewed by:	garga, vangyzen, bapt, se
MFC after:	1 week
2016-02-23 15:21:13 +00:00
Brooks Davis
45308eec4a Use intptr_t note ptrdiff_t when storing flags in the bottom bits of
pointers.

Obtained from:	CheriBSD (e3a69027cc)
Sponsored by:	DARPA, AFRL
2016-01-29 01:22:12 +00:00
Craig Rodrigues
d9556fb15d Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. 2015-09-20 20:55:00 +00:00
Jilles Tjoelker
636b8d937e db/recno: Open with close-on-exec like btree and hash do. 2015-09-13 17:17:52 +00:00
Konstantin Belousov
bd6060a1c6 Switch libc from using _sig{procmask,action,suspend} symbols, which
are aliases for the syscall stubs and are plt-interposed, to the
libc-private aliases of internally interposed sigprocmask() etc.

Since e.g. _sigaction is not interposed by libthr, calling signal()
removes thr_sighandler() from the handler slot etc.  The result was
breaking signal semantic and rtld locking.

The added __libc_sigprocmask and other symbols are hidden, they are
not exported and cannot be called through PLT.  The setjmp/longjmp
functions for x86 were changed to use direct calls, and since
PIC_PROLOGUE only needed for functional PLT indirection on i386, it is
removed as well.

The PowerPC bug of calling the syscall directly in the setjmp/longjmp
implementation is kept as is.

Reported by:	Pete French <petefrench@ingresso.co.uk>
Tested by:	Michiel Boland <boland37@xs4all.nl>
Reviewed by:	jilles (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2015-08-29 14:25:01 +00:00
Pedro F. Giffuni
1b81d86525 Drop some unnecessary casts.
Reported by:	Clang static analyzer
Obtained from:	NetBSD
2015-05-18 16:28:13 +00:00
Pedro F. Giffuni
a9a4a706eb dbm_delete(3) correct man page to match current behaviour.
"The dbm_store() and dbm_delete() functions shall return 0 when they
succeed and a negative value when they fail."

Reference:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/dbm_clearerr.html

PR:		42422
Suggested by:	delphij
MFC after:	3 days
2015-02-20 01:31:10 +00:00
Jeremie Le Hen
dd3d4ecb61 Let __bt_put() accept the R_SETCURSOR flag, as stated in the dbopen(3) manpage.
While here, update the comment above with all the accepted flags.

Reviewed by:	silence on hackers@
MFC after:	2 weeks
2014-03-06 07:44:45 +00:00
Marcel Moolenaar
8876613dc5 Replace use of ${.CURDIR} by ${LIBC_SRCTOP} and define ${LIBC_SRCTOP}
if not already defined. This allows building libc from outside of
lib/libc using a reach-over makefile.

A typical use-case is to build a standard ILP32 version and a COMPAT32
version in a single iteration by building the COMPAT32 version using a
reach-over makefile.

Obtained from:	Juniper Networks, Inc.
2014-03-04 02:19:39 +00:00
Jilles Tjoelker
89521d4108 db: Use O_CLOEXEC instead of separate fcntl() call. 2013-08-13 19:20:50 +00:00
Jilles Tjoelker
46d71747f6 db/hash: Use O_CLOEXEC instead of separate fcntl() call.
In particular, a hash db is used by getpwnam() and getpwuid().

MFC after:	1 week
2013-08-11 15:38:48 +00:00
Ed Schouten
6b99842ada Globally replace u_int*_t from (non-contributed) man pages.
The reasoning behind this, is that if we are consistent in our
documentation about the uint*_t stuff, people will be less tempted to
write new code that uses the non-standard types.

I am not going to bump the man page dates, as these changes can be
considered style nits. The meaning of the man pages is unaffected.

MFC after:	1 month
2012-02-12 18:29:56 +00:00
Ben Laurie
5f301949ef Fix clang warnings.
Approved by:	philip (mentor)
2011-06-18 13:56:33 +00:00
Xin LI
25879947d6 The flags argument of mpool_get() is meaningful, document it.
MFC after:	2 weeks
2011-06-18 00:10:21 +00:00
Glen Barber
416d1e6f23 Bump dates in dbopen(3) and cpuset_getaffinity(2) from r212441 and
r212438, repectively.

Approved by:	keramida (mentor)
MFC after:	1 week
2010-09-12 14:04:05 +00:00
Glen Barber
1569ab8c49 Note O_SYNC and O_NOFOLLOW flags in dbopen(3) since r190497.
PR:		150030
Submitted by:	Janne Snabb snabb at epipe com
Patch by:	Janne Snabb
Approved by:	keramida (mentor)
MFC after:	1 week
2010-09-10 23:24:55 +00:00
Andriy Gapon
f3c733e82b libc/db/hash: cap auto-tuned block size with a value that actually works
This fix mostly matters after r206129 that made it possible for
st_blksize to be greater than 4K.  For this reason, this change should
be MFC-ed before r206129.
Also, it seems that all FreeBSD uitlities that use db(3) hash databases
and create new databases in files, specify their own block size value
and thus do not depend on block size autotuning.

PR:		bin/144446
Submitted by:	Peter Jeremy <peterjeremy@acm.org>
MFC after:	5 days
2010-04-05 10:12:21 +00:00
Andriy Gapon
983419fe1e hash.3: fix a factual mistake in the man page
PR:		bin/144446
Submitted by:	Peter Jeremy <peterjeremy@acm.org>
MFC after:	3 days
2010-04-05 10:01:53 +00:00
Xin LI
4f0d3f44e0 Consider flag == 0 as the same of flag == R_NEXT. This change will restore
a historical behavior that has been changed by revision 190491, and has seen
to break exim.
2009-08-24 23:44:07 +00:00
Xin LI
47f8598e50 Update SCCS IDs for Berkeley DB 1.86 merge. 2009-06-24 01:15:10 +00:00
Xin LI
fc35a18481 style: operators should appear at the line end if we have to wrap. 2009-06-24 01:14:17 +00:00
Xin LI
e8ee08bad8 Add some casts to silence compiler warning about signedness. 2009-03-28 07:44:08 +00:00
Xin LI
9fc74a871c Minor changes from Berkeley DB 1.86 and further improvements from OpenBSD.
This does not include the new hash routines since they will cause problems
when reading old hash files.

Since mpool(3) has been changed, provide a compatibility shim for older
binaries.

Obtained from:	OpenBSD
2009-03-28 07:31:02 +00:00
Xin LI
73590c342a Allow O_SYNC and O_NOFOLLOW flags in dbopen().
Obtained from:	OpenBSD
2009-03-28 07:26:00 +00:00
Xin LI
6c90d46ee5 Plug memory leaks and a potential NULL dereference.
Obtained from:	OpenBSD
2009-03-28 07:20:39 +00:00
Xin LI
edcdc752ec Simplify the logic when determining whether to zero out a db file to after
open().  The previous logic only initializes the database when O_CREAT is
set, but as long as we can open and write the database, and the database
is empty, we should initialize it anyway.

Obtained from:	OpenBSD
2009-03-28 07:09:51 +00:00
Xin LI
a47fc82519 - If (keysize+datasize)%(bsize=14)==0, insertion of a `big key' would cause
an invariant (actually, an ugly hack) to fail, and all Hell would break
   loose.

   When deleting a big key, the offset of an empty page should be bsize, not
   bsize-1; otherwise an insertion into the empty page will cause the new key to
   be elongated by 1 byte.

   Make the packing more dense in a couple of cases.

 - fix NULL dereference exposed on big bsize values;

Obtained from:	NetBSD via OpenBSD
2009-03-28 06:47:05 +00:00
Xin LI
4524c90576 Avoid NULL deference which causes DEBUG1 to crash, not to print useful
information.

Obtained from:	OpenBSD
2009-03-28 06:40:48 +00:00
Xin LI
89bc741f77 - Avoid overwriting the cursor page when the cursor page becomes the
LRU page.
 - Fix for sequential retrieval failure when using large key/data pairs.

Obtained from:	OpenBSD
2009-03-28 06:38:31 +00:00