Adding fallback when O_DIRECT is not supported

This commit is contained in:
JTischbein 2025-12-15 13:44:20 +01:00
parent ceccfb9ee6
commit d2acc3a8a8
1 changed files with 4 additions and 0 deletions

View File

@ -165,6 +165,10 @@ struct llama_file::impl {
impl(const char * fname, const char * mode, bool uncached_read) {
if (uncached_read) {
fd = open(fname, O_RDONLY | O_DIRECT);
if (fd == -1 && (errno == EINVAL || errno == EOPNOTSUPP)) {
fd = open(fname, O_RDONLY); // retry without O_DIRECT
}
if (fd == -1) {
throw std::runtime_error(format("failed to open %s: %s", fname, strerror(errno)));
}