diff options
Diffstat (limited to 'src/cmd/restore.rs')
-rw-r--r-- | src/cmd/restore.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/cmd/restore.rs b/src/cmd/restore.rs index 147a56b..b394d7d 100644 --- a/src/cmd/restore.rs +++ b/src/cmd/restore.rs @@ -5,7 +5,7 @@ use crate::error::ObnamError; use crate::fsentry::{FilesystemEntry, FilesystemKind}; use crate::generation::{LocalGeneration, LocalGenerationError}; use indicatif::{ProgressBar, ProgressStyle}; -use libc::{chmod, timespec, utimensat, AT_FDCWD}; +use libc::{chmod, mkfifo, timespec, utimensat, AT_FDCWD}; use log::{debug, error, info}; use std::ffi::CString; use std::io::prelude::*; @@ -73,6 +73,9 @@ struct Opt { #[derive(Debug, thiserror::Error)] pub enum RestoreError { + #[error("Could not create named pipe (FIFO) {0}")] + NamedPipeCreationError(PathBuf), + #[error(transparent)] ClientError(#[from] ClientError), @@ -112,6 +115,7 @@ fn restore_generation( FilesystemKind::Directory => restore_directory(&to)?, FilesystemKind::Symlink => restore_symlink(&to, &entry)?, FilesystemKind::Socket => restore_socket(&to, &entry)?, + FilesystemKind::Fifo => restore_fifo(&to, &entry)?, } Ok(()) } @@ -188,6 +192,18 @@ fn restore_socket(path: &Path, entry: &FilesystemEntry) -> RestoreResult<()> { Ok(()) } +fn restore_fifo(path: &Path, entry: &FilesystemEntry) -> RestoreResult<()> { + debug!("creating fifo {:?}", path); + let filename = path_to_cstring(path); + match unsafe { mkfifo(filename.as_ptr(), 0) } { + -1 => { + return Err(RestoreError::NamedPipeCreationError(path.to_path_buf())); + } + _ => restore_metadata(path, entry)?, + } + Ok(()) +} + fn restore_metadata(path: &Path, entry: &FilesystemEntry) -> RestoreResult<()> { debug!("restoring metadata for {}", entry.pathbuf().display()); |