Example #1
0
int kv_read_account_meta(struct http_request *req, const char *account)
{
	uint64_t bcount, ocount, used;
	int ret;

	ret = read_account_meta(account, &bcount, &ocount, &used);
	if (ret != SD_RES_SUCCESS)
		return ret;

	http_request_writef(req, "X-Account-Container-Count: %"PRIu64"\n",
			    bcount);
	http_request_writef(req, "X-Account-Object-Count: %"PRIu64"\n", ocount);
	http_request_writef(req, "X-Account-Bytes-Used: %"PRIu64"\n", used);
	return ret;
}
Example #2
0
File: kv.c Project: skuanr/sheepdog
int kv_read_object_meta(struct http_request *req, const char *account,
			const char *bucket, const char *name)
{
	struct kv_onode *onode = NULL;
	char vdi_name[SD_MAX_VDI_LEN];
	uint32_t bucket_vid;
	int ret;

	snprintf(vdi_name, SD_MAX_VDI_LEN, "%s/%s", account, bucket);
	ret = sd_lookup_vdi(vdi_name, &bucket_vid);
	if (ret != SD_RES_SUCCESS)
		return ret;

	onode = xzalloc(sizeof(*onode));
	ret = onode_lookup(onode, bucket_vid, name);
	if (ret != SD_RES_SUCCESS)
		goto out;

	req->data_length = onode->size;
	http_request_writef(req, "Last-Modified: %s\n",
			    http_time(onode->mtime));
out:
	free(onode);
	return ret;
}
Example #3
0
File: kv.c Project: skuanr/sheepdog
int kv_read_bucket(struct http_request *req, const char *account,
		   const char *bucket)
{
	uint32_t account_vid;
	struct kv_bnode bnode;
	int ret;

	ret = sd_lookup_vdi(account, &account_vid);
	if (ret != SD_RES_SUCCESS) {
		sd_err("Failed to find account %s", account);
		return ret;
	}

	ret = bnode_lookup(&bnode, account_vid, bucket);
	if (ret != SD_RES_SUCCESS)
		goto out;
	http_request_writef(req, "X-Container-Object-Count: %"PRIu64"\n",
			    bnode.object_count);

	http_request_writef(req, "X-Container-Bytes-Used: %"PRIu64"\n",
			    bnode.bytes_used);
out:
	return ret;
}