Re: Determining if a file is local
Re: Determining if a file is local
- Subject: Re: Determining if a file is local
- From: Tim Murison <email@hidden>
- Date: Mon, 29 Jun 2009 18:38:48 -0400
- Thread-topic: Determining if a file is local
>> This isn't exactly easy, nor do I know if it's right, but this is what
>> we do:
>> - First check the easy case (statfs)
>> - If that indicates a local volume, use DiskArb to get the BSD device
>> name for the volume
>> - in IOKit, find a block storage device with the same BSD device name
>> (IOKit property "BSD Name")
>> - Iterate up the IOKit device tree until you find a disk image device
>> in the IOKit
>> - Look at its "Protocol Characteristics" property, and check the
>> value of the "Virtual Interface Location" key. This is the path to the
>> disk image. Perform statfs on that path.
>>
>> It's not trivial, but it's reliablewe've tested that it works on Time
>> Capsule devices, 3rd party NAS devices, etc. I don't have the code on
>> me and the algorithm is from memory so it might be slightly off, but
>> you can get the jist of it by looking in IORegistryExplorer.
>
> Thanks, that sounds like what I need :)
I'm hoping for a little more help!
I set my code up so that notifications of disk images being mounted and
unmounted are sent to my run loop. This part works nicely.
The problem is in trying to drill down to the information I need.
Ultimately, I see 2 ways of doing this:
Either I use IOServiceMatching(kIOBlockStorageDeviceClass) in which case I
need to navigate "down" the device tree using child iterators (since I'm
starting with the IODiskImageBlockStorageDeviceOutKernel object I need to
find the associated BSD device name.) Or, I use IOBSDNameMatching(...,
"disk2s2") or similar, and navigate "up" the device tree using parent
iterators.
The thing is, no matter which device matching strategy I use, I only ever
get 1 parent or 1 child of the initially matched device. I can see the
parent/child I'm getting in the IORegistryExplorer in the service plane so I
know I'm going in the right direction, but it stops at 1 device.
I've attached my current iteration callback function.
Thanks in advance,
-Tim
***********************************************************************
This e-mail and its attachments are confidential, legally privileged, may be subject to copyright and sent solely for the attention of the addressee(s).
Any unauthorized use or disclosure is prohibited. Statements and opinions expressed in this e-mail may not represent those of Radialpoint.
Le contenu de ce courriel est confidentiel, privilégié et peut être soumis à des droits d'auteur. Il est envoyé à l'intention exclusive de son ou de ses
destinataires. Il est interdit de l'utiliser ou de le divulguer sans autorisation. Les opinions exprimées dans le présent courriel peuvent diverger de celles de Radialpoint.
Attachment:
device iteration.m
Description: Binary data
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden