1use crate::file_info_classes;
2use binrw::prelude::*;
3use modular_bitfield::prelude::*;
4use smb_dtyp::{Guid, binrw_util::prelude::*};
5
6file_info_classes! {
7 pub QueryFileSystemInfo {
8 pub FsAttribute = 5,
9 pub FsControl = 6,
10 pub FsDevice = 4,
11 pub FsFullSize = 7,
12 pub FsObjectId = 8,
13 pub FsSectorSize = 11,
14 pub FsSize = 3,
15 pub FsVolume = 1,
16 }, Read
17}
18
19file_info_classes! {
20 pub SetFileSystemInfo {
21 pub FsControl = 6,
22 pub FsObjectId = 8,
23 }, Write
24}
25
26#[binrw::binrw]
27#[derive(Debug, PartialEq, Eq)]
28pub struct FileFsAttributeInformation {
29 pub attributes: FileSystemAttributes,
30 pub maximum_component_name_length: u32,
31 pub file_system_name_length: u32,
32 #[br(args(file_system_name_length as u64))]
33 pub file_system_name: SizedWideString,
34}
35
36#[bitfield]
37#[derive(BinWrite, BinRead, Debug, Default, Clone, Copy, PartialEq, Eq)]
38#[bw(map = |&x| Self::into_bytes(x))]
39#[br(map = Self::from_bytes)]
40pub struct FileSystemAttributes {
41 pub case_sensitive_search: bool,
42 pub case_preserved_names: bool,
43 pub unicode_on_disk: bool,
44 pub persistent_acls: bool,
45 pub file_compression: bool,
46 pub volume_quotas: bool,
47 pub supports_sparse_files: bool,
48 pub supports_reparse_points: bool,
49 pub supports_remote_storage: bool,
50 #[skip]
51 __: B6,
52 pub volume_is_compressed: bool,
53 pub supports_object_ids: bool,
54 pub supports_encryption: bool,
55 pub named_streams: bool,
56 pub read_only_volume: bool,
57 pub sequential_write_once: bool,
58 pub supports_transactions: bool,
59 pub supports_hard_links: bool,
60 pub supports_extended_attributes: bool,
61 pub supports_open_by_file_id: bool,
62 pub supports_usn_journal: bool,
63 pub support_integrity_streams: bool,
64 pub supports_block_refcounting: bool,
65 pub supports_sparse_vdl: bool,
66 #[skip]
67 __: B3,
68}
69
70#[binrw::binrw]
71#[derive(Debug, PartialEq, Eq)]
72pub struct FileFsControlInformation {
73 pub free_space_start_filtering: u64,
74 pub free_space_threshold: u64,
75 pub free_space_stop_filtering: u64,
76 pub default_quota_threshold: u64,
77 pub default_quota_limit: u64,
78 pub file_system_control_flags: FileSystemControlFlags,
79}
80
81#[binrw::binrw]
82#[derive(Debug, PartialEq, Eq)]
83pub struct FileFsDeviceInformation {
84 pub device_type: FsDeviceType,
85 pub characteristics: FsDeviceCharacteristics,
86}
87
88#[binrw::binrw]
89#[derive(Debug, PartialEq, Eq, Clone, Copy)]
90#[brw(repr(u32))]
91pub enum FsDeviceType {
92 CdRom = 2,
93 Disk = 7,
94}
95
96#[bitfield]
97#[derive(BinWrite, BinRead, Debug, Default, Clone, Copy, PartialEq, Eq)]
98#[bw(map = |&x| Self::into_bytes(x))]
99#[br(map = Self::from_bytes)]
100pub struct FsDeviceCharacteristics {
101 pub removable_media: bool,
102 pub read_only: bool,
103 pub floppy_diskette: bool,
104 pub write_once_media: bool,
105
106 pub remote: bool,
107 pub device_is_mounted: bool,
108 pub virtual_volume: bool,
109 #[skip]
110 __: bool,
111
112 pub secure_open: bool,
113 #[skip]
114 __: B3,
115
116 pub ts: bool,
117 pub webda: bool,
118 #[skip]
119 __: B3,
120
121 pub allow_appcontainer_traversal: bool,
122 pub portable: bool,
123 #[skip]
124 __: B13,
125}
126
127#[bitfield]
128#[derive(BinWrite, BinRead, Debug, Default, Clone, Copy, PartialEq, Eq)]
129#[bw(map = |&x| Self::into_bytes(x))]
130#[br(map = Self::from_bytes)]
131pub struct FileSystemControlFlags {
132 pub quota_track: bool,
133 pub quota_enforce: bool,
134 pub content_indexing_disabled: bool,
135 #[skip]
136 __: bool,
137
138 pub log_quota_threshold: bool,
139 pub log_quota_limit: bool,
140 pub log_volume_threshold: bool,
141 pub log_volume_limit: bool,
142
143 pub quotas_incomplete: bool,
144 pub quotas_rebuilding: bool,
145 #[skip]
146 __: B22,
147}
148
149#[binrw::binrw]
150#[derive(Debug, PartialEq, Eq)]
151pub struct FileFsFullSizeInformation {
152 pub total_allocation_units: u64,
153 pub caller_available_allocation_units: u64,
154 pub actual_available_allocation_units: u64,
155 pub sectors_per_allocation_unit: u32,
156 pub bytes_per_sector: u32,
157}
158
159#[binrw::binrw]
160#[derive(Debug, PartialEq, Eq)]
161pub struct FileFsObjectIdInformation {
162 pub object_id: Guid,
163 pub extended_info: [u8; 48],
164}
165
166#[binrw::binrw]
167#[derive(Debug, PartialEq, Eq)]
168pub struct FileFsSectorSizeInformation {
169 pub logical_bytes_per_sector: u32,
170 pub physical_bytes_per_sector: u32,
171 pub physical_bytes_per_sector_for_performance: u32,
172 pub effective_physical_bytes_per_sector_for_atomicity: u32,
173 pub flags: SectorSizeInfoFlags,
174 pub byte_offset_for_sector_alignment: u32,
175 pub byte_offset_for_partition_alignment: u32,
176}
177
178#[bitfield]
179#[derive(BinWrite, BinRead, Debug, Default, Clone, Copy, PartialEq, Eq)]
180#[bw(map = |&x| Self::into_bytes(x))]
181#[br(map = Self::from_bytes)]
182pub struct SectorSizeInfoFlags {
183 pub aligned_device: bool,
184 pub partition_aligned_on_device: bool,
185 pub no_seek_penalty: bool,
186 pub trim_enabled: bool,
187 #[skip]
188 __: B28,
189}
190
191#[binrw::binrw]
192#[derive(Debug, PartialEq, Eq)]
193pub struct FileFsSizeInformation {
194 pub total_allocation_units: u64,
195 pub available_allocation_units: u64,
196 pub sectors_per_allocation_unit: u32,
197 pub bytes_per_sector: u32,
198}
199
200#[binrw::binrw]
201#[derive(Debug, PartialEq, Eq)]
202pub struct FileFsVolumeInformation {
203 pub volume_creation_time: FileTime,
204 pub volume_serial_number: u32,
205 pub volume_label_length: u32,
206 pub supports_objects: Boolean,
207 #[bw(calc = 0)]
208 #[br(assert(reserved == 0))]
209 reserved: u8,
210 #[br(args(volume_label_length as u64))]
211 pub volume_label: SizedWideString,
212}