How to write data to a file outside sandbox

In the adef file, I have added the following:


requires:
{
file:
{

    /home/root/data.txt /tmp/

}

}


In the source code, I tried the following:

[code]#include “legato.h”
FILE* fh;
COMPONENT_INIT
{

FILE *f;

fh = fopen("/tmp/data.txt", "r");

//read line by line
const size_t line_size = 300;
char* line = malloc(line_size);
while (fgets(line, line_size, fh) != NULL)  {
 printf(line);
}
free(line);
fclose(fh);




f = fopen("/tmp/data.txt", "w");
LE_INFO("jyi here3. f=%d",(int)f);
	if (f!=NULL)
	{


		fprintf(f, "\nabcd \r\n");

		 fclose(f);
	}

}
[/code]

It is OK to read the data from a file outside sandbox.
However it is not OK to open the file pointer with “w”.
I am using legato version 16.01.4 on AR75xx.

Any idea?