X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Fmacros.c;h=8d455889d7ca4c30ea10c8a6e7c2471afcec7179;hb=edbc5c2334e10836479d1cc528c68d4ad5b47440;hp=c763a7ca2f8719d442cda74e017ee846fedf4fa8;hpb=b7c17c47e6b3c02192e64175cb5ee0ce7f7dda1b;p=mono.git diff --git a/support/macros.c b/support/macros.c index c763a7ca2f8..8d455889d7c 100644 --- a/support/macros.c +++ b/support/macros.c @@ -1,3 +1,4 @@ +#include "mph.h" #include #include #include @@ -7,6 +8,8 @@ #include #include #include +#include +#include "map.h" int wifexited (int status) { @@ -38,7 +41,7 @@ int wstopsig (int status) return WSTOPSIG (status); } -int helper_Mono_Posix_Stat(char *filename, int dereference, +int helper_Mono_Posix_Stat(const char *filename, int dereference, int *device, int *inode, int *mode, @@ -46,12 +49,12 @@ int helper_Mono_Posix_Stat(char *filename, int dereference, int *uid, int *gid, int *rdev, - long *size, - long *blksize, - long *blocks, - long *atime, - long *mtime, - long *ctime + gint64 *size, + gint64 *blksize, + gint64 *blocks, + gint64 *atime, + gint64 *mtime, + gint64 *ctime ) { int ret; struct stat buf; @@ -90,8 +93,67 @@ char *helper_Mono_Posix_GetGroupName(int gid) { return strdup (p->gr_name); } -char *helper_Mono_Posix_readdir(DIR *dir) { - struct dirent* e = readdir(dir); +char *helper_Mono_Posix_readdir(void *dir) { + struct dirent* e = readdir((DIR*) dir); if (e == NULL) return NULL; return strdup (e->d_name); } + +#if HAVE_GETPWNAM_R +int helper_Mono_Posix_getpwnamuid (int mode, char *in_name, int in_uid, + char **account, + char **password, + int *uid, + int *gid, + char **name, + char **home, + char **shell); + +int helper_Mono_Posix_getpwnamuid (int mode, char *in_name, int in_uid, + char **account, + char **password, + int *uid, + int *gid, + char **name, + char **home, + char **shell + ) { + + struct passwd pw, *pwp; + char buf[4096]; + int ret; + + if (mode == 0) + ret = getpwnam_r (in_name, &pw, buf, 4096, &pwp); + else + ret = getpwuid_r (in_uid, &pw, buf, 4096, &pwp); + + if (ret == 0 && pwp == NULL) { + // Don't know why this happens, but it does. + // ret == 0, errno == 0, but no record was found. + ret = ENOENT; + } + + if (ret) { + *account = NULL; // prevent marshalling unset pointers + *password = NULL; + *uid = 0; + *gid = 0; + *name = NULL; + *home = NULL; + *shell = NULL; + return ret; + } + + *account = pwp->pw_name; + *password = pwp->pw_passwd; + *uid = pwp->pw_uid; + *gid = pwp->pw_gid; + *name = pwp->pw_gecos; + *home = pwp->pw_dir; + *shell = pwp->pw_shell; + + return 0; +} +#endif /* def HAVE_GETPWNAM_R */ +