Re: opening files in the kernel
Re: opening files in the kernel
- Subject: Re: opening files in the kernel
- From: Marek Kozubal <email@hidden>
- Date: Mon, 23 Feb 2004 19:56:50 -0500 (EST)
On Sun, 22 Feb 2004, Chris Bergmann wrote:
>
Greets,
>
>
I've been trying to open/read/write/etc a file from within a KEXT,
This is generally considered to be a *bad* idea.
>
using the vnode interface. I keep running myself into locking trouble
>
because I lack a thorough understanding of the correct procedures for
>
dealing with vnodes. I've tried a few different solutions, however
>
(apart from the odd case where it "just worked" for a while) they all
>
end up either deadlocking the vfs or causing a (locking-related) panic.
Generally if you need to read/write to files from a KEXT in mass, you use
the IOKit messages or sockets or sysctl depending on what you're doing to
a user daemon to do file IO.
>
As a basic background to where i'm coming from- I've converted Apple's
>
HFS+ code to compile with C++ and made the necessary modifications to
>
run as a KEXT; now i'm trying to create some additional "system" files.
I'm baffled why you converted this to C++, file systems are not IOKit
objects, and are generally C only entities.
>
Apple's existing system files (extents tree, etc) are treated rather
>
specially by the filesystem and I don't want to go down the same path-
>
instead I would like to open a file in much the same way as a userland
>
process would (except using the vfs directly since i'm in a KEXT.)
This is generally considered a bad thing to do. The locking issues are
complex in a file system and you can easily bypass a lot of the locking
rules by accessing these functions out of context. Its incredably easy to
leave a vnode locked somewhere and not have the system panic till much
later on.
>
I'm looking for any suggestions on how to go about this task.. or any
>
good references such as books describing the usage of the vfs would be
>
great (i purchased McKusick's 4.4 BSD OS book but it's not overly
>
helpful in this area.) Pointers to existing source from which I can
>
learn by example would also be helpful.
What are you trying to accomplish anyways? If you really are trying to
add another file to the "special" area of HFS+ in CNID's 2 though 15 then
I'd imagine you'd probably have to make your own HFS+ file system and
build that into a new kernel, or try to make it a loadable file system and
put it at a higher priority for HFS in the filesystem bundles. Either way
this can get quite annoying pretty quickly.
---
Marek Kozubal
email@hidden
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.