source: rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems.h @ a9fa9b7

4.104.11
Last change on this file since a9fa9b7 was a9fa9b7, checked in by Chris Johns <chrisj@…>, on Feb 18, 2010 at 12:24:25 AM

2010-02-18 Chris Johns <chrisj@…>

  • libfs/src/rfs/rtems-rfs-bitmaps.c, libfs/src/rfs/rtems-rfs-bitmaps.h, libfs/src/rfs/rtems-rfs-bitmaps-ut.c, libfs/src/rfs/rtems-rfs-block.c, libfs/src/rfs/rtems-rfs-block.h, libfs/src/rfs/rtems-rfs-block-pos.h, libfs/src/rfs/rtems-rfs-buffer-bdbuf.c, libfs/src/rfs/rtems-rfs-buffer.c, libfs/src/rfs/rtems-rfs-buffer-devio.c, libfs/src/rfs/rtems-rfs-buffer.h, libfs/src/rfs/rtems-rfs-data.h, libfs/src/rfs/rtems-rfs-dir.c, libfs/src/rfs/rtems-rfs-dir.h, libfs/src/rfs/rtems-rfs-dir-hash.c, libfs/src/rfs/rtems-rfs-dir-hash.h, libfs/src/rfs/rtems-rfs-file.c, libfs/src/rfs/rtems-rfs-file.h, libfs/src/rfs/rtems-rfs-file-system.c, libfs/src/rfs/rtems-rfs-file-system-fwd.h, libfs/src/rfs/rtems-rfs-file-system.h, libfs/src/rfs/rtems-rfs-format.c, libfs/src/rfs/rtems-rfs-format.h, libfs/src/rfs/rtems-rfs-group.c, libfs/src/rfs/rtems-rfs-group.h, libfs/src/rfs/rtems-rfs.h, libfs/src/rfs/rtems-rfs-inode.c, libfs/src/rfs/rtems-rfs-inode.h, libfs/src/rfs/rtems-rfs-link.c, libfs/src/rfs/rtems-rfs-link.h, libfs/src/rfs/rtems-rfs-mutex.c, libfs/src/rfs/rtems-rfs-mutex.h, libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems-dev.c, libfs/src/rfs/rtems-rfs-rtems-dir.c, libfs/src/rfs/rtems-rfs-rtems-file.c, libfs/src/rfs/rtems-rfs-rtems.h, libfs/src/rfs/rtems-rfs-rtems-utils.c, libfs/src/rfs/rtems-rfs-shell.c, libfs/src/rfs/rtems-rfs-shell.h, libfs/src/rfs/rtems-rfs-trace.c, libfs/src/rfs/rtems-rfs-trace.h: New.
  • Makefile.am, preinstall.am, libfs/Makefile.am, wrapup/Makefile.am: Updated with the RFS support.
  • libfs/README: Updated after 10 years.
  • libblock/src/flashdisk.c, libblock/src/nvdisk.c, libblock/src/ramdisk-driver.c: Updated to the new error reporting in libblock.
  • libmisc/shell/main_ls.c, libmisc/shell/print-ls.c: Fix printing the size in long mode.
  • libnetworking/nfs/bootp_subr.c, libnetworking/rtems/rtems_bootp.c, libnetworking/rtems/rtems_bsdnet_internal.h: Return the BOOTP/DHCP to the forever behaviour of 4.9 with the ability to call BOOTP and control the process if required.
  • Property mode set to 100644
File size: 8.5 KB
Line 
1/*
2 *  COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 *
8 *  $Id$
9 */
10/**
11 * @file
12 *
13 * @ingroup rtems-rfs
14 *
15 * RTEMS File System RTEMS Header file.
16 *
17 * This file is not to be installed. It binds the RFS file system to RTEMS.
18 */
19
20#if !defined(RTEMS_RFS_RTEMS_DEFINED)
21#define RTEMS_RFS_RTEMS_DEFINED
22
23#include <stdbool.h>
24#include <stdint.h>
25#include <errno.h>
26
27/**
28 * RTEMS RFS RTEMS Error Enable. Set to 1 to printing of errors. Default is off.
29 */
30#define RTEMS_RFS_RTEMS_ERROR 0
31
32/**
33 * RTEMS RFS RTEMS Trace Enable. Set to 1 to printing of errors. Default is off.
34 */
35#define RTEMS_RFS_RTEMS_TRACE 0
36
37/**
38 * If we are not handling errors provide a define that removes the strings from
39 * the code.
40 */
41#if !RTEMS_RFS_RTEMS_ERROR
42#define rtems_rfs_rtems_error(_m, _e) \
43  (((errno = (_e)) == 0) ? 0 : -1)
44#else
45/**
46 * Take the result code and set errno with it and if non-zero return -1 else
47 * return 0.
48 *
49 * @param what The message to print is the error is not zero.
50 * @param error The error code.
51 * @retval -1 An error has occured.
52 * @retval 0 No error.
53 */
54int rtems_rfs_rtems_error (const char* mesg, int error);
55#endif
56
57/**
58 * Trace message defines the RTEMS bindings of the RTEMS RFS. This is a
59 * development tool where can edit the values below to control the various trace
60 * output.
61 */
62#define RTEMS_RFS_RTEMS_DEBUG_ALL           (0xffffffff)
63#define RTEMS_RFS_RTEMS_DEBUG_ERROR_MSGS    (1 << 0)
64#define RTEMS_RFS_RTEMS_DEBUG_EVAL_PATH     (1 << 1)
65#define RTEMS_RFS_RTEMS_DEBUG_EVAL_FOR_MAKE (1 << 2)
66#define RTEMS_RFS_RTEMS_DEBUG_EVAL_PERMS    (1 << 3)
67#define RTEMS_RFS_RTEMS_DEBUG_MKNOD         (1 << 4)
68#define RTEMS_RFS_RTEMS_DEBUG_RMNOD         (1 << 5)
69#define RTEMS_RFS_RTEMS_DEBUG_LINK          (1 << 6)
70#define RTEMS_RFS_RTEMS_DEBUG_UNLINK        (1 << 7)
71#define RTEMS_RFS_RTEMS_DEBUG_CHOWN         (1 << 8)
72#define RTEMS_RFS_RTEMS_DEBUG_READLINK      (1 << 9)
73#define RTEMS_RFS_RTEMS_DEBUG_FCHMOD        (1 << 10)
74#define RTEMS_RFS_RTEMS_DEBUG_STAT          (1 << 11)
75#define RTEMS_RFS_RTEMS_DEBUG_DIR_RMNOD     (1 << 12)
76#define RTEMS_RFS_RTEMS_DEBUG_FILE_OPEN     (1 << 13)
77#define RTEMS_RFS_RTEMS_DEBUG_FILE_CLOSE    (1 << 14)
78#define RTEMS_RFS_RTEMS_DEBUG_FILE_READ     (1 << 15)
79#define RTEMS_RFS_RTEMS_DEBUG_FILE_WRITE    (1 << 16)
80#define RTEMS_RFS_RTEMS_DEBUG_FILE_LSEEK    (1 << 17)
81#define RTEMS_RFS_RTEMS_DEBUG_FILE_FTRUNC   (1 << 18)
82
83/**
84 * Call to check if this part is bring traced. If RTEMS_RFS_RTEMS_TRACE is
85 * defined to 0 the code is dead code elminiated when built with -Os, -O2, or
86 * higher.
87 *
88 * @param mask The part of the API to trace.
89 * @retval true Tracing is active for the mask.
90 * @retval false Do not trace.
91 */
92#if RTEMS_RFS_RTEMS_TRACE
93bool rtems_rfs_rtems_trace (uint32_t mask);
94#else
95#define rtems_rfs_rtems_trace(_m) (0)
96#endif
97
98/**
99 * Set the mask.
100 *
101 * @param mask The mask bits to set.
102 * @return The previous mask.
103 */
104#if RTEMS_RFS_RTEMS_TRACE
105void rtems_rfs_rtems_trace_set_mask (uint32_t mask);
106#else
107#define rtems_rfs_rtems_trace_set_mask(_m)
108#endif
109
110/**
111 * Clear the mask.
112 *
113 * @param mask The mask bits to clear.
114 * @return The previous mask.
115 */
116#if RTEMS_RFS_RTEMS_TRACE
117void rtems_rfs_rtems_trace_clear_mask (uint32_t mask);
118#else
119#define rtems_rfs_rtems_trace_clear_mask(_m)
120#endif
121
122/**
123 * Add shell trace shell command.
124 */
125#if RTEMS_RFS_RTEMS_TRACE
126int rtems_rfs_rtems_trace_shell_command (int argc, char *argv[]);
127#endif
128
129#include <rtems/rfs/rtems-rfs-file-system.h>
130#include <rtems/rfs/rtems-rfs-inode.h>
131#include <rtems/rfs/rtems-rfs-mutex.h>
132#include <rtems/libio_.h>
133#include <rtems/fs.h>
134
135/**
136 * Private RFS RTEMS Port data.
137 */
138typedef struct rtems_rfs_rtems_private
139{
140  /**
141   * The access lock.
142   */
143  rtems_rfs_mutex access;
144} rtems_rfs_rtems_private;
145/**
146 * Return the file system structure given a path location.
147 *
148 * @param _loc Pointer to the path location.
149 * @return rtems_rfs_file_system*
150 */
151#define rtems_rfs_rtems_pathloc_dev(_loc) \
152  ((rtems_rfs_file_system*)((_loc)->mt_entry->fs_info))
153
154/**
155 * Set the inode number (ino) into the path location.
156 *
157 * @param _loc Pointer to the path location.
158 * @param _ino The ino to set in the path location.
159 */
160#define rtems_rfs_rtems_set_pathloc_ino(_loc, _ino) \
161  (_loc)->node_access = (void*)(_ino)
162
163/**
164 * Get the inode number (ino) given a path location.
165 *
166 * @param _loc Pointer to the path location.
167 * @return rtems_rfs_ino The inode number in the path location.
168 */
169#define rtems_rfs_rtems_get_pathloc_ino(_loc) \
170  ((rtems_rfs_ino) (intptr_t)((_loc)->node_access))
171
172/**
173 * Set the directory offset (doff) into the path location.
174 *
175 * @param _loc Pointer to the path location.
176 * @param _doff The doff to set in the path location.
177 */
178#define rtems_rfs_rtems_set_pathloc_doff(_loc, _doff) \
179  (_loc)->node_access_2 = (void*)(_doff)
180
181/**
182 * Get the directory offset (doff) given a path location.
183 *
184 * @param _loc Pointer to the path location.
185 * @return uin32_t The doff in the path location.
186 */
187#define rtems_rfs_rtems_get_pathloc_doff(_loc) \
188  ((uint32_t) (intptr_t)((_loc)->node_access_2))
189
190/**
191 * Get the ino from the I/O pointer.
192 *
193 * @param _iop The I/O pointer.
194 * @return
195 */
196#define rtems_rfs_rtems_get_iop_ino(_iop) \
197  ((intptr_t)(_iop)->file_info)
198
199/**
200 * Create the name of the handler's table given the type of handlers.
201 *
202 * @param _h The name of the handlers.
203 * @return label The name of the handler's table.
204 */
205#define rtems_rfs_rtems_handlers(_h) \
206  &rtems_rfs_rtems_ ## _h ## _handlers
207
208/**
209 * Evaluate the permissions of the inode's mode against the flags.
210 *
211 * @param inode The inode handler to check the mode, uid and gid.
212 * @param flags The flags to check permissions of.
213 * @retval true The permissions allow access to the inode.
214 * @retval false Access to the inode is not permitted.
215 */
216bool rtems_rfs_rtems_eval_perms (rtems_rfs_inode_handle* inode, int flags);
217
218/**
219 * Set the handlers in the path location based on the mode of the inode.
220 *
221 * @param loc Pointer to the path location to set the handlers in.
222 * @param inode The inode handle to check the mode of for the type of handlers.
223 * @retval true The handlers have been set.
224 * @retval false There are no handlers for the mode.
225 */
226bool rtems_rfs_rtems_set_handlers (rtems_filesystem_location_info_t* pathloc,
227                                   rtems_rfs_inode_handle*           inode);
228
229/**
230 * Convert the system mode flags to inode mode flags.
231 *
232 * @param mode The system mode flags.
233 * @return uint16_t The inode mode flags.
234 */
235uint16_t rtems_rfs_rtems_imode (mode_t mode);
236
237/**
238 * Convert the inode mode flags to system mode flags.
239 *
240 * @param imode The inode mode flags
241 * @return mode_t The system mode flags.
242 */
243mode_t rtems_rfs_rtems_mode (int imode);
244
245/**
246 * Lock the RFS file system.
247 */
248static inline void
249 rtems_rfs_rtems_lock (rtems_rfs_file_system* fs)
250{
251  rtems_rfs_rtems_private* rtems = rtems_rfs_fs_user (fs);
252  rtems_rfs_mutex_lock (&rtems->access);
253}
254
255/**
256 * Unlock the RFS file system.
257 */
258static inline void
259 rtems_rfs_rtems_unlock (rtems_rfs_file_system* fs)
260{
261  rtems_rfs_rtems_private* rtems = rtems_rfs_fs_user (fs);
262  rtems_rfs_buffers_release (fs);
263  rtems_rfs_mutex_unlock (&rtems->access);
264}
265
266/**
267 * The handlers.
268 */
269extern const rtems_filesystem_file_handlers_r rtems_rfs_rtems_dir_handlers;
270extern const rtems_filesystem_file_handlers_r rtems_rfs_rtems_device_handlers;
271extern const rtems_filesystem_file_handlers_r rtems_rfs_rtems_link_handlers;
272extern const rtems_filesystem_file_handlers_r rtems_rfs_rtems_file_handlers;
273
274/**
275 * The following routine does a stat on a node.
276 *
277 * @param pathloc
278 * @param buf
279 * @return int
280 */
281int rtems_rfs_rtems_stat (rtems_filesystem_location_info_t* loc, struct stat* buf);
282
283/**
284 * File change mode routine.
285 *
286 * @param pathloc
287 * @param mode
288 * @return int
289 */
290int rtems_rfs_rtems_fchmod (rtems_filesystem_location_info_t* loc, mode_t mode);
291
292/**
293 * Routine to remove a node from the RFS file system.
294 *
295 * @param parent_pathloc
296 * @param pathloc
297 */
298int rtems_rfs_rtems_rmnod (rtems_filesystem_location_info_t* parent_pathloc,
299                           rtems_filesystem_location_info_t* pathloc);
300
301/**
302 * The following routine does a sync on an inode node. Currently it flushes
303 * everything related to this device.
304 *
305 * @param iop
306 */
307int rtems_rfs_rtems_fdatasync (rtems_libio_t* iop);
308
309/**
310 * The following routine does a fcntl on an node.
311 *
312 * @param cmd
313 * @param iop
314 * @return int
315 */
316int rtems_rfs_rtems_fcntl (int cmd, rtems_libio_t* iop);
317
318#endif
Note: See TracBrowser for help on using the repository browser.