Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: getting process info for a kext
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting process info for a kext

At 13:33 -0700 10/6/03, Chris Silverberg wrote:
I have an existing kext that needs to be modified slightly to look at
process information.

The most supportable answer to this is to move the code that needs to do the sysctl into user space. Might it be possible to do that part of the work in user space?

Failing that, my next question is, what context is your KEXT running in? Doing any sysctl work will require you to acquire the BSD system funnel. If you're running in the context of an I/O Kit driver, you're probably not holding any funnels. If you're running in an NKE, you're probably holding the wrong (network) funnel.

Even if you're holding the right funnel, I don't think this is going to work. sysctl expects to copy its data in to and out of the user memory space of the current thread. Take a look at sysctl_int in "xnu/bsd/kern/kern_sysctl.c"; see how it blindly calls copyin/copyout.

I believe that the traditional approach for accessing sysctl-like things in the kernel is to just access the variables directly. sysctl is specifically designed to allow user space code access to these variables. It doesn't make a lot of sense to call it from kernel code in the traditional UNIX model.

OTOH, now that we're concerned about binary compatibility for kernel extensions it might make sense to support sysctl from kernel code. Something to think about when we publish the Kernel Programming Interfaces (KPI) specification for developer comment.

Quinn "The Eskimo!" <>
Apple Developer Technical Support * Networking, Communications, Hardware
darwin-kernel mailing list | email@hidden
Do not post admin requests to the list. They will be ignored.

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.