btrfs_cli/filesystem/
sync.rs1use crate::{RunContext, Runnable, util::open_path};
2use anyhow::{Context, Result};
3use btrfs_uapi::filesystem::sync;
4use clap::Parser;
5use std::{os::unix::io::AsFd, path::PathBuf};
6
7#[derive(Parser, Debug)]
9pub struct FilesystemSyncCommand {
10 pub path: PathBuf,
11}
12
13impl Runnable for FilesystemSyncCommand {
14 fn run(&self, _ctx: &RunContext) -> Result<()> {
15 let file = open_path(&self.path)?;
16 sync(file.as_fd()).with_context(|| {
17 format!("failed to sync '{}'", self.path.display())
18 })?;
19 Ok(())
20 }
21}