Re: Doing file io from kernel IOKit driver context, again.
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com
After searching darwin mailing lists i got a general impression that doing file io from kernel context is discouraged, especially if it is an IOKit driver context.) People mostly just say "don't do it", ask for bigger picture issues and advise an alternative which works.
Yeah, I ran into that same feedback a few weeks ago. For me, I investigated every other option ... but they all involved writing tons of code.
I experimented a bit with the following approach: 1) Pass an image file name to IOKit driver. 2) Lookup and acquire corresponding vnode through VFS layer. 3) Call VNOP_READ, VNOP_WRITE on vnode.
Personally, I think you could simplify things a bit. - vnode_open() (you're not calling VNOP_LOOKUP for each pathname component, are you?) - vn_rdwr() (you don't have to go through the trouble of building a uio structure, for one).
It seems to be working fine for me. Is there anything to look out for with this approach? Are there any other alternatives without using a VFS layer?
I think the only things you need to worry about is: - Make sure you're holding an iocount on the vnode before you call any vfs layer functons (via vnode_get() or a similar function) - Don't hold the iocount too long. --Ken _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Ken Hornstein