From a9fa9b765df38cc5319ae734b5148fd47ebbfd8d Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Thu, 18 Feb 2010 00:24:25 +0000 Subject: 2010-02-18 Chris Johns * libfs/src/rfs/rtems-rfs-bitmaps.c, libfs/src/rfs/rtems-rfs-bitmaps.h, libfs/src/rfs/rtems-rfs-bitmaps-ut.c, libfs/src/rfs/rtems-rfs-block.c, libfs/src/rfs/rtems-rfs-block.h, libfs/src/rfs/rtems-rfs-block-pos.h, libfs/src/rfs/rtems-rfs-buffer-bdbuf.c, libfs/src/rfs/rtems-rfs-buffer.c, libfs/src/rfs/rtems-rfs-buffer-devio.c, libfs/src/rfs/rtems-rfs-buffer.h, libfs/src/rfs/rtems-rfs-data.h, libfs/src/rfs/rtems-rfs-dir.c, libfs/src/rfs/rtems-rfs-dir.h, libfs/src/rfs/rtems-rfs-dir-hash.c, libfs/src/rfs/rtems-rfs-dir-hash.h, libfs/src/rfs/rtems-rfs-file.c, libfs/src/rfs/rtems-rfs-file.h, libfs/src/rfs/rtems-rfs-file-system.c, libfs/src/rfs/rtems-rfs-file-system-fwd.h, libfs/src/rfs/rtems-rfs-file-system.h, libfs/src/rfs/rtems-rfs-format.c, libfs/src/rfs/rtems-rfs-format.h, libfs/src/rfs/rtems-rfs-group.c, libfs/src/rfs/rtems-rfs-group.h, libfs/src/rfs/rtems-rfs.h, libfs/src/rfs/rtems-rfs-inode.c, libfs/src/rfs/rtems-rfs-inode.h, libfs/src/rfs/rtems-rfs-link.c, libfs/src/rfs/rtems-rfs-link.h, libfs/src/rfs/rtems-rfs-mutex.c, libfs/src/rfs/rtems-rfs-mutex.h, libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems-dev.c, libfs/src/rfs/rtems-rfs-rtems-dir.c, libfs/src/rfs/rtems-rfs-rtems-file.c, libfs/src/rfs/rtems-rfs-rtems.h, libfs/src/rfs/rtems-rfs-rtems-utils.c, libfs/src/rfs/rtems-rfs-shell.c, libfs/src/rfs/rtems-rfs-shell.h, libfs/src/rfs/rtems-rfs-trace.c, libfs/src/rfs/rtems-rfs-trace.h: New. * Makefile.am, preinstall.am, libfs/Makefile.am, wrapup/Makefile.am: Updated with the RFS support. * libfs/README: Updated after 10 years. * libblock/src/flashdisk.c, libblock/src/nvdisk.c, libblock/src/ramdisk-driver.c: Updated to the new error reporting in libblock. * libmisc/shell/main_ls.c, libmisc/shell/print-ls.c: Fix printing the size in long mode. * libnetworking/nfs/bootp_subr.c, libnetworking/rtems/rtems_bootp.c, libnetworking/rtems/rtems_bsdnet_internal.h: Return the BOOTP/DHCP to the forever behaviour of 4.9 with the ability to call BOOTP and control the process if required. --- cpukit/libfs/src/rfs/rtems-rfs-group.h | 151 +++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 cpukit/libfs/src/rfs/rtems-rfs-group.h (limited to 'cpukit/libfs/src/rfs/rtems-rfs-group.h') diff --git a/cpukit/libfs/src/rfs/rtems-rfs-group.h b/cpukit/libfs/src/rfs/rtems-rfs-group.h new file mode 100644 index 0000000000..3adf736e2f --- /dev/null +++ b/cpukit/libfs/src/rfs/rtems-rfs-group.h @@ -0,0 +1,151 @@ +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ +/** + * @file + * + * @ingroup rtems-rfs + * + * RTEMS File Systems Group Management. + * + * These functions manage the groups used in the file system. + */ + +#if !defined (_RTEMS_RFS_GROUP_H_) +#define _RTEMS_RFS_GROUP_H_ + +#include +#include +#include + +/** + * Block allocations for a group on disk. + */ +#define RTEMS_RFS_GROUP_BLOCK_BITMAP_BLOCK (0) +#define RTEMS_RFS_GROUP_INODE_BITMAP_BLOCK (1) +#define RTEMS_RFS_GROUP_INODE_BLOCK (2) + +/** + * A group is a selection of blocks on the disk. Typically the number of blocks + * in a group is determined by the number of bits a block holds. This makes the + * bit allocator for blocks in the group simpler plus is allows a simple way to + * localise access to files and directories. + */ +typedef struct rtems_rfs_group_t +{ + /** + * Base block number. + */ + rtems_rfs_buffer_block base; + + /** + * The number of blocks in the group. Groups may be different sizes. + */ + size_t size; + + /** + * The block bitmap control. + */ + rtems_rfs_bitmap_control block_bitmap; + + /** + * The handle to the block bitmap buffer. + */ + rtems_rfs_buffer_handle block_bitmap_buffer; + + /** + * The inode bitmap control. + */ + rtems_rfs_bitmap_control inode_bitmap; + + /** + * The handle to the inode bitmap buffer. + */ + rtems_rfs_buffer_handle inode_bitmap_buffer; + +} rtems_rfs_group; + +/** + * Return the disk's block for a block in a group. + */ +#define rtems_rfs_group_block(_g, _b) (((_g)->base) + (_b)) + +/** + * Return the file system inode for a inode in a group. + */ +#define rtems_rfs_group_inode(_f, _g, _i) \ + (((_f)->group_inodes * (_g)) + (_i) + RTEMS_RFS_ROOT_INO) + +/** + * Open a group. Allocate all the resources including the bitmaps. + * + * @param fs The file system. + * @param base The base block number. + * @param size The number of blocks in the group. + * @param group Reference to the group to open. + * @return int The error number (errno). No error if 0. + */ +int rtems_rfs_group_open (rtems_rfs_file_system* fs, + rtems_rfs_buffer_block base, + size_t size, + size_t inodes, + rtems_rfs_group* group); + +/** + * Close a group. Release all resources the group holds. + * + * @param fs The file system. + * @param group The group to close. + * @return int The error number (errno). No error if 0. + */ +int rtems_rfs_group_close (rtems_rfs_file_system* fs, + rtems_rfs_group* group); + +/** + * Allocate an inode or block. The groups are searched to find the next + * available inode or block. + * + * @param fs The file system data. + * @param goal The goal to seed the bitmap search. + * @param inode If true allocate an inode else allocate a block. + * @param result The allocated bit in the bitmap. + * @return int The error number (errno). No error if 0. + */ +int rtems_rfs_group_bitmap_alloc (rtems_rfs_file_system* fs, + rtems_rfs_bitmap_bit goal, + bool inode, + rtems_rfs_bitmap_bit* result); + +/** + * Free the group allocated bit. + * + * @param fs The file system data. + * @param inode If true the number to free is an inode else it is a block. + * @prarm block The inode or block number to free. + * @return int The error number (errno). No error if 0. + */ +int rtems_rfs_group_bitmap_free (rtems_rfs_file_system* fs, + bool inode, + rtems_rfs_bitmap_bit no); + +/** + * Test the group allocated bit. + * + * @param fs The file system data. + * @param inode If true the number to free is an inode else it is a block. + * @prarm block The inode or block number to free. + * @prarm state Return the state of the bit. + * @return int The error number (errno). No error if 0. + */ +int rtems_rfs_group_bitmap_test (rtems_rfs_file_system* fs, + bool inode, + rtems_rfs_bitmap_bit no, + bool* state); + +#endif -- cgit v1.2.3