th_manage.c revision aeb0348ba68ad95563cead4a53d0c70e207cf130
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <libdevice.h>
#include <libdevinfo.h>
#define _KERNEL
#include <sys/dditypes.h>
static int online_device(char *path);
static int offline_device(char *path);
static int getstate_device(char *path);
#define CMD_TABLE_SIZE 11
#define BOFI_ONLINE 0
#define BOFI_OFFLINE 1
#define BOFI_GETSTATE 2
#define BOFI_GETPATH 3
static struct {
char *string;
int val;
int devctl_val;
} cmd_table[] = {
};
int
{
struct bofi_errctl errctl;
struct bofi_get_handles get_handles;
int command = -1;
int devctl_command = -1;
int i;
int fd;
char buf[MAXPATHLEN];
char path[MAXPATHLEN];
if (argc == 3) {
for (i = 0; i < CMD_TABLE_SIZE; i++) {
}
}
switch (devctl_command) {
case BOFI_ONLINE:
case BOFI_OFFLINE:
case BOFI_GETPATH:
case BOFI_GETSTATE:
break;
default:
MAXPATHLEN) == -1) {
"th_manage - invalid path\n");
exit(1);
}
}
} else if (argc == 4) {
for (i = 0; i < CMD_TABLE_SIZE; i++) {
}
}
switch (devctl_command) {
case BOFI_ONLINE:
case BOFI_OFFLINE:
case BOFI_GETPATH:
case BOFI_GETSTATE:
MAXPATHLEN) == -1) {
exit(1);
}
default:
break;
}
} else {
" th_manage name instance state\n");
" th_manage path state\n");
exit(2);
}
if (command == -1) {
/*
* might have been a devctl command
*/
if (devctl_command == BOFI_ONLINE) {
while (online_device(path) != 0) {
(void) sleep(3);
}
exit(0);
}
if (devctl_command == BOFI_OFFLINE) {
while (offline_device(path) != 0) {
(void) sleep(3);
}
exit(0);
}
if (devctl_command == BOFI_GETSTATE) {
if (getstate_device(path) != 0) {
perror("th_manage - getstate failed");
exit(1);
} else {
exit(0);
}
}
if (devctl_command == BOFI_GETPATH) {
exit(0);
}
"th_manage: invalid command\n");
" Command must be one of start, stop, broadcast, "
"get_handles,\n");
" clear_acc_chk, clear_errors or clear_errdefs\n");
exit(2);
}
if (fd == -1) {
perror("th_manage - open of bofi driver");
exit(2);
}
if (command == BOFI_GET_HANDLES) {
perror("th_manage - setting state failed");
exit(2);
}
exit(0);
}
struct bofi_get_hdl_info hdli;
int i, j, *instp;
/*
* Ask the bofi driver for all handles created by the driver
* under test.
*/
perror("driver failed to return access handles");
exit(1);
}
exit(0); /* no handles */
}
perror("out of memory");
exit(1);
}
perror("couldn't obtain all handles");
exit(1);
}
perror("out of memory");
exit(1);
}
*instp = -1;
for (j = 0; instp[j] != -1; j++)
break;
if (instp[j] == -1) {
}
}
for (i = 0; instp[i] != -1; i++) {
"command failed on instance %d : %s\n",
exit(1);
}
}
} else {
perror("th_manage - setting state failed");
exit(1);
}
}
return (0);
}
/*
* These functions provide access to the devctl functions,
*/
static int
online_device(char *path)
{
return (-1);
}
return (-1);
}
return (0);
}
static int
offline_device(char *path)
{
return (-1);
}
return (-1);
}
return (0);
}
static int
getstate_device(char *path)
{
return (-1);
}
return (-1);
}
switch (state) {
case DEVICE_DOWN:
break;
case DEVICE_OFFLINE:
break;
case DEVICE_ONLINE:
break;
case (DEVICE_ONLINE | DEVICE_BUSY):
break;
case (DEVICE_DOWN | DEVICE_BUSY):
break;
default:
break;
}
return (0);
}
static int
{
char *driver_name;
return (-1);
return (-1);
}
return (0);
}
struct walk_arg {
char *path;
int instance;
char name[MAXPATHLEN];
int found;
int pathlen;
};
static int
{
char *driver_name;
char *path;
if (driver_name != NULL) {
}
return (DI_WALK_TERMINATE);
}
}
return (DI_WALK_CONTINUE);
}
static int
{
return (-1);
return (-1);
}
return (-1);
}
return (0);
}