This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Re: JFFS2 (Again!!)
- From: knud dot woehler at microplex dot de
- To: Andrew Lunn <andrew at lunn dot ch>
- Cc: ecos-discuss at sources dot redhat dot com
- Date: Fri, 25 Feb 2005 15:06:25 +0100
- Subject: Re: [ECOS] Re: JFFS2 (Again!!)
- Organization: MICROPLEX Printware AG
- References: <421EE722.4070808@microplex.de> <20050225094655.GM10405@lunn.ch>
Hi
if I start the test I have this output:
This is a test.
<5>Eep. Child "TestFile.txt" (ino #11) of dir ino #1 doesn't exist!
<4>jffs2_do_read_inode() on nonexistent ino 11
jffs2_read_inode() failed
This is a test.
Knud
#include <cyg/infra/diag.h>
#include <pkgconf/fs_jffs2.h>
#include <stdio.h>
void do_file()
{
int err;
FILE *TestFile;
char Text[255];
// mount the filesystem
err = mount( CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1, "/", "jffs2" );
if( err < 0 )
{
diag_printf("mount jffs2: %d %s\n", err, err<0?strerror(errno):"");
return;
}
// create a new file
TestFile = fopen("TestFile.txt","w");
if(TestFile == 0)
{
diag_printf("error: fopen\n");
return;
}
fputs("This is a test.", TestFile);
fclose(TestFile);
// read the file
TestFile = fopen("TestFile.txt","r");
if(TestFile == 0)
{
diag_printf("error: fopen\n");
return;
}
if( fgets( Text, sizeof(Text), TestFile ) == 0)
diag_printf("error: fgets\n");
else
diag_printf(Text);
fclose(TestFile);
// truncate the file
TestFile = fopen("TestFile.txt","w");
fclose(TestFile);
// unmount the filesystem
err = umount( "/" );
if( err < 0 )
{
diag_printf("umount jffs2: %d %s\n", err, err<0?strerror(errno):"");
return;
}
}
int main( int argc, char **argv )
{
// ok
do_file();
// not ok
do_file();
}
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss