diff --git a/cephfs/errors.go b/cephfs/errors.go index ab28f09..5643499 100644 --- a/cephfs/errors.go +++ b/cephfs/errors.go @@ -37,6 +37,9 @@ var ( ErrNotConnected = getError(-C.ENOTCONN) // ErrNotExist indicates a non-specific missing resource. ErrNotExist = getError(-C.ENOENT) + // ErrOpNotSupported is returned in general for operations that are not + // supported. + ErrOpNotSupported = getError(-C.EOPNOTSUPP) // Private errors: diff --git a/cephfs/file_fallocate_mode_zero_unsupported_test.go b/cephfs/file_fallocate_mode_zero_unsupported_test.go new file mode 100644 index 0000000..8071d30 --- /dev/null +++ b/cephfs/file_fallocate_mode_zero_unsupported_test.go @@ -0,0 +1,30 @@ +//go:build main + +package cephfs + +import ( + "os" + "testing" + + "github.com/stretchr/testify/assert" +) + +// TestFallocateModeZeroUnsupported and this test file exists merely to track +// the backports for https://tracker.ceph.com/issues/68026. Once they are +// available with release versions this can probably vanish. +func TestFallocateModeZeroUnsupported(t *testing.T) { + mount := fsConnect(t) + defer fsDisconnect(t, mount) + fname := "file1.txt" + f, err := mount.Open(fname, os.O_RDWR|os.O_CREATE, 0644) + assert.NoError(t, err) + assert.NotNil(t, f) + defer func() { + assert.NoError(t, f.Close()) + assert.NoError(t, mount.Unlink(fname)) + }() + + err = f.Fallocate(FallocNoFlag, 0, 10) + assert.Error(t, err) + assert.Equal(t, ErrOpNotSupported, err) +}