mirror of
https://github.com/akuker/RASCSI.git
synced 2025-07-15 15:24:06 +00:00
Initial merge of (incomplete) Banana Pi updates (#993)
This commit is contained in:
59
cpp/test/linux_os_stubs.cpp
Normal file
59
cpp/test/linux_os_stubs.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// SCSI Target Emulator RaSCSI Reloaded
|
||||
// for Raspberry Pi
|
||||
//
|
||||
// Copyright (C) 2022 akuker
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "test/linux_os_stubs.h"
|
||||
#include "test/test_shared.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace filesystem;
|
||||
|
||||
extern "C" {
|
||||
|
||||
#ifdef __USE_LARGEFILE64
|
||||
FILE *__wrap_fopen64(const char *__restrict __filename, const char *__restrict __modes)
|
||||
#else
|
||||
FILE *__wrap_fopen(const char *__restrict __filename, const char *__restrict __modes)
|
||||
#endif
|
||||
{
|
||||
path new_filename;
|
||||
bool create_directory = false;
|
||||
|
||||
// If we're trying to open up the device tree soc ranges,
|
||||
// re-direct it to a temporary local file.
|
||||
if (string(__filename) == "/proc/device-tree/soc/ranges") {
|
||||
create_directory = true;
|
||||
new_filename = test_data_temp_path;
|
||||
new_filename += path(__filename);
|
||||
} else {
|
||||
new_filename = path(__filename);
|
||||
}
|
||||
|
||||
if (create_directory) {
|
||||
create_directories(new_filename.parent_path());
|
||||
}
|
||||
#ifdef __USE_LARGEFILE64
|
||||
return __real_fopen64(new_filename.c_str(), __modes);
|
||||
#else
|
||||
return __real_fopen(new_filename.c_str(), __modes);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // end extern "C"
|
Reference in New Issue
Block a user