source: rtems/c/src/exec/libcsupport/src/fcntl.c @ 07a3253d

4.104.114.84.95
Last change on this file since 07a3253d was 07a3253d, checked in by Joel Sherrill <joel.sherrill@…>, on 11/23/98 at 19:07:58

Added base version of file system infrastructure. This includes a major
overhaul of the RTEMS system call interface. This base file system is
the "In-Memory File System" aka IMFS.

The design and implementation was done by the following people:

+ Joel Sherrill (joel@…)
+ Jennifer Averett (jennifer@…)
+ Steve "Mr Mount" Salitasc (salitasc@…)
+ Kerwin Wade (wade@…)

PROBLEMS
========

+ It is VERY likely that merging this will break the UNIX port. This

can/will be fixed.

+ There is likely some reentrancy/mutual exclusion needed.

+ Eventually, there should be a "mini-IMFS" description table to

eliminate links, symlinks, etc to save memory. All you need to
have "classic RTEMS" functionality is technically directories
and device IO. All the rest could be left out to save memory.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *   fcntl() - POSIX 1003.1b 6.5.2 - File Control
3 *
4 *  COPYRIGHT (c) 1989-1998.
5 *  On-Line Applications Research Corporation (OAR).
6 *  Copyright assigned to U.S. Government, 1994.
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <unistd.h>
16#include <fcntl.h>
17#include <errno.h>
18
19#include <rtems.h>
20#include "libio_.h"
21
22int fcntl(
23  int fd,
24  int cmd,
25  ...
26)
27{
28  va_list        ap;
29  rtems_libio_t *iop;
30 
31  va_start( ap, cmd );
32
33  /*
34   *  If this is not a file system based entity, it is an error.
35   */
36
37  if ( rtems_file_descriptor_type( fd ) )
38    set_errno_and_return_minus_one( EBADF );
39
40  /*
41   *  Now process the fcntl().
42   */
43
44  iop = rtems_libio_iop( fd );
45  rtems_libio_check_fd( fd );
46
47  /*
48   *  This switch should contain all the cases from POSIX.
49   */
50
51  switch ( cmd ) {
52    case F_DUPFD:        /* dup */
53      /*
54       *  This is how it appears that this case should work:
55       *
56       *     filedes2 = va_arg( ap, int )
57       *     if filedes2 is 0
58       *       duplicate fd into a new descriptor
59       *     else
60       *       duplicate fd into specified descriptor after error checking it
61       *
62       *  See dup2() in case we can eliminate stuff in there.
63       */
64      return -1;
65
66    case F_GETFD:        /* get f_flags */
67      if ( iop->flags & LIBIO_FLAGS_CLOSE_ON_EXEC )
68        return 1;
69      return 0;
70
71    case F_SETFD:        /* set f_flags */
72      /*
73       *  Interpret the third argument as the "close on exec()" flag.
74       *  If this argument is 1, then the file descriptor is to be closed
75       *  if a new process is exec()'ed.  Since RTEMS does not support
76       *  processes, then we can ignore this one except to make
77       *  F_GETFD work.
78       */
79
80      if ( va_arg( ap, int ) )
81        iop->flags |= LIBIO_FLAGS_CLOSE_ON_EXEC;
82      else
83        iop->flags &= ~LIBIO_FLAGS_CLOSE_ON_EXEC;
84      return 0;
85
86    case F_GETFL:        /* more flags (cloexec) */
87      return -1;
88
89    case F_SETFL:
90      return -1;
91
92    case F_GETLK:
93      return -1;
94
95    case F_SETLK:
96      return -1;
97
98    case F_SETLKW:
99      return -1;
100
101    case F_SETOWN:       /*  for sockets. */
102      return -1;
103
104    case F_GETOWN:       /*  for sockets. */
105      return -1;
106
107    default:
108      break;
109  }
110  return -1;
111}
Note: See TracBrowser for help on using the repository browser.