From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id D85101381F3 for ; Fri, 30 Nov 2012 00:29:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D7223E062D; Fri, 30 Nov 2012 00:29:16 +0000 (UTC) Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com [209.85.212.53]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 01B1421C090 for ; Fri, 30 Nov 2012 00:28:02 +0000 (UTC) Received: by mail-vb0-f53.google.com with SMTP id b23so11011408vbz.40 for ; Thu, 29 Nov 2012 16:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=sTAorxE9vVoHfwXzeH42UdaUdrCsfuxEyaTpsS7kd80=; b=gBUjg7YegWzUdSZ4gUso1E5PGsp8vqy3jk1mwmvjCUq9/mrxl3NLyNfaBmq7cvDCQA 2vHHxJ+B5X/rfn3UIlezyttJ8wA+ZnGz22BTUDHqUuKMJ+4QPFWZ1d+sczBedfr+rJvu UgR8Y2Nc7hV2/ioqgAd4iDJMXnC0UzyPZGuiuYJqpHDa/zTJAIoZ/w5Gnugxfb6tuZsO HHmlC0n7sgR3RfvAnx+ZQiphKzwNd1CK/3VyNMBXJX28aEMv0BWuM3UIDZuRU2ITGMlp QweeNZcjIOrqqM+KGJhtW0aD25ULhSpLlOBMudOxbYs3TVzG3LTmbG/1Ro1vqj6S40gZ CyLw== Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Received: by 10.220.241.141 with SMTP id le13mr32874457vcb.26.1354235282135; Thu, 29 Nov 2012 16:28:02 -0800 (PST) Received: by 10.58.223.170 with HTTP; Thu, 29 Nov 2012 16:28:01 -0800 (PST) In-Reply-To: <20121129223557.GA11921@waltdnes.org> References: <20121129192025.GO23914@server> <20121129223557.GA11921@waltdnes.org> Date: Fri, 30 Nov 2012 00:28:01 +0000 Message-ID: Subject: Re: [gentoo-user] serial in /sys From: Jorge Almeida To: gentoo-user@lists.gentoo.org Content-Type: text/plain; charset=ISO-8859-1 X-Archives-Salt: 273de81c-67d6-48fe-be2d-337066fe36c0 X-Archives-Hash: 3df4f771ea6a1ea86c29553941b2d8f2 On Thu, Nov 29, 2012 at 10:35 PM, Walter Dnes wrote: > On Thu, Nov 29, 2012 at 07:31:10PM +0000, Jorge Almeida wrote > > > I have a couple of scripts that automount USB devices under mdev. See > https://wiki.gentoo.org/wiki/Mdev for the general setup, and > https://wiki.gentoo.org/wiki/Mdev/Automount_USB and > https://wiki.gentoo.org/wiki/Mdev/Automount_USB/automount > I don't care for automounting, I just want customized symlinks. Using fstab is not a second choice, it is how I want it. > > The output below shows that not every USB device has a serial number, > and the "Patriot Memory" key has a serial number but no manufacturer... > > [d531][waltdnes][~] find /sys/devices/pci0* -name serial | xargs cat > OK. I found that my pens have serial numbers. I setup /proc/sys/kernel/hotplug with a script that prints the environment. When a pen is inserted, this is what is set: ACTION=add DEVPATH=/devices/pci0000:00/0000:00:04.1/usb1/1-4/1-4:1.0/host12/target12:0:0/12:0:0:0/block/sdd SUBSYSTEM=block MAJOR=8 MINOR=48 DEVNAME=sdd DEVTYPE=disk SEQNUM=1750 Following your suggestion: # find /sys/devices/pci0* -name serial /sys/devices/pci0000:00/0000:00:04.0/usb5/serial /sys/devices/pci0000:00/0000:00:04.1/usb1/1-4/serial /sys/devices/pci0000:00/0000:00:04.1/usb1/serial /sys/devices/pci0000:00/0000:00:06.0/usb6/serial /sys/devices/pci0000:00/0000:00:06.1/usb3/3-4/serial /sys/devices/pci0000:00/0000:00:06.1/usb3/serial /sys/devices/pci0000:00/0000:00:0c.0/0000:02:00.0/0000:03:01.0/0000:04:00.0/usb2/serial /sys/devices/pci0000:00/0000:00:0c.0/0000:02:00.0/0000:03:01.0/0000:04:00.0/usb4/serial # cat /sys/devices/pci0000:00/0000:00:04.1/usb1/1-4/serial AA04012700011287 So, the serial number is here. To retrieve it out of $DEVPATH, I can do (in this case, at least!): # cat /sys/devices/pci0000:00/0000:00:04.1/usb1/1-4/1-4:1.0/host12/target12:0:0/12:0:0:0/block/sdd/../../../../../../serial AA04012700011287 I'm assuming that this scenario is consistent for usb pen drives. I'll think of external hard disks next... BTW, the idea behind this is: -- have s6-devd listen to the netlink interface (http://www.skarnet.org/software/s6-linux-utils/s6-devd.html) -- when a device is inserted, s6-devd launches a program that tries to obtain the serial number, uses it as key to seek a string some_name in a constant database, and creates the symlink /dev/some_name --> $DEVNAME. On failure, exec mdev with the environment passed by the kernel. I'm supposing that the environment on netlink is the same as with the hotplug mechanism. Would this be true? I would be interested in hearing any comments... Thanks Joreg Almeida > > -- > Walter Dnes > We are apparently better off trying to avoid udev like the plague. Precisely. > Linus Torvalds; 2012/10/03 https://lkml.org/lkml/2012/10/3/349 >