• 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: Thu, 13 May 2010 05:29:26 -0400
  • Mta-interface: amavisd-new-2.3.3 (2005-08-22) + Maia Mailguard 1.0.1 at daleenterprise.com


On May 12, 2010, at 21:20 PM, Daniel Markarian wrote:

Hey Dale,

Does /sbin/mount show "nobrowse" on 10.6?

Dan

PS: You can run the 10.6 version of /sbin/mount on 10.5 to check the state of "nobrowse" on 10.5 as well.

Hey Dan,

The 10.6.2 version of mount  doesn't run in 10.5.6.

In 10.6 it does show the nobrowse but in the left side of the finder window I can see the partition (it's grayed out) but only seems to do this if there are existing finder windows open, if all windows are closed then the partitions are not visible at all.

Depending on the existence of the fstab file to do the hiding is a poor solution since I cannot guarantee the user will plug the drive only into systems that have it.

Using DiskArbitration seems to offer the results I need so I started coding a little test app but due to the lack of sample code I'm not sure I'm doing any of it properly since it segfaults when I use DADiskMountWithArguments().

Here's the code:

// test_mount.m
// gcc -Wall -o test_mount test_mount.m -framework DiskArbitration - framework Foundation


#import <Foundation/Foundation.h>
#import <DiskArbitration/DiskArbitration.h>

#define _NO_ARGS_		1

/* guessing due to lack of sample code */
DADissenterRef
MountDiskHidden(DADiskRef disk, void *context)
{
	char const *CdiskName = DADiskGetBSDName(disk);
	NSString *diskName = [NSString stringWithUTF8String:CdiskName];
	NSRange s1s1NumberRange = NSMakeRange([diskName length] - 4, 4);
	DADissenterRef dissenter;
	char *type;

if([[diskName substringWithRange:s1s1NumberRange] isEqualToString:@"s1s1"]) /* it's our magic partition */
{


#if _NO_ARGS_
DADiskMount(disk,
NULL,
kDADiskMountOptionDefault,
NULL,
NULL);
#else
CFStringRef arguments = CFStringCreateWithCString (kCFAllocatorDefault, "nobrowse", kCFStringEncodingUTF8);


		/* using this causes a segfault */
		DADiskMountWithArguments(disk,
								NULL,
								kDADiskMountOptionDefault,
								NULL,
								NULL,
								&arguments);
#endif

		dissenter = DADissenterCreate(kCFAllocatorDefault,
									kDAReturnSuccess,
									CFSTR("mounted hidden"));

		type = "mounted hidden";
	}
	else
	{
		DADiskMount(disk,
					NULL,
					kDADiskMountOptionDefault,
					NULL,
					NULL);

		dissenter = DADissenterCreate(kCFAllocatorDefault,
									kDAReturnSuccess,
									CFSTR("mount not permitted"));

		type = "mounted normal";
	}

	printf("%s: %s\n", CdiskName, type);

	return dissenter;
}

/* This should really be daemonized but should suffice for test purposes */
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
										MountDiskHidden,
										NULL); // context

	DAApprovalSessionScheduleWithRunLoop(session,
										 CFRunLoopGetCurrent(),
										 kCFRunLoopDefaultMode);

	CFRunLoopRunInMode(kCFRunLoopDefaultMode,
						45 /* seconds */,
						false);

	DAApprovalSessionUnscheduleFromRunLoop(session,
										 CFRunLoopGetCurrent(),
										 kCFRunLoopDefaultMode);

	DAUnregisterApprovalCallback(session,
								MountDiskHidden,
								NULL);

out:
   if (session)
		CFRelease(session);

    [pool release];

	exit(0);
}

_______________________________________________
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


  • Follow-Ups:
    • Re: auto mounting a partition with nobrowse
      • From: Chris Suter <email@hidden>
    • Re: auto mounting a partition with nobrowse
      • From: Daniel Markarian <email@hidden>
    • Re: auto mounting a partition with nobrowse
      • From: Kevin Elliott <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>)

  • Prev by Date: Re: auto mounting a partition with nobrowse
  • Next by Date: Re: auto mounting a partition with nobrowse
  • Previous by thread: Re: auto mounting a partition with nobrowse
  • Next by thread: Re: auto mounting a partition with nobrowse
  • Index(es):
    • Date
    • Thread