int refcount;
struct udev *udev;
struct udev_device *parent_device;
+ int parent_set;
char *syspath;
const char *devpath;
char *sysname;
{
if (udev_device == NULL)
return NULL;
-
- if (udev_device->parent_device != NULL) {
- info(udev_device->udev, "returning existing parent %p\n", udev_device->parent_device);
- return udev_device->parent_device;
+ if (!udev_device->parent_set) {
+ udev_device->parent_set = 1;
+ udev_device->parent_device = device_new_from_parent(udev_device);
}
- udev_device->parent_device = device_new_from_parent(udev_device);
+ if (udev_device->parent_device != NULL)
+ info(udev_device->udev, "returning existing parent %p\n", udev_device->parent_device);
return udev_device->parent_device;
}
udev_device->action = strdup(action);
if (udev_device->action == NULL)
return -ENOMEM;
- udev_device_add_property(udev_device, "ACTION", action);
+ udev_device_add_property(udev_device, "ACTION", udev_device->action);
return 0;
}
if (udev_device->driver == NULL)
return -ENOMEM;
udev_device->driver_set = 1;
+ udev_device_add_property(udev_device, "DRIVER", udev_device->driver);
return 0;
}
udev_device->devpath_old = strdup(devpath_old);
if (udev_device->devpath_old == NULL)
return -ENOMEM;
+ udev_device_add_property(udev_device, "DEVPATH_OLD", udev_device->devpath_old);
return 0;
}
int udev_device_set_seqnum(struct udev_device *udev_device, unsigned long long int seqnum)
{
+ char num[32];
+
udev_device->seqnum = seqnum;
+ snprintf(num, sizeof(num), "%llu", seqnum);
+ udev_device_add_property(udev_device, "SEQNUM", num);
return 0;
}
int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum)
{
+ char num[32];
+
udev_device->devnum = devnum;
+
+ snprintf(num, sizeof(num), "%u", major(devnum));
+ udev_device_add_property(udev_device, "MAJOR", num);
+ snprintf(num, sizeof(num), "%u", minor(devnum));
+ udev_device_add_property(udev_device, "MINOR", num);
return 0;
}
char buf[4096];
size_t bufpos;
int devpath_set = 0;
+ int subsystem_set = 0;
+ int action_set = 0;
int maj = 0;
int min = 0;
devpath_set = 1;
} else if (strncmp(key, "SUBSYSTEM=", 10) == 0) {
udev_device_set_subsystem(udev_device, &key[10]);
+ subsystem_set = 1;
} else if (strncmp(key, "DEVNAME=", 8) == 0) {
udev_device_set_devnode(udev_device, &key[8]);
} else if (strncmp(key, "DEVLINKS=", 9) == 0) {
udev_device_set_driver(udev_device, &key[7]);
} else if (strncmp(key, "ACTION=", 7) == 0) {
udev_device_set_action(udev_device, &key[7]);
+ action_set = 1;
} else if (strncmp(key, "MAJOR=", 6) == 0) {
maj = strtoull(&key[6], NULL, 10);
} else if (strncmp(key, "MINOR=", 6) == 0) {
udev_device_set_seqnum(udev_device, strtoull(&key[7], NULL, 10));
} else if (strncmp(key, "TIMEOUT=", 8) == 0) {
udev_device_set_timeout(udev_device, strtoull(&key[8], NULL, 10));
- }
- if (strncmp(key, "PHYSDEV", 7) == 0)
+ } else if (strncmp(key, "PHYSDEV", 7) == 0) {
+ /* skip deprecated values */
continue;
- udev_device_add_property_from_string(udev_device, key);
+ } else {
+ udev_device_add_property_from_string(udev_device, key);
+ }
}
- if (!devpath_set) {
+ if (!devpath_set || !subsystem_set || !action_set) {
+ info(udev_monitor->udev, "missing values, skip\n");
udev_device_unref(udev_device);
return NULL;
}