Revision 11115,
1.5 KB
checked in by ghudson, 26 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r11114,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
1 | /* |
---|
2 | * Copyright (c) 1992-1996 Michael A. Cooper. |
---|
3 | * This software may be freely used and distributed provided it is not sold |
---|
4 | * for profit or used for commercial gain and the author is credited |
---|
5 | * appropriately. |
---|
6 | */ |
---|
7 | |
---|
8 | #ifndef lint |
---|
9 | static char *RCSid = "$Id: getkernver.c,v 1.1.1.2 1998-02-12 21:32:05 ghudson Exp $"; |
---|
10 | #endif |
---|
11 | |
---|
12 | |
---|
13 | /* |
---|
14 | * Kernel related functions. |
---|
15 | */ |
---|
16 | |
---|
17 | #include "defs.h" |
---|
18 | |
---|
19 | #if !defined(VERSION_SYM) |
---|
20 | # define VERSION_SYM "_version" |
---|
21 | #endif |
---|
22 | |
---|
23 | /* |
---|
24 | * Get kernel version string by reading the |
---|
25 | * symbol "version" from the kernel. |
---|
26 | */ |
---|
27 | extern char *GetKernVerSym() |
---|
28 | { |
---|
29 | nlist_t *nlptr; |
---|
30 | static char Buf[BUFSIZ]; |
---|
31 | register char *p; |
---|
32 | kvm_t *kd; |
---|
33 | |
---|
34 | if (kd = KVMopen()) { |
---|
35 | if ((nlptr = KVMnlist(kd, VERSION_SYM, (nlist_t *)NULL, 0)) == NULL) |
---|
36 | return((char *) NULL); |
---|
37 | |
---|
38 | if (CheckNlist(nlptr)) |
---|
39 | return((char *) NULL); |
---|
40 | |
---|
41 | if (KVMget(kd, nlptr->n_value, (char *) Buf, sizeof(Buf), KDT_STRING)){ |
---|
42 | if (Debug) Error("Read of \"%s\" from kernel failed.", |
---|
43 | VERSION_SYM); |
---|
44 | Buf[0] = C_NULL; |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | if (kd) |
---|
49 | KVMclose(kd); |
---|
50 | |
---|
51 | #if defined(KERNSTR_END) |
---|
52 | /* |
---|
53 | * Truncate extraneous info |
---|
54 | */ |
---|
55 | if (Buf[0]) |
---|
56 | if ((p = strchr(Buf, KERNSTR_END)) != NULL) |
---|
57 | *p = C_NULL; |
---|
58 | #endif /* KERNSTR_END */ |
---|
59 | |
---|
60 | return( (Buf[0]) ? Buf : (char *) NULL); |
---|
61 | } |
---|
62 | |
---|
63 | /* |
---|
64 | * Get kernel version string |
---|
65 | */ |
---|
66 | extern char *GetKernVer() |
---|
67 | { |
---|
68 | extern PSI_t GetKernVerPSI[]; |
---|
69 | static char *Str = NULL; |
---|
70 | |
---|
71 | if (Str) |
---|
72 | return(Str); |
---|
73 | |
---|
74 | return(Str = PSIquery(GetKernVerPSI)); |
---|
75 | } |
---|
76 | |
---|
Note: See
TracBrowser
for help on using the repository browser.