summaryrefslogtreecommitdiff
path: root/src/basic/stat-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-02-08 17:14:37 +0100
committerLennart Poettering <lennart@poettering.net>2018-02-12 11:07:55 +0100
commit77f9fa3b8ea46c27e5a5e9270f71bf1b4000c3e0 (patch)
treee255deb1ac4c7aed5f8bf2c3d3412b47154dc38d /src/basic/stat-util.c
parentb8e2400586452499131ff5ab1edb60c1dfbcf92b (diff)
downloadsystemd-77f9fa3b8ea46c27e5a5e9270f71bf1b4000c3e0.tar.gz
journal: move code that checks for network fs to stat-util.[ch]
We have similar code in stat-util.[ch] and managing this at a central place almost definitely is the better choice.
Diffstat (limited to 'src/basic/stat-util.c')
-rw-r--r--src/basic/stat-util.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c
index 3a54103f1b..0fb6750a07 100644
--- a/src/basic/stat-util.c
+++ b/src/basic/stat-util.c
@@ -214,8 +214,19 @@ int path_is_fs_type(const char *path, statfs_f_type_t magic_value) {
}
bool is_temporary_fs(const struct statfs *s) {
- return is_fs_type(s, TMPFS_MAGIC) ||
- is_fs_type(s, RAMFS_MAGIC);
+ return is_fs_type(s, TMPFS_MAGIC) ||
+ is_fs_type(s, RAMFS_MAGIC);
+}
+
+bool is_network_fs(const struct statfs *s) {
+ return is_fs_type(s, CIFS_MAGIC_NUMBER) ||
+ is_fs_type(s, CODA_SUPER_MAGIC) ||
+ is_fs_type(s, NCP_SUPER_MAGIC) ||
+ is_fs_type(s, NFS_SUPER_MAGIC) ||
+ is_fs_type(s, SMB_SUPER_MAGIC) ||
+ is_fs_type(s, V9FS_MAGIC) ||
+ is_fs_type(s, AFS_SUPER_MAGIC) ||
+ is_fs_type(s, OCFS2_SUPER_MAGIC);
}
int fd_is_temporary_fs(int fd) {
@@ -227,15 +238,25 @@ int fd_is_temporary_fs(int fd) {
return is_temporary_fs(&s);
}
+int fd_is_network_fs(int fd) {
+ struct statfs s;
+
+ if (fstatfs(fd, &s) < 0)
+ return -errno;
+
+ return is_network_fs(&s);
+}
+
int fd_is_network_ns(int fd) {
int r;
r = fd_is_fs_type(fd, NSFS_MAGIC);
if (r <= 0)
return r;
- r = ioctl(fd, NS_GET_NSTYPE);
- if (r < 0)
+
+ if (ioctl(fd, NS_GET_NSTYPE) < 0)
return -errno;
+
return r == CLONE_NEWNET;
}