Subversion Repositories Kolibri OS

Rev

Rev 6536 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
#ifndef	_SYS_STAT_H
2
#define	_SYS_STAT_H
3
 
4
#ifdef __cplusplus
5
extern "C" {
6
#endif
7
 
8
#include <_ansi.h>
9
#include 
6099 serge 10
#include 
4349 Serge 11
#include 
6099 serge 12
#include 
9952 turbocat 13
#include 
4349 Serge 14
 
15
/* dj's stat defines _STAT_H_ */
16
#ifndef _STAT_H_
17
 
18
/* It is intended that the layout of this structure not change when the
19
   sizes of any of the basic types change (short, int, long) [via a compile
20
   time option].  */
21
 
22
#ifdef __CYGWIN__
23
#include 
24
#ifdef _COMPILING_NEWLIB
4921 Serge 25
#define stat64 stat
4349 Serge 26
#endif
27
#else
6099 serge 28
struct	stat
4349 Serge 29
{
30
  dev_t		st_dev;
31
  ino_t		st_ino;
32
  mode_t	st_mode;
33
  nlink_t	st_nlink;
34
  uid_t		st_uid;
35
  gid_t		st_gid;
36
  dev_t		st_rdev;
37
  off_t		st_size;
38
#if defined(__rtems__)
39
  struct timespec st_atim;
40
  struct timespec st_mtim;
41
  struct timespec st_ctim;
42
  blksize_t     st_blksize;
43
  blkcnt_t	st_blocks;
44
#else
45
  /* SysV/sco doesn't have the rest... But Solaris, eabi does.  */
46
#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
47
  time_t	st_atime;
48
  time_t	st_mtime;
49
  time_t	st_ctime;
50
#else
51
  time_t	st_atime;
52
  long		st_spare1;
53
  time_t	st_mtime;
54
  long		st_spare2;
55
  time_t	st_ctime;
56
  long		st_spare3;
57
  long		st_blksize;
58
  long		st_blocks;
59
  long	st_spare4[2];
60
#endif
61
#endif
62
};
63
 
64
#if defined(__rtems__)
65
#define st_atime st_atim.tv_sec
66
#define st_ctime st_ctim.tv_sec
67
#define st_mtime st_mtim.tv_sec
68
#endif
69
 
70
#endif
71
 
72
#define	_IFMT		0170000	/* type of file */
73
#define		_IFDIR	0040000	/* directory */
74
#define		_IFCHR	0020000	/* character special */
75
#define		_IFBLK	0060000	/* block special */
76
#define		_IFREG	0100000	/* regular */
77
#define		_IFLNK	0120000	/* symbolic link */
78
#define		_IFSOCK	0140000	/* socket */
79
#define		_IFIFO	0010000	/* fifo */
80
 
81
#define 	S_BLKSIZE  1024 /* size of a block */
82
 
83
#define	S_ISUID		0004000	/* set user id on execution */
84
#define	S_ISGID		0002000	/* set group id on execution */
85
#define	S_ISVTX		0001000	/* save swapped text even after use */
6536 serge 86
#if __BSD_VISIBLE
4349 Serge 87
#define	S_IREAD		0000400	/* read permission, owner */
88
#define	S_IWRITE 	0000200	/* write permission, owner */
89
#define	S_IEXEC		0000100	/* execute/search permission, owner */
90
#define	S_ENFMT 	0002000	/* enforcement-mode locking */
6536 serge 91
#endif	/* !_BSD_VISIBLE */
4349 Serge 92
 
93
#define	S_IFMT		_IFMT
94
#define	S_IFDIR		_IFDIR
95
#define	S_IFCHR		_IFCHR
96
#define	S_IFBLK		_IFBLK
97
#define	S_IFREG		_IFREG
98
#define	S_IFLNK		_IFLNK
99
#define	S_IFSOCK	_IFSOCK
100
#define	S_IFIFO		_IFIFO
101
 
102
#ifdef _WIN32
103
/* The Windows header files define _S_ forms of these, so we do too
104
   for easier portability.  */
105
#define _S_IFMT		_IFMT
106
#define _S_IFDIR	_IFDIR
107
#define _S_IFCHR	_IFCHR
108
#define _S_IFIFO	_IFIFO
109
#define _S_IFREG	_IFREG
110
#define _S_IREAD	0000400
111
#define _S_IWRITE	0000200
112
#define _S_IEXEC	0000100
113
#endif
114
 
115
#define	S_IRWXU 	(S_IRUSR | S_IWUSR | S_IXUSR)
116
#define		S_IRUSR	0000400	/* read permission, owner */
117
#define		S_IWUSR	0000200	/* write permission, owner */
118
#define		S_IXUSR 0000100/* execute/search permission, owner */
119
#define	S_IRWXG		(S_IRGRP | S_IWGRP | S_IXGRP)
120
#define		S_IRGRP	0000040	/* read permission, group */
121
#define		S_IWGRP	0000020	/* write permission, grougroup */
122
#define		S_IXGRP 0000010/* execute/search permission, group */
123
#define	S_IRWXO		(S_IROTH | S_IWOTH | S_IXOTH)
124
#define		S_IROTH	0000004	/* read permission, other */
125
#define		S_IWOTH	0000002	/* write permission, other */
126
#define		S_IXOTH 0000001/* execute/search permission, other */
127
 
6536 serge 128
#if __BSD_VISIBLE
4349 Serge 129
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
130
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
131
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
132
#endif
133
 
134
#define	S_ISBLK(m)	(((m)&_IFMT) == _IFBLK)
135
#define	S_ISCHR(m)	(((m)&_IFMT) == _IFCHR)
136
#define	S_ISDIR(m)	(((m)&_IFMT) == _IFDIR)
137
#define	S_ISFIFO(m)	(((m)&_IFMT) == _IFIFO)
138
#define	S_ISREG(m)	(((m)&_IFMT) == _IFREG)
139
#define	S_ISLNK(m)	(((m)&_IFMT) == _IFLNK)
140
#define	S_ISSOCK(m)	(((m)&_IFMT) == _IFSOCK)
141
 
142
#if defined(__CYGWIN__)
143
/* Special tv_nsec values for futimens(2) and utimensat(2). */
144
#define UTIME_NOW	-2L
145
#define UTIME_OMIT	-1L
146
#endif
147
 
6536 serge 148
int	_EXFUN(chmod,( const char *__path, mode_t __mode ));
149
int     _EXFUN(fchmod,(int __fd, mode_t __mode));
4349 Serge 150
int	_EXFUN(fstat,( int __fd, struct stat *__sbuf ));
151
int	_EXFUN(mkfifo,( const char *__path, mode_t __mode ));
4921 Serge 152
int	_EXFUN(stat,( const char *__restrict __path, struct stat *__restrict __sbuf ));
4349 Serge 153
mode_t	_EXFUN(umask,( mode_t __mask ));
154
 
9952 turbocat 155
#define mkdir(path, mode) _ksys_mkdir(path)
156
 
4349 Serge 157
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
4921 Serge 158
int	_EXFUN(lstat,( const char *__restrict __path, struct stat *__restrict __buf ));
4349 Serge 159
int	_EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev ));
160
#endif
161
 
6536 serge 162
#if __ATFILE_VISIBLE && !defined(__INSIDE_CYGWIN__)
4349 Serge 163
int	_EXFUN(fchmodat, (int, const char *, mode_t, int));
4921 Serge 164
int	_EXFUN(fstatat, (int, const char *__restrict , struct stat *__restrict, int));
4349 Serge 165
int	_EXFUN(mkdirat, (int, const char *, mode_t));
166
int	_EXFUN(mkfifoat, (int, const char *, mode_t));
167
int	_EXFUN(mknodat, (int, const char *, mode_t, dev_t));
6536 serge 168
int	_EXFUN(utimensat, (int, const char *, const struct timespec *, int));
6099 serge 169
#endif
6536 serge 170
#if __POSIX_VISIBLE >= 200809 && !defined(__INSIDE_CYGWIN__)
4349 Serge 171
int	_EXFUN(futimens, (int, const struct timespec *));
172
#endif
173
 
174
/* Provide prototypes for most of the _ names that are
175
   provided in newlib for some compilers.  */
176
#ifdef _COMPILING_NEWLIB
177
int	_EXFUN(_fstat,( int __fd, struct stat *__sbuf ));
4921 Serge 178
int	_EXFUN(_stat,( const char *__restrict __path, struct stat *__restrict __sbuf ));
179
int	_EXFUN(_mkdir,( const char *_path, mode_t __mode ));
4349 Serge 180
#ifdef __LARGE64_FILES
181
struct stat64;
4921 Serge 182
int	_EXFUN(_stat64,( const char *__restrict __path, struct stat64 *__restrict __sbuf ));
4349 Serge 183
int	_EXFUN(_fstat64,( int __fd, struct stat64 *__sbuf ));
184
#endif
185
#endif
186
 
187
#endif /* !_STAT_H_ */
188
#ifdef __cplusplus
189
}
190
#endif
191
#endif /* _SYS_STAT_H */