1 /* Checking routines for unistd functions. Declaration only.
2 Copyright (C) 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/>. */
19 #ifndef _BITS_UNISTD_DECL_H
20 #define _BITS_UNISTD_DECL_H 1
23 # error "Never include <bits/unistd-decl.h> directly; use <unistd.h> instead."
26 extern ssize_t
__read_chk (int __fd
, void *__buf
, size_t __nbytes
,
28 __wur
__attr_access ((__write_only__
, 2, 3));
29 extern ssize_t
__REDIRECT_FORTIFY (__read_alias
, (int __fd
, void *__buf
,
30 size_t __nbytes
), read
)
31 __wur
__attr_access ((__write_only__
, 2, 3));
32 extern ssize_t
__REDIRECT (__read_chk_warn
,
33 (int __fd
, void *__buf
, size_t __nbytes
,
34 size_t __buflen
), __read_chk
)
35 __wur
__warnattr ("read called with bigger length than size of "
36 "the destination buffer");
38 #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
39 extern ssize_t
__pread_chk (int __fd
, void *__buf
, size_t __nbytes
,
40 __off_t __offset
, size_t __bufsize
)
41 __wur
__attr_access ((__write_only__
, 2, 3));
42 extern ssize_t
__pread64_chk (int __fd
, void *__buf
, size_t __nbytes
,
43 __off64_t __offset
, size_t __bufsize
)
44 __wur
__attr_access ((__write_only__
, 2, 3));
45 extern ssize_t
__REDIRECT (__pread_alias
,
46 (int __fd
, void *__buf
, size_t __nbytes
,
47 __off_t __offset
), pread
)
48 __wur
__attr_access ((__write_only__
, 2, 3));
49 extern ssize_t
__REDIRECT (__pread64_alias
,
50 (int __fd
, void *__buf
, size_t __nbytes
,
51 __off64_t __offset
), pread64
)
52 __wur
__attr_access ((__write_only__
, 2, 3));
53 extern ssize_t
__REDIRECT (__pread_chk_warn
,
54 (int __fd
, void *__buf
, size_t __nbytes
,
55 __off_t __offset
, size_t __bufsize
), __pread_chk
)
56 __wur
__warnattr ("pread called with bigger length than size of "
57 "the destination buffer");
58 extern ssize_t
__REDIRECT (__pread64_chk_warn
,
59 (int __fd
, void *__buf
, size_t __nbytes
,
60 __off64_t __offset
, size_t __bufsize
),
62 __wur
__warnattr ("pread64 called with bigger length than size of "
63 "the destination buffer");
66 #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
67 extern ssize_t
__readlink_chk (const char *__restrict __path
,
68 char *__restrict __buf
, size_t __len
,
70 __THROW
__nonnull ((1, 2)) __wur
__attr_access ((__write_only__
, 2, 3));
71 extern ssize_t
__REDIRECT_NTH (__readlink_alias
,
72 (const char *__restrict __path
,
73 char *__restrict __buf
, size_t __len
), readlink
)
74 __nonnull ((1, 2)) __wur
__attr_access ((__write_only__
, 2, 3));
75 extern ssize_t
__REDIRECT_NTH (__readlink_chk_warn
,
76 (const char *__restrict __path
,
77 char *__restrict __buf
, size_t __len
,
78 size_t __buflen
), __readlink_chk
)
79 __nonnull ((1, 2)) __wur
__warnattr ("readlink called with bigger length "
80 "than size of destination buffer");
84 extern ssize_t
__readlinkat_chk (int __fd
, const char *__restrict __path
,
85 char *__restrict __buf
, size_t __len
,
87 __THROW
__nonnull ((2, 3)) __wur
__attr_access ((__write_only__
, 3, 4));
88 extern ssize_t
__REDIRECT_NTH (__readlinkat_alias
,
89 (int __fd
, const char *__restrict __path
,
90 char *__restrict __buf
, size_t __len
),
92 __nonnull ((2, 3)) __wur
__attr_access ((__write_only__
, 3, 4));
93 extern ssize_t
__REDIRECT_NTH (__readlinkat_chk_warn
,
94 (int __fd
, const char *__restrict __path
,
95 char *__restrict __buf
, size_t __len
,
96 size_t __buflen
), __readlinkat_chk
)
97 __nonnull ((2, 3)) __wur
__warnattr ("readlinkat called with bigger "
98 "length than size of destination "
102 extern char *__getcwd_chk (char *__buf
, size_t __size
, size_t __buflen
)
104 extern char *__REDIRECT_NTH (__getcwd_alias
,
105 (char *__buf
, size_t __size
), getcwd
) __wur
;
106 extern char *__REDIRECT_NTH (__getcwd_chk_warn
,
107 (char *__buf
, size_t __size
, size_t __buflen
),
109 __wur
__warnattr ("getcwd caller with bigger length than size of "
110 "destination buffer");
112 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
113 extern char *__getwd_chk (char *__buf
, size_t buflen
)
114 __THROW
__nonnull ((1)) __wur
__attr_access ((__write_only__
, 1, 2));
115 extern char *__REDIRECT_NTH (__getwd_warn
, (char *__buf
), getwd
)
116 __nonnull ((1)) __wur
__warnattr ("please use getcwd instead, as getwd "
117 "doesn't specify buffer size");
120 extern size_t __confstr_chk (int __name
, char *__buf
, size_t __len
,
121 size_t __buflen
) __THROW
122 __attr_access ((__write_only__
, 2, 3));
123 extern size_t __REDIRECT_NTH (__confstr_alias
, (int __name
, char *__buf
,
124 size_t __len
), confstr
)
125 __attr_access ((__write_only__
, 2, 3));
126 extern size_t __REDIRECT_NTH (__confstr_chk_warn
,
127 (int __name
, char *__buf
, size_t __len
,
128 size_t __buflen
), __confstr_chk
)
129 __warnattr ("confstr called with bigger length than size of destination "
133 extern int __getgroups_chk (int __size
, __gid_t __list
[], size_t __listlen
)
134 __THROW __wur
__attr_access ((__write_only__
, 2, 1));
135 extern int __REDIRECT_NTH (__getgroups_alias
, (int __size
, __gid_t __list
[]),
136 getgroups
) __wur
__attr_access ((__write_only__
, 2, 1));
137 extern int __REDIRECT_NTH (__getgroups_chk_warn
,
138 (int __size
, __gid_t __list
[], size_t __listlen
),
140 __wur
__warnattr ("getgroups called with bigger group count than what "
141 "can fit into destination buffer");
144 extern int __ttyname_r_chk (int __fd
, char *__buf
, size_t __buflen
,
145 size_t __nreal
) __THROW
__nonnull ((2))
146 __attr_access ((__write_only__
, 2, 3));
147 extern int __REDIRECT_NTH (__ttyname_r_alias
, (int __fd
, char *__buf
,
148 size_t __buflen
), ttyname_r
)
150 extern int __REDIRECT_NTH (__ttyname_r_chk_warn
,
151 (int __fd
, char *__buf
, size_t __buflen
,
152 size_t __nreal
), __ttyname_r_chk
)
153 __nonnull ((2)) __warnattr ("ttyname_r called with bigger buflen than "
154 "size of destination buffer");
157 #ifdef __USE_POSIX199506
158 extern int __getlogin_r_chk (char *__buf
, size_t __buflen
, size_t __nreal
)
159 __nonnull ((1)) __attr_access ((__write_only__
, 1, 2));
160 extern int __REDIRECT_FORTIFY (__getlogin_r_alias
, (char *__buf
, size_t __buflen
),
161 getlogin_r
) __nonnull ((1));
162 extern int __REDIRECT (__getlogin_r_chk_warn
,
163 (char *__buf
, size_t __buflen
, size_t __nreal
),
165 __nonnull ((1)) __warnattr ("getlogin_r called with bigger buflen than "
166 "size of destination buffer");
170 #if defined __USE_MISC || defined __USE_UNIX98
171 extern int __gethostname_chk (char *__buf
, size_t __buflen
, size_t __nreal
)
172 __THROW
__nonnull ((1)) __attr_access ((__write_only__
, 1, 2));
173 extern int __REDIRECT_NTH (__gethostname_alias
, (char *__buf
, size_t __buflen
),
175 __nonnull ((1)) __attr_access ((__write_only__
, 1, 2));
176 extern int __REDIRECT_NTH (__gethostname_chk_warn
,
177 (char *__buf
, size_t __buflen
, size_t __nreal
),
179 __nonnull ((1)) __warnattr ("gethostname called with bigger buflen than "
180 "size of destination buffer");
184 #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_UNIX98)
185 extern int __getdomainname_chk (char *__buf
, size_t __buflen
, size_t __nreal
)
186 __THROW
__nonnull ((1)) __wur
__attr_access ((__write_only__
, 1, 2));
187 extern int __REDIRECT_FORTIFY_NTH (__getdomainname_alias
, (char *__buf
,
189 getdomainname
) __nonnull ((1))
190 __wur
__attr_access ((__write_only__
, 1, 2));
191 extern int __REDIRECT_NTH (__getdomainname_chk_warn
,
192 (char *__buf
, size_t __buflen
, size_t __nreal
),
194 __nonnull ((1)) __wur
__warnattr ("getdomainname called with bigger "
195 "buflen than size of destination "
198 #endif /* bits/unistd-decl.h. */