bcachefs-ioctls 0.1.0

A more ergonomic wrapper around bcachefs' ioctl interface.
Documentation
// Copyright 2025 James Taliaferro
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use nix::{ioctl_read, ioctl_write_ptr};

const IOCTL_MAGIC: u8 = 0xbc;

#[repr(C)]
#[derive(Default, Debug)]
pub struct QueryUuidPayload {
    pub uuid: [u8; 16], // equivalent to a uuid_t; parse properly at a higher level
}

#[repr(C)]
#[derive(Default, Debug)]
pub struct SubvolumePayload {
    pub flags: u32,
    pub dirfd: u32,
    pub mode: u16,
    pub pad: [u16; 3],
    pub dst_ptr: u64,
    pub src_ptr: u64,
}

ioctl_read!(query_uuid, IOCTL_MAGIC, 1, QueryUuidPayload);
ioctl_write_ptr!(subvolume_create, IOCTL_MAGIC, 16, SubvolumePayload);
ioctl_write_ptr!(subvolume_destroy, IOCTL_MAGIC, 17, SubvolumePayload);