chiark / gitweb /
util-lib: rework path_check_fstype() and path_is_temporary_fs() to use O_PATH
authorLennart Poettering <lennart@poettering.net>
Tue, 20 Dec 2016 18:09:27 +0000 (19:09 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:35 +0000 (17:58 +0200)
Also, add tests to make sure this actually works as intended.

src/basic/stat-util.c

index 0c3fbc8e1b3bf56300fa20422cb62cd556b67e98..9dbdae0a0397d4df6fd9fa93da884e0da3285a20 100644 (file)
@@ -212,7 +212,7 @@ int fd_check_fstype(int fd, statfs_f_type_t magic_value) {
 int path_check_fstype(const char *path, statfs_f_type_t magic_value) {
         _cleanup_close_ int fd = -1;
 
-        fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY);
+        fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_PATH);
         if (fd < 0)
                 return -errno;
 
@@ -237,7 +237,7 @@ int fd_is_temporary_fs(int fd) {
 int path_is_temporary_fs(const char *path) {
         _cleanup_close_ int fd = -1;
 
-        fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY);
+        fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_PATH);
         if (fd < 0)
                 return -errno;