https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b826992ab257331294e02…
commit b826992ab257331294e02aab698182634eff2b90
Author: Vincent Franchomme <franchomme.vincent(a)gmail.com>
AuthorDate: Thu Apr 28 21:34:24 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.5 (#4417)
v1.7.5 (2020-10-31):
- Fixed text display issue in shell extension
- Added support for mingw 8
- Fixed LXSS permissions not working in new versions of Windows
- Fixed issue where truncating an inline file wouldn't change its size
- Fixed crash with Quibble where driver would try to use AVX2 before Windows had
enabled it
---
dll/shellext/shellbtrfs/balance.cpp | 22 ++---
dll/shellext/shellbtrfs/devices.cpp | 10 +--
dll/shellext/shellbtrfs/propsheet.cpp | 68 ++++++++------
dll/shellext/shellbtrfs/recv.cpp | 4 +-
dll/shellext/shellbtrfs/send.cpp | 4 +-
dll/shellext/shellbtrfs/shellbtrfs.rc | 8 +-
dll/shellext/shellbtrfs/volpropsheet.cpp | 30 +++----
dll/win32/ubtrfs/ubtrfs.rc | 8 +-
drivers/filesystems/btrfs/btrfs.c | 24 +++--
drivers/filesystems/btrfs/btrfs.inf | 2 +-
drivers/filesystems/btrfs/btrfs.rc | 8 +-
drivers/filesystems/btrfs/btrfs_drv.h | 9 --
drivers/filesystems/btrfs/create.c | 150 ++++++++++---------------------
drivers/filesystems/btrfs/fileinfo.c | 6 +-
drivers/filesystems/btrfs/write.c | 8 ++
15 files changed, 166 insertions(+), 195 deletions(-)
diff --git a/dll/shellext/shellbtrfs/balance.cpp b/dll/shellext/shellbtrfs/balance.cpp
index baa2d07ce38..345583eb0e8 100644
--- a/dll/shellext/shellbtrfs/balance.cpp
+++ b/dll/shellext/shellbtrfs/balance.cpp
@@ -42,7 +42,9 @@
#include <shlwapi.h>
#include <uxtheme.h>
-static uint64_t convtypes2[] = { BLOCK_FLAG_SINGLE, BLOCK_FLAG_DUPLICATE,
BLOCK_FLAG_RAID0, BLOCK_FLAG_RAID1, BLOCK_FLAG_RAID5, BLOCK_FLAG_RAID6, BLOCK_FLAG_RAID10
};
+static uint64_t convtypes2[] = { BLOCK_FLAG_SINGLE, BLOCK_FLAG_DUPLICATE,
BLOCK_FLAG_RAID0, BLOCK_FLAG_RAID1,
+ BLOCK_FLAG_RAID5, BLOCK_FLAG_RAID1C3, BLOCK_FLAG_RAID6,
BLOCK_FLAG_RAID10,
+ BLOCK_FLAG_RAID1C4 };
static WCHAR hex_digit(uint8_t u) {
if (u >= 0xa && u <= 0xf)
@@ -245,7 +247,7 @@ void BtrfsBalance::RefreshBalanceDlg(HWND hwndDlg, bool first) {
CheckDlgButton(hwndDlg, IDC_METADATA, BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SYSTEM, BST_UNCHECKED);
- SendMessage(GetDlgItem(hwndDlg, IDC_BALANCE_PROGRESS), PBM_SETPOS, 0,
0);
+ SendMessageW(GetDlgItem(hwndDlg, IDC_BALANCE_PROGRESS), PBM_SETPOS, 0,
0);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_DATA_OPTIONS),
IsDlgButtonChecked(hwndDlg, IDC_DATA) == BST_CHECKED ? true : false);
@@ -566,10 +568,10 @@ INT_PTR CALLBACK BtrfsBalance::BalanceOptsDlgProc(HWND hwndDlg, UINT
uMsg, WPARA
wstring_sprintf(t, u, bd->dev_id, s.c_str());
- SendMessage(devcb, CB_ADDSTRING, 0, (LPARAM)t.c_str());
+ SendMessageW(devcb, CB_ADDSTRING, 0, (LPARAM)t.c_str());
if (opts->devid == bd->dev_id)
- SendMessage(devcb, CB_SETCURSEL, num_devices, 0);
+ SendMessageW(devcb, CB_SETCURSEL, num_devices, 0);
num_devices++;
@@ -592,10 +594,10 @@ INT_PTR CALLBACK BtrfsBalance::BalanceOptsDlgProc(HWND hwndDlg, UINT
uMsg, WPARA
if (!load_string(module, convtypes[i], s))
throw last_error(GetLastError());
- SendMessage(convcb, CB_ADDSTRING, 0, (LPARAM)s.c_str());
+ SendMessageW(convcb, CB_ADDSTRING, 0, (LPARAM)s.c_str());
if (opts->convert == convtypes2[i])
- SendMessage(convcb, CB_SETCURSEL, i, 0);
+ SendMessageW(convcb, CB_SETCURSEL, i, 0);
i++;
@@ -839,10 +841,10 @@ static INT_PTR CALLBACK stub_BalanceOptsDlgProc(HWND hwndDlg, UINT
uMsg, WPARAM
BtrfsBalance* bb;
if (uMsg == WM_INITDIALOG) {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
bb = (BtrfsBalance*)lParam;
} else {
- bb = (BtrfsBalance*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ bb = (BtrfsBalance*)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
}
if (bb)
@@ -964,10 +966,10 @@ static INT_PTR CALLBACK stub_BalanceDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wPar
BtrfsBalance* bb;
if (uMsg == WM_INITDIALOG) {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
bb = (BtrfsBalance*)lParam;
} else {
- bb = (BtrfsBalance*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ bb = (BtrfsBalance*)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
}
if (bb)
diff --git a/dll/shellext/shellbtrfs/devices.cpp b/dll/shellext/shellbtrfs/devices.cpp
index e95cace5c52..26613ba1707 100644
--- a/dll/shellext/shellbtrfs/devices.cpp
+++ b/dll/shellext/shellbtrfs/devices.cpp
@@ -75,7 +75,7 @@ static void find_devices(HWND hwnd, const GUID* guid, const
mountmgr& mm, vector
static const wstring dosdevices = L"\\DosDevices\\";
- h = SetupDiGetClassDevs(guid, nullptr, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
+ h = SetupDiGetClassDevsW(guid, nullptr, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
if (h != INVALID_HANDLE_VALUE) {
DWORD index = 0;
@@ -629,10 +629,10 @@ static INT_PTR CALLBACK stub_DeviceAddDlgProc(HWND hwndDlg, UINT
uMsg, WPARAM wP
BtrfsDeviceAdd* bda;
if (uMsg == WM_INITDIALOG) {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
bda = (BtrfsDeviceAdd*)lParam;
} else {
- bda = (BtrfsDeviceAdd*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ bda = (BtrfsDeviceAdd*)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
}
if (bda)
@@ -824,10 +824,10 @@ static INT_PTR CALLBACK stub_DeviceResizeDlgProc(HWND hwndDlg, UINT
uMsg, WPARAM
BtrfsDeviceResize* bdr;
if (uMsg == WM_INITDIALOG) {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
bdr = (BtrfsDeviceResize*)lParam;
} else
- bdr = (BtrfsDeviceResize*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ bdr = (BtrfsDeviceResize*)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
if (bdr)
return bdr->DeviceResizeDlgProc(hwndDlg, uMsg, wParam, lParam);
diff --git a/dll/shellext/shellbtrfs/propsheet.cpp
b/dll/shellext/shellbtrfs/propsheet.cpp
index 90ee53b27d2..faa7194e664 100644
--- a/dll/shellext/shellbtrfs/propsheet.cpp
+++ b/dll/shellext/shellbtrfs/propsheet.cpp
@@ -435,11 +435,11 @@ void BtrfsPropSheet::set_cmdline(const wstring& cmdline) {
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS |
FILE_FLAG_OPEN_REPARSE_POINT, nullptr);
if (h == INVALID_HANDLE_VALUE)
- return;
+ throw last_error(GetLastError());
Status = NtQueryInformationFile(h, &iosb, &fai,
sizeof(FILE_ACCESS_INFORMATION), FileAccessInformation);
if (!NT_SUCCESS(Status))
- return;
+ throw ntstatus_error(Status);
if (fai.AccessFlags & FILE_READ_ATTRIBUTES)
can_change_perms = fai.AccessFlags & WRITE_DAC;
@@ -453,7 +453,10 @@ void BtrfsPropSheet::set_cmdline(const wstring& cmdline) {
Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb,
FSCTL_BTRFS_GET_INODE_INFO, nullptr, 0, &bii2, sizeof(btrfs_inode_info));
- if (NT_SUCCESS(Status) && !bii2.top) {
+ if (!NT_SUCCESS(Status))
+ throw ntstatus_error(Status);
+
+ if (!bii2.top) {
LARGE_INTEGER filesize;
subvol = bii2.subvol;
@@ -740,7 +743,7 @@ void BtrfsPropSheet::set_size_on_disk(HWND hwndDlg) {
if (cr != old_text)
SetDlgItemTextW(hwndDlg, IDC_COMPRESSION_RATIO, cr.c_str());
- uint64_t extent_size = (allocsize - sparsesize - sizes[0]) / sector_size;
+ uint64_t extent_size = (allocsize - sparsesize - sizes[0]) / (sector_size == 0 ? 4096
: sector_size);
if (num_extents == 0 || extent_size <= 1)
ratio = 0.0f;
@@ -751,7 +754,6 @@ void BtrfsPropSheet::set_size_on_disk(HWND hwndDlg) {
GetDlgItemTextW(hwndDlg, IDC_FRAGMENTATION, old_text, sizeof(old_text) /
sizeof(WCHAR));
-
if (frag != old_text)
SetDlgItemTextW(hwndDlg, IDC_FRAGMENTATION, frag.c_str());
}
@@ -813,7 +815,7 @@ static INT_PTR CALLBACK SizeDetailsDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wPara
{
BtrfsPropSheet* bps = (BtrfsPropSheet*)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)bps);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)bps);
bps->update_size_details_dialog(hwndDlg);
@@ -832,7 +834,7 @@ static INT_PTR CALLBACK SizeDetailsDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wPara
case WM_TIMER:
{
- BtrfsPropSheet* bps = (BtrfsPropSheet*)GetWindowLongPtr(hwndDlg,
GWLP_USERDATA);
+ BtrfsPropSheet* bps = (BtrfsPropSheet*)GetWindowLongPtrW(hwndDlg,
GWLP_USERDATA);
if (bps) {
bps->update_size_details_dialog(hwndDlg);
@@ -853,18 +855,18 @@ static INT_PTR CALLBACK SizeDetailsDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wPara
static void set_check_box(HWND hwndDlg, ULONG id, uint64_t min, uint64_t max) {
if (min && max) {
- SendDlgItemMessage(hwndDlg, id, BM_SETCHECK, BST_CHECKED, 0);
+ SendDlgItemMessageW(hwndDlg, id, BM_SETCHECK, BST_CHECKED, 0);
} else if (!min && !max) {
- SendDlgItemMessage(hwndDlg, id, BM_SETCHECK, BST_UNCHECKED, 0);
+ SendDlgItemMessageW(hwndDlg, id, BM_SETCHECK, BST_UNCHECKED, 0);
} else {
LONG_PTR style;
- style = GetWindowLongPtr(GetDlgItem(hwndDlg, id), GWL_STYLE);
+ style = GetWindowLongPtrW(GetDlgItem(hwndDlg, id), GWL_STYLE);
style &= ~BS_AUTOCHECKBOX;
style |= BS_AUTO3STATE;
- SetWindowLongPtr(GetDlgItem(hwndDlg, id), GWL_STYLE, style);
+ SetWindowLongPtrW(GetDlgItem(hwndDlg, id), GWL_STYLE, style);
- SendDlgItemMessage(hwndDlg, id, BM_SETCHECK, BST_INDETERMINATE, 0);
+ SendDlgItemMessageW(hwndDlg, id, BM_SETCHECK, BST_INDETERMINATE, 0);
}
}
@@ -995,13 +997,13 @@ void BtrfsPropSheet::init_propsheet(HWND hwndDlg) {
comptype = GetDlgItem(hwndDlg, IDC_COMPRESS_TYPE);
- while (SendMessage(comptype, CB_GETCOUNT, 0, 0) > 0) {
- SendMessage(comptype, CB_DELETESTRING, 0, 0);
+ while (SendMessageW(comptype, CB_GETCOUNT, 0, 0) > 0) {
+ SendMessageW(comptype, CB_DELETESTRING, 0, 0);
}
if (min_compression_type != max_compression_type) {
- SendMessage(comptype, CB_ADDSTRING, 0, (LPARAM)L"");
- SendMessage(comptype, CB_SETCURSEL, 0, 0);
+ SendMessageW(comptype, CB_ADDSTRING, 0, (LPARAM)L"");
+ SendMessageW(comptype, CB_SETCURSEL, 0, 0);
}
i = 0;
@@ -1011,13 +1013,13 @@ void BtrfsPropSheet::init_propsheet(HWND hwndDlg) {
if (!load_string(module, comp_types[i], t))
throw last_error(GetLastError());
- SendMessage(comptype, CB_ADDSTRING, 0, (LPARAM)t.c_str());
+ SendMessageW(comptype, CB_ADDSTRING, 0, (LPARAM)t.c_str());
i++;
}
if (min_compression_type == max_compression_type) {
- SendMessage(comptype, CB_SETCURSEL, min_compression_type, 0);
+ SendMessageW(comptype, CB_SETCURSEL, min_compression_type, 0);
compress_type = min_compression_type;
}
@@ -1087,12 +1089,12 @@ static INT_PTR CALLBACK PropSheetDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,
switch (uMsg) {
case WM_INITDIALOG:
{
- PROPSHEETPAGE* psp = (PROPSHEETPAGE*)lParam;
+ PROPSHEETPAGEW* psp = (PROPSHEETPAGEW*)lParam;
BtrfsPropSheet* bps = (BtrfsPropSheet*)psp->lParam;
EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)bps);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)bps);
bps->init_propsheet(hwndDlg);
@@ -1101,7 +1103,7 @@ static INT_PTR CALLBACK PropSheetDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,
case WM_COMMAND:
{
- BtrfsPropSheet* bps = (BtrfsPropSheet*)GetWindowLongPtr(hwndDlg,
GWLP_USERDATA);
+ BtrfsPropSheet* bps = (BtrfsPropSheet*)GetWindowLongPtrW(hwndDlg,
GWLP_USERDATA);
if (bps && !bps->readonly) {
switch (HIWORD(wParam)) {
@@ -1256,7 +1258,7 @@ static INT_PTR CALLBACK PropSheetDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,
break;
case PSN_APPLY: {
- BtrfsPropSheet* bps = (BtrfsPropSheet*)GetWindowLongPtr(hwndDlg,
GWLP_USERDATA);
+ BtrfsPropSheet* bps = (BtrfsPropSheet*)GetWindowLongPtrW(hwndDlg,
GWLP_USERDATA);
bps->apply_changes(hwndDlg);
SetWindowLongPtrW(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
@@ -1269,7 +1271,7 @@ static INT_PTR CALLBACK PropSheetDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,
PNMLINK pNMLink = (PNMLINK)lParam;
if (pNMLink->item.iLink == 0)
- DialogBoxParamW(module,
MAKEINTRESOURCEW(IDD_SIZE_DETAILS), hwndDlg, SizeDetailsDlgProc, GetWindowLongPtr(hwndDlg,
GWLP_USERDATA));
+ DialogBoxParamW(module,
MAKEINTRESOURCEW(IDD_SIZE_DETAILS), hwndDlg, SizeDetailsDlgProc,
GetWindowLongPtrW(hwndDlg, GWLP_USERDATA));
}
break;
}
@@ -1278,7 +1280,7 @@ static INT_PTR CALLBACK PropSheetDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,
case WM_TIMER:
{
- BtrfsPropSheet* bps = (BtrfsPropSheet*)GetWindowLongPtr(hwndDlg,
GWLP_USERDATA);
+ BtrfsPropSheet* bps = (BtrfsPropSheet*)GetWindowLongPtrW(hwndDlg,
GWLP_USERDATA);
if (bps) {
bps->set_size_on_disk(hwndDlg);
@@ -1299,7 +1301,7 @@ static INT_PTR CALLBACK PropSheetDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,
HRESULT __stdcall BtrfsPropSheet::AddPages(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM
lParam) {
try {
- PROPSHEETPAGE psp;
+ PROPSHEETPAGEW psp;
HPROPSHEETPAGE hPage;
INITCOMMONCONTROLSEX icex;
@@ -1315,15 +1317,15 @@ HRESULT __stdcall BtrfsPropSheet::AddPages(LPFNADDPROPSHEETPAGE
pfnAddPage, LPAR
psp.dwSize = sizeof(psp);
psp.dwFlags = PSP_USEREFPARENT | PSP_USETITLE;
psp.hInstance = module;
- psp.pszTemplate = MAKEINTRESOURCE(IDD_PROP_SHEET);
+ psp.pszTemplate = MAKEINTRESOURCEW(IDD_PROP_SHEET);
psp.hIcon = 0;
- psp.pszTitle = MAKEINTRESOURCE(IDS_PROP_SHEET_TITLE);
+ psp.pszTitle = MAKEINTRESOURCEW(IDS_PROP_SHEET_TITLE);
psp.pfnDlgProc = (DLGPROC)PropSheetDlgProc;
psp.pcRefParent = (UINT*)&objs_loaded;
psp.pfnCallback = nullptr;
psp.lParam = (LPARAM)this;
- hPage = CreatePropertySheetPage(&psp);
+ hPage = CreatePropertySheetPageW(&psp);
if (hPage) {
if (pfnAddPage(hPage, lParam)) {
@@ -1353,6 +1355,7 @@ void CALLBACK ShowPropSheetW(HWND hwnd, HINSTANCE hinst, LPWSTR
lpszCmdLine, int
BtrfsPropSheet bps;
PROPSHEETPAGEW psp;
PROPSHEETHEADERW psh;
+ INITCOMMONCONTROLSEX icex;
wstring title;
set_dpi_aware();
@@ -1361,6 +1364,12 @@ void CALLBACK ShowPropSheetW(HWND hwnd, HINSTANCE hinst, LPWSTR
lpszCmdLine, int
bps.set_cmdline(lpszCmdLine);
+ icex.dwSize = sizeof(icex);
+ icex.dwICC = ICC_LINK_CLASS;
+
+ if (!InitCommonControlsEx(&icex))
+ throw string_error(IDS_INITCOMMONCONTROLSEX_FAILED);
+
psp.dwSize = sizeof(psp);
psp.dwFlags = PSP_USETITLE;
psp.hInstance = module;
@@ -1381,7 +1390,8 @@ void CALLBACK ShowPropSheetW(HWND hwnd, HINSTANCE hinst, LPWSTR
lpszCmdLine, int
psh.nPages = 1;
psh.ppsp = &psp;
- PropertySheetW(&psh);
+ if (PropertySheetW(&psh) < 0)
+ throw last_error(GetLastError());
} catch (const exception& e) {
error_message(hwnd, e.what());
}
diff --git a/dll/shellext/shellbtrfs/recv.cpp b/dll/shellext/shellbtrfs/recv.cpp
index 0c1ff3ef589..0dc3bf859bb 100644
--- a/dll/shellext/shellbtrfs/recv.cpp
+++ b/dll/shellext/shellbtrfs/recv.cpp
@@ -1513,10 +1513,10 @@ static INT_PTR CALLBACK stub_RecvProgressDlgProc(HWND hwndDlg,
UINT uMsg, WPARAM
BtrfsRecv* br;
if (uMsg == WM_INITDIALOG) {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
br = (BtrfsRecv*)lParam;
} else {
- br = (BtrfsRecv*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ br = (BtrfsRecv*)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
}
if (br)
diff --git a/dll/shellext/shellbtrfs/send.cpp b/dll/shellext/shellbtrfs/send.cpp
index 74ba33774e0..b4f242f73c1 100644
--- a/dll/shellext/shellbtrfs/send.cpp
+++ b/dll/shellext/shellbtrfs/send.cpp
@@ -514,10 +514,10 @@ static INT_PTR CALLBACK stub_SendDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,
BtrfsSend* bs;
if (uMsg == WM_INITDIALOG) {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
bs = (BtrfsSend*)lParam;
} else
- bs = (BtrfsSend*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ bs = (BtrfsSend*)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
if (bs)
return bs->SendDlgProc(hwndDlg, uMsg, wParam, lParam);
diff --git a/dll/shellext/shellbtrfs/shellbtrfs.rc
b/dll/shellext/shellbtrfs/shellbtrfs.rc
index 4b6bbe2e883..4852681751d 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,4,0
- PRODUCTVERSION 1,7,4,0
+ FILEVERSION 1,7,5,0
+ PRODUCTVERSION 1,7,5,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -78,12 +78,12 @@ BEGIN
BLOCK "080904b0"
BEGIN
VALUE "FileDescription", "WinBtrfs shell extension"
- VALUE "FileVersion", "1.7.4"
+ VALUE "FileVersion", "1.7.5"
VALUE "InternalName", "btrfs"
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone
2016-20"
VALUE "OriginalFilename", "shellbtrfs.dll"
VALUE "ProductName", "WinBtrfs"
- VALUE "ProductVersion", "1.7.4"
+ VALUE "ProductVersion", "1.7.5"
END
END
BLOCK "VarFileInfo"
diff --git a/dll/shellext/shellbtrfs/volpropsheet.cpp
b/dll/shellext/shellbtrfs/volpropsheet.cpp
index ddc7dc24af0..128ac8e42b5 100644
--- a/dll/shellext/shellbtrfs/volpropsheet.cpp
+++ b/dll/shellext/shellbtrfs/volpropsheet.cpp
@@ -567,10 +567,10 @@ static INT_PTR CALLBACK stub_UsageDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam
BtrfsVolPropSheet* bvps;
if (uMsg == WM_INITDIALOG) {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
bvps = (BtrfsVolPropSheet*)lParam;
} else {
- bvps = (BtrfsVolPropSheet*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ bvps = (BtrfsVolPropSheet*)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
}
if (bvps)
@@ -943,10 +943,10 @@ static INT_PTR CALLBACK stub_StatsDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam
BtrfsVolPropSheet* bvps;
if (uMsg == WM_INITDIALOG) {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
bvps = (BtrfsVolPropSheet*)lParam;
} else {
- bvps = (BtrfsVolPropSheet*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ bvps = (BtrfsVolPropSheet*)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
}
if (bvps)
@@ -1250,10 +1250,10 @@ static INT_PTR CALLBACK stub_DeviceDlgProc(HWND hwndDlg, UINT
uMsg, WPARAM wPara
BtrfsVolPropSheet* bvps;
if (uMsg == WM_INITDIALOG) {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
bvps = (BtrfsVolPropSheet*)lParam;
} else {
- bvps = (BtrfsVolPropSheet*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ bvps = (BtrfsVolPropSheet*)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
}
if (bvps)
@@ -1331,13 +1331,13 @@ static INT_PTR CALLBACK PropSheetDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,
switch (uMsg) {
case WM_INITDIALOG:
{
- PROPSHEETPAGE* psp = (PROPSHEETPAGE*)lParam;
+ PROPSHEETPAGEW* psp = (PROPSHEETPAGEW*)lParam;
BtrfsVolPropSheet* bps = (BtrfsVolPropSheet*)psp->lParam;
btrfs_device* bd;
EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)bps);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)bps);
bps->readonly = true;
bd = bps->devices;
@@ -1386,7 +1386,7 @@ static INT_PTR CALLBACK PropSheetDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,
case WM_COMMAND:
{
- BtrfsVolPropSheet* bps = (BtrfsVolPropSheet*)GetWindowLongPtr(hwndDlg,
GWLP_USERDATA);
+ BtrfsVolPropSheet* bps = (BtrfsVolPropSheet*)GetWindowLongPtrW(hwndDlg,
GWLP_USERDATA);
if (bps) {
switch (HIWORD(wParam)) {
@@ -1428,7 +1428,7 @@ static INT_PTR CALLBACK PropSheetDlgProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,
HRESULT __stdcall BtrfsVolPropSheet::AddPages(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM
lParam) {
try {
- PROPSHEETPAGE psp;
+ PROPSHEETPAGEW psp;
HPROPSHEETPAGE hPage;
INITCOMMONCONTROLSEX icex;
@@ -1444,15 +1444,15 @@ HRESULT __stdcall BtrfsVolPropSheet::AddPages(LPFNADDPROPSHEETPAGE
pfnAddPage, L
psp.dwSize = sizeof(psp);
psp.dwFlags = PSP_USEREFPARENT | PSP_USETITLE;
psp.hInstance = module;
- psp.pszTemplate = MAKEINTRESOURCE(IDD_VOL_PROP_SHEET);
+ psp.pszTemplate = MAKEINTRESOURCEW(IDD_VOL_PROP_SHEET);
psp.hIcon = 0;
- psp.pszTitle = MAKEINTRESOURCE(IDS_VOL_PROP_SHEET_TITLE);
+ psp.pszTitle = MAKEINTRESOURCEW(IDS_VOL_PROP_SHEET_TITLE);
psp.pfnDlgProc = (DLGPROC)PropSheetDlgProc;
psp.pcRefParent = (UINT*)&objs_loaded;
psp.pfnCallback = nullptr;
psp.lParam = (LPARAM)this;
- hPage = CreatePropertySheetPage(&psp);
+ hPage = CreatePropertySheetPageW(&psp);
if (hPage) {
if (pfnAddPage(hPage, lParam)) {
@@ -1594,10 +1594,10 @@ static INT_PTR __stdcall dlg_proc(HWND hwndDlg, UINT uMsg, WPARAM
wParam, LPARAM
BtrfsChangeDriveLetter* bcdl;
if (uMsg == WM_INITDIALOG) {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
bcdl = (BtrfsChangeDriveLetter*)lParam;
} else
- bcdl = (BtrfsChangeDriveLetter*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ bcdl = (BtrfsChangeDriveLetter*)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
return bcdl->DlgProc(hwndDlg, uMsg, wParam, lParam);
}
diff --git a/dll/win32/ubtrfs/ubtrfs.rc b/dll/win32/ubtrfs/ubtrfs.rc
index 903edb0c9a5..686e30e7b3c 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,4,0
- PRODUCTVERSION 1,7,4,0
+ FILEVERSION 1,7,5,0
+ PRODUCTVERSION 1,7,5,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -68,12 +68,12 @@ BEGIN
BLOCK "080904b0"
BEGIN
VALUE "FileDescription", "Btrfs utility DLL"
- VALUE "FileVersion", "1.7.4"
+ VALUE "FileVersion", "1.7.5"
VALUE "InternalName", "ubtrfs"
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone
2016-20"
VALUE "OriginalFilename", "ubtrfs.dll"
VALUE "ProductName", "WinBtrfs"
- VALUE "ProductVersion", "1.7.4"
+ VALUE "ProductVersion", "1.7.5"
END
END
BLOCK "VarFileInfo"
diff --git a/drivers/filesystems/btrfs/btrfs.c b/drivers/filesystems/btrfs/btrfs.c
index 4824af9c87b..2f2932f1205 100644
--- a/drivers/filesystems/btrfs/btrfs.c
+++ b/drivers/filesystems/btrfs/btrfs.c
@@ -5923,7 +5923,7 @@ static void check_cpu() {
#ifndef _MSC_VER
{
- uint32_t eax, ebx, ecx, edx, xcr0;
+ uint32_t eax, ebx, ecx, edx;
__cpuid(1, eax, ebx, ecx, edx);
@@ -5935,10 +5935,17 @@ static void check_cpu() {
if (__get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx))
have_avx2 = ebx & bit_AVX2;
- if (have_avx2) { // check if supported by OS
- __asm__("xgetbv" : "=a" (xcr0) : "c" (0) :
"edx" );
+ if (have_avx2) {
+ // check Windows has enabled AVX2 - Windows 10 doesn't immediately
+
+ if (__readcr4() & (1 << 18)) {
+ uint32_t xcr0;
+
+ __asm__("xgetbv" : "=a" (xcr0) : "c" (0) :
"edx" );
- if ((xcr0 & 6) != 6)
+ if ((xcr0 & 6) != 6)
+ have_avx2 = false;
+ } else
have_avx2 = false;
}
}
@@ -5954,9 +5961,14 @@ static void check_cpu() {
have_avx2 = cpu_info[1] & (1 << 5);
if (have_avx2) {
- uint32_t xcr0 = (uint32_t)_xgetbv(0);
+ // check Windows has enabled AVX2 - Windows 10 doesn't immediately
+
+ if (__readcr4() & (1 << 18)) {
+ uint32_t xcr0 = (uint32_t)_xgetbv(0);
- if ((xcr0 & 6) != 6)
+ if ((xcr0 & 6) != 6)
+ have_avx2 = false;
+ } else
have_avx2 = false;
}
}
diff --git a/drivers/filesystems/btrfs/btrfs.inf b/drivers/filesystems/btrfs/btrfs.inf
index 695bc76f0ed..ac8ff69dc4d 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 = 05/24/2020,1.7.3.0
+DriverVer = 10/31/2020,1.7.5.0
CatalogFile = btrfs.cat
[DestinationDirs]
diff --git a/drivers/filesystems/btrfs/btrfs.rc b/drivers/filesystems/btrfs/btrfs.rc
index 8a0116a2646..e7a7ad6c280 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,4,0
- PRODUCTVERSION 1,7,4,0
+ FILEVERSION 1,7,5,0
+ PRODUCTVERSION 1,7,5,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -68,12 +68,12 @@ BEGIN
BLOCK "080904b0"
BEGIN
VALUE "FileDescription", "WinBtrfs"
- VALUE "FileVersion", "1.7.4"
+ VALUE "FileVersion", "1.7.5"
VALUE "InternalName", "btrfs"
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone
2016-20"
VALUE "OriginalFilename", "btrfs.sys"
VALUE "ProductName", "WinBtrfs"
- VALUE "ProductVersion", "1.7.4"
+ VALUE "ProductVersion", "1.7.5"
END
END
BLOCK "VarFileInfo"
diff --git a/drivers/filesystems/btrfs/btrfs_drv.h
b/drivers/filesystems/btrfs/btrfs_drv.h
index 17c58e4e5d5..0e2554adbc3 100644
--- a/drivers/filesystems/btrfs/btrfs_drv.h
+++ b/drivers/filesystems/btrfs/btrfs_drv.h
@@ -201,17 +201,8 @@ typedef struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER {
#ifndef __REACTOS__
#ifndef _MSC_VER
#define __drv_aliasesMem
-#define _Requires_lock_held_(a)
-#define _Requires_exclusive_lock_held_(a)
-#define _Releases_lock_(a)
-#define _Releases_exclusive_lock_(a)
#define _Dispatch_type_(a)
-#define _Create_lock_level_(a)
#define _Lock_level_order_(a,b)
-#define _Has_lock_level_(a)
-#define _Requires_lock_not_held_(a)
-#define _Acquires_exclusive_lock_(a)
-#define _Acquires_shared_lock_(a)
#endif
#endif // __REACTOS__
diff --git a/drivers/filesystems/btrfs/create.c b/drivers/filesystems/btrfs/create.c
index 699228e95a1..25b0b975e53 100644
--- a/drivers/filesystems/btrfs/create.c
+++ b/drivers/filesystems/btrfs/create.c
@@ -3593,22 +3593,19 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
LARGE_INTEGER zero;
if (fileref->fcb->type == BTRFS_TYPE_DIRECTORY ||
is_subvol_readonly(fileref->fcb->subvol, Irp)) {
- free_fileref(fileref);
-
- return STATUS_ACCESS_DENIED;
+ Status = STATUS_ACCESS_DENIED;
+ goto end;
}
if (Vcb->readonly) {
- free_fileref(fileref);
-
- return STATUS_MEDIA_WRITE_PROTECTED;
+ Status = STATUS_MEDIA_WRITE_PROTECTED;
+ goto end;
}
zero.QuadPart = 0;
if (!MmCanFileBeTruncated(&fileref->fcb->nonpaged->segment_object,
&zero)) {
- free_fileref(fileref);
-
- return STATUS_USER_MAPPED_FILE;
+ Status = STATUS_USER_MAPPED_FILE;
+ goto end;
}
}
@@ -3622,10 +3619,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
granted_access, &Status)) {
SeUnlockSubjectContext(&IrpSp->Parameters.Create.SecurityContext->AccessState->SubjectSecurityContext);
TRACE("SeAccessCheck failed, returning %08lx\n", Status);
-
- free_fileref(fileref);
-
- return Status;
+ goto end;
}
SeUnlockSubjectContext(&IrpSp->Parameters.Create.SecurityContext->AccessState->SubjectSecurityContext);
@@ -3638,10 +3632,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
while (sf) {
if (sf->delete_on_close) {
TRACE("could not open as deletion pending\n");
-
- free_fileref(fileref);
-
- return STATUS_DELETE_PENDING;
+ Status = STATUS_DELETE_PENDING;
+ goto end;
}
sf = sf->parent;
}
@@ -3651,9 +3643,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
is_subvol_readonly(fileref->fcb->subvol, Irp) || fileref->fcb ==
Vcb->dummy_fcb || Vcb->readonly;
if (options & FILE_DELETE_ON_CLOSE && (fileref == Vcb->root_fileref ||
readonly)) {
- free_fileref(fileref);
-
- return STATUS_CANNOT_DELETE;
+ Status = STATUS_CANNOT_DELETE;
+ goto end;
}
if (readonly) {
@@ -3681,9 +3672,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
*granted_access &= allowed;
IrpSp->Parameters.Create.SecurityContext->AccessState->PreviouslyGrantedAccess
&= allowed;
} else if (*granted_access & ~allowed) {
- free_fileref(fileref);
-
- return Vcb->readonly ? STATUS_MEDIA_WRITE_PROTECTED :
STATUS_ACCESS_DENIED;
+ Status = Vcb->readonly ? STATUS_MEDIA_WRITE_PROTECTED :
STATUS_ACCESS_DENIED;
+ goto end;
}
}
@@ -3709,24 +3699,20 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
Irp->Tail.Overlay.AuxiliaryBuffer = (void*)data;
- free_fileref(fileref);
-
- return STATUS_REPARSE;
+ Status = STATUS_REPARSE;
+ goto end;
}
}
if (fileref->fcb->type == BTRFS_TYPE_DIRECTORY &&
!fileref->fcb->ads) {
if (options & FILE_NON_DIRECTORY_FILE && !(fileref->fcb->atts
& FILE_ATTRIBUTE_REPARSE_POINT)) {
- free_fileref(fileref);
-
- return STATUS_FILE_IS_A_DIRECTORY;
+ Status = STATUS_FILE_IS_A_DIRECTORY;
+ goto end;
}
} else if (options & FILE_DIRECTORY_FILE) {
TRACE("returning STATUS_NOT_A_DIRECTORY (type = %u)\n",
fileref->fcb->type);
-
- free_fileref(fileref);
-
- return STATUS_NOT_A_DIRECTORY;
+ Status = STATUS_NOT_A_DIRECTORY;
+ goto end;
}
if (fileref->open_count > 0) {
@@ -3738,9 +3724,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
else
WARN("IoCheckShareAccess failed, returning %08lx\n", Status);
- free_fileref(fileref);
-
- return Status;
+ goto end;
}
IoUpdateShareAccess(FileObject, &fileref->fcb->share_access);
@@ -3749,12 +3733,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
if (*granted_access & FILE_WRITE_DATA || options & FILE_DELETE_ON_CLOSE) {
if (!MmFlushImageSection(&fileref->fcb->nonpaged->segment_object,
MmFlushForWrite)) {
-
- IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
-
- free_fileref(fileref);
-
- return (options & FILE_DELETE_ON_CLOSE) ? STATUS_CANNOT_DELETE :
STATUS_SHARING_VIOLATION;
+ Status = (options & FILE_DELETE_ON_CLOSE) ? STATUS_CANNOT_DELETE :
STATUS_SHARING_VIOLATION;
+ goto end2;
}
}
@@ -3762,9 +3742,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
Status = FsRtlCheckOplock(fcb_oplock(fileref->fcb), Irp, NULL, NULL, NULL);
if (!NT_SUCCESS(Status)) {
WARN("FsRtlCheckOplock returned %08lx\n", Status);
- free_fileref(fileref);
-
- return Status;
+ goto end2;
}
if (RequestedDisposition == FILE_OVERWRITE || RequestedDisposition ==
FILE_OVERWRITE_IF || RequestedDisposition == FILE_SUPERSEDE) {
@@ -3774,43 +3752,26 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
if ((RequestedDisposition == FILE_OVERWRITE || RequestedDisposition ==
FILE_OVERWRITE_IF) && readonly) {
WARN("cannot overwrite readonly file\n");
-
- IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
-
- free_fileref(fileref);
-
- return STATUS_ACCESS_DENIED;
+ Status = STATUS_ACCESS_DENIED;
+ goto end2;
}
if (!fileref->fcb->ads &&
(IrpSp->Parameters.Create.FileAttributes & (FILE_ATTRIBUTE_HIDDEN |
FILE_ATTRIBUTE_SYSTEM)) != ((fileref->fcb->atts & (FILE_ATTRIBUTE_SYSTEM |
FILE_ATTRIBUTE_HIDDEN)))) {
- IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
-
- free_fileref(fileref);
-
- return STATUS_ACCESS_DENIED;
+ Status = STATUS_ACCESS_DENIED;
+ goto end2;
}
if (fileref->fcb->ads) {
Status = stream_set_end_of_file_information(Vcb, 0, fileref->fcb, fileref,
false);
if (!NT_SUCCESS(Status)) {
ERR("stream_set_end_of_file_information returned %08lx\n",
Status);
-
- IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
-
- free_fileref(fileref);
-
- return Status;
+ goto end2;
}
} else {
Status = truncate_file(fileref->fcb, 0, Irp, rollback);
if (!NT_SUCCESS(Status)) {
ERR("truncate_file returned %08lx\n", Status);
-
- IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
-
- free_fileref(fileref);
-
- return Status;
+ goto end2;
}
}
@@ -3819,12 +3780,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
if (!NT_SUCCESS(Status)) {
ERR("extend_file returned %08lx\n", Status);
-
- IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
-
- free_fileref(fileref);
-
- return Status;
+ goto end2;
}
}
@@ -3838,12 +3794,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
Status = IoCheckEaBufferValidity(Irp->AssociatedIrp.SystemBuffer,
IrpSp->Parameters.Create.EaLength, &offset);
if (!NT_SUCCESS(Status)) {
ERR("IoCheckEaBufferValidity returned %08lx (error at offset
%lu)\n", Status, offset);
-
- IoRemoveShareAccess(FileObject,
&fileref->fcb->share_access);
-
- free_fileref(fileref);
-
- return Status;
+ goto end2;
}
fileref->fcb->ealen = 4;
@@ -3872,12 +3823,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
fileref->fcb->ea_xattr.Buffer = ExAllocatePoolWithTag(pool_type,
IrpSp->Parameters.Create.EaLength, ALLOC_TAG);
if (!fileref->fcb->ea_xattr.Buffer) {
ERR("out of memory\n");
-
- IoRemoveShareAccess(FileObject,
&fileref->fcb->share_access);
-
- free_fileref(fileref);
-
- return STATUS_INSUFFICIENT_RESOURCES;
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto end2;
}
fileref->fcb->ea_xattr.Length =
fileref->fcb->ea_xattr.MaximumLength =
(USHORT)IrpSp->Parameters.Create.EaLength;
@@ -3914,10 +3861,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
Status = delete_fileref(dc->fileref, NULL, false, NULL,
rollback);
if (!NT_SUCCESS(Status)) {
ERR("delete_fileref returned %08lx\n", Status);
-
- free_fileref(fileref);
-
- return Status;
+ goto end2;
}
}
} else
@@ -3973,11 +3917,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
if (ffei->Flags & FILE_NEED_EA) {
WARN("returning STATUS_ACCESS_DENIED as no EA
knowledge\n");
- IoRemoveShareAccess(FileObject,
&fileref->fcb->share_access);
-
- free_fileref(fileref);
-
- return STATUS_ACCESS_DENIED;
+ Status = STATUS_ACCESS_DENIED;
+ goto end2;
}
if (ffei->NextEntryOffset == 0)
@@ -3994,11 +3935,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
if (!ccb) {
ERR("out of memory\n");
- IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
-
- free_fileref(fileref);
-
- return STATUS_INSUFFICIENT_RESOURCES;
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto end2;
}
RtlZeroMemory(ccb, sizeof(*ccb));
@@ -4076,7 +4014,17 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG
RequestedDisposition, PO
#endif
InterlockedIncrement(&Vcb->open_files);
- return STATUS_SUCCESS;
+ Status = STATUS_SUCCESS;
+
+end2:
+ if (!NT_SUCCESS(Status))
+ IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
+
+end:
+ if (!NT_SUCCESS(Status))
+ free_fileref(fileref);
+
+ return Status;
}
NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
device_extension* Vcb,
diff --git a/drivers/filesystems/btrfs/fileinfo.c b/drivers/filesystems/btrfs/fileinfo.c
index 85006b55fc5..4bebfda1904 100644
--- a/drivers/filesystems/btrfs/fileinfo.c
+++ b/drivers/filesystems/btrfs/fileinfo.c
@@ -5807,7 +5807,7 @@ NTSTATUS __stdcall drv_set_ea(IN PDEVICE_OBJECT DeviceObject, IN
PIRP Irp) {
goto end2;
}
- if (Irp->RequestorMode == KernelMode) {
+ if (Irp->RequestorMode == KernelMode || ccb->access &
FILE_WRITE_ATTRIBUTES) {
RtlCopyMemory(&fcb->inode_item.st_uid, item->value.Buffer,
sizeof(uint32_t));
fcb->sd_dirty = true;
fcb->sd_deleted = false;
@@ -5822,7 +5822,7 @@ NTSTATUS __stdcall drv_set_ea(IN PDEVICE_OBJECT DeviceObject, IN
PIRP Irp) {
goto end2;
}
- if (Irp->RequestorMode == KernelMode)
+ if (Irp->RequestorMode == KernelMode || ccb->access &
FILE_WRITE_ATTRIBUTES)
RtlCopyMemory(&fcb->inode_item.st_gid, item->value.Buffer,
sizeof(uint32_t));
RemoveEntryList(&item->list_entry);
@@ -5834,7 +5834,7 @@ NTSTATUS __stdcall drv_set_ea(IN PDEVICE_OBJECT DeviceObject, IN
PIRP Irp) {
goto end2;
}
- if (Irp->RequestorMode == KernelMode) {
+ if (Irp->RequestorMode == KernelMode || ccb->access &
FILE_WRITE_ATTRIBUTES) {
uint32_t allowed = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP |
S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH | S_ISGID | S_ISVTX | S_ISUID;
uint32_t val;
diff --git a/drivers/filesystems/btrfs/write.c b/drivers/filesystems/btrfs/write.c
index e8e354280c3..0d63ac01cec 100644
--- a/drivers/filesystems/btrfs/write.c
+++ b/drivers/filesystems/btrfs/write.c
@@ -3298,6 +3298,14 @@ NTSTATUS truncate_file(fcb* fcb, uint64_t end, PIRP Irp,
LIST_ENTRY* rollback) {
}
fcb->inode_item.st_blocks += end;
+
+ fcb->inode_item.st_size = end;
+ fcb->inode_item_changed = true;
+ TRACE("setting st_size to %I64x\n", end);
+
+ fcb->Header.AllocationSize.QuadPart =
sector_align(fcb->inode_item.st_size, fcb->Vcb->superblock.sector_size);
+ fcb->Header.FileSize.QuadPart = fcb->inode_item.st_size;
+ fcb->Header.ValidDataLength.QuadPart = fcb->inode_item.st_size;
}
ExFreePool(buf);