diff options
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/aarch64/gen/sigsetjmp.S | 8 | ||||
| -rw-r--r-- | lib/libc/gen/syslog.c | 46 | ||||
| -rw-r--r-- | lib/libc/include/compat.h | 2 | ||||
| -rw-r--r-- | lib/libc/include/libc_private.h | 7 | ||||
| -rw-r--r-- | lib/libc/rpc/rpcb_clnt.c | 3 | ||||
| -rw-r--r-- | lib/libc/sys/Makefile.inc | 11 | ||||
| -rw-r--r-- | lib/libc/sys/Symbol.map | 2 | ||||
| -rw-r--r-- | lib/libc/sys/compat-ino64.h | 102 | ||||
| -rw-r--r-- | lib/libc/sys/fstat.c | 54 | ||||
| -rw-r--r-- | lib/libc/sys/fstatat.c | 50 | ||||
| -rw-r--r-- | lib/libc/sys/fstatfs.c | 54 | ||||
| -rw-r--r-- | lib/libc/sys/getdents.c | 7 | ||||
| -rw-r--r-- | lib/libc/sys/getdirentries.c | 117 | ||||
| -rw-r--r-- | lib/libc/sys/getfsstat.c | 65 | ||||
| -rw-r--r-- | lib/libc/sys/kqueue.2 | 74 | ||||
| -rw-r--r-- | lib/libc/sys/lstat.c | 14 | ||||
| -rw-r--r-- | lib/libc/sys/mmap.2 | 47 | ||||
| -rw-r--r-- | lib/libc/sys/munmap.2 | 4 | ||||
| -rw-r--r-- | lib/libc/sys/pdfork.2 | 21 | ||||
| -rw-r--r-- | lib/libc/sys/stat.2 | 44 | ||||
| -rw-r--r-- | lib/libc/sys/stat.c | 14 | ||||
| -rw-r--r-- | lib/libc/sys/statfs.c | 50 | ||||
| -rw-r--r-- | lib/libc/sys/wait.2 | 6 | 
23 files changed, 685 insertions, 117 deletions
| diff --git a/lib/libc/aarch64/gen/sigsetjmp.S b/lib/libc/aarch64/gen/sigsetjmp.S index be49f5343871..917e1ef6ee56 100644 --- a/lib/libc/aarch64/gen/sigsetjmp.S +++ b/lib/libc/aarch64/gen/sigsetjmp.S @@ -34,8 +34,10 @@ __FBSDID("$FreeBSD$");  ENTRY(sigsetjmp)  	cmp	x1, #0 -	b.eq	_C_LABEL(_setjmp) +	b.eq	1f  	b	_C_LABEL(setjmp) +1: +	b	_C_LABEL(_setjmp)  END(sigsetjmp)  ENTRY(siglongjmp) @@ -45,8 +47,10 @@ ENTRY(siglongjmp)  	/* Check the magic */  	cmp	x2, x3 -	b.eq	_C_LABEL(_longjmp) +	b.eq	1f  	b	_C_LABEL(longjmp) +1: +	b	_C_LABEL(_longjmp)  	.align	3  .Lmagic:  	.quad	_JB_MAGIC__SETJMP diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index dfca67360fa9..2c390efe95ea 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -129,8 +129,8 @@ syslog(int pri, const char *fmt, ...)  	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 +151,9 @@ vsyslog(int pri, const char *fmt, va_list ap)  	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 +163,8 @@ vsyslog(int pri, const char *fmt, va_list ap)  	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 +194,6 @@ vsyslog(int pri, const char *fmt, va_list ap)  		fmt_fp = fwopen(&fmt_cookie, writehook);  		if (fmt_fp == NULL) {  			fclose(fp); -			THREAD_UNLOCK();  			return;  		} @@ -285,10 +278,8 @@ vsyslog(int pri, const char *fmt, va_list ap)  			 */  			disconnectlog();  			connectlog(); -			if (send(LogFile, tbuf, cnt, 0) >= 0) { -				THREAD_UNLOCK(); +			if (send(LogFile, tbuf, cnt, 0) >= 0)  				return; -			}  			/*  			 * if the resend failed, fall through to  			 * possible scenario 2 @@ -303,15 +294,11 @@ vsyslog(int pri, const char *fmt, va_list ap)  			if (status == CONNPRIV)  				break;  			_usleep(1); -			if (send(LogFile, tbuf, cnt, 0) >= 0) { -				THREAD_UNLOCK(); +			if (send(LogFile, tbuf, cnt, 0) >= 0)  				return; -			}  		} -	} else { -		THREAD_UNLOCK(); +	} else  		return; -	}  	/*  	 * Output the message to the console; try not to block @@ -333,10 +320,25 @@ vsyslog(int pri, const char *fmt, va_list ap)  		(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) @@ -423,9 +425,11 @@ openlog_unlocked(const char *ident, int logstat, int logfac)  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);  } diff --git a/lib/libc/include/compat.h b/lib/libc/include/compat.h index 559c8502fb93..e353b0712430 100644 --- a/lib/libc/include/compat.h +++ b/lib/libc/include/compat.h @@ -65,6 +65,8 @@ __sym_compat(statfs, freebsd11_statfs, FBSD_1.0);  __sym_compat(mknod, freebsd11_mknod, FBSD_1.0);  __sym_compat(mknodat, freebsd11_mknodat, FBSD_1.1); +__sym_compat(kevent, freebsd11_kevent, FBSD_1.0); +  #undef __sym_compat  #define	__weak_reference(sym,alias)	\ diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index 3602a4260053..85674ab3c872 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -311,6 +311,7 @@ struct rusage;  struct sigaction;  struct sockaddr;  struct stat; +struct statfs;  struct timespec;  struct timeval;  struct timezone; @@ -327,13 +328,16 @@ int		__sys_clock_nanosleep(__clockid_t, int,  		    const struct timespec *, struct timespec *);  int		__sys_close(int);  int		__sys_connect(int, const struct sockaddr *, __socklen_t); -__ssize_t	__sys_getdirentries(int, char *, __size_t, __off_t *);  int		__sys_fcntl(int, int, ...);  int		__sys_fdatasync(int); +int		__sys_fstat(int fd, struct stat *); +int		__sys_fstatfs(int fd, struct statfs *);  int		__sys_fstatat(int, const char *, struct stat *, int);  int		__sys_fsync(int);  __pid_t		__sys_fork(void);  int		__sys_ftruncate(int, __off_t); +__ssize_t	__sys_getdirentries(int, char *, __size_t, __off_t *); +int		__sys_getfsstat(struct statfs *, long, int);  int		__sys_gettimeofday(struct timeval *, struct timezone *);  int		__sys_kevent(int, const struct kevent *, int, struct kevent *,  		    int, const struct timespec *); @@ -372,6 +376,7 @@ int		__sys_sigtimedwait(const __sigset_t *, struct __siginfo *,  		    const struct timespec *);  int		__sys_sigwait(const __sigset_t *, int *);  int		__sys_sigwaitinfo(const __sigset_t *, struct __siginfo *); +int		__sys_statfs(const char *, struct statfs *);  int		__sys_swapcontext(struct __ucontext *,  		    const struct __ucontext *);  int		__sys_thr_kill(long, int); diff --git a/lib/libc/rpc/rpcb_clnt.c b/lib/libc/rpc/rpcb_clnt.c index f9d89c1ae814..8c9b8ca22bfb 100644 --- a/lib/libc/rpc/rpcb_clnt.c +++ b/lib/libc/rpc/rpcb_clnt.c @@ -499,14 +499,15 @@ try_nconf:  					hostname = IN6_LOCALHOST_STRING;  			}  		} -		endnetconfig(nc_handle);  		if (tmpnconf == NULL) { +			endnetconfig(nc_handle);  			rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;  			mutex_unlock(&loopnconf_lock);  			return (NULL);  		}  		loopnconf = getnetconfigent(tmpnconf->nc_netid);  		/* loopnconf is never freed */ +		endnetconfig(nc_handle);  	}  	mutex_unlock(&loopnconf_lock);  	client = getclnthandle(hostname, loopnconf, NULL); diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 9b9f718dbe2f..a5e7e04597d0 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -37,6 +37,14 @@ SRCS+=	\  SRCS+= getdents.c lstat.c mknod.c stat.c +SRCS+= fstat.c fstatat.c fstatfs.c getfsstat.c statfs.c +NOASM+= fstat.o fstatat.o fstatfs.o getfsstat.o statfs.o +PSEUDO+= _fstat.o _fstatat.o _fstatfs.o _getfsstat.o _statfs.o + +SRCS+= getdirentries.c +NOASM+= getdirentries.o +PSEUDO+= _getdirentries.o +  SRCS+= pipe.c  INTERPOSED = \ @@ -421,8 +429,7 @@ MLINKS+=open.2 openat.2  MLINKS+=pathconf.2 fpathconf.2  MLINKS+=pathconf.2 lpathconf.2  MLINKS+=pdfork.2 pdgetpid.2\ -	pdfork.2 pdkill.2 \ -	pdfork.2 pdwait4.2 +	pdfork.2 pdkill.2  MLINKS+=pipe.2 pipe2.2  MLINKS+=poll.2 ppoll.2  MLINKS+=rctl_add_rule.2 rctl_get_limits.2 \ diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index feccda6f6bf4..4411cfe968cd 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -121,7 +121,6 @@ FBSD_1.0 {  	jail;  	jail_attach;  	kenv; -	kevent;  	kill;  	kldfind;  	kldfirstmod; @@ -393,6 +392,7 @@ FBSD_1.5 {  	getdents;  	getdirentries;  	getfsstat; +	kevent;  	lstat;  	mknod;  	mknodat; diff --git a/lib/libc/sys/compat-ino64.h b/lib/libc/sys/compat-ino64.h new file mode 100644 index 000000000000..dde741e4f089 --- /dev/null +++ b/lib/libc/sys/compat-ino64.h @@ -0,0 +1,102 @@ +/*- + * Copyright (c) 2017 M. Warner Losh <imp@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$ + */ + +/* + * Forward compatibility shim to convert old stat buffer to + * new so we can call the old system call, but return data in + * the new system call's format. + */ +#define _WANT_FREEBSD11_STATFS +#include <sys/fcntl.h> +#include <sys/mount.h> + +#define _WANT_FREEBSD11_STAT +#include <sys/stat.h> + +#include <string.h> + +#define INO64_FIRST 1200031 + +static __inline void +__stat11_to_stat(const struct freebsd11_stat *sb11, struct stat *sb) +{ + +	sb->st_dev = sb11->st_dev; +	sb->st_ino = sb11->st_ino; +	sb->st_nlink = sb11->st_nlink; +	sb->st_mode = sb11->st_mode; +	sb->st_uid = sb11->st_uid; +	sb->st_gid = sb11->st_gid; +	sb->st_rdev = sb11->st_rdev; +	sb->st_atim = sb11->st_atim; +	sb->st_mtim = sb11->st_mtim; +	sb->st_ctim = sb11->st_ctim; +#ifdef __STAT_TIME_T_EXT +	sb->st_atim_ext = 0; +	sb->st_mtim_ext = 0; +	sb->st_ctim_ext = 0; +	sb->st_btim_ext = 0; +#endif +	sb->st_birthtim = sb11->st_birthtim; +	sb->st_size = sb11->st_size; +	sb->st_blocks = sb11->st_blocks; +	sb->st_blksize = sb11->st_blksize; +	sb->st_flags = sb11->st_flags; +	sb->st_gen = sb11->st_gen; +	sb->st_padding0 = 0; +	sb->st_padding1 = 0; +	memset(sb->st_spare, 0, sizeof(sb->st_spare)); +} + +static __inline void +__statfs11_to_statfs(const struct freebsd11_statfs *sf11, struct statfs *sf) +{ + +	sf->f_version = STATFS_VERSION; +	sf->f_type = sf11->f_type; +	sf->f_flags = sf11->f_flags; +	sf->f_bsize = sf11->f_bsize; +	sf->f_iosize = sf11->f_iosize; +	sf->f_blocks = sf11->f_blocks; +	sf->f_bfree = sf11->f_bfree; +	sf->f_bavail = sf11->f_bavail; +	sf->f_files = sf11->f_files; +	sf->f_ffree = sf11->f_ffree; +	sf->f_syncwrites = sf11->f_syncwrites; +	sf->f_asyncwrites = sf11->f_asyncwrites; +	sf->f_syncreads = sf11->f_syncreads; +	sf->f_asyncreads = sf11->f_asyncreads; +	sf->f_namemax = sf11->f_namemax; +	sf->f_owner = sf11->f_owner; +	sf->f_fsid = sf11->f_fsid; +	memset(sf->f_spare, 0, sizeof(sf->f_spare)); +	memset(sf->f_charspare, 0, sizeof(sf->f_charspare)); +	strlcpy(sf->f_fstypename, sf11->f_fstypename, sizeof(sf->f_fstypename)); +	strlcpy(sf->f_mntfromname, sf11->f_mntfromname, sizeof(sf->f_mntfromname)); +	strlcpy(sf->f_mntonname, sf11->f_mntonname, sizeof(sf->f_mntonname)); +} diff --git a/lib/libc/sys/fstat.c b/lib/libc/sys/fstat.c new file mode 100644 index 000000000000..a57a8aad52a2 --- /dev/null +++ b/lib/libc/sys/fstat.c @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2017 M. Warner Losh <imp@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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include <sys/param.h> +#include <sys/syscall.h> +#include "compat-ino64.h" +#include <unistd.h> + +#include "libc_private.h" + +#undef fstat +__weak_reference(_fstat, fstat); + +#pragma weak _fstat +int +_fstat(int fd, struct stat *sb) +{ +	struct freebsd11_stat stat11; +	int rv; + +	if (__getosreldate() >= INO64_FIRST) +		return (__sys_fstat(fd, sb)); +	rv = syscall(SYS_freebsd11_fstat, fd, &stat11); +	if (rv == 0) +		__stat11_to_stat(&stat11, sb); +	return (rv); +} diff --git a/lib/libc/sys/fstatat.c b/lib/libc/sys/fstatat.c new file mode 100644 index 000000000000..5e6edccdb97d --- /dev/null +++ b/lib/libc/sys/fstatat.c @@ -0,0 +1,50 @@ +/*- + * Copyright (c) 2017 M. Warner Losh <imp@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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include <sys/param.h> +#include <sys/syscall.h> +#include "compat-ino64.h" +#include <unistd.h> + +#include "libc_private.h" + +int +fstatat(int fd, const char *path, struct stat *sb, int flag) +{ +	struct freebsd11_stat stat11; +	int rv; + +	if (__getosreldate() >= INO64_FIRST) +		return (__sys_fstatat(fd, path, sb, flag)); +	rv = syscall(SYS_freebsd11_fstatat, fd, path, &stat11, flag); +	if (rv == 0) +		__stat11_to_stat(&stat11, sb); +	return (rv); +} diff --git a/lib/libc/sys/fstatfs.c b/lib/libc/sys/fstatfs.c new file mode 100644 index 000000000000..71ee12dc0bfb --- /dev/null +++ b/lib/libc/sys/fstatfs.c @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2017 M. Warner Losh <imp@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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include <sys/param.h> +#include <sys/syscall.h> +#include "compat-ino64.h" +#include <unistd.h> + +#include "libc_private.h" + +#undef fstatfs +__weak_reference(_fstatfs, fstatfs); + +#pragma weak _fstatfs +int +_fstatfs(int fd, struct statfs *buf) +{ +	struct freebsd11_statfs statfs11; +	int rv; + +	if (__getosreldate() >= INO64_FIRST) +		return (__sys_fstatfs(fd, buf)); +	rv = syscall(SYS_freebsd11_fstatfs, fd, &statfs11); +	if (rv == 0) +		__statfs11_to_statfs(&statfs11, buf); +	return (rv); +} diff --git a/lib/libc/sys/getdents.c b/lib/libc/sys/getdents.c index c8a2878c972f..480fbf265fb9 100644 --- a/lib/libc/sys/getdents.c +++ b/lib/libc/sys/getdents.c @@ -36,6 +36,11 @@ __FBSDID("$FreeBSD$");  ssize_t  getdents(int fd, char *buf, size_t nbytes)  { +	/* +	 * _getdirentries knows how to call the right thing and +	 * return it in the new format. It assumes that the entire +	 * libc expecting the new format. +	 */ -	return (__sys_getdirentries(fd, buf, nbytes, NULL)); +	return (_getdirentries(fd, buf, nbytes, NULL));  } diff --git a/lib/libc/sys/getdirentries.c b/lib/libc/sys/getdirentries.c new file mode 100644 index 000000000000..469e6d26d790 --- /dev/null +++ b/lib/libc/sys/getdirentries.c @@ -0,0 +1,117 @@ +/*- + * Copyright (c) 2017 M. Warner Losh <imp@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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#define _WANT_FREEBSD11_DIRENT + +#include "namespace.h" +#include <sys/param.h> +#include <sys/syscall.h> +#include "compat-ino64.h" +#include <dirent.h> +#include <errno.h> +#include <stddef.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include "libc_private.h" + +static ssize_t +__cvt_dirents_from11(const char *de11, ssize_t len11, char *de, ssize_t len) +{ +	struct dirent *dst; +	const struct freebsd11_dirent *src; +	const char *edst, *esrc; +	ssize_t rlen; + +	src = (const struct freebsd11_dirent *)de11; +	dst = (struct dirent *)de; +	esrc = de11 + len11; +	edst = de + len; +	while ((const char *)src < esrc && (const char *)dst < edst) { +		rlen = roundup(offsetof(struct dirent, d_name) + src->d_namlen + 1, 8); +		if ((const char *)dst + rlen >= edst) +			break; +		dst->d_fileno = src->d_fileno; +		dst->d_off = 0;			/* nothing uses it yet, so safe for now */ +		dst->d_reclen = rlen; +		dst->d_type = src->d_type; +		dst->d_pad0 = 0; +		dst->d_namlen = src->d_namlen; +		dst->d_pad1 = 0; +		memset(dst->d_name, 0, roundup(src->d_namlen + 1, 8)); +		memcpy(dst->d_name, src->d_name, src->d_namlen); +		dst = (struct dirent *)((char *)dst + rlen); +		src = (const struct freebsd11_dirent *)((const char *)src + src->d_reclen); +	} +	return ((char *)dst - de); +} + +#undef getdirentries +__weak_reference(_getdirentries, getdirentries); + +#pragma weak _getdirentries +ssize_t +_getdirentries(int fd, char *buf, size_t nbytes, off_t *basep) +{ +	char *oldbuf; +	size_t len; +	ssize_t rv; + +	if (__getosreldate() >= INO64_FIRST) +		return (__sys_getdirentries(fd, buf, nbytes, basep)); + +	/* +	 * Because the old system call returns entries that are smaller than the +	 * new, we could wind up in a situation where we have too many to fit in +	 * the buffer with the new encoding. So sacrifice a small bit of +	 * efficiency to ensure that never happens. We pick 1/4 the size round +	 * up to the next DIRBLKSIZ. This will guarnatee enough room exists in +	 * the dst buffer due to changes in efficiency in packing dirent +	 * entries. We don't check against minimum block size to avoid a lot of +	 * stat calls, we'll see if that's wise or not. +	 * TBD: Will this difference matter to lseek? +	 */ +	len = roundup(nbytes / 4, DIRBLKSIZ); +	oldbuf = malloc(len); +	if (oldbuf == NULL) { +		errno = EINVAL;		/* ENOMEM not in possible list */ +		return (-1); +	} +	rv = syscall(SYS_freebsd11_getdirentries, fd, oldbuf, len, basep); +	if (rv == -1) { +		free(oldbuf); +		return (rv); +	} +	if (rv > 0) +		rv = __cvt_dirents_from11(oldbuf, rv, buf, nbytes); +	free(oldbuf); + +	return (rv); +} diff --git a/lib/libc/sys/getfsstat.c b/lib/libc/sys/getfsstat.c new file mode 100644 index 000000000000..ca81f3e9fd52 --- /dev/null +++ b/lib/libc/sys/getfsstat.c @@ -0,0 +1,65 @@ +/*- + * Copyright (c) 2017 M. Warner Losh <imp@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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include <sys/param.h> +#include "compat-ino64.h" +#include <sys/errno.h> +#include <sys/syscall.h> +#include <stdlib.h> +#include <unistd.h> + +#include "libc_private.h" + +int +getfsstat(struct statfs *buf, long bufsize, int flags) +{ +	struct freebsd11_statfs *statfs11 = NULL; +	ssize_t len = 0; +	int rv, i; + +	if (__getosreldate() >= INO64_FIRST) +		return (__sys_getfsstat(buf, bufsize, flags)); +	if (buf != NULL) { +		len = sizeof(struct freebsd11_statfs) *	/* Round down on purpose to avoid */ +		    (bufsize / sizeof(struct statfs));	/* overflow on translation.	  */ +		statfs11 = malloc(len); +		if (statfs11 == NULL) { +			errno = ENOMEM; +			return (-1); +		} +	} +	rv = syscall(SYS_freebsd11_getfsstat, statfs11, len, flags); +	if (rv != -1 && buf != NULL) { +		for (i = 0; i < rv; i++) +			__statfs11_to_statfs(&statfs11[i], &buf[i]); +	} +	free(statfs11); +	return (rv); +} diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2 index e7bca7231690..6630ae3db688 100644 --- a/lib/libc/sys/kqueue.2 +++ b/lib/libc/sys/kqueue.2 @@ -24,7 +24,7 @@  .\"  .\" $FreeBSD$  .\" -.Dd April 18, 2017 +.Dd June 22, 2017  .Dt KQUEUE 2  .Os  .Sh NAME @@ -148,12 +148,13 @@ The  structure is defined as:  .Bd -literal  struct kevent { -	uintptr_t ident;	/* identifier for this event */ +	uintptr_t  ident;	/* identifier for this event */  	short	  filter;	/* filter for event */  	u_short	  flags;	/* action flags for kqueue */  	u_int	  fflags;	/* filter flag value */ -	intptr_t  data;		/* filter data value */ +	int64_t   data;		/* filter data value */  	void	  *udata;	/* opaque user data identifier */ +	uint64_t  ext[4];	/* extentions */  };  .Ed  .Pp @@ -177,6 +178,20 @@ Filter-specific flags.  Filter-specific data value.  .It Fa udata  Opaque user-defined value passed through the kernel unchanged. +.It Fa ext +Extended data passed to and from kernel. +The +.Fa ext[0] +and +.Fa ext[1] +members use is defined by the filter. +If the filter does not use them, the members are copied unchanged. +The +.Fa ext[2] +and +.Fa ext[3] +members are always passed throught the kernel as-is, +making additional context available to application.  .El  .Pp  The @@ -336,33 +351,18 @@ case.  Takes a descriptor as the identifier, and returns whenever  there is no remaining data in the write buffer.  .It Dv EVFILT_AIO -The sigevent portion of the AIO request is filled in, with -.Va sigev_notify_kqueue -containing the descriptor of the kqueue that the event should -be attached to, -.Va sigev_notify_kevent_flags -containing the kevent flags which should be -.Dv EV_ONESHOT , -.Dv EV_CLEAR -or -.Dv EV_DISPATCH , -.Va sigev_value -containing the udata value, and -.Va sigev_notify -set to -.Dv SIGEV_KEVENT . -When the -.Fn aio_* -system call is made, the event will be registered -with the specified kqueue, and the -.Va ident -argument set to the -.Fa struct aiocb -returned by the -.Fn aio_* -system call. +Events for this filter are not registered with +.Fn kevent +directly but are registered via the +.Va aio_sigevent +member of an asychronous I/O request when it is scheduled via an asychronous I/O +system call such as +.Fn aio_read .  The filter returns under the same conditions as  .Fn aio_error . +For more details on this filter see +.Xr sigevent 3 and +.Xr aio 4 .  .It Dv EVFILT_VNODE  Takes a file descriptor as the identifier and the events to watch for in  .Va fflags , @@ -515,16 +515,26 @@ Establishes an arbitrary timer identified by  .Va ident .  When adding a timer,  .Va data -specifies the timeout period. +specifies the moment to fire the timer (for +.Dv NOTE_ABSTIME ) +or the timeout period.  The timer will be periodic unless  .Dv EV_ONESHOT +or +.Dv NOTE_ABSTIME  is specified.  On return,  .Va data  contains the number of times the timeout has expired since the last call to  .Fn kevent . -This filter automatically sets the EV_CLEAR flag internally. -.Bl -tag -width "Dv NOTE_USECONDS" +For non-monotonic timers, this filter automatically sets the +.Dv EV_CLEAR +flag internally. +.Pp +The filter accepts the following flags in the +.Va fflags +argument: +.Bl -tag -width "Dv NOTE_MSECONDS"  .It Dv NOTE_SECONDS  .Va data  is in seconds. @@ -537,6 +547,8 @@ is in microseconds.  .It Dv NOTE_NSECONDS  .Va data  is in nanoseconds. +.It Dv NOTE_ABSTIME +The specified expiration time is absolute.  .El  .Pp  If diff --git a/lib/libc/sys/lstat.c b/lib/libc/sys/lstat.c index ccc73e3d3d06..d639a42d3dd0 100644 --- a/lib/libc/sys/lstat.c +++ b/lib/libc/sys/lstat.c @@ -1,4 +1,5 @@  /*- + * Copyright (c) 2017 M. Warner Losh <imp@FreeBSD.org>   * Copyright (c) 2012 Gleb Kurtsou <gleb@FreeBSD.org>   * All rights reserved.   * @@ -29,15 +30,22 @@ __FBSDID("$FreeBSD$");  #include "namespace.h"  #include <sys/param.h> -#include <sys/fcntl.h>  #include <sys/syscall.h> -#include <sys/stat.h> +#include "compat-ino64.h"  #include <unistd.h> +  #include "libc_private.h"  int  lstat(const char *path, struct stat *sb)  { +	struct freebsd11_stat stat11; +	int rv; -	return (__sys_fstatat(AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW)); +	if (__getosreldate() >= INO64_FIRST) +		return (__sys_fstatat(AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW)); +	rv = syscall(SYS_freebsd11_lstat, path, &stat11); +	if (rv == 0) +		__stat11_to_stat(&stat11, sb); +	return (rv);  } diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2 index e36f804c587b..b7704a2351c0 100644 --- a/lib/libc/sys/mmap.2 +++ b/lib/libc/sys/mmap.2 @@ -28,7 +28,7 @@  .\"	@(#)mmap.2	8.4 (Berkeley) 5/11/95  .\" $FreeBSD$  .\" -.Dd February 4, 2017 +.Dd June 22, 2017  .Dt MMAP 2  .Os  .Sh NAME @@ -69,7 +69,7 @@ current) offsets in the object.  In particular, the  .Fa offset  value cannot be negative. -If the object is truncated and the process later accesses a pages that +If the object is truncated and the process later accesses a page that  is wholly within the truncated region, the access is aborted and a  .Dv SIGBUS  signal is delivered to the process. @@ -199,9 +199,21 @@ In contrast, if  .Dv MAP_EXCL  is specified, the request will fail if a mapping  already exists within the range. -.It Dv MAP_HASSEMAPHORE -Notify the kernel that the region may contain semaphores and that special -handling may be necessary. +.It Dv MAP_GUARD +Instead of a mapping, create a guard of the specified size. +Guards allow a process to create reservations in its address space, +which can later be replaced by actual mappings. +.Pp +.Fa mmap +will not create mappings in the address range of a guard unless +the request specifies +.Dv MAP_FIXED . +Guards can be destroyed with +.Xr munmap 2 . +Any memory access by a thread to the guarded range results +in the delivery of a +.Dv SIGSEGV +signal to that thread.  .It Dv MAP_NOCORE  Region is not included in a core file.  .It Dv MAP_NOSYNC @@ -306,6 +318,7 @@ must include at least  .Dv PROT_READ  and  .Dv PROT_WRITE . +.Pp  This option creates  a memory region that grows to at most  .Fa len @@ -316,6 +329,10 @@ stack top is the starting address returned by the call, plus  bytes.  The bottom of the stack at maximum growth is the starting  address returned by the call. +The system uses guards to prevent the inadvertent use of +regions into which stacks created with +.Dv MAP_STACK +will automatically grow, without mapping the whole stack in advance.  .El  .Pp  The @@ -409,6 +426,7 @@ were specified.  .It Bq Er EINVAL  None of  .Dv MAP_ANON , +.Dv MAP_GUARD ,  .Dv MAP_PRIVATE ,  .Dv MAP_SHARED ,  or @@ -458,6 +476,25 @@ were specified, but the requested region is already used by a mapping.  was specified, but  .Dv MAP_FIXED  was not. +.It Bq Er EINVAL +.Dv MAP_GUARD +was specified, but the +.Fa offset +argument was not zero, the +.Fa fd +argument was not -1, or the +.Fa prot +argument was not +.Dv PROT_NONE . +.It Bq Er EINVAL +.Dv MAP_GUARD +was specified together with one of the flags +.Dv MAP_ANON , +.Dv MAP_PREFAULT , +.Dv MAP_PREFAULT_READ , +.Dv MAP_PRIVATE , +.Dv MAP_SHARED , +.Dv MAP_STACK .  .It Bq Er ENODEV  .Dv MAP_ANON  has not been specified and diff --git a/lib/libc/sys/munmap.2 b/lib/libc/sys/munmap.2 index 8fa539550fbe..d050db0f3fac 100644 --- a/lib/libc/sys/munmap.2 +++ b/lib/libc/sys/munmap.2 @@ -28,7 +28,7 @@  .\"	@(#)munmap.2	8.3 (Berkeley) 5/27/94  .\" $FreeBSD$  .\" -.Dd May 27, 1994 +.Dd June 22, 2017  .Dt MUNMAP 2  .Os  .Sh NAME @@ -44,7 +44,7 @@  The  .Fn munmap  system call -deletes the mappings for the specified address range, +deletes the mappings and guards for the specified address range,  and causes further references to addresses within the range  to generate invalid memory references.  .Sh RETURN VALUES diff --git a/lib/libc/sys/pdfork.2 b/lib/libc/sys/pdfork.2 index 5f1a86e3b961..ab1a73dc9ce1 100644 --- a/lib/libc/sys/pdfork.2 +++ b/lib/libc/sys/pdfork.2 @@ -32,14 +32,13 @@  .\"  .\" $FreeBSD$  .\" -.Dd June 8, 2016 +.Dd June 17, 2017  .Dt PDFORK 2  .Os  .Sh NAME  .Nm pdfork ,  .Nm pdgetpid , -.Nm pdkill , -.Nm pdwait4 +.Nm pdkill  .Nd System calls to manage process descriptors  .Sh LIBRARY  .Lb libc @@ -51,8 +50,6 @@  .Fn pdgetpid "int fd" "pid_t *pidp"  .Ft int  .Fn pdkill "int fd" "int signum" -.Ft int -.Fn pdwait4 "int fd" "int *status" "int options" "struct rusage *rusage"  .Sh DESCRIPTION  Process descriptors are special file descriptors that represent processes,  and are created using @@ -96,11 +93,6 @@ except that it accepts a process descriptor,  .Fa fd ,  rather than a PID.  .Pp -.Fn pdwait4 -behaves identically to -.Xr wait4 2 , -but operates with respect to a process descriptor argument rather than a PID. -.Pp  The following system calls also have effects specific to process descriptors:  .Pp  .Xr fstat 2 @@ -146,9 +138,6 @@ does.  and  .Fn pdkill  return 0 on success and -1 on failure. -.Pp -.Fn pdwait4 -returns a PID on success and -1 on failure.  .Sh ERRORS  These functions may return the same error numbers as their PID-based equivalents  (e.g. @@ -180,9 +169,8 @@ for  The  .Fn pdfork ,  .Fn pdgetpid , -.Fn pdkill  and -.Fn pdwait4 +.Fn pdkill  system calls first appeared in  .Fx 9.0 .  .Pp @@ -197,6 +185,3 @@ and  .An Jonathan Anderson Aq Mt jonathan@FreeBSD.org  at the University of Cambridge Computer Laboratory with support from a grant  from Google, Inc. -.Sh BUGS -.Fn pdwait4 -has not yet been implemented. diff --git a/lib/libc/sys/stat.2 b/lib/libc/sys/stat.2 index e706a408275d..8256ebc23cd0 100644 --- a/lib/libc/sys/stat.2 +++ b/lib/libc/sys/stat.2 @@ -28,7 +28,7 @@  .\"     @(#)stat.2	8.4 (Berkeley) 5/1/95  .\" $FreeBSD$  .\" -.Dd January 14, 2016 +.Dd June 23, 2017  .Dt STAT 2  .Os  .Sh NAME @@ -62,7 +62,7 @@ The  .Fn lstat  system call is like  .Fn stat -except in the case where the named file is a symbolic link, +except when the named file is a symbolic link,  in which case  .Fn lstat  returns information about the link, @@ -82,7 +82,7 @@ system call is equivalent to  .Fn stat  and  .Fn lstat -except in the case where the +except when the  .Fa path  specifies a relative path.  In this case the status is retrieved from a file relative to @@ -92,7 +92,7 @@ instead of the current working directory.  .Pp  The values for the  .Fa flag -are constructed by a bitwise-inclusive OR of flags from the following list, +are constructed by a bitwise-inclusive OR of flags from this list,  defined in  .In fcntl.h :  .Bl -tag -width indent @@ -129,16 +129,16 @@ and into which information is placed concerning the file.  .Pp  The fields of  .Vt "struct stat" -related to the file system are as follows: +related to the file system are:  .Bl -tag -width ".Va st_nlink"  .It Va st_dev -The numeric ID of the device containing the file. +Numeric ID of the device containing the file.  .It Va st_ino  The file's inode number.  .It Va st_nlink -The number of hard links to the file. +Number of hard links to the file.  .It Va st_flags -The flags enabled for the file. +Flags enabled for the file.  See  .Xr chflags 2  for the list of flags and their description. @@ -152,10 +152,10 @@ fields together identify the file uniquely within the system.  .Pp  The time-related fields of  .Vt "struct stat" -are as follows: +are:  .Bl -tag -width ".Va st_birthtim"  .It Va st_atim -Time when file data last accessed. +Time when file data was last accessed.  Changed by the  .Xr mknod 2 ,  .Xr utimes 2 , @@ -164,7 +164,7 @@ and  .Xr readv 2  system calls.  .It Va st_mtim -Time when file data last modified. +Time when file data was last modified.  Changed by the  .Xr mkdir 2 ,  .Xr mkfifo 2 , @@ -199,7 +199,7 @@ system calls.  Time when the inode was created.  .El  .Pp -The following time-related macros are defined for compatibility: +These time-related macros are defined for compatibility:  .Bd -literal  #define	st_atime		st_atim.tv_sec  #define	st_mtime		st_mtim.tv_sec @@ -216,35 +216,35 @@ The following time-related macros are defined for compatibility:  #endif  .Ed  .Pp -The size-related fields of the +Size-related fields of the  .Vt "struct stat" -are as follows: +are:  .Bl -tag -width ".Va st_blksize"  .It Va st_size -The file size in bytes. +File size in bytes.  .It Va st_blksize -The optimal I/O block size for the file. +Optimal I/O block size for the file.  .It Va st_blocks -The actual number of blocks allocated for the file in 512-byte units. +Actual number of blocks allocated for the file in 512-byte units.  As short symbolic links are stored in the inode, this number may  be zero.  .El  .Pp  The access-related fields of  .Vt "struct stat" -are as follows: +are:  .Bl -tag -width ".Va st_mode"  .It Va st_uid -The user ID of the file's owner. +User ID of the file's owner.  .It Va st_gid -The group ID of the file. +Group ID of the file.  .It Va st_mode  Status of the file (see below).  .El  .Pp  The status information word  .Fa st_mode -has the following bits: +has these bits:  .Bd -literal  #define S_IFMT   0170000  /* type of file mask */  #define S_IFIFO  0010000  /* named pipe (fifo) */ @@ -277,7 +277,7 @@ For a list of access modes, see  .Xr access 2  and  .Xr chmod 2 . -The following macros are available to test whether a +These macros are available to test whether a  .Va st_mode  value passed in the  .Fa m diff --git a/lib/libc/sys/stat.c b/lib/libc/sys/stat.c index 6b58daa9e515..a7ed7baf5c2f 100644 --- a/lib/libc/sys/stat.c +++ b/lib/libc/sys/stat.c @@ -1,4 +1,5 @@  /*- + * Copyright (c) 2017 M. Warner Losh <imp@FreeBSD.org>   * Copyright (c) 2012 Gleb Kurtsou <gleb@FreeBSD.org>   * All rights reserved.   * @@ -29,15 +30,22 @@ __FBSDID("$FreeBSD$");  #include "namespace.h"  #include <sys/param.h> -#include <sys/fcntl.h>  #include <sys/syscall.h> -#include <sys/stat.h> +#include "compat-ino64.h"  #include <unistd.h> +  #include "libc_private.h"  int  stat(const char *path, struct stat *sb)  { +	struct freebsd11_stat stat11; +	int rv; -	return (__sys_fstatat(AT_FDCWD, path, sb, 0)); +	if (__getosreldate() >= INO64_FIRST) +		return (__sys_fstatat(AT_FDCWD, path, sb, 0)); +	rv = syscall(SYS_freebsd11_stat, path, &stat11); +	if (rv == 0) +		__stat11_to_stat(&stat11, sb); +	return (rv);  } diff --git a/lib/libc/sys/statfs.c b/lib/libc/sys/statfs.c new file mode 100644 index 000000000000..63774e999d92 --- /dev/null +++ b/lib/libc/sys/statfs.c @@ -0,0 +1,50 @@ +/*- + * Copyright (c) 2017 M. Warner Losh <imp@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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include <sys/param.h> +#include <sys/syscall.h> +#include "compat-ino64.h" +#include <unistd.h> + +#include "libc_private.h" + +int +statfs(const char *path, struct statfs *buf) +{ +	struct freebsd11_statfs statfs11; +	int rv; + +	if (__getosreldate() >= INO64_FIRST) +		return (__sys_statfs(path, buf)); +	rv = syscall(SYS_freebsd11_statfs, path, &statfs11); +	if (rv == 0) +		__statfs11_to_statfs(&statfs11, buf); +	return (rv); +} diff --git a/lib/libc/sys/wait.2 b/lib/libc/sys/wait.2 index c34743290451..49cbc269d326 100644 --- a/lib/libc/sys/wait.2 +++ b/lib/libc/sys/wait.2 @@ -28,7 +28,7 @@  .\"     @(#)wait.2	8.2 (Berkeley) 4/19/94  .\" $FreeBSD$  .\" -.Dd June 1, 2016 +.Dd June 17, 2017  .Dt WAIT 2  .Os  .Sh NAME @@ -601,9 +601,7 @@ must be checked against zero to determine if a process reported status.  called with -1 to wait for any child process will ignore a child that is  referenced by a process descriptor (see  .Xr pdfork 2 ) . -Specific processes can still be waited on by specifying the process ID -or descriptor (see -.Xr pdwait 4 ) . +Specific processes can still be waited on by specifying the process ID.  .Sh ERRORS  The  .Fn wait | 
