xref: /illumos-gate/usr/src/uts/common/sys/statvfs.h (revision b4203d75)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
237c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate /*
26*ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
27*ba3594baSGarrett D'Amore  *
287c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
297c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifndef _SYS_STATVFS_H
337c478bd9Sstevel@tonic-gate #define	_SYS_STATVFS_H
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
367c478bd9Sstevel@tonic-gate #include <sys/types.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
397c478bd9Sstevel@tonic-gate extern "C" {
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * Structure returned by statvfs(2).
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #define	_FSTYPSZ	16
477c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
487c478bd9Sstevel@tonic-gate #ifndef FSTYPSZ
497c478bd9Sstevel@tonic-gate #define	FSTYPSZ	_FSTYPSZ
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate typedef struct statvfs {
547c478bd9Sstevel@tonic-gate 	unsigned long	f_bsize;	/* fundamental file system block size */
557c478bd9Sstevel@tonic-gate 	unsigned long	f_frsize;	/* fragment size */
567c478bd9Sstevel@tonic-gate 	fsblkcnt_t	f_blocks;	/* total blocks of f_frsize on fs */
577c478bd9Sstevel@tonic-gate 	fsblkcnt_t	f_bfree;	/* total free blocks of f_frsize */
587c478bd9Sstevel@tonic-gate 	fsblkcnt_t	f_bavail;	/* free blocks avail to non-superuser */
597c478bd9Sstevel@tonic-gate 	fsfilcnt_t	f_files;	/* total file nodes (inodes) */
607c478bd9Sstevel@tonic-gate 	fsfilcnt_t	f_ffree;	/* total free file nodes */
617c478bd9Sstevel@tonic-gate 	fsfilcnt_t	f_favail;	/* free nodes avail to non-superuser */
627c478bd9Sstevel@tonic-gate 	unsigned long	f_fsid;		/* file system id (dev for now) */
637c478bd9Sstevel@tonic-gate 	char		f_basetype[_FSTYPSZ];	/* target fs type name, */
647c478bd9Sstevel@tonic-gate 						/* null-terminated */
657c478bd9Sstevel@tonic-gate 	unsigned long	f_flag;		/* bit-mask of flags */
667c478bd9Sstevel@tonic-gate 	unsigned long	f_namemax;	/* maximum file name length */
677c478bd9Sstevel@tonic-gate 	char		f_fstr[32];	/* filesystem-specific string */
687c478bd9Sstevel@tonic-gate #if !defined(_LP64)
697c478bd9Sstevel@tonic-gate 	unsigned long 	f_filler[16];	/* reserved for future expansion */
707c478bd9Sstevel@tonic-gate #endif
717c478bd9Sstevel@tonic-gate } statvfs_t;
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate /* Kernel view of user ILP32 statvfs structure */
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate typedef struct statvfs32 {
787c478bd9Sstevel@tonic-gate 	uint32_t	f_bsize;	/* fundamental file system block size */
797c478bd9Sstevel@tonic-gate 	uint32_t	f_frsize;	/* fragment size */
807c478bd9Sstevel@tonic-gate 	fsblkcnt32_t	f_blocks;	/* total blocks of f_frsize on fs */
817c478bd9Sstevel@tonic-gate 	fsblkcnt32_t	f_bfree;	/* total free blocks of f_frsize */
827c478bd9Sstevel@tonic-gate 	fsblkcnt32_t	f_bavail;	/* free blocks avail to non-superuser */
837c478bd9Sstevel@tonic-gate 	fsfilcnt32_t	f_files;	/* total file nodes (inodes) */
847c478bd9Sstevel@tonic-gate 	fsfilcnt32_t	f_ffree;	/* total free file nodes */
857c478bd9Sstevel@tonic-gate 	fsfilcnt32_t	f_favail;	/* free nodes avail to non-superuser */
867c478bd9Sstevel@tonic-gate 	uint32_t	f_fsid;		/* file system id (dev for now) */
877c478bd9Sstevel@tonic-gate 	char		f_basetype[_FSTYPSZ];	/* target fs type name, */
887c478bd9Sstevel@tonic-gate 						/* null-terminated */
897c478bd9Sstevel@tonic-gate 	uint32_t	f_flag;		/* bit-mask of flags */
907c478bd9Sstevel@tonic-gate 	uint32_t	f_namemax;	/* maximum file name length */
917c478bd9Sstevel@tonic-gate 	char		f_fstr[32];	/* filesystem-specific string */
927c478bd9Sstevel@tonic-gate 	uint32_t	f_filler[16];	/* reserved for future expansion */
937c478bd9Sstevel@tonic-gate } statvfs32_t;
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate /* transitional large file interface version */
987c478bd9Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE)
997c478bd9Sstevel@tonic-gate typedef struct statvfs64 {
1007c478bd9Sstevel@tonic-gate 	unsigned long	f_bsize;	/* preferred file system block size */
1017c478bd9Sstevel@tonic-gate 	unsigned long	f_frsize;	/* fundamental file system block size */
1027c478bd9Sstevel@tonic-gate 	fsblkcnt64_t	f_blocks;	/* total blocks of f_frsize */
1037c478bd9Sstevel@tonic-gate 	fsblkcnt64_t	f_bfree;	/* total free blocks of f_frsize */
1047c478bd9Sstevel@tonic-gate 	fsblkcnt64_t	f_bavail;	/* free blocks avail to non-superuser */
1057c478bd9Sstevel@tonic-gate 	fsfilcnt64_t	f_files;	/* total # of file nodes (inodes) */
1067c478bd9Sstevel@tonic-gate 	fsfilcnt64_t	f_ffree;	/* total # of free file nodes */
1077c478bd9Sstevel@tonic-gate 	fsfilcnt64_t	f_favail;	/* free nodes avail to non-superuser */
1087c478bd9Sstevel@tonic-gate 	unsigned long	f_fsid;		/* file system id (dev for now) */
1097c478bd9Sstevel@tonic-gate 	char		f_basetype[FSTYPSZ];	/* target fs type name, */
1107c478bd9Sstevel@tonic-gate 						/* null-terminated */
1117c478bd9Sstevel@tonic-gate 	unsigned long	f_flag;		/* bit-mask of flags */
1127c478bd9Sstevel@tonic-gate 	unsigned long	f_namemax;	/* maximum file name length */
1137c478bd9Sstevel@tonic-gate 	char		f_fstr[32];	/* filesystem-specific string */
1147c478bd9Sstevel@tonic-gate #if !defined(_LP64)
1157c478bd9Sstevel@tonic-gate 	unsigned long	f_filler[16];	/* reserved for future expansion */
1167c478bd9Sstevel@tonic-gate #endif	/* _LP64 */
1177c478bd9Sstevel@tonic-gate } statvfs64_t;
1187c478bd9Sstevel@tonic-gate #endif
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /* Kernel view of user ILP32 statvfs64 structure */
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
1257c478bd9Sstevel@tonic-gate #pragma pack(4)
1267c478bd9Sstevel@tonic-gate #endif
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate typedef struct statvfs64_32 {
1297c478bd9Sstevel@tonic-gate 	uint32_t	f_bsize;	/* preferred file system block size */
1307c478bd9Sstevel@tonic-gate 	uint32_t	f_frsize;	/* fundamental file system block size */
1317c478bd9Sstevel@tonic-gate 	fsblkcnt64_t	f_blocks;	/* total blocks of f_frsize */
1327c478bd9Sstevel@tonic-gate 	fsblkcnt64_t	f_bfree;	/* total free blocks of f_frsize */
1337c478bd9Sstevel@tonic-gate 	fsblkcnt64_t	f_bavail;	/* free blocks avail to non-superuser */
1347c478bd9Sstevel@tonic-gate 	fsfilcnt64_t	f_files;	/* total # of file nodes (inodes) */
1357c478bd9Sstevel@tonic-gate 	fsfilcnt64_t	f_ffree;	/* total # of free file nodes */
1367c478bd9Sstevel@tonic-gate 	fsfilcnt64_t	f_favail;	/* free nodes avail to non-superuser */
1377c478bd9Sstevel@tonic-gate 	uint32_t	f_fsid;		/* file system id (dev for now) */
1387c478bd9Sstevel@tonic-gate 	char		f_basetype[FSTYPSZ];	/* target fs type name, */
1397c478bd9Sstevel@tonic-gate 						/* null-terminated */
1407c478bd9Sstevel@tonic-gate 	uint32_t	f_flag;		/* bit-mask of flags */
1417c478bd9Sstevel@tonic-gate 	uint32_t	f_namemax;	/* maximum file name length */
1427c478bd9Sstevel@tonic-gate 	char		f_fstr[32];	/* filesystem-specific string */
1437c478bd9Sstevel@tonic-gate 	uint32_t	f_filler[16];	/* reserved for future expansion */
1447c478bd9Sstevel@tonic-gate } statvfs64_32_t;
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
1477c478bd9Sstevel@tonic-gate #pragma	pack()
1487c478bd9Sstevel@tonic-gate #endif
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate /*
1537c478bd9Sstevel@tonic-gate  * Flag definitions.
1547c478bd9Sstevel@tonic-gate  */
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate #define	ST_RDONLY	0x01	/* read-only file system */
1577c478bd9Sstevel@tonic-gate #define	ST_NOSUID	0x02	/* does not support setuid/setgid semantics */
1587c478bd9Sstevel@tonic-gate #define	ST_NOTRUNC	0x04	/* does not truncate long file names */
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate #if !defined(_KERNEL)
1617c478bd9Sstevel@tonic-gate /*
1627c478bd9Sstevel@tonic-gate  * large file compilation environment setup
1637c478bd9Sstevel@tonic-gate  */
1647c478bd9Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
1657c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
1667c478bd9Sstevel@tonic-gate #pragma redefine_extname	statvfs		statvfs64
1677c478bd9Sstevel@tonic-gate #pragma redefine_extname	fstatvfs	fstatvfs64
1687c478bd9Sstevel@tonic-gate #else
1697c478bd9Sstevel@tonic-gate #define	statvfs_t		statvfs64_t
1707c478bd9Sstevel@tonic-gate #define	statvfs			statvfs64
1717c478bd9Sstevel@tonic-gate #define	fstatvfs		fstatvfs64
1727c478bd9Sstevel@tonic-gate #endif
1737c478bd9Sstevel@tonic-gate #endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
1767c478bd9Sstevel@tonic-gate /*
1777c478bd9Sstevel@tonic-gate  * In the LP64 compilation environment, map large file interfaces
1787c478bd9Sstevel@tonic-gate  * back to native versions where possible.
1797c478bd9Sstevel@tonic-gate  */
1807c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
1817c478bd9Sstevel@tonic-gate #pragma	redefine_extname	statvfs64	statvfs
1827c478bd9Sstevel@tonic-gate #pragma	redefine_extname	fstatvfs64	fstatvfs
1837c478bd9Sstevel@tonic-gate #else
1847c478bd9Sstevel@tonic-gate #define	statvfs64_t		statvfs_t
1857c478bd9Sstevel@tonic-gate #define	statvfs64		statvfs
1867c478bd9Sstevel@tonic-gate #define	fstatvfs64		fstatvfs
1877c478bd9Sstevel@tonic-gate #endif
1887c478bd9Sstevel@tonic-gate #endif	/* _LP64 && _LARGEFILE64_SOURCE */
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate int statvfs(const char *_RESTRICT_KYWD, statvfs_t *_RESTRICT_KYWD);
1917c478bd9Sstevel@tonic-gate int fstatvfs(int, statvfs_t *);
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate /* transitional large file interface versions */
1947c478bd9Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
1957c478bd9Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
1967c478bd9Sstevel@tonic-gate int statvfs64(const char *_RESTRICT_KYWD, statvfs64_t *_RESTRICT_KYWD);
1977c478bd9Sstevel@tonic-gate int fstatvfs64(int, statvfs64_t *);
1987c478bd9Sstevel@tonic-gate #endif	/* _LARGEFILE64_SOURCE... */
1997c478bd9Sstevel@tonic-gate #endif	/* !defined(_KERNEL) */
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2027c478bd9Sstevel@tonic-gate }
2037c478bd9Sstevel@tonic-gate #endif
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate #endif	/* _SYS_STATVFS_H */
206