From owner-svn-src-head@FreeBSD.ORG Thu Jan 30 18:04:41 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 109F7F51; Thu, 30 Jan 2014 18:04:41 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id F00C415B9; Thu, 30 Jan 2014 18:04:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0UI4eY9062632; Thu, 30 Jan 2014 18:04:40 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0UI4dI0062625; Thu, 30 Jan 2014 18:04:39 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201401301804.s0UI4dI0062625@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 30 Jan 2014 18:04:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261290 - in head: lib/libc/gen lib/libc/sys sys/compat/freebsd32 sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jan 2014 18:04:41 -0000 Author: kib Date: Thu Jan 30 18:04:39 2014 New Revision: 261290 URL: http://svnweb.freebsd.org/changeset/base/261290 Log: The posix_madvise(3) and posix_fadvise(2) should return error on failure, same as posix_fallocate(2). Noted by: Bob Bishop Discussed with: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/lib/libc/gen/pmadvise.c head/lib/libc/sys/madvise.2 head/lib/libc/sys/posix_fadvise.2 head/lib/libc/sys/posix_fallocate.2 head/sys/compat/freebsd32/freebsd32_misc.c head/sys/kern/vfs_syscalls.c Modified: head/lib/libc/gen/pmadvise.c ============================================================================== --- head/lib/libc/gen/pmadvise.c Thu Jan 30 11:35:19 2014 (r261289) +++ head/lib/libc/gen/pmadvise.c Thu Jan 30 18:04:39 2014 (r261290) @@ -8,9 +8,19 @@ __FBSDID("$FreeBSD$"); #include +#include int posix_madvise(void *address, size_t size, int how) { - return madvise(address, size, how); + int ret, saved_errno; + + saved_errno = errno; + if (madvise(address, size, how) == -1) { + ret = errno; + errno = saved_errno; + } else { + ret = 0; + } + return (ret); } Modified: head/lib/libc/sys/madvise.2 ============================================================================== --- head/lib/libc/sys/madvise.2 Thu Jan 30 11:35:19 2014 (r261289) +++ head/lib/libc/sys/madvise.2 Thu Jan 30 18:04:39 2014 (r261290) @@ -28,7 +28,7 @@ .\" @(#)madvise.2 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd July 19, 1996 +.Dd January 30, 2014 .Dt MADVISE 2 .Os .Sh NAME @@ -50,7 +50,10 @@ allows a process that has knowledge of i to describe it to the system. The .Fn posix_madvise -interface is identical and is provided for standards conformance. +interface is identical, except it returns an error number on error and does +not modify +.Va errno , +and is provided for standards conformance. .Pp The known behaviors are: .Bl -tag -width MADV_SEQUENTIAL Modified: head/lib/libc/sys/posix_fadvise.2 ============================================================================== --- head/lib/libc/sys/posix_fadvise.2 Thu Jan 30 11:35:19 2014 (r261289) +++ head/lib/libc/sys/posix_fadvise.2 Thu Jan 30 18:04:39 2014 (r261290) @@ -28,7 +28,7 @@ .\" @(#)madvise.2 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd June 19, 2012 +.Dd January 30, 2014 .Dt POSIX_FADVISE 2 .Os .Sh NAME @@ -93,7 +93,7 @@ Future access to this data may require a .Sh ERRORS The .Fn posix_fadvise -system call will fail if: +system call returns zero on success, and an error on failure: .Bl -tag -width Er .It Bq Er EBADF The Modified: head/lib/libc/sys/posix_fallocate.2 ============================================================================== --- head/lib/libc/sys/posix_fallocate.2 Thu Jan 30 11:35:19 2014 (r261289) +++ head/lib/libc/sys/posix_fallocate.2 Thu Jan 30 18:04:39 2014 (r261290) @@ -83,9 +83,8 @@ that reduces the file size to a size sma If successful, .Fn posix_fallocate returns zero. -It returns error number on failure, without setting -.Va errno -variable. +It returns an error on failure, without setting +.Va errno . .Sh ERRORS Possible failure conditions: .Bl -tag -width Er Modified: head/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_misc.c Thu Jan 30 11:35:19 2014 (r261289) +++ head/sys/compat/freebsd32/freebsd32_misc.c Thu Jan 30 18:04:39 2014 (r261290) @@ -3005,8 +3005,10 @@ freebsd32_posix_fadvise(struct thread *t struct freebsd32_posix_fadvise_args *uap) { - return (kern_posix_fadvise(td, uap->fd, PAIR32TO64(off_t, uap->offset), - PAIR32TO64(off_t, uap->len), uap->advice)); + td->td_retval[0] = kern_posix_fadvise(td, uap->fd, + PAIR32TO64(off_t, uap->offset), PAIR32TO64(off_t, uap->len), + uap->advice); + return (0); } int Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Thu Jan 30 11:35:19 2014 (r261289) +++ head/sys/kern/vfs_syscalls.c Thu Jan 30 18:04:39 2014 (r261290) @@ -4725,6 +4725,7 @@ int sys_posix_fadvise(struct thread *td, struct posix_fadvise_args *uap) { - return (kern_posix_fadvise(td, uap->fd, uap->offset, uap->len, - uap->advice)); + td->td_retval[0] = kern_posix_fadvise(td, uap->fd, uap->offset, + uap->len, uap->advice); + return (0); }