RTEMS 6.1-rc5
Loading...
Searching...
No Matches
rtems-rfs-inode.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
41#if !defined (_RTEMS_RFS_INODE_H_)
42#define _RTEMS_RFS_INODE_H_
43
44#include <sys/stat.h>
45
48
52#define RTEMS_RFS_S_ISUID S_ISUID
53#define RTEMS_RFS_S_ISGID S_ISGID
54#define RTEMS_RFS_S_ISVTX S_ISVTX
55#define RTEMS_RFS_S_IREAD S_IREAD
56#define RTEMS_RFS_S_IWRITE S_IWRITE
57#define RTEMS_RFS_S_IEXEC S_IEXEC
58#define RTEMS_RFS_S_ENFMT S_ENFMT
59#define RTEMS_RFS_S_IFMT S_IFMT
60#define RTEMS_RFS_S_IFDIR S_IFDIR
61#define RTEMS_RFS_S_IFCHR S_IFCHR
62#define RTEMS_RFS_S_IFBLK S_IFBLK
63#define RTEMS_RFS_S_IFREG S_IFREG
64#define RTEMS_RFS_S_IFLNK S_IFLNK
65#define RTEMS_RFS_S_IFSOCK S_IFSOCK
66#define RTEMS_RFS_S_IFIFO S_IFIFO
67#define RTEMS_RFS_S_IRWXU S_IRWXU
68#define RTEMS_RFS_S_IRUSR S_IRUSR
69#define RTEMS_RFS_S_IWUSR S_IWUSR
70#define RTEMS_RFS_S_IXUSR S_IXUSR
71#define RTEMS_RFS_S_IRWXG S_IRWXG
72#define RTEMS_RFS_S_IRGRP S_IRGRP
73#define RTEMS_RFS_S_IWGRP S_IWGRP
74#define RTEMS_RFS_S_IXGRP S_IXGRP
75#define RTEMS_RFS_S_IRWXO S_IRWXO
76#define RTEMS_RFS_S_IROTH S_IROTH
77#define RTEMS_RFS_S_IWOTH S_IWOTH
78#define RTEMS_RFS_S_IXOTH S_IXOTH
80#define RTEMS_RFS_S_ISBLK(m) S_ISBLK(m)
81#define RTEMS_RFS_S_ISCHR(m) S_ISCHR(m)
82#define RTEMS_RFS_S_ISDIR(m) S_ISDIR(m)
83#define RTEMS_RFS_S_ISFIFO(m) S_ISFIFO(m)
84#define RTEMS_RFS_S_ISREG(m) S_ISREG(m)
85#define RTEMS_RFS_S_ISLNK(m) S_ISLNK(m)
86#define RTEMS_RFS_S_ISSOCK(m) S_ISSOCK(m)
87
91#define RTEMS_RFS_S_SYMLINK \
92 RTEMS_RFS_S_IFLNK | RTEMS_RFS_S_IRWXU | RTEMS_RFS_S_IRWXG | RTEMS_RFS_S_IRWXO
93
97typedef uint32_t rtems_rfs_ino;
98
102typedef uint32_t rtems_rfs_time;
103
108typedef uint32_t rtems_rfs_inode_block;
109
113#define RTEMS_RFS_INODE_DATA_NAME_SIZE \
114 (RTEMS_RFS_INODE_BLOCKS * sizeof (rtems_rfs_inode_block))
115
119typedef struct _rtems_rfs_inode
120{
124 uint16_t links;
125
129 uint16_t mode;
130
134 uint32_t owner;
135
139 uint16_t flags;
140
144 uint16_t block_offset;
145
149 uint32_t block_count;
150
155
160
165
173 union
174 {
176 uint8_t name[RTEMS_RFS_INODE_DATA_NAME_SIZE];
178
184
189
191
195#define RTEMS_RFS_INODE_SIZE (sizeof (rtems_rfs_inode))
196
201{
206
211
216
221
226
231
235 int loads;
236
238
242#define rtems_rfs_inode_is_loaded(_h) ((_h)->node)
243
247#define rtems_rfs_inode_ino(_h) ((_h)->ino)
248
256static inline uint16_t
257rtems_rfs_inode_get_links (rtems_rfs_inode_handle* handle)
258{
259 uint16_t links;
260 links = rtems_rfs_read_u16 (&handle->node->links);
261 if (links == 0xffff)
262 links = 0;
263 return links;
264}
265
272static inline void
273rtems_rfs_inode_set_links (rtems_rfs_inode_handle* handle, uint16_t links)
274{
275 rtems_rfs_write_u16 (&handle->node->links, links);
277}
278
286static inline uint16_t
287rtems_rfs_inode_get_flags (rtems_rfs_inode_handle* handle)
288{
289 return rtems_rfs_read_u16 (&handle->node->flags);
290}
291
298static inline void
299rtems_rfs_inode_set_flags (rtems_rfs_inode_handle* handle, uint16_t flags)
300{
301 rtems_rfs_write_u16 (&handle->node->flags, flags);
303}
304
312static inline uint16_t
313rtems_rfs_inode_get_mode (rtems_rfs_inode_handle* handle)
314{
315 return rtems_rfs_read_u16 (&handle->node->mode);
316}
317
324static inline void
325rtems_rfs_inode_set_mode (rtems_rfs_inode_handle* handle, uint16_t mode)
326{
327 rtems_rfs_write_u16 (&handle->node->mode, mode);
329}
330
338static inline uint16_t
339rtems_rfs_inode_get_uid (rtems_rfs_inode_handle* handle)
340{
341 return rtems_rfs_read_u32 (&handle->node->owner) & 0xffff;
342}
343
351static inline uint16_t
352rtems_rfs_inode_get_gid (rtems_rfs_inode_handle* handle)
353{
354 return (rtems_rfs_read_u32 (&handle->node->owner) >> 16) & 0xffff;
355}
356
364static inline void
365rtems_rfs_inode_set_uid_gid (rtems_rfs_inode_handle* handle,
366 uint16_t uid, uint16_t gid)
367{
368 rtems_rfs_write_u32 (&handle->node->owner, (((uint32_t) gid) << 16) | uid);
370}
371
379static inline uint16_t
380rtems_rfs_inode_get_block_offset (rtems_rfs_inode_handle* handle)
381{
382 return rtems_rfs_read_u16 (&handle->node->block_offset);
383}
384
391static inline void
392rtems_rfs_inode_set_block_offset (rtems_rfs_inode_handle* handle,
393 uint16_t block_offset)
394{
395 rtems_rfs_write_u16 (&handle->node->block_offset, block_offset);
397}
398
406static inline uint32_t
407rtems_rfs_inode_get_block_count (rtems_rfs_inode_handle* handle)
408{
409 return rtems_rfs_read_u32 (&handle->node->block_count);
410}
411
418static inline void
419rtems_rfs_inode_set_block_count (rtems_rfs_inode_handle* handle, uint32_t block_count)
420{
421 rtems_rfs_write_u32 (&handle->node->block_count, block_count);
423}
424
432static inline rtems_rfs_time
433rtems_rfs_inode_get_atime (rtems_rfs_inode_handle* handle)
434{
435 return rtems_rfs_read_u32 (&handle->node->atime);
436}
437
444static inline void
445rtems_rfs_inode_set_atime (rtems_rfs_inode_handle* handle,
446 rtems_rfs_time atime)
447{
448 rtems_rfs_write_u32 (&handle->node->atime, atime);
450}
451
459static inline rtems_rfs_time
460rtems_rfs_inode_get_mtime (rtems_rfs_inode_handle* handle)
461{
462 return rtems_rfs_read_u32 (&handle->node->mtime);
463}
464
471static inline void
472rtems_rfs_inode_set_mtime (rtems_rfs_inode_handle* handle,
473 rtems_rfs_time mtime)
474{
475 rtems_rfs_write_u32 (&handle->node->mtime, mtime);
477}
478
486static inline rtems_rfs_time
487rtems_rfs_inode_get_ctime (rtems_rfs_inode_handle* handle)
488{
489 return rtems_rfs_read_u32 (&handle->node->ctime);
490}
491
498static inline void
499rtems_rfs_inode_set_ctime (rtems_rfs_inode_handle* handle,
500 rtems_rfs_time ctime)
501{
502 rtems_rfs_write_u32 (&handle->node->ctime, ctime);
504}
505
514static inline uint32_t
515rtems_rfs_inode_get_block (rtems_rfs_inode_handle* handle, int block)
516{
517 return rtems_rfs_read_u32 (&handle->node->data.blocks[block]);
518}
519
527static inline void
528rtems_rfs_inode_set_block (rtems_rfs_inode_handle* handle, int block, uint32_t bno)
529{
530 rtems_rfs_write_u32 (&handle->node->data.blocks[block], bno);
532}
533
541static inline uint32_t
542rtems_rfs_inode_get_last_map_block (rtems_rfs_inode_handle* handle)
543{
544 return rtems_rfs_read_u32 (&handle->node->last_map_block);
545}
546
553static inline void
554rtems_rfs_inode_set_last_map_block (rtems_rfs_inode_handle* handle, uint32_t last_map_block)
555{
556 rtems_rfs_write_u32 (&handle->node->last_map_block, last_map_block);
558}
559
568static inline uint32_t
569rtems_rfs_inode_get_last_data_block (rtems_rfs_inode_handle* handle)
570{
571 return rtems_rfs_read_u32 (&handle->node->last_data_block);
572}
573
580static inline void
581rtems_rfs_inode_set_last_data_block (rtems_rfs_inode_handle* handle, uint32_t last_data_block)
582{
583 rtems_rfs_write_u32 (&handle->node->last_data_block, last_data_block);
585}
586
598 rtems_rfs_ino* ino);
599
610 rtems_rfs_ino ino);
611
626 rtems_rfs_ino ino,
628 bool load);
629
640 rtems_rfs_inode_handle* handle);
641
652 rtems_rfs_inode_handle* handle);
653
666 bool update_ctime);
667
679 rtems_rfs_ino parent,
680 const char* name,
681 size_t length,
682 uint16_t mode,
683 uint16_t links,
684 uid_t uid,
685 gid_t gid,
686 rtems_rfs_ino* ino);
687
699 rtems_rfs_inode_handle* handle);
700
714 uint16_t links,
715 uint16_t mode,
716 uid_t uid,
717 gid_t gid);
718
732 bool atime,
733 bool mtime);
734
744 rtems_rfs_inode_handle* handle);
745
746#endif
747
int32_t rtems_rfs_bitmap_bit
Definition: rtems-rfs-bitmaps.h:103
uint32_t rtems_rfs_buffer_block
Definition: rtems-rfs-buffer.h:81
#define rtems_rfs_buffer_mark_dirty(_h)
Definition: rtems-rfs-buffer.h:163
RTEMS File System Data.
#define rtems_rfs_write_u32(_d, _v)
Definition: rtems-rfs-data.h:100
#define rtems_rfs_read_u16(_d)
Definition: rtems-rfs-data.h:69
#define rtems_rfs_write_u16(_d, _v)
Definition: rtems-rfs-data.h:91
#define rtems_rfs_read_u32(_d)
Definition: rtems-rfs-data.h:76
RTEMS File System Data.
#define RTEMS_RFS_INODE_BLOCKS
Definition: rtems-rfs-file-system.h:86
uint64_t rtems_rfs_pos
Definition: rtems-rfs-file-system.h:109
struct _rtems_rfs_inode_handle rtems_rfs_inode_handle
int rtems_rfs_inode_alloc(rtems_rfs_file_system *fs, rtems_rfs_bitmap_bit goal, rtems_rfs_ino *ino)
Definition: rtems-rfs-inode.c:51
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:72
int rtems_rfs_inode_delete(rtems_rfs_file_system *fs, rtems_rfs_inode_handle *handle)
Definition: rtems-rfs-inode.c:339
int rtems_rfs_inode_close(rtems_rfs_file_system *fs, rtems_rfs_inode_handle *handle)
Definition: rtems-rfs-inode.c:110
int rtems_rfs_inode_free(rtems_rfs_file_system *fs, rtems_rfs_ino ino)
Definition: rtems-rfs-inode.c:63
uint32_t rtems_rfs_time
Definition: rtems-rfs-inode.h:102
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:392
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:198
uint32_t rtems_rfs_inode_block
Definition: rtems-rfs-inode.h:108
#define RTEMS_RFS_INODE_DATA_NAME_SIZE
Definition: rtems-rfs-inode.h:113
struct _rtems_rfs_inode rtems_rfs_inode
int rtems_rfs_inode_load(rtems_rfs_file_system *fs, rtems_rfs_inode_handle *handle)
Definition: rtems-rfs-inode.c:133
rtems_rfs_pos rtems_rfs_inode_get_size(rtems_rfs_file_system *fs, rtems_rfs_inode_handle *handle)
Definition: rtems-rfs-inode.c:429
int rtems_rfs_inode_unload(rtems_rfs_file_system *fs, rtems_rfs_inode_handle *handle, bool update_ctime)
Definition: rtems-rfs-inode.c:164
int rtems_rfs_inode_time_stamp_now(rtems_rfs_inode_handle *handle, bool atime, bool mtime)
Definition: rtems-rfs-inode.c:413
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-system.h:135
Definition: rtems-rfs-inode.h:201
rtems_rfs_buffer_block block
Definition: rtems-rfs-inode.h:225
int offset
Definition: rtems-rfs-inode.h:230
int loads
Definition: rtems-rfs-inode.h:235
rtems_rfs_ino ino
Definition: rtems-rfs-inode.h:210
rtems_rfs_buffer_handle buffer
Definition: rtems-rfs-inode.h:220
rtems_chain_node link
Definition: rtems-rfs-inode.h:205
rtems_rfs_inode * node
Definition: rtems-rfs-inode.h:215
Definition: rtems-rfs-inode.h:120
uint16_t mode
Definition: rtems-rfs-inode.h:129
uint32_t block_count
Definition: rtems-rfs-inode.h:149
union _rtems_rfs_inode::@4398 data
uint16_t block_offset
Definition: rtems-rfs-inode.h:144
uint16_t links
Definition: rtems-rfs-inode.h:124
uint16_t flags
Definition: rtems-rfs-inode.h:139
rtems_rfs_inode_block last_map_block
Definition: rtems-rfs-inode.h:183
uint32_t owner
Definition: rtems-rfs-inode.h:134
rtems_rfs_time mtime
Definition: rtems-rfs-inode.h:159
rtems_rfs_time ctime
Definition: rtems-rfs-inode.h:164
rtems_rfs_inode_block last_data_block
Definition: rtems-rfs-inode.h:188
rtems_rfs_time atime
Definition: rtems-rfs-inode.h:154
Definition: rtems-rfs-buffer.h:111