Пример #1
0
Файл: mgmt.c Проект: fujita/tgt
static tgtadm_err device_mgmt(int lld_no, struct mgmt_task *mtask)
{
	struct tgtadm_req *req = &mtask->req;
	char *params = mtask->req_buf;
	tgtadm_err adm_err = TGTADM_UNSUPPORTED_OPERATION;

	switch (req->op) {
	case OP_NEW:
		eprintf("sz:%d params:%s\n",mtask->req_bsize,params);
		adm_err = tgt_device_create(req->tid, req->device_type, req->lun,
					    params, 1);
		break;
	case OP_DELETE:
		adm_err = tgt_device_destroy(req->tid, req->lun, 0);
		break;
	case OP_UPDATE:
		adm_err = tgt_device_update(req->tid, req->lun, params);
		break;
	case OP_STATS:
		concat_buf_init(&mtask->rsp_concat);
		if (!req->sid)
			adm_err = tgt_stat_device_by_id(req->tid, req->lun,
							&mtask->rsp_concat);
		else if (tgt_drivers[lld_no]->stat)
			adm_err = tgt_drivers[lld_no]->stat(req->mode, req->tid,
							    req->sid, req->cid, req->lun,
							    &mtask->rsp_concat);
		concat_buf_finish(&mtask->rsp_concat);
		break;
	default:
		break;
	}

	return adm_err;
}
Пример #2
0
static int device_mgmt(int lld_no, struct tgtadm_req *req, char *params,
                       struct tgtadm_rsp *rsp, int *rlen)
{
    int err = TGTADM_UNSUPPORTED_OPERATION;

    switch (req->op) {
    case OP_NEW:
        err = tgt_device_create(req->tid, req->device_type, req->lun,
                                params, 1);
        break;
    case OP_DELETE:
        err = tgt_device_destroy(req->tid, req->lun, 0);
        break;
    case OP_UPDATE:
        err = tgt_device_update(req->tid, req->lun, params);
        break;
    default:
        break;
    }

    rsp->err = err;
    rsp->len = sizeof(*rsp);

    return err;
}