mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-18 02:44:03 -05:00
Portability fixes for FreeBSD - os_fdatasync()
Use fsync() when fdatasync() and F_FULLSYNC isn't available. Signed-off-by: Rui Paulo <rpaulo@freebsd.org>
This commit is contained in:
parent
e8dc205f17
commit
22e8df3a98
@ -445,16 +445,16 @@ int os_file_exists(const char *fname)
|
|||||||
int os_fdatasync(FILE *stream)
|
int os_fdatasync(FILE *stream)
|
||||||
{
|
{
|
||||||
if (!fflush(stream)) {
|
if (!fflush(stream)) {
|
||||||
#ifndef __MACH__
|
#ifdef __linux__
|
||||||
return fdatasync(fileno(stream));
|
return fdatasync(fileno(stream));
|
||||||
#else /* __MACH__ */
|
#else /* !__linux__ */
|
||||||
#ifdef F_FULLFSYNC
|
#ifdef F_FULLFSYNC
|
||||||
/* OS X does not implement fdatasync(). */
|
/* OS X does not implement fdatasync(). */
|
||||||
return fcntl(fileno(stream), F_FULLFSYNC);
|
return fcntl(fileno(stream), F_FULLFSYNC);
|
||||||
#else /* F_FULLFSYNC */
|
#else /* F_FULLFSYNC */
|
||||||
#error Neither fdatasync nor F_FULLSYNC are defined
|
return fsync(fileno(stream));
|
||||||
#endif /* F_FULLFSYNC */
|
#endif /* F_FULLFSYNC */
|
||||||
#endif /* __MACH__ */
|
#endif /* __linux__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user