macos fixes

This commit is contained in:
2025-09-28 08:28:55 -05:00
parent 132e0b73be
commit 691a9e3d0a
3 changed files with 57 additions and 17 deletions

View File

@@ -1222,11 +1222,19 @@ auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr)
if (SETATTR_WANTS_MODTIME(attr)) {
struct timespec ts[2];
if (SETATTR_WANTS_ACCTIME(attr)) {
if (not fuse_drive_base::validate_timespec(attr->acctime)) {
return api_error::invalid_operation;
}
ts[0].tv_sec = attr->acctime.tv_sec;
ts[0].tv_nsec = attr->acctime.tv_nsec;
} else {
if (not fuse_drive_base::validate_timespec(attr->modtime)) {
return api_error::invalid_operation;
}
struct timeval tv{};
gettimeofday(&tv, NULL);
gettimeofday(&tv, nullptr);
ts[0].tv_sec = tv.tv_sec;
ts[0].tv_nsec = tv.tv_usec * 1000;
}

View File

@@ -51,8 +51,8 @@ auto remote_fuse_drive::access_impl(std::string api_path, int mask)
}
#if defined(__APPLE__)
api_error remote_fuse_drive::chflags_impl(std::string api_path,
uint32_t flags) {
auto remote_fuse_drive::chflags_impl(std::string api_path, uint32_t flags)
-> api_error {
return utils::to_api_error(
remote_instance_->fuse_chflags(api_path.c_str(), flags));
}
@@ -142,6 +142,18 @@ auto remote_fuse_drive::fsetattr_x_impl(std::string api_path,
struct setattr_x *attr,
struct fuse_file_info *f_info)
-> api_error {
if (SETATTR_WANTS_MODTIME(attr)) {
if (not fuse_drive_base::validate_timespec(attr->modtime)) {
return api_error::invalid_operation;
}
}
if (SETATTR_WANTS_ACCTIME(attr)) {
if (not fuse_drive_base::validate_timespec(attr->acctime)) {
return api_error::invalid_operation;
}
}
remote::setattr_x attributes{};
attributes.valid = attr->valid;
attributes.mode = attr->mode;
@@ -210,9 +222,9 @@ auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *u_stat)
}
#if defined(__APPLE__)
api_error remote_fuse_drive::getxtimes_impl(std::string api_path,
struct timespec *bkuptime,
struct timespec *crtime) {
auto remote_fuse_drive::getxtimes_impl(std::string api_path,
struct timespec *bkuptime,
struct timespec *crtime) -> api_error {
if (not(bkuptime && crtime)) {
return utils::to_api_error(-EFAULT);
}
@@ -489,8 +501,20 @@ auto remote_fuse_drive::rmdir_impl(std::string api_path) -> api_error {
}
#if defined(__APPLE__)
api_error remote_fuse_drive::setattr_x_impl(std::string api_path,
struct setattr_x *attr) {
auto remote_fuse_drive::setattr_x_impl(std::string api_path,
struct setattr_x *attr) -> api_error {
if (SETATTR_WANTS_MODTIME(attr)) {
if (not fuse_drive_base::validate_timespec(attr->modtime)) {
return api_error::invalid_operation;
}
}
if (SETATTR_WANTS_ACCTIME(attr)) {
if (not fuse_drive_base::validate_timespec(attr->acctime)) {
return api_error::invalid_operation;
}
}
remote::setattr_x attributes{};
attributes.valid = attr->valid;
attributes.mode = attr->mode;
@@ -518,8 +542,9 @@ api_error remote_fuse_drive::setattr_x_impl(std::string api_path,
remote_instance_->fuse_setattr_x(api_path.c_str(), attributes));
}
api_error remote_fuse_drive::setbkuptime_impl(std::string api_path,
const struct timespec *bkuptime) {
auto remote_fuse_drive::setbkuptime_impl(std::string api_path,
const struct timespec *bkuptime)
-> api_error {
remote::file_time repertory_bkuptime =
((static_cast<remote::file_time>(bkuptime->tv_sec) *
utils::time::NANOS_PER_SECOND) +
@@ -528,8 +553,9 @@ api_error remote_fuse_drive::setbkuptime_impl(std::string api_path,
remote_instance_->fuse_setbkuptime(api_path.c_str(), repertory_bkuptime));
}
api_error remote_fuse_drive::setchgtime_impl(std::string api_path,
const struct timespec *chgtime) {
auto remote_fuse_drive::setchgtime_impl(std::string api_path,
const struct timespec *chgtime)
-> api_error {
remote::file_time repertory_chgtime =
((static_cast<remote::file_time>(chgtime->tv_sec) *
utils::time::NANOS_PER_SECOND) +
@@ -538,8 +564,9 @@ api_error remote_fuse_drive::setchgtime_impl(std::string api_path,
remote_instance_->fuse_setchgtime(api_path.c_str(), repertory_chgtime));
}
api_error remote_fuse_drive::setcrtime_impl(std::string api_path,
const struct timespec *crtime) {
auto remote_fuse_drive::setcrtime_impl(std::string api_path,
const struct timespec *crtime)
-> api_error {
remote::file_time repertory_crtime =
((static_cast<remote::file_time>(crtime->tv_sec) *
utils::time::NANOS_PER_SECOND) +
@@ -548,12 +575,12 @@ api_error remote_fuse_drive::setcrtime_impl(std::string api_path,
remote_instance_->fuse_setcrtime(api_path.c_str(), repertory_crtime));
}
api_error remote_fuse_drive::setvolname_impl(const char *volname) {
auto remote_fuse_drive::setvolname_impl(const char *volname) -> api_error {
return utils::to_api_error(remote_instance_->fuse_setvolname(volname));
}
api_error remote_fuse_drive::statfs_x_impl(std::string api_path,
struct statfs *stbuf) {
auto remote_fuse_drive::statfs_x_impl(std::string api_path,
struct statfs *stbuf) -> api_error {
auto res = statfs(config_.get_data_directory().c_str(), stbuf);
if (res == 0) {
remote::statfs_x r_stat{};
@@ -624,8 +651,13 @@ auto remote_fuse_drive::utimens_impl(std::string api_path,
auto remote_fuse_drive::utimens_impl(std::string api_path,
const struct timespec tv[2]) -> api_error {
#endif // FUSE_USE_VERSION >= 30
REPERTORY_USES_FUNCTION_NAME();
if (not fuse_drive_base::validate_timespec(tv[0]) ||
not fuse_drive_base::validate_timespec(tv[1])) {
utils::error::handle_info(
function_name,
fmt::format("failed|{}|{}", tv[0].tv_nsec, tv[1].tv_nsec));
return api_error::invalid_operation;
}

0
support/3rd_party/icu_configure.sh vendored Normal file → Executable file
View File