From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755229AbXHGGit (ORCPT ); Tue, 7 Aug 2007 02:38:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752196AbXHGGil (ORCPT ); Tue, 7 Aug 2007 02:38:41 -0400 Received: from pentafluge.infradead.org ([213.146.154.40]:41279 "EHLO pentafluge.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751931AbXHGGik (ORCPT ); Tue, 7 Aug 2007 02:38:40 -0400 Subject: Re: [PATCH/RFC] allow mapping from block-device-file to sysfs entry. From: Arjan van de Ven To: Neil Brown Cc: linux-kernel@vger.kernel.org In-Reply-To: <18104.3098.696484.970773@notabene.brown> References: <18104.3098.696484.970773@notabene.brown> Content-Type: text/plain Organization: Intel International BV Date: Mon, 06 Aug 2007 23:37:03 -0700 Message-Id: <1186468623.2700.4.camel@laptopd505.fenrus.org> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-2.fc7) Content-Transfer-Encoding: 7bit X-SRS-Rewrite: SMTP reverse-path rewritten from by pentafluge.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org 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. > > 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.... (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...)