lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <18104.7056.369176.547630@notabene.brown>
Date:	Tue, 7 Aug 2007 17:13:20 +1000
From:	Neil Brown <neilb@...e.de>
To:	Arjan van de Ven <arjan@...radead.org>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: [PATCH/RFC] allow mapping from block-device-file to sysfs
	entry.

On Monday August 6, arjan@...radead.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.
> > 
> > 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, but one day that might change
to "class/block/sda/sda1" or some-such.

> 
> (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....

#define SYSFSLOCATION _IOR(0, 0xff, char[256])
??

Thanks,
NeilBrown
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ