udevadm-control.c revision e4255f115330b949c1caeb561cbe0e39f5225f50
b7ff1e47da4653d2ff1ec7b489e6067fed29d8c5Lennart Poettering * Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org>
c904f64d84db8c4eebedf210ba10893f19ba05edLennart Poettering * This program is free software; you can redistribute it and/or modify it
f80781eaf9f927d7b4d5e66116e3f3a4242e6fa1Lennart Poettering * under the terms of the GNU General Public License as published by the
f80781eaf9f927d7b4d5e66116e3f3a4242e6fa1Lennart Poettering * Free Software Foundation version 2 of the License.
05677bb78079c3fa0283101aac2c07581f4873f1Lennart Poettering * This program is distributed in the hope that it will be useful, but
73090dc815390f4fca4e3ed8a7e1d3806605daaaLennart Poettering * WITHOUT ANY WARRANTY; without even the implied warranty of
71092d70af35567dd154d3de2ce04ce62e157a7cLennart Poettering * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35c5c7a01daeb2c83c693deea07c8f2d0d6c83e2Lennart Poettering * General Public License for more details.
ddd88763921a1534081ed28e36f6712a85449005Lennart Poettering * You should have received a copy of the GNU General Public License along
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers * with this program; if not, write to the Free Software Foundation, Inc.,
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
7d441ddb5ca090b5a97f58ac4b4d97b3e84fa81eLennart Poetteringextern struct udev_ctrl *udev_ctrl_new_from_socket(const char *socket_path);
7d441ddb5ca090b5a97f58ac4b4d97b3e84fa81eLennart Poetteringextern void udev_ctrl_unref(struct udev_ctrl *uctrl);
14e639ae7a1dbf156273ce697d30fbc6c6594209Lennart Poetteringextern int udev_ctrl_set_log_level(struct udev_ctrl *uctrl, int priority);
14e639ae7a1dbf156273ce697d30fbc6c6594209Lennart Poetteringextern int udev_ctrl_stop_exec_queue(struct udev_ctrl *uctrl);
b38bb4937972546dcc60ab5ea4a7d4b898349c1cKay Sieversextern int udev_ctrl_start_exec_queue(struct udev_ctrl *uctrl);
034a2a52ac0ec83e0229941d635d310b23eb04dfLennart Poetteringextern int udev_ctrl_reload_rules(struct udev_ctrl *uctrl);
ff01d048b4c1455241c894cf7982662c9d28fd34Lennart Poetteringextern int udev_ctrl_set_env(struct udev_ctrl *uctrl, const char *key);
ff01d048b4c1455241c894cf7982662c9d28fd34Lennart Poetteringextern int udev_ctrl_set_max_childs(struct udev_ctrl *uctrl, int count);
72b9ed828bd22f3ddd74b6853c183eebf006d6d8Lennart Poetteringextern int udev_ctrl_set_max_childs_running(struct udev_ctrl *uctrl, int count);
0a55b298d930543c8065bb9e708dd112562b1736Lennart Poetteringstruct udev_ctrl *udev_ctrl_new_from_socket(const char *socket_path)
85f248b26653f5322c26735661d63d4e8460c30eLennart Poettering uctrl = malloc(sizeof(struct udev_ctrl));
1258097cd3cdbc5dd3d264850119e553a29c5068Lennart Poettering memset(uctrl, 0x00, sizeof(struct udev_ctrl));
1258097cd3cdbc5dd3d264850119e553a29c5068Lennart Poettering uctrl->sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
a4c279f87451186b8beb1b8cc21c7cad561ecf4bLennart Poettering err("error getting socket: %s\n", strerror(errno));
d3fc81bd6a5a046b22600ac1204df220c93d2c15Lennart Poettering strcpy(uctrl->saddr.sun_path, socket_path);
71092d70af35567dd154d3de2ce04ce62e157a7cLennart Poettering uctrl->addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(uctrl->saddr.sun_path);
253ee27a0c7a410d27d490bb79ea97caed6a2b68Lennart Poettering /* translate leading '@' to abstract namespace */
f28f1daf754a9a07de90e6fc4ada581bf5de677dLennart Poetteringvoid udev_ctrl_unref(struct udev_ctrl *uctrl)
916abb21d0a6653e0187b91591e492026886b0a4Lennart Poetteringstatic int ctrl_send(struct udev_ctrl *uctrl, enum udevd_ctrl_msg_type type, int intval, const char *buf)
71092d70af35567dd154d3de2ce04ce62e157a7cLennart Poettering memset(&ctrl_msg, 0x00, sizeof(struct udevd_ctrl_msg));
9534ce54858c67363b841cdbdc315140437bfdb4Lennart Poettering strlcpy(ctrl_msg.buf, buf, sizeof(ctrl_msg.buf));
73090dc815390f4fca4e3ed8a7e1d3806605daaaLennart Poettering err = sendto(uctrl->sock, &ctrl_msg, sizeof(ctrl_msg), 0, (struct sockaddr *)&uctrl->saddr, uctrl->addrlen);
c798c40ec957a35cd4b7d04a196a9e58880c6ff3Lennart Poettering err("error sending message: %s\n", strerror(errno));
253ee27a0c7a410d27d490bb79ea97caed6a2b68Lennart Poetteringint udev_ctrl_set_log_level(struct udev_ctrl *uctrl, int priority)
5d0fcd7c8d29340ac9425c309e8ac436a9af699cLennart Poettering ctrl_send(uctrl, UDEVD_CTRL_SET_LOG_LEVEL, priority, NULL);
f957632b960a0a42999b38ded7089fa602b41745Kay Sieversint udev_ctrl_stop_exec_queue(struct udev_ctrl *uctrl)
44143309dd0b37d61d7d842ca58f01a65646ec71Kay Sievers ctrl_send(uctrl, UDEVD_CTRL_STOP_EXEC_QUEUE, 0, NULL);
ba1a55152c50dfbcd3d4a64353b95f4a2f37985eLennart Poetteringint udev_ctrl_start_exec_queue(struct udev_ctrl *uctrl)
71092d70af35567dd154d3de2ce04ce62e157a7cLennart Poettering ctrl_send(uctrl, UDEVD_CTRL_START_EXEC_QUEUE, 0, NULL);
260abb780a135e4cae8c10715c7e85675efc345aLennart Poetteringint udev_ctrl_reload_rules(struct udev_ctrl *uctrl)
260abb780a135e4cae8c10715c7e85675efc345aLennart Poettering ctrl_send(uctrl, UDEVD_CTRL_RELOAD_RULES, 0, NULL);
21bdae12e11ae20460715475d8a0c991f15464acLennart Poetteringint udev_ctrl_set_env(struct udev_ctrl *uctrl, const char *key)