Skip to content

Commit

Permalink
block: move fcntl_setfl()
Browse files Browse the repository at this point in the history
It is only used by block/file-posix.c, move it there.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
elmarco committed May 3, 2022
1 parent 4d14cb0 commit ad24b67
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
15 changes: 15 additions & 0 deletions block/file-posix.c
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions include/sysemu/os-posix.h
Expand Up @@ -96,8 +96,6 @@ static inline void qemu_funlockfile(FILE *f)
funlockfile(f);
}

int fcntl_setfl(int fd, int flag);

#ifdef __cplusplus
}
#endif
Expand Down
15 changes: 0 additions & 15 deletions util/oslib-posix.c
Expand Up @@ -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);
Expand Down

0 comments on commit ad24b67

Please sign in to comment.