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] fix permission handling logic
[elogind.git]
/
udev.c
diff --git
a/udev.c
b/udev.c
index a3984771188a50d33a3e6b02fcf38922868ea8df..bf18a568eaae06b7ce09b3ea0ca79ddde3be0434 100644
(file)
--- a/
udev.c
+++ b/
udev.c
@@
-27,6
+27,7
@@
#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"
@@
-34,8
+35,11
@@
#include "udevdb.h"
#include "libsysfs/libsysfs.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
+47,26
@@
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;
char *subsystem;
int retval = -EINVAL;
@@
-74,17
+82,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;
}
@@
-100,10
+108,13
@@
int main(int argc, char **argv, char **envp)
goto exit;
}
goto exit;
}
+ /* initialize our configuration */
+ udev_init_config();
+
/* 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;
}
@@
-111,13
+122,13
@@
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();
@@
-125,4
+136,3
@@
int main(int argc, char **argv, char **envp)
exit:
return retval;
}
exit:
return retval;
}
-