source: rtems/cpukit/libfs/src/imfs/imfs_handlers_memfile.c @ 183af89

4.115
Last change on this file since 183af89 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: 1.5 KB
Line 
1/*
2 *  Memfile Operations Tables for the IMFS
3 *
4 *  COPYRIGHT (c) 1989-1999.
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 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15  #include "config.h"
16#endif
17
18#include "imfs.h"
19
20static int IMFS_stat_file(
21  const rtems_filesystem_location_info_t *loc,
22  struct stat *buf
23)
24{
25  const IMFS_jnode_t *node = loc->node_access;
26
27  buf->st_size = node->info.file.size;
28  buf->st_blksize = imfs_rq_memfile_bytes_per_block;
29
30  return IMFS_stat( loc, buf );
31}
32
33static const rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
34  memfile_open,
35  rtems_filesystem_default_close,
36  memfile_read,
37  memfile_write,
38  memfile_ioctl,
39  rtems_filesystem_default_lseek_file,
40  IMFS_stat_file,
41  memfile_ftruncate,
42  rtems_filesystem_default_fsync_or_fdatasync_success,
43  rtems_filesystem_default_fsync_or_fdatasync_success,
44  rtems_filesystem_default_fcntl
45};
46
47const IMFS_node_control IMFS_node_control_memfile = {
48  .imfs_type = IMFS_MEMORY_FILE,
49  .handlers = &IMFS_memfile_handlers,
50  .node_initialize = IMFS_node_initialize_default,
51  .node_remove = IMFS_node_remove_default,
52  .node_destroy = IMFS_memfile_remove
53};
54
55const IMFS_node_control IMFS_node_control_linfile = {
56  .imfs_type = IMFS_LINEAR_FILE,
57  .handlers = &IMFS_memfile_handlers,
58  .node_initialize = IMFS_node_initialize_default,
59  .node_remove = IMFS_node_remove_default,
60  .node_destroy = IMFS_node_destroy_default
61};
Note: See TracBrowser for help on using the repository browser.