Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / service_runtime / include / bits / stat.h
1 /*
2  * Copyright (c) 2008 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 /*
8  * NaCl Service Runtime API.
9  */
10
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_BITS_STAT_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_BITS_STAT_H_
13
14 /*
15  * nacl_abi_mode_t is uint32_t, so we have more bits to play with:
16  *
17  * 3 b/octal digit, 30 bits:   1234567890
18  */
19 #define NACL_ABI_S_IFMT        0000370000  /* for now */
20 #define NACL_ABI_S_IFSHM_SYSV  0000300000  /* must map all-or-nothing */
21 #define NACL_ABI_S_IFSEMA      0000270000
22 #define NACL_ABI_S_IFCOND      0000260000
23 #define NACL_ABI_S_IFMUTEX     0000250000
24 #define NACL_ABI_S_IFSHM       0000240000
25 #define NACL_ABI_S_IFBOUNDSOCK 0000230000  /* bound socket*/
26 #define NACL_ABI_S_IFSOCKADDR  0000220000  /* socket address */
27 #define NACL_ABI_S_IFDSOCK     0000210000  /* data-only, transferable socket*/
28
29 #define NACL_ABI_S_IFSOCK      0000140000  /* data-and-descriptor socket*/
30 #define NACL_ABI_S_IFLNK       0000120000  /* symbolic link */
31 #define NACL_ABI_S_IFREG       0000100000  /* regular file */
32 #define NACL_ABI_S_IFBLK       0000060000  /* block device */
33 #define NACL_ABI_S_IFDIR       0000040000  /* directory */
34 #define NACL_ABI_S_IFCHR       0000020000  /* character device */
35 #define NACL_ABI_S_IFIFO       0000010000  /* fifo */
36
37 #define NACL_ABI_S_UNSUP       0000370000  /* unsupported file type */
38 /*
39  * NaCl does not support file system objects other than regular files
40  * and directories, and objects of other types will appear in the
41  * directory namespace but will be mapped to NACL_ABI_S_UNSUP when
42  * these objects are stat(2)ed.  Opening these kinds of objects will
43  * fail.
44  *
45  * The ABI includes these bits so (library) code that use these
46  * preprocessor symbols will compile.  The semantics of having a new
47  * "unsupported" file type should enable code to run in a reasonably
48  * sane way, but YMMV.
49  *
50  * NB: sysv shm is only available when host OS is linux, and cannot be
51  * created by untrusted code.  The only use is in Pepper2d, and other
52  * trusted code is responsible for their creation -- essentially,
53  * these objects wrap sysv shm used by the MIT-SHM extension to X11,
54  * where the X server creates a SysV shm object to hold pixmap data.
55  */
56
57 #define NACL_ABI_S_ISUID      0004000
58 #define NACL_ABI_S_ISGID      0002000
59 #define NACL_ABI_S_ISVTX      0001000
60
61 #define NACL_ABI_S_IREAD      0400
62 #define NACL_ABI_S_IWRITE     0200
63 #define NACL_ABI_S_IEXEC      0100
64
65 #define NACL_ABI_S_IRWXU  (NACL_ABI_S_IREAD|NACL_ABI_S_IWRITE|NACL_ABI_S_IEXEC)
66 #define NACL_ABI_S_IRUSR  (NACL_ABI_S_IREAD)
67 #define NACL_ABI_S_IWUSR  (NACL_ABI_S_IWRITE)
68 #define NACL_ABI_S_IXUSR  (NACL_ABI_S_IEXEC)
69
70 #define NACL_ABI_S_IRWXG  (NACL_ABI_S_IRWXU >> 3)
71 #define NACL_ABI_S_IRGRP  (NACL_ABI_S_IREAD >> 3)
72 #define NACL_ABI_S_IWGRP  (NACL_ABI_S_IWRITE >> 3)
73 #define NACL_ABI_S_IXGRP  (NACL_ABI_S_IEXEC >> 3)
74
75 #define NACL_ABI_S_IRWXO  (NACL_ABI_S_IRWXU >> 6)
76 #define NACL_ABI_S_IROTH  (NACL_ABI_S_IREAD >> 6)
77 #define NACL_ABI_S_IWOTH  (NACL_ABI_S_IWRITE >> 6)
78 #define NACL_ABI_S_IXOTH  (NACL_ABI_S_IEXEC >> 6)
79 /*
80  * only user access bits are supported; the rest are cleared when set
81  * (effectively, umask of 077) and cleared when read.
82  */
83
84 #define NACL_ABI_S_ISSOCK(m)  (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFSOCK)
85 #define NACL_ABI_S_ISLNK(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFLNK)
86 #define NACL_ABI_S_ISREG(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFREG)
87 #define NACL_ABI_S_ISBLK(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFBLK)
88 #define NACL_ABI_S_ISDIR(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFDIR)
89 #define NACL_ABI_S_ISSOCKADDR(m) \
90                               (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFSOCKADDR)
91 #define NACL_ABI_S_ISCHR(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFCHR)
92 #define NACL_ABI_S_ISFIFO(m)  (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFIFO)
93 #define NACL_ABI_S_ISSHM(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFSHM)
94 #define NACL_ABI_S_ISSHM_SYSV(m) \
95   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFSHM_SYSV)
96
97 #endif