|
|
| version 1.1.1.2, 2013/10/14 07:51:14 | version 1.1.1.4, 2021/03/17 00:32:36 |
|---|---|
| Line 2 | Line 2 |
| * Extended attribute support for rsync. | * Extended attribute support for rsync. |
| * | * |
| * Copyright (C) 2004 Red Hat, Inc. | * Copyright (C) 2004 Red Hat, Inc. |
| * Copyright (C) 2003-2008 Wayne Davison | * Copyright (C) 2003-2019 Wayne Davison |
| * Written by Jay Fenlason. | * Written by Jay Fenlason. |
| * | * |
| * This program is free software; you can redistribute it and/or modify | * This program is free software; you can redistribute it and/or modify |
| Line 22 | Line 22 |
| #include "rsync.h" | #include "rsync.h" |
| #include "sysxattrs.h" | #include "sysxattrs.h" |
| extern int preserve_hfs_compression; | |
| #ifdef SUPPORT_XATTRS | #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 | #if defined HAVE_LINUX_XATTRS |
| ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size) | ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size) |
| Line 55 ssize_t sys_llistxattr(const char *path, char *list, s | Line 66 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 sys_lgetxattr(const char *path, const char *name, void *value, size_t size) |
| { | { |
| return 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_options); | |
| if (len <= 0) | |
| break; | |
| data_retrieved += len; | |
| offset += (u_int32_t)len; | |
| } | |
| len = data_retrieved; | |
| } | |
| return len; | |
| } | } |
| ssize_t sys_fgetxattr(int filedes, const char *name, void *value, size_t size) | ssize_t sys_fgetxattr(int filedes, const char *name, void *value, size_t size) |
| Line 70 int sys_lsetxattr(const char *path, const char *name, | Line 103 int sys_lsetxattr(const char *path, const char *name, |
| int sys_lremovexattr(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) | 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 | #elif HAVE_FREEBSD_XATTRS |