version 1.1.1.3, 2016/11/01 09:54:32
|
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-2015 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 |
#ifdef HAVE_OSX_XATTRS |
|
#ifndef XATTR_SHOWCOMPRESSION |
|
#define XATTR_SHOWCOMPRESSION 0x0020 |
|
#endif |
#define GETXATTR_FETCH_LIMIT (64*1024*1024) |
#define GETXATTR_FETCH_LIMIT (64*1024*1024) |
|
|
|
int xattr_options = XATTR_NOFOLLOW; |
#endif |
#endif |
|
|
#if defined HAVE_LINUX_XATTRS |
#if defined HAVE_LINUX_XATTRS |
Line 59 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) |
{ |
{ |
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 we're retrieving data, handle resource forks > 64MB specially */ |
if (value != NULL && len == GETXATTR_FETCH_LIMIT && (size_t)len < size) { |
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 */ |
/* getxattr will only return 64MB of data at a time, need to call again with a new offset */ |
u_int32_t offset = len; |
u_int32_t offset = len; |
size_t data_retrieved = len; |
size_t data_retrieved = len; |
while (data_retrieved < size) { |
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) |
if (len <= 0) |
break; |
break; |
data_retrieved += len; |
data_retrieved += len; |
Line 91 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 |