|
1 | 1 | /* automatically generated by rust-bindgen */ |
2 | 2 |
|
| 3 | +#[repr(C)] |
| 4 | +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] |
| 5 | +pub struct __BindgenBitfieldUnit<Storage, Align> { |
| 6 | + storage: Storage, |
| 7 | + align: [Align; 0], |
| 8 | +} |
| 9 | +impl<Storage, Align> __BindgenBitfieldUnit<Storage, Align> { |
| 10 | + #[inline] |
| 11 | + pub const fn new(storage: Storage) -> Self { |
| 12 | + Self { storage, align: [] } |
| 13 | + } |
| 14 | +} |
| 15 | +impl<Storage, Align> __BindgenBitfieldUnit<Storage, Align> |
| 16 | +where |
| 17 | + Storage: AsRef<[u8]> + AsMut<[u8]>, |
| 18 | +{ |
| 19 | + #[inline] |
| 20 | + pub fn get_bit(&self, index: usize) -> bool { |
| 21 | + debug_assert!(index / 8 < self.storage.as_ref().len()); |
| 22 | + let byte_index = index / 8; |
| 23 | + let byte = self.storage.as_ref()[byte_index]; |
| 24 | + let bit_index = if cfg!(target_endian = "big") { |
| 25 | + 7 - (index % 8) |
| 26 | + } else { |
| 27 | + index % 8 |
| 28 | + }; |
| 29 | + let mask = 1 << bit_index; |
| 30 | + byte & mask == mask |
| 31 | + } |
| 32 | + #[inline] |
| 33 | + pub fn set_bit(&mut self, index: usize, val: bool) { |
| 34 | + debug_assert!(index / 8 < self.storage.as_ref().len()); |
| 35 | + let byte_index = index / 8; |
| 36 | + let byte = &mut self.storage.as_mut()[byte_index]; |
| 37 | + let bit_index = if cfg!(target_endian = "big") { |
| 38 | + 7 - (index % 8) |
| 39 | + } else { |
| 40 | + index % 8 |
| 41 | + }; |
| 42 | + let mask = 1 << bit_index; |
| 43 | + if val { |
| 44 | + *byte |= mask; |
| 45 | + } else { |
| 46 | + *byte &= !mask; |
| 47 | + } |
| 48 | + } |
| 49 | + #[inline] |
| 50 | + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { |
| 51 | + debug_assert!(bit_width <= 64); |
| 52 | + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); |
| 53 | + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); |
| 54 | + let mut val = 0; |
| 55 | + for i in 0..(bit_width as usize) { |
| 56 | + if self.get_bit(i + bit_offset) { |
| 57 | + let index = if cfg!(target_endian = "big") { |
| 58 | + bit_width as usize - 1 - i |
| 59 | + } else { |
| 60 | + i |
| 61 | + }; |
| 62 | + val |= 1 << index; |
| 63 | + } |
| 64 | + } |
| 65 | + val |
| 66 | + } |
| 67 | + #[inline] |
| 68 | + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { |
| 69 | + debug_assert!(bit_width <= 64); |
| 70 | + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); |
| 71 | + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); |
| 72 | + for i in 0..(bit_width as usize) { |
| 73 | + let mask = 1 << i; |
| 74 | + let val_bit_is_set = val & mask == mask; |
| 75 | + let index = if cfg!(target_endian = "big") { |
| 76 | + bit_width as usize - 1 - i |
| 77 | + } else { |
| 78 | + i |
| 79 | + }; |
| 80 | + self.set_bit(index + bit_offset, val_bit_is_set); |
| 81 | + } |
| 82 | + } |
| 83 | +} |
3 | 84 | pub const ZFS_MAX_DATASET_NAME_LEN: u32 = 256; |
4 | 85 | pub const ZPROP_VALUE: &'static [u8; 6usize] = b"value\0"; |
5 | 86 | pub const ZPOOL_CONFIG_POOL_NAME: &'static [u8; 5usize] = b"name\0"; |
@@ -81,7 +162,7 @@ impl ::std::ops::BitAndAssign for zfs_type_t { |
81 | 162 | self.0 &= rhs.0; |
82 | 163 | } |
83 | 164 | } |
84 | | -#[repr(C)] |
| 165 | +#[repr(transparent)] |
85 | 166 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
86 | 167 | pub struct zfs_type_t(pub u32); |
87 | 168 | pub const dmu_objset_type_DMU_OST_NONE: dmu_objset_type = 0; |
@@ -661,11 +742,158 @@ extern "C" { |
661 | 742 | altroot: *mut ::std::os::raw::c_char, |
662 | 743 | ) -> ::std::os::raw::c_int; |
663 | 744 | } |
| 745 | +#[repr(C)] |
| 746 | +#[derive(Debug, Copy, Clone)] |
| 747 | +pub struct importargs { |
| 748 | + pub path: *mut *mut ::std::os::raw::c_char, |
| 749 | + pub paths: ::std::os::raw::c_int, |
| 750 | + pub poolname: *mut ::std::os::raw::c_char, |
| 751 | + pub guid: u64, |
| 752 | + pub cachefile: *mut ::std::os::raw::c_char, |
| 753 | + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, |
| 754 | + pub __bindgen_padding_0: [u8; 7usize], |
| 755 | +} |
| 756 | +#[test] |
| 757 | +fn bindgen_test_layout_importargs() { |
| 758 | + assert_eq!( |
| 759 | + ::std::mem::size_of::<importargs>(), |
| 760 | + 48usize, |
| 761 | + concat!("Size of: ", stringify!(importargs)) |
| 762 | + ); |
| 763 | + assert_eq!( |
| 764 | + ::std::mem::align_of::<importargs>(), |
| 765 | + 8usize, |
| 766 | + concat!("Alignment of ", stringify!(importargs)) |
| 767 | + ); |
| 768 | + assert_eq!( |
| 769 | + unsafe { &(*(::std::ptr::null::<importargs>())).path as *const _ as usize }, |
| 770 | + 0usize, |
| 771 | + concat!( |
| 772 | + "Offset of field: ", |
| 773 | + stringify!(importargs), |
| 774 | + "::", |
| 775 | + stringify!(path) |
| 776 | + ) |
| 777 | + ); |
| 778 | + assert_eq!( |
| 779 | + unsafe { &(*(::std::ptr::null::<importargs>())).paths as *const _ as usize }, |
| 780 | + 8usize, |
| 781 | + concat!( |
| 782 | + "Offset of field: ", |
| 783 | + stringify!(importargs), |
| 784 | + "::", |
| 785 | + stringify!(paths) |
| 786 | + ) |
| 787 | + ); |
| 788 | + assert_eq!( |
| 789 | + unsafe { &(*(::std::ptr::null::<importargs>())).poolname as *const _ as usize }, |
| 790 | + 16usize, |
| 791 | + concat!( |
| 792 | + "Offset of field: ", |
| 793 | + stringify!(importargs), |
| 794 | + "::", |
| 795 | + stringify!(poolname) |
| 796 | + ) |
| 797 | + ); |
| 798 | + assert_eq!( |
| 799 | + unsafe { &(*(::std::ptr::null::<importargs>())).guid as *const _ as usize }, |
| 800 | + 24usize, |
| 801 | + concat!( |
| 802 | + "Offset of field: ", |
| 803 | + stringify!(importargs), |
| 804 | + "::", |
| 805 | + stringify!(guid) |
| 806 | + ) |
| 807 | + ); |
| 808 | + assert_eq!( |
| 809 | + unsafe { &(*(::std::ptr::null::<importargs>())).cachefile as *const _ as usize }, |
| 810 | + 32usize, |
| 811 | + concat!( |
| 812 | + "Offset of field: ", |
| 813 | + stringify!(importargs), |
| 814 | + "::", |
| 815 | + stringify!(cachefile) |
| 816 | + ) |
| 817 | + ); |
| 818 | +} |
| 819 | +impl importargs { |
| 820 | + #[inline] |
| 821 | + pub fn can_be_active(&self) -> ::std::os::raw::c_int { |
| 822 | + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } |
| 823 | + } |
| 824 | + #[inline] |
| 825 | + pub fn set_can_be_active(&mut self, val: ::std::os::raw::c_int) { |
| 826 | + unsafe { |
| 827 | + let val: u32 = ::std::mem::transmute(val); |
| 828 | + self._bitfield_1.set(0usize, 1u8, val as u64) |
| 829 | + } |
| 830 | + } |
| 831 | + #[inline] |
| 832 | + pub fn unique(&self) -> ::std::os::raw::c_int { |
| 833 | + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u32) } |
| 834 | + } |
| 835 | + #[inline] |
| 836 | + pub fn set_unique(&mut self, val: ::std::os::raw::c_int) { |
| 837 | + unsafe { |
| 838 | + let val: u32 = ::std::mem::transmute(val); |
| 839 | + self._bitfield_1.set(1usize, 1u8, val as u64) |
| 840 | + } |
| 841 | + } |
| 842 | + #[inline] |
| 843 | + pub fn exists(&self) -> ::std::os::raw::c_int { |
| 844 | + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u32) } |
| 845 | + } |
| 846 | + #[inline] |
| 847 | + pub fn set_exists(&mut self, val: ::std::os::raw::c_int) { |
| 848 | + unsafe { |
| 849 | + let val: u32 = ::std::mem::transmute(val); |
| 850 | + self._bitfield_1.set(2usize, 1u8, val as u64) |
| 851 | + } |
| 852 | + } |
| 853 | + #[inline] |
| 854 | + pub fn scan(&self) -> ::std::os::raw::c_int { |
| 855 | + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u32) } |
| 856 | + } |
| 857 | + #[inline] |
| 858 | + pub fn set_scan(&mut self, val: ::std::os::raw::c_int) { |
| 859 | + unsafe { |
| 860 | + let val: u32 = ::std::mem::transmute(val); |
| 861 | + self._bitfield_1.set(3usize, 1u8, val as u64) |
| 862 | + } |
| 863 | + } |
| 864 | + #[inline] |
| 865 | + pub fn new_bitfield_1( |
| 866 | + can_be_active: ::std::os::raw::c_int, |
| 867 | + unique: ::std::os::raw::c_int, |
| 868 | + exists: ::std::os::raw::c_int, |
| 869 | + scan: ::std::os::raw::c_int, |
| 870 | + ) -> __BindgenBitfieldUnit<[u8; 1usize], u8> { |
| 871 | + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> = |
| 872 | + Default::default(); |
| 873 | + __bindgen_bitfield_unit.set(0usize, 1u8, { |
| 874 | + let can_be_active: u32 = unsafe { ::std::mem::transmute(can_be_active) }; |
| 875 | + can_be_active as u64 |
| 876 | + }); |
| 877 | + __bindgen_bitfield_unit.set(1usize, 1u8, { |
| 878 | + let unique: u32 = unsafe { ::std::mem::transmute(unique) }; |
| 879 | + unique as u64 |
| 880 | + }); |
| 881 | + __bindgen_bitfield_unit.set(2usize, 1u8, { |
| 882 | + let exists: u32 = unsafe { ::std::mem::transmute(exists) }; |
| 883 | + exists as u64 |
| 884 | + }); |
| 885 | + __bindgen_bitfield_unit.set(3usize, 1u8, { |
| 886 | + let scan: u32 = unsafe { ::std::mem::transmute(scan) }; |
| 887 | + scan as u64 |
| 888 | + }); |
| 889 | + __bindgen_bitfield_unit |
| 890 | + } |
| 891 | +} |
| 892 | +pub type importargs_t = importargs; |
664 | 893 | extern "C" { |
665 | | - pub fn zpool_find_import( |
| 894 | + pub fn zpool_search_import( |
666 | 895 | arg1: *mut libzfs_handle_t, |
667 | | - arg2: ::std::os::raw::c_int, |
668 | | - arg3: *mut *mut ::std::os::raw::c_char, |
| 896 | + arg2: *mut importargs_t, |
669 | 897 | ) -> *mut nvlist_t; |
670 | 898 | } |
671 | 899 | extern "C" { |
|
0 commit comments