Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:12

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @brief RTEMS File System Information Node
0007  *
0008  * @ingroup rtems_rfs
0009  *
0010  * RTEMS File System Information Node.
0011  *
0012  * The information nodes hold the data about all nodes in the file system.
0013  */
0014 
0015 /*
0016  *  COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
0017  *
0018  * Redistribution and use in source and binary forms, with or without
0019  * modification, are permitted provided that the following conditions
0020  * are met:
0021  * 1. Redistributions of source code must retain the above copyright
0022  *    notice, this list of conditions and the following disclaimer.
0023  * 2. Redistributions in binary form must reproduce the above copyright
0024  *    notice, this list of conditions and the following disclaimer in the
0025  *    documentation and/or other materials provided with the distribution.
0026  *
0027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0037  * POSSIBILITY OF SUCH DAMAGE.
0038  */
0039 
0040 
0041 #if !defined (_RTEMS_RFS_INODE_H_)
0042 #define _RTEMS_RFS_INODE_H_
0043 
0044 #include <sys/stat.h>
0045 
0046 #include <rtems/rfs/rtems-rfs-data.h>
0047 #include <rtems/rfs/rtems-rfs-file-system.h>
0048 
0049 /**
0050  * The RFS mode definitions. Currently map to the C library ones.
0051  */
0052 #define RTEMS_RFS_S_ISUID  S_ISUID  /**< Set user id on execution */
0053 #define RTEMS_RFS_S_ISGID  S_ISGID  /**< Set group id on execution */
0054 #define RTEMS_RFS_S_ISVTX  S_ISVTX  /**< Save swapped text even after use */
0055 #define RTEMS_RFS_S_IREAD  S_IREAD  /**< Read permission, owner */
0056 #define RTEMS_RFS_S_IWRITE S_IWRITE /**< Write permission, owner */
0057 #define RTEMS_RFS_S_IEXEC  S_IEXEC  /**< Execute/search permission, owner */
0058 #define RTEMS_RFS_S_ENFMT  S_ENFMT  /**< Enforcement-mode locking */
0059 #define RTEMS_RFS_S_IFMT   S_IFMT   /**< Type of file */
0060 #define RTEMS_RFS_S_IFDIR  S_IFDIR  /**< Directory */
0061 #define RTEMS_RFS_S_IFCHR  S_IFCHR  /**< Character special */
0062 #define RTEMS_RFS_S_IFBLK  S_IFBLK  /**< Block special */
0063 #define RTEMS_RFS_S_IFREG  S_IFREG  /**< Regular */
0064 #define RTEMS_RFS_S_IFLNK  S_IFLNK  /**< Symbolic link */
0065 #define RTEMS_RFS_S_IFSOCK S_IFSOCK /**< Socket */
0066 #define RTEMS_RFS_S_IFIFO  S_IFIFO  /**< Fifo */
0067 #define RTEMS_RFS_S_IRWXU  S_IRWXU
0068 #define RTEMS_RFS_S_IRUSR  S_IRUSR  /**< Read permission, owner */
0069 #define RTEMS_RFS_S_IWUSR  S_IWUSR  /**< Write permission, owner */
0070 #define RTEMS_RFS_S_IXUSR  S_IXUSR  /**< Execute/search permission, owner */
0071 #define RTEMS_RFS_S_IRWXG  S_IRWXG
0072 #define RTEMS_RFS_S_IRGRP  S_IRGRP  /**< Read permission, group */
0073 #define RTEMS_RFS_S_IWGRP  S_IWGRP  /**< Write permission, grougroup */
0074 #define RTEMS_RFS_S_IXGRP  S_IXGRP  /**< Execute/search permission, group */
0075 #define RTEMS_RFS_S_IRWXO  S_IRWXO
0076 #define RTEMS_RFS_S_IROTH  S_IROTH  /**< Read permission, other */
0077 #define RTEMS_RFS_S_IWOTH  S_IWOTH  /**< Write permission, other */
0078 #define RTEMS_RFS_S_IXOTH  S_IXOTH  /**< Execute/search permission, other */
0079 
0080 #define RTEMS_RFS_S_ISBLK(m)  S_ISBLK(m)
0081 #define RTEMS_RFS_S_ISCHR(m)  S_ISCHR(m)
0082 #define RTEMS_RFS_S_ISDIR(m)  S_ISDIR(m)
0083 #define RTEMS_RFS_S_ISFIFO(m) S_ISFIFO(m)
0084 #define RTEMS_RFS_S_ISREG(m)  S_ISREG(m)
0085 #define RTEMS_RFS_S_ISLNK(m)  S_ISLNK(m)
0086 #define RTEMS_RFS_S_ISSOCK(m) S_ISSOCK(m)
0087 
0088 /**
0089  * Permissions of a symlink.
0090  */
0091 #define RTEMS_RFS_S_SYMLINK \
0092   RTEMS_RFS_S_IFLNK | RTEMS_RFS_S_IRWXU | RTEMS_RFS_S_IRWXG | RTEMS_RFS_S_IRWXO
0093 
0094 /**
0095  * The inode number or ino.
0096  */
0097 typedef uint32_t rtems_rfs_ino;
0098 
0099 /**
0100  * The time in the file system.
0101  */
0102 typedef uint32_t rtems_rfs_time;
0103 
0104 /**
0105  * The size of a block value on disk. This include the inodes and indirect
0106  * tables.
0107  */
0108 typedef uint32_t rtems_rfs_inode_block;
0109 
0110 /**
0111  * The size of the data name field in the inode.
0112  */
0113 #define RTEMS_RFS_INODE_DATA_NAME_SIZE \
0114   (RTEMS_RFS_INODE_BLOCKS * sizeof (rtems_rfs_inode_block))
0115 
0116 /**
0117  * The inode.
0118  */
0119 typedef struct _rtems_rfs_inode
0120 {
0121   /**
0122    * The number of links to the inode.
0123    */
0124   uint16_t links;
0125 
0126   /**
0127    * The mode of the node.
0128    */
0129   uint16_t mode;
0130 
0131   /**
0132    * The owner of the node.
0133    */
0134   uint32_t owner;
0135 
0136   /**
0137    * Reserved.
0138    */
0139   uint16_t flags;
0140 
0141   /**
0142    * Amount of data held in the last block data.
0143    */
0144   uint16_t block_offset;
0145 
0146   /**
0147    * Number of blocks held by this file.
0148    */
0149   uint32_t block_count;
0150 
0151   /**
0152    * The access time. The last time the file was read.
0153    */
0154   rtems_rfs_time atime;
0155 
0156   /**
0157    * The modified time. The last time the file was written too.
0158    */
0159   rtems_rfs_time mtime;
0160 
0161   /**
0162    * The change time. The last time the inode was written too.
0163    */
0164   rtems_rfs_time ctime;
0165 
0166   /**
0167    * Blocks. These are the block numbers used by the node or table of
0168    * nodes. The flags indicate the mode the blocks are being held in. In the
0169    * direct table mode the blocks are entries in this table. In the indirect
0170    * mode the blocks point to blocks that hold the block numbers. The data can
0171    * also be a name if it fits. For example a symbolic link.
0172    */
0173   union
0174   {
0175     rtems_rfs_inode_block blocks[RTEMS_RFS_INODE_BLOCKS];
0176     uint8_t               name[RTEMS_RFS_INODE_DATA_NAME_SIZE];
0177   } data;
0178 
0179   /**
0180    * The last block map block. Used as the goal when allocating a new block for
0181    * use in the map.
0182    */
0183   rtems_rfs_inode_block last_map_block;
0184 
0185   /**
0186    * The last data block. Used as the goal when allocating a new block.
0187    */
0188   rtems_rfs_inode_block last_data_block;
0189 
0190 } rtems_rfs_inode;
0191 
0192 /**
0193  * The size of an inode.
0194  */
0195 #define RTEMS_RFS_INODE_SIZE (sizeof (rtems_rfs_inode))
0196 
0197 /**
0198  * RFS Inode Handle.
0199  */
0200 typedef struct _rtems_rfs_inode_handle
0201 {
0202   /**
0203    * Handles can be linked as a list for easy processing.
0204    */
0205   rtems_chain_node link;
0206 
0207   /**
0208    * The ino for this handle.
0209    */
0210   rtems_rfs_ino ino;
0211 
0212   /**
0213    * The pointer to the inode.
0214    */
0215   rtems_rfs_inode* node;
0216 
0217   /**
0218    * The buffer that contains this inode.
0219    */
0220   rtems_rfs_buffer_handle buffer;
0221 
0222   /**
0223    * The block number that holds the inode.
0224    */
0225   rtems_rfs_buffer_block block;
0226 
0227   /**
0228    * The offset into the block for the inode.
0229    */
0230   int offset;
0231 
0232   /**
0233    * Number of load requests.
0234    */
0235   int loads;
0236 
0237 } rtems_rfs_inode_handle;
0238 
0239 /**
0240  * Is the inode loaded ?
0241  */
0242 #define rtems_rfs_inode_is_loaded(_h) ((_h)->node)
0243 
0244 /**
0245  * Get the inode ino for a handle.
0246  */
0247 #define rtems_rfs_inode_ino(_h) ((_h)->ino)
0248 
0249 /**
0250  * Get the link count.
0251  *
0252  * @param[in] handle is the inode handle.
0253  *
0254  * @retval links The link count.
0255  */
0256 static inline uint16_t
0257 rtems_rfs_inode_get_links (rtems_rfs_inode_handle* handle)
0258 {
0259   uint16_t links;
0260   links = rtems_rfs_read_u16 (&handle->node->links);
0261   if (links == 0xffff)
0262     links = 0;
0263   return links;
0264 }
0265 
0266 /**
0267  * Set the link count.
0268  *
0269  * @param[in] handle is the inode handle.
0270  * @param[in] links are the links.
0271  */
0272 static inline void
0273 rtems_rfs_inode_set_links (rtems_rfs_inode_handle* handle, uint16_t links)
0274 {
0275   rtems_rfs_write_u16 (&handle->node->links, links);
0276   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0277 }
0278 
0279 /**
0280  * Get the flags.
0281  *
0282  * @param[in] handle is the inode handle.
0283  *
0284  * @retval flags The flags.
0285  */
0286 static inline uint16_t
0287 rtems_rfs_inode_get_flags (rtems_rfs_inode_handle* handle)
0288 {
0289   return rtems_rfs_read_u16 (&handle->node->flags);
0290 }
0291 
0292 /**
0293  * Set the flags.
0294  *
0295  * @param[in] handle is the inode handle.
0296  * @param[in] flags are the flags.
0297  */
0298 static inline void
0299 rtems_rfs_inode_set_flags (rtems_rfs_inode_handle* handle, uint16_t flags)
0300 {
0301   rtems_rfs_write_u16 (&handle->node->flags, flags);
0302   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0303 }
0304 
0305 /**
0306  * Get the mode.
0307  *
0308  * @param[in] handle is the inode handle.
0309  *
0310  * @retval mode The mode.
0311  */
0312 static inline uint16_t
0313 rtems_rfs_inode_get_mode (rtems_rfs_inode_handle* handle)
0314 {
0315   return rtems_rfs_read_u16 (&handle->node->mode);
0316 }
0317 
0318 /**
0319  * Set the mode.
0320  *
0321  * @param[in] handle is the inode handle.
0322  * @param[in] mode is the mode.
0323  */
0324 static inline void
0325 rtems_rfs_inode_set_mode (rtems_rfs_inode_handle* handle, uint16_t mode)
0326 {
0327   rtems_rfs_write_u16 (&handle->node->mode, mode);
0328   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0329 }
0330 
0331 /**
0332  * Get the user id.
0333  *
0334  * @param[in] handle is the inode handle.
0335  *
0336  * @retval uid The used id.
0337  */
0338 static inline uint16_t
0339 rtems_rfs_inode_get_uid (rtems_rfs_inode_handle* handle)
0340 {
0341   return rtems_rfs_read_u32 (&handle->node->owner) & 0xffff;
0342 }
0343 
0344 /**
0345  * Get the group id.
0346  *
0347  * @param[in] handle is the inode handle.
0348  *
0349  * @retval gid The grpup id.
0350  */
0351 static inline uint16_t
0352 rtems_rfs_inode_get_gid (rtems_rfs_inode_handle* handle)
0353 {
0354   return (rtems_rfs_read_u32 (&handle->node->owner) >> 16) & 0xffff;
0355 }
0356 
0357 /**
0358  * Set the user id and group id.
0359  *
0360  * @param[in] handle is the inode handle.
0361  * @param[in] uid is the user id (uid).
0362  * @param[in] gid is the group id (gid).
0363  */
0364 static inline void
0365 rtems_rfs_inode_set_uid_gid (rtems_rfs_inode_handle* handle,
0366                              uint16_t uid, uint16_t gid)
0367 {
0368   rtems_rfs_write_u32 (&handle->node->owner, (((uint32_t) gid) << 16) | uid);
0369   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0370 }
0371 
0372 /**
0373  * Get the block offset.
0374  *
0375  * @param[in] handle is the inode handle.
0376  *
0377  * @retval offset The block offset.
0378  */
0379 static inline uint16_t
0380 rtems_rfs_inode_get_block_offset (rtems_rfs_inode_handle* handle)
0381 {
0382   return rtems_rfs_read_u16 (&handle->node->block_offset);
0383 }
0384 
0385 /**
0386  * Set the block offset.
0387  *
0388  * @param[in] handle is the inode handle.
0389  * @param[in] block_count is the block offset.
0390  */
0391 static inline void
0392 rtems_rfs_inode_set_block_offset (rtems_rfs_inode_handle* handle,
0393                                   uint16_t                block_offset)
0394 {
0395   rtems_rfs_write_u16 (&handle->node->block_offset, block_offset);
0396   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0397 }
0398 
0399 /**
0400  * Get the block count.
0401  *
0402  * @param[in] handle is the inode handle.
0403  *
0404  * @retval count The block count.
0405  */
0406 static inline uint32_t
0407 rtems_rfs_inode_get_block_count (rtems_rfs_inode_handle* handle)
0408 {
0409   return rtems_rfs_read_u32 (&handle->node->block_count);
0410 }
0411 
0412 /**
0413  * Set the block count.
0414  *
0415  * @param[in] handle is the inode handle.
0416  * @param[in] block_count is the block count.
0417  */
0418 static inline void
0419 rtems_rfs_inode_set_block_count (rtems_rfs_inode_handle* handle, uint32_t block_count)
0420 {
0421   rtems_rfs_write_u32 (&handle->node->block_count, block_count);
0422   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0423 }
0424 
0425 /**
0426  * Get the atime.
0427  *
0428  * @param[in] handle is the inode handle.
0429  *
0430  * @retval atime The atime.
0431  */
0432 static inline rtems_rfs_time
0433 rtems_rfs_inode_get_atime (rtems_rfs_inode_handle* handle)
0434 {
0435   return rtems_rfs_read_u32 (&handle->node->atime);
0436 }
0437 
0438 /**
0439  * Set the atime.
0440  *
0441  * @param[in] handle is the inode handle.
0442  * @param[in] atime The atime.
0443  */
0444 static inline void
0445 rtems_rfs_inode_set_atime (rtems_rfs_inode_handle* handle,
0446                            rtems_rfs_time          atime)
0447 {
0448   rtems_rfs_write_u32 (&handle->node->atime, atime);
0449   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0450 }
0451 
0452 /**
0453  * Get the mtime.
0454  *
0455  * @param[in] handle is the inode handle.
0456  *
0457  * @retval mtime The mtime.
0458  */
0459 static inline rtems_rfs_time
0460 rtems_rfs_inode_get_mtime (rtems_rfs_inode_handle* handle)
0461 {
0462   return rtems_rfs_read_u32 (&handle->node->mtime);
0463 }
0464 
0465 /**
0466  * Set the mtime.
0467  *
0468  * @param[in] handle is the inode handle.
0469  * @param[in] mtime The mtime.
0470  */
0471 static inline void
0472 rtems_rfs_inode_set_mtime (rtems_rfs_inode_handle* handle,
0473                            rtems_rfs_time          mtime)
0474 {
0475   rtems_rfs_write_u32 (&handle->node->mtime, mtime);
0476   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0477 }
0478 
0479 /**
0480  * Get the ctime.
0481  *
0482  * @param[in] handle is the inode handle.
0483  *
0484  * @retval ctime The ctime.
0485  */
0486 static inline rtems_rfs_time
0487 rtems_rfs_inode_get_ctime (rtems_rfs_inode_handle* handle)
0488 {
0489   return rtems_rfs_read_u32 (&handle->node->ctime);
0490 }
0491 
0492 /**
0493  * Set the ctime.
0494  *
0495  * @param[in] handle is the inode handle.
0496  * @param[in] ctime The ctime.
0497  */
0498 static inline void
0499 rtems_rfs_inode_set_ctime (rtems_rfs_inode_handle* handle,
0500                            rtems_rfs_time          ctime)
0501 {
0502   rtems_rfs_write_u32 (&handle->node->ctime, ctime);
0503   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0504 }
0505 
0506 /**
0507  * Get the block number.
0508  *
0509  * @param[in] handle is the inode handle.
0510  * @param[in] block is the block number to return.
0511  *
0512  * @retval block The block number.
0513  */
0514 static inline uint32_t
0515 rtems_rfs_inode_get_block (rtems_rfs_inode_handle* handle, int block)
0516 {
0517   return rtems_rfs_read_u32 (&handle->node->data.blocks[block]);
0518 }
0519 
0520 /**
0521  * Set the block number for a given block index.
0522  *
0523  * @param[in] handle is the inode handle.
0524  * @param[in] block is the block index.
0525  * @param[in] bno is the block number.
0526  */
0527 static inline void
0528 rtems_rfs_inode_set_block (rtems_rfs_inode_handle* handle, int block, uint32_t bno)
0529 {
0530   rtems_rfs_write_u32 (&handle->node->data.blocks[block], bno);
0531   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0532 }
0533 
0534 /**
0535  * Get the last map block from the inode.
0536  *
0537  * @param[in] handle is the inode handle.
0538  *
0539  * @retval block The last map block number.
0540  */
0541 static inline uint32_t
0542 rtems_rfs_inode_get_last_map_block (rtems_rfs_inode_handle* handle)
0543 {
0544   return rtems_rfs_read_u32 (&handle->node->last_map_block);
0545 }
0546 
0547 /**
0548  * Set the last map block.
0549  *
0550  * @param[in] handle is the inode handle.
0551  * @param[in] block_count is last map block number.
0552  */
0553 static inline void
0554 rtems_rfs_inode_set_last_map_block (rtems_rfs_inode_handle* handle, uint32_t last_map_block)
0555 {
0556   rtems_rfs_write_u32 (&handle->node->last_map_block, last_map_block);
0557   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0558 }
0559 
0560 /**
0561  * Get the last data block from the inode.
0562  *
0563  * @param[in] handle is the inode handle.
0564  *
0565  * @retval block The last data block number.
0566  *
0567  */
0568 static inline uint32_t
0569 rtems_rfs_inode_get_last_data_block (rtems_rfs_inode_handle* handle)
0570 {
0571   return rtems_rfs_read_u32 (&handle->node->last_data_block);
0572 }
0573 
0574 /**
0575  * Set the last data block.
0576  *
0577  * @param[in] handle is the inode handle.
0578  * @param[in] block_count is the last data block number.
0579  */
0580 static inline void
0581 rtems_rfs_inode_set_last_data_block (rtems_rfs_inode_handle* handle, uint32_t last_data_block)
0582 {
0583   rtems_rfs_write_u32 (&handle->node->last_data_block, last_data_block);
0584   rtems_rfs_buffer_mark_dirty (&handle->buffer);
0585 }
0586 
0587 /**
0588  * Allocate an inode number and return it.
0589  *
0590  * @param[in] fs is the file system data.
0591  * @param[out] ino will contain the ino.
0592  *
0593  * @retval 0 Successful operation.
0594  * @retval error_code An error occurred.
0595  */
0596 int rtems_rfs_inode_alloc (rtems_rfs_file_system* fs,
0597                            rtems_rfs_bitmap_bit   goal,
0598                            rtems_rfs_ino*         ino);
0599 
0600 /**
0601  * Free an inode.
0602  *
0603  * @param[in] fs is the file system data.
0604  * @param[in] ino is the ino too free.
0605  *
0606  * @retval 0 Successful operation.
0607  * @retval error_code An error occurred.
0608  */
0609 int rtems_rfs_inode_free (rtems_rfs_file_system* fs,
0610                           rtems_rfs_ino          ino);
0611 
0612 /**
0613  * Open the inode handle. This reads the inode into the buffer and sets the
0614  * data pointer. All data is in media byte order and needs to be accessed via
0615  * the supporting calls.
0616  *
0617  * @param[in] fs is the file system.
0618  * @param[in] ino is the inode number.
0619  * @param[in] handle is the handle to the inode we are opening.
0620  * @param[in] load If true load the inode into memory from the media.
0621  *
0622  * @retval 0 Successful operation.
0623  * @retval error_code An error occurred.
0624  */
0625 int rtems_rfs_inode_open (rtems_rfs_file_system*  fs,
0626                           rtems_rfs_ino           ino,
0627                           rtems_rfs_inode_handle* handle,
0628                           bool                    load);
0629 
0630 /**
0631  * The close inode handle. All opened inodes need to be closed.
0632  *
0633  * @param[in] fs is the file system.
0634  * @param[in] handle is the handle to close.
0635  *
0636  * @retval 0 Successful operation.
0637  * @retval error_code An error occurred.
0638  */
0639 int rtems_rfs_inode_close (rtems_rfs_file_system*  fs,
0640                            rtems_rfs_inode_handle* handle);
0641 
0642 /**
0643  * Load the inode into memory.
0644  *
0645  * @param[in] fs is the file system.
0646  * @param[in] handle is the inode handle to load.
0647  *
0648  * @retval 0 Successful operation.
0649  * @retval error_code An error occurred.
0650  */
0651 int rtems_rfs_inode_load (rtems_rfs_file_system*  fs,
0652                           rtems_rfs_inode_handle* handle);
0653 
0654 /**
0655  * Unload the inode from memory.
0656  *
0657  * @param[in] fs is the file system.
0658  * @param[in] handle is the inode handle to unload.
0659  * @param[in] update_ctime Update the ctime field of the inode.
0660  *
0661  * @retval 0 Successful operation.
0662  * @retval error_code An error occurred.
0663  */
0664 int rtems_rfs_inode_unload (rtems_rfs_file_system*  fs,
0665                             rtems_rfs_inode_handle* handle,
0666                             bool                    update_ctime);
0667 
0668 /**
0669  * Create an inode allocating, initialising and adding an entry to the parent
0670  * directory.
0671  *
0672  * @param[in] fs is the file system data.
0673  * @param[in] parent is the parent inode number to add the directory entry to.
0674  * @param[in] name is a pointer to the name of the directory entryinode
0675  *             to create.
0676  *
0677  */
0678 int rtems_rfs_inode_create (rtems_rfs_file_system*  fs,
0679                             rtems_rfs_ino           parent,
0680                             const char*             name,
0681                             size_t                  length,
0682                             uint16_t                mode,
0683                             uint16_t                links,
0684                             uid_t                   uid,
0685                             gid_t                   gid,
0686                             rtems_rfs_ino*          ino);
0687 
0688 /**
0689  * Delete the inode eraseing it and release the buffer to commit the write. You
0690  * need to load the inode again if you wish to use it again.
0691  *
0692  * @param[in] fs is the file system.
0693  * @param[in] handle is the inode handle to erase.
0694  *
0695  * @retval 0 Successful operation.
0696  * @retval error_code An error occurred.
0697  */
0698 int rtems_rfs_inode_delete (rtems_rfs_file_system*  fs,
0699                             rtems_rfs_inode_handle* handle);
0700 
0701 /**
0702  * Initialise a new inode.
0703  *
0704  * @param[in] handle is the inode handle to initialise.
0705  * @param[in] links are the number of links to the inode.
0706  * @param[in] mode is the inode mode.
0707  * @param[in] uid is the user id.
0708  * @param[in] gid is the group id.
0709  *
0710  * @retval 0 Successful operation.
0711  * @retval error_code An error occurred.
0712  */
0713 int rtems_rfs_inode_initialise (rtems_rfs_inode_handle* handle,
0714                                 uint16_t                links,
0715                                 uint16_t                mode,
0716                                 uid_t                   uid,
0717                                 gid_t                   gid);
0718 
0719 /**
0720  * Time stamp the inode with the current time. The ctime field is hanlded
0721  * automatically.
0722  *
0723  * @param[in] handle is the inode handle.
0724  * @param[in] atime Update the atime field.
0725  * @param[in] mtime UPdate the mtime field.
0726  *
0727  * @retval 0 Successful operation.
0728  * @retval ENXIO No inode is loaded.
0729  * @retval error_code An error occurred.
0730  */
0731 int rtems_rfs_inode_time_stamp_now (rtems_rfs_inode_handle* handle,
0732                                     bool                    atime,
0733                                     bool                    mtime);
0734 
0735 /**
0736  * Calculate the size of data attached to the inode.
0737  *
0738  * @param[in] fs is the file system data.
0739  * @param[in] handle is the inode handle.
0740  *
0741  * @retval size The data size in bytes in the block map attched to the inode.
0742  */
0743 rtems_rfs_pos rtems_rfs_inode_get_size (rtems_rfs_file_system*  fs,
0744                                         rtems_rfs_inode_handle* handle);
0745 
0746 #endif
0747