Struct Zfs

Source
pub struct Zfs { /* private fields */ }
Expand description

A handle to work with Zfs pools, datasets, etc

Implementations§

Source§

impl Zfs

Source

pub fn new() -> Result<Self>

Create a handle to the Zfs subsystem

Source

pub fn create<S: CStrArgument>( &self, name: S, dataset_type: DataSetType, props: &NvList, ) -> Result<()>

Create a new dataset of the given type with props set as properties

Corresponds to lzc_create()

Source

pub fn clone_dataset<S: CStrArgument, S2: CStrArgument>( &self, name: S, origin: S2, props: &mut NvListRef, ) -> Result<()>

Corresponds to lzc_clone()

Source

pub fn promote<S: CStrArgument>( &self, fsname: S, snap_name_buf: &mut [u8], ) -> Result<()>

Corresponds to lzc_promote()

Source

pub fn rename<S: CStrArgument, T: CStrArgument>( &self, source: S, target: T, ) -> Result<()>

Corresponds to lzc_rename()

Source

pub fn destroy<S: CStrArgument>(&self, name: S) -> Result<()>

Destroy the given dataset (which may be a filesystem, snapshot, bookmark, volume, etc)

Corresponds to lzc_destroy()

Source

pub fn snapshot<I: IntoIterator<Item = S>, S: CStrArgument>( &self, snaps: I, ) -> Result<(), Error>

Create snapshot(s)

The snapshots must be from the same pool, and must not reference the same dataset (iow: cannot create 2 snapshots of the same filesystem).

Corresponds to lzc_snapshot().

Source

pub fn snapshot_raw( &self, snaps: &NvList, props: &NvList, ) -> Result<(), Result<Error, NvList>>

Create snapshot(s). snaps is a list of bool (not boolean_value) entries, the names of which correspond to snapshot names.

The snapshots must be from the same pool, and must not reference the same dataset (iow: cannot create 2 snapshots of the same filesystem with a single call).

Corresponds to lzc_snapshot().

Source

pub fn destroy_snaps<I: IntoIterator<Item = S>, S: CStrArgument>( &self, snaps: I, defer: Defer, ) -> Result<(), (Error, NvList)>

Source

pub fn destroy_snaps_raw( &self, snaps: &NvList, defer: Defer, ) -> Result<(), (Error, NvList)>

Corresponds to lzc_destroy_snaps()

Source

pub fn snaprange_space<F: CStrArgument, L: CStrArgument>( &self, first_snap: F, last_snap: L, ) -> Result<u64>

Corresponds to lzc_snaprange_space()

Source

pub fn exists<S: CStrArgument>(&self, name: S) -> bool

Check if a dataset (a filesystem, or a volume, or a snapshot) with the given name exists.

Note: cannot check for bookmarks

Corresponds to lzc_exists().

Source

pub fn sync<S: CStrArgument>(&self, pool_name: S, force: bool) -> Result<()>

Corresponds to lzc_sync().

Source

pub fn hold_raw( &self, holds: &NvListRef, cleanup_fd: Option<RawFd>, ) -> Result<(), Result<Error, NvList>>

Create “user holds” on snapshots. If there is a hold on a snapshot, the snapshot can not be destroyed. (However, it can be marked for deletion by lzc_destroy_snaps(defer=B_TRUE).)

The keys in the nvlist are snapshot names.
The snapshots must all be in the same pool. The value is the name of the hold (string type).

Source

pub fn hold<'a, H, S, N>( &self, holds: H, cleanup_fd: Option<RawFd>, ) -> Result<(), Error>
where H: IntoIterator<Item = &'a (S, N)>, S: 'a + CStrArgument + Clone, N: 'a + CStrArgument + Clone,

Create a set of holds, each on a given snapshot

Related: [get_holds], [release], [hold_raw], [release_raw].

Corresponds to lzc_hold.

Source

pub fn release_raw( &self, holds: &NvListRef, ) -> Result<(), Result<Error, NvList>>

Release holds from various snapshots

The holds nvlist is [(snap_name, [hold_names])], allowing multiple holds for multiple snapshots to be released with one call.

Related: [release]

Corresponds to lzc_release.

Source

pub fn release<'a, F, C, H, N>(&self, holds: F) -> Result<(), Error>
where F: IntoIterator<Item = &'a (C, H)>, C: 'a + CStrArgument + Clone, H: 'a + IntoIterator<Item = N> + Clone, N: 'a + CStrArgument + Clone,

For a list of datasets, release one or more holds by name

Corresponds to lzc_release.

Source

pub fn get_holds<S: CStrArgument>(&self, snapname: S) -> Result<HoldList>

Get the holds for a given snapshot

The returned nvlist is [(hold_name: String, unix_timestamp_seconds: u64)], where the unix timestamp is when the hold was created.

Corresponds to lzc_get_holds()

Source

pub fn send<S: CStrArgument, F: CStrArgument>( &self, snapname: S, from: Option<F>, fd: RawFd, flags: SendFlags, ) -> Result<()>

Send the described stream

Internally, is a wrapper around [send_resume_redacted()]

Corresponds to lzc_send()

Source

pub fn send_resume<S: CStrArgument, F: CStrArgument>( &self, snapname: S, from: F, fd: RawFd, flags: SendFlags, resume_obj: u64, resume_off: u64, ) -> Result<()>

Send the described stream with resume information

Internally, this is a wrapper around [send_resume_redacted()].

Corresponds to lzc_send_resume()

Source

pub fn send_space<S: CStrArgument, F: CStrArgument>( &self, snapname: S, from: F, flags: SendFlags, ) -> Result<u64>

Estimate the size of the stream to be sent if [send] were called with the same arguments

Internally, this is a wrapper around [send_space_resume_redacted()].

Corresponds to lzc_send_space()

Source

pub fn receive<S: CStrArgument, O: CStrArgument>( &self, snapname: S, props: Option<&NvListRef>, origin: Option<O>, force: bool, raw: bool, fd: RawFd, ) -> Result<()>

Corresponds to lzc_receive()

Source

pub fn receive_resumable<S: CStrArgument, O: CStrArgument>( &self, snapname: S, props: &NvListRef, origin: O, force: bool, raw: bool, fd: RawFd, ) -> Result<()>

Corresponds to lzc_receive_resumable()

Source

pub fn rollback<S: CStrArgument>(&self, fsname: S) -> Result<CString>

Corresponds to lzc_rollback()

Source

pub fn rollback_to<F: CStrArgument, S: CStrArgument>( &self, fsname: F, snapname: S, ) -> Result<()>

Corresponds to lzc_rollback_to()

Source

pub fn bookmark<I: IntoIterator<Item = (D, S)>, D: CStrArgument, S: CStrArgument>( &self, bookmarks: I, ) -> Result<(), ErrorList>

Create bookmarks from existing snapshot or bookmark

Source

pub fn bookmark_raw(&self, bookmarks: &NvListRef) -> Result<(), (Error, NvList)>

Create bookmarks from existing snapshot or bookmark

The bookmarks nvlist is [(full_name_of_new_bookmark, full_name_of_source_snap_or_bookmark)].

Corresponds to lzc_bookmark()

Source

pub fn get_bookmarks_raw<F: CStrArgument>( &self, fsname: F, props: &NvListRef, ) -> Result<NvList>

Retreive bookmarks for the given filesystem

props is a list of [(prop_name, ())], where prop_name names a property on a bookmark. All the named properties are returned in the return value as the values of each bookmark.

Corresponds to lzc_get_bookmarks()

Source

pub fn get_bookmark_props<B: CStrArgument>(&self, bookmark: B) -> Result<NvList>

Corresponds to lzc_get_bookmark_props()

Source

pub fn destroy_bookmarks( &self, bookmarks: &NvListRef, ) -> Result<(), (Error, NvList)>

Corresponds to lzc_destroy_bookmarks()

Source

pub fn channel_program<P: CStrArgument, R: CStrArgument>( &self, pool: P, program: R, instruction_limit: u64, memlimit: u64, args: &NvListRef, ) -> Result<NvList>

Execute a channel program

root privlidges are required to execute a channel program

Corresponds to lzc_channel_program()

Source

pub fn channel_program_nosync<P: CStrArgument, R: CStrArgument>( &self, pool: P, program: R, instruction_limit: u64, memlimit: u64, args: &NvListRef, ) -> Result<NvList>

Execute a read-only channel program

root privlidges are required to execute a channel program (even a read-only one)

Corresponds to lzc_channel_program_nosync()

Source

pub fn pool_checkpoint<P: CStrArgument>(&self, pool: P) -> Result<()>

Create a pool checkpoint

Corresponds to lzc_pool_checkpoint()

Source

pub fn pool_checkpoint_discard<P: CStrArgument>(&self, pool: P) -> Result<()>

Discard the pool checkpoint

Corresponds to lzc_pool_checkpoint_discard()

Source

pub fn load_key<F: CStrArgument>( &self, fsname: F, noop: bool, keydata: &[u8], ) -> Result<()>

Corresponds to lzc_load_key()

Source

pub fn unload_key<F: CStrArgument>(&self, fsname: F) -> Result<()>

Corresponds to lzc_unload_key()

Source

pub fn change_key<F: CStrArgument>( &self, fsname: F, crypt_cmd: u64, props: &NvListRef, keydata: Option<&[u8]>, ) -> Result<()>

Corresponds to lzc_change_key()

Source

pub fn reopen<P: CStrArgument>( &self, pool: P, scrub_restart: bool, ) -> Result<()>

Corresponds to lzc_reopen()

Source

pub fn initialize<P: CStrArgument>( &self, pool: P, initialize_func: PoolInitializeFunc, vdevs: &NvListRef, ) -> Result<(), (Error, NvList)>

Corresponds to lzc_initialize()

Source

pub fn trim<P: CStrArgument>( &self, pool: P, pool_trim_func: PoolTrimFunc, rate: u64, secure: bool, vdevs: &NvListRef, ) -> Result<(), (Error, NvList)>

Corresponds to lzc_trim()

Trait Implementations§

Source§

impl Debug for Zfs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Zfs

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Zfs

§

impl RefUnwindSafe for Zfs

§

impl Send for Zfs

§

impl Sync for Zfs

§

impl Unpin for Zfs

§

impl UnwindSafe for Zfs

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.