summaryrefslogtreecommitdiff
path: root/pkgtools/libnbcompat/files/nbcompat/statvfs.h
blob: 6561b06a9f023e704db6c6900bca73fb45977196 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*	$NetBSD: statvfs.h,v 1.3 2004/08/23 03:32:13 jlam Exp $	*/

/*-
 * Copyright (c) 2004 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Christos Zoulas.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *        This product includes software developed by the NetBSD
 *        Foundation, Inc. and its contributors.
 * 4. Neither the name of The NetBSD Foundation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef _NBCOMPAT_STATVFS_H_
#define _NBCOMPAT_STATVFS_H_

#if HAVE_SYS_STATVFS_H
# include <sys/statvfs.h>
#endif

#if !HAVE_STATVFS

#include <nbcompat/types.h>
#include <nbcompat/param.h>

#if HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif

#if HAVE_SYS_STATFS_H
#include <sys/statfs.h>
#endif

#if HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif

#if HAVE_STDINT_H
#include <stdint.h>
#endif

#define VFS_NAMELEN	32
#define VFS_MNAMELEN	1024

typedef uint64_t	fsblkcnt_t;	/* fs block count (statvfs) */
typedef uint64_t	fsfilcnt_t;	/* fs file count */

#if !HAVE_FSID_T
typedef struct { int32_t val[2]; } fsid_t;
#endif

struct statvfs {
	unsigned long	f_flag;		/* copy of mount exported flags */
	unsigned long	f_bsize;	/* system block size */
	unsigned long	f_frsize;	/* system fragment size */
	unsigned long	f_iosize;	/* optimal file system block size */

	fsblkcnt_t	f_blocks;	/* number of blocks in file system */
	fsblkcnt_t	f_bfree;	/* free blocks avail in file system */
	fsblkcnt_t	f_bavail;	/* free blocks avail to non-root */
	fsblkcnt_t	f_bresvd;	/* blocks reserved for root */

	fsfilcnt_t	f_files;	/* total file nodes in file system */
	fsfilcnt_t	f_ffree;	/* free file nodes in file system */
	fsfilcnt_t	f_favail;	/* free file nodes avail to non-root */
	fsfilcnt_t	f_fresvd;	/* file nodes reserved for root */

	uint64_t	f_syncreads;	/* count of sync reads since mount */
	uint64_t	f_syncwrites;	/* count of sync writes since mount */

	uint64_t	f_asyncreads;	/* count of async reads since mount */
	uint64_t	f_asyncwrites;	/* count of async writes since mount */

	fsid_t		f_fsidx;	/* NetBSD compatible fsid */
	unsigned long	f_fsid;		/* Posix compatible fsid */
	unsigned long	f_namemax;	/* maximum filename length */
	uint32_t	f_owner;	/* user that mounted the file system */

	uint32_t	f_spare[4];	/* spare space */

	char	f_fstypename[VFS_NAMELEN]; /* fs type name */
	char	f_mntonname[VFS_MNAMELEN];  /* directory on which mounted */
	char	f_mntfromname[VFS_MNAMELEN];  /* mounted file system */
};

#ifndef MNT_RDONLY
#define MNT_RDONLY	0x00000001	/* read only filesystem */
#endif
#ifndef ST_RDONLY
#define ST_RDONLY	MNT_RDONLY
#endif

#ifndef MNT_NOSUID
#define MNT_NOSUID	0x00000008	/* don't honor setuid bits on fs */
#endif
#ifndef ST_NOSUID
#define ST_NOSUID	MNT_NOSUID
#endif

int	statvfs(const char *path, struct statvfs *vfs);
int	fstatvfs(int fd, struct statvfs *vfs);

#endif /* !HAVE_STATVFS */

#endif /* !_NBCOMPAT_STATVFS_H_ */