예제 #1
0
func (f *fs) handleMkdir(r *fuse.MkdirRequest) {
	log.Println("Inside handleMkdir")
	log.Println(r)
	resp := &fuse.MkdirResponse{}

	m, err := f.rpc.api.MkDir(f.getContext(), &pb.MkDirRequest{Name: r.Name, Parent: uint64(r.Node), Attr: &pb.Attr{Uid: r.Uid, Gid: r.Gid, Mode: uint32(r.Mode)}})
	if err != nil {
		log.Printf("Mkdir failed(%s): %s", r.Name, err)
		r.RespondError(fuse.EIO)
		return
	}
	// If the name is empty, then the dir already exists
	if m.Name != r.Name {
		log.Printf("EEXIST Mkdir(%s)", r.Name)
		r.RespondError(fuse.EEXIST)
		return
	}
	resp.Node = fuse.NodeID(m.Attr.Inode)
	copyAttr(&resp.Attr, m.Attr)
	resp.Attr.Valid = attrValidTime
	resp.EntryValid = entryValidTime

	log.Println(resp)
	r.Respond(resp)
}
예제 #2
0
func (f *fs) handleLookup(r *fuse.LookupRequest) {
	log.Println("Inside handleLookup")
	log.Printf("Running Lookup for %s", r.Name)
	log.Println(r)
	resp := &fuse.LookupResponse{}

	l, err := f.rpc.api.Lookup(f.getContext(), &pb.LookupRequest{Name: r.Name, Parent: uint64(r.Node)})

	if err != nil {
		log.Printf("Lookup failed(%s): %s", r.Name, err)
		r.RespondError(fuse.EIO)
		return
	}
	// If there is no name then it wasn't found
	if l.Name != r.Name {
		log.Printf("ENOENT Lookup(%s)", r.Name)
		r.RespondError(fuse.ENOENT)
		return
	}
	resp.Node = fuse.NodeID(l.Attr.Inode)
	copyAttr(&resp.Attr, l.Attr)
	// TODO: should we make these configureable?
	resp.Attr.Valid = attrValidTime
	resp.EntryValid = entryValidTime

	log.Println(resp)
	r.Respond(resp)
}
예제 #3
0
func (f *fs) handleSymlink(r *fuse.SymlinkRequest) {
	log.Println("Inside handleSymlink")
	log.Println(r)
	resp := &fuse.SymlinkResponse{}
	symlink, err := f.rpc.api.Symlink(f.getContext(), &pb.SymlinkRequest{Parent: uint64(r.Node), Name: r.NewName, Target: r.Target, Uid: r.Uid, Gid: r.Gid})
	if err != nil {
		log.Printf("Symlink failed: %s", err)
		r.RespondError(fuse.EIO)
		return
	}
	resp.Node = fuse.NodeID(symlink.Attr.Inode)
	copyAttr(&resp.Attr, symlink.Attr)
	resp.Attr.Valid = attrValidTime
	resp.EntryValid = entryValidTime
	log.Println(resp)
	r.Respond(resp)
}
예제 #4
0
func (f *fs) handleCreate(r *fuse.CreateRequest) {
	log.Println("Inside handleCreate")
	log.Println(r)
	resp := &fuse.CreateResponse{}
	c, err := f.rpc.api.Create(f.getContext(), &pb.CreateRequest{Parent: uint64(r.Node), Name: r.Name, Attr: &pb.Attr{Uid: r.Uid, Gid: r.Gid, Mode: uint32(r.Mode)}})
	if err != nil {
		log.Printf("Failed to create file: %s", err)
		r.RespondError(fuse.EIO)
		return
	}
	resp.Node = fuse.NodeID(c.Attr.Inode)
	copyAttr(&resp.Attr, c.Attr)
	resp.EntryValid = entryValidTime
	resp.Attr.Valid = attrValidTime
	copyAttr(&resp.LookupResponse.Attr, c.Attr)
	resp.LookupResponse.EntryValid = entryValidTime
	resp.LookupResponse.Attr.Valid = attrValidTime
	r.Respond(resp)
}