File tree Expand file tree Collapse file tree 2 files changed +53
-14
lines changed Expand file tree Collapse file tree 2 files changed +53
-14
lines changed Original file line number Diff line number Diff line change 1
1
// Common functions that are unfortunately missing on illumos and
2
2
// Solaris, but often needed by other crates.
3
3
4
+ use core:: cmp:: min;
4
5
use unix:: solarish:: * ;
5
6
6
7
const PTEM : & [ u8 ] = b"ptem\0 " ;
@@ -169,3 +170,51 @@ pub unsafe fn forkpty(
169
170
170
171
0
171
172
}
173
+
174
+ pub unsafe fn getpwent_r (
175
+ pwd : * mut passwd ,
176
+ buf : * mut :: c_char ,
177
+ buflen : :: size_t ,
178
+ result : * mut * mut passwd ,
179
+ ) -> :: c_int {
180
+ let old_errno = * :: ___errno ( ) ;
181
+ * :: ___errno ( ) = 0 ;
182
+ * result = native_getpwent_r (
183
+ pwd,
184
+ buf,
185
+ min ( buflen, :: c_int:: max_value ( ) as :: size_t ) as :: c_int ,
186
+ ) ;
187
+
188
+ let ret = if ( * result) . is_null ( ) {
189
+ * :: ___errno ( )
190
+ } else {
191
+ 0
192
+ } ;
193
+ * :: ___errno ( ) = old_errno;
194
+
195
+ ret
196
+ }
197
+
198
+ pub unsafe fn getgrent_r (
199
+ grp : * mut :: group ,
200
+ buf : * mut :: c_char ,
201
+ buflen : :: size_t ,
202
+ result : * mut * mut :: group ,
203
+ ) -> :: c_int {
204
+ let old_errno = * :: ___errno ( ) ;
205
+ * :: ___errno ( ) = 0 ;
206
+ * result = native_getgrent_r (
207
+ grp,
208
+ buf,
209
+ min ( buflen, :: c_int:: max_value ( ) as :: size_t ) as :: c_int ,
210
+ ) ;
211
+
212
+ let ret = if ( * result) . is_null ( ) {
213
+ * :: ___errno ( )
214
+ } else {
215
+ 0
216
+ } ;
217
+ * :: ___errno ( ) = old_errno;
218
+
219
+ ret
220
+ }
Original file line number Diff line number Diff line change @@ -3016,24 +3016,14 @@ extern "C" {
3016
3016
) -> :: c_int ;
3017
3017
#[ cfg_attr(
3018
3018
any( target_os = "solaris" , target_os = "illumos" ) ,
3019
- link_name = "__posix_getpwent_r "
3019
+ link_name = "getpwent_r "
3020
3020
) ]
3021
- pub fn getpwent_r (
3022
- pwd : * mut passwd ,
3023
- buf : * mut :: c_char ,
3024
- buflen : :: size_t ,
3025
- result : * mut * mut passwd ,
3026
- ) -> :: c_int ;
3021
+ fn native_getpwent_r ( pwd : * mut passwd , buf : * mut :: c_char , buflen : :: c_int ) -> * mut passwd ;
3027
3022
#[ cfg_attr(
3028
3023
any( target_os = "solaris" , target_os = "illumos" ) ,
3029
- link_name = "__posix_getgrent_r "
3024
+ link_name = "getgrent_r "
3030
3025
) ]
3031
- pub fn getgrent_r (
3032
- grp : * mut :: group ,
3033
- buf : * mut :: c_char ,
3034
- buflen : :: size_t ,
3035
- result : * mut * mut :: group ,
3036
- ) -> :: c_int ;
3026
+ fn native_getgrent_r ( grp : * mut :: group , buf : * mut :: c_char , buflen : :: c_int ) -> * mut :: group ;
3037
3027
#[ cfg_attr(
3038
3028
any( target_os = "solaris" , target_os = "illumos" ) ,
3039
3029
link_name = "__posix_sigwait"
You can’t perform that action at this time.
0 commit comments