Merge pull request #117 from madewokherd/win32build
[mono-project.git] / support / sys-stat.c
blob952a46363dbb687052d045404063c46142ac4cd7
1 /*
2 * <sys/stat.h> wrapper functions.
4 * Authors:
5 * Jonathan Pryor (jonpryor@vt.edu)
7 * Copyright (C) 2004-2006 Jonathan Pryor
8 */
10 #ifndef _GNU_SOURCE
11 #define _GNU_SOURCE
12 #endif /* ndef _GNU_SOURCE */
14 #include <sys/types.h>
15 #include <sys/stat.h>
16 #include <unistd.h>
17 #include <fcntl.h>
18 #include <errno.h>
20 #include "map.h"
21 #include "mph.h"
23 G_BEGIN_DECLS
25 gint32
26 Mono_Posix_Syscall_stat (const char *file_name, struct Mono_Posix_Stat *buf)
28 int r;
29 struct stat _buf;
31 if (buf == NULL) {
32 errno = EFAULT;
33 return -1;
35 r = stat (file_name, &_buf);
36 if (r != -1 && Mono_Posix_ToStat (&_buf, buf) == -1)
37 r = -1;
38 return r;
41 gint32
42 Mono_Posix_Syscall_fstat (int filedes, struct Mono_Posix_Stat *buf)
44 int r;
45 struct stat _buf;
47 if (buf == NULL) {
48 errno = EFAULT;
49 return -1;
51 r = fstat (filedes, &_buf);
52 if (r != -1 && Mono_Posix_ToStat (&_buf, buf) == -1)
53 r = -1;
54 return r;
57 gint32
58 Mono_Posix_Syscall_lstat (const char *file_name, struct Mono_Posix_Stat *buf)
60 int r;
61 struct stat _buf;
63 if (buf == NULL) {
64 errno = EFAULT;
65 return -1;
67 r = lstat (file_name, &_buf);
68 if (r != -1 && Mono_Posix_ToStat (&_buf, buf) == -1)
69 r = -1;
70 return r;
73 gint32
74 Mono_Posix_Syscall_mknod (const char *pathname, guint32 mode, mph_dev_t dev)
76 if (Mono_Posix_FromFilePermissions (mode, &mode) == -1)
77 return -1;
78 return mknod (pathname, mode, dev);
81 G_END_DECLS
84 * vim: noexpandtab