mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 10:10:41 +00:00
arch: fix file permissions for Windows pstore.
Without setting the share mode, we can't do occasionally useful things like tail the pstore file. BUG=b:237597358 TEST=builds + tested downstream on Windows Change-Id: I893d0e52a671eeec5981527c1009b9d188110534 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3736759 Commit-Queue: Noah Gold <nkgold@google.com> Reviewed-by: Vikram Auradkar <auradkar@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
b273d2f30b
commit
3fd26a58b3
1 changed files with 14 additions and 4 deletions
|
@ -3,6 +3,8 @@
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
|
#[cfg(windows)]
|
||||||
|
use std::os::windows::fs::OpenOptionsExt;
|
||||||
|
|
||||||
use crate::Pstore;
|
use crate::Pstore;
|
||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
|
@ -10,6 +12,8 @@ use base::MemoryMappingBuilder;
|
||||||
use hypervisor::Vm;
|
use hypervisor::Vm;
|
||||||
use resources::AddressRange;
|
use resources::AddressRange;
|
||||||
use vm_memory::GuestAddress;
|
use vm_memory::GuestAddress;
|
||||||
|
#[cfg(windows)]
|
||||||
|
use winapi::um::winnt::FILE_SHARE_READ;
|
||||||
|
|
||||||
pub struct RamoopsRegion {
|
pub struct RamoopsRegion {
|
||||||
pub address: u64,
|
pub address: u64,
|
||||||
|
@ -27,10 +31,16 @@ pub fn create_memory_region(
|
||||||
bail!("insufficient space for pstore {} {}", region, pstore.size);
|
bail!("insufficient space for pstore {} {}", region, pstore.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
let file = OpenOptions::new()
|
let mut open_opts = OpenOptions::new();
|
||||||
.read(true)
|
open_opts.read(true).write(true).create(true);
|
||||||
.write(true)
|
|
||||||
.create(true)
|
// Allow other applications to read the memory region.
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
open_opts.share_mode(FILE_SHARE_READ);
|
||||||
|
}
|
||||||
|
|
||||||
|
let file = open_opts
|
||||||
.open(&pstore.path)
|
.open(&pstore.path)
|
||||||
.context("failed to open pstore")?;
|
.context("failed to open pstore")?;
|
||||||
file.set_len(pstore.size as u64)
|
file.set_len(pstore.size as u64)
|
||||||
|
|
Loading…
Reference in a new issue