smb_fscc/
common_info.rs

1use binrw::{NullString, prelude::*};
2use modular_bitfield::prelude::*;
3
4use smb_dtyp::binrw_util::prelude::{FileTime, SizedWideString};
5
6use crate::{ChainedItemList, FileAttributes};
7
8#[binrw::binrw]
9#[derive(Debug, PartialEq, Eq)]
10pub struct FileBasicInformation {
11    pub creation_time: FileTime,
12    pub last_access_time: FileTime,
13    pub last_write_time: FileTime,
14    pub change_time: FileTime,
15    pub file_attributes: FileAttributes,
16    #[bw(calc = 0)]
17    #[br(assert(_reserved == 0))]
18    _reserved: u32,
19}
20
21#[binrw::binrw]
22#[derive(Debug, PartialEq, Eq)]
23pub struct FileFullEaInformationInner {
24    pub flags: u8,
25    #[bw(try_calc = ea_name.len().try_into())]
26    ea_name_length: u8,
27    #[bw(calc = match ea_value {
28        Some(v) => v.len() as u16,
29        None => 0
30    })]
31    ea_value_length: u16,
32    #[br(assert(ea_name.len() == ea_name_length as usize))]
33    pub ea_name: NullString,
34    #[br(if(ea_value_length > 0))]
35    #[br(count = ea_value_length)]
36    pub ea_value: Option<Vec<u8>>,
37}
38
39pub type FileFullEaInformation = ChainedItemList<FileFullEaInformationInner>;
40
41#[bitfield]
42#[derive(BinWrite, BinRead, Debug, Default, Clone, Copy, PartialEq, Eq)]
43#[bw(map = |&x| Self::into_bytes(x))]
44#[br(map = Self::from_bytes)]
45pub struct FileModeInformation {
46    #[skip]
47    __: bool,
48    pub write_through: bool,
49    pub sequential_access: bool,
50    pub no_intermediate_buffering: bool,
51
52    pub syncronous_io_alert: bool,
53    pub syncronous_io_non_alert: bool,
54    #[skip]
55    __: B6,
56
57    pub delete_on_close: bool,
58    #[skip]
59    __: B19,
60}
61
62#[binrw::binrw]
63#[derive(Debug, PartialEq, Eq)]
64pub struct FilePipeInformation {
65    pub read_mode: PipeReadMode,
66    pub completion_mode: PipeCompletionMode,
67}
68
69#[binrw::binrw]
70#[derive(Debug, PartialEq, Eq)]
71#[brw(repr(u32))]
72pub enum PipeReadMode {
73    Stream = 0,
74    Message = 1,
75}
76
77#[binrw::binrw]
78#[derive(Debug, PartialEq, Eq)]
79#[brw(repr(u32))]
80pub enum PipeCompletionMode {
81    Queue = 0,
82    Complete = 1,
83}
84
85#[binrw::binrw]
86#[derive(Debug, PartialEq, Eq)]
87pub struct FilePositionInformation {
88    pub current_byte_offset: u64,
89}
90
91#[binrw::binrw]
92#[derive(Debug, PartialEq, Eq)]
93pub struct FileNameInformation {
94    #[bw(try_calc = file_name.size().try_into())]
95    file_name_length: u32,
96    #[br(args(file_name_length as u64))]
97    pub file_name: SizedWideString,
98}
99
100/// [MS-FSCC 2.1.2.1](<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/c8e77b37-3909-4fe6-a4ea-2b9d423b1ee4>):
101/// Each reparse point has a reparse tag.
102/// The reparse tag uniquely identifies the owner of that reparse point.
103/// The owner is the implementer of the file system filter driver associated with a reparse tag.
104#[binrw::binrw]
105#[derive(Debug, PartialEq, Eq)]
106#[repr(u32)]
107#[brw(repr(u32))]
108pub enum ReparseTag {
109    /// Reserved reparse tag value.
110    ReservedZero = 0x00000000,
111
112    /// Reserved reparse tag value.
113    ReservedOne = 0x00000001,
114
115    /// Reserved reparse tag value.
116    ReservedTwo = 0x00000002,
117
118    /// Used for mount point support, specified in section 2.1.2.5.
119    MountPoint = 0xA0000003,
120
121    /// Obsolete. Used by legacy Hierarchical Storage Manager Product.
122    HSM = 0xC0000004,
123
124    /// Home server drive extender.<3>
125    DriveExtender = 0x80000005,
126
127    /// Obsolete. Used by legacy Hierarchical Storage Manager Product.
128    HSM2 = 0x80000006,
129
130    /// Used by single-instance storage (SIS) filter driver. Server-side interpretation only, not meaningful over the wire.
131    SIS = 0x80000007,
132
133    /// Used by the WIM Mount filter. Server-side interpretation only, not meaningful over the wire.
134    WIM = 0x80000008,
135
136    /// Obsolete. Used by Clustered Shared Volumes (CSV) version 1 in Windows Server 2008 R2 operating system. Server-side interpretation only, not meaningful over the wire.
137    CSV = 0x80000009,
138
139    /// Used by the DFS filter. The DFS is described in the Distributed File System (DFS): Referral Protocol Specification [MS-DFSC]. Server-side interpretation only, not meaningful over the wire.
140    DFS = 0x8000000A,
141
142    /// Used by filter manager test harness.<4>
143    FilterManager = 0x8000000B,
144
145    /// Used for symbolic link support. See section 2.1.2.4.
146    Symlink = 0xA000000C,
147
148    /// Used by Microsoft Internet Information Services (IIS) caching. Server-side interpretation only, not meaningful over the wire.
149    IISCache = 0xA0000010,
150
151    /// Used by the DFS filter. The DFS is described in [MS-DFSC]. Server-side interpretation only, not meaningful over the wire.
152    DFSR = 0x80000012,
153
154    /// Used by the Data Deduplication (Dedup) filter. Server-side interpretation only, not meaningful over the wire.
155    Dedup = 0x80000013,
156
157    /// Not used.
158    Appxstrm = 0xC0000014,
159
160    /// Used by the Network File System (NFS) component. Server-side interpretation only, not meaningful over the wire.
161    NFS = 0x80000014,
162
163    /// Obsolete. Used by Windows Shell for legacy placeholder files in Windows 8.1. Server-side interpretation only, not meaningful over the wire.
164    FilePlaceholder = 0x80000015,
165
166    /// Used by the Dynamic File filter. Server-side interpretation only, not meaningful over the wire.
167    DFM = 0x80000016,
168
169    /// Used by the Windows Overlay filter, for either WIMBoot or single-file compression. Server-side interpretation only, not meaningful over the wire.
170    WOF = 0x80000017,
171
172    /// Used by the Windows Container Isolation filter. Server-side interpretation only, not meaningful over the wire.
173    WCI = 0x80000018,
174
175    /// Used by the Windows Container Isolation filter. Server-side interpretation only, not meaningful over the wire.
176    Wci1 = 0x90001018,
177
178    /// Used by NPFS to indicate a named pipe symbolic link from a server silo into the host silo. Server-side interpretation only, not meaningful over the wire.
179    GlobalReparse = 0xA0000019,
180
181    /// Used by the Cloud Files filter, for files managed by a sync engine such as Microsoft OneDrive. Server-side interpretation only, not meaningful over the wire.
182    Cloud = 0x9000001A,
183
184    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
185    Cloud1 = 0x9000101A,
186
187    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
188    Cloud2 = 0x9000201A,
189
190    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
191    Cloud3 = 0x9000301A,
192
193    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
194    Cloud4 = 0x9000401A,
195
196    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
197    Cloud5 = 0x9000501A,
198
199    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
200    Cloud6 = 0x9000601A,
201
202    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
203    Cloud7 = 0x9000701A,
204
205    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
206    Cloud8 = 0x9000801A,
207
208    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
209    Cloud9 = 0x9000901A,
210
211    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
212    CloudA = 0x9000A01A,
213
214    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
215    CloudB = 0x9000B01A,
216
217    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
218    CloudC = 0x9000C01A,
219
220    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
221    CloudD = 0x9000D01A,
222
223    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
224    CloudE = 0x9000E01A,
225
226    /// Used by the Cloud Files filter, for files managed by a sync engine such as OneDrive. Server-side interpretation only, not meaningful over the wire.
227    CloudF = 0x9000F01A,
228
229    /// Used by Universal Windows Platform (UWP) packages to encode information that allows the application to be launched by CreateProcess. Server-side interpretation only, not meaningful over the wire.
230    Appexeclink = 0x8000001B,
231
232    /// Used by the Windows Projected File System filter, for files managed by a user mode provider such as VFS for Git. Server-side interpretation only, not meaningful over the wire.
233    Projfs = 0x9000001C,
234
235    /// Used by the Windows Subsystem for Linux (WSL) to represent a UNIX symbolic link. Server-side interpretation only, not meaningful over the wire.
236    LxSymlink = 0xA000001D,
237
238    /// Used by the Azure File Sync (AFS) filter. Server-side interpretation only, not meaningful over the wire.
239    StorageSync = 0x8000001E,
240
241    /// Used by the Azure File Sync (AFS) filter for folder. Server-side interpretation only, not meaningful over the wire.
242    StorageSyncFolder = 0x90000027,
243
244    /// Used by the Windows Container Isolation filter. Server-side interpretation only, not meaningful over the wire.
245    WciTombstone = 0xA000001F,
246
247    /// Used by the Windows Container Isolation filter. Server-side interpretation only, not meaningful over the wire.
248    Unhandled = 0x80000020,
249
250    /// Not used.
251    Onedrive = 0x80000021,
252
253    /// Used by the Windows Projected File System filter, for files managed by a user mode provider such as VFS for Git. Server-side interpretation only, not meaningful over the wire.
254    ProjfsTombstone = 0xA0000022,
255
256    /// Used by the Windows Subsystem for Linux (WSL) to represent a UNIX domain socket. Server-side interpretation only, not meaningful over the wire.
257    AfUnix = 0x80000023,
258
259    /// Used by the Windows Subsystem for Linux (WSL) to represent a UNIX FIFO (named pipe). Server-side interpretation only, not meaningful over the wire.
260    LxFifo = 0x80000024,
261
262    /// Used by the Windows Subsystem for Linux (WSL) to represent a UNIX character special file. Server-side interpretation only, not meaningful over the wire.
263    LxChr = 0x80000025,
264
265    /// Used by the Windows Subsystem for Linux (WSL) to represent a UNIX block special file. Server-side interpretation only, not meaningful over the wire.
266    LxBlk = 0x80000026,
267
268    /// Used by the Windows Container Isolation filter. Server-side interpretation only, not meaningful over the wire.
269    WciLink = 0xA0000027,
270
271    /// Used by the Windows Container Isolation filter. Server-side interpretation only, not meaningful over the wire.
272    WciLink1 = 0xA0001027,
273}