Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Made list more complete.
[rsync/rsync.git]
/
backup.c
diff --git
a/backup.c
b/backup.c
index
7db0d2c
..
f915265
100644
(file)
--- a/
backup.c
+++ b/
backup.c
@@
-5,8
+5,9
@@
* Copyright (C) 2003-2007 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* Copyright (C) 2003-2007 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 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
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-14,8
+15,7
@@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* 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.,
- * 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ * with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
*/
#include "rsync.h"
@@
-92,32
+92,37
@@
static int make_simple_backup(const char *fname)
Create a directory given an absolute path, perms based upon another directory
path
****************************************************************************/
Create a directory given an absolute path, perms based upon another directory
path
****************************************************************************/
-
static int make_bak_dir(
char *fullpath)
+
int make_bak_dir(const
char *fullpath)
{
{
-
statx sx
;
+
char fbuf[MAXPATHLEN], *rel, *end, *p
;
struct file_struct *file;
struct file_struct *file;
- char *rel = fullpath + backup_dir_len;
- char *end = rel + strlen(rel);
- char *p = end;
+ int len = backup_dir_len;
+ stat_x sx;
- while (
strncmp(fullpath, "./", 2) == 0)
+ while (
*fullpath == '.' && fullpath[1] == '/') {
fullpath += 2;
fullpath += 2;
+ len -= 2;
+ }
+
+ if (strlcpy(fbuf, fullpath, sizeof fbuf) >= sizeof fbuf)
+ return -1;
+
+ rel = fbuf + len;
+ end = p = rel + strlen(rel);
/* Try to find an existing dir, starting from the deepest dir. */
while (1) {
/* Try to find an existing dir, starting from the deepest dir. */
while (1) {
- if (--p == fullpath) {
- p += strlen(p);
- goto failure;
- }
+ if (--p == fbuf)
+ return -1;
if (*p == '/') {
*p = '\0';
if (*p == '/') {
*p = '\0';
- if (mkdir_defmode(f
ullpath
) == 0)
+ if (mkdir_defmode(f
buf
) == 0)
break;
if (errno != ENOENT) {
rsyserr(FERROR, errno,
"make_bak_dir mkdir %s failed",
break;
if (errno != ENOENT) {
rsyserr(FERROR, errno,
"make_bak_dir mkdir %s failed",
- full_fname(f
ullpath
));
-
goto failure
;
+ full_fname(f
buf
));
+
return -1
;
}
}
}
}
}
}
@@
-154,7
+159,7
@@
static int make_bak_dir(char *fullpath)
free_xattr(&sx);
}
#endif
free_xattr(&sx);
}
#endif
- set_file_attrs(f
ullpath
, file, NULL, NULL, 0);
+ set_file_attrs(f
buf
, file, NULL, NULL, 0);
unmake_file(file);
}
}
unmake_file(file);
}
}
@@
-162,20
+167,14
@@
static int make_bak_dir(char *fullpath)
p += strlen(p);
if (p == end)
break;
p += strlen(p);
if (p == end)
break;
- if (mkdir_defmode(f
ullpath
) < 0) {
+ if (mkdir_defmode(f
buf
) < 0) {
rsyserr(FERROR, errno, "make_bak_dir mkdir %s failed",
rsyserr(FERROR, errno, "make_bak_dir mkdir %s failed",
- full_fname(f
ullpath
));
-
goto failure
;
+ full_fname(f
buf
));
+
return -1
;
}
}
}
}
- return 0;
- failure:
- while (p != end) {
- *p = '/';
- p += strlen(p);
- }
- return -1;
+ return 0;
}
/* robustly move a file, creating new directory structures if necessary */
}
/* robustly move a file, creating new directory structures if necessary */
@@
-193,7
+192,7
@@
static int robust_move(const char *src, char *dst)
* We will move the file to be deleted into a parallel directory tree. */
static int keep_backup(const char *fname)
{
* We will move the file to be deleted into a parallel directory tree. */
static int keep_backup(const char *fname)
{
- statx sx;
+ stat
_
x sx;
struct file_struct *file;
char *buf;
int kept = 0;
struct file_struct *file;
char *buf;
int kept = 0;