Beispiel #1
0
// Getxattr fetches the contents a named extended attribute. The name doesn't have to have
// been returned by a previous Listxattr().
func (file *consulFile) Getxattr(
	ctx context.Context,
	req *fuse.GetxattrRequest,
	resp *fuse.GetxattrResponse,
) error {
	var data []byte
	var err error
	switch req.Name {
	case "session":
		data, err = file.readSession(ctx)
	default:
		err = fuse.ErrNoXattr
	}
	if err != nil {
		return err
	}
	// OSXFUSE returns an "[Errno 34] Result too large" error the userspace process when
	// this method attempts to return an empty data set, so it's easier to pretend the
	// xattr never existed.
	if len(data) == 0 {
		return fuse.ErrNoXattr
	}
	if req.Position >= uint32(len(data)) {
		data = nil
	} else {
		data = data[req.Position:]
	}
	if req.Size != 0 && uint32(len(data)) > req.Size {
		data = data[:req.Size]
	}
	resp.Xattr = data
	return nil
}
Beispiel #2
0
/** Xattr ops.
 */
func (x *IdNode) Getxattr(ctx context.Context, req *f.GetxattrRequest, resp *f.GetxattrResponse) error {
	logD("Getxattr", "path", x.Path, "xattr", req.Name)
	bytes := xattr.Get(string(x.Path), req.Name)
	if bytes != nil {
		resp.Xattr = bytes
	}
	return nil
}
Beispiel #3
0
// Getxattr retrieves extended attributes of an object node.
func (o *Object) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error {
	if !Xattr {
		return fuse.ENOTSUP
	}

	key := canonicalHeaderKey(objectMetaHeaderXattr + req.Name)
	value, err := hex.DecodeString(o.sh[key])
	if err != nil {
		return err
	}

	resp.Xattr = []byte(value)
	return nil
}
Beispiel #4
0
func (n *Node) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error {
	defer trace(NewGetxattrOp(req, n.path))
	size, err := syscallx.Getxattr(n.path, req.Name, []byte{})
	if err != nil || size <= 0 {
		return fuse.ErrNoXattr
	}
	buffer := make([]byte, size)
	size, err = syscallx.Getxattr(n.path, req.Name, buffer)
	if err != nil {
		return osErrorToFuseError(err)
	}
	resp.Xattr = buffer
	return nil
}
Beispiel #5
0
func (x *xattr) get(req *fuse.GetxattrRequest, res *fuse.GetxattrResponse) error {
	x.mu.Lock()
	defer x.mu.Unlock()

	val, found := (*x.xattrs)[req.Name]

	if !found {
		return fuse.ErrNoXattr
	}

	res.Xattr = val

	return nil
}
Beispiel #6
0
func (file *File) Getxattr(req *fuse.GetxattrRequest, res *fuse.GetxattrResponse, intr fs.Intr) fuse.Error {
	// return fuse.EPERM
	// fmt.Printf("Get attr: %s\n", req.Name)

	buf := make([]byte, 8192)
	size, err := syscallx.Getxattr(file.Path, req.Name, buf)

	if err != nil {
		// fmt.Printf("Get xattr error: %s - %s: \n", file.Path, req.Name, err)
		// return err
		// On osx, we need to return NOATTR, but this isn't built into go or bazil.org/fuse, so we need to do this:
		return fuse.Errno(93)
	}

	res.Xattr = buf[:size]

	return nil
}
Beispiel #7
0
func (f *getxattrSize) Getxattr(req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse, intr fs.Intr) fuse.Error {
	resp.Xattr = []byte("hello, world")
	return nil
}