if (do_rename(fname, fnamebak) != 0) {
/* cygwin (at least version b19) reports 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;
}
} else if (verbose > 1) {
if (do_mkdir(fullpath, 0777 & ~orig_umask) == 0)
break;
if (errno != ENOENT) {
- rprintf(FERROR,
- "make_bak_dir mkdir %s failed: %s\n",
- full_fname(fullpath), strerror(errno));
+ rsyserr(FERROR, errno,
+ "make_bak_dir mkdir %s failed",
+ full_fname(fullpath));
goto failure;
}
}
/* Try to transfer the directory settings of the
* actual dir that the files are coming from. */
if (do_lstat(rel, &st) != 0) {
- rprintf(FERROR,
- "make_bak_dir stat %s failed: %s\n",
- full_fname(rel), strerror(errno));
+ rsyserr(FERROR, errno,
+ "make_bak_dir stat %s failed",
+ full_fname(rel));
} else {
do_lchown(fullpath, st.st_uid, st.st_gid);
do_chmod(fullpath, st.st_mode);
if (p == end)
break;
if (do_mkdir(fullpath, 0777 & ~orig_umask) < 0) {
- rprintf(FERROR,
- "make_bak_dir mkdir %s failed: %s\n",
- full_fname(fullpath), strerror(errno));
+ rsyserr(FERROR, errno, "make_bak_dir mkdir %s failed",
+ full_fname(fullpath));
goto failure;
}
}
if (do_mknod(backup_dir_buf, file->mode, file->u.rdev) < 0
&& (errno != ENOENT || make_bak_dir(backup_dir_buf) < 0
|| do_mknod(backup_dir_buf, file->mode, file->u.rdev) < 0)) {
- rprintf(FERROR, "mknod %s failed: %s\n",
- full_fname(backup_dir_buf), strerror(errno));
+ rsyserr(FERROR, errno, "mknod %s failed",
+ full_fname(backup_dir_buf));
} else if (verbose > 2) {
rprintf(FINFO,
"make_backup: DEVICE %s successful.\n",
if (do_mkdir(backup_dir_buf, file->mode) < 0
&& (errno != ENOENT || make_bak_dir(backup_dir_buf) < 0
|| do_mkdir(backup_dir_buf, file->mode) < 0)) {
- rprintf(FINFO, "mkdir %s failed: %s\n",
- full_fname(backup_dir_buf), strerror(errno));
+ rsyserr(FINFO, errno, "mkdir %s failed",
+ full_fname(backup_dir_buf));
}
ret_code = do_rmdir(fname);
if (do_symlink(file->u.link, backup_dir_buf) < 0
&& (errno != ENOENT || make_bak_dir(backup_dir_buf) < 0
|| do_symlink(file->u.link, backup_dir_buf) < 0)) {
- rprintf(FERROR, "link %s -> %s : %s\n",
- full_fname(backup_dir_buf), file->u.link, strerror(errno));
+ rsyserr(FERROR, errno, "link %s -> \"%s\"",
+ full_fname(backup_dir_buf), file->u.link);
}
do_unlink(fname);
kept = 1;
/* move to keep tree if a file */
if (!kept) {
if (robust_move(fname, backup_dir_buf) != 0) {
- rprintf(FERROR, "keep_backup failed: %s -> \"%s\": %s\n",
- full_fname(fname), backup_dir_buf, strerror(errno));
+ rsyserr(FERROR, errno, "keep_backup failed: %s -> \"%s\"",
+ full_fname(fname), backup_dir_buf);
}
}
set_perms(backup_dir_buf, file, NULL, 0);
f = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (f < 0) {
- rprintf(FERROR, "Batch file %s open error: %s\n",
- filename, strerror(errno));
+ rsyserr(FERROR, errno, "Batch file %s open error", filename);
exit_cleanup(1);
}
f = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IEXEC);
if (f < 0) {
- rprintf(FERROR, "Batch file %s open error: %s\n",
- filename, strerror(errno));
+ rsyserr(FERROR, errno, "Batch file %s open error", filename);
exit_cleanup(1);
}
buff[0] = '\0';
}
strlcat(buff, "\n", sizeof buff);
if (!write(f, buff, strlen(buff))) {
- rprintf(FERROR, "Batch file %s write error: %s\n",
- filename, strerror(errno));
+ rsyserr(FERROR, errno, "Batch file %s write error", filename);
close(f);
exit_cleanup(1);
}
f = do_open(filename, O_RDONLY, 0);
if (f < 0) {
- rprintf(FERROR, "Batch file %s open error: %s\n",
- filename, strerror(errno));
+ rsyserr(FERROR, errno, "Batch file %s open error", filename);
exit_cleanup(1);
}
void write_batch_csums_file(void *buff, int bytes_to_write)
{
if (write(f_csums, buff, bytes_to_write) < 0) {
- rprintf(FERROR, "Batch file write error: %s\n",
- strerror(errno));
+ rsyserr(FERROR, errno, "Batch file write error");
close(f_csums);
exit_cleanup(1);
}
f_csums = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR);
if (f_csums < 0) {
- rprintf(FERROR, "Batch file %s open error: %s\n",
- filename, strerror(errno));
+ rsyserr(FERROR, errno, "Batch file %s open error",
+ filename);
close(f_csums);
exit_cleanup(1);
}
int bytes_read;
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);
exit_cleanup(1);
}
f_csums = do_open(filename, O_RDONLY, 0);
if (f_csums < 0) {
- rprintf(FERROR, "Batch file %s open error: %s\n",
- filename, strerror(errno));
+ rsyserr(FERROR, errno, "Batch file %s open error",
+ filename);
close(f_csums);
exit_cleanup(1);
}
f_delta = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR);
if (f_delta < 0) {
- rprintf(FERROR, "Batch file %s open error: %s\n",
- filename, strerror(errno));
+ rsyserr(FERROR, errno, "Batch file %s open error",
+ filename);
exit_cleanup(1);
}
}
if (write(f_delta, buff, bytes_to_write) < 0) {
- rprintf(FERROR, "Batch file %s write error: %s\n",
- filename, strerror(errno));
+ rsyserr(FERROR, errno, "Batch file %s write error", filename);
close(f_delta);
exit_cleanup(1);
}
f_delta = do_open(filename, O_RDONLY, 0);
if (f_delta < 0) {
- rprintf(FERROR, "Batch file %s open error: %s\n",
- filename, strerror(errno));
+ rsyserr(FERROR, errno, "Batch file %s open error",
+ filename);
close(f_delta);
exit_cleanup(1);
}
bytes_read = read(f_delta, buff, len);
if (bytes_read < 0) {
- rprintf(FERROR, "Batch file %s read error: %s\n",
- filename, strerror(errno));
+ rsyserr(FERROR, errno, "Batch file %s read error", filename);
close(f_delta);
exit_cleanup(1);
}
if (getpeername(fd, (struct sockaddr *) ss, ss_len)) {
/* FIXME: Can we really not continue? */
- rprintf(FERROR, RSYNC_NAME ": getpeername on fd%d failed: %s\n",
- fd, strerror(errno));
+ rsyserr(FERROR, errno, "getpeername on fd%d failed", fd);
exit_cleanup(RERR_SOCKETIO);
}
if (!claim_connection(lp_lock_file(i), lp_max_connections(i))) {
if (errno) {
- rprintf(FERROR,"failed to open lock file %s : %s\n",
- lp_lock_file(i), strerror(errno));
- io_printf(f_out, "@ERROR: failed to open lock file %s : %s\n",
- lp_lock_file(i), strerror(errno));
+ rsyserr(FERROR, errno, "failed to open lock file %s",
+ lp_lock_file(i));
+ io_printf(f_out, "@ERROR: failed to open lock file %s\n",
+ lp_lock_file(i));
} else {
rprintf(FERROR,"max connections (%d) reached\n",
lp_max_connections(i));
}
else {
io_error |= IOERR_GENERAL;
- rprintf(FERROR, "readlink %s failed: %s\n",
- full_fname(thisname), strerror(save_errno));
+ rsyserr(FERROR, save_errno, "readlink %s failed",
+ full_fname(thisname));
}
return NULL;
}
d = opendir(dir);
if (!d) {
io_error |= IOERR_GENERAL;
- rprintf(FERROR, "opendir %s failed: %s\n",
- full_fname(dir), strerror(errno));
+ rsyserr(FERROR, errno, "opendir %s failed", full_fname(dir));
return;
}
}
if (errno) {
io_error |= IOERR_GENERAL;
- rprintf(FERROR, "readdir(%s): (%d) %s\n",
- dir, errno, strerror(errno));
+ rsyserr(FERROR, errno, "readdir(%s)", dir);
}
closedir(d);
io_start_buffering_out(f);
if (filesfrom_fd >= 0) {
if (argv[0] && !push_dir(argv[0])) {
- rprintf(FERROR, "push_dir %s failed: %s\n",
- full_fname(argv[0]), strerror(errno));
+ rsyserr(FERROR, errno, "push_dir %s failed",
+ full_fname(argv[0]));
exit_cleanup(RERR_FILESELECT);
}
use_ff_fd = 1;
if (link_stat(fname, &st) != 0) {
if (f != -1) {
io_error |= IOERR_GENERAL;
- rprintf(FERROR, "link_stat %s failed: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "link_stat %s failed",
+ full_fname(fname));
}
continue;
}
if (!push_dir(dir)) {
io_error |= IOERR_GENERAL;
- rprintf(FERROR, "push_dir %s failed: %s\n",
- full_fname(dir), strerror(errno));
+ rsyserr(FERROR, errno, "push_dir %s failed",
+ full_fname(dir));
continue;
}
flist_dir = NULL;
flist_dir_len = 0;
if (!pop_dir(olddir)) {
- rprintf(FERROR, "pop_dir %s failed: %s\n",
- full_fname(dir), strerror(errno));
+ rsyserr(FERROR, errno, "pop_dir %s failed",
+ full_fname(dir));
exit_cleanup(RERR_FILESELECT);
}
}
if (dry_run) return; /* XXXX -- might cause inaccuracies?? -- mbp */
if (statret == 0 && !S_ISDIR(st.st_mode)) {
if (robust_unlink(fname) != 0) {
- rprintf(FERROR,
- "recv_generator: unlink %s to make room for directory: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno,
+ "recv_generator: unlink %s to make room for directory",
+ full_fname(fname));
return;
}
statret = -1;
}
if (statret != 0 && do_mkdir(fname,file->mode) != 0 && errno != EEXIST) {
- if (!(relative_paths && errno==ENOENT &&
- create_directory_path(fname, orig_umask)==0 &&
- do_mkdir(fname,file->mode)==0)) {
- rprintf(FERROR, "recv_generator: mkdir %s failed: %s\n",
- full_fname(fname), strerror(errno));
+ if (!(relative_paths && errno == ENOENT
+ && create_directory_path(fname, orig_umask) == 0
+ && do_mkdir(fname, file->mode) == 0)) {
+ rsyserr(FERROR, errno,
+ "recv_generator: mkdir %s failed",
+ full_fname(fname));
}
}
/* f_out is set to -1 when doing final directory
delete_file(fname);
}
if (do_symlink(file->u.link,fname) != 0) {
- rprintf(FERROR, "symlink %s -> \"%s\" failed: %s\n",
- full_fname(fname), file->u.link, strerror(errno));
+ rsyserr(FERROR, errno, "symlink %s -> \"%s\" failed",
+ full_fname(fname), file->u.link);
} else {
set_perms(fname,file,NULL,0);
if (verbose) {
st.st_mode != file->mode ||
st.st_rdev != file->u.rdev) {
delete_file(fname);
- if (verbose > 2)
+ if (verbose > 2) {
rprintf(FINFO,"mknod(%s,0%o,0x%x)\n",
fname,(int)file->mode,(int)file->u.rdev);
+ }
if (do_mknod(fname,file->mode,file->u.rdev) != 0) {
- rprintf(FERROR, "mknod %s failed: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "mknod %s failed",
+ full_fname(fname));
} else {
set_perms(fname,file,NULL,0);
if (verbose)
else if (link_dest && !dry_run) {
if (do_link(fnamecmpbuf, fname) != 0) {
if (verbose > 0) {
- rprintf(FINFO,"link %s => %s : %s\n",
- fnamecmpbuf, fname,
- strerror(errno));
+ rsyserr(FINFO, errno, "link %s => %s",
+ fnamecmpbuf, fname);
}
}
fnamecmp = fnamecmpbuf;
write_int(f_out,i);
if (!dry_run) write_sum_head(f_out, NULL);
} else if (verbose > 1) {
- rprintf(FERROR,
- "recv_generator: failed to open %s: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno,
+ "recv_generator: failed to open %s",
+ full_fname(fname));
}
return;
}
fd = do_open(fnamecmp, O_RDONLY, 0);
if (fd == -1) {
- rprintf(FERROR, "failed to open %s, continuing: %s\n",
- full_fname(fnamecmp), strerror(errno));
+ rsyserr(FERROR, errno, "failed to open %s, continuing",
+ full_fname(fnamecmp));
/* pretend the file didn't exist */
if (preserve_hard_links && hard_link_check(file, HL_SKIP))
return;
{
if (do_link(hlink1, hlink2)) {
if (verbose) {
- rprintf(FINFO, "link %s => %s failed: %s\n",
- hlink2, hlink1, strerror(errno));
+ rsyserr(FINFO, errno, "link %s => %s failed",
+ hlink2, hlink1);
}
}
else if (verbose)
continue;
} else if (robust_unlink(hlink2)) {
if (verbose > 0) {
- rprintf(FINFO,
- "unlink %s failed: %s\n",
- full_fname(hlink2),
- strerror(errno));
+ rsyserr(FINFO, errno,
+ "unlink %s failed",
+ full_fname(hlink2));
}
continue;
}
/* -*- c-file-style: "linux" -*-
- *
- * Copyright (C) 1996-2001 by Andrew Tridgell
+ *
+ * Copyright (C) 1996-2001 by Andrew Tridgell
* Copyright (C) Paul Mackerras 1996
* Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
if (last_io && io_timeout && (t-last_io) >= io_timeout) {
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));
}
exit_cleanup(RERR_TIMEOUT);
if (kludge_around_eof)
exit_cleanup(0);
else {
- rprintf(FERROR,
- "%s: connection unexpectedly closed "
+ rprintf(FERROR, RSYNC_NAME ": connection unexpectedly closed "
"(%.0f bytes read so far)\n",
- RSYNC_NAME, (double)stats.total_read);
+ (double)stats.total_read);
exit_cleanup(RERR_STREAMIO);
}
/* this prevents us trying to write errors on a dead socket */
io_multiplexing_close();
- rprintf(FERROR, "%s: read error: %s\n",
- RSYNC_NAME, strerror(err));
+ rsyserr(FERROR, err, "read error");
exit_cleanup(RERR_STREAMIO);
}
*/
static int read_timeout(int fd, char *buf, size_t len)
{
- int n, ret=0;
+ int n, ret = 0;
io_flush(NORMAL_FLUSH);
whine_about_eof();
return -1; /* doesn't return */
} else if (n < 0) {
- if (errno == EINTR || errno == EWOULDBLOCK ||
- errno == EAGAIN)
+ if (errno == EINTR || errno == EWOULDBLOCK
+ || errno == EAGAIN)
continue;
die_from_readerr(errno);
}
/**
* Read from the file descriptor handling multiplexing - return number
* of bytes read.
- *
- * Never returns <= 0.
+ *
+ * Never returns <= 0.
*/
static int read_unbuffered(int fd, char *buf, size_t len)
{
static void readfd(int fd, char *buffer, size_t N)
{
int ret;
- size_t total=0;
+ size_t total = 0;
while (total < N) {
ret = read_unbuffered(fd, buffer + total, N-total);
if (msg_fd_in >= 0) {
FD_ZERO(&r_fds);
FD_SET(msg_fd_in,&r_fds);
- if (msg_fd_in > fd_count)
+ if (msg_fd_in > fd_count)
fd_count = msg_fd_in;
}
/* Don't try to write errors back
* across the stream */
io_multiplexing_close();
- rprintf(FERROR, RSYNC_NAME
- ": writefd_unbuffered failed to write %ld bytes: phase \"%s\": %s\n",
- (long) len, io_write_phase,
- strerror(errno));
+ rsyserr(FERROR, errno,
+ "writefd_unbuffered failed to write %ld bytes: phase \"%s\"",
+ (long) len, io_write_phase);
exit_cleanup(RERR_STREAMIO);
}
sleep_for_bwlimit(ret);
-
+
total += ret;
if (io_timeout)
void io_flush(int flush_it_all)
{
int fd = multiplex_out_fd;
-
+
msg_list_push(flush_it_all);
if (!io_buffer_count || no_flush)
void io_printf(int fd, const char *format, ...)
{
- va_list ap;
+ va_list ap;
char buf[1024];
int len;
OpenedFile = fopen( FileName, "r" );
if( NULL == OpenedFile )
{
- rprintf(FERROR,"rsync: unable to open configuration file \"%s\": %s\n",
- FileName, strerror(errno));
+ rsyserr(FERROR, errno, "rsync: unable to open configuration file \"%s\"",
+ FileName);
}
return( OpenedFile );
}
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);
}
pid = do_fork();
if (pid == -1) {
- rprintf(FERROR, "fork: %s\n", strerror(errno));
+ rsyserr(FERROR, errno, "fork");
exit_cleanup(RERR_IPC);
}
close(to_child_pipe[1]) < 0 ||
close(from_child_pipe[0]) < 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);
}
if (to_child_pipe[0] != STDIN_FILENO)
if (blocking_io > 0)
set_blocking(STDOUT_FILENO);
execvp(command[0], command);
- rprintf(FERROR, "Failed to exec %s : %s\n",
- command[0], strerror(errno));
+ rsyserr(FERROR, errno, "Failed to exec %s", command[0]);
exit_cleanup(RERR_IPC);
}
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);
}
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);
}
pid = do_fork();
if (pid == -1) {
- rprintf(FERROR,"fork: %s\n",strerror(errno));
+ rsyserr(FERROR, errno, "fork");
exit_cleanup(RERR_IPC);
}
close(to_child_pipe[1]) < 0 ||
close(from_child_pipe[0]) < 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);
}
if (to_child_pipe[0] != STDIN_FILENO) close(to_child_pipe[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);
}
{
if (!is_dir) {
if (robust_unlink(fn) != 0) {
- rprintf(FERROR, "delete_one: unlink %s failed: %s\n",
- full_fname(fn), strerror(errno));
+ rsyserr(FERROR, errno, "delete_one: unlink %s failed",
+ full_fname(fn));
} 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 failed: %s\n",
- full_fname(fn), strerror(errno));
+ rsyserr(FERROR, errno,
+ "delete_one: rmdir %s failed",
+ full_fname(fn));
}
} else if (verbose) {
rprintf(FINFO, "deleting directory %s\n", fn);
sum_update(data,i);
if (fd != -1 && write_file(fd,data,i) != i) {
- rprintf(FERROR, "write failed on %s: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "write failed on %s",
+ full_fname(fname));
exit_cleanup(RERR_FILEIO);
}
offset += i;
}
if (fd != -1 && write_file(fd,map,len) != (int) len) {
- rprintf(FERROR, "write failed on %s: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "write failed on %s",
+ full_fname(fname));
exit_cleanup(RERR_FILEIO);
}
offset += len;
end_progress(total_size);
if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
- rprintf(FERROR, "write failed on %s: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "write failed on %s",
+ full_fname(fname));
exit_cleanup(RERR_FILEIO);
}
}
if (fd1 != -1 && do_fstat(fd1,&st) != 0) {
- rprintf(FERROR, "fstat %s failed: %s\n",
- full_fname(fnamecmp), strerror(errno));
+ rsyserr(FERROR, errno, "fstat %s failed",
+ full_fname(fnamecmp));
receive_data(f_in,NULL,-1,NULL,file->length);
close(fd1);
continue;
fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
}
if (fd2 == -1) {
- rprintf(FERROR, "mkstemp %s failed: %s\n",
- full_fname(fnametmp), strerror(errno));
+ rsyserr(FERROR, errno, "mkstemp %s failed",
+ full_fname(fnametmp));
receive_data(f_in,mapbuf,-1,NULL,file->length);
if (mapbuf) unmap_file(mapbuf);
if (fd1 != -1) close(fd1);
close(fd1);
}
if (close(fd2) < 0) {
- rprintf(FERROR, "close failed on %s: %s\n",
- full_fname(fnametmp), strerror(errno));
+ rsyserr(FERROR, errno, "close failed on %s",
+ full_fname(fnametmp));
exit_cleanup(RERR_FILEIO);
}
if (!S_ISDIR(st.st_mode)) {
if (robust_unlink(fname) == 0 || errno == ENOENT)
return 0;
- rprintf(FERROR, "delete_file: unlink %s failed: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "delete_file: unlink %s failed",
+ full_fname(fname));
return -1;
}
return 0;
if (!force_delete || !recurse
|| (errno != ENOTEMPTY && errno != EEXIST)) {
- rprintf(FERROR, "delete_file: rmdir %s failed: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "delete_file: rmdir %s failed",
+ full_fname(fname));
return -1;
}
/* now we do a recsursive delete on the directory ... */
if (!(d = opendir(fname))) {
- rprintf(FERROR, "delete_file: opendir %s failed: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "delete_file: opendir %s failed",
+ full_fname(fname));
return -1;
}
}
}
if (errno) {
- rprintf(FERROR, "delete_file: readdir %s failed: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "delete_file: readdir %s failed",
+ full_fname(fname));
closedir(d);
return -1;
}
closedir(d);
if (do_rmdir(fname) != 0) {
- rprintf(FERROR, "delete_file: rmdir %s failed: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "delete_file: rmdir %s failed",
+ full_fname(fname));
return -1;
}
if (!st) {
if (link_stat(fname,&st2) != 0) {
- rprintf(FERROR, "stat %s failed: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "stat %s failed",
+ full_fname(fname));
return 0;
}
st = &st2;
* 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",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "failed to set times on %s",
+ full_fname(fname));
return 0;
}
updated = 1;
change_gid ? file->gid : st->st_gid) != 0) {
/* shouldn't have attempted to change uid or gid
* unless have the privilege */
- rprintf(FERROR, "%s %s failed: %s\n",
+ rsyserr(FERROR, errno, "%s %s failed",
change_uid ? "chown" : "chgrp",
- full_fname(fname), strerror(errno));
+ full_fname(fname));
return 0;
}
/* a lchown had been done - we have to re-stat if the
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",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno, "failed to set permissions on %s",
+ full_fname(fname));
return 0;
}
}
/* move tmp file over real file */
ret = robust_rename(fnametmp, fname, file->mode & INITACCESSPERMS);
if (ret < 0) {
- rprintf(FERROR, "%s %s -> \"%s\": %s\n",
+ rsyserr(FERROR, errno, "%s %s -> \"%s\"",
ret == -2 ? "copy" : "rename",
- full_fname(fnametmp), fname, strerror(errno));
+ full_fname(fnametmp), fname);
do_unlink(fnametmp);
} else {
set_perms(fname, file, NULL,
full_fname(fname));
} else {
io_error |= IOERR_GENERAL;
- rprintf(FERROR, "send_files failed to open %s: %s\n",
- full_fname(fname), strerror(errno));
+ rsyserr(FERROR, errno,
+ "send_files failed to open %s",
+ full_fname(fname));
}
free_sums(s);
continue;
/* map the local file */
if (do_fstat(fd, &st) != 0) {
io_error |= IOERR_GENERAL;
- rprintf(FERROR, "fstat failed: %s\n", strerror(errno));
+ rsyserr(FERROR, errno, "fstat failed");
free_sums(s);
close(fd);
return;
j = unmap_file(mbuf);
if (j) {
io_error |= IOERR_GENERAL;
- rprintf(FERROR,
- "read errors mapping %s: (%d) %s\n",
- full_fname(fname), j, strerror(j));
+ rsyserr(FERROR, j,
+ "read errors mapping %s",
+ full_fname(fname));
}
}
close(fd);
host, port, authhdr, authbuf);
len = strlen(buffer);
if (write(fd, buffer, len) != len) {
- rprintf(FERROR, "failed to write to proxy: %s\n",
- strerror(errno));
+ rsyserr(FERROR, errno, "failed to write to proxy");
return -1;
}
for (cp = buffer; cp < &buffer[sizeof buffer - 1]; cp++) {
if (read(fd, cp, 1) != 1) {
- rprintf(FERROR, "failed to read from proxy: %s\n",
- strerror(errno));
+ rsyserr(FERROR, errno, "failed to read from proxy");
return -1;
}
if (*cp == '\n')
while (1) {
for (cp = buffer; cp < &buffer[sizeof buffer - 1]; cp++) {
if (read(fd, cp, 1) != 1) {
- rprintf(FERROR, "failed to read from proxy: %s\n",
- strerror(errno));
+ rsyserr(FERROR, errno,
+ "failed to read from proxy");
return -1;
}
if (*cp == '\n')
}
freeaddrinfo(res0);
if (s < 0) {
- rprintf(FERROR, RSYNC_NAME ": failed to connect to %s: %s\n",
- h, strerror(errno));
+ rsyserr(FERROR, errno, "failed to connect to %s", h);
return -1;
}
return s;
FD_ZERO(&deffds);
for (i = 0, maxfd = -1; sp[i] >= 0; i++) {
if (listen(sp[i], 5) < 0) {
- rprintf(FERROR, "listen() on socket failed: %s\n",
- strerror(errno));
+ rsyserr(FERROR, errno, "listen() on socket failed");
#ifdef INET6
if (errno == EADDRINUSE && i > 0) {
rprintf(FINFO,
close_all();
_exit(ret);
} else if (pid < 0) {
- rprintf(FERROR,
- RSYNC_NAME
- ": could not create child server process: %s\n",
- strerror(errno));
+ rsyserr(FERROR, errno,
+ "could not create child server process");
close(fd);
/* This might have happened because we're
* overloaded. Sleep briefly before trying to
break;
}
- if (ret != 0)
- rprintf(FERROR, "failed to set socket option %s: %s\n", tok,
- strerror(errno));
+ if (ret != 0) {
+ rsyserr(FERROR, errno,
+ "failed to set socket option %s", tok);
+ }
}
free(options);
int fd[2];
if (socketpair_tcp(fd) != 0) {
- rprintf(FERROR, RSYNC_NAME ": socketpair_tcp failed (%s)\n",
- strerror(errno));
+ rsyserr(FERROR, errno, "socketpair_tcp failed");
return -1;
}
if (verbose >= 2)
ifd = do_open(source, O_RDONLY, 0);
if (ifd == -1) {
- rprintf(FERROR,"open %s: %s\n",
- full_fname(source), strerror(errno));
+ rsyserr(FERROR, errno, "open %s", full_fname(source));
return -1;
}
if (robust_unlink(dest) && errno != ENOENT) {
- rprintf(FERROR,"unlink %s: %s\n",
- full_fname(dest), strerror(errno));
+ rsyserr(FERROR, errno, "unlink %s", full_fname(dest));
return -1;
}
ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode);
if (ofd == -1) {
- rprintf(FERROR,"open %s: %s\n",
- full_fname(dest), strerror(errno));
+ rsyserr(FERROR, errno, "open %s", full_fname(dest));
close(ifd);
return -1;
}
while ((len = safe_read(ifd, buf, sizeof buf)) > 0) {
if (full_write(ofd, buf, len) < 0) {
- rprintf(FERROR,"write %s: %s\n",
- full_fname(dest), strerror(errno));
+ rsyserr(FERROR, errno, "write %s", full_fname(dest));
close(ifd);
close(ofd);
return -1;
}
if (len < 0) {
- rprintf(FERROR, "read %s: %s\n",
- full_fname(source), strerror(errno));
+ rsyserr(FERROR, errno, "read %s", full_fname(source));
close(ifd);
close(ofd);
return -1;
}
if (close(ifd) < 0) {
- rprintf(FINFO, "close failed on %s: %s\n",
- full_fname(source), strerror(errno));
+ rsyserr(FINFO, errno, "close failed on %s",
+ full_fname(source));
}
if (close(ofd) < 0) {
- rprintf(FERROR, "close failed on %s: %s\n",
- full_fname(dest), strerror(errno));
+ rsyserr(FERROR, errno, "close failed on %s",
+ full_fname(dest));
return -1;
}