Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use anyhow::{bail, Context, Result};
use log::debug;
use std::fs;
use std::io::{self, Write};
use std::os::linux::fs::MetadataExt;
use std::os::unix::fs::{symlink, OpenOptionsExt};
use std::os::unix::fs::{symlink, MetadataExt, OpenOptionsExt};
use std::path::{Path, PathBuf};

/// Canonicalise `path`, checking for directory traversal outside of `base`.
Expand Down Expand Up @@ -76,12 +75,12 @@ pub fn link_localtime(

// We should seek to avoid avoid /etc/localtime disappearing, even briefly, to avoid
// applications being unhappy -- that's why we insist on atomic rename.
let tmp_dev = localtime_tmp_path.metadata()?.st_dev();
let tmp_dev = localtime_tmp_path.metadata()?.dev();
let target_dev = localtime_path
.parent()
.context("localtime path has no parent")?
.metadata()?
.st_dev();
.dev();

if tmp_dev != target_dev {
fs::remove_file(&localtime_tmp_path)?;
Expand Down