/src/hothd/sys_interface.hpp
Line | Count | Source |
1 | | // Copyright 2024 Google LLC |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #pragma once |
16 | | |
17 | | #include <sys/ioctl.h> |
18 | | #include <unistd.h> |
19 | | |
20 | | #include <cstdint> |
21 | | |
22 | | namespace google |
23 | | { |
24 | | namespace hoth |
25 | | { |
26 | | namespace internal |
27 | | { |
28 | | |
29 | | /** @class Sys |
30 | | * @brief Overridable direct syscall interface |
31 | | * |
32 | | * TODO: factor this out into a syscall class shared by all upstream projects |
33 | | */ |
34 | | class Sys |
35 | | { |
36 | | public: |
37 | 0 | virtual ~Sys() = default; |
38 | | |
39 | | virtual int open(const char* pathname, int flags) const = 0; |
40 | | virtual int close(int fd) const = 0; |
41 | | virtual off_t lseek(int fd, off_t offset, int whence) const = 0; |
42 | | virtual ssize_t read(int fd, void* buf, size_t count) const = 0; |
43 | | virtual ssize_t write(int fd, const void* buf, size_t count) const = 0; |
44 | | virtual int ioctl(int fd, uint64_t request, void* mtd) const = 0; |
45 | | }; |
46 | | |
47 | | } // namespace internal |
48 | | |
49 | | } // namespace hoth |
50 | | |
51 | | } // namespace google |