Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: mojo/services/files/public/c/mojio_sys_stat.h

Issue 1388413005: Move //mojo/services/X/public/... to //mojo/services/X/... (part 1). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Partial <sys/stat.h>-lookalike-ish. Note that this is a C header, so that
6 // crappy (and non-crappy) C programs can use it.
7 //
8 // In general, functions/types/macros are given "mojio_"/"MOJIO_"/etc. prefixes.
9 // There are a handful of exceptions (noted below).
10
11 #ifndef MOJO_SERVICES_FILES_PUBLIC_C_MOJIO_SYS_STAT_H_
12 #define MOJO_SERVICES_FILES_PUBLIC_C_MOJIO_SYS_STAT_H_
13
14 // Includes --------------------------------------------------------------------
15
16 // <sys/stat.h> is required to define a large number of types defined in
17 // <sys/types.h>, so we just include our equivalent of the latter.
18 #include "files/public/c/mojio_sys_types.h"
19
20 // We need our |struct timespec| equivalent.
21 #include "files/public/c/mojio_time.h"
22
23 // Macros ----------------------------------------------------------------------
24
25 #define MOJIO_S_IRWXU (MOJIO_S_IRUSR | MOJIO_S_IWUSR | MOJIO_S_IXUSR)
26 #define MOJIO_S_IRUSR 00400
27 #define MOJIO_S_IWUSR 00200
28 #define MOJIO_S_IXUSR 00100
29
30 #define MOJIO_S_IRWXG (MOJIO_S_IRGRP | MOJIO_S_IWGRP | MOJIO_S_IXGRP)
31 #define MOJIO_S_IRGRP 00040
32 #define MOJIO_S_IWGRP 00020
33 #define MOJIO_S_IXGRP 00010
34
35 #define MOJIO_S_IRWXO (MOJIO_S_IROTH | MOJIO_S_IWOTH | MOJIO_S_IXOTH)
36 #define MOJIO_S_IROTH 00004
37 #define MOJIO_S_IWOTH 00002
38 #define MOJIO_S_IXOTH 00001
39
40 #define MOJIO_S_ISUID 04000
41 #define MOJIO_S_ISGID 02000
42 #define MOJIO_S_ISVTX 01000
43
44 // Mask for the values below.
45 #define MOJIO_S_IFMT 0170000
46 // These values are mysterious, but are the standard values on Linux.
47 #define MOJIO_S_IFBLK 0060000
48 #define MOJIO_S_IFCHR 0020000
49 #define MOJIO_S_IFDIR 0040000
50 #define MOJIO_S_IFIFO 0010000
51 #define MOJIO_S_IFLNK 0120000
52 #define MOJIO_S_IFREG 0100000
53 #define MOJIO_S_IFSOCK 0140000
54
55 #define MOJIO_S_ISBLK(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFBLK)
56 #define MOJIO_S_ISCHR(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFCHR)
57 #define MOJIO_S_ISDIR(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFDIR)
58 #define MOJIO_S_ISFIFO(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFIFO)
59 #define MOJIO_S_ISLNK(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFLNK)
60 #define MOJIO_S_ISREG(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFREG)
61 #define MOJIO_S_ISSOCK(mode) (((mode)&MOJIO_S_IFMT) == MOJIO_S_IFSOCK)
62
63 // POSIX.1-2008 says we should define |st_atime| to |st_atim.tv_sec| (and
64 // similarly for |st_mtime| and |st_ctime|). This is to provide (source)
65 // backwards compatibility with older versions of POSIX.
66 //
67 // We could reasonably provide these macros on systems that are compliant with
68 // POSIX.1-2008 (or later): even though they might collide with macro
69 // definitions in the "real" <sys/stat.h>, it's okay since the macro definitions
70 // will be identical. However, providing these macros on systems that aren't
71 // POSIX.1-2008-compliant (like Android) leads to an intractable conflict. Thus
72 // we provide prefixed macros instead.
73 #define mojio_st_atime st_atim.tv_sec
74 #define mojio_st_mtime st_mtim.tv_sec
75 #define mojio_st_ctime st_ctim.tv_sec
76
77 // Types -----------------------------------------------------------------------
78
79 struct mojio_stat {
80 mojio_dev_t st_dev;
81 mojio_ino_t st_ino;
82 mojio_mode_t st_mode;
83 mojio_nlink_t st_nlink;
84 mojio_uid_t st_uid;
85 mojio_gid_t st_gid;
86 mojio_dev_t st_rdev;
87 mojio_off_t st_size;
88 struct mojio_timespec st_atim;
89 struct mojio_timespec st_mtim;
90 struct mojio_timespec st_ctim;
91 mojio_blksize_t st_blksize;
92 mojio_blkcnt_t st_blocks;
93 };
94
95 // Functions -------------------------------------------------------------------
96
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100
101 // TODO(vtl): Below is a complete list of functions in <sys/stat.h> (according
102 // to POSIX.1-2008, 2013 edition). Figure out which ones we want/need to
103 // support.
104 //
105 // int chmod(const char*, mode_t);
106 // int fchmod(int, mode_t);
107 // int fchmodat(int, const char*, mode_t, int);
108 // [DONE] int fstat(int, struct stat*);
109 // int fstatat(int, const char* restrict, struct stat* restrict, int);
110 // int futimens(int, const struct timespec [2]);
111 // int lstat(const char* restrict, struct stat* restrict);
112 // int mkdir(const char*, mode_t);
113 // int mkdirat(int, const char*, mode_t);
114 // int mkfifo(const char*, mode_t);
115 // int mkfifoat(int, const char*, mode_t);
116 // [XSI] int mknod(const char*, mode_t, dev_t);
117 // [XSI] int mknodat(int, const char*, mode_t, dev_t);
118 // int stat(const char* restrict, struct stat* restrict);
119 // mode_t umask(mode_t);
120 // int utimensat(int, const char*, const struct timespec [2], int);
121
122 int mojio_fstat(int fd, struct mojio_stat* buf);
123
124 #ifdef __cplusplus
125 } // extern "C"
126 #endif
127
128 #endif // MOJO_SERVICES_FILES_PUBLIC_C_MOJIO_SYS_STAT_H_
OLDNEW
« no previous file with comments | « mojo/services/files/public/c/mojio_stdio.h ('k') | mojo/services/files/public/c/mojio_sys_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698