Upstream version 11.40.277.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 /* Removed NACL_ABI_S_IFSHM_SYSV, which was 0000300000. */
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
51 #define NACL_ABI_S_ISUID      0004000
52 #define NACL_ABI_S_ISGID      0002000
53 #define NACL_ABI_S_ISVTX      0001000
54
55 #define NACL_ABI_S_IREAD      0400
56 #define NACL_ABI_S_IWRITE     0200
57 #define NACL_ABI_S_IEXEC      0100
58
59 #define NACL_ABI_S_IRWXU  (NACL_ABI_S_IREAD|NACL_ABI_S_IWRITE|NACL_ABI_S_IEXEC)
60 #define NACL_ABI_S_IRUSR  (NACL_ABI_S_IREAD)
61 #define NACL_ABI_S_IWUSR  (NACL_ABI_S_IWRITE)
62 #define NACL_ABI_S_IXUSR  (NACL_ABI_S_IEXEC)
63
64 #define NACL_ABI_S_IRWXG  (NACL_ABI_S_IRWXU >> 3)
65 #define NACL_ABI_S_IRGRP  (NACL_ABI_S_IREAD >> 3)
66 #define NACL_ABI_S_IWGRP  (NACL_ABI_S_IWRITE >> 3)
67 #define NACL_ABI_S_IXGRP  (NACL_ABI_S_IEXEC >> 3)
68
69 #define NACL_ABI_S_IRWXO  (NACL_ABI_S_IRWXU >> 6)
70 #define NACL_ABI_S_IROTH  (NACL_ABI_S_IREAD >> 6)
71 #define NACL_ABI_S_IWOTH  (NACL_ABI_S_IWRITE >> 6)
72 #define NACL_ABI_S_IXOTH  (NACL_ABI_S_IEXEC >> 6)
73 /*
74  * only user access bits are supported; the rest are cleared when set
75  * (effectively, umask of 077) and cleared when read.
76  */
77
78 #define NACL_ABI_S_ISSOCK(m)  (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFSOCK)
79 #define NACL_ABI_S_ISLNK(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFLNK)
80 #define NACL_ABI_S_ISREG(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFREG)
81 #define NACL_ABI_S_ISBLK(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFBLK)
82 #define NACL_ABI_S_ISDIR(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFDIR)
83 #define NACL_ABI_S_ISSOCKADDR(m) \
84                               (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFSOCKADDR)
85 #define NACL_ABI_S_ISCHR(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFCHR)
86 #define NACL_ABI_S_ISFIFO(m)  (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFIFO)
87 #define NACL_ABI_S_ISSHM(m)   (((m) & NACL_ABI_S_IFMT) == NACL_ABI_S_IFSHM)
88
89 #endif