2019-03-19 00:21:48 +08:00
|
|
|
#ifndef SANDBOXED_API_SANDBOX2_SYSCALL_DEFS_H_
|
|
|
|
#define SANDBOXED_API_SANDBOX2_SYSCALL_DEFS_H_
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2020-01-07 21:26:10 +08:00
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2020-01-07 21:26:10 +08:00
|
|
|
#include "absl/strings/string_view.h"
|
2019-03-19 00:21:48 +08:00
|
|
|
#include "absl/types/span.h"
|
2020-01-07 21:26:10 +08:00
|
|
|
#include "sandboxed_api/sandbox2/syscall.h"
|
2019-03-19 00:21:48 +08:00
|
|
|
|
|
|
|
namespace sandbox2 {
|
|
|
|
namespace syscalls {
|
2020-01-07 21:26:10 +08:00
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
constexpr int kMaxArgs = 6;
|
2020-01-07 21:26:10 +08:00
|
|
|
|
|
|
|
} // namespace syscalls
|
2019-03-19 00:21:48 +08:00
|
|
|
|
|
|
|
class SyscallTable {
|
|
|
|
public:
|
2020-01-07 21:26:10 +08:00
|
|
|
struct Entry;
|
2019-03-19 00:21:48 +08:00
|
|
|
|
2020-01-07 21:26:10 +08:00
|
|
|
// Returns the syscall table for the architecture.
|
|
|
|
static SyscallTable get(Syscall::CpuArch arch);
|
2019-03-19 00:21:48 +08:00
|
|
|
|
2020-01-07 21:26:10 +08:00
|
|
|
int size() { return data_.size(); }
|
2019-03-19 00:21:48 +08:00
|
|
|
|
2020-01-07 21:26:10 +08:00
|
|
|
absl::string_view GetName(int syscall) const;
|
2019-03-19 00:21:48 +08:00
|
|
|
|
2020-01-07 21:26:10 +08:00
|
|
|
std::vector<std::string> GetArgumentsDescription(
|
|
|
|
int syscall, const uint64_t values[syscalls::kMaxArgs], pid_t pid) const;
|
2019-03-19 00:21:48 +08:00
|
|
|
|
2020-01-07 21:26:10 +08:00
|
|
|
private:
|
2019-03-19 00:21:48 +08:00
|
|
|
constexpr SyscallTable() = default;
|
2020-01-07 21:26:10 +08:00
|
|
|
explicit constexpr SyscallTable(absl::Span<const Entry> data) : data_(data) {}
|
2019-03-19 00:21:48 +08:00
|
|
|
|
|
|
|
const absl::Span<const Entry> data_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sandbox2
|
|
|
|
|
|
|
|
#endif // SANDBOXED_API_SANDBOX2_SYSCALL_DEFS_H_
|