mgmt_remove.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"
/*
* This file deals with XML data for removing various configuration data.
*/
#include <errno.h>
#include <strings.h>
#include <unistd.h>
#include <priv.h>
#include <syslog.h>
#include <libzfs.h>
#include <iscsitgt_impl.h>
#include "utility.h"
#include "queue.h"
#include "target.h"
#include "iscsi_cmd.h"
#include "errcode.h"
#include "isns_client.h"
#include "mgmt_scf.h"
static char *remove_target(tgt_node_t *x);
static char *remove_initiator(tgt_node_t *x);
static char *remove_tpgt(tgt_node_t *x);
/*ARGSUSED*/
void
{
tgt_node_t *x;
char msgbuf[80];
} else {
x = p->x_child;
reply_msg = remove_target(x);
reply_msg = remove_initiator(x);
reply_msg = remove_tpgt(x);
} else {
"Unknown object '%s' for delete element",
x->x_name);
}
}
}
/*
* remove_zfs -- unshare a ZVOL from the target
*/
static char *
{
char *prop;
const priv_set_t *eset;
return (msg);
}
return (msg);
}
ucred_geteuid(cred) != 0) {
/*
* See if user has ZFS dataset permissions to do operation
*/
return (msg);
}
}
!= NULL) {
break;
}
/*
* We're unsharing a target. If we don't have a reference
* then there's no problem.
*/
return (msg);
}
False) {
return (msg);
}
/*
* Wait until here to issue a logout to any initiators that
* might be logged into the target. Certain initiators are
* sneaky in that if asked to logout they will, but turn right
* around and log back into the target. By waiting until here
* to issue the logout we'll have removed reference to the target
* such that this can't happen.
*/
if (isns_enabled() == True) {
if (isns_dereg(prop) != 0)
}
return (msg);
}
static char *
{
tgt_node_t *c = NULL;
int lun_num;
return (msg);
}
NULL) {
break;
}
return (msg);
}
return (msg);
}
NULL) {
return (msg);
}
goto error;
}
tgt_node_free(c);
change_made = True;
}
return (msg);
}
NULL) {
return (msg);
}
goto error;
}
tgt_node_free(c);
/* update isns */
if (isns_enabled()) {
}
change_made = True;
}
False) {
return (msg);
}
/*
* Save the iscsi-name which we'll need to remove LUNs.
*/
False) {
return (msg);
}
goto error;
/* ISNS de-register target if it's the last lun */
if (isns_dereg(prop) != 0)
}
change_made = True;
}
if (change_made == True) {
if (mgmt_config_save2scf() == True)
} else {
}
return (msg);
if (c != NULL)
tgt_node_free(c);
return (msg);
}
static char *
{
char *name;
return (msg);
}
NULL) {
break;
}
return (msg);
}
return (msg);
}
if (mgmt_config_save2scf() == True)
return (msg);
}
static char *
{
tgt_node_t *c = NULL;
return (msg);
}
NULL) {
break;
}
return (msg);
}
return (msg);
}
goto error;
}
tgt_node_free(c);
change_made = True;
}
if ((change_made != True) &&
change_made = True;
}
if (change_made == True) {
/* Isns re-register all target */
if (isns_enabled() == True)
isns_reg_all();
if (mgmt_config_save2scf() == True)
} else {
}
return (msg);
if (c != NULL)
tgt_node_free(c);
return (msg);
}