char *devnode;
char *subsystem;
struct udev_list_node devlinks_list;
+ int devlinks_uptodate;
struct udev_list_node properties_list;
char *envp[128];
int envp_uptodate;
return 0;
}
-static int device_read_uevent_file(struct udev_device *udev_device)
+int udev_device_read_uevent_file(struct udev_device *udev_device)
{
char filename[UTIL_PATH_SIZE];
FILE *f;
static void device_load_info(struct udev_device *device)
{
device->info_loaded = 1;
- device_read_uevent_file(device);
+ udev_device_read_uevent_file(device);
device_read_db(device);
}
void udev_device_cleanup_devlinks_list(struct udev_device *udev_device)
{
+ udev_device->devlinks_uptodate = 0;
udev_list_cleanup(udev_device->udev, &udev_device->devlinks_list);
}
return NULL;
if (!udev_device->info_loaded)
device_load_info(udev_device);
+ if (!udev_device->devlinks_uptodate) {
+ char symlinks[UTIL_PATH_SIZE];
+ struct udev_list_entry *list_entry;
+
+ udev_device->devlinks_uptodate = 1;
+ list_entry = udev_device_get_devlinks_list_entry(udev_device);
+ if (list_entry != NULL) {
+ util_strlcpy(symlinks, udev_list_entry_get_name(list_entry), sizeof(symlinks));
+ udev_list_entry_foreach(list_entry, udev_list_entry_get_next(list_entry)) {
+ util_strlcat(symlinks, " ", sizeof(symlinks));
+ util_strlcat(symlinks, udev_list_entry_get_name(list_entry), sizeof(symlinks));
+ }
+ udev_device_add_property(udev_device, "DEVLINKS", symlinks);
+ }
+ }
return udev_list_get_entry(&udev_device->properties_list);
}
{
free(udev_device->devnode);
udev_device->devnode = strdup(devnode);
+ if (devnode == NULL)
+ return 0;
if (udev_device->devnode == NULL)
return -ENOMEM;
udev_device_add_property(udev_device, "DEVNAME", udev_device->devnode);
int udev_device_add_devlink(struct udev_device *udev_device, const char *devlink)
{
- char symlinks[UTIL_PATH_SIZE];
- struct udev_list_entry *list_entry;
-
+ udev_device->devlinks_uptodate = 0;
if (udev_list_entry_add(udev_device->udev, &udev_device->devlinks_list, devlink, NULL, 1, 0) == NULL)
return -ENOMEM;
- list_entry = udev_device_get_devlinks_list_entry(udev_device);
- util_strlcpy(symlinks, udev_list_entry_get_name(list_entry), sizeof(symlinks));
- udev_list_entry_foreach(list_entry, udev_list_entry_get_next(list_entry)) {
- util_strlcat(symlinks, " ", sizeof(symlinks));
- util_strlcat(symlinks, udev_list_entry_get_name(list_entry), sizeof(symlinks));
- }
- udev_device_add_property(udev_device, "DEVLINKS", symlinks);
return 0;
}
extern struct udev_list_entry *udev_device_add_property(struct udev_device *udev_device, const char *key, const char *value);
extern struct udev_list_entry *udev_device_add_property_from_string(struct udev_device *udev_device, const char *property);
extern char **udev_device_get_properties_envp(struct udev_device *udev_device);
+extern int udev_device_read_uevent_file(struct udev_device *udev_device);
extern int udev_device_set_action(struct udev_device *udev_device, const char *action);
extern int udev_device_set_driver(struct udev_device *udev_device, const char *driver);
extern const char *udev_device_get_devpath_old(struct udev_device *udev_device);