How to programmatically detect a mounted device

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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


Re: How to programmatically detect a mounted device

| 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 |
We've slightly trimmed the long signature. Click to see the full one.
Re: How to programmatically detect a mounted device
Quoted text here. Click to load it

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

Best,
P


Re: How to programmatically detect a mounted device
On 9 Apr 2007 12:31:57 -0700

Quoted text here. Click to load it


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.               http://www.sysdev.org
/ __|\// __||  \  __   __          /         snipped-for-privacy@sysdev.org
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline