Skip to content

Commit 14ae545

Browse files
committed
Don't use ioctl
Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 45eb07e commit 14ae545

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

sys_util/src/block.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use ioctl::ioctl_with_mut_ref;
54
use std::fs::File;
6-
use std::io::Error;
5+
use std::io::{Error, Seek, SeekFrom};
76
use std::os::raw;
87

9-
const FS: raw::c_uint = 0x12;
10-
ioctl_ior_nr!(BLKGETSIZE64, FS, 114, ::std::os::raw::c_ulong);
11-
128
pub fn get_blk_dev_size(path: &std::path::Path) -> std::result::Result<u64, std::io::Error> {
13-
let mut size: u64 = 0;
14-
15-
let file = File::open(path)?;
16-
let ret = unsafe { ioctl_with_mut_ref(&file, BLKGETSIZE64(), &mut size) };
17-
18-
if ret < 0 {
19-
return Err(Error::last_os_error());
20-
}
9+
let mut file = File::open(path)?;
10+
let size = file.seek(SeekFrom::End(0))?;
2111
Ok(size)
2212
}
2313

tests/integration_tests/functional/test_drives.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ def test_rescan_file(test_microvm_with_ssh, network_config):
6161
def test_rescan_dev(test_microvm_with_ssh, network_config):
6262
"""Verify that rescan works with a device-backed virtio device."""
6363
test_microvm = test_microvm_with_ssh
64-
# To access a block device, seccomp_level = 2 is too restrictive
65-
test_microvm.jailer.seccomp_level = 1
6664
test_microvm.spawn()
6765

6866
# Set up the microVM with 1 vCPUs, 256 MiB of RAM, 0 network ifaces and

0 commit comments

Comments
 (0)