xref: /netbsd/sys/sys/statvfs.h (revision 6550d01e)
1 /*	$NetBSD: statvfs.h,v 1.15 2008/07/31 05:38:06 simonb Exp $	 */
2 
3 /*-
4  * Copyright (c) 2004 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Christos Zoulas.
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	_SYS_STATVFS_H_
33 #define	_SYS_STATVFS_H_
34 
35 #include <sys/cdefs.h>
36 #include <sys/featuretest.h>
37 #include <sys/stdint.h>
38 #include <machine/ansi.h>
39 #include <sys/ansi.h>
40 #include <sys/fstypes.h>
41 
42 #define	_VFS_NAMELEN	32
43 #define	_VFS_MNAMELEN	1024
44 
45 #ifndef	fsblkcnt_t
46 typedef	__fsblkcnt_t	fsblkcnt_t;	/* fs block count (statvfs) */
47 #define	fsblkcnt_t	__fsblkcnt_t
48 #endif
49 
50 #ifndef	fsfilcnt_t
51 typedef	__fsfilcnt_t	fsfilcnt_t;	/* fs file count */
52 #define	fsfilcnt_t	__fsfilcnt_t
53 #endif
54 
55 #ifndef	uid_t
56 typedef	__uid_t		uid_t;		/* user id */
57 #define	uid_t		__uid_t
58 #endif
59 
60 #ifdef	_BSD_SIZE_T_
61 typedef	_BSD_SIZE_T_		size_t;
62 #define	_SIZE_T
63 #undef	_BSD_SIZE_T_
64 #endif
65 
66 struct statvfs {
67 	unsigned long	f_flag;		/* copy of mount exported flags */
68 	unsigned long	f_bsize;	/* file system block size */
69 	unsigned long	f_frsize;	/* fundamental file system block size */
70 	unsigned long	f_iosize;	/* optimal file system block size */
71 
72 	fsblkcnt_t	f_blocks;	/* number of blocks in file system, */
73 					/*   (in units of f_frsize) */
74 	fsblkcnt_t	f_bfree;	/* free blocks avail in file system */
75 	fsblkcnt_t	f_bavail;	/* free blocks avail to non-root */
76 	fsblkcnt_t	f_bresvd;	/* blocks reserved for root */
77 
78 	fsfilcnt_t	f_files;	/* total file nodes in file system */
79 	fsfilcnt_t	f_ffree;	/* free file nodes in file system */
80 	fsfilcnt_t	f_favail;	/* free file nodes avail to non-root */
81 	fsfilcnt_t	f_fresvd;	/* file nodes reserved for root */
82 
83 	uint64_t  	f_syncreads;	/* count of sync reads since mount */
84 	uint64_t  	f_syncwrites;	/* count of sync writes since mount */
85 
86 	uint64_t  	f_asyncreads;	/* count of async reads since mount */
87 	uint64_t  	f_asyncwrites;	/* count of async writes since mount */
88 
89 	fsid_t		f_fsidx;	/* NetBSD compatible fsid */
90 	unsigned long	f_fsid;		/* Posix compatible fsid */
91 	unsigned long	f_namemax;	/* maximum filename length */
92 	uid_t		f_owner;	/* user that mounted the file system */
93 
94 	uint32_t	f_spare[4];	/* spare space */
95 
96 	char	f_fstypename[_VFS_NAMELEN]; /* fs type name */
97 	char	f_mntonname[_VFS_MNAMELEN];  /* directory on which mounted */
98 	char	f_mntfromname[_VFS_MNAMELEN];  /* mounted file system */
99 
100 };
101 
102 #if defined(_NETBSD_SOURCE) && !defined(_POSIX_SOURCE) && \
103     !defined(_XOPEN_SOURCE)
104 #define	VFS_NAMELEN	_VFS_NAMELEN
105 #define	VFS_MNAMELEN	_VFS_MNAMELEN
106 #endif
107 
108 #define	ST_RDONLY	MNT_RDONLY
109 #define	ST_SYNCHRONOUS	MNT_SYNCHRONOUS
110 #define	ST_NOEXEC	MNT_NOEXEC
111 #define	ST_NOSUID	MNT_NOSUID
112 #define	ST_NODEV	MNT_NODEV
113 #define	ST_UNION	MNT_UNION
114 #define	ST_ASYNC	MNT_ASYNC
115 #define	ST_NOCOREDUMP	MNT_NOCOREDUMP
116 #define	ST_IGNORE	MNT_IGNORE
117 #define	ST_NOATIME	MNT_NOATIME
118 #define	ST_SYMPERM	MNT_SYMPERM
119 #define	ST_NODEVMTIME	MNT_NODEVMTIME
120 #define	ST_SOFTDEP	MNT_SOFTDEP
121 #define	ST_LOG		MNT_LOG
122 
123 #define	ST_EXRDONLY	MNT_EXRDONLY
124 #define	ST_EXPORTED	MNT_EXPORTED
125 #define	ST_DEFEXPORTED	MNT_DEFEXPORTED
126 #define	ST_EXPORTANON	MNT_EXPORTANON
127 #define	ST_EXKERB	MNT_EXKERB
128 #define	ST_EXNORESPORT	MNT_EXNORESPORT
129 #define	ST_EXPUBLIC	MNT_EXPUBLIC
130 
131 #define	ST_LOCAL	MNT_LOCAL
132 #define	ST_QUOTA	MNT_QUOTA
133 #define	ST_ROOTFS	MNT_ROOTFS
134 
135 
136 #define	ST_WAIT		MNT_WAIT
137 #define	ST_NOWAIT	MNT_NOWAIT
138 
139 #if defined(_KERNEL) || defined(_STANDALONE)
140 struct mount;
141 struct lwp;
142 
143 int	set_statvfs_info(const char *, int, const char *, int,
144     const char *, struct mount *, struct lwp *);
145 void	copy_statvfs_info(struct statvfs *, const struct mount *);
146 int	dostatvfs(struct mount *, struct statvfs *, struct lwp *, int, int);
147 #else
148 __BEGIN_DECLS
149 int	statvfs(const char *__restrict, struct statvfs *__restrict);
150 int	fstatvfs(int, struct statvfs *);
151 int	getvfsstat(struct statvfs *, size_t, int);
152 #ifndef __LIBC12_SOURCE__
153 int	getmntinfo(struct statvfs **, int) __RENAME(__getmntinfo13);
154 #endif /* __LIBC12_SOURCE__ */
155 #if defined(_NETBSD_SOURCE)
156 #ifndef __LIBC12_SOURCE__
157 int	fhstatvfs(const void *, size_t, struct statvfs *)
158     __RENAME(__fhstatvfs40);
159 #endif
160 
161 int	statvfs1(const char *__restrict, struct statvfs *__restrict, int);
162 int	fstatvfs1(int, struct statvfs *, int);
163 #ifndef __LIBC12_SOURCE__
164 int	fhstatvfs1(const void *, size_t, struct statvfs *, int)
165     __RENAME(__fhstatvfs140);
166 #endif
167 #endif /* _NETBSD_SOURCE */
168 __END_DECLS
169 #endif /* _KERNEL || _STANDALONE */
170 
171 #if defined(_KERNEL)
172 #include <sys/kmem.h>
173 #define	STATVFSBUF_GET()	kmem_alloc(sizeof(struct statvfs), KM_SLEEP)
174 #define	STATVFSBUF_PUT(sb)	kmem_free(sb, sizeof(struct statvfs))
175 #endif /* defined(_KERNEL) */
176 
177 #endif /* !_SYS_STATVFS_H_ */
178