dragonfly.git
5 years agoPut lwkt_serialize_array_{enter,try,exit}() into its own header file;
Sepherosa Ziehau [Sun, 12 Apr 2009 06:25:07 +0000 (14:25 +0800)]
Put lwkt_serialize_array_{enter,try,exit}() into its own header file;
name it sys/serialize2.h according to our convention.

5 years agoifnet serializer split: Whack ifnet.if_serializer if driver supplies
Sepherosa Ziehau [Sun, 12 Apr 2009 06:15:51 +0000 (14:15 +0800)]
ifnet serializer split: Whack ifnet.if_serializer if driver supplies
serialize functions; mainly to catch invalid reference of if_serializer.

5 years agopktgen: Use ifnet_{serialize,deserialize}_tx()
Sepherosa Ziehau [Sun, 12 Apr 2009 02:02:17 +0000 (10:02 +0800)]
pktgen: Use ifnet_{serialize,deserialize}_tx()

5 years agoSplit ifnet serializer step 4/many: Add IFNET_SERIALIZE_MAIN, which is
Sepherosa Ziehau [Sat, 11 Apr 2009 07:58:20 +0000 (15:58 +0800)]
Split ifnet serializer step 4/many: Add IFNET_SERIALIZE_MAIN, which is
used by polling(4) code.  Now polling(4) no longer tries to hold all
of the serializers of the driver; it just holds driver's main serializer.

5 years agoemx(4): Add serialize/deserialize functions which just skip main serializer
Sepherosa Ziehau [Sat, 11 Apr 2009 05:25:32 +0000 (13:25 +0800)]
emx(4): Add serialize/deserialize functions which just skip main serializer

5 years agoFactor out lwkt_serialize_array_{enter,try,exit}()
Sepherosa Ziehau [Sat, 11 Apr 2009 05:10:19 +0000 (13:10 +0800)]
Factor out lwkt_serialize_array_{enter,try,exit}()

5 years agoAdd IFNET_SERIALIZE_RX(idx)
Sepherosa Ziehau [Sat, 11 Apr 2009 03:13:22 +0000 (11:13 +0800)]
Add IFNET_SERIALIZE_RX(idx)

5 years agoSplit ifnet serializer step 3/many: We no longer need to hold RX
Sepherosa Ziehau [Sat, 11 Apr 2009 03:05:06 +0000 (11:05 +0800)]
Split ifnet serializer step 3/many: We no longer need to hold RX
serializer before calling ifnet.if_input()

5 years agoSplit ifnet serializer step 2/many: Add if_serialize_assert() function
Sepherosa Ziehau [Sat, 11 Apr 2009 02:37:59 +0000 (10:37 +0800)]
Split ifnet serializer step 2/many: Add if_serialize_assert() function
pointer to ifnet, so that upper layer could assert ifnet's serialization
states.  Remove the serialization state assertion on ifnet.if_input()
path, since the serialization state normaly has nothing to do with the
input processing.

5 years agoMerge altq_cbq fix defc2f8f8d209ca94cc6f3d0a8f64c465258a43f
Sepherosa Ziehau [Wed, 8 Apr 2009 12:05:06 +0000 (20:05 +0800)]
Merge altq_cbq fix defc2f8f8d209ca94cc6f3d0a8f64c465258a43f

5 years agoLet emx(4) install its own ifnet serialize functions
Sepherosa Ziehau [Tue, 7 Apr 2009 13:13:51 +0000 (21:13 +0800)]
Let emx(4) install its own ifnet serialize functions

5 years agoPut ifnet.if_serializer assertion under FIX_SERIALIZE_ASSERT
Sepherosa Ziehau [Tue, 7 Apr 2009 13:11:59 +0000 (21:11 +0800)]
Put ifnet.if_serializer assertion under FIX_SERIALIZE_ASSERT

5 years agoSplit ifnet serialize step 1/many: Add if_{serialize,deserialize,tryserialize}()
Sepherosa Ziehau [Sun, 5 Apr 2009 01:04:08 +0000 (09:04 +0800)]
Split ifnet serialize step 1/many: Add if_{serialize,deserialize,tryserialize}()
function pointers to ifnet.

These three function pointers accept ifnet struct and ifnet_serialize
enumeration.

The ifnet_serialize enumeration indicates the serialization type:
IFNET_SERIALIZE_ALL:
    All of the serializers should be held.  Except for if_start and if_input,
    this enumeration must be used when call ifnet function pointers.
IFNET_SERIALIZE_TX:
    Only transmit serializer should be held.  This enumeration could be used
    when calling ifnet.if_start.
IFNET_SERIALIZE_RX:
    Only receive serializer should be held.  This enumeration could be used
    when calling ifnet.if_input.

If the NIC driver does not set these three function pointer, then if_attach()
will set them to the default ones: only one serializer (if_serializer) is used
and ifnet_serialize parameter is ignored.

Following several inline functions are added which are sheer wrappers of the
three ifnet serialize function pointers:
ifnet_serialize_{all,tx,rx}()
ifnet_deserialize_{all,tx,rx}()
ifnet_tryserialize_{all,tx,rx}()

All of the protocol layers and most of the pseudo drivers are converted.

Discussed-with: dillon@

5 years agofts(3): fix typo in MLINK
Stathis Kamperis [Sun, 12 Apr 2009 08:41:57 +0000 (08:41 +0000)]
fts(3): fix typo in MLINK

5 years agokdump: Add net/if_arp.h include
Thomas Nikolajsen [Sun, 12 Apr 2009 06:19:15 +0000 (08:19 +0200)]
kdump: Add net/if_arp.h include

Missing in 7a80e26d5284cff1a1ddbfa4098cf939e9569155

5 years agoRevert "kdump: Add net/if_arp.h include"
Thomas Nikolajsen [Sun, 12 Apr 2009 06:13:37 +0000 (08:13 +0200)]
Revert "kdump: Add net/if_arp.h include"

This reverts commit b81d560f4a7e775a5f5636141f28bdd82425b4fe.

Commit made with wrong username.

5 years agokdump: Add net/if_arp.h include
Charlie [Sun, 12 Apr 2009 05:46:40 +0000 (07:46 +0200)]
kdump: Add net/if_arp.h include

Missing in 7a80e26d5284cff1a1ddbfa4098cf939e9569155

5 years agoxdr(3): Add some missing MLINKS.
Sascha Wildner [Sat, 11 Apr 2009 20:47:05 +0000 (22:47 +0200)]
xdr(3): Add some missing MLINKS.

5 years agolibc/include/namespace.h: Add _getprogname().
Sascha Wildner [Sat, 11 Apr 2009 19:51:08 +0000 (21:51 +0200)]
libc/include/namespace.h: Add _getprogname().

5 years agosln(4): Include <sys/param.h>
Sepherosa Ziehau [Sat, 11 Apr 2009 11:50:14 +0000 (19:50 +0800)]
sln(4): Include <sys/param.h>

5 years agoUnbreak GENERIC building
Sepherosa Ziehau [Sat, 11 Apr 2009 11:40:26 +0000 (19:40 +0800)]
Unbreak GENERIC building

5 years agonetgraph/i4b: sppp struct should start with arpcom, so netgraph could work
Sepherosa Ziehau [Sat, 11 Apr 2009 11:19:41 +0000 (19:19 +0800)]
netgraph/i4b: sppp struct should start with arpcom, so netgraph could work

Reported-by: swildner@
5 years agoBump the version number for the OpenSSL-0.9.8k import.
Peter Avalos [Sat, 11 Apr 2009 08:47:31 +0000 (08:47 +0000)]
Bump the version number for the OpenSSL-0.9.8k import.

5 years agoMerge branch 'vendor/OPENSSL'
Peter Avalos [Sat, 11 Apr 2009 03:15:33 +0000 (03:15 +0000)]
Merge branch 'vendor/OPENSSL'

5 years agoUpgrade to OpenSSL-0.9.8k.
Peter Avalos [Sat, 11 Apr 2009 03:00:56 +0000 (03:00 +0000)]
Upgrade to OpenSSL-0.9.8k.

This fixes security issues (CVE-2009-0590, CVE-2009-0591, CVE-2009-0789)
and other minor bugs.  See CHANGES for more details.

5 years agoAdd README.DELETED to the vendor branch for OpenSSL.
Peter Avalos [Sat, 11 Apr 2009 02:44:26 +0000 (02:44 +0000)]
Add README.DELETED to the vendor branch for OpenSSL.

This is probably a good idea for other directories as well.  It's too
cumbersome not having this file available on the vendor branch, since
that's really where the work is done to remove unwanted files from the
vendor's distribution.

5 years agoComment out granpt() from stdlib.h.
Peter Avalos [Sat, 11 Apr 2009 01:18:46 +0000 (01:18 +0000)]
Comment out granpt() from stdlib.h.

We don't support this yet (hopefully soon).

Noticed-by: beket
5 years agoAdd `set -o tabcomplete' to /bin/sh
YONETANI Tomokazu [Sat, 14 Feb 2009 13:37:20 +0000 (22:37 +0900)]
Add `set -o tabcomplete' to /bin/sh

When set, it binds <tab> to the libedit filename completion function.
Taken-From: NetBSD
In our version, it's turned on by default in an interactive shell.
If you don't like it, put the following line

  set +o tabcomplete >/dev/null 2>&1 || true

in your ~/.shinit (or whatever path $ENV is set to) .

5 years agoAdd missing MLINKS for fts(3)
Stathis Kamperis [Fri, 10 Apr 2009 22:58:20 +0000 (22:58 +0000)]
Add missing MLINKS for fts(3)

5 years agoAdd missing MLINKS for bus_dma(9)
Stathis Kamperis [Fri, 10 Apr 2009 15:45:55 +0000 (15:45 +0000)]
Add missing MLINKS for bus_dma(9)

5 years agocallbootd: Silence warnings.
Sascha Wildner [Fri, 10 Apr 2009 18:22:08 +0000 (20:22 +0200)]
callbootd: Silence warnings.

5 years agoAdd missing MLINK for STAILQ_FOREACH_MUTABLE
Stathis Kamperis [Fri, 10 Apr 2009 13:55:02 +0000 (13:55 +0000)]
Add missing MLINK for STAILQ_FOREACH_MUTABLE

5 years agoAdd missing MLINKS for strto{f,ld} functions
Stathis Kamperis [Fri, 10 Apr 2009 08:26:23 +0000 (08:26 +0000)]
Add missing MLINKS for strto{f,ld} functions

5 years agofpgetround(3): Sync manual page with FreeBSD.
Sascha Wildner [Thu, 9 Apr 2009 09:24:42 +0000 (11:24 +0200)]
fpgetround(3): Sync manual page with FreeBSD.

5 years agotrpt(8): Raise WARNS to 6 and fix warnings.
Sascha Wildner [Wed, 8 Apr 2009 20:39:41 +0000 (22:39 +0200)]
trpt(8): Raise WARNS to 6 and fix warnings.

5 years agotcp_{debug,timer}.h & protosw.h: Constify some strings.
Sascha Wildner [Wed, 8 Apr 2009 20:39:02 +0000 (22:39 +0200)]
tcp_{debug,timer}.h & protosw.h: Constify some strings.

5 years agosemaphore.h: Revert the last commit. NULL is not defined here.
Sascha Wildner [Wed, 8 Apr 2009 19:20:58 +0000 (21:20 +0200)]
semaphore.h: Revert the last commit. NULL is not defined here.

5 years agoqueue(3): Sync MLINKS situation with the manual page.
Sascha Wildner [Wed, 8 Apr 2009 13:06:34 +0000 (15:06 +0200)]
queue(3): Sync MLINKS situation with the manual page.

5 years agoqueue(3): Mention SLIST_FOREACH_PREVPTR (taken from OpenBSD).
Sascha Wildner [Wed, 8 Apr 2009 13:06:10 +0000 (15:06 +0200)]
queue(3): Mention SLIST_FOREACH_PREVPTR (taken from OpenBSD).

5 years agoaltq_cbq: In restart, release ALTQ serializer to avoid dead lock
Sepherosa Ziehau [Wed, 8 Apr 2009 11:44:31 +0000 (19:44 +0800)]
altq_cbq: In restart, release ALTQ serializer to avoid dead lock

5 years agoSome mdoc fixes in various places.
Sascha Wildner [Wed, 8 Apr 2009 07:10:37 +0000 (09:10 +0200)]
Some mdoc fixes in various places.

5 years agoAdd MLINKS for getgrent_r(3), getgrgid_r(3) & getgrnam_r(3).
Sascha Wildner [Wed, 8 Apr 2009 07:09:53 +0000 (09:09 +0200)]
Add MLINKS for getgrent_r(3), getgrgid_r(3) & getgrnam_r(3).

5 years agoMerge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
Matthew Dillon [Tue, 7 Apr 2009 23:08:21 +0000 (16:08 -0700)]
Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly

5 years agoHAMMER VFS - Fix edge case in mirroring code.
Matthew Dillon [Tue, 7 Apr 2009 23:03:24 +0000 (16:03 -0700)]
HAMMER VFS - Fix edge case in mirroring code.

There is an edge case where a record is physically destroyed on the master
and a mirroring or mirror-streaming operation attempts to delete the record
on the slave using a mirror-end TID that in fact matches the create_tid of
the record.  This results in a protective panic.

Fix the problem simply by not deleting such edge-case records.  They will
be deleted in the next pass, since in order to have been destroyed on the
master the master must have done the operation with a larger TID then
the create_tid of the record that was destroyed.

Reported-by: Brad Frank <brad.frank@gmail.com>
5 years agoSync a couple of prototypes (mknod(), mktemp() & friends) with FreeBSD.
Sascha Wildner [Tue, 7 Apr 2009 21:41:28 +0000 (23:41 +0200)]
Sync a couple of prototypes (mknod(), mktemp() & friends) with FreeBSD.

5 years agoMerge commit 'chlamydia/master'
Thomas Nikolajsen [Tue, 7 Apr 2009 21:15:00 +0000 (23:15 +0200)]
Merge commit 'chlamydia/master'

5 years agosys/types.h: Add protection of typedefs
Thomas Nikolajsen [Tue, 7 Apr 2009 20:58:26 +0000 (22:58 +0200)]
sys/types.h: Add protection of typedefs

missing in 9d66746cf7a1da0544550266a1c5cb53e776aa01

5 years agotimed(8): Include <string.h> instead of <strings.h> for strlen() etc. prototypes.
Sascha Wildner [Tue, 7 Apr 2009 20:48:44 +0000 (22:48 +0200)]
timed(8): Include <string.h> instead of <strings.h> for strlen() etc. prototypes.

5 years agoncplogin(1): Include <string.h> instead of <strings.h> for strlen() etc. prototypes.
Sascha Wildner [Tue, 7 Apr 2009 20:48:07 +0000 (22:48 +0200)]
ncplogin(1): Include <string.h> instead of <strings.h> for strlen() etc. prototypes.

5 years agolibncp: Include <string.h> instead of <strings.h> for strlen() etc. prototypes.
Sascha Wildner [Tue, 7 Apr 2009 20:47:33 +0000 (22:47 +0200)]
libncp: Include <string.h> instead of <strings.h> for strlen() etc. prototypes.

5 years agopw(8): setgrent()'s return type is void.
Sascha Wildner [Tue, 7 Apr 2009 16:59:53 +0000 (18:59 +0200)]
pw(8): setgrent()'s return type is void.

5 years agonewsyslog(8): Silence warning.
Sascha Wildner [Tue, 7 Apr 2009 16:59:17 +0000 (18:59 +0200)]
newsyslog(8): Silence warning.

5 years agosh(1): Deconstify unsetvar()'s argument when passing it to change_env().
Sascha Wildner [Tue, 7 Apr 2009 16:58:08 +0000 (18:58 +0200)]
sh(1): Deconstify unsetvar()'s argument when passing it to change_env().

5 years agoInclude <string.h> instead of <strings.h> in various places.
Sascha Wildner [Tue, 7 Apr 2009 16:56:23 +0000 (18:56 +0200)]
Include <string.h> instead of <strings.h> in various places.

5 years agoAdd missing MLINKS for {getchar,putchar}_unlocked functions
Stathis Kamperis [Tue, 7 Apr 2009 11:25:40 +0000 (11:25 +0000)]
Add missing MLINKS for {getchar,putchar}_unlocked functions

5 years agoReplace all casts of NULL to something with NULL.
Sascha Wildner [Mon, 6 Apr 2009 12:52:46 +0000 (14:52 +0200)]
Replace all casts of NULL to something with NULL.

5 years ago<sys/un.h>: #include <sys/file.h> for struct file.
Sascha Wildner [Mon, 6 Apr 2009 00:19:59 +0000 (02:19 +0200)]
<sys/un.h>: #include <sys/file.h> for struct file.

5 years agoindent(1): Sync with FreeBSD and raise WARNS to 6.
Sascha Wildner [Sun, 5 Apr 2009 23:45:19 +0000 (01:45 +0200)]
indent(1): Sync with FreeBSD and raise WARNS to 6.

5 years agoGenerally use NULL instead of explicitly casting 0 to some pointer type (part2).
Sascha Wildner [Sun, 5 Apr 2009 22:52:17 +0000 (00:52 +0200)]
Generally use NULL instead of explicitly casting 0 to some pointer type (part2).

5 years agoGenerally use NULL instead of explicitly casting 0 to some pointer type.
Sascha Wildner [Sun, 5 Apr 2009 20:33:01 +0000 (22:33 +0200)]
Generally use NULL instead of explicitly casting 0 to some pointer type.

5 years agoUse NULL instead of 0 in various places.
Sascha Wildner [Sun, 5 Apr 2009 20:31:26 +0000 (22:31 +0200)]
Use NULL instead of 0 in various places.

5 years agogetnetgrent(3): Improve markup.
Sascha Wildner [Sun, 5 Apr 2009 20:28:37 +0000 (22:28 +0200)]
getnetgrent(3): Improve markup.

5 years agosys/dev/usbmisc/Makefile: Remove duplicate entry.
Sascha Wildner [Sun, 5 Apr 2009 20:09:15 +0000 (22:09 +0200)]
sys/dev/usbmisc/Makefile: Remove duplicate entry.

5 years agoBump libc's version and __DragonFly_version for recent changes made.
Peter Avalos [Mon, 23 Mar 2009 02:19:11 +0000 (16:19 -1000)]
Bump libc's version and __DragonFly_version for recent changes made.

5 years agoClean up sysconf and associated headers.
Peter Avalos [Sat, 4 Apr 2009 05:23:27 +0000 (05:23 +0000)]
Clean up sysconf and associated headers.

* Fixes for amd64.

* Implement more keys.

* Namespace cleanups for the include files.  Move definitions that are
implemented in userspace from sys/unistd.h to unistd.h.

* Try to avoid using sysctl and just provide the constants direct.

Obtained-from: FreeBSD

5 years agoFix some namespace issues with grp.h and pwd.h.
Peter Avalos [Sun, 22 Mar 2009 21:47:29 +0000 (11:47 -1000)]
Fix some namespace issues with grp.h and pwd.h.

* [1] endpwent, getpwent, setgrent, and setpwent are XSI extensions.

* Change setgrent's prototype to match SuS.

* SuS requires that gid_t be defined in grp.h and pwd.h, and uid_t be in
  pwd.h.

[1] Obtained-from: FreeBSD

5 years agoRevert "Temporary hack out reentrant user database functions."
Peter Avalos [Sun, 22 Mar 2009 21:31:06 +0000 (11:31 -1000)]
Revert "Temporary hack out reentrant user database functions."

This reverts commit 75ce8d9fc3ccabbd5bd15bcf79ab1e7da8a5b4cb.

5 years agoSync ttyname with FreeBSD:
Peter Avalos [Mon, 16 Mar 2009 02:56:50 +0000 (16:56 -1000)]
Sync ttyname with FreeBSD:

* SuS says ttyname_r should return an int, so do that.

* Use devname(3) instead of rolling our own code.

* Simplify the threaded/unthreaded stuff.

5 years agoSync times() with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 11:16:52 +0000 (01:16 -1000)]
Sync times() with FreeBSD:

* The times(3) function returns the number of CLK_TCKs since the
startup time, not since the UNIX Epoch.

* Make the returnvalue of times(3) insensitive to changes in wall-clock.

5 years agotime() C99 compliance:
Peter Avalos [Sun, 15 Mar 2009 11:09:48 +0000 (01:09 -1000)]
time() C99 compliance:

* time() always sets its return value in both places (if present),
even on error.

Obtained-from: FreeBSD

5 years agoAdd a tcgetsid() function that returns session id.
Peter Avalos [Sun, 15 Mar 2009 11:01:05 +0000 (01:01 -1000)]
Add a tcgetsid() function that returns session id.

Obtained-from: FreeBSD

5 years agoSync syslogd with FreBSD:
Peter Avalos [Sun, 15 Mar 2009 10:28:51 +0000 (00:28 -1000)]
Sync syslogd with FreBSD:

* Add a flag, -T, that tells syslogd to always replace the timestamp on
messages from the network.  This option lets us replace timestamps that
are correctly formatted but wrong.

* Allow comment to be placed at the end of a configuration line.

* Add a -8 switch to syslogd to prevent it from mangling 8-bit data.

* Open ctty in non-blocking mode to avoid hangs during open and close.

* Handle "*" as a priority properly.

* Dynamically determine length vs. hardcoding it.

* Free the previous message buffer (f_prevline) only after logging all
the messages and just before the process exit.  Also check f_prevline for
NULL before using it.

* Add the ability to log to an arbitrary udp port as well as the
standard syslog port.

* Currently, if writing out a log entry fails, we unlink that log entry
from our internal list of logfiles. So if writev(2) fails for potentially
transient errors like ENOSPC, syslogd requires a restart, even if the
filesystem has purged.  This change allows syslogd to ignore ENOSPC
space errors, so that when the filesystem is cleaned up, syslogd will
automatically start logging again without requiring the reset.
This makes syslogd(8) a bit more reliable.

* Add -C option which tells syslogd(8) to create log files if they don't
exist.

* Add cases for ENOBUFS and ENETDOWN. We need to make sure that we
catch all transient errors. This fixes situations where transient
error conditions such as network interfaces losing carrier signals
or the system running out of mbufs would result in the permanent
removal of forwarding syslog messages.

* Add -S option which allows to change the pathname of the privileged
socket /var/run/logpriv.

* Check that supplied facility is not bigger than LOG_NFACILITIES.

* Allow ':' and '%' in hostname specifications so that we can specify
IPv6 addresses and scope IDs.

* Protect against local flooder of /var/run/log. Do not loop forever in
syslog(3) if we are a priveleged program (sshd, su, etc.).

  - Make syslogd open an additional socket /var/run/logpriv, with 0600
    permissions.
  - In libc, try to use this socket.
  - Do not loop forever if we are using this socket

* Use stailqueue for sockets instead of socket buffer. Thus remove
limit for 20 sockets.

* Add possibility to specify file mode for sockets created with '-l'.

* Check that socket name in '-l' is absolute.

* Make syslog(3) thread safe.

5 years agoSimplify the return value of sysctlnametomib.
Peter Avalos [Sun, 15 Mar 2009 09:04:16 +0000 (23:04 -1000)]
Simplify the return value of sysctlnametomib.

Obtained-from: FreeBSD

5 years agoWARNS: Add a prototype for __sysctl.
Peter Avalos [Sun, 15 Mar 2009 08:58:26 +0000 (22:58 -1000)]
WARNS: Add a prototype for __sysctl.

Obtained-from: FreeBSD

5 years agoSync stringlist with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 08:06:53 +0000 (22:06 -1000)]
Sync stringlist with FreeBSD:

* Fix a few namespace issues concerning err().

* sl_add returns an int now.

* Fix some whitespace issues in stringlist.h.

5 years agoReduce setproctitle's memory footprint on libc.
Peter Avalos [Sun, 15 Mar 2009 07:45:18 +0000 (21:45 -1000)]
Reduce setproctitle's memory footprint on libc.

Obtained-from: FreeBSD

5 years agoSync setmode(3) with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 04:20:21 +0000 (18:20 -1000)]
Sync setmode(3) with FreeBSD:

* Use correct error detection of realloc failure

* strtol negative return check

* use strtol to validate string instead of rolling our own
validation code

* terminate the command sequence correctly

5 years agoSync popen(3) with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 03:32:32 +0000 (17:32 -1000)]
Sync popen(3) with FreeBSD:

* Convert popen()'s `pidlist' to a SLIST, for consistency.

* Protect pidlist with a mutex to avoid a race causing a duplicate
free() when the same pipe FILE is pclosed()'d in different threads,
and to avoid corrupting the linked list when adding or removing
items.

5 years agoSync sys/queue.h with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 06:58:33 +0000 (20:58 -1000)]
Sync sys/queue.h with FreeBSD:

* Introduce REMOVE_NEXT() macro's for SLIST and STAILQ.

* Add sanity checking for QUEUE(3) TAILQs and LISTs under
INVARIANTS.  Races may lead to list corruption, which can be
difficult to unravel in a post-mortem analysis.  These checks verify
that the prev and next pointers are consistent when inserting or
removing elements, thus catching any corruption earlier.

* Use TRASHIT to break LIST and SLIST link pointers on element removal.

* Add more _FOREACH_MUTABLEs. Note: FreeBSD and NetBSD call these _SAFE,
but _MUTABLE is a better name, so that's what we're using.

* Add a macro for SLIST traversal 'SLIST_FOREACH_PREVPTR',
this macro keeps a pointer to the previous element's next
pointer to allow for search and O(1) removal.

* Remove CIRCLEQs and replace them with TAILQs.

5 years agoinitgroups(): Remove unneeded includes and use gid_t.
Peter Avalos [Sun, 15 Mar 2009 02:43:29 +0000 (16:43 -1000)]
initgroups(): Remove unneeded includes and use gid_t.

5 years agoSync glob(3) with FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 02:31:59 +0000 (16:31 -1000)]
Sync glob(3) with FreeBSD:

* Change int to size_t where appropriate.

* Don't reuse *pl to skip [], it is already used for {} parts in the
loop above.

* Add support for multibyte characters.

5 years agogetttyent(3) fixes from FreeBSD:
Peter Avalos [Sun, 15 Mar 2009 01:40:26 +0000 (15:40 -1000)]
getttyent(3) fixes from FreeBSD:

* In getttyent(3), if /etc/ttys doesn't end in a newline, don't
freak out and keep trying to expand the buffer until realloc()
fails.

* Move initialization above point of first possible reference to
avoid overwriting ty_status values set from the 'type' field.

* Fix the NAME section making whatis(1) happy in particular.

5 years agoSync getnetgrent with FreeBSD:
Peter Avalos [Tue, 10 Mar 2009 08:30:28 +0000 (22:30 -1000)]
Sync getnetgrent with FreeBSD:

* Fix innetgr() returning false positives and negatives when reverse
netgroup matching is used.

* Remember to reset nextgrp in getnetgrent(), so that subsequent calls
to getnetgrent() doesn't return bogus information.

5 years agoSync gethostname() with FreeBSD:
Peter Avalos [Tue, 10 Mar 2009 07:54:43 +0000 (21:54 -1000)]
Sync gethostname() with FreeBSD:

* Change gethostname() to set errno to ENAMETOOLONG instead of ENOMEM
when the buffer is not long enough to hold the current host name.
POSIX does not standardize error returns for gethostname(), so it
doesn't matter which one we use, but ENAMETOOLONG is at least a little
more intuitive.

* Update prototype to match SuS (int->size_t).

5 years agoSync getcap() with FreeBSD:
Peter Avalos [Tue, 10 Mar 2009 06:27:21 +0000 (20:27 -1000)]
Sync getcap() with FreeBSD:

* Expand contractions and fix sentence breaks.

* In cgetmatch(3), return -1 if a NULL or 0-length name parameter is
  used.  This prevents lpd from hanging at boot with certain (legal)
  printcap entries.

* Sprinkle some const.

5 years agoIncrease "max" to a more reasonable maximum in getbsize.
Peter Avalos [Sat, 7 Mar 2009 08:52:26 +0000 (03:52 -0500)]
Increase "max" to a more reasonable maximum in getbsize.

Obtained-from: FreeBSD

5 years agoSync fts(3) with FreeBSD.
Peter Avalos [Fri, 27 Feb 2009 08:26:46 +0000 (03:26 -0500)]
Sync fts(3) with FreeBSD.

Here's some of the relevant commit logs from FreeBSD:

FTSENT now avoids the use of the struct hack, thereby allowing future
extensions to the structure (e.g., for extended attributes) without
rebreaking the ABI.  FTSENT now contains a pointer to the parent stream,
which fts_compar() can then take advantage of, avoiding the undefined
behavior previously warned about.  As a consequence of this change, the
prototype of the comparison function passed to fts_open() has changed
to reflect the required amount of constness for its use.  All callers
in the tree are updated to use the correct prototype.

Comparison functions can now make use of the new parent pointer to
access the new stream-specific private data pointer, which is intended
to assist creation of reentrant library routines which use fts(3)
internally.

The FTS_NOSTAT option is an optimisation that reduces the number
of stat(2) calls by keeping an eye of the number of links a directory
has. It assumes that each subdirectory will have a hard link to its
parent, to represent the ".." node, and stops calling stat(2) when
all links are accounted for in a given directory.

This assumption is really only valid for UNIX-like filesystems: A
concrete example is NTFS. The NTFS "i-node" does contain a link
count, but most/all directories have a link count between 0 and 2
inclusive. The end result is that find on an NTFS volume won't
actually traverse the entire hierarchy of the directories passed
to it. (Those with a link count of two are not traversed at all)

The fix checks the "UFSness" of the filesystem before enabling the
optimisation.

In fts_build(), if we try to chdir and fail (e.g. due to lack of search
permission), try to continue in FTS_DONTCHDIR mode.  Of course this
won't work for long paths, but we can't descend more than one pathname
component beyond the directory anyway if we lack search permission.

Our fts(3) API, as inherited from 4.4BSD, suffers from integer
fields in FTS and FTSENT structs being too narrow.  In addition,
the narrow types creep from there into fts.c.  As a result, fts(3)
consumers, e.g., find(1) or rm(1), can't handle file trees an ordinary
user can create, which can have security implications.

Fix a file descriptor leak.

5 years agoAdd getfstab(3) and setfstab(3).
Peter Avalos [Thu, 26 Feb 2009 10:47:37 +0000 (05:47 -0500)]
Add getfstab(3) and setfstab(3).

* Use PATH_FSTAB instead of hard-coded value.
* Change function name in dump(8) that was conflicting.

Obtained-from: FreeBSD

5 years agoReplace frexp(3) with MI code and add a frexpl(3) function to libm.
Peter Avalos [Thu, 26 Feb 2009 10:19:26 +0000 (05:19 -0500)]
Replace frexp(3) with MI code and add a frexpl(3) function to libm.

Obtained-from: FreeBSD

5 years agoMake FLT_ROUNDS reflect the dynamic rounding mode and use correct values for LDBL_*.
Peter Avalos [Fri, 27 Feb 2009 02:38:59 +0000 (21:38 -0500)]
Make FLT_ROUNDS reflect the dynamic rounding mode and use correct values for LDBL_*.

Obtained-from: FreeBSD

5 years agoSync fnmatch(3) with FreeBSD.
Peter Avalos [Thu, 26 Feb 2009 08:21:07 +0000 (03:21 -0500)]
Sync fnmatch(3) with FreeBSD.

* Define FNM_NOSYS iaw SUS.

* Document the missing portions of IEEE Std. 1003.2.

* Add support for multibyte characters.

5 years agoSync fmtcheck(3) with FreeBSD, teaching it some new flags and args.
Peter Avalos [Thu, 26 Feb 2009 07:32:43 +0000 (02:32 -0500)]
Sync fmtcheck(3) with FreeBSD, teaching it some new flags and args.

5 years agoAdd posix_spawn() and posix_spawnp().
Peter Avalos [Sun, 15 Feb 2009 20:46:03 +0000 (15:46 -0500)]
Add posix_spawn() and posix_spawnp().

Also add execvP() which takes the search path as an argument.

Obtained-from: FreeBSD

5 years agoAdd a few new errnos and improve documentation.
Peter Avalos [Sat, 14 Feb 2009 23:11:36 +0000 (18:11 -0500)]
Add a few new errnos and improve documentation.

Some of these aren't used, but are required by POSIX.

Obtained-from: FreeBSD

5 years agoFix a few namespace issues in err.c.
Peter Avalos [Sat, 14 Feb 2009 19:48:33 +0000 (14:48 -0500)]
Fix a few namespace issues in err.c.

While I'm here, use sysexits in examples in the manual page.

Obtained-from: FreeBSD

5 years agoSync daemon(3) with FreeBSD:
Peter Avalos [Fri, 13 Feb 2009 22:37:49 +0000 (17:37 -0500)]
Sync daemon(3) with FreeBSD:

* Prevent abnormal termination of a child daemon process when created
by a parent that is a session leader (e.g., login shell) by ignoring
SIGHUP in before calling fork(2) and then restoring SIGHUP's action
after setsid(3).

* Merge some updates and markup fixes from OpenBSD for the manual page.

5 years agoSync confstr(3) with FreeBSD:
Peter Avalos [Fri, 13 Feb 2009 21:40:06 +0000 (16:40 -0500)]
Sync confstr(3) with FreeBSD:

* Support SUS "programming environment".
* confstr() returns compile-time constants.  Don't use sysctl to get
  the value of _PATD_STDPATH when we can just get it directly.

5 years agoSync assert with FreeBSD:
Peter Avalos [Fri, 13 Feb 2009 18:43:06 +0000 (13:43 -0500)]
Sync assert with FreeBSD:

* Change __assert() function to print failing function name.

* Make the output from assert() look more like the example in the C99
standard.

5 years agoSync arc4random with FreeBSD:
Peter Avalos [Fri, 13 Feb 2009 06:15:48 +0000 (01:15 -0500)]
Sync arc4random with FreeBSD:

* Add locking.

* Automatically re-stir

* Implement _buf() and _uniform() functions.

* Eliminate the arc4_stream arg since there's only 1 that's possible.

5 years agoFix format strings and a spelling errors.
Peter Avalos [Sun, 8 Feb 2009 16:45:31 +0000 (11:45 -0500)]
Fix format strings and a spelling errors.

Obtained-from: FreeBSD