[Midnightbsd-cvs] src [10621] trunk/lib/libc/gen/wordexp.c: sync with freebsd
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jun 9 11:41:33 EDT 2018
Revision: 10621
http://svnweb.midnightbsd.org/src/?rev=10621
Author: laffer1
Date: 2018-06-09 11:41:32 -0400 (Sat, 09 Jun 2018)
Log Message:
-----------
sync with freebsd
Modified Paths:
--------------
trunk/lib/libc/gen/Makefile.inc
trunk/lib/libc/gen/Symbol.map
trunk/lib/libc/gen/__getosreldate.c
trunk/lib/libc/gen/__xuname.c
trunk/lib/libc/gen/_once_stub.c
trunk/lib/libc/gen/_pthread_stubs.c
trunk/lib/libc/gen/_rand48.c
trunk/lib/libc/gen/_spinlock_stub.c
trunk/lib/libc/gen/_thread_init.c
trunk/lib/libc/gen/alarm.3
trunk/lib/libc/gen/alarm.c
trunk/lib/libc/gen/arc4random.3
trunk/lib/libc/gen/arc4random.c
trunk/lib/libc/gen/assert.c
trunk/lib/libc/gen/basename.3
trunk/lib/libc/gen/basename.c
trunk/lib/libc/gen/check_utility_compat.3
trunk/lib/libc/gen/check_utility_compat.c
trunk/lib/libc/gen/clock.3
trunk/lib/libc/gen/clock.c
trunk/lib/libc/gen/closedir.c
trunk/lib/libc/gen/confstr.3
trunk/lib/libc/gen/confstr.c
trunk/lib/libc/gen/crypt.c
trunk/lib/libc/gen/ctermid.3
trunk/lib/libc/gen/ctermid.c
trunk/lib/libc/gen/daemon.3
trunk/lib/libc/gen/daemon.c
trunk/lib/libc/gen/devname.3
trunk/lib/libc/gen/devname.c
trunk/lib/libc/gen/directory.3
trunk/lib/libc/gen/dirname.3
trunk/lib/libc/gen/dirname.c
trunk/lib/libc/gen/disklabel.c
trunk/lib/libc/gen/dl_iterate_phdr.3
trunk/lib/libc/gen/dladdr.3
trunk/lib/libc/gen/dlfcn.c
trunk/lib/libc/gen/dlinfo.3
trunk/lib/libc/gen/dllockinit.3
trunk/lib/libc/gen/dlopen.3
trunk/lib/libc/gen/drand48.c
trunk/lib/libc/gen/elf_utils.c
trunk/lib/libc/gen/erand48.c
trunk/lib/libc/gen/err.3
trunk/lib/libc/gen/err.c
trunk/lib/libc/gen/errlst.c
trunk/lib/libc/gen/errno.c
trunk/lib/libc/gen/exec.3
trunk/lib/libc/gen/exec.c
trunk/lib/libc/gen/fdevname.c
trunk/lib/libc/gen/feature_present.3
trunk/lib/libc/gen/feature_present.c
trunk/lib/libc/gen/fmtcheck.3
trunk/lib/libc/gen/fmtcheck.c
trunk/lib/libc/gen/fmtmsg.3
trunk/lib/libc/gen/fmtmsg.c
trunk/lib/libc/gen/fnmatch.3
trunk/lib/libc/gen/fnmatch.c
trunk/lib/libc/gen/fpclassify.3
trunk/lib/libc/gen/fpclassify.c
trunk/lib/libc/gen/frexp.3
trunk/lib/libc/gen/frexp.c
trunk/lib/libc/gen/fstab.c
trunk/lib/libc/gen/ftok.3
trunk/lib/libc/gen/ftok.c
trunk/lib/libc/gen/fts-compat.c
trunk/lib/libc/gen/fts-compat.h
trunk/lib/libc/gen/fts.3
trunk/lib/libc/gen/fts.c
trunk/lib/libc/gen/ftw.3
trunk/lib/libc/gen/ftw.c
trunk/lib/libc/gen/getbootfile.3
trunk/lib/libc/gen/getbootfile.c
trunk/lib/libc/gen/getbsize.3
trunk/lib/libc/gen/getbsize.c
trunk/lib/libc/gen/getcap.3
trunk/lib/libc/gen/getcap.c
trunk/lib/libc/gen/getcontext.3
trunk/lib/libc/gen/getcwd.3
trunk/lib/libc/gen/getcwd.c
trunk/lib/libc/gen/getdiskbyname.3
trunk/lib/libc/gen/getdomainname.3
trunk/lib/libc/gen/getdomainname.c
trunk/lib/libc/gen/getfsent.3
trunk/lib/libc/gen/getgrent.3
trunk/lib/libc/gen/getgrent.c
trunk/lib/libc/gen/getgrouplist.3
trunk/lib/libc/gen/getgrouplist.c
trunk/lib/libc/gen/gethostname.3
trunk/lib/libc/gen/gethostname.c
trunk/lib/libc/gen/getloadavg.3
trunk/lib/libc/gen/getloadavg.c
trunk/lib/libc/gen/getlogin.c
trunk/lib/libc/gen/getmntinfo.3
trunk/lib/libc/gen/getmntinfo.c
trunk/lib/libc/gen/getnetgrent.3
trunk/lib/libc/gen/getnetgrent.c
trunk/lib/libc/gen/getosreldate.3
trunk/lib/libc/gen/getosreldate.c
trunk/lib/libc/gen/getpagesize.3
trunk/lib/libc/gen/getpagesize.c
trunk/lib/libc/gen/getpagesizes.3
trunk/lib/libc/gen/getpagesizes.c
trunk/lib/libc/gen/getpass.3
trunk/lib/libc/gen/getpeereid.3
trunk/lib/libc/gen/getpeereid.c
trunk/lib/libc/gen/getprogname.3
trunk/lib/libc/gen/getprogname.c
trunk/lib/libc/gen/getpwent.3
trunk/lib/libc/gen/getpwent.c
trunk/lib/libc/gen/getttyent.3
trunk/lib/libc/gen/getttyent.c
trunk/lib/libc/gen/getusershell.3
trunk/lib/libc/gen/getusershell.c
trunk/lib/libc/gen/getutxent.3
trunk/lib/libc/gen/getutxent.c
trunk/lib/libc/gen/getvfsbyname.3
trunk/lib/libc/gen/getvfsbyname.c
trunk/lib/libc/gen/glob.3
trunk/lib/libc/gen/glob.c
trunk/lib/libc/gen/initgroups.3
trunk/lib/libc/gen/initgroups.c
trunk/lib/libc/gen/isatty.c
trunk/lib/libc/gen/isgreater.3
trunk/lib/libc/gen/isinf.c
trunk/lib/libc/gen/isnan.c
trunk/lib/libc/gen/jrand48.c
trunk/lib/libc/gen/lcong48.c
trunk/lib/libc/gen/ldexp.3
trunk/lib/libc/gen/ldexp.c
trunk/lib/libc/gen/libc_dlopen.c
trunk/lib/libc/gen/lockf.3
trunk/lib/libc/gen/lockf.c
trunk/lib/libc/gen/lrand48.c
trunk/lib/libc/gen/makecontext.3
trunk/lib/libc/gen/modf.3
trunk/lib/libc/gen/mrand48.c
trunk/lib/libc/gen/nftw.c
trunk/lib/libc/gen/nice.3
trunk/lib/libc/gen/nice.c
trunk/lib/libc/gen/nlist.3
trunk/lib/libc/gen/nlist.c
trunk/lib/libc/gen/nrand48.c
trunk/lib/libc/gen/opendir.c
trunk/lib/libc/gen/pause.3
trunk/lib/libc/gen/pause.c
trunk/lib/libc/gen/pmadvise.c
trunk/lib/libc/gen/popen.3
trunk/lib/libc/gen/popen.c
trunk/lib/libc/gen/posix_spawn.3
trunk/lib/libc/gen/posix_spawn.c
trunk/lib/libc/gen/posix_spawn_file_actions_addopen.3
trunk/lib/libc/gen/posix_spawn_file_actions_init.3
trunk/lib/libc/gen/posix_spawnattr_getflags.3
trunk/lib/libc/gen/posix_spawnattr_getpgroup.3
trunk/lib/libc/gen/posix_spawnattr_getschedparam.3
trunk/lib/libc/gen/posix_spawnattr_getschedpolicy.3
trunk/lib/libc/gen/posix_spawnattr_getsigdefault.3
trunk/lib/libc/gen/posix_spawnattr_getsigmask.3
trunk/lib/libc/gen/posix_spawnattr_init.3
trunk/lib/libc/gen/psignal.3
trunk/lib/libc/gen/psignal.c
trunk/lib/libc/gen/pututxline.c
trunk/lib/libc/gen/pw_scan.c
trunk/lib/libc/gen/pw_scan.h
trunk/lib/libc/gen/raise.3
trunk/lib/libc/gen/raise.c
trunk/lib/libc/gen/rand48.3
trunk/lib/libc/gen/rand48.h
trunk/lib/libc/gen/readdir.c
trunk/lib/libc/gen/readpassphrase.3
trunk/lib/libc/gen/readpassphrase.c
trunk/lib/libc/gen/rewinddir.c
trunk/lib/libc/gen/rfork_thread.3
trunk/lib/libc/gen/scandir.3
trunk/lib/libc/gen/scandir.c
trunk/lib/libc/gen/seed48.c
trunk/lib/libc/gen/seekdir.c
trunk/lib/libc/gen/sem.c
trunk/lib/libc/gen/sem_destroy.3
trunk/lib/libc/gen/sem_getvalue.3
trunk/lib/libc/gen/sem_init.3
trunk/lib/libc/gen/sem_new.c
trunk/lib/libc/gen/sem_open.3
trunk/lib/libc/gen/sem_post.3
trunk/lib/libc/gen/sem_timedwait.3
trunk/lib/libc/gen/sem_wait.3
trunk/lib/libc/gen/semctl.c
trunk/lib/libc/gen/setdomainname.c
trunk/lib/libc/gen/sethostname.c
trunk/lib/libc/gen/setjmp.3
trunk/lib/libc/gen/setjmperr.c
trunk/lib/libc/gen/setmode.3
trunk/lib/libc/gen/setmode.c
trunk/lib/libc/gen/setproctitle.3
trunk/lib/libc/gen/setproctitle.c
trunk/lib/libc/gen/setprogname.c
trunk/lib/libc/gen/siginterrupt.3
trunk/lib/libc/gen/siginterrupt.c
trunk/lib/libc/gen/siglist.c
trunk/lib/libc/gen/signal.3
trunk/lib/libc/gen/signal.c
trunk/lib/libc/gen/sigsetops.3
trunk/lib/libc/gen/sigsetops.c
trunk/lib/libc/gen/sleep.3
trunk/lib/libc/gen/sleep.c
trunk/lib/libc/gen/srand48.c
trunk/lib/libc/gen/statvfs.3
trunk/lib/libc/gen/statvfs.c
trunk/lib/libc/gen/stringlist.3
trunk/lib/libc/gen/stringlist.c
trunk/lib/libc/gen/strtofflags.3
trunk/lib/libc/gen/strtofflags.c
trunk/lib/libc/gen/sysconf.3
trunk/lib/libc/gen/sysconf.c
trunk/lib/libc/gen/sysctl.3
trunk/lib/libc/gen/sysctl.c
trunk/lib/libc/gen/sysctlbyname.c
trunk/lib/libc/gen/sysctlnametomib.c
trunk/lib/libc/gen/syslog.3
trunk/lib/libc/gen/syslog.c
trunk/lib/libc/gen/tcgetpgrp.3
trunk/lib/libc/gen/tcgetsid.3
trunk/lib/libc/gen/tcsendbreak.3
trunk/lib/libc/gen/tcsetattr.3
trunk/lib/libc/gen/tcsetpgrp.3
trunk/lib/libc/gen/tcsetsid.3
trunk/lib/libc/gen/telldir.c
trunk/lib/libc/gen/telldir.h
trunk/lib/libc/gen/termios.c
trunk/lib/libc/gen/time.3
trunk/lib/libc/gen/time.c
trunk/lib/libc/gen/times.3
trunk/lib/libc/gen/times.c
trunk/lib/libc/gen/timezone.3
trunk/lib/libc/gen/timezone.c
trunk/lib/libc/gen/tls.c
trunk/lib/libc/gen/ttyname.3
trunk/lib/libc/gen/ttyname.c
trunk/lib/libc/gen/ttyslot.c
trunk/lib/libc/gen/tzset.3
trunk/lib/libc/gen/ualarm.3
trunk/lib/libc/gen/ualarm.c
trunk/lib/libc/gen/ucontext.3
trunk/lib/libc/gen/ulimit.3
trunk/lib/libc/gen/ulimit.c
trunk/lib/libc/gen/uname.3
trunk/lib/libc/gen/uname.c
trunk/lib/libc/gen/unvis-compat.c
trunk/lib/libc/gen/usleep.3
trunk/lib/libc/gen/usleep.c
trunk/lib/libc/gen/utime.3
trunk/lib/libc/gen/utime.c
trunk/lib/libc/gen/utxdb.c
trunk/lib/libc/gen/utxdb.h
trunk/lib/libc/gen/valloc.3
trunk/lib/libc/gen/valloc.c
trunk/lib/libc/gen/wait.c
trunk/lib/libc/gen/wait3.c
trunk/lib/libc/gen/waitid.c
trunk/lib/libc/gen/waitpid.c
trunk/lib/libc/gen/wordexp.3
trunk/lib/libc/gen/wordexp.c
Added Paths:
-----------
trunk/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c
trunk/lib/libc/gen/auxv.c
trunk/lib/libc/gen/cap_rights_get.3
trunk/lib/libc/gen/cap_sandboxed.3
trunk/lib/libc/gen/cap_sandboxed.c
trunk/lib/libc/gen/clock_getcpuclockid.3
trunk/lib/libc/gen/clock_getcpuclockid.c
trunk/lib/libc/gen/dirfd.c
trunk/lib/libc/gen/dup3.3
trunk/lib/libc/gen/dup3.c
trunk/lib/libc/gen/gen-private.h
trunk/lib/libc/gen/modf.c
Property Changed:
----------------
trunk/lib/libc/gen/Makefile.inc
trunk/lib/libc/gen/Symbol.map
trunk/lib/libc/gen/alarm.3
trunk/lib/libc/gen/arc4random.3
trunk/lib/libc/gen/basename.3
trunk/lib/libc/gen/check_utility_compat.3
trunk/lib/libc/gen/clock.3
trunk/lib/libc/gen/confstr.3
trunk/lib/libc/gen/ctermid.3
trunk/lib/libc/gen/daemon.3
trunk/lib/libc/gen/devname.3
trunk/lib/libc/gen/directory.3
trunk/lib/libc/gen/dirname.3
trunk/lib/libc/gen/dl_iterate_phdr.3
trunk/lib/libc/gen/dladdr.3
trunk/lib/libc/gen/dlinfo.3
trunk/lib/libc/gen/dllockinit.3
trunk/lib/libc/gen/dlopen.3
trunk/lib/libc/gen/err.3
trunk/lib/libc/gen/exec.3
trunk/lib/libc/gen/feature_present.3
trunk/lib/libc/gen/fmtcheck.3
trunk/lib/libc/gen/fmtmsg.3
trunk/lib/libc/gen/fnmatch.3
trunk/lib/libc/gen/fpclassify.3
trunk/lib/libc/gen/frexp.3
trunk/lib/libc/gen/ftok.3
trunk/lib/libc/gen/fts.3
trunk/lib/libc/gen/ftw.3
trunk/lib/libc/gen/getbootfile.3
trunk/lib/libc/gen/getbsize.3
trunk/lib/libc/gen/getcap.3
trunk/lib/libc/gen/getcontext.3
trunk/lib/libc/gen/getcwd.3
trunk/lib/libc/gen/getdiskbyname.3
trunk/lib/libc/gen/getdomainname.3
trunk/lib/libc/gen/getfsent.3
trunk/lib/libc/gen/getgrent.3
trunk/lib/libc/gen/getgrouplist.3
trunk/lib/libc/gen/gethostname.3
trunk/lib/libc/gen/getloadavg.3
trunk/lib/libc/gen/getmntinfo.3
trunk/lib/libc/gen/getnetgrent.3
trunk/lib/libc/gen/getosreldate.3
trunk/lib/libc/gen/getpagesize.3
trunk/lib/libc/gen/getpagesizes.3
trunk/lib/libc/gen/getpass.3
trunk/lib/libc/gen/getpeereid.3
trunk/lib/libc/gen/getprogname.3
trunk/lib/libc/gen/getpwent.3
trunk/lib/libc/gen/getttyent.3
trunk/lib/libc/gen/getusershell.3
trunk/lib/libc/gen/getutxent.3
trunk/lib/libc/gen/getvfsbyname.3
trunk/lib/libc/gen/glob.3
trunk/lib/libc/gen/initgroups.3
trunk/lib/libc/gen/isgreater.3
trunk/lib/libc/gen/ldexp.3
trunk/lib/libc/gen/lockf.3
trunk/lib/libc/gen/makecontext.3
trunk/lib/libc/gen/modf.3
trunk/lib/libc/gen/nice.3
trunk/lib/libc/gen/nlist.3
trunk/lib/libc/gen/pause.3
trunk/lib/libc/gen/popen.3
trunk/lib/libc/gen/posix_spawn.3
trunk/lib/libc/gen/posix_spawn_file_actions_addopen.3
trunk/lib/libc/gen/posix_spawn_file_actions_init.3
trunk/lib/libc/gen/posix_spawnattr_getflags.3
trunk/lib/libc/gen/posix_spawnattr_getpgroup.3
trunk/lib/libc/gen/posix_spawnattr_getschedparam.3
trunk/lib/libc/gen/posix_spawnattr_getschedpolicy.3
trunk/lib/libc/gen/posix_spawnattr_getsigdefault.3
trunk/lib/libc/gen/posix_spawnattr_getsigmask.3
trunk/lib/libc/gen/posix_spawnattr_init.3
trunk/lib/libc/gen/psignal.3
trunk/lib/libc/gen/raise.3
trunk/lib/libc/gen/rand48.3
trunk/lib/libc/gen/readpassphrase.3
trunk/lib/libc/gen/rfork_thread.3
trunk/lib/libc/gen/scandir.3
trunk/lib/libc/gen/sem_destroy.3
trunk/lib/libc/gen/sem_getvalue.3
trunk/lib/libc/gen/sem_init.3
trunk/lib/libc/gen/sem_open.3
trunk/lib/libc/gen/sem_post.3
trunk/lib/libc/gen/sem_timedwait.3
trunk/lib/libc/gen/sem_wait.3
trunk/lib/libc/gen/setjmp.3
trunk/lib/libc/gen/setmode.3
trunk/lib/libc/gen/setproctitle.3
trunk/lib/libc/gen/siginterrupt.3
trunk/lib/libc/gen/signal.3
trunk/lib/libc/gen/sigsetops.3
trunk/lib/libc/gen/sleep.3
trunk/lib/libc/gen/statvfs.3
trunk/lib/libc/gen/stringlist.3
trunk/lib/libc/gen/strtofflags.3
trunk/lib/libc/gen/sysconf.3
trunk/lib/libc/gen/sysctl.3
trunk/lib/libc/gen/syslog.3
trunk/lib/libc/gen/tcgetpgrp.3
trunk/lib/libc/gen/tcgetsid.3
trunk/lib/libc/gen/tcsendbreak.3
trunk/lib/libc/gen/tcsetattr.3
trunk/lib/libc/gen/tcsetpgrp.3
trunk/lib/libc/gen/tcsetsid.3
trunk/lib/libc/gen/time.3
trunk/lib/libc/gen/times.3
trunk/lib/libc/gen/timezone.3
trunk/lib/libc/gen/ttyname.3
trunk/lib/libc/gen/tzset.3
trunk/lib/libc/gen/ualarm.3
trunk/lib/libc/gen/ucontext.3
trunk/lib/libc/gen/ulimit.3
trunk/lib/libc/gen/uname.3
trunk/lib/libc/gen/usleep.3
trunk/lib/libc/gen/utime.3
trunk/lib/libc/gen/valloc.3
trunk/lib/libc/gen/wordexp.3
Modified: trunk/lib/libc/gen/Makefile.inc
===================================================================
--- trunk/lib/libc/gen/Makefile.inc 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/Makefile.inc 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,40 +1,151 @@
+# $MidnightBSD$
# @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
-# $MidnightBSD$
+# $FreeBSD: stable/10/lib/libc/gen/Makefile.inc 277317 2015-01-18 11:54:20Z kib $
# machine-independent gen sources
.PATH: ${.CURDIR}/${LIBC_ARCH}/gen ${.CURDIR}/gen
-SRCS+= __getosreldate.c __xuname.c \
- _once_stub.c _pthread_stubs.c _rand48.c _spinlock_stub.c \
+SRCS+= __getosreldate.c \
+ __pthread_mutex_init_calloc_cb_stub.c \
+ __xuname.c \
+ _once_stub.c \
+ _pthread_stubs.c \
+ _rand48.c \
+ _spinlock_stub.c \
_thread_init.c \
- alarm.c arc4random.c assert.c aux.c basename.c check_utility_compat.c \
- clock.c closedir.c confstr.c \
- crypt.c ctermid.c daemon.c devname.c dirname.c disklabel.c \
- dlfcn.c drand48.c elf_utils.c erand48.c err.c errlst.c errno.c \
- exec.c fdevname.c feature_present.c fmtcheck.c fmtmsg.c fnmatch.c \
- fpclassify.c frexp.c fstab.c ftok.c fts.c fts-compat.c ftw.c \
- getbootfile.c getbsize.c \
- getcap.c getcwd.c getdomainname.c getgrent.c getgrouplist.c \
- gethostname.c getloadavg.c getlogin.c getmntinfo.c getnetgrent.c \
- getosreldate.c getpagesize.c getpagesizes.c \
- getpeereid.c getprogname.c getpwent.c getttyent.c \
- getusershell.c getutxent.c getvfsbyname.c glob.c \
- initgroups.c isatty.c isinf.c isnan.c jrand48.c lcong48.c \
+ alarm.c \
+ arc4random.c \
+ assert.c \
+ auxv.c \
+ basename.c \
+ cap_sandboxed.c \
+ check_utility_compat.c \
+ clock.c \
+ clock_getcpuclockid.c \
+ closedir.c \
+ confstr.c \
+ crypt.c \
+ ctermid.c \
+ daemon.c \
+ devname.c \
+ dirfd.c \
+ dirname.c \
+ disklabel.c \
+ dlfcn.c \
+ drand48.c \
+ dup3.c \
+ elf_utils.c \
+ erand48.c \
+ err.c \
+ errlst.c \
+ errno.c \
+ exec.c \
+ fdevname.c \
+ feature_present.c \
+ fmtcheck.c \
+ fmtmsg.c \
+ fnmatch.c \
+ fpclassify.c \
+ frexp.c \
+ fstab.c \
+ ftok.c \
+ fts.c \
+ fts-compat.c \
+ ftw.c \
+ getbootfile.c \
+ getbsize.c \
+ getcap.c \
+ getcwd.c \
+ getdomainname.c \
+ getgrent.c \
+ getgrouplist.c \
+ gethostname.c \
+ getloadavg.c \
+ getlogin.c \
+ getmntinfo.c \
+ getnetgrent.c \
+ getosreldate.c \
+ getpagesize.c \
+ getpagesizes.c \
+ getpeereid.c \
+ getprogname.c \
+ getpwent.c \
+ getttyent.c \
+ getusershell.c \
+ getutxent.c \
+ getvfsbyname.c \
+ glob.c \
+ initgroups.c \
+ isatty.c \
+ isinf.c \
+ isnan.c \
+ jrand48.c \
+ lcong48.c \
libc_dlopen.c \
- lockf.c lrand48.c mrand48.c nftw.c nice.c \
- nlist.c nrand48.c opendir.c \
- pause.c pmadvise.c popen.c posix_spawn.c \
- psignal.c pututxline.c pw_scan.c \
- raise.c readdir.c readpassphrase.c rewinddir.c \
- scandir.c seed48.c seekdir.c semctl.c \
- setdomainname.c sethostname.c setjmperr.c setmode.c \
- setproctitle.c setprogname.c siginterrupt.c siglist.c signal.c \
- sigsetops.c sleep.c srand48.c statvfs.c stringlist.c strtofflags.c \
- sysconf.c sysctl.c sysctlbyname.c sysctlnametomib.c \
- syslog.c telldir.c termios.c time.c times.c timezone.c tls.c \
- ttyname.c ttyslot.c ualarm.c ulimit.c uname.c unvis-compat.c \
- usleep.c utime.c utxdb.c valloc.c wait.c wait3.c waitpid.c \
- waitid.c wordexp.c
+ lockf.c \
+ lrand48.c \
+ mrand48.c \
+ nftw.c \
+ nice.c \
+ nlist.c \
+ nrand48.c \
+ opendir.c \
+ pause.c \
+ pmadvise.c \
+ popen.c \
+ posix_spawn.c \
+ psignal.c \
+ pututxline.c \
+ pw_scan.c \
+ raise.c \
+ readdir.c \
+ readpassphrase.c \
+ rewinddir.c \
+ scandir.c \
+ seed48.c \
+ seekdir.c \
+ semctl.c \
+ setdomainname.c \
+ sethostname.c \
+ setjmperr.c \
+ setmode.c \
+ setproctitle.c \
+ setprogname.c \
+ siginterrupt.c \
+ siglist.c \
+ signal.c \
+ sigsetops.c \
+ sleep.c \
+ srand48.c \
+ statvfs.c \
+ stringlist.c \
+ strtofflags.c \
+ sysconf.c \
+ sysctl.c \
+ sysctlbyname.c \
+ sysctlnametomib.c \
+ syslog.c \
+ telldir.c \
+ termios.c \
+ time.c \
+ times.c \
+ timezone.c \
+ tls.c \
+ ttyname.c \
+ ttyslot.c \
+ ualarm.c \
+ ulimit.c \
+ uname.c \
+ unvis-compat.c \
+ usleep.c \
+ utime.c \
+ utxdb.c \
+ valloc.c \
+ wait.c \
+ wait3.c \
+ waitpid.c \
+ waitid.c \
+ wordexp.c
.PATH: ${.CURDIR}/../../contrib/libc-pwcache
SRCS+= pwcache.c pwcache.h
@@ -43,6 +154,8 @@
CFLAGS+= -I${.CURDIR}/../../contrib/libc-vis
SRCS+= unvis.c vis.c
+MISRCS+=modf.c
+
CANCELPOINTS_SRCS=sem.c sem_new.c
.for src in ${CANCELPOINTS_SRCS}
SRCS+=cancelpoints_${src}
@@ -56,102 +169,262 @@
# machine-dependent gen sources
.sinclude "${.CURDIR}/${LIBC_ARCH}/gen/Makefile.inc"
-MAN+= alarm.3 arc4random.3 \
- basename.3 check_utility_compat.3 clock.3 \
- confstr.3 ctermid.3 daemon.3 devname.3 directory.3 dirname.3 \
- dl_iterate_phdr.3 dladdr.3 dlinfo.3 dllockinit.3 dlopen.3 \
- err.3 exec.3 \
- feature_present.3 fmtcheck.3 fmtmsg.3 fnmatch.3 fpclassify.3 frexp.3 \
- ftok.3 fts.3 ftw.3 \
- getbootfile.3 getbsize.3 getcap.3 getcontext.3 getcwd.3 \
- getdiskbyname.3 getdomainname.3 getfsent.3 \
- getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \
- getmntinfo.3 getnetgrent.3 getosreldate.3 getpagesize.3 \
- getpagesizes.3 getpass.3 getpeereid.3 getprogname.3 getpwent.3 \
- getttyent.3 getusershell.3 getutxent.3 getvfsbyname.3 \
- glob.3 initgroups.3 isgreater.3 ldexp.3 lockf.3 makecontext.3 \
+MAN+= alarm.3 \
+ arc4random.3 \
+ basename.3 \
+ cap_rights_get.3 \
+ cap_sandboxed.3 \
+ check_utility_compat.3 \
+ clock.3 \
+ clock_getcpuclockid.3 \
+ confstr.3 \
+ ctermid.3 \
+ daemon.3 \
+ devname.3 \
+ directory.3 \
+ dirname.3 \
+ dl_iterate_phdr.3 \
+ dladdr.3 \
+ dlinfo.3 \
+ dllockinit.3 \
+ dlopen.3 \
+ dup3.3 \
+ err.3 \
+ exec.3 \
+ feature_present.3 \
+ fmtcheck.3 \
+ fmtmsg.3 \
+ fnmatch.3 \
+ fpclassify.3 \
+ frexp.3 \
+ ftok.3 \
+ fts.3 \
+ ftw.3 \
+ getbootfile.3 \
+ getbsize.3 \
+ getcap.3 \
+ getcontext.3 \
+ getcwd.3 \
+ getdiskbyname.3 \
+ getdomainname.3 \
+ getfsent.3 \
+ getgrent.3 \
+ getgrouplist.3 \
+ gethostname.3 \
+ getloadavg.3 \
+ getmntinfo.3 \
+ getnetgrent.3 \
+ getosreldate.3 \
+ getpagesize.3 \
+ getpagesizes.3 \
+ getpass.3 \
+ getpeereid.3 \
+ getprogname.3 \
+ getpwent.3 \
+ getttyent.3 \
+ getusershell.3 \
+ getutxent.3 \
+ getvfsbyname.3 \
+ glob.3 \
+ initgroups.3 \
+ isgreater.3 \
+ ldexp.3 \
+ lockf.3 \
+ makecontext.3 \
modf.3 \
- nice.3 nlist.3 pause.3 popen.3 \
- posix_spawn.3 posix_spawn_file_actions_addopen.3 \
- posix_spawn_file_actions_init.3 posix_spawnattr_getflags.3 \
- posix_spawnattr_getpgroup.3 posix_spawnattr_getschedparam.3 \
- posix_spawnattr_getschedpolicy.3 posix_spawnattr_init.3 \
- posix_spawnattr_getsigdefault.3 posix_spawnattr_getsigmask.3 \
- psignal.3 pwcache.3 \
- raise.3 rand48.3 readpassphrase.3 rfork_thread.3 \
- scandir.3 sem_destroy.3 sem_getvalue.3 sem_init.3 \
- sem_open.3 sem_post.3 sem_timedwait.3 sem_wait.3 \
- setjmp.3 setmode.3 setproctitle.3 \
- siginterrupt.3 signal.3 sigsetops.3 sleep.3 \
- statvfs.3 stringlist.3 \
- strtofflags.3 sysconf.3 sysctl.3 syslog.3 tcgetpgrp.3 tcgetsid.3 \
- tcsendbreak.3 tcsetattr.3 tcsetpgrp.3 tcsetsid.3 time.3 times.3 \
- timezone.3 ttyname.3 tzset.3 ualarm.3 ucontext.3 ulimit.3 uname.3 \
- unvis.3 usleep.3 utime.3 valloc.3 vis.3 wordexp.3
+ nice.3 \
+ nlist.3 \
+ pause.3 \
+ popen.3 \
+ posix_spawn.3 \
+ posix_spawn_file_actions_addopen.3 \
+ posix_spawn_file_actions_init.3 \
+ posix_spawnattr_getflags.3 \
+ posix_spawnattr_getpgroup.3 \
+ posix_spawnattr_getschedparam.3 \
+ posix_spawnattr_getschedpolicy.3 \
+ posix_spawnattr_init.3 \
+ posix_spawnattr_getsigdefault.3 \
+ posix_spawnattr_getsigmask.3 \
+ psignal.3 \
+ pwcache.3 \
+ raise.3 \
+ rand48.3 \
+ readpassphrase.3 \
+ rfork_thread.3 \
+ scandir.3 \
+ sem_destroy.3 \
+ sem_getvalue.3 \
+ sem_init.3 \
+ sem_open.3 \
+ sem_post.3 \
+ sem_timedwait.3 \
+ sem_wait.3 \
+ setjmp.3 \
+ setmode.3 \
+ setproctitle.3 \
+ siginterrupt.3 \
+ signal.3 \
+ sigsetops.3 \
+ sleep.3 \
+ statvfs.3 \
+ stringlist.3 \
+ strtofflags.3 \
+ sysconf.3 \
+ sysctl.3 \
+ syslog.3 \
+ tcgetpgrp.3 \
+ tcgetsid.3 \
+ tcsendbreak.3 \
+ tcsetattr.3 \
+ tcsetpgrp.3 \
+ tcsetsid.3 \
+ time.3 \
+ times.3 \
+ timezone.3 \
+ ttyname.3 \
+ tzset.3 \
+ ualarm.3 \
+ ucontext.3 \
+ ulimit.3 \
+ uname.3 \
+ unvis.3 \
+ usleep.3 \
+ utime.3 \
+ valloc.3 \
+ vis.3 \
+ wordexp.3
-MLINKS+=arc4random.3 arc4random_addrandom.3 arc4random.3 arc4random_stir.3 \
- arc4random.3 arc4random_buf.3 arc4random.3 arc4random_uniform.3
+MLINKS+=arc4random.3 arc4random_addrandom.3 \
+ arc4random.3 arc4random_stir.3 \
+ arc4random.3 arc4random_buf.3 \
+ arc4random.3 arc4random_uniform.3
MLINKS+=basename.3 basename_r.3
MLINKS+=ctermid.3 ctermid_r.3
MLINKS+=devname.3 devname_r.3
MLINKS+=devname.3 fdevname.3
MLINKS+=devname.3 fdevname_r.3
-MLINKS+=directory.3 closedir.3 directory.3 dirfd.3 directory.3 opendir.3 \
+MLINKS+=directory.3 closedir.3 \
+ directory.3 dirfd.3 \
+ directory.3 fdclosedir.3 \
directory.3 fdopendir.3 \
- directory.3 readdir.3 directory.3 readdir_r.3 directory.3 rewinddir.3 \
- directory.3 seekdir.3 directory.3 telldir.3
-MLINKS+=dlopen.3 fdlopen.3 dlopen.3 dlclose.3 dlopen.3 dlerror.3 \
- dlopen.3 dlfunc.3 dlopen.3 dlsym.3
-MLINKS+=err.3 err_set_exit.3 err.3 err_set_file.3 err.3 errc.3 err.3 errx.3 \
- err.3 verr.3 err.3 verrc.3 err.3 verrx.3 err.3 vwarn.3 err.3 vwarnc.3 \
- err.3 vwarnx.3 err.3 warnc.3 err.3 warn.3 err.3 warnx.3
-MLINKS+=exec.3 execl.3 exec.3 execle.3 exec.3 execlp.3 exec.3 exect.3 \
- exec.3 execv.3 exec.3 execvP.3 exec.3 execvp.3
-MLINKS+=fpclassify.3 finite.3 fpclassify.3 finitef.3 \
- fpclassify.3 isfinite.3 fpclassify.3 isinf.3 fpclassify.3 isnan.3 \
+ directory.3 opendir.3 \
+ directory.3 readdir.3 \
+ directory.3 readdir_r.3 \
+ directory.3 rewinddir.3 \
+ directory.3 seekdir.3 \
+ directory.3 telldir.3
+MLINKS+=dlopen.3 fdlopen.3 \
+ dlopen.3 dlclose.3 \
+ dlopen.3 dlerror.3 \
+ dlopen.3 dlfunc.3 \
+ dlopen.3 dlsym.3
+MLINKS+=err.3 err_set_exit.3 \
+ err.3 err_set_file.3 \
+ err.3 errc.3 \
+ err.3 errx.3 \
+ err.3 verr.3 \
+ err.3 verrc.3 \
+ err.3 verrx.3 \
+ err.3 vwarn.3 \
+ err.3 vwarnc.3 \
+ err.3 vwarnx.3 \
+ err.3 warnc.3 \
+ err.3 warn.3 \
+ err.3 warnx.3
+MLINKS+=exec.3 execl.3 \
+ exec.3 execle.3 \
+ exec.3 execlp.3 \
+ exec.3 exect.3 \
+ exec.3 execv.3 \
+ exec.3 execvP.3 \
+ exec.3 execvp.3
+MLINKS+=fpclassify.3 finite.3 \
+ fpclassify.3 finitef.3 \
+ fpclassify.3 isfinite.3 \
+ fpclassify.3 isinf.3 \
+ fpclassify.3 isnan.3 \
fpclassify.3 isnormal.3
-MLINKS+=frexp.3 frexpf.3 frexp.3 frexpl.3
-MLINKS+=fts.3 fts_children.3 fts.3 fts_close.3 fts.3 fts_open.3 \
- fts.3 fts_read.3 fts.3 fts_set.3 fts.3 fts_set_clientptr.3 \
- fts.3 fts_get_clientptr.3 fts.3 fts_get_stream.3
+MLINKS+=frexp.3 frexpf.3 \
+ frexp.3 frexpl.3
+MLINKS+=fts.3 fts_children.3 \
+ fts.3 fts_close.3 \
+ fts.3 fts_open.3 \
+ fts.3 fts_read.3 \
+ fts.3 fts_set.3 \
+ fts.3 fts_set_clientptr.3 \
+ fts.3 fts_get_clientptr.3 \
+ fts.3 fts_get_stream.3
MLINKS+=ftw.3 nftw.3
-MLINKS+=getcap.3 cgetcap.3 getcap.3 cgetclose.3 getcap.3 cgetent.3 \
- getcap.3 cgetfirst.3 getcap.3 cgetmatch.3 getcap.3 cgetnext.3 \
- getcap.3 cgetnum.3 getcap.3 cgetset.3 getcap.3 cgetstr.3 \
+MLINKS+=getcap.3 cgetcap.3 \
+ getcap.3 cgetclose.3 \
+ getcap.3 cgetent.3 \
+ getcap.3 cgetfirst.3 \
+ getcap.3 cgetmatch.3 \
+ getcap.3 cgetnext.3 \
+ getcap.3 cgetnum.3 \
+ getcap.3 cgetset.3 \
+ getcap.3 cgetstr.3 \
getcap.3 cgetustr.3
MLINKS+=getcwd.3 getwd.3
MLINKS+=getcontext.3 getcontextx.3
MLINKS+=getcontext.3 setcontext.3
MLINKS+=getdomainname.3 setdomainname.3
-MLINKS+=getfsent.3 endfsent.3 getfsent.3 getfsfile.3 getfsent.3 getfsspec.3 \
- getfsent.3 getfstype.3 getfsent.3 setfsent.3 \
- getfsent.3 setfstab.3 getfsent.3 getfstab.3
-MLINKS+=getgrent.3 endgrent.3 getgrent.3 getgrgid.3 getgrent.3 getgrnam.3 \
- getgrent.3 setgrent.3 getgrent.3 setgroupent.3 \
- getgrent.3 getgrent_r.3 getgrent.3 getgrnam_r.3 getgrent.3 getgrgid_r.3
+MLINKS+=getfsent.3 endfsent.3 \
+ getfsent.3 getfsfile.3 \
+ getfsent.3 getfsspec.3 \
+ getfsent.3 getfstype.3 \
+ getfsent.3 setfsent.3 \
+ getfsent.3 setfstab.3 \
+ getfsent.3 getfstab.3
+MLINKS+=getgrent.3 endgrent.3 \
+ getgrent.3 getgrgid.3 \
+ getgrent.3 getgrnam.3 \
+ getgrent.3 setgrent.3 \
+ getgrent.3 setgroupent.3 \
+ getgrent.3 getgrent_r.3 \
+ getgrent.3 getgrnam_r.3 \
+ getgrent.3 getgrgid_r.3
MLINKS+=gethostname.3 sethostname.3
-MLINKS+=getnetgrent.3 endnetgrent.3 getnetgrent.3 innetgr.3 \
+MLINKS+=getnetgrent.3 endnetgrent.3 \
+ getnetgrent.3 innetgr.3 \
getnetgrent.3 setnetgrent.3
MLINKS+=getprogname.3 setprogname.3
-MLINKS+=getpwent.3 endpwent.3 getpwent.3 getpwnam.3 getpwent.3 getpwuid.3 \
- getpwent.3 setpassent.3 getpwent.3 setpwent.3 getpwent.3 setpwfile.3 \
- getpwent.3 getpwent_r.3 getpwent.3 getpwnam_r.3 \
+MLINKS+=getpwent.3 endpwent.3 \
+ getpwent.3 getpwnam.3 \
+ getpwent.3 getpwuid.3 \
+ getpwent.3 setpassent.3 \
+ getpwent.3 setpwent.3 \
+ getpwent.3 setpwfile.3 \
+ getpwent.3 getpwent_r.3 \
+ getpwent.3 getpwnam_r.3 \
getpwent.3 getpwuid_r.3
-MLINKS+=getttyent.3 endttyent.3 getttyent.3 getttynam.3 \
- getttyent.3 isdialuptty.3 getttyent.3 isnettty.3 \
+MLINKS+=getttyent.3 endttyent.3 \
+ getttyent.3 getttynam.3 \
+ getttyent.3 isdialuptty.3 \
+ getttyent.3 isnettty.3 \
getttyent.3 setttyent.3
-MLINKS+=getusershell.3 endusershell.3 getusershell.3 setusershell.3
-MLINKS+=getutxent.3 endutxent.3 getutxent.3 getutxid.3 \
- getutxent.3 getutxline.3 getutxent.3 getutxuser.3 \
- getutxent.3 pututxline.3 getutxent.3 setutxdb.3 \
- getutxent.3 setutxent.3 getutxent.3 utmpx.3
+MLINKS+=getusershell.3 endusershell.3 \
+ getusershell.3 setusershell.3
+MLINKS+=getutxent.3 endutxent.3 \
+ getutxent.3 getutxid.3 \
+ getutxent.3 getutxline.3 \
+ getutxent.3 getutxuser.3 \
+ getutxent.3 pututxline.3 \
+ getutxent.3 setutxdb.3 \
+ getutxent.3 setutxent.3 \
+ getutxent.3 utmpx.3
MLINKS+=glob.3 globfree.3
-MLINKS+=isgreater.3 isgreaterequal.3 isgreater.3 isless.3 \
- isgreater.3 islessequal.3 isgreater.3 islessgreater.3 \
+MLINKS+=isgreater.3 isgreaterequal.3 \
+ isgreater.3 isless.3 \
+ isgreater.3 islessequal.3 \
+ isgreater.3 islessgreater.3 \
isgreater.3 isunordered.3
-MLINKS+=ldexp.3 ldexpf.3 ldexp.3 ldexpl.3
+MLINKS+=ldexp.3 ldexpf.3 \
+ ldexp.3 ldexpl.3
MLINKS+=makecontext.3 swapcontext.3
-MLINKS+=modf.3 modff.3 modf.3 modfl.3
+MLINKS+=modf.3 modff.3 \
+ modf.3 modfl.3
MLINKS+=popen.3 pclose.3
MLINKS+=posix_spawn.3 posix_spawnp.3 \
posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_addclose.3 \
@@ -164,35 +437,63 @@
posix_spawnattr_getsigdefault.3 posix_spawnattr_setsigdefault.3 \
posix_spawnattr_getsigmask.3 posix_spawnattr_setsigmask.3 \
posix_spawnattr_init.3 posix_spawnattr_destroy.3
-MLINKS+=psignal.3 strsignal.3 psignal.3 sys_siglist.3 psignal.3 sys_signame.3
-MLINKS+=pwcache.3 group_from_gid.3 pwcache.3 user_from_uid.3
-MLINKS+=rand48.3 _rand48.3 rand48.3 drand48.3 rand48.3 erand48.3 \
- rand48.3 jrand48.3 rand48.3 lcong48.3 rand48.3 lrand48.3 \
- rand48.3 mrand48.3 rand48.3 nrand48.3 rand48.3 seed48.3 \
+MLINKS+=psignal.3 strsignal.3 \
+ psignal.3 sys_siglist.3 \
+ psignal.3 sys_signame.3
+MLINKS+=pwcache.3 group_from_gid.3 \
+ pwcache.3 user_from_uid.3
+MLINKS+=rand48.3 _rand48.3 \
+ rand48.3 drand48.3 \
+ rand48.3 erand48.3 \
+ rand48.3 jrand48.3 \
+ rand48.3 lcong48.3 \
+ rand48.3 lrand48.3 \
+ rand48.3 mrand48.3 \
+ rand48.3 nrand48.3 \
+ rand48.3 seed48.3 \
rand48.3 srand48.3
MLINKS+=scandir.3 alphasort.3
-MLINKS+=sem_open.3 sem_close.3 sem_open.3 sem_unlink.3
+MLINKS+=sem_open.3 sem_close.3 \
+ sem_open.3 sem_unlink.3
MLINKS+=sem_wait.3 sem_trywait.3
-MLINKS+=setjmp.3 _longjmp.3 setjmp.3 _setjmp.3 setjmp.3 longjmp.3 \
- setjmp.3 longjmperr.3 setjmp.3 longjmperror.3 \
- setjmp.3 siglongjmp.3 setjmp.3 sigsetjmp.3
+MLINKS+=setjmp.3 _longjmp.3 \
+ setjmp.3 _setjmp.3 \
+ setjmp.3 longjmp.3 \
+ setjmp.3 longjmperr.3 \
+ setjmp.3 longjmperror.3 \
+ setjmp.3 siglongjmp.3 \
+ setjmp.3 sigsetjmp.3
MLINKS+=setmode.3 getmode.3
-MLINKS+=sigsetops.3 sigaddset.3 sigsetops.3 sigdelset.3 \
- sigsetops.3 sigemptyset.3 sigsetops.3 sigfillset.3 \
+MLINKS+=sigsetops.3 sigaddset.3 \
+ sigsetops.3 sigdelset.3 \
+ sigsetops.3 sigemptyset.3 \
+ sigsetops.3 sigfillset.3 \
sigsetops.3 sigismember.3
MLINKS+=statvfs.3 fstatvfs.3
-MLINKS+=stringlist.3 sl_add.3 stringlist.3 sl_find.3 \
- stringlist.3 sl_free.3 stringlist.3 sl_init.3
+MLINKS+=stringlist.3 sl_add.3 \
+ stringlist.3 sl_find.3 \
+ stringlist.3 sl_free.3 \
+ stringlist.3 sl_init.3
MLINKS+=strtofflags.3 fflagstostr.3
-MLINKS+=sysctl.3 sysctlbyname.3 sysctl.3 sysctlnametomib.3
-MLINKS+=syslog.3 closelog.3 syslog.3 openlog.3 syslog.3 setlogmask.3 \
+MLINKS+=sysctl.3 sysctlbyname.3 \
+ sysctl.3 sysctlnametomib.3
+MLINKS+=syslog.3 closelog.3 \
+ syslog.3 openlog.3 \
+ syslog.3 setlogmask.3 \
syslog.3 vsyslog.3
-MLINKS+=tcsendbreak.3 tcdrain.3 tcsendbreak.3 tcflow.3 tcsendbreak.3 tcflush.3
-MLINKS+=tcsetattr.3 cfgetispeed.3 tcsetattr.3 cfgetospeed.3 \
- tcsetattr.3 cfmakeraw.3 tcsetattr.3 cfmakesane.3 \
- tcsetattr.3 cfsetispeed.3 tcsetattr.3 cfsetospeed.3 \
- tcsetattr.3 cfsetspeed.3 tcsetattr.3 tcgetattr.3
-MLINKS+=ttyname.3 isatty.3 ttyname.3 ttyname_r.3
+MLINKS+=tcsendbreak.3 tcdrain.3 \
+ tcsendbreak.3 tcflow.3 \
+ tcsendbreak.3 tcflush.3
+MLINKS+=tcsetattr.3 cfgetispeed.3 \
+ tcsetattr.3 cfgetospeed.3 \
+ tcsetattr.3 cfmakeraw.3 \
+ tcsetattr.3 cfmakesane.3 \
+ tcsetattr.3 cfsetispeed.3 \
+ tcsetattr.3 cfsetospeed.3 \
+ tcsetattr.3 cfsetspeed.3 \
+ tcsetattr.3 tcgetattr.3
+MLINKS+=ttyname.3 isatty.3 \
+ ttyname.3 ttyname_r.3
MLINKS+=tzset.3 tzsetwall.3
MLINKS+=unvis.3 strunvis.3 \
unvis.3 strunvisx.3
@@ -211,4 +512,5 @@
vis.3 strvis.3 \
vis.3 strvisx.3 \
vis.3 svis.3
+
MLINKS+=wordexp.3 wordfree.3
Property changes on: trunk/lib/libc/gen/Makefile.inc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/Symbol.map
===================================================================
--- trunk/lib/libc/gen/Symbol.map 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/Symbol.map 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,6 +1,5 @@
-/*
- * $FreeBSD: src/lib/libc/gen/Symbol.map,v 1.6 2007/05/31 13:01:33 deischen Exp $
- * $MidnightBSD: src/lib/libc/gen/Symbol.map,v 1.7 2012/10/20 03:08:31 laffer1 Exp $
+/* $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/Symbol.map 277317 2015-01-18 11:54:20Z kib $
*/
FBSD_1.0 {
@@ -214,6 +213,7 @@
ldexp;
lockf;
lrand48;
+ modf;
mrand48;
nftw;
nice;
@@ -381,7 +381,11 @@
};
FBSD_1.3 {
- fdlopen;
+ clock_getcpuclockid;
+ dirfd;
+ dup3;
+ fdclosedir;
+ fdlopen;
__FreeBSD_libc_enter_restricted_mode;
getcontextx;
gid_from_group;
@@ -479,6 +483,7 @@
_rtld_atfork_post;
_rtld_error; /* for private use */
_rtld_get_stack_prot;
+ _rtld_is_dlopened;
_rtld_thread_init; /* for private use */
__elf_phdr_match_addr;
_err;
@@ -524,6 +529,8 @@
_libc_sem_post_compat;
_libc_sem_getvalue_compat;
+ __libc_tcdrain;
+
__elf_aux_vector;
__pthread_map_stacks_exec;
__fillcontextx;
Property changes on: trunk/lib/libc/gen/Symbol.map
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/__getosreldate.c
===================================================================
--- trunk/lib/libc/gen/__getosreldate.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/__getosreldate.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2007 Peter Wemm
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/__getosreldate.c 211416 2010-08-17 09:13:26Z kib $");
#include <sys/param.h>
#include <sys/sysctl.h>
Added: trunk/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c
===================================================================
--- trunk/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c (rev 0)
+++ trunk/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,46 @@
+/* $MidnightBSD$ */
+/*
+ * Copyright (c) 2014 The FreeBSD Foundation.
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice(s), this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified other than the possible
+ * addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice(s), this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c 277317 2015-01-18 11:54:20Z kib $");
+
+#include <pthread.h>
+#include "libc_private.h"
+
+int
+_pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
+ void *(calloc_cb)(size_t, size_t))
+{
+
+ return (0);
+}
Property changes on: trunk/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/gen/__xuname.c
===================================================================
--- trunk/lib/libc/gen/__xuname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/__xuname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
/*static char sccsid[] = "From: @(#)uname.c 8.1 (Berkeley) 1/4/94";*/
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/__xuname.c 184185 2008-10-22 21:56:57Z kib $");
#include <sys/param.h>
#include <sys/sysctl.h>
Modified: trunk/lib/libc/gen/_once_stub.c
===================================================================
--- trunk/lib/libc/gen/_once_stub.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/_once_stub.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
/*-
- * Copyright (c) 2009 Advanced Computing Technologies LLC
+ * Copyright (c) 2009 Hudson River Trading LLC
* Written by: John H. Baldwin <jhb at FreeBSD.org>
* All rights reserved.
*
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/_once_stub.c 283927 2015-06-02 19:20:39Z jhb $");
#include "namespace.h"
#include <pthread.h>
Modified: trunk/lib/libc/gen/_pthread_stubs.c
===================================================================
--- trunk/lib/libc/gen/_pthread_stubs.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/_pthread_stubs.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 2001 Daniel Eischen <deischen at FreeBSD.org>.
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/_pthread_stubs.c 320823 2017-07-09 03:57:24Z kib $");
#include <signal.h>
#include <pthread.h>
@@ -271,10 +272,11 @@
STUB_FUNC2(pthread_setcancelstate, PJT_SETCANCELSTATE, int, int, void *)
STUB_FUNC2(pthread_setcanceltype, PJT_SETCANCELTYPE, int, int, void *)
STUB_FUNC(pthread_testcancel, PJT_TESTCANCEL, void)
-STUB_FUNC1(__pthread_cleanup_pop_imp, PJT_CLEANUP_POP_IMP, int, int)
-STUB_FUNC2(__pthread_cleanup_push_imp, PJT_CLEANUP_PUSH_IMP, void, void*, void *);
-STUB_FUNC1(_pthread_cancel_enter, PJT_CANCEL_ENTER, int, int)
-STUB_FUNC1(_pthread_cancel_leave, PJT_CANCEL_LEAVE, int, int)
+STUB_FUNC1(__pthread_cleanup_pop_imp, PJT_CLEANUP_POP_IMP, void, int)
+STUB_FUNC3(__pthread_cleanup_push_imp, PJT_CLEANUP_PUSH_IMP, void, void *,
+ void *, void *);
+STUB_FUNC1(_pthread_cancel_enter, PJT_CANCEL_ENTER, void, int)
+STUB_FUNC1(_pthread_cancel_leave, PJT_CANCEL_LEAVE, void, int)
static int
stub_zero(void)
Modified: trunk/lib/libc/gen/_rand48.c
===================================================================
--- trunk/lib/libc/gen/_rand48.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/_rand48.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/_rand48.c 92986 2002-03-22 21:53:29Z obrien $");
#include "rand48.h"
Modified: trunk/lib/libc/gen/_spinlock_stub.c
===================================================================
--- trunk/lib/libc/gen/_spinlock_stub.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/_spinlock_stub.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1998 John Birrell <jb at cimlogic.com.au>.
* All rights reserved.
@@ -28,11 +29,12 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/_spinlock_stub.c 279518 2015-03-02 09:15:50Z kib $");
#include <stdio.h>
#include "spinlock.h"
+#include "libc_private.h"
long _atomic_lock_stub(volatile long *);
void _spinlock_stub(spinlock_t *);
@@ -39,18 +41,8 @@
void _spinunlock_stub(spinlock_t *);
void _spinlock_debug_stub(spinlock_t *, char *, int);
-/*
- * Declare weak definitions in case the application is not linked
- * with libpthread.
- */
__weak_reference(_atomic_lock_stub, _atomic_lock);
-__weak_reference(_spinlock_stub, _spinlock);
-__weak_reference(_spinunlock_stub, _spinunlock);
-__weak_reference(_spinlock_debug_stub, _spinlock_debug);
-/*
- * This function is a stub for the _atomic_lock function in libpthread.
- */
long
_atomic_lock_stub(volatile long *lck __unused)
{
@@ -57,27 +49,33 @@
return (0L);
}
+__weak_reference(_spinlock, _spinlock_debug);
+#pragma weak _spinlock
+void
+_spinlock(spinlock_t *lck)
+{
-/*
- * This function is a stub for the spinlock function in libpthread.
- */
+ ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinlock])
+ (lck);
+
+}
+
+#pragma weak _spinunlock
void
-_spinlock_stub(spinlock_t *lck __unused)
+_spinunlock(spinlock_t *lck)
{
+
+ ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinunlock])
+ (lck);
+
}
-/*
- * This function is a stub for the spinunlock function in libpthread.
- */
void
-_spinunlock_stub(spinlock_t *lck __unused)
+__libc_spinlock_stub(spinlock_t *lck __unused)
{
}
-/*
- * This function is a stub for the debug spinlock function in libpthread.
- */
void
-_spinlock_debug_stub(spinlock_t *lck __unused, char *fname __unused, int lineno __unused)
+__libc_spinunlock_stub(spinlock_t *lck __unused)
{
}
Modified: trunk/lib/libc/gen/_thread_init.c
===================================================================
--- trunk/lib/libc/gen/_thread_init.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/_thread_init.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 2001 Daniel Eischen <deischen at FreeBSD.org>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/_thread_init.c 218824 2011-02-18 21:44:53Z nwhitehorn $");
#include <sys/types.h>
Modified: trunk/lib/libc/gen/alarm.3
===================================================================
--- trunk/lib/libc/gen/alarm.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/alarm.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1980, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)alarm.3 8.2 (Berkeley) 4/19/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/alarm.3 207735 2010-05-06 22:49:54Z jilles $
.\"
.Dd April 19, 1994
.Dt ALARM 3
Property changes on: trunk/lib/libc/gen/alarm.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/alarm.c
===================================================================
--- trunk/lib/libc/gen/alarm.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/alarm.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)alarm.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/alarm.c 165903 2007-01-09 00:28:16Z imp $");
/*
* Backwards compatible alarm.
Modified: trunk/lib/libc/gen/arc4random.3
===================================================================
--- trunk/lib/libc/gen/arc4random.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/arc4random.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $OpenBSD: arc4random.3,v 1.2 1997/04/27 22:40:25 angelos Exp $
.\" Copyright 1997 Niels Provos <provos at physnet.uni-hamburg.de>
.\" All rights reserved.
@@ -28,7 +29,7 @@
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" Manual page, using -mandoc macros
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/arc4random.3 231564 2012-02-12 18:29:56Z ed $
.\"
.Dd April 15, 1997
.Dt ARC4RANDOM 3
@@ -44,12 +45,12 @@
.Lb libc
.Sh SYNOPSIS
.In stdlib.h
-.Ft u_int32_t
+.Ft uint32_t
.Fn arc4random "void"
.Ft void
.Fn arc4random_buf "void *buf" "size_t nbytes"
-.Ft u_int32_t
-.Fn arc4random_uniform "u_int32_t upper_bound"
+.Ft uint32_t
+.Fn arc4random_uniform "uint32_t upper_bound"
.Ft void
.Fn arc4random_stir "void"
.Ft void
Property changes on: trunk/lib/libc/gen/arc4random.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/arc4random.c
===================================================================
--- trunk/lib/libc/gen/arc4random.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/arc4random.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,6 @@
+/* $MidnightBSD$ */
+/* $OpenBSD: arc4random.c,v 1.24 2013/06/11 16:59:50 deraadt Exp $ */
+
/*
* Copyright (c) 1996, David Mazieres <dm at uun.org>
* Copyright (c) 2008, Damien Miller <djm at openbsd.org>
@@ -24,28 +27,32 @@
* which is a trade secret). The same algorithm is used as a stream
* cipher called "arcfour" in Tatu Ylonen's ssh package.
*
- * Here the stream cipher has been modified always to include the time
- * when initializing the state. That makes it impossible to
- * regenerate the same random sequence twice, so this can't be used
- * for encryption, but will generate good random numbers.
- *
* RC4 is a registered trademark of RSA Laboratories.
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/arc4random.c 315227 2017-03-14 06:12:51Z delphij $");
#include "namespace.h"
+#include <fcntl.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
#include <sys/time.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
#include <pthread.h>
#include "libc_private.h"
#include "un-namespace.h"
+#ifdef __GNUC__
+#define inline __inline
+#else /* !__GNUC__ */
+#define inline
+#endif /* !__GNUC__ */
+
struct arc4_stream {
u_int8_t i;
u_int8_t j;
@@ -55,24 +62,27 @@
static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER;
#define RANDOMDEV "/dev/random"
-#define KEYSIZE 128
-#define THREAD_LOCK() \
+#define KEYSIZE 128
+#define _ARC4_LOCK() \
do { \
if (__isthreaded) \
_pthread_mutex_lock(&arc4random_mtx); \
} while (0)
-#define THREAD_UNLOCK() \
+#define _ARC4_UNLOCK() \
do { \
if (__isthreaded) \
_pthread_mutex_unlock(&arc4random_mtx); \
} while (0)
+static int rs_initialized;
static struct arc4_stream rs;
-static int rs_initialized;
-static int rs_stired;
+static pid_t arc4_stir_pid;
static int arc4_count;
+extern int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
+ void *newp, size_t newlen);
+
static inline u_int8_t arc4_getbyte(void);
static void arc4_stir(void);
@@ -104,24 +114,54 @@
rs.j = rs.i;
}
+static size_t
+arc4_sysctl(u_char *buf, size_t size)
+{
+ int mib[2];
+ size_t len, done;
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_ARND;
+ done = 0;
+
+ do {
+ len = size;
+ if (__sysctl(mib, 2, buf, &len, NULL, 0) == -1)
+ return (done);
+ done += len;
+ buf += len;
+ size -= len;
+ } while (size > 0);
+
+ return (done);
+}
+
static void
arc4_stir(void)
{
- int done, fd, n;
+ int done, fd, i;
struct {
struct timeval tv;
- pid_t pid;
- u_int8_t rnd[KEYSIZE];
+ pid_t pid;
+ u_char rnd[KEYSIZE];
} rdat;
- fd = _open(RANDOMDEV, O_RDONLY, 0);
+ if (!rs_initialized) {
+ arc4_init();
+ rs_initialized = 1;
+ }
done = 0;
- if (fd >= 0) {
- if (_read(fd, &rdat, KEYSIZE) == KEYSIZE)
- done = 1;
- (void)_close(fd);
- }
+ if (arc4_sysctl((u_char *)&rdat, KEYSIZE) == KEYSIZE)
+ done = 1;
if (!done) {
+ fd = _open(RANDOMDEV, O_RDONLY | O_CLOEXEC, 0);
+ if (fd >= 0) {
+ if (_read(fd, &rdat, KEYSIZE) == KEYSIZE)
+ done = 1;
+ (void)_close(fd);
+ }
+ }
+ if (!done) {
(void)gettimeofday(&rdat.tv, NULL);
rdat.pid = getpid();
/* We'll just take whatever was on the stack too... */
@@ -130,17 +170,25 @@
arc4_addrandom((u_char *)&rdat, KEYSIZE);
/*
- * Throw away the first N bytes of output, as suggested in the
- * paper "Weaknesses in the Key Scheduling Algorithm of RC4"
- * by Fluher, Mantin, and Shamir. N=1024 is based on
- * suggestions in the paper "(Not So) Random Shuffles of RC4"
- * by Ilya Mironov.
+ * Discard early keystream, as per recommendations in:
+ * "(Not So) Random Shuffles of RC4" by Ilya Mironov.
*/
- for (n = 0; n < 1024; n++)
- (void) arc4_getbyte();
+ for (i = 0; i < 3072; i++)
+ (void)arc4_getbyte();
arc4_count = 1600000;
}
+static void
+arc4_stir_if_needed(void)
+{
+ pid_t pid = getpid();
+
+ if (arc4_count <= 0 || !rs_initialized || arc4_stir_pid != pid) {
+ arc4_stir_pid = pid;
+ arc4_stir();
+ }
+}
+
static inline u_int8_t
arc4_getbyte(void)
{
@@ -152,7 +200,6 @@
sj = rs.s[rs.j];
rs.s[rs.i] = sj;
rs.s[rs.j] = si;
-
return (rs.s[(si + sj) & 0xff]);
}
@@ -160,66 +207,41 @@
arc4_getword(void)
{
u_int32_t val;
-
val = arc4_getbyte() << 24;
val |= arc4_getbyte() << 16;
val |= arc4_getbyte() << 8;
val |= arc4_getbyte();
-
- return (val);
+ return val;
}
-static void
-arc4_check_init(void)
-{
- if (!rs_initialized) {
- arc4_init();
- rs_initialized = 1;
- }
-}
-
-static inline void
-arc4_check_stir(void)
-{
- if (!rs_stired || arc4_count <= 0) {
- arc4_stir();
- rs_stired = 1;
- }
-}
-
void
arc4random_stir(void)
{
- THREAD_LOCK();
- arc4_check_init();
+ _ARC4_LOCK();
arc4_stir();
- rs_stired = 1;
- THREAD_UNLOCK();
+ _ARC4_UNLOCK();
}
void
arc4random_addrandom(u_char *dat, int datlen)
{
- THREAD_LOCK();
- arc4_check_init();
- arc4_check_stir();
+ _ARC4_LOCK();
+ if (!rs_initialized)
+ arc4_stir();
arc4_addrandom(dat, datlen);
- THREAD_UNLOCK();
+ _ARC4_UNLOCK();
}
u_int32_t
arc4random(void)
{
- u_int32_t rnd;
-
- THREAD_LOCK();
- arc4_check_init();
- arc4_check_stir();
- rnd = arc4_getword();
+ u_int32_t val;
+ _ARC4_LOCK();
arc4_count -= 4;
- THREAD_UNLOCK();
-
- return (rnd);
+ arc4_stir_if_needed();
+ val = arc4_getword();
+ _ARC4_UNLOCK();
+ return val;
}
void
@@ -226,15 +248,14 @@
arc4random_buf(void *_buf, size_t n)
{
u_char *buf = (u_char *)_buf;
-
- THREAD_LOCK();
- arc4_check_init();
+ _ARC4_LOCK();
+ arc4_stir_if_needed();
while (n--) {
- arc4_check_stir();
+ if (--arc4_count <= 0)
+ arc4_stir();
buf[n] = arc4_getbyte();
- arc4_count--;
}
- THREAD_UNLOCK();
+ _ARC4_UNLOCK();
}
/*
@@ -253,20 +274,10 @@
u_int32_t r, min;
if (upper_bound < 2)
- return (0);
+ return 0;
-#if (ULONG_MAX > 0xffffffffUL)
- min = 0x100000000UL % upper_bound;
-#else
- /* Calculate (2**32 % upper_bound) avoiding 64-bit math */
- if (upper_bound > 0x80000000)
- min = 1 + ~upper_bound; /* 2**32 - upper_bound */
- else {
- /* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */
- min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound;
- }
-#endif
-
+ /* 2**32 % x == (2**32 - x) % x */
+ min = -upper_bound % upper_bound;
/*
* This could theoretically loop forever but each retry has
* p > 0.5 (worst case, usually far better) of selecting a
@@ -279,7 +290,7 @@
break;
}
- return (r % upper_bound);
+ return r % upper_bound;
}
#if 0
Modified: trunk/lib/libc/gen/assert.c
===================================================================
--- trunk/lib/libc/gen/assert.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/assert.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)assert.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/assert.c 165903 2007-01-09 00:28:16Z imp $");
#include <assert.h>
#include <stdio.h>
Added: trunk/lib/libc/gen/auxv.c
===================================================================
--- trunk/lib/libc/gen/auxv.c (rev 0)
+++ trunk/lib/libc/gen/auxv.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,187 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright 2010, 2012 Konstantin Belousov <kib at FreeBSD.ORG>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/auxv.c 239193 2012-08-11 12:07:24Z ed $");
+
+#include "namespace.h"
+#include <elf.h>
+#include <errno.h>
+#include <link.h>
+#include <pthread.h>
+#include <string.h>
+#include "un-namespace.h"
+#include "libc_private.h"
+
+extern char **environ;
+extern int _DYNAMIC;
+#pragma weak _DYNAMIC
+
+void *__elf_aux_vector;
+static pthread_once_t aux_vector_once = PTHREAD_ONCE_INIT;
+
+static void
+init_aux_vector_once(void)
+{
+ Elf_Addr *sp;
+
+ sp = (Elf_Addr *)environ;
+ while (*sp++ != 0)
+ ;
+ __elf_aux_vector = (Elf_Auxinfo *)sp;
+}
+
+void
+__init_elf_aux_vector(void)
+{
+
+ if (&_DYNAMIC != NULL)
+ return;
+ _once(&aux_vector_once, init_aux_vector_once);
+}
+
+static pthread_once_t aux_once = PTHREAD_ONCE_INIT;
+static int pagesize, osreldate, canary_len, ncpus, pagesizes_len;
+static char *canary, *pagesizes;
+static void *timekeep;
+
+static void
+init_aux(void)
+{
+ Elf_Auxinfo *aux;
+
+ for (aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) {
+ switch (aux->a_type) {
+ case AT_CANARY:
+ canary = (char *)(aux->a_un.a_ptr);
+ break;
+
+ case AT_CANARYLEN:
+ canary_len = aux->a_un.a_val;
+ break;
+
+ case AT_PAGESIZES:
+ pagesizes = (char *)(aux->a_un.a_ptr);
+ break;
+
+ case AT_PAGESIZESLEN:
+ pagesizes_len = aux->a_un.a_val;
+ break;
+
+ case AT_PAGESZ:
+ pagesize = aux->a_un.a_val;
+ break;
+
+ case AT_OSRELDATE:
+ osreldate = aux->a_un.a_val;
+ break;
+
+ case AT_NCPUS:
+ ncpus = aux->a_un.a_val;
+ break;
+
+ case AT_TIMEKEEP:
+ timekeep = aux->a_un.a_ptr;
+ break;
+ }
+ }
+}
+
+int
+_elf_aux_info(int aux, void *buf, int buflen)
+{
+ int res;
+
+ __init_elf_aux_vector();
+ if (__elf_aux_vector == NULL)
+ return (ENOSYS);
+ _once(&aux_once, init_aux);
+
+ switch (aux) {
+ case AT_CANARY:
+ if (canary != NULL && canary_len >= buflen) {
+ memcpy(buf, canary, buflen);
+ memset(canary, 0, canary_len);
+ canary = NULL;
+ res = 0;
+ } else
+ res = ENOENT;
+ break;
+ case AT_PAGESIZES:
+ if (pagesizes != NULL && pagesizes_len >= buflen) {
+ memcpy(buf, pagesizes, buflen);
+ res = 0;
+ } else
+ res = ENOENT;
+ break;
+
+ case AT_PAGESZ:
+ if (buflen == sizeof(int)) {
+ if (pagesize != 0) {
+ *(int *)buf = pagesize;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ case AT_OSRELDATE:
+ if (buflen == sizeof(int)) {
+ if (osreldate != 0) {
+ *(int *)buf = osreldate;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ case AT_NCPUS:
+ if (buflen == sizeof(int)) {
+ if (ncpus != 0) {
+ *(int *)buf = ncpus;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ case AT_TIMEKEEP:
+ if (buflen == sizeof(void *)) {
+ if (timekeep != NULL) {
+ *(void **)buf = timekeep;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ default:
+ res = ENOENT;
+ break;
+ }
+ return (res);
+}
Property changes on: trunk/lib/libc/gen/auxv.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/gen/basename.3
===================================================================
--- trunk/lib/libc/gen/basename.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/basename.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $OpenBSD: basename.3,v 1.20 2007/05/31 19:19:28 jmc Exp $
.\"
.\" Copyright (c) 1997 Todd C. Miller <Todd.Miller at courtesan.com>
@@ -14,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/basename.3 223216 2011-06-18 00:33:34Z delphij $
.\"
.Dd March 31, 2010
.Dt BASENAME 3
Property changes on: trunk/lib/libc/gen/basename.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/basename.c
===================================================================
--- trunk/lib/libc/gen/basename.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/basename.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $OpenBSD: basename.c,v 1.14 2005/08/08 08:05:33 espie Exp $ */
/*
@@ -17,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/basename.c 223216 2011-06-18 00:33:34Z delphij $");
#include <errno.h>
#include <libgen.h>
Added: trunk/lib/libc/gen/cap_rights_get.3
===================================================================
--- trunk/lib/libc/gen/cap_rights_get.3 (rev 0)
+++ trunk/lib/libc/gen/cap_rights_get.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,120 @@
+.\" $MidnightBSD$
+.\"
+.\" Copyright (c) 2013 The FreeBSD Foundation
+.\" All rights reserved.
+.\"
+.\" This documentation was written by Pawel Jakub Dawidek under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: stable/10/lib/libc/gen/cap_rights_get.3 280247 2015-03-19 11:24:07Z rwatson $
+.\"
+.Dd March 27, 2014
+.Dt CAP_RIGHTS_GET 3
+.Os
+.Sh NAME
+.Nm cap_rights_get
+.Nd obtain capability rights
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/capsicum.h
+.Ft int
+.Fn cap_rights_get "int fd" "cap_rights_t *rights"
+.Sh DESCRIPTION
+The
+.Nm cap_rights_get
+function allows to obtain current capability rights for the given descriptor.
+The function will fill the
+.Fa rights
+argument with all capability rights if they were not limited or capability
+rights configured during the last successful call of
+.Xr cap_rights_limit 2
+on the given descriptor.
+.Pp
+The
+.Fa rights
+argument can be inspected using
+.Xr cap_rights_init 3
+family of functions.
+.Pp
+The complete list of the capability rights can be found in the
+.Xr rights 4
+manual page.
+.Sh RETURN VALUES
+.Rv -std
+.Sh EXAMPLES
+The following example demonstrates how to limit file descriptor capability
+rights and how to obtain them.
+.Bd -literal
+cap_rights_t setrights, getrights;
+int fd;
+
+memset(&setrights, 0, sizeof(setrights));
+memset(&getrights, 0, sizeof(getrights));
+
+fd = open("/tmp/foo", O_RDONLY);
+if (fd < 0)
+ err(1, "open() failed");
+
+cap_rights_init(&setrights, CAP_FSTAT, CAP_READ);
+if (cap_rights_limit(fd, &setrights) < 0 && errno != ENOSYS)
+ err(1, "cap_rights_limit() failed");
+
+if (cap_rights_get(fd, &getrights) < 0 && errno != ENOSYS)
+ err(1, "cap_rights_get() failed");
+
+assert(memcmp(&setrights, &getrights, sizeof(setrights)) == 0);
+.Ed
+.Sh ERRORS
+.Fn cap_rights_get
+succeeds unless:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument is not a valid active descriptor.
+.It Bq Er EFAULT
+The
+.Fa rights
+argument points at an invalid address.
+.El
+.Sh SEE ALSO
+.Xr cap_rights_limit 2 ,
+.Xr cap_rights_init 3 ,
+.Xr errno 2 ,
+.Xr open 2 ,
+.Xr assert 3 ,
+.Xr err 3 ,
+.Xr memcmp 3 ,
+.Xr memset 3 ,
+.Xr capsicum 4 ,
+.Xr rights 4
+.Sh HISTORY
+Support for capabilities and capabilities mode was developed as part of the
+.Tn TrustedBSD
+Project.
+.Sh AUTHORS
+This function was created by
+.An Pawel Jakub Dawidek Aq pawel at dawidek.net
+under sponsorship of the FreeBSD Foundation.
Property changes on: trunk/lib/libc/gen/cap_rights_get.3
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/gen/cap_sandboxed.3
===================================================================
--- trunk/lib/libc/gen/cap_sandboxed.3 (rev 0)
+++ trunk/lib/libc/gen/cap_sandboxed.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,72 @@
+.\" $MidnightBSD$
+.\"
+.\" Copyright (c) 2012 The FreeBSD Foundation
+.\" All rights reserved.
+.\"
+.\" This documentation was written by Pawel Jakub Dawidek under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: stable/10/lib/libc/gen/cap_sandboxed.3 280247 2015-03-19 11:24:07Z rwatson $
+.\"
+.Dd March 27, 2014
+.Dt CAP_SANDBOXED 3
+.Os
+.Sh NAME
+.Nm cap_sandboxed
+.Nd Check if in a capability mode sandbox
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/capsicum.h
+.In stdbool.h
+.Ft bool
+.Fn cap_sandboxed "void"
+.Sh DESCRIPTION
+.Fn cap_sandboxed
+returns
+.Va true
+if the process is in a capability mode sandbox or
+.Va false
+if it is not.
+This function is a more handy alternative to the
+.Xr cap_getmode 2
+system call as it always succeeds, so there is no need for error checking.
+If the support for capability mode is not compiled into the kernel,
+.Fn cap_sandboxed
+will always return
+.Va false .
+.Sh RETURN VALUES
+Function
+.Fn cap_sandboxed
+is always successful and will return either
+.Va true
+or
+.Va false .
+.Sh SEE ALSO
+.Xr cap_enter 2 ,
+.Xr capsicum 4
+.Sh AUTHORS
+This function was implemented and manual page was written by
+.An Pawel Jakub Dawidek Aq pawel at dawidek.net
+under sponsorship of the FreeBSD Foundation.
Property changes on: trunk/lib/libc/gen/cap_sandboxed.3
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/gen/cap_sandboxed.c
===================================================================
--- trunk/lib/libc/gen/cap_sandboxed.c (rev 0)
+++ trunk/lib/libc/gen/cap_sandboxed.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,51 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2012 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/cap_sandboxed.c 280250 2015-03-19 12:32:48Z rwatson $");
+
+#include <sys/capsicum.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+
+bool
+cap_sandboxed(void)
+{
+ u_int mode;
+
+ if (cap_getmode(&mode) != 0) {
+ assert(errno == ENOSYS);
+ return (false);
+ }
+ assert(mode == 0 || mode == 1);
+ return (mode == 1);
+}
Property changes on: trunk/lib/libc/gen/cap_sandboxed.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/gen/check_utility_compat.3
===================================================================
--- trunk/lib/libc/gen/check_utility_compat.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/check_utility_compat.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright 2002 Massachusetts Institute of Technology
.\"
@@ -26,7 +27,7 @@
.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/check_utility_compat.3 206622 2010-04-14 19:08:06Z uqs $
.\"
.Dd October 27, 2002
.Dt CHECK_UTILITY_COMPAT 3
Property changes on: trunk/lib/libc/gen/check_utility_compat.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/check_utility_compat.c
===================================================================
--- trunk/lib/libc/gen/check_utility_compat.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/check_utility_compat.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright 2002 Massachusetts Institute of Technology
*
@@ -28,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/check_utility_compat.c 244568 2012-12-21 22:20:59Z delphij $");
/*
* I din't use "namespace.h" here because none of the relevant utilities
Modified: trunk/lib/libc/gen/clock.3
===================================================================
--- trunk/lib/libc/gen/clock.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/clock.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -30,7 +31,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)clock.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/clock.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 4, 1993
.Dt CLOCK 3
Property changes on: trunk/lib/libc/gen/clock.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/clock.c
===================================================================
--- trunk/lib/libc/gen/clock.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/clock.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)clock.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/clock.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/param.h>
#include <sys/time.h>
Added: trunk/lib/libc/gen/clock_getcpuclockid.3
===================================================================
--- trunk/lib/libc/gen/clock_getcpuclockid.3 (rev 0)
+++ trunk/lib/libc/gen/clock_getcpuclockid.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,96 @@
+.\" $MidnightBSD$
+.\" Copyright (c) 2012 David Xu <davidxu at FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" Portions of this text are reprinted and reproduced in electronic form
+.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
+.\" Portable Operating System Interface (POSIX), The Open Group Base
+.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
+.\" Electrical and Electronics Engineers, Inc and The Open Group. In the
+.\" event of any discrepancy between this version and the original IEEE and
+.\" The Open Group Standard, the original IEEE and The Open Group Standard is
+.\" the referee document. The original Standard can be obtained online at
+.\" http://www.opengroup.org/unix/online.html.
+.\"
+.\" $FreeBSD: stable/10/lib/libc/gen/clock_getcpuclockid.3 239499 2012-08-21 13:33:48Z joel $
+.\"
+.Dd August 21, 2012
+.Dt CLOCK_GETCPUCLOCKID 3
+.Os
+.Sh NAME
+.Nm clock_getcpuclockid
+.Nd access a process CPU-time clock
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In time.h
+.Ft int
+.Fn clock_getcpuclockid "pid_t pid" "clockid_t *clock_id"
+.Sh DESCRIPTION
+The
+.Fn clock_getcpuclockid
+returns the clock ID of the CPU-time clock of the process specified by
+.Fa pid .
+If the process described by
+.Fa pid
+exists and the calling process has permission, the clock ID of this
+clock will be returned in
+.Fa clock_id .
+.Pp
+If
+.Fa pid
+is zero, the
+.Fn clock_getcpuclockid
+function returns the clock ID of the CPU-time clock of the process
+making the call, in
+.Fa clock_id .
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn clock_getcpuclockid
+returns zero; otherwise, an error number is returned to indicate the
+error.
+.Sh ERRORS
+The clock_getcpuclockid() function will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The requesting process does not have permission to access the CPU-time
+clock for the process.
+.It Bq Er ESRCH
+No process can be found corresponding to the process specified by
+.Fa pid .
+.El
+.Sh SEE ALSO
+.Xr clock_gettime 2
+.Sh STANDARDS
+The
+.Fn clock_getcpuclockid
+function conform to
+.St -p1003.1-2001 .
+.Sh HISTORY
+The
+.Fn clock_getcpuclockid
+function first appeared in
+.Fx 10.0 .
+.Sh AUTHORS
+.An David Xu Aq davidxu at FreeBSD.org
Property changes on: trunk/lib/libc/gen/clock_getcpuclockid.3
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/gen/clock_getcpuclockid.c
===================================================================
--- trunk/lib/libc/gen/clock_getcpuclockid.c (rev 0)
+++ trunk/lib/libc/gen/clock_getcpuclockid.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,42 @@
+/* $MidnightBSD$ */
+/*
+ * Copyright (c) 2012 David Xu <davidxu at FreeBSD.org>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/clock_getcpuclockid.c 239485 2012-08-21 09:17:13Z davidxu $");
+
+#include <errno.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+int
+clock_getcpuclockid(pid_t pid, clockid_t *clock_id)
+{
+ if (clock_getcpuclockid2(pid, CPUCLOCK_WHICH_PID, clock_id))
+ return (errno);
+ return (0);
+}
Property changes on: trunk/lib/libc/gen/clock_getcpuclockid.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/gen/closedir.c
===================================================================
--- trunk/lib/libc/gen/closedir.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/closedir.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)closedir.c 8.1 (Berkeley) 6/10/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/closedir.c 254499 2013-08-18 20:11:34Z pjd $");
#include "namespace.h"
#include <sys/types.h>
@@ -42,6 +43,7 @@
#include "un-namespace.h"
#include "libc_private.h"
+#include "gen-private.h"
#include "telldir.h"
/*
@@ -48,14 +50,12 @@
* close a directory.
*/
int
-closedir(dirp)
- DIR *dirp;
+fdclosedir(DIR *dirp)
{
int fd;
if (__isthreaded)
_pthread_mutex_lock(&dirp->dd_lock);
- _seekdir(dirp, dirp->dd_rewind); /* free seekdir storage */
fd = dirp->dd_fd;
dirp->dd_fd = -1;
dirp->dd_loc = 0;
@@ -66,5 +66,12 @@
_pthread_mutex_destroy(&dirp->dd_lock);
}
free((void *)dirp);
- return(_close(fd));
+ return (fd);
}
+
+int
+closedir(DIR *dirp)
+{
+
+ return (_close(fdclosedir(dirp)));
+}
Modified: trunk/lib/libc/gen/confstr.3
===================================================================
--- trunk/lib/libc/gen/confstr.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/confstr.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)confstr.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/confstr.3 213573 2010-10-08 12:40:16Z uqs $
.\"
.Dd December 3, 2006
.Dt CONFSTR 3
Property changes on: trunk/lib/libc/gen/confstr.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/confstr.c
===================================================================
--- trunk/lib/libc/gen/confstr.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/confstr.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)confstr.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/confstr.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/param.h>
Modified: trunk/lib/libc/gen/crypt.c
===================================================================
--- trunk/lib/libc/gen/crypt.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/crypt.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989 The Regents of the University of California.
* All rights reserved.
@@ -35,7 +36,7 @@
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/crypt.c 165903 2007-01-09 00:28:16Z imp $");
#include <stdio.h>
#include <string.h>
Modified: trunk/lib/libc/gen/ctermid.3
===================================================================
--- trunk/lib/libc/gen/ctermid.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ctermid.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ctermid.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/ctermid.3 225897 2011-10-01 12:19:48Z ed $
.\"
-.Dd June 4, 1993
+.Dd October 1, 2011
.Dt CTERMID 3
.Os
.Sh NAME
@@ -77,7 +78,8 @@
.Dv NULL
is returned.
.Pp
-The current implementation simply returns
+If no suitable lookup of the controlling terminal name can be performed,
+this implementation returns
.Ql /dev/tty .
.Sh RETURN VALUES
Upon successful completion, a
Property changes on: trunk/lib/libc/gen/ctermid.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/ctermid.c
===================================================================
--- trunk/lib/libc/gen/ctermid.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ctermid.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,6 +1,7 @@
+/* $MidnightBSD$ */
/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 2011 Ed Schouten <ed at FreeBSD.org>
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,14 +11,11 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -27,31 +25,47 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ctermid.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/ctermid.c 225897 2011-10-01 12:19:48Z ed $");
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+
+#include <errno.h>
+#include <paths.h>
#include <stdio.h>
-#include <paths.h>
#include <string.h>
+#define LEN_PATH_DEV (sizeof(_PATH_DEV) - 1)
+
char *
ctermid(char *s)
{
- static char def[] = _PATH_TTY;
+ static char def[sizeof(_PATH_DEV) + SPECNAMELEN];
+ struct stat sb;
+ size_t dlen;
+ int sverrno;
- if (s) {
- bcopy(def, s, sizeof(_PATH_TTY));
- return(s);
- }
- return(def);
+ if (s == NULL) {
+ s = def;
+ dlen = sizeof(def) - LEN_PATH_DEV;
+ } else
+ dlen = L_ctermid - LEN_PATH_DEV;
+ strcpy(s, _PATH_TTY);
+
+ /* Attempt to perform a lookup of the actual TTY pathname. */
+ sverrno = errno;
+ if (stat(_PATH_TTY, &sb) == 0 && S_ISCHR(sb.st_mode))
+ (void)sysctlbyname("kern.devname", s + LEN_PATH_DEV,
+ &dlen, &sb.st_rdev, sizeof(sb.st_rdev));
+ errno = sverrno;
+ return (s);
}
-
char *
ctermid_r(char *s)
{
- return (s) ? ctermid(s) : NULL;
+
+ return (s != NULL ? ctermid(s) : NULL);
}
Modified: trunk/lib/libc/gen/daemon.3
===================================================================
--- trunk/lib/libc/gen/daemon.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/daemon.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)daemon.3 8.1 (Berkeley) 6/9/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/daemon.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 9, 1993
.Dt DAEMON 3
Property changes on: trunk/lib/libc/gen/daemon.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/daemon.c
===================================================================
--- trunk/lib/libc/gen/daemon.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/daemon.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/daemon.c 287480 2015-09-05 08:55:51Z kib $");
#include "namespace.h"
#include <errno.h>
@@ -41,10 +42,10 @@
#include <signal.h>
#include <unistd.h>
#include "un-namespace.h"
+#include "libc_private.h"
int
-daemon(nochdir, noclose)
- int nochdir, noclose;
+daemon(int nochdir, int noclose)
{
struct sigaction osa, sa;
int fd;
@@ -56,7 +57,7 @@
sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_IGN;
sa.sa_flags = 0;
- osa_ok = _sigaction(SIGHUP, &sa, &osa);
+ osa_ok = __libc_sigaction(SIGHUP, &sa, &osa);
switch (fork()) {
case -1:
@@ -74,7 +75,7 @@
newgrp = setsid();
oerrno = errno;
if (osa_ok != -1)
- _sigaction(SIGHUP, &osa, NULL);
+ __libc_sigaction(SIGHUP, &osa, NULL);
if (newgrp == -1) {
errno = oerrno;
Modified: trunk/lib/libc/gen/devname.3
===================================================================
--- trunk/lib/libc/gen/devname.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/devname.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)devname.3 8.2 (Berkeley) 4/29/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/devname.3 188497 2009-02-11 20:24:59Z ed $
.\"
.Dd February 22, 2005
.Dt DEVNAME 3
Property changes on: trunk/lib/libc/gen/devname.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/devname.c
===================================================================
--- trunk/lib/libc/gen/devname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/devname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,12 +32,13 @@
static char sccsid[] = "@(#)devname.c 8.2 (Berkeley) 4/29/95";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/devname.c 225847 2011-09-28 18:53:36Z ed $");
#include <sys/types.h>
#include <sys/sysctl.h>
#include <stdio.h>
+#include <stdint.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
@@ -60,8 +62,8 @@
}
/* Finally just format it */
- snprintf(buf, len, "#%c:%d:0x%x",
- S_ISCHR(type) ? 'C' : 'B', major(dev), minor(dev));
+ snprintf(buf, len, "#%c:%#jx",
+ S_ISCHR(type) ? 'C' : 'B', (uintmax_t)dev);
return (buf);
}
Modified: trunk/lib/libc/gen/directory.3
===================================================================
--- trunk/lib/libc/gen/directory.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/directory.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)directory.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/directory.3 305569 2016-09-07 21:09:44Z jilles $
.\"
-.Dd April 16, 2008
+.Dd August 31, 2016
.Dt DIRECTORY 3
.Os
.Sh NAME
@@ -40,6 +41,7 @@
.Nm seekdir ,
.Nm rewinddir ,
.Nm closedir ,
+.Nm fdclosedir ,
.Nm dirfd
.Nd directory operations
.Sh LIBRARY
@@ -64,9 +66,20 @@
.Ft int
.Fn closedir "DIR *dirp"
.Ft int
+.Fn fdclosedir "DIR *dirp"
+.Ft int
.Fn dirfd "DIR *dirp"
.Sh DESCRIPTION
+.Bf -symbolic
The
+.Fn readdir_r
+interface is deprecated
+because it cannot be used correctly unless
+.Brq Va NAME_MAX
+is a fixed value.
+.Ef
+.Pp
+The
.Fn opendir
function
opens the directory named by
@@ -120,7 +133,13 @@
.Fn readdir
function
returns a pointer to the next directory entry.
-It returns
+The directory entry remains valid until the next call to
+.Fn readdir
+or
+.Fn closedir
+on the same
+.Em directory stream .
+The function returns
.Dv NULL
upon reaching the end of the directory or on error.
In the event of an error,
@@ -137,6 +156,13 @@
but the caller must provide a directory
.Fa entry
buffer to store the results in.
+The buffer must be large enough for a
+.Vt struct dirent
+with a
+.Va d_name
+array with
+.Brq Va NAME_MAX
++ 1 elements.
If the read succeeds,
.Fa result
is pointed at the
@@ -153,7 +179,7 @@
The
.Fn telldir
function
-returns the current location associated with the named
+returns a token representing the current location associated with the named
.Em directory stream .
Values returned by
.Fn telldir
@@ -166,6 +192,10 @@
reopened, prior values returned by
.Fn telldir
will no longer be valid.
+Values returned by
+.Fn telldir
+are also invalidated by a call to
+.Fn rewinddir .
.Pp
The
.Fn seekdir
@@ -201,6 +231,13 @@
is set to indicate the error.
.Pp
The
+.Fn fdclosedir
+function is equivalent to the
+.Fn closedir
+function except that this function returns directory file descriptor instead of
+closing it.
+.Pp
+The
.Fn dirfd
function
returns the integer file descriptor associated with the named
@@ -245,3 +282,29 @@
.Fn fdopendir
function appeared in
.Fx 8.0 .
+.Fn fdclosedir
+function appeared in
+.Fx 10.0 .
+.Sh BUGS
+The behaviour of
+.Fn telldir
+and
+.Fn seekdir
+is likely to be wrong if there are parallel unlinks happening
+and the directory is larger than one page.
+There is code to ensure that a
+.Fn seekdir
+to the location given by a
+.Fn telldir
+immediately before the last
+.Fn readdir
+will always set the correct location to return the same value as that last
+.Fn readdir
+performed.
+This is enough for some applications which want to "push back the last entry read" E.g. Samba.
+Seeks back to any other location,
+other than the beginning of the directory,
+may result in unexpected behaviour if deletes are present.
+It is hoped that this situation will be resolved with changes to
+.Fn getdirentries
+and the VFS.
Property changes on: trunk/lib/libc/gen/directory.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/lib/libc/gen/dirfd.c
===================================================================
--- trunk/lib/libc/gen/dirfd.c (rev 0)
+++ trunk/lib/libc/gen/dirfd.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,46 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2011 Gleb Kurtsou <gleb at FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: stable/10/lib/libc/gen/dirfd.c 235649 2012-05-19 14:30:49Z gleb $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/dirfd.c 235649 2012-05-19 14:30:49Z gleb $");
+
+#include "namespace.h"
+#include <sys/param.h>
+
+#include <dirent.h>
+#include "un-namespace.h"
+
+#include "gen-private.h"
+
+int
+dirfd(DIR *dirp)
+{
+
+ return (_dirfd(dirp));
+}
Property changes on: trunk/lib/libc/gen/dirfd.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/gen/dirname.3
===================================================================
--- trunk/lib/libc/gen/dirname.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/dirname.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $OpenBSD: dirname.3,v 1.17 2007/05/31 19:19:28 jmc Exp $
.\"
.\" Copyright (c) 1997 Todd C. Miller <Todd.Miller at courtesan.com>
@@ -14,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/dirname.3 184578 2008-11-03 05:19:45Z delphij $
.\"
.Dd October 12, 2006
.Dt DIRNAME 3
Property changes on: trunk/lib/libc/gen/dirname.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/dirname.c
===================================================================
--- trunk/lib/libc/gen/dirname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/dirname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $OpenBSD: dirname.c,v 1.13 2005/08/08 08:05:33 espie Exp $ */
/*
@@ -17,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/dirname.c 184578 2008-11-03 05:19:45Z delphij $");
#include <errno.h>
#include <libgen.h>
Modified: trunk/lib/libc/gen/disklabel.c
===================================================================
--- trunk/lib/libc/gen/disklabel.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/disklabel.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1987, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 5/3/95";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/disklabel.c 279008 2015-02-19 16:17:44Z pfg $");
#include <sys/param.h>
#define DKTYPENAMES
@@ -85,10 +86,13 @@
cq++, cp++;
*cq = '\0';
- if (cgetstr(buf, "ty", &cq) > 0 && strcmp(cq, "removable") == 0)
- dp->d_flags |= D_REMOVABLE;
- else if (cq && strcmp(cq, "simulated") == 0)
- dp->d_flags |= D_RAMDISK;
+ if (cgetstr(buf, "ty", &cq) > 0) {
+ if (strcmp(cq, "removable") == 0)
+ dp->d_flags |= D_REMOVABLE;
+ else if (cq && strcmp(cq, "simulated") == 0)
+ dp->d_flags |= D_RAMDISK;
+ free(cq);
+ }
if (cgetcap(buf, "sf", ':') != NULL)
dp->d_flags |= D_BADSECT;
@@ -100,9 +104,10 @@
getnumdflt(dp->d_nsectors, "ns", 0);
getnumdflt(dp->d_ncylinders, "nc", 0);
- if (cgetstr(buf, "dt", &cq) > 0)
+ if (cgetstr(buf, "dt", &cq) > 0) {
dp->d_type = gettype(cq, dktypenames);
- else
+ free(cq);
+ } else
getnumdflt(dp->d_type, "dt", 0);
getnumdflt(dp->d_secpercyl, "sc", dp->d_nsectors * dp->d_ntracks);
getnumdflt(dp->d_secperunit, "su", dp->d_secpercyl * dp->d_ncylinders);
@@ -140,8 +145,11 @@
pp->p_frag = 8;
}
getnumdflt(pp->p_fstype, ptype, 0);
- if (pp->p_fstype == 0 && cgetstr(buf, ptype, &cq) > 0)
- pp->p_fstype = gettype(cq, fstypenames);
+ if (pp->p_fstype == 0)
+ if (cgetstr(buf, ptype, &cq) >= 0) {
+ pp->p_fstype = gettype(cq, fstypenames);
+ free(cq);
+ }
max = p;
}
}
Modified: trunk/lib/libc/gen/dl_iterate_phdr.3
===================================================================
--- trunk/lib/libc/gen/dl_iterate_phdr.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/dl_iterate_phdr.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2005 Mark Kettenis
.\" Copyright (c) 2012 Konstantin Belousov <kib at FreeBSD.org>
.\"
@@ -14,8 +15,8 @@
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" $OpenBSD: dl_iterate_phdr.3,v 1.3 2007/05/31 19:19:48 jmc Exp $
-.\" $FreeBSD$
-.Dd February 15, 2012
+.\" $FreeBSD: stable/10/lib/libc/gen/dl_iterate_phdr.3 274531 2014-11-14 21:52:31Z emaste $
+.Dd October 9, 2014
.Dt DL_ITERATE_PHDR 3
.Os
.Sh NAME
@@ -29,7 +30,7 @@
.Fn dl_iterate_phdr
from libc.
.Sh SYNOPSIS
-.Fd #include <link.h>
+.In link.h
.Ft int
.Fn dl_iterate_phdr "int (*callback)(struct dl_phdr_info *, size_t, void *)" "void *data"
.Sh DESCRIPTION
@@ -68,7 +69,7 @@
The base address at which the object is mapped into the address
space of the calling process.
.It Fa dlpi_name
-The name of the ELF object.
+The pathname of the ELF object.
.It Fa dlpi_phdr
A pointer to the object's program headers.
.It Fa dlpi_phnum
Property changes on: trunk/lib/libc/gen/dl_iterate_phdr.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/dladdr.3
===================================================================
--- trunk/lib/libc/gen/dladdr.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/dladdr.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright (c) 1998 John D. Polstra
.\" All rights reserved.
@@ -23,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/dladdr.3 206622 2010-04-14 19:08:06Z uqs $
.\"
.Dd February 5, 1998
.Dt DLADDR 3
Property changes on: trunk/lib/libc/gen/dladdr.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/dlfcn.c
===================================================================
--- trunk/lib/libc/gen/dlfcn.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/dlfcn.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1998 John D. Polstra
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/dlfcn.c 283597 2015-05-27 08:23:23Z kib $");
/*
* Linkage to services provided by the dynamic linker.
@@ -149,10 +150,8 @@
dl_init_phdr_info(void)
{
Elf_Auxinfo *auxp;
- size_t phent;
unsigned int i;
- phent = 0;
for (auxp = __elf_aux_vector; auxp->a_type != AT_NULL; auxp++) {
switch (auxp->a_type) {
case AT_BASE:
@@ -165,9 +164,6 @@
phdr_info.dlpi_phdr =
(const Elf_Phdr *)auxp->a_un.a_ptr;
break;
- case AT_PHENT:
- phent = auxp->a_un.a_val;
- break;
case AT_PHNUM:
phdr_info.dlpi_phnum = (Elf_Half)auxp->a_un.a_val;
break;
@@ -233,3 +229,10 @@
return (PROT_EXEC | PROT_READ | PROT_WRITE);
}
+#pragma weak _rtld_is_dlopened
+int
+_rtld_is_dlopened(void *arg)
+{
+
+ return (0);
+}
Modified: trunk/lib/libc/gen/dlinfo.3
===================================================================
--- trunk/lib/libc/gen/dlinfo.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/dlinfo.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright (c) 2003 Alexey Zelkin <phantom at FreeBSD.org>
.\" All rights reserved.
@@ -23,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/dlinfo.3 206622 2010-04-14 19:08:06Z uqs $
.\"
.Dd February 14, 2003
.Dt DLINFO 3
Property changes on: trunk/lib/libc/gen/dlinfo.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/dllockinit.3
===================================================================
--- trunk/lib/libc/gen/dllockinit.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/dllockinit.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright (c) 1999, 2000 John D. Polstra
.\" All rights reserved.
@@ -23,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/dllockinit.3 206622 2010-04-14 19:08:06Z uqs $
.\"
.Dd July 5, 2000
.Dt DLLOCKINIT 3
Property changes on: trunk/lib/libc/gen/dllockinit.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/dlopen.3
===================================================================
--- trunk/lib/libc/gen/dlopen.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/dlopen.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" This source code is a product of Sun Microsystems, Inc. and is provided
.\" for unrestricted use provided that this legend is included on all tape
.\" media and as a part of the software program in whole or part. Users
@@ -30,7 +31,7 @@
.\" Copyright (c) 1991 Sun Microsystems, Inc.
.\"
.\" @(#) dlopen.3 1.6 90/01/31 SMI
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/dlopen.3 229768 2012-01-07 10:33:01Z kib $
.\"
.Dd December 21, 2011
.Dt DLOPEN 3
Property changes on: trunk/lib/libc/gen/dlopen.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/drand48.c
===================================================================
--- trunk/lib/libc/gen/drand48.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/drand48.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/drand48.c 92986 2002-03-22 21:53:29Z obrien $");
#include "rand48.h"
Added: trunk/lib/libc/gen/dup3.3
===================================================================
--- trunk/lib/libc/gen/dup3.3 (rev 0)
+++ trunk/lib/libc/gen/dup3.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,117 @@
+.\" $MidnightBSD$
+.\" Copyright (c) 2013 Jilles Tjoelker
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: stable/10/lib/libc/gen/dup3.3 254488 2013-08-18 13:25:18Z jilles $
+.\"
+.Dd August 16, 2013
+.Dt DUP3 3
+.Os
+.Sh NAME
+.Nm dup3
+.Nd duplicate an existing file descriptor
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In fcntl.h
+.In unistd.h
+.Ft int
+.Fn dup3 "int oldd" "int newd" "int flags"
+.Sh DESCRIPTION
+The
+.Fn dup3
+function
+duplicates an existing object descriptor
+while allowing the value of the new descriptor to be specified.
+.Pp
+The close-on-exec flag on the new file descriptor is determined by the
+.Dv O_CLOEXEC
+bit in
+.Fa flags .
+.Pp
+If
+.Fa oldd
+\*(Ne
+.Fa newd
+and
+.Fa flags
+== 0,
+the behavior is identical to
+.Li dup2(oldd, newd) .
+.Pp
+If
+.Fa oldd
+==
+.Fa newd ,
+then
+.Fn dup3
+fails, unlike
+.Xr dup2 2 .
+.Sh RETURN VALUES
+The value -1 is returned if an error occurs.
+The external variable
+.Va errno
+indicates the cause of the error.
+.Sh ERRORS
+The
+.Fn dup3
+function fails if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa oldd
+argument is not a valid active descriptor or the
+.Fa newd
+argument is negative or exceeds the maximum allowable descriptor number
+.It Bq Er EINVAL
+The
+.Fa oldd
+argument is equal to the
+.Fa newd
+argument.
+.It Bq Er EINVAL
+The
+.Fa flags
+argument has bits set other than
+.Dv O_CLOEXEC .
+.El
+.Sh SEE ALSO
+.Xr accept 2 ,
+.Xr close 2 ,
+.Xr dup2 2 ,
+.Xr fcntl 2 ,
+.Xr getdtablesize 2 ,
+.Xr open 2 ,
+.Xr pipe 2 ,
+.Xr socket 2 ,
+.Xr socketpair 2
+.Sh STANDARDS
+The
+.Fn dup3
+function does not conform to any standard.
+.Sh HISTORY
+The
+.Fn dup3
+function appeared in
+.Fx 10.0 .
Property changes on: trunk/lib/libc/gen/dup3.3
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/gen/dup3.c
===================================================================
--- trunk/lib/libc/gen/dup3.c (rev 0)
+++ trunk/lib/libc/gen/dup3.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,60 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2012 Jukka A. Ukkonen
+ * All rights reserved.
+ *
+ * This software was developed by Jukka Ukkonen for FreeBSD.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/dup3.c 254409 2013-08-16 13:10:30Z jilles $");
+
+#include "namespace.h"
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "un-namespace.h"
+
+int
+__dup3(int oldfd, int newfd, int flags)
+{
+ int how;
+
+ if (oldfd == newfd) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ if (flags & ~O_CLOEXEC) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ how = (flags & O_CLOEXEC) ? F_DUP2FD_CLOEXEC : F_DUP2FD;
+
+ return (_fcntl(oldfd, how, newfd));
+}
+
+__weak_reference(__dup3, dup3);
+__weak_reference(__dup3, _dup3);
Property changes on: trunk/lib/libc/gen/dup3.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/gen/elf_utils.c
===================================================================
--- trunk/lib/libc/gen/elf_utils.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/elf_utils.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 2010 Konstantin Belousov <kib at freebsd.org>
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/elf_utils.c 296732 2016-03-12 17:33:40Z kib $
*/
#include <sys/types.h>
@@ -32,6 +33,7 @@
#include <sys/sysctl.h>
#include <link.h>
#include <stddef.h>
+#include "libc_private.h"
int
__elf_phdr_match_addr(struct dl_phdr_info *phdr_info, void *addr)
@@ -51,9 +53,8 @@
return (i != phdr_info->dlpi_phnum);
}
-#pragma weak __pthread_map_stacks_exec
void
-__pthread_map_stacks_exec(void)
+__libc_map_stacks_exec(void)
{
int mib[2];
struct rlimit rlim;
@@ -72,3 +73,10 @@
rlim.rlim_cur, _rtld_get_stack_prot());
}
+#pragma weak __pthread_map_stacks_exec
+void
+__pthread_map_stacks_exec(void)
+{
+
+ ((void (*)(void))__libc_interposing[INTERPOS_map_stacks_exec])();
+}
Modified: trunk/lib/libc/gen/erand48.c
===================================================================
--- trunk/lib/libc/gen/erand48.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/erand48.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/erand48.c 92986 2002-03-22 21:53:29Z obrien $");
#include "rand48.h"
Modified: trunk/lib/libc/gen/err.3
===================================================================
--- trunk/lib/libc/gen/err.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/err.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)err.3 8.1 (Berkeley) 6/9/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/err.3 234714 2012-04-26 19:21:58Z eadler $
.\"
.Dd March 29, 2012
.Dt ERR 3
Property changes on: trunk/lib/libc/gen/err.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/err.c
===================================================================
--- trunk/lib/libc/gen/err.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/err.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/err.c 321124 2017-07-18 08:50:36Z ngie $");
#include "namespace.h"
#include <err.h>
@@ -99,8 +100,8 @@
void
verrc(int eval, int code, const char *fmt, va_list ap)
{
- if (err_file == 0)
- err_set_file((FILE *)0);
+ if (err_file == NULL)
+ err_set_file(NULL);
fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL) {
vfprintf(err_file, fmt, ap);
@@ -124,8 +125,8 @@
void
verrx(int eval, const char *fmt, va_list ap)
{
- if (err_file == 0)
- err_set_file((FILE *)0);
+ if (err_file == NULL)
+ err_set_file(NULL);
fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL)
vfprintf(err_file, fmt, ap);
@@ -164,8 +165,8 @@
void
vwarnc(int code, const char *fmt, va_list ap)
{
- if (err_file == 0)
- err_set_file((FILE *)0);
+ if (err_file == NULL)
+ err_set_file(NULL);
fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL) {
vfprintf(err_file, fmt, ap);
@@ -186,8 +187,8 @@
void
vwarnx(const char *fmt, va_list ap)
{
- if (err_file == 0)
- err_set_file((FILE *)0);
+ if (err_file == NULL)
+ err_set_file(NULL);
fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL)
vfprintf(err_file, fmt, ap);
Modified: trunk/lib/libc/gen/errlst.c
===================================================================
--- trunk/lib/libc/gen/errlst.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/errlst.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1982, 1985, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,9 +32,10 @@
static char sccsid[] = "@(#)errlst.c 8.2 (Berkeley) 11/16/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/errlst.c 255108 2013-08-31 22:32:42Z jilles $");
#include <stdio.h>
+#include "errlst.h"
const char *const sys_errlist[] = {
"No error: 0", /* 0 - ENOERROR */
@@ -152,5 +154,12 @@
"Protocol error", /* 92 - EPROTO */
"Capabilities insufficient", /* 93 - ENOTCAPABLE */
"Not permitted in capability mode", /* 94 - ECAPMODE */
+ "State not recoverable", /* 95 - ENOTRECOVERABLE */
+ "Previous owner died", /* 96 - EOWNERDEAD */
};
const int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]);
+
+#ifdef PIC
+__strong_reference(sys_errlist, __hidden_sys_errlist);
+__strong_reference(sys_nerr, __hidden_sys_nerr);
+#endif
Modified: trunk/lib/libc/gen/errno.c
===================================================================
--- trunk/lib/libc/gen/errno.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/errno.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2002 Peter Wemm <peter at freebsd.org>
* All rights reserved.
@@ -25,6 +26,6 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/errno.c 104704 2002-10-09 08:04:24Z peter $");
int errno;
Modified: trunk/lib/libc/gen/exec.3
===================================================================
--- trunk/lib/libc/gen/exec.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/exec.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)exec.3 8.3 (Berkeley) 1/24/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/exec.3 292511 2015-12-20 13:41:06Z jilles $
.\"
-.Dd January 24, 1994
+.Dd December 12, 2015
.Dt EXEC 3
.Os
.Sh NAME
@@ -223,7 +224,7 @@
.Fn execvp
functions was
.Dq Pa :/bin:/usr/bin .
-This was changed to place the current directory last to enhance system
+This was changed to remove the current directory to enhance system
security.
.Pp
The behavior of
Property changes on: trunk/lib/libc/gen/exec.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/exec.c
===================================================================
--- trunk/lib/libc/gen/exec.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/exec.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/exec.c 229403 2012-01-03 18:51:58Z ed $");
#include "namespace.h"
#include <sys/param.h>
@@ -159,7 +160,7 @@
eacces = 0;
/* If it's an absolute or relative path name, it's easy. */
- if (index(name, '/')) {
+ if (strchr(name, '/')) {
bp = name;
cur = NULL;
goto retry;
Modified: trunk/lib/libc/gen/fdevname.c
===================================================================
--- trunk/lib/libc/gen/fdevname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fdevname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2009 Ed Schouten <ed at FreeBSD.org>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/fdevname.c 200133 2009-12-05 18:51:44Z ed $");
#include "namespace.h"
#include <sys/param.h>
Modified: trunk/lib/libc/gen/feature_present.3
===================================================================
--- trunk/lib/libc/gen/feature_present.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/feature_present.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 Yahoo!, Inc.
.\" All rights reserved.
.\" Written by: John Baldwin <jhb at FreeBSD.org>
@@ -26,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/feature_present.3 222286 2011-05-25 14:13:53Z ru $
.\"
.Dd January 8, 2008
.Dt FEATURE_PRESENT 3
Property changes on: trunk/lib/libc/gen/feature_present.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/feature_present.c
===================================================================
--- trunk/lib/libc/gen/feature_present.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/feature_present.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Yahoo!, Inc.
* All rights reserved.
@@ -29,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/feature_present.c 175220 2008-01-10 22:11:21Z jhb $");
#include <sys/types.h>
#include <sys/sysctl.h>
Modified: trunk/lib/libc/gen/fmtcheck.3
===================================================================
--- trunk/lib/libc/gen/fmtcheck.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fmtcheck.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
@@ -24,7 +25,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/fmtcheck.3 208027 2010-05-13 12:07:55Z uqs $
.Dd October 16, 2002
.Dt FMTCHECK 3
.Os
Property changes on: trunk/lib/libc/gen/fmtcheck.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/fmtcheck.c
===================================================================
--- trunk/lib/libc/gen/fmtcheck.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fmtcheck.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $NetBSD: fmtcheck.c,v 1.8 2008/04/28 20:22:59 martin Exp $ */
/*-
@@ -29,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/fmtcheck.c 194800 2009-06-23 23:52:12Z delphij $");
#include <stdio.h>
#include <string.h>
Modified: trunk/lib/libc/gen/fmtmsg.3
===================================================================
--- trunk/lib/libc/gen/fmtmsg.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fmtmsg.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright (c) 2002 Mike Barcroft <mike at FreeBSD.org>
.\" All rights reserved.
@@ -23,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/fmtmsg.3 107619 2002-12-04 18:57:46Z ru $
.\"
.Dd August 5, 2002
.Dt FMTMSG 3
Property changes on: trunk/lib/libc/gen/fmtmsg.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/fmtmsg.c
===================================================================
--- trunk/lib/libc/gen/fmtmsg.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fmtmsg.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2002 Mike Barcroft <mike at FreeBSD.org>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/fmtmsg.c 244092 2012-12-10 17:56:51Z jilles $");
#include <fmtmsg.h>
#include <stdio.h>
@@ -45,10 +46,6 @@
*sevinfo(int);
static int validmsgverb(const char *);
-static const char *validlist[] = {
- "label", "severity", "text", "action", "tag", NULL
-};
-
int
fmtmsg(long class, const char *label, int sev, const char *text,
const char *action, const char *tag)
@@ -87,7 +84,7 @@
if (output == NULL)
return (MM_NOCON);
if (*output != '\0') {
- if ((fp = fopen("/dev/console", "a")) == NULL) {
+ if ((fp = fopen("/dev/console", "ae")) == NULL) {
free(output);
return (MM_NOCON);
}
@@ -205,14 +202,18 @@
static int
validmsgverb(const char *msgverb)
{
+ const char *validlist = "label\0severity\0text\0action\0tag\0";
char *msgcomp;
- int i, equality;
+ size_t len1, len2;
+ const char *p;
+ int equality;
equality = 0;
while ((msgcomp = nextcomp(msgverb)) != NULL) {
equality--;
- for (i = 0; validlist[i] != NULL; i++) {
- if (strcmp(msgcomp, validlist[i]) == 0)
+ len1 = strlen(msgcomp);
+ for (p = validlist; (len2 = strlen(p)) != 0; p += len2 + 1) {
+ if (len1 == len2 && memcmp(msgcomp, p, len1) == 0)
equality++;
}
}
Modified: trunk/lib/libc/gen/fnmatch.3
===================================================================
--- trunk/lib/libc/gen/fnmatch.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fnmatch.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -28,7 +29,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)fnmatch.3 8.3 (Berkeley) 4/28/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/fnmatch.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd July 18, 2004
.Dt FNMATCH 3
Property changes on: trunk/lib/libc/gen/fnmatch.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/fnmatch.c
===================================================================
--- trunk/lib/libc/gen/fnmatch.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fnmatch.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -39,7 +40,7 @@
static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/fnmatch.c 324505 2017-10-10 21:04:40Z pfg $");
/*
* Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
@@ -91,11 +92,14 @@
int flags;
mbstate_t patmbs, strmbs;
{
+ const char *bt_pattern, *bt_string;
+ mbstate_t bt_patmbs, bt_strmbs;
char *newp;
char c;
wchar_t pc, sc;
size_t pclen, sclen;
+ bt_pattern = bt_string = NULL;
for (;;) {
pclen = mbrtowc(&pc, pattern, MB_LEN_MAX, &patmbs);
if (pclen == (size_t)-1 || pclen == (size_t)-2)
@@ -111,16 +115,18 @@
case EOS:
if ((flags & FNM_LEADING_DIR) && sc == '/')
return (0);
- return (sc == EOS ? 0 : FNM_NOMATCH);
+ if (sc == EOS)
+ return (0);
+ goto backtrack;
case '?':
if (sc == EOS)
return (FNM_NOMATCH);
if (sc == '/' && (flags & FNM_PATHNAME))
- return (FNM_NOMATCH);
+ goto backtrack;
if (sc == '.' && (flags & FNM_PERIOD) &&
(string == stringstart ||
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
+ goto backtrack;
string += sclen;
break;
case '*':
@@ -132,7 +138,7 @@
if (sc == '.' && (flags & FNM_PERIOD) &&
(string == stringstart ||
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
+ goto backtrack;
/* Optimize for pattern with * at end or before /. */
if (c == EOS)
@@ -148,33 +154,24 @@
break;
}
- /* General case, use recursion. */
- while (sc != EOS) {
- if (!fnmatch1(pattern, string, stringstart,
- flags, patmbs, strmbs))
- return (0);
- sclen = mbrtowc(&sc, string, MB_LEN_MAX,
- &strmbs);
- if (sclen == (size_t)-1 ||
- sclen == (size_t)-2) {
- sc = (unsigned char)*string;
- sclen = 1;
- memset(&strmbs, 0, sizeof(strmbs));
- }
- if (sc == '/' && flags & FNM_PATHNAME)
- break;
- string += sclen;
- }
- return (FNM_NOMATCH);
+ /*
+ * First try the shortest match for the '*' that
+ * could work. We can forget any earlier '*' since
+ * there is no way having it match more characters
+ * can help us, given that we are already here.
+ */
+ bt_pattern = pattern, bt_patmbs = patmbs;
+ bt_string = string, bt_strmbs = strmbs;
+ break;
case '[':
if (sc == EOS)
return (FNM_NOMATCH);
if (sc == '/' && (flags & FNM_PATHNAME))
- return (FNM_NOMATCH);
+ goto backtrack;
if (sc == '.' && (flags & FNM_PERIOD) &&
(string == stringstart ||
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
+ goto backtrack;
switch (rangematch(pattern, sc, flags, &newp,
&patmbs)) {
@@ -184,7 +181,7 @@
pattern = newp;
break;
case RANGE_NOMATCH:
- return (FNM_NOMATCH);
+ goto backtrack;
}
string += sclen;
break;
@@ -192,23 +189,47 @@
if (!(flags & FNM_NOESCAPE)) {
pclen = mbrtowc(&pc, pattern, MB_LEN_MAX,
&patmbs);
- if (pclen == (size_t)-1 || pclen == (size_t)-2)
+ if (pclen == 0 || pclen == (size_t)-1 ||
+ pclen == (size_t)-2)
return (FNM_NOMATCH);
- if (pclen == 0)
- pc = '\\';
pattern += pclen;
}
/* FALLTHROUGH */
default:
norm:
+ string += sclen;
if (pc == sc)
;
else if ((flags & FNM_CASEFOLD) &&
(towlower(pc) == towlower(sc)))
;
- else
- return (FNM_NOMATCH);
- string += sclen;
+ else {
+ backtrack:
+ /*
+ * If we have a mismatch (other than hitting
+ * the end of the string), go back to the last
+ * '*' seen and have it match one additional
+ * character.
+ */
+ if (bt_pattern == NULL)
+ return (FNM_NOMATCH);
+ sclen = mbrtowc(&sc, bt_string, MB_LEN_MAX,
+ &bt_strmbs);
+ if (sclen == (size_t)-1 ||
+ sclen == (size_t)-2) {
+ sc = (unsigned char)*bt_string;
+ sclen = 1;
+ memset(&bt_strmbs, 0,
+ sizeof(bt_strmbs));
+ }
+ if (sc == EOS)
+ return (FNM_NOMATCH);
+ if (sc == '/' && flags & FNM_PATHNAME)
+ return (FNM_NOMATCH);
+ bt_string += sclen;
+ pattern = bt_pattern, patmbs = bt_patmbs;
+ string = bt_string, strmbs = bt_strmbs;
+ }
break;
}
}
@@ -285,8 +306,8 @@
if (table->__collate_load_error ?
c <= test && test <= c2 :
- __collate_range_cmp(table, c, test) <= 0
- && __collate_range_cmp(table, test, c2) <= 0
+ __wcollate_range_cmp(c, test) <= 0
+ && __wcollate_range_cmp(test, c2) <= 0
)
ok = 1;
} else if (c == test)
Modified: trunk/lib/libc/gen/fpclassify.3
===================================================================
--- trunk/lib/libc/gen/fpclassify.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fpclassify.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2003 Mike Barcroft <mike at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -22,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/fpclassify.3 140890 2005-01-27 05:46:17Z das $
.\"
.Dd January 26, 2005
.Dt FPCLASSIFY 3
Property changes on: trunk/lib/libc/gen/fpclassify.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/fpclassify.c
===================================================================
--- trunk/lib/libc/gen/fpclassify.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fpclassify.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Mike Barcroft <mike at FreeBSD.org>
* Copyright (c) 2002, 2003 David Schultz <das at FreeBSD.ORG>
@@ -24,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/fpclassify.c 141379 2005-02-06 03:23:31Z das $
*/
#include <sys/endian.h>
Modified: trunk/lib/libc/gen/frexp.3
===================================================================
--- trunk/lib/libc/gen/frexp.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/frexp.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -30,7 +31,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)frexp.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/frexp.3 206616 2010-04-14 18:29:34Z uqs $
.\"
.Dd March 4, 2005
.Dt FREXP 3
Property changes on: trunk/lib/libc/gen/frexp.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/frexp.c
===================================================================
--- trunk/lib/libc/gen/frexp.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/frexp.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/frexp.c 132366 2004-07-18 21:23:39Z das $
*/
#include <math.h>
Modified: trunk/lib/libc/gen/fstab.c
===================================================================
--- trunk/lib/libc/gen/fstab.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fstab.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1980, 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)fstab.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/fstab.c 243865 2012-12-04 16:54:43Z jilles $");
#include "namespace.h"
#include <sys/param.h>
@@ -39,7 +40,6 @@
#include <sys/stat.h>
#include <errno.h>
-#include <fcntl.h>
#include <fstab.h>
#include <paths.h>
#include <stdio.h>
@@ -46,6 +46,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <vis.h>
#include "un-namespace.h"
static FILE *_fs_fp;
@@ -76,7 +77,7 @@
}
const char *
-getfstab (void)
+getfstab(void)
{
if (fsp_set)
@@ -86,7 +87,7 @@
}
static void
-fixfsfile()
+fixfsfile(void)
{
static char buf[sizeof(_PATH_DEV) + MNAMELEN];
struct stat sb;
@@ -108,7 +109,7 @@
}
static int
-fstabscan()
+fstabscan(void)
{
char *cp, *p;
#define MAXLINELENGTH 1024
@@ -119,7 +120,7 @@
for (;;) {
if (!(p = fgets(line, sizeof(line), _fs_fp)))
- return(0);
+ return (0);
/* OLD_STYLE_FSTAB */
++LineNo;
if (*line == '#' || *line == '\n')
@@ -140,7 +141,7 @@
_fs_fstab.fs_freq = atoi(cp);
if ((cp = strsep(&p, ":\n")) != NULL) {
_fs_fstab.fs_passno = atoi(cp);
- return(1);
+ return (1);
}
}
}
@@ -150,11 +151,17 @@
while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0')
;
_fs_fstab.fs_spec = cp;
- if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#')
+ if (_fs_fstab.fs_spec == NULL || *_fs_fstab.fs_spec == '#')
continue;
+ if (strunvis(_fs_fstab.fs_spec, _fs_fstab.fs_spec) < 0)
+ goto bad;
while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0')
;
_fs_fstab.fs_file = cp;
+ if (_fs_fstab.fs_file == NULL)
+ goto bad;
+ if (strunvis(_fs_fstab.fs_file, _fs_fstab.fs_file) < 0)
+ goto bad;
fixfsfile();
while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0')
;
@@ -206,7 +213,7 @@
if (typexx)
continue;
if (cp != NULL)
- return(1);
+ return (1);
bad: /* no way to distinguish between EOF and syntax error */
error(EFTYPE);
@@ -215,44 +222,43 @@
}
struct fstab *
-getfsent()
+getfsent(void)
{
+
if ((!_fs_fp && !setfsent()) || !fstabscan())
- return((struct fstab *)NULL);
- return(&_fs_fstab);
+ return (NULL);
+ return (&_fs_fstab);
}
struct fstab *
-getfsspec(name)
- const char *name;
+getfsspec(const char *name)
{
+
if (setfsent())
while (fstabscan())
if (!strcmp(_fs_fstab.fs_spec, name))
- return(&_fs_fstab);
- return((struct fstab *)NULL);
+ return (&_fs_fstab);
+ return (NULL);
}
struct fstab *
-getfsfile(name)
- const char *name;
+getfsfile(const char *name)
{
+
if (setfsent())
while (fstabscan())
if (!strcmp(_fs_fstab.fs_file, name))
- return(&_fs_fstab);
- return((struct fstab *)NULL);
+ return (&_fs_fstab);
+ return (NULL);
}
-int
-setfsent()
+int
+setfsent(void)
{
- int fd;
-
if (_fs_fp) {
rewind(_fs_fp);
LineNo = 0;
- return(1);
+ return (1);
}
if (fsp_set == 0) {
if (issetugid())
@@ -260,24 +266,18 @@
else
setfstab(getenv("PATH_FSTAB"));
}
- fd = _open(path_fstab, O_RDONLY | O_CLOEXEC);
- if (fd == -1) {
- error(errno);
- return (0);
- }
- _fs_fp = fdopen(fd, "r");
- if (_fs_fp != NULL) {
+ if ((_fs_fp = fopen(path_fstab, "re")) != NULL) {
LineNo = 0;
- return(1);
+ return (1);
}
error(errno);
- _close(fd);
- return(0);
+ return (0);
}
void
-endfsent()
+endfsent(void)
{
+
if (_fs_fp) {
(void)fclose(_fs_fp);
_fs_fp = NULL;
@@ -287,8 +287,7 @@
}
static void
-error(err)
- int err;
+error(int err)
{
char *p;
char num[30];
Modified: trunk/lib/libc/gen/ftok.3
===================================================================
--- trunk/lib/libc/gen/ftok.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ftok.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo at sigmasoft.com>
.\" All rights reserved.
.\"
@@ -23,7 +24,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/ftok.3 206622 2010-04-14 19:08:06Z uqs $
.Dd July 9, 2009
.Dt FTOK 3
.Os
Property changes on: trunk/lib/libc/gen/ftok.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/ftok.c
===================================================================
--- trunk/lib/libc/gen/ftok.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ftok.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo at sigmasoft.com>
* All rights reserved.
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/ftok.c 129926 2004-06-01 06:53:07Z tjr $");
#include <sys/types.h>
#include <sys/stat.h>
Modified: trunk/lib/libc/gen/fts-compat.c
===================================================================
--- trunk/lib/libc/gen/fts-compat.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fts-compat.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -36,7 +37,7 @@
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/fts-compat.c 301405 2016-06-04 17:40:23Z bdrewery $");
#include "namespace.h"
#include <sys/param.h>
@@ -52,6 +53,8 @@
#include "fts-compat.h"
#include "un-namespace.h"
+#include "gen-private.h"
+
FTSENT *__fts_children_44bsd(FTS *, int);
int __fts_close_44bsd(FTS *);
void *__fts_get_clientptr_44bsd(FTS *);
@@ -112,7 +115,6 @@
"ufs",
"zfs",
"nfs",
- "nfs4",
"ext2fs",
0
};
@@ -584,8 +586,10 @@
if ((fd = _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0)
return (NULL);
sp->fts_child = fts_build(sp, instr);
- if (fchdir(fd))
+ if (fchdir(fd)) {
+ (void)_close(fd);
return (NULL);
+ }
(void)_close(fd);
return (sp->fts_child);
}
@@ -713,7 +717,7 @@
*/
cderrno = 0;
if (nlinks || type == BREAD) {
- if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) {
+ if (fts_safe_changedir(sp, cur, _dirfd(dirp), NULL)) {
if (nlinks && type == BREAD)
cur->fts_errno = errno;
cur->fts_flags |= FTS_DONTCHDIR;
Modified: trunk/lib/libc/gen/fts-compat.h
===================================================================
--- trunk/lib/libc/gen/fts-compat.h 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fts-compat.h 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -10,11 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -31,7 +28,7 @@
* SUCH DAMAGE.
*
* @(#)fts.h 8.3 (Berkeley) 8/14/94
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/fts-compat.h 251071 2013-05-28 21:05:06Z emaste $
*/
#ifndef _FTS_H_
Modified: trunk/lib/libc/gen/fts.3
===================================================================
--- trunk/lib/libc/gen/fts.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fts.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)fts.3 8.5 (Berkeley) 4/16/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/fts.3 250888 2013-05-21 21:39:18Z ed $
.\"
-.Dd March 18, 2012
+.Dd May 21, 2013
.Dt FTS 3
.Os
.Sh NAME
@@ -37,8 +38,6 @@
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
-.In sys/types.h
-.In sys/stat.h
.In fts.h
.Ft FTS *
.Fn fts_open "char * const *path_argv" "int options" "int (*compar)(const FTSENT * const *, const FTSENT * const *)"
Property changes on: trunk/lib/libc/gen/fts.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/fts.c
===================================================================
--- trunk/lib/libc/gen/fts.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/fts.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -36,7 +37,7 @@
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/fts.c 301405 2016-06-04 17:40:23Z bdrewery $");
#include "namespace.h"
#include <sys/param.h>
@@ -52,6 +53,8 @@
#include <unistd.h>
#include "un-namespace.h"
+#include "gen-private.h"
+
static FTSENT *fts_alloc(FTS *, char *, size_t);
static FTSENT *fts_build(FTS *, int);
static void fts_lfree(FTSENT *);
@@ -60,7 +63,7 @@
static void fts_padjust(FTS *, FTSENT *);
static int fts_palloc(FTS *, size_t);
static FTSENT *fts_sort(FTS *, FTSENT *, size_t);
-static int fts_stat(FTS *, FTSENT *, int);
+static int fts_stat(FTS *, FTSENT *, int, int);
static int fts_safe_changedir(FTS *, FTSENT *, int, char *);
static int fts_ufslinks(FTS *, const FTSENT *);
@@ -102,7 +105,6 @@
"ufs",
"zfs",
"nfs",
- "nfs4",
"ext2fs",
0
};
@@ -132,9 +134,8 @@
}
/* Allocate/initialize the stream. */
- if ((priv = malloc(sizeof(*priv))) == NULL)
+ if ((priv = calloc(1, sizeof(*priv))) == NULL)
return (NULL);
- memset(priv, 0, sizeof(*priv));
sp = &priv->ftsp_fts;
sp->fts_compar = compar;
sp->fts_options = options;
@@ -160,17 +161,13 @@
/* Allocate/initialize root(s). */
for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) {
- /* Don't allow zero-length paths. */
- if ((len = strlen(*argv)) == 0) {
- errno = ENOENT;
- goto mem3;
- }
+ len = strlen(*argv);
p = fts_alloc(sp, *argv, len);
p->fts_level = FTS_ROOTLEVEL;
p->fts_parent = parent;
p->fts_accpath = p->fts_name;
- p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW));
+ p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW), -1);
/* Command-line "." and ".." are real directories. */
if (p->fts_info == FTS_DOT)
@@ -227,9 +224,7 @@
}
static void
-fts_load(sp, p)
- FTS *sp;
- FTSENT *p;
+fts_load(FTS *sp, FTSENT *p)
{
size_t len;
char *cp;
@@ -253,8 +248,7 @@
}
int
-fts_close(sp)
- FTS *sp;
+fts_close(FTS *sp)
{
FTSENT *freep, *p;
int saved_errno;
@@ -308,8 +302,7 @@
? p->fts_pathlen - 1 : p->fts_pathlen)
FTSENT *
-fts_read(sp)
- FTS *sp;
+fts_read(FTS *sp)
{
FTSENT *p, *tmp;
int instr;
@@ -329,7 +322,7 @@
/* Any type of file may be re-visited; re-stat and re-turn. */
if (instr == FTS_AGAIN) {
- p->fts_info = fts_stat(sp, p, 0);
+ p->fts_info = fts_stat(sp, p, 0, -1);
return (p);
}
@@ -341,7 +334,7 @@
*/
if (instr == FTS_FOLLOW &&
(p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
- p->fts_info = fts_stat(sp, p, 1);
+ p->fts_info = fts_stat(sp, p, 1, -1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if ((p->fts_symfd = _open(".", O_RDONLY | O_CLOEXEC,
0)) < 0) {
@@ -409,8 +402,6 @@
/* Move to the next node on this level. */
next: tmp = p;
if ((p = p->fts_link) != NULL) {
- free(tmp);
-
/*
* If reached the top, return to the original directory (or
* the root of the tree), and load the paths for the next root.
@@ -420,6 +411,7 @@
SET(FTS_STOP);
return (NULL);
}
+ free(tmp);
fts_load(sp, p);
return (sp->fts_cur = p);
}
@@ -429,10 +421,12 @@
* ignore. If followed, get a file descriptor so we can
* get back if necessary.
*/
- if (p->fts_instr == FTS_SKIP)
+ if (p->fts_instr == FTS_SKIP) {
+ free(tmp);
goto next;
+ }
if (p->fts_instr == FTS_FOLLOW) {
- p->fts_info = fts_stat(sp, p, 1);
+ p->fts_info = fts_stat(sp, p, 1, -1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if ((p->fts_symfd =
_open(".", O_RDONLY | O_CLOEXEC, 0)) < 0) {
@@ -444,6 +438,8 @@
p->fts_instr = FTS_NOINSTR;
}
+ free(tmp);
+
name: t = sp->fts_path + NAPPEND(p->fts_parent);
*t++ = '/';
memmove(t, p->fts_name, p->fts_namelen + 1);
@@ -452,7 +448,6 @@
/* Move up to the parent node. */
p = tmp->fts_parent;
- free(tmp);
if (p->fts_level == FTS_ROOTPARENTLEVEL) {
/*
@@ -459,6 +454,7 @@
* Done; free everything up and set errno to 0 so the user
* can distinguish between error and EOF.
*/
+ free(tmp);
free(p);
errno = 0;
return (sp->fts_cur = NULL);
@@ -491,6 +487,7 @@
SET(FTS_STOP);
return (NULL);
}
+ free(tmp);
p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP;
return (sp->fts_cur = p);
}
@@ -503,10 +500,7 @@
*/
/* ARGSUSED */
int
-fts_set(sp, p, instr)
- FTS *sp;
- FTSENT *p;
- int instr;
+fts_set(FTS *sp, FTSENT *p, int instr)
{
if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
instr != FTS_NOINSTR && instr != FTS_SKIP) {
@@ -518,12 +512,10 @@
}
FTSENT *
-fts_children(sp, instr)
- FTS *sp;
- int instr;
+fts_children(FTS *sp, int instr)
{
FTSENT *p;
- int fd;
+ int fd, rc, serrno;
if (instr != 0 && instr != FTS_NAMEONLY) {
errno = EINVAL;
@@ -579,11 +571,14 @@
if ((fd = _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0)
return (NULL);
sp->fts_child = fts_build(sp, instr);
- if (fchdir(fd)) {
- (void)_close(fd);
+ serrno = (sp->fts_child == NULL) ? errno : 0;
+ rc = fchdir(fd);
+ if (rc < 0 && serrno == 0)
+ serrno = errno;
+ (void)_close(fd);
+ errno = serrno;
+ if (rc < 0)
return (NULL);
- }
- (void)_close(fd);
return (sp->fts_child);
}
@@ -630,9 +625,7 @@
* been found, cutting the stat calls by about 2/3.
*/
static FTSENT *
-fts_build(sp, type)
- FTS *sp;
- int type;
+fts_build(FTS *sp, int type)
{
struct dirent *dp;
FTSENT *p, *head;
@@ -710,7 +703,7 @@
*/
cderrno = 0;
if (nlinks || type == BREAD) {
- if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) {
+ if (fts_safe_changedir(sp, cur, _dirfd(dirp), NULL)) {
if (nlinks && type == BREAD)
cur->fts_errno = errno;
cur->fts_flags |= FTS_DONTCHDIR;
@@ -810,10 +803,11 @@
if (ISSET(FTS_NOCHDIR)) {
p->fts_accpath = p->fts_path;
memmove(cp, p->fts_name, p->fts_namelen + 1);
- } else
+ p->fts_info = fts_stat(sp, p, 0, _dirfd(dirp));
+ } else {
p->fts_accpath = p->fts_name;
- /* Stat it. */
- p->fts_info = fts_stat(sp, p, 0);
+ p->fts_info = fts_stat(sp, p, 0, -1);
+ }
/* Decrement link count if applicable. */
if (nlinks > 0 && (p->fts_info == FTS_D ||
@@ -878,10 +872,7 @@
}
static int
-fts_stat(sp, p, follow)
- FTS *sp;
- FTSENT *p;
- int follow;
+fts_stat(FTS *sp, FTSENT *p, int follow, int dfd)
{
FTSENT *t;
dev_t dev;
@@ -888,7 +879,13 @@
ino_t ino;
struct stat *sbp, sb;
int saved_errno;
+ const char *path;
+ if (dfd == -1)
+ path = p->fts_accpath, dfd = AT_FDCWD;
+ else
+ path = p->fts_name;
+
/* If user needs stat info, stat buffer already allocated. */
sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp;
@@ -909,16 +906,17 @@
* fail, set the errno from the stat call.
*/
if (ISSET(FTS_LOGICAL) || follow) {
- if (stat(p->fts_accpath, sbp)) {
+ if (fstatat(dfd, path, sbp, 0)) {
saved_errno = errno;
- if (!lstat(p->fts_accpath, sbp)) {
- errno = 0;
+ if (fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) {
+ p->fts_errno = saved_errno;
+ goto err;
+ }
+ errno = 0;
+ if (S_ISLNK(sbp->st_mode))
return (FTS_SLNONE);
- }
- p->fts_errno = saved_errno;
- goto err;
}
- } else if (lstat(p->fts_accpath, sbp)) {
+ } else if (fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) {
p->fts_errno = errno;
err: memset(sbp, 0, sizeof(struct stat));
return (FTS_NS);
@@ -976,10 +974,7 @@
}
static FTSENT *
-fts_sort(sp, head, nitems)
- FTS *sp;
- FTSENT *head;
- size_t nitems;
+fts_sort(FTS *sp, FTSENT *head, size_t nitems)
{
FTSENT **ap, *p;
@@ -1008,10 +1003,7 @@
}
static FTSENT *
-fts_alloc(sp, name, namelen)
- FTS *sp;
- char *name;
- size_t namelen;
+fts_alloc(FTS *sp, char *name, size_t namelen)
{
FTSENT *p;
size_t len;
@@ -1058,8 +1050,7 @@
}
static void
-fts_lfree(head)
- FTSENT *head;
+fts_lfree(FTSENT *head)
{
FTSENT *p;
@@ -1077,9 +1068,7 @@
* plus 256 bytes so don't realloc the path 2 bytes at a time.
*/
static int
-fts_palloc(sp, more)
- FTS *sp;
- size_t more;
+fts_palloc(FTS *sp, size_t more)
{
sp->fts_pathlen += more + 256;
@@ -1092,9 +1081,7 @@
* already returned.
*/
static void
-fts_padjust(sp, head)
- FTS *sp;
- FTSENT *head;
+fts_padjust(FTS *sp, FTSENT *head)
{
FTSENT *p;
char *addr = sp->fts_path;
@@ -1135,11 +1122,7 @@
* Assumes p->fts_dev and p->fts_ino are filled in.
*/
static int
-fts_safe_changedir(sp, p, fd, path)
- FTS *sp;
- FTSENT *p;
- int fd;
- char *path;
+fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path)
{
int ret, oerrno, newfd;
struct stat sb;
Modified: trunk/lib/libc/gen/ftw.3
===================================================================
--- trunk/lib/libc/gen/ftw.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ftw.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $OpenBSD: ftw.3,v 1.5 2004/01/25 14:48:32 jmc Exp $
.\"
.\" Copyright (c) 2003 Todd C. Miller <Todd.Miller at courtesan.com>
@@ -18,7 +19,7 @@
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/ftw.3 152714 2005-11-23 15:41:36Z ru $
.\"
.Dd July 5, 2004
.Dt FTW 3
Property changes on: trunk/lib/libc/gen/ftw.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/ftw.c
===================================================================
--- trunk/lib/libc/gen/ftw.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ftw.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $OpenBSD: ftw.c,v 1.5 2005/08/08 08:05:34 espie Exp $ */
/*
@@ -21,7 +22,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/ftw.c 239151 2012-08-09 15:11:38Z jilles $");
#include <sys/types.h>
#include <sys/stat.h>
Added: trunk/lib/libc/gen/gen-private.h
===================================================================
--- trunk/lib/libc/gen/gen-private.h (rev 0)
+++ trunk/lib/libc/gen/gen-private.h 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,59 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: stable/10/lib/libc/gen/gen-private.h 270002 2014-08-14 20:20:21Z jhb $
+ */
+
+#ifndef _GEN_PRIVATE_H_
+#define _GEN_PRIVATE_H_
+
+struct _telldir; /* see telldir.h */
+struct pthread_mutex;
+
+/*
+ * Structure describing an open directory.
+ *
+ * NOTE. Change structure layout with care, at least dd_fd field has to
+ * remain unchanged to guarantee backward compatibility.
+ */
+struct _dirdesc {
+ int dd_fd; /* file descriptor associated with directory */
+ long dd_loc; /* offset in current buffer */
+ long dd_size; /* amount of data returned by getdirentries */
+ char *dd_buf; /* data buffer */
+ int dd_len; /* size of data buffer */
+ long dd_seek; /* magic cookie returned by getdirentries */
+ int dd_flags; /* flags for readdir */
+ struct pthread_mutex *dd_lock; /* lock */
+ struct _telldir *dd_td; /* telldir position recording */
+};
+
+#define _dirfd(dirp) ((dirp)->dd_fd)
+
+#endif /* !_GEN_PRIVATE_H_ */
Property changes on: trunk/lib/libc/gen/gen-private.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/gen/getbootfile.3
===================================================================
--- trunk/lib/libc/gen/getbootfile.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getbootfile.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)gethostname.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getbootfile.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd September 23, 1994
.Dt GETBOOTFILE 3
Property changes on: trunk/lib/libc/gen/getbootfile.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getbootfile.c
===================================================================
--- trunk/lib/libc/gen/getbootfile.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getbootfile.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "From: @(#)gethostname.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getbootfile.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/param.h>
#include <sys/sysctl.h>
Modified: trunk/lib/libc/gen/getbsize.3
===================================================================
--- trunk/lib/libc/gen/getbsize.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getbsize.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,14 +27,14 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getbsize.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getbsize.3 321127 2017-07-18 08:54:35Z ngie $
.\"
-.Dd June 4, 1993
+.Dd June 11, 2017
.Dt GETBSIZE 3
.Os
.Sh NAME
.Nm getbsize
-.Nd get user block size
+.Nd get preferred block size
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
@@ -43,12 +44,33 @@
.Sh DESCRIPTION
The
.Fn getbsize
-function determines the user's preferred block size based on the value of the
-.Dq BLOCKSIZE
-environment variable; see
-.Xr environ 7
-for details on its use and format.
+function returns a preferred block size for reporting by system utilities
+.Xr df 1 ,
+.Xr du 1 ,
+.Xr ls 1
+and
+.Xr systat 1 ,
+based on the value of the
+.Ev BLOCKSIZE
+environment variable.
+.Ev BLOCKSIZE
+may be specified directly in bytes, or in multiples of a kilobyte by
+specifying a number followed by ``K'' or ``k'', in multiples of a
+megabyte by specifying a number followed by ``M'' or ``m'' or in
+multiples of a gigabyte by specifying a number followed by ``G'' or
+``g''.
+Multiples must be integers.
.Pp
+Valid values of
+.Ev BLOCKSIZE
+are 512 bytes to 1 gigabyte.
+Sizes less than 512 bytes are rounded up to 512 bytes, and sizes
+greater than 1 GB are rounded down to 1 GB.
+In each case
+.Fn getbsize
+produces a warning message via
+.Xr warnx 3 .
+.Pp
The
.Fn getbsize
function returns a pointer to a null-terminated string describing
@@ -61,10 +83,6 @@
The memory referenced by
.Fa blocksizep
is filled in with block size, in bytes.
-.Pp
-If the user's block size is unreasonable, a warning message is
-written to standard error and the returned information reflects
-a block size of 512 bytes.
.Sh SEE ALSO
.Xr df 1 ,
.Xr du 1 ,
Property changes on: trunk/lib/libc/gen/getbsize.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getbsize.c
===================================================================
--- trunk/lib/libc/gen/getbsize.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getbsize.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)getbsize.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getbsize.c 181280 2008-08-04 06:53:13Z cperciva $");
#include <err.h>
#include <stdio.h>
Modified: trunk/lib/libc/gen/getcap.3
===================================================================
--- trunk/lib/libc/gen/getcap.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getcap.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -29,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getcap.3 8.4 (Berkeley) 5/13/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getcap.3 213573 2010-10-08 12:40:16Z uqs $
.\"
.Dd March 22, 2002
.Dt GETCAP 3
Property changes on: trunk/lib/libc/gen/getcap.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getcap.c
===================================================================
--- trunk/lib/libc/gen/getcap.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getcap.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -34,7 +35,7 @@
static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getcap.c 244092 2012-12-10 17:56:51Z jilles $");
#include "namespace.h"
#include <sys/types.h>
@@ -264,7 +265,7 @@
*cap = cbuf;
return (retval);
} else {
- fd = _open(*db_p, O_RDONLY, 0);
+ fd = _open(*db_p, O_RDONLY | O_CLOEXEC, 0);
if (fd < 0)
continue;
myfd = 1;
@@ -654,7 +655,7 @@
if (dbp == NULL)
dbp = db_array;
- if (pfp == NULL && (pfp = fopen(*dbp, "r")) == NULL) {
+ if (pfp == NULL && (pfp = fopen(*dbp, "re")) == NULL) {
(void)cgetclose();
return (-1);
}
@@ -679,7 +680,7 @@
(void)cgetclose();
return (0);
} else if ((pfp =
- fopen(*dbp, "r")) == NULL) {
+ fopen(*dbp, "re")) == NULL) {
(void)cgetclose();
return (-1);
} else
Modified: trunk/lib/libc/gen/getcontext.3
===================================================================
--- trunk/lib/libc/gen/getcontext.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getcontext.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2002 Packet Design, LLC.
.\" All rights reserved.
.\"
@@ -33,7 +34,7 @@
.\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
.\" THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getcontext.3 248250 2013-03-13 18:18:16Z pluknet $
.\"
.Dd March 13, 2013
.Dt GETCONTEXT 3
Property changes on: trunk/lib/libc/gen/getcontext.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getcwd.3
===================================================================
--- trunk/lib/libc/gen/getcwd.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getcwd.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getcwd.3 8.2 (Berkeley) 12/11/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getcwd.3 206760 2010-04-17 15:52:50Z jilles $
.\"
.Dd April 17, 2010
.Dt GETCWD 3
Property changes on: trunk/lib/libc/gen/getcwd.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getcwd.c
===================================================================
--- trunk/lib/libc/gen/getcwd.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getcwd.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1991, 1993, 1995
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getcwd.c 241046 2012-09-29 11:54:34Z jilles $");
#include "namespace.h"
#include <sys/param.h>
@@ -46,6 +47,8 @@
#include <unistd.h>
#include "un-namespace.h"
+#include "gen-private.h"
+
#define ISDOT(dp) \
(dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \
(dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
@@ -117,7 +120,7 @@
for (first = 1;; first = 0) {
/* Stat the current level. */
- if (dir != NULL ? _fstat(dirfd(dir), &s) : lstat(".", &s))
+ if (dir != NULL ? _fstat(_dirfd(dir), &s) : lstat(".", &s))
goto err;
/* Save current node values. */
@@ -139,13 +142,13 @@
}
/* Open and stat parent directory. */
- fd = _openat(dir != NULL ? dirfd(dir) : AT_FDCWD,
- "..", O_RDONLY);
+ fd = _openat(dir != NULL ? _dirfd(dir) : AT_FDCWD,
+ "..", O_RDONLY | O_CLOEXEC);
if (fd == -1)
goto err;
if (dir)
(void) closedir(dir);
- if (!(dir = fdopendir(fd)) || _fstat(dirfd(dir), &s)) {
+ if (!(dir = fdopendir(fd)) || _fstat(_dirfd(dir), &s)) {
_close(fd);
goto err;
}
@@ -171,7 +174,7 @@
continue;
/* Save the first error for later. */
- if (fstatat(dirfd(dir), dp->d_name, &s,
+ if (fstatat(_dirfd(dir), dp->d_name, &s,
AT_SYMLINK_NOFOLLOW)) {
if (!save_errno)
save_errno = errno;
Modified: trunk/lib/libc/gen/getdiskbyname.3
===================================================================
--- trunk/lib/libc/gen/getdiskbyname.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getdiskbyname.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getdiskbyname.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getdiskbyname.3 220617 2011-04-14 08:53:04Z pluknet $
.\"
.Dd June 4, 1993
.Dt GETDISKBYNAME 3
Property changes on: trunk/lib/libc/gen/getdiskbyname.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getdomainname.3
===================================================================
--- trunk/lib/libc/gen/getdomainname.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getdomainname.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)gethostname.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getdomainname.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd May 6, 1994
.Dt GETDOMAINNAME 3
Property changes on: trunk/lib/libc/gen/getdomainname.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getdomainname.c
===================================================================
--- trunk/lib/libc/gen/getdomainname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getdomainname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)gethostname.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getdomainname.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/param.h>
#include <sys/sysctl.h>
Modified: trunk/lib/libc/gen/getfsent.3
===================================================================
--- trunk/lib/libc/gen/getfsent.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getfsent.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getfsent.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getfsent.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd April 7, 2003
.Dt GETFSENT 3
Property changes on: trunk/lib/libc/gen/getfsent.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getgrent.3
===================================================================
--- trunk/lib/libc/gen/getgrent.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getgrent.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)getgrent.3 8.2 (Berkeley) 4/19/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getgrent.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd April 16, 2003
.Dt GETGRENT 3
Property changes on: trunk/lib/libc/gen/getgrent.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getgrent.c
===================================================================
--- trunk/lib/libc/gen/getgrent.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getgrent.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Networks Associates Technology, Inc.
* All rights reserved.
@@ -31,7 +32,7 @@
*
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getgrent.c 328943 2018-02-06 19:09:49Z mckusick $");
#include "namespace.h"
#include <sys/param.h>
@@ -433,7 +434,7 @@
{
int ret, dupc;
- for (dupc = 0; dupc < MIN(maxgrp, *grpcnt); dupc++) {
+ for (dupc = 1; dupc < MIN(maxgrp, *grpcnt); dupc++) {
if (groups[dupc] == gid)
return 1;
}
@@ -659,7 +660,6 @@
NS_FALLBACK_CB(getgroupmembership_fallback)
{ NULL, NULL, NULL }
};
- int rv;
assert(uname != NULL);
/* groups may be NULL if just sizing when invoked with maxgrp = 0 */
@@ -666,7 +666,7 @@
assert(grpcnt != NULL);
*grpcnt = 0;
- rv = _nsdispatch(NULL, dtab, NSDB_GROUP, "getgroupmembership",
+ (void)_nsdispatch(NULL, dtab, NSDB_GROUP, "getgroupmembership",
defaultsrc, uname, agroup, groups, maxgrp, grpcnt);
/* too many groups found? */
@@ -810,7 +810,7 @@
if (st->fp != NULL)
rewind(st->fp);
else if (stayopen)
- st->fp = fopen(_PATH_GROUP, "r");
+ st->fp = fopen(_PATH_GROUP, "re");
break;
case ENDGRENT:
if (st->fp != NULL) {
@@ -861,7 +861,7 @@
if (*errnop != 0)
return (NS_UNAVAIL);
if (st->fp == NULL &&
- ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
+ ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
*errnop = errno;
return (NS_UNAVAIL);
}
@@ -1251,7 +1251,7 @@
if (st->fp != NULL)
rewind(st->fp);
else if (stayopen)
- st->fp = fopen(_PATH_GROUP, "r");
+ st->fp = fopen(_PATH_GROUP, "re");
set_setent(dtab, mdata);
(void)_nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgrent",
compatsrc, 0);
@@ -1335,7 +1335,7 @@
if (*errnop != 0)
return (NS_UNAVAIL);
if (st->fp == NULL &&
- ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
+ ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
*errnop = errno;
rv = NS_UNAVAIL;
goto fin;
Modified: trunk/lib/libc/gen/getgrouplist.3
===================================================================
--- trunk/lib/libc/gen/getgrouplist.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getgrouplist.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getgrouplist.3 8.1 (Berkeley) 6/9/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getgrouplist.3 231945 2012-02-20 20:46:27Z pjd $
.\"
-.Dd June 9, 1993
+.Dd February 20, 2012
.Dt GETGROUPLIST 3
.Os
.Sh NAME
@@ -64,7 +65,7 @@
The
.Fn getgrouplist
function
-returns \-1 if the size of the group list is too small to
+returns 0 on success and \-1 if the size of the group list is too small to
hold all the user's groups.
Here, the group array will be filled with as many groups as will fit.
.Sh FILES
Property changes on: trunk/lib/libc/gen/getgrouplist.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getgrouplist.c
===================================================================
--- trunk/lib/libc/gen/getgrouplist.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getgrouplist.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getgrouplist.c 174547 2007-12-12 10:08:03Z bushman $");
/*
* get credential
Modified: trunk/lib/libc/gen/gethostname.3
===================================================================
--- trunk/lib/libc/gen/gethostname.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/gethostname.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)gethostname.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/gethostname.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd August 18, 2003
.Dt GETHOSTNAME 3
Property changes on: trunk/lib/libc/gen/gethostname.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/gethostname.c
===================================================================
--- trunk/lib/libc/gen/gethostname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/gethostname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)gethostname.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/gethostname.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/param.h>
#include <sys/sysctl.h>
Modified: trunk/lib/libc/gen/getloadavg.3
===================================================================
--- trunk/lib/libc/gen/getloadavg.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getloadavg.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getloadavg.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getloadavg.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 4, 1993
.Dt GETLOADAVG 3
Property changes on: trunk/lib/libc/gen/getloadavg.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getloadavg.c
===================================================================
--- trunk/lib/libc/gen/getloadavg.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getloadavg.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)getloadavg.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getloadavg.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/param.h>
#include <sys/time.h>
Modified: trunk/lib/libc/gen/getlogin.c
===================================================================
--- trunk/lib/libc/gen/getlogin.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getlogin.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)getlogin.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getlogin.c 269453 2014-08-03 01:51:48Z marcel $");
#include <sys/param.h>
#include <errno.h>
@@ -50,7 +51,7 @@
extern int _getlogin(char *, int);
-int _logname_valid; /* known to setlogin() */
+int _logname_valid __hidden; /* known to setlogin() */
static pthread_mutex_t logname_mutex = PTHREAD_MUTEX_INITIALIZER;
static char *
@@ -87,11 +88,16 @@
char *result;
int len;
int status;
-
+
+ if (namelen < 1)
+ return (ERANGE);
+ logname[0] = '\0';
+
THREAD_LOCK();
result = getlogin_basic(&status);
- if (status == 0) {
- if ((len = strlen(result) + 1) > namelen)
+ if (status == 0 && result != NULL) {
+ len = strlen(result) + 1;
+ if (len > namelen)
status = ERANGE;
else
strncpy(logname, result, len);
Modified: trunk/lib/libc/gen/getmntinfo.3
===================================================================
--- trunk/lib/libc/gen/getmntinfo.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getmntinfo.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getmntinfo.3 8.1 (Berkeley) 6/9/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getmntinfo.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 9, 1993
.Dt GETMNTINFO 3
Property changes on: trunk/lib/libc/gen/getmntinfo.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getmntinfo.c
===================================================================
--- trunk/lib/libc/gen/getmntinfo.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getmntinfo.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)getmntinfo.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getmntinfo.c 309485 2016-12-03 17:17:42Z ngie $");
#include <sys/param.h>
#include <sys/ucred.h>
@@ -58,7 +59,7 @@
if (mntbuf)
free(mntbuf);
bufsize = (mntsize + 1) * sizeof(struct statfs);
- if ((mntbuf = (struct statfs *)malloc(bufsize)) == 0)
+ if ((mntbuf = malloc(bufsize)) == NULL)
return (0);
if ((mntsize = getfsstat(mntbuf, bufsize, flags)) < 0)
return (0);
Modified: trunk/lib/libc/gen/getnetgrent.3
===================================================================
--- trunk/lib/libc/gen/getnetgrent.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getnetgrent.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getnetgrent.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getnetgrent.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 4, 1993
.Dt GETNETGRENT 3
Property changes on: trunk/lib/libc/gen/getnetgrent.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getnetgrent.c
===================================================================
--- trunk/lib/libc/gen/getnetgrent.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getnetgrent.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -34,7 +35,7 @@
static char sccsid[] = "@(#)getnetgrent.c 8.2 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getnetgrent.c 303680 2016-08-02 21:17:34Z markj $");
#include <ctype.h>
#include <stdio.h>
@@ -173,7 +174,7 @@
if (((stat(_PATH_NETGROUP, &_yp_statp) < 0) &&
errno == ENOENT) || _yp_statp.st_size == 0)
_use_only_yp = _netgr_yp_enabled = 1;
- if ((netf = fopen(_PATH_NETGROUP,"r")) != NULL ||_use_only_yp){
+ if ((netf = fopen(_PATH_NETGROUP,"re")) != NULL ||_use_only_yp){
/*
* Icky: grab the first character of the netgroup file
* and turn on NIS if it's a '+'. rewind the stream
@@ -197,7 +198,7 @@
return;
}
#else
- if ((netf = fopen(_PATH_NETGROUP, "r"))) {
+ if ((netf = fopen(_PATH_NETGROUP, "re"))) {
#endif
if (parse_netgrp(group))
endnetgrent();
@@ -512,6 +513,7 @@
ng[NG_DOM] == NULL ? "" : ",",
ng[NG_DOM] == NULL ? "" : ng[NG_DOM],
lp->l_groupname);
+ }
#endif
} else {
spos = strsep(&pos, ", \t");
@@ -558,6 +560,10 @@
continue;
}
}
+ if (strlen(result) == 0) {
+ free(result);
+ return (NULL);
+ }
snprintf(line, LINSIZ, "%s %s", group, result);
free(result);
}
@@ -614,6 +620,8 @@
if (linep == NULL) {
free(lp->l_groupname);
free(lp);
+ if (olen > 0)
+ free(olinep);
return (NULL);
}
if (olen > 0) {
Modified: trunk/lib/libc/gen/getosreldate.3
===================================================================
--- trunk/lib/libc/gen/getosreldate.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getosreldate.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2002 The FreeBSD Project.
.\" All rights reserved.
.\"
@@ -22,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD: src/lib/libc/gen/getosreldate.3,v 1.4 2012/10/20 03:08:32 laffer1 Exp $
+.\" $FreeBSD: stable/10/lib/libc/gen/getosreldate.3 183495 2008-09-30 11:25:55Z kib $
.\"
.Dd September 30, 2008
.Dt GETOSRELDATE 3
@@ -30,7 +31,7 @@
.Sh NAME
.Nm getosreldate
.Nd get the value of
-.Dv __MidnightBSD_version
+.Dv __FreeBSD_version
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
@@ -42,7 +43,7 @@
.Fn getosreldate
function returns an integer showing the version of the
currently running
-.Mx
+.Fx
kernel.
Definitions of the values can be found in
.%B "The Porter's Handbook"
@@ -66,7 +67,7 @@
.El
.Sh EXAMPLES
An example can be found in
-.Pa /usr/share/examples/MidnightBSD_version .
+.Pa /usr/share/examples/FreeBSD_version .
.Sh ERRORS
The
.Fn getosreldate
Property changes on: trunk/lib/libc/gen/getosreldate.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getosreldate.c
===================================================================
--- trunk/lib/libc/gen/getosreldate.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getosreldate.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,15 +32,14 @@
static char sccsid[] = "@(#)gethostid.c 8.1 (Berkeley) 6/2/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getosreldate.c 228492 2011-12-14 08:35:08Z ru $");
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/sysctl.h>
-#include <errno.h>
+
#include <stdlib.h>
+#include <unistd.h>
-#include <osreldate.h>
-
int
getosreldate(void)
{
Modified: trunk/lib/libc/gen/getpagesize.3
===================================================================
--- trunk/lib/libc/gen/getpagesize.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getpagesize.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getpagesize.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getpagesize.3 321249 2017-07-19 20:58:16Z ngie $
.\"
-.Dd June 4, 1993
+.Dd April 26, 2017
.Dt GETPAGESIZE 3
.Os
.Sh NAME
Property changes on: trunk/lib/libc/gen/getpagesize.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getpagesize.c
===================================================================
--- trunk/lib/libc/gen/getpagesize.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getpagesize.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)getpagesize.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getpagesize.c 317735 2017-05-03 09:54:37Z kib $");
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -53,7 +54,7 @@
int
getpagesize()
{
- int mib[2];
+ int mib[2];
static int value;
size_t size;
int error;
@@ -68,8 +69,8 @@
mib[0] = CTL_HW;
mib[1] = HW_PAGESIZE;
size = sizeof value;
- if (sysctl(mib, 2, &value, &size, NULL, 0) == -1)
- return (-1);
+ if (sysctl(mib, nitems(mib), &value, &size, NULL, 0) == -1)
+ return (PAGE_SIZE);
return (value);
}
Modified: trunk/lib/libc/gen/getpagesizes.3
===================================================================
--- trunk/lib/libc/gen/getpagesizes.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getpagesizes.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2009 Alan L. Cox <alc at cs.rice.edu>
.\" All rights reserved.
.\"
@@ -22,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getpagesizes.3 233648 2012-03-29 05:02:12Z eadler $
.\"
.Dd September 21, 2009
.Dt GETPAGESIZES 3
Property changes on: trunk/lib/libc/gen/getpagesizes.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getpagesizes.c
===================================================================
--- trunk/lib/libc/gen/getpagesizes.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getpagesizes.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2009 Alan L. Cox <alc at cs.rice.edu>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getpagesizes.c 211416 2010-08-17 09:13:26Z kib $");
#include <sys/param.h>
#include <sys/mman.h>
Modified: trunk/lib/libc/gen/getpass.3
===================================================================
--- trunk/lib/libc/gen/getpass.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getpass.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getpass.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getpass.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 4, 1993
.Dt GETPASS 3
Property changes on: trunk/lib/libc/gen/getpass.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getpeereid.3
===================================================================
--- trunk/lib/libc/gen/getpeereid.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getpeereid.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright (c) 2001 Dima Dorfman.
.\" All rights reserved.
@@ -23,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getpeereid.3 108030 2002-12-18 10:13:54Z ru $
.\"
.Dd July 15, 2001
.Dt GETPEEREID 3
Property changes on: trunk/lib/libc/gen/getpeereid.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getpeereid.c
===================================================================
--- trunk/lib/libc/gen/getpeereid.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getpeereid.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 2001 Dima Dorfman.
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getpeereid.c 330095 2018-02-28 02:39:38Z pfg $");
#include <sys/param.h>
#include <sys/socket.h>
@@ -46,8 +47,10 @@
error = getsockopt(s, 0, LOCAL_PEERCRED, &xuc, &xuclen);
if (error != 0)
return (error);
- if (xuc.cr_version != XUCRED_VERSION)
- return (EINVAL);
+ if (xuc.cr_version != XUCRED_VERSION) {
+ errno = EINVAL;
+ return (-1);
+ }
*euid = xuc.cr_uid;
*egid = xuc.cr_gid;
return (0);
Modified: trunk/lib/libc/gen/getprogname.3
===================================================================
--- trunk/lib/libc/gen/getprogname.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getprogname.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright (c) 2001 Christopher G. Demetriou
.\" All rights reserved.
@@ -29,7 +30,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getprogname.3 84306 2001-10-01 16:09:29Z ru $
.\"
.Dd May 1, 2001
.Dt GETPROGNAME 3
Property changes on: trunk/lib/libc/gen/getprogname.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getprogname.c
===================================================================
--- trunk/lib/libc/gen/getprogname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getprogname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getprogname.c 93399 2002-03-29 22:43:43Z markm $");
#include "namespace.h"
#include <stdlib.h>
Modified: trunk/lib/libc/gen/getpwent.3
===================================================================
--- trunk/lib/libc/gen/getpwent.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getpwent.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1988, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)getpwent.3 8.2 (Berkeley) 12/11/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getpwent.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd April 16, 2003
.Dt GETPWENT 3
Property changes on: trunk/lib/libc/gen/getpwent.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getpwent.c
===================================================================
--- trunk/lib/libc/gen/getpwent.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getpwent.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Networks Associates Technology, Inc.
* All rights reserved.
@@ -31,7 +32,7 @@
*
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getpwent.c 158115 2006-04-28 12:03:38Z ume $");
#include "namespace.h"
#include <sys/param.h>
Modified: trunk/lib/libc/gen/getttyent.3
===================================================================
--- trunk/lib/libc/gen/getttyent.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getttyent.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getttyent.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getttyent.3 202275 2010-01-14 05:37:43Z ed $
.\"
.Dd November 17, 1996
.Dt GETTTYENT 3
Property changes on: trunk/lib/libc/gen/getttyent.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getttyent.c
===================================================================
--- trunk/lib/libc/gen/getttyent.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getttyent.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,13 +32,16 @@
static char sccsid[] = "@(#)getttyent.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getttyent.c 316216 2017-03-30 05:13:52Z ngie $");
-#include <ttyent.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
-#include <ctype.h>
#include <string.h>
+#include <ttyent.h>
static char zapchar;
static FILE *tf;
@@ -64,6 +68,36 @@
return (t);
}
+static int
+auto_tty_status(const char *ty_name)
+{
+ size_t len;
+ char *buf, *cons, *nextcons;
+
+ /* Check if this is an enabled kernel console line */
+ buf = NULL;
+ if (sysctlbyname("kern.console", NULL, &len, NULL, 0) == -1)
+ return (0); /* Errors mean don't enable */
+ buf = malloc(len);
+ if (sysctlbyname("kern.console", buf, &len, NULL, 0) == -1)
+ goto done;
+
+ if ((cons = strchr(buf, '/')) == NULL)
+ goto done;
+ *cons = '\0';
+ nextcons = buf;
+ while ((cons = strsep(&nextcons, ",")) != NULL && strlen(cons) != 0) {
+ if (strcmp(cons, ty_name) == 0) {
+ free(buf);
+ return (TTY_ON);
+ }
+ }
+
+done:
+ free(buf);
+ return (0);
+}
+
struct ttyent *
getttyent(void)
{
@@ -78,7 +112,7 @@
if (!fgets(p = line, lbsize, tf))
return (NULL);
/* extend buffer if line was too big, and retry */
- while (!index(p, '\n') && !feof(tf)) {
+ while (!strchr(p, '\n') && !feof(tf)) {
i = strlen(p);
lbsize += MALLOCCHUNK;
if ((p = realloc(line, lbsize)) == NULL) {
@@ -126,6 +160,8 @@
tty.ty_status &= ~TTY_ON;
else if (scmp(_TTYS_ON))
tty.ty_status |= TTY_ON;
+ else if (scmp(_TTYS_ONIFCONSOLE))
+ tty.ty_status |= auto_tty_status(tty.ty_name);
else if (scmp(_TTYS_SECURE))
tty.ty_status |= TTY_SECURE;
else if (scmp(_TTYS_INSECURE))
@@ -148,7 +184,7 @@
tty.ty_comment = p;
if (*p == 0)
tty.ty_comment = 0;
- if ( (p = index(p, '\n')) )
+ if ((p = strchr(p, '\n')))
*p = '\0';
return (&tty);
}
@@ -196,7 +232,7 @@
value(char *p)
{
- return ((p = index(p, '=')) ? ++p : NULL);
+ return ((p = strchr(p, '=')) ? ++p : NULL);
}
int
@@ -211,7 +247,7 @@
if (tf) {
rewind(tf);
return (1);
- } else if ( (tf = fopen(_PATH_TTYS, "r")) )
+ } else if ( (tf = fopen(_PATH_TTYS, "re")) )
return (1);
return (0);
}
Modified: trunk/lib/libc/gen/getusershell.3
===================================================================
--- trunk/lib/libc/gen/getusershell.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getusershell.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $NetBSD: getusershell.3,v 1.6 1999/03/22 19:44:42 garbled Exp $
.\"
.\" Copyright (c) 1985, 1991, 1993
@@ -28,7 +29,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getusershell.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getusershell.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd January 16, 1999
.Dt GETUSERSHELL 3
Property changes on: trunk/lib/libc/gen/getusershell.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getusershell.c
===================================================================
--- trunk/lib/libc/gen/getusershell.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getusershell.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,7 +33,7 @@
#endif /* LIBC_SCCS and not lint */
/* $NetBSD: getusershell.c,v 1.17 1999/01/25 01:09:34 lukem Exp $ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getusershell.c 244092 2012-12-10 17:56:51Z jilles $");
#include "namespace.h"
#include <sys/param.h>
@@ -58,12 +59,6 @@
#endif
#include "un-namespace.h"
-/*
- * Local shells should NOT be added here. They should be added in
- * /etc/shells.
- */
-
-static const char *const okshells[] = { _PATH_BSHELL, _PATH_CSHELL, NULL };
static const char *const *curshell;
static StringList *sl;
@@ -121,7 +116,7 @@
sl_free(sl, 1);
sl = sl_init();
- if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
+ if ((fp = fopen(_PATH_SHELLS, "re")) == NULL)
return NS_UNAVAIL;
cp = line;
@@ -261,8 +256,13 @@
!= NS_SUCCESS) {
if (sl)
sl_free(sl, 1);
- sl = NULL;
- return (okshells);
+ sl = sl_init();
+ /*
+ * Local shells should NOT be added here. They should be
+ * added in /etc/shells.
+ */
+ sl_add(sl, strdup(_PATH_BSHELL));
+ sl_add(sl, strdup(_PATH_CSHELL));
}
sl_add(sl, NULL);
Modified: trunk/lib/libc/gen/getutxent.3
===================================================================
--- trunk/lib/libc/gen/getutxent.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getutxent.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2010 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -22,9 +23,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getutxent.3 231530 2012-02-11 20:28:42Z ed $
.\"
-.Dd February 19, 2011
+.Dd October 27, 2011
.Dt GETUTXENT 3
.Os
.Sh NAME
@@ -301,7 +302,6 @@
determines which databases are modified.
.Pp
Entries of type
-.Dv BOOT_TIME ,
.Dv SHUTDOWN_TIME ,
.Dv OLD_TIME
and
@@ -335,7 +335,7 @@
.Dv BOOT_TIME
and
.Dv SHUTDOWN_TIME
-will cause all entries in
+will cause all existing entries in
.Pa /var/run/utx.active
to be discarded.
.Pp
@@ -419,13 +419,12 @@
.Sh SEE ALSO
.Xr last 1 ,
.Xr write 1 ,
-.Xr wtmpcvt 1 ,
.Xr getpid 2 ,
.Xr gettimeofday 2 ,
.Xr tty 4 ,
.Xr ac 8 ,
.Xr newsyslog 8 ,
-.Xr utxrm 8
+.Xr utx 8
.Sh STANDARDS
The
.Fn endutxent ,
Property changes on: trunk/lib/libc/gen/getutxent.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getutxent.c
===================================================================
--- trunk/lib/libc/gen/getutxent.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getutxent.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2010 Ed Schouten <ed at FreeBSD.org>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getutxent.c 257320 2013-10-29 09:23:51Z glebius $");
#include "namespace.h"
#include <sys/endian.h>
@@ -38,8 +39,13 @@
#include "utxdb.h"
#include "un-namespace.h"
+#ifdef __NO_TLS
static FILE *uf = NULL;
static int udb;
+#else
+static _Thread_local FILE *uf = NULL;
+static _Thread_local int udb;
+#endif
int
setutxdb(int db, const char *file)
@@ -66,7 +72,7 @@
if (uf != NULL)
fclose(uf);
- uf = fopen(file, "r");
+ uf = fopen(file, "re");
if (uf == NULL)
return (-1);
@@ -117,9 +123,20 @@
if (udb == UTXDB_LOG) {
uint16_t len;
+retry:
if (fread(&len, sizeof(len), 1, uf) != 1)
return (-1);
len = be16toh(len);
+ if (len == 0) {
+ /*
+ * XXX: Though zero-size records are valid in theory,
+ * they can never occur in practice. Zero-size records
+ * indicate file corruption. Seek one byte forward, to
+ * see if we can find a record there.
+ */
+ ungetc('\0', uf);
+ goto retry;
+ }
if (len > sizeof *fu) {
/* Forward compatibility. */
if (fread(fu, sizeof(*fu), 1, uf) != 1)
Modified: trunk/lib/libc/gen/getvfsbyname.3
===================================================================
--- trunk/lib/libc/gen/getvfsbyname.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getvfsbyname.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1995
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)kvm_getvfsbyname.3 8.3 (Berkeley) 5/4/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/getvfsbyname.3 305568 2016-09-07 21:04:39Z jilles $
.\"
-.Dd April 5, 2007
+.Dd August 30, 2016
.Dt GETVFSBYNAME 3
.Os
.Sh NAME
@@ -97,11 +98,6 @@
.Sh ERRORS
The following errors may be reported:
.Bl -tag -width Er
-.It Bq Er EFAULT
-The
-.Fa vfc
-argument
-points to an invalid address.
.It Bq Er ENOENT
The
.Fa name
Property changes on: trunk/lib/libc/gen/getvfsbyname.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/getvfsbyname.c
===================================================================
--- trunk/lib/libc/gen/getvfsbyname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/getvfsbyname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1995
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)kvm_getvfsbyname.c 8.1 (Berkeley) 4/3/95";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/getvfsbyname.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/param.h>
#include <sys/mount.h>
Modified: trunk/lib/libc/gen/glob.3
===================================================================
--- trunk/lib/libc/gen/glob.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/glob.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -28,7 +29,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)glob.3 8.3 (Berkeley) 4/16/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/glob.3 304203 2016-08-16 07:14:09Z ache $
.\"
.Dd December 20, 2011
.Dt GLOB 3
@@ -275,24 +276,10 @@
.Pf non- Dv NULL ,
.Fn glob
calls
-.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) .
-This may be unintuitive: a pattern like
-.Ql */Makefile
-will try to
-.Xr stat 2
-.Ql foo/Makefile
-even if
-.Ql foo
-is not a directory, resulting in a
-call to
-.Fa errfunc .
-The error routine can suppress this action by testing for
-.Er ENOENT
-and
-.Er ENOTDIR ;
+.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) ,
however, the
.Dv GLOB_ERR
-flag will still cause an immediate
+flag will cause an immediate
return when this happens.
.Pp
If
@@ -377,7 +364,7 @@
.It Dv GLOB_NOSPACE
An attempt to allocate memory failed, or if
.Fa errno
-was 0
+was E2BIG,
.Dv GLOB_LIMIT
was specified in the flags and
.Fa pglob\->gl_matchc
Property changes on: trunk/lib/libc/gen/glob.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/glob.c
===================================================================
--- trunk/lib/libc/gen/glob.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/glob.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,7 +40,7 @@
static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/glob.c 304203 2016-08-16 07:14:09Z ache $");
/*
* glob(3) -- a superset of the one defined in POSIX 1003.2.
@@ -71,7 +72,7 @@
* 1. Patterns with illegal byte sequences match nothing - even if
* GLOB_NOCHECK is specified.
* 2. Illegal byte sequences in filenames are handled by treating them as
- * single-byte characters with a value of the first byte of the sequence
+ * single-byte characters with a values of such bytes of the sequence
* cast to wchar_t.
* 3. State-dependent encodings are not currently supported.
*/
@@ -113,26 +114,21 @@
size_t l_string_cnt;
};
-#define DOLLAR '$'
-#define DOT '.'
-#define EOS '\0'
-#define LBRACKET '['
-#define NOT '!'
-#define QUESTION '?'
-#define QUOTE '\\'
-#define RANGE '-'
-#define RBRACKET ']'
-#define SEP '/'
-#define STAR '*'
-#define TILDE '~'
-#define UNDERSCORE '_'
-#define LBRACE '{'
-#define RBRACE '}'
-#define SLASH '/'
-#define COMMA ','
+#define DOT L'.'
+#define EOS L'\0'
+#define LBRACKET L'['
+#define NOT L'!'
+#define QUESTION L'?'
+#define QUOTE L'\\'
+#define RANGE L'-'
+#define RBRACKET L']'
+#define SEP L'/'
+#define STAR L'*'
+#define TILDE L'~'
+#define LBRACE L'{'
+#define RBRACE L'}'
+#define COMMA L','
-#ifndef DEBUG
-
#define M_QUOTE 0x8000000000ULL
#define M_PROTECT 0x4000000000ULL
#define M_MASK 0xffffffffffULL
@@ -140,29 +136,20 @@
typedef uint_fast64_t Char;
-#else
-
-#define M_QUOTE 0x80
-#define M_PROTECT 0x40
-#define M_MASK 0xff
-#define M_CHAR 0x7f
-
-typedef char Char;
-
-#endif
-
-
#define CHAR(c) ((Char)((c)&M_CHAR))
#define META(c) ((Char)((c)|M_QUOTE))
-#define M_ALL META('*')
-#define M_END META(']')
-#define M_NOT META('!')
-#define M_ONE META('?')
-#define M_RNG META('-')
-#define M_SET META('[')
+#define UNPROT(c) ((c) & ~M_PROTECT)
+#define M_ALL META(L'*')
+#define M_END META(L']')
+#define M_NOT META(L'!')
+#define M_ONE META(L'?')
+#define M_RNG META(L'-')
+#define M_SET META(L'[')
#define ismeta(c) (((c)&M_QUOTE) != 0)
+#ifdef DEBUG
+#define isprot(c) (((c)&M_PROTECT) != 0)
+#endif
-
static int compare(const void *, const void *);
static int g_Ctoc(const Char *, char *, size_t);
static int g_lstat(Char *, struct stat *, glob_t *);
@@ -172,19 +159,27 @@
static Char *g_strcat(Char *, const Char *);
#endif
static int g_stat(Char *, struct stat *, glob_t *);
-static int glob0(const Char *, glob_t *, struct glob_limit *);
+static int glob0(const Char *, glob_t *, struct glob_limit *,
+ const char *);
static int glob1(Char *, glob_t *, struct glob_limit *);
static int glob2(Char *, Char *, Char *, Char *, glob_t *,
struct glob_limit *);
static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *,
struct glob_limit *);
-static int globextend(const Char *, glob_t *, struct glob_limit *);
+static int globextend(const Char *, glob_t *, struct glob_limit *,
+ const char *);
static const Char *
globtilde(const Char *, Char *, size_t, glob_t *);
+static int globexp0(const Char *, glob_t *, struct glob_limit *,
+ const char *);
static int globexp1(const Char *, glob_t *, struct glob_limit *);
-static int globexp2(const Char *, const Char *, glob_t *, int *,
+static int globexp2(const Char *, const Char *, glob_t *,
struct glob_limit *);
+static int globfinal(glob_t *, struct glob_limit *, size_t,
+ const char *);
static int match(Char *, Char *, Char *);
+static int err_nomatch(glob_t *, struct glob_limit *, const char *);
+static int err_aborted(glob_t *, int, char *);
#ifdef DEBUG
static void qprintf(const char *, Char *);
#endif
@@ -199,6 +194,7 @@
mbstate_t mbs;
wchar_t wc;
size_t clen;
+ int too_long;
patnext = pattern;
if (!(flags & GLOB_APPEND)) {
@@ -218,14 +214,17 @@
bufnext = patbuf;
bufend = bufnext + MAXPATHLEN - 1;
+ too_long = 1;
if (flags & GLOB_NOESCAPE) {
memset(&mbs, 0, sizeof(mbs));
- while (bufend - bufnext >= MB_CUR_MAX) {
+ while (bufnext <= bufend) {
clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
if (clen == (size_t)-1 || clen == (size_t)-2)
- return (GLOB_NOMATCH);
- else if (clen == 0)
+ return (err_nomatch(pglob, &limit, pattern));
+ else if (clen == 0) {
+ too_long = 0;
break;
+ }
*bufnext++ = wc;
patnext += clen;
}
@@ -232,10 +231,10 @@
} else {
/* Protect the quoted characters. */
memset(&mbs, 0, sizeof(mbs));
- while (bufend - bufnext >= MB_CUR_MAX) {
- if (*patnext == QUOTE) {
- if (*++patnext == EOS) {
- *bufnext++ = QUOTE | M_PROTECT;
+ while (bufnext <= bufend) {
+ if (*patnext == '\\') {
+ if (*++patnext == '\0') {
+ *bufnext++ = QUOTE;
continue;
}
prot = M_PROTECT;
@@ -243,21 +242,49 @@
prot = 0;
clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
if (clen == (size_t)-1 || clen == (size_t)-2)
- return (GLOB_NOMATCH);
- else if (clen == 0)
+ return (err_nomatch(pglob, &limit, pattern));
+ else if (clen == 0) {
+ too_long = 0;
break;
+ }
*bufnext++ = wc | prot;
patnext += clen;
}
}
+ if (too_long)
+ return (err_nomatch(pglob, &limit, pattern));
*bufnext = EOS;
if (flags & GLOB_BRACE)
- return globexp1(patbuf, pglob, &limit);
+ return (globexp0(patbuf, pglob, &limit, pattern));
else
- return glob0(patbuf, pglob, &limit);
+ return (glob0(patbuf, pglob, &limit, pattern));
}
+static int
+globexp0(const Char *pattern, glob_t *pglob, struct glob_limit *limit,
+ const char *origpat) {
+ int rv;
+ size_t oldpathc;
+
+ /* Protect a single {}, for find(1), like csh */
+ if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS) {
+ if ((pglob->gl_flags & GLOB_LIMIT) &&
+ limit->l_brace_cnt++ >= GLOB_LIMIT_BRACE) {
+ errno = E2BIG;
+ return (GLOB_NOSPACE);
+ }
+ return (glob0(pattern, pglob, limit, origpat));
+ }
+
+ oldpathc = pglob->gl_pathc;
+
+ if ((rv = globexp1(pattern, pglob, limit)) != 0)
+ return rv;
+
+ return (globfinal(pglob, limit, oldpathc, origpat));
+}
+
/*
* Expand recursively a glob {} pattern. When there is no more expansion
* invoke the standard globbing routine to glob the rest of the magic
@@ -266,24 +293,18 @@
static int
globexp1(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
{
- const Char* ptr = pattern;
- int rv;
+ const Char* ptr;
- if ((pglob->gl_flags & GLOB_LIMIT) &&
- limit->l_brace_cnt++ >= GLOB_LIMIT_BRACE) {
- errno = 0;
- return (GLOB_NOSPACE);
+ if ((ptr = g_strchr(pattern, LBRACE)) != NULL) {
+ if ((pglob->gl_flags & GLOB_LIMIT) &&
+ limit->l_brace_cnt++ >= GLOB_LIMIT_BRACE) {
+ errno = E2BIG;
+ return (GLOB_NOSPACE);
+ }
+ return (globexp2(ptr, pattern, pglob, limit));
}
- /* Protect a single {}, for find(1), like csh */
- if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
- return glob0(pattern, pglob, limit);
-
- while ((ptr = g_strchr(ptr, LBRACE)) != NULL)
- if (!globexp2(ptr, pattern, pglob, &rv, limit))
- return rv;
-
- return glob0(pattern, pglob, limit);
+ return (glob0(pattern, pglob, limit, NULL));
}
@@ -293,10 +314,10 @@
* If it fails then it tries to glob the rest of the pattern and returns.
*/
static int
-globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv,
+globexp2(const Char *ptr, const Char *pattern, glob_t *pglob,
struct glob_limit *limit)
{
- int i;
+ int i, rv;
Char *lm, *ls;
const Char *pe, *pm, *pm1, *pl;
Char patbuf[MAXPATHLEN];
@@ -308,7 +329,7 @@
ls = lm;
/* Find the balanced brace */
- for (i = 0, pe = ++ptr; *pe; pe++)
+ for (i = 0, pe = ++ptr; *pe != EOS; pe++)
if (*pe == LBRACKET) {
/* Ignore everything between [] */
for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++)
@@ -330,10 +351,8 @@
}
/* Non matching braces; just glob the pattern */
- if (i != 0 || *pe == EOS) {
- *rv = glob0(patbuf, pglob, limit);
- return 0;
- }
+ if (i != 0 || *pe == EOS)
+ return (glob0(pattern, pglob, limit, NULL));
for (i = 0, pl = pm = ptr; pm <= pe; pm++)
switch (*pm) {
@@ -378,7 +397,9 @@
#ifdef DEBUG
qprintf("globexp2:", patbuf);
#endif
- *rv = globexp1(patbuf, pglob, limit);
+ rv = globexp1(patbuf, pglob, limit);
+ if (rv)
+ return (rv);
/* move after the comma, to the next string */
pl = pm + 1;
@@ -388,8 +409,7 @@
default:
break;
}
- *rv = 0;
- return 0;
+ return (0);
}
@@ -401,24 +421,34 @@
globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
{
struct passwd *pwd;
- char *h;
+ char *h, *sc;
const Char *p;
Char *b, *eb;
+ wchar_t wc;
+ wchar_t wbuf[MAXPATHLEN];
+ wchar_t *wbufend, *dc;
+ size_t clen;
+ mbstate_t mbs;
+ int too_long;
if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
- return pattern;
+ return (pattern);
/*
* Copy up to the end of the string or /
*/
eb = &patbuf[patbuf_len - 1];
- for (p = pattern + 1, h = (char *) patbuf;
- h < (char *)eb && *p && *p != SLASH; *h++ = *p++)
+ for (p = pattern + 1, b = patbuf;
+ b < eb && *p != EOS && UNPROT(*p) != SEP; *b++ = *p++)
continue;
- *h = EOS;
+ if (*p != EOS && UNPROT(*p) != SEP)
+ return (NULL);
- if (((char *) patbuf)[0] == EOS) {
+ *b = EOS;
+ h = NULL;
+
+ if (patbuf[0] == EOS) {
/*
* handle a plain ~ or ~/ by expanding $HOME first (iff
* we're not running setuid or setgid) and then trying
@@ -431,7 +461,7 @@
(pwd = getpwuid(getuid())) != NULL)
h = pwd->pw_dir;
else
- return pattern;
+ return (pattern);
}
}
else {
@@ -438,22 +468,58 @@
/*
* Expand a ~user
*/
- if ((pwd = getpwnam((char*) patbuf)) == NULL)
- return pattern;
+ if (g_Ctoc(patbuf, (char *)wbuf, sizeof(wbuf)))
+ return (NULL);
+ if ((pwd = getpwnam((char *)wbuf)) == NULL)
+ return (pattern);
else
h = pwd->pw_dir;
}
/* Copy the home directory */
- for (b = patbuf; b < eb && *h; *b++ = *h++)
+ dc = wbuf;
+ sc = h;
+ wbufend = wbuf + MAXPATHLEN - 1;
+ too_long = 1;
+ memset(&mbs, 0, sizeof(mbs));
+ while (dc <= wbufend) {
+ clen = mbrtowc(&wc, sc, MB_LEN_MAX, &mbs);
+ if (clen == (size_t)-1 || clen == (size_t)-2) {
+ /* XXX See initial comment #2. */
+ wc = (unsigned char)*sc;
+ clen = 1;
+ memset(&mbs, 0, sizeof(mbs));
+ }
+ if ((*dc++ = wc) == EOS) {
+ too_long = 0;
+ break;
+ }
+ sc += clen;
+ }
+ if (too_long)
+ return (NULL);
+
+ dc = wbuf;
+ for (b = patbuf; b < eb && *dc != EOS; *b++ = *dc++ | M_PROTECT)
continue;
+ if (*dc != EOS)
+ return (NULL);
/* Append the rest of the pattern */
- while (b < eb && (*b++ = *p++) != EOS)
- continue;
- *b = EOS;
+ if (*p != EOS) {
+ too_long = 1;
+ while (b <= eb) {
+ if ((*b++ = *p++) == EOS) {
+ too_long = 0;
+ break;
+ }
+ }
+ if (too_long)
+ return (NULL);
+ } else
+ *b = EOS;
- return patbuf;
+ return (patbuf);
}
@@ -464,8 +530,8 @@
* if things went well, nonzero if errors occurred.
*/
static int
-glob0(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
-{
+glob0(const Char *pattern, glob_t *pglob, struct glob_limit *limit,
+ const char *origpat) {
const Char *qpatnext;
int err;
size_t oldpathc;
@@ -472,6 +538,10 @@
Char *bufnext, c, patbuf[MAXPATHLEN];
qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
+ if (qpatnext == NULL) {
+ errno = E2BIG;
+ return (GLOB_NOSPACE);
+ }
oldpathc = pglob->gl_pathc;
bufnext = patbuf;
@@ -530,30 +600,29 @@
if ((err = glob1(patbuf, pglob, limit)) != 0)
return(err);
- /*
- * If there was no match we are going to append the pattern
- * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
- * and the pattern did not contain any magic characters
- * GLOB_NOMAGIC is there just for compatibility with csh.
- */
- if (pglob->gl_pathc == oldpathc) {
- if (((pglob->gl_flags & GLOB_NOCHECK) ||
- ((pglob->gl_flags & GLOB_NOMAGIC) &&
- !(pglob->gl_flags & GLOB_MAGCHAR))))
- return(globextend(pattern, pglob, limit));
- else
- return(GLOB_NOMATCH);
- }
+ if (origpat != NULL)
+ return (globfinal(pglob, limit, oldpathc, origpat));
+
+ return (0);
+}
+
+static int
+globfinal(glob_t *pglob, struct glob_limit *limit, size_t oldpathc,
+ const char *origpat) {
+ if (pglob->gl_pathc == oldpathc)
+ return (err_nomatch(pglob, limit, origpat));
+
if (!(pglob->gl_flags & GLOB_NOSORT))
qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
pglob->gl_pathc - oldpathc, sizeof(char *), compare);
- return(0);
+
+ return (0);
}
static int
compare(const void *p, const void *q)
{
- return(strcmp(*(char **)p, *(char **)q));
+ return (strcoll(*(char **)p, *(char **)q));
}
static int
@@ -563,8 +632,8 @@
/* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */
if (*pattern == EOS)
- return(0);
- return(glob2(pathbuf, pathbuf, pathbuf + MAXPATHLEN - 1,
+ return (0);
+ return (glob2(pathbuf, pathbuf, pathbuf + MAXPATHLEN - 1,
pattern, pglob, limit));
}
@@ -589,39 +658,40 @@
if (*pattern == EOS) { /* End of pattern? */
*pathend = EOS;
if (g_lstat(pathbuf, &sb, pglob))
- return(0);
+ return (0);
if ((pglob->gl_flags & GLOB_LIMIT) &&
limit->l_stat_cnt++ >= GLOB_LIMIT_STAT) {
- errno = 0;
- if (pathend + 1 > pathend_last)
- return (GLOB_ABORTED);
- *pathend++ = SEP;
- *pathend = EOS;
+ errno = E2BIG;
return (GLOB_NOSPACE);
}
- if (((pglob->gl_flags & GLOB_MARK) &&
- pathend[-1] != SEP) && (S_ISDIR(sb.st_mode)
- || (S_ISLNK(sb.st_mode) &&
- (g_stat(pathbuf, &sb, pglob) == 0) &&
+ if ((pglob->gl_flags & GLOB_MARK) &&
+ UNPROT(pathend[-1]) != SEP &&
+ (S_ISDIR(sb.st_mode) ||
+ (S_ISLNK(sb.st_mode) &&
+ g_stat(pathbuf, &sb, pglob) == 0 &&
S_ISDIR(sb.st_mode)))) {
- if (pathend + 1 > pathend_last)
- return (GLOB_ABORTED);
+ if (pathend + 1 > pathend_last) {
+ errno = E2BIG;
+ return (GLOB_NOSPACE);
+ }
*pathend++ = SEP;
*pathend = EOS;
}
++pglob->gl_matchc;
- return(globextend(pathbuf, pglob, limit));
+ return (globextend(pathbuf, pglob, limit, NULL));
}
/* Find end of next segment, copy tentatively to pathend. */
q = pathend;
p = pattern;
- while (*p != EOS && *p != SEP) {
+ while (*p != EOS && UNPROT(*p) != SEP) {
if (ismeta(*p))
anymeta = 1;
- if (q + 1 > pathend_last)
- return (GLOB_ABORTED);
+ if (q + 1 > pathend_last) {
+ errno = E2BIG;
+ return (GLOB_NOSPACE);
+ }
*q++ = *p++;
}
@@ -628,14 +698,16 @@
if (!anymeta) { /* No expansion, do next segment. */
pathend = q;
pattern = p;
- while (*pattern == SEP) {
- if (pathend + 1 > pathend_last)
- return (GLOB_ABORTED);
+ while (UNPROT(*pattern) == SEP) {
+ if (pathend + 1 > pathend_last) {
+ errno = E2BIG;
+ return (GLOB_NOSPACE);
+ }
*pathend++ = *pattern++;
}
} else /* Need expansion, recurse. */
- return(glob3(pathbuf, pathend, pathend_last, pattern, p,
- pglob, limit));
+ return (glob3(pathbuf, pathend, pathend_last, pattern,
+ p, pglob, limit));
}
/* NOTREACHED */
}
@@ -647,42 +719,44 @@
{
struct dirent *dp;
DIR *dirp;
- int err;
- char buf[MAXPATHLEN];
+ int err, too_long, saverrno, saverrno2;
+ char buf[MAXPATHLEN + MB_LEN_MAX - 1];
- /*
- * The readdirfunc declaration can't be prototyped, because it is
- * assigned, below, to two functions which are prototyped in glob.h
- * and dirent.h as taking pointers to differently typed opaque
- * structures.
- */
- struct dirent *(*readdirfunc)();
+ struct dirent *(*readdirfunc)(DIR *);
- if (pathend > pathend_last)
- return (GLOB_ABORTED);
+ if (pathend > pathend_last) {
+ errno = E2BIG;
+ return (GLOB_NOSPACE);
+ }
*pathend = EOS;
+ if (pglob->gl_errfunc != NULL &&
+ g_Ctoc(pathbuf, buf, sizeof(buf))) {
+ errno = E2BIG;
+ return (GLOB_NOSPACE);
+ }
+
+ saverrno = errno;
errno = 0;
-
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
- /* TODO: don't call for ENOENT or ENOTDIR? */
- if (pglob->gl_errfunc) {
- if (g_Ctoc(pathbuf, buf, sizeof(buf)))
- return (GLOB_ABORTED);
- if (pglob->gl_errfunc(buf, errno) ||
- pglob->gl_flags & GLOB_ERR)
- return (GLOB_ABORTED);
- }
- return(0);
+ if (errno == ENOENT || errno == ENOTDIR)
+ return (0);
+ err = err_aborted(pglob, errno, buf);
+ if (errno == 0)
+ errno = saverrno;
+ return (err);
}
err = 0;
- /* Search directory for matching names. */
+ /* pglob->gl_readdir takes a void *, fix this manually */
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- readdirfunc = pglob->gl_readdir;
+ readdirfunc = (struct dirent *(*)(DIR *))pglob->gl_readdir;
else
readdirfunc = readdir;
- while ((dp = (*readdirfunc)(dirp))) {
+
+ errno = 0;
+ /* Search directory for matching names. */
+ while ((dp = (*readdirfunc)(dirp)) != NULL) {
char *sc;
Char *dc;
wchar_t wc;
@@ -691,54 +765,75 @@
if ((pglob->gl_flags & GLOB_LIMIT) &&
limit->l_readdir_cnt++ >= GLOB_LIMIT_READDIR) {
- errno = 0;
- if (pathend + 1 > pathend_last)
- err = GLOB_ABORTED;
- else {
- *pathend++ = SEP;
- *pathend = EOS;
- err = GLOB_NOSPACE;
- }
+ errno = E2BIG;
+ err = GLOB_NOSPACE;
break;
}
/* Initial DOT must be matched literally. */
- if (dp->d_name[0] == DOT && *pattern != DOT)
+ if (dp->d_name[0] == '.' && UNPROT(*pattern) != DOT) {
+ errno = 0;
continue;
+ }
memset(&mbs, 0, sizeof(mbs));
dc = pathend;
sc = dp->d_name;
- while (dc < pathend_last) {
+ too_long = 1;
+ while (dc <= pathend_last) {
clen = mbrtowc(&wc, sc, MB_LEN_MAX, &mbs);
if (clen == (size_t)-1 || clen == (size_t)-2) {
- wc = *sc;
+ /* XXX See initial comment #2. */
+ wc = (unsigned char)*sc;
clen = 1;
memset(&mbs, 0, sizeof(mbs));
}
- if ((*dc++ = wc) == EOS)
+ if ((*dc++ = wc) == EOS) {
+ too_long = 0;
break;
+ }
sc += clen;
}
- if (!match(pathend, pattern, restpattern)) {
+ if (too_long && (err = err_aborted(pglob, ENAMETOOLONG,
+ buf))) {
+ errno = ENAMETOOLONG;
+ break;
+ }
+ if (too_long || !match(pathend, pattern, restpattern)) {
*pathend = EOS;
+ errno = 0;
continue;
}
+ if (errno == 0)
+ errno = saverrno;
err = glob2(pathbuf, --dc, pathend_last, restpattern,
pglob, limit);
if (err)
break;
+ errno = 0;
}
+ saverrno2 = errno;
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
(*pglob->gl_closedir)(dirp);
else
closedir(dirp);
- return(err);
+ errno = saverrno2;
+
+ if (err)
+ return (err);
+
+ if (dp == NULL && errno != 0 &&
+ (err = err_aborted(pglob, errno, buf)))
+ return (err);
+
+ if (errno == 0)
+ errno = saverrno;
+ return (0);
}
/*
- * Extend the gl_pathv member of a glob_t structure to accomodate a new item,
+ * Extend the gl_pathv member of a glob_t structure to accommodate a new item,
* add the new item, and update gl_pathc.
*
* This assumes the BSD realloc, which only copies the block when its size
@@ -752,7 +847,8 @@
* gl_pathv points to (gl_offs + gl_pathc + 1) items.
*/
static int
-globextend(const Char *path, glob_t *pglob, struct glob_limit *limit)
+globextend(const Char *path, glob_t *pglob, struct glob_limit *limit,
+ const char *origpat)
{
char **pathv;
size_t i, newsize, len;
@@ -761,7 +857,7 @@
if ((pglob->gl_flags & GLOB_LIMIT) &&
pglob->gl_matchc > limit->l_path_lim) {
- errno = 0;
+ errno = E2BIG;
return (GLOB_NOSPACE);
}
@@ -769,7 +865,7 @@
/* realloc(NULL, newsize) is equivalent to malloc(newsize). */
pathv = realloc((void *)pglob->gl_pathv, newsize);
if (pathv == NULL)
- return(GLOB_NOSPACE);
+ return (GLOB_NOSPACE);
if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
/* first time around -- clear initial gl_offs items */
@@ -779,24 +875,32 @@
}
pglob->gl_pathv = pathv;
- for (p = path; *p++;)
- continue;
- len = MB_CUR_MAX * (size_t)(p - path); /* XXX overallocation */
- limit->l_string_cnt += len;
- if ((pglob->gl_flags & GLOB_LIMIT) &&
- limit->l_string_cnt >= GLOB_LIMIT_STRING) {
- errno = 0;
- return (GLOB_NOSPACE);
+ if (origpat != NULL)
+ copy = strdup(origpat);
+ else {
+ for (p = path; *p++ != EOS;)
+ continue;
+ len = MB_CUR_MAX * (size_t)(p - path); /* XXX overallocation */
+ if ((copy = malloc(len)) != NULL) {
+ if (g_Ctoc(path, copy, len)) {
+ free(copy);
+ errno = E2BIG;
+ return (GLOB_NOSPACE);
+ }
+ }
}
- if ((copy = malloc(len)) != NULL) {
- if (g_Ctoc(path, copy, len)) {
+ if (copy != NULL) {
+ limit->l_string_cnt += strlen(copy) + 1;
+ if ((pglob->gl_flags & GLOB_LIMIT) &&
+ limit->l_string_cnt >= GLOB_LIMIT_STRING) {
free(copy);
+ errno = E2BIG;
return (GLOB_NOSPACE);
}
pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
}
pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
- return(copy == NULL ? GLOB_NOSPACE : 0);
+ return (copy == NULL ? GLOB_NOSPACE : 0);
}
/*
@@ -816,43 +920,45 @@
switch (c & M_MASK) {
case M_ALL:
if (pat == patend)
- return(1);
+ return (1);
do
if (match(name, pat, patend))
- return(1);
+ return (1);
while (*name++ != EOS);
- return(0);
+ return (0);
case M_ONE:
if (*name++ == EOS)
- return(0);
+ return (0);
break;
case M_SET:
ok = 0;
if ((k = *name++) == EOS)
- return(0);
- if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
+ return (0);
+ if ((negate_range = ((*pat & M_MASK) == M_NOT)) != 0)
++pat;
while (((c = *pat++) & M_MASK) != M_END)
if ((*pat & M_MASK) == M_RNG) {
if (table->__collate_load_error ?
- CHAR(c) <= CHAR(k) && CHAR(k) <= CHAR(pat[1]) :
- __collate_range_cmp(table, CHAR(c), CHAR(k)) <= 0
- && __collate_range_cmp(table, CHAR(k), CHAR(pat[1])) <= 0
- )
+ CHAR(c) <= CHAR(k) &&
+ CHAR(k) <= CHAR(pat[1]) :
+ __wcollate_range_cmp(CHAR(c),
+ CHAR(k)) <= 0 &&
+ __wcollate_range_cmp(CHAR(k),
+ CHAR(pat[1])) <= 0)
ok = 1;
pat += 2;
} else if (c == k)
ok = 1;
if (ok == negate_range)
- return(0);
+ return (0);
break;
default:
if (*name++ != c)
- return(0);
+ return (0);
break;
}
}
- return(*name == EOS);
+ return (*name == EOS);
}
/* Free allocated data belonging to a glob_t structure. */
@@ -875,25 +981,27 @@
static DIR *
g_opendir(Char *str, glob_t *pglob)
{
- char buf[MAXPATHLEN];
+ char buf[MAXPATHLEN + MB_LEN_MAX - 1];
- if (!*str)
+ if (*str == EOS)
strcpy(buf, ".");
else {
- if (g_Ctoc(str, buf, sizeof(buf)))
+ if (g_Ctoc(str, buf, sizeof(buf))) {
+ errno = ENAMETOOLONG;
return (NULL);
+ }
}
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- return((*pglob->gl_opendir)(buf));
+ return ((*pglob->gl_opendir)(buf));
- return(opendir(buf));
+ return (opendir(buf));
}
static int
g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
{
- char buf[MAXPATHLEN];
+ char buf[MAXPATHLEN + MB_LEN_MAX - 1];
if (g_Ctoc(fn, buf, sizeof(buf))) {
errno = ENAMETOOLONG;
@@ -901,13 +1009,13 @@
}
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
return((*pglob->gl_lstat)(buf, sb));
- return(lstat(buf, sb));
+ return (lstat(buf, sb));
}
static int
g_stat(Char *fn, struct stat *sb, glob_t *pglob)
{
- char buf[MAXPATHLEN];
+ char buf[MAXPATHLEN + MB_LEN_MAX - 1];
if (g_Ctoc(fn, buf, sizeof(buf))) {
errno = ENAMETOOLONG;
@@ -914,8 +1022,8 @@
return (-1);
}
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- return((*pglob->gl_stat)(buf, sb));
- return(stat(buf, sb));
+ return ((*pglob->gl_stat)(buf, sb));
+ return (stat(buf, sb));
}
static const Char *
@@ -937,10 +1045,14 @@
memset(&mbs, 0, sizeof(mbs));
while (len >= MB_CUR_MAX) {
- clen = wcrtomb(buf, *str, &mbs);
- if (clen == (size_t)-1)
- return (1);
- if (*str == L'\0')
+ clen = wcrtomb(buf, CHAR(*str), &mbs);
+ if (clen == (size_t)-1) {
+ /* XXX See initial comment #2. */
+ *buf = (char)CHAR(*str);
+ clen = 1;
+ memset(&mbs, 0, sizeof(mbs));
+ }
+ if (CHAR(*str) == EOS)
return (0);
str++;
buf += clen;
@@ -949,6 +1061,29 @@
return (1);
}
+static int
+err_nomatch(glob_t *pglob, struct glob_limit *limit, const char *origpat) {
+ /*
+ * If there was no match we are going to append the origpat
+ * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
+ * and the origpat did not contain any magic characters
+ * GLOB_NOMAGIC is there just for compatibility with csh.
+ */
+ if ((pglob->gl_flags & GLOB_NOCHECK) ||
+ ((pglob->gl_flags & GLOB_NOMAGIC) &&
+ !(pglob->gl_flags & GLOB_MAGCHAR)))
+ return (globextend(NULL, pglob, limit, origpat));
+ return (GLOB_NOMATCH);
+}
+
+static int
+err_aborted(glob_t *pglob, int err, char *buf) {
+ if ((pglob->gl_errfunc != NULL && pglob->gl_errfunc(buf, err)) ||
+ (pglob->gl_flags & GLOB_ERR))
+ return (GLOB_ABORTED);
+ return (0);
+}
+
#ifdef DEBUG
static void
qprintf(const char *str, Char *s)
@@ -955,15 +1090,17 @@
{
Char *p;
- (void)printf("%s:\n", str);
- for (p = s; *p; p++)
- (void)printf("%c", CHAR(*p));
- (void)printf("\n");
- for (p = s; *p; p++)
- (void)printf("%c", *p & M_PROTECT ? '"' : ' ');
- (void)printf("\n");
- for (p = s; *p; p++)
- (void)printf("%c", ismeta(*p) ? '_' : ' ');
- (void)printf("\n");
+ (void)printf("%s\n", str);
+ if (s != NULL) {
+ for (p = s; *p != EOS; p++)
+ (void)printf("%c", (char)CHAR(*p));
+ (void)printf("\n");
+ for (p = s; *p != EOS; p++)
+ (void)printf("%c", (isprot(*p) ? '\\' : ' '));
+ (void)printf("\n");
+ for (p = s; *p != EOS; p++)
+ (void)printf("%c", (ismeta(*p) ? '_' : ' '));
+ (void)printf("\n");
+ }
}
#endif
Modified: trunk/lib/libc/gen/initgroups.3
===================================================================
--- trunk/lib/libc/gen/initgroups.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/initgroups.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)initgroups.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/initgroups.3 194494 2009-06-19 15:58:24Z brooks $
.\"
.Dd June 4, 1993
.Dt INITGROUPS 3
Property changes on: trunk/lib/libc/gen/initgroups.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/initgroups.c
===================================================================
--- trunk/lib/libc/gen/initgroups.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/initgroups.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)initgroups.c 8.1 (Berkeley) 6/4/93";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/initgroups.c 194494 2009-06-19 15:58:24Z brooks $");
#include <sys/param.h>
Modified: trunk/lib/libc/gen/isatty.c
===================================================================
--- trunk/lib/libc/gen/isatty.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/isatty.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)isatty.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/isatty.c 165903 2007-01-09 00:28:16Z imp $");
#include <termios.h>
#include <unistd.h>
Modified: trunk/lib/libc/gen/isgreater.3
===================================================================
--- trunk/lib/libc/gen/isgreater.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/isgreater.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2003 David Schultz <das at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -22,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/isgreater.3 208291 2010-05-19 08:57:53Z uqs $
.\"
.Dd February 12, 2003
.Dt ISGREATER 3
Property changes on: trunk/lib/libc/gen/isgreater.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/isinf.c
===================================================================
--- trunk/lib/libc/gen/isinf.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/isinf.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/isinf.c 131898 2004-07-10 15:52:26Z marcel $
*/
#include <math.h>
Modified: trunk/lib/libc/gen/isnan.c
===================================================================
--- trunk/lib/libc/gen/isnan.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/isnan.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 David Schultz <das at FreeBSD.ORG>
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/isnan.c 242894 2012-11-11 13:28:04Z dim $
*/
#include <math.h>
Modified: trunk/lib/libc/gen/jrand48.c
===================================================================
--- trunk/lib/libc/gen/jrand48.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/jrand48.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,13 +13,16 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/jrand48.c 310320 2016-12-20 07:50:49Z ed $");
+#include <stdint.h>
+
#include "rand48.h"
long
jrand48(unsigned short xseed[3])
{
+
_dorand48(xseed);
- return ((long) xseed[2] << 16) + (long) xseed[1];
+ return ((int32_t)(((uint32_t)xseed[2] << 16) | (uint32_t)xseed[1]));
}
Modified: trunk/lib/libc/gen/lcong48.c
===================================================================
--- trunk/lib/libc/gen/lcong48.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/lcong48.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/lcong48.c 92986 2002-03-22 21:53:29Z obrien $");
#include "rand48.h"
Modified: trunk/lib/libc/gen/ldexp.3
===================================================================
--- trunk/lib/libc/gen/ldexp.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ldexp.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -30,7 +31,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ldexp.3 8.2 (Berkeley) 4/19/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/ldexp.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd March 4, 2005
.Dt LDEXP 3
Property changes on: trunk/lib/libc/gen/ldexp.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/ldexp.c
===================================================================
--- trunk/lib/libc/gen/ldexp.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ldexp.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* @(#)s_scalbn.c 5.1 93/09/24 */
/* @(#)fdlibm.h 5.1 93/09/24 */
/*
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/ldexp.c 140607 2005-01-22 06:03:40Z das $");
#include <sys/types.h>
#include <machine/endian.h>
Modified: trunk/lib/libc/gen/libc_dlopen.c
===================================================================
--- trunk/lib/libc/gen/libc_dlopen.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/libc_dlopen.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2011 Xin Li <delphij at FreeBSD.org>
* All rights reserved.
@@ -23,11 +24,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/libc_dlopen.c 228843 2011-12-23 15:00:37Z cperciva $
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/libc_dlopen.c 228843 2011-12-23 15:00:37Z cperciva $");
#include <dlfcn.h>
#include <stddef.h>
Modified: trunk/lib/libc/gen/lockf.3
===================================================================
--- trunk/lib/libc/gen/lockf.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/lockf.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $NetBSD: lockf.3,v 1.10 2008/04/30 13:10:50 martin Exp $
.\"
.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,9 +28,9 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/lockf.3 255486 2013-09-12 00:53:38Z bdrewery $
.\"
-.Dd December 19, 1997
+.Dd September 11, 2013
.Dt LOCKF 3
.Os
.Sh NAME
@@ -40,7 +41,7 @@
.Sh SYNOPSIS
.In unistd.h
.Ft int
-.Fn lockf "int filedes" "int function" "off_t size"
+.Fn lockf "int fd" "int function" "off_t size"
.Sh DESCRIPTION
The
.Fn lockf
@@ -52,7 +53,7 @@
All the locks for a process are removed when the process terminates.
.Pp
The argument
-.Fa filedes
+.Fa fd
is an open file descriptor.
The file descriptor must have been opened either for write-only
.Dv ( O_WRONLY )
@@ -207,7 +208,7 @@
and the section is already locked by another process.
.It Bq Er EBADF
The argument
-.Fa filedes
+.Fa fd
is not a valid open file descriptor.
.Pp
The argument
@@ -217,7 +218,7 @@
or
.Dv F_TLOCK ,
and
-.Fa filedes
+.Fa fd
is not a valid file descriptor open for writing.
.It Bq Er EDEADLK
The argument
@@ -243,7 +244,7 @@
.Dv F_TEST .
.Pp
The argument
-.Fa filedes
+.Fa fd
refers to a file that does not support locking.
.It Bq Er ENOLCK
The argument
Property changes on: trunk/lib/libc/gen/lockf.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/lockf.c
===================================================================
--- trunk/lib/libc/gen/lockf.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/lockf.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $NetBSD: lockf.c,v 1.3 2008/04/28 20:22:59 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -29,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/lockf.c 292762 2015-12-27 00:42:13Z kib $");
#include "namespace.h"
#include <errno.h>
@@ -36,6 +37,7 @@
#include <fcntl.h>
#include <unistd.h>
#include "un-namespace.h"
+#include "libc_private.h"
int
lockf(int filedes, int function, off_t size)
@@ -62,9 +64,12 @@
break;
case F_TEST:
fl.l_type = F_WRLCK;
- if (_fcntl(filedes, F_GETLK, &fl) == -1)
+ if (((int (*)(int, int, ...))
+ __libc_interposing[INTERPOS_fcntl])(filedes, F_GETLK, &fl)
+ == -1)
return (-1);
- if (fl.l_type == F_UNLCK || (fl.l_sysid == 0 && fl.l_pid == getpid()))
+ if (fl.l_type == F_UNLCK || (fl.l_sysid == 0 &&
+ fl.l_pid == getpid()))
return (0);
errno = EAGAIN;
return (-1);
@@ -75,5 +80,6 @@
/* NOTREACHED */
}
- return (_fcntl(filedes, cmd, &fl));
+ return (((int (*)(int, int, ...))
+ __libc_interposing[INTERPOS_fcntl])(filedes, cmd, &fl));
}
Modified: trunk/lib/libc/gen/lrand48.c
===================================================================
--- trunk/lib/libc/gen/lrand48.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/lrand48.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/lrand48.c 92986 2002-03-22 21:53:29Z obrien $");
#include "rand48.h"
Modified: trunk/lib/libc/gen/makecontext.3
===================================================================
--- trunk/lib/libc/gen/makecontext.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/makecontext.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2002 Packet Design, LLC.
.\" All rights reserved.
.\"
@@ -33,9 +34,9 @@
.\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
.\" THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/makecontext.3 330133 2018-02-28 22:39:47Z jhb $
.\"
-.Dd September 10, 2002
+.Dd January 31, 2018
.Dt MAKECONTEXT 3
.Os
.Sh NAME
@@ -68,11 +69,16 @@
The
.Fa argc
argument
-must be equal to the number of additional arguments provided to
+must be equal to the number of additional arguments of type
+.Vt int
+provided to
.Fn makecontext
-and also equal to the number of arguments to
-.Fn func ,
-or else the behavior is undefined.
+and also equal to the number of arguments of type
+.Vt int
+to
+.Fn func ;
+otherwise ,
+the behavior is undefined.
.Pp
The
.Fa "ucp->uc_link"
Property changes on: trunk/lib/libc/gen/makecontext.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/modf.3
===================================================================
--- trunk/lib/libc/gen/modf.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/modf.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -30,7 +31,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)modf.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/modf.3 177710 2008-03-29 16:19:35Z das $
.\"
.Dd March 29, 2008
.Dt MODF 3
Property changes on: trunk/lib/libc/gen/modf.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/lib/libc/gen/modf.c
===================================================================
--- trunk/lib/libc/gen/modf.c (rev 0)
+++ trunk/lib/libc/gen/modf.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -0,0 +1,139 @@
+/* $MidnightBSD$ */
+/* @(#)s_modf.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/modf.c 226606 2011-10-21 06:40:36Z das $");
+
+/*
+ * modf(double x, double *iptr)
+ * return fraction part of x, and return x's integral part in *iptr.
+ * Method:
+ * Bit twiddling.
+ *
+ * Exception:
+ * No exception.
+ */
+
+#include <sys/types.h>
+#include <machine/endian.h>
+#include <math.h>
+
+/* Bit fiddling routines copied from msun/src/math_private.h,v 1.15 */
+
+#if BYTE_ORDER == BIG_ENDIAN
+
+typedef union
+{
+ double value;
+ struct
+ {
+ u_int32_t msw;
+ u_int32_t lsw;
+ } parts;
+} ieee_double_shape_type;
+
+#endif
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+
+typedef union
+{
+ double value;
+ struct
+ {
+ u_int32_t lsw;
+ u_int32_t msw;
+ } parts;
+} ieee_double_shape_type;
+
+#endif
+
+/* Get two 32 bit ints from a double. */
+
+#define EXTRACT_WORDS(ix0,ix1,d) \
+do { \
+ ieee_double_shape_type ew_u; \
+ ew_u.value = (d); \
+ (ix0) = ew_u.parts.msw; \
+ (ix1) = ew_u.parts.lsw; \
+} while (0)
+
+/* Get the more significant 32 bit int from a double. */
+
+#define GET_HIGH_WORD(i,d) \
+do { \
+ ieee_double_shape_type gh_u; \
+ gh_u.value = (d); \
+ (i) = gh_u.parts.msw; \
+} while (0)
+
+/* Set a double from two 32 bit ints. */
+
+#define INSERT_WORDS(d,ix0,ix1) \
+do { \
+ ieee_double_shape_type iw_u; \
+ iw_u.parts.msw = (ix0); \
+ iw_u.parts.lsw = (ix1); \
+ (d) = iw_u.value; \
+} while (0)
+
+static const double one = 1.0;
+
+double
+modf(double x, double *iptr)
+{
+ int32_t i0,i1,j0;
+ u_int32_t i;
+ EXTRACT_WORDS(i0,i1,x);
+ j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */
+ if(j0<20) { /* integer part in high x */
+ if(j0<0) { /* |x|<1 */
+ INSERT_WORDS(*iptr,i0&0x80000000,0); /* *iptr = +-0 */
+ return x;
+ } else {
+ i = (0x000fffff)>>j0;
+ if(((i0&i)|i1)==0) { /* x is integral */
+ u_int32_t high;
+ *iptr = x;
+ GET_HIGH_WORD(high,x);
+ INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ return x;
+ } else {
+ INSERT_WORDS(*iptr,i0&(~i),0);
+ return x - *iptr;
+ }
+ }
+ } else if (j0>51) { /* no fraction part */
+ u_int32_t high;
+ if (j0 == 0x400) { /* inf/NaN */
+ *iptr = x;
+ return 0.0 / x;
+ }
+ *iptr = x*one;
+ GET_HIGH_WORD(high,x);
+ INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ return x;
+ } else { /* fraction part in low x */
+ i = ((u_int32_t)(0xffffffff))>>(j0-20);
+ if((i1&i)==0) { /* x is integral */
+ u_int32_t high;
+ *iptr = x;
+ GET_HIGH_WORD(high,x);
+ INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ return x;
+ } else {
+ INSERT_WORDS(*iptr,i0,i1&(~i));
+ return x - *iptr;
+ }
+ }
+}
Property changes on: trunk/lib/libc/gen/modf.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/gen/mrand48.c
===================================================================
--- trunk/lib/libc/gen/mrand48.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/mrand48.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,8 +13,10 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/mrand48.c 310320 2016-12-20 07:50:49Z ed $");
+#include <stdint.h>
+
#include "rand48.h"
extern unsigned short _rand48_seed[3];
@@ -21,6 +24,8 @@
long
mrand48(void)
{
+
_dorand48(_rand48_seed);
- return ((long) _rand48_seed[2] << 16) + (long) _rand48_seed[1];
+ return ((int32_t)(((uint32_t)_rand48_seed[2] << 16) |
+ (uint32_t)_rand48_seed[1]));
}
Modified: trunk/lib/libc/gen/nftw.c
===================================================================
--- trunk/lib/libc/gen/nftw.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/nftw.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,4 +1,5 @@
-/* $OpenBSD: nftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $ */
+/* $MidnightBSD$ */
+/* $OpenBSD: nftw.c,v 1.7 2006/03/31 19:41:44 millert Exp $ */
/*
* Copyright (c) 2003, 2004 Todd C. Miller <Todd.Miller at courtesan.com>
@@ -20,14 +21,8 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: nftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-#endif
-
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/nftw.c 239160 2012-08-09 22:05:40Z jilles $");
#include <sys/types.h>
#include <sys/stat.h>
@@ -71,6 +66,8 @@
continue;
fnflag = FTW_D;
break;
+ case FTS_DC:
+ continue;
case FTS_DNR:
fnflag = FTW_DNR;
break;
@@ -93,9 +90,6 @@
case FTS_SLNONE:
fnflag = FTW_SLN;
break;
- case FTS_DC:
- errno = ELOOP;
- /* FALLTHROUGH */
default:
error = -1;
goto done;
Modified: trunk/lib/libc/gen/nice.3
===================================================================
--- trunk/lib/libc/gen/nice.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/nice.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)nice.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/nice.3 313479 2017-02-09 21:19:24Z ngie $
.\"
-.Dd June 4, 1993
+.Dd February 28, 2015
.Dt NICE 3
.Os
.Sh NAME
@@ -48,9 +49,9 @@
.Pp
The
.Fn nice
-function obtains the scheduling priority of the process
-from the system and sets it to the priority value specified in
-.Fa incr .
+function adds
+.Fa incr
+to the scheduling priority of the process.
The priority is a value in the range -20 to 20.
The default priority is 0; lower priorities cause more favorable scheduling.
Only the super-user may lower priorities.
@@ -57,11 +58,39 @@
.Pp
Children inherit the priority of their parent processes via
.Xr fork 2 .
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn nice
+returns 0, and
+.Va errno
+is unchanged.
+Otherwise, \-1 is returned, the process' nice value is not changed, and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn nice
+function will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The
+.Fa incr
+argument is negative and the caller does not have appropriate privileges.
+.El
.Sh SEE ALSO
.Xr nice 1 ,
.Xr fork 2 ,
.Xr setpriority 2 ,
.Xr renice 8
+.Sh STANDARDS
+The
+.Fn nice
+function conforms to
+.St -p1003.1-2008
+except for the return value.
+This implementation returns 0 upon successful completion but
+the standard requires returning the new nice value,
+which could be \-1.
.Sh HISTORY
A
.Fn nice
Property changes on: trunk/lib/libc/gen/nice.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/nice.c
===================================================================
--- trunk/lib/libc/gen/nice.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/nice.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)nice.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/nice.c 313479 2017-02-09 21:19:24Z ngie $");
#include <sys/types.h>
#include <sys/time.h>
@@ -43,14 +44,20 @@
* Backwards compatible nice.
*/
int
-nice(incr)
- int incr;
+nice(int incr)
{
- int prio;
+ int saverrno, prio;
+ saverrno = errno;
errno = 0;
prio = getpriority(PRIO_PROCESS, 0);
- if (prio == -1 && errno)
+ if (prio == -1 && errno != 0)
return (-1);
- return (setpriority(PRIO_PROCESS, 0, prio + incr));
+ if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) {
+ if (errno == EACCES)
+ errno = EPERM;
+ return (-1);
+ }
+ errno = saverrno;
+ return (0);
}
Modified: trunk/lib/libc/gen/nlist.3
===================================================================
--- trunk/lib/libc/gen/nlist.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/nlist.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)nlist.3 8.3 (Berkeley) 4/19/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/nlist.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd April 19, 1994
.Dt NLIST 3
Property changes on: trunk/lib/libc/gen/nlist.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/nlist.c
===================================================================
--- trunk/lib/libc/gen/nlist.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/nlist.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/nlist.c 241046 2012-09-29 11:54:34Z jilles $");
#include "namespace.h"
#include <sys/param.h>
@@ -66,7 +67,7 @@
{
int fd, n;
- fd = _open(name, O_RDONLY, 0);
+ fd = _open(name, O_RDONLY | O_CLOEXEC, 0);
if (fd < 0)
return (-1);
n = __fdnlist(fd, list);
Modified: trunk/lib/libc/gen/nrand48.c
===================================================================
--- trunk/lib/libc/gen/nrand48.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/nrand48.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/nrand48.c 92986 2002-03-22 21:53:29Z obrien $");
#include "rand48.h"
Modified: trunk/lib/libc/gen/opendir.c
===================================================================
--- trunk/lib/libc/gen/opendir.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/opendir.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)opendir.c 8.8 (Berkeley) 5/1/95";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/opendir.c 309485 2016-12-03 17:17:42Z ngie $");
#include "namespace.h"
#include <sys/param.h>
@@ -46,9 +47,10 @@
#include <unistd.h>
#include "un-namespace.h"
+#include "gen-private.h"
#include "telldir.h"
-static DIR * __opendir_common(int, const char *, int);
+static DIR * __opendir_common(int, int, bool);
/*
* Open a directory.
@@ -66,18 +68,10 @@
DIR *
fdopendir(int fd)
{
- struct stat statb;
- /* Check that fd is associated with a directory. */
- if (_fstat(fd, &statb) != 0)
- return (NULL);
- if (!S_ISDIR(statb.st_mode)) {
- errno = ENOTDIR;
- return (NULL);
- }
if (_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
return (NULL);
- return (__opendir_common(fd, NULL, DTF_HIDEW|DTF_NODUP));
+ return (__opendir_common(fd, DTF_HIDEW|DTF_NODUP, true));
}
DIR *
@@ -84,12 +78,22 @@
__opendir2(const char *name, int flags)
{
int fd;
+ DIR *dir;
+ int saved_errno;
+ if ((flags & (__DTF_READALL | __DTF_SKIPREAD)) != 0)
+ return (NULL);
if ((fd = _open(name,
O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC)) == -1)
return (NULL);
- return __opendir_common(fd, name, flags);
+ dir = __opendir_common(fd, flags, false);
+ if (dir == NULL) {
+ saved_errno = errno;
+ _close(fd);
+ errno = saved_errno;
+ }
+ return (dir);
}
static int
@@ -101,10 +105,181 @@
}
/*
+ * For a directory at the top of a unionfs stack, the entire directory's
+ * contents are read and cached locally until the next call to rewinddir().
+ * For the fdopendir() case, the initial seek position must be preserved.
+ * For rewinddir(), the full directory should always be re-read from the
+ * beginning.
+ *
+ * If an error occurs, the existing buffer and state of 'dirp' is left
+ * unchanged.
+ */
+bool
+_filldir(DIR *dirp, bool use_current_pos)
+{
+ struct dirent **dpv;
+ char *buf, *ddptr, *ddeptr;
+ off_t pos;
+ int fd2, incr, len, n, saved_errno, space;
+
+ len = 0;
+ space = 0;
+ buf = NULL;
+ ddptr = NULL;
+
+ /*
+ * Use the system page size if that is a multiple of DIRBLKSIZ.
+ * Hopefully this can be a big win someday by allowing page
+ * trades to user space to be done by _getdirentries().
+ */
+ incr = getpagesize();
+ if ((incr % DIRBLKSIZ) != 0)
+ incr = DIRBLKSIZ;
+
+ /*
+ * The strategy here is to read all the directory
+ * entries into a buffer, sort the buffer, and
+ * remove duplicate entries by setting the inode
+ * number to zero.
+ *
+ * We reopen the directory because _getdirentries()
+ * on a MNT_UNION mount modifies the open directory,
+ * making it refer to the lower directory after the
+ * upper directory's entries are exhausted.
+ * This would otherwise break software that uses
+ * the directory descriptor for fchdir or *at
+ * functions, such as fts.c.
+ */
+ if ((fd2 = _openat(dirp->dd_fd, ".", O_RDONLY | O_CLOEXEC)) == -1)
+ return (false);
+
+ if (use_current_pos) {
+ pos = lseek(dirp->dd_fd, 0, SEEK_CUR);
+ if (pos == -1 || lseek(fd2, pos, SEEK_SET) == -1) {
+ saved_errno = errno;
+ _close(fd2);
+ errno = saved_errno;
+ return (false);
+ }
+ }
+
+ do {
+ /*
+ * Always make at least DIRBLKSIZ bytes
+ * available to _getdirentries
+ */
+ if (space < DIRBLKSIZ) {
+ space += incr;
+ len += incr;
+ buf = reallocf(buf, len);
+ if (buf == NULL) {
+ saved_errno = errno;
+ _close(fd2);
+ errno = saved_errno;
+ return (false);
+ }
+ ddptr = buf + (len - space);
+ }
+
+ n = _getdirentries(fd2, ddptr, space, &dirp->dd_seek);
+ if (n > 0) {
+ ddptr += n;
+ space -= n;
+ }
+ if (n < 0) {
+ saved_errno = errno;
+ _close(fd2);
+ errno = saved_errno;
+ return (false);
+ }
+ } while (n > 0);
+ _close(fd2);
+
+ ddeptr = ddptr;
+
+ /*
+ * There is now a buffer full of (possibly) duplicate
+ * names.
+ */
+ dirp->dd_buf = buf;
+
+ /*
+ * Go round this loop twice...
+ *
+ * Scan through the buffer, counting entries.
+ * On the second pass, save pointers to each one.
+ * Then sort the pointers and remove duplicate names.
+ */
+ for (dpv = NULL;;) {
+ n = 0;
+ ddptr = buf;
+ while (ddptr < ddeptr) {
+ struct dirent *dp;
+
+ dp = (struct dirent *) ddptr;
+ if ((long)dp & 03L)
+ break;
+ if ((dp->d_reclen <= 0) ||
+ (dp->d_reclen > (ddeptr + 1 - ddptr)))
+ break;
+ ddptr += dp->d_reclen;
+ if (dp->d_fileno) {
+ if (dpv)
+ dpv[n] = dp;
+ n++;
+ }
+ }
+
+ if (dpv) {
+ struct dirent *xp;
+
+ /*
+ * This sort must be stable.
+ */
+ mergesort(dpv, n, sizeof(*dpv), opendir_compar);
+
+ dpv[n] = NULL;
+ xp = NULL;
+
+ /*
+ * Scan through the buffer in sort order,
+ * zapping the inode number of any
+ * duplicate names.
+ */
+ for (n = 0; dpv[n]; n++) {
+ struct dirent *dp = dpv[n];
+
+ if ((xp == NULL) ||
+ strcmp(dp->d_name, xp->d_name)) {
+ xp = dp;
+ } else {
+ dp->d_fileno = 0;
+ }
+ if (dp->d_type == DT_WHT &&
+ (dirp->dd_flags & DTF_HIDEW))
+ dp->d_fileno = 0;
+ }
+
+ free(dpv);
+ break;
+ } else {
+ dpv = malloc((n+1) * sizeof(struct dirent *));
+ if (dpv == NULL)
+ break;
+ }
+ }
+
+ dirp->dd_len = len;
+ dirp->dd_size = ddptr - dirp->dd_buf;
+ return (true);
+}
+
+
+/*
* Common routine for opendir(3), __opendir2(3) and fdopendir(3).
*/
static DIR *
-__opendir_common(int fd, const char *name, int flags)
+__opendir_common(int fd, int flags, bool use_current_pos)
{
DIR *dirp;
int incr;
@@ -114,6 +289,11 @@
if ((dirp = malloc(sizeof(DIR) + sizeof(struct _telldir))) == NULL)
return (NULL);
+ dirp->dd_buf = NULL;
+ dirp->dd_fd = fd;
+ dirp->dd_flags = flags;
+ dirp->dd_loc = 0;
+ dirp->dd_lock = NULL;
dirp->dd_td = (struct _telldir *)((char *)dirp + sizeof(DIR));
LIST_INIT(&dirp->dd_td->td_locq);
dirp->dd_td->td_loccnt = 0;
@@ -142,164 +322,40 @@
}
if (unionstack) {
- int len = 0;
- int space = 0;
- char *buf = 0;
- char *ddptr = 0;
- char *ddeptr;
- int n;
- struct dirent **dpv;
-
- /*
- * The strategy here is to read all the directory
- * entries into a buffer, sort the buffer, and
- * remove duplicate entries by setting the inode
- * number to zero.
- */
-
- do {
- /*
- * Always make at least DIRBLKSIZ bytes
- * available to _getdirentries
- */
- if (space < DIRBLKSIZ) {
- space += incr;
- len += incr;
- buf = reallocf(buf, len);
- if (buf == NULL)
- goto fail;
- ddptr = buf + (len - space);
- }
-
- n = _getdirentries(fd, ddptr, space, &dirp->dd_seek);
- if (n > 0) {
- ddptr += n;
- space -= n;
- }
- } while (n > 0);
-
- ddeptr = ddptr;
- flags |= __DTF_READALL;
-
- /*
- * Re-open the directory.
- * This has the effect of rewinding back to the
- * top of the union stack and is needed by
- * programs which plan to fchdir to a descriptor
- * which has also been read -- see fts.c.
- */
- if (flags & DTF_REWIND) {
- (void)_close(fd);
- if ((fd = _open(name, O_RDONLY | O_DIRECTORY)) == -1) {
- saved_errno = errno;
- free(buf);
- free(dirp);
- errno = saved_errno;
- return (NULL);
- }
- }
-
- /*
- * There is now a buffer full of (possibly) duplicate
- * names.
- */
- dirp->dd_buf = buf;
-
- /*
- * Go round this loop twice...
- *
- * Scan through the buffer, counting entries.
- * On the second pass, save pointers to each one.
- * Then sort the pointers and remove duplicate names.
- */
- for (dpv = 0;;) {
- n = 0;
- ddptr = buf;
- while (ddptr < ddeptr) {
- struct dirent *dp;
-
- dp = (struct dirent *) ddptr;
- if ((long)dp & 03L)
- break;
- if ((dp->d_reclen <= 0) ||
- (dp->d_reclen > (ddeptr + 1 - ddptr)))
- break;
- ddptr += dp->d_reclen;
- if (dp->d_fileno) {
- if (dpv)
- dpv[n] = dp;
- n++;
- }
- }
-
- if (dpv) {
- struct dirent *xp;
-
- /*
- * This sort must be stable.
- */
- mergesort(dpv, n, sizeof(*dpv),
- opendir_compar);
-
- dpv[n] = NULL;
- xp = NULL;
-
- /*
- * Scan through the buffer in sort order,
- * zapping the inode number of any
- * duplicate names.
- */
- for (n = 0; dpv[n]; n++) {
- struct dirent *dp = dpv[n];
-
- if ((xp == NULL) ||
- strcmp(dp->d_name, xp->d_name)) {
- xp = dp;
- } else {
- dp->d_fileno = 0;
- }
- if (dp->d_type == DT_WHT &&
- (flags & DTF_HIDEW))
- dp->d_fileno = 0;
- }
-
- free(dpv);
- break;
- } else {
- dpv = malloc((n+1) * sizeof(struct dirent *));
- if (dpv == NULL)
- break;
- }
- }
-
- dirp->dd_len = len;
- dirp->dd_size = ddptr - dirp->dd_buf;
+ if (!_filldir(dirp, use_current_pos))
+ goto fail;
+ dirp->dd_flags |= __DTF_READALL;
} else {
dirp->dd_len = incr;
- dirp->dd_size = 0;
dirp->dd_buf = malloc(dirp->dd_len);
if (dirp->dd_buf == NULL)
goto fail;
- dirp->dd_seek = 0;
- flags &= ~DTF_REWIND;
+ if (use_current_pos) {
+ /*
+ * Read the first batch of directory entries
+ * to prime dd_seek. This also checks if the
+ * fd passed to fdopendir() is a directory.
+ */
+ dirp->dd_size = _getdirentries(dirp->dd_fd,
+ dirp->dd_buf, dirp->dd_len, &dirp->dd_seek);
+ if (dirp->dd_size < 0) {
+ if (errno == EINVAL)
+ errno = ENOTDIR;
+ goto fail;
+ }
+ dirp->dd_flags |= __DTF_SKIPREAD;
+ } else {
+ dirp->dd_size = 0;
+ dirp->dd_seek = 0;
+ }
}
- dirp->dd_loc = 0;
- dirp->dd_fd = fd;
- dirp->dd_flags = flags;
- dirp->dd_lock = NULL;
-
- /*
- * Set up seek point for rewinddir.
- */
- dirp->dd_rewind = telldir(dirp);
-
return (dirp);
fail:
saved_errno = errno;
+ free(dirp->dd_buf);
free(dirp);
- (void)_close(fd);
errno = saved_errno;
return (NULL);
}
Modified: trunk/lib/libc/gen/pause.3
===================================================================
--- trunk/lib/libc/gen/pause.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/pause.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)pause.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/pause.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 4, 1993
.Dt PAUSE 3
Property changes on: trunk/lib/libc/gen/pause.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/pause.c
===================================================================
--- trunk/lib/libc/gen/pause.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/pause.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,13 +32,13 @@
static char sccsid[] = "@(#)pause.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/pause.c 277317 2015-01-18 11:54:20Z kib $");
-#include "namespace.h"
#include <signal.h>
#include <unistd.h>
-#include "un-namespace.h"
+#include "libc_private.h"
+
/*
* Backwards compatible pause.
*/
@@ -46,9 +47,10 @@
{
sigset_t oset;
- if (_sigprocmask(SIG_BLOCK, NULL, &oset) == -1)
+ if (sigprocmask(SIG_BLOCK, NULL, &oset) == -1)
return (-1);
- return (_sigsuspend(&oset));
+ return (sigsuspend(&oset));
}
+
__weak_reference(__pause, pause);
__weak_reference(__pause, _pause);
Modified: trunk/lib/libc/gen/pmadvise.c
===================================================================
--- trunk/lib/libc/gen/pmadvise.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/pmadvise.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* The contents of this file are in the public domain.
* Written by Garrett A. Wollman, 2000-10-07.
@@ -5,12 +6,22 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/pmadvise.c 261560 2014-02-06 19:47:17Z kib $");
#include <sys/mman.h>
+#include <errno.h>
int
posix_madvise(void *address, size_t size, int how)
{
- return madvise(address, size, how);
+ int ret, saved_errno;
+
+ saved_errno = errno;
+ if (madvise(address, size, how) == -1) {
+ ret = errno;
+ errno = saved_errno;
+ } else {
+ ret = 0;
+ }
+ return (ret);
}
Modified: trunk/lib/libc/gen/popen.3
===================================================================
--- trunk/lib/libc/gen/popen.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/popen.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)popen.3 8.2 (Berkeley) 5/3/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/popen.3 250827 2013-05-20 17:31:18Z jilles $
.\"
-.Dd May 3, 1995
+.Dd May 20, 2013
.Dt POPEN 3
.Os
.Sh NAME
@@ -79,6 +80,11 @@
.Ql r+
for reading and writing.
.Pp
+A letter
+.Ql e
+may be appended to that to request that the underlying file descriptor
+be set close-on-exec.
+.Pp
The
.Fa command
argument is a pointer to a null-terminated string
Property changes on: trunk/lib/libc/gen/popen.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/popen.c
===================================================================
--- trunk/lib/libc/gen/popen.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/popen.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -34,7 +35,7 @@
static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/popen.c 293463 2016-01-09 05:05:15Z rpokala $");
#include "namespace.h"
#include <sys/param.h>
@@ -43,6 +44,7 @@
#include <signal.h>
#include <errno.h>
+#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -71,10 +73,12 @@
{
struct pid *cur;
FILE *iop;
- int pdes[2], pid, twoway;
+ int pdes[2], pid, twoway, cloexec;
+ int pdes_unused_in_parent;
char *argv[4];
struct pid *p;
+ cloexec = strchr(type, 'e') != NULL;
/*
* Lite2 introduced two-way popen() pipes using _socketpair().
* FreeBSD's pipe() is bidirectional, so we use that.
@@ -84,10 +88,11 @@
type = "r+";
} else {
twoway = 0;
- if ((*type != 'r' && *type != 'w') || type[1])
+ if ((*type != 'r' && *type != 'w') ||
+ (type[1] && (type[1] != 'e' || type[2])))
return (NULL);
}
- if (pipe(pdes) < 0)
+ if ((cloexec ? pipe2(pdes, O_CLOEXEC) : pipe(pdes)) < 0)
return (NULL);
if ((cur = malloc(sizeof(struct pid))) == NULL) {
@@ -96,6 +101,20 @@
return (NULL);
}
+ if (*type == 'r') {
+ iop = fdopen(pdes[0], type);
+ pdes_unused_in_parent = pdes[1];
+ } else {
+ iop = fdopen(pdes[1], type);
+ pdes_unused_in_parent = pdes[0];
+ }
+ if (iop == NULL) {
+ (void)_close(pdes[0]);
+ (void)_close(pdes[1]);
+ free(cur);
+ return (NULL);
+ }
+
argv[0] = "sh";
argv[1] = "-c";
argv[2] = (char *)command;
@@ -105,9 +124,14 @@
switch (pid = vfork()) {
case -1: /* Error. */
THREAD_UNLOCK();
- (void)_close(pdes[0]);
- (void)_close(pdes[1]);
+ /*
+ * The _close() closes the unused end of pdes[], while
+ * the fclose() closes the used end of pdes[], *and* cleans
+ * up iop.
+ */
+ (void)_close(pdes_unused_in_parent);
free(cur);
+ (void)fclose(iop);
return (NULL);
/* NOTREACHED */
case 0: /* Child. */
@@ -120,20 +144,29 @@
* the compiler is free to corrupt all the local
* variables.
*/
- (void)_close(pdes[0]);
+ if (!cloexec)
+ (void)_close(pdes[0]);
if (pdes[1] != STDOUT_FILENO) {
(void)_dup2(pdes[1], STDOUT_FILENO);
- (void)_close(pdes[1]);
+ if (!cloexec)
+ (void)_close(pdes[1]);
if (twoway)
(void)_dup2(STDOUT_FILENO, STDIN_FILENO);
- } else if (twoway && (pdes[1] != STDIN_FILENO))
+ } else if (twoway && (pdes[1] != STDIN_FILENO)) {
(void)_dup2(pdes[1], STDIN_FILENO);
+ if (cloexec)
+ (void)_fcntl(pdes[1], F_SETFD, 0);
+ } else if (cloexec)
+ (void)_fcntl(pdes[1], F_SETFD, 0);
} else {
if (pdes[0] != STDIN_FILENO) {
(void)_dup2(pdes[0], STDIN_FILENO);
- (void)_close(pdes[0]);
- }
- (void)_close(pdes[1]);
+ if (!cloexec)
+ (void)_close(pdes[0]);
+ } else if (cloexec)
+ (void)_fcntl(pdes[0], F_SETFD, 0);
+ if (!cloexec)
+ (void)_close(pdes[1]);
}
SLIST_FOREACH(p, &pidlist, next)
(void)_close(fileno(p->fp));
@@ -143,14 +176,8 @@
}
THREAD_UNLOCK();
- /* Parent; assume fdopen can't fail. */
- if (*type == 'r') {
- iop = fdopen(pdes[0], type);
- (void)_close(pdes[1]);
- } else {
- iop = fdopen(pdes[1], type);
- (void)_close(pdes[0]);
- }
+ /* Parent. */
+ (void)_close(pdes_unused_in_parent);
/* Link into list of file descriptors. */
cur->fp = iop;
Modified: trunk/lib/libc/gen/posix_spawn.3
===================================================================
--- trunk/lib/libc/gen/posix_spawn.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/posix_spawn.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -32,7 +33,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/posix_spawn.3 223576 2011-06-26 18:27:17Z ed $
.\"
.Dd June 17, 2011
.Dt POSIX_SPAWN 3
Property changes on: trunk/lib/libc/gen/posix_spawn.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/posix_spawn.c
===================================================================
--- trunk/lib/libc/gen/posix_spawn.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/posix_spawn.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008 Ed Schouten <ed at FreeBSD.org>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/posix_spawn.c 301151 2016-06-01 17:39:03Z truckman $");
#include "namespace.h"
#include <sys/queue.h>
@@ -118,15 +119,18 @@
return (errno);
}
- /* Set signal masks/defaults */
+ /*
+ * Set signal masks/defaults.
+ * Use unwrapped syscall, libthr is in undefined state after vfork().
+ */
if (sa->sa_flags & POSIX_SPAWN_SETSIGMASK) {
- _sigprocmask(SIG_SETMASK, &sa->sa_sigmask, NULL);
+ __sys_sigprocmask(SIG_SETMASK, &sa->sa_sigmask, NULL);
}
if (sa->sa_flags & POSIX_SPAWN_SETSIGDEF) {
for (i = 1; i <= _SIG_MAXSIG; i++) {
if (sigismember(&sa->sa_sigdefault, i))
- if (_sigaction(i, &sigact, NULL) != 0)
+ if (__sys_sigaction(i, &sigact, NULL) != 0)
return (errno);
}
}
@@ -137,7 +141,7 @@
static int
process_file_actions_entry(posix_spawn_file_actions_entry_t *fae)
{
- int fd;
+ int fd, saved_errno;
switch (fae->fae_action) {
case FAE_OPEN:
@@ -146,8 +150,11 @@
if (fd < 0)
return (errno);
if (fd != fae->fae_fildes) {
- if (_dup2(fd, fae->fae_fildes) == -1)
- return (errno);
+ if (_dup2(fd, fae->fae_fildes) == -1) {
+ saved_errno = errno;
+ (void)_close(fd);
+ return (saved_errno);
+ }
if (_close(fd) != 0) {
if (errno == EBADF)
return (EBADF);
Modified: trunk/lib/libc/gen/posix_spawn_file_actions_addopen.3
===================================================================
--- trunk/lib/libc/gen/posix_spawn_file_actions_addopen.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/posix_spawn_file_actions_addopen.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -32,7 +33,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/posix_spawn_file_actions_addopen.3 250554 2013-05-12 05:54:58Z pluknet $
.\"
.Dd May 9, 2013
.Dt POSIX_SPAWN_FILE_ACTIONS_ADDOPEN 3
@@ -190,7 +191,7 @@
.Fa newfildes
(clearing
.Dv FD_CLOEXEC ) .
-A future update of the Standard is expected to require this behavior,
+A future update of the Standard is expected to require this behavior.
.Sh HISTORY
The
.Fn posix_spawn_file_actions_addopen ,
Property changes on: trunk/lib/libc/gen/posix_spawn_file_actions_addopen.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/posix_spawn_file_actions_init.3
===================================================================
--- trunk/lib/libc/gen/posix_spawn_file_actions_init.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/posix_spawn_file_actions_init.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -32,7 +33,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/posix_spawn_file_actions_init.3 198788 2009-11-02 12:35:38Z brueffer $
.\"
.Dd March 24, 2008
.Dt POSIX_SPAWN_FILE_ACTIONS_INIT 3
Property changes on: trunk/lib/libc/gen/posix_spawn_file_actions_init.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/posix_spawnattr_getflags.3
===================================================================
--- trunk/lib/libc/gen/posix_spawnattr_getflags.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/posix_spawnattr_getflags.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -32,7 +33,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/posix_spawnattr_getflags.3 236438 2012-06-02 08:47:26Z joel $
.\"
.Dd March 24, 2008
.Dt POSIX_SPAWNATTR_GETFLAGS 3
@@ -70,7 +71,7 @@
It is the bitwise-inclusive OR of zero or more of the following flags
(see
.Fn posix_spawn ) :
-.Bl -tag -offset indent
+.Bl -tag -width "POSIX_SPAWN_SETSCHEDPARAM" -offset indent
.It Dv POSIX_SPAWN_RESETIDS
.It Dv POSIX_SPAWN_SETPGROUP
.It Dv POSIX_SPAWN_SETSIGDEF
Property changes on: trunk/lib/libc/gen/posix_spawnattr_getflags.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/posix_spawnattr_getpgroup.3
===================================================================
--- trunk/lib/libc/gen/posix_spawnattr_getpgroup.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/posix_spawnattr_getpgroup.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -32,7 +33,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/posix_spawnattr_getpgroup.3 198788 2009-11-02 12:35:38Z brueffer $
.\"
.Dd March 24, 2008
.Dt POSIX_SPAWNATTR_GETPGROUP 3
Property changes on: trunk/lib/libc/gen/posix_spawnattr_getpgroup.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/posix_spawnattr_getschedparam.3
===================================================================
--- trunk/lib/libc/gen/posix_spawnattr_getschedparam.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/posix_spawnattr_getschedparam.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -32,7 +33,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/posix_spawnattr_getschedparam.3 198788 2009-11-02 12:35:38Z brueffer $
.\"
.Dd March 24, 2008
.Dt POSIX_SPAWNATTR_GETSCHEDPARAM 3
Property changes on: trunk/lib/libc/gen/posix_spawnattr_getschedparam.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/posix_spawnattr_getschedpolicy.3
===================================================================
--- trunk/lib/libc/gen/posix_spawnattr_getschedpolicy.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/posix_spawnattr_getschedpolicy.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -32,7 +33,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/posix_spawnattr_getschedpolicy.3 198788 2009-11-02 12:35:38Z brueffer $
.\"
.Dd March 24, 2008
.Dt POSIX_SPAWNATTR_GETSCHEDPOLICY 3
Property changes on: trunk/lib/libc/gen/posix_spawnattr_getschedpolicy.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/posix_spawnattr_getsigdefault.3
===================================================================
--- trunk/lib/libc/gen/posix_spawnattr_getsigdefault.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/posix_spawnattr_getsigdefault.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -32,7 +33,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/posix_spawnattr_getsigdefault.3 198788 2009-11-02 12:35:38Z brueffer $
.\"
.Dd March 24, 2008
.Dt POSIX_SPAWNATTR_GETSIGDEFAULT 3
Property changes on: trunk/lib/libc/gen/posix_spawnattr_getsigdefault.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/posix_spawnattr_getsigmask.3
===================================================================
--- trunk/lib/libc/gen/posix_spawnattr_getsigmask.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/posix_spawnattr_getsigmask.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -32,7 +33,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/posix_spawnattr_getsigmask.3 198788 2009-11-02 12:35:38Z brueffer $
.\"
.Dd March 24, 2008
.Dt POSIX_SPAWNATTR_GETSIGMASK 3
Property changes on: trunk/lib/libc/gen/posix_spawnattr_getsigmask.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/posix_spawnattr_init.3
===================================================================
--- trunk/lib/libc/gen/posix_spawnattr_init.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/posix_spawnattr_init.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -32,7 +33,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/posix_spawnattr_init.3 198788 2009-11-02 12:35:38Z brueffer $
.\"
.Dd March 24, 2008
.Dt POSIX_SPAWNATTR_INIT 3
Property changes on: trunk/lib/libc/gen/posix_spawnattr_init.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/psignal.3
===================================================================
--- trunk/lib/libc/gen/psignal.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/psignal.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)psignal.3 8.2 (Berkeley) 2/27/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/psignal.3 233510 2012-03-26 15:18:14Z joel $
.\"
.Dd February 4, 2011
.Dt PSIGNAL 3
@@ -79,7 +80,7 @@
If the signal number is not recognized
.Pq Xr sigaction 2 ,
the string
-.Dq "Unknown signal
+.Dq "Unknown signal"
is produced.
.Pp
The message strings can be accessed directly
Property changes on: trunk/lib/libc/gen/psignal.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/psignal.c
===================================================================
--- trunk/lib/libc/gen/psignal.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/psignal.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)psignal.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/psignal.c 165903 2007-01-09 00:28:16Z imp $");
/*
* Print the name of the signal indicated
Modified: trunk/lib/libc/gen/pututxline.c
===================================================================
--- trunk/lib/libc/gen/pututxline.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/pututxline.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2010 Ed Schouten <ed at FreeBSD.org>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/pututxline.c 249593 2013-04-17 21:08:15Z jilles $");
#include "namespace.h"
#include <sys/endian.h>
@@ -47,7 +48,7 @@
struct stat sb;
int fd;
- fd = _open(file, O_CREAT|O_RDWR|O_EXLOCK, 0644);
+ fd = _open(file, O_CREAT|O_RDWR|O_EXLOCK|O_CLOEXEC, 0644);
if (fd < 0)
return (NULL);
@@ -86,6 +87,9 @@
return (-1);
while (fread(&fe, sizeof(fe), 1, fp) == 1) {
switch (fe.fu_type) {
+ case BOOT_TIME:
+ /* Leave these intact. */
+ break;
case USER_PROCESS:
case INIT_PROCESS:
case LOGIN_PROCESS:
@@ -128,7 +132,8 @@
else
error = 0;
fclose(fp);
- errno = error;
+ if (error != 0)
+ errno = error;
return (error == 0 ? 0 : 1);
}
@@ -166,11 +171,25 @@
}
fclose(fp);
- errno = error;
+ if (ret != 0)
+ errno = error;
return (ret);
}
static void
+utx_active_init(const struct futx *fu)
+{
+ int fd;
+
+ /* Initialize utx.active with a single BOOT_TIME record. */
+ fd = _open(_PATH_UTX_ACTIVE, O_CREAT|O_RDWR|O_TRUNC, 0644);
+ if (fd < 0)
+ return;
+ _write(fd, fu, sizeof(*fu));
+ _close(fd);
+}
+
+static void
utx_active_purge(void)
{
@@ -209,7 +228,8 @@
ret = -1;
}
fclose(fp);
- errno = error;
+ if (ret == -1)
+ errno = error;
return (ret);
}
@@ -219,7 +239,7 @@
struct stat sb;
int fd;
- fd = _open(_PATH_UTX_LASTLOGIN, O_RDWR, 0644);
+ fd = _open(_PATH_UTX_LASTLOGIN, O_RDWR|O_CLOEXEC, 0644);
if (fd < 0)
return;
@@ -253,7 +273,7 @@
vec[1].iov_len = l;
l = htobe16(l);
- fd = _open(_PATH_UTX_LOG, O_CREAT|O_WRONLY|O_APPEND, 0644);
+ fd = _open(_PATH_UTX_LOG, O_CREAT|O_WRONLY|O_APPEND|O_CLOEXEC, 0644);
if (fd < 0)
return (-1);
if (_writev(fd, vec, 2) == -1)
@@ -261,7 +281,8 @@
else
error = 0;
_close(fd);
- errno = error;
+ if (error != 0)
+ errno = error;
return (error == 0 ? 0 : 1);
}
@@ -277,9 +298,11 @@
switch (fu.fu_type) {
case BOOT_TIME:
+ utx_active_init(&fu);
+ utx_lastlogin_upgrade();
+ break;
case SHUTDOWN_TIME:
utx_active_purge();
- utx_lastlogin_upgrade();
break;
case OLD_TIME:
case NEW_TIME:
Modified: trunk/lib/libc/gen/pw_scan.c
===================================================================
--- trunk/lib/libc/gen/pw_scan.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/pw_scan.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)pw_scan.c 8.3 (Berkeley) 4/2/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/pw_scan.c 195827 2009-07-22 20:46:17Z kensmith $");
/*
* This module is used to "verify" password entries by chpass(1) and
Modified: trunk/lib/libc/gen/pw_scan.h
===================================================================
--- trunk/lib/libc/gen/pw_scan.h 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/pw_scan.h 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
@@ -27,7 +28,7 @@
* SUCH DAMAGE.
*
* @(#)pw_scan.h 8.1 (Berkeley) 4/1/94
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/pw_scan.h 165903 2007-01-09 00:28:16Z imp $
*/
#define _PWSCAN_MASTER 0x01
Modified: trunk/lib/libc/gen/raise.3
===================================================================
--- trunk/lib/libc/gen/raise.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/raise.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -30,7 +31,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)raise.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/raise.3 207749 2010-05-07 17:20:15Z jilles $
.\"
.Dd May 7, 2010
.Dt RAISE 3
Property changes on: trunk/lib/libc/gen/raise.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/raise.c
===================================================================
--- trunk/lib/libc/gen/raise.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/raise.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,11 +32,13 @@
static char sccsid[] = "@(#)raise.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/raise.c 277317 2015-01-18 11:54:20Z kib $");
#include <signal.h>
#include <unistd.h>
+#include "libc_private.h"
+
__weak_reference(__raise, raise);
__weak_reference(__raise, _raise);
@@ -42,5 +45,9 @@
int
__raise(int s)
{
- return(kill(getpid(), s));
+ long id;
+
+ if (__sys_thr_self(&id) == -1)
+ return (-1);
+ return (__sys_thr_kill(id, s));
}
Modified: trunk/lib/libc/gen/rand48.3
===================================================================
--- trunk/lib/libc/gen/rand48.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/rand48.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1993 Martin Birgmeier
.\" All rights reserved.
.\"
@@ -10,7 +11,7 @@
.\" to anyone/anything when using this software.
.\"
.\" @(#)rand48.3 V1.0 MB 8 Oct 1993
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/rand48.3 240361 2012-09-11 12:55:15Z des $
.\"
.Dd September 4, 2012
.Dt RAND48 3
Property changes on: trunk/lib/libc/gen/rand48.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/rand48.h
===================================================================
--- trunk/lib/libc/gen/rand48.h 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/rand48.h 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -10,7 +11,7 @@
* of any kind. I shall in no event be liable for anything that happens
* to anyone/anything when using this software.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/rand48.h 90045 2002-02-01 01:32:19Z obrien $
*/
#ifndef _RAND48_H_
Modified: trunk/lib/libc/gen/readdir.c
===================================================================
--- trunk/lib/libc/gen/readdir.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/readdir.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)readdir.c 8.3 (Berkeley) 9/29/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/readdir.c 282979 2015-05-15 15:49:24Z julian $");
#include "namespace.h"
#include <sys/param.h>
@@ -42,6 +43,7 @@
#include "un-namespace.h"
#include "libc_private.h"
+#include "gen-private.h"
#include "telldir.h"
/*
@@ -53,19 +55,27 @@
int skip;
{
struct dirent *dp;
+ long initial_seek;
+ long initial_loc = 0;
for (;;) {
if (dirp->dd_loc >= dirp->dd_size) {
if (dirp->dd_flags & __DTF_READALL)
return (NULL);
+ initial_loc = dirp->dd_loc;
+ dirp->dd_flags &= ~__DTF_SKIPREAD;
dirp->dd_loc = 0;
}
- if (dirp->dd_loc == 0 && !(dirp->dd_flags & __DTF_READALL)) {
+ if (dirp->dd_loc == 0 &&
+ !(dirp->dd_flags & (__DTF_READALL | __DTF_SKIPREAD))) {
+ initial_seek = dirp->dd_seek;
dirp->dd_size = _getdirentries(dirp->dd_fd,
dirp->dd_buf, dirp->dd_len, &dirp->dd_seek);
if (dirp->dd_size <= 0)
return (NULL);
+ _fixtelldir(dirp, initial_seek, initial_loc);
}
+ dirp->dd_flags &= ~__DTF_SKIPREAD;
dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc);
if ((long)dp & 03L) /* bogus pointer check */
return (NULL);
Modified: trunk/lib/libc/gen/readpassphrase.3
===================================================================
--- trunk/lib/libc/gen/readpassphrase.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/readpassphrase.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $OpenBSD: readpassphrase.3,v 1.17 2007/05/31 19:19:28 jmc Exp $
.\"
.\" Copyright (c) 2000, 2002 Todd C. Miller <Todd.Miller at courtesan.com>
@@ -18,7 +19,7 @@
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/readpassphrase.3 215236 2010-11-13 10:38:06Z delphij $
.\"
.Dd May 31, 2007
.Dt READPASSPHRASE 3
Property changes on: trunk/lib/libc/gen/readpassphrase.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/readpassphrase.c
===================================================================
--- trunk/lib/libc/gen/readpassphrase.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/readpassphrase.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,4 +1,5 @@
-/* $OpenBSD: readpassphrase.c,v 1.23 2010/05/14 13:30:34 millert Exp $ */
+/* $MidnightBSD$ */
+/* $OpenBSD: readpassphrase.c,v 1.24 2013/11/24 23:51:29 deraadt Exp $ */
/*
* Copyright (c) 2000-2002, 2007, 2010
@@ -22,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/readpassphrase.c 295055 2016-01-30 00:09:30Z sobomax $");
#include "namespace.h"
#include <ctype.h>
@@ -36,6 +37,7 @@
#include <unistd.h>
#include <readpassphrase.h>
#include "un-namespace.h"
+#include "libc_private.h"
static volatile sig_atomic_t signo[NSIG];
@@ -45,7 +47,7 @@
readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
{
ssize_t nr;
- int input, output, save_errno, i, need_restart;
+ int input, output, save_errno, i, need_restart, input_is_tty;
char ch, *p, *end;
struct termios term, oterm;
struct sigaction sa, savealrm, saveint, savehup, savequit, saveterm;
@@ -67,12 +69,20 @@
* Read and write to /dev/tty if available. If not, read from
* stdin and write to stderr unless a tty is required.
*/
- if ((flags & RPP_STDIN) ||
- (input = output = _open(_PATH_TTY, O_RDWR)) == -1) {
- if (flags & RPP_REQUIRE_TTY) {
- errno = ENOTTY;
- return(NULL);
+ input_is_tty = 0;
+ if (!(flags & RPP_STDIN)) {
+ input = output = _open(_PATH_TTY, O_RDWR | O_CLOEXEC);
+ if (input == -1) {
+ if (flags & RPP_REQUIRE_TTY) {
+ errno = ENOTTY;
+ return(NULL);
+ }
+ input = STDIN_FILENO;
+ output = STDERR_FILENO;
+ } else {
+ input_is_tty = 1;
}
+ } else {
input = STDIN_FILENO;
output = STDERR_FILENO;
}
@@ -82,7 +92,7 @@
* If we are using a tty but are not the foreground pgrp this will
* generate SIGTTOU, so do it *before* installing the signal handlers.
*/
- if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) {
+ if (input_is_tty && tcgetattr(input, &oterm) == 0) {
memcpy(&term, &oterm, sizeof(term));
if (!(flags & RPP_ECHO_ON))
term.c_lflag &= ~(ECHO | ECHONL);
@@ -104,15 +114,15 @@
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0; /* don't restart system calls */
sa.sa_handler = handler;
- (void)_sigaction(SIGALRM, &sa, &savealrm);
- (void)_sigaction(SIGHUP, &sa, &savehup);
- (void)_sigaction(SIGINT, &sa, &saveint);
- (void)_sigaction(SIGPIPE, &sa, &savepipe);
- (void)_sigaction(SIGQUIT, &sa, &savequit);
- (void)_sigaction(SIGTERM, &sa, &saveterm);
- (void)_sigaction(SIGTSTP, &sa, &savetstp);
- (void)_sigaction(SIGTTIN, &sa, &savettin);
- (void)_sigaction(SIGTTOU, &sa, &savettou);
+ (void)__libc_sigaction(SIGALRM, &sa, &savealrm);
+ (void)__libc_sigaction(SIGHUP, &sa, &savehup);
+ (void)__libc_sigaction(SIGINT, &sa, &saveint);
+ (void)__libc_sigaction(SIGPIPE, &sa, &savepipe);
+ (void)__libc_sigaction(SIGQUIT, &sa, &savequit);
+ (void)__libc_sigaction(SIGTERM, &sa, &saveterm);
+ (void)__libc_sigaction(SIGTSTP, &sa, &savetstp);
+ (void)__libc_sigaction(SIGTTIN, &sa, &savettin);
+ (void)__libc_sigaction(SIGTTOU, &sa, &savettou);
if (!(flags & RPP_STDIN))
(void)_write(output, prompt, strlen(prompt));
@@ -122,11 +132,11 @@
if (p < end) {
if ((flags & RPP_SEVENBIT))
ch &= 0x7f;
- if (isalpha(ch)) {
+ if (isalpha((unsigned char)ch)) {
if ((flags & RPP_FORCELOWER))
- ch = (char)tolower(ch);
+ ch = (char)tolower((unsigned char)ch);
if ((flags & RPP_FORCEUPPER))
- ch = (char)toupper(ch);
+ ch = (char)toupper((unsigned char)ch);
}
*p++ = ch;
}
@@ -142,16 +152,16 @@
errno == EINTR && !signo[SIGTTOU])
continue;
}
- (void)_sigaction(SIGALRM, &savealrm, NULL);
- (void)_sigaction(SIGHUP, &savehup, NULL);
- (void)_sigaction(SIGINT, &saveint, NULL);
- (void)_sigaction(SIGQUIT, &savequit, NULL);
- (void)_sigaction(SIGPIPE, &savepipe, NULL);
- (void)_sigaction(SIGTERM, &saveterm, NULL);
- (void)_sigaction(SIGTSTP, &savetstp, NULL);
- (void)_sigaction(SIGTTIN, &savettin, NULL);
- (void)_sigaction(SIGTTOU, &savettou, NULL);
- if (input != STDIN_FILENO)
+ (void)__libc_sigaction(SIGALRM, &savealrm, NULL);
+ (void)__libc_sigaction(SIGHUP, &savehup, NULL);
+ (void)__libc_sigaction(SIGINT, &saveint, NULL);
+ (void)__libc_sigaction(SIGQUIT, &savequit, NULL);
+ (void)__libc_sigaction(SIGPIPE, &savepipe, NULL);
+ (void)__libc_sigaction(SIGTERM, &saveterm, NULL);
+ (void)__libc_sigaction(SIGTSTP, &savetstp, NULL);
+ (void)__libc_sigaction(SIGTTIN, &savettin, NULL);
+ (void)__libc_sigaction(SIGTTOU, &savettou, NULL);
+ if (input_is_tty)
(void)_close(input);
/*
Modified: trunk/lib/libc/gen/rewinddir.c
===================================================================
--- trunk/lib/libc/gen/rewinddir.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/rewinddir.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,11 +32,17 @@
static char sccsid[] = "@(#)rewinddir.c 8.1 (Berkeley) 6/8/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/rewinddir.c 282979 2015-05-15 15:49:24Z julian $");
+#include "namespace.h"
#include <sys/types.h>
#include <dirent.h>
+#include <pthread.h>
+#include <unistd.h>
+#include "un-namespace.h"
+#include "libc_private.h"
+#include "gen-private.h"
#include "telldir.h"
void
@@ -43,6 +50,17 @@
DIR *dirp;
{
- _seekdir(dirp, dirp->dd_rewind);
- dirp->dd_rewind = telldir(dirp);
+ if (__isthreaded)
+ _pthread_mutex_lock(&dirp->dd_lock);
+ dirp->dd_flags &= ~__DTF_SKIPREAD; /* current contents are invalid */
+ if (dirp->dd_flags & __DTF_READALL)
+ _filldir(dirp, false);
+ else {
+ (void) lseek(dirp->dd_fd, 0, SEEK_SET);
+ dirp->dd_seek = 0;
+ }
+ dirp->dd_loc = 0;
+ _reclaim_telldir(dirp);
+ if (__isthreaded)
+ _pthread_mutex_unlock(&dirp->dd_lock);
}
Modified: trunk/lib/libc/gen/rfork_thread.3
===================================================================
--- trunk/lib/libc/gen/rfork_thread.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/rfork_thread.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright (c) 2000 Peter Wemm <peter at FreeBSD.org>
.\" All rights reserved.
@@ -23,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/rfork_thread.3 218385 2011-02-06 23:26:14Z jilles $
.\"
.Dd February 6, 2011
.Dt RFORK_THREAD 3
Property changes on: trunk/lib/libc/gen/rfork_thread.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/scandir.3
===================================================================
--- trunk/lib/libc/gen/scandir.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/scandir.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)scandir.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/scandir.3 208734 2010-06-02 10:20:38Z uqs $
.\"
.Dd January 3, 2010
.Dt SCANDIR 3
Property changes on: trunk/lib/libc/gen/scandir.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/scandir.c
===================================================================
--- trunk/lib/libc/gen/scandir.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/scandir.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)scandir.c 8.3 (Berkeley) 1/2/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/scandir.c 202693 2010-01-20 11:59:46Z ache $");
/*
* Scan the directory dirname calling select to make a list of selected
Modified: trunk/lib/libc/gen/seed48.c
===================================================================
--- trunk/lib/libc/gen/seed48.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/seed48.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,7 +13,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/seed48.c 92986 2002-03-22 21:53:29Z obrien $");
#include "rand48.h"
Modified: trunk/lib/libc/gen/seekdir.c
===================================================================
--- trunk/lib/libc/gen/seekdir.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/seekdir.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)seekdir.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/seekdir.c 235647 2012-05-19 12:44:27Z gleb $");
#include "namespace.h"
#include <sys/param.h>
@@ -40,6 +41,7 @@
#include "un-namespace.h"
#include "libc_private.h"
+#include "gen-private.h"
#include "telldir.h"
/*
Modified: trunk/lib/libc/gen/sem.c
===================================================================
--- trunk/lib/libc/gen/sem.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sem.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (C) 2010 David Xu <davidxu at freebsd.org>.
* Copyright (C) 2000 Jason Evans <jasone at freebsd.org>.
@@ -27,7 +28,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/sem.c 232144 2012-02-25 02:12:17Z davidxu $
*/
/*
@@ -312,15 +313,24 @@
}
static int
-_umtx_wait_uint(volatile unsigned *mtx, unsigned id, const struct timespec *timeout)
+_umtx_wait_uint(volatile unsigned *mtx, unsigned id, const struct timespec *abstime)
{
- if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 &&
- timeout->tv_nsec <= 0))) {
- errno = ETIMEDOUT;
- return (-1);
+ struct _umtx_time *tm_p, timeout;
+ size_t tm_size;
+
+ if (abstime == NULL) {
+ tm_p = NULL;
+ tm_size = 0;
+ } else {
+ timeout._clockid = CLOCK_REALTIME;
+ timeout._flags = UMTX_ABSTIME;
+ timeout._timeout = *abstime;
+ tm_p = &timeout;
+ tm_size = sizeof(timeout);
}
return _umtx_op(__DEVOLATILE(void *, mtx),
- UMTX_OP_WAIT_UINT_PRIVATE, id, NULL, __DECONST(void*, timeout));
+ UMTX_OP_WAIT_UINT_PRIVATE, id,
+ (void *)tm_size, __DECONST(void*, tm_p));
}
static int
@@ -355,7 +365,6 @@
_libc_sem_timedwait_compat(sem_t * __restrict sem,
const struct timespec * __restrict abstime)
{
- struct timespec ts, ts2;
int val, retval;
if (sem_check_validity(sem) != 0)
@@ -384,13 +393,11 @@
errno = EINVAL;
return (-1);
}
- clock_gettime(CLOCK_REALTIME, &ts);
- TIMESPEC_SUB(&ts2, abstime, &ts);
}
atomic_add_int(&(*sem)->nwaiters, 1);
pthread_cleanup_push(sem_cancel_handler, sem);
_pthread_cancel_enter(1);
- retval = _umtx_wait_uint(&(*sem)->count, 0, abstime ? &ts2 : NULL);
+ retval = _umtx_wait_uint(&(*sem)->count, 0, abstime);
_pthread_cancel_leave(0);
pthread_cleanup_pop(0);
atomic_add_int(&(*sem)->nwaiters, -1);
@@ -434,7 +441,7 @@
return ksem_post((*sem)->semid);
atomic_add_rel_int(&(*sem)->count, 1);
-
+ rmb();
if ((*sem)->nwaiters)
return _umtx_wake(&(*sem)->count);
return (0);
Modified: trunk/lib/libc/gen/sem_destroy.3
===================================================================
--- trunk/lib/libc/gen/sem_destroy.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sem_destroy.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (C) 2000 Jason Evans <jasone at FreeBSD.org>.
.\" All rights reserved.
.\"
@@ -25,7 +26,7 @@
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/sem_destroy.3 131465 2004-07-02 16:45:56Z ru $
.\"
.Dd February 15, 2000
.Dt SEM_DESTROY 3
Property changes on: trunk/lib/libc/gen/sem_destroy.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/sem_getvalue.3
===================================================================
--- trunk/lib/libc/gen/sem_getvalue.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sem_getvalue.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (C) 2000 Jason Evans <jasone at FreeBSD.org>.
.\" All rights reserved.
.\"
@@ -25,7 +26,7 @@
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/sem_getvalue.3 131465 2004-07-02 16:45:56Z ru $
.\"
.Dd February 15, 2000
.Dt SEM_GETVALUE 3
Property changes on: trunk/lib/libc/gen/sem_getvalue.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/sem_init.3
===================================================================
--- trunk/lib/libc/gen/sem_init.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sem_init.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (C) 2000 Jason Evans <jasone at FreeBSD.org>.
.\" All rights reserved.
.\"
@@ -25,7 +26,7 @@
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/sem_init.3 202133 2010-01-12 01:30:05Z davidxu $
.\"
.Dd January 9, 2010
.Dt SEM_INIT 3
Property changes on: trunk/lib/libc/gen/sem_init.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/sem_new.c
===================================================================
--- trunk/lib/libc/gen/sem_new.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sem_new.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (C) 2010 David Xu <davidxu at freebsd.org>.
* All rights reserved.
@@ -26,7 +27,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/sem_new.c 317900 2017-05-07 08:02:28Z kib $
*/
#include "namespace.h"
@@ -41,6 +42,7 @@
#include <fcntl.h>
#include <pthread.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -66,6 +68,8 @@
struct sem_nameinfo {
int open_count;
char *name;
+ dev_t dev;
+ ino_t ino;
sem_t *sem;
LIST_ENTRY(sem_nameinfo) next;
};
@@ -72,10 +76,10 @@
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t sem_llock;
-static LIST_HEAD(,sem_nameinfo) sem_list = LIST_HEAD_INITIALIZER(sem_list);
+static LIST_HEAD(, sem_nameinfo) sem_list = LIST_HEAD_INITIALIZER(sem_list);
static void
-sem_prefork()
+sem_prefork(void)
{
_pthread_mutex_lock(&sem_llock);
@@ -82,14 +86,16 @@
}
static void
-sem_postfork()
+sem_postfork(void)
{
+
_pthread_mutex_unlock(&sem_llock);
}
static void
-sem_child_postfork()
+sem_child_postfork(void)
{
+
_pthread_mutex_unlock(&sem_llock);
}
@@ -96,12 +102,8 @@
static void
sem_module_init(void)
{
- pthread_mutexattr_t ma;
- _pthread_mutexattr_init(&ma);
- _pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE);
- _pthread_mutex_init(&sem_llock, &ma);
- _pthread_mutexattr_destroy(&ma);
+ _pthread_mutex_init(&sem_llock, NULL);
_pthread_atfork(sem_prefork, sem_postfork, sem_child_postfork);
}
@@ -111,10 +113,8 @@
if (sem->_magic == SEM_MAGIC)
return (0);
- else {
- errno = EINVAL;
- return (-1);
- }
+ errno = EINVAL;
+ return (-1);
}
int
@@ -138,50 +138,64 @@
_sem_open(const char *name, int flags, ...)
{
char path[PATH_MAX];
-
struct stat sb;
va_list ap;
- struct sem_nameinfo *ni = NULL;
- sem_t *sem = NULL;
- int fd = -1, mode, len, errsave;
- int value = 0;
+ struct sem_nameinfo *ni;
+ sem_t *sem, tmp;
+ int errsave, fd, len, mode, value;
+ ni = NULL;
+ sem = NULL;
+ fd = -1;
+ value = 0;
+
if (name[0] != '/') {
errno = EINVAL;
return (SEM_FAILED);
}
name++;
-
+ strcpy(path, SEM_PREFIX);
+ if (strlcat(path, name, sizeof(path)) >= sizeof(path)) {
+ errno = ENAMETOOLONG;
+ return (SEM_FAILED);
+ }
if (flags & ~(O_CREAT|O_EXCL)) {
errno = EINVAL;
return (SEM_FAILED);
}
-
+ if ((flags & O_CREAT) != 0) {
+ va_start(ap, flags);
+ mode = va_arg(ap, int);
+ value = va_arg(ap, int);
+ va_end(ap);
+ }
+ fd = -1;
_pthread_once(&once, sem_module_init);
_pthread_mutex_lock(&sem_llock);
LIST_FOREACH(ni, &sem_list, next) {
- if (strcmp(name, ni->name) == 0) {
- if ((flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) {
- _pthread_mutex_unlock(&sem_llock);
- errno = EEXIST;
- return (SEM_FAILED);
- } else {
- ni->open_count++;
- sem = ni->sem;
- _pthread_mutex_unlock(&sem_llock);
- return (sem);
+ if (ni->name != NULL && strcmp(name, ni->name) == 0) {
+ fd = _open(path, flags | O_RDWR | O_CLOEXEC |
+ O_EXLOCK, mode);
+ if (fd == -1 || _fstat(fd, &sb) == -1) {
+ ni = NULL;
+ goto error;
}
+ if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT |
+ O_EXCL) || ni->dev != sb.st_dev ||
+ ni->ino != sb.st_ino) {
+ ni->name = NULL;
+ ni = NULL;
+ break;
+ }
+ ni->open_count++;
+ sem = ni->sem;
+ _pthread_mutex_unlock(&sem_llock);
+ _close(fd);
+ return (sem);
}
}
- if (flags & O_CREAT) {
- va_start(ap, flags);
- mode = va_arg(ap, int);
- value = va_arg(ap, int);
- va_end(ap);
- }
-
len = sizeof(*ni) + strlen(name) + 1;
ni = (struct sem_nameinfo *)malloc(len);
if (ni == NULL) {
@@ -192,36 +206,22 @@
ni->name = (char *)(ni+1);
strcpy(ni->name, name);
- strcpy(path, SEM_PREFIX);
- if (strlcat(path, name, sizeof(path)) >= sizeof(path)) {
- errno = ENAMETOOLONG;
- goto error;
+ if (fd == -1) {
+ fd = _open(path, flags | O_RDWR | O_CLOEXEC | O_EXLOCK, mode);
+ if (fd == -1 || _fstat(fd, &sb) == -1)
+ goto error;
}
-
- fd = _open(path, flags|O_RDWR, mode);
- if (fd == -1)
- goto error;
- if (flock(fd, LOCK_EX) == -1)
- goto error;
- if (_fstat(fd, &sb)) {
- flock(fd, LOCK_UN);
- goto error;
- }
if (sb.st_size < sizeof(sem_t)) {
- sem_t tmp;
-
tmp._magic = SEM_MAGIC;
tmp._kern._has_waiters = 0;
tmp._kern._count = value;
tmp._kern._flags = USYNC_PROCESS_SHARED | SEM_NAMED;
- if (_write(fd, &tmp, sizeof(tmp)) != sizeof(tmp)) {
- flock(fd, LOCK_UN);
+ if (_write(fd, &tmp, sizeof(tmp)) != sizeof(tmp))
goto error;
- }
}
flock(fd, LOCK_UN);
- sem = (sem_t *)mmap(NULL, sizeof(sem_t), PROT_READ|PROT_WRITE,
- MAP_SHARED|MAP_NOSYNC, fd, 0);
+ sem = mmap(NULL, sizeof(sem_t), PROT_READ | PROT_WRITE,
+ MAP_SHARED | MAP_NOSYNC, fd, 0);
if (sem == MAP_FAILED) {
sem = NULL;
if (errno == ENOMEM)
@@ -234,19 +234,21 @@
}
ni->open_count = 1;
ni->sem = sem;
+ ni->dev = sb.st_dev;
+ ni->ino = sb.st_ino;
LIST_INSERT_HEAD(&sem_list, ni, next);
+ _close(fd);
_pthread_mutex_unlock(&sem_llock);
- _close(fd);
return (sem);
error:
errsave = errno;
- _pthread_mutex_unlock(&sem_llock);
if (fd != -1)
_close(fd);
if (sem != NULL)
munmap(sem, sizeof(sem_t));
free(ni);
+ _pthread_mutex_unlock(&sem_llock);
errno = errsave;
return (SEM_FAILED);
}
@@ -255,6 +257,7 @@
_sem_close(sem_t *sem)
{
struct sem_nameinfo *ni;
+ bool last;
if (sem_check_validity(sem) != 0)
return (-1);
@@ -269,22 +272,17 @@
_pthread_mutex_lock(&sem_llock);
LIST_FOREACH(ni, &sem_list, next) {
if (sem == ni->sem) {
- if (--ni->open_count > 0) {
- _pthread_mutex_unlock(&sem_llock);
- return (0);
+ last = --ni->open_count == 0;
+ if (last)
+ LIST_REMOVE(ni, next);
+ _pthread_mutex_unlock(&sem_llock);
+ if (last) {
+ munmap(sem, sizeof(*sem));
+ free(ni);
}
- else
- break;
+ return (0);
}
}
-
- if (ni) {
- LIST_REMOVE(ni, next);
- _pthread_mutex_unlock(&sem_llock);
- munmap(sem, sizeof(*sem));
- free(ni);
- return (0);
- }
_pthread_mutex_unlock(&sem_llock);
errno = EINVAL;
return (-1);
@@ -300,13 +298,13 @@
return -1;
}
name++;
-
strcpy(path, SEM_PREFIX);
if (strlcat(path, name, sizeof(path)) >= sizeof(path)) {
errno = ENAMETOOLONG;
return (-1);
}
- return unlink(path);
+
+ return (unlink(path));
}
int
@@ -338,21 +336,28 @@
static __inline int
usem_wake(struct _usem *sem)
{
- if (!sem->_has_waiters)
- return (0);
- return _umtx_op(sem, UMTX_OP_SEM_WAKE, 0, NULL, NULL);
+
+ return (_umtx_op(sem, UMTX_OP_SEM_WAKE, 0, NULL, NULL));
}
static __inline int
-usem_wait(struct _usem *sem, const struct timespec *timeout)
+usem_wait(struct _usem *sem, const struct timespec *abstime)
{
- if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 &&
- timeout->tv_nsec <= 0))) {
- errno = ETIMEDOUT;
- return (-1);
+ struct _umtx_time *tm_p, timeout;
+ size_t tm_size;
+
+ if (abstime == NULL) {
+ tm_p = NULL;
+ tm_size = 0;
+ } else {
+ timeout._clockid = CLOCK_REALTIME;
+ timeout._flags = UMTX_ABSTIME;
+ timeout._timeout = *abstime;
+ tm_p = &timeout;
+ tm_size = sizeof(timeout);
}
- return _umtx_op(sem, UMTX_OP_SEM_WAIT, 0, NULL,
- __DECONST(void*, timeout));
+ return _umtx_op(sem, UMTX_OP_SEM_WAIT, 0,
+ (void *)tm_size, __DECONST(void*, tm_p));
}
int
@@ -371,22 +376,10 @@
return (-1);
}
-#define TIMESPEC_SUB(dst, src, val) \
- do { \
- (dst)->tv_sec = (src)->tv_sec - (val)->tv_sec; \
- (dst)->tv_nsec = (src)->tv_nsec - (val)->tv_nsec; \
- if ((dst)->tv_nsec < 0) { \
- (dst)->tv_sec--; \
- (dst)->tv_nsec += 1000000000; \
- } \
- } while (0)
-
-
int
_sem_timedwait(sem_t * __restrict sem,
const struct timespec * __restrict abstime)
{
- struct timespec ts, ts2;
int val, retval;
if (sem_check_validity(sem) != 0)
@@ -393,6 +386,7 @@
return (-1);
retval = 0;
+ _pthread_testcancel();
for (;;) {
while ((val = sem->_kern._count) > 0) {
if (atomic_cmpset_acq_int(&sem->_kern._count, val, val - 1))
@@ -413,11 +407,9 @@
errno = EINVAL;
return (-1);
}
- clock_gettime(CLOCK_REALTIME, &ts);
- TIMESPEC_SUB(&ts2, abstime, &ts);
}
_pthread_cancel_enter(1);
- retval = usem_wait(&sem->_kern, abstime ? &ts2 : NULL);
+ retval = usem_wait(&sem->_kern, abstime);
_pthread_cancel_leave(0);
}
return (retval);
@@ -426,7 +418,8 @@
int
_sem_wait(sem_t *sem)
{
- return _sem_timedwait(sem, NULL);
+
+ return (_sem_timedwait(sem, NULL));
}
/*
@@ -438,10 +431,18 @@
int
_sem_post(sem_t *sem)
{
+ unsigned int count;
if (sem_check_validity(sem) != 0)
return (-1);
- atomic_add_rel_int(&sem->_kern._count, 1);
- return usem_wake(&sem->_kern);
+ do {
+ count = sem->_kern._count;
+ if (count + 1 > SEM_VALUE_MAX) {
+ errno = EOVERFLOW;
+ return (-1);
+ }
+ } while(!atomic_cmpset_rel_int(&sem->_kern._count, count, count+1));
+ (void)usem_wake(&sem->_kern);
+ return (0);
}
Modified: trunk/lib/libc/gen/sem_open.3
===================================================================
--- trunk/lib/libc/gen/sem_open.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sem_open.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (C) 2000 Jason Evans <jasone at FreeBSD.org>.
.\" All rights reserved.
.\"
@@ -25,7 +26,7 @@
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/sem_open.3 202133 2010-01-12 01:30:05Z davidxu $
.\"
.Dd January 9, 2010
.Dt SEM_OPEN 3
Property changes on: trunk/lib/libc/gen/sem_open.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/sem_post.3
===================================================================
--- trunk/lib/libc/gen/sem_post.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sem_post.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (C) 2000 Jason Evans <jasone at FreeBSD.org>.
.\" All rights reserved.
.\"
@@ -25,9 +26,9 @@
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/sem_post.3 278410 2015-02-08 21:58:25Z jilles $
.\"
-.Dd February 15, 2000
+.Dd January 28, 2015
.Dt SEM_POST 3
.Os
.Sh NAME
@@ -65,6 +66,9 @@
.Fa sem
argument
points to an invalid semaphore.
+.It Bq Er EOVERFLOW
+The semaphore value would exceed
+.Dv SEM_VALUE_MAX .
.El
.Sh SEE ALSO
.Xr sem_getvalue 3 ,
Property changes on: trunk/lib/libc/gen/sem_post.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/sem_timedwait.3
===================================================================
--- trunk/lib/libc/gen/sem_timedwait.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sem_timedwait.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008, David Xu <davidxu at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -32,7 +33,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/sem_timedwait.3 208291 2010-05-19 08:57:53Z uqs $
.\"
.Dd March 3, 2008
.Dt SEM_TIMEDWAIT 3
Property changes on: trunk/lib/libc/gen/sem_timedwait.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/sem_wait.3
===================================================================
--- trunk/lib/libc/gen/sem_wait.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sem_wait.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (C) 2000 Jason Evans <jasone at FreeBSD.org>.
.\" All rights reserved.
.\"
@@ -25,7 +26,7 @@
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/sem_wait.3 249567 2013-04-16 20:31:15Z joel $
.\"
.Dd April 16, 2013
.Dt SEM_WAIT 3
Property changes on: trunk/lib/libc/gen/sem_wait.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/semctl.c
===================================================================
--- trunk/lib/libc/gen/semctl.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/semctl.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2002 Doug Rabson
* All rights reserved.
@@ -27,7 +28,7 @@
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/semctl.c 194910 2009-06-24 21:10:52Z jhb $");
#define _WANT_SEMUN_OLD
Modified: trunk/lib/libc/gen/setdomainname.c
===================================================================
--- trunk/lib/libc/gen/setdomainname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/setdomainname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)sethostname.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/setdomainname.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/param.h>
#include <sys/sysctl.h>
Modified: trunk/lib/libc/gen/sethostname.c
===================================================================
--- trunk/lib/libc/gen/sethostname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sethostname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)sethostname.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/sethostname.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/param.h>
#include <sys/sysctl.h>
Modified: trunk/lib/libc/gen/setjmp.3
===================================================================
--- trunk/lib/libc/gen/setjmp.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/setjmp.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -30,7 +31,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)setjmp.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/setjmp.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 4, 1993
.Dt SETJMP 3
Property changes on: trunk/lib/libc/gen/setjmp.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/setjmperr.c
===================================================================
--- trunk/lib/libc/gen/setjmperr.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/setjmperr.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)setjmperr.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/setjmperr.c 165903 2007-01-09 00:28:16Z imp $");
/*
* This routine is called from longjmp() when an error occurs.
Modified: trunk/lib/libc/gen/setmode.3
===================================================================
--- trunk/lib/libc/gen/setmode.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/setmode.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/setmode.3 280392 2015-03-23 19:44:18Z pfg $
.\"
-.Dd August 15, 2015
+.Dd February 22, 2015
.Dt SETMODE 3
.Os
.Sh NAME
Property changes on: trunk/lib/libc/gen/setmode.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/setmode.c
===================================================================
--- trunk/lib/libc/gen/setmode.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/setmode.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -34,11 +35,12 @@
static char sccsid[] = "@(#)setmode.c 8.2 (Berkeley) 3/25/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/setmode.c 287480 2015-09-05 08:55:51Z kib $");
#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/sysctl.h>
#include <ctype.h>
#include <errno.h>
@@ -52,6 +54,7 @@
#include <stdio.h>
#endif
#include "un-namespace.h"
+#include "libc_private.h"
#define SET_LEN 6 /* initial # of bitcmd struct to malloc */
#define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */
@@ -68,6 +71,7 @@
#define CMD2_OBITS 0x08
#define CMD2_UBITS 0x10
+static mode_t getumask(void);
static BITCMD *addcmd(BITCMD *, mode_t, mode_t, mode_t, mode_t);
static void compress_mode(BITCMD *);
#ifdef SETMODE_DEBUG
@@ -169,7 +173,6 @@
int serrno;
char op, *ep;
BITCMD *set, *saveset, *endset;
- sigset_t sigset, sigoset;
mode_t mask, perm, permXbits, who;
long perml;
int equalopdone;
@@ -182,15 +185,9 @@
/*
* Get a copy of the mask for the permissions that are mask relative.
- * Flip the bits, we want what's not set. Since it's possible that
- * the caller is opening files inside a signal handler, protect them
- * as best we can.
+ * Flip the bits, we want what's not set.
*/
- sigfillset(&sigset);
- (void)_sigprocmask(SIG_BLOCK, &sigset, &sigoset);
- (void)umask(mask = umask(0));
- mask = ~mask;
- (void)_sigprocmask(SIG_SETMASK, &sigoset, NULL);
+ mask = ~getumask();
setlen = SET_LEN + 2;
@@ -346,6 +343,35 @@
return NULL;
}
+static mode_t
+getumask(void)
+{
+ sigset_t sigset, sigoset;
+ size_t len;
+ mode_t mask;
+ u_short smask;
+
+ /*
+ * First try requesting the umask without temporarily modifying it.
+ * Note that this does not work if the sysctl
+ * security.bsd.unprivileged_proc_debug is set to 0.
+ */
+ len = sizeof(smask);
+ if (sysctl((int[4]){ CTL_KERN, KERN_PROC, KERN_PROC_UMASK, getpid() },
+ 4, &smask, &len, NULL, 0) == 0)
+ return (smask);
+
+ /*
+ * Since it's possible that the caller is opening files inside a signal
+ * handler, protect them as best we can.
+ */
+ sigfillset(&sigset);
+ (void)__libc_sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+ (void)umask(mask = umask(0));
+ (void)__libc_sigprocmask(SIG_SETMASK, &sigoset, NULL);
+ return (mask);
+}
+
static BITCMD *
addcmd(BITCMD *set, mode_t op, mode_t who, mode_t oparg, mode_t mask)
{
Modified: trunk/lib/libc/gen/setproctitle.3
===================================================================
--- trunk/lib/libc/gen/setproctitle.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/setproctitle.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1995 Peter Wemm <peter at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -17,7 +18,7 @@
.\" 5. Modifications may be freely made to this file providing the above
.\" conditions are met.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/setproctitle.3 208291 2010-05-19 08:57:53Z uqs $
.\"
.\" The following requests are required for all man pages.
.Dd December 16, 1995
Property changes on: trunk/lib/libc/gen/setproctitle.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/setproctitle.c
===================================================================
--- trunk/lib/libc/gen/setproctitle.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/setproctitle.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1995 Peter Wemm <peter at freebsd.org>
* All rights reserved.
@@ -16,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/setproctitle.c 282409 2015-05-04 08:05:13Z kib $");
#include "namespace.h"
#include <sys/types.h>
@@ -42,9 +43,10 @@
* 1: old_ps_strings at the very top of the stack.
* 2: old_ps_strings at SPARE_USRSPACE below the top of the stack.
* 3: ps_strings at the very top of the stack.
- * This attempts to support a kernel built in the #2 and #3 era.
- */
-
+ * We only support a kernel providing #3 style ps_strings.
+ *
+ * For historical purposes, a definition of the old ps_strings structure
+ * and location is preserved below:
struct old_ps_strings {
char *old_ps_argvstr;
int old_ps_nargvstr;
@@ -53,6 +55,7 @@
};
#define OLD_PS_STRINGS ((struct old_ps_strings *) \
(USRSTACK - SPARE_USRSPACE - sizeof(struct old_ps_strings)))
+ */
#include <stdarg.h>
@@ -136,41 +139,38 @@
ps_strings = (struct ps_strings *)ul_ps_strings;
}
- /* PS_STRINGS points to zeroed memory on a style #2 kernel */
- if (ps_strings->ps_argvstr) {
- /* style #3 */
- if (oargc == -1) {
- /* Record our original args */
- oargc = ps_strings->ps_nargvstr;
- oargv = ps_strings->ps_argvstr;
- for (i = len = 0; i < oargc; i++) {
- /*
- * The program may have scribbled into its
- * argv array, e.g., to remove some arguments.
- * If that has happened, break out before
- * trying to call strlen on a NULL pointer.
- */
- if (oargv[i] == NULL) {
- oargc = i;
- break;
- }
- snprintf(obuf + len, SPT_BUFSIZE - len, "%s%s",
- len ? " " : "", oargv[i]);
- if (len)
- len++;
- len += strlen(oargv[i]);
- if (len >= SPT_BUFSIZE)
- break;
+ /*
+ * PS_STRINGS points to zeroed memory on a style #2 kernel.
+ * Should not happen.
+ */
+ if (ps_strings->ps_argvstr == NULL)
+ return;
+
+ /* style #3 */
+ if (oargc == -1) {
+ /* Record our original args */
+ oargc = ps_strings->ps_nargvstr;
+ oargv = ps_strings->ps_argvstr;
+ for (i = len = 0; i < oargc; i++) {
+ /*
+ * The program may have scribbled into its
+ * argv array, e.g., to remove some arguments.
+ * If that has happened, break out before
+ * trying to call strlen on a NULL pointer.
+ */
+ if (oargv[i] == NULL) {
+ oargc = i;
+ break;
}
+ snprintf(obuf + len, SPT_BUFSIZE - len, "%s%s",
+ len != 0 ? " " : "", oargv[i]);
+ if (len != 0)
+ len++;
+ len += strlen(oargv[i]);
+ if (len >= SPT_BUFSIZE)
+ break;
}
- ps_strings->ps_nargvstr = nargc;
- ps_strings->ps_argvstr = nargvp;
- } else {
- /* style #2 - we can only restore our first arg :-( */
- if (*obuf == '\0')
- strncpy(obuf, OLD_PS_STRINGS->old_ps_argvstr,
- SPT_BUFSIZE - 1);
- OLD_PS_STRINGS->old_ps_nargvstr = 1;
- OLD_PS_STRINGS->old_ps_argvstr = nargvp[0];
}
+ ps_strings->ps_nargvstr = nargc;
+ ps_strings->ps_argvstr = nargvp;
}
Modified: trunk/lib/libc/gen/setprogname.c
===================================================================
--- trunk/lib/libc/gen/setprogname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/setprogname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/setprogname.c 93399 2002-03-29 22:43:43Z markm $");
#include <stdlib.h>
#include <string.h>
Modified: trunk/lib/libc/gen/siginterrupt.3
===================================================================
--- trunk/lib/libc/gen/siginterrupt.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/siginterrupt.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)siginterrupt.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/siginterrupt.3 207735 2010-05-06 22:49:54Z jilles $
.\"
.Dd June 4, 1993
.Dt SIGINTERRUPT 3
Property changes on: trunk/lib/libc/gen/siginterrupt.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/siginterrupt.c
===================================================================
--- trunk/lib/libc/gen/siginterrupt.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/siginterrupt.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)siginterrupt.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/siginterrupt.c 287480 2015-09-05 08:55:51Z kib $");
#include "namespace.h"
#include <signal.h>
@@ -43,14 +44,13 @@
* after an instance of the indicated signal.
*/
int
-siginterrupt(sig, flag)
- int sig, flag;
+siginterrupt(int sig, int flag)
{
- extern sigset_t _sigintr;
+ extern sigset_t _sigintr __hidden;
struct sigaction sa;
int ret;
- if ((ret = _sigaction(sig, (struct sigaction *)0, &sa)) < 0)
+ if ((ret = __libc_sigaction(sig, (struct sigaction *)0, &sa)) < 0)
return (ret);
if (flag) {
sigaddset(&_sigintr, sig);
@@ -59,5 +59,5 @@
sigdelset(&_sigintr, sig);
sa.sa_flags |= SA_RESTART;
}
- return (_sigaction(sig, &sa, (struct sigaction *)0));
+ return (__libc_sigaction(sig, &sa, (struct sigaction *)0));
}
Modified: trunk/lib/libc/gen/siglist.c
===================================================================
--- trunk/lib/libc/gen/siglist.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/siglist.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)siglist.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/siglist.c 218285 2011-02-04 16:40:50Z jilles $");
#include <signal.h>
Modified: trunk/lib/libc/gen/signal.3
===================================================================
--- trunk/lib/libc/gen/signal.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/signal.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)signal.3 8.3 (Berkeley) 4/19/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/signal.3 255171 2013-09-03 08:19:06Z rwatson $
.\"
.Dd June 7, 2004
.Dt SIGNAL 3
@@ -38,20 +39,11 @@
.Lb libc
.Sh SYNOPSIS
.In signal.h
-.\" XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
-.\" The prototype for signal(3) cannot be cleanly marked up in -mdoc
-.\" without the following lower-level tweak.
-.nr in-synopsis-section 0
+.\" The following is Quite Ugly, but syntactically correct.
+.\" Don't try to fix it.
+.Ft void
+.Fn \*(lp*signal "int sig" "void \*(lp*func\*(rp\*(lpint\*(rp\*(rp\*(rp\*(lpint"
.Pp
-.Ft "void \*(lp*" Ns
-.Fo signal
-.Fa "int sig"
-.Fa "void \*(lp*func\*(rp\*(lpint\*(rp"
-.Fc Ns
-.Ft "\*(rp\*(lpint\*(rp" ;
-.Pp
-.nr in-synopsis-section 1
-.\" XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
or in
.Fx Ap s
equivalent but easier to read typedef'd version:
@@ -98,7 +90,7 @@
These signals are defined in the file
.In signal.h :
.Bl -column No ".Dv SIGVTALRM" "create core image"
-.It Sy "No Name Default Action Description"
+.It Sy "Num" Ta Sy "Name" Ta Sy "Default Action" Ta Sy "Description"
.It 1 Ta Dv SIGHUP Ta "terminate process" Ta "terminal line hangup"
.It 2 Ta Dv SIGINT Ta "terminate process" Ta "interrupt program"
.It 3 Ta Dv SIGQUIT Ta "create core image" Ta "quit program"
@@ -141,6 +133,7 @@
.It 30 Ta Dv SIGUSR1 Ta "terminate process" Ta "User defined signal 1"
.It 31 Ta Dv SIGUSR2 Ta "terminate process" Ta "User defined signal 2"
.It 32 Ta Dv SIGTHR Ta "terminate process" Ta "thread interrupt"
+.It 33 Ta Dv SIGLIBRT Ta "terminate process" Ta "real-time library interrupt"
.El
.Pp
The
Property changes on: trunk/lib/libc/gen/signal.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/signal.c
===================================================================
--- trunk/lib/libc/gen/signal.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/signal.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1985, 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)signal.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/signal.c 287480 2015-09-05 08:55:51Z kib $");
/*
* Almost backwards compatible signal.
@@ -41,12 +42,10 @@
#include "un-namespace.h"
#include "libc_private.h"
-sigset_t _sigintr; /* shared with siginterrupt */
+sigset_t _sigintr __hidden; /* shared with siginterrupt */
sig_t
-signal(s, a)
- int s;
- sig_t a;
+signal(int s, sig_t a)
{
struct sigaction sa, osa;
@@ -55,7 +54,7 @@
sa.sa_flags = 0;
if (!sigismember(&_sigintr, s))
sa.sa_flags |= SA_RESTART;
- if (_sigaction(s, &sa, &osa) < 0)
+ if (__libc_sigaction(s, &sa, &osa) < 0)
return (SIG_ERR);
return (osa.sa_handler);
}
Modified: trunk/lib/libc/gen/sigsetops.3
===================================================================
--- trunk/lib/libc/gen/sigsetops.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sigsetops.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)sigsetops.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/sigsetops.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd December 16, 2004
.Dt SIGSETOPS 3
Property changes on: trunk/lib/libc/gen/sigsetops.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/sigsetops.c
===================================================================
--- trunk/lib/libc/gen/sigsetops.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sigsetops.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -33,7 +34,7 @@
static char sccsid[] = "@(#)sigsetops.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/sigsetops.c 165903 2007-01-09 00:28:16Z imp $");
#include <errno.h>
#include <signal.h>
Modified: trunk/lib/libc/gen/sleep.3
===================================================================
--- trunk/lib/libc/gen/sleep.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sleep.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1986, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)sleep.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/sleep.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd February 13, 1998
.Dt SLEEP 3
Property changes on: trunk/lib/libc/gen/sleep.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/sleep.c
===================================================================
--- trunk/lib/libc/gen/sleep.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sleep.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)sleep.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/sleep.c 277317 2015-01-18 11:54:20Z kib $");
#include "namespace.h"
#include <errno.h>
@@ -40,6 +41,8 @@
#include <unistd.h>
#include "un-namespace.h"
+#include "libc_private.h"
+
unsigned int
__sleep(unsigned int seconds)
{
@@ -55,12 +58,14 @@
time_to_sleep.tv_sec = seconds;
time_to_sleep.tv_nsec = 0;
- if (_nanosleep(&time_to_sleep, &time_remaining) != -1)
+ if (((int (*)(const struct timespec *, struct timespec *))
+ __libc_interposing[INTERPOS_nanosleep])(
+ &time_to_sleep, &time_remaining) != -1)
return (0);
if (errno != EINTR)
return (seconds); /* best guess */
return (time_remaining.tv_sec +
- (time_remaining.tv_nsec != 0)); /* round up */
+ (time_remaining.tv_nsec != 0)); /* round up */
}
__weak_reference(__sleep, sleep);
Modified: trunk/lib/libc/gen/srand48.c
===================================================================
--- trunk/lib/libc/gen/srand48.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/srand48.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
Modified: trunk/lib/libc/gen/statvfs.3
===================================================================
--- trunk/lib/libc/gen/statvfs.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/statvfs.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright 2002 Massachusetts Institute of Technology
.\"
@@ -26,7 +27,7 @@
.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/statvfs.3 116021 2003-06-08 10:01:52Z charnier $
.\"
.Dd July 13, 2002
.Dt STATVFS 3
Property changes on: trunk/lib/libc/gen/statvfs.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/statvfs.c
===================================================================
--- trunk/lib/libc/gen/statvfs.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/statvfs.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright 2002 Massachusetts Institute of Technology
*
@@ -28,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/statvfs.c 103012 2002-09-06 11:24:06Z tjr $");
#include "namespace.h"
#include <sys/param.h>
Modified: trunk/lib/libc/gen/stringlist.3
===================================================================
--- trunk/lib/libc/gen/stringlist.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/stringlist.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $NetBSD: stringlist.3,v 1.5 1999/03/22 19:44:46 garbled Exp $
.\"
.\" Copyright (c) 1997, 1999 The NetBSD Foundation, Inc.
@@ -26,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/stringlist.3 249802 2013-04-23 13:03:03Z eadler $
.\"
.Dd November 28, 1999
.Dt STRINGLIST 3
Property changes on: trunk/lib/libc/gen/stringlist.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/stringlist.c
===================================================================
--- trunk/lib/libc/gen/stringlist.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/stringlist.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1994 Christos Zoulas
* All rights reserved.
@@ -30,7 +31,7 @@
static char *rcsid = "$NetBSD: stringlist.c,v 1.2 1997/01/17 07:26:20 lukem Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/stringlist.c 249802 2013-04-23 13:03:03Z eadler $");
#include "namespace.h"
#include <stdio.h>
Modified: trunk/lib/libc/gen/strtofflags.3
===================================================================
--- trunk/lib/libc/gen/strtofflags.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/strtofflags.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/strtofflags.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd January 1, 2000
.Dt STRTOFFLAGS 3
Property changes on: trunk/lib/libc/gen/strtofflags.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/strtofflags.c
===================================================================
--- trunk/lib/libc/gen/strtofflags.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/strtofflags.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/strtofflags.c 254627 2013-08-21 23:04:48Z ken $");
#include <sys/types.h>
#include <sys/stat.h>
@@ -41,35 +42,51 @@
#include <string.h>
#include <unistd.h>
+#define longestflaglen 12
static struct {
- char *name;
+ char name[longestflaglen + 1];
+ char invert;
u_long flag;
- int invert;
-} mapping[] = {
+} const mapping[] = {
/* shorter names per flag first, all prefixed by "no" */
- { "nosappnd", SF_APPEND, 0 },
- { "nosappend", SF_APPEND, 0 },
- { "noarch", SF_ARCHIVED, 0 },
- { "noarchived", SF_ARCHIVED, 0 },
- { "noschg", SF_IMMUTABLE, 0 },
- { "noschange", SF_IMMUTABLE, 0 },
- { "nosimmutable", SF_IMMUTABLE, 0 },
- { "nosunlnk", SF_NOUNLINK, 0 },
- { "nosunlink", SF_NOUNLINK, 0 },
+ { "nosappnd", 0, SF_APPEND },
+ { "nosappend", 0, SF_APPEND },
+ { "noarch", 0, SF_ARCHIVED },
+ { "noarchived", 0, SF_ARCHIVED },
+ { "noschg", 0, SF_IMMUTABLE },
+ { "noschange", 0, SF_IMMUTABLE },
+ { "nosimmutable", 0, SF_IMMUTABLE },
+ { "nosunlnk", 0, SF_NOUNLINK },
+ { "nosunlink", 0, SF_NOUNLINK },
#ifdef SF_SNAPSHOT
- { "nosnapshot", SF_SNAPSHOT, 0 },
+ { "nosnapshot", 0, SF_SNAPSHOT },
#endif
- { "nouappnd", UF_APPEND, 0 },
- { "nouappend", UF_APPEND, 0 },
- { "nouchg", UF_IMMUTABLE, 0 },
- { "nouchange", UF_IMMUTABLE, 0 },
- { "nouimmutable", UF_IMMUTABLE, 0 },
- { "nodump", UF_NODUMP, 1 },
- { "noopaque", UF_OPAQUE, 0 },
- { "nouunlnk", UF_NOUNLINK, 0 },
- { "nouunlink", UF_NOUNLINK, 0 }
+ { "nouappnd", 0, UF_APPEND },
+ { "nouappend", 0, UF_APPEND },
+ { "nouarch", 0, UF_ARCHIVE },
+ { "nouarchive", 0, UF_ARCHIVE },
+ { "nohidden", 0, UF_HIDDEN },
+ { "nouhidden", 0, UF_HIDDEN },
+ { "nouchg", 0, UF_IMMUTABLE },
+ { "nouchange", 0, UF_IMMUTABLE },
+ { "nouimmutable", 0, UF_IMMUTABLE },
+ { "nodump", 1, UF_NODUMP },
+ { "nouunlnk", 0, UF_NOUNLINK },
+ { "nouunlink", 0, UF_NOUNLINK },
+ { "nooffline", 0, UF_OFFLINE },
+ { "nouoffline", 0, UF_OFFLINE },
+ { "noopaque", 0, UF_OPAQUE },
+ { "nordonly", 0, UF_READONLY },
+ { "nourdonly", 0, UF_READONLY },
+ { "noreadonly", 0, UF_READONLY },
+ { "noureadonly", 0, UF_READONLY },
+ { "noreparse", 0, UF_REPARSE },
+ { "noureparse", 0, UF_REPARSE },
+ { "nosparse", 0, UF_SPARSE },
+ { "nousparse", 0, UF_SPARSE },
+ { "nosystem", 0, UF_SYSTEM },
+ { "nousystem", 0, UF_SYSTEM }
};
-#define longestflaglen 12
#define nmappings (sizeof(mapping) / sizeof(mapping[0]))
/*
@@ -82,7 +99,8 @@
u_long flags;
{
char *string;
- char *sp, *dp;
+ const char *sp;
+ char *dp;
u_long setflags;
int i;
Modified: trunk/lib/libc/gen/sysconf.3
===================================================================
--- trunk/lib/libc/gen/sysconf.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sysconf.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)sysconf.3 8.3 (Berkeley) 4/19/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/sysconf.3 249956 2013-04-26 21:43:42Z jilles $
.\"
.Dd April 26, 2013
.Dt SYSCONF 3
Property changes on: trunk/lib/libc/gen/sysconf.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/sysconf.c
===================================================================
--- trunk/lib/libc/gen/sysconf.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sysconf.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
@@ -34,7 +35,7 @@
static char sccsid[] = "@(#)sysconf.c 8.2 (Berkeley) 3/20/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/sysconf.c 317131 2017-04-19 10:57:57Z kib $");
#include <sys/param.h>
#include <sys/time.h>
@@ -47,6 +48,7 @@
#include <limits.h>
#include <paths.h>
#include <pthread.h> /* we just need the limits */
+#include <semaphore.h>
#include <time.h>
#include <unistd.h>
@@ -298,13 +300,9 @@
mib[1] = CTL_P1003_1B_RTSIG_MAX;
goto yesno;
case _SC_SEM_NSEMS_MAX:
- mib[0] = CTL_P1003_1B;
- mib[1] = CTL_P1003_1B_SEM_NSEMS_MAX;
- goto yesno;
+ return (-1);
case _SC_SEM_VALUE_MAX:
- mib[0] = CTL_P1003_1B;
- mib[1] = CTL_P1003_1B_SEM_VALUE_MAX;
- goto yesno;
+ return (SEM_VALUE_MAX);
case _SC_SIGQUEUE_MAX:
mib[0] = CTL_P1003_1B;
mib[1] = CTL_P1003_1B_SIGQUEUE_MAX;
@@ -359,11 +357,7 @@
return (_POSIX_CLOCK_SELECTION);
#endif
case _SC_CPUTIME:
-#if _POSIX_CPUTIME == 0
-#error "_POSIX_CPUTIME"
-#else
return (_POSIX_CPUTIME);
-#endif
#ifdef notdef
case _SC_FILE_LOCKING:
/*
@@ -371,11 +365,17 @@
* _POSIX_FILE_LOCKING, so we can't answer this one.
*/
#endif
-#if _POSIX_THREAD_SAFE_FUNCTIONS > -1
+
+ /*
+ * SUSv4tc1 says the following about _SC_GETGR_R_SIZE_MAX and
+ * _SC_GETPW_R_SIZE_MAX:
+ * Note that sysconf(_SC_GETGR_R_SIZE_MAX) may return -1 if
+ * there is no hard limit on the size of the buffer needed to
+ * store all the groups returned.
+ */
case _SC_GETGR_R_SIZE_MAX:
case _SC_GETPW_R_SIZE_MAX:
-#error "somebody needs to implement this"
-#endif
+ return (-1);
case _SC_HOST_NAME_MAX:
return (MAXHOSTNAMELEN - 1); /* does not include \0 */
case _SC_LOGIN_NAME_MAX:
Modified: trunk/lib/libc/gen/sysctl.3
===================================================================
--- trunk/lib/libc/gen/sysctl.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sysctl.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/sysctl.3 309072 2016-11-23 23:53:52Z jhb $
.\"
-.Dd February 11, 2012
+.Dd May 17, 2013
.Dt SYSCTL 3
.Os
.Sh NAME
@@ -183,16 +184,16 @@
and are as follows.
The next and subsequent levels down are found in the include files
listed here, and described in separate sections below.
-.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent
-.It Sy "Name Next level names Description"
-.It "CTL_DEBUG sys/sysctl.h Debugging"
-.It "CTL_VFS sys/mount.h File system"
-.It "CTL_HW sys/sysctl.h Generic CPU, I/O"
-.It "CTL_KERN sys/sysctl.h High kernel limits"
-.It "CTL_MACHDEP sys/sysctl.h Machine dependent"
-.It "CTL_NET sys/socket.h Networking"
-.It "CTL_USER sys/sysctl.h User-level"
-.It "CTL_VM vm/vm_param.h Virtual memory"
+.Bl -column CTLXMACHDEPXXX "Next Level NamesXXXXXX" -offset indent
+.It Sy Name Ta Sy Next Level Names Ta Sy Description
+.It Dv CTL_DEBUG Ta In sys/sysctl.h Ta Debugging
+.It Dv CTL_VFS Ta In sys/mount.h Ta File system
+.It Dv CTL_HW Ta In sys/sysctl.h Ta Generic CPU, I/O
+.It Dv CTL_KERN Ta In sys/sysctl.h Ta High kernel limits
+.It Dv CTL_MACHDEP Ta In sys/sysctl.h Ta Machine dependent
+.It Dv CTL_NET Ta In sys/socket.h Ta Networking
+.It Dv CTL_USER Ta In sys/sysctl.h Ta User-level
+.It Dv CTL_VM Ta In vm/vm_param.h Ta Virtual memory
.El
.Pp
For example, the following retrieves the maximum number of processes allowed
@@ -270,20 +271,20 @@
is detailed below.
The changeable column shows whether a process with appropriate
privilege may change the value.
-.Bl -column "Second level nameXXXXXX" integerXXX -offset indent
-.It Sy "Second level name Type Changeable"
-.It "HW_MACHINE string no"
-.It "HW_MODEL string no"
-.It "HW_NCPU integer no"
-.It "HW_BYTEORDER integer no"
-.It "HW_PHYSMEM integer no"
-.It "HW_USERMEM integer no"
-.It "HW_PAGESIZE integer no"
-.\".It "HW_DISKNAMES integer no"
-.\".It "HW_DISKSTATS integer no"
-.It "HW_FLOATINGPT integer no"
-.It "HW_MACHINE_ARCH string no"
-.It "HW_REALMEM integer no"
+.Bl -column "Second Level Name" integerXXX Changeable -offset indent
+.It Sy Second Level Name Ta Sy Type Ta Sy Changeable
+.It Dv HW_MACHINE Ta string Ta no
+.It Dv HW_MODEL Ta string Ta no
+.It Dv HW_NCPU Ta integer Ta no
+.It Dv HW_BYTEORDER Ta integer Ta no
+.It Dv HW_PHYSMEM Ta integer Ta no
+.It Dv HW_USERMEM Ta integer Ta no
+.It Dv HW_PAGESIZE Ta integer Ta no
+.\".It Dv HW_DISKNAMES Ta integer Ta no
+.\".It Dv HW_DISKSTATS Ta integer Ta no
+.It Dv HW_FLOATINGPT Ta integer Ta no
+.It Dv HW_MACHINE_ARCH Ta string Ta no
+.It Dv HW_REALMEM Ta integer Ta no
.El
.Bl -tag -width 6n
.It Li HW_MACHINE
@@ -293,7 +294,7 @@
.It Li HW_NCPU
The number of cpus.
.It Li HW_BYTEORDER
-The byteorder (4,321, or 1,234).
+The byteorder (4321 or 1234).
.It Li HW_PHYSMEM
The bytes of physical memory.
.It Li HW_USERMEM
@@ -319,36 +320,36 @@
virtual memory statistics, load average history, and clock rate
information.
.Bl -column "KERNXMAXFILESPERPROCXXX" "struct clockrateXXX" -offset indent
-.It Sy "Second level name Type Changeable"
-.It "KERN_ARGMAX integer no"
-.It "KERN_BOOTFILE string yes"
-.It "KERN_BOOTTIME struct timeval no"
-.It "KERN_CLOCKRATE struct clockinfo no"
-.It "KERN_FILE struct xfile no"
-.It "KERN_HOSTID integer yes"
-.It "KERN_HOSTUUID string yes"
-.It "KERN_HOSTNAME string yes"
-.It "KERN_JOB_CONTROL integer no"
-.It "KERN_MAXFILES integer yes"
-.It "KERN_MAXFILESPERPROC integer yes"
-.It "KERN_MAXPROC integer no"
-.It "KERN_MAXPROCPERUID integer yes"
-.It "KERN_MAXVNODES integer yes"
-.It "KERN_NGROUPS integer no"
-.It "KERN_NISDOMAINNAME string yes"
-.It "KERN_OSRELDATE integer no"
-.It "KERN_OSRELEASE string no"
-.It "KERN_OSREV integer no"
-.It "KERN_OSTYPE string no"
-.It "KERN_POSIX1 integer no"
-.It "KERN_PROC node not applicable"
-.It "KERN_PROF node not applicable"
-.It "KERN_QUANTUM integer yes"
-.It "KERN_SAVED_IDS integer no"
-.It "KERN_SECURELVL integer raise only"
-.It "KERN_UPDATEINTERVAL integer no"
-.It "KERN_VERSION string no"
-.It "KERN_VNODE struct xvnode no"
+.It Sy Second Level Name Ta Sy Type Ta Sy Changeable
+.It Dv KERN_ARGMAX Ta integer Ta no
+.It Dv KERN_BOOTFILE Ta string Ta yes
+.It Dv KERN_BOOTTIME Ta struct timeval Ta no
+.It Dv KERN_CLOCKRATE Ta struct clockinfo Ta no
+.It Dv KERN_FILE Ta struct xfile Ta no
+.It Dv KERN_HOSTID Ta integer Ta yes
+.It Dv KERN_HOSTUUID Ta string Ta yes
+.It Dv KERN_HOSTNAME Ta string Ta yes
+.It Dv KERN_JOB_CONTROL Ta integer Ta no
+.It Dv KERN_MAXFILES Ta integer Ta yes
+.It Dv KERN_MAXFILESPERPROC Ta integer Ta yes
+.It Dv KERN_MAXPROC Ta integer Ta no
+.It Dv KERN_MAXPROCPERUID Ta integer Ta yes
+.It Dv KERN_MAXVNODES Ta integer Ta yes
+.It Dv KERN_NGROUPS Ta integer Ta no
+.It Dv KERN_NISDOMAINNAME Ta string Ta yes
+.It Dv KERN_OSRELDATE Ta integer Ta no
+.It Dv KERN_OSRELEASE Ta string Ta no
+.It Dv KERN_OSREV Ta integer Ta no
+.It Dv KERN_OSTYPE Ta string Ta no
+.It Dv KERN_POSIX1 Ta integer Ta no
+.It Dv KERN_PROC Ta node Ta not applicable
+.It Dv KERN_PROF Ta node Ta not applicable
+.It Dv KERN_QUANTUM Ta integer Ta yes
+.It Dv KERN_SAVED_IDS Ta integer Ta no
+.It Dv KERN_SECURELVL Ta integer Ta raise only
+.It Dv KERN_UPDATEINTERVAL Ta integer Ta no
+.It Dv KERN_VERSION Ta string Ta no
+.It Dv KERN_VNODE Ta struct xvnode Ta no
.El
.Bl -tag -width 6n
.It Li KERN_ARGMAX
@@ -439,14 +440,14 @@
.Va struct kinfo_proc
structures is returned,
whose size depends on the current number of such objects in the system.
-.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
-.It "Third level name Fourth level is:"
-.It "KERN_PROC_ALL None"
-.It "KERN_PROC_PID A process ID"
-.It "KERN_PROC_PGRP A process group"
-.It "KERN_PROC_TTY A tty device"
-.It "KERN_PROC_UID A user ID"
-.It "KERN_PROC_RUID A real user ID"
+.Bl -column "Third Level NameXXXXXX" "Fourth LevelXXXXXX" -offset indent
+.It Sy Third Level Name Ta Sy Fourth Level
+.It Dv KERN_PROC_ALL Ta None
+.It Dv KERN_PROC_PID Ta A process ID
+.It Dv KERN_PROC_PGRP Ta A process group
+.It Dv KERN_PROC_TTY Ta A tty device
+.It Dv KERN_PROC_UID Ta A user ID
+.It Dv KERN_PROC_RUID Ta A real user ID
.El
.Pp
If the third level name is
@@ -465,8 +466,8 @@
a process ID of
.Li \-1
implies the current process.
-.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
-.It Sy "Third level name Fourth level is:"
+.Bl -column "Third Level NameXXXXXX" "Fourth LevelXXXXXX" -offset indent
+.It Sy Third Level Name Ta Sy Fourth Level
.It Dv KERN_PROC_ARGS Ta "A process ID"
.It Dv KERN_PROC_PATHNAME Ta "A process ID"
.El
@@ -481,12 +482,12 @@
The changeable column shows whether a process with appropriate
privilege may change the value.
.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent
-.It Sy "Third level name Type Changeable"
-.It "GPROF_STATE integer yes"
-.It "GPROF_COUNT u_short[\|] yes"
-.It "GPROF_FROMS u_short[\|] yes"
-.It "GPROF_TOS struct tostruct yes"
-.It "GPROF_GMONPARAM struct gmonparam no"
+.It Sy Third Level Name Ta Sy Type Ta Sy Changeable
+.It Dv GPROF_STATE Ta integer Ta yes
+.It Dv GPROF_COUNT Ta u_short[\|] Ta yes
+.It Dv GPROF_FROMS Ta u_short[\|] Ta yes
+.It Dv GPROF_TOS Ta struct tostruct Ta yes
+.It Dv GPROF_GMONPARAM Ta struct gmonparam Ta no
.El
.Pp
The variables are as follows:
@@ -530,11 +531,11 @@
is detailed below.
The changeable column shows whether a process with appropriate
privilege may change the value.
-.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
-.It Sy "Second level name Type Changeable"
-.It "PF_ROUTE routing messages no"
-.It "PF_INET IPv4 values yes"
-.It "PF_INET6 IPv6 values yes"
+.Bl -column "Second Level NameXXXXXX" "routing messagesXXX" -offset indent
+.It Sy Second Level Name Ta Sy Type Ta Sy Changeable
+.It Dv PF_ROUTE Ta routing messages Ta no
+.It Dv PF_INET Ta IPv4 values Ta yes
+.It Dv PF_INET6 Ta IPv6 values Ta yes
.El
.Bl -tag -width 6n
.It Li PF_ROUTE
@@ -547,14 +548,14 @@
The third level name is a protocol number, which is currently always 0.
The fourth level name is an address family, which may be set to 0 to
select all address families.
-The fifth and sixth level names are as follows:
-.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
-.It Sy "Fifth level name Sixth level is:"
-.It "NET_RT_FLAGS rtflags"
-.It "NET_RT_DUMP None"
-.It "NET_RT_IFLIST 0 or if_index"
-.It "NET_RT_IFMALIST 0 or if_index"
-.It "NET_RT_IFLISTL 0 or if_index"
+The fifth, sixth, and seventh level names are as follows:
+.Bl -column -offset indent "Fifth Level" "Sixth Level" "Seventh Level"
+.It Sy Fifth level Ta Sy Sixth Level Ta Sy Seventh Level
+.It Dv NET_RT_FLAGS Ta rtflags Ta None
+.It Dv NET_RT_DUMP Ta None Ta None or fib number
+.It Dv NET_RT_IFLIST Ta 0 or if_index Ta None
+.It Dv NET_RT_IFMALIST Ta 0 or if_index Ta None
+.It Dv NET_RT_IFLISTL Ta 0 or if_index Ta None
.El
.Pp
The
@@ -582,13 +583,13 @@
The fourth level name is the variable name.
The currently defined protocols and names are:
.Bl -column ProtocolXX VariableXX TypeXX ChangeableXX
-.It Sy "Protocol Variable Type Changeable"
-.It "icmp bmcastecho integer yes"
-.It "icmp maskrepl integer yes"
-.It "ip forwarding integer yes"
-.It "ip redirect integer yes"
-.It "ip ttl integer yes"
-.It "udp checksum integer yes"
+.It Sy Protocol Ta Sy Variable Ta Sy Type Ta Sy Changeable
+.It icmp Ta bmcastecho Ta integer Ta yes
+.It icmp Ta maskrepl Ta integer Ta yes
+.It ip Ta forwarding Ta integer Ta yes
+.It ip Ta redirect Ta integer Ta yes
+.It ip Ta ttl Ta integer Ta yes
+.It udp Ta checksum Ta integer Ta yes
.El
.Pp
The variables are as follows:
@@ -633,27 +634,27 @@
The changeable column shows whether a process with appropriate
privilege may change the value.
.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
-.It Sy "Second level name Type Changeable"
-.It "USER_BC_BASE_MAX integer no"
-.It "USER_BC_DIM_MAX integer no"
-.It "USER_BC_SCALE_MAX integer no"
-.It "USER_BC_STRING_MAX integer no"
-.It "USER_COLL_WEIGHTS_MAX integer no"
-.It "USER_CS_PATH string no"
-.It "USER_EXPR_NEST_MAX integer no"
-.It "USER_LINE_MAX integer no"
-.It "USER_POSIX2_CHAR_TERM integer no"
-.It "USER_POSIX2_C_BIND integer no"
-.It "USER_POSIX2_C_DEV integer no"
-.It "USER_POSIX2_FORT_DEV integer no"
-.It "USER_POSIX2_FORT_RUN integer no"
-.It "USER_POSIX2_LOCALEDEF integer no"
-.It "USER_POSIX2_SW_DEV integer no"
-.It "USER_POSIX2_UPE integer no"
-.It "USER_POSIX2_VERSION integer no"
-.It "USER_RE_DUP_MAX integer no"
-.It "USER_STREAM_MAX integer no"
-.It "USER_TZNAME_MAX integer no"
+.It Sy Second Level Name Ta Sy Type Ta Sy Changeable
+.It Dv USER_BC_BASE_MAX Ta integer Ta no
+.It Dv USER_BC_DIM_MAX Ta integer Ta no
+.It Dv USER_BC_SCALE_MAX Ta integer Ta no
+.It Dv USER_BC_STRING_MAX Ta integer Ta no
+.It Dv USER_COLL_WEIGHTS_MAX Ta integer Ta no
+.It Dv USER_CS_PATH Ta string Ta no
+.It Dv USER_EXPR_NEST_MAX Ta integer Ta no
+.It Dv USER_LINE_MAX Ta integer Ta no
+.It Dv USER_POSIX2_CHAR_TERM Ta integer Ta no
+.It Dv USER_POSIX2_C_BIND Ta integer Ta no
+.It Dv USER_POSIX2_C_DEV Ta integer Ta no
+.It Dv USER_POSIX2_FORT_DEV Ta integer Ta no
+.It Dv USER_POSIX2_FORT_RUN Ta integer Ta no
+.It Dv USER_POSIX2_LOCALEDEF Ta integer Ta no
+.It Dv USER_POSIX2_SW_DEV Ta integer Ta no
+.It Dv USER_POSIX2_UPE Ta integer Ta no
+.It Dv USER_POSIX2_VERSION Ta integer Ta no
+.It Dv USER_RE_DUP_MAX Ta integer Ta no
+.It Dv USER_STREAM_MAX Ta integer Ta no
+.It Dv USER_TZNAME_MAX Ta integer Ta no
.El
.Bl -tag -width 6n
.It Li USER_BC_BASE_MAX
@@ -731,19 +732,18 @@
is detailed below.
The changeable column shows whether a process with appropriate
privilege may change the value.
-.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
-.It Sy "Second level name Type Changeable"
-.It "VM_LOADAVG struct loadavg no"
-.It "VM_TOTAL struct vmtotal no"
-.It "VM_PAGEOUT_ALGORITHM integer yes"
-.It "VM_SWAPPING_ENABLED integer maybe"
-.It "VM_V_CACHE_MAX integer yes"
-.It "VM_V_CACHE_MIN integer yes"
-.It "VM_V_FREE_MIN integer yes"
-.It "VM_V_FREE_RESERVED integer yes"
-.It "VM_V_FREE_TARGET integer yes"
-.It "VM_V_INACTIVE_TARGET integer yes"
-.It "VM_V_PAGEOUT_FREE_MIN integer yes"
+.Bl -column "Second Level NameXXXXXX" "struct loadavgXXX" -offset indent
+.It Sy Second Level Name Ta Sy Type Ta Sy Changeable
+.It Dv VM_LOADAVG Ta struct loadavg Ta no
+.It Dv VM_TOTAL Ta struct vmtotal Ta no
+.It Dv VM_SWAPPING_ENABLED Ta integer Ta maybe
+.It Dv VM_V_CACHE_MAX Ta integer Ta yes
+.It Dv VM_V_CACHE_MIN Ta integer Ta yes
+.It Dv VM_V_FREE_MIN Ta integer Ta yes
+.It Dv VM_V_FREE_RESERVED Ta integer Ta yes
+.It Dv VM_V_FREE_TARGET Ta integer Ta yes
+.It Dv VM_V_INACTIVE_TARGET Ta integer Ta yes
+.It Dv VM_V_PAGEOUT_FREE_MIN Ta integer Ta yes
.El
.Bl -tag -width 6n
.It Li VM_LOADAVG
@@ -754,9 +754,6 @@
Return the system wide virtual memory statistics.
The returned data consists of a
.Va struct vmtotal .
-.It Li VM_PAGEOUT_ALGORITHM
-0 if the statistics-based page management algorithm is in use
-or 1 if the near-LRU algorithm is in use.
.It Li VM_SWAPPING_ENABLED
1 if process swapping is enabled or 0 if disabled.
This variable is
Property changes on: trunk/lib/libc/gen/sysctl.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/sysctl.c
===================================================================
--- trunk/lib/libc/gen/sysctl.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sysctl.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)sysctl.c 8.2 (Berkeley) 1/4/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/sysctl.c 285604 2015-07-15 16:55:56Z pkelsey $");
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -50,9 +51,24 @@
sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp,
const void *newp, size_t newlen)
{
- if (name[0] != CTL_USER)
- return (__sysctl(name, namelen, oldp, oldlenp, newp, newlen));
+ int retval;
+ size_t orig_oldlen;
+ orig_oldlen = oldlenp ? *oldlenp : 0;
+ retval = __sysctl(name, namelen, oldp, oldlenp, newp, newlen);
+ /*
+ * All valid names under CTL_USER have a dummy entry in the sysctl
+ * tree (to support name lookups and enumerations) with an
+ * empty/zero value, and the true value is supplied by this routine.
+ * For all such names, __sysctl() is used solely to validate the
+ * name.
+ *
+ * Return here unless there was a successful lookup for a CTL_USER
+ * name.
+ */
+ if (retval || name[0] != CTL_USER)
+ return (retval);
+
if (newp != NULL) {
errno = EPERM;
return (-1);
@@ -64,7 +80,7 @@
switch (name[1]) {
case USER_CS_PATH:
- if (oldp && *oldlenp < sizeof(_PATH_STDPATH)) {
+ if (oldp && orig_oldlen < sizeof(_PATH_STDPATH)) {
errno = ENOMEM;
return -1;
}
Modified: trunk/lib/libc/gen/sysctlbyname.c
===================================================================
--- trunk/lib/libc/gen/sysctlbyname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sysctlbyname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
@@ -9,7 +10,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/sysctlbyname.c 244153 2012-12-12 15:27:33Z pjd $");
#include <sys/types.h>
#include <sys/sysctl.h>
@@ -19,13 +20,10 @@
const void *newp, size_t newlen)
{
int real_oid[CTL_MAXNAME+2];
- int error;
size_t oidlen;
oidlen = sizeof(real_oid) / sizeof(int);
- error = sysctlnametomib(name, real_oid, &oidlen);
- if (error < 0)
- return (error);
- error = sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen);
- return (error);
+ if (sysctlnametomib(name, real_oid, &oidlen) < 0)
+ return (-1);
+ return (sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen));
}
Modified: trunk/lib/libc/gen/sysctlnametomib.c
===================================================================
--- trunk/lib/libc/gen/sysctlnametomib.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/sysctlnametomib.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright 2001 The FreeBSD Project. All Rights Reserved.
*
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/sysctlnametomib.c 204170 2010-02-21 13:57:02Z ed $");
#include <sys/types.h>
#include <sys/sysctl.h>
Modified: trunk/lib/libc/gen/syslog.3
===================================================================
--- trunk/lib/libc/gen/syslog.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/syslog.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)syslog.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/syslog.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd December 30, 2004
.Dt SYSLOG 3
Property changes on: trunk/lib/libc/gen/syslog.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/syslog.c
===================================================================
--- trunk/lib/libc/gen/syslog.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/syslog.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/syslog.c 320312 2017-06-24 14:44:59Z kib $");
#include "namespace.h"
#include <sys/types.h>
@@ -129,8 +130,8 @@
va_end(ap);
}
-void
-vsyslog(int pri, const char *fmt, va_list ap)
+static void
+vsyslog1(int pri, const char *fmt, va_list ap)
{
int cnt;
char ch, *p;
@@ -151,13 +152,9 @@
saved_errno = errno;
- THREAD_LOCK();
-
/* Check priority against setlogmask values. */
- if (!(LOG_MASK(LOG_PRI(pri)) & LogMask)) {
- THREAD_UNLOCK();
+ if (!(LOG_MASK(LOG_PRI(pri)) & LogMask))
return;
- }
/* Set default facility if none specified. */
if ((pri & LOG_FACMASK) == 0)
@@ -167,10 +164,8 @@
tbuf_cookie.base = tbuf;
tbuf_cookie.left = sizeof(tbuf);
fp = fwopen(&tbuf_cookie, writehook);
- if (fp == NULL) {
- THREAD_UNLOCK();
+ if (fp == NULL)
return;
- }
/* Build the message. */
(void)time(&now);
@@ -200,7 +195,6 @@
fmt_fp = fwopen(&fmt_cookie, writehook);
if (fmt_fp == NULL) {
fclose(fp);
- THREAD_UNLOCK();
return;
}
@@ -261,38 +255,51 @@
connectlog();
/*
- * If the send() failed, there are two likely scenarios:
+ * If the send() fails, there are two likely scenarios:
* 1) syslogd was restarted
* 2) /var/run/log is out of socket buffer space, which
* in most cases means local DoS.
- * We attempt to reconnect to /var/run/log[priv] to take care of
- * case #1 and keep send()ing data to cover case #2
- * to give syslogd a chance to empty its socket buffer.
+ * If the error does not indicate a full buffer, we address
+ * case #1 by attempting to reconnect to /var/run/log[priv]
+ * and resending the message once.
*
- * If we are working with a priveleged socket, then take
- * only one attempt, because we don't want to freeze a
+ * If we are working with a privileged socket, the retry
+ * attempts end there, because we don't want to freeze a
* critical application like su(1) or sshd(8).
*
+ * Otherwise, we address case #2 by repeatedly retrying the
+ * send() to give syslogd a chance to empty its socket buffer.
*/
if (send(LogFile, tbuf, cnt, 0) < 0) {
if (errno != ENOBUFS) {
+ /*
+ * Scenario 1: syslogd was restarted
+ * reconnect and resend once
+ */
disconnectlog();
connectlog();
+ if (send(LogFile, tbuf, cnt, 0) >= 0)
+ return;
+ /*
+ * if the resend failed, fall through to
+ * possible scenario 2
+ */
}
- do {
+ while (errno == ENOBUFS) {
+ /*
+ * Scenario 2: out of socket buffer space
+ * possible DoS, fail fast on a privileged
+ * socket
+ */
if (status == CONNPRIV)
break;
_usleep(1);
- if (send(LogFile, tbuf, cnt, 0) >= 0) {
- THREAD_UNLOCK();
+ if (send(LogFile, tbuf, cnt, 0) >= 0)
return;
- }
- } while (errno == ENOBUFS);
- } else {
- THREAD_UNLOCK();
+ }
+ } else
return;
- }
/*
* Output the message to the console; try not to block
@@ -300,7 +307,8 @@
* Make sure the error reported is the one from the syslogd failure.
*/
if (LogStat & LOG_CONS &&
- (fd = _open(_PATH_CONSOLE, O_WRONLY|O_NONBLOCK, 0)) >= 0) {
+ (fd = _open(_PATH_CONSOLE, O_WRONLY|O_NONBLOCK|O_CLOEXEC, 0)) >=
+ 0) {
struct iovec iov[2];
struct iovec *v = iov;
@@ -313,10 +321,25 @@
(void)_writev(fd, iov, 2);
(void)_close(fd);
}
+}
+static void
+syslog_cancel_cleanup(void *arg __unused)
+{
+
THREAD_UNLOCK();
}
+void
+vsyslog(int pri, const char *fmt, va_list ap)
+{
+
+ THREAD_LOCK();
+ pthread_cleanup_push(syslog_cancel_cleanup, NULL);
+ vsyslog1(pri, fmt, ap);
+ pthread_cleanup_pop(1);
+}
+
/* Should be called with mutex acquired */
static void
disconnectlog(void)
@@ -349,7 +372,7 @@
SyslogAddr.sun_family = AF_UNIX;
/*
- * First try priveleged socket. If no success,
+ * First try privileged socket. If no success,
* then try default socket.
*/
(void)strncpy(SyslogAddr.sun_path, _PATH_LOG_PRIV,
@@ -403,9 +426,11 @@
void
openlog(const char *ident, int logstat, int logfac)
{
+
THREAD_LOCK();
+ pthread_cleanup_push(syslog_cancel_cleanup, NULL);
openlog_unlocked(ident, logstat, logfac);
- THREAD_UNLOCK();
+ pthread_cleanup_pop(1);
}
Modified: trunk/lib/libc/gen/tcgetpgrp.3
===================================================================
--- trunk/lib/libc/gen/tcgetpgrp.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/tcgetpgrp.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)tcgetpgrp.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/tcgetpgrp.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 4, 1993
.Dt TCGETPGRP 3
Property changes on: trunk/lib/libc/gen/tcgetpgrp.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/tcgetsid.3
===================================================================
--- trunk/lib/libc/gen/tcgetsid.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/tcgetsid.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008 David Xu <davidxu at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -22,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/tcgetsid.3 208291 2010-05-19 08:57:53Z uqs $
.\"
.Dd April 15, 2008
.Dt TCGETSID 3
Property changes on: trunk/lib/libc/gen/tcgetsid.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/tcsendbreak.3
===================================================================
--- trunk/lib/libc/gen/tcsendbreak.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/tcsendbreak.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)tcsendbreak.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/tcsendbreak.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 4, 1993
.Dt TCSENDBREAK 3
Property changes on: trunk/lib/libc/gen/tcsendbreak.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/tcsetattr.3
===================================================================
--- trunk/lib/libc/gen/tcsetattr.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/tcsetattr.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)tcsetattr.3 8.3 (Berkeley) 1/2/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/tcsetattr.3 214680 2010-11-02 17:00:56Z ed $
.\"
.Dd January 2, 1994
.Dt TCSETATTR 3
Property changes on: trunk/lib/libc/gen/tcsetattr.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/tcsetpgrp.3
===================================================================
--- trunk/lib/libc/gen/tcsetpgrp.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/tcsetpgrp.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)tcsetpgrp.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/tcsetpgrp.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 4, 1993
.Dt TCSETPGRP 3
Property changes on: trunk/lib/libc/gen/tcsetpgrp.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/tcsetsid.3
===================================================================
--- trunk/lib/libc/gen/tcsetsid.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/tcsetsid.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2009 Ed Schouten <ed at FreeBSD.org>
.\" All rights reserved.
.\"
@@ -22,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/tcsetsid.3 191882 2009-05-07 13:49:48Z ed $
.\"
.Dd May 4, 2009
.Dt TCSETSID 3
Property changes on: trunk/lib/libc/gen/tcsetsid.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/telldir.c
===================================================================
--- trunk/lib/libc/gen/telldir.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/telldir.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)telldir.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/telldir.c 317634 2017-05-01 06:03:44Z mav $");
#include "namespace.h"
#include <sys/param.h>
@@ -43,16 +44,10 @@
#include "un-namespace.h"
#include "libc_private.h"
+#include "gen-private.h"
#include "telldir.h"
/*
- * The option SINGLEUSE may be defined to say that a telldir
- * cookie may be used only once before it is freed. This option
- * is used to avoid having memory usage grow without bound.
- */
-#define SINGLEUSE
-
-/*
* return a pointer into a directory
*/
long
@@ -59,19 +54,42 @@
telldir(dirp)
DIR *dirp;
{
- struct ddloc *lp;
+ struct ddloc *lp, *flp;
+ long idx;
- if ((lp = (struct ddloc *)malloc(sizeof(struct ddloc))) == NULL)
- return (-1);
if (__isthreaded)
_pthread_mutex_lock(&dirp->dd_lock);
- lp->loc_index = dirp->dd_td->td_loccnt++;
- lp->loc_seek = dirp->dd_seek;
- lp->loc_loc = dirp->dd_loc;
- LIST_INSERT_HEAD(&dirp->dd_td->td_locq, lp, loc_lqe);
+ flp = NULL;
+ LIST_FOREACH(lp, &dirp->dd_td->td_locq, loc_lqe) {
+ if (lp->loc_seek == dirp->dd_seek) {
+ if (flp == NULL)
+ flp = lp;
+ if (lp->loc_loc == dirp->dd_loc)
+ break;
+ } else if (flp != NULL) {
+ lp = NULL;
+ break;
+ }
+ }
+ if (lp == NULL) {
+ lp = malloc(sizeof(struct ddloc));
+ if (lp == NULL) {
+ if (__isthreaded)
+ _pthread_mutex_unlock(&dirp->dd_lock);
+ return (-1);
+ }
+ lp->loc_index = dirp->dd_td->td_loccnt++;
+ lp->loc_seek = dirp->dd_seek;
+ lp->loc_loc = dirp->dd_loc;
+ if (flp != NULL)
+ LIST_INSERT_BEFORE(flp, lp, loc_lqe);
+ else
+ LIST_INSERT_HEAD(&dirp->dd_td->td_locq, lp, loc_lqe);
+ }
+ idx = lp->loc_index;
if (__isthreaded)
_pthread_mutex_unlock(&dirp->dd_lock);
- return (lp->loc_index);
+ return (idx);
}
/*
@@ -93,23 +111,55 @@
if (lp == NULL)
return;
if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek)
- goto found;
+ return;
+
+ /* If it's within the same chunk of data, don't bother reloading. */
+ if (lp->loc_seek == dirp->dd_seek) {
+ /*
+ * If we go back to 0 don't make the next readdir
+ * trigger a call to getdirentries().
+ */
+ if (lp->loc_loc == 0)
+ dirp->dd_flags |= __DTF_SKIPREAD;
+ dirp->dd_loc = lp->loc_loc;
+ return;
+ }
(void) lseek(dirp->dd_fd, (off_t)lp->loc_seek, SEEK_SET);
dirp->dd_seek = lp->loc_seek;
dirp->dd_loc = 0;
+ dirp->dd_flags &= ~__DTF_SKIPREAD; /* current contents are invalid */
while (dirp->dd_loc < lp->loc_loc) {
dp = _readdir_unlocked(dirp, 0);
if (dp == NULL)
break;
}
-found:
-#ifdef SINGLEUSE
- LIST_REMOVE(lp, loc_lqe);
- free((caddr_t)lp);
-#endif
}
/*
+ * After readdir returns the last entry in a block, a call to telldir
+ * returns a location that is after the end of that last entry.
+ * However, that location doesn't refer to a valid directory entry.
+ * Ideally, the call to telldir would return a location that refers to
+ * the first entry in the next block. That location is not known
+ * until the next block is read, so readdir calls this function after
+ * fetching a new block to fix any such telldir locations.
+ */
+void
+_fixtelldir(DIR *dirp, long oldseek, long oldloc)
+{
+ struct ddloc *lp;
+
+ lp = LIST_FIRST(&dirp->dd_td->td_locq);
+ if (lp != NULL) {
+ if (lp->loc_loc == oldloc &&
+ lp->loc_seek == oldseek) {
+ lp->loc_seek = dirp->dd_seek;
+ lp->loc_loc = dirp->dd_loc;
+ }
+ }
+}
+
+/*
* Reclaim memory for telldir cookies which weren't used.
*/
void
Modified: trunk/lib/libc/gen/telldir.h
===================================================================
--- trunk/lib/libc/gen/telldir.h 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/telldir.h 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -29,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/telldir.h 282979 2015-05-15 15:49:24Z julian $
*/
#ifndef _TELLDIR_H_
@@ -36,6 +37,7 @@
#define _TELLDIR_H_
#include <sys/queue.h>
+#include <stdbool.h>
/*
* One of these structures is malloced to describe the current directory
@@ -59,8 +61,10 @@
long td_loccnt; /* index of entry for sequential readdir's */
};
+bool _filldir(DIR *, bool);
struct dirent *_readdir_unlocked(DIR *, int);
void _reclaim_telldir(DIR *);
void _seekdir(DIR *, long);
+void _fixtelldir(DIR *dirp, long oldseek, long oldloc);
#endif
Modified: trunk/lib/libc/gen/termios.c
===================================================================
--- trunk/lib/libc/gen/termios.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/termios.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/termios.c 277317 2015-01-18 11:54:20Z kib $");
#include "namespace.h"
#include <sys/types.h>
@@ -46,6 +47,8 @@
#include <unistd.h>
#include "un-namespace.h"
+#include "libc_private.h"
+
int
tcgetattr(int fd, struct termios *t)
{
@@ -208,14 +211,24 @@
}
int
-__tcdrain(int fd)
+__libc_tcdrain(int fd)
{
+
return (_ioctl(fd, TIOCDRAIN, 0));
}
-__weak_reference(__tcdrain, tcdrain);
-__weak_reference(__tcdrain, _tcdrain);
+#pragma weak tcdrain
+int
+tcdrain(int fd)
+{
+ return (((int (*)(int))
+ __libc_interposing[INTERPOS_tcdrain])(fd));
+}
+
+__weak_reference(__libc_tcdrain, __tcdrain);
+__weak_reference(__libc_tcdrain, _tcdrain);
+
int
tcflush(int fd, int which)
{
Modified: trunk/lib/libc/gen/time.3
===================================================================
--- trunk/lib/libc/gen/time.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/time.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -30,7 +31,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)time.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/time.3 201201 2009-12-29 14:29:08Z kib $
.\"
.Dd July 18, 2003
.Dt TIME 3
Property changes on: trunk/lib/libc/gen/time.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/time.c
===================================================================
--- trunk/lib/libc/gen/time.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/time.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/time.c 201194 2009-12-29 12:47:47Z kib $");
#include <sys/types.h>
#include <sys/time.h>
Modified: trunk/lib/libc/gen/times.3
===================================================================
--- trunk/lib/libc/gen/times.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/times.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)times.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/times.3 185519 2008-12-01 15:27:00Z keramida $
.\"
.Dd December 1, 2008
.Dt TIMES 3
Property changes on: trunk/lib/libc/gen/times.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/times.c
===================================================================
--- trunk/lib/libc/gen/times.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/times.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)times.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/times.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/param.h>
#include <sys/time.h>
Modified: trunk/lib/libc/gen/timezone.3
===================================================================
--- trunk/lib/libc/gen/timezone.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/timezone.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)timezone.3 8.2 (Berkeley) 4/19/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/timezone.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd April 19, 1994
.Dt TIMEZONE 3
Property changes on: trunk/lib/libc/gen/timezone.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/timezone.c
===================================================================
--- trunk/lib/libc/gen/timezone.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/timezone.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1987, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)timezone.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/timezone.c 229403 2012-01-03 18:51:58Z ed $");
#include <sys/types.h>
#include <sys/time.h>
@@ -59,7 +60,7 @@
*end;
if ( (beg = getenv("TZNAME")) ) { /* set in environment */
- if ( (end = index(beg, ',')) ) {/* "PST,PDT" */
+ if ((end = strchr(beg, ','))) { /* "PST,PDT" */
if (dst)
return(++end);
*end = '\0';
Modified: trunk/lib/libc/gen/tls.c
===================================================================
--- trunk/lib/libc/gen/tls.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/tls.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Doug Rabson
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/tls.c 324617 2017-10-14 16:49:39Z brooks $
*/
/*
@@ -39,6 +40,11 @@
#include "libc_private.h"
+/* Provided by jemalloc to avoid bootstrapping issues. */
+void *__jemalloc_a0malloc(size_t size);
+void *__jemalloc_a0calloc(size_t num, size_t size);
+void __jemalloc_a0free(void *ptr);
+
__weak_reference(__libc_allocate_tls, _rtld_allocate_tls);
__weak_reference(__libc_free_tls, _rtld_free_tls);
@@ -66,12 +72,11 @@
#error TLS_TCB_ALIGN undefined for target architecture
#endif
-#if defined(__arm__) || defined(__ia64__) || \
+#if defined(__arm__) || defined(__ia64__) || defined(__mips__) || \
defined(__powerpc__)
#define TLS_VARIANT_I
#endif
-#if defined(__i386__) || defined(__amd64__) || defined(__sparc64__) || \
- defined(__mips__)
+#if defined(__i386__) || defined(__amd64__) || defined(__sparc64__)
#define TLS_VARIANT_II
#endif
@@ -121,8 +126,8 @@
tls = (Elf_Addr **)((Elf_Addr)tcb + tcbsize - TLS_TCB_SIZE);
dtv = tls[0];
- free(dtv);
- free(tcb);
+ __jemalloc_a0free(dtv);
+ __jemalloc_a0free(tcb);
}
/*
@@ -138,18 +143,18 @@
if (oldtcb != NULL && tcbsize == TLS_TCB_SIZE)
return (oldtcb);
- tcb = calloc(1, tls_static_space + tcbsize - TLS_TCB_SIZE);
+ tcb = __jemalloc_a0calloc(1, tls_static_space + tcbsize - TLS_TCB_SIZE);
tls = (Elf_Addr **)(tcb + tcbsize - TLS_TCB_SIZE);
if (oldtcb != NULL) {
memcpy(tls, oldtcb, tls_static_space);
- free(oldtcb);
+ __jemalloc_a0free(oldtcb);
/* Adjust the DTV. */
dtv = tls[0];
dtv[2] = (Elf_Addr)tls + TLS_TCB_SIZE;
} else {
- dtv = malloc(3 * sizeof(Elf_Addr));
+ dtv = __jemalloc_a0malloc(3 * sizeof(Elf_Addr));
tls[0] = dtv;
dtv[0] = 1;
dtv[1] = 1;
@@ -157,9 +162,6 @@
if (tls_init_size > 0)
memcpy((void*)dtv[2], tls_init, tls_init_size);
- if (tls_static_space > tls_init_size)
- memset((void*)(dtv[2] + tls_init_size), 0,
- tls_static_space - tls_init_size);
}
return(tcb);
@@ -190,8 +192,8 @@
dtv = ((Elf_Addr**)tcb)[1];
tlsend = (Elf_Addr) tcb;
tlsstart = tlsend - size;
- free((void*) tlsstart);
- free(dtv);
+ __jemalloc_a0free((void*) tlsstart);
+ __jemalloc_a0free(dtv);
}
/*
@@ -209,8 +211,8 @@
if (tcbsize < 2 * sizeof(Elf_Addr))
tcbsize = 2 * sizeof(Elf_Addr);
- tls = calloc(1, size + tcbsize);
- dtv = malloc(3 * sizeof(Elf_Addr));
+ tls = __jemalloc_a0calloc(1, size + tcbsize);
+ dtv = __jemalloc_a0malloc(3 * sizeof(Elf_Addr));
segbase = (Elf_Addr)(tls + size);
((Elf_Addr*)segbase)[0] = segbase;
@@ -280,7 +282,7 @@
while (*sp++ != 0)
;
aux = (Elf_Auxinfo *) sp;
- phdr = 0;
+ phdr = NULL;
phent = phnum = 0;
for (auxp = aux; auxp->a_type != AT_NULL; auxp++) {
switch (auxp->a_type) {
@@ -297,7 +299,7 @@
break;
}
}
- if (phdr == 0 || phent != sizeof(Elf_Phdr) || phnum == 0)
+ if (phdr == NULL || phent != sizeof(Elf_Phdr) || phnum == 0)
return;
for (i = 0; (unsigned) i < phnum; i++) {
Modified: trunk/lib/libc/gen/ttyname.3
===================================================================
--- trunk/lib/libc/gen/ttyname.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ttyname.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ttyname.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/ttyname.3 278417 2015-02-08 22:29:06Z jilles $
.\"
-.Dd May 14, 2005
+.Dd July 18, 2014
.Dt TTYNAME 3
.Os
.Sh NAME
@@ -76,6 +77,14 @@
takes a buffer and length as arguments to avoid this problem.
.Sh RETURN VALUES
The
+.Fn isatty
+function returns 1 if
+.Fa fd
+refers to a terminal type device;
+otherwise, it returns 0 and may set
+.Va errno
+to indicate the error.
+The
.Fn ttyname
function
returns the null terminated name if the device is found and
@@ -89,15 +98,23 @@
function returns 0 if successful.
Otherwise an error number is returned.
.Sh ERRORS
-The
-.Fn ttyname_r
-may fail and return the following error codes:
+These functions may fail if:
.Bl -tag -width Er
-.It Bq Er ENOTTY
+.It Bq Er EBADF
The
.Fa fd
argument
is not a valid file descriptor.
+.It Bq Er ENOTTY
+The file associated with
+.Fa fd
+is not a terminal.
+.El
+.Pp
+Additionally,
+.Fn ttyname_r
+may fail if:
+.Bl -tag -width Er
.It Bq Er ERANGE
The
.Fa bufsize
Property changes on: trunk/lib/libc/gen/ttyname.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/ttyname.c
===================================================================
--- trunk/lib/libc/gen/ttyname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ttyname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)ttyname.c 8.2 (Berkeley) 1/27/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/ttyname.c 317392 2017-04-24 22:44:59Z brooks $");
#include "namespace.h"
#include <sys/types.h>
@@ -61,11 +62,15 @@
{
size_t used;
+ /* Don't write off the end of a zero-length buffer. */
+ if (len < 1)
+ return (ERANGE);
+
*buf = '\0';
/* Must be a terminal. */
if (!isatty(fd))
- return (ENOTTY);
+ return (errno);
/* Must have enough room */
if (len <= sizeof(_PATH_DEV))
return (ERANGE);
@@ -73,7 +78,7 @@
strcpy(buf, _PATH_DEV);
used = strlen(buf);
if (fdevname_r(fd, buf + used, len - used) == NULL)
- return (ENOTTY);
+ return (errno == EINVAL ? ERANGE : errno);
return (0);
}
Modified: trunk/lib/libc/gen/ttyslot.c
===================================================================
--- trunk/lib/libc/gen/ttyslot.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ttyslot.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)ttyslot.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/ttyslot.c 202487 2010-01-17 15:43:14Z ed $");
int
__ttyslot(void)
Modified: trunk/lib/libc/gen/tzset.3
===================================================================
--- trunk/lib/libc/gen/tzset.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/tzset.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -29,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)tzset.3 8.2 (Berkeley) 11/17/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/tzset.3 199405 2009-11-17 16:29:39Z obrien $
.\"
.Dd November 17, 1993
.Dt TZSET 3
Property changes on: trunk/lib/libc/gen/tzset.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/ualarm.3
===================================================================
--- trunk/lib/libc/gen/ualarm.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ualarm.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1986, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)ualarm.3 8.2 (Berkeley) 4/19/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/ualarm.3 207735 2010-05-06 22:49:54Z jilles $
.\"
.Dd April 19, 1994
.Dt UALARM 3
Property changes on: trunk/lib/libc/gen/ualarm.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/ualarm.c
===================================================================
--- trunk/lib/libc/gen/ualarm.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ualarm.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)ualarm.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/ualarm.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/time.h>
#include <unistd.h>
Modified: trunk/lib/libc/gen/ucontext.3
===================================================================
--- trunk/lib/libc/gen/ucontext.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ucontext.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2002 Packet Design, LLC.
.\" All rights reserved.
.\"
@@ -33,7 +34,7 @@
.\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
.\" THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/ucontext.3 230429 2012-01-21 18:00:28Z kib $
.\"
.Dd September 10, 2002
.Dt UCONTEXT 3
Property changes on: trunk/lib/libc/gen/ucontext.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/ulimit.3
===================================================================
--- trunk/lib/libc/gen/ulimit.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ulimit.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2002 Kyle Martin. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -21,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/ulimit.3 108637 2003-01-04 01:11:49Z tjr $
.\"
.Dd January 4, 2003
.Dt ULIMIT 3
Property changes on: trunk/lib/libc/gen/ulimit.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/ulimit.c
===================================================================
--- trunk/lib/libc/gen/ulimit.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/ulimit.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2002 Kyle Martin <mkm at ieee.org>
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/ulimit.c 279129 2015-02-22 01:31:28Z pfg $
*/
#include <sys/types.h>
@@ -40,7 +41,7 @@
{
struct rlimit limit;
va_list ap;
- long arg;
+ rlim_t arg;
if (cmd == UL_GETFSIZE) {
if (getrlimit(RLIMIT_FSIZE, &limit) == -1)
@@ -53,14 +54,16 @@
va_start(ap, cmd);
arg = va_arg(ap, long);
va_end(ap);
- limit.rlim_max = limit.rlim_cur = (rlim_t)arg * 512;
+ if (arg < 0)
+ arg = LONG_MAX;
+ if (arg > RLIM_INFINITY / 512)
+ arg = RLIM_INFINITY / 512;
+ limit.rlim_max = limit.rlim_cur = arg * 512;
/* The setrlimit() function sets errno to EPERM if needed. */
if (setrlimit(RLIMIT_FSIZE, &limit) == -1)
return (-1);
- if (arg * 512 > LONG_MAX)
- return (LONG_MAX);
- return (arg);
+ return ((long)arg);
} else {
errno = EINVAL;
return (-1);
Modified: trunk/lib/libc/gen/uname.3
===================================================================
--- trunk/lib/libc/gen/uname.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/uname.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1994
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)uname.3 8.1 (Berkeley) 1/4/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/uname.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd December 2, 2005
.Dt UNAME 3
Property changes on: trunk/lib/libc/gen/uname.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/uname.c
===================================================================
--- trunk/lib/libc/gen/uname.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/uname.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "From: @(#)uname.c 8.1 (Berkeley) 1/4/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/uname.c 202661 2010-01-19 23:07:12Z ed $");
#define uname wrapped_uname
#include <sys/param.h>
Modified: trunk/lib/libc/gen/unvis-compat.c
===================================================================
--- trunk/lib/libc/gen/unvis-compat.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/unvis-compat.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2012 SRI International
* All rights reserved.
@@ -27,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/unvis-compat.c 244401 2012-12-18 16:37:24Z brooks $
*/
#include <vis.h>
Modified: trunk/lib/libc/gen/usleep.3
===================================================================
--- trunk/lib/libc/gen/usleep.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/usleep.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1986, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)usleep.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/usleep.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd February 13, 1998
.Dt USLEEP 3
Property changes on: trunk/lib/libc/gen/usleep.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/usleep.c
===================================================================
--- trunk/lib/libc/gen/usleep.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/usleep.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)usleep.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/usleep.c 277317 2015-01-18 11:54:20Z kib $");
#include "namespace.h"
#include <time.h>
@@ -38,6 +39,8 @@
#include <unistd.h>
#include "un-namespace.h"
+#include "libc_private.h"
+
int
__usleep(useconds_t useconds)
{
@@ -45,7 +48,8 @@
time_to_sleep.tv_nsec = (useconds % 1000000) * 1000;
time_to_sleep.tv_sec = useconds / 1000000;
- return (_nanosleep(&time_to_sleep, NULL));
+ return (((int (*)(const struct timespec *, struct timespec *))
+ __libc_interposing[INTERPOS_nanosleep])(&time_to_sleep, NULL));
}
__weak_reference(__usleep, usleep);
Modified: trunk/lib/libc/gen/utime.3
===================================================================
--- trunk/lib/libc/gen/utime.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/utime.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)utime.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/utime.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd June 4, 1993
.Dt UTIME 3
Property changes on: trunk/lib/libc/gen/utime.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/utime.c
===================================================================
--- trunk/lib/libc/gen/utime.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/utime.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)utime.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/utime.c 165903 2007-01-09 00:28:16Z imp $");
#include <sys/time.h>
Modified: trunk/lib/libc/gen/utxdb.c
===================================================================
--- trunk/lib/libc/gen/utxdb.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/utxdb.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2010 Ed Schouten <ed at FreeBSD.org>
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/utxdb.c 233345 2012-03-23 08:26:31Z ed $");
#include "namespace.h"
#include <sys/endian.h>
@@ -126,7 +127,11 @@
struct utmpx *
futx_to_utx(const struct futx *fu)
{
+#ifdef __NO_TLS
static struct utmpx *ut;
+#else
+ static _Thread_local struct utmpx *ut;
+#endif
if (ut == NULL) {
ut = calloc(1, sizeof *ut);
Modified: trunk/lib/libc/gen/utxdb.h
===================================================================
--- trunk/lib/libc/gen/utxdb.h 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/utxdb.h 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2010 Ed Schouten <ed at FreeBSD.org>
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: stable/10/lib/libc/gen/utxdb.h 202530 2010-01-17 21:40:05Z ed $
*/
#ifndef _UTXDB_H_
Modified: trunk/lib/libc/gen/valloc.3
===================================================================
--- trunk/lib/libc/gen/valloc.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/valloc.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)valloc.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/valloc.3 173182 2007-10-30 15:26:20Z keramida $
.\"
.Dd October 30, 2007
.Dt VALLOC 3
Property changes on: trunk/lib/libc/gen/valloc.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/valloc.c
===================================================================
--- trunk/lib/libc/gen/valloc.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/valloc.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)valloc.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/valloc.c 165903 2007-01-09 00:28:16Z imp $");
#include <stdlib.h>
#include <unistd.h>
Modified: trunk/lib/libc/gen/wait.c
===================================================================
--- trunk/lib/libc/gen/wait.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/wait.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)wait.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/wait.c 277317 2015-01-18 11:54:20Z kib $");
#include "namespace.h"
#include <sys/types.h>
@@ -40,10 +41,14 @@
#include <sys/resource.h>
#include "un-namespace.h"
+#include "libc_private.h"
+
pid_t
__wait(int *istat)
{
- return (_wait4(WAIT_ANY, istat, 0, (struct rusage *)0));
+
+ return (((pid_t (*)(pid_t, int *, int, struct rusage *))
+ __libc_interposing[INTERPOS_wait4])(WAIT_ANY, istat, 0, NULL));
}
__weak_reference(__wait, wait);
Modified: trunk/lib/libc/gen/wait3.c
===================================================================
--- trunk/lib/libc/gen/wait3.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/wait3.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)wait3.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/wait3.c 277317 2015-01-18 11:54:20Z kib $");
#include "namespace.h"
#include <sys/types.h>
@@ -40,11 +41,14 @@
#include <sys/resource.h>
#include "un-namespace.h"
+#include "libc_private.h"
+
pid_t
-wait3(istat, options, rup)
- int *istat;
- int options;
- struct rusage *rup;
+__wait3(int *istat, int options, struct rusage *rup)
{
- return (_wait4(WAIT_ANY, istat, options, rup));
+
+ return (((pid_t (*)(pid_t, int *, int, struct rusage *))
+ __libc_interposing[INTERPOS_wait4])(WAIT_ANY, istat, options, rup));
}
+
+__weak_reference(__wait3, wait3);
Modified: trunk/lib/libc/gen/waitid.c
===================================================================
--- trunk/lib/libc/gen/waitid.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/waitid.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2012 Jukka A. Ukkonen
* All rights reserved.
@@ -27,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/waitid.c 281981 2015-04-25 08:14:08Z kib $");
#include "namespace.h"
#include <sys/types.h>
@@ -37,6 +38,7 @@
#include <signal.h>
#include <errno.h>
#include "un-namespace.h"
+#include "libc_private.h"
int
__waitid(idtype_t idtype, id_t id, siginfo_t *info, int flags)
@@ -44,7 +46,9 @@
int status;
pid_t ret;
- ret = _wait6(idtype, id, &status, flags, NULL, info);
+ ret = ((pid_t (*)(idtype_t, id_t, int *, int, struct __wrusage *,
+ siginfo_t *))__libc_interposing[INTERPOS_wait6])(idtype, id,
+ &status, flags, NULL, info);
/*
* According to SUSv4, waitid() shall not return a PID when a
Modified: trunk/lib/libc/gen/waitpid.c
===================================================================
--- trunk/lib/libc/gen/waitpid.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/waitpid.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)waitpid.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/waitpid.c 277317 2015-01-18 11:54:20Z kib $");
#include "namespace.h"
#include <sys/types.h>
@@ -40,10 +41,14 @@
#include <sys/resource.h>
#include "un-namespace.h"
+#include "libc_private.h"
+
pid_t
__waitpid(pid_t pid, int *istat, int options)
{
- return (_wait4(pid, istat, options, (struct rusage *)0));
+
+ return (((pid_t (*)(pid_t, int *, int, struct rusage *))
+ __libc_interposing[INTERPOS_wait4])(pid, istat, options, NULL));
}
__weak_reference(__waitpid, waitpid);
Modified: trunk/lib/libc/gen/wordexp.3
===================================================================
--- trunk/lib/libc/gen/wordexp.3 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/wordexp.3 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"
.\" Copyright (c) 2002 Tim J. Robbins
.\" All rights reserved.
@@ -23,9 +24,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/gen/wordexp.3 289938 2015-10-25 17:17:50Z jilles $
.\"
-.Dd July 29, 2004
+.Dd September 30, 2015
.Dt WORDEXP 3
.Os
.Sh NAME
@@ -108,8 +109,8 @@
.Sh IMPLEMENTATION NOTES
The
.Fn wordexp
-function is implemented as a wrapper around the undocumented
-.Ic wordexp
+function is implemented using the undocumented
+.Ic freebsd_wordexp
shell built-in command.
.Sh RETURN VALUES
The
@@ -189,18 +190,19 @@
functions conform to
.St -p1003.1-2001 .
.Sh BUGS
-Do not pass untrusted user data to
-.Fn wordexp ,
-regardless of whether the
-.Dv WRDE_NOCMD
-flag is set.
-The
+The current
.Fn wordexp
-function attempts to detect input that would cause commands to be
-executed before passing it to the shell
-but it does not use the same parser so it may be fooled.
+implementation does not recognize multibyte characters other than UTF-8, since
+the shell (which it invokes to perform expansions) does not.
+.Sh SECURITY CONSIDERATIONS
+Pathname generation may create output that is exponentially larger than the
+input size.
.Pp
-The current
-.Fn wordexp
-implementation does not recognize multibyte characters, since the
-shell (which it invokes to perform expansions) does not.
+Although this implementation detects command substitution reliably for
+.Dv WRDE_NOCMD ,
+the attack surface remains fairly large.
+Also, some other implementations
+(such as older versions of this one)
+may execute command substitutions even if
+.Dv WRDE_NOCMD
+is set.
Property changes on: trunk/lib/libc/gen/wordexp.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/gen/wordexp.c
===================================================================
--- trunk/lib/libc/gen/wordexp.c 2018-06-09 15:32:00 UTC (rev 10620)
+++ trunk/lib/libc/gen/wordexp.c 2018-06-09 15:41:32 UTC (rev 10621)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2002 Tim J. Robbins.
* All rights reserved.
@@ -32,6 +33,7 @@
#include <fcntl.h>
#include <paths.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -38,11 +40,12 @@
#include <unistd.h>
#include <wordexp.h>
#include "un-namespace.h"
+#include "libc_private.h"
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/gen/wordexp.c 289938 2015-10-25 17:17:50Z jilles $");
static int we_askshell(const char *, wordexp_t *, int);
-static int we_check(const char *, int);
+static int we_check(const char *);
/*
* wordexp --
@@ -64,7 +67,7 @@
we->we_strings = NULL;
we->we_nbytes = 0;
}
- if ((error = we_check(words, flags)) != 0) {
+ if ((error = we_check(words)) != 0) {
wordfree(we);
return (error);
}
@@ -93,18 +96,37 @@
return done;
}
+static bool
+we_write_fully(int fd, const char *buffer, size_t len)
+{
+ size_t done;
+ ssize_t nwritten;
+
+ done = 0;
+ do {
+ nwritten = _write(fd, buffer + done, len - done);
+ if (nwritten == -1 && errno == EINTR)
+ continue;
+ if (nwritten <= 0)
+ return (false);
+ done += nwritten;
+ } while (done != len);
+ return (true);
+}
+
/*
* we_askshell --
- * Use the `wordexp' /bin/sh builtin function to do most of the work
- * in expanding the word string. This function is complicated by
+ * Use the `freebsd_wordexp' /bin/sh builtin function to do most of the
+ * work in expanding the word string. This function is complicated by
* memory management.
*/
static int
we_askshell(const char *words, wordexp_t *we, int flags)
{
- int pdes[2]; /* Pipe to child */
- char bbuf[9]; /* Buffer for byte count */
- char wbuf[9]; /* Buffer for word count */
+ int pdesw[2]; /* Pipe for writing words */
+ int pdes[2]; /* Pipe for reading output */
+ char wfdstr[sizeof(int) * 3 + 1];
+ char buf[35]; /* Buffer for byte and word count */
long nwords, nbytes; /* Number of words, bytes from child */
long i; /* Handy integer */
size_t sofs; /* Offset into we->we_strings */
@@ -114,72 +136,95 @@
int status; /* Child exit status */
int error; /* Our return value */
int serrno; /* errno to return */
- char *ifs; /* IFS env. var. */
char *np, *p; /* Handy pointers */
char *nstrings; /* Temporary for realloc() */
char **nwv; /* Temporary for realloc() */
sigset_t newsigblock, oldsigblock;
+ const char *ifs;
serrno = errno;
- if ((ifs = getenv("IFS")) == NULL)
- ifs = " \t\n";
+ ifs = getenv("IFS");
- if (pipe(pdes) < 0)
+ if (pipe2(pdesw, O_CLOEXEC) < 0)
return (WRDE_NOSPACE); /* XXX */
+ snprintf(wfdstr, sizeof(wfdstr), "%d", pdesw[0]);
+ if (pipe2(pdes, O_CLOEXEC) < 0) {
+ _close(pdesw[0]);
+ _close(pdesw[1]);
+ return (WRDE_NOSPACE); /* XXX */
+ }
(void)sigemptyset(&newsigblock);
(void)sigaddset(&newsigblock, SIGCHLD);
- (void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock);
+ (void)__libc_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock);
if ((pid = fork()) < 0) {
serrno = errno;
+ _close(pdesw[0]);
+ _close(pdesw[1]);
_close(pdes[0]);
_close(pdes[1]);
- (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
+ (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
errno = serrno;
return (WRDE_NOSPACE); /* XXX */
}
else if (pid == 0) {
/*
- * We are the child; just get /bin/sh to run the wordexp
- * builtin on `words'.
+ * We are the child; make /bin/sh expand `words'.
*/
- int devnull;
- char *cmd;
-
- (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
- _close(pdes[0]);
- if (_dup2(pdes[1], STDOUT_FILENO) < 0)
+ (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
+ if ((pdes[1] != STDOUT_FILENO ?
+ _dup2(pdes[1], STDOUT_FILENO) :
+ _fcntl(pdes[1], F_SETFD, 0)) < 0)
_exit(1);
- _close(pdes[1]);
- if (asprintf(&cmd, "wordexp%c%s\n", *ifs, words) < 0)
+ if (_fcntl(pdesw[0], F_SETFD, 0) < 0)
_exit(1);
- if ((flags & WRDE_SHOWERR) == 0) {
- if ((devnull = _open(_PATH_DEVNULL, O_RDWR, 0666)) < 0)
- _exit(1);
- if (_dup2(devnull, STDERR_FILENO) < 0)
- _exit(1);
- _close(devnull);
- }
execl(_PATH_BSHELL, "sh", flags & WRDE_UNDEF ? "-u" : "+u",
- "-c", cmd, (char *)NULL);
+ "-c", "IFS=$1;eval \"$2\";"
+ "freebsd_wordexp -f \"$3\" ${4:+\"$4\"}",
+ "",
+ ifs != NULL ? ifs : " \t\n",
+ flags & WRDE_SHOWERR ? "" : "exec 2>/dev/null",
+ wfdstr,
+ flags & WRDE_NOCMD ? "-p" : "",
+ (char *)NULL);
_exit(1);
}
/*
- * We are the parent; read the output of the shell wordexp function,
- * which is a 32-bit hexadecimal word count, a 32-bit hexadecimal
- * byte count (not including terminating null bytes), followed by
- * the expanded words separated by nulls.
+ * We are the parent; write the words.
*/
_close(pdes[1]);
- if (we_read_fully(pdes[0], wbuf, 8) != 8 ||
- we_read_fully(pdes[0], bbuf, 8) != 8) {
- error = flags & WRDE_UNDEF ? WRDE_BADVAL : WRDE_SYNTAX;
+ _close(pdesw[0]);
+ if (!we_write_fully(pdesw[1], words, strlen(words))) {
+ _close(pdesw[1]);
+ error = WRDE_SYNTAX;
+ goto cleanup;
+ }
+ _close(pdesw[1]);
+ /*
+ * Read the output of the shell wordexp function,
+ * which is a byte indicating that the words were parsed successfully,
+ * a 64-bit hexadecimal word count, a dummy byte, a 64-bit hexadecimal
+ * byte count (not including terminating null bytes), followed by the
+ * expanded words separated by nulls.
+ */
+ switch (we_read_fully(pdes[0], buf, 34)) {
+ case 1:
+ error = buf[0] == 'C' ? WRDE_CMDSUB :
+ flags & WRDE_UNDEF ? WRDE_BADVAL :
+ WRDE_SYNTAX;
serrno = errno;
goto cleanup;
+ case 34:
+ break;
+ default:
+ error = WRDE_SYNTAX;
+ serrno = errno;
+ goto cleanup;
}
- wbuf[8] = bbuf[8] = '\0';
- nwords = strtol(wbuf, NULL, 16);
- nbytes = strtol(bbuf, NULL, 16) + nwords;
+ buf[17] = '\0';
+ nwords = strtol(buf + 1, NULL, 16);
+ buf[34] = '\0';
+ nbytes = strtol(buf + 18, NULL, 16) + nwords;
/*
* Allocate or reallocate (when flags & WRDE_APPEND) the word vector
@@ -220,7 +265,7 @@
do
wpid = _waitpid(pid, &status, 0);
while (wpid < 0 && errno == EINTR);
- (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
+ (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
if (error != 0) {
errno = serrno;
return (error);
@@ -252,82 +297,96 @@
* we_check --
* Check that the string contains none of the following unquoted
* special characters: <newline> |&;<>(){}
- * or command substitutions when WRDE_NOCMD is set in flags.
+ * This mainly serves for {} which are normally legal in sh.
+ * It deliberately does not attempt to model full sh syntax.
*/
static int
-we_check(const char *words, int flags)
+we_check(const char *words)
{
char c;
- int dquote, level, quote, squote;
+ /* Saw \ or $, possibly not special: */
+ bool quote = false, dollar = false;
+ /* Saw ', ", ${, ` or $(, possibly not special: */
+ bool have_sq = false, have_dq = false, have_par_begin = false;
+ bool have_cmd = false;
+ /* Definitely saw a ', ", ${, ` or $(, need a closing character: */
+ bool need_sq = false, need_dq = false, need_par_end = false;
+ bool need_cmd_old = false, need_cmd_new = false;
- quote = squote = dquote = 0;
while ((c = *words++) != '\0') {
switch (c) {
case '\\':
- quote ^= 1;
+ quote = !quote;
continue;
+ case '$':
+ if (quote)
+ quote = false;
+ else
+ dollar = !dollar;
+ continue;
case '\'':
- if (quote + dquote == 0)
- squote ^= 1;
+ if (!quote && !have_sq && !have_dq)
+ need_sq = true;
+ else
+ need_sq = false;
+ have_sq = true;
break;
case '"':
- if (quote + squote == 0)
- dquote ^= 1;
+ if (!quote && !have_sq && !have_dq)
+ need_dq = true;
+ else
+ need_dq = false;
+ have_dq = true;
break;
case '`':
- if (quote + squote == 0 && flags & WRDE_NOCMD)
- return (WRDE_CMDSUB);
- while ((c = *words++) != '\0' && c != '`')
- if (c == '\\' && (c = *words++) == '\0')
- break;
- if (c == '\0')
- return (WRDE_SYNTAX);
+ if (!quote && !have_sq && !have_cmd)
+ need_cmd_old = true;
+ else
+ need_cmd_old = false;
+ have_cmd = true;
break;
- case '|': case '&': case ';': case '<': case '>':
- case '{': case '}': case '(': case ')': case '\n':
- if (quote + squote + dquote == 0)
+ case '{':
+ if (!quote && !dollar && !have_sq && !have_dq &&
+ !have_cmd)
return (WRDE_BADCHAR);
+ if (dollar) {
+ if (!quote && !have_sq)
+ need_par_end = true;
+ have_par_begin = true;
+ }
break;
- case '$':
- if ((c = *words++) == '\0')
- break;
- else if (quote + squote == 0 && c == '(') {
- if (flags & WRDE_NOCMD && *words != '(')
- return (WRDE_CMDSUB);
- level = 1;
- while ((c = *words++) != '\0') {
- if (c == '\\') {
- if ((c = *words++) == '\0')
- break;
- } else if (c == '(')
- level++;
- else if (c == ')' && --level == 0)
- break;
- }
- if (c == '\0' || level != 0)
- return (WRDE_SYNTAX);
- } else if (quote + squote == 0 && c == '{') {
- level = 1;
- while ((c = *words++) != '\0') {
- if (c == '\\') {
- if ((c = *words++) == '\0')
- break;
- } else if (c == '{')
- level++;
- else if (c == '}' && --level == 0)
- break;
- }
- if (c == '\0' || level != 0)
- return (WRDE_SYNTAX);
- } else
- --words;
+ case '}':
+ if (!quote && !have_sq && !have_dq && !have_par_begin &&
+ !have_cmd)
+ return (WRDE_BADCHAR);
+ need_par_end = false;
break;
+ case '(':
+ if (!quote && !dollar && !have_sq && !have_dq &&
+ !have_cmd)
+ return (WRDE_BADCHAR);
+ if (dollar) {
+ if (!quote && !have_sq)
+ need_cmd_new = true;
+ have_cmd = true;
+ }
+ break;
+ case ')':
+ if (!quote && !have_sq && !have_dq && !have_cmd)
+ return (WRDE_BADCHAR);
+ need_cmd_new = false;
+ break;
+ case '|': case '&': case ';': case '<': case '>': case '\n':
+ if (!quote && !have_sq && !have_dq && !have_cmd)
+ return (WRDE_BADCHAR);
+ break;
default:
break;
}
- quote = 0;
+ quote = dollar = false;
}
- if (quote + squote + dquote != 0)
+ if (quote || dollar || need_sq || need_dq || need_par_end ||
+ need_cmd_old || need_cmd_new)
return (WRDE_SYNTAX);
return (0);
More information about the Midnightbsd-cvs
mailing list