Reputation: 475
I want to find the hard drives name (eg: ada, da, etc) under FreeBSD 9, using C. The hard drive is not mounted (so I can not use statfs), can contain different types of filesystems and can be different hardware architectures.
Also, if there is a shell-based solution (without grepping into camcontrol output) I would be glad to hear it.
Upvotes: 2
Views: 335
Reputation: 18339
If you are just looking for device names, you can just look under /dev for devices that match what you're looking for. A machine can have many hard drives and aliases are possible. You can also have device names that are specific to a kind of RAID controller, like /dev/mfid, /dev/aacd, /dev/mfisyspd or /dev/twe.
You should look at the geom subsystem to understand how this stuff works. Manpages to look at: geom(4), GEOM(4), libgeom(3).
Quick sysctls you can read to find out how the system is configured include kern.geom.conftxt and kern.geom.confxml, depending on whether you want text as input to your code.
Upvotes: 1