libbtrfsutil: add aliases for new naming scheme, version 1.3

The initial version of libbtrfsutil did not follow a unified naming
scheme that's usually used for libraries like those provide by
util-linux. Add aliases that are "btrfs_util_" + object + action +
suffix.

The library version changes to 1.3 but there's no new functionality,
only the aliases added. New functions can be added in the future without
possible confusion when the same action could apply to different
objects.

Issue: #574
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-03-05 22:38:53 +01:00
parent 5f87b467a9
commit 27e965f538
6 changed files with 592 additions and 127 deletions

View File

@ -26,13 +26,15 @@
#include <sys/time.h>
#define BTRFS_UTIL_VERSION_MAJOR 1
#define BTRFS_UTIL_VERSION_MINOR 2
#define BTRFS_UTIL_VERSION_MINOR 3
#define BTRFS_UTIL_VERSION_PATCH 0
#ifdef __cplusplus
extern "C" {
#endif
#define LIBBTRFSUTIL_ALIAS(orig)
/**
* enum btrfs_util_error - libbtrfsutil error codes.
*
@ -78,50 +80,91 @@ enum btrfs_util_error {
*/
const char *btrfs_util_strerror(enum btrfs_util_error err);
/**
* btrfs_util_sync() - Alias of btrfs_fs_util_sync(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_sync(const char *path);
/**
* btrfs_util_sync() - Force a sync on a specific Btrfs filesystem.
* @path: Path on a Btrfs filesystem.
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_sync(const char *path);
enum btrfs_util_error btrfs_util_fs_sync(const char *path)
LIBBTRFSUTIL_ALIAS(btrfs_util_sync);
/**
* btrfs_util_sync_fd() - See btrfs_util_sync().
* btrfs_util_sync_fd() - Alias of btrfs_util_fs_sync_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_sync_fd(int fd);
/**
* btrfs_util_start_sync() - Start a sync on a specific Btrfs filesystem but
* btrfs_util_fs_sync_fd() - See btrfs_util_fs_sync().
*/
enum btrfs_util_error btrfs_util_fs_sync_fd(int fd)
LIBBTRFSUTIL_ALIAS(btrfs_util_sync_fd);
/**
* btrfs_util_start_sync() - Alias of btrfs_util_fs_start_sync(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_start_sync(const char *path, uint64_t *transid);
/**
* btrfs_util_fs_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_fs_wait_sync(). This can be %NULL.
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_start_sync(const char *path,
uint64_t *transid);
enum btrfs_util_error btrfs_util_fs_start_sync(const char *path, uint64_t *transid)
LIBBTRFSUTIL_ALIAS(btrfs_util_start_sync);
/**
* btrfs_util_start_sync_fd() - See btrfs_util_start_sync().
* btrfs_util_start_sync_fd() - Alias of btrfs_util_fs_start_sync_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_start_sync_fd(int fd, uint64_t *transid);
/**
* btrfs_util_wait_sync() - Wait for a transaction with a given ID to sync.
* btrfs_util_fs_start_sync_fd() - See btrfs_util_start_sync().
*/
enum btrfs_util_error btrfs_util_fs_start_sync_fd(int fd, uint64_t *transid)
LIBBTRFSUTIL_ALIAS(btrfs_util_start_sync_fd);
/**
* btrfs_util_wait_sync() - Alias of btrfs_util_fs_wait_sync(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_wait_sync(const char *path, uint64_t transid);
/**
* btrfs_util_fs_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.
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_wait_sync(const char *path, uint64_t transid);
enum btrfs_util_error btrfs_util_fs_wait_sync(const char *path, uint64_t transid)
LIBBTRFSUTIL_ALIAS(btrfs_util_wait_sync);
/**
* btrfs_util_wait_sync_fd() - See btrfs_util_wait_sync().
* btrfs_util_wait_sync_fd() - Alias of btrfs_util_fs_wait_sync_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_wait_sync_fd(int fd, uint64_t transid);
/**
* btrfs_util_fs_wait_sync_fd() - See btrfs_util_fs_wait_sync().
*/
enum btrfs_util_error btrfs_util_fs_wait_sync_fd(int fd, uint64_t transid)
LIBBTRFSUTIL_ALIAS(btrfs_util_wait_sync_fd);
/**
* btrfs_util_is_subvolume() - Alias of btrfs_util_subvolume_is_valid(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_is_subvolume(const char *path);
/**
* btrfs_util_is_subvolume() - Return whether a given path is a Btrfs subvolume.
* @path: Path to check.
@ -131,7 +174,8 @@ enum btrfs_util_error btrfs_util_wait_sync_fd(int fd, uint64_t transid);
* %BTRFS_UTIL_ERROR_NOT_SUBVOLUME if @path is not a subvolume, non-zero error
* code on any other failure.
*/
enum btrfs_util_error btrfs_util_is_subvolume(const char *path);
enum btrfs_util_error btrfs_util_subvolume_is_valid(const char *path)
LIBBTRFSUTIL_ALIAS(btrfs_util_is_subvolume);
/**
* btrfs_util_is_subvolume_fd() - See btrfs_util_is_subvolume().
@ -139,22 +183,44 @@ enum btrfs_util_error btrfs_util_is_subvolume(const char *path);
enum btrfs_util_error btrfs_util_is_subvolume_fd(int fd);
/**
* btrfs_util_subvolume_id() - Get the ID of the subvolume containing a path.
* btrfs_util_subvolume_is_valid_fd() - See btrfs_util_subvolume_is_valid().
*/
enum btrfs_util_error btrfs_util_subvolume_is_valid_fd(int fd)
LIBBTRFSUTIL_ALIAS(btrfs_util_is_subvolume_fd);
/**
* btrfs_util_subvolume_id() - Alias of btrfs_util_subvolume_get_id(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_subvolume_id(const char *path, uint64_t *id_ret);
/**
* btrfs_util_subvolume_get_id() - Get the ID of the subvolume containing a path.
* @path: Path on a Btrfs filesystem.
* @id_ret: Returned subvolume ID.
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_subvolume_id(const char *path,
uint64_t *id_ret);
enum btrfs_util_error btrfs_util_subvolume_get_id(const char *path, uint64_t *id_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_id);
/**
* btrfs_util_subvolume_id_fd() - See btrfs_util_subvolume_id().
* btrfs_util_subvolume_id_fd() - Alias of btrfs_util_subvolume_get_id_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_subvolume_id_fd(int fd, uint64_t *id_ret);
/**
* btrfs_util_subvolume_path() - Get the path of the subvolume with a given ID
* btrfs_util_subvolume_get_id_fd() - See btrfs_util_subvolume_get_id().
*/
enum btrfs_util_error btrfs_util_subvolume_get_id_fd(int fd, uint64_t *id_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_id_fd);
/**
* btrfs_util_subvolume_path() - Alias of btrfs_util_subvolume_get_path(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_subvolume_path(const char *path, uint64_t id, char **path_ret);
/**
* btrfs_util_subvolume_get_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
@ -165,14 +231,19 @@ enum btrfs_util_error btrfs_util_subvolume_id_fd(int fd, uint64_t *id_ret);
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_subvolume_path(const char *path, uint64_t id,
char **path_ret);
enum btrfs_util_error btrfs_util_subvolume_get_path(const char *path, uint64_t id, char **path_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_path);
/**
* btrfs_util_subvolume_path_fd() - See btrfs_util_subvolume_path().
* btrfs_util_subvolume_path_fd() - Alias of btrfs_util_subvolume_get_path_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_subvolume_path_fd(int fd, uint64_t id,
char **path_ret);
enum btrfs_util_error btrfs_util_subvolume_path_fd(int fd, uint64_t id, char **path_ret);
/**
* btrfs_util_subvolume_get_path_fd() - See btrfs_util_subvolume_get_path().
*/
enum btrfs_util_error btrfs_util_subvolume_get_path_fd(int fd, uint64_t id, char **path_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_path_fd);
/**
* struct btrfs_util_subvolume_info - Information about a Btrfs subvolume.
@ -260,6 +331,12 @@ struct btrfs_util_subvolume_info {
struct timespec rtime;
};
/**
* btrfs_util_subvolume_info() - Alias of (), do not use in new code.
*/
enum btrfs_util_error btrfs_util_subvolume_info(const char *path, uint64_t id,
struct btrfs_util_subvolume_info *subvol);
/**
* btrfs_util_subvolume_info() - Get information about a subvolume.
* @path: Path in a Btrfs filesystem. This may be any path in the filesystem; it
@ -275,33 +352,56 @@ struct btrfs_util_subvolume_info {
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_subvolume_info(const char *path, uint64_t id,
struct btrfs_util_subvolume_info *subvol);
enum btrfs_util_error btrfs_util_subvolume_get_info(const char *path, uint64_t id,
struct btrfs_util_subvolume_info *subvol)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_info);
/**
* btrfs_util_subvolume_info_fd() - See btrfs_util_subvolume_info().
* btrfs_util_subvolume_info_fd() - Alias of btrfs_util_subvolume_get_info_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_subvolume_info_fd(int fd, uint64_t id,
struct btrfs_util_subvolume_info *subvol);
/**
* btrfs_util_get_subvolume_read_only() - Get whether a subvolume is read-only.
* btrfs_util_subvolume_get_info_fd() - See btrfs_util_subvolume_get_info().
*/
enum btrfs_util_error btrfs_util_subvolume_get_info_fd(int fd, uint64_t id,
struct btrfs_util_subvolume_info *subvol)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_info_fd);
/**
* btrfs_util_get_subvolume_read_only() - Alias of btrfs_util_subvolume_get_read_only(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_get_subvolume_read_only(const char *path, bool *ret);
/**
* btrfs_util_subvolume_get_read_only() - Get whether a subvolume is read-only.
* @path: Subvolume path.
* @ret: Returned read-only flag.
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_get_subvolume_read_only(const char *path,
bool *ret);
enum btrfs_util_error btrfs_util_subvolume_get_read_only(const char *path, bool *ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_get_subvolume_read_only);
/**
* btrfs_util_get_subvolume_read_only_fd() - See
* btrfs_util_get_subvolume_read_only().
* btrfs_util_get_subvolume_read_only_fd() - Alias of btrfs_util_subvolume_get_read_only_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_get_subvolume_read_only_fd(int fd, bool *ret);
/**
* btrfs_util_set_subvolume_read_only() - Set whether a subvolume is read-only.
* btrfs_util_subvolume_get_read_only_fd() - See btrfs_util_subvolume_get_read_only().
*/
enum btrfs_util_error btrfs_util_subvolume_get_read_only_fd(int fd, bool *ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_get_subvolume_read_only_fd);
/**
* btrfs_util_set_subvolume_read_only() - Alias of btrfs_util_subvolume_set_read_only(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_set_subvolume_read_only(const char *path, bool read_only);
/**
* btrfs_util_subvolume_set_read_only() - Set whether a subvolume is read-only.
* @path: Subvolume path.
* @read_only: New value of read-only flag.
*
@ -309,18 +409,27 @@ enum btrfs_util_error btrfs_util_get_subvolume_read_only_fd(int fd, bool *ret);
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_set_subvolume_read_only(const char *path,
bool read_only);
enum btrfs_util_error btrfs_util_subvolume_set_read_only(const char *path, bool read_only)
LIBBTRFSUTIL_ALIAS(btrfs_util_set_subvolume_read_only);
/**
* btrfs_util_set_subvolume_read_only_fd() - See
* btrfs_util_set_subvolume_read_only().
* btrfs_util_set_subvolume_read_only_fd() - Alias of btrfs_util_subvolume_set_read_only_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_set_subvolume_read_only_fd(int fd,
bool read_only);
enum btrfs_util_error btrfs_util_set_subvolume_read_only_fd(int fd, bool read_only);
/**
* btrfs_util_get_default_subvolume() - Get the default subvolume for a
* btrfs_util_subvolume_set_read_only_fd() - See btrfs_util_subvolume_set_read_only().
*/
enum btrfs_util_error btrfs_util_subvolume_set_read_only_fd(int fd, bool read_only)
LIBBTRFSUTIL_ALIAS(btrfs_util_set_subvolume_read_only_fd);
/**
* btrfs_util_get_default_subvolume() - Alias of btrfs_util_subvolume_get_default(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_get_default_subvolume(const char *path, uint64_t *id_ret);
/**
* btrfs_util_subvolume_get_default() - Get the default subvolume for a
* filesystem.
* @path: Path on a Btrfs filesystem.
* @id_ret: Returned subvolume ID.
@ -329,18 +438,28 @@ enum btrfs_util_error btrfs_util_set_subvolume_read_only_fd(int fd,
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_get_default_subvolume(const char *path,
uint64_t *id_ret);
enum btrfs_util_error btrfs_util_subvolume_get_default(const char *path, uint64_t *id_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_get_default_subvolume);
/**
* btrfs_util_get_default_subvolume_fd() - See
* btrfs_util_get_default_subvolume().
*/
enum btrfs_util_error btrfs_util_get_default_subvolume_fd(int fd,
uint64_t *id_ret);
enum btrfs_util_error btrfs_util_get_default_subvolume_fd(int fd, uint64_t *id_ret);
/**
* btrfs_util_set_default_subvolume() - Set the default subvolume for a
* btrfs_util__subvolume_get_default_fd() - See btrfs_util_subvolume_get_default().
*/
enum btrfs_util_error btrfs_util_subvolume_get_default_fd(int fd, uint64_t *id_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_get_default_subvolume_fd);
/**
* btrfs_util_set_default_subvolume() - Alias of btrfs_util_set_default_subvolume(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_set_default_subvolume(const char *path, uint64_t id);
/**
* btrfs_util_subvolume_set_default() - 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.
@ -351,19 +470,32 @@ enum btrfs_util_error btrfs_util_get_default_subvolume_fd(int fd,
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_set_default_subvolume(const char *path,
uint64_t id);
enum btrfs_util_error btrfs_util_subvolume_set_default(const char *path, uint64_t id)
LIBBTRFSUTIL_ALIAS(btrfs_util_set_default_subvolume);
/**
* btrfs_util_set_default_subvolume_fd() - See
* btrfs_util_set_default_subvolume().
* btrfs_util_set_default_subvolume_fd() - Alias of btrfs_util_subvolume_set_default_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_set_default_subvolume_fd(int fd, uint64_t id);
/**
* btrfs_util_subvolume_set_default_fd() - See
* btrfs_util_subvolume_set_default().
*/
enum btrfs_util_error btrfs_util_subvolume_set_default_fd(int fd, uint64_t id)
LIBBTRFSUTIL_ALIAS(btrfs_util_set_default_subvolume_fd);
struct btrfs_util_qgroup_inherit;
/**
* btrfs_util_create_subvolume() - Create a new subvolume.
* btrfs_util_create_subvolume() - Alias of btrfs_util_subvolume_create(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_create_subvolume(const char *path, int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit);
/**
* btrfs_util_subvolume_create() - Create a new subvolume.
* @path: Where to create the subvolume.
* @flags: Must be zero.
* @unused: No longer used (since 5.15)
@ -371,12 +503,22 @@ struct btrfs_util_qgroup_inherit;
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_create_subvolume(const char *path, int flags,
enum btrfs_util_error btrfs_util_subvolume_create(const char *path, int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit);
struct btrfs_util_qgroup_inherit *qgroup_inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_subvolume);
/**
* btrfs_util_create_subvolume_fd() - Create a new subvolume given its parent
* btrfs_util_create_subvolume_fd() - Alias of btrfs_util_subvolume_create_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_create_subvolume_fd(int parent_fd,
const char *name,
int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit);
/**
* btrfs_util_subvolume_create_fd() - Create a new subvolume given its parent
* and name.
* @parent_fd: File descriptor of the parent directory where the subvolume
* should be created.
@ -387,11 +529,12 @@ enum btrfs_util_error btrfs_util_create_subvolume(const char *path, int flags,
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_create_subvolume_fd(int parent_fd,
enum btrfs_util_error btrfs_util_subvolume_create_fd(int parent_fd,
const char *name,
int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit);
struct btrfs_util_qgroup_inherit *qgroup_inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_subvolume_fd);
/**
* BTRFS_UTIL_CREATE_SNAPSHOT_RECURSIVE - Also snapshot subvolumes beneath the
@ -410,15 +553,7 @@ enum btrfs_util_error btrfs_util_create_subvolume_fd(int parent_fd,
#define BTRFS_UTIL_CREATE_SNAPSHOT_MASK ((1 << 2) - 1)
/**
* 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.
* @unused: See btrfs_util_create_subvolume().
* @qgroup_inherit: See btrfs_util_create_subvolume().
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
* btrfs_util_create_snapshot() - Alias of btrfs_util_snapshot_snapshot(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_create_snapshot(const char *source,
const char *path, int flags,
@ -426,7 +561,24 @@ enum btrfs_util_error btrfs_util_create_snapshot(const char *source,
struct btrfs_util_qgroup_inherit *qgroup_inherit);
/**
* btrfs_util_create_snapshot_fd() - See btrfs_util_create_snapshot().
* btrfs_util_subvolume_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.
* @unused: See btrfs_util_create_subvAlias of (), do not use in new code.olume().
* @qgroup_inherit: See btrfs_util_create_subvolume().
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_subvolume_snapshot(const char *source,
const char *path, int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_snapshot);
/**
* btrfs_util_create_snapshot_fd() - Alias of btrfs_util_subvolume_snapshot_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_create_snapshot_fd(int fd, const char *path,
int flags,
@ -434,15 +586,16 @@ enum btrfs_util_error btrfs_util_create_snapshot_fd(int fd, const char *path,
struct btrfs_util_qgroup_inherit *qgroup_inherit);
/**
* 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().
* @unused: See btrfs_util_create_snapshot().
* @qgroup_inherit: See btrfs_util_create_snapshot().
* btrfs_util_subvolume_snapshot_fd() - See btrfs_util_subvolume_snapshot().
*/
enum btrfs_util_error btrfs_util_subvolume_snapshot_fd(int fd, const char *path,
int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_snapshot_fd);
/**
* btrfs_util_create_snapshot_fd2() -Alias of btrfs_util_subvolume_snapshot_fd2(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_create_snapshot_fd2(int fd, int parent_fd,
const char *name,
@ -450,6 +603,24 @@ enum btrfs_util_error btrfs_util_create_snapshot_fd2(int fd, int parent_fd,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit);
/**
* btrfs_util_subvolume_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_subvolume_snapshot().
* @unused: See btrfs_util_subvolume_snapshot().
* @qgroup_inherit: See btrfs_util_subvolume_snapshot().
*/
enum btrfs_util_error btrfs_util_subvolume_snapshot_fd2(int fd, int parent_fd,
const char *name,
int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_snapshot_fd2);
/**
* BTRFS_UTIL_DELETE_SUBVOLUME_RECURSIVE - Delete subvolumes beneath the given
* subvolume before attempting to delete the given subvolume.
@ -462,7 +633,12 @@ enum btrfs_util_error btrfs_util_create_snapshot_fd2(int fd, int parent_fd,
#define BTRFS_UTIL_DELETE_SUBVOLUME_MASK ((1 << 1) - 1)
/**
* btrfs_util_delete_subvolume() - Delete a subvolume or snapshot.
* btrfs_util_delete_subvolume() - Alias of btrfs_util_subvolume_delete(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_delete_subvolume(const char *path, int flags);
/**
* btrfs_util_subvolume_delete() - Delete a subvolume or snapshot.
* @path: Path of the subvolume to delete.
* @flags: Bitmask of BTRFS_UTIL_DELETE_SUBVOLUME_* flags.
*
@ -475,31 +651,45 @@ enum btrfs_util_error btrfs_util_create_snapshot_fd2(int fd, int parent_fd,
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_delete_subvolume(const char *path, int flags);
enum btrfs_util_error btrfs_util_subvolume_delete(const char *path, int flags)
LIBBTRFSUTIL_ALIAS(btrfs_util_delete_subvolume);
/**
* 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().
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
* btrfs_util_delete_subvolume_fd() - Alias of (), do not use in new code.
*/
enum btrfs_util_error btrfs_util_delete_subvolume_fd(int parent_fd,
const char *name,
int flags);
/**
* btrfs_util_delete_subvolume_by_id_fd() - Delete a subvolume or snapshot using
* btrfs_util_subvolume_delete_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_subvolume_delete().
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_subvolume_delete_fd(int parent_fd,
const char *name,
int flags)
LIBBTRFSUTIL_ALIAS(btrfs_util_delete_subvolume_fd);
/**
* btrfs_util_delete_subvolume_by_id_fd() -Alias of btrfs_util_subvolume_delete_by_id_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_delete_subvolume_by_id_fd(int fd, uint64_t subvolid);
/**
* btrfs_util_subvolume_delete_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.
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_delete_subvolume_by_id_fd(int fd,
uint64_t subvolid);
enum btrfs_util_error btrfs_util_subvolume_delete_by_id_fd(int fd, uint64_t subvolid)
LIBBTRFSUTIL_ALIAS(btrfs_util_delete_subvolume_by_id_fd);
struct btrfs_util_subvolume_iterator;
@ -512,7 +702,15 @@ struct btrfs_util_subvolume_iterator;
#define BTRFS_UTIL_SUBVOLUME_ITERATOR_MASK ((1 << 1) - 1)
/**
* btrfs_util_create_subvolume_iterator() - Create an iterator over subvolumes
* btrfs_util_create_subvolume_iterator() - Alias of btrfs_util_subvolume_iter_create(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_create_subvolume_iterator(const char *path,
uint64_t top,
int flags,
struct btrfs_util_subvolume_iterator **ret);
/**
* btrfs_util_subvolume_iter_create() - 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.
@ -530,18 +728,18 @@ struct btrfs_util_subvolume_iterator;
* skipped.
*
* The returned iterator must be freed with
* btrfs_util_destroy_subvolume_iterator().
* btrfs_util_subvolume_iter_destroy().
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_create_subvolume_iterator(const char *path,
uint64_t top,
int flags,
struct btrfs_util_subvolume_iterator **ret);
enum btrfs_util_error btrfs_util_subvolume_iter_create(const char *path,
uint64_t top,
int flags,
struct btrfs_util_subvolume_iterator **ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_subvolume_iterator);
/**
* btrfs_util_create_subvolume_iterator_fd() - See
* btrfs_util_create_subvolume_iterator().
* btrfs_util_create_subvolume_iterator_fd() - Alias of btrfs_util_subvolume_iter_create_fd(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_create_subvolume_iterator_fd(int fd,
uint64_t top,
@ -549,14 +747,34 @@ enum btrfs_util_error btrfs_util_create_subvolume_iterator_fd(int fd,
struct btrfs_util_subvolume_iterator **ret);
/**
* btrfs_util_destroy_subvolume_iterator() - Destroy a subvolume iterator
* previously created by btrfs_util_create_subvolume_iterator().
* @iter: Iterator to destroy.
* btrfs_util_subvolume_iter_create_fd() - See btrfs_util_subvolume_iter_create().
*/
enum btrfs_util_error btrfs_util_subvolume_iter_create_fd(int fd,
uint64_t top,
int flags,
struct btrfs_util_subvolume_iterator **ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_subvolume_iterator_fd);
/**
* btrfs_util_destroy_subvolume_iterator() - Alias of btrfs_util_subvolume_iter_destroy(), do not use in new code.
*/
void btrfs_util_destroy_subvolume_iterator(struct btrfs_util_subvolume_iterator *iter);
/**
* btrfs_util_subvolume_iterator_fd() - Get the file descriptor associated with
* btrfs_util_subvolume_iter_destroy() - Destroy a subvolume iterator
* previously created by btrfs_util_subvolume_iter_create().
* @iter: Iterator to destroy.
*/
void btrfs_util_subvolume_iter_destroy(struct btrfs_util_subvolume_iterator *iter)
LIBBTRFSUTIL_ALIAS(btrfs_util_destroy_subvolume_iterator);
/**
* btrfs_util_subvolume_iterator_fd() -Alias of btrfs_util_subvolume_iterator_get_fd(), do not use in new code.
*/
int btrfs_util_subvolume_iterator_fd(const struct btrfs_util_subvolume_iterator *iter);
/**
* btrfs_util_subvolume_iterator_get_fd() - Get the file descriptor associated with
* a subvolume iterator.
* @iter: Iterator to get.
*
@ -566,10 +784,18 @@ void btrfs_util_destroy_subvolume_iterator(struct btrfs_util_subvolume_iterator
*
* Return: File descriptor.
*/
int btrfs_util_subvolume_iterator_fd(const struct btrfs_util_subvolume_iterator *iter);
int btrfs_util_subvolume_iterator_get_fd(const struct btrfs_util_subvolume_iterator *iter)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_iterator_fd);
/**
* btrfs_util_subvolume_iterator_next() - Get the next subvolume from a
* btrfs_util_subvolume_iterator_next() - Alias of btrfs_util_subvolume_iter_next(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_subvolume_iterator_next(struct btrfs_util_subvolume_iterator *iter,
char **path_ret,
uint64_t *id_ret);
/**
* btrfs_util_subvolume_iter_next() - Get the next subvolume from a
* subvolume iterator.
* @iter: Subvolume iterator.
* @path_ret: Returned subvolume path, relative to the subvolume ID used to
@ -583,31 +809,45 @@ int btrfs_util_subvolume_iterator_fd(const struct btrfs_util_subvolume_iterator
* Return: %BTRFS_UTIL_OK on success, %BTRFS_UTIL_ERROR_STOP_ITERATION if there
* are no more subvolumes, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_subvolume_iterator_next(struct btrfs_util_subvolume_iterator *iter,
char **path_ret,
uint64_t *id_ret);
enum btrfs_util_error btrfs_util_subvolume_iter_next(struct btrfs_util_subvolume_iterator *iter,
char **path_ret,
uint64_t *id_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_iterator_next);
/**
* 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.
*
* This convenience function basically combines
* btrfs_util_subvolume_iterator_next() and btrfs_util_subvolume_info().
*
* This requires appropriate privilege (CAP_SYS_ADMIN) for kernels < 4.18. See
* btrfs_util_create_subvolume_iterator().
*
* Return: See btrfs_util_subvolume_iterator_next().
* btrfs_util_subvolume_iterator_next_info() - Alias of btrfs_util_subvolume_iter_next_info(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_subvolume_iterator_next_info(struct btrfs_util_subvolume_iterator *iter,
char **path_ret,
struct btrfs_util_subvolume_info *subvol);
/**
* btrfs_util_deleted_subvolumes() - Get a list of subvolume which have been
* btrfs_util_subvolume_iter_next_info() - Get information about the next
* subvolume for a subvolume iterator.
* @iter: Subvolume iterator.
* @path_ret: See btrfs_util_subvolume_iter_next().
* @subvol: Returned subvolume information.
*
* This convenience function basically combines
* btrfs_util_subvolume_iter_next() and btrfs_util_subvolume_info().
*
* This requires appropriate privilege (CAP_SYS_ADMIN) for kernels < 4.18. See
* btrfs_util_create_subvolume_iterator().
*
* Return: See btrfs_util_subvolume_iter_next().
*/
enum btrfs_util_error btrfs_util_subvolume_iter_next_info(struct btrfs_util_subvolume_iterator *iter,
char **path_ret,
struct btrfs_util_subvolume_info *subvol)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_iterator_next_info);
/**
* btrfs_util_deleted_subvolumes() - Alias of btrfs_util_subvolume_list_deleted(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_deleted_subvolumes(const char *path, uint64_t **ids, size_t *n);
/**
* btrfs_util_subvolume_list_deleted() - 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.
@ -617,36 +857,51 @@ enum btrfs_util_error btrfs_util_subvolume_iterator_next_info(struct btrfs_util_
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_deleted_subvolumes(const char *path,
uint64_t **ids,
size_t *n);
enum btrfs_util_error btrfs_util_subvolume_list_deleted(const char *path, uint64_t **ids, size_t *n)
LIBBTRFSUTIL_ALIAS(btrfs_util_deleted_subvolumes);
/**
* btrfs_util_deleted_subvolumes_fd() - See btrfs_util_deleted_subvolumes().
* btrfs_util_deleted_subvolumes_fd() - See btrfs_util_subvolume_list_deleted().
*/
enum btrfs_util_error btrfs_util_deleted_subvolumes_fd(int fd, uint64_t **ids,
size_t *n);
enum btrfs_util_error btrfs_util_deleted_subvolumes_fd(int fd, uint64_t **ids, size_t *n);
/**
* btrfs_util_create_qgroup_inherit() - Create a qgroup inheritance specifier
* btrfs_util_subvolume_list_deleted_fd() - See btrfs_util_subvolume_list_deleted().
*/
enum btrfs_util_error btrfs_util_subvolume_list_deleted_fd(int fd, uint64_t **ids, size_t *n)
LIBBTRFSUTIL_ALIAS(btrfs_util_deleted_subvolumes_fd);
/**
* btrfs_util_create_qgroup_inherit() - Alias of btrfs_util_qgroup_inherit_create(), do not use in new code.
*/
enum btrfs_util_error btrfs_util_create_qgroup_inherit(int flags, struct btrfs_util_qgroup_inherit **ret);
/**
* btrfs_util_qgroup_inherit_create() - Create a qgroup inheritance specifier
* for btrfs_util_create_subvolume() or btrfs_util_create_snapshot().
* @flags: Must be zero.
* @ret: Returned qgroup inheritance specifier.
*
* The returned structure must be freed with
* btrfs_util_destroy_qgroup_inherit().
* btrfs_util_qgroup_inherit_destroy().
*
* Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
*/
enum btrfs_util_error btrfs_util_create_qgroup_inherit(int flags,
struct btrfs_util_qgroup_inherit **ret);
enum btrfs_util_error btrfs_util_qgroup_inherit_create(int flags, struct btrfs_util_qgroup_inherit **ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_qgroup_inherit);
/**
* btrfs_util_destroy_qgroup_inherit() - Destroy a qgroup inheritance specifier
* btrfs_util_destroy_qgroup_inherit() - Alias of btrfs_util_qgroup_inherit_destroy(), do not use in new code.
*/
void btrfs_util_destroy_qgroup_inherit(struct btrfs_util_qgroup_inherit *inherit);
/**
* btrfs_util_qgroup_inherit_destroy() - Destroy a qgroup inheritance specifier
* previously created with btrfs_util_create_qgroup_inherit().
* @inherit: Specifier to destroy.
*/
void btrfs_util_destroy_qgroup_inherit(struct btrfs_util_qgroup_inherit *inherit);
void btrfs_util_qgroup_inherit_destroy(struct btrfs_util_qgroup_inherit *inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_destroy_qgroup_inherit);
/**
* btrfs_util_qgroup_inherit_add_group() - Add inheritance from a qgroup to a
@ -669,6 +924,8 @@ enum btrfs_util_error btrfs_util_qgroup_inherit_add_group(struct btrfs_util_qgro
void btrfs_util_qgroup_inherit_get_groups(const struct btrfs_util_qgroup_inherit *inherit,
const uint64_t **groups, size_t *n);
#undef LIBBTRFSUTIL_ALIAS
#ifdef __cplusplus
}
#endif

View File

@ -30,6 +30,7 @@
#include "btrfs_tree.h"
#define PUBLIC __attribute__((visibility("default")))
#define LIBBTRFSUTIL_ALIAS(orig) __attribute__((alias(#orig)))
#define le16_to_cpu __le16_to_cpu
#define le32_to_cpu __le32_to_cpu

View File

@ -37,6 +37,8 @@ PUBLIC enum btrfs_util_error btrfs_util_sync(const char *path)
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_fs_sync(const char *path)
LIBBTRFSUTIL_ALIAS(btrfs_util_sync);
PUBLIC enum btrfs_util_error btrfs_util_sync_fd(int fd)
{
@ -48,6 +50,8 @@ PUBLIC enum btrfs_util_error btrfs_util_sync_fd(int fd)
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_fs_sync_fd(int fd)
LIBBTRFSUTIL_ALIAS(btrfs_util_sync_fd);
PUBLIC enum btrfs_util_error btrfs_util_start_sync(const char *path,
uint64_t *transid)
@ -63,6 +67,8 @@ PUBLIC enum btrfs_util_error btrfs_util_start_sync(const char *path,
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_fs_start_sync(const char *path, uint64_t *transid)
LIBBTRFSUTIL_ALIAS(btrfs_util_start_sync);
PUBLIC enum btrfs_util_error btrfs_util_start_sync_fd(int fd, uint64_t *transid)
{
@ -74,6 +80,8 @@ PUBLIC enum btrfs_util_error btrfs_util_start_sync_fd(int fd, uint64_t *transid)
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_fs_start_sync_fd(int fd, uint64_t *transid)
LIBBTRFSUTIL_ALIAS(btrfs_util_start_sync_fd);
PUBLIC enum btrfs_util_error btrfs_util_wait_sync(const char *path,
uint64_t transid)
@ -89,6 +97,8 @@ PUBLIC enum btrfs_util_error btrfs_util_wait_sync(const char *path,
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_fs_wait_sync(const char *path, uint64_t transid)
LIBBTRFSUTIL_ALIAS(btrfs_util_wait_sync);
PUBLIC enum btrfs_util_error btrfs_util_wait_sync_fd(int fd, uint64_t transid)
{
@ -100,3 +110,5 @@ PUBLIC enum btrfs_util_error btrfs_util_wait_sync_fd(int fd, uint64_t transid)
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_fs_wait_sync_fd(int fd, uint64_t transid)
LIBBTRFSUTIL_ALIAS(btrfs_util_wait_sync_fd);

View File

@ -1,45 +1,70 @@
LIBBTRFSUTIL_1.1 {
global:
/* btrfs_util_qgroup_inherit_create */
btrfs_util_create_qgroup_inherit;
/* btrfs_util_subvolume_snapshot */
btrfs_util_create_snapshot;
btrfs_util_create_snapshot_fd;
btrfs_util_create_snapshot_fd2;
/* btrfs_util_subvolume_create */
btrfs_util_create_subvolume;
btrfs_util_create_subvolume_fd;
/* btrfs_util_subvolume_iter_create */
btrfs_util_create_subvolume_iterator;
btrfs_util_create_subvolume_iterator_fd;
/* btrfs_util_subvolume_list_deleted */
btrfs_util_deleted_subvolumes;
btrfs_util_deleted_subvolumes_fd;
/* btrfs_util_subvolume_delete */
btrfs_util_delete_subvolume;
btrfs_util_delete_subvolume_fd;
/* btrfs_util_qgroup_inherit_destroy */
btrfs_util_destroy_qgroup_inherit;
/* btrfs_util_subvolume_iter_destroy */
btrfs_util_destroy_subvolume_iterator;
/* btrfs_util_subvolume_get_default */
btrfs_util_get_default_subvolume;
btrfs_util_get_default_subvolume_fd;
/* btrfs_util_subvolume_get_read_only */
btrfs_util_get_subvolume_read_only;
btrfs_util_get_subvolume_read_only_fd;
/* btrfs_util_subvolume_is_valid */
btrfs_util_is_subvolume;
btrfs_util_is_subvolume_fd;
/* No alias */
btrfs_util_qgroup_inherit_add_group;
/* No alias */
btrfs_util_qgroup_inherit_get_groups;
/* btrfs_util_subvolume_set_default */
btrfs_util_set_default_subvolume;
btrfs_util_set_default_subvolume_fd;
/* btrfs_util_subvolume_set_read_only */
btrfs_util_set_subvolume_read_only;
btrfs_util_set_subvolume_read_only_fd;
/* btrfs_util_fs_start_sync */
btrfs_util_start_sync;
btrfs_util_start_sync_fd;
/* No alias */
btrfs_util_strerror;
/* btrfs_util_subvolume_get_id */
btrfs_util_subvolume_id;
btrfs_util_subvolume_id_fd;
/* btrfs_util_subvolume_get_info */
btrfs_util_subvolume_info;
btrfs_util_subvolume_info_fd;
/* btrfs_util_subvolume_iterator_get_fd */
btrfs_util_subvolume_iterator_fd;
/* btrfs_util_subvolume_iter_next */
btrfs_util_subvolume_iterator_next;
/* btrfs_util_subvolume_iter_next_info */
btrfs_util_subvolume_iterator_next_info;
/* btrfs_util_subvolume_get_path */
btrfs_util_subvolume_path;
btrfs_util_subvolume_path_fd;
/* btrfs_util_fs_sync */
btrfs_util_sync;
btrfs_util_sync_fd;
/* btrfs_util_fs_wait_sync */
btrfs_util_wait_sync;
btrfs_util_wait_sync_fd;
local:
@ -50,3 +75,75 @@ LIBBTRFSUTIL_1.2 {
global:
btrfs_util_delete_subvolume_by_id_fd;
} LIBBTRFSUTIL_1.1;
/* Add aliases for all exported functions. */
LIBBTRFSUTIL_1.3 {
global:
/* btrfs_util_create_subvolume */
btrfs_util_subvolume_create;
btrfs_util_subvolume_create_fd;
/* btrfs_util_delete_subvolume */
btrfs_util_subvolume_delete;
btrfs_util_subvolume_delete_fd;
/* btrfs_util_delete_subvolume_by_id_fd */
btrfs_util_subvolume_delete_by_id_fd;
/* btrfs_util_subvolume_id */
btrfs_util_subvolume_get_id;
btrfs_util_subvolume_get_id_fd;
/* btrfs_util_subvolume_info */
btrfs_util_subvolume_get_info;
btrfs_util_subvolume_get_info_fd;
/* btrfs_util_is_subvolume */
btrfs_util_subvolume_is_valid;
btrfs_util_subvolume_is_valid_fd;
/* btrfs_util_subvolume_path */
btrfs_util_subvolume_get_path;
btrfs_util_subvolume_get_path_fd;
/* btrfs_util_get_default_subvolume */
btrfs_util_subvolume_get_default;
btrfs_util_subvolume_get_default_fd;
/* btrfs_util_set_default_subvolume */
btrfs_util_subvolume_set_default;
btrfs_util_subvolume_set_default_fd;
/* btrfs_util_deleted_subvolumes */
btrfs_util_subvolume_list_deleted;
btrfs_util_subvolume_list_deleted_fd;
/* btrfs_util_create_snapshot */
btrfs_util_subvolume_snapshot;
btrfs_util_subvolume_snapshot_fd;
btrfs_util_subvolume_snapshot_fd2;
/* btrfs_util_get_subvolume_read_only */
btrfs_util_subvolume_get_read_only;
btrfs_util_subvolume_get_read_only_fd;
/* btrfs_util_set_subvolume_read_only */
btrfs_util_subvolume_set_read_only;
btrfs_util_subvolume_set_read_only_fd;
/* btrfs_util_create_subvolume_iterator */
btrfs_util_subvolume_iter_create;
btrfs_util_subvolume_iter_create_fd;
/* btrfs_util_destroy_subvolume_iterator */
btrfs_util_subvolume_iter_destroy;
/* btrfs_util_subvolume_iterator_fd */
btrfs_util_subvolume_iterator_get_fd;
/* btrfs_util_subvolume_iterator_next */
btrfs_util_subvolume_iter_next;
/* btrfs_util_subvolume_iterator_next_info */
btrfs_util_subvolume_iter_next_info;
/* Qgroup adapters */
/* btrfs_util_create_qgroup_inherit */
btrfs_util_qgroup_inherit_create;
/* btrfs_util_destroy_qgroup_inherit */
btrfs_util_qgroup_inherit_destroy;
/* btrfs_util_sync */
btrfs_util_fs_sync;
btrfs_util_fs_sync_fd;
/* btrfs_util_start_sync */
btrfs_util_fs_start_sync;
btrfs_util_fs_start_sync_fd;
/* btrfs_util_wait_sync */
btrfs_util_fs_wait_sync;
btrfs_util_fs_wait_sync_fd;
} LIBBTRFSUTIL_1.2;

View File

@ -46,11 +46,15 @@ PUBLIC enum btrfs_util_error btrfs_util_create_qgroup_inherit(int flags,
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_qgroup_inherit_create(int flags, struct btrfs_util_qgroup_inherit **ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_qgroup_inherit);
PUBLIC void btrfs_util_destroy_qgroup_inherit(struct btrfs_util_qgroup_inherit *inherit)
{
free(inherit);
}
PUBLIC void btrfs_util_qgroup_inherit_destroy(struct btrfs_util_qgroup_inherit *inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_destroy_qgroup_inherit);
PUBLIC enum btrfs_util_error btrfs_util_qgroup_inherit_add_group(struct btrfs_util_qgroup_inherit **inherit,
uint64_t qgroupid)

View File

@ -70,6 +70,8 @@ PUBLIC enum btrfs_util_error btrfs_util_is_subvolume(const char *path)
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_is_valid(const char *path)
LIBBTRFSUTIL_ALIAS(btrfs_util_is_subvolume);
PUBLIC enum btrfs_util_error btrfs_util_is_subvolume_fd(int fd)
{
@ -97,6 +99,8 @@ PUBLIC enum btrfs_util_error btrfs_util_is_subvolume_fd(int fd)
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_is_valid_fd(int fd)
LIBBTRFSUTIL_ALIAS(btrfs_util_is_subvolume_fd);
PUBLIC enum btrfs_util_error btrfs_util_subvolume_id(const char *path,
uint64_t *id_ret)
@ -112,6 +116,8 @@ PUBLIC enum btrfs_util_error btrfs_util_subvolume_id(const char *path,
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_get_id(const char *path, uint64_t *id_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_id);
PUBLIC enum btrfs_util_error btrfs_util_subvolume_id_fd(int fd,
uint64_t *id_ret)
@ -130,6 +136,8 @@ PUBLIC enum btrfs_util_error btrfs_util_subvolume_id_fd(int fd,
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_get_id_fd(int fd, uint64_t *id_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_id_fd);
PUBLIC enum btrfs_util_error btrfs_util_subvolume_path(const char *path,
uint64_t id,
@ -146,6 +154,8 @@ PUBLIC enum btrfs_util_error btrfs_util_subvolume_path(const char *path,
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_get_path(const char *path, uint64_t id, char **path_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_path);
PUBLIC enum btrfs_util_error btrfs_util_subvolume_path_fd(int fd, uint64_t id,
char **path_ret)
@ -255,6 +265,8 @@ PUBLIC enum btrfs_util_error btrfs_util_subvolume_path_fd(int fd, uint64_t id,
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_get_path_fd(int fd, uint64_t id, char **path_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_path_fd);
static void copy_timespec(struct timespec *timespec,
const struct btrfs_timespec *btrfs_timespec)
@ -298,6 +310,9 @@ PUBLIC enum btrfs_util_error btrfs_util_subvolume_info(const char *path,
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_get_info(const char *path, uint64_t id,
struct btrfs_util_subvolume_info *subvol)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_info);
static enum btrfs_util_error get_subvolume_info_privileged(int fd, uint64_t id,
struct btrfs_util_subvolume_info *subvol)
@ -452,6 +467,9 @@ PUBLIC enum btrfs_util_error btrfs_util_subvolume_info_fd(int fd, uint64_t id,
return get_subvolume_info_privileged(fd, id, subvol);
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_get_info_fd(int fd, uint64_t id,
struct btrfs_util_subvolume_info *subvol)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_info_fd);
PUBLIC enum btrfs_util_error btrfs_util_get_subvolume_read_only_fd(int fd,
bool *read_only_ret)
@ -466,6 +484,8 @@ PUBLIC enum btrfs_util_error btrfs_util_get_subvolume_read_only_fd(int fd,
*read_only_ret = flags & BTRFS_SUBVOL_RDONLY;
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_get_read_only_fd(int fd, bool *ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_get_subvolume_read_only_fd);
PUBLIC enum btrfs_util_error btrfs_util_get_subvolume_read_only(const char *path,
bool *ret)
@ -481,6 +501,8 @@ PUBLIC enum btrfs_util_error btrfs_util_get_subvolume_read_only(const char *path
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_get_read_only(const char *path, bool *ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_get_subvolume_read_only);
PUBLIC enum btrfs_util_error btrfs_util_set_subvolume_read_only(const char *path,
bool read_only)
@ -496,6 +518,8 @@ PUBLIC enum btrfs_util_error btrfs_util_set_subvolume_read_only(const char *path
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_set_read_only(const char *path, bool read_only)
LIBBTRFSUTIL_ALIAS(btrfs_util_set_subvolume_read_only);
PUBLIC enum btrfs_util_error btrfs_util_set_subvolume_read_only_fd(int fd,
bool read_only)
@ -518,6 +542,8 @@ PUBLIC enum btrfs_util_error btrfs_util_set_subvolume_read_only_fd(int fd,
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_set_read_only_fd(int fd, bool read_only)
LIBBTRFSUTIL_ALIAS(btrfs_util_set_subvolume_read_only_fd);
PUBLIC enum btrfs_util_error btrfs_util_get_default_subvolume(const char *path,
uint64_t *id_ret)
@ -533,6 +559,8 @@ PUBLIC enum btrfs_util_error btrfs_util_get_default_subvolume(const char *path,
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_get_default(const char *path, uint64_t *id_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_get_default_subvolume);
PUBLIC enum btrfs_util_error btrfs_util_get_default_subvolume_fd(int fd,
uint64_t *id_ret)
@ -593,6 +621,8 @@ PUBLIC enum btrfs_util_error btrfs_util_get_default_subvolume_fd(int fd,
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_get_default_fd(int fd, uint64_t *id_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_get_default_subvolume_fd);
PUBLIC enum btrfs_util_error btrfs_util_set_default_subvolume(const char *path,
uint64_t id)
@ -608,6 +638,8 @@ PUBLIC enum btrfs_util_error btrfs_util_set_default_subvolume(const char *path,
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_set_default(const char *path, uint64_t id)
LIBBTRFSUTIL_ALIAS(btrfs_util_set_default_subvolume);
PUBLIC enum btrfs_util_error btrfs_util_set_default_subvolume_fd(int fd,
uint64_t id)
@ -631,6 +663,8 @@ PUBLIC enum btrfs_util_error btrfs_util_set_default_subvolume_fd(int fd,
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_set_default_fd(int fd, uint64_t id)
LIBBTRFSUTIL_ALIAS(btrfs_util_set_default_subvolume_fd);
static enum btrfs_util_error openat_parent_and_name(int dirfd, const char *path,
char *name, size_t name_len,
@ -701,6 +735,10 @@ PUBLIC enum btrfs_util_error btrfs_util_create_subvolume(const char *path,
SAVE_ERRNO_AND_CLOSE(parent_fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_create(const char *path, int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_subvolume);
PUBLIC enum btrfs_util_error btrfs_util_create_subvolume_fd(int parent_fd,
const char *name,
@ -739,6 +777,12 @@ PUBLIC enum btrfs_util_error btrfs_util_create_subvolume_fd(int parent_fd,
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_create_fd(int parent_fd,
const char *name,
int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_subvolume_fd);
#define BTRFS_UTIL_SUBVOLUME_ITERATOR_CLOSE_FD (1 << 30)
@ -949,6 +993,11 @@ PUBLIC enum btrfs_util_error btrfs_util_create_subvolume_iterator(const char *pa
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_iter_create(const char *path,
uint64_t top,
int flags,
struct btrfs_util_subvolume_iterator **ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_subvolume_iterator);
PUBLIC enum btrfs_util_error btrfs_util_create_subvolume_iterator_fd(int fd,
uint64_t top,
@ -1016,6 +1065,11 @@ out_iter:
free(iter);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_iter_create_fd(int fd,
uint64_t top,
int flags,
struct btrfs_util_subvolume_iterator **ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_subvolume_iterator_fd);
static enum btrfs_util_error snapshot_subvolume_children(int fd, int parent_fd,
const char *name)
@ -1101,6 +1155,11 @@ PUBLIC enum btrfs_util_error btrfs_util_create_snapshot(const char *source,
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_snapshot(const char *source,
const char *path, int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_snapshot);
PUBLIC enum btrfs_util_error btrfs_util_create_snapshot_fd(int fd,
const char *path,
@ -1122,6 +1181,11 @@ PUBLIC enum btrfs_util_error btrfs_util_create_snapshot_fd(int fd,
SAVE_ERRNO_AND_CLOSE(parent_fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_snapshot_fd(int fd, const char *path,
int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_snapshot_fd);
PUBLIC enum btrfs_util_error btrfs_util_create_snapshot_fd2(int fd,
int parent_fd,
@ -1172,6 +1236,12 @@ PUBLIC enum btrfs_util_error btrfs_util_create_snapshot_fd2(int fd,
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_snapshot_fd2(int fd, int parent_fd,
const char *name,
int flags,
uint64_t *unused,
struct btrfs_util_qgroup_inherit *qgroup_inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_snapshot_fd2);
static enum btrfs_util_error delete_subvolume_children(int parent_fd,
const char *name)
@ -1239,6 +1309,8 @@ PUBLIC enum btrfs_util_error btrfs_util_delete_subvolume(const char *path,
SAVE_ERRNO_AND_CLOSE(parent_fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_delete(const char *path, int flags)
LIBBTRFSUTIL_ALIAS(btrfs_util_delete_subvolume);
PUBLIC enum btrfs_util_error btrfs_util_delete_subvolume_fd(int parent_fd,
const char *name,
@ -1274,6 +1346,10 @@ PUBLIC enum btrfs_util_error btrfs_util_delete_subvolume_fd(int parent_fd,
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_delete_fd(int parent_fd,
const char *name,
int flags)
LIBBTRFSUTIL_ALIAS(btrfs_util_delete_subvolume_fd);
PUBLIC enum btrfs_util_error btrfs_util_delete_subvolume_by_id_fd(int parent_fd,
uint64_t subvolid)
@ -1290,6 +1366,8 @@ PUBLIC enum btrfs_util_error btrfs_util_delete_subvolume_by_id_fd(int parent_fd,
return BTRFS_UTIL_OK;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_delete_by_id_fd(int fd, uint64_t subvolid)
LIBBTRFSUTIL_ALIAS(btrfs_util_delete_subvolume_by_id_fd);
PUBLIC void btrfs_util_destroy_subvolume_iterator(struct btrfs_util_subvolume_iterator *iter)
{
@ -1303,11 +1381,15 @@ PUBLIC void btrfs_util_destroy_subvolume_iterator(struct btrfs_util_subvolume_it
free(iter);
}
}
PUBLIC void btrfs_util_subvolume_iter_destroy(struct btrfs_util_subvolume_iterator *iter)
LIBBTRFSUTIL_ALIAS(btrfs_util_destroy_subvolume_iterator);
PUBLIC int btrfs_util_subvolume_iterator_fd(const struct btrfs_util_subvolume_iterator *iter)
{
return iter->fd;
}
PUBLIC int btrfs_util_subvolume_iterator_get_fd(const struct btrfs_util_subvolume_iterator *iter)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_iterator_fd);
static enum btrfs_util_error build_subvol_path(struct btrfs_util_subvolume_iterator *iter,
const char *name, size_t name_len,
@ -1586,6 +1668,10 @@ PUBLIC enum btrfs_util_error btrfs_util_subvolume_iterator_next(struct btrfs_uti
id_ret);
}
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_iter_next(struct btrfs_util_subvolume_iterator *iter,
char **path_ret,
uint64_t *id_ret)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_iterator_next);
PUBLIC enum btrfs_util_error btrfs_util_subvolume_iterator_next_info(struct btrfs_util_subvolume_iterator *iter,
char **path_ret,
@ -1603,6 +1689,10 @@ PUBLIC enum btrfs_util_error btrfs_util_subvolume_iterator_next_info(struct btrf
else
return btrfs_util_subvolume_info_fd(iter->cur_fd, 0, subvol);
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_iter_next_info(struct btrfs_util_subvolume_iterator *iter,
char **path_ret,
struct btrfs_util_subvolume_info *subvol)
LIBBTRFSUTIL_ALIAS(btrfs_util_subvolume_iterator_next_info);
PUBLIC enum btrfs_util_error btrfs_util_deleted_subvolumes(const char *path,
uint64_t **ids,
@ -1619,6 +1709,8 @@ PUBLIC enum btrfs_util_error btrfs_util_deleted_subvolumes(const char *path,
SAVE_ERRNO_AND_CLOSE(fd);
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_list_deleted(const char *path, uint64_t **ids, size_t *n)
LIBBTRFSUTIL_ALIAS(btrfs_util_deleted_subvolumes);
PUBLIC enum btrfs_util_error btrfs_util_deleted_subvolumes_fd(int fd,
uint64_t **ids,
@ -1704,3 +1796,5 @@ out:
}
return err;
}
PUBLIC enum btrfs_util_error btrfs_util_subvolume_list_deleted_fd(int fd, uint64_t **ids, size_t *n)
LIBBTRFSUTIL_ALIAS(btrfs_util_deleted_subvolumes_fd);