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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

1,596件の閲覧回数
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 返答(返信)

1,585件の閲覧回数
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 件の賞賛
返信

1,564件の閲覧回数
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 件の賞賛
返信

1,555件の閲覧回数
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 件の賞賛
返信