mgmt_modify.c revision 36c5fee33fa8b822175d410202aebcf592c8d342
/*
* 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 2006 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 "xml.h"
#include "queue.h"
#include "utility.h"
#include "iscsi_cmd.h"
#include "target.h"
#include "errcode.h"
static char *modify_target(xml_node_t *x);
static char *modify_initiator(xml_node_t *x);
static char *modify_admin(xml_node_t *x);
static char *modify_tpgt(xml_node_t *x);
/*
* []----
* | modify_func -- dispatch routine for objects
* []----
*/
/*ARGSUSED*/
void
{
xml_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);
} else {
}
}
}
/*
* []----
* | modify_target -- updates one or more properties for a target
* []----
*/
static char *
{
*iscsi,
size_str[16],
*m,
xml_node_t *t = NULL,
*c = NULL,
*node;
int lun = 0,
fd,
return (msg);
}
t)) != NULL) {
break;
}
}
/* ---- 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;
return (msg);
}
/* ---- default to LUN 0 ---- */
/* ---- read in current paramaters ---- */
return (msg);
}
0)) != NULL) {
while (xmlTextReaderRead(r) == 1)
break;
} else {
return (msg);
}
/* ---- 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);
}
xml_tree_free(c);
/* ---- now update params file ---- */
return (msg);
}
/* ---- grow lu backing store ---- */
return (msg);
}
return (msg);
}
}
return (msg);
}
/*
* Validate that the Target Portal Group Tag is reasonable.
*/
((m != NULL) && (*m != '\0'))) {
return (msg);
}
NULL) {
return (msg);
}
/*
* xml_replace_child will duplicate the child node
* xml_add_child which is used below just links it
* into the tree.
*/
xml_tree_free(c);
} else {
return (msg);
}
(void) xml_add_child(list, c);
(void) xml_add_child(t, list);
}
change_made = True;
}
return (msg);
}
if (c == NULL) {
return (msg);
}
/* ---- See above usage ---- */
xml_tree_free(c);
} else {
return (msg);
}
(void) xml_add_child(list, c);
(void) xml_add_child(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) {
} 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) {
} else {
}
return (msg);
}
/*
* []----
* | modify_admin -- modify one or more of the admin related props
* []----
*/
static 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) {
} 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 (name)
if (ip_str)
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
{
xml_node_t *c;
return (False);
else {
xml_replace_child(p, c, m);
xml_tree_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);
}
count++;
}
if (target_basedir == NULL) {
} else if (count == 0) {
} else {
if (process_target_config() == False) {
}
}
} else {
}
return (msg);
}
/*
* []----
* | validate_radius -- validate that server[:port] are valid
* []----
*/
char *
{
*sp,
*p;
int port;
return (msg);
*p++ = '\0';
return (msg);
}
}
else
return (msg);
}