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.
8 * NaCl Service Runtime API.
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_BITS_STAT_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_BITS_STAT_H_
15 * nacl_abi_mode_t is uint32_t, so we have more bits to play with:
17 * 3 b/octal digit, 30 bits: 1234567890
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*/
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 */
37 #define NACL_ABI_S_UNSUP 0000370000 /* unsupported file type */
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
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
51 #define NACL_ABI_S_ISUID 0004000
52 #define NACL_ABI_S_ISGID 0002000
53 #define NACL_ABI_S_ISVTX 0001000
55 #define NACL_ABI_S_IREAD 0400
56 #define NACL_ABI_S_IWRITE 0200
57 #define NACL_ABI_S_IEXEC 0100
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)
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)
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)
74 * only user access bits are supported; the rest are cleared when set
75 * (effectively, umask of 077) and cleared when read.
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)