如何在Linux驱动程序中列出MMC分区? [英] How can I list MMC partitions in a Linux driver?

查看:74
本文介绍了如何在Linux驱动程序中列出MMC分区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试读取eMMC上存储的U-Boot环境,但是我不知道如何列出磁盘.我正在创建的驱动程序与mmc设备驱动程序(/dev/mmcblk0p1)分开.

I'm trying to read the U-Boot environment that is stored on eMMC, but I can't figure out how I can list the disks. The driver I'm creating is separated of the mmc device driver (/dev/mmcblk0p1).

我已经发现mmcblk0的分区是__mtd_next_device .

I already found out that the partitions of mmcblk0 are struct mmc_part entries in struct mmc_card. Basically I'm searching for the mmc variant of __mtd_next_device.


我发现可以得到 block_device 通过 bdget ,但 gendisk 指向 NULL .

struct block_device *my_bdevice;
struct gendisk *my_gdisk;
my_bdevice = bdget(179);
my_gdisk = part_to_disk(my_bdevice->bd_part);
if (!my_gdisk) goto end; // Goes to end..

推荐答案

在我上面的代码中, my_bdevice = bdget(179); 是错误的:

In my code above, my_bdevice = bdget(179); is wrong:

dev_t devt = blk_lookup_devt("mmcblk0", 0);
my_bdevice = bdget(devt);

这篇关于如何在Linux驱动程序中列出MMC分区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆