[jbossnative-commits] JBoss Native SVN: r979 - trunk/sight/native/os/linux.

jbossnative-commits at lists.jboss.org jbossnative-commits at lists.jboss.org
Thu Sep 6 05:12:12 EDT 2007


Author: mladen.turk at jboss.com
Date: 2007-09-06 05:12:12 -0400 (Thu, 06 Sep 2007)
New Revision: 979

Modified:
   trunk/sight/native/os/linux/main.c
Log:
Detect Linux kernel version on startup

Modified: trunk/sight/native/os/linux/main.c
===================================================================
--- trunk/sight/native/os/linux/main.c	2007-09-06 06:26:43 UTC (rev 978)
+++ trunk/sight/native/os/linux/main.c	2007-09-06 09:12:12 UTC (rev 979)
@@ -30,11 +30,16 @@
 #include "sight_types.h"
 #include "sight_private.h"
 #include <sys/sysinfo.h>
+#include <sys/utsname.h>
 #include <unistd.h>
 
 static apr_int64_t sight_ticks_ms = 0L;
 static apr_int64_t sight_ticks_us = 0L;
 
+int kernel_major = 0;
+int kernel_minor = 0;
+int kernel_patch = 0;
+
 apr_int64_t TCK2MS(apr_int64_t t)
 {
     return (t * sight_ticks_ms);
@@ -47,7 +52,18 @@
 
 apr_status_t sight_main(apr_pool_t *pool)
 {
+    struct utsname uts;
     sight_ticks_ms = 1000L    / sysconf(_SC_CLK_TCK);
     sight_ticks_us = 1000000L / sysconf(_SC_CLK_TCK);
+    int major, minor, patch;
+
+    if (!uname(&uts)) {
+        if (sscanf(uts.release, "%d.%d.%d",
+                   &kernel_major, &kernel_minor, &kernel_patch) != 3) {
+            kernel_major = 0;
+            kernel_minor = 0;
+            kernel_patch = 0;
+        }
+    }
     return APR_SUCCESS;
 }




More information about the jbossnative-commits mailing list