初步实现
This commit is contained in:
1 parent
aace751d01
commit
6e60886fd3
8 files changed
+451
-120
No files matched your search
@@ -1,2 +1,3 @@
|
|||||||
.idea
|
.idea
|
||||||
cmake-build-debug
|
cmake-build-debug
|
||||||
|
build
|
||||||
@@ -56,6 +56,8 @@ add_executable(seadisk src/main.cpp
|
|||||||
|
|
||||||
target_compile_definitions(seadisk PRIVATE
|
target_compile_definitions(seadisk PRIVATE
|
||||||
NOMINMAX
|
NOMINMAX
|
||||||
|
UNICODE
|
||||||
|
_UNICODE
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(seadisk PRIVATE
|
target_include_directories(seadisk PRIVATE
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
namespace seafile::fs
|
namespace seafile::fs
|
||||||
{
|
{
|
||||||
struct FileContext final
|
struct SeaFileContext final
|
||||||
{
|
{
|
||||||
std::string repo_id;
|
std::string repo_id;
|
||||||
std::string path;
|
std::string path;
|
||||||
|
|||||||
@@ -9,9 +9,12 @@
|
|||||||
|
|
||||||
#include "seafile/seafile_api.hpp"
|
#include "seafile/seafile_api.hpp"
|
||||||
#include "seafile/token_type.hpp"
|
#include "seafile/token_type.hpp"
|
||||||
|
#include "seafile/fs/file_context.hpp"
|
||||||
|
|
||||||
namespace seafile::fs {
|
namespace seafile::fs
|
||||||
class SeafileFileSystem final {
|
{
|
||||||
|
class SeafileFileSystem final
|
||||||
|
{
|
||||||
std::string repo_id;
|
std::string repo_id;
|
||||||
std::string token;
|
std::string token;
|
||||||
TokenType token_type = TokenType::TOKEN;
|
TokenType token_type = TokenType::TOKEN;
|
||||||
@@ -19,47 +22,61 @@ namespace seafile::fs {
|
|||||||
std::wstring mount_point;
|
std::wstring mount_point;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SeafileFileSystem(const std::string &server,
|
explicit SeafileFileSystem(const std::string& server,
|
||||||
const std::wstring &mount_point) : api(server), mount_point(mount_point) {
|
const std::wstring& mount_point) : api(server), mount_point(mount_point)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void auth(const std::string &username, const std::string &password);
|
void auth(const std::string& username, const std::string& password);
|
||||||
|
|
||||||
SeafileFileSystem(const SeafileFileSystem &) = delete;
|
SeafileFileSystem(const SeafileFileSystem&) = delete;
|
||||||
|
|
||||||
SeafileFileSystem(SeafileFileSystem &&) = delete;
|
SeafileFileSystem(SeafileFileSystem&&) = delete;
|
||||||
|
|
||||||
SeafileFileSystem &operator=(const SeafileFileSystem &) = delete;
|
SeafileFileSystem& operator=(const SeafileFileSystem&) = delete;
|
||||||
|
|
||||||
SeafileFileSystem &operator=(SeafileFileSystem &&) = delete;
|
SeafileFileSystem& operator=(SeafileFileSystem&&) = delete;
|
||||||
|
|
||||||
NTSTATUS GetVolumeInfo(FSP_FSCTL_VOLUME_INFO *VolumeInfo);
|
NTSTATUS GetVolumeInfo(FSP_FSCTL_VOLUME_INFO* VolumeInfo);
|
||||||
|
|
||||||
NTSTATUS SetVolumeLabel_(PWSTR VolumeLabel,
|
NTSTATUS SetVolumeLabel_(PWSTR VolumeLabel,
|
||||||
FSP_FSCTL_VOLUME_INFO *VolumeInfo);
|
FSP_FSCTL_VOLUME_INFO* VolumeInfo);
|
||||||
|
|
||||||
NTSTATUS GetSecurityByName(PWSTR FileName,
|
NTSTATUS GetSecurityByName(PWSTR FileName,
|
||||||
PUINT32 PFileAttributes,
|
PUINT32 PFileAttributes,
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
SIZE_T *PSecurityDescriptorSize);
|
SIZE_T* PSecurityDescriptorSize);
|
||||||
|
|
||||||
|
NTSTATUS Create(PWSTR FileName, UINT32 CreateOptions,
|
||||||
|
UINT32 GrantedAccess, UINT32 FileAttributes, PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
UINT64 AllocationSize, PVOID* PFileContext, FSP_FSCTL_FILE_INFO* FileInfo);
|
||||||
|
|
||||||
NTSTATUS Open(
|
NTSTATUS Open(
|
||||||
PWSTR FileName,
|
PWSTR FileName,
|
||||||
UINT32 CreateOptions,
|
UINT32 CreateOptions,
|
||||||
UINT32 GrantedAccess,
|
UINT32 GrantedAccess,
|
||||||
PVOID *PFileContext,
|
PVOID* PFileContext,
|
||||||
FSP_FSCTL_FILE_INFO *FileInfo);
|
FSP_FSCTL_FILE_INFO* FileInfo);
|
||||||
|
|
||||||
NTSTATUS Read(PVOID FileContext, PVOID Buffer, UINT64 Offset, ULONG Length,
|
NTSTATUS Read(PVOID FileContext, PVOID Buffer, UINT64 Offset, ULONG Length,
|
||||||
PULONG PBytesTransferred);
|
PULONG PBytesTransferred);
|
||||||
|
|
||||||
NTSTATUS GetFileInfo(HANDLE Handle, FSP_FSCTL_FILE_INFO *FileInfo);
|
NTSTATUS GetFileInfo(HANDLE Handle, FSP_FSCTL_FILE_INFO* FileInfo);
|
||||||
|
|
||||||
|
|
||||||
VOID Close(PVOID FileContext0);
|
VOID Close(PVOID FileContext0);
|
||||||
|
|
||||||
NTSTATUS ReadDirectory(PVOID FileContext0, PWSTR Pattern, PWSTR Marker,
|
VOID Cleanup(PVOID FileContext, PWSTR FileName, ULONG Flags);
|
||||||
|
|
||||||
|
NTSTATUS Overwrite(
|
||||||
|
PVOID FileContext, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes, UINT64 AllocationSize,
|
||||||
|
FSP_FSCTL_FILE_INFO* FileInfo);
|
||||||
|
|
||||||
|
NTSTATUS ReadDirectory(PVOID FileContext, PWSTR Pattern, PWSTR Marker,
|
||||||
PVOID Buffer, ULONG BufferLength, PULONG PBytesTransferred);
|
PVOID Buffer, ULONG BufferLength, PULONG PBytesTransferred);
|
||||||
|
|
||||||
|
NTSTATUS GetDirInfoByName(PVOID FileContext, PWSTR FileName,
|
||||||
|
FSP_FSCTL_DIR_INFO* DirInfo);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif //SEADISK_SEAFILE_FILE_SYSTEM_HPP
|
#endif //SEADISK_SEAFILE_FILE_SYSTEM_HPP
|
||||||
@@ -6,56 +6,64 @@
|
|||||||
#define SEADISK_WINFSP_ADAPTER_HPP
|
#define SEADISK_WINFSP_ADAPTER_HPP
|
||||||
#include "seafile_file_system.hpp"
|
#include "seafile_file_system.hpp"
|
||||||
|
|
||||||
namespace seafile::fs {
|
namespace seafile::fs
|
||||||
class WinFSPAdapter {
|
{
|
||||||
|
class WinFSPAdapter
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
static NTSTATUS GetVolumeInfo(FSP_FILE_SYSTEM *FileSystem, FSP_FSCTL_VOLUME_INFO *VolumeInfo);
|
static NTSTATUS GetVolumeInfo(FSP_FILE_SYSTEM* FileSystem, FSP_FSCTL_VOLUME_INFO* VolumeInfo);
|
||||||
|
|
||||||
static NTSTATUS SvcStart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv);
|
static NTSTATUS SvcStart(FSP_SERVICE* Service, ULONG argc, PWSTR* argv);
|
||||||
|
|
||||||
static NTSTATUS SvcStop(FSP_SERVICE *Service);
|
static NTSTATUS SvcStop(FSP_SERVICE* Service);
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS SetVolumeLabel_(FSP_FILE_SYSTEM *FileSystem, PWSTR VolumeLabel,
|
static NTSTATUS SetVolumeLabel_(FSP_FILE_SYSTEM* FileSystem, PWSTR VolumeLabel,
|
||||||
FSP_FSCTL_VOLUME_INFO *VolumeInfo);
|
FSP_FSCTL_VOLUME_INFO* VolumeInfo);
|
||||||
|
|
||||||
static NTSTATUS GetSecurityByName(FSP_FILE_SYSTEM *FileSystem, PWSTR FileName, PUINT32 PFileAttributes,
|
static NTSTATUS GetSecurityByName(FSP_FILE_SYSTEM* FileSystem, PWSTR FileName, PUINT32 PFileAttributes,
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
SIZE_T *PSecurityDescriptorSize);
|
SIZE_T* PSecurityDescriptorSize);
|
||||||
|
|
||||||
static NTSTATUS Open(FSP_FILE_SYSTEM *FileSystem, PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess,
|
static NTSTATUS Open(FSP_FILE_SYSTEM* FileSystem, PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess,
|
||||||
PVOID *PFileContext,
|
PVOID* PFileContext,
|
||||||
FSP_FSCTL_FILE_INFO *FileInfo);
|
FSP_FSCTL_FILE_INFO* FileInfo);
|
||||||
|
|
||||||
static NTSTATUS Create(FSP_FILE_SYSTEM *FileSystem,
|
static NTSTATUS Create(FSP_FILE_SYSTEM* FileSystem,
|
||||||
PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess,
|
PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess,
|
||||||
UINT32 FileAttributes, PSECURITY_DESCRIPTOR SecurityDescriptor, UINT64 AllocationSize,
|
UINT32 FileAttributes, PSECURITY_DESCRIPTOR SecurityDescriptor, UINT64 AllocationSize,
|
||||||
PVOID *PFileContext, FSP_FSCTL_FILE_INFO *FileInfo);
|
PVOID* PFileContext, FSP_FSCTL_FILE_INFO* FileInfo);
|
||||||
|
|
||||||
static NTSTATUS Read(FSP_FILE_SYSTEM *FileSystem,
|
static NTSTATUS Read(FSP_FILE_SYSTEM* FileSystem,
|
||||||
PVOID FileContext, PVOID Buffer, UINT64 Offset, ULONG Length,
|
PVOID FileContext, PVOID Buffer, UINT64 Offset, ULONG Length,
|
||||||
PULONG PBytesTransferred);
|
PULONG PBytesTransferred);
|
||||||
|
|
||||||
static NTSTATUS GetFileInfo(FSP_FILE_SYSTEM *FileSystem, HANDLE Handle, FSP_FSCTL_FILE_INFO *FileInfo);
|
static NTSTATUS Overwrite(FSP_FILE_SYSTEM *FileSystem,
|
||||||
|
PVOID FileContext, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes, UINT64 AllocationSize,
|
||||||
|
FSP_FSCTL_FILE_INFO *FileInfo);
|
||||||
|
|
||||||
|
static VOID Cleanup(FSP_FILE_SYSTEM* FileSystem, PVOID FileContext, PWSTR FileName, ULONG Flags);
|
||||||
|
|
||||||
|
static NTSTATUS GetFileInfo(FSP_FILE_SYSTEM* FileSystem, HANDLE Handle, FSP_FSCTL_FILE_INFO* FileInfo);
|
||||||
|
|
||||||
|
|
||||||
static VOID Close(FSP_FILE_SYSTEM *FileSystem, PVOID FileContext0);
|
static VOID Close(FSP_FILE_SYSTEM* FileSystem, PVOID FileContext0);
|
||||||
|
|
||||||
static NTSTATUS ReadDirectory(FSP_FILE_SYSTEM *FileSystem, PVOID FileContext0, PWSTR Pattern, PWSTR Marker,
|
static NTSTATUS ReadDirectory(FSP_FILE_SYSTEM* FileSystem, PVOID FileContext0, PWSTR Pattern, PWSTR Marker,
|
||||||
PVOID Buffer, ULONG BufferLength, PULONG PBytesTransferred);
|
PVOID Buffer, ULONG BufferLength, PULONG PBytesTransferred);
|
||||||
|
|
||||||
static NTSTATUS GetDirInfoByName(FSP_FILE_SYSTEM *FileSystem,
|
static NTSTATUS GetDirInfoByName(FSP_FILE_SYSTEM* FileSystem,
|
||||||
PVOID FileContext, PWSTR FileName,
|
PVOID FileContext, PWSTR FileName,
|
||||||
FSP_FSCTL_DIR_INFO *DirInfo);
|
FSP_FSCTL_DIR_INFO* DirInfo);
|
||||||
|
|
||||||
static NTSTATUS SetSecurity(FSP_FILE_SYSTEM *FileSystem,
|
static NTSTATUS SetSecurity(FSP_FILE_SYSTEM* FileSystem,
|
||||||
PVOID FileContext,
|
PVOID FileContext,
|
||||||
SECURITY_INFORMATION SecurityInformation,
|
SECURITY_INFORMATION SecurityInformation,
|
||||||
PSECURITY_DESCRIPTOR ModificationDescriptor);
|
PSECURITY_DESCRIPTOR ModificationDescriptor);
|
||||||
|
|
||||||
static NTSTATUS GetSecurity(FSP_FILE_SYSTEM *FileSystem,
|
static NTSTATUS GetSecurity(FSP_FILE_SYSTEM* FileSystem,
|
||||||
PVOID FileContext,
|
PVOID FileContext,
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor, SIZE_T *PSecurityDescriptorSize);
|
PSECURITY_DESCRIPTOR SecurityDescriptor, SIZE_T* PSecurityDescriptorSize);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif //SEADISK_WINFSP_ADAPTER_HPP
|
#endif //SEADISK_WINFSP_ADAPTER_HPP
|
||||||
@@ -252,7 +252,7 @@ namespace seafile
|
|||||||
const std::string& token,
|
const std::string& token,
|
||||||
const TokenType token_type) const
|
const TokenType token_type) const
|
||||||
{
|
{
|
||||||
if (const auto download_url = downloadFileUrl(repo_id, path, token, token_type); download_url.has_value())
|
if (auto download_url = downloadFileUrl(repo_id, path, token, token_type); download_url.has_value())
|
||||||
{
|
{
|
||||||
const auto auth = makeAuthToken(token, token_type);
|
const auto auth = makeAuthToken(token, token_type);
|
||||||
const auto url = cpr::Url{download_url.value()};
|
const auto url = cpr::Url{download_url.value()};
|
||||||
@@ -263,7 +263,7 @@ namespace seafile
|
|||||||
"bytes={}-{}",
|
"bytes={}-{}",
|
||||||
start ? std::to_string(*start) : "",
|
start ? std::to_string(*start) : "",
|
||||||
end ? std::to_string(*end) : "");
|
end ? std::to_string(*end) : "");
|
||||||
header.emplace("range", std::move(range));
|
header.emplace("range", range);
|
||||||
const auto response = cpr::Get(url, header);
|
const auto response = cpr::Get(url, header);
|
||||||
return parseResponse<std::string>(response);
|
return parseResponse<std::string>(response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,60 +1,319 @@
|
|||||||
//
|
|
||||||
// Created by Shell on 2026-06-18.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "seafile/fs/seafile_file_system.hpp"
|
#include "seafile/fs/seafile_file_system.hpp"
|
||||||
|
|
||||||
namespace seafile::fs {
|
namespace seafile::fs
|
||||||
void SeafileFileSystem::auth(const std::string &username, const std::string &password) {
|
{
|
||||||
if (const auto authToken = api.authToken(username, password); authToken.has_value()) {
|
namespace
|
||||||
this->token = authToken.value().token;
|
{
|
||||||
|
constexpr int64_t UNIX_EPOCH_AS_FILETIME = 116444736000000000LL;
|
||||||
|
constexpr int64_t HUNDREDS_OF_NANOSECONDS_PER_SECOND = 10000000LL;
|
||||||
|
|
||||||
|
int64_t UnixTimeToFileTime(int64_t unix_time)
|
||||||
|
{
|
||||||
|
return UNIX_EPOCH_AS_FILETIME + unix_time * HUNDREDS_OF_NANOSECONDS_PER_SECOND;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t NowFileTime()
|
||||||
|
{
|
||||||
|
FILETIME ft;
|
||||||
|
GetSystemTimeAsFileTime(&ft);
|
||||||
|
return (static_cast<int64_t>(ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetFileInfo(FSP_FSCTL_FILE_INFO* FileInfo, uint32_t attributes, uint64_t size, int64_t mtime)
|
||||||
|
{
|
||||||
|
FileInfo->FileAttributes = attributes;
|
||||||
|
FileInfo->AllocationSize = size;
|
||||||
|
FileInfo->FileSize = size;
|
||||||
|
const auto ft = mtime ? UnixTimeToFileTime(mtime) : NowFileTime();
|
||||||
|
FileInfo->CreationTime = ft;
|
||||||
|
FileInfo->LastAccessTime = ft;
|
||||||
|
FileInfo->LastWriteTime = ft;
|
||||||
|
FileInfo->ChangeTime = ft;
|
||||||
|
FileInfo->IndexNumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplitPath(const std::wstring& path, std::string& repo_id, std::string& sub_path)
|
||||||
|
{
|
||||||
|
repo_id.clear();
|
||||||
|
sub_path = "/";
|
||||||
|
auto p = path;
|
||||||
|
while (!p.empty() && p[0] == L'\\')
|
||||||
|
p = p.substr(1);
|
||||||
|
if (p.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto sep = p.find(L'\\');
|
||||||
|
auto repo_id_w = (sep == std::wstring::npos) ? p : p.substr(0, sep);
|
||||||
|
repo_id.assign(repo_id_w.begin(), repo_id_w.end());
|
||||||
|
|
||||||
|
if (sep != std::wstring::npos)
|
||||||
|
{
|
||||||
|
auto rest = p.substr(sep);
|
||||||
|
sub_path.clear();
|
||||||
|
for (auto c : rest)
|
||||||
|
sub_path += static_cast<char>(c);
|
||||||
|
while (!sub_path.empty() && sub_path.front() == '\\')
|
||||||
|
sub_path = sub_path.substr(1);
|
||||||
|
sub_path = "/" + sub_path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SeafileFileSystem::Close(PVOID FileContext0) {
|
void SeafileFileSystem::auth(const std::string& username, const std::string& password)
|
||||||
|
{
|
||||||
|
if (const auto authToken = api.authToken(username, password); authToken.has_value())
|
||||||
|
this->token = authToken.value().token;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SeafileFileSystem::Close(PVOID FileContext)
|
||||||
|
{
|
||||||
|
delete static_cast<SeaFileContext*>(FileContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS SeafileFileSystem::GetSecurityByName(PWSTR FileName, PUINT32 PFileAttributes,
|
NTSTATUS SeafileFileSystem::GetSecurityByName(PWSTR FileName, PUINT32 PFileAttributes,
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
SIZE_T *PSecurityDescriptorSize) {
|
SIZE_T* PSecurityDescriptorSize)
|
||||||
*PFileAttributes = FILE_ATTRIBUTE_NORMAL;
|
{
|
||||||
*PSecurityDescriptorSize = 0;
|
|
||||||
|
if (PFileAttributes)
|
||||||
|
{
|
||||||
|
if (wcscmp(FileName, L"\\") == 0)
|
||||||
|
{
|
||||||
|
*PFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
*PFileAttributes = FILE_ATTRIBUTE_NORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PSecurityDescriptorSize)
|
||||||
|
*PSecurityDescriptorSize = 0;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS SeafileFileSystem::GetVolumeInfo(FSP_FSCTL_VOLUME_INFO *VolumeInfo) {
|
NTSTATUS SeafileFileSystem::Overwrite(PVOID FileContext, UINT32 FileAttributes, BOOLEAN ReplaceFileAttributes, UINT64 AllocationSize, FSP_FSCTL_FILE_INFO* FileInfo)
|
||||||
|
{
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS SeafileFileSystem::GetVolumeInfo(FSP_FSCTL_VOLUME_INFO* VolumeInfo)
|
||||||
|
{
|
||||||
const auto userInfo = api.accountInfo(this->token, this->token_type);
|
const auto userInfo = api.accountInfo(this->token, this->token_type);
|
||||||
if (userInfo.has_value()) {
|
if (userInfo.has_value())
|
||||||
const auto &info = userInfo.value();
|
{
|
||||||
|
const auto& info = userInfo.value();
|
||||||
VolumeInfo->FreeSize = info.total - info.usage;
|
VolumeInfo->FreeSize = info.total - info.usage;
|
||||||
VolumeInfo->TotalSize = info.total;
|
VolumeInfo->TotalSize = info.total;
|
||||||
wcscpy(VolumeInfo->VolumeLabel, L"Seafile");
|
wcscpy(VolumeInfo->VolumeLabel, L"Seafile");
|
||||||
VolumeInfo->VolumeLabelLength = static_cast<UINT16>((wcslen(VolumeInfo->VolumeLabel) * sizeof(WCHAR)));
|
VolumeInfo->VolumeLabelLength = static_cast<UINT16>((wcslen(VolumeInfo->VolumeLabel) * sizeof(WCHAR)));
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
return STATUS_END_OF_MEDIA;
|
return STATUS_END_OF_MEDIA;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS SeafileFileSystem::Open(PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess, PVOID *PFileContext,
|
void SeafileFileSystem::Cleanup(PVOID FileContext, PWSTR FileName, ULONG Flags)
|
||||||
FSP_FSCTL_FILE_INFO *FileInfo) {
|
{
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS SeafileFileSystem::Read(PVOID FileContext, PVOID Buffer, UINT64 Offset, ULONG Length, PULONG PBytesTransferred) {
|
NTSTATUS SeafileFileSystem::Open(PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess, PVOID* PFileContext,
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
FSP_FSCTL_FILE_INFO* FileInfo)
|
||||||
|
{
|
||||||
|
std::string repo_id, sub_path;
|
||||||
|
SplitPath(FileName, repo_id, sub_path);
|
||||||
|
|
||||||
|
const bool expect_dir = (CreateOptions & FILE_DIRECTORY_FILE) != 0;
|
||||||
|
|
||||||
|
if (repo_id.empty())
|
||||||
|
{
|
||||||
|
auto ctx = new SeaFileContext{"", "/", 0, ""};
|
||||||
|
*PFileContext = ctx;
|
||||||
|
SetFileInfo(FileInfo, FILE_ATTRIBUTE_DIRECTORY, 0, 0);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sub_path == "/")
|
||||||
|
{
|
||||||
|
auto repo = api.repoInfo(repo_id, token, token_type);
|
||||||
|
if (!repo.has_value())
|
||||||
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
|
auto ctx = new SeaFileContext{repo->id, "/", 0, ""};
|
||||||
|
*PFileContext = ctx;
|
||||||
|
SetFileInfo(FileInfo, FILE_ATTRIBUTE_DIRECTORY, repo->size, repo->mtime);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expect_dir)
|
||||||
|
{
|
||||||
|
auto entries = api.repoDir(repo_id, sub_path, token, token_type);
|
||||||
|
if (entries.has_value())
|
||||||
|
{
|
||||||
|
auto ctx = new SeaFileContext{repo_id, sub_path, 0, ""};
|
||||||
|
*PFileContext = ctx;
|
||||||
|
SetFileInfo(FileInfo, FILE_ATTRIBUTE_DIRECTORY, 0, 0);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
auto fdetail = api.fileDetail(repo_id, sub_path, token, token_type);
|
||||||
|
if (fdetail.has_value())
|
||||||
|
return STATUS_NOT_A_DIRECTORY;
|
||||||
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto fdetail = api.fileDetail(repo_id, sub_path, token, token_type);
|
||||||
|
if (fdetail.has_value())
|
||||||
|
{
|
||||||
|
auto ctx = new SeaFileContext{repo_id, sub_path, fdetail->size, ""};
|
||||||
|
*PFileContext = ctx;
|
||||||
|
SetFileInfo(FileInfo, FILE_ATTRIBUTE_NORMAL, fdetail->size, fdetail->mtime);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
auto entries = api.repoDir(repo_id, sub_path, token, token_type);
|
||||||
|
if (entries.has_value())
|
||||||
|
return STATUS_FILE_IS_A_DIRECTORY;
|
||||||
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS SeafileFileSystem::ReadDirectory(PVOID FileContext0, PWSTR Pattern, PWSTR Marker, PVOID Buffer,
|
NTSTATUS SeafileFileSystem::Read(PVOID FileContext, PVOID Buffer, UINT64 Offset, ULONG Length,
|
||||||
ULONG BufferLength, PULONG PBytesTransferred) {
|
PULONG PBytesTransferred)
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
{
|
||||||
|
const auto fc = static_cast<SeaFileContext*>(FileContext);
|
||||||
|
auto result = api.downloadFile(
|
||||||
|
fc->repo_id, fc->path,
|
||||||
|
Offset, Offset + Length - 1,
|
||||||
|
token, token_type);
|
||||||
|
if (result.has_value())
|
||||||
|
{
|
||||||
|
const auto& data = result.value();
|
||||||
|
const auto copy_len = (std::min)(data.size(), static_cast<size_t>(Length));
|
||||||
|
memcpy(Buffer, data.data(), copy_len);
|
||||||
|
*PBytesTransferred = static_cast<ULONG>(copy_len);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS SeafileFileSystem::SetVolumeLabel_(PWSTR VolumeLabel, FSP_FSCTL_VOLUME_INFO *VolumeInfo) {
|
NTSTATUS SeafileFileSystem::ReadDirectory(PVOID FileContext, PWSTR Pattern, PWSTR Marker,
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
PVOID Buffer, ULONG BufferLength, PULONG PBytesTransferred)
|
||||||
|
{
|
||||||
|
const auto fc = static_cast<SeaFileContext*>(FileContext);
|
||||||
|
*PBytesTransferred = 0;
|
||||||
|
|
||||||
|
auto add_entry = [&](const std::wstring& name, UINT32 attrs, uint64_t size, int64_t mtime) -> bool
|
||||||
|
{
|
||||||
|
if (Marker && wcscmp(name.c_str(), Marker) <= 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const auto name_bytes = (wcslen(name.c_str()) + 1) * sizeof(WCHAR);
|
||||||
|
const auto entry_size = static_cast<ULONG>(offsetof(FSP_FSCTL_DIR_INFO, FileNameBuf) + name_bytes);
|
||||||
|
if (*PBytesTransferred + entry_size > BufferLength)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto DirInfo = reinterpret_cast<FSP_FSCTL_DIR_INFO*>(
|
||||||
|
static_cast<PUINT8>(Buffer) + *PBytesTransferred);
|
||||||
|
memset(DirInfo, 0, sizeof(FSP_FSCTL_DIR_INFO));
|
||||||
|
DirInfo->Size = entry_size;
|
||||||
|
SetFileInfo(&DirInfo->FileInfo, attrs, size, mtime);
|
||||||
|
memcpy(DirInfo->FileNameBuf, name.c_str(), name_bytes);
|
||||||
|
*PBytesTransferred += entry_size;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (fc->repo_id.empty())
|
||||||
|
{
|
||||||
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
|
}
|
||||||
|
bool ok = true;
|
||||||
|
auto entries = api.repoDir(fc->repo_id, fc->path, token, token_type);
|
||||||
|
if (!entries.has_value())
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
|
for (const auto& entry : entries.value())
|
||||||
|
{
|
||||||
|
auto wname = std::wstring(entry.name.begin(), entry.name.end());
|
||||||
|
const auto attrs = (entry.type == "dir") ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL;
|
||||||
|
const auto sz = entry.size.value_or(0);
|
||||||
|
ok = add_entry(wname, attrs, sz, entry.mtime);
|
||||||
|
if (!ok) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS SeafileFileSystem::GetFileInfo(HANDLE Handle, FSP_FSCTL_FILE_INFO *FileInfo) {
|
NTSTATUS SeafileFileSystem::GetFileInfo(HANDLE Handle, FSP_FSCTL_FILE_INFO* FileInfo)
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
{
|
||||||
|
auto fc = static_cast<SeaFileContext*>(Handle);
|
||||||
|
if (fc->repo_id.empty() || fc->path == "/" || fc->path.back() == '/')
|
||||||
|
{
|
||||||
|
if (fc->repo_id.empty())
|
||||||
|
{
|
||||||
|
SetFileInfo(FileInfo, FILE_ATTRIBUTE_DIRECTORY, 0, 0);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
auto repo = api.repoInfo(fc->repo_id, token, token_type);
|
||||||
|
if (!repo.has_value())
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
SetFileInfo(FileInfo, FILE_ATTRIBUTE_DIRECTORY, repo->size, repo->mtime);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
auto fdetail = api.fileDetail(fc->repo_id, fc->path, token, token_type);
|
||||||
|
if (!fdetail.has_value())
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
SetFileInfo(FileInfo, FILE_ATTRIBUTE_NORMAL, fdetail->size, fdetail->mtime);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS SeafileFileSystem::Create(PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess, UINT32 FileAttributes, PSECURITY_DESCRIPTOR SecurityDescriptor, UINT64 AllocationSize, PVOID* PFileContext, FSP_FSCTL_FILE_INFO* FileInfo)
|
||||||
|
{
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS SeafileFileSystem::GetDirInfoByName(PVOID FileContext, PWSTR FileName,
|
||||||
|
FSP_FSCTL_DIR_INFO* DirInfo)
|
||||||
|
{
|
||||||
|
auto fc = static_cast<SeaFileContext*>(FileContext);
|
||||||
|
std::wstring name(FileName);
|
||||||
|
|
||||||
|
if (name == L"." || name == L"..")
|
||||||
|
{
|
||||||
|
memset(DirInfo, 0, sizeof(FSP_FSCTL_DIR_INFO));
|
||||||
|
DirInfo->Size = sizeof(FSP_FSCTL_DIR_INFO) + (wcslen(FileName) + 1) * sizeof(WCHAR);
|
||||||
|
SetFileInfo(&DirInfo->FileInfo, FILE_ATTRIBUTE_DIRECTORY, 0, 0);
|
||||||
|
wcscpy_s(DirInfo->FileNameBuf, wcslen(FileName) + 1, FileName);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string utf8_name;
|
||||||
|
for (const auto c : name)
|
||||||
|
utf8_name += static_cast<char>(c);
|
||||||
|
|
||||||
|
if (fc->repo_id.empty())
|
||||||
|
{
|
||||||
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto entries = api.repoDir(fc->repo_id, fc->path, token, token_type);
|
||||||
|
if (!entries.has_value())
|
||||||
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
|
|
||||||
|
for (const auto& entry : entries.value())
|
||||||
|
{
|
||||||
|
if (entry.name != utf8_name)
|
||||||
|
continue;
|
||||||
|
memset(DirInfo, 0, sizeof(FSP_FSCTL_DIR_INFO));
|
||||||
|
const auto name_bytes = (name.size() + 1) * sizeof(WCHAR);
|
||||||
|
DirInfo->Size = static_cast<UINT64>(offsetof(FSP_FSCTL_DIR_INFO, FileNameBuf) + name_bytes);
|
||||||
|
const auto attrs = (entry.type == "dir") ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL;
|
||||||
|
SetFileInfo(&DirInfo->FileInfo, attrs, entry.size.value_or(0), entry.mtime);
|
||||||
|
wcscpy_s(DirInfo->FileNameBuf, name.size() + 1, FileName);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS SeafileFileSystem::SetVolumeLabel_(PWSTR VolumeLabel, FSP_FSCTL_VOLUME_INFO* VolumeInfo)
|
||||||
|
{
|
||||||
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,14 +6,18 @@
|
|||||||
//
|
//
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace seafile::fs {
|
namespace seafile::fs
|
||||||
namespace {
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
FSP_FILE_SYSTEM_INTERFACE FsInterface = {
|
FSP_FILE_SYSTEM_INTERFACE FsInterface = {
|
||||||
.GetVolumeInfo = WinFSPAdapter::GetVolumeInfo,
|
.GetVolumeInfo = WinFSPAdapter::GetVolumeInfo,
|
||||||
.SetVolumeLabel = WinFSPAdapter::SetVolumeLabel_,
|
.SetVolumeLabel = WinFSPAdapter::SetVolumeLabel_,
|
||||||
.GetSecurityByName = WinFSPAdapter::GetSecurityByName,
|
.GetSecurityByName = WinFSPAdapter::GetSecurityByName,
|
||||||
.Create = WinFSPAdapter::Create,
|
.Create = WinFSPAdapter::Create,
|
||||||
.Open = WinFSPAdapter::Open,
|
.Open = WinFSPAdapter::Open,
|
||||||
|
.Overwrite = WinFSPAdapter::Overwrite,
|
||||||
|
.Cleanup = WinFSPAdapter::Cleanup,
|
||||||
.Close = WinFSPAdapter::Close,
|
.Close = WinFSPAdapter::Close,
|
||||||
.Read = WinFSPAdapter::Read,
|
.Read = WinFSPAdapter::Read,
|
||||||
.GetFileInfo = WinFSPAdapter::GetFileInfo,
|
.GetFileInfo = WinFSPAdapter::GetFileInfo,
|
||||||
@@ -22,15 +26,14 @@ namespace seafile::fs {
|
|||||||
.ReadDirectory = WinFSPAdapter::ReadDirectory,
|
.ReadDirectory = WinFSPAdapter::ReadDirectory,
|
||||||
.GetDirInfoByName = WinFSPAdapter::GetDirInfoByName
|
.GetDirInfoByName = WinFSPAdapter::GetDirInfoByName
|
||||||
};
|
};
|
||||||
std::unordered_map<FSP_FILE_SYSTEM *, SeafileFileSystem *> fstab;
|
std::unordered_map<FSP_FILE_SYSTEM*, SeafileFileSystem*> fstab;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::SvcStart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv) {
|
NTSTATUS WinFSPAdapter::SvcStart(FSP_SERVICE* Service, ULONG argc, PWSTR* argv)
|
||||||
DWORD LastError;
|
{
|
||||||
FILETIME CreationTime;
|
FILETIME CreationTime;
|
||||||
FSP_FSCTL_VOLUME_PARAMS VolumeParams = {};
|
FSP_FSCTL_VOLUME_PARAMS VolumeParams = {};
|
||||||
FSP_FILE_SYSTEM *FileSystem = nullptr;
|
FSP_FILE_SYSTEM* FileSystem = nullptr;
|
||||||
|
|
||||||
GetSystemTimeAsFileTime(&CreationTime);
|
GetSystemTimeAsFileTime(&CreationTime);
|
||||||
|
|
||||||
@@ -44,7 +47,7 @@ namespace seafile::fs {
|
|||||||
VolumeParams.CaseSensitiveSearch = 0;
|
VolumeParams.CaseSensitiveSearch = 0;
|
||||||
VolumeParams.CasePreservedNames = 1;
|
VolumeParams.CasePreservedNames = 1;
|
||||||
VolumeParams.UnicodeOnDisk = 1;
|
VolumeParams.UnicodeOnDisk = 1;
|
||||||
VolumeParams.PersistentAcls = 1;
|
VolumeParams.PersistentAcls = 0;
|
||||||
VolumeParams.PostCleanupWhenModifiedOnly = 1; // (4)
|
VolumeParams.PostCleanupWhenModifiedOnly = 1; // (4)
|
||||||
VolumeParams.UmFileContextIsUserContext2 = 1; // (4)
|
VolumeParams.UmFileContextIsUserContext2 = 1; // (4)
|
||||||
VolumeParams.ReadOnlyVolume = 1;
|
VolumeParams.ReadOnlyVolume = 1;
|
||||||
@@ -56,21 +59,23 @@ namespace seafile::fs {
|
|||||||
&FsInterface,
|
&FsInterface,
|
||||||
&FileSystem);
|
&FileSystem);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Result)) {
|
if (!NT_SUCCESS(Result))
|
||||||
|
{
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
const auto mount_point = std::wstring(L"X:");
|
auto mount_point = std::wstring(L"X:");
|
||||||
auto seafile_file_system = new SeafileFileSystem("https://pan.hanwangsoft.com", mount_point);
|
auto seafile_file_system = new SeafileFileSystem("https://pan.hanwangsoft.com", mount_point);
|
||||||
seafile_file_system->auth("asypost@yeah.net", "Shell0805@china");
|
seafile_file_system->auth("asypost@yeah.net", "Shell0805@china");
|
||||||
FileSystem->UserContext = seafile_file_system;
|
FileSystem->UserContext = seafile_file_system;
|
||||||
fstab.insert({FileSystem, seafile_file_system});
|
fstab.insert({FileSystem, seafile_file_system});
|
||||||
|
|
||||||
Result = FspFileSystemSetMountPoint(FileSystem, PWSTR(mount_point.data()));
|
Result = FspFileSystemSetMountPoint(FileSystem, static_cast<PWSTR>(mount_point.data()));
|
||||||
|
|
||||||
LastError = GetLastError();
|
DWORD LastError = GetLastError();
|
||||||
std::cout << LastError << std::endl;
|
std::cout << LastError << std::endl;
|
||||||
|
|
||||||
if (!NT_SUCCESS(Result)) {
|
if (!NT_SUCCESS(Result))
|
||||||
|
{
|
||||||
FspFileSystemDelete(FileSystem);
|
FspFileSystemDelete(FileSystem);
|
||||||
fstab.erase(FileSystem);
|
fstab.erase(FileSystem);
|
||||||
|
|
||||||
@@ -80,11 +85,13 @@ namespace seafile::fs {
|
|||||||
|
|
||||||
Result = FspFileSystemStartDispatcher(FileSystem, 0);
|
Result = FspFileSystemStartDispatcher(FileSystem, 0);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Result)) {
|
if (!NT_SUCCESS(Result))
|
||||||
|
{
|
||||||
FspFileSystemDelete(FileSystem);
|
FspFileSystemDelete(FileSystem);
|
||||||
fstab.erase(FileSystem);
|
fstab.erase(FileSystem);
|
||||||
|
|
||||||
delete seafile_file_system;
|
delete seafile_file_system;
|
||||||
|
|
||||||
|
return Result;
|
||||||
}
|
}
|
||||||
FspFileSystemSetDebugLog(
|
FspFileSystemSetDebugLog(
|
||||||
FileSystem,
|
FileSystem,
|
||||||
@@ -94,8 +101,10 @@ namespace seafile::fs {
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::SvcStop(FSP_SERVICE *Service) {
|
NTSTATUS WinFSPAdapter::SvcStop(FSP_SERVICE* Service)
|
||||||
for (auto &[fileSystem, seafileFs]: fstab) {
|
{
|
||||||
|
for (auto& [fileSystem, seafileFs] : fstab)
|
||||||
|
{
|
||||||
FspFileSystemStopDispatcher(fileSystem);
|
FspFileSystemStopDispatcher(fileSystem);
|
||||||
fileSystem->UserContext = nullptr;
|
fileSystem->UserContext = nullptr;
|
||||||
FspFileSystemDelete(fileSystem);
|
FspFileSystemDelete(fileSystem);
|
||||||
@@ -106,70 +115,105 @@ namespace seafile::fs {
|
|||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::GetVolumeInfo(FSP_FILE_SYSTEM *FileSystem, FSP_FSCTL_VOLUME_INFO *VolumeInfo) {
|
NTSTATUS WinFSPAdapter::GetVolumeInfo(FSP_FILE_SYSTEM* FileSystem, FSP_FSCTL_VOLUME_INFO* VolumeInfo)
|
||||||
std::cout<<"Getting Volume Info" <<std::endl;
|
{
|
||||||
auto fs = static_cast<SeafileFileSystem *>(FileSystem->UserContext);
|
std::cout << "Getting Volume Info" << std::endl;
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
return fs->GetVolumeInfo(VolumeInfo);
|
return fs->GetVolumeInfo(VolumeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinFSPAdapter::Close(FSP_FILE_SYSTEM *FileSystem, PVOID FileContext0) {
|
NTSTATUS WinFSPAdapter::Overwrite(FSP_FILE_SYSTEM* FileSystem, PVOID FileContext, UINT32 FileAttributes,
|
||||||
auto fs = static_cast<SeafileFileSystem *>(FileSystem->UserContext);
|
BOOLEAN ReplaceFileAttributes, UINT64 AllocationSize,
|
||||||
fs->Close(FileContext0);
|
FSP_FSCTL_FILE_INFO* FileInfo)
|
||||||
|
{
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
|
return fs->Overwrite(FileContext, FileAttributes, ReplaceFileAttributes, AllocationSize, FileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::Create(FSP_FILE_SYSTEM *FileSystem, PWSTR FileName, UINT32 CreateOptions, UINT32 GrantedAccess, UINT32 FileAttributes, PSECURITY_DESCRIPTOR SecurityDescriptor, UINT64 AllocationSize, PVOID *PFileContext, FSP_FSCTL_FILE_INFO *FileInfo) {
|
void WinFSPAdapter::Close(FSP_FILE_SYSTEM* FileSystem, PVOID FileContext)
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
{
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
|
fs->Close(FileContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::ReadDirectory(FSP_FILE_SYSTEM *FileSystem, PVOID FileContext0, PWSTR Pattern, PWSTR Marker,
|
NTSTATUS WinFSPAdapter::Create(FSP_FILE_SYSTEM* FileSystem, PWSTR FileName, UINT32 CreateOptions,
|
||||||
PVOID Buffer, ULONG BufferLength, PULONG PBytesTransferred) {
|
UINT32 GrantedAccess, UINT32 FileAttributes, PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
auto fs = static_cast<SeafileFileSystem *>(FileSystem->UserContext);
|
UINT64 AllocationSize, PVOID* PFileContext, FSP_FSCTL_FILE_INFO* FileInfo)
|
||||||
|
{
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
|
return fs->Create(FileName, CreateOptions,
|
||||||
|
GrantedAccess, FileAttributes, SecurityDescriptor,
|
||||||
|
AllocationSize, PFileContext, FileInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID WinFSPAdapter::Cleanup(FSP_FILE_SYSTEM* FileSystem, PVOID FileContext, PWSTR FileName, ULONG Flags)
|
||||||
|
{
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
|
fs->Cleanup(FileContext, FileName, Flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS WinFSPAdapter::ReadDirectory(FSP_FILE_SYSTEM* FileSystem, PVOID FileContext0, PWSTR Pattern, PWSTR Marker,
|
||||||
|
PVOID Buffer, ULONG BufferLength, PULONG PBytesTransferred)
|
||||||
|
{
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
return fs->ReadDirectory(FileContext0, Pattern, Marker, Buffer, BufferLength, PBytesTransferred);
|
return fs->ReadDirectory(FileContext0, Pattern, Marker, Buffer, BufferLength, PBytesTransferred);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::GetDirInfoByName(FSP_FILE_SYSTEM *FileSystem,
|
NTSTATUS WinFSPAdapter::GetDirInfoByName(FSP_FILE_SYSTEM* FileSystem,
|
||||||
PVOID FileContext, PWSTR FileName,
|
PVOID FileContext, PWSTR FileName,
|
||||||
FSP_FSCTL_DIR_INFO *DirInfo) {
|
FSP_FSCTL_DIR_INFO* DirInfo)
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
{
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
|
return fs->GetDirInfoByName(FileContext, FileName, DirInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::GetSecurityByName(FSP_FILE_SYSTEM *FileSystem, PWSTR FileName, PUINT32 PFileAttributes,
|
NTSTATUS WinFSPAdapter::GetSecurityByName(FSP_FILE_SYSTEM* FileSystem, PWSTR FileName, PUINT32 PFileAttributes,
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
SIZE_T *PSecurityDescriptorSize) {
|
SIZE_T* PSecurityDescriptorSize)
|
||||||
auto fs = static_cast<SeafileFileSystem *>(FileSystem->UserContext);
|
{
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
return fs->GetSecurityByName(FileName, PFileAttributes, SecurityDescriptor, PSecurityDescriptorSize);
|
return fs->GetSecurityByName(FileName, PFileAttributes, SecurityDescriptor, PSecurityDescriptorSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::SetVolumeLabel_(FSP_FILE_SYSTEM *FileSystem, PWSTR VolumeLabel,
|
NTSTATUS WinFSPAdapter::SetVolumeLabel_(FSP_FILE_SYSTEM* FileSystem, PWSTR VolumeLabel,
|
||||||
FSP_FSCTL_VOLUME_INFO *VolumeInfo) {
|
FSP_FSCTL_VOLUME_INFO* VolumeInfo)
|
||||||
auto fs = static_cast<SeafileFileSystem *>(FileSystem->UserContext);
|
{
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
return fs->SetVolumeLabel_(VolumeLabel, VolumeInfo);
|
return fs->SetVolumeLabel_(VolumeLabel, VolumeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::Open(FSP_FILE_SYSTEM *FileSystem, PWSTR FileName, UINT32 CreateOptions,
|
NTSTATUS WinFSPAdapter::Open(FSP_FILE_SYSTEM* FileSystem, PWSTR FileName, UINT32 CreateOptions,
|
||||||
UINT32 GrantedAccess, PVOID *PFileContext, FSP_FSCTL_FILE_INFO *FileInfo) {
|
UINT32 GrantedAccess, PVOID* PFileContext, FSP_FSCTL_FILE_INFO* FileInfo)
|
||||||
auto fs = static_cast<SeafileFileSystem *>(FileSystem->UserContext);
|
{
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
return fs->Open(FileName, CreateOptions, GrantedAccess, PFileContext, FileInfo);
|
return fs->Open(FileName, CreateOptions, GrantedAccess, PFileContext, FileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::Read(FSP_FILE_SYSTEM *FileSystem, PVOID FileContext, PVOID Buffer, UINT64 Offset,
|
NTSTATUS WinFSPAdapter::Read(FSP_FILE_SYSTEM* FileSystem, PVOID FileContext, PVOID Buffer, UINT64 Offset,
|
||||||
ULONG Length, PULONG PBytesTransferred) {
|
ULONG Length, PULONG PBytesTransferred)
|
||||||
auto fs = static_cast<SeafileFileSystem *>(FileSystem->UserContext);
|
{
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
return fs->Read(FileContext, Buffer, Offset, Length, PBytesTransferred);
|
return fs->Read(FileContext, Buffer, Offset, Length, PBytesTransferred);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::GetFileInfo(FSP_FILE_SYSTEM *FileSystem, HANDLE Handle,
|
NTSTATUS WinFSPAdapter::GetFileInfo(FSP_FILE_SYSTEM* FileSystem, HANDLE Handle,
|
||||||
FSP_FSCTL_FILE_INFO *FileInfo) {
|
FSP_FSCTL_FILE_INFO* FileInfo)
|
||||||
auto fs = static_cast<SeafileFileSystem *>(FileSystem->UserContext);
|
{
|
||||||
|
const auto fs = static_cast<SeafileFileSystem*>(FileSystem->UserContext);
|
||||||
return fs->GetFileInfo(Handle, FileInfo);
|
return fs->GetFileInfo(Handle, FileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::SetSecurity(FSP_FILE_SYSTEM *FileSystem, PVOID FileContext, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR ModificationDescriptor) {
|
NTSTATUS WinFSPAdapter::SetSecurity(FSP_FILE_SYSTEM* FileSystem, PVOID FileContext,
|
||||||
|
SECURITY_INFORMATION SecurityInformation,
|
||||||
|
PSECURITY_DESCRIPTOR ModificationDescriptor)
|
||||||
|
{
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WinFSPAdapter::GetSecurity(FSP_FILE_SYSTEM *FileSystem, PVOID FileContext, PSECURITY_DESCRIPTOR SecurityDescriptor, SIZE_T *PSecurityDescriptorSize) {
|
NTSTATUS WinFSPAdapter::GetSecurity(FSP_FILE_SYSTEM* FileSystem, PVOID FileContext,
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor, SIZE_T* PSecurityDescriptorSize)
|
||||||
|
{
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user