]>
git.ipfire.org Git - thirdparty/systemd.git/blob - udev.c
6 * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation version 2 of the License.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include "libsysfs/sysfs/libsysfs.h"
34 #include "udev_version.h"
39 /* global variables */
44 unsigned char logname
[LOGNAME_SIZE
];
45 void log_message(int level
, const char *format
, ...)
52 va_start(args
, format
);
53 vsyslog(level
, format
, args
);
58 asmlinkage
static void sig_handler(int signum
)
66 dbg("unhandled signal %d", signum
);
70 static char *subsystem_blacklist
[] = {
79 int main(int argc
, char *argv
[], char *envp
[])
95 dbg("version %s", UDEV_VERSION
);
97 /* initialize our configuration */
100 if (strstr(argv
[0], "udevstart")) {
101 act_type
= UDEVSTART
;
103 action
= get_action();
108 if (strcmp(action
, "add") == 0) {
110 } else if (strcmp(action
, "remove") == 0) {
113 dbg("unknown action '%s'", action
);
117 devpath
= get_devpath();
122 dbg("looking at '%s'", devpath
);
124 /* we only care about class devices and block stuff */
125 if (!strstr(devpath
, "class") && !strstr(devpath
, "block")) {
126 dbg("not a block or class device");
130 subsystem
= get_subsystem(main_argv
[1]);
132 dbg("no subsystem?");
136 /* skip blacklisted subsystems */
138 while (subsystem_blacklist
[i
][0] != '\0') {
139 if (strcmp(subsystem
, subsystem_blacklist
[i
]) == 0) {
140 dbg("don't care about '%s' devices", subsystem
);
147 /* set signal handlers */
148 act
.sa_handler
= sig_handler
;
149 sigemptyset (&act
.sa_mask
);
150 act
.sa_flags
= SA_RESTART
;
151 sigaction(SIGINT
, &act
, NULL
);
152 sigaction(SIGTERM
, &act
, NULL
);
154 /* initialize udev database */
155 if (udevdb_init(UDEVDB_DEFAULT
) != 0) {
156 dbg("unable to initialize database");
165 retval
= udev_start();
170 retval
= udev_add_device(devpath
, subsystem
, NOFAKE
);
174 retval
= udev_remove_device(devpath
, subsystem
);