2008-07-20 22:58:32 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* include/sys/stat.h
|
2007-05-19 23:30:57 +02:00
|
|
|
*
|
2020-05-28 15:39:46 +02: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-19 23:30:57 +02:00
|
|
|
*
|
2020-05-28 15:39:46 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-05-19 23:30:57 +02:00
|
|
|
*
|
2020-05-28 15:39:46 +02: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-19 23:30:57 +02:00
|
|
|
*
|
2008-07-20 22:58:32 +02:00
|
|
|
****************************************************************************/
|
2007-05-19 23:30:57 +02:00
|
|
|
|
2012-07-17 05:58:11 +02:00
|
|
|
#ifndef __INCLUDE_SYS_STAT_H
|
|
|
|
#define __INCLUDE_SYS_STAT_H
|
2007-05-19 23:30:57 +02:00
|
|
|
|
2008-07-20 22:58:32 +02:00
|
|
|
/****************************************************************************
|
2007-05-19 23:30:57 +02:00
|
|
|
* Included Files
|
2008-07-20 22:58:32 +02:00
|
|
|
****************************************************************************/
|
2007-05-19 23:30:57 +02:00
|
|
|
|
2017-02-07 19:32:45 +01:00
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2007-05-19 23:30:57 +02:00
|
|
|
#include <sys/types.h>
|
2007-05-27 20:08:18 +02:00
|
|
|
#include <time.h>
|
|
|
|
|
2008-07-20 22:58:32 +02:00
|
|
|
/****************************************************************************
|
2015-02-16 21:29:43 +01:00
|
|
|
* Pre-processor Definitions
|
2008-07-20 22:58:32 +02:00
|
|
|
****************************************************************************/
|
2007-05-27 20:08:18 +02:00
|
|
|
|
2012-04-18 17:57:45 +02:00
|
|
|
/* mode_t bit settings (most of these do not apply to Nuttx). This assumes
|
|
|
|
* that the full size of a mode_t is 16-bits. (However, mode_t must be size
|
|
|
|
* 'int' because it is promoted to size int when passed in varargs).
|
2017-02-03 20:22:33 +01:00
|
|
|
*
|
|
|
|
* LTTT ...U UUGG GOOO
|
|
|
|
*
|
|
|
|
* Bits 0-2: Permissions for others
|
|
|
|
* Bits 3-5: Group permissions
|
|
|
|
* Bits 6-8: Owner permissions
|
2018-04-26 14:49:13 +02:00
|
|
|
* Bits 9-10: Not used
|
|
|
|
* Bits 11-14: File type bits
|
2017-02-03 20:22:33 +01:00
|
|
|
* Bit 15: Symbolic link
|
2007-05-27 20:08:18 +02:00
|
|
|
*/
|
|
|
|
|
2017-02-03 20:22:33 +01:00
|
|
|
#define S_IXOTH (1 << 0) /* Bits 0-2: Permissions for others: RWX */
|
|
|
|
#define S_IWOTH (1 << 1)
|
|
|
|
#define S_IROTH (1 << 2)
|
|
|
|
#define S_IRWXO (7 << 0)
|
|
|
|
|
|
|
|
#define S_IXGRP (1 << 3) /* Bits 3-5: Group permissions: RWX */
|
|
|
|
#define S_IWGRP (1 << 4)
|
|
|
|
#define S_IRGRP (1 << 5)
|
|
|
|
#define S_IRWXG (7 << 3)
|
|
|
|
|
|
|
|
#define S_IXUSR (1 << 6) /* Bits 6-8: Owner permissions: RWX */
|
|
|
|
#define S_IWUSR (1 << 7)
|
|
|
|
#define S_IRUSR (1 << 8)
|
|
|
|
#define S_IRWXU (7 << 6)
|
|
|
|
|
2020-07-05 17:30:43 +02:00
|
|
|
#define S_ISVTX (1 << 9) /* "Sticky" bit (not used) */
|
|
|
|
#define S_ISGID (1 << 10) /* Set group ID bit (not used)*/
|
|
|
|
#define S_ISUID (1 << 11) /* Set UID bit (not used) */
|
|
|
|
|
|
|
|
#define S_IFIFO (1 << 12) /* Bits 12-15: File type bits (not all used) */
|
|
|
|
#define S_IFCHR (2 << 12)
|
|
|
|
#define S_IFSEM (3 << 12)
|
|
|
|
#define S_IFDIR (4 << 12)
|
|
|
|
#define S_IFMQ (5 << 12)
|
|
|
|
#define S_IFBLK (6 << 12)
|
|
|
|
#define S_IFSHM (7 << 12)
|
|
|
|
#define S_IFREG (8 << 12)
|
|
|
|
#define S_IFMTD (9 << 12)
|
|
|
|
#define S_IFLNK (10 << 12)
|
|
|
|
#define S_IFSOCK (12 << 12)
|
|
|
|
#define S_IFMT (15 << 12)
|
2007-05-27 20:08:18 +02:00
|
|
|
|
|
|
|
/* File type macros that operate on an instance of mode_t */
|
|
|
|
|
2020-07-05 17:30:43 +02:00
|
|
|
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
|
|
|
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
|
|
|
#define S_ISSEM(m) (((m) & S_IFMT) == S_IFSEM)
|
|
|
|
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
|
|
|
#define S_ISMQ(m) (((m) & S_IFMT) == S_IFMQ)
|
|
|
|
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
|
|
|
#define S_ISSHM(m) (((m) & S_IFMT) == S_IFSHM)
|
|
|
|
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
|
|
|
#define S_ISMTD(m) (((m) & S_IFMT) == S_IFMTD)
|
|
|
|
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
|
|
|
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
|
|
|
|
|
|
|
/* These are from POSIX.1b. If the objects are not implemented using separate
|
|
|
|
* distinct file types, the macros always will evaluate to zero. Unlike the
|
|
|
|
* other S_* macros the following three take a pointer to a `struct stat'
|
|
|
|
* object as the argument.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define S_TYPEISSEM(buf) S_ISSEM((buf)->st_mode)
|
|
|
|
#define S_TYPEISMQ(buf) S_ISMQ((buf)->st_mode)
|
|
|
|
#define S_TYPEISSHM(buf) S_ISSHM((buf)->st_mode)
|
2007-05-19 23:30:57 +02:00
|
|
|
|
2020-04-30 20:05:12 +02:00
|
|
|
/* The following macros are required by POSIX to acheive backward
|
|
|
|
* compatibility with earlier versions of struct stat.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define st_atime st_atim.tv_sec
|
|
|
|
#define st_ctime st_ctim.tv_sec
|
|
|
|
#define st_mtime st_mtim.tv_sec
|
|
|
|
|
2008-07-20 22:58:32 +02:00
|
|
|
/****************************************************************************
|
2007-05-19 23:30:57 +02:00
|
|
|
* Type Definitions
|
2008-07-20 22:58:32 +02:00
|
|
|
****************************************************************************/
|
2007-05-19 23:30:57 +02:00
|
|
|
|
2015-06-02 19:43:44 +02:00
|
|
|
/* This is the simplified struct stat as returned by stat() and fstat().
|
|
|
|
* This structure provides information about a specific file or directory in
|
|
|
|
* the file system.
|
2007-05-27 20:08:18 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct stat
|
|
|
|
{
|
2017-02-07 22:50:39 +01:00
|
|
|
/* Required, standard fields */
|
|
|
|
|
2020-04-30 20:05:12 +02:00
|
|
|
dev_t st_dev; /* Device ID of device containing file */
|
|
|
|
ino_t st_ino; /* File serial number */
|
|
|
|
mode_t st_mode; /* File type, attributes, and access mode bits */
|
|
|
|
nlink_t st_nlink; /* Number of hard links to the file */
|
|
|
|
uid_t st_uid; /* User ID of file */
|
|
|
|
gid_t st_gid; /* Group ID of file */
|
|
|
|
dev_t st_rdev; /* Device ID (if file is character or block special) */
|
|
|
|
off_t st_size; /* Size of file/directory, in bytes */
|
|
|
|
struct timespec st_atim; /* Time of last access */
|
|
|
|
struct timespec st_mtim; /* Time of last modification */
|
|
|
|
struct timespec st_ctim; /* Time of last status change */
|
|
|
|
blksize_t st_blksize; /* Block size used for filesystem I/O */
|
|
|
|
blkcnt_t st_blocks; /* Number of blocks allocated */
|
2017-02-07 22:50:39 +01:00
|
|
|
|
2017-02-13 17:07:43 +01:00
|
|
|
/* Internal fields. These are part this specific implementation and
|
|
|
|
* should not referenced by application code for portability reasons.
|
2017-02-07 22:50:39 +01:00
|
|
|
*/
|
|
|
|
|
2017-02-07 19:32:45 +01:00
|
|
|
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
|
2017-02-07 22:50:39 +01:00
|
|
|
uint8_t st_count; /* Used internally to limit traversal of links */
|
2017-02-07 19:32:45 +01:00
|
|
|
#endif
|
2007-05-27 20:08:18 +02:00
|
|
|
};
|
|
|
|
|
2008-07-20 22:58:32 +02:00
|
|
|
/****************************************************************************
|
2015-10-03 00:30:35 +02:00
|
|
|
* Public Function Prototypes
|
2008-07-20 22:58:32 +02:00
|
|
|
****************************************************************************/
|
2007-05-21 16:36:00 +02:00
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
#define EXTERN extern "C"
|
2014-07-24 23:04:50 +02:00
|
|
|
extern "C"
|
|
|
|
{
|
2007-05-21 16:36:00 +02:00
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2014-07-24 23:04:50 +02:00
|
|
|
int mkdir(FAR const char *pathname, mode_t mode);
|
|
|
|
int mkfifo(FAR const char *pathname, mode_t mode);
|
2017-09-29 16:33:36 +02:00
|
|
|
int stat(FAR const char *path, FAR struct stat *buf);
|
2020-06-22 10:44:32 +02:00
|
|
|
int lstat(FAR const char *path, FAR struct stat *buf);
|
2014-07-24 23:04:50 +02:00
|
|
|
int fstat(int fd, FAR struct stat *buf);
|
2020-06-22 05:11:56 +02:00
|
|
|
int chmod(FAR const char *path, mode_t mode);
|
|
|
|
int fchmod(int fd, mode_t mode);
|
2007-05-21 16:36:00 +02:00
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-07-17 05:58:11 +02:00
|
|
|
#endif /* __INCLUDE_SYS_STAT_H */
|