1 /* 2 * Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au> 3 * 4 * Permission to use, copy, modify, and distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER 13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #include "includes.h" 18 19 #if !defined(HAVE_STATVFS) || !defined(HAVE_FSTATVFS) 20 21 #include <sys/types.h> 22 23 #ifdef HAVE_SYS_MOUNT_H 24 #include <sys/mount.h> 25 #endif 26 #ifdef HAVE_SYS_STATFS_H 27 #include <sys/statfs.h> 28 #endif 29 #ifdef HAVE_SYS_VFS_H 30 #include <sys/vfs.h> 31 #endif 32 33 #ifndef HAVE_FSBLKCNT_T 34 typedef unsigned long fsblkcnt_t; 35 #endif 36 #ifndef HAVE_FSFILCNT_T 37 typedef unsigned long fsfilcnt_t; 38 #endif 39 40 #ifndef ST_RDONLY 41 #define ST_RDONLY 1 42 #endif 43 #ifndef ST_NOSUID 44 #define ST_NOSUID 2 45 #endif 46 47 /* as defined in IEEE Std 1003.1, 2004 Edition */ 48 struct statvfs { 49 unsigned long f_bsize; /* File system block size. */ 50 unsigned long f_frsize; /* Fundamental file system block size. */ 51 fsblkcnt_t f_blocks; /* Total number of blocks on file system in */ 52 /* units of f_frsize. */ 53 fsblkcnt_t f_bfree; /* Total number of free blocks. */ 54 fsblkcnt_t f_bavail; /* Number of free blocks available to */ 55 /* non-privileged process. */ 56 fsfilcnt_t f_files; /* Total number of file serial numbers. */ 57 fsfilcnt_t f_ffree; /* Total number of free file serial numbers. */ 58 fsfilcnt_t f_favail; /* Number of file serial numbers available to */ 59 /* non-privileged process. */ 60 unsigned long f_fsid; /* File system ID. */ 61 unsigned long f_flag; /* BBit mask of f_flag values. */ 62 unsigned long f_namemax;/* Maximum filename length. */ 63 }; 64 #endif 65 66 #ifndef HAVE_STATVFS 67 int statvfs(const char *, struct statvfs *); 68 #endif 69 70 #ifndef HAVE_FSTATVFS 71 int fstatvfs(int, struct statvfs *); 72 #endif 73