From 767b925678fd96b3fd3631d80f13542d3d048751 Mon Sep 17 00:00:00 2001
From: Firelight Flagboy <firelight.flagboy@gmail.com>
Date: Wed, 27 Nov 2024 15:56:35 +0100
Subject: [PATCH] Fix bugeous `crtime` value on macOS

During certain operation, macOS use some helper that send request to the mountpoint with `crtime` set to `0xffff83da4f80`.
That value correspond to `-2_082_844_800u64` which is the difference between the date 1904-01-01 and 1970-01-01 because macOS epoch start at 1904 and not 1970.

<https://github.com/macfuse/macfuse/issues/1042>

Fix #217
---
 src/ll/request.rs | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/ll/request.rs b/src/ll/request.rs
index 7b57c759..5f6961e9 100644
--- a/src/ll/request.rs
+++ b/src/ll/request.rs
@@ -427,6 +427,10 @@ mod op {
             #[cfg(target_os = "macos")]
             match self.arg.valid & FATTR_CRTIME {
                 0 => None,
+                // During certain operation, macOS use some helper that send request to the mountpoint with `crtime` set to 0xffffffff83da4f80.
+                // That value correspond to `-2_082_844_800u64` which is the difference between the date 1904-01-01 and 1970-01-01 because macOS epoch start at 1904 and not 1970.
+                // https://github.com/macfuse/macfuse/issues/1042
+                _ if self.arg.crtime == 0xffffffff83da4f80 => None,
                 _ => Some(
                     SystemTime::UNIX_EPOCH + Duration::new(self.arg.crtime, self.arg.crtimensec),
                 ),