RTEMS: cpukit/include/rtems/rfs/rtems-rfs-inode.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
rtems-rfs-inode.h
Go to the documentation of this file.
1
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.org/license/LICENSE.
19 */
20
21
22#if !defined (_RTEMS_RFS_INODE_H_)
23#define _RTEMS_RFS_INODE_H_
24
25#include <sys/stat.h>
26
27#include <rtems/rfs/rtems-rfs-data.h>
28#include <rtems/rfs/rtems-rfs-file-system.h>
29
33#define RTEMS_RFS_S_ISUID S_ISUID
34#define RTEMS_RFS_S_ISGID S_ISGID
35#define RTEMS_RFS_S_ISVTX S_ISVTX
36#define RTEMS_RFS_S_IREAD S_IREAD
37#define RTEMS_RFS_S_IWRITE S_IWRITE
38#define RTEMS_RFS_S_IEXEC S_IEXEC
39#define RTEMS_RFS_S_ENFMT S_ENFMT
40#define RTEMS_RFS_S_IFMT S_IFMT
41#define RTEMS_RFS_S_IFDIR S_IFDIR
42#define RTEMS_RFS_S_IFCHR S_IFCHR
43#define RTEMS_RFS_S_IFBLK S_IFBLK
44#define RTEMS_RFS_S_IFREG S_IFREG
45#define RTEMS_RFS_S_IFLNK S_IFLNK
46#define RTEMS_RFS_S_IFSOCK S_IFSOCK
47#define RTEMS_RFS_S_IFIFO S_IFIFO
48#define RTEMS_RFS_S_IRWXU S_IRWXU
49#define RTEMS_RFS_S_IRUSR S_IRUSR
50#define RTEMS_RFS_S_IWUSR S_IWUSR
51#define RTEMS_RFS_S_IXUSR S_IXUSR
52#define RTEMS_RFS_S_IRWXG S_IRWXG
53#define RTEMS_RFS_S_IRGRP S_IRGRP
54#define RTEMS_RFS_S_IWGRP S_IWGRP
55#define RTEMS_RFS_S_IXGRP S_IXGRP
56#define RTEMS_RFS_S_IRWXO S_IRWXO
57#define RTEMS_RFS_S_IROTH S_IROTH
58#define RTEMS_RFS_S_IWOTH S_IWOTH
59#define RTEMS_RFS_S_IXOTH S_IXOTH
61#define RTEMS_RFS_S_ISBLK(m) S_ISBLK(m)
62#define RTEMS_RFS_S_ISCHR(m) S_ISCHR(m)
63#define RTEMS_RFS_S_ISDIR(m) S_ISDIR(m)
64#define RTEMS_RFS_S_ISFIFO(m) S_ISFIFO(m)
65#define RTEMS_RFS_S_ISREG(m) S_ISREG(m)
66#define RTEMS_RFS_S_ISLNK(m) S_ISLNK(m)
67#define RTEMS_RFS_S_ISSOCK(m) S_ISSOCK(m)
68
72#define RTEMS_RFS_S_SYMLINK \
73 RTEMS_RFS_S_IFLNK | RTEMS_RFS_S_IRWXU | RTEMS_RFS_S_IRWXG | RTEMS_RFS_S_IRWXO
74
78 typedef uint32_t rtems_rfs_ino;
79
83 typedef uint32_t rtems_rfs_time;
84
89 typedef uint32_t rtems_rfs_inode_block;
90
94#define RTEMS_RFS_INODE_DATA_NAME_SIZE \
95 (RTEMS_RFS_INODE_BLOCKS * sizeof (rtems_rfs_inode_block))
96
100 typedef struct _rtems_rfs_inode
101{
105 uint16_t links;
106
110 uint16_t mode;
111
115 uint32_t owner;
116
120 uint16_t flags;
121
125 uint16_t block_offset;
126
130 uint32_t block_count;
131
135 rtems_rfs_time atime;
136
140 rtems_rfs_time mtime;
141
145 rtems_rfs_time ctime;
146
154 union
155 {
156 rtems_rfs_inode_block blocks[RTEMS_RFS_INODE_BLOCKS];
157 uint8_t name[RTEMS_RFS_INODE_DATA_NAME_SIZE];
158 } data;
159
164 rtems_rfs_inode_block last_map_block;
165
169 rtems_rfs_inode_block last_data_block;
170
171} rtems_rfs_inode;
172
176#define RTEMS_RFS_INODE_SIZE (sizeof (rtems_rfs_inode))
177
181 typedef struct _rtems_rfs_inode_handle
182{
186 rtems_chain_node link;
187
191 rtems_rfs_ino ino;
192
196 rtems_rfs_inode* node;
197
201 rtems_rfs_buffer_handle buffer;
202
206 rtems_rfs_buffer_block block;
207
211 int offset;
212
216 int loads;
217
218} rtems_rfs_inode_handle;
219
223#define rtems_rfs_inode_is_loaded(_h) ((_h)->node)
224
228#define rtems_rfs_inode_ino(_h) ((_h)->ino)
229
237static inline uint16_t
238rtems_rfs_inode_get_links (rtems_rfs_inode_handle* handle)
239{
240 uint16_t links;
241 links = rtems_rfs_read_u16 (&handle->node->links);
242 if (links == 0xffff)
243 links = 0;
244 return links;
245}
246
253static inline void
254rtems_rfs_inode_set_links (rtems_rfs_inode_handle* handle, uint16_t links)
255{
256 rtems_rfs_write_u16 (&handle->node->links, links);
257 rtems_rfs_buffer_mark_dirty (&handle->buffer);
258}
259
267static inline uint16_t
268rtems_rfs_inode_get_flags (rtems_rfs_inode_handle* handle)
269{
270 return rtems_rfs_read_u16 (&handle->node->flags);
271}
272
279static inline void
280rtems_rfs_inode_set_flags (rtems_rfs_inode_handle* handle, uint16_t flags)
281{
282 rtems_rfs_write_u16 (&handle->node->flags, flags);
283 rtems_rfs_buffer_mark_dirty (&handle->buffer);
284}
285
293static inline uint16_t
294rtems_rfs_inode_get_mode (rtems_rfs_inode_handle* handle)
295{
296 return rtems_rfs_read_u16 (&handle->node->mode);
297}
298
305static inline void
306rtems_rfs_inode_set_mode (rtems_rfs_inode_handle* handle, uint16_t mode)
307{
308 rtems_rfs_write_u16 (&handle->node->mode, mode);
309 rtems_rfs_buffer_mark_dirty (&handle->buffer);
310}
311
319static inline uint16_t
320rtems_rfs_inode_get_uid (rtems_rfs_inode_handle* handle)
321{
322 return rtems_rfs_read_u32 (&handle->node->owner) & 0xffff;
323}
324
332static inline uint16_t
333rtems_rfs_inode_get_gid (rtems_rfs_inode_handle* handle)
334{
335 return (rtems_rfs_read_u32 (&handle->node->owner) >> 16) & 0xffff;
336}
337
345static inline void
346rtems_rfs_inode_set_uid_gid (rtems_rfs_inode_handle* handle,
347 uint16_t uid, uint16_t gid)
348{
349 rtems_rfs_write_u32 (&handle->node->owner, (((uint32_t) gid) << 16) | uid);
350 rtems_rfs_buffer_mark_dirty (&handle->buffer);
351}
352
360static inline uint16_t
361rtems_rfs_inode_get_block_offset (rtems_rfs_inode_handle* handle)
362{
363 return rtems_rfs_read_u16 (&handle->node->block_offset);
364}
365
372static inline void
373rtems_rfs_inode_set_block_offset (rtems_rfs_inode_handle* handle,
374 uint16_t block_offset)
375{
376 rtems_rfs_write_u16 (&handle->node->block_offset, block_offset);
377 rtems_rfs_buffer_mark_dirty (&handle->buffer);
378}
379
387static inline uint32_t
388rtems_rfs_inode_get_block_count (rtems_rfs_inode_handle* handle)
389{
390 return rtems_rfs_read_u32 (&handle->node->block_count);
391}
392
399static inline void
400rtems_rfs_inode_set_block_count (rtems_rfs_inode_handle* handle, uint32_t block_count)
401{
402 rtems_rfs_write_u32 (&handle->node->block_count, block_count);
403 rtems_rfs_buffer_mark_dirty (&handle->buffer);
404}
405
413static inline rtems_rfs_time
414rtems_rfs_inode_get_atime (rtems_rfs_inode_handle* handle)
415{
416 return rtems_rfs_read_u32 (&handle->node->atime);
417}
418
425static inline void
426rtems_rfs_inode_set_atime (rtems_rfs_inode_handle* handle,
427 rtems_rfs_time atime)
428{
429 rtems_rfs_write_u32 (&handle->node->atime, atime);
430 rtems_rfs_buffer_mark_dirty (&handle->buffer);
431}
432
440static inline rtems_rfs_time
441rtems_rfs_inode_get_mtime (rtems_rfs_inode_handle* handle)
442{
443 return rtems_rfs_read_u32 (&handle->node->mtime);
444}
445
452static inline void
453rtems_rfs_inode_set_mtime (rtems_rfs_inode_handle* handle,
454 rtems_rfs_time mtime)
455{
456 rtems_rfs_write_u32 (&handle->node->mtime, mtime);
457 rtems_rfs_buffer_mark_dirty (&handle->buffer);
458}
459
467static inline rtems_rfs_time
468rtems_rfs_inode_get_ctime (rtems_rfs_inode_handle* handle)
469{
470 return rtems_rfs_read_u32 (&handle->node->ctime);
471}
472
479static inline void
480rtems_rfs_inode_set_ctime (rtems_rfs_inode_handle* handle,
481 rtems_rfs_time ctime)
482{
483 rtems_rfs_write_u32 (&handle->node->ctime, ctime);
484 rtems_rfs_buffer_mark_dirty (&handle->buffer);
485}
486
495static inline uint32_t
496rtems_rfs_inode_get_block (rtems_rfs_inode_handle* handle, int block)
497{
498 return rtems_rfs_read_u32 (&handle->node->data.blocks[block]);
499}
500
508static inline void
509rtems_rfs_inode_set_block (rtems_rfs_inode_handle* handle, int block, uint32_t bno)
510{
511 rtems_rfs_write_u32 (&handle->node->data.blocks[block], bno);
512 rtems_rfs_buffer_mark_dirty (&handle->buffer);
513}
514
522static inline uint32_t
523rtems_rfs_inode_get_last_map_block (rtems_rfs_inode_handle* handle)
524{
525 return rtems_rfs_read_u32 (&handle->node->last_map_block);
526}
527
534static inline void
535rtems_rfs_inode_set_last_map_block (rtems_rfs_inode_handle* handle, uint32_t last_map_block)
536{
537 rtems_rfs_write_u32 (&handle->node->last_map_block, last_map_block);
538 rtems_rfs_buffer_mark_dirty (&handle->buffer);
539}
540
549static inline uint32_t
550rtems_rfs_inode_get_last_data_block (rtems_rfs_inode_handle* handle)
551{
552 return rtems_rfs_read_u32 (&handle->node->last_data_block);
553}
554
561static inline void
562rtems_rfs_inode_set_last_data_block (rtems_rfs_inode_handle* handle, uint32_t last_data_block)
563{
564 rtems_rfs_write_u32 (&handle->node->last_data_block, last_data_block);
565 rtems_rfs_buffer_mark_dirty (&handle->buffer);
566}
567
577int rtems_rfs_inode_alloc (rtems_rfs_file_system* fs,
578 rtems_rfs_bitmap_bit goal,
579 rtems_rfs_ino* ino);
580
590int rtems_rfs_inode_free (rtems_rfs_file_system* fs,
591 rtems_rfs_ino ino);
592
606int rtems_rfs_inode_open (rtems_rfs_file_system* fs,
607 rtems_rfs_ino ino,
608 rtems_rfs_inode_handle* handle,
609 bool load);
610
620int rtems_rfs_inode_close (rtems_rfs_file_system* fs,
621 rtems_rfs_inode_handle* handle);
622
632int rtems_rfs_inode_load (rtems_rfs_file_system* fs,
633 rtems_rfs_inode_handle* handle);
634
645int rtems_rfs_inode_unload (rtems_rfs_file_system* fs,
646 rtems_rfs_inode_handle* handle,
647 bool update_ctime);
648
659int rtems_rfs_inode_create (rtems_rfs_file_system* fs,
660 rtems_rfs_ino parent,
661 const char* name,
662 size_t length,
663 uint16_t mode,
664 uint16_t links,
665 uid_t uid,
666 gid_t gid,
667 rtems_rfs_ino* ino);
668
679int rtems_rfs_inode_delete (rtems_rfs_file_system* fs,
680 rtems_rfs_inode_handle* handle);
681
694int rtems_rfs_inode_initialise (rtems_rfs_inode_handle* handle,
695 uint16_t links,
696 uint16_t mode,
697 uid_t uid,
698 gid_t gid);
699
712int rtems_rfs_inode_time_stamp_now (rtems_rfs_inode_handle* handle,
713 bool atime,
714 bool mtime);
715
724 rtems_rfs_pos rtems_rfs_inode_get_size (rtems_rfs_file_system* fs,
725 rtems_rfs_inode_handle* handle);
726
727#endif
728
rtems_rfs_bitmap_bit
int32_t rtems_rfs_bitmap_bit
Definition: rtems-rfs-bitmaps.h:84
rtems_rfs_buffer_block
uint32_t rtems_rfs_buffer_block
Definition: rtems-rfs-buffer.h:62
rtems_rfs_buffer_mark_dirty
#define rtems_rfs_buffer_mark_dirty(_h)
Definition: rtems-rfs-buffer.h:144
rtems-rfs-data.h
RTEMS File System Data.
rtems_rfs_write_u32
#define rtems_rfs_write_u32(_d, _v)
Definition: rtems-rfs-data.h:81
rtems_rfs_read_u16
#define rtems_rfs_read_u16(_d)
Definition: rtems-rfs-data.h:50
rtems_rfs_write_u16
#define rtems_rfs_write_u16(_d, _v)
Definition: rtems-rfs-data.h:72
rtems_rfs_read_u32
#define rtems_rfs_read_u32(_d)
Definition: rtems-rfs-data.h:57
rtems-rfs-file-system.h
RTEMS File System Data.
RTEMS_RFS_INODE_BLOCKS
#define RTEMS_RFS_INODE_BLOCKS
Definition: rtems-rfs-file-system.h:67
rtems_rfs_pos
uint64_t rtems_rfs_pos
Definition: rtems-rfs-file-system.h:90
rtems_rfs_inode_handle
struct _rtems_rfs_inode_handle rtems_rfs_inode_handle
rtems_rfs_inode_alloc
int rtems_rfs_inode_alloc(rtems_rfs_file_system *fs, rtems_rfs_bitmap_bit goal, rtems_rfs_ino *ino)
Definition: rtems-rfs-inode.c:32
rtems_rfs_inode_open
int rtems_rfs_inode_open(rtems_rfs_file_system *fs, rtems_rfs_ino ino, rtems_rfs_inode_handle *handle, bool load)
Definition: rtems-rfs-inode.c:53
rtems_rfs_inode_delete
int rtems_rfs_inode_delete(rtems_rfs_file_system *fs, rtems_rfs_inode_handle *handle)
Definition: rtems-rfs-inode.c:320
rtems_rfs_inode_close
int rtems_rfs_inode_close(rtems_rfs_file_system *fs, rtems_rfs_inode_handle *handle)
Definition: rtems-rfs-inode.c:91
rtems_rfs_inode_free
int rtems_rfs_inode_free(rtems_rfs_file_system *fs, rtems_rfs_ino ino)
Definition: rtems-rfs-inode.c:44
rtems_rfs_time
uint32_t rtems_rfs_time
Definition: rtems-rfs-inode.h:83
rtems_rfs_inode_initialise
int rtems_rfs_inode_initialise(rtems_rfs_inode_handle *handle, uint16_t links, uint16_t mode, uid_t uid, gid_t gid)
Definition: rtems-rfs-inode.c:373
rtems_rfs_inode_create
int rtems_rfs_inode_create(rtems_rfs_file_system *fs, rtems_rfs_ino parent, const char *name, size_t length, uint16_t mode, uint16_t links, uid_t uid, gid_t gid, rtems_rfs_ino *ino)
Definition: rtems-rfs-inode.c:179
rtems_rfs_inode_block
uint32_t rtems_rfs_inode_block
Definition: rtems-rfs-inode.h:89
RTEMS_RFS_INODE_DATA_NAME_SIZE
#define RTEMS_RFS_INODE_DATA_NAME_SIZE
Definition: rtems-rfs-inode.h:94
rtems_rfs_inode
struct _rtems_rfs_inode rtems_rfs_inode
rtems_rfs_inode_load
int rtems_rfs_inode_load(rtems_rfs_file_system *fs, rtems_rfs_inode_handle *handle)
Definition: rtems-rfs-inode.c:114
rtems_rfs_inode_get_size
rtems_rfs_pos rtems_rfs_inode_get_size(rtems_rfs_file_system *fs, rtems_rfs_inode_handle *handle)
Definition: rtems-rfs-inode.c:410
rtems_rfs_inode_unload
int rtems_rfs_inode_unload(rtems_rfs_file_system *fs, rtems_rfs_inode_handle *handle, bool update_ctime)
Definition: rtems-rfs-inode.c:145
rtems_rfs_inode_time_stamp_now
int rtems_rfs_inode_time_stamp_now(rtems_rfs_inode_handle *handle, bool atime, bool mtime)
Definition: rtems-rfs-inode.c:394
rtems_rfs_ino
uint32_t rtems_rfs_ino
Definition: rtems-rfs-inode.h:78
Chain_Node_struct
Definition: chain.h:68
_rtems_rfs_file_system
Definition: rtems-rfs-file-system.h:116
_rtems_rfs_inode_handle
Definition: rtems-rfs-inode.h:182
_rtems_rfs_inode_handle::block
rtems_rfs_buffer_block block
Definition: rtems-rfs-inode.h:206
_rtems_rfs_inode_handle::offset
int offset
Definition: rtems-rfs-inode.h:211
_rtems_rfs_inode_handle::loads
int loads
Definition: rtems-rfs-inode.h:216
_rtems_rfs_inode_handle::ino
rtems_rfs_ino ino
Definition: rtems-rfs-inode.h:191
_rtems_rfs_inode_handle::buffer
rtems_rfs_buffer_handle buffer
Definition: rtems-rfs-inode.h:201
_rtems_rfs_inode_handle::link
rtems_chain_node link
Definition: rtems-rfs-inode.h:186
_rtems_rfs_inode_handle::node
rtems_rfs_inode * node
Definition: rtems-rfs-inode.h:196
_rtems_rfs_inode
Definition: rtems-rfs-inode.h:101
_rtems_rfs_inode::mode
uint16_t mode
Definition: rtems-rfs-inode.h:110
_rtems_rfs_inode::block_count
uint32_t block_count
Definition: rtems-rfs-inode.h:130
_rtems_rfs_inode::block_offset
uint16_t block_offset
Definition: rtems-rfs-inode.h:125
_rtems_rfs_inode::data
union _rtems_rfs_inode::@3973 data
_rtems_rfs_inode::links
uint16_t links
Definition: rtems-rfs-inode.h:105
_rtems_rfs_inode::flags
uint16_t flags
Definition: rtems-rfs-inode.h:120
_rtems_rfs_inode::last_map_block
rtems_rfs_inode_block last_map_block
Definition: rtems-rfs-inode.h:164
_rtems_rfs_inode::owner
uint32_t owner
Definition: rtems-rfs-inode.h:115
_rtems_rfs_inode::mtime
rtems_rfs_time mtime
Definition: rtems-rfs-inode.h:140
_rtems_rfs_inode::ctime
rtems_rfs_time ctime
Definition: rtems-rfs-inode.h:145
_rtems_rfs_inode::last_data_block
rtems_rfs_inode_block last_data_block
Definition: rtems-rfs-inode.h:169
_rtems_rfs_inode::atime
rtems_rfs_time atime
Definition: rtems-rfs-inode.h:135
rtems_rfs_buffer_handle_t
Definition: rtems-rfs-buffer.h:92