X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev%2Flib%2Flibudev-device-db-write.c;h=11e0ab5f60daaf6bc3892376405fe6a2629882a1;hp=34095e5682303c08dd102ffe4287971a79e8301d;hb=c2de781ef0684e2f90760301da402b571bb38b9e;hpb=54808d77a3a62172fc6acbeec968be67c207509e diff --git a/udev/lib/libudev-device-db-write.c b/udev/lib/libudev-device-db-write.c index 34095e568..11e0ab5f6 100644 --- a/udev/lib/libudev-device-db-write.c +++ b/udev/lib/libudev-device-db-write.c @@ -56,11 +56,21 @@ int udev_device_update_db(struct udev_device *udev_device) udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) if (udev_list_entry_get_flag(list_entry)) goto file; - if (udev_device_get_num_fake_partitions(udev_device)) + if (udev_device_get_num_fake_partitions(udev_device) != 0) goto file; if (udev_device_get_ignore_remove(udev_device)) goto file; - /* try not to waste tmpfs memory; store values, if they fit, in a symlink target */ + if (udev_device_get_devlink_priority(udev_device) != 0) + goto file; + if (udev_device_get_event_timeout(udev_device) >= 0) + goto file; + if (udev_device_get_devnode(udev_device) == NULL) + goto out; + + /* + * if we have only the node and symlinks to store, try not to waste + * tmpfs memory -- store values, if they fit, in a symlink target + */ util_strlcpy(target, &udev_device_get_devnode(udev_device)[devlen], sizeof(target)); udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(udev_device)) { size_t len; @@ -86,9 +96,11 @@ file: } info(udev, "created db file for '%s' in '%s'\n", udev_device_get_devpath(udev_device), filename); - fprintf(f, "N:%s\n", &udev_device_get_devnode(udev_device)[devlen]); - udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(udev_device)) - fprintf(f, "S:%s\n", &udev_list_entry_get_name(list_entry)[devlen]); + if (udev_device_get_devnode(udev_device) != NULL) { + fprintf(f, "N:%s\n", &udev_device_get_devnode(udev_device)[devlen]); + udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(udev_device)) + fprintf(f, "S:%s\n", &udev_list_entry_get_name(list_entry)[devlen]); + } if (udev_device_get_devlink_priority(udev_device) != 0) fprintf(f, "L:%u\n", udev_device_get_devlink_priority(udev_device)); if (udev_device_get_event_timeout(udev_device) >= 0)