Tizen RT Libs&Environment  v1.0 D5
stat.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /****************************************************************************
19  * include/sys/stat.h
20  *
21  * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ****************************************************************************/
52 
61 
64 #ifndef __INCLUDE_SYS_STAT_H
65 #define __INCLUDE_SYS_STAT_H
66 
67 /****************************************************************************
68  * Included Files
69  ****************************************************************************/
70 
71 #include <sys/types.h>
72 #include <time.h>
73 
74 /****************************************************************************
75  * Definitions
76  ****************************************************************************/
77 
78 /* mode_t bit settings (most of these do not apply to TinyAra). This assumes
79  * that the full size of a mode_t is 16-bits. (However, mode_t must be size
80  * 'int' because it is promoted to size int when passed in varargs).
81  */
82 
83 #define S_IXOTH 0000001 /* Permissions for others: RWX */
84 #define S_IWOTH 0000002
85 #define S_IROTH 0000004
86 #define S_IRWXO 0000007
87 
88 #define S_IXGRP 0000010 /* Group permissions: RWX */
89 #define S_IWGRP 0000020
90 #define S_IRGRP 0000040
91 #define S_IRWXG 0000070
92 
93 #define S_IXUSR 0000100 /* Owner permissions: RWX */
94 #define S_IWUSR 0000200
95 #define S_IRUSR 0000400
96 #define S_IRWXU 0000700
97 
98 #define S_ISVTX 0001000 /* "sticky" bit */
99 #define S_ISGID 0002000 /* Set group ID bit */
100 #define S_ISUID 0004000 /* Set UID bit */
101 
102 #define S_IFIFO 0010000 /* File type bytes */
103 #define S_IFCHR 0020000
104 #define S_IFDIR 0040000
105 #define S_IFBLK 0060000
106 #define S_IFREG 0100000
107 #define S_IFLNK 0120000
108 #define S_IFSOCK 0140000
109 #define S_IFMQ 0150000
110 #define S_IFSEM 0160000
111 #define S_IFSHM 0170000
112 #define S_IFMT 0170000
113 
114 /* File type macros that operate on an instance of mode_t */
115 
116 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
117 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
118 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
119 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
120 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
121 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
122 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
123 #define S_ISMQ(m) (((m) & S_IFMT) == S_IFMQ)
124 #define S_ISSSEM(m) (((m) & S_IFMT) == S_IFSEM)
125 #define S_ISSHM(m) (((m) & S_IFMT) == S_IFSHM)
126 
127 /****************************************************************************
128  * Type Definitions
129  ****************************************************************************/
130 
131 /* This is the simplified struct stat as returned by fstat(). This structure
132  * provides information about a specific file or directory in the file system.
133  */
134 
135 struct stat {
136  mode_t st_mode; /* File type, atributes, and access mode bits */
137  off_t st_size; /* Size of file/directory, in bytes */
138  blksize_t st_blksize; /* Blocksize used for filesystem I/O */
139  blkcnt_t st_blocks; /* Number of blocks allocated */
140  time_t st_atime; /* Time of last access */
141  time_t st_mtime; /* Time of last modification */
142  time_t st_ctime; /* Time of last status change */
143 };
144 
145 /****************************************************************************
146  * Global Function Prototypes
147  ****************************************************************************/
148 
149 #undef EXTERN
150 #if defined(__cplusplus)
151 #define EXTERN extern "C"
152 extern "C" {
153 #else
154 #define EXTERN extern
155 #endif
156 
163 int mkdir(FAR const char *pathname, mode_t mode);
170 int mkfifo(FAR const char *pathname, mode_t mode);
177 int stat(const char *path, FAR struct stat *buf);
182 int fstat(int fd, FAR struct stat *buf);
186 #undef EXTERN
187 #if defined(__cplusplus)
188 }
189 #endif
190 
191 #endif /* __INCLUDE_SYS_STAT_H */
192 
int mkdir(FAR const char *pathname, mode_t mode)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
blkcnt_t st_blocks
Definition: stat.h:139
uint32_t time_t
Definition: time.h:145
blksize_t st_blksize
Definition: stat.h:138
mode_t st_mode
Definition: stat.h:136
Definition: stat.h:135
int stat(const char *path, FAR struct stat *buf)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int mkfifo(FAR const char *pathname, mode_t mode)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
time_t st_ctime
Definition: stat.h:142
time_t st_atime
Definition: stat.h:140
time_t st_mtime
Definition: stat.h:141
off_t st_size
Definition: stat.h:137