| 1 |
/* $NetBSD: statvfs.h,v 1.6 2015/12/11 23:28:10 ryoon 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 _NBCOMPAT_STATVFS_H_ |
| 33 |
#define _NBCOMPAT_STATVFS_H_ |
| 34 |
|
| 35 |
#if HAVE_SYS_STATVFS_H |
| 36 |
# include <sys/statvfs.h> |
| 37 |
#endif |
| 38 |
|
| 39 |
#if !HAVE_STATVFS |
| 40 |
|
| 41 |
#include <nbcompat/types.h> |
| 42 |
#include <nbcompat/param.h> |
| 43 |
|
| 44 |
#if HAVE_SYS_MOUNT_H |
| 45 |
#include <sys/mount.h> |
| 46 |
#endif |
| 47 |
|
| 48 |
#if HAVE_SYS_STATFS_H |
| 49 |
#include <sys/statfs.h> |
| 50 |
#endif |
| 51 |
|
| 52 |
#if HAVE_SYS_VFS_H |
| 53 |
#include <sys/vfs.h> |
| 54 |
#endif |
| 55 |
|
| 56 |
#if HAVE_STDINT_H |
| 57 |
#include <stdint.h> |
| 58 |
#endif |
| 59 |
|
| 60 |
#define VFS_NAMELEN 32 |
| 61 |
#define VFS_MNAMELEN 1024 |
| 62 |
|
| 63 |
#if !defined(fsblkcnt_t) |
| 64 |
typedef uint64_t fsblkcnt_t; /* fs block count (statvfs) */ |
| 65 |
#endif |
| 66 |
#if !defined(fsfilcnt_t) |
| 67 |
typedef uint64_t fsfilcnt_t; /* fs file count */ |
| 68 |
#endif |
| 69 |
|
| 70 |
#if !HAVE_FSID_T |
| 71 |
typedef struct { int32_t val[2]; } fsid_t; |
| 72 |
#endif |
| 73 |
|
| 74 |
struct statvfs { |
| 75 |
unsigned long f_flag; /* copy of mount exported flags */ |
| 76 |
unsigned long f_bsize; /* system block size */ |
| 77 |
unsigned long f_frsize; /* system fragment size */ |
| 78 |
unsigned long f_iosize; /* optimal file system block size */ |
| 79 |
|
| 80 |
fsblkcnt_t f_blocks; /* number of blocks in file system */ |
| 81 |
fsblkcnt_t f_bfree; /* free blocks avail in file system */ |
| 82 |
fsblkcnt_t f_bavail; /* free blocks avail to non-root */ |
| 83 |
fsblkcnt_t f_bresvd; /* blocks reserved for root */ |
| 84 |
|
| 85 |
fsfilcnt_t f_files; /* total file nodes in file system */ |
| 86 |
fsfilcnt_t f_ffree; /* free file nodes in file system */ |
| 87 |
fsfilcnt_t f_favail; /* free file nodes avail to non-root */ |
| 88 |
fsfilcnt_t f_fresvd; /* file nodes reserved for root */ |
| 89 |
|
| 90 |
uint64_t f_syncreads; /* count of sync reads since mount */ |
| 91 |
uint64_t f_syncwrites; /* count of sync writes since mount */ |
| 92 |
|
| 93 |
uint64_t f_asyncreads; /* count of async reads since mount */ |
| 94 |
uint64_t f_asyncwrites; /* count of async writes since mount */ |
| 95 |
|
| 96 |
fsid_t f_fsidx; /* NetBSD compatible fsid */ |
| 97 |
unsigned long f_fsid; /* Posix compatible fsid */ |
| 98 |
unsigned long f_namemax; /* maximum filename length */ |
| 99 |
uint32_t f_owner; /* user that mounted the file system */ |
| 100 |
|
| 101 |
uint32_t f_spare[4]; /* spare space */ |
| 102 |
|
| 103 |
char f_fstypename[VFS_NAMELEN]; /* fs type name */ |
| 104 |
char f_mntonname[VFS_MNAMELEN]; /* directory on which mounted */ |
| 105 |
char f_mntfromname[VFS_MNAMELEN]; /* mounted file system */ |
| 106 |
}; |
| 107 |
|
| 108 |
#ifndef MNT_RDONLY |
| 109 |
#define MNT_RDONLY 0x00000001 /* read only filesystem */ |
| 110 |
#endif |
| 111 |
#ifndef ST_RDONLY |
| 112 |
#define ST_RDONLY MNT_RDONLY |
| 113 |
#endif |
| 114 |
|
| 115 |
#ifndef MNT_NOSUID |
| 116 |
#define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */ |
| 117 |
#endif |
| 118 |
#ifndef ST_NOSUID |
| 119 |
#define ST_NOSUID MNT_NOSUID |
| 120 |
#endif |
| 121 |
|
| 122 |
int statvfs(const char *path, struct statvfs *vfs); |
| 123 |
int fstatvfs(int fd, struct statvfs *vfs); |
| 124 |
|
| 125 |
#endif /* !HAVE_STATVFS */ |
| 126 |
|
| 127 |
#endif /* !_NBCOMPAT_STATVFS_H_ */ |