blob: 25151d35cd0f0ec4acdfef25ee40740c756c37fb [file]
/*
* Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "LibUringUtils"
#include <android-base/strings.h>
#include <liburingutils/LibUringUtils.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <unistd.h>
bool LibUringUtils::isIouringEnabled() {
// TODO: b/385143770 - Change this behavior to also check the Liburing version.
return isIouringSupportedByKernel();
}
bool LibUringUtils::isIouringSupportedByKernel() {
struct utsname uts {};
unsigned int major, minor;
uname(&uts);
if (sscanf(uts.release, "%u.%u", &major, &minor) != 2) {
return false;
}
// We will only support kernels from 6.1 and higher.
return major > 6 || (major == 6 && minor >= 1);
}