--- embedaddon/rsync/lib/sysxattrs.c 2016/11/01 09:54:32 1.1.1.3 +++ embedaddon/rsync/lib/sysxattrs.c 2021/03/17 00:32:36 1.1.1.4 @@ -2,7 +2,7 @@ * Extended attribute support for rsync. * * Copyright (C) 2004 Red Hat, Inc. - * Copyright (C) 2003-2015 Wayne Davison + * Copyright (C) 2003-2019 Wayne Davison * Written by Jay Fenlason. * * This program is free software; you can redistribute it and/or modify @@ -22,10 +22,17 @@ #include "rsync.h" #include "sysxattrs.h" +extern int preserve_hfs_compression; + #ifdef SUPPORT_XATTRS #ifdef HAVE_OSX_XATTRS +#ifndef XATTR_SHOWCOMPRESSION +#define XATTR_SHOWCOMPRESSION 0x0020 +#endif #define GETXATTR_FETCH_LIMIT (64*1024*1024) + +int xattr_options = XATTR_NOFOLLOW; #endif #if defined HAVE_LINUX_XATTRS @@ -59,15 +66,20 @@ ssize_t sys_llistxattr(const char *path, char *list, s ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size) { - ssize_t len = getxattr(path, name, value, size, 0, XATTR_NOFOLLOW); + ssize_t len; + if (preserve_hfs_compression) + xattr_options |= XATTR_SHOWCOMPRESSION; + + len = getxattr(path, name, value, size, 0, xattr_options); + /* If we're retrieving data, handle resource forks > 64MB specially */ if (value != NULL && len == GETXATTR_FETCH_LIMIT && (size_t)len < size) { /* getxattr will only return 64MB of data at a time, need to call again with a new offset */ u_int32_t offset = len; size_t data_retrieved = len; while (data_retrieved < size) { - len = getxattr(path, name, value + offset, size - data_retrieved, offset, XATTR_NOFOLLOW); + len = getxattr(path, name, value + offset, size - data_retrieved, offset, xattr_options); if (len <= 0) break; data_retrieved += len; @@ -91,12 +103,16 @@ int sys_lsetxattr(const char *path, const char *name, int sys_lremovexattr(const char *path, const char *name) { - return removexattr(path, name, XATTR_NOFOLLOW); + if (preserve_hfs_compression) + xattr_options |= XATTR_SHOWCOMPRESSION; + return removexattr(path, name, xattr_options); } ssize_t sys_llistxattr(const char *path, char *list, size_t size) { - return listxattr(path, list, size, XATTR_NOFOLLOW); + if (preserve_hfs_compression) + xattr_options |= XATTR_SHOWCOMPRESSION; + return listxattr(path, list, size, xattr_options); } #elif HAVE_FREEBSD_XATTRS