mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-29 17:06:19 +08:00
2002-05-28 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
* libblock, libfs moved to src/exec for multilib'ing.
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
config.cache
|
||||
config.guess
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
@@ -1,58 +0,0 @@
|
||||
2002-04-06 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* src/ramdisk.c: include <string.h>.
|
||||
* src/blkdev.c: include <string.h>.
|
||||
|
||||
2002-04-03 Alexander Kukuta <kam@oktet.ru>
|
||||
|
||||
* include/rtems/bdbuf.h: Address PR168 by changing bdbuf_buffer.avl.bal
|
||||
and bdbuf_buffer.avl.cache to signed char instead of char.
|
||||
|
||||
2002-03-27 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* configure.ac:
|
||||
AC_INIT(package,_RTEMS_VERSION,_RTEMS_BUGS).
|
||||
AM_INIT_AUTOMAKE([no-define foreign 1.6]).
|
||||
* include/Makefile.am: Remove AUTOMAKE_OPTIONS.
|
||||
* Makefile.am: Remove AUTOMAKE_OPTIONS.
|
||||
* src/Makefile.am: Remove AUTOMAKE_OPTIONS.
|
||||
|
||||
2002-03-21 Alexander Kukuta <kam@oktet.ru>
|
||||
|
||||
* src/bdbuf.c (avl_insert, avl_remove): Reimplemented from scratch
|
||||
to avoid using GPLed sources in RTEMS core.
|
||||
* src/bdbuf.c, include/rtems/bdbuf.h: Remove "binary tree"
|
||||
implementation which was used for debugging only.
|
||||
|
||||
2002-03-13 Victor V. Vengerov <vvv@oktet.ru>
|
||||
|
||||
* src/bdbuf.c (find_or_assign_buffer, rtems_bdbuf_read,
|
||||
rtems_bdbuf_sync, rtems_bdbuf_syncdev, bdbuf_swapout_task):
|
||||
Fix bug: disable interrupts and set level properly before
|
||||
_CORE_mutex_Seize invocation).
|
||||
|
||||
2002-02-28 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* Submitted by Victor V. Vengerov <vvv@oktet.ru> and merged
|
||||
into the RTEMS source.
|
||||
* ChangeLog, Makefile.am, README, configure.ac, include/Makefile.am,
|
||||
include/rtems/bdbuf.h, include/rtems/blkdev.h, include/rtems/diskdevs.h,
|
||||
include/rtems/ramdisk.h, include/rtems/.cvsignore, include/.cvsignore,
|
||||
src/Makefile.am, src/bdbuf.c, src/blkdev.c, src/diskdevs.c,
|
||||
src/ramdisk.c, src/.cvsignore, .cvsignore: New files.
|
||||
|
||||
2001-11-29 Victor V. Vengerov <vvv@oktet.ru>
|
||||
* AVL trees implementation added.
|
||||
|
||||
2001-11-16 Victor V. Vengerov <vvv@oktet.ru>
|
||||
* include/rtems/bdbuf.h, src/bdbuf.c(rtems_bdbuf_syncdev): New.
|
||||
|
||||
2001-11-07 Victor V. Vengerov <vvv@oktet.ru>
|
||||
|
||||
* ChangeLog: New file.
|
||||
* src/, include/, include/rtems/: New directories.
|
||||
* README, configure.ac, Makefile.am, src/Makefile.am,
|
||||
include/Makefile.am: New files.
|
||||
* include/rtems/bdbuf.h include/rtems/blkdev.h
|
||||
include/rtems/diskdevs.h include/rtems/ramdisk.h
|
||||
src/bdbuf.c src/blkdev.c src/diskdevs.c src/ramdisk.c: New files.
|
||||
@@ -1,12 +0,0 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
ACLOCAL_AMFLAGS = -I ../../../aclocal
|
||||
|
||||
SUBDIRS = include src
|
||||
|
||||
EXTRA_DIST = README
|
||||
|
||||
include $(top_srcdir)/../../../automake/subdirs.am
|
||||
include $(top_srcdir)/../../../automake/local.am
|
||||
@@ -1,14 +0,0 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
This directory contains the block device (HDD, CDROMs, etc) support code.
|
||||
It includes:
|
||||
- block device driver interface
|
||||
- generic open/close/read/write/ioctl primitives for block device drivers
|
||||
- disk I/O buffering
|
||||
- logical disk support
|
||||
- RAM disk block device driver
|
||||
|
||||
Victor V. Vengerov, <vvv@oktet.ru>
|
||||
November, 7 2001
|
||||
@@ -1,32 +0,0 @@
|
||||
## Process this file with autoconf to produce a configure script.
|
||||
##
|
||||
## $Id$
|
||||
|
||||
AC_PREREQ(2.52)
|
||||
AC_INIT([rtems-c-src-libblock],[_RTEMS_VERSION],[rtems-bugs@OARcorp.com])
|
||||
AC_CONFIG_SRCDIR([src/bdbuf.c])
|
||||
RTEMS_TOP(../../..)
|
||||
AC_CONFIG_AUX_DIR(../../..)
|
||||
|
||||
RTEMS_CANONICAL_TARGET_CPU
|
||||
RTEMS_CANONICAL_HOST
|
||||
|
||||
AM_INIT_AUTOMAKE([no-define foreign 1.6])
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
RTEMS_ENV_RTEMSBSP
|
||||
RTEMS_CHECK_CPU
|
||||
RTEMS_CHECK_CUSTOM_BSP(RTEMS_BSP)
|
||||
RTEMS_PROG_CC_FOR_TARGET
|
||||
RTEMS_ENABLE_BARE
|
||||
|
||||
RTEMS_CANONICALIZE_TOOLS
|
||||
|
||||
RTEMS_PROJECT_ROOT
|
||||
|
||||
# Explicitly list all Makefiles here
|
||||
AC_CONFIG_FILES([Makefile
|
||||
include/Makefile
|
||||
src/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
@@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,22 +0,0 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
|
||||
include_rtemsdir = $(includedir)/rtems
|
||||
|
||||
$(PROJECT_INCLUDE)/%.h: %.h
|
||||
$(INSTALL_DATA) $< $@
|
||||
|
||||
$(PROJECT_INCLUDE)/rtems:
|
||||
@$(mkinstalldirs) $@
|
||||
|
||||
include_rtems_HEADERS = \
|
||||
rtems/bdbuf.h rtems/blkdev.h rtems/diskdevs.h rtems/ramdisk.h
|
||||
|
||||
PREINSTALL_FILES = $(PROJECT_INCLUDE)/rtems \
|
||||
$(include_rtems_HEADERS:%=$(PROJECT_INCLUDE)/%)
|
||||
|
||||
all-local: $(PREINSTALL_FILES)
|
||||
|
||||
include $(top_srcdir)/../../../automake/local.am
|
||||
@@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,275 +0,0 @@
|
||||
/* bdbuf.h -- block device buffer management
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Victor V. Vengerov <vvv@oktet.ru>
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#ifndef __RTEMS_LIBBLOCK_BDBUF_H__
|
||||
#define __RTEMS_LIBBLOCK_BDBUF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <chain.h>
|
||||
|
||||
#include "rtems/blkdev.h"
|
||||
#include "rtems/diskdevs.h"
|
||||
|
||||
|
||||
/*
|
||||
* To manage buffers we using Buffer Descriptors.
|
||||
* To speed-up buffer lookup descriptors are organized in AVL-Tree.
|
||||
* The fields 'dev' and 'block' are search key.
|
||||
*/
|
||||
|
||||
/* Buffer descriptors
|
||||
* Descriptors organized in AVL-tree to speedup buffer lookup.
|
||||
* dev and block fields are search key in AVL-tree.
|
||||
* Modified buffers, free buffers and used buffers linked in 'mod', 'free' and
|
||||
* 'lru' chains appropriately.
|
||||
*/
|
||||
|
||||
typedef struct bdbuf_buffer {
|
||||
Chain_Node link; /* Link in the lru, mod or free chains */
|
||||
|
||||
struct bdbuf_avl_node {
|
||||
signed char cache; /* Cache */
|
||||
|
||||
struct bdbuf_buffer* left; /* Left Child */
|
||||
struct bdbuf_buffer* right; /* Right Child */
|
||||
|
||||
signed char bal; /* The balance of the sub-tree */
|
||||
} avl;
|
||||
|
||||
dev_t dev; /* device number */
|
||||
blkdev_bnum block; /* block number on the device */
|
||||
|
||||
char *buffer; /* Pointer to the buffer memory area */
|
||||
rtems_status_code status; /* Last I/O operation completion status */
|
||||
int error; /* If status != RTEMS_SUCCESSFUL, this field contains
|
||||
errno value which can be used by user later */
|
||||
boolean modified:1; /* =1 if buffer was modified */
|
||||
boolean in_progress:1; /* =1 if exchange with disk is in progress;
|
||||
need to wait on semaphore */
|
||||
boolean actual:1; /* Buffer contains actual data */
|
||||
int use_count; /* Usage counter; incremented when somebody use
|
||||
this buffer; decremented when buffer released
|
||||
without modification or when buffer is flushed
|
||||
by swapout task */
|
||||
|
||||
rtems_bdpool_id pool; /* Identifier of buffer pool to which this buffer
|
||||
belongs */
|
||||
CORE_mutex_Control transfer_sema;
|
||||
/* Transfer operation semaphore */
|
||||
} bdbuf_buffer;
|
||||
|
||||
|
||||
|
||||
/* bdbuf_config structure describes block configuration (size,
|
||||
* amount, memory location) for buffering layer
|
||||
*/
|
||||
typedef struct rtems_bdbuf_config {
|
||||
int size; /* Size of block */
|
||||
int num; /* Number of blocks of appropriate size */
|
||||
char *mem_area; /* Pointer to the blocks location or NULL, in this
|
||||
case memory for blocks will be allocated by
|
||||
Buffering Layer with the help of RTEMS partition
|
||||
manager */
|
||||
} rtems_bdbuf_config;
|
||||
|
||||
extern rtems_bdbuf_config rtems_bdbuf_configuration[];
|
||||
extern int rtems_bdbuf_configuration_size;
|
||||
|
||||
/* rtems_bdbuf_init --
|
||||
* Prepare buffering layer to work - initialize buffer descritors
|
||||
* and (if it is neccessary) buffers. Buffers will be allocated accoriding
|
||||
* to the configuration table, each entry describes kind of block and
|
||||
* amount requested. After initialization all blocks is placed into
|
||||
* free elements lists.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* conf_table - pointer to the buffers configuration table
|
||||
* size - number of entries in configuration table
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS status code (RTEMS_SUCCESSFUL if operation completed successfully
|
||||
* or error code if error is occured)
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_bdbuf_init(rtems_bdbuf_config *conf_table, int size);
|
||||
|
||||
|
||||
/* rtems_bdbuf_get --
|
||||
* Obtain block buffer. If specified block already cached (i.e. there's
|
||||
* block in the _modified_, or _recently_used_), return address
|
||||
* of appropriate buffer descriptor and increment reference counter to 1.
|
||||
* If block is not cached, allocate new buffer and return it. Data
|
||||
* shouldn't be read to the buffer from media; buffer may contains
|
||||
* arbitrary data. This primitive may be blocked if there are no free
|
||||
* buffer descriptors available and there are no unused non-modified
|
||||
* (or synchronized with media) buffers available.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* device - device number (constructed of major and minor device number)
|
||||
* block - linear media block number
|
||||
* bd - address of variable to store pointer to the buffer descriptor
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS status code (RTEMS_SUCCESSFUL if operation completed successfully
|
||||
* or error code if error is occured)
|
||||
*
|
||||
* SIDE EFFECTS:
|
||||
* bufget_sema semaphore obtained by this primitive.
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_bdbuf_get(dev_t device, blkdev_bnum block, bdbuf_buffer **bdb_ptr);
|
||||
|
||||
/* rtems_bdbuf_read --
|
||||
* (Similar to the rtems_bdbuf_get, except reading data from media)
|
||||
* Obtain block buffer. If specified block already cached, return address
|
||||
* of appropriate buffer and increment reference counter to 1. If block is
|
||||
* not cached, allocate new buffer and read data to it from the media.
|
||||
* This primitive may be blocked on waiting until data to be read from
|
||||
* media, if there are no free buffer descriptors available and there are
|
||||
* no unused non-modified (or synchronized with media) buffers available.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* device - device number (consists of major and minor device number)
|
||||
* block - linear media block number
|
||||
* bd - address of variable to store pointer to the buffer descriptor
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS status code (RTEMS_SUCCESSFUL if operation completed successfully
|
||||
* or error code if error is occured)
|
||||
*
|
||||
* SIDE EFFECTS:
|
||||
* bufget_sema and transfer_sema semaphores obtained by this primitive.
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_bdbuf_read(dev_t device, blkdev_bnum block, bdbuf_buffer **bdb_ptr);
|
||||
|
||||
/* rtems_bdbuf_release --
|
||||
* Release buffer allocated before. This primitive decrease the
|
||||
* usage counter. If it is zero, further destiny of buffer depends on
|
||||
* 'modified' status. If buffer was modified, it is placed to the end of
|
||||
* mod list and flush task waken up. If buffer was not modified,
|
||||
* it is placed to the end of lru list, and bufget_sema released, allowing
|
||||
* to reuse this buffer.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* bd_buf - pointer to the bdbuf_buffer structure previously obtained using
|
||||
* get/read primitive.
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS status code (RTEMS_SUCCESSFUL if operation completed successfully
|
||||
* or error code if error is occured)
|
||||
*
|
||||
* SIDE EFFECTS:
|
||||
* flush_sema and bufget_sema semaphores may be released by this primitive.
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_bdbuf_release(bdbuf_buffer *bd_buf);
|
||||
|
||||
/* rtems_bdbuf_release_modified --
|
||||
* Release buffer allocated before, assuming that it is _modified_ by
|
||||
* it's owner. This primitive decrease usage counter for buffer, mark
|
||||
* buffer descriptor as modified. If usage counter is 0, insert it at
|
||||
* end of mod chain and release flush_sema semaphore to activate the
|
||||
* flush task.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* bd_buf - pointer to the bdbuf_buffer structure previously obtained using
|
||||
* get/read primitive.
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS status code (RTEMS_SUCCESSFUL if operation completed successfully
|
||||
* or error code if error is occured)
|
||||
*
|
||||
* SIDE EFFECTS:
|
||||
* flush_sema semaphore may be released by this primitive.
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_bdbuf_release_modified(bdbuf_buffer *bd_buf);
|
||||
|
||||
/* rtems_bdbuf_sync --
|
||||
* Wait until specified buffer synchronized with disk. Invoked on exchanges
|
||||
* critical for data consistency on the media. This primitive mark owned
|
||||
* block as modified, decrease usage counter. If usage counter is 0,
|
||||
* block inserted to the mod chain and flush_sema semaphore released.
|
||||
* Finally, primitives blocked on transfer_sema semaphore.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* bd_buf - pointer to the bdbuf_buffer structure previously obtained using
|
||||
* get/read primitive.
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS status code (RTEMS_SUCCESSFUL if operation completed successfully
|
||||
* or error code if error is occured)
|
||||
*
|
||||
* SIDE EFFECTS:
|
||||
* Primitive may be blocked on transfer_sema semaphore.
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_bdbuf_sync(bdbuf_buffer *bd_buf);
|
||||
|
||||
/* rtems_bdbuf_syncdev --
|
||||
* Synchronize with disk all buffers containing the blocks belonging to
|
||||
* specified device.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* dev - block device number
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS status code (RTEMS_SUCCESSFUL if operation completed successfully
|
||||
* or error code if error is occured)
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_bdbuf_syncdev(dev_t dev);
|
||||
|
||||
/* rtems_bdbuf_find_pool --
|
||||
* Find first appropriate buffer pool. This primitive returns the index
|
||||
* of first buffer pool which block size is greater than or equal to
|
||||
* specified size.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* block_size - requested block size
|
||||
* pool - placeholder for result
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS status code: RTEMS_SUCCESSFUL if operation completed successfully,
|
||||
* RTEMS_INVALID_SIZE if specified block size is invalid (not a power
|
||||
* of 2), RTEMS_NOT_DEFINED if buffer pool for this or greater block size
|
||||
* is not configured.
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_bdbuf_find_pool(int block_size, rtems_bdpool_id *pool);
|
||||
|
||||
/* rtems_bdbuf_get_pool_info --
|
||||
* Obtain characteristics of buffer pool with specified number.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* pool - buffer pool number
|
||||
* block_size - block size for which buffer pool is configured returned
|
||||
* there
|
||||
* blocks - number of buffers in buffer pool returned there
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS status code: RTEMS_SUCCESSFUL if operation completed successfully,
|
||||
* RTEMS_INVALID_NUMBER if appropriate buffer pool is not configured.
|
||||
*
|
||||
* NOTE:
|
||||
* Buffer pools enumerated contiguously starting from 0.
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_bdbuf_get_pool_info(rtems_bdpool_id pool, int *block_size, int *blocks);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
* blkdev.h - block device driver interface definitions
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Victor V. Vengerov <vvv@oktet.ru>
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#ifndef __RTEMS_LIBBLOCK_BLKDEV_H__
|
||||
#define __RTEMS_LIBBLOCK_BLKDEV_H__
|
||||
|
||||
#include <rtems.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Interface with device drivers
|
||||
* Block device looks, initialized and behaves like traditional RTEMS device
|
||||
* driver. Heart of the block device driver is in BIOREQUEST ioctl. This call
|
||||
* puts I/O request to the block device queue, in priority order, for
|
||||
* asynchronous processing. When driver executes request, req_done
|
||||
* function invoked, so callee knows about it. Look for details below.
|
||||
*/
|
||||
|
||||
|
||||
/* Block device block number datatype */
|
||||
typedef rtems_unsigned32 blkdev_bnum;
|
||||
|
||||
/* Block device request type */
|
||||
typedef enum blkdev_request_op {
|
||||
BLKDEV_REQ_READ, /* Read operation */
|
||||
BLKDEV_REQ_WRITE /* Write operation */
|
||||
} blkdev_request_op;
|
||||
|
||||
/* Type for block device request done callback function.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* arg - argument supplied in blkdev_request
|
||||
* status - rtems status code for this operation
|
||||
* errno - errno value to be passed to the user when
|
||||
* status != RTEMS_SUCCESSFUL
|
||||
*/
|
||||
typedef void (* blkdev_request_cb)(void *arg,
|
||||
rtems_status_code status,
|
||||
int error);
|
||||
|
||||
/* blkdev_sg_buffer
|
||||
* Block device scatter/gather buffer structure
|
||||
*/
|
||||
typedef struct blkdev_sg_buffer {
|
||||
rtems_unsigned32 length; /* Buffer length */
|
||||
void *buffer; /* Buffer pointer */
|
||||
} blkdev_sg_buffer;
|
||||
|
||||
/* blkdev_request (Block Device Request) structure is
|
||||
* used to read/write a number of blocks from/to device.
|
||||
*/
|
||||
typedef struct blkdev_request {
|
||||
blkdev_request_op req; /* Block device operation (read or write) */
|
||||
blkdev_request_cb req_done; /* Callback function */
|
||||
void *done_arg; /* Argument to be passed to callback function*/
|
||||
blkdev_bnum start; /* Start block number */
|
||||
rtems_unsigned32 count; /* Number of blocks to be exchanged */
|
||||
rtems_unsigned32 bufnum; /* Number of buffers provided */
|
||||
|
||||
blkdev_sg_buffer bufs[0];/* List of scatter/gather buffers */
|
||||
} blkdev_request;
|
||||
|
||||
/* Block device IOCTL request codes */
|
||||
#define BLKIO_REQUEST _IOWR('B', 1, blkdev_request)
|
||||
#define BLKIO_GETBLKSIZE _IO('B', 2)
|
||||
#define BLKIO_GETSIZE _IO('B', 3)
|
||||
#define BLKIO_SYNCDEV _IO('B', 4)
|
||||
|
||||
/* Device driver interface conventions suppose that driver may
|
||||
* contain initialize/open/close/read/write/ioctl entry points. These
|
||||
* primitives (except initialize) can be implemented in generic fashion,
|
||||
* based upon supplied block device driver ioctl handler. Every block
|
||||
* device driver should provide initialize entry point, which is register
|
||||
* all block devices and appropriate ioctl handlers.
|
||||
*/
|
||||
|
||||
#define GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
|
||||
rtems_blkdev_generic_open, rtems_blkdev_generic_close, \
|
||||
rtems_blkdev_generic_read, rtems_blkdev_generic_write, \
|
||||
rtems_blkdev_generic_ioctl
|
||||
|
||||
/* blkdev_generic_read --
|
||||
* Generic block device read primitive. Implemented using block device
|
||||
* buffer management primitives.
|
||||
*/
|
||||
rtems_device_driver
|
||||
rtems_blkdev_generic_read(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
);
|
||||
|
||||
/* blkdev_generic_write --
|
||||
* Generic block device driver write primitive. Implemented using block
|
||||
* device buffer management primitives.
|
||||
*/
|
||||
rtems_device_driver
|
||||
rtems_blkdev_generic_write(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
);
|
||||
|
||||
/* blkdev_generic_open --
|
||||
* Generic block device open primitive.
|
||||
*/
|
||||
rtems_device_driver
|
||||
rtems_blkdev_generic_open(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
);
|
||||
|
||||
/* blkdev_generic_close --
|
||||
* Generic block device close primitive.
|
||||
*/
|
||||
rtems_device_driver
|
||||
rtems_blkdev_generic_close(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
);
|
||||
|
||||
/* blkdev_generic_ioctl --
|
||||
* Generic block device ioctl primitive.
|
||||
*/
|
||||
rtems_device_driver
|
||||
rtems_blkdev_generic_ioctl(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,206 +0,0 @@
|
||||
/*
|
||||
* logdisk.h - Physical and logical block devices (disks) support
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Victor V. Vengerov <vvv@oktet.ru>
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#ifndef __RTEMS_LIBBLOCK_LOGDISK_H__
|
||||
#define __RTEMS_LIBBLOCK_LOGDISK_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "rtems/blkdev.h"
|
||||
|
||||
/* Buffer pool identifier */
|
||||
typedef int rtems_bdpool_id;
|
||||
|
||||
/* Block device ioctl handler */
|
||||
typedef int (* block_device_ioctl) (dev_t dev, int req, void *argp);
|
||||
|
||||
/* disk_device: Entry of this type created for every disk device (both for
|
||||
* logical and physical disks).
|
||||
* Array of arrays of pointers to disk_device structures maintained. First
|
||||
* table indexed by major number and second table indexed by minor number.
|
||||
* Such data organization allow quick lookup using data structure of
|
||||
* moderated size.
|
||||
*/
|
||||
typedef struct disk_device {
|
||||
dev_t dev; /* Device ID (major + minor) */
|
||||
struct disk_device *phys_dev; /* Physical device ID (the same
|
||||
as dev if this entry specifies
|
||||
the physical device) */
|
||||
char *name; /* Disk device name */
|
||||
int uses; /* Use counter. Device couldn't be
|
||||
removed if it is in use. */
|
||||
int start; /* Starting block number (0 for
|
||||
physical devices, block offset
|
||||
on the related physical device
|
||||
for logical device) */
|
||||
int size; /* Size of physical or logical disk
|
||||
in disk blocks */
|
||||
int block_size; /* Size of device block (minimum
|
||||
transfer unit) in bytes
|
||||
(must be power of 2) */
|
||||
int block_size_log2; /* log2 of block_size */
|
||||
rtems_bdpool_id pool; /* Buffer pool assigned to this
|
||||
device */
|
||||
block_device_ioctl ioctl; /* ioctl handler for this block
|
||||
device */
|
||||
} disk_device;
|
||||
|
||||
/* rtems_disk_create_phys --
|
||||
* Create physical disk entry. This function usually invoked from
|
||||
* block device driver initialization code when physical device
|
||||
* detected in the system. Device driver should provide ioctl handler
|
||||
* to allow block device access operations. This primitive will register
|
||||
* device in rtems (invoke rtems_io_register_name).
|
||||
*
|
||||
* PARAMETERS:
|
||||
* dev - device identifier (major, minor numbers)
|
||||
* block_size - size of disk block (minimum data transfer unit); must be
|
||||
* power of 2
|
||||
* disk_size - number of blocks on device
|
||||
* handler - IOCTL handler (function providing basic block input/output
|
||||
* request handling BIOREQUEST and other device management
|
||||
* operations)
|
||||
* name - character name of device (e.g. /dev/hda)
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS_SUCCESSFUL if information about new physical disk added, or
|
||||
* error code if error occured (device already registered, wrong block
|
||||
* size value, no memory available).
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_disk_create_phys(dev_t dev, int block_size, int disk_size,
|
||||
block_device_ioctl handler,
|
||||
char *name);
|
||||
|
||||
/* rtems_disk_create_log --
|
||||
* Create logical disk entry. Logical disk is contiguous area on physical
|
||||
* disk. Disk may be splitted to several logical disks in several ways:
|
||||
* manually or using information stored in blocks on physical disk
|
||||
* (DOS-like partition table, BSD disk label, etc). This function usually
|
||||
* invoked from application when application-specific splitting are in use,
|
||||
* or from generic code which handle different logical disk organizations.
|
||||
* This primitive will register device in rtems (invoke
|
||||
* rtems_io_register_name).
|
||||
*
|
||||
* PARAMETERS:
|
||||
* dev - logical device identifier (major, minor numbers)
|
||||
* phys - physical device (block device which holds this logical disk)
|
||||
* identifier
|
||||
* start - starting block number on the physical device
|
||||
* size - logical disk size in blocks
|
||||
* name - logical disk name
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS_SUCCESSFUL if logical device successfully added, or error code
|
||||
* if error occured (device already registered, no physical device
|
||||
* exists, logical disk is out of physical disk boundaries, no memory
|
||||
* available).
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_disk_create_log(dev_t dev, dev_t phys, int start, int size, char *name);
|
||||
|
||||
/* rtems_disk_delete --
|
||||
* Delete physical or logical disk device. Device may be deleted if its
|
||||
* use counter (and use counters of all logical devices - if it is
|
||||
* physical device) equal to 0. When physical device deleted,
|
||||
* all logical devices deleted inherently. Appropriate devices removed
|
||||
* from "/dev" filesystem.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* dev - device identifier (major, minor numbers)
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS_SUCCESSFUL if block device successfully deleted, or error code
|
||||
* if error occured (device is not defined, device is in use).
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_disk_delete(dev_t dev);
|
||||
|
||||
/* rtems_disk_lookup --
|
||||
* Find block device descriptor by its device identifier. This function
|
||||
* increment usage counter to 1. User should release disk_device structure
|
||||
* by invoking rtems_disk_release primitive.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* dev - device identifier (major, minor numbers)
|
||||
*
|
||||
* RETURNS:
|
||||
* pointer to the block device descriptor, or NULL if no such device
|
||||
* exists.
|
||||
*/
|
||||
disk_device *
|
||||
rtems_disk_lookup(dev_t dev);
|
||||
|
||||
/* rtems_disk_release --
|
||||
* Release disk_device structure (decrement usage counter to 1).
|
||||
*
|
||||
* PARAMETERS:
|
||||
* dd - pointer to disk device structure
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS_SUCCESSFUL
|
||||
*
|
||||
* NOTE:
|
||||
* It should be implemented as inline function.
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_disk_release(disk_device *dd);
|
||||
|
||||
/* rtems_disk_next --
|
||||
* Disk device enumerator. Looking for device having device number larger
|
||||
* than dev and return disk device descriptor for it. If there are no
|
||||
* such device, NULL value returned.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* dev - device number (use -1 to start search)
|
||||
*
|
||||
* RETURNS:
|
||||
* Pointer to the disk descriptor for next disk device, or NULL if all
|
||||
* devices enumerated. */
|
||||
disk_device *
|
||||
rtems_disk_next(dev_t dev);
|
||||
|
||||
/* rtems_diskio_initialize --
|
||||
* Initialization of disk device library (initialize all data structures,
|
||||
* etc.)
|
||||
*
|
||||
* PARAMETERS:
|
||||
* none
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS_SUCCESSFUL if library initialized, or error code if error
|
||||
* occured.
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_disk_io_initialize(void);
|
||||
|
||||
/* rtems_diskio_done --
|
||||
* Release all resources allocated for disk device interface.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* none
|
||||
*
|
||||
* RETURNS:
|
||||
* RTEMS_SUCCESSFUL if all resources released, or error code if error
|
||||
* occured.
|
||||
*/
|
||||
rtems_status_code
|
||||
rtems_disk_io_done(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
/* ramdisk.c -- RAM disk block device implementation
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Victor V. Vengerov <vvv@oktet.ru>
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#ifndef __RTEMS_LIBBLOCK_RAMDISK_H__
|
||||
#define __RTEMS_LIBBLOCK_RAMDISK_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
#include "rtems/blkdev.h"
|
||||
|
||||
/* RAM disk configuration table entry */
|
||||
typedef struct rtems_ramdisk_config {
|
||||
int block_size; /* RAM disk block size */
|
||||
int block_num; /* Number of blocks on this RAM disk */
|
||||
void *location; /* RAM disk permanent location (out of RTEMS controlled
|
||||
memory), or NULL if RAM disk memory should be
|
||||
allocated dynamically */
|
||||
} rtems_ramdisk_config;
|
||||
|
||||
/* If application want to use RAM disk, it should specify configuration of
|
||||
* available RAM disks.
|
||||
* The following is definitions for RAM disk configuration table
|
||||
*/
|
||||
extern rtems_ramdisk_config rtems_ramdisk_configuration[];
|
||||
extern int rtems_ramdisk_configuration_size;
|
||||
|
||||
/* ramdisk_initialize --
|
||||
* RAM disk driver initialization entry point.
|
||||
*/
|
||||
rtems_device_driver
|
||||
ramdisk_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg);
|
||||
|
||||
#define RAMDISK_DRIVER_TABLE_ENTRY \
|
||||
{ ramdisk_initialize, GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,32 +0,0 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
|
||||
LIBNAME = libblock
|
||||
LIB = ${ARCH}/${LIBNAME}.a
|
||||
|
||||
C_FILES = bdbuf.c blkdev.c diskdevs.c ramdisk.c
|
||||
|
||||
C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
|
||||
|
||||
SRCS = $(C_FILES)
|
||||
OBJS = $(C_O_FILES)
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../../../automake/compile.am
|
||||
include $(top_srcdir)/../../../automake/lib.am
|
||||
|
||||
AM_CFLAGS += $(LIBC_DEFINES)
|
||||
|
||||
TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a
|
||||
|
||||
$(LIB): ${OBJS}
|
||||
$(make-library)
|
||||
|
||||
$(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a: $(LIB)
|
||||
$(INSTALL_DATA) $< $@
|
||||
|
||||
all-local: ${ARCH} $(PREINSTALL_FILES) $(TMPINSTALL_FILES)
|
||||
|
||||
include $(top_srcdir)/../../../automake/local.am
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,245 +0,0 @@
|
||||
/*
|
||||
* blkdev.h - block device driver generic support
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Victor V. Vengerov <vvv@oktet.ru>
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "rtems/diskdevs.h"
|
||||
#include "rtems/bdbuf.h"
|
||||
|
||||
/* rtems_blkdev_generic_read --
|
||||
* Generic block device read primitive. Implemented using block device
|
||||
* buffer management primitives.
|
||||
*/
|
||||
rtems_device_driver
|
||||
rtems_blkdev_generic_read(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg)
|
||||
{
|
||||
rtems_libio_rw_args_t *args = arg;
|
||||
int block_size_log2;
|
||||
int block_size;
|
||||
char *buf;
|
||||
unsigned int count;
|
||||
unsigned int block;
|
||||
unsigned int blkofs;
|
||||
dev_t dev;
|
||||
disk_device *dd;
|
||||
|
||||
dev = rtems_filesystem_make_dev_t(major, minor);
|
||||
dd = rtems_disk_lookup(dev);
|
||||
if (dd == NULL)
|
||||
return RTEMS_INVALID_NUMBER;
|
||||
|
||||
block_size_log2 = dd->block_size_log2;
|
||||
block_size = dd->block_size;
|
||||
|
||||
buf = args->buffer;
|
||||
count = args->count;
|
||||
args->bytes_moved = 0;
|
||||
|
||||
block = args->offset >> block_size_log2;
|
||||
blkofs = args->offset & (block_size - 1);
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
bdbuf_buffer *diskbuf;
|
||||
int copy;
|
||||
rtems_status_code rc;
|
||||
|
||||
rc = rtems_bdbuf_read(dev, block, &diskbuf);
|
||||
if (rc != RTEMS_SUCCESSFUL)
|
||||
return rc;
|
||||
copy = block_size - blkofs;
|
||||
if (copy > count)
|
||||
copy = count;
|
||||
memcpy(buf, (char *)diskbuf->buffer + blkofs, copy);
|
||||
rc = rtems_bdbuf_release(diskbuf);
|
||||
args->bytes_moved += copy;
|
||||
if (rc != RTEMS_SUCCESSFUL)
|
||||
return rc;
|
||||
count -= copy;
|
||||
buf += copy;
|
||||
blkofs = 0;
|
||||
block++;
|
||||
}
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
/* rtems_blkdev_generic_write --
|
||||
* Generic block device write primitive. Implemented using block device
|
||||
* buffer management primitives.
|
||||
*/
|
||||
rtems_device_driver
|
||||
rtems_blkdev_generic_write(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg)
|
||||
{
|
||||
rtems_libio_rw_args_t *args = arg;
|
||||
int block_size_log2;
|
||||
int block_size;
|
||||
char *buf;
|
||||
unsigned int count;
|
||||
unsigned int block;
|
||||
unsigned int blkofs;
|
||||
dev_t dev;
|
||||
rtems_status_code rc;
|
||||
disk_device *dd;
|
||||
|
||||
dev = rtems_filesystem_make_dev_t(major, minor);
|
||||
dd = rtems_disk_lookup(dev);
|
||||
if (dd == NULL)
|
||||
return RTEMS_INVALID_NUMBER;
|
||||
|
||||
block_size_log2 = dd->block_size_log2;
|
||||
block_size = dd->block_size;
|
||||
|
||||
buf = args->buffer;
|
||||
count = args->count;
|
||||
args->bytes_moved = 0;
|
||||
|
||||
block = args->offset >> block_size_log2;
|
||||
blkofs = args->offset & (block_size - 1);
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
bdbuf_buffer *diskbuf;
|
||||
int copy;
|
||||
|
||||
if ((blkofs == 0) && (count > block_size))
|
||||
rc = rtems_bdbuf_get(dev, block, &diskbuf);
|
||||
else
|
||||
rc = rtems_bdbuf_read(dev, block, &diskbuf);
|
||||
if (rc != RTEMS_SUCCESSFUL)
|
||||
return rc;
|
||||
|
||||
copy = block_size - blkofs;
|
||||
if (copy > count)
|
||||
copy = count;
|
||||
memcpy((char *)diskbuf->buffer + blkofs, buf, copy);
|
||||
args->bytes_moved += copy;
|
||||
|
||||
rc = rtems_bdbuf_release_modified(diskbuf);
|
||||
if (rc != RTEMS_SUCCESSFUL)
|
||||
return rc;
|
||||
|
||||
count -= copy;
|
||||
buf += copy;
|
||||
blkofs = 0;
|
||||
block++;
|
||||
}
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
/* blkdev_generic_open --
|
||||
* Generic block device open primitive.
|
||||
*/
|
||||
rtems_device_driver
|
||||
rtems_blkdev_generic_open(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg)
|
||||
{
|
||||
dev_t dev;
|
||||
disk_device *dd;
|
||||
|
||||
dev = rtems_filesystem_make_dev_t(major, minor);
|
||||
dd = rtems_disk_lookup(dev);
|
||||
if (dd == NULL)
|
||||
return RTEMS_INVALID_NUMBER;
|
||||
|
||||
dd->uses++;
|
||||
|
||||
rtems_disk_release(dd);
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
/* blkdev_generic_close --
|
||||
* Generic block device close primitive.
|
||||
*/
|
||||
rtems_device_driver
|
||||
rtems_blkdev_generic_close(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg)
|
||||
{
|
||||
dev_t dev;
|
||||
disk_device *dd;
|
||||
|
||||
dev = rtems_filesystem_make_dev_t(major, minor);
|
||||
dd = rtems_disk_lookup(dev);
|
||||
if (dd == NULL)
|
||||
return RTEMS_INVALID_NUMBER;
|
||||
|
||||
dd->uses--;
|
||||
|
||||
rtems_disk_release(dd);
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
/* blkdev_generic_ioctl --
|
||||
* Generic block device ioctl primitive.
|
||||
*/
|
||||
rtems_device_driver
|
||||
rtems_blkdev_generic_ioctl(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg)
|
||||
{
|
||||
rtems_libio_ioctl_args_t *args = arg;
|
||||
dev_t dev;
|
||||
disk_device *dd;
|
||||
int rc;
|
||||
|
||||
dev = rtems_filesystem_make_dev_t(major, minor);
|
||||
dd = rtems_disk_lookup(dev);
|
||||
if (dd == NULL)
|
||||
return RTEMS_INVALID_NUMBER;
|
||||
|
||||
switch (args->command)
|
||||
{
|
||||
case BLKIO_GETBLKSIZE:
|
||||
args->ioctl_return = dd->block_size;
|
||||
break;
|
||||
|
||||
case BLKIO_GETSIZE:
|
||||
args->ioctl_return = dd->size;
|
||||
break;
|
||||
|
||||
case BLKIO_SYNCDEV:
|
||||
rc = rtems_bdbuf_syncdev(dd->dev);
|
||||
args->ioctl_return = (rc == RTEMS_SUCCESSFUL ? 0 : -1);
|
||||
break;
|
||||
|
||||
case BLKIO_REQUEST:
|
||||
{
|
||||
blkdev_request *req = args->buffer;
|
||||
req->start += dd->start;
|
||||
args->ioctl_return = dd->ioctl(dd->phys_dev->dev, args->command,
|
||||
req);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
args->ioctl_return = dd->ioctl(dd->phys_dev->dev, args->command,
|
||||
args->buffer);
|
||||
break;
|
||||
}
|
||||
rtems_disk_release(dd);
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,225 +0,0 @@
|
||||
/* ramdisk.c -- RAM disk block device implementation
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Victor V. Vengerov <vvv@oktet.ru>
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "rtems/blkdev.h"
|
||||
#include "rtems/diskdevs.h"
|
||||
#include "rtems/ramdisk.h"
|
||||
|
||||
#define RAMDISK_DEVICE_BASE_NAME "/dev/ramdisk"
|
||||
|
||||
/* Internal RAM disk descriptor */
|
||||
struct ramdisk {
|
||||
int block_size; /* RAM disk block size */
|
||||
int block_num; /* Number of blocks on this RAM disk */
|
||||
void *area; /* RAM disk memory area */
|
||||
rtems_boolean initialized;/* RAM disk is initialized */
|
||||
rtems_boolean malloced; /* != 0, if memory allocated by malloc for this
|
||||
RAM disk */
|
||||
};
|
||||
|
||||
static struct ramdisk *ramdisk;
|
||||
static int nramdisks;
|
||||
|
||||
/* ramdisk_read --
|
||||
* RAM disk READ request handler. This primitive copies data from RAM
|
||||
* disk to supplied buffer and invoke the callout function to inform
|
||||
* upper layer that reading is completed.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* req - pointer to the READ block device request info
|
||||
*
|
||||
* RETURNS:
|
||||
* ioctl return value
|
||||
*/
|
||||
static int
|
||||
ramdisk_read(struct ramdisk *rd, blkdev_request *req)
|
||||
{
|
||||
char *from;
|
||||
rtems_unsigned32 i;
|
||||
blkdev_sg_buffer *sg;
|
||||
rtems_unsigned32 remains;
|
||||
|
||||
from = (char *)rd->area + (req->start * rd->block_size);
|
||||
remains = rd->block_size * req->count;
|
||||
sg = req->bufs;
|
||||
for (i = 0; (remains > 0) && (i < req->bufnum); i++, sg++)
|
||||
{
|
||||
int count = sg->length;
|
||||
if (count > remains)
|
||||
count = remains;
|
||||
memcpy(sg->buffer, from, count);
|
||||
remains -= count;
|
||||
}
|
||||
req->req_done(req->done_arg, RTEMS_SUCCESSFUL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ramdisk_write --
|
||||
* RAM disk WRITE request handler. This primitive copies data from
|
||||
* supplied buffer to RAM disk and invoke the callout function to inform
|
||||
* upper layer that writing is completed.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* req - pointer to the WRITE block device request info
|
||||
*
|
||||
* RETURNS:
|
||||
* ioctl return value
|
||||
*/
|
||||
static int
|
||||
ramdisk_write(struct ramdisk *rd, blkdev_request *req)
|
||||
{
|
||||
char *to;
|
||||
rtems_unsigned32 i;
|
||||
blkdev_sg_buffer *sg;
|
||||
rtems_unsigned32 remains;
|
||||
|
||||
to = (char *)rd->area + (req->start * rd->block_size);
|
||||
remains = rd->block_size * req->count;
|
||||
sg = req->bufs;
|
||||
for (i = 0; (remains > 0) && (i < req->bufnum); i++, sg++)
|
||||
{
|
||||
int count = sg->length;
|
||||
if (count > remains)
|
||||
count = remains;
|
||||
memcpy(to, sg->buffer, count);
|
||||
remains -= count;
|
||||
}
|
||||
req->req_done(req->done_arg, RTEMS_SUCCESSFUL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ramdisk_ioctl --
|
||||
* IOCTL handler for RAM disk device.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* dev - device number (major, minor number)
|
||||
* req - IOCTL request code
|
||||
* argp - IOCTL argument
|
||||
*
|
||||
* RETURNS:
|
||||
* IOCTL return value
|
||||
*/
|
||||
static int
|
||||
ramdisk_ioctl(dev_t dev, int req, void *argp)
|
||||
{
|
||||
switch (req)
|
||||
{
|
||||
case BLKIO_REQUEST:
|
||||
{
|
||||
rtems_device_minor_number minor;
|
||||
blkdev_request *r = argp;
|
||||
struct ramdisk *rd;
|
||||
|
||||
minor = rtems_filesystem_dev_minor_t(dev);
|
||||
if ((minor >= nramdisks) || !ramdisk[minor].initialized)
|
||||
{
|
||||
errno = ENODEV;
|
||||
return -1;
|
||||
}
|
||||
|
||||
rd = ramdisk + minor;
|
||||
|
||||
switch (r->req)
|
||||
{
|
||||
case BLKDEV_REQ_READ:
|
||||
return ramdisk_read(rd, r);
|
||||
|
||||
case BLKDEV_REQ_WRITE:
|
||||
return ramdisk_write(rd, r);
|
||||
|
||||
default:
|
||||
errno = EBADRQC;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
errno = EBADRQC;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ramdisk_initialize --
|
||||
* RAM disk device driver initialization. Run through RAM disk
|
||||
* configuration information and configure appropriate RAM disks.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* major - RAM disk major device number
|
||||
* minor - minor device number, not applicable
|
||||
* arg - initialization argument, not applicable
|
||||
*
|
||||
* RETURNS:
|
||||
* none
|
||||
*/
|
||||
rtems_device_driver
|
||||
ramdisk_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg)
|
||||
{
|
||||
rtems_device_minor_number i;
|
||||
rtems_ramdisk_config *c = rtems_ramdisk_configuration;
|
||||
struct ramdisk *r;
|
||||
rtems_status_code rc;
|
||||
|
||||
rc = rtems_disk_io_initialize();
|
||||
if (rc != RTEMS_SUCCESSFUL)
|
||||
return rc;
|
||||
|
||||
r = ramdisk = calloc(rtems_ramdisk_configuration_size,
|
||||
sizeof(struct ramdisk));
|
||||
|
||||
for (i = 0; i < rtems_ramdisk_configuration_size; i++, c++, r++)
|
||||
{
|
||||
dev_t dev = rtems_filesystem_make_dev_t(major, i);
|
||||
char name[sizeof(RAMDISK_DEVICE_BASE_NAME "0123456789")];
|
||||
snprintf(name, sizeof(name), RAMDISK_DEVICE_BASE_NAME "%d", i);
|
||||
r->block_size = c->block_size;
|
||||
r->block_num = c->block_num;
|
||||
if (c->location == NULL)
|
||||
{
|
||||
r->malloced = TRUE;
|
||||
r->area = malloc(r->block_size * r->block_num);
|
||||
if (r->area == NULL) /* No enough memory for this disk */
|
||||
{
|
||||
r->initialized = FALSE;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
r->initialized = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
r->malloced = FALSE;
|
||||
r->initialized = TRUE;
|
||||
r->area = c->location;
|
||||
}
|
||||
rc = rtems_disk_create_phys(dev, c->block_size, c->block_num,
|
||||
ramdisk_ioctl, name);
|
||||
if (rc != RTEMS_SUCCESSFUL)
|
||||
{
|
||||
if (r->malloced)
|
||||
{
|
||||
free(r->area);
|
||||
}
|
||||
r->initialized = FALSE;
|
||||
}
|
||||
}
|
||||
nramdisks = rtems_ramdisk_configuration_size;
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
config.cache
|
||||
config.guess
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
config.h*
|
||||
stamp-h*
|
||||
@@ -1,323 +0,0 @@
|
||||
2002-04-06 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* src/imfs/imfs_getchild.c: include <string.h>.
|
||||
* src/imfs/imfs_gtkn.c: Include <string.h>.
|
||||
* src/imfs/ioman.c: Include <string.h>.
|
||||
* src/imfs/linearfile.c: Include <string.h>.
|
||||
* src/imfs/memfile.c: Include <string.h>.
|
||||
|
||||
2001-04-04 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/dosfs/Makefile.am: Per PR129 do not install as many files
|
||||
to the $(includedir).
|
||||
|
||||
2002-04-04 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* src/dosfs/fat.h: Include <string.h>.
|
||||
Remove DBG1 and DBG2 (unused).
|
||||
|
||||
2002-04-04 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* Per PR169.
|
||||
* src/dosfs/config.h.in, src/dosfs/stamp-h2.in: Removed from CVS.
|
||||
|
||||
|
||||
2002-03-27 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* src/dosfs/fat_file.c: Remove bsp.h.
|
||||
fat_file_write(.. const char*buf ..).
|
||||
* src/dosfs/fat_file.h: fat_file_write(.. const char*buf ..).
|
||||
|
||||
2002-03-27 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* configure.ac:
|
||||
AC_INIT(package,_RTEMS_VERSION,_RTEMS_BUGS).
|
||||
AM_INIT_AUTOMAKE([no-define foreign 1.6]).
|
||||
* src/dosfs/Makefile.am: Remove AUTOMAKE_OPTIONS.
|
||||
* src/Makefile.am: Remove AUTOMAKE_OPTIONS.
|
||||
* src/imfs/Makefile.am: Remove AUTOMAKE_OPTIONS.
|
||||
* Makefile.am: Remove AUTOMAKE_OPTIONS.
|
||||
* wrapup/Makefile.am: Remove AUTOMAKE_OPTIONS.
|
||||
|
||||
2002-03-16 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
Addressing PR 140.
|
||||
* src/dosfs/config.h.in: Removed.
|
||||
* src/dosfs/stamp-h2.in: Removed.
|
||||
* .cvsignore: Add config.h*, stamp-h*.
|
||||
* configure.ac: Remove AC_SRC_DIR(.../dosfs.h).
|
||||
Remove AM_CONFIG_HEADER(src/dosfs/config.h).
|
||||
Remove AM_CONFIG_HEADER(src/imfs/config.h).
|
||||
Add AM_CONFIG_HEADER(config.h).
|
||||
* src/dosfs/Makefile.am: INCLUDES = -I../.. .
|
||||
* src/imfs/Makefile.am: INCLUDES = -I../.. .
|
||||
|
||||
2002-03-14 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
Reported and tracked as PR130.
|
||||
* src/dosfs/Makefile.am: Reworked, Disable dosfs for UNIX.
|
||||
* wrapup/Makefile.am: Disable dosfs for UNIX.
|
||||
|
||||
2001-03-01 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/imfs/.cvsignore: Added stamp-h1.in
|
||||
|
||||
2002-02-28 Victor V. Vengerov <vvv@oktet.ru>
|
||||
|
||||
* DOS filesystem including FAT12, FAT16, and FAT32 support submitted.
|
||||
* src/dosfs, src/dosfs/Makefile.am, src/dosfs/stamp-h2.in,
|
||||
src/dosfs/config.h.in, src/dosfs/dosfs.h, src/dosfs/fat.c,
|
||||
src/dosfs/fat.h, src/dosfs/fat_fat_operations.c,
|
||||
src/dosfs/fat_fat_operations.h, src/dosfs/fat_file.c,
|
||||
src/dosfs/fat_file.h, src/dosfs/msdos.h, src/dosfs/msdos_create.c,
|
||||
src/dosfs/msdos_dir.c, src/dosfs/msdos_eval.c, src/dosfs/msdos_file.c,
|
||||
src/dosfs/msdos_free.c, src/dosfs/msdos_fsunmount.c,
|
||||
src/dosfs/msdos_handlers_dir.c, src/dosfs/msdos_handlers_file.c,
|
||||
src/dosfs/msdos_init.c, src/dosfs/msdos_initsupp.c,
|
||||
src/dosfs/msdos_misc.c, src/dosfs/msdos_mknod.c,
|
||||
src/dosfs/msdos_node_type.c, src/dosfs/.cvsignore: New files.
|
||||
* configure.ac, src/Makefile.am, wrapup/Makefile.am: Modified to
|
||||
reflect addition.
|
||||
|
||||
2002-01-07 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* src/imfs/imfs_load_tar.c: Add include <sys/types.h>.
|
||||
Add include <sys/stat.h>. Add include <fcntl.h>.
|
||||
* src/imfs/imfs_rmnod.c: Add include <stdlib.h>.
|
||||
|
||||
2002-01-04 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* src/imfs/imfs_eval.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/memfile.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs_readlink.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs_unlink.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs_link.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs_chown.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/ioman.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs_mount.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs_directory.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs_stat.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs_fchmod.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs_symlink.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs_mknod.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/linearfile.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs_unmount.c: Include <rtems/seterr.h>.
|
||||
Apply rtems_set_errno_and_return_minus_one.
|
||||
* src/imfs/imfs.h: Apply rtems_set_errno_and_return_minus_one.
|
||||
Comment out increment_and_check_linkcounts.
|
||||
|
||||
2001-11-27 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* wrapup/Makefile.am: Remove HAS_IMFS.
|
||||
|
||||
2001-11-26 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* src/imfs/Makefile.am: Cleanup.
|
||||
|
||||
2001-11-07 Jennifer Averett <jennifer@OARcorp.com>
|
||||
|
||||
Reported by Ibragimov Ilya <ibr@oktet.ru> and tracked as PR49.
|
||||
* src/imfs/imfs_directory.c: Do not calculate the offset twice.
|
||||
|
||||
2001-10-26 Victor V. Vengerov <vvv@oktet.ru>
|
||||
|
||||
* src/imfs/imfs_load_tar.c: Minor modification so this will
|
||||
compile with gcc-2.95.3 with the arguments "-m5200 -O4".
|
||||
|
||||
2001-10-16 Chris Johns <ccj@acm.org>
|
||||
|
||||
* imfs/imfs_load_tar.c: Changed the code around to remove an
|
||||
internal compiler error on the Coldfire target.
|
||||
|
||||
2001-10-11 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* .cvsignore: Add autom4te.cache for autoconf > 2.52.
|
||||
* configure.in: Remove.
|
||||
* configure.ac: New file, generated from configure.in by autoupdate.
|
||||
|
||||
2001-10-10 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/imfs/imfs_getchild.c: Correct length of static string
|
||||
as reported by Ibragimov Ilya <ibr@oktet.ru>.
|
||||
|
||||
2001-09-28 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* src/imfs/Makefile.am: Use 'PREINSTALL_FILES ='.
|
||||
|
||||
2001-09-22 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* src/imfs/Makefile.am: Revamp INCLUDES handling to make automake-1.5
|
||||
happy.
|
||||
|
||||
2001-08-09 Fernando-Ruiz Casas <correo@fernando-ruiz.com>
|
||||
|
||||
* src/imfs/imfs_eval.c: The CD_UP problem in imfs_eval has been
|
||||
touched. The order of the questions is the key.
|
||||
|
||||
2001-07-06 Thomas Doerfler <Thomas.Doerfler@imd-systems.de>
|
||||
|
||||
* src/imfs/deviceio.c: Make sure errno gets set to reflect
|
||||
the status from the driver.
|
||||
|
||||
2001-05-25 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/imfs/imfs_initsupp.c: Create the root node with the
|
||||
desired permissions. Nodes should be created with the right
|
||||
permissions because chmod() is not supported by the miniIMFS
|
||||
so changing after creation is not possible.
|
||||
|
||||
2001-04-27 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* configure.in: Add [-ansi -fasm] to RTEMS_PROG_CC_FOR_TARGET.
|
||||
|
||||
2001-04-24 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/imfs/memfile.c (memfile_open): Did not set iop->size
|
||||
and thus the value was incorrect. Before this field was cleared,
|
||||
this resulted in the value from the last time that IOP was used
|
||||
being still in place. Discovered by Andrew Bythell
|
||||
<abythell@nortelnetworks.com>.
|
||||
|
||||
2001-04-20 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/imfs/imfs_debug.c (IMFS_print_jnode): Modified to print
|
||||
only information that does not vary based on target or memory
|
||||
configuration. The old prints are still there in case they
|
||||
are needed in the future to debug. Printing target dependent
|
||||
addresses makes the test output vary by target unnecessarily.
|
||||
|
||||
2001-03-23 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/imfs/memfile.c: Reapply fix from bug report from
|
||||
Jose Sturniolo <jsturnio@nec.com.ar> where NULL pointer
|
||||
was dereferenced when freeing a triply indirect file.
|
||||
The fix was applied to the 4.5 release branch and not
|
||||
the development branch.
|
||||
|
||||
2001-02-03 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* src/imfs/Makefile.am: Apply include_*HEADERS instead of H_FILES.
|
||||
|
||||
2001-01-16 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* configure.in: Add src/imfs/config.h
|
||||
* src/imfs/Makefile.am: Add INCLUDES += -I. to pickup config.h
|
||||
* src/imfs/.cvsignore: Add config.h and stamp-h
|
||||
* src/imfs/*.c: Add config.h support.
|
||||
|
||||
2001-01-12 Jake Janovetz <janovetz@uiuc.edu>
|
||||
|
||||
* src/imfs/imfs.h, src/imfs/imfs_creat.c, src/imfs/imfs_debug.c,
|
||||
src/imfs/imfs_eval.c, src/imfs/imfs_fchmod.c,
|
||||
src/imfs/imfs_handlers_memfile.c, src/imfs/imfs_init.c,
|
||||
src/imfs/imfs_initsupp.c, src/imfs/imfs_stat.c, src/imfs/memfile.c,
|
||||
src/imfs/miniimfs_init.c: Final developmental update to "tarfs".
|
||||
When rtems_tarfs_load() is called, it checks the permissions
|
||||
on each file. If there is write permission, it just creates a
|
||||
standard file using "creat()" and therefore, uses the IMFS MEMORY_FILE.
|
||||
If there is no write permission, it creates a LINEAR_FILE node
|
||||
with the appropriate properties. If the permission is ever changed
|
||||
to writeable, IMFS_fchmod converts it to a regular memory file.
|
||||
|
||||
2000-12-12 Jake Janovetz <janovetz@uiuc.edu>
|
||||
|
||||
* src/imfs/linearfile.c, src/imfs/imfs_load_tar.c: New files.
|
||||
* src/imfs/Makefile.am, src/imfs/imfs.h,
|
||||
src/imfs/imfs_creat.c, src/imfs/imfs_debug.c,
|
||||
src/imfs/imfs_eval.c, src/imfs/imfs_handlers_memfile.c,
|
||||
src/imfs/imfs_init.c, src/imfs/imfs_initsupp.c,
|
||||
src/imfs/imfs_stat.c, src/imfs/miniimfs_init.c: Added "tarfs".
|
||||
This is not really a tar filesystem. It is a way to load a tar
|
||||
image into the IMFS but actually leave bulky file contents in the
|
||||
original tar image. It essentially adds the linear file type and
|
||||
associated support and a loader routine.
|
||||
|
||||
2000-11-28 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/imfs/memfile.c: Bug report from Sturniolo Jose
|
||||
<jsturnio@nec.com.ar> where NULL pointer was dereferenced.
|
||||
|
||||
2000-11-17 Jennifer Averret <jennifer@OARcorp.com>
|
||||
|
||||
* src/imfs/imfs_eval.c: Always return imaginary node at mount points.
|
||||
|
||||
2000-11-09 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* Makefile.am: Use ... instead of RTEMS_TOPdir in ACLOCAL_AMFLAGS.
|
||||
|
||||
2000-11-02 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* Makefile.am: Switch to ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal.
|
||||
|
||||
2000-11-01 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/imfs/Makefile.am, src/imfs/deviceio.c, src/imfs/imfs_chown.c,
|
||||
src/imfs/imfs_config.c, src/imfs/imfs_creat.c, src/imfs/imfs_debug.c,
|
||||
src/imfs/imfs_directory.c, src/imfs/imfs_eval.c, src/imfs/imfs_fchmod.c,
|
||||
src/imfs/imfs_free.c, src/imfs/imfs_fsunmount.c, src/imfs/imfs_gtkn.c,
|
||||
src/imfs/imfs_init.c, src/imfs/imfs_initsupp.c, src/imfs/imfs_link.c,
|
||||
src/imfs/imfs_mknod.c, src/imfs/imfs_mount.c, src/imfs/imfs_readlink.c,
|
||||
src/imfs/imfs_rmnod.c, src/imfs/imfs_stat.c, src/imfs/imfs_symlink.c,
|
||||
src/imfs/imfs_unixstub.c, src/imfs/imfs_unlink.c,
|
||||
src/imfs/imfs_unmount.c, src/imfs/imfs_utime.c, src/imfs/ioman.c,
|
||||
src/imfs/memfile.c, src/imfs/miniimfs_init.c:
|
||||
assoc.h, error.h, libio_.h, libio.h, and libcsupport.h moved
|
||||
from libc to lib/include/rtems and now must be referenced as
|
||||
<rtems/XXX.h>. Now we do not have to reach up and over to
|
||||
libc to pick them up.
|
||||
|
||||
2000-10-24 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* src/imfs/imfs_config.c: New file containing IMFS configuration
|
||||
information split from libc/base_fs.c.
|
||||
* src/imfs/ioman.c: New file. Moved from lib/libc. Missed previously.
|
||||
* src/imfs/Makefile.am: Added imfs_config.c and ioman.c.
|
||||
|
||||
2000-10-24 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* Makefile.am, configure.in: Introduce GNU canonicalization to libfs/.
|
||||
The approach is currently a bit of a hack as GNU canonicalization
|
||||
does not support the per-BSP build some of the other directories
|
||||
require. As more of the tree is converted, this will become less
|
||||
of an issue.
|
||||
|
||||
2000-10-19 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* .cvsignore, src/.cvsignore, src/imfs/.cvsignore, wrapup/.cvsignore:
|
||||
New files.
|
||||
|
||||
2000-10-18 Chris Johns <ccj@acm.org>
|
||||
|
||||
* libfs created.
|
||||
* src, src/imfs, wrapup: New directories.
|
||||
* ChangeLog, Makefile.am, README, configure.in, src/Makefile.am,
|
||||
wrapup/Makefile.am: New files.
|
||||
* src/imfs/deviceio.c, src/imfs/imfs_getchild.c,
|
||||
src/imfs/imfs_readlink.c, src/imfs/imfs.h, src/imfs/imfs_gtkn.c,
|
||||
src/imfs/imfs_rmnod.c, src/imfs/imfs_chown.c,
|
||||
src/imfs/imfs_handlers_device.c, src/imfs/imfs_stat.c,
|
||||
src/imfs/imfs_creat.c, src/imfs/imfs_handlers_directory.c,
|
||||
src/imfs/imfs_symlink.c, src/imfs/imfs_debug.c,
|
||||
src/imfs/imfs_handlers_link.c, src/imfs/imfs_unixstub.c,
|
||||
src/imfs/imfs_directory.c, src/imfs/imfs_handlers_memfile.c,
|
||||
src/imfs/imfs_unlink.c, src/imfs/imfs_eval.c, src/imfs/imfs_init.c,
|
||||
src/imfs/imfs_unmount.c, src/imfs/imfs_fchmod.c,
|
||||
src/imfs/imfs_initsupp.c, src/imfs/imfs_utime.c, src/imfs/imfs_fcntl.c,
|
||||
src/imfs/imfs_link.c, src/imfs/memfile.c, src/imfs/imfs_fdatasync.c,
|
||||
src/imfs/imfs_mknod.c, src/imfs/miniimfs_init.c, src/imfs/imfs_free.c,
|
||||
src/imfs/imfs_mount.c, src/imfs/imfs_fsunmount.c, src/imfs/imfs_ntype.c:
|
||||
New files. Moved from libc.
|
||||
@@ -1,12 +0,0 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
ACLOCAL_AMFLAGS = -I ../../../aclocal
|
||||
|
||||
SUBDIRS = src wrapup
|
||||
|
||||
EXTRA_DIST = README
|
||||
|
||||
include $(top_srcdir)/../../../automake/subdirs.am
|
||||
include $(top_srcdir)/../../../automake/local.am
|
||||
@@ -1,13 +0,0 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
This directory contains for the "file system" library. All supported
|
||||
file systems live under this tree.
|
||||
|
||||
Currently the only supported file systems in this library are the IMFS
|
||||
and miniIMFS. The TFTP client filesystem is part of the libnetworking
|
||||
library.
|
||||
|
||||
--Chris Johns and Joel Sherrill
|
||||
18 October 2000
|
||||
@@ -1,39 +0,0 @@
|
||||
## Process this file with autoconf to produce a configure script.
|
||||
##
|
||||
## $Id$
|
||||
|
||||
AC_PREREQ(2.52)
|
||||
AC_INIT([rtems-c-src-libfs],[_RTEMS_VERSION],[rtems-bugs@OARcorp.com])
|
||||
AC_CONFIG_SRCDIR([src/imfs/imfs.h])
|
||||
|
||||
RTEMS_TOP(../../..)
|
||||
AC_CONFIG_AUX_DIR(../../..)
|
||||
|
||||
RTEMS_CANONICAL_TARGET_CPU
|
||||
|
||||
AM_INIT_AUTOMAKE([no-define foreign 1.6])
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
RTEMS_ENABLE_BARE
|
||||
|
||||
RTEMS_ENV_RTEMSBSP
|
||||
|
||||
RTEMS_CHECK_CPU
|
||||
RTEMS_CANONICAL_HOST
|
||||
|
||||
RTEMS_PROJECT_ROOT
|
||||
|
||||
RTEMS_PROG_CC_FOR_TARGET([-ansi -fasm])
|
||||
RTEMS_CANONICALIZE_TOOLS
|
||||
|
||||
AM_CONDITIONAL(UNIX,test x"$RTEMS_CPU" = x"unix")
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
# Explicitly list all Makefiles here
|
||||
AC_CONFIG_FILES([Makefile
|
||||
src/Makefile
|
||||
src/imfs/Makefile
|
||||
src/dosfs/Makefile
|
||||
wrapup/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
@@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,9 +0,0 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
|
||||
SUBDIRS = imfs dosfs
|
||||
|
||||
include $(top_srcdir)/../../../automake/subdirs.am
|
||||
include $(top_srcdir)/../../../automake/local.am
|
||||
@@ -1,6 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
config.h
|
||||
config.h.in
|
||||
stamp-h
|
||||
stamp-h.in
|
||||
@@ -1,55 +0,0 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../../../automake/compile.am
|
||||
include $(top_srcdir)/../../../automake/lib.am
|
||||
|
||||
INCLUDES = -I../..
|
||||
|
||||
AM_CFLAGS += $(LIBC_DEFINES)
|
||||
|
||||
FATFS_C_FILES = fat.c fat_fat_operations.c fat_file.c
|
||||
|
||||
DOSFS_C_FILES = msdos_create.c msdos_dir.c msdos_eval.c msdos_file.c \
|
||||
msdos_free.c msdos_fsunmount.c msdos_handlers_dir.c \
|
||||
msdos_handlers_file.c msdos_init.c msdos_initsupp.c \
|
||||
msdos_misc.c msdos_mknod.c msdos_node_type.c
|
||||
|
||||
if !UNIX
|
||||
LIBNAME = libdosfs
|
||||
LIB = ${ARCH}/${LIBNAME}.a
|
||||
|
||||
C_FILES = $(FATFS_C_FILES) $(DOSFS_C_FILES)
|
||||
|
||||
C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
|
||||
|
||||
include_HEADERS = dosfs.h
|
||||
|
||||
H_FILES = $(PROJECT_INCLUDE) \
|
||||
$(include_HEADERS:%=$(PROJECT_INCLUDE)/%)
|
||||
|
||||
$(PROJECT_INCLUDE):
|
||||
@$(mkinstalldirs) $@
|
||||
|
||||
$(PROJECT_INCLUDE)/%.h: %.h
|
||||
$(INSTALL_DATA) $< $@
|
||||
|
||||
OBJS = $(C_O_FILES)
|
||||
|
||||
#
|
||||
# Add local stuff here using +=
|
||||
#
|
||||
all-local: ${ARCH} $(LIB)
|
||||
|
||||
$(LIB): ${OBJS}
|
||||
$(make-library)
|
||||
endif
|
||||
|
||||
TMPINSTALL_FILES += $(H_FILES)
|
||||
|
||||
EXTRA_DIST = $(DOSFS_C_FILES) $(FATFS_C_FILES)
|
||||
|
||||
include $(top_srcdir)/../../../automake/local.am
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* dosfs.h
|
||||
*
|
||||
* Application interface to MSDOS filesystem.
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
#ifndef __DOSFS_DOSFS_H__
|
||||
#define __DOSFS_DOSFS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
|
||||
extern rtems_filesystem_operations_table msdos_ops;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DOSFS_DOSFS_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,488 +0,0 @@
|
||||
/*
|
||||
* fat.h
|
||||
*
|
||||
* Constants/data structures/prototypes for low-level operations on a volume
|
||||
* with FAT filesystem
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#ifndef __DOSFS_FAT_H__
|
||||
#define __DOSFS_FAT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <rtems/seterr.h>
|
||||
|
||||
/* XXX: temporary hack :(( */
|
||||
#ifndef set_errno_and_return_minus_one
|
||||
#define set_errno_and_return_minus_one rtems_set_errno_and_return_minus_one
|
||||
#endif /* set_errno_and_return_minus_one */
|
||||
|
||||
#include <rtems/score/cpu.h>
|
||||
#include <errno.h>
|
||||
#include <rtems/bdbuf.h>
|
||||
|
||||
#ifndef RC_OK
|
||||
#define RC_OK 0x00000000
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Remember that all FAT file system on disk data structure is
|
||||
* "little endian"!
|
||||
* (derived from linux)
|
||||
*/
|
||||
/*
|
||||
* Conversion from and to little-endian byte order. (no-op on i386/i486)
|
||||
*
|
||||
* Naming: Ca_b_c, where a: F = from, T = to, b: LE = little-endian,
|
||||
* BE = big-endian, c: W = word (16 bits), L = longword (32 bits)
|
||||
*/
|
||||
|
||||
#if (CPU_BIG_ENDIAN == TRUE)
|
||||
# define CF_LE_W(v) CPU_swap_u16(v)
|
||||
# define CF_LE_L(v) CPU_swap_u32(v)
|
||||
# define CT_LE_W(v) CPU_swap_u16(v)
|
||||
# define CT_LE_L(v) CPU_swap_u32(v)
|
||||
#else
|
||||
# define CF_LE_W(v) (v)
|
||||
# define CF_LE_L(v) (v)
|
||||
# define CT_LE_W(v) (v)
|
||||
# define CT_LE_L(v) (v)
|
||||
#endif
|
||||
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
#define FAT_HASH_SIZE 2
|
||||
#define FAT_HASH_MODULE FAT_HASH_SIZE
|
||||
|
||||
|
||||
#define FAT_SECTOR512_SIZE 512 /* sector size (bytes) */
|
||||
#define FAT_SECTOR512_BITS 9 /* log2(SECTOR_SIZE) */
|
||||
|
||||
/* maximum + 1 number of clusters for FAT12 */
|
||||
#define FAT_FAT12_MAX_CLN 4085
|
||||
|
||||
/* maximum + 1 number of clusters for FAT16 */
|
||||
#define FAT_FAT16_MAX_CLN 65525
|
||||
|
||||
#define FAT_FAT12 0x01
|
||||
#define FAT_FAT16 0x02
|
||||
#define FAT_FAT32 0x04
|
||||
|
||||
#define FAT_UNDEFINED_VALUE 0xFFFFFFFF
|
||||
|
||||
#define FAT_FAT12_EOC 0x0FFF
|
||||
#define FAT_FAT16_EOC 0xFFFF
|
||||
#define FAT_FAT32_EOC 0x0FFFFFFF
|
||||
|
||||
#define FAT_FAT12_FREE 0x0000
|
||||
#define FAT_FAT16_FREE 0x0000
|
||||
#define FAT_FAT32_FREE 0x00000000
|
||||
|
||||
#define FAT_GENFAT_EOC 0xFFFFFFFF
|
||||
#define FAT_GENFAT_FREE 0x00000000
|
||||
|
||||
#define FAT_FAT12_SHIFT 0x04
|
||||
|
||||
#define FAT_FAT12_MASK 0x00000FFF
|
||||
#define FAT_FAT16_MASK 0x0000FFFF
|
||||
#define FAT_FAT32_MASK 0x0FFFFFFF
|
||||
|
||||
#define FAT_MAX_BPB_SIZE 90
|
||||
|
||||
/* size of useful information in FSInfo sector */
|
||||
#define FAT_USEFUL_INFO_SIZE 12
|
||||
|
||||
#define FAT_VAL8(x, ofs) (unsigned8)(*((unsigned8 *)(x) + (ofs)))
|
||||
|
||||
#define FAT_VAL16(x, ofs) \
|
||||
(unsigned16)( (*((unsigned8 *)(x) + (ofs))) | \
|
||||
((*((unsigned8 *)(x) + (ofs) + 1)) << 8) )
|
||||
|
||||
#define FAT_VAL32(x, ofs) \
|
||||
(unsigned32)( (*((unsigned8 *)(x) + (ofs))) | \
|
||||
((*((unsigned8 *)(x) + (ofs) + 1)) << 8) | \
|
||||
((*((unsigned8 *)(x) + (ofs) + 2)) << 16) | \
|
||||
((*((unsigned8 *)(x) + (ofs) + 3)) << 24) )
|
||||
|
||||
/* macros to access boot sector fields */
|
||||
#define FAT_BR_BYTES_PER_SECTOR(x) FAT_VAL16(x, 11)
|
||||
#define FAT_BR_SECTORS_PER_CLUSTER(x) FAT_VAL8(x, 13)
|
||||
#define FAT_BR_RESERVED_SECTORS_NUM(x) FAT_VAL16(x, 14)
|
||||
#define FAT_BR_FAT_NUM(x) FAT_VAL8(x, 16)
|
||||
#define FAT_BR_FILES_PER_ROOT_DIR(x) FAT_VAL16(x, 17)
|
||||
#define FAT_BR_TOTAL_SECTORS_NUM16(x) FAT_VAL16(x, 19)
|
||||
#define FAT_BR_MEDIA(x) FAT_VAL8(x, 21)
|
||||
#define FAT_BR_SECTORS_PER_FAT(x) FAT_VAL16(x, 22)
|
||||
#define FAT_BR_TOTAL_SECTORS_NUM32(x) FAT_VAL32(x, 32)
|
||||
#define FAT_BR_SECTORS_PER_FAT32(x) FAT_VAL32(x, 36)
|
||||
#define FAT_BR_EXT_FLAGS(x) FAT_VAL16(x, 40)
|
||||
#define FAT_BR_FAT32_ROOT_CLUSTER(x) FAT_VAL32(x, 44)
|
||||
#define FAT_BR_FAT32_FS_INFO_SECTOR(x) FAT_VAL16(x, 48)
|
||||
#define FAT_FSINFO_LEAD_SIGNATURE(x) FAT_VAL32(x, 0)
|
||||
/*
|
||||
* I read FSInfo sector from offset 484 to access the information, so offsets
|
||||
* of these fields a relative
|
||||
*/
|
||||
#define FAT_FSINFO_FREE_CLUSTER_COUNT(x) FAT_VAL32(x, 4)
|
||||
#define FAT_FSINFO_NEXT_FREE_CLUSTER(x) FAT_VAL32(x, 8)
|
||||
|
||||
#define FAT_FSINFO_FREE_CLUSTER_COUNT_OFFSET 488
|
||||
|
||||
#define FAT_FSINFO_NEXT_FREE_CLUSTER_OFFSET 492
|
||||
|
||||
#define FAT_RSRVD_CLN 0x02
|
||||
|
||||
#define FAT_FSINFO_LEAD_SIGNATURE_VALUE 0x41615252
|
||||
|
||||
#define FAT_FSI_LEADSIG_SIZE 0x04
|
||||
|
||||
#define FAT_FSI_INFO 484
|
||||
|
||||
#define MS_BYTES_PER_CLUSTER_LIMIT 0x8000 /* 32K */
|
||||
|
||||
#define FAT_BR_EXT_FLAGS_MIRROR 0x0080
|
||||
|
||||
#define FAT_BR_EXT_FLAGS_FAT_NUM 0x000F
|
||||
|
||||
|
||||
#define FAT_DIRENTRY_SIZE 32
|
||||
|
||||
#define FAT_DIRENTRIES_PER_SEC512 16
|
||||
|
||||
/*
|
||||
* Volume descriptor
|
||||
* Description of the volume the FAT filesystem is located on - generally
|
||||
* the fields of the structure corresponde to Boot Sector and BPB Srtucture
|
||||
* (see M$ White Paper) fields
|
||||
*/
|
||||
typedef struct fat_vol_s
|
||||
{
|
||||
unsigned16 bps; /* bytes per sector */
|
||||
unsigned8 sec_log2; /* log2 of bps */
|
||||
unsigned8 sec_mul; /* log2 of 512bts sectors number per sector */
|
||||
unsigned8 spc; /* sectors per cluster */
|
||||
unsigned8 spc_log2; /* log2 of spc */
|
||||
unsigned16 bpc; /* bytes per cluster */
|
||||
unsigned8 bpc_log2; /* log2 of bytes per cluster */
|
||||
unsigned8 fats; /* number of FATs */
|
||||
unsigned8 type; /* FAT type */
|
||||
unsigned32 mask;
|
||||
unsigned32 eoc_val;
|
||||
unsigned16 fat_loc; /* FAT start */
|
||||
unsigned32 fat_length; /* sectors per FAT */
|
||||
unsigned32 rdir_loc; /* root directory start */
|
||||
unsigned16 rdir_entrs; /* files per root directory */
|
||||
unsigned32 rdir_secs; /* sectors per root directory */
|
||||
unsigned32 rdir_size; /* root directory size in bytes */
|
||||
unsigned32 tot_secs; /* total count of sectors */
|
||||
unsigned32 data_fsec; /* first data sector */
|
||||
unsigned32 data_cls; /* count of data clusters */
|
||||
unsigned32 rdir_cl; /* first cluster of the root directory */
|
||||
unsigned16 info_sec; /* FSInfo Sector Structure location */
|
||||
unsigned32 free_cls; /* last known free clusters count */
|
||||
unsigned32 next_cl; /* next free cluster number */
|
||||
unsigned8 mirror; /* mirroring enabla/disable */
|
||||
unsigned32 afat_loc; /* active FAT location */
|
||||
unsigned8 afat; /* the number of active FAT */
|
||||
dev_t dev; /* device ID */
|
||||
disk_device *dd; /* disk device (see libblock) */
|
||||
void *private_data; /* reserved */
|
||||
} fat_vol_t;
|
||||
|
||||
|
||||
typedef struct fat_cache_s
|
||||
{
|
||||
unsigned32 blk_num;
|
||||
rtems_boolean modified;
|
||||
unsigned8 state;
|
||||
bdbuf_buffer *buf;
|
||||
} fat_cache_t;
|
||||
|
||||
/*
|
||||
* This structure identifies the instance of the filesystem on the FAT
|
||||
* ("fat-file") level.
|
||||
*/
|
||||
typedef struct fat_fs_info_s
|
||||
{
|
||||
fat_vol_t vol; /* volume descriptor */
|
||||
Chain_Control *vhash; /* "vhash" of fat-file descriptors */
|
||||
Chain_Control *rhash; /* "rhash" of fat-file descriptors */
|
||||
char *uino; /* array of unique ino numbers */
|
||||
unsigned32 index;
|
||||
unsigned32 uino_pool_size; /* size */
|
||||
unsigned32 uino_base;
|
||||
fat_cache_t c; /* cache */
|
||||
unsigned8 *sec_buf; /* just placeholder for anything */
|
||||
} fat_fs_info_t;
|
||||
|
||||
/*
|
||||
* if the name we looking for is file we store not only first data cluster
|
||||
* number, but and cluster number and offset for directory entry for this
|
||||
* name
|
||||
*/
|
||||
typedef struct fat_auxiliary_s
|
||||
{
|
||||
unsigned32 cln;
|
||||
unsigned32 ofs;
|
||||
} fat_auxiliary_t;
|
||||
|
||||
#define FAT_FAT_OFFSET(fat_type, cln) \
|
||||
((fat_type) & FAT_FAT12 ? ((cln) + ((cln) >> 1)) : \
|
||||
(fat_type) & FAT_FAT16 ? ((cln) << 1) : \
|
||||
((cln) << 2))
|
||||
|
||||
#define FAT_CLUSTER_IS_ODD(n) ((n) & 0x0001)
|
||||
|
||||
#define FAT12_SHIFT 0x4 /* half of a byte */
|
||||
|
||||
/* initial size of array of unique ino */
|
||||
#define FAT_UINO_POOL_INIT_SIZE 0x100
|
||||
|
||||
/* cache support */
|
||||
#define FAT_CACHE_EMPTY 0x0
|
||||
#define FAT_CACHE_ACTUAL 0x1
|
||||
|
||||
#define FAT_OP_TYPE_READ 0x1
|
||||
#define FAT_OP_TYPE_GET 0x2
|
||||
|
||||
static inline unsigned32
|
||||
fat_cluster_num_to_sector_num(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cln
|
||||
)
|
||||
{
|
||||
register fat_fs_info_t *fs_info = mt_entry->fs_info;
|
||||
|
||||
if ( (cln == 0) && (fs_info->vol.type & (FAT_FAT12 | FAT_FAT16)) )
|
||||
return fs_info->vol.rdir_loc;
|
||||
|
||||
return (((cln - FAT_RSRVD_CLN) << fs_info->vol.spc_log2) +
|
||||
fs_info->vol.data_fsec);
|
||||
}
|
||||
|
||||
static inline unsigned32
|
||||
fat_cluster_num_to_sector512_num(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cln
|
||||
)
|
||||
{
|
||||
fat_fs_info_t *fs_info = mt_entry->fs_info;
|
||||
|
||||
if (cln == 1)
|
||||
return 1;
|
||||
|
||||
return (fat_cluster_num_to_sector_num(mt_entry, cln) <<
|
||||
fs_info->vol.sec_mul);
|
||||
}
|
||||
|
||||
static inline int
|
||||
fat_buf_access(fat_fs_info_t *fs_info, unsigned32 blk, int op_type,
|
||||
bdbuf_buffer **buf)
|
||||
{
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
unsigned8 i;
|
||||
rtems_boolean sec_of_fat;
|
||||
|
||||
|
||||
if (fs_info->c.state == FAT_CACHE_EMPTY)
|
||||
{
|
||||
if (op_type == FAT_OP_TYPE_READ)
|
||||
sc = rtems_bdbuf_read(fs_info->vol.dev, blk, &fs_info->c.buf);
|
||||
else
|
||||
sc = rtems_bdbuf_get(fs_info->vol.dev, blk, &fs_info->c.buf);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
fs_info->c.blk_num = blk;
|
||||
fs_info->c.state = FAT_CACHE_ACTUAL;
|
||||
}
|
||||
|
||||
sec_of_fat = ((fs_info->c.blk_num >= fs_info->vol.fat_loc) &&
|
||||
(fs_info->c.blk_num < fs_info->vol.rdir_loc));
|
||||
|
||||
if (fs_info->c.blk_num != blk)
|
||||
{
|
||||
if (fs_info->c.modified)
|
||||
{
|
||||
if (sec_of_fat && !fs_info->vol.mirror)
|
||||
memcpy(fs_info->sec_buf, fs_info->c.buf->buffer,
|
||||
fs_info->vol.bps);
|
||||
|
||||
sc = rtems_bdbuf_release_modified(fs_info->c.buf);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
fs_info->c.modified = 0;
|
||||
|
||||
if (sec_of_fat && !fs_info->vol.mirror)
|
||||
{
|
||||
bdbuf_buffer *b;
|
||||
|
||||
for (i = 1; i < fs_info->vol.fats; i++)
|
||||
{
|
||||
sc = rtems_bdbuf_get(fs_info->vol.dev,
|
||||
fs_info->c.blk_num +
|
||||
fs_info->vol.fat_length * i,
|
||||
&b);
|
||||
if ( sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(ENOMEM);
|
||||
memcpy(b->buffer, fs_info->sec_buf, fs_info->vol.bps);
|
||||
sc = rtems_bdbuf_release_modified(b);
|
||||
if ( sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(ENOMEM);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sc = rtems_bdbuf_release(fs_info->c.buf);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
}
|
||||
if (op_type == FAT_OP_TYPE_READ)
|
||||
sc = rtems_bdbuf_read(fs_info->vol.dev, blk, &fs_info->c.buf);
|
||||
else
|
||||
sc = rtems_bdbuf_get(fs_info->vol.dev, blk, &fs_info->c.buf);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
fs_info->c.blk_num = blk;
|
||||
}
|
||||
*buf = fs_info->c.buf;
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
|
||||
static inline int
|
||||
fat_buf_release(fat_fs_info_t *fs_info)
|
||||
{
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
unsigned8 i;
|
||||
rtems_boolean sec_of_fat;
|
||||
|
||||
if (fs_info->c.state == FAT_CACHE_EMPTY)
|
||||
return RC_OK;
|
||||
|
||||
sec_of_fat = ((fs_info->c.blk_num >= fs_info->vol.fat_loc) &&
|
||||
(fs_info->c.blk_num < fs_info->vol.rdir_loc));
|
||||
|
||||
if (fs_info->c.modified)
|
||||
{
|
||||
if (sec_of_fat && !fs_info->vol.mirror)
|
||||
memcpy(fs_info->sec_buf, fs_info->c.buf->buffer, fs_info->vol.bps);
|
||||
|
||||
sc = rtems_bdbuf_release_modified(fs_info->c.buf);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
fs_info->c.modified = 0;
|
||||
|
||||
if (sec_of_fat && !fs_info->vol.mirror)
|
||||
{
|
||||
bdbuf_buffer *b;
|
||||
|
||||
for (i = 1; i < fs_info->vol.fats; i++)
|
||||
{
|
||||
sc = rtems_bdbuf_get(fs_info->vol.dev,
|
||||
fs_info->c.blk_num +
|
||||
fs_info->vol.fat_length * i,
|
||||
&b);
|
||||
if ( sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(ENOMEM);
|
||||
memcpy(b->buffer, fs_info->sec_buf, fs_info->vol.bps);
|
||||
sc = rtems_bdbuf_release_modified(b);
|
||||
if ( sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(ENOMEM);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sc = rtems_bdbuf_release(fs_info->c.buf);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
}
|
||||
fs_info->c.state = FAT_CACHE_EMPTY;
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
static inline void
|
||||
fat_buf_mark_modified(fat_fs_info_t *fs_info)
|
||||
{
|
||||
fs_info->c.modified = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ssize_t
|
||||
_fat_block_read(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 start,
|
||||
unsigned32 offset,
|
||||
unsigned32 count,
|
||||
void *buff);
|
||||
|
||||
ssize_t
|
||||
_fat_block_write(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 start,
|
||||
unsigned32 offset,
|
||||
unsigned32 count,
|
||||
const void *buff);
|
||||
|
||||
ssize_t
|
||||
fat_cluster_read(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cln,
|
||||
void *buff);
|
||||
|
||||
ssize_t
|
||||
fat_cluster_write(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cln,
|
||||
const void *buff);
|
||||
|
||||
int
|
||||
fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry);
|
||||
|
||||
int
|
||||
fat_init_clusters_chain(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 start_cln);
|
||||
|
||||
unsigned32
|
||||
fat_cluster_num_to_sector_num(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cln);
|
||||
|
||||
int
|
||||
fat_shutdown_drive(rtems_filesystem_mount_table_entry_t *mt_entry);
|
||||
|
||||
|
||||
unsigned32
|
||||
fat_get_unique_ino(rtems_filesystem_mount_table_entry_t *mt_entry);
|
||||
|
||||
rtems_boolean
|
||||
fat_ino_is_unique(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 ino);
|
||||
|
||||
void
|
||||
fat_free_unique_ino(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 ino);
|
||||
|
||||
int
|
||||
fat_fat32_update_fsinfo_sector(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 free_count,
|
||||
unsigned32 next_free
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DOSFS_FAT_H__ */
|
||||
@@ -1,445 +0,0 @@
|
||||
/*
|
||||
* fat_fat_operations.c
|
||||
*
|
||||
* General operations on File Allocation Table
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#include "fat.h"
|
||||
#include "fat_fat_operations.h"
|
||||
|
||||
/* fat_scan_fat_for_free_clusters --
|
||||
* Allocate chain of free clusters from Files Allocation Table
|
||||
*
|
||||
* PARAMETERS:
|
||||
* mt_entry - mount table entry
|
||||
* chain - the number of the first allocated cluster (first cluster
|
||||
* in the chain)
|
||||
* count - count of clusters to allocate (chain length)
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or error code if error occured (errno set
|
||||
* appropriately)
|
||||
*
|
||||
*
|
||||
*/
|
||||
int
|
||||
fat_scan_fat_for_free_clusters(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 *chain,
|
||||
unsigned32 count,
|
||||
unsigned32 *cls_added,
|
||||
unsigned32 *last_cl
|
||||
)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
fat_fs_info_t *fs_info = mt_entry->fs_info;
|
||||
unsigned32 cl4find = 2;
|
||||
unsigned32 next_cln = 0;
|
||||
unsigned32 save_cln = 0;
|
||||
unsigned32 data_cls_val = fs_info->vol.data_cls + 2;
|
||||
unsigned32 i = 2;
|
||||
|
||||
*cls_added = 0;
|
||||
|
||||
if (count == 0)
|
||||
return rc;
|
||||
|
||||
if ((fs_info->vol.type & FAT_FAT32) &&
|
||||
(fs_info->vol.next_cl != FAT_UNDEFINED_VALUE))
|
||||
cl4find = fs_info->vol.next_cl;
|
||||
|
||||
/*
|
||||
* fs_info->vol.data_cls is exactly the count of data clusters
|
||||
* starting at cluster 2, so the maximum valid cluster number is
|
||||
* (fs_info->vol.data_cls + 1)
|
||||
*/
|
||||
while (i < data_cls_val)
|
||||
{
|
||||
rc = fat_get_fat_cluster(mt_entry, cl4find, &next_cln);
|
||||
if ( rc != RC_OK )
|
||||
{
|
||||
if (*cls_added != 0)
|
||||
fat_free_fat_clusters_chain(mt_entry, (*chain));
|
||||
return rc;
|
||||
}
|
||||
|
||||
if ((next_cln & fs_info->vol.mask) == FAT_GENFAT_FREE)
|
||||
{
|
||||
/*
|
||||
* We are enforced to process allocation of the first free cluster
|
||||
* by separate 'if' statement because otherwise undo function
|
||||
* wouldn't work properly
|
||||
*/
|
||||
if (*cls_added == 0)
|
||||
{
|
||||
*chain = cl4find;
|
||||
rc = fat_set_fat_cluster(mt_entry, cl4find, FAT_GENFAT_EOC);
|
||||
if ( rc != RC_OK )
|
||||
{
|
||||
/*
|
||||
* this is the first cluster we tried to allocate so no
|
||||
* cleanup activity needed
|
||||
*/
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* set EOC value to new allocated cluster */
|
||||
rc = fat_set_fat_cluster(mt_entry, cl4find, FAT_GENFAT_EOC);
|
||||
if ( rc != RC_OK )
|
||||
{
|
||||
/* cleanup activity */
|
||||
fat_free_fat_clusters_chain(mt_entry, (*chain));
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = fat_set_fat_cluster(mt_entry, save_cln, cl4find);
|
||||
if ( rc != RC_OK )
|
||||
{
|
||||
/* cleanup activity */
|
||||
fat_free_fat_clusters_chain(mt_entry, (*chain));
|
||||
/* trying to save last allocated cluster for future use */
|
||||
fat_set_fat_cluster(mt_entry, cl4find, FAT_GENFAT_FREE);
|
||||
fat_buf_release(fs_info);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
save_cln = cl4find;
|
||||
(*cls_added)++;
|
||||
|
||||
/* have we satisfied request ? */
|
||||
if (*cls_added == count)
|
||||
{
|
||||
if (fs_info->vol.type & FAT_FAT32)
|
||||
{
|
||||
fs_info->vol.next_cl = save_cln;
|
||||
if (fs_info->vol.free_cls != 0xFFFFFFFF)
|
||||
fs_info->vol.free_cls -= (*cls_added);
|
||||
}
|
||||
*last_cl = save_cln;
|
||||
fat_buf_release(fs_info);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
cl4find++;
|
||||
if (cl4find >= data_cls_val)
|
||||
cl4find = 2;
|
||||
}
|
||||
|
||||
if (fs_info->vol.type & FAT_FAT32)
|
||||
{
|
||||
fs_info->vol.next_cl = save_cln;
|
||||
if (fs_info->vol.free_cls != 0xFFFFFFFF)
|
||||
fs_info->vol.free_cls -= (*cls_added);
|
||||
}
|
||||
*last_cl = save_cln;
|
||||
fat_buf_release(fs_info);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* fat_free_fat_clusters_chain --
|
||||
* Free chain of clusters in Files Allocation Table.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* mt_entry - mount table entry
|
||||
* chain - number of the first cluster in the chain
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno set appropriately)
|
||||
*/
|
||||
int
|
||||
fat_free_fat_clusters_chain(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 chain
|
||||
)
|
||||
{
|
||||
int rc = RC_OK, rc1 = RC_OK;
|
||||
fat_fs_info_t *fs_info = mt_entry->fs_info;
|
||||
unsigned32 cur_cln = chain;
|
||||
unsigned32 next_cln = 0;
|
||||
unsigned32 freed_cls_cnt = 0;
|
||||
|
||||
while ((cur_cln & fs_info->vol.mask) != fs_info->vol.eoc_val)
|
||||
{
|
||||
rc = fat_get_fat_cluster(mt_entry, cur_cln, &next_cln);
|
||||
if ( rc != RC_OK )
|
||||
{
|
||||
if ((fs_info->vol.type & FAT_FAT32) &&
|
||||
(fs_info->vol.free_cls != FAT_UNDEFINED_VALUE))
|
||||
fs_info->vol.free_cls += freed_cls_cnt;
|
||||
fat_buf_release(fs_info);
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = fat_set_fat_cluster(mt_entry, cur_cln, FAT_GENFAT_FREE);
|
||||
if ( rc != RC_OK )
|
||||
rc1 = rc;
|
||||
|
||||
freed_cls_cnt++;
|
||||
cur_cln = next_cln;
|
||||
}
|
||||
|
||||
if (fs_info->vol.type & FAT_FAT32)
|
||||
{
|
||||
fs_info->vol.next_cl = chain;
|
||||
if (fs_info->vol.free_cls != FAT_UNDEFINED_VALUE)
|
||||
fs_info->vol.free_cls += freed_cls_cnt;
|
||||
}
|
||||
|
||||
fat_buf_release(fs_info);
|
||||
if (rc1 != RC_OK)
|
||||
return rc1;
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* fat_get_fat_cluster --
|
||||
* Fetches the contents of the cluster (link to next cluster in the chain)
|
||||
* from Files Allocation Table.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* mt_entry - mount table entry
|
||||
* cln - number of cluster to fetch the contents from
|
||||
* ret_val - contents of the cluster 'cln' (link to next cluster in
|
||||
* the chain)
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured
|
||||
* and errno set appropriately
|
||||
*/
|
||||
int
|
||||
fat_get_fat_cluster(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cln,
|
||||
unsigned32 *ret_val
|
||||
)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
register fat_fs_info_t *fs_info = mt_entry->fs_info;
|
||||
bdbuf_buffer *block0 = NULL;
|
||||
unsigned32 sec = 0;
|
||||
unsigned32 ofs = 0;
|
||||
|
||||
/* sanity check */
|
||||
if ( (cln < 2) || (cln > (fs_info->vol.data_cls + 1)) )
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
sec = (FAT_FAT_OFFSET(fs_info->vol.type, cln) >> fs_info->vol.sec_log2) +
|
||||
fs_info->vol.afat_loc;
|
||||
ofs = FAT_FAT_OFFSET(fs_info->vol.type, cln) & (fs_info->vol.bps - 1);
|
||||
|
||||
rc = fat_buf_access(fs_info, sec, FAT_OP_TYPE_READ, &block0);
|
||||
if (rc != RC_OK)
|
||||
return rc;
|
||||
|
||||
switch ( fs_info->vol.type )
|
||||
{
|
||||
case FAT_FAT12:
|
||||
/*
|
||||
* we are enforced in complex computations for FAT12 to escape CPU
|
||||
* align problems for some architectures
|
||||
*/
|
||||
*ret_val = (*((unsigned8 *)(block0->buffer + ofs)));
|
||||
if ( ofs == (fs_info->vol.bps - 1) )
|
||||
{
|
||||
rc = fat_buf_access(fs_info, sec + 1, FAT_OP_TYPE_READ,
|
||||
&block0);
|
||||
if (rc != RC_OK)
|
||||
return rc;
|
||||
|
||||
*ret_val |= (*((unsigned8 *)(block0->buffer)))<<8;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ret_val |= (*((unsigned8 *)(block0->buffer + ofs + 1)))<<8;
|
||||
}
|
||||
|
||||
if ( FAT_CLUSTER_IS_ODD(cln) )
|
||||
*ret_val = (*ret_val) >> FAT12_SHIFT;
|
||||
else
|
||||
*ret_val = (*ret_val) & FAT_FAT12_MASK;
|
||||
|
||||
break;
|
||||
|
||||
case FAT_FAT16:
|
||||
*ret_val = *((unsigned16 *)(block0->buffer + ofs));
|
||||
*ret_val = CF_LE_W(*ret_val);
|
||||
break;
|
||||
|
||||
case FAT_FAT32:
|
||||
*ret_val = *((unsigned32 *)(block0->buffer + ofs));
|
||||
*ret_val = CF_LE_L(*ret_val);
|
||||
break;
|
||||
|
||||
default:
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
break;
|
||||
}
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* fat_set_fat_cluster --
|
||||
* Set the contents of the cluster (link to next cluster in the chain)
|
||||
* from Files Allocation Table.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* mt_entry - mount table entry
|
||||
* cln - number of cluster to set contents to
|
||||
* in_val - value to set
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured
|
||||
* and errno set appropriately
|
||||
*/
|
||||
int
|
||||
fat_set_fat_cluster(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cln,
|
||||
unsigned32 in_val
|
||||
)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
fat_fs_info_t *fs_info = mt_entry->fs_info;
|
||||
unsigned32 sec = 0;
|
||||
unsigned32 ofs = 0;
|
||||
unsigned16 fat16_clv = 0;
|
||||
unsigned32 fat32_clv = 0;
|
||||
bdbuf_buffer *block0 = NULL;
|
||||
|
||||
/* sanity check */
|
||||
if ( (cln < 2) || (cln > (fs_info->vol.data_cls + 1)) )
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
sec = (FAT_FAT_OFFSET(fs_info->vol.type, cln) >> fs_info->vol.sec_log2) +
|
||||
fs_info->vol.afat_loc;
|
||||
ofs = FAT_FAT_OFFSET(fs_info->vol.type, cln) & (fs_info->vol.bps - 1);
|
||||
|
||||
rc = fat_buf_access(fs_info, sec, FAT_OP_TYPE_READ, &block0);
|
||||
if (rc != RC_OK)
|
||||
return rc;
|
||||
|
||||
switch ( fs_info->vol.type )
|
||||
{
|
||||
case FAT_FAT12:
|
||||
if ( FAT_CLUSTER_IS_ODD(cln) )
|
||||
{
|
||||
fat16_clv = CT_LE_W((((unsigned16)in_val) << FAT_FAT12_SHIFT));
|
||||
|
||||
*((unsigned8 *)(block0->buffer + ofs)) =
|
||||
(*((unsigned8 *)(block0->buffer + ofs))) & 0x0F;
|
||||
|
||||
*((unsigned8 *)(block0->buffer + ofs)) =
|
||||
(*((unsigned8 *)(block0->buffer + ofs))) |
|
||||
(unsigned8)(fat16_clv & 0x00FF);
|
||||
|
||||
fat_buf_mark_modified(fs_info);
|
||||
|
||||
if ( ofs == (fs_info->vol.bps - 1) )
|
||||
{
|
||||
rc = fat_buf_access(fs_info, sec + 1, FAT_OP_TYPE_READ,
|
||||
&block0);
|
||||
if (rc != RC_OK)
|
||||
return rc;
|
||||
|
||||
*((unsigned8 *)(block0->buffer)) &= 0x00;
|
||||
|
||||
*((unsigned8 *)(block0->buffer)) =
|
||||
(*((unsigned8 *)(block0->buffer))) |
|
||||
(unsigned8)((fat16_clv & 0xFF00)>>8);
|
||||
|
||||
fat_buf_mark_modified(fs_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
*((unsigned8 *)(block0->buffer + ofs + 1)) &= 0x00;
|
||||
|
||||
*((unsigned8 *)(block0->buffer + ofs + 1)) =
|
||||
(*((unsigned8 *)(block0->buffer + ofs + 1))) |
|
||||
(unsigned8)((fat16_clv & 0xFF00)>>8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fat16_clv = CT_LE_W((((unsigned16)in_val) & FAT_FAT12_MASK));
|
||||
|
||||
*((unsigned8 *)(block0->buffer + ofs)) &= 0x00;
|
||||
|
||||
*((unsigned8 *)(block0->buffer + ofs)) =
|
||||
(*((unsigned8 *)(block0->buffer + ofs))) |
|
||||
(unsigned8)(fat16_clv & 0x00FF);
|
||||
|
||||
fat_buf_mark_modified(fs_info);
|
||||
|
||||
if ( ofs == (fs_info->vol.bps - 1) )
|
||||
{
|
||||
rc = fat_buf_access(fs_info, sec + 1, FAT_OP_TYPE_READ,
|
||||
&block0);
|
||||
if (rc != RC_OK)
|
||||
return rc;
|
||||
|
||||
*((unsigned8 *)(block0->buffer)) =
|
||||
(*((unsigned8 *)(block0->buffer))) & 0xF0;
|
||||
|
||||
*((unsigned8 *)(block0->buffer)) =
|
||||
(*((unsigned8 *)(block0->buffer))) |
|
||||
(unsigned8)((fat16_clv & 0xFF00)>>8);
|
||||
|
||||
fat_buf_mark_modified(fs_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
*((unsigned8 *)(block0->buffer + ofs + 1)) =
|
||||
(*((unsigned8 *)(block0->buffer + ofs + 1))) & 0xF0;
|
||||
|
||||
*((unsigned8 *)(block0->buffer + ofs+1)) =
|
||||
(*((unsigned8 *)(block0->buffer + ofs+1))) |
|
||||
(unsigned8)((fat16_clv & 0xFF00)>>8);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case FAT_FAT16:
|
||||
*((unsigned16 *)(block0->buffer + ofs)) =
|
||||
(unsigned16)(CT_LE_W(in_val));
|
||||
fat_buf_mark_modified(fs_info);
|
||||
break;
|
||||
|
||||
case FAT_FAT32:
|
||||
fat32_clv = CT_LE_L((in_val & FAT_FAT32_MASK));
|
||||
|
||||
*((unsigned32 *)(block0->buffer + ofs)) =
|
||||
(*((unsigned32 *)(block0->buffer + ofs))) & (CT_LE_L(0xF0000000));
|
||||
|
||||
*((unsigned32 *)(block0->buffer + ofs)) =
|
||||
fat32_clv | (*((unsigned32 *)(block0->buffer + ofs)));
|
||||
|
||||
fat_buf_mark_modified(fs_info);
|
||||
break;
|
||||
|
||||
default:
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* fat_fat_operations.h
|
||||
*
|
||||
* Constants/data structures/prototypes for operations on Files Allocation
|
||||
* Table
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
#ifndef __DOSFS_FAT_FAT_OPERATIONS_H__
|
||||
#define __DOSFS_FAT_FAT_OPERATIONS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#include <rtems/bdbuf.h>
|
||||
#include "fat.h"
|
||||
|
||||
int
|
||||
fat_get_fat_cluster(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cln,
|
||||
unsigned32 *ret_val);
|
||||
|
||||
int
|
||||
fat_set_fat_cluster(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cln,
|
||||
unsigned32 in_val);
|
||||
|
||||
int
|
||||
fat_scan_fat_for_free_clusters(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 *chain,
|
||||
unsigned32 count,
|
||||
unsigned32 *cls_added,
|
||||
unsigned32 *last_cl
|
||||
);
|
||||
|
||||
int
|
||||
fat_free_fat_clusters_chain(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 chain
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DOSFS_FAT_FAT_OPERATIONS_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,195 +0,0 @@
|
||||
/*
|
||||
* fat_file.h
|
||||
*
|
||||
* Constants/data structures/prototypes for operations on "fat-file"
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
#ifndef __DOSFS_FAT_FILE_H__
|
||||
#define __DOSFS_FAT_FILE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
/* "fat-file" representation
|
||||
*
|
||||
* the idea is: fat-file is nothing but a cluster chain, any open fat-file is
|
||||
* represented in system by fat-file descriptor and has well-known
|
||||
* file interface:
|
||||
*
|
||||
* fat_file_open()
|
||||
* fat_file_close()
|
||||
* fat_file_read()
|
||||
* fat_file_write()
|
||||
*
|
||||
* Such interface hides the architecture of fat-file and represents it like
|
||||
* linear file
|
||||
*/
|
||||
|
||||
typedef rtems_filesystem_node_types_t fat_file_type_t;
|
||||
|
||||
#define FAT_DIRECTORY RTEMS_FILESYSTEM_DIRECTORY
|
||||
#define FAT_FILE RTEMS_FILESYSTEM_MEMORY_FILE
|
||||
|
||||
typedef struct fat_file_map_s
|
||||
{
|
||||
unsigned32 file_cln;
|
||||
unsigned32 disk_cln;
|
||||
unsigned32 last_cln;
|
||||
} fat_file_map_t;
|
||||
/*
|
||||
* descriptor of a fat-file
|
||||
*
|
||||
* To each particular clusters chain
|
||||
*/
|
||||
typedef struct fat_file_fd_s
|
||||
{
|
||||
Chain_Node link; /*
|
||||
* fat-file descriptors organized into hash;
|
||||
* collision lists are handled via link
|
||||
* field
|
||||
*/
|
||||
unsigned32 links_num; /*
|
||||
* the number of fat_file_open call on
|
||||
* this fat-file
|
||||
*/
|
||||
unsigned32 ino; /* inode, file serial number :)))) */
|
||||
fat_file_type_t fat_file_type;
|
||||
unsigned32 size_limit;
|
||||
unsigned32 fat_file_size; /* length */
|
||||
unsigned32 info_cln;
|
||||
unsigned32 cln;
|
||||
unsigned16 info_ofs;
|
||||
unsigned char first_char;
|
||||
unsigned8 flags;
|
||||
fat_file_map_t map;
|
||||
time_t mtime;
|
||||
|
||||
} fat_file_fd_t;
|
||||
|
||||
|
||||
#define FAT_FILE_REMOVED 0x01
|
||||
|
||||
#define FAT_FILE_IS_REMOVED(p)\
|
||||
(((p)->flags & FAT_FILE_REMOVED) ? 1 : 0)
|
||||
|
||||
/* ioctl macros */
|
||||
#define F_CLU_NUM 0x01
|
||||
|
||||
/*
|
||||
* Each file and directory on a MSDOS volume is unique identified by it
|
||||
* location, i.e. location of it 32 Bytes Directory Entry Structure. We can
|
||||
* distinguish them by cluster number it locates on and offset inside this
|
||||
* cluster. But root directory on any volumes (FAT12/16/32) has no 32 Bytes
|
||||
* Directory Entry Structure corresponded to it. So we assume 32 Bytes
|
||||
* Directory Entry Structure of root directory locates at cluster 1 (invalid
|
||||
* cluaster number) and offset 0
|
||||
*/
|
||||
#define FAT_ROOTDIR_CLUSTER_NUM 0x01
|
||||
|
||||
#define FAT_FD_OF_ROOT_DIR(fat_fd) \
|
||||
((fat_fd->info_cln == FAT_ROOTDIR_CLUSTER_NUM ) && \
|
||||
(fat_fd->info_ofs == 0))
|
||||
|
||||
#define FAT_EOF 0x00
|
||||
|
||||
/* fat_construct_key --
|
||||
* Construct key for hash access: convert (cluster num, offset) to
|
||||
* (sector512 num, new offset) and than construct key as
|
||||
* key = (sector512 num) << 4 | (new offset)
|
||||
*
|
||||
* PARAMETERS:
|
||||
* cl - cluster number
|
||||
* ofs - offset inside cluster 'cl'
|
||||
* mt_entry - mount table entry
|
||||
*
|
||||
* RETURNS:
|
||||
* constructed key
|
||||
*/
|
||||
static inline unsigned32
|
||||
fat_construct_key(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cl,
|
||||
unsigned32 ofs)
|
||||
{
|
||||
return ( ((fat_cluster_num_to_sector512_num(mt_entry, cl) +
|
||||
(ofs >> FAT_SECTOR512_BITS)) << 4) +
|
||||
((ofs >> 5) & (FAT_DIRENTRIES_PER_SEC512 - 1)) );
|
||||
}
|
||||
|
||||
/* Prototypes for "fat-file" operations */
|
||||
int
|
||||
fat_file_open(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cln,
|
||||
unsigned32 ofs,
|
||||
fat_file_fd_t **fat_fd);
|
||||
|
||||
int
|
||||
fat_file_reopen(fat_file_fd_t *fat_fd);
|
||||
|
||||
int
|
||||
fat_file_close(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd);
|
||||
|
||||
ssize_t
|
||||
fat_file_read(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd,
|
||||
unsigned32 start,
|
||||
unsigned32 count,
|
||||
char *buf);
|
||||
|
||||
ssize_t
|
||||
fat_file_write(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd,
|
||||
unsigned32 start,
|
||||
unsigned32 count,
|
||||
const char *buf);
|
||||
|
||||
int
|
||||
fat_file_extend(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd,
|
||||
unsigned32 new_length,
|
||||
unsigned32 *a_length);
|
||||
|
||||
int
|
||||
fat_file_truncate(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd,
|
||||
unsigned32 new_length);
|
||||
|
||||
int
|
||||
fat_file_datasync(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd);
|
||||
|
||||
|
||||
int
|
||||
fat_file_ioctl(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd,
|
||||
int cmd,
|
||||
...);
|
||||
|
||||
int
|
||||
fat_file_size(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd);
|
||||
|
||||
void
|
||||
fat_file_mark_removed(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DOSFS_FAT_FILE_H__ */
|
||||
@@ -1,408 +0,0 @@
|
||||
/*
|
||||
* msdos.h
|
||||
*
|
||||
* The MSDOS filesystem constants/data structures/prototypes
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
#ifndef __DOSFS_MSDOS_H__
|
||||
#define __DOSFS_MSDOS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#include "fat.h"
|
||||
#include "fat_file.h"
|
||||
|
||||
#ifndef RC_OK
|
||||
#define RC_OK 0x00000000
|
||||
#endif
|
||||
|
||||
#define MSDOS_NAME_NOT_FOUND_ERR 0xDD000001
|
||||
|
||||
/*
|
||||
* This structure identifies the instance of the filesystem on the MSDOS
|
||||
* level.
|
||||
*/
|
||||
typedef struct msdos_fs_info_s
|
||||
{
|
||||
fat_fs_info_t fat; /*
|
||||
* volume
|
||||
* description
|
||||
*/
|
||||
rtems_filesystem_file_handlers_r *directory_handlers; /*
|
||||
* a set of routines
|
||||
* that handles the
|
||||
* nodes of directory
|
||||
* type
|
||||
*/
|
||||
rtems_filesystem_file_handlers_r *file_handlers; /*
|
||||
* a set of routines
|
||||
* that handles the
|
||||
* nodes of file
|
||||
* type
|
||||
*/
|
||||
rtems_id vol_sema; /*
|
||||
* semaphore
|
||||
* associated with
|
||||
* the volume
|
||||
*/
|
||||
unsigned8 *cl_buf; /*
|
||||
* just placeholder
|
||||
* for anything
|
||||
*/
|
||||
} msdos_fs_info_t;
|
||||
|
||||
/* a set of routines that handle the nodes which are directories */
|
||||
extern rtems_filesystem_file_handlers_r msdos_dir_handlers;
|
||||
|
||||
/* a set of routines that handle the nodes which are files */
|
||||
extern rtems_filesystem_file_handlers_r msdos_file_handlers;
|
||||
|
||||
/* Volume semaphore timeout value */
|
||||
#define MSDOS_VOLUME_SEMAPHORE_TIMEOUT 100
|
||||
|
||||
/* Node types */
|
||||
#define MSDOS_DIRECTORY RTEMS_FILESYSTEM_DIRECTORY
|
||||
#define MSDOS_REGULAR_FILE RTEMS_FILESYSTEM_MEMORY_FILE
|
||||
|
||||
typedef rtems_filesystem_node_types_t msdos_node_type_t;
|
||||
|
||||
/*
|
||||
* Macros for fetching fields from 32 bytes long FAT Directory Entry
|
||||
* Structure (see M$ White Paper)
|
||||
*/
|
||||
#define MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE 32 /* 32 bytes */
|
||||
|
||||
#define MSDOS_DIR_NAME(x) (unsigned8 *)((x) + 0)
|
||||
#define MSDOS_DIR_ATTR(x) (unsigned8 *)((x) + 11)
|
||||
#define MSDOS_DIR_NT_RES(x) (unsigned8 *)((x) + 12)
|
||||
#define MSDOS_DIR_CRT_TIME_TENTH(x) (unsigned8 *)((x) + 13)
|
||||
#define MSDOS_DIR_CRT_TIME(x) (unsigned16 *)((x) + 14)
|
||||
#define MSDOS_DIR_CRT_DATE(x) (unsigned16 *)((x) + 16)
|
||||
#define MSDOS_DIR_LAST_ACCESS_DATE(x) (unsigned16 *)((x) + 18)
|
||||
#define MSDOS_DIR_FIRST_CLUSTER_HI(x) (unsigned16 *)((x) + 20)
|
||||
#define MSDOS_DIR_WRITE_TIME(x) (unsigned16 *)((x) + 22)
|
||||
#define MSDOS_DIR_WRITE_DATE(x) (unsigned16 *)((x) + 24)
|
||||
#define MSDOS_DIR_FIRST_CLUSTER_LOW(x) (unsigned16 *)((x) + 26)
|
||||
#define MSDOS_DIR_FILE_SIZE(x) (unsigned32 *)((x) + 28)
|
||||
|
||||
#define MSDOS_EXTRACT_CLUSTER_NUM(p) \
|
||||
(unsigned32)( (CF_LE_W(*MSDOS_DIR_FIRST_CLUSTER_LOW(p))) | \
|
||||
((CF_LE_W((*MSDOS_DIR_FIRST_CLUSTER_HI(p))))<<16) )
|
||||
|
||||
/*
|
||||
* Fields offset in 32 bytes long FAT Directory Entry
|
||||
* Structure (see M$ White Paper)
|
||||
*/
|
||||
#define MSDOS_FILE_SIZE_OFFSET 28
|
||||
#define MSDOS_FILE_NAME_OFFSET 0
|
||||
#define MSDOS_FIRST_CLUSTER_HI_OFFSET 20
|
||||
#define MSDOS_FIRST_CLUSTER_LOW_OFFSET 26
|
||||
#define MSDOS_FILE_WDATE_OFFSET 24
|
||||
#define MSDOS_FILE_WTIME_OFFSET 22
|
||||
|
||||
/*
|
||||
* Possible values of DIR_Attr field of 32 bytes long FAT Directory Entry
|
||||
* Structure (see M$ White Paper)
|
||||
*/
|
||||
#define MSDOS_ATTR_READ_ONLY 0x01
|
||||
#define MSDOS_ATTR_HIDDEN 0x02
|
||||
#define MSDOS_ATTR_SYSTEM 0x04
|
||||
#define MSDOS_ATTR_VOLUME_ID 0x08
|
||||
#define MSDOS_ATTR_DIRECTORY 0x10
|
||||
#define MSDOS_ATTR_ARCHIVE 0x20
|
||||
|
||||
/*
|
||||
* Possible values of DIR_Name[0] field of 32 bytes long FAT Directory Entry
|
||||
* Structure (see M$ White Paper)
|
||||
*/
|
||||
#define MSDOS_THIS_DIR_ENTRY_EMPTY 0xE5
|
||||
#define MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY 0x00
|
||||
|
||||
|
||||
/*
|
||||
* Macros for names parsing and formatting
|
||||
*/
|
||||
#define msdos_is_valid_name_char(_ch) (1)
|
||||
#define msdos_is_separator(_ch) rtems_filesystem_is_separator(_ch)
|
||||
|
||||
#define MSDOS_SHORT_NAME_LEN 11 /* 11 characters */
|
||||
#define MSDOS_NAME_MAX MSDOS_SHORT_NAME_LEN
|
||||
#define MSDOS_NAME_MAX_WITH_DOT (MSDOS_NAME_MAX + 1)
|
||||
|
||||
#define MSDOS_DOT_NAME ". " /* ".", padded to MSDOS_NAME chars */
|
||||
#define MSDOS_DOTDOT_NAME ".. " /* "..", padded to MSDOS_NAME chars */
|
||||
|
||||
typedef enum msdos_token_types_e
|
||||
{
|
||||
MSDOS_NO_MORE_PATH,
|
||||
MSDOS_CURRENT_DIR,
|
||||
MSDOS_UP_DIR,
|
||||
MSDOS_NAME,
|
||||
MSDOS_INVALID_TOKEN
|
||||
} msdos_token_types_t;
|
||||
|
||||
/* Others macros */
|
||||
#define MSDOS_RES_NT_VALUE 0x00
|
||||
#define MSDOS_INIT_DIR_SIZE 0x00
|
||||
|
||||
/* "dot" entry offset in a directory */
|
||||
#define MSDOS_DOT_DIR_ENTRY_OFFSET 0x00 /* first entry in directory */
|
||||
|
||||
/* "dotdot" entry offset in a directory */
|
||||
#define MSDOS_DOTDOT_DIR_ENTRY_OFFSET 0x20 /* second entry in directory */
|
||||
|
||||
/* 'p' should be char* */
|
||||
#define DOT_NODE_P(p) ((char *)(p))
|
||||
#define DOTDOT_NODE_P(p) ((char *)((p) + MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE))
|
||||
|
||||
/* Size limits for files and directories (see M$ White Paper) */
|
||||
#define MSDOS_MAX_DIR_LENGHT 0x200000 /* 2,097,152 bytes */
|
||||
#define MSDOS_MAX_FILE_SIZE 0xFFFFFFFF /* 4 Gb */
|
||||
|
||||
/*
|
||||
* The number of 32 bytes long FAT Directory Entry
|
||||
* Structures per 512 bytes sector
|
||||
*/
|
||||
#define MSDOS_DPS512_NUM 16
|
||||
|
||||
/* Prototypes */
|
||||
int
|
||||
msdos_initialize(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
|
||||
|
||||
int
|
||||
msdos_shut_down(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
|
||||
|
||||
int
|
||||
msdos_eval_path(const char *pathname, /* IN */
|
||||
int flags, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN/OUT */);
|
||||
|
||||
int
|
||||
msdos_eval4make(const char *path, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc, /* IN/OUT */
|
||||
const char **name /* OUT */);
|
||||
|
||||
int
|
||||
msdos_unlink(rtems_filesystem_location_info_t *pathloc /* IN */);
|
||||
|
||||
int
|
||||
msdos_free_node_info(rtems_filesystem_location_info_t *pathloc /* IN */);
|
||||
|
||||
rtems_filesystem_node_types_t
|
||||
msdos_node_type(rtems_filesystem_location_info_t *pathloc);
|
||||
|
||||
int
|
||||
msdos_mknod(const char *path, /* IN */
|
||||
mode_t mode, /* IN */
|
||||
dev_t dev, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN/OUT */);
|
||||
|
||||
int
|
||||
msdos_utime(rtems_filesystem_location_info_t *pathloc, /* IN */
|
||||
time_t actime, /* IN */
|
||||
time_t modtime /* IN */);
|
||||
|
||||
int
|
||||
msdos_initialize_support(
|
||||
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
|
||||
rtems_filesystem_operations_table *op_table,
|
||||
rtems_filesystem_file_handlers_r *file_handlers,
|
||||
rtems_filesystem_file_handlers_r *directory_handlers
|
||||
);
|
||||
|
||||
int
|
||||
msdos_file_open(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const char *pathname, /* IN */
|
||||
unsigned32 flag, /* IN */
|
||||
unsigned32 mode /* IN */
|
||||
);
|
||||
|
||||
int
|
||||
msdos_file_close(rtems_libio_t *iop /* IN */);
|
||||
|
||||
ssize_t
|
||||
msdos_file_read(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
ssize_t
|
||||
msdos_file_write(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int
|
||||
msdos_file_lseek(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t offset, /* IN */
|
||||
int whence /* IN */
|
||||
);
|
||||
|
||||
int
|
||||
msdos_file_stat(rtems_filesystem_location_info_t *loc, /* IN */
|
||||
struct stat *buf /* OUT */);
|
||||
|
||||
int
|
||||
msdos_file_ftruncate(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t length /* IN */
|
||||
);
|
||||
|
||||
int
|
||||
msdos_file_sync(rtems_libio_t *iop);
|
||||
|
||||
int
|
||||
msdos_file_datasync(rtems_libio_t *iop);
|
||||
|
||||
int
|
||||
msdos_file_ioctl(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
unsigned32 command, /* IN */
|
||||
void *buffer /* IN */
|
||||
);
|
||||
|
||||
int
|
||||
msdos_file_rmnod(rtems_filesystem_location_info_t *pathloc /* IN */);
|
||||
|
||||
int
|
||||
msdos_dir_open(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
const char *pathname, /* IN */
|
||||
unsigned32 flag, /* IN */
|
||||
unsigned32 mode /* IN */
|
||||
);
|
||||
|
||||
int
|
||||
msdos_dir_close(rtems_libio_t *iop /* IN */);
|
||||
|
||||
ssize_t
|
||||
msdos_dir_read(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
void *buffer, /* IN */
|
||||
unsigned32 count /* IN */
|
||||
);
|
||||
|
||||
int
|
||||
msdos_dir_lseek(
|
||||
rtems_libio_t *iop, /* IN */
|
||||
off_t offset, /* IN */
|
||||
int whence /* IN */
|
||||
);
|
||||
|
||||
int
|
||||
msdos_dir_rmnod(rtems_filesystem_location_info_t *pathloc /* IN */);
|
||||
|
||||
int
|
||||
msdos_dir_sync(rtems_libio_t *iop);
|
||||
|
||||
int
|
||||
msdos_dir_stat(
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
struct stat *buf /* OUT */
|
||||
);
|
||||
|
||||
int
|
||||
msdos_creat_node(rtems_filesystem_location_info_t *parent_loc,
|
||||
msdos_node_type_t type,
|
||||
char *name,
|
||||
mode_t mode);
|
||||
|
||||
/* Misc prototypes */
|
||||
msdos_token_types_t msdos_get_token(const char *path,
|
||||
char *token,
|
||||
int *token_len);
|
||||
|
||||
int
|
||||
msdos_find_name(rtems_filesystem_location_info_t *parent_loc,
|
||||
char *name);
|
||||
|
||||
int
|
||||
msdos_get_name_node(rtems_filesystem_location_info_t *parent_loc,
|
||||
char *name,
|
||||
fat_auxiliary_t *paux,
|
||||
char *name_dir_entry);
|
||||
|
||||
int
|
||||
msdos_dir_info_remove(rtems_filesystem_location_info_t *pathloc);
|
||||
|
||||
void
|
||||
msdos_date_unix2dos(int unix_date,
|
||||
unsigned short *time_val,
|
||||
unsigned short *date);
|
||||
|
||||
unsigned int
|
||||
msdos_date_dos2unix(unsigned short time_val, unsigned short date);
|
||||
|
||||
int
|
||||
msdos_set_first_cluster_num(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd);
|
||||
|
||||
int
|
||||
msdos_set_file_size(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd);
|
||||
|
||||
int
|
||||
msdos_set_first_char4file_name(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cl,
|
||||
unsigned32 ofs,
|
||||
unsigned char first_char);
|
||||
|
||||
int
|
||||
msdos_set_dir_wrt_time_and_date(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd
|
||||
);
|
||||
|
||||
|
||||
int
|
||||
msdos_dir_is_empty(rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd,
|
||||
rtems_boolean *ret_val);
|
||||
|
||||
int
|
||||
msdos_find_name_in_fat_file(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd,
|
||||
char *name,
|
||||
fat_auxiliary_t *paux,
|
||||
char *name_dir_entry);
|
||||
|
||||
int
|
||||
msdos_find_node_by_cluster_num_in_fat_file(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
fat_file_fd_t *fat_fd,
|
||||
unsigned32 cl4find,
|
||||
fat_auxiliary_t *paux,
|
||||
char *dir_entry
|
||||
);
|
||||
|
||||
int
|
||||
msdos_get_dotdot_dir_info_cluster_num_and_offset(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
unsigned32 cln,
|
||||
fat_auxiliary_t *paux,
|
||||
char *dir_entry
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DOSFS_MSDOS_H__ */
|
||||
@@ -1,208 +0,0 @@
|
||||
/*
|
||||
* Routine to create a new MSDOS filesystem node
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*
|
||||
*/
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <rtems/libio_.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "fat.h"
|
||||
#include "fat_fat_operations.h"
|
||||
#include "fat_file.h"
|
||||
|
||||
#include "msdos.h"
|
||||
|
||||
/* msdos_creat_node --
|
||||
* Create a new node. If a new node is file, FAT 32 Bytes Directory
|
||||
* Entry Structure (see M$ White Paper) is initialized, free space is
|
||||
* found in parent directory and structure is written to the disk.
|
||||
* In case of directory, all above steps present and also new cluster
|
||||
* is allocated for a new directory and dot and dotdot nodes are created
|
||||
* in alloceted cluster.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* parent_loc - parent (directory we are going to create node in)
|
||||
* type - new node type (file or directory)
|
||||
* name - new node name
|
||||
* mode - mode
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno set appropriately).
|
||||
*
|
||||
*/
|
||||
int
|
||||
msdos_creat_node(
|
||||
rtems_filesystem_location_info_t *parent_loc,
|
||||
msdos_node_type_t type,
|
||||
char *name,
|
||||
mode_t mode
|
||||
)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
ssize_t ret = 0;
|
||||
msdos_fs_info_t *fs_info = parent_loc->mt_entry->fs_info;
|
||||
fat_file_fd_t *parent_fat_fd = parent_loc->node_access;
|
||||
fat_file_fd_t *fat_fd = NULL;
|
||||
time_t time_ret = 0;
|
||||
unsigned16 time_val = 0;
|
||||
unsigned16 date = 0;
|
||||
fat_auxiliary_t aux;
|
||||
unsigned char new_node[MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE];
|
||||
unsigned char dot_dotdot[MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE * 2];
|
||||
|
||||
memset(new_node, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
|
||||
memset(dot_dotdot, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE * 2);
|
||||
|
||||
/* set up name */
|
||||
strncpy(MSDOS_DIR_NAME(new_node), name, MSDOS_NAME_MAX);
|
||||
|
||||
/* fill reserved field */
|
||||
*MSDOS_DIR_NT_RES(new_node) = MSDOS_RES_NT_VALUE;
|
||||
|
||||
/* set up last write date and time */
|
||||
time_ret = time(NULL);
|
||||
if ( time_ret == -1 )
|
||||
return -1;
|
||||
|
||||
msdos_date_unix2dos(time_ret, &time_val, &date);
|
||||
*MSDOS_DIR_WRITE_TIME(new_node) = CT_LE_W(time_val);
|
||||
*MSDOS_DIR_WRITE_DATE(new_node) = CT_LE_W(date);
|
||||
|
||||
/* initialize directory/file size */
|
||||
*MSDOS_DIR_FILE_SIZE(new_node) = MSDOS_INIT_DIR_SIZE;
|
||||
|
||||
if (type == MSDOS_DIRECTORY)
|
||||
*MSDOS_DIR_ATTR(new_node) |= MSDOS_ATTR_DIRECTORY;
|
||||
else
|
||||
*MSDOS_DIR_ATTR(new_node) |= MSDOS_ATTR_ARCHIVE;
|
||||
|
||||
/*
|
||||
* find free space in the parent directory and write new initialized
|
||||
* FAT 32 Bytes Directory Entry Structure (see M$ White Paper)
|
||||
* to the disk
|
||||
*/
|
||||
rc = msdos_get_name_node(parent_loc, NULL, &aux, new_node);
|
||||
if ( rc != RC_OK )
|
||||
return rc;
|
||||
|
||||
/*
|
||||
* if we create a new file we are done, if directory there are more steps
|
||||
* to do
|
||||
*/
|
||||
if (type == MSDOS_DIRECTORY)
|
||||
{
|
||||
/* open new directory as fat-file */
|
||||
rc = fat_file_open(parent_loc->mt_entry, aux.cln, aux.ofs, &fat_fd);
|
||||
if (rc != RC_OK)
|
||||
goto err;
|
||||
|
||||
/*
|
||||
* we opened fat-file for node we just created, so initialize fat-file
|
||||
* descritor
|
||||
*/
|
||||
fat_fd->info_cln = aux.cln;
|
||||
fat_fd->info_ofs = aux.ofs;
|
||||
fat_fd->fat_file_size = 0;
|
||||
fat_fd->fat_file_type = FAT_DIRECTORY;
|
||||
fat_fd->size_limit = MSDOS_MAX_DIR_LENGHT;
|
||||
|
||||
/*
|
||||
* dot and dotdot entries are identical to new node except the
|
||||
* names
|
||||
*/
|
||||
memcpy(DOT_NODE_P(dot_dotdot), new_node,
|
||||
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
|
||||
memcpy(DOTDOT_NODE_P(dot_dotdot), new_node,
|
||||
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
|
||||
memcpy(MSDOS_DIR_NAME(DOT_NODE_P(dot_dotdot)), MSDOS_DOT_NAME,
|
||||
MSDOS_NAME_MAX);
|
||||
memcpy(MSDOS_DIR_NAME(DOTDOT_NODE_P(dot_dotdot)), MSDOS_DOTDOT_NAME,
|
||||
MSDOS_NAME_MAX);
|
||||
|
||||
/* set up cluster num for dotdot entry */
|
||||
/*
|
||||
* here we can ommit FAT32 condition because for all FAT types dirs
|
||||
* right under root dir should contain 0 in dotdot entry but for
|
||||
* FAT12/16 parent_fat_fd->cluster_num always contains such value
|
||||
*/
|
||||
if ((FAT_FD_OF_ROOT_DIR(parent_fat_fd)) &&
|
||||
(fs_info->fat.vol.type & FAT_FAT32))
|
||||
{
|
||||
*MSDOS_DIR_FIRST_CLUSTER_LOW(DOTDOT_NODE_P(dot_dotdot)) = 0x0000;
|
||||
*MSDOS_DIR_FIRST_CLUSTER_HI(DOTDOT_NODE_P(dot_dotdot)) = 0x0000;
|
||||
}
|
||||
else
|
||||
{
|
||||
*MSDOS_DIR_FIRST_CLUSTER_LOW(DOTDOT_NODE_P(dot_dotdot)) =
|
||||
CT_LE_W((unsigned16)((parent_fat_fd->cln) & 0x0000FFFF));
|
||||
*MSDOS_DIR_FIRST_CLUSTER_HI(DOTDOT_NODE_P(dot_dotdot)) =
|
||||
CT_LE_W((unsigned16)(((parent_fat_fd->cln) & 0xFFFF0000)>>16));
|
||||
}
|
||||
|
||||
/*
|
||||
* write dot and dotdot entries to new fat-file: currently fat-file
|
||||
* correspondes to a new node is zero length, so it will be extended
|
||||
* by one cluster and entries will be written
|
||||
*/
|
||||
ret = fat_file_write(parent_loc->mt_entry, fat_fd, 0,
|
||||
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE * 2,
|
||||
dot_dotdot);
|
||||
if (ret < 0)
|
||||
{
|
||||
rc = -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* increment fat-file size by cluster size */
|
||||
fat_fd->fat_file_size += fs_info->fat.vol.bpc;
|
||||
|
||||
/* set up cluster num for dot entry */
|
||||
*MSDOS_DIR_FIRST_CLUSTER_LOW(DOT_NODE_P(dot_dotdot)) =
|
||||
CT_LE_W((unsigned16)((fat_fd->cln) & 0x0000FFFF));
|
||||
*MSDOS_DIR_FIRST_CLUSTER_HI(DOT_NODE_P(dot_dotdot)) =
|
||||
CT_LE_W((unsigned16)(((fat_fd->cln) & 0xFFFF0000) >> 16));
|
||||
|
||||
/* rewrite dot entry */
|
||||
ret = fat_file_write(parent_loc->mt_entry, fat_fd, 0,
|
||||
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE,
|
||||
DOT_NODE_P(dot_dotdot));
|
||||
if (ret < 0)
|
||||
{
|
||||
rc = -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* write first cluster num of a new directory to disk */
|
||||
rc = msdos_set_first_cluster_num(parent_loc->mt_entry, fat_fd);
|
||||
if (rc != RC_OK)
|
||||
goto error;
|
||||
|
||||
fat_file_close(parent_loc->mt_entry, fat_fd);
|
||||
}
|
||||
return RC_OK;
|
||||
|
||||
error:
|
||||
fat_file_close(parent_loc->mt_entry, fat_fd);
|
||||
|
||||
err:
|
||||
/* mark 32bytes structure on the disk as free */
|
||||
msdos_set_first_char4file_name(parent_loc->mt_entry, aux.cln, aux.ofs,
|
||||
0xE5);
|
||||
return rc;
|
||||
}
|
||||
@@ -1,483 +0,0 @@
|
||||
/*
|
||||
* MSDOS directory handlers implementation
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <rtems/libio_.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
#include "fat.h"
|
||||
#include "fat_fat_operations.h"
|
||||
#include "fat_file.h"
|
||||
|
||||
#include "msdos.h"
|
||||
|
||||
/* msdos_dir_open --
|
||||
* Open fat-file which correspondes to the directory being opened and
|
||||
* set offset field of file control block to zero.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
* pathname - name
|
||||
* flag - flags
|
||||
* mode - mode
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK, if directory opened successfully, or -1 if error occured (errno
|
||||
* set apropriately)
|
||||
*/
|
||||
int
|
||||
msdos_dir_open(rtems_libio_t *iop, const char *pathname, unsigned32 flag,
|
||||
unsigned32 mode)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one( EIO );
|
||||
|
||||
rc = fat_file_reopen(fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
iop->offset = 0;
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* msdos_dir_close --
|
||||
* Close fat-file which correspondes to the directory being closed
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK, if directory closed successfully, or -1 if error occured (errno
|
||||
* set apropriately.
|
||||
*/
|
||||
int
|
||||
msdos_dir_close(rtems_libio_t *iop)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one( EIO );
|
||||
|
||||
rc = fat_file_close(iop->pathinfo.mt_entry, fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* msdos_dir_read --
|
||||
* This routine will read the next directory entry based on the directory
|
||||
* offset. The offset should be equal to -n- time the size of an
|
||||
* individual dirent structure. If n is not an integer multiple of the
|
||||
* sizeof a dirent structure, an integer division will be performed to
|
||||
* determine directory entry that will be returned in the buffer. Count
|
||||
* should reflect -m- times the sizeof dirent bytes to be placed in the
|
||||
* buffer.
|
||||
* If there are not -m- dirent elements from the current directory
|
||||
* position to the end of the exisiting file, the remaining entries will
|
||||
* be placed in the buffer and the returned value will be equal to
|
||||
* -m actual- times the size of a directory entry.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
* buffer - buffer provided by user
|
||||
* count - count of bytes to read
|
||||
*
|
||||
* RETURNS:
|
||||
* the number of bytes read on success, or -1 if error occured (errno
|
||||
* set apropriately).
|
||||
*/
|
||||
ssize_t
|
||||
msdos_dir_read(rtems_libio_t *iop, void *buffer, unsigned32 count)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
fat_file_fd_t *tmp_fat_fd = NULL;
|
||||
struct dirent tmp_dirent;
|
||||
unsigned32 start = 0;
|
||||
ssize_t ret = 0;
|
||||
unsigned32 cmpltd = 0;
|
||||
unsigned32 j = 0, i = 0;
|
||||
unsigned32 bts2rd = 0;
|
||||
unsigned32 cur_cln = 0;
|
||||
|
||||
/*
|
||||
* cast start and count - protect against using sizes that are not exact
|
||||
* multiples of the -dirent- size. These could result in unexpected
|
||||
* results
|
||||
*/
|
||||
start = iop->offset / sizeof(struct dirent);
|
||||
count = (count / sizeof(struct dirent)) * sizeof(struct dirent);
|
||||
|
||||
/*
|
||||
* optimization: we know that root directory for FAT12/16 volumes is
|
||||
* sequential set of sectors and any cluster is sequential set of sectors
|
||||
* too, so read such set of sectors is quick operation for low-level IO
|
||||
* layer.
|
||||
*/
|
||||
bts2rd = (FAT_FD_OF_ROOT_DIR(fat_fd) &&
|
||||
(fs_info->fat.vol.type & (FAT_FAT12 | FAT_FAT16))) ?
|
||||
fat_fd->fat_file_size :
|
||||
fs_info->fat.vol.bpc;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
/*
|
||||
* fat-file is already opened by open call, so read it
|
||||
* Always read directory fat-file from the beggining because of MSDOS
|
||||
* directories feature :( - we should count elements currently
|
||||
* present in the directory because there may be holes :)
|
||||
*/
|
||||
ret = fat_file_read(iop->pathinfo.mt_entry, fat_fd, (j * bts2rd),
|
||||
bts2rd, fs_info->cl_buf);
|
||||
if (ret < MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
}
|
||||
|
||||
for (i = 0; i < ret; i += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
|
||||
{
|
||||
if ((*MSDOS_DIR_NAME(fs_info->cl_buf + i)) ==
|
||||
MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return cmpltd;
|
||||
}
|
||||
|
||||
if ((*MSDOS_DIR_NAME(fs_info->cl_buf + i)) ==
|
||||
MSDOS_THIS_DIR_ENTRY_EMPTY)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* skip active entries until get the entry to start from
|
||||
*/
|
||||
if (start)
|
||||
{
|
||||
start--;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Move the entry to the return buffer
|
||||
*
|
||||
* unfortunately there is no method to extract ino except to
|
||||
* open fat-file descriptor :( ... so, open it
|
||||
*/
|
||||
|
||||
/* get number of cluster we are working with */
|
||||
rc = fat_file_ioctl(iop->pathinfo.mt_entry, fat_fd, F_CLU_NUM,
|
||||
j * bts2rd, &cur_cln);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = fat_file_open(iop->pathinfo.mt_entry, cur_cln, i,
|
||||
&tmp_fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
tmp_fat_fd->info_cln = cur_cln;
|
||||
tmp_fat_fd->info_ofs = i;
|
||||
|
||||
/* fill in dirent structure */
|
||||
/* XXX: from what and in what d_off should be computed ?! */
|
||||
tmp_dirent.d_off = start + cmpltd;
|
||||
tmp_dirent.d_reclen = sizeof(struct dirent);
|
||||
tmp_dirent.d_ino = tmp_fat_fd->ino;
|
||||
tmp_dirent.d_namlen = MSDOS_SHORT_NAME_LEN;
|
||||
memcpy(tmp_dirent.d_name, MSDOS_DIR_NAME((fs_info->cl_buf + i)),
|
||||
MSDOS_SHORT_NAME_LEN);
|
||||
|
||||
/* d_name is null-terminated */
|
||||
tmp_dirent.d_name[MSDOS_SHORT_NAME_LEN] = 0;
|
||||
memcpy(buffer + cmpltd, &tmp_dirent, sizeof(struct dirent));
|
||||
|
||||
iop->offset = iop->offset + sizeof(struct dirent);
|
||||
cmpltd += (sizeof(struct dirent));
|
||||
count -= (sizeof(struct dirent));
|
||||
|
||||
/* inode number extracted, close fat-file */
|
||||
rc = fat_file_close(iop->pathinfo.mt_entry, tmp_fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (count <= 0)
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return cmpltd;
|
||||
}
|
||||
|
||||
/* msdos_dir_write --
|
||||
* no write for directory
|
||||
*/
|
||||
|
||||
/* msdos_dir_lseek --
|
||||
*
|
||||
* This routine will behave in one of three ways based on the state of
|
||||
* argument whence. Based on the state of its value the offset argument will
|
||||
* be interpreted using one of the following methods:
|
||||
*
|
||||
* SEEK_SET - offset is the absolute byte offset from the start of the
|
||||
* logical start of the dirent sequence that represents the
|
||||
* directory
|
||||
* SEEK_CUR - offset is used as the relative byte offset from the current
|
||||
* directory position index held in the iop structure
|
||||
* SEEK_END - N/A --> This will cause an assert.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
* offset - offset
|
||||
* whence - predefine directive
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno
|
||||
* set apropriately).
|
||||
*/
|
||||
int
|
||||
msdos_dir_lseek(rtems_libio_t *iop, off_t offset, int whence)
|
||||
{
|
||||
switch (whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
case SEEK_CUR:
|
||||
break;
|
||||
/*
|
||||
* Movement past the end of the directory via lseek is not a
|
||||
* permitted operation
|
||||
*/
|
||||
case SEEK_END:
|
||||
default:
|
||||
set_errno_and_return_minus_one( EINVAL );
|
||||
break;
|
||||
}
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* msdos_dir_stat --
|
||||
*
|
||||
* This routine will obtain the following information concerning the current
|
||||
* directory:
|
||||
* st_dev device id
|
||||
* st_ino node serial number :)
|
||||
* st_mode mode extracted from the node
|
||||
* st_size total size in bytes
|
||||
* st_blksize blocksize for filesystem I/O
|
||||
* st_blocks number of blocks allocated
|
||||
* stat_mtime time of last modification
|
||||
*
|
||||
* PARAMETERS:
|
||||
* loc - this directory
|
||||
* buf - stat buffer provided by user
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK and filled stat buffer on success, or -1 if error occured (errno
|
||||
* set apropriately).
|
||||
*/
|
||||
int
|
||||
msdos_dir_stat(
|
||||
rtems_filesystem_location_info_t *loc,
|
||||
struct stat *buf
|
||||
)
|
||||
{
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = loc->mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = loc->node_access;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
buf->st_dev = fs_info->fat.vol.dev;
|
||||
buf->st_ino = fat_fd->ino;
|
||||
buf->st_mode = S_IFDIR;
|
||||
buf->st_rdev = 0ll;
|
||||
buf->st_size = fat_fd->fat_file_size;
|
||||
buf->st_blocks = fat_fd->fat_file_size >> FAT_SECTOR512_BITS;
|
||||
buf->st_blksize = fs_info->fat.vol.bps;
|
||||
buf->st_mtime = fat_fd->mtime;
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* msdos_dir_truncate --
|
||||
* No truncate for directory.
|
||||
*
|
||||
* PARAMETERS:
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
*/
|
||||
|
||||
/* msdos_dir_sync --
|
||||
* The following routine does a syncronization on a MSDOS directory node.
|
||||
* DIR_WrtTime, DIR_WrtDate and DIR_fileSize fields of 32 Bytes Directory
|
||||
* Entry Structure(see M$ White Paper) should not be updated for
|
||||
* directories, so only call to corresponding fat-file routine.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno set apropriately).
|
||||
*/
|
||||
int
|
||||
msdos_dir_sync(rtems_libio_t *iop)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
rc = fat_file_datasync(iop->pathinfo.mt_entry, fat_fd);
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* msdos_dir_rmnod --
|
||||
* Remove directory node.
|
||||
*
|
||||
* Check that this directory node is not opened as fat-file, is empty and
|
||||
* not filesystem root node. If all this conditions met then delete.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* pathloc - node description
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno set apropriately).
|
||||
*/
|
||||
int
|
||||
msdos_dir_rmnod(rtems_filesystem_location_info_t *pathloc)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = pathloc->node_access;
|
||||
rtems_boolean is_empty = FALSE;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
/*
|
||||
* We deny attemp to delete open directory (if directory is current
|
||||
* directory we assume it is open one)
|
||||
*/
|
||||
if (fat_fd->links_num > 1)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
set_errno_and_return_minus_one(EBUSY);
|
||||
}
|
||||
|
||||
/*
|
||||
* You cannot remove a node that still has children
|
||||
*/
|
||||
rc = msdos_dir_is_empty(pathloc->mt_entry, fat_fd, &is_empty);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (!is_empty)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
set_errno_and_return_minus_one(ENOTEMPTY);
|
||||
}
|
||||
|
||||
/*
|
||||
* You cannot remove the file system root node.
|
||||
*/
|
||||
if (pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
set_errno_and_return_minus_one(EBUSY);
|
||||
}
|
||||
|
||||
/*
|
||||
* You cannot remove a mountpoint.
|
||||
* not used - mount() not implemenetd yet.
|
||||
*/
|
||||
|
||||
/* mark file removed */
|
||||
rc = msdos_set_first_char4file_name(pathloc->mt_entry, fat_fd->info_cln,
|
||||
fat_fd->info_ofs,
|
||||
MSDOS_THIS_DIR_ENTRY_EMPTY);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fat_file_mark_removed(pathloc->mt_entry, fat_fd);
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
@@ -1,435 +0,0 @@
|
||||
/*
|
||||
* MSDOS evaluation routines
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#include "fat.h"
|
||||
#include "fat_fat_operations.h"
|
||||
#include "fat_file.h"
|
||||
|
||||
#include "msdos.h"
|
||||
|
||||
/* msdos_set_handlers --
|
||||
* Set handlers for the node with specified type(i.e. handlers for file
|
||||
* or directory).
|
||||
*
|
||||
* PARAMETERS:
|
||||
* loc - node description
|
||||
*
|
||||
* RETURNS:
|
||||
* None
|
||||
*/
|
||||
static void
|
||||
msdos_set_handlers(rtems_filesystem_location_info_t *loc)
|
||||
{
|
||||
msdos_fs_info_t *fs_info = loc->mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = loc->node_access;
|
||||
|
||||
if (fat_fd->fat_file_type == FAT_DIRECTORY)
|
||||
loc->handlers = fs_info->directory_handlers;
|
||||
else
|
||||
loc->handlers = fs_info->file_handlers;
|
||||
}
|
||||
|
||||
/* msdos_eval_path --
|
||||
*
|
||||
* The following routine evaluate path for a node that wishes to be
|
||||
* accessed. Structure 'pathloc' is returned with a pointer to the
|
||||
* node to be accessed.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* pathname - path for evaluation
|
||||
* flags - flags
|
||||
* pathloc - node description (IN/OUT)
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK and filled pathloc on success, or -1 if error occured
|
||||
* (errno set appropriately)
|
||||
*
|
||||
*/
|
||||
int
|
||||
msdos_eval_path(
|
||||
const char *pathname,
|
||||
int flags,
|
||||
rtems_filesystem_location_info_t *pathloc
|
||||
)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = NULL;
|
||||
rtems_filesystem_location_info_t newloc;
|
||||
int i = 0;
|
||||
int len = 0;
|
||||
msdos_token_types_t type = MSDOS_CURRENT_DIR;
|
||||
char token[MSDOS_NAME_MAX + 1];
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
if (!pathloc->node_access)
|
||||
{
|
||||
errno = ENOENT;
|
||||
rc = -1;
|
||||
goto err;
|
||||
}
|
||||
|
||||
fat_fd = pathloc->node_access;
|
||||
|
||||
rc = fat_file_reopen(fat_fd);
|
||||
if (rc != RC_OK)
|
||||
goto err;
|
||||
|
||||
while ((type != MSDOS_NO_MORE_PATH) && (type != MSDOS_INVALID_TOKEN))
|
||||
{
|
||||
type = msdos_get_token(&pathname[i], token, &len);
|
||||
i += len;
|
||||
|
||||
fat_fd = pathloc->node_access;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case MSDOS_UP_DIR:
|
||||
/*
|
||||
* Only a directory can be decended into.
|
||||
*/
|
||||
if (fat_fd->fat_file_type != FAT_DIRECTORY)
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
rc = -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Am I at the root of this mounted filesystem?
|
||||
*/
|
||||
if (pathloc->node_access ==
|
||||
pathloc->mt_entry->mt_fs_root.node_access)
|
||||
{
|
||||
/*
|
||||
* Am I at the root of all filesystems?
|
||||
* XXX: MSDOS is not supposed to be base fs.
|
||||
*/
|
||||
if (pathloc->node_access ==
|
||||
rtems_filesystem_root.node_access)
|
||||
{
|
||||
break; /* Throw out the .. in this case */
|
||||
}
|
||||
else
|
||||
{
|
||||
newloc = pathloc->mt_entry->mt_point_node;
|
||||
*pathloc = newloc;
|
||||
|
||||
rc = fat_file_close(pathloc->mt_entry, fat_fd);
|
||||
if (rc != RC_OK)
|
||||
goto err;
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return (*pathloc->ops->evalpath_h)(&(pathname[i-len]),
|
||||
flags, pathloc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = msdos_find_name(pathloc, token);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
if (rc == MSDOS_NAME_NOT_FOUND_ERR)
|
||||
{
|
||||
errno = ENOENT;
|
||||
rc = -1;
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MSDOS_NAME:
|
||||
/*
|
||||
* Only a directory can be decended into.
|
||||
*/
|
||||
if (fat_fd->fat_file_type != FAT_DIRECTORY)
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
rc = -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise find the token name in the present location and
|
||||
* set the node access to the point we have found.
|
||||
*/
|
||||
rc = msdos_find_name(pathloc, token);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
if (rc == MSDOS_NAME_NOT_FOUND_ERR)
|
||||
{
|
||||
errno = ENOENT;
|
||||
rc = -1;
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
|
||||
case MSDOS_NO_MORE_PATH:
|
||||
case MSDOS_CURRENT_DIR:
|
||||
break;
|
||||
|
||||
case MSDOS_INVALID_TOKEN:
|
||||
errno = ENAMETOOLONG;
|
||||
rc = -1;
|
||||
goto error;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Always return the root node.
|
||||
*
|
||||
* If we are at a node that is a mount point. Set loc to the
|
||||
* new fs root node and let let the mounted filesystem set the handlers.
|
||||
*
|
||||
* NOTE: The behavior of stat() on a mount point appears to be
|
||||
* questionable.
|
||||
* NOTE: MSDOS filesystem currently doesn't support mount functionality ->
|
||||
* action not implemented
|
||||
*/
|
||||
fat_fd = pathloc->node_access;
|
||||
|
||||
msdos_set_handlers(pathloc);
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return RC_OK;
|
||||
|
||||
error:
|
||||
fat_file_close(pathloc->mt_entry, fat_fd);
|
||||
|
||||
err:
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* msdos_eval4make --
|
||||
* The following routine evaluate path for a new node to be created.
|
||||
* 'pathloc' is returned with a pointer to the parent of the new node.
|
||||
* 'name' is returned with a pointer to the first character in the
|
||||
* new node name. The parent node is verified to be a directory.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* path - path for evaluation
|
||||
* pathloc - IN/OUT (start point for evaluation/parent directory for
|
||||
* creation)
|
||||
* name - new node name
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK, filled pathloc for parent directory and name of new node on
|
||||
* success, or -1 if error occured (errno set appropriately)
|
||||
*/
|
||||
int
|
||||
msdos_eval4make(
|
||||
const char *path,
|
||||
rtems_filesystem_location_info_t *pathloc,
|
||||
const char **name
|
||||
)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = NULL;
|
||||
rtems_filesystem_location_info_t newloc;
|
||||
msdos_token_types_t type;
|
||||
int i = 0;
|
||||
int len;
|
||||
char token[ MSDOS_NAME_MAX + 1 ];
|
||||
rtems_boolean done = 0;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
if (!pathloc->node_access)
|
||||
{
|
||||
errno = ENOENT;
|
||||
rc = -1;
|
||||
goto err;
|
||||
}
|
||||
|
||||
fat_fd = pathloc->node_access;
|
||||
|
||||
rc = fat_file_reopen(fat_fd);
|
||||
if (rc != RC_OK)
|
||||
goto err;
|
||||
|
||||
while (!done)
|
||||
{
|
||||
type = msdos_get_token(&path[i], token, &len);
|
||||
i += len;
|
||||
fat_fd = pathloc->node_access;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case MSDOS_UP_DIR:
|
||||
/*
|
||||
* Only a directory can be decended into.
|
||||
*/
|
||||
if (fat_fd->fat_file_type != FAT_DIRECTORY)
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
rc = -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Am I at the root of this mounted filesystem?
|
||||
*/
|
||||
if (pathloc->node_access ==
|
||||
pathloc->mt_entry->mt_fs_root.node_access)
|
||||
{
|
||||
/*
|
||||
* Am I at the root of all filesystems?
|
||||
* XXX: MSDOS is not supposed to be base fs.
|
||||
*/
|
||||
if (pathloc->node_access ==
|
||||
rtems_filesystem_root.node_access)
|
||||
{
|
||||
break; /* Throw out the .. in this case */
|
||||
}
|
||||
else
|
||||
{
|
||||
newloc = pathloc->mt_entry->mt_point_node;
|
||||
*pathloc = newloc;
|
||||
|
||||
rc = fat_file_close(pathloc->mt_entry, fat_fd);
|
||||
if (rc != RC_OK)
|
||||
goto err;
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return (*pathloc->ops->evalformake_h)(&path[i-len],
|
||||
pathloc, name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = msdos_find_name(pathloc, token);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
if (rc == MSDOS_NAME_NOT_FOUND_ERR)
|
||||
{
|
||||
errno = ENOENT;
|
||||
rc = -1;
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MSDOS_NAME:
|
||||
/*
|
||||
* Only a directory can be decended into.
|
||||
*/
|
||||
if (fat_fd->fat_file_type != FAT_DIRECTORY)
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
rc = -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise find the token name in the present location and
|
||||
* set the node access to the point we have found.
|
||||
*/
|
||||
rc = msdos_find_name(pathloc, token);
|
||||
if (rc)
|
||||
{
|
||||
if (rc != MSDOS_NAME_NOT_FOUND_ERR)
|
||||
{
|
||||
errno = ENOENT;
|
||||
rc = -1;
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
done = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case MSDOS_NO_MORE_PATH:
|
||||
errno = EEXIST;
|
||||
rc = -1;
|
||||
goto error;
|
||||
break;
|
||||
|
||||
case MSDOS_CURRENT_DIR:
|
||||
break;
|
||||
|
||||
case MSDOS_INVALID_TOKEN:
|
||||
errno = ENAMETOOLONG;
|
||||
rc = -1;
|
||||
goto error;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
*name = &path[i - len];
|
||||
|
||||
/*
|
||||
* We have evaluated the path as far as we can.
|
||||
* Verify there is not any invalid stuff at the end of the name.
|
||||
*/
|
||||
for( ; path[i] != '\0'; i++)
|
||||
{
|
||||
if (!msdos_is_separator(path[i]))
|
||||
{
|
||||
errno = ENOENT;
|
||||
rc = -1;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
fat_fd = pathloc->node_access;
|
||||
|
||||
if (fat_fd->fat_file_type != FAT_DIRECTORY)
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
rc = -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
msdos_set_handlers(pathloc);
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return RC_OK;
|
||||
|
||||
error:
|
||||
fat_file_close(pathloc->mt_entry, fat_fd);
|
||||
|
||||
err:
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
@@ -1,485 +0,0 @@
|
||||
/*
|
||||
* MSDOS file handlers implementation
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#include "fat.h"
|
||||
#include "fat_fat_operations.h"
|
||||
#include "fat_file.h"
|
||||
|
||||
#include "msdos.h"
|
||||
|
||||
/* msdos_file_open --
|
||||
* Open fat-file which correspondes to the file
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
* pathname - name
|
||||
* flag - flags
|
||||
* mode - mode
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK, if file opened successfully, or -1 if error occured
|
||||
* and errno set appropriately
|
||||
*/
|
||||
int
|
||||
msdos_file_open(rtems_libio_t *iop, const char *pathname, unsigned32 flag,
|
||||
unsigned32 mode)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
rc = fat_file_reopen(fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (iop->flags & LIBIO_FLAGS_APPEND)
|
||||
iop->offset = fat_fd->fat_file_size;
|
||||
|
||||
iop->size = fat_fd->fat_file_size;
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* msdos_file_close --
|
||||
* Close fat-file which correspondes to the file. If fat-file descriptor
|
||||
* which correspondes to the file is not marked "removed", synchronize
|
||||
* size, first cluster number, write time and date fields of the file.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK, if file closed successfully, or -1 if error occured (errno set
|
||||
* appropriately)
|
||||
*/
|
||||
int
|
||||
msdos_file_close(rtems_libio_t *iop)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
/*
|
||||
* if fat-file descriptor is not marked as "removed", synchronize
|
||||
* size, first cluster number, write time and date fields of the file
|
||||
*/
|
||||
if (!FAT_FILE_IS_REMOVED(fat_fd))
|
||||
{
|
||||
rc = msdos_set_first_cluster_num(iop->pathinfo.mt_entry, fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = msdos_set_file_size(iop->pathinfo.mt_entry, fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = msdos_set_dir_wrt_time_and_date(iop->pathinfo.mt_entry, fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
rc = fat_file_close(iop->pathinfo.mt_entry, fat_fd);
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* msdos_file_read --
|
||||
* This routine read from file pointed to by file control block into
|
||||
* the specified data buffer provided by user
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
* buffer - buffer provided by user
|
||||
* count - the number of bytes to read
|
||||
*
|
||||
* RETURNS:
|
||||
* the number of bytes read on success, or -1 if error occured (errno set
|
||||
* appropriately)
|
||||
*/
|
||||
ssize_t
|
||||
msdos_file_read(rtems_libio_t *iop, void *buffer, unsigned32 count)
|
||||
{
|
||||
ssize_t ret = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
ret = fat_file_read(iop->pathinfo.mt_entry, fat_fd, iop->offset, count,
|
||||
buffer);
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* msdos_file_write --
|
||||
* This routine writes the specified data buffer into the file pointed to
|
||||
* by file control block.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
* buffer - data to write
|
||||
* count - count of bytes to write
|
||||
*
|
||||
* RETURNS:
|
||||
* the number of bytes written on success, or -1 if error occured
|
||||
* and errno set appropriately
|
||||
*/
|
||||
ssize_t
|
||||
msdos_file_write(rtems_libio_t *iop,const void *buffer, unsigned32 count)
|
||||
{
|
||||
ssize_t ret = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
ret = fat_file_write(iop->pathinfo.mt_entry, fat_fd, iop->offset, count,
|
||||
buffer);
|
||||
if (ret < 0)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* update file size in both fat-file descriptor and file control block if
|
||||
* file was extended
|
||||
*/
|
||||
if (iop->offset + ret > fat_fd->fat_file_size)
|
||||
fat_fd->fat_file_size = iop->offset + ret;
|
||||
|
||||
iop->size = fat_fd->fat_file_size;
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* msdos_file_lseek --
|
||||
* Process lseek call to the file: extend file if lseek is up to the end
|
||||
* of the file.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
* offset - new offset
|
||||
* whence - predefine directive
|
||||
*
|
||||
* RETURNS:
|
||||
* new offset on success, or -1 if error occured (errno set
|
||||
* appropriately).
|
||||
*/
|
||||
int
|
||||
msdos_file_lseek(rtems_libio_t *iop, off_t offset, int whence)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
unsigned32 real_size = 0;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
rc = fat_file_extend(iop->pathinfo.mt_entry, fat_fd, iop->offset,
|
||||
&real_size);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (real_size > fat_fd->fat_file_size)
|
||||
fat_fd->fat_file_size = iop->offset = real_size;
|
||||
|
||||
iop->size = fat_fd->fat_file_size;
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return iop->offset;
|
||||
}
|
||||
|
||||
/* msdos_file_stat --
|
||||
*
|
||||
* PARAMETERS:
|
||||
* loc - node description
|
||||
* buf - stat buffer provided by user
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno set appropriately)
|
||||
*/
|
||||
int
|
||||
msdos_file_stat(
|
||||
rtems_filesystem_location_info_t *loc,
|
||||
struct stat *buf
|
||||
)
|
||||
{
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = loc->mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = loc->node_access;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
buf->st_dev = fs_info->fat.vol.dev;
|
||||
buf->st_ino = fat_fd->ino;
|
||||
buf->st_mode = S_IFREG;
|
||||
buf->st_rdev = 0ll;
|
||||
buf->st_size = fat_fd->fat_file_size;
|
||||
buf->st_blocks = fat_fd->fat_file_size >> FAT_SECTOR512_BITS;
|
||||
buf->st_blksize = fs_info->fat.vol.bps;
|
||||
buf->st_mtime = fat_fd->mtime;
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* msdos_file_ftruncate --
|
||||
* Truncate the file (if new length is greater then current do nothing).
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
* length - new length
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno set appropriately).
|
||||
*/
|
||||
int
|
||||
msdos_file_ftruncate(rtems_libio_t *iop, off_t length)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
|
||||
if (length >= fat_fd->fat_file_size)
|
||||
return RC_OK;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
rc = fat_file_truncate(iop->pathinfo.mt_entry, fat_fd, length);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* fat_file_truncate do nothing if new length >= fat-file size, so update
|
||||
* file size only if length < fat-file size
|
||||
*/
|
||||
if (length < fat_fd->fat_file_size)
|
||||
iop->size = fat_fd->fat_file_size = length;
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* msdos_file_sync --
|
||||
* Synchronize file - synchronize file data and if file is not removed
|
||||
* synchronize file metadata.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno set appropriately)
|
||||
*/
|
||||
int
|
||||
msdos_file_sync(rtems_libio_t *iop)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
/* synchronize file data */
|
||||
rc = fat_file_datasync(iop->pathinfo.mt_entry, fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* if fat-file descriptor is not marked "removed" - synchronize file
|
||||
* metadata
|
||||
*/
|
||||
if (!FAT_FILE_IS_REMOVED(fat_fd))
|
||||
{
|
||||
rc = msdos_set_first_cluster_num(iop->pathinfo.mt_entry, fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
rc = msdos_set_file_size(iop->pathinfo.mt_entry, fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
rc = msdos_set_dir_wrt_time_and_date(iop->pathinfo.mt_entry, fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* msdos_file_datasync --
|
||||
* Synchronize file - synchronize only file data (metadata is letf intact).
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno set appropriately)
|
||||
*/
|
||||
int
|
||||
msdos_file_datasync(rtems_libio_t *iop)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
fat_file_fd_t *fat_fd = iop->file_info;
|
||||
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
/* synchronize file data */
|
||||
rc = fat_file_datasync(iop->pathinfo.mt_entry, fat_fd);
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
|
||||
/* msdos_file_ioctl --
|
||||
*
|
||||
*
|
||||
* PARAMETERS:
|
||||
* iop - file control block
|
||||
* ...
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
*/
|
||||
int
|
||||
msdos_file_ioctl(rtems_libio_t *iop,unsigned32 command, void *buffer)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* msdos_file_rmnod --
|
||||
* Remove node associated with a file - set up first name character to
|
||||
* predefined value(and write it to the disk), and mark fat-file which
|
||||
* correspondes to the file as "removed"
|
||||
*
|
||||
* PARAMETERS:
|
||||
* pathloc - node description
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno set appropriately)
|
||||
*/
|
||||
int
|
||||
msdos_file_rmnod(rtems_filesystem_location_info_t *pathloc)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = pathloc->node_access;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
/* mark file removed */
|
||||
rc = msdos_set_first_char4file_name(pathloc->mt_entry, fat_fd->info_cln,
|
||||
fat_fd->info_ofs,
|
||||
MSDOS_THIS_DIR_ENTRY_EMPTY);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fat_file_mark_removed(pathloc->mt_entry, fat_fd);
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return RC_OK;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Free node handler implementation for the filesystem
|
||||
* operations table.
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "fat.h"
|
||||
#include "fat_fat_operations.h"
|
||||
#include "fat_file.h"
|
||||
|
||||
#include "msdos.h"
|
||||
|
||||
/* msdos_free_node_info --
|
||||
* Call fat-file close routine.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* pathloc - node description
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 code if error occured
|
||||
*
|
||||
*/
|
||||
int
|
||||
msdos_free_node_info(rtems_filesystem_location_info_t *pathloc)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
rc = fat_file_close(pathloc->mt_entry, pathloc->node_access);
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* MSDOS shut down handler implementation
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#include "fat.h"
|
||||
#include "fat_fat_operations.h"
|
||||
#include "fat_file.h"
|
||||
|
||||
#include "msdos.h"
|
||||
|
||||
/* msdos_shut_down --
|
||||
* Shut down MSDOS filesystem - free all allocated resources (don't
|
||||
* return if deallocation of some resource failed - free as much as
|
||||
* possible).
|
||||
*
|
||||
* PARAMETERS:
|
||||
* temp_mt_entry - mount table entry
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno set apropriately).
|
||||
*
|
||||
*/
|
||||
int
|
||||
msdos_shut_down(rtems_filesystem_mount_table_entry_t *temp_mt_entry)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
msdos_fs_info_t *fs_info = temp_mt_entry->fs_info;
|
||||
fat_file_fd_t *fat_fd = temp_mt_entry->mt_fs_root.node_access;
|
||||
|
||||
/* close fat-file which correspondes to root directory */
|
||||
if (fat_file_close(temp_mt_entry, fat_fd) != RC_OK)
|
||||
{
|
||||
/* no return - try to free as much as possible */
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
if (fat_shutdown_drive(temp_mt_entry) != RC_OK)
|
||||
{
|
||||
/* no return - try to free as much as possible */
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
rtems_semaphore_delete(fs_info->vol_sema);
|
||||
free(fs_info->cl_buf);
|
||||
free(temp_mt_entry->fs_info);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Directory Handlers Table for MSDOS filesystem
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/libio.h>
|
||||
#include "msdos.h"
|
||||
|
||||
rtems_filesystem_file_handlers_r msdos_dir_handlers = {
|
||||
msdos_dir_open,
|
||||
msdos_dir_close,
|
||||
msdos_dir_read,
|
||||
NULL, /* msdos_dir_write */
|
||||
NULL, /* msdos_dir_ioctl */
|
||||
msdos_dir_lseek,
|
||||
msdos_dir_stat,
|
||||
NULL,
|
||||
NULL, /* msdos_dir_ftruncate */
|
||||
NULL,
|
||||
msdos_dir_sync,
|
||||
msdos_dir_sync,
|
||||
NULL, /* msdos_dir_fcntl */
|
||||
msdos_dir_rmnod
|
||||
};
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* File Operations Table for MSDOS filesystem
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/libio.h>
|
||||
#include "msdos.h"
|
||||
|
||||
rtems_filesystem_file_handlers_r msdos_file_handlers = {
|
||||
msdos_file_open,
|
||||
msdos_file_close,
|
||||
msdos_file_read,
|
||||
msdos_file_write,
|
||||
msdos_file_ioctl,
|
||||
msdos_file_lseek,
|
||||
msdos_file_stat,
|
||||
NULL,
|
||||
msdos_file_ftruncate,
|
||||
NULL,
|
||||
msdos_file_sync,
|
||||
msdos_file_datasync,
|
||||
NULL, /* msdos_file_fcntl */
|
||||
msdos_file_rmnod
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Init routine for MSDOS
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/libio_.h>
|
||||
#include "msdos.h"
|
||||
|
||||
rtems_filesystem_operations_table msdos_ops = {
|
||||
msdos_eval_path,
|
||||
msdos_eval4make,
|
||||
NULL, /* msdos_link */
|
||||
msdos_file_rmnod,
|
||||
msdos_node_type,
|
||||
msdos_mknod,
|
||||
NULL, /* msdos_chown */
|
||||
msdos_free_node_info,
|
||||
NULL,
|
||||
msdos_initialize,
|
||||
NULL,
|
||||
msdos_shut_down, /* msdos_shut_down */
|
||||
NULL, /* msdos_utime */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
/* msdos_initialize --
|
||||
* MSDOS filesystem initialization
|
||||
*
|
||||
* PARAMETERS:
|
||||
* temp_mt_entry - mount table entry
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on success, or -1 if error occured (errno set apropriately).
|
||||
*
|
||||
*/
|
||||
int
|
||||
msdos_initialize(rtems_filesystem_mount_table_entry_t *temp_mt_entry)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
|
||||
rc = msdos_initialize_support(temp_mt_entry,
|
||||
&msdos_ops,
|
||||
&msdos_file_handlers,
|
||||
&msdos_dir_handlers);
|
||||
return rc;
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
/*
|
||||
* MSDOS Initialization support routine implementation
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <rtems.h>
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#include "fat.h"
|
||||
#include "fat_fat_operations.h"
|
||||
#include "fat_file.h"
|
||||
|
||||
#include "msdos.h"
|
||||
|
||||
/* msdos_initialize_support --
|
||||
* MSDOS filesystem initialization
|
||||
*
|
||||
* PARAMETERS:
|
||||
* temp_mt_entry - mount table entry
|
||||
* op_table - filesystem operations table
|
||||
* file_handlers - file operations table
|
||||
* directory_handlers - directory operations table
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK and filled temp_mt_entry on success, or -1 if error occured
|
||||
* (errno set apropriately)
|
||||
*
|
||||
*/
|
||||
int
|
||||
msdos_initialize_support(
|
||||
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
|
||||
rtems_filesystem_operations_table *op_table,
|
||||
rtems_filesystem_file_handlers_r *file_handlers,
|
||||
rtems_filesystem_file_handlers_r *directory_handlers
|
||||
)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = NULL;
|
||||
fat_file_fd_t *fat_fd = NULL;
|
||||
unsigned32 cl_buf_size;
|
||||
|
||||
fs_info = (msdos_fs_info_t *)calloc(1, sizeof(msdos_fs_info_t));
|
||||
if (!fs_info)
|
||||
set_errno_and_return_minus_one(ENOMEM);
|
||||
|
||||
temp_mt_entry->fs_info = fs_info;
|
||||
|
||||
rc = fat_init_volume_info(temp_mt_entry);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
free(fs_info);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fs_info->file_handlers = file_handlers;
|
||||
fs_info->directory_handlers = directory_handlers;
|
||||
|
||||
/*
|
||||
* open fat-file which correspondes to root directory
|
||||
* (so inode number 0x00000010 is always used for root directory)
|
||||
*/
|
||||
rc = fat_file_open(temp_mt_entry, FAT_ROOTDIR_CLUSTER_NUM, 0, &fat_fd);
|
||||
if (rc != RC_OK)
|
||||
{
|
||||
fat_shutdown_drive(temp_mt_entry);
|
||||
free(fs_info);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* again: unfortunately "fat-file" is just almost fat file :( */
|
||||
fat_fd->fat_file_type = FAT_DIRECTORY;
|
||||
fat_fd->size_limit = MSDOS_MAX_DIR_LENGHT;
|
||||
fat_fd->info_cln = FAT_ROOTDIR_CLUSTER_NUM;
|
||||
fat_fd->info_ofs = 0;
|
||||
fat_fd->cln = fs_info->fat.vol.rdir_cl;
|
||||
|
||||
fat_fd->map.file_cln = 0;
|
||||
fat_fd->map.disk_cln = fat_fd->cln;
|
||||
|
||||
/* if we have FAT12/16 */
|
||||
if ( fat_fd->cln == 0 )
|
||||
{
|
||||
fat_fd->fat_file_size = fs_info->fat.vol.rdir_size;
|
||||
cl_buf_size = (fs_info->fat.vol.bpc > fs_info->fat.vol.rdir_size) ?
|
||||
fs_info->fat.vol.bpc :
|
||||
fs_info->fat.vol.rdir_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = fat_file_size(temp_mt_entry, fat_fd);
|
||||
if ( rc != RC_OK )
|
||||
{
|
||||
fat_file_close(temp_mt_entry, fat_fd);
|
||||
fat_shutdown_drive(temp_mt_entry);
|
||||
free(fs_info);
|
||||
return rc;
|
||||
}
|
||||
cl_buf_size = fs_info->fat.vol.bpc;
|
||||
}
|
||||
|
||||
fs_info->cl_buf = (char *)calloc(cl_buf_size, sizeof(char));
|
||||
if (fs_info->cl_buf == NULL)
|
||||
{
|
||||
fat_file_close(temp_mt_entry, fat_fd);
|
||||
fat_shutdown_drive(temp_mt_entry);
|
||||
free(fs_info);
|
||||
set_errno_and_return_minus_one(ENOMEM);
|
||||
}
|
||||
|
||||
sc = rtems_semaphore_create(3,
|
||||
1,
|
||||
RTEMS_BINARY_SEMAPHORE | RTEMS_FIFO,
|
||||
RTEMS_INHERIT_PRIORITY,
|
||||
&fs_info->vol_sema);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
{
|
||||
fat_file_close(temp_mt_entry, fat_fd);
|
||||
fat_shutdown_drive(temp_mt_entry);
|
||||
free(fs_info->cl_buf);
|
||||
free(fs_info);
|
||||
set_errno_and_return_minus_one( EIO );
|
||||
}
|
||||
|
||||
temp_mt_entry->mt_fs_root.node_access = fat_fd;
|
||||
temp_mt_entry->mt_fs_root.handlers = directory_handlers;
|
||||
temp_mt_entry->mt_fs_root.ops = op_table;
|
||||
|
||||
return rc;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Routine for node creation in MSDOS filesystem.
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <rtems.h>
|
||||
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#include "fat.h"
|
||||
#include "fat_fat_operations.h"
|
||||
#include "fat_file.h"
|
||||
|
||||
#include "msdos.h"
|
||||
|
||||
/* msdos_mknod --
|
||||
* The following function checks spelling and formats name for a new node,
|
||||
* determines type of the node to be created and creates it.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* token - non-formatted name of a new node
|
||||
* mode - node type
|
||||
* dev - dev
|
||||
* pathloc - parent directory description
|
||||
*
|
||||
* RETURNS:
|
||||
* RC_OK on succes, or -1 if error occured and set errno
|
||||
*
|
||||
*/
|
||||
int
|
||||
msdos_mknod(
|
||||
const char *token,
|
||||
mode_t mode,
|
||||
dev_t dev,
|
||||
rtems_filesystem_location_info_t *pathloc
|
||||
)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
|
||||
msdos_token_types_t type = 0;
|
||||
char new_name[ MSDOS_NAME_MAX + 1 ];
|
||||
int len;
|
||||
|
||||
/* check spelling and format new node name */
|
||||
msdos_get_token(token, new_name, &len);
|
||||
|
||||
/*
|
||||
* Figure out what type of msdos node this is.
|
||||
*/
|
||||
if (S_ISDIR(mode))
|
||||
{
|
||||
type = MSDOS_DIRECTORY;
|
||||
}
|
||||
else if (S_ISREG(mode))
|
||||
{
|
||||
type = MSDOS_REGULAR_FILE;
|
||||
}
|
||||
else
|
||||
set_errno_and_return_minus_one(EINVAL);
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
set_errno_and_return_minus_one(EIO);
|
||||
|
||||
/* Create an MSDOS node */
|
||||
rc = msdos_creat_node(pathloc, type, new_name, mode);
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return rc;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* The following returns the type of node that the loc refers to.
|
||||
*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <rtems.h>
|
||||
|
||||
#include <rtems/libio_.h>
|
||||
|
||||
#include "fat.h"
|
||||
#include "fat_fat_operations.h"
|
||||
#include "fat_file.h"
|
||||
|
||||
#include "msdos.h"
|
||||
|
||||
/* msdos_node_type --
|
||||
* Determine type of the node that the pathloc refers to.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* pathloc - node description
|
||||
*
|
||||
* RETURNS:
|
||||
* node type
|
||||
*
|
||||
*/
|
||||
rtems_filesystem_node_types_t
|
||||
msdos_node_type(rtems_filesystem_location_info_t *pathloc)
|
||||
{
|
||||
fat_file_fd_t *fat_fd;
|
||||
|
||||
/*
|
||||
* we don't need to obtain the volume semaphore here because node_type_h
|
||||
* call always follows evalpath_h call(hence link increment occured) and
|
||||
* hence node_access memory can't be freed during processing node_type_h
|
||||
* call
|
||||
*/
|
||||
fat_fd = pathloc->node_access;
|
||||
|
||||
return fat_fd->fat_file_type;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
config.h
|
||||
config.h.in
|
||||
stamp-h
|
||||
stamp-h.in
|
||||
stamp-h1.in
|
||||
@@ -1,66 +0,0 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
|
||||
INCLUDES = -I../..
|
||||
|
||||
LIBNAME = libimfs
|
||||
LIB = ${ARCH}/${LIBNAME}.a
|
||||
|
||||
IMFS_C_FILES = imfs_chown.c imfs_config.c imfs_creat.c imfs_directory.c \
|
||||
imfs_eval.c imfs_free.c imfs_fsunmount.c imfs_gtkn.c imfs_init.c \
|
||||
imfs_initsupp.c imfs_link.c imfs_mknod.c imfs_mount.c imfs_fchmod.c \
|
||||
imfs_unlink.c imfs_unmount.c imfs_utime.c imfs_ntype.c imfs_stat.c \
|
||||
imfs_getchild.c memfile.c linearfile.c deviceio.c imfs_handlers_device.c \
|
||||
imfs_handlers_directory.c imfs_handlers_link.c imfs_handlers_memfile.c \
|
||||
imfs_debug.c imfs_rmnod.c imfs_symlink.c imfs_readlink.c imfs_fdatasync.c \
|
||||
imfs_fcntl.c ioman.c miniimfs_init.c imfs_load_tar.c
|
||||
|
||||
UNIX_C_FILES = imfs_unixstub.c
|
||||
|
||||
EMBEDDED_C_FILES = $(IMFS_C_FILES)
|
||||
|
||||
COMMON_C_FILES =
|
||||
|
||||
if UNIX
|
||||
C_FILES = $(COMMON_C_FILES) $(UNIX_C_FILES)
|
||||
else
|
||||
C_FILES = $(COMMON_C_FILES) $(EMBEDDED_C_FILES)
|
||||
endif
|
||||
C_O_FILES = $(C_FILES:%.c=${ARCH}/%.o)
|
||||
|
||||
include_HEADERS = imfs.h
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../../../automake/compile.am
|
||||
include $(top_srcdir)/../../../automake/lib.am
|
||||
|
||||
PREINSTALL_FILES = $(PROJECT_INCLUDE) \
|
||||
$(include_HEADERS:%=$(PROJECT_INCLUDE)/%)
|
||||
|
||||
$(PROJECT_INCLUDE):
|
||||
@$(mkinstalldirs) $@
|
||||
|
||||
$(PROJECT_INCLUDE)/%.h: %.h
|
||||
$(INSTALL_DATA) $< $@
|
||||
|
||||
OBJS = $(C_O_FILES)
|
||||
|
||||
#
|
||||
# Add local stuff here using +=
|
||||
#
|
||||
|
||||
AM_CFLAGS += $(LIBC_DEFINES)
|
||||
|
||||
all-local: ${ARCH} $(LIB)
|
||||
|
||||
$(LIB): ${OBJS}
|
||||
$(make-library)
|
||||
|
||||
DOC_FILES = TODO CASES
|
||||
|
||||
EXTRA_DIST = $(DOC_FILES) $(COMMON_C_FILES) $(EMBEDDED_C_FILES) \
|
||||
$(UNIX_C_FILES)
|
||||
|
||||
include $(top_srcdir)/../../../automake/local.am
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user