chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] delete udevruler?
[elogind.git]
/
udev.c
diff --git
a/udev.c
b/udev.c
index 114ca0a52bdfb40d04205c9954ba34e094dd70f7..a13f7013b6e6e2aa167a4b5fb99ebb38fbccf2d8 100644
(file)
--- a/
udev.c
+++ b/
udev.c
@@
-20,6
+20,7
@@
*
*/
*
*/
+#define _KLIBC_HAS_ARCH_SIG_ATOMIC_T
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
@@
-36,6
+37,9
@@
#include "namedev.h"
#include "udevdb.h"
#include "namedev.h"
#include "udevdb.h"
+/* timeout flag for udevdb */
+extern sig_atomic_t gotalarm;
+
/* global variables */
char **main_argv;
char **main_envp;
/* global variables */
char **main_argv;
char **main_envp;
@@
-55,9
+59,13
@@
void log_message(int level, const char *format, ...)
}
#endif
}
#endif
-
asmlinkage static void
sig_handler(int signum)
+
static void asmlinkage
sig_handler(int signum)
{
switch (signum) {
{
switch (signum) {
+ case SIGALRM:
+ gotalarm = 1;
+ info("error: timeout reached, event probably not handled correctly");
+ break;
case SIGINT:
case SIGTERM:
udevdb_exit();
case SIGINT:
case SIGTERM:
udevdb_exit();
@@
-94,7
+102,8
@@
int main(int argc, char *argv[], char *envp[])
dbg("version %s", UDEV_VERSION);
dbg("version %s", UDEV_VERSION);
- /* initialize our configuration */
+ init_logging("udev");
+
udev_init_config();
if (strstr(argv[0], "udevstart")) {
udev_init_config();
if (strstr(argv[0], "udevstart")) {
@@
-122,7
+131,7
@@
int main(int argc, char *argv[], char *envp[])
dbg("looking at '%s'", devpath);
/* we only care about class devices and block stuff */
dbg("looking at '%s'", devpath);
/* we only care about class devices and block stuff */
- if (
strstr(devpath, "class") &&
strstr(devpath, "block")) {
+ if (
!strstr(devpath, "class") && !
strstr(devpath, "block")) {
dbg("not a block or class device");
goto exit;
}
dbg("not a block or class device");
goto exit;
}
@@
-145,17
+154,19
@@
int main(int argc, char *argv[], char *envp[])
}
/* set signal handlers */
}
/* set signal handlers */
- act.sa_handler = sig_handler;
+ act.sa_handler =
(void (*) (int))
sig_handler;
sigemptyset (&act.sa_mask);
sigemptyset (&act.sa_mask);
- act.sa_flags = SA_RESTART;
+ /* alarm must interrupt syscalls*/
+ sigaction(SIGALRM, &act, NULL);
sigaction(SIGINT, &act, NULL);
sigaction(SIGTERM, &act, NULL);
sigaction(SIGINT, &act, NULL);
sigaction(SIGTERM, &act, NULL);
+ /* trigger timout to interrupt blocking syscalls */
+ alarm(ALARM_TIMEOUT);
+
/* initialize udev database */
/* initialize udev database */
- if (udevdb_init(UDEVDB_DEFAULT) != 0) {
- dbg("unable to initialize database");
- goto exit;
- }
+ if (udevdb_init(UDEVDB_DEFAULT) != 0)
+ info("error: unable to initialize database, continuing without database");
switch(act_type) {
case UDEVSTART:
switch(act_type) {
case UDEVSTART: