smb_fscc/quota.rs
1use binrw::{io::TakeSeekExt, prelude::*};
2use smb_dtyp::SID;
3use smb_dtyp::binrw_util::prelude::*;
4
5/// Query or to set file quota information for a volume.
6///
7/// For queries, an optional buffer of FILE_GET_QUOTA_INFORMATION (section 2.4.41.1) data elements is provided by the client to specify the SIDs for which quota information is requested.
8/// If the FILE_GET_QUOTA_INFORMATION buffer is not specified, information for all quotas is returned.
9/// A buffer of FILE_QUOTA_INFORMATION data elements is returned by the server.
10/// For sets, FILE_QUOTA_INFORMATION data elements are populated and sent by the client,
11/// as specified in [MS-SMB] section 2.2.7.6.1 and [MS-SMB2] section 3.2.4.15.<145>
12///
13/// [MS-FSCC 2.4.41](<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/acdc0738-ba3c-47a1-b11a-72e22d831c57>)
14///
15/// _Note_: This structure is partial: it does not contain the NextEntryOffset field, as it is intended to be used
16/// in a chained list, see [`ChainedItemList<T>`][crate::ChainedItemList].
17#[binrw::binrw]
18#[derive(Debug, PartialEq, Eq)]
19pub struct FileQuotaInformation {
20 #[bw(calc = PosMarker::default())]
21 #[br(temp)]
22 sid_length: PosMarker<u32>,
23 pub change_time: FileTime,
24 pub quota_used: u64,
25 pub quota_threshold: u64,
26 pub quota_limit: u64,
27 #[br(map_stream = |s| s.take_seek(sid_length.value as u64))]
28 #[bw(write_with = PosMarker::write_size, args(&sid_length))]
29 pub sid: SID,
30}
31
32impl FileQuotaInformation {
33 /// Minimum size of this structure in bytes.
34 pub const MIN_SIZE: usize = std::mem::size_of::<u32>()
35 + std::mem::size_of::<FileTime>()
36 + std::mem::size_of::<u64>()
37 + std::mem::size_of::<u64>()
38 + std::mem::size_of::<u64>()
39 + SID::MIN_SIZE;
40}
41
42/// This structure is used to provide the list of SIDs for which quota query information is requested.
43///
44/// [MS-FSCC 2.4.41.1](<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/56adae21-add4-4434-97ec-e40e87739d52>)
45///
46/// _Note_: This structure is partial: it does not contain the NextEntryOffset field, as it is intended to be used
47/// in a chained list, see [`ChainedItemList<T>`][crate::ChainedItemList].
48#[binrw::binrw]
49#[derive(Debug, PartialEq, Eq)]
50pub struct FileGetQuotaInformation {
51 #[bw(calc = PosMarker::default())]
52 #[br(temp)]
53 sid_length: PosMarker<u32>,
54 #[br(map_stream = |s| s.take_seek(sid_length.value as u64))]
55 #[bw(write_with = PosMarker::write_size, args(&sid_length))]
56 pub sid: SID,
57}