libfstools: fix matching device name
[project/fstools.git] / libfstools / find.c
index 52bc51f130d0db9120659a79706d098cd0b4ea7f..fcc47a7dc1c10586d7e9f7f6ad79ddce2e5308bf 100644 (file)
@@ -15,6 +15,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <sys/sysmacros.h>
 
 #include "libfstools.h"
 
@@ -45,7 +46,6 @@ find_mount(char *mp)
 {
        FILE *fp = fopen("/proc/mounts", "r");
        static char line[256];
-       char *point = NULL;
 
        if(!fp)
                return NULL;
@@ -74,7 +74,7 @@ find_mount(char *mp)
 
        fclose(fp);
 
-       return point;
+       return NULL;
 }
 
 /*
@@ -183,7 +183,7 @@ find_mount_point(char *block, int root_only)
                devname = tmp;
 
                /* if device name matches */
-               if (!strncmp(block, devname, len)) {
+               if (!strncmp(block, devname, len + 1)) {
                        if (root_only && fs_rootfs_only(fstype))
                                break;