Merge "overlayfs: Use userxattrs on supporting kernels."

This commit is contained in:
David Anderson 2021-11-22 18:16:10 +00:00 committed by Gerrit Code Review
commit 92b3b3fff6

View file

@ -322,6 +322,17 @@ std::string fs_mgr_get_overlayfs_candidate(const std::string& mount_point) {
const auto kLowerdirOption = "lowerdir="s;
const auto kUpperdirOption = "upperdir="s;
static inline bool KernelSupportsUserXattrs() {
struct utsname uts;
uname(&uts);
int major, minor;
if (sscanf(uts.release, "%d.%d", &major, &minor) != 2) {
return false;
}
return major > 5 || (major == 5 && minor >= 15);
}
// default options for mount_point, returns empty string for none available.
std::string fs_mgr_get_overlayfs_options(const std::string& mount_point) {
auto candidate = fs_mgr_get_overlayfs_candidate(mount_point);
@ -331,6 +342,9 @@ std::string fs_mgr_get_overlayfs_options(const std::string& mount_point) {
if (fs_mgr_overlayfs_valid() == OverlayfsValidResult::kOverrideCredsRequired) {
ret += ",override_creds=off";
}
if (KernelSupportsUserXattrs()) {
ret += ",userxattr";
}
return ret;
}