2011-03-15 Chris Johns <chrisj@rtems.org>

PR 1763/shell
        * libmisc/shell/hexdump-conv.c: Remove debug hacks.

        PR 1757/filesystem
        * libfs/src/rfs/rtems-rfs-block-pos.h,
        libfs/src/rfs/rtems-rfs-block.h, libfs/src/rfs/rtems-rfs-file.c,
        libfs/src/rfs/rtems-rfs-rtems-file.c: Set the file size in
        iop-size when a file is open. Fix lseek to end of file then write
        for sizes less than half the file system block size.
        * libfs/src/rfs/rtems-rfs-rtems-dev.c,
        libfs/src/rfs/rtems-rfs-rtems-dir.c,
        libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems.h:
        Fix the fstat and fchmod calls due to the change in the iop struct
        where pathinfo went away. The node_access field in pathinfo was
        overloaded.
This commit is contained in:
Chris Johns committed 2011-03-15 05:02:34 +00:00
1 parent 03b50961d8
commit d0fcd0b8a6
10 files changed
+263 -108

No files matched your search

+18
View File
@@ -1,3 +1,21 @@
2011-03-15 Chris Johns <chrisj@rtems.org>
PR 1763/shell
* libmisc/shell/hexdump-conv.c: Remove debug hacks.
PR 1757/filesystem
* libfs/src/rfs/rtems-rfs-block-pos.h,
libfs/src/rfs/rtems-rfs-block.h, libfs/src/rfs/rtems-rfs-file.c,
libfs/src/rfs/rtems-rfs-rtems-file.c: Set the file size in
iop-size when a file is open. Fix lseek to end of file then write
for sizes less than half the file system block size.
* libfs/src/rfs/rtems-rfs-rtems-dev.c,
libfs/src/rfs/rtems-rfs-rtems-dir.c,
libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems.h:
Fix the fstat and fchmod calls due to the change in the iop struct
where pathinfo went away. The node_access field in pathinfo was
overloaded.
2011-03-14 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/mouse/mouse_parser.c, libmisc/mouse/serial_mouse.c: Remove
@@ -192,6 +192,12 @@ typedef struct rtems_rfs_block_size_s
(_b)->block = 0; \
if ((_b)->boff) --(_b)->bno; } while (0)
/**
* Do the sizes match ?
*/
#define rtems_rfs_block_size_equal(_lhs, _rhs) \
(((_lhs)->count == (_rhs)->count) && ((_lhs)->offset == (_rhs)->count))
/**
* Zero a block size.
*
+27 -5
View File
@@ -162,11 +162,6 @@ typedef struct rtems_rfs_block_map_s
*/
#define rtems_rfs_block_map_size_offset(_m) ((_m)->size.offset)
/**
* Set the size offset for the map.
*/
#define rtems_rfs_block_map_set_size_offset(_m, _o) ((_m)->size.offset = (_o))
/**
* Are we at the last block in the map ?
*/
@@ -195,6 +190,33 @@ typedef struct rtems_rfs_block_map_s
*/
#define rtems_rfs_block_map_block_offset(_m) ((_m)->bpos.boff)
/**
* Set the size offset for the map. The map is tagged as dirty.
*
* @param map Pointer to the open map to set the offset in.
* @param offset The offset to set in the map's size.
*/
static inline void
rtems_rfs_block_map_set_size_offset (rtems_rfs_block_map* map,
rtems_rfs_block_off offset)
{
map->size.offset = offset;
map->dirty = true;
}
/**
* Set the map's size. The map is tagged as dirty.
*
* @param map Pointer to the open map to set the offset in.
* @param size The size to set in the map's size.
*/
static inline void
rtems_rfs_block_map_set_size (rtems_rfs_block_map* map,
rtems_rfs_block_size* size)
{
rtems_rfs_block_copy_size (&map->size, size);
map->dirty = true;
}
/**
* Open a block map. The block map data in the inode is copied into the
* map. The buffer handles are opened. The block position is set to the start
+6 -4
View File
@@ -172,8 +172,10 @@ rtems_rfs_file_close (rtems_rfs_file_system* fs,
handle->shared->mtime);
rtems_rfs_inode_set_ctime (&handle->shared->inode,
handle->shared->ctime);
handle->shared->map.size.count = handle->shared->size.count;
handle->shared->map.size.offset = handle->shared->size.offset;
if (!rtems_rfs_block_size_equal (&handle->shared->size,
&handle->shared->map.size))
rtems_rfs_block_map_set_size (&handle->shared->map,
&handle->shared->size);
}
rc = rtems_rfs_block_map_close (fs, &handle->shared->map);
@@ -420,8 +422,8 @@ rtems_rfs_file_seek (rtems_rfs_file_handle* handle,
* This means the file needs to set the file size to the pos only when a
* write occurs.
*/
if (pos <= rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (handle),
handle->shared))
if (pos < rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (handle),
handle->shared))
rtems_rfs_file_set_bpos (handle, pos);
*new_pos = pos;
+1 -1
View File
@@ -260,7 +260,7 @@ const rtems_filesystem_file_handlers_r rtems_rfs_rtems_device_handlers = {
.write_h = rtems_rfs_rtems_device_write,
.ioctl_h = rtems_rfs_rtems_device_ioctl,
.lseek_h = rtems_rfs_rtems_device_lseek,
.fstat_h = rtems_rfs_rtems_stat,
.fstat_h = rtems_rfs_rtems_fstat,
.fchmod_h = rtems_rfs_rtems_fchmod,
.ftruncate_h = rtems_rfs_rtems_device_ftruncate,
.fpathconf_h = rtems_filesystem_default_fpathconf,
+1 -1
View File
@@ -234,7 +234,7 @@ const rtems_filesystem_file_handlers_r rtems_rfs_rtems_dir_handlers = {
.write_h = rtems_filesystem_default_write,
.ioctl_h = rtems_filesystem_default_ioctl,
.lseek_h = rtems_rfs_rtems_dir_lseek,
.fstat_h = rtems_rfs_rtems_stat,
.fstat_h = rtems_rfs_rtems_fstat,
.fchmod_h = rtems_rfs_rtems_fchmod,
.ftruncate_h = rtems_filesystem_default_ftruncate,
.fpathconf_h = rtems_filesystem_default_fpathconf,
+73 -12
View File
@@ -70,6 +70,7 @@ rtems_rfs_rtems_file_open (rtems_libio_t* iop,
if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FILE_OPEN))
printf("rtems-rfs: file-open: handle:%p\n", file);
iop->size = rtems_rfs_file_size (file);
iop->pathinfo.node_access = file;
rtems_rfs_rtems_unlock (fs);
@@ -111,7 +112,7 @@ rtems_rfs_rtems_file_close (rtems_libio_t* iop)
* @param count
* @return int
*/
ssize_t
static ssize_t
rtems_rfs_rtems_file_read (rtems_libio_t* iop,
void* buffer,
size_t count)
@@ -176,7 +177,7 @@ rtems_rfs_rtems_file_read (rtems_libio_t* iop,
* @param count
* @return ssize_t
*/
ssize_t
static ssize_t
rtems_rfs_rtems_file_write (rtems_libio_t* iop,
const void* buffer,
size_t count)
@@ -195,21 +196,25 @@ rtems_rfs_rtems_file_write (rtems_libio_t* iop,
pos = iop->offset;
/*
* If the iop position is past the physical end of the file we need to set the
* file size to the new length before writing.
* If the iop position is past the physical end of the file we need to set
* the file size to the new length before writing. If the position equals the
* size of file we are still past the end of the file as positions number
* from 0. For a specific position we need a file that has a length of one
* more.
*/
if (pos > rtems_rfs_file_size (file))
if (pos >= rtems_rfs_file_size (file))
{
rc = rtems_rfs_file_set_size (file, pos);
rc = rtems_rfs_file_set_size (file, pos + 1);
if (rc)
{
rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
return rtems_rfs_rtems_error ("file-write: write extend", rc);
}
rtems_rfs_file_set_bpos (file, pos);
}
rtems_rfs_file_set_bpos (file, pos);
while (count)
{
size_t size = count;
@@ -255,7 +260,7 @@ rtems_rfs_rtems_file_write (rtems_libio_t* iop,
* @param buffer
*/
int
static int
rtems_rfs_rtems_file_ioctl (rtems_libio_t* iop, uint32_t command, void* buffer)
{
return 0;
@@ -269,7 +274,7 @@ rtems_rfs_rtems_file_ioctl (rtems_libio_t* iop, uint32_t command, void* buffer)
* @param whence
* @return rtems_off64_t
*/
rtems_off64_t
static rtems_off64_t
rtems_rfs_rtems_file_lseek (rtems_libio_t* iop,
rtems_off64_t offset,
int whence)
@@ -297,6 +302,62 @@ rtems_rfs_rtems_file_lseek (rtems_libio_t* iop,
return iop->offset;
}
/**
* Stat the file.
*
* @param iop
* @param buf
* @return int
*/
static int
rtems_rfs_rtems_file_fstat (rtems_filesystem_location_info_t* pathloc,
struct stat* buf)
{
rtems_rfs_file_handle* file = pathloc->node_access;
int rc;
if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_STAT))
printf ("rtems-rfs: file-fstat: handle:%p\n", file);
rtems_rfs_rtems_lock (rtems_rfs_file_fs (file));
rc = rtems_rfs_rtems_stat_inode (rtems_rfs_file_fs (file),
rtems_rfs_file_inode (file),
buf);
rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
return rc;
}
/**
* File change mode routine.
*
* @param iop
* @param mode
* @return int
*/
static int
rtems_rfs_rtems_file_fchmod (rtems_filesystem_location_info_t* pathloc,
mode_t mode)
{
rtems_rfs_file_handle* file = pathloc->node_access;
int rc;
if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FCHMOD))
printf ("rtems-rfs: file-fchmod: handle:%p\n", file);
rtems_rfs_rtems_lock (rtems_rfs_file_fs (file));
rc = rtems_rfs_rtems_fchmod_inode (rtems_rfs_file_fs (file),
rtems_rfs_file_inode (file),
mode);
rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
return rc;
}
/**
* This routine processes the ftruncate() system call.
*
@@ -304,7 +365,7 @@ rtems_rfs_rtems_file_lseek (rtems_libio_t* iop,
* @param length
* @return int
*/
int
static int
rtems_rfs_rtems_file_ftruncate (rtems_libio_t* iop,
rtems_off64_t length)
{
@@ -338,8 +399,8 @@ const rtems_filesystem_file_handlers_r rtems_rfs_rtems_file_handlers = {
.write_h = rtems_rfs_rtems_file_write,
.ioctl_h = rtems_rfs_rtems_file_ioctl,
.lseek_h = rtems_rfs_rtems_file_lseek,
.fstat_h = rtems_rfs_rtems_stat,
.fchmod_h = rtems_rfs_rtems_fchmod,
.fstat_h = rtems_rfs_rtems_file_fstat,
.fchmod_h = rtems_rfs_rtems_file_fchmod,
.ftruncate_h = rtems_rfs_rtems_file_ftruncate,
.fpathconf_h = rtems_filesystem_default_fpathconf,
.fsync_h = rtems_rfs_rtems_fdatasync,
File diff suppressed because it is too large. Load diff
+30 -4
View File
@@ -274,20 +274,46 @@ extern const rtems_filesystem_file_handlers_r rtems_rfs_rtems_file_handlers;
/**
* The following routine does a stat on a node.
*
* @param pathloc
* @param fs The file system data.
* @param inode The inode to stat held in memory.
* @param buf The stat buffer to fill.
* @return int The result code.
*/
int rtems_rfs_rtems_stat_inode (rtems_rfs_file_system* fs,
rtems_rfs_inode_handle* inode,
struct stat* buf);
/**
* The following routine does a stat on a node.
*
* @param iop
* @param buf
* @return int
*/
int rtems_rfs_rtems_stat (rtems_filesystem_location_info_t* loc, struct stat* buf);
int rtems_rfs_rtems_fstat (rtems_filesystem_location_info_t* pathloc,
struct stat* buf);
/**
* File change mode routine changes an inode.
*
* @param fs The file system data.
* @param inode The inode to change held in memory.
* @param buf The new mode.
* @return int The result code.
*/
int rtems_rfs_rtems_fchmod_inode (rtems_rfs_file_system* fs,
rtems_rfs_inode_handle* inode,
mode_t mode);
/**
* File change mode routine.
*
* @param pathloc
* @param iop
* @param mode
* @return int
*/
int rtems_rfs_rtems_fchmod (rtems_filesystem_location_info_t* loc, mode_t mode);
int rtems_rfs_rtems_fchmod (rtems_filesystem_location_info_t* pathloc,
mode_t mode);
/**
* Routine to remove a node from the RFS file system.
-2
View File
@@ -63,8 +63,6 @@ conv_c(rtems_shell_hexdump_globals* globals, PR *pr, u_char *p, size_t bufsize)
int converr, pad, width;
char peekbuf[MB_LEN_MAX];
printf("MB_LEN_MAX=%i\n", MB_LEN_MAX);
return;
if (pr->mbleft > 0) {
str = "**";
pr->mbleft--;