Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Pryor <jpryor@novell.com>2005-04-19 14:30:19 +0400
committerJonathan Pryor <jpryor@novell.com>2005-04-19 14:30:19 +0400
commitd8dc7da080ba256b441d54029d0a08d8a2f10ff8 (patch)
tree668d87ff6a598714cd2157a29e7a19724ce5c52c /support
parent6a8ab9a6aefa24a913e26a6d185e2146e5489d6d (diff)
* configure.in: Add check for <sys/xattr.h>.
Thanks to Daniel Drake <dsd@gentoo.org> for the patch. * support/map.c, support/map.h: Added XattrFlags values, functions. * support/sys-xattr.c: Added; <sys/xattr.h> wrapper functions. Thanks to Daniel Drake for writing these. * support/Makefile.am: Add sys-xattr.c to the build. svn path=/trunk/mono/; revision=43243
Diffstat (limited to 'support')
-rw-r--r--support/ChangeLog9
-rw-r--r--support/Makefile.am1
-rw-r--r--support/map.c46
-rw-r--r--support/map.h6
-rw-r--r--support/sys-xattr.c109
5 files changed, 170 insertions, 1 deletions
diff --git a/support/ChangeLog b/support/ChangeLog
index ee4196b63a2..a682d29af6c 100644
--- a/support/ChangeLog
+++ b/support/ChangeLog
@@ -1,4 +1,11 @@
-2005-04-07 Zoltan Varga <vargaz@freemail.hu>
+2005-04-19 Jonathan Pryor <jonpryor@vt.edu>
+
+ * map.c, map.h: Added XattrFlags values, functions.
+ * sys-xattr.c: Added; <sys/xattr.h> wrapper functions. Thanks to Daniel
+ Drake for writing these.
+ * Makefile.am: Add sys-xattr.c to the build.
+
+2005-04-07 Jonathan Pryor <jonpryor@vt.edu>
* errno.c: Use the GNU version of strerror_r if _GNU_SOURCE is defined
(otherwise assume existence of XPG variant). This allows proper
diff --git a/support/Makefile.am b/support/Makefile.am
index c1aa211460d..9e62bdf3717 100644
--- a/support/Makefile.am
+++ b/support/Makefile.am
@@ -33,6 +33,7 @@ MPH_UNIX_SOURCE = \
sys-statvfs.c \
sys-time.c \
sys-wait.c \
+ sys-xattr.c \
time.c \
unistd.c \
utime.c \
diff --git a/support/map.c b/support/map.c
index fd70bc7ead1..c9f47a44096 100644
--- a/support/map.c
+++ b/support/map.c
@@ -5975,3 +5975,49 @@ int Mono_Posix_ToPollEvents (short x, short *r)
return 0;
}
+int Mono_Posix_FromXattrFlags (int x, int *r)
+{
+ *r = 0;
+ if (x == 0)
+ return 0;
+ if ((x & Mono_Posix_XattrFlags_XATTR_AUTO) == Mono_Posix_XattrFlags_XATTR_AUTO)
+#ifdef XATTR_AUTO
+ *r |= XATTR_AUTO;
+#else /* def XATTR_AUTO */
+ {errno = EINVAL; return -1;}
+#endif /* ndef XATTR_AUTO */
+ if ((x & Mono_Posix_XattrFlags_XATTR_CREATE) == Mono_Posix_XattrFlags_XATTR_CREATE)
+#ifdef XATTR_CREATE
+ *r |= XATTR_CREATE;
+#else /* def XATTR_CREATE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef XATTR_CREATE */
+ if ((x & Mono_Posix_XattrFlags_XATTR_REPLACE) == Mono_Posix_XattrFlags_XATTR_REPLACE)
+#ifdef XATTR_REPLACE
+ *r |= XATTR_REPLACE;
+#else /* def XATTR_REPLACE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef XATTR_REPLACE */
+ return 0;
+}
+
+int Mono_Posix_ToXattrFlags (int x, int *r)
+{
+ *r = 0;
+ if (x == 0)
+ return 0;
+#ifdef XATTR_AUTO
+ if ((x & XATTR_AUTO) == XATTR_AUTO)
+ *r |= Mono_Posix_XattrFlags_XATTR_AUTO;
+#endif /* ndef XATTR_AUTO */
+#ifdef XATTR_CREATE
+ if ((x & XATTR_CREATE) == XATTR_CREATE)
+ *r |= Mono_Posix_XattrFlags_XATTR_CREATE;
+#endif /* ndef XATTR_CREATE */
+#ifdef XATTR_REPLACE
+ if ((x & XATTR_REPLACE) == XATTR_REPLACE)
+ *r |= Mono_Posix_XattrFlags_XATTR_REPLACE;
+#endif /* ndef XATTR_REPLACE */
+ return 0;
+}
+
diff --git a/support/map.h b/support/map.h
index b48be07c1b8..48da17137c4 100644
--- a/support/map.h
+++ b/support/map.h
@@ -634,6 +634,12 @@ int Mono_Posix_ToLockFlags (int x, int *r);
int Mono_Posix_FromPollEvents (short x, short *r);
int Mono_Posix_ToPollEvents (short x, short *r);
+#define Mono_Posix_XattrFlags_XATTR_AUTO 0x00000000
+#define Mono_Posix_XattrFlags_XATTR_CREATE 0x00000001
+#define Mono_Posix_XattrFlags_XATTR_REPLACE 0x00000002
+int Mono_Posix_FromXattrFlags (int x, int *r);
+int Mono_Posix_ToXattrFlags (int x, int *r);
+
G_END_DECLS
#endif /* ndef INC_Mono_Posix_map_H */
diff --git a/support/sys-xattr.c b/support/sys-xattr.c
new file mode 100644
index 00000000000..a5729a86921
--- /dev/null
+++ b/support/sys-xattr.c
@@ -0,0 +1,109 @@
+/*
+ * <sys/xattr.h> wrapper functions.
+ *
+ * Authors:
+ * Daniel Drake (dsd@gentoo.org)
+ *
+ * Copyright (C) 2005 Daniel Drake
+ */
+
+#include <config.h>
+
+#ifdef HAVE_SYS_XATTR_H
+
+#include <sys/types.h>
+#include <sys/xattr.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "map.h"
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+gint32
+Mono_Posix_Syscall_setxattr (const char *path, const char *name, char *value, mph_size_t size, gint32 flags)
+{
+ int _flags;
+ mph_return_if_size_t_overflow (size);
+
+ if (Mono_Posix_FromXattrFlags (flags, &_flags) == -1)
+ return -1;
+
+ return setxattr (path, name, value, size, _flags);
+}
+
+gint32
+Mono_Posix_Syscall_lsetxattr (const char *path, const char *name, char *value, mph_size_t size, gint32 flags)
+{
+ int _flags;
+ mph_return_if_size_t_overflow (size);
+
+ if (Mono_Posix_FromXattrFlags (flags, &_flags) == -1)
+ return -1;
+
+ return lsetxattr (path, name, value, size, _flags);
+}
+
+gint32
+Mono_Posix_Syscall_fsetxattr (int fd, const char *name, char *value, mph_size_t size, gint32 flags)
+{
+ int _flags;
+ mph_return_if_size_t_overflow (size);
+
+ if (Mono_Posix_FromXattrFlags (flags, &_flags) == -1)
+ return -1;
+
+ return lsetxattr (fd, name, value, (size_t) size, _flags);
+}
+
+mph_ssize_t
+Mono_Posix_Syscall_getxattr (const char *path, const char *name, void *value, mph_size_t size)
+{
+ mph_return_if_size_t_overflow (size);
+ return getxattr (path, name, value, (size_t) size);
+}
+
+mph_ssize_t
+Mono_Posix_Syscall_lgetxattr (const char *path, const char *name, void *value, mph_size_t size)
+{
+ mph_return_if_size_t_overflow (size);
+ return lgetxattr (path, name, value, (size_t) size);
+}
+
+mph_ssize_t
+Mono_Posix_Syscall_fgetxattr (int fd, const char *name, void *value, mph_size_t size)
+{
+ mph_return_if_size_t_overflow (size);
+ return fgetxattr (fd, name, value, (size_t) size);
+}
+
+mph_ssize_t
+Mono_Posix_Syscall_listxattr (const char *path, char *list, mph_size_t size)
+{
+ mph_return_if_size_t_overflow (size);
+ return listxattr (path, list, (size_t) size);
+}
+
+mph_ssize_t
+Mono_Posix_Syscall_llistxattr (const char *path, char *list, mph_size_t size)
+{
+ mph_return_if_size_t_overflow (size);
+ return llistxattr (path, list, (size_t) size);
+}
+
+mph_ssize_t
+Mono_Posix_Syscall_flistxattr (int fd, char *list, mph_size_t size)
+{
+ mph_return_if_size_t_overflow (size);
+ return flistxattr (fd, list, (size_t) size);
+}
+
+G_END_DECLS
+
+#endif /* def HAVE_ATTR_XATTR_H */
+
+/*
+ * vim: noexpandtab
+ */