| 348 | } |
| 349 | |
| 350 | static struct ublk_dev *ublk_ctrl_init(void) |
| 351 | { |
| 352 | struct ublk_dev *dev = (struct ublk_dev *)calloc(1, sizeof(*dev)); |
| 353 | struct ublksrv_ctrl_dev_info *info = &dev->dev_info; |
| 354 | int ret; |
| 355 | |
| 356 | dev->ctrl_fd = open(CTRL_DEV, O_RDWR); |
| 357 | if (dev->ctrl_fd < 0) { |
| 358 | free(dev); |
| 359 | return NULL; |
| 360 | } |
| 361 | |
| 362 | info->max_io_buf_bytes = UBLK_IO_MAX_BYTES; |
| 363 | |
| 364 | ret = ublk_setup_ring(&dev->ring, UBLK_CTRL_RING_DEPTH, |
| 365 | UBLK_CTRL_RING_DEPTH, IORING_SETUP_SQE128); |
| 366 | if (ret < 0) { |
| 367 | ublk_err("queue_init: %s\n", strerror(-ret)); |
| 368 | free(dev); |
| 369 | return NULL; |
| 370 | } |
| 371 | dev->nr_fds = 1; |
| 372 | |
| 373 | return dev; |
| 374 | } |
| 375 | |
| 376 | static int ublk_queue_cmd_buf_sz(struct ublk_queue *q) |
| 377 | { |
no test coverage detected