diff options
Diffstat (limited to 'lib')
47 files changed, 565 insertions, 914 deletions
diff --git a/lib/Makefile b/lib/Makefile index b8b3a52..d17cb5d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -215,8 +215,9 @@ _libldns= libldns # sense to build when clang is enabled at all. Furthermore, they can only be # built for certain architectures. .if ${MK_CLANG} != "no" && ${COMPILER_TYPE} == "clang" && \ - (${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" || \ - (${MACHINE_CPUARCH} == "arm" && ${MACHINE_ARCH} != "armeb")) + (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ + (${MACHINE_CPUARCH} == "arm" && ${MACHINE_ARCH} != "armeb") || \ + (${MACHINE_CPUARCH} == "i386")) _libclang_rt= libclang_rt .endif @@ -273,7 +274,7 @@ _libsmb= libsmb _libsmb= libsmb .endif -.if ${MACHINE_CPUARCH} == "arm" +.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" _libsmb= libsmb _libproc= libproc _librtld_db= librtld_db diff --git a/lib/csu/aarch64/crt1.c b/lib/csu/aarch64/crt1.c index de4455e..be59317 100644 --- a/lib/csu/aarch64/crt1.c +++ b/lib/csu/aarch64/crt1.c @@ -51,6 +51,8 @@ extern int eprol; extern int etext; #endif +extern long * _end; + void __start(int, char **, char **, void (*)(void)); /* The entry function. */ @@ -79,8 +81,17 @@ __start(int argc, char *argv[], char *env[], void (*cleanup)(void)) if (&_DYNAMIC != NULL) atexit(cleanup); - else + else { + /* + * Hack to resolve _end so we read the correct symbol. + * Without this it will resolve to the copy in the library + * that firsts requests it. We should fix the toolchain, + * however this is is needed until this can take place. + */ + *(volatile long *)&_end; + _init_tls(); + } #ifdef GCRT atexit(_mcleanup); diff --git a/lib/libc/aarch64/Symbol.map b/lib/libc/aarch64/Symbol.map index a0b33da..3d8ad25 100644 --- a/lib/libc/aarch64/Symbol.map +++ b/lib/libc/aarch64/Symbol.map @@ -14,6 +14,9 @@ FBSD_1.0 { _setjmp; _longjmp; fabs; + __flt_rounds; + fpgetmask; + fpsetmask; setjmp; longjmp; sigsetjmp; @@ -25,6 +28,7 @@ FBSD_1.0 { FBSDprivate_1.0 { _set_tp; + _end; curbrk; minbrk; }; diff --git a/lib/libc/aarch64/gen/Makefile.inc b/lib/libc/aarch64/gen/Makefile.inc index c4f7c80..bb70a36 100644 --- a/lib/libc/aarch64/gen/Makefile.inc +++ b/lib/libc/aarch64/gen/Makefile.inc @@ -2,6 +2,8 @@ SRCS+= fabs.S \ flt_rounds.c \ + fpgetmask.c \ + fpsetmask.c \ ldexp.c \ _setjmp.S \ _set_tp.c \ diff --git a/lib/libc/aarch64/gen/_setjmp.S b/lib/libc/aarch64/gen/_setjmp.S index 504423b..ae00195 100644 --- a/lib/libc/aarch64/gen/_setjmp.S +++ b/lib/libc/aarch64/gen/_setjmp.S @@ -59,8 +59,8 @@ ENTRY(_setjmp) /* Return value */ mov x0, #0 ret -.Lmagic: .align 3 +.Lmagic: .quad _JB_MAGIC__SETJMP END(_setjmp) diff --git a/lib/libc/aarch64/gen/fpgetmask.c b/lib/libc/aarch64/gen/fpgetmask.c new file mode 100644 index 0000000..afc05b4 --- /dev/null +++ b/lib/libc/aarch64/gen/fpgetmask.c @@ -0,0 +1,47 @@ +/*- + * Copyright (c) 2015 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <ieeefp.h> + +#define FP_X_MASK (FP_X_INV | FP_X_DZ | FP_X_OFL | FP_X_UFL | FP_X_IMP) + +fp_except_t +fpgetmask(void) +{ + uint64_t mask; + + /* Read the current mask */ + __asm __volatile("mrs %0, fpcr" : "=&r"(mask)); + + return (mask & FP_X_MASK); +} diff --git a/lib/libc/aarch64/gen/fpsetmask.c b/lib/libc/aarch64/gen/fpsetmask.c new file mode 100644 index 0000000..de9ac04 --- /dev/null +++ b/lib/libc/aarch64/gen/fpsetmask.c @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2015 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <ieeefp.h> + +#define FP_X_MASK (FP_X_INV | FP_X_DZ | FP_X_OFL | FP_X_UFL | FP_X_IMP) + +fp_except_t +fpsetmask(fp_except_t mask) +{ + uint64_t old, new; + + mask &= FP_X_MASK; + + /* Read the current mask */ + __asm __volatile("mrs %0, fpcr" : "=&r"(old)); + new = old & ~FP_X_MASK; + new |= mask; + __asm __volatile("msr fpcr, %0" :: "r"(new)); + + return ((fp_except_t)old); +} diff --git a/lib/libc/aarch64/gen/setjmp.S b/lib/libc/aarch64/gen/setjmp.S index 790ed73..a30ed6a 100644 --- a/lib/libc/aarch64/gen/setjmp.S +++ b/lib/libc/aarch64/gen/setjmp.S @@ -69,8 +69,8 @@ ENTRY(setjmp) /* Return value */ mov x0, #0 ret -.Lmagic: .align 3 +.Lmagic: .quad _JB_MAGIC_SETJMP END(setjmp) diff --git a/lib/libc/aarch64/gen/sigsetjmp.S b/lib/libc/aarch64/gen/sigsetjmp.S index 8a13c9f..be49f53 100644 --- a/lib/libc/aarch64/gen/sigsetjmp.S +++ b/lib/libc/aarch64/gen/sigsetjmp.S @@ -47,7 +47,7 @@ ENTRY(siglongjmp) cmp x2, x3 b.eq _C_LABEL(_longjmp) b _C_LABEL(longjmp) -.Lmagic: .align 3 +.Lmagic: .quad _JB_MAGIC__SETJMP END(siglongjmp) diff --git a/lib/libc/aarch64/sys/brk.S b/lib/libc/aarch64/sys/brk.S index 09167b6..1e9a215 100644 --- a/lib/libc/aarch64/sys/brk.S +++ b/lib/libc/aarch64/sys/brk.S @@ -32,6 +32,8 @@ __FBSDID("$FreeBSD$"); #include "SYS.h" + .globl _C_LABEL(_end) + .data .align 3 .globl _C_LABEL(minbrk) @@ -47,15 +49,8 @@ ENTRY(_brk) WEAK_REFERENCE(_brk, brk) /* Load the address of minbrk */ -#ifdef __PIC__ - adrp x2, :got:minbrk - ldr x3, [x2, #:got_lo12:minbrk] -#else - ldr x3, .Lminbrk -#endif - - /* Get the minimum allowable brk address */ - ldr x2, [x3] + adrp x3, minbrk + ldr x2, [x3, :lo12:minbrk] /* Validate the address */ cmp x0, x2 @@ -70,24 +65,12 @@ ENTRY(_brk) _SYSCALL(break) b.cs cerror -#ifdef __PIC__ - adrp x2, :got:curbrk - ldr x3, [x2, #:got_lo12:curbrk] -#else - ldr x3, .Lcurbrk -#endif - /* Store the new curbrk value */ - str x4, [x3] + adrp x2, curbrk + str x4, [x2, :lo12:curbrk] /* Return success */ mov x0, #0 ret -#ifndef __PIC__ -.Lcurbrk: - .quad _C_LABEL(curbrk) -.Lminbrk: - .quad _C_LABEL(minbrk) -#endif END(_brk) diff --git a/lib/libc/aarch64/sys/sbrk.S b/lib/libc/aarch64/sys/sbrk.S index db9d7e1..4880cc2 100644 --- a/lib/libc/aarch64/sys/sbrk.S +++ b/lib/libc/aarch64/sys/sbrk.S @@ -32,6 +32,8 @@ __FBSDID("$FreeBSD$"); #include "SYS.h" + .globl _C_LABEL(_end) + .data .align 3 .global _C_LABEL(curbrk) @@ -47,15 +49,10 @@ ENTRY(_sbrk) WEAK_REFERENCE(_sbrk, sbrk) /* Load the address of curbrk */ -#ifdef __PIC__ - adrp x2, :got:curbrk - ldr x3, [x2, #:got_lo12:curbrk] -#else - ldr x3, .Lcurbrk -#endif + adrp x3, curbrk /* Get the current brk address */ - ldr x2, [x3] + ldr x2, [x3, :lo12:curbrk] /* Calculate the new value */ add x0, x2, x0 @@ -66,14 +63,10 @@ ENTRY(_sbrk) b.cs cerror /* Load the old value to return */ - ldr x0, [x3] + ldr x0, [x3, :lo12:curbrk] /* Store the new curbrk value */ - str x4, [x3] + str x4, [x3, :lo12:curbrk] ret -#ifndef __PIC__ -.Lcurbrk: - .quad _C_LABEL(curbrk) -#endif END(_sbrk) diff --git a/lib/libc/stdio/Symbol.map b/lib/libc/stdio/Symbol.map index d2a8c92..a332ab2 100644 --- a/lib/libc/stdio/Symbol.map +++ b/lib/libc/stdio/Symbol.map @@ -162,6 +162,10 @@ FBSD_1.3 { mkostemps; }; +FBSD_1.4 { + fdclose; +}; + FBSDprivate_1.0 { _flockfile; _flockfile_debug_stub; diff --git a/lib/libc/stdio/fclose.3 b/lib/libc/stdio/fclose.3 index 883aa10..596ee3d 100644 --- a/lib/libc/stdio/fclose.3 +++ b/lib/libc/stdio/fclose.3 @@ -1,5 +1,6 @@ -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. +.\" Copyright (c) 1990, 1991, 1993 The Regents of the University of California. +.\" Copyright (c) 2015 Mariusz Zaborski <oshogbo@FreeBSD.org> +.\" All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, @@ -32,11 +33,12 @@ .\" @(#)fclose.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd April 22, 2006 +.Dd July 4, 2015 .Dt FCLOSE 3 .Os .Sh NAME .Nm fclose , +.Nm fdclose , .Nm fcloseall .Nd close a stream .Sh LIBRARY @@ -45,6 +47,8 @@ .In stdio.h .Ft int .Fn fclose "FILE *stream" +.Ft int +.Fn fdclose "FILE *stream" "int *fdp" .Ft void .Fn fcloseall void .Sh DESCRIPTION @@ -59,36 +63,77 @@ first, using .Xr fflush 3 . .Pp The +.Fn fdclose +function is equivalent to +.Fn fclose +except that it does not close the underlying file descriptor. +If +.Fa fdp +is not +.Dv NULL , +the file descriptor will be written to it. +If the +.Fa fdp +argument will be different then NULL the file descriptor will be returned in it, +If the stream does not have an associated file descriptor, +.Fa fdp +will be set to -1. +This type of stream is created with functions such as +.Xr fmemopen 3 , +.Xr funopen 3 , +or +.Xr open_memstream 3 . +.Pp +The .Fn fcloseall function calls .Fn fclose on all open streams. .Sh RETURN VALUES -Upon successful completion 0 is returned. +.Fn fcloseall +does not return a value. +.Pp +Upon successful completion the +.Fn fclose +and +.Fn fdclose +functions return 0. Otherwise, .Dv EOF is returned and the global variable .Va errno is set to indicate the error. -In either case no further access to the stream is possible. .Sh ERRORS +.Fn fdclose +fails if: +.Bl -tag -width Er +.It Bq Er EOPNOTSUPP +The stream does not have an associated file descriptor. +.El +.Pp The .Fn fclose -function -may also fail and set +and +.Fn fdclose +functions may also fail and set .Va errno -for any of the errors specified for the routines -.Xr close 2 -or +for any of the errors specified for .Xr fflush 3 . +.Pp +The +.Fn fclose +function may also fail and set errno for any of the errors specified for +.Xr close 2 . .Sh NOTES The .Fn fclose -function -does not handle NULL arguments; they will result in a segmentation -violation. -This is intentional - it makes it easier to make sure programs written -under +and +.Fn fdclose +functions do not handle NULL arguments in the +.Fa stream +variable; this will result in a segmentation violation. +This is intentional. +It makes it easier to make sure programs written under .Fx are bug free. This behaviour is an implementation detail, and programs should not @@ -104,8 +149,13 @@ The function conforms to .St -isoC . -.Pp +.Sh HISTORY The .Fn fcloseall function first appeared in .Fx 7.0 . +.Pp +The +.Fn fdclose +function first appeared in +.Fx 11.0 . diff --git a/lib/libc/stdio/fclose.c b/lib/libc/stdio/fclose.c index 5ed8b2c..24b9b90 100644 --- a/lib/libc/stdio/fclose.c +++ b/lib/libc/stdio/fclose.c @@ -1,6 +1,7 @@ /*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. + * Copyright (c) 1990, 1993 The Regents of the University of California. + * Copyright (c) 2013 Mariusz Zaborski <oshogbo@FreeBSD.org> + * All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. @@ -38,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <errno.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include "un-namespace.h" @@ -45,19 +47,17 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" #include "local.h" -int -fclose(FILE *fp) +static int +cleanfile(FILE *fp, bool c) { int r; - if (fp->_flags == 0) { /* not open! */ - errno = EBADF; - return (EOF); - } - FLOCKFILE(fp); r = fp->_flags & __SWR ? __sflush(fp) : 0; - if (fp->_close != NULL && (*fp->_close)(fp->_cookie) < 0) - r = EOF; + if (c) { + if (fp->_close != NULL && (*fp->_close)(fp->_cookie) < 0) + r = EOF; + } + if (fp->_flags & __SMBF) free((char *)fp->_bf._base); if (HASUB(fp)) @@ -80,6 +80,59 @@ fclose(FILE *fp) STDIO_THREAD_LOCK(); fp->_flags = 0; /* Release this FILE for reuse. */ STDIO_THREAD_UNLOCK(); + + return (r); +} + +int +fdclose(FILE *fp, int *fdp) +{ + int r, err; + + if (fdp != NULL) + *fdp = -1; + + if (fp->_flags == 0) { /* not open! */ + errno = EBADF; + return (EOF); + } + + FLOCKFILE(fp); + r = 0; + if (fp->_close != __sclose) { + r = EOF; + errno = EOPNOTSUPP; + } else if (fp->_file < 0) { + r = EOF; + errno = EBADF; + } + if (r == EOF) { + err = errno; + (void)cleanfile(fp, true); + errno = err; + } else { + if (fdp != NULL) + *fdp = fp->_file; + r = cleanfile(fp, false); + } FUNLOCKFILE(fp); + + return (r); +} + +int +fclose(FILE *fp) +{ + int r; + + if (fp->_flags == 0) { /* not open! */ + errno = EBADF; + return (EOF); + } + + FLOCKFILE(fp); + r = cleanfile(fp, true); + FUNLOCKFILE(fp); + return (r); } diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2 index 458ad8d..71b432f 100644 --- a/lib/libc/sys/ptrace.2 +++ b/lib/libc/sys/ptrace.2 @@ -2,7 +2,7 @@ .\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $ .\" .\" This file is in the public domain. -.Dd July 22, 2013 +.Dd July 3, 2015 .Dt PTRACE 2 .Os .Sh NAME @@ -503,8 +503,163 @@ The .Fa data argument is ignored. .El +.Sh x86 MACHINE-SPECIFIC REQUESTS +.Bl -tag -width "Dv PT_GETXSTATE_INFO" +.It Dv PT_GETXMMREGS +Copy the XMM FPU state into the buffer pointed to by the +argument +.Fa addr . +The buffer has the same layout as the 32-bit save buffer for the +machine instruction +.Dv FXSAVE . +.Pp +This request is only valid for i386 programs, both on native 32-bit +systems and on amd64 kernels. +For 64-bit amd64 programs, the XMM state is reported as part of +the FPU state returned by the +.Dv PT_GETFPREGS +request. +.Pp +The +.Fa data +argument is ignored. +.It Dv PT_SETXMMREGS +Load the XMM FPU state for the thread from the buffer pointed to +by the argument +.Fa addr . +The buffer has the same layout as the 32-bit load buffer for the +machine instruction +.Dv FXRSTOR . +.Pp +As with +.Dv PT_GETXMMREGS, +this request is only valid for i386 programs. +.Pp +The +.Fa data +argument is ignored. +.It Dv PT_GETXSTATE_INFO +Report which XSAVE FPU extensions are supported by the CPU +and allowed in userspace programs. +The +.Fa addr +argument must point to a variable of type +.Vt struct ptrace_xstate_info , +which contains the information on the request return. +.Vt struct ptrace_xstate_info +is defined as follows: +.Bd -literal +struct ptrace_xstate_info { + uint64_t xsave_mask; + uint32_t xsave_len; +}; +.Ed +The +.Dv xsave_mask +field is a bitmask of the currently enabled extensions. +The meaning of the bits is defined in the Intel and AMD +processor documentation. +The +.Dv xsave_len +field reports the length of the XSAVE area for storing the hardware +state for currently enabled extensions in the format defined by the x86 +.Dv XSAVE +machine instruction. +.Pp +The +.Fa data +argument value must be equal to the size of the +.Vt struct ptrace_xstate_info . +.It Dv PT_GETXSTATE +Return the content of the XSAVE area for the thread. +The +.Fa addr +argument points to the buffer where the content is copied, and the +.Fa data +argument specifies the size of the buffer. +The kernel copies out as much content as allowed by the buffer size. +The buffer layout is specified by the layout of the save area for the +.Dv XSAVE +machine instruction. +.It Dv PT_SETXSTATE +Load the XSAVE state for the thread from the buffer specified by the +.Fa addr +pointer. +The buffer size is passed in the +.Fa data +argument. +The buffer must be at least as large as the +.Vt struct savefpu +(defined in +.Pa x86/fpu.h ) +to allow the complete x87 FPU and XMM state load. +It must not be larger than the XSAVE state length, as reported by the +.Dv xsave_len +field from the +.Vt struct ptrace_xstate_info +of the +.Dv PT_GETXSTATE_INFO +request. +Layout of the buffer is identical to the layout of the load area for the +.Dv XRSTOR +machine instruction. +.It Dv PT_GETFSBASE +Return the value of the base used when doing segmented +memory addressing using the %fs segment register. +The +.Fa addr +argument points to an +.Vt unsigned long +variable where the base value is stored. +.Pp +The +.Fa data +argument is ignored. +.It Dv PT_GETGSBASE +Like the +.Dv PT_GETFSBASE +request, but returns the base for the %gs segment register. +.It Dv PT_SETFSBASE +Set the base for the %fs segment register to the value pointed to +by the +.Fa addr +argument. +.Fa addr +must point to the +.Vt unsigned long +variable containing the new base. +.Pp +The +.Fa data +argument is ignored. +.It Dv PT_SETGSBASE +Like the +.Dv PT_SETFSBASE +request, but sets the base for the %gs segment register. +.El +.Sh PowerPC MACHINE-SPECIFIC REQUESTS +.Bl -tag -width "Dv PT_SETVRREGS" +.It Dv PT_GETVRREGS +Return the thread's +.Dv ALTIVEC +machine state in the buffer pointed to by +.Fa addr . +.Pp +The +.Fa data +argument is ignored. +.It Dv PT_SETVRREGS +Set the thread's +.Dv ALTIVEC +machine state from the buffer pointed to by +.Fa addr . .Pp -Additionally, machine-specific requests can exist. +The +.Fa data +argument is ignored. +.El +.Pp +Additionally, other machine-specific requests can exist. .Sh RETURN VALUES Some requests can cause .Fn ptrace @@ -564,6 +719,38 @@ provided to was less than or equal to zero, or larger than the .Vt ptrace_lwpinfo structure known to the kernel. +.It +The size (in +.Fa data ) +provided to the x86-specific +.Dv PT_GETXSTATE_INFO +request was not equal to the size of the +.Vt struct ptrace_xstate_info . +.It +The size (in +.Fa data ) +provided to the x86-specific +.Dv PT_SETXSTATE +request was less than the size of the x87 plus the XMM save area. +.It +The size (in +.Fa data ) +provided to the x86-specific +.Dv PT_SETXSTATE +request was larger than returned in the +.Dv xsave_len +member of the +.Vt struct ptrace_xstate_info +from the +.Dv PT_GETXSTATE_INFO +request. +.It +The base value, provided to the amd64-specific requests +.Dv PT_SETFSBASE +or +.Dv PT_SETGSBASE , +pointed outside of the valid user address space. +This error will not occur in 32-bit programs. .El .It Bq Er EBUSY .Bl -bullet -compact diff --git a/lib/libcapsicum/libcapsicum.c b/lib/libcapsicum/libcapsicum.c index 79c570f..8c4d04d 100644 --- a/lib/libcapsicum/libcapsicum.c +++ b/lib/libcapsicum/libcapsicum.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> +#include <sys/nv.h> #include <assert.h> #include <errno.h> @@ -44,7 +45,6 @@ __FBSDID("$FreeBSD$"); #include "libcapsicum.h" #include "libcapsicum_impl.h" -#include "nv.h" /* * Structure describing communication channel between two separated processes. diff --git a/lib/libcapsicum/libcapsicum_dns.c b/lib/libcapsicum/libcapsicum_dns.c index a180b6b..5f54283 100644 --- a/lib/libcapsicum/libcapsicum_dns.c +++ b/lib/libcapsicum/libcapsicum_dns.c @@ -30,14 +30,14 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/nv.h> + #include <assert.h> #include <netdb.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <nv.h> - #include "libcapsicum.h" #include "libcapsicum_dns.h" diff --git a/lib/libcapsicum/libcapsicum_grp.c b/lib/libcapsicum/libcapsicum_grp.c index 267ac68..44d573e 100644 --- a/lib/libcapsicum/libcapsicum_grp.c +++ b/lib/libcapsicum/libcapsicum_grp.c @@ -30,6 +30,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/dnv.h> +#include <sys/nv.h> #include <sys/param.h> #include <assert.h> @@ -39,9 +41,6 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <unistd.h> -#include <dnv.h> -#include <nv.h> - #include "libcapsicum.h" #include "libcapsicum_grp.h" diff --git a/lib/libcapsicum/libcapsicum_pwd.c b/lib/libcapsicum/libcapsicum_pwd.c index 32eeeb0..5b44c34 100644 --- a/lib/libcapsicum/libcapsicum_pwd.c +++ b/lib/libcapsicum/libcapsicum_pwd.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> +#include <sys/nv.h> #include <assert.h> #include <errno.h> @@ -39,8 +40,6 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <unistd.h> -#include <nv.h> - #include "libcapsicum.h" #include "libcapsicum_pwd.h" diff --git a/lib/libcapsicum/libcapsicum_random.c b/lib/libcapsicum/libcapsicum_random.c index 2c3eb36..2a7b109 100644 --- a/lib/libcapsicum/libcapsicum_random.c +++ b/lib/libcapsicum/libcapsicum_random.c @@ -30,12 +30,12 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/nv.h> + #include <assert.h> #include <errno.h> #include <string.h> -#include <nv.h> - #include "libcapsicum.h" #include "libcapsicum_random.h" diff --git a/lib/libcapsicum/libcapsicum_service.c b/lib/libcapsicum/libcapsicum_service.c index edfde8c..6b6ceea 100644 --- a/lib/libcapsicum/libcapsicum_service.c +++ b/lib/libcapsicum/libcapsicum_service.c @@ -30,12 +30,13 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/nv.h> + #include <assert.h> #include <errno.h> #include <string.h> #include <unistd.h> -#include <nv.h> #include "msgio.h" #include "libcapsicum.h" diff --git a/lib/libcapsicum/libcapsicum_sysctl.c b/lib/libcapsicum/libcapsicum_sysctl.c index fc69113..3f1ccd9 100644 --- a/lib/libcapsicum/libcapsicum_sysctl.c +++ b/lib/libcapsicum/libcapsicum_sysctl.c @@ -30,11 +30,11 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/nv.h> + #include <errno.h> #include <string.h> -#include <nv.h> - #include "libcapsicum.h" #include "libcapsicum_sysctl.h" diff --git a/lib/libcasper/libcasper.c b/lib/libcasper/libcasper.c index cb95346..e241888 100644 --- a/lib/libcasper/libcasper.c +++ b/lib/libcasper/libcasper.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <sys/socket.h> #include <sys/stat.h> #include <sys/un.h> +#include <sys/nv.h> #include <assert.h> #include <dirent.h> @@ -52,7 +53,6 @@ __FBSDID("$FreeBSD$"); #include <libcapsicum.h> #include <libcasper.h> #include <libcasper_impl.h> -#include <nv.h> #include <pjdlog.h> /* diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index e0c2979..91ca6a3 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -1330,7 +1330,6 @@ static int http_authorize(conn_t *conn, const char *hdr, http_auth_challenges_t *cs, http_auth_params_t *parms, struct url *url) { - http_auth_challenge_t *basic = NULL; http_auth_challenge_t *digest = NULL; int i; @@ -1340,10 +1339,8 @@ http_authorize(conn_t *conn, const char *hdr, http_auth_challenges_t *cs, return (-1); } - /* Look for a Digest and a Basic challenge */ + /* Look for a Digest */ for (i = 0; i < cs->count; i++) { - if (cs->challenges[i]->scheme == HTTPAS_BASIC) - basic = cs->challenges[i]; if (cs->challenges[i]->scheme == HTTPAS_DIGEST) digest = cs->challenges[i]; } diff --git a/lib/libgpio/gpio.3 b/lib/libgpio/gpio.3 index 70f6b38..6bdf4ea 100644 --- a/lib/libgpio/gpio.3 +++ b/lib/libgpio/gpio.3 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 8, 2015 +.Dd July 1, 2015 .Dt GPIO 3 .Os .Sh NAME @@ -35,6 +35,7 @@ .Sh LIBRARY .Lb libgpio .Sh SYNOPSIS +.In sys/types.h .In libgpio.h .Ft "gpio_handle_t" .Fn gpio_open "unsigned int unit" @@ -161,13 +162,14 @@ are wrappers around The following example shows how to configure pin 16 as output and then drive it high: .Bd -literal +#include <sys/types.h> #include <err.h> #include <libgpio.h> gpio_handle_t handle; handle = gpio_open(0); -if (handle == GPIO_HANDLE_INVALID) +if (handle == GPIO_INVALID_HANDLE) err(1, "gpio_open failed"); gpio_pin_output(handle, 16); gpio_pin_high(handle, 16); diff --git a/lib/libipsec/pfkey_dump.c b/lib/libipsec/pfkey_dump.c index 068ad0e..872aa43 100644 --- a/lib/libipsec/pfkey_dump.c +++ b/lib/libipsec/pfkey_dump.c @@ -187,6 +187,9 @@ static struct val2str str_alg_enc[] = { #ifdef SADB_X_EALG_AESCTR { SADB_X_EALG_AESCTR, "aes-ctr", }, #endif +#ifdef SADB_X_EALG_AESGCM16 + { SADB_X_EALG_AESGCM16, "aes-gcm-16", }, +#endif #ifdef SADB_X_EALG_CAMELLIACBC { SADB_X_EALG_CAMELLIACBC, "camellia-cbc", }, #endif diff --git a/lib/libnv/Makefile b/lib/libnv/Makefile index 8b2fc78..38ec009 100644 --- a/lib/libnv/Makefile +++ b/lib/libnv/Makefile @@ -7,81 +7,13 @@ SHLIBDIR?= /lib LIB= nv SHLIB_MAJOR= 0 -.PATH: ${.CURDIR}/../../sys/kern ${.CURDIR}/../../sys/sys +.PATH: ${.CURDIR}/../../sys/contrib/libnv ${.CURDIR}/../../sys/sys CFLAGS+=-I${.CURDIR}/../../sys -I${.CURDIR} -SRCS= subr_dnvlist.c +SRCS= dnvlist.c SRCS+= msgio.c -SRCS+= subr_nvlist.c -SRCS+= subr_nvpair.c - -INCS= dnv.h -INCS+= nv.h - -MAN+= nv.3 - -MLINKS+=nv.3 libnv.3 \ - nv.3 nvlist.3 -MLINKS+=nv.3 nvlist_add_binary.3 \ - nv.3 nvlist_add_bool.3 \ - nv.3 nvlist_add_descriptor.3 \ - nv.3 nvlist_add_null.3 \ - nv.3 nvlist_add_number.3 \ - nv.3 nvlist_add_nvlist.3 \ - nv.3 nvlist_add_string.3 \ - nv.3 nvlist_add_stringf.3 \ - nv.3 nvlist_add_stringv.3 \ - nv.3 nvlist_clone.3 \ - nv.3 nvlist_create.3 \ - nv.3 nvlist_destroy.3 \ - nv.3 nvlist_dump.3 \ - nv.3 nvlist_empty.3 \ - nv.3 nvlist_error.3 \ - nv.3 nvlist_exists.3 \ - nv.3 nvlist_exists_binary.3 \ - nv.3 nvlist_exists_bool.3 \ - nv.3 nvlist_exists_descriptor.3 \ - nv.3 nvlist_exists_null.3 \ - nv.3 nvlist_exists_number.3 \ - nv.3 nvlist_exists_nvlist.3 \ - nv.3 nvlist_exists_string.3 \ - nv.3 nvlist_exists_type.3 \ - nv.3 nvlist_fdump.3 \ - nv.3 nvlist_flags.3 \ - nv.3 nvlist_free.3 \ - nv.3 nvlist_free_binary.3 \ - nv.3 nvlist_free_bool.3 \ - nv.3 nvlist_free_descriptor.3 \ - nv.3 nvlist_free_null.3 \ - nv.3 nvlist_free_number.3 \ - nv.3 nvlist_free_nvlist.3 \ - nv.3 nvlist_free_string.3 \ - nv.3 nvlist_free_type.3 \ - nv.3 nvlist_get_binary.3 \ - nv.3 nvlist_get_bool.3 \ - nv.3 nvlist_get_descriptor.3 \ - nv.3 nvlist_get_number.3 \ - nv.3 nvlist_get_nvlist.3 \ - nv.3 nvlist_get_parent.3 \ - nv.3 nvlist_get_string.3 \ - nv.3 nvlist_move_binary.3 \ - nv.3 nvlist_move_descriptor.3 \ - nv.3 nvlist_move_nvlist.3 \ - nv.3 nvlist_move_string.3 \ - nv.3 nvlist_next.3 \ - nv.3 nvlist_pack.3 \ - nv.3 nvlist_recv.3 \ - nv.3 nvlist_send.3 \ - nv.3 nvlist_set_error.3 \ - nv.3 nvlist_size.3 \ - nv.3 nvlist_take_binary.3 \ - nv.3 nvlist_take_bool.3 \ - nv.3 nvlist_take_descriptor.3 \ - nv.3 nvlist_take_number.3 \ - nv.3 nvlist_take_nvlist.3 \ - nv.3 nvlist_take_string.3 \ - nv.3 nvlist_unpack.3 \ - nv.3 nvlist_xfer.3 +SRCS+= nvlist.c +SRCS+= nvpair.c WARNS?= 6 diff --git a/lib/libnv/nv.3 b/lib/libnv/nv.3 deleted file mode 100644 index 58033be..0000000 --- a/lib/libnv/nv.3 +++ /dev/null @@ -1,691 +0,0 @@ -.\" -.\" Copyright (c) 2013 The FreeBSD Foundation -.\" All rights reserved. -.\" -.\" This documentation was written by Pawel Jakub Dawidek under sponsorship -.\" 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$ -.\" -.Dd May 2, 2015 -.Dt NV 3 -.Os -.Sh NAME -.Nm nvlist_create , -.Nm nvlist_destroy , -.Nm nvlist_error , -.Nm nvlist_set_error , -.Nm nvlist_empty , -.Nm nvlist_flags , -.Nm nvlist_exists , -.Nm nvlist_free , -.Nm nvlist_clone , -.Nm nvlist_dump , -.Nm nvlist_fdump , -.Nm nvlist_size , -.Nm nvlist_pack , -.Nm nvlist_unpack , -.Nm nvlist_send , -.Nm nvlist_recv , -.Nm nvlist_xfer , -.Nm nvlist_next , -.Nm nvlist_add , -.Nm nvlist_move , -.Nm nvlist_get , -.Nm nvlist_take -.Nd "library for name/value pairs" -.Sh LIBRARY -.Lb libnv -.Sh SYNOPSIS -.In nv.h -.Ft "nvlist_t *" -.Fn nvlist_create "int flags" -.Ft void -.Fn nvlist_destroy "nvlist_t *nvl" -.Ft int -.Fn nvlist_error "const nvlist_t *nvl" -.Ft void -.Fn nvlist_set_error "nvlist_t *nvl, int error" -.Ft bool -.Fn nvlist_empty "const nvlist_t *nvl" -.Ft int -.Fn nvlist_flags "const nvlist_t *nvl" -.\" -.Ft "nvlist_t *" -.Fn nvlist_clone "const nvlist_t *nvl" -.\" -.Ft void -.Fn nvlist_dump "const nvlist_t *nvl, int fd" -.Ft void -.Fn nvlist_fdump "const nvlist_t *nvl, FILE *fp" -.\" -.Ft size_t -.Fn nvlist_size "const nvlist_t *nvl" -.Ft "void *" -.Fn nvlist_pack "const nvlist_t *nvl" "size_t *sizep" -.Ft "nvlist_t *" -.Fn nvlist_unpack "const void *buf" "size_t size" "int flags" -.\" -.Ft int -.Fn nvlist_send "int sock" "const nvlist_t *nvl" -.Ft "nvlist_t *" -.Fn nvlist_recv "int sock" "int flags" -.Ft "nvlist_t *" -.Fn nvlist_xfer "int sock" "nvlist_t *nvl" "int flags" -.\" -.Ft "const char *" -.Fn nvlist_next "const nvlist_t *nvl" "int *typep" "void **cookiep" -.\" -.Ft bool -.Fn nvlist_exists "const nvlist_t *nvl" "const char *name" -.Ft bool -.Fn nvlist_exists_type "const nvlist_t *nvl" "const char *name" "int type" -.Ft bool -.Fn nvlist_exists_null "const nvlist_t *nvl" "const char *name" -.Ft bool -.Fn nvlist_exists_bool "const nvlist_t *nvl" "const char *name" -.Ft bool -.Fn nvlist_exists_number "const nvlist_t *nvl" "const char *name" -.Ft bool -.Fn nvlist_exists_string "const nvlist_t *nvl" "const char *name" -.Ft bool -.Fn nvlist_exists_nvlist "const nvlist_t *nvl" "const char *name" -.Ft bool -.Fn nvlist_exists_descriptor "const nvlist_t *nvl" "const char *name" -.Ft bool -.Fn nvlist_exists_binary "const nvlist_t *nvl" "const char *name" -.\" -.Ft void -.Fn nvlist_add_null "nvlist_t *nvl" "const char *name" -.Ft void -.Fn nvlist_add_bool "nvlist_t *nvl" "const char *name" "bool value" -.Ft void -.Fn nvlist_add_number "nvlist_t *nvl" "const char *name" "uint64_t value" -.Ft void -.Fn nvlist_add_string "nvlist_t *nvl" "const char *name" "const char *value" -.Ft void -.Fn nvlist_add_stringf "nvlist_t *nvl" "const char *name" "const char *valuefmt" "..." -.Ft void -.Fn nvlist_add_stringv "nvlist_t *nvl" "const char *name" "const char *valuefmt" "va_list valueap" -.Ft void -.Fn nvlist_add_nvlist "nvlist_t *nvl" "const char *name" "const nvlist_t *value" -.Ft void -.Fn nvlist_add_descriptor "nvlist_t *nvl" "const char *name" "int value" -.Ft void -.Fn nvlist_add_binary "nvlist_t *nvl" "const char *name" "const void *value" "size_t size" -.\" -.Ft void -.Fn nvlist_move_string "nvlist_t *nvl" "const char *name" "char *value" -.Ft void -.Fn nvlist_move_nvlist "nvlist_t *nvl" "const char *name" "nvlist_t *value" -.Ft void -.Fn nvlist_move_descriptor "nvlist_t *nvl" "const char *name" "int value" -.Ft void -.Fn nvlist_move_binary "nvlist_t *nvl" "const char *name" "void *value" "size_t size" -.\" -.Ft bool -.Fn nvlist_get_bool "const nvlist_t *nvl" "const char *name" -.Ft uint64_t -.Fn nvlist_get_number "const nvlist_t *nvl" "const char *name" -.Ft "const char *" -.Fn nvlist_get_string "const nvlist_t *nvl" "const char *name" -.Ft "const nvlist_t *" -.Fn nvlist_get_nvlist "const nvlist_t *nvl" "const char *name" -.Ft int -.Fn nvlist_get_descriptor "const nvlist_t *nvl" "const char *name" -.Ft "const void *" -.Fn nvlist_get_binary "const nvlist_t *nvl" "const char *name" "size_t *sizep" -.Ft "const nvlist_t *" -.Fn nvlist_get_parent "const nvlist_t *nvl" "void **cookiep" -.\" -.Ft bool -.Fn nvlist_take_bool "nvlist_t *nvl" "const char *name" -.Ft uint64_t -.Fn nvlist_take_number "nvlist_t *nvl" "const char *name" -.Ft "char *" -.Fn nvlist_take_string "nvlist_t *nvl" "const char *name" -.Ft "nvlist_t *" -.Fn nvlist_take_nvlist "nvlist_t *nvl" "const char *name" -.Ft int -.Fn nvlist_take_descriptor "nvlist_t *nvl" "const char *name" -.Ft "void *" -.Fn nvlist_take_binary "nvlist_t *nvl" "const char *name" "size_t *sizep" -.\" -.Ft void -.Fn nvlist_free "nvlist_t *nvl" "const char *name" -.Ft void -.Fn nvlist_free_type "nvlist_t *nvl" "const char *name" "int type" -.\" -.Ft void -.Fn nvlist_free_null "nvlist_t *nvl" "const char *name" -.Ft void -.Fn nvlist_free_bool "nvlist_t *nvl" "const char *name" -.Ft void -.Fn nvlist_free_number "nvlist_t *nvl" "const char *name" -.Ft void -.Fn nvlist_free_string "nvlist_t *nvl" "const char *name" -.Ft void -.Fn nvlist_free_nvlist "nvlist_t *nvl" "const char *name" -.Ft void -.Fn nvlist_free_descriptor "nvlist_t *nvl" "const char *name" -.Ft void -.Fn nvlist_free_binary "nvlist_t *nvl" "const char *name" -.Sh DESCRIPTION -The -.Nm libnv -library allows to easily manage name value pairs as well as send and receive -them over sockets. -A group (list) of name value pairs is called an -.Nm nvlist . -The API supports the following data types: -.Bl -ohang -offset indent -.It Sy null ( NV_TYPE_NULL ) -There is no data associated with the name. -.It Sy bool ( NV_TYPE_BOOL ) -The value can be either -.Dv true -or -.Dv false . -.It Sy number ( NV_TYPE_NUMBER ) -The value is a number stored as -.Vt uint64_t . -.It Sy string ( NV_TYPE_STRING ) -The value is a C string. -.It Sy nvlist ( NV_TYPE_NVLIST ) -The value is a nested nvlist. -.It Sy descriptor ( NV_TYPE_DESCRIPTOR ) -The value is a file descriptor. -Note that file descriptors can be sent only over -.Xr unix 4 -domain sockets. -.It Sy binary ( NV_TYPE_BINARY ) -The value is a binary buffer. -.El -.Pp -The -.Fn nvlist_create -function allocates memory and initializes an nvlist. -.Pp -The following flag can be provided: -.Pp -.Bl -tag -width "NV_FLAG_IGNORE_CASE" -compact -offset indent -.It Dv NV_FLAG_IGNORE_CASE -Perform case-insensitive lookups of provided names. -.It Dv NV_FLAG_NO_UNIQUE -Names in the nvlist do not have to be unique. -.El -.Pp -The -.Fn nvlist_destroy -function destroys the given nvlist. -Function does nothing if -.Dv NULL -nvlist is provided. -Function never modifies the -.Va errno -global variable. -.Pp -The -.Fn nvlist_error -function returns any error value that the nvlist accumulated. -If the given nvlist is -.Dv NULL -the -.Er ENOMEM -error will be returned. -.Pp -The -.Fn nvlist_set_error -function sets an nvlist to be in the error state. -Subsequent calls to -.Fn nvlist_error -will return the given error value. -This function cannot be used to clear the error state from an nvlist. -This function does nothing if the nvlist is already in the error state. -.Pp -The -.Fn nvlist_empty -function returns -.Dv true -if the given nvlist is empty and -.Dv false -otherwise. -The nvlist must not be in error state. -.Pp -The -.Fn nvlist_flags -function returns flags used to create the nvlist with the -.Fn nvlist_create -function. -.Pp -The -.Fn nvlist_clone -functions clones the given nvlist. -The clone shares no resources with its origin. -This also means that all file descriptors that are part of the nvlist will be -duplicated with the -.Xr dup 2 -system call before placing them in the clone. -.Pp -The -.Fn nvlist_dump -dumps nvlist content for debugging purposes to the given file descriptor -.Fa fd . -.Pp -The -.Fn nvlist_fdump -dumps nvlist content for debugging purposes to the given file stream -.Fa fp . -.Pp -The -.Fn nvlist_size -function returns the size of the given nvlist after converting it to binary -buffer with the -.Fn nvlist_pack -function. -.Pp -The -.Fn nvlist_pack -function converts the given nvlist to a binary buffer. -The function allocates memory for the buffer, which should be freed with the -.Xr free 3 -function. -If the -.Fa sizep -argument is not -.Dv NULL , -the size of the buffer will be stored there. -The function returns -.Dv NULL -in case of an error (allocation failure). -If the nvlist contains any file descriptors -.Dv NULL -will be returned. -The nvlist must not be in error state. -.Pp -The -.Fn nvlist_unpack -function converts the given buffer to the nvlist. -The -.Fa flags -argument defines what type of the top level nvlist is expected to be. -Flags are set up using the -.Fn nvlist_create -function. -If the nvlist flags do not match the flags passed to -.Fn nvlist_unpack , -the nvlist will not be returned. -Every nested nvlist list should be checked using -.Fn nvlist_flags -function. -The function returns -.Dv NULL -in case of an error. -.Pp -The -.Fn nvlist_send -function sends the given nvlist over the socket given by the -.Fa sock -argument. -Note that nvlist that contains file descriptors can only be send over -.Xr unix 4 -domain sockets. -.Pp -The -.Fn nvlist_recv -function receives nvlist over the socket given by the -.Fa sock -argument. -The -.Fa flags -argument defines what type of the top level nvlist is expected to be. -Flags are set up using the -.Fn nvlist_create -function. -If the nvlist flags do not match the flags passed to -.Fn nvlist_recv , -the nvlist will not be returned. -Every nested nvlist list should be checked using -.Fn nvlist_flags -function. -.Pp -The -.Fn nvlist_xfer -function sends the given nvlist over the socket given by the -.Fa sock -argument and receives nvlist over the same socket. -The -.Fa flags -argument defines what type of the top level nvlist is expected to be. -Flags are set up using the -.Fn nvlist_create -function. -If the nvlist flags do not match the flags passed to -.Fn nvlist_xfer , -the nvlist will not be returned. -Every nested nvlist list should be checked using -.Fn nvlist_flags -function. -The given nvlist is always destroyed. -.Pp -The -.Fn nvlist_next -function iterates over the given nvlist returning names and types of subsequent -elements. -The -.Fa cookiep -argument allows the function to figure out which element should be returned -next. -The -.Va *cookiep -should be set to -.Dv NULL -for the first call and should not be changed later. -Returning -.Dv NULL -means there are no more elements on the nvlist. -The -.Fa typep -argument can be NULL. -Elements may not be removed from the nvlist while traversing it. -The nvlist must not be in error state. -.Pp -The -.Fn nvlist_exists -function returns -.Dv true -if element of the given name exists (besides of its type) or -.Dv false -otherwise. -The nvlist must not be in error state. -.Pp -The -.Fn nvlist_exists_type -function returns -.Dv true -if element of the given name and the given type exists or -.Dv false -otherwise. -The nvlist must not be in error state. -.Pp -The -.Fn nvlist_exists_null , -.Fn nvlist_exists_bool , -.Fn nvlist_exists_number , -.Fn nvlist_exists_string , -.Fn nvlist_exists_nvlist , -.Fn nvlist_exists_descriptor , -.Fn nvlist_exists_binary -functions return -.Dv true -if element of the given name and the given type determined by the function name -exists or -.Dv false -otherwise. -The nvlist must not be in error state. -.Pp -The -.Fn nvlist_add_null , -.Fn nvlist_add_bool , -.Fn nvlist_add_number , -.Fn nvlist_add_string , -.Fn nvlist_add_stringf , -.Fn nvlist_add_stringv , -.Fn nvlist_add_nvlist , -.Fn nvlist_add_descriptor , -.Fn nvlist_add_binary -functions add element to the given nvlist. -When adding string or binary buffor the functions will allocate memory -and copy the data over. -When adding nvlist, the nvlist will be cloned and clone will be added. -When adding descriptor, the descriptor will be duplicated using the -.Xr dup 2 -system call and the new descriptor will be added. -If an error occurs while adding new element, internal error is set which can be -examined using the -.Fn nvlist_error -function. -.Pp -The -.Fn nvlist_move_string , -.Fn nvlist_move_nvlist , -.Fn nvlist_move_descriptor , -.Fn nvlist_move_binary -functions add new element to the given nvlist, but unlike -.Fn nvlist_add_<type> -functions they will consume the given resource. -If an error occurs while adding new element, the resource is destroyed and -internal error is set which can be examined using the -.Fn nvlist_error -function. -.Pp -The -.Fn nvlist_get_bool , -.Fn nvlist_get_number , -.Fn nvlist_get_string , -.Fn nvlist_get_nvlist , -.Fn nvlist_get_descriptor , -.Fn nvlist_get_binary -functions allow to obtain value of the given name. -In case of string, nvlist, descriptor or binary, returned resource should -not be modified - it still belongs to the nvlist. -If element of the given name does not exist, the program will be aborted. -To avoid that the caller should check for existence before trying to obtain -the value or use -.Xr dnvlist 3 -extension, which allows to provide default value for a missing element. -The nvlist must not be in error state. -.Pp -The -.Fn nvlist_get_parent -function allows to obtain the parent nvlist from the nested nvlist. -.Pp -The -.Fn nvlist_take_bool , -.Fn nvlist_take_number , -.Fn nvlist_take_string , -.Fn nvlist_take_nvlist , -.Fn nvlist_take_descriptor , -.Fn nvlist_take_binary -functions return value associated with the given name and remove the element -from the nvlist. -In case of string and binary values, the caller is responsible for free returned -memory using the -.Xr free 3 -function. -In case of nvlist, the caller is responsible for destroying returned nvlist -using the -.Fn nvlist_destroy -function. -In case of descriptor, the caller is responsible for closing returned descriptor -using the -.Fn close 2 -system call. -If element of the given name does not exist, the program will be aborted. -To avoid that the caller should check for existence before trying to obtain -the value or use -.Xr dnvlist 3 -extension, which allows to provide default value for a missing element. -The nvlist must not be in error state. -.Pp -The -.Fn nvlist_free -function removes element of the given name from the nvlist (besides of its type) -and frees all resources associated with it. -If element of the given name does not exist, the program will be aborted. -The nvlist must not be in error state. -.Pp -The -.Fn nvlist_free_type -function removes element of the given name and the given type from the nvlist -and frees all resources associated with it. -If element of the given name and the given type does not exist, the program -will be aborted. -The nvlist must not be in error state. -.Pp -The -.Fn nvlist_free_null , -.Fn nvlist_free_bool , -.Fn nvlist_free_number , -.Fn nvlist_free_string , -.Fn nvlist_free_nvlist , -.Fn nvlist_free_descriptor , -.Fn nvlist_free_binary -functions remove element of the given name and the given type determined by the -function name from the nvlist and free all resources associated with it. -If element of the given name and the given type does not exist, the program -will be aborted. -The nvlist must not be in error state. -.Sh EXAMPLES -The following example demonstrates how to prepare an nvlist and send it over -.Xr unix 4 -domain socket. -.Bd -literal -nvlist_t *nvl; -int fd; - -fd = open("/tmp/foo", O_RDONLY); -if (fd < 0) - err(1, "open(\\"/tmp/foo\\") failed"); - -nvl = nvlist_create(0); -/* - * There is no need to check if nvlist_create() succeeded, - * as the nvlist_add_<type>() functions can cope. - * If it failed, nvlist_send() will fail. - */ -nvlist_add_string(nvl, "filename", "/tmp/foo"); -nvlist_add_number(nvl, "flags", O_RDONLY); -/* - * We just want to send the descriptor, so we can give it - * for the nvlist to consume (that's why we use nvlist_move - * not nvlist_add). - */ -nvlist_move_descriptor(nvl, "fd", fd); -if (nvlist_send(sock, nvl) < 0) { - nvlist_destroy(nvl); - err(1, "nvlist_send() failed"); -} -nvlist_destroy(nvl); -.Ed -.Pp -Receiving nvlist and getting data: -.Bd -literal -nvlist_t *nvl; -const char *command; -char *filename; -int fd; - -nvl = nvlist_recv(sock, 0); -if (nvl == NULL) - err(1, "nvlist_recv() failed"); - -/* For command we take pointer to nvlist's buffer. */ -command = nvlist_get_string(nvl, "command"); -/* - * For filename we remove it from the nvlist and take - * ownership of the buffer. - */ -filename = nvlist_take_string(nvl, "filename"); -/* The same for the descriptor. */ -fd = nvlist_take_descriptor(nvl, "fd"); - -printf("command=%s filename=%s fd=%d\n", command, filename, fd); - -nvlist_destroy(nvl); -free(filename); -close(fd); -/* command was freed by nvlist_destroy() */ -.Ed -.Pp -Iterating over nvlist: -.Bd -literal -nvlist_t *nvl; -const char *name; -void *cookie; -int type; - -nvl = nvlist_recv(sock, 0); -if (nvl == NULL) - err(1, "nvlist_recv() failed"); - -cookie = NULL; -while ((name = nvlist_next(nvl, &type, &cookie)) != NULL) { - printf("%s=", name); - switch (type) { - case NV_TYPE_NUMBER: - printf("%ju", (uintmax_t)nvlist_get_number(nvl, name)); - break; - case NV_TYPE_STRING: - printf("%s", nvlist_get_string(nvl, name)); - break; - default: - printf("N/A"); - break; - } - printf("\\n"); -} -.Ed -.Pp -Iterating over every nested nvlist: -.Bd -literal -nvlist_t *nvl; -const char *name; -void *cookie; -int type; - -nvl = nvlist_recv(sock, 0); -if (nvl == NULL) - err(1, "nvlist_recv() failed"); - -cookie = NULL; -do { - while ((name = nvlist_next(nvl, &type, &cookie)) != NULL) { - if (type == NV_TYPE_NVLIST) { - nvl = nvlist_get_nvlist(nvl, name); - cookie = NULL; - } - } -} while ((nvl = nvlist_get_parent(nvl, &cookie)) != NULL); -.Ed -.Sh SEE ALSO -.Xr close 2 , -.Xr dup 2 , -.Xr open 2 , -.Xr err 3 , -.Xr free 3 , -.Xr printf 3 , -.Xr unix 4 -.Sh HISTORY -The -.Nm libnv -library appeared in -.Fx 11.0 . -.Sh AUTHORS -.An -nosplit -The -.Nm libnv -library was implemented by -.An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net -under sponsorship from the FreeBSD Foundation. diff --git a/lib/libnv/tests/dnv_tests.cc b/lib/libnv/tests/dnv_tests.cc index 2f92d9d..fe80d00 100644 --- a/lib/libnv/tests/dnv_tests.cc +++ b/lib/libnv/tests/dnv_tests.cc @@ -27,9 +27,10 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/dnv.h> +#include <sys/nv.h> + #include <atf-c++.hpp> -#include <dnv.h> -#include <nv.h> ATF_TEST_CASE_WITHOUT_HEAD(dnvlist_get_bool__present); ATF_TEST_CASE_BODY(dnvlist_get_bool__present) diff --git a/lib/libnv/tests/nv_tests.cc b/lib/libnv/tests/nv_tests.cc index d779190..1c65b66 100644 --- a/lib/libnv/tests/nv_tests.cc +++ b/lib/libnv/tests/nv_tests.cc @@ -27,8 +27,9 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/nv.h> + #include <atf-c++.hpp> -#include <nv.h> #include <errno.h> #include <limits> diff --git a/lib/libnv/tests/nvlist_add_test.c b/lib/libnv/tests/nvlist_add_test.c index 06bcc63..04486f3 100644 --- a/lib/libnv/tests/nvlist_add_test.c +++ b/lib/libnv/tests/nvlist_add_test.c @@ -29,12 +29,12 @@ * $FreeBSD$ */ +#include <sys/nv.h> + #include <errno.h> #include <stdio.h> #include <unistd.h> -#include <nv.h> - static int ntest = 1; #define CHECK(expr) do { \ diff --git a/lib/libnv/tests/nvlist_exists_test.c b/lib/libnv/tests/nvlist_exists_test.c index cb595d7..b4596fb6 100644 --- a/lib/libnv/tests/nvlist_exists_test.c +++ b/lib/libnv/tests/nvlist_exists_test.c @@ -29,11 +29,11 @@ * $FreeBSD$ */ +#include <sys/nv.h> + #include <stdio.h> #include <unistd.h> -#include <nv.h> - static int ntest = 1; #define CHECK(expr) do { \ diff --git a/lib/libnv/tests/nvlist_free_test.c b/lib/libnv/tests/nvlist_free_test.c index 4417a44..74ab785 100644 --- a/lib/libnv/tests/nvlist_free_test.c +++ b/lib/libnv/tests/nvlist_free_test.c @@ -29,11 +29,11 @@ * $FreeBSD$ */ +#include <sys/nv.h> + #include <stdio.h> #include <unistd.h> -#include <nv.h> - static int ntest = 1; #define CHECK(expr) do { \ diff --git a/lib/libnv/tests/nvlist_get_test.c b/lib/libnv/tests/nvlist_get_test.c index b4468db..f67da90 100644 --- a/lib/libnv/tests/nvlist_get_test.c +++ b/lib/libnv/tests/nvlist_get_test.c @@ -28,6 +28,7 @@ * * $FreeBSD$ */ +#include <sys/nv.h> #include <errno.h> #include <fcntl.h> @@ -35,8 +36,6 @@ #include <string.h> #include <unistd.h> -#include <nv.h> - static int ntest = 1; #define CHECK(expr) do { \ diff --git a/lib/libnv/tests/nvlist_move_test.c b/lib/libnv/tests/nvlist_move_test.c index 760399d..7499faa 100644 --- a/lib/libnv/tests/nvlist_move_test.c +++ b/lib/libnv/tests/nvlist_move_test.c @@ -29,14 +29,14 @@ * $FreeBSD$ */ +#include <sys/nv.h> + #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <nv.h> - static int ntest = 1; #define CHECK(expr) do { \ diff --git a/lib/libnv/tests/nvlist_send_recv_test.c b/lib/libnv/tests/nvlist_send_recv_test.c index 50222fb..f4bc1c4 100644 --- a/lib/libnv/tests/nvlist_send_recv_test.c +++ b/lib/libnv/tests/nvlist_send_recv_test.c @@ -32,6 +32,7 @@ #include <sys/types.h> #include <sys/socket.h> #include <sys/wait.h> +#include <sys/nv.h> #include <err.h> #include <errno.h> @@ -40,8 +41,6 @@ #include <string.h> #include <unistd.h> -#include <nv.h> - static int ntest = 1; #define CHECK(expr) do { \ diff --git a/lib/libproc/proc_bkpt.c b/lib/libproc/proc_bkpt.c index 1e4a6cc..50d8a9d 100644 --- a/lib/libproc/proc_bkpt.c +++ b/lib/libproc/proc_bkpt.c @@ -42,18 +42,24 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include "_libproc.h" -#if defined(__i386__) || defined(__amd64__) -#define BREAKPOINT_INSTR 0xcc /* int 0x3 */ +#if defined(__aarch64__) +#define AARCH64_BRK 0xd4200000 +#define AARCH64_BRK_IMM16_SHIFT 5 +#define AARCH64_BRK_IMM16_VAL (0xd << AARCH64_BRK_IMM16_SHIFT) +#define BREAKPOINT_INSTR (AARCH64_BRK | AARCH64_BRK_IMM16_VAL) +#define BREAKPOINT_INSTR_SZ 4 +#elif defined(__amd64__) || defined(__i386__) +#define BREAKPOINT_INSTR 0xcc /* int 0x3 */ #define BREAKPOINT_INSTR_SZ 1 +#elif defined(__arm__) +#define BREAKPOINT_INSTR 0xe7ffffff /* bkpt */ +#define BREAKPOINT_INSTR_SZ 4 #elif defined(__mips__) -#define BREAKPOINT_INSTR 0xd /* break */ +#define BREAKPOINT_INSTR 0xd /* break */ #define BREAKPOINT_INSTR_SZ 4 #elif defined(__powerpc__) -#define BREAKPOINT_INSTR 0x7fe00008 /* trap */ -#define BREAKPOINT_INSTR_SZ 4 -#elif defined(__arm__) -#define BREAKPOINT_INSTR 0xe7ffffff /* bkpt */ -#define BREAKPOINT_INSTR_SZ 4 +#define BREAKPOINT_INSTR 0x7fe00008 /* trap */ +#define BREAKPOINT_INSTR_SZ 4 #else #error "Add support for your architecture" #endif diff --git a/lib/libproc/proc_regs.c b/lib/libproc/proc_regs.c index 35d8d38..aae43ba 100644 --- a/lib/libproc/proc_regs.c +++ b/lib/libproc/proc_regs.c @@ -54,7 +54,9 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, unsigned long *regvalue) return (-1); switch (reg) { case REG_PC: -#if defined(__amd64__) +#if defined(__aarch64__) + *regvalue = regs.elr; +#elif defined(__amd64__) *regvalue = regs.r_rip; #elif defined(__arm__) *regvalue = regs.r_pc; @@ -67,7 +69,9 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, unsigned long *regvalue) #endif break; case REG_SP: -#if defined(__amd64__) +#if defined(__aarch64__) + *regvalue = regs.sp; +#elif defined(__amd64__) *regvalue = regs.r_rsp; #elif defined(__arm__) *regvalue = regs.r_sp; @@ -101,7 +105,9 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, unsigned long regvalue) return (-1); switch (reg) { case REG_PC: -#if defined(__amd64__) +#if defined(__aarch64__) + regs.elr = regvalue; +#elif defined(__amd64__) regs.r_rip = regvalue; #elif defined(__arm__) regs.r_pc = regvalue; @@ -114,7 +120,9 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, unsigned long regvalue) #endif break; case REG_SP: -#if defined(__amd64__) +#if defined(__aarch64__) + regs.sp = regvalue; +#elif defined(__amd64__) regs.r_rsp = regvalue; #elif defined(__arm__) regs.r_sp = regvalue; diff --git a/lib/libugidfw/Makefile b/lib/libugidfw/Makefile index 2e09565..f11200d 100644 --- a/lib/libugidfw/Makefile +++ b/lib/libugidfw/Makefile @@ -1,7 +1,7 @@ # $FreeBSD$ LIB= ugidfw -SHLIB_MAJOR= 4 +SHLIB_MAJOR= 5 SRCS= ugidfw.c INCS= ugidfw.h diff --git a/lib/libugidfw/ugidfw.c b/lib/libugidfw/ugidfw.c index 479ab46..a1e36d2 100644 --- a/lib/libugidfw/ugidfw.c +++ b/lib/libugidfw/ugidfw.c @@ -505,7 +505,7 @@ truncated: return (-1); } -int +static int bsde_parse_uidrange(char *spec, uid_t *min, uid_t *max, size_t buflen, char *errstr){ struct passwd *pwd; @@ -554,7 +554,7 @@ bsde_parse_uidrange(char *spec, uid_t *min, uid_t *max, return (0); } -int +static int bsde_parse_gidrange(char *spec, gid_t *min, gid_t *max, size_t buflen, char *errstr){ struct group *grp; @@ -603,7 +603,7 @@ bsde_parse_gidrange(char *spec, gid_t *min, gid_t *max, return (0); } -int +static int bsde_parse_subject(int argc, char *argv[], struct mac_bsdextended_subject *subject, size_t buflen, char *errstr) { @@ -612,7 +612,7 @@ bsde_parse_subject(int argc, char *argv[], char *endp; uid_t uid_min, uid_max; gid_t gid_min, gid_max; - int jid; + int jid = 0; size_t len; long value; @@ -720,7 +720,7 @@ bsde_parse_subject(int argc, char *argv[], return (0); } -int +static int bsde_parse_type(char *spec, int *type, size_t buflen, char *errstr) { size_t len; @@ -764,7 +764,7 @@ bsde_parse_type(char *spec, int *type, size_t buflen, char *errstr) return (0); } -int +static int bsde_parse_fsid(char *spec, struct fsid *fsid, size_t buflen, char *errstr) { size_t len; @@ -781,15 +781,15 @@ bsde_parse_fsid(char *spec, struct fsid *fsid, size_t buflen, char *errstr) return (0); } -int +static int bsde_parse_object(int argc, char *argv[], struct mac_bsdextended_object *object, size_t buflen, char *errstr) { int not_seen, flags; int current, neg, nextnot; + int type; uid_t uid_min, uid_max; gid_t gid_min, gid_max; - int type; struct fsid fsid; size_t len; @@ -797,6 +797,7 @@ bsde_parse_object(int argc, char *argv[], flags = 0; neg = 0; nextnot = 0; + type = 0; if (strcmp("not", argv[current]) == 0) { not_seen = 1; @@ -1101,7 +1102,7 @@ bsde_get_mib(const char *string, int *name, size_t *namelen) return (0); } -int +static int bsde_check_version(size_t buflen, char *errstr) { size_t len; diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index e8f9314..8d42e59 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -1008,7 +1008,6 @@ libusb10_isoc_proxy(struct libusb20_transfer *pxfer) uint16_t iso_packets; uint16_t i; uint8_t status; - uint8_t flags; status = libusb20_tr_get_status(pxfer); sxfer = libusb20_tr_get_priv_sc1(pxfer); @@ -1016,7 +1015,7 @@ libusb10_isoc_proxy(struct libusb20_transfer *pxfer) iso_packets = libusb20_tr_get_max_frames(pxfer); if (sxfer == NULL) - return; /* cancelled - nothing to do */ + return; /* cancelled - nothing to do */ uxfer = (struct libusb_transfer *)( ((uint8_t *)sxfer) + sizeof(*sxfer)); @@ -1025,16 +1024,13 @@ libusb10_isoc_proxy(struct libusb20_transfer *pxfer) iso_packets = uxfer->num_iso_packets; if (iso_packets == 0) - return; /* nothing to do */ + return; /* nothing to do */ /* make sure that the number of ISOCHRONOUS packets is valid */ uxfer->num_iso_packets = iso_packets; - flags = uxfer->flags; - switch (status) { case LIBUSB20_TRANSFER_COMPLETED: - /* update actual length */ uxfer->actual_length = actlen; for (i = 0; i != iso_packets; i++) { @@ -1043,9 +1039,7 @@ libusb10_isoc_proxy(struct libusb20_transfer *pxfer) } libusb10_complete_transfer(pxfer, sxfer, LIBUSB_TRANSFER_COMPLETED); break; - case LIBUSB20_TRANSFER_START: - /* setup length(s) */ actlen = 0; for (i = 0; i != iso_packets; i++) { @@ -1064,7 +1058,6 @@ libusb10_isoc_proxy(struct libusb20_transfer *pxfer) /* fork another USB transfer, if any */ libusb10_submit_transfer_sub(libusb20_tr_get_priv_sc0(pxfer), uxfer->endpoint); break; - default: libusb10_complete_transfer(pxfer, sxfer, libusb10_convert_error(status)); break; diff --git a/lib/libusb/libusb20_desc.c b/lib/libusb/libusb20_desc.c index 22077b6..c5cfc9d 100644 --- a/lib/libusb/libusb20_desc.c +++ b/lib/libusb/libusb20_desc.c @@ -517,9 +517,7 @@ libusb20_me_encode(void *ptr, uint16_t len, const void *pd) * room for the * complete structure: */ - uint16_t dummy; - - dummy = libusb20_me_encode(buf, + (void) libusb20_me_encode(buf, 0xFFFF - 3, ps->ptr); } else { bcopy(src_ptr, buf, src_len); @@ -673,7 +671,6 @@ libusb20_me_decode(const void *ptr, uint16_t len, void *pd) ~(LIBUSB20_ME_STRUCT_ALIGN - 1)); /* align */ while (pd_count--) { uint16_t temp; - uint16_t dummy; struct libusb20_me_struct *ps; ps = LIBUSB20_ADD_BYTES(pd, pd_offset); @@ -763,7 +760,7 @@ libusb20_me_decode(const void *ptr, uint16_t len, void *pd) * Recursivly decode * the next structure */ - dummy = libusb20_me_decode(buf, + (void) libusb20_me_decode(buf, temp, ps->ptr); } else { /* update type */ diff --git a/lib/libutil/gr_util.c b/lib/libutil/gr_util.c index b0b0b36f..93b3eb2 100644 --- a/lib/libutil/gr_util.c +++ b/lib/libutil/gr_util.c @@ -141,7 +141,7 @@ gr_tmp(int mfd) errno = ENAMETOOLONG; return (-1); } - if ((tfd = mkstemp(tempname)) == -1) + if ((tfd = mkostemp(tempname, O_SYNC)) == -1) return (-1); if (mfd != -1) { while ((nr = read(mfd, buf, sizeof(buf))) > 0) @@ -318,10 +318,28 @@ gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr) int gr_mkdb(void) { + int fd; + if (chmod(tempname, 0644) != 0) return (-1); - return (rename(tempname, group_file)); + if (rename(tempname, group_file) != 0) + return (-1); + + /* + * Make sure new group file is safe on disk. To improve performance we + * will call fsync() to the directory where file lies + */ + if ((fd = open(group_dir, O_RDONLY|O_DIRECTORY)) == -1) + return (-1); + + if (fsync(fd) != 0) { + close(fd); + return (-1); + } + + close(fd); + return(0); } /* diff --git a/lib/libutil/pw_util.3 b/lib/libutil/pw_util.3 index 706368f..901135e 100644 --- a/lib/libutil/pw_util.3 +++ b/lib/libutil/pw_util.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 06, 2015 +.Dd July 02, 2015 .Dt PW_UTIL 3 .Os .Sh NAME @@ -233,7 +233,8 @@ function returns 0 in case of success and -1 in case of failure. The .Fn pw_lock function locks the master password file. -It returns 0 in case of success and -1 in case of failure. +It returns a file descriptor to the master password file on success +and -1 on failure. .Pp The .Fn pw_scan diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c index befd1fb..af749d5 100644 --- a/lib/libutil/pw_util.c +++ b/lib/libutil/pw_util.c @@ -226,7 +226,7 @@ pw_tmp(int mfd) errno = ENAMETOOLONG; return (-1); } - if ((tfd = mkstemp(tempname)) == -1) + if ((tfd = mkostemp(tempname, O_SYNC)) == -1) return (-1); if (mfd != -1) { while ((nr = read(mfd, buf, sizeof(buf))) > 0) diff --git a/lib/libvmmapi/Makefile.depend b/lib/libvmmapi/Makefile.depend index a5c14b5..e294271 100644 --- a/lib/libvmmapi/Makefile.depend +++ b/lib/libvmmapi/Makefile.depend @@ -1,8 +1,6 @@ # $FreeBSD$ # Autogenerated - do NOT edit! -DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,} - DIRDEPS = \ gnu/lib/csu \ gnu/lib/libgcc \ diff --git a/lib/msun/arm/Makefile.inc b/lib/msun/arm/Makefile.inc index 09f08d8..e86997c 100644 --- a/lib/msun/arm/Makefile.inc +++ b/lib/msun/arm/Makefile.inc @@ -7,6 +7,6 @@ SYM_MAPS += ${.CURDIR}/arm/Symbol.map ARCH_SRCS = fenv-softfp.c fenv-vfp.c .endif -CFLAGS.fenv-vfp.c= -mfloat-abi=softfp +CFLAGS.fenv-vfp.c= -mfpu=vfp -mfloat-abi=softfp CFLAGS+= ${CFLAGS.${.IMPSRC:T}} |