Files
yatm/internal/executor/tracking_unix.go
T
Samuel Cui 4fef653b71 Prepare YATM v1.0.0-alpha.2
Unify file queries and Scan execution, retain indexed Identical results,
improve Job and Preview workflows, and verify release packaging.
2026-10-05 19:08:49 +08:00

27 lines
773 B
Go

//go:build linux || darwin
package executor
import (
"encoding/binary"
"fmt"
"os"
"syscall"
"github.com/samuelncui/yatm/internal/library"
)
// ObserveTracking derives native identity from the existing observation without opening the file or reading xattrs.
func ObserveTracking(source *library.Location, scanned os.FileInfo) []*library.FileTrackingKey {
stat, ok := scanned.Sys().(*syscall.Stat_t)
if !ok {
return nil
}
value := make([]byte, 8)
binary.BigEndian.PutUint64(value, stat.Ino)
birth, generation := nativeLifetime(stat)
return []*library.FileTrackingKey{{Kind: library.TrackingNative,
Scope: fmt.Sprintf("%s/fs/%d", source.ExecutorID, stat.Dev), KeyValue: value,
Details: library.TrackingDetails{BirthNS: birth, Generation: generation}}}
}