Expand description
§btrfsutil-sys
Raw bindings to libbtrfsutil.
§Building
This library links to libbtrfsutil
, a shared library provided by installing btrfs-progs on most Linux systems.
- Arch Linux:
# pacman -S btrfs-progs
- Ubuntu:
# apt install libbtrfsutil1
(available since eoan)
§Usage
Add this to your Cargo.toml
:
[dependencies]
btrfsutil-sys = "1.2.1"
For further details, please refer to the documentation.
Also, please keep in mind that many of the operations this library can perform may require elevated privileges(CAP_SYSTEM_ADMIN).
§License
MIT
Structs§
- btrfs_
util_ qgroup_ inherit - btrfs_
util_ subvolume_ info - struct btrfs_util_subvolume_info - Information about a Btrfs subvolume.
- btrfs_
util_ subvolume_ iterator - timespec
Constants§
- BTRFS_
FS_ TREE_ OBJECTID - Id of the root subvolume in a Btrfs filesystem.
- BTRFS_
UTIL_ CREATE_ SNAPSHOT_ MASK - BTRFS_
UTIL_ CREATE_ SNAPSHOT_ READ_ ONLY - BTRFS_
UTIL_ CREATE_ SNAPSHOT_ RECURSIVE - BTRFS_
UTIL_ DELETE_ SUBVOLUME_ MASK - BTRFS_
UTIL_ DELETE_ SUBVOLUME_ RECURSIVE - BTRFS_
UTIL_ SUBVOLUME_ ITERATOR_ MASK - BTRFS_
UTIL_ SUBVOLUME_ ITERATOR_ POST_ ORDER - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ DEFAULT_ SUBVOL_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ FS_ INFO_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ GET_ SUBVOL_ INFO_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ GET_ SUBVOL_ ROOTREF_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ INO_ LOOKUP_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ INO_ LOOKUP_ USER_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ INVALID_ ARGUMENT - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ NOT_ BTRFS - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ NOT_ SUBVOLUME - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ NO_ MEMORY - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ OPEN_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ RMDIR_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ SEARCH_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ SNAP_ CREATE_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ SNAP_ DESTROY_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ START_ SYNC_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ STATFS_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ STAT_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ STOP_ ITERATION - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ SUBVOLUME_ NOT_ FOUND - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ SUBVOL_ CREATE_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ SUBVOL_ GETFLAGS_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ SUBVOL_ SETFLAGS_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ SYNC_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ UNLINK_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ ERROR_ WAIT_ SYNC_ FAILED - btrfs_
util_ error_ BTRFS_ UTIL_ OK
Functions§
- btrfs_
util_ ⚠create_ qgroup_ inherit - btrfs_util_create_qgroup_inherit() - Create a qgroup inheritance specifier for btrfs_util_create_subvolume() or btrfs_util_create_snapshot(). @flags: Must be zero. @ret: Returned qgroup inheritance specifier.
- btrfs_
util_ ⚠create_ snapshot - btrfs_util_create_snapshot() - Create a new snapshot from a source subvolume path. @source: Path of the existing subvolume to snapshot. @path: Where to create the snapshot. @flags: Bitmask of BTRFS_UTIL_CREATE_SNAPSHOT_* flags. @async_transid: See btrfs_util_create_subvolume(). If %BTRFS_UTIL_CREATE_SNAPSHOT_RECURSIVE was in @flags, then this will contain the largest transaction ID of all created subvolumes. @qgroup_inherit: See btrfs_util_create_subvolume().
- btrfs_
util_ ⚠create_ snapshot_ fd - btrfs_util_create_snapshot_fd() - See btrfs_util_create_snapshot().
- btrfs_
util_ ⚠create_ snapshot_ fd2 - btrfs_util_create_snapshot_fd2() - Create a new snapshot from a source subvolume file descriptor and a target parent file descriptor and name. @fd: File descriptor of the existing subvolume to snapshot. @parent_fd: File descriptor of the parent directory where the snapshot should be created. @name: Name of the snapshot to create. @flags: See btrfs_util_create_snapshot(). @async_transid: See btrfs_util_create_snapshot(). @qgroup_inherit: See btrfs_util_create_snapshot().
- btrfs_
util_ ⚠create_ subvolume - btrfs_util_create_subvolume() - Create a new subvolume. @path: Where to create the subvolume. @flags: Must be zero. @async_transid: If not NULL, create the subvolume asynchronously (i.e., without waiting for it to commit it to disk) and return the transaction ID that it was created in. This transaction ID can be waited on with btrfs_util_wait_sync(). @qgroup_inherit: Qgroups to inherit from, or NULL.
- btrfs_
util_ ⚠create_ subvolume_ fd - btrfs_util_create_subvolume_fd() - Create a new subvolume given its parent and name. @parent_fd: File descriptor of the parent directory where the subvolume should be created. @name: Name of the subvolume to create. @flags: See btrfs_util_create_subvolume(). @async_transid: See btrfs_util_create_subvolume(). @qgroup_inherit: See btrfs_util_create_subvolume().
- btrfs_
util_ ⚠create_ subvolume_ iterator - btrfs_util_create_subvolume_iterator() - Create an iterator over subvolumes in a Btrfs filesystem. @path: Path in a Btrfs filesystem. This may be any path in the filesystem; it does not have to refer to a subvolume unless @top is zero. @top: List subvolumes beneath (but not including) the subvolume with this ID. If zero is given, the subvolume ID of @path is used. To list all subvolumes, pass %BTRFS_FS_TREE_OBJECTID (i.e., 5). The returned paths are relative to the subvolume with this ID. @flags: Bitmask of BTRFS_UTIL_SUBVOLUME_ITERATOR_* flags. @ret: Returned iterator.
- btrfs_
util_ ⚠create_ subvolume_ iterator_ fd - btrfs_util_create_subvolume_iterator_fd() - See btrfs_util_create_subvolume_iterator().
- btrfs_
util_ ⚠delete_ subvolume - btrfs_util_delete_subvolume() - Delete a subvolume or snapshot. @path: Path of the subvolume to delete. @flags: Bitmask of BTRFS_UTIL_DELETE_SUBVOLUME_* flags.
- btrfs_
util_ ⚠delete_ subvolume_ by_ id_ fd - btrfs_util_delete_subvolume_by_id_fd() - Delete a subvolume or snapshot using subvolume id. @fd: File descriptor of the subvolume’s parent directory. @subvolid: Subvolume id of the subvolume or snapshot to be deleted.
- btrfs_
util_ ⚠delete_ subvolume_ fd - btrfs_util_delete_subvolume_fd() - Delete a subvolume or snapshot given its parent and name. @parent_fd: File descriptor of the subvolume’s parent directory. @name: Name of the subvolume. @flags: See btrfs_util_delete_subvolume().
- btrfs_
util_ ⚠deleted_ subvolumes - btrfs_util_deleted_subvolumes() - Get a list of subvolume which have been deleted but not yet cleaned up. @path: Path on a Btrfs filesystem. @ids: Returned array of subvolume IDs. @n: Returned number of IDs in the @ids array.
- btrfs_
util_ ⚠deleted_ subvolumes_ fd - btrfs_util_deleted_subvolumes_fd() - See btrfs_util_deleted_subvolumes().
- btrfs_
util_ ⚠destroy_ qgroup_ inherit - btrfs_util_destroy_qgroup_inherit() - Destroy a qgroup inheritance specifier previously created with btrfs_util_create_qgroup_inherit(). @inherit: Specifier to destroy.
- btrfs_
util_ ⚠destroy_ subvolume_ iterator - btrfs_util_destroy_subvolume_iterator() - Destroy a subvolume iterator previously created by btrfs_util_create_subvolume_iterator(). @iter: Iterator to destroy.
- btrfs_
util_ ⚠get_ default_ subvolume - btrfs_util_get_default_subvolume() - Get the default subvolume for a filesystem. @path: Path on a Btrfs filesystem. @id_ret: Returned subvolume ID.
- btrfs_
util_ ⚠get_ default_ subvolume_ fd - btrfs_util_get_default_subvolume_fd() - See btrfs_util_get_default_subvolume().
- btrfs_
util_ ⚠get_ subvolume_ read_ only - btrfs_util_get_subvolume_read_only() - Get whether a subvolume is read-only. @path: Subvolume path. @ret: Returned read-only flag.
- btrfs_
util_ ⚠get_ subvolume_ read_ only_ fd - btrfs_util_get_subvolume_read_only_fd() - See btrfs_util_get_subvolume_read_only().
- btrfs_
util_ ⚠is_ subvolume - btrfs_util_is_subvolume() - Return whether a given path is a Btrfs subvolume. @path: Path to check.
- btrfs_
util_ ⚠is_ subvolume_ fd - btrfs_util_is_subvolume_fd() - See btrfs_util_is_subvolume().
- btrfs_
util_ ⚠qgroup_ inherit_ add_ group - btrfs_util_qgroup_inherit_add_group() - Add inheritance from a qgroup to a qgroup inheritance specifier. @inherit: Specifier to modify. May be reallocated. @qgroupid: ID of qgroup to inherit from.
- btrfs_
util_ ⚠qgroup_ inherit_ get_ groups - btrfs_util_qgroup_inherit_get_groups() - Get the qgroups a qgroup inheritance specifier contains. @inherit: Qgroup inheritance specifier. @groups: Returned array of qgroup IDs. @n: Returned number of entries in the @groups array.
- btrfs_
util_ ⚠set_ default_ subvolume - btrfs_util_set_default_subvolume() - Set the default subvolume for a filesystem. @path: Path in a Btrfs filesystem. This may be any path in the filesystem; it does not have to refer to a subvolume unless @id is zero. @id: ID of subvolume to set as the default. If zero is given, the subvolume ID of @path is used.
- btrfs_
util_ ⚠set_ default_ subvolume_ fd - btrfs_util_set_default_subvolume_fd() - See btrfs_util_set_default_subvolume().
- btrfs_
util_ ⚠set_ subvolume_ read_ only - btrfs_util_set_subvolume_read_only() - Set whether a subvolume is read-only. @path: Subvolume path. @read_only: New value of read-only flag.
- btrfs_
util_ ⚠set_ subvolume_ read_ only_ fd - btrfs_util_set_subvolume_read_only_fd() - See btrfs_util_set_subvolume_read_only().
- btrfs_
util_ ⚠start_ sync - btrfs_util_start_sync() - Start a sync on a specific Btrfs filesystem but don’t wait for it. @path: Path on a Btrfs filesystem. @transid: Returned transaction ID which can be waited on with btrfs_util_wait_sync(). This can be %NULL.
- btrfs_
util_ ⚠start_ sync_ fd - btrfs_util_start_sync_fd() - See btrfs_util_start_sync().
- btrfs_
util_ ⚠strerror - btrfs_util_strerror() - Convert a libtrfsutil error code to a string description. @err: The error to convert.
- btrfs_
util_ ⚠subvolume_ id - btrfs_util_subvolume_id() - Get the ID of the subvolume containing a path. @path: Path on a Btrfs filesystem. @id_ret: Returned subvolume ID.
- btrfs_
util_ ⚠subvolume_ id_ fd - btrfs_util_subvolume_id_fd() - See btrfs_util_subvolume_id().
- btrfs_
util_ ⚠subvolume_ info - btrfs_util_subvolume_info() - Get information about a subvolume. @path: Path in a Btrfs filesystem. This may be any path in the filesystem; it does not have to refer to a subvolume unless @id is zero. @id: ID of subvolume to get information about. If zero is given, the subvolume ID of @path is used. @subvol: Returned subvolume information. This can be %NULL if you just want to check whether the subvolume exists; %BTRFS_UTIL_ERROR_SUBVOLUME_NOT_FOUND will be returned if it does not.
- btrfs_
util_ ⚠subvolume_ info_ fd - btrfs_util_subvolume_info_fd() - See btrfs_util_subvolume_info().
- btrfs_
util_ ⚠subvolume_ iterator_ fd - btrfs_util_subvolume_iterator_fd() - Get the file descriptor associated with a subvolume iterator. @iter: Iterator to get.
- btrfs_
util_ ⚠subvolume_ iterator_ next - btrfs_util_subvolume_iterator_next() - Get the next subvolume from a subvolume iterator. @iter: Subvolume iterator. @path_ret: Returned subvolume path, relative to the subvolume ID used to create the iterator. May be %NULL. Must be freed with free(). @id_ret: Returned subvolume ID. May be %NULL.
- btrfs_
util_ ⚠subvolume_ iterator_ next_ info - btrfs_util_subvolume_iterator_next_info() - Get information about the next subvolume for a subvolume iterator. @iter: Subvolume iterator. @path_ret: See btrfs_util_subvolume_iterator_next(). @subvol: Returned subvolume information.
- btrfs_
util_ ⚠subvolume_ path - btrfs_util_subvolume_path() - Get the path of the subvolume with a given ID relative to the filesystem root. @path: Path on a Btrfs filesystem. @id: ID of subvolume to set as the default. If zero is given, the subvolume ID of @path is used. @path_ret: Returned path.
- btrfs_
util_ ⚠subvolume_ path_ fd - btrfs_util_subvolume_path_fd() - See btrfs_util_subvolume_path().
- btrfs_
util_ ⚠sync - btrfs_util_sync() - Force a sync on a specific Btrfs filesystem. @path: Path on a Btrfs filesystem.
- btrfs_
util_ ⚠sync_ fd - btrfs_util_sync_fd() - See btrfs_util_sync().
- btrfs_
util_ ⚠wait_ sync - btrfs_util_wait_sync() - Wait for a transaction with a given ID to sync. @path: Path on a Btrfs filesystem. @transid: Transaction ID to wait for, or zero for the current transaction.
- btrfs_
util_ ⚠wait_ sync_ fd - btrfs_util_wait_sync_fd() - See btrfs_util_wait_sync().
Type Aliases§
- __
syscall_ slong_ t - __
time_ t - btrfs_
util_ error - enum btrfs_util_error - libbtrfsutil error codes.