Skip to content

Commit

Permalink
Updates and fixes losetup binray
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Daffin committed Dec 5, 2017
1 parent 11151a8 commit 8a2865a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 136 deletions.
170 changes: 42 additions & 128 deletions losetup/Cargo.lock

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

2 changes: 0 additions & 2 deletions losetup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ version = "0.1.2"

[dependencies]
clap = "2.23.3"
docopt = "0.7.0"
rustc-serialize = "0.3.24"

[dependencies.loopdev]
optional = false
Expand Down
17 changes: 11 additions & 6 deletions losetup/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ fn find() {
}

fn attach(image: &str, loopdev: Option<&str>, offset: u64) {
exit_on_error!(match loopdev {
None => LoopControl::open().and_then(|lc| lc.next_free()),
Some(dev) => LoopDevice::open(&dev),
}
.and_then(|ld| ld.attach(&image, offset)))
exit_on_error!(
match loopdev {
None => LoopControl::open().and_then(|lc| lc.next_free()),
Some(dev) => LoopDevice::open(&dev),
}.and_then(|ld| ld.attach(&image, offset))
)
}

fn detach(dev: &str) {
Expand Down Expand Up @@ -73,7 +74,11 @@ fn main() {
} else if let Some(matches) = matches.subcommand_matches("attach") {
let image = matches.value_of("image").unwrap();
let loopdev = matches.value_of("loopdev");
attach(image, loopdev, matches.value_of("offset").unwrap_or(0));
attach(
image,
loopdev,
value_t!(matches.value_of("offset"), u64).unwrap_or(0),
);
} else if let Some(matches) = matches.subcommand_matches("detach") {
let file = matches.value_of("file").unwrap();
detach(file);
Expand Down

0 comments on commit 8a2865a

Please sign in to comment.