+ memset(&saddr, 0x00, sizeof(struct sockaddr_un));
+ saddr.sun_family = AF_LOCAL;
+ /* use abstract namespace for socket path */
+ 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 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++) {
+ const char *key;
+ int keylen;
+
+ key = envp[i];
+ keylen = strlen(key);
+
+ /* prevent loops in the scripts we execute */
+ if (strncmp(key, "UDEVD_EVENT=", 12) == 0) {
+ dbg("seems that the event source is not the kernel, just exit");
+ goto exit;
+ }
+
+ if (bufpos + keylen >= UEVENT_BUFFER_SIZE-1) {
+ err("environment buffer too small, probably not called by the kernel");
+ continue;
+ }
+
+ /* remember the SUBSYSTEM */
+ if (strncmp(key, "SUBSYSTEM=", 10) == 0)
+ subsystem = &key[10];
+
+ dbg("add '%s' to env[%i] buffer", key, i);
+ strcpy(&usend_msg.envbuf[bufpos], key);
+ bufpos += keylen + 1;