From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758008AbXHGHlQ (ORCPT ); Tue, 7 Aug 2007 03:41:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756052AbXHGHlF (ORCPT ); Tue, 7 Aug 2007 03:41:05 -0400 Received: from rv-out-0910.google.com ([209.85.198.185]:11635 "EHLO rv-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755297AbXHGHlD (ORCPT ); Tue, 7 Aug 2007 03:41:03 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=r+Tu0Mu8IFvwJFPOT8gXaPJc2iu5QZkMe4SwGFGy5GtkJ9ibyKm47b5Ae0vcdrNdONa4ubjfb5VCGBQmOSREQ7ve2m7aRS+FWKP7pQemOeZT17EmwvCxqZxVsEDs84qzBSMSgFoqOudKjTXtQWbLgl7sgQXOl4sE+1YBSGfxl2w= Message-ID: <3ae72650708070041s52861b7dr484cacf98353a3c6@mail.gmail.com> Date: Tue, 7 Aug 2007 09:41:02 +0200 From: "Kay Sievers" To: "Neil Brown" Subject: Re: [PATCH/RFC] allow mapping from block-device-file to sysfs entry. Cc: "Arjan van de Ven" , linux-kernel@vger.kernel.org In-Reply-To: <18104.7056.369176.547630@notabene.brown> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <18104.3098.696484.970773@notabene.brown> <1186468623.2700.4.camel@laptopd505.fenrus.org> <18104.7056.369176.547630@notabene.brown> X-Google-Sender-Auth: 8aac70ab1581acac Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On 8/7/07, Neil Brown wrote: > On Monday August 6, arjan@infradead.org wrote: > > On Tue, 2007-08-07 at 16:07 +1000, Neil Brown wrote: > > > Suppose that in a program I have an open file descriptor for a device, > > > and I want to find the /sys/block information for this device. > > > There is currently no direct way to do this. I need to read > > > /sys/block/*/dev, /sys/block/*/*/dev > > > and match major/minor numbers with the result from fstat. > > > > > > I would like a more direct mechanism. $ udevinfo --query=path --name=sda /block/sda > > > The following patch is a proposal for such a mechanism. > > > > > > It provides an 'ioctl' which returns then 'name' of the device, as > > > generated by bdevname. This is the same name that is used to create > > > entries in sysfs. > > > For a partition of a device, it returns 'device/partition'. > > > > > > how about returning the entire path relative to the start of sysfs? That > > way, if things move or something you're tolerant against that.... > > That makes a lot of sense. > So it would return "block/sda/sda1" now, Every devpath always starts with a '/' in the kernel, its kind of weird, but we should not introduce a new variation of it. :) > but one day that might change > to "class/block/sda/sda1" or some-such. It will start with /devices/..., like: /sys/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/sda/sda1 > > (I'd not be against making this a generic IOCTL for every device, a > > SYSFSLOCATION kind of ioctl... it's by no means block specific...) > > > > That too seems very sensible. Only it's harder to choose a 'generic' > ioctl request number than to choose a block-specific one :-) > > We would also need a somewhat longer buffer. The longest > /sys/**/dev > path on my test machine is > /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1:1.1/usb_endpoint/usbdev2.2_ep82/dev > > So at least 80 chars. Probably 256 would do.... They can be definitely longer than than 256, probably not longer than 512 today, but you can't be sure about that. Thanks, Kay