source: rtems/cpukit/libfs/src/rfs/rtems-rfs-dir.h @ 3c96bee

4.115
Last change on this file since 3c96bee was a15eaaf, checked in by Joel Sherrill <joel.sherrill@…>, on 01/10/13 at 19:20:34

cpukit: Doxygen group fixes and many warnings addressed

The output of the modules.html is much improved. Most
filesystem and POSIX API related groups are properly nested.
Some formatting issues were addressed as were multiple
inconsistencies.

  • Property mode set to 100644
File size: 6.6 KB
Line 
1/**
2 * @file
3 *
4 * @brief RTEMS File System Directory Support
5 *
6 * @ingroup rtems_rfs
7 *
8 * RTEMS File System Directory Support
9 *
10 * This file provides the directory support functions.
11 */
12
13/*
14 *  COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.com/license/LICENSE.
19 */
20
21#if !defined (_RTEMS_RFS_DIR_H_)
22#define _RTEMS_RFS_DIR_H_
23
24#include <dirent.h>
25
26#include <rtems/libio_.h>
27
28#include <rtems/rfs/rtems-rfs-data.h>
29#include <rtems/rfs/rtems-rfs-file-system.h>
30#include <rtems/rfs/rtems-rfs-inode.h>
31
32/**
33 * Define the offsets of the fields of a directory entry.
34 */
35#define RTEMS_RFS_DIR_ENTRY_INO  (0) /**< The ino offset in a directory
36                                      * entry. */
37#define RTEMS_RFS_DIR_ENTRY_HASH (4) /**< The hash offset in a directory
38                                      * entry. The hash is 32bits. We need at
39                                      * least 16bits and given the length and
40                                      * ino field are 4 the extra 2 bytes is
41                                      * not a big overhead.*/
42#define RTEMS_RFS_DIR_ENTRY_LEN  (8) /**< The length offset in a directory
43                                      * entry. */
44
45/**
46 * The length of the directory entry header.
47 */
48#define RTEMS_RFS_DIR_ENTRY_SIZE (4 + 4 + 2)
49
50/**
51 * The length when the remainder of the directory block is empty.
52 */
53#define RTEMS_RFS_DIR_ENTRY_EMPTY (0xffff)
54
55/**
56 * Return the hash of the entry.
57 *
58 * @param[in] _e is a pointer to the directory entry.
59 *
60 * @retval hash The uint32_t hash of the entry.
61 */
62#define rtems_rfs_dir_entry_hash(_e) \
63  rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH)
64
65/**
66 * Set the hash of the entry.
67 *
68 * @param[in] _e is a pointer to the directory entry.
69 *
70 * @param[in] _h is the hash of the entry.
71 */
72#define rtems_rfs_dir_set_entry_hash(_e, _h) \
73  rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH, _h)
74
75/**
76 * Return the ino of the entry.
77 *
78 * @param[in] _e is a pointer to the directory entry.
79 *
80 * @retval ino The ino of the entry.
81 */
82#define rtems_rfs_dir_entry_ino(_e) \
83  rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO)
84
85/**
86 * Set the ino of the entry.
87 *
88 * @param[in] _e is a pointer to the directory entry.
89 *
90 * @param[in] _i is the ino of the entry.
91 */
92#define rtems_rfs_dir_set_entry_ino(_e, _i) \
93  rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO, _i)
94
95/**
96 * Return the length of the entry.
97 *
98 * @param[in] _e Pointer to the directory entry.
99 *
100 * @retval length The length of the entry.
101 */
102#define rtems_rfs_dir_entry_length(_e) \
103  rtems_rfs_read_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN)
104
105/**
106 * Set the length of the entry.
107 *
108 * @param[in] _e is a pointer to the directory entry.
109 * @param[in] _l is the length.
110 */
111#define rtems_rfs_dir_set_entry_length(_e, _l) \
112  rtems_rfs_write_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN, _l)
113
114/**
115 * Look up a directory entry in the directory pointed to by the inode. The look
116 * up is local to this directory. No need to decend.
117 *
118 * @param[in] fs is the file system.
119 * @param[in] inode is a pointer to the inode of the directory to search.
120 * @param[in] name is a pointer to the name to look up. The name may not be
121 *             nul terminated.
122 * @param[in] length is the length of the name.
123 * @param[out] ino will be filled in with the inode number
124 *              if there is no error.
125 * @param[in] offset is the offset in the directory for the entry.
126 *
127 * @retval 0 Successful operation.
128 * @retval error_code An error occurred.
129 */
130int rtems_rfs_dir_lookup_ino (rtems_rfs_file_system*  fs,
131                              rtems_rfs_inode_handle* inode,
132                              const char*             name,
133                              int                     length,
134                              rtems_rfs_ino*          ino,
135                              uint32_t*               offset);
136
137/**
138 * Add an entry to the directory returing the inode number allocated to the
139 * entry.
140 *
141 * @param[in] fs is the file system data.
142 * @param[in] dir is a pointer to the directory inode the
143 *             entry is to be added too.
144 * @param[in] name is a pointer to the name of the entry to be added.
145 * @param[in] length is the length of the name excluding a terminating 0.
146 * @param[in] ino is the ino of the entry.
147 *
148 * @retval 0 Successful operation.
149 * @retval error_code An error occurred.
150 */
151int rtems_rfs_dir_add_entry (rtems_rfs_file_system*  fs,
152                             rtems_rfs_inode_handle* dir,
153                             const char*             name,
154                             size_t                  length,
155                             rtems_rfs_ino           ino);
156
157/**
158 * Del an entry from the directory using an inode number as a key.
159 *
160 * @param[in] fs is the file system data.
161 * @param[in] dir is a pointer to the directory inode the
162 * entry is to be deleted from.
163 * @param[in] ino is the ino of the entry.
164 * @param[in] offset is the offset in the directory of the entry
165 *               to delete. If 0  search from the start for the ino.
166 *
167 * @retval 0 Successful operation.
168 * @retval error_code An error occurred.
169 */
170int rtems_rfs_dir_del_entry (rtems_rfs_file_system*  fs,
171                             rtems_rfs_inode_handle* dir,
172                             rtems_rfs_ino           ino,
173                             uint32_t                offset);
174
175/**
176 * Read the directory entry from offset into the directory entry buffer and
177 * return the length of space this entry uses in the directory table.
178 *
179 * @param[in] fs is the file system data.
180 * @param[in] dir is a pointer to the direct inode handler.
181 * @param[in] offset is the offset in the directory to read from.
182 * @param[in] dirent is a ointer to the dirent structure the entry
183 *              is written into.
184 * @param[out] length will contain the length this entry
185 *               takes in the directory.
186 *
187 * @retval 0 Successful operation.
188 * @retval error_code An error occurred.
189 */
190int rtems_rfs_dir_read (rtems_rfs_file_system*  fs,
191                        rtems_rfs_inode_handle* dir,
192                        rtems_rfs_pos_rel       offset,
193                        struct dirent*          dirent,
194                        size_t*                 length);
195
196/**
197 * Check if the directory is empty. The current and parent directory entries
198 * are ignored.
199 *
200 * @param[in] fs is the file system data
201 * @param[in] dir is a pointer to the directory inode to check.
202 *
203 * @retval 0 Successful operation.
204 * @retval error_code An error occurred.
205 */
206int rtems_rfs_dir_empty (rtems_rfs_file_system*  fs,
207                         rtems_rfs_inode_handle* dir);
208
209#endif
Note: See TracBrowser for help on using the repository browser.