Check if the system supports xattr (#2802)

* Check if the system supports xattr

* Support xatttr for FreeBSD and NetBSD

---------

Co-authored-by: heran yang <heran.yang@seafile.com>
This commit is contained in:
feiniks 2024-08-08 16:53:40 +08:00 committed by GitHub
parent ae515945c3
commit c55e4d4021
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -50,9 +50,16 @@
#ifndef WIN32
#include <utime.h>
#endif
#ifdef __linux__
#include <sys/xattr.h>
#endif
#if defined __FreeBSD__ || defined __NetBSD__
#include <sys/extattr.h>
#endif
#include <zlib.h>
#include "log.h"
@ -2724,6 +2731,12 @@ out:
#ifdef __APPLE__
return getxattr (path, name, value, size, 0, 0);
#endif
#if defined __FreeBSD__ || defined __NetBSD__
return extattr_get_file (path, EXTATTR_NAMESPACE_USER, name, value, size);
#endif
return -1;
}
int
@ -2772,6 +2785,12 @@ out:
#ifdef __APPLE__
return setxattr (path, name, value, size, 0, 0);
#endif
#if defined __FreeBSD__ || defined __NetBSD__
return extattr_set_file (path, EXTATTR_NAMESPACE_USER, name, value, size);
#endif
return -1;
}
int