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.
33 #include "udev_version.h"
34 #include "udev_dbus.h"
37 #include "libsysfs/libsysfs.h"
39 /* global variables */
43 static inline char *get_action(void)
47 action = getenv("ACTION");
51 static inline char *get_devpath(void)
55 devpath = getenv("DEVPATH");
59 static inline char *get_seqnum(void)
63 seqnum = getenv("SEQNUM");
67 int main(int argc, char **argv, char **envp)
77 dbg("version %s", UDEV_VERSION);
80 dbg ("unknown number of arguments");
86 devpath = get_devpath();
91 dbg("looking at '%s'", devpath);
93 /* we only care about class devices and block stuff */
94 if (!strstr(devpath, "class") &&
95 !strstr(devpath, "block")) {
96 dbg("not a block or class device");
100 /* but we don't care about net class devices */
101 if (strcmp(subsystem, "net") == 0) {
102 dbg("don't care about net devices");
106 action = get_action();
112 /* initialize our configuration */
115 /* connect to the system message bus */
118 /* initialize udev database */
119 retval = udevdb_init(UDEVDB_DEFAULT);
121 dbg("unable to initialize database");
125 /* initialize the naming deamon */
128 if (strcmp(action, "add") == 0)
129 retval = udev_add_device(devpath, subsystem);
131 else if (strcmp(action, "remove") == 0)
132 retval = udev_remove_device(devpath, subsystem);
135 dbg("unknown action '%s'", action);
141 /* disconnect from the system message bus */