diff options
author | J.W. Schultz <jw@samba.org> | 2003-09-16 02:49:59 +0000 |
---|---|---|
committer | J.W. Schultz <jw@samba.org> | 2003-09-16 02:49:59 +0000 |
commit | 6a7cc46cb279b9dbf12977177330aeebb912aa34 (patch) | |
tree | 6e3b7760f73eb3610228467999714af25378f3d4 /rsync.c | |
parent | aa6dc37ccb73c83f652e72ed1ca7700934a52331 (diff) | |
download | android_external_rsync-6a7cc46cb279b9dbf12977177330aeebb912aa34.tar.gz android_external_rsync-6a7cc46cb279b9dbf12977177330aeebb912aa34.tar.bz2 android_external_rsync-6a7cc46cb279b9dbf12977177330aeebb912aa34.zip |
Detect and report when open or opendir succeed but read and
readdir fail caused by network filesystems issues and
truncated files.
Thanks to David Norwood and Michael Brown
Diffstat (limited to 'rsync.c')
-rw-r--r-- | rsync.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -88,10 +88,10 @@ int delete_file(char *fname) return -1; } - for (di=readdir(d); di; di=readdir(d)) { + for (errno = 0, di = readdir(d); di; errno = 0, di = readdir(d)) { char *dname = d_name(di); - if (strcmp(dname,".")==0 || - strcmp(dname,"..")==0) + if (strcmp(dname,".") == 0 + || strcmp(dname,"..") == 0) continue; snprintf(buf, sizeof(buf), "%s/%s", fname, dname); if (verbose > 0) @@ -101,6 +101,12 @@ int delete_file(char *fname) return -1; } } + if (errno) { + rprintf(FERROR, "delete_file: readdir(%s): (%d) %s\n", + fname, errno, strerror(errno)); + closedir(d); + return -1; + } closedir(d); @@ -148,7 +154,7 @@ static int is_in_group(gid_t gid) } int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st, - int report) + int report) { int updated = 0; STRUCT_STAT st2; @@ -218,7 +224,7 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st, } } #endif - + if (verbose > 1 && report) { if (updated) rprintf(FINFO,"%s\n",fname); @@ -245,7 +251,7 @@ void finish_transfer(char *fname, char *fnametmp, struct file_struct *file) /* move tmp file over real file */ if (robust_rename(fnametmp,fname) != 0) { if (errno == EXDEV) { - /* rename failed on cross-filesystem link. + /* rename failed on cross-filesystem link. Copy the file instead. */ if (copy_file(fnametmp,fname, file->mode & INITACCESSPERMS)) { rprintf(FERROR, "copy %s -> \"%s\": %s\n", |