Lines Matching refs:dev

56 UdevEvent *udev_event_new(sd_device *dev, usec_t exec_delay_usec, sd_netlink *rtnl, int log_level) {  in udev_event_new()  argument
59 assert(dev); in udev_event_new()
66 .dev = sd_device_ref(dev), in udev_event_new()
84 sd_device_unref(event->dev); in udev_event_free()
244 sd_device *parent, *dev = event->dev; in udev_event_subst_format() local
252 r = sd_device_get_devpath(dev, &val); in udev_event_subst_format()
258 r = sd_device_get_sysname(dev, &val); in udev_event_subst_format()
264 r = sd_device_get_sysnum(dev, &val); in udev_event_subst_format()
293 r = sd_device_get_devnum(dev, &devnum); in udev_event_subst_format()
330 log_device_debug(dev, "requested part of result string not found"); in udev_event_subst_format()
360 … (void) device_get_sysattr_value_maybe_from_netlink(dev, &event->rtnl, attr, &val); in udev_event_subst_format()
363 if (!val && event->dev_parent && event->dev_parent != dev) in udev_event_subst_format()
375 log_device_debug(dev, "%i character(s) replaced", count); in udev_event_subst_format()
381 r = sd_device_get_parent(dev, &parent); in udev_event_subst_format()
394 r = sd_device_get_devname(dev, &val); in udev_event_subst_format()
404 else if (sd_device_get_devname(dev, &val) >= 0) in udev_event_subst_format()
407 r = sd_device_get_sysname(dev, &val); in udev_event_subst_format()
414 FOREACH_DEVICE_DEVLINK(dev, val) { in udev_event_subst_format()
434 r = sd_device_get_property_value(dev, attr, &val); in udev_event_subst_format()
471 assert(event->dev); in udev_event_apply_format()
484 … log_device_warning_errno(event->dev, r, "Invalid format string, ignoring: %s", src); in udev_event_apply_format()
499 log_device_warning_errno(event->dev, subst_len, in udev_event_apply_format()
783 assert(event->dev); in udev_event_spawn()
789 return log_device_error_errno(event->dev, errno, in udev_event_spawn()
794 return log_device_error_errno(event->dev, errno, in udev_event_spawn()
799 return log_device_error_errno(event->dev, r, "Failed to split command: %m"); in udev_event_spawn()
802 return log_device_error_errno(event->dev, SYNTHETIC_ERRNO(EINVAL), in udev_event_spawn()
816 r = device_get_properties_strv(event->dev, &envp); in udev_event_spawn()
818 return log_device_error_errno(event->dev, r, "Failed to get device properties"); in udev_event_spawn()
820 log_device_debug(event->dev, "Starting '%s'", cmd); in udev_event_spawn()
824 return log_device_error_errno(event->dev, r, in udev_event_spawn()
833 DEVICE_TRACE_POINT(spawn_exec, event->dev, cmd); in udev_event_spawn()
844 .device = event->dev, in udev_event_spawn()
859 return log_device_error_errno(event->dev, r, in udev_event_spawn()
873 sd_device *dev; in rename_netif() local
882 dev = ASSERT_PTR(event->dev); in rename_netif()
888 return log_device_error_errno(dev, r, "Failed to get sysname: %m"); in rename_netif()
893 if (!device_for_action(dev, SD_DEVICE_ADD)) in rename_netif()
896 r = sd_device_get_ifindex(dev, &ifindex); in rename_netif()
900 return log_device_error_errno(dev, r, "Failed to get ifindex: %m"); in rename_netif()
904 … log_device_warning(dev, "Invalid network interface name, ignoring: %s", event->name); in rename_netif()
910 return log_device_warning_errno(dev, r, "Failed to get link flags: %m"); in rename_netif()
913 … log_device_info(dev, "Network interface '%s' is already up, refusing to rename to '%s'.", in rename_netif()
919 r = device_add_property(dev, "ID_RENAMING", "1"); in rename_netif()
921 return log_device_warning_errno(dev, r, "Failed to add 'ID_RENAMING' property: %m"); in rename_netif()
923 r = device_rename(dev, event->name); in rename_netif()
925 …return log_device_warning_errno(dev, r, "Failed to update properties with new name '%s': %m", even… in rename_netif()
940 …return log_device_error_errno(dev, r, "Failed to rename network interface %i from '%s' to '%s': %m… in rename_netif()
943 …log_device_debug(dev, "Network interface %i is renamed from '%s' to '%s'", ifindex, oldname, event… in rename_netif()
949 sd_device *dev = event->dev; in update_devnode() local
952 r = sd_device_get_devnum(dev, NULL); in update_devnode()
956 return log_device_error_errno(dev, r, "Failed to get devnum: %m"); in update_devnode()
959 r = device_get_devnode_uid(dev, &event->uid); in update_devnode()
961 return log_device_error_errno(dev, r, "Failed to get devnode UID: %m"); in update_devnode()
965 r = device_get_devnode_gid(dev, &event->gid); in update_devnode()
967 return log_device_error_errno(dev, r, "Failed to get devnode GID: %m"); in update_devnode()
971 r = device_get_devnode_mode(dev, &event->mode); in update_devnode()
973 return log_device_error_errno(dev, r, "Failed to get devnode mode: %m"); in update_devnode()
976 bool apply_mac = device_for_action(dev, SD_DEVICE_ADD); in update_devnode()
978 …r = udev_node_apply_permissions(dev, apply_mac, event->mode, event->uid, event->gid, event->seclab… in update_devnode()
980 return log_device_error_errno(dev, r, "Failed to apply devnode permissions: %m"); in update_devnode()
982 return udev_node_update(dev, event->dev_db_clone); in update_devnode()
993 sd_device *dev = event->dev; in event_execute_rules_on_remove() local
996 r = device_read_db_internal(dev, true); in event_execute_rules_on_remove()
998 log_device_debug_errno(dev, r, "Failed to read database under /run/udev/data/: %m"); in event_execute_rules_on_remove()
1000 r = device_tag_index(dev, NULL, false); in event_execute_rules_on_remove()
1002 …log_device_debug_errno(dev, r, "Failed to remove corresponding tag files under /run/udev/tag/, ign… in event_execute_rules_on_remove()
1004 r = device_delete_db(dev); in event_execute_rules_on_remove()
1006 … log_device_debug_errno(dev, r, "Failed to delete database under /run/udev/data/, ignoring: %m"); in event_execute_rules_on_remove()
1008 (void) udev_watch_end(inotify_fd, dev); in event_execute_rules_on_remove()
1012 if (sd_device_get_devnum(dev, NULL) >= 0) in event_execute_rules_on_remove()
1013 (void) udev_node_remove(dev); in event_execute_rules_on_remove()
1018 static int udev_event_on_move(sd_device *dev) { in udev_event_on_move() argument
1022 r = device_add_property(dev, "ID_RENAMING", NULL); in udev_event_on_move()
1024 … return log_device_debug_errno(dev, r, "Failed to remove 'ID_RENAMING' property: %m"); in udev_event_on_move()
1056 sd_device *dev; in udev_event_execute_rules() local
1062 dev = event->dev; in udev_event_execute_rules()
1064 r = sd_device_get_action(dev, &action); in udev_event_execute_rules()
1066 return log_device_error_errno(dev, r, "Failed to get ACTION: %m"); in udev_event_execute_rules()
1072 (void) udev_watch_end(inotify_fd, event->dev); in udev_event_execute_rules()
1074 r = device_clone_with_db(dev, &event->dev_db_clone); in udev_event_execute_rules()
1076 return log_device_debug_errno(dev, r, "Failed to clone sd_device object: %m"); in udev_event_execute_rules()
1078 r = copy_all_tags(dev, event->dev_db_clone); in udev_event_execute_rules()
1080 … log_device_warning_errno(dev, r, "Failed to copy all tags from old database entry, ignoring: %m"); in udev_event_execute_rules()
1083 r = udev_event_on_move(event->dev); in udev_event_execute_rules()
1088 DEVICE_TRACE_POINT(rules_start, dev); in udev_event_execute_rules()
1092 return log_device_debug_errno(dev, r, "Failed to apply udev rules: %m"); in udev_event_execute_rules()
1094 DEVICE_TRACE_POINT(rules_finished, dev); in udev_event_execute_rules()
1105 r = device_ensure_usec_initialized(dev, event->dev_db_clone); in udev_event_execute_rules()
1107 return log_device_debug_errno(dev, r, "Failed to set initialization timestamp: %m"); in udev_event_execute_rules()
1110 r = device_tag_index(dev, event->dev_db_clone, true); in udev_event_execute_rules()
1112 … return log_device_debug_errno(dev, r, "Failed to update tags under /run/udev/tag/: %m"); in udev_event_execute_rules()
1114 r = device_update_db(dev); in udev_event_execute_rules()
1116 … return log_device_debug_errno(dev, r, "Failed to update database under /run/udev/data/: %m"); in udev_event_execute_rules()
1118 device_set_is_initialized(dev); in udev_event_execute_rules()
1132 log_device_debug(event->dev, "Running built-in command \"%s\"", command); in udev_event_execute_run()
1133 r = udev_builtin_run(event->dev, &event->rtnl, builtin_cmd, command, false); in udev_event_execute_run()
1135 …log_device_debug_errno(event->dev, r, "Failed to run built-in command \"%s\", ignoring: %m", comma… in udev_event_execute_run()
1138 log_device_debug(event->dev, "Delaying execution of \"%s\" for %s.", in udev_event_execute_run()
1143 log_device_debug(event->dev, "Running command \"%s\"", command); in udev_event_execute_run()
1147 … log_device_warning_errno(event->dev, r, "Failed to execute '%s', ignoring: %m", command); in udev_event_execute_run()
1149 … log_device_debug(event->dev, "Command \"%s\" returned %d (error), ignoring.", command, r); in udev_event_execute_run()
1155 sd_device *dev; in udev_event_process_inotify_watch() local
1160 dev = event->dev; in udev_event_process_inotify_watch()
1162 assert(dev); in udev_event_process_inotify_watch()
1164 if (device_for_action(dev, SD_DEVICE_REMOVE)) in udev_event_process_inotify_watch()
1168 (void) udev_watch_begin(inotify_fd, dev); in udev_event_process_inotify_watch()
1170 (void) udev_watch_end(inotify_fd, dev); in udev_event_process_inotify_watch()