mount_utils: add helper to determine whether new mount api supports bind mounts

parent 79defd88
...@@ -488,3 +488,28 @@ bool can_use_mount_api(void) ...@@ -488,3 +488,28 @@ bool can_use_mount_api(void)
return supported == 1; return supported == 1;
} }
bool can_use_bind_mounts(void)
{
static int supported = -1;
if (supported == -1) {
int ret;
if (!can_use_mount_api()) {
supported = 0;
return false;
}
ret = mount_setattr(-EBADF, NULL, 0, NULL, 0);
if (!ret || errno == ENOSYS) {
supported = 0;
return false;
}
supported = 1;
TRACE("Kernel supports bind mounts in the new mount api");
}
return supported == 1;
}
...@@ -206,5 +206,6 @@ __hidden extern unsigned long add_required_remount_flags(const char *s, ...@@ -206,5 +206,6 @@ __hidden extern unsigned long add_required_remount_flags(const char *s,
unsigned long flags); unsigned long flags);
__hidden extern bool can_use_mount_api(void); __hidden extern bool can_use_mount_api(void);
__hidden extern bool can_use_bind_mounts(void);
#endif /* __LXC_MOUNT_UTILS_H */ #endif /* __LXC_MOUNT_UTILS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment