Re: How to suppress mounting externally attached disks temporarily
Re: How to suppress mounting externally attached disks temporarily
- Subject: Re: How to suppress mounting externally attached disks temporarily
- From: Karl Kuehn <email@hidden>
- Date: Mon, 4 May 2009 14:19:06 -0700
On May 4, 2009, at 10:50 AM, Thomas Tempelmann wrote:
For a data rescue tool I'm writing (iBored) I like to add the feature
to suppress mounting (and modifying, including auto-repair) of
just-attached disks.
I want the disk be read by the system, and have no problem with its
partitions being added to /dev/
But I don't want to allow any writing to it, if my app demands it.
So, either suppressing automount entirely, or forcing read-only
mounts, is what I need.
The UUID and name of the volumes on the disk are not known, so adding
exceptions to the fstab file is not an option, I think.
The old Mac OS made this easy: Simply get into a modal event polling
loop and swallow the "disk insert" event. With OS X, this isn't
possible any more. So, what's the trick to do this now?
I just had to do something of the same thing, but was looking for
only disks on a list. The solution I came up with is as follows (and
is working well):
1) Hook in with DAApprovalSessionRef
2) When a mount request comes in, put it on a list of things I want to
approve, deny it, and set a callback to re-mount a second later with
the options I want
3) When the second mount request comes through, allow it in
A second variant that I thought of:
1) Hook in with DAApprovalSessionRef
2) Deny any mount request that comes in, set a callback to mount it
with the options that you want, but this time call it with
"kDADiskOptionPrivate", that should punch around your block.
i found this all a little awkward (since mostly I just wanted to
control the mount point, the one item that does not make it into a
DAApprovalSession), but it does work.
--
Karl Kuehn
email@hidden
_______________________________________________
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