Commits

Anonymous committed 8df149d

udev: export udev_device_new_from_device_id()

  • Participants
  • Parent commits 3f4cdb9

Comments (0)

Files changed (6)

src/libudev-device.c

         return udev_device_new_from_syspath(udev, path);
 }
 
-struct udev_device *udev_device_new_from_id_filename(struct udev *udev, char *id)
+/**
+ * udev_device_new_from_device_id:
+ * @udev: udev library context
+ * @id: text string identifying a kernel device
+ *
+ * Create new udev device, and fill in information from the sys
+ * device and the udev database entry. The device is looked-up
+ * by a special string:
+ *   b8:2          - block device major:minor
+ *   c128:1        - char device major:minor
+ *   n3            - network device ifindex
+ *   +sound:card29 - kernel driver core subsystem:device name
+ *
+ * The initial refcount is 1, and needs to be decremented to
+ * release the resources of the udev device.
+ *
+ * Returns: a new udev device, or #NULL, if it does not exist
+ **/
+UDEV_EXPORT struct udev_device *udev_device_new_from_device_id(struct udev *udev, char *id)
 {
         char type;
         int maj, min;

src/libudev-enumerate.c

                         if (dent->d_name[0] == '.')
                                 continue;
 
-                        dev = udev_device_new_from_id_filename(udev_enumerate->udev, dent->d_name);
+                        dev = udev_device_new_from_device_id(udev_enumerate->udev, dent->d_name);
                         if (dev == NULL)
                                 continue;
 

src/libudev-private.h

 
 /* libudev-device.c */
 struct udev_device *udev_device_new(struct udev *udev);
-struct udev_device *udev_device_new_from_id_filename(struct udev *udev, char *id);
 mode_t udev_device_get_devnode_mode(struct udev_device *udev_device);
 int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath);
 int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode);
 struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath);
 struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum);
 struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname);
+struct udev_device *udev_device_new_from_device_id(struct udev *udev, char *id);
 struct udev_device *udev_device_new_from_environment(struct udev *udev);
 /* udev_device_get_parent_*() does not take a reference on the returned device, it is automatically unref'd with the parent */
 struct udev_device *udev_device_get_parent(struct udev_device *udev_device);
                 if (strcmp(dent->d_name, udev_device_get_id_filename(dev)) == 0)
                         continue;
 
-                dev_db = udev_device_new_from_id_filename(udev, dent->d_name);
+                dev_db = udev_device_new_from_device_id(udev, dent->d_name);
                 if (dev_db != NULL) {
                         const char *devnode;
 
                                 goto unlink;
                         s[len] = '\0';
 
-                        dev = udev_device_new_from_id_filename(udev, s);
+                        dev = udev_device_new_from_device_id(udev, s);
                         if (dev == NULL)
                                 goto unlink;
 
                 return NULL;
         s[len] = '\0';
 
-        return udev_device_new_from_id_filename(udev, s);
+        return udev_device_new_from_device_id(udev, s);
 }