main: split out nm_main_utils_ensure_rundir ()
Also, don't use nm_log_err() as nm-logging is not yet setup.
This commit is contained in:
@@ -108,6 +108,16 @@ nm_main_utils_write_pidfile (const char *pidfile)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nm_main_utils_ensure_rundir ()
|
||||||
|
{
|
||||||
|
/* Setup runtime directory */
|
||||||
|
if (g_mkdir_with_parents (NMRUNDIR, 0755) != 0) {
|
||||||
|
fprintf (stderr, _("Cannot create '%s': %s"), NMRUNDIR, strerror (errno));
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nm_main_utils_check_pidfile:
|
* nm_main_utils_check_pidfile:
|
||||||
* @pidfile: the pid file
|
* @pidfile: the pid file
|
||||||
@@ -129,12 +139,6 @@ nm_main_utils_check_pidfile (const char *pidfile, const char *name)
|
|||||||
gboolean nm_running = FALSE;
|
gboolean nm_running = FALSE;
|
||||||
const char *process_name;
|
const char *process_name;
|
||||||
|
|
||||||
/* Setup runtime directory */
|
|
||||||
if (g_mkdir_with_parents (NMRUNDIR, 0755) != 0) {
|
|
||||||
nm_log_err (LOGD_CORE, "Cannot create '%s': %s", NMRUNDIR, strerror (errno));
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!g_file_get_contents (pidfile, &contents, &len, NULL))
|
if (!g_file_get_contents (pidfile, &contents, &len, NULL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
void nm_main_utils_setup_signals (GMainLoop *main_loop);
|
void nm_main_utils_setup_signals (GMainLoop *main_loop);
|
||||||
|
|
||||||
|
void nm_main_utils_ensure_rundir (void);
|
||||||
|
|
||||||
gboolean nm_main_utils_write_pidfile (const char *pidfile);
|
gboolean nm_main_utils_write_pidfile (const char *pidfile);
|
||||||
|
|
||||||
gboolean nm_main_utils_check_pidfile (const char *pidfile, const char *name);
|
gboolean nm_main_utils_check_pidfile (const char *pidfile, const char *name);
|
||||||
|
@@ -316,6 +316,8 @@ main (int argc, char *argv[])
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nm_main_utils_ensure_rundir ();
|
||||||
|
|
||||||
/* check pid file */
|
/* check pid file */
|
||||||
if (nm_main_utils_check_pidfile (global_opt.pidfile, "NetworkManager"))
|
if (nm_main_utils_check_pidfile (global_opt.pidfile, "NetworkManager"))
|
||||||
exit (1);
|
exit (1);
|
||||||
|
@@ -375,6 +375,8 @@ main (int argc, char *argv[])
|
|||||||
g_clear_pointer (&bad_domains, g_free);
|
g_clear_pointer (&bad_domains, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nm_main_utils_ensure_rundir ();
|
||||||
|
|
||||||
pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, ifindex);
|
pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, ifindex);
|
||||||
g_assert (pidfile);
|
g_assert (pidfile);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user