mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
agent/device: Use nix::sys::stat::{major,minor} instead of libc::*
update_spec_devices() includes an unsafe block, in order to call the libc functions to get the major and minor numbers from a device ID. However, the nix crate already has a safe wrapper for this function, which we use in other places in the file. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
c01189d4a6
commit
94b7936f51
@ -3,7 +3,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use libc::{c_uint, major, minor};
|
||||
use nix::sys::stat;
|
||||
use regex::Regex;
|
||||
use std::collections::HashMap;
|
||||
@ -450,9 +449,6 @@ fn update_spec_device(
|
||||
vm_path: &str,
|
||||
final_path: &str,
|
||||
) -> Result<()> {
|
||||
let major_id: c_uint;
|
||||
let minor_id: c_uint;
|
||||
|
||||
// If no container_path is provided, we won't be able to match and
|
||||
// update the device in the OCI spec device list. This is an error.
|
||||
if host_path.is_empty() {
|
||||
@ -470,10 +466,8 @@ fn update_spec_device(
|
||||
|
||||
let meta = fs::metadata(vm_path)?;
|
||||
let dev_id = meta.rdev();
|
||||
unsafe {
|
||||
major_id = major(dev_id);
|
||||
minor_id = minor(dev_id);
|
||||
}
|
||||
let major_id = stat::major(dev_id);
|
||||
let minor_id = stat::minor(dev_id);
|
||||
|
||||
info!(
|
||||
sl!(),
|
||||
|
Loading…
Reference in New Issue
Block a user