Add listing attributes of various types in the help string to help manegement utilities. Added on request from Mark Buechler <mark.buechler@gmail.com>.

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1762 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2010-06-11 18:40:14 +00:00
parent 7a12737c9d
commit 2da20cee9e
5 changed files with 125 additions and 72 deletions

View File

@@ -3637,18 +3637,6 @@ static struct scst_trace_log iscsi_local_trace_tbl[] = {
#define ISCSI_TRACE_TBL_HELP ", d_write, conn, conn_dbg, iov, pdu, net_page"
#endif
#define ISCSI_MGMT_CMD_HELP \
" echo \"add_attribute IncomingUser name password\" >mgmt\n" \
" echo \"del_attribute IncomingUser name\" >mgmt\n" \
" echo \"add_attribute OutgoingUser name password\" >mgmt\n" \
" echo \"del_attribute OutgoingUser name\" >mgmt\n" \
" echo \"add_target_attribute target_name IncomingUser name password\" >mgmt\n" \
" echo \"del_target_attribute target_name IncomingUser name\" >mgmt\n" \
" echo \"add_target_attribute target_name OutgoingUser name password\" >mgmt\n" \
" echo \"del_target_attribute target_name OutgoingUser name\" >mgmt\n" \
" echo \"add_target_attribute target_name allowed_portal portal_mask\" >mgmt\n" \
" echo \"del_target_attribute target_name allowed_portal portal_mask\" >mgmt\n"
struct scst_tgt_template iscsi_template = {
.name = "iscsi",
.sg_tablesize = 0xFFFF /* no limit */,
@@ -3664,7 +3652,8 @@ struct scst_tgt_template iscsi_template = {
.add_target = iscsi_sysfs_add_target,
.del_target = iscsi_sysfs_del_target,
.mgmt_cmd = iscsi_sysfs_mgmt_cmd,
.mgmt_cmd_help = ISCSI_MGMT_CMD_HELP,
.tgtt_optional_attributes = "IncomingUser, OutgoingUser",
.tgt_optional_attributes = "IncomingUser, OutgoingUser, allowed_portal",
#endif
#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
.default_trace_flags = ISCSI_DEFAULT_LOG_FLAGS,

View File

@@ -50,7 +50,7 @@ instance, a Fibre Channel adapter's port. Virtual targets are hardware
independent targets, which can be dynamically added or removed, for
instance, an iSCSI target, or NPIV Fibre Channel target.
A target driver supporting virtual targets must support "mgmt" attribute
A target driver supporting virtual targets MUST support "mgmt" attribute
and "add_target"/"del_target" commands.
If target driver supports both hardware and virtual targets (for
@@ -124,31 +124,36 @@ For example:
EXTRACHECKS
DEBUG
4. "mgmt" - this attribute MUST allow to add and delete targets, if
virtual targets are supported by this driver, as well as it MAY allow to
add and delete the target driver's or its targets' attributes.
4. "mgmt" - if supported this attribute MUST allow to add and delete
targets, if virtual targets are supported by this driver, as well as it
MAY allow to add and delete the target driver's or its targets'
attributes.
This attribute MUST have read and write permissions for superuser and be
read-only for other users.
On read it MUST return a help string describing available commands and
parameters.
On read it MUST return a help string describing available commands,
parameters and attributes.
To achieve that the target driver should just set in its struct
scst_tgt_template correctly the following fields: mgmt_cmd_help,
add_target_parameters, tgtt_optional_attributes and
tgt_optional_attributes.
For example:
Usage: echo "add_target target_name [parameters]" >mgmt
echo "del_target target_name" >mgmt
echo "add_attribute IncomingUser name password" >mgmt
echo "del_attribute IncomingUser name" >mgmt
echo "add_attribute OutgoingUser name password" >mgmt
echo "del_attribute OutgoingUser name" >mgmt
echo "add_target_attribute target_name IncomingUser name password" >mgmt
echo "del_target_attribute target_name IncomingUser name" >mgmt
echo "add_target_attribute target_name OutgoingUser name password" >mgmt
echo "del_target_attribute target_name OutgoingUser name" >mgmt
echo "add_attribute <attribute> <value>" >mgmt
echo "del_attribute <attribute> <value>" >mgmt
echo "add_target_attribute target_name <attribute> <value>" >mgmt
echo "del_target_attribute target_name <attribute> <value>" >mgmt
where parameters are one or more param_name=value pairs separated by ';'
The following target driver attributes available: IncomingUser, OutgoingUser
The following target attributes available: IncomingUser, OutgoingUser, allowed_portal
4.1. "add_target" - if supported, this command MUST add new target with
name "target_name" and specified optional or required parameters. Each
parameter MUST be in form "parameter=value". All parameters MUST be
@@ -361,22 +366,25 @@ handler's or its devices' attributes.
On read it MUST return a help string describing available commands and
parameters.
To achieve that the dev handler should just set in its struct
scst_dev_type correctly the following fields: mgmt_cmd_help,
add_device_parameters, devt_optional_attributes and
dev_optional_attributes.
For example:
Usage: echo "add_device device_name [parameters]" >mgmt
echo "del_device device_name" >mgmt
echo "add_attribute AttributeX ValueX" >mgmt
echo "del_attribute AttributeX ValueX" >mgmt
echo "add_attribute AttributeY ValueY1 ValueY2" >mgmt
echo "del_attribute AttributeY" >mgmt
echo "add_device_attribute device_name AttributeDX ValueDX" >mgmt
echo "del_device_attribute device_name AttributeDX ValueDX" >mgmt
echo "add_device_attribute device_name AttributeDY ValueY1 ValueY2" >mgmt
echo "del_device_attribute device_name AttributeDY" >mgmt
echo "add_attribute <attribute> <value>" >mgmt
echo "del_attribute <attribute> <value>" >mgmt
echo "add_device_attribute device_name <attribute> <value>" >mgmt
echo "del_device_attribute device_name <attribute> <value>" >mgmt
where parameters are one or more param_name=value pairs separated by ';'
The following parameters available: filename, blocksize, write_through, nv_cache, o_direct, read_only, removable
The following device driver attributes available: AttributeX, AttributeY
The following device attributes available: AttributeDX, AttributeDY
1. "add_device" - this command MUST add new device with name
"device_name" and specified optional or required parameters. Each

View File

@@ -901,21 +901,35 @@ struct scst_tgt_template {
const char *trace_tbl_help;
#ifndef CONFIG_SCST_PROC
/* Optional sysfs attributes */
/* sysfs attributes, if any */
const struct attribute **tgtt_attrs;
/* Optional sysfs target attributes */
/* sysfs target attributes, if any */
const struct attribute **tgt_attrs;
/* Optional sysfs session attributes */
/* sysfs session attributes, if any */
const struct attribute **sess_attrs;
#endif
/* Optional help string for mgmt_cmd commands */
const char *mgmt_cmd_help;
/* Optional help string for add_target parameters */
const char *add_target_parameters_help;
/* List of parameters for add_target command, if any */
const char *add_target_parameters;
/*
* List of optional, i.e. which could be added by add_attribute command
* and deleted by del_attribute command, sysfs attributes, if any.
* Helpful for scstadmin to work correctly.
*/
const char *tgtt_optional_attributes;
/*
* List of optional, i.e. which could be added by add_target_attribute
* command and deleted by del_target_attribute command, sysfs
* attributes, if any. Helpful for scstadmin to work correctly.
*/
const char *tgt_optional_attributes;
/** Private, must be inited to 0 by memset() **/
@@ -1196,13 +1210,27 @@ struct scst_dev_type {
/* Optional help string for mgmt_cmd commands */
const char *mgmt_cmd_help;
/* Optional help string for add_device parameters */
const char *add_device_parameters_help;
/* List of parameters for add_device command, if any */
const char *add_device_parameters;
/* Optional sysfs attributes */
/*
* List of optional, i.e. which could be added by add_attribute command
* and deleted by del_attribute command, sysfs attributes, if any.
* Helpful for scstadmin to work correctly.
*/
const char *devt_optional_attributes;
/*
* List of optional, i.e. which could be added by add_device_attribute
* command and deleted by del_device_attribute command, sysfs
* attributes, if any. Helpful for scstadmin to work correctly.
*/
const char *dev_optional_attributes;
/* sysfs attributes, if any */
const struct attribute **devt_attrs;
/* Optional sysfs device attributes */
/* sysfs device attributes, if any */
const struct attribute **dev_attrs;
#endif

View File

@@ -438,7 +438,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_help = "filename, blocksize, write_through, "
.add_device_parameters = "filename, blocksize, write_through, "
"nv_cache, o_direct, read_only, removable",
#endif
#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
@@ -473,7 +473,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_help = "filename, blocksize, read_only, "
.add_device_parameters = "filename, blocksize, read_only, "
"removable",
#endif
#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
@@ -506,7 +506,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_help = "blocksize, read_only, removable",
.add_device_parameters = "blocksize, read_only, removable",
#endif
#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
.default_trace_flags = SCST_DEFAULT_DEV_LOG_FLAGS,
@@ -539,7 +539,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_help = NULL,
.add_device_parameters = NULL,
#endif
#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
.default_trace_flags = SCST_DEFAULT_DEV_LOG_FLAGS,

View File

@@ -240,27 +240,41 @@ static struct kobj_attribute tgtt_trace_attr =
static ssize_t scst_tgtt_mgmt_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
char *help = "Usage: echo \"add_target target_name [parameters]\" "
char *help = "Usage: echo \"add_target target_name [parameters]\" "
">mgmt\n"
" echo \"del_target target_name\" >mgmt\n"
"%s%s"
"%s"
"\n"
"where parameters are one or more "
"param_name=value pairs separated by ';'\n"
"%s%s";
struct scst_tgt_template *tgtt;
"param_name=value pairs separated by ';'\n\n"
"%s%s%s%s%s%s%s%s\n";
struct scst_tgt_template *tgtt;
tgtt = container_of(kobj, struct scst_tgt_template, tgtt_kobj);
if (tgtt->add_target_parameters_help != NULL)
return sprintf(buf, help,
(tgtt->mgmt_cmd_help) ? tgtt->mgmt_cmd_help : "",
"\nThe following parameters available: ",
tgtt->add_target_parameters_help);
else
return sprintf(buf, help,
(tgtt->mgmt_cmd_help) ? tgtt->mgmt_cmd_help : "",
"", "");
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, help,
(tgtt->tgtt_optional_attributes != NULL) ?
" echo \"add_attribute <attribute> <value>\" >mgmt\n"
" echo \"del_attribute <attribute> <value>\" >mgmt\n" : "",
(tgtt->tgt_optional_attributes != NULL) ?
" echo \"add_target_attribute target_name <attribute> <value>\" >mgmt\n"
" echo \"del_target_attribute target_name <attribute> <value>\" >mgmt\n" : "",
(tgtt->mgmt_cmd_help) ? tgtt->mgmt_cmd_help : "",
(tgtt->add_target_parameters != NULL) ?
"The following parameters available: " : "",
(tgtt->add_target_parameters != NULL) ?
tgtt->add_target_parameters : "",
(tgtt->tgtt_optional_attributes != NULL) ?
"The following target driver attributes available: " : "",
(tgtt->tgtt_optional_attributes != NULL) ?
tgtt->tgtt_optional_attributes : "",
(tgtt->tgtt_optional_attributes != NULL) ? "\n" : "",
(tgtt->tgt_optional_attributes != NULL) ?
"The following target attributes available: " : "",
(tgtt->tgt_optional_attributes != NULL) ?
tgtt->tgt_optional_attributes : "",
(tgtt->tgt_optional_attributes != NULL) ? "\n" : "");
}
static ssize_t scst_tgtt_mgmt_store(struct kobject *kobj,
@@ -3491,24 +3505,38 @@ static ssize_t scst_devt_mgmt_show(struct kobject *kobj,
char *help = "Usage: echo \"add_device device_name [parameters]\" "
">mgmt\n"
" echo \"del_device device_name\" >mgmt\n"
"%s%s"
"%s"
"\n"
"where parameters are one or more "
"param_name=value pairs separated by ';'\n"
"%s%s";
"param_name=value pairs separated by ';'\n\n"
"%s%s%s%s%s%s%s%s\n";
struct scst_dev_type *devt;
devt = container_of(kobj, struct scst_dev_type, devt_kobj);
if (devt->add_device_parameters_help != NULL)
return sprintf(buf, help,
(devt->mgmt_cmd_help) ? devt->mgmt_cmd_help : "",
"\nThe following parameters available: ",
devt->add_device_parameters_help);
else
return sprintf(buf, help,
(devt->mgmt_cmd_help) ? devt->mgmt_cmd_help : "",
"", "");
return 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" : "",
(devt->dev_optional_attributes != NULL) ?
" echo \"add_device_attribute device_name <attribute> <value>\" >mgmt"
" echo \"del_device_attribute device_name <attribute> <value>\" >mgmt\n" : "",
(devt->mgmt_cmd_help) ? devt->mgmt_cmd_help : "",
(devt->add_device_parameters != NULL) ?
"The following parameters available: " : "",
(devt->add_device_parameters != NULL) ?
devt->add_device_parameters : "",
(devt->devt_optional_attributes != NULL) ?
"The following dev handler attributes available: " : "",
(devt->devt_optional_attributes != NULL) ?
devt->devt_optional_attributes : "",
(devt->devt_optional_attributes != NULL) ? "\n" : "",
(devt->dev_optional_attributes != NULL) ?
"The following device attributes available: " : "",
(devt->dev_optional_attributes != NULL) ?
devt->dev_optional_attributes : "",
(devt->dev_optional_attributes != NULL) ? "\n" : "");
}
static ssize_t scst_devt_mgmt_store(struct kobject *kobj,