コード例 #1
0
ファイル: nfs4_op_nverify.c プロジェクト: asias/nfs-ganesha
int nfs4_op_nverify(struct nfs_argop4 *op, compound_data_t *data,
		    struct nfs_resop4 *resp)
{
	NVERIFY4args * const arg_NVERIFY4 = &op->nfs_argop4_u.opnverify;
	NVERIFY4res * const res_NVERIFY4 = &resp->nfs_resop4_u.opnverify;
	fattr4 file_attr4;
	int rc = 0;

	resp->resop = NFS4_OP_NVERIFY;
	res_NVERIFY4->status = NFS4_OK;

	/* Do basic checks on a filehandle */
	res_NVERIFY4->status = nfs4_sanity_check_FH(data, NO_FILE_TYPE, false);

	if (res_NVERIFY4->status != NFS4_OK)
		return res_NVERIFY4->status;

	/* operation is always permitted on pseudofs */
	if (nfs4_Is_Fh_Pseudo(&(data->currentFH))) {
		res_NVERIFY4->status = NFS4_OK;
		return res_NVERIFY4->status;
	}

	/* Get only attributes that are allowed to be read */
	if (!nfs4_Fattr_Check_Access(&arg_NVERIFY4->obj_attributes,
				     FATTR4_ATTR_READ)) {
		res_NVERIFY4->status = NFS4ERR_INVAL;
		return res_NVERIFY4->status;
	}

	/* Ask only for supported attributes */
	if (!nfs4_Fattr_Supported(&arg_NVERIFY4->obj_attributes)) {
		res_NVERIFY4->status = NFS4ERR_ATTRNOTSUPP;
		return res_NVERIFY4->status;
	}

	res_NVERIFY4->status =
	    cache_entry_To_Fattr(data->current_entry,
				 &file_attr4,
				 data,
				 &(data->currentFH),
				 &(arg_NVERIFY4->obj_attributes.attrmask));

	if (res_NVERIFY4->status != NFS4_OK)
		return res_NVERIFY4->status;

	rc = nfs4_Fattr_cmp(&arg_NVERIFY4->obj_attributes, &file_attr4);

	if (rc == false) {
		res_NVERIFY4->status = NFS4_OK;
	} else {
		if (rc == -1)
			res_NVERIFY4->status = NFS4ERR_INVAL;
		else
			res_NVERIFY4->status = NFS4ERR_SAME;
	}

	nfs4_Fattr_Free(&file_attr4);
	return res_NVERIFY4->status;
}				/* nfs4_op_nverify */
コード例 #2
0
/**
 * @brief Gets attributes for an entry in the FSAL.
 *
 * Impelments the NFS4_OP_GETATTR operation, which gets attributes for
 * an entry in the FSAL.
 *
 * @param[in]     op   Arguments for nfs4_op
 * @param[in,out] data Compound request's data
 * @param[out]    resp Results for nfs4_op
 *
 * @return per RFC5661, p. 365
 *
 */
int nfs4_op_getattr(struct nfs_argop4 *op, compound_data_t *data,
		    struct nfs_resop4 *resp)
{
	GETATTR4args * const arg_GETATTR4 = &op->nfs_argop4_u.opgetattr;
	GETATTR4res * const res_GETATTR4 = &resp->nfs_resop4_u.opgetattr;

	/* This is a NFS4_OP_GETTAR */
	resp->resop = NFS4_OP_GETATTR;
	res_GETATTR4->status = NFS4_OK;

	/* Do basic checks on a filehandle */
	res_GETATTR4->status = nfs4_sanity_check_FH(data, NO_FILE_TYPE, false);

	if (res_GETATTR4->status != NFS4_OK)
		return res_GETATTR4->status;

	/* Sanity check: if no attributes are wanted, nothing is to be
	 * done.  In this case NFS4_OK is to be returned */
	if (arg_GETATTR4->attr_request.bitmap4_len == 0) {
		res_GETATTR4->status = NFS4_OK;
		return res_GETATTR4->status;
	}

	/* Get only attributes that are allowed to be read */
	if (!nfs4_Fattr_Check_Access_Bitmap(&arg_GETATTR4->attr_request,
					    FATTR4_ATTR_READ)) {
		res_GETATTR4->status = NFS4ERR_INVAL;
		return res_GETATTR4->status;
	}

	nfs4_bitmap4_Remove_Unsupported(&arg_GETATTR4->attr_request);

	res_GETATTR4->status =
		   cache_entry_To_Fattr(data->current_entry,
					&res_GETATTR4->GETATTR4res_u.resok4.
					obj_attributes,
					data,
					&data->currentFH,
					&arg_GETATTR4->attr_request);

	return res_GETATTR4->status;
}				/* nfs4_op_getattr */