[06/13] installer: Make hw_mkdir static

Message ID 20240405125942.1803058-6-michael.tremer@ipfire.org
State Staged
Commit 0e0346cc4bb6c33ad44c5a361a4cd42cb6a6aaa1
Headers
Series [01/13] installer: Update language files |

Commit Message

Michael Tremer April 5, 2024, 12:59 p.m. UTC
  Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 src/installer/hw.c | 86 +++++++++++++++++++++++-----------------------
 1 file changed, 43 insertions(+), 43 deletions(-)
  

Patch

diff --git a/src/installer/hw.c b/src/installer/hw.c
index f4a84804d..f05608fd1 100644
--- a/src/installer/hw.c
+++ b/src/installer/hw.c
@@ -54,6 +54,48 @@  static int system_chroot(const char* output, const char* path, const char* cmd)
 	return mysystem(output, chroot_cmd);
 }
 
+static 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;
+}
+
 struct hw* hw_init() {
 	struct hw* hw = calloc(1, sizeof(*hw));
 	assert(hw);
@@ -959,7 +1001,7 @@  static int hw_mount_btrfs_subvolumes(const char* source) {
 			return r;
 
 		// Create the directory.
-		r = hw_mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO);
+		r = hw_mkdir(path);
 
 		// Abort if the directory could not be created.
 		if(r != 0 && errno != EEXIST)
@@ -1416,45 +1458,3 @@  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;
-}