From a7f702a021a23e123f2d7c5cdcdc8bbb7a17b571 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 29 Apr 2022 20:54:43 +0200 Subject: [PATCH] LibC: Implement posix_fadvise() (as a harmless no-op) --- Userland/Libraries/LibC/fcntl.cpp | 15 +++++++++++++++ Userland/Libraries/LibC/fcntl.h | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibC/fcntl.cpp b/Userland/Libraries/LibC/fcntl.cpp index 5c1ed89ded..9ce5039f18 100644 --- a/Userland/Libraries/LibC/fcntl.cpp +++ b/Userland/Libraries/LibC/fcntl.cpp @@ -87,4 +87,19 @@ int openat(int dirfd, char const* path, int options, ...) int rc = syscall(SC_open, ¶ms); __RETURN_WITH_ERRNO(rc, rc, -1); } + +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fadvise.html +int posix_fadvise(int fd, off_t offset, off_t len, int advice) +{ + // Per POSIX: + // "The posix_fadvise() function shall have no effect on the semantics of other operations on the specified data, + // although it may affect the performance of other operations." + + // For now, we simply ignore posix_fadvise() requests. In the future we may use them to optimize performance. + (void)fd; + (void)offset; + (void)len; + (void)advice; + return 0; +} } diff --git a/Userland/Libraries/LibC/fcntl.h b/Userland/Libraries/LibC/fcntl.h index ae1e290824..b52679518c 100644 --- a/Userland/Libraries/LibC/fcntl.h +++ b/Userland/Libraries/LibC/fcntl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2022, Andreas Kling * Copyright (c) 2021, sin-ack * * SPDX-License-Identifier: BSD-2-Clause @@ -20,4 +20,6 @@ int create_inode_watcher(unsigned flags); int inode_watcher_add_watch(int fd, char const* path, size_t path_length, unsigned event_mask); int inode_watcher_remove_watch(int fd, int wd); +int posix_fadvise(int fd, off_t offset, off_t len, int advice); + __END_DECLS