6 * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation version 2 of the License.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include "udev_version.h"
34 #include "libsysfs/libsysfs.h"
36 /* global variables */
41 unsigned char logname[42];
42 void log_message (int level, const char *format, ...)
49 /* FIXME use level... */
50 va_start(args, format);
51 vprintf(format, args);
53 if (format[strlen(format)-1] != '\n')
58 static void sig_handler(int signum)
65 dbg("unhandled signal");
69 static inline char *get_action(void)
73 action = getenv("ACTION");
77 static inline char *get_devpath(void)
81 devpath = getenv("DEVPATH");
85 static inline char *get_seqnum(void)
89 seqnum = getenv("SEQNUM");
93 static char *subsystem_blacklist[] = {
102 static int udev_hotplug(int argc, char **argv)
106 int retval = -EINVAL;
108 struct sigaction act;
115 dbg("looking at '%s'", devpath);
117 /* we only care about class devices and block stuff */
118 if (!strstr(devpath, "class") &&
119 !strstr(devpath, "block")) {
120 dbg("not a block or class device");
124 /* skip blacklisted subsystems */
127 while (subsystem_blacklist[i][0] != '\0') {
128 if (strcmp(subsystem, subsystem_blacklist[i]) == 0) {
129 dbg("don't care about '%s' devices", subsystem);
135 /* initialize our configuration */
138 /* set up a default signal handler for now */
139 act.sa_handler = sig_handler;
140 sigemptyset (&act.sa_mask);
141 act.sa_flags = SA_RESTART;
142 sigaction(SIGINT, &act, NULL);
143 sigaction(SIGTERM, &act, NULL);
145 /* initialize the naming deamon */
148 retval = udev_add_device(devpath, subsystem, 1);
157 int main(int argc, char **argv, char **envp)
162 dbg("version %s", UDEV_VERSION);
164 return udev_hotplug(argc, argv);