commit 45d5c67cb4879a094f42467570ffcb630a08155a
parent 7e5ddb15d704d9a7bf4684f4700479fc02f09120
Author: Marcel Holtmann <marcel@holtmann.org>
Date: Sun, 8 Sep 2019 18:24:23 +0200
main: Move storage directory creation into storage functionality
Diffstat:
3 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/src/main.c b/src/main.c
@@ -451,15 +451,8 @@ int main(int argc, char *argv[])
exit_status = EXIT_FAILURE;
- if (create_dirs(DAEMON_STORAGEDIR "/")) {
- l_error("Failed to create " DAEMON_STORAGEDIR "/");
+ if (!storage_create_dirs())
goto fail_dbus;
- }
-
- if (create_dirs(DAEMON_STORAGEDIR "/hotspot/")) {
- l_error("Failed to create " DAEMON_STORAGEDIR "/hotspot/");
- goto fail_dbus;
- }
genl = l_genl_new();
if (!genl) {
diff --git a/src/storage.c b/src/storage.c
@@ -46,7 +46,7 @@
#define STORAGE_DIR_MODE (S_IRUSR | S_IWUSR | S_IXUSR)
#define STORAGE_FILE_MODE (S_IRUSR | S_IWUSR)
-int create_dirs(const char *filename)
+static int create_dirs(const char *filename)
{
struct stat st;
char *dir;
@@ -165,6 +165,21 @@ error_create_dirs:
return r;
}
+bool storage_create_dirs(void)
+{
+ if (create_dirs(DAEMON_STORAGEDIR "/")) {
+ l_error("Failed to create " DAEMON_STORAGEDIR "/");
+ return false;
+ }
+
+ if (create_dirs(DAEMON_STORAGEDIR "/hotspot/")) {
+ l_error("Failed to create " DAEMON_STORAGEDIR "/hotspot/");
+ return false;
+ }
+
+ return true;
+}
+
char *storage_get_network_file_path(enum security type, const char *ssid)
{
char *path;
diff --git a/src/storage.h b/src/storage.h
@@ -25,14 +25,14 @@
struct l_settings;
enum security;
-int create_dirs(const char *filename);
-
ssize_t read_file(void *buffer, size_t len, const char *path_fmt, ...)
__attribute__((format(printf, 3, 4)));
ssize_t write_file(const void *buffer, size_t len, const char *path_fmt, ...)
__attribute__((format(printf, 3, 4)));
+bool storage_create_dirs(void);
+
const char *storage_network_ssid_from_path(const char *path,
enum security *type);
char *storage_get_network_file_path(enum security type, const char *ssid);