summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generator.c63
-rw-r--r--hlink.c5
-rw-r--r--io.c4
-rw-r--r--log.c40
-rw-r--r--receiver.c25
-rw-r--r--sender.c2
6 files changed, 72 insertions, 67 deletions
diff --git a/generator.c b/generator.c
index 4ec4ac74..71bd5a72 100644
--- a/generator.c
+++ b/generator.c
@@ -50,7 +50,6 @@ extern int delete_during;
extern int delete_after;
extern int module_id;
extern int ignore_errors;
-extern int flist_extra_ndx;
extern int remove_source_files;
extern int delay_updates;
extern int update_only;
@@ -86,7 +85,6 @@ extern long block_size; /* "long" because popt can't set an int32. */
extern int max_delete;
extern int force_delete;
extern int one_file_system;
-extern int file_struct_len;
extern struct stats stats;
extern dev_t filesystem_dev;
extern char *backup_dir;
@@ -246,7 +244,7 @@ static enum delret delete_dir_contents(char *fname, int flags)
continue;
}
- strlcpy(p, fp->basename, remainder);
+ strlcpy(p, F_BASENAME(fp), remainder);
/* Save stack by recursing to ourself directly. */
if (S_ISDIR(fp->mode)
&& delete_dir_contents(fname, flags | DEL_RECURSE) != DR_SUCCESS)
@@ -393,7 +391,7 @@ static void delete_in_dir(struct file_list *flist, char *fbuf,
* from the filesystem. */
for (i = dirlist->count; i--; ) {
struct file_struct *fp = dirlist->files[i];
- if (!fp->basename)
+ if (!F_IS_ACTIVE(fp))
continue;
if (fp->flags & FLAG_MOUNT_DIR) {
if (verbose > 1)
@@ -470,7 +468,7 @@ void itemize(struct file_struct *file, int ndx, int statret, STRUCT_STAT *st,
: S_ISDIR(file->mode) ? !omit_dir_times
: !S_ISLNK(file->mode);
- if (S_ISREG(file->mode) && file->length != st->st_size)
+ if (S_ISREG(file->mode) && F_LENGTH(file) != st->st_size)
iflags |= ITEM_REPORT_SIZE;
if ((iflags & (ITEM_TRANSFER|ITEM_LOCAL_CHANGE) && !keep_time
&& !(iflags & ITEM_MATCHED)
@@ -509,7 +507,7 @@ void itemize(struct file_struct *file, int ndx, int statret, STRUCT_STAT *st,
/* Perform our quick-check heuristic for determining if a file is unchanged. */
int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
{
- if (st->st_size != file->length)
+ if (st->st_size != F_LENGTH(file))
return 0;
/* if always checksum is set then we use the checksum instead
@@ -666,7 +664,7 @@ static void generate_and_send_sums(int fd, OFF_T len, int f_out, int f_copy)
static int find_fuzzy(struct file_struct *file, struct file_list *dirlist)
{
int fname_len, fname_suf_len;
- const char *fname_suf, *fname = file->basename;
+ const char *fname_suf, *fname = F_BASENAME(file);
uint32 lowest_dist = 25 << 16; /* ignore a distance greater than 25 */
int j, lowest_j = -1;
@@ -679,12 +677,12 @@ static int find_fuzzy(struct file_struct *file, struct file_list *dirlist)
int len, suf_len;
uint32 dist;
- if (!S_ISREG(fp->mode) || !fp->length || fp->flags & FLAG_SENT)
+ if (!S_ISREG(fp->mode) || !F_LENGTH(fp) || fp->flags & FLAG_SENT)
continue;
- name = fp->basename;
+ name = F_BASENAME(fp);
- if (fp->length == file->length
+ if (F_LENGTH(fp) == F_LENGTH(file)
&& cmp_time(fp->modtime, file->modtime) == 0) {
if (verbose > 4) {
rprintf(FINFO,
@@ -724,7 +722,7 @@ void check_for_finished_hlinks(int itemizing, enum logcode code)
continue;
file = the_file_list->files[ndx];
- if (!IS_HLINKED(file))
+ if (!F_IS_HLINKED(file))
continue;
hard_link_cluster(file, ndx, itemizing, code, -1);
@@ -787,7 +785,7 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
if (hard_link_one(file, ndx, fname, 0, stp,
cmpbuf, 1, i, code) < 0)
goto try_a_copy;
- if (preserve_hard_links && IS_HLINKED(file))
+ if (preserve_hard_links && F_IS_HLINKED(file))
hard_link_cluster(file, ndx, itemizing, code, j);
} else
#endif
@@ -818,7 +816,7 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
rprintf(code, "%s%s\n", fname,
match_level == 3 ? " is uptodate" : "");
}
- if (preserve_hard_links && IS_HLINKED(file))
+ if (preserve_hard_links && F_IS_HLINKED(file))
hard_link_cluster(file, ndx, itemizing, code, j);
return -2;
}
@@ -943,7 +941,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
cmpbuf, fname);
return j;
}
- if (preserve_hard_links && IS_HLINKED(file))
+ if (preserve_hard_links && F_IS_HLINKED(file))
hard_link_cluster(file, ndx, itemizing, code, -1);
} else
#endif
@@ -1157,7 +1155,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
return;
}
- if (preserve_hard_links && IS_HLINKED(file)
+ if (preserve_hard_links && F_IS_HLINKED(file)
&& hard_link_check(file, ndx, fname, statret, &st,
itemizing, code, HL_CHECK_MASTER))
return;
@@ -1187,7 +1185,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
if (itemizing)
itemize(file, ndx, 0, &st, 0, 0, NULL);
set_file_attrs(fname, file, &st, maybe_ATTRS_REPORT);
- if (preserve_hard_links && IS_HLINKED(file))
+ if (preserve_hard_links && F_IS_HLINKED(file))
hard_link_cluster(file, ndx, itemizing, code, -1);
if (remove_source_files == 1)
goto return_with_success;
@@ -1213,7 +1211,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
} else if (j >= 0)
statret = 1;
}
- if (preserve_hard_links && IS_HLINKED(file)
+ if (preserve_hard_links && F_IS_HLINKED(file)
&& hard_link_check(file, ndx, fname, -1, &st,
itemizing, code, HL_SKIP))
return;
@@ -1228,7 +1226,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
}
if (code != FNONE && verbose)
rprintf(code, "%s -> %s\n", fname, sl);
- if (preserve_hard_links && IS_HLINKED(file))
+ if (preserve_hard_links && F_IS_HLINKED(file))
hard_link_cluster(file, ndx, itemizing, code, -1);
/* This does not check remove_source_files == 1
* because this is one of the items that the old
@@ -1261,7 +1259,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
if (itemizing)
itemize(file, ndx, 0, &st, 0, 0, NULL);
set_file_attrs(fname, file, &st, maybe_ATTRS_REPORT);
- if (preserve_hard_links && IS_HLINKED(file))
+ if (preserve_hard_links && F_IS_HLINKED(file))
hard_link_cluster(file, ndx, itemizing, code, -1);
if (remove_source_files == 1)
goto return_with_success;
@@ -1285,7 +1283,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
} else if (j >= 0)
statret = 1;
}
- if (preserve_hard_links && IS_HLINKED(file)
+ if (preserve_hard_links && F_IS_HLINKED(file)
&& hard_link_check(file, ndx, fname, -1, &st,
itemizing, code, HL_SKIP))
return;
@@ -1304,7 +1302,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
}
if (code != FNONE && verbose)
rprintf(code, "%s\n", fname);
- if (preserve_hard_links && IS_HLINKED(file))
+ if (preserve_hard_links && F_IS_HLINKED(file))
hard_link_cluster(file, ndx, itemizing, code, -1);
if (remove_source_files == 1)
goto return_with_success;
@@ -1319,7 +1317,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
return;
}
- if (max_size && file->length > max_size) {
+ if (max_size && F_LENGTH(file) > max_size) {
if (verbose > 1) {
if (the_file_list->count == 1)
fname = f_name(file, NULL);
@@ -1327,7 +1325,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
}
return;
}
- if (min_size && file->length < min_size) {
+ if (min_size && F_LENGTH(file) < min_size) {
if (verbose > 1) {
if (the_file_list->count == 1)
fname = f_name(file, NULL);
@@ -1394,7 +1392,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
rprintf(FINFO, "fuzzy basis selected for %s: %s\n",
fname, fnamecmpbuf);
}
- st.st_size = fuzzy_file->length;
+ st.st_size = F_LENGTH(fuzzy_file);
statret = 0;
fnamecmp = fnamecmpbuf;
fnamecmp_type = FNAMECMP_FUZZY;
@@ -1402,7 +1400,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
}
if (statret != 0) {
- if (preserve_hard_links && IS_HLINKED(file)
+ if (preserve_hard_links && F_IS_HLINKED(file)
&& hard_link_check(file, ndx, fname, statret, &st,
itemizing, code, HL_SKIP))
return;
@@ -1413,7 +1411,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
return;
}
- if (append_mode && st.st_size > file->length)
+ if (append_mode && st.st_size > F_LENGTH(file))
return;
if (fnamecmp_type <= FNAMECMP_BASIS_DIR_HIGH)
@@ -1430,7 +1428,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
0, 0, NULL);
}
set_file_attrs(fname, file, &st, maybe_ATTRS_REPORT);
- if (preserve_hard_links && IS_HLINKED(file))
+ if (preserve_hard_links && F_IS_HLINKED(file))
hard_link_cluster(file, ndx, itemizing, code, -1);
if (remove_source_files != 1)
return;
@@ -1465,7 +1463,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
full_fname(fnamecmp));
pretend_missing:
/* pretend the file didn't exist */
- if (preserve_hard_links && IS_HLINKED(file)
+ if (preserve_hard_links && F_IS_HLINKED(file)
&& hard_link_check(file, ndx, fname, statret, &st,
itemizing, code, HL_SKIP))
return;
@@ -1521,11 +1519,11 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
if (fnamecmp_type == FNAMECMP_FUZZY)
iflags |= ITEM_XNAME_FOLLOWS;
itemize(file, -1, real_ret, &real_st, iflags, fnamecmp_type,
- fuzzy_file ? fuzzy_file->basename : NULL);
+ fuzzy_file ? F_BASENAME(fuzzy_file) : NULL);
}
if (!do_xfers) {
- if (preserve_hard_links && IS_HLINKED(file))
+ if (preserve_hard_links && F_IS_HLINKED(file))
hard_link_cluster(file, ndx, itemizing, code, -1);
return;
}
@@ -1614,7 +1612,7 @@ void generate_files(int f_out, struct file_list *flist, char *local_name)
for (i = 0; i < flist->count; i++) {
struct file_struct *file = flist->files[i];
- if (!file->basename)
+ if (!F_IS_ACTIVE(file))
continue;
if (local_name)
@@ -1718,8 +1716,7 @@ void generate_files(int f_out, struct file_list *flist, char *local_name)
* modified-time values. */
for (i = 0; i < flist->count; i++) {
struct file_struct *file = flist->files[i];
-
- if (!file->basename || !S_ISDIR(file->mode))
+ if (!F_IS_ACTIVE(file) || !S_ISDIR(file->mode))
continue;
if (!need_retouch_dir_times && file->mode & S_IWUSR)
continue;
diff --git a/hlink.c b/hlink.c
index 8ef8c2ab..2a22d270 100644
--- a/hlink.c
+++ b/hlink.c
@@ -28,7 +28,6 @@ extern int dry_run;
extern int do_xfers;
extern int link_dest;
extern int make_backups;
-extern int flist_extra_ndx;
extern int remove_source_files;
extern int stdout_format_has_i;
extern char *basis_dir[];
@@ -106,7 +105,7 @@ static void link_idev_data(void)
file->flags |= FLAG_HLINK_LAST;
F_HLIST(file) = hl;
} else
- file->flags &= ~FLAG_HLINK_INFO;
+ file->flags &= ~FLAG_HLINKED;
}
if (!to) {
@@ -138,7 +137,7 @@ void init_hard_links(void)
hlink_count = 0;
for (i = 0; i < the_file_list->count; i++) {
- if (IS_HLINKED(FPTR(i)))
+ if (F_IS_HLINKED(FPTR(i)))
hlink_list[hlink_count++] = i;
}
diff --git a/io.c b/io.c
index 33a0e654..05a755fb 100644
--- a/io.c
+++ b/io.c
@@ -342,13 +342,13 @@ void increment_active_files(int ndx, int itemizing, enum logcode code)
}
active_filecnt++;
- active_bytecnt += the_file_list->files[ndx]->length;
+ active_bytecnt += F_LENGTH(the_file_list->files[ndx]);
}
void decrement_active_files(int ndx)
{
active_filecnt--;
- active_bytecnt -= the_file_list->files[ndx]->length;
+ active_bytecnt -= F_LENGTH(the_file_list->files[ndx]);
}
/* Try to push messages off the list onto the wire. If we leave with more
diff --git a/log.c b/log.c
index 79c3f299..6bc831ca 100644
--- a/log.c
+++ b/log.c
@@ -39,8 +39,6 @@ extern int protocol_version;
extern int preserve_times;
extern int preserve_uid;
extern int preserve_gid;
-extern int flist_extra_ndx;
-extern int file_struct_len;
extern int stdout_format_has_i;
extern int stdout_format_has_o_or_i;
extern int logfile_format_has_i;
@@ -427,8 +425,9 @@ void rflush(enum logcode code)
/* A generic logging routine for send/recv, with parameter substitiution. */
static void log_formatted(enum logcode code, const char *format, const char *op,
- struct file_struct *file, struct stats *initial_stats,
- int iflags, const char *hlink)
+ struct file_struct *file, const char *fname,
+ struct stats *initial_stats, int iflags,
+ const char *hlink)
{
char buf[MAXPATHLEN+1024], buf2[MAXPATHLEN], fmt[32];
char *p, *s, *c;
@@ -473,7 +472,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
case 'l':
strlcat(fmt, ".0f", sizeof fmt);
snprintf(buf2, sizeof buf2, fmt,
- (double)file->length);
+ (double)F_LENGTH(file));
n = buf2;
break;
case 'U':
@@ -512,7 +511,11 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
n = op;
break;
case 'f':
- c = f_name(file, NULL);
+ if (fname) {
+ c = f_name_buf();
+ strlcpy(c, fname, MAXPATHLEN);
+ } else
+ c = f_name(file, NULL);
if (am_sender && file->dir.root) {
pathjoin(buf2, sizeof buf2,
file->dir.root, c);
@@ -539,7 +542,11 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
n++;
break;
case 'n':
- c = f_name(file, NULL);
+ if (fname) {
+ c = f_name_buf();
+ strlcpy(c, fname, MAXPATHLEN);
+ } else
+ c = f_name(file, NULL);
if (S_ISDIR(file->mode))
strlcat(c, "/", MAXPATHLEN);
n = c;
@@ -548,7 +555,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
if (hlink && *hlink) {
n = hlink;
strlcpy(buf2, " => ", sizeof buf2);
- } else if (S_ISLNK(file->mode)) {
+ } else if (S_ISLNK(file->mode) && !fname) {
n = F_SYMLINK(file);
strlcpy(buf2, " -> ", sizeof buf2);
} else {
@@ -708,11 +715,11 @@ void log_item(enum logcode code, struct file_struct *file,
if (code != FLOG && stdout_format && !am_server) {
log_formatted(FCLIENT, stdout_format, s_or_r,
- file, initial_stats, iflags, hlink);
+ file, NULL, initial_stats, iflags, hlink);
}
if (code != FCLIENT && logfile_format && *logfile_format) {
log_formatted(FLOG, logfile_format, s_or_r,
- file, initial_stats, iflags, hlink);
+ file, NULL, initial_stats, iflags, hlink);
}
}
@@ -736,12 +743,15 @@ void maybe_log_item(struct file_struct *file, int iflags, int itemizing,
void log_delete(const char *fname, int mode)
{
- static struct file_struct file;
+ static struct {
+ union flist_extras ex[4]; /* just in case... */
+ struct file_struct file;
+ char basename[1];
+ } x;
int len = strlen(fname);
const char *fmt;
- file.mode = mode;
- file.basename = fname;
+ x.file.mode = mode;
if (!verbose && !stdout_format)
;
@@ -751,7 +761,7 @@ void log_delete(const char *fname, int mode)
send_msg(MSG_DELETED, fname, len);
} else {
fmt = stdout_format_has_o_or_i ? stdout_format : "deleting %n";
- log_formatted(FCLIENT, fmt, "del.", &file, &stats,
+ log_formatted(FCLIENT, fmt, "del.", &x.file, fname, &stats,
ITEM_DELETED, NULL);
}
@@ -759,7 +769,7 @@ void log_delete(const char *fname, int mode)
return;
fmt = logfile_format_has_o_or_i ? logfile_format : "deleting %n";
- log_formatted(FLOG, fmt, "del.", &file, &stats, ITEM_DELETED, NULL);
+ log_formatted(FLOG, fmt, "del.", &x.file, fname, &stats, ITEM_DELETED, NULL);
}
/*
diff --git a/receiver.c b/receiver.c
index 43d1be36..e3b79c39 100644
--- a/receiver.c
+++ b/receiver.c
@@ -39,7 +39,6 @@ extern int preserve_hard_links;
extern int preserve_perms;
extern int basis_dir_cnt;
extern int make_backups;
-extern int flist_extra_ndx;
extern int cleanup_got_literal;
extern int remove_source_files;
extern int append_mode;
@@ -301,7 +300,7 @@ static void handle_delayed_updates(struct file_list *flist, char *local_name)
full_fname(fname), partialptr);
} else {
if (remove_source_files
- || (preserve_hard_links && IS_HLINKED(file)))
+ || (preserve_hard_links && F_IS_HLINKED(file)))
send_msg_int(MSG_SUCCESS, i);
handle_partial_dir(partialptr, PDIR_DELETE);
}
@@ -414,7 +413,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
stats.current_file_index = i;
stats.num_transferred_files++;
- stats.total_transferred_size += file->length;
+ stats.total_transferred_size += F_LENGTH(file);
cleanup_got_literal = 0;
if (server_filter_list.head
@@ -426,13 +425,13 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
if (!do_xfers) { /* log the transfer */
log_item(FCLIENT, file, &stats, iflags, NULL);
if (read_batch)
- discard_receive_data(f_in, file->length);
+ discard_receive_data(f_in, F_LENGTH(file));
continue;
}
if (write_batch < 0) {
log_item(FINFO, file, &stats, iflags, NULL);
if (!am_server)
- discard_receive_data(f_in, file->length);
+ discard_receive_data(f_in, F_LENGTH(file));
continue;
}
@@ -442,7 +441,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
rprintf(FINFO,
"(Skipping batched update for \"%s\")\n",
fname);
- discard_receive_data(f_in, file->length);
+ discard_receive_data(f_in, F_LENGTH(file));
continue;
}
next_gen_i = -1;
@@ -524,7 +523,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
} else if (do_fstat(fd1,&st) != 0) {
rsyserr(FERROR, errno, "fstat %s failed",
full_fname(fnamecmp));
- discard_receive_data(f_in, file->length);
+ discard_receive_data(f_in, F_LENGTH(file));
close(fd1);
continue;
}
@@ -537,7 +536,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
*/
rprintf(FERROR,"recv_files: %s is a directory\n",
full_fname(fnamecmp));
- discard_receive_data(f_in, file->length);
+ discard_receive_data(f_in, F_LENGTH(file));
close(fd1);
continue;
}
@@ -560,14 +559,14 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
if (fd2 == -1) {
rsyserr(FERROR, errno, "open %s failed",
full_fname(fname));
- discard_receive_data(f_in, file->length);
+ discard_receive_data(f_in, F_LENGTH(file));
if (fd1 != -1)
close(fd1);
continue;
}
} else {
if (!get_tmpname(fnametmp,fname)) {
- discard_receive_data(f_in, file->length);
+ discard_receive_data(f_in, F_LENGTH(file));
if (fd1 != -1)
close(fd1);
continue;
@@ -593,7 +592,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
if (fd2 == -1) {
rsyserr(FERROR, errno, "mkstemp %s failed",
full_fname(fnametmp));
- discard_receive_data(f_in, file->length);
+ discard_receive_data(f_in, F_LENGTH(file));
if (fd1 != -1)
close(fd1);
continue;
@@ -610,7 +609,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
/* recv file data */
recv_ok = receive_data(f_in, fnamecmp, fd1, st.st_size,
- fname, fd2, file->length);
+ fname, fd2, F_LENGTH(file));
log_item(log_code, file, &initial_stats, iflags, NULL);
@@ -653,7 +652,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
if (recv_ok > 0) {
if (remove_source_files
- || (preserve_hard_links && IS_HLINKED(file)))
+ || (preserve_hard_links && F_IS_HLINKED(file)))
send_msg_int(MSG_SUCCESS, i);
} else if (!recv_ok) {
enum logcode msgtype = phase || read_batch ? FERROR : FINFO;
diff --git a/sender.c b/sender.c
index 0dff9e04..eee2a029 100644
--- a/sender.c
+++ b/sender.c
@@ -230,7 +230,7 @@ void send_files(struct file_list *flist, int f_out, int f_in)
stats.current_file_index = i;
stats.num_transferred_files++;
- stats.total_transferred_size += file->length;
+ stats.total_transferred_size += F_LENGTH(file);
if (!do_xfers) { /* log the transfer */
log_item(FCLIENT, file, &stats, iflags, NULL);