From 7173310c26bf4a7d487d020dbcc87acf0b6415d1 Mon Sep 17 00:00:00 2001 From: Tony Butler Date: Sat, 27 Feb 2010 08:22:13 +0000 Subject: [PATCH] =?utf8?q?sysfsutils:=20separate=20libsysfs=20and=20sysfsu?= =?utf8?q?tils=20and=20move=20to=20libs,=20add=20patch=20-=20thanks=20Raph?= =?utf8?q?a=C3=ABl?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit SVN-Revision: 19881 --- {utils => libs}/sysfsutils/Makefile | 35 ++++++++++-- .../patches/200-mnt_path_check.patch | 55 +++++++++++++++++++ 2 files changed, 84 insertions(+), 6 deletions(-) rename {utils => libs}/sysfsutils/Makefile (55%) create mode 100644 libs/sysfsutils/patches/200-mnt_path_check.patch diff --git a/utils/sysfsutils/Makefile b/libs/sysfsutils/Makefile similarity index 55% rename from utils/sysfsutils/Makefile rename to libs/sysfsutils/Makefile index e9807b09c..70d3388a5 100644 --- a/utils/sysfsutils/Makefile +++ b/libs/sysfsutils/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sysfsutils PKG_VERSION:=2.1.0 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/linux-diag @@ -20,27 +20,50 @@ PKG_INSTALL:=1 include $(INCLUDE_DIR)/package.mk +define Package/libsysfs + SECTION:=libs + CATEGORY:=Libraries + SUBMENU:=Filesystem + DEPENDS:=@LINUX_2_6 + TITLE:=Sysfs library + URL:=http://linux-diag.sourceforge.net/Sysfsutils.html +endef + define Package/sysfsutils SECTION:=utils CATEGORY:=Utilities SUBMENU:=Filesystem - DEPENDS:=@LINUX_2_6 - TITLE:=sysfs Utilities + DEPENDS:=@LINUX_2_6 +libsysfs + TITLE:=System Utilities Based on Sysfs URL:=http://linux-diag.sourceforge.net/Sysfsutils.html endef +define Package/libsysfs/description +The library's purpose is to provide a consistant and stable interface for +querying system device information exposed through sysfs. +endef + +define Package/sysfsutils/description +A utility built upon libsysfs that lists devices by bus, class, and topology. +endef + define Build/InstallDev $(INSTALL_DIR) $(1)/usr/include $(CP) $(PKG_INSTALL_DIR)/usr/include/sysfs $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsysfs.{a,so*} $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsysfs.{a,so*,la} $(1)/usr/lib/ +endef + +define Package/libsysfs/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsysfs.so* $(1)/usr/lib/ endef define Package/sysfsutils/install $(INSTALL_DIR) $(1)/usr/bin $(CP) $(PKG_INSTALL_DIR)/usr/bin/systool $(1)/usr/bin/ - $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsysfs.so.* $(1)/usr/lib/ endef +$(eval $(call BuildPackage,libsysfs)) $(eval $(call BuildPackage,sysfsutils)) diff --git a/libs/sysfsutils/patches/200-mnt_path_check.patch b/libs/sysfsutils/patches/200-mnt_path_check.patch new file mode 100644 index 000000000..8710578c5 --- /dev/null +++ b/libs/sysfsutils/patches/200-mnt_path_check.patch @@ -0,0 +1,55 @@ +--- a/lib/sysfs_utils.c ++++ b/lib/sysfs_utils.c +@@ -22,6 +22,7 @@ + */ + #include "libsysfs.h" + #include "sysfs.h" ++#include + + /** + * sysfs_remove_trailing_slash: Removes any trailing '/' in the given path +@@ -53,6 +54,9 @@ int sysfs_get_mnt_path(char *mnt_path, s + { + static char sysfs_path[SYSFS_PATH_MAX] = ""; + const char *sysfs_path_env; ++ FILE *mnt; ++ struct mntent *mntent; ++ int ret; + + if (len == 0 || mnt_path == NULL) + return -1; +@@ -64,12 +68,31 @@ int sysfs_get_mnt_path(char *mnt_path, s + if (sysfs_path_env != NULL) { + safestrcpymax(mnt_path, sysfs_path_env, len); + sysfs_remove_trailing_slash(mnt_path); +- return 0; ++ } else { ++ safestrcpymax(mnt_path, SYSFS_MNT_PATH, len); + } +- safestrcpymax(mnt_path, SYSFS_MNT_PATH, len); + } + +- return 0; ++ /* check that mount point is indeed mounted */ ++ ret = -1; ++ if ((mnt = setmntent(SYSFS_PROC_MNTS, "r")) == NULL) { ++ dprintf("Error getting mount information\n"); ++ return -1; ++ } ++ while ((mntent = getmntent(mnt)) != NULL) { ++ if (strcmp(mntent->mnt_type, SYSFS_FSTYPE_NAME) == 0 && ++ strcmp(mntent->mnt_dir, mnt_path) == 0) { ++ ret = 0; ++ break; ++ } ++ } ++ ++ endmntent(mnt); ++ ++ if (ret < 0) ++ errno = ENOENT; ++ ++ return ret; + } + + /** -- 2.30.2