 |
 |
Finding device paths from volume paths?
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Sep 2000
Location: Monopoli, Bary, ITALY
Status:
Offline
|
|
I have the file path of a CD driver or a DVD driver when a disk is inserted, i.e:
"/Volumes/DVD_Movie"
and I want to obtain the device path, i.e:
"/dev/disk2"
How to, using C, C++ or Objective-C?
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
The function statfs() in sys/mount.h is what you want. You pass in the path to the mount, and in the structure returned, the field you're interested in is f_mntfromname.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Sep 2000
Location: Monopoli, Bary, ITALY
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jan 2002
Location: Melbourne, Australia
Status:
Offline
|
|
I am looking to do the same thing as the original poster and tried using statfs, which does indeed return the device path as /dev/device. I am then wishing to look up the device in the IORegistry. The problem is the IORegistry just has the name, so /dev/disk6 is "BSD Name" => "disk6". Now one option would be to just remove _PATH_DEV (defined in paths.h) from the start of the string and use that, which would probably work fine.
I did however find the VolumeToBSDNode code sample which shows how get the BSD node for all mounted volumes. It uses FSGetVolumeInfo then PBHGetVolParmsSync to achieve this. However I don't want to iterate across all volumes, I already have the path to the volume I want. FSGetVolumeInfo requires the FSVolumeRefNum of the volume. From what I can find the only way to get this is via GetVRefNum which itself requires a fileRefNum to an open file on the volume - something I don't have.
Does anyone know of any other methods to get FSVolumeRefNum from a /Volumes/blah path?
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |