smb_fscc/
access_masks.rs

1//! Access masks definitions.
2
3use modular_bitfield::prelude::*;
4use smb_dtyp::access_mask;
5
6access_mask! {
7    /// File Access Mask
8    ///
9    /// This is actually taken from the SMB2 protocol, but the bits are the same as
10    /// the ones used in FSCC for files.
11    /// In the SMB2 protocol, it also applied to pipes and printers.
12    ///
13    /// See [MS-SMB2 2.2.13.1.1](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/77b36d0f-6016-458a-a7a0-0f4a72ae1534) - File_Pipe_Printer_Access_Mask
14pub struct FileAccessMask {
15    /// The right to read data from the file.
16    file_read_data: bool,
17    /// The right to write data into the file beyond the end of the file.
18    file_write_data: bool,
19    /// The right to append data into the file.
20    file_append_data: bool,
21    /// The right to read the extended attributes of the file.
22    file_read_ea: bool,
23
24    /// The right to write or change the extended attributes to the file.
25    file_write_ea: bool,
26    /// The right to execute the file.
27    file_execute: bool,
28    /// The right to delete entries within a directory.
29    file_delete_child: bool,
30    /// The right to read the attributes of the file.
31    file_read_attributes: bool,
32
33    /// The right to change the attributes of the file.
34    file_write_attributes: bool,
35    #[skip]
36    __: B7,
37}}
38
39access_mask! {
40    /// Directory Access Mask
41    ///
42    /// This is actually taken from the SMB2 protocol, but the bits are the same as
43    /// the ones used in FSCC for directories.
44    ///
45    /// See [MS-SMB2 2.2.13.1.2](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/0a5934b1-80f1-4da0-b1bf-5e021c309b71) - Directory_Access_Mask
46    pub struct DirAccessMask {
47        /// The right to enumerate the contents of the directory.
48        list_directory: bool,
49        /// The right to create a file under the directory.
50        add_file: bool,
51        /// The right to add a sub-directory under the directory.
52        add_subdirectory: bool,
53        /// The right to read the extended attributes of the directory.
54        read_ea: bool,
55
56        /// The right to write or change the extended attributes of the directory.
57        write_ea: bool,
58        /// The right to traverse this directory if the server enforces traversal checking.
59        traverse: bool,
60        /// The right to delete the files and directories within this directory.
61        delete_child: bool,
62        /// The right to read the attributes of the directory.
63        read_attributes: bool,
64
65        /// The right to change the attributes of the directory.
66        write_attributes: bool,
67        #[skip]
68        __: B7,
69    }
70}
71
72impl From<FileAccessMask> for DirAccessMask {
73    fn from(mask: FileAccessMask) -> Self {
74        // The bits are the same, just the names are different.
75        Self::from_bytes(mask.into_bytes())
76    }
77}
78
79impl From<DirAccessMask> for FileAccessMask {
80    fn from(val: DirAccessMask) -> Self {
81        // The bits are the same, just the names are different.
82        FileAccessMask::from_bytes(val.into_bytes())
83    }
84}