diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2012-10-19 10:22:11 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2012-10-19 10:22:11 +0000 |
commit | 1fa959e6fc5ebb5261b798c8c345df656f8284bc (patch) | |
tree | 2f2c3b11f1ba0640ccee05aca623ac2587594bf0 /package/libs/sysfsutils/patches | |
parent | 7ffb214ff9299a41dd1599037607f92b3ff2768e (diff) | |
download | master-187ad058-1fa959e6fc5ebb5261b798c8c345df656f8284bc.tar.gz master-187ad058-1fa959e6fc5ebb5261b798c8c345df656f8284bc.tar.bz2 master-187ad058-1fa959e6fc5ebb5261b798c8c345df656f8284bc.zip |
sysfsutils: move to the correct directory
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@33856 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/libs/sysfsutils/patches')
-rw-r--r-- | package/libs/sysfsutils/patches/200-mnt_path_check.patch | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/package/libs/sysfsutils/patches/200-mnt_path_check.patch b/package/libs/sysfsutils/patches/200-mnt_path_check.patch new file mode 100644 index 0000000000..8710578c5b --- /dev/null +++ b/package/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 <mntent.h> + + /** + * 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; + } + + /** |