Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/installer/hw.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
diff --git a/src/installer/hw.c b/src/installer/hw.c index 8396d83cf..3fa8b889e 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1281,6 +1281,49 @@ int hw_restore_backup(const char* output, const char* backup_path, const char* d return 0; }
+int hw_mkdir(const char *dir) { + char tmp[STRING_SIZE]; + char *p = NULL; + size_t len; + int r; + + snprintf(tmp, sizeof(tmp),"%s",dir); + len = strlen(tmp); + + if (tmp[len - 1] == '/') { + tmp[len - 1] = 0; + } + + for (p = tmp + 1; *p; p++) { + if (*p == '/') { + *p = 0; + + // Create target if it does not exist + if (access(tmp, X_OK) != 0) { + r = mkdir(tmp, S_IRWXU|S_IRWXG|S_IRWXO); + + if (r) { + return r; + } + } + + *p = '/'; + } + } + + // Create target if it does not exist + if (access(tmp, X_OK) != 0) { + r = mkdir(tmp, S_IRWXU|S_IRWXG|S_IRWXO); + + if (r) { + return r; + } + } + + return 0; +} + + int hw_create_btrfs_subvolume(const char* output, const char* subvolume) { char command [STRING_SIZE]; int r;