/*
* 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"
/*
* Configuration and setup interface to vcc driver.
* At intialization time, vntsd opens vcc ctrl port and read initial
* configuratioa. It manages console groups, creates the listen thread,
* dynamically adds and removes virtual console within a group.
*/
#include <syslog.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wait.h>
#include <time.h>
#include <synch.h>
#include <thread.h>
#include <signal.h>
#include "vntsd.h"
/* signal all clients that console has been deleted */
{
return (B_FALSE);
}
/* free console structure */
static void
{
}
/* free group structure */
static void
{
}
/*
* all clients connected to a console must disconnect before
* removing a console.
*/
static void
{
/* wait for all clients disconnect from the console */
/* signal client to disconnect the console */
/* wait for clients to disconnect */
}
/* reduce console count in the group */
}
/* search for a group whose console is being deleted */
static boolean_t
{
return (B_TRUE);
} else {
return (B_FALSE);
}
}
/* search for a console that is being deleted */
static boolean_t
{
return (B_TRUE);
} else {
return (B_FALSE);
}
}
/* delete a console */
void
{
for (; ; ) {
/* get the group contains deleted console */
/* no more group has console deleted */
return;
}
for (; ; ) {
/* get the console to be deleted */
/* clean up any deleted console in the group */
/* no more cons to delete */
break;
}
/* remove console from the group */
/* clean up the console */
}
/* delete group? */
/* no more console in the group delete group */
groupp);
/* clean up the group */
break;
}
}
}
}
/* clean up a group */
void
{
/* prevent from reentry */
return;
}
/* mark group waiting for listen thread to exits */
/* walk through no cons client queue */
}
/* waiting for listen thread to exit */
/* signal listen thread to exit */
/* wait listen thread to exit */
}
/* free group */
}
/* allocate and initialize console structure */
static vntsd_cons_t *
{
int rv;
/* allocate console */
return (NULL);
}
/* intialize console */
/* join the group */
return (NULL);
}
return (consp);
}
/* compare tcp with group->tcp */
static boolean_t
{
}
/* allocate and initialize group */
static vntsd_group_t *
{
/* allocate group */
return (NULL);
}
/* initialize group */
if (group_name != NULL) {
}
groupp->group_name);
return (groupp);
}
/* mark a deleted console */
{
return (B_FALSE);
}
/*
* Initialize a console, if console is associated with with a
* new group, intialize the group.
*/
static int
{
int rv;
*new_groupp = NULL;
/* match group by tcp port */
/*
* group with same tcp port found.
* if there is no console in the group, the
* group should be removed and the tcp port can
* be used for tne new group.
* This is possible, when there is tight loop of
* removed, a read thread will have an I/O error because
* vcc has closed the port. The read thread then marks
* the console is removed and notify main thread to
* remove the console.
* Meanwhile, the same port and its group (with same
* tcp port and group name) is created. Vcc notify
* vntsd that new console is added.
* Main thread now have two events. If main thread polls
* out vcc notification first, it will find that there is
* a group has no console.
*/
if (vntsd_chk_group_total_cons(groupp) == 0) {
/* all consoles in the group have been removed */
/* conflict group name */
"group name is different from existing group");
return (VNTSD_ERR_VCC_CTRL_DATA);
} else {
/* group already existed */
}
}
/* new group */
return (VNTSD_ERR_NO_MEM);
}
/* queue group to vntsdp */
if (rv != VNTSD_SUCCESS) {
return (rv);
}
*new_groupp = groupp;
}
/* intialize console */
/* no memory */
if (new_groupp != NULL) {
/* clean up new group */
}
return (VNTSD_ERR_NO_MEM);
}
return (VNTSD_SUCCESS);
}
/* create listen thread */
static boolean_t
{
int rv;
!= 0) {
"Can not create listen thread for"
/* clean up group queue */
}
return (rv != 0);
}
/* find deleted console by console no */
static boolean_t
{
return (B_FALSE);
/* has console marked as deleted? */
return (B_TRUE);
/* there is no client for this console */
return (B_TRUE);
/* need to notify clients of console ? */
/* clients of console have notified */
return (B_FALSE);
return (B_TRUE);
}
/* find group structure from console no */
static boolean_t
{
}
/* delete a console if the console exists in the vntsd */
static void
{
/* group exists? */
&cons_no);
/* no such group */
return;
}
/* group exists, if console exists? */
/* no such console */
return;
}
/* console exists - mark console for main thread to delete it */
/* already marked */
return;
}
}
/* add a console */
static void
{
int rv;
"do_add_cons():Can not add console=%d", cons_no);
/* get console configuration from vcc */
!= VNTSD_SUCCESS) {
return;
}
/* clean up the console if console was deleted and added again */
/* initialize console */
/* no memory to add this new console */
return;
}
/* new group */
/* create listen thread for this console */
if (create_listen_thread(groupp)) {
}
}
}
/* daemon wake up */
void
{
/* reason to wake up */
return;
}
case VCC_CONS_ADDED:
break;
case VCC_CONS_MISS_ADDED:
/* an added port was deleted before vntsd can process it */
return;
default:
break;
}
}
/* initial console configuration */
void
{
int i;
int num_cons;
/* num of consoles */
num_cons = 0;
return;
}
if (num_cons == 0) {
return;
}
/* allocate memory for all consoles */
return;
}
/* get console table */
"for console table\n");
return;
}
/* intialize groups and consoles */
for (i = 0; i < num_cons; i++) {
!= VNTSD_SUCCESS) {
}
}
/* create listen thread for each group */
for (; ; ) {
break;
}
}
}