https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3cfd8ab775d8e3028b365…
commit 3cfd8ab775d8e3028b3657907ff27485f7af222c
Author: Vincent Franchomme <franchomme.vincent(a)gmail.com>
AuthorDate: Thu Apr 28 21:35:40 2022 +0200
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Tue May 3 17:30:11 2022 +0200
[BTRFS][UBTRFS][SHELLBTRFS] Upgrade to 1.7.8 (#4417)
v1.7.8.1 (2021-06-13):
- Fixed bug preventing new directories from appearing in listings
- Fixed Release version of driver still not working on XP
v1.7.8 (2021-06-09):
- ~~Upgraded zstd to version 1.5.0~~ Not in ReactOS as it introduces deprecated code
- Fixed regression stopping driver from working under XP
- Fixed compilation on clang
- Fixed corruption issue when Linux mount option inode_cache had been used
- Fixed recursion issue involving virtual directory \$Root
---
dll/shellext/shellbtrfs/iconoverlay.cpp | 6 +++---
dll/shellext/shellbtrfs/iconoverlay.h | 6 +++---
dll/shellext/shellbtrfs/main.cpp | 10 +++++-----
dll/shellext/shellbtrfs/propsheet.cpp | 6 +++---
dll/shellext/shellbtrfs/recv.cpp | 18 +++++++++++++++++
dll/shellext/shellbtrfs/shellbtrfs.rc | 8 ++++----
dll/shellext/shellbtrfs/shellext.h | 10 +++++-----
dll/shellext/shellbtrfs/volpropsheet.cpp | 2 +-
dll/win32/ubtrfs/ubtrfs.rc | 8 ++++----
drivers/filesystems/btrfs/balance.c | 4 ----
drivers/filesystems/btrfs/btrfs.c | 4 ++--
drivers/filesystems/btrfs/btrfs.h | 1 +
drivers/filesystems/btrfs/btrfs.inf | 2 +-
drivers/filesystems/btrfs/btrfs.rc | 8 ++++----
drivers/filesystems/btrfs/btrfs_drv.h | 6 +++---
drivers/filesystems/btrfs/dirctrl.c | 7 +++++++
drivers/filesystems/btrfs/flushthread.c | 4 ----
drivers/filesystems/btrfs/fsctl.c | 34 ++++++++++++++------------------
sdk/lib/fslib/btrfslib/btrfslib.c | 2 --
19 files changed, 79 insertions(+), 67 deletions(-)
diff --git a/dll/shellext/shellbtrfs/iconoverlay.cpp
b/dll/shellext/shellbtrfs/iconoverlay.cpp
index 6cfbe4b6492..1c14c2c322b 100644
--- a/dll/shellext/shellbtrfs/iconoverlay.cpp
+++ b/dll/shellext/shellbtrfs/iconoverlay.cpp
@@ -43,7 +43,7 @@ HRESULT __stdcall BtrfsIconOverlay::QueryInterface(REFIID riid, void
**ppObj) {
return E_NOINTERFACE;
}
-HRESULT __stdcall BtrfsIconOverlay::GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int*
pIndex, DWORD* pdwFlags) {
+HRESULT __stdcall BtrfsIconOverlay::GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int*
pIndex, DWORD* pdwFlags) noexcept {
if (GetModuleFileNameW(module, pwszIconFile, cchMax) == 0)
return E_FAIL;
@@ -62,7 +62,7 @@ HRESULT __stdcall BtrfsIconOverlay::GetOverlayInfo(PWSTR pwszIconFile,
int cchMa
return S_OK;
}
-HRESULT __stdcall BtrfsIconOverlay::GetPriority(int *pPriority) {
+HRESULT __stdcall BtrfsIconOverlay::GetPriority(int *pPriority) noexcept {
if (!pPriority)
return E_INVALIDARG;
@@ -71,7 +71,7 @@ HRESULT __stdcall BtrfsIconOverlay::GetPriority(int *pPriority) {
return S_OK;
}
-HRESULT __stdcall BtrfsIconOverlay::IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib) {
+HRESULT __stdcall BtrfsIconOverlay::IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib) noexcept
{
win_handle h;
NTSTATUS Status;
IO_STATUS_BLOCK iosb;
diff --git a/dll/shellext/shellbtrfs/iconoverlay.h
b/dll/shellext/shellbtrfs/iconoverlay.h
index 24276ddcb9c..4defcbd1d60 100644
--- a/dll/shellext/shellbtrfs/iconoverlay.h
+++ b/dll/shellext/shellbtrfs/iconoverlay.h
@@ -51,9 +51,9 @@ public:
// IShellIconOverlayIdentifier
- virtual HRESULT __stdcall GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int* pIndex,
DWORD* pdwFlags);
- virtual HRESULT __stdcall GetPriority(int *pPriority);
- virtual HRESULT __stdcall IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib);
+ virtual HRESULT __stdcall GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int* pIndex,
DWORD* pdwFlags) noexcept;
+ virtual HRESULT __stdcall GetPriority(int *pPriority) noexcept;
+ virtual HRESULT __stdcall IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib) noexcept;
private:
LONG refcount;
diff --git a/dll/shellext/shellbtrfs/main.cpp b/dll/shellext/shellbtrfs/main.cpp
index 55b4121a090..d19db443165 100644
--- a/dll/shellext/shellbtrfs/main.cpp
+++ b/dll/shellext/shellbtrfs/main.cpp
@@ -243,11 +243,11 @@ void wstring_sprintf(wstring& s, wstring fmt, ...) {
#pragma warning(pop)
#endif
-extern "C" STDAPI DllCanUnloadNow(void) {
+STDAPI DllCanUnloadNow(void) {
return objs_loaded == 0 ? S_OK : S_FALSE;
}
-extern "C" STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) {
if (rclsid == CLSID_ShellBtrfsIconHandler) {
Factory* fact = new Factory;
if (!fact)
@@ -497,7 +497,7 @@ static void unreg_prop_sheet_handler(const wstring& filetype,
const wstring& nam
#endif
}
-extern "C" STDAPI DllRegisterServer(void) {
+STDAPI DllRegisterServer(void) {
try {
register_clsid(CLSID_ShellBtrfsIconHandler, COM_DESCRIPTION_ICON_HANDLER);
register_clsid(CLSID_ShellBtrfsContextMenu, COM_DESCRIPTION_CONTEXT_MENU);
@@ -520,7 +520,7 @@ extern "C" STDAPI DllRegisterServer(void) {
return S_OK;
}
-extern "C" STDAPI DllUnregisterServer(void) {
+STDAPI DllUnregisterServer(void) {
try {
unreg_prop_sheet_handler(L"Folder", ICON_OVERLAY_NAME);
unreg_prop_sheet_handler(L"*", ICON_OVERLAY_NAME);
@@ -541,7 +541,7 @@ extern "C" STDAPI DllUnregisterServer(void) {
return S_OK;
}
-extern "C" STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine) {
+STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine) {
if (bInstall)
return DllRegisterServer();
else
diff --git a/dll/shellext/shellbtrfs/propsheet.cpp
b/dll/shellext/shellbtrfs/propsheet.cpp
index faa7194e664..f31ce2eb85f 100644
--- a/dll/shellext/shellbtrfs/propsheet.cpp
+++ b/dll/shellext/shellbtrfs/propsheet.cpp
@@ -336,7 +336,7 @@ HRESULT BtrfsPropSheet::load_file_list() {
totalsize = allocsize = sparsesize = 0;
for (i = 0; i < num_files; i++) {
- if (DragQueryFileW((HDROP)stgm.hGlobal, i, fn, sizeof(fn) / sizeof(MAX_PATH))) {
+ if (DragQueryFileW((HDROP)stgm.hGlobal, i, fn, sizeof(fn) / sizeof(WCHAR))) {
HRESULT hr;
hr = check_file(fn, i, num_files, &sv);
@@ -704,7 +704,7 @@ void BtrfsPropSheet::apply_changes(HWND hDlg) {
num_files = DragQueryFileW((HDROP)stgm.hGlobal, 0xFFFFFFFF, nullptr, 0);
for (i = 0; i < num_files; i++) {
- if (DragQueryFileW((HDROP)stgm.hGlobal, i, fn, sizeof(fn) /
sizeof(MAX_PATH))) {
+ if (DragQueryFileW((HDROP)stgm.hGlobal, i, fn, sizeof(fn) / sizeof(WCHAR)))
{
apply_changes_file(hDlg, fn);
}
}
@@ -882,7 +882,7 @@ void BtrfsPropSheet::open_as_admin(HWND hwndDlg) {
GetModuleFileNameW(module, modfn, sizeof(modfn) / sizeof(WCHAR));
for (i = 0; i < num_files; i++) {
- if (DragQueryFileW((HDROP)stgm.hGlobal, i, fn, sizeof(fn) / sizeof(MAX_PATH))) {
+ if (DragQueryFileW((HDROP)stgm.hGlobal, i, fn, sizeof(fn) / sizeof(WCHAR))) {
wstring t;
SHELLEXECUTEINFOW sei;
diff --git a/dll/shellext/shellbtrfs/recv.cpp b/dll/shellext/shellbtrfs/recv.cpp
index 0dc3bf859bb..673df5c42fb 100644
--- a/dll/shellext/shellbtrfs/recv.cpp
+++ b/dll/shellext/shellbtrfs/recv.cpp
@@ -1563,6 +1563,11 @@ extern "C" void CALLBACK RecvSubvolGUIW(HWND hwnd,
HINSTANCE hinst, LPWSTR lpszC
tp->PrivilegeCount = 3;
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Warray-bounds"
+#endif // __clang__
+
if (!LookupPrivilegeValueW(nullptr, L"SeManageVolumePrivilege",
&luid)) {
free(tp);
throw last_error(GetLastError());
@@ -1592,6 +1597,10 @@ extern "C" void CALLBACK RecvSubvolGUIW(HWND hwnd,
HINSTANCE hinst, LPWSTR lpszC
throw last_error(GetLastError());
}
+#ifdef __clang__
+ #pragma clang diagnostic pop
+#endif // __clang__
+
file[0] = 0;
memset(&ofn, 0, sizeof(OPENFILENAMEW));
@@ -1636,6 +1645,11 @@ extern "C" void CALLBACK RecvSubvolW(HWND hwnd, HINSTANCE
hinst, LPWSTR lpszCmdL
tp->PrivilegeCount = 3;
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Warray-bounds"
+#endif // __clang__
+
if (!LookupPrivilegeValueW(nullptr, L"SeManageVolumePrivilege",
&luid)) {
free(tp);
return;
@@ -1660,6 +1674,10 @@ extern "C" void CALLBACK RecvSubvolW(HWND hwnd, HINSTANCE
hinst, LPWSTR lpszCmdL
tp->Privileges[2].Luid = luid;
tp->Privileges[2].Attributes = SE_PRIVILEGE_ENABLED;
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif // __clang__
+
if (!AdjustTokenPrivileges(token, false, tp, tplen, nullptr, nullptr)) {
free(tp);
return;
diff --git a/dll/shellext/shellbtrfs/shellbtrfs.rc
b/dll/shellext/shellbtrfs/shellbtrfs.rc
index 26d3d6aa67e..acf070e40f9 100644
--- a/dll/shellext/shellbtrfs/shellbtrfs.rc
+++ b/dll/shellext/shellbtrfs/shellbtrfs.rc
@@ -61,8 +61,8 @@ IDI_ICON1 ICON "subvol.ico"
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,7,7,0
- PRODUCTVERSION 1,7,7,0
+ FILEVERSION 1,7,8,0
+ PRODUCTVERSION 1,7,8,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -78,12 +78,12 @@ BEGIN
BLOCK "080904b0"
BEGIN
VALUE "FileDescription", "WinBtrfs shell extension"
- VALUE "FileVersion", "1.7.7"
+ VALUE "FileVersion", "1.7.8"
VALUE "InternalName", "btrfs"
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone
2016-21"
VALUE "OriginalFilename", "shellbtrfs.dll"
VALUE "ProductName", "WinBtrfs"
- VALUE "ProductVersion", "1.7.7"
+ VALUE "ProductVersion", "1.7.8"
END
END
BLOCK "VarFileInfo"
diff --git a/dll/shellext/shellbtrfs/shellext.h b/dll/shellext/shellbtrfs/shellext.h
index cfa09779213..ed85136f901 100644
--- a/dll/shellext/shellbtrfs/shellext.h
+++ b/dll/shellext/shellbtrfs/shellext.h
@@ -104,10 +104,6 @@ using namespace std;
extern "C" {
#endif
#ifndef __REACTOS__
-NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle, HANDLE Event,
PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext,
- PIO_STATUS_BLOCK IoStatusBlock, ULONG
FsControlCode, PVOID InputBuffer, ULONG InputBufferLength,
- PVOID OutputBuffer, ULONG
OutputBufferLength);
-
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine,
PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer,
ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key);
@@ -115,11 +111,15 @@ NTSTATUS WINAPI NtSetEaFile(HANDLE FileHandle, PIO_STATUS_BLOCK
IoStatusBlock, P
NTSTATUS WINAPI NtSetSecurityObject(HANDLE Handle, SECURITY_INFORMATION
SecurityInformation, PSECURITY_DESCRIPTOR SecurityDescriptor);
+#ifdef _MSC_VER
+NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle, HANDLE Event,
PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext,
+ PIO_STATUS_BLOCK IoStatusBlock, ULONG
FsControlCode, PVOID InputBuffer, ULONG InputBufferLength,
+ PVOID OutputBuffer, ULONG
OutputBufferLength);
+
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG
len, FILE_INFORMATION_CLASS FileInformationClass);
NTSTATUS NTAPI NtSetInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG
len, FILE_INFORMATION_CLASS FileInformationClass);
-#ifdef _MSC_VER
#define FileBasicInformation (FILE_INFORMATION_CLASS)4
#define FileStandardInformation (FILE_INFORMATION_CLASS)5
#define FileDispositionInformation (FILE_INFORMATION_CLASS)13
diff --git a/dll/shellext/shellbtrfs/volpropsheet.cpp
b/dll/shellext/shellbtrfs/volpropsheet.cpp
index a2f50fac2aa..c79bf8b7d30 100644
--- a/dll/shellext/shellbtrfs/volpropsheet.cpp
+++ b/dll/shellext/shellbtrfs/volpropsheet.cpp
@@ -97,7 +97,7 @@ HRESULT __stdcall BtrfsVolPropSheet::Initialize(PCIDLIST_ABSOLUTE
pidlFolder, ID
return E_FAIL;
}
- if (DragQueryFileW((HDROP)stgm.hGlobal, 0, fnbuf, sizeof(fnbuf) / sizeof(MAX_PATH)))
{
+ if (DragQueryFileW((HDROP)stgm.hGlobal, 0, fnbuf, sizeof(fnbuf) / sizeof(WCHAR))) {
fn = fnbuf;
win_handle h = CreateFileW(fn.c_str(), FILE_TRAVERSE | FILE_READ_ATTRIBUTES,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr,
diff --git a/dll/win32/ubtrfs/ubtrfs.rc b/dll/win32/ubtrfs/ubtrfs.rc
index c12381e9f56..2b17773476b 100644
--- a/dll/win32/ubtrfs/ubtrfs.rc
+++ b/dll/win32/ubtrfs/ubtrfs.rc
@@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,7,7,0
- PRODUCTVERSION 1,7,7,0
+ FILEVERSION 1,7,8,0
+ PRODUCTVERSION 1,7,8,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -68,12 +68,12 @@ BEGIN
BLOCK "080904b0"
BEGIN
VALUE "FileDescription", "Btrfs utility DLL"
- VALUE "FileVersion", "1.7.7"
+ VALUE "FileVersion", "1.7.8"
VALUE "InternalName", "ubtrfs"
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone
2016-21"
VALUE "OriginalFilename", "ubtrfs.dll"
VALUE "ProductName", "WinBtrfs"
- VALUE "ProductVersion", "1.7.7"
+ VALUE "ProductVersion", "1.7.8"
END
END
BLOCK "VarFileInfo"
diff --git a/drivers/filesystems/btrfs/balance.c b/drivers/filesystems/btrfs/balance.c
index 6f2b5e55091..143151d001a 100644
--- a/drivers/filesystems/btrfs/balance.c
+++ b/drivers/filesystems/btrfs/balance.c
@@ -68,10 +68,6 @@ typedef struct {
LIST_ENTRY list_entry;
} data_reloc_ref;
-#ifndef _MSC_VER // not in mingw yet
-#define DEVICE_DSM_FLAG_TRIM_NOT_FS_ALLOCATED 0x80000000
-#endif
-
#define BALANCE_UNIT 0x100000 // only read 1 MB at a time
static NTSTATUS add_metadata_reloc(_Requires_exclusive_lock_held_(_Curr_->tree_lock)
device_extension* Vcb, LIST_ENTRY* items, traverse_ptr* tp,
diff --git a/drivers/filesystems/btrfs/btrfs.c b/drivers/filesystems/btrfs/btrfs.c
index 6c821f12534..efd80d94357 100644
--- a/drivers/filesystems/btrfs/btrfs.c
+++ b/drivers/filesystems/btrfs/btrfs.c
@@ -397,7 +397,7 @@ static bool get_last_inode(_In_
_Requires_exclusive_lock_held_(_Curr_->tree_lock
return false;
}
- if (tp.item->key.obj_type == TYPE_INODE_ITEM || (tp.item->key.obj_type ==
TYPE_ROOT_ITEM && !(tp.item->key.obj_id & 0x8000000000000000))) {
+ if ((tp.item->key.obj_type == TYPE_INODE_ITEM || tp.item->key.obj_type ==
TYPE_ROOT_ITEM) && tp.item->key.obj_id <= BTRFS_LAST_FREE_OBJECTID) {
r->lastinode = tp.item->key.obj_id;
TRACE("last inode for tree %I64x is %I64x\n", r->id,
r->lastinode);
return true;
@@ -408,7 +408,7 @@ static bool get_last_inode(_In_
_Requires_exclusive_lock_held_(_Curr_->tree_lock
TRACE("moving on to %I64x,%x,%I64x\n", tp.item->key.obj_id,
tp.item->key.obj_type, tp.item->key.offset);
- if (tp.item->key.obj_type == TYPE_INODE_ITEM || (tp.item->key.obj_type ==
TYPE_ROOT_ITEM && !(tp.item->key.obj_id & 0x8000000000000000))) {
+ if ((tp.item->key.obj_type == TYPE_INODE_ITEM || tp.item->key.obj_type ==
TYPE_ROOT_ITEM) && tp.item->key.obj_id <= BTRFS_LAST_FREE_OBJECTID) {
r->lastinode = tp.item->key.obj_id;
TRACE("last inode for tree %I64x is %I64x\n", r->id,
r->lastinode);
return true;
diff --git a/drivers/filesystems/btrfs/btrfs.h b/drivers/filesystems/btrfs/btrfs.h
index 6ff680234df..b0b7fbd0015 100644
--- a/drivers/filesystems/btrfs/btrfs.h
+++ b/drivers/filesystems/btrfs/btrfs.h
@@ -15,6 +15,7 @@ static const uint64_t superblock_addrs[] = { 0x10000, 0x4000000,
0x4000000000, 0
#define BTRFS_MAGIC 0x4d5f53665248425f
#define MAX_LABEL_SIZE 0x100
#define SUBVOL_ROOT_INODE 0x100
+#define BTRFS_LAST_FREE_OBJECTID 0xffffffffffffff00
#define TYPE_INODE_ITEM 0x01
#define TYPE_INODE_REF 0x0C
diff --git a/drivers/filesystems/btrfs/btrfs.inf b/drivers/filesystems/btrfs/btrfs.inf
index e0f6148cdae..b5fa3da9136 100644
--- a/drivers/filesystems/btrfs/btrfs.inf
+++ b/drivers/filesystems/btrfs/btrfs.inf
@@ -10,7 +10,7 @@ Signature = "$Windows NT$"
Class = Volume
ClassGuid = {71a27cdd-812a-11d0-bec7-08002be2092f}
Provider = %Me%
-DriverVer = 04/12/2021,1.7.7.0
+DriverVer = 06/07/2021,1.7.8.0
CatalogFile = btrfs.cat
[DestinationDirs]
diff --git a/drivers/filesystems/btrfs/btrfs.rc b/drivers/filesystems/btrfs/btrfs.rc
index b4358b2419d..72a541c3f69 100644
--- a/drivers/filesystems/btrfs/btrfs.rc
+++ b/drivers/filesystems/btrfs/btrfs.rc
@@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,7,7,0
- PRODUCTVERSION 1,7,7,0
+ FILEVERSION 1,7,8,0
+ PRODUCTVERSION 1,7,8,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -68,12 +68,12 @@ BEGIN
BLOCK "080904b0"
BEGIN
VALUE "FileDescription", "WinBtrfs"
- VALUE "FileVersion", "1.7.7"
+ VALUE "FileVersion", "1.7.8"
VALUE "InternalName", "btrfs"
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone
2016-21"
VALUE "OriginalFilename", "btrfs.sys"
VALUE "ProductName", "WinBtrfs"
- VALUE "ProductVersion", "1.7.7"
+ VALUE "ProductVersion", "1.7.8"
END
END
BLOCK "VarFileInfo"
diff --git a/drivers/filesystems/btrfs/btrfs_drv.h
b/drivers/filesystems/btrfs/btrfs_drv.h
index 106332d77c4..597e5d62794 100644
--- a/drivers/filesystems/btrfs/btrfs_drv.h
+++ b/drivers/filesystems/btrfs/btrfs_drv.h
@@ -126,7 +126,7 @@ C_ASSERT(sizeof(bool) == 1);
#define BTRFS_VOLUME_PREFIX L"\\Device\\Btrfs{"
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__clang__)
#define try __try
#define except __except
#define finally __finally
@@ -1633,7 +1633,7 @@ extern BTRFS_UUID boot_uuid;
// not in mingw yet
#ifndef _MSC_VER
typedef struct {
- FSRTL_COMMON_FCB_HEADER DUMMYSTRUCTNAME;
+ FSRTL_COMMON_FCB_HEADER Header;
PFAST_MUTEX FastMutex;
LIST_ENTRY FilterContexts;
EX_PUSH_LOCK PushLock;
@@ -1652,7 +1652,7 @@ typedef struct {
#endif
#else
typedef struct {
- FSRTL_COMMON_FCB_HEADER DUMMYSTRUCTNAME;
+ FSRTL_COMMON_FCB_HEADER Header;
PFAST_MUTEX FastMutex;
LIST_ENTRY FilterContexts;
EX_PUSH_LOCK PushLock;
diff --git a/drivers/filesystems/btrfs/dirctrl.c b/drivers/filesystems/btrfs/dirctrl.c
index a7f7f0c0953..6b7b66cba4f 100644
--- a/drivers/filesystems/btrfs/dirctrl.c
+++ b/drivers/filesystems/btrfs/dirctrl.c
@@ -727,6 +727,13 @@ next:
if (!dc)
return STATUS_NO_MORE_FILES;
+ if (dc->root_dir && fileref->parent) { // hide $Root dir unless in
apparent root, to avoid recursion
+ if (dc->list_entry_index.Flink ==
&fileref->fcb->dir_children_index)
+ return STATUS_NO_MORE_FILES;
+
+ dc = CONTAINING_RECORD(dc->list_entry_index.Flink, dir_child,
list_entry_index);
+ }
+
de->key = dc->key;
de->name = dc->name;
de->type = dc->type;
diff --git a/drivers/filesystems/btrfs/flushthread.c
b/drivers/filesystems/btrfs/flushthread.c
index e6354b36822..565f400c4b5 100644
--- a/drivers/filesystems/btrfs/flushthread.c
+++ b/drivers/filesystems/btrfs/flushthread.c
@@ -46,10 +46,6 @@ typedef struct {
static NTSTATUS create_chunk(device_extension* Vcb, chunk* c, PIRP Irp);
static NTSTATUS update_tree_extents(device_extension* Vcb, tree* t, PIRP Irp, LIST_ENTRY*
rollback);
-#ifndef _MSC_VER // not in mingw yet
-#define DEVICE_DSM_FLAG_TRIM_NOT_FS_ALLOCATED 0x80000000
-#endif
-
_Function_class_(IO_COMPLETION_ROUTINE)
static NTSTATUS __stdcall write_completion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID
conptr) {
write_context* context = conptr;
diff --git a/drivers/filesystems/btrfs/fsctl.c b/drivers/filesystems/btrfs/fsctl.c
index 8ad58df883f..310816c272f 100644
--- a/drivers/filesystems/btrfs/fsctl.c
+++ b/drivers/filesystems/btrfs/fsctl.c
@@ -36,10 +36,6 @@
#define SEF_AVOID_PRIVILEGE_CHECK 0x08 // on MSDN but not in any header files(?)
-#ifndef _MSC_VER // not in mingw yet
-#define DEVICE_DSM_FLAG_TRIM_NOT_FS_ALLOCATED 0x80000000
-#endif
-
#define SEF_SACL_AUTO_INHERIT 0x02
extern LIST_ENTRY VcbList;
@@ -5030,7 +5026,7 @@ static NTSTATUS get_retrieval_pointers(device_extension* Vcb,
PFILE_OBJECT FileO
ExAcquireResourceSharedLite(fcb->Header.Resource, true);
- try {
+ _SEH2_TRY {
LIST_ENTRY* le = fcb->extents.Flink;
extent* first_ext = NULL;
unsigned int num_extents = 0, first_extent_num = 0, i;
@@ -5067,7 +5063,7 @@ static NTSTATUS get_retrieval_pointers(device_extension* Vcb,
PFILE_OBJECT FileO
if (!first_ext) {
Status = STATUS_END_OF_FILE;
- leave;
+ _SEH2_LEAVE;
}
out->ExtentCount = num_extents - first_extent_num;
@@ -5090,7 +5086,7 @@ static NTSTATUS get_retrieval_pointers(device_extension* Vcb,
PFILE_OBJECT FileO
if (ext->offset > last_off) {
if (outlen < sizeof(LARGE_INTEGER) + sizeof(LARGE_INTEGER)) {
Status = STATUS_BUFFER_OVERFLOW;
- leave;
+ _SEH2_LEAVE;
}
out->Extents[i].NextVcn.QuadPart = ext->offset >>
Vcb->sector_shift;
@@ -5103,7 +5099,7 @@ static NTSTATUS get_retrieval_pointers(device_extension* Vcb,
PFILE_OBJECT FileO
if (outlen < sizeof(LARGE_INTEGER) + sizeof(LARGE_INTEGER)) {
Status = STATUS_BUFFER_OVERFLOW;
- leave;
+ _SEH2_LEAVE;
}
out->Extents[i].NextVcn.QuadPart = (ext->offset +
ext->extent_data.decoded_size) >> Vcb->sector_shift;
@@ -5125,7 +5121,7 @@ static NTSTATUS get_retrieval_pointers(device_extension* Vcb,
PFILE_OBJECT FileO
if (num_sectors << Vcb->sector_shift > last_off) {
if (outlen < sizeof(LARGE_INTEGER) + sizeof(LARGE_INTEGER)) {
Status = STATUS_BUFFER_OVERFLOW;
- leave;
+ _SEH2_LEAVE;
}
out->Extents[i].NextVcn.QuadPart = num_sectors;
@@ -5136,9 +5132,9 @@ static NTSTATUS get_retrieval_pointers(device_extension* Vcb,
PFILE_OBJECT FileO
}
Status = STATUS_SUCCESS;
- } finally {
+ } _SEH2_FINALLY {
ExReleaseResourceLite(fcb->Header.Resource);
- }
+ } _SEH2_END;
return Status;
}
@@ -5235,7 +5231,7 @@ static NTSTATUS get_csum_info(device_extension* Vcb, PFILE_OBJECT
FileObject, bt
ExAcquireResourceSharedLite(fcb->Header.Resource, true);
- try {
+ _SEH2_TRY {
LIST_ENTRY* le;
uint8_t* ptr;
uint64_t last_off;
@@ -5244,17 +5240,17 @@ static NTSTATUS get_csum_info(device_extension* Vcb, PFILE_OBJECT
FileObject, bt
if (fcb->ads) {
Status = STATUS_INVALID_DEVICE_REQUEST;
- leave;
+ _SEH2_LEAVE;
}
if (fcb->type == BTRFS_TYPE_DIRECTORY) {
Status = STATUS_FILE_IS_A_DIRECTORY;
- leave;
+ _SEH2_LEAVE;
}
if (fcb->inode_item.flags & BTRFS_INODE_NODATASUM) {
Status = STATUS_INVALID_DEVICE_REQUEST;
- leave;
+ _SEH2_LEAVE;
}
buf->csum_type = Vcb->superblock.csum_type;
@@ -5273,7 +5269,7 @@ static NTSTATUS get_csum_info(device_extension* Vcb, PFILE_OBJECT
FileObject, bt
buf->num_sectors = 0;
*retlen = offsetof(btrfs_csum_info, data[0]);
Status = STATUS_SUCCESS;
- leave;
+ _SEH2_LEAVE;
}
le = le->Flink;
@@ -5284,7 +5280,7 @@ static NTSTATUS get_csum_info(device_extension* Vcb, PFILE_OBJECT
FileObject, bt
if (buflen < offsetof(btrfs_csum_info, data[0]) + (buf->csum_length *
buf->num_sectors)) {
Status = STATUS_BUFFER_OVERFLOW;
*retlen = offsetof(btrfs_csum_info, data[0]);
- leave;
+ _SEH2_LEAVE;
}
ptr = buf->data;
@@ -5333,9 +5329,9 @@ static NTSTATUS get_csum_info(device_extension* Vcb, PFILE_OBJECT
FileObject, bt
*retlen = offsetof(btrfs_csum_info, data[0]) + (buf->csum_length *
buf->num_sectors);
Status = STATUS_SUCCESS;
- } finally {
+ } _SEH2_FINALLY {
ExReleaseResourceLite(fcb->Header.Resource);
- }
+ } _SEH2_END;
return Status;
}
diff --git a/sdk/lib/fslib/btrfslib/btrfslib.c b/sdk/lib/fslib/btrfslib/btrfslib.c
index 7c07cdc1d63..695f2f00e8f 100644
--- a/sdk/lib/fslib/btrfslib/btrfslib.c
+++ b/sdk/lib/fslib/btrfslib/btrfslib.c
@@ -82,8 +82,6 @@ void blake2b(void *out, size_t outlen, const void* in, size_t inlen);
#ifdef __cplusplus
extern "C" {
#endif
-NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle, HANDLE Event,
PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG
FsControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG
OutputBufferLength);
-
NTSTATUS NTAPI NtWriteFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine,
PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer,
ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key);