source: rtems/cpukit/libfs/src/defaults/default_lseek_directory.c @ 30d4124

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

Filesystem: PR1398: Fix lseek() mechanic

According to POSIX the lseek() function shall not, by itself, extend the
size of a file.

Remove the size field of rtems_libio_t. A file has only one size but
may have multiple open file descriptors. Thus a file size field in the
file descriptor may lead to inconsistencies.

New default handlers rtems_filesystem_default_lseek_file() and
rtems_filesystem_default_lseek_directory().

  • Property mode set to 100644
File size: 671 bytes
Line 
1/*
2 * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Obere Lagerstr. 30
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.com/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include <rtems/libio_.h>
20
21off_t rtems_filesystem_default_lseek_directory(
22  rtems_libio_t *iop,
23  off_t offset,
24  int whence
25)
26{
27  off_t rv = 0;
28
29  if ( offset == 0 && whence == SEEK_SET ) {
30    iop->offset = 0;
31  } else {
32    errno = EINVAL;
33    rv = -1;
34  }
35
36  return rv;
37}
Note: See TracBrowser for help on using the repository browser.