From b59d06e6e8ef43e37dd568c2b5ae20d7b4b42433 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Mon, 15 Oct 2012 14:06:53 -0700 Subject: [PATCH] mount-encrypted: fix mount detection to use device Instead of fsid, which is unpopulated for tmpfs, use device number since that will increment for each different tmpfs. BUG=chrome-os-partner:15192 TEST=parrot build, manual testing BRANCH=none Change-Id: I0024f7283c90684daaf1278d3cf6b76cc85bb253 Signed-off-by: Kees Cook Reviewed-on: https://gerrit.chromium.org/gerrit/35615 Reviewed-by: Simon Glass Tested-by: Simon Glass Reviewed-by: Elly Jones --- utility/mount-helpers.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/utility/mount-helpers.c b/utility/mount-helpers.c index 29db21cf91..aed5ef0628 100644 --- a/utility/mount-helpers.c +++ b/utility/mount-helpers.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -99,17 +98,17 @@ int runcmd(const gchar *argv[], gchar **output) int same_vfs(const char *mnt_a, const char *mnt_b) { - struct statvfs stat_a, stat_b; + struct stat stat_a, stat_b; - if (statvfs(mnt_a, &stat_a)) { - PERROR("statvfs(%s)", mnt_a); + if (lstat(mnt_a, &stat_a)) { + PERROR("lstat(%s)", mnt_a); exit(1); } - if (statvfs(mnt_b, &stat_b)) { - PERROR("statvfs(%s)", mnt_b); + if (lstat(mnt_b, &stat_b)) { + PERROR("lstat(%s)", mnt_b); exit(1); } - return (stat_a.f_fsid == stat_b.f_fsid); + return (stat_a.st_dev == stat_b.st_dev); } /* Returns allocated string that holds [length]*2 + 1 characters. */