From 132e0b73becac2d6865d4144c1a52a8b090a2168 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sun, 28 Sep 2025 07:52:30 -0500 Subject: [PATCH] macos fixes --- .../include/drives/fuse/fuse_drive_base.hpp | 2 ++ .../librepertory/src/drives/fuse/fuse_drive.cpp | 14 -------------- .../src/drives/fuse/fuse_drive_base.cpp | 14 ++++++++++++++ .../drives/fuse/remotefuse/remote_fuse_drive.cpp | 6 ++++++ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp b/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp index b586415f..9c4d8b60 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp @@ -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 diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp index a3e764b4..571d34b9 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp @@ -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(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; } diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp index f8d69972..31407da0 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp @@ -364,6 +364,20 @@ void fuse_drive_base::set_timespec_from_meta(const api_meta_map &meta, ts.tv_sec = static_cast(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( + utils::time::NANOS_PER_SECOND)) { + return false; + } + + return true; +}; + } // namespace repertory #endif // !defined(_WIN32) diff --git a/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp index e783d229..71c79d54 100644 --- a/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp @@ -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) {