Author: jonpryor
Date: 2005-04-19 06:30:19 -0400 (Tue, 19 Apr 2005)
New Revision: 43243
Added:
trunk/mono/support/sys-xattr.c
Modified:
trunk/mono/ChangeLog
trunk/mono/configure.in
trunk/mono/support/ChangeLog
trunk/mono/support/Makefile.am
trunk/mono/support/map.c
trunk/mono/support/map.h
Log:
* configure.in: Add check for <sys/xattr.h>.
Thanks to Daniel Drake <[EMAIL PROTECTED]> 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.
Modified: trunk/mono/ChangeLog
===================================================================
--- trunk/mono/ChangeLog 2005-04-19 09:09:41 UTC (rev 43242)
+++ trunk/mono/ChangeLog 2005-04-19 10:30:19 UTC (rev 43243)
@@ -1,3 +1,8 @@
+2005-04-19 Jonathan Pryor <[EMAIL PROTECTED]>
+
+ * configure.in: Add check for <sys/xattr.h>.
+ Thanks to Daniel Drake <[EMAIL PROTECTED]> for the patch.
+
2005-04-18 Zoltan Varga <[EMAIL PROTECTED]>
* configure.in: Applied another freebsd patch from Bill Middleton
([EMAIL PROTECTED]).
Modified: trunk/mono/configure.in
===================================================================
--- trunk/mono/configure.in 2005-04-19 09:09:41 UTC (rev 43242)
+++ trunk/mono/configure.in 2005-04-19 10:30:19 UTC (rev 43243)
@@ -1133,6 +1133,7 @@
AC_CHECK_HEADERS(sys/sendfile.h)
AC_CHECK_HEADERS(sys/statvfs.h)
AC_CHECK_HEADERS(sys/vfstab.h)
+ AC_CHECK_HEADERS(sys/xattr.h)
AC_CHECK_FUNCS(getdomainname)
AC_CHECK_FUNCS(setdomainname)
AC_CHECK_FUNCS(fgetgrent)
Modified: trunk/mono/support/ChangeLog
===================================================================
--- trunk/mono/support/ChangeLog 2005-04-19 09:09:41 UTC (rev 43242)
+++ trunk/mono/support/ChangeLog 2005-04-19 10:30:19 UTC (rev 43243)
@@ -1,5 +1,12 @@
-2005-04-07 Zoltan Varga <[EMAIL PROTECTED]>
+2005-04-19 Jonathan Pryor <[EMAIL PROTECTED]>
+ * 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 <[EMAIL PROTECTED]>
+
* errno.c: Use the GNU version of strerror_r if _GNU_SOURCE is defined
(otherwise assume existence of XPG variant). This allows proper
compilation under Red Hat 9.
Modified: trunk/mono/support/Makefile.am
===================================================================
--- trunk/mono/support/Makefile.am 2005-04-19 09:09:41 UTC (rev 43242)
+++ trunk/mono/support/Makefile.am 2005-04-19 10:30:19 UTC (rev 43243)
@@ -33,6 +33,7 @@
sys-statvfs.c \
sys-time.c \
sys-wait.c \
+ sys-xattr.c \
time.c \
unistd.c \
utime.c \
Modified: trunk/mono/support/map.c
===================================================================
--- trunk/mono/support/map.c 2005-04-19 09:09:41 UTC (rev 43242)
+++ trunk/mono/support/map.c 2005-04-19 10:30:19 UTC (rev 43243)
@@ -5975,3 +5975,49 @@
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;
+}
+
Modified: trunk/mono/support/map.h
===================================================================
--- trunk/mono/support/map.h 2005-04-19 09:09:41 UTC (rev 43242)
+++ trunk/mono/support/map.h 2005-04-19 10:30:19 UTC (rev 43243)
@@ -634,6 +634,12 @@
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 */
Added: trunk/mono/support/sys-xattr.c
===================================================================
--- trunk/mono/support/sys-xattr.c 2005-04-19 09:09:41 UTC (rev 43242)
+++ trunk/mono/support/sys-xattr.c 2005-04-19 10:30:19 UTC (rev 43243)
@@ -0,0 +1,109 @@
+/*
+ * <sys/xattr.h> wrapper functions.
+ *
+ * Authors:
+ * Daniel Drake ([EMAIL PROTECTED])
+ *
+ * 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
+ */
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches