From 3f72b427b44f39a1aec6806dad6f6b57103ae9ed Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 23 Apr 2015 13:23:03 +0200 Subject: path-util: make use of "mnt_id" field exported in /proc/self/fdinfo/ to test for mount points It's a very recent kernel addition, but certainly makes sense to support. --- src/test/test-path-util.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/test/test-path-util.c') diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index 55d75ae7a1..e5b9c28bc0 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -36,6 +36,8 @@ } static void test_path(void) { + _cleanup_close_ int fd = -1; + test_path_compare("/goo", "/goo", 0); test_path_compare("/goo", "/goo", 0); test_path_compare("//goo", "/goo", 0); @@ -89,9 +91,16 @@ static void test_path(void) { assert_se(path_is_mount_point("/", true) > 0); assert_se(path_is_mount_point("/", false) > 0); + fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY); + assert_se(fd >= 0); + assert_se(fd_is_mount_point(fd) > 0); + assert_se(path_is_mount_point("/proc", true) > 0); assert_se(path_is_mount_point("/proc", false) > 0); + assert_se(path_is_mount_point("/proc/1", true) == 0); + assert_se(path_is_mount_point("/proc/1", false) == 0); + assert_se(path_is_mount_point("/sys", true) > 0); assert_se(path_is_mount_point("/sys", false) > 0); -- cgit v1.2.3-54-g00ecf