This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: JFFS2 (Again!!)


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]