Store Temporary Logs In Own Directory
This commit is contained in:
parent
6c89e64f8b
commit
0e32fd36c8
@ -7,6 +7,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <libreborn/libreborn.h>
|
#include <libreborn/libreborn.h>
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ static void exit_handler(__attribute__((unused)) int signal) {
|
|||||||
// Setup
|
// Setup
|
||||||
#define PIPE_READ 0
|
#define PIPE_READ 0
|
||||||
#define PIPE_WRITE 1
|
#define PIPE_WRITE 1
|
||||||
|
#define MCPI_LOGS_DIR "/tmp/.minecraft-pi-logs"
|
||||||
void setup_crash_report() {
|
void setup_crash_report() {
|
||||||
// Store Output
|
// Store Output
|
||||||
int output_pipe[2];
|
int output_pipe[2];
|
||||||
@ -100,8 +102,21 @@ void setup_crash_report() {
|
|||||||
#define BUFFER_SIZE 1024
|
#define BUFFER_SIZE 1024
|
||||||
char buf[BUFFER_SIZE];
|
char buf[BUFFER_SIZE];
|
||||||
|
|
||||||
|
// Ensure Temporary Directory
|
||||||
|
{
|
||||||
|
// Check If It Exists
|
||||||
|
struct stat tmp_stat;
|
||||||
|
int exists = stat(MCPI_LOGS_DIR, &tmp_stat) != 0 ? 0 : S_ISDIR(tmp_stat.st_mode);
|
||||||
|
if (!exists) {
|
||||||
|
// Doesn't Exist
|
||||||
|
if (mkdir(MCPI_LOGS_DIR, S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
|
||||||
|
ERR("Unable To Create Temporary Folder: %s", strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create Temporary File
|
// Create Temporary File
|
||||||
char log_filename[] = "/tmp/.minecraft-pi-log-XXXXXX";
|
char log_filename[] = MCPI_LOGS_DIR "/XXXXXX";
|
||||||
int log_file_fd = mkstemp(log_filename);
|
int log_file_fd = mkstemp(log_filename);
|
||||||
if (log_file_fd == -1) {
|
if (log_file_fd == -1) {
|
||||||
ERR("Unable To Create Log File: %s", strerror(errno));
|
ERR("Unable To Create Log File: %s", strerror(errno));
|
||||||
|
Loading…
Reference in New Issue
Block a user