summaryrefslogtreecommitdiffstats
path: root/file_io/fdopen/README
blob: dee115d88eb30cd4bdd3e900f58742d1670690e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#
#  README for fdopen() test
#

Resolution: Fixed

This test failed because fcntl() did not yet support the F_GETFL
control operation.  This code was added (along with F_SETFL) and
the test began to work.

-----------------------

This is the original email that the test came from:

From janovetz@tempest.ece.uiuc.edu Sat Mar  6 10:34:11 1999
Date: Thu, 4 Mar 1999 19:37:37 -0600
From: Jake Janovetz <janovetz@tempest.ece.uiuc.edu>
To: rtems-snapshots@oarcorp.com
Subject: More on fdopen()

Hello all...

Sorry to beat a dead horse (to me, it's still living), but I
still can't get the fdopen stuff to work...  Since I cannot
find a reference to fdopen() under the rtems source tree,
I presume its only incarnation in 'newlib'.  The
newlib-1.8.1 19990302 patch does not seem to have a reference
to fdopen, so I don't see anything modified there.

I'd like to know where the fdopen fix resides, so I know I 
have it.

Finally, I'm including a simple test for fdopen().  If some
merciful soul can run this (Eric has already verified that his
version works -- I'm hoping that maybe a patch didn't make it
into 0302), I would appreciate it.

    Cheers,
    Jake

-- 
   janovetz@uiuc.edu    | Once you have flown, you will walk the earth with
 University of Illinois | your eyes turned skyward, for there you have been,
                        | there you long to return.     -- da Vinci
        PP-ASEL         | http://www.ews.uiuc.edu/~janovetz/index.html




#include <bsp.h>
#include <fcntl.h>

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_EXECUTIVE_RAM_SIZE              (2048*1024)
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES          4 
#define CONFIGURE_MAXIMUM_SEMAPHORES              20
#define CONFIGURE_MAXIMUM_TASKS                   20
#define CONFIGURE_MAXIMUM_TIMERS                  20
#define CONFIGURE_MAXIMUM_PERIODS                 1
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS  10
#define CONFIGURE_INIT_TASK_STACK_SIZE            (32*1024)
#define CONFIGURE_INIT_TASK_PRIORITY              90
#define CONFIGURE_INIT_TASK_INITIAL_MODES         (RTEMS_PREEMPT | \
                                                   RTEMS_NO_TIMESLICE | \
                                                   RTEMS_NO_ASR | \
                                                   RTEMS_INTERRUPT_LEVEL(0))
#define CONFIGURE_MICROSECONDS_PER_TICK           10486
#define CONFIGURE_INIT
rtems_task Init(rtems_task_argument argument);

#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
rtems_driver_address_table Device_drivers[] = {
   CONSOLE_DRIVER_TABLE_ENTRY,
   CLOCK_DRIVER_TABLE_ENTRY,
};

#include <rtems/confdefs.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <rtems.h>
#include <rtems/error.h>
#include <rtems/libio.h>
#include "m68360.h"
#include <stdlib.h>
#include <errno.h>


rtems_task
Init(rtems_task_argument ignored)
{
   int fd;
   FILE *fp;
   char str[256];


   /***********************************************************************
    * Print the boot-up message.
    **********************************************************************/
   printf("\n\n");
   printf("%s\n", _RTEMS_version);

   printf("Here we go!\n");
   fp = fopen("test", "w");
   fprintf(fp, "Hello world!!!\n");
   fclose(fp);

   fp = fopen("test", "r");
   fgets(str, 200, fp);
   printf("read: %s\n", str);
   fclose(fp);

   fd = open("test", O_RDONLY);
   if (fd == -1)
   {
      printf("Starting on the wrong foot....\n");
   }
   fp = fdopen(fd, "r");
   if (fp == NULL)
   {
      printf("Crap, man!  Nothing ever goes my way!\n");
      close(fd);
   }
   else
   {
      printf("Soon, I will be able to take over the world!\n");
      fgets(str, 200, fp);
      printf("%s\n", str);
      fclose(fp);
   }

   while (1)
   {
      rtems_task_wake_after(100);
   }


   exit(0);
}