[prev in list] [next in list] [prev in thread] [next in thread] 

List:       trousers-tech
Subject:    [TrouSerS-tech] updated fix for platform.c
From:       Wyllys Ingersoll <wyllys.ingersoll () sun ! com>
Date:       2009-04-21 23:46:10
Message-ID: 49EE5AC2.6020305 () sun ! com
[Download RAW message or body]


The fix below if for src/tcsd/platform.c - this supercedes the patch
submitted earlier.  I found a few problems with it when I tried to compile.

---
Trousers' Developer's Certificate of Origin 1.0

By making a contribution to the Trousers project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

Signed-off-by: Wyllys Ingersoll <wyllys.ingersoll@sun.com>
---

diff --git a/src/tcsd/platform.c b/src/tcsd/platform.c
index 5bac0e1..5c8712d 100644
--- a/src/tcsd/platform.c
+++ b/src/tcsd/platform.c
@@ -13,7 +13,7 @@
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <err.h>
-#elif (defined (__linux) || defined (linux))
+#elif (defined (__linux) || defined (linux) || defined (SOLARIS))
 #include <utmp.h>
 #endif
 
@@ -31,7 +31,7 @@
 #include "tcslog.h"
 
 
-#if (defined (__linux) || defined (linux))
+#if (defined (__linux) || defined (linux) || defined (SOLARIS))
 MUTEX_DECLARE_INIT(utmp_lock);
 
 char
@@ -39,28 +39,40 @@ platform_get_runlevel()
 {
        char runlevel;
        struct utmp ut, save, *next = NULL;
+#ifdef SOLARIS
+       time_t tv = 0;
+#else
        struct timeval tv;
+#endif /* SOLARIS */
        int flag = 0, counter = 0;
 
        MUTEX_LOCK(utmp_lock);
 
        memset(&ut, 0, sizeof(struct utmp));
        memset(&save, 0, sizeof(struct utmp));
+#ifndef SOLARIS
        memset(&tv, 0, sizeof(struct timeval));
+#endif
 
        ut.ut_type = RUN_LVL;
 
        next = getutid(&ut);
 
        while (next != NULL) {
+#ifdef SOLARIS
+               if (next->ut_time >= tv) {
+#else
                if (next->ut_tv.tv_sec > tv.tv_sec) {
+#endif
                        memcpy(&save, next, sizeof(*next));
                        flag = 1;
+#ifndef SOLARIS
                } else if (next->ut_tv.tv_sec == tv.tv_sec) {
                        if (next->ut_tv.tv_usec > tv.tv_usec) {
                                memcpy(&save, next, sizeof(*next));
                                flag = 1;
                        }
+#endif /* SOLARIS */
                }
 
                counter++;


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
TrouSerS-tech mailing list
TrouSerS-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/trousers-tech
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic