pub struct Zfs { /* private fields */ }
Expand description
A handle to work with Zfs pools, datasets, etc
Implementations§
Source§impl Zfs
impl Zfs
Sourcepub fn create<S: CStrArgument>(
&self,
name: S,
dataset_type: DataSetType,
props: &NvList,
) -> Result<()>
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()
Sourcepub fn clone_dataset<S: CStrArgument, S2: CStrArgument>(
&self,
name: S,
origin: S2,
props: &mut NvListRef,
) -> Result<()>
pub fn clone_dataset<S: CStrArgument, S2: CStrArgument>( &self, name: S, origin: S2, props: &mut NvListRef, ) -> Result<()>
Corresponds to lzc_clone()
Sourcepub fn promote<S: CStrArgument>(
&self,
fsname: S,
snap_name_buf: &mut [u8],
) -> Result<()>
pub fn promote<S: CStrArgument>( &self, fsname: S, snap_name_buf: &mut [u8], ) -> Result<()>
Corresponds to lzc_promote()
Sourcepub fn rename<S: CStrArgument, T: CStrArgument>(
&self,
source: S,
target: T,
) -> Result<()>
pub fn rename<S: CStrArgument, T: CStrArgument>( &self, source: S, target: T, ) -> Result<()>
Corresponds to lzc_rename()
Sourcepub fn destroy<S: CStrArgument>(&self, name: S) -> Result<()>
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()
Sourcepub fn snapshot<I: IntoIterator<Item = S>, S: CStrArgument>(
&self,
snaps: I,
) -> Result<(), Error>
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()
.
Sourcepub fn snapshot_raw(
&self,
snaps: &NvList,
props: &NvList,
) -> Result<(), Result<Error, NvList>>
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()
.
pub fn destroy_snaps<I: IntoIterator<Item = S>, S: CStrArgument>( &self, snaps: I, defer: Defer, ) -> Result<(), (Error, NvList)>
Sourcepub fn destroy_snaps_raw(
&self,
snaps: &NvList,
defer: Defer,
) -> Result<(), (Error, NvList)>
pub fn destroy_snaps_raw( &self, snaps: &NvList, defer: Defer, ) -> Result<(), (Error, NvList)>
Corresponds to lzc_destroy_snaps()
Sourcepub fn snaprange_space<F: CStrArgument, L: CStrArgument>(
&self,
first_snap: F,
last_snap: L,
) -> Result<u64>
pub fn snaprange_space<F: CStrArgument, L: CStrArgument>( &self, first_snap: F, last_snap: L, ) -> Result<u64>
Corresponds to lzc_snaprange_space()
Sourcepub fn exists<S: CStrArgument>(&self, name: S) -> bool
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()
.
Sourcepub fn sync<S: CStrArgument>(&self, pool_name: S, force: bool) -> Result<()>
pub fn sync<S: CStrArgument>(&self, pool_name: S, force: bool) -> Result<()>
Corresponds to lzc_sync()
.
Sourcepub fn hold_raw(
&self,
holds: &NvListRef,
cleanup_fd: Option<RawFd>,
) -> Result<(), Result<Error, NvList>>
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).
Sourcepub 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,
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
.
Sourcepub fn release_raw(
&self,
holds: &NvListRef,
) -> Result<(), Result<Error, NvList>>
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
.
Sourcepub 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,
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
.
Sourcepub fn get_holds<S: CStrArgument>(&self, snapname: S) -> Result<HoldList>
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()
Sourcepub fn send<S: CStrArgument, F: CStrArgument>(
&self,
snapname: S,
from: Option<F>,
fd: RawFd,
flags: SendFlags,
) -> Result<()>
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()
Sourcepub fn send_resume<S: CStrArgument, F: CStrArgument>(
&self,
snapname: S,
from: F,
fd: RawFd,
flags: SendFlags,
resume_obj: u64,
resume_off: u64,
) -> Result<()>
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()
Sourcepub fn send_space<S: CStrArgument, F: CStrArgument>(
&self,
snapname: S,
from: F,
flags: SendFlags,
) -> Result<u64>
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()
Sourcepub fn receive<S: CStrArgument, O: CStrArgument>(
&self,
snapname: S,
props: Option<&NvListRef>,
origin: Option<O>,
force: bool,
raw: bool,
fd: RawFd,
) -> Result<()>
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()
Sourcepub fn receive_resumable<S: CStrArgument, O: CStrArgument>(
&self,
snapname: S,
props: &NvListRef,
origin: O,
force: bool,
raw: bool,
fd: RawFd,
) -> Result<()>
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()
Sourcepub fn rollback<S: CStrArgument>(&self, fsname: S) -> Result<CString>
pub fn rollback<S: CStrArgument>(&self, fsname: S) -> Result<CString>
Corresponds to lzc_rollback()
Sourcepub fn rollback_to<F: CStrArgument, S: CStrArgument>(
&self,
fsname: F,
snapname: S,
) -> Result<()>
pub fn rollback_to<F: CStrArgument, S: CStrArgument>( &self, fsname: F, snapname: S, ) -> Result<()>
Corresponds to lzc_rollback_to()
Sourcepub fn bookmark<I: IntoIterator<Item = (D, S)>, D: CStrArgument, S: CStrArgument>(
&self,
bookmarks: I,
) -> Result<(), ErrorList>
pub fn bookmark<I: IntoIterator<Item = (D, S)>, D: CStrArgument, S: CStrArgument>( &self, bookmarks: I, ) -> Result<(), ErrorList>
Create bookmarks from existing snapshot or bookmark
Sourcepub fn bookmark_raw(&self, bookmarks: &NvListRef) -> Result<(), (Error, NvList)>
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()
Sourcepub fn get_bookmarks_raw<F: CStrArgument>(
&self,
fsname: F,
props: &NvListRef,
) -> Result<NvList>
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()
Sourcepub fn get_bookmark_props<B: CStrArgument>(&self, bookmark: B) -> Result<NvList>
pub fn get_bookmark_props<B: CStrArgument>(&self, bookmark: B) -> Result<NvList>
Corresponds to lzc_get_bookmark_props()
Sourcepub fn destroy_bookmarks(
&self,
bookmarks: &NvListRef,
) -> Result<(), (Error, NvList)>
pub fn destroy_bookmarks( &self, bookmarks: &NvListRef, ) -> Result<(), (Error, NvList)>
Corresponds to lzc_destroy_bookmarks()
Sourcepub fn channel_program<P: CStrArgument, R: CStrArgument>(
&self,
pool: P,
program: R,
instruction_limit: u64,
memlimit: u64,
args: &NvListRef,
) -> Result<NvList>
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()
Sourcepub fn channel_program_nosync<P: CStrArgument, R: CStrArgument>(
&self,
pool: P,
program: R,
instruction_limit: u64,
memlimit: u64,
args: &NvListRef,
) -> Result<NvList>
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()
Sourcepub fn pool_checkpoint<P: CStrArgument>(&self, pool: P) -> Result<()>
pub fn pool_checkpoint<P: CStrArgument>(&self, pool: P) -> Result<()>
Create a pool checkpoint
Corresponds to lzc_pool_checkpoint()
Sourcepub fn pool_checkpoint_discard<P: CStrArgument>(&self, pool: P) -> Result<()>
pub fn pool_checkpoint_discard<P: CStrArgument>(&self, pool: P) -> Result<()>
Discard the pool checkpoint
Corresponds to lzc_pool_checkpoint_discard()
Sourcepub fn load_key<F: CStrArgument>(
&self,
fsname: F,
noop: bool,
keydata: &[u8],
) -> Result<()>
pub fn load_key<F: CStrArgument>( &self, fsname: F, noop: bool, keydata: &[u8], ) -> Result<()>
Corresponds to lzc_load_key()
Sourcepub fn unload_key<F: CStrArgument>(&self, fsname: F) -> Result<()>
pub fn unload_key<F: CStrArgument>(&self, fsname: F) -> Result<()>
Corresponds to lzc_unload_key()
Sourcepub fn change_key<F: CStrArgument>(
&self,
fsname: F,
crypt_cmd: u64,
props: &NvListRef,
keydata: Option<&[u8]>,
) -> Result<()>
pub fn change_key<F: CStrArgument>( &self, fsname: F, crypt_cmd: u64, props: &NvListRef, keydata: Option<&[u8]>, ) -> Result<()>
Corresponds to lzc_change_key()
Sourcepub fn reopen<P: CStrArgument>(
&self,
pool: P,
scrub_restart: bool,
) -> Result<()>
pub fn reopen<P: CStrArgument>( &self, pool: P, scrub_restart: bool, ) -> Result<()>
Corresponds to lzc_reopen()
Sourcepub fn initialize<P: CStrArgument>(
&self,
pool: P,
initialize_func: PoolInitializeFunc,
vdevs: &NvListRef,
) -> Result<(), (Error, NvList)>
pub fn initialize<P: CStrArgument>( &self, pool: P, initialize_func: PoolInitializeFunc, vdevs: &NvListRef, ) -> Result<(), (Error, NvList)>
Corresponds to lzc_initialize()