LCOV - code coverage report
Current view: top level - core - load-dropin.c (source / functions) Hit Total Coverage
Test: systemd test coverage Lines: 9 21 42.9 %
Date: 2015-07-29 18:47:03 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
       2             : 
       3             : /***
       4             :   This file is part of systemd.
       5             : 
       6             :   Copyright 2010 Lennart Poettering
       7             : 
       8             :   systemd is free software; you can redistribute it and/or modify it
       9             :   under the terms of the GNU Lesser General Public License as published by
      10             :   the Free Software Foundation; either version 2.1 of the License, or
      11             :   (at your option) any later version.
      12             : 
      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             :   Lesser General Public License for more details.
      17             : 
      18             :   You should have received a copy of the GNU Lesser General Public License
      19             :   along with systemd; If not, see <http://www.gnu.org/licenses/>.
      20             : ***/
      21             : 
      22             : 
      23             : #include "unit.h"
      24             : #include "load-dropin.h"
      25             : #include "log.h"
      26             : #include "strv.h"
      27             : #include "unit-name.h"
      28             : #include "conf-parser.h"
      29             : #include "load-fragment.h"
      30             : 
      31           0 : static int add_dependency_consumer(
      32             :                 UnitDependency dependency,
      33             :                 const char *entry,
      34             :                 const char* filepath,
      35             :                 void *arg) {
      36           0 :         Unit *u = arg;
      37             :         int r;
      38             : 
      39           0 :         assert(u);
      40             : 
      41           0 :         r = unit_add_dependency_by_name(u, dependency, entry, filepath, true);
      42           0 :         if (r < 0)
      43           0 :                 log_error_errno(r, "Cannot add dependency %s to %s, ignoring: %m", entry, u->id);
      44             : 
      45           0 :         return 0;
      46             : }
      47             : 
      48         732 : int unit_load_dropin(Unit *u) {
      49             :         Iterator i;
      50             :         char *t, **f;
      51             :         int r;
      52             : 
      53         732 :         assert(u);
      54             : 
      55             :         /* Load dependencies from supplementary drop-in directories */
      56             : 
      57        2202 :         SET_FOREACH(t, u->names, i) {
      58             :                 char **p;
      59             : 
      60        1476 :                 STRV_FOREACH(p, u->manager->lookup_paths.unit_path) {
      61         738 :                         unit_file_process_dir(u->manager->unit_path_cache, *p, t, ".wants", UNIT_WANTS,
      62             :                                               add_dependency_consumer, u, NULL);
      63         738 :                         unit_file_process_dir(u->manager->unit_path_cache, *p, t, ".requires", UNIT_REQUIRES,
      64             :                                               add_dependency_consumer, u, NULL);
      65             :                 }
      66             :         }
      67             : 
      68         732 :         r = unit_find_dropin_paths(u, &u->dropin_paths);
      69         732 :         if (r <= 0)
      70         732 :                 return 0;
      71             : 
      72           0 :         STRV_FOREACH(f, u->dropin_paths) {
      73           0 :                 config_parse(u->id, *f, NULL,
      74           0 :                              UNIT_VTABLE(u)->sections,
      75             :                              config_item_perf_lookup, load_fragment_gperf_lookup,
      76             :                              false, false, false, u);
      77             :         }
      78             : 
      79           0 :         u->dropin_mtime = now(CLOCK_REALTIME);
      80             : 
      81           0 :         return 0;
      82             : }

Generated by: LCOV version 1.11