devices/virtio/scsi/sys/
linux.rs

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
5use anyhow::Context;
6use disk::DiskFile;
7
8use crate::virtio::scsi::ScsiOption;
9
10impl ScsiOption {
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            lock: self.lock,
18            ..Default::default()
19        })
20        .context("open_disk_file failed")
21    }
22}