X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/9935066b704bcf2e6e48dac85cb1b4047d8f439d..2b284ee33d97c4414c49c45720a3566a58a93a18:/flist.c diff --git a/flist.c b/flist.c index 19931a5f..6a11d0f9 100644 --- a/flist.c +++ b/flist.c @@ -33,6 +33,7 @@ extern int verbose; extern int do_progress; extern int am_root; extern int am_server; +extern int am_daemon; extern int always_checksum; extern int module_id; extern int ignore_errors; @@ -46,7 +47,6 @@ extern char *files_from; extern int filesfrom_fd; extern int one_file_system; -extern int make_backups; extern int preserve_links; extern int preserve_hard_links; extern int preserve_perms; @@ -81,7 +81,7 @@ void init_flist(void) struct file_struct f; /* Figure out how big the file_struct is without trailing padding */ - file_struct_len = ((char*)&f.flags - (char*)&f) + sizeof f.flags; + file_struct_len = offsetof(struct file_struct, flags) + sizeof f.flags; } @@ -361,7 +361,7 @@ void send_file_entry(struct file_struct *file, int f, unsigned short base_flags) /* Set both flags to simplify the test * when writing the data. */ flags |= XMIT_SAME_RDEV_pre28 - | XMIT_SAME_HIGH_RDEV; + | XMIT_SAME_HIGH_RDEV; } else rdev = file->u.rdev; } else @@ -400,8 +400,8 @@ void send_file_entry(struct file_struct *file, int f, unsigned short base_flags) #endif for (l1 = 0; - lastname[l1] && (fname[l1] == lastname[l1]) && (l1 < 255); - l1++) {} + lastname[l1] && (fname[l1] == lastname[l1]) && (l1 < 255); + l1++) {} l2 = strlen(fname+l1); if (l1 > 0) @@ -494,8 +494,8 @@ void send_file_entry(struct file_struct *file, int f, unsigned short base_flags) } else sum = NULL; if (sum) { - write_buf(f, sum, protocol_version < 21? 2 - : MD4_SUM_LENGTH); + write_buf(f, sum, + protocol_version < 21 ? 2 : MD4_SUM_LENGTH); } } @@ -659,10 +659,8 @@ void receive_file_entry(struct file_struct **fptr, unsigned short flags, #if SUPPORT_HARD_LINKS if (preserve_hard_links && protocol_version < 28 && S_ISREG(mode)) flags |= XMIT_HAS_IDEV_DATA; - if (flags & XMIT_HAS_IDEV_DATA && flist->hlink_pool) { + if (flags & XMIT_HAS_IDEV_DATA) { INO64_T inode; - file->link_u.idev = pool_talloc(flist->hlink_pool, - struct idev, 1, "inode_table"); if (protocol_version < 26) { dev = read_int(f); inode = read_int(f); @@ -672,6 +670,8 @@ void receive_file_entry(struct file_struct **fptr, unsigned short flags, inode = read_longint(f); } if (flist->hlink_pool) { + file->link_u.idev = pool_talloc(flist->hlink_pool, + struct idev, 1, "inode_table"); file->F_INODE = inode; file->F_DEV = dev; } @@ -689,8 +689,8 @@ void receive_file_entry(struct file_struct **fptr, unsigned short flags, } else sum = NULL; if (sum) { - read_buf(f, sum, protocol_version < 21? 2 - : MD4_SUM_LENGTH); + read_buf(f, sum, + protocol_version < 21 ? 2 : MD4_SUM_LENGTH); } } @@ -732,6 +732,8 @@ struct file_struct *make_file(char *fname, char *basename, *dirname, *bp; unsigned short flags = 0; + if (!flist) /* lastdir isn't valid if flist is NULL */ + lastdir_len = -1; if (strlcpy(thisname, fname, sizeof thisname) >= sizeof thisname - flist_dir_len) { @@ -746,18 +748,26 @@ struct file_struct *make_file(char *fname, if (readlink_stat(thisname, &st, linkname) != 0) { int save_errno = errno; - if (errno == ENOENT && exclude_level != NO_EXCLUDES) { + if (errno == ENOENT) { + enum logcode c = am_daemon && protocol_version < 28 + ? FERROR : FINFO; /* either symlink pointing nowhere or file that * was removed during rsync run; see if excluded * before reporting an error */ - if (check_exclude_file(thisname, 0, exclude_level)) { + if (exclude_level != NO_EXCLUDES + && check_exclude_file(thisname, 0, exclude_level)) { /* file is excluded anyway, ignore silently */ return NULL; } + io_error |= IOERR_VANISHED; + rprintf(c, "file has vanished: %s\n", + full_fname(thisname)); + } + else { + io_error |= IOERR_GENERAL; + rprintf(FERROR, "readlink %s failed: %s\n", + full_fname(thisname), strerror(save_errno)); } - io_error |= IOERR_GENERAL; - rprintf(FERROR, "readlink %s failed: %s\n", - full_fname(thisname), strerror(save_errno)); return NULL; } @@ -783,7 +793,7 @@ struct file_struct *make_file(char *fname, if (lp_ignore_nonreadable(module_id) && access(thisname, R_OK) != 0) return NULL; - skip_excludes: +skip_excludes: if (verbose > 2) { rprintf(FINFO, "[%s] make_file(%s,*,%d)\n", @@ -1175,8 +1185,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) finish_filelist_progress(flist); } - if (flist->hlink_pool) - { + if (flist->hlink_pool) { pool_destroy(flist->hlink_pool); flist->hlink_pool = NULL; } @@ -1291,7 +1300,7 @@ struct file_list *recv_file_list(int f) return flist; - oom: +oom: out_of_memory("recv_file_list"); return NULL; /* not reached */ } @@ -1370,7 +1379,7 @@ struct file_list *flist_new(int with_hlink, char *msg) #if SUPPORT_HARD_LINKS if (with_hlink && preserve_hard_links) { - if (!(flist->hlink_pool = pool_create(HLINK_EXTENT, + if (!(flist->hlink_pool = pool_create(HLINK_EXTENT, sizeof (struct idev), out_of_memory, POOL_INTERN))) out_of_memory(msg); } @@ -1403,7 +1412,7 @@ static void clean_flist(struct file_list *flist, int strip_root, int no_dups) return; qsort(flist->files, flist->count, - sizeof flist->files[0], (int (*)()) file_compare); + sizeof flist->files[0], (int (*)()) file_compare); for (i = no_dups? 0 : flist->count; i < flist->count; i++) { if (flist->files[i]->basename) {