فهرست منبع

* 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.

svn path=/trunk/mono/; revision=43243

Jonathan Pryor 21 سال پیش
والد
کامیت
d8dc7da080
7فایلهای تغییر یافته به همراه176 افزوده شده و 1 حذف شده
  1. 5 0
      ChangeLog
  2. 1 0
      configure.in
  3. 8 1
      support/ChangeLog
  4. 1 0
      support/Makefile.am
  5. 46 0
      support/map.c
  6. 6 0
      support/map.h
  7. 109 0
      support/sys-xattr.c

+ 5 - 0
ChangeLog

@@ -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]).

+ 1 - 0
configure.in

@@ -1133,6 +1133,7 @@ if test x$platform_win32 = xno; then
 	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)

+ 8 - 1
support/ChangeLog

@@ -1,4 +1,11 @@
-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

+ 1 - 0
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    \

+ 46 - 0
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;
+}
+

+ 6 - 0
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 */

+ 109 - 0
support/sys-xattr.c

@@ -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
+ */