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