Gentoo Archives: gentoo-user

From: Jorge Almeida <jjalmeida@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] serial in /sys
Date: Fri, 30 Nov 2012 09:59:45
Message-Id: CAKpSnpJ-EDwCffoEq-SkBPzFj9H-U+m=nNM9mYtUSdd_X7XO6A@mail.gmail.com
In Reply to: Re: [gentoo-user] serial in /sys by Walter Dnes
1 On Fri, Nov 30, 2012 at 3:09 AM, Walter Dnes <waltdnes@××××××××.org> wrote:
2 > On Fri, Nov 30, 2012 at 12:28:01AM +0000, Jorge Almeida wrote
3 >
4 >> When a pen is inserted, this is what is set:
5 >>
6 >> DEVNAME=sdd
7 >
8 > This is almost exactly what I remember from when I was
9 > writing/testing/debugging my automount scripts. The one difference I
10 > remember is that when mdev handled it, there was no "DEVNAME" variable,
11 > but rather it was "MDEV". But otherwise identical. Two important notes...
12
13 Strange. The variable name is set by the kernel. Maybe you were using a
14 patched kernel?
15
16 >
17 > 1) For a USB mass storage device (pen or external hard drive) with N
18 > partitions, the hotplug handler will get N+1 events when inserting and
19 > also when removing. E.g. if your pen drive has 3 partitions, you'll get
20 > 4 events...
21
22 Right. The helper program is launched 4 times and will create (or remove,
23 depending on $ACTION) 4 symlinks.
24 >
25 > Would you be OK if the devices were always mounted in /media ? The
26 > reason I ask is that my scripts use pmount, which can take an optional
27 > label argument. E.g. if MDEV is "sdd1"
28 >
29
30 pmount looks a good idea for a many-users workstation. For a 1-user computer,
31 there's no loss of functionality with sticking with fstab.
32
33 >
34 > Actually, if I was writing it, I would add a few lines to my script
35 > for the "add" ACTION
36
37 Sure, I just didn't mention it.
38
39 > * label=${MDEV}
40 > * look for a "serial" file in the PCI path of the newly-inserted device
41 > * if found; then
42 > grep through a textfile to match the contents of the "serial" file
43
44 I thought of keeping data-- (key,value) = (serial_number,
45 custom_name_of_device)-- in a cdb database. I think it is faster than reading
46 a text file, and no parsing needed. It is also scalable (although this is
47 probably irrelevant on a custom-workstation scale...). My (untested) program is
48 about 11k, statically compiled.
49
50 By the way, I don't suppose there is a mailing list to talk about these
51 matters (mdev/ udev-alternative/ udev-fork related)? This is really
52 distro-agnostic stuff...
53
54 Thanks
55
56 Jorge Almeida

Replies

Subject Author
Re: [gentoo-user] serial in /sys Walter Dnes <waltdnes@××××××××.org>