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