Improved file-related error messages by using the new

full_fname() function.
This commit is contained in:
Wayne Davison committed 2003-09-11 04:53:05 +00:00
1 parent b7b2741f3a
commit ea42541fe0
7 files changed
+98 -92

No files matched your search

+15 -12
View File
@@ -108,15 +108,18 @@ static int make_bak_dir(char *fname, char *bak_path)
do_mkdir(fullpath, 0777 & ~orig_umask);
if(p>q) {
if(do_lstat(q, &st) != 0) {
rprintf(FERROR, "make_bak_dir stat %s : %s\n", fullpath, strerror(errno));
rprintf(FERROR, "make_bak_dir stat %s failed: %s\n",
full_fname(fullpath), strerror(errno));
} else {
st2 = &st;
set_modtime(fullpath, st2->st_mtime);
if(do_lchown(fullpath, st2->st_uid, st2->st_gid) != 0) {
rprintf(FERROR, "make_bak_dir chown %s : %s\n", fullpath, strerror(errno));
rprintf(FERROR, "make_bak_dir chown %s failed: %s\n",
full_fname(fullpath), strerror(errno));
}
if(do_chmod(fullpath, st2->st_mode) != 0) {
rprintf(FERROR, "make_bak_dir failed to set permissions on %s : %s\n", fullpath, strerror(errno));
rprintf(FERROR, "make_bak_dir failed to set permissions on %s: %s\n",
full_fname(fullpath), strerror(errno));
}
}
}
@@ -218,10 +221,10 @@ static int keep_backup(char *fname)
if(am_root && preserve_devices) {
make_bak_dir(fname, backup_dir);
if(do_mknod(keep_name, file->mode, file->rdev) != 0) {
rprintf(FERROR, "mknod %s : %s\n",
keep_name, strerror(errno));
rprintf(FERROR, "mknod %s failed: %s\n",
full_fname(keep_name), strerror(errno));
} else if(verbose>2) {
rprintf(FINFO, "make_backup : DEVICE %s successful.\n", fname);
rprintf(FINFO, "make_backup: DEVICE %s successful.\n", fname);
}
}
kept = 1;
@@ -236,8 +239,8 @@ static int keep_backup(char *fname)
ret_code = do_rmdir(fname);
if(verbose>2) {
rprintf(FINFO, "make_backup : RMDIR %s returns %i\n",
fname, ret_code);
rprintf(FINFO, "make_backup: RMDIR %s returns %i\n",
full_fname(fname), ret_code);
}
kept = 1;
}
@@ -248,14 +251,14 @@ static int keep_backup(char *fname)
if (safe_symlinks && unsafe_symlink(file->link, keep_name)) {
if (verbose) {
rprintf(FINFO, "ignoring unsafe symlink %s -> %s\n",
keep_name, file->link);
full_fname(keep_name), file->link);
}
kept = 1;
}
make_bak_dir(fname, backup_dir);
if(do_symlink(file->link, keep_name) != 0) {
rprintf(FERROR, "link %s -> %s : %s\n",
keep_name, file->link, strerror(errno));
full_fname(keep_name), file->link, strerror(errno));
}
do_unlink(fname);
kept = 1;
@@ -274,8 +277,8 @@ static int keep_backup(char *fname)
/* move to keep tree if a file */
if(!kept) {
if (!robust_move (fname, keep_name)) {
rprintf(FERROR, "keep_backup failed %s -> %s : %s\n",
fname, keep_name, strerror(errno));
rprintf(FERROR, "keep_backup failed: %s -> \"%s\": %s\n",
full_fname(fname), keep_name, strerror(errno));
}
}
set_perms (keep_name, file, NULL, 0);
+15 -15
View File
@@ -693,8 +693,8 @@ struct file_struct *make_file(char *fname, struct string_area **ap,
}
}
io_error = 1;
rprintf(FERROR, "readlink %s: %s\n",
fname, strerror(save_errno));
rprintf(FERROR, "readlink %s failed: %s\n",
full_fname(fname), strerror(save_errno));
return NULL;
}
@@ -843,7 +843,8 @@ static void send_directory(int f, struct file_list *flist, char *dir)
d = opendir(dir);
if (!d) {
io_error = 1;
rprintf(FERROR, "opendir(%s): %s\n", dir, strerror(errno));
rprintf(FERROR, "opendir %s failed: %s\n",
full_fname(dir), strerror(errno));
return;
}
@@ -852,9 +853,8 @@ static void send_directory(int f, struct file_list *flist, char *dir)
if (fname[l - 1] != '/') {
if (l == MAXPATHLEN - 1) {
io_error = 1;
rprintf(FERROR,
"skipping long-named directory %s\n",
fname);
rprintf(FERROR, "skipping long-named directory: %s\n",
full_fname(fname));
closedir(d);
return;
}
@@ -873,7 +873,7 @@ static void send_directory(int f, struct file_list *flist, char *dir)
io_error = 1;
rprintf(FINFO,
"cannot cvs-exclude in long-named directory %s\n",
fname);
full_fname(fname));
}
}
@@ -920,8 +920,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
io_start_buffering(f);
if (filesfrom_fd >= 0) {
if (argv[0] && !push_dir(argv[0], 0)) {
rprintf(FERROR, "push_dir %s : %s\n",
argv[0], strerror(errno));
rprintf(FERROR, "push_dir %s failed: %s\n",
full_fname(argv[0]), strerror(errno));
exit_cleanup(RERR_FILESELECT);
}
use_ff_fd = 1;
@@ -957,8 +957,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
if (link_stat(fname, &st) != 0) {
if (f != -1) {
io_error = 1;
rprintf(FERROR, "link_stat %s : %s\n",
fname, strerror(errno));
rprintf(FERROR, "link_stat %s failed: %s\n",
full_fname(fname), strerror(errno));
}
continue;
}
@@ -1024,8 +1024,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
if (!olddir) {
io_error = 1;
rprintf(FERROR, "push_dir %s : %s\n",
dir, strerror(errno));
rprintf(FERROR, "push_dir %s failed: %s\n",
full_fname(dir), strerror(errno));
continue;
}
@@ -1040,8 +1040,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
if (olddir != NULL) {
flist_dir = NULL;
if (pop_dir(olddir) != 0) {
rprintf(FERROR, "pop_dir %s : %s\n",
dir, strerror(errno));
rprintf(FERROR, "pop_dir %s failed: %s\n",
full_fname(dir), strerror(errno));
exit_cleanup(RERR_FILESELECT);
}
}
+17 -16
View File
@@ -314,9 +314,9 @@ void recv_generator(char *fname, struct file_list *flist, int i, int f_out)
if (dry_run) return; /* XXXX -- might cause inaccuracies?? -- mbp */
if (statret == 0 && !S_ISDIR(st.st_mode)) {
if (robust_unlink(fname) != 0) {
rprintf(FERROR, RSYNC_NAME
": recv_generator: unlink \"%s\" to make room for directory: %s\n",
fname,strerror(errno));
rprintf(FERROR,
"recv_generator: unlink %s to make room for directory: %s\n",
full_fname(fname), strerror(errno));
return;
}
statret = -1;
@@ -325,8 +325,8 @@ void recv_generator(char *fname, struct file_list *flist, int i, int f_out)
if (!(relative_paths && errno==ENOENT &&
create_directory_path(fname, orig_umask)==0 &&
do_mkdir(fname,file->mode)==0)) {
rprintf(FERROR, RSYNC_NAME ": recv_generator: mkdir \"%s\": %s (2)\n",
fname,strerror(errno));
rprintf(FERROR, "recv_generator: mkdir %s failed: %s\n",
full_fname(fname), strerror(errno));
}
}
/* f_out is set to -1 when doing final directory
@@ -344,8 +344,8 @@ void recv_generator(char *fname, struct file_list *flist, int i, int f_out)
if (safe_symlinks && unsafe_symlink(file->link, fname)) {
if (verbose) {
rprintf(FINFO,"ignoring unsafe symlink \"%s\" -> \"%s\"\n",
fname,file->link);
rprintf(FINFO, "ignoring unsafe symlink %s -> \"%s\"\n",
full_fname(fname), file->link);
}
return;
}
@@ -367,8 +367,8 @@ void recv_generator(char *fname, struct file_list *flist, int i, int f_out)
delete_file(fname);
}
if (do_symlink(file->link,fname) != 0) {
rprintf(FERROR,RSYNC_NAME": symlink \"%s\" -> \"%s\": %s\n",
fname,file->link,strerror(errno));
rprintf(FERROR, "symlink %s -> \"%s\" failed: %s\n",
full_fname(fname), file->link, strerror(errno));
} else {
set_perms(fname,file,NULL,0);
if (verbose) {
@@ -389,7 +389,8 @@ void recv_generator(char *fname, struct file_list *flist, int i, int f_out)
rprintf(FINFO,"mknod(%s,0%o,0x%x)\n",
fname,(int)file->mode,(int)file->rdev);
if (do_mknod(fname,file->mode,file->rdev) != 0) {
rprintf(FERROR,"mknod %s : %s\n",fname,strerror(errno));
rprintf(FERROR, "mknod %s failed: %s\n",
full_fname(fname), strerror(errno));
} else {
set_perms(fname,file,NULL,0);
if (verbose)
@@ -444,11 +445,10 @@ void recv_generator(char *fname, struct file_list *flist, int i, int f_out)
if (errno == ENOENT) {
write_int(f_out,i);
if (!dry_run) write_sum_head(f_out, NULL);
} else {
if (verbose > 1)
rprintf(FERROR, RSYNC_NAME
": recv_generator failed to open \"%s\": %s\n",
fname, strerror(errno));
} else if (verbose > 1) {
rprintf(FERROR,
"recv_generator: failed to open %s: %s\n",
full_fname(fname), strerror(errno));
}
return;
}
@@ -497,7 +497,8 @@ void recv_generator(char *fname, struct file_list *flist, int i, int f_out)
fd = do_open(fnamecmp, O_RDONLY, 0);
if (fd == -1) {
rprintf(FERROR,RSYNC_NAME": failed to open \"%s\", continuing : %s\n",fnamecmp,strerror(errno));
rprintf(FERROR, "failed to open %s, continuing: %s\n",
full_fname(fnamecmp), strerror(errno));
/* pretend the file didn't exist */
write_int(f_out,i);
write_sum_head(f_out, NULL);
+10 -9
View File
@@ -298,8 +298,8 @@ static char *get_local_name(struct file_list *flist,char *name)
if (do_stat(name,&st) == 0) {
if (S_ISDIR(st.st_mode)) {
if (!push_dir(name, 0)) {
rprintf(FERROR,"push_dir %s : %s (1)\n",
name,strerror(errno));
rprintf(FERROR, "push_dir %s failed: %s (1)\n",
full_fname(name), strerror(errno));
exit_cleanup(RERR_FILESELECT);
}
return NULL;
@@ -315,8 +315,8 @@ static char *get_local_name(struct file_list *flist,char *name)
return name;
if (do_mkdir(name,0777 & ~orig_umask) != 0) {
rprintf(FERROR, RSYNC_NAME ": mkdir %s: %s\n",
name, strerror(errno));
rprintf(FERROR, "mkdir %s failed: %s\n",
full_fname(name), strerror(errno));
exit_cleanup(RERR_FILEIO);
} else {
if (verbose > 0)
@@ -324,8 +324,8 @@ static char *get_local_name(struct file_list *flist,char *name)
}
if (!push_dir(name, 0)) {
rprintf(FERROR, RSYNC_NAME ": push_dir %s: %s\n",
name, strerror(errno));
rprintf(FERROR, "push_dir %s failed: %s (2)\n",
full_fname(name), strerror(errno));
exit_cleanup(RERR_FILESELECT);
}
@@ -347,7 +347,8 @@ static void do_server_sender(int f_in, int f_out, int argc,char *argv[])
rprintf(FINFO,"server_sender starting pid=%d\n",(int)getpid());
if (!relative_paths && !push_dir(dir, 0)) {
rprintf(FERROR,"push_dir %s: %s (3)\n",dir,strerror(errno));
rprintf(FERROR, "push_dir %s failed: %s (3)\n",
full_fname(dir), strerror(errno));
exit_cleanup(RERR_FILESELECT);
}
argc--;
@@ -494,8 +495,8 @@ static void do_server_recv(int f_in, int f_out, int argc,char *argv[])
argc--;
argv++;
if (!am_daemon && !push_dir(dir, 0)) {
rprintf(FERROR,"push_dir %s : %s (4)\n",
dir,strerror(errno));
rprintf(FERROR, "push_dir %s failed: %s (4)\n",
full_fname(dir), strerror(errno));
exit_cleanup(RERR_FILESELECT);
}
}
+17 -22
View File
@@ -86,16 +86,16 @@ static void delete_one(char *fn, int is_dir)
{
if (!is_dir) {
if (robust_unlink(fn) != 0) {
rprintf(FERROR, "delete_one: unlink %s: %s\n",
fn, strerror(errno));
rprintf(FERROR, "delete_one: unlink %s failed: %s\n",
full_fname(fn), strerror(errno));
} else if (verbose) {
rprintf(FINFO, "deleting %s\n", fn);
}
} else {
if (do_rmdir(fn) != 0) {
if (errno != ENOTEMPTY && errno != EEXIST) {
rprintf(FERROR, "delete_one: rmdir %s: %s\n",
fn, strerror(errno));
rprintf(FERROR, "delete_one: rmdir %s failed: %s\n",
full_fname(fn), strerror(errno));
}
} else if (verbose) {
rprintf(FINFO, "deleting directory %s\n", fn);
@@ -271,7 +271,8 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname,
sum_update(data,i);
if (fd != -1 && write_file(fd,data,i) != i) {
rprintf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
rprintf(FERROR, "write failed on %s: %s\n",
full_fname(fname), strerror(errno));
exit_cleanup(RERR_FILEIO);
}
offset += i;
@@ -298,8 +299,8 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname,
}
if (fd != -1 && write_file(fd,map,len) != (int) len) {
rprintf(FERROR,"write failed on %s : %s\n",
fname,strerror(errno));
rprintf(FERROR, "write failed on %s: %s\n",
full_fname(fname), strerror(errno));
exit_cleanup(RERR_FILEIO);
}
offset += len;
@@ -309,8 +310,8 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname,
end_progress(total_size);
if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
rprintf(FERROR,"write failed on %s : %s\n",
fname,strerror(errno));
rprintf(FERROR, "write failed on %s: %s\n",
full_fname(fname), strerror(errno));
exit_cleanup(RERR_FILEIO);
}
@@ -413,7 +414,8 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
}
if (fd1 != -1 && do_fstat(fd1,&st) != 0) {
rprintf(FERROR,"fstat %s : %s\n",fnamecmp,strerror(errno));
rprintf(FERROR, "fstat %s failed: %s\n",
full_fname(fnamecmp), strerror(errno));
receive_data(f_in,NULL,-1,NULL,file->length);
close(fd1);
continue;
@@ -425,8 +427,8 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
* and the underlying robust_unlink could cope
* with directories
*/
rprintf(FERROR,"%s : is a directory (recv_files)\n",
fnamecmp);
rprintf(FERROR,"recv_files: %s is a directory\n",
full_fname(fnamecmp));
receive_data(f_in, NULL, -1, NULL, file->length);
close(fd1);
continue;
@@ -478,15 +480,8 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
}
if (fd2 == -1) {
extern char curr_dir[];
char *p1, *p2;
if (*fnametmp == '.') {
p1 = curr_dir;
p2 = "/";
} else
p1 = p2 = "";
rprintf(FERROR, "mkstemp %s%s%s failed: %s\n",
p1, p2, fnametmp, strerror(errno));
rprintf(FERROR, "mkstemp %s failed: %s\n",
full_fname(fnametmp), strerror(errno));
receive_data(f_in,buf,-1,NULL,file->length);
if (buf) unmap_file(buf);
if (fd1 != -1) close(fd1);
@@ -520,7 +515,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
if (!recv_ok) {
if (csum_length == SUM_LENGTH) {
rprintf(FERROR,"ERROR: file corruption in %s. File changed during transfer?\n",
fname);
full_fname(fname));
} else {
if (verbose > 1)
rprintf(FINFO,"redoing %s(%d)\n",fname,i);
+21 -15
View File
@@ -67,22 +67,24 @@ int delete_file(char *fname)
if (!S_ISDIR(st.st_mode)) {
if (robust_unlink(fname) == 0 || errno == ENOENT) return 0;
rprintf(FERROR,"delete_file: unlink(%s) : %s\n", fname, strerror(errno));
rprintf(FERROR, "delete_file: unlink %s failed: %s\n",
full_fname(fname), strerror(errno));
return -1;
}
if (do_rmdir(fname) == 0 || errno == ENOENT) return 0;
if (!force_delete || !recurse ||
(errno != ENOTEMPTY && errno != EEXIST)) {
rprintf(FERROR,"delete_file: rmdir(%s) : %s\n", fname, strerror(errno));
rprintf(FERROR, "delete_file: rmdir %s failed: %s\n",
full_fname(fname), strerror(errno));
return -1;
}
/* now we do a recsursive delete on the directory ... */
d = opendir(fname);
if (!d) {
rprintf(FERROR,"delete_file: opendir(%s): %s\n",
fname,strerror(errno));
rprintf(FERROR, "delete_file: opendir %s failed: %s\n",
full_fname(fname), strerror(errno));
return -1;
}
@@ -103,7 +105,8 @@ int delete_file(char *fname)
closedir(d);
if (do_rmdir(fname) != 0) {
rprintf(FERROR,"delete_file: rmdir(%s) : %s\n", fname, strerror(errno));
rprintf(FERROR, "delete_file: rmdir %s failed: %s\n",
full_fname(fname), strerror(errno));
return -1;
}
@@ -155,7 +158,8 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
if (!st) {
if (link_stat(fname,&st2) != 0) {
rprintf(FERROR,"stat %s : %s\n",fname,strerror(errno));
rprintf(FERROR, "stat %s failed: %s\n",
full_fname(fname), strerror(errno));
return 0;
}
st = &st2;
@@ -167,8 +171,8 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
because some filesystems can't do it */
if (set_modtime(fname,file->modtime) != 0 &&
!S_ISDIR(st->st_mode)) {
rprintf(FERROR,"failed to set times on %s : %s\n",
fname,strerror(errno));
rprintf(FERROR, "failed to set times on %s: %s\n",
full_fname(fname), strerror(errno));
return 0;
} else {
updated = 1;
@@ -189,7 +193,8 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
change_gid?file->gid:st->st_gid) != 0) {
/* shouldn't have attempted to change uid or gid
unless have the privilege */
rprintf(FERROR,"chown %s : %s\n", fname,strerror(errno));
rprintf(FERROR, "chown %s failed: %s\n",
full_fname(fname), strerror(errno));
return 0;
}
/* a lchown had been done - we have to re-stat if the
@@ -206,8 +211,8 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) {
updated = 1;
if (do_chmod(fname,(file->mode & CHMOD_BITS)) != 0) {
rprintf(FERROR,"failed to set permissions on %s : %s\n",
fname,strerror(errno));
rprintf(FERROR, "failed to set permissions on %s: %s\n",
full_fname(fname), strerror(errno));
return 0;
}
}
@@ -243,14 +248,15 @@ void finish_transfer(char *fname, char *fnametmp, struct file_struct *file)
/* 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",
fnametmp,fname,strerror(errno));
rprintf(FERROR, "copy %s -> \"%s\": %s\n",
full_fname(fnametmp), fname,
strerror(errno));
} else {
set_perms(fname,file,NULL,0);
}
} else {
rprintf(FERROR,"rename %s -> %s : %s\n",
fnametmp,fname,strerror(errno));
rprintf(FERROR,"rename %s -> \"%s\": %s\n",
full_fname(fnametmp), fname, strerror(errno));
}
do_unlink(fnametmp);
} else {
+3 -3
View File
@@ -158,7 +158,7 @@ void send_files(struct file_list *flist, int f_out, int f_in)
if (strlen(fname) == MAXPATHLEN-1) {
io_error = 1;
rprintf(FERROR, "send_files failed on long-named directory %s\n",
fname);
full_fname(fname));
return;
}
strlcat(fname, "/", MAXPATHLEN);
@@ -194,7 +194,7 @@ void send_files(struct file_list *flist, int f_out, int f_in)
if (fd == -1) {
io_error = 1;
rprintf(FERROR, "send_files failed to open %s: %s\n",
fname, strerror(errno));
full_fname(fname), strerror(errno));
free_sums(s);
continue;
}
@@ -202,7 +202,7 @@ void send_files(struct file_list *flist, int f_out, int f_in)
/* map the local file */
if (do_fstat(fd, &st) != 0) {
io_error = 1;
rprintf(FERROR, "fstat failed : %s\n", strerror(errno));
rprintf(FERROR, "fstat failed: %s\n", strerror(errno));
free_sums(s);
close(fd);
return;