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] more init script cleanups, the stop target now calls udev to cleanup instead...
[elogind.git]
/
udev.c
diff --git
a/udev.c
b/udev.c
index 0aba8c4bf9aa133999dedb8b8e209d078593aaf3..ac29ec6f4424909fcd9799ec1db1fbeb3dc421ce 100644
(file)
--- a/
udev.c
+++ b/
udev.c
@@
-27,15
+27,20
@@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
+#include <ctype.h>
#include "udev.h"
#include "udev_version.h"
#include "udev.h"
#include "udev_version.h"
+#include "udev_dbus.h"
#include "namedev.h"
#include "udevdb.h"
#include "libsysfs/libsysfs.h"
#include "namedev.h"
#include "udevdb.h"
#include "libsysfs/libsysfs.h"
+/* global variables */
+char **main_argv;
+char **main_envp;
-static char *get_action(void)
+static
inline
char *get_action(void)
{
char *action;
{
char *action;
@@
-43,28
+48,34
@@
static char *get_action(void)
return action;
}
return action;
}
-
-static char *get_device(void)
+static inline char *get_devpath(void)
{
{
- char *dev
ice
;
+ char *dev
path
;
- dev
ice
= getenv("DEVPATH");
- return dev
ice
;
+ dev
path
= getenv("DEVPATH");
+ return dev
path
;
}
}
-char **main_argv;
-char **main_envp;
+static inline char *get_seqnum(void)
+{
+ char *seqnum;
+
+ seqnum = getenv("SEQNUM");
+ return seqnum;
+}
int main(int argc, char **argv, char **envp)
{
char *action;
int main(int argc, char **argv, char **envp)
{
char *action;
- char *dev
ice
;
+ char *dev
path
;
char *subsystem;
int retval = -EINVAL;
main_argv = argv;
main_envp = envp;
char *subsystem;
int retval = -EINVAL;
main_argv = argv;
main_envp = envp;
+ dbg("version %s", UDEV_VERSION);
+
if (argc != 2) {
dbg ("unknown number of arguments");
goto exit;
if (argc != 2) {
dbg ("unknown number of arguments");
goto exit;
@@
-72,17
+83,17
@@
int main(int argc, char **argv, char **envp)
subsystem = argv[1];
subsystem = argv[1];
- dev
ice = get_device
();
- if (!dev
ice
) {
- dbg ("no dev
ice
?");
+ dev
path = get_devpath
();
+ if (!dev
path
) {
+ dbg ("no dev
path
?");
goto exit;
}
goto exit;
}
- dbg("looking at
%s", device
);
+ dbg("looking at
'%s'", devpath
);
/* we only care about class devices and block stuff */
/* we only care about class devices and block stuff */
- if (!strstr(dev
ice
, "class") &&
- !strstr(dev
ice
, "block")) {
- dbg("not
block or class
");
+ if (!strstr(dev
path
, "class") &&
+ !strstr(dev
path
, "block")) {
+ dbg("not
a block or class device
");
goto exit;
}
goto exit;
}
@@
-98,10
+109,16
@@
int main(int argc, char **argv, char **envp)
goto exit;
}
goto exit;
}
+ /* initialize our configuration */
+ udev_init_config();
+
+ /* connect to the system message bus */
+ sysbus_connect();
+
/* initialize udev database */
retval = udevdb_init(UDEVDB_DEFAULT);
if (retval != 0) {
/* initialize udev database */
retval = udevdb_init(UDEVDB_DEFAULT);
if (retval != 0) {
- dbg("
Unable to initialize database.
");
+ dbg("
unable to initialize database
");
goto exit;
}
goto exit;
}
@@
-109,18
+126,20
@@
int main(int argc, char **argv, char **envp)
namedev_init();
if (strcmp(action, "add") == 0)
namedev_init();
if (strcmp(action, "add") == 0)
- retval = udev_add_device(dev
ice, argv[1]
);
+ retval = udev_add_device(dev
path, subsystem
);
else if (strcmp(action, "remove") == 0)
else if (strcmp(action, "remove") == 0)
- retval = udev_remove_device(dev
ice, argv[1]
);
+ retval = udev_remove_device(dev
path, subsystem
);
else {
else {
- dbg("
Unknown action: %s
", action);
+ dbg("
unknown action '%s'
", action);
retval = -EINVAL;
}
udevdb_exit();
retval = -EINVAL;
}
udevdb_exit();
-exit:
+ /* disconnect from the system message bus */
+ sysbus_disconnect();
+
+exit:
return retval;
}
return retval;
}
-