eio: also copy xattr when available.

SVN revision: 59015
This commit is contained in:
Cedric BAIL 2011-04-28 16:45:45 +00:00
parent 31d4f2699b
commit fc27a465a3
2 changed files with 67 additions and 0 deletions

View File

@ -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 <stdlib.h>
#include <sys/types.h>
#include <sys/xattr.h>
]],
[[
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}"

View File

@ -105,6 +105,10 @@
#include "eio_private.h"
#include "Eio.h"
#ifdef HAVE_XATTR
# include <sys/xattr.h>
#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);