Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Finding device paths from volume paths?

Finding device paths from volume paths?
Thread Tools
Fresh-Faced Recruit
Join Date: Sep 2000
Location: Monopoli, Bary, ITALY
Status: Offline
Reply With Quote
Jan 27, 2004, 04:14 AM
 
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
Reply With Quote
Jan 27, 2004, 05:15 AM
 
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'."
     
antofic  (op)
Fresh-Faced Recruit
Join Date: Sep 2000
Location: Monopoli, Bary, ITALY
Status: Offline
Reply With Quote
Jan 27, 2004, 05:47 AM
 
Thanks
     
Grizzled Veteran
Join Date: Jan 2002
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Jul 13, 2006, 06:20 AM
 
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?
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:54 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2