Re: Remounting afp Filesystem
Re: Remounting afp Filesystem
- Subject: Re: Remounting afp Filesystem
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Mon, 21 Aug 2006 10:22:15 +0200
On 20 Aug 2006, at 18:19, Ryan Britton wrote:
This works for AFP too: http://www.cocoabuilder.com/archive/
message/cocoa/2006/8/3/168957
On Aug 20, 2006, at 7:05 AM, Gerriet M. Denkmann wrote:
Because NSFileManager sometimes messes up my afp connection, and
because manually (in Finder) unmounting/remounting it fixes the
problem, I would like to do this programmatically.
mount( type, "/Volumes/userid", MNT_RELOAD, data)
But: what to use for "type"? "afp" or "afpfs" or what?
And what about data?
Man is not really helpful with this.
And: does afp accept a MNT_RELOAD?
Any better ideas to force a reload of afp?
Probably Carbon is indeed the way to go (all error checking removed
for brevity):
NSString *path = @"/Volumes/myuserid/some/file";
// unmount
NSURL *fileUrl = [ NSURL fileURLWithPath: path ] ;
FSRef fsRef;
Boolean ok = CFURLGetFSRef( (CFURLRef)fileUrl, &fsRef) ;
FSCatalogInfo catalogInfo;
OSErr s1 = FSGetCatalogInfo( &fsRef, kFSCatInfoVolume, &catalogInfo,
NULL, NULL, NULL);
FSVolumeRefNum vRefNum = catalogInfo.volume;
NSURL *mountUrl;
OSStatus s2 = FSCopyURLForVolume( vRefNum, (CFURLRef *)&mountUrl) ;
[ mountUrl autorelease ];
// [ mountUrl scheme ] should be "afp"
pid_t dissenter;
OSStatus s3 = FSUnmountVolumeSync( vRefNum, 0, &dissenter);
// remount
FSVolumeRefNum mountReference;
OSStatus s4 = FSMountServerVolumeSync ( (CFURLRef)mountUrl, NULL,
nil, nil, &mountReference, 0);
FSRef mountPathRef;
OSErr s4 = FSGetVolumeInfo( mountReference, 0, NULL, kFSVolInfoNone,
NULL, NULL, &mountPathRef);
NSURL *reMountUrl = (NSURL *)CFURLCreateFromFSRef
( kCFAllocatorDefault, &mountPathRef);
[ reMountUrl autorelease ];
NSString *reMountPath = [ reMountUrl path ];
// path should have prefix reMountPath
Gerriet.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden