version 1.27, 2021/05/17 12:11:05 |
version 1.28, 2021/05/17 12:15:48 |
|
|
|
|
assert(p->rootfd != -1); |
assert(p->rootfd != -1); |
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW); |
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW); |
|
|
|
if (rc == -1 && errno != ENOENT) { |
|
ERR("%s: fstatat", f->path); |
|
return -1; |
|
} |
if (rc != -1 && !S_ISLNK(st.st_mode)) { |
if (rc != -1 && !S_ISLNK(st.st_mode)) { |
if (S_ISDIR(st.st_mode) && |
if (S_ISDIR(st.st_mode) && |
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) { |
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) { |
|
|
return -1; |
return -1; |
} |
} |
rc = -1; |
rc = -1; |
} else if (rc == -1 && errno != ENOENT) { |
|
ERR("%s: fstatat", f->path); |
|
return -1; |
|
} |
} |
|
|
/* |
/* |
|
|
assert(p->rootfd != -1); |
assert(p->rootfd != -1); |
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW); |
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW); |
|
|
|
if (rc == -1 && errno != ENOENT) { |
|
ERR("%s: fstatat", f->path); |
|
return -1; |
|
} |
if (rc != -1 && !(S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode))) { |
if (rc != -1 && !(S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode))) { |
if (S_ISDIR(st.st_mode) && |
if (S_ISDIR(st.st_mode) && |
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) { |
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) { |
|
|
return -1; |
return -1; |
} |
} |
rc = -1; |
rc = -1; |
} else if (rc == -1 && errno != ENOENT) { |
|
ERR("%s: fstatat", f->path); |
|
return -1; |
|
} |
} |
|
|
/* Make sure existing device is of the correct type. */ |
/* Make sure existing device is of the correct type. */ |
|
|
assert(p->rootfd != -1); |
assert(p->rootfd != -1); |
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW); |
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW); |
|
|
|
if (rc == -1 && errno != ENOENT) { |
|
ERR("%s: fstatat", f->path); |
|
return -1; |
|
} |
if (rc != -1 && !S_ISFIFO(st.st_mode)) { |
if (rc != -1 && !S_ISFIFO(st.st_mode)) { |
if (S_ISDIR(st.st_mode) && |
if (S_ISDIR(st.st_mode) && |
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) { |
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) { |
|
|
return -1; |
return -1; |
} |
} |
rc = -1; |
rc = -1; |
} else if (rc == -1 && errno != ENOENT) { |
|
ERR("%s: fstatat", f->path); |
|
return -1; |
|
} |
} |
|
|
if (rc == -1) { |
if (rc == -1) { |
|
|
assert(p->rootfd != -1); |
assert(p->rootfd != -1); |
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW); |
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW); |
|
|
|
if (rc == -1 && errno != ENOENT) { |
|
ERR("%s: fstatat", f->path); |
|
return -1; |
|
} |
if (rc != -1 && !S_ISSOCK(st.st_mode)) { |
if (rc != -1 && !S_ISSOCK(st.st_mode)) { |
if (S_ISDIR(st.st_mode) && |
if (S_ISDIR(st.st_mode) && |
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) { |
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) { |
|
|
return -1; |
return -1; |
} |
} |
rc = -1; |
rc = -1; |
} else if (rc == -1 && errno != ENOENT) { |
|
ERR("%s: fstatat", f->path); |
|
return -1; |
|
} |
} |
|
|
if (rc == -1) { |
if (rc == -1) { |
|
|
if (rc == -1 && errno != ENOENT) { |
if (rc == -1 && errno != ENOENT) { |
ERR("%s: fstatat", f->path); |
ERR("%s: fstatat", f->path); |
return -1; |
return -1; |
} else if (rc != -1 && !S_ISDIR(st.st_mode)) { |
} |
|
if (rc != -1 && !S_ISDIR(st.st_mode)) { |
ERRX("%s: not a directory", f->path); |
ERRX("%s: not a directory", f->path); |
return -1; |
return -1; |
} else if (rc != -1) { |
} else if (rc != -1) { |
|
|
ERR("%s: fstatat", f->path); |
ERR("%s: fstatat", f->path); |
return -1; |
return -1; |
} |
} |
if (rc != -1 && !S_ISREG(st->st_mode)) { |
if (!S_ISREG(st->st_mode)) { |
if (S_ISDIR(st->st_mode) && |
if (S_ISDIR(st->st_mode) && |
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) { |
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) { |
ERR("%s: unlinkat", f->path); |
ERR("%s: unlinkat", f->path); |
|
|
return 1; |
return 1; |
} |
} |
|
|
|
/* quick check if file is the same */ |
if (st->st_size == f->st.size && |
if (st->st_size == f->st.size && |
st->st_mtime == f->st.mtime) { |
st->st_mtime == f->st.mtime) { |
LOG3("%s: skipping: up to date", f->path); |
LOG3("%s: skipping: up to date", f->path); |