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"
42 /* global variables */
46 void log_message (int level, const char *format, ...)
50 va_start(args, format);
51 vsyslog(level, format, args);
57 int main(int argc, char *argv[], char *envp[])
59 static struct udevd_msg usend_msg;
60 struct sockaddr_un saddr;
64 logging_init("udevcontrol");
65 dbg("version %s", UDEV_VERSION);
68 info("usage: udevcontrol <cmd>\n");
72 memset(&usend_msg, 0x00, sizeof(struct udevd_msg));
73 strcpy(usend_msg.magic, UDEV_MAGIC);
75 if (strstr(argv[1], "stop_exec_queue"))
76 usend_msg.type = UDEVD_STOP_EXEC_QUEUE;
77 else if (strstr(argv[1], "start_exec_queue"))
78 usend_msg.type = UDEVD_START_EXEC_QUEUE;
80 info("unknown command\n");
84 sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
86 info("error getting socket");
90 memset(&saddr, 0x00, sizeof(struct sockaddr_un));
91 saddr.sun_family = AF_LOCAL;
92 /* use abstract namespace for socket path */
93 strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
94 addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
97 retval = sendto(sock, &usend_msg, sizeof(usend_msg), 0, (struct sockaddr *)&saddr, addrlen);
99 info("error sending message (%s)", strerror(errno));