path.c revision b5efdb8af40ea759a1ea584c1bc44ecc81dd00ce
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen This file is part of systemd.
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen Copyright 2014 Lennart Poettering
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen systemd is free software; you can redistribute it and/or modify it
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen under the terms of the GNU Lesser General Public License as published by
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen (at your option) any later version.
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen systemd is distributed in the hope that it will be useful, but
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen Lesser General Public License for more details.
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen You should have received a copy of the GNU Lesser General Public License
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersenstatic const char* const path_table[_SD_PATH_MAX] = {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_TEMPORARY_LARGE] = "temporary-large",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SYSTEM_BINARIES] = "system-binaries",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SYSTEM_LIBRARY_PRIVATE] = "system-library-private",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SYSTEM_LIBRARY_ARCH] = "system-library-arch",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SYSTEM_CONFIGURATION_FACTORY] = "system-configuration-factory",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SYSTEM_STATE_FACTORY] = "system-state-factory",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SYSTEM_CONFIGURATION] = "system-configuration",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SYSTEM_RUNTIME_LOGS] = "system-runtime-logs",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SYSTEM_STATE_PRIVATE] = "system-state-private",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SYSTEM_STATE_LOGS] = "system-state-logs",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SYSTEM_STATE_CACHE] = "system-state-cache",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SYSTEM_STATE_SPOOL] = "system-state-spool",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_USER_LIBRARY_PRIVATE] = "user-library-private",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_USER_LIBRARY_ARCH] = "user-library-arch",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_USER_CONFIGURATION] = "user-configuration",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_USER_STATE_CACHE] = "user-state-cache",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SEARCH_BINARIES] = "search-binaries",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SEARCH_LIBRARY_PRIVATE] = "search-library-private",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SEARCH_LIBRARY_ARCH] = "search-library-arch",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SEARCH_CONFIGURATION_FACTORY] = "search-configuration-factory",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SEARCH_STATE_FACTORY] = "search-state-factory",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen [SD_PATH_SEARCH_CONFIGURATION] = "search-configuration",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersenstatic int list_homes(void) {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen for (i = 0; i < ELEMENTSOF(path_table); i++) {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen log_error_errno(r, "Failed to query %s: %m", path_table[i]);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersenstatic int print_home(const char *n) {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen for (i = 0; i < ELEMENTSOF(path_table); i++) {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen return log_error_errno(r, "Failed to query %s: %m", n);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersenstatic void help(void) {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen "Show system and user paths.\n\n"
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen " -h --help Show this help\n"
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen " --version Show package version\n"
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen " --suffix=SUFFIX Suffix to append to paths\n",
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersenstatic int parse_argv(int argc, char *argv[]) {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen { "version", no_argument, NULL, ARG_VERSION },
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen { "suffix", required_argument, NULL, ARG_SUFFIX },
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
help();
case ARG_VERSION:
return version();
case ARG_SUFFIX:
return -EINVAL;
log_open();
goto finish;
r = list_homes();