From e2c7082c64ef93a668ccb3cdb56a3eefb2b8dfcb Mon Sep 17 00:00:00 2001 From: K900 Date: Thu, 19 Jan 2023 11:02:49 +0300 Subject: fix: fix compatibility with latest WSL update --- scripts/native-systemd-shim/src/main.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/native-systemd-shim/src/main.rs b/scripts/native-systemd-shim/src/main.rs index 1cfc90c..504335c 100644 --- a/scripts/native-systemd-shim/src/main.rs +++ b/scripts/native-systemd-shim/src/main.rs @@ -4,13 +4,13 @@ use nix::mount::{mount, MsFlags}; use nix::sys::wait::{waitid, Id, WaitPidFlag}; use nix::unistd::Pid; use std::env; -use std::fs::{create_dir_all, remove_dir_all, remove_file, OpenOptions}; +use std::fs::{create_dir_all, metadata, remove_dir_all, remove_file, OpenOptions}; use std::os::unix::io::{FromRawFd, IntoRawFd}; use std::os::unix::process::CommandExt; use std::path::Path; use std::process::{Command, Stdio}; -fn real_main() -> anyhow::Result<()> { +fn unscrew_dev_shm() -> anyhow::Result<()> { log::trace!("Unscrewing /dev/shm..."); let dev_shm = Path::new("/dev/shm"); @@ -39,6 +39,19 @@ fn real_main() -> anyhow::Result<()> { ) .context("When bind mounting /run/shm to /dev/shm")?; + Ok(()) +} + +fn real_main() -> anyhow::Result<()> { + if metadata("/dev/shm") + .context("When checking /dev/shm")? + .is_symlink() + { + unscrew_dev_shm()?; + } else { + log::trace!("/dev/shm is not a symlink, leaving as-is..."); + }; + log::trace!("Remounting / shared..."); mount( -- cgit v1.2.3