示例#1
0
文件: node.go 项目: rizki96/kakigoori
func (f *AzukiFile) Truncate(size uint64) fuse.Status {
	f.lock.Lock()
	r := fuse.ToStatus(syscall.Ftruncate(int(f.File.Fd()), int64(size)))
	f.lock.Unlock()
	go event.Notify(event.Trunc, f.File.Name())
	return r
}
示例#2
0
文件: node.go 项目: rizki96/kakigoori
func (f *AzukiFile) Chown(uid uint32, gid uint32) fuse.Status {
	f.lock.Lock()
	r := fuse.ToStatus(f.File.Chown(int(uid), int(gid)))
	f.lock.Unlock()
	go event.Notify(event.Chown, f.File.Name())
	return r
}
示例#3
0
文件: node.go 项目: rizki96/kakigoori
func (f *AzukiFile) Read(buf []byte, off int64) (res fuse.ReadResult, code fuse.Status) {
	f.lock.Lock()
	r := fuse.ReadResultFd(f.File.Fd(), off, len(buf))
	f.lock.Unlock()
	go event.Notify(event.Read, f.File.Name())
	return r, fuse.OK
}
示例#4
0
文件: node.go 项目: rizki96/kakigoori
func (f *AzukiFile) Write(data []byte, off int64) (uint32, fuse.Status) {
	f.lock.Lock()
	n, err := f.File.WriteAt(data, off)
	f.lock.Unlock()
	go event.Notify(event.Write, f.File.Name())
	return uint32(n), fuse.ToStatus(err)
}
示例#5
0
文件: node.go 项目: rizki96/kakigoori
func (f *AzukiFile) Fsync(flags int) (code fuse.Status) {
	f.lock.Lock()
	r := fuse.ToStatus(syscall.Fsync(int(f.File.Fd())))
	f.lock.Unlock()
	go event.Notify(event.Fsync, f.File.Name())
	return r
}
示例#6
0
文件: node.go 项目: rizki96/kakigoori
func (f *AzukiFile) Chmod(mode uint32) fuse.Status {
	f.lock.Lock()
	r := fuse.ToStatus(f.File.Chmod(os.FileMode(mode)))
	f.lock.Unlock()
	go event.Notify(event.Chmod, f.File.Name())
	return r
}
示例#7
0
func (fs *KakigooriFileSystem) Rename(oldPath string, newPath string, context *fuse.Context) (codee fuse.Status) {
	fullOldPath := fs.GetPath(oldPath)
	fullNewPath := fs.GetPath(newPath)
	err := os.Rename(fullOldPath, fullNewPath)
	go event.Notify(event.Rename, fmt.Sprintf("%s -> %s", fullOldPath, fullNewPath))
	return fuse.ToStatus(err)
}
示例#8
0
func (fs *KakigooriFileSystem) Open(name string, flags uint32, context *fuse.Context) (fuseFile nodefs.File, status fuse.Status) {
	fullPath := fs.GetPath(name)
	f, err := os.OpenFile(fullPath, int(flags), 0)
	if err != nil {
		return nil, fuse.ToStatus(err)
	}
	go event.Notify(event.Open, fullPath)
	return NewAzukiFile(f), fuse.OK
}
示例#9
0
文件: node.go 项目: rizki96/kakigoori
func (f *AzukiFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
	f.lock.Lock()
	err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz))
	f.lock.Unlock()
	if err != nil {
		return fuse.ToStatus(err)
	}
	go event.Notify(event.Fallocate, f.File.Name())
	return fuse.OK
}
示例#10
0
func (fs *KakigooriFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) {
	fullPath := fs.GetPath(name)
	f, err := os.Open(fullPath)
	if err != nil {
		return nil, fuse.ToStatus(err)
	}
	want := 500
	output := make([]fuse.DirEntry, 0, want)
	for {
		infos, err := f.Readdir(want)
		for i := range infos {
			// workaround for https://code.google.com/p/go/issues/detail?id=5960
			if infos[i] == nil {
				continue
			}
			n := infos[i].Name()
			d := fuse.DirEntry{
				Name: n,
			}
			if s := fuse.ToStatT(infos[i]); s != nil {
				d.Mode = uint32(s.Mode)
			} else {
				log.Printf("ReadDir entry %q for %q has no stat info", n, name)
			}
			output = append(output, d)
		}
		if len(infos) < want || err == io.EOF {
			break
		}
		if err != nil {
			log.Println("Readdir() returned err:", err)
			break
		}
	}
	f.Close()
	go event.Notify(event.OpenDir, fullPath)
	return output, fuse.OK
}
示例#11
0
文件: node.go 项目: rizki96/kakigoori
func (f *AzukiFile) Release() {
	go event.Notify(event.Close, f.File.Name())
	f.lock.Lock()
	f.File.Close()
	f.lock.Unlock()
}
示例#12
0
func (fs *KakigooriFileSystem) Readlink(name string, context *fuse.Context) (out string, code fuse.Status) {
	fullPath := fs.GetPath(name)
	f, err := os.Readlink(fullPath)
	go event.Notify(event.Readlink, fullPath)
	return f, fuse.ToStatus(err)
}
示例#13
0
func (fs *KakigooriFileSystem) Link(orig string, newName string, context *fuse.Context) (code fuse.Status) {
	fullOrig := fs.GetPath(orig)
	fullNewName := fs.GetPath(newName)
	go event.Notify(event.Link, fmt.Sprintf("%s -> %s", fullOrig, fullNewName))
	return fuse.ToStatus(os.Link(fullOrig, fullNewName))
}
示例#14
0
func (fs *KakigooriFileSystem) Symlink(pointedTo string, linkName string, context *fuse.Context) (code fuse.Status) {
	fullPath := fs.GetPath(pointedTo)
	linkPath := fs.GetPath(linkName)
	go event.Notify(event.Symlink, fmt.Sprintf("%s -> %s", fullPath, linkPath))
	return fuse.ToStatus(os.Symlink(pointedTo, linkPath))
}
示例#15
0
func (fs *KakigooriFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) {
	fullPath := fs.GetPath(name)
	go event.Notify(event.Rmdir, fullPath)
	return fuse.ToStatus(syscall.Rmdir(fullPath))
}
示例#16
0
func (fs *KakigooriFileSystem) Mkdir(path string, mode uint32, context *fuse.Context) (code fuse.Status) {
	fullPath := fs.GetPath(path)
	go event.Notify(event.Mkdir, fullPath)
	return fuse.ToStatus(os.Mkdir(fullPath, os.FileMode(mode)))
}
示例#17
0
func (fs *KakigooriFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) (code fuse.Status) {
	fullPath := fs.GetPath(name)
	go event.Notify(event.Mknod, fullPath)
	return fuse.ToStatus(syscall.Mknod(fullPath, mode, int(dev)))
}
示例#18
0
func (fs *KakigooriFileSystem) Chown(path string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) {
	fullPath := fs.GetPath(path)
	go event.Notify(event.Chown, fullPath)
	return fuse.ToStatus(os.Chown(fullPath, int(uid), int(gid)))
}
示例#19
0
func (fs *KakigooriFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) {
	fullPath := fs.GetPath(name)
	go event.Notify(event.Access, fullPath)
	return fuse.ToStatus(syscall.Access(fullPath, mode))
}
示例#20
0
func (fs *KakigooriFileSystem) Truncate(path string, offset uint64, context *fuse.Context) (code fuse.Status) {
	fullPath := fs.GetPath(path)
	go event.Notify(event.Trunc, fullPath)
	return fuse.ToStatus(os.Truncate(fullPath, int64(offset)))
}
示例#21
0
func (fs *KakigooriFileSystem) Create(path string, flags uint32, mode uint32, context *fuse.Context) (fuseFile nodefs.File, code fuse.Status) {
	fullPath := fs.GetPath(path)
	f, err := os.OpenFile(fullPath, int(flags)|os.O_CREATE, os.FileMode(mode))
	go event.Notify(event.Create, fullPath)
	return NewAzukiFile(f), fuse.ToStatus(err)
}
示例#22
0
func (fs *KakigooriFileSystem) Chmod(path string, mode uint32, context *fuse.Context) (code fuse.Status) {
	fullPath := fs.GetPath(path)
	err := os.Chmod(fullPath, os.FileMode(mode))
	go event.Notify(event.Chmod, fullPath)
	return fuse.ToStatus(err)
}