From e8568a4e672014cf8336643e5a949f038d46a90b Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 19 Jun 2017 18:32:23 +0200 Subject: [PATCH] libudev-fbsd: add stubs for usbip Signed-off-by: Daniel Golle --- libs/libudev-fbsd/Makefile | 2 +- .../100-add-stub-udev_device_get_driver.patch | 25 +++++++ ...ev_device_new_from_subsystem_sysname.patch | 72 +++++++++++++++++++ ...b-udev_enumerate_add_nomatch_sysattr.patch | 41 +++++++++++ 4 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 libs/libudev-fbsd/patches/100-add-stub-udev_device_get_driver.patch create mode 100644 libs/libudev-fbsd/patches/101-add-stub-udev_device_new_from_subsystem_sysname.patch create mode 100644 libs/libudev-fbsd/patches/102-add-stub-udev_enumerate_add_nomatch_sysattr.patch diff --git a/libs/libudev-fbsd/Makefile b/libs/libudev-fbsd/Makefile index 8ef712025..e71f6bc88 100644 --- a/libs/libudev-fbsd/Makefile +++ b/libs/libudev-fbsd/Makefile @@ -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 index 000000000..aaa56f3cf --- /dev/null +++ b/libs/libudev-fbsd/patches/100-add-stub-udev_device_get_driver.patch @@ -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 index 000000000..bc12d66a6 --- /dev/null +++ b/libs/libudev-fbsd/patches/101-add-stub-udev_device_new_from_subsystem_sysname.patch @@ -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 index 000000000..86e6b96cd --- /dev/null +++ b/libs/libudev-fbsd/patches/102-add-stub-udev_enumerate_add_nomatch_sysattr.patch @@ -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) \