]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
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)
committerLennart Poettering <lennart@poettering.net>
Tue, 20 Dec 2016 19:00:09 +0000 (20:00 +0100)
As simple wrapper around fd_is_temporary_fs().

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

index 848572687e2201802e3466a30a289b10976e5d2a..ac5db71022934ea7a351798b3d820a22216232f7 100644 (file)
@@ -224,3 +224,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 56d28f791e3d0c99d32853860879d12f1db745dd..5d571efe186fb43f394282f72018522776e23404 100644 (file)
@@ -61,6 +61,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