Merge pull request #3181 from egernst/topic/clean-lint

Cleanup some unused variables, definitions
This commit is contained in:
Bin Liu
2021-12-03 11:06:42 +08:00
committed by GitHub
2 changed files with 17 additions and 28 deletions

View File

@@ -34,17 +34,9 @@ use crate::log_child;
// struct is populated from the content in the /proc/<pid>/mountinfo file.
#[derive(std::fmt::Debug)]
pub struct Info {
id: i32,
parent: i32,
major: i32,
minor: i32,
root: String,
mount_point: String,
opts: String,
optional: String,
fstype: String,
source: String,
vfs_opts: String,
}
const MOUNTINFOFORMAT: &str = "{d} {d} {d}:{d} {} {} {} {}";
@@ -562,7 +554,20 @@ fn parse_mount_table() -> Result<Vec<Info>> {
for (_index, line) in reader.lines().enumerate() {
let line = line?;
let (id, parent, major, minor, root, mount_point, opts, optional) = scan_fmt!(
//Example mountinfo format:
// id
// | / parent
// | | / major:minor
// | | | / root
// | | | | / mount_point
// | | | | | / opts
// | | | | | | / optional
// | | | | | | | / fstype
// | | | | | | | | / source
// | | | | | | | | | / vfs_opts
// 22 96 0:21 / /sys rw,nosuid,nodev,noexec,relatime shared:2 - sysfs sysfs rw,seclabel
let (_id, _parent, _major, _minor, _root, mount_point, _opts, optional) = scan_fmt!(
&line,
MOUNTINFOFORMAT,
i32,
@@ -577,7 +582,7 @@ fn parse_mount_table() -> Result<Vec<Info>> {
let fields: Vec<&str> = line.split(" - ").collect();
if fields.len() == 2 {
let (fstype, source, vfs_opts) =
let (fstype, _source, _vfs_opts) =
scan_fmt!(fields[1], "{} {} {}", String, String, String)?;
let mut optional_new = String::new();
@@ -586,17 +591,9 @@ fn parse_mount_table() -> Result<Vec<Info>> {
}
let info = Info {
id,
parent,
major,
minor,
root,
mount_point,
opts,
optional: optional_new,
fstype,
source,
vfs_opts,
};
infos.push(info);

View File

@@ -5,30 +5,22 @@
use anyhow::{anyhow, Result};
use nix::mount::{self, MsFlags};
use protocols::types::{Interface, Route};
use slog::Logger;
use std::collections::HashMap;
use std::fs;
const KATA_GUEST_SANDBOX_DNS_FILE: &str = "/run/kata-containers/sandbox/resolv.conf";
const GUEST_DNS_FILE: &str = "/etc/resolv.conf";
// Network fully describes a sandbox network with its interfaces, routes and dns
// Network describes a sandbox network, includings its dns
// related information.
#[derive(Debug, Default)]
pub struct Network {
ifaces: HashMap<String, Interface>,
routes: Vec<Route>,
dns: Vec<String>,
}
impl Network {
pub fn new() -> Network {
Network {
ifaces: HashMap::new(),
routes: Vec::new(),
dns: Vec::new(),
}
Network { dns: Vec::new() }
}
pub fn set_dns(&mut self, dns: String) {