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)
91 signal(SIGINT, sig_handler);
92 signal(SIGTERM, sig_handler);
93 signal(SIGKILL, sig_handler);
98 dbg("version %s", UDEV_VERSION);
101 dbg ("unknown number of arguments");
107 devpath = get_devpath();
112 dbg("looking at '%s'", devpath);
114 /* we only care about class devices and block stuff */
115 if (!strstr(devpath, "class") &&
116 !strstr(devpath, "block")) {
117 dbg("not a block or class device");
121 /* but we don't care about net class devices */
122 if (strcmp(subsystem, "net") == 0) {
123 dbg("don't care about net devices");
127 action = get_action();
133 /* initialize our configuration */
136 /* connect to the system message bus */
139 /* initialize udev database */
140 retval = udevdb_init(UDEVDB_DEFAULT);
142 dbg("unable to initialize database");
146 /* initialize the naming deamon */
149 if (strcmp(action, "add") == 0)
150 retval = udev_add_device(devpath, subsystem);
152 else if (strcmp(action, "remove") == 0)
153 retval = udev_remove_device(devpath, subsystem);
156 dbg("unknown action '%s'", action);
162 /* disconnect from the system message bus */