mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-21 14:46:23 +00:00
scst: Change add_device_parameters from a string into an array
This patch does not change any functionality. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7964 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
+5
-2
@@ -1734,8 +1734,11 @@ struct scst_dev_type {
|
||||
/* Optional help string for mgmt_cmd commands */
|
||||
const char *mgmt_cmd_help;
|
||||
|
||||
/* List of parameters for add_device command, if any */
|
||||
const char *add_device_parameters;
|
||||
/*
|
||||
* Array with parameters for add_device command, if any. NULL
|
||||
* terminated.
|
||||
*/
|
||||
const char *const *add_device_parameters;
|
||||
|
||||
/*
|
||||
* List of optional, i.e. which could be added by add_attribute command
|
||||
|
||||
@@ -754,6 +754,28 @@ static vdisk_op_fn fileio_ops[256];
|
||||
static vdisk_op_fn blockio_ops[256];
|
||||
static vdisk_op_fn nullio_ops[256];
|
||||
|
||||
static const char *fileio_add_dev_params[] = {
|
||||
"async",
|
||||
"blocksize",
|
||||
"cluster_mode",
|
||||
"dif_filename",
|
||||
"dif_mode",
|
||||
"dif_static_app_tag",
|
||||
"dif_type",
|
||||
"filename",
|
||||
"numa_node_id",
|
||||
"nv_cache",
|
||||
"o_direct",
|
||||
"read_only",
|
||||
"removable",
|
||||
"rotational",
|
||||
"thin_provisioned",
|
||||
"tst",
|
||||
"write_through",
|
||||
"zero_copy",
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* Be careful changing "name" field, since it is the name of the corresponding
|
||||
* /sys/kernel/scst_tgt entry, hence a part of user space ABI.
|
||||
@@ -786,25 +808,7 @@ static struct scst_dev_type vdisk_file_devtype = {
|
||||
.add_device = vdisk_add_fileio_device,
|
||||
.del_device = vdisk_del_device,
|
||||
.dev_attrs = vdisk_fileio_attrs,
|
||||
.add_device_parameters =
|
||||
"async, "
|
||||
"blocksize, "
|
||||
"cluster_mode, "
|
||||
"filename, "
|
||||
"numa_node_id, "
|
||||
"nv_cache, "
|
||||
"o_direct, "
|
||||
"read_only, "
|
||||
"removable, "
|
||||
"rotational, "
|
||||
"thin_provisioned, "
|
||||
"tst, "
|
||||
"write_through, "
|
||||
"zero_copy, "
|
||||
"dif_mode, "
|
||||
"dif_type, "
|
||||
"dif_static_app_tag, "
|
||||
"dif_filename",
|
||||
.add_device_parameters = fileio_add_dev_params,
|
||||
#endif
|
||||
#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
|
||||
.default_trace_flags = SCST_DEFAULT_DEV_LOG_FLAGS,
|
||||
@@ -818,6 +822,27 @@ static struct scst_dev_type vdisk_file_devtype = {
|
||||
|
||||
static struct kmem_cache *blockio_work_cachep;
|
||||
|
||||
static const char *blockio_add_dev_params[] = {
|
||||
"active",
|
||||
"bind_alua_state",
|
||||
"blocksize",
|
||||
"cluster_mode",
|
||||
"dif_filename",
|
||||
"dif_mode",
|
||||
"dif_static_app_tag",
|
||||
"dif_type",
|
||||
"filename",
|
||||
"numa_node_id",
|
||||
"nv_cache",
|
||||
"read_only",
|
||||
"removable",
|
||||
"rotational",
|
||||
"thin_provisioned",
|
||||
"tst",
|
||||
"write_through",
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct scst_dev_type vdisk_blk_devtype = {
|
||||
.name = "vdisk_blockio",
|
||||
.type = TYPE_DISK,
|
||||
@@ -843,24 +868,7 @@ static struct scst_dev_type vdisk_blk_devtype = {
|
||||
.add_device = vdisk_add_blockio_device,
|
||||
.del_device = vdisk_del_device,
|
||||
.dev_attrs = vdisk_blockio_attrs,
|
||||
.add_device_parameters =
|
||||
"active, "
|
||||
"bind_alua_state, "
|
||||
"blocksize, "
|
||||
"dif_mode, "
|
||||
"dif_type, "
|
||||
"dif_static_app_tag, "
|
||||
"dif_filename, "
|
||||
"filename, "
|
||||
"numa_node_id, "
|
||||
"nv_cache, "
|
||||
"cluster_mode, "
|
||||
"read_only, "
|
||||
"removable, "
|
||||
"rotational, "
|
||||
"thin_provisioned, "
|
||||
"tst, "
|
||||
"write_through",
|
||||
.add_device_parameters = blockio_add_dev_params,
|
||||
#endif
|
||||
#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
|
||||
.default_trace_flags = SCST_DEFAULT_DEV_LOG_FLAGS,
|
||||
@@ -872,6 +880,23 @@ static struct scst_dev_type vdisk_blk_devtype = {
|
||||
#endif
|
||||
};
|
||||
|
||||
static const char *nullio_add_dev_params[] = {
|
||||
"blocksize",
|
||||
"cluster_mode",
|
||||
"dif_mode",
|
||||
"dif_static_app_tag",
|
||||
"dif_type",
|
||||
"dummy",
|
||||
"numa_node_id",
|
||||
"read_only",
|
||||
"removable",
|
||||
"rotational",
|
||||
"size",
|
||||
"size_mb",
|
||||
"tst",
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct scst_dev_type vdisk_null_devtype = {
|
||||
.name = "vdisk_nullio",
|
||||
.type = TYPE_DISK,
|
||||
@@ -895,20 +920,7 @@ static struct scst_dev_type vdisk_null_devtype = {
|
||||
.add_device = vdisk_add_nullio_device,
|
||||
.del_device = vdisk_del_device,
|
||||
.dev_attrs = vdisk_nullio_attrs,
|
||||
.add_device_parameters =
|
||||
"blocksize, "
|
||||
"dif_mode, "
|
||||
"dif_type, "
|
||||
"dif_static_app_tag, "
|
||||
"dummy, "
|
||||
"numa_node_id, "
|
||||
"cluster_mode, "
|
||||
"read_only, "
|
||||
"removable, "
|
||||
"rotational, "
|
||||
"size, "
|
||||
"size_mb, "
|
||||
"tst",
|
||||
.add_device_parameters = nullio_add_dev_params,
|
||||
#endif
|
||||
#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
|
||||
.default_trace_flags = SCST_DEFAULT_DEV_LOG_FLAGS,
|
||||
@@ -920,6 +932,11 @@ static struct scst_dev_type vdisk_null_devtype = {
|
||||
#endif
|
||||
};
|
||||
|
||||
static const char *cdrom_add_dev_params[] = {
|
||||
"tst",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct scst_dev_type vcdrom_devtype = {
|
||||
.name = "vcdrom",
|
||||
.type = TYPE_ROM,
|
||||
@@ -943,7 +960,7 @@ static struct scst_dev_type vcdrom_devtype = {
|
||||
.add_device = vcdrom_add_device,
|
||||
.del_device = vcdrom_del_device,
|
||||
.dev_attrs = vcdrom_attrs,
|
||||
.add_device_parameters = "tst",
|
||||
.add_device_parameters = cdrom_add_dev_params,
|
||||
#endif
|
||||
#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
|
||||
.default_trace_flags = SCST_DEFAULT_DEV_LOG_FLAGS,
|
||||
|
||||
+30
-7
@@ -5771,6 +5771,28 @@ static struct kobj_type scst_devt_ktype = {
|
||||
.default_attrs = scst_devt_default_attrs,
|
||||
};
|
||||
|
||||
static char *scst_dev_params(struct scst_dev_type *devt)
|
||||
{
|
||||
char *p, *r;
|
||||
const char *const *q;
|
||||
bool comma = false;
|
||||
|
||||
if (!devt->add_device_parameters)
|
||||
return NULL;
|
||||
p = kstrdup("The following parameters available: ", GFP_KERNEL);
|
||||
if (!p)
|
||||
return NULL;
|
||||
for (q = devt->add_device_parameters; *q; q++) {
|
||||
r = kasprintf(GFP_KERNEL, "%s%s%s", p, comma ? ", " : "", *q);
|
||||
kfree(p);
|
||||
if (!r)
|
||||
return NULL;
|
||||
p = r;
|
||||
comma = true;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
static ssize_t scst_devt_mgmt_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
@@ -5782,12 +5804,14 @@ static ssize_t scst_devt_mgmt_show(struct kobject *kobj,
|
||||
"\n"
|
||||
"where parameters are one or more "
|
||||
"param_name=value pairs separated by ';'\n\n"
|
||||
"%s%s%s%s%s%s%s%s%s%s\n";
|
||||
"%s%s%s%s%s%s%s%s%s\n";
|
||||
struct scst_dev_type *devt;
|
||||
char *p;
|
||||
int res;
|
||||
|
||||
devt = container_of(kobj, struct scst_dev_type, devt_kobj);
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, help,
|
||||
p = scst_dev_params(devt);
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, help,
|
||||
(devt->devt_optional_attributes != NULL) ?
|
||||
" echo \"add_attribute <attribute> <value>\" >mgmt\n"
|
||||
" echo \"del_attribute <attribute> <value>\" >mgmt\n" : "",
|
||||
@@ -5796,10 +5820,7 @@ static ssize_t scst_devt_mgmt_show(struct kobject *kobj,
|
||||
" echo \"del_device_attribute device_name <attribute> <value>\" >mgmt\n" : "",
|
||||
(devt->mgmt_cmd_help) ? devt->mgmt_cmd_help : "",
|
||||
(devt->mgmt_cmd_help) ? "\n" : "",
|
||||
(devt->add_device_parameters != NULL) ?
|
||||
"The following parameters available: " : "",
|
||||
(devt->add_device_parameters != NULL) ?
|
||||
devt->add_device_parameters : "",
|
||||
p ? : "",
|
||||
(devt->add_device_parameters != NULL) ? "\n" : "",
|
||||
(devt->devt_optional_attributes != NULL) ?
|
||||
"The following dev handler attributes available: " : "",
|
||||
@@ -5811,6 +5832,8 @@ static ssize_t scst_devt_mgmt_show(struct kobject *kobj,
|
||||
(devt->dev_optional_attributes != NULL) ?
|
||||
devt->dev_optional_attributes : "",
|
||||
(devt->dev_optional_attributes != NULL) ? "\n" : "");
|
||||
kfree(p);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int scst_process_devt_mgmt_store(char *buffer,
|
||||
|
||||
Reference in New Issue
Block a user