mgmt_modify.c revision a9fd9a9e12bea66c9ea9b31f4b6f0ef584933f59
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <strings.h>
#include <assert.h>
#include <netdb.h>
#include <libzfs.h>
#include <libgen.h>
#include <iscsitgt_impl.h>
#include "queue.h"
#include "utility.h"
#include "iscsi_cmd.h"
#include "target.h"
#include "errcode.h"
#include "isns_client.h"
#include "mgmt_scf.h"
static char *modify_target(tgt_node_t *x);
static char *modify_initiator(tgt_node_t *x);
static char *modify_admin(tgt_node_t *x);
static char *modify_tpgt(tgt_node_t *x);
static char *modify_zfs(tgt_node_t *x);
/*
* []----
* | modify_func -- dispatch routine for objects
* []----
*/
/*ARGSUSED*/
void
{
tgt_node_t *x;
} else {
x = p->x_child;
reply_msg = modify_target(x);
reply_msg = modify_initiator(x);
reply_msg = modify_admin(x);
reply_msg = modify_tpgt(x);
reply_msg = modify_zfs(x);
} else {
}
}
}
/*
* []----
* | modify_target -- updates one or more properties for a target
* []----
*/
static char *
{
char iscsi_path[MAXPATHLEN];
char targ_name[64];
char path[MAXPATHLEN];
char *m;
tgt_node_t *t = NULL;
tgt_node_t *c = NULL;
int lun = 0;
int fd;
return (msg);
}
t)) != NULL) {
break;
}
}
/*
* Under base dir, file 'target name' is a symbolic link
* to the real directory 'IQN name' which stores params and back
* storage. Therefore we can easily get IQN name from target
* name by read the symbolic link content.
*/
/* ---- Finished with these so go ahead and release the memory ---- */
if (t == NULL) {
return (msg);
}
/*
* Grow the LU. We currently do not support shrinking the LU and
* that is only because it's unknown if any applications could support
* that type of data loss. To support shrinking all that would be
* The actually truncation request should be shipped off to the T10
* layer so that the LU thread can remap the smaller size without
* anyone accessing the data.
*/
return (msg);
}
return (msg);
}
if ((new_lu_size % 512LL) != 0) {
return (msg);
}
new_lu_size /= 512LL;
/* ---- default to LUN 0 ---- */
/* ---- read in current parameters ---- */
/* ---- validate that we're indeed growing the LU ---- */
False) {
return (msg);
}
return (msg);
}
if (new_lu_size < cur_lu_size) {
return (msg);
}
/* ---- check that this LU is of type 'disk' or 'tape' ---- */
False) {
return (msg);
}
return (msg);
}
/* ---- validate the backing store is a regular file ---- */
return (msg);
}
return (msg);
}
/* ---- update the parameter node with new size ---- */
== False) {
return (msg);
}
tgt_node_free(c);
/* ---- now update params file ---- */
/* ---- grow lu backing store ---- */
return (msg);
}
return (msg);
}
change_made = True;
}
return (msg);
}
/*
* Validate that the Target Portal Group Tag is reasonable.
*/
((m != NULL) && (*m != '\0'))) {
return (msg);
}
/* update isns only if TPGT contains ip_addr */
continue;
!= NULL) {
break;
} else {
return (msg);
}
}
NULL) {
return (msg);
}
/*
* tgt_node_replace will duplicate the child node
* tgt_node_add which is used below just links it
* into the tree.
*/
tgt_node_free(c);
} else {
return (msg);
}
tgt_node_add(list, c);
tgt_node_add(t, list);
}
change_made = True;
}
return (msg);
}
if (c == NULL) {
return (msg);
}
/* ---- See above usage ---- */
tgt_node_free(c);
} else {
return (msg);
}
tgt_node_add(list, c);
tgt_node_add(t, list);
}
change_made = True;
}
return (msg);
}
False) {
return (msg);
}
change_made = True;
}
return (msg);
}
return (msg);
}
return (msg);
}
False) {
return (msg);
}
change_made = True;
}
if (change_made == True) {
if (mgmt_config_save2scf() == False) {
return (msg);
}
if (isns_enabled() == True) {
return (msg);
}
}
} else {
}
return (msg);
}
/*
* []----
* | modify_initiator -- store the CHAP information for an initiator
* []----
*/
static char *
{
return (msg);
}
break;
}
/*
* We no longer need the name since we should have found the node
* it refers to and this way we don't have to worry about freeing
* the storage later.
*/
return (msg);
}
return (msg);
}
return (msg);
}
changes_made = True;
}
return (msg);
}
return (msg);
}
changes_made = True;
}
if (changes_made == True) {
if (mgmt_config_save2scf() == True)
} else {
}
return (msg);
}
/*
* []----
* | modify_admin -- modify one or more of the admin related props
* []----
*/
static char *
{
char *prop;
break;
/*
* Do the function call first if it exists which
* will allow possible checking to be done first.
*/
return (msg);
}
return (msg);
}
changes_made = True;
}
}
if (changes_made == True) {
/* isns_update updates isns_access & isns server name */
if (isns_update() != 0) {
return (msg);
}
if (mgmt_config_save2scf() == True)
} else {
}
return (msg);
}
/*
* []----
* | modify_tpgt -- add an IP-address to a target portal group
* []----
*/
static char *
{
goto error;
}
goto error;
}
goto error;
}
break;
}
goto error;
}
False) {
return (msg);
}
if (mgmt_config_save2scf() == True)
/*
* Re-register all targets, currently there's no method to
* update TPGT for individual target
*/
if (isns_enabled() == True) {
isns_reg_all();
}
if (name)
if (ip_str)
return (msg);
}
/*
* modify_zfs -- test for the existence of a certain dataset being shared
*
* Called when someone uses the iscsitgt_is_shared() function from libiscsitgt.
* All that
*/
/*ARGSUSED*/
static char *
modify_zfs(tgt_node_t *x)
{
tgt_node_t *n = NULL;
/*
* No need to check the credentials of the user for this function.
* There's no harm is allowing everyone to know whether or not
* a dataset is shared.
*/
return (msg);
}
goto error;
}
NULL) {
break;
}
if (n == NULL) {
goto error;
}
if (zfsh)
if (prop)
if (zh)
if (dataset)
return (msg);
}
/*
* []----
* | modify_element -- helper function to create node and add it to parent
* |
* | A False return value indicates a failure to allocate enough memory.
* []----
*/
static Boolean_t
{
tgt_node_t *c;
return (False);
} else {
tgt_node_replace(p, c, m);
tgt_node_free(c);
return (True);
}
}
/*
* []----
* | update_basedir -- update the global target directory
* |
* | Most of the properties when updated require no futher processing. The
* | target base directory however must be updated if it hasn't been set.
* | On a new system the daemon will not have any location to place the
* | backing store and target configuration files. On a live system we would
* | screw things up if we changed the global variable if it was already
* | in use, so we only allow the updating to occur if there are no targets.
* []----
*/
/*ARGSUSED*/
char *
{
int count = 0;
return (msg);
}
/*
* If the target does not have the "in-core" attribute, or
* if it does have the attribute, but is set to "false" then
* count the target.
* Targets that are marked as in-core simply mean that some
* other entity is storing the configuration data. Since that's
* the case there's no trouble in change the base directory
* because nothing will be lost.
*/
False) ||
count++;
}
if (val) {
}
}
if (target_basedir == NULL) {
} else if (count == 0) {
}
} else {
}
return (msg);
}
/*
* []----
* | validate_radius -- validate that server[:port] are valid
* []----
*/
char *
{
char *sp, *p;
int port;
return (msg);
*p++ = '\0';
return (msg);
}
}
else
return (msg);
}
/*
* []----
* | validate_isns_server -- validate that server[:port] are valid
* []----
*/
char *
{
char *sp, *p;
int port;
return (msg);
*p++ = '\0';
return (msg);
}
}
else
return (msg);
}