forked from Imagelibrary/rtems
2005-10-25 Joel Sherrill <joel@OARcorp.com>
* sapi/include/confdefs.h, telnetd/pty.c, telnetd/pty.h: Attempt to fix MAX_PTYS and provide a real configuration entry. This should make telnetd some suitable for inclusion in cpukit.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2005-10-25 Joel Sherrill <joel@OARcorp.com>
|
||||||
|
|
||||||
|
* sapi/include/confdefs.h, telnetd/pty.c, telnetd/pty.h: Attempt
|
||||||
|
to fix MAX_PTYS and provide a real configuration entry. This should
|
||||||
|
make telnetd some suitable for inclusion in cpukit.
|
||||||
|
|
||||||
2005-10-17 Ralf Corsepius <ralf.corsepius@rtems.org>
|
2005-10-17 Ralf Corsepius <ralf.corsepius@rtems.org>
|
||||||
|
|
||||||
* libfs/src/dosfs/msdos_misc.c: Revert to vers. 1.9.
|
* libfs/src/dosfs/msdos_misc.c: Revert to vers. 1.9.
|
||||||
|
|||||||
@@ -103,6 +103,20 @@ uint32_t rtems_libio_number_iops = CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS;
|
|||||||
((CONFIGURE_NUMBER_OF_TERMIOS_PORTS * 4) + 1)
|
((CONFIGURE_NUMBER_OF_TERMIOS_PORTS * 4) + 1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PTYs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIGURE_MAXIMUM_PTYS
|
||||||
|
#define CONFIGURE_MAXIMUM_PTYS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIGURE_INIT
|
||||||
|
int rtems_telnetd_maximum_ptys = CONFIGURE_MAXIMUM_PTYS;
|
||||||
|
#else
|
||||||
|
extern int rtems_telnetd_maximum_ptys;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mount Table Configuration
|
* Mount Table Configuration
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -45,10 +45,7 @@
|
|||||||
#define IAC_SE 240
|
#define IAC_SE 240
|
||||||
#define IAC_EOR 239
|
#define IAC_EOR 239
|
||||||
|
|
||||||
struct pty_tt;
|
typedef struct {
|
||||||
typedef struct pty_tt pty_t;
|
|
||||||
|
|
||||||
struct pty_tt {
|
|
||||||
char *devname;
|
char *devname;
|
||||||
struct rtems_termios_tty *ttyp;
|
struct rtems_termios_tty *ttyp;
|
||||||
tcflag_t c_cflag;
|
tcflag_t c_cflag;
|
||||||
@@ -57,11 +54,12 @@ struct pty_tt {
|
|||||||
|
|
||||||
int last_cr;
|
int last_cr;
|
||||||
int iac_mode;
|
int iac_mode;
|
||||||
};
|
} pty_t;
|
||||||
|
|
||||||
|
|
||||||
int ptys_initted=FALSE;
|
int ptys_initted=FALSE;
|
||||||
pty_t ptys[MAX_PTYS];
|
pty_t *ptys;
|
||||||
|
int rtems_telnetd_maximum_ptys;
|
||||||
|
|
||||||
/* This procedure returns the devname for a pty slot free.
|
/* This procedure returns the devname for a pty slot free.
|
||||||
* If not slot availiable (field socket>=0)
|
* If not slot availiable (field socket>=0)
|
||||||
@@ -71,7 +69,7 @@ pty_t ptys[MAX_PTYS];
|
|||||||
char * get_pty(int socket) {
|
char * get_pty(int socket) {
|
||||||
int ndx;
|
int ndx;
|
||||||
if (!ptys_initted) return NULL;
|
if (!ptys_initted) return NULL;
|
||||||
for (ndx=0;ndx<MAX_PTYS;ndx++) {
|
for (ndx=0;ndx<rtems_telnetd_maximum_ptys;ndx++) {
|
||||||
if (ptys[ndx].socket<0) {
|
if (ptys[ndx].socket<0) {
|
||||||
ptys[ndx].socket=socket;
|
ptys[ndx].socket=socket;
|
||||||
return ptys[ndx].devname;
|
return ptys[ndx].devname;
|
||||||
@@ -205,7 +203,7 @@ const rtems_termios_callbacks * pty_get_termios_handlers(int polled) ;
|
|||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
ptySetAttributes(int minor,const struct termios *t) {
|
ptySetAttributes(int minor,const struct termios *t) {
|
||||||
if (minor<MAX_PTYS) {
|
if (minor<rtems_telnetd_maximum_ptys) {
|
||||||
ptys[minor].c_cflag=t->c_cflag;
|
ptys[minor].c_cflag=t->c_cflag;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -217,7 +215,7 @@ static int
|
|||||||
ptyPollInitialize(int major,int minor,void * arg) {
|
ptyPollInitialize(int major,int minor,void * arg) {
|
||||||
rtems_libio_open_close_args_t * args = arg;
|
rtems_libio_open_close_args_t * args = arg;
|
||||||
struct termios t;
|
struct termios t;
|
||||||
if (minor<MAX_PTYS) {
|
if (minor<rtems_telnetd_maximum_ptys) {
|
||||||
if (ptys[minor].socket<0) return -1;
|
if (ptys[minor].socket<0) return -1;
|
||||||
ptys[minor].opened=TRUE;
|
ptys[minor].opened=TRUE;
|
||||||
ptys[minor].ttyp=args->iop->data1;
|
ptys[minor].ttyp=args->iop->data1;
|
||||||
@@ -230,7 +228,7 @@ ptyPollInitialize(int major,int minor,void * arg) {
|
|||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
ptyShutdown(int major,int minor,void * arg) {
|
ptyShutdown(int major,int minor,void * arg) {
|
||||||
if (minor<MAX_PTYS) {
|
if (minor<rtems_telnetd_maximum_ptys) {
|
||||||
ptys[minor].opened=FALSE;
|
ptys[minor].opened=FALSE;
|
||||||
if (ptys[minor].socket>=0) close(ptys[minor].socket);
|
if (ptys[minor].socket>=0) close(ptys[minor].socket);
|
||||||
ptys[minor].socket=-1;
|
ptys[minor].socket=-1;
|
||||||
@@ -246,7 +244,7 @@ ptyShutdown(int major,int minor,void * arg) {
|
|||||||
static int
|
static int
|
||||||
ptyPollWrite(int minor, const char * buf,int len) {
|
ptyPollWrite(int minor, const char * buf,int len) {
|
||||||
int count;
|
int count;
|
||||||
if (minor<MAX_PTYS) {
|
if (minor<rtems_telnetd_maximum_ptys) {
|
||||||
if (ptys[minor].socket<0) return -1;
|
if (ptys[minor].socket<0) return -1;
|
||||||
count=write(ptys[minor].socket,buf,len);
|
count=write(ptys[minor].socket,buf,len);
|
||||||
} else {
|
} else {
|
||||||
@@ -258,7 +256,7 @@ ptyPollWrite(int minor, const char * buf,int len) {
|
|||||||
static int
|
static int
|
||||||
ptyPollRead(int minor) {
|
ptyPollRead(int minor) {
|
||||||
int result;
|
int result;
|
||||||
if (minor<MAX_PTYS) {
|
if (minor<rtems_telnetd_maximum_ptys) {
|
||||||
if (ptys[minor].socket<0) return -1;
|
if (ptys[minor].socket<0) return -1;
|
||||||
result=read_pty(minor);
|
result=read_pty(minor);
|
||||||
return result;
|
return result;
|
||||||
@@ -283,7 +281,8 @@ const rtems_termios_callbacks * pty_get_termios_handlers(int polled) {
|
|||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
void init_ptys(void) {
|
void init_ptys(void) {
|
||||||
int ndx;
|
int ndx;
|
||||||
for (ndx=0;ndx<MAX_PTYS;ndx++) {
|
ptys = malloc( sizeof(pty_t) * rtems_telnetd_maximum_ptys );
|
||||||
|
for (ndx=0;ndx<rtems_telnetd_maximum_ptys;ndx++) {
|
||||||
ptys[ndx].devname=malloc(strlen("/dev/ptyXX")+1);
|
ptys[ndx].devname=malloc(strlen("/dev/ptyXX")+1);
|
||||||
sprintf(ptys[ndx].devname,"/dev/pty%X",ndx);
|
sprintf(ptys[ndx].devname,"/dev/pty%X",ndx);
|
||||||
ptys[ndx].ttyp=NULL;
|
ptys[ndx].ttyp=NULL;
|
||||||
@@ -326,14 +325,15 @@ rtems_device_driver pty_initialize(
|
|||||||
/*
|
/*
|
||||||
* Register the devices
|
* Register the devices
|
||||||
*/
|
*/
|
||||||
for (ndx=0;ndx<MAX_PTYS;ndx++) {
|
for (ndx=0;ndx<rtems_telnetd_maximum_ptys;ndx++) {
|
||||||
status = rtems_io_register_name(ptys[ndx].devname, major, ndx);
|
status = rtems_io_register_name(ptys[ndx].devname, major, ndx);
|
||||||
if (status != RTEMS_SUCCESSFUL)
|
if (status != RTEMS_SUCCESSFUL)
|
||||||
rtems_fatal_error_occurred(status);
|
rtems_fatal_error_occurred(status);
|
||||||
chmod(ptys[ndx].devname,0660);
|
chmod(ptys[ndx].devname,0660);
|
||||||
chown(ptys[ndx].devname,2,0); /* tty,root*/
|
chown(ptys[ndx].devname,2,0); /* tty,root*/
|
||||||
};
|
};
|
||||||
printk("Device: /dev/pty%X../dev/pty%X (%d)pseudo-terminals registered.\n",0,MAX_PTYS-1,MAX_PTYS);
|
printk("Device: /dev/pty%X../dev/pty%X (%d)pseudo-terminals registered.\n",
|
||||||
|
0,rtems_telnetd_maximum_ptys-1,rtems_telnetd_maximum_ptys);
|
||||||
|
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
|
|
||||||
#ifndef MAX_PTYS
|
|
||||||
#define MAX_PTYS 16
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char * get_pty(int socket);
|
char * get_pty(int socket);
|
||||||
|
|
||||||
rtems_device_driver pty_initialize(
|
rtems_device_driver pty_initialize(
|
||||||
|
|||||||
Reference in New Issue
Block a user