FreeBSD/Linux Kernel Cross Reference
sys/compat/sys/stat.h
1 /* $NetBSD: stat.h,v 1.3 2007/12/12 21:17:57 dsl Exp $ */
2
3 /*-
4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)stat.h 8.12 (Berkeley) 8/17/94
37 */
38
39 #ifndef _COMPAT_SYS_STAT_H_
40 #define _COMPAT_SYS_STAT_H_
41
42 #ifdef _KERNEL
43 struct stat43 { /* BSD-4.3 stat struct */
44 u_int16_t st_dev; /* inode's device */
45 u_int32_t st_ino; /* inode's number */
46 u_int16_t st_mode; /* inode protection mode */
47 u_int16_t st_nlink; /* number of hard links */
48 u_int16_t st_uid; /* user ID of the file's owner */
49 u_int16_t st_gid; /* group ID of the file's group */
50 u_int16_t st_rdev; /* device type */
51 int32_t st_size; /* file size, in bytes */
52 struct timespec st_atimespec;/* time of last access */
53 struct timespec st_mtimespec;/* time of last data modification */
54 struct timespec st_ctimespec;/* time of last file status change */
55 int32_t st_blksize; /* optimal blocksize for I/O */
56 int32_t st_blocks; /* blocks allocated for file */
57 u_int32_t st_flags; /* user defined flags for file */
58 u_int32_t st_gen; /* file generation number */
59 };
60 #endif /* defined(_KERNEL) */
61
62 struct stat12 { /* NetBSD-1.2 stat struct */
63 dev_t st_dev; /* inode's device */
64 u_int32_t st_ino; /* inode's number */
65 u_int16_t st_mode; /* inode protection mode */
66 u_int16_t st_nlink; /* number of hard links */
67 uid_t st_uid; /* user ID of the file's owner */
68 gid_t st_gid; /* group ID of the file's group */
69 dev_t st_rdev; /* device type */
70 struct timespec st_atimespec;/* time of last access */
71 struct timespec st_mtimespec;/* time of last data modification */
72 struct timespec st_ctimespec;/* time of last file status change */
73 off_t st_size; /* file size, in bytes */
74 int64_t st_blocks; /* blocks allocated for file */
75 u_int32_t st_blksize; /* optimal blocksize for I/O */
76 u_int32_t st_flags; /* user defined flags for file */
77 u_int32_t st_gen; /* file generation number */
78 int32_t st_lspare;
79 int64_t st_qspare[2];
80 };
81
82 /*
83 * On systems with 8 byte longs and 4 byte time_ts, padding the time_ts
84 * is required in order to have a consistent ABI. This is because the
85 * stat structure used to contain timespecs, which had different
86 * alignment constraints than a time_t and a long alone. The padding
87 * should be removed the next time the stat structure ABI is changed.
88 * (This will happen whever we change to 8 byte time_t.)
89 */
90 #if defined(_LP64) /* XXXX && _BSD_TIME_T_ == int */
91 #define __STATPAD(x) int x;
92 #else
93 #define __STATPAD(x) /* nothing */
94 #endif
95
96 struct stat13 {
97 dev_t st_dev; /* inode's device */
98 uint32_t st_ino; /* inode's number */
99 mode_t st_mode; /* inode protection mode */
100 nlink_t st_nlink; /* number of hard links */
101 uid_t st_uid; /* user ID of the file's owner */
102 gid_t st_gid; /* group ID of the file's group */
103 dev_t st_rdev; /* device type */
104 #if defined(_NETBSD_SOURCE)
105 struct timespec st_atimespec;/* time of last access */
106 struct timespec st_mtimespec;/* time of last data modification */
107 struct timespec st_ctimespec;/* time of last file status change */
108 #else
109 __STATPAD(__pad0)
110 time_t st_atime; /* time of last access */
111 __STATPAD(__pad1)
112 long st_atimensec; /* nsec of last access */
113 time_t st_mtime; /* time of last data modification */
114 __STATPAD(__pad2)
115 long st_mtimensec; /* nsec of last data modification */
116 time_t st_ctime; /* time of last file status change */
117 __STATPAD(__pad3)
118 long st_ctimensec; /* nsec of last file status change */
119 #endif
120 off_t st_size; /* file size, in bytes */
121 blkcnt_t st_blocks; /* blocks allocated for file */
122 blksize_t st_blksize; /* optimal blocksize for I/O */
123 u_int32_t st_flags; /* user defined flags for file */
124 u_int32_t st_gen; /* file generation number */
125 u_int32_t st_spare0;
126 #if defined(_NETBSD_SOURCE)
127 struct timespec st_birthtimespec;
128 #else
129 time_t st_birthtime;
130 __STATPAD(__pad4)
131 long st_birthtimensec;
132 #endif
133 #if !defined(_LP64)
134 int __pad5;
135 #endif
136 };
137
138 #if defined(_KERNEL)
139 void compat_12_stat_conv(const struct stat *st, struct stat12 *ost);
140 #endif
141
142 #if !defined(_KERNEL) && !defined(_STANDALONE)
143
144 __BEGIN_DECLS
145 int stat(const char *, struct stat12 *);
146 int fstat(int, struct stat12 *);
147 int __stat13(const char *, struct stat13 *);
148 int __fstat13(int, struct stat13 *);
149 int __stat30(const char *, struct stat *);
150 int __fstat30(int, struct stat *);
151 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
152 int lstat(const char *, struct stat12 *);
153 int __lstat13(const char *, struct stat13 *);
154 int __lstat30(const char *, struct stat *);
155 #endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
156 __END_DECLS
157
158 #endif /* !_KERNEL && !_STANDALONE */
159 #endif /* !_COMPAT_SYS_STAT_H_ */
Cache object: 17f6cd0912a11637f6c61f16b8ebcbb2
|