2010-02-18 Chris Johns <chrisj@rtems.org>

* libfs/src/rfs/rtems-rfs-bitmaps.c,
        libfs/src/rfs/rtems-rfs-bitmaps.h,
        libfs/src/rfs/rtems-rfs-bitmaps-ut.c,
        libfs/src/rfs/rtems-rfs-block.c, libfs/src/rfs/rtems-rfs-block.h,
        libfs/src/rfs/rtems-rfs-block-pos.h,
        libfs/src/rfs/rtems-rfs-buffer-bdbuf.c,
        libfs/src/rfs/rtems-rfs-buffer.c,
        libfs/src/rfs/rtems-rfs-buffer-devio.c,
        libfs/src/rfs/rtems-rfs-buffer.h, libfs/src/rfs/rtems-rfs-data.h,
        libfs/src/rfs/rtems-rfs-dir.c, libfs/src/rfs/rtems-rfs-dir.h,
        libfs/src/rfs/rtems-rfs-dir-hash.c,
        libfs/src/rfs/rtems-rfs-dir-hash.h,
        libfs/src/rfs/rtems-rfs-file.c, libfs/src/rfs/rtems-rfs-file.h,
        libfs/src/rfs/rtems-rfs-file-system.c,
        libfs/src/rfs/rtems-rfs-file-system-fwd.h,
        libfs/src/rfs/rtems-rfs-file-system.h,
        libfs/src/rfs/rtems-rfs-format.c,
        libfs/src/rfs/rtems-rfs-format.h, libfs/src/rfs/rtems-rfs-group.c,
        libfs/src/rfs/rtems-rfs-group.h, libfs/src/rfs/rtems-rfs.h,
        libfs/src/rfs/rtems-rfs-inode.c, libfs/src/rfs/rtems-rfs-inode.h,
        libfs/src/rfs/rtems-rfs-link.c, libfs/src/rfs/rtems-rfs-link.h,
        libfs/src/rfs/rtems-rfs-mutex.c, libfs/src/rfs/rtems-rfs-mutex.h,
        libfs/src/rfs/rtems-rfs-rtems.c,
        libfs/src/rfs/rtems-rfs-rtems-dev.c,
        libfs/src/rfs/rtems-rfs-rtems-dir.c,
        libfs/src/rfs/rtems-rfs-rtems-file.c,
        libfs/src/rfs/rtems-rfs-rtems.h,
        libfs/src/rfs/rtems-rfs-rtems-utils.c,
        libfs/src/rfs/rtems-rfs-shell.c, libfs/src/rfs/rtems-rfs-shell.h,
        libfs/src/rfs/rtems-rfs-trace.c, libfs/src/rfs/rtems-rfs-trace.h:
        New.

        * Makefile.am, preinstall.am, libfs/Makefile.am,
        wrapup/Makefile.am: Updated with the RFS support.

        * libfs/README: Updated after 10 years.

        * libblock/src/flashdisk.c, libblock/src/nvdisk.c,
        libblock/src/ramdisk-driver.c: Updated to the new error reporting
        in libblock.

        * libmisc/shell/main_ls.c, libmisc/shell/print-ls.c: Fix printing
        the size in long mode.

        * libnetworking/nfs/bootp_subr.c,
        libnetworking/rtems/rtems_bootp.c,
        libnetworking/rtems/rtems_bsdnet_internal.h: Return the BOOTP/DHCP
        to the forever behaviour of 4.9 with the ability to call BOOTP and
        control the process if required.
This commit is contained in:
Chris Johns committed 2010-02-18 00:24:25 +00:00
1 parent 7a115ee642
commit a9fa9b765d
55 files changed
+13475 -53

No files matched your search

+52
View File
@@ -1,3 +1,55 @@
2010-02-18 Chris Johns <chrisj@rtems.org>
* libfs/src/rfs/rtems-rfs-bitmaps.c,
libfs/src/rfs/rtems-rfs-bitmaps.h,
libfs/src/rfs/rtems-rfs-bitmaps-ut.c,
libfs/src/rfs/rtems-rfs-block.c, libfs/src/rfs/rtems-rfs-block.h,
libfs/src/rfs/rtems-rfs-block-pos.h,
libfs/src/rfs/rtems-rfs-buffer-bdbuf.c,
libfs/src/rfs/rtems-rfs-buffer.c,
libfs/src/rfs/rtems-rfs-buffer-devio.c,
libfs/src/rfs/rtems-rfs-buffer.h, libfs/src/rfs/rtems-rfs-data.h,
libfs/src/rfs/rtems-rfs-dir.c, libfs/src/rfs/rtems-rfs-dir.h,
libfs/src/rfs/rtems-rfs-dir-hash.c,
libfs/src/rfs/rtems-rfs-dir-hash.h,
libfs/src/rfs/rtems-rfs-file.c, libfs/src/rfs/rtems-rfs-file.h,
libfs/src/rfs/rtems-rfs-file-system.c,
libfs/src/rfs/rtems-rfs-file-system-fwd.h,
libfs/src/rfs/rtems-rfs-file-system.h,
libfs/src/rfs/rtems-rfs-format.c,
libfs/src/rfs/rtems-rfs-format.h, libfs/src/rfs/rtems-rfs-group.c,
libfs/src/rfs/rtems-rfs-group.h, libfs/src/rfs/rtems-rfs.h,
libfs/src/rfs/rtems-rfs-inode.c, libfs/src/rfs/rtems-rfs-inode.h,
libfs/src/rfs/rtems-rfs-link.c, libfs/src/rfs/rtems-rfs-link.h,
libfs/src/rfs/rtems-rfs-mutex.c, libfs/src/rfs/rtems-rfs-mutex.h,
libfs/src/rfs/rtems-rfs-rtems.c,
libfs/src/rfs/rtems-rfs-rtems-dev.c,
libfs/src/rfs/rtems-rfs-rtems-dir.c,
libfs/src/rfs/rtems-rfs-rtems-file.c,
libfs/src/rfs/rtems-rfs-rtems.h,
libfs/src/rfs/rtems-rfs-rtems-utils.c,
libfs/src/rfs/rtems-rfs-shell.c, libfs/src/rfs/rtems-rfs-shell.h,
libfs/src/rfs/rtems-rfs-trace.c, libfs/src/rfs/rtems-rfs-trace.h:
New.
* Makefile.am, preinstall.am, libfs/Makefile.am,
wrapup/Makefile.am: Updated with the RFS support.
* libfs/README: Updated after 10 years.
* libblock/src/flashdisk.c, libblock/src/nvdisk.c,
libblock/src/ramdisk-driver.c: Updated to the new error reporting
in libblock.
* libmisc/shell/main_ls.c, libmisc/shell/print-ls.c: Fix printing
the size in long mode.
* libnetworking/nfs/bootp_subr.c,
libnetworking/rtems/rtems_bootp.c,
libnetworking/rtems/rtems_bsdnet_internal.h: Return the BOOTP/DHCP
to the forever behaviour of 4.9 with the ability to call BOOTP and
control the process if required.
2010-02-16 Chris Johns <chrisj@rtems.org>
* libcsupport/src/open.c: Tighten the open handler check.
+23
View File
@@ -95,6 +95,29 @@ if LIBDOSFS
include_rtems_HEADERS += libfs/src/dosfs/dosfs.h
endif
# RFS
include_rtems_HEADERS += \
libfs/src/rfs/rtems-rfs.h \
libfs/src/rfs/rtems-rfs-format.h \
libfs/src/rfs/rtems-rfs-shell.h
include_rtems_rfsdir = $(include_rtemsdir)/rfs
include_rtems_rfs_HEADERS = \
libfs/src/rfs/rtems-rfs-bitmaps.h \
libfs/src/rfs/rtems-rfs-block-pos.h \
libfs/src/rfs/rtems-rfs-block.h \
libfs/src/rfs/rtems-rfs-buffer.h \
libfs/src/rfs/rtems-rfs-data.h \
libfs/src/rfs/rtems-rfs-dir.h \
libfs/src/rfs/rtems-rfs-dir-hash.h \
libfs/src/rfs/rtems-rfs-file.h \
libfs/src/rfs/rtems-rfs-file-system-fwd.h \
libfs/src/rfs/rtems-rfs-file-system.h \
libfs/src/rfs/rtems-rfs-group.h \
libfs/src/rfs/rtems-rfs-inode.h \
libfs/src/rfs/rtems-rfs-link.h \
libfs/src/rfs/rtems-rfs-mutex.h \
libfs/src/rfs/rtems-rfs-trace.h
## libblock
include_rtems_HEADERS += libblock/include/rtems/bdbuf.h \
libblock/include/rtems/blkdev.h libblock/include/rtems/diskdevs.h \
+8 -6
View File
@@ -134,7 +134,7 @@
* @todo A sequence number for the block could be added. This would
* mean a larger descriptor size. Need to make the sequence
* large like 20+ bits so a large file system would not have
* more blocks available then the sequence number.
* more blocks available than the sequence number.
*/
typedef struct rtems_fdisk_page_desc
{
@@ -1304,9 +1304,9 @@ rtems_fdisk_queue_segment (rtems_flashdisk* fd, rtems_fdisk_segment_ctl* sc)
/**
* Compact the used segments to free what is available. Find the segment
* with the most avalable number of pages and see if the we have
* with the most avalable number of pages and see if we have
* used segments that will fit. The used queue is sorted on the least
* number active pages.
* number of active pages.
*/
static int
rtems_fdisk_compact (rtems_flashdisk* fd)
@@ -1701,7 +1701,7 @@ rtems_fdisk_recover_block_mappings (rtems_flashdisk* fd)
* @return EIO Invalid block size, block number, segment pointer, crc,
* page flags.
*/
static int
static bool
rtems_fdisk_read_block (rtems_flashdisk* fd,
uint32_t block,
uint8_t* buffer)
@@ -2071,7 +2071,8 @@ rtems_fdisk_read (rtems_flashdisk* fd, rtems_blkdev_request* req)
}
}
req->req_done (req->done_arg, ret ? RTEMS_SUCCESSFUL : RTEMS_IO_ERROR);
req->status = ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL;
req->req_done (req->done_arg, req->status);
return ret;
}
@@ -2106,7 +2107,8 @@ rtems_fdisk_write (rtems_flashdisk* fd, rtems_blkdev_request* req)
}
}
req->req_done (req->done_arg, ret ? RTEMS_SUCCESSFUL : RTEMS_IO_ERROR);
req->status = ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL;
req->req_done (req->done_arg, req->status);
return 0;
}
+4 -2
View File
@@ -595,7 +595,8 @@ rtems_nvdisk_read (rtems_nvdisk* nvd, rtems_blkdev_request* req)
}
}
req->req_done (req->done_arg, ret ? RTEMS_SUCCESSFUL : RTEMS_IO_ERROR);
req->status = ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL;
req->req_done (req->done_arg, req->status);
return ret;
}
@@ -634,7 +635,8 @@ rtems_nvdisk_write (rtems_nvdisk* nvd, rtems_blkdev_request* req)
}
}
req->req_done (req->done_arg, ret ? RTEMS_SUCCESSFUL : RTEMS_IO_ERROR);
req->status = ret ? RTEMS_IO_ERROR : RTEMS_SUCCESSFUL;
req->req_done (req->done_arg, req->status);
return 0;
}
+2
View File
@@ -65,6 +65,7 @@ ramdisk_read(struct ramdisk *rd, rtems_blkdev_request *req)
#endif
memcpy(sg->buffer, from + (sg->block * rd->block_size), sg->length);
}
req->status = RTEMS_SUCCESSFUL;
req->req_done(req->done_arg, RTEMS_SUCCESSFUL);
return 0;
}
@@ -89,6 +90,7 @@ ramdisk_write(struct ramdisk *rd, rtems_blkdev_request *req)
#endif
memcpy(to + (sg->block * rd->block_size), sg->buffer, sg->length);
}
req->status = RTEMS_SUCCESSFUL;
req->req_done(req->done_arg, RTEMS_SUCCESSFUL);
return 0;
}
+15
View File
@@ -62,6 +62,21 @@ libdosfs_a_SOURCES += src/dosfs/msdos_create.c src/dosfs/msdos_dir.c \
src/dosfs/dosfs.h
endif
# RFS
noinst_LIBRARIES += librfs.a
librfs_a_SOURCES = \
src/rfs/rtems-rfs-bitmaps.c src/rfs/rtems-rfs-block.c \
src/rfs/rtems-rfs-buffer-bdbuf.c src/rfs/rtems-rfs-buffer.c \
src/rfs/rtems-rfs-dir-hash.c src/rfs/rtems-rfs-file.c \
src/rfs/rtems-rfs-group.c src/rfs/rtems-rfs-inode.c \
src/rfs/rtems-rfs-rtems-dev.c src/rfs/rtems-rfs-rtems-utils.c \
src/rfs/rtems-rfs-rtems.c src/rfs/rtems-rfs-shell.c \
src/rfs/rtems-rfs-bitmaps-ut.c src/rfs/rtems-rfs-dir.c \
src/rfs/rtems-rfs-file-system.c src/rfs/rtems-rfs-format.c \
src/rfs/rtems-rfs-link.c src/rfs/rtems-rfs-mutex.c \
src/rfs/rtems-rfs-rtems-dir.c src/rfs/rtems-rfs-rtems-file.c \
src/rfs/rtems-rfs-trace.c
# ---
include $(srcdir)/preinstall.am
include $(top_srcdir)/automake/local.am
+20 -4
View File
@@ -5,9 +5,25 @@
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.
Currently the supported file systems in this library are:
- IMFS or In Memory File System
This is the only root file system on RTEMS at the moment. It supports
files, directories, device nodes and mount points. It can also be
configured to be the miniIMFS.
- TFTP and FTP filesystem are part of the libnetworking library.
- DEVFS or Device File system
- DOSFS, a FAT 12/16/32 MSDOS compatible file system.
- NFS Client, can mount NFS exported file systems.
- PIPE, a pipe file system.
- RFS, The RTEMS File System.
--Chris Johns and Joel Sherrill
18 October 2000
17 Feb 2010
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,87 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File Systems Buffer Routines for the RTEMS libblock BD buffer cache.
*
*/
#include <errno.h>
#include <rtems/rfs/rtems-rfs-buffer.h>
#include <rtems/rfs/rtems-rfs-file-system.h>
#if RTEMS_RFS_USE_LIBBLOCK
/**
* Show errors.
*/
#define RTEMS_RFS_BUFFER_ERRORS 0
int
rtems_rfs_buffer_bdbuf_request (rtems_rfs_file_system* fs,
rtems_rfs_buffer_block block,
bool read,
rtems_rfs_buffer** buffer)
{
rtems_status_code sc;
int rc = 0;
if (read)
sc = rtems_bdbuf_read (rtems_rfs_fs_device (fs), block, buffer);
else
sc = rtems_bdbuf_get (rtems_rfs_fs_device (fs), block, buffer);
if (sc != RTEMS_SUCCESSFUL)
{
#if RTEMS_RFS_BUFFER_ERRORS
printf ("rtems-rfs: buffer-bdbuf-request: block=%lu: bdbuf-%s: %d: %s\n",
block, read ? "read" : "get", sc, rtems_status_text (sc));
#endif
rc = EIO;
}
return rc;
}
int
rtems_rfs_buffer_bdbuf_release (rtems_rfs_buffer* buffer,
bool modified)
{
rtems_status_code sc;
int rc = 0;
if (rtems_rfs_trace (RTEMS_RFS_TRACE_BUFFER_RELEASE))
printf ("rtems-rfs: bdbuf-release: block=%lu bdbuf=%lu %s\n",
(rtems_rfs_buffer_block) buffer->user,
buffer->block, modified ? "(modified)" : "");
if (modified)
sc = rtems_bdbuf_release_modified (buffer);
else
sc = rtems_bdbuf_release (buffer);
if (sc != RTEMS_SUCCESSFUL)
{
#if RTEMS_RFS_BUFFER_ERRORS
printf ("rtems-rfs: buffer-release: bdbuf-%s: %s(%d)\n",
modified ? "modified" : "not-modified",
rtems_status_text (sc), sc);
#endif
rc = EIO;
}
return rc;
}
#endif
@@ -0,0 +1,57 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File Systems Buffer Routines.
*
*/
#include <errno.h>
#include <rtems/rfs/rtems-rfs-buffer.h>
#include <rtems/rfs/rtems-rfs-file-system.h>
#if !RTEMS_RFS_USE_LIBBLOCK
/**
* Show errors.
*/
#define RTEMS_RFS_BUFFER_ERRORS 1
int
rtems_rfs_buffer_deviceio_request (rtems_rfs_buffer_handle* handle,
dev_t device,
rtems_rfs_buffer_block block,
bool read)
{
}
int
rtems_rfs_buffer_deviceio_release (rtems_rfs_buffer_handle* handle,
dev_t device)
{
}
int
rtems_rfs_buffer_deviceio_handle_open (rtems_rfs_buffer_handle* handle,
dev_t device)
{
}
int
rtems_rfs_buffer_device_handle_close (rtems_rfs_buffer_handle* handle,
dev_t device)
{
}
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+78
View File
@@ -0,0 +1,78 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File System Data.
*
* Access data in the correct byte order for the specific target we are running
* on.
*
* @todo Make direct access on matching byte ordered targets.
*/
#if !defined (_RTEMS_RFS_DATA_H_)
#define _RTEMS_RFS_DATA_H_
#include <stdint.h>
/**
* Helper function to make sure we have a byte pointer.
*/
#define rtems_rfs_data_ptr(_d) ((uint8_t*)(_d))
/**
* RFS Read Unsigned 8bit Integer
*/
#define rtems_rfs_read_u8(_d) \
(*rtems_rfs_data_ptr (_d))
/**
* RFS Read Unsigned 16bit Integer
*/
#define rtems_rfs_read_u16(_d) \
((rtems_rfs_data_ptr (_d)[0] << 8) | (rtems_rfs_data_ptr (_d)[1]))
/**
* RFS Read Unsigned 32bit Integer
*/
#define rtems_rfs_read_u32(_d) \
((rtems_rfs_data_ptr (_d)[0] << 24) | (rtems_rfs_data_ptr (_d)[1] << 16) | \
(rtems_rfs_data_ptr (_d)[2] << 8) | (rtems_rfs_data_ptr (_d)[3]))
/**
* RFS Write Unsigned 8bit Integer
*/
#define rtems_rfs_write_u8(_d, _v) \
(*rtems_rfs_data_ptr (_d) = (uint8_t)(_v))
/**
* RFS Write Unsigned 16bit Integer
*/
#define rtems_rfs_write_u16(_d, _v) \
do { \
rtems_rfs_data_ptr (_d)[0] = (uint8_t)((_v) >> 8); \
rtems_rfs_data_ptr (_d)[1] = (uint8_t)((_v)); \
} while (0)
/**
* RFS Write Unsigned 32bit Integer
*/
#define rtems_rfs_write_u32(_d, _v) \
do { \
rtems_rfs_data_ptr (_d)[0] = (uint8_t)((_v) >> 24); \
rtems_rfs_data_ptr (_d)[1] = (uint8_t)((_v) >> 16); \
rtems_rfs_data_ptr (_d)[2] = (uint8_t)((_v) >> 8); \
rtems_rfs_data_ptr (_d)[3] = (uint8_t)((_v)); \
} while (0)
#endif
File diff suppressed because it is too large. Load diff
+34
View File
@@ -0,0 +1,34 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File Systems Directory Hash provides a 32bit hash of a string. This is
* used to search a directory.
*/
#if !defined (_RTEMS_RFS_DIR_HASH_H_)
#define _RTEMS_RFS_DIR_HAS_H_
#include <stddef.h>
#include <stdint.h>
/**
* Compute a hash of the key over the length of string.
*
* @param key The key to calculate the hash of.
* @param length The length of the key in bytes.
* @return uint32_t The hash.
*/
uint32_t rtems_rfs_dir_hash (const void *key, size_t length);
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,27 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File Systems Data forward decl.
*/
#if !defined (_RTEMS_RFS_FILE_SYSTEM_FWD_H_)
#define _RTEMS_RFS_FILE_SYSTEM_FWD_H_
/**
* Forward reference to the file system data.
*/
struct rtems_rfs_file_system_t;
typedef struct rtems_rfs_file_system_t rtems_rfs_file_system;
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+90
View File
@@ -0,0 +1,90 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File System Format.
*
* This function lets you format a disk in the RFS format.
*/
#if !defined (_RTEMS_RFS_FORMAT_H_)
#define _RTEMS_RFS_FORMAT_H_
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <rtems/rfs/rtems-rfs-trace.h>
/**
* RFS File System Configuration data used to format the file system. For
* default values leave the field set to 0.
*/
typedef struct rtems_rfs_format_config_t
{
/**
* The size of a block.
*/
size_t block_size;
/**
* The number of blocks in a group.
*/
size_t group_blocks;
/**
* The number of inodes in a group.
*/
size_t group_inodes;
/**
* The percentage overhead allocated to inodes.
*/
int inode_overhead;
/**
* The maximum length of a name.
*/
size_t max_name_length;
/**
* Initialise the inode tables to all ones.
*/
bool initialise_inodes;
/**
* Is the format verbose.
*/
bool verbose;
} rtems_rfs_format_config;
/**
* RFS Format command.
*
* @param name The device name to format.
* @param config Pointer to a configuration table.
* @retval -1 Error. See errno.
* @retval 0 No error. Format successful.
*/
int rtems_rfs_format (const char* name, const rtems_rfs_format_config* config);
#ifdef __cplusplus
}
#endif
#endif
File diff suppressed because it is too large. Load diff
+151
View File
@@ -0,0 +1,151 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File Systems Group Management.
*
* These functions manage the groups used in the file system.
*/
#if !defined (_RTEMS_RFS_GROUP_H_)
#define _RTEMS_RFS_GROUP_H_
#include <rtems/rfs/rtems-rfs-trace.h>
#include <rtems/rfs/rtems-rfs-bitmaps.h>
#include <rtems/rfs/rtems-rfs-buffer.h>
/**
* Block allocations for a group on disk.
*/
#define RTEMS_RFS_GROUP_BLOCK_BITMAP_BLOCK (0)
#define RTEMS_RFS_GROUP_INODE_BITMAP_BLOCK (1)
#define RTEMS_RFS_GROUP_INODE_BLOCK (2)
/**
* A group is a selection of blocks on the disk. Typically the number of blocks
* in a group is determined by the number of bits a block holds. This makes the
* bit allocator for blocks in the group simpler plus is allows a simple way to
* localise access to files and directories.
*/
typedef struct rtems_rfs_group_t
{
/**
* Base block number.
*/
rtems_rfs_buffer_block base;
/**
* The number of blocks in the group. Groups may be different sizes.
*/
size_t size;
/**
* The block bitmap control.
*/
rtems_rfs_bitmap_control block_bitmap;
/**
* The handle to the block bitmap buffer.
*/
rtems_rfs_buffer_handle block_bitmap_buffer;
/**
* The inode bitmap control.
*/
rtems_rfs_bitmap_control inode_bitmap;
/**
* The handle to the inode bitmap buffer.
*/
rtems_rfs_buffer_handle inode_bitmap_buffer;
} rtems_rfs_group;
/**
* Return the disk's block for a block in a group.
*/
#define rtems_rfs_group_block(_g, _b) (((_g)->base) + (_b))
/**
* Return the file system inode for a inode in a group.
*/
#define rtems_rfs_group_inode(_f, _g, _i) \
(((_f)->group_inodes * (_g)) + (_i) + RTEMS_RFS_ROOT_INO)
/**
* Open a group. Allocate all the resources including the bitmaps.
*
* @param fs The file system.
* @param base The base block number.
* @param size The number of blocks in the group.
* @param group Reference to the group to open.
* @return int The error number (errno). No error if 0.
*/
int rtems_rfs_group_open (rtems_rfs_file_system* fs,
rtems_rfs_buffer_block base,
size_t size,
size_t inodes,
rtems_rfs_group* group);
/**
* Close a group. Release all resources the group holds.
*
* @param fs The file system.
* @param group The group to close.
* @return int The error number (errno). No error if 0.
*/
int rtems_rfs_group_close (rtems_rfs_file_system* fs,
rtems_rfs_group* group);
/**
* Allocate an inode or block. The groups are searched to find the next
* available inode or block.
*
* @param fs The file system data.
* @param goal The goal to seed the bitmap search.
* @param inode If true allocate an inode else allocate a block.
* @param result The allocated bit in the bitmap.
* @return int The error number (errno). No error if 0.
*/
int rtems_rfs_group_bitmap_alloc (rtems_rfs_file_system* fs,
rtems_rfs_bitmap_bit goal,
bool inode,
rtems_rfs_bitmap_bit* result);
/**
* Free the group allocated bit.
*
* @param fs The file system data.
* @param inode If true the number to free is an inode else it is a block.
* @prarm block The inode or block number to free.
* @return int The error number (errno). No error if 0.
*/
int rtems_rfs_group_bitmap_free (rtems_rfs_file_system* fs,
bool inode,
rtems_rfs_bitmap_bit no);
/**
* Test the group allocated bit.
*
* @param fs The file system data.
* @param inode If true the number to free is an inode else it is a block.
* @prarm block The inode or block number to free.
* @prarm state Return the state of the bit.
* @return int The error number (errno). No error if 0.
*/
int rtems_rfs_group_bitmap_test (rtems_rfs_file_system* fs,
bool inode,
rtems_rfs_bitmap_bit no,
bool* state);
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+99
View File
@@ -0,0 +1,99 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File System Link Support
*
* This file provides the link support functions.
*/
#if !defined (_RTEMS_RFS_LINK_H_)
#define _RTEMS_RFS_LINK_H_
#include <dirent.h>
#include <rtems/rfs/rtems-rfs-file-system.h>
#include <rtems/rfs/rtems-rfs-inode.h>
/**
* Create a link.
*
* @param fs The file system.
* @param name The name of the link.
* @param length The length of the name.
* @param parent The inode number of the parent directory.
* @param target The inode of the target.
* @return int The error number (errno). No error if 0.
*/
int rtems_rfs_link (rtems_rfs_file_system* fs,
const char* name,
int length,
rtems_rfs_ino parent,
rtems_rfs_ino target);
/**
* Unlink the node from the parent directory. A directory offset for the target
* entry is required because links cause a number of inode numbers to appear in
* a single directory so scanning does not work.
*
* @param fs The file system.
* @param parent The inode number of the parent directory.
* @param target The inode of the target.
* @param doff Parent directory entry offset for the target entry.
* @param dir If true unlinking of directory nodes is allowed.
* @return int The error number (errno). No error if 0.
*/
int rtems_rfs_unlink (rtems_rfs_file_system* fs,
rtems_rfs_ino parent,
rtems_rfs_ino target,
uint32_t doff,
bool dir);
/**
* Symbolic link is an inode that has a path attached.
*
* @param fs The file system data.
* @param name The name of the node.
* @param length The length of the name of the node.
* @param link The link path attached to the symlink inode.
* @param link_length The length of the link path.
* @param parent The parent inode number.
* @return int The error number (errno). No error if 0.
*/
int rtems_rfs_symlink (rtems_rfs_file_system* fs,
const char* name,
int length,
const char* link,
int link_length,
uid_t uid,
gid_t gid,
rtems_rfs_ino parent);
/**
* Read a symbolic link into the provided buffer returning the link of link
* name.
*
* @param fs The file system data.
* @param link The link inode number to read.
* @param path The buffer to write the link path into.
* @param size The size of the buffer.
* @param length Set to the length of the link path.
* @return int The error number (errno). No error if 0.
*/
int rtems_rfs_symlink_read (rtems_rfs_file_system* fs,
rtems_rfs_ino link,
char* path,
size_t size,
size_t* length);
#endif
+68
View File
@@ -0,0 +1,68 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File System Mutex.
*/
#include <rtems/rfs/rtems-rfs-mutex.h>
#if __rtems__
/**
* RTEMS_RFS Mutex Attributes
*
* @warning Do not configure as inherit priority. If a driver is in the driver
* initialisation table this locked semaphore will have the IDLE task
* as the holder and a blocking task will raise the priority of the
* IDLE task which can cause unsual side effects like not work.
*/
#define RTEMS_RFS_MUTEX_ATTRIBS \
(RTEMS_PRIORITY | RTEMS_SIMPLE_BINARY_SEMAPHORE | \
RTEMS_NO_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL)
#endif
int
rtems_rfs_mutex_create (rtems_rfs_mutex* mutex)
{
#if __rtems__
rtems_status_code sc;
sc = rtems_semaphore_create (rtems_build_name ('R', 'F', 'S', 'm'),
1, RTEMS_RFS_MUTEX_ATTRIBS, 0,
mutex);
if (sc != RTEMS_SUCCESSFUL)
{
if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
printf ("rtems-rfs: mutex: open failed: %s\n",
rtems_status_text (sc));
return EIO;
}
#endif
return 0;
}
int
rtems_rfs_mutex_destroy (rtems_rfs_mutex* mutex)
{
#if __rtems__
rtems_status_code sc;
sc = rtems_semaphore_delete (*mutex);
if (sc != RTEMS_SUCCESSFUL)
{
if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
printf ("rtems-rfs: mutex: close failed: %s\n",
rtems_status_text (sc));
return EIO;
}
#endif
return 0;
}
+108
View File
@@ -0,0 +1,108 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File System Mutex.
*
* It may be suprising we abstract this for the RTEMS file system but this code
* is designed to be run on host operating systems.
*/
#if !defined (_RTEMS_RFS_MUTEX_H_)
#define _RTEMS_RFS_MUTEX_H_
#include <errno.h>
#include <rtems/rfs/rtems-rfs-trace.h>
#if __rtems__
#include <rtems.h>
#include <rtems/error.h>
#endif
/**
* RFS Mutex type.
*/
#if __rtems__
typedef rtems_id rtems_rfs_mutex;
#else
typedef uint32_t rtems_rfs_mutex; /* place holder */
#endif
/**
* Create the mutex.
*
* @param mutex Reference to the mutex handle returned to the caller.
* @return int The error number (errno). No error if 0.
*/
int rtems_rfs_mutex_create (rtems_rfs_mutex* mutex);
/**
* Create the mutex.
*
* @param mutex Reference to the mutex handle returned to the caller.
* @return int The error number (errno). No error if 0.
*/
int rtems_rfs_mutex_destroy (rtems_rfs_mutex* mutex);
/**
* Lock the mutex.
*
* @param mutex The mutex to lock.
* @retval true The mutex is locked.
* @retval false The mutex could not be locked.
*/
static inline int
rtems_rfs_mutex_lock (rtems_rfs_mutex* mutex)
{
#if __rtems__
rtems_status_code sc = rtems_semaphore_obtain (*mutex, RTEMS_WAIT, 0);
if (sc != RTEMS_SUCCESSFUL)
{
#if RTEMS_RFS_TRACE
if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
printf ("rtems-rfs: mutex: obtain failed: %s\n",
rtems_status_text (sc));
#endif
return EIO;
}
#endif
return 0;
}
/**
* Unlock the mutex.
*
* @param mutex The mutex to unlock.
* @retval true The mutex is unlocked.
* @retval false The mutex could not be unlocked.
*/
static inline int
rtems_rfs_mutex_unlock (rtems_rfs_mutex* mutex)
{
#if __rtems__
rtems_status_code sc = rtems_semaphore_release (*mutex);
if (sc != RTEMS_SUCCESSFUL)
{
#if RTEMS_RFS_TRACE
if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
printf ("rtems-rfs: mutex: release failed: %s\n",
rtems_status_text (sc));
#endif
return EIO;
}
#endif
return 0;
}
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+35
View File
@@ -0,0 +1,35 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File Systems Shell commands provide a CLI interface to support and
* development od the RFS file system.
*/
#if !defined (_RTEMS_RFS_SHELL_H_)
#define _RTEMS_RFS_SHELL_H_
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
/**
* The shell command for the RFS debugger.
*
* @param argc The argument count.
* @param argv The argument variables.
* @return int The exit code for the command. A 0 is no error.
*/
int rtems_rfs_shell_debugrfs (int argc, char *argv[]);
#endif
+154
View File
@@ -0,0 +1,154 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File Systems Trace Support
*/
#include <string.h>
#include <rtems/rfs/rtems-rfs-trace.h>
#if RTEMS_RFS_TRACE
static rtems_rfs_trace_mask rtems_rfs_trace_flags;
bool
rtems_rfs_trace (rtems_rfs_trace_mask mask)
{
bool result = false;
if (mask & rtems_rfs_trace_flags)
result = true;
return result;
}
rtems_rfs_trace_mask
rtems_rfs_trace_set_mask (rtems_rfs_trace_mask mask)
{
rtems_rfs_trace_mask state = rtems_rfs_trace_flags;
rtems_rfs_trace_flags |= mask;
return state;
}
rtems_rfs_trace_mask
rtems_rfs_trace_clear_mask (rtems_rfs_trace_mask mask)
{
rtems_rfs_trace_mask state = rtems_rfs_trace_flags;
rtems_rfs_trace_flags &= ~mask;
return state;
}
int
rtems_rfs_trace_shell_command (int argc, char *argv[])
{
const char* table[] =
{
"open",
"close",
"mutex",
"buffer-open",
"buffer-close",
"buffer-sync",
"buffer-release",
"buffer-chains",
"buffer-handle-request",
"buffer-handle-release",
"buffer-setblksize",
"buffers-release",
"block-find",
"block-map-grow",
"block-map-shrink",
"group-open",
"group-close",
"group-bitmaps",
"inode-open",
"inode-close",
"inode-load",
"inode-unload",
"inode-create",
"link",
"unlink",
"dir-lookup-ino",
"dir-lookup-ino-check",
"dir-lookup-ino-found",
"dir-add-entry",
"dir-del-entry",
"dir-read",
"dir-empty",
"symlink",
"symlink-read",
"file-open",
"file-close",
"file-io"
};
rtems_rfs_trace_mask set_value = 0;
rtems_rfs_trace_mask clear_value = 0;
bool set = true;
int arg;
int t;
for (arg = 1; arg < argc; arg++)
{
if (argv[arg][0] == '-')
{
switch (argv[arg][1])
{
case 'h':
printf ("usage: %s [-hl] [set/clear] [flags]\n", argv[0]);
return 0;
case 'l':
printf ("%s: valid flags to set or clear are:\n", argv[0]);
for (t = 0; t < (sizeof (table) / sizeof (const char*)); t++)
printf (" %s\n", table[t]);
return 0;
default:
printf ("error: unknown option\n");
return 1;
}
}
else
{
if (strcmp (argv[arg], "set") == 0)
set = true;
if (strcmp (argv[arg], "clear") == 0)
set = false;
else if (strcmp (argv[arg], "all") == 0)
{
if (set)
set_value = RTEMS_RFS_TRACE_ALL;
else
clear_value = RTEMS_RFS_TRACE_ALL;
}
else
{
for (t = 0; t < (sizeof (table) / sizeof (const char*)); t++)
{
if (strcmp (argv[arg], table[t]) == 0)
{
if (set)
set_value = 1 << t;
else
clear_value = 1 << t;
break;
}
}
}
rtems_rfs_trace_flags |= set_value;
rtems_rfs_trace_flags &= ~clear_value;
}
}
return 0;
}
#endif
+126
View File
@@ -0,0 +1,126 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File Systems Trace manages the trace and debugging features of the
* RTEMS RFS file system. The design allows all tracing code and strings to be
* removed from the target code for small footprint systems.
*/
#if !defined (_RTEMS_RFS_TRACE_H_)
#define _RTEMS_RFS_TRACE_H_
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
/**
* Is tracing enabled ?
*/
#define RTEMS_RFS_TRACE 0
/**
* The type of the mask.
*/
typedef uint64_t rtems_rfs_trace_mask;
/**
* List of tracing bits for the various parts of the file system.
*/
#define RTEMS_RFS_TRACE_ALL (0xffffffffffffffffULL)
#define RTEMS_RFS_TRACE_OPEN (1ULL << 0)
#define RTEMS_RFS_TRACE_CLOSE (1ULL << 1)
#define RTEMS_RFS_TRACE_MUTEX (1ULL << 2)
#define RTEMS_RFS_TRACE_BUFFER_OPEN (1ULL << 3)
#define RTEMS_RFS_TRACE_BUFFER_CLOSE (1ULL << 4)
#define RTEMS_RFS_TRACE_BUFFER_SYNC (1ULL << 5)
#define RTEMS_RFS_TRACE_BUFFER_RELEASE (1ULL << 6)
#define RTEMS_RFS_TRACE_BUFFER_CHAINS (1ULL << 7)
#define RTEMS_RFS_TRACE_BUFFER_HANDLE_REQUEST (1ULL << 8)
#define RTEMS_RFS_TRACE_BUFFER_HANDLE_RELEASE (1ULL << 9)
#define RTEMS_RFS_TRACE_BUFFER_SETBLKSIZE (1ULL << 10)
#define RTEMS_RFS_TRACE_BUFFERS_RELEASE (1ULL << 11)
#define RTEMS_RFS_TRACE_BLOCK_FIND (1ULL << 12)
#define RTEMS_RFS_TRACE_BLOCK_MAP_GROW (1ULL << 13)
#define RTEMS_RFS_TRACE_BLOCK_MAP_SHRINK (1ULL << 14)
#define RTEMS_RFS_TRACE_GROUP_OPEN (1ULL << 15)
#define RTEMS_RFS_TRACE_GROUP_CLOSE (1ULL << 16)
#define RTEMS_RFS_TRACE_GROUP_BITMAPS (1ULL << 17)
#define RTEMS_RFS_TRACE_INODE_OPEN (1ULL << 18)
#define RTEMS_RFS_TRACE_INODE_CLOSE (1ULL << 19)
#define RTEMS_RFS_TRACE_INODE_LOAD (1ULL << 20)
#define RTEMS_RFS_TRACE_INODE_UNLOAD (1ULL << 21)
#define RTEMS_RFS_TRACE_INODE_CREATE (1ULL << 22)
#define RTEMS_RFS_TRACE_LINK (1ULL << 23)
#define RTEMS_RFS_TRACE_UNLINK (1ULL << 24)
#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO (1ULL << 25)
#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_CHECK (1ULL << 26)
#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_FOUND (1ULL << 27)
#define RTEMS_RFS_TRACE_DIR_ADD_ENTRY (1ULL << 28)
#define RTEMS_RFS_TRACE_DIR_DEL_ENTRY (1ULL << 29)
#define RTEMS_RFS_TRACE_DIR_READ (1ULL << 30)
#define RTEMS_RFS_TRACE_DIR_EMPTY (1ULL << 31)
#define RTEMS_RFS_TRACE_SYMLINK (1ULL << 32)
#define RTEMS_RFS_TRACE_SYMLINK_READ (1ULL << 33)
#define RTEMS_RFS_TRACE_FILE_OPEN (1ULL << 34)
#define RTEMS_RFS_TRACE_FILE_CLOSE (1ULL << 35)
#define RTEMS_RFS_TRACE_FILE_IO (1ULL << 36)
#define RTEMS_RFS_TRACE_FILE_SET (1ULL << 37)
/**
* Call to check if this part is bring traced. If RTEMS_RFS_TRACE is defined to
* 0 the code is dead code elminiated when built with -Os, -O2, or higher.
*
* @param mask The part of the API to trace.
* @retval true Tracing is active for the mask.
* @retval false Do not trace.
*/
#if RTEMS_RFS_TRACE
bool rtems_rfs_trace (rtems_rfs_trace_mask mask);
#else
#define rtems_rfs_trace(_m) (0)
#endif
/**
* Set the mask.
*
* @param mask The mask bits to set.
* @return The previous mask.
*/
#if RTEMS_RFS_TRACE
rtems_rfs_trace_mask rtems_rfs_trace_set_mask (rtems_rfs_trace_mask mask);
#else
#define rtems_rfs_trace_set_mask(_m)
#endif
/**
* Clear the mask.
*
* @param mask The mask bits to clear.
* @return The previous mask.
*/
#if RTEMS_RFS_TRACE
rtems_rfs_trace_mask rtems_rfs_trace_clear_mask (rtems_rfs_trace_mask mask);
#else
#define rtems_rfs_trace_clear_mask(_m)
#endif
/**
* Add shell trace shell command.
*/
#if RTEMS_RFS_TRACE
int rtems_rfs_trace_shell_command (int argc, char *argv[]);
#endif
#endif
+35
View File
@@ -0,0 +1,35 @@
/*
* COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
/**
* @file
*
* @ingroup rtems-rfs
*
* RTEMS File System
*
*/
#if !defined(RTEMS_RFS_DEFINED)
#define RTEMS_RFS_DEFINED
#include <rtems.h>
#include <rtems/fs.h>
/**
* File ops table for the RFS file system.
*/
const rtems_filesystem_operations_table rtems_rfs_ops;
/**
* Initialise the RFS File system.
*/
int rtems_rfs_initialise (rtems_filesystem_mount_table_entry_t *mt_entry);
#endif
+3 -2
View File
@@ -573,8 +573,9 @@ display(rtems_shell_ls_globals* globals, FTSENT *p, FTSENT *list)
maxlen = cur->fts_namelen;
if (needstats) {
sp = cur->fts_statp;
size = ((uint64_t) sp->st_blocks) * sp->st_blksize;
if (size < 0x100000000ULL)
if (sp->st_size < 0)
size = sp->st_size * -1;
else
size = sp->st_size;
if (sp->st_blocks > maxblock)
maxblock = sp->st_blocks;
+4 -3
View File
@@ -162,9 +162,10 @@ printlong(rtems_shell_ls_globals* globals, DISPLAY *dp)
} else {
#endif
{
unsigned long long size = sp->st_blocks;
size *= sp->st_blksize;
if (size < 0x100000000ULL)
unsigned long long size;
if (sp->st_size < 0)
size = sp->st_size * -1;
else
size = sp->st_size;
(void)printf("%*llu ", dp->s_size, size);
}
+43 -33
View File
@@ -152,8 +152,6 @@ bootpc_adjust_interface(struct ifreq *ireq,struct socket *so,
struct sockaddr_in *gw,
struct proc *procp);
void bootpc_init(int update_files);
#ifdef BOOTP_DEBUG
void
bootpboot_p_sa(struct sockaddr *sa, struct sockaddr *ma)
@@ -463,7 +461,7 @@ bootpc_call(
goto gotreply; /* break two levels */
} /* while secs */
} /* forever send/receive */
} /* send/receive a number of times then return an error */
{
uint32_t addr = ntohl(sin->sin_addr.s_addr);
printf("BOOTP timeout for server %lu.%lu.%lu.%lu\n",
@@ -943,8 +941,8 @@ processOptions (unsigned char *optbuf, int optbufSize)
#define EALEN 6
void
bootpc_init(int update_files)
bool
bootpc_init(bool update_files, bool forever)
{
struct bootp_packet call;
struct bootp_packet reply;
@@ -965,7 +963,7 @@ bootpc_init(int update_files)
* If already filled in, don't touch it here
*/
if (nfs_diskless_valid)
return;
return true;
/*
* If we are to update the files create the root
@@ -991,7 +989,7 @@ bootpc_init(int update_files)
break;
if (ifp == NULL) {
printf("bootpc_init: no suitable interface\n");
return;
return false;
}
bzero(&ireq,sizeof(ireq));
sprintf(ireq.ifr_name, "%s%d", ifp->if_name,ifp->if_unit);
@@ -1000,28 +998,31 @@ bootpc_init(int update_files)
if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0,procp)) != 0) {
printf("bootpc_init: socreate, error=%d", error);
return;
return false;
}
if (bootpc_fakeup_interface(&ireq,so,procp) != 0) {
return;
soclose(so);
return false;
}
/* Get HW address */
for (ifa = ifp->if_addrlist;ifa; ifa = ifa->ifa_next)
if (ifa->ifa_addr->sa_family == AF_LINK &&
(sdl = ((struct sockaddr_dl *) ifa->ifa_addr)) &&
sdl->sdl_type == IFT_ETHER)
(sdl = ((struct sockaddr_dl *) ifa->ifa_addr)) &&
sdl->sdl_type == IFT_ETHER)
break;
if (!sdl) {
printf("bootpc: Unable to find HW address\n");
return;
soclose(so);
return false;
}
if (sdl->sdl_alen != EALEN ) {
printf("bootpc: HW address len is %d, expected value is %d\n",
sdl->sdl_alen,EALEN);
return;
soclose(so);
return false;
}
printf("bootpc hw address is ");
@@ -1036,32 +1037,39 @@ bootpc_init(int update_files)
bootpboot_p_iflist();
bootpboot_p_rtlist();
#endif
bzero((caddr_t) &call, sizeof(call));
/* bootpc part */
call.op = 1; /* BOOTREQUEST */
call.htype= 1; /* 10mb ethernet */
call.hlen=sdl->sdl_alen; /* Hardware address length */
call.hops=0;
xid++;
call.xid = txdr_unsigned(xid);
bcopy(LLADDR(sdl),&call.chaddr,sdl->sdl_alen);
while (true) {
bzero((caddr_t) &call, sizeof(call));
/* bootpc part */
call.op = 1; /* BOOTREQUEST */
call.htype= 1; /* 10mb ethernet */
call.hlen=sdl->sdl_alen; /* Hardware address length */
call.hops=0;
xid++;
call.xid = txdr_unsigned(xid);
bcopy(LLADDR(sdl),&call.chaddr,sdl->sdl_alen);
call.vend[0]=99;
call.vend[1]=130;
call.vend[2]=83;
call.vend[3]=99;
call.vend[4]=255;
call.vend[0]=99;
call.vend[1]=130;
call.vend[2]=83;
call.vend[3]=99;
call.vend[4]=255;
call.secs = 0;
call.flags = htons(0x8000); /* We need an broadcast answer */
call.secs = 0;
call.flags = htons(0x8000); /* We need an broadcast answer */
error = bootpc_call(&call,&reply,procp);
error = bootpc_call(&call,&reply,procp);
if (error) {
if (!error)
break;
printf("BOOTP call failed -- error %d", error);
return;
if (!forever) {
soclose(so);
return false;
}
}
/*
@@ -1200,4 +1208,6 @@ bootpc_init(int update_files)
error = bootpc_adjust_interface(&ireq,so,
&myaddr,&dhcp_netmask,&dhcp_gw,procp);
soclose(so);
return true;
}
+8 -2
View File
@@ -18,9 +18,12 @@
void
rtems_bsdnet_do_bootp (void)
{
bool ok;
rtems_bsdnet_semaphore_obtain ();
bootpc_init (FALSE);
ok = bootpc_init (false, true);
rtems_bsdnet_semaphore_release ();
if (!ok)
panic ("rtems_bsdnet_do_bootp: bootp failed");
}
/*
@@ -30,7 +33,10 @@ rtems_bsdnet_do_bootp (void)
void
rtems_bsdnet_do_bootp_and_rootfs (void)
{
bool ok;
rtems_bsdnet_semaphore_obtain ();
bootpc_init (TRUE);
ok = bootpc_init (true, true);
rtems_bsdnet_semaphore_release ();
if (!ok)
panic ("rtems_bsdnet_do_bootp_and_rootfs: bootp failed");
}
@@ -179,7 +179,7 @@ void domaininit (void *);
void ifinit (void *);
void ipintr (void);
void arpintr (void);
void bootpc_init(int );
bool bootpc_init(bool, bool);
int socket (int, int, int);
int ioctl (int, ioctl_command_t, ...);
+77
View File
@@ -172,6 +172,83 @@ $(PROJECT_INCLUDE)/rtems/dosfs.h: libfs/src/dosfs/dosfs.h $(PROJECT_INCLUDE)/rte
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/dosfs.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/dosfs.h
endif
$(PROJECT_INCLUDE)/rtems/rtems-rfs.h: libfs/src/rfs/rtems-rfs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems-rfs.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems-rfs.h
$(PROJECT_INCLUDE)/rtems/rtems-rfs-format.h: libfs/src/rfs/rtems-rfs-format.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems-rfs-format.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems-rfs-format.h
$(PROJECT_INCLUDE)/rtems/rtems-rfs-shell.h: libfs/src/rfs/rtems-rfs-shell.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems-rfs-shell.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems-rfs-shell.h
$(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/rfs
@: > $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-bitmaps.h: libfs/src/rfs/rtems-rfs-bitmaps.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-bitmaps.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-bitmaps.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block-pos.h: libfs/src/rfs/rtems-rfs-block-pos.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block-pos.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block-pos.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block.h: libfs/src/rfs/rtems-rfs-block.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-buffer.h: libfs/src/rfs/rtems-rfs-buffer.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-buffer.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-buffer.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-data.h: libfs/src/rfs/rtems-rfs-data.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-data.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-data.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir.h: libfs/src/rfs/rtems-rfs-dir.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir-hash.h: libfs/src/rfs/rtems-rfs-dir-hash.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir-hash.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir-hash.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file.h: libfs/src/rfs/rtems-rfs-file.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system-fwd.h: libfs/src/rfs/rtems-rfs-file-system-fwd.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system-fwd.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system-fwd.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system.h: libfs/src/rfs/rtems-rfs-file-system.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-group.h: libfs/src/rfs/rtems-rfs-group.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-group.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-group.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-inode.h: libfs/src/rfs/rtems-rfs-inode.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-inode.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-inode.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-link.h: libfs/src/rfs/rtems-rfs-link.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-link.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-link.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-mutex.h: libfs/src/rfs/rtems-rfs-mutex.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-mutex.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-mutex.h
$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-trace.h: libfs/src/rfs/rtems-rfs-trace.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-trace.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-trace.h
$(PROJECT_INCLUDE)/rtems/bdbuf.h: libblock/include/rtems/bdbuf.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bdbuf.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bdbuf.h
+1
View File
@@ -32,6 +32,7 @@ if LIBDOSFS
TMP_LIBS += ../libfs/libdosfs.a
endif
TMP_LIBS += ../libfs/libimfs.a
TMP_LIBS += ../libfs/librfs.a
TMP_LIBS += ../libmisc/libmonitor.a
TMP_LIBS += ../libmisc/libuntar.a