Remove <sys/statvfs.h> inlines for API level 19.
API level 19 is no longer supported by the NDK. While I'm here, let's remove the duplicated structure defintion (as we've already done for `struct stat`). Test: treehugger Change-Id: I9d8286f9e7ba803f3131b6dcb0486ff1b0f9d5d1
This commit is contained in:
parent
83b661802d
commit
3c3736e1bd
|
@ -14,17 +14,36 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/statfs.h>
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
|
|
||||||
// libc++ uses statvfs (for Darwin compatibility), but on Linux statvfs is
|
static __inline void __bionic_statfs_to_statvfs(const struct statfs* src, struct statvfs* dst) {
|
||||||
// just another name for statfs, so it didn't arrive until API level 19. We
|
dst->f_bsize = src->f_bsize;
|
||||||
// make the implementation available as inlines to support std::filesystem
|
dst->f_frsize = src->f_frsize;
|
||||||
// for NDK users (see https://github.com/android-ndk/ndk/issues/609).
|
dst->f_blocks = src->f_blocks;
|
||||||
|
dst->f_bfree = src->f_bfree;
|
||||||
|
dst->f_bavail = src->f_bavail;
|
||||||
|
dst->f_files = src->f_files;
|
||||||
|
dst->f_ffree = src->f_ffree;
|
||||||
|
dst->f_favail = src->f_ffree;
|
||||||
|
dst->f_fsid = src->f_fsid.__val[0] | static_cast<uint64_t>(src->f_fsid.__val[1]) << 32;
|
||||||
|
dst->f_flag = src->f_flags;
|
||||||
|
dst->f_namemax = src->f_namelen;
|
||||||
|
}
|
||||||
|
|
||||||
#define __BIONIC_SYS_STATVFS_INLINE /* Out of line. */
|
int statvfs(const char* path, struct statvfs* result) {
|
||||||
#define __BIONIC_NEED_STATVFS_INLINES
|
struct statfs tmp;
|
||||||
#undef __BIONIC_NEED_STATVFS64_INLINES
|
if (statfs(path, &tmp) == -1) return -1;
|
||||||
#include <bits/sys_statvfs_inlines.h>
|
__bionic_statfs_to_statvfs(&tmp, result);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fstatvfs(int fd, struct statvfs* result) {
|
||||||
|
struct statfs tmp;
|
||||||
|
if (fstatfs(fd, &tmp) == -1) return -1;
|
||||||
|
__bionic_statfs_to_statvfs(&tmp, result);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Historically we provided actual symbols for statvfs64 and fstatvfs64.
|
// Historically we provided actual symbols for statvfs64 and fstatvfs64.
|
||||||
// They're not particularly useful, but we can't take them away.
|
// They're not particularly useful, but we can't take them away.
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The Android Open Source Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
|
|
||||||
* COPYRIGHT OWNER 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file legacy_sys_statvfs_inlines.h
|
|
||||||
* @brief Inline definitions of statvfs/fstatvfs for old API levels.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
|
|
||||||
#if __ANDROID_API__ < 21
|
|
||||||
|
|
||||||
#define __BIONIC_NEED_STATVFS64_INLINES
|
|
||||||
#if __ANDROID_API__ < 19
|
|
||||||
#define __BIONIC_NEED_STATVFS_INLINES
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define __BIONIC_SYS_STATVFS_INLINE static __inline
|
|
||||||
#include <bits/sys_statvfs_inlines.h>
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,95 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019 The Android Open Source Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
|
|
||||||
* COPYRIGHT OWNER 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#include <sys/statfs.h>
|
|
||||||
#include <sys/statvfs.h>
|
|
||||||
|
|
||||||
#if defined(__BIONIC_SYS_STATVFS_INLINE)
|
|
||||||
|
|
||||||
__BEGIN_DECLS
|
|
||||||
|
|
||||||
#if defined(__BIONIC_NEED_STATVFS_INLINES)
|
|
||||||
|
|
||||||
static __inline void __bionic_statfs_to_statvfs(const struct statfs* __src,
|
|
||||||
struct statvfs* __dst) {
|
|
||||||
__dst->f_bsize = __src->f_bsize;
|
|
||||||
__dst->f_frsize = __src->f_frsize;
|
|
||||||
__dst->f_blocks = __src->f_blocks;
|
|
||||||
__dst->f_bfree = __src->f_bfree;
|
|
||||||
__dst->f_bavail = __src->f_bavail;
|
|
||||||
__dst->f_files = __src->f_files;
|
|
||||||
__dst->f_ffree = __src->f_ffree;
|
|
||||||
__dst->f_favail = __src->f_ffree;
|
|
||||||
__dst->f_fsid = __src->f_fsid.__val[0] |
|
|
||||||
__BIONIC_CAST(static_cast, uint64_t, __src->f_fsid.__val[1]) << 32;
|
|
||||||
__dst->f_flag = __src->f_flags;
|
|
||||||
__dst->f_namemax = __src->f_namelen;
|
|
||||||
}
|
|
||||||
|
|
||||||
__BIONIC_SYS_STATVFS_INLINE int statvfs(const char* __path,
|
|
||||||
struct statvfs* __result) {
|
|
||||||
struct statfs __tmp;
|
|
||||||
int __rc = statfs(__path, &__tmp);
|
|
||||||
if (__rc != 0) return __rc;
|
|
||||||
__bionic_statfs_to_statvfs(&__tmp, __result);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
__BIONIC_SYS_STATVFS_INLINE int fstatvfs(int __fd,
|
|
||||||
struct statvfs* __result) {
|
|
||||||
struct statfs __tmp;
|
|
||||||
int __rc = fstatfs(__fd, &__tmp);
|
|
||||||
if (__rc != 0) return __rc;
|
|
||||||
__bionic_statfs_to_statvfs(&__tmp, __result);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__BIONIC_NEED_STATVFS64_INLINES)
|
|
||||||
|
|
||||||
__BIONIC_SYS_STATVFS_INLINE int statvfs64(const char* __path,
|
|
||||||
struct statvfs64* __result) {
|
|
||||||
return statvfs(__path, __BIONIC_CAST(reinterpret_cast, struct statvfs*,
|
|
||||||
__result));
|
|
||||||
}
|
|
||||||
|
|
||||||
__BIONIC_SYS_STATVFS_INLINE int fstatvfs64(int __fd,
|
|
||||||
struct statvfs64* __result) {
|
|
||||||
return fstatvfs(__fd, __BIONIC_CAST(reinterpret_cast, struct statvfs*,
|
|
||||||
__result));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
__END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -27,63 +27,39 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
struct statvfs {
|
#define __STATVFS64_BODY \
|
||||||
/** Block size. */
|
/** Block size. */ \
|
||||||
unsigned long f_bsize;
|
unsigned long f_bsize; \
|
||||||
/** Fragment size. */
|
/** Fragment size. */ \
|
||||||
unsigned long f_frsize;
|
unsigned long f_frsize; \
|
||||||
/** Total size of filesystem in `f_frsize` blocks. */
|
/** Total size of filesystem in `f_frsize` blocks. */ \
|
||||||
fsblkcnt_t f_blocks;
|
fsblkcnt_t f_blocks; \
|
||||||
/** Number of free blocks. */
|
/** Number of free blocks. */ \
|
||||||
fsblkcnt_t f_bfree;
|
fsblkcnt_t f_bfree; \
|
||||||
/** Number of free blocks for non-root. */
|
/** Number of free blocks for non-root. */ \
|
||||||
fsblkcnt_t f_bavail;
|
fsblkcnt_t f_bavail; \
|
||||||
/** Number of inodes. */
|
/** Number of inodes. */ \
|
||||||
fsfilcnt_t f_files;
|
fsfilcnt_t f_files; \
|
||||||
/** Number of free inodes. */
|
/** Number of free inodes. */ \
|
||||||
fsfilcnt_t f_ffree;
|
fsfilcnt_t f_ffree; \
|
||||||
/** Number of free inodes for non-root. */
|
/** Number of free inodes for non-root. */ \
|
||||||
fsfilcnt_t f_favail;
|
fsfilcnt_t f_favail; \
|
||||||
/** Filesystem id. */
|
/** Filesystem id. */ \
|
||||||
unsigned long f_fsid;
|
unsigned long f_fsid; \
|
||||||
/** Mount flags. (See `ST_` constants.) */
|
/** Mount flags. (See `ST_` constants.) */ \
|
||||||
unsigned long f_flag;
|
unsigned long f_flag; \
|
||||||
/** Maximum filename length. */
|
/** Maximum filename length. */ \
|
||||||
unsigned long f_namemax;
|
unsigned long f_namemax; \
|
||||||
|
|
||||||
#if defined(__LP64__)
|
#if defined(__LP64__)
|
||||||
uint32_t __f_reserved[6];
|
#define __STATVFS64_CODA uint32_t __f_reserved[6];
|
||||||
|
#else
|
||||||
|
#define __STATVFS64_CODA
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
struct statvfs64 {
|
struct statvfs { __STATVFS64_BODY __STATVFS64_CODA };
|
||||||
/** 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__)
|
struct statvfs64 { __STATVFS64_BODY __STATVFS64_CODA };
|
||||||
uint32_t __f_reserved[6];
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Flag for `f_flag` in `struct statvfs`: mounted read-only. */
|
/** Flag for `f_flag` in `struct statvfs`: mounted read-only. */
|
||||||
#define ST_RDONLY 0x0001
|
#define ST_RDONLY 0x0001
|
||||||
|
@ -112,14 +88,13 @@ struct statvfs64 {
|
||||||
/** Flag for `f_flag` in `struct statvfs`: see `MS_RELATIME`. */
|
/** Flag for `f_flag` in `struct statvfs`: see `MS_RELATIME`. */
|
||||||
#define ST_RELATIME 0x1000
|
#define ST_RELATIME 0x1000
|
||||||
|
|
||||||
#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)
|
* [statvfs(3)](http://man7.org/linux/man-pages/man3/statvfs.3.html)
|
||||||
* queries filesystem statistics for the given path.
|
* queries filesystem statistics for the given path.
|
||||||
*
|
*
|
||||||
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
||||||
|
*
|
||||||
|
* Available since API level 19.
|
||||||
*/
|
*/
|
||||||
int statvfs(const char* __path, struct statvfs* __buf) __INTRODUCED_IN(19);
|
int statvfs(const char* __path, struct statvfs* __buf) __INTRODUCED_IN(19);
|
||||||
|
|
||||||
|
@ -128,22 +103,15 @@ int statvfs(const char* __path, struct statvfs* __buf) __INTRODUCED_IN(19);
|
||||||
* queries filesystem statistics for the given file descriptor.
|
* queries filesystem statistics for the given file descriptor.
|
||||||
*
|
*
|
||||||
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
* Returns 0 on success, and returns -1 and sets `errno` on failure.
|
||||||
|
*
|
||||||
|
* Available since API level 19.
|
||||||
*/
|
*/
|
||||||
int fstatvfs(int __fd, struct statvfs* __buf) __INTRODUCED_IN(19);
|
int fstatvfs(int __fd, struct statvfs* __buf) __INTRODUCED_IN(19);
|
||||||
|
|
||||||
#endif
|
/** Equivalent to statvfs() . */
|
||||||
|
|
||||||
#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);
|
int statvfs64(const char* __path, struct statvfs64* __buf) __INTRODUCED_IN(21);
|
||||||
|
|
||||||
/** Equivalent to fstatvfs(). */
|
/** Equivalent to fstatvfs(). */
|
||||||
int fstatvfs64(int __fd, struct statvfs64* __buf) __INTRODUCED_IN(21);
|
int fstatvfs64(int __fd, struct statvfs64* __buf) __INTRODUCED_IN(21);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
#include <android/legacy_sys_statvfs_inlines.h>
|
|
||||||
|
|
Loading…
Reference in New Issue