diff --git a/scoutfs.go b/scoutfs.go index b0337f1..61e9a89 100644 --- a/scoutfs.go +++ b/scoutfs.go @@ -166,28 +166,34 @@ func FStatMore(f *os.File) (Stat, error) { } // SetAttrMore sets special scoutfs attributes -func SetAttrMore(path string, version, size, flags uint64, ctime time.Time) error { +func SetAttrMore(path string, version, size, flags uint64, ctime time.Time, crtime time.Time) error { f, err := os.OpenFile(path, os.O_RDWR, 0600) if err != nil { return err } defer f.Close() - return FSetAttrMore(f, version, size, flags, ctime) + return FSetAttrMore(f, version, size, flags, ctime, crtime) } // FSetAttrMore sets special scoutfs attributes for file handle -func FSetAttrMore(f *os.File, version, size, flags uint64, ctime time.Time) error { - var nsec int32 +func FSetAttrMore(f *os.File, version, size, flags uint64, ctime time.Time, crtime time.Time) error { + var cnsec int32 + var crnsec int32 if ctime.UnixNano() == int64(int32(ctime.UnixNano())) { - nsec = int32(ctime.UnixNano()) + cnsec = int32(ctime.UnixNano()) + } + if crtime.UnixNano() == int64(int32(crtime.UnixNano())) { + crnsec = int32(crtime.UnixNano()) } s := setattrMore{ Data_version: version, I_size: size, Flags: flags, Ctime_sec: uint64(ctime.Unix()), - Ctime_nsec: uint32(nsec), + Ctime_nsec: uint32(cnsec), + Crtime_sec: uint64(crtime.Unix()), + Crtime_nsec: uint32(crnsec), } _, err := scoutfsctl(f, IOCSETATTRMORE, unsafe.Pointer(&s)) diff --git a/scoutfsdefs.go b/scoutfsdefs.go index 6514254..3d2dae8 100644 --- a/scoutfsdefs.go +++ b/scoutfsdefs.go @@ -7,9 +7,9 @@ const IOCQUERYINODES = 0x80487301 const IOCINOPATH = 0x80287302 const IOCRELEASE = 0x40187303 const IOCSTAGE = 0x40207304 -const IOCSTATMORE = 0x80307305 +const IOCSTATMORE = 0x80407305 const IOCDATAWAITING = 0x80287306 -const IOCSETATTRMORE = 0x40287307 +const IOCSETATTRMORE = 0x40307307 const IOCLISTXATTRHIDDEN = 0x80187308 const IOCSEARCHXATTRS = 0x80387309 const IOCSTATFSMORE = 0x8038730a @@ -69,6 +69,9 @@ type Stat struct { Data_version uint64 Online_blocks uint64 Offline_blocks uint64 + Crtime_sec uint64 + Crtime_nsec uint32 + X_pad [4]uint8 } type DataWaitingEntry struct { Ino uint64 @@ -98,7 +101,8 @@ type setattrMore struct { Flags uint64 Ctime_sec uint64 Ctime_nsec uint32 - X_pad [4]uint8 + Crtime_nsec uint32 + Crtime_sec uint64 } type listXattrHidden struct { Id_pos uint64