1 --- a/lib/sysfs_utils.c
2 +++ b/lib/sysfs_utils.c
10 * sysfs_remove_trailing_slash: Removes any trailing '/' in the given path
11 @@ -53,6 +54,9 @@ int sysfs_get_mnt_path(char *mnt_path, s
13 static char sysfs_path[SYSFS_PATH_MAX] = "";
14 const char *sysfs_path_env;
16 + struct mntent *mntent;
19 if (len == 0 || mnt_path == NULL)
21 @@ -64,12 +68,31 @@ int sysfs_get_mnt_path(char *mnt_path, s
22 if (sysfs_path_env != NULL) {
23 safestrcpymax(mnt_path, sysfs_path_env, len);
24 sysfs_remove_trailing_slash(mnt_path);
27 + safestrcpymax(mnt_path, SYSFS_MNT_PATH, len);
29 - safestrcpymax(mnt_path, SYSFS_MNT_PATH, len);
33 + /* check that mount point is indeed mounted */
35 + if ((mnt = setmntent(SYSFS_PROC_MNTS, "r")) == NULL) {
36 + dprintf("Error getting mount information\n");
39 + while ((mntent = getmntent(mnt)) != NULL) {
40 + if (strcmp(mntent->mnt_type, SYSFS_FSTYPE_NAME) == 0 &&
41 + strcmp(mntent->mnt_dir, mnt_path) == 0) {