#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
+#include "fstab-util.h"
#include "glyph-util.h"
#include "hashmap.h"
#include "initrd-util.h"
(void) unlink(p);
return mfree(p);
}
+
+static int path_get_mount_info(
+ const char *path,
+ char **ret_fstype,
+ char **ret_options) {
+
+ _cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
+ _cleanup_free_ char *fstype = NULL, *options = NULL;
+ struct libmnt_fs *fs;
+ int r;
+
+ assert(path);
+
+ table = mnt_new_table();
+ if (!table)
+ return -ENOMEM;
+
+ r = mnt_table_parse_mtab(table, /* filename = */ NULL);
+ if (r < 0)
+ return r;
+
+ fs = mnt_table_find_mountpoint(table, path, MNT_ITER_FORWARD);
+ if (!fs)
+ return -EINVAL;
+
+ if (ret_fstype) {
+ fstype = strdup(strempty(mnt_fs_get_fstype(fs)));
+ if (!fstype)
+ return -ENOMEM;
+ }
+
+ if (ret_options) {
+ options = strdup(strempty(mnt_fs_get_options(fs)));
+ if (!options)
+ return -ENOMEM;
+ }
+
+ if (ret_fstype)
+ *ret_fstype = TAKE_PTR(fstype);
+ if (ret_options)
+ *ret_options = TAKE_PTR(options);
+
+ return 0;
+}
+
+int path_is_network_fs_harder(const char *path) {
+ _cleanup_free_ char *fstype = NULL, *options = NULL;
+ int r, ret;
+
+ assert(path);
+
+ ret = path_is_network_fs(path);
+ if (ret > 0)
+ return true;
+
+ r = path_get_mount_info(path, &fstype, &options);
+ if (r < 0)
+ return RET_GATHER(ret, r);
+
+ if (fstype_is_network(fstype))
+ return true;
+
+ if (fstab_test_option(options, "_netdev\0"))
+ return true;
+
+ return false;
+}
int mount_credentials_fs(const char *path, size_t size, bool ro);
int make_fsmount(int error_log_level, const char *what, const char *type, unsigned long flags, const char *options, int userns_fd);
+
+int path_is_network_fs_harder(const char *path);
assert_se(umount_recursive(b, 0) >= 0);
}
+TEST(path_is_network_fs_harder) {
+ ASSERT_OK(path_is_network_fs_harder("/"));
+ ASSERT_OK_ZERO(path_is_network_fs_harder("/dev"));
+ ASSERT_OK_ZERO(path_is_network_fs_harder("/sys"));
+ ASSERT_OK_ZERO(path_is_network_fs_harder("/run"));
+}
+
DEFINE_TEST_MAIN(LOG_DEBUG);