Skip to content

Commit

Permalink
Merge branch 'eero/diroid' into 'master'
Browse files Browse the repository at this point in the history
[NODE-1355] Create tool to help with migration to e2fsdroid

One chunk of https://gitlab.com/dfinity-lab/public/ic/-/merge_requests/19059. 

See merge request dfinity-lab/public/ic!19273
  • Loading branch information
Bownairo committed May 14, 2024
2 parents 46c5dd1 + 42fc5a9 commit 619f23a
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ members = [
"rs/http_utils",
"rs/ic_os/deterministic_ips",
"rs/ic_os/dflate",
"rs/ic_os/diroid",
"rs/ic_os/config",
"rs/ic_os/fstrim_tool",
"rs/ic_os/guestos_tool",
Expand Down
17 changes: 17 additions & 0 deletions rs/ic_os/diroid/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@rules_rust//rust:defs.bzl", "rust_binary")

package(default_visibility = ["//visibility:public"])

DEPENDENCIES = [
"@crate_index//:walkdir",
]

MACRO_DEPENDENCIES = []

rust_binary(
name = "diroid",
srcs = glob(["src/**/*.rs"]),
proc_macro_deps = MACRO_DEPENDENCIES,
version = "0.1.0",
deps = DEPENDENCIES,
)
9 changes: 9 additions & 0 deletions rs/ic_os/diroid/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "diroid"
version = "0.1.0"
edition = "2021"

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

[dependencies]
walkdir = "2.5.0"
4 changes: 4 additions & 0 deletions rs/ic_os/diroid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# diroid

`diroid` is a tool that generates an `e2fsdroid` `fs_config` file for a given directory tree.
This file describes the metadata associated with files as they are placed into the filesystem.
25 changes: 25 additions & 0 deletions rs/ic_os/diroid/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::env;
use std::os::unix::fs::MetadataExt;

use walkdir::WalkDir;

fn main() {
let args: Vec<String> = env::args().collect();

if args.len() != 2 {
panic!("Incorrect arguments!");
}

for entry in WalkDir::new(&args[1]) {
let entry = entry.unwrap();

let metadata = entry.metadata().unwrap();
println!(
"{} {} {} {:o}",
entry.path().strip_prefix(&args[1]).unwrap().display(),
metadata.uid(),
metadata.gid(),
metadata.mode()
);
}
}

0 comments on commit 619f23a

Please sign in to comment.