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]
Date:	Thu, 4 Feb 2010 11:13:37 +0000
From:	Alan Cox <alan@...rguk.ukuu.org.uk>
To:	vb@...e.com
Cc:	linux-kernel@...r.kernel.org
Subject: Re: associating miscdevice with inode

On Wed, 3 Feb 2010 22:24:46 -0800
vb@...e.com wrote:

> guys,
> 
> say I have a misc device driver which instantiates several devices.
> When a file operation on this device is invoked, I need to be able to
> figure out which device is being accessed. All available information
> are
> 
> struct inode and struct file. Is there a way to find the address of
> the miscdevice structure passed to misc_register() when this device
> was created?

Not really. If you have a single misc device which each open creates a
new context of some sort then use filp->private_data to store your own
cotntext pointer.

Misc doesn't expect people to be registering lots of devices - its for
one offs and weirdnesses. You could I guess work backwards from

	minor = iminor(inode);

and see which of your miscdevs has c->minor == minor.

If you have more than a couple of instances being put into misc you
should probably register an anonymous device major/minor range instead
and go direct.

Alan
--
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