1 // Copyright 2023 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 use anyhow::Context; 6 use disk::DiskFile; 7 8 use crate::virtio::scsi::ScsiOption; 9 10 impl ScsiOption { open(&self) -> anyhow::Result<Box<dyn DiskFile>>11 pub fn open(&self) -> anyhow::Result<Box<dyn DiskFile>> { 12 // We only support sparse disks for now. 13 disk::open_disk_file(disk::DiskFileParams { 14 path: self.path.clone(), 15 is_read_only: self.read_only, 16 is_sparse_file: true, 17 is_overlapped: false, 18 is_direct: false, 19 lock: self.lock, 20 depth: 0, 21 }) 22 .context("open_disk_file failed") 23 } 24 } 25