problem with MFS on SD card.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

problem with MFS on SD card.

534 Views
botaoyang
Contributor II

I am using MFS to creat a sub directory in sd card, the program is as below:

error_code = ioctl(filesystem_handle, IO_IOCTL_CREATE_SUBDIR,"data\\neee");

if (!error_code)

{

       printf("success create subdir.\n");

}

this program works some time, but the program  also always stops here,

I am using my custom board, and I am sure the board is ok.

MQX 4.1, CW 10.6.

Labels (1)
0 Kudos
1 Reply

331 Views
soledad
NXP Employee
NXP Employee

Hello botao,

Please check the sdcard example located at the path: C:\Freescale\Freescale_MQX_4_2\mfs\examples\sdcard

This example may helps as reference.

In addition please check the below code, this is from sh_mkdir.c file:

/*FUNCTION*-------------------------------------------------------------------

*

* Function Name    :  Shell_mkdir

* Returned Value  :  int32_t error code

* Comments  :  mount a filesystem on a device.

*

* Usage:  mkdir <directory>

*

*END*---------------------------------------------------------------------*/

int32_t  Shell_mkdir(int32_t argc, char *argv[] )

{ /* Body */

  bool                    print_usage, temp, shorthelp = FALSE;

  int32_t                    error = 0, return_code = SHELL_EXIT_SUCCESS;

  MQX_FILE_PTR              fs_ptr;

  SHELL_CONTEXT_PTR          shell_ptr = Shell_get_context( argv );

  char                  *abs_path = NULL;

  print_usage = Shell_check_help_request(argc, argv, &shorthelp );

  if (!print_usage)  {

      if (argc !=  2) {

        printf("Error, invalid number of parameters\n");

        return_code = SHELL_EXIT_ERROR;

        print_usage=TRUE;

      } else  {

        if (MFS_alloc_path(&abs_path) != MFS_NO_ERROR) {

            printf("Error, unable to allocate memory for paths\n" );

            return_code = SHELL_EXIT_ERROR;

        }

        else

        {

            _io_get_dev_for_path(abs_path,&temp,PATHNAME_SIZE,(char *)argv[1],Shell_get_current_filesystem_name(shell_ptr));

            fs_ptr = _io_get_fs_by_name(abs_path);

            /* check if filesystem is mounted */

            if (fs_ptr == NULL)  {

              printf("Error, file system not mounted\n" );

              return_code = SHELL_EXIT_ERROR;

            } else  {

              error = _io_rel2abs(abs_path,shell_ptr->CURRENT_DIR,(char *) argv[1],PATHNAME_SIZE,Shell_get_current_filesystem_name(shell_ptr));

              if(!error)

              {

                  error = ioctl(fs_ptr, IO_IOCTL_CREATE_SUBDIR, (void *) abs_path);

              }

              if (error)  {

                  printf("Error creating directory %s\n", argv[1]);

              }

            }

          MFS_free_path(abs_path);

        }

      }

  }

    

    

  if (print_usage)  {

      if (shorthelp)  {

        printf("%s <directory> \n", argv[0]);

      } else  {

        printf("Usage: %s <directory>\n", argv[0]);

        printf("  <directory> = name of directory to create\n");

      }

  }

  return return_code;

}

#endif //SHELLCFG_USES_MFS

/* EOF*/


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos