Dear PetrM,
please look at my c lines:
if ( error_code == MFS_NOT_A_DOS_DISK )
{
//printf("NOT A DOS DISK! You must format to continue.\n");
format_data.PHYSICAL_DRIVE = 0x80;
format_data.MEDIA_DESCRIPTOR = 0xf8;
format_data.BYTES_PER_SECTOR = 512;
format_data.SECTORS_PER_TRACK = 0;
format_data.NUMBER_OF_HEADS = 0;
format_data.NUMBER_OF_SECTORS = 128; //at least 7
format_data.HIDDEN_SECTORS = 0;
format_data.RESERVED_SECTORS = 1;
format_struct.FORMAT_PTR = &format_data;
format_struct.COUNT_PTR = &bad_cluster_count;
error_code=ioctl(filesystem_handle, IO_IOCTL_FORMAT_TEST ,(uint_32_ptr)&format_struct);
}
if(error_code == MFS_NO_ERROR)
{
textfile_ptr = fopen("c:myfile.txt", "a+");
write(textfile_ptr, buffer, strlen(buffer));
fclose(textfile_ptr);
my_mfs_ptr = fopen("c:myfile.txt", "r");
read(my_mfs_ptr, buffer1,strlen(buffer));
fclose(my_mfs_ptr);
}
the format procedure will be run successfully without the "textfile_ptr=fopen("c:myfile.txt", "a++"); " lines.
if i cancel these lines such as below, the format runs correct.
/*
if(error_code == MFS_NO_ERROR)
{
textfile_ptr = fopen("c:myfile.txt", "a+");
write(textfile_ptr, buffer, strlen(buffer));
fclose(textfile_ptr);
my_mfs_ptr = fopen("c:myfile.txt", "r");
read(my_mfs_ptr, buffer1,strlen(buffer));
fclose(my_mfs_ptr);
}
*/
after format successfully, i add the lines canceles before.
this time , all lines works well.
would you like to tell me how to use write() or read() to write/read a file after FORMAT?
Best regards