-static void export_event_state(struct udev_event *event, enum event_state state)
-{
- char filename[UTIL_PATH_SIZE];
- char filename_failed[UTIL_PATH_SIZE];
- size_t start;
-
- /* location of queue file */
- snprintf(filename, sizeof(filename), "%s/.udev/queue/%llu",
- udev_get_dev_path(event->udev), udev_device_get_seqnum(event->dev));
-
- /* location of failed file */
- util_strlcpy(filename_failed, udev_get_dev_path(event->udev), sizeof(filename_failed));
- util_strlcat(filename_failed, "/", sizeof(filename_failed));
- start = util_strlcat(filename_failed, ".udev/failed/", sizeof(filename_failed));
- util_strlcat(filename_failed, udev_device_get_devpath(event->dev), sizeof(filename_failed));
- util_path_encode(&filename_failed[start], sizeof(filename_failed) - start);
-
- switch (state) {
- case EVENT_QUEUED:
- if(unlink(filename_failed) == 0)
- util_delete_path(event->udev, filename_failed);
- util_create_path(event->udev, filename);
- udev_selinux_setfscreatecon(event->udev, filename, S_IFLNK);
- symlink(udev_device_get_devpath(event->dev), filename);
- udev_selinux_resetfscreatecon(event->udev);
- break;
- case EVENT_FINISHED:
- if (udev_device_get_devpath_old(event->dev) != NULL) {
- /* "move" event - rename failed file to current name, do not delete failed */
- char filename_failed_old[UTIL_PATH_SIZE];
-
- util_strlcpy(filename_failed_old, udev_get_dev_path(event->udev), sizeof(filename_failed_old));
- util_strlcat(filename_failed_old, "/", sizeof(filename_failed_old));
- start = util_strlcat(filename_failed_old, ".udev/failed/", sizeof(filename_failed_old));
- util_strlcat(filename_failed_old, udev_device_get_devpath_old(event->dev), sizeof(filename_failed_old));
- util_path_encode(&filename_failed_old[start], sizeof(filename) - start);
-
- if (rename(filename_failed_old, filename_failed) == 0)
- info(event->udev, "renamed devpath, moved failed state of '%s' to %s'\n",
- udev_device_get_devpath_old(event->dev), udev_device_get_devpath(event->dev));
- } else {
- if (unlink(filename_failed) == 0)
- util_delete_path(event->udev, filename_failed);
- }