mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-22 16:33:17 +00:00
41bdcd4aed
* Update logging * Remove duplicate code * Update unit tests * Clean up includes * Merge ProtobufSerializer into protobuf_util namespace * Precompile regex * Add const * Add Split() convenience method, update log level/ID parsing * Move log.h to legacy folder * Elimininate gotos * Fixes for gcc 13 * Update compiler flags * Update default folder handling * Use references instead of pointers * Move code for better encapsulation * Move code * Remove unused method argument * Move device logger * Remove redundant to_string * Rename for consistency * Update handling of protobuf pointers * Simplify protobuf usage * Memory handling update * Add hasher
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
|
|
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator PiSCSI
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2022 akuker
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#include "test/linux_os_stubs.h"
|
|
#include "test/test_shared.h"
|
|
|
|
#include <filesystem>
|
|
#include <map>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <string>
|
|
#ifdef __linux__
|
|
#include <sys/epoll.h>
|
|
#endif
|
|
#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;
|
|
auto in_filename = path(__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") ||
|
|
(string(__filename).find(".properties") != string::npos)) {
|
|
create_directory = true;
|
|
new_filename = test_data_temp_path;
|
|
if (!in_filename.has_parent_path()) {
|
|
new_filename += "/";
|
|
}
|
|
new_filename += in_filename;
|
|
} else {
|
|
new_filename = in_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"
|