blob: 5016a66e4a2e705dcc142cd6c5b525c2119f1753 [file] [log] [blame]
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "sys_interface.hpp"
#include <cstdint>
#include <mtd/mtd-user.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <system_error>
namespace google
{
namespace hoth
{
namespace internal
{
/** @class SysImpl
* @brief syscall concrete implementation
* @details Passes through all calls to the normal linux syscalls
*/
class SysImpl : public Sys
{
public:
int open(const char* pathname, int flags) const override;
int close(int fd) const override;
off_t lseek(int fd, off_t offset, int whence) const override;
ssize_t read(int fd, void* buf, size_t count) const override;
ssize_t write(int fd, const void* buf, size_t count) const override;
int ioctl(int fd, uint64_t request, void* mtd) const override;
};
inline std::system_error errnoException(const std::string& message)
{
return std::system_error(errno, std::generic_category(), message);
}
/** @brief Default instantiation of sys */
extern SysImpl sys_impl;
} // namespace internal
} // namespace hoth
} // namespace google