summaryrefslogtreecommitdiff
path: root/rootdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'rootdev.c')
-rw-r--r--rootdev.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/rootdev.c b/rootdev.c
index 82e423f..f0de1ff 100644
--- a/rootdev.c
+++ b/rootdev.c
@@ -357,10 +357,11 @@ int rootdev_get_path(char *path, size_t size, const char *device,
if (path_len != strlen(dev_path) + 1 + strlen(device))
return -1;
- // TODO(bsimonnet): We should check that |path| exists and is the right
- // device. We don't do this currently as OEMs can add custom SELinux rules
- // which may prevent us from accessing this.
- // See b/24267261.
+ if (stat(path, &dev_statbuf) != 0)
+ return 1;
+
+ if (dev && dev != dev_statbuf.st_rdev)
+ return 2;
return 0;
}