xref: /illumos-gate/usr/src/uts/common/sys/statvfs.h (revision dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9)
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 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #ifndef _SYS_STATVFS_H
32 #define	_SYS_STATVFS_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.10 */
35 
36 #include <sys/feature_tests.h>
37 #include <sys/types.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 /*
44  * Structure returned by statvfs(2).
45  */
46 
47 #define	_FSTYPSZ	16
48 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
49 #ifndef FSTYPSZ
50 #define	FSTYPSZ	_FSTYPSZ
51 #endif
52 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
53 
54 typedef struct statvfs {
55 	unsigned long	f_bsize;	/* fundamental file system block size */
56 	unsigned long	f_frsize;	/* fragment size */
57 	fsblkcnt_t	f_blocks;	/* total blocks of f_frsize on fs */
58 	fsblkcnt_t	f_bfree;	/* total free blocks of f_frsize */
59 	fsblkcnt_t	f_bavail;	/* free blocks avail to non-superuser */
60 	fsfilcnt_t	f_files;	/* total file nodes (inodes) */
61 	fsfilcnt_t	f_ffree;	/* total free file nodes */
62 	fsfilcnt_t	f_favail;	/* free nodes avail to non-superuser */
63 	unsigned long	f_fsid;		/* file system id (dev for now) */
64 	char		f_basetype[_FSTYPSZ];	/* target fs type name, */
65 						/* null-terminated */
66 	unsigned long	f_flag;		/* bit-mask of flags */
67 	unsigned long	f_namemax;	/* maximum file name length */
68 	char		f_fstr[32];	/* filesystem-specific string */
69 #if !defined(_LP64)
70 	unsigned long 	f_filler[16];	/* reserved for future expansion */
71 #endif
72 } statvfs_t;
73 
74 #if defined(_SYSCALL32)
75 
76 /* Kernel view of user ILP32 statvfs structure */
77 
78 typedef struct statvfs32 {
79 	uint32_t	f_bsize;	/* fundamental file system block size */
80 	uint32_t	f_frsize;	/* fragment size */
81 	fsblkcnt32_t	f_blocks;	/* total blocks of f_frsize on fs */
82 	fsblkcnt32_t	f_bfree;	/* total free blocks of f_frsize */
83 	fsblkcnt32_t	f_bavail;	/* free blocks avail to non-superuser */
84 	fsfilcnt32_t	f_files;	/* total file nodes (inodes) */
85 	fsfilcnt32_t	f_ffree;	/* total free file nodes */
86 	fsfilcnt32_t	f_favail;	/* free nodes avail to non-superuser */
87 	uint32_t	f_fsid;		/* file system id (dev for now) */
88 	char		f_basetype[_FSTYPSZ];	/* target fs type name, */
89 						/* null-terminated */
90 	uint32_t	f_flag;		/* bit-mask of flags */
91 	uint32_t	f_namemax;	/* maximum file name length */
92 	char		f_fstr[32];	/* filesystem-specific string */
93 	uint32_t	f_filler[16];	/* reserved for future expansion */
94 } statvfs32_t;
95 
96 #endif	/* _SYSCALL32 */
97 
98 /* transitional large file interface version */
99 #if defined(_LARGEFILE64_SOURCE)
100 typedef struct statvfs64 {
101 	unsigned long	f_bsize;	/* preferred file system block size */
102 	unsigned long	f_frsize;	/* fundamental file system block size */
103 	fsblkcnt64_t	f_blocks;	/* total blocks of f_frsize */
104 	fsblkcnt64_t	f_bfree;	/* total free blocks of f_frsize */
105 	fsblkcnt64_t	f_bavail;	/* free blocks avail to non-superuser */
106 	fsfilcnt64_t	f_files;	/* total # of file nodes (inodes) */
107 	fsfilcnt64_t	f_ffree;	/* total # of free file nodes */
108 	fsfilcnt64_t	f_favail;	/* free nodes avail to non-superuser */
109 	unsigned long	f_fsid;		/* file system id (dev for now) */
110 	char		f_basetype[FSTYPSZ];	/* target fs type name, */
111 						/* null-terminated */
112 	unsigned long	f_flag;		/* bit-mask of flags */
113 	unsigned long	f_namemax;	/* maximum file name length */
114 	char		f_fstr[32];	/* filesystem-specific string */
115 #if !defined(_LP64)
116 	unsigned long	f_filler[16];	/* reserved for future expansion */
117 #endif	/* _LP64 */
118 } statvfs64_t;
119 #endif
120 
121 #if defined(_SYSCALL32)
122 
123 /* Kernel view of user ILP32 statvfs64 structure */
124 
125 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
126 #pragma pack(4)
127 #endif
128 
129 typedef struct statvfs64_32 {
130 	uint32_t	f_bsize;	/* preferred file system block size */
131 	uint32_t	f_frsize;	/* fundamental file system block size */
132 	fsblkcnt64_t	f_blocks;	/* total blocks of f_frsize */
133 	fsblkcnt64_t	f_bfree;	/* total free blocks of f_frsize */
134 	fsblkcnt64_t	f_bavail;	/* free blocks avail to non-superuser */
135 	fsfilcnt64_t	f_files;	/* total # of file nodes (inodes) */
136 	fsfilcnt64_t	f_ffree;	/* total # of free file nodes */
137 	fsfilcnt64_t	f_favail;	/* free nodes avail to non-superuser */
138 	uint32_t	f_fsid;		/* file system id (dev for now) */
139 	char		f_basetype[FSTYPSZ];	/* target fs type name, */
140 						/* null-terminated */
141 	uint32_t	f_flag;		/* bit-mask of flags */
142 	uint32_t	f_namemax;	/* maximum file name length */
143 	char		f_fstr[32];	/* filesystem-specific string */
144 	uint32_t	f_filler[16];	/* reserved for future expansion */
145 } statvfs64_32_t;
146 
147 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
148 #pragma	pack()
149 #endif
150 
151 #endif	/* _SYSCALL32 */
152 
153 /*
154  * Flag definitions.
155  */
156 
157 #define	ST_RDONLY	0x01	/* read-only file system */
158 #define	ST_NOSUID	0x02	/* does not support setuid/setgid semantics */
159 #define	ST_NOTRUNC	0x04	/* does not truncate long file names */
160 
161 #if !defined(_KERNEL)
162 /*
163  * large file compilation environment setup
164  */
165 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
166 #ifdef __PRAGMA_REDEFINE_EXTNAME
167 #pragma redefine_extname	statvfs		statvfs64
168 #pragma redefine_extname	fstatvfs	fstatvfs64
169 #else
170 #define	statvfs_t		statvfs64_t
171 #define	statvfs			statvfs64
172 #define	fstatvfs		fstatvfs64
173 #endif
174 #endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */
175 
176 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
177 /*
178  * In the LP64 compilation environment, map large file interfaces
179  * back to native versions where possible.
180  */
181 #ifdef __PRAGMA_REDEFINE_EXTNAME
182 #pragma	redefine_extname	statvfs64	statvfs
183 #pragma	redefine_extname	fstatvfs64	fstatvfs
184 #else
185 #define	statvfs64_t		statvfs_t
186 #define	statvfs64		statvfs
187 #define	fstatvfs64		fstatvfs
188 #endif
189 #endif	/* _LP64 && _LARGEFILE64_SOURCE */
190 
191 #if defined(__STDC__)
192 int statvfs(const char *_RESTRICT_KYWD, statvfs_t *_RESTRICT_KYWD);
193 int fstatvfs(int, statvfs_t *);
194 
195 /* transitional large file interface versions */
196 #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
197 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
198 int statvfs64(const char *_RESTRICT_KYWD, statvfs64_t *_RESTRICT_KYWD);
199 int fstatvfs64(int, statvfs64_t *);
200 #endif	/* _LARGEFILE64_SOURCE... */
201 #endif	/* defined(__STDC__) */
202 #endif	/* !defined(_KERNEL) */
203 
204 #ifdef	__cplusplus
205 }
206 #endif
207 
208 #endif	/* _SYS_STATVFS_H */
209