/// Creates a new snapshot from a source subvolume.
Creates a new snapshot from a source subvolume.
Creates a new snapshot from a source subvolume .
pub fn create_snapshot<P: AsRef<Path>>(
    source: P,
    path: P,
    flags: CreateSnapshotFlags,
    qgroup: Option<QgroupInherit>,
) -> Result<(), Error> {
    let csource = CString::new(source.as_ref().as_os_str().as_bytes()).unwrap();
    let cpath = CString::new(path.as_ref().as_os_str().as_bytes()).unwrap();
    let cflags = flags.bits();
    let unused = std::ptr::null_mut();
    let cqgroup: *mut ffi::btrfs_util_qgroup_inherit = if let Some(qg) = qgroup {
        qg.as_ptr()
    } else {
        std::ptr::null_mut()
    };
    unsafe {
        let errcode = ffi::btrfs_util_create_snapshot(
            csource.as_ptr(),
            cpath.as_ptr(),
            cflags,
            unused,
            cqgroup,
        );
        if errcode != ffi::btrfs_util_error_BTRFS_UTIL_OK {
            return Err(errcode.into());
        }
    }
    Ok(())
}
pub fn create_snapshot < P : AsRef < Path > > ( source : P , path : P , flags : CreateSnapshotFlags , qgroup : Option < QgroupInherit > , ) -> Result < ( ) , Error > { let csource = CString :: new ( source . as_ref ( ) . as_os_str ( ) . as_bytes ( ) ) . unwrap ( ) ; let cpath = CString :: new ( path . as_ref ( ) . as_os_str ( ) . as_bytes ( ) ) . unwrap ( ) ; let cflags = flags . bits ( ) ; let unused = std :: ptr :: null_mut ( ) ; let cqgroup : * mut ffi :: btrfs_util_qgroup_inherit = if let Some ( qg ) = qgroup { qg . as_ptr ( ) } else { std :: ptr :: null_mut ( ) } ; unsafe { let errcode = ffi :: btrfs_util_create_snapshot ( csource . as_ptr ( ) , cpath . as_ptr ( ) , cflags , unused , cqgroup , ) ; if errcode != ffi :: btrfs_util_error_BTRFS_UTIL_OK { return Err ( errcode . into ( ) ) ; } } Ok ( ( ) ) }
Creates a new snapshot from a source subvolume.
Creates a new snapshot from a source subvolume .
source
P
path
P
flags
CreateSnapshotFlags
qgroup
Option<QgroupInherit>