libudev-fbsd: add stubs for usbip
authorDaniel Golle <daniel@makrotopia.org>
Mon, 19 Jun 2017 16:32:23 +0000 (18:32 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 19 Jun 2017 18:49:40 +0000 (20:49 +0200)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
libs/libudev-fbsd/Makefile
libs/libudev-fbsd/patches/100-add-stub-udev_device_get_driver.patch [new file with mode: 0644]
libs/libudev-fbsd/patches/101-add-stub-udev_device_new_from_subsystem_sysname.patch [new file with mode: 0644]
libs/libudev-fbsd/patches/102-add-stub-udev_enumerate_add_nomatch_sysattr.patch [new file with mode: 0644]

index 8ef7120259c5dbd7100f93e1daaa15f5acf98b6c..e71f6bc88208b4bf7ec2e240b7ed3a78454e23ca 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=libudev-fbsd
 
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_VERSION:=20160820
 PKG_SOURCE_VERSION:=1f21323b817e70253d3c04bc8bedd61c477d0544
 
diff --git a/libs/libudev-fbsd/patches/100-add-stub-udev_device_get_driver.patch b/libs/libudev-fbsd/patches/100-add-stub-udev_device_get_driver.patch
new file mode 100644 (file)
index 0000000..aaa56f3
--- /dev/null
@@ -0,0 +1,25 @@
+--- a/src/libudev.c
++++ b/src/libudev.c
+@@ -130,6 +130,12 @@ udev_device_get_devnum(struct udev_devic
+ }
+ char const *
++udev_device_get_driver(struct udev_device *udev_device)
++{
++      return NULL;
++}
++
++char const *
+ udev_device_get_property_value(struct udev_device *dev, char const *property)
+ {
+       LOG("udev_device_get_property_value %s\n", property);
+--- a/src/libudev.h
++++ b/src/libudev.h
+@@ -30,6 +30,7 @@ struct udev_device *udev_device_new_from
+     struct udev *udev, char const *syspath);
+ struct udev_device *udev_device_new_from_devnum(
+     struct udev *udev, char type, dev_t devnum);
++char const *udev_device_get_driver(struct udev_device *udev_device);
+ char const *udev_device_get_syspath(struct udev_device *udev_device);
+ char const *udev_device_get_sysname(struct udev_device *udev_device);
+ char const *udev_device_get_subsystem(struct udev_device *udev_device);
diff --git a/libs/libudev-fbsd/patches/101-add-stub-udev_device_new_from_subsystem_sysname.patch b/libs/libudev-fbsd/patches/101-add-stub-udev_device_new_from_subsystem_sysname.patch
new file mode 100644 (file)
index 0000000..bc12d66
--- /dev/null
@@ -0,0 +1,72 @@
+--- a/src/libudev.c
++++ b/src/libudev.c
+@@ -26,6 +26,7 @@ struct udev_device {
+       struct udev *udev;
+       int refcount;
+       char syspath[32];
++      char sysfspath[64];
+       dev_t devnum;
+       char const *sysname;
+       char const *action;
+@@ -115,6 +116,29 @@ udev_device_new_from_devnum(struct udev
+       return NULL;
+ }
++struct udev_device *
++udev_device_new_from_subsystem_sysname(
++    struct udev *udev, const char *subsystem, const char *sysname)
++{
++      struct udev_device *u;
++      char sysfsname[64];
++      struct stat st;
++
++      snprintf(sysfsname, sizeof(sysfsname), "/sys/bus/%s/devices/%s/", subsystem, sysname);
++      if (stat(sysfsname, &st) == 0)
++      {
++              char sysfsdev[64];
++              u = calloc(1, sizeof(struct udev_device));
++              strncpy(u->sysfspath, sysfsname, sizeof(u->sysfspath));
++
++              return u;
++      }
++      else
++      {
++              return NULL;
++      }
++}
++
+ char const *
+ udev_device_get_devnode(struct udev_device *udev_device)
+ {
+@@ -132,6 +156,20 @@ udev_device_get_devnum(struct udev_devic
+ char const *
+ udev_device_get_driver(struct udev_device *udev_device)
+ {
++      if (udev_device->sysfspath)
++      {
++              char driverlnp[64];
++              char driverlnk[32];
++              snprintf(driverlnp, sizeof(driverlnp), "%s/driver",
++                       udev_device->sysfspath);
++              if (readlink(driverlnp, driverlnk, sizeof(driver)))
++              {
++                      char *drivernm;
++                      drivernm = strrchr(driverlnk, '/');
++                      if (drivernm)
++                              return ++drivernm;
++              }
++      }
+       return NULL;
+ }
+--- a/src/libudev.h
++++ b/src/libudev.h
+@@ -30,6 +30,8 @@ struct udev_device *udev_device_new_from
+     struct udev *udev, char const *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);
+ char const *udev_device_get_driver(struct udev_device *udev_device);
+ char const *udev_device_get_syspath(struct udev_device *udev_device);
+ char const *udev_device_get_sysname(struct udev_device *udev_device);
diff --git a/libs/libudev-fbsd/patches/102-add-stub-udev_enumerate_add_nomatch_sysattr.patch b/libs/libudev-fbsd/patches/102-add-stub-udev_enumerate_add_nomatch_sysattr.patch
new file mode 100644 (file)
index 0000000..86e6b96
--- /dev/null
@@ -0,0 +1,41 @@
+--- a/src/libudev.c
++++ b/src/libudev.c
+@@ -162,7 +162,7 @@ udev_device_get_driver(struct udev_devic
+               char driverlnk[32];
+               snprintf(driverlnp, sizeof(driverlnp), "%s/driver",
+                        udev_device->sysfspath);
+-              if (readlink(driverlnp, driverlnk, sizeof(driver)))
++              if (readlink(driverlnp, driverlnk, sizeof(driverlnk)))
+               {
+                       char *drivernm;
+                       drivernm = strrchr(driverlnk, '/');
+@@ -600,6 +600,18 @@ udev_enumerate_add_match_property(struct
+           value);
+       return -1;
+ }
++
++int
++udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate,
++    const char *sysattr, const char *value)
++{
++      (void)udev_enumerate;
++      (void)sysattr;
++      (void)value;
++      LOG("stub: udev_enumerate_add_nomatch_sysattr %s %s\n", sysattr,
++          value);
++      return -1;
++}
+ void
+ udev_enumerate_unref(struct udev_enumerate *udev_enumerate)
+--- a/src/libudev.h
++++ b/src/libudev.h
+@@ -59,6 +59,8 @@ int udev_enumerate_add_match_sysname(
+     struct udev_enumerate *udev_enumerate, char const *sysname);
+ int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate,
+     char const *property, char const *value);
++int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate,
++    const char *sysattr, const char *value);
+ void udev_enumerate_unref(struct udev_enumerate *udev_enumerate);
+ #define udev_list_entry_foreach(list_entry, first_entry)                      \