source: rtems/c/src/lib/libc/syscalls.c @ 4dc0fd6

4.104.114.84.95
Last change on this file since 4dc0fd6 was 4dc0fd6, checked in by Joel Sherrill <joel.sherrill@…>, on 01/19/98 at 22:22:25

Patch from Eric Norum:

With this in place, it is possible to fdopen a TCP stream socket and
getc/fprintf/etc. on the STDIO stream!

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  RTEMS Fake System Calls
3 *
4 *  This file contains "fake" versions of the system call routines
5 *  which are reference by many libc implementations.  Once a routine
6 *  has been implemented in terms of RTEMS services, it should be
7 *  taken out of this file.
8 *
9 *  COPYRIGHT (c) 1989-1997.
10 *  On-Line Applications Research Corporation (OAR).
11 *  Copyright assigned to U.S. Government, 1994.
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.OARcorp.com/rtems/license.html.
16 *
17 *  $Id$
18 *
19 */
20
21#include <sys/types.h>
22#include <sys/stat.h>
23#include <assert.h>
24#include <errno.h>
25#include <string.h>
26#include <stdio.h>  /* only for puts */
27
28#include <rtems.h>
29#include <rtems/libio.h>
30
31#ifdef RTEMS_NEWLIB
32/*
33 *  fstat, stat, and isatty must lie consistently and report that everything
34 *  is a tty or stdout will not be line buffered.
35 */
36
37int __rtems_fstat(int _fd, struct stat* _sbuf)
38{
39#ifdef HAVE_BLKSIZE
40  _sbuf->st_blksize = 0;
41#endif
42
43  /*
44   * For now assume stdin/stdout/stderr are always a TTY line
45   */
46  if (_fd <= 2) {
47    _sbuf->st_mode = S_IFCHR;
48  } else {
49    switch (rtems_file_descriptor_type (_fd)) {
50    case RTEMS_FILE_DESCRIPTOR_TYPE_SOCKET:
51      _sbuf->st_mode = S_IFSOCK;
52      break;
53
54    default:
55      puts( "__rtems_fstat -- unknown socket type" );
56      assert( 0 );
57    }
58  }
59  return 0;
60}
61
62int __rtems_isatty(int _fd)
63{
64  struct stat st;
65
66  if (__rtems_fstat(_fd, &st) < 0)
67    return 0;
68  return S_ISCHR (st.st_mode);
69}
70
71#if !defined(RTEMS_UNIX)
72int stat( const char *path, struct stat *buf )
73{
74  if ( strncmp( "/dev/", path, 5 ) ) {
75    return -1;
76  }
77  return __rtems_fstat( 0, buf );
78}
79
80int link( const char *existing, const char *new )
81{
82  /* always fail */
83  return -1;
84}
85
86int unlink( const char *path )
87{
88  /* always fail */
89  return -1;
90}
91
92char *getcwd( char *_buf, size_t _size)
93{
94
95/*  assert( FALSE ); */
96  errno = ENOSYS;
97  return 0;
98}
99int fork() {
100  puts( "fork -- not supported!!!" );
101  assert( 0 );
102  errno = ENOSYS;
103  return -1;
104}
105int execv(const char *_path, char * const _argv[] ) {
106  puts( "execv -- not supported!!!" );
107  assert( 0 );
108  errno = ENOSYS;
109  return -1;
110}
111int wait() {
112  puts( "wait -- not supported!!!" );
113  assert( 0 );
114  errno = ENOSYS;
115  return -1;
116}
117#endif
118
119#endif
Note: See TracBrowser for help on using the repository browser.