1 /*
2  * Copyright (C) 2023 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 #include <sys/stat.h>
18 
19 #include <cstddef>
20 #include <tuple>
21 
22 #include "berberis/guest_state/guest_addr.h"
23 #include "berberis/kernel_api/fcntl_emulation.h"
24 #include "berberis/kernel_api/sys_ptrace_emulation.h"
25 
26 #include "riscv64/guest_types.h"
27 
28 namespace berberis {
29 
GuestFcntlArch(int,int,long)30 std::tuple<bool, int> GuestFcntlArch(int, int, long) {
31   return {false, -1};
32 }
33 
PtraceForGuestArch(int,pid_t,void *,void *)34 std::tuple<bool, int> PtraceForGuestArch(int, pid_t, void*, void*) {
35   return {false, -1};
36 }
37 
ConvertHostStatToGuestArch(const struct stat & host_stat,GuestAddr guest_addr)38 void ConvertHostStatToGuestArch(const struct stat& host_stat, GuestAddr guest_addr) {
39   auto* guest_stat = ToHostAddr<Guest_stat>(guest_addr);
40   guest_stat->st_dev = host_stat.st_dev;
41   guest_stat->st_ino = host_stat.st_ino;
42   guest_stat->st_mode = host_stat.st_mode;
43   guest_stat->st_nlink = host_stat.st_nlink;
44   guest_stat->st_uid = host_stat.st_uid;
45   guest_stat->st_gid = host_stat.st_gid;
46   guest_stat->st_rdev = host_stat.st_rdev;
47   guest_stat->st_size = host_stat.st_size;
48   guest_stat->st_blksize = host_stat.st_blksize;
49   guest_stat->st_blocks = host_stat.st_blocks;
50   guest_stat->st_atim = host_stat.st_atim;
51   guest_stat->st_mtim = host_stat.st_mtim;
52   guest_stat->st_ctim = host_stat.st_ctim;
53 }
54 
55 }  // namespace berberis
56