Gentoo Archives: gentoo-user

From: Jorge Almeida <jjalmeida@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] serial in /sys
Date: Sat, 01 Dec 2012 09:09:42
Message-Id: CAKpSnpK0zU6Zp2y=60odHadgyExaC+M5iOZs3ejGPPuq_op7Fw@mail.gmail.com
In Reply to: Re: [gentoo-user] serial in /sys by Walter Dnes
1 On Sat, Dec 1, 2012 at 3:47 AM, Walter Dnes <waltdnes@××××××××.org> wrote:
2 > On Fri, Nov 30, 2012 at 09:58:10AM +0000, Jorge Almeida wrote
3 >> On Fri, Nov 30, 2012 at 3:09 AM, Walter Dnes <waltdnes@××××××××.org> wrote:
4 >>
5 >
6 >> I thought of keeping data-- (key,value) = (serial_number,
7 >> custom_name_of_device)-- in a cdb database. I think it is faster than
8 >> reading a text file, and no parsing needed. It is also scalable
9 >> (although this is probably irrelevant on a custom-workstation
10 >> scale...). My (untested) program is about 11k, statically compiled.
11 >
12 > Come to think of it, I'd want to make it more general. I'd have my
13 > script read through a textfile ("flat-file database") with 3 columns.
14 >
15 > 1) Attribute; one of "manufacturer", "product", or "serial"; are there
16 > any others?
17 >
18
19 I checked that netlink and hotplug export exactly the same variables (well, at
20 least for the devices I tried), but SERIAL is not one of them, one has to dig
21 /sys. But the location of the "serial" file seems to be consistent, so problem
22 solved.
23
24 > 2) Value to match, i.e. manufacturer string, product name, or serial #.
25 >
26 > 3) The custom name I want my device to have
27 >
28
29 The problem with that approach is that the code is much less simple, and the
30 program less lean. I don't know what that implies regarding efficiency, but
31 inserting a usb pen with only one partition gives rise to 12 (!) events, and
32 thus the program (and hence mdev) is run 12 times, 10 of which are probably
33 completely useless (but there's no helping that).
34
35 You could have 3 cdb files, one for each type of key ("manufacturer",...) and
36 have the program seek them sequentially. It would still be very fast
37 (faster?), and less error prone. (I know cdb is not the most widely known type
38 of database, but it really is the appropriate one for this kind of usage--read
39 many times, write once in a blue moon--and it is very easy to deal with. I'm
40 using tinycdb (http://www.corpit.ru/mjt/tinycdb.html) because it provides a
41 library interface.)
42
43 >> By the way, I don't suppose there is a mailing list to talk about these
44 >> matters (mdev/ udev-alternative/ udev-fork related)? This is really
45 >> distro-agnostic stuff...
46 >
47 > For mdev-related questions, the best place I know of is the busybox
48 > mailing list http://lists.busybox.net/mailman/listinfo/busybox mdev is
49 > part of busybox.
50 >
51 OK, I just feel that mdev-related questions are really somewhat related, for
52 example, with the recent intentions of forking udev (which I hope will be
53 successful). For example, the evdev xorg driver requires udev! Is there a
54 really good reason for this, or is it another way to make udev mandatory? (A
55 bit of paranoia...) I don't know what list would be appropriate to raise this
56 question in.
57
58 Jorge Almeida