From 6ec6d4021bb2613e24224220bfa171146384a344 Mon Sep 17 00:00:00 2001 From: Ossi Herrala Date: Mon, 9 Aug 2021 08:46:16 +0300 Subject: Fix compilation on MacOS For chmod() we need to cast mode parameter from u32 to u16 because MacOS has 16 bit mode_t while Linux is using 32 bits. --- src/cmd/restore.rs | 2 +- src/fsentry.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cmd/restore.rs b/src/cmd/restore.rs index e03f3de..e9e89b5 100644 --- a/src/cmd/restore.rs +++ b/src/cmd/restore.rs @@ -264,7 +264,7 @@ fn restore_metadata(path: &Path, entry: &FilesystemEntry) -> Result<(), RestoreE unsafe { if entry.kind() != FilesystemKind::Symlink { debug!("chmod {:?}", path); - if chmod(path.as_ptr(), entry.mode()) == -1 { + if chmod(path.as_ptr(), entry.mode() as libc::mode_t) == -1 { let error = Error::last_os_error(); error!("chmod failed on {:?}", path); return Err(RestoreError::Chmod(pathbuf, error)); diff --git a/src/fsentry.rs b/src/fsentry.rs index 1a30d41..8338cc2 100644 --- a/src/fsentry.rs +++ b/src/fsentry.rs @@ -3,11 +3,16 @@ use serde::{Deserialize, Serialize}; use std::ffi::OsString; use std::fs::read_link; use std::fs::{FileType, Metadata}; -use std::os::linux::fs::MetadataExt; use std::os::unix::ffi::OsStringExt; use std::os::unix::fs::FileTypeExt; use std::path::{Path, PathBuf}; +#[cfg(target_os = "linux")] +use std::os::linux::fs::MetadataExt; + +#[cfg(target_os = "macos")] +use std::os::macos::fs::MetadataExt; + /// A file system entry. /// /// Represent all backup-relevant the metadata about a file system -- cgit v1.2.1