chiark / gitweb /
add dummy inotify syscalls on unsupported architecture
[elogind.git] / udevinitsend.c
index 26ae5c84185b5a18c74793909427d5229961a624..4f50da8f680160e2e3187ae3d17105f3ae4547ef 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * udevinitsend.c
  *
- * Userspace devfs
- *
- * Copyright (C) 2004, 2005 Hannes Reinecke <hare@suse.de>
+ * Copyright (C) 2004, 2005 SuSE Linux Products GmbH
+ * Author:
+ *     Hannes Reinecke <hare@suse.de>
  *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the
 #include "udev_utils.h"
 #include "logging.h"
 
-static int log = 0;
+static int udev_log = 0;
 
 #ifdef USE_LOG
 void log_message (int priority, const char *format, ...)
 {
        va_list args;
 
-       if (priority > log)
+       if (priority > udev_log)
                return;
 
        va_start(args, format);
@@ -128,15 +128,14 @@ static int udevsend(char *filename, int sock, int disable_loop_detection)
                }
 
                if (ch < le) {
-
                        strncpy(&usend_msg.envbuf[bufpos],ls,(ch - ls) + 1);
                        bufpos += (ch - ls) + 1;
                        if (ch[1] == '\'' && le[-1] == '\'') {
-                               strncpy(&usend_msg.envbuf[bufpos],ch + 2, (le - ch) -3);
+                               strncpy(&usend_msg.envbuf[bufpos],ch + 2, (le - ch) - 3);
                                bufpos += (le - ch) - 3;
                        } else {
-                               strncpy(&usend_msg.envbuf[bufpos],ch, (le - ch));
-                               bufpos += (le - ch);
+                               strncpy(&usend_msg.envbuf[bufpos],ch + 1, (le - ch) - 1);
+                               bufpos += (le - ch) - 1;
                        }
                        bufpos++;
                }
@@ -153,9 +152,10 @@ loop_end:
                retval = sendto(sock, &usend_msg, usend_msg_len, 0, (struct sockaddr *)&saddr, addrlen);
                if (retval < 0) {
                        dbg("error sending message (%s)", strerror(errno));
+                       retval = -1;
                }
        }
-               
+
        return retval;
 }
 
@@ -167,14 +167,14 @@ int main(int argc, char *argv[], char *envp[])
        char *event_file = NULL;
        DIR *dirstream;
        struct dirent *direntry;
-       int retval = 1;
+       int retval = 0;
        int disable_loop_detection = 0;
        int sock;
        const char *env;
 
        env = getenv("UDEV_LOG");
        if (env)
-               log = log_priority(env);
+               udev_log = log_priority(env);
 
        logging_init("udevinitsend");
        dbg("version %s", UDEV_VERSION);
@@ -218,7 +218,7 @@ int main(int argc, char *argv[], char *envp[])
                if (!dirstream) {
                        info("error opening directory %s: %s\n",
                             event_dir, strerror(errno));
-                       return 1;
+                       return 2;
                }
                chdir(event_dir);
                while ((direntry = readdir(dirstream)) != NULL) {
@@ -235,5 +235,7 @@ int main(int argc, char *argv[], char *envp[])
        if (sock != -1)
                close(sock);
 
-       return retval;
+       if (retval)
+               return 3;
+       return 0;
 }