source: rtems/cpukit/libcsupport/src/__usrenv.c @ 4116fce6

4.115
Last change on this file since 4116fce6 was 4116fce6, checked in by Sebastian Huber <sebastian.huber@…>, on 02/24/12 at 16:39:27

Filesystem: New defaults fsync_h and fdatasync_h

New defaults rtems_filesystem_default_fsync_or_fdatasync() and
rtems_filesystem_default_fsync_or_fdatasync_success() for fsync_h and
fdatasync_h. The rtems_filesystem_default_fsync_or_fdatasync() sets now
errno to EINVAL according to POSIX.

  • Property mode set to 100644
File size: 5.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  Modifications to support reference counting in the file system are
6 *  Copyright (c) 2012 embedded brains GmbH.
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.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include <sys/stat.h>
20
21#include <rtems/libio_.h>
22
23static int null_handler_open(
24  rtems_libio_t *iop,
25  const char *path,
26  int oflag,
27  mode_t mode
28)
29{
30  return -1;
31}
32
33static int null_handler_fstat(
34  const rtems_filesystem_location_info_t *pathloc,
35  struct stat *buf
36)
37{
38  return -1;
39}
40
41const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers = {
42  .open_h = null_handler_open,
43  .close_h = rtems_filesystem_default_close,
44  .read_h = rtems_filesystem_default_read,
45  .write_h = rtems_filesystem_default_write,
46  .ioctl_h = rtems_filesystem_default_ioctl,
47  .lseek_h = rtems_filesystem_default_lseek,
48  .fstat_h = null_handler_fstat,
49  .ftruncate_h = rtems_filesystem_default_ftruncate,
50  .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
51  .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
52  .fcntl_h = rtems_filesystem_default_fcntl
53};
54
55static void null_op_lock_or_unlock(
56  rtems_filesystem_mount_table_entry_t *mt_entry
57)
58{
59  /* Do nothing */
60}
61
62static int null_op_mknod(
63  const rtems_filesystem_location_info_t *parentloc,
64  const char *name,
65  size_t namelen,
66  mode_t mode,
67  dev_t dev
68)
69{
70  return -1;
71}
72
73static int null_op_rmnod(
74  const rtems_filesystem_location_info_t *parentloc,
75  const rtems_filesystem_location_info_t *loc
76)
77{
78  return -1;
79}
80
81static int null_op_link(
82  const rtems_filesystem_location_info_t *parentloc,
83  const rtems_filesystem_location_info_t *targetloc,
84  const char *name,
85  size_t namelen
86)
87{
88  return -1;
89}
90
91static int null_op_fchmod(
92  const rtems_filesystem_location_info_t *pathloc,
93  mode_t mode
94)
95{
96  return -1;
97}
98
99static int null_op_chown(
100  const rtems_filesystem_location_info_t *loc,
101  uid_t owner,
102  gid_t group
103)
104{
105  return -1;
106}
107
108static int null_op_clonenode(
109  rtems_filesystem_location_info_t *loc
110)
111{
112  return -1;
113}
114
115static int null_op_mount(
116  rtems_filesystem_mount_table_entry_t *mt_entry
117)
118{
119  return -1;
120}
121
122static int null_op_fsmount_me(
123  rtems_filesystem_mount_table_entry_t *mt_entry,
124  const void *data
125)
126{
127  return -1;
128}
129
130static int null_op_unmount(
131  rtems_filesystem_mount_table_entry_t *mt_entry
132)
133{
134  return -1;
135}
136
137static void null_op_fsunmount_me(
138  rtems_filesystem_mount_table_entry_t *mt_entry
139)
140{
141  /* Do nothing */
142}
143
144static int null_op_utime(
145  const rtems_filesystem_location_info_t *loc,
146  time_t actime,
147  time_t modtime
148)
149{
150  return -1;
151}
152
153static int null_op_symlink(
154  const rtems_filesystem_location_info_t *parentloc,
155  const char *name,
156  size_t namelen,
157  const char *target
158)
159{
160  return -1;
161}
162
163static ssize_t null_op_readlink(
164  const rtems_filesystem_location_info_t *loc,
165  char *buf,
166  size_t bufsize
167)
168{
169  return -1;
170}
171
172static int null_op_rename(
173  const rtems_filesystem_location_info_t *oldparentloc,
174  const rtems_filesystem_location_info_t *oldloc,
175  const rtems_filesystem_location_info_t *newparentloc,
176  const char *name,
177  size_t namelen
178)
179{
180  return -1;
181}
182
183static int null_op_statvfs(
184  const rtems_filesystem_location_info_t *loc,
185  struct statvfs *buf
186)
187{
188  return -1;
189}
190
191static const rtems_filesystem_operations_table null_ops = {
192  .lock_h = null_op_lock_or_unlock,
193  .unlock_h = null_op_lock_or_unlock,
194  .eval_path_h = rtems_filesystem_default_eval_path,
195  .link_h = null_op_link,
196  .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal,
197  .node_type_h = rtems_filesystem_default_node_type,
198  .mknod_h = null_op_mknod,
199  .rmnod_h = null_op_rmnod,
200  .fchmod_h = null_op_fchmod,
201  .chown_h = null_op_chown,
202  .clonenod_h = null_op_clonenode,
203  .freenod_h = rtems_filesystem_default_freenode,
204  .mount_h = null_op_mount,
205  .fsmount_me_h = null_op_fsmount_me,
206  .unmount_h = null_op_unmount,
207  .fsunmount_me_h = null_op_fsunmount_me,
208  .utime_h = null_op_utime,
209  .symlink_h = null_op_symlink,
210  .readlink_h = null_op_readlink,
211  .rename_h = null_op_rename,
212  .statvfs_h = null_op_statvfs
213};
214
215rtems_filesystem_mount_table_entry_t rtems_filesystem_null_mt_entry = {
216  .location_chain = {
217    .Head = {
218      .Node = {
219        .next = &rtems_filesystem_global_location_null.location.mt_entry_node,
220        .previous = NULL
221      },
222      .fill = &rtems_filesystem_global_location_null.location.mt_entry_node,
223    }
224  },
225  .mt_point_node = &rtems_filesystem_global_location_null,
226  .mt_fs_root = &rtems_filesystem_global_location_null,
227  .mounted = false,
228  .writeable = false
229};
230
231rtems_filesystem_global_location_t rtems_filesystem_global_location_null = {
232  .location = {
233    .mt_entry_node = {
234      .next = &rtems_filesystem_null_mt_entry.location_chain.Tail.Node,
235      .previous = &rtems_filesystem_null_mt_entry.location_chain.Head.Node
236    },
237    .handlers = &rtems_filesystem_null_handlers,
238    .ops = &null_ops,
239    .mt_entry = &rtems_filesystem_null_mt_entry
240  },
241
242  /*
243   * The initial reference count accounts for the following references
244   *  o the root directory of the user environment,
245   *  o the current directory of the user environment,
246   *  o the root node of the null file system instance, and
247   *  o the mount point node of the null file system instance.
248   */
249  .reference_count = 4
250};
251
252rtems_user_env_t rtems_global_user_env = {
253  .current_directory = &rtems_filesystem_global_location_null,
254  .root_directory = &rtems_filesystem_global_location_null,
255  .umask = S_IWGRP | S_IWOTH
256};
257
258rtems_user_env_t *rtems_current_user_env = &rtems_global_user_env;
Note: See TracBrowser for help on using the repository browser.