summaryrefslogtreecommitdiffstats
path: root/libc-bottom-half/cloudlibc/src/libc/unistd/fsync.c
blob: 733e29479431006a88b75eeb894ae36cd7e8f9f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
//
// SPDX-License-Identifier: BSD-2-Clause

#include <wasi/api.h>
#include <errno.h>
#include <unistd.h>

int fsync(int fildes) {
  __wasi_errno_t error = __wasi_fd_sync(fildes);
  if (error != 0) {
    errno = error == ENOTCAPABLE ? EINVAL : error;
    return -1;
  }
  return 0;
}