Improve unpack error handling, ignore mkdir failure on EEXIST

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
David Oberhollenzer 2019-02-03 16:18:34 +01:00
parent dd6022b686
commit 8754729cb1
1 changed files with 7 additions and 2 deletions

View File

@ -16,7 +16,10 @@ static int create_hierarchy(int dirfd, image_entry_t *list)
for (ent = list; ent != NULL; ent = ent->next) {
if (S_ISDIR(ent->mode)) {
if (mkdirat(dirfd, ent->name, 0755)) {
perror(ent->name);
if (errno == EEXIST)
continue;
fprintf(stderr, "mkdir %s: %s\n", ent->name,
strerror(errno));
return -1;
}
}
@ -26,7 +29,9 @@ static int create_hierarchy(int dirfd, image_entry_t *list)
if (S_ISLNK(ent->mode)) {
if (symlinkat(ent->data.symlink.target,
dirfd, ent->name)) {
perror(ent->name);
fprintf(stderr, "symlink %s to %s: %s\n",
ent->name, ent->data.symlink.target,
strerror(errno));
return -1;
}
}