source: rtems/cpukit/libcsupport/src/open_dev_console.c @ eecf752

4.104.115
Last change on this file since eecf752 was eecf752, checked in by Joel Sherrill <joel.sherrill@…>, on 11/09/09 at 15:19:57

2009-11-09 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/open_dev_console.c: Use constant numbers to avoid overflow when shifting on 16-bit targets.
  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 *  open_dev_console - open /dev/console
3 *
4 *  COPYRIGHT (c) 1989-2009.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems.h>
19#include <rtems/libio.h>
20#include <fcntl.h>
21
22/*
23 *  This is a replaceable stub which opens the console, if present.
24 */
25void open_dev_console(void)
26{
27  int      stdin_fd;
28  int      stdout_fd;
29  int      stderr_fd;
30
31  /*
32   * Attempt to open /dev/console.
33   */
34  if ((stdin_fd = open("/dev/console", O_RDONLY, 0)) == -1) {
35    /*
36     * There may not be a console driver so this is OK.
37     */
38    return;
39  }
40
41  /*
42   *  But if we find /dev/console once, we better find it twice more
43   *  or something is REALLY wrong.
44   */
45  if ((stdout_fd = open("/dev/console", O_WRONLY, 0)) == -1)
46    rtems_fatal_error_occurred( 0x55544431 );  /* error STD1 */
47
48  if ((stderr_fd = open("/dev/console", O_WRONLY, 0)) == -1)
49    rtems_fatal_error_occurred( 0x55544432 );  /* error STD2 */
50}
51
Note: See TracBrowser for help on using the repository browser.