1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef BERBERIS_KERNEL_API_OPEN_EMULATION_H_
18 #define BERBERIS_KERNEL_API_OPEN_EMULATION_H_
19 
20 // Documentation says that to get access to the constants used below one
21 // must include these three files.  In reality it looks as if all constants
22 // are defined by <fcntl.h>.  Including sys/stat.h conflicts with the asm/stat.h
23 // needed in sys_stat_emulation.h when compliling against musl, so leave it out.
24 #include <fcntl.h>
25 // #include <sys/stat.h>
26 #include <sys/types.h>
27 
28 namespace berberis {
29 
30 int ToHostOpenFlags(int guest_flags);
31 int ToGuestOpenFlags(int host_flags);
32 
33 int OpenatForGuest(int dirfd, const char* pathname, int flags, mode_t mode);
34 int OpenForGuest(const char* pathname, int flags, mode_t mode);
35 
36 bool IsFileDescriptorEmulatedProcSelfMaps(int fd);
37 void CloseEmulatedProcSelfMapsFileDescriptor(int fd);
38 
39 extern const char* kGuestCpuinfoPath;
40 
41 }  // namespace berberis
42 
43 #endif  // BERBERIS_KERNEL_API_OPEN_EMULATION_H_
44