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 08:59:42 -0400
- Thread-topic: Determining if a file is local
>> Hi,
>>
>> I'm trying to determine whether a given file is mounted on a local
>> drive, or
>> a network drive.
>>
>> I've been using statfs64(), checking f_flags & MNT_LOCAL. This seems
>> to work
>> in most cases, but it turns out that if I mount a dmg from a network
>> drive,
>> f_flags says it is local.
>>
>> Does anyone know of a way to determine if a file inside a mounted
>> dmg is
>> ultimately local or remote?
> 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 :)
***********************************************************************
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.
_______________________________________________
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