chiark / gitweb /
prepare for new HAL udevdb dump
[elogind.git] / udevsend.c
index 8915edacc8cf2c27a4fdb72571fe2b42184e48ca..0ba1b58a4ba380a49095d0fa4e7f1822c996b6ad 100644 (file)
@@ -1,12 +1,9 @@
 /*
  * udevsend.c
  *
- * Userspace devfs
- *
  * Copyright (C) 2004 Ling, Xiaofeng <xiaofeng.ling@intel.com>
  * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
  *
- *
  *     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
  *     Free Software Foundation version 2 of the License.
  *
  */
 
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/wait.h>
-#include <sys/un.h>
-#include <time.h>
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
-#include <string.h>
 #include <unistd.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <sys/un.h>
 #include <linux/stddef.h>
 
 #include "udev.h"
@@ -115,7 +112,7 @@ static void run_udev(const char *subsystem)
 
 int main(int argc, char *argv[], char *envp[])
 {
-       static struct udevsend_msg usend_msg;
+       static struct udevd_msg usend_msg;
        int usend_msg_len;
        int i;
        int loop;
@@ -144,8 +141,9 @@ int main(int argc, char *argv[], char *envp[])
        strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
        addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
 
-       memset(&usend_msg, 0x00, sizeof(struct udevsend_msg));
+       memset(&usend_msg, 0x00, sizeof(struct udevd_msg));
        strcpy(usend_msg.magic, UDEV_MAGIC);
+       usend_msg.type = UDEVD_UEVENT_UDEVSEND;
 
        /* copy all keys to send buffer */
        for (i = 0; envp[i]; i++) {
@@ -161,7 +159,7 @@ int main(int argc, char *argv[], char *envp[])
                        goto exit;
                }
 
-               if (bufpos + keylen >= HOTPLUG_BUFFER_SIZE-1) {
+               if (bufpos + keylen >= UEVENT_BUFFER_SIZE-1) {
                        err("environment buffer too small, probably not called by the kernel");
                        continue;
                }
@@ -180,11 +178,11 @@ int main(int argc, char *argv[], char *envp[])
                dbg("add 'SUBSYSTEM=%s' to env[%i] buffer from argv", argv[1], i);
        }
 
-       usend_msg_len = offsetof(struct udevsend_msg, envbuf) + bufpos;
+       usend_msg_len = offsetof(struct udevd_msg, envbuf) + bufpos;
        dbg("usend_msg_len=%i", usend_msg_len);
 
        /* If we can't send, try to start daemon and resend message */
-       loop = SEND_WAIT_MAX_SECONDS * SEND_WAIT_LOOP_PER_SECOND;
+       loop = UDEVSEND_WAIT_MAX_SECONDS * UDEVSEND_WAIT_LOOP_PER_SECOND;
        while (--loop) {
                retval = sendto(sock, &usend_msg, usend_msg_len, 0, (struct sockaddr *)&saddr, addrlen);
                if (retval != -1) {
@@ -207,8 +205,8 @@ int main(int argc, char *argv[], char *envp[])
                        dbg("udevd daemon started");
                        started_daemon = 1;
                } else {
-                       dbg("retry to connect %d", SEND_WAIT_MAX_SECONDS * SEND_WAIT_LOOP_PER_SECOND - loop);
-                       usleep(1000 * 1000 / SEND_WAIT_LOOP_PER_SECOND);
+                       dbg("retry to connect %d", UDEVSEND_WAIT_MAX_SECONDS * UDEVSEND_WAIT_LOOP_PER_SECOND - loop);
+                       usleep(1000 * 1000 / UDEVSEND_WAIT_LOOP_PER_SECOND);
                }
        }