@@ -508,7 +508,7 @@ int dfs_mount_table(void)
508508 mount_table [index ].rwflag ,
509509 mount_table [index ].data ) != 0 )
510510 {
511- rt_kprintf ("mount fs[%s] on %s failed.\n" , mount_table [index ].filesystemtype ,
511+ LOG_E ("mount fs[%s] on %s failed.\n" , mount_table [index ].filesystemtype ,
512512 mount_table [index ].path );
513513 return - RT_ERROR ;
514514 }
@@ -518,6 +518,43 @@ int dfs_mount_table(void)
518518 return 0 ;
519519}
520520INIT_ENV_EXPORT (dfs_mount_table );
521+
522+ int dfs_mount_device (rt_device_t dev )
523+ {
524+ int index = 0 ;
525+
526+ if (dev == RT_NULL ) {
527+ rt_kprintf ("the device is NULL to be mounted.\n" );
528+ return - RT_ERROR ;
529+ }
530+
531+ while (1 )
532+ {
533+ if (mount_table [index ].path == NULL ) break ;
534+
535+ if (strcmp (mount_table [index ].device_name , dev -> parent .name ) == 0 ) {
536+ if (dfs_mount (mount_table [index ].device_name ,
537+ mount_table [index ].path ,
538+ mount_table [index ].filesystemtype ,
539+ mount_table [index ].rwflag ,
540+ mount_table [index ].data ) != 0 )
541+ {
542+ LOG_E ("mount fs[%s] device[%s] to %s failed.\n" , mount_table [index ].filesystemtype , dev -> parent .name ,
543+ mount_table [index ].path );
544+ return - RT_ERROR ;
545+ } else {
546+ LOG_D ("mount fs[%s] device[%s] to %s ok.\n" , mount_table [index ].filesystemtype , dev -> parent .name ,
547+ mount_table [index ].path );
548+ return RT_EOK ;
549+ }
550+ }
551+
552+ index ++ ;
553+ }
554+
555+ rt_kprintf ("can't find device:%s to be mounted.\n" , dev -> parent .name );
556+ return - RT_ERROR ;
557+ }
521558#endif
522559
523560#ifdef RT_USING_FINSH
0 commit comments