macos fixes

This commit is contained in:
2025-09-28 07:52:30 -05:00
parent a407f8d15b
commit 132e0b73be
4 changed files with 22 additions and 14 deletions

View File

@@ -133,6 +133,8 @@ public:
[[nodiscard]] auto check_parent_access(const std::string &api_path,
int mask) const -> api_error override;
[[nodiscard]] static auto validate_timespec(const timespec &spec) -> bool;
};
} // namespace repertory

View File

@@ -1420,20 +1420,6 @@ auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2],
auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2])
-> api_error {
#endif
const auto validate_timespec = [](const timespec &spec) {
if (spec.tv_nsec == UTIME_NOW || spec.tv_nsec == UTIME_OMIT) {
return true;
}
if (spec.tv_nsec < 0 ||
spec.tv_nsec >=
static_cast<std::int64_t>(utils::time::NANOS_PER_SECOND)) {
return false;
}
return true;
};
if (not validate_timespec(tv[0]) || not validate_timespec(tv[1])) {
return api_error::invalid_operation;
}

View File

@@ -364,6 +364,20 @@ void fuse_drive_base::set_timespec_from_meta(const api_meta_map &meta,
ts.tv_sec =
static_cast<std::int64_t>(meta_time / utils::time::NANOS_PER_SECOND);
}
auto fuse_drive_base::validate_timespec(const timespec &spec) -> bool {
if (spec.tv_nsec == UTIME_NOW || spec.tv_nsec == UTIME_OMIT) {
return true;
}
if (spec.tv_nsec < 0 || spec.tv_nsec >= static_cast<std::int64_t>(
utils::time::NANOS_PER_SECOND)) {
return false;
}
return true;
};
} // namespace repertory
#endif // !defined(_WIN32)

View File

@@ -24,6 +24,7 @@
#include "drives/fuse/remotefuse/remote_fuse_drive.hpp"
#include "app_config.hpp"
#include "drives/fuse/fuse_drive_base.hpp"
#include "events/consumers/console_consumer.hpp"
#include "events/consumers/logging_consumer.hpp"
#include "events/event_system.hpp"
@@ -623,6 +624,11 @@ 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
if (not fuse_drive_base::validate_timespec(tv[0]) ||
not fuse_drive_base::validate_timespec(tv[1])) {
return api_error::invalid_operation;
}
remote::file_time rtv[2U] = {0};
if (tv != nullptr) {
const auto update_timespec = [](auto &dst, const auto &src) {