Show More
@@ -320,7 +320,14 b' impl Repo {' | |||||
320 | .set(Some(docket.uuid.to_owned())); |
|
320 | .set(Some(docket.uuid.to_owned())); | |
321 | let data_size = docket.data_size(); |
|
321 | let data_size = docket.data_size(); | |
322 | let metadata = docket.tree_metadata(); |
|
322 | let metadata = docket.tree_metadata(); | |
323 | if let Some(data_mmap) = self |
|
323 | if crate::vfs::is_on_nfs_mount(docket.data_filename()) { | |
|
324 | // Don't mmap on NFS to prevent `SIGBUS` error on deletion | |||
|
325 | OwningDirstateMap::new_v2( | |||
|
326 | self.hg_vfs().read(docket.data_filename())?, | |||
|
327 | data_size, | |||
|
328 | metadata, | |||
|
329 | ) | |||
|
330 | } else if let Some(data_mmap) = self | |||
324 | .hg_vfs() |
|
331 | .hg_vfs() | |
325 | .mmap_open(docket.data_filename()) |
|
332 | .mmap_open(docket.data_filename()) | |
326 | .io_not_found_as_none()? |
|
333 | .io_not_found_as_none()? |
@@ -172,3 +172,24 b' pub(crate) fn is_dir(path: impl AsRef<Pa' | |||||
172 | pub(crate) fn is_file(path: impl AsRef<Path>) -> Result<bool, HgError> { |
|
172 | pub(crate) fn is_file(path: impl AsRef<Path>) -> Result<bool, HgError> { | |
173 | Ok(fs_metadata(path)?.map_or(false, |meta| meta.is_file())) |
|
173 | Ok(fs_metadata(path)?.map_or(false, |meta| meta.is_file())) | |
174 | } |
|
174 | } | |
|
175 | ||||
|
176 | /// Returns whether the given `path` is on a network file system. | |||
|
177 | /// Taken from `cargo`'s codebase. | |||
|
178 | #[cfg(target_os = "linux")] | |||
|
179 | pub(crate) fn is_on_nfs_mount(path: impl AsRef<Path>) -> bool { | |||
|
180 | use std::ffi::CString; | |||
|
181 | use std::mem; | |||
|
182 | use std::os::unix::prelude::*; | |||
|
183 | ||||
|
184 | let path = match CString::new(path.as_ref().as_os_str().as_bytes()) { | |||
|
185 | Ok(path) => path, | |||
|
186 | Err(_) => return false, | |||
|
187 | }; | |||
|
188 | ||||
|
189 | unsafe { | |||
|
190 | let mut buf: libc::statfs = mem::zeroed(); | |||
|
191 | let r = libc::statfs(path.as_ptr(), &mut buf); | |||
|
192 | ||||
|
193 | r == 0 && buf.f_type as u32 == libc::NFS_SUPER_MAGIC as u32 | |||
|
194 | } | |||
|
195 | } |
General Comments 0
You need to be logged in to leave comments.
Login now