X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=extras%2Fdbus%2Fudev_dbus.c;h=4852d429f81751d9f962ee2d2744d90aa8352cf1;hb=eab52c24431b4305708a7579a823585555b8f33b;hp=955a3dbb49fe56d7336582532340aa3fc07d6795;hpb=357f44a534e5e32e52020121c983aca90ae7ac1b;p=elogind.git diff --git a/extras/dbus/udev_dbus.c b/extras/dbus/udev_dbus.c index 955a3dbb4..4852d429f 100644 --- a/extras/dbus/udev_dbus.c +++ b/extras/dbus/udev_dbus.c @@ -1,3 +1,23 @@ +/* + * udev_dbus.c + * + * Copyright (C) 2003 David Zeuthen + * + * 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. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + #include #include #include @@ -18,21 +38,18 @@ void log_message(int level, const char *format, ...) { va_list args; - if (!udev_log) - return; - va_start(args, format); vsyslog(level, format, args); va_end(args); } #endif -/** variable for the connection the to system message bus or #NULL +/* Variable for the connection the to system message bus or NULL * if we cannot connect or acquire the org.kernel.udev service */ static DBusConnection* sysbus_connection; -/** Disconnect from the system message bus */ +/* Disconnect from the system message bus */ static void sysbus_disconnect(void) { if (sysbus_connection == NULL) @@ -42,7 +59,7 @@ static void sysbus_disconnect(void) sysbus_connection = NULL; } -/** Connect to the system message bus */ +/* Connect to the system message bus */ static void sysbus_connect(void) { DBusError error; @@ -70,20 +87,20 @@ static void sysbus_connect(void) dbus_bus_acquire_service(sysbus_connection, "org.kernel.udev", 0, &error); if (dbus_error_is_set(&error)) { - printf("cannot acquire org.kernel.udev service, error %s: %s'", - error.name, error.message); + dbg("cannot acquire org.kernel.udev service, error %s: %s'", + error.name, error.message); sysbus_disconnect(); return; } } -/** Send out a signal that a device node is created +/* Send out a signal that a device node is created * - * @param devnode name of the device node, e.g. /dev/sda1 - * @param path Sysfs path of device + * @param devname Name of the device node, e.g. /dev/sda1 + * @param path Sysfs path of device */ -static void sysbus_send_create(const char *devnode, const char *path) +static void sysbus_send_create(const char *devname, const char *path) { DBusMessage* message; DBusMessageIter iter; @@ -94,7 +111,7 @@ static void sysbus_send_create(const char *devnode, const char *path) "NodeCreated"); dbus_message_iter_init(message, &iter); - dbus_message_iter_append_string(&iter, devnode); + dbus_message_iter_append_string(&iter, devname); dbus_message_iter_append_string(&iter, path); if ( !dbus_connection_send(sysbus_connection, message, NULL) ) @@ -105,12 +122,12 @@ static void sysbus_send_create(const char *devnode, const char *path) dbus_connection_flush(sysbus_connection); } -/** Send out a signal that a device node is deleted +/* Send out a signal that a device node is deleted * - * @param devnode Name of the device node, e.g. /udev/sda1 - * @param path Sysfs path of device + * @param devname Name of the device node, e.g. /udev/sda1 + * @param path Sysfs path of device */ -static void sysbus_send_remove(const char *devnode, const char *path) +static void sysbus_send_remove(const char *devname, const char *path) { DBusMessage* message; DBusMessageIter iter; @@ -121,7 +138,7 @@ static void sysbus_send_remove(const char *devnode, const char *path) "NodeDeleted"); dbus_message_iter_init(message, &iter); - dbus_message_iter_append_string(&iter, devnode); + dbus_message_iter_append_string(&iter, devname); dbus_message_iter_append_string(&iter, path); if ( !dbus_connection_send(sysbus_connection, message, NULL) ) @@ -136,7 +153,7 @@ int main(int argc, char *argv[], char *envp[]) { char *action; char *devpath; - char *devnode; + char *devname; int retval = 0; init_logging("udev_dbus"); @@ -155,17 +172,17 @@ int main(int argc, char *argv[], char *envp[]) dbg("no devpath?"); goto exit; } - devnode = get_devnode(); - if (!devnode) { - dbg("no devnode?"); + devname = get_devname(); + if (!devname) { + dbg("no devname?"); goto exit; } if (strcmp(action, "add") == 0) { - sysbus_send_create(devnode, devpath); + sysbus_send_create(devname, devpath); } else { if (strcmp(action, "remove") == 0) { - sysbus_send_remove(devnode, devpath); + sysbus_send_remove(devname, devpath); } else { dbg("unknown action '%s'", action); retval = -EINVAL;