fsal_status_t tank_setextattr_value(struct fsal_obj_handle *obj_hdl, const char *xattr_name, caddr_t buffer_addr, size_t buffer_size, int create) { struct zfs_fsal_obj_handle *obj_handle = NULL; int rc = 0; creden_t cred; obj_handle = container_of(obj_hdl, struct zfs_fsal_obj_handle, obj_handle); /* remove final '\n', if any */ chomp_attr_value((char *)buffer_addr, buffer_size); cred.uid = op_ctx->creds->caller_uid; cred.gid = op_ctx->creds->caller_gid; rc = libzfswrap_setxattr(ZFSFSAL_GetVFS(obj_handle->handle), &cred, obj_handle->handle->zfs_handle, xattr_name, buffer_addr); if (rc != 0) return fsalstat(posix2fsal_error(rc), rc); else return fsalstat(ERR_FSAL_NO_ERROR, 0); }
fsal_status_t ZFSFSAL_SetXAttrValue(fsal_handle_t * obj_handle, /* IN */ const fsal_name_t * xattr_name, /* IN */ fsal_op_context_t * p_context, /* IN */ caddr_t buffer_addr, /* IN */ size_t buffer_size, /* IN */ int create /* IN */ ) { //@TODO: use the create parameter ? int rc; creden_t cred; zfsfsal_handle_t * p_objecthandle = (zfsfsal_handle_t *)obj_handle; /* Hook to prevent any modification in the snapshots */ if(p_objecthandle->data.i_snap != 0) Return(ERR_FSAL_ROFS, 0, INDEX_FSAL_SetXAttrValue); /* Remove trailing '\n', if any */ chomp_attr_value((char*)buffer_addr, buffer_size); cred.uid = p_context->credential.user; cred.gid = p_context->credential.group; TakeTokenFSCall(); rc = libzfswrap_setxattr(((zfsfsal_op_context_t *)p_context)->export_context->p_vfs, &cred, p_objecthandle->data.zfs_handle, xattr_name->name, (char*)buffer_addr); ReleaseTokenFSCall(); if(rc) Return(posix2fsal_error(rc), 0, INDEX_FSAL_SetXAttrValue); Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_SetXAttrValue); }