3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

main: Move storage directory creation into storage functionality

This commit is contained in:
Marcel Holtmann 2019-09-08 18:24:23 +02:00
parent 7e5ddb15d7
commit 45d5c67cb4
3 changed files with 19 additions and 11 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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);