chiark / gitweb /
[PATCH] add -V option to udev to print the version number
[elogind.git] / udev.c
diff --git a/udev.c b/udev.c
index ca79bb4ec0e37812770ceaea2b76acf901d9e438..b1ba1435e7236926e905e7f20959058954b906fe 100644 (file)
--- a/udev.c
+++ b/udev.c
@@ -61,6 +61,10 @@ static int manage_hotplug_event(void) {
        int fd;
        int len;
 
+       /* false, if we are called directly */
+       if (!getenv("MANAGED_EVENT"))
+               goto exit;
+
        fd = open("/proc/sys/kernel/hotplug", O_RDONLY);
        if (fd < 0)
                goto exit;
@@ -103,8 +107,14 @@ int main(int argc, char *argv[], char *envp[])
        const char *devpath = getenv("DEVPATH");
        const char *subsystem = argv[1];
 
-       dbg("version %s", UDEV_VERSION);
+       if (argc == 2 && strcmp(argv[1], "-V") == 0) {
+               printf("%s\n", UDEV_VERSION);
+               exit(0);
+       }
+
        logging_init("udev");
+       dbg("version %s", UDEV_VERSION);
+
        udev_init_config();
 
        /* set signal handlers */