diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-03-08 21:39:39 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-03-08 21:39:39 +0000 |
commit | b10f6e12e00caba93e56976cdef7b6326bc3af3e (patch) | |
tree | 471a29104f216413b8f87c967a2f45c52666ac43 /c | |
parent | Added code to translate internal libio flags to POSIX style flags. (diff) | |
download | rtems-b10f6e12e00caba93e56976cdef7b6326bc3af3e.tar.bz2 |
Corrected bug where pointer to doubly linked blocks was being incorrectly
calculated.
Diffstat (limited to '')
-rw-r--r-- | c/src/exec/libfs/src/imfs/memfile.c | 36 | ||||
-rw-r--r-- | c/src/lib/libc/memfile.c | 36 | ||||
-rw-r--r-- | c/src/libfs/src/imfs/memfile.c | 36 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/memfile.c | 36 |
4 files changed, 136 insertions, 8 deletions
diff --git a/c/src/exec/libfs/src/imfs/memfile.c b/c/src/exec/libfs/src/imfs/memfile.c index eda9d6b4a1..3abaeb8f17 100644 --- a/c/src/exec/libfs/src/imfs/memfile.c +++ b/c/src/exec/libfs/src/imfs/memfile.c @@ -734,6 +734,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d at %d in %d: %*s\n", to_copy, start_offset, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ start_offset ], src, to_copy ); src += to_copy; block++; @@ -751,6 +754,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d in %d: %*s\n", to_copy, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ 0 ], src, to_copy ); src += to_copy; block++; @@ -770,6 +776,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d in %d: %*s\n", to_copy, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ 0 ], src, my_length ); my_length = 0; copied += to_copy; @@ -788,12 +797,35 @@ MEMFILE_STATIC int IMFS_memfile_write( * TRUE, then the block is allocated. Otherwise, it is an error. */ +#if 0 +block_p *IMFS_memfile_get_block_pointer_DEBUG( + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +); + block_p *IMFS_memfile_get_block_pointer( IMFS_jnode_t *the_jnode, unsigned int block, int malloc_it ) { + block_p *p; + + p = IMFS_memfile_get_block_pointer_DEBUG( the_jnode, block, malloc_it ); + printf( "(%d -> %p) ", block, p ); + return p; +} + +block_p *IMFS_memfile_get_block_pointer_DEBUG( +#else +block_p *IMFS_memfile_get_block_pointer( +#endif + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +) +{ unsigned int my_block; IMFS_memfile_t *info; unsigned int singly; @@ -880,7 +912,7 @@ fflush(stdout); p[ doubly ] = (block_p) p1; } - return (block_p *)&p[ singly ]; + return (block_p *)&p1[ singly ]; } if ( !p ) @@ -987,7 +1019,7 @@ void *memfile_alloc_block(void) } /* - * memfile_free_blocK + * memfile_free_block * * Free a block from an in-memory file. */ diff --git a/c/src/lib/libc/memfile.c b/c/src/lib/libc/memfile.c index eda9d6b4a1..3abaeb8f17 100644 --- a/c/src/lib/libc/memfile.c +++ b/c/src/lib/libc/memfile.c @@ -734,6 +734,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d at %d in %d: %*s\n", to_copy, start_offset, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ start_offset ], src, to_copy ); src += to_copy; block++; @@ -751,6 +754,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d in %d: %*s\n", to_copy, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ 0 ], src, to_copy ); src += to_copy; block++; @@ -770,6 +776,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d in %d: %*s\n", to_copy, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ 0 ], src, my_length ); my_length = 0; copied += to_copy; @@ -788,12 +797,35 @@ MEMFILE_STATIC int IMFS_memfile_write( * TRUE, then the block is allocated. Otherwise, it is an error. */ +#if 0 +block_p *IMFS_memfile_get_block_pointer_DEBUG( + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +); + block_p *IMFS_memfile_get_block_pointer( IMFS_jnode_t *the_jnode, unsigned int block, int malloc_it ) { + block_p *p; + + p = IMFS_memfile_get_block_pointer_DEBUG( the_jnode, block, malloc_it ); + printf( "(%d -> %p) ", block, p ); + return p; +} + +block_p *IMFS_memfile_get_block_pointer_DEBUG( +#else +block_p *IMFS_memfile_get_block_pointer( +#endif + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +) +{ unsigned int my_block; IMFS_memfile_t *info; unsigned int singly; @@ -880,7 +912,7 @@ fflush(stdout); p[ doubly ] = (block_p) p1; } - return (block_p *)&p[ singly ]; + return (block_p *)&p1[ singly ]; } if ( !p ) @@ -987,7 +1019,7 @@ void *memfile_alloc_block(void) } /* - * memfile_free_blocK + * memfile_free_block * * Free a block from an in-memory file. */ diff --git a/c/src/libfs/src/imfs/memfile.c b/c/src/libfs/src/imfs/memfile.c index eda9d6b4a1..3abaeb8f17 100644 --- a/c/src/libfs/src/imfs/memfile.c +++ b/c/src/libfs/src/imfs/memfile.c @@ -734,6 +734,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d at %d in %d: %*s\n", to_copy, start_offset, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ start_offset ], src, to_copy ); src += to_copy; block++; @@ -751,6 +754,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d in %d: %*s\n", to_copy, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ 0 ], src, to_copy ); src += to_copy; block++; @@ -770,6 +776,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d in %d: %*s\n", to_copy, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ 0 ], src, my_length ); my_length = 0; copied += to_copy; @@ -788,12 +797,35 @@ MEMFILE_STATIC int IMFS_memfile_write( * TRUE, then the block is allocated. Otherwise, it is an error. */ +#if 0 +block_p *IMFS_memfile_get_block_pointer_DEBUG( + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +); + block_p *IMFS_memfile_get_block_pointer( IMFS_jnode_t *the_jnode, unsigned int block, int malloc_it ) { + block_p *p; + + p = IMFS_memfile_get_block_pointer_DEBUG( the_jnode, block, malloc_it ); + printf( "(%d -> %p) ", block, p ); + return p; +} + +block_p *IMFS_memfile_get_block_pointer_DEBUG( +#else +block_p *IMFS_memfile_get_block_pointer( +#endif + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +) +{ unsigned int my_block; IMFS_memfile_t *info; unsigned int singly; @@ -880,7 +912,7 @@ fflush(stdout); p[ doubly ] = (block_p) p1; } - return (block_p *)&p[ singly ]; + return (block_p *)&p1[ singly ]; } if ( !p ) @@ -987,7 +1019,7 @@ void *memfile_alloc_block(void) } /* - * memfile_free_blocK + * memfile_free_block * * Free a block from an in-memory file. */ diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c index eda9d6b4a1..3abaeb8f17 100644 --- a/cpukit/libfs/src/imfs/memfile.c +++ b/cpukit/libfs/src/imfs/memfile.c @@ -734,6 +734,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d at %d in %d: %*s\n", to_copy, start_offset, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ start_offset ], src, to_copy ); src += to_copy; block++; @@ -751,6 +754,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d in %d: %*s\n", to_copy, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ 0 ], src, to_copy ); src += to_copy; block++; @@ -770,6 +776,9 @@ MEMFILE_STATIC int IMFS_memfile_write( assert( block_ptr ); if ( !block_ptr ) return copied; +#if 0 +printf( "write %d in %d: %*s\n", to_copy, block, to_copy, src ); +#endif memcpy( &(*block_ptr)[ 0 ], src, my_length ); my_length = 0; copied += to_copy; @@ -788,12 +797,35 @@ MEMFILE_STATIC int IMFS_memfile_write( * TRUE, then the block is allocated. Otherwise, it is an error. */ +#if 0 +block_p *IMFS_memfile_get_block_pointer_DEBUG( + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +); + block_p *IMFS_memfile_get_block_pointer( IMFS_jnode_t *the_jnode, unsigned int block, int malloc_it ) { + block_p *p; + + p = IMFS_memfile_get_block_pointer_DEBUG( the_jnode, block, malloc_it ); + printf( "(%d -> %p) ", block, p ); + return p; +} + +block_p *IMFS_memfile_get_block_pointer_DEBUG( +#else +block_p *IMFS_memfile_get_block_pointer( +#endif + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +) +{ unsigned int my_block; IMFS_memfile_t *info; unsigned int singly; @@ -880,7 +912,7 @@ fflush(stdout); p[ doubly ] = (block_p) p1; } - return (block_p *)&p[ singly ]; + return (block_p *)&p1[ singly ]; } if ( !p ) @@ -987,7 +1019,7 @@ void *memfile_alloc_block(void) } /* - * memfile_free_blocK + * memfile_free_block * * Free a block from an in-memory file. */ |