updating to the latest module.
[mono.git] / support / sys-xattr.c
1 /*
2  * <sys/xattr.h> wrapper functions.
3  *
4  * Authors:
5  *   Daniel Drake (dsd@gentoo.org)
6  *
7  * Copyright (C) 2005 Daniel Drake
8  */
9
10 #include <config.h>
11
12 #ifdef HAVE_SYS_XATTR_H
13
14 #include <sys/types.h>
15 #include <sys/xattr.h>
16 #include <unistd.h>
17 #include <fcntl.h>
18 #include <errno.h>
19
20 #include "map.h"
21 #include "mph.h"
22
23 G_BEGIN_DECLS
24
25 gint32
26 Mono_Posix_Syscall_setxattr (const char *path, const char *name, char *value, mph_size_t size, gint32 flags)
27 {
28         int _flags;
29         mph_return_if_size_t_overflow (size);
30
31         if (Mono_Posix_FromXattrFlags (flags, &_flags) == -1)
32                 return -1;
33
34         return setxattr (path, name, value, size, _flags);
35 }
36
37 gint32
38 Mono_Posix_Syscall_lsetxattr (const char *path, const char *name, char *value, mph_size_t size, gint32 flags)
39 {
40         int _flags;
41         mph_return_if_size_t_overflow (size);
42
43         if (Mono_Posix_FromXattrFlags (flags, &_flags) == -1)
44                 return -1;
45
46         return lsetxattr (path, name, value, size, _flags);
47 }
48
49 gint32
50 Mono_Posix_Syscall_fsetxattr (int fd, const char *name, char *value, mph_size_t size, gint32 flags)
51 {
52         int _flags;
53         mph_return_if_size_t_overflow (size);
54
55         if (Mono_Posix_FromXattrFlags (flags, &_flags) == -1)
56                 return -1;
57
58         return lsetxattr (fd, name, value, (size_t) size, _flags);
59 }
60
61 mph_ssize_t
62 Mono_Posix_Syscall_getxattr (const char *path, const char *name, void *value, mph_size_t size)
63 {
64         mph_return_if_size_t_overflow (size);
65         return getxattr (path, name, value, (size_t) size);
66 }
67
68 mph_ssize_t
69 Mono_Posix_Syscall_lgetxattr (const char *path, const char *name, void *value, mph_size_t size)
70 {
71         mph_return_if_size_t_overflow (size);
72         return lgetxattr (path, name, value, (size_t) size);
73 }
74
75 mph_ssize_t
76 Mono_Posix_Syscall_fgetxattr (int fd, const char *name, void *value, mph_size_t size)
77 {
78         mph_return_if_size_t_overflow (size);
79         return fgetxattr (fd, name, value, (size_t) size);
80 }
81
82 mph_ssize_t
83 Mono_Posix_Syscall_listxattr (const char *path, char *list, mph_size_t size)
84 {
85         mph_return_if_size_t_overflow (size);
86         return listxattr (path, list, (size_t) size);
87 }
88
89 mph_ssize_t
90 Mono_Posix_Syscall_llistxattr (const char *path, char *list, mph_size_t size)
91 {
92         mph_return_if_size_t_overflow (size);
93         return llistxattr (path, list, (size_t) size);
94 }
95
96 mph_ssize_t
97 Mono_Posix_Syscall_flistxattr (int fd, char *list, mph_size_t size)
98 {
99         mph_return_if_size_t_overflow (size);
100         return flistxattr (fd, list, (size_t) size);
101 }
102
103 G_END_DECLS
104
105 #endif /* def HAVE_ATTR_XATTR_H */
106
107 /*
108  * vim: noexpandtab
109  */