Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: IOUSBFamily or OS Version from kernel space
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IOUSBFamily or OS Version from kernel space



Even easier, you can use the following globals (present in all versions of Mac OS X, and now with prototypes in Tiger!).
You should be able to just check for version_major==7 (corresponds to 10.3.*) and version_minor==7


extern const int version_major;
extern const int version_minor;
extern const char version_variant[];

/* osrelease, is a string as returned by uname -r */
extern const char osrelease[];

/* version is a string of the following form, as returned by uname -v:
* "Darwin Kernel Version <osrelease>: <build date>; <osbuilder>:<build root>"
*/
extern const char version[];

Cheers, - Dean


On Jan 28, 2005, at 2:31 PM, Stuart Smith wrote:

Dean,

I don't really want to use an unsupported function; if I know I only need to
do this on 10.3, I'd need to know the OS version anyway, putting me in a
chicken and egg situation.


I could use sysctl to find the Darwin version (as a string), could I not?
sysctl is callable from the kernel, isn't it?


#include <sys/types.h>#include <sys/sysctl.h>

int mib[3] = { CTL_KERN, KERN_OSRELEASE, 0 };
size_t len = 0;
char * p = NULL;

sysctl(mib, 2, NULL, &len, NULL, 0);
p = malloc(len);
sysctl(mib, 2, p, &len, NULL, 0);

on return, p will point at "7.7.0" for Mac OS 10.3.7.

The number kern.osrevision = 199506 may be more useful, but I've no idea how
that number correlates with OS revision.


what are those compiled-in globals I was thinking of? I don't know what
header they are in. Perhaps they'd give me a more direct way of determining
the system version.


Stuart

on 1/28/05 1:34 PM, Dean Reece at xxxx wrote:

"from kernel space"
I should have read the title more carefully.  There isn't a supported
way to do this for loaded kexts.  The compiled-in globals you are
thinking of only cover the kernel and it's major sections, not
families.

The UNsupported way to do this is to use kmod_lookupbyname(), which is
available on Panther and Tiger, but will go away in the future.  Since
it isn't a public function, you'll have to look at Darwin xnu to get
the prototype and calling conventions for it.
- Dean

On Jan 28, 2005, at 1:24 PM, Dean Reece wrote:

On Mac OS X, the USB Family is not compiled into the kernel; it is
loaded as a kernel extension (kext).
You can find the versions of all loaded kexts via the kextstat command.
The kexts that show a load address of 0x0 represent compiled-in code.
All other kexts are loaded.


Cheesr,
 - Dean


On Jan 28, 2005, at 12:57 PM, Stuart Smith wrote:
how do I find the version of the IOUSBFamily which is currently in the
kernel (either as a version number or a string like "214.4.5".


Alternatively, can I find the OS Version as an NumVersion or as a
string
e.g. "10.3.7"

I believe some information of this kind is compiled-in as kernel
globals,
but I can't find any documentation for them, I only vaguely remember
that
someone may have mentioned them on a list...

TIA, Stuart




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-drivers mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden

_______________________________________________ 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
References: 
 >Re: IOUSBFamily or OS Version from kernel space (From: Stuart Smith <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.