6 * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation version 2 of the License.
13 * This program 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 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
34 #include "udev_version.h"
35 #include "udev_dbus.h"
38 #include "libsysfs/libsysfs.h"
40 /* global variables */
44 static void sig_handler(int signum)
46 dbg("caught signal %d", signum);
56 dbg("unhandled signal");
60 static inline char *get_action(void)
64 action = getenv("ACTION");
68 static inline char *get_devpath(void)
72 devpath = getenv("DEVPATH");
76 static inline char *get_seqnum(void)
80 seqnum = getenv("SEQNUM");
84 int main(int argc, char **argv, char **envp)
94 dbg("version %s", UDEV_VERSION);
97 dbg ("unknown number of arguments");
103 devpath = get_devpath();
108 dbg("looking at '%s'", devpath);
110 /* we only care about class devices and block stuff */
111 if (!strstr(devpath, "class") &&
112 !strstr(devpath, "block")) {
113 dbg("not a block or class device");
117 /* but we don't care about net class devices */
118 if (strcmp(subsystem, "net") == 0) {
119 dbg("don't care about net devices");
123 action = get_action();
129 /* initialize our configuration */
132 /* connect to the system message bus */
135 /* initialize udev database */
136 retval = udevdb_init(UDEVDB_DEFAULT);
138 dbg("unable to initialize database");
142 /* set up a default signal handler for now */
143 signal(SIGINT, sig_handler);
144 signal(SIGTERM, sig_handler);
145 signal(SIGKILL, sig_handler);
147 /* initialize the naming deamon */
150 if (strcmp(action, "add") == 0)
151 retval = udev_add_device(devpath, subsystem);
153 else if (strcmp(action, "remove") == 0)
154 retval = udev_remove_device(devpath, subsystem);
157 dbg("unknown action '%s'", action);
163 /* disconnect from the system message bus */