4.104.114.84.95
Last change
on this file since 7edb9281 was
73f6236,
checked in by Joel Sherrill <joel.sherrill@…>, on 03/01/99 at 22:40:08
|
Patch from Eric Norum <eric@…> to eliminate external
IO handlers scheme that was implemented originally just to support
sockets. The file system IO switch is more general and works fine.
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | /* |
---|
2 | * write() - POSIX 1003.1b 6.4.2 - Write to a File |
---|
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 "libio_.h" |
---|
16 | |
---|
17 | |
---|
18 | /* |
---|
19 | * write |
---|
20 | * |
---|
21 | * This routine writes count bytes from from buffer pointed to by buffer |
---|
22 | * to the file associated with the open file descriptor, fildes. |
---|
23 | */ |
---|
24 | |
---|
25 | ssize_t write( |
---|
26 | int fd, |
---|
27 | const void *buffer, |
---|
28 | size_t count |
---|
29 | ) |
---|
30 | { |
---|
31 | rtems_status_code rc; |
---|
32 | rtems_libio_t *iop; |
---|
33 | |
---|
34 | rtems_libio_check_fd( fd ); |
---|
35 | iop = rtems_libio_iop( fd ); |
---|
36 | rtems_libio_check_is_open(iop); |
---|
37 | rtems_libio_check_buffer( buffer ); |
---|
38 | rtems_libio_check_count( count ); |
---|
39 | rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE ); |
---|
40 | |
---|
41 | /* |
---|
42 | * Now process the write() request. |
---|
43 | */ |
---|
44 | |
---|
45 | if ( !iop->handlers->write ) |
---|
46 | set_errno_and_return_minus_one( ENOTSUP ); |
---|
47 | |
---|
48 | rc = (*iop->handlers->write)( iop, buffer, count ); |
---|
49 | |
---|
50 | if ( rc > 0 ) |
---|
51 | iop->offset += rc; |
---|
52 | |
---|
53 | return rc; |
---|
54 | } |
---|
55 | |
---|
56 | /* |
---|
57 | * _write_r |
---|
58 | * |
---|
59 | * This is the Newlib dependent reentrant version of write(). |
---|
60 | */ |
---|
61 | |
---|
62 | #if defined(RTEMS_NEWLIB) |
---|
63 | |
---|
64 | #include <reent.h> |
---|
65 | |
---|
66 | long _write_r( |
---|
67 | struct _reent *ptr, |
---|
68 | int fd, |
---|
69 | const void *buf, |
---|
70 | size_t nbytes |
---|
71 | ) |
---|
72 | { |
---|
73 | return write( fd, buf, nbytes ); |
---|
74 | } |
---|
75 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.