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 /testsuites/psxtests/psximfs01/init.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 '')
-rw-r--r-- | testsuites/psxtests/psximfs01/init.c | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/testsuites/psxtests/psximfs01/init.c b/testsuites/psxtests/psximfs01/init.c index c567eee10f..88796bac29 100644 --- a/testsuites/psxtests/psximfs01/init.c +++ b/testsuites/psxtests/psximfs01/init.c @@ -56,7 +56,7 @@ void write_helper(void) do { written = write( TestFd, Buffer, sizeof(Buffer) ); if ( written == -1 ) { - if ( errno == ENOSPC ) { + if ( errno == EFBIG ) { printf( "Total written = %zd\n", TotalWritten ); return; } @@ -93,22 +93,21 @@ void read_helper(void) rtems_test_exit(0); } i++; - continue; - } - /* Unsure if ENOSPC is the write error to be returned */ - if ( errno == ENOSPC && i == TotalWritten ) { - puts( "File correctly read until ENOSPC returned\n" ); - return; + } else if ( sc != 0 ) { + fprintf( + stderr, + "ERROR - at offset %d - returned %zd and error=%s\n", + i, + sc, + strerror( errno ) + ); + rtems_test_exit(0); } - fprintf( - stderr, - "ERROR - at offset %d - returned %zd and error=%s\n", - i, - sc, - strerror( errno ) - ); - rtems_test_exit(0); - } while (1); + } while ( sc > 0 ); + + if ( i == TotalWritten ) { + puts( "File correctly read until EOF returned\n" ); + } } void truncate_helper(void) @@ -143,7 +142,7 @@ void truncate_helper(void) } while (new > 0); } -void extend_helper(void) +void extend_helper(int eno) { off_t position; off_t new; @@ -164,18 +163,11 @@ void extend_helper(void) new = position; do { sc = lseek( TestFd, new, SEEK_SET ); - if( sc == -1 ) { - if( errno == ENOSPC ) { - break; - } - else { - rtems_test_assert( 0 ); - } - } + rtems_test_assert( sc == new ); rc = ftruncate( TestFd, new ); if ( rc != 0 ) { - if( errno != ENOSPC ) { + if( errno != eno ) { fprintf( stderr, "ERROR - at offset %d - returned %d and error=%s\n", @@ -218,8 +210,10 @@ rtems_task Init( { int i; void *alloc_ptr = (void *)0; - int position = 0; - int status = 0; + off_t position; + off_t new_position; + char buf [1]; + ssize_t n; puts( "\n\n*** TEST IMFS 01 ***" ); @@ -244,18 +238,21 @@ rtems_task Init( */ alloc_ptr = malloc( malloc_free_space() - 4 ); - extend_helper(); + extend_helper(ENOSPC); /* * free the allocated heap memory */ free(alloc_ptr); - extend_helper(); + extend_helper(EFBIG); position = lseek( TestFd , 0, SEEK_END ); - status = lseek( TestFd, position+2, SEEK_SET ); - rtems_test_assert( status == -1 ); - rtems_test_assert( errno == ENOSPC ); + new_position = lseek( TestFd, position + 2, SEEK_SET ); + rtems_test_assert( new_position == position + 2 ); + + n = write( TestFd, buf, sizeof(buf) ); + rtems_test_assert( n == -1 ); + rtems_test_assert( errno == EFBIG ); close_it(); unlink_it(); |