Skip to content

Commit

Permalink
review: use nix mknod
Browse files Browse the repository at this point in the history
Signed-off-by: Silenio Quarti <[email protected]>
  • Loading branch information
squarti authored and fitzthum committed Aug 29, 2024
1 parent fbd897f commit 02af65a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion image-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ kbc = { path = "../attestation-agent/kbc", default-features = false, optional =
lazy_static = { workspace = true, optional = true }
log = "0.4.22"
loopdev = { git = "https://github.com/mdaffin/loopdev", rev = "c9f91e8f0326ce8a3364ac911e81eb32328a5f27" }
nix = { workspace = true, optional = true, features = ["mount"] }
nix = { workspace = true, optional = true, features = ["mount", "fs"] }
oci-client = { version = "0.12", default-features = false, optional = true }
oci-spec = "0.6.7"
ocicrypt-rs = { path = "../ocicrypt-rs", default-features = false, features = [
Expand Down
7 changes: 3 additions & 4 deletions image-rs/src/unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use filetime::FileTime;
use futures::StreamExt;
use log::{debug, warn};
use nix::libc::timeval;
use nix::sys::stat::{mknod, Mode, SFlag};

use std::{
collections::HashMap,
convert::TryInto,
Expand Down Expand Up @@ -80,10 +82,7 @@ async fn convert_whiteout(
original_path.display()
))?;

let ret = unsafe { nix::libc::mknod(path.as_ptr(), nix::libc::S_IFCHR, 0) };
if ret != 0 {
bail!("mknod: {:?} error: {:?}", path, io::Error::last_os_error());
}
mknod(path.as_c_str(), SFlag::S_IFCHR, Mode::empty(), 0)?;

set_perms_ownerships(&path, ChownType::LChown, uid, gid, mode).await
}
Expand Down

0 comments on commit 02af65a

Please sign in to comment.