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 11// Common functions that are unfortunately missing on illumos and
22// Solaris, but often needed by other crates.
33
4+ use core:: cmp:: min;
45use unix:: solarish:: * ;
56
67const PTEM : & [ u8 ] = b"ptem\0 " ;
@@ -169,3 +170,51 @@ pub unsafe fn forkpty(
169170
170171 0
171172}
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" {
30163016 ) -> :: c_int ;
30173017 #[ cfg_attr(
30183018 any( target_os = "solaris" , target_os = "illumos" ) ,
3019- link_name = "__posix_getpwent_r "
3019+ link_name = "getpwent_r "
30203020 ) ]
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 ;
30273022 #[ cfg_attr(
30283023 any( target_os = "solaris" , target_os = "illumos" ) ,
3029- link_name = "__posix_getgrent_r "
3024+ link_name = "getgrent_r "
30303025 ) ]
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 ;
30373027 #[ cfg_attr(
30383028 any( target_os = "solaris" , target_os = "illumos" ) ,
30393029 link_name = "__posix_sigwait"
You can’t perform that action at this time.
0 commit comments