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

Function list_blk

components/drivers/block/blk.c:501–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501static int list_blk(int argc, char**argv)
502{
503 rt_ubase_t level;
504 rt_size_t cap, minor;
505 const char *size_name;
506 struct rt_object *obj;
507 struct rt_device *dev;
508 struct rt_blk_disk *disk;
509 struct rt_blk_device *blk_dev;
510 struct rt_device_blk_geometry geome;
511 struct rt_object_information *info = rt_object_get_information(RT_Object_Class_Device);
512
513 level = rt_hw_interrupt_disable();
514
515 rt_kprintf("%-*.s MAJ:MIN RM SIZE\tRO TYPE MOUNTPOINT\n", RT_NAME_MAX, "NAME");
516
517 rt_list_for_each_entry(obj, &info->object_list, list)
518 {
519 dev = rt_container_of(obj, struct rt_device, parent);
520
521 if (dev->type != RT_Device_Class_Block)
522 {
523 continue;
524 }
525
526 disk = to_blk_disk(dev);
527
528 if (disk->__magic != RT_BLK_DISK_MAGIC)
529 {
530 continue;
531 }
532
533 if (disk->ops->getgeome(disk, &geome))
534 {
535 continue;
536 }
537
538 size_name = convert_size(&geome, geome.sector_count, &cap, &minor);
539
540 rt_kprintf("%-*.s %3u.%-3u %u %u.%u%s\t%u disk %s\n",
541 RT_NAME_MAX, to_disk_name(disk),
542 #ifdef RT_USING_DM
543 disk->parent.master_id, disk->parent.device_id,
544 #else
545 0, 0,
546 #endif
547 disk->removable, cap, minor, size_name, disk->read_only,
548 disk->max_partitions != RT_BLK_PARTITION_NONE ? "\b" :
549 (dfs_filesystem_get_mounted_path(&disk->parent) ? : "\b"));
550
551 rt_list_for_each_entry(blk_dev, &disk->part_nodes, list)
552 {
553 size_name = convert_size(&geome, blk_dev->sector_count, &cap, &minor);
554
555 rt_kprintf("%c--%-*.s %3u.%-3u %u %u.%u%s\t%u part %s\n",
556 blk_dev->list.next != &disk->part_nodes ? '|' : '`',
557 RT_NAME_MAX - 3, to_blk_name(blk_dev),
558 #ifdef RT_USING_DM

Callers

nothing calls this directly

Calls 6

rt_kprintfFunction · 0.85
convert_sizeFunction · 0.85
rt_hw_interrupt_disableFunction · 0.50
rt_hw_interrupt_enableFunction · 0.50

Tested by

no test coverage detected