• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: auto mounting a partition with nobrowse
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: auto mounting a partition with nobrowse


  • Subject: Re: auto mounting a partition with nobrowse
  • From: websrvr <email@hidden>
  • Date: Fri, 14 May 2010 08:23:42 -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 = "mounted hidden";
	}
	else
	{
		/* allow normal mounting */
		dissenter = NULL;

		type = "mounted normal";
	}

	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 when calling DADiskMountWithArguments() from the callback function it seems to trigger the approval process for the same partition, is there something I need to do to prevent this?


Also, is it possible to change the mountroot rather than specifying a mountpoint???

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 or even a link to any sample code and google is pretty useless.

-- Dale
_______________________________________________
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


References: 
 >auto mounting a partition with nobrowse (From: websrvr <email@hidden>)
 >Re: auto mounting a partition with nobrowse (From: Daniel Markarian <email@hidden>)
 >Re: auto mounting a partition with nobrowse (From: websrvr <email@hidden>)
 >Re: auto mounting a partition with nobrowse (From: Daniel Markarian <email@hidden>)
 >Re: auto mounting a partition with nobrowse (From: websrvr <email@hidden>)
 >Re: auto mounting a partition with nobrowse (From: Daniel Markarian <email@hidden>)
 >Re: auto mounting a partition with nobrowse (From: websrvr <email@hidden>)
 >Re: auto mounting a partition with nobrowse (From: Chris Suter <email@hidden>)
 >Re: auto mounting a partition with nobrowse (From: websrvr <email@hidden>)

  • Prev by Date: Re: auto mounting a partition with nobrowse
  • Next by Date: DARegisterDiskMountApprovalCallback() behavior
  • Previous by thread: Re: auto mounting a partition with nobrowse
  • Next by thread: Any updated information to "FileID race detected" email thread?
  • Index(es):
    • Date
    • Thread