summaryrefslogtreecommitdiff
path: root/backup.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2003-08-01 07:58:41 +0000
committerWayne Davison <wayned@samba.org>2003-08-01 07:58:41 +0000
commitdaa8ce838ba79378196c7e1380d2e16dedd8fef6 (patch)
treef2d506b45c57842d7a7cc29b45eacc50a7f93343 /backup.c
parentb19fd07c023c3923979ba965e8f485433d7ecf18 (diff)
downloadrsync-daa8ce838ba79378196c7e1380d2e16dedd8fef6.tar.gz
rsync-daa8ce838ba79378196c7e1380d2e16dedd8fef6.tar.bz2
rsync-daa8ce838ba79378196c7e1380d2e16dedd8fef6.zip
Use the new backup_suffix_len and backup_dir_len variables. Got rid
of the suffix_specified kludge.
Diffstat (limited to 'backup.c')
-rw-r--r--backup.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/backup.c b/backup.c
index 990b0d85..7d64b6d7 100644
--- a/backup.c
+++ b/backup.c
@@ -21,11 +21,11 @@
#include "rsync.h"
extern int verbose;
-extern int suffix_specified;
+extern int backup_suffix_len;
+extern int backup_dir_len;
extern char *backup_suffix;
extern char *backup_dir;
-
extern int am_root;
extern int preserve_devices;
extern int preserve_links;
@@ -35,7 +35,7 @@ extern int preserve_hard_links;
static int make_simple_backup(char *fname)
{
char fnamebak[MAXPATHLEN];
- if (strlen(fname) + strlen(backup_suffix) > (MAXPATHLEN-1)) {
+ if (strlen(fname) + backup_suffix_len > MAXPATHLEN-1) {
rprintf(FERROR, "backup filename too long\n");
return 0;
}
@@ -184,8 +184,8 @@ static int keep_backup(char *fname)
int ret_code;
if (!initialised) {
- if (backup_dir[strlen(backup_dir) - 1] == '/')
- backup_dir[strlen(backup_dir) - 1] = 0;
+ if (backup_dir_len && backup_dir[backup_dir_len - 1] == '/')
+ backup_dir[--backup_dir_len] = '\0';
if (verbose > 0)
rprintf (FINFO, "backup_dir is %s\n", backup_dir);
initialised = 1;
@@ -204,20 +204,13 @@ static int keep_backup(char *fname)
if (!file) return 1;
/* make a complete pathname for backup file */
- if (strlen(backup_dir) + strlen(fname) +
- (suffix_specified ? strlen(backup_suffix) : 0) > (MAXPATHLEN - 1)) {
+ if (backup_dir_len+strlen(fname)+backup_suffix_len > MAXPATHLEN-1) {
rprintf (FERROR, "keep_backup filename too long\n");
return 0;
}
- if (suffix_specified) {
- snprintf(keep_name, sizeof (keep_name), "%s/%s%s",
- backup_dir, fname, backup_suffix);
- } else {
- snprintf(keep_name, sizeof (keep_name), "%s/%s",
- backup_dir, fname);
- }
-
+ snprintf(keep_name, sizeof (keep_name), "%s/%s%s",
+ backup_dir, fname, backup_suffix);
#ifdef HAVE_MKNOD
/* Check to see if this is a device file, or link */