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 char sysfs_path[SYSFS_PATH_MAX];
43 char udev_config_dir[PATH_MAX];
44 char udev_root[PATH_MAX];
45 char udev_db_filename[PATH_MAX+NAME_MAX];
46 char udev_permission_filename[PATH_MAX+NAME_MAX];
47 char udev_rules_filename[PATH_MAX+NAME_MAX];
48 char udev_config_filename[PATH_MAX+NAME_MAX];
49 char default_mode_str[NAME_MAX];
52 static inline char *get_action(void)
56 action = getenv("ACTION");
60 static inline char *get_devpath(void)
64 devpath = getenv("DEVPATH");
68 static inline char *get_seqnum(void)
72 seqnum = getenv("SEQNUM");
76 int main(int argc, char **argv, char **envp)
86 dbg("version %s", UDEV_VERSION);
89 dbg ("unknown number of arguments");
95 devpath = get_devpath();
100 dbg("looking at '%s'", devpath);
102 /* we only care about class devices and block stuff */
103 if (!strstr(devpath, "class") &&
104 !strstr(devpath, "block")) {
105 dbg("not a block or class device");
109 /* but we don't care about net class devices */
110 if (strcmp(subsystem, "net") == 0) {
111 dbg("don't care about net devices");
115 action = get_action();
121 /* initialize our configuration */
124 /* initialize udev database */
125 retval = udevdb_init(UDEVDB_DEFAULT);
127 dbg("unable to initialize database");
131 /* initialize the naming deamon */
134 if (strcmp(action, "add") == 0)
135 retval = udev_add_device(devpath, subsystem);
137 else if (strcmp(action, "remove") == 0)
138 retval = udev_remove_device(devpath, subsystem);
141 dbg("unknown action '%s'", action);