Module Name: src Committed By: snj Date: Sun Feb 8 22:05:55 UTC 2015
Modified Files: src/lib/libc/include [netbsd-7]: namespace.h src/lib/libc/sys [netbsd-7]: Makefile.inc fdiscard.2 Added Files: src/lib/libc/sys [netbsd-7]: fdiscard.c posix_fallocate.c Log Message: Pull up following revision(s) (requested by christos in ticket #472): lib/libc/include/namespace.h: revision 1.175 lib/libc/sys/Makefile.inc: revision 1.225, 1.227 lib/libc/sys/fdiscard.2: revision 1.3 lib/libc/sys/fdiscard.c: revision 1.1 lib/libc/sys/posix_fallocate.c: revision 1.1 Fix argument paddiing for posix_fallocate and fdiscard with gcc 1.x -- PR/49617: Kirk Russell: posix_fallocate() should be returning an error on failure, without setting errno, so make it PSEUDO_NOERROR, by adding a new category GLUENOERR. -- PR/49617: Kirk Russell: Describe the posix_fallocate return values correctly. To generate a diff of this commit: cvs rdiff -u -r1.174 -r1.174.2.1 src/lib/libc/include/namespace.h cvs rdiff -u -r1.224 -r1.224.2.1 src/lib/libc/sys/Makefile.inc cvs rdiff -u -r1.2 -r1.2.4.1 src/lib/libc/sys/fdiscard.2 cvs rdiff -u -r0 -r1.1.2.2 src/lib/libc/sys/fdiscard.c \ src/lib/libc/sys/posix_fallocate.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/include/namespace.h diff -u src/lib/libc/include/namespace.h:1.174 src/lib/libc/include/namespace.h:1.174.2.1 --- src/lib/libc/include/namespace.h:1.174 Fri Jun 13 15:45:05 2014 +++ src/lib/libc/include/namespace.h Sun Feb 8 22:05:55 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: namespace.h,v 1.174 2014/06/13 15:45:05 joerg Exp $ */ +/* $NetBSD: namespace.h,v 1.174.2.1 2015/02/08 22:05:55 snj Exp $ */ /*- * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. @@ -281,6 +281,7 @@ #define execv _execv #define execvp _execvp #define explicit_memset _explicit_memset +#define fdiscard _fdiscard #define fdopen _fdopen #define fgetln _fgetln #define fgetwln _fgetwln @@ -520,6 +521,7 @@ #define pread _pread #define printf_l _printf_l #define pselect _pselect +#define posix_fallocate _posix_fallocate #define psignal _psignal #define pthread_atfork _pthread_atfork #define ptree_init ptree_init Index: src/lib/libc/sys/Makefile.inc diff -u src/lib/libc/sys/Makefile.inc:1.224 src/lib/libc/sys/Makefile.inc:1.224.2.1 --- src/lib/libc/sys/Makefile.inc:1.224 Fri Jul 25 08:30:47 2014 +++ src/lib/libc/sys/Makefile.inc Sun Feb 8 22:05:55 2015 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.224 2014/07/25 08:30:47 dholland Exp $ +# $NetBSD: Makefile.inc,v 1.224.2.1 2015/02/08 22:05:55 snj Exp $ # @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 # sys sources @@ -30,9 +30,10 @@ SRCS+= posix_fadvise.c posix_madvise.c s # glue to provide compatibility between GCC 1.X and 2.X and for compat # with old syscall interfaces. -GLUE+= ftruncate.c lseek.c mmap.c pread.c preadv.c pwrite.c \ - pwritev.c truncate.c ntp_adjtime.c mknodat.c - +GLUE+= fdiscard.c ftruncate.c lseek.c mmap.c \ + pread.c preadv.c pwrite.c pwritev.c truncate.c ntp_adjtime.c \ + mknodat.c +GLUENOERR+= posix_fallocate.c GLUE50+= adjtime.c clock_settime.c settimeofday.c # 'glue' files might .c or .S depending on the architecture @@ -53,6 +54,23 @@ ASM_GLUE+= tmp_${glue:.c=.S} .endfor # 'glue' files might .c or .S depending on the architecture +.for glue in ${GLUENOERR} +. if exists(${glue:.c=.S}) +# Build the ASM glue file +SRCS+=${glue:.c=.S} +. else +. if exists(__${glue:.c=.S}) +SRCS+=__${glue:.c=.S} ${glue} +. else +# Build the C glue file +SRCS+= ${glue} +# and an asm entry for __<syscall> +ASM_GLUENOERR+= tmp_${glue:.c=.S} +. endif +. endif +.endfor + +# 'glue' files might .c or .S depending on the architecture .for glue in ${GLUE50} . if exists(${glue:.c=.S}) # Build the ASM glue file @@ -147,11 +165,11 @@ ASM_MD= _lwp_getprivate.S mremap.S .endfor WEAKASM= accept.S __aio_suspend50.S close.S connect.S execve.S \ - fcntl.S fdatasync.S fdiscard.S fsync.S \ + fcntl.S fdatasync.S fsync.S \ fsync_range.S __kevent50.S \ kill.S mq_receive.S mq_send.S __mq_timedreceive50.S __mq_timedsend50.S \ msgrcv.S msgsnd.S __msync13.S __nanosleep50.S open.S poll.S \ - __pollts50.S posix_fallocate.S __pselect50.S read.S readlink.S \ + __pollts50.S __pselect50.S read.S readlink.S \ readv.S _sched_setparam.S _sched_getparam.S _sched_setaffinity.S \ _sched_getaffinity.S sched_yield.S \ __select50.S setcontext.S __sigprocmask14.S __sigsuspend14.S sysarch.S \ @@ -162,8 +180,11 @@ NOERR= getegid.S geteuid.S getgid.S getp PSEUDONOERR= _exit.S -SRCS+= ${ASM} ${WEAKASM} ${NOERR} ${PSEUDONOERR} ${ASM_GLUE} -CLEANFILES+= ${ASM} ${WEAKASM} ${NOERR} ${PSEUDONOERR} ${ASM_GLUE} +_GENFILES= ${ASM} ${WEAKASM} ${NOERR} ${PSEUDONOERR} \ + ${ASM_GLUE} ${ASM_GLUENOERR} + +SRCS+= ${_GENFILES} +CLEANFILES+= ${_GENFILES} ASMDEPS= ${.CURDIR}/sys/Makefile.inc ${ARCHDIR}/SYS.h \ ${DESTDIR}/usr/include/sys/syscall.h @@ -178,6 +199,10 @@ ${ASM_GLUE}: ${ASMDEPS} ${_MKTARGET_CREATE} printf '#include "SYS.h"\nPSEUDO(${.PREFIX:S/tmp_/__/},${.PREFIX:S/tmp_//})\n' >${.TARGET} +${ASM_GLUENOERR}: ${ASMDEPS} + ${_MKTARGET_CREATE} + printf '#include "SYS.h"\nPSEUDO_NOERROR(${.PREFIX:S/tmp_/__/},${.PREFIX:S/tmp_//})\n' >${.TARGET} + ${WEAKASM}: ${ASMDEPS} ${_MKTARGET_CREATE} printf '#include "SYS.h"\nWSYSCALL(${.PREFIX},_sys_${.PREFIX})\nWEAK_ALIAS(_${.PREFIX},_sys_${.PREFIX})\n' >${.TARGET} Index: src/lib/libc/sys/fdiscard.2 diff -u src/lib/libc/sys/fdiscard.2:1.2 src/lib/libc/sys/fdiscard.2:1.2.4.1 --- src/lib/libc/sys/fdiscard.2:1.2 Fri Jul 25 08:47:42 2014 +++ src/lib/libc/sys/fdiscard.2 Sun Feb 8 22:05:55 2015 @@ -1,4 +1,4 @@ -.\" $NetBSD: fdiscard.2,v 1.2 2014/07/25 08:47:42 wiz Exp $ +.\" $NetBSD: fdiscard.2,v 1.2.4.1 2015/02/08 22:05:55 snj Exp $ .\" .\" Copyright (c) 2014 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd July 25, 2014 +.Dd February 1, 2015 .Dt FDISCARD 2 .Os .Sh NAME @@ -127,8 +127,16 @@ by may not be persistent after a crash or reboot if the space reserved has not yet been written to. .Sh RETURN VALUES -On success these calls return 0. -On error, \-1 is returned, and the global variable +If successful, the +.Fn posix_fallocate +function will return zero. +Otherwise an error number will be returned, without setting +.Va errno . +.Pp +If successful, the +.Fn fdiscard +function will return zero. +Otherwise the value \-1 is returned and the global variable .Va errno is set to indicate the error. .Sh ERRORS Added files: Index: src/lib/libc/sys/fdiscard.c diff -u /dev/null src/lib/libc/sys/fdiscard.c:1.1.2.2 --- /dev/null Sun Feb 8 22:05:55 2015 +++ src/lib/libc/sys/fdiscard.c Sun Feb 8 22:05:55 2015 @@ -0,0 +1,52 @@ +/* $NetBSD: fdiscard.c,v 1.1.2.2 2015/02/08 22:05:55 snj Exp $ */ + +/* + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Emmanuel Dreyfus. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD: fdiscard.c,v 1.1.2.2 2015/02/08 22:05:55 snj Exp $"); +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <sys/syscall.h> +#include <unistd.h> + +int __fdiscard(int, int, off_t, off_t); + +/* + * 64-bit offset padding required for gcc 1.x + */ +int +fdiscard(int fd, off_t off, off_t len) +{ + return __fdiscard(fd, 0, off, len); +} Index: src/lib/libc/sys/posix_fallocate.c diff -u /dev/null src/lib/libc/sys/posix_fallocate.c:1.1.2.2 --- /dev/null Sun Feb 8 22:05:55 2015 +++ src/lib/libc/sys/posix_fallocate.c Sun Feb 8 22:05:55 2015 @@ -0,0 +1,52 @@ +/* $NetBSD: posix_fallocate.c,v 1.1.2.2 2015/02/08 22:05:55 snj Exp $ */ + +/* + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Emmanuel Dreyfus. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD: posix_fallocate.c,v 1.1.2.2 2015/02/08 22:05:55 snj Exp $"); +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <sys/syscall.h> +#include <unistd.h> + +int __posix_fallocate(int, int, off_t, off_t); + +/* + * 64-bit offset padding required for gcc 1.x + */ +int +posix_fallocate(int fd, off_t off, off_t len) +{ + return __posix_fallocate(fd, 0, off, len); +}