MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_mkfs

Function dfs_mkfs

components/dfs/dfs_v1/src/dfs_fs.c:432–477  ·  view source on GitHub ↗

* make a file system on the special device * * @param fs_name the file system name * @param device_name the special device name * * @return 0 on successful, otherwise failed. */

Source from the content-addressed store, hash-verified

430 * @return 0 on successful, otherwise failed.
431 */
432int dfs_mkfs(const char *fs_name, const char *device_name)
433{
434 int index;
435 rt_device_t dev_id = NULL;
436
437 /* check device name, and it should not be NULL */
438 if (device_name != NULL)
439 dev_id = rt_device_find(device_name);
440
441 if (dev_id == NULL)
442 {
443 rt_set_errno(-ENODEV);
444 LOG_E("Device (%s) was not found", device_name);
445 return -1;
446 }
447
448 /* lock file system */
449 dfs_lock();
450 /* find the file system operations */
451 for (index = 0; index < DFS_FILESYSTEM_TYPES_MAX; index ++)
452 {
453 if (filesystem_operation_table[index] != NULL &&
454 strncmp(filesystem_operation_table[index]->name, fs_name,
455 strlen(filesystem_operation_table[index]->name)) == 0)
456 break;
457 }
458 dfs_unlock();
459
460 if (index < DFS_FILESYSTEM_TYPES_MAX)
461 {
462 /* find file system operation */
463 const struct dfs_filesystem_ops *ops = filesystem_operation_table[index];
464 if (ops->mkfs == NULL)
465 {
466 LOG_E("The file system (%s) mkfs function was not implement", fs_name);
467 rt_set_errno(-ENOSYS);
468 return -1;
469 }
470
471 return ops->mkfs(dev_id, fs_name);
472 }
473
474 LOG_E("File system (%s) was not found.", fs_name);
475
476 return -1;
477}
478
479/**
480 * this function will return the information about a mounted file system.

Callers 15

mkfsFunction · 0.70
cmd_mkfsFunction · 0.50
test_mkfsFunction · 0.50
test_mkfsFunction · 0.50
mnt_initFunction · 0.50
flash_initFunction · 0.50
mount_initFunction · 0.50
filesysytem_try_mountFunction · 0.50
fal_elmfat_sampleFunction · 0.50
app_filesystem_initFunction · 0.50
littlefs_mountFunction · 0.50
rt_hw_fs_initFunction · 0.50

Calls 4

rt_device_findFunction · 0.85
rt_set_errnoFunction · 0.85
dfs_lockFunction · 0.70
dfs_unlockFunction · 0.70

Tested by 3

test_mkfsFunction · 0.40
test_mkfsFunction · 0.40
mnt_initFunction · 0.40