github.com/ncruces/go-sqlite3@v0.15.1-0.20240520133447-53eef1510ff0/vfs/os_f2fs_linux.go (about) 1 //go:build (amd64 || arm64 || riscv64) && !sqlite3_nosys 2 3 package vfs 4 5 import ( 6 "os" 7 8 "golang.org/x/sys/unix" 9 ) 10 11 const ( 12 _F2FS_IOC_START_ATOMIC_WRITE = 62721 13 _F2FS_IOC_COMMIT_ATOMIC_WRITE = 62722 14 _F2FS_IOC_ABORT_ATOMIC_WRITE = 62725 15 _F2FS_IOC_GET_FEATURES = 2147808524 16 _F2FS_FEATURE_ATOMIC_WRITE = 4 17 ) 18 19 func osBatchAtomic(file *os.File) bool { 20 flags, err := unix.IoctlGetInt(int(file.Fd()), _F2FS_IOC_GET_FEATURES) 21 return err == nil && flags&_F2FS_FEATURE_ATOMIC_WRITE != 0 22 } 23 24 func (f *vfsFile) BeginAtomicWrite() error { 25 return unix.IoctlSetInt(int(f.Fd()), _F2FS_IOC_START_ATOMIC_WRITE, 0) 26 } 27 28 func (f *vfsFile) CommitAtomicWrite() error { 29 return unix.IoctlSetInt(int(f.Fd()), _F2FS_IOC_COMMIT_ATOMIC_WRITE, 0) 30 } 31 32 func (f *vfsFile) RollbackAtomicWrite() error { 33 return unix.IoctlSetInt(int(f.Fd()), _F2FS_IOC_ABORT_ATOMIC_WRITE, 0) 34 }