iscsitsvc.c revision a6d42e7d71324c5193c3b94d57d96ba2925d52e1
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * CDDL HEADER START
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * The contents of this file are subject to the terms of the
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Common Development and Distribution License (the "License").
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * You may not use this file except in compliance with the License.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * See the License for the specific language governing permissions
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * and limitations under the License.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * When distributing Covered Code, include this CDDL HEADER in each
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * If applicable, add the following below this CDDL HEADER, with the
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * fields enclosed by brackets "[]" replaced with your own identifying
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * information: Portions Copyright [yyyy] [name of copyright owner]
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * CDDL HEADER END
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Use is subject to license terms.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int it_enable(int, char **, cmdOptions_t *, void *);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic int it_disable(int, char **, cmdOptions_t *, void *);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * MAJOR - This should only change when there is an incompatible change made
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * to the interfaces or the output.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * MINOR - This should change whenever there is a new command or new feature
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * with no incompatible change.
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/* 10 ms sleep in nanoseconds */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/* tables set up based on cmdparse instructions */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/* add new options here */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Add new subcommands here
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap {"start", it_enable, NULL, NULL, NULL, OPERAND_NONE, NULL},
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap {"stop", it_disable, NULL, NULL, NULL, OPERAND_NONE, NULL},
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/* globals */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Opens the iSCSI Target Node
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * fd - Return the iscsit file descriptor
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (void) fprintf(stdout, "open failed: INVALID");
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Enables the iSCSI Target
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapit_enable(int operandLen, char *operands[], cmdOptions_t *options,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Open the iscsi target node */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (void) fprintf(stdout, "Unable to open device %s", ISCSIT_NODE);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (void) fprintf(stdout, "it_enable [fd=%d]\n", fd);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* enable the iscsi target */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (void) strncpy(buf + sizeof (uint32_t), "target_name",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if ((ret != -1) && (ret < sizeof (hostinfo.fqhn))) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap hostinfo.length += sysinfo(SI_SRPC_DOMAIN, fqhnp,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (void) fprintf(stdout, "it_enable: fqhn = '%s'\n", hostinfo.fqhn);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if ((ret = ioctl(fd, ISCSIT_IOC_ENABLE_SVC, &hostinfo)) != 0) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (void) fprintf(stdout, "Unable to issue ioctl: %d", errno);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * Disable the iSCSI target
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap/* ARGSUSED */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapit_disable(int operandLen, char *operands[], cmdOptions_t *options,
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap gettext("Requesting to disable iscsi target"));
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* Open the iscsi target node */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* disable the iSCSI target */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap if ((ret = ioctl(fd, ISCSIT_IOC_DISABLE_SVC, NULL)) != 0) {
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * execFullName - exec name of program (argv[0])
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * copied from usr/src/cmd/zoneadm/zoneadm.c in OS/Net
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * (changed name to lowerCamelCase to keep consistent with this file)
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap * command name portion of execFullName
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlapstatic char *
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* guard against '/' at end of command invocation */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap /* set global command name */
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap (void) snprintf(versionString, VERSION_STRING_MAX_LEN, "%s.%s",
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap synTables.subCommandPropsTbl = &subcommands[0];
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap ret = cmdParse(argc, argv, synTables, subcommandArgs, &funcRet);
a6d42e7d71324c5193c3b94d57d96ba2925d52e1Peter Dunlap} /* end main */