RTEMS  5.1
rtems-rfs-rtems.h
Go to the documentation of this file.
1 
11 /*
12  * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #if !defined(RTEMS_RFS_RTEMS_DEFINED)
20 #define RTEMS_RFS_RTEMS_DEFINED
21 
22 #include <stdbool.h>
23 #include <stdint.h>
24 #include <errno.h>
25 
29 #define RTEMS_RFS_RTEMS_ERROR 0
30 
34 #define RTEMS_RFS_RTEMS_TRACE 0
35 
40 #if !RTEMS_RFS_RTEMS_ERROR
41 #define rtems_rfs_rtems_error(_m, _e) \
42  (((errno = (_e)) == 0) ? 0 : -1)
43 #else
44 
55 int rtems_rfs_rtems_error (const char* mesg, int error);
56 #endif
57 
63 #define RTEMS_RFS_RTEMS_DEBUG_ALL (0xffffffff)
64 #define RTEMS_RFS_RTEMS_DEBUG_ERROR_MSGS (1 << 0)
65 #define RTEMS_RFS_RTEMS_DEBUG_EVAL_PATH (1 << 1)
66 #define RTEMS_RFS_RTEMS_DEBUG_EVAL_FOR_MAKE (1 << 2)
67 #define RTEMS_RFS_RTEMS_DEBUG_EVAL_PERMS (1 << 3)
68 #define RTEMS_RFS_RTEMS_DEBUG_MKNOD (1 << 4)
69 #define RTEMS_RFS_RTEMS_DEBUG_RMNOD (1 << 5)
70 #define RTEMS_RFS_RTEMS_DEBUG_LINK (1 << 6)
71 #define RTEMS_RFS_RTEMS_DEBUG_UNLINK (1 << 7)
72 #define RTEMS_RFS_RTEMS_DEBUG_CHOWN (1 << 8)
73 #define RTEMS_RFS_RTEMS_DEBUG_READLINK (1 << 9)
74 #define RTEMS_RFS_RTEMS_DEBUG_FCHMOD (1 << 10)
75 #define RTEMS_RFS_RTEMS_DEBUG_STAT (1 << 11)
76 #define RTEMS_RFS_RTEMS_DEBUG_RENAME (1 << 12)
77 #define RTEMS_RFS_RTEMS_DEBUG_DIR_RMNOD (1 << 13)
78 #define RTEMS_RFS_RTEMS_DEBUG_FILE_OPEN (1 << 14)
79 #define RTEMS_RFS_RTEMS_DEBUG_FILE_CLOSE (1 << 15)
80 #define RTEMS_RFS_RTEMS_DEBUG_FILE_READ (1 << 16)
81 #define RTEMS_RFS_RTEMS_DEBUG_FILE_WRITE (1 << 17)
82 #define RTEMS_RFS_RTEMS_DEBUG_FILE_LSEEK (1 << 18)
83 #define RTEMS_RFS_RTEMS_DEBUG_FILE_FTRUNC (1 << 19)
84 
95 #if RTEMS_RFS_RTEMS_TRACE
96 bool rtems_rfs_rtems_trace (uint32_t mask);
97 #else
98 #define rtems_rfs_rtems_trace(_m) (0)
99 #endif
100 
108 #if RTEMS_RFS_RTEMS_TRACE
109 void rtems_rfs_rtems_trace_set_mask (uint32_t mask);
110 #else
111 #define rtems_rfs_rtems_trace_set_mask(_m)
112 #endif
113 
121 #if RTEMS_RFS_RTEMS_TRACE
122 void rtems_rfs_rtems_trace_clear_mask (uint32_t mask);
123 #else
124 #define rtems_rfs_rtems_trace_clear_mask(_m)
125 #endif
126 
130 #if RTEMS_RFS_RTEMS_TRACE
131 int rtems_rfs_rtems_trace_shell_command (int argc, char *argv[]);
132 #endif
133 
137 #include <rtems/libio_.h>
138 #include <rtems/fs.h>
139 
144 {
156 #define rtems_rfs_rtems_pathloc_dev(_loc) \
157  ((rtems_rfs_file_system*)((_loc)->mt_entry->fs_info))
158 
165 #define rtems_rfs_rtems_set_pathloc_ino(_loc, _ino) \
166  (_loc)->node_access = (void*)((intptr_t)(_ino))
167 
174 #define rtems_rfs_rtems_get_pathloc_ino(_loc) \
175  ((rtems_rfs_ino) (intptr_t)((_loc)->node_access))
176 
183 #define rtems_rfs_rtems_set_pathloc_doff(_loc, _doff) \
184  (_loc)->node_access_2 = (void*)((intptr_t)(_doff))
185 
192 #define rtems_rfs_rtems_get_pathloc_doff(_loc) \
193  ((uint32_t) (intptr_t)((_loc)->node_access_2))
194 
201 #define rtems_rfs_rtems_get_iop_ino(_iop) \
202  ((intptr_t)(_iop)->pathinfo.node_access)
203 
210 #define rtems_rfs_rtems_get_iop_file_handle(_iop) \
211  ((rtems_rfs_file_handle*)(_iop)->pathinfo.node_access_2)
212 
219 #define rtems_rfs_rtems_set_iop_file_handle(_iop, _fh) \
220  (_iop)->pathinfo.node_access_2 = (_fh)
221 
228 #define rtems_rfs_rtems_handlers(_h) \
229  &rtems_rfs_rtems_ ## _h ## _handlers
230 
242  rtems_rfs_inode_handle* inode);
243 
250 uint16_t rtems_rfs_rtems_imode (mode_t mode);
251 
258 mode_t rtems_rfs_rtems_mode (int imode);
259 
263 static inline void
264  rtems_rfs_rtems_lock (rtems_rfs_file_system* fs)
265 {
267  rtems_rfs_mutex_lock (&rtems->access);
268 }
269 
273 static inline void
274  rtems_rfs_rtems_unlock (rtems_rfs_file_system* fs)
275 {
278  rtems_rfs_mutex_unlock (&rtems->access);
279 }
280 
285 extern const rtems_filesystem_file_handlers_r rtems_rfs_rtems_device_handlers;
287 extern const rtems_filesystem_file_handlers_r rtems_rfs_rtems_file_handlers;
288 
293  struct stat* buf);
294 
302  const rtems_filesystem_location_info_t* pathloc);
303 
311 
312 #endif
#define rtems_rfs_rtems_error(_m, _e)
Definition: rtems-rfs-rtems.h:41
int rtems_rfs_rtems_rmnod(const rtems_filesystem_location_info_t *parent_pathloc, const rtems_filesystem_location_info_t *pathloc)
Definition: rtems-rfs-rtems.c:563
const rtems_filesystem_file_handlers_r rtems_rfs_rtems_link_handlers
Definition: rtems-rfs-rtems.c:691
#define rtems_rfs_rtems_trace(_m)
Definition: rtems-rfs-rtems.h:98
RTEMS File System Data.
int rtems_rfs_rtems_fstat(const rtems_filesystem_location_info_t *pathloc, struct stat *buf)
Definition: rtems-rfs-rtems.c:416
uint32_t rtems_rfs_mutex
Definition: rtems-rfs-mutex.h:41
RTEMS File System Mutex.
Definition: rtems-rfs-file-system.h:123
mode_t rtems_rfs_rtems_mode(int imode)
Definition: rtems-rfs-rtems-utils.c:63
File system node operations table.
Definition: libio.h:1005
#define rtems_rfs_fs_user(_fs)
Definition: rtems-rfs-file-system.h:372
bool rtems_rfs_rtems_set_handlers(rtems_filesystem_location_info_t *pathloc, rtems_rfs_inode_handle *inode)
Definition: rtems-rfs-rtems-utils.c:32
Definition: rtems-rfs-inode.h:181
RTEMS File System Information Node.
struct rtems_rfs_rtems_private rtems_rfs_rtems_private
int rtems_rfs_rtems_fdatasync(rtems_libio_t *iop)
Definition: rtems-rfs-rtems.c:593
Definition: rtems-rfs-rtems.h:143
LibIO Internal Interface.
Basic Filesystem Types.
const rtems_filesystem_file_handlers_r rtems_rfs_rtems_dir_handlers
Definition: rtems-rfs-rtems-dir.c:155
#define rtems_rfs_rtems_trace_clear_mask(_m)
Definition: rtems-rfs-rtems.h:124
#define rtems_rfs_rtems_trace_set_mask(_m)
Definition: rtems-rfs-rtems.h:111
An open file data structure.
Definition: libio.h:1320
uint16_t rtems_rfs_rtems_imode(mode_t mode)
Definition: rtems-rfs-rtems-utils.c:54
int rtems_rfs_buffers_release(rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:466
rtems_rfs_mutex access
Definition: rtems-rfs-rtems.h:148
File system location.
Definition: fs.h:53