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] add support for the default_mode variable, as it is documented...
[elogind.git]
/
udev.c
diff --git
a/udev.c
b/udev.c
index 74572625afaae0830175bcf653e2063fc3d0b7b3..bf18a568eaae06b7ce09b3ea0ca79ddde3be0434 100644
(file)
--- a/
udev.c
+++ b/
udev.c
@@
-27,14
+27,19
@@
#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 "namedev.h"
#include "udev.h"
#include "udev_version.h"
#include "namedev.h"
+#include "udevdb.h"
#include "libsysfs/libsysfs.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;
@@
-42,22
+47,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;
@@
-65,17
+82,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;
}
@@
-91,19
+108,31
@@
int main(int argc, char *argv[])
goto exit;
}
goto exit;
}
+ /* initialize our configuration */
+ udev_init_config();
+
+ /* initialize udev database */
+ retval = udevdb_init(UDEVDB_DEFAULT);
+ if (retval != 0) {
+ dbg("unable to initialize database");
+ goto exit;
+ }
+
/* initialize the naming deamon */
namedev_init();
if (strcmp(action, "add") == 0)
/* initialize the naming deamon */
namedev_init();
if (strcmp(action, "add") == 0)
- ret
urn udev_add_device(device, argv[1]
);
+ ret
val = udev_add_device(devpath, subsystem
);
- if (strcmp(action, "remove") == 0)
- ret
urn udev_remove_device(device, argv[1]
);
+
else
if (strcmp(action, "remove") == 0)
+ ret
val = udev_remove_device(devpath, subsystem
);
- dbg("Unknown action: %s", action);
- retval = -EINVAL;
+ else {
+ dbg("unknown action '%s'", action);
+ retval = -EINVAL;
+ }
+ udevdb_exit();
exit:
return retval;
}
exit:
return retval;
}
-