Skip to content

Commit 738bded

Browse files
committed
filemap: added check for duplicate paths
1 parent e1dbf83 commit 738bded

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/isolation/filemap.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl UhyveFileMap {
3030
/// * `mappings` - A list of host->guest path mappings with the format "./host_path.txt:guest.txt"
3131
/// * `tempdir` - Path to create temporary directory on
3232
pub fn new(mappings: &[String], tempdir: Option<PathBuf>) -> UhyveFileMap {
33-
UhyveFileMap {
33+
let fm = UhyveFileMap {
3434
files: mappings
3535
.iter()
3636
.map(String::as_str)
@@ -39,7 +39,13 @@ impl UhyveFileMap {
3939
.collect(),
4040
tempdir: create_temp_dir(tempdir),
4141
fdmap: UhyveFileDescriptorLayer::default(),
42-
}
42+
};
43+
assert_eq!(
44+
fm.files.len(),
45+
mappings.len(),
46+
"Error when creating filemap. Are duplicate paths present?"
47+
);
48+
fm
4349
}
4450

4551
/// Returns the host_path on the host filesystem given a requested guest_path, if it exists.

0 commit comments

Comments
 (0)