Skip to content
This repository has been archived by the owner on Dec 30, 2021. It is now read-only.

Commit

Permalink
Implement a better naming convention for sub-crates
Browse files Browse the repository at this point in the history
  • Loading branch information
loganwendholt committed Aug 27, 2019
1 parent 24d39f9 commit 76dddf6
Show file tree
Hide file tree
Showing 74 changed files with 2,334 additions and 223 deletions.
156 changes: 76 additions & 80 deletions Cargo.lock

Large diffs are not rendered by default.

38 changes: 2 additions & 36 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
[package]
name = "reverie"
version = "0.1.0"
authors = ["Baojun Wang <wangbj@gmail.com>"]
edition = "2018"

[workspace]
members= [".", "syscalls", "tools_helper", "common", "preloader", "examples/none", "examples/echo", "examples/counter", "examples/det" ]
default-members = [".", "syscalls", "common", "preloader" ]

[lib]
name = "reverie"
path = "src/lib.rs"

[[bin]]
name = "reverie"
path = "src/main.rs"

[dependencies]
libc = { version = "0.2", default-features = false }
syscalls = { path = "syscalls" }
common = { path = "common" }
nix = "0.13"
goblin = "0.0"
procfs = "0.5"
clap = "2.32"
lazy_static = "1.3"
colored = "1.7"
chrono = "0.4"
log = "0.4"
fern = "0.5"
serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0"

[build-dependencies]
cc = "1.0"
sysnum = { path = "sysnum" }
members= ["reverie", "reverie-syscalls", "reverie-tools-helper", "reverie-common", "reverie-preloader", "examples/none", "examples/echo", "examples/counter", "examples/det" ]
default-members = ["reverie", "reverie-syscalls", "reverie-common", "reverie-preloader" ]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ all:
$(MAKE) -C tests all
@cargo build $(WAY) --all
@cargo build --manifest-path examples/echo/Cargo.toml --target-dir=target
@cp -v target/$(TARGETDIR)/libpreloader.so lib/
@cp -v target/$(TARGETDIR)/libreverie_preloader.so lib/
@cp -v target/$(TARGETDIR)/libecho.so lib/
@cp -v target/$(TARGETDIR)/libnone.so lib/
@cp -v target/$(TARGETDIR)/libcounter.so lib/
Expand Down
3 changes: 1 addition & 2 deletions examples/counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ crate-type = ["cdylib"]
path = "src/lib.rs"

[dependencies]
syscalls = { path = "../../syscalls" }
tools_helper = { path = "../../tools_helper" }
reverie-tools-helper = { path = "../../reverie-tools-helper" }
log = { version = "0.4", default-features = false }

[build-dependencies]
Expand Down
3 changes: 1 addition & 2 deletions examples/counter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#[allow(unused_imports)]
use std::ffi::CStr;

use tools_helper::*;
use syscalls::*;
use reverie_tools_helper::{ syscalls::*, counter::*, common::local_state::ProcessState, logger };

#[cfg_attr(target_os = "linux", link_section = ".ctors")]
#[used]
Expand Down
3 changes: 1 addition & 2 deletions examples/det/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ crate-type = ["cdylib"]
path = "src/lib.rs"

[dependencies]
syscalls = { path = "../../syscalls" }
tools_helper = { path = "../../tools_helper" }
reverie-tools-helper = { path = "../../reverie-tools-helper" }
log = { version = "0.4", default-features = false }
libc = { version = "0.2", default-features = false }

Expand Down
7 changes: 3 additions & 4 deletions examples/det/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#![allow(unused_imports)]
#![allow(unused_attributes)]

use tools_helper::*;
use syscalls::*;
use reverie_tools_helper::{syscalls::*, counter::*, common::local_state::ProcessState, logger};
use log::*;

#[allow(unused_imports)]
Expand Down Expand Up @@ -38,10 +37,10 @@ pub extern "C" fn captured_syscall(
a5: i64,
) -> i64 {
note_syscall(p, no, NoteInfo::SyscallEntry);
let sc = syscalls::SyscallNo::from(no);
let sc = SyscallNo::from(no);
#[allow(unused_assignments)]
let mut res = -38; // ENOSYS

match sc {
SYS_gettimeofday => {
let tick = LOGICAL_TIME.fetch_add(1, Ordering::SeqCst) as i64;
Expand Down
3 changes: 1 addition & 2 deletions examples/echo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ crate-type = ["cdylib"]
path = "src/lib.rs"

[dependencies]
syscalls = { path = "../../syscalls" }
tools_helper = { path = "../../tools_helper" }
reverie-tools-helper = { path = "../../reverie-tools-helper" }
log = { version = "0.4", default-features = false }
serde = { version = "1.0", default-features = false, features = [ "derive" ] }
libc = { version = "0.2", default-features = false, features = [] }
Expand Down
5 changes: 1 addition & 4 deletions examples/echo/src/dpc.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
//! deferred precedure calls
//!
use syscalls::syscall;
use reverie_tools_helper::{ common::consts, syscalls::syscall, logger} ;
use log::debug;

use tools_helper::common::consts;
use tools_helper::logger;

const DPC_PREFIX: &'static str = "/tmp/dpc-task.";

const PF_UNIX: i32 = 1;
Expand Down
12 changes: 7 additions & 5 deletions examples/echo/src/entry.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//! echo entrypoint who defines `captured_syscall`
//!
use syscalls::*;
use tools_helper::*;
use crate::show::*;
use tools_helper::counter::{note_syscall, NoteInfo};
use tools_helper::common::local_state::{ProcessState, ThreadState};
use reverie_tools_helper::syscalls::*;
use reverie_tools_helper::counter::{note_syscall, NoteInfo};
use reverie_tools_helper::common::local_state::{ProcessState, ThreadState};

use reverie_tools_helper::logger::*;
use reverie_tools_helper::*;

#[macro_export(smsg)]
macro_rules! smsg {
Expand All @@ -32,7 +34,7 @@ pub extern "C" fn captured_syscall(
a4: i64,
a5: i64,
) -> i64 {
let sc = syscalls::SyscallNo::from(no);
let sc = SyscallNo::from(no);
note_syscall(p, no, NoteInfo::SyscallEntry);

let tid = syscall!(SYS_gettid).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/echo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(format_args_nl, slice_internals)]
#![allow(unused_attributes)]

use tools_helper::*;
use reverie_tools_helper::{counter, common, logger};

#[macro_use]
pub mod macros;
Expand Down
4 changes: 2 additions & 2 deletions examples/echo/src/show/args.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! pretty print syscalls
use syscalls::*;
use reverie_tools_helper::syscalls::*;
use core::fmt;
use core::fmt::Display;
use core::ptr::NonNull;
Expand Down Expand Up @@ -891,7 +891,7 @@ impl Display for kernel_sigaction {
self.sa_mask,
{
let flags = self.sa_flags as i32;
let mut v: Vec<_> =
let mut v: Vec<_> =
[ libc_bit_field!(flags, SA_NOCLDSTOP),
libc_bit_field!(flags, SA_NOCLDWAIT),
libc_bit_field!(flags, SA_SIGINFO),
Expand Down
2 changes: 1 addition & 1 deletion examples/echo/src/show/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

use core::ptr::NonNull;
use core::ffi::c_void as void;
use syscalls::SyscallNo;
use reverie_tools_helper::syscalls::SyscallNo;

/// syscall return vaules for formatting purpose
#[derive(Clone, Copy)]
Expand Down
3 changes: 1 addition & 2 deletions examples/none/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ crate-type = ["cdylib"]
path = "src/lib.rs"

[dependencies]
syscalls = { path = "../../syscalls" }
tools_helper = { path = "../../tools_helper" }
reverie-tools-helper = { path = "../../reverie-tools-helper" }
serde = { version = "1.0", default-features = false, features = [ "derive" ] }

[build-dependencies]
Expand Down
3 changes: 1 addition & 2 deletions examples/none/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#![allow(unused_imports)]
#![allow(unused_attributes)]

use syscalls::*;
use tools_helper::*;
use reverie_tools_helper::{ syscalls::*, common::local_state::ProcessState };

#[no_mangle]
pub extern "C" fn captured_syscall(
Expand Down
15 changes: 0 additions & 15 deletions include/systrace.h

This file was deleted.

6 changes: 5 additions & 1 deletion common/Cargo.toml → reverie-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[package]
name = "common"
name = "reverie-common"
version = "0.1.0"
authors = ["Logan Wendholt <lwendholt@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
name = "reverie_common"
path = "src/lib.rs"

[dependencies]
nix = "0.13"
lazy_static = "1.3"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions preloader/Cargo.toml → reverie-preloader/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[package]
name = "preloader"
name = "reverie-preloader"
version = "0.1.0"
authors = ["Baojun Wang <wangbj@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
name = "preloader"
name = "reverie_preloader"
crate-type = ["cdylib"]
path = "src/lib.rs"

[dependencies]
syscalls = { path = "../syscalls" }
common = { path = "../common" }
reverie-syscalls = { path = "../reverie-syscalls" }
reverie-common = { path = "../reverie-common" }
procfs = "0.5"
nix = "0.14"
libc = "0.2"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions preloader/src/lib.rs → reverie-preloader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::io::Result;
pub mod relink;
pub mod seccomp_bpf;

use syscalls::*;
use common::consts;
use reverie_syscalls::*;
use reverie_common::consts;

#[link_section = ".init_array"]
#[used]
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions syscalls/Cargo.toml → reverie-syscalls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "syscalls"
name = "reverie-syscalls"
version = "0.1.0"
authors = ["Baojun Wang <wangbj@gmail.com>"]
edition = "2018"

[lib]
name = "syscalls"
name = "reverie_syscalls"
path = "src/lib.rs"

[dependencies]

[build-dependencies]
sysnum = { path = "../sysnum" }
reverie-sysnum = { path = "../reverie-sysnum" }
2 changes: 1 addition & 1 deletion syscalls/build.rs → reverie-syscalls/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fs::File;
use std::io::{Result, Write};
use std::path::PathBuf;
use sysnum::gen_syscalls;
use reverie_sysnum::gen_syscalls;

fn gen_syscall_nrs(dest: PathBuf) -> Result<()> {
let mut f = File::create(dest)?;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 76dddf6

Please sign in to comment.