12 #include "mph.h" /* Don't remove or move after map.h! Works around issues with Android SDK unified headers */
15 int wifexited (int status
)
17 return WIFEXITED (status
);
20 int wexitstatus (int status
)
22 return WEXITSTATUS (status
);
25 int wifsignaled (int status
)
27 return WIFSIGNALED (status
);
30 int wtermsig (int status
)
32 return WTERMSIG (status
);
35 int wifstopped (int status
)
37 return WIFSTOPPED (status
);
40 int wstopsig (int status
)
42 return WSTOPSIG (status
);
45 int helper_Mono_Posix_Stat(const char *filename
, int dereference
,
64 ret
= stat(filename
, &buf
);
66 ret
= lstat(filename
, &buf
);
73 *nlinks
= buf
.st_nlink
;
78 *blksize
= buf
.st_blksize
;
79 *blocks
= buf
.st_blocks
;
80 *atime
= buf
.st_atime
;
81 *mtime
= buf
.st_mtime
;
82 *ctime
= buf
.st_ctime
;
86 char *helper_Mono_Posix_GetUserName(int uid
) {
87 struct passwd
*p
= getpwuid(uid
);
88 if (p
== NULL
) return NULL
;
89 return strdup (p
->pw_name
);
91 char *helper_Mono_Posix_GetGroupName(int gid
) {
92 struct group
*p
= getgrgid(gid
);
93 if (p
== NULL
) return NULL
;
94 return strdup (p
->gr_name
);
97 char *helper_Mono_Posix_readdir(void *dir
) {
98 struct dirent
* e
= readdir((DIR*) dir
);
99 if (e
== NULL
) return NULL
;
100 return strdup (e
->d_name
);
104 int helper_Mono_Posix_getpwnamuid (int mode
, char *in_name
, int in_uid
,
113 int helper_Mono_Posix_getpwnamuid (int mode
, char *in_name
, int in_uid
,
123 struct passwd pw
, *pwp
;
128 ret
= getpwnam_r (in_name
, &pw
, buf
, 4096, &pwp
);
130 ret
= getpwuid_r (in_uid
, &pw
, buf
, 4096, &pwp
);
132 if (ret
== 0 && pwp
== NULL
) {
133 // Don't know why this happens, but it does.
134 // ret == 0, errno == 0, but no record was found.
139 *account
= NULL
; // prevent marshalling unset pointers
149 *account
= pwp
->pw_name
;
150 *password
= pwp
->pw_passwd
;
153 *name
= pwp
->pw_gecos
;
155 *shell
= pwp
->pw_shell
;
159 #endif /* def HAVE_GETPWNAM_R */