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
If the system's popt.h file is not found, use our provided popt code.
[rsync/rsync.git]
/
flist.c
diff --git
a/flist.c
b/flist.c
index
2035045
..
dd3b3b1
100644
(file)
--- a/
flist.c
+++ b/
flist.c
@@
-4,7
+4,7
@@
* Copyright (C) 1996 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
* Copyright (C) 1996 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
- * Copyright (C) 2002-200
7
Wayne Davison
+ * Copyright (C) 2002-200
8
Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-44,6
+44,8
@@
extern int filesfrom_fd;
extern int one_file_system;
extern int copy_dirlinks;
extern int keep_dirlinks;
extern int one_file_system;
extern int copy_dirlinks;
extern int keep_dirlinks;
+extern int preserve_uid;
+extern int preserve_gid;
extern int preserve_acls;
extern int preserve_xattrs;
extern int preserve_links;
extern int preserve_acls;
extern int preserve_xattrs;
extern int preserve_links;
@@
-422,24
+424,24
@@
static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
}
} else if (protocol_version < 28)
rdev = MAKEDEV(0, 0);
}
} else if (protocol_version < 28)
rdev = MAKEDEV(0, 0);
- if (
uid_ndx
) {
+ if (
preserve_uid
) {
if ((uid_t)F_OWNER(file) == uid && *lastname)
xflags |= XMIT_SAME_UID;
else {
uid = F_OWNER(file);
if ((uid_t)F_OWNER(file) == uid && *lastname)
xflags |= XMIT_SAME_UID;
else {
uid = F_OWNER(file);
- if (
uid_ndx &&
!numeric_ids) {
+ if (!numeric_ids) {
user_name = add_uid(uid);
if (inc_recurse && user_name)
xflags |= XMIT_USER_NAME_FOLLOWS;
}
}
}
user_name = add_uid(uid);
if (inc_recurse && user_name)
xflags |= XMIT_USER_NAME_FOLLOWS;
}
}
}
- if (
gid_ndx
) {
+ if (
preserve_gid
) {
if ((gid_t)F_GROUP(file) == gid && *lastname)
xflags |= XMIT_SAME_GID;
else {
gid = F_GROUP(file);
if ((gid_t)F_GROUP(file) == gid && *lastname)
xflags |= XMIT_SAME_GID;
else {
gid = F_GROUP(file);
- if (
gid_ndx &&
!numeric_ids) {
+ if (!numeric_ids) {
group_name = add_gid(gid);
if (inc_recurse && group_name)
xflags |= XMIT_GROUP_NAME_FOLLOWS;
group_name = add_gid(gid);
if (inc_recurse && group_name)
xflags |= XMIT_GROUP_NAME_FOLLOWS;
@@
-522,7
+524,7
@@
static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
}
if (!(xflags & XMIT_SAME_MODE))
write_int(f, to_wire_mode(mode));
}
if (!(xflags & XMIT_SAME_MODE))
write_int(f, to_wire_mode(mode));
- if (
uid_ndx
&& !(xflags & XMIT_SAME_UID)) {
+ if (
preserve_uid
&& !(xflags & XMIT_SAME_UID)) {
if (protocol_version < 30)
write_int(f, uid);
else {
if (protocol_version < 30)
write_int(f, uid);
else {
@@
-534,7
+536,7
@@
static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
}
}
}
}
}
}
- if (
gid_ndx
&& !(xflags & XMIT_SAME_GID)) {
+ if (
preserve_gid
&& !(xflags & XMIT_SAME_GID)) {
if (protocol_version < 30)
write_int(f, gid);
else {
if (protocol_version < 30)
write_int(f, gid);
else {
@@
-706,9
+708,9
@@
static struct file_struct *recv_file_entry(struct file_list *flist,
file_length = F_LENGTH(first);
modtime = first->modtime;
mode = first->mode;
file_length = F_LENGTH(first);
modtime = first->modtime;
mode = first->mode;
- if (
uid_ndx
)
+ if (
preserve_uid
)
uid = F_OWNER(first);
uid = F_OWNER(first);
- if (
gid_ndx
)
+ if (
preserve_gid
)
gid = F_GROUP(first);
if ((preserve_devices && IS_DEVICE(mode))
|| (preserve_specials && IS_SPECIAL(mode))) {
gid = F_GROUP(first);
if ((preserve_devices && IS_DEVICE(mode))
|| (preserve_specials && IS_SPECIAL(mode))) {
@@
-745,7
+747,7
@@
static struct file_struct *recv_file_entry(struct file_list *flist,
if (chmod_modes && !S_ISLNK(mode))
mode = tweak_mode(mode, chmod_modes);
if (chmod_modes && !S_ISLNK(mode))
mode = tweak_mode(mode, chmod_modes);
- if (
uid_ndx
&& !(xflags & XMIT_SAME_UID)) {
+ if (
preserve_uid
&& !(xflags & XMIT_SAME_UID)) {
if (protocol_version < 30)
uid = (uid_t)read_int(f);
else {
if (protocol_version < 30)
uid = (uid_t)read_int(f);
else {
@@
-756,7
+758,7
@@
static struct file_struct *recv_file_entry(struct file_list *flist,
uid = match_uid(uid);
}
}
uid = match_uid(uid);
}
}
- if (
gid_ndx
&& !(xflags & XMIT_SAME_GID)) {
+ if (
preserve_gid
&& !(xflags & XMIT_SAME_GID)) {
if (protocol_version < 30)
gid = (gid_t)read_int(f);
else {
if (protocol_version < 30)
gid = (gid_t)read_int(f);
else {
@@
-817,9
+819,9
@@
static struct file_struct *recv_file_entry(struct file_list *flist,
#endif
#ifdef SUPPORT_ACLS
#endif
#ifdef SUPPORT_ACLS
- /*
We need one or two index int32s when we're preserving ACLs
. */
- if (preserve_acls)
- extra_len +=
(S_ISDIR(mode) ? 2 : 1) *
EXTRA_LEN;
+ /*
Directories need an extra int32 for the default ACL
. */
+ if (preserve_acls
&& S_ISDIR(mode)
)
+ extra_len += EXTRA_LEN;
#endif
if (always_checksum && S_ISREG(mode))
#endif
if (always_checksum && S_ISREG(mode))
@@
-852,7
+854,6
@@
static struct file_struct *recv_file_entry(struct file_list *flist,
bp += FILE_STRUCT_LEN;
memcpy(bp, basename, basename_len);
bp += FILE_STRUCT_LEN;
memcpy(bp, basename, basename_len);
- bp += basename_len + linkname_len; /* skip space for symlink too */
#ifdef SUPPORT_HARD_LINKS
if (xflags & XMIT_HLINKED)
#ifdef SUPPORT_HARD_LINKS
if (xflags & XMIT_HLINKED)
@@
-865,9
+866,9
@@
static struct file_struct *recv_file_entry(struct file_list *flist,
OPT_EXTRA(file, 0)->unum = (uint32)(file_length >> 32);
}
file->mode = mode;
OPT_EXTRA(file, 0)->unum = (uint32)(file_length >> 32);
}
file->mode = mode;
- if (
uid_ndx
)
+ if (
preserve_uid
)
F_OWNER(file) = uid;
F_OWNER(file) = uid;
- if (
gid_ndx
) {
+ if (
preserve_gid
) {
F_GROUP(file) = gid;
file->flags |= gid_flags;
}
F_GROUP(file) = gid;
file->flags |= gid_flags;
}
@@
-917,7
+918,7
@@
static struct file_struct *recv_file_entry(struct file_list *flist,
#ifdef SUPPORT_LINKS
if (linkname_len) {
#ifdef SUPPORT_LINKS
if (linkname_len) {
- bp
= (char*)file->basename +
basename_len;
+ bp
+=
basename_len;
if (first_hlink_ndx >= flist->ndx_start) {
struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start];
memcpy(bp, F_SYMLINK(first), linkname_len);
if (first_hlink_ndx >= flist->ndx_start) {
struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start];
memcpy(bp, F_SYMLINK(first), linkname_len);
@@
-1121,8
+1122,14
@@
struct file_struct *make_file(const char *fname, struct file_list *flist,
pool = dir_flist->file_pool;
} else
pool = flist->file_pool;
pool = dir_flist->file_pool;
} else
pool = flist->file_pool;
- } else
+ } else {
+#ifdef SUPPORT_ACLS
+ /* Directories need an extra int32 for the default ACL. */
+ if (preserve_acls && S_ISDIR(st.st_mode))
+ extra_len += EXTRA_LEN;
+#endif
pool = NULL;
pool = NULL;
+ }
if (verbose > 2) {
rprintf(FINFO, "[%s] make_file(%s,*,%d)\n",
if (verbose > 2) {
rprintf(FINFO, "[%s] make_file(%s,*,%d)\n",
@@
-1170,7
+1177,6
@@
struct file_struct *make_file(const char *fname, struct file_list *flist,
bp += FILE_STRUCT_LEN;
memcpy(bp, basename, basename_len);
bp += FILE_STRUCT_LEN;
memcpy(bp, basename, basename_len);
- bp += basename_len + linkname_len; /* skip space for symlink too */
#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links && flist && flist->prev) {
#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links && flist && flist->prev) {
@@
-1199,25
+1205,26
@@
struct file_struct *make_file(const char *fname, struct file_list *flist,
OPT_EXTRA(file, 0)->unum = (uint32)(st.st_size >> 32);
}
file->mode = st.st_mode;
OPT_EXTRA(file, 0)->unum = (uint32)(st.st_size >> 32);
}
file->mode = st.st_mode;
- if (uid_ndx)
+ if (uid_ndx)
/* Check uid_ndx instead of preserve_uid for del support */
F_OWNER(file) = st.st_uid;
F_OWNER(file) = st.st_uid;
- if (gid_ndx)
+ if (gid_ndx)
/* Check gid_ndx instead of preserve_gid for del support */
F_GROUP(file) = st.st_gid;
if (basename != thisname)
file->dirname = lastdir;
#ifdef SUPPORT_LINKS
F_GROUP(file) = st.st_gid;
if (basename != thisname)
file->dirname = lastdir;
#ifdef SUPPORT_LINKS
- if (linkname_len) {
- bp = (char*)file->basename + basename_len;
- memcpy(bp, linkname, linkname_len);
- }
+ if (linkname_len)
+ memcpy(bp + basename_len, linkname, linkname_len);
#endif
if (always_checksum && am_sender && S_ISREG(st.st_mode))
file_checksum(thisname, tmp_sum, st.st_size);
#endif
if (always_checksum && am_sender && S_ISREG(st.st_mode))
file_checksum(thisname, tmp_sum, st.st_size);
- F_PATHNAME(file) = pathname;
+ if (am_sender)
+ F_PATHNAME(file) = pathname;
+ else if (!pool)
+ F_DEPTH(file) = extra_len / EXTRA_LEN;
/* This code is only used by the receiver when it is building
* a list of files for a delete pass. */
/* This code is only used by the receiver when it is building
* a list of files for a delete pass. */
@@
-1253,12
+1260,7
@@
struct file_struct *make_file(const char *fname, struct file_list *flist,
/* Only called for temporary file_struct entries created by make_file(). */
void unmake_file(struct file_struct *file)
{
/* Only called for temporary file_struct entries created by make_file(). */
void unmake_file(struct file_struct *file)
{
- int extra_cnt = file_extra_cnt + LEN64_BUMP(file);
-#if EXTRA_ROUNDING > 0
- if (extra_cnt & EXTRA_ROUNDING)
- extra_cnt = (extra_cnt | EXTRA_ROUNDING) + 1;
-#endif
- free(REQ_EXTRA(file, extra_cnt));
+ free(REQ_EXTRA(file, F_DEPTH(file)));
}
static struct file_struct *send_file_name(int f, struct file_list *flist,
}
static struct file_struct *send_file_name(int f, struct file_list *flist,