Skip to content

Commit

Permalink
More.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Mar 21, 2024
1 parent 9b67559 commit d17eacc
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 31 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,4 @@ jobs:
- uses: docker/setup-qemu-action@v3

- name: Test
run: GOARCH=arm64 go test -v -short ./...

test-f2fs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with: { lfs: 'true' }

- name: Mount F2FS
run: .github/workflows/f2fs.sh
run: GOARCH=arm64 go test -v -short ./...
4 changes: 2 additions & 2 deletions sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ func instantiateSQLite() (sqlt *sqlite, err error) {
}

sqlt.freer = util.ReadUint32(sqlt.mod, uint32(global.Get()))
if err != nil {
return nil, err
if sqlt.freer == 0 {
return nil, util.BadBinaryErr
}
return sqlt, nil
}
Expand Down
16 changes: 0 additions & 16 deletions vfs/f2fs_linux.go

This file was deleted.

8 changes: 6 additions & 2 deletions vfs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,14 @@ func (*vfsFile) SectorSize() int {
}

func (f *vfsFile) DeviceCharacteristics() DeviceCharacteristic {
var res DeviceCharacteristic
if osBatchAtomic(f.File) {
res |= IOCAP_BATCH_ATOMIC
}
if f.psow {
return IOCAP_POWERSAFE_OVERWRITE
res |= IOCAP_POWERSAFE_OVERWRITE
}
return 0
return res
}

func (f *vfsFile) SizeHint(size int64) error {
Expand Down
34 changes: 34 additions & 0 deletions vfs/os_f2fs_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//go:build amd64 || arm64 || !sqlite3_nosys

package vfs

import (
"os"

"golang.org/x/sys/unix"
)

const (
_F2FS_IOC_START_ATOMIC_WRITE = 62721
_F2FS_IOC_COMMIT_ATOMIC_WRITE = 62722
_F2FS_IOC_ABORT_ATOMIC_WRITE = 62725
_F2FS_IOC_GET_FEATURES = 2147546380
_F2FS_FEATURE_ATOMIC_WRITE = 4
)

func osBatchAtomic(file *os.File) bool {
flags, err := unix.IoctlGetInt(int(file.Fd()), _F2FS_IOC_GET_FEATURES)
return err == nil && flags&_F2FS_FEATURE_ATOMIC_WRITE != 0
}

func (f *vfsFile) BeginAtomicWrite() error {
return unix.IoctlSetInt(int(f.Fd()), _F2FS_IOC_START_ATOMIC_WRITE, 0)
}

func (f *vfsFile) CommitAtomicWrite() error {
return unix.IoctlSetInt(int(f.Fd()), _F2FS_IOC_COMMIT_ATOMIC_WRITE, 0)
}

func (f *vfsFile) RollbackAtomicWrite() error {
return unix.IoctlSetInt(int(f.Fd()), _F2FS_IOC_ABORT_ATOMIC_WRITE, 0)
}
9 changes: 9 additions & 0 deletions vfs/os_std_atomic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !linux || !(amd64 || arm64) || sqlite3_nosys

package vfs

import "os"

func osBatchAtomic(*os.File) bool {
return false
}

0 comments on commit d17eacc

Please sign in to comment.