From fc27a465a3a4e4e4195cbf035d924755bd5d3546 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Thu, 28 Apr 2011 16:45:45 +0000 Subject: [PATCH] eio: also copy xattr when available. SVN revision: 59015 --- legacy/eio/configure.ac | 24 +++++++++++++++++++ legacy/eio/src/lib/eio_file.c | 43 +++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/legacy/eio/configure.ac b/legacy/eio/configure.ac index 21b962c577..4aa8be11df 100644 --- a/legacy/eio/configure.ac +++ b/legacy/eio/configure.ac @@ -187,6 +187,29 @@ EIO_CHECK_NOTIFY_WIN32([${want_notify_win32}], [have_notify_win32="yes"], [have_ AM_CONDITIONAL([EIO_HAVE_INOTIFY], [test "x$have_inotify" = "xyes"]) AM_CONDITIONAL([EIO_HAVE_WINCHANGE], [test "x$have_notify_win32" = "xyes"]) +### Check for extended attribute + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include +#include + ]], + [[ +size_t tmp = listxattr("/", NULL, 0); +tmp = getxattr("/", "user.ethumb.md5", NULL, 0); +setxattr("/", "user.ethumb.md5", NULL, 0, 0); + ]])], + [ + AC_DEFINE(HAVE_XATTR, 1, [Define to 1 if you have 'listxattr', 'setxattr' and 'getxattr']) + have_xattr="yes" + ], + [have_xattr="no"]) + +AC_MSG_CHECKING([for Xattr]) +AC_MSG_RESULT([${have_xattr}]) + ## Report AC_OUTPUT([ @@ -209,6 +232,7 @@ echo echo echo "Configuration Options Summary:" echo +echo " Xattr................: ${have_xattr}" echo " Thread Support.......: ${have_threads}" echo " Inotify..............: ${have_inotify}" echo " Windows notification.: ${have_notify_win32}" diff --git a/legacy/eio/src/lib/eio_file.c b/legacy/eio/src/lib/eio_file.c index 6f96b88da6..57362cc044 100644 --- a/legacy/eio/src/lib/eio_file.c +++ b/legacy/eio/src/lib/eio_file.c @@ -105,6 +105,10 @@ #include "eio_private.h" #include "Eio.h" +#ifdef HAVE_XATTR +# include +#endif + /*============================================================================* * Local * *============================================================================*/ @@ -251,6 +255,41 @@ _eio_file_error(void *data, Ecore_Thread *thread __UNUSED__) free(async); } +#ifdef HAVE_XATTR +static void +_eio_file_copy_xattr(Ecore_Thread *thread, Eio_File_Progress *op, int in, int out) +{ + char *tmp; + ssize_t length; + ssize_t i; + + length = flistxattr(in, NULL, 0); + + if (length > 0) return ; + + tmp = alloca(length); + length = flistxattr(in, tmp, length); + + for (i = 0; i < length; i += strlen(tmp) + 1) + { + ssize_t attr_length; + void *value; + + attr_length = fgetxattr(in, tmp, NULL, 0); + if (!attr_length) continue ; + + value = malloc(attr_length); + if (!value) continue ; + attr_length = fgetxattr(in, tmp, value, attr_length); + + if (attr_length > 0) + fsetxattr(out, tmp, value, attr_length, 0); + + free(value); + } +} +#endif + static Eina_Bool _eio_file_write(int fd, void *mem, ssize_t length) { @@ -594,6 +633,10 @@ eio_file_copy_do(Ecore_Thread *thread, Eio_File_Progress *copy) goto on_error; #endif +#ifdef HAVE_XATTR + _eio_file_copy_xattr(thread, copy, in, out); +#endif + close(out); close(in);