Crate btrfsutil_sys

source ·
Expand description

btrfsutil-sys

Build Status btrfsutil-sys docs libbtrfsutil version

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

Constants

Functions

  • 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() - 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() - See btrfs_util_create_snapshot().
  • 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() - 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() - 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() - 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() - See btrfs_util_create_subvolume_iterator().
  • 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() - 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() - 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() - 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() - See btrfs_util_deleted_subvolumes().
  • 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() - Destroy a subvolume iterator previously created by btrfs_util_create_subvolume_iterator(). @iter: Iterator to destroy.
  • 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() - See btrfs_util_get_default_subvolume().
  • 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() - See btrfs_util_get_subvolume_read_only().
  • btrfs_util_is_subvolume() - Return whether a given path is a Btrfs subvolume. @path: Path to check.
  • btrfs_util_is_subvolume_fd() - See btrfs_util_is_subvolume().
  • 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() - 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() - 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() - See btrfs_util_set_default_subvolume().
  • 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() - See btrfs_util_set_subvolume_read_only().
  • 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() - See btrfs_util_start_sync().
  • btrfs_util_strerror() - Convert a libtrfsutil error code to a string description. @err: The error to convert.
  • 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() - See btrfs_util_subvolume_id().
  • 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() - See btrfs_util_subvolume_info().
  • btrfs_util_subvolume_iterator_fd() - Get the file descriptor associated with a subvolume iterator. @iter: Iterator to get.
  • 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() - 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() - 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() - See btrfs_util_subvolume_path().
  • btrfs_util_sync() - Force a sync on a specific Btrfs filesystem. @path: Path on a Btrfs filesystem.
  • btrfs_util_sync_fd() - See btrfs_util_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() - See btrfs_util_wait_sync().

Type Definitions