chiark / gitweb /
util-lib: add new path_is_temporary_fs() API
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Dec 2016 18:39:50 +0000 (19:39 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:35 +0000 (17:58 +0200)
As simple wrapper around fd_is_temporary_fs().

src/basic/stat-util.c
src/basic/stat-util.h

index b62acdb7a164420435858f754a8a1bb2d6b9726d..0c3fbc8e1b3bf56300fa20422cb62cd556b67e98 100644 (file)
@@ -233,3 +233,13 @@ int fd_is_temporary_fs(int fd) {
 
         return is_temporary_fs(&s);
 }
+
+int path_is_temporary_fs(const char *path) {
+        _cleanup_close_ int fd = -1;
+
+        fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY);
+        if (fd < 0)
+                return -errno;
+
+        return fd_is_temporary_fs(fd);
+}
index 077bfdd50d1f019b47a611a0fc1910d06e32bc7d..168cb3cb531ed37ef58110604ba10893fe285649 100644 (file)
@@ -71,6 +71,7 @@ int path_check_fstype(const char *path, statfs_f_type_t magic_value);
 
 bool is_temporary_fs(const struct statfs *s) _pure_;
 int fd_is_temporary_fs(int fd);
+int path_is_temporary_fs(const char *path);
 
 /* Because statfs.t_type can be int on some architectures, we have to cast
  * the const magic to the type, otherwise the compiler warns about