6 * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation version 2 of the License.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <sys/types.h>
25 #include <sys/socket.h>
35 #include <linux/stddef.h>
38 #include "udev_version.h"
40 #include "udev_utils.h"
43 /* global variables */
48 void log_message (int priority, const char *format, ...)
55 va_start(args, format);
56 vsyslog(priority, format, args);
62 int main(int argc, char *argv[], char *envp[])
64 static struct udevd_msg usend_msg;
65 struct sockaddr_un saddr;
72 env = getenv("UDEV_LOG");
74 log = log_priority(env);
76 logging_init("udevcontrol");
77 dbg("version %s", UDEV_VERSION);
80 err("error finding comand");
84 memset(&usend_msg, 0x00, sizeof(struct udevd_msg));
85 strcpy(usend_msg.magic, UDEV_MAGIC);
87 if (!strcmp(argv[1], "stop_exec_queue"))
88 usend_msg.type = UDEVD_STOP_EXEC_QUEUE;
89 else if (!strcmp(argv[1], "start_exec_queue"))
90 usend_msg.type = UDEVD_START_EXEC_QUEUE;
91 else if (!strncmp(argv[1], "log_priority=", strlen("log_priority="))) {
92 intval = (int *) usend_msg.envbuf;
93 val = &argv[1][strlen("log_priority=")];
94 usend_msg.type = UDEVD_SET_LOG_LEVEL;
95 *intval = log_priority(val);
96 info("send log_priority=%i", *intval);
97 } else if (!strncmp(argv[1], "max_childs=", strlen("max_childs="))) {
98 intval = (int *) usend_msg.envbuf;
99 val = &argv[1][strlen("max_childs=")];
100 usend_msg.type = UDEVD_SET_MAX_CHILDS;
102 info("send max_childs=%i", *intval);
104 err("error parsing command\n");
108 sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
110 err("error getting socket");
114 memset(&saddr, 0x00, sizeof(struct sockaddr_un));
115 saddr.sun_family = AF_LOCAL;
116 /* use abstract namespace for socket path */
117 strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
118 addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
121 retval = sendto(sock, &usend_msg, sizeof(usend_msg), 0, (struct sockaddr *)&saddr, addrlen);
123 info("error sending message (%s)", strerror(errno));
126 dbg("sent message type=0x%02x, %u bytes sent", usend_msg.type, retval);