1 /* The `struct utmp' type, describing entries in the utmp file. 2 Copyright (C) 1993-2022 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 <https://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 #if __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] 63 __attribute_nonstring__; /* Devicename. */ 64 char ut_id[4] 65 __attribute_nonstring__; /* Inittab ID. */ 66 char ut_user[UT_NAMESIZE] 67 __attribute_nonstring__; /* Username. */ 68 char ut_host[UT_HOSTSIZE] 69 __attribute_nonstring__; /* Hostname for remote login. */ 70 struct exit_status ut_exit; /* Exit status of a process marked 71 as DEAD_PROCESS. */ 72 /* The ut_session and ut_tv fields must be the same size when compiled 73 32- and 64-bit. This allows data files and shared memory to be 74 shared between 32- and 64-bit applications. */ 75 #if __WORDSIZE_TIME64_COMPAT32 76 int32_t ut_session; /* Session ID, used for windowing. */ 77 struct 78 { 79 int32_t tv_sec; /* Seconds. */ 80 int32_t tv_usec; /* Microseconds. */ 81 } ut_tv; /* Time entry was made. */ 82 #else 83 long int ut_session; /* Session ID, used for windowing. */ 84 struct timeval ut_tv; /* Time entry was made. */ 85 #endif 86 87 int32_t ut_addr_v6[4]; /* Internet address of remote host. */ 88 char __glibc_reserved[20]; /* Reserved for future use. */ 89 }; 90 91 /* Backwards compatibility hacks. */ 92 #define ut_name ut_user 93 #ifndef _NO_UT_TIME 94 /* We have a problem here: `ut_time' is also used otherwise. Define 95 _NO_UT_TIME if the compiler complains. */ 96 # define ut_time ut_tv.tv_sec 97 #endif 98 #define ut_xtime ut_tv.tv_sec 99 #define ut_addr ut_addr_v6[0] 100 101 102 /* Values for the `ut_type' field of a `struct utmp'. */ 103 #define EMPTY 0 /* No valid user accounting information. */ 104 105 #define RUN_LVL 1 /* The system's runlevel. */ 106 #define BOOT_TIME 2 /* Time of system boot. */ 107 #define NEW_TIME 3 /* Time after system clock changed. */ 108 #define OLD_TIME 4 /* Time when system clock changed. */ 109 110 #define INIT_PROCESS 5 /* Process spawned by the init process. */ 111 #define LOGIN_PROCESS 6 /* Session leader of a logged in user. */ 112 #define USER_PROCESS 7 /* Normal process. */ 113 #define DEAD_PROCESS 8 /* Terminated process. */ 114 115 #define ACCOUNTING 9 116 117 /* Old Linux name for the EMPTY type. */ 118 #define UT_UNKNOWN EMPTY 119 120 121 /* Tell the user that we have a modern system with UT_HOST, UT_PID, 122 UT_TYPE, UT_ID and UT_TV fields. */ 123 #define _HAVE_UT_TYPE 1 124 #define _HAVE_UT_PID 1 125 #define _HAVE_UT_ID 1 126 #define _HAVE_UT_TV 1 127 #define _HAVE_UT_HOST 1 128