1
0
Fork 0
mirror of https://github.com/pygos/pkg-utils.git synced 2024-11-06 05:37:10 +01:00
pkg-utils/main/cmd/unpack/create_hierarchy.c

27 lines
446 B
C
Raw Normal View History

#include "unpack.h"
int create_hierarchy(image_entry_t *list)
{
image_entry_t *ent;
for (ent = list; ent != NULL; ent = ent->next) {
if (S_ISDIR(ent->mode)) {
if (mkdir(ent->name, 0755)) {
perror(ent->name);
return -1;
}
}
}
for (ent = list; ent != NULL; ent = ent->next) {
if (S_ISLNK(ent->mode)) {
if (symlink(ent->data.symlink.target, ent->name)) {
perror(ent->name);
return -1;
}
}
}
return 0;
}