1 /* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 /** 20 * @file sys/statvfs.h 21 * @brief Filesystem statistics. 22 */ 23 24 #include <sys/cdefs.h> 25 26 #include <stdint.h> 27 #include <sys/types.h> 28 29 __BEGIN_DECLS 30 31 #define __STATVFS64_BODY \ 32 /** Block size. */ \ 33 unsigned long f_bsize; \ 34 /** Fragment size. */ \ 35 unsigned long f_frsize; \ 36 /** Total size of filesystem in `f_frsize` blocks. */ \ 37 fsblkcnt_t f_blocks; \ 38 /** Number of free blocks. */ \ 39 fsblkcnt_t f_bfree; \ 40 /** Number of free blocks for non-root. */ \ 41 fsblkcnt_t f_bavail; \ 42 /** Number of inodes. */ \ 43 fsfilcnt_t f_files; \ 44 /** Number of free inodes. */ \ 45 fsfilcnt_t f_ffree; \ 46 /** Number of free inodes for non-root. */ \ 47 fsfilcnt_t f_favail; \ 48 /** Filesystem id. */ \ 49 unsigned long f_fsid; \ 50 /** Mount flags. (See `ST_` constants.) */ \ 51 unsigned long f_flag; \ 52 /** Maximum filename length. */ \ 53 unsigned long f_namemax; \ 54 55 #if defined(__LP64__) 56 #define __STATVFS64_CODA uint32_t __f_reserved[6]; 57 #else 58 #define __STATVFS64_CODA 59 #endif 60 61 struct statvfs { __STATVFS64_BODY __STATVFS64_CODA }; 62 63 struct statvfs64 { __STATVFS64_BODY __STATVFS64_CODA }; 64 65 /** Flag for `f_flag` in `struct statvfs`: mounted read-only. */ 66 #define ST_RDONLY 0x0001 67 68 /** Flag for `f_flag` in `struct statvfs`: setuid/setgid ignored. */ 69 #define ST_NOSUID 0x0002 70 71 /** Flag for `f_flag` in `struct statvfs`: access to device files disallowed. */ 72 #define ST_NODEV 0x0004 73 74 /** Flag for `f_flag` in `struct statvfs`: execution disallowed. */ 75 #define ST_NOEXEC 0x0008 76 77 /** Flag for `f_flag` in `struct statvfs`: writes synced immediately. */ 78 #define ST_SYNCHRONOUS 0x0010 79 80 /** Flag for `f_flag` in `struct statvfs`: mandatory locking permitted. */ 81 #define ST_MANDLOCK 0x0040 82 83 /** Flag for `f_flag` in `struct statvfs`: access times not updated. */ 84 #define ST_NOATIME 0x0400 85 86 /** Flag for `f_flag` in `struct statvfs`: directory access times not updated. */ 87 #define ST_NODIRATIME 0x0800 88 89 /** Flag for `f_flag` in `struct statvfs`: see `MS_RELATIME`. */ 90 #define ST_RELATIME 0x1000 91 92 /** Flag for `f_flag` in `struct statvfs`: don't follow symlinks. */ 93 #define ST_NOSYMFOLLOW 0x2000 94 95 /** 96 * [statvfs(3)](https://man7.org/linux/man-pages/man3/statvfs.3.html) 97 * queries filesystem statistics for the given path. 98 * 99 * Returns 0 on success, and returns -1 and sets `errno` on failure. 100 */ 101 int statvfs(const char* _Nonnull __path, struct statvfs* _Nonnull __buf); 102 103 /** 104 * [fstatvfs(3)](https://man7.org/linux/man-pages/man3/fstatvfs.3.html) 105 * queries filesystem statistics for the given file descriptor. 106 * 107 * Returns 0 on success, and returns -1 and sets `errno` on failure. 108 */ 109 int fstatvfs(int __fd, struct statvfs* _Nonnull __buf); 110 111 /** Equivalent to statvfs() . */ 112 int statvfs64(const char* _Nonnull __path, struct statvfs64* _Nonnull __buf); 113 114 /** Equivalent to fstatvfs(). */ 115 int fstatvfs64(int __fd, struct statvfs64* _Nonnull __buf); 116 117 __END_DECLS 118