Hi,

Problem statement:
I have to retain a value....Hence i am storing the same to flash using fwrite and fread operations(Os Linux).

Observarion:
1. As soon as the data is written(fwrite) i am reading(fread) the value.
I am able to read the value and it is intact.
2. Problem begins when i have switched the Hardware OFF and once every thing is set. Now i do an fopen() which suceeds but fread() fails all the time with error "ENOENT"
3. I am writing to jffs1..........Strange is this stuff used to work some time back now it doesn't.....What could be wrong here?


Following is the code: I am really frustrated with this


Code:
static Bool mWritetoFlashFreqInt(void)
{
	FILE *fptr;
	Bool Sucess = FALSE;
	memset(mStoredFreqIntervalDetails,'\0',(MAX_URISIZE));
	str_strcpy(mStoredFreqIntervalDetails,mHtvClnSvcDirPath);
	str_strcat(mStoredFreqIntervalDetails,"/htvclnsvc/");
	mkdir(mStoredFreqIntervalDetails,(S_IROTH | S_IWOTH | S_IXOTH));
    str_strcat(mStoredFreqIntervalDetails,STOREPATH_FREQINTERVAL);		 
	
	//unlink(mStoredFreqIntervalDetails);
	fptr = fopen(mStoredFreqIntervalDetails,"w");
	if(fptr)
	{
		size = fwrite(&sAutoUpgFreqInterval, sizeof(tsAutoUpgFreqInterval), 1, fptr);
		fclose(fptr);
	}
	else
	{
		Sucess = FALSE;
	}	
	
	mReadFlashFreqInt();
	return Sucess;
}


static Bool mReadFlashFreqInt(void)
{
	FILE *fptr;
	Bool Sucess = FALSE;
	int i;

	memset(mStoredFreqIntervalDetails,'\0',(MAX_URISIZE));
	str_strcpy(mStoredFreqIntervalDetails,mHtvClnSvcDirPath);
	str_strcat(mStoredFreqIntervalDetails,"/htvclnsvc/");
    str_strcat(mStoredFreqIntervalDetails,STOREPATH_FREQINTERVAL);		 
	fptr = fopen(mStoredFreqIntervalDetails,"r");
	
	if(fptr)
	{
		size = fread(&sAutoUpgFreqInterval, sizeof(tsAutoUpgFreqInterval), 1, fptr);			
		if(size == 1)
		{
			Sucess = TRUE;
		}			
		fclose(fptr);
	}
	else
	{
		Sucess = FALSE;
	}	
	return Sucess;
}
Thanks in advance