Changed rprintf() calls that included strerror() to use rsyserr().
This commit is contained in:
36
backup.c
36
backup.c
@@ -49,7 +49,8 @@ static int make_simple_backup(char *fname)
|
|||||||
if (do_rename(fname, fnamebak) != 0) {
|
if (do_rename(fname, fnamebak) != 0) {
|
||||||
/* cygwin (at least version b19) reports EINVAL */
|
/* cygwin (at least version b19) reports EINVAL */
|
||||||
if (errno != ENOENT && errno != EINVAL) {
|
if (errno != ENOENT && errno != EINVAL) {
|
||||||
rsyserr(FERROR, errno, "rename %s to backup %s", fname, fnamebak);
|
rsyserr(FERROR, errno,
|
||||||
|
"rename %s to backup %s", fname, fnamebak);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else if (verbose > 1) {
|
} else if (verbose > 1) {
|
||||||
@@ -84,9 +85,9 @@ static int make_bak_dir(char *fullpath)
|
|||||||
if (do_mkdir(fullpath, 0777 & ~orig_umask) == 0)
|
if (do_mkdir(fullpath, 0777 & ~orig_umask) == 0)
|
||||||
break;
|
break;
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
rprintf(FERROR,
|
rsyserr(FERROR, errno,
|
||||||
"make_bak_dir mkdir %s failed: %s\n",
|
"make_bak_dir mkdir %s failed",
|
||||||
full_fname(fullpath), strerror(errno));
|
full_fname(fullpath));
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,9 +99,9 @@ static int make_bak_dir(char *fullpath)
|
|||||||
/* Try to transfer the directory settings of the
|
/* Try to transfer the directory settings of the
|
||||||
* actual dir that the files are coming from. */
|
* actual dir that the files are coming from. */
|
||||||
if (do_lstat(rel, &st) != 0) {
|
if (do_lstat(rel, &st) != 0) {
|
||||||
rprintf(FERROR,
|
rsyserr(FERROR, errno,
|
||||||
"make_bak_dir stat %s failed: %s\n",
|
"make_bak_dir stat %s failed",
|
||||||
full_fname(rel), strerror(errno));
|
full_fname(rel));
|
||||||
} else {
|
} else {
|
||||||
do_lchown(fullpath, st.st_uid, st.st_gid);
|
do_lchown(fullpath, st.st_uid, st.st_gid);
|
||||||
do_chmod(fullpath, st.st_mode);
|
do_chmod(fullpath, st.st_mode);
|
||||||
@@ -111,9 +112,8 @@ static int make_bak_dir(char *fullpath)
|
|||||||
if (p == end)
|
if (p == end)
|
||||||
break;
|
break;
|
||||||
if (do_mkdir(fullpath, 0777 & ~orig_umask) < 0) {
|
if (do_mkdir(fullpath, 0777 & ~orig_umask) < 0) {
|
||||||
rprintf(FERROR,
|
rsyserr(FERROR, errno, "make_bak_dir mkdir %s failed",
|
||||||
"make_bak_dir mkdir %s failed: %s\n",
|
full_fname(fullpath));
|
||||||
full_fname(fullpath), strerror(errno));
|
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,8 +172,8 @@ static int keep_backup(char *fname)
|
|||||||
if (do_mknod(backup_dir_buf, file->mode, file->u.rdev) < 0
|
if (do_mknod(backup_dir_buf, file->mode, file->u.rdev) < 0
|
||||||
&& (errno != ENOENT || make_bak_dir(backup_dir_buf) < 0
|
&& (errno != ENOENT || make_bak_dir(backup_dir_buf) < 0
|
||||||
|| do_mknod(backup_dir_buf, file->mode, file->u.rdev) < 0)) {
|
|| do_mknod(backup_dir_buf, file->mode, file->u.rdev) < 0)) {
|
||||||
rprintf(FERROR, "mknod %s failed: %s\n",
|
rsyserr(FERROR, errno, "mknod %s failed",
|
||||||
full_fname(backup_dir_buf), strerror(errno));
|
full_fname(backup_dir_buf));
|
||||||
} else if (verbose > 2) {
|
} else if (verbose > 2) {
|
||||||
rprintf(FINFO,
|
rprintf(FINFO,
|
||||||
"make_backup: DEVICE %s successful.\n",
|
"make_backup: DEVICE %s successful.\n",
|
||||||
@@ -190,8 +190,8 @@ static int keep_backup(char *fname)
|
|||||||
if (do_mkdir(backup_dir_buf, file->mode) < 0
|
if (do_mkdir(backup_dir_buf, file->mode) < 0
|
||||||
&& (errno != ENOENT || make_bak_dir(backup_dir_buf) < 0
|
&& (errno != ENOENT || make_bak_dir(backup_dir_buf) < 0
|
||||||
|| do_mkdir(backup_dir_buf, file->mode) < 0)) {
|
|| do_mkdir(backup_dir_buf, file->mode) < 0)) {
|
||||||
rprintf(FINFO, "mkdir %s failed: %s\n",
|
rsyserr(FINFO, errno, "mkdir %s failed",
|
||||||
full_fname(backup_dir_buf), strerror(errno));
|
full_fname(backup_dir_buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
ret_code = do_rmdir(fname);
|
ret_code = do_rmdir(fname);
|
||||||
@@ -214,8 +214,8 @@ static int keep_backup(char *fname)
|
|||||||
if (do_symlink(file->u.link, backup_dir_buf) < 0
|
if (do_symlink(file->u.link, backup_dir_buf) < 0
|
||||||
&& (errno != ENOENT || make_bak_dir(backup_dir_buf) < 0
|
&& (errno != ENOENT || make_bak_dir(backup_dir_buf) < 0
|
||||||
|| do_symlink(file->u.link, backup_dir_buf) < 0)) {
|
|| do_symlink(file->u.link, backup_dir_buf) < 0)) {
|
||||||
rprintf(FERROR, "link %s -> %s : %s\n",
|
rsyserr(FERROR, errno, "link %s -> \"%s\"",
|
||||||
full_fname(backup_dir_buf), file->u.link, strerror(errno));
|
full_fname(backup_dir_buf), file->u.link);
|
||||||
}
|
}
|
||||||
do_unlink(fname);
|
do_unlink(fname);
|
||||||
kept = 1;
|
kept = 1;
|
||||||
@@ -230,8 +230,8 @@ static int keep_backup(char *fname)
|
|||||||
/* move to keep tree if a file */
|
/* move to keep tree if a file */
|
||||||
if (!kept) {
|
if (!kept) {
|
||||||
if (robust_move(fname, backup_dir_buf) != 0) {
|
if (robust_move(fname, backup_dir_buf) != 0) {
|
||||||
rprintf(FERROR, "keep_backup failed: %s -> \"%s\": %s\n",
|
rsyserr(FERROR, errno, "keep_backup failed: %s -> \"%s\"",
|
||||||
full_fname(fname), backup_dir_buf, strerror(errno));
|
full_fname(fname), backup_dir_buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_perms(backup_dir_buf, file, NULL, 0);
|
set_perms(backup_dir_buf, file, NULL, 0);
|
||||||
|
|||||||
39
batch.c
39
batch.c
@@ -34,8 +34,7 @@ void write_batch_flist_info(int flist_count, struct file_struct **files)
|
|||||||
|
|
||||||
f = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
f = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
||||||
if (f < 0) {
|
if (f < 0) {
|
||||||
rprintf(FERROR, "Batch file %s open error: %s\n",
|
rsyserr(FERROR, errno, "Batch file %s open error", filename);
|
||||||
filename, strerror(errno));
|
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,8 +71,7 @@ void write_batch_argvs_file(int argc, char *argv[])
|
|||||||
f = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
|
f = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
|
||||||
S_IRUSR | S_IWUSR | S_IEXEC);
|
S_IRUSR | S_IWUSR | S_IEXEC);
|
||||||
if (f < 0) {
|
if (f < 0) {
|
||||||
rprintf(FERROR, "Batch file %s open error: %s\n",
|
rsyserr(FERROR, errno, "Batch file %s open error", filename);
|
||||||
filename, strerror(errno));
|
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
buff[0] = '\0';
|
buff[0] = '\0';
|
||||||
@@ -111,8 +109,7 @@ void write_batch_argvs_file(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
strlcat(buff, "\n", sizeof buff);
|
strlcat(buff, "\n", sizeof buff);
|
||||||
if (!write(f, buff, strlen(buff))) {
|
if (!write(f, buff, strlen(buff))) {
|
||||||
rprintf(FERROR, "Batch file %s write error: %s\n",
|
rsyserr(FERROR, errno, "Batch file %s write error", filename);
|
||||||
filename, strerror(errno));
|
|
||||||
close(f);
|
close(f);
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
@@ -131,8 +128,7 @@ struct file_list *create_flist_from_batch(void)
|
|||||||
|
|
||||||
f = do_open(filename, O_RDONLY, 0);
|
f = do_open(filename, O_RDONLY, 0);
|
||||||
if (f < 0) {
|
if (f < 0) {
|
||||||
rprintf(FERROR, "Batch file %s open error: %s\n",
|
rsyserr(FERROR, errno, "Batch file %s open error", filename);
|
||||||
filename, strerror(errno));
|
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,8 +157,7 @@ struct file_list *create_flist_from_batch(void)
|
|||||||
void write_batch_csums_file(void *buff, int bytes_to_write)
|
void write_batch_csums_file(void *buff, int bytes_to_write)
|
||||||
{
|
{
|
||||||
if (write(f_csums, buff, bytes_to_write) < 0) {
|
if (write(f_csums, buff, bytes_to_write) < 0) {
|
||||||
rprintf(FERROR, "Batch file write error: %s\n",
|
rsyserr(FERROR, errno, "Batch file write error");
|
||||||
strerror(errno));
|
|
||||||
close(f_csums);
|
close(f_csums);
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
@@ -196,8 +191,8 @@ void write_batch_csum_info(int *flist_entry, struct sum_struct *s)
|
|||||||
f_csums = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
|
f_csums = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
|
||||||
S_IRUSR | S_IWUSR);
|
S_IRUSR | S_IWUSR);
|
||||||
if (f_csums < 0) {
|
if (f_csums < 0) {
|
||||||
rprintf(FERROR, "Batch file %s open error: %s\n",
|
rsyserr(FERROR, errno, "Batch file %s open error",
|
||||||
filename, strerror(errno));
|
filename);
|
||||||
close(f_csums);
|
close(f_csums);
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
@@ -221,7 +216,7 @@ int read_batch_csums_file(char *buff, int len)
|
|||||||
int bytes_read;
|
int bytes_read;
|
||||||
|
|
||||||
if ((bytes_read = read(f_csums, buff, len)) < 0) {
|
if ((bytes_read = read(f_csums, buff, len)) < 0) {
|
||||||
rprintf(FERROR, "Batch file read error: %s\n", strerror(errno));
|
rsyserr(FERROR, errno, "Batch file read error");
|
||||||
close(f_csums);
|
close(f_csums);
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
@@ -244,8 +239,8 @@ void read_batch_csum_info(int flist_entry, struct sum_struct *s,
|
|||||||
|
|
||||||
f_csums = do_open(filename, O_RDONLY, 0);
|
f_csums = do_open(filename, O_RDONLY, 0);
|
||||||
if (f_csums < 0) {
|
if (f_csums < 0) {
|
||||||
rprintf(FERROR, "Batch file %s open error: %s\n",
|
rsyserr(FERROR, errno, "Batch file %s open error",
|
||||||
filename, strerror(errno));
|
filename);
|
||||||
close(f_csums);
|
close(f_csums);
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
@@ -284,15 +279,14 @@ void write_batch_delta_file(char *buff, int bytes_to_write)
|
|||||||
f_delta = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
|
f_delta = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
|
||||||
S_IRUSR | S_IWUSR);
|
S_IRUSR | S_IWUSR);
|
||||||
if (f_delta < 0) {
|
if (f_delta < 0) {
|
||||||
rprintf(FERROR, "Batch file %s open error: %s\n",
|
rsyserr(FERROR, errno, "Batch file %s open error",
|
||||||
filename, strerror(errno));
|
filename);
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write(f_delta, buff, bytes_to_write) < 0) {
|
if (write(f_delta, buff, bytes_to_write) < 0) {
|
||||||
rprintf(FERROR, "Batch file %s write error: %s\n",
|
rsyserr(FERROR, errno, "Batch file %s write error", filename);
|
||||||
filename, strerror(errno));
|
|
||||||
close(f_delta);
|
close(f_delta);
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
@@ -315,8 +309,8 @@ int read_batch_delta_file(char *buff, int len)
|
|||||||
|
|
||||||
f_delta = do_open(filename, O_RDONLY, 0);
|
f_delta = do_open(filename, O_RDONLY, 0);
|
||||||
if (f_delta < 0) {
|
if (f_delta < 0) {
|
||||||
rprintf(FERROR, "Batch file %s open error: %s\n",
|
rsyserr(FERROR, errno, "Batch file %s open error",
|
||||||
filename, strerror(errno));
|
filename);
|
||||||
close(f_delta);
|
close(f_delta);
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
@@ -324,8 +318,7 @@ int read_batch_delta_file(char *buff, int len)
|
|||||||
|
|
||||||
bytes_read = read(f_delta, buff, len);
|
bytes_read = read(f_delta, buff, len);
|
||||||
if (bytes_read < 0) {
|
if (bytes_read < 0) {
|
||||||
rprintf(FERROR, "Batch file %s read error: %s\n",
|
rsyserr(FERROR, errno, "Batch file %s read error", filename);
|
||||||
filename, strerror(errno));
|
|
||||||
close(f_delta);
|
close(f_delta);
|
||||||
exit_cleanup(1);
|
exit_cleanup(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,8 +170,7 @@ void client_sockaddr(int fd,
|
|||||||
|
|
||||||
if (getpeername(fd, (struct sockaddr *) ss, ss_len)) {
|
if (getpeername(fd, (struct sockaddr *) ss, ss_len)) {
|
||||||
/* FIXME: Can we really not continue? */
|
/* FIXME: Can we really not continue? */
|
||||||
rprintf(FERROR, RSYNC_NAME ": getpeername on fd%d failed: %s\n",
|
rsyserr(FERROR, errno, "getpeername on fd%d failed", fd);
|
||||||
fd, strerror(errno));
|
|
||||||
exit_cleanup(RERR_SOCKETIO);
|
exit_cleanup(RERR_SOCKETIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -233,10 +233,10 @@ static int rsync_module(int f_in, int f_out, int i)
|
|||||||
|
|
||||||
if (!claim_connection(lp_lock_file(i), lp_max_connections(i))) {
|
if (!claim_connection(lp_lock_file(i), lp_max_connections(i))) {
|
||||||
if (errno) {
|
if (errno) {
|
||||||
rprintf(FERROR,"failed to open lock file %s : %s\n",
|
rsyserr(FERROR, errno, "failed to open lock file %s",
|
||||||
lp_lock_file(i), strerror(errno));
|
lp_lock_file(i));
|
||||||
io_printf(f_out, "@ERROR: failed to open lock file %s : %s\n",
|
io_printf(f_out, "@ERROR: failed to open lock file %s\n",
|
||||||
lp_lock_file(i), strerror(errno));
|
lp_lock_file(i));
|
||||||
} else {
|
} else {
|
||||||
rprintf(FERROR,"max connections (%d) reached\n",
|
rprintf(FERROR,"max connections (%d) reached\n",
|
||||||
lp_max_connections(i));
|
lp_max_connections(i));
|
||||||
|
|||||||
26
flist.c
26
flist.c
@@ -778,8 +778,8 @@ struct file_struct *make_file(char *fname,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
io_error |= IOERR_GENERAL;
|
io_error |= IOERR_GENERAL;
|
||||||
rprintf(FERROR, "readlink %s failed: %s\n",
|
rsyserr(FERROR, save_errno, "readlink %s failed",
|
||||||
full_fname(thisname), strerror(save_errno));
|
full_fname(thisname));
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -970,8 +970,7 @@ static void send_directory(int f, struct file_list *flist, char *dir)
|
|||||||
d = opendir(dir);
|
d = opendir(dir);
|
||||||
if (!d) {
|
if (!d) {
|
||||||
io_error |= IOERR_GENERAL;
|
io_error |= IOERR_GENERAL;
|
||||||
rprintf(FERROR, "opendir %s failed: %s\n",
|
rsyserr(FERROR, errno, "opendir %s failed", full_fname(dir));
|
||||||
full_fname(dir), strerror(errno));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1018,8 +1017,7 @@ static void send_directory(int f, struct file_list *flist, char *dir)
|
|||||||
}
|
}
|
||||||
if (errno) {
|
if (errno) {
|
||||||
io_error |= IOERR_GENERAL;
|
io_error |= IOERR_GENERAL;
|
||||||
rprintf(FERROR, "readdir(%s): (%d) %s\n",
|
rsyserr(FERROR, errno, "readdir(%s)", dir);
|
||||||
dir, errno, strerror(errno));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(d);
|
closedir(d);
|
||||||
@@ -1054,8 +1052,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
|||||||
io_start_buffering_out(f);
|
io_start_buffering_out(f);
|
||||||
if (filesfrom_fd >= 0) {
|
if (filesfrom_fd >= 0) {
|
||||||
if (argv[0] && !push_dir(argv[0])) {
|
if (argv[0] && !push_dir(argv[0])) {
|
||||||
rprintf(FERROR, "push_dir %s failed: %s\n",
|
rsyserr(FERROR, errno, "push_dir %s failed",
|
||||||
full_fname(argv[0]), strerror(errno));
|
full_fname(argv[0]));
|
||||||
exit_cleanup(RERR_FILESELECT);
|
exit_cleanup(RERR_FILESELECT);
|
||||||
}
|
}
|
||||||
use_ff_fd = 1;
|
use_ff_fd = 1;
|
||||||
@@ -1092,8 +1090,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
|||||||
if (link_stat(fname, &st) != 0) {
|
if (link_stat(fname, &st) != 0) {
|
||||||
if (f != -1) {
|
if (f != -1) {
|
||||||
io_error |= IOERR_GENERAL;
|
io_error |= IOERR_GENERAL;
|
||||||
rprintf(FERROR, "link_stat %s failed: %s\n",
|
rsyserr(FERROR, errno, "link_stat %s failed",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1162,8 +1160,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
|||||||
|
|
||||||
if (!push_dir(dir)) {
|
if (!push_dir(dir)) {
|
||||||
io_error |= IOERR_GENERAL;
|
io_error |= IOERR_GENERAL;
|
||||||
rprintf(FERROR, "push_dir %s failed: %s\n",
|
rsyserr(FERROR, errno, "push_dir %s failed",
|
||||||
full_fname(dir), strerror(errno));
|
full_fname(dir));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1185,8 +1183,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
|||||||
flist_dir = NULL;
|
flist_dir = NULL;
|
||||||
flist_dir_len = 0;
|
flist_dir_len = 0;
|
||||||
if (!pop_dir(olddir)) {
|
if (!pop_dir(olddir)) {
|
||||||
rprintf(FERROR, "pop_dir %s failed: %s\n",
|
rsyserr(FERROR, errno, "pop_dir %s failed",
|
||||||
full_fname(dir), strerror(errno));
|
full_fname(dir));
|
||||||
exit_cleanup(RERR_FILESELECT);
|
exit_cleanup(RERR_FILESELECT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
43
generator.c
43
generator.c
@@ -309,19 +309,20 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
|
|||||||
if (dry_run) return; /* XXXX -- might cause inaccuracies?? -- mbp */
|
if (dry_run) return; /* XXXX -- might cause inaccuracies?? -- mbp */
|
||||||
if (statret == 0 && !S_ISDIR(st.st_mode)) {
|
if (statret == 0 && !S_ISDIR(st.st_mode)) {
|
||||||
if (robust_unlink(fname) != 0) {
|
if (robust_unlink(fname) != 0) {
|
||||||
rprintf(FERROR,
|
rsyserr(FERROR, errno,
|
||||||
"recv_generator: unlink %s to make room for directory: %s\n",
|
"recv_generator: unlink %s to make room for directory",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
statret = -1;
|
statret = -1;
|
||||||
}
|
}
|
||||||
if (statret != 0 && do_mkdir(fname,file->mode) != 0 && errno != EEXIST) {
|
if (statret != 0 && do_mkdir(fname,file->mode) != 0 && errno != EEXIST) {
|
||||||
if (!(relative_paths && errno==ENOENT &&
|
if (!(relative_paths && errno == ENOENT
|
||||||
create_directory_path(fname, orig_umask)==0 &&
|
&& create_directory_path(fname, orig_umask) == 0
|
||||||
do_mkdir(fname,file->mode)==0)) {
|
&& do_mkdir(fname, file->mode) == 0)) {
|
||||||
rprintf(FERROR, "recv_generator: mkdir %s failed: %s\n",
|
rsyserr(FERROR, errno,
|
||||||
full_fname(fname), strerror(errno));
|
"recv_generator: mkdir %s failed",
|
||||||
|
full_fname(fname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* f_out is set to -1 when doing final directory
|
/* f_out is set to -1 when doing final directory
|
||||||
@@ -362,8 +363,8 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
|
|||||||
delete_file(fname);
|
delete_file(fname);
|
||||||
}
|
}
|
||||||
if (do_symlink(file->u.link,fname) != 0) {
|
if (do_symlink(file->u.link,fname) != 0) {
|
||||||
rprintf(FERROR, "symlink %s -> \"%s\" failed: %s\n",
|
rsyserr(FERROR, errno, "symlink %s -> \"%s\" failed",
|
||||||
full_fname(fname), file->u.link, strerror(errno));
|
full_fname(fname), file->u.link);
|
||||||
} else {
|
} else {
|
||||||
set_perms(fname,file,NULL,0);
|
set_perms(fname,file,NULL,0);
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
@@ -380,12 +381,13 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
|
|||||||
st.st_mode != file->mode ||
|
st.st_mode != file->mode ||
|
||||||
st.st_rdev != file->u.rdev) {
|
st.st_rdev != file->u.rdev) {
|
||||||
delete_file(fname);
|
delete_file(fname);
|
||||||
if (verbose > 2)
|
if (verbose > 2) {
|
||||||
rprintf(FINFO,"mknod(%s,0%o,0x%x)\n",
|
rprintf(FINFO,"mknod(%s,0%o,0x%x)\n",
|
||||||
fname,(int)file->mode,(int)file->u.rdev);
|
fname,(int)file->mode,(int)file->u.rdev);
|
||||||
|
}
|
||||||
if (do_mknod(fname,file->mode,file->u.rdev) != 0) {
|
if (do_mknod(fname,file->mode,file->u.rdev) != 0) {
|
||||||
rprintf(FERROR, "mknod %s failed: %s\n",
|
rsyserr(FERROR, errno, "mknod %s failed",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
} else {
|
} else {
|
||||||
set_perms(fname,file,NULL,0);
|
set_perms(fname,file,NULL,0);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
@@ -421,9 +423,8 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
|
|||||||
else if (link_dest && !dry_run) {
|
else if (link_dest && !dry_run) {
|
||||||
if (do_link(fnamecmpbuf, fname) != 0) {
|
if (do_link(fnamecmpbuf, fname) != 0) {
|
||||||
if (verbose > 0) {
|
if (verbose > 0) {
|
||||||
rprintf(FINFO,"link %s => %s : %s\n",
|
rsyserr(FINFO, errno, "link %s => %s",
|
||||||
fnamecmpbuf, fname,
|
fnamecmpbuf, fname);
|
||||||
strerror(errno));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fnamecmp = fnamecmpbuf;
|
fnamecmp = fnamecmpbuf;
|
||||||
@@ -440,9 +441,9 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
|
|||||||
write_int(f_out,i);
|
write_int(f_out,i);
|
||||||
if (!dry_run) write_sum_head(f_out, NULL);
|
if (!dry_run) write_sum_head(f_out, NULL);
|
||||||
} else if (verbose > 1) {
|
} else if (verbose > 1) {
|
||||||
rprintf(FERROR,
|
rsyserr(FERROR, errno,
|
||||||
"recv_generator: failed to open %s: %s\n",
|
"recv_generator: failed to open %s",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -493,8 +494,8 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
|
|||||||
fd = do_open(fnamecmp, O_RDONLY, 0);
|
fd = do_open(fnamecmp, O_RDONLY, 0);
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
rprintf(FERROR, "failed to open %s, continuing: %s\n",
|
rsyserr(FERROR, errno, "failed to open %s, continuing",
|
||||||
full_fname(fnamecmp), strerror(errno));
|
full_fname(fnamecmp));
|
||||||
/* pretend the file didn't exist */
|
/* pretend the file didn't exist */
|
||||||
if (preserve_hard_links && hard_link_check(file, HL_SKIP))
|
if (preserve_hard_links && hard_link_check(file, HL_SKIP))
|
||||||
return;
|
return;
|
||||||
|
|||||||
11
hlink.c
11
hlink.c
@@ -154,8 +154,8 @@ static void hard_link_one(char *hlink1, char *hlink2)
|
|||||||
{
|
{
|
||||||
if (do_link(hlink1, hlink2)) {
|
if (do_link(hlink1, hlink2)) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
rprintf(FINFO, "link %s => %s failed: %s\n",
|
rsyserr(FINFO, errno, "link %s => %s failed",
|
||||||
hlink2, hlink1, strerror(errno));
|
hlink2, hlink1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (verbose)
|
else if (verbose)
|
||||||
@@ -196,10 +196,9 @@ void do_hard_links(void)
|
|||||||
continue;
|
continue;
|
||||||
} else if (robust_unlink(hlink2)) {
|
} else if (robust_unlink(hlink2)) {
|
||||||
if (verbose > 0) {
|
if (verbose > 0) {
|
||||||
rprintf(FINFO,
|
rsyserr(FINFO, errno,
|
||||||
"unlink %s failed: %s\n",
|
"unlink %s failed",
|
||||||
full_fname(hlink2),
|
full_fname(hlink2));
|
||||||
strerror(errno));
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
25
io.c
25
io.c
@@ -137,7 +137,7 @@ static void check_timeout(void)
|
|||||||
|
|
||||||
if (last_io && io_timeout && (t-last_io) >= io_timeout) {
|
if (last_io && io_timeout && (t-last_io) >= io_timeout) {
|
||||||
if (!am_server && !am_daemon) {
|
if (!am_server && !am_daemon) {
|
||||||
rprintf(FERROR,"io timeout after %d seconds - exiting\n",
|
rprintf(FERROR, "io timeout after %d seconds - exiting\n",
|
||||||
(int)(t-last_io));
|
(int)(t-last_io));
|
||||||
}
|
}
|
||||||
exit_cleanup(RERR_TIMEOUT);
|
exit_cleanup(RERR_TIMEOUT);
|
||||||
@@ -334,10 +334,9 @@ static void whine_about_eof(void)
|
|||||||
if (kludge_around_eof)
|
if (kludge_around_eof)
|
||||||
exit_cleanup(0);
|
exit_cleanup(0);
|
||||||
else {
|
else {
|
||||||
rprintf(FERROR,
|
rprintf(FERROR, RSYNC_NAME ": connection unexpectedly closed "
|
||||||
"%s: connection unexpectedly closed "
|
|
||||||
"(%.0f bytes read so far)\n",
|
"(%.0f bytes read so far)\n",
|
||||||
RSYNC_NAME, (double)stats.total_read);
|
(double)stats.total_read);
|
||||||
|
|
||||||
exit_cleanup(RERR_STREAMIO);
|
exit_cleanup(RERR_STREAMIO);
|
||||||
}
|
}
|
||||||
@@ -349,8 +348,7 @@ static void die_from_readerr(int err)
|
|||||||
/* this prevents us trying to write errors on a dead socket */
|
/* this prevents us trying to write errors on a dead socket */
|
||||||
io_multiplexing_close();
|
io_multiplexing_close();
|
||||||
|
|
||||||
rprintf(FERROR, "%s: read error: %s\n",
|
rsyserr(FERROR, err, "read error");
|
||||||
RSYNC_NAME, strerror(err));
|
|
||||||
exit_cleanup(RERR_STREAMIO);
|
exit_cleanup(RERR_STREAMIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,7 +366,7 @@ static void die_from_readerr(int err)
|
|||||||
*/
|
*/
|
||||||
static int read_timeout(int fd, char *buf, size_t len)
|
static int read_timeout(int fd, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
int n, ret=0;
|
int n, ret = 0;
|
||||||
|
|
||||||
io_flush(NORMAL_FLUSH);
|
io_flush(NORMAL_FLUSH);
|
||||||
|
|
||||||
@@ -508,8 +506,8 @@ static int read_timeout(int fd, char *buf, size_t len)
|
|||||||
whine_about_eof();
|
whine_about_eof();
|
||||||
return -1; /* doesn't return */
|
return -1; /* doesn't return */
|
||||||
} else if (n < 0) {
|
} else if (n < 0) {
|
||||||
if (errno == EINTR || errno == EWOULDBLOCK ||
|
if (errno == EINTR || errno == EWOULDBLOCK
|
||||||
errno == EAGAIN)
|
|| errno == EAGAIN)
|
||||||
continue;
|
continue;
|
||||||
die_from_readerr(errno);
|
die_from_readerr(errno);
|
||||||
}
|
}
|
||||||
@@ -671,7 +669,7 @@ static int read_unbuffered(int fd, char *buf, size_t len)
|
|||||||
static void readfd(int fd, char *buffer, size_t N)
|
static void readfd(int fd, char *buffer, size_t N)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
size_t total=0;
|
size_t total = 0;
|
||||||
|
|
||||||
while (total < N) {
|
while (total < N) {
|
||||||
ret = read_unbuffered(fd, buffer + total, N-total);
|
ret = read_unbuffered(fd, buffer + total, N-total);
|
||||||
@@ -829,10 +827,9 @@ static void writefd_unbuffered(int fd,char *buf,size_t len)
|
|||||||
/* Don't try to write errors back
|
/* Don't try to write errors back
|
||||||
* across the stream */
|
* across the stream */
|
||||||
io_multiplexing_close();
|
io_multiplexing_close();
|
||||||
rprintf(FERROR, RSYNC_NAME
|
rsyserr(FERROR, errno,
|
||||||
": writefd_unbuffered failed to write %ld bytes: phase \"%s\": %s\n",
|
"writefd_unbuffered failed to write %ld bytes: phase \"%s\"",
|
||||||
(long) len, io_write_phase,
|
(long) len, io_write_phase);
|
||||||
strerror(errno));
|
|
||||||
exit_cleanup(RERR_STREAMIO);
|
exit_cleanup(RERR_STREAMIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
params.c
4
params.c
@@ -491,8 +491,8 @@ static FILE *OpenConfFile( char *FileName )
|
|||||||
OpenedFile = fopen( FileName, "r" );
|
OpenedFile = fopen( FileName, "r" );
|
||||||
if( NULL == OpenedFile )
|
if( NULL == OpenedFile )
|
||||||
{
|
{
|
||||||
rprintf(FERROR,"rsync: unable to open configuration file \"%s\": %s\n",
|
rsyserr(FERROR, errno, "rsync: unable to open configuration file \"%s\"",
|
||||||
FileName, strerror(errno));
|
FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return( OpenedFile );
|
return( OpenedFile );
|
||||||
|
|||||||
20
pipe.c
20
pipe.c
@@ -52,14 +52,14 @@ pid_t piped_child(char **command, int *f_in, int *f_out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fd_pair(to_child_pipe) < 0 || fd_pair(from_child_pipe) < 0) {
|
if (fd_pair(to_child_pipe) < 0 || fd_pair(from_child_pipe) < 0) {
|
||||||
rprintf(FERROR, "pipe: %s\n", strerror(errno));
|
rsyserr(FERROR, errno, "pipe");
|
||||||
exit_cleanup(RERR_IPC);
|
exit_cleanup(RERR_IPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pid = do_fork();
|
pid = do_fork();
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
rprintf(FERROR, "fork: %s\n", strerror(errno));
|
rsyserr(FERROR, errno, "fork");
|
||||||
exit_cleanup(RERR_IPC);
|
exit_cleanup(RERR_IPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,8 +68,7 @@ pid_t piped_child(char **command, int *f_in, int *f_out)
|
|||||||
close(to_child_pipe[1]) < 0 ||
|
close(to_child_pipe[1]) < 0 ||
|
||||||
close(from_child_pipe[0]) < 0 ||
|
close(from_child_pipe[0]) < 0 ||
|
||||||
dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
|
dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
|
||||||
rprintf(FERROR, "Failed to dup/close : %s\n",
|
rsyserr(FERROR, errno, "Failed to dup/close");
|
||||||
strerror(errno));
|
|
||||||
exit_cleanup(RERR_IPC);
|
exit_cleanup(RERR_IPC);
|
||||||
}
|
}
|
||||||
if (to_child_pipe[0] != STDIN_FILENO)
|
if (to_child_pipe[0] != STDIN_FILENO)
|
||||||
@@ -81,13 +80,12 @@ pid_t piped_child(char **command, int *f_in, int *f_out)
|
|||||||
if (blocking_io > 0)
|
if (blocking_io > 0)
|
||||||
set_blocking(STDOUT_FILENO);
|
set_blocking(STDOUT_FILENO);
|
||||||
execvp(command[0], command);
|
execvp(command[0], command);
|
||||||
rprintf(FERROR, "Failed to exec %s : %s\n",
|
rsyserr(FERROR, errno, "Failed to exec %s", command[0]);
|
||||||
command[0], strerror(errno));
|
|
||||||
exit_cleanup(RERR_IPC);
|
exit_cleanup(RERR_IPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (close(from_child_pipe[1]) < 0 || close(to_child_pipe[0]) < 0) {
|
if (close(from_child_pipe[1]) < 0 || close(to_child_pipe[0]) < 0) {
|
||||||
rprintf(FERROR, "Failed to close : %s\n", strerror(errno));
|
rsyserr(FERROR, errno, "Failed to close");
|
||||||
exit_cleanup(RERR_IPC);
|
exit_cleanup(RERR_IPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,14 +104,14 @@ pid_t local_child(int argc, char **argv,int *f_in,int *f_out,
|
|||||||
|
|
||||||
if (fd_pair(to_child_pipe) < 0 ||
|
if (fd_pair(to_child_pipe) < 0 ||
|
||||||
fd_pair(from_child_pipe) < 0) {
|
fd_pair(from_child_pipe) < 0) {
|
||||||
rprintf(FERROR,"pipe: %s\n",strerror(errno));
|
rsyserr(FERROR, errno, "pipe");
|
||||||
exit_cleanup(RERR_IPC);
|
exit_cleanup(RERR_IPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pid = do_fork();
|
pid = do_fork();
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
rprintf(FERROR,"fork: %s\n",strerror(errno));
|
rsyserr(FERROR, errno, "fork");
|
||||||
exit_cleanup(RERR_IPC);
|
exit_cleanup(RERR_IPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +126,7 @@ pid_t local_child(int argc, char **argv,int *f_in,int *f_out,
|
|||||||
close(to_child_pipe[1]) < 0 ||
|
close(to_child_pipe[1]) < 0 ||
|
||||||
close(from_child_pipe[0]) < 0 ||
|
close(from_child_pipe[0]) < 0 ||
|
||||||
dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
|
dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
|
||||||
rprintf(FERROR,"Failed to dup/close : %s\n",strerror(errno));
|
rsyserr(FERROR, errno, "Failed to dup/close");
|
||||||
exit_cleanup(RERR_IPC);
|
exit_cleanup(RERR_IPC);
|
||||||
}
|
}
|
||||||
if (to_child_pipe[0] != STDIN_FILENO) close(to_child_pipe[0]);
|
if (to_child_pipe[0] != STDIN_FILENO) close(to_child_pipe[0]);
|
||||||
@@ -141,7 +139,7 @@ pid_t local_child(int argc, char **argv,int *f_in,int *f_out,
|
|||||||
|
|
||||||
if (close(from_child_pipe[1]) < 0 ||
|
if (close(from_child_pipe[1]) < 0 ||
|
||||||
close(to_child_pipe[0]) < 0) {
|
close(to_child_pipe[0]) < 0) {
|
||||||
rprintf(FERROR,"Failed to close : %s\n",strerror(errno));
|
rsyserr(FERROR, errno, "Failed to close");
|
||||||
exit_cleanup(RERR_IPC);
|
exit_cleanup(RERR_IPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
33
receiver.c
33
receiver.c
@@ -51,16 +51,17 @@ static void delete_one(char *fn, int is_dir)
|
|||||||
{
|
{
|
||||||
if (!is_dir) {
|
if (!is_dir) {
|
||||||
if (robust_unlink(fn) != 0) {
|
if (robust_unlink(fn) != 0) {
|
||||||
rprintf(FERROR, "delete_one: unlink %s failed: %s\n",
|
rsyserr(FERROR, errno, "delete_one: unlink %s failed",
|
||||||
full_fname(fn), strerror(errno));
|
full_fname(fn));
|
||||||
} else if (verbose) {
|
} else if (verbose) {
|
||||||
rprintf(FINFO, "deleting %s\n", fn);
|
rprintf(FINFO, "deleting %s\n", fn);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (do_rmdir(fn) != 0) {
|
if (do_rmdir(fn) != 0) {
|
||||||
if (errno != ENOTEMPTY && errno != EEXIST) {
|
if (errno != ENOTEMPTY && errno != EEXIST) {
|
||||||
rprintf(FERROR, "delete_one: rmdir %s failed: %s\n",
|
rsyserr(FERROR, errno,
|
||||||
full_fname(fn), strerror(errno));
|
"delete_one: rmdir %s failed",
|
||||||
|
full_fname(fn));
|
||||||
}
|
}
|
||||||
} else if (verbose) {
|
} else if (verbose) {
|
||||||
rprintf(FINFO, "deleting directory %s\n", fn);
|
rprintf(FINFO, "deleting directory %s\n", fn);
|
||||||
@@ -223,8 +224,8 @@ static int receive_data(int f_in,struct map_struct *mapbuf,int fd,char *fname,
|
|||||||
sum_update(data,i);
|
sum_update(data,i);
|
||||||
|
|
||||||
if (fd != -1 && write_file(fd,data,i) != i) {
|
if (fd != -1 && write_file(fd,data,i) != i) {
|
||||||
rprintf(FERROR, "write failed on %s: %s\n",
|
rsyserr(FERROR, errno, "write failed on %s",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
exit_cleanup(RERR_FILEIO);
|
exit_cleanup(RERR_FILEIO);
|
||||||
}
|
}
|
||||||
offset += i;
|
offset += i;
|
||||||
@@ -251,8 +252,8 @@ static int receive_data(int f_in,struct map_struct *mapbuf,int fd,char *fname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fd != -1 && write_file(fd,map,len) != (int) len) {
|
if (fd != -1 && write_file(fd,map,len) != (int) len) {
|
||||||
rprintf(FERROR, "write failed on %s: %s\n",
|
rsyserr(FERROR, errno, "write failed on %s",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
exit_cleanup(RERR_FILEIO);
|
exit_cleanup(RERR_FILEIO);
|
||||||
}
|
}
|
||||||
offset += len;
|
offset += len;
|
||||||
@@ -264,8 +265,8 @@ static int receive_data(int f_in,struct map_struct *mapbuf,int fd,char *fname,
|
|||||||
end_progress(total_size);
|
end_progress(total_size);
|
||||||
|
|
||||||
if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
|
if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
|
||||||
rprintf(FERROR, "write failed on %s: %s\n",
|
rsyserr(FERROR, errno, "write failed on %s",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
exit_cleanup(RERR_FILEIO);
|
exit_cleanup(RERR_FILEIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,8 +372,8 @@ int recv_files(int f_in,struct file_list *flist,char *local_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fd1 != -1 && do_fstat(fd1,&st) != 0) {
|
if (fd1 != -1 && do_fstat(fd1,&st) != 0) {
|
||||||
rprintf(FERROR, "fstat %s failed: %s\n",
|
rsyserr(FERROR, errno, "fstat %s failed",
|
||||||
full_fname(fnamecmp), strerror(errno));
|
full_fname(fnamecmp));
|
||||||
receive_data(f_in,NULL,-1,NULL,file->length);
|
receive_data(f_in,NULL,-1,NULL,file->length);
|
||||||
close(fd1);
|
close(fd1);
|
||||||
continue;
|
continue;
|
||||||
@@ -436,8 +437,8 @@ int recv_files(int f_in,struct file_list *flist,char *local_name)
|
|||||||
fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
|
fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
|
||||||
}
|
}
|
||||||
if (fd2 == -1) {
|
if (fd2 == -1) {
|
||||||
rprintf(FERROR, "mkstemp %s failed: %s\n",
|
rsyserr(FERROR, errno, "mkstemp %s failed",
|
||||||
full_fname(fnametmp), strerror(errno));
|
full_fname(fnametmp));
|
||||||
receive_data(f_in,mapbuf,-1,NULL,file->length);
|
receive_data(f_in,mapbuf,-1,NULL,file->length);
|
||||||
if (mapbuf) unmap_file(mapbuf);
|
if (mapbuf) unmap_file(mapbuf);
|
||||||
if (fd1 != -1) close(fd1);
|
if (fd1 != -1) close(fd1);
|
||||||
@@ -460,8 +461,8 @@ int recv_files(int f_in,struct file_list *flist,char *local_name)
|
|||||||
close(fd1);
|
close(fd1);
|
||||||
}
|
}
|
||||||
if (close(fd2) < 0) {
|
if (close(fd2) < 0) {
|
||||||
rprintf(FERROR, "close failed on %s: %s\n",
|
rsyserr(FERROR, errno, "close failed on %s",
|
||||||
full_fname(fnametmp), strerror(errno));
|
full_fname(fnametmp));
|
||||||
exit_cleanup(RERR_FILEIO);
|
exit_cleanup(RERR_FILEIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
40
rsync.c
40
rsync.c
@@ -68,8 +68,8 @@ int delete_file(char *fname)
|
|||||||
if (!S_ISDIR(st.st_mode)) {
|
if (!S_ISDIR(st.st_mode)) {
|
||||||
if (robust_unlink(fname) == 0 || errno == ENOENT)
|
if (robust_unlink(fname) == 0 || errno == ENOENT)
|
||||||
return 0;
|
return 0;
|
||||||
rprintf(FERROR, "delete_file: unlink %s failed: %s\n",
|
rsyserr(FERROR, errno, "delete_file: unlink %s failed",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,15 +77,15 @@ int delete_file(char *fname)
|
|||||||
return 0;
|
return 0;
|
||||||
if (!force_delete || !recurse
|
if (!force_delete || !recurse
|
||||||
|| (errno != ENOTEMPTY && errno != EEXIST)) {
|
|| (errno != ENOTEMPTY && errno != EEXIST)) {
|
||||||
rprintf(FERROR, "delete_file: rmdir %s failed: %s\n",
|
rsyserr(FERROR, errno, "delete_file: rmdir %s failed",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now we do a recsursive delete on the directory ... */
|
/* now we do a recsursive delete on the directory ... */
|
||||||
if (!(d = opendir(fname))) {
|
if (!(d = opendir(fname))) {
|
||||||
rprintf(FERROR, "delete_file: opendir %s failed: %s\n",
|
rsyserr(FERROR, errno, "delete_file: opendir %s failed",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,8 +103,8 @@ int delete_file(char *fname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (errno) {
|
if (errno) {
|
||||||
rprintf(FERROR, "delete_file: readdir %s failed: %s\n",
|
rsyserr(FERROR, errno, "delete_file: readdir %s failed",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
closedir(d);
|
closedir(d);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -112,8 +112,8 @@ int delete_file(char *fname)
|
|||||||
closedir(d);
|
closedir(d);
|
||||||
|
|
||||||
if (do_rmdir(fname) != 0) {
|
if (do_rmdir(fname) != 0) {
|
||||||
rprintf(FERROR, "delete_file: rmdir %s failed: %s\n",
|
rsyserr(FERROR, errno, "delete_file: rmdir %s failed",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,8 +131,8 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
|
|||||||
|
|
||||||
if (!st) {
|
if (!st) {
|
||||||
if (link_stat(fname,&st2) != 0) {
|
if (link_stat(fname,&st2) != 0) {
|
||||||
rprintf(FERROR, "stat %s failed: %s\n",
|
rsyserr(FERROR, errno, "stat %s failed",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
st = &st2;
|
st = &st2;
|
||||||
@@ -146,8 +146,8 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
|
|||||||
* because some filesystems can't do it */
|
* because some filesystems can't do it */
|
||||||
if (set_modtime(fname,file->modtime) != 0 &&
|
if (set_modtime(fname,file->modtime) != 0 &&
|
||||||
!S_ISDIR(st->st_mode)) {
|
!S_ISDIR(st->st_mode)) {
|
||||||
rprintf(FERROR, "failed to set times on %s: %s\n",
|
rsyserr(FERROR, errno, "failed to set times on %s",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
updated = 1;
|
updated = 1;
|
||||||
@@ -174,9 +174,9 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
|
|||||||
change_gid ? file->gid : st->st_gid) != 0) {
|
change_gid ? file->gid : st->st_gid) != 0) {
|
||||||
/* shouldn't have attempted to change uid or gid
|
/* shouldn't have attempted to change uid or gid
|
||||||
* unless have the privilege */
|
* unless have the privilege */
|
||||||
rprintf(FERROR, "%s %s failed: %s\n",
|
rsyserr(FERROR, errno, "%s %s failed",
|
||||||
change_uid ? "chown" : "chgrp",
|
change_uid ? "chown" : "chgrp",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* a lchown had been done - we have to re-stat if the
|
/* a lchown had been done - we have to re-stat if the
|
||||||
@@ -193,8 +193,8 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
|
|||||||
if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) {
|
if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) {
|
||||||
updated = 1;
|
updated = 1;
|
||||||
if (do_chmod(fname,(file->mode & CHMOD_BITS)) != 0) {
|
if (do_chmod(fname,(file->mode & CHMOD_BITS)) != 0) {
|
||||||
rprintf(FERROR, "failed to set permissions on %s: %s\n",
|
rsyserr(FERROR, errno, "failed to set permissions on %s",
|
||||||
full_fname(fname), strerror(errno));
|
full_fname(fname));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,9 +239,9 @@ void finish_transfer(char *fname, char *fnametmp, struct file_struct *file,
|
|||||||
/* move tmp file over real file */
|
/* move tmp file over real file */
|
||||||
ret = robust_rename(fnametmp, fname, file->mode & INITACCESSPERMS);
|
ret = robust_rename(fnametmp, fname, file->mode & INITACCESSPERMS);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
rprintf(FERROR, "%s %s -> \"%s\": %s\n",
|
rsyserr(FERROR, errno, "%s %s -> \"%s\"",
|
||||||
ret == -2 ? "copy" : "rename",
|
ret == -2 ? "copy" : "rename",
|
||||||
full_fname(fnametmp), fname, strerror(errno));
|
full_fname(fnametmp), fname);
|
||||||
do_unlink(fnametmp);
|
do_unlink(fnametmp);
|
||||||
} else {
|
} else {
|
||||||
set_perms(fname, file, NULL,
|
set_perms(fname, file, NULL,
|
||||||
|
|||||||
13
sender.c
13
sender.c
@@ -201,8 +201,9 @@ void send_files(struct file_list *flist, int f_out, int f_in)
|
|||||||
full_fname(fname));
|
full_fname(fname));
|
||||||
} else {
|
} else {
|
||||||
io_error |= IOERR_GENERAL;
|
io_error |= IOERR_GENERAL;
|
||||||
rprintf(FERROR, "send_files failed to open %s: %s\n",
|
rsyserr(FERROR, errno,
|
||||||
full_fname(fname), strerror(errno));
|
"send_files failed to open %s",
|
||||||
|
full_fname(fname));
|
||||||
}
|
}
|
||||||
free_sums(s);
|
free_sums(s);
|
||||||
continue;
|
continue;
|
||||||
@@ -211,7 +212,7 @@ void send_files(struct file_list *flist, int f_out, int f_in)
|
|||||||
/* map the local file */
|
/* map the local file */
|
||||||
if (do_fstat(fd, &st) != 0) {
|
if (do_fstat(fd, &st) != 0) {
|
||||||
io_error |= IOERR_GENERAL;
|
io_error |= IOERR_GENERAL;
|
||||||
rprintf(FERROR, "fstat failed: %s\n", strerror(errno));
|
rsyserr(FERROR, errno, "fstat failed");
|
||||||
free_sums(s);
|
free_sums(s);
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
@@ -287,9 +288,9 @@ void send_files(struct file_list *flist, int f_out, int f_in)
|
|||||||
j = unmap_file(mbuf);
|
j = unmap_file(mbuf);
|
||||||
if (j) {
|
if (j) {
|
||||||
io_error |= IOERR_GENERAL;
|
io_error |= IOERR_GENERAL;
|
||||||
rprintf(FERROR,
|
rsyserr(FERROR, j,
|
||||||
"read errors mapping %s: (%d) %s\n",
|
"read errors mapping %s",
|
||||||
full_fname(fname), j, strerror(j));
|
full_fname(fname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|||||||
32
socket.c
32
socket.c
@@ -71,15 +71,13 @@ static int establish_proxy_connection(int fd, char *host, int port,
|
|||||||
host, port, authhdr, authbuf);
|
host, port, authhdr, authbuf);
|
||||||
len = strlen(buffer);
|
len = strlen(buffer);
|
||||||
if (write(fd, buffer, len) != len) {
|
if (write(fd, buffer, len) != len) {
|
||||||
rprintf(FERROR, "failed to write to proxy: %s\n",
|
rsyserr(FERROR, errno, "failed to write to proxy");
|
||||||
strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (cp = buffer; cp < &buffer[sizeof buffer - 1]; cp++) {
|
for (cp = buffer; cp < &buffer[sizeof buffer - 1]; cp++) {
|
||||||
if (read(fd, cp, 1) != 1) {
|
if (read(fd, cp, 1) != 1) {
|
||||||
rprintf(FERROR, "failed to read from proxy: %s\n",
|
rsyserr(FERROR, errno, "failed to read from proxy");
|
||||||
strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (*cp == '\n')
|
if (*cp == '\n')
|
||||||
@@ -108,8 +106,8 @@ static int establish_proxy_connection(int fd, char *host, int port,
|
|||||||
while (1) {
|
while (1) {
|
||||||
for (cp = buffer; cp < &buffer[sizeof buffer - 1]; cp++) {
|
for (cp = buffer; cp < &buffer[sizeof buffer - 1]; cp++) {
|
||||||
if (read(fd, cp, 1) != 1) {
|
if (read(fd, cp, 1) != 1) {
|
||||||
rprintf(FERROR, "failed to read from proxy: %s\n",
|
rsyserr(FERROR, errno,
|
||||||
strerror(errno));
|
"failed to read from proxy");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (*cp == '\n')
|
if (*cp == '\n')
|
||||||
@@ -278,8 +276,7 @@ int open_socket_out(char *host, int port, const char *bind_address,
|
|||||||
}
|
}
|
||||||
freeaddrinfo(res0);
|
freeaddrinfo(res0);
|
||||||
if (s < 0) {
|
if (s < 0) {
|
||||||
rprintf(FERROR, RSYNC_NAME ": failed to connect to %s: %s\n",
|
rsyserr(FERROR, errno, "failed to connect to %s", h);
|
||||||
h, strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
@@ -450,8 +447,7 @@ void start_accept_loop(int port, int (*fn)(int, int))
|
|||||||
FD_ZERO(&deffds);
|
FD_ZERO(&deffds);
|
||||||
for (i = 0, maxfd = -1; sp[i] >= 0; i++) {
|
for (i = 0, maxfd = -1; sp[i] >= 0; i++) {
|
||||||
if (listen(sp[i], 5) < 0) {
|
if (listen(sp[i], 5) < 0) {
|
||||||
rprintf(FERROR, "listen() on socket failed: %s\n",
|
rsyserr(FERROR, errno, "listen() on socket failed");
|
||||||
strerror(errno));
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
if (errno == EADDRINUSE && i > 0) {
|
if (errno == EADDRINUSE && i > 0) {
|
||||||
rprintf(FINFO,
|
rprintf(FINFO,
|
||||||
@@ -513,10 +509,8 @@ void start_accept_loop(int port, int (*fn)(int, int))
|
|||||||
close_all();
|
close_all();
|
||||||
_exit(ret);
|
_exit(ret);
|
||||||
} else if (pid < 0) {
|
} else if (pid < 0) {
|
||||||
rprintf(FERROR,
|
rsyserr(FERROR, errno,
|
||||||
RSYNC_NAME
|
"could not create child server process");
|
||||||
": could not create child server process: %s\n",
|
|
||||||
strerror(errno));
|
|
||||||
close(fd);
|
close(fd);
|
||||||
/* This might have happened because we're
|
/* This might have happened because we're
|
||||||
* overloaded. Sleep briefly before trying to
|
* overloaded. Sleep briefly before trying to
|
||||||
@@ -633,9 +627,10 @@ void set_socket_options(int fd, char *options)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0) {
|
||||||
rprintf(FERROR, "failed to set socket option %s: %s\n", tok,
|
rsyserr(FERROR, errno,
|
||||||
strerror(errno));
|
"failed to set socket option %s", tok);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(options);
|
free(options);
|
||||||
@@ -765,8 +760,7 @@ int sock_exec(const char *prog)
|
|||||||
int fd[2];
|
int fd[2];
|
||||||
|
|
||||||
if (socketpair_tcp(fd) != 0) {
|
if (socketpair_tcp(fd) != 0) {
|
||||||
rprintf(FERROR, RSYNC_NAME ": socketpair_tcp failed (%s)\n",
|
rsyserr(FERROR, errno, "socketpair_tcp failed");
|
||||||
strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (verbose >= 2)
|
if (verbose >= 2)
|
||||||
|
|||||||
23
util.c
23
util.c
@@ -252,29 +252,25 @@ int copy_file(char *source, char *dest, mode_t mode)
|
|||||||
|
|
||||||
ifd = do_open(source, O_RDONLY, 0);
|
ifd = do_open(source, O_RDONLY, 0);
|
||||||
if (ifd == -1) {
|
if (ifd == -1) {
|
||||||
rprintf(FERROR,"open %s: %s\n",
|
rsyserr(FERROR, errno, "open %s", full_fname(source));
|
||||||
full_fname(source), strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (robust_unlink(dest) && errno != ENOENT) {
|
if (robust_unlink(dest) && errno != ENOENT) {
|
||||||
rprintf(FERROR,"unlink %s: %s\n",
|
rsyserr(FERROR, errno, "unlink %s", full_fname(dest));
|
||||||
full_fname(dest), strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode);
|
ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode);
|
||||||
if (ofd == -1) {
|
if (ofd == -1) {
|
||||||
rprintf(FERROR,"open %s: %s\n",
|
rsyserr(FERROR, errno, "open %s", full_fname(dest));
|
||||||
full_fname(dest), strerror(errno));
|
|
||||||
close(ifd);
|
close(ifd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((len = safe_read(ifd, buf, sizeof buf)) > 0) {
|
while ((len = safe_read(ifd, buf, sizeof buf)) > 0) {
|
||||||
if (full_write(ofd, buf, len) < 0) {
|
if (full_write(ofd, buf, len) < 0) {
|
||||||
rprintf(FERROR,"write %s: %s\n",
|
rsyserr(FERROR, errno, "write %s", full_fname(dest));
|
||||||
full_fname(dest), strerror(errno));
|
|
||||||
close(ifd);
|
close(ifd);
|
||||||
close(ofd);
|
close(ofd);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -282,21 +278,20 @@ int copy_file(char *source, char *dest, mode_t mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
rprintf(FERROR, "read %s: %s\n",
|
rsyserr(FERROR, errno, "read %s", full_fname(source));
|
||||||
full_fname(source), strerror(errno));
|
|
||||||
close(ifd);
|
close(ifd);
|
||||||
close(ofd);
|
close(ofd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (close(ifd) < 0) {
|
if (close(ifd) < 0) {
|
||||||
rprintf(FINFO, "close failed on %s: %s\n",
|
rsyserr(FINFO, errno, "close failed on %s",
|
||||||
full_fname(source), strerror(errno));
|
full_fname(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (close(ofd) < 0) {
|
if (close(ofd) < 0) {
|
||||||
rprintf(FERROR, "close failed on %s: %s\n",
|
rsyserr(FERROR, errno, "close failed on %s",
|
||||||
full_fname(dest), strerror(errno));
|
full_fname(dest));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user