chiark / gitweb /
[PATCH] 004 changelog entrys
[elogind.git] / udev.c
diff --git a/udev.c b/udev.c
index 7457262..a398477 100644 (file)
--- a/udev.c
+++ b/udev.c
@@ -31,6 +31,7 @@
 #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"
 
 
@@ -51,13 +52,21 @@ static char *get_device(void)
        return device;
 }
 
        return device;
 }
 
-int main(int argc, char *argv[])
+char **main_argv;
+char **main_envp;
+
+int main(int argc, char **argv, char **envp)
 {
        char *action;
        char *device;
        char *subsystem;
        int retval = -EINVAL;
        
 {
        char *action;
        char *device;
        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;
@@ -91,17 +100,27 @@ int main(int argc, char *argv[])
                goto exit;
        }
 
                goto exit;
        }
 
+       /* 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)
-               return udev_add_device(device, argv[1]);
+               retval = udev_add_device(device, argv[1]);
 
 
-       if (strcmp(action, "remove") == 0)
-               return udev_remove_device(device, argv[1]);
+       else if (strcmp(action, "remove") == 0)
+               retval = udev_remove_device(device, argv[1]);
 
 
-       dbg("Unknown action: %s", action);
-       retval = -EINVAL;
+       else {
+               dbg("Unknown action: %s", action);
+               retval = -EINVAL;
+       }
+       udevdb_exit();
 
 exit:  
        return retval;
 
 exit:  
        return retval;