1/*	$NetBSD: linux_types.h,v 1.10.14.1 2009/01/11 00:17:51 christos Exp $ */
2
3/*-
4 * Copyright (c) 1995, 1998, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden, Eric Haszlakiewicz and Emmanuel Dreyfus.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _MIPS_LINUX_TYPES_H
33#define _MIPS_LINUX_TYPES_H
34
35/*
36 * from Linux's include/asm-mips/posix-types.h
37 */
38typedef int linux_uid_t;
39typedef int linux_gid_t;
40typedef unsigned int linux_dev_t;
41typedef unsigned int linux_mode_t;
42typedef long linux_time_t;
43typedef long linux_suseconds_t;
44typedef long linux_clock_t;
45typedef long linux_off_t;
46typedef int linux_pid_t;
47#if defined(ELFSIZE) && (ELFSIZE == 64)
48typedef unsigned int linux_ino_t;
49typedef unsigned int linux_nlink_t;
50typedef unsigned long linux_ino_t32;
51typedef int linux_nlink_t32;
52#else
53typedef unsigned long linux_ino_t;
54typedef int linux_nlink_t;
55typedef linux_ino_t linux_ino_t32;
56typedef linux_nlink_t linux_nlink_t32;
57#endif
58
59/*
60 * From Linux's include/asm-mips/termbits.h
61 */
62typedef unsigned char linux_cc_t;
63#if defined(ELFSIZE) && (ELFSIZE == 64)
64typedef unsigned int linux_speed_t;
65typedef unsigned int linux_tcflag_t;
66#else
67typedef unsigned long linux_speed_t;
68typedef unsigned long linux_tcflag_t;
69#endif
70
71#if defined(ELFSIZE) && (ELFSIZE == 64)
72/*
73 * From Linux's include/asm-mips64/stat.h
74 * 64 bit version of struct linux_stat memory layout is the
75 * same as of struct stat64 of the 32-bit Linux kernel
76 */
77struct linux_stat {
78	linux_dev_t	lst_dev;
79	unsigned int	lst_pad0[3];
80	unsigned long	lst_ino;
81	linux_mode_t	lst_mode;
82	linux_nlink_t	lst_nlink;
83	linux_uid_t	lst_uid;
84	linux_gid_t	lst_gid;
85	linux_dev_t	lst_rdev;
86	unsigned int	lst_pad1[3];
87	linux_off_t	lst_size;
88	unsigned int	lst_atime;
89	unsigned int	lreserved0;
90	unsigned int	lst_mtime;
91	unsigned int	lreserved1;
92	unsigned int	lst_ctime;
93	unsigned int	lreserved2;
94	unsigned int	lst_blksize;
95	unsigned int	lst_pad2;
96	unsigned long	lst_blocks;
97};
98
99struct stat32 {
100	linux_dev_t	lst_dev;
101 	int		lst_pad1[3];
102 	linux_ino_t32	lst_ino;
103 	linux_mode_t	lst_mode;
104 	linux_nlink_t32	lst_nlink;
105 	linux_uid_t	lst_uid;
106 	linux_gid_t	lst_gid;
107 	linux_dev_t	lst_rdev;
108 	int		lst_pad2[2];
109 	linux_off_t	lst_size;
110 	int		lst_pad3;
111 	linux_time_t	lst_atime;
112 	int		lreserved0;
113 	linux_time_t	lst_mtime;
114 	int		lreserved1;
115 	linux_time_t	lst_ctime;
116 	int		lreserved2;
117 	int		lst_blksize;
118 	int		lst_blocks;
119 	int		lst_pad4[14];
120};
121#else
122/*
123 * This matches struct stat64 in glibc2.1, hence the absolutely
124 * insane amounts of padding around dev_t's.
125 *
126 * Still from Linux's include/asm-mips/stat.h
127 */
128struct linux_stat64 {
129	unsigned long	lst_dev;
130	unsigned long	lst_pad0[3];
131	unsigned long long lst_ino;
132#define lst_ino64 lst_ino
133	linux_mode_t	lst_mode;
134	linux_nlink_t	lst_nlink;
135	linux_uid_t	lst_uid;
136	linux_gid_t	lst_gid;
137	unsigned long	lst_rdev;
138	unsigned long	lst_pad1[3];
139	long long	lst_size;
140	linux_time_t	lst_atime;
141	unsigned long 	lreserved0;
142	linux_time_t	lst_mtime;
143	unsigned long 	lreserved1;
144	linux_time_t	lst_ctime;
145	unsigned long 	lreserved2;
146	unsigned long	lst_blksize;
147	long long 	lst_blocks;
148};
149
150/*
151 * struct linux_stat is defined in Linux's include/asm-mips/stat.h
152 * There is also a old_kernel_stat in Linux
153 */
154struct linux_stat {
155	linux_dev_t	lst_dev;
156	long		lst_pad[3];
157	linux_ino_t32	lst_ino;
158	linux_mode_t	lst_mode;
159	linux_nlink_t32	lst_nlink;
160	linux_uid_t	lst_uid;
161	linux_gid_t	lst_gid;
162	linux_dev_t	lst_rdev;
163	long		lst_pad2[2];
164	linux_off_t	lst_size;
165	long		lst_pad3;
166	linux_time_t	lst_atime;
167	long		lreserved0;
168	linux_time_t	lst_mtime;
169	long		lreserved1;
170	linux_time_t	lst_ctime;
171	long		lreserved2;
172	long		lst_blksize;
173	long		lst_blocks;
174	char		lst_fstype[16];
175	long		lst_pad4[8];
176	unsigned int	lst_flags;
177	unsigned int	lst_gen;
178};
179#endif
180
181#endif /* !_MIPS_LINUX_TYPES_H */
182