2014-05-12 12:41:46 -04:00
|
|
|
/*
|
2026-02-23 13:22:21 -06:00
|
|
|
ISC License
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2026, Antonio SJ Musumeci <trapexit@spawn.link>
|
2016-01-14 16:50:22 -05:00
|
|
|
|
|
|
|
|
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.
|
2014-05-12 12:41:46 -04:00
|
|
|
*/
|
|
|
|
|
|
2025-07-25 17:53:48 -05:00
|
|
|
#include "fuse_fsync.hpp"
|
|
|
|
|
|
2019-01-25 07:03:46 -05:00
|
|
|
#include "errno.hpp"
|
|
|
|
|
#include "fileinfo.hpp"
|
2020-08-17 16:29:22 -04:00
|
|
|
#include "fs_fdatasync.hpp"
|
|
|
|
|
#include "fs_fsync.hpp"
|
2025-07-25 17:53:48 -05:00
|
|
|
#include "to_neg_errno.hpp"
|
2019-01-25 07:03:46 -05:00
|
|
|
|
2020-12-19 15:06:08 -05:00
|
|
|
#include "fuse.h"
|
2014-05-12 12:41:46 -04:00
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2020-12-19 15:06:08 -05:00
|
|
|
|
2025-07-25 17:53:48 -05:00
|
|
|
static
|
|
|
|
|
int
|
|
|
|
|
_fsync(const int fd_,
|
|
|
|
|
const int isdatasync_)
|
2014-05-12 12:41:46 -04:00
|
|
|
{
|
2025-07-25 17:53:48 -05:00
|
|
|
int rv;
|
|
|
|
|
|
|
|
|
|
rv = (isdatasync_ ?
|
|
|
|
|
fs::fdatasync(fd_) :
|
|
|
|
|
fs::fsync(fd_));
|
|
|
|
|
|
|
|
|
|
return ::to_neg_errno(rv);
|
2014-05-12 12:41:46 -04:00
|
|
|
}
|
|
|
|
|
|
2025-07-25 17:53:48 -05:00
|
|
|
int
|
2025-10-13 00:21:36 -04:00
|
|
|
FUSE::fsync(const fuse_req_ctx_t *ctx_,
|
2026-03-01 13:58:06 -06:00
|
|
|
cu64 fh_,
|
|
|
|
|
int isdatasync_)
|
2014-05-12 12:41:46 -04:00
|
|
|
{
|
2025-09-17 23:51:16 -04:00
|
|
|
FileInfo *fi = FileInfo::from_fh(fh_);
|
2025-07-25 17:53:48 -05:00
|
|
|
|
2026-03-09 22:40:46 -05:00
|
|
|
if(not fi)
|
|
|
|
|
return -EBADF;
|
|
|
|
|
|
2025-07-25 17:53:48 -05:00
|
|
|
return ::_fsync(fi->fd,isdatasync_);
|
2014-05-12 12:41:46 -04:00
|
|
|
}
|