This commit is contained in:
Joel Sherrill
1999-11-16 15:27:52 +00:00
parent b88691c30f
commit c7016198fa
16 changed files with 619 additions and 3 deletions

View File

@@ -0,0 +1,33 @@
/*
* ctermid() - POSIX 1003.1b 4.7.1 - Generate Terminal Pathname
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <stdio.h>
static ctermid_name = "/dev/console";
char *ctermid(
char *s
)
{
if ( !s )
return ctermid_name;
strcpy( s, ctermid_name );
return s;
}
#endif

View File

@@ -0,0 +1,33 @@
/*
* tcgetprgrp() - POSIX 1003.1b 7.2.3 - Get Foreground Process Group ID
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
/* #include <sys/ioctl.h> */
int ioctl();
#include <rtems/libio.h>
pid_t tcgetprgrp(int fd)
{
return getpid();
}
#endif

View File

@@ -0,0 +1,33 @@
/*
* tcsendbreak() - POSIX 1003.1b 7.2.2 - Line Control Functions
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
/* #include <sys/ioctl.h> */
int ioctl();
#include <rtems/libio.h>
int tcsendbreak ( int fd, int duration )
{
return 0;
}
#endif

View File

@@ -0,0 +1,33 @@
/*
* tcsetprgrp() - POSIX 1003.1b 7.2.4 - Set Foreground Process Group ID
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
/* #include <sys/ioctl.h> */
int ioctl();
#include <rtems/libio.h>
int tcsetprgrp(int fd, pid_t pid)
{
return 0;
}
#endif

View File

@@ -0,0 +1,73 @@
/*
* ttyname_r() - POSIX 1003.1b 4.7.2 - Demetermine Terminal Device Name
*
* $Id$
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <termios.h>
#include <unistd.h>
#include <paths.h>
#include <_syslist.h>
#include <errno.h>
#include <rtems/posix/seterr.h>
int ttyname_r(
int fd,
char *name,
int namesize
)
{
struct stat sb;
struct termios tty;
struct dirent *dirp;
DIR *dp;
struct stat dsb;
char *rval;
/* Must be a terminal. */
if (tcgetattr (fd, &tty) < 0)
set_errno_and_return_minus_one(EBADF);
/* Must be a character device. */
if (_fstat (fd, &sb) || !S_ISCHR (sb.st_mode))
set_errno_and_return_minus_one(EBADF);
if ((dp = opendir (_PATH_DEV)) == NULL)
set_errno_and_return_minus_one(EBADF);
for (rval = NULL; (dirp = readdir (dp)) != NULL ;)
{
if (dirp->d_ino != sb.st_ino)
continue;
strcpy (name + sizeof (_PATH_DEV) - 1, dirp->d_name);
if (stat (name, &dsb) || sb.st_dev != dsb.st_dev ||
sb.st_ino != dsb.st_ino)
continue;
(void) closedir (dp);
rval = name;
break;
}
(void) closedir (dp);
return 0;
}
static char buf[sizeof (_PATH_DEV) + MAXNAMLEN] = _PATH_DEV;
/*
* ttyname() - POSIX 1003.1b 4.7.2 - Demetermine Terminal Device Name
*/
char *ttyname(
int fd
)
{
if ( !ttyname_r( fd, buf, sizeof(buf) ) )
return buf;
return NULL;
}

View File

@@ -32,13 +32,13 @@ IMFS_C_PIECES = imfs_chown imfs_creat imfs_directory imfs_eval imfs_free \
imfs_fcntl miniimfs_init
TERMIOS_C_PIECES = cfgetispeed cfgetospeed cfsetispeed cfsetospeed tcgetattr \
tcsetattr tcdrain tcflow tcflush termios \
termiosinitialize termiosreserveresources
tcsetattr tcdrain tcflow tcflush tcgetprgrp tcsendbreak tcsetpgrp \
termios termiosinitialize termiosreserveresources
SYSTEM_CALL_C_PIECES = open close read write lseek ioctl mkdir mknod mkfifo \
rmdir chdir chmod fchmod chown link unlink umask ftruncate utime fstat \
fcntl fpathconf getdents fsync fdatasync pipe dup dup2 symlink readlink \
creat isatty
creat
DIRECTORY_SCAN_C_PIECES = opendir closedir readdir rewinddir scandir seekdir \
telldir getcwd
@@ -47,6 +47,7 @@ MALLOC_C_PIECES = malloc __brk __sbrk
PASSWORD_GROUP_C_PIECES = getpwent getgrent
TERMINAL_IDENTIFICATION = ctermid isatty ttyname ttyname_r
LIBC_GLUE_C_PIECES = __getpid __gettod __times truncate access stat \
lstat pathconf newlibc no_posix no_libc

33
c/src/lib/libc/ctermid.c Normal file
View File

@@ -0,0 +1,33 @@
/*
* ctermid() - POSIX 1003.1b 4.7.1 - Generate Terminal Pathname
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <stdio.h>
static ctermid_name = "/dev/console";
char *ctermid(
char *s
)
{
if ( !s )
return ctermid_name;
strcpy( s, ctermid_name );
return s;
}
#endif

View File

@@ -0,0 +1,33 @@
/*
* tcgetprgrp() - POSIX 1003.1b 7.2.3 - Get Foreground Process Group ID
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
/* #include <sys/ioctl.h> */
int ioctl();
#include <rtems/libio.h>
pid_t tcgetprgrp(int fd)
{
return getpid();
}
#endif

View File

@@ -0,0 +1,33 @@
/*
* tcsendbreak() - POSIX 1003.1b 7.2.2 - Line Control Functions
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
/* #include <sys/ioctl.h> */
int ioctl();
#include <rtems/libio.h>
int tcsendbreak ( int fd, int duration )
{
return 0;
}
#endif

View File

@@ -0,0 +1,33 @@
/*
* tcsetprgrp() - POSIX 1003.1b 7.2.4 - Set Foreground Process Group ID
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
/* #include <sys/ioctl.h> */
int ioctl();
#include <rtems/libio.h>
int tcsetprgrp(int fd, pid_t pid)
{
return 0;
}
#endif

73
c/src/lib/libc/ttyname.c Normal file
View File

@@ -0,0 +1,73 @@
/*
* ttyname_r() - POSIX 1003.1b 4.7.2 - Demetermine Terminal Device Name
*
* $Id$
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <termios.h>
#include <unistd.h>
#include <paths.h>
#include <_syslist.h>
#include <errno.h>
#include <rtems/posix/seterr.h>
int ttyname_r(
int fd,
char *name,
int namesize
)
{
struct stat sb;
struct termios tty;
struct dirent *dirp;
DIR *dp;
struct stat dsb;
char *rval;
/* Must be a terminal. */
if (tcgetattr (fd, &tty) < 0)
set_errno_and_return_minus_one(EBADF);
/* Must be a character device. */
if (_fstat (fd, &sb) || !S_ISCHR (sb.st_mode))
set_errno_and_return_minus_one(EBADF);
if ((dp = opendir (_PATH_DEV)) == NULL)
set_errno_and_return_minus_one(EBADF);
for (rval = NULL; (dirp = readdir (dp)) != NULL ;)
{
if (dirp->d_ino != sb.st_ino)
continue;
strcpy (name + sizeof (_PATH_DEV) - 1, dirp->d_name);
if (stat (name, &dsb) || sb.st_dev != dsb.st_dev ||
sb.st_ino != dsb.st_ino)
continue;
(void) closedir (dp);
rval = name;
break;
}
(void) closedir (dp);
return 0;
}
static char buf[sizeof (_PATH_DEV) + MAXNAMLEN] = _PATH_DEV;
/*
* ttyname() - POSIX 1003.1b 4.7.2 - Demetermine Terminal Device Name
*/
char *ttyname(
int fd
)
{
if ( !ttyname_r( fd, buf, sizeof(buf) ) )
return buf;
return NULL;
}

View File

@@ -0,0 +1,33 @@
/*
* ctermid() - POSIX 1003.1b 4.7.1 - Generate Terminal Pathname
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <stdio.h>
static ctermid_name = "/dev/console";
char *ctermid(
char *s
)
{
if ( !s )
return ctermid_name;
strcpy( s, ctermid_name );
return s;
}
#endif

View File

@@ -0,0 +1,33 @@
/*
* tcgetprgrp() - POSIX 1003.1b 7.2.3 - Get Foreground Process Group ID
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
/* #include <sys/ioctl.h> */
int ioctl();
#include <rtems/libio.h>
pid_t tcgetprgrp(int fd)
{
return getpid();
}
#endif

View File

@@ -0,0 +1,33 @@
/*
* tcsendbreak() - POSIX 1003.1b 7.2.2 - Line Control Functions
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
/* #include <sys/ioctl.h> */
int ioctl();
#include <rtems/libio.h>
int tcsendbreak ( int fd, int duration )
{
return 0;
}
#endif

View File

@@ -0,0 +1,33 @@
/*
* tcsetprgrp() - POSIX 1003.1b 7.2.4 - Set Foreground Process Group ID
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
/* #include <sys/ioctl.h> */
int ioctl();
#include <rtems/libio.h>
int tcsetprgrp(int fd, pid_t pid)
{
return 0;
}
#endif

View File

@@ -0,0 +1,73 @@
/*
* ttyname_r() - POSIX 1003.1b 4.7.2 - Demetermine Terminal Device Name
*
* $Id$
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <termios.h>
#include <unistd.h>
#include <paths.h>
#include <_syslist.h>
#include <errno.h>
#include <rtems/posix/seterr.h>
int ttyname_r(
int fd,
char *name,
int namesize
)
{
struct stat sb;
struct termios tty;
struct dirent *dirp;
DIR *dp;
struct stat dsb;
char *rval;
/* Must be a terminal. */
if (tcgetattr (fd, &tty) < 0)
set_errno_and_return_minus_one(EBADF);
/* Must be a character device. */
if (_fstat (fd, &sb) || !S_ISCHR (sb.st_mode))
set_errno_and_return_minus_one(EBADF);
if ((dp = opendir (_PATH_DEV)) == NULL)
set_errno_and_return_minus_one(EBADF);
for (rval = NULL; (dirp = readdir (dp)) != NULL ;)
{
if (dirp->d_ino != sb.st_ino)
continue;
strcpy (name + sizeof (_PATH_DEV) - 1, dirp->d_name);
if (stat (name, &dsb) || sb.st_dev != dsb.st_dev ||
sb.st_ino != dsb.st_ino)
continue;
(void) closedir (dp);
rval = name;
break;
}
(void) closedir (dp);
return 0;
}
static char buf[sizeof (_PATH_DEV) + MAXNAMLEN] = _PATH_DEV;
/*
* ttyname() - POSIX 1003.1b 4.7.2 - Demetermine Terminal Device Name
*/
char *ttyname(
int fd
)
{
if ( !ttyname_r( fd, buf, sizeof(buf) ) )
return buf;
return NULL;
}