On Fri, 29 Apr 2005, Mike Smith wrote:
>
> On Apr 29, 2005, at 10:18 AM, John Dalgliesh wrote:
>
> > Here is maybe the first legitimate Tiger question! Although the
> > readers
> > of this list will be the judge of its legitimacy I'm sure :)
>
> If it were on the right list (darwin-kernel) you'd be spot-on. 8)
Whoops. I'll go and subscribe to that one right now then :)
> > Short version: How do i get or create a vfs_context?
>
> It depends on why you want one; typically they're generated by the
> system
> call layer, and so you're not calling something that needs one unless
> you
> already have one.
I see. So it is meant for kernel developers wishing to write their own
file systems, not for driver developers wishing to access the file system.
And that's why I'm on the wrong list :)
> It's important to understand what the vfs_context_t actually is; it
> encapsulates
> the context in which the VFS operation is being performed. That is,
> it holds
> useful things such as the credential, the address space reference and
> so forth
> that the operation is being performed against.
>
> This makes it practical for arbitrary threads to do VFS-related work
> for a third
> party, without having to pass of that around as arguments.
That was pretty much what I'd guessed.
> If you need a vfs_context_t for the current context, you can call
> vfs_context_create()
> with a NULL context argument. The context argument allows you to
> create a
> new context from one passed to you - typically vfs_context_t's are only
> valid for the duration of the function call, so if you need to hold
> one for longer
> (e.g. you're going to pass it off to a worker thread) you need to
> create a new one
> that contains the same information.
Excellent, thankyou. I should have just tried passing in NULL! I've now
got my firmware-file-reading code working again - once I realised that the
vnode lock shouldn't be taken when doing a read - and released a new
version of my driver package.
I have to say that the lack of funnels in the KPI is fantastic. And if it
means for the user that all disk access no longer blocks when one disk is
spinning up, then IMHO all the work that must have gone into finer grained
locking will have been well worthwhile ('tho I haven't tested this yet :)
Some random notes for others updating their drivers for Tiger:
- In your OSBundleLibraries array, you can't mix the new com.apple.kpi.xxx
pseudo-bundles with the old com.apple.kernel.xxx ones (where xxx is iokit,
bsd, mach, etc). They overlap, so just choose one style.
- I had to add "-fabi-version=1" to my GCC flags to be able to use C++
new/delete with GCC 4.0 (this might be common knowledge but wasn't to me).
- The addition to IOUSBPipe of the Read method that takes a
IOUSBCompletionWithTimeStamp aliases the one that takes a plain
IOUSBCompletion. If you are trying to call them synchronously, you will
have to cast your NULL completion pointer to one of those types or gcc
will complain about the ambiguity.
- com.apple.kpi.unsupported does NOT contain the difference between all
the other kpi's and com.apple.kernel. e.g. for me, vnode_lock and
vnode_unlock are missing from there. Conversely, com.apple.kernel will not
give you any indirect symbols like IOLockLock and IOLockUnlock that are
defined in the individual pseudo-bundles.
- All the functions in the headers in Kernel.framework are not in the KPI
bundles (vnode_[un]lock again). There are some functions in the KPI
bundles that are not in the headers (vn_rdwr). If you are unsure whether
or not the kext linker will link your function, you best bet is just to
use 'nm' on the bundle and see if the symbol is there.
OK that's enough from me for now I think :)
> = Mike
{P^/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-drivers mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden