This allows for userspace to change the device path after it has been created. Thus giving the user the ability to change the path. The use case for this is to allow for virtual optical to have media change.
Unified · Split
| @@ -1548,6 +1548,46 @@ static ssize_t tcmu_cmd_time_out_store(struct config_item *item, const char *pag · 1547 unmodified lines | |||
| 1548 | } | 1548 | } |
| 1549 | CONFIGFS_ATTR(tcmu_, cmd_time_out); | 1549 | CONFIGFS_ATTR(tcmu_, cmd_time_out); |
| 1550 | 1550 | ||
| 1551 | static ssize_t tcmu_dev_path_show(struct config_item *item, char *page) | ||
| 1552 | { | ||
| 1553 | struct se_dev_attrib *da = container_of(to_config_group(item), | ||
| 1554 | struct se_dev_attrib, da_group); | ||
| 1555 | struct tcmu_dev *udev = TCMU_DEV(da->da_dev); | ||
| 1556 | |||
| 1557 | return snprintf(page, PAGE_SIZE, "%s\n", udev->dev_config); | ||
| 1558 | } | ||
| 1559 | |||
| 1560 | static ssize_t tcmu_dev_path_store(struct config_item *item, const char *page, | ||
| 1561 | size_t count) | ||
| 1562 | { | ||
| 1563 | struct se_dev_attrib *da = container_of(to_config_group(item), | ||
| 1564 | struct se_dev_attrib, da_group); | ||
| 1565 | struct tcmu_dev *udev = TCMU_DEV(da->da_dev); | ||
| 1566 | char *copy = NULL; | ||
| 1567 | int ret; | ||
| 1568 | |||
| 1569 | copy = kstrdup(page, GFP_KERNEL); | ||
| 1570 | if (!copy) { | ||
| 1571 | kfree(copy); | ||
| 1572 | return -EINVAL; | ||
| 1573 | } | ||
| 1574 | strlcpy(udev->dev_config, copy, TCMU_CONFIG_LEN); | ||
| 1575 | |||
| 1576 | /* Check if device has been configured before */ | ||
| 1577 | if (tcmu_dev_configured(udev)) { | ||
| 1578 | ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE, | ||
| 1579 | udev->uio_info.name, | ||
| 1580 | udev->uio_info.uio_dev->minor); | ||
| 1581 | if (ret) { | ||
| 1582 | pr_err("Unable to reconfigure device\n"); | ||
| 1583 | return ret; | ||
| 1584 | } | ||
| 1585 | } | ||
| 1586 | |||
| 1587 | return count; | ||
| 1588 | } | ||
| 1589 | CONFIGFS_ATTR(tcmu_, dev_path); | ||
| 1590 | |||
| 1551 | static ssize_t tcmu_dev_size_show(struct config_item *item, char *page) | 1591 | static ssize_t tcmu_dev_size_show(struct config_item *item, char *page) |
| 1552 | { | 1592 | { |
| 1553 | struct se_dev_attrib *da = container_of(to_config_group(item), | 1593 | struct se_dev_attrib *da = container_of(to_config_group(item), |
| @@ -1626,6 +1666,7 @@ CONFIGFS_ATTR(tcmu_, emulate_write_cache); · 72 unmodified lines | |||
| 1626 | 1666 | ||
| 1627 | struct configfs_attribute *tcmu_attrib_attrs[] = { | 1667 | struct configfs_attribute *tcmu_attrib_attrs[] = { |
| 1628 | &tcmu_attr_cmd_time_out, | 1668 | &tcmu_attr_cmd_time_out, |
| 1669 | &tcmu_attr_dev_path, | ||
| 1629 | &tcmu_attr_dev_size, | 1670 | &tcmu_attr_dev_size, |
| 1630 | &tcmu_attr_emulate_write_cache, | 1671 | &tcmu_attr_emulate_write_cache, |
| 1631 | NULL, | 1672 | NULL, |