• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2  * include/sys/statfs.h
3  *
4  *   Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
5  *   Author: Gregory Nutt <gnutt@nuttx.org>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name NuttX nor the names of its contributors may be
18  *    used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  ****************************************************************************/
35 
36 #ifndef __INCLUDE_SYS_STATFS_H
37 #define __INCLUDE_SYS_STATFS_H
38 
39 /****************************************************************************
40  * Included Files
41  ****************************************************************************/
42 
43 #include <nuttx/config.h>
44 
45 #include <sys/types.h>
46 #include <stdint.h>
47 
48 /****************************************************************************
49  * Pre-processor Definitions
50  ****************************************************************************/
51 
52 /* struct statfs file system types. */
53 
54 #define ADFS_SUPER_MAGIC      0xadf5
55 #define AFFS_SUPER_MAGIC      0xadff
56 #define BEFS_SUPER_MAGIC      0x42465331
57 #define BFS_MAGIC             0x1badface
58 #define CIFS_MAGIC_NUMBER     0xff534d42
59 #define CODA_SUPER_MAGIC      0x73757245
60 #define COH_SUPER_MAGIC       0x012ff7b7
61 #define CRAMFS_MAGIC          0x28cd3d45
62 #define DEVFS_SUPER_MAGIC     0x1373
63 #define EFS_SUPER_MAGIC       0x00414a53
64 #define EXT_SUPER_MAGIC       0x137d
65 #define EXT2_OLD_SUPER_MAGIC  0xef51
66 #define EXT2_SUPER_MAGIC      0xef53
67 #define EXT3_SUPER_MAGIC      0xef53
68 #define HFS_SUPER_MAGIC       0x4244
69 #define HPFS_SUPER_MAGIC      0xf995e849
70 #define HUGETLBFS_MAGIC       0x958458f6
71 #define ISOFS_SUPER_MAGIC     0x9660
72 #define JFFS2_SUPER_MAGIC     0x72b6
73 #define JFS_SUPER_MAGIC       0x3153464a
74 #define MINIX_SUPER_MAGIC     0x137f /* orig. minix */
75 #define MINIX_SUPER_MAGIC2    0x138f /* 30 char minix */
76 #define MINIX2_SUPER_MAGIC    0x2468 /* minix V2 */
77 #define MINIX2_SUPER_MAGIC2   0x2478 /* minix V2, 30 char names */
78 #define MSDOS_SUPER_MAGIC     0x4d44
79 #define NCP_SUPER_MAGIC       0x564c
80 #define NFS_SUPER_MAGIC       0x6969
81 #define NTFS_SB_MAGIC         0x5346544e
82 #define OPENPROM_SUPER_MAGIC  0x9fa1
83 #define PROC_SUPER_MAGIC      0x9fa0
84 #define QNX4_SUPER_MAGIC      0x002f
85 #define REISERFS_SUPER_MAGIC  0x52654973
86 #define ROMFS_MAGIC           0x7275
87 #define SMB_SUPER_MAGIC       0x517B
88 #define SYSV2_SUPER_MAGIC     0x012ff7b6
89 #define SYSV4_SUPER_MAGIC     0x012FF7B5
90 #define TMPFS_MAGIC           0x01021994
91 #define UDF_SUPER_MAGIC       0x15013346
92 #define UFS_MAGIC             0x00011954
93 #define USBDEVICE_SUPER_MAGIC 0x9fa2
94 #define VXFS_SUPER_MAGIC      0xa501fcf5
95 #define XENIX_SUPER_MAGIC     0x012ff7b4
96 #define XFS_SUPER_MAGIC       0x58465342
97 #define _XIAFS_SUPER_MAGIC    0x012fd16d
98 #define SPIFFS_SUPER_MAGIC    0x20090315
99 #define LITTLEFS_SUPER_MAGIC  0x0a732923
100 #define ZPFS_MAGIC            0xa000e93
101 
102 /* NuttX specific file-systems */
103 
104 #define BINFS_MAGIC           0x4242
105 #define PROCFS_MAGIC          0x434f5250
106 #define NXFFS_MAGIC           0x4747
107 #define SMARTFS_MAGIC         0x54524D53
108 #define UNIONFS_MAGIC         0x53464e55
109 #define HOSTFS_MAGIC          0x54534f48
110 #define USERFS_MAGIC          0x52455355
111 #define CROMFS_MAGIC          0x4d4f5243
112 
113 /****************************************************************************
114  * Type Definitions
115  ****************************************************************************/
116 
117 struct statfs
118 {
119   uint32_t f_type;     /* Type of filesystem (see definitions above) */
120   size_t   f_namelen;  /* Maximum length of filenames */
121   size_t   f_bsize;    /* Optimal block size for transfers */
122   off_t    f_blocks;   /* Total data blocks in the file system of this size */
123   off_t    f_bfree;    /* Free blocks in the file system */
124   off_t    f_bavail;   /* Free blocks avail to non-superuser */
125   off_t    f_files;    /* Total file nodes in the file system */
126   off_t    f_ffree;    /* Free file nodes in the file system */
127 };
128 
129 /****************************************************************************
130  * Public Function Prototypes
131  ****************************************************************************/
132 
133 #undef EXTERN
134 #if defined(__cplusplus)
135 #define EXTERN extern "C"
136 extern "C"
137 {
138 #else
139 #define EXTERN extern
140 #endif
141 
142 /* Inspired by Linux statfs() which was, in turn, inspired by
143  * the BSD statfs(). None of these implementations agree in the
144  * form of the struct statfs.
145  */
146 
147 int statfs(FAR const char *path, FAR struct statfs *buf);
148 int fstatfs(int fd, FAR struct statfs *buf);
149 
150 #undef EXTERN
151 #if defined(__cplusplus)
152 }
153 #endif
154 
155 #endif /* __INCLUDE_SYS_STATFS_H */
156