1 /* Checking macros for unistd functions.
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
20 # error "Never include <bits/unistd.h> directly; use <unistd.h> instead."
23 # include <bits/unistd-decl.h>
25 __fortify_function __wur ssize_t
26 read (int __fd
, void *__buf
, size_t __nbytes
)
28 return __glibc_fortify (read
, __nbytes
, sizeof (char),
29 __glibc_objsize0 (__buf
),
30 __fd
, __buf
, __nbytes
);
33 #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
34 # ifndef __USE_FILE_OFFSET64
35 __fortify_function __wur ssize_t
36 pread (int __fd
, void *__buf
, size_t __nbytes
, __off_t __offset
)
38 return __glibc_fortify (pread
, __nbytes
, sizeof (char),
39 __glibc_objsize0 (__buf
),
40 __fd
, __buf
, __nbytes
, __offset
);
43 __fortify_function __wur ssize_t
44 pread (int __fd
, void *__buf
, size_t __nbytes
, __off64_t __offset
)
46 return __glibc_fortify (pread64
, __nbytes
, sizeof (char),
47 __glibc_objsize0 (__buf
),
48 __fd
, __buf
, __nbytes
, __offset
);
52 # ifdef __USE_LARGEFILE64
53 __fortify_function __wur ssize_t
54 pread64 (int __fd
, void *__buf
, size_t __nbytes
, __off64_t __offset
)
56 return __glibc_fortify (pread64
, __nbytes
, sizeof (char),
57 __glibc_objsize0 (__buf
),
58 __fd
, __buf
, __nbytes
, __offset
);
63 #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
64 __fortify_function
__nonnull ((1, 2)) __wur ssize_t
65 __NTH (readlink (const char *__restrict __path
, char *__restrict __buf
,
68 return __glibc_fortify (readlink
, __len
, sizeof (char),
69 __glibc_objsize (__buf
),
70 __path
, __buf
, __len
);
75 __fortify_function
__nonnull ((2, 3)) __wur ssize_t
76 __NTH (readlinkat (int __fd
, const char *__restrict __path
,
77 char *__restrict __buf
, size_t __len
))
79 return __glibc_fortify (readlinkat
, __len
, sizeof (char),
80 __glibc_objsize (__buf
),
81 __fd
, __path
, __buf
, __len
);
85 __fortify_function __wur
char *
86 __NTH (getcwd (char *__buf
, size_t __size
))
88 return __glibc_fortify (getcwd
, __size
, sizeof (char),
89 __glibc_objsize (__buf
),
93 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
94 __fortify_function
__nonnull ((1)) __attribute_deprecated__ __wur
char *
95 __NTH (getwd (char *__buf
))
97 if (__glibc_objsize (__buf
) != (size_t) -1)
98 return __getwd_chk (__buf
, __glibc_objsize (__buf
));
99 return __getwd_warn (__buf
);
103 __fortify_function
size_t
104 __NTH (confstr (int __name
, char *__buf
, size_t __len
))
106 return __glibc_fortify (confstr
, __len
, sizeof (char),
107 __glibc_objsize (__buf
),
108 __name
, __buf
, __len
);
112 __fortify_function
int
113 __NTH (getgroups (int __size
, __gid_t __list
[]))
115 return __glibc_fortify (getgroups
, __size
, sizeof (__gid_t
),
116 __glibc_objsize (__list
),
121 __fortify_function
int
122 __NTH (ttyname_r (int __fd
, char *__buf
, size_t __buflen
))
124 return __glibc_fortify (ttyname_r
, __buflen
, sizeof (char),
125 __glibc_objsize (__buf
),
126 __fd
, __buf
, __buflen
);
130 #ifdef __USE_POSIX199506
131 __fortify_function
int
132 getlogin_r (char *__buf
, size_t __buflen
)
134 return __glibc_fortify (getlogin_r
, __buflen
, sizeof (char),
135 __glibc_objsize (__buf
),
141 #if defined __USE_MISC || defined __USE_UNIX98
142 __fortify_function
int
143 __NTH (gethostname (char *__buf
, size_t __buflen
))
145 return __glibc_fortify (gethostname
, __buflen
, sizeof (char),
146 __glibc_objsize (__buf
),
152 #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_UNIX98)
153 __fortify_function
int
154 __NTH (getdomainname (char *__buf
, size_t __buflen
))
156 return __glibc_fortify (getdomainname
, __buflen
, sizeof (char),
157 __glibc_objsize (__buf
),