diff mbox

[v2,4/5] tcmu: Make dev_config configurable

Message ID 1496169080-58746-5-git-send-email-bryantly@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bryant G. Ly May 30, 2017, 6:31 p.m. UTC
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.

Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
---
 drivers/target/target_core_user.c | 41 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

Comments

kernel test robot May 30, 2017, 11:21 p.m. UTC | #1
Hi Bryant,

[auto build test ERROR on target/master]
[also build test ERROR on v4.12-rc3 next-20170530]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Bryant-G-Ly/TCMU-Enable-Reconfiguration-Patches/20170531-062328
base:   https://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master
config: i386-randconfig-x005-201722 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers//target/target_core_user.c: In function 'tcmu_dev_path_store':
>> drivers//target/target_core_user.c:1571:3: error: implicit declaration of function 'kree' [-Werror=implicit-function-declaration]
      kree(copy);
      ^~~~
   cc1: some warnings being treated as errors

vim +/kree +1571 drivers//target/target_core_user.c

  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			kree(copy);
  1572			return -EINVAL;
  1573		}
  1574		strcpy(udev->dev_config, copy);
  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,

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Mike Christie June 6, 2017, 2:02 a.m. UTC | #2
On 05/30/2017 01:31 PM, Bryant G. Ly wrote:
> 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.
> 
> Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
> ---
>  drivers/target/target_core_user.c | 41 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index c8c84b7..7575bc9 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -1548,6 +1548,46 @@ static ssize_t tcmu_cmd_time_out_store(struct config_item *item, const char *pag
>  }
>  CONFIGFS_ATTR(tcmu_, cmd_time_out);
>  
> +static ssize_t tcmu_dev_path_show(struct config_item *item, char *page)
> +{
> +	struct se_dev_attrib *da = container_of(to_config_group(item),
> +						struct se_dev_attrib, da_group);
> +	struct tcmu_dev *udev = TCMU_DEV(da->da_dev);
> +
> +	return snprintf(page, PAGE_SIZE, "%s\n", udev->dev_config);
> +}
> +
> +static ssize_t tcmu_dev_path_store(struct config_item *item, const char *page,
> +				   size_t count)
> +{
> +	struct se_dev_attrib *da = container_of(to_config_group(item),
> +						struct se_dev_attrib, da_group);
> +	struct tcmu_dev *udev = TCMU_DEV(da->da_dev);
> +	char *copy = NULL;
> +	int ret;
> +
> +	copy = kstrdup(page, GFP_KERNEL);
> +	if (!copy) {
> +		kree(copy);
> +		return -EINVAL;
> +	}
> +	strcpy(udev->dev_config, copy);


I think we need to do strlcpy with TCMU_CONFIG_LEN here.
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index c8c84b7..7575bc9 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1548,6 +1548,46 @@  static ssize_t tcmu_cmd_time_out_store(struct config_item *item, const char *pag
 }
 CONFIGFS_ATTR(tcmu_, cmd_time_out);
 
+static ssize_t tcmu_dev_path_show(struct config_item *item, char *page)
+{
+	struct se_dev_attrib *da = container_of(to_config_group(item),
+						struct se_dev_attrib, da_group);
+	struct tcmu_dev *udev = TCMU_DEV(da->da_dev);
+
+	return snprintf(page, PAGE_SIZE, "%s\n", udev->dev_config);
+}
+
+static ssize_t tcmu_dev_path_store(struct config_item *item, const char *page,
+				   size_t count)
+{
+	struct se_dev_attrib *da = container_of(to_config_group(item),
+						struct se_dev_attrib, da_group);
+	struct tcmu_dev *udev = TCMU_DEV(da->da_dev);
+	char *copy = NULL;
+	int ret;
+
+	copy = kstrdup(page, GFP_KERNEL);
+	if (!copy) {
+		kree(copy);
+		return -EINVAL;
+	}
+	strcpy(udev->dev_config, copy);
+
+	/* Check if device has been configured before */
+	if (tcmu_dev_configured(udev)) {
+		ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
+					 udev->uio_info.name,
+					 udev->uio_info.uio_dev->minor);
+		if (ret) {
+			pr_err("Unable to reconfigure device\n");
+			return ret;
+		}
+	}
+
+	return count;
+}
+CONFIGFS_ATTR(tcmu_, dev_path);
+
 static ssize_t tcmu_dev_size_show(struct config_item *item, char *page)
 {
 	struct se_dev_attrib *da = container_of(to_config_group(item),
@@ -1626,6 +1666,7 @@  CONFIGFS_ATTR(tcmu_, emulate_write_cache);
 
 struct configfs_attribute *tcmu_attrib_attrs[] = {
 	&tcmu_attr_cmd_time_out,
+	&tcmu_attr_dev_path,
 	&tcmu_attr_dev_size,
 	&tcmu_attr_emulate_write_cache,
 	NULL,