diff options
author | kib <kib@FreeBSD.org> | 2015-04-18 21:50:13 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2015-04-18 21:50:13 +0000 |
commit | 2254748ed0eebd8391a1bc331f3d54d0ddb1f69d (patch) | |
tree | 5939add2a0816746476989dd37677ad0fb0428ac /lib/libc/sys | |
parent | 2b1ec4f62f3bd13a47fea3a9c366c9a7a0ac35e0 (diff) | |
download | FreeBSD-src-2254748ed0eebd8391a1bc331f3d54d0ddb1f69d.zip FreeBSD-src-2254748ed0eebd8391a1bc331f3d54d0ddb1f69d.tar.gz |
The lseek(2), mmap(2), truncate(2), ftruncate(2), pread(2), and
pwrite(2) syscalls are wrapped to provide compatibility with pre-7.x
kernels which required padding before the off_t parameter. The
fcntl(2) contains compatibility code to handle kernels before the
struct flock was changed during the 8.x CURRENT development. The
shims were reasonable to allow easier revert to the older kernel at
that time.
Now, two or three major releases later, shims do not serve any
purpose. Such old kernels cannot handle current libc, so revert the
compatibility code.
Make padded syscalls support conditional under the COMPAT6 config
option. For COMPAT32, the syscalls were under COMPAT6 already.
Remove WITHOUT_SYSCALL_COMPAT build option, which only purpose was to
(partially) disable the removed shims.
Reviewed by: jhb, imp (previous versions)
Discussed with: peter
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Diffstat (limited to 'lib/libc/sys')
-rw-r--r-- | lib/libc/sys/Makefile.inc | 12 | ||||
-rw-r--r-- | lib/libc/sys/fcntl.c | 62 | ||||
-rw-r--r-- | lib/libc/sys/ftruncate.c | 55 | ||||
-rw-r--r-- | lib/libc/sys/interposing_table.c | 2 | ||||
-rw-r--r-- | lib/libc/sys/lseek.c | 56 | ||||
-rw-r--r-- | lib/libc/sys/mmap.c | 56 | ||||
-rw-r--r-- | lib/libc/sys/pread.c | 57 | ||||
-rw-r--r-- | lib/libc/sys/pwrite.c | 56 | ||||
-rw-r--r-- | lib/libc/sys/truncate.c | 55 |
9 files changed, 7 insertions, 404 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index a38a923..5162563 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -26,18 +26,6 @@ SRCS+= \ __error.c \ interposing_table.c -.if ${MK_SYSCALL_COMPAT} != "no" -SYSCALL_COMPAT_SRCS= \ - ftruncate.c \ - lseek.c \ - mmap.c \ - pread.c \ - pwrite.c \ - truncate.c -SRCS+= ${SYSCALL_COMPAT_SRCS} -NOASM+= ${SYSCALL_COMPAT_SRCS:S/.c/.o/} -.endif - SRCS+= futimens.c utimensat.c NOASM+= futimens.o utimensat.o PSEUDO+= _futimens.o _utimensat.o diff --git a/lib/libc/sys/fcntl.c b/lib/libc/sys/fcntl.c index 7af617e..e85574a 100644 --- a/lib/libc/sys/fcntl.c +++ b/lib/libc/sys/fcntl.c @@ -3,6 +3,12 @@ * Authors: Doug Rabson <dfr@rabson.org> * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org> * + * Copyright (c) 2014-2015 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * 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: @@ -48,59 +54,3 @@ fcntl(int fd, int cmd, ...) return (((int (*)(int, int, ...)) __libc_interposing[INTERPOS_fcntl])(fd, cmd, arg)); } - -#ifdef SYSCALL_COMPAT -__weak_reference(__fcntl_compat, __fcntl); - -int -__fcntl_compat(int fd, int cmd, ...) -{ - va_list args; - long arg; - struct __oflock ofl; - struct flock *flp; - int res; - - va_start(args, cmd); - arg = va_arg(args, long); - va_end(args); - - if (__getosreldate() >= 800028) { - return (__sys_fcntl(fd, cmd, arg)); - } else { - if (cmd == F_GETLK || cmd == F_SETLK || cmd == F_SETLKW) { - /* - * Convert new-style struct flock (which - * includes l_sysid) to old-style. - */ - flp = (struct flock *) (uintptr_t) arg; - ofl.l_start = flp->l_start; - ofl.l_len = flp->l_len; - ofl.l_pid = flp->l_pid; - ofl.l_type = flp->l_type; - ofl.l_whence = flp->l_whence; - - switch (cmd) { - case F_GETLK: - res = __sys_fcntl(fd, F_OGETLK, &ofl); - if (res >= 0) { - flp->l_start = ofl.l_start; - flp->l_len = ofl.l_len; - flp->l_pid = ofl.l_pid; - flp->l_type = ofl.l_type; - flp->l_whence = ofl.l_whence; - flp->l_sysid = 0; - } - return (res); - - case F_SETLK: - return (__sys_fcntl(fd, F_OSETLK, &ofl)); - - case F_SETLKW: - return (__sys_fcntl(fd, F_OSETLKW, &ofl)); - } - } - return (__sys_fcntl(fd, cmd, arg)); - } -} -#endif diff --git a/lib/libc/sys/ftruncate.c b/lib/libc/sys/ftruncate.c deleted file mode 100644 index 78b5a36..0000000 --- a/lib/libc/sys/ftruncate.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ftruncate.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -int -ftruncate(fd, length) - int fd; - off_t length; -{ - - if (__getosreldate() >= 700051) - return(__sys_ftruncate(fd, length)); - else - return(__sys_freebsd6_ftruncate(fd, 0, length)); -} diff --git a/lib/libc/sys/interposing_table.c b/lib/libc/sys/interposing_table.c index c4d1429..08dfbb1 100644 --- a/lib/libc/sys/interposing_table.c +++ b/lib/libc/sys/interposing_table.c @@ -44,7 +44,7 @@ interpos_func_t __libc_interposing[INTERPOS_MAX] = { SLOT(aio_suspend, __sys_aio_suspend), SLOT(close, __sys_close), SLOT(connect, __sys_connect), - SLOT(fcntl, __fcntl_compat), + SLOT(fcntl, __sys_fcntl), SLOT(fsync, __sys_fsync), SLOT(fork, __sys_fork), SLOT(msync, __sys_msync), diff --git a/lib/libc/sys/lseek.c b/lib/libc/sys/lseek.c deleted file mode 100644 index a086be1..0000000 --- a/lib/libc/sys/lseek.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)lseek.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -off_t -lseek(fd, offset, whence) - int fd; - off_t offset; - int whence; -{ - - if (__getosreldate() >= 700051) - return(__sys_lseek(fd, offset, whence)); - else - return(__sys_freebsd6_lseek(fd, 0, offset, whence)); -} diff --git a/lib/libc/sys/mmap.c b/lib/libc/sys/mmap.c deleted file mode 100644 index 0fa03ba..0000000 --- a/lib/libc/sys/mmap.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mmap.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -void * -mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - - if (__getosreldate() >= 700051) { - return (__sys_mmap(addr, len, prot, flags, fd, offset)); - } else { - return (__sys_freebsd6_mmap(addr, len, prot, flags, fd, 0, - offset)); - } -} diff --git a/lib/libc/sys/pread.c b/lib/libc/sys/pread.c deleted file mode 100644 index 7566566..0000000 --- a/lib/libc/sys/pread.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mmap.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -ssize_t -pread(fd, buf, nbyte, offset) - int fd; - void *buf; - size_t nbyte; - off_t offset; -{ - - if (__getosreldate() >= 700051) - return (__sys_pread(fd, buf, nbyte, offset)); - else - return (__sys_freebsd6_pread(fd, buf, nbyte, 0, offset)); -} diff --git a/lib/libc/sys/pwrite.c b/lib/libc/sys/pwrite.c deleted file mode 100644 index d17ed29..0000000 --- a/lib/libc/sys/pwrite.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mmap.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -ssize_t -pwrite(fd, buf, nbyte, offset) - int fd; - const void *buf; - size_t nbyte; - off_t offset; -{ - if (__getosreldate() >= 700051) - return (__sys_pwrite(fd, buf, nbyte, offset)); - else - return (__sys_freebsd6_pwrite(fd, buf, nbyte, 0, offset)); -} diff --git a/lib/libc/sys/truncate.c b/lib/libc/sys/truncate.c deleted file mode 100644 index 375c9d9..0000000 --- a/lib/libc/sys/truncate.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)truncate.c 8.1 (Berkeley) 6/17/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "libc_private.h" - -/* - * This function provides 64-bit offset padding that - * is not supplied by GCC 1.X but is supplied by GCC 2.X. - */ -int -truncate(path, length) - const char *path; - off_t length; -{ - - if (__getosreldate() >= 700051) - return(__sys_truncate(path, length)); - else - return(__sys_freebsd6_truncate(path, 0, length)); -} |