Skip to content

Commit

Permalink
Changed rprintf() calls that included strerror() to use rsyserr().
Browse files Browse the repository at this point in the history
  • Loading branch information
Wayne Davison committed May 15, 2004
1 parent 982e05b commit d62bcc1
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 201 deletions.
36 changes: 18 additions & 18 deletions backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ static int make_simple_backup(char *fname)
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) {
Expand Down Expand Up @@ -84,9 +85,9 @@ static int make_bak_dir(char *fullpath)
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;
}
}
Expand All @@ -98,9 +99,9 @@ static int make_bak_dir(char *fullpath)
/* 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);
Expand All @@ -111,9 +112,8 @@ static int make_bak_dir(char *fullpath)
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;
}
}
Expand Down Expand Up @@ -172,8 +172,8 @@ static int keep_backup(char *fname)
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",
Expand All @@ -190,8 +190,8 @@ static int keep_backup(char *fname)
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);
Expand All @@ -214,8 +214,8 @@ static int keep_backup(char *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;
Expand All @@ -230,8 +230,8 @@ static int keep_backup(char *fname)
/* 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);
Expand Down
39 changes: 16 additions & 23 deletions batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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);
}

Expand Down Expand Up @@ -72,8 +71,7 @@ void write_batch_argvs_file(int argc, char *argv[])
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';
Expand Down Expand Up @@ -111,8 +109,7 @@ void write_batch_argvs_file(int argc, char *argv[])
}
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);
}
Expand All @@ -131,8 +128,7 @@ struct file_list *create_flist_from_batch(void)

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);
}

Expand Down Expand Up @@ -161,8 +157,7 @@ struct file_list *create_flist_from_batch(void)
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);
}
Expand Down Expand Up @@ -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,
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);
}
Expand All @@ -221,7 +216,7 @@ int read_batch_csums_file(char *buff, int len)
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);
}
Expand All @@ -244,8 +239,8 @@ void read_batch_csum_info(int flist_entry, struct sum_struct *s,

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);
}
Expand Down Expand Up @@ -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,
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);
}
Expand All @@ -315,17 +309,16 @@ int read_batch_delta_file(char *buff, int len)

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);
}
Expand Down
3 changes: 1 addition & 2 deletions clientname.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ void client_sockaddr(int fd,

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);
}

Expand Down
8 changes: 4 additions & 4 deletions clientserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 (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));
Expand Down
26 changes: 12 additions & 14 deletions flist.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,8 @@ struct file_struct *make_file(char *fname,
}
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;
}
Expand Down Expand Up @@ -970,8 +970,7 @@ static void send_directory(int f, struct file_list *flist, char *dir)
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;
}

Expand Down Expand Up @@ -1018,8 +1017,7 @@ static void send_directory(int f, struct file_list *flist, char *dir)
}
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);
Expand Down Expand Up @@ -1054,8 +1052,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
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;
Expand Down Expand Up @@ -1092,8 +1090,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
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;
}
Expand Down Expand Up @@ -1162,8 +1160,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])

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;
}

Expand All @@ -1185,8 +1183,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
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);
}
}
Expand Down
Loading

0 comments on commit d62bcc1

Please sign in to comment.