source: rtems/cpukit/libcsupport/src/write.c @ 53da07e

4.115
Last change on this file since 53da07e was 53da07e, checked in by Sebastian Huber <sebastian.huber@…>, on 05/14/12 at 13:21:30

Filesystem: PR1255: Move offset update to handlers

It is now the responsibility of the read() and write() handler to update
the offset field of the IO descriptor (rtems_libio_t). This change
makes it possible to protect the IO descriptor from concurrent access by
per file locks.

  • Property mode set to 100644
File size: 1.0 KB
Line 
1/*
2 *  write() - POSIX 1003.1b 6.4.2 - Write to a File
3 *
4 *  COPYRIGHT (c) 1989-2011.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/libio_.h>
17#include <rtems/seterr.h>
18
19/*
20 * write
21 *
22 * This routine writes count bytes from from buffer pointed to by buffer
23 * to the file associated with the open file descriptor, fildes.
24 */
25
26ssize_t write(
27  int         fd,
28  const void *buffer,
29  size_t      count
30)
31{
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_with_error( iop, LIBIO_FLAGS_WRITE, EBADF );
40
41  /*
42   *  Now process the write() request.
43   */
44  return (*iop->pathinfo.handlers->write_h)( iop, buffer, count );
45}
Note: See TracBrowser for help on using the repository browser.