2008-09-12 08:39:12 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* include/sys/statfs.h
|
2007-05-28 04:40:01 +08:00
|
|
|
*
|
2021-02-03 18:33:49 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you 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
|
2007-05-28 04:40:01 +08:00
|
|
|
*
|
2021-02-03 18:33:49 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-05-28 04:40:01 +08:00
|
|
|
*
|
2021-02-03 18:33:49 +08:00
|
|
|
* 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.
|
2007-05-28 04:40:01 +08:00
|
|
|
*
|
2008-09-12 08:39:12 +08:00
|
|
|
****************************************************************************/
|
2007-05-28 04:40:01 +08:00
|
|
|
|
2012-07-17 11:58:11 +08:00
|
|
|
#ifndef __INCLUDE_SYS_STATFS_H
|
|
|
|
#define __INCLUDE_SYS_STATFS_H
|
2007-05-28 04:40:01 +08:00
|
|
|
|
2008-09-12 08:39:12 +08:00
|
|
|
/****************************************************************************
|
2007-05-28 04:40:01 +08:00
|
|
|
* Included Files
|
2008-09-12 08:39:12 +08:00
|
|
|
****************************************************************************/
|
2007-05-28 04:40:01 +08:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2009-12-15 07:32:23 +08:00
|
|
|
|
2007-05-28 04:40:01 +08:00
|
|
|
#include <sys/types.h>
|
2009-12-15 07:32:23 +08:00
|
|
|
#include <stdint.h>
|
2007-05-28 04:40:01 +08:00
|
|
|
|
2008-09-12 08:39:12 +08:00
|
|
|
/****************************************************************************
|
2015-02-17 04:29:43 +08:00
|
|
|
* Pre-processor Definitions
|
2008-09-12 08:39:12 +08:00
|
|
|
****************************************************************************/
|
2007-05-28 04:40:01 +08:00
|
|
|
|
|
|
|
/* struct statfs file system types. */
|
|
|
|
|
|
|
|
#define ADFS_SUPER_MAGIC 0xadf5
|
2011-04-29 05:05:39 +08:00
|
|
|
#define AFFS_SUPER_MAGIC 0xadff
|
2007-05-28 04:40:01 +08:00
|
|
|
#define BEFS_SUPER_MAGIC 0x42465331
|
2011-04-29 05:05:39 +08:00
|
|
|
#define BFS_MAGIC 0x1badface
|
|
|
|
#define CIFS_MAGIC_NUMBER 0xff534d42
|
2007-05-28 04:40:01 +08:00
|
|
|
#define CODA_SUPER_MAGIC 0x73757245
|
2011-04-29 05:05:39 +08:00
|
|
|
#define COH_SUPER_MAGIC 0x012ff7b7
|
2007-05-28 04:40:01 +08:00
|
|
|
#define CRAMFS_MAGIC 0x28cd3d45
|
|
|
|
#define DEVFS_SUPER_MAGIC 0x1373
|
2011-04-29 05:05:39 +08:00
|
|
|
#define EFS_SUPER_MAGIC 0x00414a53
|
|
|
|
#define EXT_SUPER_MAGIC 0x137d
|
|
|
|
#define EXT2_OLD_SUPER_MAGIC 0xef51
|
|
|
|
#define EXT2_SUPER_MAGIC 0xef53
|
|
|
|
#define EXT3_SUPER_MAGIC 0xef53
|
2007-05-28 04:40:01 +08:00
|
|
|
#define HFS_SUPER_MAGIC 0x4244
|
2011-04-29 05:05:39 +08:00
|
|
|
#define HPFS_SUPER_MAGIC 0xf995e849
|
2007-05-28 04:40:01 +08:00
|
|
|
#define HUGETLBFS_MAGIC 0x958458f6
|
|
|
|
#define ISOFS_SUPER_MAGIC 0x9660
|
|
|
|
#define JFFS2_SUPER_MAGIC 0x72b6
|
|
|
|
#define JFS_SUPER_MAGIC 0x3153464a
|
2011-04-29 05:05:39 +08:00
|
|
|
#define MINIX_SUPER_MAGIC 0x137f /* orig. minix */
|
|
|
|
#define MINIX_SUPER_MAGIC2 0x138f /* 30 char minix */
|
2007-05-28 04:40:01 +08:00
|
|
|
#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 */
|
|
|
|
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2, 30 char names */
|
|
|
|
#define MSDOS_SUPER_MAGIC 0x4d44
|
|
|
|
#define NCP_SUPER_MAGIC 0x564c
|
|
|
|
#define NFS_SUPER_MAGIC 0x6969
|
|
|
|
#define NTFS_SB_MAGIC 0x5346544e
|
|
|
|
#define OPENPROM_SUPER_MAGIC 0x9fa1
|
|
|
|
#define PROC_SUPER_MAGIC 0x9fa0
|
|
|
|
#define QNX4_SUPER_MAGIC 0x002f
|
|
|
|
#define REISERFS_SUPER_MAGIC 0x52654973
|
|
|
|
#define ROMFS_MAGIC 0x7275
|
|
|
|
#define SMB_SUPER_MAGIC 0x517B
|
2011-04-29 05:05:39 +08:00
|
|
|
#define SYSV2_SUPER_MAGIC 0x012ff7b6
|
2007-05-28 04:40:01 +08:00
|
|
|
#define SYSV4_SUPER_MAGIC 0x012FF7B5
|
|
|
|
#define TMPFS_MAGIC 0x01021994
|
|
|
|
#define UDF_SUPER_MAGIC 0x15013346
|
|
|
|
#define UFS_MAGIC 0x00011954
|
|
|
|
#define USBDEVICE_SUPER_MAGIC 0x9fa2
|
2011-04-29 05:05:39 +08:00
|
|
|
#define VXFS_SUPER_MAGIC 0xa501fcf5
|
|
|
|
#define XENIX_SUPER_MAGIC 0x012ff7b4
|
2007-05-28 04:40:01 +08:00
|
|
|
#define XFS_SUPER_MAGIC 0x58465342
|
2011-04-29 05:05:39 +08:00
|
|
|
#define _XIAFS_SUPER_MAGIC 0x012fd16d
|
This commit brings in an inital port of the SPIFFS flash file system into NuttX. The file system is still untested at this point (and subject to some additional review). It is, however, marked EXPERIMENTAL should this should not cause a problem for anyone.
Squashed commit of the following:
fs/spiffs: Fix last compilation issue. Now compiles without error. It is still not quite ready for testing as there is additional code review that must be be performed. It is now marked as EXPERIMENTAL so that it can be brought onto the master branch with little risk.
fs/spiffs: Remove some dead code.
fs/spiffs: Weak start of analysis of spiffs_nucleus.c. Renamed to spiffs_core.c
fs/spiffs: Rename spiffs_nucleus.c to spiffs_core.c
fs/spiffs: Remove spiffs_config.h. All configuration settings are now available in the SPIFFS Kconfig options.
fs/spiffs: Finished review, update, and repartitioning of spiffs_check.c. Added spiffs_check.h.
fs/spiffs: Finished review, update, and repartitioning of spiffs_cache.c. Added spiffs_cache.h.
fs/spiffs: Clean up some defines used in debug output statements.
fs/spiffs: Finished review, update, and repartitioning of spiffs_gc.c. Added spiffs_gc.h.
fs/spiffs: Now that VFS interface is completed, I have begun the long march of repartitioning the remaining functionality, reviewing logic, identifying dead code, and cleaning up loose ends.
fs/spiffs: Initial integration of MTD interface, replacing the SPIFFS native flash interface. Lots of open issues such as the use of pages vs. blocks vs. erase blocks and units of addresses, offsets, and lengths that are passed in function calls. Remove SPIFFS_USE_MAGIC support. That option (which default to OFF anyway), wrote a magic value at the beginning of every sector and support verifiable identification of the file system. It was not being and used and removing it makes life simpler.
fs/spiffs: Remove semaphore lock on the file object structure. Ultimately, the file access must modify the volume and access the volume structue which also has a exclusivity lock. So use of the volume lock alone should be sufficient.
Integrated the SPIFFS rename logic into the NuttX VFS. Removed non-standard application calls or convert them to IOCTL commands. These were converted to IOCTL commands: (1) integrity check, (2) garbage collection, and (3) format flash. These were removed: (1) Integrity check callback. These provided a lot of good information about the state of the file system, but such callbacks are not compatible with a POSIX compliant file system. (2) Index maps. The index maps were a performance improvement feature. The user could provide the memory and request that a region of a a file use that memory for improved lookup performance when accessing parts of the file. The fallback is the less performance lookup by traversing the FLASH memory. (3) Removed the quick garbage collection interface (the code is still used internally). Only the full garbage collection is available to the user application via IOCTL.
configs/sim/spiffs: A simulator configuration to use for testing SPIFFS.
fs/spiffs: Integrate SPIFFS logic into NuttX VFS bind() and unbind() methods.
fs/mount/fs_mount.c: Add SPIFFS to the list of drivers that require MTD vs block drivers.
fs/spiffs: Trivial changes, mostly from analysis of how to integrate the rename() VFS method.
fs/spiffs: Connect NuttX VFS unlink method to the SPIFFS_remove() function. Lots of name-changing.
fs/spiffs: Remove non-standard errno support. Remove bogus SPIFFS_LOCK() and SPIFFS_UNLOCK() macros.
fs/spiffs: Add NuttX VFS implementation for statfs() method. Clean up some of the accumulating compilation problems.
fs/spiffs: Add stat(), truncate() methods. Dummy out unsupport mkdir() and rmdir() methods.
fs/spiffs: Replace some of the custom error numbers with standard error numbers.
fs/spiffs: Hooks read(), write(), fstat(), ioctl(), opendir(), closedir(), rewindif(), and readdir() into the NuttX VFS.
fs/spiffs: Beginning the organization to work with the NuttX VFS. Lots of things are get broken!
fs/spiffs: Add spiffs.c which will be the interface between SPIFFS and NuttX. No very close at present, however.
fs/spiffs: Clean up some compile problems introduced by coding standard changes.
fs/spiffs: A little closer to NuttX coding standard.
fs/spiffs: Ran tools/indent.sh against all files. Closer to NuttX coding standard, but needs a lot more effort to be fully compliant.
fs/spiffs: This commit brings in version 0.3.7 of Peter Anderson's SPIFFS. The initial commit includes the core FS files (with some definitions destributed to their correct header files) and hooks into the build system.
2018-09-25 08:05:09 +08:00
|
|
|
#define SPIFFS_SUPER_MAGIC 0x20090315
|
2019-01-10 04:26:51 +08:00
|
|
|
#define LITTLEFS_SUPER_MAGIC 0x0a732923
|
2011-04-29 05:05:39 +08:00
|
|
|
|
|
|
|
/* NuttX specific file-systems */
|
|
|
|
|
2011-03-28 08:05:58 +08:00
|
|
|
#define BINFS_MAGIC 0x4242
|
2013-11-14 05:59:14 +08:00
|
|
|
#define PROCFS_MAGIC 0x434f5250
|
2011-04-29 05:05:39 +08:00
|
|
|
#define NXFFS_MAGIC 0x4747
|
2013-05-01 10:13:30 +08:00
|
|
|
#define SMARTFS_MAGIC 0x54524D53
|
2015-06-06 03:18:06 +08:00
|
|
|
#define UNIONFS_MAGIC 0x53464e55
|
2015-11-25 22:26:26 +08:00
|
|
|
#define HOSTFS_MAGIC 0x54534f48
|
2017-10-31 08:04:28 +08:00
|
|
|
#define USERFS_MAGIC 0x52455355
|
2018-03-19 21:08:40 +08:00
|
|
|
#define CROMFS_MAGIC 0x4d4f5243
|
2007-05-28 04:40:01 +08:00
|
|
|
|
2021-07-21 11:46:21 +08:00
|
|
|
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
|
|
|
# define statfs64 statfs
|
|
|
|
# define fstatfs64 fstatfs
|
|
|
|
#endif
|
|
|
|
|
2008-09-12 08:39:12 +08:00
|
|
|
/****************************************************************************
|
2007-05-28 04:40:01 +08:00
|
|
|
* Type Definitions
|
2008-09-12 08:39:12 +08:00
|
|
|
****************************************************************************/
|
2007-05-28 04:40:01 +08:00
|
|
|
|
|
|
|
struct statfs
|
|
|
|
{
|
2021-07-19 15:04:01 +08:00
|
|
|
uint32_t f_type; /* Type of filesystem (see definitions above) */
|
|
|
|
size_t f_namelen; /* Maximum length of filenames */
|
|
|
|
size_t f_bsize; /* Optimal block size for transfers */
|
|
|
|
fsblkcnt_t f_blocks; /* Total data blocks in the file system of this size */
|
|
|
|
fsblkcnt_t f_bfree; /* Free blocks in the file system */
|
|
|
|
fsblkcnt_t f_bavail; /* Free blocks avail to non-superuser */
|
|
|
|
fsfilcnt_t f_files; /* Total file nodes in the file system */
|
|
|
|
fsfilcnt_t f_ffree; /* Free file nodes in the file system */
|
2007-05-28 04:40:01 +08:00
|
|
|
};
|
|
|
|
|
2008-09-12 08:39:12 +08:00
|
|
|
/****************************************************************************
|
2007-05-28 04:40:01 +08:00
|
|
|
* Public Function Prototypes
|
2008-09-12 08:39:12 +08:00
|
|
|
****************************************************************************/
|
2007-05-28 04:40:01 +08:00
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
#define EXTERN extern "C"
|
2015-02-17 04:29:43 +08:00
|
|
|
extern "C"
|
|
|
|
{
|
2007-05-28 04:40:01 +08:00
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Inspired by Linux statfs() which was, in turn, inspired by
|
|
|
|
* the BSD statfs(). None of these implementations agree in the
|
|
|
|
* form of the struct statfs.
|
|
|
|
*/
|
|
|
|
|
2015-05-12 21:00:11 +08:00
|
|
|
int statfs(FAR const char *path, FAR struct statfs *buf);
|
|
|
|
int fstatfs(int fd, FAR struct statfs *buf);
|
2007-05-28 04:40:01 +08:00
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-07-17 11:58:11 +08:00
|
|
|
#endif /* __INCLUDE_SYS_STATFS_H */
|