revert
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,8 +21,6 @@
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp"
|
||||
|
||||
#include "app_config.hpp"
|
||||
@@ -49,6 +47,8 @@ remote_winfsp_drive::winfsp_service::winfsp_service(
|
||||
host_(drive) {}
|
||||
|
||||
auto remote_winfsp_drive::winfsp_service::OnStart(ULONG, PWSTR *) -> NTSTATUS {
|
||||
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
|
||||
|
||||
const auto mount_location = utils::string::to_lower(
|
||||
utils::path::absolute((drive_args_.size() > 1u) ? drive_args_[1u] : ""));
|
||||
const auto drive_letter =
|
||||
@@ -75,7 +75,7 @@ auto remote_winfsp_drive::winfsp_service::OnStart(ULONG, PWSTR *) -> NTSTATUS {
|
||||
event_system::instance().raise<drive_mount_failed>(mount_location,
|
||||
std::to_string(ret));
|
||||
if (not lock_.set_mount_state(false, "", -1)) {
|
||||
utils::error::raise_error(__FUNCTION__, "failed to set mount state");
|
||||
utils::error::raise_error(function_name, "failed to set mount state");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,9 +83,11 @@ auto remote_winfsp_drive::winfsp_service::OnStart(ULONG, PWSTR *) -> NTSTATUS {
|
||||
}
|
||||
|
||||
auto remote_winfsp_drive::winfsp_service::OnStop() -> NTSTATUS {
|
||||
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
|
||||
|
||||
host_.Unmount();
|
||||
if (not lock_.set_mount_state(false, "", -1)) {
|
||||
utils::error::raise_error(__FUNCTION__, "failed to set mount state");
|
||||
utils::error::raise_error(function_name, "failed to set mount state");
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
@@ -134,7 +136,8 @@ auto remote_winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
|
||||
set_file_info(ofi->FileInfo, fi);
|
||||
const auto file_path = utils::string::from_utf8(normalized_name);
|
||||
wcsncpy(ofi->NormalizedName, &file_path[0], wcslen(&file_path[0]));
|
||||
ofi->NormalizedNameSize = (UINT16)(wcslen(&file_path[0]) * sizeof(WCHAR));
|
||||
ofi->NormalizedNameSize =
|
||||
static_cast<UINT16>(wcslen(&file_path[0]) * sizeof(WCHAR));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -258,6 +261,8 @@ auto remote_winfsp_drive::mount(const std::vector<std::string> &drive_args)
|
||||
}
|
||||
|
||||
auto remote_winfsp_drive::Mounted(PVOID host) -> NTSTATUS {
|
||||
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
|
||||
|
||||
auto *file_system_host = reinterpret_cast<FileSystemHost *>(host);
|
||||
remote_instance_ = factory_();
|
||||
server_ = std::make_unique<server>(config_);
|
||||
@@ -265,7 +270,7 @@ auto remote_winfsp_drive::Mounted(PVOID host) -> NTSTATUS {
|
||||
mount_location_ = utils::string::to_utf8(file_system_host->MountPoint());
|
||||
if (not lock_.set_mount_state(true, mount_location_,
|
||||
::GetCurrentProcessId())) {
|
||||
utils::error::raise_error(__FUNCTION__, "failed to set mount state");
|
||||
utils::error::raise_error(function_name, "failed to set mount state");
|
||||
}
|
||||
|
||||
return remote_instance_->winfsp_mounted(file_system_host->MountPoint());
|
||||
@@ -284,7 +289,8 @@ auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
|
||||
set_file_info(ofi->FileInfo, fi);
|
||||
const auto file_path = utils::string::from_utf8(normalize_name);
|
||||
wcsncpy(ofi->NormalizedName, &file_path[0], wcslen(&file_path[0]));
|
||||
ofi->NormalizedNameSize = (UINT16)(wcslen(&file_path[0]) * sizeof(WCHAR));
|
||||
ofi->NormalizedNameSize =
|
||||
static_cast<UINT16>(wcslen(&file_path[0]) * sizeof(WCHAR));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -445,11 +451,13 @@ auto remote_winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc,
|
||||
}
|
||||
|
||||
VOID remote_winfsp_drive::Unmounted(PVOID host) {
|
||||
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
|
||||
|
||||
server_->stop();
|
||||
server_.reset();
|
||||
auto *file_system_host = reinterpret_cast<FileSystemHost *>(host);
|
||||
if (not lock_.set_mount_state(false, "", -1)) {
|
||||
utils::error::raise_error(__FUNCTION__, "failed to set mount state");
|
||||
utils::error::raise_error(function_name, "failed to set mount state");
|
||||
}
|
||||
remote_instance_->winfsp_unmounted(file_system_host->MountPoint());
|
||||
remote_instance_.reset();
|
||||
|
Reference in New Issue
Block a user