diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-08 17:14:37 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-05-30 07:54:00 +0200 |
commit | 1b6b01c3a07ef32d6c524ae914db7af9a67e4f88 (patch) | |
tree | f2173a49712c0e5556c977da62506f475eb69ca7 /src/basic/stat-util.c | |
parent | 40155e8a3d6c7b44a3353f2c4c5f7af9673fd320 (diff) |
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.
(cherry picked from commit 77f9fa3b8ea46c27e5a5e9270f71bf1b4000c3e0)
Diffstat (limited to 'src/basic/stat-util.c')
-rw-r--r-- | src/basic/stat-util.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c index 964fa91b2..270e80fee 100644 --- a/src/basic/stat-util.c +++ b/src/basic/stat-util.c @@ -224,8 +224,19 @@ int path_is_fs_type(const char *path, statfs_f_type_t magic_value) { #endif // 0 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); } #if 0 /// UNNEEDED by elogind @@ -238,15 +249,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; } |