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"
36 #include "libsysfs/libsysfs.h"
38 /* global variables */
42 static inline char *get_action(void)
46 action = getenv("ACTION");
50 static inline char *get_devpath(void)
54 devpath = getenv("DEVPATH");
58 static inline char *get_seqnum(void)
62 seqnum = getenv("SEQNUM");
66 int main(int argc, char **argv, char **envp)
76 dbg("version %s", UDEV_VERSION);
79 dbg ("unknown number of arguments");
85 devpath = get_devpath();
90 dbg("looking at '%s'", devpath);
92 /* we only care about class devices and block stuff */
93 if (!strstr(devpath, "class") &&
94 !strstr(devpath, "block")) {
95 dbg("not a block or class device");
99 /* but we don't care about net class devices */
100 if (strcmp(subsystem, "net") == 0) {
101 dbg("don't care about net devices");
105 action = get_action();
111 /* initialize our configuration */
114 /* initialize udev database */
115 retval = udevdb_init(UDEVDB_DEFAULT);
117 dbg("unable to initialize database");
121 /* initialize the naming deamon */
124 if (strcmp(action, "add") == 0)
125 retval = udev_add_device(devpath, subsystem);
127 else if (strcmp(action, "remove") == 0)
128 retval = udev_remove_device(devpath, subsystem);
131 dbg("unknown action '%s'", action);