1 /* The `struct utmp' type, describing entries in the utmp file. GNU version. 2 Copyright (C) 1993-2012 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library; if not, see 17 <http://www.gnu.org/licenses/>. */ 18 19 #ifndef _UTMP_H 20 # error "Never include <bits/utmp.h> directly; use <utmp.h> instead." 21 #endif 22 23 #include <paths.h> 24 #include <sys/time.h> 25 #include <sys/types.h> 26 #include <bits/wordsize.h> 27 28 29 #define UT_LINESIZE 32 30 #define UT_NAMESIZE 32 31 #define UT_HOSTSIZE 256 32 33 34 /* The structure describing an entry in the database of 35 previous logins. */ 36 struct lastlog 37 { 38 #ifdef __WORDSIZE_TIME64_COMPAT32 39 int32_t ll_time; 40 #else 41 __time_t ll_time; 42 #endif 43 char ll_line[UT_LINESIZE]; 44 char ll_host[UT_HOSTSIZE]; 45 }; 46 47 48 /* The structure describing the status of a terminated process. This 49 type is used in `struct utmp' below. */ 50 struct exit_status 51 { 52 short int e_termination; /* Process termination status. */ 53 short int e_exit; /* Process exit status. */ 54 }; 55 56 57 /* The structure describing an entry in the user accounting database. */ 58 struct utmp 59 { 60 short int ut_type; /* Type of login. */ 61 pid_t ut_pid; /* Process ID of login process. */ 62 char ut_line[UT_LINESIZE]; /* Devicename. */ 63 char ut_id[4]; /* Inittab ID. */ 64 char ut_user[UT_NAMESIZE]; /* Username. */ 65 char ut_host[UT_HOSTSIZE]; /* Hostname for remote login. */ 66 struct exit_status ut_exit; /* Exit status of a process marked 67 as DEAD_PROCESS. */ 68 /* The ut_session and ut_tv fields must be the same size when compiled 69 32- and 64-bit. This allows data files and shared memory to be 70 shared between 32- and 64-bit applications. */ 71 #ifdef __WORDSIZE_TIME64_COMPAT32 72 int32_t ut_session; /* Session ID, used for windowing. */ 73 struct 74 { 75 int32_t tv_sec; /* Seconds. */ 76 int32_t tv_usec; /* Microseconds. */ 77 } ut_tv; /* Time entry was made. */ 78 #else 79 long int ut_session; /* Session ID, used for windowing. */ 80 struct timeval ut_tv; /* Time entry was made. */ 81 #endif 82 83 int32_t ut_addr_v6[4]; /* Internet address of remote host. */ 84 char __unused[20]; /* Reserved for future use. */ 85 }; 86 87 /* Backwards compatibility hacks. */ 88 #define ut_name ut_user 89 #ifndef _NO_UT_TIME 90 /* We have a problem here: `ut_time' is also used otherwise. Define 91 _NO_UT_TIME if the compiler complains. */ 92 # define ut_time ut_tv.tv_sec 93 #endif 94 #define ut_xtime ut_tv.tv_sec 95 #define ut_addr ut_addr_v6[0] 96 97 98 /* Values for the `ut_type' field of a `struct utmp'. */ 99 #define EMPTY 0 /* No valid user accounting information. */ 100 101 #define RUN_LVL 1 /* The system's runlevel. */ 102 #define BOOT_TIME 2 /* Time of system boot. */ 103 #define NEW_TIME 3 /* Time after system clock changed. */ 104 #define OLD_TIME 4 /* Time when system clock changed. */ 105 106 #define INIT_PROCESS 5 /* Process spawned by the init process. */ 107 #define LOGIN_PROCESS 6 /* Session leader of a logged in user. */ 108 #define USER_PROCESS 7 /* Normal process. */ 109 #define DEAD_PROCESS 8 /* Terminated process. */ 110 111 #define ACCOUNTING 9 112 113 /* Old Linux name for the EMPTY type. */ 114 #define UT_UNKNOWN EMPTY 115 116 117 /* Tell the user that we have a modern system with UT_HOST, UT_PID, 118 UT_TYPE, UT_ID and UT_TV fields. */ 119 #define _HAVE_UT_TYPE 1 120 #define _HAVE_UT_PID 1 121 #define _HAVE_UT_ID 1 122 #define _HAVE_UT_TV 1 123 #define _HAVE_UT_HOST 1 124