2013-07-09 22:25:03 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-08-30 05:45:14 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file sys/statvfs.h
|
|
|
|
* @brief Filesystem statistics.
|
|
|
|
*/
|
2013-07-09 22:25:03 +02:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
2019-08-30 05:45:14 +02:00
|
|
|
struct statvfs {
|
|
|
|
/** Block size. */
|
|
|
|
unsigned long f_bsize;
|
|
|
|
/** Fragment size. */
|
|
|
|
unsigned long f_frsize;
|
|
|
|
/** Total size of filesystem in `f_frsize` blocks. */
|
|
|
|
fsblkcnt_t f_blocks;
|
|
|
|
/** Number of free blocks. */
|
|
|
|
fsblkcnt_t f_bfree;
|
|
|
|
/** Number of free blocks for non-root. */
|
|
|
|
fsblkcnt_t f_bavail;
|
|
|
|
/** Number of inodes. */
|
|
|
|
fsfilcnt_t f_files;
|
|
|
|
/** Number of free inodes. */
|
|
|
|
fsfilcnt_t f_ffree;
|
|
|
|
/** Number of free inodes for non-root. */
|
|
|
|
fsfilcnt_t f_favail;
|
|
|
|
/** Filesystem id. */
|
|
|
|
unsigned long f_fsid;
|
|
|
|
/** Mount flags. (See `ST_` constants.) */
|
|
|
|
unsigned long f_flag;
|
|
|
|
/** Maximum filename length. */
|
|
|
|
unsigned long f_namemax;
|
|
|
|
|
|
|
|
#if defined(__LP64__)
|
|
|
|
uint32_t __f_reserved[6];
|
2014-05-09 23:28:09 +02:00
|
|
|
#endif
|
2019-08-30 05:45:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct statvfs64 {
|
|
|
|
/** Block size. */
|
|
|
|
unsigned long f_bsize;
|
|
|
|
/** Fragment size. */
|
|
|
|
unsigned long f_frsize;
|
|
|
|
/** Total size of filesystem in `f_frsize` blocks. */
|
|
|
|
fsblkcnt_t f_blocks;
|
|
|
|
/** Number of free blocks. */
|
|
|
|
fsblkcnt_t f_bfree;
|
|
|
|
/** Number of free blocks for non-root. */
|
|
|
|
fsblkcnt_t f_bavail;
|
|
|
|
/** Number of inodes. */
|
|
|
|
fsfilcnt_t f_files;
|
|
|
|
/** Number of free inodes. */
|
|
|
|
fsfilcnt_t f_ffree;
|
|
|
|
/** Number of free inodes for non-root. */
|
|
|
|
fsfilcnt_t f_favail;
|
|
|
|
/** Filesystem id. */
|
|
|
|
unsigned long f_fsid;
|
|
|
|
/** Mount flags. (See `ST_` constants.) */
|
|
|
|
unsigned long f_flag;
|
|
|
|
/** Maximum filename length. */
|
|
|
|
unsigned long f_namemax;
|
2014-05-09 23:28:09 +02:00
|
|
|
|
2019-08-30 05:45:14 +02:00
|
|
|
#if defined(__LP64__)
|
|
|
|
uint32_t __f_reserved[6];
|
|
|
|
#endif
|
|
|
|
};
|
2014-05-09 23:28:09 +02:00
|
|
|
|
2019-08-30 05:45:14 +02:00
|
|
|
/** Flag for `f_flag` in `struct statvfs`: mounted read-only. */
|
2013-07-09 22:25:03 +02:00
|
|
|
#define ST_RDONLY 0x0001
|
2019-08-30 05:45:14 +02:00
|
|
|
|
|
|
|
/** Flag for `f_flag` in `struct statvfs`: setuid/setgid ignored. */
|
2013-07-09 22:25:03 +02:00
|
|
|
#define ST_NOSUID 0x0002
|
2019-08-30 05:45:14 +02:00
|
|
|
|
|
|
|
/** Flag for `f_flag` in `struct statvfs`: access to device files disallowed. */
|
2013-07-09 22:25:03 +02:00
|
|
|
#define ST_NODEV 0x0004
|
2019-08-30 05:45:14 +02:00
|
|
|
|
|
|
|
/** Flag for `f_flag` in `struct statvfs`: execution disallowed. */
|
2013-07-09 22:25:03 +02:00
|
|
|
#define ST_NOEXEC 0x0008
|
2019-08-30 05:45:14 +02:00
|
|
|
|
|
|
|
/** Flag for `f_flag` in `struct statvfs`: writes synced immediately. */
|
2013-07-09 22:25:03 +02:00
|
|
|
#define ST_SYNCHRONOUS 0x0010
|
2019-08-30 05:45:14 +02:00
|
|
|
|
|
|
|
/** Flag for `f_flag` in `struct statvfs`: mandatory locking permitted. */
|
2013-07-09 22:25:03 +02:00
|
|
|
#define ST_MANDLOCK 0x0040
|
2019-08-30 05:45:14 +02:00
|
|
|
|
|
|
|
/** Flag for `f_flag` in `struct statvfs`: access times not updated. */
|
2013-07-09 22:25:03 +02:00
|
|
|
#define ST_NOATIME 0x0400
|
2019-08-30 05:45:14 +02:00
|
|
|
|
|
|
|
/** Flag for `f_flag` in `struct statvfs`: directory access times not updated. */
|
2013-07-09 22:25:03 +02:00
|
|
|
#define ST_NODIRATIME 0x0800
|
2019-08-30 05:45:14 +02:00
|
|
|
|
|
|
|
/** Flag for `f_flag` in `struct statvfs`: see `MS_RELATIME`. */
|
2013-07-09 22:25:03 +02:00
|
|
|
#define ST_RELATIME 0x1000
|
|
|
|
|
2019-08-30 05:45:14 +02:00
|
|
|
#if __ANDROID_API__ >= 19
|
|
|
|
// These functions are implemented as static inlines before API level 19.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* [statvfs(3)](http://man7.org/linux/man-pages/man3/statvfs.3.html)
|
|
|
|
* queries filesystem statistics for the given path.
|
|
|
|
*
|
|
|
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
|
|
|
*/
|
2017-08-18 00:34:21 +02:00
|
|
|
int statvfs(const char* __path, struct statvfs* __buf) __INTRODUCED_IN(19);
|
2019-08-30 05:45:14 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [fstatvfs(3)](http://man7.org/linux/man-pages/man3/fstatvfs.3.html)
|
|
|
|
* queries filesystem statistics for the given file descriptor.
|
|
|
|
*
|
|
|
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
|
|
|
*/
|
2017-08-18 00:34:21 +02:00
|
|
|
int fstatvfs(int __fd, struct statvfs* __buf) __INTRODUCED_IN(19);
|
2019-08-30 05:45:14 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if __ANDROID_API__ >= 21
|
|
|
|
// These functions are implemented as static inlines before API level 21.
|
|
|
|
|
|
|
|
/** Equivalent to statvfs(). */
|
|
|
|
int statvfs64(const char* __path, struct statvfs64* __buf) __INTRODUCED_IN(21);
|
|
|
|
|
|
|
|
/** Equivalent to fstatvfs(). */
|
2017-08-18 00:34:21 +02:00
|
|
|
int fstatvfs64(int __fd, struct statvfs64* __buf) __INTRODUCED_IN(21);
|
2013-07-09 22:25:03 +02:00
|
|
|
|
2019-08-30 05:45:14 +02:00
|
|
|
#endif
|
|
|
|
|
2013-07-09 22:25:03 +02:00
|
|
|
__END_DECLS
|
|
|
|
|
2019-08-30 05:45:14 +02:00
|
|
|
#include <android/legacy_sys_statvfs_inlines.h>
|