Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 May 2015 08:43:51 +0200
From:      Polytropon <freebsd@edvax.de>
To:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Using SD cards with automount / GUI notification
Message-ID:  <20150513084351.2be8f6fa.freebsd@edvax.de>

next in thread | raw e-mail | index | archive | help
What is the recommended use of built-in card readers in
combination with device (and media) autodetection, followed
by notification services (such as employed by desktop
environments to make icons pop up)? This is essential for
automount functionality that users (in single-user single-PC
contexts) usually rely on. Think of how Gnome (as a "simple"
example) handles removable devices.

I'm asking because of the required "re-tasting" of the devices
and how it fits into that concept.

Initially, the device files corresponding to the different
card slots are present: /dev/da[0-2] in this example.

# camcontrol devlist
<HL-DT-ST DVDRAM GSA-H42N RL00>    at scbus0 target 0 lun 0 (pass0,cd0)
<Generic Flash HS-CF 4.55>         at scbus3 target 0 lun 0 (da0,pass1)
<Generic Flash HS-MS/SD 4.55>      at scbus3 target 0 lun 1 (da1,pass2) <-
<Generic Flash HS-SM 4.55>         at scbus3 target 0 lun 2 (da2,pass3)

And therefore:

# ls /dev/da*
/dev/da0  /dev/da1  /dev/da2

After inserting a SD card into the SD card reader (which
is /dev/da1 here), nothing happens. That's why:

# true > /dev/da1

And suddenly:

# ls /dev/da*
/dev/da0    /dev/da1    /dev/da1s1  /dev/da2

Now possible:

# mount /media/sd

The SD card can be accessed (due to the entry in /etc/fstab
which specifies the required options); in this case /dev/da1s1
will be mounted at /media/sd as msdosfs with the options set
of rw,noauto,noatime,-m=644,-M=755.

When done:

# umount /media/sd

The card is then removed. But the device file shown above
(/dev/da1s1) isn't removed, even after "re-tasting" it keeps
being present:

# ls /dev/da*
/dev/da0    /dev/da1    /dev/da1s1  /dev/da2
# true > /dev/da1
/dev/da1: Device not configured.
# ls /dev/da*
/dev/da0    /dev/da1    /dev/da1s1  /dev/da2

My questions so far:

1. In order to get the notification mechanism working for
   card readers, is it acceptable to do "true > true > /dev/da[0-2]"
   in a repeated manner, let's say, every 10 seconds (because
   users don't want to waste time waiting)? Is this better being
   done with a /etc/rc.local "hack" or via cron?

2. How to deal with the notification when the card disappears?

3. Does using the presence of labels (not tested here) offer
   a better approach?

I will be thankful for any insight in this strange topic. :-)


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150513084351.2be8f6fa.freebsd>