From 89ba41c79e09729ad48a230bc5c7eb09812110a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Mon, 19 Dec 2016 11:21:38 +0100 Subject: [PATCH] sys/posix: Add sys/statvfs.h --- sys/posix/include/sys/statvfs.h | 78 +++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 sys/posix/include/sys/statvfs.h diff --git a/sys/posix/include/sys/statvfs.h b/sys/posix/include/sys/statvfs.h new file mode 100644 index 000000000..42c142023 --- /dev/null +++ b/sys/posix/include/sys/statvfs.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2016 Eistec AB + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @file + * @brief POSIX compatible sys/statvfs.h definitions + * @author Joakim NohlgÄrd + */ + +/* If building on native we need to use the system libraries instead */ +#ifdef CPU_NATIVE +#pragma GCC system_header +/* without the GCC pragma above #include_next will trigger a pedantic error */ +#include_next +#else +#ifndef SYS_STATVFS_H_ +#define SYS_STATVFS_H_ + +#include /* for fsblkcnt_t, fsfilcnt_t */ +/** @todo Remove ifdef BOARD_MIPS_MALTA special case after + * [#6639](https://github.com/RIOT-OS/RIOT/pull/6639) is merged */ +#if MODULE_NEWLIB || defined(BOARD_MIPS_MALTA) +/* newlib support for fsblkcnt_t was only recently added to the newlib git + * repository, commit f3e587d30a9f65d0c6551ad14095300f6e81672e, 15 apr 2016. + * Will be included in release 2.5.0, around new year 2016/2017. + * We provide the below workaround if the used tool chain is too old. */ +#ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */ +#include +/* Default to 32 bit file sizes on newlib platforms */ +typedef uint32_t fsblkcnt_t; +typedef uint32_t fsfilcnt_t; +#define _FSBLKCNT_T_DECLARED +#endif +#endif +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief File system information + */ +struct statvfs { + unsigned long f_bsize; /**< File system block size. */ + unsigned long f_frsize; /**< Fundamental file system block size. */ + fsblkcnt_t f_blocks; /**< Total number of blocks on file system in + units of @c f_frsize. */ + fsblkcnt_t f_bfree; /**< Total number of free blocks. */ + fsblkcnt_t f_bavail; /**< Number of free blocks available to + non-privileged process. */ + fsfilcnt_t f_files; /**< Total number of file serial numbers. */ + fsfilcnt_t f_ffree; /**< Total number of free file serial numbers. */ + fsfilcnt_t f_favail; /**< Number of file serial numbers available to + non-privileged process. */ + + unsigned long f_fsid; /**< File system ID. */ + unsigned long f_flag; /**< Bit mask of f_flag values. */ + unsigned long f_namemax; /**< Maximum filename length. */ +}; + +enum { + ST_RDONLY = 1, /* Mount read-only. */ + ST_NOSUID = 2, /* Ignore suid and sgid bits. */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* SYS_STATVFS_H_ */ + +#endif /* CPU_NATIVE */ + +/** @} */