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