Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing pub structs exposed in lib.rs #30

Merged
merged 5 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions examples/memfs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use std::{
};
use winfsp_wrs::{
filetime_now, u16cstr, u16str, CleanupFlags, CreateFileInfo, CreateOptions, DirInfo,
FileAccessRights, FileAttributes, FileInfo, FileSystem, FileSystemContext, PSecurityDescriptor,
Params, SecurityDescriptor, U16CStr, U16CString, U16Str, VolumeInfo, VolumeParams, WriteMode,
NTSTATUS, STATUS_ACCESS_DENIED, STATUS_DIRECTORY_NOT_EMPTY, STATUS_END_OF_FILE,
STATUS_MEDIA_WRITE_PROTECTED, STATUS_NOT_A_DIRECTORY, STATUS_OBJECT_NAME_COLLISION,
STATUS_OBJECT_NAME_NOT_FOUND,
FileAccessRights, FileAttributes, FileInfo, FileSystem, FileSystemInterface,
PSecurityDescriptor, Params, SecurityDescriptor, U16CStr, U16CString, U16Str, VolumeInfo,
VolumeParams, WriteMode, NTSTATUS, STATUS_ACCESS_DENIED, STATUS_DIRECTORY_NOT_EMPTY,
STATUS_END_OF_FILE, STATUS_MEDIA_WRITE_PROTECTED, STATUS_NOT_A_DIRECTORY,
STATUS_OBJECT_NAME_COLLISION, STATUS_OBJECT_NAME_NOT_FOUND,
};

macro_rules! debug {
Expand Down Expand Up @@ -246,17 +246,17 @@ impl MemFs {
}
}

impl FileSystemContext for MemFs {
impl FileSystemInterface for MemFs {
type FileContext = Arc<Mutex<Obj>>;

const SET_DELETE_DEFINED: bool = true;

const GET_VOLUME_INFO_DEFINED: bool = true;
fn get_volume_info(&self) -> Result<VolumeInfo, NTSTATUS> {
debug!("get_volume_info()");

Ok(self.volume_info.lock().unwrap().clone())
}

const SET_VOLUME_LABEL_DEFINED: bool = true;
fn set_volume_label(&self, volume_label: &U16CStr) -> Result<VolumeInfo, NTSTATUS> {
debug!("set_volume_label(volume_label: {:?})", volume_label);

Expand All @@ -269,6 +269,7 @@ impl FileSystemContext for MemFs {
Ok(guard.clone())
}

const GET_SECURITY_BY_NAME_DEFINED: bool = true;
fn get_security_by_name(
&self,
file_name: &U16CStr,
Expand Down Expand Up @@ -298,6 +299,7 @@ impl FileSystemContext for MemFs {
}
}

const CREATE_EX_DEFINED: bool = true;
fn create_ex(
&self,
file_name: &U16CStr,
Expand Down Expand Up @@ -349,6 +351,7 @@ impl FileSystemContext for MemFs {
Ok((file_context, file_info))
}

const OPEN_DEFINED: bool = true;
fn open(
&self,
file_name: &U16CStr,
Expand All @@ -372,6 +375,7 @@ impl FileSystemContext for MemFs {
}
}

const OVERWRITE_EX_DEFINED: bool = true;
fn overwrite_ex(
&self,
file_context: Self::FileContext,
Expand Down Expand Up @@ -416,6 +420,7 @@ impl FileSystemContext for MemFs {
self.get_file_info_from_obj(&fc)
}

const CLEANUP_DEFINED: bool = true;
fn cleanup(
&self,
file_context: Self::FileContext,
Expand Down Expand Up @@ -479,6 +484,7 @@ impl FileSystemContext for MemFs {
}
}

const READ_DEFINED: bool = true;
fn read(
&self,
file_context: Self::FileContext,
Expand All @@ -505,6 +511,7 @@ impl FileSystemContext for MemFs {
}
}

const WRITE_DEFINED: bool = true;
fn write(
&self,
file_context: Self::FileContext,
Expand Down Expand Up @@ -539,13 +546,15 @@ impl FileSystemContext for MemFs {
Ok((written, self.get_file_info_from_obj(&fc)?))
}

const FLUSH_DEFINED: bool = true;
fn flush(&self, file_context: Self::FileContext) -> Result<FileInfo, NTSTATUS> {
let fc = file_context.lock().unwrap();
debug!("[WinFSP] flush(file_context: {:?})", fc);

self.get_file_info_from_obj(&fc)
}

const GET_FILE_INFO_DEFINED: bool = true;
fn get_file_info(&self, file_context: Self::FileContext) -> Result<FileInfo, NTSTATUS> {
let fc = file_context.lock().unwrap();
debug!("[WinFSP] get_file_info(file_context: {:?})", fc);
Expand All @@ -556,6 +565,7 @@ impl FileSystemContext for MemFs {
}
}

const SET_BASIC_INFO_DEFINED: bool = true;
fn set_basic_info(
&self,
file_context: Self::FileContext,
Expand Down Expand Up @@ -615,6 +625,7 @@ impl FileSystemContext for MemFs {
self.get_file_info_from_obj(&fc)
}

const SET_FILE_SIZE_DEFINED: bool = true;
fn set_file_size(
&self,
file_context: Self::FileContext,
Expand Down Expand Up @@ -647,6 +658,7 @@ impl FileSystemContext for MemFs {
self.get_file_info_from_obj(&fc)
}

const RENAME_DEFINED: bool = true;
fn rename(
&self,
file_context: Self::FileContext,
Expand Down Expand Up @@ -699,6 +711,7 @@ impl FileSystemContext for MemFs {
Ok(())
}

const GET_SECURITY_DEFINED: bool = true;
fn get_security(
&self,
file_context: Self::FileContext,
Expand All @@ -712,6 +725,7 @@ impl FileSystemContext for MemFs {
}
}

const SET_SECURITY_DEFINED: bool = true;
fn set_security(
&self,
file_context: Self::FileContext,
Expand Down Expand Up @@ -743,6 +757,7 @@ impl FileSystemContext for MemFs {
Ok(())
}

const READ_DIRECTORY_DEFINED: bool = true;
fn read_directory(
&self,
file_context: Self::FileContext,
Expand Down Expand Up @@ -808,6 +823,7 @@ impl FileSystemContext for MemFs {
}
}

const SET_DELETE_DEFINED: bool = true;
fn set_delete(
&self,
file_context: Self::FileContext,
Expand Down
9 changes: 7 additions & 2 deletions examples/minimal/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use winfsp_wrs::{
filetime_now, u16cstr, u16str, CreateOptions, DirInfo, FileAccessRights, FileAttributes,
FileInfo, FileSystem, FileSystemContext, PSecurityDescriptor, Params, SecurityDescriptor,
FileInfo, FileSystem, FileSystemInterface, PSecurityDescriptor, Params, SecurityDescriptor,
U16CStr, U16Str, VolumeInfo, VolumeParams, NTSTATUS,
};

Expand Down Expand Up @@ -48,9 +48,10 @@ impl MemFs {
}
}

impl FileSystemContext for MemFs {
impl FileSystemInterface for MemFs {
type FileContext = Arc<Context>;

const GET_SECURITY_BY_NAME_DEFINED: bool = true;
fn get_security_by_name(
&self,
_file_name: &U16CStr,
Expand All @@ -63,6 +64,7 @@ impl FileSystemContext for MemFs {
))
}

const OPEN_DEFINED: bool = true;
fn open(
&self,
_file_name: &U16CStr,
Expand All @@ -74,14 +76,17 @@ impl FileSystemContext for MemFs {
Ok((file_context, file_info))
}

const GET_FILE_INFO_DEFINED: bool = true;
fn get_file_info(&self, _file_context: Self::FileContext) -> Result<FileInfo, NTSTATUS> {
Ok(self.file_context.info)
}

const GET_VOLUME_INFO_DEFINED: bool = true;
fn get_volume_info(&self) -> Result<VolumeInfo, NTSTATUS> {
Ok(self.volume_info.clone())
}

const READ_DIRECTORY_DEFINED: bool = true;
fn read_directory(
&self,
_file_context: Self::FileContext,
Expand Down
Loading
Loading