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