![]() |
|
|||
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 Systems Group Management 0007 * 0008 * @ingroup rtems_rfs 0009 * 0010 * RTEMS File Systems Group Management. 0011 * 0012 * These functions manage the groups used 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_GROUP_H_) 0042 #define _RTEMS_RFS_GROUP_H_ 0043 0044 /** 0045 * @ingroup rtems_rfs 0046 * 0047 * RTEMS File System Group Management 0048 */ 0049 /**@{*/ 0050 0051 #include <rtems/rfs/rtems-rfs-trace.h> 0052 #include <rtems/rfs/rtems-rfs-bitmaps.h> 0053 #include <rtems/rfs/rtems-rfs-buffer.h> 0054 0055 /** 0056 * Block allocations for a group on disk. 0057 */ 0058 #define RTEMS_RFS_GROUP_BLOCK_BITMAP_BLOCK (0) 0059 #define RTEMS_RFS_GROUP_INODE_BITMAP_BLOCK (1) 0060 #define RTEMS_RFS_GROUP_INODE_BLOCK (2) 0061 0062 /** 0063 * @brief Creates bit allocator for blocks in the group simpler. 0064 * 0065 * A group is a selection of blocks on the disk. Typically the number of blocks 0066 * in a group is determined by the number of bits a block holds. This makes the 0067 * bit allocator for blocks in the group simpler plus is allows a simple way to 0068 * localise access to files and directories. 0069 */ 0070 typedef struct _rtems_rfs_group 0071 { 0072 /** 0073 * Base block number. 0074 */ 0075 rtems_rfs_buffer_block base; 0076 0077 /** 0078 * The number of blocks in the group. Groups may be different sizes. 0079 */ 0080 size_t size; 0081 0082 /** 0083 * The block bitmap control. 0084 */ 0085 rtems_rfs_bitmap_control block_bitmap; 0086 0087 /** 0088 * The handle to the block bitmap buffer. 0089 */ 0090 rtems_rfs_buffer_handle block_bitmap_buffer; 0091 0092 /** 0093 * The inode bitmap control. 0094 */ 0095 rtems_rfs_bitmap_control inode_bitmap; 0096 0097 /** 0098 * The handle to the inode bitmap buffer. 0099 */ 0100 rtems_rfs_buffer_handle inode_bitmap_buffer; 0101 0102 } rtems_rfs_group; 0103 0104 /** 0105 * Return the disk's block for a block in a group. 0106 */ 0107 #define rtems_rfs_group_block(_g, _b) (((_g)->base) + (_b)) 0108 0109 /** 0110 * Return the file system inode for a inode in a group. 0111 */ 0112 #define rtems_rfs_group_inode(_f, _g, _i) \ 0113 (((_f)->group_inodes * (_g)) + (_i) + RTEMS_RFS_ROOT_INO) 0114 0115 /** 0116 * @brief Open a group. 0117 * 0118 * Allocate all the resources including the bitmaps. 0119 * 0120 * @param fs The file system. 0121 * @param base The base block number. 0122 * @param size The number of blocks in the group. 0123 * @param group Reference to the group to open. 0124 * @retval int The error number (errno). No error if 0. 0125 */ 0126 int rtems_rfs_group_open (rtems_rfs_file_system* fs, 0127 rtems_rfs_buffer_block base, 0128 size_t size, 0129 size_t inodes, 0130 rtems_rfs_group* group); 0131 0132 /** 0133 * @brief Close a group. 0134 * 0135 * Release all resources the group holds. 0136 * 0137 * @param fs The file system. 0138 * @param group The group to close. 0139 * @retval int The error number (errno). No error if 0. 0140 */ 0141 int rtems_rfs_group_close (rtems_rfs_file_system* fs, 0142 rtems_rfs_group* group); 0143 0144 /** 0145 * @brief Allocate an inode or block. 0146 * 0147 * The groups are searched to find the next 0148 * available inode or block. 0149 * 0150 * @param fs The file system data. 0151 * @param goal The goal to seed the bitmap search. 0152 * @param inode If true allocate an inode else allocate a block. 0153 * @param result The allocated bit in the bitmap. 0154 * @retval int The error number (errno). No error if 0. 0155 */ 0156 int rtems_rfs_group_bitmap_alloc (rtems_rfs_file_system* fs, 0157 rtems_rfs_bitmap_bit goal, 0158 bool inode, 0159 rtems_rfs_bitmap_bit* result); 0160 0161 /** 0162 * @brief Free the group allocated bit. 0163 * 0164 * @param fs The file system data. 0165 * @param inode If true the number to free is an inode else it is a block. 0166 * @param block The inode or block number to free. 0167 * @retval int The error number (errno). No error if 0. 0168 */ 0169 int rtems_rfs_group_bitmap_free (rtems_rfs_file_system* fs, 0170 bool inode, 0171 rtems_rfs_bitmap_bit no); 0172 0173 /** 0174 * @brief Test the group allocated bit. 0175 * 0176 * @param fs The file system data. 0177 * @param inode If true the number to free is an inode else it is a block. 0178 * @param block The inode or block number to free. 0179 * @param state Return the state of the bit. 0180 * @retval int The error number (errno). No error if 0. 0181 */ 0182 int rtems_rfs_group_bitmap_test (rtems_rfs_file_system* fs, 0183 bool inode, 0184 rtems_rfs_bitmap_bit no, 0185 bool* state); 0186 0187 /** 0188 * @brief Determine the number of blocks and inodes used. 0189 * 0190 * @param fs The file system data. 0191 * @param blocks The number of blocks used. 0192 * @param inodes The number of inodes used. 0193 * @retval int The error number (errno). No error if 0. 0194 */ 0195 int rtems_rfs_group_usage (rtems_rfs_file_system* fs, 0196 size_t* blocks, 0197 size_t* inodes); 0198 0199 /** @} */ 0200 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |