2016-10-19 09:28:06 -04:00
|
|
|
/*
|
|
|
|
|
ISC License
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
|
|
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-06-30 11:15:20 -04:00
|
|
|
#pragma once
|
2016-12-22 22:46:20 -05:00
|
|
|
|
2017-04-11 08:53:46 -04:00
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-07-25 17:53:48 -05:00
|
|
|
#include "to_neg_errno.hpp"
|
2016-12-22 22:46:20 -05:00
|
|
|
|
2017-06-30 11:15:20 -04:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2020-12-19 15:06:08 -05:00
|
|
|
|
2016-10-19 09:28:06 -04:00
|
|
|
namespace fs
|
|
|
|
|
{
|
|
|
|
|
static
|
|
|
|
|
inline
|
|
|
|
|
int
|
2019-01-25 07:03:46 -05:00
|
|
|
fdatasync(const int fd_)
|
2016-10-19 09:28:06 -04:00
|
|
|
{
|
2016-10-22 23:14:50 -04:00
|
|
|
#if _POSIX_SYNCHRONIZED_IO > 0
|
2025-07-25 17:53:48 -05:00
|
|
|
int rv;
|
|
|
|
|
|
|
|
|
|
rv = ::fdatasync(fd_);
|
|
|
|
|
|
|
|
|
|
return ::to_neg_errno(rv);
|
2016-10-22 23:14:50 -04:00
|
|
|
#else
|
2025-07-25 17:53:48 -05:00
|
|
|
return -ENOSYS;
|
2016-10-22 23:14:50 -04:00
|
|
|
#endif
|
2016-10-19 09:28:06 -04:00
|
|
|
}
|
|
|
|
|
}
|