func NewCFile(client *client.Client, name string) nodefs.File { f := new(CFile) f.client = client f.File = nodefs.NewDefaultFile() f.name = name return f }
func (rfs *ReverseFS) newVirtualFile(content []byte, parentFile string) (nodefs.File, fuse.Status) { return &virtualFile{ File: nodefs.NewDefaultFile(), content: content, parentFile: parentFile, ino: rfs.inoGen.next(), }, fuse.OK }
func (n *blobNode) LoadMemory() (nodefs.File, error) { blob, err := n.fs.repo.LookupBlob(n.id) if err != nil { return nil, err } return &memoryFile{ File: nodefs.NewDefaultFile(), blob: blob, }, nil }
func (n *folderNode) Create(name string, flags uint32, mode uint32, context *fuse.Context) (nodefs.File, *nodefs.Inode, fuse.Status) { if !n.fetch() { return nil, nil, fuse.EIO } obj := mtp.ObjectInfo{ StorageID: n.StorageID(), Filename: name, ObjectFormat: mtp.OFC_Undefined, ModificationDate: time.Now(), ParentObject: n.Handle(), CompressedSize: 0, } var file nodefs.File var fsNode nodefs.Node if n.fs.options.Android { _, _, handle, err := n.fs.dev.SendObjectInfo(n.StorageID(), n.Handle(), &obj) if err != nil { log.Println("SendObjectInfo failed", err) return nil, nil, fuse.EIO } err = n.fs.dev.SendObject(&bytes.Buffer{}, 0) if err != nil { log.Println("SendObject failed:", err) return nil, nil, fuse.EIO } aNode := &androidNode{ mtpNodeImpl: mtpNodeImpl{ Node: nodefs.NewDefaultNode(), obj: &obj, fs: n.fs, handle: handle, }, } if !aNode.startEdit() { return nil, nil, fuse.EIO } file = &androidFile{ File: nodefs.NewDefaultFile(), node: aNode, } fsNode = aNode } else { var err error file, fsNode, err = n.fs.createClassicFile(obj) if err != nil { return nil, nil, fuse.ToStatus(err) } } return file, n.Inode().NewChild(name, false, fsNode), fuse.OK }
func (m *MNode) Open(flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { m.obj.Lock() defer m.obj.Unlock() j,ok := m.obj.Obj.(*joinf.JoinFile) if !ok { return nil,fuse.EINVAL } if (flags&uint32(os.O_TRUNC))!=0 { e := j.Truncate(0) if e!=nil { return nil,fuse.ToStatus(e) } } return &MFile{nodefs.NewDefaultFile(),m.obj,j},fuse.OK }
// NewAdbFile returns a File that reads and writes to name on the device. // perms should be set from the existing file if it exists, or to the desired new permissions if new. func NewAdbFile(opts AdbFileOpenOptions) nodefs.File { logEntry := StartFileOperation("New", opts.FileBuffer.Path, fmt.Sprint(opts)) defer logEntry.FinishOperation() adbFile := &AdbFile{ // Log all the operations we don't implement. File: newLoggingFile(nodefs.NewDefaultFile(), opts.FileBuffer.Path), AdbFileOpenOptions: opts, } return nodefs.NewReadOnlyFile(adbFile) }
func NewObjectFile(name string, obj mapper.Object) *ObjectFile { f := &ObjectFile{ name: name, object: obj, lock: sync.Mutex{}, needUpload: false, File: nodefs.NewDefaultFile(), } return f }
func (fs *nomsFS) Open(path string, flags uint32, context *fuse.Context) (nodefs.File, fuse.Status) { fs.mdLock.Lock() defer fs.mdLock.Unlock() np, code := fs.getPath(path) if code != fuse.OK { return nil, code } nfile := nomsFile{ File: nodefs.NewDefaultFile(), fs: fs, node: np, } return nfile, fuse.OK }
func (fs *nomsFS) Create(path string, flags uint32, mode uint32, context *fuse.Context) (nodefs.File, fuse.Status) { fs.mdLock.Lock() defer fs.mdLock.Unlock() np, code := fs.createCommon(path, mode, func() types.Value { blob := types.NewEmptyBlob() return types.NewStructWithType(fileType, types.ValueSlice{fs.ds.Database().WriteValue(blob)}) }) if code != fuse.OK { return nil, code } nfile := nomsFile{ File: nodefs.NewDefaultFile(), fs: fs, node: np, } return nfile, fuse.OK }
func (fs *deviceFS) createClassicFile(obj mtp.ObjectInfo) (file nodefs.File, node nodefs.Node, err error) { backingFile, err := ioutil.TempFile(fs.options.Dir, "") cl := &classicNode{ mtpNodeImpl: mtpNodeImpl{ Node: nodefs.NewDefaultNode(), obj: &obj, fs: fs, }, dirty: true, backing: backingFile.Name(), } file = &pendingFile{ loopback: nodefs.NewLoopbackFile(backingFile), node: cl, File: nodefs.NewDefaultFile(), } node = cl return }
func (fs *objectFileSystem) Create(name string, flags uint32, mode uint32, context *fuse.Context) (nodefs.File, fuse.Status) { log.Debugf("Create: %s, flags: %d", name, flags) fs.lock.Lock() defer fs.lock.Unlock() // Add to mapper obj, err := fs.mapper.Create(name) if err != nil { log.Warnf("Can't append to mapper %v", err) return nodefs.NewDefaultFile(), fuse.EIO } file := NewObjectFile(name, obj) if err := file.OpenLocalFile(flags, mode); err != nil { log.Warnf("Create: OpenLocalFile() error %v", err) return file, fuse.EIO } return file, fuse.OK }
func (rfs *ReverseFS) newFile(relPath string, flags uint32) (nodefs.File, fuse.Status) { absPath, err := rfs.abs(rfs.decryptPath(relPath)) if err != nil { return nil, fuse.ToStatus(err) } fd, err := os.OpenFile(absPath, int(flags), 0666) if err != nil { return nil, fuse.ToStatus(err) } id := derivePathIV(relPath, ivPurposeFileID) header := contentenc.FileHeader{ Version: contentenc.CurrentVersion, ID: id, } return &reverseFile{ File: nodefs.NewDefaultFile(), fd: fd, header: header, block0IV: derivePathIV(relPath, ivPurposeBlock0IV), contentEnc: rfs.contentEnc, }, fuse.OK }
func (n *androidNode) Open(flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { return &androidFile{ node: n, File: nodefs.NewDefaultFile(), }, fuse.OK }
func NewOssFile(bucket string, fileName string, ossClient *oss.Client, lock *sync.Mutex, size int64, bufFile *BufFile) (ossFile *OssFile) { ossFile = &OssFile{bucket: bucket, fileName: fileName, ossClient: ossClient, lock: lock, size: size, bufFile: bufFile} ossFile.File = nodefs.NewDefaultFile() return ossFile }
func (n *classicNode) Open(flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status) { return &pendingFile{ File: nodefs.NewDefaultFile(), node: n, }, fuse.OK }
func newFile(s store.Store, kv *store.KVPair) nodefs.File { return &file{s, kv, nodefs.NewDefaultFile()} }
func NewFile() *MutableDataFile { return &MutableDataFile{File: nodefs.NewDefaultFile()} }
func (fs *DefaultReadFS) Open(name string, f uint32, context *fuse.Context) (nodefs.File, fuse.Status) { return nodefs.NewDefaultFile(), fuse.OK }
func (f *FileObj) Init() { f.File = nodefs.NewDefaultFile() }