mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-11 08:19:32 +00:00
libbtrfsutil: add support for IOC_SNAP_DESTROY_V2
Add new ioctl and helpers to allow extended arguments to be passed to subvolume deletion ioctl. The parent_fs argument should be a mount point. Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
f9fb36787a
commit
672e398eed
@ -36,12 +36,14 @@ struct btrfs_ioctl_vol_args {
|
||||
#define BTRFS_DEVICE_PATH_NAME_MAX 1024
|
||||
|
||||
#define BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3)
|
||||
#define BTRFS_SUBVOL_SPEC_BY_ID (1ULL << 4)
|
||||
|
||||
#define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED \
|
||||
(BTRFS_SUBVOL_CREATE_ASYNC | \
|
||||
BTRFS_SUBVOL_RDONLY | \
|
||||
BTRFS_SUBVOL_QGROUP_INHERIT | \
|
||||
BTRFS_DEVICE_SPEC_BY_ID)
|
||||
BTRFS_DEVICE_SPEC_BY_ID | \
|
||||
BTRFS_SUBVOL_SPEC_BY_ID)
|
||||
|
||||
#define BTRFS_FSID_SIZE 16
|
||||
#define BTRFS_UUID_SIZE 16
|
||||
@ -120,6 +122,7 @@ struct btrfs_ioctl_vol_args_v2 {
|
||||
union {
|
||||
char name[BTRFS_SUBVOL_NAME_MAX + 1];
|
||||
__u64 devid;
|
||||
__u64 subvolid;
|
||||
};
|
||||
};
|
||||
|
||||
@ -942,5 +945,7 @@ enum btrfs_err_code {
|
||||
struct btrfs_ioctl_get_subvol_rootref_args)
|
||||
#define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \
|
||||
struct btrfs_ioctl_ino_lookup_user_args)
|
||||
#define BTRFS_IOC_SNAP_DESTROY_V2 _IOW(BTRFS_IOCTL_MAGIC, 63, \
|
||||
struct btrfs_ioctl_vol_args_v2)
|
||||
|
||||
#endif /* _LINUX_BTRFS_H */
|
||||
|
@ -488,6 +488,17 @@ 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
|
||||
* 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);
|
||||
|
||||
struct btrfs_util_subvolume_iterator;
|
||||
|
||||
/**
|
||||
|
@ -1290,6 +1290,22 @@ PUBLIC enum btrfs_util_error btrfs_util_delete_subvolume_fd(int parent_fd,
|
||||
return BTRFS_UTIL_OK;
|
||||
}
|
||||
|
||||
PUBLIC enum btrfs_util_error btrfs_util_delete_subvolume_by_id_fd(int parent_fd,
|
||||
uint64_t subvolid)
|
||||
{
|
||||
struct btrfs_ioctl_vol_args_v2 args = {};
|
||||
int ret;
|
||||
|
||||
args.flags = BTRFS_SUBVOL_SPEC_BY_ID;
|
||||
args.subvolid = subvolid;
|
||||
|
||||
ret = ioctl(parent_fd, BTRFS_IOC_SNAP_DESTROY_V2, &args);
|
||||
if (ret == -1)
|
||||
return BTRFS_UTIL_ERROR_SNAP_DESTROY_FAILED;
|
||||
|
||||
return BTRFS_UTIL_OK;
|
||||
}
|
||||
|
||||
PUBLIC void btrfs_util_destroy_subvolume_iterator(struct btrfs_util_subvolume_iterator *iter)
|
||||
{
|
||||
if (iter) {
|
||||
|
Loading…
Reference in New Issue
Block a user