1.1 --- a/epoc32/include/stdapis/sys/stat.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/sys/stat.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,330 @@
1.4 -stat.h
1.5 +/*-
1.6 + * Copyright (c) 1982, 1986, 1989, 1993
1.7 + * The Regents of the University of California. All rights reserved.
1.8 + * (c) UNIX System Laboratories, Inc.
1.9 + * All or some portions of this file are derived from material licensed
1.10 + * to the University of California by American Telephone and Telegraph
1.11 + * Co. or Unix System Laboratories, Inc. and are reproduced herein with
1.12 + * the permission of UNIX System Laboratories, Inc.
1.13 + *
1.14 + * Redistribution and use in source and binary forms, with or without
1.15 + * modification, are permitted provided that the following conditions
1.16 + * are met:
1.17 + * 1. Redistributions of source code must retain the above copyright
1.18 + * notice, this list of conditions and the following disclaimer.
1.19 + * 2. Redistributions in binary form must reproduce the above copyright
1.20 + * notice, this list of conditions and the following disclaimer in the
1.21 + * documentation and/or other materials provided with the distribution.
1.22 + * 4. Neither the name of the University nor the names of its contributors
1.23 + * may be used to endorse or promote products derived from this software
1.24 + * without specific prior written permission.
1.25 + *
1.26 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1.27 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.28 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.29 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1.30 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.31 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1.32 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.33 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1.34 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1.35 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1.36 + * SUCH DAMAGE.
1.37 + * © Portions copyright (c) 2007 Symbian Software Ltd. All rights reserved.
1.38 + * @(#)stat.h 8.12 (Berkeley) 6/16/95
1.39 + * $FreeBSD: src/sys/sys/stat.h,v 1.41 2005/03/22 01:19:18 das Exp $
1.40 + */
1.41 +
1.42 +#ifndef _SYS_STAT_H_
1.43 +#define _SYS_STAT_H_
1.44 +
1.45 +#include <sys/cdefs.h>
1.46 +#include <sys/_types.h>
1.47 +
1.48 +#ifndef _BLKSIZE_T_DECLARED
1.49 +typedef __blksize_t blksize_t;
1.50 +#define _BLKSIZE_T_DECLARED
1.51 +#endif
1.52 +
1.53 +#ifndef _BLKCNT_T_DECLARED
1.54 +typedef __blkcnt_t blkcnt_t;
1.55 +#define _BLKCNT_T_DECLARED
1.56 +#endif
1.57 +
1.58 +#ifndef _DEV_T_DECLARED
1.59 +typedef __dev_t dev_t;
1.60 +#define _DEV_T_DECLARED
1.61 +#endif
1.62 +
1.63 +#ifndef _FFLAGS_T_DECLARED
1.64 +typedef __fflags_t fflags_t;
1.65 +#define _FFLAGS_T_DECLARED
1.66 +#endif
1.67 +
1.68 +#ifndef _GID_T_DECLARED
1.69 +typedef __gid_t gid_t;
1.70 +#define _GID_T_DECLARED
1.71 +#endif
1.72 +
1.73 +#ifndef _INO_T_DECLARED
1.74 +typedef __ino_t ino_t;
1.75 +#define _INO_T_DECLARED
1.76 +#endif
1.77 +
1.78 +#ifndef _MODE_T_DECLARED
1.79 +typedef __mode_t mode_t;
1.80 +#define _MODE_T_DECLARED
1.81 +#endif
1.82 +
1.83 +#ifndef _NLINK_T_DECLARED
1.84 +typedef __nlink_t nlink_t;
1.85 +#define _NLINK_T_DECLARED
1.86 +#endif
1.87 +
1.88 +#ifndef _OFF_T_DECLARED
1.89 +typedef __off_t off_t;
1.90 +#define _OFF_T_DECLARED
1.91 +#endif
1.92 +
1.93 +#ifndef _TIME_T_DECLARED
1.94 +typedef __time_t time_t;
1.95 +#define _TIME_T_DECLARED
1.96 +#endif
1.97 +
1.98 +#ifndef _UID_T_DECLARED
1.99 +typedef __uid_t uid_t;
1.100 +#define _UID_T_DECLARED
1.101 +#endif
1.102 +
1.103 +#if !defined(_KERNEL) && __BSD_VISIBLE
1.104 +/*
1.105 + * XXX we need this for struct timespec. We get miscellaneous namespace
1.106 + * pollution with it.
1.107 + */
1.108 +#include <sys/time.h>
1.109 +#endif
1.110 +
1.111 +#if !__BSD_VISIBLE
1.112 +#include <sys/_timespec.h>
1.113 +#endif
1.114 +
1.115 +#if __BSD_VISIBLE
1.116 +struct ostat {
1.117 + __uint16_t st_dev; /* inode's device */
1.118 + ino_t st_ino; /* inode's number */
1.119 + mode_t st_mode; /* inode protection mode */
1.120 + nlink_t st_nlink; /* number of hard links */
1.121 + __uint16_t st_uid; /* user ID of the file's owner */
1.122 + __uint16_t st_gid; /* group ID of the file's group */
1.123 + __uint16_t st_rdev; /* device type */
1.124 + __int32_t st_size; /* file size, in bytes */
1.125 + struct timespec st_atimespec; /* time of last access */
1.126 + struct timespec st_mtimespec; /* time of last data modification */
1.127 + struct timespec st_ctimespec; /* time of last file status change */
1.128 + __int32_t st_blksize; /* optimal blocksize for I/O */
1.129 + __int32_t st_blocks; /* blocks allocated for file */
1.130 + fflags_t st_flags; /* user defined flags for file */
1.131 + __uint32_t st_gen; /* file generation number */
1.132 +};
1.133 +#endif /* __BSD_VISIBLE */
1.134 +
1.135 +struct stat {
1.136 + __dev_t st_dev; /* inode's device */
1.137 + ino_t st_ino; /* inode's number */
1.138 + mode_t st_mode; /* inode protection mode */
1.139 + nlink_t st_nlink; /* number of hard links */
1.140 + uid_t st_uid; /* user ID of the file's owner */
1.141 + gid_t st_gid; /* group ID of the file's group */
1.142 + __dev_t st_rdev; /* device type */
1.143 +#if __BSD_VISIBLE
1.144 + struct timespec st_atimespec; /* time of last access */
1.145 + struct timespec st_mtimespec; /* time of last data modification */
1.146 + struct timespec st_ctimespec; /* time of last file status change */
1.147 +#else
1.148 + time_t st_atime; /* time of last access */
1.149 + long __st_atimensec; /* nsec of last access */
1.150 + time_t st_mtime; /* time of last data modification */
1.151 + long __st_mtimensec; /* nsec of last data modification */
1.152 + time_t st_ctime; /* time of last file status change */
1.153 + long __st_ctimensec; /* nsec of last file status change */
1.154 +#endif
1.155 + off_t st_size; /* file size, in bytes */
1.156 + blkcnt_t st_blocks; /* blocks allocated for file */
1.157 + blksize_t st_blksize; /* optimal blocksize for I/O */
1.158 + fflags_t st_flags; /* user defined flags for file */
1.159 + __uint32_t st_gen; /* file generation number */
1.160 + __int32_t st_lspare;
1.161 +#if __BSD_VISIBLE
1.162 + struct timespec st_birthtimespec; /* time of file creation */
1.163 + /*
1.164 + * Explicitly pad st_birthtimespec to 16 bytes so that the size of
1.165 + * struct stat is backwards compatible. We use bitfields instead
1.166 + * of an array of chars so that this doesn't require a C99 compiler
1.167 + * to compile if the size of the padding is 0. We use 2 bitfields
1.168 + * to cover up to 64 bits on 32-bit machines. We assume that
1.169 + * CHAR_BIT is 8...
1.170 + */
1.171 + unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
1.172 + unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
1.173 +#else
1.174 + time_t st_birthtime; /* time of file creation */
1.175 + long st_birthtimensec; /* nsec of file creation */
1.176 + unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
1.177 + unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
1.178 +#endif
1.179 +};
1.180 +
1.181 +#if __BSD_VISIBLE
1.182 +struct nstat {
1.183 + __dev_t st_dev; /* inode's device */
1.184 + ino_t st_ino; /* inode's number */
1.185 + __uint32_t st_mode; /* inode protection mode */
1.186 + __uint32_t st_nlink; /* number of hard links */
1.187 + uid_t st_uid; /* user ID of the file's owner */
1.188 + gid_t st_gid; /* group ID of the file's group */
1.189 + __dev_t st_rdev; /* device type */
1.190 + struct timespec st_atimespec; /* time of last access */
1.191 + struct timespec st_mtimespec; /* time of last data modification */
1.192 + struct timespec st_ctimespec; /* time of last file status change */
1.193 + off_t st_size; /* file size, in bytes */
1.194 + blkcnt_t st_blocks; /* blocks allocated for file */
1.195 + blksize_t st_blksize; /* optimal blocksize for I/O */
1.196 + fflags_t st_flags; /* user defined flags for file */
1.197 + __uint32_t st_gen; /* file generation number */
1.198 + struct timespec st_birthtimespec; /* time of file creation */
1.199 + /*
1.200 + * See above about the following padding.
1.201 + */
1.202 + unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
1.203 + unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
1.204 +};
1.205 +#endif
1.206 +
1.207 +#if __BSD_VISIBLE
1.208 +#define st_atime st_atimespec.tv_sec
1.209 +#define st_mtime st_mtimespec.tv_sec
1.210 +#define st_ctime st_ctimespec.tv_sec
1.211 +#define st_birthtime st_birthtimespec.tv_sec
1.212 +#endif
1.213 +
1.214 +#define S_ISUID 0004000 /* set user id on execution */
1.215 +#define S_ISGID 0002000 /* set group id on execution */
1.216 +#if __BSD_VISIBLE
1.217 +#define S_ISTXT 0001000 /* sticky bit */
1.218 +#endif
1.219 +
1.220 +#define S_IRWXU 0000700 /* RWX mask for owner */
1.221 +#define S_IRUSR 0000400 /* R for owner */
1.222 +#define S_IWUSR 0000200 /* W for owner */
1.223 +#define S_IXUSR 0000100 /* X for owner */
1.224 +
1.225 +#if __BSD_VISIBLE
1.226 +#define S_IREAD S_IRUSR
1.227 +#define S_IWRITE S_IWUSR
1.228 +#define S_IEXEC S_IXUSR
1.229 +#endif
1.230 +
1.231 +#define S_IRWXG 0000070 /* RWX mask for group */
1.232 +#define S_IRGRP 0000040 /* R for group */
1.233 +#define S_IWGRP 0000020 /* W for group */
1.234 +#define S_IXGRP 0000010 /* X for group */
1.235 +
1.236 +#define S_IRWXO 0000007 /* RWX mask for other */
1.237 +#define S_IROTH 0000004 /* R for other */
1.238 +#define S_IWOTH 0000002 /* W for other */
1.239 +#define S_IXOTH 0000001 /* X for other */
1.240 +
1.241 +#if __XSI_VISIBLE
1.242 +#define S_IFMT 0170000 /* type of file mask */
1.243 +#define S_IFIFO 0010000 /* named pipe (fifo) */
1.244 +#define S_IFCHR 0020000 /* character special */
1.245 +#define S_IFDIR 0040000 /* directory */
1.246 +#define S_IFBLK 0060000 /* block special */
1.247 +#define S_IFREG 0100000 /* regular */
1.248 +#define S_IFLNK 0120000 /* symbolic link */
1.249 +#define S_IFSOCK 0140000 /* socket */
1.250 +#define S_ISVTX 0001000 /* save swapped text even after use */
1.251 +#endif
1.252 +#if __BSD_VISIBLE
1.253 +#define S_IFWHT 0160000 /* whiteout */
1.254 +#endif
1.255 +
1.256 +#define S_ISDIR(m) (((m) & 0170000) == 0040000) /* directory */
1.257 +#define S_ISCHR(m) (((m) & 0170000) == 0020000) /* char special */
1.258 +#define S_ISBLK(m) (((m) & 0170000) == 0060000) /* block special */
1.259 +#define S_ISREG(m) (((m) & 0170000) == 0100000) /* regular file */
1.260 +#define S_ISFIFO(m) (((m) & 0170000) == 0010000) /* fifo or socket */
1.261 +#if __POSIX_VISIBLE >= 200112
1.262 +#define S_ISLNK(m) (((m) & 0170000) == 0120000) /* symbolic link */
1.263 +#define S_ISSOCK(m) (((m) & 0170000) == 0140000) /* socket */
1.264 +#endif
1.265 +#if __BSD_VISIBLE
1.266 +#define S_ISWHT(m) (((m) & 0170000) == 0160000) /* whiteout */
1.267 +#endif
1.268 +
1.269 +#if __BSD_VISIBLE
1.270 +#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
1.271 + /* 7777 */
1.272 +#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
1.273 + /* 0666 */
1.274 +#ifndef DEFFILEMODE
1.275 +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
1.276 +#endif//DEFFILEMODE
1.277 +
1.278 +#define S_BLKSIZE 512 /* block size used in the stat struct */
1.279 +
1.280 +/*
1.281 + * Definitions of flags stored in file flags word.
1.282 + *
1.283 + * Super-user and owner changeable flags.
1.284 + */
1.285 +#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
1.286 +#define UF_NODUMP 0x00000001 /* do not dump file */
1.287 +#define UF_IMMUTABLE 0x00000002 /* file may not be changed */
1.288 +#define UF_APPEND 0x00000004 /* writes to file may only append */
1.289 +#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
1.290 +#define UF_NOUNLINK 0x00000010 /* file may not be removed or renamed */
1.291 +/*
1.292 + * Super-user changeable flags.
1.293 + */
1.294 +#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
1.295 +#define SF_ARCHIVED 0x00010000 /* file is archived */
1.296 +#define SF_IMMUTABLE 0x00020000 /* file may not be changed */
1.297 +#define SF_APPEND 0x00040000 /* writes to file may only append */
1.298 +#define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
1.299 +#define SF_SNAPSHOT 0x00200000 /* snapshot inode */
1.300 +
1.301 +#ifdef _KERNEL
1.302 +/*
1.303 + * Shorthand abbreviations of above.
1.304 + */
1.305 +#define OPAQUE (UF_OPAQUE)
1.306 +#define APPEND (UF_APPEND | SF_APPEND)
1.307 +#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
1.308 +#define NOUNLINK (UF_NOUNLINK | SF_NOUNLINK)
1.309 +#endif
1.310 +
1.311 +#endif /* __BSD_VISIBLE */
1.312 +
1.313 +#ifndef _KERNEL
1.314 +__BEGIN_DECLS
1.315 +IMPORT_C
1.316 +int chmod(const char *, mode_t);
1.317 +#if __BSD_VISIBLE
1.318 +IMPORT_C
1.319 +int fchmod(int, mode_t);
1.320 +#endif
1.321 +IMPORT_C int fstat(int, struct stat *);
1.322 +#if __POSIX_VISIBLE >= 200112
1.323 +IMPORT_C int lstat(const char * __restrict, struct stat * __restrict);
1.324 +#endif
1.325 +IMPORT_C int __xstat(int /* vers */, const char *file, struct stat *buf);
1.326 +IMPORT_C int __lxstat (int /* version*/, const char *file, struct stat *buf);
1.327 +IMPORT_C int mkdir(const char *, mode_t);
1.328 +IMPORT_C int mkfifo(const char *, mode_t);
1.329 +IMPORT_C int stat(const char * __restrict, struct stat * __restrict);
1.330 +IMPORT_C mode_t umask(mode_t);
1.331 +__END_DECLS
1.332 +#endif /* !_KERNEL */
1.333 +
1.334 +#endif /* !_SYS_STAT_H_ */