source: rtems/cpukit/libcsupport/src/__usrenv.c @ ba46b936

5
Last change on this file since ba46b936 was c6bb1c33, checked in by Kevin Kirspel <kevin-kirspel@…>, on 06/29/17 at 14:36:43

posix/mmap: Add support for file handler and MAP_ANON

Added a mmap file handler to struct _rtems_filesystem_file_handlers_r.
Updated each file handler object to support the default mmap handler.
Updated mmap() to call the mmap handler for MAP_SHARED.
Added a mmap file handler for shm

Added support for MAP_ANON in mmap().

Updates #2859

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