proc-cmdline.c revision 11c3a36649e5e5e77db499c92f3cdcbd619efd3a
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2010 Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering return get_process_cmdline(1, 0, false, ret);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering return read_one_line_file("/proc/cmdline", ret);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering const char *p;
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek _cleanup_free_ char *word = NULL;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering /* Filter out arguments that are intended only for the
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering if (!in_initrd() && startswith(word, "rd."))
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint get_proc_cmdline_key(const char *key, char **value) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _cleanup_free_ char *line = NULL, *ret = NULL;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering const char *p;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering const char *e;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek /* Filter out arguments that are intended only for the
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek if (!in_initrd() && startswith(word, "rd."))
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek _cleanup_free_ char *value = NULL;
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek r = get_proc_cmdline_key("systemd.restore_state=", &value);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmekstatic const char * const rlmap[] = {
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek "emergency", SPECIAL_EMERGENCY_TARGET,
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek "rescue", SPECIAL_RESCUE_TARGET,
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek "single", SPECIAL_RESCUE_TARGET,
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersenconst char* runlevel_to_target(const char *word) {