Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Jul 2009 20:49:45 +0200
From:      Roland Smith <rsmith@xs4all.nl>
To:        Sagara Wijetunga <sagara@tomahawk.com.sg>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Why this flash drive not detected in devd?
Message-ID:  <20090710184945.GA4323@slackbox.xs4all.nl>
In-Reply-To: <20090710014128.13958.qmail@us1.tomahawkonline.net>
References:  <4A560B28.6080705@tomahawk.com.sg> <20090709165927.GB63043@slackbox.xs4all.nl> <20090710014128.13958.qmail@us1.tomahawkonline.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--7AUc2qLy4jB3hD7Z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Jul 09, 2009 at 08:41:28PM -0500, Sagara Wijetunga wrote:
>  Roland Smith writes:
>=20
>    On Thu, Jul 09, 2009 at 11:22:16PM +0800, Sagara Wijetunga wrote:
>=20
>      Hi FreeBSD community
>=20
>      This is FreeBSD 7.2 on i386.
>=20
>      sysctl -a | grep dev.umass
>      dev.umass.1.%desc: Imation Flash Drive, class 0/0, rev 2.00/1.03, ad=
dr 3
>      dev.umass.1.%driver: umass
>      dev.umass.1.%location: port=3D6 interface=3D0
>      dev.umass.1.%pnpinfo: vendor=3D0x0718 product=3D0x0081 devclass=3D0x=
00 devsubclass=3D0x00
>      release=3D0x0103 sernum=3D"14925B00" intclass=3D0x08 intsubclass=3D0=
x06
>      dev.umass.1.%parent: uhub4
>=20
>      Following added to /etc/devd.conf:
>       1. Imation Flash Drive, class 0/0, rev 2.00/1.03, addr 3
>      attach 200 {
>          match "vendor"  "0x0718";
>          match "product" "0x0081";
>          match "serial"  "14925B00";
>          action "touch /tmp/Imation-Flash-Drive-detected";
>      };
>=20
>      Could I know why the flash drive is not detected on attach?
>=20
>    The USB subsystem isn't currently equipped to notify devd (technically,
>    the devctl_notify function isn't used in the USB stack). So the only
>    notification you'll get is when devfs creates a device. Since there is
>    no predictable link between a USB device and a disk device, info from
>    the USB stack would be less then usefull.
>=20
>    You can check this by reading from /dev/devctrl (when devd is not
>    running, since this device can only be opened by one program at a time)
>    just after you plugged in the device. For my usb thumbdrive I get:
>=20
>    cat /dev/devctl
>    !system=3DDEVFS subsystem=3DCDEV type=3DCREATE cdev=3Dpass2
>    !system=3DDEVFS subsystem=3DCDEV type=3DCREATE cdev=3Dda0
>    !system=3DDEVFS subsystem=3DCDEV type=3DCREATE cdev=3Dda0s1
>    !system=3DDEVFS subsystem=3DCDEV type=3DCREATE cdev=3Dmsdosfs/RFS1
>=20
>    While sysctl gives:
>=20
>    dev.umass.0.%desc: vendor 0x3538 USB Mass Storage Device, class 0/0, r=
ev 2.00/1.00, addr 2
>    dev.umass.0.%driver: umass
>    dev.umass.0.%location: port=3D4 interface=3D0
>    dev.umass.0.%pnpinfo: vendor=3D0x3538 product=3D0x0042 devclass=3D0x00=
 devsubclass=3D0x00 release=3D0x0100
>    sernum=3D"000000000004E1" intclass=3D0x08 intsubclass=3D0x06
>    dev.umass.0.%parent: uhub4
>=20
>    So for now, you'll have to match on the creation of da* devices, or
>    labels if you use those.
>=20
>  Roland, thanks for the reply.
>=20
>  Here is my side info on FreeBSD 7.2:
>  cat /dev/devctl
>  ? at port=3D6 vendor=3D0x0718 product=3D0x0081 devclass=3D0x00 devsubcla=
ss=3D0x00 release=3D0x0103
>  sernum=3D"14925B00" on uhub4

The "?" means "Unknown device detected". See devctl(4). This is _not_
noticed be devd, I think

>  +umass1 vendor=3D0x0718 product=3D0x0081 devclass=3D0x00 devsubclass=3D0=
x00 release=3D0x0103
>  sernum=3D"14925B00" intclass=3D0x08 intsubclass=3D0x06 at port=3D6 inter=
face=3D0 vendor=3D0x0718
>  product=3D0x0081 devclass=3D0x00 devsubclass=3D0x00 release=3D0x0103 ser=
num=3D"14925B00" intclass=3D0x08
>  intsubclass=3D0x06 on uhub4

Note that while "+" denotes a device creation event, it is for umass1,
not for a disk device.

>  !system=3DDEVFS subsystem=3DCDEV type=3DCREATE cdev=3Dpass4
>  !system=3DDEVFS subsystem=3DCDEV type=3DCREATE cdev=3Dda4
>  !system=3DDEVFS subsystem=3DCDEV type=3DCREATE cdev=3Dda4s1
>  !system=3DDEVFS subsystem=3DCDEV type=3DCREATE cdev=3Dmsdosfs/
>=20
>  I have few questions:
>  1. Above shows info we need available under '?' and '+' lines. What
>  we need is vendor, product and sernum. Can these be accessed in
>  addition to cdev?

Not currently. The hooks into the USB subsystem are missing.=20

But even if they were there, that info is not very usefull in
itself. You also need to know the disk device number that the USB drive
gets! If there were hooks in the USB system, you would get _multiple_
events in devd:

1) USB device plugged in. (serial no etc...)
2) pass device created by devfs
3) da devices created by devfs
4) msdodfs/ devices created by devfs.

So you would need to remember the first event until the device creation
happens. Devd itself has no facilities for that. Sure, you can cobble
something together with tempoeary files etc., but that would be fragile.

And as I've said before, there is no one-on-one link between a USB
device that gets plugged in and the disk device that is assigned to it!
=20
>  2. Is this issue been fixed in FreeBSD 8.0?

I don't know. The USB stack was rewritten for 8.0. Ask on the -current
or -hackers list.
=20
>  3. Can you or someone think of a patch against FreeBSD 7.2 to provide
>  vendor, product and sernum in addition to cdev? It's very big help
>  someone could extend to us to release Tomahawk Desktop

As I explained above, this would not accomplish what you want.

Again, maybe you should check out sysutils/hal.

Roland
--=20
R.F.Smith                                   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)

--7AUc2qLy4jB3hD7Z
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (FreeBSD)

iEYEARECAAYFAkpXjUkACgkQEnfvsMMhpyXYAACgiU2FP+D53EJJ+Ry8UzTFjRpW
4/0AoKIfkYE6r2k8l97+OQ+Ge736sqt+
=2kdC
-----END PGP SIGNATURE-----

--7AUc2qLy4jB3hD7Z--



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