Skip to content

Commit

Permalink
Remove unneeded fuse.E*** dependencies (use syscall.E***)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalif committed Jun 5, 2023
1 parent 171fbc9 commit 41eac99
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 128 deletions.
7 changes: 3 additions & 4 deletions internal/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import (
"io/ioutil"
"strings"
"sync"
"syscall"
"time"

"github.com/jacobsa/fuse"
)

type Capabilities struct {
Expand Down Expand Up @@ -456,7 +455,7 @@ func (e StorageBackendInitError) HeadBlob(param *HeadBlobInput) (*HeadBlobOutput
ContentType: PString("text/plain"),
}, nil
} else {
return nil, fuse.ENOENT
return nil, syscall.ENOENT
}
}

Expand Down Expand Up @@ -508,7 +507,7 @@ func (e StorageBackendInitError) GetBlob(param *GetBlobInput) (*GetBlobOutput, e
Body: ioutil.NopCloser(strings.NewReader(errStr)),
}, nil
} else {
return nil, fuse.ENOENT
return nil, syscall.ENOENT
}
}

Expand Down
19 changes: 9 additions & 10 deletions internal/backend_adlv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"syscall"
"time"

"github.com/jacobsa/fuse"
uuid "github.com/satori/go.uuid"
"github.com/sirupsen/logrus"

Expand Down Expand Up @@ -355,7 +354,7 @@ func (b *ADLv1) ListBlobs(param *ListBlobsInput) (*ListBlobsOutput, error) {

_, prefixes, items, err := b.appendToListResults(NilStr(param.Prefix),
recursive, NilStr(continuationToken), param.MaxKeys, nil, nil)
if err == fuse.ENOENT {
if err == syscall.ENOENT {
err = nil
} else if err != nil {
return nil, err
Expand All @@ -375,7 +374,7 @@ func (b *ADLv1) DeleteBlob(param *DeleteBlobInput) (*DeleteBlobOutput, error) {
return nil, err
}
if !*res.OperationResult {
return nil, fuse.ENOENT
return nil, syscall.ENOENT
}
return &DeleteBlobOutput{}, nil
}
Expand Down Expand Up @@ -417,7 +416,7 @@ func (b *ADLv1) RenameBlob(param *RenameBlobInput) (*RenameBlobOutput, error) {
// (the reverse, renaming a file to a directory works
// in ADLv1 and is the same as moving the file into
// the directory)
return nil, fuse.ENOENT
return nil, syscall.ENOENT
}

return &RenameBlobOutput{}, nil
Expand Down Expand Up @@ -556,7 +555,7 @@ func (b *ADLv1) uploadPart(param *MultipartBlobAddInput, offset uint64) error {
// created. The behavior is odd: seems
// like the first stream will error
// but the latter stream works fine
err = fuse.EINVAL
err = syscall.EINVAL
return err
} else if adlErr.resp.StatusCode == 400 &&
adlErr.RemoteException.Exception == "BadOffsetException" {
Expand Down Expand Up @@ -641,7 +640,7 @@ func (b *ADLv1) MultipartBlobCommit(param *MultipartBlobCommitInput) (*Multipart
&ReadSeekerCloser{bytes.NewReader([]byte(""))}, PInt64(int64(commitData.Size)),
adl.CLOSE, &leaseId, &leaseId)
err = mapADLv1Error(res.Response, err, false)
if err == fuse.ENOENT {
if err == syscall.ENOENT {
// either the blob was concurrently deleted or we got
// another CREATE which broke our lease. Either way
// technically we did finish uploading data so swallow
Expand All @@ -661,7 +660,7 @@ func (b *ADLv1) MultipartExpire(param *MultipartExpireInput) (*MultipartExpireOu

func (b *ADLv1) RemoveBucket(param *RemoveBucketInput) (*RemoveBucketOutput, error) {
if b.bucket == "" {
return nil, fuse.EINVAL
return nil, syscall.EINVAL
}

res, err := b.client.Delete(context.TODO(), b.account, b.path(""), PBool(false))
Expand All @@ -670,15 +669,15 @@ func (b *ADLv1) RemoveBucket(param *RemoveBucketInput) (*RemoveBucketOutput, err
return nil, err
}
if !*res.OperationResult {
return nil, fuse.ENOENT
return nil, syscall.ENOENT
}

return &RemoveBucketOutput{}, nil
}

func (b *ADLv1) MakeBucket(param *MakeBucketInput) (*MakeBucketOutput, error) {
if b.bucket == "" {
return nil, fuse.EINVAL
return nil, syscall.EINVAL
}

err := b.mkdir("")
Expand All @@ -697,7 +696,7 @@ func (b *ADLv1) mkdir(dir string) error {
return err
}
if !*res.OperationResult {
return fuse.EEXIST
return syscall.EEXIST
}
return nil
}
9 changes: 4 additions & 5 deletions internal/backend_adlv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"time"

"github.com/google/uuid"
"github.com/jacobsa/fuse"
"github.com/sirupsen/logrus"

adl2 "github.com/Azure/azure-sdk-for-go/services/storage/datalake/2018-11-09/storagedatalake"
Expand Down Expand Up @@ -197,7 +196,7 @@ func (b *ADLv2) Delegate() interface{} {

func (b *ADLv2) Init(key string) (err error) {
_, err = b.HeadBlob(&HeadBlobInput{Key: key})
if err == fuse.ENOENT {
if err == syscall.ENOENT {
err = nil
}
return
Expand Down Expand Up @@ -439,7 +438,7 @@ func (b *ADLv2) listBlobs(param *ListBlobsInput, maxResults *int32) (adl2PathLis

func (b *ADLv2) ListBlobs(param *ListBlobsInput) (*ListBlobsOutput, error) {
if param.Delimiter != nil && *param.Delimiter != "/" {
return nil, fuse.EINVAL
return nil, syscall.EINVAL
}

var maxResults *int32
Expand All @@ -449,7 +448,7 @@ func (b *ADLv2) ListBlobs(param *ListBlobsInput) (*ListBlobsOutput, error) {

res, err := b.listBlobs(param, maxResults)
if err != nil {
if err == fuse.ENOENT {
if err == syscall.ENOENT {
return &ListBlobsOutput{
RequestId: res.Response.Response.Header.Get(ADL2_REQUEST_ID),
}, nil
Expand Down Expand Up @@ -724,7 +723,7 @@ func (b *ADLv2) PutBlob(param *PutBlobInput) (*PutBlobOutput, error) {
func (b *ADLv2) MultipartBlobBegin(param *MultipartBlobBeginInput) (*MultipartBlobCommitInput, error) {
leaseId := uuid.New().String()
err := b.lease(adl2.Acquire, param.Key, leaseId, 60, "")
if err == fuse.ENOENT {
if err == syscall.ENOENT {
// the file didn't exist, we will create the file
// first and then acquire the lease
create, err := b.create(param.Key, adl2.File, param.ContentType, param.Metadata, "")
Expand Down
23 changes: 11 additions & 12 deletions internal/backend_azblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/Azure/azure-storage-blob-go/azblob"

"github.com/google/uuid"
"github.com/jacobsa/fuse"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -305,7 +304,7 @@ func (b *AZBlob) updateToken() (*azblob.ContainerURL, error) {
u, err := url.Parse(sUrl)
if err != nil {
azbLog.Errorf("Unable to construct service URL: %v", sUrl)
return nil, fuse.EINVAL
return nil, syscall.EINVAL
}

serviceURL := azblob.NewServiceURL(*u, b.pipeline)
Expand All @@ -325,7 +324,7 @@ func (b *AZBlob) testBucket(key string) (err error) {
_, err = b.HeadBlob(&HeadBlobInput{Key: key})
if err != nil {
err = mapAZBError(err)
if err == fuse.ENOENT {
if err == syscall.ENOENT {
err = nil
}
}
Expand Down Expand Up @@ -353,7 +352,7 @@ func mapAZBError(err error) error {
case azblob.ServiceCodeBlobAlreadyExists:
return syscall.EACCES
case azblob.ServiceCodeBlobNotFound:
return fuse.ENOENT
return syscall.ENOENT
case azblob.ServiceCodeContainerAlreadyExists:
return syscall.EEXIST
case azblob.ServiceCodeContainerBeingDeleted:
Expand All @@ -363,17 +362,17 @@ func mapAZBError(err error) error {
case azblob.ServiceCodeContainerNotFound:
return syscall.ENODEV
case azblob.ServiceCodeCopyAcrossAccountsNotSupported:
return fuse.EINVAL
return syscall.EINVAL
case azblob.ServiceCodeSourceConditionNotMet:
return fuse.EINVAL
return syscall.EINVAL
case azblob.ServiceCodeSystemInUse:
return syscall.EAGAIN
case azblob.ServiceCodeTargetConditionNotMet:
return fuse.EINVAL
return syscall.EINVAL
case azblob.ServiceCodeBlobBeingRehydrated:
return syscall.EAGAIN
case azblob.ServiceCodeBlobArchived:
return fuse.EINVAL
return syscall.EINVAL
case azblob.ServiceCodeAccountBeingCreated:
return syscall.EAGAIN
case azblob.ServiceCodeAuthenticationFailed:
Expand All @@ -387,7 +386,7 @@ func mapAZBError(err error) error {
case azblob.ServiceCodeOperationTimedOut:
return syscall.EAGAIN
case azblob.ServiceCodeResourceNotFound:
return fuse.ENOENT
return syscall.ENOENT
case azblob.ServiceCodeServerBusy:
return syscall.EAGAIN
case "AuthorizationFailure": // from Azurite emulator
Expand Down Expand Up @@ -426,7 +425,7 @@ func (b *AZBlob) HeadBlob(param *HeadBlobInput) (*HeadBlobOutput, error) {
if err == nil {
if !dirBlob.IsDirBlob {
// we requested for a dir suffix, but this isn't one
err = fuse.ENOENT
err = syscall.ENOENT
}
}
return dirBlob, err
Expand Down Expand Up @@ -604,7 +603,7 @@ func (b *AZBlob) ListBlobs(param *ListBlobsInput) (*ListBlobsOutput, error) {
*dirBlob.Key += "/"
items = append(items, dirBlob.BlobItemOutput)
sortItems = true
} else if err == fuse.ENOENT {
} else if err == syscall.ENOENT {
err = nil
} else {
return nil, err
Expand Down Expand Up @@ -672,7 +671,7 @@ func (b *AZBlob) DeleteBlobs(param *DeleteBlobsInput) (ret *DeleteBlobsOutput, d
_, err := b.DeleteBlob(&DeleteBlobInput{key})
if err != nil {
err = mapAZBError(err)
if err != fuse.ENOENT {
if err != syscall.ENOENT {
deleteError = err
}
}
Expand Down
3 changes: 1 addition & 2 deletions internal/backend_gcs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"sync"
"syscall"

"github.com/jacobsa/fuse"
"cloud.google.com/go/storage"
"google.golang.org/api/iterator"
)
Expand Down Expand Up @@ -135,7 +134,7 @@ func (s *GCS3) DeleteBlobs(param *DeleteBlobsInput) (*DeleteBlobsOutput, error)
_, err := s.DeleteBlob(&DeleteBlobInput{
Key: key,
})
if err != nil && err != fuse.ENOENT {
if err != nil && err != syscall.ENOENT {
overallErr = err
}
wg.Done()
Expand Down
10 changes: 4 additions & 6 deletions internal/backend_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/s3"

"github.com/jacobsa/fuse"
)

type S3Backend struct {
Expand Down Expand Up @@ -323,7 +321,7 @@ func (s *S3Backend) detectBucketLocationByHEAD() (err error, isAws bool) {
s.awsConfig.Endpoint = aws.String("")
}
case 400:
err = fuse.EINVAL
err = syscall.EINVAL
case 403:
err = syscall.EACCES
case 404:
Expand Down Expand Up @@ -351,7 +349,7 @@ func (s *S3Backend) detectBucketLocationByHEAD() (err error, isAws bool) {
func (s *S3Backend) testBucket(key string) (err error) {
_, err = s.HeadBlob(&HeadBlobInput{Key: key})
if err != nil {
if mapAwsError(err) == fuse.ENOENT {
if mapAwsError(err) == syscall.ENOENT {
err = nil
}
}
Expand All @@ -361,7 +359,7 @@ func (s *S3Backend) testBucket(key string) (err error) {

func (s *S3Backend) fallbackV2Signer() (err error) {
if s.v2Signer {
return fuse.EINVAL
return syscall.EINVAL
}

s3Log.Infoln("Falling back to v2 signer")
Expand Down Expand Up @@ -399,7 +397,7 @@ func (s *S3Backend) Init(key string) error {
// swift3, ceph-s3 returns 400
// Amplidata just gives up and return 500
code := mapAwsError(err)
if code == syscall.EACCES || code == fuse.EINVAL || code == syscall.EAGAIN {
if code == syscall.EACCES || code == syscall.EINVAL || code == syscall.EAGAIN {
err = s.fallbackV2Signer()
if err != nil {
return err
Expand Down
Loading

0 comments on commit 41eac99

Please sign in to comment.