| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Licensed Materials - Property of IBM | 3 * Licensed Materials - Property of IBM |
| 4 * | 4 * |
| 5 * trousers - An open source TCG Software Stack | 5 * trousers - An open source TCG Software Stack |
| 6 * | 6 * |
| 7 * (C) Copyright International Business Machines Corp. 2004, 2005 | 7 * (C) Copyright International Business Machines Corp. 2004, 2005 |
| 8 * | 8 * |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 | 11 |
| 12 #if (defined (__FreeBSD__) || defined (__OpenBSD__)) | 12 #if (defined (__FreeBSD__) || defined (__OpenBSD__)) |
| 13 #include <sys/param.h> | 13 #include <sys/param.h> |
| 14 #include <sys/sysctl.h> | 14 #include <sys/sysctl.h> |
| 15 #include <err.h> | 15 #include <err.h> |
| 16 #elif (defined (__linux) || defined (linux)) | 16 #elif (defined (__linux) || defined (linux) || defined(__GLIBC__)) |
| 17 #include <utmp.h> | 17 #include <utmp.h> |
| 18 #elif (defined (SOLARIS)) | 18 #elif (defined (SOLARIS)) |
| 19 #include <utmpx.h> | 19 #include <utmpx.h> |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #include <sys/time.h> | 22 #include <sys/time.h> |
| 23 #include <stdlib.h> | 23 #include <stdlib.h> |
| 24 #include <stdio.h> | 24 #include <stdio.h> |
| 25 #include <string.h> | 25 #include <string.h> |
| 26 | 26 |
| 27 #include "trousers/tss.h" | 27 #include "trousers/tss.h" |
| 28 #include "trousers_types.h" | 28 #include "trousers_types.h" |
| 29 #include "tcs_tsp.h" | 29 #include "tcs_tsp.h" |
| 30 #include "tcs_int_literals.h" | 30 #include "tcs_int_literals.h" |
| 31 #include "capabilities.h" | 31 #include "capabilities.h" |
| 32 #include "tcsps.h" | 32 #include "tcsps.h" |
| 33 #include "tcslog.h" | 33 #include "tcslog.h" |
| 34 | 34 |
| 35 | 35 |
| 36 #if (defined (__linux) || defined (linux)) | 36 #if (defined (__linux) || defined (linux) || defined(__GLIBC__)) |
| 37 MUTEX_DECLARE_INIT(utmp_lock); | 37 MUTEX_DECLARE_INIT(utmp_lock); |
| 38 | 38 |
| 39 char | 39 char |
| 40 platform_get_runlevel() | 40 platform_get_runlevel() |
| 41 { | 41 { |
| 42 char runlevel; | 42 char runlevel; |
| 43 struct utmp ut, save, *next = NULL; | 43 struct utmp ut, save, *next = NULL; |
| 44 struct timeval tv; | 44 struct timeval tv; |
| 45 int flag = 0, counter = 0; | 45 int flag = 0, counter = 0; |
| 46 | 46 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if (utp->ut_type == RUN_LVL && | 125 if (utp->ut_type == RUN_LVL && |
| 126 sscanf(utp->ut_line, "run-level %c", &runlevel) != 1) | 126 sscanf(utp->ut_line, "run-level %c", &runlevel) != 1) |
| 127 runlevel = 'u'; | 127 runlevel = 'u'; |
| 128 endutxent(); | 128 endutxent(); |
| 129 | 129 |
| 130 MUTEX_UNLOCK(utmp_lock); | 130 MUTEX_UNLOCK(utmp_lock); |
| 131 | 131 |
| 132 return runlevel; | 132 return runlevel; |
| 133 } | 133 } |
| 134 #endif | 134 #endif |
| OLD | NEW |