diff options
author | Daniel Golle <daniel@makrotopia.org> | 2017-06-30 17:20:22 +0200 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2017-06-30 17:25:24 +0200 |
commit | bdcb075fafdac0bfe3207c23f64acd58432bad86 (patch) | |
tree | beba215423fc6165ff30f760291fc26a9f0be543 | |
parent | ef2d4387ee99219f1ead6b4c4c19731d436de44b (diff) | |
download | fstools-bdcb075fafdac0bfe3207c23f64acd58432bad86.tar.gz |
libfstools: fix matching device name
compare strlen()+1 characters to make sure we match the trailing \0 as
well. Otherwise things get fishy when using lvm2, see this example:
/dev/mapper/data: UUID="xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx" MOUNT="/mnt" TYPE="LVM2_member"
/dev/mapper/data-fs: UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" LABEL="xxxxxxxx" VERSION="1.0" MOUNT="/mnt" TYPE="ext4"
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r-- | libfstools/find.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libfstools/find.c b/libfstools/find.c index 190fa81..fcc47a7 100644 --- a/libfstools/find.c +++ b/libfstools/find.c @@ -46,7 +46,6 @@ find_mount(char *mp) { FILE *fp = fopen("/proc/mounts", "r"); static char line[256]; - char *point = NULL; if(!fp) return NULL; @@ -75,7 +74,7 @@ find_mount(char *mp) fclose(fp); - return point; + return NULL; } /* @@ -184,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; |