smb_fscc/
notify.rs

1//! Directory Change Notifications
2//!
3//! [MS-FSCC 2.7](<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/8e8b7296-fb56-42d7-bfec-3fc1f59d5fa0>)
4
5use smb_dtyp::binrw_util::prelude::*;
6
7/// FILE_NOTIFY_INFORMATION - [MS-FSCC 2.7.1](<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/634043d7-7b39-47e9-9e26-bda64685e4c9>)
8///
9/// This structure is similar to the references struct, excluding the NextEntryOffset field.
10///
11/// You must use [`ChainedItemList<FileNotifyInformation>`][crate::ChainedItemList] to properly represent a list of these structures.
12#[binrw::binrw]
13#[derive(Debug, PartialEq, Eq)]
14#[bw(import(has_next: bool))]
15pub struct FileNotifyInformation {
16    pub action: NotifyAction,
17    #[bw(try_calc = file_name.size().try_into())]
18    file_name_length: u32,
19    #[br(args { size: SizedStringSize::Bytes(file_name_length.into())})]
20    pub file_name: SizedWideString,
21}
22
23/// See [`FileNotifyInformation`]
24#[binrw::binrw]
25#[derive(Debug, PartialEq, Eq)]
26#[brw(repr(u32))]
27pub enum NotifyAction {
28    /// The file was renamed, and FileName contains the new name.
29    /// This notification is only sent when the rename operation changes the directory the file resides in.
30    /// The client will also receive a FILE_ACTION_REMOVED notification.
31    /// This notification will not be received if the file is renamed within a directory.
32    Added = 0x1,
33
34    /// The file was renamed, and FileName contains the old name.
35    /// This notification is only sent when the rename operation changes the directory the file resides in.
36    /// The client will also receive a FILE_ACTION_ADDED notification.
37    /// This notification will not be received if the file is renamed within a directory.
38    Removed = 0x2,
39
40    /// The file was modified. This can be a change to the data or attributes of the file.
41    Modified = 0x3,
42
43    /// The file was renamed, and FileName contains the old name.
44    /// This notification is only sent when the rename operation does not change the directory the file resides in.
45    /// The client will also receive a FILE_ACTION_RENAMED_NEW_NAME notification. This notification will not be received if the file is renamed to a different directory.
46    RenamedOldName = 0x4,
47
48    /// The file was renamed, and FileName contains the new name.
49    /// This notification is only sent when the rename operation does not change the directory the file resides in.
50    /// The client will also receive a FILE_ACTION_RENAMED_OLD_NAME notification. This notification will not be received if the file is renamed to a different directory.
51    RenamedNewName = 0x5,
52
53    /// The file was added to a named stream.
54    AddedStream = 0x6,
55
56    /// The file was removed from the named stream.
57    RemovedStream = 0x7,
58
59    /// The file was modified. This can be a change to the data or attributes of the file.
60    ModifiedStream = 0x8,
61
62    /// An object ID was removed because the file the object ID referred to was deleted.
63    ///
64    /// This notification is only sent when the directory being monitored is the special directory "\$Extend\$ObjId:$O:$INDEX_ALLOCATION".
65    RemovedByDelete = 0x9,
66
67    /// An attempt to tunnel object ID information to a file being created or renamed failed because the object ID is in use by another file on the same volume.
68    ///
69    /// This notification is only sent when the directory being monitored is the special directory "\$Extend\$ObjId:$O:$INDEX_ALLOCATION".
70    IdNotTunnelled = 0xa,
71
72    /// An attempt to tunnel object ID information to a file being renamed failed because the file already has an object ID.
73    ///
74    /// This notification is only sent when the directory being monitored is the special directory "\$Extend\$ObjId:$O:$INDEX_ALLOCATION".
75    TunnelledIdCollision = 0xb,
76}
77
78// Unit Tests for those structures exist in the `smb-msg` crate (for `ChangeNotifyResponse`)