DARegisterDiskMountApprovalCallback() behavior
DARegisterDiskMountApprovalCallback() behavior
- Subject: DARegisterDiskMountApprovalCallback() behavior
- From: websrvr <email@hidden>
- Date: Fri, 14 May 2010 08:53:32 -0400
- Mta-interface: amavisd-new-2.3.3 (2005-08-22) + Maia Mailguard 1.0.1 at daleenterprise.com
Example code:
#import <Foundation/Foundation.h>
#import <DiskArbitration/DiskArbitration.h>
DADissenterRef
DiskApproved(DADiskRef disk, void *context)
{
char const *CdiskName = DADiskGetBSDName(disk);
DADissenterRef dissenter;
char *type;
NSString *diskName = [NSString stringWithUTF8String:CdiskName];
NSRange s1s1NumberRange = NSMakeRange([diskName length] - 4, 4);
if([[diskName substringWithRange:s1s1NumberRange]
isEqualToString:@"s3s1"]) /* check for our magic partition */
{
CFStringRef arguments[] =
{
CFStringCreateWithCString(kCFAllocatorDefault, "nobrowse",
kCFStringEncodingUTF8),
CFStringCreateWithCString(kCFAllocatorDefault, "owners",
kCFStringEncodingUTF8),
CFStringCreateWithCString(kCFAllocatorDefault, "suid",
kCFStringEncodingUTF8),
NULL
};
DADiskMountWithArguments(disk,
NULL,
kDADiskMountOptionDefault,
NULL,
NULL,
arguments);
/* deny the mount since we already mounted it */
dissenter = DADissenterCreate(kCFAllocatorDefault,
kDAReturnNotPermitted,
CFSTR("mounted hidden"));
type = "we will mounted";
}
else
{
/* allow normal mounting */
dissenter = NULL;
type = "system will mount";
}
printf("%s: %s\n", CdiskName, type);
return dissenter;
}
int
main (int argc, const char * argv[])
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
DAApprovalSessionRef session = DAApprovalSessionCreate
(kCFAllocatorDefault);
if (!session)
{
fprintf(stderr, "failed to create Disk Arbitration session");
goto out;
}
DARegisterDiskMountApprovalCallback(session,
NULL, // matches all disk objects
DiskApproved,
NULL); // context
DAApprovalSessionScheduleWithRunLoop(session,
CFRunLoopGetCurrent(),
kCFRunLoopDefaultMode);
CFRunLoopRunInMode(kCFRunLoopDefaultMode,
60 /* seconds */,
false);
DAApprovalSessionUnscheduleFromRunLoop(session,
CFRunLoopGetCurrent(),
kCFRunLoopDefaultMode);
DAUnregisterApprovalCallback(session,
DiskApproved,
NULL);
out:
if (session)
CFRelease(session);
[pool release];
return 0;
}
________________________________________________________________________
_______________________
The example appears to work but I'm noticing the call to
DADiskMountWithArguments() from the callback function seems to
trigger the approval process for the same partition.
I've look at suggested solution to my mount issue and a manual
solution is not acceptable or the use of the fstab file because it
cannot be guaranteed that it exists or that the content will be correct.
It has been suggested that example code does exist however no one has
point me to or provided me with any sample code that shows usage of
these functions.
Also, it seems that calling DADiskMount() or DADiskMountWithArguments
() from within my callback function seem to trigger the approval
process again
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden