summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-03-13 22:55:39 +0100
committerThomas Haller <thaller@redhat.com>2015-03-20 11:43:30 +0100
commit29718fcaa43f52606e4f0b3addbca3f7afb2a224 (patch)
tree526a9730f21e4a615e867d3d90a9bfe14596eef6
parent5775df9a6dcfaa4a9d208c8e78d6a7419c0e6a07 (diff)
downloadNetworkManager-29718fcaa43f52606e4f0b3addbca3f7afb2a224.tar.gz
main: split out nm_main_utils_ensure_rundir ()
Also, don't use nm_log_err() as nm-logging is not yet setup.
-rw-r--r--src/main-utils.c16
-rw-r--r--src/main-utils.h2
-rw-r--r--src/main.c2
-rw-r--r--src/nm-iface-helper.c2
4 files changed, 16 insertions, 6 deletions
diff --git a/src/main-utils.c b/src/main-utils.c
index 5a470fa0de..4daa0eef52 100644
--- a/src/main-utils.c
+++ b/src/main-utils.c
@@ -108,6 +108,16 @@ nm_main_utils_write_pidfile (const char *pidfile)
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:
* @pidfile: the pid file
@@ -129,12 +139,6 @@ nm_main_utils_check_pidfile (const char *pidfile, const char *name)
gboolean nm_running = FALSE;
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))
return FALSE;
diff --git a/src/main-utils.h b/src/main-utils.h
index 88d217a559..be3d08626f 100644
--- a/src/main-utils.h
+++ b/src/main-utils.h
@@ -25,6 +25,8 @@
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_check_pidfile (const char *pidfile, const char *name);
diff --git a/src/main.c b/src/main.c
index c06c746ddf..35a47b9502 100644
--- a/src/main.c
+++ b/src/main.c
@@ -316,6 +316,8 @@ main (int argc, char *argv[])
exit (1);
}
+ nm_main_utils_ensure_rundir ();
+
/* check pid file */
if (nm_main_utils_check_pidfile (global_opt.pidfile, "NetworkManager"))
exit (1);
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
index 4125ba5012..3a3a71157e 100644
--- a/src/nm-iface-helper.c
+++ b/src/nm-iface-helper.c
@@ -375,6 +375,8 @@ main (int argc, char *argv[])
g_clear_pointer (&bad_domains, g_free);
}
+ nm_main_utils_ensure_rundir ();
+
pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, ifindex);
g_assert (pidfile);