aboutsummaryrefslogtreecommitdiffstats
path: root/flist.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2009-02-14 08:35:57 -0800
committerWayne Davison <wayned@samba.org>2009-02-14 08:35:57 -0800
commitd39d60a129b82d0a2c99104538b2421de07dd67c (patch)
tree0b7d47bbdbc183c3b31f3fa44f1c3abbae590f9d /flist.c
parent49c2407141e85d9e3ce2a507db4c2facb7cd74b5 (diff)
downloadandroid_external_rsync-d39d60a129b82d0a2c99104538b2421de07dd67c.tar.gz
android_external_rsync-d39d60a129b82d0a2c99104538b2421de07dd67c.tar.bz2
android_external_rsync-d39d60a129b82d0a2c99104538b2421de07dd67c.zip
Handle a link_stat() failure with errno ENOENT as a vanished file.
Diffstat (limited to 'flist.c')
-rw-r--r--flist.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/flist.c b/flist.c
index 0fc7851a..2fdff344 100644
--- a/flist.c
+++ b/flist.c
@@ -1627,6 +1627,19 @@ static void add_dirs_to_tree(int parent_ndx, struct file_list *from_flist,
DIR_NEXT_SIBLING(dp) = -1;
}
+static void interpret_stat_error(const char *fname, int is_dir)
+{
+ if (errno == ENOENT) {
+ io_error |= IOERR_VANISHED;
+ rprintf(FWARNING, "%s has vanished: %s\n",
+ is_dir ? "directory" : "file", full_fname(fname));
+ } else {
+ io_error |= IOERR_GENERAL;
+ rsyserr(FERROR_XFER, errno, "link_stat %s failed",
+ full_fname(fname));
+ }
+}
+
/* This function is normally called by the sender, but the receiving side also
* calls it from get_dirlist() with f set to -1 so that we just construct the
* file list in memory without sending it over the wire. Also, get_dirlist()
@@ -1646,8 +1659,11 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
assert(flist != NULL);
if (!(d = opendir(fbuf))) {
- if (errno == ENOENT)
+ if (errno == ENOENT) {
+ if (am_sender) /* Can abuse this for vanished error w/ENOENT: */
+ interpret_stat_error(fbuf, True);
return;
+ }
io_error |= IOERR_GENERAL;
rsyserr(FERROR_XFER, errno, "opendir %s failed", full_fname(fbuf));
return;
@@ -1819,9 +1835,7 @@ static void send1extra(int f, struct file_struct *file, struct file_list *flist)
if (one_file_system) {
STRUCT_STAT st;
if (link_stat(fbuf, &st, copy_dirlinks) != 0) {
- io_error |= IOERR_GENERAL;
- rsyserr(FERROR_XFER, errno, "link_stat %s failed",
- full_fname(fbuf));
+ interpret_stat_error(fbuf, True);
return;
}
filesystem_dev = st.st_dev;
@@ -1856,9 +1870,7 @@ static void send1extra(int f, struct file_struct *file, struct file_list *flist)
if (name_type != NORMAL_NAME) {
STRUCT_STAT st;
if (link_stat(fbuf, &st, 1) != 0) {
- io_error |= IOERR_GENERAL;
- rsyserr(FERROR_XFER, errno, "link_stat %s failed",
- full_fname(fbuf));
+ interpret_stat_error(fbuf, True);
continue;
}
send_file_name(f, flist, fbuf, &st, FLAG_TOP_DIR | flags, ALL_FILTERS);