kernel: Adjust some comments to the unionfs removal.
[dragonfly.git] / include / utmpx.h
CommitLineData
59a92d18
AH
1/*-
2 * Copyright (c) 2002 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Christos Zoulas.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef _UTMPX_H_
31#define _UTMPX_H_
32
33#include <sys/cdefs.h>
34#include <sys/socket.h>
35#include <sys/time.h>
36
37#define _PATH_UTMPX "/var/run/utmpx"
38#define _PATH_WTMPX "/var/log/wtmpx"
39#define _PATH_LASTLOGX "/var/log/lastlogx"
40#define _PATH_UTMP_UPDATE "/usr/libexec/utmp_update"
41
42#define _UTX_USERSIZE 32
43#define _UTX_LINESIZE 32
44#define _UTX_IDSIZE 4
45#define _UTX_HOSTSIZE 256
46
47#define UTX_USERSIZE _UTX_USERSIZE
48#define UTX_LINESIZE _UTX_LINESIZE
49#define UTX_IDSIZE _UTX_IDSIZE
50#define UTX_HOSTSIZE _UTX_HOSTSIZE
51
52
53#define EMPTY 0
69df205f 54#if __BSD_VISIBLE
59a92d18 55#define RUN_LVL 1
69df205f 56#endif
59a92d18
AH
57#define BOOT_TIME 2
58#define OLD_TIME 3
59#define NEW_TIME 4
60#define INIT_PROCESS 5
61#define LOGIN_PROCESS 6
62#define USER_PROCESS 7
63#define DEAD_PROCESS 8
64
65#define ACCOUNTING 9
66#define SIGNATURE 10
67#define DOWN_TIME 11
68
69/*
70 * Strings placed in the ut_line field to indicate special type entries
71 */
72#define RUNLVL_MSG "run-level %c"
73#define BOOT_MSG "system boot"
74#define OTIME_MSG "old time"
75#define NTIME_MSG "new time"
76#define DOWN_MSG "system down"
77
78#define ut_user ut_name
79#define ut_xtime ut_tv.tv_sec
80
81typedef enum {
82 UTX_DB_UTMPX,
83 UTX_DB_WTMPX,
84 UTX_DB_LASTLOGX
85} utx_db_t;
86
87struct exit_status
88{
89 uint16_t e_termination; /* termination status */
90 uint16_t e_exit; /* exit status */
91};
92
93struct utmpx {
94 char ut_name[_UTX_USERSIZE]; /* login name */
95 char ut_id[_UTX_IDSIZE]; /* inittab id */
96 char ut_line[_UTX_LINESIZE]; /* tty name */
97 char ut_host[_UTX_HOSTSIZE]; /* host name */
98 uint8_t ut_unused[16]; /* reserved for future use */
99 uint16_t ut_session; /* session id used for windowing */
100 uint16_t ut_type; /* type of this entry */
101 pid_t ut_pid; /* process id creating the entry */
102 struct exit_status ut_exit; /* process termination/exit status */
103 struct sockaddr_storage ut_ss; /* address where entry was made from */
104 struct timeval ut_tv; /* time entry was created */
105 uint8_t ut_unused2[16]; /* reserved for future use */
106};
107
c4fc0030
SW
108struct lastlogx {
109 struct timeval ll_tv; /* time entry was created */
110 char ll_line[_UTX_LINESIZE]; /* tty name */
111 char ll_host[_UTX_HOSTSIZE]; /* host name */
112 struct sockaddr_storage ll_ss; /* address where entry was made from */
113};
59a92d18 114
c4fc0030 115__BEGIN_DECLS
59a92d18
AH
116void endutxent(void);
117struct utmpx *getutxent(void);
118struct utmpx *getutxid(const struct utmpx *);
119struct utmpx *getutxline(const struct utmpx *);
120struct utmpx *pututxline(const struct utmpx *);
121void setutxent(void);
122
c4fc0030 123#ifdef __BSD_VISIBLE
bdb02cd9
AH
124int _updwtmpx(const char *, const struct utmpx *);
125void updwtmpx(const char *, const struct utmpx *);
59a92d18
AH
126struct lastlogx *getlastlogx(const char *, uid_t, struct lastlogx *);
127int updlastlogx(const char *, uid_t, struct lastlogx *);
128struct utmp;
129void getutmp(const struct utmpx *, struct utmp *);
130void getutmpx(const struct utmp *, struct utmpx *);
131int utmpxname(const char *);
132int setutxdb(utx_db_t, char *);
c4fc0030
SW
133#endif
134__END_DECLS
59a92d18
AH
135
136#endif /* _UTMPX_H_ */
137