github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/libdokan/emptyfs.go (about) 1 // Copyright 2016 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package libdokan 6 7 import ( 8 "time" 9 10 "github.com/keybase/client/go/kbfs/dokan" 11 "github.com/keybase/client/go/kbfs/dokan/winacl" 12 "golang.org/x/net/context" 13 ) 14 15 // Return dokan.ErrAccessDenied by default as that is a safe default. 16 17 type emptyFile struct{} 18 19 func (t emptyFile) Cleanup(ctx context.Context, fi *dokan.FileInfo) { 20 } 21 func (t emptyFile) CloseFile(ctx context.Context, fi *dokan.FileInfo) { 22 } 23 func (t emptyFile) SetEndOfFile(ctx context.Context, fi *dokan.FileInfo, length int64) error { 24 return dokan.ErrAccessDenied 25 } 26 func (t emptyFile) SetAllocationSize(ctx context.Context, fi *dokan.FileInfo, length int64) error { 27 return dokan.ErrAccessDenied 28 } 29 func (t emptyFile) ReadFile(ctx context.Context, fi *dokan.FileInfo, bs []byte, offset int64) (int, error) { 30 return 0, dokan.ErrAccessDenied 31 } 32 func (t emptyFile) WriteFile(ctx context.Context, fi *dokan.FileInfo, bs []byte, offset int64) (int, error) { 33 return 0, dokan.ErrAccessDenied 34 } 35 func (t emptyFile) FlushFileBuffers(ctx context.Context, fi *dokan.FileInfo) error { 36 return dokan.ErrAccessDenied 37 } 38 func (t emptyFile) FindFiles(ctx context.Context, fi *dokan.FileInfo, ignored string, cb func(*dokan.NamedStat) error) error { 39 return dokan.ErrAccessDenied 40 } 41 func (t emptyFile) SetFileTime(context.Context, *dokan.FileInfo, time.Time, time.Time, time.Time) error { 42 return dokan.ErrAccessDenied 43 } 44 func (t emptyFile) SetFileAttributes(ctx context.Context, fi *dokan.FileInfo, fileAttributes dokan.FileAttribute) error { 45 return dokan.ErrAccessDenied 46 } 47 func (t emptyFile) LockFile(ctx context.Context, fi *dokan.FileInfo, offset int64, length int64) error { 48 return dokan.ErrAccessDenied 49 } 50 func (t emptyFile) UnlockFile(ctx context.Context, fi *dokan.FileInfo, offset int64, length int64) error { 51 return dokan.ErrAccessDenied 52 } 53 func (t emptyFile) CanDeleteFile(ctx context.Context, fi *dokan.FileInfo) error { 54 return dokan.ErrAccessDenied 55 } 56 func (t emptyFile) CanDeleteDirectory(ctx context.Context, fi *dokan.FileInfo) error { 57 return dokan.ErrAccessDenied 58 } 59 func (t emptyFile) GetFileSecurity(ctx context.Context, fi *dokan.FileInfo, si winacl.SecurityInformation, sd *winacl.SecurityDescriptor) error { 60 if si&winacl.OwnerSecurityInformation != 0 && currentUserSID != nil { 61 sd.SetOwner(currentUserSID) 62 } 63 if si&winacl.GroupSecurityInformation != 0 && currentGroupSID != nil { 64 sd.SetGroup(currentGroupSID) 65 } 66 if si&winacl.DACLSecurityInformation != 0 { 67 var acl winacl.ACL 68 acl.AddAllowAccess(0x001F01FF, currentUserSID) 69 sd.SetDacl(&acl) 70 } 71 return nil 72 } 73 func (t emptyFile) SetFileSecurity(ctx context.Context, fi *dokan.FileInfo, si winacl.SecurityInformation, sd *winacl.SecurityDescriptor) error { 74 return dokan.ErrAccessDenied 75 }