How to detect sd card insert/removal in user space code

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to detect sd card insert/removal in user space code

729 次查看
Dhevan
Contributor IV

Hi,

      We are using imx8m mini evk board.

      SD card auto mounting is working fine.

      But we want user space code detect to detect sd card insertion and removal.

      Ubuntu i have tried netlink(libnl) suite https://www.infradead.org/~tgr/libnl/doc/core.html but not able to find proper apis.

      Please help us solve the issue.

Thanks & Regards,

       Vasu

0 项奖励
3 回复数

718 次查看
b36401
NXP Employee
NXP Employee

I can suggest to grep /var/log/messages for messages related to SD card.
I mean something like this:
[ 542.576330] mmc1: card 59b4 removed
and this:
[ 570.761873] mmc1: new high speed SDHC card at address 59b4

0 项奖励

697 次查看
Dhevan
Contributor IV

Hi @b36401,

     We want to detect user space c/c++ code.

     Do you have any suggestion detecting in user space c/c++ code ?

Thanks & Regards,

        Vasu

0 项奖励

688 次查看
b36401
NXP Employee
NXP Employee

Another way (that may be more useful for C code) is to check if /dev/mmcblk1 appears.
I mean that the code may periodically check /dev/mmcblk1 filesystem entry for existing.

0 项奖励