extern int am_root;
extern int am_server;
extern int am_daemon;
-@@ -93,6 +94,9 @@ extern iconv_t ic_send, ic_recv;
+@@ -94,6 +95,9 @@ extern iconv_t ic_send, ic_recv;
#define PTR_SIZE (sizeof (struct file_struct *))
int io_error;
int checksum_len;
dev_t filesystem_dev; /* used to implement -x */
-@@ -132,8 +136,13 @@ static char empty_sum[MAX_DIGEST_LEN];
+@@ -133,8 +137,13 @@ static char empty_sum[MAX_DIGEST_LEN];
static int flist_count_offset; /* for --delete --progress */
static int dir_count = 0;
} *csum_cache = NULL;
static void flist_sort_and_clean(struct file_list *flist, int flags);
-@@ -327,7 +336,79 @@ static void flist_done_allocating(struct file_list *flist)
+@@ -363,7 +372,79 @@ static void flist_done_allocating(struct file_list *flist)
flist->pool_boundary = ptr;
}
{
int slot, slots = am_sender ? 1 : basis_dir_cnt + 1;
-@@ -341,6 +422,9 @@ void reset_checksum_cache()
+@@ -377,6 +458,9 @@ void reset_checksum_cache()
struct file_list *flist = csum_cache[slot].flist;
if (flist) {
/* Reset the pool memory and empty the file-list array. */
pool_free_old(flist->file_pool,
pool_boundary(flist->file_pool, 0));
-@@ -351,6 +435,10 @@ void reset_checksum_cache()
+@@ -387,6 +471,10 @@ void reset_checksum_cache()
flist->low = 0;
flist->high = -1;
flist->next = NULL;
}
}
-@@ -359,7 +447,7 @@ void reset_checksum_cache()
+@@ -394,7 +482,7 @@ void reset_checksum_cache()
static int add_checksum(struct file_list *flist, const char *dirname,
const char *basename, int basename_len, OFF_T file_length,
time_t mtime, uint32 ctime, uint32 inode,
{
struct file_struct *file;
int alloc_len, extra_len;
-@@ -375,7 +463,7 @@ static int add_checksum(struct file_list *flist, const char *dirname,
+@@ -411,7 +499,7 @@ static int add_checksum(struct file_list *flist, const char *dirname,
if (extra_len & (EXTRA_ROUNDING * EXTRA_LEN))
extra_len = (extra_len | (EXTRA_ROUNDING * EXTRA_LEN)) + EXTRA_LEN;
#endif
bp = pool_alloc(flist->file_pool, alloc_len, "add_checksum");
memset(bp, 0, extra_len + FILE_STRUCT_LEN);
-@@ -384,7 +472,14 @@ static int add_checksum(struct file_list *flist, const char *dirname,
+@@ -420,7 +508,14 @@ static int add_checksum(struct file_list *flist, const char *dirname,
bp += FILE_STRUCT_LEN;
memcpy(bp, basename, basename_len);
file->mode = S_IFREG;
file->modtime = mtime;
file->len32 = (uint32)file_length;
-@@ -413,10 +508,11 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -449,10 +544,11 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
char line[MAXPATHLEN+1024], fbuf[MAXPATHLEN], sum[MAX_DIGEST_LEN];
FILE *fp;
char *cp;
+ const char *alt_sum = NULL;
int dlen = dirname ? strlcpy(fbuf, dirname, sizeof fbuf) : 0;
- if (dlen >= (int)(sizeof fbuf - sizeof RSYNCSUMS_FILE))
-@@ -437,7 +533,7 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+ if (dlen >= (int)(sizeof fbuf - 1 - RSYNCSUMS_LEN))
+@@ -473,7 +569,7 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
while (fgets(line, sizeof line, fp)) {
cp = line;
if (protocol_version >= 30) {
if (*cp == '=')
while (*++cp == '=') {}
else
-@@ -448,7 +544,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -484,7 +580,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
}
if (*cp == '=') {
} else {
for (i = 0; i < checksum_len*2; i++, cp++) {
int x;
-@@ -466,13 +569,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -502,13 +605,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
else
sum[i/2] = x << 4;
}
if (*cp == '=')
while (*++cp == '=') {}
else
-@@ -522,24 +626,112 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -558,24 +662,112 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
continue;
strlcpy(fbuf+dlen, cp, sizeof fbuf - dlen);
read_checksums(slot, flist, file->dirname);
}
-@@ -551,12 +743,31 @@ void get_cached_checksum(int slot, const char *fname, struct file_struct *file,
+@@ -587,12 +779,31 @@ void get_cached_checksum(int slot, const char *fname, struct file_struct *file,
&& (checksum_files & CSF_LAX
|| (F_CTIME(fp) == (uint32)stp->st_ctime
&& F_INODE(fp) == (uint32)stp->st_ino))) {
}
int push_pathname(const char *dir, int len)
-@@ -1343,6 +1554,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1378,6 +1589,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
if (is_excluded(thisname, S_ISDIR(st.st_mode) != 0, filter_level)) {
if (ignore_perishable)
non_perishable_cnt++;
return NULL;
}
-@@ -1383,13 +1596,13 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1424,13 +1637,13 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
lastdir[len] = '\0';
lastdir_len = len;
if (checksum_files && am_sender && flist)
}
}
basename_len = strlen(basename) + 1; /* count the '\0' */
-@@ -1471,7 +1684,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1512,7 +1725,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
if (always_checksum && am_sender && S_ISREG(st.st_mode)) {
if (flist && checksum_files)
else
file_checksum(thisname, st.st_size, tmp_sum);
}
-@@ -1768,6 +1981,9 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
+@@ -1804,6 +2017,9 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
closedir(d);
if (f >= 0 && recurse && !divert_dirs) {
int i, end = flist->used - 1;
/* send_if_directory() bumps flist->used, so use "end". */
-@@ -2333,6 +2549,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
+@@ -2389,6 +2605,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
}
} else
flist_eof = 1;
diff --git a/generator.c b/generator.c
--- a/generator.c
+++ b/generator.c
-@@ -114,6 +114,7 @@ static int lull_mod;
- static int dir_tweaking;
+@@ -114,6 +114,7 @@ static int dir_tweaking;
+ static int symlink_timeset_failed_flags;
static int need_retouch_dir_times;
static int need_retouch_dir_perms;
+static int started_whole_dir, upcoming_whole_dir;
static const char *solo_file = NULL;
/* For calling delete_item() and delete_dir_contents(). */
-@@ -705,7 +706,7 @@ int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st, int slot
+@@ -717,7 +718,7 @@ int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st, int slot
if (always_checksum > 0 && S_ISREG(st->st_mode)) {
char sum[MAX_DIGEST_LEN];
if (checksum_files && slot >= 0)
else
file_checksum(fn, st->st_size, sum);
return memcmp(sum, F_SUM(file), checksum_len) == 0;
-@@ -1328,7 +1329,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1350,7 +1351,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
fuzzy_dirlist = get_dirlist(fnamecmpbuf, -1, 1);
}
if (checksum_files) {
}
need_new_dirscan = 0;
}
-@@ -1457,9 +1459,12 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1488,9 +1490,12 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
DEV_MINOR(devp) = minor(real_sx.st.st_dev);
}
}
-- else if (delete_during && f_out != -1 && !phase && dry_run < 2
-- && (file->flags & FLAG_CONTENT_DIR))
+- else if (delete_during && f_out != -1 && !phase
+- && BITS_SETnUNSET(file->flags, FLAG_CONTENT_DIR, FLAG_MISSING_DIR))
- delete_in_dir(fname, file, &real_sx.st.st_dev);
+ else if (file->flags & FLAG_CONTENT_DIR && f_out != -1) {
-+ if (delete_during && !phase && dry_run < 2)
++ if (delete_during && !phase && !(file->flags & FLAG_MISSING_DIR))
+ delete_in_dir(fname, file, &real_sx.st.st_dev);
+ upcoming_whole_dir = 1;
+ } else
goto cleanup;
}
-@@ -1757,6 +1762,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1783,6 +1788,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
handle_partial_dir(partialptr, PDIR_DELETE);
}
set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT);
if (itemizing)
itemize(fnamecmp, file, ndx, statret, &sx, 0, 0, NULL);
#ifdef SUPPORT_HARD_LINKS
-@@ -2132,6 +2139,7 @@ void generate_files(int f_out, const char *local_name)
+@@ -2195,6 +2202,7 @@ void generate_files(int f_out, const char *local_name)
delete_in_dir(f_name(fp, fbuf), fp, &dirdev);
}
}
}
for (i = cur_flist->low; i <= cur_flist->high; i++) {
struct file_struct *file = cur_flist->sorted[i];
-@@ -2212,6 +2220,9 @@ void generate_files(int f_out, const char *local_name)
+@@ -2275,6 +2283,9 @@ void generate_files(int f_out, const char *local_name)
wait_for_receiver();
}
diff --git a/io.c b/io.c
--- a/io.c
+++ b/io.c
-@@ -49,6 +49,7 @@ extern int read_batch;
+@@ -50,6 +50,7 @@ extern int read_batch;
extern int csum_length;
extern int protect_args;
extern int checksum_seed;
extern int protocol_version;
extern int remove_source_files;
extern int preserve_hard_links;
-@@ -200,6 +201,9 @@ static void got_flist_entry_status(enum festatus status, const char *buf)
+@@ -205,6 +206,9 @@ static void got_flist_entry_status(enum festatus status, const char *buf)
flist_ndx_push(&hlink_list, ndx);
flist->in_progress++;
}
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -1217,7 +1217,15 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1233,7 +1233,15 @@ int parse_arguments(int *argc_p, const char ***argv_p)
case OPT_SUMFILES:
arg = poptGetOptArg(pc);
diff --git a/rsync.h b/rsync.h
--- a/rsync.h
+++ b/rsync.h
-@@ -864,6 +864,8 @@ typedef struct {
+@@ -866,6 +866,8 @@ typedef struct {
#define CSF_ENABLE (1<<1)
#define CSF_LAX (1<<2)