Date: Thu, 6 Feb 2014 19:47:17 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r261560 - in stable/10: lib/libc/gen lib/libc/sys sys/compat/freebsd32 sys/kern Message-ID: <201402061947.s16JlHST095831@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Thu Feb 6 19:47:17 2014 New Revision: 261560 URL: http://svnweb.freebsd.org/changeset/base/261560 Log: MFC r261080: The posix_fallocate(2) syscall should return error number on error, without modifying errno. MFC r261290: The posix_madvise(3) and posix_fadvise(2) should return error on failure, same as posix_fallocate(2). Modified: stable/10/lib/libc/gen/pmadvise.c stable/10/lib/libc/sys/madvise.2 stable/10/lib/libc/sys/posix_fadvise.2 stable/10/lib/libc/sys/posix_fallocate.2 stable/10/sys/compat/freebsd32/freebsd32_misc.c stable/10/sys/kern/vfs_syscalls.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/pmadvise.c ============================================================================== --- stable/10/lib/libc/gen/pmadvise.c Thu Feb 6 18:41:20 2014 (r261559) +++ stable/10/lib/libc/gen/pmadvise.c Thu Feb 6 19:47:17 2014 (r261560) @@ -8,9 +8,19 @@ __FBSDID("$FreeBSD$"); #include <sys/mman.h> +#include <errno.h> int posix_madvise(void *address, size_t size, int how) { - return madvise(address, size, how); + int ret, saved_errno; + + saved_errno = errno; + if (madvise(address, size, how) == -1) { + ret = errno; + errno = saved_errno; + } else { + ret = 0; + } + return (ret); } Modified: stable/10/lib/libc/sys/madvise.2 ============================================================================== --- stable/10/lib/libc/sys/madvise.2 Thu Feb 6 18:41:20 2014 (r261559) +++ stable/10/lib/libc/sys/madvise.2 Thu Feb 6 19:47:17 2014 (r261560) @@ -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: stable/10/lib/libc/sys/posix_fadvise.2 ============================================================================== --- stable/10/lib/libc/sys/posix_fadvise.2 Thu Feb 6 18:41:20 2014 (r261559) +++ stable/10/lib/libc/sys/posix_fadvise.2 Thu Feb 6 19:47:17 2014 (r261560) @@ -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: stable/10/lib/libc/sys/posix_fallocate.2 ============================================================================== --- stable/10/lib/libc/sys/posix_fallocate.2 Thu Feb 6 18:41:20 2014 (r261559) +++ stable/10/lib/libc/sys/posix_fallocate.2 Thu Feb 6 19:47:17 2014 (r261560) @@ -83,9 +83,8 @@ that reduces the file size to a size sma If successful, .Fn posix_fallocate returns zero. -It returns -1 on failure, and sets -.Va errno -to indicate the error. +It returns an error on failure, without setting +.Va errno . .Sh ERRORS Possible failure conditions: .Bl -tag -width Er Modified: stable/10/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/10/sys/compat/freebsd32/freebsd32_misc.c Thu Feb 6 18:41:20 2014 (r261559) +++ stable/10/sys/compat/freebsd32/freebsd32_misc.c Thu Feb 6 19:47:17 2014 (r261560) @@ -2963,8 +2963,9 @@ freebsd32_posix_fallocate(struct thread struct freebsd32_posix_fallocate_args *uap) { - return (kern_posix_fallocate(td, uap->fd, - PAIR32TO64(off_t, uap->offset), PAIR32TO64(off_t, uap->len))); + td->td_retval[0] = kern_posix_fallocate(td, uap->fd, + PAIR32TO64(off_t, uap->offset), PAIR32TO64(off_t, uap->len)); + return (0); } int @@ -2972,8 +2973,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: stable/10/sys/kern/vfs_syscalls.c ============================================================================== --- stable/10/sys/kern/vfs_syscalls.c Thu Feb 6 18:41:20 2014 (r261559) +++ stable/10/sys/kern/vfs_syscalls.c Thu Feb 6 19:47:17 2014 (r261560) @@ -4585,7 +4585,9 @@ int sys_posix_fallocate(struct thread *td, struct posix_fallocate_args *uap) { - return (kern_posix_fallocate(td, uap->fd, uap->offset, uap->len)); + td->td_retval[0] = kern_posix_fallocate(td, uap->fd, uap->offset, + uap->len); + return (0); } /* @@ -4724,6 +4726,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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402061947.s16JlHST095831>