Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed "statx" to "stat_x" to try to work around a build problem on AIX.
[rsync/rsync.git]
/
xattrs.c
diff --git
a/xattrs.c
b/xattrs.c
index
f662cf7
..
50748b4
100644
(file)
--- a/
xattrs.c
+++ b/
xattrs.c
@@
-6,8
+6,9
@@
* Copyright (C) 2006, 2007 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* Copyright (C) 2006, 2007 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-15,11
+16,11
@@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ * with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
*/
#include "rsync.h"
+#include "ifuncs.h"
#include "lib/sysxattrs.h"
#ifdef SUPPORT_XATTRS
#include "lib/sysxattrs.h"
#ifdef SUPPORT_XATTRS
@@
-30,6
+31,7
@@
extern int am_sender;
extern int am_generator;
extern int read_only;
extern int list_only;
extern int am_generator;
extern int read_only;
extern int list_only;
+extern int preserve_xattrs;
extern int checksum_seed;
#define RSYNC_XAL_INITIAL 5
extern int checksum_seed;
#define RSYNC_XAL_INITIAL 5
@@
-62,7
+64,6
@@
extern int checksum_seed;
#define RPRE_LEN ((int)sizeof RSYNC_PREFIX - 1)
#define XSTAT_ATTR RSYNC_PREFIX "%stat"
#define RPRE_LEN ((int)sizeof RSYNC_PREFIX - 1)
#define XSTAT_ATTR RSYNC_PREFIX "%stat"
-#define XSTAT_LEN ((int)sizeof XSTAT_ATTR - 1)
typedef struct {
char *datum, *name;
typedef struct {
char *datum, *name;
@@
-89,7
+90,7
@@
static void rsync_xal_free(item_list *xalp)
xalp->count = 0;
}
xalp->count = 0;
}
-void free_xattr(statx *sxp)
+void free_xattr(stat
_
x *sxp)
{
if (!sxp->xattr)
return;
{
if (!sxp->xattr)
return;
@@
-223,8
+224,9
@@
static int rsync_xal_get(const char *fname, item_list *xalp)
continue;
#endif
continue;
#endif
- if (am_root < 0 && name_len == XSTAT_LEN + 1
- && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0)
+ /* No rsync.%FOO attributes are copied w/o 2 -X options. */
+ if (preserve_xattrs < 2 && name_len > RPRE_LEN
+ && name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX))
continue;
datum_len = name_len; /* Pass extra size to get_xattr_data() */
continue;
datum_len = name_len; /* Pass extra size to get_xattr_data() */
@@
-266,7
+268,7
@@
static int rsync_xal_get(const char *fname, item_list *xalp)
}
/* Read the xattr(s) for this filename. */
}
/* Read the xattr(s) for this filename. */
-int get_xattr(const char *fname, statx *sxp)
+int get_xattr(const char *fname, stat
_
x *sxp)
{
sxp->xattr = new(item_list);
*sxp->xattr = empty_xattr;
{
sxp->xattr = new(item_list);
*sxp->xattr = empty_xattr;
@@
-328,7
+330,7
@@
static void rsync_xal_store(item_list *xalp)
}
/* Send the make_xattr()-generated xattr list for this flist entry. */
}
/* Send the make_xattr()-generated xattr list for this flist entry. */
-int send_xattr(statx *sxp, int f)
+int send_xattr(stat
_
x *sxp, int f)
{
int ndx = find_matching_xattr(sxp->xattr);
{
int ndx = find_matching_xattr(sxp->xattr);
@@
-374,7
+376,7
@@
int send_xattr(statx *sxp, int f)
/* Return a flag indicating if we need to change a file's xattrs. If
* "find_all" is specified, also mark any abbreviated xattrs that we
* need so that send_xattr_request() can tell the sender about them. */
/* Return a flag indicating if we need to change a file's xattrs. If
* "find_all" is specified, also mark any abbreviated xattrs that we
* need so that send_xattr_request() can tell the sender about them. */
-int xattr_diff(struct file_struct *file, statx *sxp, int find_all)
+int xattr_diff(struct file_struct *file, stat
_
x *sxp, int find_all)
{
item_list *lst = rsync_xal_l.items;
rsync_xa *snd_rxa, *rec_rxa;
{
item_list *lst = rsync_xal_l.items;
rsync_xa *snd_rxa, *rec_rxa;
@@
-636,8
+638,9
@@
void receive_xattr(struct file_struct *file, int f)
continue;
}
#endif
continue;
}
#endif
- if (am_root < 0 && name_len == XSTAT_LEN + 1
- && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0) {
+ /* No rsync.%FOO attributes are copied w/o 2 -X options. */
+ if (preserve_xattrs < 2 && name_len > RPRE_LEN
+ && name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX)) {
free(ptr);
continue;
}
free(ptr);
continue;
}
@@
-654,9
+657,9
@@
void receive_xattr(struct file_struct *file, int f)
F_XATTR(file) = ndx;
}
F_XATTR(file) = ndx;
}
-/* Turn the xattr data in statx into cached xattr data, setting the index
+/* Turn the xattr data in stat
_
x into cached xattr data, setting the index
* values in the file struct. */
* values in the file struct. */
-void cache_xattr(struct file_struct *file, statx *sxp)
+void cache_xattr(struct file_struct *file, stat
_
x *sxp)
{
int ndx;
{
int ndx;
@@
-671,7
+674,7
@@
void cache_xattr(struct file_struct *file, statx *sxp)
}
static int rsync_xal_set(const char *fname, item_list *xalp,
}
static int rsync_xal_set(const char *fname, item_list *xalp,
- const char *fnamecmp, statx *sxp)
+ const char *fnamecmp, stat
_
x *sxp)
{
rsync_xa *rxas = xalp->items;
ssize_t list_len;
{
rsync_xa *rxas = xalp->items;
ssize_t list_len;
@@
-778,7
+781,7
@@
static int rsync_xal_set(const char *fname, item_list *xalp,
/* Set extended attributes on indicated filename. */
int set_xattr(const char *fname, const struct file_struct *file,
/* Set extended attributes on indicated filename. */
int set_xattr(const char *fname, const struct file_struct *file,
- const char *fnamecmp, statx *sxp)
+ const char *fnamecmp, stat
_
x *sxp)
{
int ndx;
item_list *lst = rsync_xal_l.items;
{
int ndx;
item_list *lst = rsync_xal_l.items;
@@
-886,7
+889,7
@@
int set_stat_xattr(const char *fname, struct file_struct *file)
fst.st_rdev = 0; /* just in case */
if (mode == fmode && fst.st_rdev == rdev
fst.st_rdev = 0; /* just in case */
if (mode == fmode && fst.st_rdev == rdev
- && fst.st_uid == F_
UID(file) && fst.st_gid == F_GID
(file)) {
+ && fst.st_uid == F_
OWNER(file) && fst.st_gid == F_GROUP
(file)) {
/* xst.st_mode will be 0 if there's no current stat xattr */
if (xst.st_mode && sys_lremovexattr(fname, XSTAT_ATTR) < 0) {
rsyserr(FERROR, errno,
/* xst.st_mode will be 0 if there's no current stat xattr */
if (xst.st_mode && sys_lremovexattr(fname, XSTAT_ATTR) < 0) {
rsyserr(FERROR, errno,
@@
-898,12
+901,12
@@
int set_stat_xattr(const char *fname, struct file_struct *file)
}
if (xst.st_mode != fmode || xst.st_rdev != rdev
}
if (xst.st_mode != fmode || xst.st_rdev != rdev
- || xst.st_uid != F_
UID(file) || xst.st_gid != F_GID
(file)) {
+ || xst.st_uid != F_
OWNER(file) || xst.st_gid != F_GROUP
(file)) {
char buf[256];
int len = snprintf(buf, sizeof buf, "%o %u,%u %u:%u",
to_wire_mode(fmode),
(int)major(rdev), (int)minor(rdev),
char buf[256];
int len = snprintf(buf, sizeof buf, "%o %u,%u %u:%u",
to_wire_mode(fmode),
(int)major(rdev), (int)minor(rdev),
-
(int)F_UID(file), (int)F_GID
(file));
+
F_OWNER(file), F_GROUP
(file));
if (sys_lsetxattr(fname, XSTAT_ATTR, buf, len) < 0) {
if (errno == EPERM && S_ISLNK(fst.st_mode))
return 0;
if (sys_lsetxattr(fname, XSTAT_ATTR, buf, len) < 0) {
if (errno == EPERM && S_ISLNK(fst.st_mode))
return 0;