read.c revision 8100efacfab0b6f34c0700fc9bf20aba0cc6ff93
/*
* 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
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* read thread - Read from tcp client and write to vcc driver. There are one
* writer and multiple readers per console. The first client who connects to
* a console get write access. An error message is returned to readers if they
* attemp to input commands. Read thread accepts special daemon commands from
* all clients.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <thread.h>
#include <synch.h>
#include <signal.h>
#include <assert.h>
#include <ctype.h>
#include <syslog.h>
#include <libintl.h>
#include "vntsd.h"
#include "chars.h"
/* write_vcc() - write to vcc virtual console */
static int
{
int n;
if (n < 0) {
/* write error */
return (vntsd_cons_chk_intr(clientp));
}
return (VNTSD_STATUS_VCC_IO_ERR);
}
assert(n != 0);
return (VNTSD_SUCCESS);
}
/*
* acquire_writer() the client is going to be writer.
* insert the client to the head of the console client queue.
*/
static int
{
int rv;
/* clientp is a writer already */
return (VNTSD_SUCCESS);
}
/* current writer */
/* move client to be first in the console queue */
/* move previous writer to be the second in the queue */
if (rv != VNTSD_SUCCESS) {
return (rv);
}
/* write warning message to the writer */
gettext("Warning: Console connection forced into read-only mode")))
!= VNTSD_SUCCESS) {
return (rv);
}
return (VNTSD_SUCCESS);
}
/* interrupt handler */
int
{
return (VNTSD_STATUS_CLIENT_QUIT);
}
return (VNTSD_STATUS_RESELECT_CONS);
}
return (VNTSD_STATUS_CLIENT_QUIT);
}
return (VNTSD_STATUS_CONTINUE);
}
/* read from client */
static int
{
int rv;
for (; ; ) {
switch (rv) {
case VNTSD_STATUS_CONTINUE:
break;
if (rv != VNTSD_SUCCESS) {
return (rv);
}
break;
default:
return (rv);
}
}
}
/* vntsd_read worker */
int
{
char c;
int rv;
for (; ; ) {
/* client input */
if (rv == VNTSD_STATUS_INTR) {
}
if (rv != VNTSD_SUCCESS) {
return (rv);
}
/* reader - print error message */
/* check errors and may exit */
if (rv == VNTSD_STATUS_INTR) {
}
if (rv != VNTSD_SUCCESS) {
return (rv);
}
}
continue;
}
switch (rv) {
case VNTSD_STATUS_CONTINUE:
continue;
break;
case VNTSD_STATUS_INTR:
if (rv != VNTSD_SUCCESS) {
return (rv);
}
break;
case VNTSD_SUCCESS:
break;
default:
return (rv);
}
/* write to vcc */
if (rv == VNTSD_STATUS_INTR) {
}
if (rv != VNTSD_SUCCESS) {
return (rv);
}
}
/*NOTREACHED*/
return (NULL);
}