From ad24b679d215c2f8eaab6125a68e864c2a5d7dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 29 Mar 2022 15:27:12 +0400 Subject: [PATCH] block: move fcntl_setfl() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is only used by block/file-posix.c, move it there. Signed-off-by: Marc-André Lureau Reviewed-by: Richard Henderson --- block/file-posix.c | 15 +++++++++++++++ include/sysemu/os-posix.h | 2 -- util/oslib-posix.c | 15 --------------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index bfd9b21111..48cd096624 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1022,6 +1022,21 @@ static int raw_handle_perm_lock(BlockDriverState *bs, return ret; } +/* Sets a specific flag */ +static int fcntl_setfl(int fd, int flag) +{ + int flags; + + flags = fcntl(fd, F_GETFL); + if (flags == -1) { + return -errno; + } + if (fcntl(fd, F_SETFL, flags | flag) == -1) { + return -errno; + } + return 0; +} + static int raw_reconfigure_getfd(BlockDriverState *bs, int flags, int *open_flags, uint64_t perm, bool force_dup, Error **errp) diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h index adbe19d3e4..58de7c994d 100644 --- a/include/sysemu/os-posix.h +++ b/include/sysemu/os-posix.h @@ -96,8 +96,6 @@ static inline void qemu_funlockfile(FILE *f) funlockfile(f); } -int fcntl_setfl(int fd, int flag); - #ifdef __cplusplus } #endif diff --git a/util/oslib-posix.c b/util/oslib-posix.c index b8bf7d4070..289efca3fa 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -897,21 +897,6 @@ size_t qemu_get_host_physmem(void) return 0; } -/* Sets a specific flag */ -int fcntl_setfl(int fd, int flag) -{ - int flags; - - flags = fcntl(fd, F_GETFL); - if (flags == -1) { - return -errno; - } - if (fcntl(fd, F_SETFL, flags | flag) == -1) { - return -errno; - } - return 0; -} - int qemu_msync(void *addr, size_t length, int fd) { size_t align_mask = ~(qemu_real_host_page_size() - 1);