2 * udev_run_directory.c - directory multiplexer
4 * Copyright (C) 2005 Kay Sievers <kay@vrfy.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2 of the License.
21 #include <sys/types.h>
25 #include "../../udev.h"
26 #include "run_directory.h"
28 static int exec_program(const char *filename, const char *subsystem)
32 dbg("running %s", filename);
37 execl(filename, filename, subsystem, NULL);
38 dbg("exec of child failed");
41 dbg("fork of child failed");
45 waitpid(pid, NULL, 0);
51 int run_directory(const char *dir, const char *suffix, const char *subsystem)
53 struct name_entry *name_loop, *name_tmp;
57 dbg("looking at '%s'", dir);
59 if (stat(dir, &buf) != 0) {
60 dbg("directory '%s' not found", dir);
64 add_matching_files(&name_list, dir, suffix);
66 list_for_each_entry_safe(name_loop, name_tmp, &name_list, node) {
67 exec_program(name_loop->name, subsystem);
68 list_del(&name_loop->node);