Exemplo n.º 1
0
//---------------------------------------------------------------------------
int part_connect(mass_dev* dev)
{
	part_table partTable;
	unsigned int count = 0, i;
	XPRINTF("USBHDFSD: part_connect devId %i \n", dev->devId);

	if (part_getPartitionTable(dev, &partTable) < 0)
		return -1;

	for ( i = 0; i < 4; i++)
	{
		if(
			partTable.record[ i ].sid == 6    ||
			partTable.record[ i ].sid == 4    ||
			partTable.record[ i ].sid == 1    ||  // fat 16, fat 12
			partTable.record[ i ].sid == 0x0B ||
			partTable.record[ i ].sid == 0x0C ||  // fat 32
			partTable.record[ i ].sid == 0x0E)    // fat 16 LBA
		{
			XPRINTF("USBHDFSD: mount partition %d\n", i);
			if (fat_mount(dev, partTable.record[i].start, partTable.record[i].count) >= 0)
				count++;
		}
	}

	if ( count == 0 )
	{	// no partition table detected
		// try to use "floppy" option
		XPRINTF("USBHDFSD: mount drive\n");
		if (fat_mount(dev, 0, dev->maxLBA) < 0)
			return -1;
	}

	return 0;
}
Exemplo n.º 2
0
int main(int argc, char *argv[]) {
  int p = 0;
  int rerrno = 0;
  FILE *fp;
  int len;
  uint8_t *d;
//   int v;
  printf("Running FAT tests...\n\n");
  printf("[%4d] start block device emulation...", p++);
  printf("   %d\n", block_init());
  
  printf("[%4d] mount filesystem, FAT32", p++);
  printf("   %d\n", fat_mount(0, PART_TYPE_FAT32));

//   p = test_open(p);

  int fd;
  
//   printf("Open\n");
//   fd = fat_open("/newfile.txt", O_WRONLY | O_CREAT, 0777, &rerrno);
//   printf("fd = %d, errno=%d (%s)\n", fd, rerrno, strerror(rerrno));
//   if(fd > -1) {
//     printf("Write\n");
//     fat_write(fd, "Hello World\n", 12, &rerrno);
//     printf("errno=%d (%s)\n", rerrno, strerror(rerrno));
//     printf("Close\n");
//     fat_close(fd, &rerrno);
//     printf("errno=%d (%s)\n", rerrno, strerror(rerrno));
//   }
  
  printf("Open\n");
  fd = fat_open("/newfile.png", O_WRONLY | O_CREAT, 0777, &rerrno);
  printf("fd = %d, errno=%d (%s)\n", fd, rerrno, strerror(rerrno));
  if(fd > -1) {
    fp = fopen("/home/nathan/gowrong_draft1.png", "rb");
    fseek(fp, 0, SEEK_END);
    len = ftell(fp);
    d = malloc(len);
    fseek(fp, 0, SEEK_SET);
    fread(d, 1, len, fp);
    fclose(fp);
    printf("Write PNG\n");
    fat_write(fd, d, len, &rerrno);
    printf("errno=%d (%s)\n", rerrno, strerror(rerrno));
    printf("Close\n");
    fat_close(fd, &rerrno);
    printf("errno=%d (%s)\n", rerrno, strerror(rerrno));
  }
  
  block_pc_snapshot_all("writenfs.img");
  exit(0);
}
Exemplo n.º 3
0
int main()
{
	int res;
	Volume *v;
	nls_init();
	res = fat_mount("../img/floppy.img", &v);
	printf("Mount: %i (%s)\n", res, strerror(-res));
	//for (res = 0; res < 100000; res++)
	//unlink_test(v, "\\grub\\menu.lst");
	//rmdir_test(v, "\\faccio un provolone");
	rename_test(v, "\\grub\\rentest", "\\puppo");
		//read_test(v, "\\grub\\menu.lst");
		//lfnfind_test(v, "\\grub", "*.*");
		//create_test(v, "\\faccio una prova.txt");
		//mkdir_test(v, "\\faccio un provolone");
		//dosfind_test(v, "\\autoexec.bat\\*.*");
	res = fat_unmount(v);
	printf("Unmount: %i (%s)\n", res, strerror(-res));
	#if 0
	//res = fat_open(v, "\\autoexec.bat", NULL, O_RDWR, 0, &c);
	res = fat_open(v, "\\faccio una prova.txt", NULL, O_RDWR | O_CREAT | O_EXCL, 0, &c);
	printf("Open: %i (%s)\n", res, strerror(-res));
	#if 1 /* write */
	res = fat_lseek(c, 0, SEEK_SET);
	printf("Seek: %i (%s)\n", res, strerror(-res));
	for (k = 0; k < sizeof(buf); k++) buf[k] = (k % 10) + '0';
	res = fat_write(c, buf, sizeof(buf));
	printf("Write: %i (%s)\n", res, strerror(-res));
	#elif 0 /* read */
	res = fat_read(c, buf, sizeof(buf));
	printf("Read: %i (%s)\n", res, strerror(-res));
	for (k = 0; k < res; k++) fputc(buf[k], stdout);
	#elif 0 /* truncate */
	res = fat_ftruncate(c, 65432);
	printf("Truncate: %i (%s)\n", res, strerror(-res));
	#endif
	res = fat_close(c);
	printf("Close: %i (%s)\n", res, strerror(-res));
	res = fat_unmount(v);
	printf("Unmount: %i (%s)\n", res, strerror(-res));
	#endif
	return 0;
}
Exemplo n.º 4
0
int main(int argc, char *argv[]) {
    int p = 0;
    int rerrno = 0;
    int result;
    int parts;
    uint8_t temp[512];
    struct partition *part_list;

    if(argc < 2) {
        printf("Please specify a disk image to work on.\n");
        exit(-2);
    }

    block_pc_set_image_name(argv[1]);
//   int v;
    printf("Running FAT tests...\n\n");
    printf("[%4d] start block device emulation...", p++);
    printf("   %d\n", block_init());

    printf("[%4d] mount filesystem, FAT32", p++);

    result = fat_mount(0, block_get_volume_size(), PART_TYPE_FAT32);

    printf("   %d\n", result);

    if(result != 0) {
        // mounting failed.
        // try listing the partitions
        block_read(0, temp);
        parts = read_partition_table(temp, block_get_volume_size(), &part_list);

        printf("Found %d valid partitions.\n", parts);

        if(parts > 0) {
            result = fat_mount(part_list[0].start, part_list[0].length, part_list[0].type);
        }
        if(result != 0) {
            printf("Mount failed\n");
            exit(-2);
        }

    }

    printf("Part type = %02X\n", fatfs.type);
    //   p = test_open(p);

    int fd;
    int i;
    char block_o_data[1024];
    uint32_t temp_uint = 0xDEADBEEF;
    memset(block_o_data, 0x42, 1024);
//   printf("Open\n");
//   fd = fat_open("/newfile.txt", O_WRONLY | O_CREAT, 0777, &rerrno);
//   printf("fd = %d, errno=%d (%s)\n", fd, rerrno, strerror(rerrno));
//   if(fd > -1) {
//     printf("Write\n");
//     fat_write(fd, "Hello World\n", 12, &rerrno);
//     printf("errno=%d (%s)\n", rerrno, strerror(rerrno));
//     printf("Close\n");
//     fat_close(fd, &rerrno);
//     printf("errno=%d (%s)\n", rerrno, strerror(rerrno));
//   }

//   printf("Open\n");
//   fd = fat_open("/newfile.png", O_WRONLY | O_CREAT, 0777, &rerrno);
//   printf("fd = %d, errno=%d (%s)\n", fd, rerrno, strerror(rerrno));
//   if(fd > -1) {
//     fp = fopen("gowrong_draft1.png", "rb");
//     fseek(fp, 0, SEEK_END);
//     len = ftell(fp);
//     d = malloc(len);
//     fseek(fp, 0, SEEK_SET);
//     fread(d, 1, len, fp);
//     fclose(fp);
//     printf("Write PNG\n");
//     fat_write(fd, d, len, &rerrno);
//     printf("errno=%d (%s)\n", rerrno, strerror(rerrno));
//     printf("Close\n");
//     fat_close(fd, &rerrno);
//     printf("errno=%d (%s)\n", rerrno, strerror(rerrno));
//   }

    printf("errno = (%d) %s\n", rerrno, strerror(rerrno));
    result = fat_mkdir("/foo", 0777, &rerrno);
    printf("mkdir /foo: %d (%d) %s\n", result, rerrno, strerror(rerrno));

    result = fat_mkdir("/foo/bar", 0777, &rerrno);
    printf("mkdir /foo/bar: %d (%d) %s\n", result, rerrno, strerror(rerrno));

    result = fat_mkdir("/web", 0777, &rerrno);
    printf("mkdir /web: %d (%d) %s\n", result, rerrno, strerror(rerrno));

    if((fd = fat_open("/foo/bar/file.html", O_WRONLY | O_CREAT, 0777, &rerrno)) == -1) {
        printf("Couldn't open file (%d) %s\n", rerrno, strerror(rerrno));
        exit(-1);
    }

    for(i=0; i<20; i++) {
//     printf("fd.cluster = %d\n", file_num[fd].full_first_cluster);
        if(fat_write(fd, block_o_data, 1024, &rerrno) == -1) {
            printf("Error writing to new file (%d) %s\n", rerrno, strerror(rerrno));
        }
    }

    if(fat_close(fd, &rerrno)) {
        printf("Error closing file (%d) %s\n", rerrno, strerror(rerrno));
    }

    printf("Open directory\n");
    if((fd = fat_open("/foo/bar", O_RDONLY, 0777, &rerrno)) < 0) {
        printf("Failed to open directory (%d) %s\n", rerrno, strerror(rerrno));
        exit(-1);
    }
    struct dirent de;

    while(!fat_get_next_dirent(fd, &de, &rerrno)) {
        printf("%s\n", de.d_name);
    }
    printf("Directory read failed. (%d) %s\n", rerrno, strerror(rerrno));

    if(fat_close(fd, &rerrno)) {
        printf("Error closing directory, (%d) %s\n", rerrno, strerror(rerrno));
    }

    if(fat_open("/web/version.txt", O_RDONLY, 0777, &rerrno) < 0) {
        printf("Error opening missing file (%d) %s\n", rerrno, strerror(rerrno));
    } else {
        printf("success! opened non existent file for reading.\n");
    }

    printf("Trying to write a big file.\n");

    if((fd = fat_open("big_file.bin", O_WRONLY | O_CREAT, 0777, &rerrno))) {
        printf("Error opening a file for writing.\n");
    }

    for(i=0; i<1024 * 1024 * 10; i++) {
        if((i & 0xfff) == 0)
            printf("Written %d bytes\n", i * 4);
        fat_write(fd, &temp_uint, 4, &rerrno);
    }
    fat_close(fd, &rerrno);

//   result = fat_rmdir("/foo/bar", &rerrno);
//   printf("rmdir /foo/bar: %d (%d) %s\n", result, rerrno, strerror(rerrno));
//
//   result = fat_rmdir("/foo", &rerrno);
//   printf("rmdir /foo: %d (%d) %s\n", result, rerrno, strerror(rerrno));

    block_pc_snapshot_all("writenfs.img");
    exit(0);
}
Exemplo n.º 5
0
int fat_request(DWORD Function, void *Params)
{
  int Res;
  switch (Function)
  {
    case FD32_READ:
    {
      fd32_read_t *X = (fd32_read_t *) Params;
      tFile       *F;
      if (X->Size < sizeof(fd32_read_t)) return EINVAL;
      F = (tFile *) X->DeviceId;
      if (F->FilSig != FAT_FILSIG) return EBADF;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(F->V)) < 0) return Res;
      #endif
      return fat_read(F, X->Buffer, X->BufferBytes);
    }
    case FD32_WRITE:
    {
      #ifdef FATWRITE
      fd32_write_t *X = (fd32_write_t *) Params;
      tFile        *F;
      if (X->Size < sizeof(fd32_write_t)) return EINVAL;
      F = (tFile *) X->DeviceId;
      if (F->FilSig != FAT_FILSIG) return EBADF;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(F->V)) < 0) return Res;
      #endif
      return fat_write(F, X->Buffer, X->BufferBytes);
      #else
      return EROFS;
      #endif
    }
    case FD32_LSEEK:
    {
      fd32_lseek_t *X = (fd32_lseek_t *) Params;
      if (X->Size < sizeof(fd32_lseek_t)) return EINVAL;
      if (((tFile *) X->DeviceId)->FilSig != FAT_FILSIG) return EBADF;
      return fat_lseek((tFile *) X->DeviceId, &X->Offset, X->Origin);
    }
    case FD32_OPENFILE:
    {
      fd32_openfile_t *X = (fd32_openfile_t *) Params;
      tVolume         *V;
      if (X->Size < sizeof(fd32_openfile_t)) return EINVAL;
      V = (tVolume *) X->DeviceId;
      if (V->VolSig != FAT_VOLSIG) return ENODEV;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(V)) < 0) return Res;
      #endif
      return fat_open(V, X->FileName, X->Mode, X->Attr, X->AliasHint, (tFile **) &X->FileId);
    }
    case FD32_CLOSE:
    {
      fd32_close_t *X = (fd32_close_t *) Params;
      tFile        *F;
      if (X->Size < sizeof(fd32_close_t)) return EINVAL;
      F = (tFile *) X->DeviceId;
      if (F->FilSig != FAT_FILSIG) return EBADF;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(F->V)) < 0) return Res;
      #endif
      return fat_close(F);
    }
    case FD32_READDIR:
    {
      fd32_readdir_t *X = (fd32_readdir_t *) Params;
      tFile          *F;
      if (X->Size < sizeof(fd32_readdir_t)) return EINVAL;
      F = (tFile *) X->DirId;
      if (F->FilSig != FAT_FILSIG) return EBADF;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(F->V)) < 0) return Res;
      #endif
      return fat_readdir(F, (fd32_fs_lfnfind_t *) X->Entry);
    }
    case FD32_FFLUSH:
    {
      #ifdef FATWRITE
      fd32_fflush_t *X = (fd32_fflush_t *) Params;
      tFile         *F;
      if (X->Size < sizeof(fd32_fflush_t)) return EINVAL;
      F = (tFile *) X->DeviceId;
      if (F->FilSig != FAT_FILSIG) return EBADF;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(F->V)) < 0) return Res;
      #endif
      return fat_fflush(F);
      #else
      return EROFS;
      #endif
    }
    case FD32_OPEN:
    {
      fd32_open_t *X = (fd32_open_t *) Params;
      if (X->Size < sizeof(fd32_open_t)) return EINVAL;
      if (((tFile *) X->DeviceId)->FilSig != FAT_FILSIG) return EBADF;
      return ++((tFile *) X->DeviceId)->References;
    }
    case FD32_GETATTR:
    {
      fd32_getattr_t *X = (fd32_getattr_t *) Params;
      if (X->Size < sizeof(fd32_getattr_t)) return EINVAL;
      if (((tFile *) X->FileId)->FilSig != FAT_FILSIG) return EBADF;
      return fat_get_attr((tFile *) X->FileId, (fd32_fs_attr_t *) X->Attr);
    }
    case FD32_SETATTR:
    {
      #ifdef FATWRITE
      fd32_setattr_t *X = (fd32_setattr_t *) Params;
      tFile          *F;
      if (X->Size < sizeof(fd32_setattr_t)) return EINVAL;
      F = (tFile *) X->FileId;
      if (F->FilSig != FAT_FILSIG) return EBADF;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(F->V)) < 0) return Res;
      #endif
      return fat_set_attr(F, (fd32_fs_attr_t *) X->Attr);
      #else
      return EROFS;
      #endif
    }
    case FD32_REOPENDIR:
    {
      fd32_reopendir_t *X = (fd32_reopendir_t *) Params;
      tVolume          *V;
      if (X->Size < sizeof(fd32_reopendir_t)) return EINVAL;
      V = (tVolume *) X->DeviceId;
      if (V->VolSig != FAT_VOLSIG) return ENODEV;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(V)) < 0) return Res;
      #endif
      return fat_reopendir(V, (tFindRes *) X->DtaReserved, (tFile **) &X->DirId);
    }
    case FD32_UNLINK:
    {
      #ifdef FATWRITE
      fd32_unlink_t *X = (fd32_unlink_t *) Params;
      tVolume       *V;
      if (X->Size < sizeof(fd32_unlink_t)) return EINVAL;
      V = (tVolume *) X->DeviceId;
      if (V->VolSig != FAT_VOLSIG) return ENODEV;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(V)) < 0) return Res;
      #endif
      return fat_unlink(V, X->FileName, X->Flags);
      #else
      return EROFS;
      #endif
    }
    case FD32_RENAME:
    {
      #ifdef FATWRITE
      fd32_rename_t *X = (fd32_rename_t *) Params;
      tVolume       *V;
      if (X->Size < sizeof(fd32_rename_t)) return EINVAL;
      V = (tVolume *) X->DeviceId;
      if (V->VolSig != FAT_VOLSIG) return ENODEV;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(V)) < 0) return Res;
      #endif
      return fat_rename(V, X->OldName, X->NewName);
      #else
      return EROFS;
      #endif
    }
    case FD32_MKDIR:
    {
      #ifdef FATWRITE
      fd32_mkdir_t *X = (fd32_mkdir_t *) Params;
      tVolume      *V;
      if (X->Size < sizeof(fd32_mkdir_t)) return EINVAL;
      V = (tVolume *) X->DeviceId;
      if (V->VolSig != FAT_VOLSIG) return ENODEV;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(V)) < 0) return Res;
      #endif
      return fat_mkdir(V, X->DirName);
      #else
      return FD32_EROFS;
      #endif
    }
    case FD32_RMDIR:
    {
      #ifdef FATWRITE
      fd32_rmdir_t *X = (fd32_rmdir_t *) Params;
      tVolume      *V;
      if (X->Size < sizeof(fd32_rmdir_t)) return EINVAL;
      V = (tVolume *) X->DeviceId;
      if (V->VolSig != FAT_VOLSIG) return ENODEV;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(V)) < 0) return Res;
      #endif
      return fat_rmdir(V, X->DirName);
      #else
      return FD32_EROFS;
      #endif
    }
    case FD32_MOUNT:
    {
      fd32_mount_t *X = (fd32_mount_t *) Params;
      if (X->Size < sizeof(fd32_mount_t)) return EINVAL;
      return fat_mount(X->hDev, (tVolume **) &X->FsDev);
    }
    case FD32_UNMOUNT:
    {
      fd32_unmount_t *X = (fd32_unmount_t *) Params;
      tVolume        *V;
      if (X->Size < sizeof(fd32_unmount_t)) return EINVAL;
      V = (tVolume *) X->DeviceId;
      if (V->VolSig != FAT_VOLSIG) return ENODEV;
      #ifdef FATREMOVABLE
      if ((Res = fat_mediachange(V)) < 0) return Res;
      #endif
      return fat_unmount(V);
    }
    case FD32_PARTCHECK:
    {
      fd32_partcheck_t *X = (fd32_partcheck_t *) Params;
      if (X->Size < sizeof(fd32_partcheck_t)) return EINVAL;
      return fat_partcheck(X->PartId);
    }
    case FD32_GETFSINFO:
    {
      fd32_getfsinfo_t *X = (fd32_getfsinfo_t *) Params;
      if (X->Size < sizeof(fd32_getfsinfo_t)) return EINVAL;
      return fat_get_fsinfo((fd32_fs_info_t *) X->FSInfo);
    }
    case FD32_GETFSFREE:
      return fat_get_fsfree((fd32_getfsfree_t *) Params);
  }
  return EINVAL;
}
void IBN_FileAccess (u8 nParamsGet_u8,u8 CMD_u8,u32 Param_u32)
{
	s32 FileID_s32;
	s32 Ret_s32;

//	testtt[1000] = 4;

	if (0 == nParamsGet_u8)
	{
		CI_LocalPrintf ("File access\r\n");
		CI_LocalPrintf (" 0 = Set lun 0\r\n");
		CI_LocalPrintf (" 1 = Mount\r\n");
    CI_LocalPrintf (" 2 = Show free space\r\n");
    CI_LocalPrintf ("11 = Set BUSY Lun 0\r\n");
    CI_LocalPrintf ("12 = Update contend lun X\r\n");
    CI_LocalPrintf ("16 = Copy test.txt to test1.txt\n\r");
    CI_LocalPrintf ("17 = Format LUN X\n\r");
		return;
	}

	switch (CMD_u8)
	{
   	   case 0 :
			fs_g_nav.u8_lun = 0;   // On chip RAM
			break;
#if LUN_2 == ENABLE
   	   case 1 :
			if (2 != nParamsGet_u8)
			{
				CI_LocalPrintf ("USAGE: fa 1 [lun]\r\n");
				break;
			}
			b_fsaccess_init ();

			fs_g_nav.u8_lun = Param_u32;   // On chip RAM

			virtual_test_unit_ready() ;

			if (TRUE == fat_mount ())
			{
				CI_LocalPrintf ("Mount LUN %d OK\r\n",Param_u32);
			}
			else
			{
				CI_LocalPrintf ("Mount LUN %d FAIL - %d - %s\r\n",Param_u32,fs_g_status, IBN_FileSystemErrorText(fs_g_status));
			}
//			nav_partition_mount ();
			break;
#endif
   	   case 2 :
			CI_LocalPrintf ("Free mem = %d sectors\r\n",fat_getfreespace());
   		    break;
   	   case 3 :

   		    FileID_s32 = open ("test.txt",O_CREAT|O_RDWR);
			CI_LocalPrintf ("Open  = %d - %d - %s\r\n",FileID_s32,fs_g_status, IBN_FileSystemErrorText(fs_g_status));

			Ret_s32 = write (FileID_s32,"Test\n",6);
			CI_LocalPrintf ("Write  = %d \r\n",Ret_s32);
/*
			if (TRUE == fat_cache_flush ())
			{
				CI_LocalPrintf ("fat_cache_flush OK\r\n");
			}
			else
			{
				CI_LocalPrintf ("fat_cache_flush FAIL - %d - %s\r\n",fs_g_status, IBN_FileSystemErrorText(fs_g_status));
			}
*/
			Ret_s32 = close (FileID_s32);
			CI_LocalPrintf ("Close  = %d \r\n",Ret_s32);

#if LUN_2 == ENABLE
			virtual_unit_state_e = CTRL_BUSY;    // only for ram disk
#endif
			sd_mmc_mci_unit_state_e = CTRL_BUSY;
			vTaskDelay (500);
#if LUN_2 == ENABLE
			virtual_unit_state_e = CTRL_GOOD;
#endif
      sd_mmc_mci_unit_state_e = CTRL_GOOD;

   		    break;
   	   case 4 :
			if (2 != nParamsGet_u8)
			{
				CI_LocalPrintf ("USAGE: fa 6 [lun]\r\n");
				break;
			}

   		    FAI_Write (Param_u32);
			break;

   	   case 5 :
			FAI_ShowDirContent ();
   		    break;
   	   case 6:
			if (2 != nParamsGet_u8)
			{
				CI_LocalPrintf ("USAGE: fa 6 [lun]\r\n");
				break;
			}
   		   FAI_mount(Param_u32);
		   break;
   	   case 7 :
   		   FAI_free_space(Param_u32);
   		   break;
   	   case 8 :
   		   FAI_nb_drive();
   		   break;
   	   case 9 :
   		   FAI_Dir (0);
   		   break;
   	   case 10 :
		   if (TRUE == nav_drive_set (Param_u32))
		   {
			   CI_LocalPrintf ("nav_drive_set OK\r\n");
		   }
		   else
		   {
			   CI_LocalPrintf ("nav_drive_set FAIL - %d - %s\r\n",fs_g_status, IBN_FileSystemErrorText(fs_g_status));
		   }
   		   break;
   	   case 11 :
#if LUN_2 == ENABLE
         CI_LocalPrintf ("Set LUN %d CTRL_BUSY\n\r",Param_u32);
         //virtual_unit_state_e = CTRL_BUSY;
         set_virtual_unit_busy ();
#endif
         break;
   	   case 12 :
         CI_LocalPrintf ("Update LUN %d\n\r",Param_u32);
   	    FAI_UpdateContend (Param_u32);;
   	    break;
   	   case 13 :
         CI_LocalPrintf ("fat_cache_flush\n\r");
   	     fat_cache_flush ();
         break;
   	   case 14 :
         CI_LocalPrintf ("fat_check_device\n\r");
   	     fat_check_device ();
   	     break;
       case 15 :
         CI_LocalPrintf ("fat_check_device\n\r");
        fat_read_dir ();
        break;
       case 16 :
         CI_LocalPrintf ("Copy test.txt to test1.txt\n\r");
         {
           u8 F1[10];
           u8 F2[10];

           strcpy ((char*)F1,"test.txt");
           strcpy ((char*)F2,"test1.txt");
           FAI_CopyFile (F1,F2);
         }
        break;
       case 17 :
         CI_LocalPrintf ("Format LUN %d\n\r",Param_u32);
         nav_drive_set(Param_u32);
         if( !nav_drive_format(FS_FORMAT_FAT) )
         {
           CI_LocalPrintf ("Format LUN %d - ERROR\n\r",Param_u32);
         }
         break;

	}
}