1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include <dbus/dbus.h>
28 #include <sys/types.h>
33 #include "mount-setup.h"
35 int main(int argc, char *argv[]) {
40 const char *default_unit;
43 default_unit = argv[1];
45 default_unit = SPECIAL_DEFAULT_TARGET;
47 /* Move out of the way, so that we won't block unmounts */
48 assert_se(chdir("/") == 0);
50 /* Reset all signal handlers. */
51 assert_se(reset_all_signal_handlers() == 0);
53 /* Become a session leader if we aren't one yet. */
56 /* Disable the umask logic */
59 /* Make sure D-Bus doesn't fiddle with the SIGPIPE handlers */
60 dbus_connection_set_change_sigpipe(FALSE);
62 /* Mount /dev, /sys and friends */
66 log_set_target(LOG_TARGET_CONSOLE);
68 /* Open the logging devices, if possible and necessary*/
72 if ((r = manager_new(&m)) < 0) {
73 log_error("Failed to allocate manager object: %s", strerror(-r));
77 if ((r = manager_coldplug(m)) < 0) {
78 log_error("Failed to retrieve coldplug information: %s", strerror(-r));
82 log_debug("Activating default unit: %s", default_unit);
84 if ((r = manager_load_unit(m, default_unit, &target)) < 0) {
85 log_error("Failed to load default target: %s", strerror(-r));
89 printf("→ By units:\n");
90 manager_dump_units(m, stdout, "\t");
92 if ((r = manager_add_job(m, JOB_START, target, JOB_REPLACE, false, &job)) < 0) {
93 log_error("Failed to start default target: %s", strerror(-r));
97 printf("→ By jobs:\n");
98 manager_dump_jobs(m, stdout, "\t");
100 if ((r = manager_loop(m)) < 0) {
101 log_error("Failed to run mainloop: %s", strerror(-r));