RTEMS 6.1-rc1
rtems-rfs-file.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
15/*
16 * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40#if !defined (_RTEMS_RFS_FILE_H_)
41#define _RTEMS_RFS_FILE_H_
42
43#include <rtems/libio_.h>
44
49
57{
62
67
72
78
84
89
94
99
105
107
115static inline rtems_rfs_time
116rtems_rfs_file_shared_get_atime (rtems_rfs_file_shared* shared)
117{
118 return shared->atime;
119}
120
128static inline rtems_rfs_time
129rtems_rfs_file_shared_get_mtime (rtems_rfs_file_shared* shared)
130{
131 return shared->mtime;
132}
133
141static inline rtems_rfs_time
142rtems_rfs_file_shared_get_ctime (rtems_rfs_file_shared* shared)
143{
144 return shared->ctime;
145}
146
154static inline uint32_t
155rtems_rfs_file_shared_get_block_count (rtems_rfs_file_shared* shared)
156{
157 return shared->size.count;
158}
159
167static inline uint16_t
168rtems_rfs_file_shared_get_block_offset (rtems_rfs_file_shared* shared)
169{
170 return shared->size.offset;
171}
172
181static inline rtems_rfs_pos
182rtems_rfs_file_shared_get_size (rtems_rfs_file_system* fs,
183 rtems_rfs_file_shared* shared)
184{
185 return rtems_rfs_block_get_size (fs, &shared->size);
186}
187
191#define RTEMS_RFS_FILE_NO_ATIME_UPDATE (1 << 0)
194#define RTEMS_RFS_FILE_NO_MTIME_UPDATE (1 << 1)
197#define RTEMS_RFS_FILE_NO_LENGTH_UPDATE (1 << 2)
205{
209 int flags;
210
215
220
225
227
231#define rtems_rfs_file_data(_f) \
232 (rtems_rfs_buffer_data (&(_f)->buffer) + (_f)->bpos.boff)
233
237#define rtems_rfs_file_fs(_f) ((_f)->shared->fs)
238
242#define rtems_rfs_file_inode(_f) (&(_f)->shared->inode)
243
247#define rtems_rfs_file_map(_f) (&(_f)->shared->map)
248
252#define rtems_rfs_file_bpos(_f) (&(_f)->bpos)
253
257#define rtems_rfs_file_block(_f) ((_f)->bpos.bno)
258
262#define rtems_rfs_file_block_offset(_f) ((_f)->bpos.boff)
263
267#define rtems_rfs_file_set_bpos(_f, _p) \
268 rtems_rfs_block_get_bpos (rtems_rfs_file_fs (_f), _p, (&(_f)->bpos))
269
273#define rtems_rfs_file_buffer(_f) (&(_f)->buffer)
274
278#define rtems_rfs_file_update_atime(_f) \
279 (((_f)->flags & RTEMS_RFS_FILE_NO_ATIME_UPDATE) == 0)
280
284#define rtems_rfs_file_update_mtime(_f) \
285 (((_f)->flags & RTEMS_RFS_FILE_NO_MTIME_UPDATE) == 0)
286
290#define rtems_rfs_file_update_length(_f) \
291 (((_f)->flags & RTEMS_RFS_FILE_NO_LENGTH_UPDATE) == 0)
292
296#define rtems_rfs_file_get_size(_f) \
297 (&(_f)->shared->size)
298
302#define rtems_rfs_file_size(_f) \
303 rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (_f), (_f)->shared)
304
308#define rtems_rfs_file_size_count(_f) \
309 rtems_rfs_file_shared_get_block_count ((_f)->shared)
310
314#define rtems_rfs_file_size_offset(_f) \
315 rtems_rfs_file_shared_get_block_offset ((_f)->shared)
316
328 rtems_rfs_ino ino,
329 int oflag,
330 rtems_rfs_file_handle** handle);
331
342 rtems_rfs_file_handle* handle);
343
361 size_t* available,
362 bool read);
363
379 size_t size,
380 bool read);
381
393
406 rtems_rfs_pos pos,
407 rtems_rfs_pos* new_pos);
408
420
432 rtems_rfs_ino ino);
433
434
435#endif
ssize_t read(int fd, void *buffer, size_t count)
Definition: read.c:46
LibIO Internal Interface.
rtems_rfs_pos rtems_rfs_block_get_size(rtems_rfs_file_system *fs, rtems_rfs_block_size *size)
Definition: rtems-rfs-block.c:98
RTEMS File Systems Block Management.
RTEMS File System Data.
RTEMS File System Data.
uint64_t rtems_rfs_pos
Definition: rtems-rfs-file-system.h:109
int rtems_rfs_file_set_size(rtems_rfs_file_handle *handle, rtems_rfs_pos size)
Definition: rtems-rfs-file.c:490
struct _rtems_rfs_file_handle rtems_rfs_file_handle
int rtems_rfs_file_io_release(rtems_rfs_file_handle *handle)
Definition: rtems-rfs-file.c:416
rtems_rfs_file_shared * rtems_rfs_file_get_shared(rtems_rfs_file_system *fs, rtems_rfs_ino ino)
Definition: rtems-rfs-file.c:640
int rtems_rfs_file_close(rtems_rfs_file_system *fs, rtems_rfs_file_handle *handle)
Definition: rtems-rfs-file.c:164
int rtems_rfs_file_io_start(rtems_rfs_file_handle *handle, size_t *available, bool read)
Definition: rtems-rfs-file.c:241
int rtems_rfs_file_open(rtems_rfs_file_system *fs, rtems_rfs_ino ino, int oflag, rtems_rfs_file_handle **handle)
Definition: rtems-rfs-file.c:52
int rtems_rfs_file_seek(rtems_rfs_file_handle *handle, rtems_rfs_pos pos, rtems_rfs_pos *new_pos)
Definition: rtems-rfs-file.c:426
int rtems_rfs_file_io_end(rtems_rfs_file_handle *handle, size_t size, bool read)
Definition: rtems-rfs-file.c:329
struct _rtems_rfs_file_shared rtems_rfs_file_shared
RTEMS File System Information Node.
uint32_t rtems_rfs_time
Definition: rtems-rfs-inode.h:102
uint32_t rtems_rfs_ino
Definition: rtems-rfs-inode.h:97
This structure represents a chain node.
Definition: chain.h:78
Definition: rtems-rfs-file.h:205
int flags
Definition: rtems-rfs-file.h:209
rtems_rfs_block_pos bpos
Definition: rtems-rfs-file.h:219
rtems_rfs_file_shared * shared
Definition: rtems-rfs-file.h:224
rtems_rfs_buffer_handle buffer
Definition: rtems-rfs-file.h:214
Definition: rtems-rfs-file.h:57
rtems_rfs_inode_handle inode
Definition: rtems-rfs-file.h:71
rtems_rfs_file_system * fs
Definition: rtems-rfs-file.h:104
int references
Definition: rtems-rfs-file.h:66
rtems_rfs_block_size size
Definition: rtems-rfs-file.h:83
rtems_rfs_time atime
Definition: rtems-rfs-file.h:88
rtems_rfs_time ctime
Definition: rtems-rfs-file.h:98
rtems_rfs_block_map map
Definition: rtems-rfs-file.h:77
rtems_rfs_time mtime
Definition: rtems-rfs-file.h:93
rtems_chain_node link
Definition: rtems-rfs-file.h:61
Definition: rtems-rfs-file-system.h:135
Definition: rtems-rfs-inode.h:201
Definition: rtems-rfs-block.h:112
Definition: rtems-rfs-block-pos.h:71
Definition: rtems-rfs-block-pos.h:161
rtems_rfs_block_off offset
Definition: rtems-rfs-block-pos.h:172
rtems_rfs_block_no count
Definition: rtems-rfs-block-pos.h:166
Definition: rtems-rfs-buffer.h:111
unsigned size
Definition: tte.h:1