On Thu, Jul 22, 2010 at 8:38 PM, Peter Taps <ptr...@yahoo.com> wrote:
> Hello,
>
> I am working on an application that requires me to enumerate disks and 
> present their information to the user.
>
> Disks can be enumerated using "format" command. However, I am looking for a 
> programmatic way to do it. I would like to avoid running "format" process and 
> parsing the returned output.
>
> I would appreciate it if you could point me in the right direction for sample 
> 'C' language code.
>
> Our application is being built in Java. Any pointer to JNA or JNI samples 
> would be much appreciated.

Simplest way is to walk through the kstats. This allows you to reproduce
'iostat -E', which may be good enough.

(This falls down in two ways: first, it doesn't identify removable media - I
would love to be able to identify those accurately, preferably without
needing any extra privilege. Second, it doesn't handle multipathed
devices - but then, neither does format. And while it can enumerate
disks, getting the partition layout [ie. prtvtoc] can't be done with
kstats.)

To get at kstats from java, allow me to blow my own trumpet:

http://www.petertribble.co.uk/Solaris/jkstat.html

or, for an application which already does a disk enumeration the
way I described:

http://www.petertribble.co.uk/Solaris/solview.html

If any of those are useful, feel free to bug me for advice or help;
if they aren't then also let me know as I'm trying to solve a similar
problem.

-- 
-Peter Tribble
http://www.petertribble.co.uk/ - http://ptribble.blogspot.com/
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to