mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 20:54:26 +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
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
use libc::{c_uint, major, minor};
|
|
||||||
use nix::sys::stat;
|
use nix::sys::stat;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@ -450,9 +449,6 @@ fn update_spec_device(
|
|||||||
vm_path: &str,
|
vm_path: &str,
|
||||||
final_path: &str,
|
final_path: &str,
|
||||||
) -> Result<()> {
|
) -> 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
|
// 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.
|
// update the device in the OCI spec device list. This is an error.
|
||||||
if host_path.is_empty() {
|
if host_path.is_empty() {
|
||||||
@ -470,10 +466,8 @@ fn update_spec_device(
|
|||||||
|
|
||||||
let meta = fs::metadata(vm_path)?;
|
let meta = fs::metadata(vm_path)?;
|
||||||
let dev_id = meta.rdev();
|
let dev_id = meta.rdev();
|
||||||
unsafe {
|
let major_id = stat::major(dev_id);
|
||||||
major_id = major(dev_id);
|
let minor_id = stat::minor(dev_id);
|
||||||
minor_id = minor(dev_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
sl!(),
|
sl!(),
|
||||||
|
Loading…
Reference in New Issue
Block a user