update statmore and setattermore for crtime

This commit is contained in:
Ben McClelland
2021-09-14 09:29:49 -07:00
parent 9647f2c881
commit bbcd7e330f
2 changed files with 19 additions and 9 deletions

View File

@@ -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))

View File

@@ -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