mnt.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include <rtthread.h>
  2. #ifdef RT_USING_DFS
  3. #include <dfs_fs.h>
  4. rt_weak uint8_t *cromfs_get_partition_data(uint32_t *len)
  5. {
  6. return RT_NULL;
  7. }
  8. static int mnt_cromfs(void)
  9. {
  10. uint32_t length = 0;
  11. uint8_t *data = cromfs_get_partition_data(&length);
  12. int ret = -1;
  13. if (data && length)
  14. {
  15. ret = dfs_mount(NULL, "/", "crom", 0, data);
  16. }
  17. return ret;
  18. }
  19. int mnt_init(void)
  20. {
  21. rt_err_t ret;
  22. ret = mnt_cromfs();
  23. if (ret != RT_EOK)
  24. {
  25. rt_kprintf("CromFS mount failed!\n");
  26. return ret;
  27. }
  28. mkdir("/dev/shm", 0x777);
  29. if (dfs_mount(RT_NULL, "/dev/shm", "tmp", 0, 0) != 0)
  30. {
  31. rt_kprintf("Dir /dev/shm mount failed!\n");
  32. }
  33. #ifdef BSP_SD_SDIO_DEV
  34. while (mmcsd_wait_cd_changed(100) != MMCSD_HOST_PLUGED)
  35. ;
  36. if (dfs_mount(BSP_SD_MNT_DEVNAME, "/mnt", "elm", 0, 0) != 0)
  37. {
  38. rt_kprintf("Dir /mnt mount failed!\n");
  39. }
  40. #endif
  41. rt_kprintf("file system initialization done!\n");
  42. return 0;
  43. }
  44. INIT_ENV_EXPORT(mnt_init);
  45. #endif