xref: /freebsd/lib/libc/sys/fcntl.c (revision 7dd9070e4425a1c2e2418694fd632425a283d558)
1d7847a8dSBrooks Davis /*-
2d7847a8dSBrooks Davis  * SPDX-License-Identifier: BSD-2-Clause
3d7847a8dSBrooks Davis  *
4d7847a8dSBrooks Davis  * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
5d7847a8dSBrooks Davis  * Authors: Doug Rabson <dfr@rabson.org>
6d7847a8dSBrooks Davis  * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
7d7847a8dSBrooks Davis  *
8d7847a8dSBrooks Davis  * Copyright (c) 2014-2015 The FreeBSD Foundation.
9d7847a8dSBrooks Davis  *
10d7847a8dSBrooks Davis  * Portions of this software were developed by Konstantin Belousov
11d7847a8dSBrooks Davis  * under sponsorship from the FreeBSD Foundation.
12d7847a8dSBrooks Davis  *
13d7847a8dSBrooks Davis  * Redistribution and use in source and binary forms, with or without
14d7847a8dSBrooks Davis  * modification, are permitted provided that the following conditions
15d7847a8dSBrooks Davis  * are met:
16d7847a8dSBrooks Davis  * 1. Redistributions of source code must retain the above copyright
17d7847a8dSBrooks Davis  *    notice, this list of conditions and the following disclaimer.
18d7847a8dSBrooks Davis  * 2. Redistributions in binary form must reproduce the above copyright
19d7847a8dSBrooks Davis  *    notice, this list of conditions and the following disclaimer in the
20d7847a8dSBrooks Davis  *    documentation and/or other materials provided with the distribution.
21d7847a8dSBrooks Davis  *
22d7847a8dSBrooks Davis  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23d7847a8dSBrooks Davis  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24d7847a8dSBrooks Davis  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25d7847a8dSBrooks Davis  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26d7847a8dSBrooks Davis  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27d7847a8dSBrooks Davis  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28d7847a8dSBrooks Davis  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29d7847a8dSBrooks Davis  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30d7847a8dSBrooks Davis  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31d7847a8dSBrooks Davis  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32d7847a8dSBrooks Davis  * SUCH DAMAGE.
33d7847a8dSBrooks Davis  */
34d7847a8dSBrooks Davis 
35d7847a8dSBrooks Davis #include <fcntl.h>
36d7847a8dSBrooks Davis #include <stdarg.h>
37d7847a8dSBrooks Davis #include <sys/types.h>
38d7847a8dSBrooks Davis #include <sys/syscall.h>
39d7847a8dSBrooks Davis #include "libc_private.h"
40d7847a8dSBrooks Davis 
41d7847a8dSBrooks Davis #pragma weak fcntl
42d7847a8dSBrooks Davis int
43d7847a8dSBrooks Davis fcntl(int fd, int cmd, ...)
44d7847a8dSBrooks Davis {
45d7847a8dSBrooks Davis 	va_list args;
46d7847a8dSBrooks Davis 	long arg;
47d7847a8dSBrooks Davis 
48d7847a8dSBrooks Davis 	va_start(args, cmd);
49d7847a8dSBrooks Davis 	arg = va_arg(args, long);
50d7847a8dSBrooks Davis 	va_end(args);
51d7847a8dSBrooks Davis 
52*7dd9070eSBrooks Davis 	return (INTERPOS_SYS(fcntl, fd, cmd, arg));
53d7847a8dSBrooks Davis }
54