xref: /illumos-gate/usr/src/lib/libc/port/sys/open.c (revision 533affcbc7fc4d0c8132976ea454aaa715fe2307)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
27  */
28 
29 /*	Copyright (c) 1988 AT&T	*/
30 /*	  All Rights Reserved	*/
31 
32 #include "lint.h"
33 #include <limits.h>
34 #include <stdarg.h>
35 #include <unistd.h>
36 #include <sys/fcntl.h>
37 #include <sys/syscall.h>
38 #include "libc.h"
39 
40 int
41 __openat(int dfd, const char *path, int oflag, mode_t mode)
42 {
43 	return (syscall(SYS_openat, dfd, path, oflag, mode));
44 }
45 
46 int
47 __open(const char *path, int oflag, mode_t mode)
48 {
49 #if defined(_RETAIN_OLD_SYSCALLS)
50 	return (syscall(SYS_open, path, oflag, mode));
51 #else
52 	return (__openat(AT_FDCWD, path, oflag, mode));
53 #endif
54 }
55 
56 #if !defined(_LP64)
57 
58 int
59 __openat64(int dfd, const char *path, int oflag, mode_t mode)
60 {
61 	return (syscall(SYS_openat64, dfd, path, oflag, mode));
62 }
63 
64 int
65 __open64(const char *path, int oflag, mode_t mode)
66 {
67 #if defined(_RETAIN_OLD_SYSCALLS)
68 	return (syscall(SYS_open64, path, oflag, mode));
69 #else
70 	return (__openat64(AT_FDCWD, path, oflag, mode));
71 #endif
72 }
73 
74 #endif	/* !_LP64 */
75