diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-06-20 22:20:32 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-06-20 22:20:32 +0000 |
commit | 442e430ddcc94536705b3fef428f7aa71dc7e112 (patch) | |
tree | ea9299bd1409e991c1910958ad4b62d6329da11c /cpukit/libcsupport | |
parent | 2007-06-20 Ray Xu <rayx@gmail.com> (diff) | |
download | rtems-442e430ddcc94536705b3fef428f7aa71dc7e112.tar.bz2 |
2007-06-20 Joel Sherrill <joel.sherrill@OARcorp.com>
* libcsupport/Makefile.am:
* libcsupport/src/open_dev_console.c: New file.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r-- | cpukit/libcsupport/Makefile.am | 3 | ||||
-rw-r--r-- | cpukit/libcsupport/src/open_dev_console.c | 51 |
2 files changed, 53 insertions, 1 deletions
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index 589e75fbb1..96ab0d0413 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -45,7 +45,8 @@ ASSOCIATION_C_FILES = src/assoc.c src/assoclocalbyname.c \ BASE_FS_C_FILES = src/base_fs.c src/mount.c src/unmount.c src/libio.c \ src/libio_init.c \ - src/libio_sockets.c src/eval.c src/fs_null_handlers.c src/privateenv.c + src/libio_sockets.c src/eval.c src/fs_null_handlers.c src/privateenv.c \ + src/open_dev_console.c TERMIOS_C_FILES = src/cfgetispeed.c src/cfgetospeed.c src/cfsetispeed.c \ src/cfsetospeed.c src/tcgetattr.c src/tcsetattr.c src/tcdrain.c \ diff --git a/cpukit/libcsupport/src/open_dev_console.c b/cpukit/libcsupport/src/open_dev_console.c new file mode 100644 index 0000000000..4606c1f15f --- /dev/null +++ b/cpukit/libcsupport/src/open_dev_console.c @@ -0,0 +1,51 @@ +/* + * open_dev_console - open /dev/console + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems.h> +#include <rtems/libio.h> +#include <fcntl.h> + +/* + * This is a replaceable stub + */ + +void open_dev_console(void) +{ + int stdin_fd, stdout_fd, stderr_fd; + int error_code = 'S' << 24 | 'T' << 16 | 'D' << 8; + + /* + * Attempt to open /dev/console. + */ + if ((stdin_fd = open("/dev/console", O_RDONLY, 0)) == -1) { + /* + * There may not be a console driver so this is OK. + */ + return; + } + + /* + * But if we find /dev/console once, we better find it twice more + * or something is REALLY wrong. + */ + if ((stdout_fd = open("/dev/console", O_WRONLY, 0)) == -1) + rtems_fatal_error_occurred( error_code | '1' ); + + if ((stderr_fd = open("/dev/console", O_WRONLY, 0)) == -1) + rtems_fatal_error_occurred( error_code | '2' ); +} + |