Skip to content

Allow track files to be stored in persistant storage #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions common/src/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pub static ANGORA_LOG_FILE: &str = "angora.log";
pub static COND_QUEUE_FILE: &str = "cond_queue.csv";
pub static CHART_STAT_FILE: &str = "chart_stat.json";

// tmpfs.rs
pub static PERSIST_TRACK_FILES: &str = "ANGORA_DISABLE_TMPFS";

pub const SLOW_SPEED: u32 = 888888;
pub const UNREACHABLE: u64 = std::u64::MAX;

Expand Down
10 changes: 9 additions & 1 deletion fuzzer/src/tmpfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
// inputs directory and .cur_input, .socket file

use libc;
use std::{fs, os::unix::fs::symlink, path::Path};
use std::{fs, os::unix::fs::symlink, path::Path, env};
use angora_common::defs;

static LINUX_TMPFS_DIR: &str = "/dev/shm";

pub fn create_tmpfs_dir(target: &Path) {
if env::var(defs::PERSIST_TRACK_FILES).is_ok() {
fs::create_dir(&target).unwrap();
return;
}
let shm_dir = Path::new(LINUX_TMPFS_DIR);
if shm_dir.is_dir() {
// support tmpfs
Expand All @@ -31,6 +36,9 @@ pub fn create_tmpfs_dir(target: &Path) {
}

pub fn clear_tmpfs_dir(target: &Path) {
if env::var(defs::PERSIST_TRACK_FILES).is_ok() {
return;
}
if target.exists() {
fs::remove_file(target).unwrap();
}
Expand Down