pub trait FileSystemInterface {
type FileContext: FileContextKind;
Show 32 associated constants and 32 methods
const GET_VOLUME_INFO_DEFINED: bool = false;
const SET_VOLUME_LABEL_DEFINED: bool = false;
const GET_SECURITY_BY_NAME_DEFINED: bool = false;
const CREATE_DEFINED: bool = false;
const CREATE_EX_DEFINED: bool = false;
const OPEN_DEFINED: bool = false;
const OVERWRITE_DEFINED: bool = false;
const OVERWRITE_EX_DEFINED: bool = false;
const CLEANUP_DEFINED: bool = false;
const CLOSE_DEFINED: bool = false;
const READ_DEFINED: bool = false;
const WRITE_DEFINED: bool = false;
const FLUSH_DEFINED: bool = false;
const GET_FILE_INFO_DEFINED: bool = false;
const SET_BASIC_INFO_DEFINED: bool = false;
const SET_FILE_SIZE_DEFINED: bool = false;
const CAN_DELETE_DEFINED: bool = false;
const RENAME_DEFINED: bool = false;
const GET_SECURITY_DEFINED: bool = false;
const SET_SECURITY_DEFINED: bool = false;
const READ_DIRECTORY_DEFINED: bool = false;
const GET_REPARSE_POINT_DEFINED: bool = false;
const SET_REPARSE_POINT_DEFINED: bool = false;
const DELETE_REPARSE_POINT_DEFINED: bool = false;
const GET_STREAM_INFO_DEFINED: bool = false;
const GET_DIR_INFO_BY_NAME_DEFINED: bool = false;
const CONTROL_DEFINED: bool = false;
const SET_DELETE_DEFINED: bool = false;
const GET_EA_DEFINED: bool = false;
const SET_EA_DEFINED: bool = false;
const DISPATCHER_STOPPED_DEFINED: bool = false;
const RESOLVE_REPARSE_POINTS_DEFINED: bool = false;
// Provided methods
fn get_volume_info(&self) -> Result<VolumeInfo, NTSTATUS> { ... }
fn set_volume_label(
&self,
_volume_label: &U16CStr,
) -> Result<VolumeInfo, NTSTATUS> { ... }
fn get_security_by_name(
&self,
_file_name: &U16CStr,
_find_reparse_point: impl Fn() -> Option<FileAttributes>,
) -> Result<(FileAttributes, PSecurityDescriptor, bool), NTSTATUS> { ... }
fn create(
&self,
_file_name: &U16CStr,
_create_file_info: CreateFileInfo,
_security_descriptor: SecurityDescriptor,
) -> Result<(Self::FileContext, FileInfo), NTSTATUS> { ... }
fn create_ex(
&self,
_file_name: &U16CStr,
_create_file_info: CreateFileInfo,
_security_descriptor: SecurityDescriptor,
_buffer: &[u8],
_extra_buffer_is_reparse_point: bool,
) -> Result<(Self::FileContext, FileInfo), NTSTATUS> { ... }
fn open(
&self,
_file_name: &U16CStr,
_create_options: CreateOptions,
_granted_access: FileAccessRights,
) -> Result<(Self::FileContext, FileInfo), NTSTATUS> { ... }
fn overwrite(
&self,
_file_context: Self::FileContext,
_file_attributes: FileAttributes,
_replace_file_attributes: bool,
_allocation_size: u64,
) -> Result<FileInfo, NTSTATUS> { ... }
fn overwrite_ex(
&self,
_file_context: Self::FileContext,
_file_attributes: FileAttributes,
_replace_file_attributes: bool,
_allocation_size: u64,
_buffer: &[u8],
) -> Result<FileInfo, NTSTATUS> { ... }
fn cleanup(
&self,
_file_context: Self::FileContext,
_file_name: Option<&U16CStr>,
_flags: CleanupFlags,
) { ... }
fn close(&self, _file_context: Self::FileContext) { ... }
fn read(
&self,
_file_context: Self::FileContext,
_buffer: &mut [u8],
_offset: u64,
) -> Result<usize, NTSTATUS> { ... }
fn write(
&self,
_file_context: Self::FileContext,
_buffer: &[u8],
_mode: WriteMode,
) -> Result<(usize, FileInfo), NTSTATUS> { ... }
fn flush(
&self,
_file_context: Self::FileContext,
) -> Result<FileInfo, NTSTATUS> { ... }
fn get_file_info(
&self,
_file_context: Self::FileContext,
) -> Result<FileInfo, NTSTATUS> { ... }
fn set_basic_info(
&self,
_file_context: Self::FileContext,
_file_attributes: FileAttributes,
_creation_time: u64,
_last_access_time: u64,
_last_write_time: u64,
_change_time: u64,
) -> Result<FileInfo, NTSTATUS> { ... }
fn set_file_size(
&self,
_file_context: Self::FileContext,
_new_size: u64,
_set_allocation_size: bool,
) -> Result<FileInfo, NTSTATUS> { ... }
fn can_delete(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
) -> Result<(), NTSTATUS> { ... }
fn rename(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
_new_file_name: &U16CStr,
_replace_if_exists: bool,
) -> Result<(), NTSTATUS> { ... }
fn get_security(
&self,
_file_context: Self::FileContext,
) -> Result<PSecurityDescriptor, NTSTATUS> { ... }
fn set_security(
&self,
_file_context: Self::FileContext,
_security_information: u32,
_modification_descriptor: PSecurityDescriptor,
) -> Result<(), NTSTATUS> { ... }
fn read_directory(
&self,
_file_context: Self::FileContext,
_marker: Option<&U16CStr>,
_add_dir_info: impl FnMut(DirInfo) -> bool,
) -> Result<(), NTSTATUS> { ... }
fn get_reparse_point(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
_buffer: &mut [u8],
) -> Result<usize, NTSTATUS> { ... }
fn set_reparse_point(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
_buffer: &mut [u8],
) -> Result<(), NTSTATUS> { ... }
fn delete_reparse_point(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
_buffer: &mut [u8],
) -> Result<(), NTSTATUS> { ... }
fn get_stream_info(
&self,
_file_context: Self::FileContext,
_buffer: &mut [u8],
) -> Result<usize, NTSTATUS> { ... }
fn get_dir_info_by_name(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
) -> Result<FileInfo, NTSTATUS> { ... }
fn control(
&self,
_file_context: Self::FileContext,
_control_code: u32,
_input_buffer: &[u8],
_output_buffer: &mut [u8],
) -> Result<usize, NTSTATUS> { ... }
fn set_delete(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
_delete_file: bool,
) -> Result<(), NTSTATUS> { ... }
fn get_ea(
&self,
_file_context: Self::FileContext,
_buffer: &[u8],
) -> Result<usize, NTSTATUS> { ... }
fn set_ea(
&self,
_file_context: Self::FileContext,
_buffer: &[u8],
) -> Result<FileInfo, NTSTATUS> { ... }
fn dispatcher_stopped(&self, _normally: bool) { ... }
fn get_reparse_point_by_name(
&self,
_file_name: &U16CStr,
_is_directory: bool,
_buffer: Option<&mut [u8]>,
) -> Result<usize, NTSTATUS> { ... }
}Expand description
High level interface over FSP_FILE_SYSTEM_INTERFACE.
This trait requires to overwrite all WinFSP callbacks you need and it corresponding
xxx_DEFINED associated const boolean.
This is needed to properly build the FSP_FILE_SYSTEM_INTERFACE struct, as
a callback pointer set to NULL (i.e. if xxx_DEFINED=false) leads to a different
behavior that a callback pointer containing a mock implementation (e.g.
returning Err(STATUS_NOT_IMPLEMENTED)).
So the way to work with this trait is to overwrite the method and xxx_DEFINED for
each function pointer you will need in FSP_FILE_SYSTEM_INTERFACE:
struct MyFS;
impl FileSystemInterface for MyFS {
type FileContext: usize;
// `CREATE_DEFINED` not overwritten, hence `FSP_FILE_SYSTEM_INTERFACE.Create == NULL`
const CREATE_EX_DEFINED: bool = true; // i.e. `FSP_FILE_SYSTEM_INTERFACE.CreateEx != NULL`
fn create_ex(
&self,
file_name: &U16CStr,
create_file_info: CreateFileInfo,
security_descriptor: SecurityDescriptor,
buffer: &[u8],
extra_buffer_is_reparse_point: bool,
) -> Result<(Self::FileContext, FileInfo), NTSTATUS> {
...
}
}Notes:
- Associated method and
xxx_DEFINEDconst must be overwritten together, as the method is simply ignored ifxxx_DEFINEDis not set, and settingxxx_DEFINEDwithout overwritting the method means the function pointer relies on the method default implementation that panics whenever used (ah !). - If your are curious about the reason for using a trait here instead of a struct (or
associated const fields with
Option<fn()>type in the trait instead of methods), it all boils down to the fact some methods have animpl Fnfunction pointer as argument, which is only possible in trait method.
Provided Associated Constants§
const GET_VOLUME_INFO_DEFINED: bool = false
const SET_VOLUME_LABEL_DEFINED: bool = false
const GET_SECURITY_BY_NAME_DEFINED: bool = false
const CREATE_DEFINED: bool = false
const CREATE_EX_DEFINED: bool = false
const OPEN_DEFINED: bool = false
const OVERWRITE_DEFINED: bool = false
const OVERWRITE_EX_DEFINED: bool = false
const CLEANUP_DEFINED: bool = false
const CLOSE_DEFINED: bool = false
const READ_DEFINED: bool = false
const WRITE_DEFINED: bool = false
const FLUSH_DEFINED: bool = false
const GET_FILE_INFO_DEFINED: bool = false
const SET_BASIC_INFO_DEFINED: bool = false
const SET_FILE_SIZE_DEFINED: bool = false
const CAN_DELETE_DEFINED: bool = false
const RENAME_DEFINED: bool = false
const GET_SECURITY_DEFINED: bool = false
const SET_SECURITY_DEFINED: bool = false
const READ_DIRECTORY_DEFINED: bool = false
const GET_REPARSE_POINT_DEFINED: bool = false
const SET_REPARSE_POINT_DEFINED: bool = false
const DELETE_REPARSE_POINT_DEFINED: bool = false
const GET_STREAM_INFO_DEFINED: bool = false
const GET_DIR_INFO_BY_NAME_DEFINED: bool = false
const CONTROL_DEFINED: bool = false
const SET_DELETE_DEFINED: bool = false
const GET_EA_DEFINED: bool = false
const SET_EA_DEFINED: bool = false
const DISPATCHER_STOPPED_DEFINED: bool = false
const RESOLVE_REPARSE_POINTS_DEFINED: bool = false
Required Associated Types§
Provided Methods§
Sourcefn get_volume_info(&self) -> Result<VolumeInfo, NTSTATUS>
fn get_volume_info(&self) -> Result<VolumeInfo, NTSTATUS>
Get volume information.
Sourcefn set_volume_label(
&self,
_volume_label: &U16CStr,
) -> Result<VolumeInfo, NTSTATUS>
fn set_volume_label( &self, _volume_label: &U16CStr, ) -> Result<VolumeInfo, NTSTATUS>
Set volume label.
Sourcefn get_security_by_name(
&self,
_file_name: &U16CStr,
_find_reparse_point: impl Fn() -> Option<FileAttributes>,
) -> Result<(FileAttributes, PSecurityDescriptor, bool), NTSTATUS>
fn get_security_by_name( &self, _file_name: &U16CStr, _find_reparse_point: impl Fn() -> Option<FileAttributes>, ) -> Result<(FileAttributes, PSecurityDescriptor, bool), NTSTATUS>
Get file or directory attributes and security descriptor given a file name.
[out]:
- file_attributes
- security descriptor
- reparse (false if
reparse_pointis not supported)
[help]:
- find_reparse_point (optional, can be ignored): Helper to find reparse
points (
get_reparse_point_by_nameshould be implemented). If reparse point is found, return theFileAttributesandreparseshould be set totrue.
Sourcefn create(
&self,
_file_name: &U16CStr,
_create_file_info: CreateFileInfo,
_security_descriptor: SecurityDescriptor,
) -> Result<(Self::FileContext, FileInfo), NTSTATUS>
fn create( &self, _file_name: &U16CStr, _create_file_info: CreateFileInfo, _security_descriptor: SecurityDescriptor, ) -> Result<(Self::FileContext, FileInfo), NTSTATUS>
Create new file or directory.
Note: FileSystemContext::create_ex takes precedence over FileSystemContext::create
Sourcefn create_ex(
&self,
_file_name: &U16CStr,
_create_file_info: CreateFileInfo,
_security_descriptor: SecurityDescriptor,
_buffer: &[u8],
_extra_buffer_is_reparse_point: bool,
) -> Result<(Self::FileContext, FileInfo), NTSTATUS>
fn create_ex( &self, _file_name: &U16CStr, _create_file_info: CreateFileInfo, _security_descriptor: SecurityDescriptor, _buffer: &[u8], _extra_buffer_is_reparse_point: bool, ) -> Result<(Self::FileContext, FileInfo), NTSTATUS>
Create new file or directory.
This function works like create, except that it also accepts an extra buffer
that may contain extended attributes or a reparse point.
Note: FileSystemContext::create_ex takes precedence over FileSystemContext::create
Sourcefn open(
&self,
_file_name: &U16CStr,
_create_options: CreateOptions,
_granted_access: FileAccessRights,
) -> Result<(Self::FileContext, FileInfo), NTSTATUS>
fn open( &self, _file_name: &U16CStr, _create_options: CreateOptions, _granted_access: FileAccessRights, ) -> Result<(Self::FileContext, FileInfo), NTSTATUS>
Open a file or directory.
Sourcefn overwrite(
&self,
_file_context: Self::FileContext,
_file_attributes: FileAttributes,
_replace_file_attributes: bool,
_allocation_size: u64,
) -> Result<FileInfo, NTSTATUS>
fn overwrite( &self, _file_context: Self::FileContext, _file_attributes: FileAttributes, _replace_file_attributes: bool, _allocation_size: u64, ) -> Result<FileInfo, NTSTATUS>
Overwrite a file.
Note: FileSystemContext::overwrite_ex takes precedence over FileSystemContext::overwrite
Sourcefn overwrite_ex(
&self,
_file_context: Self::FileContext,
_file_attributes: FileAttributes,
_replace_file_attributes: bool,
_allocation_size: u64,
_buffer: &[u8],
) -> Result<FileInfo, NTSTATUS>
fn overwrite_ex( &self, _file_context: Self::FileContext, _file_attributes: FileAttributes, _replace_file_attributes: bool, _allocation_size: u64, _buffer: &[u8], ) -> Result<FileInfo, NTSTATUS>
Overwrite a file.
This function works like overwrite, except that it also accepts EA (extended attributes).
Note: FileSystemContext::overwrite_ex takes precedence over FileSystemContext::overwrite
Sourcefn cleanup(
&self,
_file_context: Self::FileContext,
_file_name: Option<&U16CStr>,
_flags: CleanupFlags,
)
fn cleanup( &self, _file_context: Self::FileContext, _file_name: Option<&U16CStr>, _flags: CleanupFlags, )
Cleanup a file.
Sourcefn close(&self, _file_context: Self::FileContext)
fn close(&self, _file_context: Self::FileContext)
Close a file.
Sourcefn read(
&self,
_file_context: Self::FileContext,
_buffer: &mut [u8],
_offset: u64,
) -> Result<usize, NTSTATUS>
fn read( &self, _file_context: Self::FileContext, _buffer: &mut [u8], _offset: u64, ) -> Result<usize, NTSTATUS>
Read a file.
Sourcefn write(
&self,
_file_context: Self::FileContext,
_buffer: &[u8],
_mode: WriteMode,
) -> Result<(usize, FileInfo), NTSTATUS>
fn write( &self, _file_context: Self::FileContext, _buffer: &[u8], _mode: WriteMode, ) -> Result<(usize, FileInfo), NTSTATUS>
Write a file.
Sourcefn flush(&self, _file_context: Self::FileContext) -> Result<FileInfo, NTSTATUS>
fn flush(&self, _file_context: Self::FileContext) -> Result<FileInfo, NTSTATUS>
Flush a file or volume.
Sourcefn get_file_info(
&self,
_file_context: Self::FileContext,
) -> Result<FileInfo, NTSTATUS>
fn get_file_info( &self, _file_context: Self::FileContext, ) -> Result<FileInfo, NTSTATUS>
Get file or directory information.
Sourcefn set_basic_info(
&self,
_file_context: Self::FileContext,
_file_attributes: FileAttributes,
_creation_time: u64,
_last_access_time: u64,
_last_write_time: u64,
_change_time: u64,
) -> Result<FileInfo, NTSTATUS>
fn set_basic_info( &self, _file_context: Self::FileContext, _file_attributes: FileAttributes, _creation_time: u64, _last_access_time: u64, _last_write_time: u64, _change_time: u64, ) -> Result<FileInfo, NTSTATUS>
Set file or directory basic information.
Sourcefn set_file_size(
&self,
_file_context: Self::FileContext,
_new_size: u64,
_set_allocation_size: bool,
) -> Result<FileInfo, NTSTATUS>
fn set_file_size( &self, _file_context: Self::FileContext, _new_size: u64, _set_allocation_size: bool, ) -> Result<FileInfo, NTSTATUS>
Set file/allocation size.
Sourcefn can_delete(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
) -> Result<(), NTSTATUS>
fn can_delete( &self, _file_context: Self::FileContext, _file_name: &U16CStr, ) -> Result<(), NTSTATUS>
Determine whether a file or directory can be deleted.
Note: FileSystemContext::set_delete takes precedence over FileSystemContext::can_delete
Sourcefn rename(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
_new_file_name: &U16CStr,
_replace_if_exists: bool,
) -> Result<(), NTSTATUS>
fn rename( &self, _file_context: Self::FileContext, _file_name: &U16CStr, _new_file_name: &U16CStr, _replace_if_exists: bool, ) -> Result<(), NTSTATUS>
Renames a file or directory.
Sourcefn get_security(
&self,
_file_context: Self::FileContext,
) -> Result<PSecurityDescriptor, NTSTATUS>
fn get_security( &self, _file_context: Self::FileContext, ) -> Result<PSecurityDescriptor, NTSTATUS>
Get file or directory security descriptor.
Sourcefn set_security(
&self,
_file_context: Self::FileContext,
_security_information: u32,
_modification_descriptor: PSecurityDescriptor,
) -> Result<(), NTSTATUS>
fn set_security( &self, _file_context: Self::FileContext, _security_information: u32, _modification_descriptor: PSecurityDescriptor, ) -> Result<(), NTSTATUS>
Set file or directory security descriptor.
Sourcefn read_directory(
&self,
_file_context: Self::FileContext,
_marker: Option<&U16CStr>,
_add_dir_info: impl FnMut(DirInfo) -> bool,
) -> Result<(), NTSTATUS>
fn read_directory( &self, _file_context: Self::FileContext, _marker: Option<&U16CStr>, _add_dir_info: impl FnMut(DirInfo) -> bool, ) -> Result<(), NTSTATUS>
Read a directory.
add_dir_info returns false if there is no more space left to add elements.
Sourcefn get_reparse_point(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
_buffer: &mut [u8],
) -> Result<usize, NTSTATUS>
fn get_reparse_point( &self, _file_context: Self::FileContext, _file_name: &U16CStr, _buffer: &mut [u8], ) -> Result<usize, NTSTATUS>
Get reparse point.
Sourcefn set_reparse_point(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
_buffer: &mut [u8],
) -> Result<(), NTSTATUS>
fn set_reparse_point( &self, _file_context: Self::FileContext, _file_name: &U16CStr, _buffer: &mut [u8], ) -> Result<(), NTSTATUS>
Set reparse point.
Sourcefn delete_reparse_point(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
_buffer: &mut [u8],
) -> Result<(), NTSTATUS>
fn delete_reparse_point( &self, _file_context: Self::FileContext, _file_name: &U16CStr, _buffer: &mut [u8], ) -> Result<(), NTSTATUS>
Delete reparse point.
Sourcefn get_stream_info(
&self,
_file_context: Self::FileContext,
_buffer: &mut [u8],
) -> Result<usize, NTSTATUS>
fn get_stream_info( &self, _file_context: Self::FileContext, _buffer: &mut [u8], ) -> Result<usize, NTSTATUS>
Get named streams information.
Sourcefn get_dir_info_by_name(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
) -> Result<FileInfo, NTSTATUS>
fn get_dir_info_by_name( &self, _file_context: Self::FileContext, _file_name: &U16CStr, ) -> Result<FileInfo, NTSTATUS>
Get directory information for a single file or directory within a parent directory.
Sourcefn control(
&self,
_file_context: Self::FileContext,
_control_code: u32,
_input_buffer: &[u8],
_output_buffer: &mut [u8],
) -> Result<usize, NTSTATUS>
fn control( &self, _file_context: Self::FileContext, _control_code: u32, _input_buffer: &[u8], _output_buffer: &mut [u8], ) -> Result<usize, NTSTATUS>
Process control code.
Sourcefn set_delete(
&self,
_file_context: Self::FileContext,
_file_name: &U16CStr,
_delete_file: bool,
) -> Result<(), NTSTATUS>
fn set_delete( &self, _file_context: Self::FileContext, _file_name: &U16CStr, _delete_file: bool, ) -> Result<(), NTSTATUS>
Set the file delete flag.
Note: FileSystemContext::set_delete takes precedence over FileSystemContext::can_delete
Sourcefn get_ea(
&self,
_file_context: Self::FileContext,
_buffer: &[u8],
) -> Result<usize, NTSTATUS>
fn get_ea( &self, _file_context: Self::FileContext, _buffer: &[u8], ) -> Result<usize, NTSTATUS>
Get extended attributes.
Sourcefn set_ea(
&self,
_file_context: Self::FileContext,
_buffer: &[u8],
) -> Result<FileInfo, NTSTATUS>
fn set_ea( &self, _file_context: Self::FileContext, _buffer: &[u8], ) -> Result<FileInfo, NTSTATUS>
Set extended attributes.
fn dispatcher_stopped(&self, _normally: bool)
Sourcefn get_reparse_point_by_name(
&self,
_file_name: &U16CStr,
_is_directory: bool,
_buffer: Option<&mut [u8]>,
) -> Result<usize, NTSTATUS>
fn get_reparse_point_by_name( &self, _file_name: &U16CStr, _is_directory: bool, _buffer: Option<&mut [u8]>, ) -> Result<usize, NTSTATUS>
Get reparse point given a file name.
This method is used as a callback parameter to FspFileSystemFindReparsePoint &
FspFileSystemResolveReparsePoints helpers to respectively implement
FSP_FILE_SYSTEM_INTERFACE’s GetSecurityByName & ResolveReparsePoints.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.