X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=device.c;h=1b0b50fd4e796752826d79a278c4d322c7430919;hb=81a2b7ceda7100fbc0dd8ce423b9599e03656851;hp=6eeae036249beaa7369a3d2932b232fbef3a7689;hpb=f94ea366d38fed424200b748cb042ca44f8c8d50;p=elogind.git diff --git a/device.c b/device.c index 6eeae0362..1b0b50fd4 100644 --- a/device.c +++ b/device.c @@ -1,5 +1,24 @@ /*-*- Mode: C; c-basic-offset: 8 -*-*/ +/*** + This file is part of systemd. + + Copyright 2010 Lennart Poettering + + systemd 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; either version 2 of the License, or + (at your option) any later version. + + systemd 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 systemd; If not, see . +***/ + #include #include #include @@ -68,7 +87,7 @@ static UnitActiveState device_active_state(Unit *u) { return state_translation_table[DEVICE(u)->state]; } -static int device_add_escaped_name(Unit *u, const char *prefix, const char *dn, bool make_id) { +static int device_add_escaped_name(Unit *u, const char *dn, bool make_id) { char *e; int r; @@ -76,7 +95,7 @@ static int device_add_escaped_name(Unit *u, const char *prefix, const char *dn, assert(dn); assert(dn[0] == '/'); - if (!(e = unit_name_escape_path(prefix, dn+1, ".device"))) + if (!(e = unit_name_escape_path(dn+1, ".device"))) return -ENOMEM; r = unit_add_name(u, e); @@ -118,7 +137,7 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u return -ENOMEM; assert(sysfs[0] == '/'); - if (!(e = unit_name_escape_path("sysfs-", sysfs+1, ".device"))) + if (!(e = unit_name_escape_path(sysfs+1, ".device"))) return -ENOMEM; if (!(u = manager_get_unit(m, e))) { @@ -143,9 +162,12 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u } if ((model = udev_device_get_property_value(dev, "ID_MODEL_FROM_DATABASE")) || - (model = udev_device_get_property_value(dev, "ID_MODEL"))) + (model = udev_device_get_property_value(dev, "ID_MODEL"))) { if ((r = unit_set_description(u, model)) < 0) goto fail; + } else if (dn) + if ((r = unit_set_description(u, dn)) < 0) + goto fail; unit_add_to_load_queue(u); } else { @@ -154,12 +176,12 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u } if (dn) - if ((r = device_add_escaped_name(u, "node-", dn, true)) < 0) + if ((r = device_add_escaped_name(u, dn, true)) < 0) goto fail; first = udev_device_get_devlinks_list_entry(dev); udev_list_entry_foreach(item, first) - if ((r = device_add_escaped_name(u, "node-", udev_list_entry_get_name(item), false)) < 0) + if ((r = device_add_escaped_name(u, udev_list_entry_get_name(item), false)) < 0) goto fail; if (names) { @@ -193,6 +215,8 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u device_set_state(DEVICE(u), DEVICE_AVAILABLE); } + unit_add_to_dbus_queue(u); + return 0; fail: @@ -231,7 +255,7 @@ static int device_process_removed_device(Manager *m, struct udev_device *dev) { return -ENOMEM; assert(sysfs[0] == '/'); - if (!(e = unit_name_escape_path("sysfs-", sysfs+1, ".device"))) + if (!(e = unit_name_escape_path(sysfs+1, ".device"))) return -ENOMEM; u = manager_get_unit(m, e);