1 #ifndef CYGONCE_ISO_STAT_H
2 #define CYGONCE_ISO_STAT_H
3 /*========================================================================
7 // POSIX file characteristics
9 //========================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later version.
19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 // You should have received a copy of the GNU General Public License along
25 // with eCos; if not, write to the Free Software Foundation, Inc.,
26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28 // As a special exception, if other files instantiate templates or use macros
29 // or inline functions from this file, or you compile this file and link it
30 // with other works to produce a work based on this file, this file does not
31 // by itself cause the resulting work to be covered by the GNU General Public
32 // License. However the source code for this file must still be made available
33 // in accordance with section (3) of the GNU General Public License.
35 // This exception does not invalidate any other reasons why a work based on
36 // this file might be covered by the GNU General Public License.
38 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39 // at http://sources.redhat.com/ecos/ecos-license/
40 // -------------------------------------------
41 //####ECOSGPLCOPYRIGHTEND####
42 //========================================================================
43 //#####DESCRIPTIONBEGIN####
45 // Author(s): jlarmour
48 // Purpose: This file provides the macros, types and functions
49 // for file characteristics required by POSIX 1003.1.
50 // Description: The real contents of this file get set from the
51 // configuration (set by the implementation)
52 // Usage: #include <sys/stat.h>
54 //####DESCRIPTIONEND####
56 //======================================================================
61 #include <pkgconf/isoinfra.h> /* Configuration header */
65 #ifdef CYGBLD_ISO_STAT_DEFS_HEADER
66 # include CYGBLD_ISO_STAT_DEFS_HEADER
69 #include <sys/types.h> /* ino_t, dev_t, etc. */
70 #include <time.h> /* time_t */
72 #define __stat_mode_DIR (1<<0)
73 #define __stat_mode_CHR (1<<1)
74 #define __stat_mode_BLK (1<<2)
75 #define __stat_mode_REG (1<<3)
76 #define __stat_mode_FIFO (1<<4)
77 #define __stat_mode_MQ (1<<5)
78 #define __stat_mode_SEM (1<<6)
79 #define __stat_mode_SHM (1<<7)
80 #define __stat_mode_LNK (1<<8)
81 #define __stat_mode_SOCK (1<<9)
83 #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE >= 200112L)
84 #define S_IFDIR (__stat_mode_DIR)
85 #define S_IFCHR (__stat_mode_CHR)
86 #define S_IFBLK (__stat_mode_BLK)
87 #define S_IFREG (__stat_mode_REG)
88 #define S_IFIFO (__stat_mode_FIFO)
89 #define S_IFLNK (__stat_mode_LNK)
90 #define S_IFSOCK (__stat_mode_SOCK)
91 #define S_IFMT (S_IFDIR|S_IFCHR|S_IFBLK|S_IFREG| \
92 S_IFIFO|S_IFLNK|S_IFSOCK)
95 #define S_ISDIR(__mode) ((__mode) & __stat_mode_DIR )
96 #define S_ISCHR(__mode) ((__mode) & __stat_mode_CHR )
97 #define S_ISBLK(__mode) ((__mode) & __stat_mode_BLK )
98 #define S_ISREG(__mode) ((__mode) & __stat_mode_REG )
99 #define S_ISFIFO(__mode) ((__mode) & __stat_mode_FIFO )
100 #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE >= 200112L)
101 #define S_ISLNK(__mode) ((__mode) & __stat_mode_LNK )
102 #define S_ISSOCK(__mode) ((__mode) & __stat_mode_SOCK )
105 #define S_TYPEISMQ(__buf) ((__buf)->st_mode & __stat_mode_MQ )
106 #define S_TYPEISSEM(__buf) ((__buf)->st_mode & __stat_mode_SEM )
107 #define S_TYPEISSHM(__buf) ((__buf)->st_mode & __stat_mode_SHM )
110 #define S_IRUSR (1<<16)
111 #define S_IWUSR (1<<17)
112 #define S_IXUSR (1<<18)
113 #define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
115 #define S_IRGRP (1<<19)
116 #define S_IWGRP (1<<20)
117 #define S_IXGRP (1<<21)
118 #define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
120 #define S_IROTH (1<<22)
121 #define S_IWOTH (1<<23)
122 #define S_IXOTH (1<<24)
123 #define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
125 #define S_ISUID (1<<25)
126 #define S_ISGID (1<<26)
130 mode_t st_mode; /* File mode */
131 ino_t st_ino; /* File serial number */
132 dev_t st_dev; /* ID of device containing file */
133 nlink_t st_nlink; /* Number of hard links */
134 uid_t st_uid; /* User ID of the file owner */
135 gid_t st_gid; /* Group ID of the file's group */
136 off_t st_size; /* File size (regular files only) */
137 time_t st_atime; /* Last access time */
138 time_t st_mtime; /* Last data modification time */
139 time_t st_ctime; /* Last file status change time */
142 #endif /* ifndef CYGBLD_ISO_STAT_DEFS_HEADER */
146 __externC int stat( const char *path, struct stat *buf );
148 __externC int fstat( int fd, struct stat *buf );
150 __externC int mkdir(const char *path, mode_t mode);
152 #endif /* CYGONCE_ISO_STAT_H multiple inclusion protection */