source: rtems/doc/new_chapters/io.t @ 487c5d58

4.104.114.84.95
Last change on this file since 487c5d58 was e21f7d8, checked in by Wade A Smith <warm38@…>, on 09/27/98 at 16:00:18

Documented the following routines: dup, dup2, close, read, write, and fcntl.f

  • Property mode set to 100644
File size: 10.3 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-1998.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@chapter Input and Output Primitives Manager
10
11@section Introduction
12
13The input and output primitives manager is ...
14
15The directives provided by the input and output primitives manager are:
16
17@itemize @bullet
18@item @code{pipe} - YYY
19@item @code{dup} - Duplicates an open file descriptor
20@item @code{dup2} - Duplicates an open file descriptor
21@item @code{close} - Closes a file
22@item @code{read} - Reads from a file
23@item @code{write} - Writes to a file
24@item @code{fcntl} - Manipulates an open file descriptor
25@item @code{lseek} - XXX
26@item @code{fsynch} - XXX
27@item @code{fdatasynch} - XXX
28@item @code{aio_read} - YYY
29@item @code{aio_write} - YYY
30@item @code{lio_listio} - YYY
31@item @code{aio_error} - YYY
32@item @code{aio_return} - YYY
33@item @code{aio_cancel} - YYY
34@item @code{aio_suspend} - YYY
35@item @code{aio_fsync} - YYY
36@end itemize
37
38@section Background
39
40@section Operations
41
42@section Directives
43
44This section details the input and output primitives manager's directives.
45A subsection is dedicated to each of this manager's directives
46and describes the calling sequence, related constants, usage,
47and status codes.
48
49@page
50@subsection pipe -
51
52@subheading CALLING SEQUENCE:
53
54@ifset is-C
55@example
56int pipe(
57);
58@end example
59@end ifset
60
61@ifset is-Ada
62@end ifset
63
64@subheading STATUS CODES:
65
66@table @b
67@item E
68The
69
70@end table
71
72@subheading DESCRIPTION:
73
74@subheading NOTES:
75
76@page
77@subsection dup - Duplicates an open file descriptor
78
79@subheading CALLING SEQUENCE:
80
81@ifset is-C
82@example
83#include <unistd.h>
84
85int dup(int fildes
86);
87@end example
88@end ifset
89
90@ifset is-Ada
91@end ifset
92
93@subheading STATUS CODES:
94
95@table @b
96@item EBADF
97Invalid file descriptor.
98@item EINTR
99Function was interrupted by a signal.
100@item EMFILE
101The process already has the maximum number of file descriptors open
102and tried to open a new one.
103@end table
104
105@subheading DESCRIPTION:
106
107The @code{dup} function returns the lowest numbered available file
108descriptor.  This new desciptor refers to the same open file as the
109original descriptor and shares any locks.
110
111@subheading NOTES: None
112
113@page
114@subsection dup2 - Duplicates an open file descriptor
115
116@subheading CALLING SEQUENCE:
117
118@ifset is-C
119@example
120#include <unistd.h>
121
122int dup2(int fildes,
123         int fildes2
124);
125@end example
126@end ifset
127
128@ifset is-Ada
129@end ifset
130
131@subheading STATUS CODES:
132
133@table @b
134@item EBADF
135Invalid file descriptor.
136@item EINTR
137Function was interrupted by a signal.
138@item EMFILE
139The process already has the maximum number of file descriptors open
140and tried to open a new one.
141@end table
142
143@subheading DESCRIPTION:
144
145@code{Dup2} creates a copy of the file descriptor @code{oldfd}.
146
147The old and new descriptors may be used interchangeably.  They share locks, file
148position pointers and flags; for example, if the file position is modified by using
149@code{lseek} on one of the descriptors, the position is also changed for the other.
150
151@subheading NOTES: None
152
153@page
154@subsection close - Closes a file.
155
156@subheading CALLING SEQUENCE:
157
158@ifset is-C
159@example
160#include <unistd.h>
161
162int close(int fildes
163);
164@end example
165@end ifset
166
167@ifset is-Ada
168@end ifset
169
170@subheading STATUS CODES:
171
172@table @b
173@item EBADF
174Invalid file descriptor
175@item EINTR
176Function was interrupted by a signal.
177@end table
178
179@subheading DESCRIPTION:
180
181The @code{close()} function deallocates the file descriptor named by
182@code{fildes} and makes it available for reuse.  All outstanding
183record locks owned by this process for the file are unlocked.
184
185@subheading NOTES:
186
187A signal can interrupt the @code{close()} function.  In that case,
188@code{close()} returns -1 with @code{errno} set to EINTR.  The file
189may or may not be closed.
190
191@page
192@subsection read - Reads from a file.
193
194@subheading CALLING SEQUENCE:
195
196@ifset is-C
197@example
198#include <unistd.h>
199
200int read(int f         ildes,
201         void         *buf,
202         unsigned int  nbyte
203);
204@end example
205@end ifset
206
207@ifset is-Ada
208@end ifset
209
210@subheading STATUS CODES:
211
212@table @b
213@item EAGAIN
214The
215@item EBADF
216Invalid file descriptor
217@item EINTR
218Function was interrupted by a signal.
219@item EIO
220Input or output error
221
222@end table
223
224@subheading DESCRIPTION:
225
226The @code{read()} function reads @code{nbyte} bytes from the file
227associated with @code{fildes} into the buffer pointed to by @code{buf}.
228
229The @code{read()} function returns the number of bytes actually read
230and placed in the buffer. This will be less than @code{nbyte} if:
231  - The number of bytes left in the file is less than @code{nbyte}
232  - The @code{read()} request was interrupted by a signal
233  - The file is a pipe or FIFO or special file with less than @code{nbytes}
234    immediately available for reading.
235
236When attempting to read from any empty pipe or FIFO:
237  - If no process has the pipe open for writing, zero is returned to
238    indicate end-of-file.
239  - If some process has the pipe open for writing and O_NONBLOCK is set,
240    -1 is returned and @code{errno} is set to EAGAIN.
241  - If some process has the pipe open for writing and O_NONBLOCK is clear,
242    @code{read()} waits for some data to be written or the pipe to be closed.
243
244When attempting to read from a file other than a pipe or FIFO and no data
245is available
246  - If O_NONBLOCK is set, -1 is returned and @code{errno} is set to EAGAIN.
247  - If O_NONBLOCK is clear, @code{read()} waits for some data to become
248    available.
249  - The O_NONBLOCK flag is ignored if data is available.
250
251@subheading NOTES: None
252
253@page
254@subsection write - Writes to a file
255
256@subheading CALLING SEQUENCE:
257
258@ifset is-C
259@example
260#include <unistd.h>
261
262int write(int         fildes,
263          const void *buf,
264          unsigned int nbytes
265);
266@end example
267@end ifset
268
269@ifset is-Ada
270@end ifset
271
272@subheading STATUS CODES:
273
274@table @b
275@item EAGAIN
276The O_NONBLOCK flag is set for a file descriptor and the process
277would be delayed in the I/O operation.
278@item EBADF
279Invalid file descriptor
280@item EFBIG
281The
282@item EINTR
283The function was interrupted by a signal.
284@item EIO
285Input or output error.
286@item ENOSPC
287No space left on disk.
288@item EPIPE
289Attempt to write to a pope or FIFO with no reader.
290
291@end table
292
293@subheading DESCRIPTION:
294
295The @code{write()} function writes @code{nbyte} from the array pointed
296to by @code{buf} into the file associated with @code{fildes}.
297
298If @code{nybte} is zero and the file is a regular file, the @code{write()}
299function returns zero and has no other effect.  If @code{nbyte} is zero
300and the file is a special file, te results are not portable.
301
302The @code{write()} function returns the number of bytes written.  This
303number will be less than @code{nbytes} if there is an error.  It will never
304be greater than @code{nbytes}.
305
306@subheading NOTES: None
307
308@page
309@subsection fcntl - Manipulates an open file descriptor
310
311@subheading CALLING SEQUENCE:
312
313@ifset is-C
314@example
315#include <sys/types.h>
316#include <fcntl.h>
317#include <unistd.h>
318
319int fcntl(int fildes,
320          int    cmd
321);
322@end example
323@end ifset
324
325@ifset is-Ada
326@end ifset
327
328@subheading STATUS CODES:
329
330@table @b
331@item EACCESS
332Search permission is denied for a direcotry in a file's path
333prefix.
334@item EAGAIN
335The O_NONBLOCK flag is set for a file descriptor and the process
336would be delayed in the I/O operation.
337@item EBADF
338Invalid file descriptor
339@item EDEADLK
340An @code{fcntl} with function F_SETLKW would cause a deadlock.
341@item EINTR
342The functioin was interrupted by a signal.
343@item EINVAL
344Invalid argument
345@item EMFILE
346Too many file descriptor or in use by the process.
347@item ENOLCK
348No locks available
349
350@end table
351
352@subheading DESCRIPTION:
353
354@subheading NOTES:
355
356@page
357@subsection lseek -
358
359@subheading CALLING SEQUENCE:
360
361@ifset is-C
362@example
363int lseek(
364);
365@end example
366@end ifset
367
368@ifset is-Ada
369@end ifset
370
371@subheading STATUS CODES:
372
373@table @b
374@item E
375The
376
377@end table
378
379@subheading DESCRIPTION:
380
381@subheading NOTES:
382
383@page
384@subsection fsynch -
385
386@subheading CALLING SEQUENCE:
387
388@ifset is-C
389@example
390int fsynch(
391);
392@end example
393@end ifset
394
395@ifset is-Ada
396@end ifset
397
398@subheading STATUS CODES:
399
400@table @b
401@item E
402The
403
404@end table
405
406@subheading DESCRIPTION:
407
408@subheading NOTES:
409
410@page
411@subsection fdatasynch -
412
413@subheading CALLING SEQUENCE:
414
415@ifset is-C
416@example
417int fdatasynch(
418);
419@end example
420@end ifset
421
422@ifset is-Ada
423@end ifset
424
425@subheading STATUS CODES:
426
427@table @b
428@item E
429The
430
431@end table
432
433@subheading DESCRIPTION:
434
435@subheading NOTES:
436
437@page
438@subsection aio_read -
439
440@subheading CALLING SEQUENCE:
441
442@ifset is-C
443@example
444int aio_read(
445);
446@end example
447@end ifset
448
449@ifset is-Ada
450@end ifset
451
452@subheading STATUS CODES:
453
454@table @b
455@item E
456The
457
458@end table
459
460@subheading DESCRIPTION:
461
462@subheading NOTES:
463
464@page
465@subsection aio_write -
466
467@subheading CALLING SEQUENCE:
468
469@ifset is-C
470@example
471int aio_write(
472);
473@end example
474@end ifset
475
476@ifset is-Ada
477@end ifset
478
479@subheading STATUS CODES:
480
481@table @b
482@item E
483The
484
485@end table
486
487@subheading DESCRIPTION:
488
489@subheading NOTES:
490
491@page
492@subsection lio_listio -
493
494@subheading CALLING SEQUENCE:
495
496@ifset is-C
497@example
498int lio_listio(
499);
500@end example
501@end ifset
502
503@ifset is-Ada
504@end ifset
505
506@subheading STATUS CODES:
507
508@table @b
509@item E
510The
511
512@end table
513
514@subheading DESCRIPTION:
515
516@subheading NOTES:
517
518@page
519@subsection aio_error -
520
521@subheading CALLING SEQUENCE:
522
523@ifset is-C
524@example
525int aio_error(
526);
527@end example
528@end ifset
529
530@ifset is-Ada
531@end ifset
532
533@subheading STATUS CODES:
534
535@table @b
536@item E
537The
538
539@end table
540
541@subheading DESCRIPTION:
542
543@subheading NOTES:
544
545@page
546@subsection aio_return -
547
548@subheading CALLING SEQUENCE:
549
550@ifset is-C
551@example
552int aio_return(
553);
554@end example
555@end ifset
556
557@ifset is-Ada
558@end ifset
559
560@subheading STATUS CODES:
561
562@table @b
563@item E
564The
565
566@end table
567
568@subheading DESCRIPTION:
569
570@subheading NOTES:
571
572@page
573@subsection aio_cancel -
574
575@subheading CALLING SEQUENCE:
576
577@ifset is-C
578@example
579int aio_cancel(
580);
581@end example
582@end ifset
583
584@ifset is-Ada
585@end ifset
586
587@subheading STATUS CODES:
588
589@table @b
590@item E
591The
592
593@end table
594
595@subheading DESCRIPTION:
596
597@subheading NOTES:
598
599@page
600@subsection aio_suspend -
601
602@subheading CALLING SEQUENCE:
603
604@ifset is-C
605@example
606int aio_suspend(
607);
608@end example
609@end ifset
610
611@ifset is-Ada
612@end ifset
613
614@subheading STATUS CODES:
615
616@table @b
617@item E
618The
619
620@end table
621
622@subheading DESCRIPTION:
623
624@subheading NOTES:
625
626@page
627@subsection aio_fsync -
628
629@subheading CALLING SEQUENCE:
630
631@ifset is-C
632@example
633int aio_fsync(
634);
635@end example
636@end ifset
637
638@ifset is-Ada
639@end ifset
640
641@subheading STATUS CODES:
642
643@table @b
644@item E
645The
646
647@end table
648
649@subheading DESCRIPTION:
650
651@subheading NOTES:
652
653This routine is not currently supported by RTEMS but could be
654in a future version.
Note: See TracBrowser for help on using the repository browser.