Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblongpath-rsync
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liblongpath
liblongpath-rsync
Commits
9b594a53
Commit
9b594a53
authored
Mar 09, 2010
by
Wayne Davison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle files that spring up while doing backup path checking.
parent
5d8dcd1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
15 deletions
+37
-15
backup.c
backup.c
+37
-15
No files found.
backup.c
View file @
9b594a53
...
...
@@ -34,6 +34,26 @@ extern char backup_dir_buf[MAXPATHLEN];
extern
char
*
backup_suffix
;
extern
char
*
backup_dir
;
/* Returns -1 on error, 0 on missing dir, and 1 on present dir. */
static
int
validate_backup_dir
(
void
)
{
STRUCT_STAT
st
;
if
(
do_lstat
(
backup_dir_buf
,
&
st
)
<
0
)
{
if
(
errno
==
ENOENT
)
return
0
;
rsyserr
(
FERROR
,
errno
,
"backup lstat %s failed"
,
backup_dir_buf
);
return
-
1
;
}
if
(
!
S_ISDIR
(
st
.
st_mode
))
{
int
flags
=
get_del_for_flag
(
st
.
st_mode
)
|
DEL_FOR_BACKUP
|
DEL_RECURSE
;
if
(
delete_item
(
backup_dir_buf
,
st
.
st_mode
,
flags
)
==
0
)
return
0
;
return
-
1
;
}
return
1
;
}
/* Create a backup path from the given fname, putting the result into
* backup_dir_buf. Any new directories (compared to the prior backup
* path) are ensured to exist as directories, replacing anything else
...
...
@@ -41,7 +61,7 @@ extern char *backup_dir;
static
BOOL
copy_valid_path
(
const
char
*
fname
)
{
const
char
*
f
;
int
flags
;
int
val
;
BOOL
ret
=
True
;
stat_x
sx
;
char
*
b
,
*
rel
=
backup_dir_buf
+
backup_dir_len
,
*
name
=
rel
;
...
...
@@ -62,17 +82,10 @@ static BOOL copy_valid_path(const char *fname)
return
True
;
*
b
=
'\0'
;
if
(
do_lstat
(
backup_dir_buf
,
&
sx
.
st
)
<
0
)
{
if
(
errno
==
ENOENT
)
break
;
rsyserr
(
FERROR
,
errno
,
"backup lstat %s failed"
,
backup_dir_buf
);
*
name
=
'\0'
;
return
False
;
}
if
(
!
S_ISDIR
(
sx
.
st
.
st_mode
))
{
flags
=
get_del_for_flag
(
sx
.
st
.
st_mode
)
|
DEL_FOR_BACKUP
|
DEL_RECURSE
;
if
(
delete_item
(
backup_dir_buf
,
sx
.
st
.
st_mode
,
flags
)
==
0
)
break
;
val
=
validate_backup_dir
();
if
(
val
==
0
)
break
;
if
(
val
<
0
)
{
*
name
=
'\0'
;
return
False
;
}
...
...
@@ -85,11 +98,18 @@ static BOOL copy_valid_path(const char *fname)
for
(
;
b
;
name
=
b
+
1
,
b
=
strchr
(
name
,
'/'
))
{
*
b
=
'\0'
;
if
(
mkdir_defmode
(
backup_dir_buf
)
<
0
)
{
rsyserr
(
FERROR
,
errno
,
"backup mkdir %s failed"
,
backup_dir_buf
);
while
(
mkdir_defmode
(
backup_dir_buf
)
<
0
)
{
if
(
errno
==
EEXIST
)
{
val
=
validate_backup_dir
();
if
(
val
>
0
)
break
;
if
(
val
==
0
)
continue
;
}
else
rsyserr
(
FERROR
,
errno
,
"backup mkdir %s failed"
,
backup_dir_buf
);
*
name
=
'\0'
;
ret
=
False
;
break
;
goto
cleanup
;
}
/* Try to transfer the directory settings of the actual dir
...
...
@@ -121,6 +141,8 @@ static BOOL copy_valid_path(const char *fname)
*
b
=
'/'
;
}
cleanup:
#ifdef SUPPORT_ACLS
uncache_tmp_acls
();
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment