diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-05-07 16:30:37 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-05-11 13:58:43 +0200 |
commit | 30d412469c930fe4150ad2b9a321eea2747ec6f4 (patch) | |
tree | d91c4bfaa8e968a6da87ba9b5860502758d4a26f /cpukit/libfs/src/imfs/memfile.c | |
parent | pc386 - Clock driver compiles again plus clean up (diff) | |
download | rtems-30d412469c930fe4150ad2b9a321eea2747ec6f4.tar.bz2 |
Filesystem: PR1398: Fix lseek() mechanic
According to POSIX the lseek() function shall not, by itself, extend the
size of a file.
Remove the size field of rtems_libio_t. A file has only one size but
may have multiple open file descriptors. Thus a file size field in the
file descriptor may lead to inconsistencies.
New default handlers rtems_filesystem_default_lseek_file() and
rtems_filesystem_default_lseek_directory().
Diffstat (limited to 'cpukit/libfs/src/imfs/memfile.c')
-rw-r--r-- | cpukit/libfs/src/imfs/memfile.c | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c index d2cff01517..64679df037 100644 --- a/cpukit/libfs/src/imfs/memfile.c +++ b/cpukit/libfs/src/imfs/memfile.c @@ -109,7 +109,6 @@ int memfile_open( if (iop->flags & LIBIO_FLAGS_APPEND) iop->offset = the_jnode->info.file.size; - iop->size = the_jnode->info.file.size; return 0; } @@ -148,7 +147,6 @@ ssize_t memfile_write( the_jnode = iop->pathinfo.node_access; status = IMFS_memfile_write( the_jnode, iop->offset, buffer, count ); - iop->size = the_jnode->info.file.size; return status; } @@ -170,34 +168,6 @@ int memfile_ioctl( } /* - * memfile_lseek - * - * This routine processes the lseek() system call. - */ -off_t memfile_lseek( - rtems_libio_t *iop, - off_t offset, - int whence -) -{ - IMFS_jnode_t *the_jnode; - - the_jnode = iop->pathinfo.node_access; - - if (IMFS_type( the_jnode ) == IMFS_LINEAR_FILE) { - if (iop->offset > the_jnode->info.linearfile.size) - iop->offset = the_jnode->info.linearfile.size; - } - else { /* Must be a block file (IMFS_MEMORY_FILE). */ - if (IMFS_memfile_extend( the_jnode, iop->offset )) - rtems_set_errno_and_return_minus_one( ENOSPC ); - - iop->size = the_jnode->info.file.size; - } - return iop->offset; -} - -/* * memfile_stat * * This IMFS_stat() can be used. @@ -232,7 +202,6 @@ int memfile_ftruncate( * future use and just set the length. */ the_jnode->info.file.size = length; - iop->size = the_jnode->info.file.size; IMFS_update_atime( the_jnode ); @@ -265,7 +234,7 @@ MEMFILE_STATIC int IMFS_memfile_extend( * Verify new file size is supported */ if ( new_length >= IMFS_MEMFILE_MAXIMUM_SIZE ) - rtems_set_errno_and_return_minus_one( EINVAL ); + rtems_set_errno_and_return_minus_one( EFBIG ); /* * Verify new file size is actually larger than current size @@ -654,7 +623,7 @@ MEMFILE_STATIC ssize_t IMFS_memfile_write( if ( last_byte > the_jnode->info.file.size ) { status = IMFS_memfile_extend( the_jnode, last_byte ); if ( status ) - rtems_set_errno_and_return_minus_one( ENOSPC ); + return status; } copied = 0; |