source: rtems/c/src/lib/libc/syscalls.c @ 60b791ad

4.104.114.84.95
Last change on this file since 60b791ad was 60b791ad, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 17, 1998 at 11:46:28 PM

updated copyright to 1998

  • Property mode set to 100644
File size: 2.6 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-1998.
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   *  From Eric Norum:
47   *
48   *  The `fix' is not complete.  It still doesn't properly handle
49   *  file descriptors for any files/devices other  than the console
50   *  serial lines.....
51   */
52  if (_fd <= 2) {
53    _sbuf->st_mode = S_IFCHR;
54  } else {
55    switch (rtems_file_descriptor_type (_fd)) {
56    case RTEMS_FILE_DESCRIPTOR_TYPE_FILE:
57      _sbuf->st_mode = S_IFREG;
58      break;
59
60    case RTEMS_FILE_DESCRIPTOR_TYPE_SOCKET:
61      _sbuf->st_mode = S_IFSOCK;
62      break;
63
64    default:
65      puts( "__rtems_fstat -- unknown file descriptor type" );
66      assert( 0 );
67    }
68  }
69  return 0;
70}
71
72int __rtems_isatty(int _fd)
73{
74  struct stat st;
75
76  if (__rtems_fstat(_fd, &st) < 0)
77    return 0;
78  return S_ISCHR (st.st_mode);
79}
80
81#if !defined(RTEMS_UNIX)
82int stat( const char *path, struct stat *buf )
83{
84  if ( strncmp( "/dev/", path, 5 ) ) {
85    return -1;
86  }
87  return __rtems_fstat( 0, buf );
88}
89
90int link( const char *existing, const char *new )
91{
92  /* always fail */
93  return -1;
94}
95
96int unlink( const char *path )
97{
98  /* always fail */
99  return -1;
100}
101
102char *getcwd( char *_buf, size_t _size)
103{
104
105/*  assert( FALSE ); */
106  errno = ENOSYS;
107  return 0;
108}
109int fork() {
110  puts( "fork -- not supported!!!" );
111  assert( 0 );
112  errno = ENOSYS;
113  return -1;
114}
115int execv(const char *_path, char * const _argv[] ) {
116  puts( "execv -- not supported!!!" ); 
117  assert( 0 );
118  errno = ENOSYS;
119  return -1;
120}
121int wait() {
122  puts( "wait -- not supported!!!" );
123  assert( 0 );
124  errno = ENOSYS;
125  return -1;
126}
127#endif
128
129#endif
Note: See TracBrowser for help on using the repository browser.