예제 #1
0
파일: bench_test.go 프로젝트: ringtail/fuse
func (f benchFile) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
	if f.conf.directIO {
		resp.Flags |= fuse.OpenDirectIO
	}
	// TODO configurable?
	resp.Flags |= fuse.OpenKeepCache
	return f, nil
}
예제 #2
0
func (f benchFile) Open(req *fuse.OpenRequest, resp *fuse.OpenResponse, intr fs.Intr) (fs.Handle, fuse.Error) {
	if f.conf.directIO {
		resp.Flags |= fuse.OpenDirectIO
	}
	// TODO configurable?
	resp.Flags |= fuse.OpenKeepCache
	return f, nil
}
예제 #3
0
파일: file.go 프로젝트: conductant/gohm
func (f *File) Open(c context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
	defer log.Debugln("open:", f.dir.path, f.name, "resp=", resp, "flags=", resp.Flags)

	resp.Flags =
		fuse.OpenDirectIO | // git gives bus error when this is set
			fuse.OpenNonSeekable |
			fuse.OpenPurgeAttr |
			fuse.OpenPurgeUBC

	if req.Flags.IsReadOnly() {
		// we don't need to track read-only handles
		return f, nil
	}

	f.mu.Lock()
	defer f.mu.Unlock()

	if f.writers == 0 {
		// load data
		fn := func(b []byte) {
			f.data = append([]byte(nil), b...)
		}
		if err := f.load(c, fn); err != nil {
			return nil, err
		}
	}

	f.writers++

	return f, nil
}
예제 #4
0
파일: clockfs.go 프로젝트: read-later/fuse
func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
	if !req.Flags.IsReadOnly() {
		return nil, fuse.Errno(syscall.EACCES)
	}
	resp.Flags |= fuse.OpenKeepCache
	return f, nil
}
예제 #5
0
파일: ro.go 프로젝트: camlistore/camlistore
// Empirically:
//  open for read:   req.Flags == 0
//  open for append: req.Flags == 1
//  open for write:  req.Flags == 1
//  open for read/write (+<)   == 2 (bitmask? of?)
//
// open flags are O_WRONLY (1), O_RDONLY (0), or O_RDWR (2). and also
// bitmaks of O_SYMLINK (0x200000) maybe. (from
// fuse_filehandle_xlate_to_oflags in macosx/kext/fuse_file.h)
func (n *roFile) Open(ctx context.Context, req *fuse.OpenRequest, res *fuse.OpenResponse) (fs.Handle, error) {
	roFileOpen.Incr()

	if isWriteFlags(req.Flags) {
		return nil, fuse.EPERM
	}

	log.Printf("roFile.Open: %v: content: %v dir=%v flags=%v", n.permanode, n.content, req.Dir, req.Flags)
	r, err := schema.NewFileReader(n.fs.fetcher, n.content)
	if err != nil {
		roFileOpenError.Incr()
		log.Printf("roFile.Open: %v", err)
		return nil, fuse.EIO
	}

	// Turn off the OpenDirectIO bit (on by default in rsc fuse server.go),
	// else append operations don't work for some reason.
	res.Flags &= ^fuse.OpenDirectIO

	// Read-only.
	nod := &node{
		fs:      n.fs,
		blobref: n.content,
	}
	return &nodeReader{n: nod, fr: r}, nil
}
예제 #6
0
// Responds on FUSE Open request for a file inside zip archive
func (this *ZipFile) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
	contentStream, err := this.zipFile.Open()
	if err != nil {
		return nil, err
	}
	// reporting to FUSE that the stream isn't seekable
	resp.Flags |= fuse.OpenNonSeekable
	return NewZipFileHandle(contentStream), nil
}
예제 #7
0
// Open implements the fs.NodeOpener interface for SpecialReadFile.
func (f *SpecialReadFile) Open(ctx context.Context, req *fuse.OpenRequest,
	resp *fuse.OpenResponse) (fs.Handle, error) {
	data, _, err := f.read(ctx)
	if err != nil {
		return nil, err
	}

	resp.Flags |= fuse.OpenDirectIO
	return fs.DataHandle(data), nil
}
예제 #8
0
파일: file.go 프로젝트: read-later/bazil
func (f *file) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
	// allow kernel to use buffer cache
	resp.Flags &^= fuse.OpenDirectIO
	f.mu.Lock()
	defer f.mu.Unlock()
	tmp := f.handles + 1
	if tmp == 0 {
		return nil, fuse.Errno(syscall.ENFILE)
	}
	f.handles = tmp
	return f, nil
}
예제 #9
0
// Open the file for read or write
func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fusefs.Handle, error) {
	// if o is nil it isn't valid yet
	o, err := f.waitForValidObject()
	if err != nil {
		return nil, err
	}

	fs.Debug(o, "File.Open")

	switch {
	case req.Flags.IsReadOnly():
		if noSeek {
			resp.Flags |= fuse.OpenNonSeekable
		}
		return newReadFileHandle(o)
	case req.Flags.IsWriteOnly():
		resp.Flags |= fuse.OpenNonSeekable
		src := newCreateInfo(f.d.f, o.Remote())
		fh, err := newWriteFileHandle(f.d, f, src)
		if err != nil {
			return nil, err
		}
		return fh, nil
	case req.Flags.IsReadWrite():
		return nil, errors.New("can't open read and write")
	}

	/*
	   // File was opened in append-only mode, all writes will go to end
	   // of file. OS X does not provide this information.
	   OpenAppend    OpenFlags = syscall.O_APPEND
	   OpenCreate    OpenFlags = syscall.O_CREAT
	   OpenDirectory OpenFlags = syscall.O_DIRECTORY
	   OpenExclusive OpenFlags = syscall.O_EXCL
	   OpenNonblock  OpenFlags = syscall.O_NONBLOCK
	   OpenSync      OpenFlags = syscall.O_SYNC
	   OpenTruncate  OpenFlags = syscall.O_TRUNC
	*/
	return nil, errors.New("can't figure out how to open")
}
예제 #10
0
파일: file.go 프로젝트: rfjakob/cluefs
func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fusefs.Handle, error) {
	op := NewOpenOp(req, f.path)
	defer trace(op)
	newfile := NewFile(f.parent, f.name, f.fs)
	size, err := newfile.doOpen(f.path, req.Flags)
	if err != nil {
		return nil, err
	}
	resp.Handle = newfile.handleID
	op.FileSize = size
	op.BlockSize = newfile.blksize
	return newfile, nil
}
예제 #11
0
파일: fs.go 프로젝트: bwester/consulfs
// Open implements the NodeOpener interface. It is called the first time a file is opened
// by any process. Further opens or FD duplications will reuse this handle. When all FDs
// have been closed, Release() will be called.
func (file *consulFile) Open(
	ctx context.Context,
	req *fuse.OpenRequest,
	resp *fuse.OpenResponse,
) (fs.Handle, error) {
	// Using the DirectIO flag disables the kernel buffer cache. *Every* read and write
	// will be passed directly to this module. This gives the module greater control over
	// the file's consistency model.
	resp.Flags |= fuse.OpenDirectIO
	file.Mutex.Lock()
	defer file.Mutex.Unlock()
	file.IsOpen = true
	return file, nil
}
예제 #12
0
파일: dir.go 프로젝트: rfjakob/cluefs
func (d *Dir) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fusefs.Handle, error) {
	op := NewOpenOp(req, d.path)
	defer trace(op)
	newdir := NewDir(d.parent, d.name, d.fs)
	size, err := newdir.doOpen(d.path, req.Flags)
	if err != nil {
		return nil, err
	}
	newdir.SetProcessInfo(req.Header)
	resp.Handle = newdir.handleID
	op.FileSize = size
	op.BlockSize = newdir.blksize
	return newdir, nil
}
예제 #13
0
파일: file.go 프로젝트: funkygao/gafka
func (f *File) Open(ctx context.Context, req *fuse.OpenRequest,
	resp *fuse.OpenResponse) (fs.Handle, error) {
	log.Trace("File Open, req=%#v, topic=%s, partitionId=%d", req,
		f.topic, f.partitionId)

	// Allow kernel to use buffer cache
	resp.Flags &^= fuse.OpenDirectIO
	f.opened = true
	f.closeCh = make(chan struct{})

	go f.readContent()
	time.Sleep(time.Second * 2) // TODO

	return f, nil
}
예제 #14
0
파일: file.go 프로젝트: ryanstout/mirrorfs
func (file *File) Open(req *fuse.OpenRequest, res *fuse.OpenResponse, intr fs.Intr) (fs.Handle, fuse.Error) {
	fmt.Printf("Open with: %d - %d\n", req.Flags, int(req.Flags))

	// Allow kernel to use buffer cache
	res.Flags &^= fuse.OpenDirectIO

	fsHandle, err := os.OpenFile(file.Path, int(req.Flags), 0)

	handle := &FileHandle{fsHandle, file}

	if err != nil {
		return nil, err
	}

	return handle, nil
}
예제 #15
0
func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
	glog.Infof("Entered Open with file name: %s.\n", f.name)

	if f.name == ".description" {
		return &FileHandle{r: nil, f: f}, nil
	}

	if f.name[0] == '.' {
		return nil, fuse.EPERM
	}

	if runtime.GOOS == "darwin" {
		resp.Flags |= fuse.OpenDirectIO
	}

	if req.Flags.IsReadOnly() {
		glog.Info("Open: File requested is read only.\n")
	}
	if req.Flags.IsReadWrite() {
		glog.Info("Open: File requested is read write.\n")
	}
	if req.Flags.IsWriteOnly() {
		glog.Info("Open: File requested is write only.\n")
	}

	var err error
	var songPath string
	if f.artist == "drop" {
		songPath, err = store.GetDropFilePath(f.name, f.mPoint)
		PushFileItem(*f, DelayedVoid)
	} else if f.artist == "playlists" {
		songPath, err = store.GetPlaylistFilePath(f.album, f.name, f.mPoint)
		PushFileItem(*f, DelayedVoid)
	} else {
		songPath, err = store.GetFilePath(f.artist, f.album, f.name)
	}
	if err != nil {
		glog.Error(err)
		return nil, err
	}

	r, err := os.OpenFile(songPath, int(req.Flags), 0666)
	if err != nil {
		return nil, err
	}
	return &FileHandle{r: r, f: f}, nil
}
예제 #16
0
func (f *file) Open(ctx context.Context, request *fuse.OpenRequest, response *fuse.OpenResponse) (_ fs.Handle, retErr error) {
	defer func() {
		if retErr == nil {
			protolion.Debug(&FileOpen{&f.Node, errorToString(retErr)})
		} else {
			protolion.Error(&FileOpen{&f.Node, errorToString(retErr)})
		}
	}()
	response.Flags |= fuse.OpenDirectIO | fuse.OpenNonSeekable
	fileInfo, err := f.fs.apiClient.InspectFileUnsafe(
		f.File.Commit.Repo.Name,
		f.File.Commit.ID,
		f.File.Path,
		f.fs.getFromCommitID(f.getRepoOrAliasName()),
		f.Shard,
		f.fs.handleID,
	)
	if err != nil {
		return nil, err
	}
	return f.newHandle(int(fileInfo.SizeBytes)), nil
}
예제 #17
0
파일: stat.go 프로젝트: chenchun/cgroupfs
func (sf StatFile) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
	resp.Flags |= fuse.OpenDirectIO
	return sf, nil
}
예제 #18
0
func (ds DiskStatsFile) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fusefs.Handle, error) {
	resp.Flags |= fuse.OpenDirectIO
	return ds, nil
}
예제 #19
0
파일: main.go 프로젝트: orivej/ghfs
func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
	resp.Flags |= fuse.OpenNonSeekable
	return &FileHandle{r: base64.NewDecoder(base64.StdEncoding, strings.NewReader(*f.Content.Content))}, nil
}
예제 #20
0
파일: file.go 프로젝트: voidException/bazil
func (f *file) Open(req *fuse.OpenRequest, resp *fuse.OpenResponse, intr fs.Intr) (fs.Handle, fuse.Error) {
	// allow kernel to use buffer cache
	resp.Flags &^= fuse.OpenDirectIO
	return f, nil
}
예제 #21
0
func (ci CpuInfoFile) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
	resp.Flags |= fuse.OpenDirectIO
	return ci, nil
}
예제 #22
0
func (f directRead) Open(req *fuse.OpenRequest, resp *fuse.OpenResponse, intr fs.Intr) (fs.Handle, fuse.Error) {
	// do not allow the kernel to use page cache
	resp.Flags |= fuse.OpenDirectIO
	return f, nil
}
예제 #23
0
func (s *stat) Open(ctx context.Context, req *fuse.OpenRequest, res *fuse.OpenResponse) (fs.Handle, error) {
	// Set DirectIO to keep this file from being cached in OS X's kernel.
	res.Flags |= fuse.OpenDirectIO
	return s, nil
}