From 9315b3d16fe2fd451414095a5829786f42d1fb23 Mon Sep 17 00:00:00 2001 From: Ian Stakenvicius Date: Tue, 2 Apr 2013 15:59:28 -0400 Subject: [PATCH] Add support for legacy behaviour in udev_device_get_sysattr_value() Wraps the changes made in systemd commits 5ae18ddc and 53726349 with a #if's on LIBUDEV_LEGACY_VERSION so that old behaviour can be chosen at build-time if users find it necessary to support legacy software dependent on the original behaviour Original Authors: Kay Sievers Signed-off-by: Ian Stakenvicius Signed-off-by: Anthony G. Basile --- src/libudev/Makefile.am | 1 + src/libudev/libudev-device.c | 11 +++++++++++ src/libudev/libudev.h | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/src/libudev/Makefile.am b/src/libudev/Makefile.am index f49799505..98d6e4e0f 100644 --- a/src/libudev/Makefile.am +++ b/src/libudev/Makefile.am @@ -18,6 +18,7 @@ AM_CPPFLAGS = \ -include $(top_builddir)/config.h \ -DUDEV_CONF_FILE=\"$(udevconffile)\" \ -DUDEV_HWDB_BIN=\"$(udevhwdbbin)\" \ + -DUDEV_VERSION=$(UDEV_VERSION) \ -I $(top_srcdir)/src/udev lib_LTLIBRARIES = \ diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index aa82507e9..3c9783ffd 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -1381,7 +1381,9 @@ _public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_devi } if (S_ISLNK(statbuf.st_mode)) { +#if LIBUDEV_LEGACY_VERSION < 199 struct udev_device *dev; +#endif /* * Some core links return only the last element of the target path, @@ -1398,6 +1400,11 @@ _public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_devi goto out; } +#if LIBUDEV_LEGACY_VERSION < 199 +#if LIBUDEV_LEGACY_VERSION >= 196 + /* resolve only custom link to a device */ + if (!streq(sysattr, "device")) { +#endif /* resolve link to a device and return its syspath */ util_strscpyl(path, sizeof(path), udev_device->syspath, "/", sysattr, NULL); dev = udev_device_new_from_syspath(udev_device->udev, path); @@ -1407,6 +1414,10 @@ _public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_devi val = udev_list_entry_get_value(list_entry); udev_device_unref(dev); } +#if LIBUDEV_LEGACY_VERSION >= 196 + } +#endif +#endif goto out; } diff --git a/src/libudev/libudev.h b/src/libudev/libudev.h index 61567b1d6..e54c5bf67 100644 --- a/src/libudev/libudev.h +++ b/src/libudev/libudev.h @@ -20,6 +20,10 @@ #ifndef _LIBUDEV_H_ #define _LIBUDEV_H_ +#ifndef LIBUDEV_LEGACY_VERSION +#define LIBUDEV_LEGACY_VERSION UDEV_VERSION +#endif + #include #include #include