How to programmatically detect a mounted device

Hi,

I have a gumstix running linux version below.

# uname -r

2.6.11gum

It has a MMC slot which I use for collecting log files. My requirements is that if the MMC card is mounted, my application would archive log files to the MMC card. If the card is not mounted (user not inserted), the my application would not archive log files, so as to not write to the internal flash.

My question is: how can I programmatically detect whether or not a MMC card is mounted?

Thanks for any help.

P
Reply to
Podi
Loading thread data ...

| I have a gumstix running linux version below. | | # uname -r | 2.6.11gum | | It has a MMC slot which I use for collecting log files. My | requirements is that if the MMC card is mounted, my application would | archive log files to the MMC card. If the card is not mounted (user | not inserted), the my application would not archive log files, so as | to not write to the internal flash. | | My question is: how can I programmatically detect whether or not a MMC | card is mounted?

By scanning the contents of /proc/mounts (if you have /proc enabled and mounted).

--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org)  /  Do not send to the address below |
 Click to see the full signature
Reply to
phil-news-nospam

Yes, thank you. I do see the entry in the file after mounting the card.

Best, P

Reply to
Podi

Here is a little /bin/sh routine that you probably might find useful, or can modify to suit...

is_reader() { test=$( cat /proc/scsi/usb-storage*/* 2> /dev/null | grep "Card Reader"; cat /proc/bus/usb/devices 2> /dev/null | grep Cnt=0[1-9] ) if [ "$test" = "" ]; then return 0 else return 1 fi }

TonyB

There are 10 types of people in this world, those that read binary and those who don't!

-- __ __ _ I N C.

formatting link
/ __|\\// __|| \ __ __ / snipped-for-privacy@sysdev.org \__ \ \/\__ \||)|/ O_)\/ / \/ System Tools / Utilities |___/ || ___/|_ /\___|\_/ WIntel / Linux Device Drivers

Reply to
Hufnus

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.