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] check for empty line a bit better in the parser.
[elogind.git]
/
udev.c
diff --git
a/udev.c
b/udev.c
index 6e7ac25175b8dc9450b9426cda9a266f538c2288..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,22
+48,34
@@
static char *get_action(void)
return action;
}
return action;
}
+static inline char *get_devpath(void)
+{
+ char *devpath;
+
+ devpath = getenv("DEVPATH");
+ return devpath;
+}
-static
char *get_device
(void)
+static
inline char *get_seqnum
(void)
{
{
- char *
device
;
+ char *
seqnum
;
-
device = getenv("DEVPATH
");
- return
device
;
+
seqnum = getenv("SEQNUM
");
+ return
seqnum
;
}
}
-int main(int argc, char *
argv[]
)
+int main(int argc, char *
*argv, char **envp
)
{
char *action;
{
char *action;
- char *dev
ice
;
+ char *dev
path
;
char *subsystem;
int retval = -EINVAL;
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;
@@
-66,17
+83,17
@@
int main(int argc, char *argv[])
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;
}
@@
-92,10
+109,16
@@
int main(int argc, char *argv[])
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;
}
@@
-103,18
+126,20
@@
int main(int argc, char *argv[])
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;
}
-