summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cpukit/ChangeLog6
-rw-r--r--cpukit/sapi/include/confdefs.h14
-rw-r--r--cpukit/telnetd/pty.c32
-rw-r--r--cpukit/telnetd/pty.h4
4 files changed, 36 insertions, 20 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 8e76ad6e7f..ed58954bd8 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -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>
* libfs/src/dosfs/msdos_misc.c: Revert to vers. 1.9.
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 4d6fea1e89..d7dbc2ba1d 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -104,6 +104,20 @@ uint32_t rtems_libio_number_iops = CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS;
#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
*/
diff --git a/cpukit/telnetd/pty.c b/cpukit/telnetd/pty.c
index c19d05db37..38aa0a1c97 100644
--- a/cpukit/telnetd/pty.c
+++ b/cpukit/telnetd/pty.c
@@ -45,10 +45,7 @@
#define IAC_SE 240
#define IAC_EOR 239
-struct pty_tt;
-typedef struct pty_tt pty_t;
-
-struct pty_tt {
+typedef struct {
char *devname;
struct rtems_termios_tty *ttyp;
tcflag_t c_cflag;
@@ -57,11 +54,12 @@ struct pty_tt {
int last_cr;
int iac_mode;
-};
+} pty_t;
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.
* If not slot availiable (field socket>=0)
@@ -71,7 +69,7 @@ pty_t ptys[MAX_PTYS];
char * get_pty(int socket) {
int ndx;
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) {
ptys[ndx].socket=socket;
return ptys[ndx].devname;
@@ -205,7 +203,7 @@ const rtems_termios_callbacks * pty_get_termios_handlers(int polled) ;
/*-----------------------------------------------------------*/
static int
ptySetAttributes(int minor,const struct termios *t) {
- if (minor<MAX_PTYS) {
+ if (minor<rtems_telnetd_maximum_ptys) {
ptys[minor].c_cflag=t->c_cflag;
} else {
return -1;
@@ -217,7 +215,7 @@ static int
ptyPollInitialize(int major,int minor,void * arg) {
rtems_libio_open_close_args_t * args = arg;
struct termios t;
- if (minor<MAX_PTYS) {
+ if (minor<rtems_telnetd_maximum_ptys) {
if (ptys[minor].socket<0) return -1;
ptys[minor].opened=TRUE;
ptys[minor].ttyp=args->iop->data1;
@@ -230,7 +228,7 @@ ptyPollInitialize(int major,int minor,void * arg) {
/*-----------------------------------------------------------*/
static int
ptyShutdown(int major,int minor,void * arg) {
- if (minor<MAX_PTYS) {
+ if (minor<rtems_telnetd_maximum_ptys) {
ptys[minor].opened=FALSE;
if (ptys[minor].socket>=0) close(ptys[minor].socket);
ptys[minor].socket=-1;
@@ -246,7 +244,7 @@ ptyShutdown(int major,int minor,void * arg) {
static int
ptyPollWrite(int minor, const char * buf,int len) {
int count;
- if (minor<MAX_PTYS) {
+ if (minor<rtems_telnetd_maximum_ptys) {
if (ptys[minor].socket<0) return -1;
count=write(ptys[minor].socket,buf,len);
} else {
@@ -258,7 +256,7 @@ ptyPollWrite(int minor, const char * buf,int len) {
static int
ptyPollRead(int minor) {
int result;
- if (minor<MAX_PTYS) {
+ if (minor<rtems_telnetd_maximum_ptys) {
if (ptys[minor].socket<0) return -1;
result=read_pty(minor);
return result;
@@ -283,7 +281,8 @@ const rtems_termios_callbacks * pty_get_termios_handlers(int polled) {
/*-----------------------------------------------------------*/
void init_ptys(void) {
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);
sprintf(ptys[ndx].devname,"/dev/pty%X",ndx);
ptys[ndx].ttyp=NULL;
@@ -315,7 +314,7 @@ rtems_device_driver pty_initialize(
)
{
int ndx;
- rtems_status_code status ;
+ rtems_status_code status;
/*
* Set up ptys
@@ -326,14 +325,15 @@ rtems_device_driver pty_initialize(
/*
* 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);
if (status != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred(status);
chmod(ptys[ndx].devname,0660);
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;
}
diff --git a/cpukit/telnetd/pty.h b/cpukit/telnetd/pty.h
index 9d3d6295ce..5d27ddb9d9 100644
--- a/cpukit/telnetd/pty.h
+++ b/cpukit/telnetd/pty.h
@@ -20,10 +20,6 @@ extern "C" {
#include <rtems.h>
-#ifndef MAX_PTYS
-#define MAX_PTYS 16
-#endif
-
char * get_pty(int socket);
rtems_device_driver pty_initialize(