Skip to content

Commit

Permalink
Add FileSystemContext::SET_DELETE_DEFINED flag to handle SetDelete vs…
Browse files Browse the repository at this point in the history
… CanDelete priority
  • Loading branch information
touilleMan committed Mar 17, 2024
1 parent a7f5146 commit bf22fcb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions examples/memfs/src/main.rs
Expand Up @@ -250,6 +250,8 @@ impl MemFs {
impl FileSystemContext for MemFs {
type FileContext = Arc<Mutex<Obj>>;

const SET_DELETE_DEFINED: bool = true;

fn get_volume_info(&self) -> Result<VolumeInfo, NTSTATUS> {
debug!("get_volume_info()");

Expand Down
12 changes: 10 additions & 2 deletions winfsp_wrs/src/callback.rs
Expand Up @@ -80,6 +80,10 @@ impl FileContextKind for usize {
pub trait FileSystemContext {
type FileContext: FileContextKind;

/// `SetDelete` takes precedence over `CanDelete` if both are defined in `FSP_FILE_SYSTEM_INTERFACE`.
/// If this boolean is not set, `FSP_FILE_SYSTEM_INTERFACE`'s `SetDelete` function will not be set.
const SET_DELETE_DEFINED: bool = false;

/// Get volume information.
fn get_volume_info(&self) -> Result<VolumeInfo, NTSTATUS>;

Expand Down Expand Up @@ -1392,7 +1396,7 @@ impl Interface {
}

pub(crate) fn interface<Ctx: FileSystemContext>() -> FSP_FILE_SYSTEM_INTERFACE {
FSP_FILE_SYSTEM_INTERFACE {
let mut fsp_interface = FSP_FILE_SYSTEM_INTERFACE {
CanDelete: Some(Self::can_delete_ext::<Ctx>),
Cleanup: Some(Self::cleanup_ext::<Ctx>),
Close: Some(Self::close_ext::<Ctx>),
Expand All @@ -1416,14 +1420,18 @@ impl Interface {
Rename: Some(Self::rename_ext::<Ctx>),
ResolveReparsePoints: Some(Self::resolve_reparse_points_ext::<Ctx>),
SetBasicInfo: Some(Self::set_basic_info_ext::<Ctx>),
SetDelete: Some(Self::set_delete_ext::<Ctx>),
SetDelete: None,
SetEa: Some(Self::set_ea_ext::<Ctx>),
SetFileSize: Some(Self::set_file_size_ext::<Ctx>),
SetReparsePoint: Some(Self::set_reparse_point_ext::<Ctx>),
SetSecurity: Some(Self::set_security_ext::<Ctx>),
SetVolumeLabelW: Some(Self::set_volume_label_w_ext::<Ctx>),
Write: Some(Self::write_ext::<Ctx>),
..Default::default()
};
if Ctx::SET_DELETE_DEFINED {
fsp_interface.SetDelete = Some(Self::set_delete_ext::<Ctx>);
}
fsp_interface
}
}

0 comments on commit bf22fcb

Please sign in to comment.