diff options
Diffstat (limited to 'cpukit/libfs')
28 files changed, 10 insertions, 6528 deletions
diff --git a/cpukit/libfs/Makefile.am b/cpukit/libfs/Makefile.am index 0985b2ffb4..a76fa8ae2d 100644 --- a/cpukit/libfs/Makefile.am +++ b/cpukit/libfs/Makefile.am @@ -112,6 +112,11 @@ librfs_a_SOURCES = \ # JFFS2 project_lib_LIBRARIES = libjffs2.a + +$(PROJECT_LIB)/libjffs2.a: libjffs2.a + $(INSTALL_DATA) $< $(PROJECT_LIB)/libjffs2.a +TMPINSTALL_FILES = $(PROJECT_LIB)/libjffs2.a + libjffs2_a_SOURCES = libjffs2_a_SOURCES += src/jffs2/src/build.c libjffs2_a_SOURCES += src/jffs2/src/compat-crc32.c @@ -139,6 +144,5 @@ libjffs2_a_CPPFLAGS += -D__ECOS libjffs2_a_CPPFLAGS += '-DKBUILD_MODNAME="JFFS2"' # --- -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/subdirs.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/libfs/preinstall.am b/cpukit/libfs/preinstall.am deleted file mode 100644 index 2aca1ef32f..0000000000 --- a/cpukit/libfs/preinstall.am +++ /dev/null @@ -1,24 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-local: $(TMPINSTALL_FILES) - -TMPINSTALL_FILES = -CLEANFILES = $(TMPINSTALL_FILES) - -$(PROJECT_LIB)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_LIB) - @: > $(PROJECT_LIB)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp) - -$(PROJECT_LIB)/libjffs2.a: libjffs2.a $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_LIB)/libjffs2.a -TMPINSTALL_FILES += $(PROJECT_LIB)/libjffs2.a - diff --git a/cpukit/libfs/src/devfs/devfs.h b/cpukit/libfs/src/devfs/devfs.h deleted file mode 100644 index b0a9197eca..0000000000 --- a/cpukit/libfs/src/devfs/devfs.h +++ /dev/null @@ -1,255 +0,0 @@ -/** -* @file -* -* @brief Device Only File System -* -* This include file contains all constants and structures associated -* with the 'device-only' filesystem. -*/ - -#ifndef _RTEMS_DEVFS_H -#define _RTEMS_DEVFS_H - -#include <rtems/libio_.h> - -/** - * @defgroup DevFsDeviceTable Device Only File System - * - * @ingroup FileSystemTypesAndMount - * - * @brief This structure defines the type of device table - */ -/**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Per Device Node Control Structure - * - * This structure is instanced per device node and contains all information - * used by this file system implementation to manage that device node. - */ -typedef struct { - /** This member points to device name which is not a null-terminated string */ - const char *name; - /** This member is the name length of a device */ - size_t namelen; - /** major number of a device */ - rtems_device_major_number major; - /** minor number of a device */ - rtems_device_minor_number minor; - /** device creation mode, only device file can be created */ - mode_t mode; -} devFS_node; - -typedef struct { - devFS_node *nodes; - size_t count; -} devFS_data; - -/** - * The following defines the device-only filesystem operating - * operations. - */ -extern const rtems_filesystem_operations_table devFS_ops; - -/** - * The following defines the device-only filesystem operating - * handlers. - */ -extern const rtems_filesystem_file_handlers_r devFS_file_handlers; - -/** - * @brief Obtain Immutable Pointer to Immutable File System Data - * - * This methods returns the immutable file system specific information - * associated with this file. - */ -static inline const devFS_data *devFS_get_data( - const rtems_filesystem_location_info_t *loc -) -{ - return (const devFS_data *) loc->mt_entry->immutable_fs_info; -} - -/** - * @brief Evaluate Path - */ -extern void devFS_eval_path( - rtems_filesystem_eval_path_context_t *ctx -); - -/** - * @brief Maps Open Operation to rtems_io_open - * - * This handler maps open operation to rtems_io_open. - * - * @param iop This is the RTEMS's internal representation of file. - * @param pathname a null-terminated string that starts with /dev. - * @param oflag access flags - * @param mode access mode - * - * @retval the same as open - */ -extern int devFS_open( - rtems_libio_t *iop, - const char *pathname, - int oflag, - mode_t mode -); - - -/** - * @brief Maps Close Operation to rtems_io_close - * - * This handler maps close operation to rtems_io_close. - * - * @param iop This is the RTEMS's internal representation of file - * - * @retval the same as close - */ -extern int devFS_close( - rtems_libio_t *iop -); - -/** - * @brief Maps Read Operation to rtems_io_read - * - * This handler maps read operation to rtems_io_read. - * - * @param iop This is the RTEMS's internal representation of file - * @param buffer memory location to store read data - * @param count how many bytes to read - * - * @retval On successful, this routine returns total bytes read. On error - * it returns -1 and errno is set to proper value. - */ -extern ssize_t devFS_read( - rtems_libio_t *iop, - void *buffer, - size_t count -); - -/** - * @brief Writes Operation to rtems_io_write - * - * This handler maps write operation to rtems_io_write. - * - * @param iop This is the RTEMS's internal representation of file - * @param buffer data to be written - * @param count how many bytes to write - * - * @retval On successful, this routine returns total bytes written. On error - * it returns -1 and errno is set to proper value. - */ -extern ssize_t devFS_write( - rtems_libio_t *iop, - const void *buffer, - size_t count -); - -/** - * @brief Maps ioctl Operation to rtems_io_ioctl - * - * This handler maps ioctl operation to rtems_io_ioctl. - * - * @param iop This is the RTEMS's internal representation of file - * @param command io control command - * @param buffer io control parameters - * - * @retval On successful, this routine returns total bytes written. On error - * it returns -1 and errno is set to proper value. - */ -extern int devFS_ioctl( - rtems_libio_t *iop, - ioctl_command_t command, - void *buffer -); - -/** - * @brief Gets the Device File Information - * - * This handler gets the device file information. This routine only - * set the following member of struct stat: - * - * - st_dev: device number - * - st_mode: device file creation mode, only two mode are accepted: - * + S_IFCHR: character device file - * + S_IFBLK: block device file - * - * @param loc contains filesystem access information - * @param buf buffer to hold the device file's information - * - * @retval On successful, this routine returns 0. On error - * it returns -1 and errno is set to proper value. - */ -extern int devFS_stat( - const rtems_filesystem_location_info_t *loc, - struct stat *buf -); - -/** - * @brief Creates an item in the main device table. - * - * This routine is invoked upon registration of a new device - * file. It is responsible for creating a item in the main - * device table. This routine searches the device table in - * sequential order, when found a empty slot, it fills the slot - * with proper values. - * - * @see rtems_filesystem_mknod_t. - */ -extern int devFS_mknod( - const rtems_filesystem_location_info_t *parentloc, - const char *name, - size_t namelen, - mode_t mode, - dev_t dev -); - -/** - * @brief Creates the Main Device Table - * - * This routine is invoked upon rtems filesystem initialization. - * It is responsible for creating the main device table, - * initializing it to a known state, and set device file operation - * handlers. After this, the device-only filesytem is ready for use - * - * @param mt_entry The filesystem mount table entry. - * @param data Filesystem specific data. - * - * @retval upon success, this routine returns 0; otherwise it returns - * -1 and errno is set to proper value. The only error is when malloc - * failed, and errno is set to NOMEM. - */ -extern int devFS_initialize( - rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data -); - -/** - * @brief Retrieves and Prints all the Device Registered in System - * - * This routine retrieves all the device registered in system, and - * prints out their detail information. For example, on one system, - * devFS_show will print out following message: - * - * @code - * /dev/console 0 0 - * /dev/clock 1 0 - * /dev/tty0 0 0 - * /flash 2 0 - * @endcode - * - * This routine is intended for debugging, and can be used by shell - * program to provide user with the system information. - */ -extern void devFS_Show(void); - -#ifdef __cplusplus -} -#endif -/**@}*/ -#endif - diff --git a/cpukit/libfs/src/dosfs/dosfs.h b/cpukit/libfs/src/dosfs/dosfs.h deleted file mode 100644 index 7691ed7e43..0000000000 --- a/cpukit/libfs/src/dosfs/dosfs.h +++ /dev/null @@ -1,433 +0,0 @@ -/** - * @file - * - * @brief Application Interface to FAT Filesystem - * - * @ingroup DOSFS - */ - -/* - * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia - * Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru> - * - * Modifications to support UTF-8 in the file system are - * Copyright (c) 2013 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_DOSFS_H -#define _RTEMS_DOSFS_H - -#include <rtems.h> -#include <rtems/libio.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rtems_dosfs_convert_control rtems_dosfs_convert_control; - -/** - * @brief Converts from UTF-8 into a specific code page. - * - * @param[in,out] self The convert control. - * @param[in] src A well-formed UTF-8 string to be converted. - * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). - * @param[out] dst The address the converted string will get copied to. - * @param[in,out] dst_size The size of the buffer in bytes respectively the - * number of bytes written to the buffer. - * - * @retval 0 Successful operation. - * @retval EINVAL Conversion was successful, but is not reversible. - * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). - */ -typedef int (*rtems_dosfs_utf8_to_codepage)( - rtems_dosfs_convert_control *self, - const uint8_t *src, - size_t src_size, - char *dst, - size_t *dst_size -); - -/** - * @brief Converts from a specific code page into UTF-8 - * - * @param[in,out] self The convert control. - * @param[in] src A well-formed string in code page format. - * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). - * @param[out] dst The address the converted string will get copied to. - * @param[in,out] dst_size The size of the buffer in bytes respectively the - * number of bytes written to the buffer. - * - * @retval 0 Successful operation. - * @retval EINVAL Conversion was successful, but is not reversible. - * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). - */ -typedef int (*rtems_dosfs_codepage_to_utf8)( - rtems_dosfs_convert_control *self, - const char *src, - size_t src_size, - uint8_t *dst, - size_t *dst_size -); - -/** - * @brief Converts from UTF-8 to UTF-16 - * - * @param[in,out] self The convert control. - * @param[in] src A well-formed UTF-8 string to be converted. - * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). - * @param[out] dst The address the converted string will get copied to - * @param[in,out] dst_size The size of the buffer in bytes respectively the - * number of bytes written to the buffer. - * - * @retval 0 Successful operation. - * @retval EINVAL Conversion was successful, but is not reversible. - * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). - */ -typedef int (*rtems_dosfs_utf8_to_utf16)( - rtems_dosfs_convert_control *self, - const uint8_t *src, - size_t src_size, - uint16_t *dst, - size_t *dst_size -); - -/** - * @brief Converts from UTF-16 to UTF-8. - * - * @param[in,out] self The convert control. - * @param[in] src A well-formed UTF-16 string to be converted. - * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). - * @param[out] dst The address the converted string will get copied to. - * @param[in,out] dst_size The size of the buffer in bytes respectively the - * number of bytes written to the buffer - * - * @retval 0 Successful operation. - * @retval EINVAL Conversion was successful, but is not reversible. - * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). - */ -typedef int (*rtems_dosfs_utf16_to_utf8)( - rtems_dosfs_convert_control *self, - const uint16_t *src, - size_t src_size, - uint8_t *dst, - size_t *dst_size -); - -/** - * @brief Converts from UTF-8 to Normalized Form Canonical Decomposition. - * - * Does canonical decomposition of the UTF-8 string and in addition - * also converts upper case alphabetic characters to lower case characters - * - * @param[in,out] self The convert control. - * @param[in] src A well-formed UTF-8 string to be normalized and fold. - * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). - * @param[out] dst The address the normalized and fold string will get - * copied to. - * @param[in,out] dst_size The size of the buffer in bytes respectively the - * number of bytes written to the buffer. - * - * @retval 0 Successful operation. - * @retval EINVAL Conversion failed. - * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). - * @retval EOVERFLOW Conversion failed. - * @retval ENOENT Conversion failed. - */ -typedef int (*rtems_dosfs_utf8_normalize_and_fold)( - rtems_dosfs_convert_control *self, - const uint8_t *src, - size_t src_size, - uint8_t *dst, - size_t *dst_size -); - -/** - * @brief Destroys a convert control structure. - * - * @param[in,out] self The convert control for destruction. - */ -typedef void (*rtems_dosfs_convert_destroy)( - rtems_dosfs_convert_control *self -); - -/** - * @brief FAT filesystem convert handler. - */ -typedef struct { - rtems_dosfs_utf8_to_codepage utf8_to_codepage; - rtems_dosfs_codepage_to_utf8 codepage_to_utf8; - rtems_dosfs_utf8_to_utf16 utf8_to_utf16; - rtems_dosfs_utf16_to_utf8 utf16_to_utf8; - rtems_dosfs_utf8_normalize_and_fold utf8_normalize_and_fold; - rtems_dosfs_convert_destroy destroy; -} rtems_dosfs_convert_handler; - -typedef struct { - void *data; - size_t size; -} rtems_dosfs_buffer; - -/** - * @brief FAT filesystem convert control. - * - * Short file names are stored in the code page format. Long file names are - * stored as little-endian UTF-16. The convert control determines the format - * conversions to and from the POSIX file name strings. - */ -struct rtems_dosfs_convert_control { - const rtems_dosfs_convert_handler *handler; - rtems_dosfs_buffer buffer; -}; - -/** - * @defgroup DOSFS FAT Filesystem Support - * - * @ingroup FileSystemTypesAndMount - * - * @brief FAT file system configuration support, format and mount options. - * - * A block device can be formatted with a FAT file system with the - * msdos_format() function. - * - * The FAT file system mount operation can be controlled with FAT file system - * specific mount options, see @ref rtems_dosfs_mount_options. - * - * @{ - */ - -/** - * @brief Semaphore count per FAT filesystem instance. - * - * This can be used for system configuration via <rtems/confdefs.h>. - */ -#define RTEMS_DOSFS_SEMAPHORES_PER_INSTANCE 1 - -/** - * @brief FAT filesystem mount options. - */ -typedef struct { - /** - * @brief Converter implementation for new file system instance. - * - * Before converters have been added to the RTEMS implementation of the FAT - * file system, the implementation was: - * - Short names were saved in code page format (as is still the case). - * - Long names were not saved in UTF-16 format as mandated by the FAT file - * system specification. Instead the character in the local encoding was - * stored to the low byte directly and the high byte was set to zero. - * - * There are a few compatibility issues due to a non-standard conform - * implementation of the FAT file system before the UTF-8 support was added. - * These following issues affect the default converter and the UTF-8 - * converter: - * - Before UTF-8 support was added, it was possible to create files with the - * the same short name in single case and mixed case in a directory. It - * was for example possible to have files "ABC" and "aBc" in a single - * directory. Now this bug is fixed. - * - Before UTF-8 support was added, it was possible to create files with a - * name length of slightly more than 255 characters. Now the - * implementation adheres exactly to the 255 character limit. - * - Long file names saved before UTF-8 support was added could contain - * non-ASCII characters in the low byte which was saved for a long name - * character. With the default converter this means such files can be read - * only by their short file name. With the UTF-8 converter file names will - * be read correctly as long as the characters written with the old - * implementation were Latin-1 characters. - * - * The following sample code demonstrates how to mount a file - * system with UTF-8 support: - * @code - * #include <errno.h> - * #include <assert.h> - * #include <rtems/dosfs.h> - * #include <rtems/libio.h> - * - * static int mount_with_utf8( - * const char *device_file, - * const char *mount_point - * ) - * { - * rtems_dosfs_convert_control *convert_ctrl; - * int rv; - * - * convert_ctrl = rtems_dosfs_create_utf8_converter( "CP850" ); - * - * if ( convert_ctrl != NULL ) { - * rtems_dosfs_mount_options mount_opts; - * - * memset( &mount_opts, 0, sizeof( mount_opts ) ); - * mount_opts.converter = convert_ctrl; - * - * rv = mount_and_make_target_path( - * device_file, - * mount_point, - * RTEMS_FILESYSTEM_TYPE_DOSFS, - * RTEMS_FILESYSTEM_READ_WRITE, - * &mount_opts - * ); - * } else { - * rv = -1; - * errno = ENOMEM; - * } - * - * return rv; - * } - * @endcode - * - * In case you do not want UTF-8 support, you can simply pass a NULL pointer - * to mount_and_make_target_path() respectively to mount() instead of the - * mount_opts address. - * - * @see rtems_dosfs_create_default_converter() and - * rtems_dosfs_create_utf8_converter(). - */ - rtems_dosfs_convert_control *converter; -} rtems_dosfs_mount_options; - -/** - * @brief Allocates and initializes a default converter. - * - * This default converter will accept only POSIX file names with pure ASCII - * characters. This largely corresponds to the file name handling before the - * optional UTF-8 support was added to the RTEMS implementation of the FAT file - * system. This handling is mostly backwards compatible to the previous RTEMS - * implementation of the FAT file system. - * - * For backwards compatibility and the previous RTEMS implementation of the FAT - * file system please see also @ref rtems_dosfs_mount_options and mount(). - * - * @retval NULL Something failed. - * @retval other Pointer to initialized converter. - */ -rtems_dosfs_convert_control *rtems_dosfs_create_default_converter(void); - -/** - * @brief Allocates and initializes a UTF-8 converter. - * - * This converter will assume that all file names passed to POSIX file handling - * methods are UTF-8 strings and will convert them to the selected code page - * for short file names and to UTF-16 for long file names. This conversion - * will be done during reading and writing. These conversions correspond to - * the specification of the FAT file system. This handling is mostly backwards - * compatible to the previous RTEMS implementation of the FAT file system. - * - * For backwards compatibility and the previous RTEMS implementation of the FAT - * file system please see also @ref rtems_dosfs_mount_options and mount(). - * - * One possible issue with this converter is: When reading file names which - * have been created with other implementations of the FAT file system, it can - * happen that during the conversion to UTF-8 a long file name becomes longer - * and exceeds the 255 bytes limit. In such a case only the short file name - * will get read. - * - * @param[in] codepage The iconv() identification string for the used code - * page. - * - * @retval NULL Something failed. - * @retval other Pointer to initialized converter. - */ -rtems_dosfs_convert_control *rtems_dosfs_create_utf8_converter( - const char *codepage -); - -#define MSDOS_FMT_INFO_LEVEL_NONE (0) -#define MSDOS_FMT_INFO_LEVEL_INFO (1) -#define MSDOS_FMT_INFO_LEVEL_DETAIL (2) -#define MSDOS_FMT_INFO_LEVEL_DEBUG (3) - -/** - * @brief FAT file system format request parameters. - */ -typedef struct { - /** - * @brief OEM name string or NULL. - */ - const char *OEMName; - - /** - * @brief Volume label string or NULL. - */ - const char *VolLabel; - - /** - * @brief Sectors per cluster hint. - * - * The format procedure may choose another value. Use 0 as default value. - */ - uint32_t sectors_per_cluster; - - /** - * @brief Number of FATs hint. - * - * Use 0 as default value. - */ - uint32_t fat_num; - - /** - * @brief Minimum files in root directory for FAT12 and FAT16. - * - * The format procedure may choose a greater value. Use 0 as default value. - */ - uint32_t files_per_root_dir; - - /** - * @brief Media code. - * - * Use 0 as default value. The default media code is 0xf8. - */ - uint8_t media; - - /** - * @brief Quick format. - * - * If set to true, then do not clear data sectors to zero. - */ - bool quick_format; - - /** - * @brief Do not align FAT, data cluster, and root directory to a cluster - * boundary. - */ - bool skip_alignment; - - /** - * @brief Synchronize device after write operations. - */ - bool sync_device; - - /** - * @brief The amount of info to output. - */ - int info_level; -} msdos_format_request_param_t; - -/** - * @brief Formats a block device with a FAT file system. - * - * @param[in] devname The block device path. - * @param[in] rqdata The FAT file system format request data. Use NULL for - * default parameters. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - */ -int msdos_format ( - const char *devname, - const msdos_format_request_param_t *rqdata -); - -/** @} */ - -int rtems_dosfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libfs/src/imfs/imfs.h b/cpukit/libfs/src/imfs/imfs.h deleted file mode 100644 index fe3c5b12a9..0000000000 --- a/cpukit/libfs/src/imfs/imfs.h +++ /dev/null @@ -1,946 +0,0 @@ -/** - * @file - * - * @brief Header File for the In-Memory File System - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_IMFS_H -#define _RTEMS_IMFS_H - -#include <limits.h> - -#include <rtems/libio_.h> -#include <rtems/pipe.h> - -/** - * @brief In-Memory File System Support. - * - * @defgroup IMFS In-Memory File System Support - * - * @ingroup FileSystemTypesAndMount - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Data types - */ - -struct IMFS_jnode_tt; -typedef struct IMFS_jnode_tt IMFS_jnode_t; - -/** - * IMFS "memfile" information - * - * The data structure for the in-memory "memfiles" is based on classic UNIX. - * - * block_ptr is a pointer to a block of IMFS_MEMFILE_BYTES_PER_BLOCK in - * length which could be data or a table of pointers to blocks. - * - * Setting IMFS_MEMFILE_BYTES_PER_BLOCK to different values has a significant - * impact on the maximum file size supported as well as the amount of - * memory wasted due to internal file fragmentation. The following - * is a list of maximum file sizes based on various settings - * - * @code - * max_filesize with blocks of 16 is 1,328 - * max_filesize with blocks of 32 is 18,656 - * max_filesize with blocks of 64 is 279,488 - * max_filesize with blocks of 128 is 4,329,344 - * max_filesize with blocks of 256 is 68,173,568 - * max_filesize with blocks of 512 is 1,082,195,456 - * @endcode - */ -#define IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK 128 - extern int imfs_rq_memfile_bytes_per_block; - extern int imfs_memfile_bytes_per_block; - -#define IMFS_MEMFILE_BYTES_PER_BLOCK imfs_memfile_bytes_per_block -#define IMFS_MEMFILE_BLOCK_SLOTS \ - (IMFS_MEMFILE_BYTES_PER_BLOCK / sizeof(void *)) - -typedef uint8_t *block_p; -typedef block_p *block_ptr; - -/* - * Important block numbers for "memfiles" - */ -#define FIRST_INDIRECT (0) -#define LAST_INDIRECT (IMFS_MEMFILE_BLOCK_SLOTS - 1) - -#define FIRST_DOUBLY_INDIRECT (LAST_INDIRECT + 1) -#define LAST_DOUBLY_INDIRECT \ - (LAST_INDIRECT + \ - (IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS)) - -#define FIRST_TRIPLY_INDIRECT (LAST_DOUBLY_INDIRECT + 1) -#define LAST_TRIPLY_INDIRECT \ - (LAST_DOUBLY_INDIRECT +\ - (IMFS_MEMFILE_BLOCK_SLOTS * \ - IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS)) - -#define IMFS_MEMFILE_MAXIMUM_SIZE \ - (LAST_TRIPLY_INDIRECT * IMFS_MEMFILE_BYTES_PER_BLOCK) - -/** @} */ - -/** - * @addtogroup IMFSGenericNodes - */ -/**@{*/ - -/** - * @brief Initializes an IMFS node. - * - * @param[in] node The IMFS node. - * @param[in] arg The user provided argument pointer. It may contain node - * specific initialization information. - * - * @retval node Successful operation. - * @retval NULL An error occurred. The @c errno indicates the error. This - * will abort the make operation. - * - * @see IMFS_node_control, IMFS_node_initialize_default(), and - * IMFS_node_initialize_generic(). - */ -typedef IMFS_jnode_t *(*IMFS_node_control_initialize)( - IMFS_jnode_t *node, - void *arg -); - -/** - * @brief Returns the node and does nothing else. - * - * @param[in] node The IMFS node. - * @param[in] arg The user provided argument pointer. It is not used. - * - * @retval node Returns always the node passed as parameter. - * - * @see IMFS_node_control. - */ -IMFS_jnode_t *IMFS_node_initialize_default( - IMFS_jnode_t *node, - void *arg -); - -IMFS_jnode_t *IMFS_node_initialize_directory( - IMFS_jnode_t *node, - void *arg -); - -/** - * @brief Returns the node and sets the generic node context. - * - * @param[in] node The IMFS node. - * @param[in] arg The user provided argument pointer. It must contain the - * generic context. - * - * @retval node Returns always the node passed as parameter. - * - * @see IMFS_node_control. - */ -IMFS_jnode_t *IMFS_node_initialize_generic( - IMFS_jnode_t *node, - void *arg -); - -/** - * @brief Prepares the removal of an IMFS node from its parent directory. - * - * @param[in] node The IMFS node. - * - * @retval node Successful operation. - * @retval NULL An error occurred. The @c errno indicates the error. This - * will abort the removal operation. - * - * @see IMFS_node_control and IMFS_node_remove_default(). - */ -typedef IMFS_jnode_t *(*IMFS_node_control_remove)( - IMFS_jnode_t *node -); - -/** - * @brief Returns the node and does nothing else. - * - * @param[in] node The IMFS node. - * - * @retval node Returns always the node passed as parameter. - * - * @see IMFS_node_control. - */ -IMFS_jnode_t *IMFS_node_remove_default( - IMFS_jnode_t *node -); - -IMFS_jnode_t *IMFS_node_remove_directory( IMFS_jnode_t *node ); - -/** - * @brief Destroys an IMFS node. - * - * @param[in] node The IMFS node. - * - * @see IMFS_node_control and IMFS_node_destroy_default(). - */ -typedef void (*IMFS_node_control_destroy)( IMFS_jnode_t *node ); - -/** - * @brief Frees the node. - * - * @param[in] node The IMFS node. - * - * @see IMFS_node_control. - */ -void IMFS_node_destroy_default( IMFS_jnode_t *node ); - -/** - * @brief IMFS node control. - */ -typedef struct { - const rtems_filesystem_file_handlers_r *handlers; - IMFS_node_control_initialize node_initialize; - IMFS_node_control_remove node_remove; - IMFS_node_control_destroy node_destroy; -} IMFS_node_control; - -typedef struct { - IMFS_node_control node_control; - size_t node_size; -} IMFS_mknod_control; - -/** @} */ - -/** - * @addtogroup IMFS - */ -/**@{*/ - -/* - * Maximum length of a "basename" of an IMFS file/node. - */ - -#define IMFS_NAME_MAX _POSIX_NAME_MAX - -/* - - * The control structure for an IMFS jnode. - */ - -struct IMFS_jnode_tt { - rtems_chain_node Node; /* for chaining them together */ - IMFS_jnode_t *Parent; /* Parent node */ - const char *name; /* "basename" (not \0 terminated) */ - uint16_t namelen; /* Length of "basename" */ - uint16_t flags; /* Node flags */ - mode_t st_mode; /* File mode */ - unsigned short reference_count; - nlink_t st_nlink; /* Link count */ - - uid_t st_uid; /* User ID of owner */ - gid_t st_gid; /* Group ID of owner */ - - time_t stat_atime; /* Time of last access */ - time_t stat_mtime; /* Time of last modification */ - time_t stat_ctime; /* Time of last status change */ - const IMFS_node_control *control; -}; - -#define IMFS_NODE_FLAG_NAME_ALLOCATED 0x1 - -typedef struct { - IMFS_jnode_t Node; - rtems_chain_control Entries; - rtems_filesystem_mount_table_entry_t *mt_fs; -} IMFS_directory_t; - -typedef struct { - IMFS_jnode_t Node; - rtems_device_major_number major; - rtems_device_minor_number minor; -} IMFS_device_t; - -typedef struct { - IMFS_jnode_t Node; - IMFS_jnode_t *link_node; -} IMFS_link_t; - -typedef struct { - IMFS_jnode_t Node; - char *name; -} IMFS_sym_link_t; - -typedef struct { - IMFS_jnode_t Node; - size_t size; /* size of file in bytes */ -} IMFS_filebase_t; - -typedef struct { - IMFS_filebase_t File; - block_ptr indirect; /* array of 128 data blocks pointers */ - block_ptr doubly_indirect; /* 128 indirect blocks */ - block_ptr triply_indirect; /* 128 doubly indirect blocks */ -} IMFS_memfile_t; - -typedef struct { - IMFS_filebase_t File; - block_p direct; /* pointer to file image */ -} IMFS_linearfile_t; - -/* Support copy on write for linear files */ -typedef union { - IMFS_jnode_t Node; - IMFS_filebase_t File; - IMFS_memfile_t Memfile; - IMFS_linearfile_t Linearfile; -} IMFS_file_t; - -typedef struct { - IMFS_jnode_t Node; - pipe_control_t *pipe; -} IMFS_fifo_t; - -typedef struct { - IMFS_jnode_t Node; - void *context; -} IMFS_generic_t; - -static inline IMFS_directory_t *IMFS_iop_to_directory( - const rtems_libio_t *iop -) -{ - return (IMFS_directory_t *) iop->pathinfo.node_access; -} - -static inline IMFS_device_t *IMFS_iop_to_device( const rtems_libio_t *iop ) -{ - return (IMFS_device_t *) iop->pathinfo.node_access; -} - -static inline IMFS_file_t *IMFS_iop_to_file( const rtems_libio_t *iop ) -{ - return (IMFS_file_t *) iop->pathinfo.node_access; -} - -static inline IMFS_memfile_t *IMFS_iop_to_memfile( const rtems_libio_t *iop ) -{ - return (IMFS_memfile_t *) iop->pathinfo.node_access; -} - -static inline void IMFS_update_atime( IMFS_jnode_t *jnode ) -{ - struct timeval now; - - gettimeofday( &now, 0 ); - - jnode->stat_atime = now.tv_sec; -} - -static inline void IMFS_update_mtime( IMFS_jnode_t *jnode ) -{ - struct timeval now; - - gettimeofday( &now, 0 ); - - jnode->stat_mtime = now.tv_sec; -} - -static inline void IMFS_update_ctime( IMFS_jnode_t *jnode ) -{ - struct timeval now; - - gettimeofday( &now, 0 ); - - jnode->stat_ctime = now.tv_sec; -} - -static inline void IMFS_mtime_ctime_update( IMFS_jnode_t *jnode ) -{ - struct timeval now; - - gettimeofday( &now, 0 ); - - jnode->stat_mtime = now.tv_sec; - jnode->stat_ctime = now.tv_sec; -} - -typedef struct { - const IMFS_mknod_control *directory; - const IMFS_mknod_control *device; - const IMFS_mknod_control *file; - const IMFS_mknod_control *fifo; -} IMFS_mknod_controls; - -typedef struct { - IMFS_directory_t Root_directory; - const IMFS_mknod_controls *mknod_controls; -} IMFS_fs_info_t; - -typedef struct { - IMFS_fs_info_t *fs_info; - const rtems_filesystem_operations_table *ops; - const IMFS_mknod_controls *mknod_controls; -} IMFS_mount_data; - -/* - * Shared Data - */ - -extern const IMFS_mknod_control IMFS_mknod_control_dir_default; -extern const IMFS_mknod_control IMFS_mknod_control_dir_minimal; -extern const IMFS_mknod_control IMFS_mknod_control_device; -extern const IMFS_mknod_control IMFS_mknod_control_memfile; -extern const IMFS_node_control IMFS_node_control_linfile; -extern const IMFS_mknod_control IMFS_mknod_control_fifo; -extern const IMFS_mknod_control IMFS_mknod_control_enosys; - -extern const rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS; - -/* - * Routines - */ - -extern int IMFS_initialize( - rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data -); - -extern int IMFS_initialize_support( - rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data -); - -/** - * @brief Unmount this instance of IMFS. - */ -extern void IMFS_fsunmount( - rtems_filesystem_mount_table_entry_t *mt_entry -); - -/** - * @brief RTEMS load tarfs. - * - * This file implements the "mount" procedure for tar-based IMFS - * extensions. The TAR is not actually mounted under the IMFS. - * Directories from the TAR file are created as usual in the IMFS. - * File entries are created as IMFS_LINEAR_FILE nodes with their nods - * pointing to addresses in the TAR image. - * - * Here we create the mountpoint directory and load the tarfs at - * that node. Once the IMFS has been mounted, we work through the - * tar image and perform as follows: - * - For directories, simply call mkdir(). The IMFS creates nodes as - * needed. - * - For files, we make our own calls to IMFS eval_for_make and - * create_node. - * - * TAR file format: - * - * @code - * Offset Length Contents - * 0 100 bytes File name ('\0' terminated, 99 maxmum length) - * 100 8 bytes File mode (in octal ascii) - * 108 8 bytes User ID (in octal ascii) - * 116 8 bytes Group ID (in octal ascii) - * 124 12 bytes File size (s) (in octal ascii) - * 136 12 bytes Modify time (in octal ascii) - * 148 8 bytes Header checksum (in octal ascii) - * 156 1 bytes Link flag - * 157 100 bytes Linkname ('\0' terminated, 99 maxmum length) - * 257 8 bytes Magic PAX ("ustar\0" + 2 bytes padding) - * 257 8 bytes Magic GNU tar ("ustar \0") - * 265 32 bytes User name ('\0' terminated, 31 maxmum length) - * 297 32 bytes Group name ('\0' terminated, 31 maxmum length) - * 329 8 bytes Major device ID (in octal ascii) - * 337 8 bytes Minor device ID (in octal ascii) - * 345 167 bytes Padding - * 512 (s+p) bytes File contents (s+p) := (((s) + 511) & ~511), - * round up to 512 bytes - * @endcode - * - * Checksum: - * @code - * int i, sum; - * char *header = tar_header_pointer; - * - * sum = 0; - * for (i = 0; i < 512; i++) - * sum += 0xFF & header[i]; - * @endcode - */ -extern int rtems_tarfs_load( - const char *mountpoint, - uint8_t *tar_image, - size_t tar_size -); - -/** - * @brief Destroy an IMFS node. - */ -extern void IMFS_node_destroy( IMFS_jnode_t *node ); - -/** - * @brief Clone an IMFS node. - */ -extern int IMFS_node_clone( rtems_filesystem_location_info_t *loc ); - -/** - * @brief Free an IMFS node. - */ -extern void IMFS_node_free( const rtems_filesystem_location_info_t *loc ); - -/** - * @brief Perform a status processing for the IMFS. - * - * This routine provides a stat for the IMFS file system. - */ -extern int IMFS_stat( - const rtems_filesystem_location_info_t *loc, - struct stat *buf -); - -extern int IMFS_stat_file( - const rtems_filesystem_location_info_t *loc, - struct stat *buf -); - -/** - * @brief IMFS evaluation node support. - */ -extern void IMFS_eval_path( - rtems_filesystem_eval_path_context_t *ctx -); - -/** - * @brief Create a new IMFS link node. - * - * The following rouine creates a new link node under parent with the - * name given in name. The link node is set to point to the node at - * to_loc. - */ -extern int IMFS_link( - const rtems_filesystem_location_info_t *parentloc, - const rtems_filesystem_location_info_t *targetloc, - const char *name, - size_t namelen -); - -/** - * @brief Change the owner of IMFS. - * - * This routine is the implementation of the chown() system - * call for the IMFS. - */ -extern int IMFS_chown( - const rtems_filesystem_location_info_t *loc, - uid_t owner, - gid_t group -); - -/** - * @brief Create an IMFS node. - * - * Routine to create a node in the IMFS file system. - */ -extern int IMFS_mknod( - const rtems_filesystem_location_info_t *parentloc, - const char *name, - size_t namelen, - mode_t mode, - dev_t dev -); - -extern IMFS_jnode_t *IMFS_initialize_node( - IMFS_jnode_t *node, - const IMFS_node_control *node_control, - const char *name, - size_t namelen, - mode_t mode, - void *arg -); - -/** - * @brief Create an IMFS node. - * - * Create an IMFS filesystem node of an arbitrary type that is NOT - * the root directory node. - */ -extern IMFS_jnode_t *IMFS_create_node( - const rtems_filesystem_location_info_t *parentloc, - const IMFS_node_control *node_control, - size_t node_size, - const char *name, - size_t namelen, - mode_t mode, - void *arg -); - -static inline bool IMFS_is_imfs_instance( - const rtems_filesystem_location_info_t *loc -) -{ - return loc->mt_entry->ops->clonenod_h == IMFS_node_clone; -} - -/** @} */ - -/** - * @defgroup IMFSGenericNodes IMFS Generic Nodes - * - * @ingroup LibIO - * - * @brief Generic nodes are an alternative to standard drivers in RTEMS. - * - * The handlers of a generic node are called with less overhead compared to the - * standard driver operations. The usage of file system node handlers enable - * more features like support for fsync() and fdatasync(). The generic nodes - * use the reference counting of the IMFS. This provides automatic node - * destruction when the last reference vanishes. - * - * @{ - */ - -/** - * @brief Initializer for a generic node control. - * - * @param[in] handlers The file system node handlers. - * @param[in] init The node initialization method. - * @param[in] destroy The node destruction method. - */ -#define IMFS_GENERIC_INITIALIZER( handlers, init, destroy ) \ - { \ - ( handlers ), \ - ( init ), \ - IMFS_node_remove_default, \ - ( destroy ) \ - } - -/** - * @brief Makes a generic IMFS node. - * - * @param[in] path The path to the new generic IMFS node. - * @param[in] mode The node mode. - * @param[in] node_control The node control. - * @param[in] context The node control handler context. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - * - * @code - * #include <sys/stat.h> - * #include <assert.h> - * #include <fcntl.h> - * - * #include <rtems/imfs.h> - * - * static const rtems_filesystem_file_handlers_r some_node_handlers = { - * ... - * }; - * - * static IMFS_jnode_t *some_node_init(IMFS_jnode_t *node, void *arg) - * { - * void *context; - * - * node = IMFS_node_initialize_generic(node, arg); - * context = IMFS_generic_get_context_by_node(node); - * - * return node; - * } - * - * static void some_node_destroy(IMFS_jnode_t *node) - * { - * void *context = IMFS_generic_get_context_by_node(node); - * - * IMFS_node_destroy_default(node); - * } - * - * static const IMFS_node_control some_node_control = IMFS_GENERIC_INITIALIZER( - * &some_node_handlers, - * some_node_init, - * some_node_destroy - * ); - * - * void example(void *some_node_context) - * { - * int rv; - * - * rv = IMFS_make_generic_node( - * "/path/to/some/generic/node", - * S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, - * &some_node_control, - * some_node_context - * ); - * assert(rv == 0); - * } - * @endcode - */ -extern int IMFS_make_generic_node( - const char *path, - mode_t mode, - const IMFS_node_control *node_control, - void *context -); - -/** @} */ - -/** - * @addtogroup IMFS - */ -/**@{*/ - -/** - * @brief Mount an IMFS. - */ -extern int IMFS_mount( - rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ -); - -/** - * @brief Unmount an IMFS. - */ -extern int IMFS_unmount( - rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ -); - -/** - * @name IMFS Memory File Handlers - * - * This section contains the set of handlers used to process operations on - * IMFS memory file nodes. The memory files are created in memory using - * malloc'ed memory. Thus any data stored in one of these files is lost - * at system shutdown unless special arrangements to copy the data to - * some type of non-volailte storage are made by the application. - */ -/**@{*/ - -extern ssize_t IMFS_memfile_write( - IMFS_memfile_t *memfile, - off_t start, - const unsigned char *source, - unsigned int length -); - -/** @} */ - -/** - * @name IMFS Device Node Handlers - * - * This section contains the set of handlers used to map operations on - * IMFS device nodes onto calls to the RTEMS Classic API IO Manager. - */ -/**@{*/ - -extern int device_open( - rtems_libio_t *iop, /* IN */ - const char *pathname, /* IN */ - int oflag, /* IN */ - mode_t mode /* IN */ -); - -extern int device_close( - rtems_libio_t *iop /* IN */ -); - -extern ssize_t device_read( - rtems_libio_t *iop, /* IN */ - void *buffer, /* IN */ - size_t count /* IN */ -); - -extern ssize_t device_write( - rtems_libio_t *iop, /* IN */ - const void *buffer, /* IN */ - size_t count /* IN */ -); - -extern int device_ioctl( - rtems_libio_t *iop, - ioctl_command_t command, - void *buffer -); - -extern int device_ftruncate( - rtems_libio_t *iop, /* IN */ - off_t length /* IN */ -); - -/** @} */ - -/** - * @brief Set IMFS file access and modification times. - * - * - * This routine is the implementation of the utime() system - * call for the IMFS. - */ -extern int IMFS_utime( - const rtems_filesystem_location_info_t *loc, - time_t actime, - time_t modtime -); - -/** - * @brief Change the IMFS file mode. - */ -extern int IMFS_fchmod( - const rtems_filesystem_location_info_t *loc, - mode_t mode -); - -/** - * @brief Create a new IMFS symbolic link node. - * - * The following rouine creates a new symbolic link node under parent - * with the name given in name. The node is set to point to the node at - * to_loc. - */ -extern int IMFS_symlink( - const rtems_filesystem_location_info_t *parentloc, - const char *name, - size_t namelen, - const char *target -); - -/** - * @brief Put IMFS symbolic link into buffer. - * - * The following rouine puts the symbolic links destination name into - * buff. - * - */ -extern ssize_t IMFS_readlink( - const rtems_filesystem_location_info_t *loc, - char *buf, - size_t bufsize -); - -/** - * @brief Rename the IMFS. - * - * The following rouine creates a new link node under parent with the - * name given in name and removes the old. - */ -extern int IMFS_rename( - const rtems_filesystem_location_info_t *oldparentloc, - const rtems_filesystem_location_info_t *oldloc, - const rtems_filesystem_location_info_t *newparentloc, - const char *name, - size_t namelen -); -/** - * @brief IMFS node removal handler. - * - * This file contains the handler used to remove a node when a file type - * does not require special actions. - */ -extern int IMFS_rmnod( - const rtems_filesystem_location_info_t *parentloc, - const rtems_filesystem_location_info_t *loc -); - -/* - * Turn on IMFS assertions when RTEMS_DEBUG is defined. - */ -#ifdef RTEMS_DEBUG - #include <assert.h> - - #define IMFS_assert(_x) assert(_x) -#else - #define IMFS_assert(_x) -#endif - -static inline void IMFS_Set_handlers( rtems_filesystem_location_info_t *loc ) -{ - IMFS_jnode_t *node = (IMFS_jnode_t *) loc->node_access; - - loc->handlers = node->control->handlers; -} - -static inline void IMFS_add_to_directory( - IMFS_jnode_t *dir_node, - IMFS_jnode_t *entry_node -) -{ - IMFS_directory_t *dir = (IMFS_directory_t *) dir_node; - - entry_node->Parent = dir_node; - rtems_chain_append_unprotected( &dir->Entries, &entry_node->Node ); -} - -static inline void IMFS_remove_from_directory( IMFS_jnode_t *node ) -{ - IMFS_assert( node->Parent != NULL ); - node->Parent = NULL; - rtems_chain_extract_unprotected( &node->Node ); -} - -static inline bool IMFS_is_directory( const IMFS_jnode_t *node ) -{ - return S_ISDIR( node->st_mode ); -} - -#define IMFS_STAT_FMT_HARD_LINK 0 - -static inline bool IMFS_is_hard_link( mode_t mode ) -{ - return ( mode & S_IFMT ) == IMFS_STAT_FMT_HARD_LINK; -} - -static inline ino_t IMFS_node_to_ino( const IMFS_jnode_t *node ) -{ - return (ino_t) ((uintptr_t) node); -} - -/** @} */ - -/** - * @addtogroup IMFSGenericNodes - */ -/**@{*/ - -static inline void *IMFS_generic_get_context_by_node( - const IMFS_jnode_t *node -) -{ - const IMFS_generic_t *generic = (const IMFS_generic_t *) node; - - return generic->context; -} - -static inline void *IMFS_generic_get_context_by_location( - const rtems_filesystem_location_info_t *loc -) -{ - return loc->node_access_2; -} - -static inline void *IMFS_generic_get_context_by_iop( - const rtems_libio_t *iop -) -{ - return IMFS_generic_get_context_by_location( &iop->pathinfo ); -} - -static inline dev_t IMFS_generic_get_device_identifier_by_node( - const IMFS_jnode_t *node -) -{ - return rtems_filesystem_make_dev_t_from_pointer( node ); -} - -#ifdef __cplusplus -} -#endif -/** @} */ -#endif -/* end of include file */ diff --git a/cpukit/libfs/src/jffs2/include/rtems/jffs2.h b/cpukit/libfs/src/jffs2/include/rtems/jffs2.h deleted file mode 100644 index a856c46c41..0000000000 --- a/cpukit/libfs/src/jffs2/include/rtems/jffs2.h +++ /dev/null @@ -1,604 +0,0 @@ -/* - * Copyright (c) 2013, 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef RTEMS_JFFS2_H -#define RTEMS_JFFS2_H - -#include <rtems/fs.h> -#include <sys/param.h> -#include <sys/ioccom.h> -#include <zlib.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef struct rtems_jffs2_flash_control rtems_jffs2_flash_control; - -/** - * @defgroup JFFS2 Journalling Flash File System Version 2 (JFFS2) Support - * - * @ingroup FileSystemTypesAndMount - * - * @brief Mount options for the Journalling Flash File System, Version 2 - * (JFFS2). - * - * The application must provide flash device geometry information and flash - * device operations in the flash control structure - * @ref rtems_jffs2_flash_control. - * - * The application can optionally provide a compressor control structure to - * enable data compression using the selected compression algorithm. - * - * The application must enable JFFS2 support with rtems_filesystem_register() - * or CONFIGURE_FILESYSTEM_JFFS2 via <rtems/confdefs.h>. - * - * An example mount with a simple memory based flash device simulation follows. - * The zlib is used for as the compressor. - * - * @code - * #include <string.h> - * - * #include <rtems/jffs2.h> - * #include <rtems/libio.h> - * - * #define BLOCK_SIZE (32UL * 1024UL) - * - * #define FLASH_SIZE (32UL * BLOCK_SIZE) - * - * typedef struct { - * rtems_jffs2_flash_control super; - * unsigned char area[FLASH_SIZE]; - * } flash_control; - * - * static flash_control *get_flash_control(rtems_jffs2_flash_control *super) - * { - * return (flash_control *) super; - * } - * - * static int flash_read( - * rtems_jffs2_flash_control *super, - * uint32_t offset, - * unsigned char *buffer, - * size_t size_of_buffer - * ) - * { - * flash_control *self = get_flash_control(super); - * unsigned char *chunk = &self->area[offset]; - * - * memcpy(buffer, chunk, size_of_buffer); - * - * return 0; - * } - * - * static int flash_write( - * rtems_jffs2_flash_control *super, - * uint32_t offset, - * const unsigned char *buffer, - * size_t size_of_buffer - * ) - * { - * flash_control *self = get_flash_control(super); - * unsigned char *chunk = &self->area[offset]; - * size_t i; - * - * for (i = 0; i < size_of_buffer; ++i) { - * chunk[i] &= buffer[i]; - * } - * - * return 0; - * } - * - * static int flash_erase( - * rtems_jffs2_flash_control *super, - * uint32_t offset - * ) - * { - * flash_control *self = get_flash_control(super); - * unsigned char *chunk = &self->area[offset]; - * - * memset(chunk, 0xff, BLOCK_SIZE); - * - * return 0; - * } - * - * static flash_control flash_instance = { - * .super = { - * .block_size = BLOCK_SIZE, - * .flash_size = FLASH_SIZE, - * .read = flash_read, - * .write = flash_write, - * .erase = flash_erase, - * .device_identifier = 0xc01dc0fe - * } - * }; - * - * static rtems_jffs2_compressor_zlib_control compressor_instance = { - * .super = { - * .compress = rtems_jffs2_compressor_zlib_compress, - * .decompress = rtems_jffs2_compressor_zlib_decompress - * } - * }; - * - * static const rtems_jffs2_mount_data mount_data = { - * .flash_control = &flash_instance.super, - * .compressor_control = &compressor_instance.super - * }; - * - * static void erase_all(void) - * { - * memset(&flash_instance.area[0], 0xff, FLASH_SIZE); - * } - * - * void example_jffs2_mount(const char *mount_dir) - * { - * int rv; - * - * erase_all(); - * - * rv = mount_and_make_target_path( - * NULL, - * mount_dir, - * RTEMS_FILESYSTEM_TYPE_JFFS2, - * RTEMS_FILESYSTEM_READ_WRITE, - * &mount_data - * ); - * assert(rv == 0); - * } - * @endcode - * - * @{ - */ - -/** - * @brief Read from flash operation. - * - * @param[in, out] self The flash control. - * @param[in] offset The offset to read from the flash begin in bytes. - * @param[out] buffer The buffer receiving the data. - * @param[in] size_of_buffer The size of the buffer in bytes. - * - * @retval 0 Successful operation. - * @retval -EIO An error occurred. Please note that the value is negative. - * @retval other All other values are reserved and must not be used. - */ -typedef int (*rtems_jffs2_flash_read)( - rtems_jffs2_flash_control *self, - uint32_t offset, - unsigned char *buffer, - size_t size_of_buffer -); - -/** - * @brief Write to flash operation. - * - * @param[in, out] self The flash control. - * @param[in] offset The offset to write from the flash begin in bytes. - * @param[in] buffer The buffer containing the data to write. - * @param[in] size_of_buffer The size of the buffer in bytes. - * - * @retval 0 Successful operation. - * @retval -EIO An error occurred. Please note that the value is negative. - * @retval other All other values are reserved and must not be used. - */ -typedef int (*rtems_jffs2_flash_write)( - rtems_jffs2_flash_control *self, - uint32_t offset, - const unsigned char *buffer, - size_t size_of_buffer -); - -/** - * @brief Flash erase operation. - * - * This operation must erase one block specified by the offset. - * - * @param[in, out] self The flash control. - * @param[in] offset The offset to erase from the flash begin in bytes. - * - * @retval 0 Successful operation. - * @retval -EIO An error occurred. Please note that the value is negative. - * @retval other All other values are reserved and must not be used. - */ -typedef int (*rtems_jffs2_flash_erase)( - rtems_jffs2_flash_control *self, - uint32_t offset -); - -/** - * @brief Flash destroy operation. - * - * The flash destroy operation is called during unmount of the file system - * instance. It can be used to free the resources associated with the now - * unused flash control - * - * @param[in, out] self The flash control. - */ -typedef void (*rtems_jffs2_flash_destroy)( - rtems_jffs2_flash_control *self -); - -/** - * @brief Trigger garbage collection operation. - * - * An optional garbage collection thread may perform now a garbage collection - * using the RTEMS_JFFS2_ON_DEMAND_GARBAGE_COLLECTION IO control. - * - * The garbage collection must not run in the executing context. - * - * @param[in] self The flash control. - */ -typedef void (*rtems_jffs2_trigger_garbage_collection)( - rtems_jffs2_flash_control *self -); - -/** - * @brief JFFS2 flash device control. - */ -struct rtems_jffs2_flash_control { - /** - * @brief The size in bytes of the erasable unit of the flash device. - */ - uint32_t block_size; - - /** - * @brief The size in bytes of the flash device. - * - * It must be an integral multiple of the block size. The flash device must - * have at least five blocks. - */ - uint32_t flash_size; - - /** - * @brief Read from flash operation. - */ - rtems_jffs2_flash_read read; - - /** - * @brief Write to flash operation. - */ - rtems_jffs2_flash_write write; - - /** - * @brief Flash erase operation. - */ - rtems_jffs2_flash_erase erase; - - /** - * @brief Flash destroy operation. - * - * This operation is optional and the pointer may be @c NULL. - */ - rtems_jffs2_flash_destroy destroy; - - /** - * @brief The device identifier of the flash device. - * - * It is used in combination with the inode number to uniquely identify a - * file system node in the system. - */ - dev_t device_identifier; - - /** - * @brief Trigger garbage collection operation. - * - * This operation is optional and may be NULL. This operation should wake up - * a garbage collection thread. The garbage collection thread should use the - * RTEMS_JFFS2_ON_DEMAND_GARBAGE_COLLECTION IO control to carry out the work. - */ - rtems_jffs2_trigger_garbage_collection trigger_garbage_collection; -}; - -typedef struct rtems_jffs2_compressor_control rtems_jffs2_compressor_control; - -/** - * @brief Compress operation. - * - * @param[in, out] self The compressor control. - * @param[in] data_in The uncompressed data. - * @param[out] cdata_out Pointer to buffer with the compressed data. - * @param[in, out] datalen On entry, the size in bytes of the uncompressed - * data. On exit, the size in bytes of uncompressed data which was actually - * compressed. - * @param[in, out] cdatalen On entry, the size in bytes available for - * compressed data. On exit, the size in bytes of the actually compressed - * data. - * - * @return The compressor type. - */ -typedef uint16_t (*rtems_jffs2_compressor_compress)( - rtems_jffs2_compressor_control *self, - unsigned char *data_in, - unsigned char *cdata_out, - uint32_t *datalen, - uint32_t *cdatalen -); - -/** - * @brief Decompress operation. - * - * @param[in, out] self The compressor control. - * @param[in] comprtype The compressor type. - * @param[in] cdata_in The compressed data. - * @param[out] data_out The uncompressed data. - * @param[in] cdatalen The size in bytes of the compressed data. - * @param[in] datalen The size in bytes of the uncompressed data. - * - * @retval 0 Successful operation. - * @retval -EIO An error occurred. Please note that the value is negative. - * @retval other All other values are reserved and must not be used. - */ -typedef int (*rtems_jffs2_compressor_decompress)( - rtems_jffs2_compressor_control *self, - uint16_t comprtype, - unsigned char *cdata_in, - unsigned char *data_out, - uint32_t cdatalen, - uint32_t datalen -); - -/** - * @brief Compressor destroy operation. - * - * The compressor destroy operation is called during unmount of the file system - * instance. It can be used to free the resources associated with the now - * unused compressor operations. - * - * @param[in, out] self The compressor control. - */ -typedef void (*rtems_jffs2_compressor_destroy)( - rtems_jffs2_compressor_control *self -); - -/** - * @brief JFFS2 compressor control. - */ -struct rtems_jffs2_compressor_control { - /** - * @brief Compress operation. - */ - rtems_jffs2_compressor_compress compress; - - /** - * @brief Decompress operation. - */ - rtems_jffs2_compressor_decompress decompress; - - /** - * @brief Compressor destroy operation. - * - * This operation is optional and the pointer may be @c NULL. - */ - rtems_jffs2_compressor_destroy destroy; - - /** - * @brief Compression buffer. - */ - unsigned char buffer[PAGE_SIZE]; -}; - -/** - * @brief RTIME compressor compress operation. - */ -uint16_t rtems_jffs2_compressor_rtime_compress( - rtems_jffs2_compressor_control *self, - unsigned char *data_in, - unsigned char *cdata_out, - uint32_t *datalen, - uint32_t *cdatalen -); - -/** - * @brief RTIME compressor decompress operation. - */ -int rtems_jffs2_compressor_rtime_decompress( - rtems_jffs2_compressor_control *self, - uint16_t comprtype, - unsigned char *cdata_in, - unsigned char *data_out, - uint32_t cdatalen, - uint32_t datalen -); - -/** - * @brief ZLIB compressor control structure. - */ -typedef struct { - rtems_jffs2_compressor_control super; - z_stream stream; -} rtems_jffs2_compressor_zlib_control; - -/** - * @brief ZLIB compressor compress operation. - */ -uint16_t rtems_jffs2_compressor_zlib_compress( - rtems_jffs2_compressor_control *self, - unsigned char *data_in, - unsigned char *cdata_out, - uint32_t *datalen, - uint32_t *cdatalen -); - -/** - * @brief ZLIB compressor decompress operation. - */ -int rtems_jffs2_compressor_zlib_decompress( - rtems_jffs2_compressor_control *self, - uint16_t comprtype, - unsigned char *cdata_in, - unsigned char *data_out, - uint32_t cdatalen, - uint32_t datalen -); - -/** - * @brief JFFS2 mount options. - * - * For JFFS2 the mount options are mandatory. - */ -typedef struct { - /** - * @brief Flash control. - */ - rtems_jffs2_flash_control *flash_control; - - /** - * @brief Compressor control. - * - * The compressor is optional and this pointer may be @c NULL. - */ - rtems_jffs2_compressor_control *compressor_control; -} rtems_jffs2_mount_data; - -/** - * @brief Initialization handler of the JFFS2 file system. - * - * @param[in, out] mt_entry The mount table entry. - * @param[in] data The mount options are mandatory for JFFS2 and data must - * point to a valid @ref rtems_jffs2_mount_data structure used for this file - * system instance. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - * - * @see mount(). - */ -int rtems_jffs2_initialize( - rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data -); - -/** - * @brief JFFS2 filesystem instance information. - * - * @see RTEMS_JFFS2_GET_INFO. - */ -typedef struct { - /** - * @brief Flash size in bytes. - */ - uint32_t flash_size; - - /** - * @brief Count of flash blocks (erasable units). - */ - uint32_t flash_blocks; - - /** - * @brief Size of a flash block in bytes. - */ - uint32_t flash_block_size; - - /** - * @brief Used size in bytes. - * - * Used areas contain valid data. - */ - uint32_t used_size; - - /** - * @brief Dirty size in bytes. - * - * Used areas contain no longer used data. - */ - uint32_t dirty_size; - - /** - * @brief Wasted size in bytes. - * - * Wasted areas are unusable. - */ - uint32_t wasted_size; - - /** - * @brief Free size in bytes. - * - * Free areas may be used to store new data. - */ - uint32_t free_size; - - /** - * @brief Bad size in bytes. - * - * Bad areas indicate damaged flash blocks. - */ - uint32_t bad_size; - - /** - * @brief Count of clean blocks. - * - * Clean blocks contain only used areas. - */ - uint32_t clean_blocks; - - /** - * @brief Count of dirty blocks. - * - * Dirty blocks contain dirty and used areas. - */ - uint32_t dirty_blocks; - - /** - * @brief Count of erasable blocks. - * - * Erase blocks contain only dirty or wasted areas. - */ - uint32_t erasable_blocks; - - /** - * @brief Count of free blocks. - * - * Free blocks contain a free area. - */ - uint32_t free_blocks; - - /** - * @brief Count of bad blocks. - * - * Bad blocks are damaged. - */ - uint32_t bad_blocks; -} rtems_jffs2_info; - -/** - * @brief IO control to get the JFFS2 filesystem instance information. - * - * @see rtems_jffs2_info. - */ -#define RTEMS_JFFS2_GET_INFO _IOR('F', 1, rtems_jffs2_info) - -/** - * @brief IO control to perform an on demand garbage collection in a JFFS2 - * filesystem instance. - * - * This operation is intended to be used by an optional garbage collection - * thread. See rtems_jffs2_flash_control::trigger_garbage_collection. - */ -#define RTEMS_JFFS2_ON_DEMAND_GARBAGE_COLLECTION _IO('F', 2) - -/** - * @brief IO control to force a garbage collection in a JFFS2 filesystem - * instance. - * - * Use this operation with care since it may wear out your flash. - */ -#define RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION _IO('F', 3) - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_JFFS2_H */ diff --git a/cpukit/libfs/src/nfsclient/Makefile.am b/cpukit/libfs/src/nfsclient/Makefile.am index 85f4a71756..04d840f507 100644 --- a/cpukit/libfs/src/nfsclient/Makefile.am +++ b/cpukit/libfs/src/nfsclient/Makefile.am @@ -10,6 +10,11 @@ dirutils_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) if LIBNETWORKING project_lib_LIBRARIES = libnfs.a +$(PROJECT_LIB)/libnfs.a: libnfs.a + $(INSTALL_DATA) $< $(PROJECT_LIB)/libnfs.a +TMPINSTALL_FILES = $(PROJECT_LIB)/libnfs.a + + # if you have CEXP set this variable to 'YES' # and some "help" info will be compiled in. libnfs_a_SOURCES = src/rpcio.c src/rpcio.h @@ -19,8 +24,6 @@ libnfs_a_SOURCES += proto/mount_prot.h proto/nfs_prot.h # With CEXP # libnfs_a_SOURCES += dirutils.c rpcio.modini.c nfs.modini.c cexphelp.c -include_HEADERS = src/librtemsNfs.h - # PGMS=${ARCH}/nfs.obj ${ARCH}/rpcio.obj ${ARCH}/dirutils.obj libnfs_a_CPPFLAGS = $(AM_CPPFLAGS) @@ -66,5 +69,4 @@ $(srcdir)/proto/nfs_prot_xdr.c: proto/nfs_prot.x proto/nfs_prot.h > nfs_prot_xdr.c) endif -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/libfs/src/nfsclient/preinstall.am b/cpukit/libfs/src/nfsclient/preinstall.am deleted file mode 100644 index 593fc0367d..0000000000 --- a/cpukit/libfs/src/nfsclient/preinstall.am +++ /dev/null @@ -1,51 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -all-local: $(TMPINSTALL_FILES) - -TMPINSTALL_FILES = -CLEANFILES += $(TMPINSTALL_FILES) - -$(PROJECT_LIB)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_LIB) - @: > $(PROJECT_LIB)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - -$(PROJECT_LIB)/dirutils.rel: dirutils.rel $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_PROGRAM) $< $(PROJECT_LIB)/dirutils.rel -TMPINSTALL_FILES += $(PROJECT_LIB)/dirutils.rel - -if LIBNETWORKING -$(PROJECT_LIB)/libnfs.a: libnfs.a $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_LIB)/libnfs.a -TMPINSTALL_FILES += $(PROJECT_LIB)/libnfs.a - -$(PROJECT_INCLUDE)/librtemsNfs.h: src/librtemsNfs.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/librtemsNfs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/librtemsNfs.h - -$(PROJECT_LIB)/nfs.rel: nfs.rel $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_PROGRAM) $< $(PROJECT_LIB)/nfs.rel -TMPINSTALL_FILES += $(PROJECT_LIB)/nfs.rel - -$(PROJECT_LIB)/rpcio.rel: rpcio.rel $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_PROGRAM) $< $(PROJECT_LIB)/rpcio.rel -TMPINSTALL_FILES += $(PROJECT_LIB)/rpcio.rel -endif diff --git a/cpukit/libfs/src/nfsclient/src/librtemsNfs.h b/cpukit/libfs/src/nfsclient/src/librtemsNfs.h deleted file mode 100644 index 530eee2144..0000000000 --- a/cpukit/libfs/src/nfsclient/src/librtemsNfs.h +++ /dev/null @@ -1,234 +0,0 @@ -/** - * @file - * - * @brief Public Interface to the NFS Client Library for RTEMS - * - * @ingroup rtems-nfsclient - */ - -/* - * Author: Till Straumann <strauman@slac.stanford.edu> 2002-2003 - * - * Authorship - * ---------- - * This software (NFS-2 client implementation for RTEMS) was created by - * Till Straumann <strauman@slac.stanford.edu>, 2002-2007, - * Stanford Linear Accelerator Center, Stanford University. - * - * Acknowledgement of sponsorship - * ------------------------------ - * The NFS-2 client implementation for RTEMS was produced by - * the Stanford Linear Accelerator Center, Stanford University, - * under Contract DE-AC03-76SFO0515 with the Department of Energy. - * - * Government disclaimer of liability - * ---------------------------------- - * Neither the United States nor the United States Department of Energy, - * nor any of their employees, makes any warranty, express or implied, or - * assumes any legal liability or responsibility for the accuracy, - * completeness, or usefulness of any data, apparatus, product, or process - * disclosed, or represents that its use would not infringe privately owned - * rights. - * - * Stanford disclaimer of liability - * -------------------------------- - * Stanford University makes no representations or warranties, express or - * implied, nor assumes any liability for the use of this software. - * - * Stanford disclaimer of copyright - * -------------------------------- - * Stanford University, owner of the copyright, hereby disclaims its - * copyright and all other rights in this software. Hence, anyone may - * freely use it for any purpose without restriction. - * - * Maintenance of notices - * ---------------------- - * In the interest of clarity regarding the origin and status of this - * SLAC software, this and all the preceding Stanford University notices - * are to remain affixed to any copy or derivative of this software made - * or distributed by the recipient and are to be affixed to any copy of - * software made or distributed by the recipient that contains a copy or - * derivative of this software. - * - * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 - */ - -#ifndef LIB_RTEMS_NFS_CLIENT_H -#define LIB_RTEMS_NFS_CLIENT_H - -/** - * @defgroup rtems-nfsclient NFS Client Library - * - * @ingroup nfsclient - * @{ - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <rtems.h> -#include <rtems/libio.h> -#include <rtems/libio_.h> -#include <rtems/seterr.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <assert.h> -#include <sys/stat.h> -#include <dirent.h> -#include <netdb.h> -#include <ctype.h> -#include <netinet/in.h> -#include <arpa/inet.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** RPCIO driver interface. - * If you need RPCIO for other purposes than NFS - * you may want to include <rpcio.h> -#include "rpcio.h" - */ - -/** Priority of daemon; may be setup prior to calling rpcUdpInit(); - * otherwise the network task priority from the rtems_bsdnet_config - * is used... - */ -extern rtems_task_priority rpciodPriority; - -#ifdef RTEMS_SMP -/** CPU affinity of daemon; may be setup prior to calling rpcUdpInit(); - * otherwise the network task CPU affinity from the rtems_bsdnet_config - * is used... - */ -extern const cpu_set_t *rpciodCpuset; -extern size_t rpciodCpusetSize; -#endif - -/** - * @brief Sets the XIDs of the RPC transaction hash table. - * - * The active RPC transactions are stored in a hash table. Each table entry - * contains the XID of its corresponding transaction. The XID consists of two - * parts. The lower part is determined by the hash table index. The upper - * part is incremented in each send operation. - * - * This function sets the upper part of the XID in all hash table entries. - * This can be used to ensure that the XIDs are not reused in a short interval - * for example during a boot process or after resets. - * - * @param[in] xid The upper part is used to set the upper XID part of the hash - * table entries. - */ -void -rpcSetXIDs(uint32_t xid); - -/** Initialize the driver. - * - * Note, called in nfsfs initialise when mount is called. - * - * @retval 0 on success, -1 on failure - */ -int -rpcUdpInit(void); - -/** - * @brief RPC cleanup and stop. - * - * @retval 0 on success, nonzero if still in use - */ -int -rpcUdpCleanup(void); - -/** NFS driver interface */ - -/** - * @brief Initialize the NFS driver. - * - * The RPCIO driver must have been initialized prior to calling this. - * - * Note, called in nfsfs initialise when mount is called with defaults. - * - * ARGS: depth of the small and big - * transaction pools, i.e. how - * many transactions (buffers) - * should always be kept around. - * - * (If more transactions are needed, - * they are created and destroyed - * on the fly). - * - * Supply zero values to have the - * driver chose reasonable defaults. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - */ -int -nfsInit(int smallPoolDepth, int bigPoolDepth); - -/** - * @brief Driver cleanup code. - * - * @retval 0 on success, nonzero if still in use - */ -int -nfsCleanup(void); - -/** - * @brief Dump a list of the currently mounted NFS to a file. - * - * Dump a list of the currently mounted NFS to a file - * (stdout is used in case f==NULL) - */ -int -nfsMountsShow(FILE *f); - -/** - * @brief Filesystem mount table mount handler. - * - * Filesystem mount table mount handler. Do not call, use the mount call. - */ -int -rtems_nfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data); - -/** - * @brief A utility routine to find the path leading to a - * rtems_filesystem_location_info_t node. - * - * This should really be present in libcsupport... - * - * @param[in] 'loc' and a buffer 'buf' (length 'len') to hold the path. - * - * @param[out] path copied into 'buf' - * - * @retval 0 on success, RTEMS error code on error. - */ -rtems_status_code -rtems_filesystem_resolve_location(char *buf, int len, rtems_filesystem_location_info_t *loc); - -/** - * @brief Set the timeout (initial default: 10s) for NFS and mount calls. - * - * Set the timeout (initial default: 10s) for NFS and mount calls. - * - * @retval 0 on success, nonzero if the requested timeout is less than - * a clock tick or if the system clock rate cannot be determined. - */ - -int -nfsSetTimeout(uint32_t timeout_ms); - -/** Read current timeout (in milliseconds) */ -uint32_t -nfsGetTimeout(void); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif diff --git a/cpukit/libfs/src/pipe/pipe.h b/cpukit/libfs/src/pipe/pipe.h deleted file mode 100644 index 7c6566ad50..0000000000 --- a/cpukit/libfs/src/pipe/pipe.h +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @file - * - * @brief POSIX FIFO/pipe File System Support - * - * This include file defines the interface to the POSIX FIFO/pipe file system - * support. - */ - -/* - * Author: Wei Shen <cquark@gmail.com> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_PIPE_H -#define _RTEMS_PIPE_H - -#include <rtems/libio.h> - -/** - * @defgroup FIFO_PIPE FIFO/Pipe File System Support - * - * @ingroup FileSystemTypesAndMount - * - * @brief Interface to the POSIX FIFO/Pipe File System - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Control block to manage each pipe */ -typedef struct pipe_control { - char *Buffer; - unsigned int Size; - unsigned int Start; - unsigned int Length; - unsigned int Readers; - unsigned int Writers; - unsigned int waitingReaders; - unsigned int waitingWriters; - unsigned int readerCounter; /* incremental counters */ - unsigned int writerCounter; /* for differentiation of successive opens */ - rtems_id Semaphore; - rtems_id readBarrier; /* wait queues */ - rtems_id writeBarrier; -#if 0 - boolean Anonymous; /* anonymous pipe or FIFO */ -#endif -} pipe_control_t; - -/** - * @brief Create an anonymous pipe. - * - * Called by pipe() to create an anonymous pipe. - */ -extern int pipe_create( - int filsdes[2] -); - -/** - * @brief Release a pipe. - * - * Interface to file system close. - * - * *pipep points to pipe control structure. When the last user releases pipe, - * it will be set to NULL. - */ -extern void pipe_release( - pipe_control_t **pipep, - rtems_libio_t *iop -); - -/** - * @brief File system open. - * Interface to file system open. - * - * *pipep points to pipe control structure. If called with *pipep = NULL, - * fifo_open will try allocating and initializing a control structure. If the - * call succeeds, *pipep will be set to address of new control structure. - */ -extern int fifo_open( - pipe_control_t **pipep, - rtems_libio_t *iop -); - -/** - * @brief File system read. - * - * Interface to file system read. - */ -extern ssize_t pipe_read( - pipe_control_t *pipe, - void *buffer, - size_t count, - rtems_libio_t *iop -); - -/** - * @brief File system write. - * - * Interface to file system write. - */ -extern ssize_t pipe_write( - pipe_control_t *pipe, - const void *buffer, - size_t count, - rtems_libio_t *iop -); - -/** - * @brief File system Input/Output control. - * - * Interface to file system ioctl. - */ -extern int pipe_ioctl( - pipe_control_t *pipe, - ioctl_command_t cmd, - void *buffer, - rtems_libio_t *iop -); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-bitmaps.h b/cpukit/libfs/src/rfs/rtems-rfs-bitmaps.h deleted file mode 100644 index 5574339421..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-bitmaps.h +++ /dev/null @@ -1,326 +0,0 @@ -/** - * @file - * - * @brief RTEMS File Systems Bitmap Routines - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Bitmap Routines. - * - * These functions manage bit maps. A bit map consists of the map of bit - * allocated in a block and a search map where a bit represents 32 actual - * bits. The search map allows for a faster search for an available bit as 32 - * search bits can checked in a test. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_BITMAPS_H_) -#define _RTEMS_RFS_BITMAPS_H_ - -#include <rtems/rfs/rtems-rfs-buffer.h> -#include <rtems/rfs/rtems-rfs-file-system-fwd.h> -#include <rtems/rfs/rtems-rfs-trace.h> - -/** - * Define the way the bits are configured. We can have them configured as clear - * being 0 or clear being 1. This does not effect how masks are defined. A mask - * always has a 1 for set and 0 for clear. - */ -#define RTEMS_RFS_BITMAP_CLEAR_ZERO 0 - -#if RTEMS_RFS_BITMAP_CLEAR_ZERO -/* - * Bit set is a 1 and clear is 0. - */ -#define RTEMS_RFS_BITMAP_BIT_CLEAR 0 -#define RTEMS_RFS_BITMAP_BIT_SET 1 -#define RTEMS_RFS_BITMAP_ELEMENT_SET (RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK) -#define RTEMS_RFS_BITMAP_ELEMENT_CLEAR (0) -#define RTEMS_RFS_BITMAP_SET_BITS(_t, _b) ((_t) | (_b)) -#define RTEMS_RFS_BITMAP_CLEAR_BITS(_t, _b) ((_t) & ~(_b)) -#define RTEMS_RFS_BITMAP_TEST_BIT(_t, _b) (((_t) & (1 << (_b))) != 0 ? true : false) -#else -/* - * Bit set is a 0 and clear is 1. - */ -#define RTEMS_RFS_BITMAP_BIT_CLEAR 1 -#define RTEMS_RFS_BITMAP_BIT_SET 0 -#define RTEMS_RFS_BITMAP_ELEMENT_SET (0) -#define RTEMS_RFS_BITMAP_ELEMENT_CLEAR (RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK) -#define RTEMS_RFS_BITMAP_SET_BITS(_t, _b) ((_t) & ~(_b)) -#define RTEMS_RFS_BITMAP_CLEAR_BITS(_t, _b) ((_t) | (_b)) -#define RTEMS_RFS_BITMAP_TEST_BIT(_t, _b) (((_t) & (1 << (_b))) == 0 ? true : false) -#endif - -/** - * Invert a mask. Masks are always 1 for set and 0 for clear. - */ -#define RTEMS_RFS_BITMAP_INVERT_MASK(_mask) (~(_mask)) - -/** - * This is the full mask of the length of the element. A mask is always a 1 for - * set and 0 for clear. It is not effected by the state of - * RTEMS_RFS_BITMAP_CLEAR_ZERO. - */ -#define RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK (0xffffffffUL) - -/** - * The bitmap search window. Searches occur around a seed in either direction - * for half the window. - */ -#define RTEMS_RFS_BITMAP_SEARCH_WINDOW (rtems_rfs_bitmap_element_bits () * 64) - -/** - * A bit in a map. - */ -typedef int32_t rtems_rfs_bitmap_bit; - -/** - * The basic element of a bitmap. A bitmap is manipulated by elements. - */ -typedef uint32_t rtems_rfs_bitmap_element; - -/** - * The power of 2 number of bits in the element. - */ -#define RTEMS_RFS_ELEMENT_BITS_POWER_2 (5) - -/** - * A bitmap or map is an array of bitmap elements. - */ -typedef rtems_rfs_bitmap_element* rtems_rfs_bitmap_map; - -/** - * The bitmap control is a simple way to manage the various parts of a bitmap. - */ -typedef struct rtems_rfs_bitmap_control_s -{ - rtems_rfs_buffer_handle* buffer; //< Handle the to buffer with the bit - //map. - rtems_rfs_file_system* fs; //< The map's file system. - rtems_rfs_buffer_block block; //< The map's block number on disk. - size_t size; //< Number of bits in the map. Passed - //to create. - size_t free; //< Number of bits in the map that are - //free (clear). - rtems_rfs_bitmap_map search_bits; //< The search bit map memory. -} rtems_rfs_bitmap_control; - -/** - * Return the number of bits for the number of bytes provided. - */ -#define rtems_rfs_bitmap_numof_bits(_bytes) (8 * (_bytes)) - -/** - * Return the number of bits for the number of bytes provided. The search - * element and the element must have the same number of bits. - */ -#define rtems_rfs_bitmap_element_bits() \ - rtems_rfs_bitmap_numof_bits (sizeof (rtems_rfs_bitmap_element)) - -/** - * Return the number of bits a search element covers. - */ -#define rtems_rfs_bitmap_search_element_bits() \ - (rtems_rfs_bitmap_element_bits() * rtems_rfs_bitmap_element_bits()) - -/** - * Return the number of elements for a given number of bits. - */ -#define rtems_rfs_bitmap_elements(_bits) \ - ((((_bits) - 1) / rtems_rfs_bitmap_element_bits()) + 1) - -/** - * Release the bitmap buffer back to the buffer pool or cache. - */ -#define rtems_rfs_bitmap_release_buffer(_fs, _bm) \ - rtems_rfs_buffer_handle_release (_fs, (_bm)->buffer) - -/** - * Return the element index for a given bit. We use a macro to hide any - * implementation assuptions. Typically this would be calculated by dividing - * the bit index by the number of bits in an element. Given we have a power of - * 2 as the number of bits we can avoid the division by using a shift. A good - * compiler should figure this out but I would rather enforce this than rely on - * the specific backend of a compiler to do the right thing. - */ -#define rtems_rfs_bitmap_map_index(_b) \ - ((_b) >> RTEMS_RFS_ELEMENT_BITS_POWER_2) - -/** - * Return the bit offset for a given bit in an element in a map. See @ref - * rtems_rfs_bitmap_map_index for a detailed reason why. - */ -#define rtems_rfs_bitmap_map_offset(_b) \ - ((_b) & ((1 << RTEMS_RFS_ELEMENT_BITS_POWER_2) - 1)) - -/** - * Return the size of the bitmap. - */ -#define rtems_rfs_bitmap_map_size(_c) ((_c)->size) - -/** - * Return the number of free bits in the bitmap. - */ -#define rtems_rfs_bitmap_map_free(_c) ((_c)->free) - -/** - * Return the buffer handle. - */ -#define rtems_rfs_bitmap_map_handle(_c) ((_c)->buffer) - -/** - * Return the bitmap map block. - */ -#define rtems_rfs_bitmap_map_block(_c) ((_c)->block) - -/** - * Create a bit mask with the specified number of bits up to an element's - * size. The mask is aligned to bit 0 of the element. - * - * @param[in] size is the number of bits in the mask. - * - * @return The mask of the argument size number of bits. - */ -rtems_rfs_bitmap_element rtems_rfs_bitmap_mask (unsigned int size); - -/** - * Create a bit mask section. A mask section is a mask that is not aligned to - * an end of the element. - * - * @param[in] start is the first bit of the mask numbered from 0. - * @param[in] end is the end bit of the mask numbered from 0. - * - * @return Mask section as defined by the start and end arguments. - */ -rtems_rfs_bitmap_element rtems_rfs_bitmap_mask_section (unsigned int start, - unsigned int end); - -/** - * Set a bit in a map and if all the bits are set, set the search map bit as - * well. - * - * @param[in] control is the control for the map. - * @param[in] bit is the bit in the map to set. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_map_set (rtems_rfs_bitmap_control* control, - rtems_rfs_bitmap_bit bit); - -/** - * Clear a bit in a map and make sure the search map bit is clear so a search - * will find this bit available. - * - * @param[in] control is the control for the map. - * @param[in] bit is the bit in the map to clear. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_map_clear (rtems_rfs_bitmap_control* control, - rtems_rfs_bitmap_bit bit); - -/** - * Test a bit in the map. - * - * @param[in] control is the bitmap control. - * @param[in] bit is the bit to test. - * @param[in] state is the state of the bit if no error is returned. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int -rtems_rfs_bitmap_map_test (rtems_rfs_bitmap_control* control, - rtems_rfs_bitmap_bit bit, - bool* state); - -/** - * Set all bits in the bitmap and set the dirty bit. - * - * @param[in] control is the bitmap control. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_map_set_all (rtems_rfs_bitmap_control* control); - -/** - * Clear all bits in the bitmap and set the dirty bit. - * - * @param[in] control is the bitmap control. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_map_clear_all (rtems_rfs_bitmap_control* control); - -/** - * Find a free bit searching from the seed up and down until found. The search - * is performing by moving up from the seed for the window distance then to - * search down from the seed for the window distance. This is repeated out - * from the seed for each window until a free bit is found. The search is - * performed by checking the search map to see if the map has a free bit. - * - * @param[in] control is the map control. - * @param[in] seed is the bit to search out from. - * @param[out] allocate A bit was allocated. - * @param[out] bit will contain the bit found free if true is returned. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_map_alloc (rtems_rfs_bitmap_control* control, - rtems_rfs_bitmap_bit seed, - bool* allocate, - rtems_rfs_bitmap_bit* bit); - -/** - * Create a search bit map from the actual bit map. - * - * @param[in] control is the map control. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_create_search (rtems_rfs_bitmap_control* control); - -/** - * Open a bitmap control with a map and search map. - * - * @param[in] control is the map control. - * @param[in] fs is the file system data. - * @param[in] buffer is a pointer to the buffer handle the map is - * stored in. - * @param[in] size is the number of bits in the map. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_open (rtems_rfs_bitmap_control* control, - rtems_rfs_file_system* fs, - rtems_rfs_buffer_handle* buffer, - size_t size, - rtems_rfs_buffer_block block); - -/** - * Close a bitmap. - * - * @param[in] control is the bit map control. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_close (rtems_rfs_bitmap_control* control); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-block-pos.h b/cpukit/libfs/src/rfs/rtems-rfs-block-pos.h deleted file mode 100644 index 7d0f0693be..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-block-pos.h +++ /dev/null @@ -1,242 +0,0 @@ -/** - * @file - * - * @brief RTEMS File Systems Block Position and Size Management - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Block Position and Size Management. - * - * These functions manage the position in a block map as well as a size of data - * held in a block map. The position is the block count plus the offset into - * the last block where a block position of 0 and an offset of 0 is the start - * of a map. The size has a block count plus an offset, but the offset into the - * last block gives the actual size of the data in the map. This means a size - * will always have a block count greater than 0 when the file is not empty. A - * size offset of 0 and a non-zero block count means the length if aligned to - * the end of the block. For this reason there are 2 similar types so we know - * which set of rules are in use and the reason for this file. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_BLOCK_POS_H_) -#define _RTEMS_RFS_BLOCK_POS_H_ - -#include <rtems/rfs/rtems-rfs-file-system.h> -#include <rtems/rfs/rtems-rfs-inode.h> - -/** - * The block number is the same type as the inode block number. This makes sure - * the sizes of the types match. - */ -typedef rtems_rfs_inode_block rtems_rfs_block_no; - -/** - * The offset into a block. - */ -typedef uint32_t rtems_rfs_block_off; - -/** - * A block position is a block number times the block size plus the offset. The - * block field can be used hold a block number for the position as a look up - * cache. - */ -typedef struct rtems_rfs_block_pos_s -{ - /** - * The block index in the map. Range is from 0 to the maps block count minus - * 1. - */ - rtems_rfs_block_no bno; - - /** - * The offset into the block. Must be less than the block size. - */ - rtems_rfs_block_off boff; - - /** - * The block number that the bpos + boff map to. The 0 value is invalid and - * means no block number has been set. - */ - rtems_rfs_block_no block; - -} rtems_rfs_block_pos; - -/** - * Copy a block position. - * - * @param[in] _lhs is the left hand side. - * @param[in] _rhs is the right hand side. - */ -#define rtems_rfs_block_copy_bpos(_lhs, _rhs) \ - do { (_lhs)->bno = (_rhs)->bno; \ - (_lhs)->boff = (_rhs)->boff; \ - (_lhs)->block = (_rhs)->block; } while (0) - -/** - * Zero a block position. - * - * @param[in] bpos is a pointer to the block position. - */ -static inline void -rtems_rfs_block_set_bpos_zero (rtems_rfs_block_pos* bpos) -{ - bpos->bno = 0; - bpos->boff = 0; - bpos->block = 0; -} - -/** - * Given a position compute the block number and block offset. - * - * @param[in] fs is the file system data. - * @param[in] pos is the position as an absolute offset from the start. - * @param[out] bpos is a pointer to the block position to fill in. - */ -void rtems_rfs_block_get_bpos (rtems_rfs_file_system* fs, - rtems_rfs_pos pos, - rtems_rfs_block_pos* bpos); - -/** - * Given a block position compute the absolute offset. - * - * @param[in] fs is the file system data. - * @param[out] bpos is a pointer to the block position to fill in. - * - * @retval offset The absolute offset. - */ -rtems_rfs_pos rtems_rfs_block_get_pos (rtems_rfs_file_system* fs, - rtems_rfs_block_pos* bpos); - -/** - * Add the relative position to the block position. The relative position is - * signed. - * - * @param[in] fs is the file system data. - * @param[in] offset is the relative offset add to the block position. - * @param[out] bpos is a pointer to the block position to fill in. - */ -static inline void -rtems_rfs_block_add_pos (rtems_rfs_file_system* fs, - rtems_rfs_pos_rel offset, - rtems_rfs_block_pos* bpos) -{ - rtems_rfs_block_get_bpos (fs, - rtems_rfs_block_get_pos (fs, bpos) + offset, - bpos); - bpos->block = 0; -} - -/** - * A block size is the number of blocks less one plus the offset where the - * offset must be less than the block size. - */ -typedef struct rtems_rfs_block_size_s -{ - /** - * The count of blocks in a map. A 0 means no blocks and a zero length and - * the offset should also be 0. - */ - rtems_rfs_block_no count; - - /** - * The offset into the block. An offset of 0 means block size, ie the first - * byte of the next block which is not allocated. - */ - rtems_rfs_block_off offset; - -} rtems_rfs_block_size; - -/** - * Copy a block size. - * - * @param[in] _lhs is the left hand side. - * @param[in] _rhs is the right hand side. - */ -#define rtems_rfs_block_copy_size(_lhs, _rhs) \ - do { (_lhs)->count = (_rhs)->count; \ - (_lhs)->offset = (_rhs)->offset; } while (0) - -/** - * Last block ? - */ -#define rtems_rfs_block_pos_last_block(_p, _s) \ - ((((_p)->bno == 0) && ((_s)->count == 0)) || ((_p)->bno == ((_s)->count - 1))) - -/** - * Last block ? - */ -#define rtems_rfs_block_pos_past_end(_p, _s) \ - (((_p)->bno && ((_s)->count == 0)) || \ - ((_p)->bno >= (_s)->count) || \ - (((_p)->bno == ((_s)->count - 1)) && ((_p)->boff > (_s)->offset))) - -/** - * Is the block position past the end. - */ -#define rtems_rfs_block_pos_block_past_end(_p, _s) \ - (((_p)->bno && ((_s)->count == 0)) || ((_p)->bno >= (_s)->count)) - -/** - * Copy the size to the block position. Note the block position and the size - * have different block counts. - */ -#define rtems_rfs_block_size_get_bpos(_s, _b) \ - do { (_b)->bno = (_s)->count; \ - (_b)->boff = (_s)->offset; \ - (_b)->block = 0; \ - if ((_b)->boff) --(_b)->bno; } while (0) - -/** - * Do the sizes match ? - */ -#define rtems_rfs_block_size_equal(_lhs, _rhs) \ - (((_lhs)->count == (_rhs)->count) && ((_lhs)->offset == (_rhs)->offset)) - -/** - * Zero a block size. - * - * @param[in] size is a pointer to the block size. - */ -static inline void -rtems_rfs_block_set_size_zero (rtems_rfs_block_size* size) -{ - size->count = 0; - size->offset = 0; -} - -/** - * Set the size given a position. - * - * @param[in] fs is the file system data. - * @param[in] pos is the position as an absolute offset from the start. - * @param[out] size is a pointer to the block size to fill in. - */ -void rtems_rfs_block_get_block_size (rtems_rfs_file_system* fs, - rtems_rfs_pos pos, - rtems_rfs_block_size* size); - -/** - * Calculate the position given the number of blocks and the offset. If the - * block count is 0 the size is 0. If the block is greater than 0 and the - * offset is 0 the size is number of blocks multipled by the block size and if - * the offset is not 0 it is the offset into the last block. For example if - * blocks is 1 and offset is 0 the size is the block size. If the block count - * is 1 and size is 100 the size is 100. - * - * @param[in] fs is the file system data. - * @param[in] size The size in blocks and offset. - * - * @retval size The size in bytes. - */ -rtems_rfs_pos rtems_rfs_block_get_size (rtems_rfs_file_system* fs, - rtems_rfs_block_size* size); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-block.h b/cpukit/libfs/src/rfs/rtems-rfs-block.h deleted file mode 100644 index 394853b7ad..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-block.h +++ /dev/null @@ -1,344 +0,0 @@ -/** - * @file - * - * @brief RTEMS File Systems Block Management - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Block Management. - * - * These functions manage the blocks used in the file system. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_BLOCK_H_) -#define _RTEMS_RFS_BLOCK_H_ - -#include <rtems/rfs/rtems-rfs-block-pos.h> -#include <rtems/rfs/rtems-rfs-buffer.h> -#include <rtems/rfs/rtems-rfs-data.h> -#include <rtems/rfs/rtems-rfs-file-system.h> - -/** - * Get a block number in the media format and return it in the host format. - * - * @param[in] _h is the buffer handle of the block. - * @param[in] _b is the block number index. - * - * @retval block The block number. - */ -#define rtems_rfs_block_get_number(_h, _b) \ - ((rtems_rfs_block_no) \ - (rtems_rfs_read_u32 (rtems_rfs_buffer_data (_h) + \ - ((_b) * sizeof (rtems_rfs_block_no))))) - -/** - * Set a block number in the media format given a number in the host format. - * - * @param[in] _h is the buffer handle of the block. - * @param[in] _b is the block number index, ie the number of block number not the - * buffer offset. - * @param[in] _n is the block number. - */ -#define rtems_rfs_block_set_number(_h, _b, _n) \ - do { \ - rtems_rfs_write_u32 (rtems_rfs_buffer_data (_h) + \ - ((_b) * sizeof (rtems_rfs_block_no)), (_n)); \ - rtems_rfs_buffer_mark_dirty (_h); \ - } while (0) - -/** - * A block map manges the block lists that originate from an inode. The inode - * contains a number of block numbers. A block map takes those block numbers - * and manages them. - * - * The blocks cannot have all ones as a block number nor block 0. The block map - * is series of block numbers in a blocks. The size of the map determines the - * way the block numbers are stored. The map uses the following: - * - * @li @e Direct Access, - * @li @e Single Indirect Access, and - * @li @e Double Indirect Access. - * - * Direct access has the blocks numbers in the inode slots. The Single Indirect - * Access has block numbers in the inode slots that pointer to a table of block - * numbers that point to data blocks. The Double Indirect Access has block - * numbers in the inode that point to Single Indirect block tables. - * - * The inode can hold a number of Direct, Single Indirect, and Double Indirect - * block tables. The move from Direct to Single occurs then the block count in - * the map is above the number of slots in the inode. The move from Single to - * Double occurs when the map block count is greated than the block numbers per - * block multipled by the slots in the inode. The move from Single to Double - * occurs when the map block count is over the block numbers per block squared - * multipled by the number of slots in the inode. - * - * The block map can managed files of the follow size verses block size with 5 - * inode slots: - * - * @li 41,943,040 bytes for a 512 byte block size, - * @li 335,544,320 bytes for a 1024 byte block size, - * @li 2,684,354,560 bytes for a 2048 byte block size, and - * @li 21,474,836,480 bytes for a 4096 byte block size. - */ -typedef struct rtems_rfs_block_map_s -{ - /** - * Is the map dirty ? - */ - bool dirty; - - /** - * The inode this map is attached to. - */ - rtems_rfs_inode_handle* inode; - - /** - * The size of the map. - */ - rtems_rfs_block_size size; - - /** - * The block map position. Used to navigate the map when seeking. The find - * call is to a position in the file/directory and is a block number plus - * offset. The block find only needs to locate a block and not worry about - * the offset while a seek can be less than a block size yet move across a - * block boundary. Therefore the position a block map has to maintain must - * include the offset so seeks work. - */ - rtems_rfs_block_pos bpos; - - /** - * The last map block allocated. This is used as the goal when allocating a - * new map block. - */ - rtems_rfs_block_no last_map_block; - - /** - * The last data block allocated. This is used as the goal when allocating a - * new data block. - */ - rtems_rfs_block_no last_data_block; - - /** - * The block map. - */ - uint32_t blocks[RTEMS_RFS_INODE_BLOCKS]; - - /** - * Singly Buffer handle. - */ - rtems_rfs_buffer_handle singly_buffer; - - /** - * Doubly Buffer handle. - */ - rtems_rfs_buffer_handle doubly_buffer; - -} rtems_rfs_block_map; - -/** - * Is the map dirty ? - */ -#define rtems_rfs_block_map_is_dirty(_m) ((_m)->dirty) - -/** - * Return the block count in the map. - */ -#define rtems_rfs_block_map_count(_m) ((_m)->size.count) - -/** - * Return the map's size element. - */ -#define rtems_rfs_block_map_size(_m) (&((_m)->size)) - -/** - * Return the size offset for the map. - */ -#define rtems_rfs_block_map_size_offset(_m) ((_m)->size.offset) - -/** - * Are we at the last block in the map ? - */ -#define rtems_rfs_block_map_last(_m) \ - rtems_rfs_block_pos_last_block (&(_m)->bpos, &(_m)->size) - -/** - * Is the position past the end of the block ? - */ -#define rtems_rfs_block_map_past_end(_m, _p) \ - rtems_rfs_block_pos_past_end (_p, &(_m)->size) - -/** - * Return the current position in the map. - */ -#define rtems_rfs_block_map_pos(_f, _m) \ - rtems_rfs_block_get_pos (_f, &(_m)->bpos) - -/** - * Return the map's current block number. - */ -#define rtems_rfs_block_map_block(_m) ((_m)->bpos.bno) - -/** - * Return the map's current block offset. - */ -#define rtems_rfs_block_map_block_offset(_m) ((_m)->bpos.boff) - -/** - * Set the size offset for the map. The map is tagged as dirty. - * - * @param[in] map is a pointer to the open map to set the offset in. - * @param[in] offset is the offset to set in the map's size. - */ -static inline void -rtems_rfs_block_map_set_size_offset (rtems_rfs_block_map* map, - rtems_rfs_block_off offset) -{ - map->size.offset = offset; - map->dirty = true; -} - -/** - * Set the map's size. The map is tagged as dirty. - * - * @param[in] map is a pointer to the open map to set the offset in. - * @param[in] size is the size to set in the map's size. - */ -static inline void -rtems_rfs_block_map_set_size (rtems_rfs_block_map* map, - rtems_rfs_block_size* size) -{ - rtems_rfs_block_copy_size (&map->size, size); - map->dirty = true; -} -/** - * Open a block map. The block map data in the inode is copied into the - * map. The buffer handles are opened. The block position is set to the start - * so a seek of offset 0 will return the first block. - * - * @param[in] fs is the file system data. - * @param[in] inode is a pointer to the inode the map belongs to. - * @param[in] map is a pointer to the map that is opened. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_open (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* inode, - rtems_rfs_block_map* map); - -/** - * Close the map. The buffer handles are closed and any help buffers are - * released. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the map that is opened. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_close (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map); - -/** - * Find a block number in the map from the position provided. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the map to search. - * @param[in] bpos is a pointer to the block position to find. - * @param[out] block will contain the block in when found. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_find (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map, - rtems_rfs_block_pos* bpos, - rtems_rfs_buffer_block* block); - -/** - * Seek around the map. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the map to search. - * @param[in] offset is the distance to seek. It is signed. - * @param[out] block will contain the block in when found. - * - * @retval 0 Successful operation. - * @retval ENXIO Failed to seek because it is outside the block map. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_seek (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map, - rtems_rfs_pos_rel offset, - rtems_rfs_buffer_block* block); - -/** - * Seek to the next block. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the map to search. - * @param[out] block will contain the block in when found. - * - * @retval 0 Successful operation. - * @retval ENXIO Failed to seek because it is outside the block map. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_next_block (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map, - rtems_rfs_buffer_block* block); - -/** - * Grow the block map by the specified number of blocks. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the open map to grow. - * @param[in] blocks is the number of blocks to grow the map by. - * @param[out] new_block will contain first of the blocks allocated - * to the map. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_grow (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map, - size_t blocks, - rtems_rfs_block_no* new_block); - -/** - * Grow the block map by the specified number of blocks. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the open map to shrink. - * @param[in] blocks is the number of blocks to shrink the map by. If more - * than the number of blocks the map is emptied. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_shrink (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map, - size_t blocks); - -/** - * Free all blocks in the map. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the open map to free all blocks from. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_free_all (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-buffer.h b/cpukit/libfs/src/rfs/rtems-rfs-buffer.h deleted file mode 100644 index 1c603e1827..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-buffer.h +++ /dev/null @@ -1,283 +0,0 @@ -/** - * @file - * - * @ingroup rtems_rfs - * - * @brief Maps Blocks to the Media Interface Layers - * - * These functions map blocks to the media interface layers. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_BUFFER_H_) -#define _RTEMS_RFS_BUFFER_H_ - -#include <errno.h> - -#include <rtems/rfs/rtems-rfs-file-system-fwd.h> -#include <rtems/rfs/rtems-rfs-trace.h> - -/** - * Define the method used to interface to the buffers. It can be libblock or - * device I/O. The libblock interface is to the RTEMS cache and block devices - * and device I/O accesses the media via a device file handle. - */ -#if defined (__rtems__) -#define RTEMS_RFS_USE_LIBBLOCK 1 -#endif - -/** - * The RTEMS RFS I/O Layering. - */ -#if RTEMS_RFS_USE_LIBBLOCK -#include <rtems/bdbuf.h> -#include <rtems/error.h> - -typedef rtems_blkdev_bnum rtems_rfs_buffer_block; -typedef rtems_bdbuf_buffer rtems_rfs_buffer; -#define rtems_rfs_buffer_io_request rtems_rfs_buffer_bdbuf_request -#define rtems_rfs_buffer_io_release rtems_rfs_buffer_bdbuf_release - -/** - * Request a buffer from the RTEMS libblock BD buffer cache. - */ -int rtems_rfs_buffer_bdbuf_request (rtems_rfs_file_system* fs, - rtems_rfs_buffer_block block, - bool read, - rtems_rfs_buffer** buffer); -/** - * Release a buffer to the RTEMS libblock BD buffer cache. - */ -int rtems_rfs_buffer_bdbuf_release (rtems_rfs_buffer* handle, - bool modified); -#else /* Device I/O */ -typedef uint32_t rtems_rfs_buffer_block; -typedef struct _rtems_rfs_buffer -{ - rtems_chain_node link; - rtems_rfs_buffer_block user; - void* buffer; - size_t size; - uint32_t references; -} rtems_rfs_buffer; -#define rtems_rfs_buffer_io_request rtems_rfs_buffer_deviceio_request -#define rtems_rfs_buffer_io_release rtems_rfs_buffer_deviceio_release - -/** - * Request a buffer from the device I/O. - */ -int rtems_rfs_buffer_deviceio_request (rtems_rfs_file_system* fs, - rtems_rfs_buffer_block block, - bool read, - rtems_rfs_buffer* buffer); -/** - * Release a buffer to the RTEMS libblock BD buffer cache. - */ -int rtems_rfs_buffer_deviceio_release (rtems_rfs_buffer* handle, - bool modified); -#endif - -/** - * RFS Buffer handle. - */ -typedef struct rtems_rfs_buffer_handle_t -{ - /** - * Has the buffer been modifed? - */ - bool dirty; - - /** - * Block number. The lower layer block number may be absolute and we maybe - * relative to an offset in the disk so hold locally. - */ - rtems_rfs_buffer_block bnum; - - /** - * Reference the buffer descriptor. - */ - rtems_rfs_buffer* buffer; - -} rtems_rfs_buffer_handle; - -/** - * The buffer linkage. - */ -#define rtems_rfs_buffer_link(_h) (&(_h)->buffer->link) - -/** - * Return the start of the data area of the buffer given a handle. - */ -#define rtems_rfs_buffer_data(_h) ((void*)((_h)->buffer->buffer)) - -/** - * Return the size of the buffer given a handle. - */ -#define rtems_rfs_buffer_size(_h) ((_h)->buffer->size) - -/** - * Return the block number. - */ -#define rtems_rfs_buffer_bnum(_h) ((_h)->bnum) - -/** - * Return the buffer dirty status. - */ -#define rtems_rfs_buffer_dirty(_h) ((_h)->dirty) - -/** - * Does the handle have a valid block attached ? - */ -#define rtems_rfs_buffer_handle_has_block(_h) ((_h)->buffer ? true : false) - -/** - * Mark the buffer as dirty. - */ -#define rtems_rfs_buffer_mark_dirty(_h) ((_h)->dirty = true) - -/** - * Return the reference count. - */ -#define rtems_rfs_buffer_refs(_h) ((_h)->buffer->references) - -/** - * Increment the reference count. - */ -#define rtems_rfs_buffer_refs_up(_h) ((_h)->buffer->references += 1) - -/** - * Decrement the reference count. - */ -#define rtems_rfs_buffer_refs_down(_h) ((_h)->buffer->references -= 1) - -/** - * Request a buffer. The buffer can be filled with data from the media - * (read == true) or you can request a buffer to fill with data. - * - * @param[in] fs is the file system data. - * @param[in] handle is the handle the requested buffer is attached to. - * @param[in] block is the block number. - * @param[in] read Read the data from the disk. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_handle_request (rtems_rfs_file_system* fs, - rtems_rfs_buffer_handle* handle, - rtems_rfs_buffer_block block, - bool read); - -/** - * Release a buffer. If the buffer is dirty the buffer is written to disk. The - * result does not indicate if the data was successfully written to the disk as - * this operation may be performed in asynchronously to this release. - * - * @param[in] fs is the file system data. - * @param[in] handle is the handle the requested buffer is attached to. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_handle_release (rtems_rfs_file_system* fs, - rtems_rfs_buffer_handle* handle); - -/** - * Open a handle. - * - * @param[in] fs i the file system data. - * @param[in] handle i the buffer handle to open. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -static inline int -rtems_rfs_buffer_handle_open (rtems_rfs_file_system* fs, - rtems_rfs_buffer_handle* handle) -{ - handle->dirty = false; - handle->bnum = 0; - handle->buffer = NULL; - return 0; -} - -/** - * Close a handle. - * - * @param[in] fs is the file system data. - * @param[in] handle is the buffer handle to close. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -static inline int -rtems_rfs_buffer_handle_close (rtems_rfs_file_system* fs, - rtems_rfs_buffer_handle* handle) -{ - rtems_rfs_buffer_handle_release (fs, handle); - handle->dirty = false; - handle->bnum = 0; - handle->buffer = NULL; - return 0; -} - -/** - * Open the buffer interface. - * - * @param[in] name is a pointer to the device name to the media. - * @param[in] fs is the file system data. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_open (const char* name, rtems_rfs_file_system* fs); - -/** - * Close the buffer interface. - * - * @param[in] fs is the file system data. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_close (rtems_rfs_file_system* fs); - -/** - * Sync all buffers to the media. - * - * @param[in] fs is the file system data. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_sync (rtems_rfs_file_system* fs); - -/** - * Set the block size of the device. - * - * @param[in] fs is the file system data. - * @param[in] size is the new block size. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_setblksize (rtems_rfs_file_system* fs, uint32_t size); - -/** - * Release any chained buffers. - * - * @param[in] fs is the file system data. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffers_release (rtems_rfs_file_system* fs); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-data.h b/cpukit/libfs/src/rfs/rtems-rfs-data.h deleted file mode 100644 index 6217e74587..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-data.h +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Data - * - * @ingroup rtems_rfs - * - * RTEMS File System Data. - * - * Access data in the correct byte order for the specific target we are running - * on. - * - * @todo Make direct access on matching byte ordered targets. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_DATA_H_) -#define _RTEMS_RFS_DATA_H_ - -#include <stdint.h> - -/** - * Helper function to make sure we have a byte pointer. - */ -#define rtems_rfs_data_ptr(_d) ((uint8_t*)(_d)) - -/** - * Helper function to get the data shifted in the correctly sized type. - */ -#define rtems_rfs_data_get(_d, _t, _o, _s) \ - (((_t)(rtems_rfs_data_ptr (_d)[_o])) << (_s)) - -/** - * RFS Read Unsigned 8bit Integer - */ -#define rtems_rfs_read_u8(_d) \ - (*rtems_rfs_data_ptr (_d)) - -/** - * RFS Read Unsigned 16bit Integer - */ -#define rtems_rfs_read_u16(_d) \ - (rtems_rfs_data_get (_d, uint16_t, 0, 8) | \ - rtems_rfs_data_get (_d, uint16_t, 1, 0)) - -/** - * RFS Read Unsigned 32bit Integer - */ -#define rtems_rfs_read_u32(_d) \ - (rtems_rfs_data_get (_d, uint32_t, 0, 24) | \ - rtems_rfs_data_get (_d, uint32_t, 1, 16) | \ - rtems_rfs_data_get (_d, uint32_t, 2, 8) | \ - rtems_rfs_data_get (_d, uint32_t, 3, 0)) - -/** - * RFS Write Unsigned 8bit Integer - */ -#define rtems_rfs_write_u8(_d, _v) \ - (*rtems_rfs_data_ptr (_d) = (uint8_t)(_v)) - -/** - * RFS Write Unsigned 16bit Integer - */ -#define rtems_rfs_write_u16(_d, _v) \ - do { \ - rtems_rfs_data_ptr (_d)[0] = (uint8_t)(((uint16_t)(_v)) >> 8); \ - rtems_rfs_data_ptr (_d)[1] = (uint8_t)((_v)); \ - } while (0) - -/** - * RFS Write Unsigned 32bit Integer - */ -#define rtems_rfs_write_u32(_d, _v) \ - do { \ - rtems_rfs_data_ptr (_d)[0] = (uint8_t)(((uint32_t)(_v)) >> 24); \ - rtems_rfs_data_ptr (_d)[1] = (uint8_t)(((uint32_t)(_v)) >> 16); \ - rtems_rfs_data_ptr (_d)[2] = (uint8_t)(((uint32_t)(_v)) >> 8); \ - rtems_rfs_data_ptr (_d)[3] = (uint8_t)((uint32_t)(_v)); \ - } while (0) - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-dir-hash.h b/cpukit/libfs/src/rfs/rtems-rfs-dir-hash.h deleted file mode 100644 index d9a8a2004f..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-dir-hash.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file - * - * @brief Provides a 32bit Hash of a String used to Search a Directory - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Directory Hash provides a 32bit hash of a string. This is - * used to search a directory. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_DIR_HASH_H_) -#define _RTEMS_RFS_DIR_HAS_H_ - -#include <stddef.h> -#include <stdint.h> - -/** - * Compute a hash of the key over the length of string. - * - * @param[in] key is a pointer to the key to calculate the hash of. - * @param[in] length is the length of the key in bytes. - * - * @retval hash The computed uint32_t hash. - */ -uint32_t rtems_rfs_dir_hash (const void *key, size_t length); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-dir.h b/cpukit/libfs/src/rfs/rtems-rfs-dir.h deleted file mode 100644 index ae3647d03c..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-dir.h +++ /dev/null @@ -1,209 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Directory Support - * - * @ingroup rtems_rfs - * - * RTEMS File System Directory Support - * - * This file provides the directory support functions. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_DIR_H_) -#define _RTEMS_RFS_DIR_H_ - -#include <dirent.h> - -#include <rtems/libio_.h> - -#include <rtems/rfs/rtems-rfs-data.h> -#include <rtems/rfs/rtems-rfs-file-system.h> -#include <rtems/rfs/rtems-rfs-inode.h> - -/** - * Define the offsets of the fields of a directory entry. - */ -#define RTEMS_RFS_DIR_ENTRY_INO (0) /**< The ino offset in a directory - * entry. */ -#define RTEMS_RFS_DIR_ENTRY_HASH (4) /**< The hash offset in a directory - * entry. The hash is 32bits. We need at - * least 16bits and given the length and - * ino field are 4 the extra 2 bytes is - * not a big overhead.*/ -#define RTEMS_RFS_DIR_ENTRY_LEN (8) /**< The length offset in a directory - * entry. */ - -/** - * The length of the directory entry header. - */ -#define RTEMS_RFS_DIR_ENTRY_SIZE (4 + 4 + 2) - -/** - * The length when the remainder of the directory block is empty. - */ -#define RTEMS_RFS_DIR_ENTRY_EMPTY (0xffff) - -/** - * Return the hash of the entry. - * - * @param[in] _e is a pointer to the directory entry. - * - * @retval hash The uint32_t hash of the entry. - */ -#define rtems_rfs_dir_entry_hash(_e) \ - rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH) - -/** - * Set the hash of the entry. - * - * @param[in] _e is a pointer to the directory entry. - * - * @param[in] _h is the hash of the entry. - */ -#define rtems_rfs_dir_set_entry_hash(_e, _h) \ - rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH, _h) - -/** - * Return the ino of the entry. - * - * @param[in] _e is a pointer to the directory entry. - * - * @retval ino The ino of the entry. - */ -#define rtems_rfs_dir_entry_ino(_e) \ - rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO) - -/** - * Set the ino of the entry. - * - * @param[in] _e is a pointer to the directory entry. - * - * @param[in] _i is the ino of the entry. - */ -#define rtems_rfs_dir_set_entry_ino(_e, _i) \ - rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO, _i) - -/** - * Return the length of the entry. - * - * @param[in] _e Pointer to the directory entry. - * - * @retval length The length of the entry. - */ -#define rtems_rfs_dir_entry_length(_e) \ - rtems_rfs_read_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN) - -/** - * Set the length of the entry. - * - * @param[in] _e is a pointer to the directory entry. - * @param[in] _l is the length. - */ -#define rtems_rfs_dir_set_entry_length(_e, _l) \ - rtems_rfs_write_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN, _l) - -/** - * Look up a directory entry in the directory pointed to by the inode. The look - * up is local to this directory. No need to decend. - * - * @param[in] fs is the file system. - * @param[in] inode is a pointer to the inode of the directory to search. - * @param[in] name is a pointer to the name to look up. The name may not be - * nul terminated. - * @param[in] length is the length of the name. - * @param[out] ino will be filled in with the inode number - * if there is no error. - * @param[in] offset is the offset in the directory for the entry. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_dir_lookup_ino (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* inode, - const char* name, - int length, - rtems_rfs_ino* ino, - uint32_t* offset); - -/** - * Add an entry to the directory returing the inode number allocated to the - * entry. - * - * @param[in] fs is the file system data. - * @param[in] dir is a pointer to the directory inode the - * entry is to be added too. - * @param[in] name is a pointer to the name of the entry to be added. - * @param[in] length is the length of the name excluding a terminating 0. - * @param[in] ino is the ino of the entry. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_dir_add_entry (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* dir, - const char* name, - size_t length, - rtems_rfs_ino ino); - -/** - * Del an entry from the directory using an inode number as a key. - * - * @param[in] fs is the file system data. - * @param[in] dir is a pointer to the directory inode the - * entry is to be deleted from. - * @param[in] ino is the ino of the entry. - * @param[in] offset is the offset in the directory of the entry - * to delete. If 0 search from the start for the ino. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* dir, - rtems_rfs_ino ino, - uint32_t offset); - -/** - * Read the directory entry from offset into the directory entry buffer and - * return the length of space this entry uses in the directory table. - * - * @param[in] fs is the file system data. - * @param[in] dir is a pointer to the direct inode handler. - * @param[in] offset is the offset in the directory to read from. - * @param[in] dirent is a ointer to the dirent structure the entry - * is written into. - * @param[out] length will contain the length this entry - * takes in the directory. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_dir_read (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* dir, - rtems_rfs_pos_rel offset, - struct dirent* dirent, - size_t* length); - -/** - * Check if the directory is empty. The current and parent directory entries - * are ignored. - * - * @param[in] fs is the file system data - * @param[in] dir is a pointer to the directory inode to check. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_dir_empty (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* dir); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-file-system-fwd.h b/cpukit/libfs/src/rfs/rtems-rfs-file-system-fwd.h deleted file mode 100644 index e239c25d6f..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-file-system-fwd.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @file - * - * @brief RTEMS File Systems Data Forward Declaration - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Data forward decl. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_FILE_SYSTEM_FWD_H_) -#define _RTEMS_RFS_FILE_SYSTEM_FWD_H_ - -/** - * Forward reference to the file system data. - */ -struct _rtems_rfs_file_system; -typedef struct _rtems_rfs_file_system rtems_rfs_file_system; - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-file-system.h b/cpukit/libfs/src/rfs/rtems-rfs-file-system.h deleted file mode 100644 index e00b142532..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-file-system.h +++ /dev/null @@ -1,410 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Data - * - * @ingroup rtems_rfs - * - * RTEMS File System Data - * - * This file defines the file system data. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_FILE_SYSTEM_H_) -#define _RTEMS_RFS_FILE_SYSTEM_H_ - -#include <rtems/rfs/rtems-rfs-group.h> - -/** - * Superblock offsets and values. - */ -#define RTEMS_RFS_SB_OFFSET_MAGIC (0) -#define RTEMS_RFS_SB_MAGIC (0x28092001) -#define RTEMS_RFS_SB_OFFSET_VERSION (RTEMS_RFS_SB_OFFSET_MAGIC + 4) -#define RTEMS_RFS_SB_OFFSET_BLOCK_SIZE (RTEMS_RFS_SB_OFFSET_VERSION + 4) -#define RTEMS_RFS_SB_OFFSET_BLOCKS (RTEMS_RFS_SB_OFFSET_BLOCK_SIZE + 4) -#define RTEMS_RFS_SB_OFFSET_BAD_BLOCKS (RTEMS_RFS_SB_OFFSET_BLOCKS + 4) -#define RTEMS_RFS_SB_OFFSET_MAX_NAME_LENGTH (RTEMS_RFS_SB_OFFSET_BAD_BLOCKS + 4) -#define RTEMS_RFS_SB_OFFSET_GROUPS (RTEMS_RFS_SB_OFFSET_MAX_NAME_LENGTH + 4) -#define RTEMS_RFS_SB_OFFSET_GROUP_BLOCKS (RTEMS_RFS_SB_OFFSET_GROUPS + 4) -#define RTEMS_RFS_SB_OFFSET_GROUP_INODES (RTEMS_RFS_SB_OFFSET_GROUP_BLOCKS + 4) -#define RTEMS_RFS_SB_OFFSET_INODE_SIZE (RTEMS_RFS_SB_OFFSET_GROUP_INODES + 4) - -/** - * RFS Version Number. - */ -#define RTEMS_RFS_VERSION (0x00000000) - -/** - * RFS Version Number Mask. The mask determines which bits of the version - * number indicate compatility issues. - */ -#define RTEMS_RFS_VERSION_MASK INT32_C(0x00000000) - -/** - * The root inode number. Do not use 0 as this has special meaning in some - * Unix operating systems. - */ -#define RTEMS_RFS_ROOT_INO (1) - -/** - * Empty inode number. - */ -#define RTEMS_RFS_EMPTY_INO (0) - -/** - * The number of blocks in the inode. This number effects the size of the - * inode and that effects the overhead of the inode tables in a group. - */ -#define RTEMS_RFS_INODE_BLOCKS (5) - -/** - * The inode overhead is the percentage of space reserved for inodes. It is - * calculated as the percentage number of blocks in a group. The number of - * blocks in a group is the number of bits a block can hold. - */ -#define RTEMS_RFS_INODE_OVERHEAD_PERCENTAGE (1) - -/** - * Number of blocks in the superblock. Yes I know it is a superblock and not - * superblocks but if for any reason this needs to change it is handled. - */ -#define RTEMS_RFS_SUPERBLOCK_SIZE (1) - -/** - * The maximum number of buffers held by the file system at any one time. - */ -#define RTEMS_RFS_FS_MAX_HELD_BUFFERS (5) - -/** - * Absolute position. Make a 64bit value. - */ -typedef uint64_t rtems_rfs_pos; - -/** - * Relative position. Make a 64bit value. - */ -typedef int64_t rtems_rfs_pos_rel; - -/** - * Flags to control the file system. - */ -#define RTEMS_RFS_FS_BITMAPS_HOLD (1 << 0) /**< Do not release bitmaps - * when finished. Default is - * off so they are released. */ -#define RTEMS_RFS_FS_NO_LOCAL_CACHE (1 << 1) /**< Do not cache the buffers - * and release directly to the - * buffer support layer. The - * default is to hold buffers. */ -#define RTEMS_RFS_FS_FORCE_OPEN (1 << 2) /**< Force open and ignore any - * errors. */ -#define RTEMS_RFS_FS_READ_ONLY (1 << 3) /**< Make the mount - * read-only. Currently not - * supported. */ -/** - * RFS File System data. - */ -struct _rtems_rfs_file_system -{ - /** - * Flags to control the file system. Some can be controlled via the ioctl. - */ - uint32_t flags; - - /** - * The number of blocks in the disk. The size of the disk is the number of - * blocks by the block size. This should be within a block size of the size - * returned by the media driver. - */ - size_t blocks; - - /** - * The size of a block. This must be a multiple of the disk's media block - * size. - */ - size_t block_size; - - /** - * The file descriptor for device I/O. - */ - int device; - -#if RTEMS_RFS_USE_LIBBLOCK - /** - * The disk device. This is the data about the block device this file system - * is mounted on. We access the data held in this structure rather than - * making an extra copy in this structure. - */ - rtems_disk_device* disk; -#else - /** - * The number of blocks in the file system. - */ - size_t size; -#endif - - /** - * Inode count. - */ - uint32_t inodes; - - /** - * Bad block blocks. This is a table of blocks that have been found to be - * bad. - */ - uint32_t bad_blocks; - - /** - * Maximum length of names supported by this file system. - */ - uint32_t max_name_length; - - /** - * A disk is broken down into a series of groups. - */ - rtems_rfs_group* groups; - - /** - * Number of groups. - */ - int group_count; - - /** - * Number of blocks in a group. - */ - size_t group_blocks; - - /** - * Number of inodes in a group. - */ - size_t group_inodes; - - /** - * Number of inodes in each block. - */ - size_t inodes_per_block; - - /** - * Number of block numbers in a block. - */ - size_t blocks_per_block; - - /** - * Block map single indirect count. This is the block number per block - * multiplied but the slots in the inode. - */ - size_t block_map_singly_blocks; - - /** - * Block map double indirect count. This is the block number per block - * squared and multiplied by the slots in the inode. It is the maximum - * number of blocks a map (file/directory) can have. - */ - size_t block_map_doubly_blocks; - - /** - * Number of buffers held before releasing back to the cache. - */ - uint32_t max_held_buffers; - - /** - * List of buffers attached to buffer handles. Allows sharing. - */ - rtems_chain_control buffers; - - /** - * Number of buffers held on the buffers list. - */ - uint32_t buffers_count; - - /** - * List of buffers that need to be released when the processing of a file - * system request has completed. - */ - rtems_chain_control release; - - /** - * Number of buffers held on the release list. - */ - uint32_t release_count; - - /** - * List of buffers that need to be released modified when the processing of a - * file system request has completed. - */ - rtems_chain_control release_modified; - - /** - * Number of buffers held on the release modified list. - */ - uint32_t release_modified_count; - - /** - * List of open shared file node data. The shared node data such as the inode - * and block map allows a single file to be open more than once. - */ - rtems_chain_control file_shares; - - /** - * Pointer to user data supplied when opening. - */ - void* user; -}; - -/** - * Return the flags. - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_flags(_f) ((_f)->flags) -/** - * Should bitmap buffers be released when finished ? - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_release_bitmaps(_f) (!((_f)->flags & RTEMS_RFS_FS_BITMAPS_HOLD)) - -/** - * Are the buffers locally cache or released back to the buffering layer ? - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_no_local_cache(_f) ((_f)->flags & RTEMS_RFS_FS_NO_LOCAL_CACHE) - -/** - * The disk device number. - * - * @param[in] _fs is a pointer to the file system. - */ -#if RTEMS_RFS_USE_LIBBLOCK -#define rtems_rfs_fs_device(_fs) ((_fs)->disk) -#else -#define rtems_rfs_fs_device(_fs) ((_fs)->device) -#endif - -/** - * The size of the disk in blocks. - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_blocks(_fs) ((_fs)->blocks) - -/** - * The block size. - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_block_size(_fs) ((_fs)->block_size) - -/** - * The number of inodes. - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_inodes(_fs) ((_fs)->inodes) - -/** - * Calculate a block in the file system given the group and the block within - * the group. - * - * @param[in] _fs is a pointer to the file system. - * @param[in] _grp is the group. - * @param[in] _blk is the block within the group. - * @return The absolute block number. - */ -#define rtems_rfs_fs_block(_fs, _grp, _blk) \ - ((((_fs)->group_blocks) * (_grp)) + (_blk) + 1) - -/** - * The media size of the disk in media size blocks. - * - * @param[in] _fs is a pointer to the file system. - */ -#if RTEMS_RFS_USE_LIBBLOCK -#define rtems_rfs_fs_media_blocks(_fs) ((_fs)->disk->size) -#else -#define rtems_rfs_fs_media_blocks(_fs) ((_fs)->media_size) -#endif - -/** - * The media block size. This is the size of a block on disk. For a device I/O - * this value is 1. - * - * @param[in] _fs is a pointer to the file system. - */ -#if RTEMS_RFS_USE_LIBBLOCK -#define rtems_rfs_fs_media_block_size(_fs) ((_fs)->disk->media_block_size) -#else -#define rtems_rfs_fs_media_block_size(_fs) (1) -#endif - -/** - * The maximum length of a name supported by the file system. - */ -#define rtems_rfs_fs_max_name(_fs) ((_fs)->max_name_length) - -/** - * Return the maximum number of blocks in a block map. - * - * @return uint32_t The maximum number of blocks possible. - */ -#define rtems_rfs_fs_max_block_map_blocks(_fs) ((_fs)->block_map_doubly_blocks) - -/** - * Return the user pointer. - */ -#define rtems_rfs_fs_user(_fs) ((_fs)->user) - -/** - * Return the size of the disk in bytes. - * - * @param[in] fs is a pointer to the file system. - * @return uint64_t The size of the disk in bytes. - */ -uint64_t rtems_rfs_fs_size(rtems_rfs_file_system* fs); - -/** - * The size of the disk in bytes calculated from the media parameters.. - * - * @param[in] fs is a pointer to the file system. - * @return uint64_t The size of the disk in bytes. - */ -uint64_t rtems_rfs_fs_media_size (rtems_rfs_file_system* fs); - -/** - * Open the file system given a file path. - * - * @param[in] name is a pointer to the device to open. - * @param[in] fs is the file system data filled in by this call. - * @param[in] user is a pointer to the user data. - * @param[in] flags is a initial set of user flags for the file system. - * @param[in] max_held_buffers is the maximum number of buffers the RFS holds. - * - * @retval 0 Successful operation. - * @retval -1 Error. See errno - */ -int rtems_rfs_fs_open (const char* name, - void* user, - uint32_t flags, - uint32_t max_held_buffers, - rtems_rfs_file_system** fs); - -/** - * Close the file system. - * - * @param[in] fs is the file system data. - * - * @retval 0 Successful operation. - * @retval -1 Error. See errno - */ -int rtems_rfs_fs_close (rtems_rfs_file_system* fs); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-file.h b/cpukit/libfs/src/rfs/rtems-rfs-file.h deleted file mode 100644 index 772e846143..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-file.h +++ /dev/null @@ -1,416 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System File Support - * - * @ingroup rtems_rfs - * - * RTEMS File System File Support - * - * This file provides the support functions. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_FILE_H_) -#define _RTEMS_RFS_FILE_H_ - -#include <rtems/libio_.h> - -#include <rtems/rfs/rtems-rfs-block.h> -#include <rtems/rfs/rtems-rfs-data.h> -#include <rtems/rfs/rtems-rfs-file-system.h> -#include <rtems/rfs/rtems-rfs-inode.h> - -/** - * File data that is shared by various file handles accessing the same file. We - * hold various inode values common to the file that can change frequently so - * the inode is not thrashed yet we meet the requirements of the POSIX - * standard. The stat call needs to check the shared file data. - */ -typedef struct _rtems_rfs_file_shared -{ - /** - * The shared parts are maintained as a list. - */ - rtems_chain_node link; - - /** - * Reference count the users of this data. - */ - int references; - - /** - * The inode for the file. - */ - rtems_rfs_inode_handle inode; - - /** - * The block map for the file. The handle holds the file's position not the - * map. - */ - rtems_rfs_block_map map; - - /** - * The size of the file as taken from the inode. The map's size and - * this size should be the same. - */ - rtems_rfs_block_size size; - - /** - * The access time. The last time the file was read. - */ - rtems_rfs_time atime; - - /** - * The modified time. The last time the file was written too. - */ - rtems_rfs_time mtime; - - /** - * The change time. The last time the inode was written too. - */ - rtems_rfs_time ctime; - - /** - * Hold a pointer to the file system data so users can take the handle and - * use it without the needing to hold the file system data pointer. - */ - rtems_rfs_file_system* fs; - -} rtems_rfs_file_shared; - -/** - * Get the atime. - * - * @param[in] shared is a pointer to the shared file data. - * - * @retval atime The atime. - */ -static inline rtems_rfs_time -rtems_rfs_file_shared_get_atime (rtems_rfs_file_shared* shared) -{ - return shared->atime; -} - -/** - * Get the mtime. - * - * @param[in] shared is a pointer to the shared file data. - * - * @retval mtime The mtime. - */ -static inline rtems_rfs_time -rtems_rfs_file_shared_get_mtime (rtems_rfs_file_shared* shared) -{ - return shared->mtime; -} - -/** - * Get the ctime. - * - * @param[in] shared is a pointer to the shared file data. - * - * @retval ctime The ctime. - */ -static inline rtems_rfs_time -rtems_rfs_file_shared_get_ctime (rtems_rfs_file_shared* shared) -{ - return shared->ctime; -} - -/** - * Get the block count. - * - * @param[in] shared is a pointer to the shared file data. - * - * @retval count The block count. - */ -static inline uint32_t -rtems_rfs_file_shared_get_block_count (rtems_rfs_file_shared* shared) -{ - return shared->size.count; -} - -/** - * Get the block offset. - * - * @param shared is a pointer to the shared file data. - * - * @retval offset The block offset. - */ -static inline uint16_t -rtems_rfs_file_shared_get_block_offset (rtems_rfs_file_shared* shared) -{ - return shared->size.offset; -} - -/** - * Calculate the size of data. - * - * @param[in] fs is the file system data. - * @param[in] shared is a pointer to the shared file data. - * - * @retval data The data size in bytes. - */ -static inline rtems_rfs_pos -rtems_rfs_file_shared_get_size (rtems_rfs_file_system* fs, - rtems_rfs_file_shared* shared) -{ - return rtems_rfs_block_get_size (fs, &shared->size); -} - -/** - * File flags. - */ -#define RTEMS_RFS_FILE_NO_ATIME_UPDATE (1 << 0) /**< Do not update the atime - * field in the inode if - * set. */ -#define RTEMS_RFS_FILE_NO_MTIME_UPDATE (1 << 1) /**< Do not update the mtime - * field in the inode if - * set. */ -#define RTEMS_RFS_FILE_NO_LENGTH_UPDATE (1 << 2) /**< Do not update the position - * field in the inode if - * set. */ - -/** - * File data used to managed an open file. - */ -typedef struct _rtems_rfs_file_handle -{ - /** - * Special flags that can be controlled by the fctrl call. - */ - int flags; - - /** - * The buffer of data at the file's position. - */ - rtems_rfs_buffer_handle buffer; - - /** - * The block position of this file handle. - */ - rtems_rfs_block_pos bpos; - - /** - * Pointer to the shared file data. - */ - rtems_rfs_file_shared* shared; - -} rtems_rfs_file_handle; - -/** - * Access the data in the buffer. - */ -#define rtems_rfs_file_data(_f) \ - (rtems_rfs_buffer_data (&(_f)->buffer) + (_f)->bpos.boff) - -/** - * Return the file system data pointer given a file handle. - */ -#define rtems_rfs_file_fs(_f) ((_f)->shared->fs) - -/** - * Return the file's inode handle pointer given a file handle. - */ -#define rtems_rfs_file_inode(_f) (&(_f)->shared->inode) - -/** - * Return the file's block map pointer given a file handle. - */ -#define rtems_rfs_file_map(_f) (&(_f)->shared->map) - -/** - * Return the file's block position pointer given a file handle. - */ -#define rtems_rfs_file_bpos(_f) (&(_f)->bpos) - -/** - * Return the file's block number given a file handle. - */ -#define rtems_rfs_file_block(_f) ((_f)->bpos.bno) - -/** - * Return the file's block offset given a file handle. - */ -#define rtems_rfs_file_block_offset(_f) ((_f)->bpos.boff) - -/** - * Set the file's block position given a file position (absolute). - */ -#define rtems_rfs_file_set_bpos(_f, _p) \ - rtems_rfs_block_get_bpos (rtems_rfs_file_fs (_f), _p, (&(_f)->bpos)) - -/** - * Return the file's buffer handle pointer given a file handle. - */ -#define rtems_rfs_file_buffer(_f) (&(_f)->buffer) - -/** - * Update the access time field of the inode when reading if flagged to do so. - */ -#define rtems_rfs_file_update_atime(_f) \ - (((_f)->flags & RTEMS_RFS_FILE_NO_ATIME_UPDATE) == 0) - -/** - * Update the modified time field of the inode when writing if flagged to do so. - */ -#define rtems_rfs_file_update_mtime(_f) \ - (((_f)->flags & RTEMS_RFS_FILE_NO_MTIME_UPDATE) == 0) - -/** - * Update the length field of the inode. - */ -#define rtems_rfs_file_update_length(_f) \ - (((_f)->flags & RTEMS_RFS_FILE_NO_LENGTH_UPDATE) == 0) - -/** - * Return the shared size varable. - */ -#define rtems_rfs_file_get_size(_f) \ - (&(_f)->shared->size) - -/** - * Return the size of file. - */ -#define rtems_rfs_file_size(_f) \ - rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (_f), (_f)->shared) - -/** - * Return the file block count. - */ -#define rtems_rfs_file_size_count(_f) \ - rtems_rfs_file_shared_get_block_count ((_f)->shared) - -/** - * Return the file block offset. - */ -#define rtems_rfs_file_size_offset(_f) \ - rtems_rfs_file_shared_get_block_offset ((_f)->shared) - -/** - * Open a file handle. - * - * @param[in] fs is the file system. - * @param[in] ino is the inode number of the file to be opened. - * @param[out] handle will be filled in with the handle pointer. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_open (rtems_rfs_file_system* fs, - rtems_rfs_ino ino, - int oflag, - rtems_rfs_file_handle** handle); - -/** - * Close an open file handle. - * - * @param[in] fs is the file system. - * @param[in] handle is the open file handle. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_close (rtems_rfs_file_system* fs, - rtems_rfs_file_handle* handle); - -/** - * Start I/O on a block of a file. This call only requests the block from the - * media if reading and makes the buffer available to you the via the - * rtems_rfs_file_data interface after the call. The available amount data is - * taken from the current file position until the end of the block. The file - * position is not adujsted until the I/O ends. An I/O request cannot perform - * I/O past the end of a block so the call returns the amount of data - * available. - * - * @param[in] handle is the file handle. - * @param[in] available is the amount of data available for I/O. - * @param[in] read is the I/O operation is a read so the block is read from the media. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_io_start (rtems_rfs_file_handle* handle, - size_t* available, - bool read); - -/** - * End the I/O. Any buffers held in the file handle and returned to the - * cache. If inode updating is not disable and the I/O is a read the atime - * field is updated and if a write I/O the mtime is updated. - * - * If the file's position is updated by the size amount. - * - * @param[in] handle is the file handle. - * @param[in] size is the amount of data read or written. - * @param[in] read is the I/O was a read if true else it was a write. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_io_end (rtems_rfs_file_handle* handle, - size_t size, - bool read); - -/** - * Release the I/O resources without any changes. If data has changed in the - * buffer and the buffer was not already released as modified the data will be - * lost. - * - * @param[in] handle is the file handle. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_io_release (rtems_rfs_file_handle* handle); - -/** - * The file to the position returning the old position. The position is - * abolute. - * - * @param[in] handle The file handle. - * @param[in] pos is the position to seek to. - * @param[out] new_pos will contain the actual position. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_seek (rtems_rfs_file_handle* handle, - rtems_rfs_pos pos, - rtems_rfs_pos* new_pos); - -/** - * Set the size of the file to the new size. This can extend the file to a new - * size. - * - * @param[in] handle is the file handle. - * @param[in] size is the new size of the file. - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_set_size (rtems_rfs_file_handle* handle, - rtems_rfs_pos size); - -/** - * Return the shared file data for an ino. - * - * @param[in] fs is the file system data. - * @param[in] ino is the inode number to locate the data for. - * @return rtems_rfs_file_shared* The shared data or NULL is not located. - * - * @retval shared The shared data. - * @retval NULL No shared file data is located. - */ -rtems_rfs_file_shared* rtems_rfs_file_get_shared (rtems_rfs_file_system* fs, - rtems_rfs_ino ino); - - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-format.h b/cpukit/libfs/src/rfs/rtems-rfs-format.h deleted file mode 100644 index f65cce1789..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-format.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file - * - * @ingroup rtems_rfs - * - * @brief RTEMS File System Format - * - * This function lets you format a disk in the RFS format. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_FORMAT_H_) -#define _RTEMS_RFS_FORMAT_H_ - -#include <stddef.h> -#include <stdbool.h> -#include <stdint.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#include <rtems/rfs/rtems-rfs-trace.h> - -/** - * RFS File System Configuration data used to format the file system. For - * default values leave the field set to 0. - */ -typedef struct _rtems_rfs_format_config -{ - /** - * The size of a block. - */ - size_t block_size; - - /** - * The number of blocks in a group. - */ - size_t group_blocks; - - /** - * The number of inodes in a group. - */ - size_t group_inodes; - - /** - * The percentage overhead allocated to inodes. - */ - int inode_overhead; - - /** - * The maximum length of a name. - */ - size_t max_name_length; - - /** - * Initialise the inode tables to all ones. - */ - bool initialise_inodes; - - /** - * Is the format verbose. - */ - bool verbose; - -} rtems_rfs_format_config; - -/** - * RFS Format command. - * - * @param[in] name is the device name to format. - * @param[in] config is a pointer to the configuration table. - * - * @retval -1 Error. See errno. - * @retval 0 No error. Format successful. - */ -int rtems_rfs_format (const char* name, const rtems_rfs_format_config* config); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-group.h b/cpukit/libfs/src/rfs/rtems-rfs-group.h deleted file mode 100644 index 23e6434b2c..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-group.h +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @file - * - * @brief RTEMS File Systems Group Management - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Group Management. - * - * These functions manage the groups used in the file system. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_GROUP_H_) -#define _RTEMS_RFS_GROUP_H_ - -/** - * @ingroup rtems_rfs - * - * RTEMS File System Group Management - */ -/**@{*/ - -#include <rtems/rfs/rtems-rfs-trace.h> -#include <rtems/rfs/rtems-rfs-bitmaps.h> -#include <rtems/rfs/rtems-rfs-buffer.h> - -/** - * 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) - -/** - * @brief Creates bit allocator for blocks in the group simpler. - * - * 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 -{ - /** - * 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) - -/** - * @brief 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. - * @retval 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); - -/** - * @brief Close a group. - * - * Release all resources the group holds. - * - * @param fs The file system. - * @param group The group to close. - * @retval int The error number (errno). No error if 0. - */ -int rtems_rfs_group_close (rtems_rfs_file_system* fs, - rtems_rfs_group* group); - -/** - * @brief 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. - * @retval 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); - -/** - * @brief 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. - * @param block The inode or block number to free. - * @retval 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); - -/** - * @brief 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. - * @param block The inode or block number to free. - * @param state Return the state of the bit. - * @retval 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); - -/** - * @brief Determine the number of blocks and inodes used. - * - * @param fs The file system data. - * @param blocks The number of blocks used. - * @param inodes The number of inodes used. - * @retval int The error number (errno). No error if 0. - */ -int rtems_rfs_group_usage (rtems_rfs_file_system* fs, - size_t* blocks, - size_t* inodes); - -/** @} */ -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-inode.h b/cpukit/libfs/src/rfs/rtems-rfs-inode.h deleted file mode 100644 index 95861ea8a7..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-inode.h +++ /dev/null @@ -1,728 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Information Node - * - * @ingroup rtems_rfs - * - * RTEMS File System Information Node. - * - * The information nodes hold the data about all nodes in the file system. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_INODE_H_) -#define _RTEMS_RFS_INODE_H_ - -#include <sys/stat.h> - -#include <rtems/rfs/rtems-rfs-data.h> -#include <rtems/rfs/rtems-rfs-file-system.h> - -/** - * The RFS mode definitions. Currently map to the C library ones. - */ -#define RTEMS_RFS_S_ISUID S_ISUID /**< Set user id on execution */ -#define RTEMS_RFS_S_ISGID S_ISGID /**< Set group id on execution */ -#define RTEMS_RFS_S_ISVTX S_ISVTX /**< Save swapped text even after use */ -#define RTEMS_RFS_S_IREAD S_IREAD /**< Read permission, owner */ -#define RTEMS_RFS_S_IWRITE S_IWRITE /**< Write permission, owner */ -#define RTEMS_RFS_S_IEXEC S_IEXEC /**< Execute/search permission, owner */ -#define RTEMS_RFS_S_ENFMT S_ENFMT /**< Enforcement-mode locking */ -#define RTEMS_RFS_S_IFMT S_IFMT /**< Type of file */ -#define RTEMS_RFS_S_IFDIR S_IFDIR /**< Directory */ -#define RTEMS_RFS_S_IFCHR S_IFCHR /**< Character special */ -#define RTEMS_RFS_S_IFBLK S_IFBLK /**< Block special */ -#define RTEMS_RFS_S_IFREG S_IFREG /**< Regular */ -#define RTEMS_RFS_S_IFLNK S_IFLNK /**< Symbolic link */ -#define RTEMS_RFS_S_IFSOCK S_IFSOCK /**< Socket */ -#define RTEMS_RFS_S_IFIFO S_IFIFO /**< Fifo */ -#define RTEMS_RFS_S_IRWXU S_IRWXU -#define RTEMS_RFS_S_IRUSR S_IRUSR /**< Read permission, owner */ -#define RTEMS_RFS_S_IWUSR S_IWUSR /**< Write permission, owner */ -#define RTEMS_RFS_S_IXUSR S_IXUSR /**< Execute/search permission, owner */ -#define RTEMS_RFS_S_IRWXG S_IRWXG -#define RTEMS_RFS_S_IRGRP S_IRGRP /**< Read permission, group */ -#define RTEMS_RFS_S_IWGRP S_IWGRP /**< Write permission, grougroup */ -#define RTEMS_RFS_S_IXGRP S_IXGRP /**< Execute/search permission, group */ -#define RTEMS_RFS_S_IRWXO S_IRWXO -#define RTEMS_RFS_S_IROTH S_IROTH /**< Read permission, other */ -#define RTEMS_RFS_S_IWOTH S_IWOTH /**< Write permission, other */ -#define RTEMS_RFS_S_IXOTH S_IXOTH /**< Execute/search permission, other */ - -#define RTEMS_RFS_S_ISBLK(m) S_ISBLK(m) -#define RTEMS_RFS_S_ISCHR(m) S_ISCHR(m) -#define RTEMS_RFS_S_ISDIR(m) S_ISDIR(m) -#define RTEMS_RFS_S_ISFIFO(m) S_ISFIFO(m) -#define RTEMS_RFS_S_ISREG(m) S_ISREG(m) -#define RTEMS_RFS_S_ISLNK(m) S_ISLNK(m) -#define RTEMS_RFS_S_ISSOCK(m) S_ISSOCK(m) - -/** - * Permissions of a symlink. - */ -#define RTEMS_RFS_S_SYMLINK \ - RTEMS_RFS_S_IFLNK | RTEMS_RFS_S_IRWXU | RTEMS_RFS_S_IRWXG | RTEMS_RFS_S_IRWXO - -/** - * The inode number or ino. - */ -typedef uint32_t rtems_rfs_ino; - -/** - * The time in the file system. - */ -typedef uint32_t rtems_rfs_time; - -/** - * The size of a block value on disk. This include the inodes and indirect - * tables. - */ -typedef uint32_t rtems_rfs_inode_block; - -/** - * The size of the data name field in the inode. - */ -#define RTEMS_RFS_INODE_DATA_NAME_SIZE \ - (RTEMS_RFS_INODE_BLOCKS * sizeof (rtems_rfs_inode_block)) - -/** - * The inode. - */ -typedef struct _rtems_rfs_inode -{ - /** - * The number of links to the inode. - */ - uint16_t links; - - /** - * The mode of the node. - */ - uint16_t mode; - - /** - * The owner of the node. - */ - uint32_t owner; - - /** - * Reserved. - */ - uint16_t flags; - - /** - * Amount of data held in the last block data. - */ - uint16_t block_offset; - - /** - * Number of blocks held by this file. - */ - uint32_t block_count; - - /** - * The access time. The last time the file was read. - */ - rtems_rfs_time atime; - - /** - * The modified time. The last time the file was written too. - */ - rtems_rfs_time mtime; - - /** - * The change time. The last time the inode was written too. - */ - rtems_rfs_time ctime; - - /** - * Blocks. These are the block numbers used by the node or table of - * nodes. The flags indicate the mode the blocks are being held in. In the - * direct table mode the blocks are entries in this table. In the indirect - * mode the blocks point to blocks that hold the block numbers. The data can - * also be a name if it fits. For example a symbolic link. - */ - union - { - rtems_rfs_inode_block blocks[RTEMS_RFS_INODE_BLOCKS]; - uint8_t name[RTEMS_RFS_INODE_DATA_NAME_SIZE]; - } data; - - /** - * The last block map block. Used as the goal when allocating a new block for - * use in the map. - */ - rtems_rfs_inode_block last_map_block; - - /** - * The last data block. Used as the goal when allocating a new block. - */ - rtems_rfs_inode_block last_data_block; - -} rtems_rfs_inode; - -/** - * The size of an inode. - */ -#define RTEMS_RFS_INODE_SIZE (sizeof (rtems_rfs_inode)) - -/** - * RFS Inode Handle. - */ -typedef struct _rtems_rfs_inode_handle -{ - /** - * Handles can be linked as a list for easy processing. - */ - rtems_chain_node link; - - /** - * The ino for this handle. - */ - rtems_rfs_ino ino; - - /** - * The pointer to the inode. - */ - rtems_rfs_inode* node; - - /** - * The buffer that contains this inode. - */ - rtems_rfs_buffer_handle buffer; - - /** - * The block number that holds the inode. - */ - rtems_rfs_buffer_block block; - - /** - * The offset into the block for the inode. - */ - int offset; - - /** - * Number of load requests. - */ - int loads; - -} rtems_rfs_inode_handle; - -/** - * Is the inode loaded ? - */ -#define rtems_rfs_inode_is_loaded(_h) ((_h)->node) - -/** - * Get the inode ino for a handle. - */ -#define rtems_rfs_inode_ino(_h) ((_h)->ino) - -/** - * Get the link count. - * - * @param[in] handle is the inode handle. - * - * @retval links The link count. - */ -static inline uint16_t -rtems_rfs_inode_get_links (rtems_rfs_inode_handle* handle) -{ - uint16_t links; - links = rtems_rfs_read_u16 (&handle->node->links); - if (links == 0xffff) - links = 0; - return links; -} - -/** - * Set the link count. - * - * @param[in] handle is the inode handle. - * @param[in] links are the links. - */ -static inline void -rtems_rfs_inode_set_links (rtems_rfs_inode_handle* handle, uint16_t links) -{ - rtems_rfs_write_u16 (&handle->node->links, links); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the flags. - * - * @param[in] handle is the inode handle. - * - * @retval flags The flags. - */ -static inline uint16_t -rtems_rfs_inode_get_flags (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u16 (&handle->node->flags); -} - -/** - * Set the flags. - * - * @param[in] handle is the inode handle. - * @param[in] flags are the flags. - */ -static inline void -rtems_rfs_inode_set_flags (rtems_rfs_inode_handle* handle, uint16_t flags) -{ - rtems_rfs_write_u16 (&handle->node->flags, flags); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the mode. - * - * @param[in] handle is the inode handle. - * - * @retval mode The mode. - */ -static inline uint16_t -rtems_rfs_inode_get_mode (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u16 (&handle->node->mode); -} - -/** - * Set the mode. - * - * @param[in] handle is the inode handle. - * @param[in] mode is the mode. - */ -static inline void -rtems_rfs_inode_set_mode (rtems_rfs_inode_handle* handle, uint16_t mode) -{ - rtems_rfs_write_u16 (&handle->node->mode, mode); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the user id. - * - * @param[in] handle is the inode handle. - * - * @retval uid The used id. - */ -static inline uint16_t -rtems_rfs_inode_get_uid (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->owner) & 0xffff; -} - -/** - * Get the group id. - * - * @param[in] handle is the inode handle. - * - * @retval gid The grpup id. - */ -static inline uint16_t -rtems_rfs_inode_get_gid (rtems_rfs_inode_handle* handle) -{ - return (rtems_rfs_read_u32 (&handle->node->owner) >> 16) & 0xffff; -} - -/** - * Set the user id and group id. - * - * @param[in] handle is the inode handle. - * @param[in] uid is the user id (uid). - * @param[in] gid is the group id (gid). - */ -static inline void -rtems_rfs_inode_set_uid_gid (rtems_rfs_inode_handle* handle, - uint16_t uid, uint16_t gid) -{ - rtems_rfs_write_u32 (&handle->node->owner, (((uint32_t) gid) << 16) | uid); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the block offset. - * - * @param[in] handle is the inode handle. - * - * @retval offset The block offset. - */ -static inline uint16_t -rtems_rfs_inode_get_block_offset (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u16 (&handle->node->block_offset); -} - -/** - * Set the block offset. - * - * @param[in] handle is the inode handle. - * @param[in] block_count is the block offset. - */ -static inline void -rtems_rfs_inode_set_block_offset (rtems_rfs_inode_handle* handle, - uint16_t block_offset) -{ - rtems_rfs_write_u16 (&handle->node->block_offset, block_offset); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the block count. - * - * @param[in] handle is the inode handle. - * - * @retval count The block count. - */ -static inline uint32_t -rtems_rfs_inode_get_block_count (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->block_count); -} - -/** - * Set the block count. - * - * @param[in] handle is the inode handle. - * @param[in] block_count is the block count. - */ -static inline void -rtems_rfs_inode_set_block_count (rtems_rfs_inode_handle* handle, uint32_t block_count) -{ - rtems_rfs_write_u32 (&handle->node->block_count, block_count); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the atime. - * - * @param[in] handle is the inode handle. - * - * @retval atime The atime. - */ -static inline rtems_rfs_time -rtems_rfs_inode_get_atime (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->atime); -} - -/** - * Set the atime. - * - * @param[in] handle is the inode handle. - * @param[in] atime The atime. - */ -static inline void -rtems_rfs_inode_set_atime (rtems_rfs_inode_handle* handle, - rtems_rfs_time atime) -{ - rtems_rfs_write_u32 (&handle->node->atime, atime); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the mtime. - * - * @param[in] handle is the inode handle. - * - * @retval mtime The mtime. - */ -static inline rtems_rfs_time -rtems_rfs_inode_get_mtime (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->mtime); -} - -/** - * Set the mtime. - * - * @param[in] handle is the inode handle. - * @param[in] mtime The mtime. - */ -static inline void -rtems_rfs_inode_set_mtime (rtems_rfs_inode_handle* handle, - rtems_rfs_time mtime) -{ - rtems_rfs_write_u32 (&handle->node->mtime, mtime); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the ctime. - * - * @param[in] handle is the inode handle. - * - * @retval ctime The ctime. - */ -static inline rtems_rfs_time -rtems_rfs_inode_get_ctime (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->ctime); -} - -/** - * Set the ctime. - * - * @param[in] handle is the inode handle. - * @param[in] ctime The ctime. - */ -static inline void -rtems_rfs_inode_set_ctime (rtems_rfs_inode_handle* handle, - rtems_rfs_time ctime) -{ - rtems_rfs_write_u32 (&handle->node->ctime, ctime); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the block number. - * - * @param[in] handle is the inode handle. - * @param[in] block is the block number to return. - * - * @retval block The block number. - */ -static inline uint32_t -rtems_rfs_inode_get_block (rtems_rfs_inode_handle* handle, int block) -{ - return rtems_rfs_read_u32 (&handle->node->data.blocks[block]); -} - -/** - * Set the block number for a given block index. - * - * @param[in] handle is the inode handle. - * @param[in] block is the block index. - * @param[in] bno is the block number. - */ -static inline void -rtems_rfs_inode_set_block (rtems_rfs_inode_handle* handle, int block, uint32_t bno) -{ - rtems_rfs_write_u32 (&handle->node->data.blocks[block], bno); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the last map block from the inode. - * - * @param[in] handle is the inode handle. - * - * @retval block The last map block number. - */ -static inline uint32_t -rtems_rfs_inode_get_last_map_block (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->last_map_block); -} - -/** - * Set the last map block. - * - * @param[in] handle is the inode handle. - * @param[in] block_count is last map block number. - */ -static inline void -rtems_rfs_inode_set_last_map_block (rtems_rfs_inode_handle* handle, uint32_t last_map_block) -{ - rtems_rfs_write_u32 (&handle->node->last_map_block, last_map_block); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the last data block from the inode. - * - * @param[in] handle is the inode handle. - * - * @retval block The last data block number. - * - */ -static inline uint32_t -rtems_rfs_inode_get_last_data_block (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->last_data_block); -} - -/** - * Set the last data block. - * - * @param[in] handle is the inode handle. - * @param[in] block_count is the last data block number. - */ -static inline void -rtems_rfs_inode_set_last_data_block (rtems_rfs_inode_handle* handle, uint32_t last_data_block) -{ - rtems_rfs_write_u32 (&handle->node->last_data_block, last_data_block); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Allocate an inode number and return it. - * - * @param[in] fs is the file system data. - * @param[out] ino will contain the ino. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_alloc (rtems_rfs_file_system* fs, - rtems_rfs_bitmap_bit goal, - rtems_rfs_ino* ino); - -/** - * Free an inode. - * - * @param[in] fs is the file system data. - * @param[in] ino is the ino too free. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_free (rtems_rfs_file_system* fs, - rtems_rfs_ino ino); - -/** - * Open the inode handle. This reads the inode into the buffer and sets the - * data pointer. All data is in media byte order and needs to be accessed via - * the supporting calls. - * - * @param[in] fs is the file system. - * @param[in] ino is the inode number. - * @param[in] handle is the handle to the inode we are opening. - * @param[in] load If true load the inode into memory from the media. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_open (rtems_rfs_file_system* fs, - rtems_rfs_ino ino, - rtems_rfs_inode_handle* handle, - bool load); - -/** - * The close inode handle. All opened inodes need to be closed. - * - * @param[in] fs is the file system. - * @param[in] handle is the handle to close. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_close (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* handle); - -/** - * Load the inode into memory. - * - * @param[in] fs is the file system. - * @param[in] handle is the inode handle to load. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_load (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* handle); - -/** - * Unload the inode from memory. - * - * @param[in] fs is the file system. - * @param[in] handle is the inode handle to unload. - * @param[in] update_ctime Update the ctime field of the inode. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_unload (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* handle, - bool update_ctime); - -/** - * Create an inode allocating, initialising and adding an entry to the parent - * directory. - * - * @param[in] fs is the file system data. - * @param[in] parent is the parent inode number to add the directory entry to. - * @param[in] name is a pointer to the name of the directory entryinode - * to 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); - -/** - * Delete the inode eraseing it and release the buffer to commit the write. You - * need to load the inode again if you wish to use it again. - * - * @param[in] fs is the file system. - * @param[in] handle is the inode handle to erase. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_delete (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* handle); - -/** - * Initialise a new inode. - * - * @param[in] handle is the inode handle to initialise. - * @param[in] links are the number of links to the inode. - * @param[in] mode is the inode mode. - * @param[in] uid is the user id. - * @param[in] gid is the group id. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_initialise (rtems_rfs_inode_handle* handle, - uint16_t links, - uint16_t mode, - uid_t uid, - gid_t gid); - -/** - * Time stamp the inode with the current time. The ctime field is hanlded - * automatically. - * - * @param[in] handle is the inode handle. - * @param[in] atime Update the atime field. - * @param[in] mtime UPdate the mtime field. - * - * @retval 0 Successful operation. - * @retval ENXIO No inode is loaded. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_time_stamp_now (rtems_rfs_inode_handle* handle, - bool atime, - bool mtime); - -/** - * Calculate the size of data attached to the inode. - * - * @param[in] fs is the file system data. - * @param[in] handle is the inode handle. - * - * @retval size The data size in bytes in the block map attched to the inode. - */ -rtems_rfs_pos rtems_rfs_inode_get_size (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* handle); - -#endif - diff --git a/cpukit/libfs/src/rfs/rtems-rfs-link.h b/cpukit/libfs/src/rfs/rtems-rfs-link.h deleted file mode 100644 index d30814aaff..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-link.h +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Link Support - * - * @ingroup rtems_rfs - * - * RTEMS File System Link Support - * - * This file provides the link support functions. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_LINK_H_) -#define _RTEMS_RFS_LINK_H_ - -#include <dirent.h> - -#include <rtems/rfs/rtems-rfs-file-system.h> -#include <rtems/rfs/rtems-rfs-inode.h> - -/** - * Directory unlink modes. - */ -typedef enum rtems_rfs_unlink_dir_e -{ - rtems_rfs_unlink_dir_denied, /**< Not allowed to unlink a directory. */ - rtems_rfs_unlink_dir_if_empty, /**< Unlink if the directory is empty. */ - rtems_rfs_unlink_dir_allowed /**< Unlinking of directories is allowed. */ -} rtems_rfs_unlink_dir; - -/** - * Create a link. Do not link directories unless renaming or you will create - * loops in the file system. - * - * @param[in] fs is the file system. - * @param[in] name is a pointer to the name of the link. - * @param[in] length is the length of the name. - * @param[in] parent is the inode number of the parent directory. - * @param[in] target is the inode of the target. - * @param[in] link_dir If true directories can be linked. Useful when - * renaming. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_link (rtems_rfs_file_system* fs, - const char* name, - int length, - rtems_rfs_ino parent, - rtems_rfs_ino target, - bool link_dir); - -/** - * Unlink the node from the parent directory. A directory offset for the - * target entry is required because links cause a number of inode numbers to - * appear in a single directory so scanning does not work. - * - * @param[in] fs is the file system. - * @param[in] parent is the inode number of the parent directory. - * @param[in] target is the inode of the target. - * @param[in] doff is the parent directory entry offset for the target entry. - * @param[in] dir_mode is the directory unlink mode. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_unlink (rtems_rfs_file_system* fs, - rtems_rfs_ino parent, - rtems_rfs_ino target, - uint32_t doff, - rtems_rfs_unlink_dir dir_mode); - -/** - * Symbolic link is an inode that has a path attached. - * - * @param[in] fs is the file system data. - * @param[in] name is a pointer to the name of the node. - * @param[in] length is the length of the name of the node. - * @param[in] link is a pointer to the link path attached to the - * symlink inode. - * @param[in] link_length is the length of the link path. - * @param[in] parent is the parent inode number. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_symlink (rtems_rfs_file_system* fs, - const char* name, - int length, - const char* link, - int link_length, - uid_t uid, - gid_t gid, - rtems_rfs_ino parent); - -/** - * Read a symbolic link into the provided buffer returning the link of link - * name. - * - * @param[in] fs is the file system data. - * @param[in] link is the link inode number to read. - * @param[in] path is a pointer to the buffer to write the link path into. - * @param[in] size is the size of the buffer. - * @param[out] length will contain the length of the link path. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_symlink_read (rtems_rfs_file_system* fs, - rtems_rfs_ino link, - char* path, - size_t size, - size_t* length); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-mutex.h b/cpukit/libfs/src/rfs/rtems-rfs-mutex.h deleted file mode 100644 index 606fd53233..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-mutex.h +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Mutex - * - * @ingroup rtems_rfs - * - * RTEMS File System Mutex. - * - * It may be suprising we abstract this for the RTEMS file system but this code - * is designed to be run on host operating systems. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_MUTEX_H_) -#define _RTEMS_RFS_MUTEX_H_ - -#include <errno.h> - -#include <rtems/rfs/rtems-rfs-trace.h> - -#if __rtems__ -#include <rtems.h> -#include <rtems/error.h> -#endif - -/** - * RFS Mutex type. - */ -#if __rtems__ -typedef rtems_id rtems_rfs_mutex; -#else -typedef uint32_t rtems_rfs_mutex; /* place holder */ -#endif - -/** - * @brief Create the mutex. - * - * @param [in] mutex is pointer to the mutex handle returned to the caller. - * - * @retval 0 Successful operation. - * @retval EIO An error occurred. - * - */ -int rtems_rfs_mutex_create (rtems_rfs_mutex* mutex); - -/** - * @brief Destroy the mutex. - * - * @param[in] mutex Reference to the mutex handle returned to the caller. - * - * @retval 0 Successful operation. - * @retval EIO An error occurred. - */ -int rtems_rfs_mutex_destroy (rtems_rfs_mutex* mutex); - -/** - * @brief Lock the mutex. - * - * @param[in] mutex is a pointer to the mutex to lock. - * - * @retval 0 Successful operation. - * @retval EIO An error occurred. - */ -static inline int -rtems_rfs_mutex_lock (rtems_rfs_mutex* mutex) -{ -#if __rtems__ - rtems_status_code sc = rtems_semaphore_obtain (*mutex, RTEMS_WAIT, 0); - if (sc != RTEMS_SUCCESSFUL) - { -#if RTEMS_RFS_TRACE - if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX)) - printf ("rtems-rfs: mutex: obtain failed: %s\n", - rtems_status_text (sc)); -#endif - return EIO; - } -#endif - return 0; -} - -/** - * @brief Unlock the mutex. - * - * @param[in] mutex is a pointer to the mutex to unlock. - * - * @retval 0 Successful operation. - * @retval EIO An error occurred. - */ -static inline int -rtems_rfs_mutex_unlock (rtems_rfs_mutex* mutex) -{ -#if __rtems__ - rtems_status_code sc = rtems_semaphore_release (*mutex); - if (sc != RTEMS_SUCCESSFUL) - { -#if RTEMS_RFS_TRACE - if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX)) - printf ("rtems-rfs: mutex: release failed: %s\n", - rtems_status_text (sc)); -#endif - return EIO; - } -#endif - return 0; -} - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-shell.h b/cpukit/libfs/src/rfs/rtems-rfs-shell.h deleted file mode 100644 index c2e1108a47..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-shell.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file - * - * @ingroup rtems_rfs - * @brief RTEMS File Systems Shell Commands - * - * RTEMS File Systems Shell commands provide a CLI interface to support and - * development of the RFS file system. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_SHELL_H_) -#define _RTEMS_RFS_SHELL_H_ - -#include <stddef.h> -#include <stdbool.h> -#include <stdint.h> - -/** - * The shell command for the RFS debugger. - * - * @param[in] argc is the argument count. - * @param[in] argv is a pointer to the argument variables. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_shell_debugrfs (int argc, char *argv[]); - -/** - * The shell command for formatting an RFS file system. - * - * @param[in] argc is the argument count. - * @param[in] argv is a pointer to the argument variables. - * - * @retval 0 Successful operation. - * @retval 1 An error occurred. - */ -int rtems_shell_rfs_format (int argc, char* argv[]); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-trace.h b/cpukit/libfs/src/rfs/rtems-rfs-trace.h deleted file mode 100644 index 4d6d0c9ddb..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-trace.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @file - * - * @brief Manages the Trace and Debugging Features of the - * RTEMS RFS File System - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Trace manages the trace and debugging features of the - * RTEMS RFS file system. The design allows all tracing code and strings to be - * removed from the target code for small footprint systems. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_TRACE_H_) -#define _RTEMS_RFS_TRACE_H_ - -#include <stddef.h> -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> - -/** - * Is tracing enabled ? - */ -#if !defined (RTEMS_RFS_TRACE) -#define RTEMS_RFS_TRACE 1 -#endif - -/** - * The type of the mask. - */ -typedef uint64_t rtems_rfs_trace_mask; - -/** - * List of tracing bits for the various parts of the file system. - */ -#define RTEMS_RFS_TRACE_ALL (0xffffffffffffffffULL) -#define RTEMS_RFS_TRACE_OPEN (1ULL << 0) -#define RTEMS_RFS_TRACE_CLOSE (1ULL << 1) -#define RTEMS_RFS_TRACE_MUTEX (1ULL << 2) -#define RTEMS_RFS_TRACE_BUFFER_OPEN (1ULL << 3) -#define RTEMS_RFS_TRACE_BUFFER_CLOSE (1ULL << 4) -#define RTEMS_RFS_TRACE_BUFFER_SYNC (1ULL << 5) -#define RTEMS_RFS_TRACE_BUFFER_RELEASE (1ULL << 6) -#define RTEMS_RFS_TRACE_BUFFER_CHAINS (1ULL << 7) -#define RTEMS_RFS_TRACE_BUFFER_HANDLE_REQUEST (1ULL << 8) -#define RTEMS_RFS_TRACE_BUFFER_HANDLE_RELEASE (1ULL << 9) -#define RTEMS_RFS_TRACE_BUFFER_SETBLKSIZE (1ULL << 10) -#define RTEMS_RFS_TRACE_BUFFERS_RELEASE (1ULL << 11) -#define RTEMS_RFS_TRACE_BLOCK_FIND (1ULL << 12) -#define RTEMS_RFS_TRACE_BLOCK_MAP_GROW (1ULL << 13) -#define RTEMS_RFS_TRACE_BLOCK_MAP_SHRINK (1ULL << 14) -#define RTEMS_RFS_TRACE_GROUP_OPEN (1ULL << 15) -#define RTEMS_RFS_TRACE_GROUP_CLOSE (1ULL << 16) -#define RTEMS_RFS_TRACE_GROUP_BITMAPS (1ULL << 17) -#define RTEMS_RFS_TRACE_INODE_OPEN (1ULL << 18) -#define RTEMS_RFS_TRACE_INODE_CLOSE (1ULL << 19) -#define RTEMS_RFS_TRACE_INODE_LOAD (1ULL << 20) -#define RTEMS_RFS_TRACE_INODE_UNLOAD (1ULL << 21) -#define RTEMS_RFS_TRACE_INODE_CREATE (1ULL << 22) -#define RTEMS_RFS_TRACE_INODE_DELETE (1ULL << 23) -#define RTEMS_RFS_TRACE_LINK (1ULL << 24) -#define RTEMS_RFS_TRACE_UNLINK (1ULL << 25) -#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO (1ULL << 26) -#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_CHECK (1ULL << 27) -#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_FOUND (1ULL << 28) -#define RTEMS_RFS_TRACE_DIR_ADD_ENTRY (1ULL << 29) -#define RTEMS_RFS_TRACE_DIR_DEL_ENTRY (1ULL << 30) -#define RTEMS_RFS_TRACE_DIR_READ (1ULL << 31) -#define RTEMS_RFS_TRACE_DIR_EMPTY (1ULL << 32) -#define RTEMS_RFS_TRACE_SYMLINK (1ULL << 33) -#define RTEMS_RFS_TRACE_SYMLINK_READ (1ULL << 34) -#define RTEMS_RFS_TRACE_FILE_OPEN (1ULL << 35) -#define RTEMS_RFS_TRACE_FILE_CLOSE (1ULL << 36) -#define RTEMS_RFS_TRACE_FILE_IO (1ULL << 37) -#define RTEMS_RFS_TRACE_FILE_SET (1ULL << 38) - -/** - * Call to check if this part is bring traced. If RTEMS_RFS_TRACE is defined to - * 0 the code is dead code elminiated when built with -Os, -O2, or higher. - * - * @param[in] mask is the part of the API to trace. - * - * @retval true Tracing is active for the mask. - * @retval false Do not trace. - */ -#if RTEMS_RFS_TRACE -bool rtems_rfs_trace (rtems_rfs_trace_mask mask); -#else -#define rtems_rfs_trace(_m) (0) -#endif - -/** - * Set the mask. - * - * @param[in] mask are the mask bits to set. - * - * @retval mask The previous mask. - */ -#if RTEMS_RFS_TRACE -rtems_rfs_trace_mask rtems_rfs_trace_set_mask (rtems_rfs_trace_mask mask); -#else -#define rtems_rfs_trace_set_mask(_m) -#endif - -/** - * Clear the mask. - * - * @param[in] mask are the mask bits to clear. - * - * @retval mask The previous mask. - */ -#if RTEMS_RFS_TRACE -rtems_rfs_trace_mask rtems_rfs_trace_clear_mask (rtems_rfs_trace_mask mask); -#else -#define rtems_rfs_trace_clear_mask(_m) -#endif - -/** - * Add shell trace shell command. - */ -#if RTEMS_RFS_TRACE -int rtems_rfs_trace_shell_command (int argc, char *argv[]); -#endif - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs.h b/cpukit/libfs/src/rfs/rtems-rfs.h deleted file mode 100644 index 958f9a636b..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file - * - * @brief RFS File system Initialization - * @ingroup rtems_rfs - * - * RTEMS File System - * - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined(RTEMS_RFS_DEFINED) -#define RTEMS_RFS_DEFINED - -#include <rtems.h> -#include <rtems/fs.h> - -/** - * @defgroup rtems_rfs RTEMS File System Group Management - * - * @ingroup FileSystemTypesAndMount - */ -/**@{*/ - -/** - * Initialise the RFS File system. - */ -int rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t *mt_entry, const void *data); - -/**@}*/ -#endif |