Re: mount() from Cocoa App
Re: mount() from Cocoa App
- Subject: Re: mount() from Cocoa App
- From: Jim Luther <email@hidden>
- Date: Fri, 28 Oct 2005 15:11:27 -0700
On Oct 28, 2005, at 1:47 PM, Philip D. Wasson wrote:
On Oct 28, 2005, at 07:32, Dalton Hamilton wrote:
I am using FSMountServerVolumeAsync and FSUnmountVolumeSync to
mount and unmount smb and afp shares.
QUESTION 1:
However, I don't see a way to detect if the user has mounted the
shared volume manually. If the user has mounted the share
manually and then he runs my application and clicks on the button
to mount the same shared volume, my application calls
FSMountServerVolumeAsync and a second volume (icon is a Globe)
appears on the desktop for the same shared volume. However, If
the volume was mounted by my application and then the user
attempts to mount the volume again, the applications
FSMountServerVolumeAsync operation provides an error code (to my
callback function) of volOnLinErr -- which means Volume is already
online. I don't see the connection. Why doesn't the
FSMountServerVolumeAsync operation give the same volOnLinErr when
the volume has been mounted already manually???
We do something similar in a few of our apps (all Carbon). To see
if the desired volume is already mounted, we start by iterating
through all mounted volumes using the Carbon File Manager call
PBHGetVInfoSync() in indexed mode; that gets each valid volume
reference number. For each, we call PBGetVolMountInfo() to get the
remote mounting info and compare the values therein with what we're
looking for (you'll get an error for local volumes). That works
fine for AFP shares, not so much for SMB. For those, we then call
FSCopyURLForVolume() and extract the host name using
CFURLCopyHostName() and compare to the desired one. That can get
messy depending on whether what you're looking for is a host name
or IP address. The worst example of that is where there's no domain
server available for local machines, so you're looking for an IP
address, but somehow the file sharing client gets the host name
from the host during its connection, so when you call
FSCopyURLForVolume(), a host name comes back instead of an IP
address. And you can't even get around it by looking up the name
for the IP address you have and also comparing that name, or by
looking up the address for the name you got back and comparing
that, because there's no domain name server. Hopefully you don't
run into that.
If you haven't used the File Manager APIs very much, take a look at
the MoreFilesX sample code. For example, the FSGetMountedVolumes()
function shows how to get a list of volumes the File Manager knows
about (it returns an array of FSRefs, but that code could easily be
changed to return an array of FSVolumeRefNums). There's also a high-
level version of PBGetVolMountInfo.
- Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden