From 41eac9973168224cc0fb297af03d32660a9150ee Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Mon, 29 May 2023 13:35:06 +0300 Subject: [PATCH] Remove unneeded fuse.E*** dependencies (use syscall.E***) --- internal/backend.go | 7 ++- internal/backend_adlv1.go | 19 ++++---- internal/backend_adlv2.go | 9 ++-- internal/backend_azblob.go | 23 +++++----- internal/backend_gcs3.go | 3 +- internal/backend_s3.go | 10 ++--- internal/dir.go | 29 ++++++------ internal/file.go | 28 ++++++------ internal/goofys.go | 18 ++++---- internal/goofys_test.go | 92 +++++++++++++++++++------------------- internal/handles.go | 6 +-- main.go | 2 +- 12 files changed, 118 insertions(+), 128 deletions(-) diff --git a/internal/backend.go b/internal/backend.go index b58e0c91..28822b98 100644 --- a/internal/backend.go +++ b/internal/backend.go @@ -21,9 +21,8 @@ import ( "io/ioutil" "strings" "sync" + "syscall" "time" - - "github.com/jacobsa/fuse" ) type Capabilities struct { @@ -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 } } @@ -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 } } diff --git a/internal/backend_adlv1.go b/internal/backend_adlv1.go index 5e4e33d1..08650632 100644 --- a/internal/backend_adlv1.go +++ b/internal/backend_adlv1.go @@ -28,7 +28,6 @@ import ( "syscall" "time" - "github.com/jacobsa/fuse" uuid "github.com/satori/go.uuid" "github.com/sirupsen/logrus" @@ -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 @@ -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 } @@ -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 @@ -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" { @@ -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 @@ -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)) @@ -670,7 +669,7 @@ 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 @@ -678,7 +677,7 @@ func (b *ADLv1) RemoveBucket(param *RemoveBucketInput) (*RemoveBucketOutput, err func (b *ADLv1) MakeBucket(param *MakeBucketInput) (*MakeBucketOutput, error) { if b.bucket == "" { - return nil, fuse.EINVAL + return nil, syscall.EINVAL } err := b.mkdir("") @@ -697,7 +696,7 @@ func (b *ADLv1) mkdir(dir string) error { return err } if !*res.OperationResult { - return fuse.EEXIST + return syscall.EEXIST } return nil } diff --git a/internal/backend_adlv2.go b/internal/backend_adlv2.go index 85fdfbf4..fe4cac40 100644 --- a/internal/backend_adlv2.go +++ b/internal/backend_adlv2.go @@ -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" @@ -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 @@ -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 @@ -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 @@ -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, "") diff --git a/internal/backend_azblob.go b/internal/backend_azblob.go index 8745ad8e..ac6c2256 100644 --- a/internal/backend_azblob.go +++ b/internal/backend_azblob.go @@ -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" ) @@ -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) @@ -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 } } @@ -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: @@ -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: @@ -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 @@ -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 @@ -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 @@ -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 } } diff --git a/internal/backend_gcs3.go b/internal/backend_gcs3.go index b5308b1b..1129bd15 100644 --- a/internal/backend_gcs3.go +++ b/internal/backend_gcs3.go @@ -23,7 +23,6 @@ import ( "sync" "syscall" - "github.com/jacobsa/fuse" "cloud.google.com/go/storage" "google.golang.org/api/iterator" ) @@ -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() diff --git a/internal/backend_s3.go b/internal/backend_s3.go index 807c984f..8fa2927a 100644 --- a/internal/backend_s3.go +++ b/internal/backend_s3.go @@ -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 { @@ -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: @@ -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 } } @@ -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") @@ -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 diff --git a/internal/dir.go b/internal/dir.go index c10f1b92..347c6909 100644 --- a/internal/dir.go +++ b/internal/dir.go @@ -27,7 +27,6 @@ import ( "github.com/aws/aws-sdk-go/aws" - "github.com/jacobsa/fuse" "github.com/jacobsa/fuse/fuseops" "github.com/jacobsa/fuse/fuseutil" ) @@ -1039,7 +1038,7 @@ func (inode *Inode) SendDelete() { inode.mu.Lock() atomic.AddInt64(&inode.Parent.fs.activeFlushers, -1) inode.IsFlushing -= inode.fs.flags.MaxParallelParts - if mapAwsError(err) == fuse.ENOENT { + if mapAwsError(err) == syscall.ENOENT { // object is already deleted err = nil } @@ -1255,7 +1254,7 @@ func (inode *Inode) ReadSymlink() (target string, err error) { defer inode.mu.Unlock() if inode.userMetadata[inode.fs.flags.SymlinkAttr] == nil { - return "", fuse.EIO + return "", syscall.EIO } return string(inode.userMetadata[inode.fs.flags.SymlinkAttr]), nil @@ -1351,7 +1350,7 @@ func (parent *Inode) RmDir(name string) (err error) { parent.mu.Unlock() if inode != nil { if !inode.isDir() { - return fuse.ENOTDIR + return syscall.ENOTDIR } dh := NewDirHandle(inode) @@ -1363,7 +1362,7 @@ func (parent *Inode) RmDir(name string) (err error) { } if en != nil { fuseLog.Debugf("Directory %v not empty: still has entry \"%v\"", inode.FullName(), en.Name) - return fuse.ENOTEMPTY + return syscall.ENOTEMPTY } parent.mu.Lock() @@ -1419,7 +1418,7 @@ func (parent *Inode) Rename(from string, newParent *Inode, to string) (err error toCloud, toPath := newParent.cloud() if fromCloud != toCloud { // cannot rename across cloud backend - err = fuse.EINVAL + err = syscall.EINVAL return } @@ -1427,21 +1426,21 @@ func (parent *Inode) Rename(from string, newParent *Inode, to string) (err error fromInode := parent.findChildUnlocked(from) toInode := newParent.findChildUnlocked(to) if fromInode == nil { - return fuse.ENOENT + return syscall.ENOENT } fromInode.mu.Lock() defer fromInode.mu.Unlock() if toInode != nil { if fromInode.isDir() { if !toInode.isDir() { - return fuse.ENOTDIR + return syscall.ENOTDIR } toEmpty, err := toInode.isEmptyDir() if err != nil { return err } if !toEmpty { - return fuse.ENOTEMPTY + return syscall.ENOTEMPTY } } else if toInode.isDir() { return syscall.EISDIR @@ -1800,7 +1799,7 @@ func (parent *Inode) LookUpInodeMaybeDir(name string) (*BlobItemOutput, error) { } if parent.fs.flags.Cheap { <- results - if mapAwsError(objectError) != fuse.ENOENT { + if mapAwsError(objectError) != syscall.ENOENT { break } } @@ -1813,7 +1812,7 @@ func (parent *Inode) LookUpInodeMaybeDir(name string) (*BlobItemOutput, error) { }() if parent.fs.flags.Cheap { <- results - if mapAwsError(dirError) != fuse.ENOENT { + if mapAwsError(dirError) != syscall.ENOENT { break } } @@ -1859,14 +1858,14 @@ func (parent *Inode) LookUpInodeMaybeDir(name string) (*BlobItemOutput, error) { } } - if objectError != nil && mapAwsError(objectError) != fuse.ENOENT { + if objectError != nil && mapAwsError(objectError) != syscall.ENOENT { return nil, objectError } - if dirError != nil && mapAwsError(dirError) != fuse.ENOENT { + if dirError != nil && mapAwsError(dirError) != syscall.ENOENT { return nil, dirError } - if prefixError != nil && mapAwsError(prefixError) != fuse.ENOENT { + if prefixError != nil && mapAwsError(prefixError) != syscall.ENOENT { return nil, prefixError } - return nil, fuse.ENOENT + return nil, syscall.ENOENT } diff --git a/internal/file.go b/internal/file.go index ba7a80f3..d16043f8 100644 --- a/internal/file.go +++ b/internal/file.go @@ -25,8 +25,6 @@ import ( "sync/atomic" "syscall" "time" - - "github.com/jacobsa/fuse" ) type FileHandle struct { @@ -465,7 +463,7 @@ func (fh *FileHandle) WriteFile(offset int64, data []byte, copyData bool) (err e // Oops, it's a deleted file. We don't support changing invisible files fh.inode.fs.bufferPool.Use(-int64(len(data)), false) fh.inode.mu.Unlock() - return fuse.ENOENT + return syscall.ENOENT } fh.inode.checkPauseWriters() @@ -818,7 +816,7 @@ func (inode *Inode) LoadRange(offset uint64, size uint64, readAheadSize uint64, // One of the buffers disappeared => read error requestErr = inode.readError if requestErr == nil { - requestErr = fuse.EIO + requestErr = syscall.EIO } return } @@ -833,7 +831,7 @@ func (inode *Inode) LoadRange(offset uint64, size uint64, readAheadSize uint64, // One of the buffers disappeared => read error requestErr = inode.readError if requestErr == nil { - requestErr = fuse.EIO + requestErr = syscall.EIO } return } @@ -1092,7 +1090,7 @@ func (fh *FileHandle) ReadFile(sOffset int64, sLen int64) (data [][]byte, bytesR mappedErr := mapAwsError(requestErr) if requestErr != nil { err = requestErr - if mappedErr == fuse.ENOENT || mappedErr == syscall.ERANGE { + if mappedErr == syscall.ENOENT || mappedErr == syscall.ERANGE { // Object is deleted or resized remotely (416). Discard local version log.Warnf("File %v is deleted or resized remotely, discarding local changes", fh.inode.FullName()) fh.inode.resetCache() @@ -1118,7 +1116,7 @@ func (fh *FileHandle) ReadFile(sOffset int64, sLen int64) (data [][]byte, bytesR } else { err = requestErr if err == nil { - err = fuse.EIO + err = syscall.EIO } return } @@ -1146,7 +1144,7 @@ func (fh *FileHandle) ReadFile(sOffset int64, sLen int64) (data [][]byte, bytesR } else { err = requestErr if err == nil { - err = fuse.EIO + err = syscall.EIO } return } @@ -1336,10 +1334,10 @@ func (inode *Inode) SendUpload() bool { // Rename the old directory object to copy xattrs from it if it has them // We're almost never sure if the directory is implicit or not so we // always try to rename the directory object, but ignore NotFound errors - if mappedErr == fuse.ENOENT && skipRename { + if mappedErr == syscall.ENOENT && skipRename { err = nil notFoundIgnore = true - } else if mappedErr == fuse.ENOENT || mappedErr == syscall.ERANGE { + } else if mappedErr == syscall.ENOENT || mappedErr == syscall.ERANGE { s3Log.Warnf("Conflict detected (inode %v): failed to copy %v to %v: %v. File is removed remotely, dropping cache", inode.Id, from, key, err) inode.mu.Lock() newParent := inode.Parent @@ -1484,7 +1482,7 @@ func (inode *Inode) SendUpload() bool { if err != nil { mappedErr := mapAwsError(err) inode.userMetadataDirty = 2 - if mappedErr == fuse.ENOENT || mappedErr == syscall.ERANGE { + if mappedErr == syscall.ENOENT || mappedErr == syscall.ERANGE { // Object is deleted or resized remotely (416). Discard local version s3Log.Warnf("Conflict detected (inode %v): File %v is deleted or resized remotely, discarding local changes", inode.Id, inode.FullName()) inode.resetCache() @@ -1728,7 +1726,7 @@ func (inode *Inode) FlushSmallObject() { if inode.CacheState == ST_MODIFIED { _, err := inode.LoadRange(0, sz, 0, true) mappedErr := mapAwsError(err) - if mappedErr == fuse.ENOENT || mappedErr == syscall.ERANGE { + if mappedErr == syscall.ENOENT || mappedErr == syscall.ERANGE { // Object is deleted or resized remotely (416). Discard local version s3Log.Warnf("Conflict detected (inode %v): File %v is deleted or resized remotely, discarding local changes", inode.Id, inode.FullName()) inode.resetCache() @@ -1867,7 +1865,7 @@ func (inode *Inode) copyUnmodifiedParts(numParts uint64) (err error) { if inode.mpu == nil { // Upload was canceled (file deleted) inode.mu.Unlock() - err = fuse.ENOENT + err = syscall.ENOENT } else { inode.mu.Unlock() log.Debugf("Copying unmodified range %v-%v MB of object %v", @@ -1926,7 +1924,7 @@ func (inode *Inode) FlushPart(part uint64) { return } mappedErr := mapAwsError(err) - if mappedErr == fuse.ENOENT || mappedErr == syscall.ERANGE { + if mappedErr == syscall.ENOENT || mappedErr == syscall.ERANGE { // Object is deleted or resized remotely (416). Discard local version s3Log.Warnf("Conflict detected (inode %v): File %v is deleted or resized remotely, discarding local changes", inode.Id, inode.FullName()) inode.resetCache() @@ -2010,7 +2008,7 @@ func (inode *Inode) completeMultipart() { return } mappedErr := mapAwsError(err) - if mappedErr == fuse.ENOENT || mappedErr == syscall.ERANGE { + if mappedErr == syscall.ENOENT || mappedErr == syscall.ERANGE { // Object is deleted or resized remotely (416). Discard local version s3Log.Warnf("Conflict detected (inode %v): File %v is deleted or resized remotely, discarding local changes", inode.Id, inode.FullName()) inode.resetCache() diff --git a/internal/goofys.go b/internal/goofys.go index be5f5a4d..d2a4c1b2 100644 --- a/internal/goofys.go +++ b/internal/goofys.go @@ -966,7 +966,7 @@ func (fs *Goofys) SetXattr(ctx context.Context, if fs.connection != nil { // Send notifications from another goroutine to prevent deadlocks go func() { - if mappedErr == fuse.ENOENT { + if mappedErr == syscall.ENOENT { fs.connection.Notify(&fuseops.NotifyDelete{ Parent: parentId, Child: inodeId, @@ -980,7 +980,7 @@ func (fs *Goofys) SetXattr(ctx context.Context, } }() } - if mappedErr == fuse.ENOENT { + if mappedErr == syscall.ENOENT { // We don't mind if the file disappeared return nil } @@ -1038,13 +1038,13 @@ func (fs *Goofys) ReadSymlink(ctx context.Context, func mapHttpError(status int) error { switch status { case 400: - return fuse.EINVAL + return syscall.EINVAL case 401: return syscall.EACCES case 403: return syscall.EACCES case 404: - return fuse.ENOENT + return syscall.ENOENT case 405: return syscall.ENOTSUP case http.StatusConflict: @@ -1073,7 +1073,7 @@ func mapAwsError(err error) error { case "NoSuchBucket": return syscall.ENXIO case "BucketAlreadyOwnedByYou": - return fuse.EEXIST + return syscall.EEXIST } if reqErr, ok := err.(awserr.RequestFailure); ok { @@ -1157,13 +1157,13 @@ func (fs *Goofys) LookUpInode( if _, ok := parent.dir.DeletedChildren[op.Name]; ok { // File is deleted locally parent.mu.Unlock() - return fuse.ENOENT + return syscall.ENOENT } } if !expired(parent.dir.DirTime, fs.flags.StatCacheTTL) { // Don't recheck from the server if directory cache is actual parent.mu.Unlock() - return fuse.ENOENT + return syscall.ENOENT } } parent.mu.Unlock() @@ -1175,7 +1175,7 @@ func (fs *Goofys) LookUpInode( return } if inode == nil { - return fuse.ENOENT + return syscall.ENOENT } } @@ -1736,7 +1736,7 @@ func (fs *Goofys) SetInodeAttributes( if inode.CacheState == ST_DELETED || inode.CacheState == ST_DEAD { // Oops, it's a deleted file. We don't support changing invisible files inode.mu.Unlock() - return fuse.ENOENT + return syscall.ENOENT } } diff --git a/internal/goofys_test.go b/internal/goofys_test.go index 3ae4b406..861d05f2 100644 --- a/internal/goofys_test.go +++ b/internal/goofys_test.go @@ -810,7 +810,7 @@ func (s *GoofysTest) TestLookUpInode(t *C) { t.Assert(err, IsNil) _, err = s.LookUpInode(t, "fileNotFound") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) _, err = s.LookUpInode(t, "dir1/file3") t.Assert(err, IsNil) @@ -969,7 +969,7 @@ func (s *GoofysTest) TestReadDirWithExternalChanges(t *C) { s.assertHasEntries(t, s.getRoot(t), newEntries) _, err = s.LookUpInode(t, "file1") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) s.setupBlobs(s.cloud, t, map[string]*string{"file1": nil, "dir1/file3": nil}) s.removeBlob(s.cloud, t, "file3") @@ -1108,7 +1108,7 @@ func (s *GoofysTest) TestUnlink(t *C) { // make sure that it's gone from s3 _, err = s.cloud.GetBlob(&GetBlobInput{Key: fileName}) - t.Assert(mapAwsError(err), Equals, fuse.ENOENT) + t.Assert(mapAwsError(err), Equals, syscall.ENOENT) } type FileHandleReader struct { @@ -1156,7 +1156,7 @@ func (s *GoofysTest) testCreateAndWrite(t *C, fileName string, size int64, write } err := s.fs.LookUpInode(nil, &lookup) if err != nil { - if err == fuse.ENOENT { + if err == syscall.ENOENT { create := fuseops.CreateFileOp{ Parent: root.Id, Name: fileName, @@ -1364,12 +1364,12 @@ func (s *GoofysTest) TestMkDir(t *C) { err := inode.Unlink(fileName) t.Assert(err, IsNil) } else { - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) } err = s.getRoot(t).RmDir(dirName) t.Assert(err, IsNil) } else { - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) } inode, err = s.getRoot(t).MkDir(dirName) @@ -1402,12 +1402,12 @@ func (s *GoofysTest) TestRmDir(t *C) { _, err = s.LookUpInode(t, "test_rmdir/dir1") t.Assert(err, IsNil) err = root.RmDir("dir1") - t.Assert(err, Equals, fuse.ENOTEMPTY) + t.Assert(err, Equals, syscall.ENOTEMPTY) _, err = s.LookUpInode(t, "test_rmdir/dir2") t.Assert(err, IsNil) err = root.RmDir("dir2") - t.Assert(err, Equals, fuse.ENOTEMPTY) + t.Assert(err, Equals, syscall.ENOTEMPTY) _, err = s.LookUpInode(t, "test_rmdir/empty_dir") t.Assert(err, IsNil) @@ -1440,7 +1440,7 @@ func (s *GoofysTest) TestRenamePreserveMetadata(t *C) { toInode, err := s.LookUpInode(t, to) if err != nil { - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) } else { err = root.Unlink(to) t.Assert(err, IsNil) @@ -1521,11 +1521,11 @@ func (s *GoofysTest) TestRenameOpenedUnmodified(t *C) { var fh *FileHandle in, err := s.LookUpInode(t, "file20") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) in, err = s.LookUpInode(t, "file10") - t.Assert(err == nil || err == fuse.ENOENT, Equals, true) - if err == fuse.ENOENT { + t.Assert(err == nil || err == syscall.ENOENT, Equals, true) + if err == syscall.ENOENT { op := &fuseops.CreateFileOp{ Parent: root.Id, Name: "file10", @@ -1559,7 +1559,7 @@ func (s *GoofysTest) TestRenameOpenedUnmodified(t *C) { // Check that the file is actually renamed _, err = s.cloud.HeadBlob(&HeadBlobInput{Key: "file10"}) t.Assert(err, NotNil) - t.Assert(mapAwsError(err), Equals, fuse.ENOENT) + t.Assert(mapAwsError(err), Equals, syscall.ENOENT) _, err = s.cloud.HeadBlob(&HeadBlobInput{Key: "file20"}) t.Assert(err, IsNil) } @@ -1745,7 +1745,7 @@ func (s *GoofysTest) TestRenameDir(t *C) { t.Assert(err, IsNil) err = root.Rename("empty_dir", root, "dir1") - t.Assert(err, Equals, fuse.ENOTEMPTY) + t.Assert(err, Equals, syscall.ENOTEMPTY) err = root.Rename("empty_dir", root, "new_dir") t.Assert(err, IsNil) @@ -1756,7 +1756,7 @@ func (s *GoofysTest) TestRenameDir(t *C) { oldId := dir2.Id _, err = s.LookUpInode(t, "new_dir2") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) err = s.fs.Rename(nil, &fuseops.RenameOp{ OldParent: root.Id, @@ -1767,13 +1767,13 @@ func (s *GoofysTest) TestRenameDir(t *C) { t.Assert(err, IsNil) _, err = s.LookUpInode(t, "dir2/dir3") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) _, err = s.LookUpInode(t, "dir2/dir3/file4") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) _, err = s.LookUpInode(t, "dir2") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) new_dir2, err := s.LookUpInode(t, "new_dir2") t.Assert(err, IsNil) @@ -1785,7 +1785,7 @@ func (s *GoofysTest) TestRenameDir(t *C) { t.Assert(old, NotNil) _, err = s.LookUpInode(t, "new_dir3") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) err = s.fs.Rename(nil, &fuseops.RenameOp{ OldParent: root.Id, @@ -1801,10 +1801,10 @@ func (s *GoofysTest) TestRenameDir(t *C) { t.Assert(old.Id, Equals, new.Id) _, err = s.LookUpInode(t, "new_dir2/dir3") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) _, err = s.LookUpInode(t, "new_dir2/dir3/file4") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) } func (s *GoofysTest) TestRename(t *C) { @@ -1816,7 +1816,7 @@ func (s *GoofysTest) TestRename(t *C) { _, err = s.LookUpInode(t, to) t.Assert(err, IsNil) err = root.Rename(from, root, to) - t.Assert(err, Equals, fuse.ENOTDIR) + t.Assert(err, Equals, syscall.ENOTDIR) from, to = "file1", "empty_dir" _, err = s.LookUpInode(t, from) @@ -1831,7 +1831,7 @@ func (s *GoofysTest) TestRename(t *C) { t.Assert(err, IsNil) _, err = s.LookUpInode(t, to) if err != nil { - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) } err = root.Rename(from, root, to) t.Assert(err, IsNil) @@ -1844,7 +1844,7 @@ func (s *GoofysTest) TestRename(t *C) { t.Assert(err, IsNil) _, err = s.cloud.HeadBlob(&HeadBlobInput{Key: from}) - t.Assert(mapAwsError(err), Equals, fuse.ENOENT) + t.Assert(mapAwsError(err), Equals, syscall.ENOENT) from, to = "file3", "new_file2" dir, _ := s.LookUpInode(t, "dir1") @@ -1852,7 +1852,7 @@ func (s *GoofysTest) TestRename(t *C) { t.Assert(err, IsNil) _, err = s.LookUpInode(t, to) if err != nil { - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) } err = dir.Rename(from, root, to) t.Assert(err, IsNil) @@ -1865,11 +1865,11 @@ func (s *GoofysTest) TestRename(t *C) { t.Assert(err, IsNil) _, err = s.cloud.HeadBlob(&HeadBlobInput{Key: from}) - t.Assert(mapAwsError(err), Equals, fuse.ENOENT) + t.Assert(mapAwsError(err), Equals, syscall.ENOENT) from, to = "no_such_file", "new_file" err = root.Rename(from, root, to) - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) if s3, ok := s.cloud.Delegate().(*S3Backend); ok { if !hasEnv("GCS") { @@ -2080,7 +2080,7 @@ func (s *GoofysTest) testExplicitDir(t *C) { t.Assert(err, IsNil) _, err = s.LookUpInode(t, "fileNotFound") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) _, err = s.LookUpInode(t, "dir4/file5") t.Assert(err, IsNil) @@ -2236,7 +2236,7 @@ func (s *GoofysTest) TestPutMimeType(t *C) { t.Assert(err, IsNil) _, err = s.LookUpInode(t, file) if err != nil { - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) } err = root.Rename(jpg, root, file) t.Assert(err, IsNil) @@ -2250,7 +2250,7 @@ func (s *GoofysTest) TestPutMimeType(t *C) { _, err = s.LookUpInode(t, jpg2) if err != nil { - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) } err = root.Rename(file, root, jpg2) t.Assert(err, IsNil) @@ -2295,7 +2295,7 @@ func (s *GoofysTest) TestRenameCache(t *C) { t.Assert(err, IsNil) err = s.fs.LookUpInode(nil, &lookupOp2) - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) renameOp := fuseops.RenameOp{ OldParent: root.Id, @@ -2311,7 +2311,7 @@ func (s *GoofysTest) TestRenameCache(t *C) { lookupOp2.Entry = fuseops.ChildInodeEntry{} err = s.fs.LookUpInode(nil, &lookupOp1) - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) err = s.fs.LookUpInode(nil, &lookupOp2) t.Assert(err, IsNil) @@ -2483,7 +2483,7 @@ func (s *GoofysTest) TestIssue162(t *C) { t.Assert(err, IsNil) toInode, err := s.LookUpInode(t, "dir1/myfile.jpg") if err != nil { - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) } else { err = s.getRoot(t).Unlink("dir1/myfile.jpg") t.Assert(err, IsNil) @@ -2722,7 +2722,7 @@ func (s *GoofysTest) TestXAttrCopied(t *C) { _, err = s.LookUpInode(t, "file0") if err != nil { - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) } err = root.Rename("file1", root, "file0") @@ -2939,7 +2939,7 @@ func (s *GoofysTest) TestCreateRenameBeforeCloseFuse(t *C) { t.Assert(err, NotNil) pathErr, ok := err.(*os.PathError) t.Assert(ok, Equals, true) - t.Assert(pathErr.Err, Equals, fuse.ENOENT) + t.Assert(pathErr.Err, Equals, syscall.ENOENT) content, err := ioutil.ReadFile(to) t.Assert(err, IsNil) @@ -2981,7 +2981,7 @@ func (s *GoofysTest) TestRenameBeforeCloseFuse(t *C) { t.Assert(err, NotNil) pathErr, ok := err.(*os.PathError) t.Assert(ok, Equals, true) - t.Assert(pathErr.Err, Equals, fuse.ENOENT) + t.Assert(pathErr.Err, Equals, syscall.ENOENT) content, err := ioutil.ReadFile(to) t.Assert(err, IsNil) @@ -3754,7 +3754,7 @@ func (s *GoofysTest) TestVFS(t *C) { // the mount would shadow dir4/file5 _, err = in.LookUp("file5", false) - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) _, fh := in.Create("testfile") err = fh.inode.SyncFile() @@ -3805,7 +3805,7 @@ func (s *GoofysTest) TestVFS(t *C) { t.Assert(err, IsNil) _, err = cloud2.GetBlob(&GetBlobInput{Key: "cloud2Prefix/subdir/testfile2"}) - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) resp, err = cloud2.GetBlob(&GetBlobInput{Key: "cloud2Prefix/testfile2"}) t.Assert(err, IsNil) @@ -3815,7 +3815,7 @@ func (s *GoofysTest) TestVFS(t *C) { t.Assert(err, IsNil) _, err = cloud2.GetBlob(&GetBlobInput{Key: "cloud2Prefix/testfile2"}) - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) resp, err = cloud2.GetBlob(&GetBlobInput{Key: "cloud2Prefix/subdir/testfile2"}) t.Assert(err, IsNil) @@ -3874,7 +3874,7 @@ func (s *GoofysTest) TestMountsNewDir(t *C) { s.clearPrefix(t, s.cloud, "dir5") _, err := s.LookUpInode(t, "dir5") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) s.fs.MountAll([]*Mount{ &Mount{"dir5/cloud1", s.cloud, "", false}, @@ -3911,7 +3911,7 @@ func (s *GoofysTest) TestMountsNewMounts(t *C) { t.Assert(c1.dir.cloud == cloud, Equals, true) _, err = s.LookUpInode(t, "dir4/cloud2") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) s.fs.MountAll([]*Mount{ &Mount{"dir4/cloud1", cloud, "", false}, @@ -3976,14 +3976,14 @@ func (s *GoofysTest) TestMountsError(t *C) { t.Assert(errfile.isDir(), Equals, false) _, err = s.LookUpInode(t, "dir4/newerror/not_there") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) errfile, err = s.LookUpInode(t, "dir4/initerror/"+INIT_ERR_BLOB) t.Assert(err, IsNil) t.Assert(errfile.isDir(), Equals, false) _, err = s.LookUpInode(t, "dir4/initerror/not_there") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) in, err := s.LookUpInode(t, "dir4/initerror") t.Assert(err, IsNil) @@ -4050,7 +4050,7 @@ func (s *GoofysTest) testMountsNested(t *C, cloud StorageBackend, s.clearPrefix(t, cloud, "test_nested") _, err := s.LookUpInode(t, "dir5") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) s.fs.MountAll(mounts) @@ -4079,7 +4079,7 @@ func (s *GoofysTest) testMountsNested(t *C, cloud StorageBackend, t.Assert(dir_dir.dir.cloud == cloud, Equals, true) _, err = s.LookUpInode(t, "dir5/in/testfile") - t.Assert(err, Equals, fuse.ENOENT) + t.Assert(err, Equals, syscall.ENOENT) _, fh := dir_in.Create("testfile") err = fh.inode.SyncFile() t.Assert(err, IsNil) @@ -4575,7 +4575,7 @@ func (s *GoofysTest) testReadMyOwnWriteFuse(t *C, externalUpdate bool) { // return the mtime, so the open above will think the // file is updated and not re-use cache if _, adlv1 := s.cloud.(*ADLv1); !adlv1 { - cloud.err = fuse.EINVAL + cloud.err = syscall.EINVAL } } else { // if there was externalUpdate, we wrote our own diff --git a/internal/handles.go b/internal/handles.go index b6220e12..b25a214f 100644 --- a/internal/handles.go +++ b/internal/handles.go @@ -538,7 +538,7 @@ func (inode *Inode) fillXattr() (err error) { inode.mu.Lock() if err != nil { err = mapAwsError(err) - if err == fuse.ENOENT { + if err == syscall.ENOENT { err = nil if inode.isDir() { inode.ImplicitDir = true @@ -624,7 +624,7 @@ func (inode *Inode) SetXattr(name string, value []byte, flags uint32) error { if inode.CacheState == ST_DELETED || inode.CacheState == ST_DEAD { // Oops, it's a deleted file. We don't support changing invisible files - return fuse.ENOENT + return syscall.ENOENT } meta, name, err := inode.getXattrMap(name, true) @@ -662,7 +662,7 @@ func (inode *Inode) RemoveXattr(name string) error { if inode.CacheState == ST_DELETED || inode.CacheState == ST_DEAD { // Oops, it's a deleted file. We don't support changing invisible files - return fuse.ENOENT + return syscall.ENOENT } meta, name, err := inode.getXattrMap(name, true) diff --git a/main.go b/main.go index 16bf509f..2bbb69ee 100644 --- a/main.go +++ b/main.go @@ -205,7 +205,7 @@ func main() { if waitedForSignal == syscall.SIGUSR1 { return } else { - return fuse.EINVAL + return syscall.EINVAL } } else { // kill our own waiting goroutine