xref: /onnv-gate/usr/src/lib/libbc/libc/sys/common/compat.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright (c) 1999 by Sun Microsystems, Inc.
24*0Sstevel@tonic-gate  * All rights reserved.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate #include <utmp.h>
30*0Sstevel@tonic-gate #include <sys/types.h>
31*0Sstevel@tonic-gate #include <sys/time.h>
32*0Sstevel@tonic-gate 
33*0Sstevel@tonic-gate /*
34*0Sstevel@tonic-gate  * the following value will be stuffed into "fd2", which was previously
35*0Sstevel@tonic-gate  * used to hold the fd of the utmpx or wtmpx file when the application
36*0Sstevel@tonic-gate  * attempted to open utmp or wtmp.  Since we now only support utmpx
37*0Sstevel@tonic-gate  * and wtmpx, that is always the only file we open (now as "fd").
38*0Sstevel@tonic-gate  * The magic value in the second descriptor simply tells us that
39*0Sstevel@tonic-gate  * the fd is "special", in that we have to do utmp to utmpx
40*0Sstevel@tonic-gate  * record conversions on data read or written.  The magic value
41*0Sstevel@tonic-gate  * is specifically chosen to be higher than any possible fd value
42*0Sstevel@tonic-gate  * could be in a 4.x application.
43*0Sstevel@tonic-gate  */
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate #define UTMPX_MAGIC_FLAG	512
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate /*
48*0Sstevel@tonic-gate  * 4.x utmp record format
49*0Sstevel@tonic-gate  */
50*0Sstevel@tonic-gate struct compat_utmp
51*0Sstevel@tonic-gate   {
52*0Sstevel@tonic-gate 	char	ut_line[8];		/* tty name */
53*0Sstevel@tonic-gate 	char	ut_name[8];		/* user id */
54*0Sstevel@tonic-gate 	char	ut_host[16];		/* host name, if remote */
55*0Sstevel@tonic-gate 	time_t	ut_time;		/* time on */
56*0Sstevel@tonic-gate   } ;
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate 
59*0Sstevel@tonic-gate struct exit_status
60*0Sstevel@tonic-gate {
61*0Sstevel@tonic-gate 	short e_termination;		/* termination status */
62*0Sstevel@tonic-gate 	short e_exit;			/* exit status */
63*0Sstevel@tonic-gate } ;
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate struct utmpx
66*0Sstevel@tonic-gate   {
67*0Sstevel@tonic-gate       char    ut_user[32];            /* user login name */
68*0Sstevel@tonic-gate       char    ut_id[4];               /* inittab id */
69*0Sstevel@tonic-gate       char    ut_line[32];            /* device name (console, lnxx) */
70*0Sstevel@tonic-gate       long   ut_pid;                 /* process id */
71*0Sstevel@tonic-gate       short   ut_type;                /* type of entry */
72*0Sstevel@tonic-gate       struct exit_status ut_exit;     /* process termination/exit status */
73*0Sstevel@tonic-gate       struct timeval ut_tv;           /* time entry was made */
74*0Sstevel@tonic-gate       long    ut_session;             /* session ID, used for windowing */
75*0Sstevel@tonic-gate       long    pad[5];                 /* reserved for future use */
76*0Sstevel@tonic-gate       short   ut_syslen;              /* significant length of ut_host */
77*0Sstevel@tonic-gate                                       /*   including terminating null */
78*0Sstevel@tonic-gate       char    ut_host[257];           /* remote host name */
79*0Sstevel@tonic-gate   } ;
80*0Sstevel@tonic-gate 
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate #define getmodsize(size, ftype, ttype)	\
83*0Sstevel@tonic-gate 	(((size / ftype) * ttype) + (size % ftype))
84